From 0f5f0d65a05ff8f878122f3a360ce814b2499b8d Mon Sep 17 00:00:00 2001 From: Johannes Stoelp Date: Sun, 2 Jul 2023 21:25:19 +0200 Subject: make: add patsubst example --- src/development/make.md | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/development/make.md') diff --git a/src/development/make.md b/src/development/make.md index 1ebe98e..254a7d7 100644 --- a/src/development/make.md +++ b/src/development/make.md @@ -101,6 +101,15 @@ out := $(in:.o=.c) # => out = a.c l.a c.c ``` +### `patsubst` ([ref][make-patsubst]) +```make +in := a.c b.c +out := $(patsubst %.c, build/%.o, $(in)) +# => out = build/a.o build/b.o + +# This is actually equivalent to $(in:%.c=build/%.o) +``` + ### `filter` Keep strings matching a pattern in a list. ```make @@ -129,3 +138,4 @@ $(realpath fname1 fname2 ..) ``` [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 -- cgit v1.2.3