OSDN Git Service

Rename vms to vax-vms; split long lines.
[pf3gnuchains/gcc-fork.git] / gcc / vmsconfig.com
1 $ !
2 $ !     Set up to compile GCC on VAX/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-vax-vms.h []config.h
14 $ echo "Linked `config.h' to `[.config]xm-vax-vms.h'.
15 $ !
16 $ if f$search("tconfig.h") .nes. "" then delete tconfig.h.*
17 $ create []tconfig.h
18 $DECK
19 /* tconfig.h == config.h :: target and host configurations are the same */
20 #include "config.h"
21 $EOD
22 $ echo "Created `tconfig.h'.
23 $ !
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'.
27 $ !
28 $ if f$search("md.") .nes. "" then delete md..*
29 $ copy [.config]vax.md []md.
30 $ echo "Linked `md' to `[.config]vax.md'.
31 $ !
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'.
35 $ !
36 $!
37 $!
38 $! Create the file version.opt, which helps identify the executable.
39 $!
40 $search version.c version_string,"="/match=and/output=t.tmp
41 $open ifile$ t.tmp
42 $read ifile$ line
43 $close ifile$
44 $delete 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)
51 $!
52 $i=0
53 $loop:
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
57 $i=i+1
58 $goto loop
59 $!
60 $no_ident:
61 $elm="?.??"
62 $!
63 $!
64 $write_ident:
65 $open ifile$ version.opt/write
66 $write ifile$ "ident="+""""+elm+""""
67 $close ifile$
68 $purge version.opt
69 $!
70 $!
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.
74 $!
75 $!
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
80 $!
81 $!
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);
87 !
88 ! Now fix up a few things in the output buffer
89 !
90         pat_replace (".o ",",");
91         pat_replace (".o","");  !appear at end of lines.
92 !
93 ! Remove trailing commas, if present.
94 !
95         position (beginning_of (newbuffer));
96         LOOP
97           range1 := search_quietly("," & ((SPAN(" ") & LINE_END) | LINE_END),
98                                    FORWARD, EXACT);
99           exitif range1 = 0;
100           position (beginning_of (range1));
101           erase(range1);
102           split_line;           
103           ENDLOOP;
104 ! get rid of leading spaces on lines.
105         position (beginning_of (current_buffer)) ;
106         LOOP
107           range1 := search_quietly ( LINE_BEGIN & " ", FORWARD, EXACT) ;
108           EXITIF range1 = 0;
109           position (end_of (range1));
110           erase_character(1);
111         ENDLOOP;       
112 !
113 ! Now write the output file.
114 !
115         SET(OUTPUT_FILE, newbuffer, outfile);
116       write_file (newbuffer);
117       erase (newbuffer);
118    ENDPROCEDURE;
119
120 !
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.
123 !
124    PROCEDURE recursive_fetch_tag (TAG_N);
125    fetch_tag (TAG_N);
126 !
127 ! substitute any  makefile symbols $(...)
128 !
129         position (beginning_of (current_buffer)) ;
130         LOOP
131           range1 := search_quietly ("$(" &  
132       SPAN("abcdefghijklmnopqrstuvwxyz_ABCDEFGHIJKLMNOPQRSTUVWXYZ#~0123456789")
133                                     & ")", FORWARD, EXACT) ;
134           EXITIF range1 = 0;
135           position (beginning_of (range1));
136           move_horizontal(2);
137           mark_1 := MARK (NONE);
138           position (end_of (range1));
139           move_horizontal(-1);
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);
144           erase (range1);
145           fetch_tag (LINE_BEGIN & tag_string & ((SPAN(" ") & "=") | "="));
146           position (beginning_of (current_buffer)) ;
147         ENDLOOP;       
148    ENDPROCEDURE;
149
150 !
151 ! Looks up the translation of a tag, and inserts it at the current location
152 ! in the buffer
153 !
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) ;
159       IF (range2 = 0) then 
160         position (mark3);
161         return;
162         endif;
163       position (end_of (range2)) ;
164       MOVE_HORIZONTAL(1);
165       mark1 := MARK(NONE) ;
166       position (beginning_of (range2)) ;
167       MOVE_VERTICAL(1);
168       MOVE_HORIZONTAL(-2);
169       LOOP
170         EXITIF CURRENT_CHARACTER <> "\" ;
171         ERASE_CHARACTER(1);
172         MOVE_HORIZONTAL(1);
173         MOVE_VERTICAL(1);
174         MOVE_HORIZONTAL(-2);
175         ENDLOOP;
176       MOVE_HORIZONTAL(1);
177       mark2 := MARK(NONE) ;
178       range2 := CREATE_RANGE(mark1, mark2, NONE) ;
179       position (mark3);
180       if (length(range2) = 0) then return; endif;
181       copy_text(range2);
182    ENDPROCEDURE;
183
184    PROCEDURE pat_replace (
185       oldstring, !
186       newstring)  !
187       LOCAL range2;
188       position (beginning_of (current_buffer)) ;
189       LOOP
190          range2 := search_quietly (oldstring, FORWARD, EXACT) ;
191          EXITIF range2 = 0 ;
192          position (beginning_of (range2)) ;
193          erase (range2) ;
194          copy_text (newstring) ;
195          ENDLOOP ;
196    ENDPROCEDURE ;
197
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");
203 !
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.
208 !
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 <> " ";
214         erase_character(1);
215         ENDLOOP;
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)) ;
220          erase_character(1);
221          ENDLOOP ;
222    position (end_of (compiler_list));
223    move_horizontal(-1);
224    LOOP ! kill trailing spaces.
225         exitif current_character <> " ";
226         erase_character(1);
227         move_horizontal(-1);
228         ENDLOOP;
229    position (beginning_of (compiler_list));
230       LOOP
231          range1 := search_quietly (" ", FORWARD, EXACT) ;
232          EXITIF range1 = 0 ;
233          position (beginning_of (range1)) ;
234          erase (range1) ;
235          split_line;
236          ENDLOOP ;
237 !
238 ! We now have a list of supported compilers.  Now write it, and use it.
239 !
240         SET(OUTPUT_FILE, compiler_list, "compilers.list");
241       write_file (compiler_list);
242    generate_option_file(LINE_BEGIN & "OBJS" & ((SPAN(" ") & "=") | "="),
243                         "independent.opt");
244    generate_option_file(LINE_BEGIN & "LIB2FUNCS" & ((SPAN(" ") & "=") | "="),
245                         "libgcc2.list");
246 !
247 ! Now change OBJS in the Makefile, so each language specific options file 
248 ! does not pick up all of the language independent files.
249 !
250    position (beginning_of (mainbuffer));
251    range1 := search_quietly (LINE_BEGIN & "OBJS" & ((SPAN(" ") & "=") | "="),
252                              FORWARD, EXACT) ;
253    position (end_of (range1));
254    split_line;
255    position (beginning_of (compiler_list));
256    LOOP
257      cmark := mark(NONE);
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");
262      position (cmark);
263      move_vertical(1);
264    ENDLOOP ;
265    quit ;
266 $ echo ""
267 $!
268 $! Remove excessive versions of the option files...
269 $!
270 $ purge *.opt
271 $ purge compilers.list,libgcc2.list
272 $!
273 $!
274 $!
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."
278 $ close file
279 $ type config.status
280 $ echo ""