bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: not breaking "make" after m4 macros and source files changed


From: Dave Hart
Subject: Re: not breaking "make" after m4 macros and source files changed
Date: Sun, 3 Apr 2011 09:09:37 +0000

On Sun, Apr 3, 2011 at 08:22 UTC, Ralf Wildenhues wrote:
> * Bruno Haible wrote on Sat, Apr 02, 2011 at 07:08:14PM CEST:
>>   - A removed .h file.
>>     Before: configure.ac depends on m4/macros.m4 that AC_SUBSTs STDIO_H to 
>> stdio.h.
>>             lib/stdio.h is generated through lib/Makefile if STDIO_H is 
>> non-empty.
>>             lib/foo.c includes stdio.h and needs to be compiled for 'all'.
>>     After:  configure.ac depends on m4/macros.m4 that AC_SUBSTs STDIO_H to 
>> empty.
>>             lib/stdio.h is generated through lib/Makefile if STDIO_H is 
>> non-empty.
>>             lib/foo.c includes stdio.h and needs to be compiled for 'all'.
>>     Here you need to check that after "make", lib/stdio.h is gone.
>
> This is a case that doesn't currently work, as nothing causes
> lib/stdio.h to be removed.  It is not yet clear to me where to
> stick those semantics sanely.

Removing or renaming a header can break the build for people tracking
the source using a version control system who reuse a build directory
from before the header removal/renaming, as I recall.  The problem I
saw was make failing because a .Po dependency tracking include file
was not present.  NTP has a manual mechanism to allow this scenario to
work:  Each Makefile.am includes depsver.mf which drops a version
stamp in each .deps directory if there is not one already, and
compares the version if there is a version stamp already present.
When the problem is recognized or anticipated, the .deps version (in
file deps-ver) is bumped.  When depsver.mf detects a version mismatch,
it forces regeneration of the .deps directory.  The implementation is
limited by being a make (not automake) fragment to the top-level and
one level of subdirs, but that's good enough for us.

It would be slick if Automake provided something similar without the
depth restriction.  Bonus points will be given for not requiring the
developer renaming/removing headers to manually trigger the mechanism.
 ;)

Below is our depsver.mf fragment [1], with comments that may well be
more accurate than my recollection above.

Cheers,
Dave Hart

[1] depsver.mf:

$(DEPDIR)/deps-ver: $(top_srcdir)/deps-ver
        @[ -f $@ ] ||                                                   \
                cp $(top_srcdir)/deps-ver $@
        @[ -w $@ ] ||                                                   \
                chmod ug+w $@
        @cmp $(top_srcdir)/deps-ver $@ > /dev/null || (                 \
                $(MAKE) clean &&                                        \
                echo -n "Prior $(subdir)/$(DEPDIR) version " &&         \
                cat $@ &&                                               \
                rm -rf $(DEPDIR) &&                                     \
                mkdir $(DEPDIR) &&                                      \
                case "$(top_builddir)" in                               \
                 .)                                                     \
                    ./config.status Makefile depfiles                   \
                    ;;                                                  \
                 ..)                                                    \
                        cd .. &&                                        \
                        ./config.status $(subdir)/Makefile depfiles &&  \
                        cd $(subdir)                                    \
                    ;;                                                  \
                 *)                                                     \
                    echo 'Fatal: depsver.mf Automake fragment limited'  \
                         'to immediate subdirectories.' &&              \
                    echo "top_builddir: $(top_builddir)" &&             \
                    echo "subdir:       $(subdir)" &&                   \
                    exit 1                                              \
                    ;;                                                  \
                esac &&                                                 \
                echo -n "Cleaned $(subdir)/$(DEPDIR) version " &&       \
                cat $(top_srcdir)/deps-ver                              \
        )
        cp $(top_srcdir)/deps-ver $@

.deps-ver: $(top_srcdir)/deps-ver
        @[ ! -d $(DEPDIR) ] || $(MAKE) $(DEPDIR)/deps-ver
        @touch $@

BUILT_SOURCES += .deps-ver
CLEANFILES += .deps-ver

#
# depsver.mf    included in Makefile.am for directories with .deps
#
# When building in the same directory with sources that change over
# time, such as when tracking using bk, the .deps files can become
# stale with respect to moved, deleted, or superceded headers.  Most
# commonly, this would exhibit as make reporting a failure to make a
# header file which is no longer in the location given.  To address
# this issue, we use a deps-ver file which is updated with each change
# that breaks old .deps files.  A copy of deps-ver is made into
# $(DEPDIR) if not already present.  If $(DEPDIR)/deps-ver is present
# with different contents than deps-ver, we make clean to ensure all
# .o files built before the incompatible change are rebuilt along with
# their updated .deps files, then remove $(DEPDIR) and recreate it as
# empty stubs.
#
# It is normal when configured with --disable-dependency-tracking for
# the DEPDIR to not have been created.  For this reason, we use the
# intermediate target .deps-ver, which invokes make recursively if
# DEPDIR exists.
#
# If you modify depsver.mf, please make the changes to the master
# copy, the one in sntp is copied by the bootstrap script from it.
#
# This comment block follows rather than leads the related code so that
# it stays with it in the generated Makefile.in and Makefile.
#



reply via email to

[Prev in Thread] Current Thread [Next in Thread]