functions.mk 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. all:
  2. test "$(subst e,EE,hello)" = "hEEllo"
  3. test "$(strip $(NULL) test data )" = "test data"
  4. test "$(findstring hell,hello)" = "hell"
  5. test "$(findstring heaven,hello)" = ""
  6. test "$(filter foo/%.c b%,foo/a.c b.c foo/a.o)" = "foo/a.c b.c"
  7. test "$(filter foo,foo bar)" = "foo"
  8. test "$(filter-out foo/%.c b%,foo/a.c b.c foo/a.o)" = "foo/a.o"
  9. test "$(filter-out %.c,foo,bar.c foo,bar.o)" = "foo,bar.o"
  10. test "$(sort .go a b aa A c cc)" = ".go A a aa b c cc"
  11. test "$(word 1, hello )" = "hello"
  12. test "$(word 2, hello )" = ""
  13. test "$(wordlist 1, 2, foo bar baz )" = "foo bar"
  14. test "$(words 1 2 3)" = "3"
  15. test "$(words )" = "0"
  16. test "$(firstword $(NULL) foo bar baz)" = "foo"
  17. test "$(firstword )" = ""
  18. test "$(dir foo.c path/foo.o dir/dir2/)" = "./ path/ dir/dir2/"
  19. test "$(notdir foo.c path/foo.o dir/dir2/)" = "foo.c foo.o "
  20. test "$(suffix src/foo.c dir/my.dir/foo foo.o)" = ".c .o"
  21. test "$(basename src/foo.c dir/my.dir/foo foo.c .c)" = "src/foo dir/my.dir/foo foo "
  22. test "$(addprefix src/,foo bar.c dir/foo)" = "src/foo src/bar.c src/dir/foo"
  23. test "$(addsuffix .c,foo dir/bar)" = "foo.c dir/bar.c"
  24. test "$(join a b c, 1 2 3)" = "a1 b2 c3"
  25. test "$(join a b, 1 2 3)" = "a1 b2 3"
  26. test "$(join a b c, 1 2)" = "a1 b2 c"
  27. test "$(if $(NULL) ,yes)" = ""
  28. test "$(if 1,yes,no)" = "yes"
  29. test "$(if ,yes,no )" = "no "
  30. test "$(if ,$(error Short-circuit problem))" = ""
  31. test "$(or $(NULL),1)" = "1"
  32. test "$(or $(NULL),2,$(warning TEST-FAIL bad or short-circuit))" = "2"
  33. test "$(and ,$(warning TEST-FAIL bad and short-circuit))" = ""
  34. test "$(and 1,2)" = "2"
  35. test "$(foreach i,foo bar,found:$(i))" = "found:foo found:bar"
  36. @echo TEST-PASS