Subversion Repositories tendra.SVN

Rev

Rev 2 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
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 "environ.h"
36
#include "flags.h"
37
#include "compile.h"
38
#include "execute.h"
39
#include "options.h"
40
#include "stages.h"
41
#include "startup.h"
42
#include "suffix.h"
43
#include "utility.h"
44
static filename *apply_unjoin PROTO_S ( ( filename *, int ) ) ;
45
 
46
 
47
/*
48
    CHECK IF ONE FILE IS THE C SPEC OF THE OTHER
49
 
50
    This macro checks if q is the C or C++ spec file corresponding to p.
51
    q must be of type C_SPEC and have the same uniq value as p.
52
*/
53
 
54
#define spec_of( p, q )\
55
	( ( q ) && ( ( q )->type == C_SPEC || ( q )->type == CPP_SPEC ) \
56
			 && ( q )->uniq == ( p )->uniq )
57
 
58
 
59
/*
60
    APPLY THE SYSTEM COMPILER
61
 
62
    This routine applies the system C compiler to the files, input,
63
    returning the result.
64
*/
65
 
66
static filename *apply_cc
67
    PROTO_N ( ( input ) )
68
    PROTO_T ( filename *input )
69
{
70
    filename *p = input ;
71
    filename *output = null ;
72
    while ( p != null ) {
73
	filename *ps = null ;
74
	filename *pn = p->next ;
75
	p->next = null ;
76
	switch ( p->type ) {
77
 
78
	    case C_SOURCE : {
79
		/* C source */
80
		if ( make_preproc || keeps [ PREPROC_C ] ) {
81
		    p = do_cc ( p, PREPROC_C ) ;
82
		    if ( stops [ PREPROC_C ] ) break ;
83
		}
84
		goto preproc_c_lab ;
85
	    }
86
 
87
	    case PREPROC_C :
88
	    preproc_c_lab : {
89
		/* Preprocessed C source */
90
		if ( use_system_cc == 1 ) {
91
		    ps = do_produce ( p ) ;
92
		    if ( ps == null ) {
93
			p = null ;
94
			break ;
95
		    } else {
96
			ps = ps->next ;
97
		    }
98
		}
99
		if ( stops [ DEP_TDF ] ) {
100
		    if ( ps != null ) p = null ;
101
		    break ;
102
		} else if ( stops [ AS_SOURCE ] ) {
103
		    p = do_cc ( p, AS_SOURCE ) ;
104
		    break ;
105
		} else if ( keeps [ AS_SOURCE ] ) {
106
		    p = do_cc ( p, AS_SOURCE ) ;
107
		} else {
108
		    p = do_cc ( p, binary_obj_type ) ;
109
		    break ;
110
		}
111
		goto as_source_lab ;
112
	    }
113
 
114
	    case CPP_SOURCE : {
115
		/* C++ source */
116
		if ( make_preproc || keeps [ PREPROC_CPP ] ) {
117
		    p = do_cc ( p, PREPROC_CPP ) ;
118
		    if ( stops [ PREPROC_CPP ] ) break ;
119
		}
120
		goto preproc_cpp_lab ;
121
	    }
122
 
123
	    case PREPROC_CPP :
124
	    preproc_cpp_lab : {
125
		/* Preprocessed C++ source */
126
		if ( use_system_cc == 1 ) {
127
		    ps = do_cpp_produce ( p ) ;
128
		    if ( ps == null ) {
129
			p = null ;
130
			break ;
131
		    } else {
132
			ps = ps->next ;
133
		    }
134
		}
135
		if ( stops [ DEP_TDF ] ) {
136
		    if ( ps != null ) p = null ;
137
		    break ;
138
		} else if ( stops [ AS_SOURCE ] ) {
139
		    p = do_cc ( p, AS_SOURCE ) ;
140
		    break ;
141
		} else if ( keeps [ AS_SOURCE ] ) {
142
		    p = do_cc ( p, AS_SOURCE ) ;
143
		} else {
144
		    p = do_cc ( p, binary_obj_type ) ;
145
		    break ;
146
		}
147
		goto as_source_lab ;
148
	    }
149
 
150
	    case AS_SOURCE :
151
	    as_source_lab : {
152
		/* Assembly source file */
153
		if ( !stops [ AS_SOURCE ] ) p = do_cc ( p, BINARY_OBJ ) ;
154
		break ;
155
	    }
156
 
157
	    case BINARY_OBJ : {
158
		/* Binary object file */
159
		break ;
160
	    }
161
 
162
	    case C_SPEC : {
163
		/* C spec file */
164
		if ( !allow_specs ) {
165
		    error ( WARNING, "'%s' is a C spec file", p->name ) ;
166
		    p->type = DEFAULT_TYPE ;
167
		} else {
168
		    if ( p->storage == INPUT_FILE &&
169
			 keeps_aux [ BINARY_OBJ ] == 1 &&
170
			 !stops [ AS_SOURCE ] ) {
171
			p = do_build_file ( p, BINARY_OBJ ) ;
172
		    }
173
		}
174
		break ;
175
	    }
176
 
177
	    case CPP_SPEC : {
178
		/* C++ spec file */
179
		if ( !allow_specs || !allow_cpp ) {
180
		    error ( WARNING, "'%s' is a C++ spec file", p->name ) ;
181
		    p->type = DEFAULT_TYPE ;
182
		} else {
183
		    if ( p->storage == INPUT_FILE &&
184
			 keeps_aux [ BINARY_OBJ ] == 1 &&
185
			 !stops [ AS_SOURCE ] ) {
186
			p = do_build_file ( p, BINARY_OBJ ) ;
187
		    }
188
		}
189
		break ;
190
	    }
191
 
192
	    default : {
193
		/* Other file types give an error */
194
		error ( WARNING, "TDF file '%s' not recognised in cc mode",
195
			p->name ) ;
196
		p->type = DEFAULT_TYPE ;
197
		break ;
198
	    }
199
	}
200
	if ( p && p->storage != INPUT_FILE && p->aux == null ) {
201
	    boolean have_spec = 0 ;
202
	    filename *p_archive = p ;
203
	    int t = p->type ;
204
	    if ( t == BINARY_OBJ && keeps [t] && binary_obj_type != t ) {
205
		if ( spec_of ( p_archive, ps ) ) {
206
		    p_archive->next = ps ;
207
		    p_archive = p_archive->next ;
208
		    ps = ps ->next ;
209
		    p_archive->next = null ;
210
		    have_spec = 1 ;
211
		}
212
		if ( have_spec ) {
213
		    p = do_build_file ( p, BINARY_OBJ ) ;
214
		}
215
	    }
216
	}
217
	output = add_filename ( output, p ) ;
218
	if ( ps ) output = add_filename ( output, ps ) ;
219
	p = pn ;
220
    }
221
    return ( output ) ;
222
}
223
 
