Subject: Re: make and .OPTIONAL
To: <>
From: David Laight <david@l8s.co.uk>
List: tech-toolchain
Date: 11/08/2003 08:35:10
On Sat, Nov 08, 2003 at 04:03:03PM +1100, Luke Mewburn wrote:
> On Fri, Nov 07, 2003 at 07:19:35PM +0000, David Laight wrote:
>   | I thought I'd try to stop the build failing when a .depend file
>   | references an old .h file by changing mkdep so that it adds:
>   | 
>   | .OPTIONAL: header.h .....
>   | 
>   | This stops the build failing, but the program that depended on the
>   | deleted .h file is always rebuilt.
> 
> I'm not convinced that this is necessary.  I'll defer to the make(1)
> gurus (sjg@, etc :) if they disagree.
> 
> 
> I was considering that an extra option to mkdep(1) to "validate .depend"
> (and return non-zero if files missing, but don't necessarily rebuild)
> and use that for this purpose.  That would be quicker than doing the
> check in bsd.dep.mk with sed/make .for loop.

I've had another thought overnight (really ought to get some sleep!):
- Always run ${CC} with -MD so that EVERY compilation regenerates xxx.d
- In the ".depend: *.d" rule do the 'twiddling' that mkdep currently
  does and also add .OPTIONAL for all the headers.
- Arrange for the .depend file to be regenerated every time a program is
  built (it is a cheap action)

I think that would mean that the 'make depend' pass would be unnecessary.

Has this been tried before?

	David

-- 
David Laight: david@l8s.co.uk