verbose.mk 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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. _Y:=\\033[33m
  19. _N:=\\033[m
  20. endif
  21. ifneq ($(KBUILD_VERBOSE),99)
  22. define MESSAGE
  23. printf "$(_Y)%s$(_N)\n" "$(1)" >&8
  24. endef
  25. ifeq ($(QUIET),1)
  26. ifneq ($(CURDIR),$(TOPDIR))
  27. _DIR:=$(patsubst $(TOPDIR)/%,%,${CURDIR})
  28. else
  29. _DIR:=
  30. endif
  31. _NULL:=$(if $(MAKECMDGOALS),$(shell \
  32. $(call MESSAGE, make[$(MAKELEVEL)]$(if $(_DIR), -C $(_DIR)) $(MAKECMDGOALS)); \
  33. ))
  34. SUBMAKE=$(MAKE)
  35. else
  36. ifeq ($(KBUILD_VERBOSE),0)
  37. SILENT:=>/dev/null 2>&1
  38. else
  39. SILENT:=
  40. endif
  41. export QUIET:=1
  42. SUBMAKE=cmd() { $(SILENT) $(MAKE) -s $$* || { echo "make $$*: build failed. Please re-run make with V=99 to see what's going on"; false; } } 8>&1 9>&2; cmd
  43. endif
  44. .SILENT: $(MAKECMDGOALS)
  45. else
  46. SUBMAKE=$(MAKE)
  47. define MESSAGE
  48. printf "%s\n" "$(1)"
  49. endef
  50. endif