[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 2/6] test defs: setup `*FLAGS' variables for GNU compilers
From: |
Stefano Lattarini |
Subject: |
[PATCH 2/6] test defs: setup `*FLAGS' variables for GNU compilers |
Date: |
Thu, 19 Jan 2012 14:55:17 +0100 |
* configure.ac: Setup some `*FLAGS' variables for use by the
GNU compilers in our testsuite. For example, use `GNU_CFLAGS'
instead of `CFLAGS', and so on for similar variables. This
is especially useful in case the compilers found or defined
at configure time are not the GNU ones.
* tests/defs-static.in: Initialize those same variables with
the values set at configure time, but allowing overrides
from the environment.
* tests/Makefile.am (do_subst): Process configure-style
substitutions of those variables (e.g., address@hidden@').
* tests/defs: When a GNU compiler is required, override the
corresponding generic `*FLAGS' variable with the GNU-specific
variant (e.g., redefine `$CFLAGS' to take the value of
`$GNU_CFLAGS').
---
configure.ac | 28 ++++++++++++++++++++++++++++
tests/Makefile.am | 4 ++++
tests/defs | 16 ++++++++++------
tests/defs-static.in | 6 ++++++
4 files changed, 48 insertions(+), 6 deletions(-)
diff --git a/configure.ac b/configure.ac
index ea3671a..c865194 100644
--- a/configure.ac
+++ b/configure.ac
@@ -255,10 +255,12 @@ AC_DEFUN([_AM_COMPILER_CAN_FAIL], [
# Prefer generic compilers to GNU ones when possible. This will ensure
# more testsuite coverage "in the wild".
+
# FIXME: maybe we should a more comprehensive list too look for more
# FIXME: "exotic" compilers? And what about looking also for the MSVC
# FIXME: compiler on Cygwin/MinGW systems?
_AM_COMPILER_CAN_FAIL([AC_PROG_CC([cc gcc])], [CC=false])
+AS_IF([test x"$GCC" = x"yes"], [am_CC_is_GNU=yes], [am_CC_is_GNU=no])
# The list of C++ compilers here has been copied, pasted and edited
# from `lib/autoconf/c.m4:AC_PROG_CXX' in the Autoconf distribution.
@@ -267,18 +269,44 @@ _AM_COMPILER_CAN_FAIL([AC_PROG_CC([cc gcc])], [CC=false])
_AM_COMPILER_CAN_FAIL([AC_PROG_CXX(dnl
[aCC CC cl.exe FCC KCC RCC xlC_r xlC c++ cxx cc++ gpp g++])],
[CXX=false])
+AS_IF([test x"$GXX" = x"yes"], [am_CXX_is_GNU=yes], [am_CXX_is_GNU=no])
# The lists of Fortran compilers here has been copied, pasted and edited
# from file `lib/autoconf/fortran.m4' in the Autoconf distribution.
# Keep it in sync, or better again, find out a way to avoid this code
# duplication.
+
_AM_COMPILER_CAN_FAIL([AC_PROG_FC(dnl
[xlf95 f95 fort ifort ifc efc pgfortran pgf95 lf95 ftn nagfor] dnl
[xlf90 f90 pgf90 pghpf epcf90 g95 gfortran])],
[FC=false])
+# FIXME this won't work as expected until we can assume autoconf 2.69 :-(
+AS_IF([test x"$GFC" = x"yes"], [am_FC_is_GNU=yes], [am_FC_is_GNU=no])
+
_AM_COMPILER_CAN_FAIL([AC_PROG_F77(dnl
[xlf f77 frt pgf77 cf77 fort77 fl32 af77 g77 gfortran])],
[F77=false])
+AS_IF([test x"$G77" = x"yes"], [am_F77_is_GNU=yes], [am_F77_is_GNU=no])
+
+# Some tests will need the GNU compilers. Searching for them here would
+# be overkill, since our testsuite already handles their search and setup
+# pretty well. However, in case the compilers detected above at configure
+# time are not the GNU ones, we cannot use the values of CFLAGS, CXXFLAGS,
+# FCFLAGS and FFLAGS detected for them with the GNU compilers too, since
+# it's likely they won't be compatible. So we allow the user to define
+# variants of this variables for the GNU compilers separately.
+
+test $am_CC_is_GNU = yes && GNU_CFLAGS=${GNU_CFLAGS-$CFLAGS}
+AC_ARG_VAR([GNU_CFLAGS], [GNU C compiler flags])
+
+test $am_CXX_is_GNU = yes && GNU_CXXFLAGS=${GNU_CXXFLAGS-$CXXFLAGS}
+AC_ARG_VAR([GNU_CXXFLAGS], [GNU C++ compiler flags])
+
+test $am_F77_is_GNU = yes && GNU_FCFLAGS=${GNU_FCFLAGS-$FCFLAGS}
+AC_ARG_VAR([GNU_FCFLAGS], [GNU Fortran compiler flags])
+
+test $am_FC_is_GNU = yes && GNU_FFLAGS=${GNU_FFLAGS-$FFLAGS}
+AC_ARG_VAR([GNU_FFLAGS], [GNU Fortran 77 compiler flags])
# If we have been able to find at least a working compiler above, we
# know what the object and executable extensions for this platform are.
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 5696b44..d47be78 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -147,6 +147,10 @@ do_subst = sed \
-e 's|@address@hidden|$(PERL)|g' \
-e 's|@address@hidden|$(EGREP)|g' \
-e 's|@address@hidden|$(FGREP)|g' \
+ -e 's|@address@hidden|$(GNU_CFLAGS)|g' \
+ -e 's|@address@hidden|$(GNU_CXXFLAGS)|g' \
+ -e 's|@address@hidden|$(GNU_FFLAGS)|g' \
+ -e 's|@address@hidden|$(GNU_FCFLAGS)|g' \
-e 's|@address@hidden|$(TEX)|g' \
-e 's|@address@hidden|$(MODIFICATION_DELAY)|g' \
-e 's|@address@hidden|$(am_AUTOCONF)|g' \
diff --git a/tests/defs b/tests/defs
index 41ee262..1c50523 100644
--- a/tests/defs
+++ b/tests/defs
@@ -703,7 +703,8 @@ do
# has defined CC in his environment, otherwise ./configure will
# prefer gcc to other compilers.
CC=${am__tool_prefix}gcc
- export CC
+ CFLAGS=$GNU_CFLAGS
+ export CC CFLAGS
echo "$me: running $CC --version"
$CC --version || skip_all_ "GNU C compiler not available"
echo "$me: running $CC -v"
@@ -719,7 +720,8 @@ do
;;
g++)
CXX=${am__tool_prefix}g++
- export CXX
+ CXXFLAGS=$GNU_CXXFLAGS
+ export CXX CXXFLAGS
echo "$me: running $CXX --version"
$CXX --version || skip_all_ "GNU C++ compiler not available"
echo "$me: running $CXX -v"
@@ -727,26 +729,28 @@ do
;;
gfortran)
FC=${am__tool_prefix}gfortran
- export FC
+ FCFLAGS=$GNU_FCFLAGS
+ export FC FCFLAGS
echo "$me: running $FC --version"
$FC --version || skip_all_ "GNU Fortran compiler not available"
echo "$me: running $FC -v"
$FC -v || skip_all_ "botched installation for GNU Fortran compiler"
case " $required " in
*\ g77\ *) ;;
- *) F77=$FC; export F77;;
+ *) F77=$FC FFLAGS=$FCFLAGS; export F77 FFLAGS;;
esac
;;
g77)
F77=${am__tool_prefix}g77
- export F77
+ FFLAGS=$GNU_FFLAGS
+ export F77 FFLAGS
echo "$me: running $F77 --version"
$F77 --version || skip_all_ "GNU Fortran 77 compiler not available"
echo "$me: running $F77 -v"
$F77 -v || skip_all_ "botched installation for GNU Fortran 77 compiler"
case " $required " in
*\ gfortran\ *) ;;
- *) FC=$F77; export FC;;
+ *) FC=$F77 FCFLAGS=$FFLAGS; export FC FCFLAGS;;
esac
;;
icc)
diff --git a/tests/defs-static.in b/tests/defs-static.in
index 2bae9c1..e58a1a1 100644
--- a/tests/defs-static.in
+++ b/tests/defs-static.in
@@ -194,6 +194,12 @@ AUTORECONF="$AUTORECONF -B /no/such/dir"
EGREP=${AM_TESTSUITE_EGREP-'@EGREP@'}
FGREP=${AM_TESTSUITE_FGREP-'@FGREP@'}
+# Flags for the GNU compilers.
+GNU_FFLAGS=${AM_TESTSUITE_GNU_FFLAGS-${GNU_FFLAGS-'@GNU_FFLAGS@'}}
+GNU_FCFLAGS=${AM_TESTSUITE_GNU_FCFLAGS-${GNU_FCFLAGS-'@GNU_FCFLAGS@'}}
+GNU_CXXFLAGS=${AM_TESTSUITE_GNU_CXXFLAGS-${GNU_CXXFLAGS-'@GNU_CXXFLAGS@'}}
+GNU_CFLAGS=${AM_TESTSUITE_GNU_CFLAGS-${GNU_CFLAGS-'@GNU_CFLAGS@'}}
+
# No all versions of Tex support `--version', so we use a configure
# check to decide if tex is available. This decision is embodied in
# this variable.
--
1.7.7.3
- [PATCH 0/6] Merge 'experimental/compilers-for-testsuite' into master, Stefano Lattarini, 2012/01/19
- [PATCH 2/6] test defs: setup `*FLAGS' variables for GNU compilers,
Stefano Lattarini <=
- [PATCH 5/6] tests: no need to unset CFLAGS in tests requiring 'gcc' anymore, Stefano Lattarini, 2012/01/19
- [PATCH 1/6] configure: search generic compilers for use in the tests, Stefano Lattarini, 2012/01/19
- Re: [PATCH 1/6] configure: search generic compilers for use in the tests, Peter Rosin, 2012/01/20
- Re: [PATCH 1/6] configure: search generic compilers for use in the tests, Stefano Lattarini, 2012/01/20
- Re: [PATCH 1/6] configure: search generic compilers for use in the tests, Peter Rosin, 2012/01/20
- Re: [PATCH 1/6] configure: search generic compilers for use in the tests, Stefano Lattarini, 2012/01/20
- Re: [PATCH 1/6] configure: search generic compilers for use in the tests, Peter Rosin, 2012/01/23
- Re: [PATCH 1/6] configure: search generic compilers for use in the tests, Stefano Lattarini, 2012/01/23
[PATCH 3/6] test defs: substitute compilers and flags found at configure time, Stefano Lattarini, 2012/01/19
[PATCH 6/6] readme: how to run the testsuite with cross-compilers, Stefano Lattarini, 2012/01/19