224
 
225
/*
226
    APPLY THE TDF LINKER
227
 
228
    This routine applies the TDF linker to p, returning the result.
229
*/
230
 
231
static filename *apply_tdf_link
232
    PROTO_N ( ( p ) )
233
    PROTO_T ( filename *p )
234
{
235
    static boolean tried = 0 ;
236
    if ( p == null || stops [ INDEP_TDF ] ) return ( p ) ;
237
    if ( tokdef_name && tokdef_output == null && !tried ) {
238
	filename *q ;
239
	if ( !allow_notation ) read_env ( TNC_ENV ) ;
240
	q = find_filename ( tokdef_name, PRETTY_TDF ) ;
241
	q = do_notation ( q ) ;
242
	if ( q ) tokdef_output = q->name ;
243
	tried = 1 ;
244
    }
245
    return ( do_tdf_link ( p ) ) ;
246
}
247
 
248
 
249
/*
250
    APPLY THE MAIN COMPILATION STAGES
251
 
252
    This routine applies the main compilation phases to the input files
253
    input, and returns the corresponding output files.  If produce is
254
    true then the compilation stops at the target independent TDF stage.
255
    This, and all the routines in this module, needs to be kept in step
256
    with Table 1.
257
*/
258
 
259
static filename *apply_compile
260
    PROTO_N ( ( input, produce ) )
