Skip to content

Commit 7b61575

Browse files
committedSep 23, 2012
initial Mac OS X support
1 parent 38c1674 commit 7b61575

File tree

3 files changed

+26
-10
lines changed

3 files changed

+26
-10
lines changed
 

‎CMakeLists.txt

+17-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,11 @@ endif()
3636
option(BUNDLED_LIBS "Use bundled libraries instead of the system ones." OFF)
3737

3838
# Optional features
39-
option(SMP_SUPPORT "Enable SMP (multicore support) (client)" ON)
39+
if (CMAKE_SYSTEM MATCHES "Darwin")
40+
option(SMP_SUPPORT "Enable SMP (multicore support) (client)" OFF)
41+
else()
42+
option(SMP_SUPPORT "Enable SMP (multicore support) (client)" ON)
43+
endif()
4044
option(USE_CURL "Enable auto-download support using cURL (client)" ON)
4145
option(USE_CODEC_VORBIS "Enable OGG Vorbis support (client)" OFF)
4246
option(USE_OPENAL "Enable OpenAL sound backend (client) [BROKEN]" OFF)
@@ -60,6 +64,14 @@ if(UNIX)
6064
if (CMAKE_SYSTEM MATCHES "OpenBSD*")
6165
set(OS_LIBRARIES m pthread)
6266
set(LIB_SUFFIX ".mp.obsd.")
67+
elseif(CMAKE_SYSTEM MATCHES "Darwin")
68+
set(OS_LIBRARIES dl m)
69+
set(CMAKE_EXE_LINKER_FLAGS "-lobjc -framework Cocoa -framework IOKit -framework CoreFoundation")
70+
if(BUILD_CLIENT)
71+
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -framework Quartz -framework AudioUnit -framework Carbon -lSDLmain")
72+
endif()
73+
set(LIB_SUFFIX ".mp.")
74+
add_definitions("-DMACOS_X")
6375
else()
6476
set(OS_LIBRARIES dl m)
6577
set(LIB_SUFFIX ".mp.")
@@ -101,6 +113,10 @@ endif()
101113
FILE(GLOB COMMON_SRC
102114
"src/qcommon/*.c"
103115
)
116+
if(CMAKE_SYSTEM MATCHES "Darwin")
117+
LIST(APPEND COMMON_SRC "src/sys/sys_osx.m")
118+
SET_SOURCE_FILES_PROPERTIES("src/sys/sys_osx.m" PROPERTIES LANGUAGE C)
119+
endif()
104120

105121
FILE(GLOB COMMON_SRC_REMOVE
106122
"src/qcommon/dl_main_curl.c"

‎src/qcommon/q_shared.h

+7-7
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,6 @@ typedef unsigned __int8 uint8_t;
193193

194194
#if defined(MACOS_X)
195195

196-
#error WTF
197-
198196
#define MAC_STATIC
199197

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

211-
static inline float idSqrt(float x)
209+
// TODO: check if x86 arch has speed increase. fix this function
210+
/*static inline float idSqrt(float x)
212211
{
213212
const float half = 0.5;
214213
const float one = 1.0;
215214
float B, y0, y1;
216215
217216
// This'll NaN if it hits frsqrte. Handle both +0.0 and -0.0
218-
if (Q_fabs(x) == 0.0)
217+
if (fabs(x) == 0.0)
219218
{
220219
return x;
221220
}
@@ -226,19 +225,20 @@ static inline float idSqrt(float x)
226225
#else
227226
y0 = __frsqrte(B);
228227
#endif
229-
/* First refinement step */
228+
// First refinement step
230229
231230
y1 = y0 + half * y0 * (one - B * y0 * y0);
232231
233-
/* Second refinement step -- copy the output of the last step to the input of this step */
232+
// Second refinement step -- copy the output of the last step to the input of this step
234233
235234
y0 = y1;
236235
y1 = y0 + half * y0 * (one - B * y0 * y0);
237236
238-
/* Get sqrt(x) from x * 1/sqrt(x) */
237+
// Get sqrt(x) from x * 1/sqrt(x)
239238
return x * y1;
240239
}
241240
#define sqrt idSqrt
241+
*/
242242

243243

244244
#endif

‎src/sdl/sdl_input.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@
3232
*/
3333

3434
#ifdef BUNDLED_LIBS
35-
# include "SDL.h"
35+
#include "SDL.h"
3636
#else
37-
# include <SDL/SDL.h>
37+
#include <SDL/SDL.h>
3838
#endif
3939

4040
#include <stdarg.h>

0 commit comments

Comments
 (0)