From 4a6d7fa068fa1d53e0807c03bcb4c3eb9ffa567e Mon Sep 17 00:00:00 2001 From: Alexandre Duret-Lutz Date: Fri, 2 Apr 2004 07:14:24 +0000 Subject: [PATCH] Better support for Fortran 9x. * automake.in: Add "fc" and "ppfc" languages for Fortran 9x. * doc/automake.texi (Fortran 9x Support): New section. * lib/Automake/Variable.pm (%_ac_macro_for_var): Add AC_PROG_FC. * tests/compile_f90_c_cxx.test: New file. * tests/ext.test: Add AC_PROG_FC. * tests/f90only.test: New file. * tests/link_f90_only.test: New file. * tests/Makefile.am (TESTS): Add new tests. --- ChangeLog | 12 ++++++ NEWS | 5 +++ THANKS | 1 + automake.in | 48 +++++++++++++++++++++++- doc/automake.texi | 73 +++++++++++++++++++++++++++++++++++- doc/stamp-vti | 4 +- doc/version.texi | 4 +- lib/Automake/Variable.pm | 2 + tests/Makefile.am | 3 ++ tests/Makefile.in | 3 ++ tests/compile_f90_c_cxx.test | 54 ++++++++++++++++++++++++++ tests/ext.test | 1 + tests/f90only.test | 54 ++++++++++++++++++++++++++ tests/link_f90_only.test | 51 +++++++++++++++++++++++++ 14 files changed, 307 insertions(+), 8 deletions(-) create mode 100755 tests/compile_f90_c_cxx.test create mode 100755 tests/f90only.test create mode 100755 tests/link_f90_only.test diff --git a/ChangeLog b/ChangeLog index 14518799..98271fe8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2004-04-02 Mike Nolta + + Better support for Fortran 9x. + * automake.in: Add "fc" and "ppfc" languages for Fortran 9x. + * doc/automake.texi (Fortran 9x Support): New section. + * lib/Automake/Variable.pm (%_ac_macro_for_var): Add AC_PROG_FC. + * tests/compile_f90_c_cxx.test: New file. + * tests/ext.test: Add AC_PROG_FC. + * tests/f90only.test: New file. + * tests/link_f90_only.test: New file. + * tests/Makefile.am (TESTS): Add new tests. + 2004-04-01 Paul Eggert * lib/install-sh: If "mv -f" works, use it, and fall back to diff --git a/NEWS b/NEWS index 7e9156c1..c7021ccc 100644 --- a/NEWS +++ b/NEWS @@ -1,5 +1,10 @@ New in 1.8a: +* Better support for Fortran 90/95 with the new "fc" and "ppfc" languages. + Works the same as the old Fortran 77 implementation; just replace F77 + with FC everywhere (exception: FFLAGS becomes FCFLAGS). Requires a + version of autoconf which provides AC_PROG_FC (>=2.59). + * Libtool tags are used with libtool versions that support them. (I.e., with Libtool 1.5 or greater.) diff --git a/THANKS b/THANKS index 09cc4d52..e20d50b1 100644 --- a/THANKS +++ b/THANKS @@ -157,6 +157,7 @@ Merijn de Jonge M.de.Jonge@cwi.nl Michael Brantley Michael-Brantley@deshaw.com Michel de Ruiter mdruiter@cs.vu.nl Mike Castle dalgoda@ix.netcom.com +Mike Nolta mrnolta@princeton.edu Miles Bader miles@ccs.mt.nec.co.jp Miloslav Trmac trmac@popelka.ms.mff.cuni.cz Miodrag Vallat miodrag@ifrance.com diff --git a/automake.in b/automake.in index b27d3b1e..c88f7dd3 100755 --- a/automake.in +++ b/automake.in @@ -805,7 +805,39 @@ register_language ('name' => 'f77', 'lder' => 'F77LD', 'ld' => '$(F77)', 'pure' => 1, - 'extensions' => ['.f', '.for', '.f90']); + 'extensions' => ['.f', '.for']); + +# Fortran +register_language ('name' => 'fc', + 'Name' => 'Fortran', + 'linker' => 'FCLINK', + 'link' => '$(FCLD) $(AM_FCFLAGS) $(FCFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@', + 'flags' => ['FCFLAGS'], + 'compile' => '$(FC) $(AM_FCFLAGS) $(FCFLAGS)', + 'compiler' => 'FCCOMPILE', + 'compile_flag' => '-c', + 'output_flag' => '-o', + 'lder' => 'FCLD', + 'ld' => '$(FC)', + 'pure' => 1, + 'extensions' => ['.f90', '.f95']); + +# Preprocessed Fortran +register_language ('name' => 'ppfc', + 'Name' => 'Preprocessed Fortran', + 'config_vars' => ['FC'], + 'linker' => 'FCLINK', + 'link' => '$(FCLD) $(AM_FFLAGS) $(FCFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@', + 'lder' => 'FCLD', + 'ld' => '$(FC)', + 'flags' => ['FCFLAGS', 'CPPFLAGS'], + 'compiler' => 'PPFCCOMPILE', + 'compile' => '$(FC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_FCFLAGS) $(FCFLAGS)', + 'compile_flag' => '-c', + 'output_flag' => '-o', + 'libtool_tag' => 'FC', + 'pure' => 1, + 'extensions' => ['.F90','.F95']); # Preprocessed Fortran 77 # @@ -5004,6 +5036,18 @@ sub lang_f77_rewrite return LANG_PROCESS; } +# Rewrite a single Fortran file. +sub lang_fc_rewrite +{ + return LANG_PROCESS; +} + +# Rewrite a single preprocessed Fortran file. +sub lang_ppfc_rewrite +{ + return LANG_PROCESS; +} + # Rewrite a single preprocessed Fortran 77 file. sub lang_ppf77_rewrite { @@ -5196,7 +5240,7 @@ sub resolve_linker { my (%linkers) = @_; - foreach my $l (qw(GCJLINK CXXLINK F77LINK OBJCLINK)) + foreach my $l (qw(GCJLINK CXXLINK F77LINK FCLINK OBJCLINK)) { return $l if defined $linkers{$l}; } diff --git a/doc/automake.texi b/doc/automake.texi index fb96fc1f..254c3913 100644 --- a/doc/automake.texi +++ b/doc/automake.texi @@ -167,6 +167,7 @@ Building Programs and Libraries * C++ Support:: Compiling C++ sources * Assembly Support:: Compiling assembly sources * Fortran 77 Support:: Compiling Fortran 77 sources +* Fortran 9x Support:: Compiling Fortran 9x sources * Java Support:: Compiling Java sources * Support for Other Languages:: Compiling other languages * ANSI:: Automatic de-ANSI-fication @@ -202,6 +203,10 @@ Mixing Fortran 77 With C and C++ * How the Linker is Chosen:: Automatic linker selection +Fortran 9x Support + +* Compiling Fortran 9x Files:: Compiling Fortran 9x sources + Other Derived Objects * Scripts:: Executable scripts @@ -1393,6 +1398,12 @@ languages that include Fortran 77 (@pxref{Mixing Fortran 77 With C and C++}). @xref{Macros, , Autoconf macros supplied with Automake}. @cvindex AC_F77_LIBRARY_LDFLAGS +@item AC_PROG_FC +This is required if any Fortran 90/95 source is included. This macro is +distributed with Autoconf version 2.58 and later. @xref{Particular +Programs, , Particular Program Checks, autoconf, The Autoconf Manual}. +@cvindex AC_PROG_FC + @item AC_PROG_LIBTOOL Automake will turn on processing for @code{libtool} (@pxref{Top, , Introduction, libtool, The Libtool Manual}). @@ -2371,6 +2382,7 @@ to build programs and libraries. * C++ Support:: Compiling C++ sources * Assembly Support:: Compiling assembly sources * Fortran 77 Support:: Compiling Fortran 77 sources +* Fortran 9x Support:: Compiling Fortran 9x sources * Java Support:: Compiling Java sources * Support for Other Languages:: Compiling other languages * ANSI:: Automatic de-ANSI-fication @@ -3910,6 +3922,62 @@ included by the C++ linker, then they must be manually added to an +---------+---------+---------+ @end example +@node Fortran 9x Support +@comment node-name, next, previous, up +@section Fortran 9x Support + +@cindex Fortran 9x support +@cindex Support for Fortran 9x + +Automake includes full support for Fortran 9x. + +Any package including Fortran 9x code must define the output variable +@samp{FC} in @file{configure.ac}; the simplest way to do this is to use +the @code{AC_PROG_FC} macro (@pxref{Particular Programs, , Particular +Program Checks, autoconf, The Autoconf Manual}). + +A few additional variables are defined when a Fortran 9x source file is +seen: + +@vtable @code + +@item FC +The name of the Fortran 9x compiler. + +@item FCFLAGS +Any flags to pass to the Fortran 9x compiler. + +@item AM_FCFLAGS +The maintainer's variant of @code{FCFLAGS}. + +@item FCCOMPILE +The command used to actually compile a Fortran 9x source file. The file +name is appended to form the complete command line. + +@item FCLINK +The command used to actually link a pure Fortran 9x program or shared +library. + +@end vtable + +@menu +* Compiling Fortran 9x Files:: Compiling Fortran 9x sources +@end menu + +@node Compiling Fortran 9x Files +@comment node-name, next, previous, up +@subsection Compiling Fortran 9x Files + +@file{N.o} is made automatically from @file{N.f90} or @file{N.f95} +by running the Fortran 9x compiler. The precise command used +is as follows: + +@table @file + +@item .f9x +@code{$(FC) -c $(AM_FCFLAGS) $(FCFLAGS)} + +@end table @node Java Support @comment node-name, next, previous, up @@ -3954,8 +4022,9 @@ the @code{_LDFLAGS} variable for the program. @section Support for Other Languages Automake currently only includes full support for C, C++ (@pxref{C++ -Support}), Fortran 77 (@pxref{Fortran 77 Support}), and Java -(@pxref{Java Support}). There is only rudimentary support for other +Support}), Fortran 77 (@pxref{Fortran 77 Support}), +Fortran 9x (@pxref{Fortran 9x Support}), +and Java (@pxref{Java Support}). There is only rudimentary support for other languages, support for which will be improved based on user demand. Some limited support for adding your own languages is available via the diff --git a/doc/stamp-vti b/doc/stamp-vti index ae24e54d..a6946560 100644 --- a/doc/stamp-vti +++ b/doc/stamp-vti @@ -1,4 +1,4 @@ -@set UPDATED 16 February 2004 -@set UPDATED-MONTH February 2004 +@set UPDATED 2 April 2004 +@set UPDATED-MONTH April 2004 @set EDITION 1.8a @set VERSION 1.8a diff --git a/doc/version.texi b/doc/version.texi index ae24e54d..a6946560 100644 --- a/doc/version.texi +++ b/doc/version.texi @@ -1,4 +1,4 @@ -@set UPDATED 16 February 2004 -@set UPDATED-MONTH February 2004 +@set UPDATED 2 April 2004 +@set UPDATED-MONTH April 2004 @set EDITION 1.8a @set VERSION 1.8a diff --git a/lib/Automake/Variable.pm b/lib/Automake/Variable.pm index 332c5b44..0bb14434 100644 --- a/lib/Automake/Variable.pm +++ b/lib/Automake/Variable.pm @@ -175,6 +175,8 @@ my %_ac_macro_for_var = CXXFLAGS => 'AC_PROG_CXX', F77 => 'AC_PROG_F77', F77FLAGS => 'AC_PROG_F77', + FC => 'AC_PROG_FC', + FCFLAGS => 'AC_PROG_FC', RANLIB => 'AC_PROG_RANLIB', YACC => 'AC_PROG_YACC', ); diff --git a/tests/Makefile.am b/tests/Makefile.am index 67adfad7..6d4e122b 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -87,6 +87,7 @@ comment4.test \ comment5.test \ comment6.test \ comment7.test \ +compile_f90_c_cxx.test \ compile_f_c_cxx.test \ cond.test \ cond2.test \ @@ -211,6 +212,7 @@ extra4.test \ extra5.test \ extra6.test \ extra7.test \ +f90only.test \ flibs.test \ fnoc.test \ fo.test \ @@ -287,6 +289,7 @@ libtool8.test \ license.test \ link_c_cxx.test \ link_dist.test \ +link_f90_only.test \ link_fc.test \ link_fccxx.test \ link_fcxx.test \ diff --git a/tests/Makefile.in b/tests/Makefile.in index 5ae0e5e8..c67430ca 100644 --- a/tests/Makefile.in +++ b/tests/Makefile.in @@ -202,6 +202,7 @@ comment4.test \ comment5.test \ comment6.test \ comment7.test \ +compile_f90_c_cxx.test \ compile_f_c_cxx.test \ cond.test \ cond2.test \ @@ -326,6 +327,7 @@ extra4.test \ extra5.test \ extra6.test \ extra7.test \ +f90only.test \ flibs.test \ fnoc.test \ fo.test \ @@ -402,6 +404,7 @@ libtool8.test \ license.test \ link_c_cxx.test \ link_dist.test \ +link_f90_only.test \ link_fc.test \ link_fccxx.test \ link_fcxx.test \ diff --git a/tests/compile_f90_c_cxx.test b/tests/compile_f90_c_cxx.test new file mode 100755 index 00000000..20809ad2 --- /dev/null +++ b/tests/compile_f90_c_cxx.test @@ -0,0 +1,54 @@ +#! /bin/sh +# Copyright (C) 1998, 1999, 2001, 2002 Free Software Foundation, Inc. +# +# This file is part of GNU Automake. +# +# GNU Automake is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. +# +# GNU Automake is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Automake; see the file COPYING. If not, write to +# the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +# Boston, MA 02111-1307, USA. + +# Test to make sure rules to invoke all compilers are selected with +# mixed source objects. +# (copied from compile_f_c_cxx.test) Mike Nolta + +. ./defs || exit 1 + +cat >> configure.in << 'END' +AC_PROG_CC +AC_PROG_CXX +AC_PROG_FC +AC_FC_LIBRARY_LDFLAGS +END + +cat > Makefile.am << 'END' +bin_PROGRAMS = foo +foo_SOURCES = foo.f90 bar.c baz.cc +foo_LDADD = @FLIBS@ +END + +: > foo.f90 +: > bar.c +: > baz.cc + +$ACLOCAL || exit 1 +$AUTOMAKE || exit 1 + + +# Look for the macros at the beginning of rules. Be careful, as there +# are literal tabs at the beginning of the search strings. +grep ' \$(COMPILE)' Makefile.in || exit 1 +grep ' \$(CXXCOMPILE)' Makefile.in || exit 1 +grep ' \$(FCCOMPILE)' Makefile.in || exit 1 + +exit 0 diff --git a/tests/ext.test b/tests/ext.test index a34b0b04..42795756 100755 --- a/tests/ext.test +++ b/tests/ext.test @@ -24,6 +24,7 @@ cat >> configure.in << 'END' AC_PROG_F77 +AC_PROG_FC _AM_DEPENDENCIES(OBJC) AC_SUBST(OBJC) END diff --git a/tests/f90only.test b/tests/f90only.test new file mode 100755 index 00000000..9b59f22a --- /dev/null +++ b/tests/f90only.test @@ -0,0 +1,54 @@ +#! /bin/sh +# Copyright (C) 1998, 1999, 2001, 2002 Free Software Foundation, Inc. +# +# This file is part of GNU Automake. +# +# GNU Automake is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. +# +# GNU Automake is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Automake; see the file COPYING. If not, write to +# the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +# Boston, MA 02111-1307, USA. + +# Make sure programs with only Fortran 90 source are handled properly. +# (copied from fonly.test) Mike Nolta + +. ./defs || exit 1 + +cat >> configure.in << 'END' +AC_PROG_FC +END + +# Tue Aug 11 09:50:48 1998 Matthew D. Langston +# +# This test currently fails with automake v. 1.3 since automake assumes +# that elements of `bin_PROGRAMS' (e.g. zardoz) without a corresponding +# `_SOURCES' (e.g. zardoz_SOURCES) should be compiled from `zardoz.c' +# whether or not `zardoz.c' actually exists. For example, even if the +# file `zardoz.c' doesn't exist but the file `zardoz.f' does exist, this +# tests would still fail. +# +# Therefore, for now I have put in the line `zardoz_SOURCES = zardoz.f' +# (see below) so that automake's top-level `make check' won't fail, but +# this line should be removed once automake handles this situation +# correctly. + +cat > Makefile.am <<'END' +bin_PROGRAMS = zardoz +zardoz_SOURCES = zardoz.f90 +END + +: > zardoz.f90 + +$ACLOCAL || exit 1 +$AUTOMAKE || exit 1 + +grep 'zardoz.f90' Makefile.in diff --git a/tests/link_f90_only.test b/tests/link_f90_only.test new file mode 100755 index 00000000..8d27835f --- /dev/null +++ b/tests/link_f90_only.test @@ -0,0 +1,51 @@ +#! /bin/sh +# Copyright (C) 1998, 1999, 2001, 2002 Free Software Foundation, Inc. +# +# This file is part of GNU Automake. +# +# GNU Automake is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. +# +# GNU Automake is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Automake; see the file COPYING. If not, write to +# the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +# Boston, MA 02111-1307, USA. + +# Test to make sure the Fortran 90 linker is used when appropriate. +# (copied from link_f_only.test) Mike Nolta + +. ./defs || exit 1 + +cat >> configure.in << 'END' +AC_PROG_FC +END + +cat > Makefile.am << 'END' +bin_PROGRAMS = lavalamp +lavalamp_SOURCES = lamp.f90 +END + +: > lamp.f90 + +$ACLOCAL || exit 1 +$AUTOMAKE || exit 1 + + +# We should only see the Fortran linker in the rules of `Makefile.in'. + +# Look for this macro not at the beginning of any line; that will have +# to be good enough for now. +grep '.\$(FCLINK)' Makefile.in || exit 1 + +# We should not see these patterns: +grep '.\$(CXXLINK)' Makefile.in && exit 1 +grep '.\$(LINK)' Makefile.in && exit 1 + +exit 0 -- 2.43.5