makefile Variables Simply-Expanded Variables

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Extensions
> Step 2: And Like the video. BONUS: You can also share it!

Example

Simply-expanded variables behave like variables from traditional programming languages. The expression on the right-hand side is evaluated, and the result is stored in the variable. If the right-hand side contains a variable reference, that variable is expanded before the assignment takes place.

x := hello
y := $(x)
# Both $(x) and $(y) will now yield "hello"
x := world
# $(x) will now yield "world", and $(y) will yield "hello"

An alternative form is to use double-colon assignment:

x ::= hello

Single- and double-colon assignment are equivalent. The POSIX make standard only mentions the ::= form, so implementations with strict standards compliance may not support the single-colon version.



Got any makefile Question?