./configure --libdir problem

B

Brian Candler

I've got a compilation issue.

If I set --libdir when compiling ruby-1.8.2, I find that ruby installs its
standard libraries in one place, but at runtime it looks for them in the
wrong place.

To demonstrate, let me build ruby like this:

# mkdir /opt /opt/lib /opt/include
...
$ ./configure --prefix=/opt/ruby --libdir=/opt/lib \
--with-cppflags=-I/opt/include --with-ldflags=-L/opt/lib
$ make
$ sudo make install

[the reason is to keep ruby together with the external libraries I need to
link it against]

Now, if I do this, I find that Ruby's libraries are installed here:

/opt/lib/ruby/1.8 # .rb files
/opt/lib/ruby/1.8/i386-freebsd5.3 # .so files

But the Ruby binary is searching for them elsewhere:

$ /opt/ruby/bin/ruby -e 'p $:'
["/opt/ruby/lib/ruby/site_ruby/1.8",
"/opt/ruby/lib/ruby/site_ruby/1.8/i386-freebsd5.3",
"/opt/ruby/lib/ruby/site_ruby",
"/opt/ruby/lib/ruby/1.8", # <<<< NOTE
"/opt/ruby/lib/ruby/1.8/i386-freebsd5.3", # <<<< NOTE
"."]

As a result, none of the ruby system libraries can be found:

$ /opt/ruby/bin/irb
/opt/ruby/bin/irb:10:in `require': No such file to load -- irb (LoadError)
from /opt/ruby/bin/irb:10

Now, I would have thought that setting --libdir would automatically update
rubylibdir and archdir, and in fact it has done so:

$ /opt/ruby/bin/ruby -rrbconfig -e 'p Config::CONFIG["rubylibdir"]'
"/opt/lib/ruby/1.8"
$ /opt/ruby/bin/ruby -rrbconfig -e 'p Config::CONFIG["archdir"]'
"/opt/lib/ruby/1.8/i386-freebsd5.3"

So, why is $: not set to the correct value? It seems that it the wrong value
exists in config.h:

$ grep RUBY_LIB *
config.h:#define RUBY_LIB "/opt/ruby/lib/ruby/1.8"

but it's not clear to me why that should be, since it's created from within
the ./configure script, which ought to have access to the --libdir
parameter. As far as I can tell it's an oversight, because RUBY_LIB_PREFIX
is derived directly from ${prefix}, not from ${libdir}.

Now, I'd be happy to work around this by setting rubylibdir to
/opt/ruby/lib/ruby/1.8
so that the library files are installed in the place where $: expects to
find them; however I can't see how to do this.

./configure --rubylibdir=/opt/ruby/lib/ruby/1.8 # gives an error
./configure --with-rubylibdir=/opt/ruby/lib/ruby/1.8 # has no effect

So I'm a bit stumped now. To summarise:

(1) "./configure --libdir=/foo" correctly updates rubylibdir so that
the .rb/.so files are installed there, but does not update RUBY_LIB
in config.h, so $: has the wrong path to those files.

And:

(2) I can't see a way from the ./configure line to set
CONFIG["rubylibdir"] independently of --libdir

Any suggestions for how I can work around this? Unfortunately, I do really
want to specify --prefix and --libdir separately for my particular file
layout.

Thanks,

Brian.
 
B

Brian Candler

--J2SCkAp4GZ/dPZZf
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

If I set --libdir when compiling ruby-1.8.2, I find that ruby installs its
standard libraries in one place, but at runtime it looks for them in the
wrong place.

I made a patch which seems to fix this for me - see below. (Note that I've
not run it through autoconf; I just edited configure and configure.in by
hand)

There is still the underlying issue that, in effect, the same value is being
calculated twice independently:

prefix/libdir --> ./configure ----> RUBY_LIB_PREFIX in config.h ---> $:
\
`--> mkconfig.rb --> rbconfig.rb
[rubylibdir]
\
`-> files installed
here

But at least, overriding --libdir now has (hopefully) the same effect on
both.

Regards,

Brian.

--J2SCkAp4GZ/dPZZf
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename=ruby-libdir

diff -uNr ruby-1.8.2.orig/configure.in ruby-1.8.2/configure.in
--- ruby-1.8.2.orig/configure.in Wed Dec 22 15:16:55 2004
+++ ruby-1.8.2/configure.in Thu Feb 17 19:08:26 2005
@@ -1386,15 +1386,15 @@
RUBY_LIB_PREFIX="/lib/ruby"
;;
*)
- RUBY_LIB_PREFIX="${prefix}/lib/ruby"
+ RUBY_LIB_PREFIX="${libdir}/ruby"
;;
esac
RUBY_LIB_PATH="${RUBY_LIB_PREFIX}/${MAJOR}.${MINOR}"

AC_ARG_WITH(sitedir,
- [ --with-sitedir=DIR site libraries in DIR [PREFIX/lib/ruby/site_ruby]],
+ [ --with-sitedir=DIR site libraries in DIR [LIBDIR/ruby/site_ruby]],
[sitedir=$withval],
- [sitedir='${prefix}/lib/ruby/site_ruby'])
+ [sitedir='${libdir}/ruby/site_ruby'])
SITE_DIR="`eval \"echo ${sitedir}\"`"
case "$target_os" in
cygwin*|mingw*|*djgpp*|os2-emx*)
diff -uNr ruby-1.8.2.orig/configure ruby-1.8.2/configure
--- ruby-1.8.2.orig/configure Sat Dec 25 10:58:38 2004
+++ ruby-1.8.2/configure Thu Feb 17 19:08:03 2005
@@ -875,7 +875,7 @@
--with-default-kcode=CODE specify default value for \$KCODE (utf8|euc|sjis|none)
--with-dln-a-out use dln_a_out if possible
--with-static-linked-ext link external modules statically
- --with-sitedir=DIR site libraries in DIR PREFIX/lib/ruby/site_ruby
+ --with-sitedir=DIR site libraries in DIR LIBDIR/ruby/site_ruby
--with-search-path=DIR specify the additional search path
--with-mantype=TYPE specify man page type; TYPE is one of man and doc

@@ -14961,7 +14961,7 @@
RUBY_LIB_PREFIX="/lib/ruby"
;;
*)
- RUBY_LIB_PREFIX="${prefix}/lib/ruby"
+ RUBY_LIB_PREFIX="${libdir}/ruby"
;;
esac
RUBY_LIB_PATH="${RUBY_LIB_PREFIX}/${MAJOR}.${MINOR}"
@@ -14972,7 +14972,7 @@
withval="$with_sitedir"
sitedir=$withval
else
- sitedir='${prefix}/lib/ruby/site_ruby'
+ sitedir='${libdir}/ruby/site_ruby'
fi;
SITE_DIR="`eval \"echo ${sitedir}\"`"
case "$target_os" in

--J2SCkAp4GZ/dPZZf--
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top