]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
build: Allow compiling xfsprogs in a cross compile environment
authorGwendal Grignou <gwendal@chromium.org>
Thu, 12 Jan 2017 20:12:29 +0000 (14:12 -0600)
committerEric Sandeen <sandeen@redhat.com>
Thu, 12 Jan 2017 20:12:29 +0000 (14:12 -0600)
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 <gwendal@chromium.org>
Reviewed-by: Mike Frysinger <vapier@gentoo.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
configure.ac
include/builddefs.in
libxfs/Makefile

index 36b5b1ebedc09553a2979b79cd029c53a6ff69c9..239c65790771c3a1c15ec6020cc61fd77115b051 100644 (file)
@@ -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,
index 521907123a23f4a934a20939ddcc898e8db038f8..612b547dde3f3da8e310163b4888a426c5fb8993 100644 (file)
@@ -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
 
index 64997316088970dfb5ad99ef159e4b3f03b0156b..baba02f037805c62bf6644fc1d0c771db9c75e6b 100644 (file)
@@ -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