From e14913c167250f3eb38488bf88a64b0b427490a7 Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Mon, 3 Aug 2015 10:16:21 +1000 Subject: [PATCH] xfsprogs: define and use BUILD_CC in configure.ac for cross compilation 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 Reviewed-by: Christoph Hellwig Signed-off-by: Dave Chinner --- 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 3dabd5d37..f60efd14d 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 d40677450..cdf2d41cc 100644 --- a/include/builddefs.in +++ b/include/builddefs.in @@ -63,6 +63,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 95de27ea0..85c3ed754 100644 --- a/libxfs/Makefile +++ b/libxfs/Makefile @@ -111,7 +111,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 @@ -122,7 +122,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) ./$@ # set up include/xfs header directory -- 2.47.2