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?
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 (\).
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.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With