Skip to content

Commit 808c149

Browse files
committed
Fix path substitution and iteration in makefile example
1 parent 63f3283 commit 808c149

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

README.md

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -114,24 +114,28 @@ way:
114114

115115
```makefile
116116
markdown_pages := index.md
117+
117118
posts_dir := posts
119+
output_dir := docs
118120

119121
markdown_posts := $(wildcard $(posts_dir)/*.md)
120122

121123
# Main markdown pages
122-
generated_files := $(markdown_pages:%.md=%.html)
124+
generated_files := $(foreach page,$(markdown_pages),$(patsubst %.md,$(output_dir)/%.html,$(page)))
123125
# Append posts pages
124-
generated_files += $(patsubst $(posts_dir)/%.md,%.html,$(markdown_posts))
126+
generated_files += $(foreach post,$(markdown_posts),$(patsubst $(posts_dir)/%.md,$(output_dir)/%.html,$(post)))
125127

126128
.DEFAULT: compile
127129

128-
compile: $(markdown_pages) $(markdown_posts)
129-
../ssb/ssb -p $(posts_dir) $(markdown_pages)
130+
compile: $(generated_files)
131+
132+
$(generated_files): $(markdown_pages) $(markdown_posts)
133+
ssb -p $(posts_dir) -o $(output_dir) $(markdown_pages)
130134

131135
.PHONY: clean
132136

133137
clean:
134-
rm $(generated_files)
138+
rm -f $(generated_files)
135139
```
136140

137141
## Acknowledgements

0 commit comments

Comments
 (0)