1
|
1 |
dnl Turn on the additional warnings last, so -Werror doesn't affect other tests. |
|
2 |
|
|
3 |
AC_DEFUN([LM_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, [ --with-compile-warnings=[no/yes/error] Compiler warnings ], [enable_compile_warnings="$withval"], [enable_compile_warnings="$default_compile_warnings"]) |
|
11 |
|
|
12 |
warnCFLAGS= |
|
13 |
if test "x$GCC" != xyes; then |
|
14 |
enable_compile_warnings=no |
|
15 |
fi |
|
16 |
|
|
17 |
warning_flags= |
|
18 |
realsave_CFLAGS="$CFLAGS" |
|
19 |
|
|
20 |
case "$enable_compile_warnings" in |
|
21 |
no) |
|
22 |
warning_flags= |
|
23 |
;; |
|
24 |
yes) |
|
25 |
warning_flags="-Wall -Wunused -Wmissing-prototypes -Wmissing-declarations" |
|
26 |
;; |
|
27 |
maximum|error) |
|
28 |
warning_flags="-Wall -Wunused -Wchar-subscripts -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wpointer-arith" |
|
29 |
CFLAGS="$warning_flags $CFLAGS" |
|
30 |
for option in -Wsign-promo -Wno-sign-compare; do |
|
31 |
SAVE_CFLAGS="$CFLAGS" |
|
32 |
CFLAGS="$CFLAGS $option" |
|
33 |
AC_MSG_CHECKING([whether gcc understands $option]) |
|
34 |
AC_TRY_COMPILE([], [], |
|
35 |
has_option=yes, |
|
36 |
has_option=no,) |
|
37 |
CFLAGS="$SAVE_CFLAGS" |
|
38 |
AC_MSG_RESULT($has_option) |
|
39 |
if test $has_option = yes; then |
|
40 |
warning_flags="$warning_flags $option" |
|
41 |
fi |
|
42 |
unset has_option |
|
43 |
unset SAVE_CFLAGS |
|
44 |
done |
|
45 |
unset option |
|
46 |
if test "$enable_compile_warnings" = "error" ; then |
|
47 |
warning_flags="$warning_flags -Werror" |
|
48 |
fi |
|
49 |
;; |
|
50 |
*) |
|
51 |
AC_MSG_ERROR(Unknown argument '$enable_compile_warnings' to --enable-compile-warnings) |
|
52 |
;; |
|
53 |
esac |
|
54 |
CFLAGS="$realsave_CFLAGS" |
|
55 |
AC_MSG_CHECKING(what warning flags to pass to the C compiler) |
|
56 |
AC_MSG_RESULT($warning_flags) |
|
57 |
|
|
58 |
WARN_CFLAGS="$warning_flags" |
|
59 |
AC_SUBST(WARN_CFLAGS) |
|
60 |
]) |
|
61 |
|