#!/bin/sh
# Verification de l usage 

case $# in
 0|1|2) echo usage: config nom binaire configuration [tailles]; exit 1;;
   *) nom=$1; bin=$2; conf=$3; shift; shift; shift;;
esac

# Le fichier de configuration est-il un path absolu
#  ou bien un path relatif
case $conf in
	/*) ;; 
	*)  conf=conf/$conf ;;
esac

# Le fichier de configuration est-il la
if test ! -f $conf
then
   echo Le fichier $conf n existe pas.
   exit 1
fi

DIR=/usr/local/caml/V2-6.1/camlisp
SYSDIR=$DIR/sony

# Creation du script shell de commande
llcmd=/tmp/ll$$
trap "rm -f $llcmd;exit 1" 1 2 3 15
echo exec $SYSDIR/$bin \
         $* -r $SYSDIR/llcore/$nom.core \$\* > $llcmd
chmod +x $llcmd
 
#  Creation de l image memoire
#  Pour ne pas charger son .lelisp au moment de creer le core
HOME=qwerty

$llcmd $DIR/llib/startup.ll <<EOF
(setq #:system:name (quote |$nom|))
`cat $conf`
(end)
EOF

cp $llcmd $nom
rm -f $llcmd
