build: fix VPATH build of remote driver
build: fix VPATH build of remote driver

Commit 073e1575 tried to set things up so that 1) generated files
to be shipped in the tarball always live in srcdir, and 2) we have
no files in SOURCES that depend on any other files with a literal
$(srcdir) in the name, because that situation can cause confusing
results for the make expansion of $@ depending on whether the file
is found locally or via VPATH.  But all my testing for that patch
was done incrementally, where all the protocol.[ch] files had
already been generated prior to the patch and were up-to-date in
the srcdir, and thus I missed one case where $@ causes grief in a
VPATH build from a fresh checkout:

We have a pattern rule for generating remote_protocol.[ch], and
what's more, the rule for protocol.c depends on protocol.h AND
on the protocol.x file.  The pattern for protocol.c is only
satisfied via the VPATH lookup for protocol.x, and if protocol.h
doesn't yet exist, the VPATH rule kicks in and we end up with a
dependency on a file with $(srcdir) in the name.  Based on make's
rules for $@, this resulted in make building remote_protocol.h
into srcdir (where we want it), then remote_protocol.c into
builddir (oops, not so good for the tarball), and also causes
the build to fail (the compiler can't find the .h if it lives
in a different directory than the .c):

  CC       remote/libvirt_driver_remote_la-remote_protocol.lo
remote/remote_protocol.c:7:29: fatal error: remote_protocol.h: No such file or directory
 #include "remote_protocol.h"
                             ^
compilation terminated.

As before, the fix is to hard-code the output file to go into
srcdir in spite of $@; but since this is in a pattern rule, we
are forced to use $@ in the recipe, so the patch is a bit
trickier than what was done in commit 073e1575.

* src/Makefile.am (%protocol.c, %protocol.h): Force output to srcdir.

Signed-off-by: Eric Blake <a9da18479c871fe903d9590822cfe2629c6a4d11@redhat.com>

datto/libvirt,jardasgit/libvirt,shugaoye/libvirt,VenkatDatta/libvirt,taget/libvirt,eskultety/libvirt,rlaager/libvirt,cbosdo/libvirt,VenkatDatta/libvirt,taget/libvirt,taget/libvirt,zhlcindy/libvirt-1.1.4-maintain,fabianfreyer/libvirt,cbosdo/libvirt,fabianfreyer/libvirt,olafhering/libvirt,nertpinx/libvirt,andreabolognani/libvirt,jfehlig/libvirt,zhlcindy/libvirt-1.1.4-maintain,zippy2/libvirt,zippy2/libvirt,olafhering/libvirt,datto/libvirt,taget/libvirt,cbosdo/libvirt,nertpinx/libvirt,andreabolognani/libvirt,datto/libvirt,jfehlig/libvirt,crobinso/libvirt,shugaoye/libvirt,crobinso/libvirt,cbosdo/libvirt,shugaoye/libvirt,agx/libvirt,rlaager/libvirt,VenkatDatta/libvirt,agx/libvirt,zhlcindy/libvirt-1.1.4-maintain,elmarco/libvirt,andreabolognani/libvirt,fabianfreyer/libvirt,rlaager/libvirt,elmarco/libvirt,cbosdo/libvirt,VenkatDatta/libvirt,nertpinx/libvirt,eskultety/libvirt,zhlcindy/libvirt-1.1.4-maintain,zhlcindy/libvirt-1.1.4-maintain,agx/libvirt,rlaager/libvirt,datto/libvirt,libvirt/libvirt,libvirt/libvirt,eskultety/libvirt,rlaager/libvirt,fabianfreyer/libvirt,crobinso/libvirt,jardasgit/libvirt,agx/libvirt,nertpinx/libvirt,agx/libvirt,libvirt/libvirt,jfehlig/libvirt,elmarco/libvirt,olafhering/libvirt,jardasgit/libvirt,shugaoye/libvirt,crobinso/libvirt,andreabolognani/libvirt,shugaoye/libvirt,elmarco/libvirt,eskultety/libvirt,jfehlig/libvirt,libvirt/libvirt,VenkatDatta/libvirt,zippy2/libvirt,datto/libvirt,taget/libvirt,nertpinx/libvirt,fabianfreyer/libvirt,zippy2/libvirt,andreabolognani/libvirt,olafhering/libvirt,jardasgit/libvirt,eskultety/libvirt,elmarco/libvirt,jardasgit/libvirt