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