OSDN Git Service

(alpha_need_linkage): Call get_identifier.
[pf3gnuchains/gcc-fork.git] / gcc / make-cc1.com
1 $v='f$verify(0) !make-cc1.com
2 $!
3 $!      Build the GNU C compiler on VMS.
4 $!
5 $!      Usage:
6 $!        $ @make-cc1.com [host-compiler] [various]
7 $!
8 $!      where [host-compiler] is one of "GNUC", "VAXC", "DECC";
9 $!      default when none specified is "GNUC",
10 $!      and where [various] is one or more of "CC1", "CC1PLUS",
11 $!      "CC1OBJ", "OBJCLIB", "INDEPENDENT", "BC", "ALL", "LINK", "DEBUG".
12 $!      "CC1" (C compiler) is the default; of the others, only
13 $!      "CC1PLUS" (C++ compiler), "CC1OBJ" (Objective-C compiler),
14 $!      and "OBJCLIB" (Objective-C run-time library) are of interest
15 $!      for normal installation.
16 $!      If both [host-compiler] and other option(s) are specified,
17 $!      the host compiler argument must come first.
18 $!
19 $ if f$type(gcc_debug).eqs."INTEGER" then  if gcc_debug.and.1 then  set verify
20 $
21 $ p1 = f$edit(p1,"UPCASE,TRIM")
22 $ if p1.eqs."" then  p1 = "GNUC"
23 $!
24 $!      Compiler-specific setup (assume GNU C, then override as necessary):
25 $!
26 $ CC     = "gcc"
27 $ CFLAGS = "/Debug/noVerbos/CC1=""-mpcc-alignment"""
28 $ LIBS   = "gnu_cc:[000000]gcclib.olb/Libr,sys$library:vaxcrtl.olb/Libr"
29 $ if p1.eqs."GNUC"
30 $ then
31 $   p1 = ""
32 $ else
33 $   CC     = "cc"
34 $   CFLAGS = "/noOpt"   !disable optimizer when bootstrapping with native cc
35 $   if p2.eqs."DEBUG" .or. p3.eqs."DEBUG" then  CFLAGS = CFLAGS + "/Debug"
36 $   if p1.eqs."VAXC"
37 $   then
38 $     p1 = ""
39 $     if f$trnlnm("DECC$CC_DEFAULT").nes."" then  CC = "cc/VAXC"
40 $     LIBS = "alloca.obj,sys$library:vaxcrtl.olb/Libr"
41 $     define/noLog SYS SYS$LIBRARY:
42 $   else
43 $     if p1.eqs."DECC"
44 $     then
45 $       p1 = ""
46 $       if f$trnlnm("DECC$CC_DEFAULT").nes."" then  CC = "cc/DECC"
47 $       CC = CC + "/Prefix=All/Warn=Disabl=(ImplicitFunc)"
48 $       LIBS = "alloca.obj"     !DECC$SHR will be found implicitly by linker
49 $       define/noLog SYS DECC$LIBRARY_INCLUDE:
50 $     endif !DECC
51 $   endif !VAXC
52 $ endif !GNUC
53 $
54 $!
55 $!      Other setup:
56 $!
57 $ LDFLAGS =     "/noMap"
58 $ PARSER  =     "bison"
59 $ PARSER_FLAGS= "/Define/Verbose"
60 $ RENAME  =     "rename/New_Version"
61 $ LINK    =     "link"
62 $ EDIT    =     "edit"
63 $ SEARCH  =     "search"
64 $ ABORT   =     "exit %x002C"
65 $ echo    =     "write sys$output"
66 $!
67 $!      Stage[123] options
68 $!
69 $ CINCL1 =      "/Incl=[]"                      !stage 1 -I flags
70 $ CINCL2 =      "/Incl=([],[.ginclude])"        !stage 2,3,... flags
71 $ CINCL_SUB =   "/Incl=([],[-],[-.ginclude])"   ![.cp] flags
72 $
73 $!!!!!!!
74 $!      Nothing beyond this point should need any local configuration changes.
75 $!!!!!!!
76 $
77 $! Set the default directory to the same place as this command procedure.
78 $ flnm = f$enviroment("PROCEDURE")      !get current procedure name
79 $ set default 'f$parse(flnm,,,"DEVICE")''f$parse(flnm,,,"DIRECTORY")'
80 $
81 $!
82 $!  First we figure out what needs to be done.  This is sort of like a limited
83 $! make facility - the command line options specify exactly what components
84 $! we want to build.  The following options are understood:
85 $!
86 $!      LINK:   Assume that the object modules for the selected compiler(s)
87 $!              have already been compiled, perform link phase only.
88 $!
89 $!      CC1:    Compile and link "C" compiler.
90 $!
91 $!      CC1PLUS:Compile and link "C++" compiler.
92 $!
93 $!      CC1OBJ: Compile and link objective C compiler.
94 $!
95 $!      ALL:    Compile and link all of the CC1 passes.
96 $!
97 $!      INDEPENDENT:
98 $!              Compile language independent source modules. (On by default).
99 $!
100 $!      BC:
101 $!              Compile byte compiler source modules. (On by default).
102 $!
103 $!      OBJCLIB:
104 $!              Compile Objective-C run-time library.
105 $!
106 $!      DEBUG:  Link images with /debug.
107 $!
108 $! If you want to list more than one option, you should use a spaces to
109 $! separate them.
110 $!
111 $!      Any one of the above options can be prefaced with a "NO".  For example,
112 $! if you had already built GCC, and you wanted to build G++, you could use the
113 $! "CC1PLUS NOINDEPENDENT" options, which would only compile the C++ language
114 $! specific source files, and then link the C++ compiler.
115 $!
116 $! If you do not specify which compiler you want to build, it is assumed that
117 $! you want to build GNU-C ("CC1").
118 $!
119 $! Now figure out what we have been requested to do.
120 $p1 = p1+" "+p2+" "+p3+" "+p4+" "+p5+" "+p6+" "+p7+" "+p8
121 $p1 = f$edit(p1,"COMPRESS,TRIM")
122 $i=0
123 $DO_ALL = 0
124 $DO_LINK = 0
125 $DO_DEBUG = 0
126 $DO_CC1PLUS = 0
127 $DO_CC1OBJ = 0
128 $DO_OBJCLIB = 0
129 $if f$trnlnm("cfile$").nes."" then  close/noLog cfile$
130 $open cfile$ compilers.list
131 $cinit:read cfile$ compilername/end=cinit_done
132 $DO_'compilername'=0
133 $goto cinit
134 $cinit_done: close cfile$
135 $DO_INDEPENDENT = 1
136 $DO_DEFAULT = 1
137 $DO_BC = 1
138 $loop:
139 $string = f$element(i," ",p1)
140 $if string.eqs." " then goto done
141 $flag = 1
142 $if string.eqs."CC1PLUS" then DO_DEFAULT = 0
143 $if string.eqs."CC1OBJ" then DO_DEFAULT = 0
144 $if string.eqs."OBJCLIB"
145 $then   DO_DEFAULT = 0
146 $       DO_INDEPENDENT = DO_CC1OBJ
147 $       DO_BC = DO_CC1OBJ
148 $endif
149 $if f$extract(0,2,string).nes."NO" then goto parse_option
150 $  string=f$extract(2,f$length(string)-2,string)
151 $  flag = 0
152 $parse_option:
153 $DO_'string' = flag
154 $i=i+1
155 $goto loop
156 $!
157 $done:
158 $if DO_DEFAULT.eq.1 then DO_CC1 = 1
159 $echo "This command file will now perform the following actions:
160 $if DO_LINK.eq.1 then goto link_only
161 $if DO_ALL.eq.1 then echo "   Compile all language specific object modules."
162 $if DO_CC1.eq.1 then echo "   Compile C specific object modules."
163 $if DO_CC1PLUS.eq.1 then echo "   Compile C++ specific object modules."
164 $if DO_CC1OBJ.eq.1 then echo "   Compile obj-C specific object modules."
165 $if DO_INDEPENDENT.eq.1 then echo "   Compile language independent object modules."
166 $if DO_BC.eq.1 then echo "   Compile byte compiler object modules."
167 $if DO_OBJCLIB.eq.1 then echo "   Create Objective-C run-time library."
168 $link_only:
169 $if DO_CC1.eq.1 then    echo "   Link C compiler (gcc-cc1.exe)."
170 $if DO_CC1PLUS.eq.1 then echo "   Link C++ compiler (gcc-cc1plus.exe)."
171 $if DO_CC1OBJ.eq.1 then echo "   Link objective-C compiler (gcc-cc1obj.exe)."
172 $if DO_DEBUG.eq.1 then echo  "   Link images to run under debugger."
173 $!
174 $! Update CFLAGS with appropriate CINCLx value.
175 $!
176 $if f$edit(f$extract(0,3,CC),"LOWERCASE").nes."gcc" then goto stage1
177 $if f$search("gcc-cc1.exe").eqs."" then goto stage1
178 $if f$file_attr("gnu_cc:[000000]gcc-cc1.exe","FID").nes.-
179     f$file_attr("gcc-cc1.exe","FID") then goto stage1
180 $ CFLAGS = CFLAGS + CINCL2
181 $ goto cinclX
182 $stage1:
183 $ CFLAGS = CFLAGS + CINCL1
184 $cinclX:
185 $!
186 $! Test and see if we need these messages or not.  The -1 switch gives it away.
187 $!
188 $gas := $gnu_cc:[000000]gcc-as.exe
189 $if f$search(gas-"$").eqs."" then  goto gas_missing_message     !must be VAXC
190 $define/user sys$error sys$scratch:gas_test.tmp
191 $gas -1 nla0: -o nla0:
192 $size=f$file_attributes("sys$scratch:gas_test.tmp","ALQ")
193 $delete/nolog sys$scratch:gas_test.tmp;*
194 $if size.eq.0 then goto skip_gas_message
195 $type sys$input:        !an old version of gas was found
196
197 -----
198      Note:  you appear to have an old version of gas, the GNU assembler.
199 GCC 2.x treats external variables differently than GCC 1.x does.  Before
200 you use GCC 2.x, you should obtain a version of the assembler which works
201 with GCC 2.x (gas-1.38 and earlier did not have the necessary support;
202 gas-2.0 through gas-2.3 did not work reliably for vax/vms configuration).
203 The assembler in gcc-vms-1.42 contained patches to provide the proper
204 support, and more recent versions have an up to date version of gas which
205 provides the support.  gas from binutils-2.5 or later is recommended.
206
207      If you do not update the assembler, the compiler will still work,
208 but `extern const' variables will be treated as `extern'.  This will result
209 in linker warning messages about mismatched psect attributes, and these
210 variables will be placed in read/write storage.
211 -----
212
213 $goto skip_gas_message
214 $gas_missing_message:
215 $type sys$input:        !no version of gas was found
216
217 -----
218      Note:  you appear to be missing gas, the GNU assembler.  Since
219 GCC produces assembly code as output from compilation, you need the
220 assembler to make full use of the compiler.  It should be put in place
221 as GNU_CC:[000000]GCC-AS.EXE.
222
223      A prebuilt copy of gas is available from the "gcc-vms" distribution,
224 and the gas source code is included in the GNU "binutils" distribution.
225 Version 2.5.2 or later is recommended.
226 -----
227
228 $skip_gas_message:
229 $!
230 $!
231 $ if DO_DEBUG.eq.1 then LDFLAGS = LDFLAGS + "/Debug"
232 $!
233 $if DO_LINK.eq.1 then goto no_yfiles    !compile_cc1
234 $!
235 $! Build alloca if necessary (in 'LIBS for use with VAXC)
236 $!
237 $ if f$locate("alloca.obj",f$edit(LIBS,"lowercase")).ge.f$length(LIBS) then -
238         goto skip_alloca
239 $ if f$search("alloca.obj").nes."" then -  !does .obj exist? is it up to date?
240     if f$cvtime(f$file_attributes("alloca.obj","RDT")).gts.-
241        f$cvtime(f$file_attributes("alloca.c","RDT")) then  goto skip_alloca
242 $set verify
243 $ 'CC''CFLAGS'/Defi=("HAVE_CONFIG_H","STACK_DIRECTION=(-1)") alloca.c
244 $!'f$verify(0)
245 $skip_alloca:
246 $!
247 $if DO_BC.eq.1
248 $       then
249 $       call compile bi_all.opt ""
250 $       if f$trnlnm("ifile$").nes."" then  close/noLog ifile$
251 $       open ifile$ bc_all.list
252 $       read ifile$ bc_line
253 $       close ifile$
254 $       bc_index = 0
255 $bc_loop:
256 $       tfile = f$element(bc_index, ",", bc_line)
257 $       if tfile.eqs."," then goto bc_done
258 $       call bc_generate 'tfile' "bi_all.opt/opt,"
259 $       bc_index = bc_index + 1
260 $       goto bc_loop
261 $bc_done:
262 $       endif
263 $!
264 $!
265 $if DO_INDEPENDENT.eq.1
266 $       then
267 $!
268 $! First build a couple of header files from the machine description
269 $! These are used by many of the source modules, so we build them now.
270 $!
271 $set verify
272 $ 'CC''CFLAGS' rtl.c
273 $ 'CC''CFLAGS' obstack.c
274 $!'f$verify(0)
275 $! Generate insn-attr.h
276 $       call generate insn-attr.h
277 $       call generate insn-flags.h
278 $       call generate insn-codes.h
279 $       call generate insn-config.h
280 $!
281 $call compile independent.opt "rtl,obstack,insn-attrtab"
282 $!
283 $       call generate insn-attrtab.c "rtlanal.obj,"
284 $set verify
285 $ 'CC''CFLAGS' insn-attrtab.c
286 $ 'CC''CFLAGS' bc-emit.c
287 $ 'CC''CFLAGS' bc-optab.c
288 $!'f$verify(0)
289 $       endif
290 $!
291 $compile_cc1:
292 $if (DO_CC1 + DO_CC1OBJ) .ne.0
293 $       then
294 $if (f$search("C-PARSE.Y") .eqs. "") then goto yes_yfiles
295 $if (f$cvtime(f$file_attributes("C-PARSE.IN","RDT")).gts. -
296             f$cvtime(f$file_attributes("C-PARSE.Y","RDT")))  -
297                 then goto yes_yfiles
298 $if (f$search("OBJC-PARSE.Y") .eqs. "") then goto yes_yfiles
299 $if (f$cvtime(f$file_attributes("C-PARSE.IN","RDT")).gts. -
300             f$cvtime(f$file_attributes("OBJC-PARSE.Y","RDT")))  -
301                 then goto yes_yfiles
302 $GOTO no_yfiles
303 $yes_yfiles:
304 $echo "Now processing c-parse.in to generate c-parse.y and objc-parse.y."
305 $ edit/tpu/nojournal/nosection/nodisplay/command=sys$input
306 !
307 !     Read c-parse.in, write c-parse.y and objc-parse.y, depending on
308 !     paired lines of "ifc" & "end ifc" and "ifobjc" & "end ifobjc" to
309 !     control what goes into each file.  Most lines will be common to
310 !     both (hence not bracketed by either control pair).  Mismatched
311 !     pairs aren't detected--garbage in, garbage out...
312 !
313
314    PROCEDURE do_output()
315       IF NOT objc_only THEN POSITION(END_OF(c)); COPY_TEXT(input_line); ENDIF;
316       IF NOT c_only THEN POSITION(END_OF(objc)); COPY_TEXT(input_line); ENDIF;
317       POSITION(input_file);                     !reset
318    ENDPROCEDURE;
319
320    input_file := CREATE_BUFFER("input", "c-parse.in");  !load data
321                  SET(NO_WRITE, input_file);
322    c          := CREATE_BUFFER("c_output");     !1st output file
323    objc       := CREATE_BUFFER("objc_output");  !2nd output file
324
325    POSITION(BEGINNING_OF(input_file));
326    c_only     := 0;
327    objc_only  := 0;
328
329    LOOP
330       EXITIF MARK(NONE) = END_OF(input_file);   !are we done yet?
331
332       input_line := CURRENT_LINE;               !access current_line just once
333       CASE EDIT(input_line, TRIM_TRAILING, OFF, NOT_IN_PLACE)
334          ["ifc"]        : c_only := 1;
335          ["end ifc"]    : c_only := 0;
336          ["ifobjc"]     : objc_only := 1;
337          ["end ifobjc"] : objc_only := 0;
338 !         default -- add non-control line to either or both output files
339          [INRANGE]      : do_output();          !between "end" and "if"
340          [OUTRANGE]     : do_output();          !before "end" or after "if"
341       ENDCASE;
342
343       MOVE_VERTICAL(1);                         !go to next line
344    ENDLOOP;
345
346    WRITE_FILE(c, "c-parse.y");
347    WRITE_FILE(objc, "objc-parse.y");
348    QUIT
349 $       endif   
350 $no_yfiles:
351 $!
352 $open cfile$ compilers.list
353 $cloop:read cfile$ compilername/end=cdone
354 $! language specific modules
355 $!
356 $if (DO_ALL + DO_'compilername').eq.0 then goto cloop
357 $if DO_LINK.eq.0 then -
358  call compile 'compilername'-objs.opt "obstack,bc-emit,bc-optab"
359 $!
360 $! CAUTION: If you want to link gcc-cc1* to the sharable image library
361 $! VAXCRTL, see the notes in gcc.texinfo (or INSTALL) first.
362 $!
363 $set verify
364 $ 'LINK''LDFLAGS'/Exe=gcc-'compilername'.exe  version.opt/Opt,-
365           'compilername'-objs.opt/Opt,independent.opt/Opt,-
366           'LIBS'
367 $!'f$verify(0)
368 $goto cloop
369 $!
370 $!
371 $cdone: close cfile$
372 $!
373 $ if DO_OBJCLIB
374 $ then  set default [.objc]     !push
375 $       save_cflags = CFLAGS
376 $       CFLAGS = CFLAGS - CINCL1 - CINCL2 + CINCL_SUB
377 $       MFLAGS = "/Lang=ObjC" + CFLAGS
378 $       library/Obj [-]objclib.olb/Create
379 $       if f$trnlnm("IFILE$").nes."" then  close/noLog ifile$
380 $       open/Read ifile$ [-]objc-objs.opt
381 $ocl1:  read/End=ocl3 ifile$ line
382 $       i = 0
383 $ocl2:  o = f$element(i,",",line)
384 $       if o.eqs."," then goto ocl1
385 $       n = o - ".o"
386 $       if f$search(n + ".m").nes.""
387 $       then    f = n + ".m"
388 $               flags = MFLAGS
389 $       else    f = n + ".c"
390 $               flags = CFLAGS
391 $       endif
392 $       set verify
393 $ 'CC' 'flags' 'f'
394 $!'f$verify(0)'
395 $       library/Obj [-]objclib.olb 'n'.obj/Insert
396 $       delete/noConfirm/noLog 'n'.obj;*
397 $       i = i + 1
398 $       goto ocl2
399 $ocl3:  close ifile$
400 $       CFLAGS = save_cflags
401 $       set default [-] !pop
402 $ endif !DO_OBJCLIB
403 $!
404 $!      Done
405 $!
406 $! 'f$verify(v)
407 $exit
408 $!
409 $!  Various DCL subroutines follow...
410 $!
411 $!  This routine takes parameter p1 to be a linker options file with a list
412 $!  of object files that are needed.  It extracts the names, and compiles
413 $!  each source module, one by one.  File names that begin with an
414 $!  "INSN-" are assumed to be generated by a GEN*.C program.
415 $!
416 $!  Parameter P2 is a list of files which will appear in the options file
417 $!  that should not be compiled.  This allows us to handle special cases.
418 $!
419 $compile:
420 $subroutine
421 $on error then goto c_err
422 $on control_y then goto c_err
423 $open ifile$ 'p1'
424 $loop: read ifile$ line/end=c_done
425 $!
426 $i=0
427 $loop1:
428 $flnm=f$element(i,",",line)
429 $i=i+1
430 $if flnm.eqs."" then goto loop
431 $if flnm.eqs."," then goto loop
432 $if f$locate(flnm,p2).lt.f$length(p2) then goto loop1
433 $! check for front-end subdirectory: "[.prfx]flnm"
434 $prfx = ""
435 $k = f$locate("]",flnm)
436 $if k.eq.1      ![]c-common for [.cp]
437 $then
438 $ if f$search(f$parse(".obj",flnm)).nes."" then  goto loop1
439 $ flnm = f$extract(2,999,flnm)
440 $else if k.lt.f$length(flnm)
441 $ then  prfx = f$extract(2,k-2,flnm)
442 $       flnm = f$extract(k+1,99,flnm)
443 $ endif
444 $endif
445 $ if prfx.nes.""
446 $ then  set default [.'prfx']   !push
447 $       save_cflags = CFLAGS
448 $       CFLAGS = CFLAGS - CINCL1 - CINCL2 + CINCL_SUB
449 $ endif
450 $!
451 $ if f$locate("parse",flnm).nes.f$length(flnm)
452 $ then
453 $   if f$search("''flnm'.c").nes."" then -
454       if f$cvtime(f$file_attributes("''flnm'.c","RDT")).ges. -
455          f$cvtime(f$file_attributes("''flnm'.y","RDT")) then  goto skip_yacc
456 $ set verify
457 $       'PARSER' 'PARSER_FLAGS' 'flnm'.y
458 $       'RENAME' 'flnm'_tab.c 'flnm'.c
459 $       'RENAME' 'flnm'_tab.h 'flnm'.h
460 $!'f$verify(0)
461 $       if flnm.eqs."cp-parse" .or. (prfx.eqs."cp" .and. flnm.eqs."parse")
462 $       then            ! fgrep '#define YYEMPTY' cp-parse.c >>cp-parse.h
463 $               if f$trnlnm("JFILE$").nes."" then  close/noLog jfile$
464 $               open/Append jfile$ 'flnm'.h
465 $               'SEARCH'/Exact/Output=jfile$ 'flnm'.c "#define YYEMPTY"
466 $               close jfile$
467 $       endif
468 $skip_yacc:
469 $        echo " (Ignore any warning about not finding file ""bison.simple"".)"
470 $ endif
471 $!
472 $if f$extract(0,5,flnm).eqs."insn-" then call generate 'flnm'.c
473 $!
474 $set verify
475 $ 'CC''CFLAGS' 'flnm'.c
476 $!'f$verify(0)
477 $ if prfx.nes.""
478 $ then  set default [-]         !pop
479 $       CFLAGS = save_CFLAGS
480 $ endif
481 $
482 $goto loop1
483 $!
484 $!
485 $! In case of error or abort, go here (In order to close file).
486 $!
487 $c_err: !'f$verify(0)
488 $close ifile$
489 $ABORT
490 $!
491 $c_done:
492 $close ifile$
493 $endsubroutine
494 $!
495 $! This subroutine generates the insn-* files.  The first argument is the
496 $! name of the insn-* file to generate.  The second argument contains a
497 $! list of any other object modules which must be linked to the gen*.c
498 $! program.
499 $!
500 $generate:
501 $subroutine
502 $if f$extract(0,5,p1).nes."INSN-"
503 $       then
504 $       write sys$error "Unknown file passed to generate."
505 $       ABORT
506 $       endif
507 $root1=f$parse(f$extract(5,255,p1),,,"NAME")
508 $       set verify
509 $ 'CC''CFLAGS' GEN'root1'.C
510 $ 'LINK''f$string(LDFLAGS - "/Debug")' GEN'root1'.OBJ,rtl.obj,obstack.obj,'p2' -
511           'LIBS'
512 $!      'f$verify(0)
513 $!
514 $set verify
515 $       assign/user 'p1' sys$output:
516 $       mcr sys$disk:[]GEN'root1' vax.md
517 $!'f$verify(0)
518 $endsubroutine
519 $!
520 $! This subroutine generates the bc-* files.  The first argument is the
521 $! name of the bc-* file to generate.  The second argument contains a
522 $! list of any other object modules which must be linked to the bi*.c
523 $! program.
524 $!
525 $bc_generate:
526 $subroutine
527 $if f$extract(0,3,p1).nes."BC-"
528 $       then
529 $       write sys$error "Unknown file passed to bc_generate."
530 $       ABORT
531 $       endif
532 $root1=f$parse(f$extract(3,255,p1),,,"NAME")
533 $       set verify
534 $ 'CC''CFLAGS' BI-'root1'.C
535 $ 'LINK''f$string(LDFLAGS - "/Debug")' BI-'root1'.OBJ,'p2' -
536           'LIBS'
537 $!      'f$verify(0)
538 $!
539 $set verify
540 $       assign/user bytecode.def sys$input:
541 $       assign/user 'p1' sys$output:
542 $       mcr sys$disk:[]BI-'root1'
543 $!'f$verify(0)
544 $endsubroutine