call 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. # -*-perl-*-
  2. $description = "Test the call function.\n";
  3. $details = "Try various uses of call and ensure they all give the correct
  4. results.\n";
  5. open(MAKEFILE, "> $makefile");
  6. # The Contents of the MAKEFILE ...
  7. print MAKEFILE <<'EOMAKE';
  8. # Simple, just reverse two things
  9. #
  10. reverse = $2 $1
  11. # A complex `map' function, using recursive `call'.
  12. #
  13. map = $(foreach a,$2,$(call $1,$a))
  14. # Test using a builtin; this is silly as it's simpler to do without call
  15. #
  16. my-notdir = $(call notdir,$(1))
  17. # Test using non-expanded builtins
  18. #
  19. my-foreach = $(foreach $(1),$(2),$(3))
  20. my-if = $(if $(1),$(2),$(3))
  21. # Test recursive invocations of call with different arguments
  22. #
  23. one = $(1) $(2) $(3)
  24. two = $(call one,$(1),foo,$(2))
  25. all: ; @echo '$(call reverse,bar,foo)'; \
  26. echo '$(call map,origin,MAKE reverse map)'; \
  27. echo '$(call my-notdir,a/b c/d e/f)'; \
  28. echo '$(call my-foreach)'; \
  29. echo '$(call my-foreach,a,,,)'; \
  30. echo '$(call my-if,a,b,c)'; \
  31. echo '$(call two,bar,baz)'
  32. EOMAKE
  33. # These won't work until/unless PR/1527 is resolved.
  34. # echo '$(call my-foreach,a,x y z,$(a)$(a))'; \
  35. # echo '$(call my-if,,$(warning don't print this),ok)'
  36. #
  37. # $answer = "xx yy zz\nok\n";
  38. # END of Contents of MAKEFILE
  39. close(MAKEFILE);
  40. &run_make_with_options($makefile, "", &get_logfile);
  41. $answer = "foo bar\ndefault file file\nb d f\n\n\nb\nbar foo baz\n";
  42. &compare_output($answer, &get_logfile(1));
  43. 1;