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