Final merge of HEAD (bf-blender) into the orange branch.
[blender.git] / SConstruct
1 #!/usr/bin/env python
2 import string
3 import os
4 import time
5 import sys
6 from distutils import sysconfig
7 from tools.scons.bs import *
8
9 bs_globals.arguments = ARGUMENTS
10 bs_globals.targets = COMMAND_LINE_TARGETS
11
12 print 'targets = ',bs_globals.targets
13 print 'arguments = ', bs_globals.arguments
14 print os.getcwd()
15
16 appname = ''
17 playername = ''
18 config_guess = ''
19
20 bs_config.checkPyVersion()
21
22 if sys.platform != 'win32':
23         #~ sys.stdout = os.popen("tee build.log", "w")
24         #~ sys.stderr = sys.stdout
25         # guess at the platform, used to maintain the tarball naming scheme
26         config_guess = os.popen("SRCHOME=source/ source/tools/guess/guessconfig").read()[:-1]
27 else:
28         config_guess = "windows"
29
30 #the above check is not enough for darwin. we way want to build for darwin/X11
31 #more, now even for Os X, we need to check and take in account arch 
32 #(PPC, x86, universal binaries) 
33 if sys.platform == 'darwin':
34         appname = 'blender'
35         playername = 'blenderplayer'
36 else:
37         appname = 'blender$PROGSUFFIX'
38         playername = 'blenderplayer$PROGSUFFIX'
39
40 # Build directory.
41 # root_build_dir = '..' + os.sep + 'build' + os.sep + sys.platform + os.sep
42
43 bs_config.parseOpts()
44
45 # Create the build directory. SCons does this automatically, but since we
46 # don't want to put scons-generated .sconsign files in the source tree, but in
47 # the root_build_dir, we have to create that dir ourselves before SCons tries
48 # to access/create the file containing .sconsign data.
49 # we need to create the top level hierarchy too (at least on Os X) 
50 if os.path.isdir (bs_globals.root_build_dir) == 0:
51         os.makedirs (bs_globals.root_build_dir)
52         os.makedirs (bs_globals.root_build_dir+os.sep+'extern')
53         os.makedirs (bs_globals.root_build_dir+os.sep+'intern')
54         os.makedirs (bs_globals.root_build_dir+os.sep+'source')
55
56 # Blender version.
57 version='2.40-alpha1'
58 shortversion = '240alpha1' # for wininst target -> nsis installer creation
59
60 sdl_env = Environment (ENV = os.environ)
61 freetype_env = Environment (ENV = os.environ)
62 env = Environment (ENV = os.environ)
63
64 if sys.platform == 'linux2' or sys.platform == 'linux-i386':
65         use_international = 'true'
66         use_gameengine = 'true'
67         use_openal = 'false'
68         use_fmod = 'false'
69         use_quicktime = 'false'
70         use_openexr = 'true'
71         use_sumo = 'true'
72         use_ode = 'false'
73         use_bullet = 'true'
74         use_buildinfo = 'true'
75         use_fluidsim = 'true'
76         build_blender_dynamic = 'true'
77         build_blender_static = 'false'
78         build_blender_player = 'false'
79         build_blender_plugin = 'false'
80         release_flags = ['-O2']
81         debug_flags = ['-O2', '-g']
82         extra_flags = ['-pipe', '-funsigned-char']
83         cxxflags = []
84         defines = []
85         warn_flags = ['-Wall', '-W']
86         window_system = 'X11'
87         platform_libs = ['m', 'util', 'stdc++']
88         platform_libpath = []
89         platform_linkflags = ['-pthread']
90         extra_includes = []
91         # z library information
92         z_lib = ['z']
93         z_libpath = ['/usr/lib']
94         z_include = ['/usr/include']
95         # png library information
96         png_lib = ['png']
97         png_libpath = ['/usr/lib']
98         png_include = ['/usr/include']
99         # OpenEXR library information
100         if use_openexr == 'true':
101                 defines += ['WITH_OPENEXR']
102         openexr_lib = ['Iex', 'Half', 'IlmImf', 'Imath']
103         openexr_libpath = ['/usr/lib']
104         openexr_include = ['/usr/include/OpenEXR']
105         # jpeg library information
106         jpeg_lib = ['jpeg']
107         jpeg_libpath = ['/usr/lib']
108         jpeg_include = ['/usr/include']
109         #tiff library information
110         tiff_lib = ['tiff']
111         tiff_libpath = ['/usr/lib']
112         tiff_include = ['/usr/include']
113         # OpenGL library information
114         opengl_lib = ['GL', 'GLU']
115         opengl_static = ['/usr/lib/libGL.a', '/usr/lib/libGLU.a']
116         opengl_libpath = ['/usr/lib', '/usr/X11R6/lib']
117         opengl_include = ['/usr/include', '/usr/X11R6/include']
118         # SDL library information
119         sdl_env.ParseConfig ('sdl-config --cflags --libs')
120         sdl_cflags = sdl_env.Dictionary()['CCFLAGS']
121         sdl_include = sdl_env.Dictionary()['CPPPATH']
122         sdl_libpath = sdl_env.Dictionary()['LIBPATH']
123         sdl_lib = sdl_env.Dictionary()['LIBS']
124         # SOLID library information
125         solid_lib = []
126         solid_libpath = []
127         solid_include = ['#extern/solid']
128         qhull_lib = []
129         qhull_libpath = []
130         qhull_include = ['#extern/qhull/include']
131         # Bullet library information
132         bullet_lib = []
133         bullet_libpath = []
134         bullet_include = ['#extern/bullet','#extern/bullet/LinearMath','#extern/bullet/Bullet','#extern/bullet/BulletDynamics']
135         # ODE library information
136         ode_lib = ['ode']
137         ode_libpath = ['#../lib/linux-glibc2.2.5-i386/ode/lib']
138         ode_include = ['#../lib/linux-glibc2.2.5-i386/ode/include']
139         # Python library information
140         python_lib = ['python%d.%d' % sys.version_info[0:2]]
141         python_libpath = [sysconfig.get_python_lib (0, 1) + '/config']
142         python_include = [sysconfig.get_python_inc ()]
143         python_linkflags = Split (sysconfig.get_config_var('LINKFORSHARED'))
144         # International support information
145         ftgl_lib = []
146         ftgl_libpath = []
147         ftgl_include = ['#extern/bFTGL/include']
148         freetype_env.ParseConfig ('pkg-config --cflags --libs freetype2 2>/dev/null || freetype-config --cflags --libs 2>/dev/null')
149         freetype_lib = freetype_env.Dictionary()['LIBS']
150         freetype_libpath = freetype_env.Dictionary()['LIBPATH']
151         freetype_include = freetype_env.Dictionary()['CPPPATH']
152         gettext_lib = []
153         gettext_libpath = []
154         gettext_include = []
155         # OpenAL library information
156         openal_lib = ['openal']
157         openal_libpath = ['/usr/lib']
158         openal_include = ['/usr/include']
159
160 elif sys.platform == 'darwin':
161         use_international = 'true'
162         use_gameengine = 'false'
163         use_openal = 'true'
164         use_fmod = 'false'
165         use_openal = 'false'
166         use_quicktime = 'true'
167         use_openexr = 'true'
168         use_precomp = 'true'
169         use_sumo = 'true'
170         use_ode = 'false'
171         use_bullet = 'true'
172         use_buildinfo = 'true'
173         use_fluidsim = 'true'
174         build_blender_dynamic = 'true'
175         build_blender_static = 'false'
176         build_blender_player = 'false'
177         build_blender_plugin = 'false'
178         # TODO: replace darwin-6.1-powerpc with the actual directiory on the
179         #       build machine
180         # darwin-6.1 is the name of cvs precomp folder
181         # a symbolic link named darwin-X.Y-powerpc must be manually done
182         #for now. X-Y is darwin kernel rev number
183         darwin_precomp = '#../lib/darwin-6.1-powerpc/'
184         fink_path = '/sw/'
185         # TODO : try -mpowerpc -mpowerpc-gopt -mpowerpc-gfxopt optims
186         #           doing actual profiling
187         extra_flags = ['-pipe', '-fPIC', '-funsigned-char', '-ffast-math', '-mpowerpc', '-mtune=G4']
188         
189         # , '-malign-natural'] malign is causing problems with jpeg lib but worth a 1-2% speedup
190         #'-force_cpusubtype_ALL', '-mpowerpc-gpopt', 
191         cxxflags = []
192         defines = ['_THREAD_SAFE' ]
193         if use_quicktime == 'true':
194                 defines += ['WITH_QUICKTIME']
195         warn_flags = ['-Wall']    # , '-W'
196         release_flags = ['-O2']
197         debug_flags = ['-g']
198         window_system = 'CARBON'
199         # z library information
200         z_lib = ['z']
201         z_libpath = []
202         z_include = []
203         # TODO : add a flag to allow each lib to be build from fink or precomp
204         #        without having to have to specify the path manually in config.opts.    
205         # png library information
206         png_lib = ['libpng']
207         png_libpath = [darwin_precomp + 'png/lib']
208         png_include = [darwin_precomp + 'png/include']
209         # OpenEXR library information
210         if use_openexr == 'true':
211                 defines += ['WITH_OPENEXR']
212         openexr_lib = ['Iex', 'Half', 'IlmImf', 'Imath']
213         openexr_libpath = ['/usr/local/lib']
214         openexr_include = ['/usr/local/include/OpenEXR']
215         # jpeg library information
216         jpeg_lib = ['libjpeg']
217         jpeg_libpath = [darwin_precomp + 'jpeg/lib']
218         jpeg_include = [darwin_precomp + 'jpeg/include']
219         # TIFF library information
220         tiff_lib = ['libtiff']
221         tiff_libpath = [darwin_precomp + 'tiff/lib']
222         tiff_include = [darwin_precomp + 'tiff/include']
223         # OpenGL library information
224         opengl_lib = ['GL', 'GLU']
225         opengl_static = []
226         opengl_libpath = []
227         opengl_include = []
228         # SDL specific stuff.
229         #sdl_env.ParseConfig ('sdl-config --cflags --libs')
230         # Want to use precompiled libraries?
231         if use_precomp == 'true':
232                 sdl_include = [darwin_precomp + 'sdl/include']
233                 sdl_libpath = [darwin_precomp + 'sdl/lib']
234                 sdl_lib = ['libSDL.a']
235                 sdl_cflags = [ '-I' + darwin_precomp + 'sdl/include' ]
236                 sdl_env.Append (CCFLAGS = sdl_cflags )
237                 sdl_env.Append (CPPPATH = [darwin_precomp + 'sdl/include'] )
238
239         platform_libs = ['stdc++'] 
240         extra_includes = ['/sw/include']
241         platform_libpath = ['/System/Library/Frameworks/OpenGL.framework/Libraries']
242         platform_linkflags = []
243         # SOLID library information
244         solid_lib = []                                          
245         solid_libpath = []                                          
246         solid_include = ['#/extern/solid']
247         qhull_lib = []                                          
248         qhull_libpath = []                                          
249         qhull_include = ['#/extern/qhull/include']
250         # Bullet library information
251         bullet_lib = []
252         bullet_libpath = []
253         bullet_include = ['#extern/bullet','#extern/bullet/LinearMath','#extern/bullet/Bullet','#extern/bullet/BulletDynamics']
254         # ODE library information
255         ode_lib = ['libode']                                             
256         ode_libpath = [darwin_precomp + 'ode/lib']                                          
257         ode_include = [darwin_precomp + 'ode/include/ode']
258         # Python variables.
259         # TODO : fill vars differently if we are on 10.2 or 10.3
260         # python_lib = ['python%d.%d' % sys.version_info[0:2]]
261         # python_libpath = [sysconfig.get_python_lib (0, 1) + '/config']
262         # python_include = [sysconfig.get_python_inc ()]
263         # python_linkflags = Split (sysconfig.get_config_var('LINKFORSHARED'))
264         python_lib = []
265         python_libpath = ['/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/config']
266         python_include = ['/System/Library/Frameworks/Python.framework/Versions/2.3/include/python2.3']
267         python_linkflags = ['-u', '__dummy', '-u', '_PyMac_Error', 
268                                                 '-framework', 'System',
269                                                 '-framework', 'Python',
270                                                 '-framework', 'CoreServices',
271                                                 '-framework', 'Foundation',
272                                                 '-framework', 'OpenGL',
273                                                 '-framework', 'IOKit' , 
274                                                 '-framework', 'AppKit']
275         # International stuff
276         ftgl_lib = ['libftgl']
277         ftgl_libpath = [darwin_precomp + 'ftgl/lib']
278         ftgl_include = ['#extern/bFTGL/include']
279         freetype_lib = ['libfreetype']
280         freetype_libpath = [darwin_precomp + 'freetype/lib']
281         freetype_include = [darwin_precomp + 'freetype/include']
282         gettext_lib = ['libintl']
283         gettext_libpath = [darwin_precomp + 'gettext/lib']
284         gettext_include = [darwin_precomp + 'gettext/include']
285         # OpenAL library information
286         openal_lib = ['libopenal']
287         openal_libpath = [darwin_precomp + 'openal/lib']
288         openal_include = [darwin_precomp + 'openal/include']
289
290 elif sys.platform == 'cygwin':
291         use_international = 'false'
292         use_gameengine = 'false'
293         use_openal = 'false'
294         use_fmod = 'false'
295         use_quicktime = 'false'
296         use_openexr = 'true'
297         use_sumo = 'false'
298         use_ode = 'false'
299         use_bullet = 'false'
300         use_buildinfo = 'false'
301         use_fluidsim = 'true'
302         build_blender_dynamic = 'true'
303         build_blender_static = 'false'
304         build_blender_player = 'false'
305         build_blender_plugin = 'false'
306         release_flags = ['-O2']
307         debug_flags = ['-O2', '-g']
308         extra_flags = ['-pipe', '-mno-cygwin', '-mwindows', '-funsigned-char']
309         cxxflags = []
310         defines = ['FREE_WINDOWS']
311         warn_flags = ['-Wall', '-Wno-char-subscripts']
312         platform_libs = ['png', 'jpeg', 'netapi32',
313                                          'opengl32', 'glu32', 'winmm',
314                                          'mingw32']
315         platform_libpath = ['/usr/lib/w32api', '/lib/w32api']
316         platform_linkflags = ['-mwindows', '-mno-cygwin', '-mconsole']
317         window_system = 'WIN32'
318         extra_includes = []
319         # z library information
320         z_lib = ['z']
321         z_libpath = ['#../lib/windows/zlib/lib']
322         z_include = ['#../lib/windows/zlib/include']
323         # png library information
324         png_lib = ['png']
325         png_libpath = ['#../lib/windows/png/lib']
326         png_include = ['#../lib/windows/png/include']
327         # OpenEXR library information
328         if use_openexr == 'true':
329                 defines += ['WITH_OPENEXR']
330         openexr_lib = ['Iex', 'Half', 'IlmImf', 'Imath']
331         openexr_libpath = ['/usr/lib']
332         openexr_include = ['/usr/include/OpenEXR']
333         # jpeg library information
334         jpeg_lib = ['jpeg']
335         jpeg_libpath = ['#../lib/windows/jpeg/lib']
336         jpeg_include = ['#../lib/windows/jpeg/include']
337         # OpenGL library information
338         opengl_lib = ['opengl32', 'glu32']
339         opengl_static = []
340         opengl_libpath = []
341         opengl_include = []
342         # SDL specific stuff.
343         sdl_include = ['#../lib/windows/sdl/include']
344         sdl_libpath = ['#../lib/windows/sdl/lib']
345         sdl_lib = ['SDL']
346         sdl_cflags = []
347         #sdl_cflags = '-DWIN32'
348         # SOLID library information
349         solid_lib = []
350         solid_libpath = []
351         solid_include = ['#extern/solid']
352         qhull_lib = []
353         qhull_libpath = []
354         qhull_include = ['#extern/qhull/include']
355         # Bullet library information
356         bullet_lib = []
357         bullet_libpath = []
358         bullet_include = ['#extern/bullet','#extern/bullet/LinearMath','#extern/bullet/Bullet','#extern/bullet/BulletDynamics']
359         # ODE library information
360         ode_lib = ['ode']
361         ode_libpath = ['#../lib/windows/gcc/ode/lib']
362         ode_include = ['#../lib/windows/gcc/ode/include']
363         # Python library information
364         python_include = ['#../lib/windows/python/include/python2.2']
365         python_libpath = ['#../lib/windows/python/lib']
366         python_lib = ['python22']
367         python_linkflags = []
368         # International stuff
369         ftgl_lib = []
370         ftgl_libpath = []
371         ftgl_include = ['#extern/bFTGL/include']
372         freetype_lib = ['freetype']
373         freetype_libpath = ['#../lib/windows/gcc/freetype/lib']
374         freetype_include = ['#../lib/windows/gcc/freetype/include']
375         gettext_lib = []
376         gettext_libpath = []
377         gettext_include = []
378         # OpenAL library information
379         openal_lib = []
380         openal_libpath = []
381         openal_include = []
382
383 elif sys.platform == 'win32':
384         use_international = 'true'
385         use_gameengine = 'true'
386         use_openal = 'true'
387         use_fmod = 'false'
388         use_quicktime = 'true'
389         use_openexr = 'true'
390         use_bullet = 'true'
391         use_sumo = 'true'
392         use_ode = 'false'
393         use_buildinfo = 'true'
394         use_fluidsim = 'true'
395         build_blender_dynamic = 'true'
396         build_blender_static = 'false'
397         build_blender_player = 'true'
398         build_blender_plugin = 'false'
399         release_flags = ['/Og', '/Ot', '/Ob1', '/Op', '/G6']
400         debug_flags = ['/Zi', '/Fr${TARGET.base}.sbr']
401         extra_flags = ['/EHsc', '/J', '/W3', '/Gd', '/MT']
402         cxxflags = []
403         defines = ['WIN32', '_CONSOLE']
404         if use_quicktime == 'true':
405                 defines += ['WITH_QUICKTIME']
406         defines += ['_LIB', 'USE_OPENAL']
407         defines += ['FTGL_LIBRARY_STATIC']
408         warn_flags = []
409         platform_libs = [ 'qtmlClient', 'soundsystem',
410                                          'ws2_32', 'dxguid', 'vfw32', 'winmm',
411                                          'iconv', 'kernel32', 'user32', 'gdi32',
412                                          'comdlg32', 'advapi32', 'shell32',
413                                          'ole32', 'oleaut32', 'uuid', 
414                                          'libcmt', 'libc']
415         platform_libpath = ['#../lib/windows/iconv/lib',
416                                                 '#../lib/windows/QTDevWin/Libraries']
417         platform_linkflags = [
418                                                 '/SUBSYSTEM:CONSOLE',
419                                                 '/MACHINE:IX86',
420                                                 '/ENTRY:mainCRTStartup',
421                                                 '/INCREMENTAL:NO',
422                                                 '/NODEFAULTLIB:"msvcprt.lib"',
423                                                 '/NODEFAULTLIB:"glut32.lib"',
424                                                 '/NODEFAULTLIB:"libcd.lib"',
425                                                 #'/NODEFAULTLIB:"libc.lib"',
426                                                 '/NODEFAULTLIB:"libcpd.lib"',
427                                                 '/NODEFAULTLIB:"libcp.lib"',
428                                                 '/NODEFAULTLIB:"libcmtd.lib"',
429                                                 ]
430         window_system = 'WIN32'
431         extra_includes = []
432         if use_quicktime == 'true':
433                 extra_includes += ['#../lib/windows/QTDevWin/CIncludes']
434         # z library information
435         z_lib = ['zlib']
436         z_libpath = ['#../lib/windows/zlib/lib']
437         z_include = ['#../lib/windows/zlib/include']
438         # png library information
439         png_lib = ['libpng_st']
440         png_libpath = ['#../lib/windows/png/lib']
441         png_include = ['#../lib/windows/png/include']
442         # OpenEXR library information
443         if use_openexr == 'true':
444                 defines += ['WITH_OPENEXR']
445         openexr_lib = ['Iex', 'Half', 'IlmImf', 'Imath']
446         openexr_libpath = ['/usr/lib']
447         openexr_include = ['/usr/include/OpenEXR']
448         # jpeg library information
449         jpeg_lib = ['libjpeg']
450         jpeg_libpath = ['#../lib/windows/jpeg/lib']
451         jpeg_include = ['#../lib/windows/jpeg/include']
452         # Tiff Library information
453         tiff_lib = ['libtiff']
454         tiff_libpath = ['#../lib/windows/tiff/lib']
455         tiff_include = ['#../lib/windows/tiff/include']
456         # OpenGL library information
457         opengl_lib = ['opengl32', 'glu32']
458         opengl_static = []
459         opengl_libpath = []
460         opengl_include = ['/usr/include']
461         # SDL library information
462         sdl_include = ['#../lib/windows/sdl/include']
463         sdl_libpath = ['#../lib/windows/sdl/lib']
464         sdl_lib = ['SDL']
465         sdl_cflags = []
466         window_system = 'WIN32'
467         # SOLID library information
468         solid_lib = ['extern/solid']
469         solid_libpath = ['#../lib/windows/solid/lib']
470         solid_include = ['#extern/solid']
471         qhull_lib = ['qhull']
472         qhull_libpath = ['#../lib/windows/qhull/lib']
473         qhull_include = ['#extern/qhull/include']
474         # Bullet library information
475         bullet_lib = []
476         bullet_libpath = []
477         bullet_include = ['#extern/bullet','#extern/bullet/LinearMath','#extern/bullet/Bullet','#extern/bullet/BulletDynamics']
478         # ODE library information
479         ode_lib = []                                                                                            # TODO
480         ode_libpath = ['#../lib/windows/ode/lib']
481         ode_include = ['#../lib/windows/ode/include']
482         # Python lib name
483         python_include = ['#../lib/windows/python/include/python2.4']
484         python_libpath = ['#../lib/windows/python/lib']
485         python_lib = ['python24']
486         python_linkflags = []
487         # International stuff
488         ftgl_lib = []
489         ftgl_libpath = []
490         ftgl_include = ['#extern/bFTGL/include']
491         freetype_lib = ['freetype2ST']
492         freetype_libpath = ['#../lib/windows/freetype/lib']
493         freetype_include = ['#../lib/windows/freetype/include']
494         gettext_lib = ['gnu_gettext']
495         gettext_libpath = ['#../lib/windows/gettext/lib']
496         gettext_include = ['#../lib/windows/gettext/include']
497         # OpenAL library information
498         openal_lib = ['openal_static']
499         openal_libpath = ['#../lib/windows/openal/lib']
500         openal_include = ['#../lib/windows/openal/include']
501
502 elif string.find (sys.platform, 'sunos') != -1:
503         use_international = 'true'
504         use_gameengine = 'false'
505         use_openal = 'false'
506         use_fmod = 'false'
507         use_quicktime = 'false'
508         use_openexr = 'false'
509         use_sumo = 'false'
510         use_ode = 'false'
511         use_bullet = 'false'
512         use_buildinfo = 'false'
513         use_fluidsim = 'true'
514         build_blender_dynamic = 'true'
515         build_blender_static = 'false'
516         build_blender_player = 'false'
517         build_blender_plugin = 'false'
518         release_flags = ['-O2']
519         debug_flags = ['-O2', '-g']
520         extra_flags = ['-pipe', '-fPIC', '-funsigned-char', '-DSUN_OGL_NO_VERTEX_MACROS']
521         cxxflags = []
522         defines = []
523         warn_flags = ['-Wall', '-W']
524         window_system = 'X11'
525         platform_libs = ['stdc++', 'dl', 'm']
526         platform_libpath = []
527         platform_linkflags = []
528         extra_includes = []
529         # z library information
530         z_lib = ['z']
531         z_libpath = []
532         z_include = []
533         # png library information
534         png_lib = ['png']
535         png_libpath = []
536         png_include = []
537         # OpenEXR library information
538         if use_openexr == 'true':
539                 defines += ['WITH_OPENEXR']
540         openexr_lib = ['Iex', 'Half', 'IlmImf', 'Imath']
541         openexr_libpath = ['/usr/lib']
542         openexr_include = ['/usr/include/OpenEXR']
543         # jpeg library information
544         jpeg_lib = ['jpeg']
545         jpeg_libpath = []
546         jpeg_include = []
547         # OpenGL library information
548         opengl_lib = ['GL', 'GLU', 'X11']
549         opengl_static = []
550         opengl_libpath = ['/usr/openwin/include']
551         opengl_include = ['/usr/openwin/lib']
552         # SDL library information
553         sdl_env.ParseConfig ('sdl-config --cflags --libs')
554         sdl_cflags = sdl_env.Dictionary()['CCFLAGS']
555         sdl_include = sdl_env.Dictionary()['CPPPATH']
556         sdl_libpath = sdl_env.Dictionary()['LIBPATH']
557         sdl_lib = sdl_env.Dictionary()['LIBS']
558         # SOLID library information
559         solid_lib = []
560         solid_libpath = []
561         solid_include = ['#extern/solid']
562         qhull_lib = []
563         qhull_libpath = []
564         qhull_include = ['#extern/qhull/include']
565         # ODE library information
566         ode_lib = []
567         ode_libpath = []
568         ode_include = ['#extern/ode/dist/include/ode']
569         # Bullet library information
570         bullet_lib = []
571         bullet_libpath = []
572         bullet_include = ['#extern/bullet','#extern/bullet/LinearMath','#extern/bullet/Bullet','#extern/bullet/BulletDynamics']
573         # Python variables.
574         python_lib = ['python%d.%d' % sys.version_info[0:2]]
575         python_libpath = [sysconfig.get_python_lib (0, 1) + '/config']
576         python_include = [sysconfig.get_python_inc ()]
577         python_linkflags = []
578         # International support information
579         ftgl_lib = []
580         ftgl_libpath = []
581         ftgl_include = ['#extern/bFTGL/include']
582         freetype_lib = ['freetype']
583         freetype_libpath = ['#../lib/solaris-2.8-sparc/freetype/lib']
584         freetype_include = ['#../lib/solaris-2.8-sparc/freetype/include']
585         gettext_lib = []
586         gettext_libpath = []
587         gettext_include = []
588         # OpenAL library information
589         openal_lib = []
590         openal_libpath = []
591         openal_include = []
592
593 elif string.find (sys.platform, 'irix') != -1:
594         use_international = 'false'
595         use_gameengine = 'false'
596         use_openal = 'false'
597         use_fmod = 'false'
598         use_quicktime = 'false'
599         use_openexr = 'false'
600         use_sumo = 'false'
601         use_ode = 'false'
602         use_bullet = 'false'
603         use_buildinfo = 'false'
604         use_fluidsim = 'true'
605         build_blender_dynamic = 'true'
606         build_blender_static = 'false'
607         build_blender_player = 'false'
608         build_blender_plugin = 'false'
609         irix_precomp = '#../lib/irix-6.5-mips'
610         extra_flags = ['-n32', '-mips3', '-Xcpluscomm']
611         cxxflags = ['-n32', '-mips3', '-Xcpluscomm', '-LANG:std']
612         cxxflags += ['-LANG:libc_in_namespace_std=off']
613         
614         window_system = 'X11'
615         release_flags = ['-O2', '-OPT:Olimit=0']
616         debug_flags = ['-O2', '-g']
617         defines = []
618         warn_flags = ['-fullwarn', '-woff', '1001,1110,1201,1209,1355,1424,1681,3201']
619         platform_libs = ['movieGL', 'Xmu', 'Xext', 'X11',
620                                          'c', 'm', 'dmedia', 'cl', 'audio',
621                                          'Cio', 'pthread']
622         platform_libpath = ['/usr/lib32/mips3',
623                                                 '/lib/freeware/lib32',
624                                                 '/usr/lib32']
625         platform_linkflags = ['-mips3', '-n32']
626         extra_includes = ['/usr/freeware/include',
627                                           '/usr/include']
628         # z library information
629         z_lib = ['z']
630         z_libpath = []
631         z_include = []
632         # png library information
633         png_lib = ['png']
634         png_libpath = [irix_precomp + '/png/lib']
635         png_include = [irix_precomp + '/png/include']
636         # OpenEXR library information
637         if use_openexr == 'true':
638                 defines += ['WITH_OPENEXR']
639         openexr_lib = ['Iex', 'Half', 'IlmImf', 'Imath']
640         openexr_libpath = ['/usr/lib']
641         openexr_include = ['/usr/include/OpenEXR']
642         # jpeg library information
643         jpeg_lib = ['jpeg']
644         jpeg_libpath = [irix_precomp + '/jpeg/lib']
645         jpeg_include = [irix_precomp + '/jpeg/include']
646         # OpenGL library information
647         opengl_lib = ['GL', 'GLU']
648         opengl_static = []
649         opengl_libpath = []
650         opengl_include = []
651         # SDL library information
652         sdl_cflags = []
653         sdl_include = [irix_precomp + '/sdl/include/SDL']
654         sdl_libpath = [irix_precomp + '/sdl/lib']
655         sdl_lib = ['SDL', 'libSDL.a']
656         # SOLID library information
657         solid_lib = []
658         solid_libpath = []
659         solid_include = [irix_precomp + '/solid/include']
660         qhull_lib = []
661         qhull_libpath = []
662         qhull_include = ['#extern/qhull/include']
663         # Bullet library information
664         bullet_lib = []
665         bullet_libpath = []
666         bullet_include = ['#extern/bullet','#extern/bullet/LinearMath','#extern/bullet/Bullet','#extern/bullet/BulletDynamics']
667         # ODE library information
668         ode_lib = []
669         ode_libpath = []
670         ode_include = [irix_precomp + '/ode/include']
671         # Python library information
672         python_libpath = [irix_precomp + '/python/lib/python2.2/config']
673         python_include = [irix_precomp + '/python/include/python2.2']
674         python_lib = ['python2.2']
675         python_linkflags = []
676         # International support information
677         ftgl_lib = []
678         ftgl_libpath = []
679         ftgl_include = ['#extern/bFTGL/include']
680         freetype_lib = ['freetype']
681         freetype_libpath = [irix_precomp + '/freetype/lib']
682         freetype_include = [irix_precomp + '/freetype/include']
683         gettext_lib = []
684         gettext_libpath = []
685         gettext_include = []
686         # OpenAL library information
687         openal_lib = []
688         openal_libpath = []
689         openal_include = []
690
691 elif string.find (sys.platform, 'hp-ux') != -1:
692         window_system = 'X11'
693         defines = []
694
695 elif sys.platform=='openbsd3':
696         print "Building for OpenBSD 3.x"
697         use_international = 'false'
698         use_gameengine = 'false'
699         use_openal = 'false'
700         use_fmod = 'false'
701         use_quicktime = 'false'
702         use_openexr = 'false'
703         use_sumo = 'false'
704         use_ode = 'false'
705         use_bullet = 'false'
706         use_buildinfo = 'true'
707         use_fluidsim = 'true'
708         build_blender_dynamic = 'true'
709         build_blender_static = 'false'
710         build_blender_player = 'false'
711         build_blender_plugin = 'false'
712         release_flags = ['-O2']
713         debug_flags = ['-O2', '-g']
714         extra_flags = ['-pipe', '-fPIC', '-funsigned-char']
715         cxxflags = []
716         defines = []
717         warn_flags = ['-Wall','-W']
718         window_system = 'X11'
719         platform_libs = ['m', 'stdc++', 'pthread', 'util']
720         platform_libpath = []
721         platform_linkflags = []
722         extra_includes = []
723         z_lib = ['z']
724         z_libpath = ['/usr/lib']
725         z_include = ['/usr/include']
726         # png library information
727         png_lib = ['png']
728         png_libpath = ['/usr/local/lib']
729         png_include = ['/usr/local/include/libpng']
730         # OpenEXR library information
731         if use_openexr == 'true':
732                 defines += ['WITH_OPENEXR']
733         openexr_lib = ['Iex', 'Half', 'IlmImf', 'Imath']
734         openexr_libpath = ['/usr/lib']
735         openexr_include = ['/usr/include/OpenEXR']
736         # jpeg library information
737         jpeg_lib = ['jpeg']
738         jpeg_libpath = ['/usr/local/lib']
739         jpeg_include = ['/usr/local/include']
740         # OpenGL library information
741         opengl_lib = ['GL', 'GLU']
742         opengl_static = ['/usr/lib/libGL.a', '/usr/lib/libGLU.a']
743         opengl_libpath = ['/usr/lib', '/usr/X11R6/lib']
744         opengl_include = ['/usr/X11R6/include/']
745         # SDL library information
746         sdl_env.ParseConfig ('sdl-config --cflags --libs')
747         sdl_cflags = sdl_env.Dictionary()['CCFLAGS']
748         sdl_include = sdl_env.Dictionary()['CPPPATH']
749         sdl_libpath = sdl_env.Dictionary()['LIBPATH']
750         sdl_lib = sdl_env.Dictionary()['LIBS']
751         # SOLID library information
752         solid_lib = []
753         solid_libpath = []
754         solid_include = ['#extern/solid']
755         qhull_lib = []
756         qhull_libpath = []
757         qhull_include = ['#extern/qhull/include']
758         # Bullet library information
759         bullet_lib = []
760         bullet_libpath = []
761         bullet_include = ['#extern/bullet','#extern/bullet/LinearMath','#extern/bullet/Bullet','#extern/bullet/BulletDynamics']
762         # ODE library information
763         ode_lib = ['ode']
764         ode_libpath = ['#../lib/linux-glibc2.2.5-i386/ode/lib']
765         ode_include = ['#../lib/linux-glibc2.2.5-i386/ode/include']
766         # Python library information
767         python_lib = ['python%d.%d' % sys.version_info[0:2]]
768         python_libpath = [sysconfig.get_python_lib (0, 1) + '/config']
769         python_include = [sysconfig.get_python_inc ()]
770         python_linkflags = []
771         # International support information
772         ftgl_lib = []
773         ftgl_libpath = []
774         ftgl_include = ['#extern/bFTGL/include']
775         freetype_env.ParseConfig('pkg-config --cflags --libs freetype2')
776         freetype_lib = freetype_env.Dictionary()['LIBS']
777         freetype_libpath = freetype_env.Dictionary()['LIBPATH']
778         freetype_include = freetype_env.Dictionary()['CPPPATH']
779         gettext_lib = []
780         gettext_libpath = []
781         gettext_include = []
782         # OpenAL library information
783         openal_lib = ['openal']
784         openal_libpath = ['/usr/lib']
785         openal_include = ['/usr/include']
786         
787 elif sys.platform=='freebsd4' or sys.platform=='freebsd5':
788         print "Building for FreeBSD"
789         use_international = 'false'
790         use_gameengine = 'false'
791         use_openal = 'false'
792         use_fmod = 'false'
793         use_quicktime = 'false'
794         use_openexr = 'false'
795         use_sumo = 'false'
796         use_ode = 'false'
797         use_bullet = 'false'
798         use_buildinfo = 'true'
799         use_fluidsim = 'true'
800         build_blender_dynamic = 'true'
801         build_blender_static = 'false'
802         build_blender_player = 'false'
803         build_blender_plugin = 'false'
804         release_flags = ['-O2']
805         debug_flags = ['-O2', '-g']
806         extra_flags = ['-pipe', '-fPIC', '-funsigned-char']
807         cxxflags = []
808         defines = []
809         warn_flags = ['-Wall','-W']
810         window_system = 'X11'
811         platform_libs = ['m', 'stdc++', 'util']
812         platform_libpath = []
813         platform_linkflags = ['-pthread']
814         extra_includes = []
815         z_lib = ['z']
816         z_libpath = ['/usr/lib']
817         z_include = ['/usr/include']
818         # png library information
819         png_lib = ['png']
820         png_libpath = ['/usr/local/lib']
821         png_include = ['/usr/local/include']
822         # OpenEXR library information
823         if use_openexr == 'true':
824                 defines += ['WITH_OPENEXR']
825         openexr_lib = ['Iex', 'Half', 'IlmImf', 'Imath']
826         openexr_libpath = ['/usr/lib']
827         openexr_include = ['/usr/include/OpenEXR']
828         # jpeg library information
829         jpeg_lib = ['jpeg']
830         jpeg_libpath = ['/usr/local/lib']
831         jpeg_include = ['/usr/local/include']
832         # OpenGL library information
833         opengl_lib = ['GL', 'GLU']
834         opengl_static = ['/usr/lib/libGL.a', '/usr/lib/libGLU.a']
835         opengl_libpath = ['/usr/lib', '/usr/X11R6/lib']
836         opengl_include = ['/usr/X11R6/include/']
837         # SDL library information
838         sdl_env.ParseConfig ('sdl11-config --cflags --libs')
839         sdl_cflags = sdl_env.Dictionary()['CCFLAGS']
840         sdl_include = sdl_env.Dictionary()['CPPPATH']
841         sdl_libpath = ['/usr/local/include/SDL11']
842         sdl_lib = sdl_env.Dictionary()['LIBS']
843         # SOLID library information
844         solid_lib = []
845         solid_libpath = []
846         solid_include = ['#extern/solid']
847         qhull_lib = []
848         qhull_libpath = []
849         qhull_include = ['#extern/qhull/include']
850         # Bullet library information
851         bullet_lib = []
852         bullet_libpath = []
853         bullet_include = ['#extern/bullet','#extern/bullet/LinearMath','#extern/bullet/Bullet','#extern/bullet/BulletDynamics']
854         # ODE library information
855         ode_lib = ['ode']
856         ode_libpath = ['#../lib/linux-glibc2.2.5-i386/ode/lib']
857         ode_include = ['#../lib/linux-glibc2.2.5-i386/ode/include']
858         # Python library information
859         python_lib = ['python%d.%d' % sys.version_info[0:2]]
860         python_libpath = [sysconfig.get_python_lib (0, 1) + '/config']
861         python_include = [sysconfig.get_python_inc ()]
862         python_linkflags = []
863         # International support information
864         ftgl_lib = []
865         ftgl_libpath = []
866         ftgl_include = ['#extern/bFTGL/include']
867         freetype_env.ParseConfig('pkg-config --cflags --libs freetype2')
868         freetype_lib = freetype_env.Dictionary()['LIBS']
869         freetype_libpath = freetype_env.Dictionary()['LIBPATH']
870         freetype_include = freetype_env.Dictionary()['CPPPATH']
871         gettext_lib = []
872         gettext_libpath = []
873         gettext_include = []
874         # OpenAL library information
875         openal_lib = ['openal']
876         openal_libpath = ['/usr/lib']
877         openal_include = ['/usr/include']
878
879 else:
880         print "Unknown platform %s"%sys.platform
881         exit
882
883 #-----------------------------------------------------------------------------
884 # End of platform specific section
885 #-----------------------------------------------------------------------------
886
887 #-----------------------------------------------------------------------------
888 # User configurable options to be saved in a config file.
889 #-----------------------------------------------------------------------------
890 # Checking for an existing config file - use that one if it exists,
891 # otherwise create one.
892 my_defines = []
893 my_ccflags = []
894 my_cxxflags = []
895 my_ldflags = []
896 if os.path.exists (bs_globals.config_file):
897         print "Using config file: " + bs_globals.config_file
898 else:
899         print "Creating new config file: " + bs_globals.config_file
900         env_dict = env.Dictionary()
901         config=open (bs_globals.config_file, 'w')
902         config.write ("# Configuration file containing user definable options.\n")
903         config.write ("VERSION = %r\n"%(version))
904         config.write ("BUILD_BINARY = 'release'\n")
905         config.write ("USE_BUILDINFO = %r\n"%(use_buildinfo))
906         config.write ("BUILD_BLENDER_DYNAMIC = %r\n"%(build_blender_dynamic))
907         config.write ("BUILD_BLENDER_STATIC = %r\n"%(build_blender_static))
908         config.write ("BUILD_BLENDER_PLAYER = %r\n"%(build_blender_player))
909         config.write ("BUILD_BLENDER_PLUGIN = %r\n"%(build_blender_plugin))
910         config.write ("BUILD_DIR = %r\n"%(bs_globals.root_build_dir))
911         
912         config.write ("\n# Extra compiler flags can be defined here.\n")
913         config.write ("DEFINES = %s\n"%(my_defines))
914         config.write ("CCFLAGS = %s\n"%(my_ccflags))
915         config.write ("CXXFLAGS = %s\n"%(my_cxxflags))
916         config.write ("LDFLAGS = %s\n"%(my_ldflags))
917
918         config.write ("USE_INTERNATIONAL = %r\n"%(use_international))
919         config.write ("BUILD_GAMEENGINE = %r\n"%(use_gameengine))
920         if use_ode == 'true':
921                 config.write ("USE_PHYSICS = 'ode'\n")
922         elif (use_bullet == 'true') and (use_sumo == 'false'):
923                 config.write("USE_PHYSICS = 'bullet'\n")
924         else:
925                 config.write ("USE_PHYSICS = 'solid'\n")
926         config.write ("USE_OPENAL = %r\n"%(use_openal))
927         config.write ("USE_FMOD = %r\n"%(use_fmod))
928         config.write ("USE_QUICKTIME = %r\n"%(use_quicktime))
929         config.write ("USE_OPENEXR = %r\n"%(use_openexr))
930         config.write ("USE_FLUIDSIM = %r\n"%(use_fluidsim))
931         config.write ("\n# Compiler information.\n")
932         config.write ("HOST_CC = %r\n"%(env_dict['CC']))
933         config.write ("HOST_CXX = %r\n"%(env_dict['CXX']))
934         config.write ("TARGET_CC = %r\n"%(env_dict['CC']))
935         config.write ("TARGET_CXX = %r\n"%(env_dict['CXX']))
936         config.write ("TARGET_AR = %r\n"%(env_dict['AR']))
937         config.write ("PATH = %r\n"%(os.environ['PATH']))
938         config.write ("\n# External library information.\n")
939         config.write ("PLATFORM_LIBS = %r\n"%(platform_libs))
940         config.write ("PLATFORM_LIBPATH = %r\n"%(platform_libpath))
941         config.write ("PLATFORM_LINKFLAGS = %r\n"%(platform_linkflags))
942         config.write ("PYTHON_INCLUDE = %r\n"%(python_include))
943         config.write ("PYTHON_LIBPATH = %r\n"%(python_libpath))
944         config.write ("PYTHON_LIBRARY = %r\n"%(python_lib))
945         config.write ("PYTHON_LINKFLAGS = %r\n"%(python_linkflags))
946         config.write ("SDL_CFLAGS = %r\n"%(sdl_cflags))
947         config.write ("SDL_INCLUDE = %r\n"%(sdl_include))
948         config.write ("SDL_LIBPATH = %r\n"%(sdl_libpath))
949         config.write ("SDL_LIBRARY = %r\n"%(sdl_lib))
950         config.write ("Z_INCLUDE = %r\n"%(z_include))
951         config.write ("Z_LIBPATH = %r\n"%(z_libpath))
952         config.write ("Z_LIBRARY = %r\n"%(z_lib))
953         config.write ("PNG_INCLUDE = %r\n"%(png_include))
954         config.write ("PNG_LIBPATH = %r\n"%(png_libpath))
955         config.write ("PNG_LIBRARY = %r\n"%(png_lib))
956         config.write ("OPENEXR_INCLUDE = %r\n"%(openexr_include))
957         config.write ("OPENEXR_LIBPATH = %r\n"%(openexr_libpath))
958         config.write ("OPENEXR_LIBRARY = %r\n"%(openexr_lib))
959         config.write ("JPEG_INCLUDE = %r\n"%(jpeg_include))
960         config.write ("JPEG_LIBPATH = %r\n"%(jpeg_libpath))
961         config.write ("JPEG_LIBRARY = %r\n"%(jpeg_lib))
962         config.write ("TIFF_INCLUDE = %r\n"%(tiff_include))
963         config.write ("TIFF_LIBPATH = %r\n"%(tiff_libpath))
964         config.write ("TIFF_LIBRARY = %r\n"%(tiff_lib))
965         config.write ("OPENGL_INCLUDE = %r\n"%(opengl_include))
966         config.write ("OPENGL_LIBPATH = %r\n"%(opengl_libpath))
967         config.write ("OPENGL_LIBRARY = %r\n"%(opengl_lib))
968         config.write ("OPENGL_STATIC = %r\n"%(opengl_static))
969         config.write ("\n# The following information is only necessary when you've enabled support for\n")
970         config.write ("# the game engine.\n")
971         config.write ("SOLID_INCLUDE = %r\n"%(solid_include))
972         config.write ("SOLID_LIBPATH = %r\n"%(solid_libpath))
973         config.write ("SOLID_LIBRARY = %r\n"%(solid_lib))
974         config.write ("QHULL_INCLUDE = %r\n"%(qhull_include))
975         config.write ("QHULL_LIBPATH = %r\n"%(qhull_libpath))
976         config.write ("QHULL_LIBRARY = %r\n"%(qhull_lib))
977         config.write ("ODE_INCLUDE = %r\n"%(ode_include))
978         config.write ("ODE_LIBPATH = %r\n"%(ode_libpath))
979         config.write ("ODE_LIBRARY = %r\n"%(ode_lib))
980         config.write ("BULLET_INCLUDE = %r\n"%(bullet_include))
981         config.write ("BULLET_LIBPATH = %r\n"%(bullet_libpath))
982         config.write ("BULLET_LIBRARY = %r\n"%(bullet_lib))
983         config.write ("OPENAL_INCLUDE = %r\n"%(openal_include))
984         config.write ("OPENAL_LIBPATH = %r\n"%(openal_libpath))
985         config.write ("OPENAL_LIBRARY = %r\n"%(openal_lib))
986         config.write ("\n# The following information is only necessary when building with\n")
987         config.write ("# internationalization support.\n");
988         config.write ("FTGL_INCLUDE = %r\n"%(ftgl_include))
989         config.write ("FTGL_LIBPATH = %r\n"%(ftgl_libpath))
990         config.write ("FTGL_LIBRARY = %r\n"%(ftgl_lib))
991         config.write ("FREETYPE_INCLUDE = %r\n"%(freetype_include))
992         config.write ("FREETYPE_LIBPATH = %r\n"%(freetype_libpath))
993         config.write ("FREETYPE_LIBRARY = %r\n"%(freetype_lib))
994         config.write ("GETTEXT_INCLUDE = %r\n"%(gettext_include))
995         config.write ("GETTEXT_LIBPATH = %r\n"%(gettext_libpath))
996         config.write ("GETTEXT_LIBRARY = %r\n"%(gettext_lib))
997         config.close ()
998
999 #-----------------------------------------------------------------------------
1000 # Read the options from the config file and update the various necessary flags
1001 #-----------------------------------------------------------------------------
1002 list_opts = []
1003 user_options = Options (bs_globals.config_file)
1004 user_options_env = Environment (ENV = os.environ, options = user_options)
1005 user_options.AddOptions (
1006                 ('VERSION', 'Blender version', version),
1007                 (EnumOption ('BUILD_BINARY', 'release',
1008                                         'Select a release or debug binary.',
1009                                          allowed_values = ('release', 'debug'))),
1010                 (BoolOption ('USE_BUILDINFO',
1011                                         'Set to 1 if you want to add build information.',
1012                                         'false')),
1013                 (BoolOption ('BUILD_BLENDER_DYNAMIC',
1014                                         'Set to 1 if you want to build blender with hardware accellerated OpenGL support.',
1015                                         'true')),
1016                 (BoolOption ('BUILD_BLENDER_STATIC',
1017                                         'Set to 1 if you want to build blender with software OpenGL support.',
1018                                         'false')),
1019                 (BoolOption ('BUILD_BLENDER_PLAYER',
1020                                         'Set to 1 if you want to build the blender player.',
1021                                         'false')),
1022                 (BoolOption ('BUILD_BLENDER_PLUGIN',
1023                                         'Set to 1 if you want to build the blender plugin.',
1024                                         'false')),
1025                 ('BUILD_DIR', 'Target directory for intermediate files.',
1026                                         bs_globals.root_build_dir),
1027                 (BoolOption ('USE_INTERNATIONAL',
1028                                         'Set to 1 to have international support.',
1029                                         'false')),
1030                 (EnumOption ('USE_PHYSICS', 'solid',
1031                                         'Select which physics engine to use.',
1032                                         allowed_values = ('ode', 'solid', 'bullet'))),
1033                 (BoolOption ('BUILD_GAMEENGINE',
1034                                         'Set to 1 to build blender with game engine support.',
1035                                         'false')),
1036                 (BoolOption ('USE_OPENAL',
1037                                         'Set to 1 to build the game engine with OpenAL support.',
1038                                         'false')),
1039                 (BoolOption ('USE_FMOD',
1040                                         'Set to 1 to build the game engine with FMod support.',
1041                                         'false')),
1042                 (BoolOption ('USE_QUICKTIME',
1043                                         'Set to 1 to add support for QuickTime.',
1044                                         'false')),
1045                 (BoolOption ('USE_OPENEXR',
1046                                         'Set to 1 to add support for OpenEXR.',
1047                                         'false')),
1048                 (BoolOption ('USE_FLUIDSIM', # NT test new
1049                                         'Set to 0 to disable compilation of fluid simulation library El\'Beem.',
1050                                         'true')),
1051                 ('HOST_CC', 'C compiler for the host platfor. This is the same as target platform when not cross compiling.'),
1052                 ('HOST_CXX', 'C++ compiler for the host platform. This is the same as target platform when not cross compiling.'),
1053                 ('TARGET_CC', 'C compiler for the target platform.'),
1054                 ('TARGET_CXX', 'C++ compiler for the target platform.'),
1055                 ('TARGET_AR', 'Linker command for linking libraries.'),
1056                 ('PATH', 'Standard search path'),
1057                 ('PLATFORM_LIBS', 'Platform specific libraries.'),
1058                 ('PLATFORM_LIBPATH', 'Platform specific library link path.'),
1059                 ('PLATFORM_LINKFLAGS', 'Platform specific linkflags'),
1060                 ('PYTHON_INCLUDE', 'Include directory for Python header files.'),
1061                 ('PYTHON_LIBPATH', 'Library path where the Python lib is located.'),
1062                 ('PYTHON_LIBRARY', 'Python library name.'),
1063                 ('PYTHON_LINKFLAGS', 'Python specific linkflags.'),
1064                 ('SDL_CFLAGS', 'Necessary CFLAGS when using sdl functionality.'),
1065                 ('SDL_INCLUDE', 'Include directory for SDL header files.'),
1066                 ('SDL_LIBPATH', 'Library path where the SDL library is located.'),
1067                 ('SDL_LIBRARY', 'SDL library name.'),
1068                 ('Z_INCLUDE', 'Include directory for zlib header files.'),
1069                 ('Z_LIBPATH', 'Library path where the zlib library is located.'),
1070                 ('Z_LIBRARY', 'Z library name.'),
1071                 ('PNG_INCLUDE', 'Include directory for png header files.'),
1072                 ('PNG_LIBPATH', 'Library path where the png library is located.'),
1073                 ('PNG_LIBRARY', 'png library name.'),
1074                 ('OPENEXR_INCLUDE', 'Include directory for OpenEXR header files.'),
1075                 ('OPENEXR_LIBPATH', 'Library path where the OpenEXR libraries are located.'),
1076                 ('OPENEXR_LIBRARY', 'OpenEXR library names.'),
1077                 ('JPEG_INCLUDE', 'Include directory for jpeg header files.'),
1078                 ('JPEG_LIBPATH', 'Library path where the jpeg library is located.'),
1079                 ('JPEG_LIBRARY', 'jpeg library name.'),
1080                 ('TIFF_INCLUDE', 'Include directory for TIFF header files.'),
1081                 ('TIFF_LIBPATH', 'Library path where the TIFF library is located.'),
1082                 ('TIFF_LIBRARY', 'TIFF library name.'),
1083                 ('OPENGL_INCLUDE', 'Include directory for OpenGL header files.'),
1084                 ('OPENGL_LIBPATH', 'Library path where the OpenGL libraries are located.'),
1085                 ('OPENGL_LIBRARY', 'OpenGL library names.'),
1086                 ('OPENGL_STATIC', 'Linker flags for static linking of Open GL.'),
1087                 ('SOLID_INCLUDE', 'Include directory for SOLID header files.'),
1088                 ('SOLID_LIBPATH', 'Library path where the SOLID library is located.'),
1089                 ('SOLID_LIBRARY', 'SOLID library name.'),
1090                 ('QHULL_INCLUDE', 'Include directory for QHULL header files.'),
1091                 ('QHULL_LIBPATH', 'Library path where the QHULL library is located.'),
1092                 ('QHULL_LIBRARY', 'QHULL library name.'),
1093                 ('ODE_INCLUDE', 'Include directory for ODE header files.'),
1094                 ('ODE_LIBPATH', 'Library path where the ODE library is located.'),
1095                 ('ODE_LIBRARY', 'ODE library name.'),
1096                 ('BULLET_INCLUDE', 'Include directory for BULLET header files.'),
1097                 ('BULLET_LIBPATH', 'Library path where the BULLET library is located.'),
1098                 ('BULLET_LIBRARY', 'BULLET library name'),
1099                 ('OPENAL_INCLUDE', 'Include directory for OpenAL header files.'),
1100                 ('OPENAL_LIBPATH', 'Library path where the OpenAL library is located.'),
1101                 ('OPENAL_LIBRARY', 'OpenAL library name.'),
1102                 ('FTGL_INCLUDE', 'Include directory for ftgl header files.'),
1103                 ('FTGL_LIBPATH', 'Library path where the ftgl library is located.'),
1104                 ('FTGL_LIBRARY', 'ftgl library name.'),
1105                 ('FREETYPE_INCLUDE', 'Include directory for freetype2 header files.'),
1106                 ('FREETYPE_LIBPATH', 'Library path where the freetype2 library is located.'),
1107                 ('FREETYPE_LIBRARY', 'Freetype2 library name.'),
1108                 ('GETTEXT_INCLUDE', 'Include directory for gettext header files.'),
1109                 ('GETTEXT_LIBPATH', 'Library path where the gettext library is located.'),
1110                 ('GETTEXT_LIBRARY', 'gettext library name.'),
1111                 ('DEFINES', 'Extra Preprocessor defines.'),
1112                 ('CCFLAGS', 'Extra C Compiler flags.'),
1113                 ('CXXFLAGS','Extra C++ Compiler flags.'),
1114                 ('LDFLAGS', 'Extra Linker flags.')
1115         )
1116 user_options.Update (user_options_env)
1117 user_options_dict = user_options_env.Dictionary()
1118 Help(user_options.GenerateHelpText(user_options_env))
1119 bs_globals.root_build_dir = user_options_dict['BUILD_DIR']
1120 # SET MODULE VARS #
1121 init_env = Environment(ENV = os.environ)
1122
1123 bs_globals.user_options_dict = user_options_dict
1124 bs_globals.init_env = init_env
1125 bs_globals.version = version
1126 bs_globals.shortversion = shortversion
1127 bs_globals.appname = appname
1128 bs_globals.playername = playername
1129 bs_globals.config_guess = config_guess
1130 # END SET MODULE VARS #
1131
1132 if user_options_dict['BUILD_GAMEENGINE'] == 1:
1133         defines += ['GAMEBLENDER=1']
1134         defines += ['USE_BULLET']
1135         if user_options_dict['USE_PHYSICS'] == 'ode':
1136                 defines += ['USE_ODE']
1137         else:
1138                 defines += ['USE_SUMO_SOLID']
1139 else:
1140         defines += ['GAMEBLENDER=0']
1141
1142 if user_options_dict['BUILD_BINARY'] == 'release':
1143         cflags = extra_flags + release_flags + warn_flags
1144         defines += ['NDEBUG']
1145 else:
1146         cflags = extra_flags + debug_flags + warn_flags
1147         if sys.platform == 'win32':
1148                 platform_linkflags = ['/DEBUG','/PDB:blender.pdb'] + platform_linkflags
1149
1150 defines += user_options_dict['DEFINES']
1151 cflags += user_options_dict['CCFLAGS']
1152 cxxflags += user_options_dict['CXXFLAGS']
1153 platform_linkflags += user_options_dict['LDFLAGS'] 
1154
1155 user_options_dict['PLATFORM_LINKFLAGS'] = platform_linkflags
1156
1157 if user_options_dict['USE_FLUIDSIM'] == 0: # NT test new
1158         use_fluidsim='false';
1159
1160 #-----------------------------------------------------------------------------
1161 # Generic library generation environment. This one is the basis for each
1162 # library.
1163 #-----------------------------------------------------------------------------
1164 library_env = env.Copy ()
1165 library_env.Replace (CC = user_options_dict['TARGET_CC'])
1166 library_env.Replace (CXX = user_options_dict['TARGET_CXX'])
1167 library_env.Replace (PATH = user_options_dict['PATH'])
1168 library_env.Replace (AR = user_options_dict['TARGET_AR'])
1169 library_env.Append (CCFLAGS = cflags)
1170 library_env.Append (CXXFLAGS = cxxflags)
1171 library_env.Append (CPPDEFINES = defines)
1172 library_env.SConsignFile (bs_globals.root_build_dir+'scons-signatures')
1173
1174 #-----------------------------------------------------------------------------
1175 # Settings to be exported to other SConscript files
1176 #-----------------------------------------------------------------------------
1177
1178 if bs_globals.enable_clean==0: # only read SConscripts when not cleaning, this to cut overhead
1179         Export ('cflags')
1180         Export ('defines')
1181         Export ('window_system')
1182         Export ('extra_includes')
1183         Export ('user_options_dict')
1184         Export ('library_env')
1185         Export ('sdl_env')
1186         Export ('use_fluidsim') # NT test
1187         
1188         BuildDir (bs_globals.root_build_dir+'/extern', 'extern', duplicate=0)
1189         SConscript (bs_globals.root_build_dir+'extern/SConscript')
1190         BuildDir (bs_globals.root_build_dir+'/intern', 'intern', duplicate=0)
1191         SConscript (bs_globals.root_build_dir+'intern/SConscript')
1192         BuildDir (bs_globals.root_build_dir+'/source', 'source', duplicate=0)
1193         SConscript (bs_globals.root_build_dir+'source/SConscript')
1194         
1195         libpath = (['#'+bs_globals.root_build_dir+'/lib'])
1196         
1197         link_env = library_env.Copy ()
1198         link_env.Append (LIBPATH=libpath)
1199
1200 def buildinfo(env, build_type):
1201         """
1202         Generate a buildinfo object
1203         """
1204         build_date = time.strftime ("%Y-%m-%d")
1205         build_time = time.strftime ("%H:%M:%S")
1206         obj = []
1207         if user_options_dict['USE_BUILDINFO'] == 1:
1208                 if sys.platform=='win32':
1209                         build_info_file = open("source/creator/winbuildinfo.h", 'w')
1210                         build_info_file.write("char *build_date=\"%s\";\n"%build_date)
1211                         build_info_file.write("char *build_time=\"%s\";\n"%build_time)
1212                         build_info_file.write("char *build_platform=\"win32\";\n")
1213                         build_info_file.write("char *build_type=\"dynamic\";\n")
1214                         build_info_file.close()
1215                         env.Append (CPPDEFINES = ['NAN_BUILDINFO', 'BUILD_DATE'])
1216                 else:
1217                         env.Append (CPPDEFINES = ['BUILD_TIME=\'"%s"\''%(build_time),
1218                                                         'BUILD_DATE=\'"%s"\''%(build_date),
1219                                                         'BUILD_TYPE=\'"dynamic"\'',
1220                                                         'NAN_BUILDINFO',
1221                                                         'BUILD_PLATFORM=\'"%s"\''%(sys.platform)])
1222                 obj = [env.Object (bs_globals.root_build_dir+'source/creator/%s_buildinfo'%build_type,
1223                                                 [bs_globals.root_build_dir+'source/creator/buildinfo.c'])]
1224         return obj
1225
1226 if bs_globals.enable_clean == 0:
1227         if user_options_dict['BUILD_BLENDER_DYNAMIC'] == 1:
1228                 dy_blender = link_env.Copy ()
1229                 if sys.platform=='win32':
1230                         bs_libs.winblenderres(dy_blender)
1231                 bs_libs.blender_libs(dy_blender)
1232                 bs_libs.common_libs(dy_blender)
1233                 bs_libs.international_libs(dy_blender)
1234                 bs_libs.ketsji_libs(dy_blender)
1235                 bs_libs.system_libs(dy_blender)
1236                 dy_blender.Append (LIBS=user_options_dict['OPENGL_LIBRARY'])
1237                 dy_blender.Append (LIBPATH=user_options_dict['OPENGL_LIBPATH'])
1238                 dy_blender.Append (CPPPATH=user_options_dict['OPENGL_INCLUDE'])
1239                 d_obj = buildinfo(dy_blender, "dynamic")
1240                 if sys.platform == 'win32':
1241                         dy_blender.Program (target='blender',
1242                                                 source=d_obj + ['source/icons/winblender.res'])
1243                 else:
1244                         if sys.platform == 'cygwin':
1245                                 dy_blender.Replace (CC='g++')
1246                         dy_blender.Program (target='blender', source=d_obj)
1247         
1248         if user_options_dict['BUILD_BLENDER_STATIC'] == 1:
1249                 st_blender = link_env.Copy ()
1250                 if sys.platform=='win32':
1251                         bs_libs.winblenderres(st_blender)
1252                 bs_libs.blender_libs(st_blender)
1253                 bs_libs.common_libs(st_blender)
1254                 bs_libs.international_libs(st_blender)
1255                 bs_libs.ketsji_libs(st_blender)
1256                 bs_libs.system_libs(st_blender)
1257                 # The next line is to make sure that the LINKFLAGS are appended at the end
1258                 # of the link command. This 'trick' is needed because the GL and GLU static
1259                 # libraries need to be at the end of the command.
1260                 st_blender.Replace(LINKCOM="$LINK -o $TARGET $SOURCES $_LIBDIRFLAGS $_LIBFLAGS $LINKFLAGS")
1261                 s_obj = buildinfo(st_blender, "static")
1262                 st_blender.Append (LINKFLAGS=user_options_dict['OPENGL_STATIC'])
1263                 st_blender.Append (CPPPATH=user_options_dict['OPENGL_INCLUDE'])
1264                 st_blender.Prepend (LIBPATH=['/usr/lib/opengl/xfree/lib'])
1265                 st_blender.Program (target='blenderstatic', source=s_obj)
1266         
1267         if sys.platform=='win32':
1268                 if user_options_dict['BUILD_BINARY']=='debug':
1269                         browser = Environment(ENV = os.environ)
1270                         browser_tmp = bs_globals.root_build_dir+'bscmake.tmp'
1271                         browser.Command ('blender.bsc', 'blender$PROGSUFFIX',
1272                                 ['dir /b/s '+bs_globals.root_build_dir+'*.sbr >'+browser_tmp,
1273                                  'bscmake /nologo /n /oblender.bsc @'+browser_tmp,
1274                                  'del '+browser_tmp])
1275         
1276         if user_options_dict['BUILD_BLENDER_PLAYER'] == 1 and user_options_dict['BUILD_GAMEENGINE'] == 1:
1277                 player_blender = link_env.Copy()
1278                 bs_libs.player_libs(player_blender)
1279                 bs_libs.common_libs(player_blender)
1280                 bs_libs.international_libs(player_blender)
1281                 bs_libs.ketsji_libs(player_blender)
1282                 bs_libs.player_libs2(player_blender)
1283                 bs_libs.system_libs(player_blender)
1284                 player_blender.Append (LIBS=user_options_dict['OPENGL_LIBRARY'])
1285                 player_blender.Append (LIBPATH=user_options_dict['OPENGL_LIBPATH'])
1286                 player_blender.Append (CPPPATH=user_options_dict['OPENGL_INCLUDE'])
1287                 d_obj = buildinfo(player_blender, "player")
1288                 if sys.platform == 'win32':
1289                         player_blender.Program (target='blenderplayer',
1290                                                 source=d_obj + ['source/icons/winblender.res'])
1291                 else:
1292                         if sys.platform == 'cygwin':
1293                                 player_blender.Replace (CC='g++')
1294                         player_blender.Program (target='blenderplayer', source=d_obj)
1295                 if sys.platform=='win32':
1296                         if user_options_dict['BUILD_BINARY']=='debug':
1297                                 browser = Environment(ENV = os.environ)
1298                                 browser_tmp = bs_globals.root_build_dir+'bscmake.tmp'
1299                                 browser.Command ('blenderplayer.bsc', 'blenderplayer$PROGSUFFIX',
1300                                 ['dir /b/s '+bs_globals.root_build_dir+'*.sbr >'+browser_tmp,
1301                                 'bscmake /nologo /n /oblenderplayer.bsc @'+browser_tmp,
1302                                 'del '+browser_tmp])
1303
1304         release_target = env.Alias("release", bs_arc.BlenderRelease(appname))
1305         default_target = env.Alias("default", bs_default.BlenderDefault(appname))
1306         wininst_target = env.Alias("winist", bs_nsis.BlenderNSIS(appname))
1307         if bs_globals.docopy == 1:
1308                 bincopy_target = env.Alias("bincopy", bs_bincopy.BlenderCopy(appname))
1309                 
1310 else: # only clean target to prevent any building
1311         clean_target = env.Alias("clean", bs_clean.DoClean(bs_globals.root_build_dir))
1312         Default("clean")
1313
1314 if bs_globals.enable_clean == 0: # only set up dependencies when not cleaning
1315         if sys.platform == 'darwin':
1316                 Default("release")
1317         else:
1318                 Default("default")
1319
1320         if sys.platform == 'win32':
1321                 if user_options_dict['BUILD_BLENDER_PLAYER'] == 1:
1322                         env.Depends(wininst_target, playername)
1323                 env.Depends(wininst_target, appname)
1324         
1325         if user_options_dict['BUILD_BLENDER_PLAYER'] == 1:
1326                 env.Depends(release_target, playername)
1327                 env.Depends(default_target, playername)
1328                 if bs_globals.docopy == 1:
1329                         env.Depends(bincopy_target, playername)
1330         env.Depends(release_target, appname)
1331         env.Depends(default_target, appname)
1332         if bs_globals.docopy == 1:
1333                 env.Depends(bincopy_target, appname)