Debian Codegraph @

Makefile

raw symbols SCIP
1 ##########################################################################
2 ## # The Rocq Prover / The Rocq Development Team ##
3 ## v # Copyright INRIA, CNRS and contributors ##
4 ## <O___,, # (see version control and CREDITS file for authors & dates) ##
5 ## \VV/ ###############################################################
6 ## // # This file is distributed under the terms of the ##
7 ## # GNU Lesser General Public License Version 2.1 ##
8 ## # (see LICENSE file for the text of the license) ##
9 ##########################################################################
10
11 # Dune Makefile for Rocq
12
13 .PHONY: help help-install states world rocqide watch check # Main developer targets
14 .PHONY: refman-html refman-pdf corelib-html apidoc # Documentation targets
15 .PHONY: test-suite dev-targets
16 .PHONY: fmt ocheck obuild ireport clean # Maintenance targets
17 .PHONY: dunestrap release install # Miscellaneous
18
19 # We don't allow parallel build here, this is just a placehoder for
20 # dune commands for the most part
21 .NOTPARALLEL:
22
23 ###########################################################################
24 # The SHOW and HIDE variables control whether make will echo complete commands
25 # or only abbreviated versions.
26 # Quiet mode is ON by default except if VERBOSE=1 option is given to make
27 # Used only by targets which don't go through dune (eg doc_gram_rsts)
28
29 VERBOSE ?=
30 SHOW := $(if $(VERBOSE),@true "",@echo "")
31 HIDE := $(if $(VERBOSE),,@)
32
33 # use DUNEOPT=--display=short for a more verbose build
34 # DUNEOPT=--display=short
35
36 help:
37 @echo ""
38 @echo "Welcome to Rocq's Dune-based build system. If you are final user type"
39 @echo "make help-install for installation instructions. Common developer targets are:"
40 @echo ""
41 @echo " - states: build a minimal functional rocq repl"
42 @echo " - world: build main public binaries and libraries in developer mode (no rocqide)"
43 @echo " - watch: build main public binaries and libraries [continuous build]"
44 @echo " - rocqide: build rocqide binary in developer mode"
45 @echo " - check: build all ML files as fast as possible"
46 @echo " - test-suite: run Rocq's test suite [env NJOBS=N to set job parallelism]"
47 @echo " - dunestrap: Generate the dune rules for vo files"
48 @echo ""
49 @echo " Note: running ./configure is not recommended for developers,"
50 @echo " see dev/doc/build-system.dune.md for more info"
51 @echo " Note: these targets produce a developer build, not suitable"
52 @echo " for distribution to end-users or install"
53 @echo ""
54 @echo " To run rocq:"
55 @echo ""
56 @echo " - use 'dune exec -- rocq \$$subcommand args'"
57 @echo " Example: 'dune exec -- rocq compile file.v'"
58 @echo ""
59 @echo " Documentation targets:"
60 @echo ""
61 @echo " - refman-html: build Rocq's reference manual [HTML version]"
62 @echo " - refman-pdf: build Rocq's reference manual [PDF version]"
63 @echo " - corelib-html: build Rocq's Corelib documentation [HTML version]"
64 @echo " - apidoc: build ML API documentation"
65 @echo ""
66 @echo " Miscellaneous targets:"
67 @echo ""
68 @echo " - fmt: run ocamlformat on the codebase"
69 @echo " - ocheck: check for a selection of supported OCaml versions [requires OPAM]"
70 @echo " - obuild: build for a selection of supported OCaml versions [requires OPAM]"
71 @echo " - ireport: build with optimized flambda settings and emit an inline report"
72 @echo " - clean: remove build directory and autogenerated files"
73 @echo " - help: show this message"
74 @echo ""
75 @echo " Type 'make help-install' for installation instructions"
76 @echo " Type 'make dev-targets' for more developer targets"
77
78 dev-targets:
79 @echo ""
80 @echo "In order to get a functional Rocq install layout, the world target is required."
81 @echo "However, This is often inconvenient for developers, due to the large amount of"
82 @echo "files that world will build. We provide some useful subtargets here:"
83 @echo ""
84 @echo " - theories-foo: for each directory theories/Corelib/Foo, build the vo files for it and set them up in _build/install/default."
85 @echo " For instance the init target builds the prelude, combined with rocq-runtime.install it produces a fully functional layout in _build/install/default."
86
87 help-install:
88 @echo ""
89 @echo "The Dune-based Rocq build is split into several packages; see Dune and dev/doc"
90 @echo "documentation for more details. A quick install of Rocq alone can be done with"
91 @echo ""
92 @echo " $$ make dunestrap"
93 @echo " $$ dune build -p rocq-runtime,coq-core,rocq-core"
94 @echo " $$ dune install --prefix=<install_prefix> rocq-runtime coq-core rocq-core"
95 @echo ""
96 @echo " Provided opam/dune packages are:"
97 @echo ""
98 @echo " - rocq-runtime: base Rocq package, toplevel compilers, plugins, tools, no corelib, no stdlib, no GTK"
99 @echo " - coq-core: compat binaries (coqc instead of rocq compile, etc)"
100 @echo " - rocq-core: Rocq's prelude and corelib"
101 @echo " - coqide-server: XML protocol language server"
102 @echo " - rocqide: RocqIDE gtk application"
103 @echo ""
104 @echo " To build a package, you can use:"
105 @echo ""
106 @echo " - 'dune build package.install' : build package in developer mode"
107 @echo " - 'dune build -p package' : build package in release mode"
108 @echo ""
109 @echo " Packages _must_ be installed only if built using release mode, to install a package use: "
110 @echo ""
111 @echo " - 'dune install --prefix=<install_prefix> package'"
112 @echo ""
113 @echo " Note that '--prefix' must be passed to dune install. The '-prefix' passed to"
114 @echo " configure tells Rocq where to look for libraries."
115 @echo ""
116 @echo " Note that building a package in release mode ignores other packages present in"
117 @echo " the worktree. See Dune documentation for more information."
118
119 # We setup the root even in dev mode, to avoid some problems. We used
120 # this in the past to workaround a bug in opam, but the bug was that
121 # we didn't pass `-p` to the dune build below.
122 #
123 # This would be fixed once dune can directly use `(include
124 # theories_dune)` in our files.
125 DUNESTRAPOPT=--root .
126
127 # We regenerate always as to correctly track deps, can do better
128 # We do a single call to dune as to avoid races and locking
129 ifneq ($(COQ_SPLIT),) # avoid depending on local rocq-runtime
130 _build/default/corelib_dune_split _build/default/ltac2_dune_split .dune-stamp: FORCE
131 dune build $(DUNEOPT) $(DUNESTRAPOPT) corelib_dune_split ltac2_dune_split
132 touch .dune-stamp
133
134 theories/Corelib/dune: .dune-stamp
135 cp -a _build/default/corelib_dune_split $@ && chmod +w $@
136
137 theories/Ltac2/dune: .dune-stamp
138 cp -a _build/default/ltac2_dune_split $@ && chmod +w $@
139 else
140 _build/default/corelib_dune _build/default/ltac2_dune .dune-stamp: FORCE
141 dune build $(DUNEOPT) $(DUNESTRAPOPT) corelib_dune ltac2_dune
142 touch .dune-stamp
143
144 theories/Corelib/dune: .dune-stamp
145 cp -a _build/default/corelib_dune $@ && chmod +w $@
146
147 theories/Ltac2/dune: .dune-stamp
148 cp -a _build/default/ltac2_dune $@ && chmod +w $@
149 endif
150
151 FORCE: ;
152
153 DUNE_FILES=theories/Corelib/dune theories/Ltac2/dune
154
155 dunestrap: $(DUNE_FILES)
156
157 states: world
158 echo "'make states' is an alias for 'make world'"
159
160 MAIN_TARGETS:=rocq-runtime.install coq-core.install rocq-core.install \
161 coqide-server.install rocq-devtools.install
162
163 world: dunestrap
164 dune build $(DUNEOPT) $(MAIN_TARGETS)
165
166 rocqide:
167 dune build $(DUNEOPT) rocqide.install
168
169 watch:
170 dune build $(DUNEOPT) $(MAIN_TARGETS) -w
171
172 check:
173 dune build $(DUNEOPT) @check
174
175 test-suite: dunestrap
176 dune runtest --no-buffer $(DUNEOPT)
177
178 refman-html: dunestrap
179 dune build --no-buffer @refman-html
180
181 refman-pdf: dunestrap
182 dune build --no-buffer @refman-pdf
183
184 corelib-html: dunestrap
185 dune build @corelib-html
186
187 apidoc:
188 dune build $(DUNEOPT) @doc
189
190 # We define this target as to override Make's built-in one
191 install:
192 @echo "To install Rocq using dune, use 'dune build -p P && dune install P'"
193 @echo "where P is any of the packages defined by opam files in the root dir"
194 @false
195
196 fmt:
197 dune build @fmt --auto-promote
198
199 ocheck:
200 dune build $(DUNEOPT) @check --workspace=dev/dune-workspace.all
201
202 obuild: dunestrap
203 dune build $(DUNEOPT) @default --workspace=dev/dune-workspace.all
204
205 ireport:
206 dune clean
207 dune build $(DUNEOPT) @install --profile=ireport
208
209 clean:
210 rm -f .dune-stamp theories/Corelib/dune theories/Ltac2/dune
211 dune clean
212
213 # docgram
214
215 DOC_GRAM:=_build/default/doc/tools/docgram/doc_grammar.exe
216
217 # not worth figuring out dependencies, just leave it to dune
218 .PHONY: $(DOC_GRAM)
219 $(DOC_GRAM):
220 dune build $(DUNEOPT) $@
221
222 include doc/Makefile.docgram
223
224 # This requires a install layout to be available.
225
226 CONTEXT=_build/install/default
227
228 # XXX: Port this to a dune alias so the build is hygienic!
229 .PHONY: plugin-tutorial
230 plugin-tutorial: world
231 $(MAKE) OCAMLPATH=$(shell pwd)/$(CONTEXT)/lib/ COQBIN="$(shell pwd)/$(CONTEXT)/bin/" -C doc/plugin_tutorial
232
233 # This is broken in a very weird way with a permission error... see
234 # the rule in doc/plugin_tutorial/dune:
235
236 # plugin-tutorial: dunestrap
237 # dune build @plugin-tutorial
238
239 # ci-* targets
240
241 CI_PURE_DUNE:=1
242 export CI_PURE_DUNE
243 include Makefile.ci
244
245 # Custom targets to create subsets of the world target but with less
246 # compiled files. This is desired when we want to have our Rocq Dune
247 # build with Rocq developments that are not dunerized and thus still
248 # expect an install layout with a working Rocq setup, but smaller than
249 # world.
250 #
251 # Unfortunately, Dune still lacks the capability to refer to install
252 # targets in rules, see https://github.com/ocaml/dune/issues/3192 ;
253 # thus we can't simply yet use `%{pkg:coq:theories/Corelib/Arith/Arith.vo` to
254 # have the rule install the target, we thus imitate such behavior
255 # using make as a helper.
256
257 # $(1) is the directory (theories/Corelib/Foo/)
258 # $(2) is the name (foo)
259 define subtarget =
260 .PHONY: theories-$(2)
261
262 $(2)_FILES=$$(wildcard $(1)*.v)
263 $(2)_FILES_PATH=$$(addprefix _build/install/default/lib/coq/, $$($(2)_FILES:.v=.vo))
264
265 theories-$(2):
266 @echo "DUNE $(1)*.vo"
267 @dune build $$($(2)_FILES_PATH)
268 endef
269
270 $(foreach subdir,$(wildcard theories/Corelib/*/),$(eval $(call subtarget,$(subdir),$(shell echo $(subst /,,$(subst theories/Corelib/,,$(subdir))) | tr A-Z a-z))))
271
272 # Other common dev targets:
273 #
274 # dune build rocq-runtime.install
275 # dune build coq.install
276 # dune build rocqide.install
277 #
278 # Packaging / OPAM targets:
279 #
280 # dune -p coq @install
281 # dune -p rocqide @install