Makefile 2.1 KB
Newer Older
1 2 3 4 5 6
# Forward most targets to Coq makefile (with some trick to make this phony)
%: Makefile.coq phony
	+@make -f Makefile.coq $@

all: Makefile.coq
	+@make -f Makefile.coq all
7
.PHONY: all
8 9 10

clean: Makefile.coq
	+@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
12
	rm -f Makefile.coq
13
.PHONY: clean
14

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.
17
Makefile.coq: _CoqProject Makefile awk.Makefile
18 19 20 21 22
	"$(COQBIN)coq_makefile" -f _CoqProject -o Makefile.coq
	mv Makefile.coq Makefile.coq.tmp && awk -f awk.Makefile Makefile.coq.tmp > Makefile.coq && rm Makefile.coq.tmp

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

# Some files that do *not* need to be forwarded to Makefile.coq
Makefile: ;
_CoqProject: ;
awk.Makefile: ;
46
opam: ;
47

48
# Phony wildcard targets
49
phony: ;
50
.PHONY: phony