Tools/GCCProxy - Hacked up script to avoid patching gcc/binutils
[tpg/acess2.git] / Tools / GCCProxy / gccproxy.sh
1 #!/bin/bash
2
3 # Get invocation path (which could be a symlink in $PATH)
4 fullpath=`which "$0"`
5 if [[ !$? ]]; then
6         fullpath="$0"
7 fi
8
9 # Resolve symlink
10 fullpath=`readlink -f "$fullpath"`
11
12 # Get base directory
13 BASEDIR=`dirname "$fullpath"`
14
15 cfgfile=`mktemp`
16 make --no-print-directory -f $BASEDIR/getconfig.mk ARCH=x86 > $cfgfile
17 #echo $cfgfile
18 #cat $cfgfile
19 . $cfgfile
20 rm $cfgfile
21
22 _miscargs=""
23 _compile=0
24
25 while [[ $# -gt 0 ]]; do
26         case "$1" in
27         -c)
28                 _compile=1
29                 ;;
30         -o)
31                 shift
32                 _outfile="-o $1"
33                 ;;
34         -I)
35                 shift
36                 _cflags=$_cflags" -I$1"
37                 ;;
38         -I*|-D*|-O*)
39                 _cflags=$_cflags" $1"
40                 ;;
41         -Wl,*)
42                 arg=$1
43                 arg=${arg#-Wl}
44                 arg=${arg/,/ }
45                 _ldflags=$_ldflags" ${arg}"
46                 ;;
47         -l)
48                 shift
49                 _libs=$_libs" -l$1"
50                 ;;
51         -l*)
52                 _libs=$_libs" $1"
53                 ;;
54         *)
55                 _miscargs=$_miscargs" $1"
56                 ;;
57         esac
58         shift
59 done
60
61 if [[ $_compile -eq 1 ]]; then
62 #       echo $_CC $CFLAGS $*
63         $_CC $CFLAGS $_miscargs -c $_outfile
64 else if echo " $_miscargs" | grep '\.c' >/dev/null; then
65         tmpout=`mktemp acess_gccproxy.XXXXXXXXXX.o --tmpdir`
66         $_CC $CFLAGS $_miscargs -c -o $tmpout
67         $_LD $LDFLAGS $_ldflags $_libs $tmpout $_outfile
68         rm $tmpout
69 else
70         $_LD $LDFLAGS $_ldflags $_miscargs $_outfile $LIBGCC_PATH
71 fi; fi
72

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