diff mbox

Handle verbosity in infrastructures

Message ID 1441487237-10040-1-git-send-email-cedric.marie@openmailbox.org
State Superseded
Headers show

Commit Message

Cédric Marie Sept. 5, 2015, 9:07 p.m. UTC
The verbosity of the build step is controlled in a different way for
every type of infrastructure. It is not possible to export a variable
that could be understood by all of them.

As a consequence, in root Makefile:
* 'VERBOSE' is removed.
* 'KBUILD_VERBOSE' and 'quiet' are also removed, because they are not
  used.
* 'Q' is kept because it is used by Buildroot.

Instead, each infrastructure should add a specific variable to export
at build time, when V is set in the command line ('make V=1').

* CMake adds 'VERBOSE=1' when V=1
* Autotools forward 'V=0' and 'V=1'. The default behaviour depends on
  the package. It is kept unchanged, unless explicitly modified by
  'make V=0' or 'make V=1'.

Signed-off-by: Cédric Marie <cedric.marie@openmailbox.org>
---
 Makefile                 | 18 +++---------------
 package/pkg-autotools.mk | 16 ++++++++++++++--
 package/pkg-cmake.mk     | 12 ++++++++++--
 3 files changed, 27 insertions(+), 19 deletions(-)

Comments

Arnout Vandecappelle Sept. 6, 2015, 9:50 p.m. UTC | #1
Hi Cédric,

On 05-09-15 23:07, Cédric Marie wrote:
> The verbosity of the build step is controlled in a different way for
> every type of infrastructure. It is not possible to export a variable
> that could be understood by all of them.
> 
> As a consequence, in root Makefile:
> * 'VERBOSE' is removed.
> * 'KBUILD_VERBOSE' and 'quiet' are also removed, because they are not
>   used.

 Perhaps the removal of KBUILD_VERBOSE and quiet should be a separate patch,
since that's a change that shouldn't make any difference. The verbose-handling
in cmake and autotools, on the other hand, do change the behaviour.

> * 'Q' is kept because it is used by Buildroot.
> 
> Instead, each infrastructure should add a specific variable to export
> at build time, when V is set in the command line ('make V=1').
> 
> * CMake adds 'VERBOSE=1' when V=1
> * Autotools forward 'V=0' and 'V=1'. The default behaviour depends on
>   the package. It is kept unchanged, unless explicitly modified by
>   'make V=0' or 'make V=1'.
> 
> Signed-off-by: Cédric Marie <cedric.marie@openmailbox.org>
> ---
>  Makefile                 | 18 +++---------------
>  package/pkg-autotools.mk | 16 ++++++++++++++--
>  package/pkg-cmake.mk     | 12 ++++++++++--
>  3 files changed, 27 insertions(+), 19 deletions(-)
> 
> diff --git a/Makefile b/Makefile
> index 23e2ee6..4a6c9ef 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -218,23 +218,11 @@ endif
>  
>  # To put more focus on warnings, be less verbose as default
>  # Use 'make V=1' to see the full commands
> +Q = @
>  ifeq ("$(origin V)", "command line")
> -  KBUILD_VERBOSE = $(V)
> -endif
> -ifndef KBUILD_VERBOSE
> -  KBUILD_VERBOSE = 0
> -endif
> -
> -ifeq ($(KBUILD_VERBOSE),1)
> -  quiet =
> +ifeq ($(V),1)
>    Q =
> -ifndef VERBOSE
> -  VERBOSE = 1
>  endif
> -export VERBOSE
> -else
> -  quiet = quiet_
> -  Q = @
>  endif
>  
>  # we want bash as shell
> @@ -245,7 +233,7 @@ SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \
>  # kconfig uses CONFIG_SHELL
>  CONFIG_SHELL := $(SHELL)
>  
> -export SHELL CONFIG_SHELL quiet Q KBUILD_VERBOSE
> +export SHELL CONFIG_SHELL Q
>  
>  ifndef HOSTAR
>  HOSTAR := ar
> diff --git a/package/pkg-autotools.mk b/package/pkg-autotools.mk
> index 4787914..18ab1ae 100644
> --- a/package/pkg-autotools.mk
> +++ b/package/pkg-autotools.mk
> @@ -94,6 +94,18 @@ define AUTORECONF_HOOK
>  	$(Q)cd $($(PKG)_SRCDIR) && $($(PKG)_AUTORECONF_ENV) $(AUTORECONF) $($(PKG)_AUTORECONF_OPTS)
>  endef
>  
> +# During build step:
> +# 'make V=0' disables the verbose mode (if enabled by the package)
> +# 'make V=1' enables the verbose mode (if not already enabled by the package)

 Add a comment here that we use the package's default unless V=0/1 was passed on
