495 $(filter $(addsuffix /%,$(patsubst %/,%,$1)) $1,$(FIND_CACHE))) 496 endef 497 498 else 499 # If CacheFind is disabled, just run the find command. 500 # Param 1 - Dirs to find in 501 # Param 2 - (optional) specialization. Normally "-a \( ... \)" expression. 502 define CacheFind 503 $(shell $(FIND) $1 \( -type f -o -type l \) $2) 504 endef 505 endif 506 507 ################################################################################ 508 509 define AddFileToCopy 510 # Helper macro for SetupCopyFiles 511 # 1 : Source file 512 # 2 : Dest file 513 # 3 : Variable to add targets to 514 # 4 : Macro to call for copy operation 515 516 $2: $1 517 $(ECHO) $(LOG_INFO) Copying $$(patsubst $(OUTPUT_ROOT)/%,%,$$@) 518 $$($$(strip $4)) 519 520 $3 += $2 521 endef 522 523 define SetupCopyFiles 524 # param 1 is for example COPY_MYFILES 525 # param 2,3,4,5 are named args. 526 # SRC : Source root dir 527 # DEST : Dest root dir 528 # FILES : List of files to copy with absolute paths, or path relative to SRC. Must be in SRC. 529 # FLATTEN : Set to flatten the directory structure in the DEST dir. 530 # MACRO : Optionally override the default macro used for making the copy. Default is 'install-file' 531 $(foreach i,2 3 4 5 6, $(if $($i),$1_$(strip $($i)))$(NEWLINE)) 532 $(call LogSetupMacroEntry,SetupCopyFiles($1),$2,$3,$4,$5,$6) 533 $(if $(7),$(error Internal makefile error: Too many arguments to SetupCopyFiles)) 534 535 ifeq ($$($1_MACRO), ) 536 $1_MACRO := install-file 537 endif 538 539 $$(foreach f, $$(patsubst $$($1_SRC)/%,%,$$($1_FILES)), \ 540 $$(eval $$(call AddFileToCopy, $$($1_SRC)/$$f, \ 541 $$($1_DEST)/$$(if $$($1_FLATTEN),$$(notdir $$f),$$f), $1, $$($1_MACRO)))) 542 543 endef 544 545 ################################################################################ 546 547 # Hook to include the corresponding custom file, if present. 548 $(eval $(call IncludeCustomExtension, , common/MakeBase.gmk)) 549 550 endif # _MAKEBASE_GMK | 495 $(filter $(addsuffix /%,$(patsubst %/,%,$1)) $1,$(FIND_CACHE))) 496 endef 497 498 else 499 # If CacheFind is disabled, just run the find command. 500 # Param 1 - Dirs to find in 501 # Param 2 - (optional) specialization. Normally "-a \( ... \)" expression. 502 define CacheFind 503 $(shell $(FIND) $1 \( -type f -o -type l \) $2) 504 endef 505 endif 506 507 ################################################################################ 508 509 define AddFileToCopy 510 # Helper macro for SetupCopyFiles 511 # 1 : Source file 512 # 2 : Dest file 513 # 3 : Variable to add targets to 514 # 4 : Macro to call for copy operation 515 $2: $1 516 $(ECHO) $(LOG_INFO) Copying $$(patsubst $(OUTPUT_ROOT)/%,%,$$@) 517 $$($$(strip $4)) 518 519 $3 += $2 520 endef 521 522 define SetupCopyFiles 523 # param 1 is for example COPY_MYFILES 524 # param 2,3,4,5 are named args. 525 # SRC : Source root dir (defaults to dir of first file) 526 # DEST : Dest root dir 527 # FILES : List of files to copy with absolute paths, or path relative to SRC. 528 # Must be in SRC. 529 # FLATTEN : Set to flatten the directory structure in the DEST dir. 530 # MACRO : Optionally override the default macro used for making the copy. 531 # Default is 'install-file' 532 $(foreach i,2 3 4 5 6, $(if $($i),$1_$(strip $($i)))$(NEWLINE)) 533 $(call LogSetupMacroEntry,SetupCopyFiles($1),$2,$3,$4,$5,$6) 534 $(if $(7),$(error Internal makefile error: Too many arguments to SetupCopyFiles)) 535 536 ifeq ($$($1_MACRO), ) 537 $1_MACRO := install-file 538 endif 539 540 # Default SRC to the dir of the first file. 541 ifeq ($$($1_SRC), ) 542 $1_SRC := $$(dir $$(firstword $$($1_FILES))) 543 endif 544 545 # Remove any trailing slash from SRC 546 $1_SRC := $$(patsubst %/,%,$$($1_SRC)) 547 548 $$(foreach f, $$(patsubst $$($1_SRC)/%,%,$$($1_FILES)), \ 549 $$(eval $$(call AddFileToCopy, $$($1_SRC)/$$f, \ 550 $$($1_DEST)/$$(if $$($1_FLATTEN),$$(notdir $$f),$$f), $1, $$($1_MACRO)))) 551 552 endef 553 554 ################################################################################ 555 556 # Hook to include the corresponding custom file, if present. 557 $(eval $(call IncludeCustomExtension, , common/MakeBase.gmk)) 558 559 endif # _MAKEBASE_GMK |