261
    PROTO_T ( filename *input X int produce )
262
{
263
    filename *p = input ;
264
    filename *output = null ;
265
    if ( use_system_cc ) return ( apply_cc ( input ) ) ;
266
    while ( p != null ) {
267
	filename *pc = p ;
268
	filename *pn = p->next ;
269
	p->next = null ;
270
	switch ( p->type ) {
271
 
272
	    case C_SOURCE : {
273
		/* C source */
274
		if ( keeps [ PREPROC_C ] ) {
275
		    p = do_preproc ( p ) ;
276
		} else {
277
		    p = do_produce ( p ) ;
278
		}
279
		if ( allow_specs && stops [ C_SPEC ] ) p = null ;
280
		if ( p != pc ) p = apply_compile ( p, produce ) ;
281
		break ;
282
	    }
283
 
284
	    case PREPROC_C : {
285
		/* Preprocessed C source */
286
		if ( stops [ PREPROC_C ] ) break ;
287
		p = do_produce ( p ) ;
288
		if ( allow_specs && stops [ C_SPEC ] ) p = null ;
289
		if ( p != pc ) p = apply_compile ( p, produce ) ;
290
		break ;
291
	    }
292
 
293
	    case CPP_SOURCE : {
294
		/* C++ source */
295
		if ( allow_cpp ) {
296
		    if ( keeps [ PREPROC_CPP ] ) {
297
			p = do_cpp_preproc ( p ) ;
298
		    } else {
299
			p = do_cpp_produce ( p ) ;
300
		    }
301
		    if ( allow_specs && stops [ CPP_SPEC ] ) p = null ;
302
		    if ( p != pc ) p = apply_compile ( p, produce ) ;
303
		} else {
304
		    error ( WARNING, "'%s' is a C++ source file",
305
			    p->name ) ;
306
		    p->type = DEFAULT_TYPE ;
307
		}
308
		break ;
309
	    }
310
 
311
	    case PREPROC_CPP : {
312
		/* Preprocessed C++ source */
313
		if ( stops [ PREPROC_CPP ] ) break ;
314
		if ( allow_cpp ) {
315
		    p = do_cpp_produce ( p ) ;
316
		    if ( allow_specs && stops [ CPP_SPEC ] ) p = null ;
317
		    if ( p != pc ) p = apply_compile ( p, produce ) ;
318
		} else {
319
		    error ( WARNING, "'%s' is a preprocessed C++ source file",
320
			    p->name ) ;
321
		    p->type = DEFAULT_TYPE ;
322
		}
323
		break ;
324
	    }
325
 
326
	    case INDEP_TDF : {
327
		/* Target independent TDF */
328
		if ( !produce ) {
329
		    p = apply_tdf_link ( p ) ;
330
		    if ( p != pc ) p = apply_compile ( p, produce ) ;
331
		}
332
		break ;
333
	    }
334
 
335
	    case DEP_TDF : {
336
		/* Target dependent TDF */
337
		if ( !produce ) {
338
		    p = do_translate ( p ) ;
339
		    if ( p != pc ) p = apply_compile ( p, produce ) ;
340
		}
341
		break ;
342
	    }
343
 
344
	    case AS_SOURCE : {
345
		/* Assembly source */
346
		if ( !produce ) {
347
		    p = do_assemble ( p ) ;
348
		    if ( p != pc ) p = apply_compile ( p, produce ) ;
349
		}
350
		break ;
351
	    }
352
 
353
	    case PRETTY_TDF : {
354
		/* TDF notation source */
355
		if ( allow_notation ) {
356
		    p = do_notation ( p ) ;
357
		    if ( p != pc ) p = apply_compile ( p, produce ) ;
358
		} else {
359
		    error ( WARNING, "'%s' is a TDF notation source file",
360
			    p->name ) ;
361
		    p->type = DEFAULT_TYPE ;
362
		}
363
		break ;
364
	    }
365
 
366
	    case PL_TDF : {
367
		/* PL_TDF source */
368
		if ( allow_pl_tdf ) {
369
		    p = do_pl_tdf ( p ) ;
370
		    if ( p != pc ) p = apply_compile ( p, produce ) ;
371
		} else {
372
		    error ( WARNING, "'%s' is a PL_TDF source file",
373
			    p->name ) ;
374
		    p->type = DEFAULT_TYPE ;
375
		}
376
		break ;
377
	    }
378
 
379
	    case C_SPEC : {
380
		/* C spec file */
381
		if ( !allow_specs ) {
382
		    error ( WARNING, "'%s' is a C spec file", p->name ) ;
383
		    p->type = DEFAULT_TYPE ;
384
		} else {
385
		    if ( p->storage == INPUT_FILE &&
386
			 keeps_aux [ BINARY_OBJ ] == 1 &&
387
			 !stops [ AS_SOURCE ] ) {
388
			p = do_build_file ( p, BINARY_OBJ ) ;
389
		    }
390
		}
391
		break ;
392
	    }
393
 
394
	    case CPP_SPEC : {
395
		/* C++ spec file */
396
		if ( !allow_specs || !allow_cpp ) {
397
		    error ( WARNING, "'%s' is a C++ spec file", p->name ) ;
398
		    p->type = DEFAULT_TYPE ;
399
		} else {
400
		    if ( p->storage == INPUT_FILE &&
401
			 keeps_aux [ BINARY_OBJ ] == 1 &&
402
			 !stops [ AS_SOURCE ] ) {
403
			p = do_build_file ( p, BINARY_OBJ ) ;
404
		    }
405
		}
406
		break ;
407
	    }
408
	}
409
	if ( p && p->storage != INPUT_FILE && p->aux == null ) {
410
	    boolean have_spec = 0 ;
411
	    filename *p_archive = p ;
412
	    if ( spec_of ( p_archive, p_archive->next ) ) {
413
		p_archive = p_archive->next ;
414
		have_spec = 1 ;
415
	    } else if ( spec_of ( p_archive, pn ) ) {
416
		p_archive->next = pn ;
417
		p_archive = p_archive->next ;
418
		pn = pn->next ;
419
		p_archive->next = null ;
420
		have_spec = 1 ;
421
	    }
422
	    if ( have_spec ) {
423
		int t = p->type ;
424
		if ( t == INDEP_TDF && checker && !stops [t] ) {
425
		    if ( stops [ BINARY_OBJ ] ||
426
			 keeps_aux [ BINARY_OBJ ] == 1 ) {
427
			p = do_build_file ( p->next, BINARY_OBJ ) ;
428
		    }
429
		}
430
		if ( t == BINARY_OBJ && keeps [t] ) {
431
		    p = do_build_file ( p, BINARY_OBJ ) ;
432
		}
433
	    }
434
	}
435
	output = add_filename ( output, p ) ;
436
	p = pn ;
437
    }
438
    return ( output ) ;
439
}
440
 
