#!/bin/sh
PRGNAM=tqtinterface
CWD=`pwd`
TMP=${TMP:-/tmp}
PKG=$TMP/package-$PRGNAM
OUTPUT=$CWD

# Set the config option variables if they are not already set:
if [ -r ./KDE.options ]; then
  . ./KDE.options
fi

rm -rf $PKG
rm -fr $TMP/$PRGNAM*
mkdir -p $PKG/usr

# Avoid a version number in .la files:
if [ -d /usr/lib/qt ]; then
  QTDIR=/usr/lib/qt
fi

echo "Building $PRGNAM-$VERSION."
echo
echo "Copying svn dependencies to build environment..."
# Source files from Trinity are already unpacked. Just copy to $TMP.
echo "Copying $PRGNAM source files to $TMP..."
cp -a src/dependencies $TMP/
cp -a src/hooks $TMP/
cd $TMP/dependencies/$PRGNAM || exit 1
echo

echo "Building make and config files..."
echo
cp -Rp /usr/lib/build/libtool.m4 file> admin/libtool.m4.in
cp -Rp /usr/lib/build/ltmain.sh file> admin/ltmain.sh
make -f admin/Makefile.common
echo
echo "Finished building make and config files."
echo

chown -R root:root .
# ./configure --help

CFLAGS=$CPUOPT \
CXXFLAGS=$CPUOPT \
./configure \
  --prefix=/usr \
  --sysconfdir=/etc/kde \
  --program-prefix="" \
  --program-suffix=""

make || exit 1
exit
make install DESTDIR=$PKG

cd $PKG
makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD.tgz

# cleanup
#rm -rf $TMP/$PRGNAM*
#rm -rf $PKG
