aboutsummaryrefslogtreecommitdiffhomepage
path: root/Makefile.doc
blob: 4670c79eced11f9672c2a107ac5a129cbae86867 (plain)
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
##########################################################################
##         #   The Coq Proof Assistant / The Coq Development Team       ##
##  v      #   INRIA, CNRS and contributors - Copyright 1999-2018       ##
## <O___,, #       (see CREDITS file for the list of authors)           ##
##   \VV/  ###############################################################
##    //   #    This file is distributed under the terms of the         ##
##         #     GNU Lesser General Public License Version 2.1          ##
##         #     (see LICENSE file for the text of the license)         ##
##########################################################################

# Makefile for the Coq documentation

# Read INSTALL.doc to learn about the dependencies

# The main entry point :

documentation: doc-$(WITHDOC)  ## see $(WITHDOC) in config/Makefile
doc-all: doc
doc-no:

.PHONY: documentation doc-all doc-no

######################################################################
### Variables
######################################################################

LATEX:=latex
MAKEINDEX:=makeindex
PDFLATEX:=pdflatex
DVIPS:=dvips
HTMLSTYLE:=coqremote

# Sphinx-related variables
SPHINXOPTS= -j4
SPHINXBUILD= sphinx-build
SPHINXBUILDDIR= doc/sphinx/_build

# Internal variables.
ALLSPHINXOPTS= -d $(SPHINXBUILDDIR)/doctrees $(SPHINXOPTS)

DOCCOMMON:=doc/common/version.tex doc/common/title.tex doc/common/macros.tex

######################################################################
### General rules
######################################################################

.PHONY: doc doc-html doc-pdf doc-ps
.PHONY: stdlib full-stdlib

doc: sphinx stdlib

ifndef QUICK
SPHINX_DEPS := coq
endif

sphinx: $(SPHINX_DEPS)
	$(SHOW)'SPHINXBUILD doc/sphinx'
	$(HIDE)COQBIN="$(abspath bin)" $(SPHINXBUILD) -W -b html $(ALLSPHINXOPTS) doc/sphinx $(SPHINXBUILDDIR)/html
	@echo
	@echo "Build finished. The HTML pages are in $(SPHINXBUILDDIR)/html."

doc-html:\
  doc/stdlib/html/index.html sphinx

doc-pdf:\
  doc/stdlib/Library.pdf

doc-ps:\
  doc/stdlib/Library.ps

stdlib: \
  doc/stdlib/html/index.html doc/stdlib/Library.ps doc/stdlib/Library.pdf

full-stdlib: \
  doc/stdlib/html/index.html doc/stdlib/FullLibrary.ps doc/stdlib/FullLibrary.pdf

######################################################################
### Implicit rules
######################################################################

%.ps: %.dvi
	(cd `dirname $<`; $(DVIPS) -q -o `basename $@` `basename $<`)

######################################################################
# Common
######################################################################

### Version

doc/common/version.tex: config/Makefile
	printf '\\newcommand{\\coqversion}{$(VERSION)}' > doc/common/version.tex

######################################################################
# Standard library
######################################################################

### Standard library (browsable html format)

ifdef QUICK
doc/stdlib/html/genindex.html:
else
doc/stdlib/html/genindex.html: | $(COQDOC) $(ALLVO)
endif
	- rm -rf doc/stdlib/html
	$(MKDIR) doc/stdlib/html
	$(COQDOC) -q -d doc/stdlib/html --with-header doc/common/styles/html/$(HTMLSTYLE)/header.html --with-footer doc/common/styles/html/$(HTMLSTYLE)/footer.html --multi-index --html -g \
	  -R theories Coq -R plugins Coq $(VFILES)
	mv doc/stdlib/html/index.html doc/stdlib/html/genindex.html

doc/stdlib/index-list.html: doc/stdlib/index-list.html.template doc/stdlib/make-library-index
	./doc/stdlib/make-library-index doc/stdlib/index-list.html doc/stdlib/hidden-files

doc/stdlib/html/index.html: doc/stdlib/html/genindex.html doc/stdlib/index-list.html
	cat doc/common/styles/html/$(HTMLSTYLE)/header.html doc/stdlib/index-list.html > $@
	cat doc/common/styles/html/$(HTMLSTYLE)/footer.html >> $@

### Standard library (light version, full version is definitely too big)

