#!/bin/rc

FRAME = none

fn usage {
	echo 'Usage: makegen {-asm|-hll} type'
	exit 1
}

if (~ $#* 0) usage

switch(x$1) {
case x-hll
	FRAME = hll
	shift
case x-asm
	FRAME = asm
	shift
case *
	usage
}

if (~ $#* 0 || ~ $FRAME none) usage

OUTFILE = txcg$1.t
DEFFILE = cg$1.def
FRAMEFILE = txcg_$FRAME^_frame

if (! test -f $DEFFILE) {
	echo MAKEGEN: cannot open definition file: $DEFFILE
	exit 1
}

if (! test -f $FRAMEFILE) {
	echo "MAKEGEN: cannot open file file: $FRAMEFILE"
	exit 1
}

cp $FRAMEFILE txcg_frame
./txcgg <$DEFFILE > $OUTFILE.pp
rm txcg_frame

../compiler/txpp <$OUTFILE.pp >$OUTFILE
rm $OUTFILE.pp

./txboot.rc $OUTFILE 
