在不使用CMake时执行make make命令

时间:2012-06-12 20:52:16

标签: makefile

我看到这是与

相同的问题

Making cmake print commands before executing

但这个答案对我不起作用。我猜这个答案只适用于cmake。没有cmake的选项有哪些?

注意尝试了这些

make VERBOSE=1 target
make target VERBOSE=1
VERBOSE=1 make target
make V=1 target
make target V=1
V=1 make target
make -V target
make -v target

他们都没有工作。

make -v return

GNU Make 3.81
Copyright (C) 2006  Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.

This program built for x86_64-pc-linux-gnu

3 个答案:

答案 0 :(得分:91)

默认情况下,make会在执行前打印每个命令。可以通过以下机制之一来抑制此打印:

  • 根据具体情况,在命令开头添加@
  • 全局,通过添加.SILENT内置目标。
  • 在make过程的某个地方,通过调用其中一个标记-s--silent--quiet的子标记,例如在$(MAKE) --silent -C someDir中,例如。从那一刻开始,命令回显在sub-make中被抑制。

如果你的makefile没有打印命令,那么它可能正在使用这三种机制中的一种,你必须实际检查makefile以找出哪些。

作为避免这些回声抑制机制的解决方法,您可以重新定义用于使用调试模式的shell,例如make SHELL="/bin/bash -x" target。其他炮弹有类似的选择。使用这种方法,它不是make打印命令,而是shell本身。

如果使用标志-n--just-print,将忽略回声抑制机制,您将始终看到make认为应该执行的所有命令 - 但它们是没有实际执行,只是印刷。这可能是一个很好的方法来弄清楚你真正期望看到的东西。

VERBOSE变量对make没有标准含义,但前提是你的makefile解释它。

答案 1 :(得分:2)

对于我的 make 版本,我发现两个参数 -n-d 都有帮助。

<块引用>

GNU Make 3.80 版权所有 (C) 2002 自由软件基金会

  -d                          Print lots of debugging information.
  -n, --just-print, --dry-run, --recon
                              Don't actually run any commands; just print them.

当包含一堆 makefile 片段时,如果没有这个关键的调试标志,行号就没有意义。

CreateProcess(....exe,...)
Reading makefile `../../../../build/Makefile.options' (search path) (don't care) (no ~ expansion)...
Makefile:361: Extraneous text after `else' directive
Makefile:368: Extraneous text after `else' directive
Makefile:368: *** only one `else' per conditional.  Stop.

答案 2 :(得分:1)

我认为这就是你想要的: make MAKE_VERBOSE = 1 target

相关问题