Commit 57e9f637 authored by Lorenz Huedepohl's avatar Lorenz Huedepohl
Browse files

Recursively include dependencies via LDADD/LIBADD

Now, also module provided via automake _LDADD/_LIBADD statements are
considered and added as dependencies, if used by the target.
parent 189a54b0
......@@ -4,10 +4,14 @@
# see the file LICENSE for more information
#
define translate_name
$(subst -,_,$(subst .,_,$1))
endef
_f90_verbose = $(_f90_verbose_$(V))
_f90_verbose_ = $(_f90_verbose_$(AM_DEFAULT_VERBOSITY))
_f90_verbose_0 = @echo " $1";
_f90_targets = $(subst -,_,$(subst .,_,$(PROGRAMS) $(LTLIBRARIES)))
_f90_targets = $(call translate_name,$(PROGRAMS) $(LTLIBRARIES))
FORTRAN_CPP ?= cpp -P -traditional -Wall -Werror
......@@ -53,7 +57,7 @@ $(dir $1)$(2)$(call strip_fortran_ext,$(notdir $1)).use_mods.$(call object_exten
$(eval _$(3)_def_mods += $(dir $1)$(2)$(call strip_fortran_ext,$(notdir $1)).def_mods.$(call object_extension,$3))
$(dir $1)$(2)$(call strip_fortran_ext,$(notdir $1)).def_mods.$(call object_extension,$3): $1 $(dir $1)$(am__dirstamp)
$(call _f90_verbose,F90 MOD [$3] $$<)$(FORTRAN_CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $($p_CPPFLAGS) $(CPPFLAGS) -o /dev/stdout $$< | grep -i -o '^ *module [^!]*' | tr '[:upper:]' '[:lower:]' | grep -v "\<procedure\>" > $$@ || true
$(call _f90_verbose,F90 MOD [$3] $$<)$(FORTRAN_CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $($p_CPPFLAGS) $(CPPFLAGS) -o /dev/stdout $$< | grep -i -o '^ *module [^!]*' | tr '[:upper:]' '[:lower:]' | grep -v "\<procedure\>\|\<intrinsic\>" > $$@ || true
endef
$(foreach p,$(_f90_targets),$(if $(call is_per_target,$p),$(foreach s,$(call fortran_sources,$p),$(eval $(call module_targets,$s,$p-,$p))),$(foreach s,$(call fortran_sources,$p),$(eval $(call module_targets,$s,,$p)))))
......@@ -61,6 +65,11 @@ $(foreach p,$(_f90_targets),$(if $(call is_per_target,$p),$(foreach s,$(call for
_f90_depdir=$(abs_builddir)/.fortran_dependencies
_f90_depfile = $(_f90_depdir)/dependencies.mk
# $1 target-name
define recursive_lib_deps
$(foreach l,$(call translate_name,$($1_LDADD) $($1_LIBADD)),$l $(call recursive_lib_deps,$l))
endef
define is_clean
$(if $(filter-out mostlyclean clean distclean maintainer-clean,$(MAKECMDGOALS)),0,1)
endef
......@@ -69,7 +78,7 @@ ifneq ($(call is_clean),1)
include $(_f90_depfile)
endif
$(_f90_depfile): $(top_srcdir)/fdep/fortran_dependencies.pl $(foreach p,$(_f90_targets),$(_$p_use_mods) $(_$p_def_mods)) | $(foreach p,$(_f90_targets),$(_f90_depdir)/$p)
$(call _f90_verbose,F90 DEPS $@)echo > $@; $(foreach p,$(_f90_targets),$(top_srcdir)/fdep/fortran_dependencies.pl $p $(_$p_use_mods) $(_$p_def_mods) >> $@; )
$(call _f90_verbose,F90 DEPS $@)echo > $@; $(foreach p,$(_f90_targets),$(top_srcdir)/fdep/fortran_dependencies.pl $p $(_$p_use_mods) $(_$p_def_mods) $(foreach l,$(call recursive_lib_deps,$p),$(_$l_use_mods) $(_$l_def_mods)) >> $@; )
$(_f90_depdir):
@mkdir $@
......
......@@ -10,6 +10,7 @@ use strict;
my %defs = ();
my %uses = ();
my %files = ();
my $use_re = qr/^\s*use\s+(\S+)\s*$/;
my $def_re = qr/^\s*module\s+(\S+)\s*$/;
......@@ -42,6 +43,11 @@ sub add_def {
my $target = shift;
foreach my $file (@ARGV) {
if (exists $files{$file}) {
next;
} else {
$files{$file} = 1;
}
my $re;
my $add;
my $object;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment