#!/bin/sh

# Slackware build script for libcap

# Written by Menno Duursma

# This program is free software. It comes without any warranty.
# Granted WTFPL, Version 2, as published by Sam Hocevar. See
# http://sam.zoy.org/wtfpl/COPYING for more details.

PKGNAM=libcap
VERSION=2.16
BUILD=${BUILD:-1}

. /etc/pkghelpers
pkghelpers_env

rm -rf $PKG
mkdir -p $TMP $PKG
cd $TMP 
rm -rf $PKGNAM-$VERSION
tar xvf $CWD/$PKGNAM-$VERSION.tar.bz2
cd $PKGNAM-$VERSION || exit 1
pkghelpers_permissions

# Set the CFLAGS
sed -i.orig "s/^\(DEBUG =\).*/\1$SLKCFLAGS/" Make.Rules

make DYNAMIC=yes
make install FAKEROOT=$PKG man_prefix=/usr
chmod 755 $PKG/lib$LIBSUFFIX/libcap.so*

# Add included scripts
( cd contrib || exit 1
  for file in pcaps4convenience pcaps4server pcaps4suid0 ; do
    install -m 0755 -D $file $PKG/usr/sbin/$file
  done
)

# glibc already has the capget/capset manpage
rm -rf $PKG/usr/man/man2

mkdir -p $PKG/usr/doc/$PKGNAM-$VERSION
cp -a \
  CHANGELOG License README License pgp.keys.asc doc/capability.notes \
  progs/quicktest.sh $CWD/capfaq-0.2.txt $CWD/README.SLACKWARE \
  $PKG/usr/doc/$PKGNAM-$VERSION
chown -R root:root $PKG/usr/doc
find $PKG/usr/doc -type f -exec chmod 644 {} \;

mkdir -p $PKG/install
cat $CWD/slack-desc > $PKG/install/slack-desc

cd $PKG
pkghelpers_fixup
pkghelpers_makepkg