forked from seL4/seL4
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
316 lines (257 loc) · 10.8 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
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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
#
# Copyright 2014, General Dynamics C4 Systems
#
# SPDX-License-Identifier: GPL-2.0-only
#
# $Id: Makefile,v 1.26 2009-04-21 05:40:29 gernot Exp $
#
# To create a LaTeX diff against the CVS HEAD revision, use the target
# "diff" (or "viewdiff").
# To use a revision other than HEAD, speciff DIFF=x on the
# make command line to choose the revision x.
#
# This Makefile contains bash'isms.
SHELL=bash
.PHONY: all
BIBDIR ?= /home/disy/lib/BibTeX:../../../bibtex
LaTeXEnv = TEXINPUTS=".:/home/disy/lib/TeX:/home/disy/lib/ps:${TEXINPUTS}:"
BibTexEnv = BIBINPUTS=".:${BIBDIR}:${BIBINPUTS}:"
BibFiles = defs,extra,combined,theses,os-other
LaTeX = ${LaTeXEnv} pdflatex -interaction=nonstopmode
BibTeX = ${BibTexEnv} bibtex
Fig2Eps = fig2dev -L eps
Dia2Eps = dia -t eps -e
GnuPlot = gnuplot
Eps2Pdf = epstopdf --outfile
PdfView = xpdf
#PdfView = open -a preview
#PdfView = acroread
Lpr = lpr
mv = mv
awk = awk
R = R
doxygen = doxygen
PYTHON ?= python3
# To add a second target, simply append the basename of the .tex file here
Targets = manual
# CONFIGURATION OPTIONS
# =====================
# Extra figures that aren't supplied as dia, gnuplot or fig sources
# (eg figures already supplied in PDF, or supplied in EPS).
# List with PDF extensions:
ExtraFigs= #imgs/eps-fig.pdf
# Any other stuff that may be needed
# END CONFIGURATION OPTIONS
# =========================
Optional = $(addsuffix -diff, $(Targets))
All = $(Targets) $(Optional)
Diffopts=--type=BWUNDERLINE #-c .latexdiffconfig --append-safecmd="Comment"
Perf_Sources = $(wildcard imgs/*.perf)
Dia_Sources = $(wildcard imgs/*.dia)
Fig_Sources = $(wildcard imgs/*.fig)
Gnuplot_Sources = $(wildcard imgs/*.gnuplot)
R_Sources = $(wildcard imgs/*.r)
Figures = $(Perf_Sources:.perf=.pdf) $(Dia_Sources:.dia=.pdf) $(Fig_Sources:.fig=.pdf) $(Gnuplot_Sources:.gnuplot=.pdf) $(R_Sources:.r=.pdf) $(ExtraFigs)
Pdf = $(addsuffix .pdf, $(Targets))
Bib = references.bib
Tex = $(addsuffix .tex, $(Targets))
Diff_Pdf = $(addsuffix .pdf, $(Optional))
DoxygenOutput = doxygen-output
DoxygenXml = $(DoxygenOutput)/xml
Stage = stage
Libsel4Dir = ../libsel4
GeneratedLatexDir = generated
GeneratedLatex = $(wildcard $(GeneratedLatexDir)/*.tex)
GeneratedMarkdownDir = generated_markdown
GeneratedMarkdown = $(wildcard $(GeneratedMarkdownDir)/*.md)
GenerationTool = tools/parse_doxygen_xml.py
GenerateObjectInvocationTool = tools/gen_invocations.py
InterfaceDtd = $(Libsel4Dir)/tools/sel4_idl.dtd
.PHONY: FORCE
all: pdf
diff: diff_pdf
FORCE:
ps: $(Ps)
pdf: generated-latex $(Figures) Makefile $(Pdf)
diff_pdf: $(Figures) Makefile $(Diff_Pdf)
markdown: generated-markdown
# Verbosity.
ifeq (${V},1)
Q:=
else
Q:=@
endif
.PHONY: doxygen generated-headers generated-latex generated-markdown
# We call doxygen twice below while excluding either syscalls_master.h or syscalls_mcs.h.
# Without excluding one of the two files, the doc strings get merged in inconsistent ways
# and lead to bad output in the manual. If there is a better way to support duplicates
# then it could be used instead.
doxygen: generated-headers
( cat Doxyfile ; echo "EXCLUDE = ./../libsel4/include/sel4/syscalls_master.h" ) | $(doxygen) -
( cat Doxyfile ; echo "EXCLUDE = ./../libsel4/include/sel4/syscalls_mcs.h" ) | $(doxygen) -
# Xml files generated by doxygen
${DoxygenXml}/%.xml: doxygen
@echo "====> Generating $@"
# Latex files translated from doxygen-generated xml
${GeneratedLatexDir}/%SystemCalls.tex: ${DoxygenXml}/group__%SystemCalls.xml
@echo "====> Generating $@"
${Q}${PYTHON} ${GenerationTool} --level 3 --input $< --output $@
${GeneratedLatexDir}/%.tex: ${DoxygenXml}/group__%.xml
@echo "====> Generating $@"
${Q}${PYTHON} ${GenerationTool} --level 2 --input $< --output $@
# Collect generated latex files into single rule
generated-latex: ${GeneratedLatexDir}/GeneralSystemCalls.tex \
${GeneratedLatexDir}/MCSSystemCalls.tex \
${GeneratedLatexDir}/DebuggingSystemCalls.tex \
${GeneratedLatexDir}/BenchmarkingSystemCalls.tex \
${GeneratedLatexDir}/X86SystemCalls.tex \
${GeneratedLatexDir}/ObjectApi.tex \
${GeneratedLatexDir}/ObjectApiX86.tex \
${GeneratedLatexDir}/ObjectApiArm.tex \
${GeneratedLatexDir}/ObjectApiAarch32.tex \
${GeneratedLatexDir}/ObjectApiAarch64.tex \
${GeneratedLatexDir}/ObjectApiIa32.tex \
${GeneratedLatexDir}/ObjectApiX64.tex \
${GeneratedLatexDir}/ObjectApiRISCV.tex
# Markdown files translated from doxygen-generated xml
${GeneratedMarkdownDir}/%.md: ${DoxygenXml}/group__%.xml Makefile
@echo "====> Generating $@"
${Q}${PYTHON} ${GenerationTool} --format markdown --level 2 --input $< --output $@
# Collect generated markdown files into single rule
generated-markdown: ${GeneratedMarkdownDir}/GeneralSystemCalls.md \
${GeneratedMarkdownDir}/MCSSystemCalls.md \
${GeneratedMarkdownDir}/DebuggingSystemCalls.md \
${GeneratedMarkdownDir}/BenchmarkingSystemCalls.md \
${GeneratedMarkdownDir}/X86SystemCalls.md \
${GeneratedMarkdownDir}/ObjectApi.md \
${GeneratedMarkdownDir}/ObjectApiX86.md \
${GeneratedMarkdownDir}/ObjectApiArm.md \
${GeneratedMarkdownDir}/ObjectApiAarch32.md \
${GeneratedMarkdownDir}/ObjectApiAarch64.md \
${GeneratedMarkdownDir}/ObjectApiIa32.md \
${GeneratedMarkdownDir}/ObjectApiX64.md \
${GeneratedMarkdownDir}/ObjectApiRISCV.md
# Generate object invocation prototypes
${Stage}/object_invocations.h: ${Libsel4Dir}/include/interfaces/sel4.xml \
${Libsel4Dir}/arch_include/x86/interfaces/sel4arch.xml \
${Libsel4Dir}/arch_include/arm/interfaces/sel4arch.xml \
${Libsel4Dir}/sel4_arch_include/aarch32/interfaces/sel4arch.xml \
${Libsel4Dir}/sel4_arch_include/aarch64/interfaces/sel4arch.xml \
${Libsel4Dir}/sel4_arch_include/ia32/interfaces/sel4arch.xml \
${Libsel4Dir}/sel4_arch_include/x86_64/interfaces/sel4arch.xml \
${Libsel4Dir}/arch_include/riscv/interfaces/sel4arch.xml
@echo "====> Generating documented object invocation header"
${Q}${PYTHON} ${GenerateObjectInvocationTool} --dtd ${InterfaceDtd} --output $@ $^
# Collect generated headers into single rule
generated-headers: ${Stage}/object_invocations.h
# Fetch information from the environment that needs to go into the document.
env.tex: FORCE
@echo 'ENV ->' $@
${Q}${PYTHON} tools/gen_env.py $@
manual.pdf: VERSION env.tex manual.tex parts/*.tex parts/api/*.tex
%.pdf: %.perf tools/bargraph.pl
@echo $< '->' $@
${Q}${BarGraph} -pdf $< > $@
%.pdf: %.eps
@echo $< '->' $@
${Q}${Eps2Pdf} $@ $<
%.pdf: %.ps
@echo $< '->' $@
${Q}${Eps2Pdf} $@ $<
%.eps: %.dia
@echo $< '->' $@
${Q}${Dia2Eps} $@ $<
%.eps: %.fig
@echo $< '->' $@
${Q}${Fig2Eps} $< $@
%.eps: %.gnuplot
@echo $< '->' $@
${Q}${GnuPlot} $<
%.eps: %.r
@echo $< '->' $@
${Q}${R} --vanilla < $<
view: pdf
${Q}for i in $(Pdf); do \
$(PdfView) $$i & \
done
viewdiff: diff
${Q}for i in $(Diff_Pdf); do \
$(PdfView) $$i & \
done
print: pdf
${Q}for i in $(Pdf); do \
$(Lpr) $$i \
done
clean:
rm -f *.aux *.toc *.bbl *.blg *.dvi *.log *.pstex* *.eps *.cb *.brf \
*.out *.ps *-diff.tex *.mps .log *.pdf *.tgz *~ *.lof *.lot env.tex
rm -rf ${DoxygenOutput} ${GeneratedLatexDir} ${GeneratedMarkdownDir}
rm -rf ${Stage}
tar: clean
( p=`pwd` && d=`basename "$$p"` && cd .. && \
tar cfz $$d.tgz $$d && \
mv $$d.tgz $$d )
help:
@echo "Main targets: all diff view viewdiff print clean tar"
@echo "'make diff' will show changes to head revision"
@echo "'make DIFF=<rev> diff' will show changes to revision <rev>"
##############################################################################
DIFF ?= tip
%-diff.dvi: %-diff.tex
%-diff.tex: %.tex FORCE
@echo "====> Retrieving revision $(DIFF) of $<"
${Q}hg cat -r $(DIFF) $< > $(@:-diff.tex=-$(DIFF)-diff.tex)
@echo "====> Creating diff of revision $(DIFF) of $<"
${Q}./tools/latexdiff $(Diffopts) $(@:-diff.tex=-$(DIFF)-diff.tex) $< > $@
.PHONY: FORCE
FORCE:
# don't delete %.aux intermediates
.SECONDARY:
##############################################################################
Rerun = '(There were undefined references|Rerun to get (cross-references|the bars) right)'
Rerun_Bib = 'No file.*\.bbl|Citation.*undefined'
Undefined = '((Reference|Citation).*undefined)|(Label.*multiply defined)'
Error = '^! '
# combine citation commands from all targets into tmp.aux, generate references.bib from this
references.bib: $(addsuffix .tex, $(Targets)) env.tex
@echo "====> Parsing targets for references";
${Q}for i in $(Targets); do \
$(LaTeX) $$i.tex >>.log; \
cat $$i.aux | grep -e "\(citation\|bibdata\|bibstyle\)" | sed 's/bibdata{references}/bibdata{$(BibFiles)}/g' >> all_refs.aux; \
done
@echo "====> Removing duplicate bib entries";
${Q}cat all_refs.aux | uniq > tmp.aux;
${Q}diff references.aux tmp.aux > references.diff 2> /dev/null; \
if [ -s references.diff ] && [ -e references.bib ]; then \
echo "====> Changed references:"; \
cat references.diff | grep "citation"; \
echo -n "These will cause changes to references.bib, do you want to rebuild this file? (yes/no): "; \
read rebuild_refs; \
fi; \
if [ "$$rebuild_refs" == "yes" ] || [ \! -e references.bib ]; then \
echo "====> Building references.bib"; \
$(BibTexEnv) ./tools/bibexport.sh -t -o references.bib tmp.aux > /dev/null 2> /dev/null; \
cp tmp.aux references.aux; \
fi;
${Q}rm all_refs.aux tmp.aux references.diff
%.pdf: %.tex references.bib $(Figures) Makefile
${Q}if ! test -e $*.bbl || test $(Bib) -nt $*.bbl; then rm -f $*.bbl; fi
@echo "====> LaTeX first pass: $(<)"
${Q}$(LaTeX) $< >.log || if egrep -q $(Error) $*.log ; then cat .log; rm $@; false ; fi
${Q}if egrep -q $(Rerun_Bib) $*.log ; then echo "====> BibTex" && $(BibTeX) $* > /dev/null && echo "====> LaTeX BibTeX pass" && $(LaTeX) >.log $< ; fi
${Q}if egrep -q $(Rerun) $*.log ; then echo "====> LaTeX rerun" && $(LaTeX) >.log $<; fi
${Q}if egrep -q $(Rerun) $*.log ; then echo "====> LaTeX rerun" && $(LaTeX) >.log $<; fi
${Q}if egrep -q $(Rerun) $*.log ; then echo "====> LaTeX rerun" && $(LaTeX) >.log $<; fi
@echo "====> Undefined references and citations in $(<):"
${Q}egrep -i $(Undefined) $*.log || echo "None."
@echo "====> Dimensions:"
${Q}grep "dimension:" $*.log || echo "None."
##############################################################################
# Generate a list of FIXMEs
fixmes:
${Q}for i in $(Tex); do \
echo "FIXMEs in $$i:"; \
nl -b a $$i | grep "FIXME{" | nl -b a; \
echo -n "Total FIXMES: " && grep "FIXME{" $$i | wc -l; \
echo; \
done