2015-03-03 51 views
1

我有一个奇怪的行为,我的make命令。为什么“make”不回应任何内容?

它在执行前不打印命令行。 我知道在命令行之前存在-s--silent--quiet选项或使用@。我没有使用它们中的任何一个。

例如,一个非常基本的Makefile:

[email protected]:~$ make 
[email protected]:~$ 

另一台计算机上执行:我的电脑上

all: 
     touch toto.txt 
     rm toto.txt 

执行

[email protected]:~$ make 
touch toto.txt 
rm toto.txt 
[email protected]:~$ 

化妆的版本是一样的在这两台电脑上:

[email protected]:~$ make -version 
GNU Make 3.81 
... 

打印命令行是默认行为(https://www.gnu.org/software/make/manual/html_node/Echoing.html),我没有使用任何特殊配置。

有人知道为什么我的make执行但不回显命令行?

PS:

  • 我没有文件或目录名为“所有”
  • 如果我删除rm toto.txt是没有任何化妆的呼应创建的文件。

PPS:

  • 这些输出的最后几行,当我发出make -d

    Considering target file `all'. 
        File `all' does not exist. 
        Finished prerequisites of target file `all'. 
    Must remake target `all'. 
    Need a job token; we don't have children 
    Putting child 0x01144970 (all) PID 7478 on the chain. 
    Commands of `all' are being run. 
    Live child 0x01144970 (all) PID 7478 
    Reaping winning child 0x01144970 PID 7478 
    Removing child 0x01144970 PID 7478 from chain. 
    Considering target file `all'. 
    File `all' was considered already. 
    
+0

试试'make -d' ... – reinierpost 2015-03-03 16:00:45

+0

这里是'make -d'输出:http://pastebin.com/kwt41E15。对我来说没有任何问题。 – Oneil67 2015-03-04 09:25:54

+0

我已将最后一行复制到您的答案中。它表示它调用命令来创建'all'目标,但不显示它们;我认为它应该。如果你想在这里帮助一些读者,用'env LANG = en_US make -d'重试。 – reinierpost 2015-03-04 09:35:33

回答

2

你在你的调试输出有这样的字符串:

需要一份工作令牌;我们没有孩子

除非我使用-j选项,否则我无法在调试输出中获取此字符串。但是,您声明您在命令行中使用了make -d。这也是你的糊状物显示的。

这表明你没有运行股票(即未经修改的)GNU make。可能性:

  • 您实际上运行环绕真正的品牌和传递-j-s使除了你给的参数的脚本。上面的行解释了-j的添加。 -s的解释说明了为什么你不能得到回声。

  • 您有一个shell别名或一个shell函数,它与上面的推定脚本具有相同的功能。

  • 您正在使用MAKEFLAGS环境变量设置-j-s(在bash你可以使用type -a make检查什么make是,由于MadScientist约type -a提醒。)。 (在bash中,您可以使用printenv MAKEFLAGS来检查它。)

  • 您正在运行自定义二进制文件。

+1

请运行'type -a make'命令来查看您的环境是否有任何使用额外标志调用make的特殊别名或shell函数。 – MadScientist 2015-03-04 13:04:32

+0

@MadScientist忘记了这种方法。 – Louis 2015-03-04 13:05:35

+0

当我在我的bash中做别名时没有使用'make'。 当我直接运行'/ usr/bin/make'时同样的行为。 另外,我尝试了一个'apt-get purge make'和一个'apt-get install make'仍然一样的行为。 – Oneil67 2015-03-04 13:15:41

1

你可能有一个名为all文件或目录的工作目录在您的计算机上。 Make看到并看到规则在您的makefile中创建all,并决定它是最新的(因为它存在并且没有先决条件),所以什么也不做。

将一个.PHONY: all添加到您的生成文件将解决此问题。你也可以运行make -d,看看它在运行你的makefile时正在想什么(非常详细)。

+0

@ Oneil67增加上面的答案,你可以删除'rm toto.txt'规则,并检查运行'make'后是否创建了toto.txt确认规则是不是正在执行或者是没有回应 – 2015-03-03 14:12:32

+0

使用make 3.81和4.0,用OP显示的Makefile运行'make',当当前目录中已经存在'all'文件时将输出'make:'全部'是最新的'。 – Louis 2015-03-03 17:08:34

+0

是的。我认为如果你运行'make all',可能只会这样做,但不是这样。在这种情况下,我想不出任何方式会使打印没有输出。他必须进行调查:按照我的建议运行'make -d'。 – MadScientist 2015-03-03 17:30:45

相关问题