diff options
author | Simon McVittie <simon.mcvittie@collabora.co.uk> | 2008-12-23 15:29:20 +0000 |
---|---|---|
committer | Simon McVittie <simon.mcvittie@collabora.co.uk> | 2009-01-07 14:00:53 +0000 |
commit | 0f3d6b9e3bae40feb8cb55c8c63bf0720e90351f (patch) | |
tree | 305278f617d2965b2d2cb9d6d4cd47b7e54330c8 | |
parent | aceed13684c2333b57eb3b4bc4e60cf6f40f5116 (diff) |
configure.ac: factor out a TP_COMPILER_WARNINGS macro
-rw-r--r-- | configure.ac | 66 | ||||
-rw-r--r-- | m4/Makefile.am | 3 | ||||
-rw-r--r-- | m4/tp-compiler-warnings.m4 | 40 |
3 files changed, 59 insertions, 50 deletions
diff --git a/configure.ac b/configure.ac index 4636da1a8..59717d9d9 100644 --- a/configure.ac +++ b/configure.ac @@ -70,58 +70,26 @@ COMPILER_COVERAGE LINKER_OPTIMISATIONS LINKER_VERSION_SCRIPT -dnl decide error flags -AS_COMPILER_FLAG(-Wall, ERROR_CFLAGS="-Wall", ERROR_CFLAGS="") -AS_COMPILER_FLAG(-Werror, werror=yes, werror=no) -# never enable -Werror unless -Wno-error=foo also works -AS_COMPILER_FLAG([-Wno-error=missing-field-initializers], [], [werror=no]) -AS_COMPILER_FLAG([-Wno-error=unused-parameter], [], [werror=no]) - -AC_ARG_ENABLE(Werror, - AC_HELP_STRING([--disable-Werror],[compile without -Werror (normally enabled in development builds)]), - werror=$enableval, :) - -AS_COMPILER_FLAG(-Wextra, wextra=yes, wextra=no) -AS_COMPILER_FLAG(-Wno-missing-field-initializers, - wno_missing_field_initializers=yes, - wno_missing_field_initializers=no) -AS_COMPILER_FLAG(-Wno-unused-parameter, - wno_unused_parameter=yes, - wno_unused_parameter=no) - ifelse(tp_glib_nano_version, 0, [ official_release=yes ], - [ - official_release=no - if test x$werror = xyes; then - ERROR_CFLAGS="$ERROR_CFLAGS -Werror" - # We never want missing field initializers or unused parameters - # to be an error. We try to turn the warnings off, but CDBS has a - # tendency to turn them back on again... - ERROR_CFLAGS="$ERROR_CFLAGS -Wno-error=missing-field-initializers" - ERROR_CFLAGS="$ERROR_CFLAGS -Wno-error=unused-parameter" - fi - if test x$wextra = xyes -a \ - x$wno_missing_field_initializers = xyes -a \ - x$wno_unused_parameter = xyes; then - ERROR_CFLAGS="$ERROR_CFLAGS -Wextra" - ERROR_CFLAGS="$ERROR_CFLAGS -Wno-missing-field-initializers" - ERROR_CFLAGS="$ERROR_CFLAGS -Wno-unused-parameter" - fi - ]) + [ official_release=no ]) + +TP_COMPILER_WARNINGS([ERROR_CFLAGS], [test "x$official_release" = xno], + [all \ + extra \ + declaration-after-statement \ + shadow \ + strict-prototypes \ + missing-prototypes \ + sign-compare \ + nested-externs \ + pointer-arith \ + format-security \ + init-self], + [missing-field-initializers \ + unused-parameter]) +AC_SUBST([ERROR_CFLAGS]) -AS_COMPILER_FLAG(-Wdeclaration-after-statement, ERROR_CFLAGS="$ERROR_CFLAGS -Wdeclaration-after-statement") -AS_COMPILER_FLAG(-Wshadow, ERROR_CFLAGS="$ERROR_CFLAGS -Wshadow") -AS_COMPILER_FLAG(-Wstrict-prototypes, ERROR_CFLAGS="$ERROR_CFLAGS -Wstrict-prototypes") -AS_COMPILER_FLAG(-Wmissing-prototypes, ERROR_CFLAGS="$ERROR_CFLAGS -Wmissing-prototypes") -AS_COMPILER_FLAG(-Wmissing-declarations, ERROR_CFLAGS="$ERROR_CFLAGS -Wmissing-declarations") -AS_COMPILER_FLAG(-Wsign-compare, ERROR_CFLAGS="$ERROR_CFLAGS -Wsign-compare") -AS_COMPILER_FLAG(-Wnested-externs, ERROR_CFLAGS="$ERROR_CFLAGS -Wnested-externs") -AS_COMPILER_FLAG(-Wpointer-arith, ERROR_CFLAGS="$ERROR_CFLAGS -Wpointer-arith") -AS_COMPILER_FLAG(-Wformat-security, ERROR_CFLAGS="$ERROR_CFLAGS -Wformat-security") -AS_COMPILER_FLAG(-Winit-self, ERROR_CFLAGS="$ERROR_CFLAGS -Winit-self") - -AC_SUBST(ERROR_CFLAGS) AM_CONDITIONAL([OFFICIAL_RELEASE], [test "x$official_release" = xyes]) AC_ARG_ENABLE(debug, diff --git a/m4/Makefile.am b/m4/Makefile.am index 06007e740..e2267e0da 100644 --- a/m4/Makefile.am +++ b/m4/Makefile.am @@ -2,4 +2,5 @@ EXTRA_DIST = \ as-compiler-flag.m4 \ compiler.m4 \ gtk-doc.m4 \ -linker.m4 +linker.m4 \ +tp-compiler-warnings.m4 diff --git a/m4/tp-compiler-warnings.m4 b/m4/tp-compiler-warnings.m4 new file mode 100644 index 000000000..dbc4ebbe2 --- /dev/null +++ b/m4/tp-compiler-warnings.m4 @@ -0,0 +1,40 @@ +dnl TP_COMPILER_WARNINGS(VARIABLE, WERROR_BY_DEFAULT, DESIRABLE, UNDESIRABLE) +dnl $1 (VARIABLE): the variable to put flags into +dnl $2 (WERROR_BY_DEFAULT): a command returning true if -Werror should be the +dnl default +dnl $3 (DESIRABLE): warning flags we want (e.g. all extra shadow) +dnl $4 (UNDESIRABLE): warning flags we don't want (e.g. +dnl missing-field-initializers unused-parameter) +AC_DEFUN([TP_COMPILER_WARNINGS], +[ + AC_REQUIRE([AC_ARG_ENABLE])dnl + AC_REQUIRE([AC_HELP_STRING])dnl + AC_REQUIRE([AS_COMPILER_FLAG])dnl + + tp_warnings="" + for tp_flag in $3; do + AS_COMPILER_FLAG([-W$tp_flag], [tp_warnings="$tp_warnings -W$tp_flag"]) + done + + tp_error_flags="-Werror" + AS_COMPILER_FLAG([-Werror], [tp_werror=yes], [tp_werror=no]) + + for tp_flag in $4; do + AS_COMPILER_FLAG([-Wno-$tp_flag], + [tp_warnings="$tp_warnings -Wno-$tp_flag"]) + AS_COMPILER_FLAG([-Wno-error=$tp_flag], + [tp_error_flags="$tp_error_flags -Wno-error=$tp_flag"], [tp_werror=no]) + done + + AC_ARG_ENABLE([Werror], + AC_HELP_STRING([--disable-Werror], + [compile without -Werror (normally enabled in development builds)]), + tp_werror=$enableval, :) + + if test "x$tp_werror" = xyes && $2; then + $1="$tp_warnings $tp_error_flags" + else + $1="$tp_warnings" + fi + +]) |