How can I use .NOTPARALLEL in makefile only on specific targets?
Solution 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.)
Solution 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
shd
Updated on June 30, 2022Comments
-
shd almost 2 years
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 usemake -j
. If I use.NOTPARALLEL
, it will make all of themNOTPARALLEL
, any suggestion on how to do that? -
Maxim Egorushkin almost 11 yearsIt is called order-only dependency to be precise.
-
Nitin4873 almost 11 yearsthis should solve the base requirement - hence the make even if it forks many processes it will have to ensure that order of completion of the targets even iff the non parallel option is not used !! , +1 @laindir
-
devnull almost 11 yearsYes. The solution would work in parallel, regardless of the number of simultaneous jobs.
-
shd almost 11 yearsthis will not work with -j7 , since it ignore everything i think
-
laindir almost 11 yearsThis will work with any number of jobs, since we have explicitly told
make
that last_label must not run before the other labels have finished. -
TrueY about 10 yearsI assume the
intermediate
target should come afterall
, otherwise it would become the default target.