class Mkrf::Generator

Generator is concerned with taking configuration for an extension and writing a Rakefile to the local filesystem which will later be used to build the extension.

You will typically only create one Generator per extconf.rb file, which in turn will generate a Rakefile for building one extension module.

Usage

In the most basic usage, Generator simply takes the name of the library to compile:

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

Configuration of the build can be passed to the Generator constructor as a block:

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

It is also possible to specify the library paths in include_library

Mkrf::Generator.new('libxml') do |g|
  g.include_library('socket','socket', '/usr/local/lib/libxml')
end