1 | #!/bin/sh |
---|
2 | |
---|
3 | # Copyright 2013, 2014, 2015 Patrick J. Volkerding, Sebeka, MN, USA |
---|
4 | # Copyright 2014 Heinz Wiesinger, Amsterdam, NL |
---|
5 | # All rights reserved. |
---|
6 | # |
---|
7 | # Redistribution and use of this script, with or without modification, is |
---|
8 | # permitted provided that the following conditions are met: |
---|
9 | # |
---|
10 | # 1. Redistributions of this script must retain the above copyright |
---|
11 | # notice, this list of conditions and the following disclaimer. |
---|
12 | # |
---|
13 | # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED |
---|
14 | # WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
---|
15 | # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO |
---|
16 | # EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
---|
17 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
---|
18 | # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; |
---|
19 | # OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
---|
20 | # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR |
---|
21 | # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF |
---|
22 | # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
---|
23 | |
---|
24 | |
---|
25 | PKGNAM=gc |
---|
26 | VERSION=${VERSION:-$(echo $PKGNAM-*.tar.xz | rev | cut -f 3- -d . | cut -f 1 -d - | rev)} |
---|
27 | BUILD=${BUILD:-3} |
---|
28 | |
---|
29 | # Automatically determine the architecture we're building on: |
---|
30 | if [ -z "$ARCH" ]; then |
---|
31 | case "$( uname -m )" in |
---|
32 | i?86) export ARCH=i586 ;; |
---|
33 | arm*) export ARCH=arm ;; |
---|
34 | # Unless $ARCH is already set, use uname -m for all other archs: |
---|
35 | *) export ARCH=$( uname -m ) ;; |
---|
36 | esac |
---|
37 | fi |
---|
38 | |
---|
39 | NUMJOBS=${NUMJOBS:-" -j7 "} |
---|
40 | |
---|
41 | CWD=$(pwd) |
---|
42 | TMP=${TMP:-/tmp} |
---|
43 | PKG=$TMP/package-$PKGNAM |
---|
44 | rm -rf $PKG |
---|
45 | mkdir -p $PKG/usr |
---|
46 | |
---|
47 | if [ "$ARCH" = "i586" ]; then |
---|
48 | SLKCFLAGS="-O2 -march=i586 -mtune=i686" |
---|
49 | LIBDIRSUFFIX="" |
---|
50 | elif [ "$ARCH" = "s390" ]; then |
---|
51 | SLKCFLAGS="-O2" |
---|
52 | LIBDIRSUFFIX="" |
---|
53 | elif [ "$ARCH" = "x86_64" ]; then |
---|
54 | SLKCFLAGS="-O2 -fPIC" |
---|
55 | LIBDIRSUFFIX="64" |
---|
56 | else |
---|
57 | SLKCFLAGS="-O2" |
---|
58 | LIBDIRSUFFIX="" |
---|
59 | fi |
---|
60 | |
---|
61 | cd $TMP |
---|
62 | rm -rf $PKGNAM-$VERSION $PKGNAM-$(echo $VERSION | cut -b 1-3) |
---|
63 | tar xvf $CWD/$PKGNAM-$VERSION.tar.xz || exit 1 |
---|
64 | cd $PKGNAM-$VERSION 2> /dev/null || cd $PKGNAM-$(echo $VERSION | cut -b 1-3) || exit 1 |
---|
65 | tar xvf $CWD/libatomic_ops-$VERSION.tar.xz || exit 1 |
---|
66 | mv libatomic_ops-$VERSION libatomic_ops |
---|
67 | chown -R root:root . |
---|
68 | find . \ |
---|
69 | \( -perm 777 -o -perm 775 -o -perm 711 -o -perm 555 -o -perm 511 \) \ |
---|
70 | -exec chmod 755 {} \; -o \ |
---|
71 | \( -perm 666 -o -perm 664 -o -perm 600 -o -perm 444 -o -perm 440 -o -perm 400 \) \ |
---|
72 | -exec chmod 644 {} \; |
---|
73 | |
---|
74 | # https://github.com/ivmai/bdwgc/pull/51 |
---|
75 | zcat $CWD/noelision.patch.gz | patch -p1 --verbose || exit 1 |
---|
76 | |
---|
77 | # Guarding GC_setup_mark_lock usage with PARALLEL_MARK is required to avoid |
---|
78 | # an undefined reference in non-PARALLEL_MARK configurations: |
---|
79 | zcat $CWD/refer_to_GC_setup_mark_lock_only_in_PARALLEL_MARK_code.patch.gz | patch -p0 --verbose || exit 1 |
---|
80 | |
---|
81 | sed -i 's#pkgdata#doc#' doc/doc.am |
---|
82 | sed -i 's#pkgdata#doc#' libatomic_ops/Makefile.am |
---|
83 | sed -i 's#pkgdata#doc#' libatomic_ops/doc/Makefile.am |
---|
84 | |
---|
85 | autoreconf -vif |
---|
86 | automake --add-missing |
---|
87 | |
---|
88 | # See bugzilla.redhat.com/689877 for -DUSE_GET_STACKBASE_FOR_MAIN |
---|
89 | |
---|
90 | CFLAGS="$SLKCFLAGS -DUSE_GET_STACKBASE_FOR_MAIN" \ |
---|
91 | ./configure \ |
---|
92 | --prefix=/usr \ |
---|
93 | --libdir=/usr/lib${LIBDIRSUFFIX} \ |
---|
94 | --infodir=/usr/info \ |
---|
95 | --mandir=/usr/man \ |
---|
96 | --disable-dependency-tracking \ |
---|
97 | --enable-cplusplus \ |
---|
98 | --enable-large-config \ |
---|
99 | --enable-parallel-mark \ |
---|
100 | --enable-threads=posix \ |
---|
101 | --with-libatomic-ops=no \ |
---|
102 | --build=$ARCH-slackware-linux |
---|
103 | |
---|
104 | # NOTE: Using --disable-static exports a subset of symbols, and has caused |
---|
105 | # some things that use gc to break. So it is recommended to build the static |
---|
106 | # libraries and then remove them before packaging. |
---|
107 | |
---|
108 | # Does not like parallel make... |
---|
109 | make $NUMJOBS || make || exit 1 |
---|
110 | make install DESTDIR=$PKG || exit 1 |
---|
111 | |
---|
112 | mkdir -p $PKG/usr/man/man3 |
---|
113 | sed -i -e 's/GC_MALLOC 1L/gc 3/' doc/gc.man |
---|
114 | install -m 644 doc/gc.man $PKG/usr/man/man3/gc.3 |
---|
115 | |
---|
116 | # Install libatomic_ops |
---|
117 | cd libatomic_ops |
---|
118 | make install DESTDIR=$PKG || exit 1 |
---|
119 | cd - |
---|
120 | |
---|
121 | # Remove static libraries that we don't want in the package, and fix the |
---|
122 | # .la files to remove the references to them: |
---|
123 | ( cd $PKG/usr/lib${LIBDIRSUFFIX} |
---|
124 | for static in libcord libgc libgccpp ; do |
---|
125 | rm --verbose ${static}.a |
---|
126 | sed -i "s#old_library='.*'#old_library=''#g" ${static}.la |
---|
127 | done |
---|
128 | ) |
---|
129 | |
---|
130 | find $PKG | xargs file | grep -e "executable" -e "shared object" | grep ELF \ |
---|
131 | | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null |
---|
132 | |
---|
133 | # Compress and link manpages, if any: |
---|
134 | if [ -d $PKG/usr/man ]; then |
---|
135 | ( cd $PKG/usr/man |
---|
136 | for manpagedir in $(find . -type d -name "man*") ; do |
---|
137 | ( cd $manpagedir |
---|
138 | for eachpage in $( find . -type l -maxdepth 1) ; do |
---|
139 | ln -s $( readlink $eachpage ).gz $eachpage.gz |
---|
140 | rm $eachpage |
---|
141 | done |
---|
142 | gzip -9 *.? |
---|
143 | ) |
---|
144 | done |
---|
145 | ) |
---|
146 | fi |
---|
147 | |
---|
148 | mkdir -p $PKG/usr/doc/$PKGNAM-$VERSION |
---|
149 | mv $PKG/usr/share/doc/* $PKG/usr/doc/$PKGNAM-$VERSION/ |
---|
150 | rm -f $PKG/usr/doc/$PKGNAM-$VERSION/gc/gc.man |
---|
151 | rm -rf $PKG/usr/share |
---|
152 | cp -a \ |
---|
153 | README.QUICK TODO \ |
---|
154 | $PKG/usr/doc/$PKGNAM-$VERSION |
---|
155 | |
---|
156 | mkdir -p $PKG/install |
---|
157 | cat $CWD/slack-desc > $PKG/install/slack-desc |
---|
158 | |
---|
159 | cd $PKG |
---|
160 | /sbin/makepkg -l y -c n $TMP/$PKGNAM-$VERSION-$ARCH-$BUILD.txz |
---|
161 | |
---|