~ubuntu-branches/ubuntu/natty/libvirt/natty-proposed

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,
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])"])
19
20
    warnCFLAGS=
21
1.1.3 by Soren Hansen
Import upstream version 0.3.3
22
    common_flags="-Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fasynchronous-unwind-tables"
1.1.1 by Chuck Short
Import upstream version 0.2.2
23
24
    case "$enable_compile_warnings" in
25
    no)
1.1.3 by Soren Hansen
Import upstream version 0.3.3
26
        try_compiler_flags=""
1.1.1 by Chuck Short
Import upstream version 0.2.2
27
	;;
28
    minimum)
1.1.4 by Soren Hansen
Import upstream version 0.4.0
29
	try_compiler_flags="-Wall -Wformat -Wformat-security $common_flags"
1.1.1 by Chuck Short
Import upstream version 0.2.2
30
	;;
31
    yes)
1.1.4 by Soren Hansen
Import upstream version 0.4.0
32
	try_compiler_flags="-Wall -Wformat -Wformat-security -Wmissing-prototypes $common_flags"
1.1.1 by Chuck Short
Import upstream version 0.2.2
33
	;;
34
    maximum|error)
1.1.4 by Soren Hansen
Import upstream version 0.4.0
35
	try_compiler_flags="-Wall -Wformat -Wformat-security -Wmissing-prototypes -Wnested-externs -Wpointer-arith"
1.1.3 by Soren Hansen
Import upstream version 0.3.3
36
	try_compiler_flags="$try_compiler_flags -Wextra -Wshadow -Wcast-align -Wwrite-strings -Waggregate-return"
1.1.1 by Chuck Short
Import upstream version 0.2.2
37
	try_compiler_flags="$try_compiler_flags -Wstrict-prototypes -Winline -Wredundant-decls -Wno-sign-compare"
1.1.3 by Soren Hansen
Import upstream version 0.3.3
38
	try_compiler_flags="$try_compiler_flags $common_flags"
1.1.1 by Chuck Short
Import upstream version 0.2.2
39
	if test "$enable_compile_warnings" = "error" ; then
40
	    try_compiler_flags="$try_compiler_flags -Werror"
41
	fi
42
	;;
43
    *)
44
	AC_MSG_ERROR(Unknown argument '$enable_compile_warnings' to --enable-compile-warnings)
45
	;;
46
    esac
47
1.1.9 by Soren Hansen
Import upstream version 0.6.0
48
    COMPILER_FLAGS=
1.1.1 by Chuck Short
Import upstream version 0.2.2
49
    for option in $try_compiler_flags; do
1.1.9 by Soren Hansen
Import upstream version 0.6.0
50
        gl_COMPILER_FLAGS($option)
1.1.1 by Chuck Short
Import upstream version 0.2.2
51
    done
52
    unset option
53
    unset try_compiler_flags
54
55
    AC_ARG_ENABLE(iso-c,
56
                  AC_HELP_STRING([--enable-iso-c],
57
                                 [Try to warn if code is not ISO C ]),,
58
                  [enable_iso_c=no])
59
60
    AC_MSG_CHECKING(what language compliance flags to pass to the C compiler)
61
    complCFLAGS=
62
    if test "x$enable_iso_c" != "xno"; then
63
	if test "x$GCC" = "xyes"; then
64
	case " $CFLAGS " in
65
	    *[\ \	]-ansi[\ \	]*) ;;
66
	    *) complCFLAGS="$complCFLAGS -ansi" ;;
67
	esac
68
	case " $CFLAGS " in
69
	    *[\ \	]-pedantic[\ \	]*) ;;
70
	    *) complCFLAGS="$complCFLAGS -pedantic" ;;
71
	esac
72
	fi
73
    fi
74
    AC_MSG_RESULT($complCFLAGS)
75
1.1.9 by Soren Hansen
Import upstream version 0.6.0
76
    WARN_CFLAGS="$COMPILER_FLAGS $complCFLAGS"
1.1.1 by Chuck Short
Import upstream version 0.2.2
77
    AC_SUBST(WARN_CFLAGS)
1.1.9 by Soren Hansen
Import upstream version 0.6.0
78
79
    dnl Needed to keep compile quiet on python 2.4
80
    COMPILER_FLAGS=
81
    gl_COMPILER_FLAGS(-Wno-redundant-decls)
82
    WARN_PYTHON_CFLAGS=$COMPILER_FLAGS
83
    AC_SUBST(WARN_PYTHON_CFLAGS)
1.1.1 by Chuck Short
Import upstream version 0.2.2
84
])
1.1.5 by Soren Hansen
Import upstream version 0.4.2
85
86
87
dnl
88
dnl To support the old pkg-config from RHEL4 vintage, we need
89
dnl to define the PKG_PROG_PKG_CONFIG macro if its not already
90
dnl present
91
m4_ifndef([PKG_PROG_PKG_CONFIG],
92
  [AC_DEFUN([PKG_PROG_PKG_CONFIG],
93
[m4_pattern_forbid([^_?PKG_[A-Z_]+$])
94
m4_pattern_allow([^PKG_CONFIG(_PATH)?$])
95
AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility])dnl
96
if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then
97
        AC_PATH_TOOL([PKG_CONFIG], [pkg-config])
98
fi
99
if test -n "$PKG_CONFIG"; then
100
        _pkg_min_version=m4_default([$1], [0.9.0])
101
        AC_MSG_CHECKING([pkg-config is at least version $_pkg_min_version])
102
        if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then
103
                AC_MSG_RESULT([yes])
104
        else
105
                AC_MSG_RESULT([no])
106
                PKG_CONFIG=""
107
        fi
108
fi[]dnl
109
])])
110