[Ruby Forum] Ruby extconf.rb / autoconf (in?)compatibility

A

Alexey Verkhovsky

To all who said that Ruby Forum was a good idea (and all who said it
wasn't, and all who said nothing) : please help.

Unanswered question from http://www.ruby-forum.org/bb/viewtopic.php?t=53

----

I have made a software packagae, complearn-0.6.2.tar.gz ,
that uses autoconf and automake to manage system configuration. One of
the standard options is:
/configure --prefix=$HOME/wherever/placetoinstall

In many autoconf or automake enabled software packages written in C
(such as GNU / FSF utilities) this creates subdirectories like
$HOME/wherever/placetoinstall/bin for executables
$HOME/wherever/placetoinstall/lib for libraries
$HOME/wherever/placetoinstall/man for manual_pages

and so on for many common naming conventions.

Unfortunately I cannot understand how to correctly pass this option on
to ruby mkmf:
ruby extconf.rb
make

I have seen that there is an option to make using
a DESTDIR variable such as:
make DESTDIR=$HOME/wherever/placetoinstall

but then this creates deep directory structure
$HOME/wherever/placetoinstall/usr/local/lib/site_ruby/1.8/CompLearnLib

and to me it seems that the /usr/local portion of the above path
structure is redundant. Is there a way to remove it in the ruby mkmf
extconf.rb structure? The best I can come up with so far is to use an mv
and then an rm command to correct things, and this seems somewhat
complicated and error-prone.

Is there a better solution to this problem?
 
N

nobu.nokada

Hi,

At Sat, 25 Sep 2004 04:32:49 +0900,
Alexey Verkhovsky wrote in [ruby-talk:113667]:
Unfortunately I cannot understand how to correctly pass this option on
to ruby mkmf:
ruby extconf.rb
make

They are decided at configuration time of ruby, but not at
extconf.
I have seen that there is an option to make using
a DESTDIR variable such as:
make DESTDIR=$HOME/wherever/placetoinstall

but then this creates deep directory structure
$HOME/wherever/placetoinstall/usr/local/lib/site_ruby/1.8/CompLearnLib

and to me it seems that the /usr/local portion of the above path
structure is redundant. Is there a way to remove it in the ruby mkmf
extconf.rb structure? The best I can come up with so far is to use an mv
and then an rm command to correct things, and this seems somewhat
complicated and error-prone.

DESTDIR is used to install files in a fake root by package
management systems.
 
R

Rudi Cilibrasi

Hi again everybody,

Unfortunately, Tim's solution is proving to be hard to understand; it
really isn't a simple system he's made, and his configuration scripts
have so many dependencies that I can't even get the package to
configure on
my Debian unstable system. I am working with Tim privately via email
to try to get the problems installing his stuff straightened out, but
while we do this I would like to reiterate the question:

Is there any way to adjust the installation-paths that will be used
in the Makefile generated by ruby extconf.rb ?

Nobu has already pointed out that the problem is that these paths are
determined at ruby install time. I also reached the same conclusion
some time ago. The question is how do I fix it?
The reason I need to do it is so that a non-root user can install
my software package in their home directory. Is this simply
impossible
in the current system? DESTDIR is not a complete solution because it
does
not offer enough flexibility in customizing the paths. To me this
seems
to suggest a basic functionality void in the ruby installation system.
What is the right way to do it? It seems to much to ask someone to
install their own version of ruby in their homedir just so they can
install
packages using mkmf / extconf.rb.

One idea that occured to me is to create a customized rbconfig.rb to
override the standard one, but I am not even sure how to do this
without
actually overwriting the real systemwide rbconfg.rb file. Is there
some
way to load my own custom rbconfig.rb instead of the default one that
is system wide so that extconf.rb will install my package in different
paths?

I really need help with this problem as it has been troubling me for
over
a year, and none of my Ruby projects are packaged well enough for the
users I am targetting. It's really the only limitation I have had
serious trouble with so far. I would hate to redo much of the
functionality
of extconf.rb but it seems like something like this will be necessary
unless we can figure out

a) is there critical functionality missing from the current mkmf
system?
(or am I just missing a simpler solution?)

and

b) what can we do to fix it?

Cheers,

Rudi
 
H

HOWARD ARA T

Is there any way to adjust the installation-paths that will be used in the
Makefile generated by ruby extconf.rb ?

what's wrong with this:

~/tmp > cat a.c
#include <stdio.h>
void Init_a()
{
printf ("42\n");
}

~/tmp > cat extconf.rb
require 'mkmf'
create_makefile 'a'

