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