Should fix up dynamic loading by disabling internal link of the library as well...

This commit is contained in:
Themaister 2010-12-30 14:26:12 +01:00
parent 19e2b2768b
commit 7e9a2a6e23
4 changed files with 19 additions and 9 deletions

View File

@ -4,7 +4,7 @@ TARGET = ssnes
OBJ = ssnes.o file.o driver.o conf/config_file.o settings.o dynamic.o
LIBS = -lsamplerate $(libsnes)
LIBS = -lsamplerate
ifeq ($(HAVE_RSOUND), 1)
OBJ += audio/rsound.o
@ -43,8 +43,10 @@ ifeq ($(HAVE_FILTER), 1)
OBJ += hqflt/snes_ntsc/snes_ntsc.o
endif
ifeq ($(HAVE_DL), 1)
ifeq ($(HAVE_DYNAMIC), 1)
LIBS += -ldl
else
LIBS += $(libsnes)
endif
CFLAGS = -Wall -O3 -g -std=gnu99 -I.

View File

@ -20,7 +20,7 @@
#include <string.h>
#include "config.h"
#ifdef HAVE_DL
#ifdef HAVE_DYNAMIC
#include <dlfcn.h>
#define SYM(x) do { \
@ -58,7 +58,7 @@ unsigned (*psnes_get_memory_size)(unsigned);
void (*psnes_unload_cartridge)(void);
void (*psnes_term)(void);
#ifdef HAVE_DL
#ifdef HAVE_DYNAMIC
static void load_dynamic(void)
{
SSNES_LOG("Loading dynamic libsnes from: \"%s\"\n", g_settings.libsnes);
@ -93,6 +93,7 @@ static void load_dynamic(void)
p##x = x; \
} while(0)
#ifndef HAVE_DYNAMIC
static void set_statics(void)
{
SSYM(snes_init);
@ -113,20 +114,26 @@ static void set_statics(void)
SSYM(snes_unload_cartridge);
SSYM(snes_term);
}
#endif
void init_dlsym(void)
{
#ifdef HAVE_DL
#ifdef HAVE_DYNAMIC
if (strlen(g_settings.libsnes) > 0)
load_dynamic();
else
#endif
{
SSNES_ERR("This binary is built to use runtime dynamic binding of libsnes. Set libsnes_path in config to load a libsnes library dynamically.\n");
exit(1);
}
#else
set_statics();
#endif
}
void uninit_dlsym(void)
{
#ifdef HAVE_DL
#ifdef HAVE_DYNAMIC
if (lib_handle)
dlclose(lib_handle);
#endif

View File

@ -20,10 +20,10 @@ check_lib CG -lCg cgCreateContext
check_lib SRC -lsamplerate src_callback_new
check_lib DL -ldl dlopen
check_lib DYNAMIC -ldl dlopen
# Creates config.mk.
VARS="ALSA OSS AL RSOUND ROAR GLFW FILTER CG DL"
VARS="ALSA OSS AL RSOUND ROAR GLFW FILTER CG DYNAMIC"
create_config_make config.mk $VARS
create_config_header config.h $VARS

View File

@ -7,6 +7,7 @@ PACKAGE_VERSION=0.1
# $1: Variable (HAVE_ALSA, HAVE_OSS, etc)
# $2: Comment
# $3: Default arg. auto implies that HAVE_ALSA will be set according to library checks later on.
add_command_line_enable DYNAMIC "Enable dynamic loading of libsnes library." no
add_command_line_string LIBSNES "libsnes library used" "-lsnes"
add_command_line_enable FILTER "Disable CPU filter support" yes
add_command_line_enable CG "Enable CG shader support" auto