forked from danielgruen/lighthouse_shapes
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
164 lines (139 loc) · 4.35 KB
/
Copy pathMakefile
File metadata and controls
164 lines (139 loc) · 4.35 KB
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
# To make the document with the default settings:
# > make
#
# To make with a specific format:
# > make <format>
#
# To tar up a flat version of a specific format:
# > make <format> tar
#
# Alex Drlica-Wagner: https://github.com/DarkEnergyScienceCollaboration/start_paper/issues/new?body=@kadrlica
# Primary file names - avoid cookiecutter variables, to enable `make
# upgrade` to cleanly over-write this Makefile...
main=main
default=$(shell cat .metadata.json | grep 'default_format' | cut -d'"' -f4)
outname=$(notdir $(shell pwd))
# LATEX environment variables
export TEXINPUTS:=./texmf/styles/:./tables/:
export BSTINPUTS:=./texmf/bib/:
# LaTeX journal class switcher flags
# apj=\def\flag{apj}
# apjl=\def
# mnras=\def\flag{mnras}
# Submission flags (these need some thought)
# arxiv=\def\flag{emulateapj}
# submit=${aastex}
# draft=\def\linenums{\linenumbers}
# Files to copy when making tarball
tardir=tmp
figdir=./figures
figures=$(figdir)/*.{png,jpg,pdf}
tabdir=./tables
tables=$(tabdir)/*.tex
styles=./texmf/styles/*.{sty,cls}
bibs=./texmf/bib/*.bst
source=$(main).{tex,bbl,bib} lsstdesc.bib authors.tex acknowledgments.tex
tarfiles=$(figures) $(tables) $(styles) $(bibs) $(source)
# Interpret `make` with no target as `make tex`, a latex Note.
# At present, if the default_format is anything other than
# [apj|apjl|mnras|prd|prl|emulateapj], a latex Note is made.
# In future, we could think of using `make` to eg run the ipynb
# notebook and make PDF from the output, but this has not been
# implemented yet.
all: export flag=\def\flag{$(default)}
all: apj copy
copy:
cp ${main}.pdf ${outname}.pdf
touch:
touch ${main}.tex
#http://journals.aas.org/authors/aastex/linux.html
#change the compiler call to allow a "." file
#
main :
latexmk -g -pdf \
-pdflatex='openout_any=a pdflatex %O -interaction=nonstopmode "${flag}\input{%S}"' \
${main}
#
tar : main
mkdir -p ${tardir}
cp ${tarfiles} ${tardir} | true
cp ${outname}.pdf ${tardir}/${outname}.pdf
cd ${tardir} && tar -czf ../${outname}.tar.gz . && cd ..
rm -rf ${tardir}
# http://stackoverflow.com/q/8028314/
TARGETS=apj apjl prd prl mnras tex
$(TARGETS): export flag = \def\flag{$(@)}
$(TARGETS):
$(MAKE) -e main
$(MAKE) -e copy
$(MAKE) -e tar
# NB. the 'tex' target doesn't actually do anything in docswitch - make
# with no target compiles PDF out of main.tex using lsstdescnote.cls
# (which is to say, by default we assume you are writing an LSST
# DESC Note in latex format).
tidy:
rm -f *.log *.aux *.out *.dvi *.synctex.gz *.fdb_latexmk *.fls
rm -f *.bbl *.blg *Notes.bib ${main}.pdf
clean: tidy
rm -f ${outname}.pdf ${outname}.tar.gz
# Update the tex styles etc:
baseurl=https://raw.githubusercontent.com/DarkEnergyScienceCollaboration/start_paper/master/%7B%7Bcookiecutter.folder_name%7D%7D
UPDATES=\
texmf/bib/apj.bst \
texmf/bib/mnras.bst \
texmf/styles/aas_macros.sty \
texmf/styles/aastex.cls \
texmf/styles/aastex61.cls \
texmf/styles/aps_macros.sty \
texmf/styles/lsstdesc_macros.sty \
texmf/styles/docswitch.sty \
texmf/styles/emulateapj.cls \
texmf/styles/mnras.cls \
texmf/styles/lsstdescnote.cls \
texmf/styles/lsstdesc_macros.sty \
.logos/desc-logo-small.png \
.logos/desc-logo.png \
.logos/header.png \
lsstdesc.bib \
.travis.yml \
figures/example.png
.PHONY: $(UPDATES)
$(UPDATES):
curl -s -S -o $(@) ${baseurl}/$(@)
@echo " "
update:
@echo "\nOver-writing LaTeX style files with the latest versions: \n"
@mkdir -p .logos figures texmf/styles texmf/bib
$(MAKE) $(UPDATES)
# Get fresh copies of the templates etc, for reference:
TEMPLATES=\
acknowledgments.tex \
authors.tex \
main.ipynb \
main.md \
main.rst \
main.tex \
main.bib
.PHONY: $(TEMPLATES) templates
$(TEMPLATES):
curl -s -S -o templates/$(@) ${baseurl}/$(@)
@echo " "
templates:
@echo "\nDownloading the latest versions of the template files, for reference: \n"
@mkdir -p templates
$(MAKE) $(TEMPLATES)
$(MAKE) new
ls templates/*
# Get a template copy of the latest Makefile, for reference:
.PHONY: new
new:
@echo "\nDownloading the latest version of the Makefile, for reference: \n"
@mkdir -p templates
curl -s -S -o templates/Makefile ${baseurl}/Makefile
@echo " "
# Over-write this Makefile with the latest version:
.PHONY: upgrade
upgrade:
@echo "\nDownloading the latest version of the Makefile: \n"
curl -s -S -o Makefile ${baseurl}/Makefile
@echo "\nNow get the latest styles and templates with\n\n make update\n make templates\n"