# Doing rake-like stuff with mkmf?

**URL:** <https://www.ruby-forum.com/t/doing-rake-like-stuff-with-mkmf/106387>\
**Category:** Ruby\
**Created:** [June 9, 2007, 4:18pm UTC](https://www.ruby-forum.com/t/doing-rake-like-stuff-with-mkmf/106387 "2007-06-09T16:18:05Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Wincent\_C](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/7993a0/32.png) [@Wincent\_C](https://www.ruby-forum.com/u/Wincent_C)\
**Post date:** [June 9, 2007, 4:18pm UTC](https://www.ruby-forum.com/t/doing-rake-like-stuff-with-mkmf/106387/1 "2007-06-09T16:18:05Z")

</div>

Following the pattern I’ve seen in widespread use, I use rake in my  
Ruby projects for most high-level tasks (running specs, building gems  
etc) and mkmf to make C extension makefiles.

mkmf works great for the simple case where you just want to compile  
some C files and link to some libraries; the default behaviour seems  
to handle most things automatically.

But what if I want to do some more sophisticated rake-like stuff where  
I manually specify dependencies? For example:

- Start with ANTLR grammar file “Grammar.g”

- Whenever this file is updated, have to run ANTLR on it and this  
regenerates new “GrammarLexer.c” and “GrammarParser.c” files

- In this case want to rebuild the extension

Is there a way to do this using mkmf? Or do I have to manually tweak  
the generated Makefile myself?

Cheers,  
Wincent

---

<div class="post-metadata">

**Author:** ![Wincent\_C](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/7993a0/32.png) [@Wincent\_C](https://www.ruby-forum.com/u/Wincent_C)\
**Post date:** [June 11, 2007, 6:34am UTC](https://www.ruby-forum.com/t/doing-rake-like-stuff-with-mkmf/106387/2 "2007-06-11T06:34:50Z")

</div>

Hi,

At Sat, 9 Jun 2007 23:15:08 +0900,  
Wincent C. wrote in [ruby-talk:254933]:

> Is there a way to do this using mkmf? Or do I have to manually tweak  
> the generated Makefile myself?

create\_makefie in mkmf appends the content of “depend” file if  
it exists, so that you can add your own rules.

---

<div class="post-metadata">

**Author:** ![Wincent\_C](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/7993a0/32.png) [@Wincent\_C](https://www.ruby-forum.com/u/Wincent_C)\
**Post date:** [June 11, 2007, 10:15pm UTC](https://www.ruby-forum.com/t/doing-rake-like-stuff-with-mkmf/106387/3 "2007-06-11T22:15:45Z")

</div>

On 6/9/07, Wincent C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Cheers,  
> Wincent

There’s mkrf ([http://rubyforge.org/projects/mkrf](http://rubyforge.org/projects/mkrf)) aimed at replacing  
mkmf generated makefile with rakefile.
