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