Skip to content
Snippets Groups Projects
Commit 01befed7 authored by Sergey Kosukhin's avatar Sergey Kosukhin
Browse files

Generate/update Fortran 77 interface files with make.

The code is quite complicated because of the following requirements and
limitations:

1. We keep the generated files in the develop branch and want to update them
   in the maintainer mode even if building out-of-source.

2. We have to support the distribution of the files over a VCS, which does not
   keep the timestamps, therefore, the files must not depend on anything in
   non-maintainer mode.

3. Files <prefix>.inc and <prefix>Fortran.c are generated with a single command
   and must be consistent, which makes the recovery in non-maintainer mode
   difficult. For example, we must not use <prefix>.inc from the source
   directory and <prefix>Fortran.c from the build directory. Also, the files
   must not be changed in the source directory in non-maintainer mode.

4. The console output of make_fint is very verbose and confusing for an
   unprepared user, therefore, we should call it in non-maintainer mode only
   when recovering.

In fact, we can have much more simple code if we fix #4 and stop distributing
the files because building make_fint does not require any extra tools or
libraries.
parent d9db7157
No related branches found
No related tags found
2 merge requests!34Version 2.2.0,!16Remove Fortran interface files from the repo
......@@ -286,15 +286,73 @@ endif
endif
#
# See https://www.gnu.org/software/automake/manual/html_node/Multiple-Outputs.html
make_fint_run = stem=`echo '$@' | sed -e 's|.*/||' -e 's|.inc||' -e 's|Fortran.c||'`;
if MAINTAINER_MODE
make_fint_run += ./make_fint -o $(@D) "$(srcdir)/$${stem}.h"
else
make_fint_run += \
test -f "$${stem}.inc" && test -f "$${stem}Fortran.c" && exit 0; \
trap "rm -rf .fint/$${stem}.lock .fint/$${stem}.stamp" 1 2 13 15; \
if mkdir .fint/$${stem}.lock 2>/dev/null; then \
rm -f .fint/$${stem}.stamp; ec=0; \
test '.' != '$(srcdir)' && \
for f in "$(srcdir)/$${stem}.inc" "$(srcdir)/$${stem}Fortran.c"; do \
test -f $$f && \
echo "The source directory is inconsistent: remove '$$f' to recover" >&2 && \
ec=1 && break; done; \
test $$ec != 0 || ./make_fint -o $(@D) "$(srcdir)/$${stem}.h" || ec=1; \
test $$ec = 0 && touch .fint/$${stem}.stamp; \
rm -rf .fint/$${stem}.lock; exit $$ec; \
else \
while test -d .fint/$${stem}.lock; do sleep 1; done; \
test -f .fint/$${stem}.stamp || exit 1; fi
endif
# We have to provide the recipe fo non-maintainer mode literally to let make
# know that it contains a recursive make call:
cdiFortran.c cdi.inc: @MAINTAINER_MODE_TRUE@ $(srcdir)/cdi.h make_fint
@MAINTAINER_MODE_FALSE@ @$(MKDIR_P) .fint; \
@MAINTAINER_MODE_FALSE@ trap 'rm -rf .fint/make.lock .fint/make.stamp' 1 2 13 15; \
@MAINTAINER_MODE_FALSE@ if mkdir .fint/make.lock 2>/dev/null; then \
@MAINTAINER_MODE_FALSE@ rm -f .fint/make.stamp; \
@MAINTAINER_MODE_FALSE@ $(MAKE) $(AM_MAKEFLAGS) make_fint; ec=$$?; \
@MAINTAINER_MODE_FALSE@ test $$ec = 0 && touch .fint/make.stamp; \
@MAINTAINER_MODE_FALSE@ rm -rf .fint/make.lock; exit $$ec; \
@MAINTAINER_MODE_FALSE@ else \
@MAINTAINER_MODE_FALSE@ while test -d .fint/make.lock; do sleep 1; done; \
@MAINTAINER_MODE_FALSE@ test -f .fint/make.stamp || exit 1; fi
$(AM_V_GEN)$(make_fint_run)
cdi.inc: @MAINTAINER_MODE_TRUE@ cdiFortran.c
cdipioFortran.c cdipio.inc: @MAINTAINER_MODE_TRUE@ $(srcdir)/cdipio.h make_fint
@MAINTAINER_MODE_FALSE@ @$(MKDIR_P) .fint; trap 'rm -rf .fint/make.lock .fint/make.stamp' 1 2 13 15; \
@MAINTAINER_MODE_FALSE@ if mkdir .fint/make.lock 2>/dev/null; then \
@MAINTAINER_MODE_FALSE@ rm -f .fint/make.stamp; \
@MAINTAINER_MODE_FALSE@ $(MAKE) $(AM_MAKEFLAGS) make_fint; ec=$$?; \
@MAINTAINER_MODE_FALSE@ test $$ec = 0 && touch .fint/make.stamp; \
@MAINTAINER_MODE_FALSE@ rm -rf .fint/make.lock; exit $$ec; \
@MAINTAINER_MODE_FALSE@ else \
@MAINTAINER_MODE_FALSE@ while test -d .fint/make.lock; do sleep 1; done; \
@MAINTAINER_MODE_FALSE@ test -f .fint/make.stamp || exit 1; fi
$(AM_V_GEN)$(make_fint_run)
cdipio.inc: @MAINTAINER_MODE_TRUE@ cdipioFortran.c
mo_cdi.f90: @MAINTAINER_MODE_TRUE@ $(srcdir)/cdi.h $(top_srcdir)/interfaces/f2003/bindGen.rb
$(AM_V_GEN)$(RUBY) $(top_srcdir)/interfaces/f2003/bindGen.rb $(srcdir)/cdi.h $@
if MAINTAINER_MODE
# Update files in $(srcdir) when building out-of-source:
$(srcdir)/cdiFortran.c $(srcdir)/cdi.inc:
$(srcdir)/cdipioFortran.c $(srcdir)/cdipio.inc:
$(srcdir)/mo_cdi.f90:
# Update files in any configuration:
BUILT_SOURCES = \
cdi.inc \
cdiFortran.c \
cdipio.inc \
cdipioFortran.c \
mo_cdi.f90
endif
......@@ -353,7 +411,8 @@ CLEANFILES += pkgconfig/cdi_f2003.pc
endif
clean-local:
test '.' = '$(srcdir)' || rm -f mo_cdi.f90
@MAINTAINER_MODE_FALSE@ -rm -rf .fint
-test '.' = '$(srcdir)' || rm -f cdi.inc cdiFortran.c cdipio.inc cdipioFortran.c mo_cdi.f90
install-exec-local: $(PKGCONFIG_FILES) $(CMAKECONFIG_FILES)
$(mkinstalldirs) "$(DESTDIR)$(libdir)/pkgconfig"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment