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