verbose.mk 1.4 KB

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