#!/bin/sh
CWD=`pwd`
TMP=/tmp
PKG=$TMP/package-expect
VERSION=5.43
VER=5.43.0
ARCH=alpha
BUILD=3
TARGET=$ARCH-alphaslack-linux

rm -rf $PKG
mkdir -p $PKG
cd $PKG
explodepkg $CWD/_expect.tar.gz
# Build shared version:
( cd $TMP
rm -rf expect-$VERSION
tar xzf $CWD/expect-$VER.tar.gz
cd expect-$VERSION
chown -R root.root .
./configure \
 --prefix=/usr \
 --with-tclconfig=/usr/lib \
 --with-tkconfig=/usr/lib \
 --with-tclinclude=/tmp/tcl8.4.15/generic \
 --enable-shared \
 --build=$TARGET \
 --host=$TARGET \
 --target=$TARGET
make || exit
mkdir -p $PKG/usr/include $PKG/usr/lib/expect$VERSION $PKG/usr/man/man1 $PKG/usr/man/man3 $PKG/usr/doc/expect-$VERSION
cp -a FAQ HISTORY INSTALL NEWS README example $PKG/usr/doc/expect-$VERSION
cat expect > $PKG/usr/bin/expect
cat expectk > $PKG/usr/bin/expectk
chown root.bin $PKG/usr/bin/expec* ; chmod 755 $PKG/usr/bin/expec* ; strip --strip-unneeded $PKG/usr/bin/expec*
cat expect.h > $PKG/usr/include/expect.h
cat expect_comm.h > $PKG/usr/include/expect_comm.h
cat expect_tcl.h > $PKG/usr/include/expect_tcl.h
cat tcldbg.h > $PKG/usr/include/tcldbg.h
chmod 644 $PKG/usr/include/* ; chown root.root $PKG/usr/include/*
cat libexpect$VERSION.a > $PKG/usr/lib/libexpect$VERSION.a
cat libexpect$VERSION.a > $PKG/usr/lib/expect$VERSION/libexpect$VERSION.a
cat libexpect$VERSION.so > $PKG/usr/lib/libexpect$VERSION.so
chmod 755 $PKG/usr/lib/libexpect$VERSION.so ; strip --strip-unneeded $PKG/usr/lib/libexpect$VERSION.so
cat pkgIndex > $PKG/usr/lib/expect$VERSION/pkgIndex.tcl ; chmod 755 $PKG/usr/lib/expect$VERSION/pkgIndex.tcl
cat libexpect.man > $PKG/usr/man/man3/libexpect.3
cat expect.man > $PKG/usr/man/man1/expect.1
cat expectk.man > $PKG/usr/man/man1/expectk.1
( cd $PKG/usr/doc/expect-$VERSION/example
 rename .man .1 *.man 
 mv *.1 $PKG/usr/man/man1 
 gzip -9 $PKG/usr/man/man?/*
)
( cd $PKG/usr/lib
 ln -sf libexpect$VERSION.a libexpect.a
 ln -sf libexpect$VERSION.so libexpect.so 
)
mkdir -p $PKG/install
cat $CWD/slack-desc > $PKG/install/slack-desc
cd $PKG
makepkg -l y -c n $TMP/expect-$VER-$ARCH-$BUILD.tgz
) 2>&1 | tee $TMP/expect.build.log
