From 6a1b01180ada3c55a205bb8ce2448e945487a8c9 Mon Sep 17 00:00:00 2001
From: deuce <>
Date: Sat, 27 Sep 2008 23:34:21 +0000
Subject: [PATCH] Add support for STATIC_LINK macro

---
 src/xpdev/xp_dl.c |  3 ++-
 src/xpdev/xp_dl.h | 13 ++++++++++---
 2 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/src/xpdev/xp_dl.c b/src/xpdev/xp_dl.c
index 1e1fb972b4..31cfcf8387 100644
--- a/src/xpdev/xp_dl.c
+++ b/src/xpdev/xp_dl.c
@@ -1,6 +1,7 @@
 #include "dirwrap.h"
 #include "xp_dl.h"
 
+#ifndef STATIC_LINK
 #if defined(__unix__)
 xp_dlopen(const char *name, int mode, int major, int minor)
 {
@@ -32,6 +33,6 @@ xp_dlopen(const char *name, int mode, int major, int minor)
 	return(NULL);
 }
 #endif
-
+#endif
 
 #endif
diff --git a/src/xpdev/xp_dl.h b/src/xpdev/xp_dl.h
index be73b9e83b..6fd8c0619b 100644
--- a/src/xpdev/xp_dl.h
+++ b/src/xpdev/xp_dl.h
@@ -3,18 +3,20 @@
 
 #include "wrapdll.h"
 
+#ifndef STATIC_LINK
 #if defined(__unix__)
 	#include <dlfcn.h>
 
 	typedef void * dll_handle;
-	#define xp_dlsym(handle, name)				dlsym(handle, name)
+	DLLEXPORT void* DLLCALL xp_dlopen(const char *name, int mode, int major, int minor);
+	#define xp_dlsym(handle, name)				dlsym(handle, #name)
 	#define xp_dlclose(handle)					dlclose(handle)
 #elif defined(_WIN32)
 	#include <Winbase.h>
 
 	typedef HMODULE WINAPI dll_handle;
 	#define xp_dlopen(name, mode, major, minor)	LoadLibrary(name)
-	#define xp_dlsym(handle, name)				((void *)GetProcAddress(handle, name))
+	#define xp_dlsym(handle, name)				((void *)GetProcAddress(handle, #name))
 	#define xp_dlclose(handle)					(FreeLibrary(handle)?0:-1)
 
 	/* Unused values for *nix compatability */
@@ -26,7 +28,12 @@
 		,RTLD_TRACE
 	};
 #endif
+#else
+	typedef void* dll_handle;
 
-DLLEXPORT void* DLLCALL xp_dlopen(const char *name, int mode, int major, int minor);
+	#define xp_dlopen(name, mode, major, minor)	(name)
+	#define xp_dlsym(handle, name)				(name)
+	#define xp_dlclose(handle)					(0)
+#endif
 
 #endif
-- 
GitLab