[ovs-dev] [PATCH 1/2] build: Respect CFLAGS and LDFLAGS passed to make

Thomas Graf tgraf at noironetworks.com
Thu Sep 11 19:34:21 UTC 2014


configure cannot expect that the user will not pass additional CFLAGS
and LDFLAGS at make time [0]. Use OVS_CFLAGS and OVS_LDFLAGS instead to
collect compiler and linker flags and substitute in Makefile.am.

This allows for:
./configure --with-dpdk=[...]
make CFLAGS=-Wno-error=foo

[0] http://www.gnu.org/software/automake/manual/html_node/Flag-Variables-Ordering.html

Signed-off-by: Thomas Graf <tgraf at noironetworks.com>
---
 Makefile.am       | 2 ++
 acinclude.m4      | 8 +++++++-
 configure.ac      | 2 ++
 m4/openvswitch.m4 | 4 ++--
 4 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index 161936d..4c48e73 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -11,6 +11,7 @@ SUBDIRS = datapath
 
 AM_CPPFLAGS = $(SSL_CFLAGS)
 AM_LDFLAGS = $(SSL_LDFLAGS)
+AM_LDFLAGS += $(OVS_LDFLAGS)
 
 if WIN32
 AM_CPPFLAGS += -I $(top_srcdir)/include/windows
@@ -29,6 +30,7 @@ AM_CPPFLAGS += $(SSL_INCLUDES)
 
 AM_CFLAGS = -Wstrict-prototypes
 AM_CFLAGS += $(WARNING_FLAGS)
+AM_CFLAGS += $(OVS_CFLAGS)
 
 if NDEBUG
 AM_CPPFLAGS += -DNDEBUG
diff --git a/acinclude.m4 b/acinclude.m4
index b0794d2..742862d 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -22,7 +22,7 @@ AC_DEFUN([OVS_ENABLE_WERROR],
      [], [enable_Werror=no])
    AC_CONFIG_COMMANDS_PRE(
      [if test "X$enable_Werror" = Xyes; then
-        CFLAGS="$CFLAGS -Werror"
+        OVS_CFLAGS="$OVS_CFLAGS -Werror"
       fi])])
 
 dnl OVS_CHECK_LINUX
@@ -172,6 +172,8 @@ AC_DEFUN([OVS_CHECK_DPDK], [
     DPDK_LIB_DIR=$RTE_SDK/lib
     DPDK_LIB=-lintel_dpdk
 
+    ovs_save_CFLAGS="$CFLAGS"
+    ovs_save_LDFLAGS="$LDFLAGS"
     LDFLAGS="$LDFLAGS -L$DPDK_LIB_DIR"
     CFLAGS="$CFLAGS -I$DPDK_INCLUDE"
 
@@ -199,6 +201,10 @@ AC_DEFUN([OVS_CHECK_DPDK], [
     if $found; then :; else
         AC_MSG_ERROR([cannot link with dpdk])
     fi
+    CFLAGS="$ovs_save_CFLAGS"
+    LDFLAGS="$ovs_save_LDFLAGS"
+    OVS_LDFLAGS="$OVS_LDFLAGS -L$DPDK_LIB_DIR"
+    OVS_CFLAGS="$OVS_CFLAGS -I$DPDK_INCLUDE"
 
     # DPDK 1.7.0 pmd drivers are not linked unless --whole-archive is used.
     #
diff --git a/configure.ac b/configure.ac
index f1c9f9f..35e884a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -122,6 +122,8 @@ AC_SUBST(KARCH)
 OVS_CHECK_LINUX
 OVS_CHECK_DPDK
 OVS_CHECK_PRAGMA_MESSAGE
+AC_SUBST([OVS_CFLAGS])
+AC_SUBST([OVS_LDFLAGS])
 
 AC_CONFIG_FILES(Makefile)
 AC_CONFIG_FILES(datapath/Makefile)
diff --git a/m4/openvswitch.m4 b/m4/openvswitch.m4
index d54483b..6e24f25 100644
--- a/m4/openvswitch.m4
+++ b/m4/openvswitch.m4
@@ -30,8 +30,8 @@ AC_DEFUN([OVS_CHECK_COVERAGE],
       esac],
      [coverage=false])
    if $coverage; then
-     CFLAGS="$CFLAGS -O0 --coverage"
-     LDFLAGS="$LDFLAGS --coverage"
+     OVS_CFLAGS="$OVS_CFLAGS -O0 --coverage"
+     OVS_LDFLAGS="$OVS_LDFLAGS --coverage"
    fi])
 
 dnl Checks for --enable-ndebug and defines NDEBUG if it is specified.
-- 
1.9.3




More information about the dev mailing list