2007-03-01 19:18:55 +03:00
dnl
dnl Taken from gnome-common/macros2/gnome-compiler-flags.m4
dnl
dnl We've added:
dnl -Wextra -Wshadow -Wcast-align -Wwrite-strings -Waggregate-return -Wstrict-prototypes -Winline -Wredundant-decls
2007-03-26 13:30:36 +04:00
dnl We've removed
dnl CFLAGS="$realsave_CFLAGS"
dnl to avoid clobbering user-specified CFLAGS
2007-03-01 19:18:55 +03:00
dnl
AC_DEFUN([LIBVIRT_COMPILE_WARNINGS],[
dnl ******************************
dnl More compiler warnings
dnl ******************************
AC_ARG_ENABLE(compile-warnings,
2010-03-30 20:09:21 +04:00
[AC_HELP_STRING([--enable-compile-warnings=@<:@no/minimum/yes/maximum/error@:>@],
[Turn on compiler warnings])],,
2007-03-21 17:52:12 +03:00
[enable_compile_warnings="m4_default([$1],[maximum])"])
2007-03-01 19:18:55 +03:00
warnCFLAGS=
2010-03-30 20:09:21 +04:00
common_flags=
common_flags="$common_flags -Wp,-D_FORTIFY_SOURCE=2"
common_flags="$common_flags -fexceptions"
common_flags="$common_flags -fasynchronous-unwind-tables"
common_flags="$common_flags -fdiagnostics-show-option"
2007-03-01 19:18:55 +03:00
case "$enable_compile_warnings" in
no)
2007-09-22 00:01:43 +04:00
try_compiler_flags=""
2007-03-01 19:18:55 +03:00
;;
minimum)
2007-11-07 15:29:37 +03:00
try_compiler_flags="-Wall -Wformat -Wformat-security $common_flags"
2007-03-01 19:18:55 +03:00
;;
yes)
2007-11-07 15:29:37 +03:00
try_compiler_flags="-Wall -Wformat -Wformat-security -Wmissing-prototypes $common_flags"
2007-03-01 19:18:55 +03:00
;;
maximum|error)
2010-07-24 00:28:31 +04:00
try_compiler_flags="-Wall -Wformat -Wformat-security"
try_compiler_flags="$try_compiler_flags -Wmissing-prototypes"
try_compiler_flags="$try_compiler_flags -Wnested-externs "
try_compiler_flags="$try_compiler_flags -Wpointer-arith"
try_compiler_flags="$try_compiler_flags -Wextra -Wshadow"
try_compiler_flags="$try_compiler_flags -Wcast-align"
try_compiler_flags="$try_compiler_flags -Wwrite-strings"
try_compiler_flags="$try_compiler_flags -Waggregate-return"
try_compiler_flags="$try_compiler_flags -Wstrict-prototypes"
try_compiler_flags="$try_compiler_flags -Winline"
try_compiler_flags="$try_compiler_flags -Wredundant-decls"
try_compiler_flags="$try_compiler_flags -Wno-sign-compare"
try_compiler_flags="$try_compiler_flags -Wlogical-op"
2007-09-22 00:01:43 +04:00
try_compiler_flags="$try_compiler_flags $common_flags"
2007-03-01 19:18:55 +03:00
if test "$enable_compile_warnings" = "error" ; then
2007-03-21 17:52:12 +03:00
try_compiler_flags="$try_compiler_flags -Werror"
2007-03-01 19:18:55 +03:00
fi
;;
*)
AC_MSG_ERROR(Unknown argument '$enable_compile_warnings' to --enable-compile-warnings)
;;
esac
2007-03-21 17:52:12 +03:00
2009-01-14 18:23:26 +03:00
COMPILER_FLAGS=
2007-03-21 17:52:12 +03:00
for option in $try_compiler_flags; do
2009-01-14 18:23:26 +03:00
gl_COMPILER_FLAGS($option)
2007-03-21 17:52:12 +03:00
done
unset option
unset try_compiler_flags
2007-03-01 19:18:55 +03:00
AC_ARG_ENABLE(iso-c,
AC_HELP_STRING([--enable-iso-c],
[Try to warn if code is not ISO C ]),,
[enable_iso_c=no])
AC_MSG_CHECKING(what language compliance flags to pass to the C compiler)
complCFLAGS=
if test "x$enable_iso_c" != "xno"; then
if test "x$GCC" = "xyes"; then
case " $CFLAGS " in
*[\ \ ]-ansi[\ \ ]*) ;;
*) complCFLAGS="$complCFLAGS -ansi" ;;
esac
case " $CFLAGS " in
*[\ \ ]-pedantic[\ \ ]*) ;;
*) complCFLAGS="$complCFLAGS -pedantic" ;;
esac
fi
fi
AC_MSG_RESULT($complCFLAGS)
2009-01-14 18:23:26 +03:00
WARN_CFLAGS="$COMPILER_FLAGS $complCFLAGS"
2010-05-15 02:45:52 +04:00
WARN_LDFLAGS=$WARN_CFLAGS
AC_SUBST([WARN_CFLAGS])
AC_SUBST([WARN_LDFLAGS])
2008-12-18 15:20:00 +03:00
dnl Needed to keep compile quiet on python 2.4
COMPILER_FLAGS=
gl_COMPILER_FLAGS(-Wno-redundant-decls)
WARN_PYTHON_CFLAGS=$COMPILER_FLAGS
AC_SUBST(WARN_PYTHON_CFLAGS)
2007-03-01 19:18:55 +03:00
])
2008-01-23 00:30:05 +03:00
dnl
dnl To support the old pkg-config from RHEL4 vintage, we need
dnl to define the PKG_PROG_PKG_CONFIG macro if its not already
dnl present
m4_ifndef([PKG_PROG_PKG_CONFIG],
[AC_DEFUN([PKG_PROG_PKG_CONFIG],
[m4_pattern_forbid([^_?PKG_[A-Z_]+$])
m4_pattern_allow([^PKG_CONFIG(_PATH)?$])
AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility])dnl
if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then
AC_PATH_TOOL([PKG_CONFIG], [pkg-config])
fi
if test -n "$PKG_CONFIG"; then
_pkg_min_version=m4_default([$1], [0.9.0])
AC_MSG_CHECKING([pkg-config is at least version $_pkg_min_version])
if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then
AC_MSG_RESULT([yes])
else
AC_MSG_RESULT([no])
PKG_CONFIG=""
fi
fi[]dnl
])])