有多个子模块,他们都各自提供了自己的Makefile文件。
我推荐的一种组织方式是:
比如有工程A,B,C
我的Makefile组织方式是
~~~~~~~~~~~~~~
./Makefile (总Makefile)
./A/Makefile (子Makefile)
./B/Makefile (子Makefile)
./C/Makefile (子Makefile)
总Makefile的实现
~~~~~~~~~
# include sub makefile
include A/Makefile
include B/Makefile
include C/Makefile
# define grobal vars
DBG_TARGETS =debug_a \
debug_b \
debug_c
REL_TARGETS =release_a \
release_b \
release_c
CLN_TARGETS =clean_a \
clean_b \
clean_c
# define targets
debug : $(DBG_TARGETS)
release : $(REL_TARGETS)
clean : $(CLN_TARGETS)
子Makefile的实现
~~~~~~~~~
# define targets of a
debug :
echo "build debug version of a"
release :
echo "build release version a"
clean :
echo "clean a"
这种组织方式的好处
~~~~~~~~~~~~
1)简单,每个子模块只维护自己的Makefile文件,只需要提供
预定义好的target即可
2)target可重用,比如我可以通过make release_a获得a模块
的release版本
阅读(1810) | 评论(0) | 转发(0) |