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 /m4 | |
parent | aceed13684c2333b57eb3b4bc4e60cf6f40f5116 (diff) |
configure.ac: factor out a TP_COMPILER_WARNINGS macro
Diffstat (limited to 'm4')
-rw-r--r-- | m4/Makefile.am | 3 | ||||
-rw-r--r-- | m4/tp-compiler-warnings.m4 | 40 |
2 files changed, 42 insertions, 1 deletions
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 + +]) |