X-Authentication-Warning: delorie.com: mailnull set sender to djgpp-bounces using -f From: Jason Green Newsgroups: comp.os.msdos.djgpp Subject: Re: Should I use bash as default shell in makefiles? Date: Sun, 23 Dec 2001 20:42:48 +0000 Lines: 33 Message-ID: References: <809aeb88 DOT 0112171814 DOT 317a55ad AT posting DOT google DOT com> <200112200325 DOT fBK3P8528329 AT envy DOT delorie DOT com> <809aeb88 DOT 0112200908 DOT 59cd0b1f AT posting DOT google DOT com> <3C25C077 DOT C6469A42 AT is DOT elta DOT co DOT il> NNTP-Posting-Host: modem-100.pajama-cardinal.dialup.pol.co.uk Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: newsg2.svr.pol.co.uk 1009140203 17659 62.137.45.228 (23 Dec 2001 20:43:23 GMT) NNTP-Posting-Date: 23 Dec 2001 20:43:23 GMT X-Complaints-To: abuse AT theplanet DOT net X-Newsreader: Forte Agent 1.7/32.534 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com Eli Zaretskii wrote: > > > %.d: %.c > > > $(SHELL) -ec '$(CC) -M $(CPPFLAGS) $< \ > > > | sed '\''s/\($*\)\.o[ :]*/\1.o $@ : /g'\'' > $@; \ > > > [ -s $@ ] || rm -f $@' > > > > I've never understood why the docs say that. Is there a good reason for > > all that effort to create the .d files? > > The reason for the Sed command is explained in the Make manual, right > after the command itself. It's a valid reason, IMHO. I've just noticed the above command is slightly different to the one I see here, so I can't be sure we're looking at the same docs. However, I believe you are refering to... > The purpose of the `sed' command is to translate (for example): > > main.o : main.c defs.h > > into: > > main.o main.d : main.c defs.h > > This makes each `.d' file depend on all the source and header files > that the corresponding `.o' file depends on. `make' then knows it must > regenerate the prerequisites whenever any of the source or header files > changes. ...but when using `-MMD' the `.d' file will still be regenerated whenever any of the source or header files changes. I'm not disputing that sed has some advantage here, but it's obviously too subtle for me to see.