1################################################################ 2# 3# Enable all the compiler debugging we can find 4# Simson L. Garfinkel 5# 6# This is originally from PhotoRec, but modified substantially by Simson 7# Figure out which flags we can use with the compiler. 8# 9# These I don't like: 10# -Wdeclaration-after-statement -Wconversion 11# doesn't work: -Wunreachable-code 12# causes configure to crash on gcc-4.2.1: -Wsign-compare-Winline 13# causes warnings with unistd.h: -Wnested-externs 14# Just causes too much annoyance: -Wmissing-format-attribute 15# 16################################################################ 17# bda - Changed to set HASHDB_CFLAGS instead of CFLAGS 18# and HASHDB_CXXFLAGS instead of CXXFLAGS 19# to allow visibility to foo_CFLAGS 20 21# First, see if we are using CLANG 22using_clang=no 23if (g++ --version 2>&1 | grep clang > /dev/null) ; 24then 25 AC_MSG_NOTICE([g++ is really clang++]) 26 using_clang=yes 27fi 28if test x$CXX == "xclang++" ; then 29 using_clang=yes 30fi 31 32 33 34# Check GCC 35C_FLAGS_TO_TEST="-MD -Wpointer-arith -Wmissing-declarations -Wmissing-prototypes \ 36 -Wshadow -Wwrite-strings -Wcast-align -Waggregate-return \ 37 -Wbad-function-cast -Wcast-qual -Wundef -Wredundant-decls -Wdisabled-optimization \ 38 -Wfloat-equal -Wmultichar -Wc++-compat -Wmissing-noreturn " 39 40if test x"${mingw}" != "xyes" ; then 41 # add the warnings we do not want to do on mingw 42 C_FLAGS_TO_TEST="$C_FLAGS_TO_TEST -Wall -Wstrict-prototypes" 43fi 44 45if test $using_clang == "no" ; then 46 # -Wstrict-null-sentinel is not supported under clang 47 CXX_FLAGS_TO_TEST="$CXX_FLAGS_TO_TEST -Wstrict-null-sentinel" 48fi 49 50 51 52echo "C flags to test: $C_FLAGS_TO_TEST" 53 54for option in $C_FLAGS_TO_TEST 55do 56 SAVE_CFLAGS="$CFLAGS" 57 CFLAGS="$CFLAGS $option" 58 AC_MSG_CHECKING([whether gcc understands $option]) 59 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])], 60 [has_option=yes; HASHDB_CFLAGS="$HASHDB_CFLAGS $option"], 61 [has_option=no]) 62 AC_MSG_RESULT($has_option) 63 unset has_option 64 CFLAGS="$SAVE_CFLAGS" 65 unset SAVE_CFLAGS 66 if test $option = "-Wmissing-format-attribute" ; then 67 AC_DEFINE(HAVE_MISSING_FORMAT_ATTRIBUTE_WARNING,1, 68 [Indicates that we have the -Wmissing-format-attribute G++ warning]) 69 fi 70done 71unset option 72 73 74# Check G++ 75# We don't use these warnings: 76# -Waggregate-return -- aggregate returns are GOOD; they simplify code design 77# We can use these warnings after ZLIB gets upgraded: 78# -Wundef --- causes problems with zlib 79# -Wcast-qual 80# -Wmissing-format-attribute --- Just too annoying 81AC_LANG_PUSH(C++) 82AC_CHECK_HEADERS([string]) 83CXX_FLAGS_TO_TEST="-Wall -MD -D_FORTIFY_SOURCE=2 -Wpointer-arith \ 84 -Wshadow -Wwrite-strings -Wcast-align \ 85 -Wredundant-decls -Wdisabled-optimization \ 86 -Wfloat-equal -Wmultichar -Wmissing-noreturn \ 87 -Woverloaded-virtual -Wsign-promo \ 88 -funit-at-a-time" 89 90if test x"${mingw}" != "xyes" ; then 91 # add the warnings we don't want to do on mingw 92 CXX_FLAGS_TO_TEST="$CXX_FLAGS_TO_TEST -Weffc++" 93fi 94 95echo "C++ flags to test: $CXX_FLAGS_TO_TEST" 96 97for option in $CXX_FLAGS_TO_TEST 98do 99 SAVE_CXXFLAGS="$CXXFLAGS" 100 CXXFLAGS="$CXXFLAGS $option" 101 AC_MSG_CHECKING([whether g++ understands $option]) 102 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])], 103 [has_option=yes; HASHDB_CXXFLAGS="$HASHDB_CXXFLAGS $option"], 104 [has_option=no]) 105 AC_MSG_RESULT($has_option) 106 unset has_option 107 CXXFLAGS="$SAVE_CXXFLAGS" 108 unset SAVE_CXXFLAGS 109done 110unset option 111AC_LANG_POP() 112 113AC_SUBST(HASHDB_CFLAGS) 114AC_SUBST(HASHDB_CXXFLAGS) 115 116