Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Semi-colon in Makefile rule definition

Tags:

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?

like image 208
Stephen Rasku Avatar asked Sep 07 '12 17:09

Stephen Rasku


People also ask

What does semicolon mean in makefile?

You can use semicolons to specify a sequence of commands to perform in a single shell invocation: test: cd /tmp ; pwd. Or, you can continue the input line onto the next line in the makefile by escaping the NEWLINE with a backslash (\).

What does command semi colon do?

Answer. The semi-colon (;) is a standard UNIX shell item used to separate commands. The overall return code will be true even if it did not succeed, that is, if there were no files to remove.

What does double-colon mean in makefile?

Double-colon rules are rules written with '::' instead of ':' after the target names. They are handled differently from ordinary rules when the same target appears in more than one rule. When a target appears in multiple rules, all the rules must be the same type: all ordinary, or all double-colon.

What are the three parts of a makefile rule?

A makefile consists of three sections: target, dependencies, and rules. The target is normally either an executable or object file name. The dependencies are source code or other things needed to make the target. The rules are the commands needed to make the target.


1 Answers

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.

like image 192
Thor Avatar answered Sep 16 '22 14:09

Thor