automake
[Top][All Lists]
Advanced

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

Re: Automatic dependency tracking when using non-depcomp tools


From: Hans Ulrich Niedermann
Subject: Re: Automatic dependency tracking when using non-depcomp tools
Date: Thu, 24 Nov 2022 15:27:06 +0100

On 2022-11-22 18:32 -0700, Karl Berry <karl@freefriends.org> wrote:

> Hi Hans - first, congratulations on getting this to work at all.

Thank you for your kind and thorough reply.

> I don't recall anyone else undertaking this.

And that might be why I could not find anybody else doing auto
dependency tracking in Makefile.am.

However, I have completely overlooked the central question about auto
dependency tracking: Can I actually rely on Automake making a verbatim
copy of the include line from Makefile.am to Makefile.im?

I presume I can rely on Automake copying the include line verbatim, due
to the following reasoning.

It appears

    include $(srcdir)/foobar.mk
    include $(top_srcdir)/foobar.mk
    include foobar.mk
    include ./foobar.mk

all cause direct inclusion of a file from the source tree, with the
first two lines being explicitly mentioned as the only two forms of
include in
https://www.gnu.org/software/automake/manual/automake.html#Include and
the last two lines being implicitly converted to the first line, but

    include ./$(some_non_srcdir_var)/foobar.mk

appears to be a Makefile.am line of a type which Automake does not know
to interpret and therefore just copies to Makefile.in verbatim like
it does with other lines like e.g. make rules and recipes.

Is that assessment correct?

FWIW, in the absence of officially documented places to hook into
Automake's auto dependency tracking, I have applied all of your
suggestions to keep out of Automake's way

  * use custom FOO_DEPDIR variable to keep out of Automake's way
  * use custom .foo-deps directory to keep out of Automake's way
  * use Automake-style *.Pc dep file name (inside custom directory)
  + include the dep file into the Makefile.am and Makefile
  * create empty dummy no-op dep file to allow first compile
  * create a proper dep file as side effect of every compile

and the Makefile.am rules therefore now look as follows, for the benefit
of anybody searching the list archives for automatic dependency
tracking using custom non-depcomp tool rules in Automake Makefile.am:

    FOO_DEPDIR = .foo-deps

    DISTCLEANFILES += ./$(FOO_DEPDIR)/foo-resources.Pc
    include ./$(FOO_DEPDIR)/foo-resources.Pc
    ./$(FOO_DEPDIR)/foo-resources.Pc:
            @$(MKDIR_P) $(@D)
            @: >>$@

    foo_SOURCES += foo-resources.c
    CLEANFILES  += foo-resources.c
    foo-resources.c: $(srcdir)/foo.gresource.xml
            $(GLIB_COMPILE_RESOURCES) \
                --sourcedir=$(srcdir) \
                --dependency-file=./$(FOO_DEPDIR)/foo-resources.Pc \
                --target=foo-resources.c \
                --generate-source \
                $(srcdir)/foo.gresource.xml



reply via email to

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