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