From b7e54037ed25e23b150e70a9c90ade8c8f127026 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Wed, 6 Mar 2002 05:20:11 +0000 Subject: [PATCH] Added a new header file: SDL_loadso.h It contains the following functions: SDL_LoadObject(), SDL_LoadFunction(), SDL_UnloadObject() The UNIX esd and arts audio code use these to dynamically load their respective audio libraries. --HG-- extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%40295 --- WhatsNew | 6 + configure.in | 74 ++++++++++++- docs.html | 1 + include/Makefile.am | 1 + include/SDL.h | 1 + include/SDL_loadso.h | 61 +++++++++++ include/SDL_name.h | 2 - src/Makefile.am | 3 +- src/SDL_loadso.c | 193 +++++++++++++++++++++++++++++++++ src/audio/arts/Makefile.am | 2 + src/audio/arts/SDL_artsaudio.c | 111 +++++++++++++++++-- src/audio/esd/Makefile.am | 2 + src/audio/esd/SDL_esdaudio.c | 83 +++++++++++++- 13 files changed, 516 insertions(+), 24 deletions(-) create mode 100644 include/SDL_loadso.h create mode 100644 src/SDL_loadso.c diff --git a/WhatsNew b/WhatsNew index 91480aa4..9ecdead2 100644 --- a/WhatsNew +++ b/WhatsNew @@ -4,6 +4,12 @@ This is a list of API changes in SDL's version history. Version 1.0: 1.2.4: + Added a new header file: SDL_loadso.h + It contains the following functions: + SDL_LoadObject(), SDL_LoadFunction(), SDL_UnloadObject() + The UNIX esd and arts audio code use these to dynamically load + their respective audio libraries. + Added SDL_LockRect() and SDL_UnlockRect() to lock a portion of a surface. This may be more efficient than a full lock if you are using a hardware surface and plan to make a few changes to small diff --git a/configure.in b/configure.in index 927a59d1..2511023a 100644 --- a/configure.in +++ b/configure.in @@ -324,12 +324,26 @@ CheckESD() [ --enable-esd support the Enlightened Sound Daemon [default=yes]], , enable_esd=yes) if test x$enable_audio = xyes -a x$enable_esd = xyes; then - AM_PATH_ESD(0.2.8, [ - CFLAGS="$CFLAGS -DESD_SUPPORT $ESD_CFLAGS" - SYSTEM_LIBS="$SYSTEM_LIBS $ESD_LIBS" + use_esd=no + AM_PATH_ESD(0.2.8, use_esd=yes) + if test x$use_esd = xyes; then + AC_ARG_ENABLE(esd-shared, +[ --enable-esd-shared dynamically load ESD support [default=yes]], + , enable_esd_shared=yes) + esd_lib_spec=`echo $ESD_LIBS | sed 's/.*-L\([[^ ]]*\).*/\1\/libesd.so.*/'` + esd_lib=`ls $esd_lib_spec | head -1 | sed 's/.*\/\(.*\)/\1/'` + echo "-- $esd_lib_spec -> $esd_lib" + if test x$enable_dlopen = xyes && \ + test x$enable_esd_shared = xyes && test x$esd_lib != x; then + CFLAGS="$CFLAGS -DESD_SUPPORT -DESD_DYNAMIC=\$(esd_lib) $ESD_CFLAGS" + AC_SUBST(esd_lib) + else + CFLAGS="$CFLAGS -DESD_SUPPORT $ESD_CFLAGS" + SYSTEM_LIBS="$SYSTEM_LIBS $ESD_LIBS" + fi AUDIO_SUBDIRS="$AUDIO_SUBDIRS esd" AUDIO_DRIVERS="$AUDIO_DRIVERS esd/libaudio_esd.la" - ]) + fi fi } @@ -359,8 +373,20 @@ CheckARTSC() CFLAGS="$save_CFLAGS" AC_MSG_RESULT($audio_arts) if test x$audio_arts = xyes; then - CFLAGS="$CFLAGS -DARTSC_SUPPORT $ARTSC_CFLAGS" - SYSTEM_LIBS="$SYSTEM_LIBS $ARTSC_LIBS" + AC_ARG_ENABLE(arts-shared, +[ --enable-arts-shared dynamically load ESD support [default=yes]], + , enable_arts_shared=yes) + arts_lib_spec=`echo $ARTSC_LIBS | sed 's/.*-L\([[^ ]]*\).*/\1\/libarts.so.*/'` + arts_lib=`ls $arts_lib_spec | head -1 | sed 's/.*\/\(.*\)/\1/'` + echo "-- $arts_lib_spec -> $arts_lib" + if test x$enable_dlopen = xyes && \ + test x$enable_arts_shared = xyes && test x$arts_lib != x; then + CFLAGS="$CFLAGS -DARTSC_SUPPORT -DARTSC_DYNAMIC=\$(arts_lib) $ARTSC_CFLAGS" + AC_SUBST(arts_lib) + else + CFLAGS="$CFLAGS -DARTSC_SUPPORT $ARTSC_CFLAGS" + SYSTEM_LIBS="$SYSTEM_LIBS $ARTSC_LIBS" + fi AUDIO_SUBDIRS="$AUDIO_SUBDIRS arts" AUDIO_DRIVERS="$AUDIO_DRIVERS arts/libaudio_arts.la" fi @@ -1353,11 +1379,36 @@ CheckQUARTZ() VIDEO_DRIVERS="$VIDEO_DRIVERS quartz/libvideo_quartz.la" } +dnl Check for the dlfcn.h interface for dynamically loading objects +CheckDLOPEN() +{ + AC_ARG_ENABLE(dlopen, +[ --enable-dlopen use dlopen for shared object loading [default=yes]], + , enable_dlopen=yes) + if test x$enable_dlopen = xyes; then + AC_MSG_CHECKING(for dlopen) + use_dlopen=no + AC_TRY_COMPILE([ + #include + ],[ + ],[ + use_dlopen=yes + ]) + AC_MSG_RESULT($use_dlopen) + + if test x$use_dlopen = xyes; then + CFLAGS="$CFLAGS -DUSE_DLOPEN" + SYSTEM_LIBS="$SYSTEM_LIBS -ldl" + fi + fi +} + case "$target" in *-*-linux*) ARCH=linux CheckDummyVideo CheckDiskAudio + CheckDLOPEN CheckNASM CheckOSS CheckALSA @@ -1429,6 +1480,7 @@ case "$target" in ARCH=bsdi CheckDummyVideo CheckDiskAudio + CheckDLOPEN CheckNASM CheckOSS CheckARTSC @@ -1480,6 +1532,7 @@ case "$target" in ARCH=freebsd CheckDummyVideo CheckDiskAudio + CheckDLOPEN CheckVGL CheckNASM CheckOSS @@ -1535,6 +1588,7 @@ case "$target" in ARCH=netbsd CheckDummyVideo CheckDiskAudio + CheckDLOPEN CheckNASM CheckOSS CheckARTSC @@ -1588,6 +1642,7 @@ case "$target" in ARCH=openbsd CheckDummyVideo CheckDiskAudio + CheckDLOPEN CheckOPENBSDAUDIO CheckNASM CheckOSS @@ -1647,6 +1702,7 @@ case "$target" in ARCH=sysv5 CheckDummyVideo CheckDiskAudio + CheckDLOPEN CheckNASM CheckOSS CheckARTSC @@ -1696,6 +1752,7 @@ case "$target" in CFLAGS="$CFLAGS -D__ELF__" # Fix for nasm on Solaris x86 CheckDummyVideo CheckDiskAudio + CheckDLOPEN CheckNASM CheckOSS CheckARTSC @@ -1744,6 +1801,7 @@ case "$target" in ARCH=irix CheckDummyVideo CheckDiskAudio + CheckDLOPEN CheckDMEDIA CheckESD CheckNAS @@ -1806,6 +1864,7 @@ case "$target" in ARCH=hpux CheckDummyVideo CheckDiskAudio + CheckDLOPEN CheckOSS CheckNAS CheckX11 @@ -1853,6 +1912,7 @@ case "$target" in ARCH=aix CheckDummyVideo CheckDiskAudio + CheckDLOPEN CheckOSS CheckNAS CheckX11 @@ -1898,6 +1958,7 @@ case "$target" in ARCH=osf CheckDummyVideo CheckDiskAudio + CheckDLOPEN CheckNAS CheckX11 CheckGGI @@ -1944,6 +2005,7 @@ case "$target" in ARCH=qnx CheckDummyVideo CheckDiskAudio + CheckDLOPEN CheckNAS CheckPHOTON CheckX11 diff --git a/docs.html b/docs.html index 6de80662..efa0aac4 100644 --- a/docs.html +++ b/docs.html @@ -16,6 +16,7 @@ be found at the main SDL page. Major changes since SDL 1.0.0: