OSX/cmake/scons: python version foolproof
[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
25 if cmd_res[:1]=='7':
26     MAC_CUR_VER='10.3'
27 elif cmd_res[:1]=='8':
28     MAC_CUR_VER='10.4'
29 elif cmd_res[:1]=='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 elif cmd_res[:2]=='12':
36     MAC_CUR_VER='10.8'
37 cmd = 'xcodebuild -version'
38 cmd_xcode=commands.getoutput(cmd)
39 XCODE_CUR_VER=cmd_xcode[6:][:3] # truncate output to major.minor version
40 cmd = 'xcodebuild -showsdks'
41 cmd_sdk=commands.getoutput(cmd)
42 MACOSX_SDK_CHECK=cmd_sdk
43
44 if MACOSX_ARCHITECTURE == 'x86_64' or MACOSX_ARCHITECTURE == 'ppc64':
45     USE_QTKIT=True # Carbon quicktime is not available for 64bit
46
47
48 # Default target OSX settings per architecture
49 # Can be customized
50
51 if MACOSX_ARCHITECTURE == 'ppc' and MAC_CUR_VER == '10.4':
52 # all releases are now made for 10.5 !
53 #   MAC_MIN_VERS = '10.3'
54 #   MACOSX_SDK='/Developer/SDKs/MacOSX10.3.9.sdk'
55 #   LCGDIR = '#../lib/darwin-6.1-powerpc'
56 #   CC = 'gcc-3.3'
57 #   CXX = 'g++-3.3'
58     MAC_MIN_VERS = '10.4'
59     MACOSX_DEPLOYMENT_TARGET = '10.4'
60     MACOSX_SDK='/Developer/SDKs/MacOSX10.4u.sdk'
61     LCGDIR = '#../lib/darwin-8.0.0-powerpc'
62     CC = 'gcc-4.0'
63     CXX = 'g++-4.0'
64 elif MACOSX_ARCHITECTURE == 'i386' and MAC_CUR_VER == '10.4':
65     MAC_MIN_VERS = '10.4'
66     MACOSX_DEPLOYMENT_TARGET = '10.4'
67     MACOSX_SDK='/Developer/SDKs/MacOSX10.4u.sdk'
68     LCGDIR = '#../lib/darwin-8.x.i386'
69     CC = 'gcc-4.0'
70     CXX = 'g++-4.0'
71 else :
72     if 'Mac OS X 10.5' in MACOSX_SDK_CHECK:
73         # OSX 10.5/6 with Xcode 3.x
74         MAC_MIN_VERS = '10.5'
75         MACOSX_DEPLOYMENT_TARGET = '10.5'
76         MACOSX_SDK='/Developer/SDKs/MacOSX10.5.sdk'
77         LCGDIR = '#../lib/darwin-9.x.universal'
78         CC = 'gcc-4.2'
79         CXX = 'g++-4.2'
80     elif 'Mac OS X 10.6' in MACOSX_SDK_CHECK:
81         # OSX 10.6/7 with Xcode 4.x
82         MAC_MIN_VERS = '10.6'
83         MACOSX_DEPLOYMENT_TARGET = '10.6'
84         MACOSX_SDK='/Developer/SDKs/MacOSX10.6.sdk'
85         LCGDIR = '#../lib/darwin-9.x.universal'
86         CC = 'gcc-4.2'
87         CXX = 'g++-4.2'
88     else:
89         # OSX 10.8 with Xcode 4.4 and higher (no 10.6sdk! )
90         MAC_MIN_VERS = '10.6'
91         MACOSX_DEPLOYMENT_TARGET = '10.6'
92         MACOSX_SDK='/Developer/SDKs/MacOSX10.7.sdk'
93         LCGDIR = '#../lib/darwin-9.x.universal'
94         CC = 'gcc'
95         CXX = 'g++'
96
97 LIBDIR = '${LCGDIR}'
98
99 if XCODE_CUR_VER >= '4.3':  ## since version 4.3, XCode and developer dir are bundled ##
100         MACOSX_SDK = '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform' + MACOSX_SDK
101
102 #############################################################################
103 ###################          Dependency settings           ##################
104 #############################################################################
105
106 #Defaults openMP to true if compiler handles it ( only gcc 4.6.1 and newer )
107 # if your compiler does not have accurate suffix you may have to enable it by hand !
108 if CC[:-2].endswith('4.6'):
109     WITH_BF_OPENMP = True  # multithreading for fluids, cloth, sculpt and smoke
110 else:
111     WITH_BF_OPENMP = False
112
113 # enable ffmpeg  support
114 WITH_BF_FFMPEG = True
115 BF_FFMPEG = LIBDIR + '/ffmpeg'
116 BF_FFMPEG_INC = "${BF_FFMPEG}/include"
117 BF_FFMPEG_LIBPATH='${BF_FFMPEG}/lib'
118 BF_FFMPEG_LIB = 'avcodec avdevice avformat avutil mp3lame swscale x264 xvidcore theora theoradec theoraenc vorbis vorbisenc vorbisfile ogg bz2'
119 #bz2 is a standard osx dynlib
120
121 BF_PYTHON_VERSION = '3.3'
122 WITH_OSX_STATICPYTHON = True
123
124 if WITH_OSX_STATICPYTHON:
125     # python 3.3 uses precompiled libraries in bf svn /lib by default
126
127     BF_PYTHON = LIBDIR + '/python'
128     BF_PYTHON_INC = '${BF_PYTHON}/include/python${BF_PYTHON_VERSION}m'
129     # BF_PYTHON_BINARY = '${BF_PYTHON}/bin/python${BF_PYTHON_VERSION}'
130     BF_PYTHON_LIB = 'python${BF_PYTHON_VERSION}m'
131     BF_PYTHON_LIBPATH = '${BF_PYTHON}/lib/python${BF_PYTHON_VERSION}'
132     # BF_PYTHON_LINKFLAGS = ['-u', '_PyMac_Error', '-framework', 'System']
133 else:
134     # python 3.2 uses Python-framework additionally installed in /Library/Frameworks
135
136     BF_PYTHON = '/Library/Frameworks/Python.framework/Versions/'
137     BF_PYTHON_INC = '${BF_PYTHON}${BF_PYTHON_VERSION}/include/python${BF_PYTHON_VERSION}m'
138     BF_PYTHON_BINARY = '${BF_PYTHON}${BF_PYTHON_VERSION}/bin/python${BF_PYTHON_VERSION}'
139     #BF_PYTHON_LIB = ''
140     BF_PYTHON_LIBPATH = '${BF_PYTHON}${BF_PYTHON_VERSION}/lib/python${BF_PYTHON_VERSION}/config-${BF_PYTHON_VERSION}m'
141
142 WITH_BF_OPENAL = True
143 #different lib must be used  following version of gcc
144 # for gcc 3.3
145 #BF_OPENAL = LIBDIR + '/openal'
146 # for gcc 3.4 and ulterior
147 if MAC_PROC == 'powerpc':
148     BF_OPENAL = '#../lib/darwin-8.0.0-powerpc/openal'
149 else :
150     BF_OPENAL = LIBDIR + '/openal'
151
152 WITH_BF_STATICOPENAL = False
153 BF_OPENAL_INC = '${BF_OPENAL}/include' # only headers from libdir needed for proper use of framework !!!!
154 #BF_OPENAL_LIB = 'openal'
155 #BF_OPENAL_LIBPATH = '${BF_OPENAL}/lib'
156 # Warning, this static lib configuration is untested! users of this OS please confirm.
157 #BF_OPENAL_LIB_STATIC = '${BF_OPENAL}/lib/libopenal.a'
158
159 # Warning, this static lib configuration is untested! users of this OS please confirm.
160 BF_CXX = '/usr'
161 WITH_BF_STATICCXX = False
162 BF_CXX_LIB_STATIC = '${BF_CXX}/lib/libstdc++.a'
163
164 # we use simply jack framework
165 WITH_BF_JACK = True
166 BF_JACK = '/Library/Frameworks/Jackmp.framework'
167 BF_JACK_INC = '${BF_JACK}/headers'
168 #BF_JACK_LIB = 'jack' # not used due framework
169 BF_JACK_LIBPATH = '${BF_JACK}'
170
171 WITH_BF_SNDFILE = True
172 BF_SNDFILE = LIBDIR + '/sndfile'
173 BF_SNDFILE_INC = '${BF_SNDFILE}/include'
174 BF_SNDFILE_LIB = 'sndfile FLAC ogg vorbis vorbisenc'
175 BF_SNDFILE_LIBPATH = '${BF_SNDFILE}/lib ${BF_FFMPEG}/lib' #ogg libs are stored in ffmpeg dir
176
177 WITH_BF_SDL = True
178 BF_SDL = LIBDIR + '/sdl' #$(shell sdl-config --prefix)
179 BF_SDL_INC = '${BF_SDL}/include' #$(shell $(BF_SDL)/bin/sdl-config --cflags)
180 BF_SDL_LIB = 'SDL' #BF_SDL #$(shell $(BF_SDL)/bin/sdl-config --libs) -lSDL_mixer
181 BF_SDL_LIBPATH = '${BF_SDL}/lib'
182
183 WITH_BF_OPENEXR = True
184 WITH_BF_STATICOPENEXR = False
185 BF_OPENEXR = '${LCGDIR}/openexr'
186 BF_OPENEXR_INC = '${BF_OPENEXR}/include ${BF_OPENEXR}/include/OpenEXR'
187 BF_OPENEXR_LIB = ' Iex Half IlmImf Imath IlmThread'
188 BF_OPENEXR_LIBPATH = '${BF_OPENEXR}/lib'
189 # Warning, this static lib configuration is untested! users of this OS please confirm.
190 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'
191
192 WITH_BF_DDS = True
193
194 #Color Management System
195 WITH_BF_LCMS = False
196 BF_LCMS = LIBDIR + '/lcms'
197 BF_LCMS_INC = '${BF_LCMS}/include'
198 BF_LCMS_LIB = 'lcms'
199 BF_LCMS_LIBPATH = '${BF_LCMS}/lib'
200
201 WITH_BF_JPEG = True
202 BF_JPEG = LIBDIR + '/jpeg'
203 BF_JPEG_INC = '${BF_JPEG}/include'
204 BF_JPEG_LIB = 'jpeg'
205 BF_JPEG_LIBPATH = '${BF_JPEG}/lib'
206
207 WITH_BF_PNG = True
208 BF_PNG = LIBDIR + '/png'
209 BF_PNG_INC = '${BF_PNG}/include'
210 BF_PNG_LIB = 'png'
211 BF_PNG_LIBPATH = '${BF_PNG}/lib'
212
213 WITH_BF_TIFF = True
214 BF_TIFF = LIBDIR + '/tiff'
215 BF_TIFF_INC = '${BF_TIFF}/include'
216 BF_TIFF_LIB = 'tiff'
217 BF_TIFF_LIBPATH = '${BF_TIFF}/lib'
218
219 WITH_BF_ZLIB = True
220 BF_ZLIB = '/usr'
221 BF_ZLIB_INC = '${BF_ZLIB}/include'
222 BF_ZLIB_LIB = 'z'
223
224 WITH_BF_INTERNATIONAL = True
225
226 WITH_BF_GAMEENGINE = True
227 WITH_BF_PLAYER = True
228 WITH_BF_OCEANSIM = True
229
230 WITH_BF_BULLET = True
231 BF_BULLET = '#extern/bullet2/src'
232 BF_BULLET_INC = '${BF_BULLET}'
233 BF_BULLET_LIB = 'extern_bullet'
234
235 WITH_BF_FFTW3 = True
236 BF_FFTW3 = LIBDIR + '/fftw3'
237 BF_FFTW3_INC = '${BF_FFTW3}/include'
238 BF_FFTW3_LIB = 'libfftw3'
239 BF_FFTW3_LIBPATH = '${BF_FFTW3}/lib'
240
241 BF_FREETYPE = LIBDIR + '/freetype'
242 BF_FREETYPE_INC = '${BF_FREETYPE}/include ${BF_FREETYPE}/include/freetype2'
243 BF_FREETYPE_LIB = 'freetype'
244 BF_FREETYPE_LIBPATH = '${BF_FREETYPE}/lib'
245
246 WITH_BF_QUICKTIME = True
247
248 WITH_BF_ICONV = True
249 BF_ICONV = '/usr'
250 BF_ICONV_INC = '${BF_ICONV}/include'
251 BF_ICONV_LIB = 'iconv'
252 #BF_ICONV_LIBPATH = '${BF_ICONV}/lib'
253
254 # Mesa Libs should go here if your using them as well....
255 WITH_BF_STATICOPENGL = True
256 BF_OPENGL_LIB = 'GL GLU'
257 BF_OPENGL_LIBPATH = '/System/Library/Frameworks/OpenGL.framework/Libraries'
258 BF_OPENGL_LINKFLAGS = ['-framework', 'OpenGL']
259
260 #OpenCollada flags
261 WITH_BF_COLLADA = True
262 BF_COLLADA = '#source/blender/collada'
263 BF_COLLADA_INC = '${BF_COLLADA}'
264 BF_COLLADA_LIB = 'bf_collada'
265 BF_OPENCOLLADA = LIBDIR + '/opencollada'
266 BF_OPENCOLLADA_INC = '${BF_OPENCOLLADA}/include'
267 BF_OPENCOLLADA_LIB = 'OpenCOLLADASaxFrameworkLoader OpenCOLLADAFramework OpenCOLLADABaseUtils OpenCOLLADAStreamWriter MathMLSolver GeneratedSaxParser UTF xml2 buffer ftoa'
268 BF_OPENCOLLADA_LIBPATH = LIBDIR + '/opencollada'
269 BF_PCRE = LIBDIR + '/opencollada'
270 BF_PCRE_LIB = 'pcre'
271 BF_PCRE_LIBPATH = '${BF_PCRE}/lib'
272 #BF_EXPAT = '/usr'
273 #BF_EXPAT_LIB = 'expat'
274 #BF_EXPAT_LIBPATH = '/usr/lib'
275
276 # Cycles
277 WITH_BF_CYCLES = True
278
279 #OSL
280
281 WITH_BF_CYCLES_OSL = True
282 BF_OSL = LIBDIR + '/osl'
283 BF_OSL_INC = '${BF_OSL}/include'
284 # note oslexec would passed via program linkflags, which is needed to
285 # make llvm happy with osl_allocate_closure_component
286 #BF_OSL_LIB = 'oslcomp oslquery'
287 BF_OSL_LIBPATH = '${BF_OSL}/lib'
288 BF_OSL_COMPILER = '${BF_OSL}/bin/oslc'
289
290 WITH_BF_LLVM = True
291 BF_LLVM = LIBDIR + '/llvm'
292 BF_LLVM_LIB = 'LLVMBitReader LLVMJIT LLVMipo LLVMVectorize LLVMBitWriter LLVMX86CodeGen LLVMX86Desc LLVMX86Info LLVMX86AsmPrinter ' + \
293     'LLVMX86Utils LLVMSelectionDAG LLVMCodeGen LLVMScalarOpts LLVMInstCombine LLVMTransformUtils LLVMipa LLVMAnalysis LLVMExecutionEngine ' + \
294     'LLVMTarget LLVMMC LLVMCore LLVMSupport'
295 BF_LLVM_LIBPATH = '${BF_LLVM}/lib'
296
297 WITH_BF_OIIO = True
298 BF_OIIO = LIBDIR + '/openimageio'
299 BF_OIIO_INC = '${BF_OIIO}/include'
300 BF_OIIO_LIB = 'OpenImageIO'
301 BF_OIIO_LIBPATH = '${BF_OIIO}/lib'
302
303 WITH_BF_OCIO = True
304 BF_OCIO = LIBDIR + '/opencolorio'
305 BF_OCIO_INC = '${BF_OCIO}/include'
306 BF_OCIO_LIB = 'OpenColorIO tinyxml yaml-cpp'
307 BF_OCIO_LIBPATH = '${BF_OCIO}/lib'
308
309 WITH_BF_BOOST = True
310 BF_BOOST = LIBDIR + '/boost'
311 BF_BOOST_INC = '${BF_BOOST}/include'
312 BF_BOOST_LIB = 'boost_date_time-mt boost_filesystem-mt boost_regex-mt boost_system-mt boost_thread-mt boost_wave-mt'
313 BF_BOOST_LIB_INTERNATIONAL = 'boost_locale-mt'
314 BF_BOOST_LIBPATH = '${BF_BOOST}/lib'
315
316 WITH_BF_CYCLES_CUDA_BINARIES = False
317 BF_CYCLES_CUDA_NVCC = '/usr/local/cuda/bin/nvcc'
318 BF_CYCLES_CUDA_BINARIES_ARCH = ['sm_13', 'sm_20', 'sm_21']
319
320 #Ray trace optimization
321 if MACOSX_ARCHITECTURE == 'x86_64' or MACOSX_ARCHITECTURE == 'i386':
322     WITH_BF_RAYOPTIMIZATION = True
323 else:
324     WITH_BF_RAYOPTIMIZATION = False
325 if MACOSX_ARCHITECTURE == 'i386':
326     BF_RAYOPTIMIZATION_SSE_FLAGS = ['-msse']
327 elif MACOSX_ARCHITECTURE == 'x86_64':
328     BF_RAYOPTIMIZATION_SSE_FLAGS = ['-msse','-msse2']
329
330 # SpaceNavigator and related 3D mice, driver must be 3DxWare 10 Beta 4 (Mac OS X) or later !
331 WITH_BF_3DMOUSE = True
332
333 #############################################################################
334 ###################  various compile settings and flags    ##################
335 #############################################################################
336
337 BF_QUIET = '1' # suppress verbose output
338
339 if MACOSX_ARCHITECTURE == 'x86_64' or MACOSX_ARCHITECTURE == 'ppc64':
340     ARCH_FLAGS = ['-m64']
341 else:
342     ARCH_FLAGS = ['-m32']
343
344 CFLAGS = []
345 CXXFLAGS = []
346 CCFLAGS = ['-pipe','-funsigned-char']
347
348 CPPFLAGS = list(ARCH_FLAGS)
349
350 if WITH_GHOST_COCOA:
351     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
352 else:
353     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
354
355 if WITH_BF_QUICKTIME:
356     if USE_QTKIT:
357         PLATFORM_LINKFLAGS = PLATFORM_LINKFLAGS+['-framework','QTKit']
358     else:
359         PLATFORM_LINKFLAGS = PLATFORM_LINKFLAGS+['-framework','QuickTime']
360
361 if not WITH_OSX_STATICPYTHON:
362     PLATFORM_LINKFLAGS = PLATFORM_LINKFLAGS+['-framework','Python']
363
364
365 #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
366 #for > 10.7.sdk, SystemStubs needs to be excluded (lib doesn't exist anymore)
367 if MACOSX_SDK.endswith("10.7.sdk") or MACOSX_SDK.endswith("10.8.sdk"):
368     LLIBS = ['stdc++']
369 else:
370     LLIBS = ['stdc++', 'SystemStubs']
371
372 # some flags shuffling for different OS versions
373 if MAC_MIN_VERS == '10.3':
374     CCFLAGS = ['-fuse-cxa-atexit'] + CCFLAGS
375     PLATFORM_LINKFLAGS = ['-fuse-cxa-atexit'] + PLATFORM_LINKFLAGS
376     LLIBS.append('crt3.o')
377
378 if USE_SDK:
379     SDK_FLAGS=['-isysroot', MACOSX_SDK,'-mmacosx-version-min='+MAC_MIN_VERS,'-arch',MACOSX_ARCHITECTURE]
380     PLATFORM_LINKFLAGS = ['-mmacosx-version-min='+MAC_MIN_VERS,'-Wl','-isysroot',MACOSX_SDK,'-arch',MACOSX_ARCHITECTURE]+PLATFORM_LINKFLAGS
381     CCFLAGS=SDK_FLAGS+CCFLAGS
382     CXXFLAGS=SDK_FLAGS+CXXFLAGS
383
384 #Intel Macs are CoreDuo and Up
385 if MACOSX_ARCHITECTURE == 'i386' or MACOSX_ARCHITECTURE == 'x86_64':
386     REL_CFLAGS = []
387     REL_CXXFLAGS = []
388     REL_CCFLAGS = ['-DNDEBUG', '-O2','-ftree-vectorize','-msse','-msse2','-msse3','-mfpmath=sse']
389 else:
390     CCFLAGS += ['-fno-strict-aliasing']
391     REL_CFLAGS = []
392     REL_CXXFLAGS = []
393     REL_CCFLAGS = ['-DNDEBUG', '-O2']
394
395 # Intel 64bit Macs are Core2Duo and up
396 if MACOSX_ARCHITECTURE == 'x86_64':
397     REL_CCFLAGS += ['-march=core2','-mssse3','-with-tune=core2','-enable-threads']
398
399 CC_WARN = ['-Wall']
400 C_WARN = ['-Wno-char-subscripts', '-Wpointer-arith', '-Wcast-align', '-Wdeclaration-after-statement', '-Wno-unknown-pragmas', '-Wstrict-prototypes']
401 CXX_WARN = ['-Wno-invalid-offsetof', '-Wno-sign-compare']
402
403 ##FIX_STUBS_WARNINGS = -Wno-unused
404
405 ##LOPTS = --dynamic
406 ##DYNLDFLAGS = -shared $(LDFLAGS)
407
408 BF_PROFILE_CCFLAGS = ['-pg', '-g ']
409 BF_PROFILE_LINKFLAGS = ['-pg']
410 BF_PROFILE = False
411
412 BF_DEBUG = False
413 BF_DEBUG_CCFLAGS = ['-g', '-D_DEBUG']
414
415 #############################################################################
416 ###################           Output directories           ##################
417 #############################################################################
418
419 BF_BUILDDIR='../build/darwin'
420 BF_INSTALLDIR='../install/darwin'