#!/bin/sh
# @(#)COMPILE version 3.6 created 12/29/94
# @(#)Copyright (c), 1987, 1994 StatSci, Inc.  All rights reserved.

#!/bin/sh
#usage: Splus COMPILE [file ...] [macro=value ...]

L=$SHOME/newfun/lib export L

opts=

case $# in
0) set *.[rcfyl];;
esac

export targets
for i
do
case "$i" in
*.[crfyl] )
	this=`echo $i|sed 's/..$/.o/'`
	targets="$targets $this"
	;;
*=*)
	opts="$opts \"$i\""
	;;
*)
	targets="$targets $i"
	;;
esac
done

if test -r Makefile; then
	if grep '^include.*S_makefile' Makefile >/dev/null; then
		# from CHAPTER
		mf="-f Makefile"
	else
		mf="-f $L/S_makefile -f Makefile"
	fi
	echo Using ./Makefile in addition to $L/S_makefile
else
	mf="-f $L/S_makefile"
	if test -r makefile; then
		mf="$mf -f makefile"
		echo Using ./makefile in addition to $L/S_makefile
	fi
fi
if [ `PLATFORM` = "APOLLO" ]; then mf="-P $mf"; fi

echo targets="$targets"
echo "make $mf $targets $opts"
eval "make $mf $targets $opts"
