From f54da035bc368eb593e671902bf67893a07d173b Mon Sep 17 00:00:00 2001 From: Quentin Carbonneaux Date: Tue, 24 Nov 2015 22:07:17 -0500 Subject: nice compile script courtesy k0ga --- minic/mcc | 77 +++++++++++++++++++++++++++++++++------------------------------ 1 file 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 + + -- cgit 1.4.1