comparison make/common/MakeBase.gmk @ 1670:216f63a10515

8136385: Various build speed improvements for windows Reviewed-by: ihse
author erikj
date Mon, 28 Sep 2015 11:39:13 +0200
parents 382d23edebb6
children 1e64ec3d1c60
comparison
equal deleted inserted replaced
31:ac2bde25d8e6 32:61f351795ab7
62 define NEWLINE 62 define NEWLINE
63 63
64 64
65 endef 65 endef
66 66
67 # In GNU Make 4.0 and higher, there is a file function for writing to files.
68 ifeq (4.0, $(firstword $(sort 4.0 $(MAKE_VERSION))))
69 HAS_FILE_FUNCTION := true
70 endif
71
67 ############################## 72 ##############################
68 # Functions 73 # Functions
69 ############################## 74 ##############################
70 75
71 ### Debug functions 76 ### Debug functions
120 ################################################################################ 125 ################################################################################
121 # This macro translates $ into $$ to protect the string from make itself. 126 # This macro translates $ into $$ to protect the string from make itself.
122 DoubleDollar = $(subst $$,$$$$,$(strip $1)) 127 DoubleDollar = $(subst $$,$$$$,$(strip $1))
123 128
124 ################################################################################ 129 ################################################################################
125 130 # ListPathsSafely can be used to print command parameters to a file. This is
126 # If the variable that you want to send to stdout for piping into a file or otherwise, 131 # typically done if the command line lenght risk being too long for the
127 # is potentially long, for example the a list of file paths, eg a list of all package directories. 132 # OS/shell. In later make versions, the file function can be used for this
128 # Then you need to use ListPathsSafely, which optimistically splits the output into several shell 133 # purpose. For earlier versions, a more complex implementation is provided.
129 # calls as well as use compression on recurrent file paths segments, to get around the potential 134 #
130 # command line length problem that exists in cygwin and other shells. 135 # The function ListPathsSafely can be called either directly or, more commonly
131 compress_pre:=$(strip $(shell $(CAT) $(SRC_ROOT)/make/common/support/ListPathsSafely-pre-compress.incl)) 136 # from a recipe line. If called from a recipe, it will be executed in the
132 compress_post:=$(strip $(shell $(CAT) $(SRC_ROOT)/make/common/support/ListPathsSafely-post-compress.incl)) 137 # evaluation phase of that recipe, which means that it will write to the file
133 compress_paths=$(compress_pre)\ 138 # before any other line in the recipe has been run.
139 ifeq ($(HAS_FILE_FUNCTION), true)
140 # Param 1 - Name of variable containing paths/arguments to output
141 # Param 2 - File to print to
142 # Param 3 - Set to true to append to file instead of overwriting
143 define ListPathsSafely
144 $$(call MakeDir, $$(dir $$(strip $2)))
145 $$(file $$(if $$(filter true, $$(strip $3)),>>,>) \
146 $$(strip $2),$$(subst $$(SPACE),$$(NEWLINE),$$(strip $$($$(strip $1)))))
147 endef
148
149 else # HAS_FILE_FUNCTION
150
151 $(eval compress_paths = \
152 $(strip $(shell $(CAT) $(SRC_ROOT)/make/common/support/ListPathsSafely-pre-compress.incl)))
153 compress_paths += \
134 $(subst $(SRC_ROOT),X97,\ 154 $(subst $(SRC_ROOT),X97,\
135 $(subst $(OUTPUT_ROOT),X98,\ 155 $(subst $(OUTPUT_ROOT),X98,\
136 $(subst X,X00,\ 156 $(subst X,X00,\
137 $(subst $(SPACE),\n,$(strip $1)))))\ 157 $(subst $(SPACE),\n,$(strip $1)))))
138 $(compress_post) 158 $(eval compress_paths += \
139 159 $(strip $(shell $(CAT) $(SRC_ROOT)/make/common/support/ListPathsSafely-post-compress.incl)))
140 decompress_paths=$(SED) -f $(SRC_ROOT)/make/common/support/ListPathsSafely-uncompress.sed -e 's|X99|\\n|g' \ 160
161 decompress_paths=$(SED) -f $(SRC_ROOT)/make/common/support/ListPathsSafely-uncompress.sed \
162 -e 's|X99|\\n|g' \
141 -e 's|X98|$(OUTPUT_ROOT)|g' -e 's|X97|$(SRC_ROOT)|g' \ 163 -e 's|X98|$(OUTPUT_ROOT)|g' -e 's|X97|$(SRC_ROOT)|g' \
142 -e 's|X00|X|g' | tr '\n' '$2' 164 -e 's|X00|X|g'
143 165
144 define ListPathsSafely_If 166 ListPathsSafely_IfPrintf = \
145 $(if $(word $3,$($1)),$(eval $1_LPS$3:=$(call compress_paths,$(wordlist $3,$4,$($1))))) 167 $(if $(word $3,$($(strip $1))), \
146 endef 168 $(shell $(PRINTF) -- "$(strip $(call EscapeDollar, \
147 169 $(call compress_paths, $(wordlist $3,$4,$($(strip $1))))))\n" \
148 define ListPathsSafely_Printf 170 | $(decompress_paths) >> $2))
149 $(if $(strip $($1_LPS$4)),$(if $(findstring $(LOG_LEVEL),trace),,@)printf \ 171
150 -- "$(strip $(call EscapeDollar, $($1_LPS$4)))\n" | $(decompress_paths) $3) 172 # Param 1 - Name of variable containing paths/arguments to output
151 endef 173 # Param 2 - File to print to
152 174 # Param 3 - Set to true to append to file instead of overwriting
153 # Receipt example:
154 # rm -f thepaths
155 # $(call ListPathsSafely,THEPATHS,\n, >> thepaths)
156 # The \n argument means translate spaces into \n
157 # if instead , , (a space) is supplied, then spaces remain spaces.
158 define ListPathsSafely 175 define ListPathsSafely
159 $(if $(word 16001,$($1)),$(error Cannot list safely more than 16000 paths. $1 has $(words $($1)) paths!))
160 $(ECHO) $(LOG_DEBUG) Writing $(words $($1)) paths to '$3'
161 $(call ListPathsSafely_If,$1,$2,1,250)
162 $(call ListPathsSafely_If,$1,$2,251,500)
163 $(call ListPathsSafely_If,$1,$2,501,750)
164 $(call ListPathsSafely_If,$1,$2,751,1000)
165
166 $(call ListPathsSafely_If,$1,$2,1001,1250)
167 $(call ListPathsSafely_If,$1,$2,1251,1500)
168 $(call ListPathsSafely_If,$1,$2,1501,1750)
169 $(call ListPathsSafely_If,$1,$2,1751,2000)
170
171 $(call ListPathsSafely_If,$1,$2,2001,2250)
172 $(call ListPathsSafely_If,$1,$2,2251,2500)
173 $(call ListPathsSafely_If,$1,$2,2501,2750)
174 $(call ListPathsSafely_If,$1,$2,2751,3000)
175
176 $(call ListPathsSafely_If,$1,$2,3001,3250)
177 $(call ListPathsSafely_If,$1,$2,3251,3500)
178 $(call ListPathsSafely_If,$1,$2,3501,3750)
179 $(call ListPathsSafely_If,$1,$2,3751,4000)
180
181 $(call ListPathsSafely_If,$1,$2,4001,4250)
182 $(call ListPathsSafely_If,$1,$2,4251,4500)
183 $(call ListPathsSafely_If,$1,$2,4501,4750)
184 $(call ListPathsSafely_If,$1,$2,4751,5000)
185
186 $(call ListPathsSafely_If,$1,$2,5001,5250)
187 $(call ListPathsSafely_If,$1,$2,5251,5500)
188 $(call ListPathsSafely_If,$1,$2,5501,5750)
189 $(call ListPathsSafely_If,$1,$2,5751,6000)
190
191 $(call ListPathsSafely_If,$1,$2,6001,6250)
192 $(call ListPathsSafely_If,$1,$2,6251,6500)
193 $(call ListPathsSafely_If,$1,$2,6501,6750)
194 $(call ListPathsSafely_If,$1,$2,6751,7000)
195
196 $(call ListPathsSafely_If,$1,$2,7001,7250)
197 $(call ListPathsSafely_If,$1,$2,7251,7500)
198 $(call ListPathsSafely_If,$1,$2,7501,7750)
199 $(call ListPathsSafely_If,$1,$2,7751,8000)
200
201 $(call ListPathsSafely_If,$1,$2,8001,8250)
202 $(call ListPathsSafely_If,$1,$2,8251,8500)
203 $(call ListPathsSafely_If,$1,$2,8501,8750)
204 $(call ListPathsSafely_If,$1,$2,8751,9000)
205
206 $(call ListPathsSafely_If,$1,$2,9001,9250)
207 $(call ListPathsSafely_If,$1,$2,9251,9500)
208 $(call ListPathsSafely_If,$1,$2,9501,9750)
209 $(call ListPathsSafely_If,$1,$2,9751,10000)
210
211 $(call ListPathsSafely_If,$1,$2,10001,10250)
212 $(call ListPathsSafely_If,$1,$2,10251,10500)
213 $(call ListPathsSafely_If,$1,$2,10501,10750)
214 $(call ListPathsSafely_If,$1,$2,10751,11000)
215
216 $(call ListPathsSafely_If,$1,$2,11001,11250)
217 $(call ListPathsSafely_If,$1,$2,11251,11500)
218 $(call ListPathsSafely_If,$1,$2,11501,11750)
219 $(call ListPathsSafely_If,$1,$2,11751,12000)
220
221 $(call ListPathsSafely_If,$1,$2,12001,12250)
222 $(call ListPathsSafely_If,$1,$2,12251,12500)
223 $(call ListPathsSafely_If,$1,$2,12501,12750)
224 $(call ListPathsSafely_If,$1,$2,12751,13000)
225
226 $(call ListPathsSafely_If,$1,$2,13001,13250)
227 $(call ListPathsSafely_If,$1,$2,13251,13500)
228 $(call ListPathsSafely_If,$1,$2,13501,13750)
229 $(call ListPathsSafely_If,$1,$2,13751,14000)
230
231 $(call ListPathsSafely_If,$1,$2,14001,14250)
232 $(call ListPathsSafely_If,$1,$2,14251,14500)
233 $(call ListPathsSafely_If,$1,$2,14501,14750)
234 $(call ListPathsSafely_If,$1,$2,14751,15000)
235
236 $(call ListPathsSafely_If,$1,$2,15001,15250)
237 $(call ListPathsSafely_If,$1,$2,15251,15500)
238 $(call ListPathsSafely_If,$1,$2,15501,15750)
239 $(call ListPathsSafely_If,$1,$2,15751,16000)
240
241 $(call ListPathsSafely_Printf,$1,$2,$3,1)
242 $(call ListPathsSafely_Printf,$1,$2,$3,251)
243 $(call ListPathsSafely_Printf,$1,$2,$3,501)
244 $(call ListPathsSafely_Printf,$1,$2,$3,751)
245
246 $(call ListPathsSafely_Printf,$1,$2,$3,1001)
247 $(call ListPathsSafely_Printf,$1,$2,$3,1251)
248 $(call ListPathsSafely_Printf,$1,$2,$3,1501)
249 $(call ListPathsSafely_Printf,$1,$2,$3,1751)
250
251 $(call ListPathsSafely_Printf,$1,$2,$3,2001)
252 $(call ListPathsSafely_Printf,$1,$2,$3,2251)
253 $(call ListPathsSafely_Printf,$1,$2,$3,2501)
254 $(call ListPathsSafely_Printf,$1,$2,$3,2751)
255
256 $(call ListPathsSafely_Printf,$1,$2,$3,3001)
257 $(call ListPathsSafely_Printf,$1,$2,$3,3251)
258 $(call ListPathsSafely_Printf,$1,$2,$3,3501)
259 $(call ListPathsSafely_Printf,$1,$2,$3,3751)
260
261 $(call ListPathsSafely_Printf,$1,$2,$3,4001)
262 $(call ListPathsSafely_Printf,$1,$2,$3,4251)
263 $(call ListPathsSafely_Printf,$1,$2,$3,4501)
264 $(call ListPathsSafely_Printf,$1,$2,$3,4751)
265
266 $(call ListPathsSafely_Printf,$1,$2,$3,5001)
267 $(call ListPathsSafely_Printf,$1,$2,$3,5251)
268 $(call ListPathsSafely_Printf,$1,$2,$3,5501)
269 $(call ListPathsSafely_Printf,$1,$2,$3,5751)
270
271 $(call ListPathsSafely_Printf,$1,$2,$3,6001)
272 $(call ListPathsSafely_Printf,$1,$2,$3,6251)
273 $(call ListPathsSafely_Printf,$1,$2,$3,6501)
274 $(call ListPathsSafely_Printf,$1,$2,$3,6751)
275
276 $(call ListPathsSafely_Printf,$1,$2,$3,7001)
277 $(call ListPathsSafely_Printf,$1,$2,$3,7251)
278 $(call ListPathsSafely_Printf,$1,$2,$3,7501)
279 $(call ListPathsSafely_Printf,$1,$2,$3,7751)
280
281 $(call ListPathsSafely_Printf,$1,$2,$3,8001)
282 $(call ListPathsSafely_Printf,$1,$2,$3,8251)
283 $(call ListPathsSafely_Printf,$1,$2,$3,8501)
284 $(call ListPathsSafely_Printf,$1,$2,$3,8751)
285
286 $(call ListPathsSafely_Printf,$1,$2,$3,9001)
287 $(call ListPathsSafely_Printf,$1,$2,$3,9251)
288 $(call ListPathsSafely_Printf,$1,$2,$3,9501)
289 $(call ListPathsSafely_Printf,$1,$2,$3,9751)
290
291 $(call ListPathsSafely_Printf,$1,$2,$3,10001)
292 $(call ListPathsSafely_Printf,$1,$2,$3,10251)
293 $(call ListPathsSafely_Printf,$1,$2,$3,10501)
294 $(call ListPathsSafely_Printf,$1,$2,$3,10751)
295
296 $(call ListPathsSafely_Printf,$1,$2,$3,11001)
297 $(call ListPathsSafely_Printf,$1,$2,$3,11251)
298 $(call ListPathsSafely_Printf,$1,$2,$3,11501)
299 $(call ListPathsSafely_Printf,$1,$2,$3,11751)
300
301 $(call ListPathsSafely_Printf,$1,$2,$3,12001)
302 $(call ListPathsSafely_Printf,$1,$2,$3,12251)
303 $(call ListPathsSafely_Printf,$1,$2,$3,12501)
304 $(call ListPathsSafely_Printf,$1,$2,$3,12751)
305
306 $(call ListPathsSafely_Printf,$1,$2,$3,13001)
307 $(call ListPathsSafely_Printf,$1,$2,$3,13251)
308 $(call ListPathsSafely_Printf,$1,$2,$3,13501)
309 $(call ListPathsSafely_Printf,$1,$2,$3,13751)
310
311 $(call ListPathsSafely_Printf,$1,$2,$3,14001)
312 $(call ListPathsSafely_Printf,$1,$2,$3,14251)
313 $(call ListPathsSafely_Printf,$1,$2,$3,14501)
314 $(call ListPathsSafely_Printf,$1,$2,$3,14751)
315
316 $(call ListPathsSafely_Printf,$1,$2,$3,15001)
317 $(call ListPathsSafely_Printf,$1,$2,$3,15251)
318 $(call ListPathsSafely_Printf,$1,$2,$3,15501)
319 $(call ListPathsSafely_Printf,$1,$2,$3,15751)
320 endef
321
322 define ListPathsSafelyNow_IfPrintf
323 ifneq (,$$(word $4,$$($1)))
324 $$(eval $1_LPS$4:=$$(call compress_paths,$$(wordlist $4,$5,$$($1))))
325 $$(shell printf -- "$$(strip $$($1_LPS$4))\n" | $(decompress_paths) $3)
326 endif
327 endef
328
329 # And an non-receipt version:
330 define ListPathsSafelyNow
331 ifneq (,$$(word 10001,$$($1))) 176 ifneq (,$$(word 10001,$$($1)))
332 $$(error Cannot list safely more than 10000 paths. $1 has $$(words $$($1)) paths!) 177 $$(error Cannot list safely more than 10000 paths. $1 has $$(words $$($1)) paths!)
333 endif 178 endif
334 $(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,1,250) 179 $$(call MakeDir, $$(dir $2))
335 $(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,251,500) 180 ifneq ($$(strip $3), true)
336 $(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,501,750) 181 $$(shell $(RM) $$(strip $2))
337 $(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,751,1000) 182 endif
338 183
339 $(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,1001,1250) 184 $$(call ListPathsSafely_IfPrintf,$1,$2,1,250)
340 $(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,1251,1500) 185 $$(call ListPathsSafely_IfPrintf,$1,$2,251,500)
341 $(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,1501,1750) 186 $$(call ListPathsSafely_IfPrintf,$1,$2,501,750)
342 $(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,1751,2000) 187 $$(call ListPathsSafely_IfPrintf,$1,$2,751,1000)
343 188
344 $(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,2001,2250) 189 $$(call ListPathsSafely_IfPrintf,$1,$2,1001,1250)
345 $(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,2251,2500) 190 $$(call ListPathsSafely_IfPrintf,$1,$2,1251,1500)
346 $(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,2501,2750) 191 $$(call ListPathsSafely_IfPrintf,$1,$2,1501,1750)
347 $(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,2751,3000) 192 $$(call ListPathsSafely_IfPrintf,$1,$2,1751,2000)
348 193
349 $(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,3001,3250) 194 $$(call ListPathsSafely_IfPrintf,$1,$2,2001,2250)
350 $(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,3251,3500) 195 $$(call ListPathsSafely_IfPrintf,$1,$2,2251,2500)
351 $(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,3501,3750) 196 $$(call ListPathsSafely_IfPrintf,$1,$2,2501,2750)
352 $(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,3751,4000) 197 $$(call ListPathsSafely_IfPrintf,$1,$2,2751,3000)
353 198
354 $(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,4001,4250) 199 $$(call ListPathsSafely_IfPrintf,$1,$2,3001,3250)
355 $(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,4251,4500) 200 $$(call ListPathsSafely_IfPrintf,$1,$2,3251,3500)
356 $(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,4501,4750) 201 $$(call ListPathsSafely_IfPrintf,$1,$2,3501,3750)
357 $(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,4751,5000) 202 $$(call ListPathsSafely_IfPrintf,$1,$2,3751,4000)
358 203
359 $(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,5001,5250) 204 $$(call ListPathsSafely_IfPrintf,$1,$2,4001,4250)
360 $(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,5251,5500) 205 $$(call ListPathsSafely_IfPrintf,$1,$2,4251,4500)
361 $(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,5501,5750) 206 $$(call ListPathsSafely_IfPrintf,$1,$2,4501,4750)
362 $(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,5751,6000) 207 $$(call ListPathsSafely_IfPrintf,$1,$2,4751,5000)
363 208
364 $(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,6001,6250) 209 $$(call ListPathsSafely_IfPrintf,$1,$2,5001,5250)
365 $(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,6251,6500) 210 $$(call ListPathsSafely_IfPrintf,$1,$2,5251,5500)
366 $(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,6501,6750) 211 $$(call ListPathsSafely_IfPrintf,$1,$2,5501,5750)
367 $(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,6751,7000) 212 $$(call ListPathsSafely_IfPrintf,$1,$2,5751,6000)
368 213
369 $(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,7001,7250) 214 $$(call ListPathsSafely_IfPrintf,$1,$2,6001,6250)
370 $(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,7251,7500) 215 $$(call ListPathsSafely_IfPrintf,$1,$2,6251,6500)
371 $(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,7501,7750) 216 $$(call ListPathsSafely_IfPrintf,$1,$2,6501,6750)
372 $(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,7751,8000) 217 $$(call ListPathsSafely_IfPrintf,$1,$2,6751,7000)
373 218
374 $(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,8001,8250) 219 $$(call ListPathsSafely_IfPrintf,$1,$2,7001,7250)
375 $(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,8251,8500) 220 $$(call ListPathsSafely_IfPrintf,$1,$2,7251,7500)
376 $(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,8501,8750) 221 $$(call ListPathsSafely_IfPrintf,$1,$2,7501,7750)
377 $(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,8751,9000) 222 $$(call ListPathsSafely_IfPrintf,$1,$2,7751,8000)
378 223
379 $(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,9001,9250) 224 $$(call ListPathsSafely_IfPrintf,$1,$2,8001,8250)
380 $(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,9251,9500) 225 $$(call ListPathsSafely_IfPrintf,$1,$2,8251,8500)
381 $(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,9501,9750) 226 $$(call ListPathsSafely_IfPrintf,$1,$2,8501,8750)
382 $(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,9751,10000) 227 $$(call ListPathsSafely_IfPrintf,$1,$2,8751,9000)
383 228
384 endef 229 $$(call ListPathsSafely_IfPrintf,$1,$2,9001,9250)
230 $$(call ListPathsSafely_IfPrintf,$1,$2,9251,9500)
231 $$(call ListPathsSafely_IfPrintf,$1,$2,9501,9750)
232 $$(call ListPathsSafely_IfPrintf,$1,$2,9751,10000)
233 endef
234 endif # HAS_FILE_FUNCTION
385 235
386 # The source tips can come from the Mercurial repository, or in the files 236 # The source tips can come from the Mercurial repository, or in the files
387 # $(HGTIP_FILENAME) which contains the tip but is also positioned in the same 237 # $(HGTIP_FILENAME) which contains the tip but is also positioned in the same
388 # directory as the original $(HGDIR) directory. 238 # directory as the original $(HGDIR) directory.
389 # These should not be := assignments, only used from the root Makefile. 239 # These should not be := assignments, only used from the root Makefile.
725 ReadFile = \ 575 ReadFile = \
726 $(shell $(CAT) $1) 576 $(shell $(CAT) $1)
727 577
728 # Param 1 - Text to write 578 # Param 1 - Text to write
729 # Param 2 - File to write to 579 # Param 2 - File to write to
580 ifeq ($(HAS_FILE_FUNCTION), true)
581 WriteFile = \
582 $(file >$2,$(strip $1))
583 else
730 # Use printf to get consistent behavior on all platforms. 584 # Use printf to get consistent behavior on all platforms.
731 WriteFile = \ 585 WriteFile = \
732 $(shell $(PRINTF) "%s" $(call ShellQuote, $1) > $2) 586 $(shell $(PRINTF) "%s" $(call ShellQuote, $1) > $2)
587 endif
733 588
734 ################################################################################ 589 ################################################################################
735 # DependOnVariable 590 # DependOnVariable
736 # 591 #
737 # This macro takes a variable name and puts the value in a file only if the 592 # This macro takes a variable name and puts the value in a file only if the
765 # else print a new file. 620 # else print a new file.
766 # Always returns the name of the file where the value was printed. 621 # Always returns the name of the file where the value was printed.
767 # Param 1 - Name of variable 622 # Param 1 - Name of variable
768 # Param 2 - (optional) name of file to store value in 623 # Param 2 - (optional) name of file to store value in
769 DependOnVariableHelper = \ 624 DependOnVariableHelper = \
770 $(strip $(if $(and $(wildcard $(call DependOnVariableFileName, $1, $2)),\ 625 $(strip \
771 $(call equals, $(strip $($1)), \ 626 $(eval -include $(call DependOnVariableFileName, $1, $2)) \
772 $(call ReadFile, $(call DependOnVariableFileName, $1, $2)))),,\ 627 $(if $(call equals, $(strip $($1)), $(strip $($1_old))),,\
773 $(call MakeDir, $(dir $(call DependOnVariableFileName, $1, $2))) \ 628 $(call MakeDir, $(dir $(call DependOnVariableFileName, $1, $2))) \
774 $(if $(findstring $(LOG_LEVEL), trace), \ 629 $(if $(findstring $(LOG_LEVEL), trace), \
775 $(info Variable $1: >$(strip $($1))<) \ 630 $(info NewVariable $1: >$(strip $($1))<) \
776 $(info File: >$(call ReadFile, $(call DependOnVariableFileName, $1, $2))<)) \ 631 $(info OldVariable $1: >$(strip $($1_old))<)) \
777 $(call WriteFile, $($1), $(call DependOnVariableFileName, $1, $2))) \ 632 $(call WriteFile, $1_old:=$($1), $(call DependOnVariableFileName, $1, $2))) \
778 $(call DependOnVariableFileName, $1, $2)) 633 $(call DependOnVariableFileName, $1, $2) \
634 )
779 635
780 # Main macro 636 # Main macro
781 # Param 1 - Name of variable 637 # Param 1 - Name of variable
782 # Param 2 - (optional) name of file to store value in 638 # Param 2 - (optional) name of file to store value in
783 DependOnVariable = \ 639 DependOnVariable = \