441
 
442
/*
443
    FILTER OUT LIST OF BINARY OBJECT FILES
444
 
445
    This routine picks out the TDF capsules from the input files, input,
446
    compiles them to binary object files, and returns them.
447
*/
448
 
449
static filename *filter_ofiles
450
    PROTO_N ( ( input ) )
451
    PROTO_T ( filename *input )
452
{
453
    filename *p = input ;
454
    filename *links = null ;
455
    while ( p != null ) {
456
	filename *pn = p->next ;
457
	p->next = null ;
458
	p->aux = pn ;
459
	if ( p->type == INDEP_TDF ) {
460
	    filename *q = apply_compile ( p, 0 ) ;
461
	    if ( q && q->type == BINARY_OBJ ) {
462
		links = add_filename ( links, q ) ;
463
	    }
464
	}
465
	p = pn ;
466
    }
467
    return ( links ) ;
468
}
469
 
470
 
471
/*
472
    APPLY THE SYSTEM LINKER
473
 
474
    This routine applies the system linker to the input files, input,
475
    and returns the corresponding output files.
476
*/
477
 
478
static filename *apply_link
479
    PROTO_N ( ( input ) )
480
    PROTO_T ( filename *input )
481
{
482
    filename *p = input ;
483
    int spec_out = C_SPEC_2 ;
484
    filename *links = null, *links_out = null ;
485
    filename *specs = null, *specs_out ;
486
    filename *others = null ;
487
    while ( p != null ) {
488
	filename *pn = p->next ;
489
	p->next = null ;
490
	p->aux = pn ;
491
	if ( p->type == BINARY_OBJ ) {
492
	    links = add_filename ( links, p ) ;
493
	} else if ( p->type == C_SPEC ) {
494
	    specs = add_filename ( specs, p ) ;
495
	} else if ( p->type == CPP_SPEC ) {
496
	    specs = add_filename ( specs, p ) ;
497
	    spec_out = CPP_SPEC_2 ;
498
	} else {
499
	    others = add_filename ( others, p ) ;
500
	}
501
	p = pn ;
502
    }
503
    last_return = 0 ;
504
    keeps [ binary_obj_type ] = 0 ;
505
    specs_out = do_link_specs ( specs, spec_out ) ;
506
    links = add_filename ( links, filter_ofiles ( specs_out ) ) ;
507
    if ( use_dynlink != 0 && use_system_cc == 0 ) links = do_dynlink ( links ) ;
508
    if ( links ) links_out = do_link ( links ) ;
509
    if ( specs_out && links_out ) specs_out->uniq = links_out->uniq ;
510
    p = add_filename ( links_out, specs_out ) ;
511
    p = add_filename ( p, others ) ;
512
    if ( last_return ) {
513
	/* If the linking failed, keep the .o files */
514
	filename *q = input ;
515
	boolean b = keeps [ BINARY_OBJ ] ;
516
	keeps [ BINARY_OBJ ] = 1 ;
517
	p = null ;
518
	while ( q != null ) {
519
	    filename *qa = q->aux ;
520
	    q->next = null ;
521
	    if ( q->type == C_SPEC || q->type == CPP_SPEC ) {
522
		q = null ;
523
	    } else if ( q->type == BINARY_OBJ ) {
524
		if ( q->storage == INPUT_FILE || b ) {
525
		    q = null ;
526
		} else if ( allow_specs ) {
527
		    if ( link_specs ) q = do_keep ( q ) ;
528
		    if ( spec_of ( q, qa ) ) {
529
			q->next = qa ;
530
			qa->next = null ;
531
			qa = qa->aux ;
532
			if ( link_specs ) q->next = do_keep ( q->next ) ;
533
		    }
534
		    q = do_build_file ( q, BINARY_OBJ ) ;
535
		} else {
536
		    q = do_keep ( q ) ;
537
		}
538
	    }
539
	    p = add_filename ( p, q ) ;
540
	    q = qa ;
541
	}
542
    }
543
    return ( p ) ;
544
}
545
 
