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