Makefile 1.93 KB
Newer Older
Ralf Jung's avatar
Ralf Jung committed
1 2 3 4 5 6 7 8 9 10
# 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
.PHONY: all

clean: Makefile.coq
	+@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
Ralf Jung's avatar
Ralf Jung committed
12 13 14
	rm -f Makefile.coq
.PHONY: clean

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

# Install build-dependencies
build-dep/opam: opam Makefile
Ralf Jung's avatar
Ralf Jung committed
21
	@echo "# Creating build-dep package."
Ralf Jung's avatar
Ralf Jung committed
22 23 24 25 26 27 28 29 30 31
	@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
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 36
	  echo "# Pinning build-dep package." && \
	  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) || ( \
Ralf Jung's avatar
Ralf Jung committed
38 39
	    echo "# Reinstalling build-dep package." && \
	    opam reinstall $(OPAMFLAGS) "$$BUILD_DEP_PACKAGE" \
Ralf Jung's avatar
Ralf Jung committed
40
	  ))
Ralf Jung's avatar
Ralf Jung committed
41 42 43 44 45 46 47 48 49 50

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

# Phony wildcard targets
phony: ;
.PHONY: phony