best practice for serialization of dependencies of a target

Bruno Haible <[email protected]>
Newsgroups gmane.comp.gnu.make.general
Message-ID <4730638.GXAFRqVoOG@nimes>
Hi,

When I have a Makefile rule

target: $(DEPS1) $(DEPS2)
	command1

it is guaranteed that $(DEPS1) and $(DEPS2) will be done, including their
dependencies, before command1 is started.
However, with -j, $(DEPS1) and $(DEPS2) are being made in parallel. If this
is not desired, I can transform this rule to

target: $(DEPS1)
	test -z "$(DEPS2)" || $(MAKE) $(DEPS2)
	command1

or (equivalently?)

target: $(DEPS1)
	$(MAKE) target2
target2: $(DEPS2)
	command1
.PHONY: target2

The question is: Are these two rewrites really equivalent? If not, how
do they differ, and what is the best practice?

Bruno
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.