-
Notifications
You must be signed in to change notification settings - Fork 30
/
CC3
executable file
·1165 lines (1094 loc) · 24.1 KB
/
CC3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/bin/sh
# /*ident "@(#)cls4:CC 1.30" */
###############################################################################
#
# C++ source for the C++ Language System, Release 3.0. This product
# is a new release of the original cfront developed in the computer
# science research center of AT&T Bell Laboratories.
#
# Copyright (c) 1993 UNIX System Laboratories, Inc.
# Copyright (c) 1991, 1992 AT&T and UNIX System Laboratories, Inc.
# Copyright (c) 1984, 1989, 1990 AT&T. All Rights Reserved.
#
# THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE of AT&T and UNIX System
#
# Laboratories, Inc. The copyright notice above does not evidence
# any actual or intended publication of such source code.
#
###############################################################################
# -----------------------------------------
CF=$(dirname $0)
CCROOTDIR=$CF
CCLIBDIR=$CF
TMPDIR=$CF/tmpdir
AON=+a1
LINE_OPT=+L
LIBRARY=$CF/libC.a
NMFLAGS=
DEMANGLE=1
PLUSI=0
cfrontC="$CF/cfront"
munch=$CF/munch
cplusfiltC=$CF/c++filt}
I=$CF/incl
LIBRARY=$CF/libC.a
TINYCC=$(which tcc)
if test -z "$TINYCC"
then
ccC="gcc -w"
cppC="gcc -Du3b -U__GNUC__ -D__cfront__ -D__cplusplus=1 -D__signed__= -D__null=0 -E"
else
ccC="tcc -w"
cppC="tcc -Du3b -U__GNUC__ -D__cfront__ -D__cplusplus=1 -D__signed__= -D__null=0 -E"
cppC="$cppC -U__SIZE_TYPE__ -D__SIZE_TYPE__=unsigned -U__PTRDIFF_TYPE__ -D__PTRDIFF_TYPE__=int"
fi
# -----------------------------------------
# This is the AT&T C++ driver.
# PT environment
PTPATH=$PATH
# end PT
#PATH=/bin:/usr/bin
# If 3D Files System will be used, there are several additions to the CC
# script that must be made. First of all, k-shell must be forced, instead
# of /bin/sh. To do this, change the first line of this script to force
# k shell to be used. Secondly, OPENWINHOME must be added to the PATH
# as shown below. Third, the shell variable I must be unset in this
# script. See comment around line 1006.
#if test "$OPENWINHOME" != ""; then
# PATH=$PATH:$OPENWINHOME/bin
#fi
# NOTE: To properly use the CC command you should check the values of the
# following variables to be sure they are the locations of the
# appropriate translator files on your system.
# directory containing cfront, c++filt, and patch/munch
CCROOTDIR=${CCROOTDIR-/usr/bin}
# directory containing the C++ libraries
CCLIBDIR=${CCLIBDIR-/usr/lib}
# colon-separated list of standard C++ include directories
I=${I-/usr/include/CC}
# set for +a0 (classic C style declarations) or +a1 (ANSI C style declarations)
AON=${AON-+a0}
# Set to "+L" to generate source line number information using the format
# "#line %d" instead of "# %d". Some cpp's have trouble when this is set,
# so the default is not to set the variable.
LINE_OPT=${LINE_OPT-}
# option passed to cc to tell linker to look for libraries in another
# directory. For example, -Wl,-L.
LOPT=${LOPT--L}
# 0 to disable linker output demangling
DEMANGLE=${DEMANGLE-1}
# id of C++ runtime library
LIB_ID=${LIB_ID-C}
# C++ runtime library
LIBRARY=${LIBRARY--l${LIB_ID}}
if test "$CCROOTDIR" != "" ;then
CCROOTDIR="$CCROOTDIR/"
fi
# location of cfront
cfrontC=${cfrontC-${CCROOTDIR}cfront}
# top level makefile will set this to MUNCH (default) or PATCH
PM_FLAG=MUNCH
if test "$PM_FLAG" = "PATCH"
then
# location of patch
patchC=${patchC-${CCROOTDIR}patch}
else
# location of munch
munchC=${munchC-${CCROOTDIR}munch}
# location of nm
NM=${NM-nm}
# NMFLAGS should be set to the options required to produce
# BSD or SysV.3 style nm output. Typically this involves
# specifying -p as an option (for example, on HP or SysV.4 systems).
NMFLAGS=${NMFLAGS-}
fi
# location of c++filt
cplusfiltC=${cplusfiltC-${CCROOTDIR}c++filt}
# location of C compiler
# if you want to use purify, add -Qpath $PURIFYHOME/nld (see next line).
# ccC=${ccC-"cc -Qpath $PURIFYHOME/nld"}
ccC=${ccC-cc}
# whatever extra options you always want passed
# to cpp, for example, -D-+ for nmake's cpp,
# -B for SunOS cpp, -Wp,-B for SVR4 cpp, and
# -C for other cpp's not supporting C++ "//" comments.
CPPFLAGS=${CPPFLAGS-}
# location of preprocessor
# for example, "cc -E" for SVR4 systems
# warning: cppC can get overridden by the -Y switch
cppC=${cppC-/lib/cpp}
# The following two environment variables are hooks for library providers
# 1 if CC -fs option is available
FS=${FS-0}
# whatever string the command line argument "-l++" should
# automatically expand into
LPPEXPAND=${LPPEXPAND-"-lg2++ -lGA -lGraph -l++"}
# PT setup
ptrdef="./ptrepository" # default repository
ptr=${ptrdef} # repository set by user
ptdmap="defmap"
ptroot=${CCROOTDIR}
ptcompC=${ptcompC-${ptroot}ptcomp}
ptlinkC=${ptlinkC-${ptroot}ptlink}
ptdef=
ptflags=
ptflags2=
ptflags3=
ptrlist=
ptscnt=0
ptT=
ptn=0
clg=0
ptrflag=0
ptiflag=0
ptd=0
PTHDR=${PTHDR-".h, .H, .hxx, .HXX, .hh, .HH, .hpp"}
PTSRC=${PTSRC-".c, .C, .cxx, .CXX, .cc, .CC, .cpp"}
# end PT
#############################################################
# You shouldn't have to change anything below this line
#############################################################
if test "$CCLIBDIR" = "/usr/lib"
then LLIBPATH=""
elif test -d /usr/alliant
then export LD_PATH="${LD_PATH-/lib /usr/lib /usr/local/lib} $CCLIBDIR"
else LLIBPATH="$LOPT$CCLIBDIR"
fi
# sys.fix will set SYS to the designated system
# it will then be defined for each CC invocation
#SYS=-DBSD
export CCROOTDIR
export cppC
# for Ansi compatibility, c_plusplus => __cplusplus
# for backward compatibility, retain c_plusplus for 2.0
CPLUS=-Dc_plusplus=1
cPLUS=-D__cplusplus=1
# variables for the C++ license manager
# Take the last directory of I for license file location.
CPLUSPLUS_LICENSE_FILE=`expr $I : '.*:\([^:]*\)' \| $I`/CPLUSPLUS.dat
# The following would check for the license file location as the first
# directory in I if this is preferred.
#CPLUSPLUS_LICENSE_FILE=`expr $I : '\([^:]*\)'`/CPLUSPLUS.dat
CPLUSPLUS_LICENSE_WARNING=45
export CPLUSPLUS_LICENSE_FILE CPLUSPLUS_LICENSE_WARNING
IDIRS=
while [ "$I" != "" ]; do
idir=`echo $I | sed 's/:.*$//'`
if [ "$idir" = "" ]; then
idir=.
fi
IDIRS="$IDIRS -I$idir"
case "$I" in
*:*) I=`echo $I | sed 's/^[^:]*://'`
;;
*) I=
esac
done
TMPDIR=${TMPDIR-/usr/tmp}
TEMPDIR=$TMPDIR/CC.$$
C= EE=0 FON= XON= O= EON=0 EC= EL= ELISTC= ELISTL= PTLISTC=
PON= R= SUF= X= DASHR= STRIP=
PLUSI=1
Z= E=0 OF= P=
ION=
NOLOAD= NLO=
AFAIL=0
OO="a.out"
OON= # for -o option
dotCcount=0 # counts up quantity of dot C files to -c option
FINALNAME=$OO
ISUF=${ISUF-".c"}
MVLIST=
APASS=0
defmem=D deflist=
Y="$CPPFLAGS"
rm -fr $TEMPDIR
trap 'rm -fr $TEMPDIR; exit' 1 2 3 13 15
mkdir $TEMPDIR
E=$?
if test $E -ne 0
then
echo "CC: error: cannot create temporary directory in $TEMPDIR: stop" 1>&2
exit $E
fi
for A in $PTOPTS "$@"
do
case $A in
# PT option parsing 1
-ptd*) if [ "$A" = "-ptd" ]
then
echo "CC[pt] warning: no pathname specified after $A" 1>&2
else
ptflags2="$ptflags2 $A"
ptd=1
fi
;;
-pti) ptiflag=1
;;
-ptr*) if [ "$A" = "-ptr" ]
then
echo "CC[pt] warning: no repository specified after $A" 1>&2
else
x=`echo $A | cut -c5-999`
ptrflag=1
if [ "$ptrlist" = "" ]
then
ptr=$x
ptrlist=" "
else
ptrlist="$ptrlist $x"
fi
fi
;;
-ptm*) if [ "$A" = "-ptm" ]
then
echo "CC[pt] warning: no load map pathname specified after $A" 1>&2
else
ptflags2="$ptflags2 $A"
fi
;;
-ptv) ptflags="$ptflags $A"
;;
-pta) ptflags2="$ptflags2 $A"
;;
-ptk) ptflags2="$ptflags2 $A"
;;
-pth) ptflags2="$ptflags2 $A"
;;
-pts) ptflags2="$ptflags2 $A"
;;
-ptt) ptflags2="$ptflags2 $A"
;;
-ptn) ptn=1
;;
-pto*) if [ "$A" = "-pto" ]
then
echo 'CC[pt] warning: no pathname specified after -pto' 1>&2
else
ptflags2="$ptflags2 $A"
fi
;;
*.[Cc]) if [ $ptscnt -eq 0 ]
then
ptscnt=1
elif [ $ptscnt -eq 1 ]
then
ptscnt=2
fi
dotCcount="`expr $dotCcount + 1`" # count up dot c's
;;
+T*) if [ "$A" = "+T" ]
then
echo "CC[pt] warning: no pathname specified after +T" 1>&2
elif [ "$ptT" != "" ]
then
echo "CC[pt] warning: second +Tfile illegal, ignored" 1>&2
else
ptT=$A
fi
;;
# end PT
-Yp,*) cppC=`expr $A : '-Yp,\(.*\)'`/`basename ${cppC}`
;;
-YI*) X="$X $A"
;;
-Y0*) X="$X $A"
;;
-Y2*) X="$X $A"
;;
-Ya*) X="$X $A"
;;
-Y*) Z="$Z $A"
;;
+a?) AON=$A
;;
-E) PON=1
;;
-F) FON=1
;;
-Fc) FON=1
;;
-C) Y="$Y $A"
;;
-P) PON=1 # pre-process only
Y="$Y $A"
SUF=".i"
NOLOAD=".i"
;;
-H) Y="$Y $A"
;;
-S*) if test "$NOLOAD" != ".i"
then
NOLOAD=".s"
NLO="$A"
fi
;;
-c*) if test "$NOLOAD" != ".i"
then
if test "$NOLOAD" != ".s"
then
NOLOAD=".o"
NLO="-c"
fi
fi
;;
-fs) if [ $FS -eq 1 ]
then Y="$Y -fs"
else echo "CC: -fs not available (ignoring -fs)" 1>&2
fi
;;
-I*) if test "$A" != "-I"
then
Y="$Y $A"
else
ION=1
fi
;;
-D*) eval $defmem='"$A"'
deflist="$deflist \"\$$defmem\""
defmem=${defmem}x
# PT option parsing 2
ptdef="$ptdef $A"
# end PT
;;
-U*) Y="$Y $A"
;;
-g) Z="$Z $A"
X="$X $A"
# O="$O +g"
;;
-gdump) O="$O +g"
PTLISTC="$PTLISTC $A"
;;
-gdem) O="$O +U"
PTLISTC="$PTLISTC $A"
;;
-ec) EON=1
;;
-el) EON=2
;;
-ispeed)O="$O +J100"
PTLISTC="$PTLISTC $A"
;;
-ispace)O="$O +J3"
PTLISTC="$PTLISTC $A"
;;
-o*) OON=1 # for -o option
;;
*) if test $ION
then
Y="$Y -I$A"
ION=""
fi
;;
esac
done
# if more than one dot C with the -c option, and -o option is used,
# then give a warning.
if test "$NOLOAD" != "" -a "$OON" = "1" -a "$dotCcount" -gt 1; then
echo "CC: Warning: -o option ignored" 1>&2
fi
if test "$AON" = "+a1"; then
Y="$Y -D__CFRONT_ANSI_OPT"
fi
for A do
case $A in
# PT option parsing 3
-pti) ;;
-ptd*) ;;
-ptr*) ;;
-ptm*) ;;
-ptv) ;;
-pta) ;;
-ptk) ;;
-pth) ;;
-ptt) ;;
-pts) ;;
-ptn) ;;
-pto*) ;;
+T*) ;;
# end PT
-Y*) ;;
+S) echo "CC: +S no longer accepted (ignored)" >&2
;;
+V) echo "CC: +V no longer accepted (ignored)" >&2
;;
+i) PLUSI=1
;;
-s) STRIP=1
;;
+x) XON=1
;;
+a?) ;;
+*) if test $EON -eq 1
then
EC="$EC $A"
ELISTC="$ELISTC -ec $A"
EON=0
elif test $EON -eq 2
then
EL="$EL $A"
ELISTL="$ELISTL -el $A"
EON=0
else
O="$O $A"
PTLISTC="$PTLISTC $A"
fi
;;
-E) ;;
-fs) ;;
-F) ;;
-Fc) ;;
-C) ;;
-P) ;;
-H) ;;
-D*) ;;
-U) ;;
-I*) if test "$A" = "-I"
then
ION=1
fi
;;
-S*) ;;
-P) ;;
-c*) ;;
-p|-pg) P="$P $A"
AUXSUF="_p"
if [ $LIBRARY = "-lC" -a -r $CCLIBDIR/libC_p.a ]
then
LIBRARY=-lC_p
fi
;;
-g) ;;
-gdump) ;;
-gdem) ;;
-ispeed);;
-ispace);;
-ec) EON=1
;;
-el) EON=2
;;
-r) DASHR=1
Z="$Z $A"
;;
-o*) if test "$A" != "-o"
then
OO=`expr $A : '-o\(.*\)'`
FINALNAME=$OO
A="-o $OO"
else
OX=1
fi
OF="$OF $A"
Z="$Z $A"
;;
-.c) echo "CC: bad suffix option: -.c (ignored)" 1>&2
;;
-.*) SUF=`expr "$A" : '-\(.*\)'`
;;
*.[Cc]) if test -f $A
then
case $A in
*.c) B=`basename $A .c`; CXX_FILE=0 ;;
*.C) B=`basename $A .C`; CXX_FILE=1 ;;
esac
if test $PON
then
if test $SUF
then
echo "$cppC $O $A > $B$SUF:" 1>&2
eval '$cppC' '$Y' $deflist '$CPLUS' '$cPLUS' '$SYS' '$IDIRS' '$A' \>$B$SUF
E=$?
else
#echo "$cppC $Y $deflist $CPLUS $cPLUS $SYS $IDIRS $A" 1>&2
eval '$cppC' '$Y' $deflist '$CPLUS' '$cPLUS' '$SYS' '$IDIRS' '$A'
E=$?
fi
case $E in
0) ;;
*) AFAIL=1; break
;;
esac
elif test $FON
then
if test $SUF
then
echo "$cfrontC $O $A > $B$SUF:" 1>&2
eval '$cppC' '$Y' $deflist '$CPLUS' '$cPLUS' '$SYS' '$IDIRS' '$A' \>$TEMPDIR/cpptmp
E=$?
if test $E -ne 0
then
echo "CC: cpp failure: $E" 1>&2
AFAIL=1; break
fi
$cfrontC ${LINE_OPT} +f$A $O $AON <$TEMPDIR/cpptmp >$B$SUF
E=$?
else
eval '$cppC' '$Y' $deflist '$CPLUS' '$cPLUS' '$SYS' '$IDIRS' '$A' \>$TEMPDIR/cpptmp
E=$?
if test $E -ne 0
then
echo "CC: cpp failure: $E" 1>&2
AFAIL=1; break
fi
$cfrontC ${LINE_OPT} +f$A $O $AON <$TEMPDIR/cpptmp
E=$?
fi
case $E in
0) ;;
*) AFAIL=1; break
;;
esac
elif test $CXX_FILE != 1
then
# C file, add to list to be compiled in $TEMPDIR
X="$X $B.c"
cp $A $TEMPDIR/$B.c
Z="$Z $TEMPDIR/$B.o" # add object entry to the load list
APASS=1 # setting APASS to 1 causes link step to execute
else
echo "CC $O $A:" 1>&2
#echo "$cppC $Y $deflist $CPLUS $cPLUS $SYS $IDIRS $A" 1>&2
eval '$cppC' '$Y' $deflist '$CPLUS' '$cPLUS' '$SYS' '$IDIRS' '$A' \>$TEMPDIR/cpptmp
E=$?
if test $E -ne 0
then
echo "CC: cpp failure: $E" 1>&2
AFAIL=1; break
fi
# PT compile-time actions
# set up for directed mode
if [ "$ptT" = "" -a $ptscnt -eq 1 -a "$NLO" != "-c" -a $ptn -eq 0 ]
then
clg=1
fi
if [ $clg -eq 1 ]
then
x=$TEMPDIR/dirinst
echo '@all' > $x
x="+T$x +s"
elif [ "$ptT" != "" ]
then
x="$ptT +s"
else
x=$TEMPDIR/dirinst
echo '@none' > $x
x="+T$x +s"
fi
$cfrontC ${LINE_OPT} +f$A $x +t$TEMPDIR/ptcf $O $AON <$TEMPDIR/cpptmp >$TEMPDIR/$B$ISUF
E=$?
R=1
C="$C $TEMPDIR/$B$ISUF"
case $E in
0) X="$X $B$ISUF"
#if test "$NOLOAD" != ".c"
#then
Z="$Z $TEMPDIR/$B.o"
#fi
MVLIST="$MVLIST $B"
OLDAPASS=$APASS
APASS=1
# see if any templates encountered
err=0
grep '^[tf] ' $TEMPDIR/ptcf >/dev/null 2>&1
err2=$?
# create repository if have to
if [ $err2 -eq 0 -a ! -d $ptr ]
then
mkdir $ptr 2>/dev/null
err=$?
if [ "$ptr" = "$ptrdef" ]
then
ptflags3="$ptflags3 -ptd"
fi
fi
if [ $err -ne 0 ]
then
echo "CC[ptcomp] warning: could not create repository $ptr, ignoring type information" 1>&2
elif [ -d $ptr -a ! -w $ptr ]
then
echo "CC[ptcomp] warning: repository $ptr is not writable, ignoring type information" 1>&2
# update repository
elif [ $err2 -eq 0 -o -d $ptr ]
then
sort -u $TEMPDIR/ptcf >$TEMPDIR/ptcf2
if [ "$ptT" != "" ]
then
ptflags3="-ptl"
fi
# get include list
ptincl=$TEMPDIR/ptincl
> $ptincl
for pti in $Y $IDIRS
do
echo $pti
done > $ptincl
PATH=$PTPATH $ptcompC $ptflags $ptflags3 $ptr $TEMPDIR/ptcf2 $ptdmap $A $ptincl
progname=$A
if test "$OON"
then
progname=$FINALNAME
fi
# PATH=$PTPATH $ptcompC $ptflags $ptflags3 $ptr $TEMPDIR/ptcf2 $ptdmap $progname $ptincl
if [ $? -ne 0 ]
then
AFAIL=1
APASS=$OLDAPASS
fi
fi
# end PT
;;
127) echo "Too many compilation errors" 1>&2
AFAIL=1
;;
999) echo "CC argument error" 1>&2
AFAIL=1
;;
1) echo "1 error" 1>&2
AFAIL=1
;;
*) echo "$E errors" 1>&2
AFAIL=1
;;
esac
fi
else
echo "CC: $A not found" 1>&2
EE=1
fi
;;
*.h) if test -f $A
then
B=`basename $A .h`
if test $PON
then
if test $SUF
then
echo "$cppC $O $A > $B$SUF:" 1>&2
eval '$cppC' '$Y' $deflist '$CPLUS' '$cPLUS' '$SYS' '$IDIRS' '$A' \>$B$SUF
E=$?
else
eval '$cppC' '$Y' $deflist '$CPLUS' '$cPLUS' '$SYS' '$IDIRS' '$A'
E=$?
fi
case $E in
0) ;;
*) AFAIL=1; break
;;
esac
else
echo "CC: error: file with unknown suffix: $A" 1>&2
fi
else
echo "CC: $A not found" 1>&2
EE=1
fi
;;
*.i) if test -f $A
then
if test $PON
then
echo "CC -E $A incompatible: ignoring $A" 1>&2
else
if test $FON
then
#eval '$cppC' '$Y' $deflist '$CPLUS' '$cPLUS' '$SYS' '$IDIRS' '$A' \>$TEMPDIR/cpptmp
#if test $? -ne 0
#then
# echo "CC: cpp failure: $E" 1>&2
# AFAIL=1; break
#fi
#$cfrontC +L +f$A $O $AON <$TEMPDIR/cpptmp
$cfrontC ${LINE_OPT} +f$A $O $AON < $A
if test $? -ne 0
then
AFAIL=1
fi
else
B=`basename $A .i`
echo "CC $O $A:" 1>&2
$cfrontC ${LINE_OPT} +f$A $O $AON < $A > $TEMPDIR/$B$ISUF
E=$?
R=1
C="$C $TEMPDIR/$B$ISUF"
case $E in
0) X="$X $B$ISUF"
#if test "$NOLOAD" != "-c"
#then
Z="$Z $TEMPDIR/$B.o"
#fi
MVLIST="$MVLIST $B"
APASS=1
;;
*) AFAIL=1
;;
esac
fi
fi
else
echo "CC: $A not found" 1>&2
EE=1
fi
;;
*.s) # add to list to be compiled in $TEMPDIR, set flag to go on
B=`basename $A .s`
X="$X $B.s"
cp $A $TEMPDIR/$B.s
APASS=1
#if test "$NOLOAD" != "-c"
#then
# add object entry to the load list
Z="$Z $TEMPDIR/$B.o"
#fi
;;
*.[ao]) Z="$Z $A" # pass archives to CC
if test $OX
then
OO=$A
FINALNAME=$OO
OF="$OF $A"
OX=""
else
X="$X $A"
fi
APASS=1 # setting APASS to 1 causes link step to execute
;;
-l++) for i in $LPPEXPAND
do
LIB_IDZZZ=`expr $i : '-l\(.*\)'`
if [ -r $CCLIBDIR/lib$LIB_IDZZZ$AUXSUF.a ]
then
Z="$Z $i$AUXSUF"
X="$X $i$AUXSUF"
else
Z="$Z $i"
X="$X $i"
fi
done
# Z="$Z $LPPEXPAND"
# X="$X $LPPEXPAND"
;;
*) if test $XON
then
O="$O +x$A"
PTLISTC="$PTLISTC +x$A"
XON=""
elif test $ION
then
ION=""
X="$X -I$A"
elif test $EON -eq 1
then
EC="$EC $A"
ELISTC="$ELISTC -ec $A"
EON=0
elif test $EON -eq 2
then
EL="$EL $A"
ELISTL="$ELISTL -el $A"
EON=0
else
Z="$Z $A"
if test $OX
then
OO=$A
FINALNAME=$OO
OF="$OF $A"
OX=""
else
X="$X $A"
fi
fi
;;
esac
done
case $APASS in
0) ;;
*) # generate code
if test "$PLUSI" #leave ..c's lying around
then
#remove #line's from the ..c's for sdb
for f in $C
do
sed "/^#/d" $f >$TEMPDIR/temp
mv $TEMPDIR/temp $f 2> /dev/null
done
fi
#if one file failed in cpp or cfront then do not create a.out
if test $AFAIL -eq 1
then
if test -z "$NOLOAD"
then
NOLOAD=".o"
NLO="-c"
fi
fi
if test "$NOLOAD"
then
# make sure there are some .c, .s, or .i files in X
ANY_CS=`expr "$X" : '.*\(\.[CcSsi]\).*'`
if test "$ANY_CS"
then
echo "$ccC $EC $P $NLO $X" 1>&2
# contortions to cope with bug handling path in cc
#compile, no load
(cd $TEMPDIR; $ccC $EC $P $NLO $X)
EE=$?
if test $EE = 0
then
# move products back into current directory
ls $TEMPDIR/*$NOLOAD >$TEMPDIR/_lsout_ 2>/dev/null
if test -s $TEMPDIR/_lsout_
then
# if -c and -o were both specified,
# and only one source file was
# specified, put the resulting .o in
# the file specified with the -o option
if test "$NOLOAD" != "" -a "$OON" -a "$dotCcount" -lt 2; then
mv $TEMPDIR/*$NOLOAD $FINALNAME 2>/dev/null
else
mv $TEMPDIR/*$NOLOAD . 2> /dev/null
fi
fi
fi
fi
else
echo "$ccC $EL $P $LLIBPATH $OF $X $LIBRARY" 1>&2
# run cc on the cfront-generated files.
# first have to remove .o's from the argument list
# passed to cc, since some cc's don't like .o's with -c
cfiles=
xxx=
for x in $X
do
case $x in
*${ISUF}) cfiles="$cfiles $x"
;;
*.o) ;;
*.a) ;;
*) xxx="$xxx $x"
;;
esac
done
if [ "$cfiles" != "" ]
then
#echo "$ccC $P -c $xxx $cfiles in $TEMPDIR" 1>&2
(cd $TEMPDIR; $ccC $EC $P -c $xxx $cfiles) # compile, no load
EE=$? # don't link if there was an error
else
EE=0 # okay to link
fi
case $EE in
0) # load
#echo "$ccC $P $LLIBPATH $Z $LIBRARY"
# PT link-time actions
PTEE=0
grep "@de[cf]" $ptr/$ptdmap >/dev/null 2>&1
x=$?
if [ $ptiflag -eq 0 -a \( $x -eq 0 -o $ptrflag -eq 1 \) ]
then
ptincl=$TEMPDIR/ptincl
ptin=$TEMPDIR/ptin
ptout=$TEMPDIR/ptout
ptccopt=$TEMPDIR/ptccopt
ptrlistx=$TEMPDIR/ptrlistx
> $ptincl
> $ptin
> $ptout
> $ptccopt
> $ptrlistx
# get include list
for pti in $Y $ptdef $CPLUS $cPLUS $SYS $IDIRS
do
echo $pti
done > $ptincl
# build list of input files and options
skipflag=0
LIBLIST=
for pti in $P $Z $LIBRARY
do
if [ $skipflag -eq 1 ]
then
skipflag=0
continue
fi
x=`echo $pti | cut -c1-1`
if [ "$x" != "-" -a "$x" != "+" ]
then
echo $pti >>$ptin
elif [ "$pti" = "-o" -o "$pti" = "-I" -o "$pti" = "-D" -o "$pti" = "-U" ]
then
skipflag=1
else
x=`echo $pti | cut -c1-2`
xx=`echo $pti | cut -c3-99`
if [ "$x" = "-l" -a -f $CCLIBDIR/lib${xx}.a ]
then
echo $CCLIBDIR/lib${xx}.a >>$ptin
elif [ "$x" = "-L" ]
then
LIBLIST="$LIBLIST $xx"
elif [ "$x" = "-l" ]
then
for LIBDIR in $LIBLIST
do
if [ -f $LIBDIR/lib${xx}.a ]
then
echo $LIBDIR/lib${xx}.a >>$ptin
fi
done
elif [ "$x" != "-I" -a "$x" != "-D" -a "$x" != "-U" ]
then