Skip to content

Commit

Permalink
initial Mac OS X support
Browse files Browse the repository at this point in the history
  • Loading branch information
morsik committed Sep 23, 2012
1 parent 38c1674 commit 7b61575
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 10 deletions.
18 changes: 17 additions & 1 deletion CMakeLists.txt
Expand Up @@ -36,7 +36,11 @@ endif()
option(BUNDLED_LIBS "Use bundled libraries instead of the system ones." OFF)

# Optional features
option(SMP_SUPPORT "Enable SMP (multicore support) (client)" ON)
if (CMAKE_SYSTEM MATCHES "Darwin")
option(SMP_SUPPORT "Enable SMP (multicore support) (client)" OFF)
else()
option(SMP_SUPPORT "Enable SMP (multicore support) (client)" ON)
endif()
option(USE_CURL "Enable auto-download support using cURL (client)" ON)
option(USE_CODEC_VORBIS "Enable OGG Vorbis support (client)" OFF)
option(USE_OPENAL "Enable OpenAL sound backend (client) [BROKEN]" OFF)
Expand All @@ -60,6 +64,14 @@ if(UNIX)
if (CMAKE_SYSTEM MATCHES "OpenBSD*")
set(OS_LIBRARIES m pthread)
set(LIB_SUFFIX ".mp.obsd.")
elseif(CMAKE_SYSTEM MATCHES "Darwin")
set(OS_LIBRARIES dl m)
set(CMAKE_EXE_LINKER_FLAGS "-lobjc -framework Cocoa -framework IOKit -framework CoreFoundation")
if(BUILD_CLIENT)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -framework Quartz -framework AudioUnit -framework Carbon -lSDLmain")
endif()
set(LIB_SUFFIX ".mp.")
add_definitions("-DMACOS_X")
else()
set(OS_LIBRARIES dl m)
set(LIB_SUFFIX ".mp.")
Expand Down Expand Up @@ -101,6 +113,10 @@ endif()
FILE(GLOB COMMON_SRC
"src/qcommon/*.c"
)
if(CMAKE_SYSTEM MATCHES "Darwin")
LIST(APPEND COMMON_SRC "src/sys/sys_osx.m")
SET_SOURCE_FILES_PROPERTIES("src/sys/sys_osx.m" PROPERTIES LANGUAGE C)
endif()

FILE(GLOB COMMON_SRC_REMOVE
"src/qcommon/dl_main_curl.c"
Expand Down
14 changes: 7 additions & 7 deletions src/qcommon/q_shared.h
Expand Up @@ -193,8 +193,6 @@ typedef unsigned __int8 uint8_t;

#if defined(MACOS_X)

#error WTF

#define MAC_STATIC

#define CPUSTRING "MacOS_X"
Expand All @@ -208,14 +206,15 @@ typedef unsigned __int8 uint8_t;
// This is about 12.4 times faster than sqrt() and according to my testing (not exhaustive)
// it returns fairly accurate results (error below 1.0e-5 up to 100000.0 in 0.1 increments).

static inline float idSqrt(float x)
// TODO: check if x86 arch has speed increase. fix this function
/*static inline float idSqrt(float x)
{
const float half = 0.5;
const float one = 1.0;
float B, y0, y1;
// This'll NaN if it hits frsqrte. Handle both +0.0 and -0.0
if (Q_fabs(x) == 0.0)
if (fabs(x) == 0.0)
{
return x;
}
Expand All @@ -226,19 +225,20 @@ static inline float idSqrt(float x)
#else
y0 = __frsqrte(B);
#endif
/* First refinement step */
// First refinement step
y1 = y0 + half * y0 * (one - B * y0 * y0);
/* Second refinement step -- copy the output of the last step to the input of this step */
// Second refinement step -- copy the output of the last step to the input of this step
y0 = y1;
y1 = y0 + half * y0 * (one - B * y0 * y0);
/* Get sqrt(x) from x * 1/sqrt(x) */
// Get sqrt(x) from x * 1/sqrt(x)
return x * y1;
}
#define sqrt idSqrt
*/


#endif
Expand Down
4 changes: 2 additions & 2 deletions src/sdl/sdl_input.c
Expand Up @@ -32,9 +32,9 @@
*/

#ifdef BUNDLED_LIBS
# include "SDL.h"
#include "SDL.h"
#else
# include <SDL/SDL.h>
#include <SDL/SDL.h>
#endif

#include <stdarg.h>
Expand Down

0 comments on commit 7b61575

Please sign in to comment.