2

In my extconf.rb, I have

$srcs = %w{foo.cpp bar.cpp}
$objs = %w{foo bar} 

Each of these is dependent upon multiple header files. If I touch foo.cpp or touch bar.cpp, and then do rake compile, it recompiles the appropriate object file.

But touching a .h file doesn't have the same effect, obviously. I can't remember if this is a symptom of my use of extconf.rb or just a fact of coding in C/C++.

Is there some way I can direct extconf.rb to write a makefile that is aware of these header files?

Translunar
  • 3,739
  • 33
  • 55

1 Answers1

1

You don't do it directly within the extconf.rb; for whatever reason, mkmf uses a separate file, named depend, to specify these sorts of things. You put all of your dependencies in the same form you would if you were writing a makefile by hand; so, for a file foo.cpp that used client.h and wombat.h, you would add the following line to depend:

foo.o: client.h wombat.h`

In the process of building your Makefile, mkmf will copy the contents of that file into your Makefile, causing those rules to be honoured as part of the build process.

womble
  • 12,033
  • 5
  • 52
  • 66
  • Wow. Thank you so much. I had no idea that's what the `depend` file did, but now that you say it, I remember seeing that in lots of projects. Good to know. – Translunar Nov 02 '14 at 01:45