Rbconfig.rb and DESTDIR confusion while cross-compiling Ruby gems

Hello,

I’m trying to cross-compile Nokogiri from one Linux platform to another.
After a lot of digging around (especially since I’m new to Ruby), I went
with the following approach:

  1. Cross-compile a version of Ruby for the target platform. This
    cross-compiled Ruby will contain a file called rbconfig.rb that contains
    build information (compiler flags used, paths to standard directories,
    etc.). This build information is used when building native extensions.

  2. Configure (produce a Makefile for) Nokogiri’s native extension by
    running the following command in Nokogiri’s root (with irrelevant flags
    left out):

    ruby -Cext/nokogiri -I<dir_of_rbconfig.rb> extconf.rb …

The ‘ruby’ used here is the native one, not the cross-compiled one, but
rbconfig.rb comes from the cross-compiled ‘ruby’. The native and
cross-compiled rubies are the same version. extconf.rb uses mkmf to
build the Makefile, and mkmf in turn uses build information from
rbconfig.rb.

  1. Build the native extension as follows:

    make -Cext/nokogiri

This approach seems to almost work, but runs into trouble for one
reason: The cross-compiled Ruby is installed into a custom sysroot
directory (with e.g. the main ruby executable at
/home/ulf/target-sysroot/usr/bin/ruby), while the paths in rbconfig.rb
seem to assume installation into / (where the ruby executable would be
at /usr/bin/ruby).

The variable DESTDIR (not to be confused with $(DESTDIR), which comes
from the Makefile) in rbconfig.rb looks promising, but is not sufficient
as it is not prepended to e.g. CONFIG[“libdir”].

The generated Makefile also has a DESTDIR. Just setting DESTDIR in the
Makefile won’t work though as mkmf needs correct paths when looking for
headers and the like during configuration.

After the above mind dump, my questions are as follows:

  • Is rbconfig.rb’s DESTDIR meant to solve problems like this? What
    exactly is its purpose?

  • Why is there an additional DESTDIR in the Makefile? Is its purpose
    different?

Thanks,
Ulf

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs