[Spice-devel] [PATCH] Fix build when builddir != srcdir
Jonathon Jongsma
jjongsma at redhat.com
Wed Nov 16 16:06:14 UTC 2016
On Wed, 2016-11-16 at 06:20 -0500, Frediano Ziglio wrote:
> >
> >
> >
> > Acked-by: Christophe Fergeau <cfergeau at redhat.com>
> >
> > On Tue, Nov 15, 2016 at 12:13:21PM -0600, Jonathon Jongsma wrote:
> > >
> > > The following build error occurs when building outside of the
> > > source
> > > directory:
> > >
> > > glib-mkenums --template spice-server-enums.tmpl.c
> > > ../../server/spice-server.h > spice-server-enums.c
> > > Can't open spice-server-enums.tmpl.c: No such file or directory
> > > Makefile:1111: recipe for target 'spice-server-enums.c' failed
> > >
> > > GNU Make does some magic to know that the spice-server-
> > > enums.tmpl.c file
>
> It's a combination of automake and VPATH (which is currently quite
> standard
> so it's more a automake setting).
>
> >
> > >
> > > listed in the prerequisites for the rule is located in the
> > > srcdir. But
> > > when we use the bare filename in the rule definition, it assumes
> > > that it is
> > > in the builddir. If there was an automatic variable that we could
> > > use
> > > (like $< that we already use for the first prerequisite), the
> > > srdir
>
> From this part of the comment seems there is no way to extract the
> second prerequisite. In GNU make you can use $(word 2,$^) if you
> want to do this without using some hacks.
> Also is not that make assumes that is in builddir is that make
> does not parse much the rules definitions as doing so would cause
> problems. Is not defined for instance that you want to use
> spice-server-enums.tmpl.c as a filename so should try to find
> the file. As far as make is concern it's just a string. The parsing
> of rule body is limited to $ (which can be quoted) and line joiningm
> beside that lines are passed verbatim to the shell (which can be
> changed).
True, we could use a make function, but I'd still prefer to just prepend $(srcdir) explicitly. I think it's more straightforward.
>
> >
> > >
> > > would be automatically prepended to the filename, but there's
> > > nothing we
> > > can use for the second prerequisite. So we need to explicitly
> > > specify
> > > the location of the input template file.
>
> I would remove this part.
How about this?
Make/Automake uses VPATH to determine that the spice-server-enums.tmpl.c
file listed in the prerequisites for the rule is located in the srcdir.
When we use an automatic variable (e.g. $<), the srcdir path gets
automatically prepended to the filename. But when we use the filename
directly within the rule definition, this won't happen. So we need to
explicitly specify that the input template file is located in srcdir.
Jonathon
>
> >
> > >
> > > ---
> > > server/Makefile.am | 4 ++--
> > > 1 file changed, 2 insertions(+), 2 deletions(-)
> > >
> > > diff --git a/server/Makefile.am b/server/Makefile.am
> > > index 972f3e2..949e56a 100644
> > > --- a/server/Makefile.am
> > > +++ b/server/Makefile.am
> > > @@ -202,10 +202,10 @@ libspice_server_la_LIBADD = libserver.la
> > > libspice_server_la_SOURCES =
> > >
> > > spice-server-enums.c: spice-server.h spice-server-enums.tmpl.c
> > > - $(AM_V_GEN)glib-mkenums --template spice-server-
> > > enums.tmpl.c $< > $@
> > > + $(AM_V_GEN)glib-mkenums --template $(srcdir)/spice-
> > > server-enums.tmpl.c $<
> > > >
> > > > $@
> > >
> > > spice-server-enums.h: spice-server.h spice-server-enums.tmpl.h
> > > - $(AM_V_GEN)glib-mkenums --template spice-server-
> > > enums.tmpl.h $< > $@
> > > + $(AM_V_GEN)glib-mkenums --template $(srcdir)/spice-
> > > server-enums.tmpl.h $<
> > > >
> > > > $@
> > >
> > > EXTRA_DIST = \
> > > spice-bitmap-utils.tmpl.c \
>
> Beside the comment I would have used the same syntax.
>
> Acked
>
> Frediano
More information about the Spice-devel
mailing list