the command line.

> +AUTOTOOLS_VERBOSE =

 Not needed to initialize it empty.

> +ifeq ("$(origin V)", "command line")
> +ifeq ($(V),0)
> +  AUTOTOOLS_VERBOSE = V=0
> +else ifeq ($(V),1)
> +  AUTOTOOLS_VERBOSE = V=1
> +endif

 This can just be:
AUTOTOOLS_VERBOSE = V=$(V)

 Also, no indentation inside make conditions.


 I also don't really like that the $(origin V) condition is repeated, but the
alternatives don't look better either.


> +endif
> +
>  ################################################################################
>  # inner-autotools-package -- defines how the configuration, compilation and
>  # installation of an autotools package should be done, implements a
> @@ -271,11 +283,11 @@ endif
>  ifndef $(2)_BUILD_CMDS
>  ifeq ($(4),target)
>  define $(2)_BUILD_CMDS
> -	$$(TARGET_MAKE_ENV) $$($$(PKG)_MAKE_ENV) $$($$(PKG)_MAKE) $$($$(PKG)_MAKE_OPTS) -C $$($$(PKG)_SRCDIR)
> +	$$(TARGET_MAKE_ENV) $$($$(PKG)_MAKE_ENV) $$($$(PKG)_MAKE) $$($$(PKG)_MAKE_OPTS) -C $$($$(PKG)_SRCDIR) $(AUTOTOOLS_VERBOSE)
>  endef
>  else
>  define $(2)_BUILD_CMDS
> -	$$(HOST_MAKE_ENV) $$($$(PKG)_MAKE_ENV) $$($$(PKG)_MAKE) $$($$(PKG)_MAKE_OPTS) -C $$($$(PKG)_SRCDIR)
> +	$$(HOST_MAKE_ENV) $$($$(PKG)_MAKE_ENV) $$($$(PKG)_MAKE) $$($$(PKG)_MAKE_OPTS) -C $$($$(PKG)_SRCDIR) $(AUTOTOOLS_VERBOSE)
>  endef
>  endif
>  endif
> diff --git a/package/pkg-cmake.mk b/package/pkg-cmake.mk
> index 574eccc..8e57a9c 100644
> --- a/package/pkg-cmake.mk
> +++ b/package/pkg-cmake.mk
> @@ -35,6 +35,14 @@ ifneq ($(QUIET),)
>  CMAKE_QUIET = -DCMAKE_RULE_MESSAGES=OFF -DCMAKE_INSTALL_MESSAGE=NEVER
>  endif
>  
> +# 'make V=1' enables the verbose mode during build step
> +CMAKE_VERBOSE =

 Again, not needed to initialize it empty.

> +ifeq ("$(origin V)", "command line")
> +ifeq ($(V),1)
> +  CMAKE_VERBOSE = VERBOSE=1

 So no indentation here either.


 Otherwise, looks good to me :-)

 Regards,
 Arnout

> +endif
> +endif
> +
>  ################################################################################
>  # inner-cmake-package -- defines how the configuration, compilation and
>  # installation of a CMake package should be done, implements a few hooks to
> @@ -159,11 +167,11 @@ $(2)_DEPENDENCIES += host-cmake
>  ifndef $(2)_BUILD_CMDS
>  ifeq ($(4),target)
>  define $(2)_BUILD_CMDS
> -	$$(TARGET_MAKE_ENV) $$($$(PKG)_MAKE_ENV) $$($$(PKG)_MAKE) $$($$(PKG)_MAKE_OPTS) -C $$($$(PKG)_BUILDDIR)
> +	$$(TARGET_MAKE_ENV) $$($$(PKG)_MAKE_ENV) $$($$(PKG)_MAKE) $$($$(PKG)_MAKE_OPTS) -C $$($$(PKG)_BUILDDIR) $(CMAKE_VERBOSE)
>  endef
>  else
>  define $(2)_BUILD_CMDS
> -	$$(HOST_MAKE_ENV) $$($$(PKG)_MAKE_ENV) $$($$(PKG)_MAKE) $$($$(PKG)_MAKE_OPTS) -C $$($$(PKG)_BUILDDIR)
> +	$$(HOST_MAKE_ENV) $$($$(PKG)_MAKE_ENV) $$($$(PKG)_MAKE) $$($$(PKG)_MAKE_OPTS) -C $$($$(PKG)_BUILDDIR) $(CMAKE_VERBOSE)
>  endef
>  endif
>  endif
>
Cédric Marie Sept. 7, 2015, 10:25 a.m. UTC | #2
Le 2015-09-06 23:50, Arnout Vandecappelle a écrit :

