summaryrefslogtreecommitdiff
path: root/api_docgen/ocamldoc/Makefile
blob: 0ad2b080389e26ced17f1fe4bdee6a8a87bb1d16 (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
#**************************************************************************
#*                                                                        *
#*                                 OCaml                                  *
#*                                                                        *
#*             Florian Angeletti, projet Cambium, Inria Paris             *
#*                                                                        *
#*   Copyright 2020 Institut National de Recherche en Informatique et     *
#*     en Automatique.                                                    *
#*                                                                        *
#*   All rights reserved.  This file is distributed under the terms of    *
#*   the GNU Lesser General Public License version 2.1, with the          *
#*   special exception on linking described in the file LICENSE.          *
#*                                                                        *
#**************************************************************************
include $(ROOTDIR)/api_docgen/Makefile.common
include $(ROOTDIR)/ocamldoc/Makefile.best_ocamldoc
vpath %.mli $(ROOTDIR)/stdlib $(DOC_COMPILERLIBS_DIRS)  $(DOC_STDLIB_DIRS)


man: build/man/Stdlib.3o
latex: build/latex/Stdlib.tex
html: \
  build/html/libref/Stdlib.html \
  build/html/compilerlibref/Compiler_libs.html
texi: build/texi/stdlib.texi

DOC_STDLIB_INCLUDES= $(addprefix -I , $(DOC_STDLIB_DIRS))

DOC_ALL_INCLUDES = \
	$(DOC_STDLIB_INCLUDES) \
	$(addprefix -I ,$(DOC_COMPILERLIBS_DIRS))

libref=$(stdlib_UNPREFIXED) $(otherlibref)

ALL_MAN= $(ALL_DOC:%=build/man/%.3o)
ALL_LATEX= $(ALL_DOC:%=build/latex/%.tex)

build/latex/ifocamldoc.tex: | build/latex
	printf '\\newif\ifocamldoc\ocamldoctrue\n' > $@

$(libref:%=build/libref/%.odoc): build/libref/%.odoc: %.mli | build/libref
	$(OCAMLDOC_RUN) -nostdlib -hide Stdlib -lib Stdlib \
	-pp \
"$(AWK) -v ocamldoc=true -f $(ROOTDIR)/stdlib/expand_module_aliases.awk" \
	$(DOC_STDLIB_INCLUDES) $< -dump  $@

$(compilerlibref:%=build/compilerlibref/%.odoc):\
build/compilerlibref/%.odoc: %.mli | build/compilerlibref
	$(OCAMLDOC_RUN) -nostdlib -hide Stdlib \
	$(DOC_ALL_INCLUDES) $< -dump  $@

$(compilerlibref_TEXT:%=build/compilerlibref/%.odoc):\
build/compilerlibref/%.odoc: $(DOCGEN)/build/%.mld | build/compilerlibref
	$(OCAMLDOC_RUN) $(DOC_ALL_INCLUDES) -text $< -dump  $@

$(libref_TEXT:%=build/libref/%.odoc):\
build/libref/%.odoc: $(DOCGEN)/%.mld | build/libref
	$(OCAMLDOC_RUN) $(DOC_STDLIB_INCLUDES) -text $< -dump  $@

ALL_COMPILED_DOC=$(ALL_DOC:%=build/%.odoc)
build/man/Stdlib.3o: $(ALL_COMPILED_DOC) | build/man
	$(OCAMLDOC_RUN) -man -d build/man -man-mini \
	-nostdlib -hide Stdlib -lib Stdlib -t "OCaml library" \
	$(addprefix -load , $(ALL_COMPILED_DOC))

HTML_OPTIONS= -charset="utf8" -colorize-code -nonavbar

build/html/libref/Stdlib.html: $(ALL_LIBREF:%=build/%.odoc) | build/html/libref
	$(OCAMLDOC_RUN) -html -d build/html/libref \
	$(HTML_OPTIONS) \
	-nostdlib -hide Stdlib -lib Stdlib -t "OCaml library" \
	$(addprefix -load , $(ALL_LIBREF:%=build/%.odoc))

build/html/compilerlibref/Compiler_libs.html: \
  $(ALL_COMPILERLIBREF:%=build/%.odoc) | build/html/compilerlibref
	$(OCAMLDOC_RUN) -html -d build/html/compilerlibref \
	-nostdlib -hide Stdlib -t "OCaml compiler library" \
	$(HTML_OPTIONS) \
	-intro $(DOCGEN)/build/Compiler_libs.mld \
	$(addprefix -load , $(ALL_COMPILERLIBREF:%=build/%.odoc))

build/texi/stdlib.texi: $(ALL_COMPILED_DOC) | build/texi
	$(OCAMLDOC_RUN) -texi -o $@ \
	-nostdlib -hide Stdlib -lib Stdlib -t "OCaml library" \
	$(addprefix -load , $(ALL_COMPILED_DOC))

build/latex/Stdlib.tex: $(ALL_COMPILED_DOC) | build/latex
	$(OCAMLDOC_RUN) -latex -o build/latex/all.tex \
	-hide Stdlib -lib Stdlib $(DOC_ALL_INCLUDES) \
	-sepfiles \
	-latextitle "1,subsection*" \
	-latextitle "2,subsubsection*" \
	-latex-type-prefix "TYP" \
	-latex-module-prefix "" \
	-latex-module-type-prefix "" \
	-latex-value-prefix "" \
	-nostdlib -hide Stdlib -lib Stdlib -t "OCaml library" \
	$(addprefix -load , $(ALL_COMPILED_DOC))

build/latex/alldoc.pdf: build/latex/Stdlib.tex build/latex/alldoc.tex \
  | build/latex
	cd build/latex && \
          TEXINPUTS=$${TEXINPUTS}:$(ROOTDIR)/ocamldoc pdflatex alldoc
	cd build/latex && \
	  TEXINPUTS=$${TEXINPUTS}:$(ROOTDIR)/ocamldoc pdflatex alldoc

stdlib_INPUT=$(foreach module,\
$(filter-out stdlib.mli camlinternal%,$(stdlib_UNPREFIXED)),\
\\input{$(call capitalize,$(module)).tex}\
)
build/latex/stdlib_input.tex: | build/latex
	echo $(stdlib_INPUT) > $@

compilerlibs_INPUT=$(foreach module,\
$(filter-out camlinternal%,$(compilerlibref)),\
\\input{$(call capitalize,$(module)).tex})
build/latex/compilerlibs_input.tex: | build/latex
	echo $(compilerlibs_INPUT) > $@

INSTALL_MANODIR=$(INSTALL_MANDIR)/man3
.PHONY:install
install:
	$(MKDIR) "$(INSTALL_MANODIR)"
	if test -d build/man; then \
	  $(INSTALL_DATA) build/man/*.3o "$(INSTALL_MANODIR)"; \
	else : ; fi