summaryrefslogtreecommitdiffstats
path: root/configure
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2014-03-24 11:07:19 +0000
committerRoy Marples <roy@marples.name>2014-03-24 11:07:19 +0000
commitffab836eabad628324dc86c95e1dcc74705d1aaf (patch)
tree88797ce8d8757d573dcf90f2f44e55ebfb7b8310 /configure
parentaf231ff80c5b983091e5df49af90376652e06d97 (diff)
downloaddhcpcd-ffab836eabad628324dc86c95e1dcc74705d1aaf.tar.xz
If given --build or --host targets, the expectation is we try and find
a compiler for that target.
Diffstat (limited to 'configure')
-rwxr-xr-xconfigure41
1 files changed, 31 insertions, 10 deletions
diff --git a/configure b/configure
index 5c84c605..f467dfd2 100755
--- a/configure
+++ b/configure
@@ -16,6 +16,7 @@ OS=
BUILD=
HOST=
TARGET=
+TARGETCC=
DEBUG=
FORK=
STATIC=
@@ -51,6 +52,7 @@ for x do
--rundir) RUNDIR=$var;;
--mandir) MANDIR=$var;;
--with-ccopts|CFLAGS) CFLAGS=$var;;
+ CC) CC=$var;;
CPPFLAGS) CPPFLAGS=$var;;
--with-hook) HOOKSCRIPTS="$HOOKSCRIPTS${HOOKSCRIPTS:+ }$var";;
--with-hooks|HOOKSCRIPTS) HOOKSCRIPTS=$var; HOOKSET=true;;
@@ -188,13 +190,15 @@ CONFIG_MK=config.mk
if [ -z "$BUILD" ]; then
# autoconf target triplet: cpu-vendor-os
BUILD=$(uname -m)-unknown-$(uname -s | tr '[:upper:]' '[:lower:]')
+else
+ TARGETCC=$BUILD-
fi
-if [ -z "$HOST" ]; then
- [ -z "$TARGET" ] && TARGET=$BUILD
- HOST=$TARGET
-fi
-if [ -z "$TARGET" ]; then
- [ -z "$HOST" ] && HOST=$BUILD
+if [ -n "$TARGET" ]; then
+ TARGETCC=$TARGET-
+elif [ -n "$HOST" ]; then
+ TARGET=$HOST
+else
+ HOST=$BUILD
TARGET=$HOST
fi
@@ -245,16 +249,33 @@ done
echo "LIBDIR= $LIBDIR" >>$CONFIG_MK
echo "MANDIR= $MANDIR" >>$CONFIG_MK
-: ${CC:=cc}
+# Always obey CC.
+# However, if CC is not specified and we are given GNU style
+# --host or --build targets the expectation is we try and match that
+# to a compiler.
+if [ -n "$CC" ]; then
+ TARGETCC=
+else
+ CC=cc
+ _COMPILERS="cc clang gcc pcc icc"
+fi
+if [ -n "$TARGETCC" ]; then
+ for _CC in $_COMPILERS; do
+ _CC=$(_which "$TARGETCC$_CC")
+ if [ -x "$_CC" ]; then
+ CC=$_CC
+ break
+ fi
+ done
+fi
if ! type "$CC" >/dev/null 2>&1; then
- for _CC in clang gcc pcc icc; do
+ for _CC in $_COMPILERS; do
_CC=$(_which "$_CC")
if [ -x "$_CC" ]; then
CC=$_CC
break
fi
done
-
fi
echo "Using compiler .. $CC"
@@ -417,7 +438,7 @@ else
echo "libc support for clock_getttime is required - aborting" >&2
abort=true
fi
-rm -f _clock_gettime.c _clockgettime
+rm -f _clock_gettime.c _clock_gettime
$abort && exit 1
if [ -z "$ARC4RANDOM" ]; then