varmod-head.mk revision 1.6 1 # $NetBSD: varmod-head.mk,v 1.6 2024/06/01 18:44:05 rillig Exp $
2 #
3 # Tests for the :H variable modifier, which returns the dirname of
4 # each of the words in the variable value.
5
6 .if ${:U a/b/c :H} != "a/b"
7 . error
8 .endif
9
10 .if ${:U def :H} != "."
11 . error
12 .endif
13
14 .if ${:U a.b.c :H} != "."
15 . error
16 .endif
17
18 .if ${:U a.b/c :H} != "a.b"
19 . error
20 .endif
21
22 .if ${:U a :H} != "."
23 . error
24 .endif
25
26 .if ${:U a.a :H} != "."
27 . error
28 .endif
29
30 .if ${:U .gitignore :H} != "."
31 . error
32 .endif
33
34 .if ${:U trailing/ :H} != "trailing"
35 . error
36 .endif
37
38 .if ${:U /abs/dir/file :H} != "/abs/dir"
39 . error
40 .endif
41
42 .if ${:U rel/dir/file :H} != "rel/dir"
43 . error
44 .endif
45
46 # The head of "/" was an empty string before 2020.07.20.14.50.41, leading to
47 # the output "before after", with two spaces. Since 2020.07.20.14.50.41, the
48 # output is "before after", discarding the empty word.
49 .if ${:U before/ / after/ :H} == "before after"
50 # OK
51 .elif ${:U before/ / after/ :H} == "before after"
52 # No '.info' to keep the file compatible with old make versions.
53 _!= echo "The modifier ':H' generates an empty word." 1>&2; echo
54 .else
55 . error
56 .endif
57
58 # An empty list is split into a single empty word.
59 # The dirname of this empty word is ".".
60 .if ${:U :H} != "."
61 . error
62 .endif
63
64 # If the ':H' is not directly followed by a delimiting ':' or '}', the
65 # ':from=to' modifier is tried as a fallback.
66 .if ${:U Head :Head=replaced} != "replaced"
67 . error
68 .endif
69
70 all: .PHONY
71