diff --git a/CMakeLists.txt b/CMakeLists.txt index b69f71f..e2f3325 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -499,6 +499,12 @@ IF(APPLE) FIND_LIBRARY(IOKIT NAMES IOKit) FIND_LIBRARY(COREAUDIO NAMES CoreAudio) TARGET_LINK_LIBRARIES(qc PUBLIC objc ${OPENGL} ${OPENAL} ${COCOA} ${IOKIT} ${COREAUDIO}) +# Included OpenAL library doesn't currently compile or link correctly +# Modern CMake versions include FindOpenAL module, so use it here +ELSEIF(UNIX AND NOT LINUX) + FIND_PACKAGE(OpenAL REQUIRED) + INCLUDE_DIRECTORIES(${OPENAL_INCLUDE_DIR}) + TARGET_LINK_LIBRARIES(qc PUBLIC ${OPENAL_LIBRARY}) ELSE() TARGET_LINK_LIBRARIES(qc PUBLIC openal) ENDIF() diff --git a/TypeInfo/TypeInfoGen.cpp b/TypeInfo/TypeInfoGen.cpp index e8f82c0..c327ab4 100644 --- a/TypeInfo/TypeInfoGen.cpp +++ b/TypeInfo/TypeInfoGen.cpp @@ -802,7 +802,7 @@ void idTypeInfoGen::CreateTypeInfo( const char *path ) { idFileList *files; idParser src; - common->Printf( "Type Info Generator v"TYPE_INFO_GEN_VERSION" (c) 2004 id Software\n" ); + common->Printf( "Type Info Generator v" TYPE_INFO_GEN_VERSION " (c) 2004 id Software\n" ); common->Printf( "%s\n", path ); files = fileSystem->ListFilesTree( path, ".cpp" ); @@ -904,7 +904,7 @@ void idTypeInfoGen::WriteTypeInfo( const char *fileName ) const { "/*\n" "===================================================================================\n" "\n" - "\tThis file has been generated with the Type Info Generator v"TYPE_INFO_GEN_VERSION" (c) 2004 id Software\n" + "\tThis file has been generated with the Type Info Generator v" TYPE_INFO_GEN_VERSION " (c) 2004 id Software\n" "\n" "\t%d constants\n" "\t%d enums\n" diff --git a/d3xp/MultiplayerGame.cpp b/d3xp/MultiplayerGame.cpp index 882418e..9a5d561 100644 --- a/d3xp/MultiplayerGame.cpp +++ b/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( __unix__ ) // replacing the oh-so-useful s_reverse with sound backend prompt mainGui->SetStateString( "driver_prompt", "1" ); #else diff --git a/framework/BuildDefines.h b/framework/BuildDefines.h index 455285a..ed386c8 100644 --- a/framework/BuildDefines.h +++ b/framework/BuildDefines.h @@ -108,7 +108,7 @@ If you have questions concerning this license or the applicable additional terms // atm, we have no useful way to reconstruct the trace, so let's leave it off #define ID_BT_STUB #ifndef ID_BT_STUB - #if defined( __linux__ ) + #if defined( __unix__ ) && !defined(MACOS_X) #if defined( _DEBUG ) #define ID_BT_STUB #endif diff --git a/framework/Common.cpp b/framework/Common.cpp index e3fb55f..3ff0622 100644 --- a/framework/Common.cpp +++ b/framework/Common.cpp @@ -66,7 +66,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", "3", CVAR_INTEGER|CVAR_SYSTEM|CVAR_ROM, ASYNCSOUND_INFO ); -#elif defined( __linux__ ) +#elif defined( __unix__ ) 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 ); @@ -2814,7 +2814,7 @@ void idCommonLocal::Init( int argc, const char **argv, const char *cmdline ) { #endif // This hint improves relative mouse movement on linux -#ifdef __LINUX__ +#ifdef __unix__ SDL_SetHint(SDL_HINT_MOUSE_RELATIVE_MODE_WARP, "1"); #endif diff --git a/framework/Session_menu.cpp b/framework/Session_menu.cpp index 33a0242..eb69f37 100644 --- a/framework/Session_menu.cpp +++ b/framework/Session_menu.cpp @@ -474,7 +474,7 @@ void idSessionLocal::SetMainMenuGuiVars( void ) { //bc //guiMsg->SetStateString( "visible_hasxp", fileSystem->HasD3XP() ? "1" : "0" ); -#if defined( __linux__ ) +#if defined( __unix__ ) guiMainMenu->SetStateString( "driver_prompt", "1" ); #else guiMainMenu->SetStateString( "driver_prompt", "0" ); @@ -1358,7 +1358,7 @@ void idSessionLocal::HandleMainMenuCommands( const char *menuCommand ) { break; } } else { -#ifndef __linux__ +#ifndef __unix__ // also turn off OpenAL so we fully go back to legacy mixer cvarSystem->SetCVarBool( "s_useOpenAL", false ); #endif diff --git a/game/MultiplayerGame.cpp b/game/MultiplayerGame.cpp index 439b223..aee480e 100644 --- a/game/MultiplayerGame.cpp +++ b/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( __unix__ ) // replacing the oh-so-useful s_reverse with sound backend prompt mainGui->SetStateString( "driver_prompt", "1" ); #else diff --git a/idlib/Lib.cpp b/idlib/Lib.cpp index 2aaa008..2799a9c 100644 --- a/idlib/Lib.cpp +++ b/idlib/Lib.cpp @@ -29,7 +29,7 @@ If you have questions concerning this license or the applicable additional terms #include "precompiled.h" #pragma hdrstop -#if defined( MACOS_X ) +#if defined(__unix__) #include #include #include @@ -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(__ppc__)) +#if defined(_WIN32) || defined(__unix__) || (defined(MACOS_X) && !defined(__ppc__)) 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(__ppc__)) +#if defined(_WIN32) || defined(__unix__) || (defined(MACOS_X) && !defined(__ppc__)) 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(__ppc__)) +#if defined(_WIN32) || defined(__unix__) || (defined(MACOS_X) && !defined(__ppc__)) 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(__ppc__)) +#if defined(_WIN32) || defined(__unix__) || (defined(MACOS_X) && !defined(__ppc__)) unpackedColor.Set( ( ( color >> 0 ) & 255 ) * ( 1.0f / 255.0f ), ( ( color >> 8 ) & 255 ) * ( 1.0f / 255.0f ), ( ( color >> 16 ) & 255 ) * ( 1.0f / 255.0f ) ); @@ -581,7 +581,7 @@ void AssertFailed( const char *file, int line, const char *expression ) { #else __asm int 0x03 #endif -#elif defined( __linux__ ) +#elif defined( __unix__ ) #ifdef __i386__ __asm__ __volatile__ ("int $0x03"); #else diff --git a/idlib/Parser.cpp b/idlib/Parser.cpp index d2b95b3..5b9bf45 100644 --- a/idlib/Parser.cpp +++ b/idlib/Parser.cpp @@ -709,9 +709,9 @@ int idParser::ExpandBuiltinDefine( idToken *deftoken, define_t *define, idToken curtime = ctime(&t); (*token) = "\""; token->Append( curtime+4 ); - token[7] = '\0'; + token[7] = (const idStr) '\0'; token->Append( curtime+20 ); - token[10] = '\0'; + token[10] = (const idStr) '\0'; token->Append( "\"" ); free(curtime); token->type = TT_STRING; @@ -728,7 +728,7 @@ int idParser::ExpandBuiltinDefine( idToken *deftoken, define_t *define, idToken curtime = ctime(&t); (*token) = "\""; token->Append( curtime+11 ); - token[8] = '\0'; + token[8] = (const idStr) '\0'; token->Append( "\"" ); free(curtime); token->type = TT_STRING; diff --git a/idlib/bv/Frustum.cpp b/idlib/bv/Frustum.cpp index 52e76d6..95e4c12 100644 --- a/idlib/bv/Frustum.cpp +++ b/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__ +#ifndef __unix__ /* ============ diff --git a/idlib/precompiled.h b/idlib/precompiled.h index 1c6b974..e6a3eb4 100644 --- a/idlib/precompiled.h +++ b/idlib/precompiled.h @@ -103,11 +103,12 @@ If you have questions concerning this license or the applicable additional terms #include #include #include -#ifdef __linux__ -#include -#elif defined __APPLE__ +#if defined __APPLE__ #include using std::min; +// This covers Linux and the BSDs +#elif defined __unix__ +#include #endif //----------------------------------------------------- diff --git a/renderer/MegaTexture.cpp b/renderer/MegaTexture.cpp index d08aee0..5a98b99 100644 --- a/renderer/MegaTexture.cpp +++ b/renderer/MegaTexture.cpp @@ -361,7 +361,7 @@ void idTextureLevel::UpdateTile( int localX, int localY, int globalX, int global if ( idMegaTexture::r_showMegaTextureLabels.GetBool() ) { // put a color marker in it - byte color[4] = { 255 * localX / TILE_PER_LEVEL, 255 * localY / TILE_PER_LEVEL, 0, 0 }; + byte color[4] = { (byte)(255 * localX / TILE_PER_LEVEL), (byte)(255 * localY / TILE_PER_LEVEL), 0, 0 }; for ( int x = 0 ; x < 8 ; x++ ) { for ( int y = 0 ; y < 8 ; y++ ) { *(int *)&data[ ( ( y + TILE_SIZE/2 - 4 ) * TILE_SIZE + x + TILE_SIZE/2 - 4 ) * 4 ] = *(int *)color; diff --git a/renderer/jpeg-6/jerror.c b/renderer/jpeg-6/jerror.c index 06c4470..4eece70 100644 --- a/renderer/jpeg-6/jerror.c +++ b/renderer/jpeg-6/jerror.c @@ -20,8 +20,8 @@ #include "jversion.h" #include "jerror.h" -extern jpg_Error( const char *fmt, ... ); -extern jpg_Printf( const char *fmt, ... ); +extern void jpg_Error( const char *fmt, ... ); +extern void jpg_Printf( const char *fmt, ... ); #ifndef EXIT_FAILURE /* define exit() codes if not provided */ #define EXIT_FAILURE 1 diff --git a/renderer/qgl.h b/renderer/qgl.h index 7acb4df..aa73299 100644 --- a/renderer/qgl.h +++ b/renderer/qgl.h @@ -42,7 +42,7 @@ If you have questions concerning this license or the applicable additional terms #define GL_GLEXT_LEGACY #include -#elif defined( __linux__ ) +#elif defined( __unix__ ) // using our local glext.h // http://oss.sgi.com/projects/ogl-sample/ABI/ @@ -572,7 +572,7 @@ extern BOOL ( WINAPI * qwglSwapLayerBuffers)(HDC, UINT); #endif // _WIN32 -#if defined( __linux__ ) +#if defined( __unix__ ) //GLX Functions extern XVisualInfo * (*qglXChooseVisual)( Display *dpy, int screen, int *attribList ); diff --git a/sound/snd_system.cpp b/sound/snd_system.cpp index c705c7a..6de54b6 100644 --- a/sound/snd_system.cpp +++ b/sound/snd_system.cpp @@ -366,7 +366,8 @@ void idSoundSystemLocal::Init() { soundCache = new idSoundCache(); } -#if defined(__linux__) || defined(__APPLE__) +// Changed this since __unix__ covers Mac OSX, Linux and the BSDs +#if defined(__unix__) idSoundSystemLocal::s_useOpenAL.SetBool( true ); #endif diff --git a/sys/glimp.cpp b/sys/glimp.cpp index 37ed680..b8a6d2b 100755 --- a/sys/glimp.cpp +++ b/sys/glimp.cpp @@ -36,7 +36,7 @@ If you have questions concerning this license or the applicable additional terms #include "../renderer/tr_local.h" -#if !defined(ID_GL_HARDLINK) && defined(__linux__) +#if !defined(ID_GL_HARDLINK) && defined(__unix__) #include "linux/local.h" #endif @@ -68,7 +68,7 @@ GLimp_Init bool GLimp_Init(glimpParms_t parms) { common->Printf("Initializing OpenGL subsystem\n"); -#if !defined(ID_GL_HARDLINK) && defined(__linux__) +#if !defined(ID_GL_HARDLINK) && defined(__unix__) if ( !GLimp_dlopen() ) { return false; } @@ -184,7 +184,7 @@ bool GLimp_Init(glimpParms_t parms) { parms.width, parms.height, flags); // set the icon for linux. -#ifdef __linux__ +#ifdef __unix__ SDL_Surface* iconSurface = SDL_LoadBMP("Icon.bmp"); if (iconSurface) { diff --git a/sys/sys_local.cpp b/sys/sys_local.cpp index 7111fee..3fdb3a8 100644 --- a/sys/sys_local.cpp +++ b/sys/sys_local.cpp @@ -125,10 +125,10 @@ void idSysLocal::DLL_Unload( void* 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__ ) - idStr::snPrintf( dllName, maxLength, "%s" CPUSTRING ".so", baseName ); #elif defined( MACOS_X ) idStr::snPrintf( dllName, maxLength, "%s" ".dylib", baseName ); +#elif defined( __unix__ ) + idStr::snPrintf( dllName, maxLength, "%s" CPUSTRING ".so", baseName ); #else #error OS define is required #endif diff --git a/sys/sys_public.h b/sys/sys_public.h index 336aef4..f124e99 100644 --- a/sys/sys_public.h +++ b/sys/sys_public.h @@ -133,7 +133,7 @@ If you have questions concerning this license or the applicable additional terms // Linux -#ifdef __linux__ +#ifdef __unix__ #ifdef __i386__ #define BUILD_STRING "linux-x86" diff --git a/sys/win32/gl_logfuncs.cpp b/sys/win32/gl_logfuncs.cpp index 5d47ed0..7c3c6f7 100644 --- a/sys/win32/gl_logfuncs.cpp +++ b/sys/win32/gl_logfuncs.cpp @@ -1871,7 +1871,7 @@ static void APIENTRY logViewport(GLint x, GLint y, GLsizei width, GLsizei height } -#ifdef __linux__ +#ifdef __unix__ static XVisualInfo * APIENTRY logChooseVisual(Display *dpy, int screen, int *attribList) { // unknown type: "Display *" name: "dpy" diff --git a/sys/win32/win_main.cpp b/sys/win32/win_main.cpp index 0167a27..5e11688 100644 --- a/sys/win32/win_main.cpp +++ b/sys/win32/win_main.cpp @@ -1386,7 +1386,7 @@ EXCEPTION_DISPOSITION __cdecl _except_handler( struct _EXCEPTION_RECORD *Excepti #if defined(MACOS_X) #define UMP_SKU "OSX" -#elif defined( __linux__ ) +#elif defined( __unix__ ) #define UMP_SKU "Linux" #else #define UMP_SKU "Win32" diff --git a/tools/compilers/dmap/optimize.cpp b/tools/compilers/dmap/optimize.cpp index 46e29ca..d423dcc 100644 --- a/tools/compilers/dmap/optimize.cpp +++ b/tools/compilers/dmap/optimize.cpp @@ -181,7 +181,7 @@ static void LinkEdge( optEdge_t *e ) { e->v2->edges = e; } -#ifdef __linux__ +#ifdef __unix__ optVertex_t *FindOptVertex( idDrawVert *v, optimizeGroup_t *opt );