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 = "/debug/cc1_options=""-mpcc-alignment""/incl=([],[.config.])"
30 $! CFLAGS = "/noopt/incl=([],[.config])"
38 $ LIBS := gnu_cc:[000000]gcclib.olb/libr,sys$library:vaxcrtl.olb/libr
39 $! LIBS := alloca.obj,sys$library:vaxcrtl.olb/libr
42 $! First we figure out what needs to be done. This is sort of like a limited
43 $! make facility - the command line options specify exactly what components
44 $! we want to build. The following options are understood:
46 $! LINK: Assume that the object modules for the selected compiler(s)
47 $! have already been compiled, perform link phase only.
49 $! CC1: Compile and link "C" compiler.
51 $! CC1PLUS:Compile and link "C++" compiler.
53 $! CC1OBJ: Compile and link objective C compiler.
55 $! ALL: Compile and link all of the CC1 passes.
58 $! Compile language independent source modules. (On by default).
60 $! DEBUG: Link images with /debug.
62 $! If you want to list more than one option, you should use a spaces to
65 $! Any one of the above options can be prefaced with a "NO". For example,
66 $! if you had already built GCC, and you wanted to build G++, you could use the
67 $! "CC1PLUS NOINDEPENDENT" options, which would only compile the C++ language
68 $! specific source files, and then link the C++ compiler.
70 $! If you do not specify which compiler you want to build, it is assumed that
71 $! you want to build GNU-C ("CC1").
73 $! Now figure out what we have been requested to do.
74 $p1 = p1+" "+p2+" "+p3+" "+p4+" "+p5+" "+p6+" "+p7
75 $p1 = f$edit(p1,"COMPRESS")
80 $open cfile$ compilers.list
81 $cinit:read cfile$ compilername/end=cinit_done
84 $cinit_done: close cfile$
88 $string = f$element(i," ",p1)
89 $if string.eqs." " then goto done
91 $if string.eqs."CC1PLUS" then DO_DEFAULT = 0
92 $if string.eqs."CC1OBJ" then DO_DEFAULT = 0
93 $if f$extract(0,2,string).nes."NO" then goto parse_option
94 $ string=f$extract(2,f$length(string)-2,string)
102 $if DO_DEFAULT.eq.1 then DO_CC1 = 1
103 $echo := write sys$Output
104 $echo "This command file will now perform the following actions:
105 $if DO_LINK.eq.1 then goto link_only
106 $if DO_ALL.eq.1 then echo " Compile all language specific object modules."
107 $if DO_CC1.eq.1 then echo " Compile C specific object modules."
108 $if DO_CC1PLUS.eq.1 then echo " Compile C++ specific object modules."
109 $if DO_CC1OBJ.eq.1 then echo " Compile obj-C specific object modules."
110 $if DO_INDEPENDENT.eq.1 then echo " Compile language independent object modules."
112 $if DO_CC1.eq.1 then echo " Link C compiler (gcc-cc1.exe)."
113 $if DO_CC1PLUS.eq.1 then echo " Link C++ compiler (gcc-cc1plus.exe)."
114 $if DO_CC1OBJ.eq.1 then echo " Link objective-C compiler (gcc-cc1obj.exe)."
115 $if DO_DEBUG.eq.1 then echo " Link images to run under debugger."
117 $! Test and see if we need these messages or not. The -1 switch gives it away.
119 $gas := $gnu_cc:[000000]gcc-as.exe
120 $if f$search(gas-"$").eqs."" then goto gas_message !must be VAXC
121 $define/user sys$error sys$scratch:gas_test.tmp
122 $gas -1 nla0: -o nla0:
123 $size=f$file_attributes("sys$scratch:gas_test.tmp","ALQ")
124 $delete/nolog sys$scratch:gas_test.tmp;*
125 $if size.eq.0 then goto no_message
129 Note: GCC 2.0 treats external variables differently than GCC 1.40 does.
130 Before you use GCC 2.0, you should obtain a version of the assembler which
131 contains the patches to work with GCC 2.0 (GCC-AS 1.38 does not contain
132 these patches - whatever comes after this probably will). The assembler
133 in gcc-vms-1.40.tar.Z from prep does contain the proper patches.
135 If you do not update the assembler, the compiler will still work,
136 but `extern const' variables will be treated as `extern'. This will result
137 in linker warning messages about mismatched psect attributes, and these
138 variables will be placed in read/write storage.
144 $ if DO_DEBUG.eq.1 then LDFLAGS :='LDFLAGS'/debug
146 $if DO_LINK.eq.1 then goto compile_cc1
147 $if DO_INDEPENDENT.eq.1
150 $! Build alloca if necessary (in 'LIBS for use with VAXC)
152 $ if f$locate("alloca.obj",f$edit(LIBS,"lowercase")).ge.f$length(LIBS) then -
154 $ if f$search("alloca.obj").nes."" then - !does .obj exist? is it up to date?
155 if f$cvtime(f$file_attributes("alloca.obj","RDT")).gts.-
156 f$cvtime(f$file_attributes("alloca.c","RDT")) then goto skip_alloca
158 $ 'CC 'CFLAGS /define="STACK_DIRECTION=(-1)" alloca.c
162 $! First build a couple of header files from the machine description
163 $! These are used by many of the source modules, so we build them now.
167 $ 'CC 'CFLAGS obstack.C
169 $! Generate insn-attr.h
170 $ call generate insn-attr.h
171 $ call generate insn-flags.h
172 $ call generate insn-codes.h
173 $ call generate insn-config.h
175 $call compile independent.opt "rtl,obstack,insn-attrtab"
177 $ call generate insn-attrtab.c "rtlanal,"
179 $ 'CC 'CFLAGS insn-attrtab.c
184 $if (DO_CC1 + DO_CC1OBJ) .ne.0
186 $if (f$search("C-PARSE.Y") .eqs. "") then goto yes_yfiles
187 $if (f$cvtime(f$file_attributes("C-PARSE.IN","RDT")).gts. -
188 f$cvtime(f$file_attributes("C-PARSE.Y","RDT"))) -
190 $if (f$search("OBJC-PARSE.Y") .eqs. "") then goto yes_yfiles
191 $if (f$cvtime(f$file_attributes("C-PARSE.IN","RDT")).gts. -
192 f$cvtime(f$file_attributes("OBJC-PARSE.Y","RDT"))) -
196 $echo "Now processing c-parse.in to generate c-parse.y and objc-parse.y."
197 $ edit/tpu/nojournal/nosection/nodisplay/command=sys$input
199 ! Read c-parse.in, write c-parse.y and objc-parse.y, depending on
200 ! paired lines of "ifc" & "end ifc" and "ifobjc" & "end ifobjc" to
201 ! control what goes into each file. Most lines will be common to
202 ! both (hence not bracketed by either control pair). Mismatched
203 ! pairs aren't detected--garbage in, garbage out...
206 PROCEDURE do_output()
207 IF NOT objc_only THEN POSITION(END_OF(c)); COPY_TEXT(input_line); ENDIF;
208 IF NOT c_only THEN POSITION(END_OF(objc)); COPY_TEXT(input_line); ENDIF;
209 POSITION(input_file); !reset
212 input_file := CREATE_BUFFER("input", "c-parse.in"); !load data
213 SET(NO_WRITE, input_file);
214 c := CREATE_BUFFER("c_output"); !1st output file
215 objc := CREATE_BUFFER("objc_output"); !2nd output file
217 POSITION(BEGINNING_OF(input_file));
222 EXITIF MARK(NONE) = END_OF(input_file); !are we done yet?
224 input_line := CURRENT_LINE; !access current_line just once
225 CASE EDIT(input_line, TRIM_TRAILING, OFF, NOT_IN_PLACE)
226 ["ifc"] : c_only := 1;
227 ["end ifc"] : c_only := 0;
228 ["ifobjc"] : objc_only := 1;
229 ["end ifobjc"] : objc_only := 0;
230 ! default -- add non-control line to either or both output files
231 [INRANGE] : do_output(); !between "end" and "if"
232 [OUTRANGE] : do_output(); !before "end" or after "if"
235 MOVE_VERTICAL(1); !go to next line
238 WRITE_FILE(c, "c-parse.y");
239 WRITE_FILE(objc, "objc-parse.y");
244 $open cfile$ compilers.list
245 $cloop:read cfile$ compilername/end=cdone
246 $! language specific modules
248 $if (DO_ALL + DO_'compilername').eq.0 then goto cloop
249 $if DO_LINK.eq.0 then call compile 'compilername'-objs.opt "obstack"
251 $! CAUTION: If you want to link gcc-cc1* to the sharable image library
252 $! VAXCRTL, see the notes in gcc.texinfo (or INSTALL) first.
255 $ link 'LDFLAGS' /exe=gcc-'compilername' version.opt/opt, -
256 'compilername'-objs.opt/opt, independent.opt/opt, -
269 $! Various DCL subroutines follow...
271 $! This routine takes parameter p1 to be a linker options file with a list
272 $! of object files that are needed. It extracts the names, and compiles
273 $! each source module, one by one. File names that begin with an
274 $! "INSN-" are assumed to be generated by a GEN*.C program.
276 $! Parameter P2 is a list of files which will appear in the options file
277 $! that should not be compiled. This allows us to handle special cases.
281 $on error then goto c_err
282 $on control_y then goto c_err
284 $loop: read ifile$ line/end=c_done
288 $flnm=f$element(i,",",line)
290 $if flnm.eqs."" then goto loop
291 $if flnm.eqs."," then goto loop
292 $if f$locate(flnm,"''p2'").nes.f$length("''p2'") then goto loop1
294 $if f$locate("-parse",flnm).nes.f$length(flnm)
296 $ if (f$search("''flnm'.C") .eqs. "") then goto yes_bison
297 $ if (f$cvtime(f$file_attributes("''flnm'.Y","RDT")).les. -
298 f$cvtime(f$file_attributes("''flnm'.C","RDT"))) -
302 $ 'BISON' /define /verbose 'flnm'.y
303 $ 'RENAME' 'flnm'_tab.c 'flnm'.c
304 $ 'RENAME' 'flnm'_tab.h 'flnm'.h
305 $ if flnm.eqs."cp-parse"
306 $ then ! fgrep '#define YYEMPTY' cp-parse.c >>cp-parse.h
307 $ open/append jfile$ cp-parse.h
308 $ search/exact/output=jfile$ cp-parse.c "#define YYEMPTY"
315 $if f$extract(0,5,flnm).eqs."insn-" then call generate 'flnm'.c
318 $ 'CC 'CFLAGS 'flnm'.c
324 $! In case of error or abort, go here (In order to close file).
326 $c_err: !'f$verify(0)
334 $! This subroutine generates the insn-* files. The first argument is the
335 $! name of the insn-* file to generate. The second argument contains a
336 $! list of any other object modules which must be linked to the gen*.c
339 $! If a previous version of insn-* exists, it is compared to the new one,
340 $! and if it has not changed, then the new one is discarded. This is
341 $! done so that make like programs do not get thrown off.
345 $if f$extract(0,5,p1).nes."INSN-"
347 $ write sys$error "Unknown file passed to generate."
350 $root1=f$parse(f$extract(5,255,p1),,,"NAME")
352 $ 'CC 'CFLAGS GEN'root1'.C
353 $ link 'LDFLAGS' GEN'root1',rtl,obstack,'p2' -
358 $ assign/user 'p1' sys$output:
359 $ mcr sys$disk:[]GEN'root1' md