Last active
July 31, 2019 11:49
-
-
Save estysdesu/d1a4fe106f3e6557e9c7dd600472de65 to your computer and use it in GitHub Desktop.
[Make: variables and assignment] #gnu #make #makefile
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
##### make/shell VARIABLES ##### | |
# $(<var>): reference make variable | |
# ${<var>}: reference environment variable | |
x = `pwd`; echo $(x) | |
y = ${PATH} | |
##### `=`/`:=`/`?=`/`+=` (VARIABLE ASSIGNMENT) ##### | |
# https://stackoverflow.com/questions/448910/what-is-the-difference-between-the-gnu-makefile-variable-assignments-a | |
# `=`: evaluated when used, not declared (lazy set); setting of a variable where values within it are recursively expanded when the variable is used | |
# `:=`: evaluated immediately (immediate set); setting of a variable with simple expansion of the values inside | |
# `?=`: setting of a variable only if it doesn't have a value (set if absent) | |
# `+=`: appending the supplied value to the existing variable value or setting to that value if the variable didn't exist (append or set) | |
x = `pwd`; cd ..; echo $(x) # --> x is one level up the tree | |
y := data.csv password.txt report.pdf | |
y += dog.png # --> y == data.csv password.txt report.pdf dog.png (with space) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment