TEMP disable %check
[libvirt/apevec.git] / acinclude.m4
blob838ec464624ee580bcf50f06455bb17fee3c3968
1 dnl
2 dnl Taken from gnome-common/macros2/gnome-compiler-flags.m4
3 dnl
4 dnl We've added:
5 dnl   -Wextra -Wshadow -Wcast-align -Wwrite-strings -Waggregate-return -Wstrict-prototypes -Winline -Wredundant-decls
6 dnl We've removed
7 dnl   CFLAGS="$realsave_CFLAGS"
8 dnl   to avoid clobbering user-specified CFLAGS
9 dnl
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])"])
20     warnCFLAGS=
22     common_flags=
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
29     no)
30         try_compiler_flags=""
31         ;;
32     minimum)
33         try_compiler_flags="-Wall -Wformat -Wformat-security $common_flags"
34         ;;
35     yes)
36         try_compiler_flags="-Wall -Wformat -Wformat-security -Wmissing-prototypes $common_flags"
37         ;;
38     maximum|error)
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"
55         fi
56         ;;
57     *)
58         AC_MSG_ERROR(Unknown argument '$enable_compile_warnings' to --enable-compile-warnings)
59         ;;
60     esac
62     COMPILER_FLAGS=
63     for option in $try_compiler_flags; do
64         gl_COMPILER_FLAGS($option)
65     done
66     unset option
67     unset try_compiler_flags
69     AC_ARG_ENABLE(iso-c,
70                   AC_HELP_STRING([--enable-iso-c],
71                                  [Try to warn if code is not ISO C ]),,
72                   [enable_iso_c=no])
74     AC_MSG_CHECKING(what language compliance flags to pass to the C compiler)
75     complCFLAGS=
76     if test "x$enable_iso_c" != "xno"; then
77         if test "x$GCC" = "xyes"; then
78         case " $CFLAGS " in
79             *[\ \       ]-ansi[\ \      ]*) ;;
80             *) complCFLAGS="$complCFLAGS -ansi" ;;
81         esac
82         case " $CFLAGS " in
83             *[\ \       ]-pedantic[\ \  ]*) ;;
84             *) complCFLAGS="$complCFLAGS -pedantic" ;;
85         esac
86         fi
87     fi
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
96     COMPILER_FLAGS=
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
106 dnl present
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
119                 AC_MSG_RESULT([yes])
120         else
121                 AC_MSG_RESULT([no])
122                 PKG_CONFIG=""
123         fi
124 fi[]dnl
125 ])])