Makefile 之 $(Q)

 1 # To put more focus on warnings, be less verbose as default
 2 # Use 'make V=1' to see the full commands
 3 ifeq ("$(origin V)", "command line")
 4   KBUILD_VERBOSE = $(V)
 5 endif
 6 ifndef KBUILD_VERBOSE
 7   KBUILD_VERBOSE = 0
 8 endif
 9 
10 ifeq ($(KBUILD_VERBOSE),1)
11   Q =
12 ifndef VERBOSE
13   VERBOSE = 1
14 endif
15 export VERBOSE
16 else
17   Q = @
18 endif

$(Q) 变量的本质就是 Makefile中的命令显示与否,命令前有@字符,则不显示命令本身而只显示命令的执行结果。

而 Q = @与否,是通过KBUILD_VERBOSE变量控制。

如果执行make menuconfig V=1,那么Q等于空,即显示命令本身且显示命令的执行结果;

如果执行make menuconfig,那么Q=@,即只显示命令的执行结果

Q变量可以协助调试分析问题。

posted @ 2018-04-20 10:14  suonikeyinsu  Views(2657)  Comments(0Edit  收藏  举报