cross compiling and autoconf's host vs build (vs target)
Andrew Cagney <[email protected]> Thu, 26 Nov 2015 13:49:39 -0500
| Newsgroups | gmane.comp.mozilla.devel.nspr |
|---|---|
| Message-ID | <CAJeAr6sSABV93HP+e3Tu1=OW2oC9r+LH4nyygX8UdP1xi5K6HQ@mail.gmail.com> |
The autoconf 2.13 to 2.50 transition, er, "cleaned up" cross
compilation and, in the process, "clarified" the meaning of "host",
"build" and "target".
For instance, I can specify:
./configure --host=m68k-uclinux-linux --build=i686-pc-linux-gnu
--target=m68k-uclinux-linux ...
to cross compile npsr (--host and host!=build trigger the cross compile):
checking build system type... i686-pc-linux-gnu
checking host system type... m68k-uclinux-linux-gnu
checking target system type... m68k-uclinux-linux-gnu
However, for nspr, this didn't work. Looking at configure.in, it
seems to still have traces of the old 2.13 conventions (mixing "$host"
and "$build"). For instance:
-if test "$target" != "$host"; then
- echo "cross compiling from $host to $target"
+if test "$target" != "$build"; then
+ echo "cross compiling from $build to $target"
which is changed by the below patch.
However, tread carefully, I find the way this all hangs together
quickly gets messy and confusing (details are in "Hosts and
Cross-Compilation" section in autoconf's documentation).
Andrew
--- nspr-4.10.10/nspr/configure.in.orig 2015-11-26 10:15:40.436090828 -0500
+++ nspr-4.10.10/nspr/configure.in 2015-11-26 10:17:44.593081097 -0500
@@ -552,8 +552,8 @@
dnl ========================================================
dnl Checks for compilers.
dnl ========================================================
-if test "$target" != "$host"; then
- echo "cross compiling from $host to $target"
+if test "$target" != "$build"; then
+ echo "cross compiling from $build to $target"
cross_compiling=yes
case "$build:$target" in
@@ -582,7 +582,7 @@
AC_PROG_CC
dnl Reenter the conditional blocks after invoking AC_PROG_CC.
-if test "$target" != "$host"; then
+if test "$target" != "$build"; then
if test -n "$USE_CPLUS"; then
AC_CHECK_PROGS(CXX, $CXX "${target_alias}-g++" "${target}-g++", echo)
unset ac_cv_prog_CXX
@@ -610,7 +610,7 @@
_SAVE_CFLAGS="$CFLAGS"
_SAVE_LDFLAGS="$LDFLAGS"
- AC_MSG_CHECKING([for $host compiler])
+ AC_MSG_CHECKING([for $build compiler])
AC_CHECK_PROGS(HOST_CC, $HOST_CC gcc cc /usr/ucb/cc, "")
if test -z "$HOST_CC"; then
AC_MSG_ERROR([no acceptable cc found in \$PATH])
@@ -621,10 +621,10 @@
CFLAGS="$HOST_CFLAGS"
LDFLAGS="$HOST_LDFLAGS"
- AC_MSG_CHECKING([whether the $host compiler ($HOST_CC
$HOST_CFLAGS $HOST_LDFLAGS) works])
+ AC_MSG_CHECKING([whether the $build compiler ($HOST_CC
$HOST_CFLAGS $HOST_LDFLAGS) works])
AC_TRY_COMPILE([], [return 0;],
[AC_MSG_RESULT([yes])],
- [AC_MSG_ERROR([installation or configuration problem: $host
compiler $HOST_CC cannot create executables.])] )
+ [AC_MSG_ERROR([installation or configuration problem: $build
compiler $HOST_CC cannot create executables.])] )
CC=$_SAVE_CC
CFLAGS=$_SAVE_CFLAGS
@@ -1163,9 +1163,9 @@
fi
dnl ========================================================
-dnl Override of system specific host options
+dnl Override of system specific build options
dnl ========================================================
-case "$host" in
+case "$build" in
*-mingw*|*-msys*)
NSINSTALL=nsinstall
;;