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