summary refs log tree commit diff
path: root/minic/mcc
blob: 77d3d3351c0a7e38b3493c3e612b4f10fc93d27a (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/../obj/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