【发布时间】:2014-03-08 18:01:16
【问题描述】:
更新:GNU Make 3.81、Ubuntu 12.04
我有一组 Markdown 文件,我想编译成(比如说)html 文件,所以这是我的规则:
%.html: %.md
pandoc $< -o $@
所以make foo.html 会将foo.md 转换为foo.html。
但是,源 Markdown 文件名中有空格,我无法控制这些,即我无法更改设置以删除空格。
这意味着如果我make foo\ bar.html,我会得到
make: *** No rule to make target `foo bar.html'. Stop.
如何编写一个通用规则%.html: %.md,其中必备文件名有空格?
我可以通过以下方式绕过它:
foo\ bar.html: foo\ bar.md
pandoc $< -o $@
但是当我宁愿使用% 构造时,我必须为我拥有的每个此类源文件手动写出此规则。我唯一的希望是做某种$(foreach f,$(get list of *.md files),$(eval $(call function_to_generate_rule)))吗?
【问题讨论】:
-
Make 确实不能很好地处理目标名称中的空格。我怀疑你找到的任何解决方案都是丑陋的组合。
-
在尝试重现您的问题时,输入
%.html: %.mdmarkdown $< > $@,我无法收到关于找不到目标的make错误。你用的是哪个版本的make? -
您知道
make要正确进行推理,源文件foo bar.md必须存在或者是make知道如何构建的东西,对吧? -
@binki:当然,
foo bar.md确实存在。 GNU 制作 3.81。我可以重现这个。 -
好的,我在 Windows 上的 GNU make 3.81 上看到了这个问题,但在 GNU 上的 GNU make 3.82 上没有看到这个问题。