beta-0.89.2
[luatex.git] / source / libs / cairo / cairo-src / build / configure.ac.warnings
blob96c7f6f6d03a3152faf2555ba8bb8a794e5dd400
1 dnl Use lots of warning flags with with gcc and compatible compilers
3 dnl Note: if you change the following variable, the cache is automatically
4 dnl skipped and all flags rechecked.  So there's no need to do anything
5 dnl else.  If for any reason you need to force a recheck, just change
6 dnl MAYBE_WARN in an ignorable way (like adding whitespace)
8 # -Wcast-align generates lots of false positive reports we need to
9 # cast image data from uint8_t to uin32_t.
11 # -Wlogical-op causes too much noise from strcmp("literal", str)
13 MAYBE_WARN="-Wall -Wextra \
14 -Wmissing-declarations -Werror-implicit-function-declaration \
15 -Wpointer-arith -Wwrite-strings -Wsign-compare -Wpacked \
16 -Wswitch-enum -Wmissing-format-attribute -Wvolatile-register-var \
17 -Wstrict-aliasing=2 -Winit-self -Wunsafe-loop-optimizations \
18 -Wno-missing-field-initializers -Wno-unused-parameter \
19 -Wno-attributes -Wno-long-long -Winline"
21 MAYBE_C_SPECIFIC_WARN="-Wold-style-definition \
22 -Wdeclaration-after-statement -Wstrict-prototypes \
23 -Wmissing-prototypes -Wbad-function-cast -Wnested-externs"
25 # New -Wno options should be added here
26 # gcc-4.4 and later accept every -Wno- option but may complain later that this
27 # option is unknow each time another warning happen.
28 # -Wunused-but-set-variable is too noisy at present
29 NO_WARN="unused-but-set-variable"
31 dnl Sun Studio 12 likes to rag at us for abusing enums like
32 dnl having cairo_status_t variables hold cairo_int_status_t
33 dnl values.  It's bad, we know.  Now please be quiet.
34 MAYBE_WARN="$MAYBE_WARN -erroff=E_ENUM_TYPE_MISMATCH_ARG \
35                         -erroff=E_ENUM_TYPE_MISMATCH_OP"
37 dnl We also abuse the warning-flag facility to enable other compiler
38 dnl options.  Namely, the following:
39 MAYBE_WARN="$MAYBE_WARN -fno-strict-aliasing -fno-common"
41 dnl Also to turn various gcc/glibc-specific preprocessor checks
42 MAYBE_WARN="$MAYBE_WARN -Wp,-D_FORTIFY_SOURCE=2"
44 # invalidate cached value if MAYBE_WARN has changed
45 if test "x$cairo_cv_warn_maybe" != "x$MAYBE_WARN"; then
46         unset cairo_cv_warn_cflags
48 AC_CACHE_CHECK([for supported warning flags], cairo_cv_warn_cflags, [
49         echo
50         WARN_CFLAGS=""
52         # Some warning options are not supported by all versions of
53         # gcc, so test all desired options against the current
54         # compiler.
55         #
56         # Note that there are some order dependencies
57         # here. Specifically, an option that disables a warning will
58         # have no net effect if a later option then enables that
59         # warnings, (perhaps implicitly). So we put some grouped
60         # options (-Wall and -Wextra) up front and the -Wno options
61         # last.
63         for W in $MAYBE_WARN; do
64                 CAIRO_CC_TRY_FLAG([$W],, [WARN_CFLAGS="$WARN_CFLAGS $W"])
65         done
66         for W in $NO_WARN; do
67                 CAIRO_CC_TRY_FLAG([-W$W -Wno-$W],, [WARN_CFLAGS="$WARN_CFLAGS -Wno-$W"])
68         done
69         cairo_cv_warn_cflags=$WARN_CFLAGS
70         cairo_cv_warn_maybe="$MAYBE_WARN $MAYBE_C_SPECIFIC_WARN"
72         AC_MSG_CHECKING([which warning flags were supported])
74 WARN_CFLAGS="$cairo_cv_warn_cflags"
75 CAIRO_CFLAGS="$CAIRO_CFLAGS $WARN_CFLAGS"
77 # We only wish to enable attribute(warn_unused_result) if we can prevent
78 # gcc from generating thousands of warnings about the misapplication of the
79 # attribute to void functions and variables.
80 AC_CACHE_CHECK([how to enable unused result warnings], cairo_cv_warn_unused_result, [
81         AC_REQUIRE([AC_PROG_GREP])
82         cairo_cv_warn_unused_result=""
83         if echo $WARN_CFLAGS | $GREP -e '-Wno-attributes' >/dev/null; then
84             CAIRO_CC_TRY_FLAG_SILENT(
85                         [-Wno-attributes],
86                         [__attribute__((__warn_unused_result__)) void f (void) {}
87                          __attribute__((__warn_unused_result__)) int g;],
88                         [cairo_cv_warn_unused_result="__attribute__((__warn_unused_result__))"])
89         fi
91 AC_DEFINE_UNQUOTED([WARN_UNUSED_RESULT], [$cairo_cv_warn_unused_result],
92           [Define to the value your compiler uses to support the warn-unused-result attribute])
94 dnl check linker flags
95 AC_CACHE_CHECK([how to allow undefined symbols in shared libraries used by test suite], cairo_cv_test_undefined_ldflags,
96                [CAIRO_CC_TRY_FLAG_SILENT([-Wl,--allow-shlib-undefined], [],
97                                   [cairo_cv_test_undefined_ldflags="-Wl,--allow-shlib-undefined]")])
98 CAIRO_TEST_UNDEFINED_LDFLAGS="$cairo_cv_test_undefined_ldflags"
99 AC_SUBST(CAIRO_TEST_UNDEFINED_LDFLAGS)