已知目录中未知文件的 Makefile 依赖性(对于 DocBook)
作为构建的一部分,我正在处理生成多个 HTML 文件(每章一个文件)的 DocBook 文件。
我想对这些 HTML 文件进行后处理并将它们复制到其他地方。 这些文件取决于 DocBook 源,但我无法提前知道文件名(文件名也取决于 DocBook 源)。
我有一个规则,如果文件已经生成,那么某种程度的工作:
www/manual/%.html: build/manual/%.html
postprocess "$<" "$@"
但我不知道如何告诉 make
生成它们(如果它们还没有)。 如果我只是为 www/manual/index.html
添加规则,则只有该文件会被后处理,而不是所有文件。
我想我需要 DocBook 的 makedepend
或者一些漂亮的通配符技巧。 对此有什么解决办法呢?
As part of the build I'm processing DocBook file that produces multiple HTML files (one file per chapter).
I want to postprocess those HTML files and copy them elsewhere. Those files depend on DocBook source, but I cannot know filenames in advance (filenames depend on DocBook source too).
I've got rule that sort-of works if the files are generated already:
www/manual/%.html: build/manual/%.html
postprocess "lt;" "$@"
but I don't know how to tell make
to generate them, if they aren't there yet. If I just add rule for www/manual/index.html
, only that file gets postprocessed, not all of them.
I suppose I need makedepend
for DocBook or perhaps some nifty wildcard trick. What's the solution for this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我将在这里盲目地假设 GNU Make; 如果不是,则应应用类似的技术,但语法略有改变。
如果是我,我会使用类似于上面的规则,可能使用 通配符函数
然后我将该规则放在一个单独的子 makefile 中,递归调用
也就是说,在你的主 Makefile 中,
Makefile 将看到已创建的 HTML 文件的完整列表。
I'm going to blindly assume GNU Make here; if not, similar techniques should apply with slightly altered syntax.
If it were me, I'd use a rule akin to yours above, possibly with a file list generated by the wildcard function
And then I'd put that rule in a separate sub-makefile, called recursively
That is, in your main Makefile,
That Makefile will see the full list of HTML files that have been created.
您是否正在尝试编写类似“如果
manual
目录中根本没有文件,则运行 foo 命令来生成它们”的规则?一种简单的可能性(一种破解,因为我不知道高级 makefile 用法,也不建议花时间学习它)是指定的 foo 命令不仅创建您事先不知道的文件名,还可以创建一个您事先知道其文件名的文件(可能是空的),然后您可以将其用作规则是否已运行的标记。
Are you trying to write a rule like "If there are no files at all in the
manual
directory then run the foo command to generate them"?One easy possibility (a hack, given that I don't know advanced makefile usage and don't propose to invest time learning it unecessarily) would be for that specified foo command to not only create filenames that you don't know in advance, but also to create one (perhaps empty) file whose filename you do know in advance, and which you can then use as your marker for whether or not the rule has been run.