-----Philip Guenther <guent...@gmail.com> schrieb: ----- >Betreff: Re: make doesn't complain if target cannot be built
> In many cases, I've found it completely unnecessary to > list the source files. Just list the objects that should be built and > provide pattern rules for the source types, then let make figure out which > source files generate which objects from the patterns, ala: > > OBJS = foo.o bar.o ... > > %.o: %.c: > $(COMPILE.c) .... > > %.o: %.cpp > $(COMPILE.cpp) .... > > ... > > $(OBJS): generated.h > > You only need to match sources > to objects if there's a naming conflict...which I would tend to solve by > renaming the file that doesn't belong. This is the pattern I normally use. But as I described in my first mail, the line "$(OBJS): generated.h" does two things: 1. state that foo.o and bar.o depend an generated.h 2. state the foo.o and bar.o are target The second has the side effect, that make doesn't complain if foo.o cannot be generated because there no matching implicit rule. A "make foo.o" wouldn't complain and exit with 0 even if there's no foo.c. > Side point: you only list an > explicit dependency for a file named generated.h, which suggests you're using > some sort of automated dependency technique (gcc -MD, make depend, etc) for > handling dependency tracking for other .h files. Yes, I do. > If that's the case, then it can be slightly better to use an order-only > prerequisite for the generated file, ala: > $(OBJS): | generated.h > That guarantees the generated.h file will > exist before trying to build any objects, but if generated.h gets rebuilt, > only the objects that have real dependencies from the automated dependency > tracking setup will get rebuilt. That makes sense. > > Philip Guenther regards Christian -- Registergericht / Register Court: Amtsgericht Traunstein, HRA 460 / Local Court Traunstein, registered under HRA 460 vertreten durch / authorized representative: Anton Kathrein This e-mail is confidential and may contain privileged information. If you have received this communication in error, please notify us immediately by responding to this email and then delete it from your system. The sender therefore does not accept liability for any errors or omissions in the contents of this message which arise as a result of e-mail transmission. We believe but do not warrant that this e-mail and any attachments are virus free. You must therefore take full responsibility for virus checking. _______________________________________________ Bug-make mailing list Bug-make@gnu.org https://lists.gnu.org/mailman/listinfo/bug-make