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