Repository navigation
Expand file tree
/
Copy pathdoc.mak
More file actions
349 lines (286 loc) · 11.4 KB
/
Copy pathdoc.mak
File metadata and controls
349 lines (286 loc) · 11.4 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
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
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
# file: doc.mak
# description: Makefile submodule to build the documentation
# author: Andrea Vedaldi
# Copyright (C) 2013-14 Andrea Vedaldi.
# Copyright (C) 2007-12 Andrea Vedaldi and Brian Fulkerson.
# All rights reserved.
#
# This file is part of the VLFeat library and is made available under
# the terms of the BSD license (see the COPYING file).
info: doc-info
clean: doc-clean
distclean: doc-distclean
archclean: doc-archclean
# --------------------------------------------------------------------
# Configuration
# --------------------------------------------------------------------
DOXYGEN ?= doxygen
PDFLATEX ?= pdflatex
FIG2DEV ?= fig2dev
CONVERT ?= convert
PYTHON ?= python
GROFF ?= groff
TIDY ?= tidy
MV ?= mv
SED ?= sed
# 95 DPI makes a letter page 808 pixels large
screen_dpi := 95
doc: doc-api doc-man doc-matlab
# generate $(doc-dir) target
$(eval $(call gendir, doc, \
doc \
doc/build doc/build/api doc/build/man doc/build/figures \
doc/demo doc/figures doc/matlab doc/api))
# generate results-dir target
$(eval $(call gendir, results, results))
# --------------------------------------------------------------------
# MATLAB
# --------------------------------------------------------------------
.PHONY: doc-deep
doc-matlab : toolbox/doc/matlab/helptoc.xml
doc-matlab : toolbox/doc/matlab/helpsearch-v3/segments.gen
ifdef MATLAB_PATH
ifeq ($(call gt,$(MATLAB_VER),80500),)
doc-matlab : toolbox/doc/matlab/helpsearch-v3/segments.gen
else
doc-matlab : toolbox/doc/matlab/helpsearch-v2/segments.gen
endif
endif
# use MATLAB to create the figures for the tutorials
doc-deep: $(doc-dir) $(results-dir) all
cd toolbox ; \
VL_DEMO_PRINT=y $(MATLAB_EXE) \
-$(ARCH) -nodesktop -nosplash \
-r "clear mex;vl_setup demo;vl_demo;exit"
@echo "Trimming images ..."
find doc/demo -name "*.jpg" -exec $(CONVERT) -trim "{}" "{}" ";"
@echo "Done trimming"
$(MAKE) doc
# make documentation searchable in MATLAB
m_doc_lnk := toolbox/doc
toolbox/doc/matlab/helptoc.xml : doc/build/matlab/helptoc.xml doc/index.html
ln -sf ../doc toolbox/doc
cp -v "$<" "$@"
toolbox/doc/matlab/helpsearch-v3/segments.gen : toolbox/doc/matlab/helptoc.xml
$(MATLAB_EXE) -$(ARCH) -nodisplay -nosplash -r \
"addpath('toolbox');builddocsearchdb('toolbox/doc/matlab/');exit"
toolbox/doc/matlab/helpsearch-v2/segments.gen : toolbox/doc/matlab/helptoc.xml
$(MATLAB_EXE) -$(ARCH) -nodisplay -nosplash -r \
"addpath('toolbox');builddocsearchdb('toolbox/doc/matlab/');exit"
# --------------------------------------------------------------------
# MDoc
# --------------------------------------------------------------------
doc-matlab: doc/build/matlab/mdoc.html
#
# Use mdoc.py to create the toolbox documentation that will be
# embedded in the website.
#
doc/build/matlab/mdoc.html doc/build/matlab/helptoc.xml: \
$(m_src) \
docsrc/mdoc.py #make/doc.mak
$(PYTHON) docsrc/mdoc.py toolbox doc/build/matlab \
--format=web \
--exclude='noprefix/.*' \
--exclude='xtune/.*' \
--exclude='xtest/.*' \
--exclude='.*/vl_test_.*' \
--exclude='.*/vl_demo_.*' \
--exclude='.*/vl_tune_.*' \
--helptoc \
--helptoc-toolbox-name VLFeat \
--verbose
# --------------------------------------------------------------------
# Auto-include demo m-files
# --------------------------------------------------------------------
m_demo_src=$(wildcard toolbox/demo/vl_demo_*.m)
# Convert the various man pages
doc/build/matlab/demo.xml : $(m_demo_src) $(doc-dir) make/doc.mak
@echo "Indexing demo files -> $@"
@( \
echo '<!DOCTYPE group PUBLIC ' ; \
echo ' "-//W3C//DTD XHTML 1.0 Transitional//EN"' ; \
echo ' "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">' ; \
echo "<group>" ; \
for fullName in $(m_demo_src) ; \
do \
fileName=$${fullName#toolbox/demo/} ; \
stem=$${fileName%.*} ; \
( \
echo "<page id='$${stem}' name='$${stem}' title='$${stem}' hide='yes'>" ; \
printf "<h1>Source code for <code>%s.m</code></h1>" "$${stem}"; \
echo "<p>This file is located in the <code>toolbox/demo</code> folder in VLFeat package.</p>" ; \
echo "<precode type='matlab'>" ; \
echo "<include src='toolbox/demo/$${fileName}' type='text'/>" ; \
echo "</precode>" ; \
echo "</page>" \
) ; \
done ; \
echo "</group>" ; \
) > "$@"
# --------------------------------------------------------------------
# Man
# --------------------------------------------------------------------
doc-man: doc/build/man/xman.xml doc/build/man/xman.html
man_src := $(wildcard src/*.1) $(wildcard src/*.7)
man_tgt := $(subst src/,doc/build/man/,$(addsuffix .html,$(man_src)))
doc/build/man/index.html : $(doc-dir)
# Integrate in Webdoc
doc/build/man/xman.xml : $(man_tgt) $(doc-dir)
@echo "Generating MAN XML webdooc document $@"
@echo "<group>" > "$@"
@for fullName in $(man_src) ; \
do \
fileName=$${fullName#src/} ; \
stem=$${fileName%.*} ; \
( \
echo "<page id='man.$${stem}' name='$${stem}' title='$${stem}'>" ; \
echo "<include src='doc/build/man/$${fileName}.html'/>" ; \
echo "</page>" \
) >> "$@" ; \
done
echo "</group>" >> "$@"
# Index page
doc/build/man/xman.html : $(man_tgt) $(doc-dir)
@echo "Generating MAN HTML index page $@"
@echo "<ul>" > "$@"
@for fullName in $(man_src) ; \
do \
fileName=$${fullName#src/} ; \
stem=$${fileName%.*} ; \
echo "<li><a href='%pathto:man.$${stem};'>$${stem}</a></li>" >> "$@" ; \
done
echo "</ul>" >> "$@"
# Convert the various man pages
doc/build/man/%.html : src/% $(doc-dir)
@echo MAN2HTML "$(@)"
@( \
echo '<!DOCTYPE group PUBLIC ' ; \
echo ' "-//W3C//DTD XHTML 1.0 Transitional//EN"' ; \
echo ' "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">' ; \
echo "<group>" ; \
$(GROFF) -mandoc -Thtml < "$<" | \
$(TIDY) -asxhtml 2>/dev/null | \
sed -e '1,/<body>/ d' -e '/<\/body>/,$$ d' ; \
echo "</group>" \
) > "$@"
# --------------------------------------------------------------------
# FIG and SVG figures and images
# --------------------------------------------------------------------
doc_fig_src := $(wildcard docsrc/figures/*.fig)
doc_svg_src := $(wildcard docsrc/figures/*.svg)
doc_fig_tgt += \
$(subst docsrc/,doc/,$(doc_fig_src:.fig=.png)) \
$(subst docsrc/,doc/,$(doc_svg_src:.svg=.png))
.PRECIOUS: doc/build/figures/%.pdf
.PRECIOUS: doc/build/figures/%.tex
doc/figures/%.png : doc/build/figures/%.pdf
$(call C,CONVERT) -units PixelsPerInch -density $(screen_dpi) -resample $(screen_dpi) -trim "$<" "$@"
doc/figures/%.png : docsrc/figures/%.svg
$(call C,CONVERT) -units PixelsPerInch -density $(screen_dpi) -resample $(screen_dpi) -trim "$<" "$@"
# Fig
doc/build/figures/%-raw.tex : docsrc/figures/%.fig $(doc-dir)
$(call C,FIG2DEV) -L pdftex_t -p doc/build/figures/$*-raw.pdf "$<" "$@"
doc/build/figures/%-raw.pdf : docsrc/figures/%.fig $(doc-dir)
$(call C,FIG2DEV) -L pdftex "$<" "$@"
doc/build/figures/%.pdf doc/build/figures/%.aux doc/build/figures/%.log : \
doc/build/figures/%.tex doc/build/figures/%-raw.tex doc/build/figures/%-raw.pdf $(doc-dir)
$(call C,PDFLATEX) -shell-escape -interaction=batchmode -output-directory="$(dir $@)" "$<" 2>/dev/null
doc/build/figures/%.tex : $(doc-dir)
@echo GEN "$(@)"
@/bin/echo '\documentclass[landscape]{article}' >$@
@/bin/echo '\usepackage[paper=a2paper,margin=0pt]{geometry}' >>$@
@/bin/echo '\usepackage{graphicx,color}' >>$@
@/bin/echo '\begin{document}' >>$@
@/bin/echo '\pagestyle{empty}' >>$@
@/bin/echo '\input{doc/build/figures/$(*)-raw.tex}' >>$@
@/bin/echo '\end{document}' >>$@
# --------------------------------------------------------------------
# Doxygen
# --------------------------------------------------------------------
doc-api: doc/api/index.html
doc/api/index.html: docsrc/doxygen.conf docsrc/vlfeat.bib VERSION \
$(dll_src) $(dll_hdr) $(doc_fig_tgt) toolbox/mexutils.h \
doc/build/doxygen_header.html doc/build/doxygen_footer.html
ln -sf docsrc/vlfeat.bib vlfeat.bib
$(DOXYGEN) $< 2>&1 | sed -e 's/Warning:/warning: /g'
rm vlfeat.bib
cp -fv docsrc/doxygen.css doc/api/doxygen.css
# --------------------------------------------------------------------
# Webdoc
# --------------------------------------------------------------------
webdoc_src = $(wildcard docsrc/*.xml) $(wildcard docsrc/*.html) $(wildcard docsrc/tutorials/*.html)
doc: doc/index.html doc/vlfeat.css doc/pygmentize.css $(doc_fig_tgt)
# prebuild to generate doxygen header and footer
doc/build/doxygen_header.html doc/build/doxygen_footer.html: $(webdoc_src) $(doc-dir)
VERSION=$(VER) $(PYTHON) docsrc/webdoc.py \
--outdir=doc/build/ \
--verbose \
docsrc/vlfeat-website-preproc.xml
cat doc/build/api/index.html | \
sed -n '/<!-- Doc Here -->/q;p' > doc/build/doxygen_header.html
echo '<div id="top">' >> doc/build/doxygen_header.html
cat doc/build/api/index.html | \
sed -n '/<!-- Doc Here -->/,$$p' > doc/build/doxygen_footer.html
doc/vlfeat.css : docsrc/vlfeat.css
cp -fv "$<" "$@"
doc/pygmentize.css : docsrc/pygmentize.css
cp -fv "$<" "$@"
# build: this is the last step integrating all documentation
doc/index.html: $(webdoc_src) $(doc-dir) \
doc/api/index.html \
doc/build/matlab/mdoc.html \
doc/build/man/xman.xml \
doc/build/man/xman.html \
doc/build/matlab/demo.xml \
docsrc/webdoc.py \
$(html_src)
cp doc/api/index.html doc/api/index.html.bak
VERSION=$(VER) $(PYTHON) docsrc/webdoc.py \
--outdir=doc \
--verbose \
--indexfile=doc/index.txt \
--doxytag=doc/doxygen.tag \
--doxydir=api \
docsrc/vlfeat-website.xml
mv doc/api/index.html.bak doc/api/index.html
rsync -r docsrc/images doc/
# --------------------------------------------------------------------
# Maintenance and others
# --------------------------------------------------------------------
.PHONY: doc-clean, doc-archclean, doc-distclean
no_dep_targets += doc-clean doc-archclean doc-distclean
VERSION: vl/generic.h
echo "$(VER)" > VERSION
doc-clean:
rm -rf doc/build
doc-archclean:
doc-distclean:
rm -f docsrc/*.pyc
rm -rf doc
rm -rf toolbox/doc
# --------------------------------------------------------------------
# Debug Makefile
# --------------------------------------------------------------------
.PHONY: doc-info
doc-info :
$(call echo-title,Documentation)
$(call dump-var,man_src)
$(call dump-var,fig_src)
$(call dump-var,demo_src)
$(call dump-var,pdf_tgt)
$(call dump-var,eps_tgt)
$(call dump-var,png_tgt)
$(call dump-var,jpg_tgt)
$(call dump-var,man_tgt)
$(call dump-var,DOXYGEN)
@echo
# --------------------------------------------------------------------
# Xcode Support
# --------------------------------------------------------------------
.PHONY: dox-
dox- : dox
.PHONY: dox-clean
dox-clean:
# Local variables:
# mode: Makefile
# End: