Subject: Re: auto creation od .depend files
To: David Laight <david@l8s.co.uk>
From: Simon J. Gerraty <sjg@crufty.net>
List: tech-toolchain
Date: 01/27/2004 16:48:06
>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.
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

>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.

>with:
>realall: ${PROG} ${SCRIPTS} .WAIT .depend

>Things are actually slightly more complicated...

But is it really necessary?  

>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?

>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

works.  A dummy target is ok if needed though.

--sjg