OSDN Git Service

*** empty log message ***
[pf3gnuchains/gcc-fork.git] / gcc / vmsconfig.com
1 $ !
2 $ !     Set up to compile GCC on VMS
3 $ !
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")'
7 $ !
8 $set symbol/scope=(nolocal,noglobal)
9 $ !
10 $ echo = "write sys$output"
11 $ !
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'.
15 $ !
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'.
19 $ !
20 $ if f$search("md.") .nes. "" then delete md..*
21 $ copy [.config]vax.md []md.
22 $ echo "Linked `md' to `[.config]vax.md'.
23 $ !
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'.
27 $ !
28 $!
29 $!
30 $! Create the file version.opt, which helps identify the executable.
31 $!
32 $search version.c version_string,"="/match=and/output=t.tmp
33 $open ifile$ t.tmp
34 $read ifile$ line
35 $close ifile$
36 $delete/nolog 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)
43 $!
44 $i=0
45 $loop:
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
49 $i=i+1
50 $goto loop
51 $!
52 $no_ident:
53 $elm="?.??"
54 $!
55 $!
56 $write_ident:
57 $open ifile$ version.opt/write
58 $write ifile$ "ident="+""""+elm+""""
59 $close ifile$
60 $pur version.opt/nolog
61 $!
62 $!
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.
66 $!
67 $!
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);
73 !
74 ! Now fix up a few things in the output buffer
75 !
76         pat_replace (".o ",",");
77         pat_replace (".o","");  !appear at end of lines.
78 !
79 ! Remove trailing commas, if present.
80 !
81         position (beginning_of (newbuffer));
82         LOOP
83           range1:=search_quietly("," & ((SPAN(" ") & LINE_END) | LINE_END), FORWARD, EXACT);
84           exitif range1 = 0;
85           position (beginning_of (range1));
86           erase(range1);
87           split_line;           
88           ENDLOOP;
89 ! get rid of leading spaces on lines.
90         position (beginning_of (current_buffer)) ;
91         LOOP
92           range1 := search_quietly ( LINE_BEGIN & " ", FORWARD, EXACT) ;
93           EXITIF range1 = 0;
94           position (end_of (range1));
95           erase_character(1);
96         ENDLOOP;       
97 !
98 ! Now write the output file.
99 !
100         SET(OUTPUT_FILE, newbuffer, outfile);
101       write_file (newbuffer);
102       erase (newbuffer);
103    ENDPROCEDURE;
104
105 !
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.
108 !
109    PROCEDURE recursive_fetch_tag (TAG_N);
110    fetch_tag (TAG_N);
111 !
112 ! substitute any  makefile symbols $(...)
113 !
114         position (beginning_of (current_buffer)) ;
115         LOOP
116           range1 := search_quietly ("$(" &  
117              SPAN("abcdefghijklmnopqrstuvwxyz_ABCDEFGHIJKLMNOPQRSTUVWXYZ#~0123456789") & ")", FORWARD, EXACT) ;
118           EXITIF range1 = 0;
119           position (beginning_of (range1));
120           move_horizontal(2);
121           mark_1 := MARK (NONE);
122           position (end_of (range1));
123           move_horizontal(-1);
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);
128           erase (range1);
129           fetch_tag (LINE_BEGIN & tag_string & ((SPAN(" ") & "=") | "="));
130           position (beginning_of (current_buffer)) ;
131         ENDLOOP;       
132    ENDPROCEDURE;
133
134 !
135 ! Looks up the translation of a tag, and inserts it at the current location
136 ! in the buffer
137 !
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) ;
143       IF (range2 = 0) then 
144         position (mark3);
145         return;
146         endif;
147       position (end_of (range2)) ;
148       MOVE_HORIZONTAL(1);
149       mark1 := MARK(NONE) ;
150       position (beginning_of (range2)) ;
151       MOVE_VERTICAL(1);
152       MOVE_HORIZONTAL(-2);
153       LOOP
154         EXITIF CURRENT_CHARACTER <> "\" ;
155         ERASE_CHARACTER(1);
156         MOVE_HORIZONTAL(1);
157         MOVE_VERTICAL(1);
158         MOVE_HORIZONTAL(-2);
159         ENDLOOP;
160       MOVE_HORIZONTAL(1);
161       mark2 := MARK(NONE) ;
162       range2 := CREATE_RANGE(mark1, mark2, NONE) ;
163       position (mark3);
164       if (length(range2) = 0) then return; endif;
165       copy_text(range2);
166    ENDPROCEDURE;
167
168    PROCEDURE pat_replace (
169       oldstring, !
170       newstring)  !
171       LOCAL range2;
172       position (beginning_of (current_buffer)) ;
173       LOOP
174          range2 := search_quietly (oldstring, FORWARD, EXACT) ;
175          EXITIF range2 = 0 ;
176          position (beginning_of (range2)) ;
177          erase (range2) ;
178          copy_text (newstring) ;
179          ENDLOOP ;
180    ENDPROCEDURE ;
181
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");
187 !
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.
192 !
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 <> " ";
198         erase_character(1);
199         ENDLOOP;
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)) ;
204          erase_character(1);
205          ENDLOOP ;
206    position (end_of (compiler_list));
207    move_horizontal(-1);
208    LOOP ! kill trailing spaces.
209         exitif current_character <> " ";
210         erase_character(1);
211         move_horizontal(-1);
212         ENDLOOP;
213    position (beginning_of (compiler_list));
214       LOOP
215          range1 := search_quietly (" ", FORWARD, EXACT) ;
216          EXITIF range1 = 0 ;
217          position (beginning_of (range1)) ;
218          erase (range1) ;
219          split_line;
220          ENDLOOP ;
221 !
222 ! We now have a list of supported compilers.  Now write it, and use it.
223 !
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");
228 !
229 ! Now change OBJS in the Makefile, so each language specific options file 
230 ! does not pick up all of the language independent files.
231 !
232    position (beginning_of (mainbuffer));
233    range1 := search_quietly (LINE_BEGIN & "OBJS" & ((SPAN(" ") & "=") | "="), FORWARD, EXACT) ;
234    position (end_of (range1));
235    split_line;
236    position (beginning_of (compiler_list));
237    LOOP
238      cmark := mark(NONE);
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");
243      position (cmark);
244      move_vertical(1);
245    ENDLOOP ;
246    quit ;
247 $ echo ""
248 $!
249 $! Remove excessive versions of the options file...
250 $!
251 $purge/nolog *.opt
252 $purge/nolog compilers.list
253 $!
254 $!
255 $!
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."
259 $ close file
260 $ type config.status
261 $ echo ""