version.h rebuild change in stable

Cameron Simpson cs at cskk.id.au
Sat Jun 1 06:36:38 UTC 2019


On 31May2019 17:36, Kevin J. McCarthy <kevin at 8t8.us> wrote:
>On Fri, May 31, 2019 at 11:19:27PM +0200, Vincent Lefevre wrote:
>>On 2019-05-31 09:37:02 -0700, Kevin J. McCarthy wrote:
>>>Of course, if anyone has an idea how to do this in a way that 
>>>works portably, we can revisit.  But for now I consider their 
>>>build issues more important than the minor convenience for 
>>>developers.
>>
>>How about using AM_CONDITIONAL in configure.ac, setting a variable 
>>GNU_MAKE when GNU Make is used (based on "make --version" output)?
>
>That might be a workable idea.  I worry about making assumptions about 
>the 'make' program that will be used, though.  It's possible the user 
>will invoke another make program outside of the search path, in certain 
>environments.  Or am I just being too paranoid... :-)

I'm an opinionated make user. Can you explain why you want the "FORCE" 
target at all? Just looking at the diff in the ticket:

  -version.h: FORCE
  -    echo '#define MUTT_VERSION "'`sh "$(srcdir)/version.sh"`'"' > $@.tmp
  -    cmp -s $@ $@.tmp && rm -f $@.tmp || mv $@.tmp $@
  -FORCE:
  +version.h: $(srcdir)/version.sh
  +    echo '#define MUTT_VERSION "'`sh "$(srcdir)/version.sh"`'"' > version.h

Is the purpose of the FORCE to (effectively) always examine the 
version.sh script output, but to only require a rebuild if version.sh 
changed contents?

If I were writing the conjectured goal above I'd probably do this:

  mutt_version='#define MUTT_VERSION "'`sh "$(srcdir)/version.sh`'"'
  version_h=`[ -s version.h ] && cat version.h`
  [ "$$mutt_version" = "$$version_h" ] || echo "$$mutt_version" >version.h

in "configure", not in the Makefile. As a prebuilt step. Once you've got 
a version.h you're good.

Then everything else can just depend in version.h as normal because the 
second make is working from a "clean" tree, prepared. This avoids any 
odd semantics like GNU make being particularly clever.

But I think what I'd really want is:

  version.h: $(srcdir)/version.sh
    echo '#define MUTT_VERSION "'`sh '$?'`'"' >'$@'

Why _don't_ we just have this?

Coming around to my opinions here, I think the BSD make is more correct: 
version.h got remade in the "FORCE" version of the Makefile, and its 
dependents need a rebuild. GNU make's presuming that file content are 
all there are - suppose an action changed something else significant not 
considered? Eg maybe the build process copies an ACL off version.h or 
some other thing beyond the content. Obviously we don't actually do 
that, but IMO GNU make is being too clever.

I think my end opinion would be that version.h should get made if 
version.sh gets modified (timestampwise). Just a straight dependency.

Rather than constructing progressively more complex "make flavour" 
dependent makefiles which try to encompass unknown make behaviour 
weirdness, expecially since as you point out we don't know the make at 
build time is the make which configure detects/infers/guesses.

Why _isn't_ is a straight dependncy of version.h on 
$(srcdir)/version.sh?

Cheers,
Cameron Simpson <cs at cskk.id.au>


More information about the Mutt-dev mailing list