summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Baulig <baulig@suse.de>2000-12-01 12:52:04 +0000
committerMartin Baulig <martin@src.gnome.org>2000-12-01 12:52:04 +0000
commitf5913c6435478563d59b948178c93b1932561af3 (patch)
treee4df3b611381d18df0d3dc4651a8a39fba0224bb
parent5cbf1adf6c9ec9c9fa3b3da52b851c94ce3cef62 (diff)
downloadgnome-common-f5913c6435478563d59b948178c93b1932561af3.tar.gz
Improved compile warnings check; the --enable-compile-warnings parameter
2000-12-01 Martin Baulig <baulig@suse.de> * compile-warnings.m4: Improved compile warnings check; the --enable-compile-warnings parameter now takes 5 different values (no/minimum/yes/maximum/error). AC_SUBST(WARN_CFLAGS). svn path=/trunk/; revision=1475
-rw-r--r--macros2/ChangeLog6
-rw-r--r--macros2/compiler-flags.m4116
2 files changed, 81 insertions, 41 deletions
diff --git a/macros2/ChangeLog b/macros2/ChangeLog
index 1d6022c..91fc618 100644
--- a/macros2/ChangeLog
+++ b/macros2/ChangeLog
@@ -1,3 +1,9 @@
+2000-12-01 Martin Baulig <baulig@suse.de>
+
+ * compile-warnings.m4: Improved compile warnings check; the
+ --enable-compile-warnings parameter now takes 5 different
+ values (no/minimum/yes/maximum/error). AC_SUBST(WARN_CFLAGS).
+
2000-11-29 Martin Baulig <baulig@suse.de>
* gnome.m4, gnome-gnorba-check.m4, gnome-fileutils.m4: Removed.
diff --git a/macros2/compiler-flags.m4 b/macros2/compiler-flags.m4
index 63f8e2e..7294784 100644
--- a/macros2/compiler-flags.m4
+++ b/macros2/compiler-flags.m4
@@ -2,56 +2,90 @@ dnl GNOME_COMPILE_WARNINGS
dnl Turn on many useful compiler warnings
dnl For now, only works on GCC
AC_DEFUN([GNOME_COMPILE_WARNINGS],[
- AC_ARG_ENABLE(compile-warnings,
- [ --enable-compile-warnings=[no/minimum/yes] Turn on compiler warnings.],,enable_compile_warnings=minimum)
+ dnl ******************************
+ dnl More compiler warnings
+ dnl ******************************
- AC_MSG_CHECKING(what warning flags to pass to the C compiler)
- warnCFLAGS=
- if test "x$GCC" != xyes; then
- enable_compile_warnings=no
- fi
+ if test -z "$1" ; then
+ default_compile_warnings=no
+ else
+ default_compile_warnings="$1"
+ fi
- if test "x$enable_compile_warnings" != "xno"; then
- if test "x$GCC" = "xyes"; then
- case " $CFLAGS " in
- *[\ \ ]-Wall[\ \ ]*) ;;
- *) warnCFLAGS="-Wall -Wunused" ;;
- esac
+ AC_ARG_ENABLE(compile-warnings,
+ [ --enable-compile-warnings=[no/minimum/yes/maximum/error] Turn on compiler warnings.], [enable_compile_warnings="$enableval"],[enable_compile_warnings="$default_compile_warnings"])
- ## -W is not all that useful. And it cannot be controlled
- ## with individual -Wno-xxx flags, unlike -Wall
- if test "x$enable_compile_warnings" = "xyes"; then
- warnCFLAGS="$warnCFLAGS -Wmissing-prototypes -Wmissing-declarations"
- fi
+ warnCFLAGS=
+ if test "x$GCC" != xyes; then
+ enable_compile_warnings=no
fi
- fi
- AC_MSG_RESULT($warnCFLAGS)
- AC_ARG_ENABLE(iso-c,
+ warning_flags=
+ realsave_CFLAGS="$CFLAGS"
+
+ case "$enable_compile_warnings" in
+ no)
+ warning_flags=
+ ;;
+ minimum)
+ warning_flags="-Wall -Wunused"
+ ;;
+ yes)
+ warning_flags="-Wall -Wunused -Wmissing-prototypes -Wmissing-declarations"
+ ;;
+ maximum|error)
+ warning_flags="-Wall -Wunused -Wchar-subscripts -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wpointer-arith"
+ CFLAGS="$warning_flags $CFLAGS"
+ for option in -Wsign-promo -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,
[ --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
+ 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
- fi
- AC_MSG_RESULT($complCFLAGS)
- if test "x$cflags_set" != "xyes"; then
- CFLAGS="$CFLAGS $warnCFLAGS $complCFLAGS"
- cflags_set=yes
- AC_SUBST(cflags_set)
- fi
+ AC_MSG_RESULT($complCFLAGS)
+
+ WARN_CFLAGS="$warning_flags $complCFLAGS"
+ AC_SUBST(WARN_CFLAGS)
])
dnl For C++, do basically the same thing.