1 $v='f$verify(0) !make-cc1.com
3 $! Build the GNU C compiler on VMS.
6 $! $ @make-cc1.com [host-compiler] [various]
8 $! where [host-compiler] is one of "GNUC", "VAXC", "DECC";
9 $! default when none specified is "GNUC",
10 $! and where [various] is one or more of "CC1", "CC1PLUS",
11 $! "CC1OBJ", "OBJCLIB", "INDEPENDENT", "BC", "ALL", "LINK", "DEBUG".
12 $! "CC1" (C compiler) is the default; of the others, only
13 $! "CC1PLUS" (C++ compiler), "CC1OBJ" (Objective-C compiler),
14 $! and "OBJCLIB" (Objective-C run-time library) are of interest
15 $! for normal installation.
16 $! If both [host-compiler] and other option(s) are specified,
17 $! the host compiler argument must come first.
19 $ if f$type(gcc_debug).eqs."INTEGER" then if gcc_debug.and.1 then set verify
21 $ p1 = f$edit(p1,"UPCASE,TRIM")
22 $ if p1.eqs."" then p1 = "GNUC"
24 $! Compiler-specific setup (assume GNU C, then override as necessary):
27 $ CFLAGS = "/Debug/noVerbos/CC1=""-mpcc-alignment"""
28 $ LIBS = "gnu_cc:[000000]gcclib.olb/Libr,sys$library:vaxcrtl.olb/Libr"
34 $ CFLAGS = "/noOpt" !disable optimizer when bootstrapping with native cc
35 $ if p2.eqs."DEBUG" .or. p3.eqs."DEBUG" then CFLAGS = CFLAGS + "/Debug"
39 $ if f$trnlnm("DECC$CC_DEFAULT").nes."" then CC = "cc/VAXC"
40 $ LIBS = "alloca.obj,sys$library:vaxcrtl.olb/Libr"
41 $ define/noLog SYS SYS$LIBRARY:
46 $ if f$trnlnm("DECC$CC_DEFAULT").nes."" then CC = "cc/DECC"
47 $ CC = CC + "/Prefix=All/Warn=Disabl=(ImplicitFunc)"
48 $ LIBS = "alloca.obj" !DECC$SHR will be found implicitly by linker
49 $ define/noLog SYS DECC$LIBRARY_INCLUDE:
59 $ PARSER_FLAGS= "/Define/Verbose"
60 $ RENAME = "rename/New_Version"
64 $ ABORT = "exit %x002C"
65 $ echo = "write sys$output"
69 $ CINCL1 = "/Incl=[]" !stage 1 -I flags
70 $ CINCL2 = "/Incl=([],[.ginclude])" !stage 2,3,... flags
71 $ CINCL_SUB = "/Incl=([],[-],[-.ginclude])" ![.cp] flags
74 $! Nothing beyond this point should need any local configuration changes.
77 $! Set the default directory to the same place as this command procedure.
78 $ flnm = f$enviroment("PROCEDURE") !get current procedure name
79 $ set default 'f$parse(flnm,,,"DEVICE")''f$parse(flnm,,,"DIRECTORY")'
82 $! First we figure out what needs to be done. This is sort of like a limited
83 $! make facility - the command line options specify exactly what components
84 $! we want to build. The following options are understood:
86 $! LINK: Assume that the object modules for the selected compiler(s)
87 $! have already been compiled, perform link phase only.
89 $! CC1: Compile and link "C" compiler.
91 $! CC1PLUS:Compile and link "C++" compiler.
93 $! CC1OBJ: Compile and link objective C compiler.
95 $! ALL: Compile and link all of the CC1 passes.
98 $! Compile language independent source modules. (On by default).
101 $! Compile byte compiler source modules. (On by default).
104 $! Compile Objective-C run-time library.
106 $! DEBUG: Link images with /debug.
108 $! If you want to list more than one option, you should use a spaces to
111 $! Any one of the above options can be prefaced with a "NO". For example,
112 $! if you had already built GCC, and you wanted to build G++, you could use the
113 $! "CC1PLUS NOINDEPENDENT" options, which would only compile the C++ language
114 $! specific source files, and then link the C++ compiler.
116 $! If you do not specify which compiler you want to build, it is assumed that
117 $! you want to build GNU-C ("CC1").
119 $! Now figure out what we have been requested to do.
120 $p1 = p1+" "+p2+" "+p3+" "+p4+" "+p5+" "+p6+" "+p7+" "+p8
121 $p1 = f$edit(p1,"COMPRESS,TRIM")
129 $if f$trnlnm("cfile$").nes."" then close/noLog cfile$
130 $open cfile$ compilers.list
131 $cinit:read cfile$ compilername/end=cinit_done
134 $cinit_done: close cfile$
139 $string = f$element(i," ",p1)
140 $if string.eqs." " then goto done
142 $if string.eqs."CC1PLUS" then DO_DEFAULT = 0
143 $if string.eqs."CC1OBJ" then DO_DEFAULT = 0
144 $if string.eqs."OBJCLIB"
146 $ DO_INDEPENDENT = DO_CC1OBJ
149 $if f$extract(0,2,string).nes."NO" then goto parse_option
150 $ string=f$extract(2,f$length(string)-2,string)
158 $if DO_DEFAULT.eq.1 then DO_CC1 = 1
159 $echo "This command file will now perform the following actions:
160 $if DO_LINK.eq.1 then goto link_only
161 $if DO_ALL.eq.1 then echo " Compile all language specific object modules."
162 $if DO_CC1.eq.1 then echo " Compile C specific object modules."
163 $if DO_CC1PLUS.eq.1 then echo " Compile C++ specific object modules."
164 $if DO_CC1OBJ.eq.1 then echo " Compile obj-C specific object modules."
165 $if DO_INDEPENDENT.eq.1 then echo " Compile language independent object modules."
166 $if DO_BC.eq.1 then echo " Compile byte compiler object modules."
167 $if DO_OBJCLIB.eq.1 then echo " Create Objective-C run-time library."
169 $if DO_CC1.eq.1 then echo " Link C compiler (gcc-cc1.exe)."
170 $if DO_CC1PLUS.eq.1 then echo " Link C++ compiler (gcc-cc1plus.exe)."
171 $if DO_CC1OBJ.eq.1 then echo " Link objective-C compiler (gcc-cc1obj.exe)."
172 $if DO_DEBUG.eq.1 then echo " Link images to run under debugger."
174 $! Update CFLAGS with appropriate CINCLx value.
176 $if f$edit(f$extract(0,3,CC),"LOWERCASE").nes."gcc" then goto stage1
177 $if f$search("gcc-cc1.exe").eqs."" then goto stage1
178 $if f$file_attr("gnu_cc:[000000]gcc-cc1.exe","FID").nes.-
179 f$file_attr("gcc-cc1.exe","FID") then goto stage1
180 $ CFLAGS = CFLAGS + CINCL2
183 $ CFLAGS = CFLAGS + CINCL1
186 $! Test and see if we need these messages or not. The -1 switch gives it away.
188 $gas := $gnu_cc:[000000]gcc-as.exe
189 $if f$search(gas-"$").eqs."" then goto gas_missing_message !must be VAXC
190 $define/user sys$error sys$scratch:gas_test.tmp
191 $gas -1 nla0: -o nla0:
192 $size=f$file_attributes("sys$scratch:gas_test.tmp","ALQ")
193 $delete/nolog sys$scratch:gas_test.tmp;*
194 $if size.eq.0 then goto skip_gas_message
195 $type sys$input: !an old version of gas was found
198 Note: you appear to have an old version of gas, the GNU assembler.
199 GCC 2.x treats external variables differently than GCC 1.x does. Before
200 you use GCC 2.x, you should obtain a version of the assembler which works
201 with GCC 2.x (gas-1.38 and earlier did not have the necessary support;
202 gas-2.0 through gas-2.3 did not work reliably for vax/vms configuration).
203 The assembler in gcc-vms-1.42 contained patches to provide the proper
204 support, and more recent versions have an up to date version of gas which
205 provides the support. gas from binutils-2.5 or later is recommended.
207 If you do not update the assembler, the compiler will still work,
208 but `extern const' variables will be treated as `extern'. This will result
209 in linker warning messages about mismatched psect attributes, and these
210 variables will be placed in read/write storage.
213 $goto skip_gas_message
214 $gas_missing_message:
215 $type sys$input: !no version of gas was found
218 Note: you appear to be missing gas, the GNU assembler. Since
219 GCC produces assembly code as output from compilation, you need the
220 assembler to make full use of the compiler. It should be put in place
221 as GNU_CC:[000000]GCC-AS.EXE.
223 A prebuilt copy of gas is available from the "gcc-vms" distribution,
224 and the gas source code is included in the GNU "binutils" distribution.
225 Version 2.5.2 or later is recommended.
231 $ if DO_DEBUG.eq.1 then LDFLAGS = LDFLAGS + "/Debug"
233 $if DO_LINK.eq.1 then goto no_yfiles !compile_cc1
235 $! Build alloca if necessary (in 'LIBS for use with VAXC)
237 $ if f$locate("alloca.obj",f$edit(LIBS,"lowercase")).ge.f$length(LIBS) then -
239 $ if f$search("alloca.obj").nes."" then - !does .obj exist? is it up to date?
240 if f$cvtime(f$file_attributes("alloca.obj","RDT")).gts.-
241 f$cvtime(f$file_attributes("alloca.c","RDT")) then goto skip_alloca
243 $ 'CC''CFLAGS'/Defi=("HAVE_CONFIG_H","STACK_DIRECTION=(-1)") alloca.c
249 $ call compile bi_all.opt ""
250 $ if f$trnlnm("ifile$").nes."" then close/noLog ifile$
251 $ open ifile$ bc_all.list
252 $ read ifile$ bc_line
256 $ tfile = f$element(bc_index, ",", bc_line)
257 $ if tfile.eqs."," then goto bc_done
258 $ call bc_generate 'tfile' "bi_all.opt/opt,"
259 $ bc_index = bc_index + 1
265 $if DO_INDEPENDENT.eq.1
268 $! First build a couple of header files from the machine description
269 $! These are used by many of the source modules, so we build them now.
273 $ 'CC''CFLAGS' obstack.c
275 $! Generate insn-attr.h
276 $ call generate insn-attr.h
277 $ call generate insn-flags.h
278 $ call generate insn-codes.h
279 $ call generate insn-config.h
281 $call compile independent.opt "rtl,obstack,insn-attrtab"
283 $ call generate insn-attrtab.c "rtlanal.obj,"
285 $ 'CC''CFLAGS' insn-attrtab.c
286 $ 'CC''CFLAGS' bc-emit.c
287 $ 'CC''CFLAGS' bc-optab.c
292 $if (DO_CC1 + DO_CC1OBJ) .ne.0
294 $if (f$search("C-PARSE.Y") .eqs. "") then goto yes_yfiles
295 $if (f$cvtime(f$file_attributes("C-PARSE.IN","RDT")).gts. -
296 f$cvtime(f$file_attributes("C-PARSE.Y","RDT"))) -
298 $if f$parse("[.OBJC]").eqs."" then create/Directory [.objc]
299 $if (f$search("[.OBJC]OBJC-PARSE.Y") .eqs. "") then goto yes_yfiles
300 $if (f$cvtime(f$file_attributes("C-PARSE.IN","RDT")).gts. -
301 f$cvtime(f$file_attributes("[.OBJC]OBJC-PARSE.Y","RDT"))) -
305 $echo "Now processing c-parse.in to generate c-parse.y and [.objc]objc-parse.y."
306 $ EDIT/Tpu/noJournal/noSection/noDisplay/Command=sys$input:
308 ! Read c-parse.in, write c-parse.y and objc/objc-parse.y, depending on
309 ! paired lines of "ifc" & "end ifc" and "ifobjc" & "end ifobjc" to
310 ! control what goes into each file. Most lines will be common to
311 ! both (hence not bracketed by either control pair). Mismatched
312 ! pairs aren't detected--garbage in, garbage out...
315 PROCEDURE do_output()
316 IF NOT objc_only THEN POSITION(END_OF(c)); COPY_TEXT(input_line); ENDIF;
317 IF NOT c_only THEN POSITION(END_OF(objc)); COPY_TEXT(input_line); ENDIF;
318 POSITION(input_file); !reset
321 input_file := CREATE_BUFFER("input", "c-parse.in"); !load data
322 SET(NO_WRITE, input_file);
323 c := CREATE_BUFFER("c_output"); !1st output file
324 objc := CREATE_BUFFER("objc_output"); !2nd output file
326 POSITION(BEGINNING_OF(input_file));
331 EXITIF MARK(NONE) = END_OF(input_file); !are we done yet?
333 input_line := CURRENT_LINE; !access current_line just once
334 CASE EDIT(input_line, TRIM_TRAILING, OFF, NOT_IN_PLACE)
335 ["ifc"] : c_only := 1;
336 ["end ifc"] : c_only := 0;
337 ["ifobjc"] : objc_only := 1;
338 ["end ifobjc"] : objc_only := 0;
339 ! default -- add non-control line to either or both output files
340 [INRANGE] : do_output(); !between "end" and "if"
341 [OUTRANGE] : do_output(); !before "end" or after "if"
344 MOVE_VERTICAL(1); !go to next line
347 WRITE_FILE(c, "c-parse.y");
348 WRITE_FILE(objc, "[.objc]objc-parse.y");
353 $open cfile$ compilers.list
354 $cloop:read cfile$ compilername/end=cdone
355 $! language specific modules
357 $if (DO_ALL + DO_'compilername').eq.0 then goto cloop
358 $if DO_LINK.eq.0 then -
359 call compile 'compilername'-objs.opt "obstack,bc-emit,bc-optab"
361 $! CAUTION: If you want to link gcc-cc1* to the sharable image library
362 $! VAXCRTL, see the notes in gcc.texinfo (or INSTALL) first.
365 $ 'LINK''LDFLAGS'/Exe=gcc-'compilername'.exe version.opt/Opt,-
366 'compilername'-objs.opt/Opt,independent.opt/Opt,-
375 $ then set default [.objc] !push
376 $ save_cflags = CFLAGS
377 $ CFLAGS = CFLAGS - CINCL1 - CINCL2 + CINCL_SUB
378 $ MFLAGS = "/Lang=ObjC" + CFLAGS
379 $ library/Obj [-]objclib.olb/Create
380 $ if f$trnlnm("IFILE$").nes."" then close/noLog ifile$
381 $ open/Read ifile$ [-]objc-objs.opt
382 $ocl1: read/End=ocl3 ifile$ line
384 $ocl2: o = f$element(i,",",line)
385 $ if o.eqs."," then goto ocl1
387 $ if f$search(n + ".m").nes.""
396 $ library/Obj [-]objclib.olb 'n'.obj/Insert
397 $ delete/noConfirm/noLog 'n'.obj;*
401 $ CFLAGS = save_cflags
402 $ set default [-] !pop
410 $! Various DCL subroutines follow...
412 $! This routine takes parameter p1 to be a linker options file with a list
413 $! of object files that are needed. It extracts the names, and compiles
414 $! each source module, one by one. File names that begin with an
415 $! "INSN-" are assumed to be generated by a GEN*.C program.
417 $! Parameter P2 is a list of files which will appear in the options file
418 $! that should not be compiled. This allows us to handle special cases.
422 $on error then goto c_err
423 $on control_y then goto c_err
425 $loop: read ifile$ line/end=c_done
429 $flnm=f$element(i,",",line)
431 $if flnm.eqs."" then goto loop
432 $if flnm.eqs."," then goto loop
433 $if f$locate(flnm,p2).lt.f$length(p2) then goto loop1
434 $! check for front-end subdirectory: "[.prfx]flnm"
436 $k = f$locate("]",flnm)
437 $if k.eq.1 ![]c-common for [.cp]
439 $ if f$search(f$parse(".obj",flnm)).nes."" then goto loop1
440 $ flnm = f$extract(2,999,flnm)
441 $else if k.lt.f$length(flnm)
442 $ then prfx = f$extract(2,k-2,flnm)
443 $ flnm = f$extract(k+1,99,flnm)
447 $ then set default [.'prfx'] !push
448 $ save_cflags = CFLAGS
449 $ CFLAGS = CFLAGS - CINCL1 - CINCL2 + CINCL_SUB
452 $ if f$locate("parse",flnm).nes.f$length(flnm)
454 $ if f$search("''flnm'.c").nes."" then -
455 if f$cvtime(f$file_attributes("''flnm'.c","RDT")).ges. -
456 f$cvtime(f$file_attributes("''flnm'.y","RDT")) then goto skip_yacc
458 $ 'PARSER' 'PARSER_FLAGS' 'flnm'.y
459 $ 'RENAME' 'flnm'_tab.c 'flnm'.c
460 $ 'RENAME' 'flnm'_tab.h 'flnm'.h
462 $ if flnm.eqs."cp-parse" .or. (prfx.eqs."cp" .and. flnm.eqs."parse")
463 $ then ! fgrep '#define YYEMPTY' cp-parse.c >>cp-parse.h
464 $ if f$trnlnm("JFILE$").nes."" then close/noLog jfile$
465 $ open/Append jfile$ 'flnm'.h
466 $ 'SEARCH'/Exact/Output=jfile$ 'flnm'.c "#define YYEMPTY"
470 $ echo " (Ignore any warning about not finding file ""bison.simple"".)"
473 $if f$extract(0,5,flnm).eqs."insn-" then call generate 'flnm'.c
476 $ 'CC''CFLAGS' 'flnm'.c
479 $ then set default [-] !pop
480 $ CFLAGS = save_CFLAGS
486 $! In case of error or abort, go here (In order to close file).
488 $c_err: !'f$verify(0)
496 $! This subroutine generates the insn-* files. The first argument is the
497 $! name of the insn-* file to generate. The second argument contains a
498 $! list of any other object modules which must be linked to the gen*.c
503 $if f$extract(0,5,p1).nes."INSN-"
505 $ write sys$error "Unknown file passed to generate."
508 $root1=f$parse(f$extract(5,255,p1),,,"NAME")
510 $ 'CC''CFLAGS' GEN'root1'.C
511 $ 'LINK''f$string(LDFLAGS - "/Debug")' GEN'root1'.OBJ,rtl.obj,obstack.obj,'p2' -
516 $ assign/user 'p1' sys$output:
517 $ mcr sys$disk:[]GEN'root1' vax.md
521 $! This subroutine generates the bc-* files. The first argument is the
522 $! name of the bc-* file to generate. The second argument contains a
523 $! list of any other object modules which must be linked to the bi*.c
528 $if f$extract(0,3,p1).nes."BC-"
530 $ write sys$error "Unknown file passed to bc_generate."
533 $root1=f$parse(f$extract(3,255,p1),,,"NAME")
535 $ 'CC''CFLAGS' BI-'root1'.C
536 $ 'LINK''f$string(LDFLAGS - "/Debug")' BI-'root1'.OBJ,'p2' -
541 $ assign/user bytecode.def sys$input:
542 $ assign/user 'p1' sys$output:
543 $ mcr sys$disk:[]BI-'root1'