#!/bin/sh

#
# This program idl-compiles all the files sitting in a subdirectory and
# creates an idl-saveset file.
#
# A file called 0list with the file list must exist
# A file called 0ff with additional commands may optionally exists
#
# Usage: MakeSave <directory>
#
# Example: MakeSave idlexa
#
# Note: To compile all directories, use MakeSaveAll
#
# Author: srio@esrf.fr, December 1998
#
#

#
# crates a file tmp.pro with the task to be done
#
/bin/rm -f tmp.pro
echo "" > tmp.pro
echo "!path=!path+':'+Expand_Path('+.')" >> tmp.pro

for y in `ls -F | grep /`
do

#SOURCE_DIR=./$y

if test -r ./$y/0ff 
   then 
       cat ./$y/0ff >> tmp.pro
fi


for x in `cat ./$y/0list`
do
   echo ".compile ./$y/$x " >> tmp.pro
done

done




# echo "save,/verbose,/routines,file='$1.sav'" >> tmp.pro
echo "save,/routines,file='/tmp/xoplibfull.sav'" >> tmp.pro
echo "print,'file /tmp/xoplibfull.sav written to disk'" >> tmp.pro
echo "exit" >> tmp.pro

echo "File tmp.pro written to disk".

#
# Calls IDL and executes tmp.pro
#
echo "@tmp.pro \n exit" | /scisoft/users/srio/bin/myidl 7.0
# this is for idl 5.5
#source /scisoft/XRayOptics/rsi/idl_5.5/bin/idl_setup
#echo "@tmp.pro \n exit" | idl

rm -f tmp.pro 

exit 0

