244 $(strip \
245 $(eval MakeDir_dirs_to_make := $(strip $(foreach d, $1, \
246 $(if $(findstring ?, $d), '$(call DecodeSpace, $d)', \
247 $(if $(wildcard $d), , $d) \
248 ) \
249 ))) \
250 $(if $(MakeDir_dirs_to_make), $(shell $(MKDIR) -p $(MakeDir_dirs_to_make))) \
251 )
252
253 # Make directory for target file. Should handle spaces in filenames. Just
254 # calling $(call MakeDir $(@D)) will not work if the directory contains a space
255 # and the target file already exists. In that case, the target file will have
256 # its wildcard ? resolved and the $(@D) will evaluate each space separated dir
257 # part on its own.
258 MakeTargetDir = \
259 $(call MakeDir, $(dir $(call EncodeSpace, $@)))
260
261 ################################################################################
262 # All install-file and related macros automatically call DecodeSpace when needed.
263
264 ifeq ($(call isTargetOs, solaris), true)
265 # On Solaris, if the target is a symlink and exists, cp won't overwrite.
266 # Cp has to operate in recursive mode to allow for -P flag, to preserve soft links. If the
267 # name of the target file differs from the source file, rename after copy.
268 # If the source and target parent directories are the same, recursive copy doesn't work
269 # so we fall back on regular copy, which isn't preserving symlinks.
270 define install-file
271 $(call MakeTargetDir)
272 $(RM) '$(call DecodeSpace, $@)'
273 if [ '$(call DecodeSpace, $(dir $(call EncodeSpace, $@)))' != \
274 '$(call DecodeSpace, $(dir $(call EncodeSpace, $<)))' ]; then \
275 $(CP) -f -r -P '$(call DecodeSpace, $<)' \
276 '$(call DecodeSpace, $(dir $(call EncodeSpace, $@)))'; \
277 if [ '$(call DecodeSpace, $(notdir $(call EncodeSpace, $@)))' != \
278 '$(call DecodeSpace, $(notdir $(call EncodeSpace, $(<))))' ]; then \
279 $(MV) '$(call DecodeSpace, $(dir $(call EncodeSpace, $@))/$(notdir $(call EncodeSpace, $<)))' \
280 '$(call DecodeSpace, $@)'; \
281 fi; \
282 else \
283 if [ -L '$(call DecodeSpace, $<)' ]; then \
284 $(ECHO) "Source file is a symlink and target is in the same directory: $< $@" ; \
285 exit 1; \
286 fi; \
287 $(CP) -f '$(call DecodeSpace, $<)' '$(call DecodeSpace, $@)'; \
288 fi
289 endef
290 else ifeq ($(call isTargetOs, macosx), true)
291 # On mac, extended attributes sometimes creep into the source files, which may later
292 # cause the creation of ._* files which confuses testing. Clear these with xattr if
293 # set. Some files get their write permissions removed after being copied to the
294 # output dir. When these are copied again to images, xattr would fail. By only clearing
295 # attributes when they are present, failing on this is avoided.
296 #
297 # If copying a soft link to a directory, need to delete the target first to avoid
298 # weird errors.
299 define install-file
300 $(call MakeTargetDir)
301 $(RM) '$(call DecodeSpace, $@)'
302 # Work around a weirdness with cp on Macosx. When copying a symlink, if
303 # the target of the link is write protected (e.g. 444), cp will add
304 # write permission for the user on the target file (644). Avoid this by
305 # using ln to create a new link instead.
306 if [ -h '$(call DecodeSpace, $<)' ]; then \
307 $(LN) -s "`$(READLINK) '$(call DecodeSpace, $<)'`" '$(call DecodeSpace, $@)'; \
308 else \
309 $(CP) -fRP '$(call DecodeSpace, $<)' '$(call DecodeSpace, $@)'; \
310 fi
|
244 $(strip \
245 $(eval MakeDir_dirs_to_make := $(strip $(foreach d, $1, \
246 $(if $(findstring ?, $d), '$(call DecodeSpace, $d)', \
247 $(if $(wildcard $d), , $d) \
248 ) \
249 ))) \
250 $(if $(MakeDir_dirs_to_make), $(shell $(MKDIR) -p $(MakeDir_dirs_to_make))) \
251 )
252
253 # Make directory for target file. Should handle spaces in filenames. Just
254 # calling $(call MakeDir $(@D)) will not work if the directory contains a space
255 # and the target file already exists. In that case, the target file will have
256 # its wildcard ? resolved and the $(@D) will evaluate each space separated dir
257 # part on its own.
258 MakeTargetDir = \
259 $(call MakeDir, $(dir $(call EncodeSpace, $@)))
260
261 ################################################################################
262 # All install-file and related macros automatically call DecodeSpace when needed.
263
264 ifeq ($(call isTargetOs, macosx), true)
265 # On mac, extended attributes sometimes creep into the source files, which may later
266 # cause the creation of ._* files which confuses testing. Clear these with xattr if
267 # set. Some files get their write permissions removed after being copied to the
268 # output dir. When these are copied again to images, xattr would fail. By only clearing
269 # attributes when they are present, failing on this is avoided.
270 #
271 # If copying a soft link to a directory, need to delete the target first to avoid
272 # weird errors.
273 define install-file
274 $(call MakeTargetDir)
275 $(RM) '$(call DecodeSpace, $@)'
276 # Work around a weirdness with cp on Macosx. When copying a symlink, if
277 # the target of the link is write protected (e.g. 444), cp will add
278 # write permission for the user on the target file (644). Avoid this by
279 # using ln to create a new link instead.
280 if [ -h '$(call DecodeSpace, $<)' ]; then \
281 $(LN) -s "`$(READLINK) '$(call DecodeSpace, $<)'`" '$(call DecodeSpace, $@)'; \
282 else \
283 $(CP) -fRP '$(call DecodeSpace, $<)' '$(call DecodeSpace, $@)'; \
284 fi
|