Hi

This patch should be the second third of the cross-compilation
changes.  After it we should apply the proposal of Mo for an automatic
use of $host-cc when cross-compilation is enabled.

Note that as is written this patch makes it possible for all the
configure to detect cross-compilation by `--host': AC_CANONICAL_FOO is
not needed at all.

Cced to Paul because this patch might be the answer to one of his
oldest grieves against Autoconf.  If this patch is applied, I guess we
can close Autoconf/14, Autoconf/15.

Cced to Ossama, because I did something which he was against: I
decided that either we cross-compile everything or nothing.  Ossama,
IIRC, said he wanted to be able to straight-compile with CC but
cross-compile with CXX for instance.

Personally, I would enjoy have more AC_MSG_ERROR and less AC_MSG_WARN,
but I suppose there lay the lengthy debates.

        Akim

Index: 0.300/ChangeLog
--- 0.300/ChangeLog Sun, 14 May 2000 07:36:36 +0200 akim (ace/34_ChangeLog 1.272 664)
+++ 0.300(w)/ChangeLog Sun, 14 May 2000 08:38:23 +0200 akim (ace/34_ChangeLog 1.272 
+664)
@@ -1,5 +1,21 @@
 2000-05-14  Akim Demaille  <[EMAIL PROTECTED]>
 
+       Either we cross-compile the whole package, or we don't.
+       Using --host explicitly enables cross-compilation.
+
+       * acgeneral.m4 (_AC_INIT_PARSE_ARGS): `--host' enables cross
+       compilation.
+       (AC_CANONICAL_BUILD): The help string should explicitly mention
+       cross compilation.
+       * aclang.m4 (AC_LANG(C), AC_LANG(C++), AC_LANG(Fortran 77)): Don't
+       set `cross_compiling'.
+       (AC_PROG_CC_WORKS, AC_PROG_CXX_WORKS, AC_PROG_F77_WORKS): Diagnose
+       situations where the compiler and the global cross compilation
+       flag disagree.
+       * doc/autoconf.texi: Adjust.
+
+2000-05-14  Akim Demaille  <[EMAIL PROTECTED]>
+
        * acgeneral.m4 (_AC_INIT_PARSE_ARGS): Prefer
          case $foo in
            *[^-a-zA-Z0-9_]*) AC_ACTION;;
Index: 0.300/NEWS
--- 0.300/NEWS Sun, 14 May 2000 04:25:41 +0200 akim (ace/31_NEWS 1.17 664)
+++ 0.300(w)/NEWS Sun, 14 May 2000 08:43:53 +0200 akim (ace/31_NEWS 1.17 664)
@@ -52,6 +52,14 @@
     ./configure ENV=VAR
   and then --recheck will work properly.  Variables declared with
   AC_ARG_VAR are also preserved.
+- cross-compilation
+  $build defaults to `config.guess`, $host to $build, and then $target
+  to $host.
+  Cross-compilation is a global status of the package, it no longer
+  depends upon the current language.
+  Cross compilation is explicitly declared iff the user specified
+  `--host'.  It is *abnormal* (but tolarated) to discover a
+  cross-compilation because we can't run compiled programs.
 
 ** config.status
 - faster
Index: 0.300/acgeneral.m4
--- 0.300/acgeneral.m4 Sun, 14 May 2000 07:36:36 +0200 akim (ace/27_acgeneral. 
1.169.8.15 644)
+++ 0.300(w)/acgeneral.m4 Sun, 14 May 2000 07:58:48 +0200 akim (ace/27_acgeneral. 
+1.169.8.15 644)
@@ -1047,8 +1047,10 @@ AC_DEFUN([_AC_INIT_PARSE_ARGS],
     ac_init_help=short ;;
 
   -host | --host | --hos | --ho)
+    cross_compiling=yes
     ac_prev=host ;;
   -host=* | --host=* | --hos=* | --ho=*)
+    cross_compiling=yes
     host=$ac_optarg ;;
 
   -includedir | --includedir | --includedi | --included | --include \
@@ -1857,7 +1859,7 @@ AC_DEFUN_ONCE([AC_CANONICAL_BUILD],
 AC_DEFUN_ONCE([AC_CANONICAL_HOST],
 [AC_REQUIRE([AC_CANONICAL_BUILD])dnl
 AC_DIVERT([HELP_CANON],
-[[  --host=HOST       configure for building programs running on HOST [BUILD]]])dnl
+[[  --host=HOST       cross-compile to build programs running on HOST [BUILD]]])dnl
 _AC_CANONICAL_THING(host)[]dnl
 ])# AC_CANONICAL_HOST
 
