From 0cb2469a2076d35049130ed7b6fe098b00365fac Mon Sep 17 00:00:00 2001 From: Ralf Wildenhues Date: Mon, 16 Oct 2006 05:24:17 +0000 Subject: [PATCH] * 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, THANKS: Update. Suggested by Steven G. Johnson. --- ChangeLog | 16 +++++++++++++ NEWS | 3 +++ THANKS | 1 + automake.in | 20 ++++++++++++++-- doc/automake.texi | 14 +++++++++--- lib/am/depend2.am | 38 +++++++++++++++---------------- tests/Makefile.am | 1 + tests/Makefile.in | 1 + tests/fort2.test | 58 +++++++++++++++++++++++++++++++++++++++++++++++ 9 files changed, 128 insertions(+), 24 deletions(-) create mode 100755 tests/fort2.test diff --git a/ChangeLog b/ChangeLog index 638c0c9b..c19738cb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,21 @@ 2006-10-16 Ralf Wildenhues + * 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, THANKS: Update. + Suggested by Steven G. Johnson. + For PR automake/480. * automake.in (lang_f77_rewrite, lang_fc_rewrite) (lang_ppfc_rewrite, lang_ppf77_rewrite, lang_ratfor_rewrite): diff --git a/NEWS b/NEWS index f93bc1ba..d3f5dd68 100644 --- a/NEWS +++ b/NEWS @@ -5,6 +5,9 @@ New in 1.10a: - subdir-object mode works now with Fortran (F77, FC, preprocessed Fortran, and Ratfor). + - For files with extension .f90 or .f95, the flag $(FCFLAGS_f9x) + computed by AC_FC_SRCEXT is now honored in compile rules. + * Miscellaneous changes: - New shorthand `$(pkglibexecdir)' for `$(libexecdir)/@PACKAGE@'. diff --git a/THANKS b/THANKS index 9a091cea..5d0b557e 100644 --- a/THANKS +++ b/THANKS @@ -272,6 +272,7 @@ Simon Richter sjr@debian.org Stefan Nordhausen nordhaus@informatik.hu-berlin.de Stepan Kasal kasal@math.cas.cz Steve M. Robbins steve@nyongwa.montreal.qc.ca +Steven G. Johnson stevenj@alum.mit.edu Sven Verdoolaege skimo@kotnet.org Tamara L. Dahlgren dahlgren1@llnl.gov Tatu Ylonen ylo@ssh.fi diff --git a/automake.in b/automake.in index 1be6959e..730b3710 100755 --- a/automake.in +++ b/automake.in @@ -417,6 +417,9 @@ my %languages = (); # 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 = @@ -1282,6 +1285,7 @@ sub handle_languages DEPBASE => $depbase, BASE => '$*', SOURCE => '$<', + SOURCEFLAG => $sourceflags{$ext} || '', OBJ => '$@', OBJOBJ => '$@', LTOBJ => '$@', @@ -1297,7 +1301,7 @@ sub handle_languages 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. @@ -1418,6 +1422,7 @@ sub handle_languages DEPBASE => $depbase_, BASE => $obj_, SOURCE => $source_, + SOURCEFLAG => $sourceflags{$srcext} || '', OBJ => "$obj_$myext", OBJOBJ => "$obj_.obj", LTOBJ => "$obj_.lo", @@ -1441,6 +1446,7 @@ sub handle_languages 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. @@ -1779,7 +1785,8 @@ sub handle_single_transform ($$$$$%) # 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 @@ -4782,6 +4789,7 @@ sub scan_autoconf_traces ($) 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, @@ -4894,6 +4902,14 @@ sub scan_autoconf_traces ($) push @config_links, $spec; } } + elsif ($macro eq 'AC_FC_SRCEXT') + { + my $suffix = $args[1]; + # These flags are used as %SOURCEFLAG% in depend2.am, + # where the trailing space is important. + $sourceflags{'.' . $suffix} = '$(FCFLAGS_' . $suffix . ') ' + if ($suffix eq 'f90' || $suffix eq 'f95'); + } elsif ($macro eq 'AC_INIT') { if (defined $args[2]) diff --git a/doc/automake.texi b/doc/automake.texi index da374111..8233733c 100644 --- a/doc/automake.texi +++ b/doc/automake.texi @@ -2782,6 +2782,11 @@ This is required for programs and shared libraries that are a mixture of languages that include Fortran 77 (@pxref{Mixing Fortran 77 With C and C++}). @xref{Macros, , Autoconf macros supplied with Automake}. +@item 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 @@ -6306,7 +6311,7 @@ trick with @code{nodist_EXTRA_@dots{}_SOURCES}. @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 @@ -6351,8 +6356,11 @@ is as follows: @table @file -@item .f9x -@code{$(FC) -c $(AM_FCFLAGS) $(FCFLAGS)} +@item .f90 +@code{$(FC) $(AM_FCFLAGS) $(FCFLAGS) -c $(FCFLAGS_f90) $<} + +@item .f95 +@code{$(FC) $(AM_FCFLAGS) $(FCFLAGS) -c $(FCFLAGS_f95) $<} @end table diff --git a/lib/am/depend2.am b/lib/am/depend2.am index e0414e53..99a942c4 100644 --- a/lib/am/depend2.am +++ b/lib/am/depend2.am @@ -65,10 +65,10 @@ if %?NONLIBTOOL% 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 @@ if %AMDEP% 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 @@ endif !%FASTDEP% 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 @@ if %AMDEP% 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 %?LIBTOOL% 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 @@ if %AMDEP% 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% diff --git a/tests/Makefile.am b/tests/Makefile.am index ff98dd01..d2136b1e 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -247,6 +247,7 @@ fn99subdir.test \ fnoc.test \ fo.test \ fort1.test \ +fort2.test \ fort4.test \ fort5.test \ fonly.test \ diff --git a/tests/Makefile.in b/tests/Makefile.in index 44dd3420..ba635c9d 100644 --- a/tests/Makefile.in +++ b/tests/Makefile.in @@ -380,6 +380,7 @@ fn99subdir.test \ fnoc.test \ fo.test \ fort1.test \ +fort2.test \ fort4.test \ fort5.test \ fonly.test \ diff --git a/tests/fort2.test b/tests/fort2.test new file mode 100755 index 00000000..fbc89059 --- /dev/null +++ b/tests/fort2.test @@ -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 +: -- 2.43.5