已知目录中未知文件的 Makefile 依赖性(对于 DocBook)

发布于 2024-07-24 11:09:11 字数 476 浏览 5 评论 0原文

作为构建的一部分,我正在处理生成多个 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

谁人与我共长歌 2024-07-31 11:09:11

我将在这里盲目地假设 GNU Make; 如果不是,则应应用类似的技术,但语法略有改变。

如果是我,我会使用类似于上面的规则,可能使用 通配符函数

然后我将该规则放在一个单独的子 makefile 中,递归调用

也就是说,在你的主 Makefile 中,


  build:
    # do the docbook processing
    $(MAKE) -f htmlprocessmakefile

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,


  build:
    # do the docbook processing
    $(MAKE) -f htmlprocessmakefile

That Makefile will see the full list of HTML files that have been created.

洋洋洒洒 2024-07-31 11:09:11

您是否正在尝试编写类似“如果 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文