verbose.mk 1.4 KB

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