diff --git a/neo/SConstruct b/neo/SConstruct index bc1ee17..546c9dd 100644 --- a/neo/SConstruct +++ b/neo/SConstruct @@ -152,38 +152,68 @@ else: cpu = 'ppc' else: cpu = 'cpu' -g_os = 'Linux' +g_os = commands.getoutput('uname') # end system detection --------------------------- # default settings ------------------------------- -CC = 'gcc' -CXX = 'g++' -JOBS = '1' -BUILD = 'debug' -DEDICATED = '0' -TARGET_CORE = '1' -TARGET_GAME = '1' -TARGET_D3XP = '1' -TARGET_MONO = '0' -TARGET_DEMO = '0' -IDNET_HOST = '' -GL_HARDLINK = '0' -DEBUG_MEMORY = '0' -LIBC_MALLOC = '1' -ID_NOLANADDRESS = '0' -ID_MCHECK = '2' -BUILD_ROOT = 'build' -ALSA = '1' -SETUP = '0' -SDK = '0' -NOCONF = '0' -NOCURL = '0' -BUILD_GAMEPAK = '0' -BASEFLAGS = '' -SILENT = '0' - +if (g_os == 'Linux'): + CC = 'gcc' + CXX = 'g++' + JOBS = '1' + BUILD = 'debug' + DEDICATED = '0' + TARGET_CORE = '1' + TARGET_GAME = '1' + TARGET_D3XP = '1' + TARGET_MONO = '0' + TARGET_DEMO = '0' + IDNET_HOST = '' + GL_HARDLINK = '0' + DEBUG_MEMORY = '0' + LIBC_MALLOC = '1' + ID_NOLANADDRESS = '0' + ID_MCHECK = '2' + BUILD_ROOT = 'build' + ALSA = '1' + SETUP = '0' + SDK = '0' + NOCONF = '0' + NOCURL = '0' + BUILD_GAMEPAK = '0' + BASEFLAGS = '' + SILENT = '0' + M4 = 'm4' + +if (g_os == 'FreeBSD'): + CC = 'gcc46' + CXX = 'g++46' + JOBS = '1' + BUILD = 'debug' + DEDICATED = '0' + TARGET_CORE = '1' + TARGET_GAME = '1' + TARGET_D3XP = '1' + TARGET_MONO = '0' + TARGET_DEMO = '0' + IDNET_HOST = '' + GL_HARDLINK = '0' + DEBUG_MEMORY = '0' + LIBC_MALLOC = '1' + ID_NOLANADDRESS = '0' + ID_MCHECK = '2' + BUILD_ROOT = 'build' + ALSA = '0' + SETUP = '0' + SDK = '0' + NOCONF = '0' + NOCURL = '0' + BUILD_GAMEPAK = '0' + BASEFLAGS = '' + SILENT = '0' + M4 = 'gm4' + # end default settings --------------------------- # site settings ---------------------------------- @@ -339,7 +369,7 @@ if ( ID_MCHECK == '1' ): BASECPPFLAGS.append( '-DID_MCHECK' ) # create the build environements -g_base_env = Environment( ENV = os.environ, CC = CC, CXX = CXX, LINK = LINK, CPPFLAGS = BASECPPFLAGS, LINKFLAGS = BASELINKFLAGS, CPPPATH = CORECPPPATH, LIBPATH = CORELIBPATH ) +g_base_env = Environment( ENV = os.environ, CC = CC, CXX = CXX, LINK = LINK, CPPFLAGS = BASECPPFLAGS, LINKFLAGS = BASELINKFLAGS, CPPPATH = CORECPPPATH, LIBPATH = CORELIBPATH, M4 = M4, OS = g_os ) scons_utils.SetupUtils( g_base_env ) g_env = g_base_env.Clone() diff --git a/neo/d3xp/MultiplayerGame.cpp b/neo/d3xp/MultiplayerGame.cpp index 1105268..73919c2 100644 --- a/neo/d3xp/MultiplayerGame.cpp +++ b/neo/d3xp/MultiplayerGame.cpp @@ -2003,7 +2003,7 @@ void idMultiplayerGame::UpdateMainGui( void ) { mainGui->SetStateString( keyval->GetKey(), keyval->GetValue() ); } mainGui->StateChanged( gameLocal.time ); -#if defined( __linux__ ) +#if defined( __linux__ ) || defined( __FreeBSD__ ) // replacing the oh-so-useful s_reverse with sound backend prompt mainGui->SetStateString( "driver_prompt", "1" ); #else diff --git a/neo/framework/Common.cpp b/neo/framework/Common.cpp index fc102e2..c1c7705 100644 --- a/neo/framework/Common.cpp +++ b/neo/framework/Common.cpp @@ -62,7 +62,7 @@ idCVar com_asyncInput( "com_asyncInput", "0", CVAR_BOOL|CVAR_SYSTEM, "sample inp #define ASYNCSOUND_INFO "0: mix sound inline, 1: memory mapped async mix, 2: callback mixing, 3: write async mix" #if defined( MACOS_X ) idCVar com_asyncSound( "com_asyncSound", "2", CVAR_INTEGER|CVAR_SYSTEM|CVAR_ROM, ASYNCSOUND_INFO ); -#elif defined( __linux__ ) +#elif defined( __linux__ ) || defined( __FreeBSD__ ) idCVar com_asyncSound( "com_asyncSound", "3", CVAR_INTEGER|CVAR_SYSTEM|CVAR_ROM, ASYNCSOUND_INFO ); #else idCVar com_asyncSound( "com_asyncSound", "1", CVAR_INTEGER|CVAR_SYSTEM, ASYNCSOUND_INFO, 0, 1 ); diff --git a/neo/framework/Session_menu.cpp b/neo/framework/Session_menu.cpp index 9c1871e..2781544 100644 --- a/neo/framework/Session_menu.cpp +++ b/neo/framework/Session_menu.cpp @@ -323,7 +323,7 @@ void idSessionLocal::SetMainMenuGuiVars( void ) { guiMsg->SetStateString( "visible_hasxp", fileSystem->HasD3XP() ? "1" : "0" ); -#if defined( __linux__ ) +#if defined( __linux__ ) || defined( __FreeBSD__ ) guiMainMenu->SetStateString( "driver_prompt", "1" ); #else guiMainMenu->SetStateString( "driver_prompt", "0" ); diff --git a/neo/game/MultiplayerGame.cpp b/neo/game/MultiplayerGame.cpp index 439b223..a207ca5 100644 --- a/neo/game/MultiplayerGame.cpp +++ b/neo/game/MultiplayerGame.cpp @@ -1485,7 +1485,7 @@ void idMultiplayerGame::UpdateMainGui( void ) { mainGui->SetStateString( keyval->GetKey(), keyval->GetValue() ); } mainGui->StateChanged( gameLocal.time ); -#if defined( __linux__ ) +#if defined( __linux__ ) || defined( __FreeBSD__ ) // replacing the oh-so-useful s_reverse with sound backend prompt mainGui->SetStateString( "driver_prompt", "1" ); #else diff --git a/neo/idlib/Lib.cpp b/neo/idlib/Lib.cpp index ccb2c98..8aae744 100644 --- a/neo/idlib/Lib.cpp +++ b/neo/idlib/Lib.cpp @@ -152,7 +152,7 @@ dword PackColor( const idVec4 &color ) { dz = ColorFloatToByte( color.z ); dw = ColorFloatToByte( color.w ); -#if defined(_WIN32) || defined(__linux__) || (defined(MACOS_X) && defined(__i386__)) +#if defined(_WIN32) || defined(__linux__) || defined(__FreeBSD__) || (defined(MACOS_X) && defined(__i386__)) return ( dx << 0 ) | ( dy << 8 ) | ( dz << 16 ) | ( dw << 24 ); #elif (defined(MACOS_X) && defined(__ppc__)) return ( dx << 24 ) | ( dy << 16 ) | ( dz << 8 ) | ( dw << 0 ); @@ -167,7 +167,7 @@ UnpackColor ================ */ void UnpackColor( const dword color, idVec4 &unpackedColor ) { -#if defined(_WIN32) || defined(__linux__) || (defined(MACOS_X) && defined(__i386__)) +#if defined(_WIN32) || defined(__linux__) || defined(__FreeBSD__) || (defined(MACOS_X) && defined(__i386__)) unpackedColor.Set( ( ( color >> 0 ) & 255 ) * ( 1.0f / 255.0f ), ( ( color >> 8 ) & 255 ) * ( 1.0f / 255.0f ), ( ( color >> 16 ) & 255 ) * ( 1.0f / 255.0f ), @@ -194,7 +194,7 @@ dword PackColor( const idVec3 &color ) { dy = ColorFloatToByte( color.y ); dz = ColorFloatToByte( color.z ); -#if defined(_WIN32) || defined(__linux__) || (defined(MACOS_X) && defined(__i386__)) +#if defined(_WIN32) || defined(__linux__) || defined(__FreeBSD__) || (defined(MACOS_X) && defined(__i386__)) return ( dx << 0 ) | ( dy << 8 ) | ( dz << 16 ); #elif (defined(MACOS_X) && defined(__ppc__)) return ( dy << 16 ) | ( dz << 8 ) | ( dx << 0 ); @@ -209,7 +209,7 @@ UnpackColor ================ */ void UnpackColor( const dword color, idVec3 &unpackedColor ) { -#if defined(_WIN32) || defined(__linux__) || (defined(MACOS_X) && defined(__i386__)) +#if defined(_WIN32) || defined(__linux__) || defined(__FreeBSD__) || (defined(MACOS_X) && defined(__i386__)) unpackedColor.Set( ( ( color >> 0 ) & 255 ) * ( 1.0f / 255.0f ), ( ( color >> 8 ) & 255 ) * ( 1.0f / 255.0f ), ( ( color >> 16 ) & 255 ) * ( 1.0f / 255.0f ) ); @@ -577,7 +577,7 @@ void AssertFailed( const char *file, int line, const char *expression ) { idLib::sys->DebugPrintf( "\n\nASSERTION FAILED!\n%s(%d): '%s'\n", file, line, expression ); #ifdef _WIN32 __asm int 0x03 -#elif defined( __linux__ ) +#elif defined( __linux__ ) || defined (__FreeBSD__) __asm__ __volatile__ ("int $0x03"); #elif defined( MACOS_X ) kill( getpid(), SIGINT ); diff --git a/neo/idlib/bv/Frustum.cpp b/neo/idlib/bv/Frustum.cpp index 52e76d6..74b2b38 100644 --- a/neo/idlib/bv/Frustum.cpp +++ b/neo/idlib/bv/Frustum.cpp @@ -2044,7 +2044,7 @@ bool idFrustum::ProjectionBounds( const idBounds &bounds, idBounds &projectionBo return ProjectionBounds( idBox( bounds, vec3_origin, mat3_identity ), projectionBounds ); } -#ifndef __linux__ +#if !defined(__linux__) && !defined(__FreeBSD__) /* ============ diff --git a/neo/renderer/qgl.h b/neo/renderer/qgl.h index 2f994af..abebc0b 100644 --- a/neo/renderer/qgl.h +++ b/neo/renderer/qgl.h @@ -51,6 +51,15 @@ If you have questions concerning this license or the applicable additional terms #include #include +#elif defined( __FreeBSD__ ) + +// using our local glext.h +// http://oss.sgi.com/projects/ogl-sample/ABI/ +#define GL_GLEXT_LEGACY +#define GLX_GLXEXT_LEGACY +#include +#include + #else #include @@ -544,7 +553,7 @@ extern BOOL ( WINAPI * qwglSwapLayerBuffers)(HDC, UINT); #endif // _WIN32 -#if defined( __linux__ ) +#if defined( __linux__ ) || defined(__FreeBSD__) //GLX Functions extern XVisualInfo * (*qglXChooseVisual)( Display *dpy, int screen, int *attribList ); diff --git a/neo/sys/gllog/gl_extensions.cpp.m4 b/neo/sys/gllog/gl_extensions.cpp.m4 index aaae369..58bc79d 100644 --- a/neo/sys/gllog/gl_extensions.cpp.m4 +++ b/neo/sys/gllog/gl_extensions.cpp.m4 @@ -46,7 +46,7 @@ GLExtension_t GLimp_ExtensionPointer( const char *name ) { } #endif GLExtension_t ret; - #if defined(__linux__) + #if defined(__linux__) || defined(__FreeBSD__) // for some reason glXGetProcAddressARB doesn't work on RH9? ret = qglXGetProcAddressARB((const GLubyte *) name); if ( !ret ) { diff --git a/neo/sys/linux/sound.cpp b/neo/sys/linux/sound.cpp index e677852..ca39c85 100644 --- a/neo/sys/linux/sound.cpp +++ b/neo/sys/linux/sound.cpp @@ -29,7 +29,6 @@ If you have questions concerning this license or the applicable additional terms #include #include #include -#include #include #include // OSS sound interface @@ -187,12 +186,14 @@ bool idAudioHardwareOSS::Initialize( ) { // may only be available starting with OSS API v4.0 // http://www.fi.opensound.com/developer/SNDCTL_SYSINFO.html // NOTE: at OSS API 4.0 headers, replace OSS_SYSINFO with SNDCTL_SYSINFO + #if defined( __linux__ ) oss_sysinfo si; if ( ioctl( m_audio_fd, OSS_SYSINFO, &si ) == -1 ) { common->Printf( "ioctl SNDCTL_SYSINFO failed: %s\nthis ioctl is only available in OSS/Linux implementation. If you run OSS/Free, don't bother.", strerror( errno ) ); } else { common->Printf( "%s: %s %s\n", s_device.GetString(), si.product, si.version ); } + #endif if ( ioctl( m_audio_fd, SNDCTL_DSP_GETCAPS, &caps ) == -1 ) { common->Warning( "ioctl SNDCTL_DSP_GETCAPS failed - driver too old?" ); @@ -205,9 +206,13 @@ bool idAudioHardwareOSS::Initialize( ) { InitFailed(); return false; } - ExtractOSSVersion( oss_version, s_oss_version ); ExtractOSSVersion( SOUND_VERSION, s_compiled_oss_version ); + #if defined( __linux__ ) + ExtractOSSVersion( oss_version, s_oss_version ); common->DPrintf( "OSS interface version %s - compile time %s\n", s_oss_version.c_str(), s_compiled_oss_version.c_str() ); + #elif defined ( __FreeBSD__ ) + common->DPrintf( "OSS interface version %s\n", s_compiled_oss_version.c_str() ); + #endif if (!(caps & DSP_CAP_MMAP)) { common->Warning( "driver doesn't have DSP_CAP_MMAP capability" ); InitFailed(); diff --git a/neo/sys/posix/posix_main.cpp b/neo/sys/posix/posix_main.cpp index 566bb81..6c1fe93 100644 --- a/neo/sys/posix/posix_main.cpp +++ b/neo/sys/posix/posix_main.cpp @@ -430,7 +430,7 @@ const char *Sys_DefaultCDPath( void ) { return ""; } -long Sys_FileTimeStamp(FILE * fp) { +ID_TIME_T Sys_FileTimeStamp(FILE * fp) { struct stat st; fstat(fileno(fp), &st); return st.st_mtime; diff --git a/neo/sys/scons/SConscript.core b/neo/sys/scons/SConscript.core index e49b115..c8cf579 100644 --- a/neo/sys/scons/SConscript.core +++ b/neo/sys/scons/SConscript.core @@ -336,7 +336,12 @@ else: sound_env.Append( CPPDEFINES = 'NO_ALSA' ) sound_lib = sound_env.StaticLibrary( 'sound', sound_list ) -local_env.Append( LIBS = [ 'pthread', 'dl' ] ) +# 'dl' is a linuxism +if (g_os == 'Linux'): + local_env.Append( LIBS = [ 'pthread', 'dl' ] ) +else: + local_env.Append( LIBS = [ 'pthread' ] ) + if ( local_dedicated == 0 ): local_env.Append( LIBS = [ 'X11', 'Xext', 'Xxf86vm' ] ) # 'Xxf86dga', local_env.Append( LIBPATH = [ '/usr/X11R6/lib' ] ) diff --git a/neo/sys/scons/SConscript.gl b/neo/sys/scons/SConscript.gl index a7053a1..b45d265 100644 --- a/neo/sys/scons/SConscript.gl +++ b/neo/sys/scons/SConscript.gl @@ -32,7 +32,7 @@ def build_logfuncs(env, target, source): do_logfunc(f_in, f_out) f_in.close() - f_out.write('\n#ifdef __linux__\n\n') + f_out.write('\n#if defined(__linux__) || defined(__FreeBSD__)\n\n') f_in = open( gllog_path + '/glX.api', 'r') do_logfunc(f_in, f_out) f_in.close() diff --git a/neo/sys/scons/scons_utils.py b/neo/sys/scons/scons_utils.py index d8ef922..5c7c277 100644 --- a/neo/sys/scons/scons_utils.py +++ b/neo/sys/scons/scons_utils.py @@ -127,7 +127,9 @@ def checkLDD( target, source, env ): def SharedLibrarySafe( env, target, source ): ret = env.SharedLibrary( target, source ) - env.AddPostAction( ret, checkLDD ) + # FIXME: This is an evil hack + if ( 'Linux' == commands.getoutput('uname')): + env.AddPostAction( ret, checkLDD ) return ret def NotImplementedStub( *whatever ): diff --git a/neo/sys/sys_local.cpp b/neo/sys/sys_local.cpp index bf40527..4391ce5 100644 --- a/neo/sys/sys_local.cpp +++ b/neo/sys/sys_local.cpp @@ -123,7 +123,7 @@ void idSysLocal::DLL_Unload( int dllHandle ) { void idSysLocal::DLL_GetFileName( const char *baseName, char *dllName, int maxLength ) { #ifdef _WIN32 idStr::snPrintf( dllName, maxLength, "%s" CPUSTRING ".dll", baseName ); -#elif defined( __linux__ ) +#elif defined( __linux__ ) || defined( __FreeBSD__ ) idStr::snPrintf( dllName, maxLength, "%s" CPUSTRING ".so", baseName ); #elif defined( MACOS_X ) idStr::snPrintf( dllName, maxLength, "%s" ".dylib", baseName ); diff --git a/neo/sys/sys_public.h b/neo/sys/sys_public.h index 996626b..7708335 100644 --- a/neo/sys/sys_public.h +++ b/neo/sys/sys_public.h @@ -133,6 +133,35 @@ If you have questions concerning this license or the applicable additional terms #endif +// FreeBSD +#ifdef __FreeBSD__ + +#ifdef __i386__ + #define BUILD_STRING "freebsd-x86" + #define BUILD_OS_ID 3 + #define CPUSTRING "x86" + #define CPU_EASYARGS 1 +#endif + +#define _alloca alloca +#define _alloca16( x ) ((void *)((((int)alloca( (x)+15 )) + 15) & ~15)) + +#define ALIGN16( x ) x +#define PACKED __attribute__((packed)) + +#define PATHSEPERATOR_STR "/" +#define PATHSEPERATOR_CHAR '/' + +#define __cdecl +#define ASSERT assert + +#define ID_INLINE inline +#define ID_STATIC_TEMPLATE + +#define assertmem( x, y ) + +#endif + #ifdef __GNUC__ #define id_attribute(x) __attribute__(x) #else