Minor bug in Makefile

Camillo Särs <[email protected]> Thu, 19 Sep 2002 10:01:31 +0300
Newsgroups gmane.mail.ifile.general
Organization private email
Message-ID <[email protected]>
Hi,

When building for multiple platforms, there is a minor bug in the Makefile 
[generated by configure] which only shows up in rare situations:

# ifile.h has macros that indicate ifile's version number; these
# must be kept up-to-date.
include/ifile.h: Version
         rm -f $(srcdir)/include/ifile-tmp.h~
         mv $(srcdir)/include/ifile.h $(srcdir)/include/ifile-tmp.h~
         cat $(srcdir)/include/ifile-tmp.h~ | sed -e \
         's/e IFILE_MAJOR_VERSION .*/e IFILE_MAJOR_VERSION $(IFILE_MAJOR_VERSION)
/' \
         | sed -e \
         's/e IFILE_MINOR_VERSION .*/e IFILE_MINOR_VERSION $(IFILE_MINOR_VERSION)
/' \
         | sed -e \
         's/e IFILE_TRIFLING_VERSION .*/e IFILE_TRIFLING_VERSION $(IFILE_TRIFLING
_VERSION)/' \
         | sed -e \
         's/e IFILE_VERSION .*/e IFILE_VERSION \"ifile $(IFILE_VERSION)\"/' \
         > $@

Spot it?  Neither did I, at first.

In the 1.1.3 release, it so happens that the file dates (at least on my system) 
for ifile.h and Version differ slightly; Version is newer, triggering this rule. 
Now, as I am running in subdirectory "iris4d", there is no "include/ifile.h" to 
write to, so the rule fails.  If re-run, make will actually remove the backup of 
ifile.h as well, permanently destroying it.

A suitable pushd/popd might help out here.  Oh, and doing a "mv -f" instead of 
the "rm -f" might make sense as well. :)

Incidentally, 1.0.11 built OK, because the file dates were not different and the 
rule did not trigger.  Which is the way things normally should be, I think.

Took a while to debug this one.

Cheers,
Camillo