>  Perhaps the removal of KBUILD_VERBOSE and quiet should be a separate 
> patch,
> since that's a change that shouldn't make any difference. The 
> verbose-handling
> in cmake and autotools, on the other hand, do change the behaviour.

OK for two patches.
By the way, I think that this part of code could be removed from 
support/scripts/mkmakefile:

if [ "${quiet}" != "silent_" ]; then

because quiet is currently never set to "silent_". And moreover I'm 
removing it.
But this code comes from the kernel I believe, so I'm not sure it's a 
good idea to simply change it.


>  Add a comment here that we use the package's default unless V=0/1 was 
> passed on
> the command line.

Yes, I agree that it's not very clear.


>> +AUTOTOOLS_VERBOSE =
> 
>  Not needed to initialize it empty.


What if I export AUTOTOOLS_VERBOSE=1 in my shell? Not necessarily to 
hack Buildroot, but maybe because this variable has to be set in my 
shell environnement for another purpose.
Isn't it more robust if I prevent this kind of (very) particular use 
case?



>> +ifeq ("$(origin V)", "command line")
>> +ifeq ($(V),0)
>> +  AUTOTOOLS_VERBOSE = V=0
>> +else ifeq ($(V),1)
>> +  AUTOTOOLS_VERBOSE = V=1
>> +endif
> 
>  This can just be:
> AUTOTOOLS_VERBOSE = V=$(V)

Shouldn't we check that the value makes sense for autotools?
What if I use make V=3, make V=zzz, or make V=


>  Also, no indentation inside make conditions.

OK, I will change it, but this rule is not always respected :-)
The code in root Makefile was indented this way, with 2 spaces.


>  I also don't really like that the $(origin V) condition is repeated, 
> but the
> alternatives don't look better either.

What I don't like with this syntax, is that there is no way to check "if 
condition AND condition". That's why I initialize the variable with a 
value that may be changed a few lines below...
Using BR2_VERBOSE sounded nice to me, but I'm respecting your 
preferences :)


>> +CMAKE_VERBOSE =
> 
>  Again, not needed to initialize it empty.

Same remark as above.


>  Otherwise, looks good to me :-)

Thanks :)

By the way, as mentioned in another mail (the initial discussion 
thread), shouldn't I modify docs/manual/make-tips.txt with the new V=0 
possibility?
I said that V=0 was very specific to autotools, but in fact V=1 is 
already specific to cmake and some autotools packages (the ones that 
have support for this option).

Regards,
Arnout Vandecappelle Sept. 7, 2015, 12:09 p.m. UTC | #3
On 07-09-15 12:25, Cédric Marie wrote:
> Le 2015-09-06 23:50, Arnout Vandecappelle a écrit :
> 
>>  Perhaps the removal of KBUILD_VERBOSE and quiet should be a separate patch,
>> since that's a change that shouldn't make any difference. The verbose-handling
>> in cmake and autotools, on the other hand, do change the behaviour.
> 
> OK for two patches.
> By the way, I think that this part of code could be removed from
> support/scripts/mkmakefile:
> 
> if [ "${quiet}" != "silent_" ]; then
> 
> because quiet is currently never set to "silent_". And moreover I'm removing it.

 Correct! I did a git grep to verify, but there were so many hits in patches and
such that I proceeded to look only at .mk files, so this one slipped by.


> But this code comes from the kernel I believe, so I'm not sure it's a good idea
> to simply change it.

 Don't worry about that, we don't keep this file in sync with the kernel (same
for the top-level makefile). The only thing we do keep in sync is the kconfig infra.

