1 $! Set the def dir to proper place for use in batch. Works for interactive too.
2 $flnm = f$enviroment("PROCEDURE") ! get current procedure name
3 $set default 'f$parse(flnm,,,"DEVICE")''f$parse(flnm,,,"DIRECTORY")'
7 $! CAUTION: If you want to link gcc-cc1 to the sharable image library
8 $! VAXCRTL, see the notes in gcc.texinfo (or INSTALL) first.
10 $! Build the GNU "C" compiler on VMS
12 $! Note: to build with DEC's VAX C compiler, uncomment the 2nd CC, CFLAGS,
13 $! and LIBS alternatives, and also execute the following command:
14 $! DEFINE SYS SYS$LIBRARY:
15 $! After a successful build, restore those items and rebuild with gcc.
20 $! CC = "cc" !uncomment for VAXC
22 $ BISON_FLAGS= "/Define/Verbose"
23 $ RENAME= "rename/New_Version"
27 $ ABORT = "exit %x002C"
28 $ echo = "write sys$output"
32 $ CFLAGS = "/Debug/noVerbos/CC1=""-mpcc-alignment"""
33 $! CFLAGS = "/noOpt" !uncomment for VAXC
34 $ CINCL1 = "/Incl=[]" !stage 1 -I flags
35 $ CINCL2 = "/Incl=([],[.ginclude])" !stage 2,3,... flags
36 $ CINCL_SUB = "/Incl=([],[-],[-.ginclude])" ![.cp] flags
44 $ LIBS = "gnu_cc:[000000]gcclib.olb/Libr,sys$library:vaxcrtl.olb/Libr"
45 $! LIBS = "alloca.obj,sys$library:vaxcrtl.olb/Libr" !uncomment for VAXC
48 $! Nothing beyond this point should need any local configuration changes.
52 $! First we figure out what needs to be done. This is sort of like a limited
53 $! make facility - the command line options specify exactly what components
54 $! we want to build. The following options are understood:
56 $! LINK: Assume that the object modules for the selected compiler(s)
57 $! have already been compiled, perform link phase only.
59 $! CC1: Compile and link "C" compiler.
61 $! CC1PLUS:Compile and link "C++" compiler.
63 $! CC1OBJ: Compile and link objective C compiler.
65 $! ALL: Compile and link all of the CC1 passes.
68 $! Compile language independent source modules. (On by default).
71 $! Compile byte compiler source modules. (On by default).
73 $! DEBUG: Link images with /debug.
75 $! If you want to list more than one option, you should use a spaces to
78 $! Any one of the above options can be prefaced with a "NO". For example,
79 $! if you had already built GCC, and you wanted to build G++, you could use the
80 $! "CC1PLUS NOINDEPENDENT" options, which would only compile the C++ language
81 $! specific source files, and then link the C++ compiler.
83 $! If you do not specify which compiler you want to build, it is assumed that
84 $! you want to build GNU-C ("CC1").
86 $! Now figure out what we have been requested to do.
87 $p1 = p1+" "+p2+" "+p3+" "+p4+" "+p5+" "+p6+" "+p7
88 $p1 = f$edit(p1,"COMPRESS,TRIM")
96 $if f$trnlnm("cfile$").nes."" then close/noLog cfile$
97 $open cfile$ compilers.list
98 $cinit:read cfile$ compilername/end=cinit_done
101 $cinit_done: close cfile$
106 $string = f$element(i," ",p1)
107 $if string.eqs." " then goto done
109 $if string.eqs."CC1PLUS" then DO_DEFAULT = 0
110 $if string.eqs."CC1OBJ" then DO_DEFAULT = 0
111 $if string.eqs."OBJCLIB"
113 $ DO_INDEPENDENT = DO_CC1OBJ
116 $if f$extract(0,2,string).nes."NO" then goto parse_option
117 $ string=f$extract(2,f$length(string)-2,string)
125 $if DO_DEFAULT.eq.1 then DO_CC1 = 1
126 $echo "This command file will now perform the following actions:
127 $if DO_LINK.eq.1 then goto link_only
128 $if DO_ALL.eq.1 then echo " Compile all language specific object modules."
129 $if DO_CC1.eq.1 then echo " Compile C specific object modules."
130 $if DO_CC1PLUS.eq.1 then echo " Compile C++ specific object modules."
131 $if DO_CC1OBJ.eq.1 then echo " Compile obj-C specific object modules."
132 $if DO_INDEPENDENT.eq.1 then echo " Compile language independent object modules."
133 $if DO_BC.eq.1 then echo " Compile byte compiler object modules."
134 $if DO_OBJCLIB.eq.1 then echo " Create Objective-C run-time library."
136 $if DO_CC1.eq.1 then echo " Link C compiler (gcc-cc1.exe)."
137 $if DO_CC1PLUS.eq.1 then echo " Link C++ compiler (gcc-cc1plus.exe)."
138 $if DO_CC1OBJ.eq.1 then echo " Link objective-C compiler (gcc-cc1obj.exe)."
139 $if DO_DEBUG.eq.1 then echo " Link images to run under debugger."
141 $! Update CFLAGS with appropriate CINCLx value.
143 $if f$edit(f$extract(0,3,CC),"LOWERCASE").nes."gcc" then goto stage1
144 $if f$search("gcc-cc1.exe").eqs."" then goto stage1
145 $if f$file_attr("gnu_cc:[000000]gcc-cc1.exe","FID").nes.-
146 f$file_attr("gcc-cc1.exe","FID") then goto stage1
147 $ CFLAGS = CFLAGS + CINCL2
150 $ CFLAGS = CFLAGS + CINCL1
153 $! Test and see if we need these messages or not. The -1 switch gives it away.
155 $gas := $gnu_cc:[000000]gcc-as.exe
156 $if f$search(gas-"$").eqs."" then goto gas_missing_message !must be VAXC
157 $define/user sys$error sys$scratch:gas_test.tmp
158 $gas -1 nla0: -o nla0:
159 $size=f$file_attributes("sys$scratch:gas_test.tmp","ALQ")
160 $delete/nolog sys$scratch:gas_test.tmp;*
161 $if size.eq.0 then goto skip_gas_message
162 $type sys$input: !an old version of gas was found
165 Note: you appear to have an old version of gas, the GNU assembler.
166 GCC 2.x treats external variables differently than GCC 1.x does. Before
167 you use GCC 2.x, you should obtain a version of the assembler which works
168 with GCC 2.x (gas-1.38 and earlier did not have the necessary support;
169 gas-2.0 through gas-2.3 did not work reliably for vax/vms configuration).
170 The assembler in gcc-vms-1.42 contained patches to provide the proper
171 support, and more recent versions have an up to date version of gas which
172 provides the support. gas from binutils-2.5 or later is recommended.
174 If you do not update the assembler, the compiler will still work,
175 but `extern const' variables will be treated as `extern'. This will result
176 in linker warning messages about mismatched psect attributes, and these
177 variables will be placed in read/write storage.
180 $goto skip_gas_message
181 $gas_missing_message:
182 $type sys$input: !no version of gas was found
185 Note: you appear to be missing gas, the GNU assembler. Since
186 GCC produces assembly code as output from compilation, you need the
187 assembler to make full use of the compiler. It should be put in place
188 as GNU_CC:[000000]GCC-AS.EXE.
190 A prebuilt copy of gas is available from the "gcc-vms" distribution,
191 and the gas source code is included in the GNU "binutils" distribution.
192 Version 2.5.2 or later is recommended.
198 $ if DO_DEBUG.eq.1 then LDFLAGS = LDFLAGS + "/Debug"
200 $if DO_LINK.eq.1 then goto no_yfiles !compile_cc1
202 $! Build alloca if necessary (in 'LIBS for use with VAXC)
204 $ if f$locate("alloca.obj",f$edit(LIBS,"lowercase")).ge.f$length(LIBS) then -
206 $ if f$search("alloca.obj").nes."" then - !does .obj exist? is it up to date?
207 if f$cvtime(f$file_attributes("alloca.obj","RDT")).gts.-
208 f$cvtime(f$file_attributes("alloca.c","RDT")) then goto skip_alloca
210 $ 'CC''CFLAGS'/Define="STACK_DIRECTION=(-1)" alloca.c
216 $ call compile bi_all.opt ""
217 $ if f$trnlnm("ifile$").nes."" then close/noLog ifile$
218 $ open ifile$ bc_all.list
219 $ read ifile$ bc_line
223 $ tfile = f$element(bc_index, ",", bc_line)
224 $ if tfile.eqs."," then goto bc_done
225 $ call bc_generate 'tfile' "bi_all.opt/opt,"
226 $ bc_index = bc_index + 1
232 $if DO_INDEPENDENT.eq.1
235 $! First build a couple of header files from the machine description
236 $! These are used by many of the source modules, so we build them now.
240 $ 'CC''CFLAGS' obstack.c
242 $! Generate insn-attr.h
243 $ call generate insn-attr.h
244 $ call generate insn-flags.h
245 $ call generate insn-codes.h
246 $ call generate insn-config.h
248 $call compile independent.opt "rtl,obstack,insn-attrtab"
250 $ call generate insn-attrtab.c "rtlanal.obj,"
252 $ 'CC''CFLAGS' insn-attrtab.c
253 $ 'CC''CFLAGS' bc-emit.c
254 $ 'CC''CFLAGS' bc-optab.c
259 $if (DO_CC1 + DO_CC1OBJ) .ne.0
261 $if (f$search("C-PARSE.Y") .eqs. "") then goto yes_yfiles
262 $if (f$cvtime(f$file_attributes("C-PARSE.IN","RDT")).gts. -
263 f$cvtime(f$file_attributes("C-PARSE.Y","RDT"))) -
265 $if (f$search("OBJC-PARSE.Y") .eqs. "") then goto yes_yfiles
266 $if (f$cvtime(f$file_attributes("C-PARSE.IN","RDT")).gts. -
267 f$cvtime(f$file_attributes("OBJC-PARSE.Y","RDT"))) -
271 $echo "Now processing c-parse.in to generate c-parse.y and objc-parse.y."
272 $ edit/tpu/nojournal/nosection/nodisplay/command=sys$input
274 ! Read c-parse.in, write c-parse.y and objc-parse.y, depending on
275 ! paired lines of "ifc" & "end ifc" and "ifobjc" & "end ifobjc" to
276 ! control what goes into each file. Most lines will be common to
277 ! both (hence not bracketed by either control pair). Mismatched
278 ! pairs aren't detected--garbage in, garbage out...
281 PROCEDURE do_output()
282 IF NOT objc_only THEN POSITION(END_OF(c)); COPY_TEXT(input_line); ENDIF;
283 IF NOT c_only THEN POSITION(END_OF(objc)); COPY_TEXT(input_line); ENDIF;
284 POSITION(input_file); !reset
287 input_file := CREATE_BUFFER("input", "c-parse.in"); !load data
288 SET(NO_WRITE, input_file);
289 c := CREATE_BUFFER("c_output"); !1st output file
290 objc := CREATE_BUFFER("objc_output"); !2nd output file
292 POSITION(BEGINNING_OF(input_file));
297 EXITIF MARK(NONE) = END_OF(input_file); !are we done yet?
299 input_line := CURRENT_LINE; !access current_line just once
300 CASE EDIT(input_line, TRIM_TRAILING, OFF, NOT_IN_PLACE)
301 ["ifc"] : c_only := 1;
302 ["end ifc"] : c_only := 0;
303 ["ifobjc"] : objc_only := 1;
304 ["end ifobjc"] : objc_only := 0;
305 ! default -- add non-control line to either or both output files
306 [INRANGE] : do_output(); !between "end" and "if"
307 [OUTRANGE] : do_output(); !before "end" or after "if"
310 MOVE_VERTICAL(1); !go to next line
313 WRITE_FILE(c, "c-parse.y");
314 WRITE_FILE(objc, "objc-parse.y");
319 $open cfile$ compilers.list
320 $cloop:read cfile$ compilername/end=cdone
321 $! language specific modules
323 $if (DO_ALL + DO_'compilername').eq.0 then goto cloop
324 $if DO_LINK.eq.0 then -
325 call compile 'compilername'-objs.opt "obstack,bc-emit,bc-optab"
327 $! CAUTION: If you want to link gcc-cc1* to the sharable image library
328 $! VAXCRTL, see the notes in gcc.texinfo (or INSTALL) first.
331 $ 'LINK''LDFLAGS'/Exe=gcc-'compilername'.exe version.opt/Opt,-
332 'compilername'-objs.opt/Opt,independent.opt/Opt,-
341 $ then set default [.objc] !push
342 $ save_cflags = CFLAGS
343 $ CFLAGS = CFLAGS - CINCL1 - CINCL2 + CINCL_SUB
344 $ MFLAGS = "/Lang=ObjC" + CFLAGS
345 $ library/Obj [-]objclib.olb/Create
346 $ if f$trnlnm("IFILE$").nes."" then close/noLog ifile$
347 $ open/Read ifile$ [-]objc-objs.opt
348 $ocl1: read/End=ocl3 ifile$ line
350 $ocl2: o = f$element(i,",",line)
351 $ if o.eqs."," then goto ocl1
353 $ if f$search(n + ".m").nes.""
362 $ library/Obj [-]objclib.olb 'n'.obj/Insert
363 $ delete/noConfirm/noLog 'n'.obj;*
367 $ CFLAGS = save_cflags
368 $ set default [-] !pop
376 $! Various DCL subroutines follow...
378 $! This routine takes parameter p1 to be a linker options file with a list
379 $! of object files that are needed. It extracts the names, and compiles
380 $! each source module, one by one. File names that begin with an
381 $! "INSN-" are assumed to be generated by a GEN*.C program.
383 $! Parameter P2 is a list of files which will appear in the options file
384 $! that should not be compiled. This allows us to handle special cases.
388 $on error then goto c_err
389 $on control_y then goto c_err
391 $loop: read ifile$ line/end=c_done
395 $flnm=f$element(i,",",line)
397 $if flnm.eqs."" then goto loop
398 $if flnm.eqs."," then goto loop
399 $if f$locate(flnm,p2).lt.f$length(p2) then goto loop1
400 $! check for front-end subdirectory: "[.prfx]flnm"
402 $k = f$locate("]",flnm)
403 $if k.eq.1 ![]c-common for [.cp]
405 $ if f$search(f$parse(".obj",flnm)).nes."" then goto loop1
406 $ flnm = f$extract(2,999,flnm)
407 $else if k.lt.f$length(flnm)
408 $ then prfx = f$extract(2,k-2,flnm)
409 $ flnm = f$extract(k+1,99,flnm)
413 $ then set default [.'prfx'] !push
414 $ save_cflags = CFLAGS
415 $ CFLAGS = CFLAGS - CINCL1 - CINCL2 + CINCL_SUB
418 $if f$locate("parse",flnm).nes.f$length(flnm)
420 $ if (f$search("''flnm'.C") .eqs. "") then goto yes_bison
421 $ if (f$cvtime(f$file_attributes("''flnm'.Y","RDT")).les. -
422 f$cvtime(f$file_attributes("''flnm'.C","RDT"))) -
426 $ 'BISON''BISON_FLAGS' 'flnm'.y
427 $ 'RENAME' 'flnm'_tab.c 'flnm'.c
428 $ 'RENAME' 'flnm'_tab.h 'flnm'.h
430 $ if flnm.eqs."cp-parse" .or. (prfx.eqs."cp" .and. flnm.eqs."parse")
431 $ then ! fgrep '#define YYEMPTY' cp-parse.c >>cp-parse.h
432 $ open/Append jfile$ 'flnm'.h
433 $ 'SEARCH'/Exact/Output=jfile$ 'flnm'.c "#define YYEMPTY"
437 $ echo " (Ignore any warning about not finding file ""bison.simple"".)"
440 $if f$extract(0,5,flnm).eqs."insn-" then call generate 'flnm'.c
443 $ 'CC''CFLAGS' 'flnm'.c
446 $ then set default [-] !pop
447 $ CFLAGS = save_CFLAGS
453 $! In case of error or abort, go here (In order to close file).
455 $c_err: !'f$verify(0)
463 $! This subroutine generates the insn-* files. The first argument is the
464 $! name of the insn-* file to generate. The second argument contains a
465 $! list of any other object modules which must be linked to the gen*.c
470 $if f$extract(0,5,p1).nes."INSN-"
472 $ write sys$error "Unknown file passed to generate."
475 $root1=f$parse(f$extract(5,255,p1),,,"NAME")
477 $ 'CC''CFLAGS' GEN'root1'.C
478 $ 'LINK''LDFLAGS' GEN'root1'.OBJ,rtl.obj,obstack.obj,'p2' -
483 $ assign/user 'p1' sys$output:
484 $ mcr sys$disk:[]GEN'root1' vax.md
488 $! This subroutine generates the bc-* files. The first argument is the
489 $! name of the bc-* file to generate. The second argument contains a
490 $! list of any other object modules which must be linked to the bi*.c
495 $if f$extract(0,3,p1).nes."BC-"
497 $ write sys$error "Unknown file passed to bc_generate."
500 $root1=f$parse(f$extract(3,255,p1),,,"NAME")
502 $ 'CC''CFLAGS' BI-'root1'.C
503 $ 'LINK''LDFLAGS' BI-'root1'.OBJ,'p2' -
508 $ assign/user bytecode.def sys$input:
509 $ assign/user 'p1' sys$output:
510 $ mcr sys$disk:[]BI-'root1'