.PHONY: all clean genreadme CATS=aaaa comms ground-segment payload satellite-bus space DOCS_ALL=$(wildcard $(addsuffix /**/README.md,$(CATS))) WRITEUP_PDF=writeup.pdf PDF_DIR=build HTML_DIR=html HTML_CONTENT_ALL=$(addprefix $(HTML_DIR)/,$(wildcard $(addsuffix /**/*,$(CATS)))) HTML_DOCS=$(addprefix $(HTML_DIR)/,$(DOCS_ALL:README.md=index.html)) HTML_INDEX=$(HTML_DIR)/index.html HTML_TEMPLATE=$(abspath default.html5) all: README.md $(WRITEUP_PDF) $(HTML_INDEX) clean: $(RM) -r $(WRITEUP_PDF) $(PDF_DIR) $(HTML_DIR) README.md: $(DOCS_ALL) @echo "GEN $@" @(printf "# BLAHAJ Hack-a-Sat 2020 Writeups\n\n"; for file in $(DOCS_ALL); do \ printf -- "- [%s](%s)\n" "$$(dirname $$file)" "$$(dirname $$file)"; done) > README.md $(WRITEUP_PDF): $(DOCS_ALL) fonts.tex misc.tex top.md @echo "GEN writeup.md" @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) && \ pandoc --filter pandoc-include-code --toc --toc-depth 1 -f markdown-implicit_figures \ -i writeup.md --pdf-engine=lualatex -o writeup.pdf @cp $(PDF_DIR)/writeup.pdf $@ $(HTML_INDEX): $(HTML_CONTENT_ALL) $(HTML_DOCS) README.md @echo "GEN $@" @cp -r mathjax/ $(HTML_DIR)/mathjax/ @pandoc -i README.md -o $@ $(HTML_CONTENT_ALL): $(HTML_DIR)/%: % @mkdir -p $(dir $@) || true @cp $< $@ $(HTML_DOCS): %index.html: %README.md @echo "HTML $@" @cd $(dir $@) && \ pandoc --filter pandoc-include-code --toc --toc-depth 2 -f markdown \ -i README.md -t html5 -o index.html --mathjax="../../mathjax/tex-mml-chtml.js" \ -s --metadata title="$$(grep '^# ' README.md)" --template $(HTML_TEMPLATE)