This is the mail archive of the automake@gnu.org mailing list for the automake project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

fortran modules


Hi,

To get automake/autoconf to work with my simple f90 project, I had to add a check for whether the module filenames are capitalized or not.

If you're not familiar with fortran, f90 module files are like C header files; however, they're generated at compile time and not written by the programmer. Also, the file format is compiler dependent, so you can't precompute them.

In addition, the actual module filename isn't standard. For example, if I have "module dummy" in the source, the SGI IRIX and Intel ifc compilers spit out "DUMMY.mod", while the Portland pgf90 compiler produces "dummy.mod".

So to work around this, I put this in Makefile.am:

	EXTRA_HEADERS = dummy.mod DUMMY.mod
	include_HEADERS = @DUMMY_MOD@

and tested for @DUMMY_MOD@ in configure.ac:

	AC_PROG_FC_UPPERCASE_MOD
	if test "$ac_cv_prog_fc_uppercase_mod" = "yes"; then
		DUMMY_MOD=DUMMY.mod
	else
		DUMMY_MOD=dummy.mod
	fi
	AC_SUBST(DUMMY_MOD)

where AC_PROG_FC_UPPERCASE_MOD is a macro I wrote to check which convention the f90 compiler uses [attached].

A couple of questions:

* Is this the best way to do this given the current versions of autoconf/make? In other words, is their a feature I don't know about which makes this rigamarole unnecessary?

* Since this is a pretty common idiom, would it make sense to extend automake to know about Fortran modules? I coudl say instead,

include_MODULES = dummy

and automake could then automagically determine the right filename depending on which compiler is being used.

Cheers,

-Mike
# _AC_PROG_FC_UPPERCASE_MOD
# -------------------------
# Test if the Fortran compiler produces uppercase module filenames.
#
AC_DEFUN([_AC_PROG_FC_UPPERCASE_MOD],
[_AC_FORTRAN_ASSERT()dnl
AC_CACHE_CHECK([whether $[]_AC_FC[] produces uppercase module filenames],
               [ac_cv_prog_[]_AC_LANG_ABBREV[]_uppercase_mod],
[AC_LANG_CONFTEST([AC_LANG_SOURCE([      module conftest
      end module])])
ac_try='$[]_AC_FC[] $[]_AC_LANG_PREFIX[]FLAGS -c conftest.$ac_ext >&AS_MESSAGE_LOG_FD'
if AC_TRY_EVAL(ac_try) &&
   test -f CONFTEST.mod ; then
        ac_cv_prog_[]_AC_LANG_ABBREV[]_uppercase_mod=yes
	rm -f CONFTEST.mod
else
  ac_cv_prog_[]_AC_LANG_ABBREV[]_uppercase_mod=no
fi
rm -f conftest*])
#if test $ac_cv_prog_[]_AC_LANG_ABBREV[]_uppercase_mod = no; then
#  AC_DEFINE([]_AC_FC[]_NO_MINUS_C_MINUS_O, 1,
#            [Define to 1 if your Fortran compiler doesn't accept
#             -c and -o together.])
#fi
])# _AC_PROG_FC_UPPERCASE_MOD


# AC_PROG_FC_MOD
# ---------------
AC_DEFUN([AC_PROG_FC_UPPERCASE_MOD],
[AC_REQUIRE([AC_PROG_FC])dnl
AC_LANG_PUSH(Fortran)dnl
_AC_PROG_FC_UPPERCASE_MOD
AC_LANG_POP(Fortran)dnl
])# AC_PROG_FC_UPPERCASE_MOD


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]