ifdef QUICK
doc/stdlib/Library.coqdoc.tex:
else
doc/stdlib/Library.coqdoc.tex: | $(COQDOC) $(THEORIESLIGHTVO)
endif
	$(COQDOC) -q -boot --gallina --body-only --latex --stdout \
            -R theories Coq $(THEORIESLIGHTVO:.vo=.v) >> $@

doc/stdlib/Library.dvi: $(DOCCOMMON) doc/stdlib/Library.coqdoc.tex doc/stdlib/Library.tex
	(cd doc/stdlib;\
	$(LATEX) -interaction=batchmode Library;\
	$(LATEX) -interaction=batchmode Library > /dev/null;\
	../tools/show_latex_messages -no-overfull Library.log)

doc/stdlib/Library.pdf: $(DOCCOMMON) doc/stdlib/Library.coqdoc.tex doc/stdlib/Library.dvi
	(cd doc/stdlib;\
	$(PDFLATEX) -interaction=batchmode Library;\
	../tools/show_latex_messages -no-overfull Library.log)

### Standard library (full version if you're crazy enouth to try)

doc/stdlib/FullLibrary.tex: doc/stdlib/Library.tex
	sed -e 's/Library.coqdoc/FullLibrary.coqdoc/g;s/\\begin{document}/\\newcommand{\\textlambda}{\\ensuremath{\\lambda}}\\newcommand{\\textPi}{\\ensuremath{\\Pi}}\\begin{document}/' $< > $@

ifdef QUICK
doc/stdlib/FullLibrary.coqdoc.tex:
	$(COQDOC) -q -boot --gallina --body-only --latex --stdout --utf8 \
            -R theories Coq -R plugins Coq $(VFILES) > $@
	sed -i.tmp -e 's///g' $@ && rm $@.tmp
else
doc/stdlib/FullLibrary.coqdoc.tex: $(COQDOC) $(ALLVO)
	$(COQDOC) -q -boot --gallina --body-only --latex --stdout --utf8 \
            -R theories Coq -R plugins Coq $(VFILES) > $@
	sed -i.tmp -e 's///g' $@ && rm $@.tmp
endif

doc/stdlib/FullLibrary.dvi: $(DOCCOMMON) doc/stdlib/FullLibrary.coqdoc.tex doc/stdlib/FullLibrary.tex
	(cd doc/stdlib;\
	$(LATEX) -interaction=batchmode FullLibrary;\
	$(LATEX) -interaction=batchmode FullLibrary > /dev/null;\
	../tools/show_latex_messages -no-overfull FullLibrary.log)

doc/stdlib/FullLibrary.pdf: $(DOCCOMMON) doc/stdlib/FullLibrary.coqdoc.tex doc/stdlib/FullLibrary.dvi
	(cd doc/stdlib;\
	$(PDFLATEX) -interaction=batchmode FullLibrary;\
	../tools/show_latex_messages -no-overfull FullLibrary.log)

######################################################################
# Install all documentation files
######################################################################

.PHONY: install-doc install-doc-meta install-doc-html install-doc-printable \
	install-doc-sphinx install-doc-stdlib-html

install-doc: install-doc-meta install-doc-html install-doc-printable

install-doc-meta:
	$(MKDIR) $(FULLDOCDIR)
	$(INSTALLLIB) doc/LICENSE $(FULLDOCDIR)/LICENSE.doc

install-doc-html: install-doc-stdlib-html install-doc-sphinx

