10
2
Fork 0
has-writeup/Makefile

81 lines
3.0 KiB
Makefile
Raw Normal View History

2020-06-04 00:53:43 +00:00
.PHONY: all clean
# i know this makefile is mega cursed i'm sorry :<
# ~ 🦈
2020-05-26 07:35:57 +00:00
2020-06-04 00:31:32 +00:00
CATS=aaaa comms ground-segment payload satellite-bus space
DOCS_ALL=$(wildcard $(addsuffix /**/README.md,$(CATS)))
2020-05-26 09:55:24 +00:00
WRITEUP_PDF=writeup.pdf
2020-06-04 00:31:32 +00:00
PDF_DIR=build
HTML_DIR=html
2020-06-04 00:53:43 +00:00
HTML_CONTENT_ALL=$(addprefix $(HTML_DIR)/,jork.png blahaj.css $(wildcard $(addsuffix /**/*,$(CATS))))
2020-06-04 00:31:32 +00:00
HTML_DOCS=$(addprefix $(HTML_DIR)/,$(DOCS_ALL:README.md=index.html))
HTML_INDEX=$(HTML_DIR)/index.html
HTML_TEMPLATE=$(abspath default.html5)
2020-05-26 07:35:57 +00:00
2020-06-04 00:31:32 +00:00
all: README.md $(WRITEUP_PDF) $(HTML_INDEX)
2020-05-26 07:35:57 +00:00
clean:
2020-06-04 00:31:32 +00:00
$(RM) -r $(WRITEUP_PDF) $(PDF_DIR) $(HTML_DIR)
2020-05-26 07:35:57 +00:00
README.md: $(DOCS_ALL)
2020-06-04 00:31:32 +00:00
@echo "GEN $@"
2020-05-26 07:36:40 +00:00
@(printf "# BLAHAJ Hack-a-Sat 2020 Writeups\n\n"; for file in $(DOCS_ALL); do \
2020-05-26 07:35:57 +00:00
printf -- "- [%s](%s)\n" "$$(dirname $$file)" "$$(dirname $$file)"; done) > README.md
2020-05-26 09:55:24 +00:00
2020-05-28 02:22:09 +00:00
$(WRITEUP_PDF): $(DOCS_ALL) fonts.tex misc.tex top.md
2020-05-26 09:55:24 +00:00
@echo "GEN writeup.md"
2020-06-04 00:31:32 +00:00
@mkdir $(PDF_DIR) 2>/dev/null || true
@find . -mindepth 3 -iname '*.png' -exec cp {} $(PDF_DIR) \;
@find . -mindepth 3 -iname '*.py' -exec cp {} $(PDF_DIR) \;
@cp fonts.tex misc.tex jork.png $(PDF_DIR)
@for md in top.md $(DOCS_ALL); do cat $$md; printf "\n\n\\\\newpage\n\n"; done > $(PDF_DIR)/writeup.md
@echo "PDF $@"
@cd $(PDF_DIR) && \
2020-05-26 10:39:51 +00:00
pandoc --filter pandoc-include-code --toc --toc-depth 1 -f markdown-implicit_figures \
-i writeup.md --pdf-engine=lualatex -o writeup.pdf
2020-06-04 00:31:32 +00:00
@cp $(PDF_DIR)/writeup.pdf $@
2020-06-15 06:26:42 +00:00
$(HTML_INDEX): $(HTML_DIR)/index.md $(HTML_DIR)/jork.png $(HTML_DIR)/blahaj.css \
$(HTML_DIR)/favicon.ico $(HTML_DIR)/writeup.pdf
2020-06-04 00:53:43 +00:00
@echo "HTML $@"
2020-06-04 00:31:32 +00:00
@cp -r mathjax/ $(HTML_DIR)/mathjax/
2020-06-04 00:53:43 +00:00
@pandoc -i $< -o $@ -t html5 -s --template $(HTML_TEMPLATE) --metadata lang=en \
--metadata title="BLAHAJ Hack-a-Sat 2020 Writeups" \
--metadata css="blahaj.css"
2020-06-15 06:26:42 +00:00
$(HTML_DIR)/favicon.ico: jork.png
@echo "ICO $@"
@convert $< -resize 128x128 $@
$(HTML_DIR)/writeup.pdf: $(WRITEUP_PDF)
@cp $< $@
2020-06-04 00:53:43 +00:00
$(HTML_DIR)/index.md: $(HTML_CONTENT_ALL) $(HTML_DOCS)
@echo "GEN $@"
@(printf "![A picture of a jork (jean shork)](jork.png)\n\n"; \
printf "# BLAHAJ Hack-a-Sat 2020 Writeups\n\n"; \
2020-06-15 06:26:42 +00:00
printf "[Writeup in PDF format](writeup.pdf)\n\n"; \
2020-06-04 00:53:43 +00:00
for file in $(DOCS_ALL); do \
2020-06-15 06:26:42 +00:00
printf -- "- [%s](%s/)\n" "$$(grep '^# ' $$file|head -n1 | sed 's/^# //')" "$$(dirname $$file)"; \
2020-06-04 00:53:43 +00:00
done) > $@
2020-06-04 00:31:32 +00:00
$(HTML_CONTENT_ALL): $(HTML_DIR)/%: %
@mkdir -p $(dir $@) || true
@cp $< $@
2020-06-15 06:26:42 +00:00
$(HTML_DOCS): %index.html: %README.md $(HTML_CONTENT_ALL)
2020-06-04 00:31:32 +00:00
@echo "HTML $@"
2020-06-15 06:26:42 +00:00
@cd $(dir $@) && $(RM) tmp.md index.html
@cd $(dir $@) && (cat README.md; \
printf "\n\n\n### Files\n"; \
for file in *; do \
[ "$$file" != "tmp.md" ] && printf -- "- [%s](%s)\n" "$$file" "$$file" || true; \
done) >> tmp.md
2020-06-04 00:31:32 +00:00
@cd $(dir $@) && \
2020-06-04 00:53:43 +00:00
pandoc --filter pandoc-include-code --toc -f markdown \
2020-06-15 06:26:42 +00:00
-i tmp.md -t html5 -o index.html --mathjax="../../mathjax/tex-mml-chtml.js" \
-s --metadata title="$$(grep '^# ' README.md|head -n1|sed 's/^# //')" --template $(HTML_TEMPLATE) \
2020-06-04 00:53:43 +00:00
--metadata lang=en --metadata css="../../blahaj.css"
2020-06-15 06:26:42 +00:00
@cd $(dir $@) && $(RM) tmp.md