Merge branch 'master' of git://localhost/acess2
[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         -E)
28                 _preproc=1
29                 ;;
30         -c)
31                 _compile=1
32                 ;;
33         -o)
34                 shift
35                 _outfile="-o $1"
36                 ;;
37         -I)
38                 shift
39                 _cflags=$_cflags" -I$1"
40                 ;;
41         -I*|-D*|-O*)
42                 _cflags=$_cflags" $1"
43                 ;;
44         -Wl,*)
45                 arg=$1
46                 arg=${arg#-Wl}
47                 arg=${arg/,/ }
48                 _ldflags=$_ldflags" ${arg}"
49                 ;;
50         -l)
51                 shift
52                 _libs=$_libs" -l$1"
53                 ;;
54         -l*|-L*)
55                 _libs=$_libs" $1"
56                 ;;
57         *)
58                 _miscargs=$_miscargs" $1"
59                 ;;
60         esac
61         shift
62 done
63
64 run() {
65 #       echo $*
66         $*
67 }
68
69 if [[ $_preproc -eq 1 ]]; then
70         run $_CC -E $CFLAGS $_cflags $_miscargs $_outfile
71         exit $?
72 fi
73 if [[ $_compile -eq 1 ]]; then
74         run $_CC $CFLAGS $_cflags $_miscargs -c $_outfile
75         exit $?
76 fi
77
78 if echo " $_miscargs" | grep '\.c' >/dev/null; then
79         tmpout=`mktemp acess_gccproxy.XXXXXXXXXX.o --tmpdir`
80         run $_CC $CFLAGS $_miscargs -c -o $tmpout
81         run $_LD $LDFLAGS $_ldflags $_libs $tmpout $_outfile
82         rm $tmpout
83 else
84         run $_LD $LDFLAGS $_ldflags $_miscargs $_outfile $LIBGCC_PATH
85 fi
86

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