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

Jonathon Jongsma jjongsma at redhat.com
Tue Nov 15 18:39:22 UTC 2016


On Tue, 2016-11-15 at 13:35 -0500, Frediano Ziglio 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
> > 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
> > 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.
> > ---
> >  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			\
> 
> Actually there may be a trick:
> 
> spice-server-enums.h: spice-server-enums.tmpl.h spice-server.h
> 	$(AM_V_GEN)glib-mkenums --template $^ > $@
> 
> the $^ should be replaced by both so the command should receive the
> right files.
> 
> (didn't try, my spice directory is in a messy state at the moment).
> 
> Frediano


Yeah, I briefly considered that approach, but it seemed too hacky so I
didn't use it. I prefer my approach, to be honest.

Jonathon



More information about the Spice-devel mailing list