开发者

With a recursive makefile, how can I pass the object files folders up the calling make?

I'm building a project with a recursive Makefile. The basic format is simple: source files in various subdirectories, Makefile in the project root. Calling make from the project root will call all the makefile in the s开发者_JAVA百科ubdirectories. So far so good.

So now I've got object files. How can I make the main makefile see which object files live in the subdirectories, the better to pass them to the linker?


This is actually not a good approach (see recursive make considered harmful), because recursive makefiles adds the overhead of launching the Make program multiple times. You can actually accomplish the same thing, much faster, by including one Makefile from another rather than invoking it from another. If you include the make files from subdirectories, that will also solve the problem of your global make file seeing all of the files it needs in order to link them together. You can have a single variable that represents all the object files, and each make file that you include can append to this.

Also, allow me to suggest using CMake. It makes configuring your build mechanism significantly simpler and less error prone, but still allows you to build with Make (it generates Makefiles for you).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