debug.mk 843 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #
  2. # Copyright (C) 2007 OpenWrt.org
  3. #
  4. # This is free software, licensed under the GNU General Public License v2.
  5. # See /LICENSE for more information.
  6. #
  7. # debug flags:
  8. #
  9. # d: show subdirectory tree
  10. # t: show added targets
  11. # l: show legacy targets
  12. # r: show autorebuild messages
  13. # v: verbose (no .SILENCE for common targets)
  14. ifeq ($(DUMP),)
  15. ifeq ($(DEBUG),all)
  16. build_debug:=dltvr
  17. else
  18. build_debug:=$(DEBUG)
  19. endif
  20. endif
  21. ifneq ($(DEBUG),)
  22. define debug
  23. $$(findstring $(2),$$(if $$(DEBUG_SCOPE_DIR),$$(if $$(filter $$(DEBUG_SCOPE_DIR)%,$(1)),$(build_debug)),$(build_debug)))
  24. endef
  25. define warn
  26. $$(if $(call debug,$(1),$(2)),$$(warning $(3)))
  27. endef
  28. define debug_eval
  29. $$(if $(call debug,$(1),$(2)),$(3))
  30. endef
  31. define warn_eval
  32. $(call warn,$(1),$(2),$(3) $(4))
  33. $(4)
  34. endef
  35. else
  36. debug:=
  37. warn:=
  38. debug_eval:=
  39. warn_eval = $(4)
  40. endif