| 1 |
#!/bin/sh |
| 2 |
|
| 3 |
DIR=`cd $(dirname $0); pwd` |
| 4 |
QBE=$DIR/../qbe |
| 5 |
|
| 6 |
usage() |
| 7 |
{ |
| 8 |
echo "usage: mcc [LDFLAGS] file.c" >&2 |
| 9 |
exit 1 |
| 10 |
} |
| 11 |
|
| 12 |
for i |
| 13 |
do |
| 14 |
case $i in |
| 15 |
-*) |
| 16 |
flags="$flags $i" |
| 17 |
;; |
| 18 |
*) |
| 19 |
if ! test -z $file |
| 20 |
then |
| 21 |
usage |
| 22 |
fi |
| 23 |
file=$i |
| 24 |
;; |
| 25 |
esac |
| 26 |
done |
| 27 |
|
| 28 |
if test -z $file |
| 29 |
then |
| 30 |
usage |
| 31 |
fi |
| 32 |
|
| 33 |
|
| 34 |
$DIR/minic < $file > /tmp/minic.ssa && |
| 35 |
$QBE < /tmp/minic.ssa > /tmp/minic.s && |
| 36 |
cc /tmp/minic.s $flags |
| 37 |
|
| 38 |
if test $? -ne 0 |
| 39 |
then |
| 40 |
echo "error processing file $file" >&2 |
| 41 |
exit 1 |
| 42 |
fi |
| 43 |
|
| 44 |
|