Index: 0.300/aclang.m4
--- 0.300/aclang.m4 Sun, 14 May 2000 02:10:17 +0200 akim (ace/b/32_aclang.m4 1.5.3.9 
664)
+++ 0.300(w)/aclang.m4 Sun, 14 May 2000 08:05:34 +0200 akim (ace/b/32_aclang.m4 
+1.5.3.9 664)
@@ -182,7 +182,6 @@ define([AC_LANG(C)],
 ac_cpp='$CPP $CPPFLAGS'
 ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&AC_FD_LOG'
 ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext 
$LIBS >&AC_FD_LOG'
-cross_compiling=$ac_cv_prog_cc_cross
 ])
 
 
@@ -245,7 +244,6 @@ define([AC_LANG(C++)],
 ac_cpp='$CXXCPP $CPPFLAGS'
 ac_compile='${CXX-g++} -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&AC_FD_LOG'
 ac_link='${CXX-g++} -o conftest${ac_exeext} $CXXFLAGS $CPPFLAGS $LDFLAGS 
conftest.$ac_ext $LIBS >&AC_FD_LOG'
-cross_compiling=$ac_cv_prog_cxx_cross
 ])
 
 
@@ -289,7 +287,6 @@ define([AC_LANG(Fortran 77)],
 [ac_ext=f
 ac_compile='${F77-f77} -c $FFLAGS conftest.$ac_ext >&AC_FD_LOG'
 ac_link='${F77-f77} -o conftest${ac_exeext} $FFLAGS $LDFLAGS conftest.$ac_ext $LIBS 
>&AC_FD_LOG'
-cross_compiling=$ac_cv_prog_f77_cross
 ])
 
 
@@ -447,7 +444,13 @@ AC_DEFUN(AC_PROG_CC_WORKS,
 fi
 AC_MSG_CHECKING([whether the C compiler ($CC $CFLAGS $CPPFLAGS $LDFLAGS) is a 
cross-compiler])
 AC_MSG_RESULT($ac_cv_prog_cc_cross)
-cross_compiling=$ac_cv_prog_cc_cross
+case $cross_compiling,$ac_cv_prog_cc_cross in
+  yes,no)
+    AC_MSG_WARN([the C compiler is not a cross compiler as was expected]);;
+  no,yes)
+    AC_MSG_WARN([cross-compilation enabled: cannot run C programs])
+    cross_compiling=yes;;
+esac
 ])# AC_PROG_CC_WORKS
 
 
@@ -642,7 +645,13 @@ AC_DEFUN(AC_PROG_CXX_WORKS,
 fi
 AC_MSG_CHECKING([whether the C++ compiler ($CXX $CXXFLAGS $CPPFLAGS $LDFLAGS) is a 
cross-compiler])
 AC_MSG_RESULT($ac_cv_prog_cxx_cross)
-cross_compiling=$ac_cv_prog_cxx_cross
+case $cross_compiling,$ac_cv_prog_cxx_cross in
+  yes,no)
+    AC_MSG_WARN([the C++ compiler is not a cross compiler as was expected]);;
+  no,yes)
+    AC_MSG_WARN([cross-compilation enabled: cannot run C++ programs])
+    cross_compiling=yes;;
+esac
 ])# AC_PROG_CXX_WORKS
 
 
@@ -739,7 +748,13 @@ AC_DEFUN(AC_PROG_F77_WORKS,
 fi
 AC_MSG_CHECKING([whether the Fortran 77 compiler ($F77 $FFLAGS $LDFLAGS) is a 
cross-compiler])
 AC_MSG_RESULT($ac_cv_prog_f77_cross)
-cross_compiling=$ac_cv_prog_f77_cross
+case $cross_compiling,$ac_cv_prog_f77_cross in
+  yes,no)
+    AC_MSG_WARN([the Fortran 77 compiler is not a cross compiler as was expected]);;
+  no,yes)
+    AC_MSG_WARN([cross-compilation enabled: cannot run Fortran 77 programs])
+    cross_compiling=yes;;
+esac
 ])# AC_PROG_F77_WORKS
 
 
