20

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?

2
  • In this context, it is a no-op. If it was followed by something on the same line, it would not be a no-op. Commented Sep 7, 2012 at 20:18
  • It is no-op, but thing to keep in mind is that it prevent implicit rules to take place. With just : and no recipe, the implicit rule (if any exists) will be used, with :;, there is empty recipe.
    – graywolf
    Commented Dec 3, 2019 at 10:51

1 Answer 1

25

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

From chapter 5 of the manual:

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.

0

Not the answer you're looking for? Browse other questions tagged or ask your own question.