2 dnl Taken from libvirt/acinclude.m4
5 dnl -Wextra -Wshadow -Wcast-align -Wwrite-strings -Waggregate-return -Wstrict-prototypes -Winline -Wredundant-decls
7 dnl CFLAGS="$realsave_CFLAGS"
8 dnl to avoid clobbering user-specified CFLAGS
10 AC_DEFUN([AUGEAS_COMPILE_WARNINGS],[
11 dnl ******************************
12 dnl More compiler warnings
13 dnl ******************************
15 AC_ARG_ENABLE(compile-warnings,
16 AC_HELP_STRING([--enable-compile-warnings=@<:@no/minimum/yes/maximum/error@:>@],
17 [Turn on compiler warnings]),,
18 [enable_compile_warnings="m4_default([$1],[maximum])"])
22 common_flags="-Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fasynchronous-unwind-tables"
24 case "$enable_compile_warnings" in
29 try_compiler_flags="-Wall -Wformat -Wformat-security $common_flags"
32 try_compiler_flags="-Wall -Wformat -Wformat-security -Wmissing-prototypes $common_flags"
35 try_compiler_flags="-Wall -Wformat -Wformat-security -Wmissing-prototypes -Wnested-externs -Wpointer-arith"
36 try_compiler_flags="$try_compiler_flags -Wextra -Wshadow -Wcast-align -Wwrite-strings -Waggregate-return"
37 try_compiler_flags="$try_compiler_flags -Wstrict-prototypes -Winline -Wredundant-decls -Wno-sign-compare"
38 try_compiler_flags="$try_compiler_flags $common_flags"
39 if test "$enable_compile_warnings" = "error" ; then
40 try_compiler_flags="$try_compiler_flags -Werror"
44 AC_MSG_ERROR(Unknown argument '$enable_compile_warnings' to --enable-compile-warnings)
49 for option in $try_compiler_flags; do
51 CFLAGS="$CFLAGS $option"
52 AC_MSG_CHECKING([whether gcc understands $option])
57 AC_MSG_RESULT($has_option)
58 if test $has_option = yes; then
59 compiler_flags="$compiler_flags $option"
65 unset try_compiler_flags
68 AC_HELP_STRING([--enable-iso-c],
69 [Try to warn if code is not ISO C ]),,
72 AC_MSG_CHECKING(what language compliance flags to pass to the C compiler)
74 if test "x$enable_iso_c" != "xno"; then
75 if test "x$GCC" = "xyes"; then
77 *[\ \ ]-ansi[\ \ ]*) ;;
78 *) complCFLAGS="$complCFLAGS -ansi" ;;
81 *[\ \ ]-pedantic[\ \ ]*) ;;
82 *) complCFLAGS="$complCFLAGS -pedantic" ;;
86 AC_MSG_RESULT($complCFLAGS)
88 WARN_CFLAGS="$compiler_flags $complCFLAGS"
93 dnl Determine readline linker flags in a way that works on RHEL 5
94 dnl Check for rl_completion_matches (missing on OS/X)
96 AC_DEFUN([AUGEAS_CHECK_READLINE], [
97 AC_CHECK_HEADERS([readline/readline.h])
100 AC_CHECK_LIB(readline, readline,
101 [use_readline=yes; READLINE_LIBS=-lreadline],
104 # If the above test failed, it may simply be that -lreadline requires
105 # some termcap-related code, e.g., from one of the following libraries.
106 # See if adding one of them to LIBS helps.
107 if test $use_readline = no; then
110 AC_SEARCH_LIBS(tgetent, ncurses curses termcap termlib)
112 no*) ;; # handle "no" and "none required"
113 *) # anything else is a -lLIBRARY
114 # Now, check for -lreadline again, also using $LIBS.
115 # Note: this time we use a different function, so that
116 # we don't get a cached "no" result.
117 AC_CHECK_LIB(readline, rl_initialize,
119 READLINE_LIBS="-lreadline $LIBS"],,
123 test $use_readline = no &&
124 AC_MSG_WARN([readline library not found])
128 if test $use_readline = no; then
129 AC_MSG_ERROR(Could not find a working readline library (see config.log for details).)
132 AC_SUBST(READLINE_LIBS)
134 if test $use_readline = yes; then
137 AC_CHECK_FUNCS([rl_completion_matches])