From 02fed04a4364ed079ce0a51069c7063ad83f1260 Mon Sep 17 00:00:00 2001 From: Mohammed Samir Date: Wed, 10 Mar 2021 23:07:03 +0200 Subject: [PATCH] Update assignment section "=" (#1626) I think these are more informative and precise examples for assignment expression. --- makefile.md | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/makefile.md b/makefile.md index 844f87b5d..cb5d8bce7 100644 --- a/makefile.md +++ b/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 ```