xfs
[Top] [All Lists]

xfsprogs: Add BUILD_CFLAGS for cross compilation

To: hch@xxxxxxxxxxxxx, tytso@xxxxxxx
Subject: xfsprogs: Add BUILD_CFLAGS for cross compilation
From: Gwendal Grignou <gwendal@xxxxxxxxxxxx>
Date: Mon, 1 Feb 2016 13:25:09 -0800
Cc: fstests@xxxxxxxxxxxxxxx, xfs@xxxxxxxxxxx
Delivered-to: xfs@xxxxxxxxxxx
Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=bW1nwh6c7l8u/rtJEIWHN41iv5PY+i5/XPyLMDOI/8g=; b=LFvHi/cRK4Jt8R1TuI/ib8Ku7nI1+J5X3DLpPaWGSbzZksSvFIIDKexuUQEpTza7iW 4hZ+wyB5ZvdrnM6UA7y0Lq8Z0dtubl//5eRT9Wc2ryadV1BQZU978hnTICu3Ge2Sm+c7 vzeE7+bT59hkvEznAvlBOC97fuA9fW99PAqsKopspGQn6ChVbjMI2vcbJte75klzCyI/ I0XaMVwQx/thEb7Cjtnr0462nNAAgVcKyzgyHOsJiqAt80tres2HmwtUibv/F7uw94g5 BDTVsq2ZvEHv4MfCgxxXIHgqB96fVBl2LQ5+ydCD0vdP5VeFOXEasIMecWkygR12uWRW YawQ==
In-reply-to: <1437913255-7524-4-git-send-email-tytso@xxxxxxx>
References: <1437913255-7524-4-git-send-email-tytso@xxxxxxx>
Sender: Gwendal Grignou <gwendal@xxxxxxxxxx>
When cross compiling, CFLAGS may contains option for the cros-compiler the
host compiler can not handle.
Add BUILD_CFLAGS variable that does not include $OPTIMIZER options.

Signed-off by: Gwendal Grignou <gwendal@xxxxxxxxxxxx>

--- a/include/builddefs.in      2016-02-01 09:44:14.636018753 -0800
+++ b/include/builddefs.in      2016-02-01 09:37:29.000000000 -0800
@@ -27,6 +27,7 @@
 LOADERFLAGS = @LDFLAGS@
 LTLDFLAGS = @LDFLAGS@
 CFLAGS = @CFLAGS@
+BUILD_CFLAGS = @BUILD_CFLAGS@
 
 LIBRT = @librt@
 LIBUUID = @libuuid@
@@ -151,7 +151,7 @@
 endif
 
 
-GCFLAGS = $(OPTIMIZER) $(DEBUG) \
+GCFLAGS = $(DEBUG) \
          -DVERSION=\"$(PKG_VERSION)\" -DLOCALEDIR=\"$(PKG_LOCALE_DIR)\"  \
          -DPACKAGE=\"$(PKG_NAME)\" -I$(TOPDIR)/include -I$(TOPDIR)/libxfs
 
@@ -160,7 +160,8 @@
 endif
 
 # First, Global, Platform, Local CFLAGS
-CFLAGS += $(FCFLAGS) $(GCFLAGS) $(PCFLAGS) $(LCFLAGS)
+BUILD_CFLAGS += $(FCFLAGS) $(GCFLAGS) $(PCFLAGS) $(LCFLAGS)
+CFLAGS += $(FCFLAGS) $(OPTIMIZER) $(GCFLAGS) $(PCFLAGS) $(LCFLAGS)
 
 include $(TOPDIR)/include/buildmacros
 
--- a/libxfs/Makefile   2016-02-01 09:44:14.644018849 -0800
+++ b/libxfs/Makefile   2016-02-01 09:37:55.000000000 -0800
@@ -111,7 +111,7 @@
 
 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
 
@@ -122,7 +122,7 @@
 # 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
--- a/configure.ac      2016-02-01 09:56:42.873010767 -0800
+++ b/configure.ac      2016-02-01 09:56:45.885047014 -0800
@@ -11,9 +11,12 @@
 AC_PROG_CC
 if test $cross_compiling = no; then
   BUILD_CC="$CC"
+  BUILD_CFLAGS="$CFLAGS"
   AC_SUBST(BUILD_CC)
 else
   AC_CHECK_PROGS(BUILD_CC, gcc cc)
+  BUILD_CFLAGS="-g"
 fi
+AC_SUBST(BUILD_CFLAGS)
 
 AC_ARG_ENABLE(shared,
 [ --enable-shared=[yes/no] Enable use of shared libraries [default=yes]],,

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