Update assignment section "=" (#1626)

I think these are more informative and precise examples for assignment expression.
This commit is contained in:
Mohammed Samir 2021-03-10 23:07:03 +02:00 committed by GitHub
parent 1e966a9ff1
commit 02fed04a43
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 7 deletions

View File

@ -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
```