-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
108 lines (88 loc) · 3.03 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
FILENAME = CHEP_2021_proposal
date = $(shell date +%Y-%m-%d)
output_file = draft_$(date).pdf
figure_src = $(wildcard figures/*.tex figures/*/*.tex)
figure_list = $(figure_src:.tex=.pdf)
LATEX = pdf #pdflatex
# LATEX = xelatex
# LATEX = lualatex
BIBTEX = bibtex
# BIBTEX = biber
default: document copy_draft
all: default
figures: $(figure_list)
# Target assumes figure source is in same directory as expected figure path
figures/%.pdf: figures/%.tex
latexmk -$(LATEX) -interaction=nonstopmode -halt-on-error $(basename $@)
mv $(notdir $(basename $@)).pdf $(basename $@).pdf
rm $(notdir $(basename $@)).*
text:
latexmk -$(LATEX) -logfilewarnings -halt-on-error -shell-escape $(FILENAME)
document: figures text
copy_draft:
rsync $(FILENAME).pdf $(output_file)
clean:
rm -f *.aux *.bbl *.blg *.dvi *.idx *.lof *.log *.lot *.toc \
*.xdy *.nav *.out *.snm *.vrb *.mp \
*.synctex.gz *.brf *.fls *.fdb_latexmk \
*.glg *.gls *.glo *.ist *.alg *.acr *.acn
clean_figures:
rm -f $(figure_list)
clean_drafts:
rm -f draft_*.pdf
realclean: clean clean_figures
rm -f *.ps *.pdf
lint:
grep -E --color=always -r -i --include=\*.tex --include=\*.bib "(\b[a-zA-Z]+) \1\b" || true
final:
if [ -f *.aux ]; then \
$(MAKE) clean; \
fi
$(MAKE) figures
$(MAKE) abstract
$(MAKE) text
$(MAKE) clean
$(MAKE) lint
arXiv: deep_clean document
# Get a minted cache
sed -i.bak 's/cache=false/cache=true/' latex/packages.tex
$(MAKE) document
# Copy files
mkdir submit_to_arXiv
cp CHEP_2021_proposal.tex submit_to_arXiv
cp *.bbl submit_to_arXiv/ms.bbl
cp -r src submit_to_arXiv
cp -r latex submit_to_arXiv
cp -r data submit_to_arXiv
cp -r figures submit_to_arXiv
cp Makefile submit_to_arXiv
mv _minted-CHEP_2021_proposal submit_to_arXiv/_minted-ms
mv submit_to_arXiv/CHEP_2021_proposal.tex submit_to_arXiv/ms.tex
# -i.bak is used for compatability across GNU and BSD/macOS sed
# Change the FILENAME to ms while ignoring commented lines
sed -i.bak '/^ *#/d;s/#.*//;0,/FILENAME/s/.*/FILENAME = ms/' submit_to_arXiv/Makefile
# Move webofc document class to top level
mv submit_to_arXiv/latex/webofc.cls submit_to_arXiv/webofc.cls
sed -i.bak 's#latex/webofc#webofc#' submit_to_arXiv/ms.tex
# Remove hyperref for arXiv
sed -i.bak '/{hyperref}/d' submit_to_arXiv/latex/packages.tex
sed -i.bak '/hypersetup/d' submit_to_arXiv/latex/packages.tex
# Use cache for minted
# c.f. https://github.com/gpoore/minted/issues/113#issuecomment-223451550
sed -i.bak 's/finalizecache/frozencache/' submit_to_arXiv/latex/packages.tex
# Cleanup temp files
find submit_to_arXiv/ -name "*.bak" -type f -delete
# arXiv requires .bib files to be compiled to .bbl files and will remove any .bib files
find submit_to_arXiv/ -name "*.bib" -type f -delete
tar -zcvf submit_to_arXiv.tar.gz submit_to_arXiv/
rm -rf submit_to_arXiv
$(MAKE) realclean
if [ -f latex/packages.tex.bak ];then \
mv latex/packages.tex.bak latex/packages.tex; \
fi
clean_arXiv:
if [ -f submit_to_arXiv.tar.gz ];then \
rm submit_to_arXiv.tar.gz; \
fi
deep_clean: realclean clean_arXiv
rm -rf submit_to_arXiv