#! /bin/csh -fe
# msCc base
# (input: base.{c2c.c,mob,mesa}) (output: `arch`/base.{c2c.o})
#
set tmpFile = "/tmp/msCc$$.o"
set dir = `arch`
set base = $argv[1]
/lib/cpp ${base}.c2c.c > ${base}.E
/bin/awk 'BEGIN {mesaSource = 0} \
/^#/ {if (mesaSource == 0) \
{if ($2 >= 123000 && $3 == "\"'$base'.mesa\"") \
mesaSource = 1} \
else if ($3 == "\"'$base'.c2c.c\"") continue} \
{print}' ${base}.E > ${base}.E.c
/lib/ccom -Xg ${base}.E.c > ${dir}/${base}.s
/usr/local/bin/msScript -mob ${base}.mob -as ${dir}/${base}.s -out ${dir}/${base}.mob.s
/bin/cc -c -o $tmpFile ${dir}/${base}.mob.s
/bin/ld -r -o ${dir}/${base}.c2c.o $tmpFile
/bin/rm -f $tmpFile ${base}.E.c ${base}.E ${dir}/${base}.mob.s ${dir}/${base}.s