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