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

mkdir -p $PKG
cd $PKG
explodepkg $CWD/_expect.tar.gz
# Build shared version:
( cd $TMP
tar xzf $CWD/expect-$VER.tar.gz
cd expect-$VERSION
# Get the weather from wunderground instead
# since U of MI no longer provides the service:
#zcat $CWD/expect.weather.diff.gz | patch -p1
chown -R root.root .
./configure --prefix=/usr --with-tclconfig=/usr/lib --with-tkconfig=/usr/lib --enable-shared $TARGET
make
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
