summaryrefslogtreecommitdiff
path: root/tests/scripts/functions
diff options
context:
space:
mode:
Diffstat (limited to 'tests/scripts/functions')
-rw-r--r--tests/scripts/functions/call16
1 files changed, 14 insertions, 2 deletions
diff --git a/tests/scripts/functions/call b/tests/scripts/functions/call
index bdb8e89..a8834cd 100644
--- a/tests/scripts/functions/call
+++ b/tests/scripts/functions/call
@@ -31,6 +31,15 @@ my-if = $(if $(1),$(2),$(3))
one = $(1) $(2) $(3)
two = $(call one,$(1),foo,$(2))
+# Test recursion on the user-defined function. As a special case make
+# won't error due to this.
+# Implement transitive closure using $(call ...)
+#
+DEP_foo = bar baz quux
+DEP_baz = quux blarp
+rest = $(wordlist 2,$(words ${1}),${1})
+tclose = $(if $1,$(firstword $1) \
+ $(call tclose,$(sort ${DEP_$(firstword $1)} $(call rest,$1))))
all: ; @echo '$(call reverse,bar,foo)'; \
echo '$(call map,origin,MAKE reverse map)'; \
@@ -38,7 +47,10 @@ all: ; @echo '$(call reverse,bar,foo)'; \
echo '$(call my-foreach)'; \
echo '$(call my-foreach,a,,,)'; \
echo '$(call my-if,a,b,c)'; \
- echo '$(call two,bar,baz)'
+ echo '$(call two,bar,baz)'; \
+ echo '$(call tclose,foo)'
+
+
EOMAKE
@@ -53,7 +65,7 @@ EOMAKE
close(MAKEFILE);
&run_make_with_options($makefile, "", &get_logfile);
-$answer = "foo bar\ndefault file file\nb d f\n\n\nb\nbar foo baz\n";
+$answer = "foo bar\ndefault file file\nb d f\n\n\nb\nbar foo baz\nfoo bar baz blarp quux \n";
&compare_output($answer, &get_logfile(1));