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

This commit is contained in:
Rémi Denis-Courmont 2012-03-20 20:31:32 +02:00
parent e83bc5b906
commit 85f5c15fe5
3 changed files with 31 additions and 4 deletions

View File

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

View File

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

View File

@ -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);
}