speed up the build system a little bit
[openwrt/staging/yousong.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 export NO_TRACE_MAKE
12 endif
13
14 ifndef KBUILD_VERBOSE
15 KBUILD_VERBOSE:=0
16 endif
17 ifeq ("$(origin V)", "command line")
18 KBUILD_VERBOSE:=$(V)
19 endif
20
21 ifneq ($(shell tty -s <&3 || echo x),x)
22 _Y:="\\33[33m"# yellow
23 _N:="\\33[m"# normal
24 endif
25
26 ifneq ($(KBUILD_VERBOSE),99)
27 ifeq ($(QUIET),1)
28 $(MAKECMDGOALS): trace
29 trace: FORCE
30 @[ -f "$(MAKECMDGOALS)" ] || { \
31 [ -z "$${PWD##$$TOPDIR}" ] || DIR=" -C $${PWD##$$TOPDIR/}"; \
32 echo -e "$(_Y)make[$$(($(MAKELEVEL)+1))]$$DIR $(MAKECMDGOALS)$(_N)" >&3; \
33 }
34 else
35 export QUIET:=1
36 ifeq ($(KBUILD_VERBOSE),0)
37 MAKE:=&>/dev/null $(MAKE)
38 endif
39 MAKE:=cmd() { $(MAKE) $$* || { echo "Build failed. Please re-run make with V=99 to see what's going on"; false; } } 3>&1 4>&2; cmd
40 endif
41
42 .SILENT: $(MAKECMDGOALS)
43 endif