summaryrefslogtreecommitdiff
path: root/configure
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2016-04-29 19:50:33 -0400
committerRich Felker <dalias@aerifal.cx>2016-04-29 19:50:33 -0400
commit2d49c2243fbe3322961e6f0a052cc3a28acd1fe2 (patch)
treee27680b21454a0846be8190121a406e6d65e6eba /configure
parentf0a61399330bae42beeb27d6ecd05570b3382a60 (diff)
downloadmusl-2d49c2243fbe3322961e6f0a052cc3a28acd1fe2.tar.gz
follow standard configure behavior for cross compile prefix
the standard configure interface, which our configure script tries to implement, identifies cross compiling (build != host) and searches for the properly-prefixed cross tools. our script was not doing that, forcing users to explicitly provide either CC or a CROSS_COMPILE tool prefix, and the more common choice, just providing CC, was incomplete because the Makefile would still invoke the native ar and ranlib programs. this happened to work when building on ELF-based systems with GNU binutils, but could easily fail when cross-compiling from dissimilar systems. like before, and like the standard configure behavior, an explicit CC or CROSS_COMPILE variable on the command line or in the environment overrides the automatic prefixing.
Diffstat (limited to 'configure')
-rwxr-xr-xconfigure14
1 files changed, 13 insertions, 1 deletions
diff --git a/configure b/configure
index 53241ab7..37942918 100755
--- a/configure
+++ b/configure
@@ -25,6 +25,7 @@ Fine tuning of the installation directories:
System types:
--target=TARGET configure to run on target TARGET [detected]
--host=HOST same as --target
+ --build=BUILD build system type; used only to infer cross-compiling
Optional features:
--enable-optimize=... optimize listed components for speed over size [auto]
@@ -129,6 +130,7 @@ includedir='$(prefix)/include'
syslibdir='/lib'
tools=
tool_libs=
+build=
target=
optimize=auto
debug=no
@@ -172,6 +174,7 @@ case "$arg" in
--disable-gcc-wrapper|--enable-gcc-wrapper=no) wrapper=no ;;
--enable-*|--disable-*|--with-*|--without-*|--*dir=*|--build=*) ;;
--host=*|--target=*) target=${arg#*=} ;;
+--build=*) build=${arg#*=} ;;
-* ) echo "$0: unknown option $arg" ;;
CC=*) CC=${arg#*=} ;;
CFLAGS=*) CFLAGS=${arg#*=} ;;
@@ -180,7 +183,7 @@ LDFLAGS=*) LDFLAGS=${arg#*=} ;;
CROSS_COMPILE=*) CROSS_COMPILE=${arg#*=} ;;
LIBCC=*) LIBCC=${arg#*=} ;;
*=*) ;;
-*) target=$arg ;;
+*) build=$arg ; target=$arg ;;
esac
done
@@ -214,6 +217,15 @@ set +C
trap 'rm "$tmpc"' EXIT INT QUIT TERM HUP
#
+# Check whether we are cross-compiling, and set a default
+# CROSS_COMPILE prefix if none was provided.
+#
+test "$target" && \
+test "$target" != "$build" && \
+test -z "$CROSS_COMPILE" && \
+CROSS_COMPILE="$target-"
+
+#
# Find a C compiler to use
#
printf "checking for C compiler... "