netifd: add flow steering mode to the packet steering script
[openwrt/openwrt.git] / include / verbose.mk
1 # SPDX-License-Identifier: GPL-2.0-only
2 #
3 # Copyright (C) 2006-2020 OpenWrt.org
4
5 ifndef OPENWRT_VERBOSE
6 OPENWRT_VERBOSE:=
7 endif
8 ifeq ("$(origin V)", "command line")
9 OPENWRT_VERBOSE:=$(V)
10 endif
11
12 ifeq ($(OPENWRT_VERBOSE),1)
13 OPENWRT_VERBOSE:=w
14 endif
15 ifeq ($(OPENWRT_VERBOSE),99)
16 OPENWRT_VERBOSE:=s
17 endif
18
19 ifeq ($(NO_TRACE_MAKE),)
20 NO_TRACE_MAKE := $(MAKE) V=s$(OPENWRT_VERBOSE)
21 export NO_TRACE_MAKE
22 endif
23
24 ifeq ($(IS_TTY),1)
25 ifneq ($(strip $(NO_COLOR)),1)
26 _Y:=\\033[33m
27 _R:=\\033[31m
28 _N:=\\033[m
29 endif
30 endif
31
32 define ERROR_MESSAGE
33 printf "$(_R)%s$(_N)\n" "$(1)" >&8
34 endef
35
36 ifeq ($(findstring s,$(OPENWRT_VERBOSE)),)
37 define MESSAGE
38 printf "$(_Y)%s$(_N)\n" "$(1)" >&8
39 endef
40
41 ifeq ($(QUIET),1)
42 ifneq ($(CURDIR),$(TOPDIR))
43 _DIR:=$(patsubst $(TOPDIR)/%,%,${CURDIR})
44 else
45 _DIR:=
46 endif
47 _NULL:=$(if $(MAKECMDGOALS),$(shell \
48 $(call MESSAGE, make[$(MAKELEVEL)]$(if $(_DIR), -C $(_DIR)) $(MAKECMDGOALS)); \
49 ))
50 SUBMAKE=$(MAKE)
51 else
52 SILENT:=>/dev/null $(if $(findstring w,$(OPENWRT_VERBOSE)),,2>&1)
53 export QUIET:=1
54 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
55 endif
56
57 .SILENT: $(MAKECMDGOALS)
58 else
59 SUBMAKE=$(MAKE) -w
60 define MESSAGE
61 printf "%s\n" "$(1)"
62 endef
63 endif