Makefile规则定义中的分号 [英] Semi-colon in Makefile rule definition

查看:795
本文介绍了Makefile规则定义中的分号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Makefile中看到许多规则,如下所示:

I am seeing a number of rules in a Makefile that look like this:

$(PATH)/foo.inc:;
include $(PATH)/foo.inc

$(PATH)/bar.inc:;
include $(PATH)/bar.inc

规则定义末尾的分号是无操作符还是有特殊含义?

Is the semi-colon at the end of the rule definition a no-op or does it have a particular meaning?

推荐答案

至少在GNU make中,具有目标先决条件的行上的分号是为此规则执行的第一个命令行.

A semicolon on the line with the target-prerequisite is the first command line to execute for this rule, at least in GNU make.

从手册第5章开始:

规则命令由要执行的Shell命令行组成 逐个.每个命令行都必须以制表符开头,除了 第一个命令行可能会附加到目标和先决条件上 中间有分号.

The commands of a rule consist of shell command lines to be executed one by one. Each command line must start with a tab, except that the first command line may be attached to the target-and-prerequisites line with a semicolon in between.

在您的情况下,由于分号后没有任何命令,所以它最终变成了空操作.

In your case since there is no command after the semi-colon then it ends up being a no-op.

这篇关于Makefile规则定义中的分号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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