This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Patch to add AC macro to detect exact gcc version
- To: gcc-patches at gcc dot gnu dot org
- Subject: Patch to add AC macro to detect exact gcc version
- From: "Kaveh R. Ghazi" <ghazi at caip dot rutgers dot edu>
- Date: Sun, 23 Sep 2001 13:18:09 -0400 (EDT)
This patch detects the exact version of gcc being used. I know
normally one attempts to test features etc with autoconf, but
sometimes a bug or warning comes and goes depending on the exact
platform and snapshot version you are using. In those cases it is
useful to just say, I know the problem was squashed in version X, so
test whether we have that or not.
You use this macro by saying e.g. this in configure.in:
> gcc_AC_HAVE_GCC_VERSION(3,1,0,20010825)
and it'll cache "yes" if major, minor, patchlevel and date minimums
are met. It'll also #define HAVE_GCC_VERSION_w_x_y_z (with the
appropriate values for w, x, y & z.) Finally, you can add
ACTION_IF_FOUND & ACTION_IF_NOT_FOUND as optional parameters 5 & 6
I plan to use this in future work for warning error detection, but I
thought it might be useful in a general sense separate from anything
else. Tested by rebuilding configure/config.in on solaris2.7 with
several test entries in configure.in to exercise the macro when
rerunning configure.
Okay to install?
Thanks,
--Kaveh
2001-09-23 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
* aclocal.m4 (gcc_AC_HAVE_GCC_VERSION): New macro.
diff -rup orig/egcs-CVS20010923/gcc/aclocal.m4 egcs-CVS20010923/gcc/aclocal.m4
--- orig/egcs-CVS20010923/gcc/aclocal.m4 Wed Jul 18 16:30:11 2001
+++ egcs-CVS20010923/gcc/aclocal.m4 Sun Sep 23 12:54:38 2001
@@ -1,3 +1,32 @@
+dnl Determine whether we have gcc of a particular version or later,
+dnl based on major, minor, patchlevel versions and date.
+dnl gcc_AC_HAVE_GCC_VERSION(MAJOR_VERSION, MINOR_VERSION, PATCH_LEVEL,
+dnl SNAPSHOT_DATE [, ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
+AC_DEFUN(gcc_AC_HAVE_GCC_VERSION,
+[AC_CACHE_CHECK([the stage1 compiler is gcc of at least version $1.$2.$3.$4],
+ ac_cv_gcc_version_$1_$2_$3_$4,
+[
+ if test x$GCC = x ; then ac_cv_gcc_version_$1_$2_$3_$4=no
+ else
+ ac_gcc_date=`$CC -v 2>&1 | grep '^gcc version ' | sed 's/ (.*//; s/.* //'`
+ if test 0$ac_gcc_date -eq 0 ; then ac_gcc_date=0 ; fi
+ AC_EGREP_CPP(yes, [#define HAVE_GCC_VERSION(MAJOR, MINOR, MICRO, DATE) \
+ (__GNUC__ > (MAJOR) \
+ || (__GNUC__ == (MAJOR) && __GNUC_MINOR__ > (MINOR)) \
+ || (__GNUC__ == (MAJOR) && __GNUC_MINOR__ == (MINOR) \
+ && __GNUC_PATCHLEVEL__ > (MICRO)) \
+ || (__GNUC__ == (MAJOR) && __GNUC_MINOR__ == (MINOR) \
+ && __GNUC_PATCHLEVEL__ == (MICRO) && ${ac_gcc_date}L >= (DATE)))
+#if HAVE_GCC_VERSION($1,$2,$3,$4)
+yes
+#endif],
+ AC_DEFINE_UNQUOTED(HAVE_GCC_VERSION_$1_$2_$3_$4, 1,
+ [Define to 1 if we have gcc $1.$2.$3 ($4)])
+ ac_cv_gcc_version_$1_$2_$3_$4=yes ; $5,
+ ac_cv_gcc_version_$1_$2_$3_$4=no ; $6)
+fi
+])])dnl
+
dnl See if stdbool.h properly defines bool and true/false.
AC_DEFUN(gcc_AC_HEADER_STDBOOL,
[AC_CACHE_CHECK([for working stdbool.h],