문제

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top