2 dnl Taken from gnome-common/macros2/gnome-compiler-flags.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([LIBVIRT_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])"])
23 common_flags="$common_flags -Wp,-D_FORTIFY_SOURCE=2"
24 common_flags="$common_flags -fexceptions"
25 common_flags="$common_flags -fasynchronous-unwind-tables"
26 common_flags="$common_flags -fdiagnostics-show-option"
28 case "$enable_compile_warnings" in
33 try_compiler_flags="-Wall -Wformat -Wformat-security $common_flags"
36 try_compiler_flags="-Wall -Wformat -Wformat-security -Wmissing-prototypes $common_flags"
39 try_compiler_flags="-Wall -Wformat -Wformat-security"
40 try_compiler_flags="$try_compiler_flags -Wmissing-prototypes"
41 try_compiler_flags="$try_compiler_flags -Wnested-externs "
42 try_compiler_flags="$try_compiler_flags -Wpointer-arith"
43 try_compiler_flags="$try_compiler_flags -Wextra -Wshadow"
44 try_compiler_flags="$try_compiler_flags -Wcast-align"
45 try_compiler_flags="$try_compiler_flags -Wwrite-strings"
46 try_compiler_flags="$try_compiler_flags -Waggregate-return"
47 try_compiler_flags="$try_compiler_flags -Wstrict-prototypes"
48 try_compiler_flags="$try_compiler_flags -Winline"
49 try_compiler_flags="$try_compiler_flags -Wredundant-decls"
50 try_compiler_flags="$try_compiler_flags -Wno-sign-compare"
51 try_compiler_flags="$try_compiler_flags -Wlogical-op"
52 try_compiler_flags="$try_compiler_flags $common_flags"
53 if test "$enable_compile_warnings" = "error" ; then
54 try_compiler_flags="$try_compiler_flags -Werror"
58 AC_MSG_ERROR(Unknown argument '$enable_compile_warnings' to --enable-compile-warnings)
63 for option in $try_compiler_flags; do
64 gl_COMPILER_FLAGS($option)
67 unset try_compiler_flags
70 AC_HELP_STRING([--enable-iso-c],
71 [Try to warn if code is not ISO C ]),,
74 AC_MSG_CHECKING(what language compliance flags to pass to the C compiler)
76 if test "x$enable_iso_c" != "xno"; then
77 if test "x$GCC" = "xyes"; then
79 *[\ \ ]-ansi[\ \ ]*) ;;
80 *) complCFLAGS="$complCFLAGS -ansi" ;;
83 *[\ \ ]-pedantic[\ \ ]*) ;;
84 *) complCFLAGS="$complCFLAGS -pedantic" ;;
88 AC_MSG_RESULT($complCFLAGS)
90 WARN_CFLAGS="$COMPILER_FLAGS $complCFLAGS"
91 WARN_LDFLAGS=$WARN_CFLAGS
92 AC_SUBST([WARN_CFLAGS])
93 AC_SUBST([WARN_LDFLAGS])
95 dnl Needed to keep compile quiet on python 2.4
97 gl_COMPILER_FLAGS(-Wno-redundant-decls)
98 WARN_PYTHON_CFLAGS=$COMPILER_FLAGS
99 AC_SUBST(WARN_PYTHON_CFLAGS)
104 dnl To support the old pkg-config from RHEL4 vintage, we need
105 dnl to define the PKG_PROG_PKG_CONFIG macro if its not already
107 m4_ifndef([PKG_PROG_PKG_CONFIG],
108 [AC_DEFUN([PKG_PROG_PKG_CONFIG],
109 [m4_pattern_forbid([^_?PKG_[A-Z_]+$])
110 m4_pattern_allow([^PKG_CONFIG(_PATH)?$])
111 AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility])dnl
112 if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then
113 AC_PATH_TOOL([PKG_CONFIG], [pkg-config])
115 if test -n "$PKG_CONFIG"; then
116 _pkg_min_version=m4_default([$1], [0.9.0])
117 AC_MSG_CHECKING([pkg-config is at least version $_pkg_min_version])
118 if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then