From: Jason Green To: djgpp AT delorie DOT com Newsgroups: comp.os.msdos.djgpp Subject: Re: Make file wildcards Date: Sat, 24 Jun 2000 18:39:32 +0100 Message-ID: References: <395309A1 DOT 881A2311 AT pacbell DOT net> <200006230948 DOT MAA02794 AT mailgw1 DOT netvision DOT net DOT il> <3953D200 DOT 897086E1 AT pacbell DOT net> <200006240638 DOT JAA15429 AT alpha DOT netvision DOT net DOT il> <200006241437 DOT RAA05163 AT mailgw1 DOT netvision DOT net DOT il> X-Mailer: Forte Agent 1.7/32.534 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Reply-To: djgpp AT delorie DOT com "Eli Zaretskii" wrote: > > Sorry, I still don't get it. I understand your original reply to mean > > that there are cases where a built-in implicit rule takes precedence > > over an implicit rule defined in the makefile. > > With implicit rules, there's no precedence. You can have several > different implicit rules that can be applied to create the same > target. Make will choose one of them, but not necessarily the last > one it sees. But there is some method in its madness. ;-) > > Can you give an example of this (if you really mean that)? > > What's wrong with the example which started this thread? Only that you said that it > is just another implicit rule, not unlike the one that Make already > knows about. When Make sees more than one implicit rule to build the > same target, it chooses the first one, which will always be the one > that's built into Make. Which got me confused because the makefile rule and the built-in are not alike, and I would expect make to always prefer a makefile rule over any built-in. Please do correct me if I am wrong. > The original makefile *did* include a rule to produce foo.o given > foo.cpp. And that is what important, as far as Make is concerned. Ok, slight technicality. ;-) This rule: %.o : %.c %.cpp %.h $(CC) $(CFLAGS) -c $< will produce test.o given test.c *and* test.cpp *and* test.h Since test.c does not exist, make prefers the built-in rule: %.o: %.cpp $(CXX) $(CXXFLAGS) $(CPPFLAGS) -c -o $@ $< But would prefer this if it found it in the makefile: %.o: %.cpp $(CC) $(CFLAGS) -c $<