#!/bin/csh -f

set cpp_args=(-I/usr/local/lib/as11)
set other_args=()

foreach arg ($argv[2-])
  if ($arg =~ -D* || $arg =~ -I*) then
    set cpp_args=($cpp_args $arg)
  else
    set other_args=($other_args $arg)
  endif
end

set echo
cc -E $cpp_args ${1:r}.asm > /tmp/$$.asm
cc -E $cpp_args ${1:r}.asm > /tmp/$$.asm
as11 /tmp/$$.asm $other_args
rm /tmp/$$.asm
mv /tmp/$$.s19 ${1:r}.s19
