[Asterisk-Dev] Asterisk make clean and make looping?? (Possible solution)

David Taylor dtaylor at dtayls.com
Tue Nov 8 17:26:52 MST 2005


Reviving this from a few days ago ...

I think you'll be needing to look at this one Kevin because it does
appear that "the logic in the Makefile is faulty" and you were the 
man who submitted the offending changes to CVS :-)

Kevin P. Fleming wrote the following on Thu Nov 3rd:
> Robert Webb wrote:
>
> > If I manually run the make_version_h script as shown in the Makefile, I 
> > get an output. Not sure if it might have something the do with the $@ 
> > variable when the .tmp gets made.
>
> Then something is wrong with 'cmp' on your system, or the logic in the 
> Makefile is faulty. Please try to execute the steps from the Makefile 
> one at a time and see what happens; what should be happening is that the 
> temp file gets created and then removed, without overwriting version.h 
> if the contents are going to be the same.

I've experienced the same problem since moving recently to the Beta releases.

The problem occurs when using sources checked out of the CVS tree where
a specific CVS-Tag is specified.  In this case the Makefile variable
ASTERISKVERSION incorporates the current date and time.  So, each time
'build_tools/make_version_h' is run the version number (ASTERISKVERSION)
changes.  The 'cmp -s' correctly determines that the files are not the
same and 'include/asterisk/version.h' of course gets updated.

Now, adding the date and time to the CVS tag info just doesn't make sense 
to me, so I've been editing the line:

ASTERISKVERSION=$(shell echo "CVS-`sed 's/^T//g' CVS/Tag`-`date +"%D-%T"`")
  to read
ASTERISKVERSION=$(shell echo "CVS-`sed 's/^T//g' CVS/Tag`")

This works for me and it might be part of the answer, but it doesn't explain
the looping behavior.  I think you'll find that this has a couple of things
contributing to the problem.  Firstly, the targets 'depend' and '.depend' 
both depend on 'version.h'.  And a number of things depend on these.
AND, if '.depend' exists then it gets included in the Makefile, so this has
me wondering whether (a) we should expect to always be out-of-sync-by-one 
on the version of '.depend' or (b) this is perhaps the cause of our little 
loop.

If my analysis is correct, the problem appears to have been introduced in
version 1.164 (CVS comment = "major Makefile and build process improvements").
It also appears to exist in the current CVS HEAD version 1.223.  And Kevin,
I believe this was your work :-)  So, I'm hoping you know what was really 
intended so it can be fixed in line with that intention.

BTW.  A little something worthy of note for those trying to come to terms
with the magic that happens in Makefiles, $(shell) actually gets evaluated
(almost) every time it is used.  For instance, try the following short 
Makefile:

ASTERISKVERSION=$(shell echo "`date +"%D-%T"`")

all: a b
    @echo All ${ASTERISKVERSION}
    @sleep 3
    @echo All ${ASTERISKVERSION}

a:
    @echo AAA ${ASTERISKVERSION}
    @sleep 2

b:
    @echo BBB ${ASTERISKVERSION}
    @sleep 2


That will yield something similar to the following (using GNU make version 3.80):

AAA 11/09/05-11:12:46
BBB 11/09/05-11:12:48
All 11/09/05-11:12:50
All 11/09/05-11:12:50


Kevin.  I suspect that you (and others) probably haven't fallen over this one 
because your environment differs from those who have experienced this.  I 
suspect this is because you are using the CVS HEAD for which the Makefile
probably works as expected.

Hoping my comments have helped to move this one along.
David.





More information about the asterisk-dev mailing list