[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: $(srcdir)/foo is not generated because $(srcdir)/$(srcdir)/foo exist
From: |
Ralf Wildenhues |
Subject: |
Re: $(srcdir)/foo is not generated because $(srcdir)/$(srcdir)/foo exists |
Date: |
Sun, 13 Feb 2011 08:44:06 +0100 |
User-agent: |
Mutt/1.5.20 (2010-08-04) |
Hello Peter,
* Peter Johansson wrote on Sat, Feb 12, 2011 at 09:56:41PM CET:
> I got bitten by how VPATH builds work and wondered if there is a
> good way to avoid getting bitten again.
Not an easy question.
> I have an Automake snippet (see below) that creates a file,
> `.revision', with current revision number and from this is a C
> header file `revision.h' created. Then to test that things work as
> I'd like I have target similar to distcheck that essentially does
>
> svn export $(srcdir) _exported
> cd _exported
> ./bootstrap
> mkdir _build
> cd _build
> ../configure
> make
> make check
>
> When doing that here I get the following error:
>
> revision=$(cat ../.revision) \
> && sed "s|@SVN_REVISION@|$revision|g" < ../svn_revision.h.in \
> > svn_revision.h-t && mv svn_revision.h-t svn_revision.h
> cat: ../.revision: No such file or directory
>
> and when I look into why there is no `../.revision' and I try
>
> make `../.revision' I get
> make: `../../.revision' is up to date.
>
> That is make finds the file in my original working copy and not in
> my current structure. Is there a good way to avoid this to happen?
I'd try to ensure the VPATH structure of your "distcheck" is different
from the one above that. I.e,. either use two levels of _build/_build
or have the upper build directory be a sibling, rather than a subdir,
of the source tree.
> --- Makefile.am ---
>
> EXTRA_DIST = .revision svn_revision.h.in
I'd use $(srcdir)/.revision here. That helps non-GNU makes understand
that it's the same thing that there is a rule for below. But please see
'info Autoconf "VPATH and Make"' for all the problems VPATH can make
(sorry for the pun).
> BUILT_SOURCES = $(srcdir)/.revision $(builddir)/svn_revision.h
>
> if HAVE_SVN_WC
> YAT_SVN_REVISION_FORCE:
> $(srcdir)/.revision: YAT_SVN_REVISION_FORCE
> @$(SVNVERSION) $(srcdir) > address@hidden \
> && $(MOVE_IF_CHANGE) address@hidden $@
I would prepend all lines of a rule with a TAB, not just those not
following a backslash-escaped newline. I'm actually not totally sure
whether that was for portability to non-Posix make or so automake would
parse things reliably.
> else
> ## this is needed in 'svn export' build
> $(srcdir)/.revision:
> echo "" > $@
I don't see why you should need this rule here. The .revision file is
distributed, so it should already exist. At most I'd add a stub target
$(srcdir)/.revision:
here. Maybe I'm missing something?
> endif
> $(builddir)/svn_revision.h: $(srcdir)/svn_revision.h.in $(srcdir)/.revision
> revision=$$(cat $(srcdir)/.revision) \
> && sed "s|@SVN_REVISION@|$$revision|g" < $(srcdir)/svn_revision.h.in \
> > address@hidden && mv address@hidden $@
Hope that helps.
Cheers,
Ralf