~ubuntu-branches/ubuntu/maverick/libvirt/maverick

1.1.1 by Chuck Short
Import upstream version 0.2.2
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 ******************************
14
15
    AC_ARG_ENABLE(compile-warnings,
3.4.14 by Guido Günther
* [70fbcb6] New patch 0007-nwfilter-Don-t-crash-if-driverState- NULL.patch
16
                  [AC_HELP_STRING([--enable-compile-warnings=@<:@no/minimum/yes/maximum/error@:>@],
17
                                 [Turn on compiler warnings])],,
1.1.1 by Chuck Short
Import upstream version 0.2.2
18
                  [enable_compile_warnings="m4_default([$1],[maximum])"])
19
20
    warnCFLAGS=
21
3.4.14 by Guido Günther
* [70fbcb6] New patch 0007-nwfilter-Don-t-crash-if-driverState- NULL.patch
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"
1.1.1 by Chuck Short
Import upstream version 0.2.2
27
28
    case "$enable_compile_warnings" in
29
    no)
1.1.3 by Soren Hansen
Import upstream version 0.3.3
30
        try_compiler_flags=""
1.1.1 by Chuck Short
Import upstream version 0.2.2
31
	;;
32
    minimum)
1.1.4 by Soren Hansen
Import upstream version 0.4.0
33
	try_compiler_flags="-Wall -Wformat -Wformat-security $common_flags"
1.1.1 by Chuck Short
Import upstream version 0.2.2
34
	;;
35
    yes)
1.1.4 by Soren Hansen
Import upstream version 0.4.0
36
	try_compiler_flags="-Wall -Wformat -Wformat-security -Wmissing-prototypes $common_flags"
1.1.1 by Chuck Short
Import upstream version 0.2.2
37
	;;
38
    maximum|error)
3.4.18 by Laurent Léonard, Guido Günther, Laurent Léonard
[ Guido Günther ]
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"
1.1.3 by Soren Hansen
Import upstream version 0.3.3
52
	try_compiler_flags="$try_compiler_flags $common_flags"
1.1.1 by Chuck Short
Import upstream version 0.2.2
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
61
1.1.9 by Soren Hansen
Import upstream version 0.6.0
62
    COMPILER_FLAGS=
1.1.1 by Chuck Short
Import upstream version 0.2.2
63
    for option in $try_compiler_flags; do
1.1.9 by Soren Hansen
Import upstream version 0.6.0
64
        gl_COMPILER_FLAGS($option)
1.1.1 by Chuck Short
Import upstream version 0.2.2
65
    done
66
    unset option
67
    unset try_compiler_flags
68
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])
73
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)
89
1.1.9 by Soren Hansen
Import upstream version 0.6.0
90
    WARN_CFLAGS="$COMPILER_FLAGS $complCFLAGS"
3.4.17 by Laurent Léonard
* Imported Upstream version 0.8.2
91
    WARN_LDFLAGS=$WARN_CFLAGS
92
    AC_SUBST([WARN_CFLAGS])
93
    AC_SUBST([WARN_LDFLAGS])
1.1.9 by Soren Hansen
Import upstream version 0.6.0
94
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)
1.1.1 by Chuck Short
Import upstream version 0.2.2
100
])
1.1.5 by Soren Hansen
Import upstream version 0.4.2
101
102
103
dnl
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])
114
fi
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
])])