#!/bin/csh -f #(ie run the cshell on this but don't read the .cshrc) set vsn="version = 1.47 of gpcc 2010 Oct 19" # 2010 Oct 19, 1.47: try to report compile status correctly on Mac OS X # 2009 Nov 16, 1.46: new location of gpcc # 2005 Sep 19, 1.45: modify comments # 2005 Aug 04, 1.43: -debug for debugging # 2005 May 25, 1.42: capture more unmarked errors # 2005 May 23, 1.41: clearer messages # 2005 May 23, 1.40: error and warning too verbose, simplify messages. # 2005 May 6, 1.39: remove message restrictions # 2005 Jan 19, 1.37: don't limit messages, dang it! # 2005 Jan 11, 1.36: report warnings separately # 2004 Sep 10, 1.35: give more version information # 2004 Sep 10, 1.34: allow use of alternative version of gpc if it exists # 2004 Sep 8, 1.32: remove the printed output of sound # 2004 Jul 29, 1.31: limit the number of lines of errors to $errormax # 2004 Jul 10, 1.30: non-standard for page() only for one version # 2004 Jul 9, 1.29: cleanup # 2004 Jul 9, 1.28: crash: need "" around 'page(' call # 2004 Jul 8, 1.27: remove --standard-pascal if program has ' page(' call # 2004 Jan 5, 1.26: report failure of compile with flag ERROR # 2001 Nov 20, 1.25: not really ... # 2001 Nov 19, 1.24: neutralize gnumsg2spc to see if it is # the cause of snowballing errors # 2001 Nov 6, 1.22: use gnumsg2spc it is available # 2001 Nov 4, 1.20: -O optimization # 2001 Nov 2, 1.20: -Wall to get more messages # 2000 Aug 17, 1.16: program no longer uses ver # origin 1999Aug30.19:57:09 # source: # http://alum.mit.edu/www/toms/ftp/gpcc # Dr. Thomas D. Schneider # National Institutes of Health # schneidt@mail.nih.gov # toms@alum.mit.edu (permanent) # http://alum.mit.edu/www/toms (permanent) # GPC is the Gnu Pascal Compiler - # This open source Pascal compiler is found at: # http://www.gnu-pascal.de/ # # You are reading GPC compiler (gpcc) script for Delila programs. # Delila programs are at # http://alum.mit.edu/www/toms/delila/delilaprograms.html # # This script sets the options for GPC so that Delila programs are # compiled in the way the programs are used in the Delila system. # # Information about the options is at: # http://www.gnu-pascal.de/gpc/GPC-Command-Line-Options.html # # --standard-pascal # This works for all programs that do not have date/time calls. # This script will detect the use of time functions and automatically # remove this option if needed. # # --transparent-file-names # This flag is set on so that file names given in the program map directly to # the local file directory names. This allows the user to have, for example, # a makelogop file and the makelogo program will automatically read it. # Without this flag on, the user would have to type the file name for every # run, which is tedious and makes scripts just about useless. # # --no-mixed-comments # This flag is required because sometimes I will use a bibtex format # reference or other things, and these have {} which are Pascal comments. # # OUTPUT: # Variable thestatus is 0 if the program compiled ok, 1 otherwise # Externally, the $status variable is set to thestatus. # # Notes: # This form will not give standard Pascal: # gpc $program.p -o $program # # This form does not allow (* {} *) # gpc --standard-pascal $program.p -o $program # # This form is unhappy if one does odd things inside comments: # gpc --standard-pascal --nested-comments $program.p -o $program # ****************************************************************************** # Set for alpha testing: set alpha = true set alpha = false set regularlocation = /usr/local/gpc/bin/gpc set alphalocation = /usr/local/gpc-20050331/bin/gpc # Some of the code below is set up to restrict the verbose # output of GPC. # Limiting errors is a nice idea, but in practice # it blocks too much. I have removed the function for now. set errormax = 10 set warningmax = 5 # maximum message lines to show: set msglines = 10 # This is the location of error messages: set messages = /tmp/`whoami`.gpcc #******************************************************************************* set printing = "true" set standard = "--standard-pascal" set optimization = 0 set debug = "" # Let the user control the amount of output if ($#argv == 2) then if (("$2" == "-silent") || ("$2" == "-s")) then set printing = "false" endif if (("$2" == "-time")) then set standard = "" endif if (("$2" == "-debug")) then # echo debugging set debug = "-ggdb" set debug = "-g" # use with dbx # http://www.pointer.gr/documents/Red%20Hat%20Enterprise%20Linux%20AS/rhel-gcc-en-4/debugging-options.html endif endif if ($printing == "true") then echo $vsn endif # 2004 Sep 10, 1.34: allow use of alternative version of gpc if it exists if (-f /usr/local/gpc/bin/gpc) then if ($alpha == false) then set gpc = $regularlocation echo Using $gpc instead of the one in the path else set gpc = $alphalocation endif else set gpc = gpc endif echo "using: $gpc" #******************************************************************************* # output status variable (to report errors to other programs): set thestatus = 0 if (($#argv == 1) || ($#argv == 2)) then set program = `echo $1 | sed -e "s/\.p//"` if ($printing == "true") then echo gpc compiling $1 if ("$debug" != '') then echo ================ DEBUGGING ======================== echo compiling with flag $debug echo == run as: echo dbx $program echo =================================================== endif endif if ($printing == "true") then echo output program name: $program endif if (-f $program.p) then if (-f $program) then if ($printing == "true") then echo -n "$program.p exists, so we can delete $program"": " echo REMOVING $program endif rm -f $program endif else echo NO SUCH PROGRAM $program\! set thestatus = 1 # sound 80 laugh >> /dev/null exit $thestatus endif # see if TimeStamp is in the program. If so, switch to allow it. set gts = `grep TimeStamp $program.p | wc -l | sed -e "s/ //g"` if !($gts == "0") then echo Allowing for time modules set standard = "" endif # report the version number of the program to be compiled: grep "version = " $program.p | head -1 echo "optimization: " $optimization echo --- # This version # GNU Pascal version 2.1 (20020510), based on gcc-2.95.3 20010315 (release). # will not accept page() but versions before and after do. # If we are running that version, turn off standard compile set gpcversion = "Use this line to test the code for version 20020510" set gpcversion = `$gpc | head -1` echo 'GPC version from "gpc --version | head -1" :' $gpc --version | head -1 echo 'GPC version from "gpc | head -1" :' echo "${gpcversion}" set oldgpc = `echo "${gpcversion}" | grep "20020510"` echo --- if ("${oldgpc}" != "") then echo 'This version of GPC will not accept page() as standard pascal,' echo 'but versions before and after do.' echo 'If the page function is used, turn off standard compile.' if ("`grep ' page(' $program.p | head -1`" != '') then echo "**********************************************************" echo "* The program ${program} is using the 'page()' function." echo "* This will be allowed during the compilation by" echo "* removing --standard-pascal from the compile call." echo "**********************************************************" set standard = "" endif endif if (${standard} == "") then echo 'NON-STANDARD PASCAL IS ALLOWED' else echo 'ONLY STANDARD PASCAL IS ALLOWED' endif echo # GPC options besides those of GCC: # http://www.gnu-pascal.de/gpc/GPC-Command-Line-Options.html # GPC index: # http://download.mirror.ac.uk/sites/www.gnu-pascal.de/gpc-es/Index-GPC.html # -Widentifier-case-local # Warn about an identifier written with varying case within one # program/module/unit. # This does not follow scope rules. That is, a local variable in # one proceedure is compared to the case of local variables in later # procedures, even though they are in completely different scopes. # My programs use text modules that come from various places, so # keeping the case consistent between all modules is not possible. # So this feature is not useful and since 'all' is on (-Wall) turn # this off with: # -Wno-identifier-case-local \ # THIS IS THE MAIN CALL OF THE SCRIPT, where GPC is invoked: $gpc $standard \ --transparent-file-names \ --no-mixed-comments \ -O$optimization \ -Wall \ -Wno-identifier-case-local \ $debug \ $program.p -o $program \ |& cat > $messages echo All messages are in file ${messages}, summaries are below: # Just GIVE all the messages!!! # Any restrictions can prevent errors from being shown. # cat $messages # no- just set errormax and warningmax to be small echo "------ Messages (up to the first $msglines lines)" head -$msglines $messages echo echo ------ Summary of Warning Messages set warningcount = `grep warning $messages|wc -l` set thecount = `grep warning $messages|head -${warningmax}|wc -l` #echo thecount is $thecount #echo warningmax is $warningmax #echo warningcount is $warningcount if ($thecount < $warningcount) then echo NOTE: only $thecount of $warningcount warning messages are shown endif if ($warningcount == 0) then echo No warnings else grep warning $messages | head -${warningmax} endif set flag1 = 'unterminated' echo echo ------ Summary of Error Messages set errorcount = `grep error $messages|grep -v warning|wc -l` set moreerrors = `grep unterminated $messages|wc -l` @ errorcount = $errorcount + $moreerrors set thecount = `grep -v warning $messages|head -${errormax}|wc -l` @ thecount = $thecount + $moreerrors if ($thecount < $errorcount) then echo NOTE: only $thecount of $errorcount error messages are shown endif if ($errorcount == 0) then echo No errors set thestatus = 0 else grep error $messages|grep -v warning grep $flag1 $messages|grep -v warning set thestatus = 1 endif echo if ($thestatus == 1) then if ($printing == "true") then echo -n "$program.p has ERROR(s)" echo " -------> ONLY up to $errormax lines of errors are shown" echo " -------> ONLY up to $warningmax lines of errors are shown" endif endif else echo "usage: gpcc [program] [-silent]" echo "gpc compile: compile a pascal program using gpc" echo "This script is designed to compile delila programs:" echo " http://alum.mit.edu/www/toms/delila.html" echo "using the gpc compiler:" echo " http://www.gnu-pascal.de/gpc/h-index.html" echo "" echo "For Macintosh computers (google: macintosh gpc pascal):" echo " http://www.microbizz.nl/gpc.html" echo "or:" echo " % fink install gpc" echo "" echo "More details are in comments in the code." echo "" echo "FLAGS: only one for now, the second argument" echo " -silent turn off no-error messages (leaving only errors)" echo " (-s does the same thing)" echo " -time allow non-standard construction (ie date/time functions)" set thestatus = 0 endif if ($thestatus) then if ($errorcount == 1) then set S = '' else set S = 'S' endif set errmsg = " --- with $errorcount ERROR${S}" else set errmsg = ' --- with no errors' endif echo "gpcc is done${errmsg}" # exit and return error status: # echo thestatus: $thestatus =============================== exit $thestatus ******************************************************************************** ******************************************************************************** extra code: # gnumsg2spc comes from: # http://gnu-pascal.de/crystal/gpc/en/attachments/7130/gnumsg2spc # It will be in later releases of gpc. # it converts the output to Sun style display, for easier reading # of errors # # set ISgnumsg2spc = `which gnumsg2spc | grep -v "no gnumsg2spc"` # if ($ISgnumsg2spc != '') then # set ISgnumsg2spc = '|& gnumsg2spc' # set ISgnumsg2spc = '| gnumsg2spc' # # set ISgnumsg2spc = '' # endif # # echo '$ISgnumsg2spc is "'$ISgnumsg2spc'"' # # this mechanism does not work because gpc thinks the | is a file ... # NOT IMPLEMENTED. # these attempts to use $ISgnumsg2spc FAILED: # $program.p -o $program $ISgnumsg2spc # $program.p -o $program \ # $ISgnumsg2spc