From 7e9a2a6e23f73eb21ab75ca936e6619ce5f44b5c Mon Sep 17 00:00:00 2001 From: Themaister Date: Thu, 30 Dec 2010 14:26:12 +0100 Subject: [PATCH] Should fix up dynamic loading by disabling internal link of the library as well... --- Makefile | 6 ++++-- dynamic.c | 17 ++++++++++++----- qb/config.libs.sh | 4 ++-- qb/config.params.sh | 1 + 4 files changed, 19 insertions(+), 9 deletions(-) diff --git a/Makefile b/Makefile index 5dde2d10b3..6f3e3a5372 100644 --- a/Makefile +++ b/Makefile @@ -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. diff --git a/dynamic.c b/dynamic.c index 0b359412f6..af87e0d027 100644 --- a/dynamic.c +++ b/dynamic.c @@ -20,7 +20,7 @@ #include #include "config.h" -#ifdef HAVE_DL +#ifdef HAVE_DYNAMIC #include #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 diff --git a/qb/config.libs.sh b/qb/config.libs.sh index 8eb41c6ed3..3ff699b50f 100644 --- a/qb/config.libs.sh +++ b/qb/config.libs.sh @@ -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 diff --git a/qb/config.params.sh b/qb/config.params.sh index 768550b26b..3bf0d3305e 100644 --- a/qb/config.params.sh +++ b/qb/config.params.sh @@ -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