From fcf5836fbff1b0172205f618e92c1c2d996c75ac Mon Sep 17 00:00:00 2001
From: Hicham HAOUARI <hicham.haouari@gmail.com>
Date: Tue, 1 Mar 2011 00:41:26 +0000
Subject: [PATCH] Use system ltdl

---
 Makefile.am         |   14 +---------
 configure.ac        |   63 ++++++++++++--------------------------------------
 libbase/Makefile.am |   23 +++---------------
 3 files changed, 21 insertions(+), 79 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index 1843ce8..f6193af 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -63,16 +63,12 @@ STD_DIRS = \
 	po \
 	$(NULL)
 
-if LIBLTDL2
-LIBLTDLDIR = libltdl
-endif
-
 if HAVE_VAAPI
 VAAPI_DIR = libvaapi
 endif
 
-SUBDIRS = $(LIBLTDLDIR) $(VAAPI_DIR) $(STD_DIRS)
-DIST_SUBDIRS = $(STD_DIRS) cygnal extensions testsuite libltdl libvaapi
+SUBDIRS = $(VAAPI_DIR) $(STD_DIRS)
+DIST_SUBDIRS = $(STD_DIRS) cygnal extensions testsuite libvaapi
 
 if TESTSUITE
 SUBDIRS += testsuite
@@ -109,10 +105,6 @@ EXTRA_DIST =  \
 	packaging/klash.xpm \
 	revno.h
 
-if LIBLTDL1
-EXTRA_DIST += libltdl/ltdl.h libltdl/ltdl.c
-endif
-
 # dist-hook:
 # 	@test -d "$(distdir)/packaging" || $(mkinstalldirs) "$(distdir)/packaging"
 # 	cp -p $(srcdir)/*.am $(top_distdir)/packaging/
@@ -292,8 +284,6 @@ endif
 	@echo "	X11_CFLAGS is $(X11_CFLAGS)"
 	@echo "	X11_LIBS is $(X11_LIBS)"
 	@echo "Support libraries..."
-	@echo "	INCLTDL $(INCLTDL) "
-	@echo "	LIBLTDL $(LIBLTDL) "
 	@echo "	GLIB_CFLAGS is $(GLIB_CFLAGS)"
 	@echo "	GLIB_LIBS is $(GLIB_LIBS)"
 	@echo "	Z_CFLAGS is $(Z_CFLAGS)"
diff --git a/configure.ac b/configure.ac
index 13e4f61..57613c6 100644
--- a/configure.ac
+++ b/configure.ac
@@ -21,7 +21,6 @@ AC_CONFIG_SRCDIR([libcore/as_object.h])
 AC_CONFIG_HEADERS([gnashconfig.h])
 AC_CONFIG_MACRO_DIR([macros])
 
-dnl AC_CONFIG_SUBDIRS(libltdl)
 AC_CANONICAL_BUILD
 AC_CANONICAL_HOST
 
@@ -1278,57 +1277,26 @@ AM_CONDITIONAL(BUILD_EXTENSIONS, [ test -n "$extensions_list"])
 
 GNASH_PKG_CLASSFILE
 
