Commit | Line | Data |
---|---|---|
f5e4d921 C |
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")' | |
4 | $! | |
5 | $ v=f$verify(0) | |
6 | $set symbol/scope=(nolocal,noglobal) | |
7 | $! | |
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. | |
10 | $! | |
11 | $! Build the GNU "C" compiler on VMS | |
12 | $! | |
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. | |
17 | $ | |
18 | $! C compiler | |
19 | $! | |
20 | $ CC := gcc | |
21 | $! CC := cc !uncomment for VAXC | |
22 | $ BISON := bison | |
23 | $ RENAME := rename/new_vers | |
24 | $ LINK := link | |
25 | $ EDIT := edit | |
26 | $! | |
27 | $! Compiler options | |
28 | $! | |
29 | $ CFLAGS = "/debug/cc1_options=""-mpcc-alignment""/incl=([],[.config])" | |
30 | $! CFLAGS = "/noopt/incl=([],[.config])" | |
31 | $! | |
32 | $! Link options | |
33 | $! | |
34 | $ LDFLAGS := /nomap | |
35 | $! | |
36 | $! Link libraries | |
37 | $! | |
38 | $ LIBS := gnu_cc:[000000]gcclib.olb/libr,sys$library:vaxcrtl.olb/libr | |
39 | $! LIBS := alloca.obj,sys$library:vaxcrtl.olb/libr | |
40 | $! | |
41 | $! | |
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: | |
45 | $! | |
46 | $! LINK: Assume that the object modules for the selected compiler(s) | |
47 | $! have already been compiled, perform link phase only. | |
48 | $! | |
49 | $! CC1: Compile and link "C" compiler. | |
50 | $! | |
51 | $! CC1PLUS:Compile and link "C++" compiler. | |
52 | $! | |
53 | $! CC1OBJ: Compile and link objective C compiler. | |
54 | $! | |
55 | $! ALL: Compile and link all of the CC1 passes. | |
56 | $! | |
57 | $! INDEPENDENT: | |
58 | $! Compile language independent source modules. (On by default). | |
59 | $! | |
60 | $! DEBUG: Link images with /debug. | |
61 | $! | |
62 | $! If you want to list more than one option, you should use a spaces to | |
63 | $! separate them. | |
64 | $! | |
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. | |
69 | $! | |
70 | $! If you do not specify which compiler you want to build, it is assumed that | |
71 | $! you want to build GNU-C ("CC1"). | |
72 | $! | |
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") | |
76 | $i=0 | |
77 | $DO_ALL = 0 | |
78 | $DO_LINK = 0 | |
79 | $DO_DEBUG = 0 | |
80 | $open cfile$ compilers.list | |
81 | $cinit:read cfile$ compilername/end=cinit_done | |
82 | $DO_'compilername'=0 | |
83 | $goto cinit | |
84 | $cinit_done: close cfile$ | |
85 | $DO_INDEPENDENT = 1 | |
86 | $DO_DEFAULT = 1 | |
87 | $loop: | |
88 | $string = f$element(i," ",p1) | |
89 | $if string.eqs." " then goto done | |
90 | $flag = 1 | |
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) | |
95 | $ flag = 0 | |
96 | $parse_option: | |
97 | $DO_'string' = flag | |
98 | $i=i+1 | |
99 | $goto loop | |
100 | $! | |
101 | $done: | |
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." | |
111 | $link_only: | |
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." | |
116 | $! | |
117 | $! Test and see if we need these messages or not. The -1 switch gives it away. | |
118 | $! | |
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 | |
126 | $gas_message: | |
127 | $type sys$input | |
128 | ||
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. | |
134 | ||
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. | |
139 | ||
140 | $! | |
141 | $no_message: | |
142 | $! | |
143 | $! | |
144 | $ if DO_DEBUG.eq.1 then LDFLAGS :='LDFLAGS'/debug | |
145 | $! | |
146 | $if DO_LINK.eq.1 then goto compile_cc1 | |
147 | $if DO_INDEPENDENT.eq.1 | |
148 | $ THEN | |
149 | $! | |
150 | $! Build alloca if necessary (in 'LIBS for use with VAXC) | |
151 | $! | |
152 | $ if f$locate("alloca.obj",f$edit(LIBS,"lowercase")).ge.f$length(LIBS) then - | |
153 | goto skip_alloca | |
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 | |
157 | $set verify | |
158 | $ 'CC 'CFLAGS /define="STACK_DIRECTION=(-1)" alloca.c | |
159 | $!'f$verify(0) | |
160 | $skip_alloca: | |
161 | $! | |
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. | |
164 | $! | |
165 | $set verify | |
166 | $ 'CC 'CFLAGS rtl.C | |
167 | $ 'CC 'CFLAGS obstack.C | |
168 | $!'f$verify(0) | |
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 | |
174 | $! | |
175 | $call compile independent.opt "rtl,obstack,insn-attrtab" | |
176 | $! | |
177 | $ call generate insn-attrtab.c "rtlanal," | |
178 | $set verify | |
179 | $ 'CC 'CFLAGS insn-attrtab.c | |
180 | $!'f$verify(0) | |
181 | $ endif | |
182 | $! | |
183 | $compile_cc1: | |
184 | $if (DO_CC1 + DO_CC1OBJ) .ne.0 | |
185 | $ then | |
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"))) - | |
189 | then goto yes_yfiles | |
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"))) - | |
193 | then goto yes_yfiles | |
194 | $GOTO no_yfiles | |
195 | $yes_yfiles: | |
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 | |
198 | ! | |
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... | |
204 | ! | |
205 | ||
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 | |
210 | ENDPROCEDURE; | |
211 | ||
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 | |
216 | ||
217 | POSITION(BEGINNING_OF(input_file)); | |
218 | c_only := 0; | |
219 | objc_only := 0; | |
220 | ||
221 | LOOP | |
222 | EXITIF MARK(NONE) = END_OF(input_file); !are we done yet? | |
223 | ||
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" | |
233 | ENDCASE; | |
234 | ||
235 | MOVE_VERTICAL(1); !go to next line | |
236 | ENDLOOP; | |
237 | ||
238 | WRITE_FILE(c, "c-parse.y"); | |
239 | WRITE_FILE(objc, "objc-parse.y"); | |
240 | QUIT | |
241 | $ endif | |
242 | $no_yfiles: | |
243 | $! | |
244 | $open cfile$ compilers.list | |
245 | $cloop:read cfile$ compilername/end=cdone | |
246 | $! language specific modules | |
247 | $! | |
248 | $if (DO_ALL + DO_'compilername').eq.0 then goto cloop | |
249 | $if DO_LINK.eq.0 then call compile 'compilername'-objs.opt "obstack" | |
250 | $! | |
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. | |
253 | $! | |
254 | $set verify | |
255 | $ link 'LDFLAGS' /exe=gcc-'compilername' version.opt/opt, - | |
256 | 'compilername'-objs.opt/opt, independent.opt/opt, - | |
257 | 'LIBS' | |
258 | $!'f$verify(0) | |
259 | $goto cloop | |
260 | $! | |
261 | $! | |
262 | $cdone: close cfile$ | |
263 | $! | |
264 | $! Done | |
265 | $! | |
266 | $! 'f$verify(v) | |
267 | $exit | |
268 | $! | |
269 | $! Various DCL subroutines follow... | |
270 | $! | |
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. | |
275 | $! | |
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. | |
278 | $! | |
279 | $compile: | |
280 | $subroutine | |
281 | $on error then goto c_err | |
282 | $on control_y then goto c_err | |
283 | $open ifile$ 'p1' | |
284 | $loop: read ifile$ line/end=c_done | |
285 | $! | |
286 | $i=0 | |
287 | $loop1: | |
288 | $flnm=f$element(i,",",line) | |
289 | $i=i+1 | |
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 | |
293 | $! | |
294 | $if f$locate("-parse",flnm).nes.f$length(flnm) | |
295 | $ then | |
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"))) - | |
299 | then goto no_bison | |
300 | $yes_bison: | |
301 | $set verify | |
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" | |
309 | $ close jfile$ | |
310 | $ endif | |
311 | $!'f$verify(0) | |
312 | $no_bison: | |
313 | $ endif | |
314 | $! | |
315 | $if f$extract(0,5,flnm).eqs."insn-" then call generate 'flnm'.c | |
316 | $! | |
317 | $set verify | |
318 | $ 'CC 'CFLAGS 'flnm'.c | |
319 | $!'f$verify(0) | |
320 | $goto loop1 | |
321 | $! | |
322 | $goto loop | |
323 | $! | |
324 | $! In case of error or abort, go here (In order to close file). | |
325 | $! | |
326 | $c_err: !'f$verify(0) | |
327 | $close ifile$ | |
328 | $exit %x2c | |
329 | $! | |
330 | $c_done: | |
331 | $close ifile$ | |
332 | $endsubroutine | |
333 | $! | |
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 | |
337 | $! program. | |
338 | $! | |
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. | |
342 | $! | |
343 | $generate: | |
344 | $subroutine | |
345 | $if f$extract(0,5,p1).nes."INSN-" | |
346 | $ then | |
347 | $ write sys$error "Unknown file passed to generate." | |
348 | $ exit 1 | |
349 | $ endif | |
350 | $root1=f$parse(f$extract(5,255,p1),,,"NAME") | |
351 | $ set verify | |
352 | $ 'CC 'CFLAGS GEN'root1'.C | |
353 | $ link 'LDFLAGS' GEN'root1',rtl,obstack,'p2' - | |
354 | 'LIBS' | |
355 | $! 'f$verify(0) | |
356 | $! | |
357 | $set verify | |
358 | $ assign/user 'p1' sys$output: | |
359 | $ mcr sys$disk:[]GEN'root1' md | |
360 | $!'f$verify(0) | |
361 | $endsubroutine |