diff --git a/ChangeLog b/ChangeLog index 4ef7cb9a80..c1226c340f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,19 @@ +Fri Jul 18 17:34:39 2003 Nobuyoshi Nakada + + * lib/mkmf.rb (rm_f): use FileUtils. + + * lib/mkmf.rb (modified?): return mtime of the target if + it exists and newer than times. + + * lib/mkmf.rb (install_files): add a current directory + file even if it does not exist yet. + + * lib/mkmf.rb (configuration): do not add $LDFLAGS to + DLDFLAGS. + + * ext/extmk.rb (extmake): check whether Makefile is newer + than depend and MANIFEST. + Fri Jul 18 14:57:19 2003 NAKAMURA Usaku * win32/win32.c (make_cmdvector): recognize quote within string. diff --git a/ext/extmk.rb b/ext/extmk.rb index 0485568d6b..f7cffa72ec 100644 --- a/ext/extmk.rb +++ b/ext/extmk.rb @@ -73,7 +73,9 @@ def extmake(target) $srcdir = File.join($top_srcdir, "ext", $mdir) unless $ignore if $static || - older("./Makefile", *MTIMES + %W"#{$srcdir}/makefile.rb #{$srcdir}/extconf.rb") + !(t = modified?("./Makefile", MTIMES)) || + %W<#{$srcdir}/makefile.rb #{$srcdir}/extconf.rb + #{$srcdir}/depend #{$srcdir}/MANIFEST>.any? {|f| modified?(f, [t])} then $defs = [] Logging::logfile 'mkmf.log' @@ -244,7 +246,7 @@ if $extlist.size > 0 end src = "void Init_ext() {\n#$extinit}\n" - if older("extinit.c", *MTIMES) || IO.read("extinit.c") != src + if !modified?("extinit.c", MTIMES) || IO.read("extinit.c") != src open("extinit.c", "w") {|f| f.print src} end @@ -268,6 +270,9 @@ rubies = [] } Dir.chdir ".." +if $extlist.size > 0 + rm_f(Config::CONFIG["LIBRUBY_SO"]) +end puts "making #{rubies.join(', ')}" $stdout.flush $mflags.concat(rubies) diff --git a/lib/mkmf.rb b/lib/mkmf.rb index 59544825c2..debb1bfb65 100644 --- a/lib/mkmf.rb +++ b/lib/mkmf.rb @@ -2,6 +2,7 @@ # invoke like: ruby -r mkmf extconf.rb require 'rbconfig' +require 'fileutils' require 'shellwords' CONFIG = Config::MAKEFILE_CONFIG @@ -105,25 +106,13 @@ class Array end def rm_f(*files) - targets = [] - for file in files - targets.concat Dir[file] - end - if not targets.empty? - File::chmod(0777, *targets) - File::unlink(*targets) - end + FileUtils.rm_f(Dir[files.join("\0")]) end -def older(target, *files) - mtime = proc do |f| - Time === f ? f : f.respond_to?(:mtime) ? f.mtime : File.mtime(f) rescue nil - end - t = mtime[target] or return true - for f in files - return true if t < (mtime[f] or next) - end - false +def modified?(target, times) + (t = File.mtime(target)) rescue return nil + Array === times or times = [times] + t if times.all? {|n| n <= t} end module Logging @@ -339,6 +328,7 @@ def install_files(mfile, ifiles, map = nil, srcprefix = nil) files = File.join(srcdir, files) len = srcdir.size end + f = nil Dir.glob(files) do |f| f[0..len] = "" if len d = File.dirname(f) @@ -347,6 +337,12 @@ def install_files(mfile, ifiles, map = nil, srcprefix = nil) f = File.join(srcprefix, f) if len path[d] << f end + unless len or f + d = File.dirname(files) + d.sub!(prefix, "") if prefix + d = (d.empty? || d == ".") ? dir : File.join(dir, d) + path[d] << files + end end dirs end @@ -370,9 +366,10 @@ def checking_for(m) f = caller[0][/in `(.*)'$/, 1] and f << ": " #` for vim m = "checking for #{m}... " message m - Logging::message "#{f}#{m}\n" + Logging::message "#{f}#{m}--------------------\n" r = yield - message(r ? "yes\n" : "no\n") + message(a = r ? "yes\n" : "no\n") + Logging::message "-------------------- #{a}\n" r end