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