#! /bin/csh -f

if ($#argv < 1) then 
   echo "usage::compile module_name.function_name"
   exit
endif
set name = $argv[1]
set use
shift argv
foreach f ($argv)
    set use = ($use' use "'$f'" ; ')
end
set use = ("CM.make ();" ' SMLofNJ.exportFn("boot-heap", '$name');')
echo use is $use

if (-f ../linux/runtime/objs/f2a.h)  then  
	rm ../linux/runtime/objs/f2a.h
endif

cd ../src/sml
echo $use | ../../smlnj.7/bin/sml
../../bin/f2a boot-heap.x86-linux ../../linux/runtime/objs/f2a.h
rm boot-heap.x86-linux

cd ../../linux
if (-f runtime/objs/f2a.h)  then 
	make bzdisk
else 
	(echo "sml source code compiling error, no heap image generated!!!"; exit 1)
endif
