New install patch

Ok,

I’ve messed around with extmk.rb.in as well as instruby.rb and
mkconfig.rb.

It now works for me, other people may be (a) interested or (b) horrified.

Sorry, Jim, it won’t provide binary relocation, as the ruby binary
contains the path specified at configure time, not install time.

The only way I can see to support that is to insist on a fixed path that
can then be symlinked to the actual location, say /opt/ruby. In which
case, you can configure ruby to look in /opt/ruby but install it wherever
you like. In that case, this install patch would be useful.

Do you think Matz would be interested in this at all?

Cheers,
Mike

···


Mike Wyer mike@wyer.org www.wyer.org/mike 07974 254007

"I want to die peacefully in my sleep like my Grandfather...

… not screaming and yelling like the passengers in his car"

Doh! Here’s the patch (it still contains some debugging code, so it’s a
little noisier than necessary):

diff -r -U3 ruby-1.6.8/ext/extmk.rb.in src/ext/extmk.rb.in
— ruby-1.6.8/ext/extmk.rb.in Tue Dec 24 08:29:10 2002
+++ src/ext/extmk.rb.in Fri Apr 4 17:23:22 2003
@@ -25,8 +25,35 @@
SRC_EXT = [“c”, “cc”, “m”, “cxx”, “cpp”, “C”]
$extlist = []

-$includedir = “@includedir@”.gsub(/${prefix}|$(prefix)/,’@prefix@’)
-$libdir = “@libdir@”.gsub(/${exec_prefix}|$(exec_prefix)/,’@exec_prefix@’)
+CONFIG_NO_EXPAND = true
+load “…/rbconfig.rb”
+include Config

···

