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

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

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

Ralf Jung's avatar
Ralf Jung committed
15 16
# Create Coq Makefile. POSIX awk can't do in-place editing, but coq_makefile wants the real
# filename, so we do some file gymnastics.
Ralf Jung's avatar
Ralf Jung committed
17
Makefile.coq: _CoqProject Makefile awk.Makefile
Ralf Jung's avatar
Ralf Jung committed
18
	"$(COQBIN)coq_makefile" -f _CoqProject -o Makefile.coq
Ralf Jung's avatar
Ralf Jung committed
19
	mv Makefile.coq Makefile.coq.tmp && awk -f awk.Makefile Makefile.coq.tmp > Makefile.coq && rm Makefile.coq.tmp
Ralf Jung's avatar
Ralf Jung committed
20 21

# Install build-dependencies
Ralf Jung's avatar
Ralf Jung committed
22
build-dep/opam: opam Makefile
Ralf Jung's avatar
Ralf Jung committed
23
	# Creating the build-dep package.
Ralf Jung's avatar
Ralf Jung committed
24
	@mkdir -p build-dep
Ralf Jung's avatar
Ralf Jung committed
25
	@sed <opam -E 's/^(build|install|remove):.*/\1: []/; s/^name: *"(.*)" */name: "\1-builddep"/' >build-dep/opam
Ralf Jung's avatar
Ralf Jung committed
26 27 28 29 30 31 32 33
	@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
	@# 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.
Ralf Jung's avatar
Ralf Jung committed
34
	@# Upgrading is needed in case the pin already exists, but the builddep package changed.
Ralf Jung's avatar
Ralf Jung committed
35
	@BUILD_DEP_PACKAGE="$$(egrep "^name:" build-dep/opam | sed 's/^name: *"\(.*\)" */\1/')"; \
Ralf Jung's avatar
Ralf Jung committed
36 37 38 39
	  echo "# Pinning build-dep package." && \
	  opam pin add -k path $(OPAMFLAGS) "$$BUILD_DEP_PACKAGE".dev build-dep && \
	  echo "# Updating build-dep package." && \
	  opam upgrade "$$BUILD_DEP_PACKAGE"
Ralf Jung's avatar
Ralf Jung committed
40

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

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