]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
If given --build or --host targets, the expectation is we try and find
authorRoy Marples <roy@marples.name>
Mon, 24 Mar 2014 11:07:19 +0000 (11:07 +0000)
committerRoy Marples <roy@marples.name>
Mon, 24 Mar 2014 11:07:19 +0000 (11:07 +0000)
a compiler for that target.

configure

index 5c84c6050eac4ae30fbd57925337b7d31932683e..f467dfd25ce87fcd0973de2c54861aa39777bddd 100755 (executable)
--- 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