automake
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Fortran 90/95 support (automake)


From: marq
Subject: Fortran 90/95 support (automake)
Date: Thu, 7 Jun 2001 22:41:20 +0200 (CEST)

Hello!

Over the last months, I have used autoconf and automake for various
libraries and programs - they are *soooo* useful!

Working in a more meteorological / scientific environment,
the only thing I found missing was the support for the fortran 90 and
95 languages.

What the attached patch does is simply to register new languages:
fortran 90, fortran 95, and their preprocessed versions. The main
rationale behind this is:

 - There are compilers (Sun, for example), where the fortran 77
   version has extensions not supported by the fortran 90
   version (e.g., a 'byte' declaration). Thus, different rules are
   required for using both fortran 77 and 90 sources in the same
   program or library. 
 - There are some features in fortran 95 which are not part of fortran
   90 (elemental and pure functions, null() etc.). Thus, sources using
   fortran 95 features (and usually using the extension f95) require a
   fortran 95 compiler -> another rule for .f95 files.
 - There are compilers (again Sun, maybe others) that require special
   libraries to be linked if f77 and f90 compiled objects are linked
   together -> an additional LD90FLAGS might be required for linking
   with f90/f95 (but not for pure f77 programs).
 - On Linux, where people might want to use g77 along with a specific
   vendor's f90 or f95, compiler flags might be different for the two
   compilers; also, a fortran 90 compiler might require additional
   flags in order to use specific features, e.g., modules (so does the
   the Fujitsu compiler on Linux or Solaris do) -> The fortran 90
   compilers may need different flags, i.e a variable F90FLAGS.

The attached patch to automake.in generates different compilation
rules for fortran 77, 90 and 95 files, using the following Makefile
variables in the generated targets:

  F90                    (instead of F77 for plain Fortran 77)
  F90FLAGS               (instead of FFLAGS for Fortran 77)
  LD90FLAGS              (but LDFLAGS is also used)

The variable

  F90LIBS

is also honoured (replacing the FLIBS variable for Fortran 77).

For fortran 95, the counterparts F90, F90FLAGS, LD90FLAGS and F95LIBS
are used.

I've also added some macros to the current cvs autoconf version and
will send them to the appropriate list in a few minutes. 

Thus, I would like to request to include the attached patch to
automake (and the corresponding patch to autoconf). If the maintainers
of both packages agree to include them, I would try to write some
description for the manuals.

Thanks,

  Chris.



Here's is the patch:

---------------------

Index: automake.in

2001-06-07  Christian Marquardt  <address@hidden>

        * automake.in: Basic support for Fortran 90 and Fortran 95.


Index: automake.in
===================================================================
RCS file: /cvs/automake/automake/automake.in,v
retrieving revision 1.1136
diff -u -r1.1136 automake.in
--- automake.in 2001/06/03 17:16:40     1.1136
+++ automake.in 2001/06/07 20:26:54
@@ -898,7 +898,7 @@
                   'lder' => 'F77LD',
                   'ld' => '$(F77)',
                   'pure' => 1,
-                  'extensions' => ['f', 'for', 'f90']);
+                  'extensions' => ['f', 'for']);
 
 # Preprocessed Fortran 77
 #
@@ -947,6 +947,70 @@
                   'pure' => 1,
                   'extensions' => ['r']);
 
