Skip to content

Commit

Permalink
build: Respect CFLAGS and LDFLAGS passed to make
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Ben Pfaff <[email protected]>
  • Loading branch information
Thomas Graf authored and blp committed Sep 11, 2014
1 parent 648cef1 commit 9562639
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 3 deletions.
2 changes: 2 additions & 0 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
8 changes: 7 additions & 1 deletion acinclude.m4
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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.
#
Expand Down
2 changes: 2 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions m4/openvswitch.m4
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 9562639

Please sign in to comment.