2 |
7u83 |
1 |
/*
|
|
|
2 |
Crown Copyright (c) 1997
|
|
|
3 |
|
|
|
4 |
This TenDRA(r) Computer Program is subject to Copyright
|
|
|
5 |
owned by the United Kingdom Secretary of State for Defence
|
|
|
6 |
acting through the Defence Evaluation and Research Agency
|
|
|
7 |
(DERA). It is made available to Recipients with a
|
|
|
8 |
royalty-free licence for its use, reproduction, transfer
|
|
|
9 |
to other parties and amendment for any purpose not excluding
|
|
|
10 |
product development provided that any such use et cetera
|
|
|
11 |
shall be deemed to be acceptance of the following conditions:-
|
|
|
12 |
|
|
|
13 |
(1) Its Recipients shall ensure that this Notice is
|
|
|
14 |
reproduced upon any copies or amended versions of it;
|
|
|
15 |
|
|
|
16 |
(2) Any amended version of it shall be clearly marked to
|
|
|
17 |
show both the nature of and the organisation responsible
|
|
|
18 |
for the relevant amendment or amendments;
|
|
|
19 |
|
|
|
20 |
(3) Its onward transfer from a recipient to another
|
|
|
21 |
party shall be deemed to be that party's acceptance of
|
|
|
22 |
these conditions;
|
|
|
23 |
|
|
|
24 |
(4) DERA gives no warranty or assurance as to its
|
|
|
25 |
quality or suitability for any purpose and DERA accepts
|
|
|
26 |
no liability whatsoever in relation to any use to which
|
|
|
27 |
it may be put.
|
|
|
28 |
*/
|
|
|
29 |
|
|
|
30 |
|
|
|
31 |
#include "config.h"
|
|
|
32 |
#include "filename.h"
|
|
|
33 |
#include "list.h"
|
|
|
34 |
#include "archive.h"
|
|
|
35 |
#include "copyright.h"
|
|
|
36 |
#include "environ.h"
|
|
|
37 |
#include "flags.h"
|
|
|
38 |
#include "startup.h"
|
|
|
39 |
#include "suffix.h"
|
|
|
40 |
#include "utility.h"
|
|
|
41 |
|
|
|
42 |
|
|
|
43 |
/*
|
|
|
44 |
STRING VARIABLES
|
|
|
45 |
|
|
|
46 |
These variables given various compilation values, including the
|
|
|
47 |
location of the main temporary directory.
|
|
|
48 |
*/
|
|
|
49 |
|
|
|
50 |
char *api_info = "unknown" ;
|
|
|
51 |
char *api_output = API_ANAL_NAME ;
|
|
|
52 |
char *dump_opts = null ;
|
|
|
53 |
char *environ_dir = "." ;
|
|
|
54 |
char *final_name = null ;
|
|
|
55 |
char *machine_name = "unknown" ;
|
|
|
56 |
char *name_E_file = ENDUP_NAME ;
|
|
|
57 |
char *name_h_file = STARTUP_NAME ;
|
|
|
58 |
char *name_j_file = TDF_COMPLEX_NAME ;
|
|
|
59 |
char *name_k_file = C_SPEC_COMPLEX_NAME ;
|
|
|
60 |
char *name_K_file = CPP_SPEC_COMPLEX_NAME ;
|
|
|
61 |
char *name_p_file = TOKDEF_NAME ;
|
|
|
62 |
char *temporary_dir = "/usr/tmp" ;
|
|
|
63 |
char *tokdef_output = null ;
|
|
|
64 |
char *version_flag = "" ;
|
|
|
65 |
|
|
|
66 |
|
|
|
67 |
/*
|
|
|
68 |
INTERNAL OPTIONS
|
|
|
69 |
|
|
|
70 |
These variables control the overall behaviour of tcc. For example,
|
|
|
71 |
should we be running in verbose mode?
|
|
|
72 |
*/
|
|
|
73 |
|
|
|
74 |
boolean api_checks = 0 ;
|
|
|
75 |
boolean checker = 0 ;
|
|
|
76 |
boolean copyright = 0 ;
|
|
|
77 |
boolean dry_run = 0 ;
|
|
|
78 |
boolean link_specs = 1 ;
|
|
|
79 |
boolean make_up_names = 0 ;
|
|
|
80 |
boolean show_api = 0 ;
|
|
|
81 |
boolean show_errors = 0 ;
|
|
|
82 |
boolean suffix_overrides = 0 ;
|
|
|
83 |
boolean taciturn = 0 ;
|
|
|
84 |
boolean tidy_up = 0 ;
|
|
|
85 |
boolean time_commands = 0 ;
|
|
|
86 |
boolean verbose = 0 ;
|
|
|
87 |
boolean warnings = 1 ;
|
|
|
88 |
|
|
|
89 |
|
|
|
90 |
/*
|
|
|
91 |
COMPILATION CONTROL OPTIONS
|
|
|
92 |
|
|
|
93 |
These variables control the main compilation path taken. For example,
|
|
|
94 |
should we form a TDF archive?
|
|
|
95 |
*/
|
|
|
96 |
|
|
|
97 |
|
|
|
98 |
boolean make_archive = 0 ;
|
|
|
99 |
boolean make_complex = 0 ;
|
|
|
100 |
boolean make_preproc = 0 ;
|
|
|
101 |
boolean make_pretty = 0 ;
|
|
|
102 |
boolean make_tspec = 0 ;
|
|
|
103 |
boolean use_assembler = 1 ;
|
|
|
104 |
boolean use_mips_assembler = 0 ;
|
|
|
105 |
boolean use_alpha_assembler = 0 ;
|
|
|
106 |
boolean use_hp_linker = 0 ;
|
|
|
107 |
boolean use_dynlink = 0 ;
|
|
|
108 |
boolean use_sparc_cc = 0 ;
|
|
|
109 |
boolean use_system_cc = 0 ;
|
|
|
110 |
boolean allow_cpp = 0 ;
|
|
|
111 |
boolean allow_notation = 0 ;
|
|
|
112 |
boolean allow_pl_tdf = 0 ;
|
|
|
113 |
boolean allow_specs = 0 ;
|
|
|
114 |
|
|
|
115 |
|
|
|
116 |
/*
|
|
|
117 |
FILE PRESERVATION AND CONSTRUCTION OPTIONS
|
|
|
118 |
|
|
|
119 |
These arrays control the creation and storage of the various file
|
|
|
120 |
types. In the keeps array, a nonzero value indicates that any file
|
|
|
121 |
of this type which is created should be preserved. In the stops
|
|
|
122 |
array, it indicates that the compilation halts at this stage. In
|
|
|
123 |
either case, 0 means "false but changeable", 1 means "true but
|
|
|
124 |
changeable", and 2 means "true and unchangeable". The special
|
|
|
125 |
variable, keep_ofiles, indicates whether all binary object files
|
|
|
126 |
should be kept when more than one input file is given (this is for
|
|
|
127 |
cc compatibility). The keeps_aux array keeps track of the explicit
|
|
|
128 |
file preservation options. These tables need to be kept in step with
|
|
|
129 |
Table 1.
|
|
|
130 |
*/
|
|
|
131 |
|
|
|
132 |
boolean keeps [ TYPE_ARRAY_SIZE ] = {
|
|
|
133 |
0, /* C_SOURCE */
|
|
|
134 |
0, /* PREPROC_C */
|
|
|
135 |
0, /* CPP_SOURCE */
|
|
|
136 |
0, /* PREPROC_CPP */
|
|
|
137 |
0, /* INDEP_TDF */
|
|
|
138 |
0, /* DEP_TDF */
|
|
|
139 |
0, /* AS_SOURCE */
|
|
|
140 |
0, /* BINARY_OBJ */
|
|
|
141 |
2, /* EXECUTABLE */
|
|
|
142 |
1, /* PRETTY_TDF */
|
|
|
143 |
0, /* PL_TDF */
|
|
|
144 |
2, /* TDF_ARCHIVE */
|
|
|
145 |
0, /* MIPS_G_FILE */
|
|
|
146 |
0, /* MIPS_T_FILE */
|
|
|
147 |
0, /* C_SPEC */
|
|
|
148 |
0, /* CPP_SPEC */
|
|
|
149 |
0, /* STARTUP_FILE */
|
|
|
150 |
0, /* UNKNOWN_TYPE */
|
|
|
151 |
0, /* INDEP_TDF_COMPLEX (dummy type) */
|
|
|
152 |
0, /* C_SPEC_1 (dummy type) */
|
|
|
153 |
1, /* C_SPEC_2 (dummy type) */
|
|
|
154 |
0, /* CPP_SPEC_1 (dummy type) */
|
|
|
155 |
1, /* CPP_SPEC_2 (dummy type) */
|
|
|
156 |
0, /* INDEP_TDF_AUX (dummy type) */
|
|
|
157 |
|
|
|
158 |
} ;
|
|
|
159 |
|
|
|
160 |
boolean keeps_aux [ TYPE_ARRAY_SIZE ] = {
|
|
|
161 |
0, /* C_SOURCE */
|
|
|
162 |
0, /* PREPROC_C */
|
|
|
163 |
0, /* CPP_SOURCE */
|
|
|
164 |
0, /* PREPROC_CPP */
|
|
|
165 |
0, /* INDEP_TDF */
|
|
|
166 |
0, /* DEP_TDF */
|
|
|
167 |
0, /* AS_SOURCE */
|
|
|
168 |
0, /* BINARY_OBJ */
|
|
|
169 |
0, /* EXECUTABLE */
|
|
|
170 |
0, /* PRETTY_TDF */
|
|
|
171 |
0, /* PL_TDF */
|
|
|
172 |
0, /* TDF_ARCHIVE */
|
|
|
173 |
0, /* MIPS_G_FILE */
|
|
|
174 |
0, /* MIPS_T_FILE */
|
|
|
175 |
0, /* C_SPEC */
|
|
|
176 |
0, /* CPP_SPEC */
|
|
|
177 |
0, /* STARTUP_FILE */
|
|
|
178 |
0, /* UNKNOWN_TYPE */
|
|
|
179 |
0, /* INDEP_TDF_COMPLEX (dummy type) */
|
|
|
180 |
0, /* C_SPEC_1 (dummy type) */
|
|
|
181 |
0, /* C_SPEC_2 (dummy type) */
|
|
|
182 |
0, /* CPP_SPEC_1 (dummy type) */
|
|
|
183 |
0, /* CPP_SPEC_2 (dummy type) */
|
|
|
184 |
0, /* INDEP_TDF_AUX (dummy type) */
|
|
|
185 |
|
|
|
186 |
} ;
|
|
|
187 |
|
|
|
188 |
boolean stops [ TYPE_ARRAY_SIZE ] = {
|
|
|
189 |
0, /* C_SOURCE */
|
|
|
190 |
0, /* PREPROC_C */
|
|
|
191 |
0, /* CPP_SOURCE */
|
|
|
192 |
0, /* PREPROC_CPP */
|
|
|
193 |
0, /* INDEP_TDF */
|
|
|
194 |
0, /* DEP_TDF */
|
|
|
195 |
0, /* AS_SOURCE */
|
|
|
196 |
0, /* BINARY_OBJ */
|
|
|
197 |
2, /* EXECUTABLE */
|
|
|
198 |
2, /* PRETTY_TDF */
|
|
|
199 |
0, /* PL_TDF */
|
|
|
200 |
2, /* TDF_ARCHIVE */
|
|
|
201 |
0, /* MIPS_G_FILE */
|
|
|
202 |
0, /* MIPS_T_FILE */
|
|
|
203 |
0, /* C_SPEC */
|
|
|
204 |
0, /* CPP_SPEC */
|
|
|
205 |
0, /* STARTUP_FILE */
|
|
|
206 |
0, /* UNKNOWN_TYPE */
|
|
|
207 |
0, /* INDEP_TDF_COMPLEX (dummy type) */
|
|
|
208 |
0, /* C_SPEC_1 (dummy type) */
|
|
|
209 |
0, /* C_SPEC_2 (dummy type) */
|
|
|
210 |
0, /* CPP_SPEC_1 (dummy type) */
|
|
|
211 |
0, /* CPP_SPEC_2 (dummy type) */
|
|
|
212 |
0, /* INDEP_TDF_AUX (dummy type) */
|
|
|
213 |
|
|
|
214 |
} ;
|
|
|
215 |
|
|
|
216 |
static boolean keep_all = 0 ;
|
|
|
217 |
static boolean keep_ofiles = 1 ;
|
|
|
218 |
|
|
|
219 |
|
|
|
220 |
/*
|
|
|
221 |
INDIVIDUAL OPTIONS
|
|
|
222 |
|
|
|
223 |
These flags control those individual executable options which are
|
|
|
224 |
not easily integrated into the main scheme of things.
|
|
|
225 |
*/
|
|
|
226 |
|
|
|
227 |
boolean flag_diag = 0 ;
|
|
|
228 |
boolean flag_keep_err = 0 ;
|
|
|
229 |
boolean flag_incl = 0 ;
|
|
|
230 |
boolean flag_merge_all = 0 ;
|
|
|
231 |
boolean flag_nepc = 0 ;
|
|
|
232 |
boolean flag_no_files = 0 ;
|
|
|
233 |
boolean flag_optim = 0 ;
|
|
|
234 |
boolean flag_prof = 0 ;
|
|
|
235 |
boolean flag_startup = 1 ;
|
|
|
236 |
boolean flag_strip = 0 ;
|
|
|
237 |
|
|
|
238 |
|
|
|
239 |
/*
|
|
|
240 |
EXECUTABLES
|
|
|
241 |
|
|
|
242 |
These variables give the values of the various executables comprising
|
|
|
243 |
the system. For example, exec_produce gives the location of the C to
|
|
|
244 |
TDF producer.
|
|
|
245 |
*/
|
|
|
246 |
|
|
|
247 |
list *exec_produce = null ;
|
|
|
248 |
list *exec_preproc = null ;
|
|
|
249 |
list *exec_cpp_produce = null ;
|
|
|
250 |
list *exec_cpp_preproc = null ;
|
|
|
251 |
list *exec_tdf_link = null ;
|
|
|
252 |
list *exec_translate = null ;
|
|
|
253 |
list *exec_assemble = null ;
|
|
|
254 |
list *exec_assemble_mips = null ;
|
|
|
255 |
list *exec_link = null ;
|
|
|
256 |
list *exec_notation = null ;
|
|
|
257 |
list *exec_pl_tdf = null ;
|
|
|
258 |
list *exec_pretty = null ;
|
|
|
259 |
list *exec_spec_link = null ;
|
|
|
260 |
list *exec_cpp_spec_link = null ;
|
|
|
261 |
list *exec_split_arch = null ;
|
|
|
262 |
list *exec_build_arch = null ;
|
|
|
263 |
list *exec_cat = null ;
|
|
|
264 |
list *exec_cc = null ;
|
|
|
265 |
list *exec_mkdir = null ;
|
|
|
266 |
list *exec_move = null ;
|
|
|
267 |
list *exec_remove = null ;
|
|
|
268 |
list *exec_touch = null ;
|
|
|
269 |
list *exec_dynlink = null ;
|
|
|
270 |
list *exec_dump_anal = null ;
|
|
|
271 |
list *exec_dump_link = null ;
|
|
|
272 |
|
|
|
273 |
|
|
|
274 |
/*
|
|
|
275 |
BUILT-IN OPTIONS
|
|
|
276 |
|
|
|
277 |
These lists of options are built into the system, although they may
|
|
|
278 |
be altered by environments and command-line options.
|
|
|
279 |
*/
|
|
|
280 |
|
|
|
281 |
list *std_prod_incldirs = null ;
|
|
|
282 |
list *std_prod_portfile = null ;
|
|
|
283 |
list *std_prod_startdirs = null ;
|
|
|
284 |
list *std_prod_startup = null ;
|
|
|
285 |
list *std_cpp_prod_incldirs = null ;
|
|
|
286 |
list *std_cpp_prod_startdirs = null ;
|
|
|
287 |
list *std_cpp_prod_startup = null ;
|
|
|
288 |
list *std_tdf_link_libdirs = null ;
|
|
|
289 |
list *std_tdf_link_libs = null ;
|
|
|
290 |
list *std_link_crt0 = null ;
|
|
|
291 |
list *std_link_crt1 = null ;
|
|
|
292 |
list *std_link_crtp_n = null ;
|
|
|
293 |
list *std_link_crtn = null ;
|
|
|
294 |
list *std_link_libdirs = null ;
|
|
|
295 |
list *std_link_libs = null ;
|
|
|
296 |
list *std_link_c_libs = null ;
|
|
|
297 |
list *std_link_entry = null ;
|
|
|
298 |
|
|
|
299 |
|
|
|
300 |
|
|
|
301 |
/*
|
|
|
302 |
COMMAND-LINE OPTIONS
|
|
|
303 |
|
|
|
304 |
These lists of options are those specified on the command-line.
|
|
|
305 |
*/
|
|
|
306 |
|
|
|
307 |
list *usr_prod_incldirs = null ;
|
|
|
308 |
list *usr_prod_foptions = null ;
|
|
|
309 |
list *usr_prod_eoptions = null ;
|
|
|
310 |
list *usr_prod_startup = null ;
|
|
|
311 |
list *usr_cpp_prod_startup = null ;
|
|
|
312 |
list *usr_pl_tdf_incldirs = null ;
|
|
|
313 |
list *usr_tdf_link_libdirs = null ;
|
|
|
314 |
list *usr_tdf_link_libs = null ;
|
|
|
315 |
list *usr_link_libdirs = null ;
|
|
|
316 |
list *usr_link_libs = null ;
|
|
|
317 |
|
|
|
318 |
|
|
|
319 |
/*
|
|
|
320 |
EXECUTABLE OPTIONS
|
|
|
321 |
|
|
|
322 |
These lists record the command-line options which are passed
|
|
|
323 |
directly to the various executables.
|
|
|
324 |
*/
|
|
|
325 |
|
|
|
326 |
list *opt_produce = null ;
|
|
|
327 |
list *opt_preproc = null ;
|
|
|
328 |
list *opt_cpp_produce = null ;
|
|
|
329 |
list *opt_cpp_preproc = null ;
|
|
|
330 |
list *opt_tdf_link = null ;
|
|
|
331 |
list *opt_translate = null ;
|
|
|
332 |
list *opt_assemble = null ;
|
|
|
333 |
list *opt_assemble_mips = null ;
|
|
|
334 |
list *opt_dynlink = null ;
|
|
|
335 |
list *opt_link = null ;
|
|
|
336 |
list *opt_notation = null ;
|
|
|
337 |
list *opt_pl_tdf = null ;
|
|
|
338 |
list *opt_pretty = null ;
|
|
|
339 |
list *opt_spec_link = null ;
|
|
|
340 |
list *opt_cpp_spec_link = null ;
|
|
|
341 |
list *opt_dump_anal = null ;
|
|
|
342 |
list *opt_dump_link = null ;
|
|
|
343 |
list *opt_archive = null ;
|
|
|
344 |
list *opt_joiner = null ;
|
|
|
345 |
list *opt_cc = null ;
|
|
|
346 |
list *opt_startup = null ;
|
|
|
347 |
list *opt_endup = null ;
|
|
|
348 |
list *opt_unknown = null ;
|
|
|
349 |
|
|
|
350 |
|
|
|
351 |
/*
|
|
|
352 |
SET A KEEP OR STOP OPTION
|
|
|
353 |
|
|
|
354 |
This routine sets a value in the keeps or stops arrays. t gives
|
|
|
355 |
the file type (including ALL_TYPES) and k gives the storage command
|
|
|
356 |
(see flags.h).
|
|
|
357 |
*/
|
|
|
358 |
|
|
|
359 |
void set_stage
|
|
|
360 |
PROTO_N ( ( t, k ) )
|
|
|
361 |
PROTO_T ( int t X int k )
|
|
|
362 |
{
|
|
|
363 |
if ( t == ALL_TYPES ) {
|
|
|
364 |
boolean ks = keeps [ STARTUP_FILE ] ;
|
|
|
365 |
if ( k == STOP_STAGE || k == STOP_ONLY_STAGE ) {
|
|
|
366 |
error ( WARNING, "Illegal stop option" ) ;
|
|
|
367 |
} else if ( k == KEEP_STAGE ) {
|
|
|
368 |
int i ;
|
|
|
369 |
for ( i = 0 ; i < array_size ( keeps ) ; i++ ) {
|
|
|
370 |
if ( keeps [i] == 0 ) keeps [i] = 1 ;
|
|
|
371 |
}
|
|
|
372 |
keep_all = 1 ;
|
|
|
373 |
} else if ( k == DONT_KEEP_STAGE ) {
|
|
|
374 |
int i ;
|
|
|
375 |
for ( i = 0 ; i < array_size ( keeps ) ; i++ ) {
|
|
|
376 |
if ( keeps [i] == 1 ) keeps [i] = 0 ;
|
|
|
377 |
}
|
|
|
378 |
keep_all = 0 ;
|
|
|
379 |
keep_ofiles = 0 ;
|
|
|
380 |
}
|
|
|
381 |
keeps [ STARTUP_FILE ] = ks ;
|
|
|
382 |
} else {
|
|
|
383 |
if ( k == STOP_STAGE || k == STOP_ONLY_STAGE ) {
|
|
|
384 |
static int last_stop = UNKNOWN_TYPE ;
|
|
|
385 |
if ( stops [t] == 0 ) stops [t] = 1 ;
|
|
|
386 |
if ( k == STOP_STAGE && keeps [t] == 0 ) keeps [t] = 1 ;
|
|
|
387 |
switch ( last_stop ) {
|
|
|
388 |
case UNKNOWN_TYPE : {
|
|
|
389 |
break ;
|
|
|
390 |
}
|
|
|
391 |
case INDEP_TDF :
|
|
|
392 |
case C_SPEC :
|
|
|
393 |
case CPP_SPEC : {
|
|
|
394 |
if ( t == C_SPEC || t == CPP_SPEC ) break ;
|
|
|
395 |
if ( t == INDEP_TDF ) break ;
|
|
|
396 |
goto default_lab ;
|
|
|
397 |
}
|
|
|
398 |
case PREPROC_C :
|
|
|
399 |
case PREPROC_CPP : {
|
|
|
400 |
if ( t == PREPROC_CPP ) {
|
|
|
401 |
break ;
|
|
|
402 |
}
|
|
|
403 |
goto default_lab ;
|
|
|
404 |
}
|
|
|
405 |
default :
|
|
|
406 |
default_lab : {
|
|
|
407 |
if ( t != last_stop ) {
|
|
|
408 |
error ( WARNING, "More than one stop option given" ) ;
|
|
|
409 |
}
|
|
|
410 |
break ;
|
|
|
411 |
}
|
|
|
412 |
}
|
|
|
413 |
last_stop = t ;
|
|
|
414 |
} else if ( k == KEEP_STAGE ) {
|
|
|
415 |
if ( keeps [t] == 0 ) keeps [t] = 1 ;
|
|
|
416 |
keeps_aux [t] = 1 ;
|
|
|
417 |
if ( t == BINARY_OBJ ) keep_ofiles = 1 ;
|
|
|
418 |
} else if ( k == DONT_KEEP_STAGE ) {
|
|
|
419 |
if ( keeps [t] == 1 ) keeps [t] = 0 ;
|
|
|
420 |
keeps_aux [t] = 2 ;
|
|
|
421 |
if ( t == BINARY_OBJ ) keep_ofiles = 0 ;
|
|
|
422 |
}
|
|
|
423 |
}
|
|
|
424 |
return ;
|
|
|
425 |
}
|
|
|
426 |
|
|
|
427 |
|
|
|
428 |
/*
|
|
|
429 |
SET THE MACHINE NAME
|
|
|
430 |
|
|
|
431 |
This routine sets any special flags required by the machine indicated
|
|
|
432 |
by machine_name.
|
|
|
433 |
*/
|
|
|
434 |
|
|
|
435 |
void set_machine
|
|
|
436 |
PROTO_Z ()
|
|
|
437 |
{
|
|
|
438 |
#if 0
|
|
|
439 |
char *mach = machine_name ;
|
|
|
440 |
use_assembler = 1 ;
|
|
|
441 |
use_mips_assembler = 0 ;
|
|
|
442 |
use_alpha_assembler = 0 ;
|
|
|
443 |
use_hp_linker = 0 ;
|
|
|
444 |
if ( streq ( mach, "hp" ) || streq ( mach, "hppa" ) ) {
|
|
|
445 |
use_hp_linker = 1 ;
|
|
|
446 |
} else if ( streq ( mach, "mips" ) ) {
|
|
|
447 |
use_mips_assembler = 1 ;
|
|
|
448 |
} else if ( streq ( mach, "alpha" ) ) {
|
|
|
449 |
use_alpha_assembler = 1 ;
|
|
|
450 |
} else if ( streq ( mach, "sparc" ) || streq ( mach, "svr4_sparc" ) ) {
|
|
|
451 |
use_sparc_cc = 1 ;
|
|
|
452 |
} else if ( streq ( mach, "svr4_i386" ) ) {
|
|
|
453 |
use_sparc_cc = 2 ;
|
|
|
454 |
} else if ( streq ( mach, "transputer" ) ) {
|
|
|
455 |
use_assembler = 0 ;
|
|
|
456 |
}
|
|
|
457 |
#endif
|
|
|
458 |
return ;
|
|
|
459 |
}
|
|
|
460 |
|
|
|
461 |
|
|
|
462 |
/*
|
|
|
463 |
INITIALISE ALL OPTIONS
|
|
|
464 |
|
|
|
465 |
This routine initialises any necessary values before the
|
|
|
466 |
command-line options are read.
|
|
|
467 |
*/
|
|
|
468 |
|
|
|
469 |
void initialise_options
|
|
|
470 |
PROTO_Z ()
|
|
|
471 |
{
|
|
|
472 |
/* Initialise executables */
|
|
|
473 |
list *p ;
|
|
|
474 |
exec_produce = make_list ( "builtin/undef C_producer" ) ;
|
|
|
475 |
exec_preproc = make_list ( "builtin/undef C_preprocessor" ) ;
|
|
|
476 |
exec_cpp_produce = make_list ( "builtin/undef C++_producer" ) ;
|
|
|
477 |
exec_cpp_preproc = make_list ( "builtin/undef C++_preprocessor" ) ;
|
|
|
478 |
exec_tdf_link = make_list ( "builtin/undef TDF_linker" ) ;
|
|
|
479 |
exec_translate = make_list ( "builtin/undef TDF_translator" ) ;
|
|
|
480 |
exec_assemble = make_list ( "builtin/undef system_assembler" ) ;
|
|
|
481 |
exec_assemble_mips = make_list ( "builtin/undef mips_assembler" ) ;
|
|
|
482 |
exec_link = make_list ( "builtin/undef system_linker" ) ;
|
|
|
483 |
exec_notation = make_list ( "builtin/undef TDF_notation_compiler" ) ;
|
|
|
484 |
exec_pl_tdf = make_list ( "builtin/undef PL_TDF_compiler" ) ;
|
|
|
485 |
exec_pretty = make_list ( "builtin/undef TDF_pretty_printer" ) ;
|
|
|
486 |
exec_spec_link = make_list ( "builtin/undef C_spec_linker" ) ;
|
|
|
487 |
exec_cpp_spec_link = make_list ( "builtin/undef C++_spec_linker" ) ;
|
|
|
488 |
exec_split_arch = make_list ( "builtin/split_archive" ) ;
|
|
|
489 |
exec_build_arch = make_list ( "builtin/build_archive" ) ;
|
|
|
490 |
exec_cat = make_list ( "builtin/cat" ) ;
|
|
|
491 |
exec_cc = make_list ( "builtin/undef system_compiler" ) ;
|
|
|
492 |
exec_mkdir = make_list ( "builtin/mkdir" ) ;
|
|
|
493 |
exec_move = make_list ( "builtin/move" ) ;
|
|
|
494 |
exec_remove = make_list ( "builtin/remove" ) ;
|
|
|
495 |
exec_touch = make_list ( "builtin/touch" ) ;
|
|
|
496 |
exec_dynlink = make_list ( "builtin/undef dynamic_initialiser" ) ;
|
|
|
497 |
|
|
|
498 |
/* Initialise other options */
|
|
|
499 |
find_envpath () ;
|
|
|
500 |
for ( p = opt_startup ; p != null ; p = p->next ) {
|
|
|
501 |
add_to_startup ( p->item ) ;
|
|
|
502 |
}
|
|
|
503 |
for ( p = opt_endup ; p != null ; p = p->next ) {
|
|
|
504 |
add_to_endup ( p->item ) ;
|
|
|
505 |
}
|
|
|
506 |
if ( checker ) allow_specs = 1 ;
|
|
|
507 |
return ;
|
|
|
508 |
}
|
|
|
509 |
|
|
|
510 |
|
|
|
511 |
/*
|
|
|
512 |
UPDATE ALL OPTIONS
|
|
|
513 |
|
|
|
514 |
This routine updates the values of the variables above after all the
|
|
|
515 |
command-line options have been read. The stops options need to be
|
|
|
516 |
kept in step with the general compilation scheme given in compile.c.
|
|
|
517 |
Deciding which versions of certain file types to preserve (INDEP_TDF
|
|
|
518 |
and C_SPEC in particular) gets pretty messy.
|
|
|
519 |
*/
|
|
|
520 |
|
|
|
521 |
void update_options
|
|
|
522 |
PROTO_Z ()
|
|
|
523 |
{
|
|
|
524 |
char *mode = null ;
|
|
|
525 |
static boolean done_diag = 0 ;
|
|
|
526 |
static boolean done_preproc = 0 ;
|
|
|
527 |
static boolean done_prof = 0 ;
|
|
|
528 |
static boolean done_time = 0 ;
|
|
|
529 |
|
|
|
530 |
/* Process archive options */
|
|
|
531 |
process_archive_opt () ;
|
|
|
532 |
|
|
|
533 |
/* Deal with cc mode */
|
|
|
534 |
if ( checker ) mode = "checker" ;
|
|
|
535 |
if ( use_system_cc ) {
|
|
|
536 |
if ( !checker ) {
|
|
|
537 |
error ( WARNING, "Using the system C compiler" ) ;
|
|
|
538 |
}
|
|
|
539 |
mode = "system compiler" ;
|
|
|
540 |
}
|
|
|
541 |
if ( mode ) {
|
|
|
542 |
if ( make_archive ) {
|
|
|
543 |
error ( WARNING, "Can't build TDF archive in %s mode", mode ) ;
|
|
|
544 |
stops [ INDEP_TDF ] = 1 ;
|
|
|
545 |
make_archive = 0 ;
|
|
|
546 |
}
|
|
|
547 |
if ( make_complex ) {
|
|
|
548 |
error ( WARNING, "Can't build TDF complex in %s mode", mode ) ;
|
|
|
549 |
make_complex = 0 ;
|
|
|
550 |
}
|
|
|
551 |
if ( make_pretty ) {
|
|
|
552 |
error ( WARNING, "Can't pretty print TDF in %s mode", mode ) ;
|
|
|
553 |
stops [ INDEP_TDF ] = 1 ;
|
|
|
554 |
make_pretty = 0 ;
|
|
|
555 |
}
|
|
|
556 |
allow_notation = 0 ;
|
|
|
557 |
allow_pl_tdf = 0 ;
|
|
|
558 |
}
|
|
|
559 |
|
|
|
560 |
/* Register extra stops */
|
|
|
561 |
if ( make_archive ) set_stage ( TDF_ARCHIVE, STOP_STAGE ) ;
|
|
|
562 |
if ( make_preproc ) {
|
|
|
563 |
set_stage ( PREPROC_C, STOP_ONLY_STAGE ) ;
|
|
|
564 |
set_stage ( PREPROC_CPP, STOP_ONLY_STAGE ) ;
|
|
|
565 |
}
|
|
|
566 |
if ( make_pretty ) set_stage ( PRETTY_TDF, STOP_STAGE ) ;
|
|
|
567 |
|
|
|
568 |
/* Read special environments etc. */
|
|
|
569 |
if ( make_preproc && keeps [ PREPROC_C ] && !done_preproc ) {
|
|
|
570 |
read_env ( PREPROC_ENV ) ;
|
|
|
571 |
done_preproc = 1 ;
|
|
|
572 |
}
|
|
|
573 |
if ( flag_diag && !done_diag ) {
|
|
|
574 |
read_env ( DIAG_ENV ) ;
|
|
|
575 |
done_diag = 1 ;
|
|
|
576 |
}
|
|
|
577 |
if ( flag_prof && !done_prof ) {
|
|
|
578 |
read_env ( PROF_ENV ) ;
|
|
|
579 |
done_prof = 1 ;
|
|
|
580 |
}
|
|
|
581 |
if ( time_commands && !done_time ) {
|
|
|
582 |
read_env ( TIME_ENV ) ;
|
|
|
583 |
done_time = 1 ;
|
|
|
584 |
}
|
|
|
585 |
|
|
|
586 |
/* Print API information */
|
|
|
587 |
if ( show_api ) {
|
|
|
588 |
error ( INFO, "API is %s", api_info ) ;
|
|
|
589 |
show_api = 0 ;
|
|
|
590 |
}
|
|
|
591 |
|
|
|
592 |
#if 0
|
|
|
593 |
/* The option -Fk means stop after producer */
|
|
|
594 |
if ( stops [ C_SPEC ] || stops [ CPP_SPEC ] ||
|
|
|
595 |
stops [ PREPROC_C ] || stops [ PREPROC_CPP ] ) {
|
|
|
596 |
stops [ INDEP_TDF ] = 1 ;
|
|
|
597 |
}
|
|
|
598 |
#endif
|
|
|
599 |
|
|
|
600 |
/* Propagate stop options down */
|
|
|
601 |
if ( stops [ INDEP_TDF ] ) {
|
|
|
602 |
stops [ INDEP_TDF_COMPLEX ] = 1 ;
|
|
|
603 |
stops [ DEP_TDF ] = 1 ;
|
|
|
604 |
stops [ AS_SOURCE ] = 1 ;
|
|
|
605 |
stops [ BINARY_OBJ ] = 1 ;
|
|
|
606 |
} else if ( stops [ DEP_TDF ] ) {
|
|
|
607 |
stops [ AS_SOURCE ] = 1 ;
|
|
|
608 |
stops [ BINARY_OBJ ] = 1 ;
|
|
|
609 |
} else if ( stops [ AS_SOURCE ] ) {
|
|
|
610 |
stops [ BINARY_OBJ ] = 1 ;
|
|
|
611 |
} else if ( stops [ MIPS_G_FILE ] ) {
|
|
|
612 |
stops [ BINARY_OBJ ] = 1 ;
|
|
|
613 |
} else if ( stops [ MIPS_T_FILE ] ) {
|
|
|
614 |
stops [ BINARY_OBJ ] = 1 ;
|
|
|
615 |
}
|
|
|
616 |
|
|
|
617 |
/* Check keep options */
|
|
|
618 |
if ( make_complex ) {
|
|
|
619 |
if ( keeps [ INDEP_TDF ] ) {
|
|
|
620 |
keeps [ INDEP_TDF ] = keep_all ;
|
|
|
621 |
keeps [ INDEP_TDF_COMPLEX ] = 1 ;
|
|
|
622 |
}
|
|
|
623 |
if ( stops [ INDEP_TDF ] ) {
|
|
|
624 |
keeps [ C_SPEC_1 ] = 1 ;
|
|
|
625 |
keeps [ CPP_SPEC_1 ] = 1 ;
|
|
|
626 |
}
|
|
|
627 |
}
|
|
|
628 |
if ( keeps [ C_SPEC ] ) {
|
|
|
629 |
if ( make_complex ) {
|
|
|
630 |
keeps [ C_SPEC ] = keep_all ;
|
|
|
631 |
keeps [ C_SPEC_1 ] = 1 ;
|
|
|
632 |
}
|
|
|
633 |
} else {
|
|
|
634 |
if ( keeps_aux [ C_SPEC ] == 2 ) {
|
|
|
635 |
keeps [ C_SPEC_1 ] = 0 ;
|
|
|
636 |
keeps [ C_SPEC_2 ] = 0 ;
|
|
|
637 |
}
|
|
|
638 |
}
|
|
|
639 |
if ( keeps [ CPP_SPEC ] ) {
|
|
|
640 |
if ( make_complex ) {
|
|
|
641 |
keeps [ CPP_SPEC ] = keep_all ;
|
|
|
642 |
keeps [ CPP_SPEC_1 ] = 1 ;
|
|
|
643 |
}
|
|
|
644 |
} else if ( keeps_aux [ CPP_SPEC ] == 2 ) {
|
|
|
645 |
keeps [ CPP_SPEC_1 ] = 0 ;
|
|
|
646 |
keeps [ CPP_SPEC_2 ] = 0 ;
|
|
|
647 |
}
|
|
|
648 |
if ( keep_ofiles && no_input_files > 1 && !make_complex ) {
|
|
|
649 |
keeps [ BINARY_OBJ ] = 1 ;
|
|
|
650 |
}
|
|
|
651 |
if ( keeps_aux [ BINARY_OBJ ] == 1 ) {
|
|
|
652 |
keeps [ BINARY_OBJ_AUX ] = 1 ;
|
|
|
653 |
}
|
|
|
654 |
if ( link_specs ) {
|
|
|
655 |
boolean b ;
|
|
|
656 |
if ( checker && !use_system_cc ) {
|
|
|
657 |
if ( keeps_aux [ BINARY_OBJ ] ) {
|
|
|
658 |
b = 1 ;
|
|
|
659 |
} else if ( stops [ BINARY_OBJ ] && !stops [ AS_SOURCE ] ) {
|
|
|
660 |
b = keeps [ BINARY_OBJ ] ;
|
|
|
661 |
} else {
|
|
|
662 |
b = 0 ;
|
|
|
663 |
}
|
|
|
664 |
} else {
|
|
|
665 |
b = keeps [ BINARY_OBJ ] ;
|
|
|
666 |
}
|
|
|
667 |
if ( b ) {
|
|
|
668 |
if ( make_complex ) {
|
|
|
669 |
keeps [ C_SPEC_1 ] = 1 ;
|
|
|
670 |
keeps [ CPP_SPEC_1 ] = 1 ;
|
|
|
671 |
} else {
|
|
|
672 |
keeps [ C_SPEC ] = 1 ;
|
|
|
673 |
keeps [ CPP_SPEC ] = 1 ;
|
|
|
674 |
}
|
|
|
675 |
keeps [ BINARY_OBJ_AUX ] = 1 ;
|
|
|
676 |
}
|
|
|
677 |
}
|
|
|
678 |
|
|
|
679 |
/* Set checker options */
|
|
|
680 |
if ( checker ) {
|
|
|
681 |
if ( allow_specs == 0 ) allow_specs = 1 ;
|
|
|
682 |
if ( !use_system_cc ) {
|
|
|
683 |
stops [ C_SPEC_2 ] = 1 ;
|
|
|
684 |
stops [ CPP_SPEC_2 ] = 1 ;
|
|
|
685 |
}
|
|
|
686 |
}
|
|
|
687 |
|
|
|
688 |
/* Print the copyright message if required */
|
|
|
689 |
if ( copyright ) {
|
|
|
690 |
print_copyright () ;
|
|
|
691 |
copyright = 0 ;
|
|
|
692 |
}
|
|
|
693 |
|
|
|
694 |
/* A couple of housekeeping routines */
|
|
|
695 |
close_startup () ;
|
|
|
696 |
find_envpath () ;
|
|
|
697 |
return ;
|
|
|
698 |
}
|