help-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Why don't more makefiles use rules like this: %.d %.o: %.c


From: John Fisher
Subject: Re: Why don't more makefiles use rules like this: %.d %.o: %.c
Date: Thu, 12 Nov 2009 14:21:28 +1100
User-agent: Thunderbird 2.0.0.21 (Windows/20090302)

I do not want to run the compiler twice or have a separate make depend target. 
The pattern rule exactly matches what the compiler is doing: from a .c file 
create a .d and .o at the same time.

A list of .d files is calculated and make includes them. If they are not there 
this forces make to create the .d files. The .o files are also created. Then 
make builds its main goal, finds the .o files are already done and runs the 
linker or librarian.

What is your alternative? How can what I suggested be harmful?

Philip Guenther wrote:
On Wed, Nov 11, 2009 at 3:25 PM, John Fisher <address@hidden> wrote:
...
My style uses a pattern rule like this

%.d %.o: %.c

and the -MMD switch to the GNU C compiler to create dependencies and object
files at the same time.

The latter (-MMD) is a good choice, yes.

The former (using a multiple target pattern rule that has %.d as a
target) is pointless or even harmful in my experience.  What are your
reasons for doing that?


Philip Guenther





reply via email to

[Prev in Thread] Current Thread [Next in Thread]