#!/bin/sh
CWD=`pwd`
TMP=/tmp
PKG=$TMP/package-gettext
VERSION=0.18
ARCH=alpha
BUILD=1
TARGET=$ARCH-alphaslack-linux

rm -rf $PKG
mkdir -p $PKG
( cd $TMP
rm -rf gettext-$VERSION
tar xf $CWD/gettext-$VERSION.tar.gz
cd gettext-$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 {} \;
./configure \
 --prefix=/usr \
 --mandir=/usr/man \
 --docdir=/usr/doc/gettext-$VERSION \
 --infodir=/usr/info \
 --build=$TARGET
make -j2 || exit
make install DESTDIR=$PKG
rm -rf $PKG/usr/lib/libintl.* $PKG/usr/share/locale/locale.alias $PKG/usr/include/libintl.h
chown -R root:bin $PKG/usr/bin
( cd $PKG/usr/doc/gettext-$VERSION
 rm -rf javadoc*
 # These take up a ton of space otherwise
 tar cjf examples.tar.bz2 examples
 rm -rf examples
 # Move the HTML docs into a subdirectory:
 mkdir html
 mv *.html html
 tar cjf html.tar.bz2 html
 rm -rf html
 # This file isn't in the package, but it's in one you have to install, or there will be
 # bigger problems than this dead link:
 rm -f ABOUT-NLS
 ln -sf /usr/share/gettext/ABOUT-NLS .
)
( cd $PKG/usr/info ; rm -rf dir ; gzip -9 * )
gzip -9 $PKG/usr/man/man?/*
( cd $PKG
 find . | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded
 find . | xargs file | grep "shared object" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded
)
mkdir -p $PKG/install
cat $CWD/slack-desc > $PKG/install/slack-desc
cd $PKG
makepkg -l y -c n $TMP/gettext-$VERSION-$ARCH-$BUILD.tgz
) 2>&1 | tee $TMP/gettext.build.log
