16a75c08c9744ff741d46f397576d697c4a9d11f
[openwrt/openwrt.git] / openwrt / 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 NO_TRACE_MAKE:=$(MAKE) V=99
10
11 ifndef KBUILD_VERBOSE
12 KBUILD_VERBOSE=0
13 ifdef V
14 KBUILD_VERBOSE=$(V)
15 endif
16 endif
17
18 ifneq ($(KBUILD_VERBOSE),99)
19 ifeq ($(QUIET),1)
20 $(MAKECMDGOALS): trace
21 trace: FORCE
22 @[ -f "$(MAKECMDGOALS)" ] || { \
23 [ -z "$${PWD##$$TOPDIR}" ] || DIR=" -C $${PWD##$$TOPDIR/}"; \
24 echo -e "\33[33mmake[$$(($(MAKELEVEL)+1))]$$DIR $(MAKECMDGOALS)\33[m" >&3; \
25 }
26 else
27 export QUIET:=1
28 ifeq ($(KBUILD_VERBOSE),0)
29 MAKE:=&>/dev/null $(MAKE)
30 endif
31 MAKE:=cmd() { $(MAKE) $$* || { echo "Build failed. Please re-run make with V=99 to see what's going on"; /bin/false; } } 3>&1 4>&2; cmd
32 endif
33
34 .SILENT: $(MAKECMDGOALS)
35 else
36 NO_TRACE_MAKE:=$(MAKE)
37 endif