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