Tools/GCCProxy - Hacked up script to avoid patching gcc/binutils
authorJohn Hodge <[email protected]>
Sat, 1 Sep 2012 05:48:40 +0000 (13:48 +0800)
committerJohn Hodge <[email protected]>
Sat, 1 Sep 2012 05:48:40 +0000 (13:48 +0800)
Tools/GCCProxy/gccproxy.sh [new file with mode: 0755]
Tools/GCCProxy/getconfig.mk [new file with mode: 0644]

diff --git a/Tools/GCCProxy/gccproxy.sh b/Tools/GCCProxy/gccproxy.sh
new file mode 100755 (executable)
index 0000000..11dd9e4
--- /dev/null
@@ -0,0 +1,72 @@
+#!/bin/bash
+
+# Get invocation path (which could be a symlink in $PATH)
+fullpath=`which "$0"`
+if [[ !$? ]]; then
+       fullpath="$0"
+fi
+
+# Resolve symlink
+fullpath=`readlink -f "$fullpath"`
+
+# Get base directory
+BASEDIR=`dirname "$fullpath"`
+
+cfgfile=`mktemp`
+make --no-print-directory -f $BASEDIR/getconfig.mk ARCH=x86 > $cfgfile
+#echo $cfgfile
+#cat $cfgfile
+. $cfgfile
+rm $cfgfile
+
+_miscargs=""
+_compile=0
+
+while [[ $# -gt 0 ]]; do
+       case "$1" in
+       -c)
+               _compile=1
+               ;;
+       -o)
+               shift
+               _outfile="-o $1"
+               ;;
+       -I)
+               shift
+               _cflags=$_cflags" -I$1"
+               ;;
+       -I*|-D*|-O*)
+               _cflags=$_cflags" $1"
+               ;;
+       -Wl,*)
+               arg=$1
+               arg=${arg#-Wl}
+               arg=${arg/,/ }
+               _ldflags=$_ldflags" ${arg}"
+               ;;
+       -l)
+               shift
+               _libs=$_libs" -l$1"
+               ;;
+       -l*)
+               _libs=$_libs" $1"
+               ;;
+       *)
+               _miscargs=$_miscargs" $1"
+               ;;
+       esac
+       shift
+done
+
+if [[ $_compile -eq 1 ]]; then
+#      echo $_CC $CFLAGS $*
+       $_CC $CFLAGS $_miscargs -c $_outfile
+else if echo " $_miscargs" | grep '\.c' >/dev/null; then
+       tmpout=`mktemp acess_gccproxy.XXXXXXXXXX.o --tmpdir`
+       $_CC $CFLAGS $_miscargs -c -o $tmpout
+       $_LD $LDFLAGS $_ldflags $_libs $tmpout $_outfile
+       rm $tmpout
+else
+       $_LD $LDFLAGS $_ldflags $_miscargs $_outfile $LIBGCC_PATH
+fi; fi
+
diff --git a/Tools/GCCProxy/getconfig.mk b/Tools/GCCProxy/getconfig.mk
new file mode 100644 (file)
index 0000000..bd0ce0d
--- /dev/null
@@ -0,0 +1,10 @@
+include $(dir $(lastword $(MAKEFILE_LIST)))../../Usermode/Applications/Makefile.cfg
+
+.PHONY: shellvars
+
+shellvars:
+       @echo '_CC="$(CC)"'
+       @echo '_LD="$(LD)"'
+       @echo 'LDFLAGS="$(LDFLAGS)"'
+       @echo 'CFLAGS="$(CFLAGS)"'
+       @echo 'LIBGCC_PATH="$(LIBGCC_PATH)"'

UCC git Repository :: git.ucc.asn.au