Skip to content

Commit

Permalink
README: added addsuffix function.
Browse files Browse the repository at this point in the history
  • Loading branch information
Nuno-Jesus committed Jul 31, 2023
1 parent 0d25fb8 commit 4ea900e
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
31 changes: 30 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1289,7 +1289,7 @@ These are the directories: foo.c bar.c baz.c
$(addprefix prefix,names…)
```

For each reference in `names`, appends a prefix to it. The final result is the prefix concatenated with each reference, separated by a space between each final reference.
For each reference in `names`, it appends `prefix` to it. The final result is the prefix concatenated with each reference, separated by a space between each final reference.

Here's an example ([code/22-addprefix-example](code/22-addprefix-example)):

Expand All @@ -1310,6 +1310,35 @@ Final paths: sources/foo.c sources/bar.c sources/baz.c
</details>
<details>
<summary><h4>addsuffix</h4> - appends a suffix to strings</summary>
```
$(addsuffix suffix,names…)
```
For each reference in `names`, it appends `suffix` to it. The final result is the suffix concatenated with each reference, separated by a space between each final reference.
Here's an example ([code/23-addsuffix-example](code/23-addsuffix-example)):
```Makefile
FILES = foo bar baz
all:
echo Final object files: $(addsuffix .o, $(FILES))
.SILENT:
```

Output:

```
Final object files: foo.o bar.o baz.o
```

</details>


<!--
Functions for file names
$(addsuffix suffix,names…)
Expand Down
5 changes: 5 additions & 0 deletions code/23-addsuffix-example/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FILES = foo bar baz

all:
echo Final object files: $(addsuffix .o, $(FILES))
.SILENT:

0 comments on commit 4ea900e

Please sign in to comment.