Using mkmf.rb / extconf.rb and autoconf/automake together



  • 1. IE events and conflict with VB6 DLL
    I've written a ClickRecorder class that monitors the "onContextMenu" click events in Internet Explorer. It's working just fine. Then I put together a VB6 activex DLL that displays a simple dialog that queries the user for information about the web app control that fired the event. That information is added to the SQL Server table along with the other information about the control. The "onContextMenu" event handler creates an instance of the class in the DLL and is supposed to display the dialog. However, it's locking up IE. My thoughts are that the event monitoring bit is probably causing the problem. Has anyone done something like this before? TIA

Using mkmf.rb / extconf.rb and autoconf/automake together

Postby Rudi Cilibrasi » Wed, 19 May 2004 04:25:06 GMT

Hi everybody,

I'm having trouble understanding how to use the mkmf module properly,
especially in conjunction with autoconf / automake.

I would like to use extconf.rb to generate the Makefile in my ext/
directory, but there are problems.  For instance, the generated Makefile
does not support the check: target, and so when somebody types
make check
at the top of my source tree it fails when recursively doing make check's
in each of the subdirs because there is no such target in the ext/ directory.
Another problem is how to pass on options like
./configure --prefix $HOME/mystuff/installpath
What is the "accepted" way to handle installation-directory overrides like
this using mkmf.rb?  What about an override of the CC for cross-compilation?
So far, what I've done is run extconf.rb and then edited the resulting
Makefile, surely there is a better way?

Any pointers to good examples of a combination autoconf / automake / extconf.rb
that supports the features above would be greatly appreciated.  I would also
appreciate any doc pointers.  Cheers,


Rudi Cilibrasi
Machine Learning Researcher
 http://www.**--****.com/ ~cilibrar/

Re: Using mkmf.rb / extconf.rb and autoconf/automake together

Postby Tim Hunter » Wed, 19 May 2004 06:01:31 GMT

