In one of the early sections of the GNU make manual, Section 3.7, there is an outline of a makefile recipe
immediate : immediate ; deferred
deferred
involving a semicolon in the prerequisites list. So a valid recipe could be
output.o : output.c header1.h header2.h; header3.h
gcc output.c -o output.o
What is the point of the semicolon? Since the aforementioned section talks about immediate and deferred variable expansion, I am guessing that the part up to the semicolon is expanded immediately and the part of the semicolon is expanded only once the target is executed. Can anybody confirm?
I have found similar questions on SO but those present special cases and none of the their accepted answers seem to get the point.
As explained in 4.2 Rule Syntax:
In general, a rule looks like this:
targets : prerequisites recipe …
or like this:
targets : prerequisites ; recipe recipe …
[...]
The recipe lines start with a tab character (or the first character in the value of the
.RECIPEPREFIX
variable; see Special Variables). The first recipe line may appear on the line after the prerequisites, with a tab character, or may appear on the same line, with a semicolon. Either way, the effect is the same.
(Emphasis mine.)
Your example is equivalent to
output.o : output.c header1.h header2.h
header3.h
gcc output.c -o output.o
Semicolon simply allows to write the first line of the recipe on the same line as the prerequisites list.
This way (given that your recipes fit a single line) you can write a Makefile w/o any evil tabs. There's no much use in it otherwise.
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