fixed ndof library detect for Mac SCons, ndof enabled by default (disabled if lib...
[blender.git] / build_files / scons / config / darwin-config.py
1 #
2 # Note : if you want to alter this file
3 # copy it as a whole in the upper folder
4 # as user-config.py
5 # dont create a new file with only some
6 # vars changed.
7
8 import commands
9
10 # IMPORTANT NOTE : OFFICIAL BUILDS SHOULD BE DONE WITH SDKs
11 USE_SDK=True
12
13 #############################################################################
14 ###################     Cocoa & architecture settings      ##################
15 #############################################################################
16 WITH_GHOST_COCOA=True
17 MACOSX_ARCHITECTURE = 'i386' # valid archs: ppc, i386, ppc64, x86_64
18
19
20 cmd = 'uname -p'
21 MAC_PROC=commands.getoutput(cmd) 
22 cmd = 'uname -r'
23 cmd_res=commands.getoutput(cmd) 
24 MAC_CUR_VER='10.5' # by default (test below fails on my 10.5 PowerPC)
25 if cmd_res[:2]=='7':
26         MAC_CUR_VER='10.3'
27 elif cmd_res[:2]=='8':
28         MAC_CUR_VER='10.4'
29 elif cmd_res[:2]=='9':
30         MAC_CUR_VER='10.5'
31 elif cmd_res[:2]=='10':
32         MAC_CUR_VER='10.6'
33 elif cmd_res[:2]=='11':
34         MAC_CUR_VER='10.7'
35
36 if MACOSX_ARCHITECTURE == 'x86_64' or MACOSX_ARCHITECTURE == 'ppc64':
37         USE_QTKIT=True # Carbon quicktime is not available for 64bit
38
39
40 # Default target OSX settings per architecture
41 # Can be customized
42
43 if MACOSX_ARCHITECTURE == 'ppc' and MAC_CUR_VER == '10.4':
44 # all releases are now made for 10.5 !
45 #       MAC_MIN_VERS = '10.3'
46 #       MACOSX_SDK='/Developer/SDKs/MacOSX10.3.9.sdk'
47 #       LCGDIR = '#../lib/darwin-6.1-powerpc'
48 #       CC = 'gcc-3.3'
49 #       CXX = 'g++-3.3'
50         MAC_MIN_VERS = '10.4'
51         MACOSX_DEPLOYMENT_TARGET = '10.4'
52         MACOSX_SDK='/Developer/SDKs/MacOSX10.4u.sdk'
53         LCGDIR = '#../lib/darwin-8.0.0-powerpc'
54         CC = 'gcc-4.0'
55         CXX = 'g++-4.0'
56 elif MACOSX_ARCHITECTURE == 'i386' and MAC_CUR_VER == '10.4':
57         MAC_MIN_VERS = '10.4'
58         MACOSX_DEPLOYMENT_TARGET = '10.4'
59         MACOSX_SDK='/Developer/SDKs/MacOSX10.4u.sdk'
60         LCGDIR = '#../lib/darwin-8.x.i386'
61         CC = 'gcc-4.0'
62         CXX = 'g++-4.0'
63 elif MAC_CUR_VER >= '10.6':
64         # OSX 10.6 and 10.7 developer tools do not come with sdk < 10.6 anymore !
65         MAC_MIN_VERS = '10.6'
66         MACOSX_DEPLOYMENT_TARGET = '10.6'
67         MACOSX_SDK='/Developer/SDKs/MacOSX10.6.sdk'
68         LCGDIR = '#../lib/darwin-9.x.universal'
69         CC = 'llvm-gcc-4.2'
70         CXX = 'llvm-g++-4.2'
71 else :
72         MAC_MIN_VERS = '10.5'
73         MACOSX_DEPLOYMENT_TARGET = '10.5'
74         MACOSX_SDK='/Developer/SDKs/MacOSX10.5.sdk'
75         LCGDIR = '#../lib/darwin-9.x.universal'
76         CC = 'gcc-4.2'
77         CXX = 'g++-4.2'
78
79 LIBDIR = '${LCGDIR}'
80
81 #############################################################################
82 ###################          Dependency settings           ##################
83 #############################################################################
84
85 #Defaults openMP to true if compiler handles it
86 if CC == 'gcc-4.2' or CC == 'llvm-gcc-4.2':
87     WITH_BF_OPENMP = True  # multithreading for fluids, cloth and smoke
88 else:
89     WITH_BF_OPENMP = False
90
91 # enable ffmpeg  support
92 WITH_BF_FFMPEG = True  # -DWITH_FFMPEG
93 BF_FFMPEG = LIBDIR + '/ffmpeg'
94 BF_FFMPEG_INC = "${BF_FFMPEG}/include"
95 BF_FFMPEG_LIBPATH='${BF_FFMPEG}/lib'
96 BF_FFMPEG_LIB = 'avcodec avdevice avformat avutil mp3lame swscale x264 xvidcore theora theoradec theoraenc vorbis vorbisenc vorbisfile ogg bz2'
97 #bz2 is a standard osx dynlib
98
99 # python 3.1 uses precompiled libraries in bf svn /lib by default
100 BF_PYTHON_VERSION = '3.2'
101 BF_PYTHON = LIBDIR + '/python'
102 BF_PYTHON_INC = '${BF_PYTHON}/include/python${BF_PYTHON_VERSION}'
103 # BF_PYTHON_BINARY = '${BF_PYTHON}/bin/python${BF_PYTHON_VERSION}'
104 BF_PYTHON_LIB = 'python${BF_PYTHON_VERSION}'
105 BF_PYTHON_LIBPATH = '${BF_PYTHON}/lib/python${BF_PYTHON_VERSION}'
106 # BF_PYTHON_LINKFLAGS = ['-u', '_PyMac_Error', '-framework', 'System']
107         
108 WITH_BF_OPENAL = True
109 #different lib must be used  following version of gcc
110 # for gcc 3.3
111 #BF_OPENAL = LIBDIR + '/openal'
112 # for gcc 3.4 and ulterior
113 if MAC_PROC == 'powerpc':
114         BF_OPENAL = '#../lib/darwin-8.0.0-powerpc/openal'
115 else :
116         BF_OPENAL = LIBDIR + '/openal'
117
118 WITH_BF_STATICOPENAL = False
119 BF_OPENAL_INC = '${BF_OPENAL}/include' # only headers from libdir needed for proper use of framework !!!!
120 #BF_OPENAL_LIB = 'openal'
121 #BF_OPENAL_LIBPATH = '${BF_OPENAL}/lib'
122 # Warning, this static lib configuration is untested! users of this OS please confirm.
123 #BF_OPENAL_LIB_STATIC = '${BF_OPENAL}/lib/libopenal.a'
124
125 # Warning, this static lib configuration is untested! users of this OS please confirm.
126 BF_CXX = '/usr'
127 WITH_BF_STATICCXX = False
128 BF_CXX_LIB_STATIC = '${BF_CXX}/lib/libstdc++.a'
129
130 BF_LIBSAMPLERATE = LIBDIR + '/samplerate'
131 BF_LIBSAMPLERATE_INC = '${BF_LIBSAMPLERATE}/include'
132 BF_LIBSAMPLERATE_LIB = 'samplerate'
133 BF_LIBSAMPLERATE_LIBPATH = '${BF_LIBSAMPLERATE}/lib'
134
135 # TODO - set proper paths here (add precompiled to lib/ ? )
136 WITH_BF_JACK = False
137 BF_JACK = '/usr'
138 BF_JACK_INC = '${BF_JACK}/include/jack'
139 BF_JACK_LIB = 'jack'
140 BF_JACK_LIBPATH = '${BF_JACK}/lib'
141
142 WITH_BF_SNDFILE = True
143 BF_SNDFILE = LIBDIR + '/sndfile'
144 BF_SNDFILE_INC = '${BF_SNDFILE}/include'
145 BF_SNDFILE_LIB = 'sndfile FLAC ogg vorbis vorbisenc'
146 BF_SNDFILE_LIBPATH = '${BF_SNDFILE}/lib ${BF_FFMPEG}/lib' #ogg libs are stored in ffmpeg dir
147
148 WITH_BF_SDL = True
149 BF_SDL = LIBDIR + '/sdl' #$(shell sdl-config --prefix)
150 BF_SDL_INC = '${BF_SDL}/include' #$(shell $(BF_SDL)/bin/sdl-config --cflags)
151 BF_SDL_LIB = 'SDL' #BF_SDL #$(shell $(BF_SDL)/bin/sdl-config --libs) -lSDL_mixer
152 BF_SDL_LIBPATH = '${BF_SDL}/lib'
153
154 WITH_BF_OPENEXR = True
155 WITH_BF_STATICOPENEXR = False
156 BF_OPENEXR = '${LCGDIR}/openexr'
157 BF_OPENEXR_INC = '${BF_OPENEXR}/include ${BF_OPENEXR}/include/OpenEXR'
158 BF_OPENEXR_LIB = ' Iex Half IlmImf Imath IlmThread'
159 BF_OPENEXR_LIBPATH = '${BF_OPENEXR}/lib'
160 # Warning, this static lib configuration is untested! users of this OS please confirm.
161 BF_OPENEXR_LIB_STATIC = '${BF_OPENEXR}/lib/libHalf.a ${BF_OPENEXR}/lib/libIlmImf.a ${BF_OPENEXR}/lib/libIex.a ${BF_OPENEXR}/lib/libImath.a ${BF_OPENEXR}/lib/libIlmThread.a'
162
163 WITH_BF_DDS = True
164
165 #Color Management System
166 WITH_BF_LCMS = False
167 BF_LCMS = LIBDIR + '/lcms'
168 BF_LCMS_INC = '${BF_LCMS}/include'
169 BF_LCMS_LIB = 'lcms'
170 BF_LCMS_LIBPATH = '${BF_LCMS}/lib'
171
172 WITH_BF_JPEG = True
173 BF_JPEG = LIBDIR + '/jpeg'
174 BF_JPEG_INC = '${BF_JPEG}/include'
175 BF_JPEG_LIB = 'jpeg'
176 BF_JPEG_LIBPATH = '${BF_JPEG}/lib'
177
178 WITH_BF_PNG = True
179 BF_PNG = LIBDIR + '/png'
180 BF_PNG_INC = '${BF_PNG}/include'
181 BF_PNG_LIB = 'png'
182 BF_PNG_LIBPATH = '${BF_PNG}/lib'
183
184 WITH_BF_TIFF = True
185 BF_TIFF = LIBDIR + '/tiff'
186 BF_TIFF_INC = '${BF_TIFF}/include'
187 BF_TIFF_LIB = 'tiff'
188 BF_TIFF_LIBPATH = '${BF_TIFF}/lib'
189
190 WITH_BF_ZLIB = True
191 BF_ZLIB = '/usr'
192 BF_ZLIB_INC = '${BF_ZLIB}/include'
193 BF_ZLIB_LIB = 'z'
194
195 WITH_BF_INTERNATIONAL = True
196
197 BF_GETTEXT = LIBDIR + '/gettext'
198 BF_GETTEXT_INC = '${BF_GETTEXT}/include'
199 BF_GETTEXT_LIB = 'intl'
200 BF_GETTEXT_LIBPATH = '${BF_GETTEXT}/lib'
201
202 WITH_BF_GAMEENGINE = True
203 WITH_BF_PLAYER = False
204
205 WITH_BF_BULLET = True
206 BF_BULLET = '#extern/bullet2/src'
207 BF_BULLET_INC = '${BF_BULLET}'
208 BF_BULLET_LIB = 'extern_bullet'
209
210 WITH_BF_FFTW3 = True
211 BF_FFTW3 = LIBDIR + '/fftw3'
212 BF_FFTW3_INC = '${BF_FFTW3}/include'
213 BF_FFTW3_LIB = 'libfftw3'
214 BF_FFTW3_LIBPATH = '${BF_FFTW3}/lib'
215
216 #WITH_BF_NSPR = True
217 #BF_NSPR = $(LIBDIR)/nspr
218 #BF_NSPR_INC = -I$(BF_NSPR)/include -I$(BF_NSPR)/include/nspr
219 #BF_NSPR_LIB = 
220
221 # Uncomment the following line to use Mozilla inplace of netscape
222 #CPPFLAGS += -DMOZ_NOT_NET
223 # Location of MOZILLA/Netscape header files...
224 #BF_MOZILLA = $(LIBDIR)/mozilla
225 #BF_MOZILLA_INC = -I$(BF_MOZILLA)/include/mozilla/nspr -I$(BF_MOZILLA)/include/mozilla -I$(BF_MOZILLA)/include/mozilla/xpcom -I$(BF_MOZILLA)/include/mozilla/idl
226 #BF_MOZILLA_LIB =
227 # Will fall back to look in BF_MOZILLA_INC/nspr and BF_MOZILLA_LIB
228 # if this is not set.
229 #
230 # Be paranoid regarding library creation (do not update archives)
231 #BF_PARANOID = True
232
233 # enable freetype2 support for text objects
234 BF_FREETYPE = LIBDIR + '/freetype'
235 BF_FREETYPE_INC = '${BF_FREETYPE}/include ${BF_FREETYPE}/include/freetype2'
236 BF_FREETYPE_LIB = 'freetype'
237 BF_FREETYPE_LIBPATH = '${BF_FREETYPE}/lib'
238
239 WITH_BF_QUICKTIME = True
240
241 WITH_BF_ICONV = True
242 BF_ICONV = '/usr'
243 BF_ICONV_INC = '${BF_ICONV}/include'
244 BF_ICONV_LIB = 'iconv'
245 #BF_ICONV_LIBPATH = '${BF_ICONV}/lib'
246
247 # Mesa Libs should go here if your using them as well....
248 WITH_BF_STATICOPENGL = True
249 BF_OPENGL_LIB = 'GL GLU'
250 BF_OPENGL_LIBPATH = '/System/Library/Frameworks/OpenGL.framework/Libraries'
251 BF_OPENGL_LINKFLAGS = ['-framework', 'OpenGL']
252
253 #OpenCollada flags
254 WITH_BF_COLLADA = False
255 BF_COLLADA = '#source/blender/collada'
256 BF_COLLADA_INC = '${BF_COLLADA}'
257 BF_COLLADA_LIB = 'bf_collada'
258 BF_OPENCOLLADA = LIBDIR + '/opencollada'
259 BF_OPENCOLLADA_INC = '${BF_OPENCOLLADA}/include'
260 BF_OPENCOLLADA_LIB = 'OpenCOLLADASaxFrameworkLoader OpenCOLLADAFramework OpenCOLLADABaseUtils OpenCOLLADAStreamWriter MathMLSolver GeneratedSaxParser UTF xml2 buffer ftoa'
261 BF_OPENCOLLADA_LIBPATH = LIBDIR + '/opencollada'
262 BF_PCRE = LIBDIR + '/opencollada'
263 BF_PCRE_LIB = 'pcre'
264 BF_PCRE_LIBPATH = '${BF_PCRE}/lib'
265 #BF_EXPAT = '/usr'
266 #BF_EXPAT_LIB = 'expat'
267 #BF_EXPAT_LIBPATH = '/usr/lib'
268
269 #Ray trace optimization
270 if MACOSX_ARCHITECTURE == 'x86_64' or MACOSX_ARCHITECTURE == 'i386':
271     WITH_BF_RAYOPTIMIZATION = True
272 else:
273     WITH_BF_RAYOPTIMIZATION = False
274 if MACOSX_ARCHITECTURE == 'i386':
275     BF_RAYOPTIMIZATION_SSE_FLAGS = ['-msse']
276 elif MACOSX_ARCHITECTURE == 'x86_64':
277     BF_RAYOPTIMIZATION_SSE_FLAGS = ['-msse','-msse2']
278
279 # SpaceNavigator and related 3D mice
280 WITH_BF_3DMOUSE = True
281
282 #############################################################################
283 ###################  various compile settings and flags    ##################
284 #############################################################################
285
286 BF_QUIET = '1' # suppress verbose output
287
288 if MACOSX_ARCHITECTURE == 'x86_64' or MACOSX_ARCHITECTURE == 'ppc64':
289         ARCH_FLAGS = ['-m64']
290 else:
291         ARCH_FLAGS = ['-m32']
292
293 CFLAGS = ['-pipe','-funsigned-char']+ARCH_FLAGS
294
295 CPPFLAGS = []+ARCH_FLAGS
296 CCFLAGS = ['-pipe','-funsigned-char']+ARCH_FLAGS
297 CXXFLAGS = ['-pipe','-funsigned-char']+ARCH_FLAGS
298
299 if WITH_GHOST_COCOA:
300         PLATFORM_LINKFLAGS = ['-fexceptions','-framework','CoreServices','-framework','Foundation','-framework','IOKit','-framework','AppKit','-framework','Cocoa','-framework','Carbon','-framework','AudioUnit','-framework','AudioToolbox','-framework','CoreAudio','-framework','OpenAL']+ARCH_FLAGS
301 else:
302         PLATFORM_LINKFLAGS = ['-fexceptions','-framework','CoreServices','-framework','Foundation','-framework','IOKit','-framework','AppKit','-framework','Carbon','-framework','AGL','-framework','AudioUnit','-framework','AudioToolbox','-framework','CoreAudio','-framework','OpenAL']+ARCH_FLAGS
303
304 if WITH_BF_QUICKTIME:
305         if USE_QTKIT:
306                 PLATFORM_LINKFLAGS = PLATFORM_LINKFLAGS+['-framework','QTKit']
307         else:
308                 PLATFORM_LINKFLAGS = PLATFORM_LINKFLAGS+['-framework','QuickTime']
309
310 if WITH_BF_3DMOUSE:
311         PLATFORM_LINKFLAGS = PLATFORM_LINKFLAGS + ['-weak_framework','3DconnexionClient']
312
313 #note to build succesfully on 10.3.9 SDK you need to patch  10.3.9 by adding the SystemStubs.a lib from 10.4
314 LLIBS = ['stdc++', 'SystemStubs']
315
316 # some flags shuffling for different OS versions
317 if MAC_MIN_VERS == '10.3':
318         CFLAGS = ['-fuse-cxa-atexit']+CFLAGS
319         CXXFLAGS = ['-fuse-cxa-atexit']+CXXFLAGS
320         PLATFORM_LINKFLAGS = ['-fuse-cxa-atexit']+PLATFORM_LINKFLAGS
321         LLIBS.append('crt3.o')
322         
323 if USE_SDK:
324         SDK_FLAGS=['-isysroot', MACOSX_SDK,'-mmacosx-version-min='+MAC_MIN_VERS,'-arch',MACOSX_ARCHITECTURE]    
325         PLATFORM_LINKFLAGS = ['-mmacosx-version-min='+MAC_MIN_VERS,'-Wl','-isysroot',MACOSX_SDK,'-arch',MACOSX_ARCHITECTURE]+PLATFORM_LINKFLAGS
326         CCFLAGS=SDK_FLAGS+CCFLAGS
327         CXXFLAGS=SDK_FLAGS+CXXFLAGS
328
329 #Intel Macs are CoreDuo and Up  
330 if MACOSX_ARCHITECTURE == 'i386' or MACOSX_ARCHITECTURE == 'x86_64':
331         REL_CFLAGS = ['-DNDEBUG', '-O2','-ftree-vectorize','-msse','-msse2','-msse3','-mfpmath=sse']
332         REL_CCFLAGS = ['-DNDEBUG', '-O2','-ftree-vectorize','-msse','-msse2','-msse3','-mfpmath=sse']
333 else:
334         CFLAGS = CFLAGS+['-fno-strict-aliasing']
335         CCFLAGS =  CCFLAGS+['-fno-strict-aliasing']
336         CXXFLAGS = CXXFLAGS+['-fno-strict-aliasing']
337         REL_CFLAGS = ['-DNDEBUG', '-O2']
338         REL_CCFLAGS = ['-DNDEBUG', '-O2']
339
340 # Intel 64bit Macs are Core2Duo and up
341 if MACOSX_ARCHITECTURE == 'x86_64':
342         REL_CFLAGS = REL_CFLAGS+['-march=core2','-mssse3','-with-tune=core2','-enable-threads']
343         REL_CCFLAGS = REL_CCFLAGS+['-march=core2','-mssse3','-with-tune=core2','-enable-threads']
344
345 CC_WARN = ['-Wall']
346 C_WARN = ['-Wno-char-subscripts', '-Wpointer-arith', '-Wcast-align', '-Wdeclaration-after-statement', '-Wno-unknown-pragmas', '-Wstrict-prototypes']
347 CXX_WARN = ['-Wno-invalid-offsetof', '-Wno-sign-compare']
348
349 ##FIX_STUBS_WARNINGS = -Wno-unused
350
351 ##LOPTS = --dynamic
352 ##DYNLDFLAGS = -shared $(LDFLAGS)
353
354 BF_PROFILE_CCFLAGS = ['-pg', '-g ']
355 BF_PROFILE_LINKFLAGS = ['-pg']
356 BF_PROFILE = False
357
358 BF_DEBUG = False
359 BF_DEBUG_CCFLAGS = ['-g', '-D_DEBUG']
360
361 #############################################################################
362 ###################           Output directories           ##################
363 #############################################################################
364
365 BF_BUILDDIR='../build/darwin'
366 BF_INSTALLDIR='../install/darwin'