summary refs log tree commit diff
diff options
context:
space:
mode:
-rwxr-xr-xminic/mcc77
1 files changed, 40 insertions, 37 deletions
diff --git a/minic/mcc b/minic/mcc
index c153370..dd662f1 100755
--- a/minic/mcc
+++ b/minic/mcc
@@ -1,37 +1,40 @@
-#!/usr/bin/python2
-
-import sys
-import subprocess
-
-root=".."
-ssafile = '/tmp/minic.ssa'
-asmfile = '/tmp/minic.s'
-cc = '/usr/bin/gcc'
-
-ccargs = []
-cfile = None
-
-for a in sys.argv[1:]:
-	if a[0] == '-':
-		ccargs.append(a)
-	else:
-		cfile = a
-
-if not cfile:
-	print >>sys.stderr, "usage: mcc [LDFLAGS] file.c"
-	sys.exit(1)
-
-ret = subprocess.call(root + "/minic/minic < " + cfile + " >" + ssafile, shell=True)
-if not ret == 0:
-	print >>sys.stderr, "minic failed (%d)" % ret
-	sys.exit(1)
-
-ret = subprocess.call(root + "/lisc/lisc <" + ssafile + " >" + asmfile, shell=True)
-if not ret == 0:
-	print >>sys.stderr, "backend failed (%d)" % ret
-	sys.exit(1)
-
-ret = subprocess.call([cc, asmfile] + ccargs)
-if not ret == 0:
-	print >>sys.stderr, "linking failed (%d)" % ret
-	sys.exit(1)
+#!/bin/sh
+
+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
+
+
+../minic/minic < $file        > /tmp/minic.ssa &&
+../lisc/lisc < /tmp/minic.ssa > /tmp/minic.s   &&
+cc $flags /tmp/minic.s
+
+if test $? -ne 0
+then
+	echo "error processing file $file" >&2
+fi
+
+