1
1
#
2
+ # ===========================================================================
3
+ # (c) Copyright IBM Corp. 2017, 2018 All Rights Reserved
4
+ # ===========================================================================
5
+ #
2
6
# Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
3
7
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
8
#
33
37
ifndef _MAKEBASE_GMK
34
38
_MAKEBASE_GMK := 1
35
39
40
+ ################################################################################
41
+ # This macro translates $ into \$ to protect the $ from expansion in the shell.
42
+ # To make this macro resilient against already escaped strings, first remove
43
+ # any present escapes before escaping so that no double escapes are added.
44
+ EscapeDollar = $(subst $$,\$$,$(subst \$$,$$,$(strip $1)))
45
+
36
46
# If the variable that you want to send to stdout for piping into a file or otherwise,
37
47
# is potentially long, for example the a list of file paths, eg a list of all package directories.
38
48
# Then you need to use ListPathsSafely, which optimistically splits the output into several shell
39
49
# calls as well as use compression on recurrent file paths segments, to get around the potential
40
50
# command line length problem that exists in cygwin and other shells.
41
- compress_pre:=$(strip $(shell $(CAT) $(SRC_ROOT)/make/common/support/ListPathsSafely-pre-compress.incl))
42
- compress_post:=$(strip $(shell $(CAT) $(SRC_ROOT)/make/common/support/ListPathsSafely-post-compress.incl))
43
- compress_paths=$(compress_pre)\
44
- $(subst $(SRC_ROOT),X97,\
45
- $(subst $(OUTPUT_ROOT),X98,\
46
- $(subst X,X00,\
47
- $(subst $(SPACE),\n,$(strip $1)))))\
48
- $(compress_post)
51
+ $(eval compress_paths = \
52
+ $(strip $(shell $(CAT) $(SRC_ROOT)/make/common/support/ListPathsSafely-pre-compress.incl)))
53
+ compress_paths += \
54
+ $(subst $(SRC_ROOT),X97, \
55
+ $(subst $(OUTPUT_ROOT),X98, \
56
+ $(subst X,X00, \
57
+ $(subst $(SPACE),\n,$(strip $1)))))
58
+ $(eval compress_paths += \
59
+ $(strip $(shell $(CAT) $(SRC_ROOT)/make/common/support/ListPathsSafely-post-compress.incl)))
49
60
50
61
decompress_paths=$(SED) -f $(SRC_ROOT)/make/common/support/ListPathsSafely-uncompress.sed -e 's|X99|\\n|g' \
51
62
-e 's|X98|$(OUTPUT_ROOT)|g' -e 's|X97|$(SRC_ROOT)|g' \
52
63
-e 's|X00|X|g' | tr '\n' '$2'
53
64
54
- define ListPathsSafely_If
55
- $(if $(word $3,$($1)),$(eval $1_LPS$3:=$(call compress_paths,$(wordlist $3,$4,$($1)))))
56
- endef
57
-
58
- define ListPathsSafely_Printf
59
- $(if $(strip $($1_LPS$4)),$(if $(findstring $(LOG_LEVEL),trace),,@)printf \
60
- -- "$(strip $($1_LPS$4))\n" | $(decompress_paths) $3)
65
+ define ListPathsSafely_IfPrintf
66
+ $(if $(word $4,$($1)), \
67
+ @printf -- "$(strip $(call EscapeDollar, \
68
+ $(call compress_paths,$(wordlist $4,$5,$($1)))))\\n" | $(decompress_paths) $3)
61
69
endef
62
70
63
71
# Receipt example:
@@ -67,166 +75,86 @@ endef
67
75
# if instead , , (a space) is supplied, then spaces remain spaces.
68
76
define ListPathsSafely
69
77
$(if $(word 16001,$($1)),$(error Cannot list safely more than 16000 paths. $1 has $(words $($1)) paths!))
70
- $(ECHO) $(LOG_DEBUG) Writing $(words $($1)) paths to '$3'
71
- $(call ListPathsSafely_If,$1,$2,1,250)
72
- $(call ListPathsSafely_If,$1,$2,251,500)
73
- $(call ListPathsSafely_If,$1,$2,501,750)
74
- $(call ListPathsSafely_If,$1,$2,751,1000)
75
-
76
- $(call ListPathsSafely_If,$1,$2,1001,1250)
77
- $(call ListPathsSafely_If,$1,$2,1251,1500)
78
- $(call ListPathsSafely_If,$1,$2,1501,1750)
79
- $(call ListPathsSafely_If,$1,$2,1751,2000)
80
-
81
- $(call ListPathsSafely_If,$1,$2,2001,2250)
82
- $(call ListPathsSafely_If,$1,$2,2251,2500)
83
- $(call ListPathsSafely_If,$1,$2,2501,2750)
84
- $(call ListPathsSafely_If,$1,$2,2751,3000)
85
-
86
- $(call ListPathsSafely_If,$1,$2,3001,3250)
87
- $(call ListPathsSafely_If,$1,$2,3251,3500)
88
- $(call ListPathsSafely_If,$1,$2,3501,3750)
89
- $(call ListPathsSafely_If,$1,$2,3751,4000)
90
-
91
- $(call ListPathsSafely_If,$1,$2,4001,4250)
92
- $(call ListPathsSafely_If,$1,$2,4251,4500)
93
- $(call ListPathsSafely_If,$1,$2,4501,4750)
94
- $(call ListPathsSafely_If,$1,$2,4751,5000)
95
-
96
- $(call ListPathsSafely_If,$1,$2,5001,5250)
97
- $(call ListPathsSafely_If,$1,$2,5251,5500)
98
- $(call ListPathsSafely_If,$1,$2,5501,5750)
99
- $(call ListPathsSafely_If,$1,$2,5751,6000)
100
-
101
- $(call ListPathsSafely_If,$1,$2,6001,6250)
102
- $(call ListPathsSafely_If,$1,$2,6251,6500)
103
- $(call ListPathsSafely_If,$1,$2,6501,6750)
104
- $(call ListPathsSafely_If,$1,$2,6751,7000)
105
-
106
- $(call ListPathsSafely_If,$1,$2,7001,7250)
107
- $(call ListPathsSafely_If,$1,$2,7251,7500)
108
- $(call ListPathsSafely_If,$1,$2,7501,7750)
109
- $(call ListPathsSafely_If,$1,$2,7751,8000)
110
-
111
- $(call ListPathsSafely_If,$1,$2,8001,8250)
112
- $(call ListPathsSafely_If,$1,$2,8251,8500)
113
- $(call ListPathsSafely_If,$1,$2,8501,8750)
114
- $(call ListPathsSafely_If,$1,$2,8751,9000)
115
-
116
- $(call ListPathsSafely_If,$1,$2,9001,9250)
117
- $(call ListPathsSafely_If,$1,$2,9251,9500)
118
- $(call ListPathsSafely_If,$1,$2,9501,9750)
119
- $(call ListPathsSafely_If,$1,$2,9751,10000)
120
-
121
- $(call ListPathsSafely_If,$1,$2,10001,10250)
122
- $(call ListPathsSafely_If,$1,$2,10251,10500)
123
- $(call ListPathsSafely_If,$1,$2,10501,10750)
124
- $(call ListPathsSafely_If,$1,$2,10751,11000)
125
-
126
- $(call ListPathsSafely_If,$1,$2,11001,11250)
127
- $(call ListPathsSafely_If,$1,$2,11251,11500)
128
- $(call ListPathsSafely_If,$1,$2,11501,11750)
129
- $(call ListPathsSafely_If,$1,$2,11751,12000)
130
-
131
- $(call ListPathsSafely_If,$1,$2,12001,12250)
132
- $(call ListPathsSafely_If,$1,$2,12251,12500)
133
- $(call ListPathsSafely_If,$1,$2,12501,12750)
134
- $(call ListPathsSafely_If,$1,$2,12751,13000)
135
-
136
- $(call ListPathsSafely_If,$1,$2,13001,13250)
137
- $(call ListPathsSafely_If,$1,$2,13251,13500)
138
- $(call ListPathsSafely_If,$1,$2,13501,13750)
139
- $(call ListPathsSafely_If,$1,$2,13751,14000)
140
-
141
- $(call ListPathsSafely_If,$1,$2,14001,14250)
142
- $(call ListPathsSafely_If,$1,$2,14251,14500)
143
- $(call ListPathsSafely_If,$1,$2,14501,14750)
144
- $(call ListPathsSafely_If,$1,$2,14751,15000)
145
-
146
- $(call ListPathsSafely_If,$1,$2,15001,15250)
147
- $(call ListPathsSafely_If,$1,$2,15251,15500)
148
- $(call ListPathsSafely_If,$1,$2,15501,15750)
149
- $(call ListPathsSafely_If,$1,$2,15751,16000)
150
-
151
- $(call ListPathsSafely_Printf,$1,$2,$3,1)
152
- $(call ListPathsSafely_Printf,$1,$2,$3,251)
153
- $(call ListPathsSafely_Printf,$1,$2,$3,501)
154
- $(call ListPathsSafely_Printf,$1,$2,$3,751)
155
-
156
- $(call ListPathsSafely_Printf,$1,$2,$3,1001)
157
- $(call ListPathsSafely_Printf,$1,$2,$3,1251)
158
- $(call ListPathsSafely_Printf,$1,$2,$3,1501)
159
- $(call ListPathsSafely_Printf,$1,$2,$3,1751)
160
-
161
- $(call ListPathsSafely_Printf,$1,$2,$3,2001)
162
- $(call ListPathsSafely_Printf,$1,$2,$3,2251)
163
- $(call ListPathsSafely_Printf,$1,$2,$3,2501)
164
- $(call ListPathsSafely_Printf,$1,$2,$3,2751)
165
-
166
- $(call ListPathsSafely_Printf,$1,$2,$3,3001)
167
- $(call ListPathsSafely_Printf,$1,$2,$3,3251)
168
- $(call ListPathsSafely_Printf,$1,$2,$3,3501)
169
- $(call ListPathsSafely_Printf,$1,$2,$3,3751)
170
-
171
- $(call ListPathsSafely_Printf,$1,$2,$3,4001)
172
- $(call ListPathsSafely_Printf,$1,$2,$3,4251)
173
- $(call ListPathsSafely_Printf,$1,$2,$3,4501)
174
- $(call ListPathsSafely_Printf,$1,$2,$3,4751)
175
-
176
- $(call ListPathsSafely_Printf,$1,$2,$3,5001)
177
- $(call ListPathsSafely_Printf,$1,$2,$3,5251)
178
- $(call ListPathsSafely_Printf,$1,$2,$3,5501)
179
- $(call ListPathsSafely_Printf,$1,$2,$3,5751)
180
-
181
- $(call ListPathsSafely_Printf,$1,$2,$3,6001)
182
- $(call ListPathsSafely_Printf,$1,$2,$3,6251)
183
- $(call ListPathsSafely_Printf,$1,$2,$3,6501)
184
- $(call ListPathsSafely_Printf,$1,$2,$3,6751)
185
-
186
- $(call ListPathsSafely_Printf,$1,$2,$3,7001)
187
- $(call ListPathsSafely_Printf,$1,$2,$3,7251)
188
- $(call ListPathsSafely_Printf,$1,$2,$3,7501)
189
- $(call ListPathsSafely_Printf,$1,$2,$3,7751)
190
-
191
- $(call ListPathsSafely_Printf,$1,$2,$3,8001)
192
- $(call ListPathsSafely_Printf,$1,$2,$3,8251)
193
- $(call ListPathsSafely_Printf,$1,$2,$3,8501)
194
- $(call ListPathsSafely_Printf,$1,$2,$3,8751)
195
-
196
- $(call ListPathsSafely_Printf,$1,$2,$3,9001)
197
- $(call ListPathsSafely_Printf,$1,$2,$3,9251)
198
- $(call ListPathsSafely_Printf,$1,$2,$3,9501)
199
- $(call ListPathsSafely_Printf,$1,$2,$3,9751)
200
-
201
- $(call ListPathsSafely_Printf,$1,$2,$3,10001)
202
- $(call ListPathsSafely_Printf,$1,$2,$3,10251)
203
- $(call ListPathsSafely_Printf,$1,$2,$3,10501)
204
- $(call ListPathsSafely_Printf,$1,$2,$3,10751)
205
-
206
- $(call ListPathsSafely_Printf,$1,$2,$3,11001)
207
- $(call ListPathsSafely_Printf,$1,$2,$3,11251)
208
- $(call ListPathsSafely_Printf,$1,$2,$3,11501)
209
- $(call ListPathsSafely_Printf,$1,$2,$3,11751)
210
-
211
- $(call ListPathsSafely_Printf,$1,$2,$3,12001)
212
- $(call ListPathsSafely_Printf,$1,$2,$3,12251)
213
- $(call ListPathsSafely_Printf,$1,$2,$3,12501)
214
- $(call ListPathsSafely_Printf,$1,$2,$3,12751)
215
-
216
- $(call ListPathsSafely_Printf,$1,$2,$3,13001)
217
- $(call ListPathsSafely_Printf,$1,$2,$3,13251)
218
- $(call ListPathsSafely_Printf,$1,$2,$3,13501)
219
- $(call ListPathsSafely_Printf,$1,$2,$3,13751)
220
-
221
- $(call ListPathsSafely_Printf,$1,$2,$3,14001)
222
- $(call ListPathsSafely_Printf,$1,$2,$3,14251)
223
- $(call ListPathsSafely_Printf,$1,$2,$3,14501)
224
- $(call ListPathsSafely_Printf,$1,$2,$3,14751)
225
-
226
- $(call ListPathsSafely_Printf,$1,$2,$3,15001)
227
- $(call ListPathsSafely_Printf,$1,$2,$3,15251)
228
- $(call ListPathsSafely_Printf,$1,$2,$3,15501)
229
- $(call ListPathsSafely_Printf,$1,$2,$3,15751)
78
+ @$(ECHO) $(LOG_DEBUG) Writing $(words $($1)) paths to '$3'
79
+ $(call ListPathsSafely_IfPrintf,$1,$2,$3,1,250)
80
+ $(call ListPathsSafely_IfPrintf,$1,$2,$3,251,500)
81
+ $(call ListPathsSafely_IfPrintf,$1,$2,$3,501,750)
82
+ $(call ListPathsSafely_IfPrintf,$1,$2,$3,751,1000)
83
+
84
+ $(call ListPathsSafely_IfPrintf,$1,$2,$3,1001,1250)
85
+ $(call ListPathsSafely_IfPrintf,$1,$2,$3,1251,1500)
86
+ $(call ListPathsSafely_IfPrintf,$1,$2,$3,1501,1750)
87
+ $(call ListPathsSafely_IfPrintf,$1,$2,$3,1751,2000)
88
+
89
+ $(call ListPathsSafely_IfPrintf,$1,$2,$3,2001,2250)
90
+ $(call ListPathsSafely_IfPrintf,$1,$2,$3,2251,2500)
91
+ $(call ListPathsSafely_IfPrintf,$1,$2,$3,2501,2750)
92
+ $(call ListPathsSafely_IfPrintf,$1,$2,$3,2751,3000)
93
+
94
+ $(call ListPathsSafely_IfPrintf,$1,$2,$3,3001,3250)
95
+ $(call ListPathsSafely_IfPrintf,$1,$2,$3,3251,3500)
96
+ $(call ListPathsSafely_IfPrintf,$1,$2,$3,3501,3750)
97
+ $(call ListPathsSafely_IfPrintf,$1,$2,$3,3751,4000)
98
+
99
+ $(call ListPathsSafely_IfPrintf,$1,$2,$3,4001,4250)
100
+ $(call ListPathsSafely_IfPrintf,$1,$2,$3,4251,4500)
101
+ $(call ListPathsSafely_IfPrintf,$1,$2,$3,4501,4750)
102
+ $(call ListPathsSafely_IfPrintf,$1,$2,$3,4751,5000)
103
+
104
+ $(call ListPathsSafely_IfPrintf,$1,$2,$3,5001,5250)
105
+ $(call ListPathsSafely_IfPrintf,$1,$2,$3,5251,5500)
106
+ $(call ListPathsSafely_IfPrintf,$1,$2,$3,5501,5750)
107
+ $(call ListPathsSafely_IfPrintf,$1,$2,$3,5751,6000)
108
+
109
+ $(call ListPathsSafely_IfPrintf,$1,$2,$3,6001,6250)
110
+ $(call ListPathsSafely_IfPrintf,$1,$2,$3,6251,6500)
111
+ $(call ListPathsSafely_IfPrintf,$1,$2,$3,6501,6750)
112
+ $(call ListPathsSafely_IfPrintf,$1,$2,$3,6751,7000)
113
+
114
+ $(call ListPathsSafely_IfPrintf,$1,$2,$3,7001,7250)
115
+ $(call ListPathsSafely_IfPrintf,$1,$2,$3,7251,7500)
116
+ $(call ListPathsSafely_IfPrintf,$1,$2,$3,7501,7750)
117
+ $(call ListPathsSafely_IfPrintf,$1,$2,$3,7751,8000)
118
+
119
+ $(call ListPathsSafely_IfPrintf,$1,$2,$3,8001,8250)
120
+ $(call ListPathsSafely_IfPrintf,$1,$2,$3,8251,8500)
121
+ $(call ListPathsSafely_IfPrintf,$1,$2,$3,8501,8750)
122
+ $(call ListPathsSafely_IfPrintf,$1,$2,$3,8751,9000)
123
+
124
+ $(call ListPathsSafely_IfPrintf,$1,$2,$3,9001,9250)
125
+ $(call ListPathsSafely_IfPrintf,$1,$2,$3,9251,9500)
126
+ $(call ListPathsSafely_IfPrintf,$1,$2,$3,9501,9750)
127
+ $(call ListPathsSafely_IfPrintf,$1,$2,$3,9751,10000)
128
+
129
+ $(call ListPathsSafely_IfPrintf,$1,$2,$3,10001,10250)
130
+ $(call ListPathsSafely_IfPrintf,$1,$2,$3,10251,10500)
131
+ $(call ListPathsSafely_IfPrintf,$1,$2,$3,10501,10750)
132
+ $(call ListPathsSafely_IfPrintf,$1,$2,$3,10751,11000)
133
+
134
+ $(call ListPathsSafely_IfPrintf,$1,$2,$3,11001,11250)
135
+ $(call ListPathsSafely_IfPrintf,$1,$2,$3,11251,11500)
136
+ $(call ListPathsSafely_IfPrintf,$1,$2,$3,11501,11750)
137
+ $(call ListPathsSafely_IfPrintf,$1,$2,$3,11751,12000)
138
+
139
+ $(call ListPathsSafely_IfPrintf,$1,$2,$3,12001,12250)
140
+ $(call ListPathsSafely_IfPrintf,$1,$2,$3,12251,12500)
141
+ $(call ListPathsSafely_IfPrintf,$1,$2,$3,12501,12750)
142
+ $(call ListPathsSafely_IfPrintf,$1,$2,$3,12751,13000)
143
+
144
+ $(call ListPathsSafely_IfPrintf,$1,$2,$3,13001,13250)
145
+ $(call ListPathsSafely_IfPrintf,$1,$2,$3,13251,13500)
146
+ $(call ListPathsSafely_IfPrintf,$1,$2,$3,13501,13750)
147
+ $(call ListPathsSafely_IfPrintf,$1,$2,$3,13751,14000)
148
+
149
+ $(call ListPathsSafely_IfPrintf,$1,$2,$3,14001,14250)
150
+ $(call ListPathsSafely_IfPrintf,$1,$2,$3,14251,14500)
151
+ $(call ListPathsSafely_IfPrintf,$1,$2,$3,14501,14750)
152
+ $(call ListPathsSafely_IfPrintf,$1,$2,$3,14751,15000)
153
+
154
+ $(call ListPathsSafely_IfPrintf,$1,$2,$3,15001,15250)
155
+ $(call ListPathsSafely_IfPrintf,$1,$2,$3,15251,15500)
156
+ $(call ListPathsSafely_IfPrintf,$1,$2,$3,15501,15750)
157
+ $(call ListPathsSafely_IfPrintf,$1,$2,$3,15751,16000)
230
158
endef
231
159
232
160
define ListPathsSafelyNow_IfPrintf
0 commit comments