Index: 0.300/doc/autoconf.texi
--- 0.300/doc/autoconf.texi Sun, 14 May 2000 07:36:36 +0200 akim (ace/16_autoconf.t 
1.61.2.17 664)
+++ 0.300(w)/doc/autoconf.texi Sun, 14 May 2000 08:39:26 +0200 akim (ace/16_autoconf.t 
+1.61.2.17 664)
@@ -405,8 +405,8 @@ @node Introduction, Making configure Scr
 configuration scripts can be regenerated automatically to take advantage
 of the updated code.
 
-The Metaconfig package is similar in purpose to Autoconf, but
-the scripts it produces require manual user intervention, which is quite
+The Metaconfig package is similar in purpose to Autoconf, but the
+scripts it produces require manual user intervention, which is quite
 inconvenient when configuring large source trees.  Unlike Metaconfig
 scripts, Autoconf scripts can support cross-compiling, if some care is
 taken in writing them.
@@ -2359,12 +2359,11 @@ @node Particular Programs, Generic Progr
 @samp{-g} for other compilers.
 
 If the C compiler being used does not produce executables that can run
-on the system where @code{configure} is being run, set the shell
-variable @code{cross_compiling} to @samp{yes}, otherwise @samp{no}.  In
-other words, this tests whether the build system type is different from
-the host system type (the target system type is irrelevant to this
-test).  @xref{Manual Configuration}, for more on support for cross
-compiling.
+on the build system (where @code{configure} is being run), assume the C
+compiler is a cross compiler.  Diagnose if the cross compilation status
+of the compiler and of @code{configure} differ, but always set the shell
+variable @code{cross_compiling} to @samp{yes}. @xref{Manual
+Configuration}, for more on support for cross compiling.
 @end defmac
 
 @defmac AC_PROG_CC_C_O
@@ -2441,12 +2440,11 @@ @node Particular Programs, Generic Progr
 @samp{-g} for other compilers.
 
 If the C++ compiler being used does not produce executables that can run
-on the system where @code{configure} is being run, set the shell
-variable @code{cross_compiling} to @samp{yes}, otherwise @samp{no}.  In
-other words, this tests whether the build system type is different from
-the host system type (the target system type is irrelevant to this
-test).  @xref{Manual Configuration}, for more on support for cross
-compiling.
+on the build system (where @code{configure} is being run), assume the C
+compiler is a cross compiler.  Diagnose if the cross compilation status
+of the compiler and of @code{configure} differ, but always set the shell
+variable @code{cross_compiling} to @samp{yes}. @xref{Manual
+Configuration}, for more on support for cross compiling.
 @end defmac
 
 @defmac AC_PROG_CXXCPP
@@ -2491,6 +2489,14 @@ @node Particular Programs, Generic Progr
 @code{g77} (or @samp{-O2} where @code{g77} does not accept @samp{-g}).
 Otherwise, set @code{FFLAGS} to @samp{-g} for all other Fortran 77
 compilers.
+
+If the Fortran 77 compiler being used does not produce executables that
+can run on the build system (where @code{configure} is being run),
+assume the C compiler is a cross compiler.  Diagnose if the cross
+compilation status of the compiler and of @code{configure} differ, but
+always set the shell variable @code{cross_compiling} to
+@samp{yes}. @xref{Manual Configuration}, for more on support for cross
+compiling.
 @end defmac
 
 @defmac AC_PROG_F77_C_O
@@ -3072,9 +3078,9 @@ @node Generic Functions,  , Particular F
 
 Autoconf follows a philosophy which was hammered along the years by the
 people who fought for portability: isolate the portability issues in
-specific files, and program as if you were on a @sc{posix} host.  Some
-functions cannot be repaired or are completely missing, your package
-must be ready to replace them.
+specific files, and program as if you were in a @sc{posix} environment.
+Some functions cannot be repaired or are completely missing, your
+package must be ready to replace them.
 
 Use the two following macros to specify the function which might be
 replaced, and use the third one to check and replace a function if
@@ -4410,7 +4416,7 @@ @node Test Programs, Guidelines, Run Tim
 To configure for cross-compiling you can also choose a value for those
 parameters based on the canonical system name (@pxref{Manual
 Configuration}).  Alternatively, set up a test results cache file with
-the correct values for the target system (@pxref{Caching Results}).
+the correct values for the host system (@pxref{Caching Results}).
 
 To provide a default for calls of @code{AC_TRY_RUN} that are embedded in
 other macros, including a few of the ones that come with Autoconf, you
