verbose.mk 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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. define MESSAGE
  23. echo -e "$(_Y)$(1)$(_N)" >&3
  24. endef
  25. ifneq ($(KBUILD_VERBOSE),99)
  26. ifeq ($(QUIET),1)
  27. $(MAKECMDGOALS): trace
  28. trace: FORCE
  29. @[ -f "$(MAKECMDGOALS)" ] || { \
  30. [ -z "$${PWD##$$TOPDIR}" ] || DIR=" -C $${PWD##$$TOPDIR/}"; \
  31. $(call MESSAGE, "make[$$(($(MAKELEVEL)+1))]$$DIR $(MAKECMDGOALS)"); \
  32. }
  33. else
  34. export QUIET:=1
  35. ifeq ($(KBUILD_VERBOSE),0)
  36. MAKE:=&>/dev/null $(MAKE)
  37. endif
  38. 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
  39. endif
  40. .SILENT: $(MAKECMDGOALS)
  41. endif