home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / gnu / gccdist / gcc-src / vms / old-driver / gcc.com < prev    next >
Encoding:
Text File  |  1991-02-27  |  5.7 KB  |  226 lines

  1. $ Verifying:= 'f$verify(0)'
  2. $!
  3. $!    GNU "CC" Compiler command file
  4. $!
  5. $!    Invoked from the GCC compile driver via LIB$DO_COMMAND:
  6. $!        P1 = File to compile
  7. $!        P2 = Options: O - Optimize
  8. $!                  D - Debug
  9. $!                  M - Produce Machine Code
  10. $!                  V - Be verbose during compilation
  11. $!        P3 = "," separated Defines
  12. $!        P4 = "," separated Undefines
  13. $!        P5 = "," separated Include directories
  14. $!        P6 = CC1 compilation phase options, including:
  15. $!            -mdont-save-r2-r5    (PCC style register saving)
  16. $!            -mpcc-alignment        (PCC style struct align)
  17. $!
  18. $!
  19. $!  Constants:
  20. $!
  21. $ Version:='f$trnlnm("GNU_CC_VERSION")'
  22. $ gcc_cpp="$GNU_CC:[000000]GCC-CPP"
  23. $ gcc_cc1="$GNU_CC:[000000]GCC-CC1"
  24. $ gcc_as= "$GNU_CC:[000000]GCC-AS ""-vGNU CC  V''Version'"""
  25. $!
  26. $!  Parse the options
  27. $!  -----------------
  28. $ P2_Length = f$length(P2)    ! So we only have to calculate it once
  29. $ Optimize = ""            !    Default = No Optimize
  30. $ Debug = ""            !    Default = No Debug
  31. $ Machine_Code = 0        !    Default = No Machine Code
  32. $ Quiet = " -quiet"        !    Default = Silent
  33. $ if f$locate("O",p2) .ne. P2_Length then Optimize = " -opt"
  34. $ if f$locate("D",p2) .ne. P2_Length then Debug = " ""-G"""
  35. $ if f$locate("M",p2) .ne. P2_Length then Machine_Code = 1
  36. $ if f$locate("V",p2) .ne. P2_Length then Quiet = ""
  37. $ Temp_File = ""        ! For Control_Y abort check
  38. $ On Control_Y then Goto Ctly_Abort
  39. $!
  40. $!    Do the CC1 compilation phase options
  41. $!
  42. $ CC1_Options = P6
  43. $ Save_R2_R5 = ""
  44. $ if f$locate("-mdont-save-r2-r5",P6) .eq. f$length(P6) then goto 10$
  45. $ Save_R2_R5 = " -fcall-used-r2 -fcall-used-r3 -fcall-used-r4 -fcall-used-r5"
  46. $ l = f$locate("-mdont-save-r2-r5",P6)
  47. $ l1 = l + 17
  48. $ CC1_Options = "''f$extract(0,l,P6)'''f$extract(l1,255,P6)'"
  49. $ 10$:
  50. $ Alignment = " -mvaxc-alignment"
  51. $ if f$locate("-mpcc-alignment",P6) .eq. f$length(P6) then goto 20$
  52. $ Alignment = ""
  53. $ Alignment_Define = " ""-DPCC_ALIGNMENT"""
  54. $ l = f$locate("-mpcc-alignment",CC1_Options)
  55. $ l1 = l + 15
  56. $ CC1_Options = "''f$extract(0,l,CC1_Options)'''f$extract(l1,255,CC1_Options)'"
  57. $ 20$:
  58. $!
  59. $!  Do the filename (default to ".C")
  60. $!
  61. $ Filename:='p1'
  62. $ Extension:='f$parse(p1,,,"TYPE","SYNTAX_ONLY")'
  63. $ if Extension .eqs. "." then Filename:='p1'.C
  64. $!
  65. $!    Do the object file
  66. $!
  67. $ Object_File:='f$parse(p1,,,"NAME","SYNTAX_ONLY")'
  68. $!
  69. $!    Start the pre-processor invocation string
  70. $!
  71. $ cpp_args=""
  72. $!
  73. $!    Do any defines
  74. $!
  75. $ inArg = p3
  76. $ if inArg .nes. "" then gosub parseList
  77. $!
  78. $!    Do any undefines
  79. $!
  80. $ inArg = p4
  81. $ if inArg .nes. "" then gosub parseList
  82. $!
  83. $!    Do any include directories
  84. $!
  85. $ Includes_Loop:
  86. $ if p5 .eqs. "" then goto Includes_Done
  87. $ l = f$locate(",",p5)
  88. $ l1 = l
  89. $ arg = f$extract(0,l,p5)
  90. $ l1 = l1 + 1
  91. $ p5 = f$extract(l1,255,p5)
  92. $ l = l + 5
  93. $ gosub doubleQuotes
  94. $ cpp_args = cpp_args + " ""-I" + arg + """"
  95. $ goto Includes_Loop
  96. $!
  97. $ Includes_Done:
  98. $!
  99. $!    Calculate the Temp file name
  100. $!
  101. $ Temp_File:=GCC_'f$getjpi(0,"PID")'
  102. $!
  103. $!    Do the "C" pre-processor
  104. $!
  105. $ if Quiet .eqs. "" then set verify
  106. $ gcc_cpp 'cpp_args''Alignment_Define' 'Filename' 'Temp_File'.CPP
  107. $ Status=$status
  108. $ l = 'f$verify(0)'
  109. $ if Status .nes. "%X00000001" then goto CPP_Error
  110. $!
  111. $!    Do the "C" compilation
  112. $!
  113. $ Assembly_File:='Temp_File'.S
  114. $ if Machine_Code then Assembly_File:='Object_File'.S
  115. $ if Quiet .eqs. "" then set verify
  116. $ gcc_cc1 'Temp_File'.CPP'Quiet' -dumpbase 'Filename''Optimize''Debug' -mgnu 'CC1_Options''Save_R2_R5''Alignment' -o 'Assembly_File'
  117. $ Status=$status
  118. $ l = 'f$verify(0)'
  119. $ delete/nolog/noconfirm 'Temp_File'.CPP;
  120. $ if Status .nes. "%X00000001" then goto CC1_Error
  121. $!
  122. $!    Do the assembly
  123. $!
  124. $ if Machine_Code then goto Exit
  125. $ if Quiet .eqs. "" then set verify
  126. $ gcc_as 'Temp_File'.S -o 'Object_File'.OBJ
  127. $ Status=$status
  128. $ l = 'f$verify(0)'
  129. $ delete/nolog/noconfirm 'Assembly_File';
  130. $ if Status .nes. "%X00000001" then goto Gas_Error
  131. $ goto Exit
  132. $!
  133. $!    ERRORS:
  134. $!    ------
  135. $ Ctly_Abort:
  136. $ if Temp_File .eqs. "" then exit 4
  137. $
  138. $ Gas_Error:
  139. $ delete/nolog/noconfirm 'Temp_File'.OBJ;
  140. $ if verifying then set verify
  141. $ exit Status    ! Error in Assembly phase
  142. $ CC1_Error:
  143. $ delete/nolog/noconfirm 'Assembly_File';
  144. $ if verifying then set verify
  145. $ exit Status    ! Error in "C" Compilation phase
  146. $ CPP_Error:
  147. $ delete/nolog/noconfirm 'Temp_File'.CPP;
  148. $ if verifying then set verify
  149. $ exit Status    ! Error in "C" Pre-Processor phase
  150. $!
  151. $!    Done
  152. $!
  153. $ Exit:
  154. $ if verifying then set verify
  155. $ exit 1
  156. $!
  157. $!    Double up them double quotes
  158. $!
  159. $doubleQuotes:
  160. $ k = f$length(arg)
  161. $ if k .eq. 0 then goto noQuotes
  162. $ j = 0
  163. $ newArg = ""
  164. $ dq1$:
  165. $  c = f$extract(j,1,arg)
  166. $  if c .eqs. """" then newArg = newArg + """"
  167. $  newArg = newArg + c
  168. $  j = j+1
  169. $  if j .lt. k then goto dq1$
  170. $ arg = newArg
  171. $ noQuotes:
  172. $ return
  173. $!
  174. $!    Parse a list of comma-separated tokens
  175. $!
  176. $!    inArg = input string
  177. $!
  178. $parseList:
  179. $!echo = "write sys$output"
  180. $ DQUOTE = """"
  181. $ i = 0
  182. $ len = f$length(inArg)
  183. $ arg = ""
  184. $ 1$:
  185. $   if i .ge. len then goto noMoreDefines
  186. $   c = f$extract(i, 1, inArg)
  187. $   if c .eqs. DQUOTE then goto quotedString
  188. $   if c .eqs. "," then goto OneDefineDone
  189. $     arg = arg + c
  190. $     goto 4$
  191. $   quotedString:
  192. $     arg = arg + c
  193. $     i = i+1
  194. $     2$:
  195. $       if i .ge. len then goto noMoreDefines
  196. $       c = f$extract(i, 1, inArg)
  197. $       if c .nes. DQUOTE then goto 3$
  198. $       if f$extract(i+1, 1, inArg) .eqs. DQUOTE then goto 2a$
  199. $       arg = arg + c
  200. $       goto 4$
  201. $     2a$:
  202. $       arg = arg + c
  203. $       i = i+1
  204. $     3$:
  205. $       arg = arg + c
  206. $    i = i+1
  207. $    goto 2$
  208. $    OneDefineDone:
  209. $      gosub doubleQuotes
  210. $!     echo "arg: ", arg
  211. $      cpp_args = cpp_args + " ""-D" + arg + """
  212. $      arg = ""
  213. $      goto 4$
  214. $    4$:
  215. $      i = i+1
  216. $      goto 1$
  217. $ noMoreDefines:
  218. $  if arg .eqs. "" then goto Defines_Done
  219. $  gosub doubleQuotes
  220. $! echo "arg: ", arg
  221. $  cpp_args = cpp_args + " " + DQUOTE + "-D" + arg + DQUOTE
  222. $!
  223. $ Defines_Done:
  224. $! echo "cpp_args: ", cpp_args
  225. $  return
  226.