|
|
1.1 root 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("hconfig.h") .nes. "" then delete hconfig.h.*
25: $ create []hconfig.h
26: $DECK
27: /* hconfig.h == config.h :: target and host 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: $ echo "Linked `tm.h' to `[.config]vax-vms.h'.
35: $ !
36: $ if f$search("md.") .nes. "" then delete md..*
37: $ copy [.config]vax.md []md.
38: $ echo "Linked `md' to `[.config]vax.md'.
39: $ !
40: $ if f$search("aux-output.c") .nes. "" then delete aux-output.c.*
41: $ copy [.config]vax.c []aux-output.c
42: $ echo "Linked `aux-output.c' to `[.config]vax.c'.
43: $ !
44: $!
45: $!
46: $! Create the file version.opt, which helps identify the executable.
47: $!
48: $search version.c version_string,"="/match=and/output=t.tmp
49: $open ifile$ t.tmp
50: $read ifile$ line
51: $close ifile$
52: $delete t.tmp;
53: $ijk=f$locate("""",line)+1
54: $line=f$extract(ijk,f$length(line)-ijk,line)
55: $ijk=f$locate("""",line)
56: $line=f$extract(0,ijk,line)
57: $ijk=f$locate("\n",line)
58: $line=f$extract(0,ijk,line)
59: $!
60: $i=0
61: $loop:
62: $elm=f$element(i," ",line)
63: $if elm.eqs."" then goto no_ident
64: $if (elm.les."9").and.(elm.ges."0") then goto write_ident
65: $i=i+1
66: $goto loop
67: $!
68: $no_ident:
69: $elm="?.??"
70: $!
71: $!
72: $write_ident:
73: $open ifile$ version.opt/write
74: $write ifile$ "ident="+""""+elm+""""
75: $close ifile$
76: $purge version.opt
77: $!
78: $!
79: $! create linker options files that lists all of the components for all
80: $! possible compilers. We do this by editing the file Makefile.in, and
81: $! generating the relevant files from it.
82: $!
83: $!
84: $! Make a copy of the makefile if the sources are on a disk that is NFS
85: $! mounted on a unix machine.
86: $if f$search("Makefile.in").eqs."" .and. f$search("$M$akefile.in").nes."" -
87: then copy $M$akefile.in Makefile.in
88: $!
89: $!
90: $echo "Now processing Makefile.in to generate linker option files."
91: $edit/tpu/nojournal/nosection/nodisplay/command=sys$input
92: PROCEDURE generate_option_file (TAG_NAME, outfile)
93: position (beginning_of (newbuffer));
94: recursive_fetch_tag (TAG_NAME);
95: !
96: ! Now fix up a few things in the output buffer
97: !
98: pat_replace (".o ",",");
99: pat_replace (".o",""); !appear at end of lines.
100: !
101: ! Remove trailing commas, if present.
102: !
103: position (beginning_of (newbuffer));
104: LOOP
105: range1 := search_quietly("," & ((SPAN(" ") & LINE_END) | LINE_END),
106: FORWARD, EXACT);
107: exitif range1 = 0;
108: position (beginning_of (range1));
109: erase(range1);
110: split_line;
111: ENDLOOP;
112: ! get rid of leading spaces on lines.
113: position (beginning_of (current_buffer)) ;
114: LOOP
115: range1 := search_quietly ( LINE_BEGIN & " ", FORWARD, EXACT) ;
116: EXITIF range1 = 0;
117: position (end_of (range1));
118: erase_character(1);
119: ENDLOOP;
120: !
121: ! Now write the output file.
122: !
123: SET(OUTPUT_FILE, newbuffer, outfile);
124: write_file (newbuffer);
125: erase (newbuffer);
126: ENDPROCEDURE;
127:
128: !
129: ! Looks up a tag, copies it to newbuffer, and then translates any $(...)
130: ! definitions that appear. The translation is put at the current point.
131: !
132: PROCEDURE recursive_fetch_tag (TAG_N);
133: fetch_tag (TAG_N);
134: !
135: ! substitute any makefile symbols $(...)
136: !
137: position (beginning_of (current_buffer)) ;
138: LOOP
139: range1 := search_quietly ("$(" &
140: SPAN("abcdefghijklmnopqrstuvwxyz_ABCDEFGHIJKLMNOPQRSTUVWXYZ#~0123456789")
141: & ")", FORWARD, EXACT) ;
142: EXITIF range1 = 0;
143: position (beginning_of (range1));
144: move_horizontal(2);
145: mark_1 := MARK (NONE);
146: position (end_of (range1));
147: move_horizontal(-1);
148: mark_2 := MARK (NONE);
149: tag_range := CREATE_RANGE(MARK_1, MARK_2, NONE);
150: position (end_of (range1));
151: tag_string := STR (tag_range);
152: erase (range1);
153: fetch_tag (LINE_BEGIN & tag_string & ((SPAN(" ") & "=") | "="));
154: position (beginning_of (current_buffer)) ;
155: ENDLOOP;
156: ENDPROCEDURE;
157:
158: !
159: ! Looks up the translation of a tag, and inserts it at the current location
160: ! in the buffer
161: !
162: PROCEDURE fetch_tag (TAG_N);
163: LOCAL mark1, mark2, mark3, range2;
164: mark3 := MARK(NONE) ;
165: position (beginning_of (mainbuffer)) ;
166: range2 := search_quietly (TAG_N, FORWARD, EXACT) ;
167: IF (range2 = 0) then
168: position (mark3);
169: return;
170: endif;
171: position (end_of (range2)) ;
172: MOVE_HORIZONTAL(1);
173: mark1 := MARK(NONE) ;
174: position (beginning_of (range2)) ;
175: MOVE_VERTICAL(1);
176: MOVE_HORIZONTAL(-2);
177: LOOP
178: EXITIF CURRENT_CHARACTER <> "\" ;
179: ERASE_CHARACTER(1);
180: MOVE_HORIZONTAL(1);
181: MOVE_VERTICAL(1);
182: MOVE_HORIZONTAL(-2);
183: ENDLOOP;
184: MOVE_HORIZONTAL(1);
185: mark2 := MARK(NONE) ;
186: range2 := CREATE_RANGE(mark1, mark2, NONE) ;
187: position (mark3);
188: if (length(range2) = 0) then return; endif;
189: copy_text(range2);
190: ENDPROCEDURE;
191:
192: PROCEDURE pat_replace (
193: oldstring, !
194: newstring) !
195: LOCAL range2;
196: position (beginning_of (current_buffer)) ;
197: LOOP
198: range2 := search_quietly (oldstring, FORWARD, EXACT) ;
199: EXITIF range2 = 0 ;
200: position (beginning_of (range2)) ;
201: erase (range2) ;
202: copy_text (newstring) ;
203: ENDLOOP ;
204: ENDPROCEDURE ;
205:
206: ! this is the start of the main procedure
207: filename := GET_INFO (COMMAND_LINE, 'file_name') ;
208: mainbuffer := CREATE_BUFFER ("Makefile.in", "Makefile.in") ;
209: newbuffer := CREATE_BUFFER("outfile");
210: compiler_list := CREATE_BUFFER("compilers");
211: !
212: ! Add to this list, as required. The file "Makefile.in" is searched for a
213: ! tag that looks like "LINE_BEGIN + 'tag + (optional space) + "="". The
214: ! contents are assumed to be a list of object files, and from this list a
215: ! VMS linker options file is generated.
216: !
217: position (beginning_of (compiler_list));
218: recursive_fetch_tag(LINE_BEGIN & "COMPILERS" & ((SPAN(" ") & "=") | "="));
219: position (beginning_of (compiler_list));
220: LOOP ! kill leading spaces.
221: exitif current_character <> " ";
222: erase_character(1);
223: ENDLOOP;
224: position (beginning_of (compiler_list));
225: LOOP ! remove any double spaces.
226: range1 := search_quietly (" ", FORWARD, EXACT) ; EXITIF range1 = 0 ;
227: position (beginning_of (range1)) ;
228: erase_character(1);
229: ENDLOOP ;
230: position (end_of (compiler_list));
231: move_horizontal(-1);
232: LOOP ! kill trailing spaces.
233: exitif current_character <> " ";
234: erase_character(1);
235: move_horizontal(-1);
236: ENDLOOP;
237: position (beginning_of (compiler_list));
238: LOOP
239: range1 := search_quietly (" ", FORWARD, EXACT) ;
240: EXITIF range1 = 0 ;
241: position (beginning_of (range1)) ;
242: erase (range1) ;
243: split_line;
244: ENDLOOP ;
245: !
246: ! We now have a list of supported compilers. Now write it, and use it.
247: !
248: SET(OUTPUT_FILE, compiler_list, "compilers.list");
249: write_file (compiler_list);
250: generate_option_file(LINE_BEGIN & "OBJS" & ((SPAN(" ") & "=") | "="),
251: "independent.opt");
252: generate_option_file(LINE_BEGIN & "LIB2FUNCS" & ((SPAN(" ") & "=") | "="),
253: "libgcc2.list");
254: !
255: ! Now change OBJS in the Makefile, so each language specific options file
256: ! does not pick up all of the language independent files.
257: !
258: position (beginning_of (mainbuffer));
259: range1 := search_quietly (LINE_BEGIN & "OBJS" & ((SPAN(" ") & "=") | "="),
260: FORWARD, EXACT) ;
261: position (end_of (range1));
262: split_line;
263: position (beginning_of (compiler_list));
264: LOOP
265: cmark := mark(NONE);
266: exitif cmark = end_of(compiler_list);
267: message(current_line);
268: generate_option_file(LINE_BEGIN & Current_line & ((SPAN(" ") & ":") | ":"),
269: current_line+"-objs.opt");
270: position (cmark);
271: move_vertical(1);
272: ENDLOOP ;
273: quit ;
274: $ echo ""
275: $!
276: $! Remove excessive versions of the option files...
277: $!
278: $ purge *.opt
279: $ purge compilers.list,libgcc2.list
280: $!
281: $!
282: $!
283: $ if f$search("config.status") .nes. "" then delete config.status.*
284: $ open/write file config.status
285: $ write file "Links are now set up for use with a vax running VMS."
286: $ close file
287: $ type config.status
288: $ echo ""
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.