aboutsummaryrefslogtreecommitdiff
path: root/Makefile.dune
blob: b77e78db69267c1ab66b949e6859e2f5ae587fb3 (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
127
128
129
130
131
132
133
# -*- mode: makefile -*-
# Dune Makefile for Coq

.PHONY: help voboot states world watch check          # Main developer targets
.PHONY: coq coqide coqide-server                      # Package targets
.PHONY: quickbyte quickopt quickide                   # Partial / quick developer targets
.PHONY: refman-html refman-pdf stdlib-html apidoc     # Documentation targets
.PHONY: test-suite release                            # Accessory targets
.PHONY: fmt ocheck ireport clean                      # Maintenance targets

# use DUNEOPT=--display=short for a more verbose build
# DUNEOPT=--display=short

BOOT_DIR=_build_boot
BOOT_CONTEXT=$(BOOT_DIR)/default

help:
	@echo "Welcome to Coq's Dune-based build system. Targets are:"
	@echo ""
	@echo "  - states: build a minimal functional coqtop"
	@echo "  - world:  build all binaries and libraries"
	@echo "  - watch:  build all binaries and libraries [continuous build]"
	@echo "  - check:  build all ML files as fast as possible"
	@echo ""
	@echo "  - coq: build package Coq [toplevel compilers, tools, stdlib, no GTK]"
	@echo "  - coqide-server: build package coqide-server [XML protocol language server]"
	@echo "  - coqide: build package CoqIDE [gtk application]"
	@echo ""
	@echo "  - quickbyte: build main ML files [coqtop + plugins + ide + printers] using the bytecode compiler"
	@echo "  - quickopt:  build main ML files [coqtop + plugins + ide + printers] using the optimizing compiler"
	@echo "  - quickide:  build main IDE files [client + server + prelude] using the optimizing compiler"
	@echo ""
	@echo "  - test-suite:  run Coq's test suite"
	@echo "  - refman-html: build Coq's reference manual [HTML version]"
	@echo "  - refman-pdf:  build Coq's reference manual [PDF version]"
	@echo "  - stdlib-html: build Coq's Stdlib documentation [HTML version]"
	@echo "  - apidoc:      build ML API documentation"
	@echo "  - release:     build Coq in release mode"
	@echo ""
	@echo "  - fmt:     run ocamlformat on the codebase"
	@echo "  - ocheck:  build for all supported OCaml versions [requires OPAM]"
	@echo "  - ireport: build with optimized flambda settings and emit an inline report"
	@echo "  - clean:   remove build directory and autogenerated files"
	@echo "  - help:    show this message"

# We need to bootstrap with a dummy coq.plugins.ltac so install targets do work.
plugins/ltac/dune:
	@echo "(library (name ltac_plugin) (public_name coq.plugins.ltac) (modules_without_implementation extraargs extratactics))" > plugins/ltac/dune

voboot: plugins/ltac/dune
	dune build --build-dir=$(BOOT_DIR) $(DUNEOPT) @vodeps
	dune exec --build-dir=$(BOOT_DIR) -- ./tools/coq_dune.exe $(BOOT_CONTEXT)/.vfiles.d

states: voboot
	dune build --display=short $(DUNEOPT) dev/shim/coqtop-prelude

NONDOC_INSTALL_TARGETS:=coq.install coqide-server.install coqide.install

world: voboot
	dune build $(DUNEOPT) $(NONDOC_INSTALL_TARGETS)

coq: voboot
	dune build $(DUNEOPT) coq.install

coqide: voboot
	dune build $(DUNEOPT) coqide.install

coqide-server: voboot
	dune build $(DUNEOPT) coqide-server.install

watch: voboot
	dune build $(DUNEOPT) $(NONDOC_INSTALL_TARGETS) -w

check: voboot
	dune build $(DUNEOPT) @check

COQTOP_FILES=ide/idetop.bc ide/coqide_main.bc checker/coqchk.bc
PLUGIN_FILES=$(wildcard plugins/*/*.mlpack)
PRINTER_FILES=dev/top_printers.cma
QUICKBYTE_TARGETS=$(COQTOP_FILES) $(PLUGIN_FILES:.mlpack=.cma) $(PRINTER_FILES) topbin/coqtop_byte_bin.bc
QUICKOPT_TARGETS=$(COQTOP_FILES:.bc=.exe) $(PLUGIN_FILES:.mlpack=.cmxs) $(PRINTER_FILES:.cma=.cmxa) topbin/coqtop_bin.exe

quickbyte: voboot
	dune build $(DUNEOPT) $(QUICKBYTE_TARGETS)

quickopt: voboot
	dune build $(DUNEOPT) $(QUICKOPT_TARGETS)

quickide: states
	dune build $(DUNEOPT) dev/shim/coqide-prelude

test-suite: voboot
	dune runtest --no-buffer $(DUNEOPT)

refman-html: voboot
	dune build @refman-html

refman-pdf: voboot
	dune build @refman-pdf

stdlib-html: voboot
	dune build @stdlib-html

apidoc: voboot
	dune build $(DUNEOPT) @doc

release: voboot
	dune build $(DUNEOPT) -p coq

fmt: voboot
	dune build @fmt --auto-promote

ocheck: voboot
	dune build $(DUNEOPT) @install --workspace=dev/dune-workspace.all

ireport:
	dune clean
	dune build --build-dir=$(BOOT_DIR) $(DUNEOPT) @vodeps
	dune exec --build-dir=$(BOOT_DIR) -- ./tools/coq_dune.exe $(BOOT_CONTEXT)/.vfiles.d
	dune build $(DUNEOPT) @install --profile=ireport

clean:
	dune clean

# Other common dev targets:
#
# dune build coq.install
# dune build coqide.install
#
# Packaging / OPAM targets:
#
# dune -p coq @install
# dune -p coqide @install