automake
[Top][All Lists]
Advanced

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

Re: Built sources and make distcheck


From: Ralf Wildenhues
Subject: Re: Built sources and make distcheck
Date: Mon, 23 Feb 2009 10:42:07 +0100
User-agent: Mutt/1.5.18 (2008-05-17)

Hello Tavian,

* Tavian Barnes wrote on Mon, Feb 23, 2009 at 06:22:12AM CET:
> EXTRA_PROGRAMS = generate
> generate_SOURCES = generate.c
> 
> generated.c: generate

BTW, the prerequisite here would need to be generate$(EXEEXT).

>         ./generate$(EXEEXT) >$@
> 
> bin_PROGRAMS = lookup
> lookup_SOURCES = lookup.c generated.c

You need to use BUILT_SOURCES, and fake dependencies so that no
distributed file depends on an undistributed one.  Untested:

EXTRA_PROGRAMS = generate
BUILT_SOURCES = generate$(EXEEXT)
generated.c: generate.c Makefile.in
        ./generate$(EXEEXT) >$@
bin_PROGRAMS = lookup
lookup_SOURCES = lookup.c generated.c

> This is almost right, but because generated.c gets distributed but
> `generate' doesn't, make sees generated.c as out-of-date in the
> tarballs, and re-builds it.  This is worse when `make distcheck' is
> run, because of the VPATH build; $@ isn't even the right location to
> write to,

generated.c can live in the source or in the build tree.  But given that
different make implementations have slightly different VPATH semantics,
it may be useful to require it to always live in the source tree;
further, it may be useful to update it lazily (this shouldn't matter for
read-only trees iff your dependencies are set up correctly, but it
should make for faster rebuilds):

$(srcdir)/generated.c: generate.c Makefile.in
        ./generate$(EXEEXT) > tmp-generated.c
        if diff tmp-generated.c $@ >/dev/null 2>&1; then \
          rm -f tmp-generated.c; \
        else \
          mv -f tmp-generated.c $@; \
        fi

lookup_SOURCES = lookup.c $(srcdir)/generated.c

> and the source directory is read-only anyway, so a qualified
> path wouldn't help.  Is there any way to not build the `generate'
> target if generated.c exists, but still build it when it doesn't?

Hope that helps.

Cheers,
Ralf




reply via email to

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