verbose.mk 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #
  2. # Copyright (C) 2006 OpenWrt.org
  3. #
  4. # This is free software, licensed under the GNU General Public License v2.
  5. # See /LICENSE for more information.
  6. #
  7. ifeq ($(NO_TRACE_MAKE),)
  8. NO_TRACE_MAKE := $(MAKE) V=99
  9. export NO_TRACE_MAKE
  10. endif
  11. ifndef KBUILD_VERBOSE
  12. KBUILD_VERBOSE:=0
  13. endif
  14. ifeq ("$(origin V)", "command line")
  15. KBUILD_VERBOSE:=$(V)
  16. endif
  17. ifeq ($(IS_TTY),1)
  18. ifneq ($(strip $(NO_COLOR)),1)
  19. _Y:=\\033[33m
  20. _N:=\\033[m
  21. endif
  22. endif
  23. ifneq ($(KBUILD_VERBOSE),99)
  24. define MESSAGE
  25. printf "$(_Y)%s$(_N)\n" "$(1)" >&8
  26. endef
  27. ifeq ($(QUIET),1)
  28. ifneq ($(CURDIR),$(TOPDIR))
  29. _DIR:=$(patsubst $(TOPDIR)/%,%,${CURDIR})
  30. else
  31. _DIR:=
  32. endif
  33. _NULL:=$(if $(MAKECMDGOALS),$(shell \
  34. $(call MESSAGE, make[$(MAKELEVEL)]$(if $(_DIR), -C $(_DIR)) $(MAKECMDGOALS)); \
  35. ))
  36. SUBMAKE=$(MAKE)
  37. else
  38. ifeq ($(KBUILD_VERBOSE),0)
  39. SILENT:=>/dev/null 2>&1
  40. else
  41. SILENT:=
  42. endif
  43. export QUIET:=1
  44. SUBMAKE=cmd() { $(SILENT) $(MAKE) -s $$* < /dev/null || { echo "make $$*: build failed. Please re-run make with V=99 to see what's going on"; false; } } 8>&1 9>&2; cmd
  45. endif
  46. .SILENT: $(MAKECMDGOALS)
  47. else
  48. SUBMAKE=$(MAKE) -w
  49. define MESSAGE
  50. printf "%s\n" "$(1)"
  51. endef
  52. endif