OSDN Git Service

(NEEDS_UNTYPED_CALL): Define.
[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.vax]xm-vms.h []config.h
14 $ echo "Linked `config.h' to `[.config.vax]xm-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("hconfig.h") .nes. "" then delete hconfig.h.*
25 $ create []hconfig.h
26 $DECK
27 /* hconfig.h == config.h :: host and target configurations are the same */
28 #include "config.h"
29 $EOD
30 $ echo "Created `hconfig.h'.
31 $ !
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
36 $DECK
37 !
38 !  Copy file, changing lines of the form
39 !       #include "vax/*"
40 !  into
41 !       #include "[.config.vax]*"
42 !
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));
46    LOOP
47       incl := SEARCH_QUIETLY(targ, FORWARD, EXACT, rang);
48       EXITIF incl = 0;
49       POSITION(BEGINNING_OF(incl));
50       ERASE(incl);
51       COPY_TEXT('#include "[.config.vax]');
52       rang := CREATE_RANGE(END_OF(incl), END_OF(file));
53    ENDLOOP;
54    WRITE_FILE(file, GET_INFO(COMMAND_LINE, "output_file"));
55    QUIT
56 $EOD
57 $ echo "Generated `tm.h' from `[.config.vax]vms.h'.
58 $ !
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'.
62 $ !
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'.
66 $ !
67 $!
68 $!
69 $! Create the file version.opt, which helps identify the executable.
70 $!
71 $search version.c version_string,"="/match=and/output=t.tmp
72 $open ifile$ t.tmp
73 $read ifile$ line
74 $close ifile$
75 $delete 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)
82 $!
83 $i=0
84 $loop:
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
88 $i=i+1
89 $goto loop
90 $!
91 $no_ident:
92 $elm="?.??"
93 $!
94 $!
95 $write_ident:
96 $open ifile$ version.opt/write
97 $write ifile$ "ident="+""""+elm+""""
98 $close ifile$
99 $purge version.opt
100 $!
101 $!
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.
105 $!
106 $!
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
111 $!
112 $!
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);
118 !
119 ! Now fix up a few things in the output buffer
120 !
121         pat_replace (".o ",",");
122         pat_replace (".o","");  !appear at end of lines.
123 !
124 ! Remove trailing commas, if present.
125 !
126         position (beginning_of (newbuffer));
127         LOOP
128           range1 := search_quietly("," & ((SPAN(" ") & LINE_END) | LINE_END),
129                                    FORWARD, EXACT);
130           exitif range1 = 0;
131           position (beginning_of (range1));
132           erase(range1);
133           split_line;           
134           ENDLOOP;
135 ! get rid of leading spaces on lines.
136         position (beginning_of (current_buffer)) ;
137         LOOP
138           range1 := search_quietly ( LINE_BEGIN & " ", FORWARD, EXACT) ;
139           EXITIF range1 = 0;
140           position (end_of (range1));
141           erase_character(1);
142         ENDLOOP;       
143 !
144 ! Now write the output file.
145 !
146         SET(OUTPUT_FILE, newbuffer, outfile);
147       write_file (newbuffer);
148       erase (newbuffer);
149    ENDPROCEDURE;
150
151 !
152 ! Looks up a tag, copies it to newbuffer, and then translates any $(...)
153 ! definitions that appear.  The translation is put at the current point.
154 !
155    PROCEDURE recursive_fetch_tag (TAG_N);
156    fetch_tag (TAG_N);
157 !
158 ! substitute any  makefile symbols $(...)
159 !
160         position (beginning_of (current_buffer)) ;
161         LOOP
162           range1 := search_quietly ("$(" &  
163       SPAN("abcdefghijklmnopqrstuvwxyz_ABCDEFGHIJKLMNOPQRSTUVWXYZ#~0123456789")
164                                     & ")", FORWARD, EXACT) ;
165           EXITIF range1 = 0;
166           position (beginning_of (range1));
167           move_horizontal(2);
168           mark_1 := MARK (NONE);
169           position (end_of (range1));
170           move_horizontal(-1);
171           mark_2 := MARK (NONE);
172           tag_range := CREATE_RANGE(MARK_1, MARK_2, NONE);
173           position (end_of (range1));
174           tag_string := STR (tag_range);
175           erase (range1);
176           fetch_tag (LINE_BEGIN & tag_string & ((SPAN(" ") & "=") | "="));
177           position (beginning_of (current_buffer)) ;
178         ENDLOOP;       
179    ENDPROCEDURE;
180
181 !
182 ! Looks up the translation of a tag, and inserts it at the current location
183 ! in the buffer
184 !
185    PROCEDURE fetch_tag (TAG_N);
186       LOCAL mark1, mark2, mark3, range2;
187       mark3 := MARK(NONE) ;
188       position (beginning_of (mainbuffer)) ;
189       range2 := search_quietly (TAG_N, FORWARD, EXACT) ;
190       IF (range2 = 0) then 
191         position (mark3);
192         return;
193         endif;
194       position (end_of (range2)) ;
195       MOVE_HORIZONTAL(1);
196       mark1 := MARK(NONE) ;
197       position (beginning_of (range2)) ;
198       MOVE_VERTICAL(1);
199       MOVE_HORIZONTAL(-2);
200       LOOP
201         EXITIF CURRENT_CHARACTER <> "\" ;
202         ERASE_CHARACTER(1);
203         MOVE_HORIZONTAL(1);
204         MOVE_VERTICAL(1);
205         MOVE_HORIZONTAL(-2);
206         ENDLOOP;
207       MOVE_HORIZONTAL(1);
208       mark2 := MARK(NONE) ;
209       range2 := CREATE_RANGE(mark1, mark2, NONE) ;
210       position (mark3);
211       if (length(range2) = 0) then return; endif;
212       copy_text(range2);
213    ENDPROCEDURE;
214
215    PROCEDURE pat_replace (
216       oldstring, !
217       newstring)  !
218       LOCAL range2;
219       position (beginning_of (current_buffer)) ;
220       LOOP
221          range2 := search_quietly (oldstring, FORWARD, EXACT) ;
222          EXITIF range2 = 0 ;
223          position (beginning_of (range2)) ;
224          erase (range2) ;
225          copy_text (newstring) ;
226          ENDLOOP ;
227    ENDPROCEDURE ;
228
229 ! this is the start of the main procedure
230    filename := GET_INFO (COMMAND_LINE, 'file_name') ;
231    mainbuffer := CREATE_BUFFER ("Makefile.in", "Makefile.in") ;
232    newbuffer := CREATE_BUFFER("outfile");
233    compiler_list := CREATE_BUFFER("compilers");
234 !
235 ! Add to this list, as required.  The file "Makefile.in" is searched for a
236 ! tag that looks like "LINE_BEGIN + 'tag + (optional space) + "="".  The
237 ! contents are assumed to be a list of object files, and from this list a
238 ! VMS linker options file is generated.
239 !
240    position (beginning_of (compiler_list));
241    recursive_fetch_tag(LINE_BEGIN & "COMPILERS" & ((SPAN(" ") & "=") | "="));
242    position (beginning_of (compiler_list));
243    LOOP ! kill leading spaces.
244         exitif current_character <> " ";
245         erase_character(1);
246         ENDLOOP;
247    position (beginning_of (compiler_list));
248       LOOP ! remove any double spaces.
249          range1 := search_quietly ("  ", FORWARD, EXACT) ; EXITIF range1 = 0 ;
250          position (beginning_of (range1)) ;
251          erase_character(1);
252          ENDLOOP ;
253    position (end_of (compiler_list));
254    move_horizontal(-1);
255    LOOP ! kill trailing spaces.
256         exitif current_character <> " ";
257         erase_character(1);
258         move_horizontal(-1);
259         ENDLOOP;
260    position (beginning_of (compiler_list));
261       LOOP
262          range1 := search_quietly (" ", FORWARD, EXACT) ;
263          EXITIF range1 = 0 ;
264          position (beginning_of (range1)) ;
265          erase (range1) ;
266          split_line;
267          ENDLOOP ;
268 !
269 ! We now have a list of supported compilers.  Now write it, and use it.
270 !
271         SET(OUTPUT_FILE, compiler_list, "compilers.list");
272       write_file (compiler_list);
273    generate_option_file(LINE_BEGIN & "OBJS" & ((SPAN(" ") & "=") | "="),
274                         "independent.opt");
275    generate_option_file(LINE_BEGIN & "LIB2FUNCS" & ((SPAN(" ") & "=") | "="),
276                         "libgcc2.list");
277 !
278 ! Now change OBJS in the Makefile, so each language specific options file 
279 ! does not pick up all of the language independent files.
280 !
281    position (beginning_of (mainbuffer));
282    range1 := search_quietly (LINE_BEGIN & "OBJS" & ((SPAN(" ") & "=") | "="),
283                              FORWARD, EXACT) ;
284    position (end_of (range1));
285    split_line;
286    position (beginning_of (compiler_list));
287    LOOP
288      cmark := mark(NONE);
289      exitif cmark = end_of(compiler_list);
290      message(current_line);
291      generate_option_file(LINE_BEGIN & Current_line & ((SPAN(" ") & ":") | ":"),
292                           current_line+"-objs.opt");
293      position (cmark);
294      move_vertical(1);
295    ENDLOOP ;
296    quit ;
297 $ echo ""
298 $!
299 $! Remove excessive versions of the option files...
300 $!
301 $ purge *.opt
302 $ purge compilers.list,libgcc2.list
303 $!
304 $!
305 $!
306 $ if f$search("config.status") .nes. "" then delete config.status.*
307 $ open/write file config.status
308 $ write file "Links are now set up for use with a vax running VMS."
309 $ close file
310 $ type config.status
311 $ echo ""