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$search("OBJC-PARSE.Y") .eqs. "") then goto yes_yfiles
299 $if (f$cvtime(f$file_attributes("C-PARSE.IN","RDT")).gts. -
300 f$cvtime(f$file_attributes("OBJC-PARSE.Y","RDT"))) -
304 $echo "Now processing c-parse.in to generate c-parse.y and objc-parse.y."
305 $ edit/tpu/nojournal/nosection/nodisplay/command=sys$input
307 ! Read c-parse.in, write c-parse.y and objc-parse.y, depending on
308 ! paired lines of "ifc" & "end ifc" and "ifobjc" & "end ifobjc" to
309 ! control what goes into each file. Most lines will be common to
310 ! both (hence not bracketed by either control pair). Mismatched
311 ! pairs aren't detected--garbage in, garbage out...
314 PROCEDURE do_output()
315 IF NOT objc_only THEN POSITION(END_OF(c)); COPY_TEXT(input_line); ENDIF;
316 IF NOT c_only THEN POSITION(END_OF(objc)); COPY_TEXT(input_line); ENDIF;
317 POSITION(input_file); !reset
320 input_file := CREATE_BUFFER("input", "c-parse.in"); !load data
321 SET(NO_WRITE, input_file);
322 c := CREATE_BUFFER("c_output"); !1st output file
323 objc := CREATE_BUFFER("objc_output"); !2nd output file
325 POSITION(BEGINNING_OF(input_file));
330 EXITIF MARK(NONE) = END_OF(input_file); !are we done yet?
332 input_line := CURRENT_LINE; !access current_line just once
333 CASE EDIT(input_line, TRIM_TRAILING, OFF, NOT_IN_PLACE)
334 ["ifc"] : c_only := 1;
335 ["end ifc"] : c_only := 0;
336 ["ifobjc"] : objc_only := 1;
337 ["end ifobjc"] : objc_only := 0;
338 ! default -- add non-control line to either or both output files
339 [INRANGE] : do_output(); !between "end" and "if"
340 [OUTRANGE] : do_output(); !before "end" or after "if"
343 MOVE_VERTICAL(1); !go to next line
346 WRITE_FILE(c, "c-parse.y");
347 WRITE_FILE(objc, "objc-parse.y");
352 $open cfile$ compilers.list
353 $cloop:read cfile$ compilername/end=cdone
354 $! language specific modules
356 $if (DO_ALL + DO_'compilername').eq.0 then goto cloop
357 $if DO_LINK.eq.0 then -
358 call compile 'compilername'-objs.opt "obstack,bc-emit,bc-optab"
360 $! CAUTION: If you want to link gcc-cc1* to the sharable image library
361 $! VAXCRTL, see the notes in gcc.texinfo (or INSTALL) first.
364 $ 'LINK''LDFLAGS'/Exe=gcc-'compilername'.exe version.opt/Opt,-
365 'compilername'-objs.opt/Opt,independent.opt/Opt,-
374 $ then set default [.objc] !push
375 $ save_cflags = CFLAGS
376 $ CFLAGS = CFLAGS - CINCL1 - CINCL2 + CINCL_SUB
377 $ MFLAGS = "/Lang=ObjC" + CFLAGS
378 $ library/Obj [-]objclib.olb/Create
379 $ if f$trnlnm("IFILE$").nes."" then close/noLog ifile$
380 $ open/Read ifile$ [-]objc-objs.opt
381 $ocl1: read/End=ocl3 ifile$ line
383 $ocl2: o = f$element(i,",",line)
384 $ if o.eqs."," then goto ocl1
386 $ if f$search(n + ".m").nes.""
395 $ library/Obj [-]objclib.olb 'n'.obj/Insert
396 $ delete/noConfirm/noLog 'n'.obj;*
400 $ CFLAGS = save_cflags
401 $ set default [-] !pop
409 $! Various DCL subroutines follow...
411 $! This routine takes parameter p1 to be a linker options file with a list
412 $! of object files that are needed. It extracts the names, and compiles
413 $! each source module, one by one. File names that begin with an
414 $! "INSN-" are assumed to be generated by a GEN*.C program.
416 $! Parameter P2 is a list of files which will appear in the options file
417 $! that should not be compiled. This allows us to handle special cases.
421 $on error then goto c_err
422 $on control_y then goto c_err
424 $loop: read ifile$ line/end=c_done
428 $flnm=f$element(i,",",line)
430 $if flnm.eqs."" then goto loop
431 $if flnm.eqs."," then goto loop
432 $if f$locate(flnm,p2).lt.f$length(p2) then goto loop1
433 $! check for front-end subdirectory: "[.prfx]flnm"
435 $k = f$locate("]",flnm)
436 $if k.eq.1 ![]c-common for [.cp]
438 $ if f$search(f$parse(".obj",flnm)).nes."" then goto loop1
439 $ flnm = f$extract(2,999,flnm)
440 $else if k.lt.f$length(flnm)
441 $ then prfx = f$extract(2,k-2,flnm)
442 $ flnm = f$extract(k+1,99,flnm)
446 $ then set default [.'prfx'] !push
447 $ save_cflags = CFLAGS
448 $ CFLAGS = CFLAGS - CINCL1 - CINCL2 + CINCL_SUB
451 $ if f$locate("parse",flnm).nes.f$length(flnm)
453 $ if f$search("''flnm'.c").nes."" then -
454 if f$cvtime(f$file_attributes("''flnm'.c","RDT")).ges. -
455 f$cvtime(f$file_attributes("''flnm'.y","RDT")) then goto skip_yacc
457 $ 'PARSER' 'PARSER_FLAGS' 'flnm'.y
458 $ 'RENAME' 'flnm'_tab.c 'flnm'.c
459 $ 'RENAME' 'flnm'_tab.h 'flnm'.h
461 $ if flnm.eqs."cp-parse" .or. (prfx.eqs."cp" .and. flnm.eqs."parse")
462 $ then ! fgrep '#define YYEMPTY' cp-parse.c >>cp-parse.h
463 $ if f$trnlnm("JFILE$").nes."" then close/noLog jfile$
464 $ open/Append jfile$ 'flnm'.h
465 $ 'SEARCH'/Exact/Output=jfile$ 'flnm'.c "#define YYEMPTY"
469 $ echo " (Ignore any warning about not finding file ""bison.simple"".)"
472 $if f$extract(0,5,flnm).eqs."insn-" then call generate 'flnm'.c
475 $ 'CC''CFLAGS' 'flnm'.c
478 $ then set default [-] !pop
479 $ CFLAGS = save_CFLAGS
485 $! In case of error or abort, go here (In order to close file).
487 $c_err: !'f$verify(0)
495 $! This subroutine generates the insn-* files. The first argument is the
496 $! name of the insn-* file to generate. The second argument contains a
497 $! list of any other object modules which must be linked to the gen*.c
502 $if f$extract(0,5,p1).nes."INSN-"
504 $ write sys$error "Unknown file passed to generate."
507 $root1=f$parse(f$extract(5,255,p1),,,"NAME")
509 $ 'CC''CFLAGS' GEN'root1'.C
510 $ 'LINK''f$string(LDFLAGS - "/Debug")' GEN'root1'.OBJ,rtl.obj,obstack.obj,'p2' -
515 $ assign/user 'p1' sys$output:
516 $ mcr sys$disk:[]GEN'root1' vax.md
520 $! This subroutine generates the bc-* files. The first argument is the
521 $! name of the bc-* file to generate. The second argument contains a
522 $! list of any other object modules which must be linked to the bi*.c
527 $if f$extract(0,3,p1).nes."BC-"
529 $ write sys$error "Unknown file passed to bc_generate."
532 $root1=f$parse(f$extract(3,255,p1),,,"NAME")
534 $ 'CC''CFLAGS' BI-'root1'.C
535 $ 'LINK''f$string(LDFLAGS - "/Debug")' BI-'root1'.OBJ,'p2' -
540 $ assign/user bytecode.def sys$input:
541 $ assign/user 'p1' sys$output:
542 $ mcr sys$disk:[]BI-'root1'