| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
ROOTDIR = ../.. |
| 18 |
|
| 19 |
include ../Makefile.common |
| 20 |
|
| 21 |
vpath %.cmti ../../stdlib $(DOC_COMPILERLIBS_DIRS) $(DOC_STDLIB_DIRS) |
| 22 |
vpath %.cmt ../../stdlib |
| 23 |
|
| 24 |
ifeq ($(DOCUMENTATION_TOOL),odoc) |
| 25 |
odoc ?= $(DOCUMENTATION_TOOL_CMD) |
| 26 |
else |
| 27 |
odoc ?= odoc |
| 28 |
endif |
| 29 |
|
| 30 |
libref = $(STDLIB) $(otherlibref) |
| 31 |
|
| 32 |
|
| 33 |
define page_name |
| 34 |
$(dir $1)page-$(notdir $1) |
| 35 |
endef |
| 36 |
|
| 37 |
define stdlib_prefix |
| 38 |
$(if $(filter-out stdlib camlinternal%,$1),\ |
| 39 |
Stdlib.$(call capitalize,$1),\ |
| 40 |
$(call capitalize, $1)) |
| 41 |
endef |
| 42 |
|
| 43 |
|
| 44 |
build/latex/ifocamldoc.tex: | build/latex |
| 45 |
$(V_GEN)printf '\\newif\\ifocamldoc\\ocamldocfalse\n' > $@ |
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
stdlib_INPUT= $(foreach module,\ |
| 50 |
$(filter-out stdlib camlinternal%, $(STDLIB:stdlib__%=%)),\ |
| 51 |
\\input{libref/Stdlib.$(call capitalize,$(module)).tex}\ |
| 52 |
) |
| 53 |
|
| 54 |
build/latex/stdlib_input.tex: | build/latex |
| 55 |
$(V_GEN)echo $(stdlib_INPUT)> $@ |
| 56 |
|
| 57 |
build/latex/compilerlibs_input.tex: | build/latex |
| 58 |
$(V_GEN)echo $(compilerlibref_C:%=\\input{compilerlibref/%})> $@ |
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
$(libref_TEXT:%=build/libref/page-%.odoc): |
| 67 |
build/libref/page-%.odoc: build/%.mld | build/libref |
| 68 |
$(V_ODOC)$(odoc) compile -I build/libref --package libref $< -o $@ |
| 69 |
|
| 70 |
$(compilerlibref_TEXT:%=build/compilerlibref/page-%.odoc):\ |
| 71 |
build/compilerlibref/page-%.odoc: build/%.mld | build/compilerlibref |
| 72 |
$(V_ODOC)$(odoc) compile -I build/libref --package compilerlibref $< -o $@ |
| 73 |
|
| 74 |
|
| 75 |
$(libref:%=build/libref/%.odoc):\ |
| 76 |
build/libref/%.odoc: %.cmti | build/libref |
| 77 |
$(V_ODOC)$(odoc) compile -I build/libref --package libref $< -o $@ |
| 78 |
|
| 79 |
|
| 80 |
$(libref_EXTRA:%=build/libref/%.odoc):build/libref/%.odoc:%.cmt |
| 81 |
$(V_ODOC)$(odoc) compile -I build/libref --package libref $< -o $@ |
| 82 |
|
| 83 |
|
| 84 |
$(compilerlibref:%=build/compilerlibref/%.odoc):\ |
| 85 |
build/compilerlibref/%.odoc: %.cmti $(libref:%=build/libref/%.odoc) \ |
| 86 |
| build/compilerlibref |
| 87 |
$(V_ODOC)$(odoc) compile -I build/libref -I build/compilerlibref \ |
| 88 |
--package compilerlibref $< -o $@ |
| 89 |
|
| 90 |
ALL_TEXT = $(libref_TEXT:%=libref/%) $(compilerlibref_TEXT:%=compilerlibref/%) |
| 91 |
ALL_PAGE_TEXT=$(foreach mld,$(ALL_TEXT),$(call page_name,$(mld))) |
| 92 |
TARGET_UNITS= \ |
| 93 |
$(compilerlibref:%=compilerlibref/%) \ |
| 94 |
libref/stdlib $(otherlibref:%=libref/%) \ |
| 95 |
$(addprefix libref/,$(filter camlinternal%,$(STDLIB))) |
| 96 |
ALL_UNITS = $(compilerlibref:%=compilerlibref/%) $(libref:%=libref/%) |
| 97 |
ALL_PAGED_DOC = $(TARGET_UNITS) $(ALL_PAGE_TEXT) |
| 98 |
|
| 99 |
|
| 100 |
|
| 101 |
|
| 102 |
%.odocl:%.odoc \ |
| 103 |
| $(ALL_PAGED_DOC:%=build/%.odoc) |
| 104 |
$(V_ODOC)$(odoc) link -I build/libref -I build/compilerlibref $(ODOC_LINK_ARGS) $< |
| 105 |
|
| 106 |
%.odocl:%.odoc \ |
| 107 |
| $(ALL_PAGED_DOC:%=build/%.odoc) |
| 108 |
$(V_ODOC)$(odoc) link -I build/libref -I build/compilerlibref $(ODOC_LINK_ARGS) $< |
| 109 |
|
| 110 |
build/libref/stdlib.odocl: ODOC_LINK_ARGS+=--open="" |
| 111 |
|
| 112 |
# Rules for all three backends: |
| 113 |
|
| 114 |
ALL_HTML = $(ALL_PAGED_DOC:%=build/%.html.stamp) |
| 115 |
ALL_MAN = $(ALL_PAGED_DOC:%=build/%.3o.stamp) |
| 116 |
ALL_LATEX = $(ALL_PAGED_DOC:%=build/%.tex.stamp) |
| 117 |
|
| 118 |
build/libref/stdlib.html.stamp: $(STDLIB:%=build/libref/%.odocl) | build/libref |
| 119 |
build/libref/stdlib.3o.stamp: $(STDLIB:%=build/libref/%.odocl) | build/libref |
| 120 |
build/libref/stdlib.tex.stamp: $(STDLIB:%=build/libref/%.odocl) | build/libref |
| 121 |
|
| 122 |
man: $(ALL_MAN) |
| 123 |
html: $(ALL_HTML) build/html/odoc.css |
| 124 |
html: build/libref/index.html.stamp build/compilerlibref/index.html.stamp |
| 125 |
|
| 126 |
# Html rules |
| 127 |
$(ALL_HTML): %.html.stamp: %.odocl | build/html |
| 128 |
$(V_ODOC)$(odoc) html-generate --output-dir build/html $< |
| 129 |
touch $@ |
| 130 |
|
| 131 |
build/html/odoc.css: | build/html |
| 132 |
$(V_ODOC)$(odoc) support-files --output-dir build/html |
| 133 |
|
| 134 |
$(build/libref.html.stamp build/compilerlibref.html.stamp): |
| 135 |
%.html.stamp: %.mld | build/ |
| 136 |
$(V_ODOC)$(odoc) html-generate --output-dir build/html $< |
| 137 |
touch $@ |
| 138 |
|
| 139 |
# Html indexes for the api documentation |
| 140 |
|
| 141 |
# The stdlib index is generated from the list of stdlib modules. |
| 142 |
stdlib_INDEX=\ |
| 143 |
$(foreach m,$(stdlib_UNPREFIXED),$(call stdlib_prefix,$m))\ |
| 144 |
$(call capitalize, $(otherlibref)) |
| 145 |
build/libref.mld: |
| 146 |
( echo "{0 OCaml standard library}"; \ |
| 147 |
echo "{!modules:$(stdlib_INDEX)}" ) > $@ |
| 148 |
|
| 149 |
build/libref/index.html.stamp: $(ALL_HTML) build/libref.mld \ |
| 150 |
| build/libref build/html/libref |
| 151 |
$(odoc) compile --package libref build/libref.mld |
| 152 |
$(odoc) link -I build/libref build/page-libref.odoc |
| 153 |
$(odoc) html-generate build/page-libref.odocl --output-dir build/html |
| 154 |
mv build/html/libref/libref.html build/html/libref/index.html |
| 155 |
touch $@ |
| 156 |
|
| 157 |
build/compilerlibref/index.html.stamp: $(ALL_HTML) \ |
| 158 |
build/compilerlibref/page-Compiler_libs.html.stamp | build/html/compilerlibref |
| 159 |
cp build/html/compilerlibref/Compiler_libs.html \ |
| 160 |
build/html/compilerlibref/index.html |
| 161 |
touch $@ |
| 162 |
|
| 163 |
# Latex rules |
| 164 |
|
| 165 |
latex: $(ALL_LATEX) |
| 166 |
|
| 167 |
|
| 168 |
build/latex/alldoc.pdf: $(ALL_LATEX) build/latex/alldoc.tex \ |
| 169 |
build/latex/stdlib_input.tex build/latex/compilerlibs_input.tex \ |
| 170 |
| build/latex |
| 171 |
cd build/latex && pdflatex alldoc.tex |
| 172 |
cd build/latex && pdflatex alldoc.tex |
| 173 |
|
| 174 |
# We include children pages directly except for the root Stdlib module |
| 175 |
NOT_STDLIB=$(filter-out libref/stdlib,$(ALL_PAGED_DOC)) |
| 176 |
$(NOT_STDLIB:%=build/%.tex.stamp):\ |
| 177 |
build/%.tex.stamp: build/%.odocl | build/ |
| 178 |
$(odoc) latex-generate --with-children=true --output-dir build/latex $< |
| 179 |
touch $@ |
| 180 |
|
| 181 |
# Stdlib latex page: we manually integrate stdlib module |
| 182 |
build/libref/stdlib.tex.stamp: build/libref/stdlib.odocl | build/libref |
| 183 |
$(odoc) latex-generate --with-children=false --output-dir build/latex $< |
| 184 |
touch $@ |
| 185 |
|
| 186 |
# Man pages |
| 187 |
$(ALL_PAGED_DOC:%=build/%.3o.stamp):build/%.3o.stamp:build/%.odocl | build/ |
| 188 |
$(odoc) man-generate --output-dir build/man $< |
| 189 |
touch $@ |
| 190 |
|
| 191 |
# Man pages are the only installed documentation |
| 192 |
.PHONY: install |
| 193 |
install: |
| 194 |
$(MKDIR) "$(INSTALL_LIBRARIES_MAN_DIR)" |
| 195 |
if test -d build/man/libref ; then \ |
| 196 |
$(INSTALL_DATA) build/man/libref/* "$(INSTALL_LIBRARIES_MAN_DIR)"; \ |
| 197 |
fi |
| 198 |
if test -d build/man/compilerlibref ; then \ |
| 199 |
$(INSTALL_DATA) build/man/libref/* "$(INSTALL_LIBRARIES_MAN_DIR)"; \ |
| 200 |
fi |
| 201 |
|
| 202 |
# Dependencies for stdlib modules. |
| 203 |
# Use the same dependencies used for compiling .cmx files. |
| 204 |
# The existing rules look like this: |
| 205 |
|
| 206 |
|
| 207 |
# stdlib__X.cmi |
| 208 |
# We want: |
| 209 |
|
| 210 |
|
| 211 |
# stdlib__X.cmti |
| 212 |
build/.depend: ../../stdlib/.depend | build/ |
| 213 |
sed \ |
| 214 |
-e ':l; /\\ *$$/ { N; bl }; # Read lines separated by \\' \ |
| 215 |
-e '/^\S*\.cmx *:/! d; # Keep only rules to .cmx' \ |
| 216 |
-e 's#\<\(\w*\)\.cmx\>#build/libref/\1.odoc#g; # .cmx -> .odoc' \ |
| 217 |
-e 's/\.cmi\>/.cmti/g; # .cmi -> .cmti' \ |
| 218 |
-e 's/\<\S*\.ml\>//g; # .ml -> removed' \ |
| 219 |
$< > $@ |
| 220 |
|
| 221 |
include build/.depend |