GNU 制作一种双冒号

发布于 2024-12-26 11:12:58 字数 344 浏览 3 评论 0原文

我在理解 gmake 语法时遇到了一些问题:

OBJ = foo.o bar.o

$(OBJ): %.o: %.cpp
    $(CC) -c -MMD -MP $(INCLUDES) $(CFLAGS) $< -o $@
    @sed (...create empty targets in file...)

我不确定 $(...): %.o: %.cpp 的作用是什么!?

我认为它可能会将“%.o: %.cpp”翻译为正确的 %.cpp 依赖项 - 是吗?谷歌在这里并没有多大帮助——它只找到了通常的双冒号(目标::),这是不同的!

有什么建议吗?谢谢!

I've got a little problem understanding following gmake syntax:

OBJ = foo.o bar.o

$(OBJ): %.o: %.cpp
    $(CC) -c -MMD -MP $(INCLUDES) $(CFLAGS) 
lt; -o $@
    @sed (...create empty targets in file...)

I'm not sure what $(...): %.o: %.cpp does!?

I think it might translate the "%.o: %.cpp" in correct %.cpp dependencies - does it? Google is not much of a help here - it finds just the usual double colon (target::) which is something different!

Any advice? Thanks!

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

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

发布评论

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

评论(1

话少心凉 2025-01-02 11:12:58

这是一个静态模式规则

$(OBJ) 是目标列表。 %.o : %.cpp 表示“对于列表中与 %.o 匹配的每个目标,它依赖于 %.cpp " (其中 % 被相应替换)。

This is a static pattern rule.

$(OBJ) is a list of targets. The %.o : %.cpp means "for each target in the list that matches %.o, it is dependent on %.cpp" (where the % is substituted accordingly).

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