@@ -722,6 +722,7 @@ def initialize(src)
722722 mf . puts "ECHO = $(ECHO1:0=@echo)"
723723 mf . puts "MFLAGS = -$(MAKEFLAGS)" if $nmake
724724 mf . puts "override MFLAGS := $(filter-out -j%,$(MFLAGS))" if $gnumake
725+ mf . puts "ext_build_dir = #{ File . dirname ( $command_output) } "
725726 mf . puts
726727
727728 def mf . macro ( name , values , max = 70 )
@@ -764,6 +765,7 @@ def mf.macro(name, values, max = 70)
764765 mf . macro "SUBMAKEOPTS" , submakeopts
765766 mf . macro "NOTE_MESG" , %w[ $(RUBY) $(top_srcdir)/tool/lib/colorize.rb skip ]
766767 mf . macro "NOTE_NAME" , %w[ $(RUBY) $(top_srcdir)/tool/lib/colorize.rb fail ]
768+ %w[ RM RMDIRS RMDIR RMALL ] . each { |w | mf . macro w , [ RbConfig ::CONFIG [ w ] ] }
767769 mf . puts
768770 targets = %w[ all install static install-so install-rb clean distclean realclean ]
769771 targets . each do |tgt |
@@ -798,16 +800,20 @@ def mf.macro(name, values, max = 70)
798800 exts . each do |d |
799801 d = d [ 0 ..-2 ]
800802 t = "#{ d } #{ tgt } "
801- if /^(dist|real)?clean$/ =~ tgt
803+ if clean = /^(dist|real)?clean$/ . match ( tgt )
802804 deps = exts . select { |e |e . start_with? ( d ) } . map { |e |"#{ e [ 0 ..-2 ] } #{ tgt } " } - [ t ]
803- pd = ' ' + deps . join ( ' ' ) unless deps . empty?
805+ pd = [ ' clean-local' , * deps ] . join ( ' ' )
804806 else
805807 pext = File . dirname ( d )
806808 pd = " #{ pext } /#{ tgt } " if exts . include? ( "#{ pext } /." )
807809 end
808810 mf . puts "#{ t } :#{ pd } \n \t $(Q)#{ submake } $(MFLAGS) V=$(V) $(@F)"
811+ if clean and clean . begin ( 1 )
812+ mf . puts "\t $(Q)$(RM) $(ext_build_dir)/exts.mk\n \t $(Q)$(RMDIRS) -p $(@D)"
813+ end
809814 end
810815 end
816+ mf . puts "\n " "clean-local:\n \t $(Q)$(RM) $(ext_build_dir)/*~ $(ext_build_dir)/*.bak $(ext_build_dir)/core"
811817 mf . puts "\n " "extso:\n "
812818 mf . puts "\t @echo EXTSO=$(EXTSO)"
813819
0 commit comments