#!/bin/bash

# brandy.SlackBuild
# by Stuart Winter <mozes@slackware.com>
# 29-Dec-2004

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

# Paths to skeleton port's source & real Slackware source tree:
slackset_var_cwds

# Paths to skeleton port's source & real Slackware source tree:
#export CWD=$SLACKSOURCE/$PKGSERIES/$PKGNAM
#export CWD=$PWD 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

# Extract source:
tar xvvf $PORTCWD/sources/brandy-${VERSION}*tar*
cd MatrixBrandy*/ || failextract
slackhousekeeping

# We want the man page:
tar xvvf $PORTCWD/sources/brandy*debian* || failextract

# Build:
make $NUMJOBS || failmake

# Install into package framework:
mkdir -p $PKG/usr/{bin,man/man1}
install -vpm755 brandy $PKG/usr/bin
install -vpm644 debian/brandy.1 $PKG/usr/man/man1

# Add 'BASIC detokenizer'.  This isn't part of the Brandy package but
# was written to detokenize (turn the BASIC tokens into human readable text).  This
# is especially useful for examining your old BASIC programs on a machine that
# doesn't have a BBC BASIC editor - like Linux for example! :)
xzcat $PORTCWD/bbcbascat.xz > $PKG/usr/bin/bbcbascat
chmod 755 $PKG/usr/bin/bbcbascat

# Install docs:
mkdir -vpm755 $PKG/usr/doc/$PKGNAM-$VERSION
cp -fav COPYING README docs/* \
     $PKG/usr/doc/$PKGNAM-$VERSION

# Apply 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 (root:bin), 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
