Hello,
to begin with, I'm an awful beginner when it comes to automake's
internals... I beg your pardon if the attached patch should break
something or is too much off the line.
I have used autoconf/automake a lot to configure programs and libraries
written in Fortran 77 and Fortran 90, partially using some autoconf
macros provided by Martin Wilck several months ago (they don't work with
the current CVS-version of autoconf anymore, but that's another issue).
Regarding automake, I believe there is an inconsistency in the way
automake handles Fortran file extensions:
- For files ending with .f or .for, Makefile targets are created
using the variables F77, FFLAGS, and F77LINK (apart from the standard
ones. Fine.
- Files ending with .f90 are also handled this way; i.e. Fortran 77 (!)
targets are created for them - not really fine... :-(
- Files ending with .F are handled in a special way - as preprocessed
Fortran files. Great!
- Files with .F90 are not handled at all, nor are Fortran 95 files
(.f95 or .F95). :-((
The last point is annoying, since it prohibits the use of any
.F90 or even .f95 files in any project that is maintained with automake:
it simply doesn't generate the proper dependencies for a library or
program - a .F90, .f95 or .F95 is never compiled, even if the
Makefile.am contains handwritten rules for their generation.
I have tried to solve this by adding the appropriate register_language
calls for f90, ppf90, f95, and ppf95; I also added some auxiliary
routines within automake.in. The generated targets are more or less
identical to those generated from the f77/ppf77 set of routines, but use
the Makefile variables F90, F90FLAGS, F90LINK and F95, F95FLAGS,
F95LINK, respectively. These somehow have to be generated by
configure.in.
To my understanding, this shouldn't break anything apart from the
"feature" that Fortran 90 files are compiled by a Fortran 77 compiler.
Probably, this could be reproduced by adding something like
F90 = @F77@
F90FLAGS = @FFLAGS@
F90LINK = @F77LINK@
in the Makefile.am (though I haven't tried that).
Thank you for considering this, and kind regards,
Chris.
--
Christian Marquardt
GFZ Potsdam, Div. 1 | Tel.: (+49) 331-288-1168
Am Telegrafenberg | Fax: (+49) 331-288-1169
D-14473 Potsdam | Email: [EMAIL PROTECTED]
Index: automake.in
===================================================================
RCS file: /cvs/automake/automake/automake.in,v
retrieving revision 1.851
diff -u -u -r1.851 automake.in
--- automake.in 2001/02/04 04:03:08 1.851
+++ automake.in 2001/02/04 13:45:30
@@ -380,7 +380,7 @@
'compile=$(F77) $(AM_FFLAGS) $(FFLAGS)',
'compiler-name=F77COMPILE',
'output-arg=-c -o $@',
- 'f', 'for', 'f90');
+ 'f', 'for');
®ister_language ('ppf77', 'linker=F77LINK', 'flags=FFLAGS',
'compile=$(F77) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS)
$(AM_FFLAGS) $(FFLAGS)',
'compiler-name=PPF77COMPILE',
@@ -392,6 +392,26 @@
'compiler-name=RCOMPILE',
'output-arg=-c -o $@',
'r');
+®ister_language ('f90', 'linker=F90LINK', 'flags=F90FLAGS',
+ 'compile=$(F90) $(AM_FFLAGS) $(F90FLAGS)',
+ 'compiler-name=F90COMPILE',
+ 'output-arg=-c -o $@',
+ 'f90');
+®ister_language ('ppf90', 'linker=F90LINK', 'flags=F90FLAGS',
+ 'compile=$(F90) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS)
+$(AM_FFLAGS) $(F90FLAGS)',
+ 'compiler-name=PPF90COMPILE',
+ 'output-arg=-c -o $@',
+ 'F90');
+®ister_language ('f95', 'linker=F95LINK', 'flags=F95FLAGS',
+ 'compile=$(F95) $(AM_FFLAGS) $(F95FLAGS)',
+ 'compiler-name=F95COMPILE',
+ 'output-arg=-c -o $@',
+ 'f95');
+®ister_language ('ppf95', 'linker=F95LINK', 'flags=F95FLAGS',
+ 'compile=$(F95) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS)
+$(AM_FFLAGS) $(F95FLAGS)',
+ 'compiler-name=PPF95COMPILE',
+ 'output-arg=-c -o $@',
+ 'F95');
# FIXME: for now we can't do dependency tracking for Java.
# autodep=GCJ
®ister_language ('java', 'linker=GCJLINK', 'flags=GCJFLAGS',
@@ -1045,7 +1065,7 @@
next if defined $done{$lang};
$done{$lang} = 1;
- $non_c = 0 if $lang !~ /(objc|cxx|f77|ratfor)$/;
+ $non_c = 0 if $lang !~ /(objc|cxx|f77|ppf77|ratfor|f90|ppf90|f95|ppf95)$/;
if ($comp ne '')
{
@@ -4662,7 +4682,7 @@
&am_conf_line_warning ($filename, $., "automake requires \`AM_PROG_LEX',
not \`AC_PROG_LEX'");
}
- if (/AC_PROG_(F77|YACC|RANLIB|CC|CXXCPP|CXX|LEX|AWK|CPP|LN_S)/)
+ if (/AC_PROG_(F77|F90|F95|YACC|RANLIB|CC|CXXCPP|CXX|LEX|AWK|CPP|LN_S)/)
{
$configure_vars{$1} = $filename . ':' . $.;
}
@@ -4737,6 +4757,16 @@
{
$configure_vars{'FLIBS'} = $filename . ':' . $.;
}
+ # Check for Fortran 90 intrinsic and run-time libraries.
+ if (/AC_F90_LIBRARY_LDFLAGS/)
+ {
+ $configure_vars{'FLIBS'} = $filename . ':' . $.;
+ }
+ # Check for Fortran 95 intrinsic and run-time libraries.
+ if (/AC_F95_LIBRARY_LDFLAGS/)
+ {
+ $configure_vars{'FLIBS'} = $filename . ':' . $.;
+ }
}
close (CONFIGURE);
@@ -5041,6 +5071,30 @@
return $LANG_PROCESS;
}
+# Rewrite a single Fortran 90 file.
+sub lang_f90_rewrite
+{
+ return $LANG_PROCESS;
+}
+
+# Rewrite a single preprocessed Fortran 90 file.
+sub lang_ppf90_rewrite
+{
+ return $LANG_PROCESS;
+}
+
+# Rewrite a single Fortran 95 file.
+sub lang_f95_rewrite
+{
+ return $LANG_PROCESS;
+}
+
+# Rewrite a single preprocessed Fortran 95 file.
+sub lang_ppf95_rewrite
+{
+ return $LANG_PROCESS;
+}
+
# Rewrite a single Objective C file.
sub lang_objc_rewrite
{
@@ -5313,6 +5367,86 @@
. "\t\$(RCOMPILE) -F \$<\n");
}
+sub lang_f90_finish
+{
+ # FIXME: this function can be called more than once. We should
+ # arrange for it to only do anything the first time through.
+
+ local ($ltcompile, $ltlink) = &libtool_compiler;
+
+ &define_variable ('F90LD', '$(F90)');
+ &define_variable ('F90LINK', $ltlink . '$(F90LD) $(AM_FFLAGS) $(F90FLAGS)
+$(AM_LDFLAGS) $(LDFLAGS) -o $@');
+
+ if (! defined $configure_vars{'F90'})
+ {
+ &am_error ("Fortran 90 source seen but \`F90' not defined in
+\`$configure_ac'");
+ }
+}
+
+# Preprocessed Fortran 90
+#
+# The current support for preprocessing Fortran 90 just involves passing
+# `$(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS)' as additional flags
+# to the Fortran 90 compiler, since this is how GNU Make does it; see
+# the `GNU Make Manual, Edition 0.51 for `make' Version 3.76 Beta'
+# (specifically, from info file `(make)Catalogue of Rules').
+#
+# A better approach would be to write an Autoconf test
+# (i.e. AC_PROG_FPP) for a Fortran 90 preprocessor, because not all
+# Fortran 90 compilers know how to do preprocessing. The Autoconf macro
+# AC_PROG_FPP should test the Fortran 90 compiler first for
+# preprocessing capabilities, and then fall back on cpp (if cpp were
+# available).
+sub lang_ppf90_finish
+{
+ &lang_f90_finish;
+
+ # We also handle the case of preprocessing `.F90' files into `.f90'
+ # files.
+ $output_rules .= (".F90.f90:\n"
+ . "\t\$(F90COMPILE) -F \$<\n");
+}
+
+sub lang_f95_finish
+{
+ # FIXME: this function can be called more than once. We should
+ # arrange for it to only do anything the first time through.
+
+ local ($ltcompile, $ltlink) = &libtool_compiler;
+
+ &define_variable ('F95LD', '$(F95)');
+ &define_variable ('F95LINK', $ltlink . '$(F95LD) $(AM_FFLAGS) $(F90FLAGS)
+$(AM_LDFLAGS) $(LDFLAGS) -o $@');
+
+ if (! defined $configure_vars{'F95'})
+ {
+ &am_error ("Fortran 95 source seen but \`F95' not defined in
+\`$configure_ac'");
+ }
+}
+
+# Preprocessed Fortran 95
+#
+# The current support for preprocessing Fortran 95 just involves passing
+# `$(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS)' as additional flags
+# to the Fortran 95 compiler, since this is how GNU Make does it; see
+# the `GNU Make Manual, Edition 0.51 for `make' Version 3.76 Beta'
+# (specifically, from info file `(make)Catalogue of Rules').
+#
+# A better approach would be to write an Autoconf test
+# (i.e. AC_PROG_FPP) for a Fortran 95 preprocessor, because not all
+# Fortran 90 compilers know how to do preprocessing. The Autoconf macro
+# AC_PROG_FPP should test the Fortran 95 compiler first for
+# preprocessing capabilities, and then fall back on cpp (if cpp were
+# available).
+sub lang_ppf95_finish
+{
+ &lang_f95_finish;
+
+ # We also handle the case of preprocessing `.F95' files into `.f95'
+ # files.
+ $output_rules .= (".F95.f95:\n"
+ . "\t\$(F95COMPILE) -F \$<\n");
+}
+
sub lang_objc_finish
{
local ($ltcompile, $ltlink) = &libtool_compiler;
@@ -5379,6 +5513,10 @@
if defined $linkers{'CXXLINK'};
return 'F77LINK'
if defined $linkers{'F77LINK'};
+ return 'F90LINK'
+ if defined $linkers{'F90LINK'};
+ return 'F95LINK'
+ if defined $linkers{'F95LINK'};
return 'OBJCLINK'
if defined $linkers{'OBJCLINK'};
return 'LINK';