Makefile include makefile from different directory

Deadly 提交于 2019-12-11 12:34:01

问题


I have two makefiles, directoryA/Makefile and directoryB/Makefile.

directoryA/Makefile depends on targets in a rather large and complex directoryB/Makefile.

I could do a recursive make

$(MAKE) -C directoryB

But that is undesirable for several reasons. Two big reasons: I make have to execute the makefile several times, and make can't correctly know when rebuilding a target is necessary.

I would like to use the include directive. The problem is twofold:

  1. The targets in directoryB/Makefile are all defined relative to that Makefile.

  2. Many commands depend on the working directory being directoryB.

Recursive make solves both of these problems, but with big disadvantages (mentioned earlier). Is there a way to solve both problems when using include?


回答1:


It's hard to say without seeing directoryA/Makefile, but another alternative is to have it include directoryB/Makefile, then

cd directoryB
make -f ../directoryA/Makefile


来源:https://stackoverflow.com/questions/22663753/makefile-include-makefile-from-different-directory

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!