From 9b67d2b7dc6d14f61bbf5cc8241c62ade3ab7265 Mon Sep 17 00:00:00 2001 From: John Hodge Date: Sat, 1 Sep 2012 13:48:40 +0800 Subject: [PATCH] Tools/GCCProxy - Hacked up script to avoid patching gcc/binutils --- Tools/GCCProxy/gccproxy.sh | 72 +++++++++++++++++++++++++++++++++++++ Tools/GCCProxy/getconfig.mk | 10 ++++++ 2 files changed, 82 insertions(+) create mode 100755 Tools/GCCProxy/gccproxy.sh create mode 100644 Tools/GCCProxy/getconfig.mk diff --git a/Tools/GCCProxy/gccproxy.sh b/Tools/GCCProxy/gccproxy.sh new file mode 100755 index 00000000..11dd9e40 --- /dev/null +++ b/Tools/GCCProxy/gccproxy.sh @@ -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 index 00000000..bd0ce0d0 --- /dev/null +++ b/Tools/GCCProxy/getconfig.mk @@ -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)"' -- 2.20.1