diff --git a/ext/extmk.rb b/ext/extmk.rb index a7eea62a27..98fd76ca68 100755 --- a/ext/extmk.rb +++ b/ext/extmk.rb @@ -83,6 +83,8 @@ end def extract_makefile(makefile, keep = true) m = File.read(makefile) + s = m[/^CLEANFILES[ \t]*=[ \t](.*)/, 1] and $cleanfiles = s.split + s = m[/^DISTCLEANFILES[ \t]*=[ \t](.*)/, 1] and $distcleanfiles = s.split if !(target = m[/^TARGET[ \t]*=[ \t]*(\S*)/, 1]) return keep end @@ -127,7 +129,6 @@ def extract_makefile(makefile, keep = true) end $objs = (m[/^OBJS[ \t]*=[ \t](.*)/, 1] || "").split $srcs = (m[/^SRCS[ \t]*=[ \t](.*)/, 1] || "").split - $distcleanfiles = (m[/^DISTCLEANFILES[ \t]*=[ \t](.*)/, 1] || "").split $LOCAL_LIBS = m[/^LOCAL_LIBS[ \t]*=[ \t]*(.*)/, 1] || "" $LIBPATH = Shellwords.shellwords(m[/^libpath[ \t]*=[ \t]*(.*)/, 1] || "") - %w[$(libdir) $(topdir)] true @@ -201,7 +202,7 @@ def extmake(target) $extconf_h = nil ok &&= extract_makefile(makefile) old_objs = $objs - old_cleanfiles = $distcleanfiles + old_cleanfiles = $distcleanfiles | $cleanfiles conf = ["#{$srcdir}/makefile.rb", "#{$srcdir}/extconf.rb"].find {|f| File.exist?(f)} if (!ok || ($extconf_h && !File.exist?($extconf_h)) || !(t = modified?(makefile, MTIMES)) || @@ -274,7 +275,7 @@ def extmake(target) args += ["static"] unless $clean $extlist.push [$static, target, $target, $preload] end - FileUtils.rm_f(old_cleanfiles - $distcleanfiles) + FileUtils.rm_f(old_cleanfiles - $distcleanfiles - $cleanfiles) FileUtils.rm_f(old_objs - $objs) unless $configure_only or system($make, *args) $ignore or $continue or return false