> 
> 
>>  Add a comment here that we use the package's default unless V=0/1 was passed on
>> the command line.
> 
> Yes, I agree that it's not very clear.
> 
> 
>>> +AUTOTOOLS_VERBOSE =
>>
>>  Not needed to initialize it empty.
> 
> 
> What if I export AUTOTOOLS_VERBOSE=1 in my shell? Not necessarily to hack
> Buildroot, but maybe because this variable has to be set in my shell
> environnement for another purpose.
> Isn't it more robust if I prevent this kind of (very) particular use case?

 Good point, you're right. Perhaps add a comment to clarify that.
# Override value passed in the environment

> 
> 
> 
>>> +ifeq ("$(origin V)", "command line")
>>> +ifeq ($(V),0)
>>> +  AUTOTOOLS_VERBOSE = V=0
>>> +else ifeq ($(V),1)
>>> +  AUTOTOOLS_VERBOSE = V=1
>>> +endif
>>
>>  This can just be:
>> AUTOTOOLS_VERBOSE = V=$(V)
> 
> Shouldn't we check that the value makes sense for autotools?
> What if I use make V=3, make V=zzz, or make V=

 Garbage in, garbage out :-) The documentation clearly states that it should be
V=1. In fact, V=0 is currently not documented, perhaps that could be added. But
I don't see that as very important.


>>  Also, no indentation inside make conditions.
> 
> OK, I will change it, but this rule is not always respected :-)
> The code in root Makefile was indented this way, with 2 spaces.

 If you do a git blame, you should see that all the lines with wrong indentation
are more than 2 years old. Lately we've been paying attention to consistent
indentation, but nobody has bothered to update existing Makefiles.

> 
> 
>>  I also don't really like that the $(origin V) condition is repeated, but the
>> alternatives don't look better either.
> 
> What I don't like with this syntax, is that there is no way to check "if
> condition AND condition". That's why I initialize the variable with a value that
> may be changed a few lines below...

 Well, you can actually put the two conditions on a single line but it looks
even worse:

ifeq ("$(origin V)"$(V), "command line"1)

> Using BR2_VERBOSE sounded nice to me, but I'm respecting your preferences :)

 I don't remember saying anything about BR2_VERBOSE, and I also can't find it in
the mails I sent (but I didn't check too carefully). I may have said something
about exporting such a variable - since nobody uses it there's no point
exporting it. Also, it doesn't match the naming convention: if it is a purely
internal (non-exported) variable, it should be just VERBOSE; if it is an
exported variable, it should be BR_VERBOSE because it is not user-visible or
Kconfig related (only user-visible or Kconfig options should have the BR2_
prefix, all others should have a BR_ prefix).

> 
> 
>>> +CMAKE_VERBOSE =
>>
>>  Again, not needed to initialize it empty.
> 
> Same remark as above.
> 
> 
>>  Otherwise, looks good to me :-)
> 
> Thanks :)
> 
> By the way, as mentioned in another mail (the initial discussion thread),
> shouldn't I modify docs/manual/make-tips.txt with the new V=0 possibility?

 Exactly :-)

> I said that V=0 was very specific to autotools, but in fact V=1 is already
> specific to cmake and some autotools packages (the ones that have support for
> this option).

 Well, V=1 is specific to buildroot, and we also export it to autotools and
cmake packages. So indeed, that could be added to the documentation as well.

 Documentation updates should probably be in a separate patch since it usually
gets some more discussion about wording etc. and that shouldn't stop the
acceptance of the code change itself.

 Regards,
 Arnout

> 
> Regards,
>
Cédric Marie Sept. 7, 2015, 2:08 p.m. UTC | #4
Le 2015-09-07 14:09, Arnout Vandecappelle a écrit :
>  Good point, you're right. Perhaps add a comment to clarify that.
> # Override value passed in the environment

OK. I'll add a comment.

>  Garbage in, garbage out :-)

Yes, but the error will only occur when it comes to compiling an 
autotools package. It may be disturbing to be notified so late, that the 
option was not correct. Well, in my case, it is simply ignored, so we're 
not notified at all... that's no better.

make V=0/1 is Buildroot "API", and althought it is the same as autotools 
"API", I think we should "translate" it, and prevent Buildroot from 
forwarding invalid values. Just my opinion, and my experience in C 
language :-)

