Skip to content
Snippets Groups Projects
Makefile 1.93 KiB
Newer Older
# 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
.PHONY: all

clean: Makefile.coq
	+@make -f Makefile.coq clean
Ralf Jung's avatar
Ralf Jung committed
	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
	rm -f Makefile.coq
Ralf Jung's avatar
Ralf Jung committed
.PHONY: clean
# Create Coq Makefile.
Makefile.coq: _CoqProject Makefile awk.Makefile
Ralf Jung's avatar
Ralf Jung committed
	"$(COQBIN)coq_makefile" -f _CoqProject -o Makefile.coq

# Install build-dependencies
Ralf Jung's avatar
Ralf Jung committed
build-dep/opam: opam Makefile
Ralf Jung's avatar
Ralf Jung committed
	@echo "# Creating build-dep package."
Ralf Jung's avatar
Ralf Jung committed
	@mkdir -p build-dep
Ralf Jung's avatar
Ralf Jung committed
	@sed <opam -E 's/^(build|install|remove):.*/\1: []/; s/^name: *"(.*)" */name: "\1-builddep"/' >build-dep/opam
Ralf Jung's avatar
Ralf Jung committed
	@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
	@# 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
	@# Reinstalling is needed with opam 1 in case the pin already exists, but the builddep
	@# package changed.
Ralf Jung's avatar
Ralf Jung committed
	@BUILD_DEP_PACKAGE="$$(egrep "^name:" build-dep/opam | sed 's/^name: *"\(.*\)" */\1/')" && \
	  echo "# Pinning build-dep package." && \
Ralf Jung's avatar
Ralf Jung committed
	  opam pin add -k path $(OPAMFLAGS) "$$BUILD_DEP_PACKAGE".dev build-dep && \
Ralf Jung's avatar
Ralf Jung committed
	  ((! opam --version | grep "^1\." > /dev/null) || ( \
	    echo "# Reinstalling build-dep package." && \
	    opam reinstall $(OPAMFLAGS) "$$BUILD_DEP_PACKAGE" \
	  ))

# Some files that do *not* need to be forwarded to Makefile.coq
Makefile: ;
_CoqProject: ;
awk.Makefile: ;
Ralf Jung's avatar
Ralf Jung committed
opam: ;
Ralf Jung's avatar
Ralf Jung committed
# Phony wildcard targets
phony: ;
Ralf Jung's avatar
Ralf Jung committed
.PHONY: phony