summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDom Lachowicz <domlachowicz@gmail.com>2008-03-02 00:28:29 +0000
committerDom Lachowicz <domlachowicz@gmail.com>2008-03-02 00:28:29 +0000
commite3c142600fb6d9b8740eec99284f1e75f746379c (patch)
tree87591f0d9f43f38df7382904f0f6ef21c280c345
parent7b8e3a1f27d41887599aaea8d11b83d1875c7595 (diff)
downloadenchant-e3c142600fb6d9b8740eec99284f1e75f746379c.tar.gz
lots of warning flags
git-svn-id: svn+ssh://svn.abisource.com/svnroot/enchant/trunk@22988 bcba8976-2d24-0410-9c9c-aab3bd5fdfd6
-rw-r--r--configure.in69
1 files changed, 69 insertions, 0 deletions
diff --git a/configure.in b/configure.in
index 6510a1d..4a9c54f 100644
--- a/configure.in
+++ b/configure.in
@@ -51,6 +51,75 @@ AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
PKG_CHECK_MODULES(ENCHANT, [glib-2.0 >= 2.6 gmodule-2.0])
+dnl ===========================================================================
+dnl check compiler flags
+AC_DEFUN([ENCHANT_CC_TRY_FLAG], [
+ AC_MSG_CHECKING([whether $CC supports $1])
+
+ enchant_save_CFLAGS="$CFLAGS"
+ CFLAGS="$CFLAGS $1"
+
+ AC_COMPILE_IFELSE([ ], [enchant_cc_flag=yes], [enchant_cc_flag=no])
+ CFLAGS="$enchant_save_CFLAGS"
+
+ if test "x$enchant_cc_flag" = "xyes"; then
+ ifelse([$2], , :, [$2])
+ else
+ ifelse([$3], , :, [$3])
+ fi
+ AC_MSG_RESULT([$enchant_cc_flag])
+])
+
+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"
+
+# invalidate cached value if MAYBE_WARN has changed
+if test "x$enchant_cv_warn_maybe" != "x$MAYBE_WARN"; then
+ unset enchant_cv_warn_cflags
+fi
+AC_CACHE_CHECK([for supported warning flags], enchant_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
+ ENCHANT_CC_TRY_FLAG([$W], [WARN_CFLAGS="$WARN_CFLAGS $W"])
+ done
+
+ enchant_cv_warn_cflags=$WARN_CFLAGS
+ enchant_cv_warn_maybe=$MAYBE_WARN
+
+ AC_MSG_CHECKING([which warning flags were supported])])
+WARN_CFLAGS="$enchant_cv_warn_cflags"
+ENCHANT_CFLAGS="$ENCHANT_CFLAGS $WARN_CFLAGS"
+
+ENCHANT_CC_TRY_FLAG([-fno-strict-aliasing],
+ [ENCHANT_CFLAGS="$ENCHANT_CFLAGS -fno-strict-aliasing"])
+
AC_SUBST(ENCHANT_CFLAGS)
AC_SUBST(ENCHANT_LIBS)