| Paul Martinolich wrote:
| > The _AC_COMPILER_GNU macro uses the cpp statements:
| > [...] 
| > to determine if the compile is a GNU compiler.  In strict Fortran,
| > these statements are illegal!  Unfortunately, I don't believe there
| > is a way (in strict Fortran) to determine those characteristics of
| > the compiler.
| 
| (I think you're missing the point.  It's fine that other compilers will
| choke on this--that will cause the test to correctly fail.  We only need
| it to work for one compiler, g77.)
| 
| Anyway, I see that Akim has checked in fixes for this problem...
| Unfortunately, it is still broken.  Now it doesn't think *any* compiler is
| g77, including g77 itself.
| 
| The problem is that the test program is compiled as conftest.f, which
| isn't run through the preprocessor by g77--it needs to be called
| conftest.fpp or conftest.F.  I'm not sure what the right way to fix this
| is.  The simplest thing would to be to simply change ac_ext temporarily
| just before calling _AC_LANG_COMPILER_GNU for Fortran:
| 
| diff -u -r1.89 aclang.m4
| --- aclang.m4 2000/11/14 11:06:37     1.89
| +++ aclang.m4 2000/11/15 03:33:58
| @@ -1029,7 +1029,10 @@
|                    [g77 f77 xlf cf77 pgf77 fl32 fort77 f90 xlf90 f95 lf95 fc])]) 
|  _AC_LANG_COMPILER_WORKS
| +ac_ext_SAVE="$ac_ext"
| +ac_ext=F
|  _AC_LANG_COMPILER_GNU
| +ac_ext="$ac_ext_SAVE"
|  G77=`test $ac_compiler_gnu = yes && echo yes`
|  AC_EXPAND_ONCE([_AC_OBJEXT])
|  AC_EXPAND_ONCE([_AC_EXEEXT])
| 
| This is a bit ugly, though, since _AC_LANG_COMPILER_GNU then does not work
| on its own for Fortran; I'm not sure where the right place to put it would
| be.  (In the long term, you may want some way of telling AC_COMPILE*
| whether or not you want to use the preprocessor too, at least for
| Fortran?)  In any case, though, you don't need to worry about using the
| "right" filename extension for preprocessing in all compilers, since it
| only has to work for g77 (and fail for other compilers).

I'm very much in favor of this patch.  I agree it is not right in the
absolute since _AC_LANG_COMPILER_GNU is not ``complete''.  But otoh,
it's also because the task in itself is not right: we're trying to
measure something which is not what we will actually be using.

In the long run, the answer will probably be to stop depending upon
GNUness of the compiler to pass -O2 -g: we should just try some sort
of

for options in "-O2 -g" "-O -g" "-g" "";
do
  see if it works OK
done

But I'd say it is too late for 2.50 (unless someone thinks we should
do that *now*).

| PS. I wonder if a better way than #ifdef'ing __GNUC__ would be to just run
| the compiler with --version and look for "GNU Fortran" on the first line?

I'm not sure all the GNU compilers always supported some --version.

I am applying your patch, comments are, as always, most welcome.

        Akim

Reply via email to