< prev index next >

make/common/MakeBase.gmk

Print this page




 360     LOG_INFO=> /dev/null
 361   endif
 362   ifneq ($$(findstring $$(LOG_LEVEL),debug trace),)
 363     LOG_DEBUG=
 364   else
 365     LOG_DEBUG=> /dev/null
 366   endif
 367   ifneq ($$(findstring $$(LOG_LEVEL),trace),)
 368     LOG_TRACE=
 369   else
 370     LOG_TRACE=> /dev/null
 371   endif
 372 endef
 373 
 374 # Make sure logging is setup for everyone that includes MakeBase.gmk.
 375 $(eval $(call SetupLogging))
 376 
 377 # This is to be called by all SetupFoo macros
 378 define LogSetupMacroEntry
 379   $(if $(27),$(error Internal makefile error: Too many arguments to LogSetupMacroEntry, please update MakeBase.gmk))
 380   $(if $(findstring $(LOG_LEVEL),debug trace), $(info $1 $(foreach i,2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26,$(if $($i),$(NEWLINE) $(strip [$i] $($i))))))
 381 endef
 382 
 383 # Support macro for all SetupFoo macros.
 384 define EvalDebugWrapper
 385   $(if $(DEBUG_$1),
 386     $(info -------- <<< Begin expansion of $1)
 387     $(info $2)
 388     $(info -------- >>> End expansion of $1)
 389   )
 390 
 391   $2
 392 endef
 393 
 394 # Make directory without forking mkdir if not needed
 395 define MakeDir
 396   ifneq ($$(wildcard $1 $2 $3 $4 $5 $6 $7 $8 $9),$$(strip $1 $2 $3 $4 $5 $6 $7 $8 $9))
 397     $$(shell $(MKDIR) -p $1 $2 $3 $4 $5 $6 $7 $8 $9)
 398   endif
 399 endef
 400 


 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


 360     LOG_INFO=> /dev/null
 361   endif
 362   ifneq ($$(findstring $$(LOG_LEVEL),debug trace),)
 363     LOG_DEBUG=
 364   else
 365     LOG_DEBUG=> /dev/null
 366   endif
 367   ifneq ($$(findstring $$(LOG_LEVEL),trace),)
 368     LOG_TRACE=
 369   else
 370     LOG_TRACE=> /dev/null
 371   endif
 372 endef
 373 
 374 # Make sure logging is setup for everyone that includes MakeBase.gmk.
 375 $(eval $(call SetupLogging))
 376 
 377 # This is to be called by all SetupFoo macros
 378 define LogSetupMacroEntry
 379   $(if $(27),$(error Internal makefile error: Too many arguments to LogSetupMacroEntry, please update MakeBase.gmk))
 380   $(if $(findstring $(LOG_LEVEL),debug trace), $(info $1 $(foreach i,2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26,$(if $(strip $($i)),$(NEWLINE) $(strip [$i] $($i))))))
 381 endef
 382 
 383 # Support macro for all SetupFoo macros.
 384 define EvalDebugWrapper
 385   $(if $(DEBUG_$1),
 386     $(info -------- <<< Begin expansion of $1)
 387     $(info $2)
 388     $(info -------- >>> End expansion of $1)
 389   )
 390 
 391   $2
 392 endef
 393 
 394 # Make directory without forking mkdir if not needed
 395 define MakeDir
 396   ifneq ($$(wildcard $1 $2 $3 $4 $5 $6 $7 $8 $9),$$(strip $1 $2 $3 $4 $5 $6 $7 $8 $9))
 397     $$(shell $(MKDIR) -p $1 $2 $3 $4 $5 $6 $7 $8 $9)
 398   endif
 399 endef
 400 


 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 # Setup make rules for copying files, with an option to do more complex
 524 # processing instead of copying.
 525 #
 526 # Parameter 1 is the name of the rule. This name is used as variable prefix,
 527 # and the targets generated are listed in a variable by that name.
 528 #
 529 # Remaining parameters are named arguments. These include:
 530 #   SRC   : Source root dir
 531 #   DEST  : Dest root dir
 532 #   FILES : List of files to copy with absolute paths, or path relative to SRC. Must be in SRC.
 533 #   FLATTEN : Set to flatten the directory structure in the DEST dir.
 534 #   MACRO : Optionally override the default macro used for making the copy. Default is 'install-file'
 535 
 536 define SetupCopyFiles
 537   $(if $(16),$(error Internal makefile error: Too many arguments to SetupCopyFiles, please update MakeBase.gmk))
 538   $(call EvalDebugWrapper,$(strip $1),$(call SetupCopyFilesInner,$(strip $1),$2,$3,$4,$5,$6,$7,$8,$9,$(10),$(11),$(12),$(13),$(14),$(15)))
 539 endef
 540 
 541 define SetupCopyFilesInner
 542   $(foreach i,2 3 4 5 6, $(if $(strip $($i)),$1_$(strip $($i)))$(NEWLINE))


 543   $(call LogSetupMacroEntry,SetupCopyFiles($1),$2,$3,$4,$5,$6)
 544   $(if $(7),$(error Internal makefile error: Too many arguments to SetupCopyFiles, please update MakeBase.gmk))
 545 
 546   ifeq ($$($1_MACRO), )
 547     $1_MACRO := install-file
 548   endif
 549 
 550   $$(foreach f, $$(patsubst $$($1_SRC)/%,%,$$($1_FILES)), \
 551       $$(eval $$(call AddFileToCopy, $$($1_SRC)/$$f, \
 552       $$($1_DEST)/$$(if $$($1_FLATTEN),$$(notdir $$f),$$f), $1, $$($1_MACRO))))
 553 
 554 endef
 555 
 556 ################################################################################
 557 
 558 # Hook to include the corresponding custom file, if present.
 559 $(eval $(call IncludeCustomExtension, , common/MakeBase.gmk))
 560 
 561 endif # _MAKEBASE_GMK
< prev index next >