From: Roy Marples Date: Mon, 24 Mar 2014 11:07:19 +0000 (+0000) Subject: If given --build or --host targets, the expectation is we try and find X-Git-Tag: v6.4.0~129 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=ffab836eabad628324dc86c95e1dcc74705d1aaf;p=thirdparty%2Fdhcpcd.git If given --build or --host targets, the expectation is we try and find a compiler for that target. --- 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