开发者

Makefile build source from 2 directory

开发者 https://www.devze.com 2023-02-08 01:40 出处:网络
I have 2 directories in main directory of project: src and utls I have makefile to build source and header file in src dir. Now in utils dir sets some *.c and *.h files which src files depend. How c

I have 2 directories in main directory of project:

src and utls

I have makefile to build source and header file in src dir. Now in utils dir sets some *.c and *.h files which src files depend. How can i build both开发者_运维百科 of this directories?

Thank you.


There are plenty of ways... For example you can build a library in utils dir, and depend on it in src. But it requires the rule how to rebuild the libutils and dependencies in src dir.

But if it doesn't worth the fuss, in higher level makefile just build utils, and then src, writing dependencies from utils headers to rebuild src .c and .h in case.


You can use make's -C option. Assume you are in the src dir from where you are trying to make. Your makefile will most probably have a target named 'all'. You can add the target utils to its list of dependencies.

all : utils

utils:
      make -C ../utils
0

精彩评论

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

关注公众号