how to use makefile with NOTPARALLEL label?

匿名 (未验证) 提交于 2019-12-03 08:28:06

问题:

I have 5 labels in Makefile:

all: label1 label2 label3 label4 last_label 

I want last_label to be done last , and I want to use make -j. If I use .NOTPARALLEL, it will make all of them NOTPARALLEL, any suggestion on how to do that?

回答1:

Create a target specifying the four targets that can be executed in parallel & include this and last_label in the all target:

intermediate: label1 label2 label3 label4  all:         $(MAKE) intermediate         $(MAKE) last_label 

This would execute the targets specified within intermediate in parallel, but intermediate and last_label would be forced consecutively.

(Note that the leading space before $(MAKE) is a TAB character.)



回答2:

If the reason last_label needs to run last is that it needs data from the other labels, the best approach would be to tell make about that dependency:

all: last_label  last_label: label1 label2 label3 label4 

If there's not a true dependency (i.e., if you don't want last_label to be rebuilt if one of the others changes), and if you're using GNU Make, you can specify these as "order-only" dependencies--make will just make sure they exist before last_label is built:

all: last_label  last_label: | label1 label2 label3 label4 


标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!