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.
2006-10-16 Ralf Wildenhues <Ralf.Wildenhues@gmx.de>
+ * 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):
- 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@'.
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
# 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 =
DEPBASE => $depbase,
BASE => '$*',
SOURCE => '$<',
+ SOURCEFLAG => $sourceflags{$ext} || '',
OBJ => '$@',
OBJOBJ => '$@',
LTOBJ => '$@',
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.
DEPBASE => $depbase_,
BASE => $obj_,
SOURCE => $source_,
+ SOURCEFLAG => $sourceflags{$srcext} || '',
OBJ => "$obj_$myext",
OBJOBJ => "$obj_.obj",
LTOBJ => "$obj_.lo",
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.
# 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
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,
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])
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
@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
@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
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%
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%
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%
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%
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%
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%
fnoc.test \
fo.test \
fort1.test \
+fort2.test \
fort4.test \
fort5.test \
fonly.test \
fnoc.test \
fo.test \
fort1.test \
+fort2.test \
fort4.test \
fort5.test \
fonly.test \
--- /dev/null
+#! /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
+: