]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
Thu Mar 01 16:17:48 EST 2007 Mark McLoughlin <markmc@redhat.com>
authorMark McLoughlin <markmc@redhat.com>
Thu, 1 Mar 2007 16:18:55 +0000 (16:18 +0000)
committerMark McLoughlin <markmc@redhat.com>
Thu, 1 Mar 2007 16:18:55 +0000 (16:18 +0000)
        * acinclude.m4: add LIBVIRT_COMPILE_WARNINGS, copied from
        GNOME but with a few more flags we'd been using.

        * configure.in: use that instead of setting CFLAGS
        directly.

        * proxy/Makefile.am, python/Makefile.am, qemud/Makefile.am,
          src/Makefile.am, tests/Makefile.am: use $(WARN_CFLAGS)

ChangeLog
acinclude.m4 [new file with mode: 0644]
configure.in
proxy/Makefile.am
python/Makefile.am
qemud/Makefile.am
src/Makefile.am
tests/Makefile.am

index 4cd90a0c46bc71135618bddae0ba60530dc014e3..7f07f607e56440c726b7c34878df951f860f84f5 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+Thu Mar 01 16:17:48 EST 2007 Mark McLoughlin <markmc@redhat.com>
+
+       * acinclude.m4: add LIBVIRT_COMPILE_WARNINGS, copied from
+       GNOME but with a few more flags we'd been using.
+       
+       * configure.in: use that instead of setting CFLAGS
+       directly.
+       
+       * proxy/Makefile.am, python/Makefile.am, qemud/Makefile.am,
+         src/Makefile.am, tests/Makefile.am: use $(WARN_CFLAGS)
+       
 Thu Mar 01 16:00:12 EST 2007 Mark McLoughlin <markmc@redhat.com>
        
        Fix from Richard W.M. Jones <rjones@redhat.com>
diff --git a/acinclude.m4 b/acinclude.m4
new file mode 100644 (file)
index 0000000..b59f94c
--- /dev/null
@@ -0,0 +1,90 @@
+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
+dnl
+AC_DEFUN([LIBVIRT_COMPILE_WARNINGS],[
+    dnl ******************************
+    dnl More compiler warnings
+    dnl ******************************
+
+    AC_ARG_ENABLE(compile-warnings,
+                  AC_HELP_STRING([--enable-compile-warnings=@<:@no/minimum/yes/maximum/error@:>@],
+                                 [Turn on compiler warnings]),,
+                  [enable_compile_warnings="m4_default([$1],[yes])"])
+
+    warnCFLAGS=
+    if test "x$GCC" != xyes; then
+       enable_compile_warnings=no
+    fi
+
+    warning_flags=
+    realsave_CFLAGS="$CFLAGS"
+
+    case "$enable_compile_warnings" in
+    no)
+       warning_flags=
+       ;;
+    minimum)
+       warning_flags="-Wall"
+       ;;
+    yes)
+       warning_flags="-Wall -Wmissing-prototypes"
+       ;;
+    maximum|error)
+       warning_flags="-Wall -Wmissing-prototypes -Wnested-externs -Wpointer-arith"
+        warning_flags="$warning_flags -Wextra -Wshadow -Wcast-align -Wwrite-strings -Waggregate-return -Wstrict-prototypes -Winline -Wredundant-decls"
+       CFLAGS="$warning_flags $CFLAGS"
+       for option in -Wno-sign-compare; do
+               SAVE_CFLAGS="$CFLAGS"
+               CFLAGS="$CFLAGS $option"
+               AC_MSG_CHECKING([whether gcc understands $option])
+               AC_TRY_COMPILE([], [],
+                       has_option=yes,
+                       has_option=no,)
+               CFLAGS="$SAVE_CFLAGS"
+               AC_MSG_RESULT($has_option)
+               if test $has_option = yes; then
+                 warning_flags="$warning_flags $option"
+               fi
+               unset has_option
+               unset SAVE_CFLAGS
+       done
+       unset option
+       if test "$enable_compile_warnings" = "error" ; then
+           warning_flags="$warning_flags -Werror"
+       fi
+       ;;
+    *)
+       AC_MSG_ERROR(Unknown argument '$enable_compile_warnings' to --enable-compile-warnings)
+       ;;
+    esac
+    CFLAGS="$realsave_CFLAGS"
+    AC_MSG_CHECKING(what warning flags to pass to the C compiler)
+    AC_MSG_RESULT($warning_flags)
+
+    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)
+
+    WARN_CFLAGS="$warning_flags $complCFLAGS"
+    AC_SUBST(WARN_CFLAGS)
+])
index 6b3f2fdcabb39850351bb8bc9f1385673f665c42..d0911fcd106e6bda1fe99a52dfef7b3002117fe4 100644 (file)
@@ -50,6 +50,8 @@ test "x$U" != "x" && AC_MSG_ERROR(Compiler not ANSI compliant)
 
 AM_PROG_LIBTOOL
 