So maybe - if you agree that it should be checked - that should be done 
at the beginning, in root Makefile.


>  If you do a git blame, you should see that all the lines with wrong 
> indentation
> are more than 2 years old. Lately we've been paying attention to 
> consistent
> indentation, but nobody has bothered to update existing Makefiles.

OK, I had noticed the two different kinds of indentation, but didn't git 
blame to check which one was the more recent.
I'll fix it.


>  Well, you can actually put the two conditions on a single line but it 
> looks
> even worse:
> 
> ifeq ("$(origin V)"$(V), "command line"1)

In fact, I thought about it, but I didn't have the idea to exclude $(V) 
out of the "" (i.e. I thought of: ifeq ("$(origin V)$(V)", "command 
line1"). And I thought that exporting 'V=command line1' in the shell 
would "hack" the test and make it invalid. Yes, I know, I'm thinking 
about very particular use cases :-)

But I agree that - even with your method that fix this problem - it 
doesn't look very nice.


>  I don't remember saying anything about BR2_VERBOSE, and I also can't 
> find it in
> the mails I sent (but I didn't check too carefully).


It was not very clear because I didn't write any code to explain what I 
meant, but I initially proposed to check $(origin V) and $(V) in the 
root Makefile, and export BR2_VERBOSE (0 or 1). Then, in 
infrastructures, it was not necessary to check $(origin V) anymore, but 
simply check BR2_VERBOSE value.

export BR2_VERBOSE=
ifeq ("$(origin V)", "command line")
ifeq ($(V),0)
BR2_VERBOSE=0
else ifeq ($(V),1)
BR2_VERBOSE=1
endif

Then, in pkg-cmake.mk:
ifeq ($(BR2_VERBOSE),1)
CMAKE_VERBOSE = VERBOSE=1
endif


> I may have said something
> about exporting such a variable - since nobody uses it there's no point
> exporting it. Also, it doesn't match the naming convention: if it is a 
> purely
> internal (non-exported) variable, it should be just VERBOSE; if it is 
> an
> exported variable, it should be BR_VERBOSE because it is not 
> user-visible or
> Kconfig related (only user-visible or Kconfig options should have the 
> BR2_
> prefix, all others should have a BR_ prefix).

OK, so I should use BR_VERBOSE.


>  Documentation updates should probably be in a separate patch since it 
> usually
> gets some more discussion about wording etc. and that shouldn't stop 
> the
> acceptance of the code change itself.

OK. 3 patches so far :-)
Arnout Vandecappelle Sept. 7, 2015, 2:23 p.m. UTC | #5
On 07-09-15 16:08, Cédric Marie wrote:
> Le 2015-09-07 14:09, Arnout Vandecappelle a écrit :
>>  Good point, you're right. Perhaps add a comment to clarify that.
>> # Override value passed in the environment
> 
> OK. I'll add a comment.
> 
>>  Garbage in, garbage out :-)
> 
> Yes, but the error will only occur when it comes to compiling an autotools
> package. It may be disturbing to be notified so late, that the option was not
> correct. Well, in my case, it is simply ignored, so we're not notified at all...
> that's no better.
> 
> make V=0/1 is Buildroot "API", and althought it is the same as autotools "API",
> I think we should "translate" it, and prevent Buildroot from forwarding invalid
> values. Just my opinion, and my experience in C language :-)
> 
> So maybe - if you agree that it should be checked - that should be done at the
> beginning, in root Makefile.

 Sounds good to me.

