Makefile 1.89 KB
Newer Older
Ralf Jung's avatar
Ralf Jung committed
1
2
3
4
5
# Default target
all: Makefile.coq
	+@$(MAKE) -f Makefile.coq all
.PHONY: all

Ralf Jung's avatar
Ralf Jung committed
6
7
8
# Permit local customization
-include Makefile.local

Hai Dang's avatar
Hai Dang committed
9
10
# Forward most targets to Coq makefile (with some trick to make this phony)
%: Makefile.coq phony
Ralf Jung's avatar
Ralf Jung committed
11
12
13
14
	@#echo "Forwarding $@"
	+@$(MAKE) -f Makefile.coq $@
phony: ;
.PHONY: phony
Hai Dang's avatar
Hai Dang committed
15
16

clean: Makefile.coq
Ralf Jung's avatar
Ralf Jung committed
17
18
19
20
	+@$(MAKE) -f Makefile.coq clean
	@# Make sure not to enter the `_opam` folder.
	find [a-z]*/ \( -name "*.d" -o -name "*.vo" -o -name "*.vo[sk]" -o -name "*.aux" -o -name "*.cache" -o -name "*.glob" -o -name "*.vio" \) -print -delete || true
	rm -f Makefile.coq .lia.cache builddep/*
Hai Dang's avatar
Hai Dang committed
21
22
23
24
.PHONY: clean

# Create Coq Makefile.
Makefile.coq: _CoqProject Makefile
Ralf Jung's avatar
Ralf Jung committed
25
	"$(COQBIN)coq_makefile" -f _CoqProject -o Makefile.coq $(EXTRA_COQFILES)
Hai Dang's avatar
Hai Dang committed
26
27

# Install build-dependencies
Ralf Jung's avatar
Ralf Jung committed
28
29
30
31
32
33
34
35
36
37
38
39
40
OPAMFILES=$(wildcard *.opam)
BUILDDEPFILES=$(addsuffix -builddep.opam, $(addprefix builddep/,$(basename $(OPAMFILES))))

builddep/%-builddep.opam: %.opam Makefile
	@echo "# Creating builddep package for $<."
	@mkdir -p builddep
	@sed <$< -E 's/^(build|install|remove):.*/\1: []/; s/"(.*)"(.*= *version.*)$$/"\1-builddep"\2/;' >$@

builddep-opamfiles: $(BUILDDEPFILES)
.PHONY: builddep-opamfiles

builddep: builddep-opamfiles
	@# We want opam to not just install the build-deps now, but to also keep satisfying these
Hai Dang's avatar
Hai Dang committed
41
42
43
44
	@# constraints.  Otherwise, `opam upgrade` may well update some packages to versions
	@# that are incompatible with our build requirements.
	@# To achieve this, we create a fake opam package that has our build-dependencies as
	@# dependencies, but does not actually install anything itself.
Ralf Jung's avatar
Ralf Jung committed
45
46
47
	@echo "# Installing builddep packages."
	@opam install $(OPAMFLAGS) $(BUILDDEPFILES)
.PHONY: builddep
Hai Dang's avatar
Hai Dang committed
48

Ralf Jung's avatar
Ralf Jung committed
49
50
51
# Backwards compatibility target
build-dep: builddep
.PHONY: build-dep
Hai Dang's avatar
Hai Dang committed
52

Ralf Jung's avatar
Ralf Jung committed
53
54
55
# Some files that do *not* need to be forwarded to Makefile.coq.
# ("::" lets Makefile.local overwrite this.)
Makefile Makefile.local _CoqProject $(OPAMFILES):: ;