summaryrefslogtreecommitdiff
path: root/configure.ac
diff options
context:
space:
mode:
authorJinghua Luo <sunmoon1997@gmail.com>2007-02-03 23:01:08 +0800
committerJinghua Luo <sunmoon1997@gmail.com>2007-02-03 23:01:08 +0800
commitd160e97b658e4b979b38946093f2b49340b960ac (patch)
treebf9b3fff22f357dc3cc21a991ac5abcbd4ef327a /configure.ac
parenta723438add4ed773cfb0c04801f5b0721a2d587d (diff)
build system: add lots of warning flags to compiler flags.
Diffstat (limited to 'configure.ac')
-rw-r--r--configure.ac63
1 files changed, 63 insertions, 0 deletions
diff --git a/configure.ac b/configure.ac
index 8d1071c..9ee5a50 100644
--- a/configure.ac
+++ b/configure.ac
@@ -182,6 +182,69 @@ AC_SUBST(SDL_FREETYPE_REQUIRES)
AC_SUBST(SDL_FREETYPE_OPENGL_REQUIRES)
AC_SUBST(SDL_FT_REQUIRES)
+AC_DEFUN([SDL_FREETYPE_CC_TRY_FLAG], [
+ AC_MSG_CHECKING([whether $CC supports $1])
+
+ sdl_freetype_save_CFLAGS="$CFLAGS"
+ CFLAGS="$CFLAGS $1"
+
+ AC_COMPILE_IFELSE([ ], [sdl_freetype_cc_flag=yes], [sdl_freetype_cc_flag=no])
+ CFLAGS="$sdl_freetype_save_CFLAGS"
+
+ if test "x$sdl_freetype_cc_flag" = "xyes"; then
+ ifelse([$2], , :, [$2])
+ else
+ ifelse([$3], , :, [$3])
+ fi
+ AC_MSG_RESULT([$sdl_freetype_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"
+
+
+# invalidate cached value if MAYBE_WARN has changed
+if test "x$sdl_freetype_cv_warn_maybe" != "x$MAYBE_WARN"; then
+ unset sdl_freetype_cv_warn_cflags
+fi
+AC_CACHE_CHECK([for supported warning flags], sdl_freetype_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
+ SDL_FREETYPE_CC_TRY_FLAG([$W], [WARN_CFLAGS="$WARN_CFLAGS $W"])
+ done
+
+ sdl_freetype_cv_warn_cflags=$WARN_CFLAGS
+ sdl_freetype_cv_warn_maybe=$MAYBE_WARN
+
+ AC_MSG_CHECKING([which warning flags were supported])])
+WARN_CFLAGS=$sdl_freetype_cv_warn_cflags
+AC_SUBST(WARN_CFLAGS)
+
AC_OUTPUT([Makefile
src/Makefile
src/sdl-freetype.pc