Makefile 1.97 KB
Newer Older
Robbert Krebbers's avatar
Robbert Krebbers committed
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
Ralf Jung's avatar
Ralf Jung committed
7
.PHONY: all
Robbert Krebbers's avatar
Robbert Krebbers committed
8 9 10 11 12

clean: Makefile.coq
	+@make -f Makefile.coq clean
	find theories \( -name "*.v.d" -o -name "*.vo" -o -name "*.aux" -o -name "*.cache" -o -name "*.glob" -o -name "*.vio" \) -print -delete
	rm -f Makefile.coq
Ralf Jung's avatar
Ralf Jung committed
13
.PHONY: clean
Robbert Krebbers's avatar
Robbert Krebbers 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.
Robbert Krebbers's avatar
Robbert Krebbers committed
17
Makefile.coq: _CoqProject Makefile awk.Makefile
Ralf Jung's avatar
Ralf Jung committed
18
	coq_makefile -f _CoqProject -o Makefile.coq
Robbert Krebbers's avatar
Robbert Krebbers committed
19 20 21
	mv Makefile.coq Makefile.coq.tmp && awk -f awk.Makefile Makefile.coq.tmp > Makefile.coq && rm Makefile.coq.tmp

# Install build-dependencies
Ralf Jung's avatar
Ralf Jung committed
22
build-dep/opam: opam
Ralf Jung's avatar
Ralf Jung committed
23 24 25 26 27 28
	# Create the build-dep package.
	@mkdir -p build-dep
	@sed <opam '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
Ralf Jung's avatar
Ralf Jung committed
29 30 31 32 33
	@# 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
	# Add the pin and (re)install build-dep package.
Ralf Jung's avatar
Ralf Jung committed
35 36
	@# Reinstallation is needed in case the pin already exists, but the builddep package changed.
	@BUILD_DEP_PACKAGE="$$(egrep "^name:" build-dep/opam | sed 's/^name: *"\(.*\)" */\1/')"; \
Ralf Jung's avatar
Ralf Jung committed
37
	  opam pin add "$$BUILD_DEP_PACKAGE".dev "$$(pwd)/build-dep" -k path $(OPAMFLAGS) && \
Ralf Jung's avatar
Ralf Jung committed
38
	  opam reinstall "$$BUILD_DEP_PACKAGE"
Robbert Krebbers's avatar
Robbert Krebbers committed
39 40 41 42 43

# Some files that do *not* need to be forwarded to Makefile.coq
Makefile: ;
_CoqProject: ;
awk.Makefile: ;
Ralf Jung's avatar
Ralf Jung committed
44
opam: ;
Robbert Krebbers's avatar
Robbert Krebbers committed
45

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