The RMagick ( http://www.**--****.com/ ) installation procedure uses a
combination of autoconf/configure and Minero Aoki's setup.rb script
( http://www.**--****.com/ ).

RMagick's configure script constructs a custom Makefile and a custom
extconf.rb. The targets in the top-level Makefile run the appropriate
setup.rb steps. The setup.rb script runs the custom extconf.rb and then
calls make on the Makefile that extconf.rb generated.

Convoluted, but it's reliable and flexible.

The actual code is probably easier to understand than my poor description.
Check out the RMagick CVS:

Of course feel free to ask questions.

Re: Using mkmf.rb / extconf.rb and autoconf/automake together

Postby nobu.nokada » Wed, 19 May 2004 09:46:27 GMT


At Tue, 18 May 2004 04:33:52 +0900,
Rudi Cilibrasi wrote in [ruby-talk:100551]:

Add check: target to ext/depend file.

An extension library's installation directory is fixed as
supplied by rbconfig.rb, and CC must match with ruby's one.
You need proper rbconfig.rb to cross-compile.

Nobu Nakada

Re: Using mkmf.rb / extconf.rb and autoconf/automake together

Postby Rudi Cilibrasi » Fri, 21 May 2004 05:29:30 GMT

k very good, I have just a few more questions:

I was referred to RMagick as a good example to follow, and it does use
autoconf but not automake. Does anybody know of one example ruby program
that uses autoconf and automake, as most Gnu utilities now do, in combination
with any of the standard Ruby installation methods? I would
like to see details of how people have interfaced the two, because it seems
nearly impossible to do elegantly.

I have read that the setup.rb script scans the directories such as bin/
and installs everything in these directories. Isn't this incompatible
with autoconf / automake? For example, in automake, I specify explicitly
what programs to compile, which files are in the source distribution, and
anything that is not listed is not used. Is there some way to tell the
setup.rb script to only install some of the files in the bin/ directory?
The exact case of this problem is visible in one of my packages that you
can download from
Here, I solve the
script problem by using autoconf to first determine where Ruby is installed,
then using @RUBYBIN@ type autoconf substitutions to convert my shell
scripts that start with names like
and become (when translated and variable-substituted)
with the correct line on top. It seems the setup.rb script duplicates this
functionality to some extent. Unfortunately, since I keep my .in files
in the bin/ directory along with the "final" versions of my scripts, I
am afraid setup.rb would incorrectly install my files such as
in the installation bin/ directory, and this is not what I want. I only
want 1/2 the files in there to be installed, and I want to say which ones

In article < XXXX@XXXXX.COM > you wrote:

Thanks for these answers Nobu. I am afraid I still do not totally understand
the solution to my problems however.
My complearn project is written to build under Windows (MinGW) or Linux.
I have a shell script there, "scripts/makeall.zsh",
that builds a .tar.gz source
distribution, a Debian package, and a Windows version using the MinGW
cross-compiler and Inno Setup, then uses ncftpput to ftp send the new
version up to SourceForge. It works well enough now, but you will see I
needed to pre-generate a Makefile under Windows (using ruby extconf.rb now)
and then edit it by hand in order to get this to work correctly. This is
obviously going to be painful to maintain over time as Ruby and my project
change, because I will have to remodify this Makefile by hand.
I have read through the small documentation I can find on setup.rb and
still cannot understand what is the correct way for me to structure this
project, or even how to tell it not to use gcc but instead
CC = i586-mingw32msvc-gcc
when cross-compiling? Right now, I use a command like the following in
my "" shell script to build a Windows version under Linux:

./configure --enable-winbuild --prefix=@TOPDIR@/scripts/buildtmp


And then within my


AC_ARG_ENABLE(winbuild, "Cross compile for windows MinGW/MSYS", winbuild=true,

Similar Threads:

1.[Ruby Forum] Ruby extconf.rb / autoconf (in?)compatibility

2.Ruby extconf.rb / autoconf (in?)compatibility

Hi again everybody,
Unfortunately, Tim's solution is proving to be hard to understand; it
really isn't a simple system he's made, and his configuration scripts
have so many dependencies that I can't even get the package to
configure on
my Debian unstable system.  I am working with Tim privately via email
to try to get the problems installing his stuff straightened out, but
while we do this I would like to reiterate the question:
Is there any way to adjust the installation-paths that will be used
in the Makefile generated by ruby extconf.rb ?  

Nobu has already pointed out that the problem is that these paths are 
determined at ruby install time. I also reached the same conclusion
some time ago.  The question is how do I fix it?
The reason I need to do it is so that a non-root user can install
my software package in their home directory.  Is this simply
in the current system?  DESTDIR is not a complete solution because it
not offer enough flexibility in customizing the paths.  To me this
to suggest a basic functionality void in the ruby installation system.
What is the right way to do it?  It seems to much to ask someone to
install their own version of ruby in their homedir just so they can
packages using mkmf / extconf.rb.
One idea that occured to me is to create a customized rbconfig.rb to
override the standard one, but I am not even sure how to do this
actually overwriting the real systemwide rbconfg.rb file.  Is there
way to load my own custom rbconfig.rb instead of the default one that
is system wide so that extconf.rb will install my package in different
I really need help with this problem as it has been troubling me for
a year, and none of my Ruby projects are packaged well enough for the
users I am targetting.  It's really the only limitation I have had
serious trouble with so far.  I would hate to redo much of the
of extconf.rb but it seems like something like this will be necessary
unless we can figure out
a) is there critical functionality missing from the current mkmf
(or am I just missing a simpler solution?)
b) what can we do to fix it?

3.Ruby extconf.rb and autoconf (in?)compatibility

I have made a software packagae, complearn-0.6.2.tar.gz , 
that uses autoconf and automake to manage system configuration. One of
the standard options is:
./configure --prefix=$HOME/wherever/placetoinstall 

In many autoconf or automake enabled software packages written in C
(such as GNU / FSF utilities) this creates subdirectories like
$HOME/wherever/placetoinstall/bin for executables 
$HOME/wherever/placetoinstall/lib for libraries 
$HOME/wherever/placetoinstall/man for manual_pages 

and so on for many common naming conventions. 

Unfortunately I cannot understand how to correctly pass this option on
to ruby mkmf:
ruby extconf.rb 

I have seen that there is an option to make using 
a DESTDIR variable such as: 
make DESTDIR=$HOME/wherever/placetoinstall 

but then this creates deep directory structure 

and to me it seems that the /usr/local portion of the above path
structure is redundant. Is there a way to remove it in the ruby mkmf
extconf.rb structure? The best I can come up with so far is to use an
mv and then an rm command to correct things, and this seems somewhat
complicated and error-prone.

Is there a better solution to this problem?

Thanks for any help you can provide,


4.How do I tell extconf.rb/mkmf NOT to try and use cl.exe

5.extconf.rb >> mkmf

6. static libraries with extconf.rb/mkmf

7. Package, a future replacement for setup.rb and mkmf.rb

8. Packaging pure ruby files when using extconf.rb

Return to ruby


Who is online

Users browsing this forum: No registered users and 6 guest