Makefile 1.97 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 3
%: Makefile.coq phony
	+@make -f Makefile.coq $@
Zhen Zhang's avatar
Zhen Zhang committed
4 5

all: Makefile.coq
6
	+@make -f Makefile.coq all
7
.PHONY: all
Zhen Zhang's avatar
Zhen Zhang committed
8 9

clean: Makefile.coq
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
Zhen Zhang's avatar
Zhen Zhang committed
12
	rm -f Makefile.coq
13
.PHONY: clean
Zhen Zhang's avatar
Zhen Zhang committed
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
Ralf Jung's avatar
Ralf Jung committed
18
	coq_makefile -f _CoqProject -o Makefile.coq
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
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
build-dep/opam: opam
	# 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
	@# 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.
	# Add the pin and (re)install build-dep package.
	@# 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/')"; \
	  opam pin add "$$BUILD_DEP_PACKAGE".dev "$$(pwd)/build-dep" -k path $(OPAMFLAGS) && \
	  opam reinstall "$$BUILD_DEP_PACKAGE"
Ralf Jung's avatar
Ralf Jung committed
39

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

46
# Phony wildcard targets
47
phony: ;
48
.PHONY: phony