This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
Factor configure-time gcc version checks (patch 1/4 for PR 7305)
- From: Richard Sandiford <rsandifo at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org
- Cc: java-patches at gcc dot gnu dot org, libstdc++ at gcc dot gnu dot org, binutils at sources dot redhat dot com, gdb-patches at sources dot redhat dot com
- Date: Thu, 25 Nov 2004 20:46:31 +0000
- Subject: Factor configure-time gcc version checks (patch 1/4 for PR 7305)
[Sorry for the wide distribution, but this patch affects top-level stuff,
C++ and libjava.]
This patch adds a new top-level configure fragment, config/gcc-version.m4,
to work out gcc's version number. Although it's really the first of four
patches to change where libjava installs its header files, I hope it's
worthwhile as a clean-up in its own right.
To describe the wider objective:
At the moment, libjava installs its header files into $prefix/include.
This causes two problems:
(1) You can't install two different versions into the same tree.
This is PR 7305: http://gcc.gnu.org/PR7305
(2) Cross compilers (quite rightly) don't look in $prefix/include,
so any attempt to use CNI headers will fail without an explicit
-I option: http://gcc.gnu.org/ml/java/2003-04/msg00243.html
This was discussed at length in the thread starting here:
http://gcc.gnu.org/ml/gcc/2003-05/msg00319.html
and it seemed that both the libstdc++ and java maintainers were happy
with installing the CNI headers into the same directory as libstdc++.
The (very few) C-compatible java headers can go into the usual
tool-specific include directory instead.
It's easy enough to change the install rules. I think the thorny bit
isn't so much that as teaching libjava where the g++ include path is.
The easy way would be to cut-&-paste the logic that can be found in
other configure scripts. Thing is, we already have three pieces of
code to work out the g++ include path: one in top-level ./configure,
one in gcc/configure, and one in libstdc++-v3/configure. I didn't
really want to add a fourth.
This series of patches instead adds a new config/gxx-include-dir.m4
fragment that can be shared between configure scripts. To avoid
getting too sidetracked, the patches will only make ./configure and
libjava/configure use this new fragment, so while there'll be no net
increase in duplication, there'll unfortunately be no net reduction
either.
Writing config/gxx-include-dir.m4 is made slightly tricky by the fact
that it needs to know the gcc version number. At the moment, there are
lots of copies of the code to work this out, and if we're going to have
a common fragment for $gxx_include_dir, it would make sense to have a
common fragment for the version number as well.
Also, the top-level and gcc/ versions of the $gxx_include_dir logic
use config.if to work out $libstdcxx_incdir. All config.if really
does is work out the gcc version and then tack "c++/" in front of it.
Once we have a common fragment to work out the gcc version number,
config.if will serve no useful purpose.
So... the four patches are as follows:
(1) Provide a config/gcc-version.m4 fragment to work out
$gcc_version_trigger, $gcc_version_full and $gcc_version.
(2) Remove config.if.
(3) Provide a config/gxx-include-dir.m4 fragment and use it
in the top-level configuration file.
(4) The main libjava patch.
Part (1) is attached below. The logic used in the new autoconf fragment
is mostly taken from config.if.
Patch bootstrapped & regression tested (on its own) on i686-pc-linux-gnu.
I also checked that:
- The top-level configure gets the right version and version trigger.
- The top-level makefile still passes --with-gcc-version-trigger
down to subconfigures.
- The subconfigures correctly read --with-gcc-version-trigger
and record the right version number.
- There's no change in the version numbers for installed paths.
OK to install?
Richard
* configure.in: Include config/gcc-version.m4. Use TL_AC_GCC_VERSION
to set gcc_version_trigger. Remove some now-redundant AC_SUBSTs.
* configure: Regenerate.
config/
* config/gcc-version.m4: New file.
fastjar/
* configure.ac: Use TL_AC_GCC_VERSION to set gcc_version.
* configure, aclocal.m4, Makefile.in: Regenerate.
fixincludes/
* configure.ac: Use TL_AC_GCC_VERSION to set gcc_version.
* aclocal.m4: Include ../config/gcc-version.m4.
* configure: Regenerate.
gcc/
* configure.ac: Use TL_AC_GCC_VERSION to set gcc_version. Remove
now-redundant AC_SUBSTs.
* aclocal.m4: Include ../config/gcc-version.m4.
* configure: Regenerate.
libffi/
* configure.ac: Use TL_AC_GCC_VERSION to set gcc_version.
* configure, aclocal.m4, Makefile.in: Regenerate.
* include/Makefile.in, testsuite/Makefile.in: Regenerate.
libgfortran/
* configure.ac: Use TL_AC_GCC_VERSION to set gcc_version.
* configure, aclocal.m4, Makefile.in: Regenerate.
libjava/
* configure.ac: Use TL_AC_GCC_VERSION to set gcc_version.
* configure, aclocal.m4, Makefile.in, gcj/Makefile.in: Regenerate.
* include/Makefile.in, testsuite/Makefile.in: Regenerate.
libmudflap/
* configure.ac: Use TL_AC_GCC_VERSION to set gcc_version.
* configure, aclocal.m4, Makefile.in: Regenerate.
* testsuite/Makefile.in: Regenerate.
libobjc/
* configure.ac: Use TL_AC_GCC_VERSION to set gcc_version.
* configure, aclocal.m4: Regenerate.
Index: configure.in
===================================================================
RCS file: /cvs/gcc/gcc/configure.in,v
retrieving revision 1.332
diff -c -p -F^\([(a-zA-Z0-9_]\|#define\) -r1.332 configure.in
*** configure.in 12 Nov 2004 19:15:21 -0000 1.332
--- configure.in 25 Nov 2004 20:19:55 -0000
***************
*** 19,24 ****
--- 19,25 ----
### WARNING: this file contains embedded tabs. Do not run untabify on this file.
sinclude(config/acx.m4)
+ sinclude(config/gcc-version.m4)
AC_INIT(move-if-change)
AC_PREREQ(2.13)
*************** fi
*** 98,122 ****
topsrcdir=$srcpwd
extra_host_args=
# Define the trigger file to make sure configure will re-run whenever
# the gcc version number changes.
! if test "${with_gcc_version_trigger+set}" = set ; then
! gcc_version_trigger="$with_gcc_version_trigger"
! gcc_version=`grep version_string ${with_gcc_version_trigger} | sed -e 's/.*\"\([[^ \"]]*\)[[ \"]].*/\1/'`
! else
! # If gcc's sources are available, define the trigger file.
! if test -f ${topsrcdir}/gcc/version.c ; then
! gcc_version_trigger=${topsrcdir}/gcc/version.c
! gcc_version=`grep version_string ${gcc_version_trigger} | sed -e 's/.*\"\([[^ \"]]*\)[[ \"]].*/\1/'`
! case "$ac_configure_args" in
! *--with-gcc-version-trigger=$gcc_version_trigger* )
! ;;
! * )
! # Add to all subconfigure arguments: build, host, and target.
! ac_configure_args="$ac_configure_args --with-gcc-version-trigger=$gcc_version_trigger"
! ;;
! esac
! fi
fi
### To add a new directory to the tree, first choose whether it is a target
--- 99,117 ----
topsrcdir=$srcpwd
extra_host_args=
+
# Define the trigger file to make sure configure will re-run whenever
# the gcc version number changes.
! TL_AC_GCC_VERSION([$topsrcdir])
! if test -f $gcc_version_trigger ; then
! case "$ac_configure_args" in
! *--with-gcc-version-trigger=$gcc_version_trigger* )
! ;;
! * )
! # Add to all subconfigure arguments: build, host, and target.
! ac_configure_args="$ac_configure_args --with-gcc-version-trigger=$gcc_version_trigger"
! ;;
! esac
fi
### To add a new directory to the tree, first choose whether it is a target
*************** AC_SUBST(SET_LIB_PATH)
*** 2154,2161 ****
AC_SUBST(RPATH_ENVVAR)
AC_SUBST(BUILD_PREFIX)
AC_SUBST(BUILD_PREFIX_1)
- AC_SUBST(gcc_version_trigger)
- AC_SUBST(gcc_version)
AC_SUBST(tooldir)
AC_SUBST(build_tooldir)
AC_SUBST(GDB_TK)
--- 2149,2154 ----
Index: fastjar/configure.ac
===================================================================
RCS file: /cvs/gcc/gcc/fastjar/configure.ac,v
retrieving revision 1.5
diff -c -p -F^\([(a-zA-Z0-9_]\|#define\) -r1.5 configure.ac
*** fastjar/configure.ac 19 Jul 2004 20:08:20 -0000 1.5
--- fastjar/configure.ac 25 Nov 2004 20:19:55 -0000
*************** AC_MSG_CHECKING([whether to place genera
*** 89,104 ****
AC_MSG_RESULT($generated_files_in_srcdir)
AM_CONDITIONAL(GENINSRC, test x$generated_files_in_srcdir = xyes)
! # Get the version trigger filename from the toplevel
! if test "${with_gcc_version_trigger+set}" = set; then
! gcc_version_trigger=$with_gcc_version_trigger
! else
! gcc_version_trigger=${srcdir}/version.c
! fi
! changequote(,)dnl
! gcc_version_full=`grep version_string ${gcc_version_trigger} | sed -e 's/.*"\([^"]*\)".*/\1/'`
! gcc_version=`echo ${gcc_version_full} | sed -e 's/\([^ ]*\) .*/\1/'`
! changequote([,])dnl
! AC_SUBST(gcc_version)
AC_OUTPUT(Makefile install-defs.sh)
--- 89,94 ----
AC_MSG_RESULT($generated_files_in_srcdir)
AM_CONDITIONAL(GENINSRC, test x$generated_files_in_srcdir = xyes)
! TL_AC_GCC_VERSION([$srcdir/..])
AC_OUTPUT(Makefile install-defs.sh)
Index: fixincludes/configure.ac
===================================================================
RCS file: /cvs/gcc/gcc/fixincludes/configure.ac,v
retrieving revision 1.4
diff -c -p -F^\([(a-zA-Z0-9_]\|#define\) -r1.4 configure.ac
*** fixincludes/configure.ac 5 Nov 2004 04:48:32 -0000 1.4
--- fixincludes/configure.ac 25 Nov 2004 20:19:55 -0000
*************** if test $TARGET = twoprocess; then
*** 52,62 ****
[Define if testing and fixing are done by separate process])
fi
! # Get GCC's version number.
! changequote(,)dnl
! gcc_version=`sed -n '/version_string/ { s/.*"\([^ "]*\)[^"]*".*/\1/p ; }' ${srcdir}/../gcc/version.c`
! changequote([,])dnl
! AC_SUBST(gcc_version)
case $host in
vax-dec-bsd* )
--- 52,58 ----
[Define if testing and fixing are done by separate process])
fi
! TL_AC_GCC_VERSION([$srcdir/..])
case $host in
vax-dec-bsd* )
Index: fixincludes/aclocal.m4
===================================================================
RCS file: /cvs/gcc/gcc/fixincludes/aclocal.m4,v
retrieving revision 1.1
diff -c -p -F^\([(a-zA-Z0-9_]\|#define\) -r1.1 aclocal.m4
*** fixincludes/aclocal.m4 31 Aug 2004 09:26:05 -0000 1.1
--- fixincludes/aclocal.m4 25 Nov 2004 20:19:56 -0000
***************
*** 1,5 ****
--- 1,6 ----
sinclude(../config/acx.m4)
sinclude(../config/accross.m4)
+ sinclude(../config/gcc-version.m4)
sinclude(../config/gettext.m4)
sinclude(../config/progtest.m4)
Index: gcc/configure.ac
===================================================================
RCS file: /cvs/gcc/gcc/gcc/configure.ac,v
retrieving revision 2.85
diff -c -p -F^\([(a-zA-Z0-9_]\|#define\) -r2.85 configure.ac
*** gcc/configure.ac 25 Nov 2004 01:41:20 -0000 2.85
--- gcc/configure.ac 25 Nov 2004 20:20:00 -0000
*************** xm_file="ansidecl.h ${xm_file}"
*** 1379,1394 ****
# UNSORTED
# --------
! # Get the version trigger filename from the toplevel
! if test "${with_gcc_version_trigger+set}" = set; then
! gcc_version_trigger=$with_gcc_version_trigger
! else
! gcc_version_trigger=${srcdir}/version.c
! fi
! changequote(,)dnl
! gcc_version_full=`grep version_string ${gcc_version_trigger} | sed -e 's/.*"\([^"]*\)".*/\1/'`
! gcc_version=`echo ${gcc_version_full} | sed -e 's/\([^ ]*\) .*/\1/'`
# Compile in configure arguments.
if test -f configargs.h ; then
# Being re-configured.
--- 1379,1387 ----
# UNSORTED
# --------
! TL_AC_GCC_VERSION([$srcdir/..])
+ changequote(,)dnl
# Compile in configure arguments.
if test -f configargs.h ; then
# Being re-configured.
*************** AC_SUBST(float_h_file)
*** 3237,3245 ****
AC_SUBST(gcc_config_arguments)
AC_SUBST(gcc_gxx_include_dir)
AC_SUBST(libstdcxx_incdir)
- AC_SUBST(gcc_version)
- AC_SUBST(gcc_version_full)
- AC_SUBST(gcc_version_trigger)
AC_SUBST(host_exeext)
AC_SUBST(host_xm_file_list)
AC_SUBST(host_xm_include_list)
--- 3230,3235 ----
Index: gcc/aclocal.m4
===================================================================
RCS file: /cvs/gcc/gcc/gcc/aclocal.m4,v
retrieving revision 1.99
diff -c -p -F^\([(a-zA-Z0-9_]\|#define\) -r1.99 aclocal.m4
*** gcc/aclocal.m4 20 Oct 2004 21:36:40 -0000 1.99
--- gcc/aclocal.m4 25 Nov 2004 20:20:00 -0000
*************** m4_include([../config/accross.m4])
*** 2,7 ****
--- 2,8 ----
m4_include([../config/acx.m4])
m4_include([../config/gettext-sister.m4])
m4_include([../config/gcc-lib-path.m4])
+ m4_include([../config/gcc-version.m4])
m4_include([../config/iconv.m4])
m4_include([../config/lcmessage.m4])
m4_include([../config/lib-ld.m4])
Index: libffi/configure.ac
===================================================================
RCS file: /cvs/gcc/gcc/libffi/configure.ac,v
retrieving revision 1.8
diff -c -p -F^\([(a-zA-Z0-9_]\|#define\) -r1.8 configure.ac
*** libffi/configure.ac 13 Oct 2004 17:20:23 -0000 1.8
--- libffi/configure.ac 25 Nov 2004 20:20:01 -0000
*************** esac
*** 226,241 ****
AC_SUBST(toolexecdir)
AC_SUBST(toolexeclibdir)
#Figure out where generated headers like ffitarget.h get installed.
- changequote(,)dnl
- gcc_version_trigger=${srcdir}/../gcc/version.c
- gcc_version_full=`grep version_string ${gcc_version_trigger} | sed -e 's/.*\"\([^\"]*\)\".*/\1/'`
- gcc_version=`echo ${gcc_version_full} | sed -e 's/\([^ ]*\) .*/\1/'`
tool_include_dir='$(libdir)/gcc/$(target_alias)/'${gcc_version}/include
- changequote([,])dnl
AC_SUBST(tool_include_dir)
- AC_SUBST(gcc_version)
-
if test "${multilib}" = "yes"; then
multilib_arg="--enable-multilib"
--- 226,236 ----
AC_SUBST(toolexecdir)
AC_SUBST(toolexeclibdir)
+ TL_AC_GCC_VERSION([$srcdir/..])
+
#Figure out where generated headers like ffitarget.h get installed.
tool_include_dir='$(libdir)/gcc/$(target_alias)/'${gcc_version}/include
AC_SUBST(tool_include_dir)
if test "${multilib}" = "yes"; then
multilib_arg="--enable-multilib"
Index: libgfortran/configure.ac
===================================================================
RCS file: /cvs/gcc/gcc/libgfortran/configure.ac,v
retrieving revision 1.16
diff -c -p -F^\([(a-zA-Z0-9_]\|#define\) -r1.16 configure.ac
*** libgfortran/configure.ac 23 Nov 2004 02:02:37 -0000 1.16
--- libgfortran/configure.ac 25 Nov 2004 20:20:02 -0000
*************** else
*** 68,78 ****
LIBGFOR_IS_NATIVE=true
fi
! # Process the option "--enable-version-specific-runtime-libs"
! gcc_version_trigger=${srcdir}/../gcc/version.c
! gcc_version_full=`grep version_string ${gcc_version_trigger} | sed -e 's/.*\"\([[^ \"]]*\)[[ \"]].*/\1/'`
! gcc_version=`echo ${gcc_version_full} | sed -e 's/\([^ ]*\) .*/\1/'`
! AC_SUBST(gcc_version)
# Calculate toolexeclibdir
# Also toolexecdir, though it's only used in toolexeclibdir
--- 68,74 ----
LIBGFOR_IS_NATIVE=true
fi
! TL_AC_GCC_VERSION([$srcdir/..])
# Calculate toolexeclibdir
# Also toolexecdir, though it's only used in toolexeclibdir
Index: libjava/configure.ac
===================================================================
RCS file: /cvs/gcc/gcc/libjava/configure.ac,v
retrieving revision 1.14
diff -c -p -F^\([(a-zA-Z0-9_]\|#define\) -r1.14 configure.ac
*** libjava/configure.ac 25 Nov 2004 03:46:56 -0000 1.14
--- libjava/configure.ac 25 Nov 2004 20:20:03 -0000
*************** AM_CONDITIONAL(USING_GCC, test "$GCC" =
*** 730,742 ****
# We're in the tree with gcc, and need to include some of its headers.
GCC_UNWIND_INCLUDE='-I$(libgcj_basedir)/../gcc'
# Figure out where generated headers like libgcj-config.h get installed.
- gcc_version_trigger=${libgcj_basedir}/../gcc/version.c
- gcc_version_full=`grep version_string ${gcc_version_trigger} | sed -e 's/.*\"\([[^\"]]*\)\".*/\1/'`
- gcc_version=`echo ${gcc_version_full} | sed -e 's/\([[^ ]]*\) .*/\1/'`
tool_include_dir='$(libdir)/gcc/$(target_noncanonical)/'${gcc_version}/include
AC_SUBST(tool_include_dir)
- AC_SUBST(gcc_version)
if test "x${with_newlib}" = "xyes"; then
# We are being configured with a cross compiler. AC_REPLACE_FUNCS
--- 730,740 ----
# We're in the tree with gcc, and need to include some of its headers.
GCC_UNWIND_INCLUDE='-I$(libgcj_basedir)/../gcc'
+ TL_AC_GCC_VERSION([$srcdir/..])
+
# Figure out where generated headers like libgcj-config.h get installed.
tool_include_dir='$(libdir)/gcc/$(target_noncanonical)/'${gcc_version}/include
AC_SUBST(tool_include_dir)
if test "x${with_newlib}" = "xyes"; then
# We are being configured with a cross compiler. AC_REPLACE_FUNCS
Index: libmudflap/configure.ac
===================================================================
RCS file: /cvs/gcc/gcc/libmudflap/configure.ac,v
retrieving revision 1.8
diff -c -p -F^\([(a-zA-Z0-9_]\|#define\) -r1.8 configure.ac
*** libmudflap/configure.ac 1 Nov 2004 21:27:26 -0000 1.8
--- libmudflap/configure.ac 25 Nov 2004 20:20:03 -0000
*************** AC_SUBST(build_libmudflapth)
*** 132,142 ****
AC_CHECK_LIB(dl, dlsym)
! # Process the option "--enable-version-specific-runtime-libs"
! gcc_version_trigger=${srcdir}/../gcc/version.c
! gcc_version_full=`grep version_string ${gcc_version_trigger} | sed -e 's/.*\"\([[^ \"]]*\)[[ \"]].*/\1/'`
! gcc_version=`echo ${gcc_version_full} | sed -e 's/\([^ ]*\) .*/\1/'`
! AC_SUBST(gcc_version)
# Calculate toolexeclibdir
# Also toolexecdir, though it's only used in toolexeclibdir
--- 132,138 ----
AC_CHECK_LIB(dl, dlsym)
! TL_AC_GCC_VERSION([$srcdir/..])
# Calculate toolexeclibdir
# Also toolexecdir, though it's only used in toolexeclibdir
Index: libobjc/configure.ac
===================================================================
RCS file: /cvs/gcc/gcc/libobjc/configure.ac,v
retrieving revision 1.11
diff -c -p -F^\([(a-zA-Z0-9_]\|#define\) -r1.11 configure.ac
*** libobjc/configure.ac 20 Oct 2004 01:26:37 -0000 1.11
--- libobjc/configure.ac 25 Nov 2004 20:20:03 -0000
*************** case $srcdir in
*** 117,127 ****
esac
AC_SUBST(glibcpp_srcdir)
! # Process the option "--enable-version-specific-runtime-libs"
! gcc_version_trigger=${srcdir}/../gcc/version.c
! gcc_version_full=`grep version_string ${gcc_version_trigger} | sed -e 's/.*\"\([[^ \"]]*\)[[ \"]].*/\1/'`
! gcc_version=`echo ${gcc_version_full} | sed -e 's/\([^ ]*\) .*/\1/'`
! AC_SUBST(gcc_version)
# Calculate toolexeclibdir
# Also toolexecdir, though it's only used in toolexeclibdir
--- 117,123 ----
esac
AC_SUBST(glibcpp_srcdir)
! TL_AC_GCC_VERSION([$srcdir/..])
# Calculate toolexeclibdir
# Also toolexecdir, though it's only used in toolexeclibdir
diff -c /dev/null config/gcc-version.m4
*** /dev/null 2004-11-05 11:37:39.608355984 +0000
--- config/gcc-version.m4 2004-11-25 15:50:09.000000000 +0000
***************
*** 0 ****
--- 1,28 ----
+ dnl Usage: TL_AC_GCC_VERSION(TOPSRCDIR)
+ dnl
+ dnl Set up the variables:
+ dnl
+ dnl gcc_version_trigger: pathname of gcc's version.c, if available
+ dnl gcc_version_full: full gcc version string
+ dnl gcc_version: the first "word" in $gcc_version_full
+ dnl
+ dnl TOPSRCDIR is the top-level source directory.
+ AC_DEFUN([TL_AC_GCC_VERSION],
+ [
+ changequote(,)dnl
+ if test "${with_gcc_version_trigger+set}" = set; then
+ gcc_version_trigger=$with_gcc_version_trigger
+ else
+ gcc_version_trigger=$1/gcc/version.c
+ fi
+ if test -f "${gcc_version_trigger}"; then
+ gcc_version_full=`grep version_string "${gcc_version_trigger}" | sed -e 's/.*"\([^"]*\)".*/\1/'`
+ else
+ gcc_version_full=`$CC -v 2>&1 | sed -n 's/^gcc version //p'`
+ fi
+ gcc_version=`echo ${gcc_version_full} | sed -e 's/\([^ ]*\) .*/\1/'`
+ changequote([,])dnl
+ AC_SUBST(gcc_version_trigger)
+ AC_SUBST(gcc_version_full)
+ AC_SUBST(gcc_version)
+ ])dnl