From 942a1c3ea591724af539b5f40b4991b502e34601 Mon Sep 17 00:00:00 2001 From: nobu Date: Sat, 16 Sep 2006 07:06:57 +0000 Subject: * Makefile.in, common.in, instruby.rb, ext/extmk.rb, lib/mkmf.rb: use instruby.rb to install extensions instead of ext/extmk.rb. * instruby.rb: store installed list into the file. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@10943 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 7 +++ Makefile.in | 2 +- common.mk | 171 +++++++++++++++++++++++++++++++++++++++++------------ ext/extmk.rb | 10 +--- instruby.rb | 189 +++++++++++++++++++++++++++++++++++++++-------------------- lib/mkmf.rb | 22 ++++--- 6 files changed, 282 insertions(+), 119 deletions(-) diff --git a/ChangeLog b/ChangeLog index e73f0b32af..ba6b904ece 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +Mon Jan 16 16:06:20 2006 Nobuyoshi Nakada + + * Makefile.in, common.in, instruby.rb, ext/extmk.rb, lib/mkmf.rb: + use instruby.rb to install extensions instead of ext/extmk.rb. + + * instruby.rb: store installed list into the file. + Thu Sep 14 16:11:15 2006 Yukihiro Matsumoto * string.c (rb_str_intern): raise SecurityError only when $SAFE diff --git a/Makefile.in b/Makefile.in index 5b48c30ceb..edf4a3ae8b 100644 --- a/Makefile.in +++ b/Makefile.in @@ -85,7 +85,7 @@ ASFLAGS = @ASFLAGS@ OBJEXT = @OBJEXT@ MANTYPE = @MANTYPE@ -PREINSTALL = @PREINSTALL@ +INSTALLED_LIST= .installed.list #### End of variables all: diff --git a/common.mk b/common.mk index cb226b8a37..311dfd098c 100644 --- a/common.mk +++ b/common.mk @@ -53,10 +53,12 @@ OBJS = array.$(OBJEXT) \ $(MISSING) SCRIPT_ARGS = --dest-dir="$(DESTDIR)" \ + --extout="$(EXTOUT)" \ --make="$(MAKE)" \ --mflags="$(MFLAGS)" \ --make-flags="$(MAKEFLAGS)" -EXTMK_ARGS = $(SCRIPT_ARGS) --extout="$(EXTOUT)" --extension $(EXTS) --extstatic $(EXTSTATIC) -- +EXTMK_ARGS = $(SCRIPT_ARGS) --extension $(EXTS) --extstatic $(EXTSTATIC) -- +INSTRUBY_ARGS = $(SCRIPT_ARGS) --installed-list $(INSTALLED_LIST) all: $(MKFILES) $(PREP) $(RBCONFIG) $(LIBRUBY) @$(MINIRUBY) $(srcdir)/ext/extmk.rb $(EXTMK_ARGS) @@ -80,46 +82,143 @@ ruby.imp: $(OBJS) install: install-nodoc $(RDOCTARGET) install-all: install-nodoc install-doc -install-nodoc: install-local install-ext -install-local: pre-install-local do-install-local post-install-local -install-ext: pre-install-ext do-install-ext post-install-ext +install-nodoc: pre-install-nodoc do-install-nodoc post-install-nodoc +pre-install-nodoc:: pre-install-local pre-install-ext +do-install-nodoc: + $(MINIRUBY) $(srcdir)/instruby.rb $(INSTRUBY_ARGS) --mantype="$(MANTYPE)" +post-install-nodoc:: post-install-local post-install-ext -do-install-local: $(RBCONFIG) - $(MINIRUBY) $(srcdir)/instruby.rb $(SCRIPT_ARGS) --mantype="$(MANTYPE)" -do-install-ext: $(RBCONFIG) - $(MINIRUBY) $(srcdir)/ext/extmk.rb $(EXTMK_ARGS) install +install-local: pre-install-local do-install-local post-install-local +pre-install-local:: pre-install-bin pre-install-lib pre-install-man +do-install-local: + $(MINIRUBY) $(srcdir)/instruby.rb $(INSTRUBY_ARGS) --install=local --mantype="$(MANTYPE)" +post-install-local:: post-install-bin post-install-lib post-install-man -install-bin: $(RBCONFIG) - $(MINIRUBY) $(srcdir)/instruby.rb $(SCRIPT_ARGS) --install=bin -install-lib: $(RBCONFIG) - $(MINIRUBY) $(srcdir)/instruby.rb $(SCRIPT_ARGS) --install=lib -install-man: $(RBCONFIG) - $(MINIRUBY) $(srcdir)/instruby.rb $(SCRIPT_ARGS) --install=man --mantype="$(MANTYPE)" +install-ext: pre-install-ext do-install-ext post-install-ext +pre-install-ext:: pre-install-ext-arch pre-install-ext-comm +do-install-ext: + $(MINIRUBY) $(srcdir)/instruby.rb $(INSTRUBY_ARGS) --install=ext +post-install-ext:: post-install-ext-arch post-install-ext-comm + +install-arch: pre-install-arch do-install-arch post-install-arch +pre-install-arch:: pre-install-bin pre-install-ext-arch +do-install-arch: + $(MINIRUBY) $(srcdir)/instruby.rb $(INSTRUBY_ARGS) --install=bin --install=ext-arch +post-install-arch:: post-install-bin post-install-ext-arch + +install-comm: pre-install-comm do-install-comm post-install-comm +pre-install-comm:: pre-install-lib pre-install-ext-comm pre-install-man +do-install-comm: + $(MINIRUBY) $(srcdir)/instruby.rb $(INSTRUBY_ARGS) --install=lib --install=ext-comm --install=man +post-install-comm:: post-install-lib post-install-ext-comm post-install-man + +install-bin: pre-install-bin do-install-bin post-install-bin +pre-install-bin:: install-prereq +do-install-bin: + $(MINIRUBY) $(srcdir)/instruby.rb $(INSTRUBY_ARGS) --install=bin +post-install-bin:: + +install-lib: pre-install-lib do-install-lib post-install-lib +pre-install-lib:: install-prereq +do-install-lib: + $(MINIRUBY) $(srcdir)/instruby.rb $(INSTRUBY_ARGS) --install=lib +post-install-lib:: + +install-ext-comm: pre-install-ext-comm do-install-ext-comm post-install-ext-comm +pre-install-ext-comm:: install-prereq +do-install-ext-comm: + $(MINIRUBY) $(srcdir)/instruby.rb $(INSTRUBY_ARGS) --install=ext-comm +post-install-ext-comm:: + +install-ext-arch: pre-install-ext-arch do-install-ext-arch post-install-ext-arch +pre-install-ext-arch:: install-prereq +do-install-ext-arch: + $(MINIRUBY) $(srcdir)/instruby.rb $(INSTRUBY_ARGS) --install=ext-arch +post-install-ext-arch:: + +install-man: pre-install-man do-install-man post-install-man +pre-install-man:: install-prereq +do-install-man: + $(MINIRUBY) $(srcdir)/instruby.rb $(INSTRUBY_ARGS) --install=man --mantype="$(MANTYPE)" +post-install-man:: + +what-where: no-install +no-install: no-install-nodoc $(RDOCTARGET) +what-where-all: no-install-all +no-install-all: no-install-nodoc + +what-where-nodoc: no-install-nodoc +no-install-nodoc: pre-no-install-nodoc dont-install-nodoc post-no-install-nodoc +pre-no-install-nodoc:: pre-no-install-local pre-no-install-ext +dont-install-nodoc: + $(MINIRUBY) $(srcdir)/instruby.rb -n $(INSTRUBY_ARGS) --mantype="$(MANTYPE)" +post-no-install-nodoc:: post-no-install-local post-no-install-ext -what-where-all no-install-all: no-install no-install-doc -what-where no-install: no-install-local no-install-ext what-where-local: no-install-local -no-install-local: $(RBCONFIG) - $(MINIRUBY) $(srcdir)/instruby.rb -n $(SCRIPT_ARGS) --mantype="$(MANTYPE)" +no-install-local: pre-no-install-local dont-install-local post-no-install-local +pre-no-install-local:: pre-no-install-bin pre-no-install-lib pre-no-install-man +dont-install-local: + $(MINIRUBY) $(srcdir)/instruby.rb -n $(INSTRUBY_ARGS) --install=local --mantype="$(MANTYPE)" +post-no-install-local:: post-no-install-bin post-no-install-lib post-no-install-man + what-where-ext: no-install-ext -no-install-ext: $(RBCONFIG) - $(MINIRUBY) $(srcdir)/ext/extmk.rb -n $(EXTMK_ARGS) install - -install-doc: pre-install-doc do-install-doc post-install-doc -do-install-doc: $(PROGRAM) - @echo Generating RDoc documentation - $(RUNRUBY) "$(srcdir)/bin/rdoc" --all --ri --op "$(RIDATADIR)" "$(srcdir)" - -pre-install: pre-install-local pre-install-ext -pre-install-local:: PHONY - $(PREINSTALL) -pre-install-ext:: PHONY -pre-install-doc:: PHONY - -post-install: post-install-local post-install-ext -post-install-local:: PHONY -post-install-ext:: PHONY -post-install-doc:: PHONY +no-install-ext: pre-no-install-ext dont-install-ext post-no-install-ext +pre-no-install-ext:: pre-no-install-ext-arch pre-no-install-ext-comm +dont-install-ext: + $(MINIRUBY) $(srcdir)/instruby.rb -n $(INSTRUBY_ARGS) --install=ext +post-no-install-ext:: post-no-install-ext-arch post-no-install-ext-comm + +what-where-arch: no-install-arch +no-install-arch: pre-no-install-arch dont-install-arch post-no-install-arch +pre-no-install-arch:: pre-no-install-bin pre-no-install-ext-arch +dont-install-arch: + $(MINIRUBY) $(srcdir)/instruby.rb -n $(INSTRUBY_ARGS) --install=bin --install=ext-arch +post-no-install-arch:: post-no-install-lib post-no-install-man post-no-install-ext-arch + +what-where-comm: no-install-comm +no-install-comm: pre-no-install-comm dont-install-comm post-no-install-comm +pre-no-install-comm:: pre-no-install-lib pre-no-install-ext-comm pre-no-install-man +dont-install-comm: + $(MINIRUBY) $(srcdir)/instruby.rb -n $(INSTRUBY_ARGS) --install=lib --install=ext-comm --install=man +post-no-install-comm:: post-no-install-lib post-no-install-ext-comm post-no-install-man + +what-where-bin: no-install-bin +no-install-bin: pre-no-install-bin dont-install-bin post-no-install-bin +pre-no-install-bin:: install-prereq +dont-install-bin: + $(MINIRUBY) $(srcdir)/instruby.rb -n $(INSTRUBY_ARGS) --install=bin +post-no-install-bin:: + +what-where-lib: no-install-lib +no-install-lib: pre-no-install-lib dont-install-lib post-no-install-lib +pre-no-install-lib:: install-prereq +dont-install-lib: + $(MINIRUBY) $(srcdir)/instruby.rb -n $(INSTRUBY_ARGS) --install=lib +post-no-install-lib:: + +what-where-ext-comm: no-install-ext-comm +no-install-ext-comm: pre-no-install-ext-comm dont-install-ext-comm post-no-install-ext-comm +pre-no-install-ext-comm:: install-prereq +dont-install-ext-comm: + $(MINIRUBY) $(srcdir)/instruby.rb -n $(INSTRUBY_ARGS) --install=ext-comm +post-no-install-ext-comm:: + +what-where-ext-arch: no-install-ext-arch +no-install-ext-arch: pre-no-install-ext-arch dont-install-ext-arch post-no-install-ext-arch +pre-no-install-ext-arch:: install-prereq +dont-install-ext-arch: + $(MINIRUBY) $(srcdir)/instruby.rb -n $(INSTRUBY_ARGS) --install=ext-arch +post-no-install-ext-arch:: + +what-where-man: no-install-man +no-install-man: pre-no-install-man dont-install-man post-no-install-man +pre-no-install-man:: install-prereq +dont-install-man: + $(MINIRUBY) $(srcdir)/instruby.rb -n $(INSTRUBY_ARGS) --install=man --mantype="$(MANTYPE)" +post-no-install-man:: + +install-prereq: + @exit > $(INSTALLED_LIST) clean: clean-ext clean-local clean-local:: diff --git a/ext/extmk.rb b/ext/extmk.rb index 615bb13ad4..fb28fb11ce 100644 --- a/ext/extmk.rb +++ b/ext/extmk.rb @@ -390,16 +390,8 @@ else end if $extout - Config.expand(extout = "#$extout", Config::CONFIG.merge("topdir"=>$topdir)) - if $install - dest = Config.expand($rubylibdir.dup) - unless $destdir.empty? - dest.sub!($dest_prefix_pattern, Config.expand($destdir.dup)) - end - FileUtils.cp_r(extout+"/.", dest, :verbose => true, :noop => $dryrun) - exit - end unless $ignore + Config.expand(extout = "#$extout", Config::CONFIG.merge("topdir"=>$topdir)) FileUtils.mkpath(extout) end end diff --git a/instruby.rb b/instruby.rb index 1237b01abc..664ac5afb0 100644 --- a/instruby.rb +++ b/instruby.rb @@ -17,12 +17,16 @@ File.umask(0) def parse_args() $mantype = 'doc' $destdir = nil + $extout = nil $make = 'make' $mflags = [] $install = [] + $installed_list = nil + $dryrun = false opt = OptionParser.new opt.on('-n') {$dryrun = true} opt.on('--dest-dir=DIR') {|dir| $destdir = dir} + opt.on('--extout=DIR') {|dir| $extout = (dir unless dir.empty?)} opt.on('--make=COMMAND') {|make| $make = make} opt.on('--mantype=MAN') {|man| $mantype = man} opt.on('--make-flags=FLAGS', '--mflags', Shellwords) do |v| @@ -31,7 +35,11 @@ def parse_args() end $mflags.concat(v) end - opt.on('--install=TYPE', [:bin, :lib, :man]) {|ins| $install << ins} + opt.on('-i', '--install=TYPE', + [:local, :bin, :lib, :man, :ext, :"ext-arch", :"ext-comm"]) do |ins| + $install << ins + end + opt.on('--installed-list [FILENAME]') {|name| $installed_list = name} opt.parse! rescue abort [$!.message, opt].join("\n") $make, *rest = Shellwords.shellwords($make) @@ -41,6 +49,10 @@ def parse_args() grep(/\A-(?!-).*#{'%c' % flag}/i) { return true } false end + def $mflags.defined?(var) + grep(/\A#{var}=(.*)/) {return $1} + false + end if $mflags.set?(?n) $dryrun = true @@ -48,9 +60,16 @@ def parse_args() $mflags << '-n' if $dryrun end - $mflags << "DESTDIR=#{$destdir}" + $destdir ||= $mflags.defined?("DESTDIR") + $extout ||= $mflags.defined?("EXTOUT") $continue = $mflags.set?(?k) + + if $installed_list ||= $mflags.defined?('INSTALLED_LIST') + Config.expand($installed_list, Config::CONFIG) + $installed_list = open($installed_list, "ab") + $installed_list.sync = true + end end parse_args() @@ -60,13 +79,22 @@ include FileUtils::NoWrite if $dryrun @fileutils_output = STDOUT @fileutils_label = '' -def install?(type) - yield if $install.empty? or $install.include?(type) +def install?(*types) + yield if $install.empty? or !($install & types).empty? end def install(src, dest, options = {}) options[:preserve] = true super + if $installed_list + dest = File.join(dest, File.basename(src)) if $made_dirs[dest] + $installed_list.puts dest + end +end + +def ln_sf(src, dest) + super + $installed_list.puts dest if $installed_list end $made_dirs = {} @@ -108,7 +136,7 @@ arc = CONFIG["LIBRUBY_A"] makedirs [bindir, libdir, rubylibdir, archlibdir, sitelibdir, sitearchlibdir] -install?(:bin) do +install?(:local, :arch, :bin) do ruby_bin = File.join(bindir, ruby_install_name) install ruby_install_name+exeext, ruby_bin+exeext, :mode => 0755 @@ -144,41 +172,72 @@ install?(:bin) do end end +if $extout + RbConfig.expand(extout = "#$extout") + if noinst = CONFIG["no_install_files"] and noinst.empty? + noinst = nil + end + dest = rubylibdir + subpath = nil + copy = proc do |s| + d = dest + s[subpath] + if File.directory?(s) + makedirs(d) + else + install s, d + end + end + install?(:ext, :arch, :'ext-arch') do + subpath = extout.size..-1 + Dir.glob("#{extout}/#{CONFIG['arch']}/**/*", File::FNM_DOTMATCH) do |src| + unless /\A\.{1,2}\z/ =~ (base = File.basename(src)) or + (noinst and File.fnmatch?(noinst, File.basename(src))) + copy[src] + end + end + end + install?(:ext, :comm, :'ext-comm') do + src = "#{extout}/common" + subpath = src.size..-1 + Dir.glob("#{src}/**/*", File::FNM_DOTMATCH, ©) + end +end + Dir.chdir srcdir -install?(:lib) do -ruby_shebang = File.join(CONFIG["bindir"], ruby_install_name) -if File::ALT_SEPARATOR - ruby_bin_dosish = ruby_shebang.tr(File::SEPARATOR, File::ALT_SEPARATOR) -end -for src in Dir["bin/*"] - next unless File.file?(src) - next if /\/[.#]|(\.(old|bak|orig|rej|diff|patch|core)|~|\/core)$/i =~ src +install?(:local, :arch, :lib) do + ruby_shebang = File.join(CONFIG["bindir"], ruby_install_name) + if File::ALT_SEPARATOR + ruby_bin_dosish = ruby_shebang.tr(File::SEPARATOR, File::ALT_SEPARATOR) + end + for src in Dir["bin/*"] + next unless File.file?(src) + next if /\/[.#]|(\.(old|bak|orig|rej|diff|patch|core)|~|\/core)$/i =~ src - name = ruby_install_name.sub(/ruby/, File.basename(src)) - dest = File.join(bindir, name) + name = ruby_install_name.sub(/ruby/, File.basename(src)) + dest = File.join(bindir, name) - install src, dest, :mode => 0755 + install src, dest, :mode => 0755 - next if $dryrun + next if $dryrun - shebang = '' - body = '' - open(dest, "r+") { |f| - shebang = f.gets - body = f.read + shebang = '' + body = '' + open(dest, "r+") { |f| + shebang = f.gets + body = f.read - if shebang.sub!(/^\#!.*?ruby\b/) {"#!" + ruby_shebang} - f.rewind - f.print shebang, body - f.truncate(f.pos) - end - } + if shebang.sub!(/^\#!.*?ruby\b/) {"#!" + ruby_shebang} + f.rewind + f.print shebang, body + f.truncate(f.pos) + end + } - if ruby_bin_dosish - batfile = File.join(CONFIG["bindir"], name + ".bat") - open(with_destdir(batfile), "w") { |b| - b.print < 0644 -end + for f in Dir["lib/**/*{.rb,help-message}"] + dir = File.dirname(f).sub!(/\Alib/, rubylibdir) || rubylibdir + makedirs dir + install f, dir, :mode => 0644 + end end -install?(:bin) do -for f in Dir["*.h"] - install f, archlibdir, :mode => 0644 -end +install?(:local, :arch, :bin) do + for f in Dir["*.h"] + install f, archlibdir, :mode => 0644 + end -if RUBY_PLATFORM =~ /mswin32|mingw|bccwin32/ - makedirs File.join(archlibdir, "win32") - install "win32/win32.h", File.join(archlibdir, "win32"), :mode => 0644 -end + if RUBY_PLATFORM =~ /mswin32|mingw|bccwin32/ + makedirs File.join(archlibdir, "win32") + install "win32/win32.h", File.join(archlibdir, "win32"), :mode => 0644 + end end -install?(:man) do -for mdoc in Dir["*.[1-9]"] - next unless File.file?(mdoc) and open(mdoc){|fh| fh.read(1) == '.'} +install?(:local, :comm, :man) do + for mdoc in Dir["*.[1-9]"] + next unless File.file?(mdoc) and open(mdoc){|fh| fh.read(1) == '.'} - section = mdoc[-1,1] + section = mdoc[-1,1] - destdir = mandir + section - destfile = File.join(destdir, mdoc.sub(/ruby/, ruby_install_name)) + destdir = mandir + section + destfile = File.join(destdir, mdoc.sub(/ruby/, ruby_install_name)) - makedirs destdir + makedirs destdir - if $mantype == "doc" - install mdoc, destfile, :mode => 0644 - else - require 'mdoc2man.rb' + if $mantype == "doc" + install mdoc, destfile, :mode => 0644 + else + require 'mdoc2man.rb' - w = Tempfile.open(mdoc) + w = Tempfile.open(mdoc) - open(mdoc) { |r| - Mdoc2Man.mdoc2man(r, w) - } + open(mdoc) { |r| + Mdoc2Man.mdoc2man(r, w) + } - w.close + w.close - install w.path, destfile, :mode => 0644 + install w.path, destfile, :mode => 0644 + end end end -end # vi:set sw=2: diff --git a/lib/mkmf.rb b/lib/mkmf.rb index 6c8ddca0a3..ae27fdac43 100644 --- a/lib/mkmf.rb +++ b/lib/mkmf.rb @@ -83,8 +83,8 @@ INSTALL_DIRS = [ def install_dirs(target_prefix = nil) if $extout dirs = [ - ['RUBYCOMMONDIR', '$(extout)'], - ['RUBYLIBDIR', '$(extout)$(target_prefix)'], + ['RUBYCOMMONDIR', '$(extout)/common'], + ['RUBYLIBDIR', '$(RUBYCOMMONDIR)/$(target_prefix)'], ['RUBYARCHDIR', '$(extout)/$(arch)$(target_prefix)'], ['extout', "#$extout"], ['extout_prefix', "#$extout_prefix"], @@ -848,7 +848,7 @@ def find_executable0(bin, path = nil) ext = config_string('EXEEXT') if File.expand_path(bin) == bin return bin if File.executable?(bin) - return file if ext and File.executable?(file = bin + ext) + ext and File.executable?(file = bin + ext) and return file return nil end if path ||= ENV['PATH'] @@ -1196,7 +1196,7 @@ def create_makefile(target, srcprefix = nil) staticlib = target ? "$(TARGET).#$LIBEXT" : "" mfile = open("Makefile", "wb") mfile.print configuration(srcprefix) - mfile.print %{ + mfile.print " libpath = #{$LIBPATH.join(" ")} LIBPATH = #{libpath} DEFFILE = #{deffile} @@ -1215,18 +1215,18 @@ TARGET = #{target} DLLIB = #{dllib} EXTSTATIC = #{$static || ""} STATIC_LIB = #{staticlib unless $static.nil?} - -} +#{!$extout && defined?($installed_list) ? "INSTALLED_LIST = #{$installed_list}\n" : ""} +" install_dirs.each {|d| mfile.print("%-14s= %s\n" % d) if /^[[:upper:]]/ =~ d[0]} n = ($extout ? '$(RUBYARCHDIR)/' : '') + '$(TARGET).' - mfile.print %{ + mfile.print " TARGET_SO = #{($extout ? '$(RUBYARCHDIR)/' : '')}$(DLLIB) CLEANLIBS = #{n}#{CONFIG['DLEXT']} #{n}il? #{n}tds #{n}map CLEANOBJS = *.#{$OBJEXT} *.#{$LIBEXT} *.s[ol] *.pdb *.exp *.bak all: #{$extout ? "install" : target ? "$(DLLIB)" : "Makefile"} static: $(STATIC_LIB)#{$extout ? " install-rb" : ""} -} +" mfile.print CLEANINGS dirs = [] mfile.print "install: install-so install-rb\n\n" @@ -1248,6 +1248,9 @@ static: $(STATIC_LIB)#{$extout ? " install-rb" : ""} dir.gsub!(/(\$\{\w+)(\})/) {$1+sep+$2} end mfile.print "\t$(INSTALL_PROG) #{f} #{dir}\n" + if defined?($installed_list) + mfile.print "\t@echo #{dir}/#{File.basename(f)}>>$(INSTALLED_LIST)\n" + end end end mfile.print("install-rb: pre-install-rb install-rb-default\n") @@ -1275,6 +1278,9 @@ static: $(STATIC_LIB)#{$extout ? " install-rb" : ""} sep = "" end mfile.print("#{f} $(@D#{sep})\n") + if defined?($installed_list) and !$extout + mfile.print("\t@echo #{dest}>>$(INSTALLED_LIST)\n") + end end end end -- cgit v1.2.3