Not all mingw build environments have libdl.  And those that do often
only have it in dll form which would have to be distributed with the
application.  So allowing use of the builtin version of dlopen in
dvdread is useful. This patch does the right thing if dlopen is not
found on the system and it adds a configure option to force use of the
builtin dlopen.

It also seems that building dlopen broke at some point.  #includes
pointing to the wrong places.
diff --git a/configure.ac b/configure.ac
index 701a730..30cab8d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -139,17 +139,29 @@ dnl dynamic linker
 dnl ---------------------------------------------
 AC_ARG_ENABLE([libdvdcss], [  --enable-libdvdcss    force linking against libdvdcss])
 
+AC_ARG_ENABLE([dlfcn],
+  [AS_HELP_STRING([--enable-dlfcn],
+  [use builtin dlfcn for mingw (default is auto)])],
+  [use_builtin_dlfcn=$enableval],
+  [use_builtin_dlfcn=no])
+
+if [[ $use_builtin_dlfcn = "yes" ]]; then
+	AC_DEFINE([USING_BUILTIN_DLFCN], [1], ["Define to 1 to use builtin dlfcn"])
+fi
+
 CSS_LIBS=""
 if test x"$enable_libdvdcss" != xyes; then
 dnl dlopen libdvdcss
 case $host in
   *mingw32*)
-    AC_CHECK_LIB(c, dlopen,
-                 DYNAMIC_LD_LIBS="",
-                 AC_CHECK_LIB(dl, dlopen,
-                              DYNAMIC_LD_LIBS="-ldl",
-                              AC_MSG_ERROR(dynamic linker needed)))
-    AC_SUBST(DYNAMIC_LD_LIBS)
+    if [[ $use_builtin_dlfcn = "no" ]]; then
+        AC_CHECK_LIB(c, dlopen,
+                     DYNAMIC_LD_LIBS="",
+                     AC_CHECK_LIB(dl, dlopen,
+                                  DYNAMIC_LD_LIBS="-ldl",
+                                  AC_MSG_WARN(Using builtin dlopen)))
+        AC_SUBST(DYNAMIC_LD_LIBS)
+    fi
     LDFLAGS="-no-undefined $LDFLAGS"
     ;;
   *cygwin*)
@@ -180,6 +192,7 @@ fi
 
 AC_SUBST(CSS_LIBS)
 
+
 dnl ---------------------------------------------
 dnl cflags
 dnl ---------------------------------------------
diff --git a/msvc/contrib/dlfcn.c b/msvc/contrib/dlfcn.c
index 3a00045..15f9ec6 100644
--- a/msvc/contrib/dlfcn.c
+++ b/msvc/contrib/dlfcn.c
@@ -9,8 +9,8 @@
 #include <string.h>
 #include <stdio.h>
 
-#include "dlfcn.h"
-#include "os_types.h"
+#include "../include/dlfcn.h"
+#include "../include/os_types.h"
 
 void *dlopen(const char *module_name, int mode)
 {
diff --git a/src/dvd_input.c b/src/dvd_input.c
index d0fe30c..2649fbd 100644
--- a/src/dvd_input.c
+++ b/src/dvd_input.c
@@ -49,11 +49,13 @@ char *      (*dvdinput_error) (dvd_input_t);
 #else
 
 /* dlopening libdvdcss */
-#ifdef HAVE_DLFCN_H
+#if defined(HAVE_DLFCN_H) && !defined(USING_BUILTIN_DLFCN)
 #include <dlfcn.h>
 #else
+#if defined(WIN32)
 /* Only needed on MINGW at the moment */
-#include "../../msvc/contrib/dlfcn.c"
+#include "../msvc/contrib/dlfcn.c"
+#endif
 #endif
 
 typedef struct dvdcss_s *dvdcss_handle;
_______________________________________________
DVDnav-discuss mailing list
[email protected]
https://lists.mplayerhq.hu/mailman/listinfo/dvdnav-discuss

Reply via email to