fed83d6fb6f69081081c40daf0f1d8fb555ed6e6
[openwrt/staging/mkresin.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
25 _N:=\\033[m
26 endif
27
28 ifneq ($(KBUILD_VERBOSE),99)
29 define MESSAGE
30 printf "$(_Y)%s$(_N)\n" "$(1)" >&3
31 endef
32
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 2>&1 $(MAKE)
45 endif
46 export QUIET:=1
47 MAKE:=cmd() { $(MAKE) -s $$* || { 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 else
52 define MESSAGE
53 printf "%s\n" "$(1)"
54 endef
55 endif