On Fri, Jul 18, 2025 at 05:24:31PM +0200, Tomas Volf wrote:
> I am looking into how to add a dependency tracking into the build
> process of my project.  The project is written in GNU Guile, so it does
> not track them out of the box.  GNU Automake has a feature to track
> dependencies -- described in (automake)Dependencies -- however I did not
> manage to find any documentation on whether it is possible to add user
> provided tooling for new languages.

There is unfortunately no documented or "officially supported" way to
do this.

That being said, while Automake's dependency tracking internals are not
part of the public documented interface it works in a very simple way
and it is relatively straightforward to extend it.

There are basically three steps:

 (a) Update your makefile rules to write dependency information,
 (b) Extend config.status am-depfiles to create stub depfiles,
 (c) Add the needed include directives to Makefile.am.

For (a) this is all your own code so there is no real problem, although
you might want to use the (undocumented) AMDEP conditional in order to
not waste time generating dependency information when the package is
configured with --disable-dependency-tracking.

For (b), current versions of Automake generate the stubs using the
am--depfiles make rule.  You can extend this by adding your own rule as
a prerequisite, which will then be run by ./config.status am-depfiles.

depfiles_rule = am--depfiles
$(depfiles_rule): generate-depfile-stubs
generate-depfile-stubs:
        [create stubs here]

For (c), write into Makefile.am (changing $(DEPDIR)/file.P as appropriate):

@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/file.P@am__quote@ # 
am--include-marker

one line for each dependency file that will be generated.

> The best I have managed to find is (make)Automatic Prerequisites.  I
> will try to use it, however I wonder whether there is some way to
> configure Automake to handle most of that for me (assuming I provide a
> script to generate the dependency files).
> 
> Connected question, can I use the $(DEPDIR) macro in my rules and expect
> it to keep working, or -- since it is not documented -- it could be
> removed in some future release?

You should not expect hooking any undocumented internals to continue
working if you switch to a different version of Automake.  It is up to
you to decide if it matters for your package.  Presumably you will test
your package when switching to a different version of Automake and you
can discover/fix problems at that time.

The above should work in current versions of Automake since 1.16, but
will not work in 1.15 or earlier which use a different method to
generate the stubs.

Cheers,
  Nick

Reply via email to