At Tue, 20 Mar 2007 08:13:41 -0700 (PDT), Ciaccia wrote: > > Hi Takashi, > It's clear that the concept of dynamic loading doesn't > conflict with static library, I think my original > question was not completely clear. > > I would like to port a sound application (just PCM, no > midi or other stuff) to an embedded system. The core > of this embedded system is a Cirrus EP9302 ARM > processor, which supports hardware floating points. > > ARM processors have several ABIs (EABI, OABI, ???) and > programs compiled using one ABI are not linkable > (neither at compile time, nor at run time) with other > binaries, because of the different format. This is a > problem for binary distributions (such as Debian), > since the same binary does not work on all ARM > architectures. > > For a reason I really don't understand, EP9302 > hardware floating point binaries only work when > compiled with -static (don't ask me why...), and > therefore I wanted to have a "static" (=without shared > libraries) ALSA application. If this would not be > possible I can always use OSS (which does not requires > shared objects to be loaded at run time), but I still > think it should be possible to develop ALSA > applications for architectures where dynamic loading > is not available... > > Is there a way to achieve this? Sure, what I meant is that the patch had no function to disable the libdl and libpthread explicitly but only checked. The new patch below, for example, can give you options --with-libdl and --with-pthread. For disabling libdl, pass --with-libdl=no. If this works for you, I'll apply it to the upstream. Takashi diff -r 6d0a999aef24 Makefile.am --- a/Makefile.am Fri Mar 16 15:22:27 2007 +0100 +++ b/Makefile.am Tue Mar 20 16:55:23 2007 +0100 @@ -1,4 +1,7 @@ SUBDIRS=doc include src modules -SUBDIRS=doc include src modules +SUBDIRS=doc include src +if BUILD_MODULES +SUBDIRS += modules +endif if BUILD_PCM_PLUGIN_SHM SUBDIRS += aserver endif diff -r 6d0a999aef24 configure.in --- a/configure.in Fri Mar 16 15:22:27 2007 +0100 +++ b/configure.in Tue Mar 20 16:55:00 2007 +0100 @@ -148,6 +148,44 @@ else else AC_MSG_RESULT(no) fi + +ALSA_DEPLIBS="" +if test "$softfloat" != "yes"; then + ALSA_DEPLIBS="-lm" +fi + +dnl Check for libdl +AC_MSG_CHECKING(for libdl) +AC_ARG_WITH(libdl, + [ --with-libdl Use libdl for plugins (default = yes)], + [ have_libdl="$withval" ], [ have_libdl="yes" ]) +if test "$have_libdl" = "yes"; then + AC_CHECK_LIB([dl], [dlsym], [HAVE_LIBDL="yes"]) + if test "$HAVE_LIBDL" = "yes" ; then + ALSA_DEPLIBS="$ALSA_DEPLIBS -ldl" + AC_DEFINE([HAVE_LIBDL], 1, [Have libdl]) + fi +else + AC_MSG_RESULT(no) +fi +AM_CONDITIONAL(BUILD_MODULES, test "$HAVE_LIBDL"="yes") + +dnl Check for pthread +AC_MSG_CHECKING(for pthread) +AC_ARG_WITH(pthread, + [ --with-pthread Use pthread (default = yes)], + [ have_pthread="$withval" ], [ have_pthread="yes" ]) +if test "$have_pthread" = "yes"; then + AC_CHECK_LIB([pthread], [pthread_join], [HAVE_LIBPTHREAD="yes"]) + if test "$HAVE_LIBPTHREAD" = "yes"; then + ALSA_DEPLIBS="$ALSA_DEPLIBS -lpthread" + AC_DEFINE([HAVE_LIBPTHREAD], 1, [Have libpthread]) + fi +else + AC_MSG_RESULT(no) +fi + +AC_SUBST(ALSA_DEPLIBS) dnl Check for architecture AC_MSG_CHECKING(for architecture) @@ -318,6 +356,21 @@ fi if test "$build_pcm_ioplug" = "yes"; then build_pcm_extplug="yes" +fi + +if test "$HAVE_LIBDL" != "yes"; then + build_pcm_meter="no" + build_pcm_ladspa="no" + build_pcm_pcm_ioplug="no" + build_pcm_pcm_extplug="no" +fi + +if test "$HAVE_LIBPTHREAD" != "yes"; then + build_pcm_share="no" +fi + +if test "$softfloat" != "yes"; then + build_pcm_lfloat="no" fi AM_CONDITIONAL(BUILD_PCM_PLUGIN, test x$build_pcm_plugin = xyes) diff -r 6d0a999aef24 include/local.h --- a/include/local.h Fri Mar 16 15:22:27 2007 +0100 +++ b/include/local.h Tue Mar 20 16:16:36 2007 +0100 @@ -36,6 +36,11 @@ #include "config.h" #ifdef SUPPORT_RESMGR #include <resmgr.h> +#endif +#ifdef HAVE_LIBDL +#include <dlfcn.h> +#else +#define RTLD_NOW 0 #endif #define _snd_config_iterator list_head diff -r 6d0a999aef24 src/Makefile.am --- a/src/Makefile.am Fri Mar 16 15:22:27 2007 +0100 +++ b/src/Makefile.am Tue Mar 20 16:16:36 2007 +0100 @@ -41,7 +41,7 @@ libasound_la_LIBADD += alisp/libalisp.la libasound_la_LIBADD += alisp/libalisp.la endif SUBDIRS += compat conf -libasound_la_LIBADD += compat/libcompat.la -lm -ldl -lpthread +libasound_la_LIBADD += compat/libcompat.la @ALSA_DEPLIBS@ libasound_la_LDFLAGS = -version-info $(COMPATNUM) $(VSYMS) diff -r 6d0a999aef24 src/async.c --- a/src/async.c Fri Mar 16 15:22:27 2007 +0100 +++ b/src/async.c Tue Mar 20 16:16:36 2007 +0100 @@ -151,9 +151,11 @@ int snd_async_del_handler(snd_async_hand if (!list_empty(&handler->hlist)) goto _end; switch (handler->type) { +#ifdef BUILD_PCM case SND_ASYNC_HANDLER_PCM: err = snd_pcm_async(handler->u.pcm, -1, 1); break; +#endif case SND_ASYNC_HANDLER_CTL: err = snd_ctl_async(handler->u.ctl, -1, 1); break; diff -r 6d0a999aef24 src/conf.c --- a/src/conf.c Fri Mar 16 15:22:27 2007 +0100 +++ b/src/conf.c Tue Mar 20 16:16:36 2007 +0100 @@ -415,12 +415,13 @@ beginning:</P> #include <stdarg.h> -#include <dlfcn.h> #include <limits.h> #include <sys/stat.h> -#include <pthread.h> #include <locale.h> #include "local.h" +#ifdef HAVE_LIBPTHREAD +#include <pthread.h> +#endif #ifndef DOC_HIDDEN @@ -3080,7 +3081,9 @@ int snd_config_update_r(snd_config_t **_ return 1; } +#ifdef HAVE_LIBPTHREAD static pthread_mutex_t snd_config_update_mutex = PTHREAD_MUTEX_INITIALIZER; +#endif /** * \brief Updates #snd_config by rereading the global configuration files (if needed). @@ -3099,9 +3102,13 @@ int snd_config_update(void) { int err; +#ifdef HAVE_LIBPTHREAD pthread_mutex_lock(&snd_config_update_mutex); +#endif err = snd_config_update_r(&snd_config, &snd_config_global_update, NULL); +#ifdef HAVE_LIBPTHREAD pthread_mutex_unlock(&snd_config_update_mutex); +#endif return err; } @@ -3128,15 +3135,18 @@ int snd_config_update_free(snd_config_up */ int snd_config_update_free_global(void) { +#ifdef HAVE_LIBPTHREAD pthread_mutex_lock(&snd_config_update_mutex); +#endif if (snd_config) snd_config_delete(snd_config); snd_config = NULL; if (snd_config_global_update) snd_config_update_free(snd_config_global_update); snd_config_global_update = NULL; +#ifdef HAVE_LIBPTHREAD pthread_mutex_unlock(&snd_config_update_mutex); - +#endif /* FIXME: better to place this in another place... */ snd_dlobj_cache_cleanup(); diff -r 6d0a999aef24 src/confmisc.c --- a/src/confmisc.c Fri Mar 16 15:22:27 2007 +0100 +++ b/src/confmisc.c Tue Mar 20 16:16:36 2007 +0100 @@ -946,6 +946,8 @@ SND_DLSYM_BUILD_VERSION(snd_func_card_na SND_DLSYM_BUILD_VERSION(snd_func_card_name, SND_CONFIG_DLSYM_VERSION_EVALUATE); #endif +#ifdef BUILD_PCM + /** * \brief Returns the pcm identification of a device. * \param dst The function puts the handle to the result configuration node @@ -1198,6 +1200,8 @@ int snd_func_private_pcm_subdevice(snd_c #ifndef DOC_HIDDEN SND_DLSYM_BUILD_VERSION(snd_func_private_pcm_subdevice, SND_CONFIG_DLSYM_VERSION_EVALUATE); #endif + +#endif /* BUILD_PCM */ /** * \brief Copies the specified configuration node. diff -r 6d0a999aef24 src/control/control.c --- a/src/control/control.c Fri Mar 16 15:22:27 2007 +0100 +++ b/src/control/control.c Tue Mar 20 16:16:36 2007 +0100 @@ -47,7 +47,6 @@ and IEC958 structure. #include <string.h> #include <fcntl.h> #include <signal.h> -#include <dlfcn.h> #include <sys/poll.h> #include "control_local.h" diff -r 6d0a999aef24 src/control/hcontrol.c --- a/src/control/hcontrol.c Fri Mar 16 15:22:27 2007 +0100 +++ b/src/control/hcontrol.c Tue Mar 20 16:16:36 2007 +0100 @@ -48,11 +48,13 @@ to reduce overhead accessing the real co #include <string.h> #include <fcntl.h> #include <sys/ioctl.h> -#include <pthread.h> #ifndef DOC_HIDDEN #define __USE_GNU #endif #include "control_local.h" +#ifdef HAVE_LIBPTHREAD +#include <pthread.h> +#endif #ifndef DOC_HIDDEN #define NOT_FOUND 1000000000 @@ -420,17 +422,22 @@ static void snd_hctl_sort(snd_hctl_t *hc static void snd_hctl_sort(snd_hctl_t *hctl) { unsigned int k; +#ifdef HAVE_LIBPTHREAD static pthread_mutex_t sync_lock = PTHREAD_MUTEX_INITIALIZER; +#endif assert(hctl); assert(hctl->compare); INIT_LIST_HEAD(&hctl->elems); +#ifdef HAVE_LIBPTHREAD pthread_mutex_lock(&sync_lock); +#endif compare_hctl = hctl; qsort(hctl->pelems, hctl->count, sizeof(*hctl->pelems), hctl_compare); +#ifdef HAVE_LIBPTHREAD pthread_mutex_unlock(&sync_lock); - +#endif for (k = 0; k < hctl->count; k++) list_add_tail(&hctl->pelems[k]->list, &hctl->elems); } diff -r 6d0a999aef24 src/dlmisc.c --- a/src/dlmisc.c Fri Mar 16 15:22:27 2007 +0100 +++ b/src/dlmisc.c Tue Mar 20 16:51:13 2007 +0100 @@ -28,7 +28,6 @@ */ #define _GNU_SOURCE -#include <dlfcn.h> #include "list.h" #include "local.h" @@ -53,13 +52,19 @@ void *snd_dlopen(const char *name, int m if (name == NULL) return &snd_dlsym_start; #else +#ifdef HAVE_LIBDL if (name == NULL) { Dl_info dlinfo; if (dladdr(snd_dlopen, &dlinfo) > 0) name = dlinfo.dli_fname; } #endif +#endif +#ifdef HAVE_LIBDL return dlopen(name, mode); +#else + return NULL; +#endif } /** @@ -76,7 +81,11 @@ int snd_dlclose(void *handle) if (handle == &snd_dlsym_start) return 0; #endif +#ifdef HAVE_LIBDL return dlclose(handle); +#else + return 0; +#endif } /** @@ -91,6 +100,7 @@ int snd_dlclose(void *handle) */ static int snd_dlsym_verify(void *handle, const char *name, const char *version) { +#ifdef HAVE_LIBDL int res; char *vname; @@ -107,6 +117,9 @@ static int snd_dlsym_verify(void *handle if (res < 0) SNDERR("unable to verify version for symbol %s", name); return res; +#else + return 0; +#endif } /** @@ -139,10 +152,16 @@ void *snd_dlsym(void *handle, const char return NULL; } #endif - err = snd_dlsym_verify(handle, name, version); - if (err < 0) - return NULL; +#ifdef HAVE_LIBDL + if (version) { + err = snd_dlsym_verify(handle, name, version); + if (err < 0) + return NULL; + } return dlsym(handle, name); +#else + return NULL; +#endif } /* diff -r 6d0a999aef24 src/hwdep/hwdep.c --- a/src/hwdep/hwdep.c Fri Mar 16 15:22:27 2007 +0100 +++ b/src/hwdep/hwdep.c Tue Mar 20 16:16:36 2007 +0100 @@ -33,7 +33,6 @@ #include <unistd.h> #include <string.h> #include <fcntl.h> -#include <dlfcn.h> #include <sys/ioctl.h> #include "hwdep_local.h" diff -r 6d0a999aef24 src/mixer/simple_abst.c --- a/src/mixer/simple_abst.c Fri Mar 16 15:22:27 2007 +0100 +++ b/src/mixer/simple_abst.c Tue Mar 20 16:52:35 2007 +0100 @@ -82,14 +82,14 @@ static int try_open(snd_mixer_class_t *c free(xlib); return -ENXIO; } - event_func = dlsym(h, "alsa_mixer_simple_event"); + event_func = snd_dlsym(h, "alsa_mixer_simple_event", NULL); if (event_func == NULL) { SNDERR("Symbol 'alsa_mixer_simple_event' was not found in '%s'", xlib); snd_dlclose(h); free(xlib); return -ENXIO; } - init_func = dlsym(h, "alsa_mixer_simple_init"); + init_func = snd_dlsym(h, "alsa_mixer_simple_init", NULL); if (init_func == NULL) { SNDERR("Symbol 'alsa_mixer_simple_init' was not found in '%s'", xlib); snd_dlclose(h); diff -r 6d0a999aef24 src/pcm/pcm.c --- a/src/pcm/pcm.c Fri Mar 16 15:22:27 2007 +0100 +++ b/src/pcm/pcm.c Tue Mar 20 16:16:36 2007 +0100 @@ -634,7 +634,6 @@ playback devices. #include <malloc.h> #include <stdarg.h> #include <signal.h> -#include <dlfcn.h> #include <sys/poll.h> #include <sys/shm.h> #include <sys/mman.h> diff -r 6d0a999aef24 src/pcm/pcm_hooks.c --- a/src/pcm/pcm_hooks.c Fri Mar 16 15:22:27 2007 +0100 +++ b/src/pcm/pcm_hooks.c Tue Mar 20 16:16:36 2007 +0100 @@ -27,7 +27,6 @@ * */ -#include <dlfcn.h> #include "pcm_local.h" #include "pcm_generic.h" diff -r 6d0a999aef24 src/pcm/pcm_ladspa.c --- a/src/pcm/pcm_ladspa.c Fri Mar 16 15:22:27 2007 +0100 +++ b/src/pcm/pcm_ladspa.c Tue Mar 20 16:16:36 2007 +0100 @@ -33,7 +33,6 @@ */ #include <dirent.h> -#include <dlfcn.h> #include <locale.h> #include <math.h> #include "pcm_local.h" diff -r 6d0a999aef24 src/pcm/pcm_rate.c --- a/src/pcm/pcm_rate.c Fri Mar 16 15:22:27 2007 +0100 +++ b/src/pcm/pcm_rate.c Tue Mar 20 16:51:41 2007 +0100 @@ -29,7 +29,6 @@ */ #include <inttypes.h> #include <byteswap.h> -#include <dlfcn.h> #include "pcm_local.h" #include "pcm_plugin.h" #include "pcm_rate.h" @@ -1326,7 +1325,7 @@ int snd_pcm_rate_open(snd_pcm_t **pcmp, free(rate); return -ENOENT; } - open_func = dlsym(h, open_name); + open_func = snd_dlsym(h, open_name, NULL); if (! open_func) { SNDERR("Cannot find function %s", open_name); snd_dlclose(h); diff -r 6d0a999aef24 src/rawmidi/rawmidi.c --- a/src/rawmidi/rawmidi.c Fri Mar 16 15:22:27 2007 +0100 +++ b/src/rawmidi/rawmidi.c Tue Mar 20 16:16:36 2007 +0100 @@ -139,7 +139,6 @@ This example shows open and read/write r #include <stdarg.h> #include <unistd.h> #include <string.h> -#include <dlfcn.h> #include "rawmidi_local.h" /** diff -r 6d0a999aef24 src/seq/seq.c --- a/src/seq/seq.c Fri Mar 16 15:22:27 2007 +0100 +++ b/src/seq/seq.c Tue Mar 20 16:16:36 2007 +0100 @@ -777,7 +777,6 @@ void event_filter(snd_seq_t *seq, snd_se */ -#include <dlfcn.h> #include <sys/poll.h> #include "seq_local.h" diff -r 6d0a999aef24 src/timer/timer.c --- a/src/timer/timer.c Fri Mar 16 15:22:27 2007 +0100 +++ b/src/timer/timer.c Tue Mar 20 16:16:36 2007 +0100 @@ -72,7 +72,6 @@ This example shows opening a timer devic #include <unistd.h> #include <string.h> #include <fcntl.h> -#include <dlfcn.h> #include <signal.h> #include <sys/ioctl.h> #include "timer_local.h" diff -r 6d0a999aef24 src/timer/timer_query.c --- a/src/timer/timer_query.c Fri Mar 16 15:22:27 2007 +0100 +++ b/src/timer/timer_query.c Tue Mar 20 16:16:36 2007 +0100 @@ -31,7 +31,6 @@ #include <unistd.h> #include <string.h> #include <fcntl.h> -#include <dlfcn.h> #include <sys/ioctl.h> #include "timer_local.h" diff -r 6d0a999aef24 utils/alsa.pc.in --- a/utils/alsa.pc.in Fri Mar 16 15:22:27 2007 +0100 +++ b/utils/alsa.pc.in Tue Mar 20 16:16:36 2007 +0100 @@ -8,7 +8,7 @@ Version: @VERSION@ Version: @VERSION@ Requires: Libs: -L${libdir} -lasound -Libs.private: -lm -ldl -lpthread +Libs.private: @ALSA_DEPLIBS@ # -I${includedir}/alsa below is just for backward compatibility # (it was set so mistakely in the older version) Cflags: -I${includedir} -I${includedir}/alsa ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys-and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ Alsa-devel mailing list Alsa-devel@xxxxxxxxxxxxxxxxxxxxx https://lists.sourceforge.net/lists/listinfo/alsa-devel