#!/bin/sh
# Set initial variables:
PKGNAM=most
VERSION=4.10.2
BUILD=2

. /etc/pkghelpers
pkghelpers_env

rm -rf $PKG
mkdir -p $PKG

cd $TMP
rm -rf most-$VERSION
tar xjvf $CWD/most-$VERSION.tar.bz2
cd most-$VERSION
chown -R root:root .
find . -perm 664 -exec chmod 644 {} \;
find . -perm 600 -exec chmod 644 {} \;
find . -perm 444 -exec chmod 644 {} \;
find . -perm 400 -exec chmod 644 {} \;
find . -perm 440 -exec chmod 644 {} \;
find . -perm 777 -exec chmod 755 {} \;
find . -perm 775 -exec chmod 755 {} \;
find . -perm 511 -exec chmod 755 {} \;
find . -perm 711 -exec chmod 755 {} \;
find . -perm 555 -exec chmod 755 {} \;
CFLAGS="$SLKCFLAGS" \
./configure --prefix=/usr --with-slanglib=/usr/lib$LIBSUFFIX
make -j12 || exit 1
make install DESTDIR=$PKG
mv $PKG/usr/doc/most $PKG/usr/doc/most-$VERSION
for file in $PKG/usr/doc/most-$VERSION/* ; do
  if [ -r `basename $file` ]; then
    cp -a `basename $file` $file
  fi
done
mkdir -p $PKG/install
cat $CWD/slack-desc > $PKG/install/slack-desc

# Build the package:
cd $PKG
pkghelpers_fixup
pkghelpers_makepkg