configure.ac: Add --enable-werror option

Change-Id: Ib2782aecd400398bf36427f255c2a427ef781e06
diff --git a/configure.ac b/configure.ac
index cc099d2..e1cc121 100644
--- a/configure.ac
+++ b/configure.ac
@@ -90,6 +90,25 @@
 	LDFLAGS="$LDFLAGS -fsanitize=address -fsanitize=undefined"
 fi
 
+AC_ARG_ENABLE(werror,
+	[AS_HELP_STRING(
+		[--enable-werror],
+		[Turn all compiler warnings into errors, with exceptions:
+		 a) deprecation (allow upstream to mark deprecation without breaking builds);
+		 b) "#warning" pragmas (allow to remind ourselves of errors without breaking builds)
+		]
+	)],
+	[werror=$enableval], [werror="no"])
+if test x"$werror" = x"yes"
+then
+	WERROR_FLAGS="-Werror"
+	WERROR_FLAGS+=" -Wno-error=deprecated -Wno-error=deprecated-declarations"
+	WERROR_FLAGS+=" -Wno-error=cpp" # "#warning"
+	CFLAGS="$CFLAGS $WERROR_FLAGS"
+	CPPFLAGS="$CPPFLAGS $WERROR_FLAGS"
+fi
+
+
 AC_ARG_WITH(uhd, [
     AS_HELP_STRING([--with-uhd],
         [enable UHD based transceiver])