Ste*_*rke 6 makefile gnu-make multiple-makefiles
我有一个设置,其中make通过一堆子目录并在这些目录中进行.我希望它立即停止构建失败.下面的代码片段说明了这一点.有人能指出我应该如何设置makefile的正确方向,或者有关从顶层到子目录构建的文档?
SUBDIRS = \
test1 \
test2
all clean check :
@for dir in $(SUBDIRS); do \
if [ -d $$dir ]; then (cd $$dir; $(MAKE) $@) fi \
done
Run Code Online (Sandbox Code Playgroud)
我是(明显的)少数民族,不同意"Recursive Make Considered Harmful".我已经为大型,混乱的代码库编写了递归Make系统,并且它们工作得非常好.
这是怎么做的:
all: $(SUBDIRS)
$(SUBDIRS): force
@ $(MAKE) -s -C $@
.PHONY: force
force :;
Run Code Online (Sandbox Code Playgroud)
(我添加了-s以使事情变得更安静.)
编辑:将目标传递给子制作(我之前应该这样做):
.PHONY: all check clean
all check clean: $(SUBDIRS)
all: TARGET=all
check: TARGET=check
clean: TARGET=clean
# No, you can't do TARGET=$@, or at least I don't know how to.
# recursive call to make
$(SUBDIRS): force
@ $(MAKE) -s -C $@ $(TARGET)
.PHONY: force
force :;
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3521 次 |
| 最近记录: |