msc-drozdz/Makefile

119 lines
4.2 KiB
Makefile
Raw Permalink Normal View History

2021-10-18 21:37:05 +02:00
SHELL=/bin/bash -O globstar
# Do not edit these values, they should be changed by modifying .cookiecutter.yml
# and re-applying the template
PAPER_ID=msc-drozdz
HAS_APPENDIX=no
LATEX_TEMPLATE=amu
WITH_ARXIV_PACKAGE=no
CONTENT_TEX_SOURCES=$(filter-out $(PAPER_ID).tex config.tex other-extras.tex autozoil-extras.tex extras.tex metadata.tex preamble.tex the-appendix.tex, $(shell ls **/*.tex))
CURRENT_DIR=$(shell pwd)
AUTOZOIL_DIR?=/opt/autozoil
AUTOZOIL_LOCALE=pl_PL
space := $(subst ,, )
ifneq (,$(wildcard appendix.tex))
ifeq ($(LATEX_TEMPLATE),acl)
IS_APPENDIX_SEPARATE=yes
endif
ifeq ($(LATEX_TEMPLATE),eacl)
IS_APPENDIX_SEPARATE=yes
endif
endif
ifeq ($(IS_APPENDIX_SEPARATE),yes)
HAS_SUPPLEMENT=yes
endif
ifeq ($(LATEX_TEMPLATE),pw-thesis)
EXTRA_PDFS=titlepage.pdf
endif
CONTENT_TEX_SOURCES_WITH_DIR := $(addprefix $(CURRENT_DIR)/, $(CONTENT_TEX_SOURCES))
SCOREFILES=$(shell perl extract-score-files.pl $(CONTENT_TEX_SOURCES))
clean_latex_stuff=rm -rf *.aux *.nav *.toc *.log *.out *.blg *.bbl autozoil-log.txt autozoil.xml the-appendix.pdf supplement.zip $(PAPER_ID).pdf $(PAPER_ID).zip arxiv-$(PAPER_ID).pdf arxiv-$(PAPER_ID).tar.gz abstract.txt sentences.txt stats.txt $(EXTRA_PDFS) helpers/$(PAPER_ID)-contribution-declaration.tex helpers/$(PAPER_ID)-contribution-declaration.pdf helpers/*.aux helpers/*.bbl helpers/*.bcf helpers/*.blg helpers/*.log helpers/*.run.xml
ifeq ($(HAS_SUPPLEMENT),yes)
all: $(PAPER_ID).pdf abstract.txt supplement.zip stats.txt sentences.txt helpers/$(PAPER_ID)-contribution-declaration.pdf
else
all: $(PAPER_ID).pdf abstract.txt stats.txt sentences.txt helpers/$(PAPER_ID)-contribution-declaration.pdf
endif
source-pack: $(PAPER_ID).zip
stats.txt: $(PAPER_ID).pdf helpers/stats.sh
bash helpers/stats.sh $< > $@
cat $@
$(PAPER_ID).pdf: $(PAPER_ID).tex preamble.tex metadata.tex $(CONTENT_TEX_SOURCES) bibliography.bib $(SCOREFILES) $(EXTRA_PDFS)
pdflatex $<
bibtex $(PAPER_ID)
pdflatex $<
pdflatex $<
# to be copied and pasted as plain text (without LaTeX stuff)
abstract.txt: abstract.tex
cat $< | perl -pne 's/noqa\{[^}]+\}//g' | detex > $@
sentences.txt: $(PAPER_ID).pdf helpers/get-sentences.sh helpers/pdf-to-plain-text.sh helpers/strip-references.pl
bash helpers/get-sentences.sh $< > $@
scores/%.txt:
mkdir -p scores
curl "https://gonito.net/api/txt/score/$(subst $(space),%20,$*)" -o "$@"
autozoil-log.txt: $(CONTENT_TEX_SOURCES)
cd $(AUTOZOIL_DIR) && set -o pipefail && ./autozoil --locale $(AUTOZOIL_LOCALE) $(CONTENT_TEX_SOURCES_WITH_DIR) --alt-log-file $(CURRENT_DIR)/$(PAPER_ID).log | tee $(CURRENT_DIR)/$@
autozoil.xml: $(CONTENT_TEX_SOURCES)
cd $(AUTOZOIL_DIR) && set -o pipefail && ./autozoil --locale $(AUTOZOIL_LOCALE) $(CONTENT_TEX_SOURCES_WITH_DIR) --format xml --alt-log-file $(CURRENT_DIR)/$(PAPER_ID).log --exit-with-zero > $(CURRENT_DIR)/autozoil.xml
$(PAPER_ID).zip:
$(clean_latex_stuff)
rm -rf *~
zip -r $@ . -x '*.git*' '*.zip'
ifeq ($(HAS_SUPPLEMENT),yes)
supplement.zip: the-appendix.pdf
zip $@ $<
ifeq ($(IS_APPENDIX_SEPARATE),yes)
the-appendix.pdf: the-appendix.tex appendix.tex
pdflatex the-appendix
pdflatex the-appendix
pdflatex the-appendix
endif
endif
ifeq ($(WITH_ARXIV_PACKAGE),yes)
# test whether a paper can be generated from the arxiv package
arxiv-$(PAPER_ID).pdf: arxiv-$(PAPER_ID).tar.gz helpers/generate-pdf-from-arxiv-package.sh
bash -xe helpers/generate-pdf-from-arxiv-package.sh $< $@
arxiv-$(PAPER_ID).tar.gz: $(PAPER_ID).tex preamble.tex metadata.tex $(CONTENT_TEX_SOURCES) bibliography.bib $(SCOREFILES) helpers/prepare-arxiv-package.sh helpers/flatten-structure.pl
bash -xe helpers/prepare-arxiv-package.sh $(LATEX_TEMPLATE) $@
endif
ifeq ($(LATEX_TEMPLATE),pw-thesis)
titlepage.pdf: titlepage.tex
xelatex $<
endif
helpers/$(PAPER_ID)-contribution-declaration.pdf: helpers/$(PAPER_ID)-contribution-declaration.tex bibliography.bib
(cd helpers && pdflatex $(PAPER_ID)-contribution-declaration.tex)
(cd helpers && biber $(PAPER_ID)-contribution-declaration)
(cd helpers && pdflatex $(PAPER_ID)-contribution-declaration.tex)
helpers/$(PAPER_ID)-contribution-declaration.tex: contributions.yaml helpers/contribution-declaration.tex.tmpl helpers/generate-contribution-declaration.py
(cd helpers && python3 generate-contribution-declaration.py) < $< > $@
clean:
$(clean_latex_stuff)