#!/bin/sh
#*=====================================================================*/
#*    serrano/ml/camloo/distribution/configure ...                     */
#*    -------------------------------------------------------------    */
#*    Author      :  Manuel Serrano                                    */
#*    Creation    :  Thu Jan 27 15:41:36 1994                          */
#*    Last change :  Wed Mar  2 10.03:49 1994 (serrano)                */
#*    -------------------------------------------------------------    */
#*    The camloo's configuration file                                  */
#*=====================================================================*/

#*---------------------------------------------------------------------*/
#*    Le site                                                          */
#*---------------------------------------------------------------------*/
site=`pwd`
version="0.0"

#*---------------------------------------------------------------------*/
#*    Checking Bigloo                                                  */
#*---------------------------------------------------------------------*/
echo ". Checking Bigloo"

bv=`bigloo -version` || exit $?

case $bv in
  Bigloo*)
    bfv=`echo $bv | sed 's/Bigloo (v//' | sed 's/)//'`
    biv=`echo $bfv | sed 's/\.//'`;;
  *)
    echo "Bigloo release 16 (or greater) is required for the Camloo package"
    exit 1;;
esac

if test $biv -lt 16; then
  echo "Bigloo release 1.6 (or greater) is required for the Camloo package"
  exit 1;
fi

#*---------------------------------------------------------------------*/
#*    Some global variables                                            */
#*---------------------------------------------------------------------*/
lib_dir=/usr/local/lib/bigloo/$bfv
bigloo_lib_dir="`bigloo -query | grep \"\*lib-dir[ ]*\*\" | sed 's/\*lib-dir\*[ ]*: //'`"
 
#*---------------------------------------------------------------------*/
#*    We parse the arguments                                           */
#*---------------------------------------------------------------------*/
while : ; do
  case $1 in
    "")
      break;;
    --lib=*|-lib=*)
      lib_dir="`echo $1 | sed 's/^[-a-z]*=//'`";;
    -*)
      echo "Unknown option \"$1\", ignored" >&2;;
  esac
  shift
done
 
#*---------------------------------------------------------------------*/
#*    We get the name of the C compiler                                */
#*---------------------------------------------------------------------*/
cc="`bigloo -query | grep \"\*cc[ ]*\*\" | sed 's/\*cc\*[ ]*: //'`"
 
#*---------------------------------------------------------------------*/
#*    We compile `beep' (so, we test cc)                               */
#*---------------------------------------------------------------------*/
echo ". Compiling tools"
 
tools_dir="$site/tools"
cflags="-O"
 
(cd $tools_dir
 $cc $cflags beep.c -o beep || exit $?)
 
(cd $tools_dir
 $cc $cflags dirname.c -o dirname || exit $?)
 
#*---------------------------------------------------------------------*/
#*    We install the temporary `caml' extension descriptor             */
#*---------------------------------------------------------------------*/
echo ". Updating distribution/install"
 
cat distribution/caml.tpl | sed -e s,"/net/cornas/icsla2/serrano/ml/camloo",$site, > lib/$version/caml
 
#*---------------------------------------------------------------------*/
#*    On patche les Makefiles des constributions                       */
#*---------------------------------------------------------------------*/
echo ". Updating contributions"
 
(cd contrib$version/libunix;
 mv Makefile Makefile.old;

 cat Makefile.old | sed -e s,"/net/cornas/icsla2/serrano/ml/camloo",$site, > Makefile;

 \rm Makefile.old)

#*---------------------------------------------------------------------*/
#*    We change the flags of the two files distribution/{boot,install} */
#*---------------------------------------------------------------------*/
echo ". changing files modes"

chmod a+rx distribution/boot
chmod a+rx distribution/install
