1 | # $Id: example-spaces.kmk 3316 2020-03-31 01:13:22Z bird $
|
---|
2 | ## @file
|
---|
3 | # kBuild - examples of GNU make filename quoting (escaping).
|
---|
4 | #
|
---|
5 |
|
---|
6 | #
|
---|
7 | # Copyright (c) 2020 knut st. osmundsen <[email protected]>
|
---|
8 | #
|
---|
9 | # This file is part of kBuild.
|
---|
10 | #
|
---|
11 | # kBuild is free software; you can redistribute it and/or modify
|
---|
12 | # it under the terms of the GNU General Public License as published by
|
---|
13 | # the Free Software Foundation; either version 3 of the License, or
|
---|
14 | # (at your option) any later version.
|
---|
15 | #
|
---|
16 | # kBuild is distributed in the hope that it will be useful,
|
---|
17 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
18 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
19 | # GNU General Public License for more details.
|
---|
20 | #
|
---|
21 | # You should have received a copy of the GNU General Public License
|
---|
22 | # along with kBuild. If not, see <http://www.gnu.org/licenses/>
|
---|
23 | #
|
---|
24 | #
|
---|
25 |
|
---|
26 |
|
---|
27 | all: \
|
---|
28 | phoney\ space\ \ 1 \
|
---|
29 | phoney\ colon\:\ 2 \
|
---|
30 | phoney\ hash\#\ 3 \
|
---|
31 | phoney\ dollar$$\ 4 \
|
---|
32 | phoney\ slash-space\\\ 5 \
|
---|
33 | phoney\ slash-hash\\\#\ 6 \
|
---|
34 | phoney\ slash-slash-hash\\\\\#\ 7 \
|
---|
35 | phoney\ percent%\ 10 \
|
---|
36 | phoney\ pipe\|\ 11 \
|
---|
37 | phoney\ plus+\ 12 \
|
---|
38 | all-trailing-slashes1 \
|
---|
39 | all-trailing-slashes2 \
|
---|
40 | all-trailing-slashes3 \
|
---|
41 | all-trailing-spaces1 \
|
---|
42 | all-trailing-spaces2 \
|
---|
43 | all-trailing-spaces3 \
|
---|
44 | all-trailing-spaces4 \
|
---|
45 | phoney\ 19-target-trailing-space-with-padding\ ignore \
|
---|
46 | phoney\ 20-target-trailing-space-with-newline-padding\ ignore \
|
---|
47 | phoney\ 21-target-trailing-space-with-newline-padding-and-tail\ my-tail-21
|
---|
48 |
|
---|
49 |
|
---|
50 | ignore:
|
---|
51 |
|
---|
52 | #
|
---|
53 | # Trailing slashes are complicated in dependency lists:
|
---|
54 | #
|
---|
55 |
|
---|
56 | # Variant #1: Must have a line-continutation to work if last in the list, but no extra escaping.
|
---|
57 | # This doesn't work: all-trailing-slashes1: phoney\ trailing-slash13\
|
---|
58 | # This doesn't work: all-trailing-slashes1: phoney\ trailing-slash13\\
|
---|
59 | all-trailing-slashes1: phoney\ trailing-slash13\ \
|
---|
60 |
|
---|
61 | all-trailing-slashes2: phoney\ trailing-slash13b\ \
|
---|
62 | \
|
---|
63 | \
|
---|
64 | \
|
---|
65 |
|
---|
66 | # Variant #2: If there are more dependencies following it, we must escape the trailing slash
|
---|
67 | all-trailing-slashes3: \
|
---|
68 | phoney\ trailing-slash14\\ \
|
---|
69 | phoney\ space\ \ 1 # whatever
|
---|
70 |
|
---|
71 | #
|
---|
72 | # Trailing spaces only works if there is a target following on the same line.
|
---|
73 | #
|
---|
74 | all-trailing-spaces1: phoney\ 15-trailing-space\ phoney_simple
|
---|
75 |
|
---|
76 | # Note! No stripping spaces! Trailing space here that gets stripped instead of escaped.
|
---|
77 | all-trailing-spaces2: phoney\ 16-no-trailing-space\
|
---|
78 |
|
---|
79 | all-trailing-spaces3: phoney\ 17-3x-escaped-newlines\ \
|
---|
80 | \
|
---|
81 | \
|
---|
82 | becomes-single-space
|
---|
83 |
|
---|
84 | # Note! Must have a trailing space or comment.
|
---|
85 | all-trailing-spaces4: phoney\ 18-3x-escaped-trailing-spaces-no-newline\ \ \ #
|
---|
86 |
|
---|
87 |
|
---|
88 | #
|
---|
89 | # TODO
|
---|
90 | #
|
---|
91 |
|
---|
92 | #busted: phoney\ equal\=\ 8 \
|
---|
93 | #impossible: phoney\ semi\;\ 9 \
|
---|
94 |
|
---|
95 |
|
---|
96 | #
|
---|
97 | # The rules.
|
---|
98 | #
|
---|
99 |
|
---|
100 | phoney_simple:
|
---|
101 |
|
---|
102 | phoney\ space\ \ 1:
|
---|
103 | echo "#1: '$@'"
|
---|
104 |
|
---|
105 | phoney\ colon\:\ 2:
|
---|
106 | echo "#2: '$@'"
|
---|
107 |
|
---|
108 | phoney\ hash\#\ 3 :
|
---|
109 | echo "#3: '$@'"
|
---|
110 |
|
---|
111 | phoney\ dollar$$\ 4 :
|
---|
112 | echo "#4: '$@'"
|
---|
113 |
|
---|
114 | phoney\ slash-space\\\ 5:
|
---|
115 | echo "#5: '$@'"
|
---|
116 |
|
---|
117 | phoney\ slash-hash\\\#\ 6:
|
---|
118 | echo "#6: '$@'"
|
---|
119 |
|
---|
120 | phoney\ slash-slash-hash\\\\\#\ 7:
|
---|
121 | echo "#7: '$@'"
|
---|
122 |
|
---|
123 | ## This is busted:
|
---|
124 | #phoney\ equal=\ 8:
|
---|
125 | # echo "#8: '$@'"
|
---|
126 |
|
---|
127 | ## This seems impossible:
|
---|
128 | #phoney\ semi\;:
|
---|
129 | # echo "#9: '$@'"
|
---|
130 |
|
---|
131 | phoney\ percent\%\ 10: # Note! The percent is only escaped on the target side!
|
---|
132 | echo "#10: '$@'"
|
---|
133 |
|
---|
134 | phoney\ pipe|\ 11: # Note! The pipe is only escaped on the dependency list side!
|
---|
135 | echo "#11: '$@'"
|
---|
136 |
|
---|
137 | phoney\ plus+\ 12:
|
---|
138 | echo "#12: '$@'"
|
---|
139 |
|
---|
140 | phoney\ trailing-slash13\\:
|
---|
141 | echo "#13: '$@'"
|
---|
142 |
|
---|
143 | phoney\ trailing-slash13b\\:
|
---|
144 | echo "#13b: '$@'"
|
---|
145 |
|
---|
146 | phoney\ trailing-slash14\\:
|
---|
147 | echo "#14: '$@'"
|
---|
148 |
|
---|
149 | phoney\ 15-trailing-space\ :
|
---|
150 | echo "#15: '$@'"
|
---|
151 |
|
---|
152 | phoney\ 16-no-trailing-space\\:
|
---|
153 | echo "#16: '$@'"
|
---|
154 |
|
---|
155 | phoney\ 17-3x-escaped-newlines\ becomes-single-space:
|
---|
156 | echo "#17: '$@'"
|
---|
157 |
|
---|
158 | phoney\ 18-3x-escaped-trailing-spaces-no-newline\ \ \\:
|
---|
159 | echo "#18: '$@'"
|
---|
160 |
|
---|
161 | phoney\ 19-target-trailing-space-with-padding\ :
|
---|
162 | echo "#19: '$@'"
|
---|
163 |
|
---|
164 | phoney\ 20-target-trailing-space-with-newline-padding\ \
|
---|
165 | \
|
---|
166 | :
|
---|
167 | echo "#20: '$@'"
|
---|
168 |
|
---|
169 | phoney\ 21-target-trailing-space-with-newline-padding-and-tail\ \
|
---|
170 | \
|
---|
171 | \
|
---|
172 | \
|
---|
173 | my-tail-21:
|
---|
174 | echo "#21: '$@'"
|
---|
175 |
|
---|