From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Paul D. Smith" To: help-gcc@gnu.org Subject: Re: dmake, GNU make, gcc, and auto-dependencies Date: Fri, 31 Dec 1999 22:24:00 -0000 Message-ID: References: <384ba7f4.91964227@vic.nnrp.telstra.net> X-SW-Source: 1999-12n/msg00077.html Message-ID: <19991231222400.Q6XNkbbxY2rcpjoU3vck3nHz1g-BOCnfRyBrn2xz71Q@z> %% stus@deimus.com.au (Stuart Summerville) writes: ss> I'm trying to get auto dependencies working amongst gnu make (V3.76 or ss> so), dmake (4) and gcc (ver?). The gnu make manual (at www.gnu.org) ss> suggests creating a pattern rule that will create a .d makefile ss> (containing dependencies for that file) for each source file, & then ss> "including" that .d file into the main makefile before the source is ss> built. I don't know anything about dmake. But for gmake and GCC, while the version in the GNU make manual works, it's considered (by me, anyway :) to be "old technology". There is a much better way to handle dependencies, invented by Tom Tromey for use in automake. I did a writeup of it; you can find it on my GNU make webpage below. ss> Question: How does one stop 'make' from including the .d files if ss> they're not built yet? For a small 1 file test project (could it be ss> smaller?), I include the .d file, but its either an old one, or isn't ss> even built yet. If you have GNU make 3.76 or better, you can use MAKECMDGOALS for this (see the manual). If you use the automake method you won't need this, though. ss> Another question: The gcc manpage states that the -MD switch will ss> generate the corresponding .d file, *and* compile the source file. In ss> doing so, does the contents of the .d file not affect the compilation ss> of the source file? If not, does that not put the auto-generation of ss> the dependency rule one step behind in the compilation process? ie. ss> Shouldn't the generation of the .d file be done in one step, for ss> subsequent use by make in determining whether to compile the source? Well, it's not "one step behind" because they're still both done at essentially the same time (during the same build invocation). It is, however, less efficient and has a few annoying "features", all of which are resolved by Tom's method. -- ------------------------------------------------------------------------------- Paul D. Smith Find some GNU make tips at: http://www.gnu.org http://www.ultranet.com/~pauld/gmake/ "Please remain calm...I may be mad, but I am a professional." --Mad Scientist