This is my version of a Slack Buildscript. I tried to separete the boilerplate code which stays the same in most buildscripts from the part which is really specific to the actual package.
This script is based on the very good howto from rworkman. Howto use a buildscript for Slackware is described here.
#!/bin/sh # Slackware build script for <appname> # Written by Stefan Beckert (becki AT web DOT de) # ==== PACKAGE CONFIGURATION ==== APP='<appname>' VERSION='0.0.0' # The dash character ("-") is not allowed EXT='tar.gz' # Extension of source tarball: tar.gz, tgz, tar.bz2, tbz MAKEINSTALL='install-strip' # make target: install or install-strip # Flags for ./configure: CONFIGFLAGS="\ --prefix=/usr \ --sysconfdir=/etc \ --localstatedir=/var\ --mandir=/usr/man\ " # Provide a function wich copies the necessary docs to the doc directory: # pwd is the sourcecode dir when this function is called function copydocs() { cp -a BUGS Changes FAQ INSTALL LICENSE MANIFEST README TODO docs/ $PKG/usr/doc/$APP-$VERSION # alternatively, if make install has already created # a doc dir somwhere in the package tree: #mv $PKG/usr/share/$APP/docs/* $PKG/usr/doc/$APP-$VERSION #rmdir $PKG/usr/share/$APP/docs/ } # ==== PACKAGE INDEPENDENT STUFF ==== ARCH=${ARCH:-i486} # respcets possibly existing environment variable BUILD=${BUILD:-1} # - " - TAG=${TAG:-_SBo} # - " - TMP=${TMP:-/tmp/SBo} # - " - CWD=$(pwd) PKG=$TMP/package-$APP # directory structure of package will be created here # set compiler flags: (http://linuxreviews.org/howtos/compiling/) if [ "$ARCH" = "i386" ] || [ "$ARCH" = "i486" ] || [ "$ARCH" = "i686" ]; then SLKCFLAGS="-O2 -march=$ARCH -mtune=i686" elif [ "$ARCH" = "x86_64" ]; then SLKCFLAGS="-O2 -fPIC" else echo "Error: ARCH $ARCH is not supported!"; exit 1 fi # get proper extract command: if [ "$EXT" = 'tgz' ] || [ "$EXT" = 'tar.gz' ]; then TAROPTS='xzf' elif [ "$EXT" = 'tbz' ] || [ "$EXT" = 'tar.bz2' ]; then TAROPTS='xjf' else echo "Error: Package format $EXT is not supported!"; exit 1 fi # cleanup & prepare: rm -rf $PKG # remove old package structure rm -rf $TMP/$APP-$VERSION # remove old source directory if [ ! -d $TMP ]; then mkdir -p $TMP; fi mkdir -p $PKG # extract source: cd $TMP || exit 1 tar -$TAROPTS $CWD/$APP-$VERSION.$EXT || exit 1 # Extract source in TMP cd $APP-$VERSION || exit 1 chown -R root:root . chmod -R u+w,go+r-w,a-s . # run configure script: CFLAGS="$SLKCFLAGS" CXXFLAGS="$SLKCFLAGS" ./configure $CONFIGFLAGS || exit 1 # compile the source: make || exit 1 # Install everything into the package directory: make $MAKEINSTALL DESTDIR=$PKG || exit 1 # copy docs: mkdir -p $PKG/usr/doc/$APP-$VERSION copydocs # package specific function find $PKG/usr/doc/$APP-$VERSION -type f -exec chmod 644 {} \; # fill slack install directory: mkdir -p $PKG/install cat $CWD/slack-desc > $PKG/install/slack-desc if [ -e $CWD/doinst.sh ]; then cat $CWD/doinst.sh > $PKG/install/doinst.sh fi # Compress man pages if they exist if [ -d $PKG/usr/man ]; then ( cd $PKG/usr/man find . -type f -exec gzip -9 {} \; for i in $(find . -type l) ; do ln -s $(readlink $i).gz $i.gz ; rm $i ; done ) fi # Compress info pages if they exist (and remove the dir file) if [ -d $PKG/usr/info ]; then gzip -9 $PKG/usr/info/*.info rm -f $PKG/usr/info/dir fi # Build the Package: cd $PKG /sbin/makepkg -l y -c n $TMP/$APP-$VERSION-$ARCH-$BUILD$TAG.tgz