X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=Tools%2FGCCProxy%2Fgccproxy.sh;h=59880812f7fa3a29c390efc40a7109f1a6f2de5b;hb=98bd9c0c8985c50c42231c116a4e18fedd47761e;hp=11dd9e40dbb017a9662b248c944d81f6ad825266;hpb=9b67d2b7dc6d14f61bbf5cc8241c62ade3ab7265;p=tpg%2Facess2.git diff --git a/Tools/GCCProxy/gccproxy.sh b/Tools/GCCProxy/gccproxy.sh index 11dd9e40..59880812 100755 --- a/Tools/GCCProxy/gccproxy.sh +++ b/Tools/GCCProxy/gccproxy.sh @@ -1,5 +1,7 @@ #!/bin/bash +toolname=${0##*-} + # Get invocation path (which could be a symlink in $PATH) fullpath=`which "$0"` if [[ !$? ]]; then @@ -12,18 +14,22 @@ 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 +_linktype=Applications + +echo [GCCProxy] $toolname $* >&2 + + while [[ $# -gt 0 ]]; do case "$1" in + -E) + _preproc=1 + ;; + -M) + _makedep=1 + ;; -c) _compile=1 ;; @@ -31,9 +37,13 @@ while [[ $# -gt 0 ]]; do shift _outfile="-o $1" ;; - -I) + -shared) + _ldflags=$_ldflags" -shared -lc -lgcc" + _linktype=Libraries + ;; + -I|-D|-O) + _cflags=$_cflags" $1 $2" shift - _cflags=$_cflags" -I$1" ;; -I*|-D*|-O*) _cflags=$_cflags" $1" @@ -44,13 +54,45 @@ while [[ $# -gt 0 ]]; do arg=${arg/,/ } _ldflags=$_ldflags" ${arg}" ;; - -l) + -Wall|-Werror|-Wextra)\ + _cflags=$_cflags" $1" + ;; + -l|-L) + _libs=$_libs" $1$2" shift - _libs=$_libs" -l$1" ;; - -l*) + -l*|-L*) _libs=$_libs" $1" ;; + -v|--version|-V) + _verarg=$_verarg" $1" + ;; + --inv=ld) + _actas=ld + ;; + -pthread) + _ldflags=$_ldflags" -lpthread" + ;; + -print-prog-name=ld) + echo $0 --inv=ld + exit 0 + ;; + -print-search-dirs) + _compile=1 + _cflags=$_cflags" $1" + ;; + -print-multi-os-directory) + _compile=1 + _cflags=$_cflags" $1" + ;; + -dumpspecs) + _compile=1 + _miscargs=$_miscargs" $1" + ;; + -dumpversion) + _compile=1 + _miscargs=$_miscargs" $1" + ;; *) _miscargs=$_miscargs" $1" ;; @@ -58,15 +100,66 @@ while [[ $# -gt 0 ]]; do shift done -if [[ $_compile -eq 1 ]]; then -# echo $_CC $CFLAGS $* - $_CC $CFLAGS $_miscargs -c $_outfile -else if echo " $_miscargs" | grep '\.c' >/dev/null; then +run() { + if [[ "x$GCCPROXY_DEBUG" != "x" ]]; then + echo --- $* + fi + $* + return $? +} + +_ldflags="-lposix -lpsocket "$_ldflags +_cflags=$_cflags" -fno-omit-frame-pointer" + +cfgfile=`mktemp` +make --no-print-directory -f $BASEDIR/getconfig.mk ARCH=x86 TYPE=$_linktype > $cfgfile +. $cfgfile +rm $cfgfile + +#echo "_compile = $_compile, _preproc = $_preproc" + +if [[ "$toolname" == "g++" ]]; then + COMPILER=$_CXX + _libs="-lc++ $_libs" +elif [[ "$toolname" == "gcc" ]]; then + COMPILER=$_CC +else + echo "ERROR: Unknown tool name $toolname" >&2 + exit 1 +fi + +if [[ "x$_verarg" != "x" ]]; then + if [[ "x$_actas" == "xld" ]]; then + run $_LD $_miscargs $_verarg + else + run $_CC $_miscargs $_verarg + fi + exit $? +fi + +if [[ "x$_actas" == "xld" ]]; then + if echo "$_miscargs" | grep '\.o\|\.a'; then + run $_LD $LDFLAGS $_ldflags $_outfile $_miscargs $LIBGCC_PATH $_libs + else + run $_LD $_miscargs $_verarg + fi + exit $? +fi + +if [[ $_preproc -eq 1 ]]; then + run $_CC -E $CFLAGS $_cflags $_miscargs $_outfile +elif [[ $_makedep -eq 1 ]]; then + run $_CC -M $CFLAGS $_cflags $_miscargs $_outfile +elif [[ $_compile -eq 1 ]]; then + run $_CC $CFLAGS $_cflags $_miscargs -c $_outfile +elif 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 + run $_CC $CFLAGS $_cflags $_miscargs -c -o $tmpout + run $_LD $LDFLAGS $_ldflags $CRTBEGIN $_libs $tmpout $_outfile $_libs $LIBGCC_PATH $CRTEND + _rv=$? rm $tmpout + exit $_rv else - $_LD $LDFLAGS $_ldflags $_miscargs $_outfile $LIBGCC_PATH -fi; fi + run $_LD $_ldflags $CRTBEGIN $_miscargs $_outfile $LDFLAGS $_libs $LIBGCC_PATH $CRTEND +fi