[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: AC_FC_MODULE_FLAG
From: |
Jim Edwards |
Subject: |
Re: AC_FC_MODULE_FLAG |
Date: |
Wed, 6 Jul 2011 15:59:13 -0600 |
Okay, here is another method that seems to work, I need to make the
subdirectory read-only then
try to compile another module in the main directory. With the -M flag it
fails because it can't write
the .mod file in the conftest.dir
Index: fortran.m4
===================================================================
--- fortran.m4 (revision 327)
+++ fortran.m4 (working copy)
@@ -593,7 +593,7 @@
# IBM: -Idir (-qmoddir=dir for writing)
# Intel: -Idir -I dir (-mod dir for writing)
# Absoft: -pdir
-# Lahey: -mod dir
+# Lahey: -Idir (-Mdir or -mod dir for writing)
# Cray: -module dir, -p dir (-J dir for writing)
# -e m is needed to enable writing .mod files at all
# Compaq: -Idir
@@ -615,17 +615,23 @@
write(*,'(a)') 'gotcha!'
end subroutine
end module]],
- [cd ..
+ # For Lahey -M will also write module and object files to that directory
+ # make it read-only so that lahey fails over to -I
+ [chmod -w .
+ cd ..
ac_fc_module_flag_FCFLAGS_save=$FCFLAGS
# Flag ordering is significant for gfortran and Sun.
for ac_flag in -M -I '-I ' '-M ' -p '-mod ' '-module ' '-Am -I'; do
# Add the flag twice to prevent matching an output flag.
FCFLAGS="$ac_fc_module_flag_FCFLAGS_save ${ac_flag}conftest.dir
${ac_flag}conftest.dir"
AC_COMPILE_IFELSE([[
- program main
+ module conftest_main
use conftest_module
+ contains
+ subroutine conftest
call conftest_routine
- end program]],
+ end subroutine
+ end module]],
[ac_cv_fc_module_flag="$ac_flag"])
if test "$ac_cv_fc_module_flag" != unknown; then
break
@@ -633,6 +639,7 @@
done
FCFLAGS=$ac_fc_module_flag_FCFLAGS_save
])
+chmod +w conftest.dir
rm -rf conftest.dir
AC_LANG_POP([Fortran])
])
On Wed, Jul 6, 2011 at 2:15 PM, Ralf Wildenhues <address@hidden>wrote:
> Hi Jim,
>
> thanks for the bug report!
>
> * Jim Edwards wrote on Wed, Jul 06, 2011 at 08:00:13PM CEST:
> > When using the lahey fortran compiler the flag -M is used as the path to
> > modules, but its also the path to where new modules should be written.
> > So if you are referencing modules in a read-only directory using the -M
> flag
> > will cause your program to fail. I think that the solution is to
> > test for -I first (that's also the most common result, so it would make
> > sense to test first I think)
>
> Well, with Solaris Fortran, -I is the flag to search for both header
> includes as well as modules, but it also has -M for module search path
> only. I'm kind of wary that if some command-line gets hardcoded -M
> flags from elsewhere, they could then end up overriding the ones
> computed by configure, although they come later in the command-line.
>
> Can we fix the test somehow so that -M is not chosen with Lahey? Adding
> the flag twice worked for some compiler at least. Could also test
> whether the compiler creates a module somewhere. Care to experiment a
> bit to find something that works with your compiler? (I don't have
> Lahey to test.)
>
> > --- fortran.m4 (revision 327)
> > +++ fortran.m4 (working copy)
> > @@ -618,7 +618,7 @@
> > [cd ..
> > ac_fc_module_flag_FCFLAGS_save=$FCFLAGS
> > # Flag ordering is significant for gfortran and Sun.
> > - for ac_flag in -M -I '-I ' '-M ' -p '-mod ' '-module ' '-Am -I'; do
> > + for ac_flag in -I '-mod ' -I '-I ' '-M ' -p '-module ' '-Am -I'; do
> > # Add the flag twice to prevent matching an output flag.
> > FCFLAGS="$ac_fc_module_flag_FCFLAGS_save ${ac_flag}conftest.dir
> > ${ac_flag}conftest.dir"
> > AC_COMPILE_IFELSE([[
>
> Thanks,
> Ralf
>