[Top][All Lists]

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

Re: How to tell Automake about dependencies between source files.

From: Peter Breitenlohner
Subject: Re: How to tell Automake about dependencies between source files.
Date: Wed, 18 Mar 2009 10:35:51 +0100 (CET)
User-agent: Alpine 1.10 (LNX 962 2008-03-14)

On Tue, 17 Mar 2009, Ralf Wildenhues wrote:

Hello Bob and Ralf,

thanks for your replies, unfortunately they gave me no new insight

Well, do you distribute any files that depend on these built files?
If you stick to distributing all files which are prerequisites to
distributed files, then there should be no problem.

That is, of course, true but not applicable in our case.  These
prerequisites are built by a tool (for the build system) that is part of the
package, and it would be extremely inconvenient to distribute them.

But showing an example failure is always the easiest to analyze.

Let me be somewhat more explicit and give you an (idealized)

bin_PROGRAMS = prog
endif COND

prog_SOURCES = foo.c foo.h
nodist_prog_SOURCES = bar.h

bar.h: tool bar.orig
        .tool $(srcdir)/bar.orig


This fails (if COND is true) because, in our case, foo.c includes bar.h, but
that is only known to Make once foo.c has been compiled (as least with

What we really would need is a dependency

foo.o: bar.h

but then this ought to be foo.$(OBJEXT) or maybe prog-foo.$(OBJEXT) and,
more important, would prevent Automake from generating a rule for this


I have tried adding


but then tool will run even if COND is false

$(prog_SOURCES): bar.h

is somewhat better until I run 'make dist'.

I could use

endif COND


$(prog_SOURCES): bar.h
endif COND

and these two almost do what I need, unless:

COND is false but prog nevertheless needs to be built because it appears as
dependency of something else, or I might have second thoughts and say

        make prog

This will then fail.


Moreover, telling Automake that foo.c depends on bar.h is a lie (foo.c will
always be older than bar.h) and may have other undesirable consequences.

What I really would need is a way to tell Automake: 'before you can compile
foo.c you must first create bar.h', and I have found no way to do that
(other than writing a compilation rule as Automake would do).


The above example may look somewhat artificial. However, it is a stripped
down version of what we really need.

Peter Breitenlohner <address@hidden>

reply via email to

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