fix for bug of long group long name, bug found and fixed for bmx007
[blender-staging.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 = 'true'
163         use_openal = 'true'
164         use_fmod = 'false'
165         use_openal = 'true'
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 = 'true'
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         # Tiff Library information
338         tiff_lib = ['libtiff']
339         tiff_libpath = ['#../lib/windows/tiff/lib']
340         tiff_include = ['#../lib/windows/tiff/include']
341         # OpenGL library information
342         opengl_lib = ['opengl32', 'glu32']
343         opengl_static = []
344         opengl_libpath = []
345         opengl_include = []
346         # SDL specific stuff.
347         sdl_include = ['#../lib/windows/sdl/include']
348         sdl_libpath = ['#../lib/windows/sdl/lib']
349         sdl_lib = ['SDL']
350         sdl_cflags = []
351         #sdl_cflags = '-DWIN32'
352         # SOLID library information
353         solid_lib = []
354         solid_libpath = []
355         solid_include = ['#extern/solid']
356         qhull_lib = []
357         qhull_libpath = []
358         qhull_include = ['#extern/qhull/include']
359         # Bullet library information
360         bullet_lib = []
361         bullet_libpath = []
362         bullet_include = ['#extern/bullet','#extern/bullet/LinearMath','#extern/bullet/Bullet','#extern/bullet/BulletDynamics']
363         # ODE library information
364         ode_lib = ['ode']
365         ode_libpath = ['#../lib/windows/gcc/ode/lib']
366         ode_include = ['#../lib/windows/gcc/ode/include']
367         # Python library information
368         python_include = ['#../lib/windows/python/include/python2.2']
369         python_libpath = ['#../lib/windows/python/lib']
370         python_lib = ['python22']
371         python_linkflags = []
372         # International stuff
373         ftgl_lib = []
374         ftgl_libpath = []
375         ftgl_include = ['#extern/bFTGL/include']
376         freetype_lib = ['freetype']
377         freetype_libpath = ['#../lib/windows/gcc/freetype/lib']
378         freetype_include = ['#../lib/windows/gcc/freetype/include']
379         gettext_lib = []
380         gettext_libpath = []
381         gettext_include = []
382         # OpenAL library information
383         openal_lib = []
384         openal_libpath = []
385         openal_include = []
386
387 elif sys.platform == 'win32':
388         use_international = 'true'
389         use_gameengine = 'true'
390         use_openal = 'true'
391         use_fmod = 'false'
392         use_quicktime = 'true'
393         use_openexr = 'true'
394         use_bullet = 'true'
395         use_sumo = 'true'
396         use_ode = 'false'
397         use_buildinfo = 'true'
398         use_fluidsim = 'true'
399         build_blender_dynamic = 'true'
400         build_blender_static = 'false'
401         build_blender_player = 'true'
402         build_blender_plugin = 'false'
403         release_flags = ['/Og', '/Ot', '/Ob1', '/Op', '/G6']
404         debug_flags = ['/Zi', '/Fr${TARGET.base}.sbr']
405         extra_flags = ['/EHsc', '/J', '/W3', '/Gd', '/MT']
406         cxxflags = []
407         defines = ['WIN32', '_CONSOLE']
408         if use_quicktime == 'true':
409                 defines += ['WITH_QUICKTIME']
410         defines += ['_LIB', 'USE_OPENAL']
411         defines += ['FTGL_LIBRARY_STATIC']
412         warn_flags = []
413         platform_libs = [ 'qtmlClient', 'soundsystem',
414                                          'ws2_32', 'dxguid', 'vfw32', 'winmm',
415                                          'iconv', 'kernel32', 'user32', 'gdi32',
416                                          'comdlg32', 'advapi32', 'shell32',
417                                          'ole32', 'oleaut32', 'uuid', 
418                                          'libcmt', 'libc']
419         platform_libpath = ['#../lib/windows/iconv/lib',
420                                                 '#../lib/windows/QTDevWin/Libraries']
421         platform_linkflags = [
422                                                 '/SUBSYSTEM:CONSOLE',
423                                                 '/MACHINE:IX86',
424                                                 '/ENTRY:mainCRTStartup',
425                                                 '/INCREMENTAL:NO',
426                                                 '/NODEFAULTLIB:"msvcprt.lib"',
427                                                 '/NODEFAULTLIB:"glut32.lib"',
428                                                 '/NODEFAULTLIB:"libcd.lib"',
429                                                 #'/NODEFAULTLIB:"libc.lib"',
430                                                 '/NODEFAULTLIB:"libcpd.lib"',
431                                                 '/NODEFAULTLIB:"libcp.lib"',
432                                                 '/NODEFAULTLIB:"libcmtd.lib"',
433                                                 ]
434         window_system = 'WIN32'
435         extra_includes = []
436         if use_quicktime == 'true':
437                 extra_includes += ['#../lib/windows/QTDevWin/CIncludes']
438         # z library information
439         z_lib = ['zlib']
440         z_libpath = ['#../lib/windows/zlib/lib']
441         z_include = ['#../lib/windows/zlib/include']
442         # png library information
443         png_lib = ['libpng_st']
444         png_libpath = ['#../lib/windows/png/lib']
445         png_include = ['#../lib/windows/png/include']
446         # OpenEXR library information
447         if use_openexr == 'true':
448                 defines += ['WITH_OPENEXR']
449         openexr_lib = ['Iex', 'Half', 'IlmImf', 'Imath']
450         openexr_libpath = ['/usr/lib']
451         openexr_include = ['/usr/include/OpenEXR']
452         # jpeg library information
453         jpeg_lib = ['libjpeg']
454         jpeg_libpath = ['#../lib/windows/jpeg/lib']
455         jpeg_include = ['#../lib/windows/jpeg/include']
456         # Tiff Library information
457         tiff_lib = ['libtiff']
458         tiff_libpath = ['#../lib/windows/tiff/lib']
459         tiff_include = ['#../lib/windows/tiff/include']
460         # OpenGL library information
461         opengl_lib = ['opengl32', 'glu32']
462         opengl_static = []
463         opengl_libpath = []
464         opengl_include = ['/usr/include']
465         # SDL library information
466         sdl_include = ['#../lib/windows/sdl/include']
467         sdl_libpath = ['#../lib/windows/sdl/lib']
468         sdl_lib = ['SDL']
469         sdl_cflags = []
470         window_system = 'WIN32'
471         # SOLID library information
472         solid_lib = ['extern/solid']
473         solid_libpath = ['#../lib/windows/solid/lib']
474         solid_include = ['#extern/solid']
475         qhull_lib = ['qhull']
476         qhull_libpath = ['#../lib/windows/qhull/lib']
477         qhull_include = ['#extern/qhull/include']
478         # Bullet library information
479         bullet_lib = []
480         bullet_libpath = []
481         bullet_include = ['#extern/bullet','#extern/bullet/LinearMath','#extern/bullet/Bullet','#extern/bullet/BulletDynamics']
482         # ODE library information
483         ode_lib = []                                                                                            # TODO
484         ode_libpath = ['#../lib/windows/ode/lib']
485         ode_include = ['#../lib/windows/ode/include']
486         # Python lib name
487         python_include = ['#../lib/windows/python/include/python2.4']
488         python_libpath = ['#../lib/windows/python/lib']
489         python_lib = ['python24']
490         python_linkflags = []
491         # International stuff
492         ftgl_lib = []
493         ftgl_libpath = []
494         ftgl_include = ['#extern/bFTGL/include']
495         freetype_lib = ['freetype2ST']
496         freetype_libpath = ['#../lib/windows/freetype/lib']
497         freetype_include = ['#../lib/windows/freetype/include']
498         gettext_lib = ['gnu_gettext']
499         gettext_libpath = ['#../lib/windows/gettext/lib']
500         gettext_include = ['#../lib/windows/gettext/include']
501         # OpenAL library information
502         openal_lib = ['openal_static']
503         openal_libpath = ['#../lib/windows/openal/lib']
504         openal_include = ['#../lib/windows/openal/include']
505
506 elif string.find (sys.platform, 'sunos') != -1:
507         use_international = 'true'
508         use_gameengine = 'false'
509         use_openal = 'false'
510         use_fmod = 'false'
511         use_quicktime = 'false'
512         use_openexr = 'false'
513         use_sumo = 'false'
514         use_ode = 'false'
515         use_bullet = 'false'
516         use_buildinfo = 'false'
517         use_fluidsim = 'true'
518         build_blender_dynamic = 'true'
519         build_blender_static = 'false'
520         build_blender_player = 'false'
521         build_blender_plugin = 'false'
522         release_flags = ['-O2']
523         debug_flags = ['-O2', '-g']
524         extra_flags = ['-pipe', '-fPIC', '-funsigned-char', '-DSUN_OGL_NO_VERTEX_MACROS']
525         cxxflags = []
526         defines = []
527         warn_flags = ['-Wall', '-W']
528         window_system = 'X11'
529         platform_libs = ['stdc++', 'dl', 'm']
530         platform_libpath = []
531         platform_linkflags = []
532         extra_includes = []
533         # z library information
534         z_lib = ['z']
535         z_libpath = []
536         z_include = []
537         # png library information
538         png_lib = ['png']
539         png_libpath = []
540         png_include = []
541         # OpenEXR library information
542         if use_openexr == 'true':
543                 defines += ['WITH_OPENEXR']
544         openexr_lib = ['Iex', 'Half', 'IlmImf', 'Imath']
545         openexr_libpath = ['/usr/lib']
546         openexr_include = ['/usr/include/OpenEXR']
547         # jpeg library information
548         jpeg_lib = ['jpeg']
549         jpeg_libpath = []
550         jpeg_include = []
551         # OpenGL library information
552         opengl_lib = ['GL', 'GLU', 'X11']
553         opengl_static = []
554         opengl_libpath = ['/usr/openwin/include']
555         opengl_include = ['/usr/openwin/lib']
556         # SDL library information
557         sdl_env.ParseConfig ('sdl-config --cflags --libs')
558         sdl_cflags = sdl_env.Dictionary()['CCFLAGS']
559         sdl_include = sdl_env.Dictionary()['CPPPATH']
560         sdl_libpath = sdl_env.Dictionary()['LIBPATH']
561         sdl_lib = sdl_env.Dictionary()['LIBS']
562         # SOLID library information
563         solid_lib = []
564         solid_libpath = []
565         solid_include = ['#extern/solid']
566         qhull_lib = []
567         qhull_libpath = []
568         qhull_include = ['#extern/qhull/include']
569         # ODE library information
570         ode_lib = []
571         ode_libpath = []
572         ode_include = ['#extern/ode/dist/include/ode']
573         # Bullet library information
574         bullet_lib = []
575         bullet_libpath = []
576         bullet_include = ['#extern/bullet','#extern/bullet/LinearMath','#extern/bullet/Bullet','#extern/bullet/BulletDynamics']
577         # Python variables.
578         python_lib = ['python%d.%d' % sys.version_info[0:2]]
579         python_libpath = [sysconfig.get_python_lib (0, 1) + '/config']
580         python_include = [sysconfig.get_python_inc ()]
581         python_linkflags = []
582         # International support information
583         ftgl_lib = []
584         ftgl_libpath = []
585         ftgl_include = ['#extern/bFTGL/include']
586         freetype_lib = ['freetype']
587         freetype_libpath = ['#../lib/solaris-2.8-sparc/freetype/lib']
588         freetype_include = ['#../lib/solaris-2.8-sparc/freetype/include']
589         gettext_lib = []
590         gettext_libpath = []
591         gettext_include = []
592         # OpenAL library information
593         openal_lib = []
594         openal_libpath = []
595         openal_include = []
596
597 elif string.find (sys.platform, 'irix') != -1:
598         use_international = 'false'
599         use_gameengine = 'false'
600         use_openal = 'false'
601         use_fmod = 'false'
602         use_quicktime = 'false'
603         use_openexr = 'false'
604         use_sumo = 'false'
605         use_ode = 'false'
606         use_bullet = 'false'
607         use_buildinfo = 'false'
608         use_fluidsim = 'true'
609         build_blender_dynamic = 'true'
610         build_blender_static = 'false'
611         build_blender_player = 'false'
612         build_blender_plugin = 'false'
613         irix_precomp = '#../lib/irix-6.5-mips'
614         extra_flags = ['-n32', '-mips3', '-Xcpluscomm']
615         cxxflags = ['-n32', '-mips3', '-Xcpluscomm', '-LANG:std']
616         cxxflags += ['-LANG:libc_in_namespace_std=off']
617         
618         window_system = 'X11'
619         release_flags = ['-O2', '-OPT:Olimit=0']
620         debug_flags = ['-O2', '-g']
621         defines = []
622         warn_flags = ['-fullwarn', '-woff', '1001,1110,1201,1209,1355,1424,1681,3201']
623         platform_libs = ['movieGL', 'Xmu', 'Xext', 'X11',
624                                          'c', 'm', 'dmedia', 'cl', 'audio',
625                                          'Cio', 'pthread']
626         platform_libpath = ['/usr/lib32/mips3',
627                                                 '/lib/freeware/lib32',
628                                                 '/usr/lib32']
629         platform_linkflags = ['-mips3', '-n32']
630         extra_includes = ['/usr/freeware/include',
631                                           '/usr/include']
632         # z library information
633         z_lib = ['z']
634         z_libpath = []
635         z_include = []
636         # png library information
637         png_lib = ['png']
638         png_libpath = [irix_precomp + '/png/lib']
639         png_include = [irix_precomp + '/png/include']
640         # OpenEXR library information
641         if use_openexr == 'true':
642                 defines += ['WITH_OPENEXR']
643         openexr_lib = ['Iex', 'Half', 'IlmImf', 'Imath']
644         openexr_libpath = ['/usr/lib']
645         openexr_include = ['/usr/include/OpenEXR']
646         # jpeg library information
647         jpeg_lib = ['jpeg']
648         jpeg_libpath = [irix_precomp + '/jpeg/lib']
649         jpeg_include = [irix_precomp + '/jpeg/include']
650         # OpenGL library information
651         opengl_lib = ['GL', 'GLU']
652         opengl_static = []
653         opengl_libpath = []
654         opengl_include = []
655         # SDL library information
656         sdl_cflags = []
657         sdl_include = [irix_precomp + '/sdl/include/SDL']
658         sdl_libpath = [irix_precomp + '/sdl/lib']
659         sdl_lib = ['SDL', 'libSDL.a']
660         # SOLID library information
661         solid_lib = []
662         solid_libpath = []
663         solid_include = [irix_precomp + '/solid/include']
664         qhull_lib = []
665         qhull_libpath = []
666         qhull_include = ['#extern/qhull/include']
667         # Bullet library information
668         bullet_lib = []
669         bullet_libpath = []
670         bullet_include = ['#extern/bullet','#extern/bullet/LinearMath','#extern/bullet/Bullet','#extern/bullet/BulletDynamics']
671         # ODE library information
672         ode_lib = []
673         ode_libpath = []
674         ode_include = [irix_precomp + '/ode/include']
675         # Python library information
676         python_libpath = [irix_precomp + '/python/lib/python2.2/config']
677         python_include = [irix_precomp + '/python/include/python2.2']
678         python_lib = ['python2.2']
679         python_linkflags = []
680         # International support information
681         ftgl_lib = []
682         ftgl_libpath = []
683         ftgl_include = ['#extern/bFTGL/include']
684         freetype_lib = ['freetype']
685         freetype_libpath = [irix_precomp + '/freetype/lib']
686         freetype_include = [irix_precomp + '/freetype/include']
687         gettext_lib = []
688         gettext_libpath = []
689         gettext_include = []
690         # OpenAL library information
691         openal_lib = []
692         openal_libpath = []
693         openal_include = []
694
695 elif string.find (sys.platform, 'hp-ux') != -1:
696         window_system = 'X11'
697         defines = []
698
699 elif sys.platform=='openbsd3':
700         print "Building for OpenBSD 3.x"
701         use_international = 'false'
702         use_gameengine = 'false'
703         use_openal = 'false'
704         use_fmod = 'false'
705         use_quicktime = 'false'
706         use_openexr = 'false'
707         use_sumo = 'false'
708         use_ode = 'false'
709         use_bullet = 'false'
710         use_buildinfo = 'true'
711         use_fluidsim = 'true'
712         build_blender_dynamic = 'true'
713         build_blender_static = 'false'
714         build_blender_player = 'false'
715         build_blender_plugin = 'false'
716         release_flags = ['-O2']
717         debug_flags = ['-O2', '-g']
718         extra_flags = ['-pipe', '-fPIC', '-funsigned-char']
719         cxxflags = []
720         defines = []
721         warn_flags = ['-Wall','-W']
722         window_system = 'X11'
723         platform_libs = ['m', 'stdc++', 'pthread', 'util']
724         platform_libpath = []
725         platform_linkflags = []
726         extra_includes = []
727         z_lib = ['z']
728         z_libpath = ['/usr/lib']
729         z_include = ['/usr/include']
730         # png library information
731         png_lib = ['png']
732         png_libpath = ['/usr/local/lib']
733         png_include = ['/usr/local/include/libpng']
734         # OpenEXR library information
735         if use_openexr == 'true':
736                 defines += ['WITH_OPENEXR']
737         openexr_lib = ['Iex', 'Half', 'IlmImf', 'Imath']
738         openexr_libpath = ['/usr/lib']
739         openexr_include = ['/usr/include/OpenEXR']
740         # jpeg library information
741         jpeg_lib = ['jpeg']
742         jpeg_libpath = ['/usr/local/lib']
743         jpeg_include = ['/usr/local/include']
744         # OpenGL library information
745         opengl_lib = ['GL', 'GLU']
746         opengl_static = ['/usr/lib/libGL.a', '/usr/lib/libGLU.a']
747         opengl_libpath = ['/usr/lib', '/usr/X11R6/lib']
748         opengl_include = ['/usr/X11R6/include/']
749         # SDL library information
750         sdl_env.ParseConfig ('sdl-config --cflags --libs')
751         sdl_cflags = sdl_env.Dictionary()['CCFLAGS']
752         sdl_include = sdl_env.Dictionary()['CPPPATH']
753         sdl_libpath = sdl_env.Dictionary()['LIBPATH']
754         sdl_lib = sdl_env.Dictionary()['LIBS']
755         # SOLID library information
756         solid_lib = []
757         solid_libpath = []
758         solid_include = ['#extern/solid']
759         qhull_lib = []
760         qhull_libpath = []
761         qhull_include = ['#extern/qhull/include']
762         # Bullet library information
763         bullet_lib = []
764         bullet_libpath = []
765         bullet_include = ['#extern/bullet','#extern/bullet/LinearMath','#extern/bullet/Bullet','#extern/bullet/BulletDynamics']
766         # ODE library information
767         ode_lib = ['ode']
768         ode_libpath = ['#../lib/linux-glibc2.2.5-i386/ode/lib']
769         ode_include = ['#../lib/linux-glibc2.2.5-i386/ode/include']
770         # Python library information
771         python_lib = ['python%d.%d' % sys.version_info[0:2]]
772         python_libpath = [sysconfig.get_python_lib (0, 1) + '/config']
773         python_include = [sysconfig.get_python_inc ()]
774         python_linkflags = []
775         # International support information
776         ftgl_lib = []
777         ftgl_libpath = []
778         ftgl_include = ['#extern/bFTGL/include']
779         freetype_env.ParseConfig('pkg-config --cflags --libs freetype2')
780         freetype_lib = freetype_env.Dictionary()['LIBS']
781         freetype_libpath = freetype_env.Dictionary()['LIBPATH']
782         freetype_include = freetype_env.Dictionary()['CPPPATH']
783         gettext_lib = []
784         gettext_libpath = []
785         gettext_include = []
786         # OpenAL library information
787         openal_lib = ['openal']
788         openal_libpath = ['/usr/lib']
789         openal_include = ['/usr/include']
790         
791 elif sys.platform=='freebsd4' or sys.platform=='freebsd5':
792         print "Building for FreeBSD"
793         use_international = 'false'
794         use_gameengine = 'false'
795         use_openal = 'false'
796         use_fmod = 'false'
797         use_quicktime = 'false'
798         use_openexr = 'false'
799         use_sumo = 'false'
800         use_ode = 'false'
801         use_bullet = 'false'
802         use_buildinfo = 'true'
803         use_fluidsim = 'true'
804         build_blender_dynamic = 'true'
805         build_blender_static = 'false'
806         build_blender_player = 'false'
807         build_blender_plugin = 'false'
808         release_flags = ['-O2']
809         debug_flags = ['-O2', '-g']
810         extra_flags = ['-pipe', '-fPIC', '-funsigned-char']
811         cxxflags = []
812         defines = []
813         warn_flags = ['-Wall','-W']
814         window_system = 'X11'
815         platform_libs = ['m', 'stdc++', 'util']
816         platform_libpath = []
817         platform_linkflags = ['-pthread']
818         extra_includes = []
819         z_lib = ['z']
820         z_libpath = ['/usr/lib']
821         z_include = ['/usr/include']
822         # png library information
823         png_lib = ['png']
824         png_libpath = ['/usr/local/lib']
825         png_include = ['/usr/local/include']
826         # OpenEXR library information
827         if use_openexr == 'true':
828                 defines += ['WITH_OPENEXR']
829         openexr_lib = ['Iex', 'Half', 'IlmImf', 'Imath']
830         openexr_libpath = ['/usr/lib']
831         openexr_include = ['/usr/include/OpenEXR']
832         # jpeg library information
833         jpeg_lib = ['jpeg']
834         jpeg_libpath = ['/usr/local/lib']
835         jpeg_include = ['/usr/local/include']
836         # OpenGL library information
837         opengl_lib = ['GL', 'GLU']
838         opengl_static = ['/usr/lib/libGL.a', '/usr/lib/libGLU.a']
839         opengl_libpath = ['/usr/lib', '/usr/X11R6/lib']
840         opengl_include = ['/usr/X11R6/include/']
841         # SDL library information
842         sdl_env.ParseConfig ('sdl11-config --cflags --libs')
843         sdl_cflags = sdl_env.Dictionary()['CCFLAGS']
844         sdl_include = sdl_env.Dictionary()['CPPPATH']
845         sdl_libpath = ['/usr/local/include/SDL11']
846         sdl_lib = sdl_env.Dictionary()['LIBS']
847         # SOLID library information
848         solid_lib = []
849         solid_libpath = []
850         solid_include = ['#extern/solid']
851         qhull_lib = []
852         qhull_libpath = []
853         qhull_include = ['#extern/qhull/include']
854         # Bullet library information
855         bullet_lib = []
856         bullet_libpath = []
857         bullet_include = ['#extern/bullet','#extern/bullet/LinearMath','#extern/bullet/Bullet','#extern/bullet/BulletDynamics']
858         # ODE library information
859         ode_lib = ['ode']
860         ode_libpath = ['#../lib/linux-glibc2.2.5-i386/ode/lib']
861         ode_include = ['#../lib/linux-glibc2.2.5-i386/ode/include']
862         # Python library information
863         python_lib = ['python%d.%d' % sys.version_info[0:2]]
864         python_libpath = [sysconfig.get_python_lib (0, 1) + '/config']
865         python_include = [sysconfig.get_python_inc ()]
866         python_linkflags = []
867         # International support information
868         ftgl_lib = []
869         ftgl_libpath = []
870         ftgl_include = ['#extern/bFTGL/include']
871         freetype_env.ParseConfig('pkg-config --cflags --libs freetype2')
872         freetype_lib = freetype_env.Dictionary()['LIBS']
873         freetype_libpath = freetype_env.Dictionary()['LIBPATH']
874         freetype_include = freetype_env.Dictionary()['CPPPATH']
875         gettext_lib = []
876         gettext_libpath = []
877         gettext_include = []
878         # OpenAL library information
879         openal_lib = ['openal']
880         openal_libpath = ['/usr/lib']
881         openal_include = ['/usr/include']
882
883 else:
884         print "Unknown platform %s"%sys.platform
885         exit
886
887 #-----------------------------------------------------------------------------
888 # End of platform specific section
889 #-----------------------------------------------------------------------------
890
891 #-----------------------------------------------------------------------------
892 # User configurable options to be saved in a config file.
893 #-----------------------------------------------------------------------------
894 # Checking for an existing config file - use that one if it exists,
895 # otherwise create one.
896 my_defines = []
897 my_ccflags = []
898 my_cxxflags = []
899 my_ldflags = []
900 if os.path.exists (bs_globals.config_file):
901         print "Using config file: " + bs_globals.config_file
902 else:
903         print "Creating new config file: " + bs_globals.config_file
904         env_dict = env.Dictionary()
905         config=open (bs_globals.config_file, 'w')
906         config.write ("# Configuration file containing user definable options.\n")
907         config.write ("VERSION = %r\n"%(version))
908         config.write ("BUILD_BINARY = 'release'\n")
909         config.write ("USE_BUILDINFO = %r\n"%(use_buildinfo))
910         config.write ("BUILD_BLENDER_DYNAMIC = %r\n"%(build_blender_dynamic))
911         config.write ("BUILD_BLENDER_STATIC = %r\n"%(build_blender_static))
912         config.write ("BUILD_BLENDER_PLAYER = %r\n"%(build_blender_player))
913         config.write ("BUILD_BLENDER_PLUGIN = %r\n"%(build_blender_plugin))
914         config.write ("BUILD_DIR = %r\n"%(bs_globals.root_build_dir))
915         
916         config.write ("\n# Extra compiler flags can be defined here.\n")
917         config.write ("DEFINES = %s\n"%(my_defines))
918         config.write ("CCFLAGS = %s\n"%(my_ccflags))
919         config.write ("CXXFLAGS = %s\n"%(my_cxxflags))
920         config.write ("LDFLAGS = %s\n"%(my_ldflags))
921
922         config.write ("USE_INTERNATIONAL = %r\n"%(use_international))
923         config.write ("BUILD_GAMEENGINE = %r\n"%(use_gameengine))
924         if use_ode == 'true':
925                 config.write ("USE_PHYSICS = 'ode'\n")
926         elif (use_bullet == 'true') and (use_sumo == 'false'):
927                 config.write("USE_PHYSICS = 'bullet'\n")
928         else:
929                 config.write ("USE_PHYSICS = 'solid'\n")
930         config.write ("USE_OPENAL = %r\n"%(use_openal))
931         config.write ("USE_FMOD = %r\n"%(use_fmod))
932         config.write ("USE_QUICKTIME = %r\n"%(use_quicktime))
933         config.write ("USE_OPENEXR = %r\n"%(use_openexr))
934         config.write ("USE_FLUIDSIM = %r\n"%(use_fluidsim))
935         config.write ("\n# Compiler information.\n")
936         config.write ("HOST_CC = %r\n"%(env_dict['CC']))
937         config.write ("HOST_CXX = %r\n"%(env_dict['CXX']))
938         config.write ("TARGET_CC = %r\n"%(env_dict['CC']))
939         config.write ("TARGET_CXX = %r\n"%(env_dict['CXX']))
940         config.write ("TARGET_AR = %r\n"%(env_dict['AR']))
941         config.write ("PATH = %r\n"%(os.environ['PATH']))
942         config.write ("\n# External library information.\n")
943         config.write ("PLATFORM_LIBS = %r\n"%(platform_libs))
944         config.write ("PLATFORM_LIBPATH = %r\n"%(platform_libpath))
945         config.write ("PLATFORM_LINKFLAGS = %r\n"%(platform_linkflags))
946         config.write ("PYTHON_INCLUDE = %r\n"%(python_include))
947         config.write ("PYTHON_LIBPATH = %r\n"%(python_libpath))
948         config.write ("PYTHON_LIBRARY = %r\n"%(python_lib))
949         config.write ("PYTHON_LINKFLAGS = %r\n"%(python_linkflags))
950         config.write ("SDL_CFLAGS = %r\n"%(sdl_cflags))
951         config.write ("SDL_INCLUDE = %r\n"%(sdl_include))
952         config.write ("SDL_LIBPATH = %r\n"%(sdl_libpath))
953         config.write ("SDL_LIBRARY = %r\n"%(sdl_lib))
954         config.write ("Z_INCLUDE = %r\n"%(z_include))
955         config.write ("Z_LIBPATH = %r\n"%(z_libpath))
956         config.write ("Z_LIBRARY = %r\n"%(z_lib))
957         config.write ("PNG_INCLUDE = %r\n"%(png_include))
958         config.write ("PNG_LIBPATH = %r\n"%(png_libpath))
959         config.write ("PNG_LIBRARY = %r\n"%(png_lib))
960         config.write ("OPENEXR_INCLUDE = %r\n"%(openexr_include))
961         config.write ("OPENEXR_LIBPATH = %r\n"%(openexr_libpath))
962         config.write ("OPENEXR_LIBRARY = %r\n"%(openexr_lib))
963         config.write ("JPEG_INCLUDE = %r\n"%(jpeg_include))
964         config.write ("JPEG_LIBPATH = %r\n"%(jpeg_libpath))
965         config.write ("JPEG_LIBRARY = %r\n"%(jpeg_lib))
966         config.write ("TIFF_INCLUDE = %r\n"%(tiff_include))
967         config.write ("TIFF_LIBPATH = %r\n"%(tiff_libpath))
968         config.write ("TIFF_LIBRARY = %r\n"%(tiff_lib))
969         config.write ("OPENGL_INCLUDE = %r\n"%(opengl_include))
970         config.write ("OPENGL_LIBPATH = %r\n"%(opengl_libpath))
971         config.write ("OPENGL_LIBRARY = %r\n"%(opengl_lib))
972         config.write ("OPENGL_STATIC = %r\n"%(opengl_static))
973         config.write ("\n# The following information is only necessary when you've enabled support for\n")
974         config.write ("# the game engine.\n")
975         config.write ("SOLID_INCLUDE = %r\n"%(solid_include))
976         config.write ("SOLID_LIBPATH = %r\n"%(solid_libpath))
977         config.write ("SOLID_LIBRARY = %r\n"%(solid_lib))
978         config.write ("QHULL_INCLUDE = %r\n"%(qhull_include))
979         config.write ("QHULL_LIBPATH = %r\n"%(qhull_libpath))
980         config.write ("QHULL_LIBRARY = %r\n"%(qhull_lib))
981         config.write ("ODE_INCLUDE = %r\n"%(ode_include))
982         config.write ("ODE_LIBPATH = %r\n"%(ode_libpath))
983         config.write ("ODE_LIBRARY = %r\n"%(ode_lib))
984         config.write ("BULLET_INCLUDE = %r\n"%(bullet_include))
985         config.write ("BULLET_LIBPATH = %r\n"%(bullet_libpath))
986         config.write ("BULLET_LIBRARY = %r\n"%(bullet_lib))
987         config.write ("OPENAL_INCLUDE = %r\n"%(openal_include))
988         config.write ("OPENAL_LIBPATH = %r\n"%(openal_libpath))
989         config.write ("OPENAL_LIBRARY = %r\n"%(openal_lib))
990         config.write ("\n# The following information is only necessary when building with\n")
991         config.write ("# internationalization support.\n");
992         config.write ("FTGL_INCLUDE = %r\n"%(ftgl_include))
993         config.write ("FTGL_LIBPATH = %r\n"%(ftgl_libpath))
994         config.write ("FTGL_LIBRARY = %r\n"%(ftgl_lib))
995         config.write ("FREETYPE_INCLUDE = %r\n"%(freetype_include))
996         config.write ("FREETYPE_LIBPATH = %r\n"%(freetype_libpath))
997         config.write ("FREETYPE_LIBRARY = %r\n"%(freetype_lib))
998         config.write ("GETTEXT_INCLUDE = %r\n"%(gettext_include))
999         config.write ("GETTEXT_LIBPATH = %r\n"%(gettext_libpath))
1000         config.write ("GETTEXT_LIBRARY = %r\n"%(gettext_lib))
1001         config.close ()
1002
1003 #-----------------------------------------------------------------------------
1004 # Read the options from the config file and update the various necessary flags
1005 #-----------------------------------------------------------------------------
1006 list_opts = []
1007 user_options = Options (bs_globals.config_file)
1008 user_options_env = Environment (ENV = os.environ, options = user_options)
1009 user_options.AddOptions (
1010                 ('VERSION', 'Blender version', version),
1011                 (EnumOption ('BUILD_BINARY', 'release',
1012                                         'Select a release or debug binary.',
1013                                          allowed_values = ('release', 'debug'))),
1014                 (BoolOption ('USE_BUILDINFO',
1015                                         'Set to 1 if you want to add build information.',
1016                                         'false')),
1017                 (BoolOption ('BUILD_BLENDER_DYNAMIC',
1018                                         'Set to 1 if you want to build blender with hardware accellerated OpenGL support.',
1019                                         'true')),
1020                 (BoolOption ('BUILD_BLENDER_STATIC',
1021                                         'Set to 1 if you want to build blender with software OpenGL support.',
1022                                         'false')),
1023                 (BoolOption ('BUILD_BLENDER_PLAYER',
1024                                         'Set to 1 if you want to build the blender player.',
1025                                         'false')),
1026                 (BoolOption ('BUILD_BLENDER_PLUGIN',
1027                                         'Set to 1 if you want to build the blender plugin.',
1028                                         'false')),
1029                 ('BUILD_DIR', 'Target directory for intermediate files.',
1030                                         bs_globals.root_build_dir),
1031                 (BoolOption ('USE_INTERNATIONAL',
1032                                         'Set to 1 to have international support.',
1033                                         'false')),
1034                 (EnumOption ('USE_PHYSICS', 'solid',
1035                                         'Select which physics engine to use.',
1036                                         allowed_values = ('ode', 'solid', 'bullet'))),
1037                 (BoolOption ('BUILD_GAMEENGINE',
1038                                         'Set to 1 to build blender with game engine support.',
1039                                         'false')),
1040                 (BoolOption ('USE_OPENAL',
1041                                         'Set to 1 to build the game engine with OpenAL support.',
1042                                         'false')),
1043                 (BoolOption ('USE_FMOD',
1044                                         'Set to 1 to build the game engine with FMod support.',
1045                                         'false')),
1046                 (BoolOption ('USE_QUICKTIME',
1047                                         'Set to 1 to add support for QuickTime.',
1048                                         'false')),
1049                 (BoolOption ('USE_OPENEXR',
1050                                         'Set to 1 to add support for OpenEXR.',
1051                                         'false')),
1052                 (BoolOption ('USE_FLUIDSIM', # NT test new
1053                                         'Set to 0 to disable compilation of fluid simulation library El\'Beem.',
1054                                         'true')),
1055                 ('HOST_CC', 'C compiler for the host platfor. This is the same as target platform when not cross compiling.'),
1056                 ('HOST_CXX', 'C++ compiler for the host platform. This is the same as target platform when not cross compiling.'),
1057                 ('TARGET_CC', 'C compiler for the target platform.'),
1058                 ('TARGET_CXX', 'C++ compiler for the target platform.'),
1059                 ('TARGET_AR', 'Linker command for linking libraries.'),
1060                 ('PATH', 'Standard search path'),
1061                 ('PLATFORM_LIBS', 'Platform specific libraries.'),
1062                 ('PLATFORM_LIBPATH', 'Platform specific library link path.'),
1063                 ('PLATFORM_LINKFLAGS', 'Platform specific linkflags'),
1064                 ('PYTHON_INCLUDE', 'Include directory for Python header files.'),
1065                 ('PYTHON_LIBPATH', 'Library path where the Python lib is located.'),
1066                 ('PYTHON_LIBRARY', 'Python library name.'),
1067                 ('PYTHON_LINKFLAGS', 'Python specific linkflags.'),
1068                 ('SDL_CFLAGS', 'Necessary CFLAGS when using sdl functionality.'),
1069                 ('SDL_INCLUDE', 'Include directory for SDL header files.'),
1070                 ('SDL_LIBPATH', 'Library path where the SDL library is located.'),
1071                 ('SDL_LIBRARY', 'SDL library name.'),
1072                 ('Z_INCLUDE', 'Include directory for zlib header files.'),
1073                 ('Z_LIBPATH', 'Library path where the zlib library is located.'),
1074                 ('Z_LIBRARY', 'Z library name.'),
1075                 ('PNG_INCLUDE', 'Include directory for png header files.'),
1076                 ('PNG_LIBPATH', 'Library path where the png library is located.'),
1077                 ('PNG_LIBRARY', 'png library name.'),
1078                 ('OPENEXR_INCLUDE', 'Include directory for OpenEXR header files.'),
1079                 ('OPENEXR_LIBPATH', 'Library path where the OpenEXR libraries are located.'),
1080                 ('OPENEXR_LIBRARY', 'OpenEXR library names.'),
1081                 ('JPEG_INCLUDE', 'Include directory for jpeg header files.'),
1082                 ('JPEG_LIBPATH', 'Library path where the jpeg library is located.'),
1083                 ('JPEG_LIBRARY', 'jpeg library name.'),
1084                 ('TIFF_INCLUDE', 'Include directory for TIFF header files.'),
1085                 ('TIFF_LIBPATH', 'Library path where the TIFF library is located.'),
1086                 ('TIFF_LIBRARY', 'TIFF library name.'),
1087                 ('OPENGL_INCLUDE', 'Include directory for OpenGL header files.'),
1088                 ('OPENGL_LIBPATH', 'Library path where the OpenGL libraries are located.'),
1089                 ('OPENGL_LIBRARY', 'OpenGL library names.'),
1090                 ('OPENGL_STATIC', 'Linker flags for static linking of Open GL.'),
1091                 ('SOLID_INCLUDE', 'Include directory for SOLID header files.'),
1092                 ('SOLID_LIBPATH', 'Library path where the SOLID library is located.'),
1093                 ('SOLID_LIBRARY', 'SOLID library name.'),
1094                 ('QHULL_INCLUDE', 'Include directory for QHULL header files.'),
1095                 ('QHULL_LIBPATH', 'Library path where the QHULL library is located.'),
1096                 ('QHULL_LIBRARY', 'QHULL library name.'),
1097                 ('ODE_INCLUDE', 'Include directory for ODE header files.'),
1098                 ('ODE_LIBPATH', 'Library path where the ODE library is located.'),
1099                 ('ODE_LIBRARY', 'ODE library name.'),
1100                 ('BULLET_INCLUDE', 'Include directory for BULLET header files.'),
1101                 ('BULLET_LIBPATH', 'Library path where the BULLET library is located.'),
1102                 ('BULLET_LIBRARY', 'BULLET library name'),
1103                 ('OPENAL_INCLUDE', 'Include directory for OpenAL header files.'),
1104                 ('OPENAL_LIBPATH', 'Library path where the OpenAL library is located.'),
1105                 ('OPENAL_LIBRARY', 'OpenAL library name.'),
1106                 ('FTGL_INCLUDE', 'Include directory for ftgl header files.'),
1107                 ('FTGL_LIBPATH', 'Library path where the ftgl library is located.'),
1108                 ('FTGL_LIBRARY', 'ftgl library name.'),
1109                 ('FREETYPE_INCLUDE', 'Include directory for freetype2 header files.'),
1110                 ('FREETYPE_LIBPATH', 'Library path where the freetype2 library is located.'),
1111                 ('FREETYPE_LIBRARY', 'Freetype2 library name.'),
1112                 ('GETTEXT_INCLUDE', 'Include directory for gettext header files.'),
1113                 ('GETTEXT_LIBPATH', 'Library path where the gettext library is located.'),
1114                 ('GETTEXT_LIBRARY', 'gettext library name.'),
1115                 ('DEFINES', 'Extra Preprocessor defines.'),
1116                 ('CCFLAGS', 'Extra C Compiler flags.'),
1117                 ('CXXFLAGS','Extra C++ Compiler flags.'),
1118                 ('LDFLAGS', 'Extra Linker flags.')
1119         )
1120 user_options.Update (user_options_env)
1121 user_options_dict = user_options_env.Dictionary()
1122 Help(user_options.GenerateHelpText(user_options_env))
1123 bs_globals.root_build_dir = user_options_dict['BUILD_DIR']
1124 # SET MODULE VARS #
1125 init_env = Environment(ENV = os.environ)
1126
1127 bs_globals.user_options_dict = user_options_dict
1128 bs_globals.init_env = init_env
1129 bs_globals.version = version
1130 bs_globals.shortversion = shortversion
1131 bs_globals.appname = appname
1132 bs_globals.playername = playername
1133 bs_globals.config_guess = config_guess
1134 # END SET MODULE VARS #
1135
1136 if user_options_dict['BUILD_GAMEENGINE'] == 1:
1137         defines += ['GAMEBLENDER=1']
1138         defines += ['USE_BULLET']
1139         if user_options_dict['USE_PHYSICS'] == 'ode':
1140                 defines += ['USE_ODE']
1141         else:
1142                 defines += ['USE_SUMO_SOLID']
1143 else:
1144         defines += ['GAMEBLENDER=0']
1145
1146 if user_options_dict['BUILD_BINARY'] == 'release':
1147         cflags = extra_flags + release_flags + warn_flags
1148         defines += ['NDEBUG']
1149 else:
1150         cflags = extra_flags + debug_flags + warn_flags
1151         if sys.platform == 'win32':
1152                 platform_linkflags = ['/DEBUG','/PDB:blender.pdb'] + platform_linkflags
1153
1154 defines += user_options_dict['DEFINES']
1155 cflags += user_options_dict['CCFLAGS']
1156 cxxflags += user_options_dict['CXXFLAGS']
1157 platform_linkflags += user_options_dict['LDFLAGS'] 
1158
1159 user_options_dict['PLATFORM_LINKFLAGS'] = platform_linkflags
1160
1161 if user_options_dict['USE_FLUIDSIM'] == 0: # NT test new
1162         use_fluidsim='false';
1163
1164 #-----------------------------------------------------------------------------
1165 # Generic library generation environment. This one is the basis for each
1166 # library.
1167 #-----------------------------------------------------------------------------
1168 library_env = env.Copy ()
1169 library_env.Replace (CC = user_options_dict['TARGET_CC'])
1170 library_env.Replace (CXX = user_options_dict['TARGET_CXX'])
1171 library_env.Replace (PATH = user_options_dict['PATH'])
1172 library_env.Replace (AR = user_options_dict['TARGET_AR'])
1173 library_env.Append (CCFLAGS = cflags)
1174 library_env.Append (CXXFLAGS = cxxflags)
1175 library_env.Append (CPPDEFINES = defines)
1176 library_env.SConsignFile (bs_globals.root_build_dir+'scons-signatures')
1177
1178 #-----------------------------------------------------------------------------
1179 # Settings to be exported to other SConscript files
1180 #-----------------------------------------------------------------------------
1181
1182 if bs_globals.enable_clean==0: # only read SConscripts when not cleaning, this to cut overhead
1183         Export ('cflags')
1184         Export ('defines')
1185         Export ('window_system')
1186         Export ('extra_includes')
1187         Export ('user_options_dict')
1188         Export ('library_env')
1189         Export ('sdl_env')
1190         Export ('use_fluidsim') # NT test
1191         
1192         BuildDir (bs_globals.root_build_dir+'/extern', 'extern', duplicate=0)
1193         SConscript (bs_globals.root_build_dir+'extern/SConscript')
1194         BuildDir (bs_globals.root_build_dir+'/intern', 'intern', duplicate=0)
1195         SConscript (bs_globals.root_build_dir+'intern/SConscript')
1196         BuildDir (bs_globals.root_build_dir+'/source', 'source', duplicate=0)
1197         SConscript (bs_globals.root_build_dir+'source/SConscript')
1198         
1199         libpath = (['#'+bs_globals.root_build_dir+'/lib'])
1200         
1201         link_env = library_env.Copy ()
1202         link_env.Append (LIBPATH=libpath)
1203
1204 def buildinfo(env, build_type):
1205         """
1206         Generate a buildinfo object
1207         """
1208         build_date = time.strftime ("%Y-%m-%d")
1209         build_time = time.strftime ("%H:%M:%S")
1210         obj = []
1211         if user_options_dict['USE_BUILDINFO'] == 1:
1212                 if sys.platform=='win32':
1213                         build_info_file = open("source/creator/winbuildinfo.h", 'w')
1214                         build_info_file.write("char *build_date=\"%s\";\n"%build_date)
1215                         build_info_file.write("char *build_time=\"%s\";\n"%build_time)
1216                         build_info_file.write("char *build_platform=\"win32\";\n")
1217                         build_info_file.write("char *build_type=\"dynamic\";\n")
1218                         build_info_file.close()
1219                         env.Append (CPPDEFINES = ['NAN_BUILDINFO', 'BUILD_DATE'])
1220                 else:
1221                         env.Append (CPPDEFINES = ['BUILD_TIME=\'"%s"\''%(build_time),
1222                                                         'BUILD_DATE=\'"%s"\''%(build_date),
1223                                                         'BUILD_TYPE=\'"dynamic"\'',
1224                                                         'NAN_BUILDINFO',
1225                                                         'BUILD_PLATFORM=\'"%s"\''%(sys.platform)])
1226                 obj = [env.Object (bs_globals.root_build_dir+'source/creator/%s_buildinfo'%build_type,
1227                                                 [bs_globals.root_build_dir+'source/creator/buildinfo.c'])]
1228         return obj
1229
1230 if bs_globals.enable_clean == 0:
1231         if user_options_dict['BUILD_BLENDER_DYNAMIC'] == 1:
1232                 dy_blender = link_env.Copy ()
1233                 if sys.platform=='win32':
1234                         bs_libs.winblenderres(dy_blender)
1235                 bs_libs.blender_libs(dy_blender)
1236                 bs_libs.common_libs(dy_blender)
1237                 bs_libs.international_libs(dy_blender)
1238                 bs_libs.ketsji_libs(dy_blender)
1239                 bs_libs.system_libs(dy_blender)
1240                 dy_blender.Append (LIBS=user_options_dict['OPENGL_LIBRARY'])
1241                 dy_blender.Append (LIBPATH=user_options_dict['OPENGL_LIBPATH'])
1242                 dy_blender.Append (CPPPATH=user_options_dict['OPENGL_INCLUDE'])
1243                 d_obj = buildinfo(dy_blender, "dynamic")
1244                 if sys.platform == 'win32':
1245                         dy_blender.Program (target='blender',
1246                                                 source=d_obj + ['source/icons/winblender.res'])
1247                 else:
1248                         if sys.platform == 'cygwin':
1249                                 dy_blender.Replace (CC='g++')
1250                         dy_blender.Program (target='blender', source=d_obj)
1251         
1252         if user_options_dict['BUILD_BLENDER_STATIC'] == 1:
1253                 st_blender = link_env.Copy ()
1254                 if sys.platform=='win32':
1255                         bs_libs.winblenderres(st_blender)
1256                 bs_libs.blender_libs(st_blender)
1257                 bs_libs.common_libs(st_blender)
1258                 bs_libs.international_libs(st_blender)
1259                 bs_libs.ketsji_libs(st_blender)
1260                 bs_libs.system_libs(st_blender)
1261                 # The next line is to make sure that the LINKFLAGS are appended at the end
1262                 # of the link command. This 'trick' is needed because the GL and GLU static
1263                 # libraries need to be at the end of the command.
1264                 st_blender.Replace(LINKCOM="$LINK -o $TARGET $SOURCES $_LIBDIRFLAGS $_LIBFLAGS $LINKFLAGS")
1265                 s_obj = buildinfo(st_blender, "static")
1266                 st_blender.Append (LINKFLAGS=user_options_dict['OPENGL_STATIC'])
1267                 st_blender.Append (CPPPATH=user_options_dict['OPENGL_INCLUDE'])
1268                 st_blender.Prepend (LIBPATH=['/usr/lib/opengl/xfree/lib'])
1269                 st_blender.Program (target='blenderstatic', source=s_obj)
1270         
1271         if sys.platform=='win32':
1272                 if user_options_dict['BUILD_BINARY']=='debug':
1273                         browser = Environment(ENV = os.environ)
1274                         browser_tmp = bs_globals.root_build_dir+'bscmake.tmp'
1275                         browser.Command ('blender.bsc', 'blender$PROGSUFFIX',
1276                                 ['dir /b/s '+bs_globals.root_build_dir+'*.sbr >'+browser_tmp,
1277                                  'bscmake /nologo /n /oblender.bsc @'+browser_tmp,
1278                                  'del '+browser_tmp])
1279         
1280         if user_options_dict['BUILD_BLENDER_PLAYER'] == 1 and user_options_dict['BUILD_GAMEENGINE'] == 1:
1281                 player_blender = link_env.Copy()
1282                 bs_libs.player_libs(player_blender)
1283                 bs_libs.common_libs(player_blender)
1284                 bs_libs.international_libs(player_blender)
1285                 bs_libs.ketsji_libs(player_blender)
1286                 bs_libs.player_libs2(player_blender)
1287                 bs_libs.system_libs(player_blender)
1288                 player_blender.Append (LIBS=user_options_dict['OPENGL_LIBRARY'])
1289                 player_blender.Append (LIBPATH=user_options_dict['OPENGL_LIBPATH'])
1290                 player_blender.Append (CPPPATH=user_options_dict['OPENGL_INCLUDE'])
1291                 d_obj = buildinfo(player_blender, "player")
1292                 if sys.platform == 'win32':
1293                         player_blender.Program (target='blenderplayer',
1294                                                 source=d_obj + ['source/icons/winblender.res'])
1295                 else:
1296                         if sys.platform == 'cygwin':
1297                                 player_blender.Replace (CC='g++')
1298                         player_blender.Program (target='blenderplayer', source=d_obj)
1299                 if sys.platform=='win32':
1300                         if user_options_dict['BUILD_BINARY']=='debug':
1301                                 browser = Environment(ENV = os.environ)
1302                                 browser_tmp = bs_globals.root_build_dir+'bscmake.tmp'
1303                                 browser.Command ('blenderplayer.bsc', 'blenderplayer$PROGSUFFIX',
1304                                 ['dir /b/s '+bs_globals.root_build_dir+'*.sbr >'+browser_tmp,
1305                                 'bscmake /nologo /n /oblenderplayer.bsc @'+browser_tmp,
1306                                 'del '+browser_tmp])
1307
1308         release_target = env.Alias("release", bs_arc.BlenderRelease(appname))
1309         default_target = env.Alias("default", bs_default.BlenderDefault(appname))
1310         wininst_target = env.Alias("winist", bs_nsis.BlenderNSIS(appname))
1311         if bs_globals.docopy == 1:
1312                 bincopy_target = env.Alias("bincopy", bs_bincopy.BlenderCopy(appname))
1313                 
1314 else: # only clean target to prevent any building
1315         clean_target = env.Alias("clean", bs_clean.DoClean(bs_globals.root_build_dir))
1316         Default("clean")
1317
1318 if bs_globals.enable_clean == 0: # only set up dependencies when not cleaning
1319         if sys.platform == 'darwin':
1320                 Default("release")
1321         else:
1322                 Default("default")
1323
1324         if sys.platform == 'win32':
1325                 if user_options_dict['BUILD_BLENDER_PLAYER'] == 1:
1326                         env.Depends(wininst_target, playername)
1327                 env.Depends(wininst_target, appname)
1328         
1329         if user_options_dict['BUILD_BLENDER_PLAYER'] == 1:
1330                 env.Depends(release_target, playername)
1331                 env.Depends(default_target, playername)
1332                 if bs_globals.docopy == 1:
1333                         env.Depends(bincopy_target, playername)
1334         env.Depends(release_target, appname)
1335         env.Depends(default_target, appname)
1336         if bs_globals.docopy == 1:
1337                 env.Depends(bincopy_target, appname)