I took a pass at the most recent --build --host stuff in
the CVS version and it looks like it is *almost* ready.

The first thing we to do was change the warning message.
It is confusing and does not really tell me that things
could still change based on what is detected at runtime.
Here is the change I propose.

Old:

./configure --host=i386-mingw32msvc

configure: WARNING: Did you mean --build instead of --host?  Assuming you did.
configure: WARNING: If not, please specify both --build and --host.
...
checking build system type... i686-pc-linux-gnu
checking host system type... i386-pc-mingw32msvc
checking for i386-mingw32msvc-g++... i386-mingw32msvc-g++
checking whether the C++ compiler works... no
yes
checking whether we are using GNU C++... yes
checking whether i386-mingw32msvc-g++ accepts -g... yes


New:

./configure --prefix=/tmp/jikes_Xmingw --host=i386-mingw32msvc

configure: WARNING: For backwards compatibility, --build will be set to --host
    if a cross compiler can not be found
...
checking build system type... i686-pc-linux-gnu
checking host system type... i386-pc-mingw32msvc
checking for i386-mingw32msvc-g++... i386-mingw32msvc-g++
checking whether the C++ compiler works... yes
checking whether we are using GNU C++... yes




The next problem is that when a cross compiler is not
detected, we need to reset --build to --host. I also
a printout of the cross_compiling variable and the
reset --build (if it was actually reset).

Old:

./configure --host=i386-pc-linux-gnu

...
checking build system type... i686-pc-linux-gnu
checking host system type... i386-pc-linux-gnu
...
checking for i386-pc-linux-gnu-g++... no
checking for i386-pc-linux-gnu-c++... no
...
checking for g++... g++
checking whether the C++ compiler works... yes
checking whether we are using GNU C++... yes

New:

...
checking build system type... i686-pc-linux-gnu
checking host system type... i386-pc-linux-gnu
checking for i386-pc-linux-gnu-g++... no
checking for i386-pc-linux-gnu-c++... no
...

checking for g++... g++
checking whether the C++ compiler works... yes
checking whether we are cross compiling... no
checking reset of build system type... i386-pc-linux-gnu
checking whether we are using GNU C++... yes



Note how the build system is initially incorrect but
after the cross compiler detection step it gets fixed.

I also fixed the bug that caused printing of multiple
cache values when searching for a compiler in the
native case.


Here is the full patch.


Index: ChangeLog
===================================================================
RCS file: /cvs/autoconf/ChangeLog,v
retrieving revision 1.712
diff -u -r1.712 ChangeLog
--- ChangeLog   2000/07/03 10:41:30     1.712
+++ ChangeLog   2000/07/04 09:25:55
@@ -1,3 +1,12 @@
+2000-07-04  Mo DeJong  <[EMAIL PROTECTED]>
+
+       * acgeneral.m4 (_AC_INIT_PARSE_ARGS, AC_CHECK_TOOLS): Change
+       warning message printed when only --host is given. Fix printing
+       of multiple compiler cache values, use PATH argument.
+       * aclang.m4 (AC_LANG_COMPILER_WORKS): Set --build to --host if
+       test for cross compiler fails and only --host is given. Print
+       the cross compile status, print the --build if it was reset.
+
 2000-07-03  Akim Demaille  <[EMAIL PROTECTED]>
 
        * acgeneral.m4 (_AC_INIT_PARSE_ARGS) <-C>: Use `./config.cache', not
Index: acgeneral.m4
===================================================================
RCS file: /cvs/autoconf/acgeneral.m4,v
retrieving revision 1.500
diff -u -r1.500 acgeneral.m4
--- acgeneral.m4        2000/07/03 10:41:30     1.500
+++ acgeneral.m4        2000/07/04 09:25:59
@@ -1567,8 +1567,8 @@
 if test "x$host_alias" != x; then
   if test "x$build_alias" = x; then
     cross_compiling=maybe
-    AC_MSG_WARN([Did you mean --build instead of --host?  Assuming you did.])
-    AC_MSG_WARN([If not, please specify both --build and --host.])
+    AC_MSG_WARN([For backwards compatibility, --build will be set to --host
+    if a cross compiler is not detected])
   elif test "x$build_alias" != "x$host_alias"; then
     cross_compiling=yes
   fi
@@ -2218,8 +2218,8 @@
 else
   AC_MSG_RESULT(ok)
 fi
-ac_cv_host_system_type=$host
 ac_cv_build_system_type=$build
+ac_cv_host_system_type=$host
 ac_cv_target_system_type=$target[]dnl
 ])
 
@@ -2921,11 +2921,11 @@
 AC_DEFUN([AC_CHECK_TOOLS],
 [for ac_prog in $2
 do
-  AC_CHECK_PROG([$1], $ac_tool_prefix$ac_prog, $ac_tool_prefix$ac_prog, [$3])
-  test "$$1" != "$3" && break
+  AC_CHECK_PROG([$1], $ac_tool_prefix$ac_prog, $ac_tool_prefix$ac_prog,, [$4])
+  test "$$1" != "" && break
 done
-if test "$$1" = "$3"; then
-  AC_CHECK_PROGS([$1], [$2], [$3])
+if test "$$1" = ""; then
+  AC_CHECK_PROGS([$1], [$2], [$3], [$4])
 fi
 ])# AC_CHECK_TOOLS
 
Index: aclang.m4
===================================================================
RCS file: /cvs/autoconf/aclang.m4,v
retrieving revision 1.35
diff -u -r1.35 aclang.m4
--- aclang.m4   2000/06/30 13:34:38     1.35
+++ aclang.m4   2000/07/04 09:26:00
@@ -466,6 +466,8 @@
                  [AC_REQUIRE([AC_PROG_CXXCPP])])])
 
 
+# FIXME : This cross_compiling stuff should be removed for autoconf 3.0
+
 # AC_LANG_COMPILER_WORKS
 # ----------------------
 define([_AC_LANG_COMPILER_WORKS],
@@ -474,9 +476,15 @@
 [# If not cross compiling, check that we can run a simple program.
 if test "$cross_compiling" != yes; then
   if AC_TRY_COMMAND(./conftest); then
+    # Set --build to --host if only --host is passed and not cross compiling
+    if test "$cross_compiling" = maybe; then
+         build=$host_alias
+         build_alias=$host_alias
+         ac_cv_build=$host_alias
+         ac_cv_reset_build_to_host=yes
+    fi
     cross_compiling=no
   else
-    AC_MSG_RESULT(no)
     if test "$cross_compiling" = maybe; then
       cross_compiling=yes
     else
@@ -488,6 +496,12 @@
 AC_MSG_RESULT(yes)],
 [AC_MSG_RESULT(no)
 AC_MSG_ERROR([_AC_LANG compiler cannot create executables], 77)])[]dnl
+AC_MSG_CHECKING([whether we are cross compiling])
+AC_MSG_RESULT($cross_compiling)
+if test "$ac_cv_reset_build_to_host" = "yes"; then
+    AC_MSG_CHECKING([reset of build system type])
+    AC_MSG_RESULT([$ac_cv_build])
+fi
 ])# AC_LANG_COMPILER_WORKS



Mo DeJong
Red Hat Inc

Reply via email to