+makevars = {}
+ENV[“MAKEFLAGS”].split(’ ').each do

  • |pair|
  • key,value = *pair.split(’=’)
  • $stderr.puts “Found #{key} = #{value}”
  • makevars[key.downcase] = value
    +end

+if makevars[“prefix”]

  • CONFIG[“prefix”] = makevars[“prefix”]
    +elsif ENV[“prefix”]
  • CONFIG[“prefix”] = ENV[“prefix”]
    +end
    +prefix = CONFIG[“prefix”]

+if makevars[“exec_prefix”]

  • CONFIG[“exec_prefix”] = makevars[“exec_prefix”]
    +elsif ENV[“exec_prefix”]
  • CONFIG[“exec_prefix”] = ENV[“exec_prefix”]
    +end

+Config::expand_all
+
+$includedir = CONFIG[“includedir”]
+$libdir = CONFIG[“libdir”]

$top_srcdir = "@top_srcdir@"
if $top_srcdir !~ “^/”
@@ -381,8 +408,8 @@

$DLDFLAGS << " -Wl,–no-undefined"

end

  • if $configure_args[’–enable-shared’] or “@LIBRUBY@” != “@LIBRUBY_A@”
  • $libs = "@LIBRUBYARG@ " + $libs
  • if $configure_args[’–enable-shared’] or CONFIG[“LIBRUBY”] != CONFIG[“LIBRUBY_A”]
  • $libs = CONFIG[“LIBRUBYARG”] + " " + $libs
    $LIBPATH.unshift $topdir
    end

@@ -435,9 +462,11 @@
RUBY_INSTALL_NAME = @RUBY_INSTALL_NAME@
RUBY_SO_NAME = @RUBY_SO_NAME@

-prefix = @prefix@
-exec_prefix = @exec_prefix@
-libdir = @libdir@
+PREFIX = @prefix@
+EXEC_PREFIX = @exec_prefix@
+prefix = $(PREFIX)
+exec_prefix = $(EXEC_PREFIX)
+libdir = $(exec_prefix)/lib
#pkglibdir = $(libdir)/$(RUBY_INSTALL_NAME)/@MAJOR@.@MINOR@
pkglibdir = $(libdir)/ruby/@MAJOR@.@MINOR@
archdir = $(pkglibdir)/@arch@
diff -r -U3 ruby-1.6.8/instruby.rb src/instruby.rb
— ruby-1.6.8/instruby.rb Mon Dec 2 16:53:03 2002
+++ src/instruby.rb Fri Apr 4 16:25:47 2003
@@ -1,35 +1,55 @@
#!./miniruby

+File.umask(0)
+CONFIG_NO_EXPAND = true
load "./rbconfig.rb"
include Config

-File.umask(0)
-destdir = ARGV[0] || ‘’
+makevars = {}
+ENV[“MAKEFLAGS”].split(’ ').each do

  • |pair|
  • key,value = *pair.split(’=’)
  • $stderr.puts “Found #{key} = #{value}”
  • makevars[key.downcase] = value
    +end

+destdir = ARGV[0] || makevars[‘destdir’] || ‘’
+
+if makevars[“prefix”]

  • CONFIG[“prefix”] = makevars[“prefix”]
    +elsif ENV[“prefix”]
  • CONFIG[“prefix”] = ENV[“prefix”]
    +end
    +prefix = CONFIG[“prefix”]

+if makevars[“exec_prefix”]

  • CONFIG[“exec_prefix”] = makevars[“exec_prefix”]
    +elsif ENV[“exec_prefix”]
  • CONFIG[“exec_prefix”] = ENV[“exec_prefix”]
    +end

+Config::expand_all

$:.unshift CONFIG[“srcdir”]+"/lib"
require "ftools"
require “find”

exeext = CONFIG[“EXEEXT”]
-if ENV[“prefix”]

  • prefix = ENV[“prefix”]
    -else
  • prefix = CONFIG[“prefix”]
    -end

ruby_install_name = CONFIG[“ruby_install_name”]
version = “/”+CONFIG[“MAJOR”]+"."+CONFIG[“MINOR”]
arch = “/”+CONFIG[“arch”]

-bindir = destdir+CONFIG[“bindir”]
-libdir = destdir+CONFIG[“libdir”]
-rubylibdir = destdir+CONFIG[“prefix”]+"/lib/ruby"+version
-archlibdir = rubylibdir+arch
-sitelibdir = destdir+CONFIG[“sitedir”]+version
-sitearchlibdir = sitelibdir+arch
-mandir = destdir+CONFIG[“mandir”] + “/man1”
+bindir = makevars[“bindir”] || destdir+CONFIG[“bindir”]
+libdir = makevars[“libdir”] || destdir+CONFIG[“libdir”]
+rubylibdir = makevars[“rubylibdir”] || destdir+prefix+"/lib/ruby"+version
+archlibdir = makevars[“archlibdir”] || rubylibdir+arch
+sitelibdir = makevars[“sitelibdir”] || destdir+CONFIG[“sitedir”]+version
+sitearchlibdir = makevars[“sitearchlibdir”] || sitelibdir+arch
+mandir = makevars[“mandir”] || destdir+CONFIG[“mandir”] + "/man1"
wdir = Dir.getwd

+#CONFIG.sort.each {|k,v| puts “#{k} => #{v}”}
File.makedirs bindir, true
File.install ruby_install_name+exeext,
"#{bindir}/#{ruby_install_name}#{exeext}", 0755, true
diff -r -U3 ruby-1.6.8/mkconfig.rb src/mkconfig.rb
— ruby-1.6.8/mkconfig.rb Thu Oct 31 18:40:10 2002
+++ src/mkconfig.rb Fri Apr 4 16:26:25 2003
@@ -107,9 +107,19 @@
end
val
end

  • CONFIG.each_value do |val|
  • Config::expand(val)
  • def Config::expand_all
  • CONFIG.each_value do |val|
  •  Config::expand(val)
    
  • end
  • end
  • expand = true
  • begin
  •  expand = false if CONFIG_NO_EXPAND
    
  • rescue NameError
  •  expand = true
    
    end
  • $stderr.puts “Auto-expanding” if expand
  • Config::expand_all if expand
    end
    EOS
    config.close

I hope so. It is a real problem when trying to do a binary
install. This is a typical distribution method in the
industry that I work in.

···

On Saturday, 5 April 2003 at 1:50:46 +0900, Mike Wyer wrote:

Ok,

Sorry, Jim, it won’t provide binary relocation, as the ruby binary
contains the path specified at configure time, not install time.

The only way I can see to support that is to insist on a fixed path that
can then be symlinked to the actual location, say /opt/ruby. In which
case, you can configure ruby to look in /opt/ruby but install it wherever
you like. In that case, this install patch would be useful.

Do you think Matz would be interested in this at all?


Jim Freeze

It is easier to change the specification to fit the program than vice
versa.