From b65228c08b17b361dd97fa24d9677ab165b3638b Mon Sep 17 00:00:00 2001 From: Jason Gross Date: Tue, 19 Jul 2016 10:22:39 -0700 Subject: Add a separate non-specific target This should fix #27. We depend on some files in the etc/coq-scripts submodule. Note that you need to either run `make cleanall -k` or `rm -f Makefile.coq` after pulling this to build the development. --- .gitignore | 1 + Makefile | 43 +++++++++++++++++++++++++++---------------- Makefile.submodule | 35 +++++++++++++++++++++++++++++++++++ 3 files changed, 63 insertions(+), 16 deletions(-) create mode 100644 Makefile.submodule diff --git a/.gitignore b/.gitignore index aeba9e55d..088f0262e 100644 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,7 @@ *~ .#* /.dir-locals.el +/submodule-update Makefile.bak Makefile.coq Makefile.coq.bak diff --git a/Makefile b/Makefile index 6dfe0a04a..2cb9a1a63 100644 --- a/Makefile +++ b/Makefile @@ -1,17 +1,37 @@ MOD_NAME := Crypto SRC_DIR := src +STDTIME?=/usr/bin/time -f "$* (real: %e, user: %U, sys: %S, mem: %M ko)" .PHONY: coq clean update-_CoqProject cleanall install \ - install-coqprime clean-coqprime coqprime + install-coqprime clean-coqprime coqprime \ + specific non-specific .DEFAULT_GOAL := coq -SORT_COQPROJECT = sed 's,[^/]*/,~&,g' | env LC_COLLATE=C sort | sed 's,~,,g' +-include Makefile.submodule + +STRICT_COQDEP ?= 1 + +-include etc/coq-scripts/Makefile.coq.common update-_CoqProject:: - $(Q)(echo '-R $(SRC_DIR) $(MOD_NAME)'; echo '-R Bedrock Bedrock'; (git ls-files 'src/*.v' 'Bedrock/*.v' | $(SORT_COQPROJECT))) > _CoqProject + $(SHOW)'ECHO > _CoqProject' + $(HIDE)(echo '-R $(SRC_DIR) $(MOD_NAME)'; echo '-R Bedrock Bedrock'; (git ls-files 'src/*.v' 'Bedrock/*.v' | $(SORT_COQPROJECT))) > _CoqProject + +clean:: + rm -f submodule-update + +$(VOFILES): | coqprime -coq: coqprime Makefile.coq - $(MAKE) -f Makefile.coq +# add files to this list to prevent them from being built by default +UNMADE_VOFILES := + +COQ_VOFILES := $(filter-out $(UNMADE_VOFILES),$(VOFILES)) +SPECIFIC_VO := $(filter src/Specific/%,$(VOFILES)) +NON_SPECIFIC_VO := $(filter-out $(SPECIFIC_VO),$(VO_FILES)) + +specific: $(SPECIFIC_VO) coqprime +non-specific: $(NON_SPECIFIC_VO) coqprime +coq: $(COQ_VOFILES) coqprime COQ_VERSION_PREFIX = The Coq Proof Assistant, version COQ_VERSION := $(firstword $(subst $(COQ_VERSION_PREFIX),,$(shell $(COQBIN)coqc --version 2>/dev/null))) @@ -31,19 +51,10 @@ clean-coqprime: install-coqprime: $(MAKE) -C $(COQPRIME_FOLDER) install -Makefile.coq: Makefile _CoqProject - $(Q)$(COQBIN)coq_makefile -f _CoqProject -o Makefile.coq - -clean: Makefile.coq - $(MAKE) -f Makefile.coq clean - rm -f Makefile.coq - -cleanall: clean clean-coqprime +cleanall:: clean clean-coqprime rm -f .dir-locals.el -install: coq Makefile.coq - $(MAKE) install-coqprime - $(MAKE) -f Makefile.coq install +install: coq install-coqprime .dir-locals.el:: sed 's:@COQPRIME@:$(COQPRIME_FOLDER):g' .dir-locals.el.in > $@ diff --git a/Makefile.submodule b/Makefile.submodule new file mode 100644 index 000000000..78f301210 --- /dev/null +++ b/Makefile.submodule @@ -0,0 +1,35 @@ +ifneq (,$(wildcard .git)) # if we're in a git repo + +# if the submodule changed, update it +SUBMODULE_DIFF=$(shell git diff etc/coq-scripts 2>&1 | grep 'Subproject commit') +SUBMODULE_DIRTY=$(shell git diff etc/coq-scripts 2>&1 | grep dirty) +ifneq (,$(SUBMODULE_DIRTY)) +submodule-update:: + @ echo "\033[0;31mThe submodule is dirty; some scripts may fail.\033[0m" + @ echo "\033[0;31mRun (cd etc/coq-scripts && git clean -xfd && git reset --hard)\033[0m" +else +ifneq (,$(SUBMODULE_DIFF)) +submodule-update:: + git submodule sync && \ + git submodule update --init && \ + touch "$@" +endif +endif + +ifeq (,$(wildcard submodule-update)) +submodule-update:: + git submodule sync && \ + git submodule update --init && \ + touch "$@" +else +submodule-update:: +endif + +etc/coq-scripts/Makefile.coq.common etc/coq-scripts/compatibility/Makefile.coq.compat_84_85 etc/coq-scripts/compatibility/Makefile.coq.compat_84_85-early: submodule-update + @ touch "$@" +endif + +FAST_TARGETS += clean-doc etc/coq-scripts etc/coq-scripts/Makefile.coq.common etc/coq-scripts/compatibility/Makefile.coq.compat_84_85 etc/coq-scripts/compatibility/Makefile.coq.compat_84_85-early submodule-update +SUPER_FAST_TARGETS += submodule-update + +Makefile.coq: etc/coq-scripts/Makefile.coq.common etc/coq-scripts/compatibility/Makefile.coq.compat_84_85 etc/coq-scripts/compatibility/Makefile.coq.compat_84_85-early -- cgit v1.2.3