#!/bin/csh
# Toggle 0/1 to change these options. In particular, if you want
# to use freesect without ghc -F. (This would be necessary in order
# to use a different compiler.)
setenv FS_ANNOTATED 0
setenv FS_PARALLEL 0
setenv FS_GHC_F 1
if ( ${#argv} == 0 ) then
set test=S25
else if ( ${#argv} > 1 ) then
foreach i ( $* )
source ./z $i
end
exit
else
set test=$1
endif
make
if ( $? ) exit 1
set rtsopts = ( \
+RTS -K96m -RTS \
# +RTS -K16m -RTS \
\
# Don't forget you need the -prof ghc flag when compiling: \
# +RTS -p -RTS \
)
if ( $FS_PARALLEL ) then
set rtsopts = ( $rtsopts \
# +RTS -i20 -RTS # (default value of granularity of resched. in ms) \
+RTS -N2 -RTS # Control.Parallel : # of cores (not including hyperthr.) \
)
endif
echo rtsopts=$rtsopts
if ( $FS_GHC_F ) then
ed -s ./freesect.sh <<EOF
/RTSOPTS/+1s/..*/rtsopts="$rtsopts"/
wq
EOF
ghc \
--make \
$test \
-main-is $test \
-keep-tmp-files \
-tmpdir . \
# -fno-warn-unrecognised-pragmas \
-F -pgmF freesect.sh \
-o $test \
>&! z.log \
##!!
set zstat=$?
cat ./z.log \
# | sed -e 's/SrcLoc {[^}]*}/SrcLoc .../g' \
| sed -e 's/SrcLoc {[^}]*}//g' \
| sed -e 's/(SrcSpanInfo {[^[][^[]*\[[^]]*]})//g' \
| sed -e 's/)))))*/)..)/g' \
##!!
echo
echo
echo "(Ignore errors about missing symbols; you can examine"
echo "freesect pre-processor output in the intermediate file.)"
echo
if ( $zstat ) exit 1
./$test
else
# If you want to run without using "ghc -F", consider the rest
# of this file. Note that there is a #define GHC_F in Main.hs
# for controlling whether or not "ghc -F" is being used.
#================================
set infiles=( \
./{$test}.hs \
)
# Must be a legal module name:
set outfile=Z_`sha1sum $infiles[1] | head -c 8`
#set outfile=Z_`sha1sum $infiles[1] | cut -d' ' -f1`
#echo $infiles
#echo $outfile
#exit
echo freesect infiles=$infiles outfile=$outfile
# >>BINPATHNAME<<
#set binpathname = /media/ramdisk/freesect
set binpathname = ./dist/build/freesect/freesect
$binpathname \
$rtsopts \
$outfile \
$infiles \
>&! ./z.log \
##!!
set zstat=$?
cat ./z.log \
# | sed -e 's/SrcLoc {[^}]*}/SrcLoc .../g' \
| sed -e 's/SrcLoc {[^}]*}//g' \
| sed -e 's/(SrcSpanInfo {[^[][^[]*\[[^]]*]})//g' \
| sed -e 's/)))))*/)..)/g' \
##!!
if ( $zstat ) exit 1 # won't work for Main's exit status, after the pipe
ghc --make {$outfile}.hs -main-is {$outfile}.main -o $outfile
set zstat=$?
echo
echo
echo "(Ignore errors about missing symbols; you can examine"
echo "freesect pre-processor output in the intermediate file.)"
echo
if ( $zstat ) exit 1 # won't work for Main's exit status, after the pipe
./$outfile
#/bin/rm -f {$outfile}.hs
endif