Commit 77401995 authored by Marvin Scholz's avatar Marvin Scholz

contrib: bluray: Add patch to fix libbluray.jar loading on macOS

This is already landed upstream but we need a new release, so for now
keep this local patch. When a release is done and the contrib is
updated, this should be removed.

Fix #19702
parent 2c0ea2ff
From 8c15fdad7797854bc4f98cdb339074a4f9f2dbb3 Mon Sep 17 00:00:00 2001
From: Marvin Scholz <epirat07@gmail.com>
Date: Wed, 7 Mar 2018 10:24:41 +0100
Subject: [PATCH] Implement dl_get_path for darwin (macOS)
---
src/file/dl_posix.c | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)
diff --git a/src/file/dl_posix.c b/src/file/dl_posix.c
index f1852a43..b97f12fe 100644
--- a/src/file/dl_posix.c
+++ b/src/file/dl_posix.c
@@ -27,6 +27,11 @@
#include "util/logging.h"
#include "util/strutl.h"
+#ifdef __APPLE__
+// Required to make dladdr available
+# define _DARWIN_C_SOURCE
+#endif
+
#if defined(HAVE_DLFCN_H)
# include <dlfcn.h>
#elif defined(HAVE_SYS_DL_H)
@@ -112,6 +117,7 @@ int dl_dlclose(void *handle)
return dlclose(handle);
}
+#define PATH_SEPARATOR '/'
const char *dl_get_path(void)
{
static char *lib_path = NULL;
@@ -120,7 +126,25 @@ const char *dl_get_path(void)
if (!initialized) {
initialized = 1;
+#ifdef __APPLE__
+ Dl_info dl_info;
+ int ret = dladdr((void *)dl_get_path, &dl_info);
+
+ if (ret != 0) {
+ lib_path = strdup(dl_info.dli_fname);
+
+ /* cut library name from path */
+ char *p = strrchr(lib_path, PATH_SEPARATOR);
+ if (p) {
+ *(p+1) = 0;
+ }
+ BD_DEBUG(DBG_FILE, "library file is %s\n", lib_path);
+ } else {
+ BD_DEBUG(DBG_FILE, "Can't determine libbluray.so install path\n");
+ }
+#else
BD_DEBUG(DBG_FILE, "Can't determine libbluray.so install path\n");
+#endif
}
return lib_path;
--
2.14.3 (Apple Git-98)
......@@ -48,6 +48,7 @@ $(TARBALLS)/libbluray-$(BLURAY_VERSION).tar.bz2:
bluray: libbluray-$(BLURAY_VERSION).tar.bz2 .sum-bluray
$(UNPACK)
$(APPLY) $(SRC)/lua/0001-Implement-dl_get_path-for-darwin-macOS.patch
$(call pkg_static,"src/libbluray.pc.in")
$(MOVE)
......
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