[RFC PATCH 2] opportunistic support for make {, dist, data}clean {all, test, install}

Tomi Ollila tomi.ollila at iki.fi
Mon Jan 9 12:06:44 PST 2017


Makes make clean, make distclean and make dataclean faster if
Makefile.config exists but configure is newer.

Makes any combination of make {,dist,data}clean {all,test,install}
work (probably, some ad-hoc hand testing done).
---

Well, could not resist the temptation to dig further...

This may be as fragile as out-of-tree build, but should
not make the status quo worse.


Makefile                  | 15 +++++++++++++++
 Makefile.local            | 14 ++++++++++++--
 completion/Makefile.local |  2 +-
 emacs/Makefile.local      |  6 +++---
 lib/Makefile.local        |  2 +-
 test/Makefile.local       |  5 +++++
 6 files changed, 37 insertions(+), 7 deletions(-)

diff --git a/Makefile b/Makefile
index 0ef57fa..874a5ae 100644
--- a/Makefile
+++ b/Makefile
@@ -22,7 +22,22 @@ include Makefile.config
 global_deps = Makefile Makefile.config Makefile.local \
 	$(subdirs:%=%/Makefile) $(subdirs:%=%/Makefile.local)
 
+ifneq ($(filter clean distclean dataclean, $(word 1, $(MAKECMDGOALS))),)
+ifneq ($(filter-out all test install, $(wordlist 2, 99, $(MAKECMDGOALS))),)
+$(error With "$(word 1, $(MAKECMDGOALS))" only "all", "test" and "install" may work)
+endif
+WITH_CLEAN := yes
+else
+WITH_CLEAN := no
+endif
+
+# Potentially speedup make clean, distclean and dataclean ; avoid
+# re-creation of Makefile.config if it exists but configure is newer.
+ifeq ($(WITH_CLEAN),yes)
+Makefile.config: | $(srcdir)/configure
+else
 Makefile.config: $(srcdir)/configure
+endif
 ifeq ($(configure_options),)
 	@echo ""
 	@echo "Note: Calling ./configure with no command-line arguments. This is often fine,"
diff --git a/Makefile.local b/Makefile.local
index 3548ed9..a9e831a 100644
--- a/Makefile.local
+++ b/Makefile.local
@@ -1,7 +1,11 @@
 # -*- makefile -*-
 
 .PHONY: all
-all: notmuch notmuch-shared build-man ruby-bindings
+ifeq ($(WITH_CLEAN),yes)
+all:
+	$(MAKE) $@ configure_options=$(configure_options)
+else
+all: _all notmuch notmuch-shared build-man ruby-bindings
 ifeq ($(MAKECMDGOALS),)
 ifeq ($(shell cat .first-build-message 2>/dev/null),)
 	@NOTMUCH_FIRST_BUILD=1 $(MAKE) --no-print-directory all
@@ -16,6 +20,7 @@ ifeq ($(shell cat .first-build-message 2>/dev/null),)
 	@echo Printed > .first-build-message
 endif
 endif
+endif
 
 # Depend (also) on the file 'version'. In case of ifeq ($(IS_GIT),yes)
 # this file may already have been updated.
@@ -249,7 +254,11 @@ notmuch-shared: $(notmuch_client_modules) lib/$(LINKER_NAME)
 	$(call quiet,$(FINAL_NOTMUCH_LINKER) $(CFLAGS)) $(notmuch_client_modules) $(FINAL_NOTMUCH_LDFLAGS) -o $@
 
 .PHONY: install
-install: all install-man
+ifeq ($(WITH_CLEAN),yes)
+install:
+	$(MAKE) $@ configure_options=$(configure_options)
+else
+install: _install all install-man
 	mkdir -p "$(DESTDIR)$(prefix)/bin/"
 	install notmuch-shared "$(DESTDIR)$(prefix)/bin/notmuch"
 ifeq ($(MAKECMDGOALS), install)
@@ -273,6 +282,7 @@ ifeq ($(WITH_EMACS), 1)
 	@echo "the command \"M-x notmuch\" from within emacs."
 endif
 endif
+endif
 
 SRCS  := $(SRCS) $(notmuch_client_srcs)
 CLEAN := $(CLEAN) notmuch notmuch-shared $(notmuch_client_modules)
diff --git a/completion/Makefile.local b/completion/Makefile.local
index dfc1271..e0a1893 100644
--- a/completion/Makefile.local
+++ b/completion/Makefile.local
@@ -8,7 +8,7 @@ dir := completion
 bash_script := $(srcdir)/$(dir)/notmuch-completion.bash
 zsh_script := $(srcdir)/$(dir)/notmuch-completion.zsh
 
-install: install-$(dir)
+_install: install-$(dir)
 
 install-$(dir):
 	@echo $@
diff --git a/emacs/Makefile.local b/emacs/Makefile.local
index 040e64d..e6a2b1b 100644
--- a/emacs/Makefile.local
+++ b/emacs/Makefile.local
@@ -35,7 +35,7 @@ $(dir)/notmuch-pkg.el: $(srcdir)/$(dir)/notmuch-pkg.el.tmpl
 	@sed -e 's/%AG%/Generated file (from $(<F)) -- do not edit!/' \
 	     -e 's/%VERSION%/"$(ELPA_VERSION)"/' $< > $@
 
-all: $(dir)/notmuch-pkg.el
+_all: $(dir)/notmuch-pkg.el
 install-emacs: $(dir)/notmuch-pkg.el
 
 emacs_mua := $(dir)/notmuch-emacs-mua
@@ -88,11 +88,11 @@ notmuch-emacs-%.tar: ${elpa_sources}
 
 ifeq ($(WITH_EMACS),1)
 ifeq ($(HAVE_EMACS),1)
-all: $(emacs_bytecode)
+_all: $(emacs_bytecode)
 install-emacs: $(emacs_bytecode)
 endif
 
-install: install-emacs
+_install: install-emacs
 endif
 
 .PHONY: install-emacs
diff --git a/lib/Makefile.local b/lib/Makefile.local
index b77e578..479c60c 100644
--- a/lib/Makefile.local
+++ b/lib/Makefile.local
@@ -71,7 +71,7 @@ $(dir)/$(SONAME): $(dir)/$(LIBNAME)
 $(dir)/$(LINKER_NAME): $(dir)/$(SONAME)
 	ln -sf $(LIBNAME) $@
 
-install: install-$(dir)
+_install: install-$(dir)
 
 install-$(dir): $(dir)/$(LIBNAME)
 	mkdir -p "$(DESTDIR)$(libdir)/"
diff --git a/test/Makefile.local b/test/Makefile.local
index f8cf90d..fbb395f 100644
--- a/test/Makefile.local
+++ b/test/Makefile.local
@@ -59,6 +59,10 @@ TEST_BINARIES := $(TEST_BINARIES:.cc=)
 
 test-binaries: $(TEST_BINARIES)
 
+ifeq ($(WITH_CLEAN),yes)
+test:
+	$(MAKE) $@ configure_options=$(configure_options)
+else
 test:	all test-binaries
 ifeq ($V,)
 	@echo 'Use "$(MAKE) V=1" to print test headings and PASSing results.'
@@ -71,6 +75,7 @@ else
 	@${test_src_dir}/notmuch-test $(OPTIONS)
 endif
 endif
+endif
 
 check: test
 
-- 
2.9.3



More information about the notmuch mailing list