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>
diff --git a/babeld/Makefile.am b/babeld/Makefile.am
index 13922d0..d34e180 100644
--- a/babeld/Makefile.am
+++ b/babeld/Makefile.am
@@ -4,7 +4,7 @@
DEFS = @DEFS@ -DSYSCONFDIR=\"$(sysconfdir)/\"
INSTALL_SDATA=@INSTALL@ -m 600
-AM_CFLAGS = $(PICFLAGS)
+AM_CFLAGS = $(PICFLAGS) $(WERROR)
AM_LDFLAGS = $(PILDFLAGS)
noinst_LIBRARIES = libbabel.a
diff --git a/bgpd/Makefile.am b/bgpd/Makefile.am
index 42f1f48..92fa10c 100644
--- a/bgpd/Makefile.am
+++ b/bgpd/Makefile.am
@@ -4,7 +4,7 @@
DEFS = @DEFS@ -DSYSCONFDIR=\"$(sysconfdir)/\"
INSTALL_SDATA=@INSTALL@ -m 600
-AM_CFLAGS = $(PICFLAGS)
+AM_CFLAGS = $(PICFLAGS) $(WERROR)
AM_LDFLAGS = $(PILDFLAGS)
noinst_LIBRARIES = libbgp.a
diff --git a/buildtest.sh b/buildtest.sh
index 3bc25f2..3dd8ed8 100755
--- a/buildtest.sh
+++ b/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"
diff --git a/configure.ac b/configure.ac
index b11c989..a82470c 100755
--- a/configure.ac
+++ b/configure.ac
@@ -175,6 +175,11 @@
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 @@
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
diff --git a/isisd/Makefile.am b/isisd/Makefile.am
index dba681b..4e67b22 100644
--- a/isisd/Makefile.am
+++ b/isisd/Makefile.am
@@ -6,7 +6,7 @@
INSTALL_SDATA=@INSTALL@ -m 600
LIBS = @LIBS@
-AM_CFLAGS = $(PICFLAGS)
+AM_CFLAGS = $(PICFLAGS) $(WERROR)
AM_LDFLAGS = $(PILDFLAGS)
noinst_LIBRARIES = libisis.a
diff --git a/lib/Makefile.am b/lib/Makefile.am
index 5a80618..56837d8 100644
--- a/lib/Makefile.am
+++ b/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
diff --git a/ospf6d/Makefile.am b/ospf6d/Makefile.am
index d30ce58..cbd850f 100644
--- a/ospf6d/Makefile.am
+++ b/ospf6d/Makefile.am
@@ -4,7 +4,7 @@
DEFS = @DEFS@ -DSYSCONFDIR=\"$(sysconfdir)/\"
INSTALL_SDATA=@INSTALL@ -m 600
-AM_CFLAGS = $(PICFLAGS)
+AM_CFLAGS = $(PICFLAGS) $(WERROR)
AM_LDFLAGS = $(PILDFLAGS)
noinst_LIBRARIES = libospf6.a
diff --git a/ospfclient/Makefile.am b/ospfclient/Makefile.am
index 09d2ba8..c4f0da8 100644
--- a/ospfclient/Makefile.am
+++ b/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
diff --git a/ospfd/Makefile.am b/ospfd/Makefile.am
index 4160bfc..40f2cfe 100644
--- a/ospfd/Makefile.am
+++ b/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
diff --git a/pimd/Makefile.am b/pimd/Makefile.am
index f13debd..816afb9 100644
--- a/pimd/Makefile.am
+++ b/pimd/Makefile.am
@@ -39,7 +39,7 @@
INSTALL_SDATA=@INSTALL@ -m 600
LIBS = @LIBS@
-AM_CFLAGS = $(PICFLAGS)
+AM_CFLAGS = $(PICFLAGS) $(WERROR)
AM_LDFLAGS = $(PILDFLAGS)
noinst_LIBRARIES = libpim.a
diff --git a/ripd/Makefile.am b/ripd/Makefile.am
index 65a626d..34c5f18 100644
--- a/ripd/Makefile.am
+++ b/ripd/Makefile.am
@@ -4,7 +4,7 @@
DEFS = @DEFS@ -DSYSCONFDIR=\"$(sysconfdir)/\"
INSTALL_SDATA=@INSTALL@ -m 600
-AM_CFLAGS = $(PICFLAGS)
+AM_CFLAGS = $(PICFLAGS) $(WERROR)
AM_LDFLAGS = $(PILDFLAGS)
noinst_LIBRARIES = librip.a
diff --git a/ripngd/Makefile.am b/ripngd/Makefile.am
index 9bd14ba..0487459 100644
--- a/ripngd/Makefile.am
+++ b/ripngd/Makefile.am
@@ -4,7 +4,7 @@
DEFS = @DEFS@ -DSYSCONFDIR=\"$(sysconfdir)/\"
INSTALL_SDATA=@INSTALL@ -m 600
-AM_CFLAGS = $(PICFLAGS)
+AM_CFLAGS = $(PICFLAGS) $(WERROR)
AM_LDFLAGS = $(PILDFLAGS)
noinst_LIBRARIES = libripng.a
diff --git a/vtysh/Makefile.am b/vtysh/Makefile.am
index a66615b..0cc6d5b 100644
--- a/vtysh/Makefile.am
+++ b/vtysh/Makefile.am
@@ -5,7 +5,7 @@
LIBS = @LIBS@ @CURSES@ @LIBPAM@
-AM_CFLAGS = $(PICFLAGS)
+AM_CFLAGS = $(PICFLAGS) $(WERROR)
AM_LDFLAGS = $(PILDFLAGS)
bin_PROGRAMS = vtysh
diff --git a/watchquagga/Makefile.am b/watchquagga/Makefile.am
index 9256006..939ecd7 100644
--- a/watchquagga/Makefile.am
+++ b/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
diff --git a/zebra/Makefile.am b/zebra/Makefile.am
index 4808791..7dcbd66 100644
--- a/zebra/Makefile.am
+++ b/zebra/Makefile.am
@@ -20,7 +20,7 @@
othersrc = zebra_fpm_netlink.c
endif
-AM_CFLAGS = $(PICFLAGS)
+AM_CFLAGS = $(PICFLAGS) $(WERROR)
AM_LDFLAGS = $(PILDFLAGS)
sbin_PROGRAMS = zebra