xref: /dragonfly/libexec/customcc/cc.sh (revision 82730a9c)
1#!/bin/sh
2#
3# Copyright (c) 2009-2012
4#	The DragonFly Project.  All rights reserved.
5#
6# Redistribution and use in source and binary forms, with or without
7# modification, are permitted provided that the following conditions
8# are met:
9#
10# 1. Redistributions of source code must retain the above copyright
11#    notice, this list of conditions and the following disclaimer.
12# 2. Redistributions in binary form must reproduce the above copyright
13#    notice, this list of conditions and the following disclaimer in
14#    the documentation and/or other materials provided with the
15#    distribution.
16# 3. Neither the name of The DragonFly Project nor the names of its
17#    contributors may be used to endorse or promote products derived
18#    from this software without specific, prior written permission.
19#
20# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23# FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE
24# COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25# INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
26# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
28# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
30# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31# SUCH DAMAGE.
32#
33
34CDIR=$(dirname $0)
35CNAME=$(basename $0)
36
37if [ "${CCVER}" = "clang" -o "${CCVER}" = "clangsvn" ]; then
38	if [ "${CNAME}" = "cpp" ]; then
39		exec ${CDIR}/../gcc44/cpp "$@"
40	else
41		INCOPT="-nobuiltininc -nostdinc \
42		    -isysroot @@INCPREFIX@@ \
43		    -isystem /usr/include \
44		    -isystem /usr/include/c++/4.4"
45	fi
46elif [ "${CCVER}" = "gcc46" ]; then
47	GCC46VER=`gnatc++ -dumpversion`
48	GCC46MAC=`gnatc++ -dumpmachine`
49	INCOPT="-nostdinc \
50	    -iprefix @@INCPREFIX@@ \
51	    -iwithprefixbefore /usr/include \
52	    -isystem /usr/pkg/include/c++/${GCC46VER} \
53	    -isystem /usr/pkg/include/c++/${GCC46VER}/${GCC46MAC}"
54fi
55
56. /etc/defaults/compilers.conf
57[ -f /etc/compilers.conf ] && . /etc/compilers.conf
58
59CUSTOM_CC=`eval echo \$\{${CCVER}_CC\}`
60CUSTOM_CFLAGS=`eval echo \$\{${CCVER}_CFLAGS\}`
61CUSTOM_CXX=`eval echo \$\{${CCVER}_CXX\}`
62CUSTOM_CXXFLAGS=`eval echo \$\{${CCVER}_CXXFLAGS\}`
63CUSTOM_CPP=`eval echo \$\{${CCVER}_CPP\}`
64CUSTOM_CPPFLAGS=`eval echo \$\{${CCVER}_CPPFLAGS\}`
65
66if [ "${CNAME}" = "cc" -o "${CNAME}" = "gcc" ]; then
67	exec ${CUSTOM_CC} ${INCOPT} ${CUSTOM_CFLAGS} "$@"
68elif [ "${CNAME}" = "c++" -o "${CNAME}" = "g++" ]; then
69	exec ${CUSTOM_CXX} ${INCOPT} ${CUSTOM_CXXFLAGS} "$@"
70elif [ "${CNAME}" = "cpp" ]; then
71	exec ${CUSTOM_CPP} ${INCOPT} ${CUSTOM_CPPFLAGS} "$@"
72fi
73