On Mon, 27 Sep 2004, Rudi Cilibrasi wrote: > 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 ===============================================================================