此makefile规则中的花括号有什么用? [英] What are the braces in this makefile rule for?

查看:96
本文介绍了此makefile规则中的花括号有什么用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在读取Qt创建的项目的makefile,该文件具有以下内容:

I am reading a makefile for a Qt-created project that has the following:

{backend}.cpp{release\}.obj::
    $(CXX) -c $(CXXFLAGS) $(INCPATH) -Forelease\ @<<
    $<  
<<

(以上代码将\ t用于配方,并与makefile相同)

这条规则和食谱都使我感到困惑.

Both the rule and the recipe confuse me.

我将从规则中的{backend}开始.显然,对于{release}也是一样.我假设这是对名为backend的特定子目录的引用.我想..\backend\release\bar.obj将被视为合法目标?但是 make 的哪一部分说这是合法的语法,这到底发生了什么?

I'll start with {backend} in the rule. Obviously the same confusion for {release} as well. I assume this is a reference to a particular sub-directory named backend. I guess that ..\backend\release\bar.obj would be found as a legitimate target? But what part of make says this is legitimate syntax and what exactly happens here?

FWIW:这是在一节中注释为:##### implicit rules. 版本:GNU Make 4.2.1 Built for x86_64-unknown-cygwin

FWIW: This is in a section commented as: ##### implicit rules. Version: GNU Make 4.2.1 Built for x86_64-unknown-cygwin

奖励积分:

说明食谱中@<<<<的用法...(是的,我缺乏bash shell技巧... ).这是否引用$<的第一个先决条件并以静默方式重定向它?为什么不是$$<?

Explain the use of @<< and << in the recipe... (Yes, I'm lacking in bash shell finesse...). Is this referencing the first prerequisite with $< and silently redirecting it? Why isn't it $$<?

谢谢.

推荐答案

这是NMAKE批处理模式规则

That is an NMAKE batch-mode rule

https://docs .microsoft.com/en-us/cpp/build/batch-mode-rules?view = vs-2017

等效的GNU Make规则类似于

The equivalent GNU Make rule would be something like

backend/%.obj: release/%.cpp:

顾名思义,这些规则将仅对所有有效目标调用一次配方,并期望该规则通过$<宏一次创建所有目标.

With the difference that, as the name suggests, these rules will invoke their recipes only once for all valid targets and expect the rule to create all of the targets in a single pass with the $< macro.

<<语法是NMAKE的内联文件功能

The << syntax is NMAKE's inline file feature

https ://docs.microsoft.com/zh-CN/cpp/build/inline-files-in-a-makefile?view = vs-2017

这将展开并捕获尖括号之间的所有内容,并将其保存到文件中,在这种情况下,这是一个临时文件,因为在括号后未指定文件名.然后,文件通过

This expands and captures everything between the angle brackets and saves it to a file, in this case a temporary file as no filename is specified after the brackets. The file is then passed to the compiler as a response file on the first line of the recipe through the @ option.

这篇关于此makefile规则中的花括号有什么用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