[Spice-devel] [PATCH] Fix build when builddir != srcdir

Frediano Ziglio fziglio at redhat.com
Wed Nov 16 11:20:00 UTC 2016


> 
> 
> 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).

> > 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.

> > ---
> >  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