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 $ echo = "write sys$output"
31 $ CFLAGS = "/Debug/noVerbos/CC1=""-mpcc-alignment"""
32 $! CFLAGS = "/noOpt" !uncomment for VAXC
33 $ CINCL1 = "/Incl=[]" !stage 1 -I flags
34 $ CINCL2 = "/Incl=([],[.ginclude])" !stage 2,3,... flags
35 $ CINCL_SUB = "/Incl=([],[-],[-.ginclude])" ![.cp] flags
43 $ LIBS = "gnu_cc:[000000]gcclib.olb/Libr,sys$library:vaxcrtl.olb/Libr"
44 $! LIBS = "alloca.obj,sys$library:vaxcrtl.olb/Libr" !uncomment for VAXC
47 $! Nothing beyond this point should need any local configuration changes.
51 $! First we figure out what needs to be done. This is sort of like a limited
52 $! make facility - the command line options specify exactly what components
53 $! we want to build. The following options are understood:
55 $! LINK: Assume that the object modules for the selected compiler(s)
56 $! have already been compiled, perform link phase only.
58 $! CC1: Compile and link "C" compiler.
60 $! CC1PLUS:Compile and link "C++" compiler.
62 $! CC1OBJ: Compile and link objective C compiler.
64 $! ALL: Compile and link all of the CC1 passes.
67 $! Compile language independent source modules. (On by default).
70 $! Compile byte compiler source modules. (On by default).
72 $! DEBUG: Link images with /debug.
74 $! If you want to list more than one option, you should use a spaces to
77 $! Any one of the above options can be prefaced with a "NO". For example,
78 $! if you had already built GCC, and you wanted to build G++, you could use the
79 $! "CC1PLUS NOINDEPENDENT" options, which would only compile the C++ language
80 $! specific source files, and then link the C++ compiler.
82 $! If you do not specify which compiler you want to build, it is assumed that
83 $! you want to build GNU-C ("CC1").
85 $! Now figure out what we have been requested to do.
86 $p1 = p1+" "+p2+" "+p3+" "+p4+" "+p5+" "+p6+" "+p7
87 $p1 = f$edit(p1,"COMPRESS")
93 $if f$trnlnm("cfile$").nes."" then close/noLog cfile$
94 $open cfile$ compilers.list
95 $cinit:read cfile$ compilername/end=cinit_done
98 $cinit_done: close cfile$
103 $string = f$element(i," ",p1)
104 $if string.eqs." " then goto done
106 $if string.eqs."CC1PLUS" then DO_DEFAULT = 0
107 $if string.eqs."CC1OBJ" then DO_DEFAULT = 0
108 $if f$extract(0,2,string).nes."NO" then goto parse_option
109 $ string=f$extract(2,f$length(string)-2,string)
117 $if DO_DEFAULT.eq.1 then DO_CC1 = 1
118 $echo "This command file will now perform the following actions:
119 $if DO_LINK.eq.1 then goto link_only
120 $if DO_ALL.eq.1 then echo " Compile all language specific object modules."
121 $if DO_CC1.eq.1 then echo " Compile C specific object modules."
122 $if DO_CC1PLUS.eq.1 then echo " Compile C++ specific object modules."
123 $if DO_CC1OBJ.eq.1 then echo " Compile obj-C specific object modules."
124 $if DO_INDEPENDENT.eq.1 then echo " Compile language independent object modules."
125 $if DO_BC.eq.1 then echo " Compile byte compiler object modules."
127 $if DO_CC1.eq.1 then echo " Link C compiler (gcc-cc1.exe)."
128 $if DO_CC1PLUS.eq.1 then echo " Link C++ compiler (gcc-cc1plus.exe)."
129 $if DO_CC1OBJ.eq.1 then echo " Link objective-C compiler (gcc-cc1obj.exe)."
130 $if DO_DEBUG.eq.1 then echo " Link images to run under debugger."
132 $! Update CFLAGS with appropriate CINCLx value.
134 $if f$edit(f$extract(0,3,CC),"LOWERCASE").nes."gcc" then goto stage1
135 $if f$search("gcc-cc1.exe").eqs."" then goto stage1
136 $if f$file_attr("gnu_cc:[000000]gcc-cc1.exe","FID").nes.-
137 f$file_attr("gcc-cc1.exe","FID") then goto stage1
138 $ CFLAGS = CFLAGS + CINCL2
141 $ CFLAGS = CFLAGS + CINCL1
144 $! Test and see if we need these messages or not. The -1 switch gives it away.
146 $gas := $gnu_cc:[000000]gcc-as.exe
147 $if f$search(gas-"$").eqs."" then goto gas_message !must be VAXC
148 $define/user sys$error sys$scratch:gas_test.tmp
149 $gas -1 nla0: -o nla0:
150 $size=f$file_attributes("sys$scratch:gas_test.tmp","ALQ")
151 $delete/nolog sys$scratch:gas_test.tmp;*
152 $if size.eq.0 then goto no_message
156 Note: GCC 2.x treats external variables differently than GCC 1.x does.
157 Before you use GCC 2.x, you should obtain a version of the assembler which
158 contains the patches to work with GCC 2.x (GCC-AS 1.38 does not contain
159 these patches - whatever comes after this probably will). The assembler
160 in gcc-vms-1.42.tar.gz from prep does contain the proper patches.
162 If you do not update the assembler, the compiler will still work,
163 but `extern const' variables will be treated as `extern'. This will result
164 in linker warning messages about mismatched psect attributes, and these
165 variables will be placed in read/write storage.
171 $ if DO_DEBUG.eq.1 then LDFLAGS = LDFLAGS + "/Debug"
173 $if DO_LINK.eq.1 then goto compile_cc1
175 $! Build alloca if necessary (in 'LIBS for use with VAXC)
177 $ if f$locate("alloca.obj",f$edit(LIBS,"lowercase")).ge.f$length(LIBS) then -
179 $ if f$search("alloca.obj").nes."" then - !does .obj exist? is it up to date?
180 if f$cvtime(f$file_attributes("alloca.obj","RDT")).gts.-
181 f$cvtime(f$file_attributes("alloca.c","RDT")) then goto skip_alloca
183 $ 'CC''CFLAGS'/Define="STACK_DIRECTION=(-1)" alloca.c
189 $ call compile bi_all.opt ""
190 $ open ifile$ bc_all.opt
191 $ read ifile$ bc_line
195 $ tfile = f$element(bc_index, " ", bc_line)
196 $ if tfile.eqs." " then goto bc_done
197 $ call bc_generate 'tfile' "bi_all.opt/opt,"
198 $ bc_index = bc_index + 1
204 $if DO_INDEPENDENT.eq.1
207 $! First build a couple of header files from the machine description
208 $! These are used by many of the source modules, so we build them now.
212 $ 'CC''CFLAGS' obstack.c
214 $! Generate insn-attr.h
215 $ call generate insn-attr.h
216 $ call generate insn-flags.h
217 $ call generate insn-codes.h
218 $ call generate insn-config.h
220 $call compile independent.opt "rtl,obstack,insn-attrtab"
222 $ call generate insn-attrtab.c "rtlanal.obj,"
224 $ 'CC''CFLAGS' insn-attrtab.c
225 $ 'CC''CFLAGS' bc-emit.c
226 $ 'CC''CFLAGS' bc-optab.c
231 $if (DO_CC1 + DO_CC1OBJ) .ne.0
233 $if (f$search("C-PARSE.Y") .eqs. "") then goto yes_yfiles
234 $if (f$cvtime(f$file_attributes("C-PARSE.IN","RDT")).gts. -
235 f$cvtime(f$file_attributes("C-PARSE.Y","RDT"))) -
237 $if (f$search("OBJC-PARSE.Y") .eqs. "") then goto yes_yfiles
238 $if (f$cvtime(f$file_attributes("C-PARSE.IN","RDT")).gts. -
239 f$cvtime(f$file_attributes("OBJC-PARSE.Y","RDT"))) -
243 $echo "Now processing c-parse.in to generate c-parse.y and objc-parse.y."
244 $ edit/tpu/nojournal/nosection/nodisplay/command=sys$input
246 ! Read c-parse.in, write c-parse.y and objc-parse.y, depending on
247 ! paired lines of "ifc" & "end ifc" and "ifobjc" & "end ifobjc" to
248 ! control what goes into each file. Most lines will be common to
249 ! both (hence not bracketed by either control pair). Mismatched
250 ! pairs aren't detected--garbage in, garbage out...
253 PROCEDURE do_output()
254 IF NOT objc_only THEN POSITION(END_OF(c)); COPY_TEXT(input_line); ENDIF;
255 IF NOT c_only THEN POSITION(END_OF(objc)); COPY_TEXT(input_line); ENDIF;
256 POSITION(input_file); !reset
259 input_file := CREATE_BUFFER("input", "c-parse.in"); !load data
260 SET(NO_WRITE, input_file);
261 c := CREATE_BUFFER("c_output"); !1st output file
262 objc := CREATE_BUFFER("objc_output"); !2nd output file
264 POSITION(BEGINNING_OF(input_file));
269 EXITIF MARK(NONE) = END_OF(input_file); !are we done yet?
271 input_line := CURRENT_LINE; !access current_line just once
272 CASE EDIT(input_line, TRIM_TRAILING, OFF, NOT_IN_PLACE)
273 ["ifc"] : c_only := 1;
274 ["end ifc"] : c_only := 0;
275 ["ifobjc"] : objc_only := 1;
276 ["end ifobjc"] : objc_only := 0;
277 ! default -- add non-control line to either or both output files
278 [INRANGE] : do_output(); !between "end" and "if"
279 [OUTRANGE] : do_output(); !before "end" or after "if"
282 MOVE_VERTICAL(1); !go to next line
285 WRITE_FILE(c, "c-parse.y");
286 WRITE_FILE(objc, "objc-parse.y");
291 $open cfile$ compilers.list
292 $cloop:read cfile$ compilername/end=cdone
293 $! language specific modules
295 $if (DO_ALL + DO_'compilername').eq.0 then goto cloop
296 $if DO_LINK.eq.0 then -
297 call compile 'compilername'-objs.opt "obstack,bc-emit,bc-optab"
299 $! CAUTION: If you want to link gcc-cc1* to the sharable image library
300 $! VAXCRTL, see the notes in gcc.texinfo (or INSTALL) first.
303 $ 'LINK''LDFLAGS'/Exe=gcc-'compilername'.exe version.opt/Opt,-
304 'compilername'-objs.opt/Opt,independent.opt/Opt,-
317 $! Various DCL subroutines follow...
319 $! This routine takes parameter p1 to be a linker options file with a list
320 $! of object files that are needed. It extracts the names, and compiles
321 $! each source module, one by one. File names that begin with an
322 $! "INSN-" are assumed to be generated by a GEN*.C program.
324 $! Parameter P2 is a list of files which will appear in the options file
325 $! that should not be compiled. This allows us to handle special cases.
329 $on error then goto c_err
330 $on control_y then goto c_err
332 $loop: read ifile$ line/end=c_done
336 $flnm=f$element(i,",",line)
338 $if flnm.eqs."" then goto loop
339 $if flnm.eqs."," then goto loop
340 $if f$locate(flnm,p2).lt.f$length(p2) then goto loop1
341 $! check for front-end subdirectory: "[.prfx]flnm"
343 $k = f$locate("]",flnm)
344 $if k.eq.1 then goto loop1 ![]c-common for [.cp]
345 $if k.lt.f$length(flnm) then prfx = f$extract(2,k-2,flnm)
346 $if k.lt.f$length(flnm) then flnm = f$extract(k+1,99,flnm)
348 $ then set default [.'prfx'] !push
349 $ save_cflags = CFLAGS
350 $ CFLAGS = CFLAGS - CINCL1 - CINCL2 + CINCL_SUB
353 $if f$locate("parse",flnm).nes.f$length(flnm)
355 $ if (f$search("''flnm'.C") .eqs. "") then goto yes_bison
356 $ if (f$cvtime(f$file_attributes("''flnm'.Y","RDT")).les. -
357 f$cvtime(f$file_attributes("''flnm'.C","RDT"))) -
361 $ 'BISON''BISON_FLAGS' 'flnm'.y
362 $ 'RENAME' 'flnm'_tab.c 'flnm'.c
363 $ 'RENAME' 'flnm'_tab.h 'flnm'.h
365 $ if flnm.eqs."cp-parse" .or. (prfx.eqs."cp" .and. flnm.eqs."parse")
366 $ then ! fgrep '#define YYEMPTY' cp-parse.c >>cp-parse.h
367 $ open/Append jfile$ 'flnm'.h
368 $ 'SEARCH'/Exact/Output=jfile$ 'flnm'.c "#define YYEMPTY"
372 $ echo " (Ignore any warning about not finding file ""bison.simple"".)"
375 $if f$extract(0,5,flnm).eqs."insn-" then call generate 'flnm'.c
378 $ 'CC''CFLAGS' 'flnm'.c
381 $ then set default [-] !pop
382 $ CFLAGS = save_CFLAGS
388 $! In case of error or abort, go here (In order to close file).
390 $c_err: !'f$verify(0)
398 $! This subroutine generates the insn-* files. The first argument is the
399 $! name of the insn-* file to generate. The second argument contains a
400 $! list of any other object modules which must be linked to the gen*.c
405 $if f$extract(0,5,p1).nes."INSN-"
407 $ write sys$error "Unknown file passed to generate."
410 $root1=f$parse(f$extract(5,255,p1),,,"NAME")
412 $ 'CC''CFLAGS' GEN'root1'.C
413 $ 'LINK''LDFLAGS' GEN'root1'.OBJ,rtl.obj,obstack.obj,'p2' -
418 $ assign/user 'p1' sys$output:
419 $ mcr sys$disk:[]GEN'root1' md
423 $! This subroutine generates the bc-* files. The first argument is the
424 $! name of the bc-* file to generate. The second argument contains a
425 $! list of any other object modules which must be linked to the bi*.c
430 $if f$extract(0,3,p1).nes."BC-"
432 $ write sys$error "Unknown file passed to generate."
435 $root1=f$parse(f$extract(3,255,p1),,,"NAME")
437 $ 'CC''CFLAGS' BI-'root1'.C
438 $ 'LINK''LDFLAGS' BI-'root1'.OBJ,'p2' -
443 $ assign/user bytecode.def sys$input:
444 $ assign/user 'p1' sys$output:
445 $ mcr sys$disk:[]BI-'root1'