+LIBVIRT_COMPILE_WARNINGS(maximum)
+
 dnl Specific dir for HTML output ?
 AC_ARG_WITH(html-dir, AC_HELP_STRING([--with-html-dir=path],
             [path to base html directory, default $datadir/doc/html]),
@@ -71,13 +73,6 @@ else
 fi
 AC_SUBST(STATIC_BINARIES)
 
-dnl
-dnl make CFLAGS very pedantic at least during the devel phase for everybody
-dnl
-    if test "${GCC}" = "yes" ; then
-       CFLAGS="-g -O -W -Wformat -Wunused -Wimplicit -Wreturn-type -Wswitch -Wcomment -Wtrigraphs -Wformat -Wchar-subscripts -Wuninitialized -Wparentheses -Wshadow -Wpointer-arith -Wcast-align -Wwrite-strings -Waggregate-return -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Winline -Wredundant-decls -Wall"
-    fi
-
 dnl --enable-debug=(yes|no)
 AC_ARG_ENABLE(debug,
               AC_HELP_STRING([--enable-debug=no/yes],
index 5d2518edade7be7f572c7c758cfe672339f3faa6..2b1ca873568f511c28800acd8a1990581361f5be 100644 (file)
@@ -3,7 +3,7 @@
 INCLUDES = -I$(top_builddir)/include -I@top_srcdir@/include \
            -I@top_srcdir@/proxy -I@top_srcdir@/src @LIBXML_CFLAGS@ \
           -DPROXY  -DLOCALEBASEDIR=\""$(datadir)/locale"\" \
-           -DGETTEXT_PACKAGE=\"$(PACKAGE)\"
+           -DGETTEXT_PACKAGE=\"$(PACKAGE)\" $(WARN_CFLAGS)
 
 libexec_PROGRAMS = libvirt_proxy
 
index f0d75a7325fd472cd8f5ee70f28711313707cbc4..d8ffd149ecf7c51a833dff84571f590cfc92f292 100644 (file)
@@ -3,6 +3,7 @@
 SUBDIRS= . tests
 
 INCLUDES = \
+        $(WARN_CFLAGS) \
         -I$(PYTHON_INCLUDES) \
        -I$(top_srcdir)/include \
        -I$(top_builddir)/include \
index e12dae7e0ce54f566ec1e708ead0da5e92833a78..ba726fef3b3aa02bc8b08b359ad7ab4f6834afa5 100644 (file)
@@ -14,7 +14,7 @@ libvirt_qemud_SOURCES = qemud.c internal.h protocol.h \
 #-D_XOPEN_SOURCE=600 -D_XOPEN_SOURCE_EXTENDED=1 -D_POSIX_C_SOURCE=199506L
 libvirt_qemud_CFLAGS = \
         -I$(top_srcdir)/include -I$(top_builddir)/include $(LIBXML_CFLAGS) \
-        -Wall -Wextra -DLOCAL_STATE_DIR="\"$(localstatedir)\"" \
+        $(WARN_CFLAGS) -DLOCAL_STATE_DIR="\"$(localstatedir)\"" \
         -DSYSCONF_DIR="\"$(sysconfdir)\""
 libvirt_qemud_LDFLAGS = $(LIBXML_LIBS) $(SYSFS_LIBS)
 libvirt_qemud_DEPENDENCIES =
index f08038103b52f6e21273e2226718aa27cc7ab983..4864fb6645b9d807b06071268ba3fc6d5b1855e1 100644 (file)
@@ -3,7 +3,7 @@
 INCLUDES = -I$(top_builddir)/include -I@top_srcdir@/include @LIBXML_CFLAGS@ -I@top_srcdir@/qemud \
           -DBINDIR=\""$(libexecdir)"\" -DSBINDIR=\""$(sbindir)"\" -DLOCALEBASEDIR=\""$(datadir)/locale"\" \
            -DLOCAL_STATE_DIR=\""$(localstatedir)"\" \
-           -DGETTEXT_PACKAGE=\"$(PACKAGE)\"
+           -DGETTEXT_PACKAGE=\"$(PACKAGE)\" $(WARN_CFLAGS)
 DEPS = libvirt.la
 LDADDS = @STATIC_BINARIES@ libvirt.la
 VIRSH_LIBS = @VIRSH_LIBS@
index 62cf4ac8e95cf802d9dcc31415928a8f11db7006..c276cb0313abbc41f6239ab0900d39c821d29b53 100644 (file)
@@ -18,7 +18,8 @@ INCLUDES = \
        @LIBXML_CFLAGS@ \
         -D_XOPEN_SOURCE=600 -D_POSIX_C_SOURCE=199506L \
         -DGETTEXT_PACKAGE=\"$(PACKAGE)\" \
-         $(COVERAGE_CFLAGS)
+         $(COVERAGE_CFLAGS) \
+         $(WARN_CFLAGS)
 
 LDADDS = \
        @STATIC_BINARIES@ \