444 $(filter $(addsuffix %,$1),$(FIND_CACHE))) |
444 $(filter $(addsuffix %,$1),$(FIND_CACHE))) |
445 endef |
445 endef |
446 |
446 |
447 ################################################################################ |
447 ################################################################################ |
448 |
448 |
|
449 define AddFileToCopy |
|
450 # Helper macro for SetupCopyFiles |
|
451 # 1 : Source file |
|
452 # 2 : Dest file |
|
453 # 3 : Variable to add targets to |
|
454 # 4 : Macro to call for copy operation |
|
455 $2: $1 |
|
456 $(ECHO) $(LOG_INFO) Copying $$(patsubst $(OUTPUT_ROOT)/%,%,$$@) |
|
457 $$($$(strip $4)) |
|
458 |
|
459 $3 += $2 |
|
460 endef |
|
461 |
|
462 define SetupCopyFiles |
|
463 # param 1 is for example COPY_MYFILES |
|
464 # param 2,3,4,5 are named args. |
|
465 # SRC : Source root dir (defaults to dir of first file) |
|
466 # DEST : Dest root dir |
|
467 # FILES : List of files to copy with absolute paths, or path relative to SRC. |
|
468 # Must be in SRC. |
|
469 # FLATTEN : Set to flatten the directory structure in the DEST dir. |
|
470 # MACRO : Optionally override the default macro used for making the copy. |
|
471 # Default is 'install-file' |
|
472 $(foreach i,2 3 4 5 6, $(if $($i),$1_$(strip $($i)))$(NEWLINE)) |
|
473 $(call LogSetupMacroEntry,SetupCopyFiles($1),$2,$3,$4,$5,$6) |
|
474 $(if $(7),$(error Internal makefile error: Too many arguments to SetupCopyFiles)) |
|
475 |
|
476 ifeq ($$($1_MACRO), ) |
|
477 $1_MACRO := install-file |
|
478 endif |
|
479 |
|
480 # Default SRC to the dir of the first file. |
|
481 ifeq ($$($1_SRC), ) |
|
482 $1_SRC := $$(dir $$(firstword $$($1_FILES))) |
|
483 endif |
|
484 |
|
485 # Remove any trailing slash from SRC |
|
486 $1_SRC := $$(patsubst %/,%,$$($1_SRC)) |
|
487 |
|
488 $$(foreach f, $$(patsubst $$($1_SRC)/%,%,$$($1_FILES)), \ |
|
489 $$(eval $$(call AddFileToCopy, $$($1_SRC)/$$f, \ |
|
490 $$($1_DEST)/$$(if $$($1_FLATTEN),$$(notdir $$f),$$f), $1, $$($1_MACRO)))) |
|
491 |
|
492 endef |
|
493 |
|
494 ################################################################################ |
|
495 |
449 endif # _MAKEBASE_GMK |
496 endif # _MAKEBASE_GMK |