1$! make-l2.com -- VMS build procedure for libgcc2.
2$
3$! Change working directory to the location of this command procedure.
4$ flnm = f$enviroment("PROCEDURE")	!get current procedure name
5$ set default 'f$parse(flnm,,,"DEVICE")''f$parse(flnm,,,"DIRECTORY")'
6$!
7$! Command file to build libgcc2.olb.  You should only run this once you
8$! have the current compiler installed, otherwise some of the builtins will
9$! not be recognized.  Once you have built libgcc2.olb, you can merge this
10$! with gnu_cc:[000000]gcclib.olb
11$!
12$! All of the C source code is assumed to be in libgcc2.c, and a list of the
13$! modules that we need from there is in libgcc2.list (which is generated
14$! when vmsconfig.com is run).  The C++ source is found in the [.cp.inc]
15$! directory and managed via libgcc2-cxx.list.
16$!
17$ if f$search("gcc-cc1.exe").eqs.""
18$ then
19$    gcc_cc1:=$gnu_cc:[000000]gcc-cc1
20$    if f$extract(0,1,f$trnlnm("GNU_CC_VERSION")).eqs."1" then goto nocompile
21$ else
22$    gcc_cc1:=$sys$disk:[]gcc-cc1
23$ endif
24$!
25$ if f$search("gcc-cpp.exe").eqs.""
26$ then
27$    gcc_cpp:=$gnu_cc:[000000]gcc-cpp
28$    if f$extract(0,1,f$trnlnm("GNU_CC_VERSION")).eqs."1" then goto nocompile
29$    Version:='f$trnlnm("GNU_CC_VERSION")'
30$ else
31$    gcc_cpp:=$sys$disk:[]gcc-cpp
32$    open ifile$ version.opt
33$    read ifile$ line
34$    close ifile$
35$    Version=line - "ident=""" - """
36$ endif
37$!
38$ if f$search("gcc-cc1plus.exe").eqs.""
39$ then	gcc_cxx = "$gnu_cc:[000000]gcc-cc1plus"
40$ else	gcc_cxx = "$sys$disk:[]gcc-cc1plus"
41$ endif
42$!
43$gcc_as:=$gnu_cc:[000000]gcc-as
44$cpp_file:=sys$scratch:gcc_'f$getjpi(0,"pid")'.cpp
45$ s_file:=sys$scratch:gcc_'f$getjpi(0,"pid")'.s
46$!
47$set symbol/scope=(nolocal,noglobal)
48$!
49$lib/create libgcc2.olb
50$on error then goto c_err
51$on control_y then goto c_err
52$
53$if f$trnlnm("IFILE$").nes."" then  close/noLog ifile$
54$open ifile$ libgcc2.list
55$loop:
56$!
57$read ifile$ line/end=c_done
58$i=0
59$loop1:
60$flnm=f$element(i," ",line)
61$i=i+1
62$if flnm.eqs."" then goto loop
63$if flnm.eqs." " then goto loop
64$!
65$flnm = "L"+flnm
66$if flnm.eqs."L_exit" then goto loop1
67$write sys$output "$ gcc/debug/define=""''flnm'"" LIBGCC2.C"
68$!
69$objname = flnm
70$if flnm.eqs."L_builtin_New" then objname = "L_builtin_nnew"
71$!
72$! We do this by hand, since the VMS compiler driver does not have a way
73$! of specifying an alternate location for the compiler executables.
74$!
75$ if arch .eqs. "alpha"
76$ then
77$   gcc_cpp "-D__IEEE_FLOAT" "-I[]" "-I[.config]" "-I[.ginclude]" "-D''flnm'"  libgcc2.c 'cpp_file'
78$   gcc_cc1 'cpp_file' -dumpbase 'objname' -
79	-quiet -mgas "-O1" -mfloat-ieee -o 's_file'
80$ else
81$   gcc_cpp "-I[]" "-I[.config]" "-I[.ginclude]" "-D''flnm'"  libgcc2.c 'cpp_file'
82$   gcc_cc1 'cpp_file' -dumpbase 'objname' -
83	-quiet -mgnu -g "-O1" -mvaxc-alignment   -o 's_file'
84$ endif
85$ delete/nolog 'cpp_file';
86$   gcc_as 's_file'  -o 'objname'.OBJ
87$ if arch .eqs. "vax"
88$ then
89$! Assemble again, preserving lowercase symbol names this time.
90$   gcc_as -h3 's_file'  -o 'objname'-c.OBJ
91$   library libgcc2.olb 'objname'.obj,'objname'-c.obj
92$   delete/nolog 'objname'.obj;,'objname'-c.obj;
93$ else
94$   library libgcc2.olb 'objname'.obj
95$   delete/nolog 'objname'.obj;
96$ endif
97$ delete/nolog 's_file';
98$!
99$!
100$goto loop1
101$!
102$! In case of error or abort, go here (In order to close file).
103$!
104$c_err:	!'f$verify(0)
105$close ifile$
106$ exit %x2c
107$!
108$c_done:
109$close ifile$
110$
111$
112$ EXIT
113$	!gcc-2.8.0: C++ libgcc2 code disabled since it's not adequately tested
114$
115$!
116$ p1 = p1+" "+p2+" "+p3+" "+p4+" "+p5+" "+p6+" "+p7+" "+p8
117$ p1 = " " + f$edit(p1,"COMPRESS,TRIM,UPCASE") + " "
118$! (note: substring locations can only be equal when neither string is present)
119$ if f$locate(" CC1PLUS ",p1).eq.f$locate(" CXX ",p1) then  goto cxx_done
120$ if f$search("libgcc2-cxx.list").eqs."" then  goto cxx_done
121$!
122$ open/read ifile$ libgcc2-cxx.list
123$cxx_line_loop:
124$ read ifile$ line/end=cxx_done
125$ i = 0
126$cxx_file_loop:
127$ flnm = f$element(i,",",line)
128$ i = i + 1
129$ if flnm.eqs."" .or. flnm.eqs."," then goto cxx_line_loop
130$ write sys$output "$ gcc/plus/debug ''flnm'.cc"
131$ objname = flnm
132$!
133$ gcc_cpp -+ "-I[]" "-I[.ginclude]" "-I[.cp.inc]" [.cp]'flnm'.cc 'cpp_file'
134$ gcc_cxx 'cpp_file' -dumpbase 'objname' -fexceptions -
135	-quiet -mgnu -g "-O1" -mvaxc-alignment	 -o 's_file'
136$ delete/nolog 'cpp_file';
137$ gcc_as "-vGNU CC  V''Version'" 's_file'  -o 'objname'.OBJ
138$! Assemble again, preserving lowercase symbol names this time.
139$ gcc_as "-vGNU CC  V''Version'" -h3 's_file'  -o 'objname'-c.OBJ
140$ delete/nolog 's_file';
141$
142$ library libgcc2.olb 'objname'.obj,'objname'-c.obj
143$ delete/nolog 'objname'.obj;,'objname'-c.obj;
144$!
145$ goto cxx_file_loop
146$!
147$cxx_done:
148$ close ifile$
149$ exit
150