mirror of
https://github.com/alliedmodders/metamod-source.git
synced 2025-02-20 13:54:14 +01:00
Mac OS X build fixes (bug 4391, r=dvander).
This commit is contained in:
parent
73e2daec56
commit
31c8cc9681
@ -314,6 +314,8 @@ LoadPluginsFromFile(const char *filepath, int &skipped)
|
||||
{
|
||||
#if defined WIN32 || defined _WIN32
|
||||
ext = ".dll";
|
||||
#elif defined __APPLE__
|
||||
ext = ".dylib";
|
||||
#else
|
||||
ext = "_i486.so";
|
||||
#endif
|
||||
@ -481,7 +483,7 @@ mm_StartupMetamod(bool is_vsp_load)
|
||||
ConVarFlag_SpOnly);
|
||||
|
||||
mm_basedir = provider->CreateConVar("mm_basedir",
|
||||
#if defined __linux__
|
||||
#if defined __linux__ || defined __APPLE__
|
||||
"addons/metamod",
|
||||
#else
|
||||
"addons\\metamod",
|
||||
@ -1123,6 +1125,8 @@ ProcessVDF(const char *path, bool &skipped)
|
||||
file,
|
||||
#if defined WIN32 || defined _WIN32
|
||||
".dll"
|
||||
#elif defined __APPLE__
|
||||
".dylib"
|
||||
#else
|
||||
"_i486.so"
|
||||
#endif
|
||||
|
@ -39,7 +39,7 @@
|
||||
#include <sourcehook/sourcehook.h>
|
||||
#include <ISmmPlugin.h>
|
||||
#include "metamod_provider.h"
|
||||
#include "version.h"
|
||||
#include <metamod_version.h>
|
||||
|
||||
using namespace SourceMM;
|
||||
|
||||
|
@ -425,6 +425,8 @@ bool Command_Meta(IMetamodSourceCommandInfo *info)
|
||||
const char *ext = UTIL_GetExtension(file);
|
||||
#if defined WIN32 || defined _WIN32
|
||||
ext = ext ? "" : ".dll";
|
||||
#elif defined __APPLE__
|
||||
ext = ext ? "" : ".dylib";
|
||||
#else
|
||||
ext = ext ? "" : "_i486.so";
|
||||
#endif
|
||||
@ -547,6 +549,8 @@ bool Command_Meta(IMetamodSourceCommandInfo *info)
|
||||
const char *ext = UTIL_GetExtension(file);
|
||||
#if defined WIN32 || defined _WIN32
|
||||
ext = ext ? "" : ".dll";
|
||||
#elif defined __APPLE__
|
||||
ext = ext ? "" : ".dylib";
|
||||
#else
|
||||
ext = ext ? "" : "_i486.so";
|
||||
#endif
|
||||
|
@ -27,9 +27,9 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include "metamod_oslink.h"
|
||||
#include <malloc.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#ifdef __linux
|
||||
#if defined __linux__ || defined __APPLE__
|
||||
#include <errno.h>
|
||||
#endif
|
||||
|
||||
@ -57,7 +57,7 @@ const char *dlerror()
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined __linux__
|
||||
#if defined __linux_ || defined __APPLE___
|
||||
int GetLastError()
|
||||
{
|
||||
return errno;
|
||||
@ -82,7 +82,7 @@ bool GetFileOfAddress(void *pAddr, char *buffer, size_t maxlength)
|
||||
return false;
|
||||
HMODULE dll = (HMODULE)mem.AllocationBase;
|
||||
GetModuleFileName(dll, (LPTSTR)buffer, maxlength);
|
||||
#elif defined __linux__
|
||||
#elif defined __linux__ || defined __APPLE__
|
||||
Dl_info info;
|
||||
if (!dladdr(pAddr, &info))
|
||||
return false;
|
||||
|
@ -51,11 +51,15 @@
|
||||
#define PATH_SEP_CHAR '\\'
|
||||
#define ALT_SEP_CHAR '/'
|
||||
#define PATH_SIZE MAX_PATH
|
||||
#define SERVER_DLL "server.dll"
|
||||
#define strcasecmp stricmp
|
||||
inline bool _IsPathSepChar(char c) { return (c == '/' || c == '\\'); }
|
||||
#elif defined __linux__
|
||||
#define OS_LINUX
|
||||
#elif defined __linux__ || defined __APPLE__
|
||||
#if defined __linux__
|
||||
#define OS_LINUX
|
||||
#elif defined __APPLE__
|
||||
#define OS_DARWIN
|
||||
#include <sys/syslimits.h>
|
||||
#endif
|
||||
#include <dlfcn.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
@ -69,11 +73,10 @@
|
||||
#define PATH_SIZE PATH_MAX
|
||||
#define stricmp strcasecmp
|
||||
#define strnicmp strncasecmp
|
||||
#define SERVER_DLL "server_i486.so"
|
||||
inline bool _IsPathSepChar(char c) { return (c == '/'); }
|
||||
#endif
|
||||
|
||||
#if defined __linux__
|
||||
#if defined __linux__ || defined __APPLE__
|
||||
#include <errno.h>
|
||||
int GetLastError();
|
||||
#endif
|
||||
@ -103,7 +106,7 @@ bool GetFileOfAddress(void *pAddr, char *buffer, size_t maxlength);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef __linux__
|
||||
#if !defined __linux__ && !defined __APPLE__
|
||||
#define snprintf _snprintf
|
||||
#if defined _MSC_VER && _MSC_VER < 1500
|
||||
#define vsnprintf _vsnprintf
|
||||
|
@ -197,7 +197,7 @@ inline bool pathchar_sep(char a)
|
||||
{
|
||||
#if defined WIN32
|
||||
return (a == '/' || a == '\\');
|
||||
#elif defined __linux__
|
||||
#else
|
||||
return (a == '/');
|
||||
#endif
|
||||
}
|
||||
@ -208,7 +208,7 @@ inline bool pathstr_isabsolute(const char *str)
|
||||
return (pathchar_isalpha(str[0])
|
||||
&& str[1] == ':'
|
||||
&& pathchar_sep(str[2]));
|
||||
#elif defined __linux__
|
||||
#else
|
||||
return (str[0] == '/');
|
||||
#endif
|
||||
}
|
||||
|
@ -54,6 +54,8 @@ static char mm_path[PLATFORM_MAX_PATH];
|
||||
|
||||
#if defined _WIN32
|
||||
#define SERVER_NAME "server.dll"
|
||||
#elif defined __APPLE__
|
||||
#define SERVER_NAME "server.dylib"
|
||||
#elif defined __linux__
|
||||
#define SERVER_NAME "server" LIB_SUFFIX
|
||||
#endif
|
||||
|
@ -81,6 +81,9 @@ static const char *backend_names[] =
|
||||
#if defined _WIN32
|
||||
#define LIBRARY_EXT ".dll"
|
||||
#define LIBRARY_MINEXT ".dll"
|
||||
#elif defined __APPLE__
|
||||
#define LIBRARY_EXT ".dylib"
|
||||
#define LIBRARY_MINEXT ".dylib"
|
||||
#elif defined __linux__
|
||||
#define LIBRARY_EXT LIB_SUFFIX
|
||||
#define LIBRARY_MINEXT ".so"
|
||||
@ -179,6 +182,9 @@ mm_GetProcAddress(const char *name)
|
||||
#if defined _WIN32
|
||||
#define TIER0_NAME "bin\\tier0.dll"
|
||||
#define VSTDLIB_NAME "bin\\vstdlib.dll"
|
||||
#elif defined __APPLE__
|
||||
#define TIER0_NAME "bin/libtier0.dylib"
|
||||
#define VSTDLIB_NAME "bin/libvstdlib.dylib"
|
||||
#elif defined __linux__
|
||||
#define TIER0_NAME "bin/" LIB_PREFIX "tier0" LIB_SUFFIX
|
||||
#define VSTDLIB_NAME "bin/" LIB_PREFIX "vstdlib" LIB_SUFFIX
|
||||
|
@ -40,26 +40,33 @@
|
||||
#define SH_COMP_MSVC 2
|
||||
|
||||
#if defined WIN32
|
||||
#define SH_SYS SH_SYS_WIN32
|
||||
#define SH_XP SH_XP_WINAPI
|
||||
#define SH_COMP SH_COMP_MSVC
|
||||
#define WINDOWS_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
#include <direct.h>
|
||||
#define PLATFORM_MAX_PATH MAX_PATH
|
||||
#define SH_SYS SH_SYS_WIN32
|
||||
#define SH_XP SH_XP_WINAPI
|
||||
#define SH_COMP SH_COMP_MSVC
|
||||
#define PATH_SEP_STR "\\"
|
||||
#define PATH_SEP_CHAR '\\'
|
||||
#define ALT_SEP_CHAR '/'
|
||||
#elif defined __linux__
|
||||
#elif defined __linux__ || defined __APPLE__
|
||||
#if defined __linux__
|
||||
#define SH_SYS SH_SYS_LINUX
|
||||
#elif defined __APPLE__
|
||||
#define SH_SYS SH_SYS_APPLE
|
||||
#endif
|
||||
#define SH_XP SH_XP_POSIX
|
||||
#define SH_COMP SH_COMP_GCC
|
||||
#include <dlfcn.h>
|
||||
#include <dirent.h>
|
||||
#include <stdint.h>
|
||||
#include <unistd.h>
|
||||
#if SH_SYS == SH_SYS_APPLE
|
||||
#include <sys/syslimits.h>
|
||||
#endif
|
||||
typedef void * HMODULE;
|
||||
#define PLATFORM_MAX_PATH PATH_MAX
|
||||
#define SH_SYS SH_SYS_LINUX
|
||||
#define SH_XP SH_XP_POSIX
|
||||
#define SH_COMP SH_COMP_GCC
|
||||
#define PATH_SEP_STR "/"
|
||||
#define PATH_SEP_CHAR '/'
|
||||
#define ALT_SEP_CHAR '\\'
|
||||
|
@ -270,7 +270,7 @@ mm_ResolvePath(const char *path, char *buffer, size_t maxlength)
|
||||
{
|
||||
#if defined _WIN32
|
||||
return _fullpath(buffer, path, maxlength) != NULL;
|
||||
#elif defined __linux__
|
||||
#elif defined __linux__ || defined __APPLE__
|
||||
assert(maxlength >= PATH_MAX);
|
||||
return realpath(path, buffer) != NULL;
|
||||
#endif
|
||||
@ -289,7 +289,7 @@ mm_LoadLibrary(const char *path, char *buffer, size_t maxlength)
|
||||
mm_GetPlatformError(buffer, maxlength);
|
||||
return NULL;
|
||||
}
|
||||
#elif defined __linux__
|
||||
#elif defined __linux__ || defined __APPLE__
|
||||
lib = dlopen(path, RTLD_NOW);
|
||||
|
||||
if (lib == NULL)
|
||||
@ -307,7 +307,7 @@ mm_GetLibAddress(void *lib, const char *name)
|
||||
{
|
||||
#if defined _WIN32
|
||||
return GetProcAddress((HMODULE)lib, name);
|
||||
#elif defined __linux__
|
||||
#elif defined __linux__ || defined __APPLE__
|
||||
return dlsym(lib, name);
|
||||
#endif
|
||||
}
|
||||
@ -317,7 +317,7 @@ mm_UnloadLibrary(void *lib)
|
||||
{
|
||||
#if defined _WIN32
|
||||
FreeLibrary((HMODULE)lib);
|
||||
#else
|
||||
#elif defined __linux__ || defined __APPLE__
|
||||
dlclose(lib);
|
||||
#endif
|
||||
}
|
||||
@ -333,7 +333,7 @@ mm_GetFileOfAddress(void *pAddr, char *buffer, size_t maxlength)
|
||||
return false;
|
||||
HMODULE dll = (HMODULE)mem.AllocationBase;
|
||||
GetModuleFileName(dll, (LPTSTR)buffer, maxlength);
|
||||
#elif defined __linux__
|
||||
#elif defined __linux__ || defined __APPLE__
|
||||
Dl_info info;
|
||||
if (!dladdr(pAddr, &info))
|
||||
return false;
|
||||
|
Loading…
x
Reference in New Issue
Block a user