546
 
547
/*
548
    SPLIT ALL TDF ARCHIVES
549
 
550
    This routine splits any TDF archives in the input files, input,
551
    and returns the corresponding output files.
552
*/
553
 
554
static filename *apply_split_arch
555
    PROTO_N ( ( input ) )
556
    PROTO_T ( filename *input )
557
{
558
    filename *p = input ;
559
    filename *output = null ;
560
    archive_type = TDF_ARCHIVE ;
561
    while ( p != null ) {
562
	filename *pn = p->next ;
563
	p->next = null ;
564
	if ( p->type == TDF_ARCHIVE ) {
565
	    if ( use_system_cc ) {
566
		error ( WARNING, "'%s' is a TDF archive", p->name ) ;
567
		p->type = DEFAULT_TYPE ;
568
	    } else {
569
		p = do_split_arch ( p ) ;
570
	    }
571
	}
572
	output = add_filename ( output, p ) ;
573
	p = pn ;
574
    }
575
    return ( output ) ;
576
}
577
 
578
 
579
/*
580
    BUILD A TDF ARCHIVE
581
 
582
    This routine creates a TDF archive from the input files, input,
583
    and returns the corresponding output files.
584
*/
585
 
586
static filename *apply_build_arch
587
    PROTO_N ( ( input ) )
