Commit cc629fa5 authored by Pierre d'Herbemont's avatar Pierre d'Herbemont

Allow libvlc client to build statically.

parent 514d6aa6
......@@ -411,6 +411,19 @@ AS_IF([test "${enable_shared}" = "no"], [
AC_MSG_ERROR([VLC is based on plugins. Shared libraries cannot be disabled.])
])
AC_ARG_ENABLE(static-modules,
[ --enable-static-modules Allow module to be linked statically. This produces a non working vlc.])
AS_IF([test "${enable_static_modules}" = yes], [
enable_shared="no"
enable_static="yes"
VLC_DEFAULT_PLUGIN_TYPE="builtin"
echo "*** WARNING: Building modules as static. VLC will not work."
], [
VLC_DEFAULT_PLUGIN_TYPE="plugin"
])
AC_SUBST(VLC_DEFAULT_PLUGIN_TYPE)
dnl
dnl Gettext stuff
dnl
......
......@@ -135,6 +135,41 @@ const char *libvlc_printerr (const char *fmt, ...);
VLC_PUBLIC_API libvlc_instance_t *
libvlc_new( int argc , const char *const *argv );
/**
* \return a static entry point for a module, suitable for passing to
* libvlc_new_with_builtins. This is to be used when you want to statically
* link to a module.
*
* Note, statically linking to a module will results in nearly zero speed gain
* and increased memory usage. Use with caution.
*/
#define vlc_plugin(module) & vlc_plugin_entry(module)
#define vlc_plugin_entry(module) vlc_entry__ ## module
#define vlc_declare_plugin(module) extern void *vlc_plugin_entry(module);
/**
* Create and initialize a libvlc instance.
*
* \param argc the number of arguments
* \param argv command-line-type arguments
* \param builtins a NULL terminated array of \see vlc_plugin.
* \return the libvlc instance or NULL in case of error
* @begincode
* {
* vlc_declare_plugin(mp4);
* vlc_declare_plugin(dummy);
* const void **builtins = { vlc_plugin(mp4), vlc_plugin(dummy), NULL };
* libvlc_instance_t *vlc = libvlc_new_with_builtins(argc, argv, builtins);
* }
* @endcode
*/
VLC_PUBLIC_API libvlc_instance_t *
libvlc_new_with_builtins( int argc , const char *const *argv, const void **builtins);
/**
* Decrement the reference count of a libvlc instance, and destroy it
* if it reaches zero.
......@@ -264,7 +299,7 @@ typedef int libvlc_event_type_t;
* \param p_event the event triggering the callback
*/
typedef void ( *libvlc_callback_t )( const struct libvlc_event_t *, void * );
/**
* Register for an event notification.
*
......
......@@ -13,17 +13,17 @@ CLEANFILES = $(BUILT_SOURCES)
LTLIBVLCCORE = $(top_builddir)/src/libvlccore.la
AM_CFLAGS = `$(VLC_CONFIG) --cflags plugin $@`
AM_CXXFLAGS = `$(VLC_CONFIG) --cxxflags plugin $@`
AM_OBJCFLAGS = `$(VLC_CONFIG) --objcflags plugin $@`
AM_CFLAGS = `$(VLC_CONFIG) --cflags $(VLC_DEFAULT_PLUGIN_TYPE) $@`
AM_CXXFLAGS = `$(VLC_CONFIG) --cxxflags $(VLC_DEFAULT_PLUGIN_TYPE) $@`
AM_OBJCFLAGS = `$(VLC_CONFIG) --objcflags $(VLC_DEFAULT_PLUGIN_TYPE) $@`
AM_LDFLAGS = -rpath '$(libvlcdir)' \
-avoid-version -module \
-export-symbols-regex ^vlc_entry \
-shrext $(LIBEXT) \
-rpath "$(libvlcdir)" \
-no-undefined \
`$(VLC_CONFIG) --ldflags plugin $@`
AM_LIBADD = `$(VLC_CONFIG) -libs plugin $@` \
`$(VLC_CONFIG) --ldflags $(VLC_DEFAULT_PLUGIN_TYPE) $@`
AM_LIBADD = `$(VLC_CONFIG) -libs $(VLC_DEFAULT_PLUGIN_TYPE) $@` \
$(LTLIBVLCCORE) $(top_builddir)/compat/libcompat.la
include $(srcdir)/Modules.am
......
......@@ -37,7 +37,8 @@
static const char nomemstr[] = "Insufficient memory";
libvlc_instance_t * libvlc_new( int argc, const char *const *argv )
libvlc_instance_t * libvlc_new_with_builtins( int argc, const char *const *argv,
const void ** builtins_module)
{
libvlc_instance_t *p_new = malloc (sizeof (*p_new));
if (unlikely(p_new == NULL))
......@@ -55,7 +56,7 @@ libvlc_instance_t * libvlc_new( int argc, const char *const *argv )
if (unlikely (p_libvlc_int == NULL))
goto error;
if (libvlc_InternalInit( p_libvlc_int, argc + 1, my_argv ))
if (libvlc_InternalInit( p_libvlc_int, argc + 1, my_argv, builtins_module ))
{
libvlc_InternalDestroy( p_libvlc_int );
goto error;
......@@ -79,6 +80,12 @@ error:
return NULL;
}
libvlc_instance_t * libvlc_new( int argc, const char *const *argv)
{
return libvlc_new_with_builtins(argc, argv, NULL);
}
void libvlc_retain( libvlc_instance_t *p_instance )
{
assert( p_instance != NULL );
......
......@@ -44,7 +44,7 @@
* Internal creation and destruction functions
***************************************************************************/
VLC_EXPORT (libvlc_int_t *, libvlc_InternalCreate, ( void ) );
VLC_EXPORT (int, libvlc_InternalInit, ( libvlc_int_t *, int, const char *ppsz_argv[] ) );
VLC_EXPORT (int, libvlc_InternalInit, ( libvlc_int_t *, int, const char *ppsz_argv[], const void **builtins_module) );
VLC_EXPORT (void, libvlc_InternalCleanup, ( libvlc_int_t * ) );
VLC_EXPORT (void, libvlc_InternalDestroy, ( libvlc_int_t * ) );
......
......@@ -249,7 +249,7 @@ error:
* - configuration and commandline parsing
*/
int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc,
const char *ppsz_argv[] )
const char *ppsz_argv[], const void **builtins_module )
{
libvlc_priv_t *priv = libvlc_priv (p_libvlc);
char * p_tmp = NULL;
......@@ -410,7 +410,7 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc,
* list of configuration options exported by each module and loads their
* default values.
*/
module_LoadPlugins( p_libvlc );
module_LoadPlugins( p_libvlc, builtins_module );
if( p_libvlc->b_die )
{
b_exit = true;
......@@ -471,7 +471,7 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc,
}
}
if( module_count <= 1)
if( module_count <= 1 )
{
msg_Err( p_libvlc, "No modules were found, refusing to start. Check "
"that you properly gave a module path with --plugin-path.");
......
......@@ -159,6 +159,7 @@ libvlc_media_set_state
libvlc_media_set_user_data
libvlc_media_subitems
libvlc_new
libvlc_new_with_builtins
libvlc_playlist_play
libvlc_release
libvlc_retain
......
......@@ -198,13 +198,19 @@ void module_EndBank( vlc_object_t *p_this, bool b_plugins )
* \param p_this vlc object structure
* \return nothing
*/
void module_LoadPlugins( vlc_object_t * p_this )
void module_LoadPlugins( vlc_object_t * p_this, const void **builtins )
{
module_bank_t *p_bank = p_module_bank;
assert( p_bank );
/*vlc_assert_locked( &module_lock ); not for static mutexes :( */
if (builtins)
{
for (int i = 0; builtins[i]; i++)
AllocateBuiltinModule( p_this, builtins[i] );
}
#ifdef HAVE_DYNAMIC_PLUGINS
if( p_bank->i_usage == 1 )
{
......
......@@ -139,10 +139,10 @@ struct module_t
module_t *vlc_module_create (vlc_object_t *);
module_t *vlc_submodule_create (module_t *module);
void module_InitBank( vlc_object_t * );
void module_InitBank( vlc_object_t *);
#define module_InitBank(a) module_InitBank(VLC_OBJECT(a))
void module_LoadPlugins( vlc_object_t * );
#define module_LoadPlugins(a) module_LoadPlugins(VLC_OBJECT(a))
void module_LoadPlugins( vlc_object_t *, const void ** );
#define module_LoadPlugins(a, b) module_LoadPlugins(VLC_OBJECT(a), b)
void module_EndBank( vlc_object_t *, bool );
#define module_EndBank(a,b) module_EndBank(VLC_OBJECT(a), b)
......
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