From: Mark McLoughlin Date: Thu, 1 Mar 2007 16:18:55 +0000 (+0000) Subject: Thu Mar 01 16:17:48 EST 2007 Mark McLoughlin X-Git-Tag: LIBVIRT_0_2_1~51 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=51d560984381a98796465f2628a5f5e2a1753506;p=thirdparty%2Flibvirt.git Thu Mar 01 16:17:48 EST 2007 Mark McLoughlin * 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) --- diff --git a/ChangeLog b/ChangeLog index 4cd90a0c46..7f07f607e5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +Thu Mar 01 16:17:48 EST 2007 Mark McLoughlin + + * 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 Fix from Richard W.M. Jones diff --git a/acinclude.m4 b/acinclude.m4 new file mode 100644 index 0000000000..b59f94c4eb --- /dev/null +++ b/acinclude.m4 @@ -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) +]) diff --git a/configure.in b/configure.in index 6b3f2fdcab..d0911fcd10 100644 --- a/configure.in +++ b/configure.in @@ -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], diff --git a/proxy/Makefile.am b/proxy/Makefile.am index 5d2518edad..2b1ca87356 100644 --- a/proxy/Makefile.am +++ b/proxy/Makefile.am @@ -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 diff --git a/python/Makefile.am b/python/Makefile.am index f0d75a7325..d8ffd149ec 100644 --- a/python/Makefile.am +++ b/python/Makefile.am @@ -3,6 +3,7 @@ SUBDIRS= . tests INCLUDES = \ + $(WARN_CFLAGS) \ -I$(PYTHON_INCLUDES) \ -I$(top_srcdir)/include \ -I$(top_builddir)/include \ diff --git a/qemud/Makefile.am b/qemud/Makefile.am index e12dae7e0c..ba726fef3b 100644 --- a/qemud/Makefile.am +++ b/qemud/Makefile.am @@ -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 = diff --git a/src/Makefile.am b/src/Makefile.am index f08038103b..4864fb6645 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -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@ diff --git a/tests/Makefile.am b/tests/Makefile.am index 62cf4ac8e9..c276cb0313 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -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@ \