PATCH 21.5
This patch captures the values of __GNUC__ and __GNUC_MINOR__ in
configure variables when gcc is used. It uses them to see if gcc 3.4 or
later is in use and, if so, adds -Wdeclaration-after-statement to the
warning flags when compiling with C.
I am interested in finding out whether this approach is acceptable to
the other developers. In particular, is the $(( ... )) syntax okay? It
is standard Bourne shell (see the Single Unix Specification on
www.unix.org), but it is not used anywhere in our present configure
script. Is anyone using a shell that does not support that syntax?
ChangeLog addition:
2006-06-20 Jerry James <james(a)xemacs.org>
* configure.ac: When gcc is used, capture the values of __GNUC__
and __GNUC_MINOR__. Use them to conditionally add warning flags
that are not supported by all versions of gcc.
xemacs-21.5 source patch:
Diff command: cvs -q diff -uN
Files affected: configure.ac
Index: configure.ac
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/configure.ac,v
retrieving revision 1.43
diff -d -u -r1.43 configure.ac
--- configure.ac 2006/06/06 00:18:29 1.43
+++ configure.ac 2006/06/20 17:11:33
@@ -1883,15 +1883,13 @@
dnl Determine GCC version.
if test "$GCC" = "yes"; then
AC_RUN_IFELSE([AC_LANG_SOURCE([int main () {
-#if __GNUC__ >= 3
-return 11;
-#else
-return 0;
-#endif
-}])], [:],
-[case "$?" in
- 11) echo "You appear to be using GCC version 3 or above."; __GCC3=yes ;;
-esac])
+return __GNUC__;
+}])], [:], [__GCC="$?"])
+AC_RUN_IFELSE([AC_LANG_SOURCE([int main () {
+return __GNUC_MINOR__;
+}])], [:], [__GCC_MINOR="$?"])
+__GCC_VERSION=$__GCC"."$__GCC_MINOR
+echo "You appear to be using GCC version" $__GCC_VERSION
fi
dnl Support for using a different compiler for xemacs itself.
@@ -2311,7 +2309,7 @@
dnl Warnings about char subscripts are pretty pointless, though,
dnl and we use them in various places.
with_cflags_warning="$with_cflags_warning -Wsign-compare
-Wno-char-subscripts"
- test "$__GCC3" = "yes" &&
with_cflags_warning="$with_cflags_warning -Wpacked"
+ test $((__GCC)) -ge 3 && with_cflags_warning="$with_cflags_warning
-Wpacked"
dnl glibc is intentionally not `-Wpointer-arith'-clean.
dnl Ulrich Drepper has rejected patches to fix the glibc header files.
test "$have_glibc" != "yes" && \
@@ -2327,8 +2325,11 @@
dnl some very ugly code changes.
if test "$with_xemacs_compiler" = "g++"; then
xe_cflags_warning="$with_cflags_warning -Weffc++"
- elif test "$__GCC3" = "yes"; then
+ elif test $((__GCC)) -ge 3; then
xe_cflags_warning="$with_cflags_warning -Wunused-parameter"
+ if test $((__GCC)) -gt 3 || test $((__GCC_MINOR)) -ge 4; then
+ with_cflags_warning="$with_cflags_warning
-Wdeclaration-after-statement"
+ fi
fi
with_cflags_warning="$with_cflags_warning -Wshadow -Wmissing-declarations"
with_cflags_warning="$with_cflags_warning -Wmissing-prototypes
-Wstrict-prototypes"
--
Jerry James, Assistant Professor james(a)xemacs.org
Computer Science Department
http://www.cs.usu.edu/~jerry/
Utah State University