#{{{  File banner
# @(#)=====================================================
# @(#)  Project : GPMIMD ESPRIT P5404
# @(#)  Authors : Mark Debbage, Mark Hill and Sean Wykes
# @(#)            University of Southampton
#  
# @(#)    Title : Library installation script
# @(#)   System : Occam 2 C
# @(#) Filename : libinstall
# @(#)  Version : 1.2
# @(#)     Date : 1/14/94
# @(#)====================================================
#}}}
#!/bin/sh
LIBSRC=$SPOC/lib/src
INMOS=0
if [ -f Makefile ]; then
  echo Libraries have already been installed
  exit 10
fi

if [ ! $SPOC ]; then
  echo You must set SPOC environment variable before installing libraries
  exit 10
fi

if [ ! -d $LIBSRC ]; then
  echo Unable to find library source directory: $LIBSRC
  exit 10
fi

echo SPOC library installation script 1.2
echo
echo This script will install links to the standard SPOC libraries
if [ $INMOS_SRC ]; then
  if [ ! -d $INMOS_SRC/hostio ]; then echo Error - Unable to find INMOS_SRC directory: $INMOS_SRC/hostio; exit 10; fi
  if [ ! -d $INMOS_SRC/string ]; then echo Error - Unable to find INMOS_SRC directory: $INMOS_SRC/string; exit 10; fi
  INMOS=1
  echo and to the INMOS libraries at $INMOS_SRC
else
  echo and to the SPOC hostio libraries
  echo
  echo If you have INMOS iserver sources, set environment INMOS_SRC to
  echo point to the root source directory, and rerun libinstall
  echo "   ie. INMOS_SRC=/inmos/d4305/source/libs"
fi

echo

response=Z
while [ $response != Y ] && [ $response != y ]; do
  echo -n "Continue with installation (y/n)? "
  read response
  if [ $response = n ] || [ $response = N ]; then exit 0; fi
done
#
#
#
echo Installing Intrinsics library
if [ ! -d Intrinsics ]; then
  mkdir Intrinsics
  ln -s $LIBSRC/Intrinsics/Intrinsics.occ Intrinsics/Intrinsics.occ
fi
rm -f Intrinsics.lib Intrinsics.hdr libIntrinsics.a
#
#
#
echo Installing convert library
if [ ! -d convert ];    then
  mkdir convert
  ln -s $LIBSRC/convert/convert.occ convert/convert.occ
fi
rm -f convert.lib convert.hdr convert.liu libconvert.a
#
#
#
echo Installing maths libraries
if [ ! -d snglmath ];    then
  mkdir snglmath
  ln -s $LIBSRC/snglmath/snglmath.occ snglmath/snglmath.occ
fi
if [ ! -d dblmath ];    then
  mkdir dblmath
  ln -s $LIBSRC/dblmath/dblmath.occ dblmath/dblmath.occ
fi
rm -f snglmath.lib snglmath.hdr snglmath.liu libsnglmath.a
#
rm -f dblmath.lib dblmath.hdr dblmath.liu libdblmath.a
#
rm -f mathvals.inc
ln -s $LIBSRC/mathvals.inc mathvals.inc
#
#
#
echo Installing hostio library
if [ ! -d hostio ]; then
  mkdir hostio
  rm -f hostio.inc
  if [ $INMOS = 1 ]; then
    ln -s $INMOS_SRC/hostio/hostio.inc hostio.inc
    for i in $INMOS_SRC/hostio/*.occ; do ln -s $i hostio/`basename $i`; done
    ln -s $LIBSRC/imslibs/hostio.occ hostio/hostio.occ
    ln -s $LIBSRC/imslibs/splib.occ hostio/splib.occ
    ln -s $LIBSRC/imslibs/solib.occ hostio/solib.occ
    ln -s $LIBSRC/imslibs/readwrit.occ hostio/readwrit.occ
  else
    ln -s $LIBSRC/hostio/hostio.occ hostio/hostio.occ
    ln -s $LIBSRC/hostio.inc hostio.inc
  fi
fi
rm -f hostio.lib hostio.hdr hostio.liu libhostio.a
#
#
#
echo Installing string library
if [ ! -d string ];    then
  mkdir string
  if [ $INMOS = 1 ]; then
    for i in $INMOS_SRC/string/*.occ; do ln -s $i string/`basename $i`; done
    ln -s $LIBSRC/imslibs/string.occ string/string.occ
  else
    ln -s $LIBSRC/string/string.occ string/string.occ
  fi
fi
rm -f string.lib string.hdr string.liu libstring.a
#
#
#
if [ $INMOS = 1 ]; then
  echo Installing spserver library
  if [ ! -d spserver ];    then
    mkdir spserver
    ln -s $LIBSRC/spserver/spserver.occ spserver/spserver.occ
  fi
  rm -f spserver.lib spserver.hdr spserver.liu libspserver.a
#
#
#
  echo Installing streamio library
  if [ ! -d streamio ];    then
    mkdir streamio
    rm -f streamio.inc
    for i in $INMOS_SRC/streamio/*.occ; do  ln -s $i streamio/`basename $i`; done
    ln -s $LIBSRC/imslibs/streamio.occ streamio/streamio.occ
    ln -s $INMOS_SRC/streamio/streamio.inc streamio.inc
  fi
  rm -f streamio.lib streamio.hdr streamio.liu libstreamio.a
fi
#
#
#
cat $LIBSRC/libmake.mak > Makefile
if [ $INMOS = 1 ]; then
  echo top: deflibs imslibs >> Makefile
  echo INMOS_SRC=$INMOS_SRC >> Makefile
else
  echo top: deflibs spoclibs >> Makefile
fi
echo >>Makefile
cat $LIBSRC/deflibs.mak >> Makefile

if [ $INMOS = 1 ]; then
  cat $LIBSRC/imslibs.mak >> Makefile
else
  cat $LIBSRC/spoclibs.mak >> Makefile
fi

rm -f Omakef.tpl
if [ $INMOS = 1 ]; then
  cat $LIBSRC/imsmake.tpl $LIBSRC/Omakef.tpl > Omakef.tpl
else
  cat $LIBSRC/Omakef.tpl > Omakef.tpl
fi

echo Now run 'make' to compile and link libraries




