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")'
6 $set symbol/scope=(nolocal,noglobal)
8 $! CAUTION: If you want to link gcc-cc1 to the sharable image library
9 $! VAXCRTL, see the notes in gcc.texinfo (or INSTALL) first.
11 $! Build the GNU "C" compiler on VMS
13 $! Note: to build with DEC's VAX C compiler, uncomment the 2nd CC, CFLAGS,
14 $! and LIBS alternatives, and also execute the following command:
15 $! DEFINE SYS SYS$LIBRARY:
16 $! After a successful build, restore those items and rebuild with gcc.
21 $! CC := cc !uncomment for VAXC
23 $ RENAME := rename/new_vers
29 $ CFLAGS = "/noVerbose/Debug/CC1=""-mpcc-alignment"""
30 $! CFLAGS = "/noOpt" !uncomment for VAXC
31 $ CINCL1 = "/Incl=[]" !stage 1 -I flags
32 $ CINCL2 = "/Incl=([],[.ginclude])" !stage 2,3,... flags
40 $ LIBS := gnu_cc:[000000]gcclib.olb/libr,sys$library:vaxcrtl.olb/libr
41 $! LIBS := alloca.obj,sys$library:vaxcrtl.olb/Libr !uncomment for VAXC
44 $! First we figure out what needs to be done. This is sort of like a limited
45 $! make facility - the command line options specify exactly what components
46 $! we want to build. The following options are understood:
48 $! LINK: Assume that the object modules for the selected compiler(s)
49 $! have already been compiled, perform link phase only.
51 $! CC1: Compile and link "C" compiler.
53 $! CC1PLUS:Compile and link "C++" compiler.
55 $! CC1OBJ: Compile and link objective C compiler.
57 $! ALL: Compile and link all of the CC1 passes.
60 $! Compile language independent source modules. (On by default).
63 $! Compile byte compiler source modules. (On by default).
65 $! DEBUG: Link images with /debug.
67 $! If you want to list more than one option, you should use a spaces to
70 $! Any one of the above options can be prefaced with a "NO". For example,
71 $! if you had already built GCC, and you wanted to build G++, you could use the
72 $! "CC1PLUS NOINDEPENDENT" options, which would only compile the C++ language
73 $! specific source files, and then link the C++ compiler.
75 $! If you do not specify which compiler you want to build, it is assumed that
76 $! you want to build GNU-C ("CC1").
78 $! Now figure out what we have been requested to do.
79 $p1 = p1+" "+p2+" "+p3+" "+p4+" "+p5+" "+p6+" "+p7
80 $p1 = f$edit(p1,"COMPRESS")
86 $open cfile$ compilers.list
87 $cinit:read cfile$ compilername/end=cinit_done
90 $cinit_done: close cfile$
95 $string = f$element(i," ",p1)
96 $if string.eqs." " then goto done
98 $if string.eqs."CC1PLUS" then DO_DEFAULT = 0
99 $if string.eqs."CC1OBJ" then DO_DEFAULT = 0
100 $if f$extract(0,2,string).nes."NO" then goto parse_option
101 $ string=f$extract(2,f$length(string)-2,string)
109 $if DO_DEFAULT.eq.1 then DO_CC1 = 1
110 $echo := write sys$Output
111 $echo "This command file will now perform the following actions:
112 $if DO_LINK.eq.1 then goto link_only
113 $if DO_ALL.eq.1 then echo " Compile all language specific object modules."
114 $if DO_CC1.eq.1 then echo " Compile C specific object modules."
115 $if DO_CC1PLUS.eq.1 then echo " Compile C++ specific object modules."
116 $if DO_CC1OBJ.eq.1 then echo " Compile obj-C specific object modules."
117 $if DO_INDEPENDENT.eq.1 then echo " Compile language independent object modules."
118 $if DO_BC.eq.1 then echo " Compile byte compiler object modules."
120 $if DO_CC1.eq.1 then echo " Link C compiler (gcc-cc1.exe)."
121 $if DO_CC1PLUS.eq.1 then echo " Link C++ compiler (gcc-cc1plus.exe)."
122 $if DO_CC1OBJ.eq.1 then echo " Link objective-C compiler (gcc-cc1obj.exe)."
123 $if DO_DEBUG.eq.1 then echo " Link images to run under debugger."
125 $! Update CFLAGS with appropriate CINCLx value.
127 $if f$edit(f$extract(0,3,CC),"LOWERCASE").nes."gcc" then goto stage1
128 $if f$search("gcc-cc1.exe").eqs."" then goto stage1
129 $if f$file_attr("gnu_cc:[000000]gcc-cc1.exe","FID").nes.-
130 f$file_attr("gcc-cc1.exe","FID") then goto stage1
131 $ CFLAGS = CFLAGS + CINCL2
134 $ CFLAGS = CFLAGS + CINCL1
137 $! Test and see if we need these messages or not. The -1 switch gives it away.
139 $gas := $gnu_cc:[000000]gcc-as.exe
140 $if f$search(gas-"$").eqs."" then goto gas_message !must be VAXC
141 $define/user sys$error sys$scratch:gas_test.tmp
142 $gas -1 nla0: -o nla0:
143 $size=f$file_attributes("sys$scratch:gas_test.tmp","ALQ")
144 $delete/nolog sys$scratch:gas_test.tmp;*
145 $if size.eq.0 then goto no_message
149 Note: GCC 2.0 treats external variables differently than GCC 1.40 does.
150 Before you use GCC 2.0, you should obtain a version of the assembler which
151 contains the patches to work with GCC 2.0 (GCC-AS 1.38 does not contain
152 these patches - whatever comes after this probably will). The assembler
153 in gcc-vms-1.40.tar.Z from prep does contain the proper patches.
155 If you do not update the assembler, the compiler will still work,
156 but `extern const' variables will be treated as `extern'. This will result
157 in linker warning messages about mismatched psect attributes, and these
158 variables will be placed in read/write storage.
164 $ if DO_DEBUG.eq.1 then LDFLAGS :='LDFLAGS'/debug
166 $if DO_LINK.eq.1 then goto compile_cc1
168 $! Build alloca if necessary (in 'LIBS for use with VAXC)
170 $ if f$locate("alloca.obj",f$edit(LIBS,"lowercase")).ge.f$length(LIBS) then -
172 $ if f$search("alloca.obj").nes."" then - !does .obj exist? is it up to date?
173 if f$cvtime(f$file_attributes("alloca.obj","RDT")).gts.-
174 f$cvtime(f$file_attributes("alloca.c","RDT")) then goto skip_alloca
176 $ 'CC 'CFLAGS /define="STACK_DIRECTION=(-1)" alloca.c
182 $ call compile bi_all.opt ""
183 $ open ifile$ bc_all.opt
184 $ read ifile$ bc_line
188 $ tfile = f$element(bc_index, " ", bc_line)
189 $ if tfile.eqs." " then goto bc_done
190 $ call bc_generate 'tfile' "bi_all.opt/opt,"
191 $ bc_index = bc_index + 1
197 $if DO_INDEPENDENT.eq.1
200 $! First build a couple of header files from the machine description
201 $! These are used by many of the source modules, so we build them now.
205 $ 'CC 'CFLAGS obstack.C
207 $! Generate insn-attr.h
208 $ call generate insn-attr.h
209 $ call generate insn-flags.h
210 $ call generate insn-codes.h
211 $ call generate insn-config.h
213 $call compile independent.opt "rtl,obstack,insn-attrtab"
215 $ call generate insn-attrtab.c "rtlanal,"
217 $ 'CC 'CFLAGS insn-attrtab.c
222 $if (DO_CC1 + DO_CC1OBJ) .ne.0
224 $if (f$search("C-PARSE.Y") .eqs. "") then goto yes_yfiles
225 $if (f$cvtime(f$file_attributes("C-PARSE.IN","RDT")).gts. -
226 f$cvtime(f$file_attributes("C-PARSE.Y","RDT"))) -
228 $if (f$search("OBJC-PARSE.Y") .eqs. "") then goto yes_yfiles
229 $if (f$cvtime(f$file_attributes("C-PARSE.IN","RDT")).gts. -
230 f$cvtime(f$file_attributes("OBJC-PARSE.Y","RDT"))) -
234 $echo "Now processing c-parse.in to generate c-parse.y and objc-parse.y."
235 $ edit/tpu/nojournal/nosection/nodisplay/command=sys$input
237 ! Read c-parse.in, write c-parse.y and objc-parse.y, depending on
238 ! paired lines of "ifc" & "end ifc" and "ifobjc" & "end ifobjc" to
239 ! control what goes into each file. Most lines will be common to
240 ! both (hence not bracketed by either control pair). Mismatched
241 ! pairs aren't detected--garbage in, garbage out...
244 PROCEDURE do_output()
245 IF NOT objc_only THEN POSITION(END_OF(c)); COPY_TEXT(input_line); ENDIF;
246 IF NOT c_only THEN POSITION(END_OF(objc)); COPY_TEXT(input_line); ENDIF;
247 POSITION(input_file); !reset
250 input_file := CREATE_BUFFER("input", "c-parse.in"); !load data
251 SET(NO_WRITE, input_file);
252 c := CREATE_BUFFER("c_output"); !1st output file
253 objc := CREATE_BUFFER("objc_output"); !2nd output file
255 POSITION(BEGINNING_OF(input_file));
260 EXITIF MARK(NONE) = END_OF(input_file); !are we done yet?
262 input_line := CURRENT_LINE; !access current_line just once
263 CASE EDIT(input_line, TRIM_TRAILING, OFF, NOT_IN_PLACE)
264 ["ifc"] : c_only := 1;
265 ["end ifc"] : c_only := 0;
266 ["ifobjc"] : objc_only := 1;
267 ["end ifobjc"] : objc_only := 0;
268 ! default -- add non-control line to either or both output files
269 [INRANGE] : do_output(); !between "end" and "if"
270 [OUTRANGE] : do_output(); !before "end" or after "if"
273 MOVE_VERTICAL(1); !go to next line
276 WRITE_FILE(c, "c-parse.y");
277 WRITE_FILE(objc, "objc-parse.y");
282 $open cfile$ compilers.list
283 $cloop:read cfile$ compilername/end=cdone
284 $! language specific modules
286 $if (DO_ALL + DO_'compilername').eq.0 then goto cloop
287 $if DO_LINK.eq.0 then call compile 'compilername'-objs.opt "obstack"
289 $! CAUTION: If you want to link gcc-cc1* to the sharable image library
290 $! VAXCRTL, see the notes in gcc.texinfo (or INSTALL) first.
293 $ link 'LDFLAGS' /exe=gcc-'compilername' version.opt/opt, -
294 'compilername'-objs.opt/opt, independent.opt/opt, -
307 $! Various DCL subroutines follow...
309 $! This routine takes parameter p1 to be a linker options file with a list
310 $! of object files that are needed. It extracts the names, and compiles
311 $! each source module, one by one. File names that begin with an
312 $! "INSN-" are assumed to be generated by a GEN*.C program.
314 $! Parameter P2 is a list of files which will appear in the options file
315 $! that should not be compiled. This allows us to handle special cases.
319 $on error then goto c_err
320 $on control_y then goto c_err
322 $loop: read ifile$ line/end=c_done
326 $flnm=f$element(i,",",line)
328 $if flnm.eqs."" then goto loop
329 $if flnm.eqs."," then goto loop
330 $if f$locate(flnm,"''p2'").nes.f$length("''p2'") then goto loop1
332 $if f$locate("-parse",flnm).nes.f$length(flnm)
334 $ if (f$search("''flnm'.C") .eqs. "") then goto yes_bison
335 $ if (f$cvtime(f$file_attributes("''flnm'.Y","RDT")).les. -
336 f$cvtime(f$file_attributes("''flnm'.C","RDT"))) -
340 $ 'BISON' /define /verbose 'flnm'.y
341 $ 'RENAME' 'flnm'_tab.c 'flnm'.c
342 $ 'RENAME' 'flnm'_tab.h 'flnm'.h
343 $ if flnm.eqs."cp-parse"
344 $ then ! fgrep '#define YYEMPTY' cp-parse.c >>cp-parse.h
345 $ open/append jfile$ cp-parse.h
346 $ search/exact/output=jfile$ cp-parse.c "#define YYEMPTY"
351 $ echo " (Ignore any warning about not finding file ""bison.simple"".)"
354 $if f$extract(0,5,flnm).eqs."insn-" then call generate 'flnm'.c
357 $ 'CC 'CFLAGS 'flnm'.c
363 $! In case of error or abort, go here (In order to close file).
365 $c_err: !'f$verify(0)
373 $! This subroutine generates the insn-* files. The first argument is the
374 $! name of the insn-* file to generate. The second argument contains a
375 $! list of any other object modules which must be linked to the gen*.c
380 $if f$extract(0,5,p1).nes."INSN-"
382 $ write sys$error "Unknown file passed to generate."
385 $root1=f$parse(f$extract(5,255,p1),,,"NAME")
387 $ 'CC 'CFLAGS GEN'root1'.C
388 $ link 'LDFLAGS' GEN'root1',rtl,obstack,'p2' -
393 $ assign/user 'p1' sys$output:
394 $ mcr sys$disk:[]GEN'root1' md
398 $! This subroutine generates the bc-* files. The first argument is the
399 $! name of the bc-* file to generate. The second argument contains a
400 $! list of any other object modules which must be linked to the bi*.c
405 $if f$extract(0,3,p1).nes."BC-"
407 $ write sys$error "Unknown file passed to generate."
410 $root1=f$parse(f$extract(3,255,p1),,,"NAME")
412 $ 'CC 'CFLAGS BI-'root1'.C
413 $ link 'LDFLAGS' BI-'root1','p2' -
418 $ assign/user bytecode.def sys$input:
419 $ assign/user 'p1' sys$output:
420 $ mcr sys$disk:[]BI-'root1'