#!/bin/sh

[ -z $PREPKG ] && exit 1

PACKAGE=inotify-tools
VERSION=3.13
FILES=/pub/linux/software/source/$PACKAGE

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

chmod -R go-w .
chown -R root:root .
CFLAGS="-O2 -march=i486 -mtune=i686" \
  ./configure \
  --prefix=/usr \
  --datarootdir=/usr \
  --disable-static \
  --build=i486-slackware-linux &> configure.output || exit 1
make $MAKEJOBS &> make.output || exit 1
make DESTDIR=$PREPKG install &> make_install.output || exit 1

# remove api docs. no static lib included, so they're pointless
rm -rf $PREPKG/usr/doc/$PACKAGE/

cp -p AUTHORS COPYING ChangeLog NEWS 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
