aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile.in55
-rw-r--r--common.mk23
-rw-r--r--win32/Makefile.sub30
3 files changed, 67 insertions, 41 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)
-
-distclean-ext realclean-ext::
- -$(Q)$(RM) ext/extinit.c ext/configure-ext.mk
- -$(Q)$(RMDIR) ext 2> /dev/null || true
-
-clean-extout:
+ if [ -f "$$dir/Makefile" ]; then \
+ echo $(@F:.sub=)ing "$$dir"; \
+ (cd "$$dir" && exec $(MAKE) $(mflags) $(@F:.sub=)); \
+ fi; \
+ done || true
+
+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)