OSDN Git Service

90th Cygnus<->FSF quick merge
[pf3gnuchains/gcc-fork.git] / gcc / make-cc1.com
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 $!
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.
9 $!
10 $!      Build the GNU "C" compiler on VMS
11 $!
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.
16 $
17 $!      C compiler
18 $!
19 $ CC    =       "gcc"
20 $! CC   =       "cc"    !uncomment for VAXC
21 $ BISON =       "bison"
22 $ BISON_FLAGS=  "/Define/Verbose"
23 $ RENAME=       "rename/New_Version"
24 $ LINK  =       "link"
25 $ EDIT  =       "edit"
26 $ SEARCH=       "search"
27 $ ABORT =       "exit %x002C"
28 $ echo  =       "write sys$output"
29 $!
30 $!      Compiler options
31 $!
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
37 $!
38 $!      Link options
39 $!
40 $ LDFLAGS =     "/noMap"
41 $!
42 $!      Link libraries
43 $!
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
46 $
47 $!!!!!!!
48 $!      Nothing beyond this point should need any local configuration changes.
49 $!!!!!!!
50 $
51 $!
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:
55 $!
56 $!      LINK:   Assume that the object modules for the selected compiler(s)
57 $!              have already been compiled, perform link phase only.
58 $!
59 $!      CC1:    Compile and link "C" compiler.
60 $!
61 $!      CC1PLUS:Compile and link "C++" compiler.
62 $!
63 $!      CC1OBJ: Compile and link objective C compiler.
64 $!
65 $!      ALL:    Compile and link all of the CC1 passes.
66 $!
67 $!      INDEPENDENT:
68 $!              Compile language independent source modules. (On by default).
69 $!
70 $!      BC:
71 $!              Compile byte compiler source modules. (On by default).
72 $!
73 $!      DEBUG:  Link images with /debug.
74 $!
75 $! If you want to list more than one option, you should use a spaces to
76 $! separate them.
77 $!
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.
82 $!
83 $! If you do not specify which compiler you want to build, it is assumed that
84 $! you want to build GNU-C ("CC1").
85 $!
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")
89 $i=0
90 $DO_ALL = 0
91 $DO_LINK = 0
92 $DO_DEBUG = 0
93 $DO_CC1PLUS = 0
94 $DO_CC1OBJ = 0
95 $DO_OBJCLIB = 0
96 $if f$trnlnm("cfile$").nes."" then  close/noLog cfile$
97 $open cfile$ compilers.list
98 $cinit:read cfile$ compilername/end=cinit_done
99 $DO_'compilername'=0
100 $goto cinit
101 $cinit_done: close cfile$
102 $DO_INDEPENDENT = 1
103 $DO_DEFAULT = 1
104 $DO_BC = 1
105 $loop:
106 $string = f$element(i," ",p1)
107 $if string.eqs." " then goto done
108 $flag = 1
109 $if string.eqs."CC1PLUS" then DO_DEFAULT = 0
110 $if string.eqs."CC1OBJ" then DO_DEFAULT = 0
111 $if string.eqs."OBJCLIB"
112 $then   DO_DEFAULT = 0
113 $       DO_INDEPENDENT = DO_CC1OBJ
114 $       DO_BC = DO_CC1OBJ
115 $endif
116 $if f$extract(0,2,string).nes."NO" then goto parse_option
117 $  string=f$extract(2,f$length(string)-2,string)
118 $  flag = 0
119 $parse_option:
120 $DO_'string' = flag
121 $i=i+1
122 $goto loop
123 $!
124 $done:
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."
135 $link_only:
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."
140 $!
141 $! Update CFLAGS with appropriate CINCLx value.
142 $!
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
148 $ goto cinclX
149 $stage1:
150 $ CFLAGS = CFLAGS + CINCL1
151 $cinclX:
152 $!
153 $! Test and see if we need these messages or not.  The -1 switch gives it away.
154 $!
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
163
164 -----
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.
173
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.
178 -----
179
180 $goto skip_gas_message
181 $gas_missing_message:
182 $type sys$input:        !no version of gas was found
183
184 -----
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.
189
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.
193 -----
194
195 $skip_gas_message:
196 $!
197 $!
198 $ if DO_DEBUG.eq.1 then LDFLAGS = LDFLAGS + "/Debug"
199 $!
200 $if DO_LINK.eq.1 then goto no_yfiles    !compile_cc1
201 $!
202 $! Build alloca if necessary (in 'LIBS for use with VAXC)
203 $!
204 $ if f$locate("alloca.obj",f$edit(LIBS,"lowercase")).ge.f$length(LIBS) then -
205         goto skip_alloca
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
209 $set verify
210 $ 'CC''CFLAGS'/Define="STACK_DIRECTION=(-1)" alloca.c
211 $!'f$verify(0)
212 $skip_alloca:
213 $!
214 $if DO_BC.eq.1 
215 $       THEN 
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
220 $       close ifile$
221 $       bc_index = 0
222 $bc_loop:
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
227 $       goto bc_loop
228 $bc_done:
229 $       endif
230 $!
231 $!
232 $if DO_INDEPENDENT.eq.1 
233 $       THEN 
234 $!
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.
237 $!
238 $set verify
239 $ 'CC''CFLAGS' rtl.c
240 $ 'CC''CFLAGS' obstack.c
241 $!'f$verify(0)
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
247 $!
248 $call compile independent.opt "rtl,obstack,insn-attrtab"
249 $!
250 $       call generate insn-attrtab.c "rtlanal.obj,"
251 $set verify
252 $ 'CC''CFLAGS' insn-attrtab.c
253 $ 'CC''CFLAGS' bc-emit.c
254 $ 'CC''CFLAGS' bc-optab.c
255 $!'f$verify(0)
256 $       endif
257 $!
258 $compile_cc1:
259 $if (DO_CC1 + DO_CC1OBJ) .ne.0
260 $       then
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")))  -
264                 then goto yes_yfiles
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")))  -
268                 then goto yes_yfiles
269 $GOTO no_yfiles
270 $yes_yfiles:
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
273 !
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...
279 !
280
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
285    ENDPROCEDURE;
286
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
291
292    POSITION(BEGINNING_OF(input_file));
293    c_only     := 0;
294    objc_only  := 0;
295
296    LOOP
297       EXITIF MARK(NONE) = END_OF(input_file);   !are we done yet?
298
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"
308       ENDCASE;
309
310       MOVE_VERTICAL(1);                         !go to next line
311    ENDLOOP;
312
313    WRITE_FILE(c, "c-parse.y");
314    WRITE_FILE(objc, "objc-parse.y");
315    QUIT
316 $       endif   
317 $no_yfiles:
318 $!
319 $open cfile$ compilers.list
320 $cloop:read cfile$ compilername/end=cdone
321 $! language specific modules
322 $!
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"
326 $!
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.
329 $!
330 $set verify
331 $ 'LINK''LDFLAGS'/Exe=gcc-'compilername'.exe  version.opt/Opt,-
332           'compilername'-objs.opt/Opt,independent.opt/Opt,-
333           'LIBS'
334 $!'f$verify(0)
335 $goto cloop
336 $!
337 $!
338 $cdone: close cfile$
339 $!
340 $ if DO_OBJCLIB
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
349 $       i = 0
350 $ocl2:  o = f$element(i,",",line)
351 $       if o.eqs."," then goto ocl1
352 $       n = o - ".o"
353 $       if f$search(n + ".m").nes.""
354 $       then    f = n + ".m"
355 $               flags = MFLAGS
356 $       else    f = n + ".c"
357 $               flags = CFLAGS
358 $       endif
359 $       set verify
360 $ 'CC' 'flags' 'f'
361 $!'f$verify(0)'
362 $       library/Obj [-]objclib.olb 'n'.obj/Insert
363 $       delete/noConfirm/noLog 'n'.obj;*
364 $       i = i + 1
365 $       goto ocl2
366 $ocl3:  close ifile$
367 $       CFLAGS = save_cflags
368 $       set default [-] !pop
369 $ endif !DO_OBJCLIB
370 $!
371 $!      Done
372 $!
373 $! 'f$verify(v)
374 $exit
375 $!
376 $!  Various DCL subroutines follow...
377 $!
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.
382 $!
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.
385 $!
386 $compile:
387 $subroutine
388 $on error then goto c_err
389 $on control_y then goto c_err
390 $open ifile$ 'p1'
391 $loop: read ifile$ line/end=c_done
392 $!
393 $i=0
394 $loop1:
395 $flnm=f$element(i,",",line)
396 $i=i+1
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"
401 $prfx = ""
402 $k = f$locate("]",flnm)
403 $if k.eq.1      ![]c-common for [.cp]
404 $then
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)
410 $ endif
411 $endif
412 $ if prfx.nes.""
413 $ then  set default [.'prfx']   !push
414 $       save_cflags = CFLAGS
415 $       CFLAGS = CFLAGS - CINCL1 - CINCL2 + CINCL_SUB
416 $ endif
417 $!
418 $if f$locate("parse",flnm).nes.f$length(flnm)
419 $       then
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")))  -
423                 then goto no_bison
424 $yes_bison:
425 $set verify
426 $        'BISON''BISON_FLAGS' 'flnm'.y
427 $        'RENAME' 'flnm'_tab.c 'flnm'.c
428 $        'RENAME' 'flnm'_tab.h 'flnm'.h
429 $!'f$verify(0)
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"
434 $               close jfile$
435 $       endif
436 $no_bison:
437 $        echo " (Ignore any warning about not finding file ""bison.simple"".)"
438 $       endif
439 $!
440 $if f$extract(0,5,flnm).eqs."insn-" then call generate 'flnm'.c
441 $!
442 $set verify
443 $ 'CC''CFLAGS' 'flnm'.c
444 $!'f$verify(0)
445 $ if prfx.nes.""
446 $ then  set default [-]         !pop
447 $       CFLAGS = save_CFLAGS
448 $ endif
449 $
450 $goto loop1
451 $!
452 $!
453 $! In case of error or abort, go here (In order to close file).
454 $!
455 $c_err: !'f$verify(0)
456 $close ifile$
457 $ABORT
458 $!
459 $c_done:
460 $close ifile$
461 $endsubroutine
462 $!
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
466 $! program.
467 $!
468 $generate:
469 $subroutine
470 $if f$extract(0,5,p1).nes."INSN-"
471 $       then
472 $       write sys$error "Unknown file passed to generate."
473 $       ABORT
474 $       endif
475 $root1=f$parse(f$extract(5,255,p1),,,"NAME")
476 $       set verify
477 $ 'CC''CFLAGS' GEN'root1'.C
478 $ 'LINK''LDFLAGS' GEN'root1'.OBJ,rtl.obj,obstack.obj,'p2' -
479           'LIBS'
480 $!      'f$verify(0)
481 $!
482 $set verify
483 $       assign/user 'p1' sys$output:
484 $       mcr sys$disk:[]GEN'root1' vax.md
485 $!'f$verify(0)
486 $endsubroutine
487 $!
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
491 $! program.
492 $!
493 $bc_generate:
494 $subroutine
495 $if f$extract(0,3,p1).nes."BC-"
496 $       then
497 $       write sys$error "Unknown file passed to bc_generate."
498 $       ABORT
499 $       endif
500 $root1=f$parse(f$extract(3,255,p1),,,"NAME")
501 $       set verify
502 $ 'CC''CFLAGS' BI-'root1'.C
503 $ 'LINK''LDFLAGS' BI-'root1'.OBJ,'p2' -
504           'LIBS'
505 $!      'f$verify(0)
506 $!
507 $set verify
508 $       assign/user bytecode.def sys$input:
509 $       assign/user 'p1' sys$output:
510 $       mcr sys$disk:[]BI-'root1'
511 $!'f$verify(0)
512 $endsubroutine