[ovs-dev] [PATCH 2/2] tests: Link test-multipath with libm.

Ben Pfaff blp at nicira.com
Tue Apr 12 18:29:58 UTC 2011


On Tue, Apr 12, 2011 at 11:03:49AM -0700, Andrew Evans wrote:
> On 4/12/11 10:00 AM, Ben Pfaff wrote:
> > Even without this patch I see -lm in the linker command:
> > 
> >     gcc -Wstrict-prototypes -Wall -Wno-sign-compare -Wpointer-arith
> >     -Wdeclaration-after-statement -Wformat-security -Wswitch-enum
> >     -Wunused-parameter -Wstrict-aliasing -Wbad-function-cast
> >     -Wcast-align -Wstrict-prototypes -Wold-style-definition
> >     -Wmissing-prototypes -Wmissing-field-initializers
> >     -Wno-override-init -g -O2 -export-dynamic -o tests/test-multipath
> >     tests/test-multipath.o lib/libopenvswitch.a -lrt -lm
> > 
> > That's because it's in LIBS due to this configure check:
> > 
> >     AC_SEARCH_LIBS([pow], [m])
> > 
> > Why isn't -lm in LIBS on Gentoo?
> 
> Ben noticed that I was running configure with -Werror set in CFLAGS.
> This breaks configure's library checks.
> 
> Patch retracted.

Here's a replacement patch.  Does it work for you?

--8<--------------------------cut here-------------------------->8--

From: Ben Pfaff <blp at nicira.com>
Date: Tue, 12 Apr 2011 11:29:09 -0700
Subject: [PATCH] configure: Add option --enable-Werror to add -Werror to CFLAGS.

-Werror is useful for development, but it screws up configure because it's
impossible to guess what new warnings compilers will add in the future.
This commit adds a new configure option to add CFLAGS after the configure
checks are done.

The use of AC_CONFIG_COMMANDS_PRE is based on Eric Blake's suggestion on
the autoconf mailing list: "AC_CONFIG_COMMANDS_PRE probably fits the bill
as the ideal macro to use for guaranteeing that you inject your shell code
at the last possible moment."

Requested-by: Andrew Evan <aevans at nicira.com>
---
 acinclude.m4 |   11 +++++++++++
 configure.ac |    1 +
 2 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/acinclude.m4 b/acinclude.m4
index fa6f534..69e61e0 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -14,6 +14,17 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+dnl OVS_ENABLE_WERROR
+AC_DEFUN([OVS_ENABLE_WERROR],
+  [AC_ARG_ENABLE(
+     [Werror],
+     [AC_HELP_STRING([--enable-Werror], [Add -Werror to CFLAGS])],
+     [], [enable_Werror=no])
+   AC_CONFIG_COMMANDS_PRE(
+     [if test "X$enable_Werror" = Xyes; then
+        CFLAGS="$CFLAGS -Werror"
+      fi])])
+
 dnl OVS_CHECK_LINUX26
 dnl
 dnl Configure linux kernel source tree 
diff --git a/configure.ac b/configure.ac
index 5a2b5c0..5b5f47e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -84,6 +84,7 @@ OVS_ENABLE_OPTION([-Wmissing-field-initializers])
 OVS_ENABLE_OPTION([-Wno-override-init])
 OVS_CONDITIONAL_CC_OPTION([-Wno-unused], [HAVE_WNO_UNUSED])
 OVS_CONDITIONAL_CC_OPTION([-Wno-unused-parameter], [HAVE_WNO_UNUSED_PARAMETER])
+OVS_ENABLE_WERROR
 
 AC_ARG_VAR(KARCH, [Kernel Architecture String])
 AC_SUBST(KARCH)
-- 
1.7.1




More information about the dev mailing list