#! /bin/csh -f
# No data file

# I tried modifying this script so that it makes either plntest and sphtest
# depending on which one you type in for the <outfile>.
# If that doesn't work, let me know and I'll test it some more.


# compile <directory>  <out file> <resultfile>:
#             <directory> is the directory containing the assignment submissions
#             <outfile> is the name of the output file 
#             <resutlfile> is the name of the new file to contain 
#                        the results of the compilation if there were errors
# for example:  compile MP1 plntest result1.txt
# run it again to compile for sphtest:	 compile MP1 sphtest result2.txt
# where:  MP1 is one directory up, where all the students' directories are
#         plntest & sphtest are the renamed executables
#



if ($#argv < 3) then
   echo ""
   echo "compile <directory> <out file> <result file>"
   echo ""
   exit
endif

cd $1
   set class = *
   foreach student ($class)
      if (-d $student) then
         cd $student
         echo -n "   compiling program for $student..."
         echo "--- results for $student ---" > $argv[$#argv]
         echo " " >> $argv[$#argv]
         if ($#argv > 2) then
            set last = $#argv
            set ofile = $2
	    		#if (-f $ofile) then
					make clean
	        		make $ofile
	    		#else
	        		#make $ofile
	       		#echo " *********  file not found:" >> $argv[$#argv]
          	#endif
            echo " " >> $argv[$#argv]
      	endif
         echo "done"
         cd ..
      endif
end

