Makes make clean, make distclean and make dataclean faster if Makefile.config exists but configure is newer.
After 1st target being *clean, any non-*clean targets may follow it -- these are built in sub-make -- and when control returns to main make, it just recognizes targers already made. --- smoke-tested. goal vs. target terminology is hard always Makefile | 15 +++++++++++++++ Makefile.local | 27 ++++++++++++++++++++------- 2 files changed, 35 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index 0ef57fa..7540903 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 clean distclean dataclean, $(wordlist 2, 99, $(MAKECMDGOALS))),) +$(error With "$(word 1, $(MAKECMDGOALS))" no further *clean targets works) +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..e33af45 100644 --- a/Makefile.local +++ b/Makefile.local @@ -198,18 +198,31 @@ quiet ?= $($(shell echo $1 | sed -e s'/ .*//')) @mkdir -p $(patsubst %/.,%,.deps/$(@D)) $(call quiet,CC $(CPPFLAGS) $(CFLAGS)) -c $(FINAL_CFLAGS) $< -o $@ -MD -MP -MF .deps/$*.d -.PHONY : clean -clean: - rm -rf $(CLEAN); rm -rf .deps +.PHONY: _clean +_clean: + rm -rf $(CLEAN) + rm -rf .deps -.PHONY: distclean -distclean: clean +.PHONY: _distclean +_distclean: _clean rm -rf $(DISTCLEAN) -.PHONY: dataclean -dataclean: distclean +.PHONY: _dataclean +_dataclean: _distclean rm -rf $(DATACLEAN) +clean: _clean +distclean: _distclean +dataclean: _dataclean + +ifeq ($(WITH_CLEAN),yes) +ifneq ($(word 2, $(MAKECMDGOALS)),) +clean distclean dataclean: goals_after_clean +goals_after_clean: + $(MAKE) $(wordlist 2, 99, $(MAKECMDGOALS)) configure_options=$(configure_options) +endif +endif + notmuch_client_srcs = \ command-line-arguments.c\ debugger.c \ -- 2.9.3 _______________________________________________ notmuch mailing list notmuch@notmuchmail.org https://notmuchmail.org/mailman/listinfo/notmuch