Set -nostdlib in CFLAGS and LDFLAGS before AC_PROG_CC if we
appear to be cross-compiling.

This makes the example kernel build work on my x86_64 system
with both

  * native compile to generate i386 example kernel
       ./configure --enable-example-kernel

  * cross-compile to generate mips example kernel
       ./configure --host=mips64-linux-gnu --enable-example-kernel

It remains to be verified how this works on other systems,
namely native mips systems, and non-x86 systems like arm.

Signed-off-by: Hans Ulrich Niedermann <h...@n-dimensional.de>

diff --git a/configure.ac b/configure.ac
index 830b1f57e..6b0718451 100644
--- a/configure.ac
+++ b/configure.ac
@@ -22,11 +22,18 @@ AM_INIT_AUTOMAKE([1.10.1])
 # Programs
 #
 
+AC_CANONICAL_BUILD
+AC_CANONICAL_HOST
+
+AS_IF([test "x$host" != "x$build"], [dnl
+  CFLAGS="-nostdlib $CFLAGS"
+  LDFLAGS="-nostdlib $LDFLAGS"
+])
+
 AC_PROG_CC
 AM_PROG_AS
 
 dnl Build the example Multiboot2 kernel (if possible on this host)
-AC_CANONICAL_HOST
 kernel_boot_arch=unsupported
 kernel_ccasflags=
 kernel_cflags=
@@ -57,8 +64,6 @@ AM_CONDITIONAL([BUILD_EXAMPLE_KERNEL],
                [test "x$enable_example_kernel" = xyes &&
                 test "x$kernel_boot_arch" != "xunsupported"])
 
-CFLAGS="-nostdlib $CFLAGS"
-
 dnl Output.
 AC_CONFIG_FILES([Makefile doc/Makefile])
 AC_OUTPUT
-- 
2.26.2


_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel

Reply via email to