verbose.mk 1.3 KB

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