2008-09-03 20:06:26 -04:00
|
|
|
dnl Use lots of warning flags with with gcc and compatible compilers
|
|
|
|
|
|
|
|
|
|
dnl Note: if you change the following variable, the cache is automatically
|
|
|
|
|
dnl skipped and all flags rechecked. So there's no need to do anything
|
|
|
|
|
dnl else. If for any reason you need to force a recheck, just change
|
|
|
|
|
dnl MAYBE_WARN in an ignorable way (like adding whitespace)
|
|
|
|
|
|
|
|
|
|
MAYBE_WARN="-Wall -Wextra \
|
|
|
|
|
-Wsign-compare -Werror-implicit-function-declaration \
|
|
|
|
|
-Wpointer-arith -Wwrite-strings -Wstrict-prototypes \
|
|
|
|
|
-Wmissing-prototypes -Wmissing-declarations -Wnested-externs \
|
|
|
|
|
-Wpacked -Wswitch-enum -Wmissing-format-attribute \
|
|
|
|
|
-Wstrict-aliasing=2 -Winit-self -Wunsafe-loop-optimizations \
|
|
|
|
|
-Wdeclaration-after-statement -Wold-style-definition \
|
|
|
|
|
-Wno-missing-field-initializers -Wno-unused-parameter \
|
|
|
|
|
-Wno-attributes -Wno-long-long -Winline"
|
|
|
|
|
|
|
|
|
|
dnl We also abuse the warning-flag facility to enable other compiler
|
|
|
|
|
dnl options. Namely, the following:
|
2008-10-15 22:27:53 +01:00
|
|
|
MAYBE_WARN="$MAYBE_WARN -fno-strict-aliasing -fno-common"
|
2008-09-03 20:06:26 -04:00
|
|
|
|
2008-09-19 18:43:43 -04:00
|
|
|
dnl Also to turn various gcc/glibc-specific preprocessor checks
|
|
|
|
|
MAYBE_WARN="$MAYBE_WARN -Wp,-D_FORTIFY_SOURCE=2"
|
|
|
|
|
|
2008-09-03 20:06:26 -04:00
|
|
|
# invalidate cached value if MAYBE_WARN has changed
|
|
|
|
|
if test "x$cairo_cv_warn_maybe" != "x$MAYBE_WARN"; then
|
|
|
|
|
unset cairo_cv_warn_cflags
|
|
|
|
|
fi
|
|
|
|
|
AC_CACHE_CHECK([for supported warning flags], cairo_cv_warn_cflags, [
|
|
|
|
|
echo
|
|
|
|
|
WARN_CFLAGS=""
|
|
|
|
|
|
|
|
|
|
# Some warning options are not supported by all versions of
|
|
|
|
|
# gcc, so test all desired options against the current
|
|
|
|
|
# compiler.
|
|
|
|
|
#
|
|
|
|
|
# Note that there are some order dependencies
|
|
|
|
|
# here. Specifically, an option that disables a warning will
|
|
|
|
|
# have no net effect if a later option then enables that
|
|
|
|
|
# warnings, (perhaps implicitly). So we put some grouped
|
|
|
|
|
# options (-Wall and -Wextra) up front and the -Wno options
|
|
|
|
|
# last.
|
|
|
|
|
|
|
|
|
|
for W in $MAYBE_WARN; do
|
|
|
|
|
CAIRO_CC_TRY_FLAG([$W], [WARN_CFLAGS="$WARN_CFLAGS $W"])
|
|
|
|
|
done
|
|
|
|
|
|
|
|
|
|
cairo_cv_warn_cflags=$WARN_CFLAGS
|
|
|
|
|
cairo_cv_warn_maybe=$MAYBE_WARN
|
|
|
|
|
|
|
|
|
|
AC_MSG_CHECKING([which warning flags were supported])
|
|
|
|
|
])
|
|
|
|
|
WARN_CFLAGS="$cairo_cv_warn_cflags"
|
|
|
|
|
CAIRO_CFLAGS="$CAIRO_CFLAGS $WARN_CFLAGS"
|
|
|
|
|
|
|
|
|
|
# We only wish to enable attribute(warn_unused_result) if we can prevent
|
|
|
|
|
# gcc from generating thousands of warnings about the misapplication of the
|
|
|
|
|
# attribute to void functions and variables.
|
|
|
|
|
AC_CACHE_CHECK([how to enable unused result warnings], cairo_cv_warn_unused_result, [
|
|
|
|
|
cairo_cv_warn_unused_result=""
|
|
|
|
|
if echo $WARN_CFLAGS | grep -e '-Wno-attributes' >/dev/null; then
|
|
|
|
|
AC_TRY_COMPILE([__attribute__((__warn_unused_result__))
|
|
|
|
|
int f (int i) { return i; }], [],
|
|
|
|
|
[cairo_cv_warn_unused_result="__attribute__((__warn_unused_result__))"])
|
|
|
|
|
fi
|
|
|
|
|
])
|
|
|
|
|
AC_DEFINE_UNQUOTED([WARN_UNUSED_RESULT], [$cairo_cv_warn_unused_result],
|
|
|
|
|
[Define to the value your compiler uses to support the warn-unused-result attribute])
|
2008-09-17 01:05:16 +01:00
|
|
|
|
|
|
|
|
dnl check linker flags
|
|
|
|
|
AC_CACHE_CHECK([how to allow undefined symbols in shared libraries used by test suite], cairo_cv_test_undefined_ldflags,
|
|
|
|
|
[CAIRO_CC_TRY_FLAG([-Wl,--allow-shlib-undefined],
|
|
|
|
|
[cairo_cv_test_undefined_ldflags="-Wl,--allow-shlib-undefined]")])
|
|
|
|
|
CAIRO_TEST_UNDEFINED_LDFLAGS="$cairo_cv_test_undefined_ldflags"
|
|
|
|
|
AC_SUBST(CAIRO_TEST_UNDEFINED_LDFLAGS)
|