#!/bin/sh
#
# A script for compiling a lisp module
#
# Usage:
#
#	llcc name target_dir source_dir -d {debug|standard|delivery}
#

usage="Usage: llcc name target_dir source_dir -d {debug|standard|delivery}"

if [ $# -lt 3 ]
then
  echo $usage
  exit 1
fi

name=$1
tdir=$2
sdir=$3
shift;shift;shift

if [ "x$1" = "x-d" ]
then
  level=$2
else
  level=standard
fi

if [ "$level" = "debug" ]
then
  copt="-O -g -DLL_NO_SYNONYMS"
else
  copt="-O"
fi

# Work around speed degradation when assembling to a file over NFS
tmpo=${TMPDIR-/var/tmp}/iltobj$$.o

gcc $copt -w \
	-I$ILT_DIR/talk/common -I$ILT_DIR/talk/i86_linux1.2_gnu2.7 \
	 -fPIC $options \
	-c $sdir/$name.c -o $tmpo && mv $tmpo $tdir/$name.o
