Makefile 1.96 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
%: Makefile.coq phony
3
	+@make -f Makefile.coq $@
4

5
all: Makefile.coq
6
	+@make -f Makefile.coq all
7 8

clean: Makefile.coq
9
	+@make -f Makefile.coq clean
10
	find theories \( -name "*.v.d" -o -name "*.vo" -o -name "*.aux" -o -name "*.cache" -o -name "*.glob" -o -name "*.vio" \) -print -delete
11 12
	rm -f Makefile.coq

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

Ralf Jung's avatar
Ralf Jung committed
19
# Install build-dependencies
20 21 22 23 24 25 26
build-dep: 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.
	mkdir -p build-dep
27
	@sed <opam 's/^\(build\|install\|remove\):.*/\1: []/; s/^name: *"\(.*\)" */name: "\1-builddep"/' > build-dep/opam
28
	@fgrep builddep build-dep/opam >/dev/null || (echo "sed failed to fix the package name" && exit 1) # sanity check
29 30 31 32 33
	@# Compute the package name, add the pin and (re)install it.  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" "$$(pwd)/build-dep" -k path $(OPAMFLAGS) && \
	  opam reinstall "$$BUILD_DEP_PACKAGE"
34

Ralf Jung's avatar
typo  
Ralf Jung committed
35
# Some files that do *not* need to be forwarded to Makefile.coq
36
Makefile: ;
Ralf Jung's avatar
Ralf Jung committed
37
_CoqProject: ;
38
awk.Makefile: ;
39

Ralf Jung's avatar
Ralf Jung committed
40
# Phony targets (i.e. targets that should be run no matter the timestamps of the involved files)
41
phony: ;
42
.PHONY: all clean phony