+# Fortran 90
+register_language ('name' => 'f90',
+                  'Name' => 'Fortran 90',
+                  'linker' => 'F90LINK',
+                  'link' => '$(F90LD) $(AM_FFLAGS) $(F90FLAGS) $(AM_LDFLAGS) 
$(LD90FLAGS) $(LDFLAGS) -o $@',
+                  'flags' => 'F90FLAGS',
+                  'compile' => '$(F90) $(AM_FFLAGS) $(F90FLAGS)',
+                  'compiler' => 'F90COMPILE',
+                  'compile_flag' => '-c',
+                  'output_flag' => '-o',
+                  'lder' => 'F90LD',
+                  'ld' => '$(F90)',
+                  'pure' => 1,
+                  'extensions' => ['f90']);
+
+# Preprocessed Fortran 90
+# Note: The same remarks made wrt to the preprocessed Fortran 77 apply here as 
well.
+register_language ('name' => 'ppf90',
+                  'Name' => 'Preprocessed Fortran 90',
+                  'config_vars' => ['F90'],
+                  'linker' => 'F90LINK',
+                  'link' => '$(F90LD) $(AM_FFLAGS) $(F90FLAGS) $(AM_LDFLAGS) 
$(LD90FLAGS) $(LDFLAGS) -o $@',
+                  'lder' => 'F90LD',
+                  'ld' => '$(F90)',
+                  'flags' => 'F90FLAGS',
+                  'compiler' => 'PPF90COMPILE',
+                  'compile' => '$(F90) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) 
$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_FFLAGS) $(F90FLAGS)',
+                  'compile_flag' => '-c',
+                  'output_flag' => '-o',
+                  'pure' => 1,
+                  'extensions' => ['F90']);
+
+# Fortran 95
+register_language ('name' => 'f95',
+                  'Name' => 'Fortran 95',
+                  'linker' => 'F95LINK',
+                  'link' => '$(F95LD) $(AM_FFLAGS) $(F95FLAGS) $(AM_LDFLAGS) 
$(LD95FLAGS) $(LDFLAGS) -o $@',
+                  'flags' => 'F95FLAGS',
+                  'compile' => '$(F95) $(AM_FFLAGS) $(F95FLAGS)',
+                  'compiler' => 'F95COMPILE',
+                  'compile_flag' => '-c',
+                  'output_flag' => '-o',
+                  'lder' => 'F95LD',
+                  'ld' => '$(F95)',
+                  'pure' => 1,
+                  'extensions' => ['f95']);
+
+# Preprocessed Fortran 95
+# Note: The same remarks made wrt to the preprocessed Fortran 77 apply here as 
well.
+register_language ('name' => 'ppf95',
+                  'Name' => 'Preprocessed Fortran 95',
+                  'config_vars' => ['F95'],
+                  'linker' => 'F95LINK',
+                  'link' => '$(F95LD) $(AM_FFLAGS) $(F95FLAGS) $(AM_LDFLAGS) 
$(LD95FLAGS) $(LDFLAGS) -o $@',
+                  'lder' => 'F95LD',
+                  'ld' => '$(F95)',
+                  'flags' => 'F95FLAGS',
+                  'compiler' => 'PPF95COMPILE',
+                  'compile' => '$(F95) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) 
$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_FFLAGS) $(F95FLAGS)',
+                  'compile_flag' => '-c',
+                  'output_flag' => '-o',
+                  'pure' => 1,
+                  'extensions' => ['F95']);
+
 # Java via gcj.
 register_language ('name' => 'java',
                   'Name' => 'Java',
@@ -4529,7 +4593,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 . ':' . $.;
        }
@@ -4612,6 +4676,18 @@
        {
            $configure_vars{'FLIBS'} = $filename . ':' . $.;
        }
+
+       # Check for Fortran 90 intrinsic and run-time libraries.
+       if (/AC_F90_LIBRARY_LDFLAGS/)
+       {
+           $configure_vars{'F90LIBS'} = $filename . ':' . $.;
+       }
+
+       # Check for Fortran 95 intrinsic and run-time libraries.
+       if (/AC_F95_LIBRARY_LDFLAGS/)
+       {
+           $configure_vars{'F95LIBS'} = $filename . ':' . $.;
+       }
     }
 
     $configfh->close;
@@ -4905,6 +4981,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
 {
@@ -5096,6 +5196,10 @@
        if defined $linkers{'GCJLINK'};
     return 'CXXLINK'
        if defined $linkers{'CXXLINK'};
+    return 'F95LINK'
+       if defined $linkers{'F95LINK'};
+    return 'F90LINK'
+       if defined $linkers{'F90LINK'};
     return 'F77LINK'
        if defined $linkers{'F77LINK'};
     return 'OBJCLINK'


-------------------

Cheers,

  Chris.

-- 

  Christian Marquardt

  GFZ Potsdam, Div. 1             |       Tel.: (+49) 331-288-1168
  Am Telegrafenberg               |       Fax:  (+49) 331-288-1732
  D-14473 Potsdam                 |       Email: address@hidden






reply via email to

[Prev in Thread] Current Thread [Next in Thread]