paper-cutter/{{cookiecutter.paper_repo_name}}/Makefile

157 lines
5.4 KiB
Makefile
Raw Normal View History

2022-11-09 16:55:03 +01:00
SHELL=/bin/bash
# Do not edit these values, they should be changed by modifying .cookiecutter.yml
# and re-applying the template
PAPER_ID={{cookiecutter.paper_id}}
HAS_APPENDIX={{cookiecutter.with_appendix}}
LATEX_TEMPLATE={{cookiecutter.latex_template}}
WITH_ARXIV_PACKAGE={{cookiecutter.with_arxiv_package}}
2022-11-09 16:55:03 +01:00
CONTENT_TEX_SOURCES=$(filter-out $(PAPER_ID).tex config.tex extras.tex metadata.tex preamble.tex the-appendix.tex, $(shell find . -name '*.tex'))
CURRENT_DIR=$(shell pwd)
AUTOZOIL_DIR?=/opt/autozoil
AUTOZOIL_LOCALE={{cookiecutter.locale}}
2022-06-06 20:03:04 +02:00
EXTERNAL_PLAIN_TEXT_CHECKER=
2021-09-17 12:16:34 +02:00
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)
2022-02-12 11:56:46 +01:00
{% if cookiecutter.contribution_declaration == 'yes' %}
all: $(PAPER_ID).pdf abstract.txt supplement.zip stats.txt sentences.txt helpers/$(PAPER_ID)-contribution-declaration.pdf
2022-02-12 11:56:46 +01:00
{% else %}
all: $(PAPER_ID).pdf abstract.txt supplement.zip stats.txt sentences.txt
{% endif %}
else
2022-02-12 11:56:46 +01:00
{% if cookiecutter.contribution_declaration == 'yes' %}
all: $(PAPER_ID).pdf abstract.txt stats.txt sentences.txt helpers/$(PAPER_ID)-contribution-declaration.pdf
2022-02-12 11:56:46 +01:00
{% else %}
all: $(PAPER_ID).pdf abstract.txt stats.txt sentences.txt
{% endif %}
endif
source-pack: $(PAPER_ID).zip
stats.txt: $(PAPER_ID).pdf helpers/stats.sh
bash helpers/stats.sh $< > $@
cat $@
2022-01-22 12:34:26 +01:00
{% if cookiecutter.beeminder_support == 'yes' %}
logbeeminder: helpers/logbeeminder.py stats.txt
python3 $<
{% endif %}
$(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 > $@
SENTENCE_EXTRACTION_METHOD=from-pdf
ifeq ($(LATEX_TEMPLATE),amu)
ifeq ($(AUTOZOIL_LOCALE),pl_PL)
SENTENCE_EXTRACTION_METHOD=from-tex
endif
endif
ifeq ($(SENTENCE_EXTRACTION_METHOD),from-tex)
2022-06-06 20:17:42 +02:00
sentences.txt: $(PAPER_ID).tex helpers/get-sentences.sh helpers/pdf-to-plain-text.sh helpers/strip-references.pl
2022-06-06 20:10:15 +02:00
bash helpers/get-sentences.sh $< from-tex > $@
else
sentences.txt: $(PAPER_ID).pdf helpers/get-sentences.sh helpers/pdf-to-plain-text.sh helpers/strip-references.pl
bash helpers/get-sentences.sh $< > $@
endif
scores/%.txt:
mkdir -p scores
2021-09-17 12:16:34 +02:00
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)/$@
2022-06-06 20:03:04 +02:00
ifeq ($(EXTERNAL_PLAIN_TEXT_CHECKER),)
autozoil: autozoil.xml
else
autozoil: autozoil.xml autozoil-external-check.xml
autozoil-external-check.xml: sentences.txt
2022-06-06 20:10:15 +02:00
curl -X POST -H "Content-Type: multipart/form-data" -F "file=@sentences.txt" $(EXTERNAL_PLAIN_TEXT_CHECKER) > $@
2022-06-06 20:03:04 +02:00
endif
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 *~
2022-01-15 22:46:14 +01:00
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
2022-02-12 11:56:46 +01:00
{% if cookiecutter.contribution_declaration == 'yes' %}
2021-10-02 10:29:50 +02:00
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
2021-10-02 10:29:50 +02:00
(cd helpers && python3 generate-contribution-declaration.py) < $< > $@
2022-02-12 11:56:46 +01:00
{% endif %}
clean:
$(clean_latex_stuff)