abs_builddir = $(shell pwd)
abs_topbuilddir = $(shell cd .. && pwd)
abs_srcdir = $(shell cd $(srcdir) && pwd)
+abs_topsrcdir = $(shell cd $(srcdir)/.. && pwd)
# No libraries with the exception of LIBXML should be listed
# here. List them against the individual XXX_la_CFLAGS targets
-I$(srcdir)/util \
-DIN_LIBVIRT \
-Dabs_topbuilddir="\"$(abs_topbuilddir)\"" \
+ -Dabs_topsrcdir="\"$(abs_topsrcdir)\"" \
$(GETTEXT_CPPFLAGS)
AM_CFLAGS = $(LIBXML_CFLAGS) \
if (flags & VIR_DOMAIN_DEF_PARSE_VALIDATE) {
char *schema = virFileFindResource("domain.rng",
- "docs/schemas",
+ abs_topsrcdir "/docs/schemas",
PKGDATADIR "/schemas");
if (!schema)
return NULL;
char *mapfile;
if (!(mapfile = virFileFindResource("cpu_map.xml",
- "src/cpu",
+ abs_topsrcdir "/src/cpu",
PKGDATADIR)))
return -1;
if (!(modfile = virFileFindResourceFull(name,
"libvirt_driver_",
".so",
- "src/.libs",
+ abs_topbuilddir "/src/.libs",
LIBDIR "/libvirt/connection-driver",
"LIBVIRT_DRIVER_DIR")))
return NULL;
}
if (!(iohelper_path = virFileFindResource("libvirt_iohelper",
- "src",
+ abs_topbuilddir "/src",
LIBEXECDIR)))
goto error;
if (!privileged &&
!(daemonPath = virFileFindResourceFull("virtlockd",
NULL, NULL,
- "src",
+ abs_topbuilddir "/src",
SBINDIR,
"VIRTLOCKD_PATH")))
goto error;
if (!(modfile = virFileFindResourceFull(name,
NULL,
".so",
- "src/.libs",
+ abs_topbuilddir "/src/.libs",
LIBDIR "/libvirt/lock-driver",
"LIBVIRT_LOCK_MANAGER_PLUGIN_DIR")))
goto cleanup;
}
if (!(lxc_path = virFileFindResource("libvirt_lxc",
- "src",
+ abs_topbuilddir "/src",
LIBEXECDIR)))
goto error;
/* This helper is used to create custom leases file for libvirt */
if (!(leaseshelper_path = virFileFindResource("libvirt_leaseshelper",
- "src",
+ abs_topbuilddir "/src",
LIBEXECDIR)))
goto cleanup;
if ((flags & VIR_DRV_OPEN_REMOTE_AUTOSTART) &&
!(daemonPath = virFileFindResourceFull("libvirtd",
NULL, NULL,
- "daemon",
+ abs_topbuilddir "/daemon",
SBINDIR,
"LIBVIRTD_PATH")))
goto failed;
int ret;
if (!(parthelper_path = virFileFindResource("libvirt_parthelper",
- "src",
+ abs_topbuilddir "/src",
LIBEXECDIR)))
return -1;
int ret;
if (!(parthelper_path = virFileFindResource("libvirt_parthelper",
- "src",
+ abs_topbuilddir "/src",
LIBEXECDIR)))
return -1;
}
if (!(iohelper_path = virFileFindResource("libvirt_iohelper",
- "src",
+ abs_topbuilddir "/src",
LIBEXECDIR)))
goto error;
* @filename: libvirt distributed filename without any path
* @prefix: optional string to prepend to filename
* @suffix: optional string to append to filename
- * @builddir: location of the binary in the source tree build tree
+ * @builddir: location of the filename in the build tree including
+ * abs_topsrcdir or abs_topbuilddir prefix
* @installdir: location of the installed binary
* @envname: environment variable used to override all dirs
*
* path in the installed location.
*
* If @envname is non-NULL it will override all other
- * directory lookup
+ * directory lookup.
*
* Only use this with @filename files that are part of
* the libvirt tree, not 3rd party binaries/files.
{
char *ret = NULL;
const char *envval = envname ? virGetEnvBlockSUID(envname) : NULL;
+ const char *path;
if (!prefix)
prefix = "";
if (!suffix)
suffix = "";
- if (envval) {
- if (virAsprintf(&ret, "%s/%s%s%s", envval, prefix, filename, suffix) < 0)
- return NULL;
- } else if (useDirOverride) {
- if (virAsprintf(&ret, "%s/%s/%s%s%s", abs_topbuilddir, builddir, prefix, filename, suffix) < 0)
- return NULL;
- } else {
- if (virAsprintf(&ret, "%s/%s%s%s", installdir, prefix, filename, suffix) < 0)
- return NULL;
- }
+ if (envval)
+ path = envval;
+ else if (useDirOverride)
+ path = builddir;
+ else
+ path = installdir;
+
+ if (virAsprintf(&ret, "%s/%s%s%s", path, prefix, filename, suffix) < 0)
+ return NULL;
VIR_DEBUG("Resolved '%s' to '%s'", filename, ret);
return ret;