--- configure.orig Wed Aug 9 18:17:28 2006 +++ configure.in Wed Aug 9 18:23:42 2006 @@ -531,22 +531,40 @@ AC_CHECK_HEADERS([stdint.h inttypes.h sys/int_types.h]) AC_CHECK_TYPES([uint64_t, uint128_t]) -dnl Use lots of warning flags with GCC +AC_DEFUN([AC_CC_TRY_FLAG], [ + AC_MSG_CHECKING([whether $CC supports $1]) -WARN_CFLAGS="" + ac_save_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS $1" + + AC_COMPILE_IFELSE([ ], [ac_cc_flag=yes], [ac_cc_flag=no]) + CFLAGS="$ac_save_CFLAGS" + + if test "x$ac_cc_flag" = "xyes"; then + ifelse([$2], , :, [$2]) + else + ifelse([$3], , :, [$3]) + fi + AC_MSG_RESULT([$ac_cc_flag]) +]) -dnl XXX: Here are some warnings we'd like to eanble, but it looks like -dnl we'll need to make them conditional on gcc version >= 4 or so: -dnl -dnl -Wstrict-aliasing=2 -Winit-self -Wunsafe-loop-optimizations -dnl -Wdeclaration-after-statement -Wold-style-definition +dnl Use lots of warning flags with GCC +WARN_CFLAGS="" if test "x$GCC" = "xyes"; then + # some warnings are not supported by all versions of gcc + MAYBE_WARN="-Wpacked -Wswitch-enum -Wmissing-format-attribute \ + -Wstrict-aliasing=2 -Winit-self -Wunsafe-loop-optimizations \ + -Wdeclaration-after-statement -Wold-style-definition" + WARN_CFLAGS="-Wall -Wsign-compare -Werror-implicit-function-declaration \ - -Wpointer-arith -Wwrite-strings -Wswitch-enum \ - -Wpacked -Wmissing-format-attribute -Wstrict-prototypes \ + -Wpointer-arith -Wwrite-strings -Wstrict-prototypes \ -Wmissing-prototypes -Wmissing-declarations \ -Wnested-externs -fno-strict-aliasing" + + for W in $MAYBE_WARN; do + AC_CC_TRY_FLAG([$W], [WARN_CFLAGS="$WARN_CFLAGS $W"]) + done fi AC_SUBST(WARN_CFLAGS)