@@ -4729,13 +4735,9 @@ @node Limitations of Usual Tools, Exitin
 statement, keep in mind that they have equal precedence.
 
 @item @command{test} (files)
-@c FIXME: Hm, I'd say the sentence should be
-@c  To enable @code{configure} scripts to support cross-compilation, they
-@c  shouldn't do anything that tests features of the build system instead of
-@c  the host system.
 To enable @code{configure} scripts to support cross-compilation, they
-shouldn't do anything that tests features of the host system instead of
-the target system.  But occasionally you may find it necessary to check
+shouldn't do anything that tests features of the build system instead of
+the host system.  But occasionally you may find it necessary to check
 whether some arbitrary file exists.  To do so, use @samp{test -f} or
 @samp{test -r}.  Do not use @samp{test -x}, because @sc{4.3bsd} does not
 have it.
@@ -5982,6 +5984,14 @@ @node Specifying Names, Canonicalizing, 
 @var{cpu}-@var{company}-@var{system}
 @end example
 
+@noindent
+where @var{system} can have one of these forms:
+
+@example
+@var{os}
+@var{kernel}-@var{os}
+@end example
+
 @code{configure} can usually guess the canonical name for the type of
 system it's running on.  To do so it runs a script called
 @code{config.guess}, which derives the name using the @code{uname}
@@ -6005,15 +6015,23 @@ @node Specifying Names, Canonicalizing, 
 produce code.
 @end table
 
-By default, the build is guessed (by @code{config.guess}), the host
-system is the build system, and the target is the host system.
+By default, the build system type is guessed (by @code{config.guess}),
+the host system is the build system, and the target is the host system.
 
-If you are cross-compiling, you still have to specify the names of the
+Using @samp{--host=@var{host-type}} explicitly enables cross-compilation
+to @var{host-type}.  You still have to specify the names of the
 cross-tools you use, in particular the C compiler, on the
 @code{configure} command line, e.g.,
 
 @example
-./configure --target=m68k-coff CC=m68k-coff-gcc
+./configure --host=m68k-coff CC=m68k-coff-gcc
+@end example
+
+@noindent
+but @code{configure} will diagnose unexpected cross-compilers:
+
+@example
+./configure CC=m68k-coff-gcc
 @end example
 
 @code{configure} recognizes short aliases for many system types; for
@@ -6063,9 +6081,8 @@ @node Canonicalizing, System Type Variab
 
 @defmac AC_VALIDATE_CACHED_SYSTEM_TUPLE (@var{cmd})
 @maindex VALIDATE_CACHED_SYSTEM_TUPLE
-If the cache file is inconsistent with the current host,
-target and build system types, execute @var{cmd} or print a default
-error message.
+If the cache file is inconsistent with the current host, target and
+build system types, execute @var{cmd} or print a default error message.
 @end defmac
 
 @node System Type Variables, Using System Type, Canonicalizing, Manual Configuration
Index: 0.300/doc/install.texi
--- 0.300/doc/install.texi Sun, 14 May 2000 02:10:17 +0200 akim (ace/15_install.te 
1.10 664)
+++ 0.300(w)/doc/install.texi Sun, 14 May 2000 08:39:40 +0200 akim (ace/15_install.te 
+1.10 664)
@@ -148,21 +148,28 @@ @node System Type
 will run on.  Usually @code{configure} can figure that out, but if it
 prints a message saying it cannot guess the host type, give it the
 @samp{--host=@var{type}} option.  @var{type} can either be a short name
-for the system type, such as @samp{sun4}, or a canonical name with three
-fields:
+for the system type, such as @samp{sun4}, or a canonical name which has
+the form:
+
 @example
 @var{cpu}-@var{company}-@var{system}
-@var{cpu}-@var{company}-@var{kernel}-@var{system}
 @end example
+
 @noindent
+where @var{system} can have one of these forms:
+
+@example
+@var{os}
+@var{kernel}-@var{os}
+@end example
+
 See the file @file{config.sub} for the possible values of each field.
 If @file{config.sub} isn't included in this package, then this package
 doesn't need to know the host type.
 
 If you are building compiler tools for cross-compiling, you can also use
 the @samp{--target=@var{type}} option to select the type of system they
-will produce code for and the @samp{--build=@var{type}} option to select
-the type of system on which you are compiling the package.
+will produce code for.
 
 @node Sharing Defaults
 @section Sharing Defaults

Reply via email to