| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
.PHONY: help help-install states world rocqide watch check |
| 14 |
.PHONY: refman-html refman-pdf corelib-html apidoc |
| 15 |
.PHONY: test-suite dev-targets |
| 16 |
.PHONY: fmt ocheck obuild ireport clean |
| 17 |
.PHONY: dunestrap release install |
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
.NOTPARALLEL: |
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
VERBOSE ?= |
| 30 |
SHOW := $(if $(VERBOSE),@true "",@echo "") |
| 31 |
HIDE := $(if $(VERBOSE),,@) |
| 32 |
|
| 33 |
|
| 34 |
|
| 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 |
|
| 120 |
|
| 121 |
|
| 122 |
|
| 123 |
|
| 124 |
|
| 125 |
DUNESTRAPOPT=--root . |
| 126 |
|
| 127 |
|
| 128 |
|
| 129 |
ifneq ($(COQ_SPLIT),) |
| 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 |
|
| 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 |
|
| 214 |
|
| 215 |
DOC_GRAM:=_build/default/doc/tools/docgram/doc_grammar.exe |
| 216 |
|
| 217 |
|
| 218 |
.PHONY: $(DOC_GRAM) |
| 219 |
$(DOC_GRAM): |
| 220 |
dune build $(DUNEOPT) $@ |
| 221 |
|
| 222 |
include doc/Makefile.docgram |
| 223 |
|
| 224 |
|
| 225 |
|
| 226 |
CONTEXT=_build/install/default |
| 227 |
|
| 228 |
|
| 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 |
|
| 234 |
|
| 235 |
|
| 236 |
|
| 237 |
|
| 238 |
|
| 239 |
|
| 240 |
|
| 241 |
CI_PURE_DUNE:=1 |
| 242 |
export CI_PURE_DUNE |
| 243 |
include Makefile.ci |
| 244 |
|
| 245 |
|
| 246 |
|
| 247 |
|
| 248 |
|
| 249 |
|
| 250 |
|
| 251 |
|
| 252 |
|
| 253 |
|
| 254 |
|
| 255 |
|
| 256 |
|
| 257 |
|
| 258 |
|
| 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 |
|
| 273 |
|
| 274 |
|
| 275 |
|
| 276 |
|
| 277 |
|
| 278 |
|
| 279 |
|
| 280 |
|
| 281 |
|