[ http://lists.gnu.org/archive/html/automake-patches/2006-08/msg00073.html http://lists.gnu.org/archive/html/automake-patches/2006-09/msg00013.html ]
Hello again, and sorry for the delay, For now I've backed down the previous plans a bit. The FCFLAGS_* are most important for the extensions .f90 and .f95; only few Fortran 90 compilers have problems with .f when $(FCFLAGS_f) is omitted (the only ones I've found so far were the AIX compilers when invoked as f90/f95, but not when invoked as xlf90/xlf95; Autoconf has since been changed to prefer the latter). To have something that's more easily acceptable, I've for now postponed the (more invasive) change that would cause Automake to use FC for *.f after seeing AC_FC_SRCEXT([f]), and only changed it to honor FCFLAGS_{f90,f95} for FC. It may be added sometime in the future, there is no requirement to do it at the same time as the patch below. I've tested some version of the proposed Fortran changes (including the other proposed patches) on: GNU/Linux g77/gfortran (GCC 3.3.5, 4.1.2) ifort (Intel 8.1, 9.0), pgf77/pgf90/pgf95 (PGI 5.2, 6.0, 6.1) pathf90/pathf95 (PathScale 2.3) f77/f90/f95 (Sun Fortran X.X) Solaris 8 f77/f90/f95 (Sun Fortran 8.0) AIX xlf90/xlf95 (AIX XL 9.1) With help of the testsuite, I've found some issues in Libtool and Autoconf, and started fixing them (for example mixing GNU and non-GNU compilers has turned up some glitches in Libtool; IME in real-world usage, users are less likely to mix). But it will be a while until fixed versions are propagated, so fort4.test and fort5.test are disarmed a bit at the moment with required='g77 gfortran' Note that AC_FC_SRCEXT has been added to autoconf/lib/autom4te.cfg (right about before 2.60 was released; phew). OK to apply? Cheers, Ralf 2006-10-14 Ralf Wildenhues <[EMAIL PROTECTED]> * lib/am/depend2.am (%SOURCEFLAG%): New substitution, goes right before the expanded source file name. * automake.in (%sourceflags): New global: per-extension flag to denote that the next compiler argument is the source file. (scan_autoconf_traces): Trace AC_FC_SRCEXT; initialize %sourceflags accordingly. (handle_single_transform): Store source file extension in... (%lang_specific_files): ...this and... (handle_languages): ...adjust here. Pass flag in SOURCEFLAG. * doc/automake.texi (Optional): Add AC_FC_SRCEXT. (Fortran 9x Support): Update. * tests/fort2.test: New test. * tests/Makefile.am: Adjust. * NEWS: Update. Suggested by Steven G. Johnson <[EMAIL PROTECTED]>. Index: NEWS =================================================================== RCS file: /cvs/automake/automake/NEWS,v retrieving revision 1.315 diff -u -r1.315 NEWS --- NEWS 5 Sep 2006 18:58:16 -0000 1.315 +++ NEWS 14 Oct 2006 08:47:22 -0000 @@ -1,5 +1,10 @@ New in 1.9c: +* Languages changes: + + - For files with extension .f90 or .f95, the flag $(FCFLAGS_f9x) + computed by AC_FC_SRCEXT is now honored in compile rules. + * Miscellaneous changes: - The script `install-sh' needs to have executable permissions for Index: automake.in =================================================================== RCS file: /cvs/automake/automake/automake.in,v retrieving revision 1.1632 diff -u -r1.1632 automake.in --- automake.in 10 Oct 2006 21:34:11 -0000 1.1632 +++ automake.in 14 Oct 2006 08:29:09 -0000 @@ -415,6 +415,9 @@ # Maps each linker variable onto a language object. my %link_languages = (); +# maps extensions to needed source flags. +my %sourceflags = (); + # List of targets we must always output. # FIXME: Complete, and remove falsely required targets. my %required_targets = @@ -1280,6 +1283,7 @@ DEPBASE => $depbase, BASE => '$*', SOURCE => '$<', + SOURCEFLAG => $sourceflags{$ext} || '', OBJ => '$@', OBJOBJ => '$@', LTOBJ => '$@', @@ -1295,7 +1299,7 @@ my %seen_files = (); foreach my $file (@{$lang_specific_files{$lang->name}}) { - my ($derived, $source, $obj, $myext, %file_transform) = @$file; + my ($derived, $source, $obj, $myext, $srcext, %file_transform) = @$file; # We might see a given object twice, for instance if it is # used under different conditions. @@ -1416,6 +1420,7 @@ DEPBASE => $depbase_, BASE => $obj_, SOURCE => $source_, + SOURCEFLAG => $sourceflags{$srcext} || '', OBJ => "$obj_$myext", OBJOBJ => "$obj_.obj", LTOBJ => "$obj_.lo", @@ -1439,6 +1444,7 @@ DEPBASE => $depbase, BASE => $obj, SOURCE => $source, + SOURCEFLAG => $sourceflags{$srcext} || '', # Use $myext and not `.o' here, in case # we are actually building a new source # file -- e.g. via yacc. @@ -1777,7 +1783,8 @@ # Only use $this_obj_ext in the derived # source case because in the other case we # *don't* want $(OBJEXT) to appear here. - ($derived_source ? $this_obj_ext : '.o')); + ($derived_source ? $this_obj_ext : '.o'), + $extension); # If we renamed the object then we want to use the # per-executable flag name. But if this is simply a @@ -4777,6 +4784,7 @@ AC_CONFIG_HEADERS => 1, AC_CONFIG_LIBOBJ_DIR => 1, AC_CONFIG_LINKS => 1, + AC_FC_SRCEXT => 1, AC_INIT => 0, AC_LIBSOURCE => 1, AC_REQUIRE_AUX_FILE => 1, @@ -4888,6 +4896,12 @@ push @config_links, $spec; } } + elsif ($macro eq 'AC_FC_SRCEXT') + { + my $suffix = $args[1]; + $sourceflags{'.' . $suffix} = '$(FCFLAGS_' . $suffix . ') ' + if ($suffix eq 'f90' || $suffix eq 'f95'); + } elsif ($macro eq 'AC_INIT') { if (defined $args[2]) Index: doc/automake.texi =================================================================== RCS file: /cvs/automake/automake/doc/automake.texi,v retrieving revision 1.150 diff -u -r1.150 automake.texi --- doc/automake.texi 28 Aug 2006 16:04:24 -0000 1.150 +++ doc/automake.texi 14 Oct 2006 08:29:15 -0000 @@ -2887,6 +2887,11 @@ languages that include Fortran 77 (@pxref{Mixing Fortran 77 With C and C++}). @xref{Macros, , Autoconf macros supplied with Automake}. [EMAIL PROTECTED] AC_FC_SRCEXT +Automake will add the flags computed by @code{AC_FC_SRCEXT} to compilation +of files with the respective source extension (@pxref{Fortran Compiler, , +Fortran Compiler Characteristics, autoconf, The Autoconf Manual}). + @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 @@ -6405,7 +6410,7 @@ @cindex Fortran 9x support @cindex Support for Fortran 9x -Automake includes full support for Fortran 9x. +Automake includes support for Fortran 9x. Any package including Fortran 9x code must define the output variable @code{FC} in @file{configure.ac}; the simplest way to do this is to use @@ -6450,8 +6455,11 @@ @table @file [EMAIL PROTECTED] .f9x [EMAIL PROTECTED](FC) -c $(AM_FCFLAGS) $(FCFLAGS)} [EMAIL PROTECTED] .f90 [EMAIL PROTECTED](FC) $(AM_FCFLAGS) $(FCFLAGS) -c $(FCFLAGS_f90) $<} + [EMAIL PROTECTED] .f95 [EMAIL PROTECTED](FC) $(AM_FCFLAGS) $(FCFLAGS) -c $(FCFLAGS_f95) $<} @end table Index: lib/am/depend2.am =================================================================== RCS file: /cvs/automake/automake/lib/am/depend2.am,v retrieving revision 1.61 diff -u -r1.61 depend2.am --- lib/am/depend2.am 31 Aug 2006 04:49:24 -0000 1.61 +++ lib/am/depend2.am 14 Oct 2006 08:29:15 -0000 @@ -65,10 +65,10 @@ if %FASTDEP% ## In fast-dep mode, we can always use -o. ## For non-suffix rules, we must emulate a VPATH search on %SOURCE%. -?!GENERIC? %COMPILE% -MT %OBJ% -MD -MP -MF %DEPBASE%.Tpo %-c% -o %OBJ% `test -f '%SOURCE%' || echo '$(srcdir)/'`%SOURCE% -?GENERIC??!SUBDIROBJ? %COMPILE% -MT %OBJ% -MD -MP -MF %DEPBASE%.Tpo %-c% -o %OBJ% %SOURCE% +?!GENERIC? %COMPILE% -MT %OBJ% -MD -MP -MF %DEPBASE%.Tpo %-c% -o %OBJ% %SOURCEFLAG%`test -f '%SOURCE%' || echo '$(srcdir)/'`%SOURCE% +?GENERIC??!SUBDIROBJ? %COMPILE% -MT %OBJ% -MD -MP -MF %DEPBASE%.Tpo %-c% -o %OBJ% %SOURCEFLAG%%SOURCE% ?GENERIC??SUBDIROBJ? depbase=`echo %OBJ% | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ -?GENERIC??SUBDIROBJ? %COMPILE% -MT %OBJ% -MD -MP -MF %DEPBASE%.Tpo %-c% -o %OBJ% %SOURCE% &&\ +?GENERIC??SUBDIROBJ? %COMPILE% -MT %OBJ% -MD -MP -MF %DEPBASE%.Tpo %-c% -o %OBJ% %SOURCEFLAG%%SOURCE% &&\ mv -f %DEPBASE%.Tpo %DEPBASE%.Po else !%FASTDEP% if %AMDEP% @@ -76,12 +76,12 @@ DEPDIR=$(DEPDIR) $(%FPFX%DEPMODE) $(depcomp) @AMDEPBACKSLASH@ endif %AMDEP% if %?GENERIC% -?-o? %COMPILE% %-c% %-o% %OBJ% %SOURCE% -?!-o? %COMPILE% %-c% %SOURCE% +?-o? %COMPILE% %-c% %-o% %OBJ% %SOURCEFLAG%%SOURCE% +?!-o? %COMPILE% %-c% %SOURCEFLAG%%SOURCE% else !%?GENERIC% ## For non-suffix rules, we must emulate a VPATH search on %SOURCE%. -?-o? %COMPILE% %-c% %-o% %OBJ% `test -f '%SOURCE%' || echo '$(srcdir)/'`%SOURCE% -?!-o? %COMPILE% %-c% `test -f '%SOURCE%' || echo '$(srcdir)/'`%SOURCE% +?-o? %COMPILE% %-c% %-o% %OBJ% %SOURCEFLAG%`test -f '%SOURCE%' || echo '$(srcdir)/'`%SOURCE% +?!-o? %COMPILE% %-c% %SOURCEFLAG%`test -f '%SOURCE%' || echo '$(srcdir)/'`%SOURCE% endif !%?GENERIC% endif !%FASTDEP% @@ -90,10 +90,10 @@ if %FASTDEP% ## In fast-dep mode, we can always use -o. ## For non-suffix rules, we must emulate a VPATH search on %SOURCE%. -?!GENERIC? %COMPILE% -MT %OBJOBJ% -MD -MP -MF %DEPBASE%.Tpo %-c% -o %OBJOBJ% `if test -f '%SOURCE%'; then $(CYGPATH_W) '%SOURCE%'; else $(CYGPATH_W) '$(srcdir)/%SOURCE%'; fi` -?GENERIC??!SUBDIROBJ? %COMPILE% -MT %OBJOBJ% -MD -MP -MF %DEPBASE%.Tpo %-c% -o %OBJOBJ% `$(CYGPATH_W) '%SOURCE%'` +?!GENERIC? %COMPILE% -MT %OBJOBJ% -MD -MP -MF %DEPBASE%.Tpo %-c% -o %OBJOBJ% %SOURCEFLAG%`if test -f '%SOURCE%'; then $(CYGPATH_W) '%SOURCE%'; else $(CYGPATH_W) '$(srcdir)/%SOURCE%'; fi` +?GENERIC??!SUBDIROBJ? %COMPILE% -MT %OBJOBJ% -MD -MP -MF %DEPBASE%.Tpo %-c% -o %OBJOBJ% %SOURCEFLAG%`$(CYGPATH_W) '%SOURCE%'` ?GENERIC??SUBDIROBJ? depbase=`echo %OBJ% | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ -?GENERIC??SUBDIROBJ? %COMPILE% -MT %OBJOBJ% -MD -MP -MF %DEPBASE%.Tpo %-c% -o %OBJOBJ% `$(CYGPATH_W) '%SOURCE%'` &&\ +?GENERIC??SUBDIROBJ? %COMPILE% -MT %OBJOBJ% -MD -MP -MF %DEPBASE%.Tpo %-c% -o %OBJOBJ% %SOURCEFLAG%`$(CYGPATH_W) '%SOURCE%'` &&\ mv -f %DEPBASE%.Tpo %DEPBASE%.Po else !%FASTDEP% if %AMDEP% @@ -101,12 +101,12 @@ DEPDIR=$(DEPDIR) $(%FPFX%DEPMODE) $(depcomp) @AMDEPBACKSLASH@ endif %AMDEP% if %?GENERIC% -?-o? %COMPILE% %-c% %-o% %OBJOBJ% `$(CYGPATH_W) '%SOURCE%'` -?!-o? %COMPILE% %-c% `$(CYGPATH_W) '%SOURCE%'` +?-o? %COMPILE% %-c% %-o% %OBJOBJ% %SOURCEFLAG%`$(CYGPATH_W) '%SOURCE%'` +?!-o? %COMPILE% %-c% `$(CYGPATH_W) %SOURCEFLAG%'%SOURCE%'` else !%?GENERIC% ## For non-suffix rules, we must emulate a VPATH search on %SOURCE%. -?-o? %COMPILE% %-c% %-o% %OBJOBJ% `if test -f '%SOURCE%'; then $(CYGPATH_W) '%SOURCE%'; else $(CYGPATH_W) '$(srcdir)/%SOURCE%'; fi` -?!-o? %COMPILE% %-c% `if test -f '%SOURCE%'; then $(CYGPATH_W) '%SOURCE%'; else $(CYGPATH_W) '$(srcdir)/%SOURCE%'; fi` +?-o? %COMPILE% %-c% %-o% %OBJOBJ% %SOURCEFLAG%`if test -f '%SOURCE%'; then $(CYGPATH_W) '%SOURCE%'; else $(CYGPATH_W) '$(srcdir)/%SOURCE%'; fi` +?!-o? %COMPILE% %-c% %SOURCEFLAG%`if test -f '%SOURCE%'; then $(CYGPATH_W) '%SOURCE%'; else $(CYGPATH_W) '$(srcdir)/%SOURCE%'; fi` endif !%?GENERIC% endif !%FASTDEP% endif %?NONLIBTOOL% @@ -117,10 +117,10 @@ if %FASTDEP% ## In fast-dep mode, we can always use -o. ## For non-suffix rules, we must emulate a VPATH search on %SOURCE%. -?!GENERIC? %LTCOMPILE% -MT %LTOBJ% -MD -MP -MF %DEPBASE%.Tpo %-c% -o %LTOBJ% `test -f '%SOURCE%' || echo '$(srcdir)/'`%SOURCE% -?GENERIC??!SUBDIROBJ? %LTCOMPILE% -MT %LTOBJ% -MD -MP -MF %DEPBASE%.Tpo %-c% -o %LTOBJ% %SOURCE% +?!GENERIC? %LTCOMPILE% -MT %LTOBJ% -MD -MP -MF %DEPBASE%.Tpo %-c% -o %LTOBJ% %SOURCEFLAG%`test -f '%SOURCE%' || echo '$(srcdir)/'`%SOURCE% +?GENERIC??!SUBDIROBJ? %LTCOMPILE% -MT %LTOBJ% -MD -MP -MF %DEPBASE%.Tpo %-c% -o %LTOBJ% %SOURCEFLAG%%SOURCE% ?GENERIC??SUBDIROBJ? depbase=`echo %OBJ% | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ -?GENERIC??SUBDIROBJ? %LTCOMPILE% -MT %LTOBJ% -MD -MP -MF %DEPBASE%.Tpo %-c% -o %LTOBJ% %SOURCE% &&\ +?GENERIC??SUBDIROBJ? %LTCOMPILE% -MT %LTOBJ% -MD -MP -MF %DEPBASE%.Tpo %-c% -o %LTOBJ% %SOURCEFLAG%%SOURCE% &&\ mv -f %DEPBASE%.Tpo %DEPBASE%.Plo else !%FASTDEP% if %AMDEP% @@ -128,8 +128,8 @@ DEPDIR=$(DEPDIR) $(%FPFX%DEPMODE) $(depcomp) @AMDEPBACKSLASH@ endif %AMDEP% ## We can always use `-o' with Libtool. -?GENERIC? %LTCOMPILE% %-c% -o %LTOBJ% %SOURCE% +?GENERIC? %LTCOMPILE% %-c% -o %LTOBJ% %SOURCEFLAG%%SOURCE% ## For non-suffix rules, we must emulate a VPATH search on %SOURCE%. -?!GENERIC? %LTCOMPILE% %-c% -o %LTOBJ% `test -f '%SOURCE%' || echo '$(srcdir)/'`%SOURCE% +?!GENERIC? %LTCOMPILE% %-c% -o %LTOBJ% %SOURCEFLAG%`test -f '%SOURCE%' || echo '$(srcdir)/'`%SOURCE% endif !%FASTDEP% endif %?LIBTOOL% Index: tests/Makefile.am =================================================================== RCS file: /cvs/automake/automake/tests/Makefile.am,v retrieving revision 1.609 diff -u -r1.609 Makefile.am --- tests/Makefile.am 30 Aug 2006 20:35:56 -0000 1.609 +++ tests/Makefile.am 14 Oct 2006 08:29:15 -0000 @@ -245,6 +245,7 @@ fnoc.test \ fo.test \ fort1.test \ +fort2.test \ fonly.test \ fortdep.test \ fpinst2.test \ --- /dev/null 2006-10-09 01:10:44.864355000 +0200 +++ tests/fort2.test 2006-10-14 10:28:48.000000000 +0200 @@ -0,0 +1,58 @@ +#! /bin/sh +# Copyright (C) 2006 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., 51 Franklin Street, Fifth Floor, +# Boston, MA 02110-1301, USA. + +# Test that AC_FC_SRCEXT(f9x) works as intended: +# - $(FCFLAGS_f) will be used + +# Cf. fort1.test and link_f90_only.test. + +. ./defs || exit 1 + +set -e + +mkdir sub + +cat >>configure.in <<'END' +AC_PROG_FC +AC_FC_SRCEXT([f90]) +AC_FC_SRCEXT([f95]) +AC_FC_SRCEXT([blabla]) +END + +cat >Makefile.am <<'END' +bin_PROGRAMS = hello goodbye +hello_SOURCES = hello.f90 foo.f95 sub/bar.f95 +goodbye_SOURCES = bye.f95 sub/baz.f90 +goodbye_FCFLAGS = +END + +$ACLOCAL +$AUTOMAKE +# The following tests aren't fool-proof, but they don't +# need a Fortran compiler. +grep '.\$(LINK)' Makefile.in && exit 1 +grep '.\$(FCLINK)' Makefile.in +grep '.\$(FCCOMPILE)' Makefile.in > stdout +grep -v '\$(FCFLAGS_f' stdout && exit 1 +grep '.\$(FC.*\$(FCFLAGS_blabla' Makefile.in && exit 1 +# Notice the TAB: +grep '^[ ].*\$(FC.*\$(FCFLAGS_f90).*\.f95' Makefile.in && exit 1 +grep '^[ ].*\$(FC.*\$(FCFLAGS_f95).*\.f90' Makefile.in && exit 1 +: