Subject: Re: auto creation od .depend files
To: Simon J. Gerraty <sjg@crufty.net>
From: David Laight <david@l8s.co.uk>
List: tech-toolchain
Date: 01/29/2004 22:28:57
On Tue, Jan 27, 2004 at 04:48:06PM -0800, Simon J. Gerraty wrote:
> >This needs to be done if and of the .d files have been created during the
> >current build (not if they are out of date at the start of the build).
> 
> Its not actually that big a deal if you do it always.
> At least I've not found it to be a problem.

Well 'make depend' only rebuild them if the .c file has changed.
This causes grief quite often.
Also the 'make depend' pass takes a moderate amount of HP.

> Have you looked at the autodep.mk I've mentioned a couple of times?
> Its been in constant use for over 3 years (in a pretty busy engineering dept.)
> and even without use of .OPTIONAL has worked very well.  
> You can find it in pkgsrc/devel/mk-files

maybe I ought to....

> >This is done by detecting whether ${CPPFLAGS) has been expanded by setting:
> >SKIP_AUTODEP=\#
> >CPPFLAGS+=${SKIP_AUTODEP::=}
> 
> This is cute - I like it.  
> Note that SKIP_AUTODEP=: would work as well, and save you
> the need to quote things.

Would it? you the assignment to SKIP_AUTODEP to happen whan a command line
is executed, not when the makefile is parsed.
> 
> >with:
> >realall: ${PROG} ${SCRIPTS} .WAIT .depend
> 
> >Things are actually slightly more complicated...
> 
> But is it really necessary?  

I've been bitten too often (as have people less savvy) by make reporting:
'don't know how to make xyz.h'
during an update build, and deciding that the only fix is to delete the
entire $OBJ tree.

> >You need 'SKIP_AUTODEP!= [ ! -f .depend ] || echo \\#' to get .depend
> >created if it is absent, but nothing is built.
> 
> >And to use
> >'_CPPFLAGS=${_SV::=${SKIP_AUTODEP}}${CPPFLAGS}${SKIP_AUTODEP::=${_SV}}'
> >instead of CPPFLAGS when passing things into nested makes.
> 
> This is starting to look fragile.  This is all just to avoid 
> unnecessarily building .depend?  is it worth it?

The _CPPFLAGS is only needed to stop .depend being generated from the .d
files for the kernel and stand libraries.

So it isn't 'fragile' since you tend to create .depend when you don't need to.
 
> >I've also had to ensure there is a dummy target (ie one with no rules)
> >to pin the '.WAIT .depend' onto.  Maybe I could use .USEBEFORE instead???
> 
> Probably better than the .END target I've used - I've been tempted to fix 
> it (and .BEGIN) so that
> 
> .END: this
> .END: that

Yes - I was a bit narked when I tried to use BEGIN more than once.

	David

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