Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
UNOFFICIAL mirror of mkrf subversion repo
C Ruby Shell
Tree: 62cdf94ffa

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
lib
test
CHANGELOG
MIT-LICENSE
README
Rakefile
TODO

README

= mkrf -- making C extensions for Ruby a bit easier

<tt>mkrf</tt> is intended to replace <tt>mkmf</tt> which is a library for building
Makefiles to build C extensions to Ruby. The major differences between the two is
that +mkrf+ builds you a Rakefile instead of a Makefile, and also that +mkrf+
provides an object-oriented interface.

Major goals of mkrf are
* easy code reuse of its <tt>Availability</tt> class and
* simple, well documented, use of the <tt>Generator</tt> class.

== Basic Usage

<tt>mkrf</tt> works similarly to <tt>mkmf</tt> in that a user writes an
extension configuration file (usually named <tt>extconf.rb</tt>) and then runs
it (<tt>ruby ./extconf.rb</tt>), which generates a <tt>Rakefile</tt> in the
current directory.

In general, <tt>extconf.rb</tt> should be placed in the root directory of the 
extension (ex. <tt>PROJECT_ROOT/ext/<i>name_of_module</i></tt>) and it expects,
by default, that files to be compiled have a <tt>.c</tt> extension and reside in
that same directory. If your project contains multiple extension modules, then
each one would get its own subdirectory under <tt>PROJECT_ROOT/ext/</tt> and
have its own <tt>extconf.rb</tt> file.

The most basic usage looks like the following, where the name of the extension
module being built is "libtrivial":

  require 'mkrf'
  Mkrf::Generator.new('libtrivial')

Extra arguments may be passed to the Rakefile generator in a block:
  
  Mkrf::Generator.new('libtrivial') do |g|
    g.logger.level = Logger::WARN
    g.include_library('z')
  end

Another example:

  Mkrf::Generator.new('libxml') do |g|
    g.include_library('socket','socket')
    g.include_header('libxml/xmlversion.h', 
                     '/opt/include/libxml2', 
                     '/usr/local/include/libxml2', 
                     '/usr/include/libxml2')
  end


== Credits
* Jim Weirich for writing Rake

== Licence
mkrf is available under an MIT-style license.

Copyright (c) 2006 Kevin Clark

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Something went wrong with that request. Please try again.