verbose.mk 1.1 KB

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