Browse Source

build: add --enable-werror

This allows enabling -Werror in a consistent way.  Note that this is
different from just specifiying it in CFLAGS, since that would either
break configure tests (if done on ./configure), or would override
configure's CFLAGS (if done on make).

Using --enable-werror instead provides a new WERROR variable that is
additionally used during make with a consistent set of warning flags.

The tests/ directory is exempt.  (Rationale being, better to have more
tests than pedantically complain about them.)

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
David Lamparter 6 years ago
parent
commit
c0bedebfe9

+ 1 - 1
babeld/Makefile.am

@@ -4,7 +4,7 @@ AM_CPPFLAGS = -I.. -I$(top_srcdir) -I$(top_srcdir)/lib -I$(top_builddir)/lib
 DEFS = @DEFS@ -DSYSCONFDIR=\"$(sysconfdir)/\"
 INSTALL_SDATA=@INSTALL@ -m 600
 
-AM_CFLAGS = $(PICFLAGS)
+AM_CFLAGS = $(PICFLAGS) $(WERROR)
 AM_LDFLAGS = $(PILDFLAGS)
 
 noinst_LIBRARIES = libbabel.a

+ 1 - 1
bgpd/Makefile.am

@@ -4,7 +4,7 @@ AM_CPPFLAGS = -I.. -I$(top_srcdir) -I$(top_srcdir)/lib -I$(top_builddir)/lib
 DEFS = @DEFS@ -DSYSCONFDIR=\"$(sysconfdir)/\"
 INSTALL_SDATA=@INSTALL@ -m 600
 
-AM_CFLAGS = $(PICFLAGS)
+AM_CFLAGS = $(PICFLAGS) $(WERROR)
 AM_LDFLAGS = $(PILDFLAGS)
 
 noinst_LIBRARIES = libbgp.a

+ 1 - 1
buildtest.sh

@@ -4,7 +4,7 @@
 # builds some git commit of Quagga in some different configurations
 # usage: buildtest.sh [commit [configurations...]]
 
-basecfg="--prefix=/usr --enable-user=quagga --enable-group=quagga --enable-vty-group=quagga --enable-configfile-mask=0660 --enable-logfile-mask=0640 --enable-vtysh --sysconfdir=/etc/quagga --enable-exampledir=/etc/quagga/samples --localstatedir=/var/run/quagga --libdir=/usr/lib64/quagga --enable-rtadv --disable-static --enable-isisd --enable-multipath=0 --enable-babeld --enable-pimd"
+basecfg="--prefix=/usr --enable-user=quagga --enable-group=quagga --enable-vty-group=quagga --enable-configfile-mask=0660 --enable-logfile-mask=0640 --enable-vtysh --sysconfdir=/etc/quagga --enable-exampledir=/etc/quagga/samples --localstatedir=/var/run/quagga --libdir=/usr/lib64/quagga --enable-rtadv --disable-static --enable-isisd --enable-multipath=0 --enable-babeld --enable-pimd --enable-werror"
 
 configs_base="gcc|$basecfg"
 

+ 7 - 0
configure.ac

@@ -175,6 +175,11 @@ else
   AC_MSG_RESULT([CFLAGS supplied by user])
 fi
 
+if test x"${enable_werror}" = x"yes" ; then
+  WERROR="-Werror"
+fi
+AC_SUBST(WERROR)
+
 dnl --------------
 dnl Check programs
 dnl --------------
@@ -296,6 +301,8 @@ AC_ARG_ENABLE(pcreposix,
   AS_HELP_STRING([--enable-pcreposix], [enable using PCRE Posix libs for regex functions]))
 AC_ARG_ENABLE(fpm,
   AS_HELP_STRING([--enable-fpm], [enable Forwarding Plane Manager support]))
+AC_ARG_ENABLE(werror,
+  AS_HELP_STRING([--enable-werror], [enable -Werror (recommended for developers only)]))
 
 if test x"${enable_gcc_rdynamic}" != x"no" ; then
   if test x"${enable_gcc_rdynamic}" = x"yes" -o x"$COMPILER" = x"GCC"; then

+ 1 - 1
isisd/Makefile.am

@@ -6,7 +6,7 @@ DEFS = @DEFS@ -DSYSCONFDIR=\"$(sysconfdir)/\"
 INSTALL_SDATA=@INSTALL@ -m 600
 LIBS = @LIBS@ 
 
-AM_CFLAGS = $(PICFLAGS)
+AM_CFLAGS = $(PICFLAGS) $(WERROR)
 AM_LDFLAGS = $(PILDFLAGS)
 
 noinst_LIBRARIES = libisis.a

+ 1 - 0
lib/Makefile.am

@@ -1,6 +1,7 @@
 ## Process this file with automake to produce Makefile.in.
 
 AM_CPPFLAGS = -I.. -I$(top_srcdir) -I$(top_srcdir)/lib -I$(top_builddir)/lib
+AM_CFLAGS = $(WERROR)
 DEFS = @DEFS@ -DSYSCONFDIR=\"$(sysconfdir)/\"
 
 lib_LTLIBRARIES = libzebra.la

