#!/bin/bash

# Build a DUMMY svgalib for architectures which do not have SVGA support
# or to which the real svgalib package has not been ported.
# by Stuart Winter <mozes@slackware.com>
# 20-Nov-2004

# Record toolchain & other info for the build log:
slackbuildinfo

# Paths to skeleton port's source & real Slackware source tree:
export CWD=$SLACKSOURCE/$PKGSERIES/$PKGNAM
export PORTCWD=$PWD

# Temporary build locations:
export TMPBUILD=$TMP/build-$PKGNAM
export PKG=$TMP/package-$PKGNAM
mkpkgdirs # Delete & re-create temporary directories then cd into $TMPBUILD

# Determine the CFLAGS for the known architectures:
case $ARCH in
   arm)     export SLKCFLAGS="-O2 -march=armv4t"
            export LIBDIRSUFFIX="" ;;
   *)       export SLKCFLAGS="-O2" ;;
esac 

# Extract source:
tar xvvf $PORTCWD/sources/$PKGNAM-*.tar.gz
cd $PKGNAM-*
slackhousekeeping

# Build:
make $NUMJOBS CC="gcc $SLKCFLAGS" || failmake

# Install:
make install PREFIX=$PKG || failinstall

# Copy some docs:
mkdir -p $PKG/usr/doc/$PKGNAM-$VERSION
install -pm644 debian/README.debian debian/changelog debian/copyright \
               $PKG/usr/doc/$PKGNAM-$VERSION
# Just so it's easier to identify:
( cd $PKG/usr/doc/* && ln -vfs README.debian THIS_IS_A_DUMMY_PACKAGE )

# Insert the package description for the dummy version:
mkdir $PKG/install
install -m644 $PORTCWD/slack-desc.dummy $PKG/install/slack-desc

# If necessary, start the fakeroot server so we can set file/dir ownerships:
start_fakeroot

# Apply generic Slackware packaging policies:
cd $PKG
slackstripall   # strip all .a archives and all ELFs
slackgzpages -i # compress man & info pages and delete usr/info/dir
slackslack      # chown -R root:root, chmod -R og-w, slackchown, slack644docs
slackdesc       # install slack-desc and doinst.sh
slackmp         # run makepkg -l y -c n

# Perform any final checks on the package:
cd $PKG
slackhlinks     # search for any hard links
