@@ -192,6 +192,13 @@ AC_ARG_ENABLE([debug],
192192 [ enable_debug=$enableval] ,
193193 [ enable_debug=no] )
194194
195+ # Turn warnings into errors
196+ AC_ARG_ENABLE ( [ werror] ,
197+ [ AS_HELP_STRING ( [ --enable-werror] ,
198+ [ Treat certain compiler warnings as errors (default is no)] ) ] ,
199+ [ enable_werror=$enableval] ,
200+ [ enable_werror=no] )
201+
195202AC_LANG_PUSH ( [ C++] )
196203AX_CHECK_COMPILE_FLAG ( [ -Werror] ,[ CXXFLAG_WERROR="-Werror"] ,[ CXXFLAG_WERROR=""] )
197204
@@ -206,6 +213,14 @@ if test "x$enable_debug" = xyes; then
206213 fi
207214fi
208215
216+ ERROR_CXXFLAGS=
217+ if test "x$enable_werror" = "xyes"; then
218+ if test "x$CXXFLAG_WERROR" = "x"; then
219+ AC_MSG_ERROR ( "enable-werror set but - Werror is not usable" )
220+ fi
221+ AX_CHECK_COMPILE_FLAG ( [ -Werror=vla] ,[ ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=vla"] ,,[ [ $CXXFLAG_WERROR] ] )
222+ fi
223+
209224if test "x$CXXFLAGS_overridden" = "xno"; then
210225 AX_CHECK_COMPILE_FLAG ( [ -Wall] ,[ CXXFLAGS="$CXXFLAGS -Wall"] ,,[ [ $CXXFLAG_WERROR] ] )
211226 AX_CHECK_COMPILE_FLAG ( [ -Wextra] ,[ CXXFLAGS="$CXXFLAGS -Wextra"] ,,[ [ $CXXFLAG_WERROR] ] )
@@ -1067,6 +1082,7 @@ AC_SUBST(BITCOIN_CLI_NAME)
10671082AC_SUBST ( BITCOIN_TX_NAME )
10681083
10691084AC_SUBST ( RELDFLAGS )
1085+ AC_SUBST ( ERROR_CXXFLAGS )
10701086AC_SUBST ( HARDENED_CXXFLAGS )
10711087AC_SUBST ( HARDENED_CPPFLAGS )
10721088AC_SUBST ( HARDENED_LDFLAGS )
@@ -1156,6 +1172,7 @@ echo " with test = $use_tests"
11561172echo " with bench = $use_bench"
11571173echo " with upnp = $use_upnp"
11581174echo " debug enabled = $enable_debug"
1175+ echo " werror = $enable_werror"
11591176echo
11601177echo " target os = $TARGET_OS"
11611178echo " build os = $BUILD_OS"
0 commit comments