From 3cef10489ae2e61ef0a14d9b676d0242e4640ccd Mon Sep 17 00:00:00 2001 From: nobu Date: Wed, 1 Mar 2017 07:53:15 +0000 Subject: [PATCH] common.mk: separate clean-ext * common.mk (clean-ext): separate clean-up of makefiles and timestamps, and clean-up of subdirectories under ext and gems. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57748 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- Makefile.in | 53 ++++++++++++++++++++++++++-------------------- common.mk | 23 ++++++++++++++++++-- win32/Makefile.sub | 30 +++++++++++++------------- 3 files changed, 66 insertions(+), 40 deletions(-) diff --git a/Makefile.in b/Makefile.in index 699b25ea50..a2a17039c6 100644 --- a/Makefile.in +++ b/Makefile.in @@ -416,36 +416,43 @@ distclean-local:: -$(Q)$(RM) $(INSTALLED_LIST) $(arch_hdrdir)/ruby/config.h verconf.h -$(Q)$(RMDIRS) $(arch_hdrdir)/ruby 2> /dev/null || true -clean-ext distclean-ext realclean-ext:: - @[ -f $(EXTS_MK) ] && $(MAKE) -f $(EXTS_MK) $(@:-ext=) - @set dummy `echo "${EXTS}" | tr , ' '`; shift; \ +ext/clean.sub gems/clean.sub:: ext/clean.mk +ext/distclean.sub gems/distclean.sub:: ext/distclean.mk +ext/realclean.sub gems/realclean.sub:: ext/realclean.mk + +ext/clean.mk ext/distclean.mk ext/realclean.mk:: + $(Q) [ -f $(EXTS_MK) ] && exec $(MAKE) -f $(EXTS_MK) $(@F:.mk=) + +ext/clean:: ext/clean.sub +ext/distclean:: ext/distclean.sub +ext/realclean:: ext/realclean.sub +gems/clean:: gems/clean.sub +gems/distclean:: gems/distclean.sub +gems/realclean:: gems/realclean.sub + +ext/clean.sub ext/distclean.sub ext/realclean.sub \ +gems/clean.sub gems/distclean.sub gems/realclean.sub:: + $(Q) set dummy `echo "${EXTS}" | tr , ' '`; shift; \ test "$$#" = 0 && set .; \ set dummy `\ - cd ext 2>/dev/null && \ + cd $(@D) 2>/dev/null && \ find "$$@" \( -name Makefile -o -name exts.mk \) -print | \ - sed -n 's:^\./::;s:^:ext/:;s:/[^/][^/]*$$::p' | sort -u; \ - ` ` \ - cd gems 2>/dev/null && \ - find "$$@" -name exts.mk -print | \ - sed -n 's:^\./::;s:^:gems/:;s:/[^/][^/]*$$::p' | sort -u; \ + sed -n 's:^\./::;s:^:$(@D)/:;s:/[^/][^/]*$$::p' | sort -u; \ `; shift; \ for dir do \ - echo $(@:-ext=)ing "$$dir"; \ $(RM) "$$dir/exts.mk"; \ - { [ ! -f "$$dir/Makefile" ] || \ - (cd "$$dir" && exec $(MAKE) $(mflags) $(@:-ext=)); } && \ - case "$@" in \ - *distclean-ext*|*realclean-ext*) \ - $(RMDIRS) "$$dir" 2> /dev/null || true;; \ - esac; \ - done - -$(Q)$(RM) ext/extinit.$(OBJEXT) + if [ -f "$$dir/Makefile" ]; then \ + echo $(@F:.sub=)ing "$$dir"; \ + (cd "$$dir" && exec $(MAKE) $(mflags) $(@F:.sub=)); \ + fi; \ + done || true -distclean-ext realclean-ext:: - -$(Q)$(RM) ext/extinit.c ext/configure-ext.mk - -$(Q)$(RMDIR) ext 2> /dev/null || true - -clean-extout: +ext/distclean ext/realclean gems/distclean gems/realclean:: + $(Q) set dummy `echo "${EXTS}" | tr , ' '`; shift; \ + test "$$#" = 0 && set .; \ + cd $(@D) 2>/dev/null && \ + find "$$@" -type d -empty -exec $(RMDIRS) {} + 2> /dev/null || true + $(Q) $(RMDIRS) $(@D) clean-enc distclean-enc realclean-enc: @test -f "$(ENC_MK)" || exit 0; \ diff --git a/common.mk b/common.mk index 2cbe3591d4..9b0caaef6a 100644 --- a/common.mk +++ b/common.mk @@ -568,11 +568,30 @@ realclean-extout: distclean-extout realclean-platform: distclean-platform realclean-rubyspec: distclean-rubyspec -clean-ext distclean-ext realclean-ext:: - $(Q)$(RM) $(EXTS_MK) +clean-ext:: ext/clean gems/clean timestamp/clean +distclean-ext:: ext/distclean gems/distclean timestamp/distclean +realclean-ext:: ext/realclean gems/realclean timestamp/realclean + +ext/clean.mk ext/distclean.mk ext/realclean.mk:: +ext/clean gems/clean:: ext/clean.mk +ext/distclean gems/distclean:: ext/distclean.mk +ext/realclean gems/realclean:: ext/realclean.mk + +timestamp/clean:: ext/clean gems/clean +timestamp/distclean:: ext/distclean gems/distclean +timestamp/realclean:: ext/realclean gems/realclean + +timestamp/clean timestamp/distclean timestamp/realclean:: $(Q)$(RM) $(TIMESTAMPDIR)/.*.time $(TIMESTAMPDIR)/.$(arch).time $(TIMESTAMPDIR)/$(arch)/.time $(Q)$(RMDIRS) $(TIMESTAMPDIR)/$(arch) 2> $(NULL) || exit 0 +clean-ext:: + -$(Q)$(RM) ext/extinit.$(OBJEXT) + +distclean-ext realclean-ext:: + -$(Q)$(RM) $(EXTS_MK) ext/extinit.* ext/configure-ext.mk + -$(Q)$(RMDIR) ext 2> $(NULL) || exit 0 + clean-enc distclean-enc realclean-enc: PHONY clean-enc: clean-enc.d diff --git a/win32/Makefile.sub b/win32/Makefile.sub index 790b41a4f1..ffccd1422c 100644 --- a/win32/Makefile.sub +++ b/win32/Makefile.sub @@ -1063,31 +1063,31 @@ distclean-local:: -$(Q)$(RM) $(INSTALLED_LIST:/=\) $(arch_hdrdir:/=\)\ruby\config.h verconf.h -$(Q)$(RMDIRS) $(arch_hdrdir:/=\)\ruby -clean-ext distclean-ext realclean-ext:: - @cd ext && for /R $(EXTS) %I in (.) \ - do @if exist %I\Makefile ( \ +ext/clean.mk ext/distclean.mk ext/realclean.mk:: + $(Q)if exist $(EXTS_MK) $(MAKE) -k -f $(EXTS_MK) top_srcdir=$(srcdir) $(*F) + +ext/clean gems/clean ext/distclean gems/distclean ext/realclean gems/realclean:: + $(Q)cd $(@D) && for /R $(EXTS) %I in (.) \ + do $(Q)if exist %I\Makefile ( \ cd %I && ( \ call set n=%I && \ - call set n=%n:%CD%\ext\=% && \ + call set n=%n:%CD%\$(@D)\=% && \ call set n=%n:\.=% && \ - call echo $(@:-ext=)ing %n:\=/% & \ - $(MAKE) $(MFLAGS) $(@:-ext=) & \ + call echo $(@F)ing %n:\=/% & \ + $(MAKE) $(MFLAGS) $(@F) & \ cd %CD% & \ $(RMDIRS) %I \ ) ) -distclean-ext realclean-ext:: - -$(Q)$(RM) ext/extinit.c ext/configure-ext.mk - @cd ext && for /D $(EXTS) %I in (.) \ - do @if exist %I\exts.mk del %I\exts.mk - -$(Q)rmdir ext 2> nul || @ - -clean-extout: +ext/distclean gems/distclean ext/realclean gems/realclean:: + $(Q)cd $(@D) && for /R $(EXTS) %I in (exts.mk*) \ + do $(Q)(del %I & rmdir %~dpI) + -$(Q)rmdir $(@D) 2> nul || @ clean-enc distclean-enc realclean-enc: !if exist($(ENC_MK)) - @echo $(@:-enc=ing) encodings - @-$(MAKE) $(MAKE_ENC) $(@:-enc=) + $(ECHO) $(@:-enc=ing) encodings + -$(Q)$(MAKE) $(MAKE_ENC) $(@:-enc=) !endif $(RBCONFIG): $(PREP)