Skip to content

Commit

Permalink
Add description of macro.
Browse files Browse the repository at this point in the history
  • Loading branch information
blindij committed Oct 7, 2024
1 parent 2c451b8 commit 4f4db51
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions doc/rules.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,23 @@ more than one character long and so must be enclosed in parentheses, i.e. $(@D),
See [GNU Make Automatic variables](https://www.gnu.org/software/make/manual/html_node/Automatic-Variables.html)


## Macro
```makefile
BIN := /usr/bin
PRINTF := $(BIN)/printf
DF := $(BIN)/df
AWK :- $(BIN)/awk

define free-space
$(PRINTF) "Free disk space "
$(DF) . | $(AWK) 'NR == 2 { print $$4 }'
endef
```
With `define - endef` command we can define a multiline variable, a variable that contains a script.
In the above example we have two-line script. With `define` the variable can contain embedded newlines.
Conseqeuently, we call it a macro to disguish from a single line variable.


## Rules
The rule governing the building of the hello world program was so called _explicit_ rule. There are other
types of rules as well, and we will be going through these now:
Expand Down

0 comments on commit 4f4db51

Please sign in to comment.