Forgive me for reviving this 2 year old thread, especially because there's no make bug in sight, but this is the only place I've found this issue discussed, so I wanted to make a couple comments and then ask a question:
Philip Guenther-2 wrote > I think I would use a test on $(MAKECMDGOALS) to make T1 a > prerequisite of T2 if and only if T1 is a goal, say... > > ifneq ($(filter T1,${MAKECMDGOALS}),) > T2: T1 > endif The specific problem I was having was "make -j clean all", an idiom I use because I can never remember "-B", and I always assumed it was equivalent. But it's not. With "-j", clean and all are invoked in parallel, which is brilliant, but causes this ordering problem. Thanks to this thread, I understand why order-only prerequisites are not the answer, and the MAKECMDGOALS suggestion pointed me in the right direction. The simple solution (which works when all targets are phony and none depend on the others) is: $(filter-out clean distclean,$(MAKECMDGOALS)): $(filter clean distclean,$(MAKECMDGOALS)) The more general solution (which I found somewhere on the web) is to define: CLEAN_DEP=$(filter clean distclean,$(MAKECMDGOALS)) and then add $(CLEAN_DEP) as a prerequistie to any targets that cannot be run in parallel with the clean targets. Now the question: now that the smoke has cleared, I believe I understand that when the prerequisite is phony, it makes no difference whether it's order-only or not. Am I missing something? I was puzzled by the comments about the targets being phony, since I was totally on the same page as Stefano, but now that I realize the error in my thinking, it makes perfect sense that people would wonder about their phoniness, since being phony makes order-only uniniteresting. -don provan dpro...@bivio.net -- View this message in context: http://gnu-make.2324884.n4.nabble.com/order-only-prerequisites-don-t-behave-as-I-d-have-expected-after-reading-the-documentation-tp3787p15681.html Sent from the Gnu - Make - Bugs mailing list archive at Nabble.com. _______________________________________________ Bug-make mailing list Bug-make@gnu.org https://lists.gnu.org/mailman/listinfo/bug-make