1dnl TP_COMPILER_WARNINGS(VARIABLE, WERROR_BY_DEFAULT, DESIRABLE, UNDESIRABLE)
2dnl $1 (VARIABLE): the variable to put flags into
3dnl $2 (WERROR_BY_DEFAULT): a command returning true if -Werror should be the
4dnl     default
5dnl $3 (DESIRABLE): warning flags we want (e.g. all extra shadow)
6dnl $4 (UNDESIRABLE): warning flags we don't want (e.g.
7dnl   missing-field-initializers unused-parameter)
8AC_DEFUN([TP_COMPILER_WARNINGS],
9[
10  AC_REQUIRE([AC_ARG_ENABLE])dnl
11  AC_REQUIRE([AC_HELP_STRING])dnl
12  AC_REQUIRE([TP_COMPILER_FLAG])dnl
13
14  tp_warnings=""
15  for tp_flag in $3; do
16    TP_COMPILER_FLAG([-W$tp_flag], [tp_warnings="$tp_warnings -W$tp_flag"])
17  done
18
19  tp_error_flags="-Werror"
20  TP_COMPILER_FLAG([-Werror], [tp_werror=yes], [tp_werror=no])
21
22  for tp_flag in $4; do
23    TP_COMPILER_FLAG([-Wno-$tp_flag],
24      [tp_warnings="$tp_warnings -Wno-$tp_flag"])
25    TP_COMPILER_FLAG([-Wno-error=$tp_flag],
26      [tp_error_flags="$tp_error_flags -Wno-error=$tp_flag"], [tp_werror=no])
27  done
28
29  AC_ARG_ENABLE([Werror],
30    AC_HELP_STRING([--disable-Werror],
31      [compile without -Werror (normally enabled in development builds)]),
32    tp_werror=$enableval, :)
33
34  if test "x$tp_werror" = xyes && $2; then
35    $1="$tp_warnings $tp_error_flags"
36  else
37    $1="$tp_warnings"
38  fi
39
40])
41