[cbeb6d3] | 1 | #!/bin/sh |
---|
| 2 | |
---|
| 3 | # Copyright 2005-2014 Patrick J. Volkerding, Sebeka, Minnesota, USA |
---|
| 4 | # All rights reserved. |
---|
| 5 | # |
---|
| 6 | # Redistribution and use of this script, with or without modification, is |
---|
| 7 | # permitted provided that the following conditions are met: |
---|
| 8 | # |
---|
| 9 | # 1. Redistributions of this script must retain the above copyright |
---|
| 10 | # notice, this list of conditions and the following disclaimer. |
---|
| 11 | # |
---|
| 12 | # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED |
---|
| 13 | # WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
---|
| 14 | # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO |
---|
| 15 | # EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
---|
| 16 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
---|
| 17 | # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; |
---|
| 18 | # OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
---|
| 19 | # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR |
---|
| 20 | # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF |
---|
| 21 | # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
---|
| 22 | |
---|
| 23 | PKGNAM=gawk |
---|
| 24 | VERSION=${VERSION:-$(echo $PKGNAM-*.tar.xz | rev | cut -f 3- -d . | cut -f 1 -d - | rev)} |
---|
| 25 | BUILD=${BUILD:-2} |
---|
| 26 | |
---|
| 27 | NUMJOBS=${NUMJOBS:--j6} |
---|
| 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 | CWD=$(pwd) |
---|
| 40 | TMP=${TMP:-/tmp} |
---|
| 41 | PKG=$TMP/package-gawk |
---|
| 42 | |
---|
| 43 | if [ "$ARCH" = "i586" ]; then |
---|
| 44 | SLKCFLAGS="-O2 -march=i586 -mtune=i686" |
---|
| 45 | LIBDIRSUFFIX="" |
---|
| 46 | elif [ "$ARCH" = "s390" ]; then |
---|
| 47 | SLKCFLAGS="-O2" |
---|
| 48 | LIBDIRSUFFIX="" |
---|
| 49 | elif [ "$ARCH" = "x86_64" ]; then |
---|
| 50 | SLKCFLAGS="-O2 -fPIC" |
---|
| 51 | LIBDIRSUFFIX="64" |
---|
| 52 | else |
---|
| 53 | SLKCFLAGS="-O2" |
---|
| 54 | LIBDIRSUFFIX="" |
---|
| 55 | fi |
---|
| 56 | |
---|
| 57 | rm -rf $PKG |
---|
| 58 | mkdir -p $TMP $PKG |
---|
| 59 | |
---|
| 60 | cd $TMP |
---|
| 61 | rm -rf gawk-$VERSION |
---|
| 62 | tar xvf $CWD/gawk-$VERSION.tar.xz |
---|
| 63 | cd gawk-$VERSION |
---|
| 64 | |
---|
| 65 | chown -R root:root . |
---|
| 66 | |
---|
| 67 | find . \ |
---|
| 68 | \( -perm 777 -o -perm 775 -o -perm 711 -o -perm 555 -o -perm 511 \) \ |
---|
| 69 | -exec chmod 755 {} \; -o \ |
---|
| 70 | \( -perm 666 -o -perm 664 -o -perm 600 -o -perm 444 -o -perm 440 -o -perm 400 \) \ |
---|
| 71 | -exec chmod 644 {} \; |
---|
| 72 | |
---|
| 73 | CFLAGS="$SLKCFLAGS" \ |
---|
| 74 | ./configure \ |
---|
| 75 | --prefix=/usr \ |
---|
| 76 | --libdir=/usr/lib${LIBDIRSUFFIX} \ |
---|
| 77 | --mandir=/usr/man \ |
---|
| 78 | --infodir=/usr/info \ |
---|
| 79 | --build=$ARCH-slackware-linux |
---|
| 80 | |
---|
| 81 | make $NUMJOBS || make || exit 1 |
---|
| 82 | make install DESTDIR=$PKG || exit 1 |
---|
| 83 | |
---|
| 84 | ( cd $PKG |
---|
| 85 | find . | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | \ |
---|
| 86 | xargs strip --strip-unneeded 2> /dev/null |
---|
| 87 | find . | xargs file | grep "shared object" | grep ELF | cut -f 1 -d : | \ |
---|
| 88 | xargs strip --strip-unneeded 2> /dev/null |
---|
| 89 | ) |
---|
| 90 | |
---|
| 91 | ( cd $PKG/usr/bin |
---|
| 92 | ln -sf gawk-$VERSION gawk |
---|
| 93 | ) |
---|
| 94 | |
---|
| 95 | mkdir -p $PKG/bin |
---|
| 96 | mv $PKG/usr/bin/gawk* $PKG/bin |
---|
| 97 | mv $PKG/usr/bin/awk $PKG/bin |
---|
| 98 | |
---|
| 99 | ( cd $PKG/usr/bin |
---|
| 100 | ln -sf ../../bin/awk . |
---|
| 101 | ln -sf ../../bin/gawk . |
---|
| 102 | ln -sf ../../bin/gawk-$VERSION . |
---|
| 103 | ) |
---|
| 104 | |
---|
| 105 | ( cd $PKG/usr/info |
---|
| 106 | rm dir |
---|
| 107 | gzip -9 * |
---|
| 108 | ) |
---|
| 109 | |
---|
| 110 | ( cd $PKG/usr/man/man1 |
---|
| 111 | ln -sf gawk.1 awk.1 |
---|
| 112 | ) |
---|
| 113 | |
---|
| 114 | # Compress manual pages: |
---|
| 115 | find $PKG/usr/man -type f -exec gzip -9 {} \; |
---|
| 116 | for i in $( find $PKG/usr/man -type l ) ; do |
---|
| 117 | ln -s $( readlink $i ).gz $i.gz |
---|
| 118 | rm $i |
---|
| 119 | done |
---|
| 120 | |
---|
| 121 | mkdir -p $PKG/usr/doc/gawk-$VERSION |
---|
| 122 | cp -a \ |
---|
| 123 | ABOUT-NLS AUTHORS COPYING* INSTALL NEWS POSIX.STD \ |
---|
| 124 | README* \ |
---|
| 125 | $PKG/usr/doc/gawk-$VERSION |
---|
| 126 | |
---|
| 127 | # We don't need to run the GPL: |
---|
| 128 | chmod 644 $PKG/usr/doc/gawk-$VERSION/COPYING* |
---|
| 129 | |
---|
| 130 | # If there's a ChangeLog, installing at least part of the recent history |
---|
| 131 | # is useful, but don't let it get totally out of control: |
---|
| 132 | if [ -r ChangeLog ]; then |
---|
| 133 | DOCSDIR=$(echo $PKG/usr/doc/*-$VERSION) |
---|
| 134 | cat ChangeLog | head -n 1000 > $DOCSDIR/ChangeLog |
---|
| 135 | touch -r ChangeLog $DOCSDIR/ChangeLog |
---|
| 136 | fi |
---|
| 137 | |
---|
| 138 | mkdir -p $PKG/install |
---|
| 139 | cat $CWD/slack-desc > $PKG/install/slack-desc |
---|
| 140 | |
---|
| 141 | # Build the package: |
---|
| 142 | cd $PKG |
---|
| 143 | /sbin/makepkg -l y -c n $TMP/gawk-$VERSION-$ARCH-$BUILD.txz |
---|
| 144 | |
---|