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