@@ -187,6 +187,9 @@ AC_ARG_ENABLE([debug],
187187 [ enable_debug=$enableval] ,
188188 [ enable_debug=no] )
189189
190+ AC_LANG_PUSH ( [ C++] )
191+ AX_CHECK_COMPILE_FLAG ( [ -Werror] ,[ CXXFLAG_WERROR="-Werror"] ,[ CXXFLAG_WERROR=""] )
192+
190193if test "x$enable_debug" = xyes; then
191194 CPPFLAGS="$CPPFLAGS -DDEBUG"
192195 if test "x$GCC" = xyes; then
@@ -198,11 +201,20 @@ if test "x$enable_debug" = xyes; then
198201 fi
199202fi
200203
201- # # TODO: Remove these hard-coded paths and flags. They are here for the sake of
202- # # compatibility with the legacy buildsystem.
203- # #
204204if test "x$CXXFLAGS_overridden" = "xno"; then
205- CXXFLAGS="$CXXFLAGS -Wall -Wextra -Wformat -Wformat-security -Wno-unused-parameter -Wno-self-assign -Wno-implicit-fallthrough"
205+ AX_CHECK_COMPILE_FLAG ( [ -Wall] ,[ CXXFLAGS="$CXXFLAGS -Wall"] ,,[ [ $CXXFLAG_WERROR] ] )
206+ AX_CHECK_COMPILE_FLAG ( [ -Wextra] ,[ CXXFLAGS="$CXXFLAGS -Wextra"] ,,[ [ $CXXFLAG_WERROR] ] )
207+ AX_CHECK_COMPILE_FLAG ( [ -Wformat] ,[ CXXFLAGS="$CXXFLAGS -Wformat"] ,,[ [ $CXXFLAG_WERROR] ] )
208+ AX_CHECK_COMPILE_FLAG ( [ -Wformat-security] ,[ CXXFLAGS="$CXXFLAGS -Wformat-security"] ,,[ [ $CXXFLAG_WERROR] ] )
209+
210+ # # Some compilers (gcc) ignore unknown -Wno-* options, but warn about all
211+ # # unknown options if any other warning is produced. Test the -Wfoo case, and
212+ # # set the -Wno-foo case if it works.
213+ AX_CHECK_COMPILE_FLAG ( [ -Wunused-parameter] ,[ CXXFLAGS="$CXXFLAGS -Wno-unused-parameter"] ,,[ [ $CXXFLAG_WERROR] ] )
214+ AX_CHECK_COMPILE_FLAG ( [ -Wself-assign] ,[ CXXFLAGS="$CXXFLAGS -Wno-self-assign"] ,,[ [ $CXXFLAG_WERROR] ] )
215+ AX_CHECK_COMPILE_FLAG ( [ -Wunused-local-typedef] ,[ CXXFLAGS="$CXXFLAGS -Wno-unused-local-typedef"] ,,[ [ $CXXFLAG_WERROR] ] )
216+ AX_CHECK_COMPILE_FLAG ( [ -Wdeprecated-register] ,[ CXXFLAGS="$CXXFLAGS -Wno-deprecated-register"] ,,[ [ $CXXFLAG_WERROR] ] )
217+ AX_CHECK_COMPILE_FLAG ( [ -Wimplicit-fallthrough] ,[ CXXFLAGS="$CXXFLAGS -Wno-implicit-fallthrough"] ,,[ [ $CXXFLAG_WERROR] ] )
206218fi
207219CPPFLAGS="$CPPFLAGS -DHAVE_BUILD_INFO -D__STDC_FORMAT_MACROS"
208220
@@ -224,8 +236,6 @@ AC_ARG_WITH([daemon],
224236 [ build_bitcoind=$withval] ,
225237 [ build_bitcoind=yes] )
226238
227- AC_LANG_PUSH ( [ C++] )
228-
229239use_pkgconfig=yes
230240case $host in
231241 *mingw*)
0 commit comments