-ltmajor=0
-AC_MSG_CHECKING([For the version of libtool])
-if test -d ${srcdir}/libltdl/libltdl; then
-  ltver=2.x
-else
-  ltver=1.x
-fi
-ltmajor=`echo $ltver | cut -d '.' -f 1`
-AC_MSG_RESULT([$ltver])
-dnl Libtool version 1.5
-if test $ltmajor -eq 1; then
-  AC_LIBLTDL_CONVENIENCE
-  AC_LIBTOOL_DLOPEN
-  if test x"${windows}" = x"yes"; then
-    dnl The following macro may be empty; the colon is necessary
-    dnl in this case to avoid an empty if statement (which is a syntax error).
-    AC_LIBTOOL_WIN32_DLL
-    :
-  fi
-  AC_DISABLE_STATIC
-  dnl FIXME: there should really be a test here to make sure it's really there,
-  dnl but because libltdl requires us to use their config code, it's a lot harder
-  dnl to do that. So if we get this far without errors, we just blindly assume
-  dnl the header exists too. This is only used by libtool 1.5, which appears to
-  dnl mostly only effect Debian lenny or OpenBSD. Libtool; 2.x defines this, but
-  dnl libtool 1.5 doesn't, and we need it for dlopen() so extensions work.
-  AC_DEFINE(HAVE_LTDL, [1], [Libtool 2.x defines this, but libtool 1.5 doesn't])
-dnl libtool version 2.x
-else
-  dnl LT_CONFIG_LTDL_DIR([libltdl])
-  LT_INIT([dlopen win32-dll disable-static])
-  LTDL_INIT([convenience recursive])
-fi
-AC_LIB_LTDL
+dnl --------------------------------------------------------
+dnl Libtool
+dnl --------------------------------------------------------
 
+AC_LIBTOOL_DLOPEN
+AC_LIBTOOL_WIN32_DLL
+AC_DISABLE_STATIC
+AC_PROG_LIBTOOL
+AC_SUBST(LIBTOOL_DEPS)
 DLOPEN="-dlopen"
 DLPREOPEN="-dlpreopen"
 AC_SUBST(DLOPEN)
 AC_SUBST(DLPREOPEN)
 
-dnl dnl Substitute INCLTDL and LIBLTDL in the Makefiles
-AC_SUBST(INCLTDL)
-AC_SUBST(LIBLTDL)
-
-AC_PROG_LIBTOOL
-AC_SUBST(LIBTOOL_DEPS)
-
-AM_CONDITIONAL(LIBLTDL2, [test $ltmajor -eq 2])
-AM_CONDITIONAL(LIBLTDL1, [test $ltmajor -eq 1])
-AM_CONDITIONAL(CONVENIENCE_LTDL, test x"${enable_ltdl_convenience-no}" != xno)
-AM_CONDITIONAL(INSTALL_LTDL, test x"${enable_ltdl_install-no}" != xno)
+AC_CHECK_HEADER([ltdl.h],
+    [AC_CHECK_LIB([ltdl],
+                  [lt_dlinit],
+                  AC_DEFINE(HAVE_LTDL, [1], [Libtool 2.x defines this, but libtool 1.5 doesn't]),
+                  AC_MSG_ERROR([Can't find any suitable libltdl to link against]))],
+    AC_MSG_ERROR([Can't find ltdl.h]))
 
 dnl --------------------------------------------------------
 dnl SOL dir
@@ -2947,7 +2915,7 @@ SUPPORTED_GUIS="`echo ${SUPPORTED_GUIS} | sed 's/,//'`" # Strip leading comma
 AC_SUBST(SUPPORTED_GUIS)
 
 dnl AC_CONFIG_LINKS(doc/C/images)
-dnl AC_CONFIG_LINKS(gnashconfig.h,libltdl/config.h)
+dnl AC_CONFIG_LINKS(gnashconfig.h)
 AC_CONFIG_LINKS(cygnal/testsuite/cygnal.all/cygnalrc:cygnal/testsuite/cygnal.all/cygnalrc.in)
 AC_CONFIG_LINKS(testsuite/libbase.all/gnashrc:testsuite/libbase.all/gnashrc.in)
 AC_CONFIG_LINKS(testsuite/libbase.all/gnashrc-local:testsuite/libbase.all/gnashrc-local.in)
@@ -2961,7 +2929,6 @@ desktop/gnash-qt-launcher:desktop/gnash-qt-launcher.in
 AC_OUTPUT(Makefile
 desktop/Makefile
 po/Makefile
-libltdl/Makefile
 libmedia/Makefile
 libsound/Makefile
 libbase/Makefile
diff --git a/libbase/Makefile.am b/libbase/Makefile.am
index cb66fa2..ead19a3 100644
--- a/libbase/Makefile.am
+++ b/libbase/Makefile.am
@@ -23,13 +23,10 @@ sysconf_DATA = gnashrc gnashpluginrc
 # this is where Gnash plugins get installed
 pluginsdir = $(prefix)/lib/gnash/plugins
 
-# If we are using an installable libltdl, then it needs to be built
-# before libgnash, as libgnash depends on it for extensions.
 pkglib_LTLIBRARIES = libgnashbase.la
 
 libgnashbase_la_CPPFLAGS = -DPLUGINSDIR=\"$(pluginsdir)\" \
 	-DSYSCONFDIR=\"$(sysconfdir)\" \
-	-I$(top_srcdir)/libltdl \
 	$(PTHREAD_CFLAGS) \
 	$(PNG_CFLAGS) \
 	$(GIF_CFLAGS) \
@@ -40,7 +37,6 @@ libgnashbase_la_CPPFLAGS = -DPLUGINSDIR=\"$(pluginsdir)\" \
 	$(Z_CFLAGS) \
 	$(JPEG_CFLAGS) \
 	$(BOOST_CFLAGS) \
-	$(INCLTDL) \
 	$(NULL)
 
 if ANDROID
@@ -130,17 +126,7 @@ if USE_GIF
 libgnashbase_la_SOURCES += GnashImageGif.cpp
 endif
 
-if LIBLTDL1
-noinst_LTLIBRARIES = libltdlc.la
-libltdlc_la_CPPFLAGS = $(LTDLINCL) -I$(top_srcdir)/libltdl
-libltdlc_la_SOURCES = $(top_srcdir)/libltdl/ltdl.c
-libgnashbase_la_LIBADD += $(top_builddir)/libbase/libltdlc.la
-endif
-
-if LIBLTDL2
-libgnashbase_la_LIBADD += $(top_builddir)/libltdl/libltdlc.la
-endif
-
+libgnashbase_la_LIBADD += -lltdl
 
 if HAIKU
   libgnashbase_la_LIBADD += $(HAIKU_LIBS)
@@ -163,7 +149,6 @@ endif
 noinst_HEADERS =
 
 inst_HEADERS = \
-	$(LIBLTDLHEAD) \
 	accumulator.h \
 	SimpleBuffer.h \
 	extension.h \
@@ -234,8 +219,8 @@ EXTENSIONS_API = \
 instdir = $(includedir)/gnash
 inst_HEADERS += $(EXTENSIONS_API)
 
-libgnashbase_la_LDFLAGS = -release $(VERSION) 
-libgnashbase_la_DEPENDENCIES = $(LIBLTDLLIB)
+libgnashbase_la_LDFLAGS = -release $(VERSION)
+libgnashbase_la_DEPENDENCIES =
 
 if BUILD_OGL_RENDERER
    libgnashbase_la_SOURCES += \
@@ -291,7 +276,7 @@ if ENABLE_PCH
 AM_CXXFLAGS = $(PCH_FLAGS)
 endif
 
-CLEANFILES = libltdl.la libltdlc.la gnashrc gnashpluginrc
+CLEANFILES = gnashrc gnashpluginrc
 
 # Rebuild with GCC 4.x Mudflap support
 mudflap:
-- 
1.7.4

