gpt4 book ai didi

具有多个依赖项的 Makefile 目标

转载 作者:行者123 更新时间:2023-12-01 05:35:53 32 4
gpt4 key购买 nike

我有一个小脚本,可将 Markdown 文件编译为 html,并将其与一些样式表和 javascript 一起插入到模板的主体中。我有一个 GNU makefile 来完成这个:

output.html: content.md compile.py style.css script.js
python compile.py < $< > $@

当我运行它时,我收到错误:

make: * No rule to make target style.css', needed byoutput.html'. Stop.



如果我删除 compile.py , style.css , 和 script.js ,目标运行,但它不再依赖于文件,所以我可以在 style.css 中进行更改,它不会重新运行目标。

所有这些文件都在同一目录中:
my_project_directory/
content.md
compile.py
style.css
script.js

如何在不导致错误的情况下将所有这些文件声明为依赖项?

最佳答案

你已经说过了 output.html需求style.css ,但 style.css文件在当前目录中不存在,并且您还没有告诉 make 如何创建它。指定style.css的真实位置(和其他文件)并且依赖项将起作用。

关于具有多个依赖项的 Makefile 目标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8836496/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com