[c5c522c] | 1 | #!/bin/sh |
---|
| 2 | |
---|
| 3 | # Heavily based on the Slackware 14.1 SlackBuild |
---|
| 4 | # Written by miklos < ardutu at gmail dot com > |
---|
| 5 | |
---|
| 6 | # Slackware build script for libbsd |
---|
| 7 | # Official Site: http://libbsd.freedesktop.org/wiki |
---|
| 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 | # Requirements: |
---|
| 27 | |
---|
| 28 | PKGNAME=libbsd |
---|
| 29 | VERSION=${VERSION:-0.6.0} |
---|
| 30 | ARCH=${ARCH:-$(uname -m)} |
---|
| 31 | BUILD=${BUILD:-1} |
---|
| 32 | TAG=${TAG:-sl} |
---|
| 33 | SOURCE="http://libbsd.freedesktop.org/releases/${PKGNAME}-${VERSION}.tar.xz" |
---|
| 34 | TAR= |
---|
| 35 | DIR= |
---|
| 36 | DOCS="COPYING ChangeLog README TODO" |
---|
| 37 | SLKFILES= |
---|
| 38 | |
---|
| 39 | # Automatically determine the architecture we're building on: |
---|
| 40 | case "$ARCH" in |
---|
| 41 | i?86) export ARCH=i486; SLKCFLAGS="-O2 -march=i486 -mtune=i686"; CHOST="i486-slackware-linux" ;; |
---|
| 42 | x86_64) SLKCFLAGS="-O2 -fPIC"; LIBDIRSUFFIX="64"; CHOST="x86_64-slackware-linux" ;; |
---|
| 43 | arm*) export ARCH=arm; SLKCFLAGS="-O2 -march=armv5te"; CHOST="arm-slackware-linux-gnueabi" ;; |
---|
| 44 | # Unless $ARCH is already set, use uname -m for all other archs: |
---|
| 45 | *) export ARCH=$( uname -m ) ;; |
---|
| 46 | esac |
---|
| 47 | |
---|
| 48 | # Do not touch following if not needed |
---|
| 49 | JOBS=${JOBS:--j2} |
---|
| 50 | CWD=$(pwd) |
---|
| 51 | TMP=${TMP:-/tmp/buildpkgs/$PKGNAME} |
---|
| 52 | PKG=$TMP/package-$PKGNAME |
---|
| 53 | OUTPUT=${OUTPUT:-$CWD} |
---|
| 54 | TAR=${TAR:-$(basename $SOURCE)} |
---|
| 55 | DIR=${DIR:-$(echo "$TAR"|sed -r 's/(\.tar|)(.gz|.bz2|.xz|.tgz|)$//')} |
---|
| 56 | |
---|
| 57 | if [ ! -e $CWD/$TAR ];then |
---|
| 58 | wget --no-check-certificate $SOURCE -O "$CWD/$TAR" |
---|
| 59 | fi |
---|
| 60 | |
---|
| 61 | ### Preparing Source |
---|
| 62 | rm -rf $TMP |
---|
| 63 | mkdir -p $TMP $PKG $OUTPUT |
---|
| 64 | cd $TMP |
---|
| 65 | tar xvf $CWD/$TAR |
---|
| 66 | cd $DIR |
---|
| 67 | |
---|
| 68 | chown -R root:root . |
---|
| 69 | chmod -R u+w,go+r-w,a-s . |
---|
| 70 | |
---|
| 71 | CFLAGS="$CFLAGS $SLKCFLAGS" \ |
---|
| 72 | CXXFLAGS="$CXXFLAGS $SLKCFLAGS" \ |
---|
| 73 | ./configure \ |
---|
| 74 | --prefix=/usr \ |
---|
| 75 | --libdir=/usr/lib$LIBDIRSUFFIX \ |
---|
| 76 | --docdir=/usr/doc/$PKGNAME-$VERSION \ |
---|
| 77 | --sysconfdir=/etc \ |
---|
| 78 | --localstatedir=/var \ |
---|
| 79 | --mandir=/usr/man \ |
---|
| 80 | --disable-static \ |
---|
| 81 | --build=$CHOST |
---|
| 82 | make $JOBS |
---|
| 83 | make install DESTDIR=$PKG |
---|
| 84 | |
---|
| 85 | # Documentation |
---|
| 86 | mkdir -p $PKG/usr/doc/$PKGNAME-$VERSION |
---|
| 87 | for DC in $DOCS;do |
---|
| 88 | [ -e $DC ] && cp -r $DC $PKG/usr/doc/$PKGNAME-$VERSION/ || true |
---|
| 89 | done |
---|
| 90 | |
---|
| 91 | mkdir -p $PKG/usr/doc/$PKGNAME-$VERSION/SlackBuild |
---|
| 92 | cd $CWD |
---|
| 93 | for SB in $PKGNAME.SlackBuild slack-desc doinst.sh doinst.sh.gz EULA.TXT $SLKFILES;do |
---|
| 94 | [ -e "$SB" ] && cp -r $SB $PKG/usr/doc/$PKGNAME-$VERSION/SlackBuild/$SB || true |
---|
| 95 | done |
---|
| 96 | |
---|
| 97 | for i in man info |
---|
| 98 | do |
---|
| 99 | if [ -d $PKG/usr/$i ]; then |
---|
| 100 | cd $PKG/usr/$i |
---|
| 101 | find . -type f -exec gzip -9 {} \; |
---|
| 102 | for file in $( find . -type l ) ; do ln -s $( readlink $file ).gz $file.gz ; rm $file ; done |
---|
| 103 | [ "$i" == "info" ] && rm -f dir |
---|
| 104 | fi |
---|
| 105 | done |
---|
| 106 | |
---|
| 107 | cd $PKG |
---|
| 108 | find . | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | xargs -r strip --strip-unneeded 2> /dev/null || true |
---|
| 109 | find . | xargs file | grep "shared object" | grep ELF | cut -f 1 -d : | xargs -r strip --strip-unneeded 2> /dev/null || true |
---|
| 110 | find . | xargs file | grep "current ar archive" | cut -f 1 -d : | xargs -r strip --strip-unneeded 2> /dev/null || true |
---|
| 111 | |
---|
| 112 | mkdir -p $PKG/install |
---|
| 113 | cat $CWD/slack-desc > $PKG/install/slack-desc |
---|
| 114 | [ -e $CWD/doinst.sh ] && cat $CWD/doinst.sh > $PKG/install/doinst.sh |
---|
| 115 | [ -e $CWD/doinst.sh.gz ] && zcat $CWD/doinst.sh.gz > $PKG/install/doinst.sh |
---|
| 116 | |
---|
| 117 | cd $PKG |
---|
| 118 | chown -R root:root $PKG |
---|
| 119 | |
---|
| 120 | if [ -x "$(which requiredbuilder 2>/dev/null)" ];then |
---|
| 121 | requiredbuilder -y -v -s $CWD $PKG # add "-c -b" if you have binary files in /usr/share |
---|
| 122 | [ -e install/slack-required ] && cat install/slack-required > $PKG/usr/doc/$PKGNAME-$VERSION/SlackBuild/slack-required |
---|
| 123 | fi |
---|
| 124 | |
---|
| 125 | /sbin/makepkg -l y -c n $OUTPUT/$PKGNAME-$VERSION-$ARCH-$BUILD$TAG.${PKGTYPE:-txz} |
---|
| 126 | |
---|
| 127 | if [ "$1" = "--cleanup" ]; then |
---|
| 128 | rm -rf $TMP |
---|
| 129 | fi |
---|