msg="Usage: S PROGRAM [options] name file ..."
case $# in 0) echo "$msg"; exit 1;; esac
case $1 in -*) mod=$1; shift;; esac
lib=LIBR
case $mod in -*g*) lib=GRZ;; esac
fun=$1
shift
touch /tmp/t1.$$
for i in $@
do
	case $i in
	*.[erfcC]) echo "$i" >>/tmp/t1.$$
		;;
	*) misc="$misc $i"
		;;
	esac
done
comp=`sed </tmp/t1.$$ "s/\.[rfcCe]$/.o/"`
touch Smakefile
ed - Smakefile <<!
g/^$fun:/.;/echo/d
w
!
case $mod in
	-*d*)
	if test ! -d ${fun}source
		then mkdir ${fun}source; echo Source files for device driver go in directory ${fun}source
	fi
	cat >>Smakefile <<!
$fun: `echo $comp`
	cd ${fun}source; S COMPILEALL
	\$(F77) \$(LDFLAGS) \$(STRIP) -o $fun ${fun}source/*.o \$(SL)/devfltr.z `echo $comp` $misc \$(GRZLIB)
	@echo $fun driver loaded
!
	;;
	*)
	cat >>Smakefile <<!
$fun: `echo $comp`
	\$(F77) \$(LDFLAGS) \$(STRIP) -o $fun `echo $comp` $misc \$($lib)
	@echo $fun loaded
!
esac
echo $fun initialized.
rm /tmp/t1.$$
