bunige-document/Makefile

62 lines
1.7 KiB
Makefile
Raw Blame History

This file contains invisible Unicode characters!

This file contains invisible Unicode characters that may be processed differently from what appears below. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to reveal hidden characters.

SOURCE_FOLDER := sources
OUTPUT_FILENAME := document
TEMPLATE_REPOSITORY := https://git.milhit.ch/igor/bunige-pagedjs-template/releases/download
# Liste les fichiers sources.
MD_UNSORTED := $(wildcard $(SOURCE_FOLDER)/*.md)
# Ordonne les fichiers sources sur la base du début numérique du nom des
# fichiers.
MD_SORTED := $(shell printf '%s\n' $(MD_UNSORTED) | sort -t- -k1,1n)
.PHONY: all
all: pdf
# Construit le fichier HTML.
.PHONY: html
html: $(MD_SORTED)
pandoc \
--to=html --standalone \
--template=static/template.html --css=static/style.css \
-V static='./static' \
--citeproc \
--bibliography=./static/references.json --csl=./static/heg-iso-690.csl \
--toc --toc-depth=2 \
--out=$(OUTPUT_FILENAME).html $(MD_SORTED)
# Construit le fichier PDF.
.PHONY: pdf
pdf: $(MD_SORTED)
pandoc \
--to=pdf --pdf-engine=pagedjs-cli --embed-resources=true \
--template=static/template.html --css=static/style.css \
-V noscript=true -V static='./static' \
--citeproc \
--bibliography=./static/references.json --csl=./static/heg-iso-690.csl \
--toc --toc-depth=2 \
--out=$(OUTPUT_FILENAME).pdf $(MD_SORTED)
# Reconstruit le fichier HTML à la modification des autres fichiers.
.PHONY: watch
watch:
watchexec -r -w . -i document.html \
-- make html
# Supprime les fichiers construits lorsqu'ils ne sont plus nécessaire.
.PHONY: clean
clean:
rm -f *.html *.pdf
# Lance un serveur web pour servir le HTML.
.PHONY: serve
serve:
watchexec -r -w . "python -m http.server"
# Mets à jour le modèle de document
# Usage: make update VERSION=v1.0.0
.PHONY: update
update:
curl -o modèle.zip $(TEMPLATE_REPOSITORY)/$(VERSION)/$(VERSION).zip
unzip -f -o modèle.zip
rm modèle.zip