588
    PROTO_T ( filename *input )
589
{
590
    filename *p = input ;
591
    filename *links = null ;
592
    filename *specs = null ;
593
    filename *others = null ;
594
    int spec_out = C_SPEC_1 ;
595
    while ( p != null ) {
596
	filename *pn = p->next ;
597
	p->next = null ;
598
	if ( p->type == INDEP_TDF ) {
599
	    links = add_filename ( links, p ) ;
600
	} else if ( p->type == C_SPEC ) {
601
	    specs = add_filename ( specs, p ) ;
602
	} else if ( p->type == CPP_SPEC ) {
603
	    specs = add_filename ( specs, p ) ;
604
	    spec_out = CPP_SPEC_1 ;
605
	} else {
606
	    others = add_filename ( others, p ) ;
607
	}
608
	p = pn ;
609
    }
610
    specs = do_link_specs ( specs, spec_out ) ;
611
    links = do_build_arch ( links ) ;
612
    if ( specs && links ) specs->uniq = links->uniq ;
613
    p = add_filename ( links, specs ) ;
614
    p = add_filename ( p, others ) ;
615
    return ( p ) ;
616
}
617
 
618
 
619
/*
620
    BUILD A TDF COMPLEX
621
 
622
    This routine creates a complex TDF capsule from the input files,
623
    input, and returns the corresponding output files.
624
*/
625
 
626
static filename *apply_build
627
    PROTO_N ( ( input ) )
628
    PROTO_T ( filename *input )
629
{
630
    filename *p = input ;
631
    filename *links = null ;
632
    filename *specs = null ;
633
    filename *others = null ;
634
    int spec_out = C_SPEC_1 ;
635
    while ( p != null ) {
636
	filename *pn = p->next ;
637
	p->next = null ;
638
	if ( p->type == INDEP_TDF ) {
639
	    links = add_filename ( links, p ) ;
640
	} else if ( p->type == C_SPEC ) {
641
	    specs = add_filename ( specs, p ) ;
642
	} else if ( p->type == CPP_SPEC ) {
643
	    specs = add_filename ( specs, p ) ;
644
	    spec_out = CPP_SPEC_1 ;
645
	} else {
646
	    others = add_filename ( others, p ) ;
647
	}
648
	p = pn ;
649
    }
650
    specs = do_link_specs ( specs, spec_out ) ;
651
    links = do_tdf_build ( links ) ;
652
    if ( specs && links ) specs->uniq = links->uniq ;
653
    p = add_filename ( links, specs ) ;
654
    p = add_filename ( p, others ) ;
655
    return ( p ) ;
656
}
657
 
658
 
659
/*
660
    APPLY THE PREPROCESSOR
661
 
662
    This routine applies the preprocessor to the input files, input,
663
    and returns the corresponding output files.
664
*/
665
 
666
static filename *apply_preproc
667
    PROTO_N ( ( input ) )
668
    PROTO_T ( filename *input )
669
{
670
    filename *p = input ;
671
    filename *output = null ;
672
    if ( use_system_cc ) return ( apply_cc ( input ) ) ;
673
    while ( p != null ) {
674
	filename *pn = p->next ;
675
	p->next = null ;
676
	if ( p->type == C_SOURCE ) p = do_preproc ( p ) ;
677
	else if ( p->type == CPP_SOURCE ) p = do_cpp_preproc ( p ) ;
678
	output = add_filename ( output, p ) ;
679
	p = pn ;
680
    }
681
    return ( output ) ;
682
}
683
 
