Commit 85f5c15f authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Linux: determine data path at run-time from library path

parent e83bc5b9
......@@ -169,7 +169,7 @@ AM_CPPFLAGS = $(INCICONV) \
-DMODULE_STRING=\"main\" \
-DLOCALEDIR=\"$(localedir)\" \
-DSYSCONFDIR=\"$(sysconfdir)\" \
-DDATA_PATH=\"$(vlcdatadir)\" \
-DPKGDATADIR=\"$(vlcdatadir)\" \
-DPKGLIBDIR=\"$(vlclibdir)\"
AM_CFLAGS = $(CFLAGS_libvlccore)
......
......@@ -35,6 +35,7 @@
#include <assert.h>
#include <limits.h>
#if !defined (__linux__)
/**
* Determines the shared data directory
*
......@@ -42,10 +43,9 @@
*/
char *config_GetDataDirDefault (void)
{
return strdup (DATA_PATH);
return strdup (PKGDATADIR);
}
#if !defined (__linux__)
/**
* Determines the architecture-dependent data directory
*
......
......@@ -26,7 +26,8 @@
#include <string.h>
#include <vlc_common.h>
#include "../libvlc.h"
#include "libvlc.h"
#include "config/configuration.h"
char *config_GetLibDir (void)
{
......@@ -73,3 +74,29 @@ char *config_GetLibDir (void)
error:
return (path != NULL) ? path : strdup (PKGLIBDIR);
}
char *config_GetDataDirDefault (void)
{
char *libdir = config_GetLibDir ();
if (libdir == NULL)
return NULL; /* OOM */
char *datadir = NULL;
/* There are no clean ways to do this, are there?
* Due to multilibs, we cannot simply append ../share/. */
char *p = strstr (libdir, "/lib/");
if (p != NULL)
{
char *p2;
/* Deal with nested "lib" directories. Grmbl. */
while ((p2 = strstr (p + 4, "/lib/")) != NULL)
p = p2;
*p = '\0';
if (unlikely(asprintf (&datadir, "%s/share/"PACKAGE, libdir) == -1))
datadir = NULL;
}
free (libdir);
return (datadir != NULL) ? datadir : strdup (PKGDATADIR);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment