diff options
Diffstat (limited to 'Makefile')
| -rw-r--r-- | Makefile | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..ac8dba0 --- /dev/null +++ b/Makefile | |||
| @@ -0,0 +1,55 @@ | |||
| 1 | # Default target | ||
| 2 | all: Makefile.coq | ||
| 3 | +@$(MAKE) -f Makefile.coq all | ||
| 4 | .PHONY: all | ||
| 5 | |||
| 6 | # Permit local customization | ||
| 7 | -include Makefile.local | ||
| 8 | |||
| 9 | # Forward most targets to Coq makefile (with some trick to make this phony) | ||
| 10 | %: Makefile.coq phony | ||
| 11 | @#echo "Forwarding $@" | ||
| 12 | +@$(MAKE) -f Makefile.coq $@ | ||
| 13 | phony: ; | ||
| 14 | .PHONY: phony | ||
| 15 | |||
| 16 | clean: Makefile.coq | ||
| 17 | +@$(MAKE) -f Makefile.coq clean | ||
| 18 | @# Make sure not to enter the `_opam` folder. | ||
| 19 | find [a-z]*/ \( -name "*.d" -o -name "*.vo" -o -name "*.vo[sk]" -o -name "*.aux" -o -name "*.cache" -o -name "*.glob" -o -name "*.vio" \) -print -delete || true | ||
| 20 | rm -f Makefile.coq .lia.cache builddep/* | ||
| 21 | .PHONY: clean | ||
| 22 | |||
| 23 | # Create Coq Makefile. | ||
| 24 | Makefile.coq: _CoqProject Makefile | ||
| 25 | "$(COQBIN)coq_makefile" -f _CoqProject -o Makefile.coq $(EXTRA_COQFILES) | ||
| 26 | |||
| 27 | # Install build-dependencies | ||
| 28 | OPAMFILES=$(wildcard *.opam) | ||
| 29 | BUILDDEPFILES=$(addsuffix -builddep.opam, $(addprefix builddep/,$(basename $(OPAMFILES)))) | ||
| 30 | |||
| 31 | builddep/%-builddep.opam: %.opam Makefile | ||
| 32 | @echo "# Creating builddep package for $<." | ||
| 33 | @mkdir -p builddep | ||
| 34 | @sed <$< -E 's/^(build|install|remove):.*/\1: []/; s/"(.*)"(.*= *version.*)$$/"\1-builddep"\2/;' >$@ | ||
| 35 | |||
| 36 | builddep-opamfiles: $(BUILDDEPFILES) | ||
| 37 | .PHONY: builddep-opamfiles | ||
| 38 | |||
| 39 | builddep: builddep-opamfiles | ||
| 40 | @# We want opam to not just install the build-deps now, but to also keep satisfying these | ||
| 41 | @# constraints. Otherwise, `opam upgrade` may well update some packages to versions | ||
| 42 | @# that are incompatible with our build requirements. | ||
| 43 | @# To achieve this, we create a fake opam package that has our build-dependencies as | ||
| 44 | @# dependencies, but does not actually install anything itself. | ||
| 45 | @echo "# Installing builddep packages." | ||
| 46 | @opam install $(OPAMFLAGS) $(BUILDDEPFILES) | ||
| 47 | .PHONY: builddep | ||
| 48 | |||
| 49 | # Backwards compatibility target | ||
| 50 | build-dep: builddep | ||
| 51 | .PHONY: build-dep | ||
| 52 | |||
| 53 | # Some files that do *not* need to be forwarded to Makefile.coq. | ||
| 54 | # ("::" lets Makefile.local overwrite this.) | ||
| 55 | Makefile Makefile.local _CoqProject $(OPAMFILES):: ; | ||