我想做的事情如下:
for i in *
do
if test -d $i
then
cd $i; make clean; make; cd -;
fi;
done
Run Code Online (Sandbox Code Playgroud)
这样可以正常工作,但是for如果构建破坏,我希望"打破" -loop.
有没有办法做到这一点?也许某种 - if陈述,可以检查成功make吗?
Eld*_*mov 19
您可以使用Make本身来实现您的目标:
SUBDIRS := $(wildcard */.)
.PHONY : all $(SUBDIRS)
all : $(SUBDIRS)
$(SUBDIRS) :
$(MAKE) -C $@ clean all
Run Code Online (Sandbox Code Playgroud)
如果任何目标失败,Make将中断执行.
支持任意目标:
SUBDIRS := $(wildcard */.) # e.g. "foo/. bar/."
TARGETS := all clean # whatever else, but must not contain '/'
# foo/.all bar/.all foo/.clean bar/.clean
SUBDIRS_TARGETS := \
$(foreach t,$(TARGETS),$(addsuffix $t,$(SUBDIRS)))
.PHONY : $(TARGETS) $(SUBDIRS_TARGETS)
# static pattern rule, expands into:
# all clean : % : foo/.% bar/.%
$(TARGETS) : % : $(addsuffix %,$(SUBDIRS))
@echo 'Done "$*" target'
# here, for foo/.all:
# $(@D) is foo
# $(@F) is .all, with leading period
# $(@F:.%=%) is just all
$(SUBDIRS_TARGETS) :
$(MAKE) -C $(@D) $(@F:.%=%)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4846 次 |
| 最近记录: |