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
28 $ CFLAGS = "/debug/cc1_options=""-mpcc-alignment""/incl=([],[.config])"
29 $! CFLAGS = "/noopt/incl=([],[.config])"
37 $ LIBS := gnu_cc:[000000]gcclib.olb/libr,sys$library:vaxcrtl.olb/libr
38 $! LIBS := alloca.obj,sys$library:vaxcrtl.olb/libr
41 $! First we figure out what needs to be done. This is sort of like a limited
42 $! make facility - the command line options specify exactly what components
43 $! we want to build. The following options are understood:
45 $! LINK: Assume that the object modules for the selected compiler(s)
46 $! have already been compiled, perform link phase only.
48 $! CC1: Compile and link "C" compiler.
50 $! CC1PLUS:Compile and link "C++" compiler.
52 $! CC1OBJ: Compile and link objective C compiler.
54 $! ALL: Compile and link all of the CC1 passes.
57 $! Compile language independent source modules. (On by default).
59 $! DEBUG: Link images with /debug.
61 $! If you want to list more than one option, you should use a spaces to
64 $! Any one of the above options can be prefaced with a "NO". For example,
65 $! if you had already built GCC, and you wanted to build G++, you could use the
66 $! "CC1PLUS NOINDEPENDENT" options, which would only compile the C++ language
67 $! specific source files, and then link the C++ compiler.
69 $! If you do not specify which compiler you want to build, it is assumed that
70 $! you want to build GNU-C ("CC1").
72 $! Now figure out what we have been requested to do.
73 $p1 = p1+" "+p2+" "+p3+" "+p4+" "+p5+" "+p6+" "+p7
74 $p1 = f$edit(p1,"COMPRESS")
79 $open cfile$ compilers.list
80 $cinit:read cfile$ compilername/end=cinit_done
83 $cinit_done: close cfile$
87 $string = f$element(i," ",p1)
88 $if string.eqs." " then goto done
90 $if string.eqs."CC1PLUS" then DO_DEFAULT = 0
91 $if string.eqs."CC1OBJ" then DO_DEFAULT = 0
92 $if f$extract(0,2,string).nes."NO" then goto parse_option
93 $ string=f$extract(2,f$length(string)-2,string)
101 $if DO_DEFAULT.eq.1 then DO_CC1 = 1
102 $echo := write sys$Output
103 $echo "This command file will now perform the following actions:
104 $if DO_LINK.eq.1 then goto link_only
105 $if DO_ALL.eq.1 then echo " Compile all language specific object modules."
106 $if DO_CC1.eq.1 then echo " Compile C specific object modules."
107 $if DO_CC1PLUS.eq.1 then echo " Compile C++ specific object modules."
108 $if DO_CC1OBJ.eq.1 then echo " Compile obj-C specific object modules."
109 $if DO_INDEPENDENT.eq.1 then echo " Compile language independent object modules."
111 $if DO_CC1.eq.1 then echo " Link C compiler (gcc-cc1.exe)."
112 $if DO_CC1PLUS.eq.1 then echo " Link C++ compiler (gcc-cc1plus.exe)."
113 $if DO_CC1OBJ.eq.1 then echo " Link objective-C compiler (gcc-cc1obj.exe)."
114 $if DO_DEBUG.eq.1 then echo " Link images to run under debugger."
116 $! Test and see if we need these messages or not. The -1 switch gives it away.
118 $gas := $gnu_cc:[000000]gcc-as.exe
119 $if f$search(gas-"$").eqs."" then goto gas_message !must be VAXC
120 $define/user sys$error sys$scratch:gas_test.tmp
121 $gas -1 nla0: -o nla0:
122 $size=f$file_attributes("sys$scratch:gas_test.tmp","ALQ")
123 $delete/nolog sys$scratch:gas_test.tmp;*
124 $if size.eq.0 then goto no_message
128 Note: GCC 2.0 treats external variables differently than GCC 1.40 does.
129 Before you use GCC 2.0, you should obtain a version of the assembler which
130 contains the patches to work with GCC 2.0 (GCC-AS 1.38 does not contain
131 these patches - whatever comes after this probably will). The assembler
132 in gcc-vms-1.40.tar.Z from prep does contain the proper patches.
134 If you do not update the assembler, the compiler will still work,
135 but `extern const' variables will be treated as `extern'. This will result
136 in linker warning messages about mismatched psect attributes, and these
137 variables will be placed in read/write storage.
143 $ if DO_DEBUG.eq.1 then LDFLAGS :='LDFLAGS'/debug
145 $if DO_LINK.eq.1 then goto compile_cc1
146 $if DO_INDEPENDENT.eq.1
149 $! Build alloca if necessary (in 'LIBS for use with VAXC)
151 $ if f$locate("alloca.obj",f$edit(LIBS,"lowercase")).ge.f$length(LIBS) then -
153 $ if f$search("alloca.obj").nes."" then - !does .obj exist? is it up to date?
154 if f$cvtime(f$file_attributes("alloca.obj","RDT")).gts.-
155 f$cvtime(f$file_attributes("alloca.c","RDT")) then goto skip_alloca
157 $ 'CC 'CFLAGS /define="STACK_DIRECTION=(-1)" alloca.c
161 $! First build a couple of header files from the machine description
162 $! These are used by many of the source modules, so we build them now.
166 $ 'CC 'CFLAGS obstack.C
168 $! Generate insn-attr.h
169 $ call generate insn-attr.h
170 $ call generate insn-flags.h
171 $ call generate insn-codes.h
172 $ call generate insn-config.h
174 $call compile independent.opt "rtl,obstack,insn-attrtab"
176 $ call generate insn-attrtab.c "rtlanal,"
178 $ 'CC 'CFLAGS insn-attrtab.c
183 $open cfile$ compilers.list
184 $cloop:read cfile$ compilername/end=cdone
185 $! language specific modules
187 $if (DO_ALL + DO_'compilername').eq.0 then goto cloop
188 $if DO_LINK.eq.0 then call compile 'compilername'-objs.opt "obstack"
190 $! CAUTION: If you want to link gcc-cc1* to the sharable image library
191 $! VAXCRTL, see the notes in gcc.texinfo (or INSTALL) first.
194 $ link 'LDFLAGS' /exe=gcc-'compilername' version.opt/opt, -
195 'compilername'-objs.opt/opt, independent.opt/opt, -
208 $! Various DCL subroutines follow...
210 $! This routine takes parameter p1 to be a linker options file with a list
211 $! of object files that are needed. It extracts the names, and compiles
212 $! each source module, one by one. File names that begin with an
213 $! "INSN-" are assumed to be generated by a GEN*.C program.
215 $! Parameter P2 is a list of files which will appear in the options file
216 $! that should not be compiled. This allows us to handle special cases.
220 $on error then goto c_err
221 $on control_y then goto c_err
223 $loop: read ifile$ line/end=c_done
227 $flnm=f$element(i,",",line)
229 $if flnm.eqs."" then goto loop
230 $if flnm.eqs."," then goto loop
231 $if f$locate(flnm,"''p2'").nes.f$length("''p2'") then goto loop1
233 $if f$locate("-parse",flnm).nes.f$length(flnm)
235 $ if (f$search("''flnm'.C") .eqs. "") then goto yes_bison
236 $ if (f$cvtime(f$file_attributes("''flnm'.Y","RDT")).les. -
237 f$cvtime(f$file_attributes("''flnm'.C","RDT"))) -
241 $ 'BISON' /define /verbose 'flnm'.y
242 $ 'RENAME' 'flnm'_tab.c 'flnm'.c
243 $ 'RENAME' 'flnm'_tab.h 'flnm'.h
248 $if f$extract(0,5,flnm).eqs."insn-" then call generate 'flnm'.c
251 $ 'CC 'CFLAGS 'flnm'.c
257 $! In case of error or abort, go here (In order to close file).
259 $c_err: !'f$verify(0)
267 $! This subroutine generates the insn-* files. The first argument is the
268 $! name of the insn-* file to generate. The second argument contains a
269 $! list of any other object modules which must be linked to the gen*.c
272 $! If a previous version of insn-* exists, it is compared to the new one,
273 $! and if it has not changed, then the new one is discarded. This is
274 $! done so that make like programs do not get thrown off.
278 $if f$extract(0,5,p1).nes."INSN-"
280 $ write sys$error "Unknown file passed to generate."
283 $root1=f$parse(f$extract(5,255,p1),,,"NAME")
285 $ 'CC 'CFLAGS GEN'root1'.C
286 $ link 'LDFLAGS' GEN'root1',rtl,obstack,'p2' -
291 $ assign/user 'p1' sys$output:
292 $ mcr sys$disk:[]GEN'root1' md