angel@FLIPPER.MIAMI.EDU (angel li) (09/01/89)
At the end of this message is a new version of gcc.com for VMS. The previous
version of gcc.com would mis-parse a define token with an embedded comma, i.e.
$ gcc /def=("TFMPATH="",/tex_fonts""", "PKDIR="",/tex_fonts""") search.c
Isn't writing DCL procedures fun!?
Angel Li
University of Miami/RSMAS Remote Sensing Group
Internet: angel@flipper.miami.edu UUCP: ncar!umigw!angel
$ Verifying:= 'f$verify(0)'
$!
$! GNU "CC" Compiler command file
$!
$! Invoked from the GCC compile driver via LIB$DO_COMMAND:
$! P1 = File to compile
$! P2 = Options: O - Optimize
$! D - Debug
$! M - Produce Machine Code
$! V - Be verbose during compilation
$! P3 = "," separated Defines
$! P4 = "," separated Undefines
$! P5 = "," separated Include directories
$! P6 = CC1 compilation phase options, including:
$! -mdont-save-r2-r5 (PCC style register saving)
$! -mpcc-alignment (PCC style struct align)
$!
$!
$! Constants:
$!
$ Version:='f$trnlnm("GNU_CC_VERSION")'
$ gcc_cpp="$GNU_CC:[000000]GCC-CPP"
$ gcc_cc1="$GNU_CC:[000000]GCC-CC1"
$ gcc_as= "$GNU_CC:[000000]GCC-AS ""-vGNU CC V''Version'"""
$!
$! Parse the options
$! -----------------
$ P2_Length = f$length(P2) ! So we only have to calculate it once
$ Optimize = "" ! Default = No Optimize
$ Debug = "" ! Default = No Debug
$ Machine_Code = 0 ! Default = No Machine Code
$ Quiet = " -quiet" ! Default = Silent
$ if f$locate("O",p2) .ne. P2_Length then Optimize = " -opt"
$ if f$locate("D",p2) .ne. P2_Length then Debug = " ""-G"""
$ if f$locate("M",p2) .ne. P2_Length then Machine_Code = 1
$ if f$locate("V",p2) .ne. P2_Length then Quiet = ""
$ Temp_File = "" ! For Control_Y abort check
$ On Control_Y then Goto Ctly_Abort
$!
$! Do the CC1 compilation phase options
$!
$ CC1_Options = P6
$ Save_R2_R5 = ""
$ if f$locate("-mdont-save-r2-r5",P6) .eq. f$length(P6) then goto 10$
$ Save_R2_R5 = " -fcall-used-r2 -fcall-used-r3 -fcall-used-r4 -fcall-used-r5"
$ l = f$locate("-mdont-save-r2-r5",P6)
$ l1 = l + 17
$ CC1_Options = "''f$extract(0,l,P6)'''f$extract(l1,255,P6)'"
$ 10$:
$ Alignment = " -mvaxc-alignment"
$ if f$locate("-mpcc-alignment",P6) .eq. f$length(P6) then goto 20$
$ Alignment = ""
$ Alignment_Define = " ""-DPCC_ALIGNMENT"""
$ l = f$locate("-mpcc-alignment",CC1_Options)
$ l1 = l + 15
$ CC1_Options = "''f$extract(0,l,CC1_Options)'''f$extract(l1,255,CC1_Options)'"
$ 20$:
$!
$! Do the filename (default to ".C")
$!
$ Filename:='p1'
$ Extension:='f$parse(p1,,,"TYPE","SYNTAX_ONLY")'
$ if Extension .eqs. "." then Filename:='p1'.C
$!
$! Do the object file
$!
$ Object_File:='f$parse(p1,,,"NAME","SYNTAX_ONLY")'
$!
$! Start the pre-processor invocation string
$!
$ cpp_args=""
$!
$! Do any defines
$!
$ inArg = p3
$ if inArg .nes. "" then gosub parseList
$!
$! Do any undefines
$!
$ inArg = p4
$ if inArg .nes. "" then gosub parseList
$!
$! Do any include directories
$!
$ Includes_Loop:
$ if p5 .eqs. "" then goto Includes_Done
$ l = f$locate(",",p5)
$ l1 = l
$ arg = f$extract(0,l,p5)
$ l1 = l1 + 1
$ p5 = f$extract(l1,255,p5)
$ l = l + 5
$ gosub doubleQuotes
$ cpp_args = cpp_args + " ""-I" + arg + """"
$ goto Includes_Loop
$!
$ Includes_Done:
$!
$! Calculate the Temp file name
$!
$ Temp_File:=GCC_'f$getjpi(0,"PID")'
$!
$! Do the "C" pre-processor
$!
$ if Quiet .eqs. "" then set verify
$ gcc_cpp 'cpp_args''Alignment_Define' 'Filename' 'Temp_File'.CPP
$ Status=$status
$ l = 'f$verify(0)'
$ if Status .nes. "%X00000001" then goto CPP_Error
$!
$! Do the "C" compilation
$!
$ Assembly_File:='Temp_File'.S
$ if Machine_Code then Assembly_File:='Object_File'.S
$ if Quiet .eqs. "" then set verify
$ gcc_cc1 'Temp_File'.CPP'Quiet' -dumpbase 'Filename''Optimize''Debug' -mgnu 'CC1_Options''Save_R2_R5''Alignment' -o 'Assembly_File'
$ Status=$status
$ l = 'f$verify(0)'
$ delete/nolog/noconfirm 'Temp_File'.CPP;
$ if Status .nes. "%X00000001" then goto CC1_Error
$!
$! Do the assembly
$!
$ if Machine_Code then goto Exit
$ if Quiet .eqs. "" then set verify
$ gcc_as 'Temp_File'.S -o 'Object_File'.OBJ
$ Status=$status
$ l = 'f$verify(0)'
$ delete/nolog/noconfirm 'Assembly_File';
$ if Status .nes. "%X00000001" then goto Gas_Error
$ goto Exit
$!
$! ERRORS:
$! ------
$ Ctly_Abort:
$ if Temp_File .eqs. "" then exit 4
$
$ Gas_Error:
$ delete/nolog/noconfirm 'Temp_File'.OBJ;
$ if verifying then set verify
$ exit Status ! Error in Assembly phase
$ CC1_Error:
$ delete/nolog/noconfirm 'Assembly_File';
$ if verifying then set verify
$ exit Status ! Error in "C" Compilation phase
$ CPP_Error:
$ delete/nolog/noconfirm 'Temp_File'.CPP;
$ if verifying then set verify
$ exit Status ! Error in "C" Pre-Processor phase
$!
$! Done
$!
$ Exit:
$ if verifying then set verify
$ exit 1
$!
$! Double up them double quotes
$!
$doubleQuotes:
$ k = f$length(arg)
$ if k .eq. 0 then goto noQuotes
$ j = 0
$ newArg = ""
$ dq1$:
$ c = f$extract(j,1,arg)
$ if c .eqs. """" then newArg = newArg + """"
$ newArg = newArg + c
$ j = j+1
$ if j .lt. k then goto dq1$
$ arg = newArg
$ noQuotes:
$ return
$!
$! Parse a list of comma-separated tokens
$!
$! inArg = input string
$!
$parseList:
$!echo = "write sys$output"
$ DQUOTE = """"
$ i = 0
$ len = f$length(inArg)
$ arg = ""
$ 1$:
$ if i .ge. len then goto noMoreDefines
$ c = f$extract(i, 1, inArg)
$ if c .eqs. DQUOTE then goto quotedString
$ if c .eqs. "," then goto OneDefineDone
$ arg = arg + c
$ goto 4$
$ quotedString:
$ arg = arg + c
$ i = i+1
$ 2$:
$ if i .ge. len then goto noMoreDefines
$ c = f$extract(i, 1, inArg)
$ if c .nes. DQUOTE then goto 3$
$ if f$extract(i+1, 1, inArg) .eqs. DQUOTE then goto 2a$
$ arg = arg + c
$ goto 4$
$ 2a$:
$ arg = arg + c
$ i = i+1
$ 3$:
$ arg = arg + c
$ i = i+1
$ goto 2$
$ OneDefineDone:
$ gosub doubleQuotes
$! echo "arg: ", arg
$ cpp_args = cpp_args + " ""-D" + arg + """
$ arg = ""
$ goto 4$
$ 4$:
$ i = i+1
$ goto 1$
$ noMoreDefines:
$ if arg .eqs. "" then goto Defines_Done
$ gosub doubleQuotes
$! echo "arg: ", arg
$ cpp_args = cpp_args + " " + DQUOTE + "-D" + arg + DQUOTE
$!
$ Defines_Done:
$! echo "cpp_args: ", cpp_args
$ return