:
:	"SCCS File Type - "
:
:	"What identification string - @(#)Kcc	1.3"
:
goto commence
      /ksos/bin/Kcc -- synopsis
      /ksos/bin/Kcc [-I directory-or-indirect-file]... [-Dsymbol] ... file.c
      shell variables
              a       root part of file.c
              b       a string of flags to be passed to m4
              c       flags for the C compiler
              d       temporary -- the first part of a C flag
              e       the directory where mk_include lives
              f       file.o
              g       status returned by the C compiler
: commence
:       'Strip off m4+ include flags'
:       'Add all of the include files to b'
= b ""
while ."$1" = ".-I"
      = b "$b $1"
      shift
      = b "$b $1"
      shift
end
:       'Strip off C compiler preprocessor defines'
:       'Add the defines to c'
= c ""
while "$1"
      expr substr $1 1 2 | = d
      if "$d" != "-D" break
      = c "$c $1"
      shift
end
:       'put the filename followed by . in a'
expr substr $1 1 "(" length $1 - 1 ")" | = a
:       'f contains the filename.o'
= f $ao
:       'copy the rest of the calling to process_id.process_id'
cp $* $$.$$
:       'if there are any includes in the file, change them to ref the'
:       'file name enclosed in parenthesis'
if ! { grep "#incl" $$.$$ } goto m4loop
sh /ksos/bin/mak.ksos2 $$.$$
: m4loop
:       'pipe results of mk_include to m4+ using the -I files in b'
:       'and the other include files specified below; results are in'
:       'process_id.c'
/ksos/bin/mk_include -l $$.$$ | \
/ksos/bin/m4+ $b -I /usr/include \
-I /ksos/bin/include \
-I /gsb/include \
-I /gsb/kip/source - > $$.c
:      'if any more includes were generated by the m4+, change them'
:      ' to contain the filename using mak.ksos2 and re-m4+'
if ! { grep "#incl" $$.c } goto Compile
mv $$.c $$.$$
sh /ksos/bin/mak.ksos2 $$.$$
goto m4loop
:       'Compile the process_id.c file'
: Compile
/bin/cc -t0 -c -O $c $$.c
= g $r
rm $$.$$
mv $$.o $f
rm $$.c
exit $g
