为文件夹中的文件制定推理规则

发布于 2024-08-29 14:28:21 字数 776 浏览 0 评论 0原文

我使用 GNU make,我希望我的源文件和目标文件位于不同的文件夹中。

第一步,我希望源文件位于项目文件夹的根目录中,目标文件位于子文件夹中(例如 Debug/)。

推理规则是:

.ss.obj:
    echo Assembling $*.ss...
    $(ASSEMBLY) $(2210_ASSEMBLY_FLAGS) $*.ss -o Debug\$*.obj 

但在这种情况下,make 会一直重建所有文件,因为根文件夹中没有 .obj。

有没有办法在 .ss.obj 行中包含目标文件夹?

我也尝试过:

$(OBJS_WITH_PATH):$(SRC)    
    echo Assembling $<...
    $(ASSEMBLY) $(ASSEMBLY_FLAGS) $< -o $@ 

使用 $(SRC) 作为我所有源的列表,$(OBJS_WITH_PATH) 以此方式构建:

OBJS_WITH_PATH = $(patsubst %.ss,Debug\\%.obj,$(SRC))

但这会建立对所有源文件的依赖关系对象文件。

我想要的是修改我首先编写的推理规则,以获取 Debug/*.obj 文件。它现在所说的是没有规则使目标成为Debug/asdfasdf.obj

I use GNU make, I want my source files and object files to be in different folders.

As a first step, I want the source files at the root of my project folder, and the object files in a subfolder (say Debug/).

The inference rule would be:

.ss.obj:
    echo Assembling $*.ss...
    $(ASSEMBLY) $(2210_ASSEMBLY_FLAGS) $*.ss -o Debug\$*.obj 

but in that case, make rebuilds all files all the time, since there are no .obj in the root folder.

Is there a way to include a folder for the target in the line .ss.obj?

I also tried:

$(OBJS_WITH_PATH):$(SRC)    
    echo Assembling 
lt;...
    $(ASSEMBLY) $(ASSEMBLY_FLAGS) 
lt; -o $@ 

with $(SRC) as a list of all my sources, $(OBJS_WITH_PATH) built that way:

OBJS_WITH_PATH = $(patsubst %.ss,Debug\\%.obj,$(SRC))

but that builds a dependency on all source files for all object files.

What I would like is to modify the inference rule I wrote first, to take Debug/*.obj files. What it says now is no rule to make target Debug/asdfasdf.obj.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

酒解孤独 2024-09-05 14:28:21

使用模式规则:

Debug/%.obj : %.ss

Use pattern rules:

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