set -e
DEFINES=
FILES=
INCLUDES=
for x in "$@"
do
	case "$x" in
	*.c)	FILES="$FILES $x" ;;
	-D*)    DEFINES="$DEFINES $x";;
	-I*)	INCLUDES="$INCLUDES $x";;
	*);;
	esac
done
tmp=/tmp/a00$$
for x in "$FILES"
do
	file=`basename $x .c`
	dir=`dirname $x`
	/lib/p1 -ef /lib/c1.err -il ${tmp} -f ${dir}/${file}.c -pc / -Q 24242 -A snd -Ze -Ol -DM_I86 -DM_I86SM -DM_SDATA -DM_STEXT -DM_I8086 -DMSDOS -DM_WORDSWAP ${DEFINES} -I/usr/include/dos ${INCLUDES} -W 1
	/lib/p2 -ef /lib/c23.err -il ${tmp} -Oc -Ol -Oa -Ot -G0 -A snd -W 1
	/lib/p3 -ef /lib/c23.err -il ${tmp} -T 0 -NM ${dir}/${file} -FPi -Ot -Oa -c ${file}.o  -A snd -CC 0sO
	rm -f ${tmp}*
done