+ 1 - 1
ospf6d/Makefile.am

@@ -4,7 +4,7 @@ AM_CPPFLAGS = -I.. -I$(top_srcdir) -I$(top_srcdir)/lib -I$(top_builddir)/lib
 DEFS = @DEFS@ -DSYSCONFDIR=\"$(sysconfdir)/\"
 INSTALL_SDATA=@INSTALL@ -m 600
 
-AM_CFLAGS = $(PICFLAGS)
+AM_CFLAGS = $(PICFLAGS) $(WERROR)
 AM_LDFLAGS = $(PILDFLAGS)
 
 noinst_LIBRARIES = libospf6.a

+ 1 - 0
ospfclient/Makefile.am

@@ -1,6 +1,7 @@
 ## Automake.am for OSPF API client
 
 AM_CPPFLAGS = -I.. -I$(top_srcdir) -I$(top_srcdir)/lib -I$(top_builddir)/lib
+AM_CFLAGS = $(WERROR)
 
 lib_LTLIBRARIES = libospfapiclient.la
 libospfapiclient_la_LDFLAGS = -version-info 0:0:0

+ 1 - 0
ospfd/Makefile.am

@@ -1,6 +1,7 @@
 ## Process this file with automake to produce Makefile.in.
 
 AM_CPPFLAGS = -I.. -I$(top_srcdir) -I$(top_srcdir)/lib -I$(top_builddir)/lib
+AM_CFLAGS = $(WERROR)
 DEFS = @DEFS@ $(LOCAL_OPTS) -DSYSCONFDIR=\"$(sysconfdir)/\"
 INSTALL_SDATA=@INSTALL@ -m 600
 

+ 1 - 1
pimd/Makefile.am

@@ -39,7 +39,7 @@ DEFS = @DEFS@ -DSYSCONFDIR=\"$(sysconfdir)/\" $(PIM_DEFS)
 INSTALL_SDATA=@INSTALL@ -m 600
 LIBS = @LIBS@
 
-AM_CFLAGS = $(PICFLAGS)
+AM_CFLAGS = $(PICFLAGS) $(WERROR)
 AM_LDFLAGS = $(PILDFLAGS)
 
 noinst_LIBRARIES = libpim.a

+ 1 - 1
ripd/Makefile.am

@@ -4,7 +4,7 @@ AM_CPPFLAGS = -I.. -I$(top_srcdir) -I$(top_srcdir)/lib -I$(top_builddir)/lib
 DEFS = @DEFS@ -DSYSCONFDIR=\"$(sysconfdir)/\"
 INSTALL_SDATA=@INSTALL@ -m 600
 
-AM_CFLAGS = $(PICFLAGS)
+AM_CFLAGS = $(PICFLAGS) $(WERROR)
 AM_LDFLAGS = $(PILDFLAGS)
 
 noinst_LIBRARIES = librip.a

+ 1 - 1
ripngd/Makefile.am

@@ -4,7 +4,7 @@ AM_CPPFLAGS = -I.. -I$(top_srcdir) -I$(top_srcdir)/lib -I$(top_builddir)/lib
 DEFS = @DEFS@ -DSYSCONFDIR=\"$(sysconfdir)/\"
 INSTALL_SDATA=@INSTALL@ -m 600
 
-AM_CFLAGS = $(PICFLAGS)
+AM_CFLAGS = $(PICFLAGS) $(WERROR)
 AM_LDFLAGS = $(PILDFLAGS)
 
 noinst_LIBRARIES = libripng.a

+ 1 - 1
vtysh/Makefile.am

@@ -5,7 +5,7 @@ DEFS = @DEFS@ -DSYSCONFDIR=\"$(sysconfdir)/\"
 
 LIBS = @LIBS@ @CURSES@ @LIBPAM@
 
-AM_CFLAGS = $(PICFLAGS)
+AM_CFLAGS = $(PICFLAGS) $(WERROR)
 AM_LDFLAGS = $(PILDFLAGS)
 
 bin_PROGRAMS = vtysh

+ 1 - 1
watchquagga/Makefile.am

@@ -3,7 +3,7 @@
 AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/lib -I$(top_builddir)/lib
 DEFS = @DEFS@ -DSTATEDIR=\"$(localstatedir)/\"
 
-AM_CFLAGS = $(PICFLAGS)
+AM_CFLAGS = $(PICFLAGS) $(WERROR)
 AM_LDFLAGS = $(PILDFLAGS)
 
 sbin_PROGRAMS = watchquagga

+ 1 - 1
zebra/Makefile.am

@@ -20,7 +20,7 @@ if HAVE_NETLINK
 othersrc = zebra_fpm_netlink.c
 endif
 
-AM_CFLAGS = $(PICFLAGS)
+AM_CFLAGS = $(PICFLAGS) $(WERROR)
 AM_LDFLAGS = $(PILDFLAGS)
 
 sbin_PROGRAMS = zebra