Commit 2d3c9c2c authored by Sam Hocevar's avatar Sam Hocevar

* configure.ac:

    + First try to detect the OS X native dynamic linker before falling
      back to dlfcn.h.
    + Enhanced the dlopen-style loader detection.
    + Added a check for HP-UX's shl_* functins.
  * src/misc/modules_plugin.h.in:
    + Support for the dylib dynamic loader on OS X.
    + Support for the shl dynamic loader on HP-UX.
parent 782cc32b
dnl Autoconf settings for vlc
dnl $Id: configure.ac,v 1.81 2003/10/04 10:54:45 gbazin Exp $
dnl $Id: configure.ac,v 1.82 2003/10/04 11:17:04 sam Exp $
AC_INIT(vlc,0.6.3-cvs)
......@@ -348,9 +348,6 @@ AM_CONDITIONAL(BUILD_GETOPT, ${need_getopt})
if test "${SYS}" != "mingw32"; then
AC_TYPE_SIGNAL
AC_CHECK_LIB(dl,dlopen,[
AX_ADD_LDFLAGS([vlc],[-ldl])
])
AC_CHECK_LIB(m,cos,[
AX_ADD_LDFLAGS([imdct adjust distort a52tofloat32],[-lm])
])
......@@ -362,6 +359,69 @@ AC_CHECK_LIB(m,sqrt,[
])
fi # end "${SYS}" != "mingw32"
dnl Check for dynamic plugins
ac_cv_have_plugins=no
# OS X style
AC_CHECK_HEADERS(mach-o/dyld.h,
[AC_CHECK_FUNCS(NSLinkModule,
[AC_DEFINE(HAVE_DL_DYLD, 1, [Define if you have the Darwin dyld API])
ac_cv_have_plugins=yes])])
# HP-UX style
if test "${ac_cv_have_plugins}" = "no"; then
AC_CHECK_HEADERS(dl.h)
ac_cv_my_have_shl_load=no
AC_CHECK_FUNC(shl_load,
[ac_cv_my_have_shl_load=yes,
AC_CHECK_LIB(dld, shl_load,
[ac_cv_my_have_shl_load=yes
AX_ADD_LDFLAGS([vlc],[-ldld])])])
if test "${ac_cv_my_have_shl_load}" = "yes"; then
AC_DEFINE(HAVE_DL_SHL_LOAD, 1, [Define if you have the shl_load API])
ac_cv_have_plugins=yes
fi
fi
# Whatever style
if test "${ac_cv_have_plugins}" = "no"; then
AC_CHECK_LIB(dld, dld_link,
[AX_ADD_LDFLAGS([vlc],[-ldld])
AC_DEFINE(HAVE_DL_DLD_LINK, 1, [Define if you have the GNU dld library])
ac_cv_have_plugins=yes])
fi
# Win32 style
if test "${ac_cv_have_plugins}" = "no"; then
AC_CHECK_LIB(kernel32, main,
[AX_ADD_LDFLAGS([vlc],[-lkernel32])
ac_cv_have_plugins=yes])
fi
# BeOS style
if test "${ac_cv_have_plugins}" = "no"; then
AC_CHECK_HEADERS(image.h,
[ac_cv_have_plugins=yes])
fi
# Only test for dlopen() if the others didn't work
if test "${ac_cv_have_plugins}" = "no"; then
AC_CHECK_HEADERS(dlfcn.h sys/dl.h)
ac_cv_my_have_dlopen=no
AC_CHECK_FUNC(dlopen,
ac_cv_my_have_dlopen=yes,
AC_CHECK_LIB(dl, dlopen,
ac_cv_my_have_dlopen=yes
AX_ADD_LDFLAGS([vlc],[-ldl]),
AC_CHECK_LIB(svld, dlopen,
ac_cv_my_have_dlopen=yes
AX_ADD_LDFLAGS([vlc],[-lsvld]))))
if test "${ac_cv_my_have_dlopen}" = "yes"; then
AC_DEFINE(HAVE_DL_DLOPEN, 1, [Define if you have the dlopen API])
ac_cv_have_plugins=yes
fi
fi
if test "${SYS}" != "mingw32"; then
dnl Check for pthreads - borrowed from XMMS
THREAD_LIB=error
......@@ -467,7 +527,6 @@ AC_EGREP_HEADER(strncasecmp,strings.h,[
dnl Check for headers
AC_CHECK_HEADERS(signal.h time.h errno.h stdint.h getopt.h strings.h inttypes.h sys/int_types.h wchar.h)
AC_CHECK_HEADERS(sys/sockio.h fcntl.h sys/types.h sys/time.h sys/times.h sys/ioctl.h sys/stat.h)
AC_CHECK_HEADERS(dlfcn.h image.h)
AC_CHECK_HEADERS(arpa/inet.h net/if.h netinet/in.h sys/socket.h)
if test "${SYS}" != "mingw32"; then
AC_CHECK_HEADERS(machine/param.h sys/shm.h)
......@@ -3191,7 +3250,7 @@ AC_ARG_ENABLE(plugins,
dnl Automagically disable plugins if there is no system support for
dnl dynamically loadable files (.so, .dll, .dylib).
dnl don't forget vlc-win32 still can load .dll as plugins
if test "${ac_cv_header_dlfcn_h}" = "no" -a "${ac_cv_header_image_h}" = "no" -a "${SYS}" != "mingw32"
if test "${ac_cv_have_plugins}" = "no"
then
echo "*** Your system doesn't have plugin support. All plugins will be built"
echo "statically."
......
......@@ -2,7 +2,7 @@
* modules.h : Module management functions.
*****************************************************************************
* Copyright (C) 2001 VideoLAN
* $Id: modules.h,v 1.63 2003/01/19 03:16:24 sam Exp $
* $Id: modules.h,v 1.64 2003/10/04 11:17:04 sam Exp $
*
* Authors: Samuel Hocevar <sam@zoy.org>
*
......@@ -30,10 +30,16 @@
#define MODULE_SHORTCUT_MAX 10
/* The module handle type. */
#ifdef SYS_BEOS
typedef int module_handle_t;
#else
typedef void * module_handle_t;
#if defined(HAVE_DL_DYLD)
typedef NSModule module_handle_t;
#elif defined(HAVE_IMAGE_H)
typedef int module_handle_t;
#elif defined(WIN32) || defined(UNDER_CE)
typedef void * module_handle_t;
#elif defined(HAVE_DL_DLOPEN)
typedef void * module_handle_t;
#elif defined(HAVE_DL_SHL_LOAD)
typedef shl_t module_handle_t;
#endif
/*****************************************************************************
......
......@@ -2,7 +2,7 @@
* modules.c : Builtin and plugin modules management functions
*****************************************************************************
* Copyright (C) 2001 VideoLAN
* $Id: modules.c,v 1.133 2003/09/26 11:30:06 gbazin Exp $
* $Id: modules.c,v 1.134 2003/10/04 11:17:04 sam Exp $
*
* Authors: Samuel Hocevar <sam@zoy.org>
* Ethan C. Baldridge <BaldridgeE@cadmus.com>
......@@ -53,16 +53,26 @@
# include <unistd.h>
#endif
#if defined(HAVE_DLFCN_H) /* Linux, BSD, Hurd */
# include <dlfcn.h> /* dlopen(), dlsym(), dlclose() */
# define HAVE_DYNAMIC_PLUGINS
#elif defined(HAVE_IMAGE_H) /* BeOS */
#define HAVE_DYNAMIC_PLUGINS
#if defined (HAVE_MACH_O_DYLD_H)
# include <mach-o/dyld.h>
#elif defined (HAVE_IMAGE_H) /* BeOS */
# include <image.h>
# define HAVE_DYNAMIC_PLUGINS
#elif defined(UNDER_CE)
# define HAVE_DYNAMIC_PLUGINS
#elif defined(WIN32)
# define HAVE_DYNAMIC_PLUGINS
#elif defined (UNDER_CE)
# include <windows.h>
#elif defined (WIN32)
# include <windows.h>
#elif defined (HAVE_DL_DLOPEN)
# if defined (HAVE_DLFCN_H) /* Linux, BSD, Hurd */
# include <dlfcn.h>
# endif
# if defined (HAVE_SYS_DL_H)
# include <sys/dl.h>
# endif
#elif defined (HAVE_DL_SHL_LOAD)
# if defined (HAVE_DL_H)
# include <dl.h>
# endif
#else
# undef HAVE_DYNAMIC_PLUGINS
#endif
......
......@@ -2,7 +2,7 @@
* modules_plugin.h : Plugin management functions used by the core application.
*****************************************************************************
* Copyright (C) 2001 VideoLAN
* $Id: modules_plugin.h.in,v 1.10 2003/07/01 12:50:56 sam Exp $
* $Id: modules_plugin.h.in,v 1.11 2003/10/04 11:17:04 sam Exp $
*
* Authors: Samuel Hocevar <sam@zoy.org>
*
......@@ -33,7 +33,35 @@
*****************************************************************************/
static int module_load( const MYCHAR * psz_filename, module_handle_t * handle )
{
#ifdef SYS_BEOS
#if defined(HAVE_DL_DYLD)
NSModule handle;
NSObjectFileImage image;
NSObjectFileImageReturnCode ret;
ret = NSCreateObjectFileImageFromFile( psz_filename, &image );
if( ret != NSObjectFileImageSuccess )
{
return -1;
}
/* Open the dynamic module */
*handle = NSLinkModule( image, psz_filename,
NSLINKMODULE_OPTION_RETURN_ON_ERROR );
if( !*handle )
{
NSLinkEditErrors errors;
const char *psz_file, *psz_err;
int i_errnum;
NSLinkEditError( &errors, &i_errnum, &psz_file, &psz_err );
return -1; /* err */
}
/* Destroy our image, we won't need it */
NSDestroyObjectFileImage( image );
#elif defined(HAVE_IMAGE_H)
*handle = load_add_on( psz_filename );
return( *handle < 0 );
......@@ -41,7 +69,7 @@ static int module_load( const MYCHAR * psz_filename, module_handle_t * handle )
*handle = LoadLibrary( psz_filename );
return( *handle == NULL );
#elif defined(RTLD_NOW)
#elif defined(HAVE_DL_DLOPEN) && defined(RTLD_NOW)
/* static is OK, we are called atomically */
static vlc_bool_t b_kde = VLC_FALSE;
......@@ -71,10 +99,17 @@ static int module_load( const MYCHAR * psz_filename, module_handle_t * handle )
*handle = dlopen( psz_filename, RTLD_NOW );
return( *handle == NULL );
#else
#elif defined(HAVE_DL_DLOPEN) && defined(DL_LAZY)
*handle = dlopen( psz_filename, DL_LAZY );
return( *handle == NULL );
#elif defined(HAVE_DL_SHL_LOAD)
*handle = shl_load( psz_filename, BIND_IMMEDIATE | BIND_NONFATAL, NULL );
return( *handle == NULL );
#else
return -1;
#endif
}
......@@ -87,15 +122,21 @@ static int module_load( const MYCHAR * psz_filename, module_handle_t * handle )
*****************************************************************************/
static void module_unload( module_handle_t handle )
{
#ifdef SYS_BEOS
#if defined(HAVE_DL_DYLD)
NSUnLinkModule( handle, FALSE );
#elif defined(HAVE_IMAGE_H)
unload_add_on( handle );
#elif defined(WIN32) || defined(UNDER_CE)
FreeLibrary( handle );
#else
#elif defined(HAVE_DL_DLOPEN)
dlclose( handle );
#elif defined(HAVE_DL_SHL_LOAD)
shl_unload( handle );
#endif
return;
}
......@@ -110,7 +151,11 @@ static void module_unload( module_handle_t handle )
static void * _module_getsymbol( module_handle_t handle,
const char * psz_function )
{
#ifdef SYS_BEOS
#if defined(HAVE_DL_DYLD)
NSSymbol sym = NSLookupSymbolInModule( handle, psz_function );
return NSAddressOfSymbol( sym );
#elif defined(HAVE_IMAGE_H)
void * p_symbol;
if( B_OK == get_image_symbol( handle, psz_function,
B_SYMBOL_TYPE_TEXT, &p_symbol ) )
......@@ -131,9 +176,14 @@ static void * _module_getsymbol( module_handle_t handle,
#elif defined( WIN32 )
return (void *)GetProcAddress( handle, (MYCHAR*)psz_function );
#else
#elif defined(HAVE_DL_DLOPEN)
return dlsym( handle, psz_function );
#elif defined(HAVE_DL_SHL_LOAD)
void *p_sym;
shl_findsym( &handle, psz_function, TYPE_UNDEFINED, &p_sym );
return p_sym;
#endif
}
......@@ -168,7 +218,10 @@ static void * module_getsymbol( module_handle_t handle,
*****************************************************************************/
static const char * module_error( char *psz_buffer )
{
#if defined(SYS_BEOS)
#if defined(HAVE_DL_DYLD)
return "failed";
#elif defined(HAVE_IMAGE_H)
return "failed";
#elif defined(UNDER_CE)
......@@ -216,9 +269,12 @@ static const char * module_error( char *psz_buffer )
return psz_buffer;
#else
#elif defined(HAVE_DL_DLOPEN)
return dlerror();
#elif defined(HAVE_DL_SHL_LOAD)
return strerror( errno );
#endif
}
......
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