2 $ ! Set up to compile GCC on VAX/VMS
4 $! Set the def dir to proper place for use in batch. Works for interactive too.
5 $flnm = f$enviroment("PROCEDURE") ! get current procedure name
6 $set default 'f$parse(flnm,,,"DEVICE")''f$parse(flnm,,,"DIRECTORY")'
8 $set symbol/scope=(nolocal,noglobal)
10 $ echo = "write sys$output"
12 $ if f$search("config.h") .nes. "" then delete config.h.*
13 $ copy [.config]xm-vax-vms.h []config.h
14 $ echo "Linked `config.h' to `[.config]xm-vax-vms.h'.
16 $ if f$search("tconfig.h") .nes. "" then delete tconfig.h.*
19 /* tconfig.h == config.h :: target and host configurations are the same */
22 $ echo "Created `tconfig.h'.
24 $ if f$search("hconfig.h") .nes. "" then delete hconfig.h.*
27 /* hconfig.h == config.h :: target and host configurations are the same */
30 $ echo "Created `hconfig.h'.
32 $ if f$search("tm.h") .nes. "" then delete tm.h.*
33 $ copy [.config]vax-vms.h []tm.h
34 $ echo "Linked `tm.h' to `[.config]vax-vms.h'.
36 $ if f$search("md.") .nes. "" then delete md..*
37 $ copy [.config]vax.md []md.
38 $ echo "Linked `md' to `[.config]vax.md'.
40 $ if f$search("aux-output.c") .nes. "" then delete aux-output.c.*
41 $ copy [.config]vax.c []aux-output.c
42 $ echo "Linked `aux-output.c' to `[.config]vax.c'.
46 $! Create the file version.opt, which helps identify the executable.
48 $search version.c version_string,"="/match=and/output=t.tmp
53 $ijk=f$locate("""",line)+1
54 $line=f$extract(ijk,f$length(line)-ijk,line)
55 $ijk=f$locate("""",line)
56 $line=f$extract(0,ijk,line)
57 $ijk=f$locate("\n",line)
58 $line=f$extract(0,ijk,line)
62 $elm=f$element(i," ",line)
63 $if elm.eqs."" then goto no_ident
64 $if (elm.les."9").and.(elm.ges."0") then goto write_ident
73 $open ifile$ version.opt/write
74 $write ifile$ "ident="+""""+elm+""""
79 $! create linker options files that lists all of the components for all
80 $! possible compilers. We do this by editing the file Makefile.in, and
81 $! generating the relevant files from it.
84 $! Make a copy of the makefile if the sources are on a disk that is NFS
85 $! mounted on a unix machine.
86 $if f$search("Makefile.in").eqs."" .and. f$search("$M$akefile.in").nes."" -
87 then copy $M$akefile.in Makefile.in
90 $echo "Now processing Makefile.in to generate linker option files."
91 $edit/tpu/nojournal/nosection/nodisplay/command=sys$input
92 PROCEDURE generate_option_file (TAG_NAME, outfile)
93 position (beginning_of (newbuffer));
94 recursive_fetch_tag (TAG_NAME);
96 ! Now fix up a few things in the output buffer
98 pat_replace (".o ",",");
99 pat_replace (".o",""); !appear at end of lines.
101 ! Remove trailing commas, if present.
103 position (beginning_of (newbuffer));
105 range1 := search_quietly("," & ((SPAN(" ") & LINE_END) | LINE_END),
108 position (beginning_of (range1));
112 ! get rid of leading spaces on lines.
113 position (beginning_of (current_buffer)) ;
115 range1 := search_quietly ( LINE_BEGIN & " ", FORWARD, EXACT) ;
117 position (end_of (range1));
121 ! Now write the output file.
123 SET(OUTPUT_FILE, newbuffer, outfile);
124 write_file (newbuffer);
129 ! Looks up a tag, copies it to newbuffer, and then translates any $(...)
130 ! definitions that appear. The translation is put at the current point.
132 PROCEDURE recursive_fetch_tag (TAG_N);
135 ! substitute any makefile symbols $(...)
137 position (beginning_of (current_buffer)) ;
139 range1 := search_quietly ("$(" &
140 SPAN("abcdefghijklmnopqrstuvwxyz_ABCDEFGHIJKLMNOPQRSTUVWXYZ#~0123456789")
141 & ")", FORWARD, EXACT) ;
143 position (beginning_of (range1));
145 mark_1 := MARK (NONE);
146 position (end_of (range1));
148 mark_2 := MARK (NONE);
149 tag_range := CREATE_RANGE(MARK_1, MARK_2, NONE);
150 position (end_of (range1));
151 tag_string := STR (tag_range);
153 fetch_tag (LINE_BEGIN & tag_string & ((SPAN(" ") & "=") | "="));
154 position (beginning_of (current_buffer)) ;
159 ! Looks up the translation of a tag, and inserts it at the current location
162 PROCEDURE fetch_tag (TAG_N);
163 LOCAL mark1, mark2, mark3, range2;
164 mark3 := MARK(NONE) ;
165 position (beginning_of (mainbuffer)) ;
166 range2 := search_quietly (TAG_N, FORWARD, EXACT) ;
171 position (end_of (range2)) ;
173 mark1 := MARK(NONE) ;
174 position (beginning_of (range2)) ;
178 EXITIF CURRENT_CHARACTER <> "\" ;
185 mark2 := MARK(NONE) ;
186 range2 := CREATE_RANGE(mark1, mark2, NONE) ;
188 if (length(range2) = 0) then return; endif;
192 PROCEDURE pat_replace (
196 position (beginning_of (current_buffer)) ;
198 range2 := search_quietly (oldstring, FORWARD, EXACT) ;
200 position (beginning_of (range2)) ;
202 copy_text (newstring) ;
206 ! this is the start of the main procedure
207 filename := GET_INFO (COMMAND_LINE, 'file_name') ;
208 mainbuffer := CREATE_BUFFER ("Makefile.in", "Makefile.in") ;
209 newbuffer := CREATE_BUFFER("outfile");
210 compiler_list := CREATE_BUFFER("compilers");
212 ! Add to this list, as required. The file "Makefile.in" is searched for a
213 ! tag that looks like "LINE_BEGIN + 'tag + (optional space) + "="". The
214 ! contents are assumed to be a list of object files, and from this list a
215 ! VMS linker options file is generated.
217 position (beginning_of (compiler_list));
218 recursive_fetch_tag(LINE_BEGIN & "COMPILERS" & ((SPAN(" ") & "=") | "="));
219 position (beginning_of (compiler_list));
220 LOOP ! kill leading spaces.
221 exitif current_character <> " ";
224 position (beginning_of (compiler_list));
225 LOOP ! remove any double spaces.
226 range1 := search_quietly (" ", FORWARD, EXACT) ; EXITIF range1 = 0 ;
227 position (beginning_of (range1)) ;
230 position (end_of (compiler_list));
232 LOOP ! kill trailing spaces.
233 exitif current_character <> " ";
237 position (beginning_of (compiler_list));
239 range1 := search_quietly (" ", FORWARD, EXACT) ;
241 position (beginning_of (range1)) ;
246 ! We now have a list of supported compilers. Now write it, and use it.
248 SET(OUTPUT_FILE, compiler_list, "compilers.list");
249 write_file (compiler_list);
250 generate_option_file(LINE_BEGIN & "OBJS" & ((SPAN(" ") & "=") | "="),
252 generate_option_file(LINE_BEGIN & "LIB2FUNCS" & ((SPAN(" ") & "=") | "="),
255 ! Now change OBJS in the Makefile, so each language specific options file
256 ! does not pick up all of the language independent files.
258 position (beginning_of (mainbuffer));
259 range1 := search_quietly (LINE_BEGIN & "OBJS" & ((SPAN(" ") & "=") | "="),
261 position (end_of (range1));
263 position (beginning_of (compiler_list));
266 exitif cmark = end_of(compiler_list);
267 message(current_line);
268 generate_option_file(LINE_BEGIN & Current_line & ((SPAN(" ") & ":") | ":"),
269 current_line+"-objs.opt");
276 $! Remove excessive versions of the option files...
279 $ purge compilers.list,libgcc2.list
283 $ if f$search("config.status") .nes. "" then delete config.status.*
284 $ open/write file config.status
285 $ write file "Links are now set up for use with a vax running VMS."