我有一个看起来像下面这样的makefile
apps = app1 app2 app3
all: dir app1 app2 app3 zip cleanup
现在我想在apps
变量列表上进行一些循环操作,
类似于
`loop on apps
endloop`
在Makefile中可以对变量列表进行循环操作,需要循环遍历apps
变量列表。
更新
假设这个变量(apps
)是由我的程序在make
文件中生成的,为每个项目提供了不同的apps
值,有时候是apps= app1 app2
,有时候是apps= app1
,有时候可能会有20个或更多的应用apps= app1 app2 appN
。
如何迭代apps
变量并执行某些操作?例如,在每次迭代中打印类似于以下内容:
now im in `app1`
now im in `app2`
etc
尝试以下操作时:
.PHONY: foo
all: foo
APPS = app1 app2 app3 app4
foo : $(APPS)
for $$f in $(APPS); do echo $$f is here; done
我遇到了以下错误:
make: *** No rule to make target
app1',需要 foo'。停止。
apps= app1 app2
,有时它是apps= app1
,有时可能有20个或更多的应用程序apps= app1 app2 appN
。 - user6124024Makefile
都有shellfor
循环。例如,GCC的源代码有一个生成Makefile
的Makefile.in
文件,两者都有for
循环。 - Basile Starynkevitch