ae2242e7c6366e6211ca82e21c61033193245307
[blender.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
9
10 # Blender version.
11 config_file = 'config.opts'
12 version='2.32'
13
14 sdl_env = Environment ()
15 freetype_env = Environment ()
16 link_env = Environment ()
17 env = Environment ()
18
19 if sys.platform == 'linux2':
20     use_international = 'false'
21     use_gameengine = 'false'
22     use_openal = 'false'
23     use_fmod = 'false'
24     use_quicktime = 'false'
25     use_sumo = 'false'
26     use_ode = 'false'
27     use_buildinfo = 'false'
28     build_blender_dynamic = 'true'
29     build_blender_static = 'false'
30     build_blender_player = 'false'
31     build_blender_plugin = 'false'
32     release_flags = ['-O2']
33     debug_flags = ['-O2', '-g']
34     extra_flags = ['-pipe', '-fPIC', '-funsigned-char']
35     cxxflags = []
36     defines = []
37     warn_flags = ['-Wall', '-W']
38     window_system = 'X11'
39     platform_libs = ['m', 'util']
40     platform_libpath = []
41     platform_linkflags = []
42     extra_includes = []
43     # z library information
44     z_lib = ['z']
45     z_libpath = ['/usr/lib']
46     z_include = ['/usr/include']
47     # png library information
48     png_lib = ['png']
49     png_libpath = ['/usr/lib']
50     png_include = ['/usr/include']
51     # jpeg library information
52     jpeg_lib = ['jpeg']
53     jpeg_libpath = ['/usr/lib']
54     jpeg_include = ['/usr/include']
55     # OpenGL library information
56     opengl_lib = ['GL', 'GLU']
57     opengl_static = ['/usr/lib/libGL.a', '/usr/lib/libGLU.a']
58     opengl_libpath = ['/usr/lib', '/usr/X11R6/lib']
59     opengl_include = ['/usr/include']
60     # SDL library information
61     sdl_env.ParseConfig ('sdl-config --cflags --libs')
62     sdl_cflags = sdl_env.Dictionary()['CCFLAGS']
63     sdl_include = sdl_env.Dictionary()['CPPPATH']
64     sdl_libpath = sdl_env.Dictionary()['LIBPATH']
65     sdl_lib = sdl_env.Dictionary()['LIBS']
66     # SOLID library information
67     solid_lib = []                                              # TODO
68     solid_libpath = []                                          # TODO
69     solid_include = ['#extern/solid/include']
70     qhull_lib = []                                              # TODO
71     qhull_libpath = []                                          # TODO
72     qhull_include = ['#extern/qhull/include']
73     # ODE library information
74     ode_lib = ['ode']
75     ode_libpath = ['#../lib/linux-glibc2.2.5-i386/ode/lib']
76     ode_include = ['#../lib/linux-glibc2.2.5-i386/ode/include']
77     # Python library information
78     python_lib = ['python%d.%d' % sys.version_info[0:2]]
79     python_libpath = [sysconfig.get_python_lib (0, 1) + '/config']
80     python_include = [sysconfig.get_python_inc ()]
81     # International support information
82     ftgl_lib = ['ftgl']
83     ftgl_libpath = ['#../lib/linux-glibc2.2.5-i386/ftgl/lib']
84     ftgl_include = ['#../lib/linux-glibc2.2.5-i386/ftgl/include']
85     freetype_env.ParseConfig ('pkg-config --cflags --libs freetype2')
86     freetype_lib = freetype_env.Dictionary()['LIBS']
87     freetype_libpath = freetype_env.Dictionary()['LIBPATH']
88     freetype_include = freetype_env.Dictionary()['CPPPATH']
89     gettext_lib = []
90     gettext_libpath = []
91     gettext_include = []
92     # OpenAL library information
93     openal_lib = ['openal']
94     openal_libpath = ['/usr/lib']
95     openal_include = ['/usr/include']
96
97 elif sys.platform == 'darwin':
98     use_international = 'false'
99     use_gameengine = 'false'
100     use_openal = 'false'
101     use_fmod = 'false'
102     use_quicktime = 'true'
103     use_precomp = 'true'
104     use_sumo = 'false'
105     use_ode = 'false'
106     use_buildinfo = 'false'
107     build_blender_dynamic = 'true'
108     build_blender_static = 'false'
109     build_blender_player = 'false'
110     build_blender_plugin = 'false'
111     # TODO: replace darwin-6.8-powerpc with the actual directiory on the
112     #       build machine
113     darwin_precomp = '#../lib/darwin-6.8-powerpc'
114     extra_flags = ['-pipe', '-fPIC', '-funsigned-char']
115     cxxflags = []
116     defines = ['_THREAD_SAFE']
117     if use_quicktime == 'true':
118         defines += ['WITH_QUICKTIME']
119     warn_flags = ['-Wall', '-W']
120     release_flags = []
121     debug_flags = ['-g']
122     window_system = 'CARBON'
123     # z library information
124     z_lib = ['z']
125     z_libpath = []
126     z_include = []
127     # png library information
128     png_lib = ['png']
129     png_libpath = []
130     png_include = []
131     # jpeg library information
132     jpeg_lib = ['jpeg']
133     jpeg_libpath = []
134     jpeg_include = []
135     # OpenGL library information
136     opengl_lib = ['GL', 'GLU']
137     opengl_static = []
138     opengl_libpath = []
139     opengl_include = []
140     # SDL specific stuff.
141     sdl_env.ParseConfig ('sdl-config --cflags --libs')
142     sdl_cflags = sdl_env.Dictionary()['CCFLAGS']
143     # Want to use precompiled libraries?
144     if use_precomp == 'true':
145         sdl_include = [darwin_precomp + '/sdl/include']
146         sdl_libpath = [darwin_precomp + '/sdl/lib']
147         sdl_lib = ['libSDL.a']
148
149     platform_libs = ['stdc++'] 
150     extra_includes = ['/sw/include']
151     platform_libpath = ['/System/Library/Frameworks/OpenGL.framework/Libraries']
152     platform_linkflags = []
153     # SOLID library information
154     solid_lib = []                                              # TODO
155     solid_libpath = []                                          # TODO
156     solid_include = ['#extern/solid/include']
157     qhull_lib = []                                              # TODO
158     qhull_libpath = []                                          # TODO
159     qhull_include = ['#extern/qhull/include']
160     # ODE library information
161     ode_lib = []                                                # TODO
162     ode_libpath = []                                            # TODO
163     ode_include = ['#extern/ode/dist/include/ode']
164     # Python variables.
165     python_lib = ['python%d.%d' % sys.version_info[0:2]]
166     python_libpath = [sysconfig.get_python_lib (0, 1) + '/config']
167     python_include = [sysconfig.get_python_inc ()]
168     # International stuff
169     ftgl_lib = ['ftgl']
170     ftgl_libpath = [darwin_precomp + '/ftgl/lib']
171     ftgl_include = [darwin_precomp + '/ftgl/include']
172     freetype_lib = ['freetype']
173     freetype_libpath = [darwin_precomp + '/freetype/lib']
174     freetype_include = [darwin_precomp + '/freetype/include']
175     gettext_lib = []
176     gettext_libpath = []
177     gettext_include = []
178     # OpenAL library information
179     openal_lib = []
180     openal_libpath = []
181     openal_include = []
182
183 elif sys.platform == 'cygwin':
184     use_international = 'false'
185     use_gameengine = 'false'
186     use_openal = 'false'
187     use_fmod = 'false'
188     use_quicktime = 'false'
189     use_sumo = 'false'
190     use_ode = 'false'
191     use_buildinfo = 'false'
192     build_blender_dynamic = 'true'
193     build_blender_static = 'false'
194     build_blender_player = 'false'
195     build_blender_plugin = 'false'
196     release_flags = ['-O2']
197     debug_flags = ['-O2', '-g']
198     extra_flags = ['-pipe', '-mno-cygwin', '-mwindows', '-funsigned-char']
199     defines = ['FREE_WINDOWS', 'NDEBUG']
200     cxxflags = []
201     warn_flags = ['-Wall', '-Wno-char-subscripts']
202     platform_libs = ['png', 'jpeg', 'netapi32',
203                      'opengl32', 'glu32', 'winmm',
204                      'mingw32']
205     platform_libpath = ['/usr/lib/w32api', '/lib/w32api']
206     platform_linkflags = ['-mwindows', '-mno-cygwin', '-mconsole']
207     window_system = 'WIN32'
208     extra_includes = ['/usr/include']
209     # z library information
210     z_lib = ['z']
211     z_libpath = ['/usr/lib']
212     z_include = ['/usr/include']
213     # SDL specific stuff.
214     sdl_env.ParseConfig ('sdl-config --cflags --libs')
215     sdl_cflags = sdl_env.Dictionary()['CCFLAGS']
216     sdl_include = sdl_env.Dictionary()['CPPPATH']
217     sdl_libpath = sdl_env.Dictionary()['LIBPATH']
218     sdl_lib = sdl_env.Dictionary()['LIBS']
219     #sdl_cflags = '-DWIN32'
220     # We need to force the Cygwin environment to use the g++ linker.
221     link_env.Replace (CC='g++')
222     # Python variables.
223     python_include = sysconfig.get_python_inc ()
224     python_libpath = sysconfig.get_python_lib (0, 1) + '/config'
225     python_lib = 'python%d.%d' % sys.version_info[0:2]
226     # International stuff
227     ftgl_lib = ['ftgl']
228     ftgl_libpath = ['#../lib/windows/ftgl/lib']
229     ftgl_include = ['#../lib/windows/ftgl/include']
230     freetype_lib = ['freetype']
231     freetype_libpath = ['#../lib/windows/freetype/lib']
232     freetype_include = ['#../lib/windows/freetype/include']
233     gettext_lib = []
234     gettext_libpath = []
235     gettext_include = []
236     # OpenAL library information
237     openal_lib = []
238     openal_libpath = []
239     openal_include = []
240
241 elif sys.platform == 'win32':
242     use_international = 'true'
243     use_gameengine = 'true'
244     use_openal = 'true'
245     use_fmod = 'false'
246     use_quicktime = 'true'
247     use_sumo = 'false'
248     use_ode = 'true'
249     use_buildinfo = 'false'
250     build_blender_dynamic = 'true'
251     build_blender_static = 'false'
252     build_blender_player = 'false'
253     build_blender_plugin = 'false'
254     release_flags = ['/G6', '/GF']
255     debug_flags = ['/Zi']
256     extra_flags = ['/EHsc', '/J', '/W3', '/Gd', '/MT']
257     cxxflags = []
258     defines = ['WIN32', '_CONSOLE']
259     defines += ['WITH_QUICKTIME']
260     defines += ['_LIB', 'USE_OPENAL']
261     warn_flags = []
262     platform_libs = [ 'qtmlClient', 'odelib', 'soundsystem',
263                      'ws2_32', 'dxguid', 'vfw32', 'winmm',
264                      'iconv', 'kernel32', 'user32', 'gdi32',
265                      'winspool', 'comdlg32', 'advapi32', 'shell32',
266                      'ole32', 'oleaut32', 'uuid', 'odbc32', 'odbccp32',
267                      'libcmt', 'libc']
268     platform_libpath = ['#../lib/windows/iconv/lib',
269                         '#../lib/windows/QTDevWin/Libraries']
270     platform_linkflags = [
271                         '/SUBSYSTEM:CONSOLE',
272                         '/MACHINE:IX86',
273                         '/ENTRY:mainCRTStartup',
274                         '/INCREMENTAL:NO',
275                         '/NODEFAULTLIB:"msvcprt.lib"',
276                         '/NODEFAULTLIB:"glut32.lib"',
277                         '/NODEFAULTLIB:"libcd.lib"',
278                         #'/NODEFAULTLIB:"libc.lib"',
279                         '/NODEFAULTLIB:"libcpd.lib"',
280                         '/NODEFAULTLIB:"libcp.lib"',
281                         '/NODEFAULTLIB:"libcmtd.lib"',
282                         ]
283     window_system = 'WIN32'
284     extra_includes = []
285     if use_quicktime == 'true':
286         extra_includes += ['#../lib/windows/QTDevWin/CIncludes']
287     # z library information
288     z_lib = ['libz_st']
289     z_libpath = ['#../lib/windows/zlib/lib']
290     z_include = ['#../lib/windows/zlib/include']
291     # png library information
292     png_lib = ['libpng_st']
293     png_libpath = ['#../lib/windows/png/lib']
294     png_include = ['#../lib/windows/png/include']
295     # jpeg library information
296     jpeg_lib = ['libjpeg']
297     jpeg_libpath = ['#../lib/windows/jpeg/lib']
298     jpeg_include = ['#../lib/windows/jpeg/include']
299     # OpenGL library information
300     opengl_lib = ['opengl32', 'glu32']
301     opengl_static = []
302     opengl_libpath = []
303     opengl_include = ['/usr/include']
304     # SDL library information
305     sdl_include = ['#../lib/windows/sdl/include']
306     sdl_libpath = ['#../lib/windows/sdl/lib']
307     sdl_lib = ['SDL']
308     sdl_cflags = []
309     link_env.RES(['source/icons/winblender.rc'])
310     window_system = 'WIN32'
311     # SOLID library information
312     solid_lib = ['solid']
313     solid_libpath = ['#../lib/windows/solid/lib']
314     solid_include = ['#../lib/windows/solid/include']
315     qhull_lib = ['qhull']
316     qhull_libpath = ['#../lib/windows/qhull/lib']
317     qhull_include = ['#extern/qhull/include']
318     # ODE library information
319     ode_lib = []                                                # TODO
320     ode_libpath = ['#../lib/windows/ode/lib']
321     ode_include = ['#../lib/windows/ode/include']
322     # Python lib name
323     python_include = ['#../lib/windows/python/include/python2.2']
324     python_libpath = ['#../lib/windows/python/lib']
325     python_lib = ['python22']
326     # International stuff
327     ftgl_lib = ['ftgl_static_ST']
328     ftgl_libpath = ['#../lib/windows/ftgl/lib']
329     ftgl_include = ['#../lib/windows/ftgl/include']
330     freetype_lib = ['freetype2ST']
331     freetype_libpath = ['#../lib/windows/freetype/lib']
332     freetype_include = ['#../lib/windows/freetype/include']
333     gettext_lib = ['gnu_gettext']
334     gettext_libpath = ['#../lib/windows/gettext/lib']
335     gettext_include = ['#../lib/windows/gettext/include']
336     # OpenAL library information
337     openal_lib = ['openal_static']
338     openal_libpath = ['#../lib/windows/openal/lib']
339     openal_include = ['#../lib/windows/openal/include']
340
341 elif string.find (sys.platform, 'sunos') != -1:
342     use_international = 'true'
343     use_gameengine = 'false'
344     use_openal = 'false'
345     use_fmod = 'false'
346     use_quicktime = 'false'
347     use_sumo = 'false'
348     use_ode = 'false'
349     use_buildinfo = 'false'
350     build_blender_dynamic = 'true'
351     build_blender_static = 'false'
352     build_blender_player = 'false'
353     build_blender_plugin = 'false'
354     release_flags = ['-O2']
355     debug_flags = ['-O2', '-g']
356     extra_flags = ['-pipe', '-fPIC', '-funsigned-char']
357     cxxflags = []
358     defines = []
359     env['ENV']['CC']='gcc'
360     env['ENV']['CXX']='g++'
361     warn_flags = ['-Wall', '-W']
362     window_system = 'X11'
363     platform_libs = ['m', 'util']
364     platform_libpath = []
365     platform_linkflags = []
366     extra_includes = []
367     # z library information
368     z_lib = ['z']
369     z_libpath = []
370     z_include = []
371     # png library information
372     png_lib = ['png']
373     png_libpath = []
374     png_include = []
375     # jpeg library information
376     jpeg_lib = ['jpeg']
377     jpeg_libpath = []
378     jpeg_include = []
379     # OpenGL library information
380     opengl_lib = ['GL', 'GLU']
381     opengl_static = []
382     opengl_libpath = []
383     opengl_include = []
384     # SDL library information
385     sdl_env.ParseConfig ('sdl-config --cflags --libs')
386     sdl_cflags = sdl_env.Dictionary()['CCFLAGS']
387     sdl_include = sdl_env.Dictionary()['CPPPATH']
388     sdl_libpath = sdl_env.Dictionary()['LIBPATH']
389     sdl_lib = sdl_env.Dictionary()['LIBS']
390     # SOLID library information
391     solid_lib = []                                              # TODO
392     solid_libpath = []                                          # TODO
393     solid_include = ['#extern/solid/include']
394     qhull_lib = []                                              # TODO
395     qhull_libpath = []                                          # TODO
396     qhull_include = ['#extern/qhull/include']
397     # ODE library information
398     ode_lib = []                                                # TODO
399     ode_libpath = []                                            # TODO
400     ode_include = ['#extern/ode/dist/include/ode']
401     # Python variables.
402     python_lib = ['python%d.%d' % sys.version_info[0:2]]
403     python_libpath = [sysconfig.get_python_lib (0, 1) + '/config']
404     python_include = [sysconfig.get_python_inc ()]
405     # International support information
406     ftgl_lib = ['ftgl']
407     ftgl_libpath = ['#../lib/solaris-2.8-sparc/ftgl/lib']
408     ftgl_include = ['#../lib/solaris-2.8-sparc/ftgl/include']
409     freetype_lib = ['freetype']
410     freetype_libpath = ['#../lib/solaris-2.8-sparc/freetype/lib']
411     freetype_include = ['#../lib/solaris-2.8-sparc/freetype/include']
412     gettext_lib = []
413     gettext_libpath = []
414     gettext_include = []
415     # OpenAL library information
416     openal_lib = []
417     openal_libpath = []
418     openal_include = []
419
420 elif string.find (sys.platform, 'irix') != -1:
421     use_international = 'false'
422     use_gameengine = 'false'
423     use_openal = 'false'
424     use_fmod = 'false'
425     use_quicktime = 'false'
426     use_sumo = 'false'
427     use_ode = 'false'
428     use_buildinfo = 'false'
429     build_blender_dynamic = 'true'
430     build_blender_static = 'false'
431     build_blender_player = 'false'
432     build_blender_plugin = 'false'
433     irix_precomp = '#../lib/irix-6.5-mips'
434     extra_flags = ['-n32', '-mips3', '-Xcpluscomm']
435     cxxflags = ['-n32', '-mips3', '-Xcpluscomm', '-LANG:std']
436     cxxflags += ['-LANG:libc_in_namespace_std=off']
437     
438     window_system = 'X11'
439     release_flags = ['-O2', '-OPT:Olimit=0']
440     debug_flags = ['-O2', '-g']
441     defines = []
442     warn_flags = ['-fullwarn', '-woff', '1001,1110,1201,1209,1355,1424,1681,3201']
443     platform_libs = ['movieGL', 'Xmu', 'Xext', 'X11',
444                      'c', 'm', 'dmedia', 'cl', 'audio',
445                      'Cio', 'pthread']
446     platform_libpath = ['/usr/lib32/mips3',
447                         '/lib/freeware/lib32',
448                         '/usr/lib32']
449     platform_linkflags = ['-mips3', '-n32']
450     extra_includes = ['/usr/freeware/include',
451                       '/usr/include']
452     # z library information
453     z_lib = ['z']
454     z_libpath = []
455     z_include = []
456     # png library information
457     png_lib = ['png']
458     png_libpath = [irix_precomp + '/png/lib']
459     png_include = [irix_precomp + '/png/include']
460     # jpeg library information
461     jpeg_lib = ['jpeg']
462     jpeg_libpath = [irix_precomp + '/jpeg/lib']
463     jpeg_include = [irix_precomp + '/jpeg/include']
464     # OpenGL library information
465     opengl_lib = ['GL', 'GLU']
466     opengl_static = []
467     opengl_libpath = []
468     opengl_include = []
469     # SDL library information
470     sdl_cflags = []
471     sdl_include = [irix_precomp + '/sdl/include/SDL']
472     sdl_libpath = [irix_precomp + '/sdl/lib']
473     sdl_lib = ['SDL', 'libSDL.a']
474     # SOLID library information
475     solid_lib = []                                              # TODO
476     solid_libpath = []                                          # TODO
477     solid_include = [irix_precomp + '/solid/include']
478     qhull_lib = []                                              # TODO
479     qhull_libpath = []                                          # TODO
480     qhull_include = ['#extern/qhull/include']
481     # ODE library information
482     ode_lib = []                                                # TODO
483     ode_libpath = []                                            # TODO
484     ode_include = [irix_precomp + '/ode/include']
485     # Python library information
486     python_libpath = [irix_precomp + '/python/lib/python2.2/config']
487     python_include = [irix_precomp + '/python/include/python2.2']
488     python_lib = ['python2.2']
489     # International support information
490     ftgl_lib = ['ftgl']
491     ftgl_libpath = [irix_precomp + '/ftgl/lib']
492     ftgl_include = [irix_precomp + '/ftgl/include']
493     freetype_lib = ['freetype']
494     freetype_libpath = [irix_precomp + '/freetype/lib']
495     freetype_include = [irix_precomp + '/freetype/include']
496     gettext_lib = []
497     gettext_libpath = []
498     gettext_include = []
499     # OpenAL library information
500     openal_lib = []
501     openal_libpath = []
502     openal_include = []
503
504 elif string.find (sys.platform, 'hp-ux') != -1:
505     window_system = 'X11'
506     defines = []
507
508 else:
509     print "Unknown platform"
510
511 #-----------------------------------------------------------------------------
512 # End of platform specific section
513 #-----------------------------------------------------------------------------
514
515 #-----------------------------------------------------------------------------
516 # User configurable options to be saved in a config file.
517 #-----------------------------------------------------------------------------
518 # Checking for an existing config file - use that one if it exists,
519 # otherwise create one.
520 if os.path.exists (config_file):
521     print "Using config file: " + config_file
522 else:
523     print "Creating new config file: " + config_file
524     config=open (config_file, 'w')
525     config.write ("# Configuration file containing user definable options.\n")
526     config.write ("VERSION = '2.32-cvs'\n")
527     config.write ("BUILD_BINARY = 'release'\n")
528     config.write ("USE_BUILDINFO = %r\n"%(use_buildinfo))
529     config.write ("BUILD_BLENDER_DYNAMIC = %r\n"%(build_blender_dynamic))
530     config.write ("BUILD_BLENDER_STATIC = %r\n"%(build_blender_static))
531     config.write ("BUILD_BLENDER_PLAYER = %r\n"%(build_blender_player))
532     config.write ("BUILD_BLENDER_PLUGIN = %r\n"%(build_blender_plugin))
533     config.write ("BUILD_DIR = %r\n"%(root_build_dir))
534     config.write ("USE_INTERNATIONAL = %r\n"%(use_international))
535     config.write ("BUILD_GAMEENGINE = %r\n"%(use_gameengine))
536     if use_sumo == 'true':
537         config.write ("USE_PHYSICS = 'solid'\n")
538     else:
539         config.write ("USE_PHYSICS = 'ode'\n")
540     config.write ("USE_OPENAL = %r\n"%(use_openal))
541     config.write ("USE_FMOD = %r\n"%(use_fmod))
542     config.write ("USE_QUICKTIME = %r\n"%(use_quicktime))
543     config.write ("\n# External library information.\n")
544     config.write ("PYTHON_INCLUDE = %r\n"%(python_include))
545     config.write ("PYTHON_LIBPATH = %r\n"%(python_libpath))
546     config.write ("PYTHON_LIBRARY = %r\n"%(python_lib))
547     config.write ("SDL_CFLAGS = %r\n"%(sdl_cflags))
548     config.write ("SDL_INCLUDE = %r\n"%(sdl_include))
549     config.write ("SDL_LIBPATH = %r\n"%(sdl_libpath))
550     config.write ("SDL_LIBRARY = %r\n"%(sdl_lib))
551     config.write ("Z_INCLUDE = %r\n"%(z_include))
552     config.write ("Z_LIBPATH = %r\n"%(z_libpath))
553     config.write ("Z_LIBRARY = %r\n"%(z_lib))
554     config.write ("PNG_INCLUDE = %r\n"%(png_include))
555     config.write ("PNG_LIBPATH = %r\n"%(png_libpath))
556     config.write ("PNG_LIBRARY = %r\n"%(png_lib))
557     config.write ("JPEG_INCLUDE = %r\n"%(jpeg_include))
558     config.write ("JPEG_LIBPATH = %r\n"%(jpeg_libpath))
559     config.write ("JPEG_LIBRARY = %r\n"%(jpeg_lib))
560     config.write ("OPENGL_INCLUDE = %r\n"%(opengl_include))
561     config.write ("OPENGL_LIBPATH = %r\n"%(opengl_libpath))
562     config.write ("OPENGL_LIBRARY = %r\n"%(opengl_lib))
563     config.write ("OPENGL_STATIC = %r\n"%(opengl_static))
564     config.write ("\n# The following information is only necessary when you've enabled support for\n")
565     config.write ("# the game engine.\n")
566     config.write ("SOLID_INCLUDE = %r\n"%(solid_include))
567     config.write ("SOLID_LIBPATH = %r\n"%(solid_libpath))
568     config.write ("SOLID_LIBRARY = %r\n"%(solid_lib))
569     config.write ("QHULL_INCLUDE = %r\n"%(qhull_include))
570     config.write ("QHULL_LIBPATH = %r\n"%(qhull_libpath))
571     config.write ("QHULL_LIBRARY = %r\n"%(qhull_lib))
572     config.write ("ODE_INCLUDE = %r\n"%(ode_include))
573     config.write ("ODE_LIBPATH = %r\n"%(ode_libpath))
574     config.write ("ODE_LIBRARY = %r\n"%(ode_lib))
575     config.write ("OPENAL_INCLUDE = %r\n"%(openal_include))
576     config.write ("OPENAL_LIBPATH = %r\n"%(openal_libpath))
577     config.write ("OPENAL_LIBRARY = %r\n"%(openal_lib))
578     config.write ("\n# The following information is only necessary when building with\n")
579     config.write ("# internationalization support.\n");
580     config.write ("FTGL_INCLUDE = %r\n"%(ftgl_include))
581     config.write ("FTGL_LIBPATH = %r\n"%(ftgl_libpath))
582     config.write ("FTGL_LIBRARY = %r\n"%(ftgl_lib))
583     config.write ("FREETYPE_INCLUDE = %r\n"%(freetype_include))
584     config.write ("FREETYPE_LIBPATH = %r\n"%(freetype_libpath))
585     config.write ("FREETYPE_LIBRARY = %r\n"%(freetype_lib))
586     config.write ("GETTEXT_INCLUDE = %r\n"%(gettext_include))
587     config.write ("GETTEXT_LIBPATH = %r\n"%(gettext_libpath))
588     config.write ("GETTEXT_LIBRARY = %r\n"%(gettext_lib))
589     config.close ()
590
591 #-----------------------------------------------------------------------------
592 # Read the options from the config file and update the various necessary flags
593 #-----------------------------------------------------------------------------
594 list_opts = []
595 user_options_env = Environment ()
596 user_options = Options (config_file)
597 user_options.AddOptions (
598         ('VERSION', 'Blender version', version),
599         (EnumOption ('BUILD_BINARY', 'release',
600                      'Select a release or debug binary.',
601                      allowed_values = ('release', 'debug'))),
602         (BoolOption ('USE_BUILDINFO',
603                      'Set to 1 if you want to add build information.',
604                      'false')),
605         (BoolOption ('BUILD_BLENDER_DYNAMIC',
606                      'Set to 1 if you want to build blender with hardware accellerated OpenGL support.',
607                      'true')),
608         (BoolOption ('BUILD_BLENDER_STATIC',
609                      'Set to 1 if you want to build blender with software OpenGL support.',
610                      'false')),
611         (BoolOption ('BUILD_BLENDER_PLAYER',
612                      'Set to 1 if you want to build the blender player.',
613                      'false')),
614         (BoolOption ('BUILD_BLENDER_PLUGIN',
615                      'Set to 1 if you want to build the blender plugin.',
616                      'false')),
617         ('BUILD_DIR', 'Target directory for intermediate files.',
618                      root_build_dir),
619         (BoolOption ('USE_INTERNATIONAL',
620                      'Set to 1 to have international support.',
621                      'false')),
622         (EnumOption ('USE_PHYSICS', 'solid',
623                      'Select which physics engine to use.',
624                      allowed_values = ('ode', 'solid'))),
625         (BoolOption ('BUILD_GAMEENGINE',
626                      'Set to 1 to build blender with game engine support.',
627                      'false')),
628         (BoolOption ('USE_OPENAL',
629                      'Set to 1 to build the game engine with OpenAL support.',
630                      'false')),
631         (BoolOption ('USE_FMOD',
632                      'Set to 1 to build the game engine with FMod support.',
633                      'false')),
634         (BoolOption ('USE_QUICKTIME',
635                      'Set to 1 to add support for QuickTime.',
636                      'false')),
637         ('PYTHON_INCLUDE', 'Include directory for Python header files.'),
638         ('PYTHON_LIBPATH', 'Library path where the Python lib is located.'),
639         ('PYTHON_LIBRARY', 'Python library name.'),
640         ('SDL_CFLAGS', 'Necessary CFLAGS when using sdl functionality.'),
641         ('SDL_INCLUDE', 'Include directory for SDL header files.'),
642         ('SDL_LIBPATH', 'Library path where the SDL library is located.'),
643         ('SDL_LIBRARY', 'SDL library name.'),
644         ('Z_INCLUDE', 'Include directory for zlib header files.'),
645         ('Z_LIBPATH', 'Library path where the zlib library is located.'),
646         ('Z_LIBRARY', 'Z library name.'),
647         ('PNG_INCLUDE', 'Include directory for png header files.'),
648         ('PNG_LIBPATH', 'Library path where the png library is located.'),
649         ('PNG_LIBRARY', 'png library name.'),
650         ('JPEG_INCLUDE', 'Include directory for jpeg header files.'),
651         ('JPEG_LIBPATH', 'Library path where the jpeg library is located.'),
652         ('JPEG_LIBRARY', 'jpeg library name.'),
653         ('OPENGL_INCLUDE', 'Include directory for OpenGL header files.'),
654         ('OPENGL_LIBPATH', 'Library path where the OpenGL libraries are located.'),
655         ('OPENGL_LIBRARY', 'OpenGL library names.'),
656         ('OPENGL_STATIC', 'Linker flags for static linking of Open GL.'),
657         ('SOLID_INCLUDE', 'Include directory for SOLID header files.'),
658         ('SOLID_LIBPATH', 'Library path where the SOLID library is located.'),
659         ('SOLID_LIBRARY', 'SOLID library name.'),
660         ('QHULL_INCLUDE', 'Include directory for QHULL header files.'),
661         ('QHULL_LIBPATH', 'Library path where the QHULL library is located.'),
662         ('QHULL_LIBRARY', 'QHULL library name.'),
663         ('ODE_INCLUDE', 'Include directory for ODE header files.'),
664         ('ODE_LIBPATH', 'Library path where the ODE library is located.'),
665         ('ODE_LIBRARY', 'ODE library name.'),
666         ('OPENAL_INCLUDE', 'Include directory for OpenAL header files.'),
667         ('OPENAL_LIBPATH', 'Library path where the OpenAL library is located.'),
668         ('OPENAL_LIBRARY', 'OpenAL library name.'),
669         ('FTGL_INCLUDE', 'Include directory for ftgl header files.'),
670         ('FTGL_LIBPATH', 'Library path where the ftgl library is located.'),
671         ('FTGL_LIBRARY', 'ftgl library name.'),
672         ('FREETYPE_INCLUDE', 'Include directory for freetype2 header files.'),
673         ('FREETYPE_LIBPATH', 'Library path where the freetype2 library is located.'),
674         ('FREETYPE_LIBRARY', 'Freetype2 library name.'),
675         ('GETTEXT_INCLUDE', 'Include directory for gettext header files.'),
676         ('GETTEXT_LIBPATH', 'Library path where the gettext library is located.'),
677         ('GETTEXT_LIBRARY', 'gettext library name.')
678     )
679 user_options.Update (user_options_env)
680 user_options_dict = user_options_env.Dictionary()
681
682 root_build_dir = user_options_dict['BUILD_DIR']
683     
684 if user_options_dict['BUILD_GAMEENGINE'] == 1:
685     defines += ['GAMEBLENDER=1']
686     if user_options_dict['USE_PHYSICS'] == 'ode':
687         defines += ['USE_ODE']
688     else:
689         defines += ['USE_SUMO_SOLID']
690 else:
691     defines += ['GAMEBLENDER=0']
692
693 if user_options_dict['BUILD_BINARY'] == 'release':
694     cflags = extra_flags + release_flags + warn_flags
695     if sys.platform == 'win32':
696         defines += ['NDEBUG']
697 else:
698     cflags = extra_flags + debug_flags + warn_flags
699     if sys.platform == 'win32':
700         #defines += ['_DEBUG'] specifying this makes msvc want to link to python22_d.lib??
701         platform_linkflags += ['/DEBUG','/PDB:blender.pdb']
702
703 #-----------------------------------------------------------------------------
704 # Settings to be exported to other SConscript files
705 #-----------------------------------------------------------------------------
706
707 Export ('cflags')
708 Export ('defines')
709 Export ('cxxflags')
710 Export ('window_system')
711 Export ('extra_includes')
712 Export ('platform_libs')
713 Export ('platform_libpath')
714 Export ('platform_linkflags')
715 Export ('user_options_dict')
716
717 BuildDir (root_build_dir+'/intern', 'intern', duplicate=0)
718 SConscript (root_build_dir+'intern/SConscript')
719 BuildDir (root_build_dir+'/source', 'source', duplicate=0)
720 SConscript (root_build_dir+'source/SConscript')
721
722 libpath = (['#'+root_build_dir+'/lib'])
723
724 libraries = (['blender_creator',
725               'blender_render',
726               'blender_yafray',
727               'blender_blendersrc',
728               'blender_renderconverter',
729               'blender_blenloader',
730               'blender_writestreamglue',
731               'blender_deflate',
732               'blender_writeblenfile',
733               'blender_readblenfile',
734               'blender_readstreamglue',
735               'blender_inflate',
736               'blender_img',
737               'blender_radiosity',
738               'blender_blenkernel',
739               'blender_blenpluginapi',
740               'blender_imbuf',
741               'blender_avi',
742               'blender_blenlib',
743               'blender_python',
744               'blender_makesdna',
745               'blender_kernel',
746               'blender_BSP',
747               'blender_LOD',
748               'blender_GHOST',
749               'blender_STR',
750               'blender_guardedalloc',
751               'blender_BMF',
752               'blender_CTR',
753               'blender_MEM',
754               'blender_IK',
755               'blender_MT',
756               'soundsystem'])
757
758 link_env.Append (LIBS=libraries)
759 link_env.Append (LIBPATH=libpath)
760 link_env.Append (CPPDEFINES=defines)
761
762 if user_options_dict['USE_INTERNATIONAL'] == 1:
763     link_env.Append (LIBS=user_options_dict['FREETYPE_LIBRARY'])
764     link_env.Append (LIBPATH=user_options_dict['FREETYPE_LIBPATH'])
765     link_env.Append (LIBS=['blender_FTF'])
766     link_env.Append (LIBS=user_options_dict['FTGL_LIBRARY'])
767     link_env.Append (LIBPATH=user_options_dict['FTGL_LIBPATH'])
768     link_env.Append (LIBS=user_options_dict['FREETYPE_LIBRARY'])
769 if user_options_dict['USE_QUICKTIME'] == 1:
770     link_env.Append (LIBS=['blender_quicktime'])
771 if user_options_dict['BUILD_GAMEENGINE'] == 1:
772     link_env.Append (LIBS=['KX_blenderhook',
773                            'KX_converter',
774                            'PHY_Dummy',
775                            'PHY_Physics',
776                            'KX_ketsji',
777                            'SCA_GameLogic',
778                            'RAS_rasterizer',
779                            'RAS_OpenGLRasterizer',
780                            'blender_expressions',
781                            'SG_SceneGraph',
782                            'blender_MT',
783                            'KX_blenderhook',
784                            'KX_network',
785                            'blender_kernel',
786                            'NG_network',
787                            'NG_loopbacknetwork'])
788     if user_options_dict['USE_PHYSICS'] == 'solid':
789         link_env.Append (LIBS=['PHY_Sumo'])
790         link_env.Append (LIBS=user_options_dict['SOLID_LIBRARY'])
791         link_env.Append (LIBPATH=user_options_dict['SOLID_LIBPATH'])
792         link_env.Append (LIBS=user_options_dict['QHULL_LIBRARY'])
793         link_env.Append (LIBPATH=user_options_dict['QHULL_LIBPATH'])
794     else:
795         link_env.Append (LIBS=['PHY_Ode',
796                                'PHY_Physics'])
797         link_env.Append (LIBS=user_options_dict['ODE_LIBRARY'])
798         link_env.Append (LIBPATH=user_options_dict['ODE_LIBPATH'])
799
800 link_env.Append (LIBS=user_options_dict['PYTHON_LIBRARY'])
801 link_env.Append (LIBPATH=user_options_dict['PYTHON_LIBPATH'])
802 link_env.Append (LIBS=user_options_dict['SDL_LIBRARY'])
803 link_env.Append (LIBPATH=user_options_dict['SDL_LIBPATH'])
804 link_env.Append (LIBS=user_options_dict['PNG_LIBRARY'])
805 link_env.Append (LIBPATH=user_options_dict['PNG_LIBPATH'])
806 link_env.Append (LIBS=user_options_dict['JPEG_LIBRARY'])
807 link_env.Append (LIBPATH=user_options_dict['JPEG_LIBPATH'])
808 link_env.Append (LIBS=user_options_dict['GETTEXT_LIBRARY'])
809 link_env.Append (LIBPATH=user_options_dict['GETTEXT_LIBPATH'])
810 link_env.Append (LIBS=user_options_dict['Z_LIBRARY'])
811 link_env.Append (LIBPATH=user_options_dict['Z_LIBPATH'])
812 if user_options_dict['USE_OPENAL'] == 1:
813     link_env.Append (LIBS=user_options_dict['OPENAL_LIBRARY'])
814     link_env.Append (LIBPATH=user_options_dict['OPENAL_LIBPATH'])
815 link_env.Append (LIBS=platform_libs)
816 link_env.Append (LIBPATH=platform_libpath)
817 if sys.platform == 'darwin':
818     link_env.Append (LINKFLAGS=' -framework Carbon')
819     link_env.Append (LINKFLAGS=' -framework AGL')
820     if user_options_dict['USE_QUICKTIME'] == 1:
821         link_env.Append (LINKFLAGS=' -framework QuickTime')
822 else:
823     link_env.Append (LINKFLAGS=platform_linkflags)
824
825 link_env.BuildDir (root_build_dir, '.', duplicate=0)
826
827 build_date = time.strftime ("%Y-%m-%d")
828 build_time = time.strftime ("%H:%M:%S")
829
830 if user_options_dict['BUILD_BLENDER_DYNAMIC'] == 1:
831     dy_blender = link_env.Copy ()
832     dy_blender.Append (LIBS=user_options_dict['OPENGL_LIBRARY'])
833     dy_blender.Append (LIBPATH=user_options_dict['OPENGL_LIBPATH'])
834     if user_options_dict['USE_BUILDINFO'] == 1:
835         dy_blender.Append (CPPDEFINES = ['BUILD_TIME=\'"%s"\''%(build_time),
836                                          'BUILD_DATE=\'"%s"\''%(build_date),
837                                          'BUILD_TYPE=\'"dynamic"\'',
838                                          'NAN_BUILDINFO',
839                                          'BUILD_PLATFORM=\'"%s"\''%(sys.platform)])
840     dy_blender.Append (CCFLAGS=cflags)
841     d_obj = [dy_blender.Object (root_build_dir+'source/creator/d_buildinfo',
842                                 [root_build_dir+'source/creator/buildinfo.c'])]
843     if sys.platform == 'win32':
844         dy_blender.Program (target='blender',
845                             source=d_obj + ['source/icons/winblender.res'])
846     else:
847         dy_blender.Program (target='blender', source=d_obj)
848 if user_options_dict['BUILD_BLENDER_STATIC'] == 1:
849     st_blender = link_env.Copy ()
850     if user_options_dict['USE_BUILDINFO'] == 1:
851         st_blender.Append (CPPDEFINES = ['BUILD_TIME=\'"%s"\''%(build_time),
852                                          'BUILD_DATE=\'"%s"\''%(build_date),
853                                          'BUILD_TYPE=\'"static"\'',
854                                          'NAN_BUILDINFO',
855                                          'BUILD_PLATFORM=\'"%s"\''%(sys.platform)])
856     st_blender.Append (CCFLAGS=cflags)
857     st_blender.Append (LINKFLAGS=user_options_dict['OPENGL_STATIC'])
858     s_obj = [st_blender.Object (root_build_dir+'source/creator/s_buildinfo',
859                                 [root_build_dir+'source/creator/buildinfo.c'])]
860     st_blender.Prepend (LIBPATH=['/usr/lib/opengl/xfree/lib'])
861     st_blender.Program (target='blenderstatic', source=s_obj)
862
863 if sys.platform == 'darwin':
864     bundle = Environment ()
865     blender_app = 'blender'
866     bundle.Depends ('#/blender.app/Contents/MacOS/' + blender_app, blender_app)
867     bundle.Command ('#/blender.app/Contents/Info.plist',
868                     '#/source/darwin/blender.app/Contents/Info.plist',
869                     "rm -rf blender.app && " + \
870                     "cp -R source/darwin/blender.app . && " +
871                     "cat $SOURCE | sed s/VERSION/`cat release/VERSION`/ | \
872                                    sed s/DATE/`date +'%Y-%b-%d'`/ \
873                                    > $TARGET")
874     bundle.Command ('blender.app/Contents/MacOS/' + blender_app, blender_app,
875                     'cp $SOURCE $TARGET && ' + \
876                     'chmod +x $TARGET && ' + \
877                     'find $SOURCE -name CVS -prune -exec rm -rf {} \; && ' +
878                     'find $SOURCE -name .DS_Store -exec rm -rf {} \;')