[ Fortran 90 support in automake/autoconf problem: some compilers,
 notably xlf90 on AIX, do not accept files with the ".f90" suffix" ]

Akim Demaille wrote on Monday:

> We should pick up the best suffix, .f90 seems very reasonable, and
> check that the compiler supports it.  Then we must be ready to handle
> the differences.  For instance we should ship a script which adjusts
> the command line.  Maybe `missing' should, although it might not be
> right since it is not actually replacing something which is missing
> here.
> 
> Anyway, we are reaching the limit between Autoconf's and Automake's
> realms.

I have an autoconf macro ready that determines whether or not the F90
compiler accepts the .f90 suffix.

Now, I see two possible ways to proceed, described below.
Which is the better solution? Or is there another one that I haven't
thought of?

1) Let automake generate a rule that looks like this:

.f90.o: 
        @F90_O_RULE@

For "normal" compilers, have autoconf substitute simply
F90_O_RULE = $(F90COMPILE) -c -o $@ $<
 
For "unusual" compilers, have autoconf substitute something like

F90_O_RULE = cp $< $*.$ac_cv_f90_source_ext; \
   $(F90COMPILE) -c -o $@ $*.$ac_cv_f90_source_ext; \
   rm -f $*.$ac_cv_f90_source_ext

where ac_cv_f90_source_ext would be "f" for xlf90.

This has the strong disadvantage that debugging the f90 code would become
impossible, because the source files are deleted after compilation. The
deletion, however, is necessary because otherwise make would use the .f.o
rule instead of .f90.o afterwards. (right?)

As far as I can see, a similar problem would arise if we e.g. provide a
shell script that wraps around the F90 compiler and accepts .f90 files.

2) Let automake generate the following:

@F90_F@
@F90_F_RULE@

@F90_F_O@:[tab]
        $(F90COMPILE) -c -o $@ $<       

Then, for normal compilers, 
F90_F=""
F90_F_RULE="" 
F90_F_O=.f90.o

For unusual compilers,

F90_F=.f90.$ac_f90_source_ext:[tab]
F90_F_RULE=[tab]cp $< $@
F90_F_O=.$ac_cv_f90_source_ext.o
        
Here, users could enable debugging by telling make not to delete
intermediate files. On the other hand, if $ac_cv_f90_source_ext="f",
there'd possibly be two ".f.o" rules, one for f77, one for f90. Therefore
it would be necessary to use the same compiler for f77 and f90 source.
Actually, autoconf/automake must detect this case, and take special
measures to handle it.

This would probably imply a lot of further complications with make and
automake rules.

-- 

Martin Wilck <[EMAIL PROTECTED]>
Institute for Tropospheric Research, Permoserstr. 15, D-04318 Leipzig, Germany
Tel. +49-341-2352151 / Fax +49-341-2352361


Reply via email to