Update assignment section "=" (#1626)
I think these are more informative and precise examples for assignment expression.
This commit is contained in:
parent
1e966a9ff1
commit
02fed04a43
16
makefile.md
16
makefile.md
|
@ -8,10 +8,13 @@ category: CLI
|
|||
## Var assignment
|
||||
|
||||
```makefile
|
||||
uglify = $(uglify) # lazy assignment
|
||||
compressor := $(uglify) # immediate assignment
|
||||
prefix ?= /usr/local # safe assignment
|
||||
hello += world # append
|
||||
foo = "bar"
|
||||
bar = $(foo) foo # dynamic (renewing) assignment
|
||||
foo := "boo" # one time assignment, $(bar) now is "boo foo"
|
||||
foo ?= /usr/local # safe assignment, $(foo) and $(bar) still the same
|
||||
bar += world # append, "boo foo world"
|
||||
foo != echo fooo # exec shell command and assign to foo
|
||||
# $(bar) now is "fooo foo world"
|
||||
```
|
||||
|
||||
`=` expressions are only evaluated when they're being used.
|
||||
|
@ -98,7 +101,6 @@ make
|
|||
-e, --environment-overrides
|
||||
-B, --always-make
|
||||
-s, --silent
|
||||
|
||||
-j, --jobs=N # parallel processing
|
||||
```
|
||||
|
||||
|
@ -107,9 +109,9 @@ make
|
|||
```makefile
|
||||
foo: $(objects)
|
||||
ifeq ($(CC),gcc)
|
||||
$(CC) -o foo $(objects) $(libs_for_gcc)
|
||||
$(CC) -o foo $(objects) $(libs_for_gcc)
|
||||
else
|
||||
$(CC) -o foo $(objects) $(normal_libs)
|
||||
$(CC) -o foo $(objects) $(normal_libs)
|
||||
endif
|
||||
```
|
||||
|
||||
|
|
Loading…
Reference in New Issue