summary refs log tree commit diff
diff options
context:
space:
mode:
authorQuentin Carbonneaux <quentin.carbonneaux@yale.edu>2015-11-24 22:07:17 -0500
committerQuentin Carbonneaux <quentin.carbonneaux@yale.edu>2015-11-24 22:07:17 -0500
commitf54da035bc368eb593e671902bf67893a07d173b (patch)
tree8365b49b55d0177b341373c4e5aeaf49b45eb02a
parent2a5fb8d8f781e1fc0bd604c131a0e6f700b0722c (diff)
downloadroux-f54da035bc368eb593e671902bf67893a07d173b.tar.gz
nice compile script courtesy k0ga
-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
+
+