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/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