install-doc-stdlib-html:
	$(MKDIR) $(FULLDOCDIR)/html/stdlib
	$(INSTALLLIB) doc/stdlib/html/* $(FULLDOCDIR)/html/stdlib

install-doc-printable: 
	$(MKDIR) $(FULLDOCDIR)/ps $(FULLDOCDIR)/pdf
	$(INSTALLLIB) doc/stdlib/Library.pdf $(FULLDOCDIR)/pdf
	$(INSTALLLIB) doc/stdlib/Library.ps $(FULLDOCDIR)/ps

install-doc-sphinx:
	$(MKDIR) $(FULLDOCDIR)/sphinx
	(for f in `cd doc/sphinx/_build; find . -type f`; do \
		$(MKDIR) $$(dirname $(FULLDOCDIR)/sphinx/$$f);\
		$(INSTALLLIB) doc/sphinx/_build/$$f $(FULLDOCDIR)/sphinx/$$f;\
	done)

###########################################################################
# Documentation of the source code (using ocamldoc)
###########################################################################

OCAMLDOCDIR=dev/ocamldoc

DOCMLLIBS= $(CORECMA:.cma=_MLLIB_DEPENDENCIES) $(PLUGINSCMO:.cmo=_MLPACK_DEPENDENCIES)
DOCMLS=$(foreach lib,$(DOCMLLIBS),$(addsuffix .ml, $($(lib))))

DOCMLIS=$(wildcard $(addsuffix /*.mli, $(SRCDIRS)))

# Defining options to generate dependencies graphs
DOT=dot
ODOCDOTOPTS=-dot -dot-reduce

.PHONY: source-doc mli-doc ml-doc

source-doc: mli-doc $(OCAMLDOCDIR)/coq.pdf

$(OCAMLDOCDIR)/coq.tex: $(DOCMLIS:.mli=.cmi)
	$(SHOW)'OCAMLDOC -latex -o $@'
	$(HIDE)$(OCAMLFIND) ocamldoc -latex -rectypes -I $(MYCAMLP5LIB) $(MLINCLUDES)\
	$(DOCMLIS) -noheader -t "Coq mlis documentation" \
	-intro $(OCAMLDOCDIR)/docintro -o $@.tmp
	$(SHOW)'OCAMLDOC utf8 fix'
	$(HIDE)$(OCAMLDOCDIR)/fix-ocamldoc-utf8 $@.tmp
	$(HIDE)cat $(OCAMLDOCDIR)/header.tex $@.tmp > $@
	rm $@.tmp

mli-doc: $(DOCMLIS:.mli=.cmi)
	$(SHOW)'OCAMLDOC -html'
	$(HIDE)$(OCAMLFIND) ocamldoc -charset utf-8 -html -rectypes -I +threads -I $(MYCAMLP5LIB) $(MLINCLUDES) \
	$(DOCMLIS) -d $(OCAMLDOCDIR)/html -colorize-code \
	-t "Coq mlis documentation" -intro $(OCAMLDOCDIR)/docintro \
	-css-style style.css

ml-dot: $(MLFILES)
	$(OCAMLFIND) ocamldoc -dot -dot-reduce -rectypes -I +threads -I $(CAMLLIB) -I $(MYCAMLP5LIB) $(MLINCLUDES) \
	$(filter $(addsuffix /%.ml,$(CORESRCDIRS)),$(MLFILES)) -o $(OCAMLDOCDIR)/coq.dot

%_dep.png: %.dot
	$(DOT) -Tpng $< -o $@

%_types.dot: %.mli
	$(OCAMLFIND) ocamldoc -rectypes $(MLINCLUDES) $(ODOCDOTOPTS) -dot-types -o $@ $<

OCAMLDOC_MLLIBD = $(OCAMLFIND) ocamldoc -rectypes $(MLINCLUDES) $(ODOCDOTOPTS) -o $@ \
  $(foreach lib,$(|:.mllib.d=_MLLIB_DEPENDENCIES),$(addsuffix .ml,$($(lib))))

%.dot: | %.mllib.d
	$(OCAMLDOC_MLLIBD)

ml-doc:
	$(SHOW)'OCAMLDOC -html'
	$(HIDE)mkdir -p $(OCAMLDOCDIR)/html/implementation
	$(HIDE)$(OCAMLFIND) ocamldoc -charset utf-8 -html -rectypes -I +threads $(MLINCLUDES) $(COQIDEFLAGS) \
	$(DOCMLS) -d $(OCAMLDOCDIR)/html/implementation -colorize-code \
	-t "Coq mls documentation" \
	-css-style ../style.css

parsing/parsing.dot : | parsing/parsing.mllib.d
	$(OCAMLDOC_MLLIBD)

grammar/grammar.dot : | grammar/grammar.mllib.d
	$(OCAMLDOC_MLLIBD)

tactics/tactics.dot: | tactics/tactics.mllib.d ltac/ltac.mllib.d
	$(OCAMLDOC_MLLIBD)

%.dot: %.mli
	$(OCAMLFIND) ocamldoc -rectypes $(MLINCLUDES) $(ODOCDOTOPTS) -o $@ $<

$(OCAMLDOCDIR)/%.pdf: $(OCAMLDOCDIR)/%.tex
	$(SHOW)'PDFLATEX $*.tex'
	$(HIDE)(cd $(OCAMLDOCDIR) ; pdflatex -interaction=batchmode $*.tex && pdflatex -interaction=batchmode $*.tex)
	$(HIDE)(cd doc/tools/; ./show_latex_messages -no-overfull ../../$(OCAMLDOCDIR)/$*.log)

# For emacs:
# Local Variables:
# mode: makefile
# End: