[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: autotools, preprocessors, and fortran 90
From: |
Ralf Wildenhues |
Subject: |
Re: autotools, preprocessors, and fortran 90 |
Date: |
Mon, 11 Dec 2006 17:45:10 +0100 |
User-agent: |
Mutt/1.5.13 (2006-11-01) |
Hello John,
* John wrote on Mon, Dec 11, 2006 at 01:33:39PM CET:
> Ralf Wildenhues wrote:
> >
[...]
> > 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) ...
> MY_FPPFLAGS="-x f95-cpp-input"
> AC_SUBST([MY_FPPFLAGS])
>
> This doesn't work because the final makefile compile lines are
>
> FCLD = $(FC)
> FCLINK = $(FCLD) $(AM_FCFLAGS) $(FCFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
> FCCOMPILE = $(FC) $(AM_FCFLAGS) $(FCFLAGS)
>
> I don't know how to get the MY_FPPFLAGS into the compile line flags.
That's what the other line was about: adding
AM_CPPFLAGS = $(MY_FPPFLAGS)
to your Makefile.am file.
> I could never get the following line to produce the substitution.
> AC_SUBST([AM_FCFLAGS], [-x f95-cpp-input])
That's what I get for recommending untested code. Apologies. It needs
to be
AC_SUBST([AM_FCFLAGS], ["-x f95-cpp-input"])
> But, in either case of the
> AM_FCFLAGS, I still have the original problem of the -x f95-cpp-input
> getting passed to the linker, which completely doesn't work since the
> preprocessor tries to process object files while linking. How do I get
> the build system to add compile flags that aren't link flags? As you
> can see above, all the compile flags are also passed to the linker.
Here's a complete example. It makes use of the fact that Automake
assumes that files ending in .F90 and .F95 (as opposed to .f90 and .f95)
get preprocessed. The preprocessor flags will only be set for the GNU
Fortran compiler.
cat >configure.ac <<\EOF
AC_INIT([fortran-test], [1], [devnull])
AM_INIT_AUTOMAKE([foreign])
AC_CONFIG_FILES([Makefile])
AC_PROG_FC
if test $ac_cv_fc_compiler_gnu = yes; then
AC_SUBST([MY_CPPFLAGS], ["-x f95-cpp-input"])
fi
AC_OUTPUT
EOF
cat >Makefile.am <<\EOF
bin_PROGRAMS = foo
foo_SOURCES = foo.F95
AM_CPPFLAGS = $(MY_CPPFLAGS)
EOF
cat >foo.F95 <<\EOF
program main
end
EOF
autoreconf -vi
./configure
make
With respect to portability among compilers, this example is lacking the
flag for source file extensions, AC_FC_SRCEXT([F95]). I omitted it
because Automake does not automatically add support for it yet
(for .f90 and .f95, that has been added in Automake 1.10). If you need
this, write me, and I'll post an updated example.
> By the way, where is the Automake list?
The address is <automake@gnu.org>, the archives are here at
<http://lists.gnu.org/archive/html/automake/>.
Cheers,
Ralf
- autotools, preprocessors, and fortran 90, John, 2006/12/10
- Re: autotools, preprocessors, and fortran 90, Ralf Wildenhues, 2006/12/10
- Message not available
- Re: autotools, preprocessors, and fortran 90, John, 2006/12/11
- Re: autotools, preprocessors, and fortran 90,
Ralf Wildenhues <=
- Message not available
- Re: autotools, preprocessors, and fortran 90, John, 2006/12/12
- Re: autotools, preprocessors, and fortran 90, Ralf Wildenhues, 2006/12/12
- Message not available
- Re: autotools, preprocessors, and fortran 90, John, 2006/12/12