Occasionally, there is a need for adding multiple continuous lines for one target in a Makefile.
Writing multiple lines for a target
Executing multiple commands in a target is trivial:
|
|
Output:
|
|
However, each line is executed in its own shell. If a continuous line is needed, the following rules must be applied:
- Use
$$
instead of$
- Terminate each line using a semicolon
;
- Add a trailing backslash at the ending of the line
\
|
|
Output:
|
|
A real use case using multi-line targets
For how.wtf
, the CI/CD process invalidates a CloudFront distribution via id.
For context, the aws
dependency verifies that aws
is executable prior to the command execution. More information on that here.
|
|
|
|
Writing multiple lines using ONESHELL
The ONESHELL
directive allows multiple lines to executed in the same shell; however, special characters like @
, -
, and +
are interpreted differently.
|
|
Output:
|
|