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

mkdir -p $PKG
( cd $TMP
rm -rf lesstif-$VERSION
tar xjf $CWD/lesstif-$VERSION.tar.bz2
cd lesstif-$VERSION
chown -R root.root .
find . -perm 777 -exec chmod 755 {} \;
find . -perm 775 -exec chmod 755 {} \;
find . -perm 664 -exec chmod 644 {} \;
./configure --prefix=/usr/X11R6 \
    --enable-shared \
    --enable-static \
    --enable-build-Xlt \
    --enable-build-Xbae \
    --enable-xbae-24bit \
    --enable-build-21 \
    --enable-xbae-row-heights \
    --disable-debug \
    --enable-production \
    $TARGET 
make
make install DESTDIR=$PKG
chown -R root.bin $PKG/usr/X11R6/bin
( cd $PKG
find . | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null
find . | xargs file | grep "shared object" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null
)
mkdir -p $PKG/usr/doc
( cd $PKG/usr/doc ; rm -rf lesstif-$VERSION ; ln -sf /usr/X11R6/LessTif lesstif-$VERSION )
# The config file handles adding this in:
mkdir -p $PKG/usr/X11R6/lib/X11/config
cp -a $PKG/usr/X11R6/lib/LessTif/config/* $PKG/usr/X11R6/lib/X11/config
( cd $PKG/usr/X11R6/lib/X11/config ; mv host.def host.def-lesstif )
mkdir -p $PKG/etc/X11
( cd $PKG/usr/X11R6/lib/X11 ; cp -a mwm $PKG/etc/X11 ; rm -rf mwm ; ln -sf ../../../../etc/X11/mwm . )
( cd $PKG/usr/X11R6/lib/X11 ; cp -a app-defaults $PKG/etc/X11 )
gzip -9 $PKG/usr/X11R6/man/man?/*.?
mkdir $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/lesstif-$VERSION-$ARCH-$BUILD.tgz
) 2>&1 | tee $TMP/lesstif.build.log
