不使用CMake时在执行之前制作make打印命令 [英] Making make print commands before executing when NOT using CMake

查看:184
本文介绍了不使用CMake时在执行之前制作make打印命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我看到这是和

在执行之前制作cmake打印命令

但是这个答案对我不起作用.我猜答案只能与cmake一起使用.不用cmake可以使用哪些选项?

But that answer doesn't work for me. I'm guessing that answer only works with cmake. What options work without 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返回

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

推荐答案

默认情况下,make会在执行命令之前先打印所有命令.可以通过以下一种机制来抑制这种打印:

By default, make does print every command before executing it. This printing can be suppressed by one of the following mechanisms:

  • 根据具体情况,在命令开头添加@
  • 在全球范围内,通过添加.SILENT内置目标.
  • 在制造过程中的某个地方,例如,通过使用标志-s--silent--quiet之一调用子制造,例如在$(MAKE) --silent -C someDir中.从那一刻起,子回声中的命令回显就被抑制了.
  • on a case-by-case basis, by adding @ at the beginning of the command
  • globally, by adding the .SILENT built-in target.
  • somewhere along the make process, by invoking sub-make(s) with one of the flags -s, --silent or --quiet, as in $(MAKE) --silent -C someDir, for example. From that moment on, command echoing is suppressed in the sub-make.

如果您的makefile文件不显示命令,则可能是这三种机制之一,因此您必须实际检查makefile文件以找出哪种.

If your makefile does not print the commands, then it is probably using one of these three mechanisms, and you have to actually inspect the makefile(s) to figure out which.

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

As a workaround to avoid these echo-suppressing mechanisms, you could re-define the shell to be used to use a debug mode, for example like make SHELL="/bin/bash -x" target. Other shells have similar options. With that approach, it is not make printing the commands, but the shell itself.

如果使用标志-n--just-print,则回声抑制机制将被忽略,并且您将始终看到make认为应执行的所有命令-但实际上并没有执行,只是打印.这可能是弄清楚您实际期望看到的东西的好方法.

If you use the flag -n or --just-print, the echo-suppressing mechanisms will be ignored and you will always see all commands that make thinks should be executed -- but they are not actually executed, just printed. That might be a good way to figure out what you can actually expect to see.

VERBOSE变量对make没有标准含义,但仅当您的makefile解释了该变量时.

The VERBOSE variable has no standard meaning for make, but only if your makefile interprets it.

这篇关于不使用CMake时在执行之前制作make打印命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