build: Respect CFLAGS and LDFLAGS passed to make
authorThomas Graf <tgraf@noironetworks.com>
Thu, 11 Sep 2014 19:34:21 +0000 (21:34 +0200)
committerBen Pfaff <blp@nicira.com>
Thu, 11 Sep 2014 19:37:38 +0000 (12:37 -0700)
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@noironetworks.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
Makefile.am
acinclude.m4
configure.ac
m4/openvswitch.m4

index 161936d..4c48e73 100644 (file)
@@ -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
index b0794d2..742862d 100644 (file)
@@ -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.
     #
index f1c9f9f..35e884a 100644 (file)
@@ -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)
index d54483b..6e24f25 100644 (file)
@@ -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.