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("tm.h") .nes. "" then delete tm.h.*
25 $ copy [.config]vax-vms.h []tm.h
26 $ echo "Linked `tm.h' to `[.config]vax-vms.h'.
28 $ if f$search("md.") .nes. "" then delete md..*
29 $ copy [.config]vax.md []md.
30 $ echo "Linked `md' to `[.config]vax.md'.
32 $ if f$search("aux-output.c") .nes. "" then delete aux-output.c.*
33 $ copy [.config]vax.c []aux-output.c
34 $ echo "Linked `aux-output.c' to `[.config]vax.c'.
38 $! Create the file version.opt, which helps identify the executable.
40 $search version.c version_string,"="/match=and/output=t.tmp
45 $ijk=f$locate("""",line)+1
46 $line=f$extract(ijk,f$length(line)-ijk,line)
47 $ijk=f$locate("""",line)
48 $line=f$extract(0,ijk,line)
49 $ijk=f$locate("\n",line)
50 $line=f$extract(0,ijk,line)
54 $elm=f$element(i," ",line)
55 $if elm.eqs."" then goto no_ident
56 $if (elm.les."9").and.(elm.ges."0") then goto write_ident
65 $open ifile$ version.opt/write
66 $write ifile$ "ident="+""""+elm+""""
71 $! create linker options files that lists all of the components for all
72 $! possible compilers. We do this by editing the file Makefile.in, and
73 $! generating the relevant files from it.
76 $! Make a copy of the makefile if the sources are on a disk that is NFS
77 $! mounted on a unix machine.
78 $if f$search("Makefile.in").eqs."" .and. f$search("$M$akefile.in").nes."" -
79 then copy $M$akefile.in Makefile.in
82 $echo "Now processing Makefile.in to generate linker option files."
83 $edit/tpu/nojournal/nosection/nodisplay/command=sys$input
84 PROCEDURE generate_option_file (TAG_NAME, outfile)
85 position (beginning_of (newbuffer));
86 recursive_fetch_tag (TAG_NAME);
88 ! Now fix up a few things in the output buffer
90 pat_replace (".o ",",");
91 pat_replace (".o",""); !appear at end of lines.
93 ! Remove trailing commas, if present.
95 position (beginning_of (newbuffer));
97 range1 := search_quietly("," & ((SPAN(" ") & LINE_END) | LINE_END),
100 position (beginning_of (range1));
104 ! get rid of leading spaces on lines.
105 position (beginning_of (current_buffer)) ;
107 range1 := search_quietly ( LINE_BEGIN & " ", FORWARD, EXACT) ;
109 position (end_of (range1));
113 ! Now write the output file.
115 SET(OUTPUT_FILE, newbuffer, outfile);
116 write_file (newbuffer);
121 ! Looks up a tag, copies it to newbuffer, and then translates any $(...)
122 ! definitions that appear. The translation is put at the current point.
124 PROCEDURE recursive_fetch_tag (TAG_N);
127 ! substitute any makefile symbols $(...)
129 position (beginning_of (current_buffer)) ;
131 range1 := search_quietly ("$(" &
132 SPAN("abcdefghijklmnopqrstuvwxyz_ABCDEFGHIJKLMNOPQRSTUVWXYZ#~0123456789")
133 & ")", FORWARD, EXACT) ;
135 position (beginning_of (range1));
137 mark_1 := MARK (NONE);
138 position (end_of (range1));
140 mark_2 := MARK (NONE);
141 tag_range := CREATE_RANGE(MARK_1, MARK_2, NONE);
142 position (end_of (range1));
143 tag_string := STR (tag_range);
145 fetch_tag (LINE_BEGIN & tag_string & ((SPAN(" ") & "=") | "="));
146 position (beginning_of (current_buffer)) ;
151 ! Looks up the translation of a tag, and inserts it at the current location
154 PROCEDURE fetch_tag (TAG_N);
155 LOCAL mark1, mark2, mark3, range2;
156 mark3 := MARK(NONE) ;
157 position (beginning_of (mainbuffer)) ;
158 range2 := search_quietly (TAG_N, FORWARD, EXACT) ;
163 position (end_of (range2)) ;
165 mark1 := MARK(NONE) ;
166 position (beginning_of (range2)) ;
170 EXITIF CURRENT_CHARACTER <> "\" ;
177 mark2 := MARK(NONE) ;
178 range2 := CREATE_RANGE(mark1, mark2, NONE) ;
180 if (length(range2) = 0) then return; endif;
184 PROCEDURE pat_replace (
188 position (beginning_of (current_buffer)) ;
190 range2 := search_quietly (oldstring, FORWARD, EXACT) ;
192 position (beginning_of (range2)) ;
194 copy_text (newstring) ;
198 ! this is the start of the main procedure
199 filename := GET_INFO (COMMAND_LINE, 'file_name') ;
200 mainbuffer := CREATE_BUFFER ("Makefile.in", "Makefile.in") ;
201 newbuffer := CREATE_BUFFER("outfile");
202 compiler_list := CREATE_BUFFER("compilers");
204 ! Add to this list, as required. The file "Makefile.in" is searched for a
205 ! tag that looks like "LINE_BEGIN + 'tag + (optional space) + "="". The
206 ! contents are assumed to be a list of object files, and from this list a
207 ! VMS linker options file is generated.
209 position (beginning_of (compiler_list));
210 recursive_fetch_tag(LINE_BEGIN & "COMPILERS" & ((SPAN(" ") & "=") | "="));
211 position (beginning_of (compiler_list));
212 LOOP ! kill leading spaces.
213 exitif current_character <> " ";
216 position (beginning_of (compiler_list));
217 LOOP ! remove any double spaces.
218 range1 := search_quietly (" ", FORWARD, EXACT) ; EXITIF range1 = 0 ;
219 position (beginning_of (range1)) ;
222 position (end_of (compiler_list));
224 LOOP ! kill trailing spaces.
225 exitif current_character <> " ";
229 position (beginning_of (compiler_list));
231 range1 := search_quietly (" ", FORWARD, EXACT) ;
233 position (beginning_of (range1)) ;
238 ! We now have a list of supported compilers. Now write it, and use it.
240 SET(OUTPUT_FILE, compiler_list, "compilers.list");
241 write_file (compiler_list);
242 generate_option_file(LINE_BEGIN & "OBJS" & ((SPAN(" ") & "=") | "="),
244 generate_option_file(LINE_BEGIN & "LIB2FUNCS" & ((SPAN(" ") & "=") | "="),
247 ! Now change OBJS in the Makefile, so each language specific options file
248 ! does not pick up all of the language independent files.
250 position (beginning_of (mainbuffer));
251 range1 := search_quietly (LINE_BEGIN & "OBJS" & ((SPAN(" ") & "=") | "="),
253 position (end_of (range1));
255 position (beginning_of (compiler_list));
258 exitif cmark = end_of(compiler_list);
259 message(current_line);
260 generate_option_file(LINE_BEGIN & Current_line & ((SPAN(" ") & ":") | ":"),
261 current_line+"-objs.opt");
268 $! Remove excessive versions of the option files...
271 $ purge compilers.list,libgcc2.list
275 $ if f$search("config.status") .nes. "" then delete config.status.*
276 $ open/write file config.status
277 $ write file "Links are now set up for use with a vax running VMS."