mkmf.rb Documentation

Discussion in 'Ruby' started by Brian Schröder, Feb 1, 2005.

  1. Hello Group,

    does there exist a mkmf.rb documentation except for the page in the pickaxe? The code is not very readable and I have found nothing so far?

    At the moment I am wondering if it is possible to generate Makefiles for the following task:

    For an extension baz I have a directory structure like this:

    baz/
    baz/src/
    baz/src/baz.rb
    baz/src/baz.base.c
    baz/src/foo/
    baz/src/foo/foo.rb
    baz/src/foo/foo.base.c
    baz/src/bar/
    baz/src/bar/bar.rb
    baz/src/bar/bar.base.c

    and I want mkmf to create makefiles that compile and copy the files to:

    baz/lib/
    baz/lib/baz.rb
    baz/lib/baz.base.so
    baz/lib/baz/foo.rb
    baz/lib/baz/foo.base.so
    baz/lib/baz/bar.rb
    baz/lib/baz/bar.base.so

    such that I can require my extensions as

    require 'baz'
    require 'baz/foo'
    require 'baz/bar'

    when I include the lib directory in the ruby search path.

    thanks a lot,

    Brian
    Brian Schröder, Feb 1, 2005
    #1
    1. Advertising

  2. Brian Schröder wrote:
    > does there exist a mkmf.rb documentation except for the page in the
    > pickaxe? The code is not very readable and I have found nothing so
    > far?


    It's not exactly what you asked, but have you seen
    http://i.loveruby.net/en/man/setup/index.html? That's what I've used to
    package extension libraries.

    Steve
    Steven Jenkins, Feb 2, 2005
    #2
    1. Advertising

  3. Brian,

    Brian Schröder wrote:
    > Hello Group,
    >
    > does there exist a mkmf.rb documentation except for the page in the

    pickaxe? The code is not very readable and I have found nothing so far?
    >
    > At the moment I am wondering if it is possible to generate Makefiles

    for the following task:
    >
    > For an extension baz I have a directory structure like this:
    >
    > baz/
    > baz/src/
    > baz/src/baz.rb
    > baz/src/baz.base.c
    > baz/src/foo/
    > baz/src/foo/foo.rb
    > baz/src/foo/foo.base.c
    > baz/src/bar/
    > baz/src/bar/bar.rb
    > baz/src/bar/bar.base.c
    >

    So I assume you have a *.base.so file for each *.base.c file. Then you
    should have a 'extconf.rb' file for each of these .so files. ie.
    insert
    baz/src/extconf.rb
    baz/src/foo/extconf.rb
    baz/src/bar/extconf.rb

    > and I want mkmf to create makefiles that compile and copy the files

    to:

    Not really a job for 'mkmf.rb'... see below.

    >
    > baz/lib/
    > baz/lib/baz.rb
    > baz/lib/baz.base.so
    > baz/lib/baz/foo.rb
    > baz/lib/baz/foo.base.so
    > baz/lib/baz/bar.rb
    > baz/lib/baz/bar.base.so
    >
    > such that I can require my extensions as
    >
    > require 'baz'
    > require 'baz/foo'
    > require 'baz/bar'
    >
    > when I include the lib directory in the ruby search path.
    >

    This part is a job for 'setup.rb'. Put setup.rb in baz/ and create the
    file 'pre-config.rb'.
    Your 'pre-config.rb' file will do the following
    For src/ and each directory in src/
    1) run extconf.rb
    2) run make
    3) copy the .rb and .so files in the directory to baz/lib/baz/-d-/
    where -d- is the current directory above src/

    Seems like you cleaverly use Dir.[], Dir.chdir(), and system() to do
    all this in a few lines of code.

    -Charlie
    Charles Mills, Feb 2, 2005
    #3
  4. s/you cleaverly/you can cleverly/
    Charles Mills, Feb 2, 2005
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Cameron Laird
    Replies:
    1
    Views:
    639
    Josiah Carlson
    Apr 3, 2004
  2. Kenneth McDonald
    Replies:
    2
    Views:
    710
  3. Replies:
    1
    Views:
    1,195
    Andy Dingley
    Sep 16, 2006
  4. Kero van Gelder

    mkmf documentation?

    Kero van Gelder, Aug 2, 2003, in forum: Ruby
    Replies:
    2
    Views:
    93
    Kero van Gelder
    Aug 3, 2003
  5. Replies:
    0
    Views:
    123
Loading...

Share This Page