This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
[libgfortran,patch] New autoconf test
- From: "François-Xavier Coudert" <fxcoudert at gmail dot com>
- To: bonzini at gnu dot org, dj at redhat dot com, neroden at gcc dot gnu dot org, aoliva at redhat dot com
- Cc: gcc-patches <gcc-patches at gcc dot gnu dot org>, GFortran <fortran at gcc dot gnu dot org>
- Date: Tue, 9 Jan 2007 08:54:53 +0100
- Subject: [libgfortran,patch] New autoconf test
- Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:cc:mime-version:content-type:content-transfer-encoding:content-disposition; b=g4GTvoPMW6H6hXF4YKJRd/KfzT3cilyzxFYzmWo1WyBq1V105q8cFJcJfA+haI0q+OpOlIxVxTNoaDcQJ9w8POjxo/BkB4ZawqL+tWNrKY8UhRUkjTZdAKZHBYQqAm7njcTup7+3QXAEJEAOZY7aRTvGhWJKNU0TSJShpcnKEwo=
Hi all,
I'd like to have the opinion of a autoconf or build machinery expert
on this patch. I'm trying to add a test in libgfortran/configure.ac to
check that the gfortran compiler that was just built (before the
target libraries) is working, and if not, issue a clear error message.
The following patch appears to do just this on my i686-linux setup,
but
a) is it the right way of doing this?
b) would it work in a cross-compiler setup?
Index: libgfortran/acinclude.m4
===================================================================
--- libgfortran/acinclude.m4 (revision 120585)
+++ libgfortran/acinclude.m4 (working copy)
@@ -1,6 +1,24 @@
m4_include(../config/acx.m4)
m4_include(../config/no-executables.m4)
+dnl Check that we have a working GNU Fortran compiler
+AC_DEFUN([LIBGFOR_WORKING_GFORTRAN], [
+ AC_MSG_CHECKING([whether the GNU Fortran compiler is working])
+ cat > conftest.f90 <<EOF
+ program foo
+ real, parameter :: bar = sin(12.34)
+ end program foo
+EOF
+ if ( $FC conftest.f90 -c -o conftest.o ); then
+ echo "yes"
+ rm conftest.f90 conftest.o
+ else
+ AC_MSG_ERROR(GNU Fortran is not working; error message is printed above)
+ rm conftest.f90
+ fi
+])
+
+
dnl Check:
dnl * If we have gettimeofday;
dnl * If we have struct timezone for use in calling it;
Index: libgfortran/configure.ac
===================================================================
--- libgfortran/configure.ac (revision 120585)
+++ libgfortran/configure.ac (working copy)
@@ -143,6 +143,10 @@
FC="$GFORTRAN"
AC_PROG_FC(gfortran)
+# We need a working compiler at that point, otherwise give a clear
+# error message and bail out.
+LIBGFOR_WORKING_GFORTRAN
+
# extra LD Flags which are required for targets
case "${host}" in
*-darwin*)
For gfortran developers: the reason why we need to do that is that
people sometime get an unusable f951 (liked with a wrong mpfr library,
or that doesn't work because LD_LIBRARY_PATH is not set correctly) and
in that case, they currently don't have a clear error message but a
rather cryptic error while compiling the library. See PR 26893
(especially the last comments).
Thanks,
FX