684
 
685
/*
686
    APPLY THE TDF PRETTY PRINTER
687
 
688
    This routine applies the TDF pretty printer to the input files,
689
    input, and returns the corresponding output files.
690
*/
691
 
692
static filename *apply_pretty
693
    PROTO_N ( ( input ) )
694
    PROTO_T ( filename *input )
695
{
696
    filename *p = input ;
697
    filename *output = null ;
698
    while ( p != null ) {
699
	filename *pn = p->next ;
700
	p->next = null ;
701
	if ( make_tspec ) {
702
	    if ( p->type == C_SPEC ) p = do_pretty ( p ) ;
703
        } else if ( p->type == INDEP_TDF ) {
704
	    if ( make_pretty == 2 ) p = apply_tdf_link ( p ) ;
705
	    p = do_pretty ( p ) ;
706
	} else if ( p->type == DEP_TDF ) {
707
	    p = do_pretty ( p ) ;
708
	}
709
	output = add_filename ( output, p ) ;
710
	p = pn ;
711
    }
712
    return ( output ) ;
713
}
714
 
715
 
716
/*
717
    APPLY THE ARCHIVER TO UNJOIN C SPEC FILES
718
 
719
    This routine scans input for input archives of type t.  It splits these
720
    into their component files.  For internal archives the contents are
721
    in the aux field.
722
*/
723
 
724
static filename *apply_unjoin
725
    PROTO_N ( ( input, t ) )
726
    PROTO_T ( filename *input X int t )
727
{
728
    filename *p = input ;
729
    filename *output = null ;
730
    archive_type = t ;
731
    while ( p != null ) {
732
	filename *pn = p->next ;
733
	p->next = null ;
734
	if ( p->type == t ) {
735
	    if ( p->storage == INPUT_FILE ) {
736
		if ( is_archive ( p->name ) ) p = do_split_arch ( p ) ;
737
	    } else if ( p->aux != null ) {
738
		p = p->aux ;
739
	    }
740
	}
741
	output = add_filename ( output, p ) ;
742
	p = pn ;
743
    }
744
    return ( output ) ;
745
}
746
 
747
 
748
/*
749
    APPLY ALL THE COMPILATION STAGES
750
 
751
    This routine applies all the compilation stages to the input files,
752
    input, and returns the corresponding output files.
753
*/
754
 
755
filename *apply_all
756
    PROTO_N ( ( input ) )
757
    PROTO_T ( filename *input )
758
{
759
    filename *p = input ;
760
 
761
    /* Set up file types */
762
    if ( allow_specs ) binary_obj_type = BINARY_OBJ_AUX ;
763
 
764
    /* Preprocessing is a special case */
765
    if ( make_preproc ) return ( apply_preproc ( p ) ) ;
766
 
767
    /* Any TDF archives are split immediately */
768
    p = apply_split_arch ( input ) ;
769
 
770
    /* Deal with building TDF archive case */
771
    if ( make_archive ) {
772
	p = apply_compile ( p, 1 ) ;
773
	if ( make_complex ) p = apply_build ( p ) ;
774
	return ( apply_build_arch ( p ) ) ;
775
    }
776
 
777
    /* Deal with pretty printing case */
778
    if ( make_pretty ) {
779
	p = apply_compile ( p, 1 ) ;
780
	if ( make_complex ) p = apply_build ( p ) ;
781
	return ( apply_pretty ( p ) ) ;
782
    }
783
 
784
    /* Deal with building TDF complex */
785
    if ( make_complex ) {
786
	p = apply_compile ( p, 1 ) ;
787
	p = apply_build ( p ) ;
788
    }
789
 
790
    /* Main compilation phases */
791
    p = apply_compile ( p, ( int ) checker ) ;
792
    if ( allow_specs && !stops [ BINARY_OBJ ] ) {
793
	p = apply_unjoin ( p, BINARY_OBJ ) ;
794
    }
795
    p = apply_link ( p ) ;
796
    return ( p ) ;
797
}