#!/bin/sh
CWD=`pwd`
TMP=/tmp
PKG=$TMP/package-pkgconfig
VERSION=0.23
ARCH=alpha
BUILD=2
TARGET=$ARCH-alphaslack-linux

rm -rf $PKG
mkdir -p $PKG/usr
( cd $TMP
rm -rf pkg-config-$VERSION
tar xzf $CWD/pkg-config-$VERSION.tar.gz
cd pkg-config-$VERSION
chown -R root:root .
find . -perm 666 -exec chmod 644 {} \;
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 {} \;
./configure \
 --prefix=/usr \
 --mandir=/usr/man \
 --build=$TARGET
make || exit 1
make install DESTDIR=$PKG
mkdir -p $PKG/etc/profile.d/
cp -a $CWD/scripts/* $PKG/etc/profile.d
chown root:root $PKG/etc/profile.d/*
chmod 755 $PKG/etc/profile.d/*
strip --strip-unneeded $PKG/usr/bin/* 2> /dev/null
chown -R root:bin $PKG/usr/bin
gzip -9 $PKG/usr/man/man?/*.?
mkdir -p $PKG/usr/doc/pkgconfig-$VERSION
cp -a AUTHORS COPYING ChangeLog NEWS README $PKG/usr/doc/pkgconfig-$VERSION
mkdir -p $PKG/install
zcat $CWD/doinst.sh.gz > $PKG/install/doinst.sh
cat $CWD/slack-desc > $PKG/install/slack-desc
cd $PKG
makepkg -l y -c n $TMP/pkgconfig-$VERSION-$ARCH-$BUILD.tgz
) 2>&1 | tee $TMP/pkgconfig.build.log
