#!/bin/sh

[ -z $PREPKG ] && exit 1

PACKAGE=balance
VERSION=3.35
FILES=$(cd $(dirname $0) ; pwd)

mkdir -p $PREPKG/{install,usr/{doc/$PACKAGE-$VERSION,man/man1,sbin}}/

chmod -R u+w .
chown -R root:root .
make $MAKEJOBS &> make.output || exit 1
make DESTDIR=$PREPKG install &> make_install.output || exit 1

# tidy up
chmod a-x $PREPKG/usr/man/man1/balance.1

chown -R root:bin $PREPKG/usr/sbin/
cp -p COPYING README \
  $PREPKG/usr/doc/$PACKAGE-$VERSION/
gzip -r9 $PREPKG/usr/man/

cp $FILES/slack-desc $PREPKG/install/

find $PREPKG -exec file {} \; \
  | awk -F : '/ ELF / {print $1}' \
  | xargs strip -p --strip-unneeded
