xfs
[Top] [All Lists]

[PATCH 3/6] xfsprogs: define and use BUILD_CC in configure.ac for cross

To: xfs@xxxxxxxxxxx
Subject: [PATCH 3/6] xfsprogs: define and use BUILD_CC in configure.ac for cross compilation
From: Theodore Ts'o <tytso@xxxxxxx>
Date: Sun, 26 Jul 2015 08:20:52 -0400
Cc: Theodore Ts'o <tytso@xxxxxxx>, fstests@xxxxxxxxxxxxxxx
Delivered-to: xfs@xxxxxxxxxxx
Dkim-signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=thunk.org; s=ef5046eb; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=zV8B3RPhPXAuJfyEBNcc3mKbcueIkWwNfyiGwG+TD2o=; b=UgMWfm3Kzqd2FbvUg53FejC5+tm2aKYVbl4LjfcbBycHL0dTfWTBnF0i1wBDaMNzn7o+gISzCFjJ3fopaFRiJ1U4pnwmDUDK6paEYRpKB+0v5zK7jOPAtynzukPD9Y0bmxjmJeHGCFUFvJ4MGIoA+7qAe182YS4XsW+GRi1AMAo=;
In-reply-to: <1437913255-7524-1-git-send-email-tytso@xxxxxxx>
References: <1437913255-7524-1-git-send-email-tytso@xxxxxxx>
In order to support cross-compilation, we need to build gen_crc32table
using the C compiler targetted for the build platform, since it is run
as part of the build process.

Signed-off-by: Theodore Ts'o <tytso@xxxxxxx>
---
 configure.ac         | 8 ++++++++
 include/builddefs.in | 1 +
 libxfs/Makefile      | 4 ++--
 3 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/configure.ac b/configure.ac
index ae17c68..4cfbd4e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -8,6 +8,14 @@ AC_PREFIX_DEFAULT(/usr)
 
 AC_PROG_LIBTOOL
 
+AC_PROG_CC
+if test $cross_compiling = no; then
+  BUILD_CC="$CC"
+  AC_SUBST(BUILD_CC)
+else
+  AC_CHECK_PROGS(BUILD_CC, gcc cc)
+fi
+
 AC_ARG_ENABLE(shared,
 [ --enable-shared=[yes/no] Enable use of shared libraries [default=yes]],,
        enable_shared=yes)
diff --git a/include/builddefs.in b/include/builddefs.in
index 7e9f53d..1d2d22e 100644
--- a/include/builddefs.in
+++ b/include/builddefs.in
@@ -64,6 +64,7 @@ PKG_DOC_DIR   = @datadir@/doc/@pkg_name@
 PKG_LOCALE_DIR = @datadir@/locale
 
 CC             = @cc@
+BUILD_CC       = @BUILD_CC@
 AWK            = @awk@
 SED            = @sed@
 TAR            = @tar@
diff --git a/libxfs/Makefile b/libxfs/Makefile
index ae15a5d..6323b81 100644
--- a/libxfs/Makefile
+++ b/libxfs/Makefile
@@ -67,7 +67,7 @@ default: crc32selftest ltdepend $(LTLIBRARY)
 
 crc32table.h: gen_crc32table.c
        @echo "    [CC]     gen_crc32table"
-       $(Q) $(CC) $(CFLAGS) -o gen_crc32table $<
+       $(Q) $(BUILD_CC) $(CFLAGS) -o gen_crc32table $<
        @echo "    [GENERATE] $@"
        $(Q) ./gen_crc32table > crc32table.h
 
@@ -78,7 +78,7 @@ crc32table.h: gen_crc32table.c
 # disk.
 crc32selftest: gen_crc32table.c crc32table.h crc32.c
        @echo "    [TEST]    CRC32"
-       $(Q) $(CC) $(CFLAGS) -D CRC32_SELFTEST=1 crc32.c -o $@
+       $(Q) $(BUILD_CC) $(CFLAGS) -D CRC32_SELFTEST=1 crc32.c -o $@
        $(Q) ./$@
 
 include $(BUILDRULES)
-- 
2.3.0

<Prev in Thread] Current Thread [Next in Thread>