source: trunk/include/verbose.mk @ 31484

Last change on this file since 31484 was 31484, checked in by nbd, 4 years ago

build: rework verbosity level selection

V=99 and V=1 are now deprecated in favor of a new verbosity class system,
though the old flags are still supported.
You can set the V variable on the command line (or OPENWRT_VERBOSE in the
environment) to one or more of the following characters:

  • s: stdout+stderr (equal to the old V=99)
  • c: commands (for build systems that suppress commands by default, e.g. kbuild)
  • w: warnings/errors only (equal to the old V=1)
  • Property svn:eol-style set to native
File size: 1.3 KB
Line 
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
8ifndef OPENWRT_VERBOSE
9  OPENWRT_VERBOSE:=
10endif
11ifeq ("$(origin V)", "command line")
12  OPENWRT_VERBOSE:=$(V)
13endif
14
15ifeq ($(OPENWRT_VERBOSE),1)
16  OPENWRT_VERBOSE:=w
17endif
18ifeq ($(OPENWRT_VERBOSE),99)
19  OPENWRT_VERBOSE:=s
20endif
21
22ifeq ($(NO_TRACE_MAKE),)
23NO_TRACE_MAKE := $(MAKE) V=$(subst w,s,$(OPENWRT_VERBOSE))
24export NO_TRACE_MAKE
25endif
26
27ifeq ($(IS_TTY),1)
28  ifneq ($(strip $(NO_COLOR)),1)
29    _Y:=\\033[33m
30    _N:=\\033[m
31  endif
32endif
33
34ifeq ($(findstring s,$(OPENWRT_VERBOSE)),)
35  define MESSAGE
36        printf "$(_Y)%s$(_N)\n" "$(1)" >&8
37  endef
38
39  ifeq ($(QUIET),1)
40    ifneq ($(CURDIR),$(TOPDIR))
41      _DIR:=$(patsubst $(TOPDIR)/%,%,${CURDIR})
42    else
43      _DIR:=
44    endif
45    _NULL:=$(if $(MAKECMDGOALS),$(shell \
46                $(call MESSAGE, make[$(MAKELEVEL)]$(if $(_DIR), -C $(_DIR)) $(MAKECMDGOALS)); \
47    ))
48    SUBMAKE=$(MAKE)
49  else
50    SILENT:=>/dev/null $(if $(findstring w,$(OPENWRT_VERBOSE)),,2>&1)
51    export QUIET:=1
52    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
53  endif
54
55  .SILENT: $(MAKECMDGOALS)
56else
57  SUBMAKE=$(MAKE) -w
58  define MESSAGE
59    printf "%s\n" "$(1)"
60  endef
61endif
Note: See TracBrowser for help on using the repository browser.