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?
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.