[snip]
>>  I don't remember saying anything about BR2_VERBOSE, and I also can't find it in
>> the mails I sent (but I didn't check too carefully).
> 
> 
> It was not very clear because I didn't write any code to explain what I meant,
> but I initially proposed to check $(origin V) and $(V) in the root Makefile, and
> export BR2_VERBOSE (0 or 1). Then, in infrastructures, it was not necessary to
> check $(origin V) anymore, but simply check BR2_VERBOSE value.
> 
> export BR2_VERBOSE=

 Yeah, this I remember. It's the export that I have a problem with. Nothing
(currently) uses this variable so there is no need to export it. I also don't
see which scripts would ever use it, since most scripts already are verbose by
default.

> ifeq ("$(origin V)", "command line")
> ifeq ($(V),0)
> BR2_VERBOSE=0
> else ifeq ($(V),1)
> BR2_VERBOSE=1
> endif
> 
> Then, in pkg-cmake.mk:
> ifeq ($(BR2_VERBOSE),1)
> CMAKE_VERBOSE = VERBOSE=1
> endif
> 
> 
>> I may have said something
>> about exporting such a variable - since nobody uses it there's no point
>> exporting it. Also, it doesn't match the naming convention: if it is a purely
>> internal (non-exported) variable, it should be just VERBOSE; if it is an
>> exported variable, it should be BR_VERBOSE because it is not user-visible or
>> Kconfig related (only user-visible or Kconfig options should have the BR2_
>> prefix, all others should have a BR_ prefix).
> 
> OK, so I should use BR_VERBOSE.

 Well, no, because it shouldn't be exported so it's purely internal to the
makefiles so VERBOSE is enough.

 Actually, the VERBOSE already existed and is in fact used in one case:
package/qt/qt.mk


>>  Documentation updates should probably be in a separate patch since it usually
>> gets some more discussion about wording etc. and that shouldn't stop the
>> acceptance of the code change itself.
> 
> OK. 3 patches so far :-)

 Or maybe 4:

1. Remove KBUILD_VERBOSE and quiet (this one will be uncontroversial I think)
2. Define VERBOSE based on V= passed on command line
3. Use VERBOSE in autotools and cmake
4. Update documentation.


 Regards,
 Arnout
Cédric Marie Sept. 7, 2015, 2:52 p.m. UTC | #6
Le 2015-09-07 16:23, Arnout Vandecappelle a écrit :
>> export BR2_VERBOSE=
> 
>  Yeah, this I remember. It's the export that I have a problem with. 
> Nothing
> (currently) uses this variable so there is no need to export it. I also 
> don't
> see which scripts would ever use it, since most scripts already are 
> verbose by
> default.

You're right. I should study the use of export more carefully!... I 
thought exporting was necessary for the variable to be visible in 
pkg-cmake.mk and pkg-autotools.mk.
But there is no recursive make, we're in the same make process, so there 
is no need to export it.


>  Well, no, because it shouldn't be exported so it's purely internal to 
> the
> makefiles so VERBOSE is enough.

Yes, I should use VERBOSE.


>  Actually, the VERBOSE already existed and is in fact used in one case:
> package/qt/qt.mk

