]> git.0d.be Git - empathy.git/blob - acinclude.m4
[darcs-to-svn @ Add artists names to contributors and credits]
[empathy.git] / acinclude.m4
1 dnl Turn on the additional warnings last, so -Werror doesn't affect other tests.
2
3 AC_DEFUN([IDT_COMPILE_WARNINGS],[
4    if test -f $srcdir/autogen.sh; then
5         default_compile_warnings="error"
6     else
7         default_compile_warnings="no"
8     fi
9
10     AC_ARG_WITH(compile-warnings,
11                 AS_HELP_STRING([--with-compile-warnings=@<:@no/yes/error@:>@],
12                                [Compiler warnings]),
13                 [enable_compile_warnings="$withval"],
14                 [enable_compile_warnings="$default_compile_warnings"])
15
16     warnCFLAGS=
17     if test "x$GCC" != xyes; then
18         enable_compile_warnings=no
19     fi
20
21     warning_flags=
22     realsave_CFLAGS="$CFLAGS"
23
24     case "$enable_compile_warnings" in
25     no)
26         warning_flags=
27         ;;
28     yes)
29         warning_flags="-Wall -Wunused -Wmissing-prototypes -Wmissing-declarations"
30         ;;
31     maximum|error)
32         warning_flags="-Wall -Wunused -Wchar-subscripts -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wpointer-arith"
33         CFLAGS="$warning_flags $CFLAGS"
34         for option in -Wno-sign-compare -Wno-pointer-sign; do
35                 SAVE_CFLAGS="$CFLAGS"
36                 CFLAGS="$CFLAGS $option"
37                 AC_MSG_CHECKING([whether gcc understands $option])
38                 AC_TRY_COMPILE([], [],
39                         has_option=yes,
40                         has_option=no,)
41                 CFLAGS="$SAVE_CFLAGS"
42                 AC_MSG_RESULT($has_option)
43                 if test $has_option = yes; then
44                   warning_flags="$warning_flags $option"
45                 fi
46                 unset has_option
47                 unset SAVE_CFLAGS
48         done
49         unset option
50         if test "$enable_compile_warnings" = "error" ; then
51             warning_flags="$warning_flags -Werror"
52         fi
53         ;;
54     *)
55         AC_MSG_ERROR(Unknown argument '$enable_compile_warnings' to --enable-compile-warnings)
56         ;;
57     esac
58     CFLAGS="$realsave_CFLAGS"
59     AC_MSG_CHECKING(what warning flags to pass to the C compiler)
60     AC_MSG_RESULT($warning_flags)
61
62     WARN_CFLAGS="$warning_flags"
63     AC_SUBST(WARN_CFLAGS)
64 ])
65