4829ac52a0640688430de28806459a68642ec68f
[dragonfly.git] / libexec / customcc / cc.sh
1 #!/bin/sh
2
3 CDIR=$(dirname $0)
4 CNAME=$(basename $0)
5
6 # XXX clang needs some special handling
7 #
8 # it is called only for "cc" and "gcc" and even then it could have been
9 # run on c++ files
10 #
11 if [ "${CCVER}" = "clang" ]; then
12         if [ "${CNAME}" = "cpp" ]; then
13                 exec ${CDIR}/../gcc41/cpp "$@"
14         elif [ "${CNAME}" = "c++" -o "${CNAME}" = "g++" ]; then
15                 exec ${CDIR}/../gcc41/c++ "$@"
16         elif [ -z $beenhere ]; then
17                 export beenhere=1
18                 oldargs="$@"
19                 export oldargs
20                 INCOPT="-nobuiltininc -nostdinc \
21                     -isysroot @@INCPREFIX@@ \
22                     -isystem /usr/include \
23                     -isystem /usr/libdata/gcc41 \
24                     -isystem /usr/include/c++/4.1"
25         elif [ "${CNAME}" = "cc" -o "${CNAME}" = "gcc" ]; then
26                 exec ${CDIR}/../gcc41/cc $oldargs
27         fi
28 elif [ "${CCVER}" = "clangsvn" ]; then
29         if [ "${CNAME}" = "cpp" ]; then
30                 exec ${CDIR}/../gcc41/cpp "$@"
31         else
32                 INCOPT="-nobuiltininc -nostdinc \
33                     -isysroot @@INCPREFIX@@ \
34                     -isystem /usr/include \
35                     -isystem /usr/include/c++/4.4"
36         fi
37 elif [ "${CCVER}" = "gcc46" ]; then
38         INCOPT="-nostdinc \
39             -isysroot @@INCPREFIX@@ \
40             -isystem /usr/include" \
41             -isystem /usr/include/c++/4.4"
42 fi
43
44 . /etc/defaults/compilers.conf
45 [ -f /etc/compilers.conf ] && . /etc/compilers.conf
46
47 CUSTOM_CC=`eval echo \$\{${CCVER}_CC\}`
48 CUSTOM_CFLAGS=`eval echo \$\{${CCVER}_CFLAGS\}`
49 CUSTOM_CXX=`eval echo \$\{${CCVER}_CXX\}`
50 CUSTOM_CXXFLAGS=`eval echo \$\{${CCVER}_CXXFLAGS\}`
51 CUSTOM_CPP=`eval echo \$\{${CCVER}_CPP\}`
52 CUSTOM_CPPFLAGS=`eval echo \$\{${CCVER}_CPPFLAGS\}`
53 CUSTOM_VERSION=`eval echo \$\{${CCVER}_VERSION\}`
54
55 if [ "${CUSTOM_VERSION}" != "" -a "$1" = "-dumpversion" ]; then
56         echo ${CUSTOM_VERSION}
57 elif [ "${CNAME}" = "cc" -o "${CNAME}" = "gcc" ]; then
58         exec ${CUSTOM_CC} ${INCOPT} ${CUSTOM_CFLAGS} "$@"
59 elif [ "${CNAME}" = "c++" -o "${CNAME}" = "g++" ]; then
60         exec ${CUSTOM_CXX} ${INCOPT} ${CUSTOM_CXXFLAGS} "$@"
61 elif [ "${CNAME}" = "cpp" ]; then
62         exec ${CUSTOM_CPP} ${INCOPT} ${CUSTOM_CPPFLAGS} "$@"
63 fi