summary refs log tree commit diff
path: root/minic/mcc
blob: 492947e86e637e32d95a2727cf748adc1c925d7b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/bin/sh

DIR=`cd $(dirname $0); pwd`
QBE=$DIR/../qbe

usage()
{
	echo "usage: mcc [LDFLAGS] file.c" >&2
	exit 1
}

for i
do
	case $i in
	-*)
		flags="$flags $i"
		;;
	*)
		if ! test -z $file
		then
			usage
		fi
		file=$i
		;;
	esac
done

if test -z $file
then
	usage
fi


$DIR/minic < $file          > /tmp/minic.ssa &&
$QBE       < /tmp/minic.ssa > /tmp/minic.s   &&
cc /tmp/minic.s $flags

if test $? -ne 0
then
	echo "error processing file $file" >&2
	exit 1
fi