CFLAGS=${SAVED_CFLAGS}
LDFLAGS=${SAVED_LDFLAGS}
- if test ${enable_debugging} = no; then
+ if test x"${enable_debugging}" = xno; then
CFLAGS="-O3 ${CFLAGS}"
else
- CFLAGS="-O0 -g -DENABLE_DEBUGGING_TOOLS ${CFLAGS}"
+ if test x"${enable_debugging}" = xyes; then
+ CFLAGS="-DENABLE_DEBUGGING_TOOLS ${CFLAGS}"
+ fi
+ CFLAGS="-O0 -g ${CFLAGS}"
LDFLAGS="${LDFLAGS} -g"
fi
- CFLAGS="-Wall -Wundef -Wpointer-arith -Winline ${CFLAGS}"
- CFLAGS="-Wstrict-prototypes -Wnested-externs -Wredundant-decls ${CFLAGS}"
-
- AC_MSG_CHECKING([for GCC>=4])
- AC_COMPILE_IFELSE(
- [AC_LANG_PROGRAM(
- [[
- #if __GNUC__ >= 4
- ;
- #else
- #error "gcc too old"
- #endif
- ]],
- [[]]
- )],
- [
- AC_MSG_RESULT([yes])
- CFLAGS="-Wextra -Wno-sign-compare -Wno-unused-parameter ${CFLAGS}"
- CFLAGS="-Wold-style-definition ${CFLAGS}"
- ],
- [AC_MSG_RESULT([no])])
+ CFLAGS_WERROR=-Werror
+
+ for flag in \
+ -Wall \
+ -Wclobbered \
+ -Wempty-body \
+ -Wignored-qualifiers \
+ -Wimplicit-fallthrough \
+ -Winline \
+ -Wmissing-field-initializers \
+ -Wmissing-parameter-type \
+ -Wnested-externs \
+ -Wold-style-declaration \
+ -Woverride-init \
+ -Wpointer-arith \
+ -Wredundant-decls \
+ -Wshift-negative-value \
+ -Wstrict-prototypes \
+ -Wtype-limits \
+ -Wundef \
+ -Wuninitialized \
+ -Wunreachable-code \
+ -Wwrite-strings \
+ \
+ -Wno-error=stringop-truncation \
+ ; do
+ AC_MSG_CHECKING([for compiler warning $flag])
+ SAVED_CFLAGS="$CFLAGS"
+ CFLAGS="$CFLAGS $flag"
+ AC_TRY_COMPILE([],[],
+ [AC_MSG_RESULT(yes)],
+ [AC_MSG_RESULT(no)
+ CFLAGS="$SAVED_CFLAGS"])
+ done
# other possibilities:
- # -Wmissing-prototypes -Wunreachable-code -Wwrite-strings
+ # -Wmissing-prototypes (requires prototypes for DEFINE_PRIMITIVE)
+ # -Wstringop-truncation (requires it to not whine about correct use
+ # of strncpy for buffers that are _not_ null-terminated)
fi
FOO=`${INSTALL} --help 2> /dev/null | ${FGREP} -e --preserve-timestamps`
if test "x${FOO}" != x; then