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