Makefile 1.9 KB
Newer Older
Ralf Jung's avatar
Ralf Jung committed
1
# Forward most targets to Coq makefile (with some trick to make this phony)
2
%: Makefile.coq phony
3
	+@make -f Makefile.coq $@
4

5
all: Makefile.coq
6
	+@make -f Makefile.coq all
Ralf Jung's avatar
Ralf Jung committed
7
.PHONY: all
8 9

clean: Makefile.coq
10
	+@make -f Makefile.coq clean
Ralf Jung's avatar
Ralf Jung committed
11
	find theories $$(test -d tests && echo tests) \( -name "*.d" -o -name "*.vo" -o -name "*.aux" -o -name "*.cache" -o -name "*.glob" -o -name "*.vio" \) -print -delete
12
	rm -f Makefile.coq
Ralf Jung's avatar
Ralf Jung committed
13
.PHONY: clean
14

15
# Create Coq Makefile.
Ralf Jung's avatar
Ralf Jung committed
16
Makefile.coq: _CoqProject Makefile
17
	"$(COQBIN)coq_makefile" -f _CoqProject -o Makefile.coq
18

Ralf Jung's avatar
Ralf Jung committed
19
# Install build-dependencies
Ralf Jung's avatar
Ralf Jung committed
20
build-dep/opam: opam Makefile
21
	@echo "# Creating build-dep package."
Ralf Jung's avatar
Ralf Jung committed
22
	@mkdir -p build-dep
Ralf Jung's avatar
Ralf Jung committed
23
	@sed <opam -E 's/^(build|install|remove):.*/\1: []/; s/^name: *"(.*)" */name: "\1-builddep"/' >build-dep/opam
Ralf Jung's avatar
Ralf Jung committed
24 25 26
	@fgrep builddep build-dep/opam >/dev/null || (echo "sed failed to fix the package name" && exit 1) # sanity check

build-dep: build-dep/opam phony
27 28 29 30 31
	@# We want opam to not just instal the build-deps now, but to also keep satisfying these
	@# 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.
32 33
	@# Reinstalling is needed with opam 1 in case the pin already exists, but the builddep
	@# package changed.
Ralf Jung's avatar
Ralf Jung committed
34
	@BUILD_DEP_PACKAGE="$$(egrep "^name:" build-dep/opam | sed 's/^name: *"\(.*\)" */\1/')" && \
Ralf Jung's avatar
Ralf Jung committed
35
	  echo "# Pinning build-dep package." && \
36
	  opam pin add -k path $(OPAMFLAGS) "$$BUILD_DEP_PACKAGE".dev build-dep && \
Ralf Jung's avatar
Ralf Jung committed
37
	  ((! opam --version | grep "^1\." > /dev/null) || ( \
38 39
	    echo "# Reinstalling build-dep package." && \
	    opam reinstall $(OPAMFLAGS) "$$BUILD_DEP_PACKAGE" \
Ralf Jung's avatar
Ralf Jung committed
40
	  ))
41

Ralf Jung's avatar
typo  
Ralf Jung committed
42
# Some files that do *not* need to be forwarded to Makefile.coq
43
Makefile: ;
Ralf Jung's avatar
Ralf Jung committed
44
_CoqProject: ;
Ralf Jung's avatar
Ralf Jung committed
45
opam: ;
46

Ralf Jung's avatar
Ralf Jung committed
47
# Phony wildcard targets
48
phony: ;
Ralf Jung's avatar
Ralf Jung committed
49
.PHONY: phony