2 $ ! Set up to compile GCC on 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-vms.h []config.h
14 $ echo "Linked `config.h' to `[.config]xm-vms.h'.
16 $ if f$search("tm.h") .nes. "" then delete tm.h.*
17 $ copy [.config]vms.h []tm.h
18 $ echo "Linked `tm.h' to `[.config]vms.h'.
20 $ if f$search("md.") .nes. "" then delete md..*
21 $ copy [.config]vax.md []md.
22 $ echo "Linked `md' to `[.config]vax.md'.
24 $ if f$search("aux-output.c") .nes. "" then delete aux-output.c.*
25 $ copy [.config]vax.c []aux-output.c
26 $ echo "Linked `aux-output.c' to `[.config]vax.c'.
30 $! Create the file version.opt, which helps identify the executable.
32 $search version.c version_string,"="/match=and/output=t.tmp
37 $ijk=f$locate("""",line)+1
38 $line=f$extract(ijk,f$length(line)-ijk,line)
39 $ijk=f$locate("""",line)
40 $line=f$extract(0,ijk,line)
41 $ijk=f$locate("\n",line)
42 $line=f$extract(0,ijk,line)
46 $elm=f$element(i," ",line)
47 $if elm.eqs."" then goto no_ident
48 $if (elm.les."9").and.(elm.ges."0") then goto write_ident
57 $open ifile$ version.opt/write
58 $write ifile$ "ident="+""""+elm+""""
60 $pur version.opt/nolog
63 $! create linker options files that lists all of the components for all
64 $! possible compilers. We do this by editing the file Makefile.in, and
65 $! generating the relevant files from it.
68 $echo "Now processing Makefile.in to generate linker option files."
69 $edit/tpu/nojournal/nosection/nodisplay/command=sys$input
70 PROCEDURE generate_option_file (TAG_NAME, outfile)
71 position (beginning_of (newbuffer));
72 recursive_fetch_tag (TAG_NAME);
74 ! Now fix up a few things in the output buffer
76 pat_replace (".o ",",");
77 pat_replace (".o",""); !appear at end of lines.
79 ! Remove trailing commas, if present.
81 position (beginning_of (newbuffer));
83 range1:=search_quietly("," & ((SPAN(" ") & LINE_END) | LINE_END), FORWARD, EXACT);
85 position (beginning_of (range1));
89 ! get rid of leading spaces on lines.
90 position (beginning_of (current_buffer)) ;
92 range1 := search_quietly ( LINE_BEGIN & " ", FORWARD, EXACT) ;
94 position (end_of (range1));
98 ! Now write the output file.
100 SET(OUTPUT_FILE, newbuffer, outfile);
101 write_file (newbuffer);
106 ! Looks up a tag, copies it to newbuffer, and then translates any $(...)
107 ! definitions that appear. The translation is put at the current point.
109 PROCEDURE recursive_fetch_tag (TAG_N);
112 ! substitute any makefile symbols $(...)
114 position (beginning_of (current_buffer)) ;
116 range1 := search_quietly ("$(" &
117 SPAN("abcdefghijklmnopqrstuvwxyz_ABCDEFGHIJKLMNOPQRSTUVWXYZ#~0123456789") & ")", FORWARD, EXACT) ;
119 position (beginning_of (range1));
121 mark_1 := MARK (NONE);
122 position (end_of (range1));
124 mark_2 := MARK (NONE);
125 tag_range := CREATE_RANGE(MARK_1, MARK_2, NONE);
126 position (end_of (range1));
127 tag_string := STR (tag_range);
129 fetch_tag (LINE_BEGIN & tag_string & ((SPAN(" ") & "=") | "="));
130 position (beginning_of (current_buffer)) ;
135 ! Looks up the translation of a tag, and inserts it at the current location
138 PROCEDURE fetch_tag (TAG_N);
139 LOCAL mark1, mark2, mark3, range2;
140 mark3 := MARK(NONE) ;
141 position (beginning_of (mainbuffer)) ;
142 range2 := search_quietly (TAG_N, FORWARD, EXACT) ;
147 position (end_of (range2)) ;
149 mark1 := MARK(NONE) ;
150 position (beginning_of (range2)) ;
154 EXITIF CURRENT_CHARACTER <> "\" ;
161 mark2 := MARK(NONE) ;
162 range2 := CREATE_RANGE(mark1, mark2, NONE) ;
164 if (length(range2) = 0) then return; endif;
168 PROCEDURE pat_replace (
172 position (beginning_of (current_buffer)) ;
174 range2 := search_quietly (oldstring, FORWARD, EXACT) ;
176 position (beginning_of (range2)) ;
178 copy_text (newstring) ;
182 ! this is the start of the main procedure
183 filename := GET_INFO (COMMAND_LINE, 'file_name') ;
184 mainbuffer := CREATE_BUFFER ("Makefile.in", "Makefile.in") ;
185 newbuffer := CREATE_BUFFER("outfile");
186 compiler_list := CREATE_BUFFER("compilers");
188 ! Add to this list, as required. The file "Makefile.in" is searched for a
189 ! tag that looks like "LINE_BEGIN + 'tag + (optional space) + "="". The
190 ! contents are assumed to be a list of object files, and from this list a
191 ! VMS linker options file is generated.
193 position (beginning_of (compiler_list));
194 recursive_fetch_tag(LINE_BEGIN & "COMPILERS" & ((SPAN(" ") & "=") | "="));
195 position (beginning_of (compiler_list));
196 LOOP ! kill leading spaces.
197 exitif current_character <> " ";
200 position (beginning_of (compiler_list));
201 LOOP ! remove any double spaces.
202 range1 := search_quietly (" ", FORWARD, EXACT) ; EXITIF range1 = 0 ;
203 position (beginning_of (range1)) ;
206 position (end_of (compiler_list));
208 LOOP ! kill trailing spaces.
209 exitif current_character <> " ";
213 position (beginning_of (compiler_list));
215 range1 := search_quietly (" ", FORWARD, EXACT) ;
217 position (beginning_of (range1)) ;
222 ! We now have a list of supported compilers. Now write it, and use it.
224 SET(OUTPUT_FILE, compiler_list, "compilers.list");
225 write_file (compiler_list);
226 generate_option_file(LINE_BEGIN & "OBJS" & ((SPAN(" ") & "=") | "="),"independent.opt");
227 generate_option_file(LINE_BEGIN & "LIB2FUNCS" & ((SPAN(" ") & "=") | "="),"libgcc2.list");
229 ! Now change OBJS in the Makefile, so each language specific options file
230 ! does not pick up all of the language independent files.
232 position (beginning_of (mainbuffer));
233 range1 := search_quietly (LINE_BEGIN & "OBJS" & ((SPAN(" ") & "=") | "="), FORWARD, EXACT) ;
234 position (end_of (range1));
236 position (beginning_of (compiler_list));
239 exitif cmark = end_of(compiler_list);
240 message(current_line);
241 generate_option_file(LINE_BEGIN & Current_line & ((SPAN(" ") & ":") | ":"),
242 current_line+"-objs.opt");
249 $! Remove excessive versions of the options file...
252 $purge/nolog compilers.list
256 $ if f$search("config.status") .nes. "" then delete config.status.*
257 $ open/write file config.status
258 $ write file "Links are now set up for use with a vax running VMS."