Browse code

Fix E2BIG errors ("argument list too long")

Rewrote the perl-script for the dependency generation to also accept
input file names from stdin, in order to avoid excessively large
argument lists.

Lorenz Hüdepohl authored on11/07/2016 10:36:09
Showing2 changed files
... ...
@@ -11,6 +11,9 @@ endef
11 11
 _f90_verbose = $(_f90_verbose_$(V))
12 12
 _f90_verbose_ = $(_f90_verbose_$(AM_DEFAULT_VERBOSITY))
13 13
 _f90_verbose_0 = @echo "  $1";
14
+_f90_only_verbose = $(_f90_only_verbose_$(V))
15
+_f90_only_verbose_ = @
16
+_f90_only_verbose_0 = @
14 17
 _f90_targets = $(call translate_name,$(PROGRAMS) $(LTLIBRARIES))
15 18
 
16 19
 FORTRAN_CPP ?= cpp -P -traditional -Wall -Werror
... ...
@@ -87,8 +90,26 @@ endef
87 90
 ifneq ($(call is_clean),1)
88 91
 include $(_f90_depfile)
89 92
 endif
93
+
94
+# $1 string
95
+# $2 file
96
+define append_to
97
+	$(_f90_only_verbose)echo '$1' >> $2
98
+
99
+endef
100
+
101
+# $1 program
102
+define program_dependencies
103
+	$(_f90_only_verbose)rm -f .$p.dep.args
104
+	$(foreach argument,$(_$p_use_mods) $(_$p_def_mods) $(foreach l,$(call recursive_lib_deps,$p),$(_$l_use_mods) $(_$l_def_mods)),$(call append_to,$(argument),.$p.dep.args))
105
+	$(_f90_only_verbose)$(top_srcdir)/fdep/fortran_dependencies.pl $p < .$p.dep.args >> $@ || { rm $@; exit 1; }
106
+	$(_f90_only_verbose)rm -f .$p.dep.args
107
+
108
+endef
109
+
90 110
 $(_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)
91
-	$(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)) >> $@; )
111
+	$(call _f90_verbose,F90 DEPS $@)echo > $@;
112
+	$(foreach p,$(_f90_targets),$(call program_dependencies,$p))
92 113
 
93 114
 $(_f90_depdir):
94 115
 	@mkdir $@
... ...
@@ -42,7 +42,8 @@ sub add_def {
42 42
 
43 43
 my $target = shift;
44 44
 
45
-foreach my $file (@ARGV) {
45
+foreach my $file (<>) {
46
+	chomp($file);
46 47
 	if (exists $files{$file}) {
47 48
 		next;
48 49
 	} else {