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