From: Gwendal Grignou Date: Thu, 12 Jan 2017 20:12:29 +0000 (-0600) Subject: build: Allow compiling xfsprogs in a cross compile environment X-Git-Tag: v4.10.0-rc1~49 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=0a71e38396304b4d1215ba0b51cd6ce8e33eb40d;p=thirdparty%2Fxfsprogs-dev.git build: Allow compiling xfsprogs in a cross compile environment Without this patch, we are using the same compiler and options for the host compiler (BUILD_CC) and the target compiler (CC), and we would get error messages at compilation: x86_64-pc-linux-gnu-gcc -O2 -O2 -pipe -march=armv7-a -mtune=cortex-a15 ... x86_64-pc-linux-gnu-gcc.real: error: unrecognized command line option '-mfpu=neon' '-mfloat-abi=hard' '-clang-syntax' '-mfpu=neon' '-mfloat-abi=hard' '-clang-syntax' Add BUILD_CC and BUILD_CFLAGS as precious variables to allow setting it up from the ebuild. Signed-off-by: Gwendal Grignou Reviewed-by: Mike Frysinger Reviewed-by: Christoph Hellwig Signed-off-by: Eric Sandeen --- diff --git a/configure.ac b/configure.ac index 36b5b1ebe..239c65790 100644 --- a/configure.ac +++ b/configure.ac @@ -9,11 +9,21 @@ 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) +AC_ARG_VAR(BUILD_CC, [C compiler for build tools]) +if test "${BUILD_CC+set}" != "set"; then + if test $cross_compiling = no; then + BUILD_CC="$CC" + else + AC_CHECK_PROGS(BUILD_CC, gcc cc) + fi +fi +AC_ARG_VAR(BUILD_CFLAGS, [C compiler flags for build tools]) +if test "${BUILD_CFLAGS+set}" != "set"; then + if test $cross_compiling = no; then + BUILD_CFLAGS="$CFLAGS" + else + BUILD_CFLAGS="-g -O2" + fi fi AC_ARG_ENABLE(shared, diff --git a/include/builddefs.in b/include/builddefs.in index 521907123..612b547dd 100644 --- a/include/builddefs.in +++ b/include/builddefs.in @@ -26,6 +26,7 @@ MALLOCLIB = @malloc_lib@ LOADERFLAGS = @LDFLAGS@ LTLDFLAGS = @LDFLAGS@ CFLAGS = @CFLAGS@ -D_FILE_OFFSET_BITS=64 +BUILD_CFLAGS = @BUILD_CFLAGS@ LIBRT = @librt@ LIBUUID = @libuuid@ @@ -154,7 +155,7 @@ PCFLAGS+= -DOVERRIDE_SYSTEM_FSXATTR endif -GCFLAGS = $(OPTIMIZER) $(DEBUG) \ +GCFLAGS = $(DEBUG) \ -DVERSION=\"$(PKG_VERSION)\" -DLOCALEDIR=\"$(PKG_LOCALE_DIR)\" \ -DPACKAGE=\"$(PKG_NAME)\" -I$(TOPDIR)/include -I$(TOPDIR)/libxfs @@ -162,8 +163,9 @@ ifeq ($(ENABLE_GETTEXT),yes) GCFLAGS += -DENABLE_GETTEXT endif +BUILD_CFLAGS += $(GCFLAGS) $(PCFLAGS) # First, Global, Platform, Local CFLAGS -CFLAGS += $(FCFLAGS) $(GCFLAGS) $(PCFLAGS) $(LCFLAGS) +CFLAGS += $(FCFLAGS) $(OPTIMIZER) $(GCFLAGS) $(PCFLAGS) $(LCFLAGS) include $(TOPDIR)/include/buildmacros diff --git a/libxfs/Makefile b/libxfs/Makefile index 649973160..baba02f03 100644 --- a/libxfs/Makefile +++ b/libxfs/Makefile @@ -124,7 +124,7 @@ default: crc32selftest ltdepend $(LTLIBRARY) crc32table.h: gen_crc32table.c @echo " [CC] gen_crc32table" - $(Q) $(BUILD_CC) $(CFLAGS) -o gen_crc32table $< + $(Q) $(BUILD_CC) $(BUILD_CFLAGS) -o gen_crc32table $< @echo " [GENERATE] $@" $(Q) ./gen_crc32table > crc32table.h @@ -135,7 +135,7 @@ crc32table.h: gen_crc32table.c # disk. crc32selftest: gen_crc32table.c crc32table.h crc32.c @echo " [TEST] CRC32" - $(Q) $(BUILD_CC) $(CFLAGS) -D CRC32_SELFTEST=1 crc32.c -o $@ + $(Q) $(BUILD_CC) $(BUILD_CFLAGS) -D CRC32_SELFTEST=1 crc32.c -o $@ $(Q) ./$@ # set up include/xfs header directory