Re: autotools, preprocessors, and fortran 90

Ralf Wildenhues <[email protected]>
Newsgroups gmane.comp.gnu.utils
Organization Department of Numerical Simulation, University of Bonn
Message-ID <[email protected]>
Hello John,

* John wrote on Sun, Dec 10, 2006 at 01:37:41PM CET:
> 
> I don't know if this is the right place for this question, but ...

Probably the automake list would be more appropriate.  Anyway.

> I'm trying to set up a small fortran 90 project using the gnu
> auto-tools.  My fortran files (*.f90) require a preprocessor to
> interpret # directives.  In the case of gcc, I need to add the flag -x
> f95-cpp-input to force the use of the preprocessor.  I can do this
> by adding the line
> 
> AM_FCFLAGS = -x f95-cpp-input
> 
> to Makefile.am.

You can set the variable from configure.ac, e.g.,
  AC_SUBST([AM_FCFLAGS], [-x f95-cpp-input])

You could conditionalize it on the compiler there.  Note that Automake
assumes preprocessed Fortran with capitalized suffixes .F90, .F95.  So 
if you use them, you can stuff preprocessing flags in AM_CPPFLAGS, e.g.,
globally in configure.ac, if your project consists only of Fortran
source, or per-Makefile.am, if you have other directories with different
source languages.  For example, you could have this in configure.ac:
  MY_FPPFLAGS="-x f95-cpp-input"
  AC_SUBST([MY_FPPFLAGS])

and this in src/f90/Makefile.am:
  AM_CPPFLAGS = $(MY_FPPFLAGS) ...

Preprocessed Fortran support in Autoconf and Automake isn't yet as good
as it could be.  There's been some work done by the Starlink people that
would be nice to merge eventually (given enough time).  Search the net
for AC_PROG_FPP in case you're interested (but doing that work isn't
exactly a newbie task).

Hope that helps.

Cheers,
Ralf
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.