verbose.mk 985 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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" # yellow
  20. _N:="\\033[m" #normal
  21. endif
  22. ifneq ($(KBUILD_VERBOSE),99)
  23. ifeq ($(QUIET),1)
  24. $(MAKECMDGOALS): trace
  25. trace: FORCE
  26. @[ -f "$(MAKECMDGOALS)" ] || { \
  27. [ -z "$${PWD##$$TOPDIR}" ] || DIR=" -C $${PWD##$$TOPDIR/}"; \
  28. echo -e "$(_Y)make[$$(($(MAKELEVEL)+1))]$$DIR $(MAKECMDGOALS)$(_N)" >&3; \
  29. }
  30. else
  31. export QUIET:=1
  32. ifeq ($(KBUILD_VERBOSE),0)
  33. MAKE:=&>/dev/null $(MAKE)
  34. endif
  35. MAKE:=cmd() { $(MAKE) $$* || { echo "Build failed. Please re-run make with V=99 to see what's going on"; false; } } 3>&1 4>&2; cmd
  36. endif
  37. .SILENT: $(MAKECMDGOALS)
  38. endif