[c5c522c] | 1 | #!/bin/sh |
---|
| 2 | |
---|
| 3 | # Slackware build script for libffi |
---|
| 4 | |
---|
| 5 | # Copyright 2011,2012 Robby Workman, Northport, Alabama, USA |
---|
| 6 | # Copyright 2012, 2013 Patrick J. Volkerding, Sebeka, MN, USA |
---|
| 7 | # All rights reserved. |
---|
| 8 | # |
---|
| 9 | # Redistribution and use of this script, with or without modification, is |
---|
| 10 | # permitted provided that the following conditions are met: |
---|
| 11 | # |
---|
| 12 | # 1. Redistributions of this script must retain the above copyright |
---|
| 13 | # notice, this list of conditions and the following disclaimer. |
---|
| 14 | # |
---|
| 15 | # THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED |
---|
| 16 | # WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
---|
| 17 | # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO |
---|
| 18 | # EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
---|
| 19 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
---|
| 20 | # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; |
---|
| 21 | # OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
---|
| 22 | # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR |
---|
| 23 | # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF |
---|
| 24 | # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
---|
| 25 | |
---|
| 26 | PKGNAM=libffi |
---|
| 27 | VERSION=${VERSION:-$(echo $PKGNAM-*.tar.?z* | rev | cut -f 3- -d . | cut -f 1 -d - | rev)} |
---|
| 28 | BUILD=${BUILD:-1} |
---|
| 29 | |
---|
| 30 | # Automatically determine the architecture we're building on: |
---|
| 31 | if [ -z "$ARCH" ]; then |
---|
| 32 | case "$(uname -m)" in |
---|
| 33 | i?86) ARCH=i486 ;; |
---|
| 34 | arm*) readelf /usr/bin/file -A | egrep -q "Tag_CPU.*[4,5]" && ARCH=arm || ARCH=armv7hl ;; |
---|
| 35 | # Unless $ARCH is already set, use uname -m for all other archs: |
---|
| 36 | *) ARCH=$(uname -m) ;; |
---|
| 37 | esac |
---|
| 38 | export ARCH |
---|
| 39 | fi |
---|
| 40 | |
---|
| 41 | CWD=$(pwd) |
---|
| 42 | TMP=${TMP:-/tmp} |
---|
| 43 | PKG=$TMP/package-$PKGNAM |
---|
| 44 | |
---|
| 45 | if [ "$ARCH" = "i486" ]; then |
---|
| 46 | SLKCFLAGS="-O2 -march=i486 -mtune=i686" |
---|
| 47 | LIBDIRSUFFIX="" |
---|
| 48 | elif [ "$ARCH" = "i686" ]; then |
---|
| 49 | SLKCFLAGS="-O2 -march=i686 -mtune=i686" |
---|
| 50 | LIBDIRSUFFIX="" |
---|
| 51 | elif [ "$ARCH" = "x86_64" ]; then |
---|
| 52 | SLKCFLAGS="-O2 -fPIC" |
---|
| 53 | LIBDIRSUFFIX="64" |
---|
| 54 | else |
---|
| 55 | SLKCFLAGS="-O2" |
---|
| 56 | LIBDIRSUFFIX="" |
---|
| 57 | fi |
---|
| 58 | |
---|
| 59 | rm -rf $PKG |
---|
| 60 | mkdir -p $TMP $PKG |
---|
| 61 | cd $TMP |
---|
| 62 | rm -rf $PKGNAM-$VERSION |
---|
| 63 | tar xvf $CWD/$PKGNAM-$VERSION.tar.xz || exit 1 |
---|
| 64 | cd $PKGNAM-$VERSION |
---|
| 65 | |
---|
| 66 | zcat $CWD/libffi.includedir.diff.gz | patch -p1 --verbose || exit 1 |
---|
| 67 | |
---|
| 68 | chown -R root:root . |
---|
| 69 | find . \ |
---|
| 70 | \( -perm 777 -o -perm 775 -o -perm 711 -o -perm 555 -o -perm 511 \) \ |
---|
| 71 | -exec chmod 755 {} \; -o \ |
---|
| 72 | \( -perm 666 -o -perm 664 -o -perm 600 -o -perm 444 -o -perm 440 -o -perm 400 \) \ |
---|
| 73 | -exec chmod 644 {} \; |
---|
| 74 | |
---|
| 75 | CFLAGS="$SLKCFLAGS" \ |
---|
| 76 | CXXFLAGS="$SLKCFLAGS" \ |
---|
| 77 | ./configure \ |
---|
| 78 | --prefix=/usr \ |
---|
| 79 | --libdir=/usr/lib${LIBDIRSUFFIX} \ |
---|
| 80 | --sysconfdir=/etc \ |
---|
| 81 | --localstatedir=/var \ |
---|
| 82 | --mandir=/usr/man \ |
---|
| 83 | --infodir=/usr/info \ |
---|
| 84 | --docdir=/usr/doc/$PKGNAM-$VERSION \ |
---|
| 85 | --disable-static \ |
---|
| 86 | --build=$ARCH-slackware-linux || exit 1 |
---|
| 87 | |
---|
| 88 | make || exit 1 |
---|
| 89 | make install DESTDIR=$PKG || exit 1 |
---|
| 90 | |
---|
| 91 | # Strip binaries: |
---|
| 92 | ( cd $PKG |
---|
| 93 | find . | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null |
---|
| 94 | find . | xargs file | grep "shared object" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null |
---|
| 95 | ) |
---|
| 96 | |
---|
| 97 | # Compress and if needed symlink the man pages: |
---|
| 98 | if [ -d $PKG/usr/man ]; then |
---|
| 99 | ( cd $PKG/usr/man |
---|
| 100 | for manpagedir in $(find . -type d -name "man*") ; do |
---|
| 101 | ( cd $manpagedir |
---|
| 102 | for eachpage in $( find . -type l -maxdepth 1) ; do |
---|
| 103 | ln -s $( readlink $eachpage ).gz $eachpage.gz |
---|
| 104 | rm $eachpage |
---|
| 105 | done |
---|
| 106 | gzip -9 *.? |
---|
| 107 | ) |
---|
| 108 | done |
---|
| 109 | ) |
---|
| 110 | fi |
---|
| 111 | |
---|
| 112 | # Compress info files, if any: |
---|
| 113 | if [ -d $PKG/usr/info ]; then |
---|
| 114 | ( cd $PKG/usr/info |
---|
| 115 | rm -f dir |
---|
| 116 | gzip -9 * |
---|
| 117 | ) |
---|
| 118 | fi |
---|
| 119 | |
---|
| 120 | mkdir -p $PKG/usr/doc/$PKGNAM-$VERSION |
---|
| 121 | cp -a LICENSE README $PKG/usr/doc/$PKGNAM-$VERSION |
---|
| 122 | |
---|
| 123 | # If there's a ChangeLog, installing at least part of the recent history |
---|
| 124 | # is useful, but don't let it get totally out of control: |
---|
| 125 | if [ -r ChangeLog ]; then |
---|
| 126 | DOCSDIR=$(echo $PKG/usr/doc/${PKGNAM}-$VERSION) |
---|
| 127 | cat ChangeLog | head -n 1000 > $DOCSDIR/ChangeLog |
---|
| 128 | touch -r ChangeLog $DOCSDIR/ChangeLog |
---|
| 129 | fi |
---|
| 130 | |
---|
| 131 | mkdir -p $PKG/install |
---|
| 132 | cat $CWD/slack-desc > $PKG/install/slack-desc |
---|
| 133 | |
---|
| 134 | cd $PKG |
---|
| 135 | /sbin/makepkg -l y -c n $TMP/$PKGNAM-$VERSION-$ARCH-$BUILD.txz |
---|