From 7470f0e2b32b351a9b60e51bd0aa279fbc18755f Mon Sep 17 00:00:00 2001
From: Felix Fietkau <nbd@openwrt.org>
Date: Thu, 26 Apr 2012 17:53:56 +0000
Subject: [PATCH] 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)

SVN-Revision: 31484
---
 include/kernel-defaults.mk         |  7 ++-----
 include/verbose.mk                 | 31 ++++++++++++++++--------------
 scripts/feeds                      |  2 +-
 target/imagebuilder/files/Makefile |  2 +-
 4 files changed, 21 insertions(+), 21 deletions(-)

diff --git a/include/kernel-defaults.mk b/include/kernel-defaults.mk
index 6864793a27..0c188502fc 100644
--- a/include/kernel-defaults.mk
+++ b/include/kernel-defaults.mk
@@ -9,7 +9,8 @@ KERNEL_MAKEOPTS := -C $(LINUX_DIR) \
 	CROSS_COMPILE="$(KERNEL_CROSS)" \
 	ARCH="$(LINUX_KARCH)" \
 	KBUILD_HAVE_NLS=no \
-	CONFIG_SHELL="$(BASH)"
+	CONFIG_SHELL="$(BASH)" \
+	$(if $(findstring c,$(OPENWRT_VERBOSE)),V=1)
 
 ifdef CONFIG_STRIP_KERNEL_EXPORTS
   KERNEL_MAKEOPTS += \
@@ -22,10 +23,6 @@ ifneq (,$(KERNEL_CC))
   KERNEL_MAKEOPTS += CC="$(KERNEL_CC)"
 endif
 
-ifeq ($(KBUILD_VERBOSE),99)
-  KERNEL_MAKEOPTS += V=1
-endif
-
 export HOST_EXTRACFLAGS=-I$(STAGING_DIR_HOST)/include
 
 # defined in quilt.mk
diff --git a/include/verbose.mk b/include/verbose.mk
index 9fe27ced52..e17b1264d8 100644
--- a/include/verbose.mk
+++ b/include/verbose.mk
@@ -5,16 +5,23 @@
 # See /LICENSE for more information.
 #
 
-ifeq ($(NO_TRACE_MAKE),)
-NO_TRACE_MAKE := $(MAKE) V=99
-export NO_TRACE_MAKE
+ifndef OPENWRT_VERBOSE
+  OPENWRT_VERBOSE:=
+endif
+ifeq ("$(origin V)", "command line")
+  OPENWRT_VERBOSE:=$(V)
 endif
 
-ifndef KBUILD_VERBOSE
-  KBUILD_VERBOSE:=0
+ifeq ($(OPENWRT_VERBOSE),1)
+  OPENWRT_VERBOSE:=w
 endif
-ifeq ("$(origin V)", "command line")
-  KBUILD_VERBOSE:=$(V)
+ifeq ($(OPENWRT_VERBOSE),99)
+  OPENWRT_VERBOSE:=s
+endif
+
+ifeq ($(NO_TRACE_MAKE),)
+NO_TRACE_MAKE := $(MAKE) V=$(subst w,s,$(OPENWRT_VERBOSE))
+export NO_TRACE_MAKE
 endif
 
 ifeq ($(IS_TTY),1)
@@ -24,7 +31,7 @@ ifeq ($(IS_TTY),1)
   endif
 endif
 
-ifneq ($(KBUILD_VERBOSE),99)
+ifeq ($(findstring s,$(OPENWRT_VERBOSE)),)
   define MESSAGE
 	printf "$(_Y)%s$(_N)\n" "$(1)" >&8
   endef
@@ -40,13 +47,9 @@ ifneq ($(KBUILD_VERBOSE),99)
     ))
     SUBMAKE=$(MAKE)
   else
-    ifeq ($(KBUILD_VERBOSE),0)
-      SILENT:=>/dev/null 2>&1
-    else
-      SILENT:=
-    endif
+    SILENT:=>/dev/null $(if $(findstring w,$(OPENWRT_VERBOSE)),,2>&1)
     export QUIET:=1
-    SUBMAKE=cmd() { $(SILENT) $(MAKE) -s $$* < /dev/null || { echo "make $$*: build failed. Please re-run make with V=99 to see what's going on"; false; } } 8>&1 9>&2; cmd
+    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
   endif
 
   .SILENT: $(MAKECMDGOALS)
diff --git a/scripts/feeds b/scripts/feeds
index 1b7aab79cc..b8c6825ed0 100755
--- a/scripts/feeds
+++ b/scripts/feeds
@@ -540,7 +540,7 @@ sub update {
 	my $perform_update=1;
 
 	$ENV{SCAN_COOKIE} = $$;
-	$ENV{KBUILD_VERBOSE} = 99;
+	$ENV{OPENWRT_VERBOSE} = 's';
 
 	getopts('ahi', \%opts);
 
diff --git a/target/imagebuilder/files/Makefile b/target/imagebuilder/files/Makefile
index f74b407896..c1177f1ba3 100644
--- a/target/imagebuilder/files/Makefile
+++ b/target/imagebuilder/files/Makefile
@@ -10,7 +10,7 @@ TOPDIR:=${CURDIR}
 LC_ALL:=C
 LANG:=C
 export TOPDIR LC_ALL LANG
-export KBUILD_VERBOSE=99
+export OPENWRT_VERBOSE=s
 all: help
 
 include $(TOPDIR)/include/host.mk
-- 
2.30.2