From 4199c23da311e612cb1ae45cf5519b5f3947c3b3 Mon Sep 17 00:00:00 2001 From: Cyril Cohen Date: Tue, 31 Jul 2018 10:37:25 +0200 Subject: Rework the whole Makefile architecture - Cleanup, refactoring and generalize the makefile architecture - Reuses @strub math-comp/analysis Makefile / Makefile.common organization - As #174, this fixes #88, but looks more stable than trying to fix the use of the MAKEFLAGS internal variable --- mathcomp/Makefile.common | 78 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 mathcomp/Makefile.common (limited to 'mathcomp/Makefile.common') diff --git a/mathcomp/Makefile.common b/mathcomp/Makefile.common new file mode 100644 index 0000000..b07b78d --- /dev/null +++ b/mathcomp/Makefile.common @@ -0,0 +1,78 @@ +# -*- Makefile -*- + +ifeq "$(COQBIN)" "" +COQBIN=$(dir $(shell which coqtop))/ +endif +ifeq "$(COQMAKEFILE)" "" +COQMAKEFILE=$(COQBIN)coq_makefile +endif +COQDEP=$(COQBIN)coqdep + +ifeq "$(COQPROJECT)" "" +COQPROJECT="_CoqProject" +endif + +# -------------------------------------------------------------------- +.PHONY: all config build clean distclean __always__ +.SUFFIXES: + +TOP = $(dir $(lastword $(MAKEFILE_LIST))) +COQMAKE = $(MAKE) -f Makefile.coq $(COQMAKEOPTIONS) + +# -------------------------------------------------------------------- +all: config build + +# -------------------------------------------------------------------- +Makefile.coq: Makefile $(BEFOREMAKEFILE) + $(COQMAKEFILE) $(COQMAKEFILEOPTIONS) -f $(COQPROJECT) -o Makefile.coq + +# -------------------------------------------------------------------- +config: sub-config this-config Makefile.coq + +build: sub-build this-build + +clean: sub-clean this-clean + +distclean: sub-distclean this-distclean + +# -------------------------------------------------------------------- +.PHONY: this-config this-build this-distclean this-clean + +this-build:: + +$(COQMAKE) + +this-distclean:: this-clean + rm -f Makefile.coq Makefile.coq.conf + +this-clean:: + @if [ -f Makefile.coq ]; then $(COQMAKE) cleanall; fi + +# -------------------------------------------------------------------- +.PHONY: install + +install: + $(COQMAKE) install +# -------------------------------------------------------------------- +.PHONY: count + +COQFILES := $(shell grep '.v$$' Make) + +count: + @coqwc $(COQFILES) | tail -1 | \ + awk '{printf ("%d (spec=%d+proof=%d)\n", $$1+$$2, $$1, $$2)}' +# -------------------------------------------------------------------- +this-distclean:: + rm -f $(shell find . -name '*~') + +# -------------------------------------------------------------------- +ifdef SUBDIRS +sub-%: __always__ + @set -e; for d in $(SUBDIRS); do +$(MAKE) -C $$d $(@:sub-%=%); done +else +sub-%: __always__ + @true +endif + +# -------------------------------------------------------------------- +%.vo: __always__ + +$(COQMAKE) $@ -- cgit v1.2.3 From 7d7b0688c818c5dde68d2b2bfc8ba3aecfe017d6 Mon Sep 17 00:00:00 2001 From: Cyril Cohen Date: Tue, 31 Jul 2018 15:20:43 +0200 Subject: removing dead code + reshuffling stuff --- mathcomp/Makefile.common | 39 ++++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 19 deletions(-) (limited to 'mathcomp/Makefile.common') diff --git a/mathcomp/Makefile.common b/mathcomp/Makefile.common index b07b78d..ea3d85c 100644 --- a/mathcomp/Makefile.common +++ b/mathcomp/Makefile.common @@ -1,33 +1,34 @@ # -*- Makefile -*- - -ifeq "$(COQBIN)" "" -COQBIN=$(dir $(shell which coqtop))/ -endif -ifeq "$(COQMAKEFILE)" "" -COQMAKEFILE=$(COQBIN)coq_makefile -endif -COQDEP=$(COQBIN)coqdep - -ifeq "$(COQPROJECT)" "" -COQPROJECT="_CoqProject" -endif +V?= +VERBOSE?=V +H:= $(if $(VERBOSE),,@) +# Options +COQBIN?=$(dir $(shell which coqtop)) +COQMAKEFILE?=$(COQBIN)coq_makefile +COQDEP?=$(COQBIN)coqdep +COQPROJECT?=_CoqProject +COQMAKEOPTIONS?= +COQMAKEFILEOPTIONS?= +BEFOREMAKEFILE?= # -------------------------------------------------------------------- .PHONY: all config build clean distclean __always__ .SUFFIXES: TOP = $(dir $(lastword $(MAKEFILE_LIST))) -COQMAKE = $(MAKE) -f Makefile.coq $(COQMAKEOPTIONS) +COQMAKE = $(MAKE) -f Makefile.this $(COQMAKEOPTIONS) # -------------------------------------------------------------------- all: config build # -------------------------------------------------------------------- -Makefile.coq: Makefile $(BEFOREMAKEFILE) +Makefile.coq: $(BEFOREMAKEFILE) Makefile $(COQMAKEFILE) $(COQMAKEFILEOPTIONS) -f $(COQPROJECT) -o Makefile.coq +Makefile.this: $(BEFOREMAKEFILES) Makefile.coq $(AFTERMAKEFILES) + cat $(BEFOREMAKEFILES) Makefile.coq $(AFTERMAKEFILES) > Makefile.this # -------------------------------------------------------------------- -config: sub-config this-config Makefile.coq +config: sub-config this-config Makefile.this build: sub-build this-build @@ -38,14 +39,14 @@ distclean: sub-distclean this-distclean # -------------------------------------------------------------------- .PHONY: this-config this-build this-distclean this-clean -this-build:: +this-build:: config +$(COQMAKE) -this-distclean:: this-clean - rm -f Makefile.coq Makefile.coq.conf +this-distclean:: this-clean $(OTHERCLEAN) + rm -f Makefile.coq Makefile.coq.conf Makefile.this this-clean:: - @if [ -f Makefile.coq ]; then $(COQMAKE) cleanall; fi + @if [ -f Makefile.this ]; then $(COQMAKE) cleanall; fi # -------------------------------------------------------------------- .PHONY: install -- cgit v1.2.3 From 1a4a4b1cd2407ffd8b76fb544596d1c91ea63a4b Mon Sep 17 00:00:00 2001 From: Cyril Cohen Date: Tue, 31 Jul 2018 15:58:21 +0200 Subject: some things should always be done --- mathcomp/Makefile.common | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'mathcomp/Makefile.common') diff --git a/mathcomp/Makefile.common b/mathcomp/Makefile.common index ea3d85c..557a05b 100644 --- a/mathcomp/Makefile.common +++ b/mathcomp/Makefile.common @@ -27,6 +27,8 @@ Makefile.coq: $(BEFOREMAKEFILE) Makefile Makefile.this: $(BEFOREMAKEFILES) Makefile.coq $(AFTERMAKEFILES) cat $(BEFOREMAKEFILES) Makefile.coq $(AFTERMAKEFILES) > Makefile.this + +__always__: Makefile.this # -------------------------------------------------------------------- config: sub-config this-config Makefile.this @@ -39,7 +41,7 @@ distclean: sub-distclean this-distclean # -------------------------------------------------------------------- .PHONY: this-config this-build this-distclean this-clean -this-build:: config +this-build:: __always__ +$(COQMAKE) this-distclean:: this-clean $(OTHERCLEAN) @@ -51,7 +53,7 @@ this-clean:: # -------------------------------------------------------------------- .PHONY: install -install: +install: __always__ $(COQMAKE) install # -------------------------------------------------------------------- .PHONY: count -- cgit v1.2.3