aboutsummaryrefslogtreecommitdiff
path: root/book/makefile
diff options
context:
space:
mode:
authormetamuffin <metamuffin@disroot.org>2024-10-13 20:18:07 +0200
committermetamuffin <metamuffin@disroot.org>2024-10-13 20:18:07 +0200
commite8b482d8e787d919af59fc5d18db137aa127b51b (patch)
tree3f46952b96f0da1f8167987b6294614cccb38b17 /book/makefile
parent7b32caf001e8abdfddbaff56851a8951489b69ab (diff)
downloadhurrycurry-e8b482d8e787d919af59fc5d18db137aa127b51b.tar
hurrycurry-e8b482d8e787d919af59fc5d18db137aa127b51b.tar.bz2
hurrycurry-e8b482d8e787d919af59fc5d18db137aa127b51b.tar.zst
add book back to main repo
Diffstat (limited to 'book/makefile')
-rw-r--r--book/makefile49
1 files changed, 49 insertions, 0 deletions
diff --git a/book/makefile b/book/makefile
new file mode 100644
index 00000000..4bdab4dc
--- /dev/null
+++ b/book/makefile
@@ -0,0 +1,49 @@
+
+noop =
+space = $(noop) $(noop)
+comma = ,
+langs = $(patsubst locale/%.ini,%,$(wildcard locale/*.ini))
+
+s_pages = 01,02,03,04,05,06,07,08,09,10,11
+s_langs = $(subst $(space),$(comma),$(langs))
+png_pages = $(shell echo out/book_{$(s_pages)}.{$(s_langs)}.png)
+webp_pages = $(shell echo out/book_{$(s_pages)}.{$(s_langs)}.webp)
+svg_pages = $(shell echo out/book_{$(s_pages)}.{$(s_langs)}.svg)
+pdfs = $(shell echo out/book.{$(s_langs)}.pdf)
+
+ALL = out/book.webp.tar.zst out/book.svg.tar.zst \
+ $(pdfs) $(png_pages) $(webp_pages) $(svg_pages)
+
+JSR = deno run
+
+
+
+.PHONY: all
+all: $(ALL)
+
+out:
+ @mkdir -p out
+
+book.json: book.js
+ DENO_NO_UPDATE_CHECK=1 $(JSR) $< > $@
+
+out/book_01.%.png: book.typ book.json locale/%.ini out
+ typst compile --input lang=$(subst out/,,$(*)) $< out/book_\{n\}.$(subst out/,,$(*)).png
+out/book_01.%.svg: book.typ book.json locale/%.ini out
+ typst compile --input lang=$(subst out/,,$(*)) $< out/book_\{n\}.$(subst out/,,$(*)).svg
+out/book.%.pdf: book.typ book.json locale/%.ini out
+ typst compile --input lang=$(subst out/,,$(*)) $< $@
+
+out/%.webp: out/%.png
+ ffmpeg -i $< -y $@
+
+out/book.svg.tar.zst: $(svg_pages)
+ tar -cf $@ $^
+out/book.webp.tar.zst: $(webp_pages)
+ tar -cf $@ $^
+
+.PHONY: clean
+clean:
+ rm -rf out
+ rm -f book.json
+