123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126 |
- # From https://tex.stackexchange.com/questions/40738/how-to-properly-make-a-latex-project
- # -----------------------------------------------------------------------------
- # You want latexmk to *always* run, because make does not have all the info.
- # Also, include non-file targets in .PHONY so they are run regardless of any
- # file of the given name existing.
- .PHONY: clean
- .PHONY: deep-clean
- # If executing in a container:
- LATEX_IMAGE=docker.io/centerforopenneuroscience/latex-biber:0.0.1-beta
- # Common options for podman invocations
- PODMAN_ARGS = --rm -v "$()../":/data:Z --user="$(id -u):$(id -g)" "$(LATEX_IMAGE)"
- SHELL = /bin/bash
- # A build of an article.
- SHOWCASE_VERSION = singularity_20230908122618
- SHOWCASE_PAPERDIFF_PDF = data/paperdiff_$(SHOWCASE_VERSION).pdf
- COMMON := $(wildcard common/*)
- TEX := $(wildcard *.tex) metadata.tex
- STYLE := $(wildcard sty/* rescience.cls)
- DATA := $(wildcard data/*.dot)
- # The first rule in a Makefile is the one executed by default ("make"). It
- # should always be the "all" rule, so that "make" and "make all" are identical.
- .PHONY: all
- all: article
- # Article formats:
- FORMAT?=frontiers
- #
- # CUSTOM BUILD RULES
- # -----------------------------------------------------------------------------
- metadata.tex: metadata.yaml
- ./classes/yaml-to-latex.py -i $< -o $@
- #
- # FIGURES GENERATION RULES
- # -----------------------------------------------------------------------------
- # The diff version name is is a placeholder dependency, the targets depend on multiple or variable output files, all of which get generated by `prepare/paperdiff.pdf`
- $(SHOWCASE_PAPERDIFF_PDF):
- datalad get ../outputs/*/*.pdf
- prepare/paperdiff.sh $(SHOWCASE_VERSION)
- data/paperdiff.csv: $(SHOWCASE_PAPERDIFF_PDF)
- cd prepare; python paperdiff_parse.py
- figs/diff_date.pdf: $(SHOWCASE_PAPERDIFF_PDF)
- scripts/diff_date.sh $(SHOWCASE_PAPERDIFF_PDF)
- figs/diff_fig.pdf: $(SHOWCASE_PAPERDIFF_PDF)
- scripts/diff_fig.sh $(SHOWCASE_PAPERDIFF_PDF)
- figs/diff_text.pdf: $(SHOWCASE_PAPERDIFF_PDF)
- scripts/diff_text.sh $(SHOWCASE_PAPERDIFF_PDF)
- figs/diff_pages.pdf: data/paperdiff.csv
- cd scripts; python diff_pages.py
- figs/topology.pdf: data/topology.dot
- cd data; dot -Tpdf topology.dot -o ../figs/topology.pdf 2>| topology.log
- figs/workflow.pdf: data/workflow.dot
- cd data; dot -Tpdf workflow.dot -o ../figs/workflow.pdf 2>| workflow.log
- # The following is used in the README, as it does not support PDF:
- cd data; dot -Tpng workflow.dot -o ../figs/workflow.png 2>| workflow.log
- #
- # Article build rules
- # -----------------------------------------------------------------------------
- .PHONY: container-article-interactive
- container-article-interactive: live
- podman run -it $(PODMAN_ARGS)
- .PHONY: container-article
- container-article:
- podman run --net=none $(PODMAN_ARGS) \
- $(MAKE) clean-publishing
- podman run $(PODMAN_ARGS) \
- $(MAKE) article FORMAT=$(FORMAT)
- .PHONY: article
- article: $(COMMON) $(TEX) $(STYLE) $(DATA) $(SHOWCASE_PAPERDIFF_PDF)
- latexmk -pdf -pdflatex="xelatex -interaction=nonstopmode" -use-make article-$(FORMAT).tex
- cp article-$(FORMAT).pdf article.pdf
- .PHONY: poster
- poster: $(COMMON) $(TEX) $(STYLE) $(DATA) $(SHOWCASE_PAPERDIFF_PDF)
- latexmk -pdf -pdflatex="xelatex -interaction=nonstopmode" -use-make poster.tex
- .PHONY: container-poster
- container-poster: $(COMMON) $(TEX) $(STYLE) $(DATA) $(SHOWCASE_PAPERDIFF_PDF)
- podman run --net=none $(PODMAN_ARGS) \
- $(MAKE) clean-publishing
- podman run $(PODMAN_ARGS) \
- $(MAKE) poster
- # Target to specifically remove LaTeX traces.
- .PHONY: clean
- clean:
- @latexmk -CA
- @rm -rf __pycache__
- @rm -f *.{run.xml,bbl}
- @rm -f data/paperdiff_*.{log,csv,pdf}
- @rm -f data/topology.log
- @rm -f figs/diff_date.pdf
- @rm -f figs/diff_fig.pdf
- @rm -f figs/diff_pages.pdf
- @rm -f figs/diff_text.pdf
- @rm -f figs/topology.pdf
- @rm -f figs/workflow.pdf
- @rm -f metadata.tex
- @rm -f *.nav
- @rm -f *.snm
- # Upload target
- .PHONY: upload
- upload: article poster
- rsync -avP article-$(FORMAT).pdf dreamarticles:articles.chymera.eu/fraaef-$(FORMAT).pdf
- rsync -avP poster.pdf dreamarticles:articles.chymera.eu/fraaef-poster.pdf
|