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="-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)
48 AH_VERBATIM([FORTIFY_SOURCE],
49 [/* Enable compile-time and run-time bounds-checking, and some warnings,
50 without upsetting newer glibc. */
51 #if !defined _FORTIFY_SOURCE && defined __OPTIMIZE__ && __OPTIMIZE__
52 # define _FORTIFY_SOURCE 2
57 for option in $try_compiler_flags; do
59 CFLAGS="$CFLAGS $option"
60 AC_MSG_CHECKING([whether gcc understands $option])
65 AC_MSG_RESULT($has_option)
66 if test $has_option = yes; then
67 compiler_flags="$compiler_flags $option"
73 unset try_compiler_flags
76 AC_HELP_STRING([--enable-iso-c],
77 [Try to warn if code is not ISO C ]),,
80 AC_MSG_CHECKING(what language compliance flags to pass to the C compiler)
82 if test "x$enable_iso_c" != "xno"; then
83 if test "x$GCC" = "xyes"; then
85 *[\ \ ]-ansi[\ \ ]*) ;;
86 *) complCFLAGS="$complCFLAGS -ansi" ;;
89 *[\ \ ]-pedantic[\ \ ]*) ;;
90 *) complCFLAGS="$complCFLAGS -pedantic" ;;
94 AC_MSG_RESULT($complCFLAGS)
96 WARN_CFLAGS="$compiler_flags $complCFLAGS"
101 dnl Determine readline linker flags in a way that works on RHEL 5
102 dnl Check for rl_completion_matches (missing on OS/X)
104 AC_DEFUN([AUGEAS_CHECK_READLINE], [
105 AC_CHECK_HEADERS([readline/readline.h])
107 # Check for readline.
108 AC_CHECK_LIB(readline, readline,
109 [use_readline=yes; READLINE_LIBS=-lreadline],
112 # If the above test failed, it may simply be that -lreadline requires
113 # some termcap-related code, e.g., from one of the following libraries.
114 # See if adding one of them to LIBS helps.
115 if test $use_readline = no; then
118 AC_SEARCH_LIBS(tgetent, ncurses curses termcap termlib)
120 no*) ;; # handle "no" and "none required"
121 *) # anything else is a -lLIBRARY
122 # Now, check for -lreadline again, also using $LIBS.
123 # Note: this time we use a different function, so that
124 # we don't get a cached "no" result.
125 AC_CHECK_LIB(readline, rl_initialize,
127 READLINE_LIBS="-lreadline $LIBS"],,
131 test $use_readline = no &&
132 AC_MSG_WARN([readline library not found])
136 if test $use_readline = no; then
137 AC_MSG_ERROR(Could not find a working readline library (see config.log for details).)
140 AC_SUBST(READLINE_LIBS)
142 if test $use_readline = yes; then
145 AC_CHECK_FUNCS([rl_completion_matches rl_crlf rl_replace_line])