~/tmp > make
gcc -fPIC -g -O2 -I. -I/usr/local/lib/ruby/1.8/i686-linux -I/usr/local/lib/ruby/1.8/i686-linux -I. -c a.c
gcc -shared -L"/usr/local/lib" -o a.so a.o -ldl -lcrypt -lm -lc

~/tmp > make install prefix=`pwd`
install -c -p -m 0755 a.so /home/ahoward/tmp/lib/ruby/site_ruby/1.8/i686-linux

~/tmp > ls ./lib/ruby/site_ruby/1.8/i686-linux/a.so
./lib/ruby/site_ruby/1.8/i686-linux/a.so

~/tmp > ruby -r ./lib/ruby/site_ruby/1.8/i686-linux/a.so -e';'
42

'make' allows to to set anything you want from the command line already -
bindir, sbindir, datadir, etc. what more could you need to set?

One idea that occured to me is to create a customized rbconfig.rb to override
the standard one, but I am not even sure how to do this without actually
overwriting the real systemwide rbconfg.rb file. Is there some way to load
my own custom rbconfig.rb instead of the default one that
is system wide so that extconf.rb will install my package in different
paths?

it seems simpler to create a little script which calls make overriding the
makefile defaults. eg.

~/tmp > cat install.rb
require 'getoptlong'

makeopts = {}
opts = GetoptLong.new(
[ "--ruby", "-r", GetoptLong::REQUIRED_ARGUMENT ],
[ "--make", "-m", GetoptLong::REQUIRED_ARGUMENT ],
[ "--prefix", "-p", GetoptLong::REQUIRED_ARGUMENT ],
[ "--datadir", "-d", GetoptLong::REQUIRED_ARGUMENT ]
).each{|o, a| makeopts[o[%r/[^-].*/]] = a}

mode = ARGV.shift
argv = ARGV.join ' '
ruby = makeopts.delete('ruby') || 'ruby'
make = makeopts.delete('make') || 'make'
mopt = makeopts.map{|kv| kv.join '='}.join(' ')

cmd =
case mode
when /config/
"#{ ruby } extconf.rb #{ argv }"
when /setup/
"#{ make } #{ mopt } #{ argv }"
when /install/
"#{ make } install #{ mopt } #{ argv }"
else
"#{ make } #{ mode } #{ mopt } #{ argv }"
end

STDERR.puts "cmd <#{ cmd.strip }>"
$VERBOSE=nil
system cmd

~/tmp > ruby install.rb clean
cmd <make clean>

~/tmp > ruby install.rb configure
cmd <ruby extconf.rb>

creating Makefile
~/tmp > ruby install.rb setup
cmd <make>
gcc -fPIC -g -O2 -I. -I/usr/local/lib/ruby/1.8/i686-linux -I/usr/local/lib/ruby/1.8/i686-linux -I. -c a.c
gcc -shared -L"/usr/local/lib" -o a.so a.o -ldl -lcrypt -lm -lc

~/tmp > ruby install.rb install --prefix=/tmp/foo/bar/
cmd <make install prefix=/tmp/foo/bar/>
install -c -p -m 0755 a.so /tmp/foo/bar//lib/ruby/site_ruby/1.8/i686-linux

in short, i think the 'make' program itself already supports all that you want
and the ruby generated makefiles are very well behaved so all that's left is to
design the interface you want and to, perhaps, have default values for things
like 'prefix', etc... i understand that you are trying to accomplish this at
the configuration stage, but this is is really a detail - what you want to do
can be done, just not at the configuration stage. if you HAD to do it at the
configuration stage it would be trivial to take the mopts above and munge the
generated Makefile using them after the configure step.

kind regards.

-a
--
===============================================================================
| EMAIL :: Ara [dot] T [dot] Howard [at] noaa [dot] gov
| PHONE :: 303.497.6469
| A flower falls, even though we love it;
| and a weed grows, even though we do not love it. | --Dogen
===============================================================================
 
M

Michal 'hramrach' Suchanek

There is setup.rb which is used by some ruby extensions to do the
configure/build/install stuff. I think it is quite flexible and accepts
arguments for specifying all these paths. The minor problem is that the
arguments have names that differ from the auto* argument names so one
has to figure out which argument is which.
At least this is my experience with install.rb/setup.rb of the
extensions I tried to install.

Thanks

Michal Suchanek
 
R

Rudi Cilibrasi

Ah my faith in Ruby is restored. Thanks for the make tip Howard;
although it was right in front of me, for some reason I didn't see
this simple solution. Also thanks for the setup.rb tip Michal, I
think finally I can see a solution to my installation problems. I
will repackage my stuff using these techniques and post again if there
are any more problems. Thanks again for the useful help from
everyone. Cheers,

Rudi
 

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

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top