# Make InstallShield file from a zipfile
# For reasons too painful to explain, we assume:
#
# o We're using Windows NT with cygnus tools (v16) installed
# o Installshield stuff is on the X drive (directory ishield5)
#
# We don't delete the very large temporary files because it
# tickles a bug in rm (blech).

zipfile=$1
fileList=$2
RULDIR="x:/ishield5/the hugs haskell system/script files/"
zip=zip$$  # use process num to avoid need to delete (blech!)
fileRoot="c:\\winnt\\profiles\\administrator\\${zip}\\hugs\\"

outputFile="x:\\ishield5\\The Hugs Haskell System\\File Groups\\Program Executable Files.fgl"

RUNHUGS=~/hugs/runhugs
MAKE_FILE_GROUPS="${RUNHUGS} -h1m hugs/src/distrib/makefilegroups.hs"

if [ x${zipfile} = x -o x${fileList} = x  ]; then
  echo "Usage: mkishield <zipfile> <fileList>"
  exit 1
fi

if [ ! -e "${RULDIR}" ]; then
  echo "Please map \\\\haskell\\hcompile to drive x:"; exit 1
fi

# Build the directory ishield wants
cp hugs/src/distrib/setup.rul "${RULDIR}"
cp hugs/src/options.h         "${RULDIR}"
/bin/rm -f "$outputFile"
${MAKE_FILE_GROUPS} ${fileRoot} ${fileList} "$outputFile"

# Unpack zipfile
mkdir  ${zip}
cd  ${zip}
unzip -a -q ~/${zipfile}
cd

echo Now do the following interactive actions:
echo Restart InstallShield 5
echo
echo   Select hugs_haskell_system
echo   Build:Compile
echo   Build:Media Build Wizard
echo  	 Accept defaults but fix the version number
echo   Build:Send Media To...
echo  	 Enter c:/foo
echo   Exit InstallShield
echo   
echo Hit return when done.

read foo

echo "Building c:/foo/hugsIS.{zip,exe}"
cd c:/foo
rm -f hugsIS.zip hugsIS.exe
zip -r9 hugsIS.zip disk1

if [ -e c:/infozip/unzipsfx.exe ]; then
  echo "Making hugsIS.exe from hugsIS.zip"
  #DISNAE WORK: cat c:/infozip/unzipsfx.exe hugsIS.zip > hugsIS.exe
  echo "copy/b c:\\infozip\\unzipsfx.exe + hugsIS.zip hugsIS.exe" | cmd
else
  echo "Not making hugsIS.zip from ${zipfile} because c:/infozip/unzipsfx.exe
doesn't exist"
fi

ls -l hugsIS.{zip,exe}

cd

echo "Please delete ${zip} directory"
exit 0