OK, so I'll check that the compilation of Qt is kept unchanged with my 
modification.
With my initial patch, it was broken! :(


>  Or maybe 4:
> 
> 1. Remove KBUILD_VERBOSE and quiet (this one will be uncontroversial I 
> think)
> 2. Define VERBOSE based on V= passed on command line
> 3. Use VERBOSE in autotools and cmake
> 4. Update documentation.

OK.

Regards,
diff mbox

Patch

diff --git a/Makefile b/Makefile
index 23e2ee6..4a6c9ef 100644
--- a/Makefile
+++ b/Makefile
@@ -218,23 +218,11 @@  endif
 
 # To put more focus on warnings, be less verbose as default
 # Use 'make V=1' to see the full commands
+Q = @
 ifeq ("$(origin V)", "command line")
-  KBUILD_VERBOSE = $(V)
-endif
-ifndef KBUILD_VERBOSE
-  KBUILD_VERBOSE = 0
-endif
-
-ifeq ($(KBUILD_VERBOSE),1)
-  quiet =
+ifeq ($(V),1)
   Q =
-ifndef VERBOSE
-  VERBOSE = 1
 endif
-export VERBOSE
-else
-  quiet = quiet_
-  Q = @
 endif
 
 # we want bash as shell
@@ -245,7 +233,7 @@  SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \
 # kconfig uses CONFIG_SHELL
 CONFIG_SHELL := $(SHELL)
 
-export SHELL CONFIG_SHELL quiet Q KBUILD_VERBOSE
+export SHELL CONFIG_SHELL Q
 
 ifndef HOSTAR
 HOSTAR := ar
diff --git a/package/pkg-autotools.mk b/package/pkg-autotools.mk
index 4787914..18ab1ae 100644
--- a/package/pkg-autotools.mk
+++ b/package/pkg-autotools.mk
@@ -94,6 +94,18 @@  define AUTORECONF_HOOK
 	$(Q)cd $($(PKG)_SRCDIR) && $($(PKG)_AUTORECONF_ENV) $(AUTORECONF) $($(PKG)_AUTORECONF_OPTS)
 endef
 
+# During build step:
+# 'make V=0' disables the verbose mode (if enabled by the package)
+# 'make V=1' enables the verbose mode (if not already enabled by the package)
+AUTOTOOLS_VERBOSE =
+ifeq ("$(origin V)", "command line")
+ifeq ($(V),0)
+  AUTOTOOLS_VERBOSE = V=0
+else ifeq ($(V),1)
+  AUTOTOOLS_VERBOSE = V=1
+endif
+endif
+
 ################################################################################
 # inner-autotools-package -- defines how the configuration, compilation and
 # installation of an autotools package should be done, implements a
@@ -271,11 +283,11 @@  endif
 ifndef $(2)_BUILD_CMDS
 ifeq ($(4),target)
 define $(2)_BUILD_CMDS
-	$$(TARGET_MAKE_ENV) $$($$(PKG)_MAKE_ENV) $$($$(PKG)_MAKE) $$($$(PKG)_MAKE_OPTS) -C $$($$(PKG)_SRCDIR)
+	$$(TARGET_MAKE_ENV) $$($$(PKG)_MAKE_ENV) $$($$(PKG)_MAKE) $$($$(PKG)_MAKE_OPTS) -C $$($$(PKG)_SRCDIR) $(AUTOTOOLS_VERBOSE)
 endef
 else
 define $(2)_BUILD_CMDS
-	$$(HOST_MAKE_ENV) $$($$(PKG)_MAKE_ENV) $$($$(PKG)_MAKE) $$($$(PKG)_MAKE_OPTS) -C $$($$(PKG)_SRCDIR)
+	$$(HOST_MAKE_ENV) $$($$(PKG)_MAKE_ENV) $$($$(PKG)_MAKE) $$($$(PKG)_MAKE_OPTS) -C $$($$(PKG)_SRCDIR) $(AUTOTOOLS_VERBOSE)
 endef
 endif
 endif
diff --git a/package/pkg-cmake.mk b/package/pkg-cmake.mk
index 574eccc..8e57a9c 100644
--- a/package/pkg-cmake.mk
+++ b/package/pkg-cmake.mk
@@ -35,6 +35,14 @@  ifneq ($(QUIET),)
 CMAKE_QUIET = -DCMAKE_RULE_MESSAGES=OFF -DCMAKE_INSTALL_MESSAGE=NEVER
 endif
 
+# 'make V=1' enables the verbose mode during build step
+CMAKE_VERBOSE =
+ifeq ("$(origin V)", "command line")
+ifeq ($(V),1)
+  CMAKE_VERBOSE = VERBOSE=1
+endif
+endif
+
 ################################################################################
 # inner-cmake-package -- defines how the configuration, compilation and
 # installation of a CMake package should be done, implements a few hooks to
@@ -159,11 +167,11 @@  $(2)_DEPENDENCIES += host-cmake
 ifndef $(2)_BUILD_CMDS
 ifeq ($(4),target)
 define $(2)_BUILD_CMDS
-	$$(TARGET_MAKE_ENV) $$($$(PKG)_MAKE_ENV) $$($$(PKG)_MAKE) $$($$(PKG)_MAKE_OPTS) -C $$($$(PKG)_BUILDDIR)
+	$$(TARGET_MAKE_ENV) $$($$(PKG)_MAKE_ENV) $$($$(PKG)_MAKE) $$($$(PKG)_MAKE_OPTS) -C $$($$(PKG)_BUILDDIR) $(CMAKE_VERBOSE)
 endef
 else
 define $(2)_BUILD_CMDS
-	$$(HOST_MAKE_ENV) $$($$(PKG)_MAKE_ENV) $$($$(PKG)_MAKE) $$($$(PKG)_MAKE_OPTS) -C $$($$(PKG)_BUILDDIR)
+	$$(HOST_MAKE_ENV) $$($$(PKG)_MAKE_ENV) $$($$(PKG)_MAKE) $$($$(PKG)_MAKE_OPTS) -C $$($$(PKG)_BUILDDIR) $(CMAKE_VERBOSE)
 endef
 endif
 endif