Makefile 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. # From https://tex.stackexchange.com/questions/40738/how-to-properly-make-a-latex-project
  2. # -----------------------------------------------------------------------------
  3. # You want latexmk to *always* run, because make does not have all the info.
  4. # Also, include non-file targets in .PHONY so they are run regardless of any
  5. # file of the given name existing.
  6. .PHONY: clean
  7. .PHONY: deep-clean
  8. # If executing in a container:
  9. LATEX_IMAGE=docker.io/centerforopenneuroscience/latex-biber:0.0.1-beta
  10. # Common options for podman invocations
  11. PODMAN_ARGS = --rm -v "$()../":/data:Z --user="$(id -u):$(id -g)" "$(LATEX_IMAGE)"
  12. SHELL = /bin/bash
  13. # A build of an article.
  14. SHOWCASE_VERSION = singularity_20230908122618
  15. SHOWCASE_PAPERDIFF_PDF = data/paperdiff_$(SHOWCASE_VERSION).pdf
  16. COMMON := $(wildcard common/*)
  17. TEX := $(wildcard *.tex) metadata.tex
  18. STYLE := $(wildcard sty/* rescience.cls)
  19. DATA := $(wildcard data/*.dot)
  20. # The first rule in a Makefile is the one executed by default ("make"). It
  21. # should always be the "all" rule, so that "make" and "make all" are identical.
  22. .PHONY: all
  23. all: article
  24. # Article formats:
  25. FORMAT?=frontiers
  26. #
  27. # CUSTOM BUILD RULES
  28. # -----------------------------------------------------------------------------
  29. metadata.tex: metadata.yaml
  30. ./classes/yaml-to-latex.py -i $< -o $@
  31. #
  32. # FIGURES GENERATION RULES
  33. # -----------------------------------------------------------------------------
  34. # 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`
  35. $(SHOWCASE_PAPERDIFF_PDF):
  36. datalad get ../outputs/*/*.pdf
  37. prepare/paperdiff.sh $(SHOWCASE_VERSION)
  38. data/paperdiff.csv: $(SHOWCASE_PAPERDIFF_PDF)
  39. cd prepare; python paperdiff_parse.py
  40. figs/diff_date.pdf: $(SHOWCASE_PAPERDIFF_PDF)
  41. scripts/diff_date.sh $(SHOWCASE_PAPERDIFF_PDF)
  42. figs/diff_fig.pdf: $(SHOWCASE_PAPERDIFF_PDF)
  43. scripts/diff_fig.sh $(SHOWCASE_PAPERDIFF_PDF)
  44. figs/diff_text.pdf: $(SHOWCASE_PAPERDIFF_PDF)
  45. scripts/diff_text.sh $(SHOWCASE_PAPERDIFF_PDF)
  46. figs/diff_pages.pdf: data/paperdiff.csv
  47. cd scripts; python diff_pages.py
  48. figs/topology.pdf: data/topology.dot
  49. cd data; dot -Tpdf topology.dot -o ../figs/topology.pdf 2>| topology.log
  50. figs/workflow.pdf: data/workflow.dot
  51. cd data; dot -Tpdf workflow.dot -o ../figs/workflow.pdf 2>| workflow.log
  52. # The following is used in the README, as it does not support PDF:
  53. cd data; dot -Tpng workflow.dot -o ../figs/workflow.png 2>| workflow.log
  54. #
  55. # Article build rules
  56. # -----------------------------------------------------------------------------
  57. .PHONY: container-article-interactive
  58. container-article-interactive: live
  59. podman run -it $(PODMAN_ARGS)
  60. .PHONY: container-article
  61. container-article:
  62. podman run --net=none $(PODMAN_ARGS) \
  63. $(MAKE) clean-publishing
  64. podman run $(PODMAN_ARGS) \
  65. $(MAKE) article FORMAT=$(FORMAT)
  66. .PHONY: article
  67. article: $(COMMON) $(TEX) $(STYLE) $(DATA) $(SHOWCASE_PAPERDIFF_PDF)
  68. latexmk -pdf -pdflatex="xelatex -interaction=nonstopmode" -use-make article-$(FORMAT).tex
  69. cp article-$(FORMAT).pdf article.pdf
  70. .PHONY: poster
  71. poster: $(COMMON) $(TEX) $(STYLE) $(DATA) $(SHOWCASE_PAPERDIFF_PDF)
  72. latexmk -pdf -pdflatex="xelatex -interaction=nonstopmode" -use-make poster.tex
  73. .PHONY: container-poster
  74. container-poster: $(COMMON) $(TEX) $(STYLE) $(DATA) $(SHOWCASE_PAPERDIFF_PDF)
  75. podman run --net=none $(PODMAN_ARGS) \
  76. $(MAKE) clean-publishing
  77. podman run $(PODMAN_ARGS) \
  78. $(MAKE) poster
  79. # Target to specifically remove LaTeX traces.
  80. .PHONY: clean
  81. clean:
  82. @latexmk -CA
  83. @rm -rf __pycache__
  84. @rm -f *.{run.xml,bbl}
  85. @rm -f data/paperdiff_*.{log,csv,pdf}
  86. @rm -f data/topology.log
  87. @rm -f figs/diff_date.pdf
  88. @rm -f figs/diff_fig.pdf
  89. @rm -f figs/diff_pages.pdf
  90. @rm -f figs/diff_text.pdf
  91. @rm -f figs/topology.pdf
  92. @rm -f figs/workflow.pdf
  93. @rm -f metadata.tex
  94. @rm -f *.nav
  95. @rm -f *.snm
  96. # Upload target
  97. .PHONY: upload
  98. upload: article poster
  99. rsync -avP article-$(FORMAT).pdf dreamarticles:articles.chymera.eu/fraaef-$(FORMAT).pdf
  100. rsync -avP poster.pdf dreamarticles:articles.chymera.eu/fraaef-poster.pdf