Skip to content

Commit

Permalink
updated make.md
Browse files Browse the repository at this point in the history
  • Loading branch information
halyph committed Mar 2, 2024
1 parent 6e364c2 commit 7076ccd
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions docs/wiki/howtos/make.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,3 +144,41 @@ build-service:
$^: one two
```

## Loops and Lists

List variable in Makefile can be single-line or multi-line (*can contain comments*).

```make
LIST_MULTILINE += AAA # Comment 1
LIST_MULTILINE += BBB # Comment 2
LIST_MULTILINE += CCC # Comment 3
LIST_MULTILINE += DDD # Comment 4

# single-line
LIST = Xxx Yyy Zzz

.PHONY: print-list
print-list:
@for i in $(LIST_MULTILINE); do \
echo elem: $$i; \
done
@echo '-------------'
@for i in $(LIST); do \
echo elem: $$i; \
done
```


??? note "output"

```shell
➜ make print-list
elem: AAA
elem: BBB
elem: CCC
elem: DDD
-------------
elem: Xxx
elem: Yyy
elem: Zzz
```

0 comments on commit 7076ccd

Please sign in to comment.