#!/bin/sh

[ -z $PREPKG ] && exit 1

PACKAGE=nvclock
VERSION=0.8b3a
FILES=$(cd $(dirname $0) ; pwd)

# notes:
# - autogen.sh not required. skip it & all is well
# - nvclock_qt allegedly built by default without '--enable-qt'. LIES!
#   brute force workaround: explicitly enable building of gtk & qt bins
# - 'make -j N' is broken. use single jobs only

mkdir -p \
  $PREPKG/{install,usr/doc/$PACKAGE-$VERSION}/

chown -R \
  root:root .
./configure \
  --prefix=/usr \
  --enable-gtk \
  --enable-qt \
  --build=i486-slackware-linux &> configure.output || exit 1
sed -i 's,cp ,cp -p ,g' Makefile || exit 1
make &> make.output || exit 1
make prefix=$PREPKG/usr install &> make_install.output || exit 1

# this isn't debian, dammit
rm -rf \
  $PREPKG/usr/share/doc/

cp -p \
  ABOUT AUTHORS COPYING ChangeLog FAQ 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
