verbose.mk 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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. # $Id:$
  8. ifeq ($(NO_TRACE_MAKE),)
  9. NO_TRACE_MAKE := $(MAKE) V=99
  10. export NO_TRACE_MAKE
  11. endif
  12. ifndef KBUILD_VERBOSE
  13. KBUILD_VERBOSE:=0
  14. endif
  15. ifeq ("$(origin V)", "command line")
  16. KBUILD_VERBOSE:=$(V)
  17. endif
  18. ifeq ($(IS_TTY),1)
  19. _Y:=\\033[33m
  20. _N:=\\033[m
  21. endif
  22. ifneq ($(KBUILD_VERBOSE),99)
  23. define MESSAGE
  24. printf "$(_Y)%s$(_N)\n" "$(1)" >&8
  25. endef
  26. ifeq ($(QUIET),1)
  27. ifneq ($(CURDIR),$(TOPDIR))
  28. _DIR:=$(patsubst $(TOPDIR)/%,%,${CURDIR})
  29. else
  30. _DIR:=
  31. endif
  32. _NULL:=$(if $(MAKECMDGOALS),$(shell \
  33. $(call MESSAGE, make[$(MAKELEVEL)]$(if $(_DIR), -C $(_DIR)) $(MAKECMDGOALS)); \
  34. ))
  35. SUBMAKE=$(MAKE)
  36. else
  37. ifeq ($(KBUILD_VERBOSE),0)
  38. SILENT:=>/dev/null 2>&1
  39. else
  40. SILENT:=
  41. endif
  42. export QUIET:=1
  43. 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
  44. endif
  45. .SILENT: $(MAKECMDGOALS)
  46. else
  47. SUBMAKE=$(MAKE)
  48. define MESSAGE
  49. printf "%s\n" "$(1)"
  50. endef
  51. endif