nan definition for precompiled libtif
[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 = 'true'
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 = 'true'
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_bullet = 'true'
361         use_sumo = 'true'
362         use_ode = '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         if use_quicktime == 'true':
375                 defines += ['WITH_QUICKTIME']
376         defines += ['_LIB', 'USE_OPENAL']
377         defines += ['FTGL_LIBRARY_STATIC']
378         warn_flags = []
379         platform_libs = [ 'qtmlClient', 'soundsystem',
380                                          'ws2_32', 'dxguid', 'vfw32', 'winmm',
381                                          'iconv', 'kernel32', 'user32', 'gdi32',
382                                          'winspool', 'comdlg32', 'advapi32', 'shell32',
383                                          'ole32', 'oleaut32', 'uuid', 
384                                          'libcmt', 'libc']
385         platform_libpath = ['#../lib/windows/iconv/lib',
386                                                 '#../lib/windows/QTDevWin/Libraries']
387         platform_linkflags = [
388                                                 '/SUBSYSTEM:CONSOLE',
389                                                 '/MACHINE:IX86',
390                                                 '/ENTRY:mainCRTStartup',
391                                                 '/INCREMENTAL:NO',
392                                                 '/NODEFAULTLIB:"msvcprt.lib"',
393                                                 '/NODEFAULTLIB:"glut32.lib"',
394                                                 '/NODEFAULTLIB:"libcd.lib"',
395                                                 #'/NODEFAULTLIB:"libc.lib"',
396                                                 '/NODEFAULTLIB:"libcpd.lib"',
397                                                 '/NODEFAULTLIB:"libcp.lib"',
398                                                 '/NODEFAULTLIB:"libcmtd.lib"',
399                                                 ]
400         window_system = 'WIN32'
401         extra_includes = []
402         if use_quicktime == 'true':
403                 extra_includes += ['#../lib/windows/QTDevWin/CIncludes']
404         # z library information
405         z_lib = ['zlib']
406         z_libpath = ['#../lib/windows/zlib/lib']
407         z_include = ['#../lib/windows/zlib/include']
408         # png library information
409         png_lib = ['libpng_st']
410         png_libpath = ['#../lib/windows/png/lib']
411         png_include = ['#../lib/windows/png/include']
412         # jpeg library information
413         jpeg_lib = ['libjpeg']
414         jpeg_libpath = ['#../lib/windows/jpeg/lib']
415         jpeg_include = ['#../lib/windows/jpeg/include']
416         # OpenGL library information
417         opengl_lib = ['opengl32', 'glu32']
418         opengl_static = []
419         opengl_libpath = []
420         opengl_include = ['/usr/include']
421         # SDL library information
422         sdl_include = ['#../lib/windows/sdl/include']
423         sdl_libpath = ['#../lib/windows/sdl/lib']
424         sdl_lib = ['SDL']
425         sdl_cflags = []
426         window_system = 'WIN32'
427         # SOLID library information
428         solid_lib = ['extern/solid']
429         solid_libpath = ['#../lib/windows/solid/lib']
430         solid_include = ['#extern/solid']
431         qhull_lib = ['qhull']
432         qhull_libpath = ['#../lib/windows/qhull/lib']
433         qhull_include = ['#extern/qhull/include']
434         # Bullet library information
435         bullet_lib = []
436         bullet_libpath = []
437         bullet_include = ['#extern/bullet','#extern/bullet/LinearMath','#extern/bullet/Bullet','#extern/bullet/BulletDynamics']
438         # ODE library information
439         ode_lib = []                                                                                            # TODO
440         ode_libpath = ['#../lib/windows/ode/lib']
441         ode_include = ['#../lib/windows/ode/include']
442         # Python lib name
443         python_include = ['#../lib/windows/python/include/python2.4']
444         python_libpath = ['#../lib/windows/python/lib']
445         python_lib = ['python24']
446         python_linkflags = []
447         # International stuff
448         ftgl_lib = []
449         ftgl_libpath = []
450         ftgl_include = ['#extern/bFTGL/include']
451         freetype_lib = ['freetype2ST']
452         freetype_libpath = ['#../lib/windows/freetype/lib']
453         freetype_include = ['#../lib/windows/freetype/include']
454         gettext_lib = ['gnu_gettext']
455         gettext_libpath = ['#../lib/windows/gettext/lib']
456         gettext_include = ['#../lib/windows/gettext/include']
457         # OpenAL library information
458         openal_lib = ['openal_static']
459         openal_libpath = ['#../lib/windows/openal/lib']
460         openal_include = ['#../lib/windows/openal/include']
461
462 elif string.find (sys.platform, 'sunos') != -1:
463         use_international = 'true'
464         use_gameengine = 'false'
465         use_openal = 'false'
466         use_fmod = 'false'
467         use_quicktime = 'false'
468         use_sumo = 'false'
469         use_ode = 'false'
470         use_bullet = 'false'
471         use_buildinfo = 'false'
472         use_fluidsim = 'true'
473         build_blender_dynamic = 'true'
474         build_blender_static = 'false'
475         build_blender_player = 'false'
476         build_blender_plugin = 'false'
477         release_flags = ['-O2']
478         debug_flags = ['-O2', '-g']
479         extra_flags = ['-pipe', '-fPIC', '-funsigned-char', '-DSUN_OGL_NO_VERTEX_MACROS']
480         cxxflags = []
481         defines = []
482         warn_flags = ['-Wall', '-W']
483         window_system = 'X11'
484         platform_libs = ['stdc++', 'dl', 'm']
485         platform_libpath = []
486         platform_linkflags = []
487         extra_includes = []
488         # z library information
489         z_lib = ['z']
490         z_libpath = []
491         z_include = []
492         # png library information
493         png_lib = ['png']
494         png_libpath = []
495         png_include = []
496         # jpeg library information
497         jpeg_lib = ['jpeg']
498         jpeg_libpath = []
499         jpeg_include = []
500         # OpenGL library information
501         opengl_lib = ['GL', 'GLU', 'X11']
502         opengl_static = []
503         opengl_libpath = ['/usr/openwin/include']
504         opengl_include = ['/usr/openwin/lib']
505         # SDL library information
506         sdl_env.ParseConfig ('sdl-config --cflags --libs')
507         sdl_cflags = sdl_env.Dictionary()['CCFLAGS']
508         sdl_include = sdl_env.Dictionary()['CPPPATH']
509         sdl_libpath = sdl_env.Dictionary()['LIBPATH']
510         sdl_lib = sdl_env.Dictionary()['LIBS']
511         # SOLID library information
512         solid_lib = []
513         solid_libpath = []
514         solid_include = ['#extern/solid']
515         qhull_lib = []
516         qhull_libpath = []
517         qhull_include = ['#extern/qhull/include']
518         # ODE library information
519         ode_lib = []
520         ode_libpath = []
521         ode_include = ['#extern/ode/dist/include/ode']
522         # Bullet library information
523         bullet_lib = []
524         bullet_libpath = []
525         bullet_include = ['#extern/bullet','#extern/bullet/LinearMath','#extern/bullet/Bullet','#extern/bullet/BulletDynamics']
526         # Python variables.
527         python_lib = ['python%d.%d' % sys.version_info[0:2]]
528         python_libpath = [sysconfig.get_python_lib (0, 1) + '/config']
529         python_include = [sysconfig.get_python_inc ()]
530         python_linkflags = []
531         # International support information
532         ftgl_lib = []
533         ftgl_libpath = []
534         ftgl_include = ['#extern/bFTGL/include']
535         freetype_lib = ['freetype']
536         freetype_libpath = ['#../lib/solaris-2.8-sparc/freetype/lib']
537         freetype_include = ['#../lib/solaris-2.8-sparc/freetype/include']
538         gettext_lib = []
539         gettext_libpath = []
540         gettext_include = []
541         # OpenAL library information
542         openal_lib = []
543         openal_libpath = []
544         openal_include = []
545
546 elif string.find (sys.platform, 'irix') != -1:
547         use_international = 'false'
548         use_gameengine = 'false'
549         use_openal = 'false'
550         use_fmod = 'false'
551         use_quicktime = 'false'
552         use_sumo = 'false'
553         use_ode = 'false'
554         use_bullet = 'false'
555         use_buildinfo = 'false'
556         use_fluidsim = 'true'
557         build_blender_dynamic = 'true'
558         build_blender_static = 'false'
559         build_blender_player = 'false'
560         build_blender_plugin = 'false'
561         irix_precomp = '#../lib/irix-6.5-mips'
562         extra_flags = ['-n32', '-mips3', '-Xcpluscomm']
563         cxxflags = ['-n32', '-mips3', '-Xcpluscomm', '-LANG:std']
564         cxxflags += ['-LANG:libc_in_namespace_std=off']
565         
566         window_system = 'X11'
567         release_flags = ['-O2', '-OPT:Olimit=0']
568         debug_flags = ['-O2', '-g']
569         defines = []
570         warn_flags = ['-fullwarn', '-woff', '1001,1110,1201,1209,1355,1424,1681,3201']
571         platform_libs = ['movieGL', 'Xmu', 'Xext', 'X11',
572                                          'c', 'm', 'dmedia', 'cl', 'audio',
573                                          'Cio', 'pthread']
574         platform_libpath = ['/usr/lib32/mips3',
575                                                 '/lib/freeware/lib32',
576                                                 '/usr/lib32']
577         platform_linkflags = ['-mips3', '-n32']
578         extra_includes = ['/usr/freeware/include',
579                                           '/usr/include']
580         # z library information
581         z_lib = ['z']
582         z_libpath = []
583         z_include = []
584         # png library information
585         png_lib = ['png']
586         png_libpath = [irix_precomp + '/png/lib']
587         png_include = [irix_precomp + '/png/include']
588         # jpeg library information
589         jpeg_lib = ['jpeg']
590         jpeg_libpath = [irix_precomp + '/jpeg/lib']
591         jpeg_include = [irix_precomp + '/jpeg/include']
592         # OpenGL library information
593         opengl_lib = ['GL', 'GLU']
594         opengl_static = []
595         opengl_libpath = []
596         opengl_include = []
597         # SDL library information
598         sdl_cflags = []
599         sdl_include = [irix_precomp + '/sdl/include/SDL']
600         sdl_libpath = [irix_precomp + '/sdl/lib']
601         sdl_lib = ['SDL', 'libSDL.a']
602         # SOLID library information
603         solid_lib = []
604         solid_libpath = []
605         solid_include = [irix_precomp + '/solid/include']
606         qhull_lib = []
607         qhull_libpath = []
608         qhull_include = ['#extern/qhull/include']
609         # Bullet library information
610         bullet_lib = []
611         bullet_libpath = []
612         bullet_include = ['#extern/bullet','#extern/bullet/LinearMath','#extern/bullet/Bullet','#extern/bullet/BulletDynamics']
613         # ODE library information
614         ode_lib = []
615         ode_libpath = []
616         ode_include = [irix_precomp + '/ode/include']
617         # Python library information
618         python_libpath = [irix_precomp + '/python/lib/python2.2/config']
619         python_include = [irix_precomp + '/python/include/python2.2']
620         python_lib = ['python2.2']
621         python_linkflags = []
622         # International support information
623         ftgl_lib = []
624         ftgl_libpath = []
625         ftgl_include = ['#extern/bFTGL/include']
626         freetype_lib = ['freetype']
627         freetype_libpath = [irix_precomp + '/freetype/lib']
628         freetype_include = [irix_precomp + '/freetype/include']
629         gettext_lib = []
630         gettext_libpath = []
631         gettext_include = []
632         # OpenAL library information
633         openal_lib = []
634         openal_libpath = []
635         openal_include = []
636
637 elif string.find (sys.platform, 'hp-ux') != -1:
638         window_system = 'X11'
639         defines = []
640
641 elif sys.platform=='openbsd3':
642         print "Building for OpenBSD 3.x"
643         use_international = 'false'
644         use_gameengine = 'false'
645         use_openal = 'false'
646         use_fmod = 'false'
647         use_quicktime = 'false'
648         use_sumo = 'false'
649         use_ode = 'false'
650         use_bullet = 'false'
651         use_buildinfo = 'true'
652         use_fluidsim = 'true'
653         build_blender_dynamic = 'true'
654         build_blender_static = 'false'
655         build_blender_player = 'false'
656         build_blender_plugin = 'false'
657         release_flags = ['-O2']
658         debug_flags = ['-O2', '-g']
659         extra_flags = ['-pipe', '-fPIC', '-funsigned-char']
660         cxxflags = []
661         defines = []
662         warn_flags = ['-Wall','-W']
663         window_system = 'X11'
664         platform_libs = ['m', 'stdc++', 'pthread', 'util']
665         platform_libpath = []
666         platform_linkflags = []
667         extra_includes = []
668         z_lib = ['z']
669         z_libpath = ['/usr/lib']
670         z_include = ['/usr/include']
671         # png library information
672         png_lib = ['png']
673         png_libpath = ['/usr/local/lib']
674         png_include = ['/usr/local/include/libpng']
675         # jpeg library information
676         jpeg_lib = ['jpeg']
677         jpeg_libpath = ['/usr/local/lib']
678         jpeg_include = ['/usr/local/include']
679         # OpenGL library information
680         opengl_lib = ['GL', 'GLU']
681         opengl_static = ['/usr/lib/libGL.a', '/usr/lib/libGLU.a']
682         opengl_libpath = ['/usr/lib', '/usr/X11R6/lib']
683         opengl_include = ['/usr/X11R6/include/']
684         # SDL library information
685         sdl_env.ParseConfig ('sdl-config --cflags --libs')
686         sdl_cflags = sdl_env.Dictionary()['CCFLAGS']
687         sdl_include = sdl_env.Dictionary()['CPPPATH']
688         sdl_libpath = sdl_env.Dictionary()['LIBPATH']
689         sdl_lib = sdl_env.Dictionary()['LIBS']
690         # SOLID library information
691         solid_lib = []
692         solid_libpath = []
693         solid_include = ['#extern/solid']
694         qhull_lib = []
695         qhull_libpath = []
696         qhull_include = ['#extern/qhull/include']
697         # Bullet library information
698         bullet_lib = []
699         bullet_libpath = []
700         bullet_include = ['#extern/bullet','#extern/bullet/LinearMath','#extern/bullet/Bullet','#extern/bullet/BulletDynamics']
701         # ODE library information
702         ode_lib = ['ode']
703         ode_libpath = ['#../lib/linux-glibc2.2.5-i386/ode/lib']
704         ode_include = ['#../lib/linux-glibc2.2.5-i386/ode/include']
705         # Python library information
706         python_lib = ['python%d.%d' % sys.version_info[0:2]]
707         python_libpath = [sysconfig.get_python_lib (0, 1) + '/config']
708         python_include = [sysconfig.get_python_inc ()]
709         python_linkflags = []
710         # International support information
711         ftgl_lib = []
712         ftgl_libpath = []
713         ftgl_include = ['#extern/bFTGL/include']
714         freetype_env.ParseConfig('pkg-config --cflags --libs freetype2')
715         freetype_lib = freetype_env.Dictionary()['LIBS']
716         freetype_libpath = freetype_env.Dictionary()['LIBPATH']
717         freetype_include = freetype_env.Dictionary()['CPPPATH']
718         gettext_lib = []
719         gettext_libpath = []
720         gettext_include = []
721         # OpenAL library information
722         openal_lib = ['openal']
723         openal_libpath = ['/usr/lib']
724         openal_include = ['/usr/include']
725         
726 elif sys.platform=='freebsd4' or sys.platform=='freebsd5':
727         print "Building for FreeBSD"
728         use_international = 'false'
729         use_gameengine = 'false'
730         use_openal = 'false'
731         use_fmod = 'false'
732         use_quicktime = 'false'
733         use_sumo = 'false'
734         use_ode = 'false'
735         use_bullet = 'false'
736         use_buildinfo = 'true'
737         use_fluidsim = 'true'
738         build_blender_dynamic = 'true'
739         build_blender_static = 'false'
740         build_blender_player = 'false'
741         build_blender_plugin = 'false'
742         release_flags = ['-O2']
743         debug_flags = ['-O2', '-g']
744         extra_flags = ['-pipe', '-fPIC', '-funsigned-char']
745         cxxflags = []
746         defines = []
747         warn_flags = ['-Wall','-W']
748         window_system = 'X11'
749         platform_libs = ['m', 'stdc++', 'util']
750         platform_libpath = []
751         platform_linkflags = ['-pthread']
752         extra_includes = []
753         z_lib = ['z']
754         z_libpath = ['/usr/lib']
755         z_include = ['/usr/include']
756         # png library information
757         png_lib = ['png']
758         png_libpath = ['/usr/local/lib']
759         png_include = ['/usr/local/include']
760         # jpeg library information
761         jpeg_lib = ['jpeg']
762         jpeg_libpath = ['/usr/local/lib']
763         jpeg_include = ['/usr/local/include']
764         # OpenGL library information
765         opengl_lib = ['GL', 'GLU']
766         opengl_static = ['/usr/lib/libGL.a', '/usr/lib/libGLU.a']
767         opengl_libpath = ['/usr/lib', '/usr/X11R6/lib']
768         opengl_include = ['/usr/X11R6/include/']
769         # SDL library information
770         sdl_env.ParseConfig ('sdl11-config --cflags --libs')
771         sdl_cflags = sdl_env.Dictionary()['CCFLAGS']
772         sdl_include = sdl_env.Dictionary()['CPPPATH']
773         sdl_libpath = ['/usr/local/include/SDL11']
774         sdl_lib = sdl_env.Dictionary()['LIBS']
775         # SOLID library information
776         solid_lib = []
777         solid_libpath = []
778         solid_include = ['#extern/solid']
779         qhull_lib = []
780         qhull_libpath = []
781         qhull_include = ['#extern/qhull/include']
782         # Bullet library information
783         bullet_lib = []
784         bullet_libpath = []
785         bullet_include = ['#extern/bullet','#extern/bullet/LinearMath','#extern/bullet/Bullet','#extern/bullet/BulletDynamics']
786         # ODE library information
787         ode_lib = ['ode']
788         ode_libpath = ['#../lib/linux-glibc2.2.5-i386/ode/lib']
789         ode_include = ['#../lib/linux-glibc2.2.5-i386/ode/include']
790         # Python library information
791         python_lib = ['python%d.%d' % sys.version_info[0:2]]
792         python_libpath = [sysconfig.get_python_lib (0, 1) + '/config']
793         python_include = [sysconfig.get_python_inc ()]
794         python_linkflags = []
795         # International support information
796         ftgl_lib = []
797         ftgl_libpath = []
798         ftgl_include = ['#extern/bFTGL/include']
799         freetype_env.ParseConfig('pkg-config --cflags --libs freetype2')
800         freetype_lib = freetype_env.Dictionary()['LIBS']
801         freetype_libpath = freetype_env.Dictionary()['LIBPATH']
802         freetype_include = freetype_env.Dictionary()['CPPPATH']
803         gettext_lib = []
804         gettext_libpath = []
805         gettext_include = []
806         # OpenAL library information
807         openal_lib = ['openal']
808         openal_libpath = ['/usr/lib']
809         openal_include = ['/usr/include']
810
811 else:
812         print "Unknown platform %s"%sys.platform
813         exit
814
815 #-----------------------------------------------------------------------------
816 # End of platform specific section
817 #-----------------------------------------------------------------------------
818
819 #-----------------------------------------------------------------------------
820 # User configurable options to be saved in a config file.
821 #-----------------------------------------------------------------------------
822 # Checking for an existing config file - use that one if it exists,
823 # otherwise create one.
824 my_defines = []
825 my_ccflags = []
826 my_cxxflags = []
827 my_ldflags = []
828 if os.path.exists (bs_globals.config_file):
829         print "Using config file: " + bs_globals.config_file
830 else:
831         print "Creating new config file: " + bs_globals.config_file
832         env_dict = env.Dictionary()
833         config=open (bs_globals.config_file, 'w')
834         config.write ("# Configuration file containing user definable options.\n")
835         config.write ("VERSION = %r\n"%(version))
836         config.write ("BUILD_BINARY = 'release'\n")
837         config.write ("USE_BUILDINFO = %r\n"%(use_buildinfo))
838         config.write ("BUILD_BLENDER_DYNAMIC = %r\n"%(build_blender_dynamic))
839         config.write ("BUILD_BLENDER_STATIC = %r\n"%(build_blender_static))
840         config.write ("BUILD_BLENDER_PLAYER = %r\n"%(build_blender_player))
841         config.write ("BUILD_BLENDER_PLUGIN = %r\n"%(build_blender_plugin))
842         config.write ("BUILD_DIR = %r\n"%(bs_globals.root_build_dir))
843         
844         config.write ("\n# Extra compiler flags can be defined here.\n")
845         config.write ("DEFINES = %s\n"%(my_defines))
846         config.write ("CCFLAGS = %s\n"%(my_ccflags))
847         config.write ("CXXFLAGS = %s\n"%(my_cxxflags))
848         config.write ("LDFLAGS = %s\n"%(my_ldflags))
849
850         config.write ("USE_INTERNATIONAL = %r\n"%(use_international))
851         config.write ("BUILD_GAMEENGINE = %r\n"%(use_gameengine))
852         if use_ode == 'true':
853                 config.write ("USE_PHYSICS = 'ode'\n")
854         elif (use_bullet == 'true') and (use_sumo == 'false'):
855                 config.write("USE_PHYSICS = 'bullet'\n")
856         else:
857                 config.write ("USE_PHYSICS = 'solid'\n")
858         config.write ("USE_OPENAL = %r\n"%(use_openal))
859         config.write ("USE_FMOD = %r\n"%(use_fmod))
860         config.write ("USE_QUICKTIME = %r\n"%(use_quicktime))
861         config.write ("USE_FLUIDSIM = %r\n"%(use_fluidsim))
862         config.write ("\n# Compiler information.\n")
863         config.write ("HOST_CC = %r\n"%(env_dict['CC']))
864         config.write ("HOST_CXX = %r\n"%(env_dict['CXX']))
865         config.write ("TARGET_CC = %r\n"%(env_dict['CC']))
866         config.write ("TARGET_CXX = %r\n"%(env_dict['CXX']))
867         config.write ("TARGET_AR = %r\n"%(env_dict['AR']))
868         config.write ("PATH = %r\n"%(os.environ['PATH']))
869         config.write ("\n# External library information.\n")
870         config.write ("PLATFORM_LIBS = %r\n"%(platform_libs))
871         config.write ("PLATFORM_LIBPATH = %r\n"%(platform_libpath))
872         config.write ("PLATFORM_LINKFLAGS = %r\n"%(platform_linkflags))
873         config.write ("PYTHON_INCLUDE = %r\n"%(python_include))
874         config.write ("PYTHON_LIBPATH = %r\n"%(python_libpath))
875         config.write ("PYTHON_LIBRARY = %r\n"%(python_lib))
876         config.write ("PYTHON_LINKFLAGS = %r\n"%(python_linkflags))
877         config.write ("SDL_CFLAGS = %r\n"%(sdl_cflags))
878         config.write ("SDL_INCLUDE = %r\n"%(sdl_include))
879         config.write ("SDL_LIBPATH = %r\n"%(sdl_libpath))
880         config.write ("SDL_LIBRARY = %r\n"%(sdl_lib))
881         config.write ("Z_INCLUDE = %r\n"%(z_include))
882         config.write ("Z_LIBPATH = %r\n"%(z_libpath))
883         config.write ("Z_LIBRARY = %r\n"%(z_lib))
884         config.write ("PNG_INCLUDE = %r\n"%(png_include))
885         config.write ("PNG_LIBPATH = %r\n"%(png_libpath))
886         config.write ("PNG_LIBRARY = %r\n"%(png_lib))
887         config.write ("JPEG_INCLUDE = %r\n"%(jpeg_include))
888         config.write ("JPEG_LIBPATH = %r\n"%(jpeg_libpath))
889         config.write ("JPEG_LIBRARY = %r\n"%(jpeg_lib))
890         config.write ("OPENGL_INCLUDE = %r\n"%(opengl_include))
891         config.write ("OPENGL_LIBPATH = %r\n"%(opengl_libpath))
892         config.write ("OPENGL_LIBRARY = %r\n"%(opengl_lib))
893         config.write ("OPENGL_STATIC = %r\n"%(opengl_static))
894         config.write ("\n# The following information is only necessary when you've enabled support for\n")
895         config.write ("# the game engine.\n")
896         config.write ("SOLID_INCLUDE = %r\n"%(solid_include))
897         config.write ("SOLID_LIBPATH = %r\n"%(solid_libpath))
898         config.write ("SOLID_LIBRARY = %r\n"%(solid_lib))
899         config.write ("QHULL_INCLUDE = %r\n"%(qhull_include))
900         config.write ("QHULL_LIBPATH = %r\n"%(qhull_libpath))
901         config.write ("QHULL_LIBRARY = %r\n"%(qhull_lib))
902         config.write ("ODE_INCLUDE = %r\n"%(ode_include))
903         config.write ("ODE_LIBPATH = %r\n"%(ode_libpath))
904         config.write ("ODE_LIBRARY = %r\n"%(ode_lib))
905         config.write ("BULLET_INCLUDE = %r\n"%(bullet_include))
906         config.write ("BULLET_LIBPATH = %r\n"%(bullet_libpath))
907         config.write ("BULLET_LIBRARY = %r\n"%(bullet_lib))
908         config.write ("OPENAL_INCLUDE = %r\n"%(openal_include))
909         config.write ("OPENAL_LIBPATH = %r\n"%(openal_libpath))
910         config.write ("OPENAL_LIBRARY = %r\n"%(openal_lib))
911         config.write ("\n# The following information is only necessary when building with\n")
912         config.write ("# internationalization support.\n");
913         config.write ("FTGL_INCLUDE = %r\n"%(ftgl_include))
914         config.write ("FTGL_LIBPATH = %r\n"%(ftgl_libpath))
915         config.write ("FTGL_LIBRARY = %r\n"%(ftgl_lib))
916         config.write ("FREETYPE_INCLUDE = %r\n"%(freetype_include))
917         config.write ("FREETYPE_LIBPATH = %r\n"%(freetype_libpath))
918         config.write ("FREETYPE_LIBRARY = %r\n"%(freetype_lib))
919         config.write ("GETTEXT_INCLUDE = %r\n"%(gettext_include))
920         config.write ("GETTEXT_LIBPATH = %r\n"%(gettext_libpath))
921         config.write ("GETTEXT_LIBRARY = %r\n"%(gettext_lib))
922         config.close ()
923
924 #-----------------------------------------------------------------------------
925 # Read the options from the config file and update the various necessary flags
926 #-----------------------------------------------------------------------------
927 list_opts = []
928 user_options = Options (bs_globals.config_file)
929 user_options_env = Environment (ENV = os.environ, options = user_options)
930 user_options.AddOptions (
931                 ('VERSION', 'Blender version', version),
932                 (EnumOption ('BUILD_BINARY', 'release',
933                                         'Select a release or debug binary.',
934                                          allowed_values = ('release', 'debug'))),
935                 (BoolOption ('USE_BUILDINFO',
936                                         'Set to 1 if you want to add build information.',
937                                         'false')),
938                 (BoolOption ('BUILD_BLENDER_DYNAMIC',
939                                         'Set to 1 if you want to build blender with hardware accellerated OpenGL support.',
940                                         'true')),
941                 (BoolOption ('BUILD_BLENDER_STATIC',
942                                         'Set to 1 if you want to build blender with software OpenGL support.',
943                                         'false')),
944                 (BoolOption ('BUILD_BLENDER_PLAYER',
945                                         'Set to 1 if you want to build the blender player.',
946                                         'false')),
947                 (BoolOption ('BUILD_BLENDER_PLUGIN',
948                                         'Set to 1 if you want to build the blender plugin.',
949                                         'false')),
950                 ('BUILD_DIR', 'Target directory for intermediate files.',
951                                         bs_globals.root_build_dir),
952                 (BoolOption ('USE_INTERNATIONAL',
953                                         'Set to 1 to have international support.',
954                                         'false')),
955                 (EnumOption ('USE_PHYSICS', 'solid',
956                                         'Select which physics engine to use.',
957                                         allowed_values = ('ode', 'solid', 'bullet'))),
958                 (BoolOption ('BUILD_GAMEENGINE',
959                                         'Set to 1 to build blender with game engine support.',
960                                         'false')),
961                 (BoolOption ('USE_OPENAL',
962                                         'Set to 1 to build the game engine with OpenAL support.',
963                                         'false')),
964                 (BoolOption ('USE_FMOD',
965                                         'Set to 1 to build the game engine with FMod support.',
966                                         'false')),
967                 (BoolOption ('USE_QUICKTIME',
968                                         'Set to 1 to add support for QuickTime.',
969                                         'false')),
970                 (BoolOption ('USE_FLUIDSIM', # NT test new
971                                         'Set to 0 to disable compilation of fluid simulation library El\'Beem.',
972                                         'true')),
973                 ('HOST_CC', 'C compiler for the host platfor. This is the same as target platform when not cross compiling.'),
974                 ('HOST_CXX', 'C++ compiler for the host platform. This is the same as target platform when not cross compiling.'),
975                 ('TARGET_CC', 'C compiler for the target platform.'),
976                 ('TARGET_CXX', 'C++ compiler for the target platform.'),
977                 ('TARGET_AR', 'Linker command for linking libraries.'),
978                 ('PATH', 'Standard search path'),
979                 ('PLATFORM_LIBS', 'Platform specific libraries.'),
980                 ('PLATFORM_LIBPATH', 'Platform specific library link path.'),
981                 ('PLATFORM_LINKFLAGS', 'Platform specific linkflags'),
982                 ('PYTHON_INCLUDE', 'Include directory for Python header files.'),
983                 ('PYTHON_LIBPATH', 'Library path where the Python lib is located.'),
984                 ('PYTHON_LIBRARY', 'Python library name.'),
985                 ('PYTHON_LINKFLAGS', 'Python specific linkflags.'),
986                 ('SDL_CFLAGS', 'Necessary CFLAGS when using sdl functionality.'),
987                 ('SDL_INCLUDE', 'Include directory for SDL header files.'),
988                 ('SDL_LIBPATH', 'Library path where the SDL library is located.'),
989                 ('SDL_LIBRARY', 'SDL library name.'),
990                 ('Z_INCLUDE', 'Include directory for zlib header files.'),
991                 ('Z_LIBPATH', 'Library path where the zlib library is located.'),
992                 ('Z_LIBRARY', 'Z library name.'),
993                 ('PNG_INCLUDE', 'Include directory for png header files.'),
994                 ('PNG_LIBPATH', 'Library path where the png library is located.'),
995                 ('PNG_LIBRARY', 'png library name.'),
996                 ('JPEG_INCLUDE', 'Include directory for jpeg header files.'),
997                 ('JPEG_LIBPATH', 'Library path where the jpeg library is located.'),
998                 ('JPEG_LIBRARY', 'jpeg library name.'),
999                 ('OPENGL_INCLUDE', 'Include directory for OpenGL header files.'),
1000                 ('OPENGL_LIBPATH', 'Library path where the OpenGL libraries are located.'),
1001                 ('OPENGL_LIBRARY', 'OpenGL library names.'),
1002                 ('OPENGL_STATIC', 'Linker flags for static linking of Open GL.'),
1003                 ('SOLID_INCLUDE', 'Include directory for SOLID header files.'),
1004                 ('SOLID_LIBPATH', 'Library path where the SOLID library is located.'),
1005                 ('SOLID_LIBRARY', 'SOLID library name.'),
1006                 ('QHULL_INCLUDE', 'Include directory for QHULL header files.'),
1007                 ('QHULL_LIBPATH', 'Library path where the QHULL library is located.'),
1008                 ('QHULL_LIBRARY', 'QHULL library name.'),
1009                 ('ODE_INCLUDE', 'Include directory for ODE header files.'),
1010                 ('ODE_LIBPATH', 'Library path where the ODE library is located.'),
1011                 ('ODE_LIBRARY', 'ODE library name.'),
1012                 ('BULLET_INCLUDE', 'Include directory for BULLET header files.'),
1013                 ('BULLET_LIBPATH', 'Library path where the BULLET library is located.'),
1014                 ('BULLET_LIBRARY', 'BULLET library name'),
1015                 ('OPENAL_INCLUDE', 'Include directory for OpenAL header files.'),
1016                 ('OPENAL_LIBPATH', 'Library path where the OpenAL library is located.'),
1017                 ('OPENAL_LIBRARY', 'OpenAL library name.'),
1018                 ('FTGL_INCLUDE', 'Include directory for ftgl header files.'),
1019                 ('FTGL_LIBPATH', 'Library path where the ftgl library is located.'),
1020                 ('FTGL_LIBRARY', 'ftgl library name.'),
1021                 ('FREETYPE_INCLUDE', 'Include directory for freetype2 header files.'),
1022                 ('FREETYPE_LIBPATH', 'Library path where the freetype2 library is located.'),
1023                 ('FREETYPE_LIBRARY', 'Freetype2 library name.'),
1024                 ('GETTEXT_INCLUDE', 'Include directory for gettext header files.'),
1025                 ('GETTEXT_LIBPATH', 'Library path where the gettext library is located.'),
1026                 ('GETTEXT_LIBRARY', 'gettext library name.'),
1027                 ('DEFINES', 'Extra Preprocessor defines.'),
1028                 ('CCFLAGS', 'Extra C Compiler flags.'),
1029                 ('CXXFLAGS','Extra C++ Compiler flags.'),
1030                 ('LDFLAGS', 'Extra Linker flags.')
1031         )
1032 user_options.Update (user_options_env)
1033 user_options_dict = user_options_env.Dictionary()
1034 Help(user_options.GenerateHelpText(user_options_env))
1035 bs_globals.root_build_dir = user_options_dict['BUILD_DIR']
1036 # SET MODULE VARS #
1037 init_env = Environment(ENV = os.environ)
1038
1039 bs_globals.user_options_dict = user_options_dict
1040 bs_globals.init_env = init_env
1041 bs_globals.version = version
1042 bs_globals.shortversion = shortversion
1043 bs_globals.appname = appname
1044 bs_globals.playername = playername
1045 bs_globals.config_guess = config_guess
1046 # END SET MODULE VARS #
1047
1048 if user_options_dict['BUILD_GAMEENGINE'] == 1:
1049         defines += ['GAMEBLENDER=1']
1050         defines += ['USE_BULLET']
1051         if user_options_dict['USE_PHYSICS'] == 'ode':
1052                 defines += ['USE_ODE']
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)