Thu 21 Nov 2002 10:35:41 PM UTC, comment #1:
The situation is not as dire as it sounds here. First, it's not really that common for the same file to be a prerequisite of a number of targets, unless your makefile is actually trying to build them different ways (which is what this feature is designed for anyway).
The feature is designed to allow things like:
all: foo bar
debug: CFLAGS += -g
debug: all
Now if you run "make all" you get a non-debuggable version, whereas if you run "make debug" you get a version with debug capabilities... and you didn't have to play fancy tricks with your variables, MAKECMDGOALS, etc.
As for the solutions offered:
1) This is not an option. Not only does it not really solve anything, as you pointed out, but (a) it defeats the purpose of the feature and (b) it's not really feasible: make never computes the full list of possible paths to a given target, it only walks its current path. So make cannot know the full set of rules above this one, without a whole lot more work.
2) This is totally unacceptable: it simply is not how make works. Anyway this also doesn't solve the problem because you can't know in what order the targets will get built, and since they're all building the same file you'll just get a random result. Utter breakage.
3) The feature is useful and used (see above), and will not be removed. It is not hard to use it in a way which is perfectly deterministic and understandable--although I agree it can be used in other ways as well. As the doctor said, "don't do that!"
4) I will add a blurb to the documentation making sure that this behavior is clear. I'm resetting this to a documentation bug.
If your makefiles are using this feature in a way which makes it non-deterministic and hard to debug---then don't use it that way any more. It's not designed to be used that way and as I said above, it's not hard to use it so that it's (pretty) obvious what's happening.
|