From: Daniel Berger Date: 2007-11-11T06:46:30+09:00 Subject: [PATCH] mkmf.rb and create_makefile - important for rubygems Hi, The following patch explains the significance of the second argument to the create_makefile method. I believe this patch is crucial, because rubygems uses the target_prefix internally, which affects how rubygems creates and installs C extensions. Submitted on the tracker at: http://rubyforge.org/tracker/index.php?func=detail&aid=15536&group_id=426&atid=1700 Thanks, Dan C:\diff -u mkmf.orig mkmf.rb --- mkmf.orig Tue Aug 21 19:24:50 2007 +++ mkmf.rb Sat Nov 10 14:20:28 2007 @@ -1150,6 +1150,37 @@ # load the file within a Ruby program later, that directory structure will # have to be followed, e.g. "require 'test/foo'". # +# The +srcprefix+ should be used when your source files are not in the same +# directory as your build script. This will not only eliminate the need for +# you to manually copy the source files into the same directory as your build +# script, but it also sets the proper +target_prefix+ in the generated +# Makefile. +# +# Setting the +target_prefix+ will, in turn, install the generated binary in +# a directory under your Config::CONFIG['sitearchdir'] that mimics your local +# filesystem when you run 'make install'. +# +# For example, given the following file tree: +# +# ext/ +# extconf.rb +# test/ +# foo.c +# +# And given the following code: +# +# create_makefile('test/foo', 'test') +# +# That will set the +target_prefix+ in the generated Makefile to 'test'. That, +# in turn, will create the following file tree when installed via the +# 'make install' command: +# +# /path/to/ruby/sitearchdir/test/foo.so +# +# It is recommended that you use this approach to generate your makefiles, +# instead of copying files around manually, because some third party +# libraries may depend on the +target_prefix+ being set properly. +# def create_makefile(target, srcprefix = nil) $target = target libpath = $DEFLIBPATH|$LIBPATH