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.vax]xm-vms.h []config.h
14 $ echo "Linked `config.h' to `[.config.vax]xm-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 :: host and target 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 $ edit/tpu/nojournal/nosection/nodisplay/command=sys$input -
35 [.config.vax]vms.h /output=[]tm.h
38 ! Copy file, changing lines of the form
41 ! #include "[.config.vax]*"
43 file := CREATE_BUFFER("file", GET_INFO(COMMAND_LINE, "file_name"));
44 targ := LINE_BEGIN & '#include' & SPAN(ASCII(32)+ASCII(9)) & '"vax/';
45 rang := CREATE_RANGE(BEGINNING_OF(file), END_OF(file));
47 incl := SEARCH_QUIETLY(targ, FORWARD, EXACT, rang);
49 POSITION(BEGINNING_OF(incl));
51 COPY_TEXT('#include "[.config.vax]');
52 rang := CREATE_RANGE(END_OF(incl), END_OF(file));
54 WRITE_FILE(file, GET_INFO(COMMAND_LINE, "output_file"));
57 $ echo "Generated `tm.h' from `[.config.vax]vms.h'.
59 $ if f$search("md.") .nes. "" then delete md..*
60 $ copy [.config.vax]vax.md []md.
61 $ echo "Linked `md' to `[.config.vax]vax.md'.
63 $ if f$search("aux-output.c") .nes. "" then delete aux-output.c.*
64 $ copy [.config.vax]vax.c []aux-output.c
65 $ echo "Linked `aux-output.c' to `[.config.vax]vax.c'.
69 $! Create the file version.opt, which helps identify the executable.
71 $search version.c version_string,"="/match=and/output=t.tmp
76 $ijk=f$locate("""",line)+1
77 $line=f$extract(ijk,f$length(line)-ijk,line)
78 $ijk=f$locate("""",line)
79 $line=f$extract(0,ijk,line)
80 $ijk=f$locate("\n",line)
81 $line=f$extract(0,ijk,line)
85 $elm=f$element(i," ",line)
86 $if elm.eqs."" then goto no_ident
87 $if (elm.les."9").and.(elm.ges."0") then goto write_ident
96 $open ifile$ version.opt/write
97 $write ifile$ "ident="+""""+elm+""""
102 $! create linker options files that lists all of the components for all
103 $! possible compilers. We do this by editing the file Makefile.in, and
104 $! generating the relevant files from it.
107 $! Make a copy of the makefile if the sources are on a disk that is NFS
108 $! mounted on a unix machine.
109 $if f$search("Makefile.in").eqs."" .and. f$search("$M$akefile.in").nes."" -
110 then copy $M$akefile.in Makefile.in
113 $echo "Now processing Makefile.in to generate linker option files."
114 $edit/tpu/nojournal/nosection/nodisplay/command=sys$input
115 PROCEDURE generate_option_file (TAG_NAME, outfile)
116 position (beginning_of (newbuffer));
117 recursive_fetch_tag (TAG_NAME);
119 ! Now fix up a few things in the output buffer
121 pat_replace ("bytecode "," ");
122 pat_replace (".o ",",");
123 pat_replace (".o",""); !appear at end of lines.
125 ! Remove trailing commas, if present.
127 position (beginning_of (newbuffer));
129 range1 := search_quietly("," & ((SPAN(" ") & LINE_END) | LINE_END),
132 position (beginning_of (range1));
136 ! get rid of leading spaces on lines.
137 position (beginning_of (current_buffer)) ;
139 range1 := search_quietly ( LINE_BEGIN & " ", FORWARD, EXACT) ;
141 position (end_of (range1));
145 ! Now write the output file.
147 SET(OUTPUT_FILE, newbuffer, outfile);
148 write_file (newbuffer);
153 ! Looks up a tag, copies it to newbuffer, and then translates any $(...)
154 ! definitions that appear. The translation is put at the current point.
156 PROCEDURE recursive_fetch_tag (TAG_N);
159 ! substitute any makefile symbols $(...)
161 position (beginning_of (current_buffer)) ;
163 range1 := search_quietly ("$(" &
164 SPAN("abcdefghijklmnopqrstuvwxyz_ABCDEFGHIJKLMNOPQRSTUVWXYZ#~0123456789")
165 & ")", FORWARD, EXACT) ;
167 position (beginning_of (range1));
169 mark_1 := MARK (NONE);
170 position (end_of (range1));
172 mark_2 := MARK (NONE);
173 tag_range := CREATE_RANGE(MARK_1, MARK_2, NONE);
174 position (end_of (range1));
175 tag_string := STR (tag_range);
177 fetch_tag (LINE_BEGIN & tag_string & ((SPAN(" ") & "=") | "="));
178 position (beginning_of (current_buffer)) ;
183 ! Looks up the translation of a tag, and inserts it at the current location
186 PROCEDURE fetch_tag (TAG_N);
187 LOCAL mark1, mark2, mark3, range2;
188 mark3 := MARK(NONE) ;
189 position (beginning_of (mainbuffer)) ;
190 range2 := search_quietly (TAG_N, FORWARD, EXACT) ;
195 position (end_of (range2)) ;
197 mark1 := MARK(NONE) ;
198 position (beginning_of (range2)) ;
202 EXITIF CURRENT_CHARACTER <> "\" ;
209 mark2 := MARK(NONE) ;
210 range2 := CREATE_RANGE(mark1, mark2, NONE) ;
212 if (length(range2) = 0) then return; endif;
216 PROCEDURE pat_replace (
220 position (beginning_of (current_buffer)) ;
222 range2 := search_quietly (oldstring, FORWARD, EXACT) ;
224 position (beginning_of (range2)) ;
226 copy_text (newstring) ;
230 ! this is the start of the main procedure
231 filename := GET_INFO (COMMAND_LINE, 'file_name') ;
232 mainbuffer := CREATE_BUFFER ("Makefile.in", "Makefile.in") ;
233 newbuffer := CREATE_BUFFER("outfile");
234 compiler_list := CREATE_BUFFER("compilers");
236 ! Add to this list, as required. The file "Makefile.in" is searched for a
237 ! tag that looks like "LINE_BEGIN + 'tag + (optional space) + "="". The
238 ! contents are assumed to be a list of object files, and from this list a
239 ! VMS linker options file is generated.
241 position (beginning_of (compiler_list));
242 recursive_fetch_tag(LINE_BEGIN & "COMPILERS" & ((SPAN(" ") & "=") | "="));
243 position (beginning_of (compiler_list));
244 LOOP ! kill leading spaces.
245 exitif current_character <> " ";
248 position (beginning_of (compiler_list));
249 LOOP ! remove any double spaces.
250 range1 := search_quietly (" ", FORWARD, EXACT) ; EXITIF range1 = 0 ;
251 position (beginning_of (range1)) ;
254 position (end_of (compiler_list));
256 LOOP ! kill trailing spaces.
257 exitif current_character <> " ";
261 position (beginning_of (compiler_list));
263 range1 := search_quietly (" ", FORWARD, EXACT) ;
265 position (beginning_of (range1)) ;
270 ! We now have a list of supported compilers. Now write it, and use it.
272 SET(OUTPUT_FILE, compiler_list, "compilers.list");
273 write_file (compiler_list);
274 generate_option_file(LINE_BEGIN & "OBJS" & ((SPAN(" ") & "=") | "="),
276 generate_option_file(LINE_BEGIN & "LIB2FUNCS" & ((SPAN(" ") & "=") | "="),
278 generate_option_file(LINE_BEGIN & "BC_ALL" & ((SPAN(" ") & "=") | "="),
280 generate_option_file(LINE_BEGIN & "BI_OBJ" & ((SPAN(" ") & "=") | "="),
283 ! Now change OBJS in the Makefile, so each language specific options file
284 ! does not pick up all of the language independent files.
286 position (beginning_of (mainbuffer));
287 range1 := search_quietly (LINE_BEGIN & "OBJS" & ((SPAN(" ") & "=") | "="),
289 position (end_of (range1));
291 position (beginning_of (compiler_list));
294 exitif cmark = end_of(compiler_list);
295 message(current_line);
296 generate_option_file(LINE_BEGIN & Current_line & ((SPAN(" ") & ":") | ":"),
297 current_line+"-objs.opt");
304 $! Remove excessive versions of the option files...
307 $ purge compilers.list,libgcc2.list
311 $ if f$search("config.status") .nes. "" then delete config.status.*
312 $ open/write file config.status
313 $ write file "Links are now set up for use with a vax running VMS."