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
|
#**************************************************************************
#* *
#* 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. *
#* *
#**************************************************************************
# Used by included Makefiles
ROOTDIR = ../..
include ../Makefile.common
vpath %.cmti ../../stdlib $(DOC_COMPILERLIBS_DIRS) $(DOC_STDLIB_DIRS)
vpath %.cmt ../../stdlib
ifeq ($(DOCUMENTATION_TOOL),odoc)
odoc ?= $(DOCUMENTATION_TOOL_CMD)
else
odoc ?= odoc
endif
libref = $(STDLIB) $(otherlibref)
# odoc needs a "page-" prefix for a mld documentation file
define page_name
$(dir $1)page-$(notdir $1)
endef
define stdlib_prefix
$(if $(filter-out stdlib camlinternal%,$1),\
Stdlib.$(call capitalize,$1),\
$(call capitalize, $1))
endef
# define the right conditional for the manual
build/latex/ifocamldoc.tex: | build/latex
$(V_GEN)printf '\\newif\\ifocamldoc\\ocamldocfalse\n' > $@
# \input{} all modules in the stdlib for the latex api manual
stdlib_INPUT= $(foreach module,\
$(filter-out stdlib camlinternal%, $(STDLIB:stdlib__%=%)),\
\\input{libref/Stdlib.$(call capitalize,$(module)).tex}\
)
build/latex/stdlib_input.tex: | build/latex
$(V_GEN)echo $(stdlib_INPUT)> $@
build/latex/compilerlibs_input.tex: | build/latex
$(V_GEN)echo $(compilerlibref_C:%=\\input{compilerlibref/%})> $@
# The build process for odoc has 3 phases:
# 1. generation of internal individual documentation files (.odoc)
# 2. generation of linked documentation files (.odocl)
# 3. generation of the actual (.tex,.html,.3o) documentation
# rules for the mld files
$(libref_TEXT:%=build/libref/page-%.odoc):
build/libref/page-%.odoc: build/%.mld | build/libref
$(V_ODOC)$(odoc) compile -I build/libref --package libref $< -o $@
$(compilerlibref_TEXT:%=build/compilerlibref/page-%.odoc):\
build/compilerlibref/page-%.odoc: build/%.mld | build/compilerlibref
$(V_ODOC)$(odoc) compile -I build/libref --package compilerlibref $< -o $@
# rules for the stdlib and otherlibs .doc files
$(libref:%=build/libref/%.odoc):\
build/libref/%.odoc: %.cmti | build/libref
$(V_ODOC)$(odoc) compile -I build/libref --package libref $< -o $@
# pervasives is handled separately due to the lack of cmti file
$(libref_EXTRA:%=build/libref/%.odoc):build/libref/%.odoc:%.cmt
$(V_ODOC)$(odoc) compile -I build/libref --package libref $< -o $@
# rules for the compilerlib documentation
$(compilerlibref:%=build/compilerlibref/%.odoc):\
build/compilerlibref/%.odoc: %.cmti $(libref:%=build/libref/%.odoc) \
| build/compilerlibref
$(V_ODOC)$(odoc) compile -I build/libref -I build/compilerlibref \
--package compilerlibref $< -o $@
ALL_TEXT = $(libref_TEXT:%=libref/%) $(compilerlibref_TEXT:%=compilerlibref/%)
ALL_PAGE_TEXT=$(foreach mld,$(ALL_TEXT),$(call page_name,$(mld)))
TARGET_UNITS= \
$(compilerlibref:%=compilerlibref/%) \
libref/stdlib $(otherlibref:%=libref/%) \
$(addprefix libref/,$(filter camlinternal%,$(STDLIB)))
ALL_UNITS = $(compilerlibref:%=compilerlibref/%) $(libref:%=libref/%)
ALL_PAGED_DOC = $(TARGET_UNITS) $(ALL_PAGE_TEXT)
# rules for odocl generation
# Note that we are using a dependency on the whole phase 1 rather than tracking
# the individual file dependencies
%.odocl:%.odoc \
| $(ALL_PAGED_DOC:%=build/%.odoc)
$(V_ODOC)$(odoc) link -I build/libref -I build/compilerlibref $(ODOC_LINK_ARGS) $<
%.odocl:%.odoc \
| $(ALL_PAGED_DOC:%=build/%.odoc)
$(V_ODOC)$(odoc) link -I build/libref -I build/compilerlibref $(ODOC_LINK_ARGS) $<
build/libref/stdlib.odocl: ODOC_LINK_ARGS+=--open=""
# Rules for all three backends:
ALL_HTML = $(ALL_PAGED_DOC:%=build/%.html.stamp)
ALL_MAN = $(ALL_PAGED_DOC:%=build/%.3o.stamp)
ALL_LATEX = $(ALL_PAGED_DOC:%=build/%.tex.stamp)
build/libref/stdlib.html.stamp: $(STDLIB:%=build/libref/%.odocl) | build/libref
build/libref/stdlib.3o.stamp: $(STDLIB:%=build/libref/%.odocl) | build/libref
build/libref/stdlib.tex.stamp: $(STDLIB:%=build/libref/%.odocl) | build/libref
man: $(ALL_MAN)
html: $(ALL_HTML) build/html/odoc.css
html: build/libref/index.html.stamp build/compilerlibref/index.html.stamp
# Html rules
$(ALL_HTML): %.html.stamp: %.odocl | build/html
$(V_ODOC)$(odoc) html-generate --output-dir build/html $<
touch $@
build/html/odoc.css: | build/html
$(V_ODOC)$(odoc) support-files --output-dir build/html
$(build/libref.html.stamp build/compilerlibref.html.stamp):
%.html.stamp: %.mld | build/
$(V_ODOC)$(odoc) html-generate --output-dir build/html $<
touch $@
# Html indexes for the api documentation
# The stdlib index is generated from the list of stdlib modules.
stdlib_INDEX=\
$(foreach m,$(stdlib_UNPREFIXED),$(call stdlib_prefix,$m))\
$(call capitalize, $(otherlibref))
build/libref.mld:
( echo "{0 OCaml standard library}"; \
echo "{!modules:$(stdlib_INDEX)}" ) > $@
build/libref/index.html.stamp: $(ALL_HTML) build/libref.mld \
| build/libref build/html/libref
$(odoc) compile --package libref build/libref.mld
$(odoc) link -I build/libref build/page-libref.odoc
$(odoc) html-generate build/page-libref.odocl --output-dir build/html
mv build/html/libref/libref.html build/html/libref/index.html
touch $@
build/compilerlibref/index.html.stamp: $(ALL_HTML) \
build/compilerlibref/page-Compiler_libs.html.stamp | build/html/compilerlibref
cp build/html/compilerlibref/Compiler_libs.html \
build/html/compilerlibref/index.html
touch $@
# Latex rules
latex: $(ALL_LATEX)
build/latex/alldoc.pdf: $(ALL_LATEX) build/latex/alldoc.tex \
build/latex/stdlib_input.tex build/latex/compilerlibs_input.tex \
| build/latex
cd build/latex && pdflatex alldoc.tex
cd build/latex && pdflatex alldoc.tex
# We include children pages directly except for the root Stdlib module
NOT_STDLIB=$(filter-out libref/stdlib,$(ALL_PAGED_DOC))
$(NOT_STDLIB:%=build/%.tex.stamp):\
build/%.tex.stamp: build/%.odocl | build/
$(odoc) latex-generate --with-children=true --output-dir build/latex $<
touch $@
# Stdlib latex page: we manually integrate stdlib module
build/libref/stdlib.tex.stamp: build/libref/stdlib.odocl | build/libref
$(odoc) latex-generate --with-children=false --output-dir build/latex $<
touch $@
# Man pages
$(ALL_PAGED_DOC:%=build/%.3o.stamp):build/%.3o.stamp:build/%.odocl | build/
$(odoc) man-generate --output-dir build/man $<
touch $@
# Man pages are the only installed documentation
.PHONY: install
install:
$(MKDIR) "$(INSTALL_LIBRARIES_MAN_DIR)"
if test -d build/man/libref ; then \
$(INSTALL_DATA) build/man/libref/* "$(INSTALL_LIBRARIES_MAN_DIR)"; \
fi
if test -d build/man/compilerlibref ; then \
$(INSTALL_DATA) build/man/libref/* "$(INSTALL_LIBRARIES_MAN_DIR)"; \
fi
# Dependencies for stdlib modules.
# Use the same dependencies used for compiling .cmx files.
# The existing rules look like this:
# stdlib__X.cmx: x.ml \
# stdlib__Y.cmx \
# stdlib__X.cmi
# We want:
# build/libref/stdlib__X.odoc: \
# build/libref/stdlib__Y.odoc \
# stdlib__X.cmti
build/.depend: ../../stdlib/.depend | build/
sed \
-e ':l; /\\ *$$/ { N; bl }; # Read lines separated by \\' \
-e '/^\S*\.cmx *:/! d; # Keep only rules to .cmx' \
-e 's#\<\(\w*\)\.cmx\>#build/libref/\1.odoc#g; # .cmx -> .odoc' \
-e 's/\.cmi\>/.cmti/g; # .cmi -> .cmti' \
-e 's/\<\S*\.ml\>//g; # .ml -> removed' \
$< > $@
include build/.depend
|