diff options
author | Simon McVittie <smcv@debian.org> | 2011-06-01 15:11:01 +0100 |
---|---|---|
committer | Simon McVittie <smcv@debian.org> | 2011-06-01 15:11:01 +0100 |
commit | e034e2bbd4352a21b7f5bf9d4d89f7a41c78cb03 (patch) | |
tree | 6dbcb05ff39c830bec9bb80e0a65aeb6679772d5 /m4/tp-compiler-warnings.m4 | |
parent | b03dfc9ec734204fa8f5e2a6fa75ad2a1973e346 (diff) | |
download | dbus-e034e2bbd4352a21b7f5bf9d4d89f7a41c78cb03.tar.gz |
Imported Upstream version 1.4.10upstream/1.4.10
Diffstat (limited to 'm4/tp-compiler-warnings.m4')
-rw-r--r-- | m4/tp-compiler-warnings.m4 | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/m4/tp-compiler-warnings.m4 b/m4/tp-compiler-warnings.m4 new file mode 100644 index 00000000..ee4af310 --- /dev/null +++ b/m4/tp-compiler-warnings.m4 @@ -0,0 +1,49 @@ +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([TP_COMPILER_FLAG])dnl + + tp_warnings="" + for tp_flag in $3; do + TP_COMPILER_FLAG([-W$tp_flag], [tp_warnings="$tp_warnings -W$tp_flag"]) + done + + tp_error_flags="-Werror" + TP_COMPILER_FLAG([-Werror], [tp_werror=yes], [tp_werror=no]) + + for tp_flag in $4; do + TP_COMPILER_FLAG([-Wno-$tp_flag], + [tp_warnings="$tp_warnings -Wno-$tp_flag"]) +dnl Yes, we do need to use both -Wno-foo and -Wno-error=foo. Simon says: +dnl some warnings we explicitly don't want, like unused-parameter, but +dnl they're in -Wall. when a distro using cdbs compiles us, we have: +dnl -Werror -Wno-unused-parameter -Wall +dnl ^ from us ^ from cdbs +dnl which turns -Wunused-parameter back on, in effect + TP_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 +dnl We put -Wno-error=foo before -Wno-foo because clang interprets -Wall +dnl -Werror -Wno-foo -Wno-error=foo as “make foo a non-fatal warning”, but does +dnl what we want if you reverse them. + $1="$tp_error_flags $tp_warnings" + else + $1="$tp_warnings" + fi + +]) |