Mkrf 0.1.0 released

I’m pleased to announce that tonight marks the first release of mkrf,
a library which generates Rakefiles to build C extensions to Ruby and
is aimed at a replacement for mkmf. This is a Ruby Summer of Code
project (http://code.google.com/soc/ruby/about.html).

Though the gem doesn’t seem to have propogated yet, it should be
availble through rubygems, and until then you can download the gem
directly at http://rubyforge.org/frs/download.php/11283/mkrf-0.1.0.gem

The code does have RDoc included which I hope explains things well
enough. Please do send questions and bug reports my way. I’ll have a
project setup at advisr.org where you can submit bug reports as soon
as I tweak its source to properly scope accounts, but until then email
is fine.

Please do try mkrf with your extensions. Please do send feedback.

As for syntax, it can be as simple as:

Mkrf::Generator.new(‘libtrivial_so.bundle’)

or more complex:

Mkrf::Generator.new(‘libxml_so.bundle’, ‘*.c’) do |g|
g.include_library(‘socket’,‘socket’)
g.include_header(‘libxml/xmlversion.h’,
‘/opt/include/libxml2’,
‘/usr/local/include/libxml2’,
‘/usr/include/libxml2’)
end

Kevin,

This looks like it will be really useful.

One place where the mkmf does not work is trying to build extensions
with MingW on Windows with a Ruby version compiled by VC++. The problem
is that mkmf assumes you are using VC++ to build your extensions
(because it grabs the library info from rbconfig), but aren’t.

Note that using MingW to build extensions works fine if you’re willing
to create your own makefiles - which is what I’ve done for the Ruby
GDAL bindings, Ruby GEOS bindings and for ruby-prof for Windows. What
would be a lot better is if I could put together a mkrf rake script,
integrated with Ruby Gems, that was smart enough to:

  • Build on Linux
  • Build on Windows with VC++
  • Build on Windows with MingW (you might also need msys).

I assume you’ve looked at Python’s distutils? If not, take a look. It
has knowledge built into it about MingW on Windows well as VC++. It
would be good to end up with something like it.

Thanks,

Charlie

Hey Charlie,
Right now I’m sure mkrf breaks in various situations. If you’ve got a
setup that you can test on, please feel free to tell me what’s broken
or submit patches. That being said, I’ll try to duplicate some of
those setups using Parallels and see what can be done.

Kevin

Hi Kevin,

I would like to test ‘mkrf’ with libcurl but I’m a bit lost. I think
you expect that people have already used mkmf ? Would it be possible
that you make a mini HOWTO ?


Cheers,
zimbatm

http://zimbatm.oree.ch

Dimitri,
I’ll look into making paths with and without the ‘/’ work. Thanks for
checking it out! Keep an eye out for the next release.
Kev

Jonas,
I’m moving today and tomorrow, but I’ll try to write up a quick guide
this weekend on my blog, http://glu.ttono.us.

Kev

Hi Kevin,

On 6/28/06, Kevin C. [email protected] wrote:

Please do try mkrf with your extensions. Please do send feedback.

I was able to compile teius, the libxml wrapper, like so:

require ‘mkrf’
Mkrf::Generator.new(’…/lib/teius.so’,‘teius.c’) do |g|
g.include_header(‘libxml/parser.h’,’/usr/include/libxml2/’)
g.include_header(‘libxml/tree.h’,’/usr/include/libxml2/’)
g.include_header(‘libxml/xpath.h’,’/usr/include/libxml2/’)
g.include_library(‘xml2’)
g.include_library(‘xslt’)
end

rake

Great! One thing, though: the ‘path’ in ‘include_header’ has to have a
‘/’
at the end, or else it’s not added to the INCLUDES. This is error-prone
and
inconsistent to how includes are written on the command-line.

It did better than the standard ‘gem install teius’, which did not find
the
includes properly on my system (the Makefile has ‘/usr/include/libxml’).

Nice tool!

  • Dimitri

Dan,
Most significantly, mkrf generates -Rakefiles-, not Makefiles. Because
I’m making Rakefiles it opens up a lot of functionalities that mkmf2
couldn’t implement easily (gem packaging, rdoc generation built in
etc.). Also, as far as I know, mkmf2 isn’t aiming for reuse of its
code. One of my goals is to make the Availability code clean and
simple enough that things like RubyGems can use it easily.

Kev

Kevin C. wrote:

enough. Please do send questions and bug reports my way. I’ll have a
or more complex:

Mkrf::Generator.new(‘libxml_so.bundle’, ‘*.c’) do |g|
g.include_library(‘socket’,‘socket’)
g.include_header(‘libxml/xmlversion.h’,
‘/opt/include/libxml2’,
‘/usr/local/include/libxml2’,
‘/usr/include/libxml2’)
end

Hm, what’s the difference between this and mkmf2?

Thanks,

Dan

This communication is the property of Qwest and may contain confidential
or
privileged information. Unauthorized use of this communication is
strictly
prohibited and may be unlawful. If you have received this communication
in error, please immediately notify the sender by reply e-mail and
destroy
all copies of the communication and any attachments.

On 6/30/06, Kevin C. [email protected] wrote:

Dan,
Most significantly, mkrf generates -Rakefiles-, not Makefiles. Because
I’m making Rakefiles it opens up a lot of functionalities that mkmf2
couldn’t implement easily (gem packaging, rdoc generation built in
etc.). Also, as far as I know, mkmf2 isn’t aiming for reuse of its
code. One of my goals is to make the Availability code clean and
simple enough that things like RubyGems can use it easily.

Kev

Ah, ok. Thanks Kevin.

Dan

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