简体   繁体   English

GNU make忽略cmd.exe上的斜杠

[英]GNU make ignores slash on cmd.exe

I had a problem with GNU make on cmd.exe. 我在cmd.exe上使用GNU make遇到问题。 Somehow it ignores '/' output by dir and says there is no rule. 它以某种方式忽略dir “ /”输出,并说没有规则。

$(foreach f,$(OBJS),$(eval $f : | $(dir $f)))

%/:
    mkdir -p $@

So I made this dirty hack. 所以我做了这个肮脏的黑客。

$(foreach f,$(OBJS),$(eval $f : | $(dir $f)D))

%/D:
    mkdir -p $@

Any better solution? 有更好的解决方案吗? Please do not tell me to throw the broken shell away. 请不要告诉我把破碎的外壳扔掉。 I don't use the shell, but others use it. 我不使用外壳,但是其他人使用它。

As far as I know target pattern matching doesn't have anything to do with the shell make will eventually use to run recipe targets. 据我所知,目标模式匹配与shell make无关,它们最终将用于运行配方目标。 It is done entirely internally to make. 它完全在内部完成。

That said that exact makefile snippet (using OBJS := a/ao b/bo c/co ) works for me with make 3.81, 3.82, 4.0 and 4.1 on CentOS 5. (I don't have make on Windows to test with.) So maybe there is something OS-specific involved here. 那就是说,确切的makefile代码片段(使用OBJS := a/ao b/bo c/co )对我来说适用于CentOS 5上的make OBJS := a/ao b/bo c/co和4.1。(我没有Windows上的make可以测试。 )因此,这里可能涉及特定于操作系统的内容。

You could try removing the / and just using % as the target? 您可以尝试删除/并仅使用%作为目标?

That all said a better solution might be to assign the directory components to a variable and use that variable as the target. 综上所述,更好的解决方案可能是将目录组件分配给变量并将该变量用作目标。

DIRS :=
$(foreach f,$(OBJS),$(eval $f : | $(dir $f)) $(eval DIRS += $(dir $f)))

$(DIRS):
    mkdir -p $@

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM