aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJohannes Stoelp <johannes.stoelp@gmail.com>2024-03-23 02:35:32 +0100
committerJohannes Stoelp <johannes.stoelp@gmail.com>2024-03-23 02:35:32 +0100
commit1ea7da67c3186119551ff88c5c6b05de05393ce0 (patch)
tree4bf5d26a47b565d09ac471e496005e34955b62b8
parentfe0a37a39f133d60e47cb041973136e5d6154657 (diff)
downloadnotes-1ea7da67c3186119551ff88c5c6b05de05393ce0.tar.gz
notes-1ea7da67c3186119551ff88c5c6b05de05393ce0.zip
make: config based example
-rw-r--r--src/development/make.md35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/development/make.md b/src/development/make.md
index 254a7d7..fdef47e 100644
--- a/src/development/make.md
+++ b/src/development/make.md
@@ -137,5 +137,40 @@ Resolve each file name as canonical path.
$(realpath fname1 fname2 ..)
```
+## Examples
+
+### Config based settings
+```make
+conf-y := default
+conf-$(FOO) := $(conf-y) foo
+conf-$(BAR) := $(conf-y) bar
+
+libs-y := libdef
+libs-$(FOO) += libfoo
+libs-$(BAR) += libbar
+
+all:
+ @echo "conf-y: $(conf-y)"
+ @echo "libs-y: $(libs-y)"
+```
+Yields the following results.
+```sh
+$ make
+conf-y: default
+libs-y: libdef
+
+$ make FOO=y
+conf-y: default foo
+libs-y: libdef libfoo
+
+$ make BAR=y
+conf-y: default bar
+libs-y: libdef libbar
+
+$ make FOO=y BAR=y
+conf-y: default foo bar
+libs-y: libdef libfoo libbar
+```
+
[make-var-override]: https://www.gnu.org/software/make/manual/html_node/Overriding.html
[make-patsubst]: https://www.gnu.org/software/make/manual/html_node/Text-Functions.html#index-patsubst-1