404 # set. Some files get their write permissions removed after being copied to the
405 # output dir. When these are copied again to images, xattr would fail. By only clearing
406 # attributes when they are present, failing on this is avoided.
407 define install-file
408 $(MKDIR) -p $(@D)
409 $(CP) -fRP '$<' '$@'
410 if [ -n "`$(XATTR) -l '$@'`" ]; then $(XATTR) -c '$@'; fi
411 endef
412 else
413 define install-file
414 $(MKDIR) -p $(@D)
415 $(CP) -fP '$<' '$@'
416 endef
417 endif
418
419 # Convenience functions for working around make's limitations with $(filter ).
420 containing = $(foreach v,$2,$(if $(findstring $1,$v),$v))
421 not-containing = $(foreach v,$2,$(if $(findstring $1,$v),,$v))
422
423 ifneq ($(DISABLE_CACHE_FIND), true)
424 ################################################################################
425 # In Cygwin, finds are very costly, both because of expensive forks and because
426 # of bad file system caching. Find is used extensively in $(shell) commands to
427 # find source files. This makes rerunning make with no or few changes rather
428 # expensive. To speed this up, these two macros are used to cache the results
429 # of simple find commands for reuse.
430 #
431 # Runs a find and stores both the directories where it was run and the results.
432 # This macro can be called multiple times to add to the cache. Only finds files
433 # with no filters.
434 #
435 # Needs to be called with $(eval )
436 #
437 # Even if the performance benifit is negligible on other platforms, keep the
438 # functionality active unless explicitly disabled to exercise it more.
439 #
440 # Initialize FIND_CACHE_DIRS with := to make it a non recursively-expanded variable
441 FIND_CACHE_DIRS :=
442 # Param 1 - Dir to find in
443 define FillCacheFind
444 # Filter out already cached dirs. The - is needed when FIND_CACHE_DIR is empty
445 # since filter out will then return empty.
446 FIND_CACHE_NEW_DIRS := $$(filter-out $$(addsuffix /%,\
447 - $(FIND_CACHE_DIRS)) $(FIND_CACHE_DIRS), $1)
448 ifneq ($$(FIND_CACHE_NEW_DIRS), )
449 # Remove any trailing slash from dirs in the cache dir list
450 FIND_CACHE_DIRS += $$(patsubst %/,%, $$(FIND_CACHE_NEW_DIRS))
451 FIND_CACHE := $$(sort $$(FIND_CACHE) $$(shell $(FIND) $$(FIND_CACHE_NEW_DIRS) -type f -o -type l))
452 endif
453 endef
454
455 # Mimics find by looking in the cache if all of the directories have been cached.
456 # Otherwise reverts to shell find. This is safe to call on all platforms, even if
457 # cache is deactivated.
458 #
459 # The extra - is needed when FIND_CACHE_DIR is empty but should be harmless.
460 # Param 1 - Dirs to find in
461 define CacheFind
462 $(if $(filter-out $(addsuffix /%,- $(FIND_CACHE_DIRS)) $(FIND_CACHE_DIRS),$1), \
463 $(shell $(FIND) $1 -type f -o -type l), \
464 $(filter $(addsuffix %,$1),$(FIND_CACHE)))
465 endef
466 else
467 # If CacheFind is disabled, just run the find command.
468 define CacheFind
469 $(shell $(FIND) $1 -type f -o -type l)
470 endef
471 endif
472
473 ################################################################################
474
475 endif # _MAKEBASE_GMK
|
404 # set. Some files get their write permissions removed after being copied to the
405 # output dir. When these are copied again to images, xattr would fail. By only clearing
406 # attributes when they are present, failing on this is avoided.
407 define install-file
408 $(MKDIR) -p $(@D)
409 $(CP) -fRP '$<' '$@'
410 if [ -n "`$(XATTR) -l '$@'`" ]; then $(XATTR) -c '$@'; fi
411 endef
412 else
413 define install-file
414 $(MKDIR) -p $(@D)
415 $(CP) -fP '$<' '$@'
416 endef
417 endif
418
419 # Convenience functions for working around make's limitations with $(filter ).
420 containing = $(foreach v,$2,$(if $(findstring $1,$v),$v))
421 not-containing = $(foreach v,$2,$(if $(findstring $1,$v),,$v))
422
423 ifneq ($(DISABLE_CACHE_FIND), true)
424 ################################################################################
425 # In Cygwin, finds are very costly, both because of expensive forks and because
426 # of bad file system caching. Find is used extensively in $(shell) commands to
427 # find source files. This makes rerunning make with no or few changes rather
428 # expensive. To speed this up, these two macros are used to cache the results
429 # of simple find commands for reuse.
430 #
431 # Runs a find and stores both the directories where it was run and the results.
432 # This macro can be called multiple times to add to the cache. Only finds files
433 # with no filters.
434 #
435 # Needs to be called with $(eval )
436 #
437 # Even if the performance benifit is negligible on other platforms, keep the
438 # functionality active unless explicitly disabled to exercise it more.
439 #
440 # Initialize FIND_CACHE_DIRS with := to make it a non recursively-expanded variable
441 FIND_CACHE_DIRS :=
442 # Param 1 - Dirs to find in
443 # Param 2 - (optional) specialization
444 define FillCacheFind
445 # Filter out already cached dirs. The - is needed when FIND_CACHE_DIR is empty
446 # since filter out will then return empty.
447 FIND_CACHE_NEW_DIRS := $$(filter-out $$(addsuffix /%,\
448 - $(FIND_CACHE_DIRS)) $(FIND_CACHE_DIRS), $1)
449 ifneq ($$(FIND_CACHE_NEW_DIRS), )
450 # Remove any trailing slash from dirs in the cache dir list
451 FIND_CACHE_DIRS += $$(patsubst %/,%, $$(FIND_CACHE_NEW_DIRS))
452 FIND_CACHE := $$(sort $$(FIND_CACHE) $$(shell $(FIND) $$(FIND_CACHE_NEW_DIRS) \( -type f -o -type l \) $2))
453 endif
454 endef
455
456 # Mimics find by looking in the cache if all of the directories have been cached.
457 # Otherwise reverts to shell find. This is safe to call on all platforms, even if
458 # cache is deactivated.
459 #
460 # The extra - is needed when FIND_CACHE_DIR is empty but should be harmless.
461 #
462 # Param 1 - Dirs to find in
463 # Param 2 - (optional) specialization
464 define CacheFind
465 $(if $(filter-out $(addsuffix /%,- $(FIND_CACHE_DIRS)) $(FIND_CACHE_DIRS),$1), \
466 $(shell $(FIND) $1 \( -type f -o -type l \) $2), \
467 $(filter $(addsuffix %,$1),$(FIND_CACHE)))
468 endef
469 else
470 # If CacheFind is disabled, just run the find command.
471 # Param 1 - Dirs to find in
472 # Param 2 - (optional) specialization
473 define CacheFind
474 $(shell $(FIND) $1 \( -type f -o -type l \) $2)
475 endef
476 endif
477
478 ################################################################################
479
480 endif # _MAKEBASE_GMK
|