delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2001/12/25/08:17:36

X-Authentication-Warning: delorie.com: mailnull set sender to djgpp-bounces using -f
From: Jason Green <news AT jgreen4 DOT fsnet DOT co DOT uk>
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: <k5gc2ukf47ujjbubu40f6u4eeofav85ku9@4ax.com>
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> <pll42u4ptd5iv2bbo8790jcd5v1jni9ba5 AT 4ax 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
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 <eliz AT is DOT elta DOT co DOT il> 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.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019