Created
December 2, 2012 19:49
-
-
Save goodell/4190680 to your computer and use it in GitHub Desktop.
automake code snippet to deal with Fortran 90 modules, extracted from MPICH's (perl-generated) src/binding/f90/Makefile.mk
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# variables for custom "silent-rules" for F90 modules | |
mod_verbose = $(mod_verbose_$(V)) | |
mod_verbose_ = $(mod_verbose_$(AM_DEFAULT_VERBOSITY)) | |
mod_verbose_0 = @echo " MOD " $@; | |
# we "manually" build the f90 sources and add them with LIBADD | |
lib_lib@MPILIBNAME@f90_la_SOURCES = | |
lib_lib@MPILIBNAME@f90_la_LIBADD += src/binding/f90/mpi_constants.lo | |
# now force libtool FC rules/variables to be generated and cause FC linking to | |
# be selected for lib/lib@MPILIBNAME@f90.la | |
EXTRA_lib_lib@MPILIBNAME@f90_la_SOURCES += src/binding/f90/mpi_constants.f90 | |
src/binding/f90/mpi_constants.$(MOD)-stamp: src/binding/f90/mpi_constants.f90 src/binding/f90/mpifnoext.h | |
@rm -f src/binding/f90/mpi_constants-tmp | |
@touch src/binding/f90/mpi_constants-tmp | |
@( cd src/binding/f90 && \ | |
if [ "$(FCEXT)" != "f90" ] || [ ! -f mpi_constants.$(FCEXT) ] ; then \ | |
rm -f mpi_constants.$(FCEXT) ; \ | |
$(LN_S) $(abs_top_srcdir)/src/binding/f90/mpi_constants.f90 mpi_constants.$(FCEXT) ; \ | |
fi ) | |
$(mod_verbose)$(FC_COMPILE_MODS) -c src/binding/f90/mpi_constants.$(FCEXT) -o src/binding/f90/mpi_constants.lo | |
@( cd src/binding/f90 && \ | |
if [ "$(FCEXT)" != "f90" ] || [ ! -f mpi_constants.$(FCEXT) ] ; then \ | |
rm -f mpi_constants.$(FCEXT) ; \ | |
fi ) | |
@mv src/binding/f90/mpi_constants-tmp src/binding/f90/mpi_constants.$(MOD)-stamp | |
src/binding/f90/mpi_constants.lo src/binding/f90/$(MPICONSTMOD).$(MOD): src/binding/f90/mpi_constants.$(MOD)-stamp | |
## Recover from the removal of $@ | |
@if test -f $@; then :; else \ | |
trap 'rm -rf src/binding/f90/mpi_constants-lock src/binding/f90/mpi_constants.$(MOD)-stamp' 1 2 13 15; \ | |
if mkdir src/binding/f90/mpi_constants-lock 2>/dev/null; then \ | |
## This code is being executed by the first process. | |
rm -f src/binding/f90/mpi_constants.$(MOD)-stamp; \ | |
$(MAKE) $(AM_MAKEFLAGS) src/binding/f90/mpi_constants.$(MOD)-stamp; \ | |
rmdir src/binding/f90/mpi_constants-lock; \ | |
else \ | |
## This code is being executed by the follower processes. | |
## Wait until the first process is done. | |
while test -d src/binding/f90/mpi_constants-lock; do sleep 1; done; \ | |
## Succeed if and only if the first process succeeded. | |
test -f src/binding/f90/mpi_constants.$(MOD)-stamp; exit $$?; \ | |
fi; \ | |
fi | |
CLEANFILES += src/binding/f90/mpi_constants.$(MOD)-stamp src/binding/f90/$(MPICONSTMOD).$(MOD) src/binding/f90/mpi_constants.lo src/binding/f90/mpi_constants-tmp |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment