#! /bin/sh

# Script to build a Windows package file.  This is called from the
# Makefile in ../msw_package.

version=$1
if [ x"$version" == x ]; then
    echo "No version given!"
    exit
fi
program=ipat

# Full path to utod (you probably need to change this).
utod="/home/stevew/src/xictools/src/packages/util/utod.exe"

# The inno packager exeutable.
inno="/inno-5.5.1/iscc"

topdir=data
rm -rf $topdir
mkdir $topdir

bin=$topdir/bin
share=$topdir/share

srclib=..

mkdir $bin
mkdir $share

echo Copying files for export ...
install -sc -m 0755 $srclib/ipat.exe $bin

cp $srclib/README $share
cp $srclib/ipatrc $share
cp $srclib/helptext $share

$utod $share/README
$utod $share/ipatrc
$utod $share/helptext

echo Completed copying files, building package ...

sed -e s/VERSION/$version/ < $program.iss.in > $program.iss
$utod $program.iss

$inno $program.iss > build.log
if [ $? != 0 ]; then
    echo Compile failed!
    exit 1
fi

mv Output/*.exe .
rmdir Output
rm $program.iss
echo Done
