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