SCons updates
[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     # Python variables.
221     python_include = sysconfig.get_python_inc ()
222     python_libpath = sysconfig.get_python_lib (0, 1) + '/config'
223     python_lib = 'python%d.%d' % sys.version_info[0:2]
224     # International stuff
225     ftgl_lib = ['ftgl']
226     ftgl_libpath = ['#../lib/windows/ftgl/lib']
227     ftgl_include = ['#../lib/windows/ftgl/include']
228     freetype_lib = ['freetype']
229     freetype_libpath = ['#../lib/windows/freetype/lib']
230     freetype_include = ['#../lib/windows/freetype/include']
231     gettext_lib = []
232     gettext_libpath = []
233     gettext_include = []
234     # OpenAL library information
235     openal_lib = []
236     openal_libpath = []
237     openal_include = []
238
239 elif sys.platform == 'win32':
240     use_international = 'true'
241     use_gameengine = 'true'
242     use_openal = 'true'
243     use_fmod = 'false'
244     use_quicktime = 'true'
245     use_sumo = 'false'
246     use_ode = 'true'
247     use_buildinfo = 'false'
248     build_blender_dynamic = 'true'
249     build_blender_static = 'false'
250     build_blender_player = 'false'
251     build_blender_plugin = 'false'
252     release_flags = ['/G6', '/GF']
253     debug_flags = ['/Zi']
254     extra_flags = ['/EHsc', '/J', '/W3', '/Gd', '/MT']
255     cxxflags = []
256     defines = ['WIN32', '_CONSOLE']
257     defines += ['WITH_QUICKTIME']
258     defines += ['_LIB', 'USE_OPENAL']
259     warn_flags = []
260     platform_libs = [ 'qtmlClient', 'odelib', 'soundsystem',
261                      'ws2_32', 'dxguid', 'vfw32', 'winmm',
262                      'iconv', 'kernel32', 'user32', 'gdi32',
263                      'winspool', 'comdlg32', 'advapi32', 'shell32',
264                      'ole32', 'oleaut32', 'uuid', 'odbc32', 'odbccp32',
265                      'libcmt', 'libc']
266     platform_libpath = ['#../lib/windows/iconv/lib',
267                         '#../lib/windows/QTDevWin/Libraries']
268     platform_linkflags = [
269                         '/SUBSYSTEM:CONSOLE',
270                         '/MACHINE:IX86',
271                         '/ENTRY:mainCRTStartup',
272                         '/INCREMENTAL:NO',
273                         '/NODEFAULTLIB:"msvcprt.lib"',
274                         '/NODEFAULTLIB:"glut32.lib"',
275                         '/NODEFAULTLIB:"libcd.lib"',
276                         #'/NODEFAULTLIB:"libc.lib"',
277                         '/NODEFAULTLIB:"libcpd.lib"',
278                         '/NODEFAULTLIB:"libcp.lib"',
279                         '/NODEFAULTLIB:"libcmtd.lib"',
280                         ]
281     window_system = 'WIN32'
282     extra_includes = []
283     if use_quicktime == 'true':
284         extra_includes += ['#../lib/windows/QTDevWin/CIncludes']
285     # z library information
286     z_lib = ['libz_st']
287     z_libpath = ['#../lib/windows/zlib/lib']
288     z_include = ['#../lib/windows/zlib/include']
289     # png library information
290     png_lib = ['libpng_st']
291     png_libpath = ['#../lib/windows/png/lib']
292     png_include = ['#../lib/windows/png/include']
293     # jpeg library information
294     jpeg_lib = ['libjpeg']
295     jpeg_libpath = ['#../lib/windows/jpeg/lib']
296     jpeg_include = ['#../lib/windows/jpeg/include']
297     # OpenGL library information
298     opengl_lib = ['opengl32', 'glu32']
299     opengl_static = []
300     opengl_libpath = []
301     opengl_include = ['/usr/include']
302     # SDL library information
303     sdl_include = ['#../lib/windows/sdl/include']
304     sdl_libpath = ['#../lib/windows/sdl/lib']
305     sdl_lib = ['SDL']
306     sdl_cflags = []
307     link_env.RES(['source/icons/winblender.rc'])
308     window_system = 'WIN32'
309     # SOLID library information
310     solid_lib = ['solid']
311     solid_libpath = ['#../lib/windows/solid/lib']
312     solid_include = ['#../lib/windows/solid/include']
313     qhull_lib = ['qhull']
314     qhull_libpath = ['#../lib/windows/qhull/lib']
315     qhull_include = ['#extern/qhull/include']
316     # ODE library information
317     ode_lib = []                                                # TODO
318     ode_libpath = ['#../lib/windows/ode/lib']
319     ode_include = ['#../lib/windows/ode/include']
320     # Python lib name
321     python_include = ['#../lib/windows/python/include/python2.2']
322     python_libpath = ['#../lib/windows/python/lib']
323     python_lib = ['python22']
324     # International stuff
325     ftgl_lib = ['ftgl_static_ST']
326     ftgl_libpath = ['#../lib/windows/ftgl/lib']
327     ftgl_include = ['#../lib/windows/ftgl/include']
328     freetype_lib = ['freetype2ST']
329     freetype_libpath = ['#../lib/windows/freetype/lib']
330     freetype_include = ['#../lib/windows/freetype/include']
331     gettext_lib = ['gnu_gettext']
332     gettext_libpath = ['#../lib/windows/gettext/lib']
333     gettext_include = ['#../lib/windows/gettext/include']
334     # OpenAL library information
335     openal_lib = ['openal_static']
336     openal_libpath = ['#../lib/windows/openal/lib']
337     openal_include = ['#../lib/windows/openal/include']
338
339 elif string.find (sys.platform, 'sunos') != -1:
340     use_international = 'true'
341     use_gameengine = 'false'
342     use_openal = 'false'
343     use_fmod = 'false'
344     use_quicktime = 'false'
345     use_sumo = 'false'
346     use_ode = 'false'
347     use_buildinfo = 'false'
348     build_blender_dynamic = 'true'
349     build_blender_static = 'false'
350     build_blender_player = 'false'
351     build_blender_plugin = 'false'
352     release_flags = ['-O2']
353     debug_flags = ['-O2', '-g']
354     extra_flags = ['-pipe', '-fPIC', '-funsigned-char']
355     cxxflags = []
356     defines = []
357     env['ENV']['CC']='gcc'
358     env['ENV']['CXX']='g++'
359     warn_flags = ['-Wall', '-W']
360     window_system = 'X11'
361     platform_libs = ['m', 'util']
362     platform_libpath = []
363     platform_linkflags = []
364     extra_includes = []
365     # z library information
366     z_lib = ['z']
367     z_libpath = []
368     z_include = []
369     # png library information
370     png_lib = ['png']
371     png_libpath = []
372     png_include = []
373     # jpeg library information
374     jpeg_lib = ['jpeg']
375     jpeg_libpath = []
376     jpeg_include = []
377     # OpenGL library information
378     opengl_lib = ['GL', 'GLU']
379     opengl_static = []
380     opengl_libpath = []
381     opengl_include = []
382     # SDL library information
383     sdl_env.ParseConfig ('sdl-config --cflags --libs')
384     sdl_cflags = sdl_env.Dictionary()['CCFLAGS']
385     sdl_include = sdl_env.Dictionary()['CPPPATH']
386     sdl_libpath = sdl_env.Dictionary()['LIBPATH']
387     sdl_lib = sdl_env.Dictionary()['LIBS']
388     # SOLID library information
389     solid_lib = []                                              # TODO
390     solid_libpath = []                                          # TODO
391     solid_include = ['#extern/solid/include']
392     qhull_lib = []                                              # TODO
393     qhull_libpath = []                                          # TODO
394     qhull_include = ['#extern/qhull/include']
395     # ODE library information
396     ode_lib = []                                                # TODO
397     ode_libpath = []                                            # TODO
398     ode_include = ['#extern/ode/dist/include/ode']
399     # Python variables.
400     python_lib = ['python%d.%d' % sys.version_info[0:2]]
401     python_libpath = [sysconfig.get_python_lib (0, 1) + '/config']
402     python_include = [sysconfig.get_python_inc ()]
403     # International support information
404     ftgl_lib = ['ftgl']
405     ftgl_libpath = ['#../lib/solaris-2.8-sparc/ftgl/lib']
406     ftgl_include = ['#../lib/solaris-2.8-sparc/ftgl/include']
407     freetype_lib = ['freetype']
408     freetype_libpath = ['#../lib/solaris-2.8-sparc/freetype/lib']
409     freetype_include = ['#../lib/solaris-2.8-sparc/freetype/include']
410     gettext_lib = []
411     gettext_libpath = []
412     gettext_include = []
413     # OpenAL library information
414     openal_lib = []
415     openal_libpath = []
416     openal_include = []
417
418 elif string.find (sys.platform, 'irix') != -1:
419     use_international = 'false'
420     use_gameengine = 'false'
421     use_openal = 'false'
422     use_fmod = 'false'
423     use_quicktime = 'false'
424     use_sumo = 'false'
425     use_ode = 'false'
426     use_buildinfo = 'false'
427     build_blender_dynamic = 'true'
428     build_blender_static = 'false'
429     build_blender_player = 'false'
430     build_blender_plugin = 'false'
431     irix_precomp = '#../lib/irix-6.5-mips'
432     extra_flags = ['-n32', '-mips3', '-Xcpluscomm']
433     cxxflags = ['-n32', '-mips3', '-Xcpluscomm', '-LANG:std']
434     cxxflags += ['-LANG:libc_in_namespace_std=off']
435     
436     window_system = 'X11'
437     release_flags = ['-O2', '-OPT:Olimit=0']
438     debug_flags = ['-O2', '-g']
439     defines = []
440     warn_flags = ['-fullwarn', '-woff', '1001,1110,1201,1209,1355,1424,1681,3201']
441     platform_libs = ['movieGL', 'Xmu', 'Xext', 'X11',
442                      'c', 'm', 'dmedia', 'cl', 'audio',
443                      'Cio', 'pthread']
444     platform_libpath = ['/usr/lib32/mips3',
445                         '/lib/freeware/lib32',
446                         '/usr/lib32']
447     platform_linkflags = ['-mips3', '-n32']
448     extra_includes = ['/usr/freeware/include',
449                       '/usr/include']
450     # z library information
451     z_lib = ['z']
452     z_libpath = []
453     z_include = []
454     # png library information
455     png_lib = ['png']
456     png_libpath = [irix_precomp + '/png/lib']
457     png_include = [irix_precomp + '/png/include']
458     # jpeg library information
459     jpeg_lib = ['jpeg']
460     jpeg_libpath = [irix_precomp + '/jpeg/lib']
461     jpeg_include = [irix_precomp + '/jpeg/include']
462     # OpenGL library information
463     opengl_lib = ['GL', 'GLU']
464     opengl_static = []
465     opengl_libpath = []
466     opengl_include = []
467     # SDL library information
468     sdl_cflags = []
469     sdl_include = [irix_precomp + '/sdl/include/SDL']
470     sdl_libpath = [irix_precomp + '/sdl/lib']
471     sdl_lib = ['SDL', 'libSDL.a']
472     # SOLID library information
473     solid_lib = []                                              # TODO
474     solid_libpath = []                                          # TODO
475     solid_include = [irix_precomp + '/solid/include']
476     qhull_lib = []                                              # TODO
477     qhull_libpath = []                                          # TODO
478     qhull_include = ['#extern/qhull/include']
479     # ODE library information
480     ode_lib = []                                                # TODO
481     ode_libpath = []                                            # TODO
482     ode_include = [irix_precomp + '/ode/include']
483     # Python library information
484     python_libpath = [irix_precomp + '/python/lib/python2.2/config']
485     python_include = [irix_precomp + '/python/include/python2.2']
486     python_lib = ['python2.2']
487     # International support information
488     ftgl_lib = ['ftgl']
489     ftgl_libpath = [irix_precomp + '/ftgl/lib']
490     ftgl_include = [irix_precomp + '/ftgl/include']
491     freetype_lib = ['freetype']
492     freetype_libpath = [irix_precomp + '/freetype/lib']
493     freetype_include = [irix_precomp + '/freetype/include']
494     gettext_lib = []
495     gettext_libpath = []
496     gettext_include = []
497     # OpenAL library information
498     openal_lib = []
499     openal_libpath = []
500     openal_include = []
501
502 elif string.find (sys.platform, 'hp-ux') != -1:
503     window_system = 'X11'
504     defines = []
505
506 else:
507     print "Unknown platform"
508
509 #-----------------------------------------------------------------------------
510 # End of platform specific section
511 #-----------------------------------------------------------------------------
512
513 #-----------------------------------------------------------------------------
514 # User configurable options to be saved in a config file.
515 #-----------------------------------------------------------------------------
516 # Checking for an existing config file - use that one if it exists,
517 # otherwise create one.
518 if os.path.exists (config_file):
519     print "Using config file: " + config_file
520 else:
521     print "Creating new config file: " + config_file
522     env_dict = env.Dictionary()
523     config=open (config_file, 'w')
524     config.write ("# Configuration file containing user definable options.\n")
525     config.write ("VERSION = '2.32-cvs'\n")
526     config.write ("BUILD_BINARY = 'release'\n")
527     config.write ("USE_BUILDINFO = %r\n"%(use_buildinfo))
528     config.write ("BUILD_BLENDER_DYNAMIC = %r\n"%(build_blender_dynamic))
529     config.write ("BUILD_BLENDER_STATIC = %r\n"%(build_blender_static))
530     config.write ("BUILD_BLENDER_PLAYER = %r\n"%(build_blender_player))
531     config.write ("BUILD_BLENDER_PLUGIN = %r\n"%(build_blender_plugin))
532     config.write ("BUILD_DIR = %r\n"%(root_build_dir))
533     config.write ("USE_INTERNATIONAL = %r\n"%(use_international))
534     config.write ("BUILD_GAMEENGINE = %r\n"%(use_gameengine))
535     if use_sumo == 'true':
536         config.write ("USE_PHYSICS = 'solid'\n")
537     else:
538         config.write ("USE_PHYSICS = 'ode'\n")
539     config.write ("USE_OPENAL = %r\n"%(use_openal))
540     config.write ("USE_FMOD = %r\n"%(use_fmod))
541     config.write ("USE_QUICKTIME = %r\n"%(use_quicktime))
542     config.write ("\n# Compiler information.\n")
543     config.write ("HOST_CC = %r\n"%(env_dict['CC']))
544     config.write ("HOST_CXX = %r\n"%(env_dict['CXX']))
545     config.write ("TARGET_CC = %r\n"%(env_dict['CC']))
546     config.write ("TARGET_CXX = %r\n"%(env_dict['CXX']))
547     config.write ("TARGET_AR = %r\n"%(env_dict['AR']))
548     config.write ("PATH = %r\n"%(os.environ['PATH']))
549     config.write ("\n# External library information.\n")
550     config.write ("PYTHON_INCLUDE = %r\n"%(python_include))
551     config.write ("PYTHON_LIBPATH = %r\n"%(python_libpath))
552     config.write ("PYTHON_LIBRARY = %r\n"%(python_lib))
553     config.write ("SDL_CFLAGS = %r\n"%(sdl_cflags))
554     config.write ("SDL_INCLUDE = %r\n"%(sdl_include))
555     config.write ("SDL_LIBPATH = %r\n"%(sdl_libpath))
556     config.write ("SDL_LIBRARY = %r\n"%(sdl_lib))
557     config.write ("Z_INCLUDE = %r\n"%(z_include))
558     config.write ("Z_LIBPATH = %r\n"%(z_libpath))
559     config.write ("Z_LIBRARY = %r\n"%(z_lib))
560     config.write ("PNG_INCLUDE = %r\n"%(png_include))
561     config.write ("PNG_LIBPATH = %r\n"%(png_libpath))
562     config.write ("PNG_LIBRARY = %r\n"%(png_lib))
563     config.write ("JPEG_INCLUDE = %r\n"%(jpeg_include))
564     config.write ("JPEG_LIBPATH = %r\n"%(jpeg_libpath))
565     config.write ("JPEG_LIBRARY = %r\n"%(jpeg_lib))
566     config.write ("OPENGL_INCLUDE = %r\n"%(opengl_include))
567     config.write ("OPENGL_LIBPATH = %r\n"%(opengl_libpath))
568     config.write ("OPENGL_LIBRARY = %r\n"%(opengl_lib))
569     config.write ("OPENGL_STATIC = %r\n"%(opengl_static))
570     config.write ("\n# The following information is only necessary when you've enabled support for\n")
571     config.write ("# the game engine.\n")
572     config.write ("SOLID_INCLUDE = %r\n"%(solid_include))
573     config.write ("SOLID_LIBPATH = %r\n"%(solid_libpath))
574     config.write ("SOLID_LIBRARY = %r\n"%(solid_lib))
575     config.write ("QHULL_INCLUDE = %r\n"%(qhull_include))
576     config.write ("QHULL_LIBPATH = %r\n"%(qhull_libpath))
577     config.write ("QHULL_LIBRARY = %r\n"%(qhull_lib))
578     config.write ("ODE_INCLUDE = %r\n"%(ode_include))
579     config.write ("ODE_LIBPATH = %r\n"%(ode_libpath))
580     config.write ("ODE_LIBRARY = %r\n"%(ode_lib))
581     config.write ("OPENAL_INCLUDE = %r\n"%(openal_include))
582     config.write ("OPENAL_LIBPATH = %r\n"%(openal_libpath))
583     config.write ("OPENAL_LIBRARY = %r\n"%(openal_lib))
584     config.write ("\n# The following information is only necessary when building with\n")
585     config.write ("# internationalization support.\n");
586     config.write ("FTGL_INCLUDE = %r\n"%(ftgl_include))
587     config.write ("FTGL_LIBPATH = %r\n"%(ftgl_libpath))
588     config.write ("FTGL_LIBRARY = %r\n"%(ftgl_lib))
589     config.write ("FREETYPE_INCLUDE = %r\n"%(freetype_include))
590     config.write ("FREETYPE_LIBPATH = %r\n"%(freetype_libpath))
591     config.write ("FREETYPE_LIBRARY = %r\n"%(freetype_lib))
592     config.write ("GETTEXT_INCLUDE = %r\n"%(gettext_include))
593     config.write ("GETTEXT_LIBPATH = %r\n"%(gettext_libpath))
594     config.write ("GETTEXT_LIBRARY = %r\n"%(gettext_lib))
595     config.close ()
596
597 #-----------------------------------------------------------------------------
598 # Read the options from the config file and update the various necessary flags
599 #-----------------------------------------------------------------------------
600 list_opts = []
601 user_options_env = Environment ()
602 user_options = Options (config_file)
603 user_options.AddOptions (
604         ('VERSION', 'Blender version', version),
605         (EnumOption ('BUILD_BINARY', 'release',
606                      'Select a release or debug binary.',
607                      allowed_values = ('release', 'debug'))),
608         (BoolOption ('USE_BUILDINFO',
609                      'Set to 1 if you want to add build information.',
610                      'false')),
611         (BoolOption ('BUILD_BLENDER_DYNAMIC',
612                      'Set to 1 if you want to build blender with hardware accellerated OpenGL support.',
613                      'true')),
614         (BoolOption ('BUILD_BLENDER_STATIC',
615                      'Set to 1 if you want to build blender with software OpenGL support.',
616                      'false')),
617         (BoolOption ('BUILD_BLENDER_PLAYER',
618                      'Set to 1 if you want to build the blender player.',
619                      'false')),
620         (BoolOption ('BUILD_BLENDER_PLUGIN',
621                      'Set to 1 if you want to build the blender plugin.',
622                      'false')),
623         ('BUILD_DIR', 'Target directory for intermediate files.',
624                      root_build_dir),
625         (BoolOption ('USE_INTERNATIONAL',
626                      'Set to 1 to have international support.',
627                      'false')),
628         (EnumOption ('USE_PHYSICS', 'solid',
629                      'Select which physics engine to use.',
630                      allowed_values = ('ode', 'solid'))),
631         (BoolOption ('BUILD_GAMEENGINE',
632                      'Set to 1 to build blender with game engine support.',
633                      'false')),
634         (BoolOption ('USE_OPENAL',
635                      'Set to 1 to build the game engine with OpenAL support.',
636                      'false')),
637         (BoolOption ('USE_FMOD',
638                      'Set to 1 to build the game engine with FMod support.',
639                      'false')),
640         (BoolOption ('USE_QUICKTIME',
641                      'Set to 1 to add support for QuickTime.',
642                      'false')),
643         ('HOST_CC', 'C compiler for the host platfor. This is the same as target platform when not cross compiling.'),
644         ('HOST_CXX', 'C++ compiler for the host platform. This is the same as target platform when not cross compiling.'),
645         ('TARGET_CC', 'C compiler for the target platform.'),
646         ('TARGET_CXX', 'C++ compiler for the target platform.'),
647         ('TARGET_AR', 'Linker command for linking libraries.'),
648         ('PATH', 'Standard search path'),
649         ('PYTHON_INCLUDE', 'Include directory for Python header files.'),
650         ('PYTHON_LIBPATH', 'Library path where the Python lib is located.'),
651         ('PYTHON_LIBRARY', 'Python library name.'),
652         ('SDL_CFLAGS', 'Necessary CFLAGS when using sdl functionality.'),
653         ('SDL_INCLUDE', 'Include directory for SDL header files.'),
654         ('SDL_LIBPATH', 'Library path where the SDL library is located.'),
655         ('SDL_LIBRARY', 'SDL library name.'),
656         ('Z_INCLUDE', 'Include directory for zlib header files.'),
657         ('Z_LIBPATH', 'Library path where the zlib library is located.'),
658         ('Z_LIBRARY', 'Z library name.'),
659         ('PNG_INCLUDE', 'Include directory for png header files.'),
660         ('PNG_LIBPATH', 'Library path where the png library is located.'),
661         ('PNG_LIBRARY', 'png library name.'),
662         ('JPEG_INCLUDE', 'Include directory for jpeg header files.'),
663         ('JPEG_LIBPATH', 'Library path where the jpeg library is located.'),
664         ('JPEG_LIBRARY', 'jpeg library name.'),
665         ('OPENGL_INCLUDE', 'Include directory for OpenGL header files.'),
666         ('OPENGL_LIBPATH', 'Library path where the OpenGL libraries are located.'),
667         ('OPENGL_LIBRARY', 'OpenGL library names.'),
668         ('OPENGL_STATIC', 'Linker flags for static linking of Open GL.'),
669         ('SOLID_INCLUDE', 'Include directory for SOLID header files.'),
670         ('SOLID_LIBPATH', 'Library path where the SOLID library is located.'),
671         ('SOLID_LIBRARY', 'SOLID library name.'),
672         ('QHULL_INCLUDE', 'Include directory for QHULL header files.'),
673         ('QHULL_LIBPATH', 'Library path where the QHULL library is located.'),
674         ('QHULL_LIBRARY', 'QHULL library name.'),
675         ('ODE_INCLUDE', 'Include directory for ODE header files.'),
676         ('ODE_LIBPATH', 'Library path where the ODE library is located.'),
677         ('ODE_LIBRARY', 'ODE library name.'),
678         ('OPENAL_INCLUDE', 'Include directory for OpenAL header files.'),
679         ('OPENAL_LIBPATH', 'Library path where the OpenAL library is located.'),
680         ('OPENAL_LIBRARY', 'OpenAL library name.'),
681         ('FTGL_INCLUDE', 'Include directory for ftgl header files.'),
682         ('FTGL_LIBPATH', 'Library path where the ftgl library is located.'),
683         ('FTGL_LIBRARY', 'ftgl library name.'),
684         ('FREETYPE_INCLUDE', 'Include directory for freetype2 header files.'),
685         ('FREETYPE_LIBPATH', 'Library path where the freetype2 library is located.'),
686         ('FREETYPE_LIBRARY', 'Freetype2 library name.'),
687         ('GETTEXT_INCLUDE', 'Include directory for gettext header files.'),
688         ('GETTEXT_LIBPATH', 'Library path where the gettext library is located.'),
689         ('GETTEXT_LIBRARY', 'gettext library name.')
690     )
691 user_options.Update (user_options_env)
692 user_options_dict = user_options_env.Dictionary()
693
694 root_build_dir = user_options_dict['BUILD_DIR']
695     
696 if user_options_dict['BUILD_GAMEENGINE'] == 1:
697     defines += ['GAMEBLENDER=1']
698     if user_options_dict['USE_PHYSICS'] == 'ode':
699         defines += ['USE_ODE']
700     else:
701         defines += ['USE_SUMO_SOLID']
702 else:
703     defines += ['GAMEBLENDER=0']
704
705 if user_options_dict['BUILD_BINARY'] == 'release':
706     cflags = extra_flags + release_flags + warn_flags
707     if sys.platform == 'win32':
708         defines += ['NDEBUG']
709 else:
710     cflags = extra_flags + debug_flags + warn_flags
711     if sys.platform == 'win32':
712         #defines += ['_DEBUG'] specifying this makes msvc want to link to python22_d.lib??
713         platform_linkflags += ['/DEBUG','/PDB:blender.pdb']
714
715 #-----------------------------------------------------------------------------
716 # Generic library generation environment. This one is the basis for each
717 # library.
718 #-----------------------------------------------------------------------------
719 library_env = Environment ()
720 library_env.Replace (CC = user_options_dict['TARGET_CC'])
721 library_env.Replace (CXX = user_options_dict['TARGET_CXX'])
722 library_env.Replace (PATH = user_options_dict['PATH'])
723 library_env.Replace (AR = user_options_dict['TARGET_AR'])
724 library_env.Append (CCFLAGS = cflags)
725 library_env.Append (CXXFLAGS = cxxflags)
726 library_env.Append (CPPDEFINES = defines)
727
728 #-----------------------------------------------------------------------------
729 # Settings to be exported to other SConscript files
730 #-----------------------------------------------------------------------------
731
732 Export ('cflags')
733 Export ('defines')
734 Export ('window_system')
735 Export ('extra_includes')
736 Export ('platform_libs')
737 Export ('platform_libpath')
738 Export ('platform_linkflags')
739 Export ('user_options_dict')
740 Export ('library_env')
741
742 BuildDir (root_build_dir+'/intern', 'intern', duplicate=0)
743 SConscript (root_build_dir+'intern/SConscript')
744 BuildDir (root_build_dir+'/source', 'source', duplicate=0)
745 SConscript (root_build_dir+'source/SConscript')
746
747 libpath = (['#'+root_build_dir+'/lib'])
748
749 libraries = (['blender_creator',
750               'blender_render',
751               'blender_yafray',
752               'blender_blendersrc',
753               'blender_renderconverter',
754               'blender_blenloader',
755               'blender_writestreamglue',
756               'blender_deflate',
757               'blender_writeblenfile',
758               'blender_readblenfile',
759               'blender_readstreamglue',
760               'blender_inflate',
761               'blender_img',
762               'blender_radiosity',
763               'blender_blenkernel',
764               'blender_blenpluginapi',
765               'blender_imbuf',
766               'blender_avi',
767               'blender_blenlib',
768               'blender_python',
769               'blender_makesdna',
770               'blender_kernel',
771               'blender_BSP',
772               'blender_LOD',
773               'blender_GHOST',
774               'blender_STR',
775               'blender_guardedalloc',
776               'blender_BMF',
777               'blender_CTR',
778               'blender_MEM',
779               'blender_IK',
780               'blender_MT',
781               'soundsystem'])
782
783 link_env.Append (LIBS=libraries)
784 link_env.Append (LIBPATH=libpath)
785 link_env.Replace (CC = user_options_dict['TARGET_CC'])
786 link_env.Replace (CXX = user_options_dict['TARGET_CXX'])
787 link_env.Replace (PATH = user_options_dict['PATH'])
788 link_env.Replace (AR = user_options_dict['TARGET_AR'])
789 link_env.Append (CCFLAGS = cflags)
790 link_env.Append (CXXFLAGS = cxxflags)
791 link_env.Append (CPPDEFINES = defines)
792
793 if user_options_dict['USE_INTERNATIONAL'] == 1:
794     link_env.Append (LIBS=user_options_dict['FREETYPE_LIBRARY'])
795     link_env.Append (LIBPATH=user_options_dict['FREETYPE_LIBPATH'])
796     link_env.Append (LIBS=['blender_FTF'])
797     link_env.Append (LIBS=user_options_dict['FTGL_LIBRARY'])
798     link_env.Append (LIBPATH=user_options_dict['FTGL_LIBPATH'])
799     link_env.Append (LIBS=user_options_dict['FREETYPE_LIBRARY'])
800 if user_options_dict['USE_QUICKTIME'] == 1:
801     link_env.Append (LIBS=['blender_quicktime'])
802 if user_options_dict['BUILD_GAMEENGINE'] == 1:
803     link_env.Append (LIBS=['KX_blenderhook',
804                            'KX_converter',
805                            'PHY_Dummy',
806                            'PHY_Physics',
807                            'KX_ketsji',
808                            'SCA_GameLogic',
809                            'RAS_rasterizer',
810                            'RAS_OpenGLRasterizer',
811                            'blender_expressions',
812                            'SG_SceneGraph',
813                            'blender_MT',
814                            'KX_blenderhook',
815                            'KX_network',
816                            'blender_kernel',
817                            'NG_network',
818                            'NG_loopbacknetwork'])
819     if user_options_dict['USE_PHYSICS'] == 'solid':
820         link_env.Append (LIBS=['PHY_Sumo'])
821         link_env.Append (LIBS=user_options_dict['SOLID_LIBRARY'])
822         link_env.Append (LIBPATH=user_options_dict['SOLID_LIBPATH'])
823         link_env.Append (LIBS=user_options_dict['QHULL_LIBRARY'])
824         link_env.Append (LIBPATH=user_options_dict['QHULL_LIBPATH'])
825     else:
826         link_env.Append (LIBS=['PHY_Ode',
827                                'PHY_Physics'])
828         link_env.Append (LIBS=user_options_dict['ODE_LIBRARY'])
829         link_env.Append (LIBPATH=user_options_dict['ODE_LIBPATH'])
830
831 link_env.Append (LIBS=user_options_dict['PYTHON_LIBRARY'])
832 link_env.Append (LIBPATH=user_options_dict['PYTHON_LIBPATH'])
833 link_env.Append (LIBS=user_options_dict['SDL_LIBRARY'])
834 link_env.Append (LIBPATH=user_options_dict['SDL_LIBPATH'])
835 link_env.Append (LIBS=user_options_dict['PNG_LIBRARY'])
836 link_env.Append (LIBPATH=user_options_dict['PNG_LIBPATH'])
837 link_env.Append (LIBS=user_options_dict['JPEG_LIBRARY'])
838 link_env.Append (LIBPATH=user_options_dict['JPEG_LIBPATH'])
839 link_env.Append (LIBS=user_options_dict['GETTEXT_LIBRARY'])
840 link_env.Append (LIBPATH=user_options_dict['GETTEXT_LIBPATH'])
841 link_env.Append (LIBS=user_options_dict['Z_LIBRARY'])
842 link_env.Append (LIBPATH=user_options_dict['Z_LIBPATH'])
843 if user_options_dict['USE_OPENAL'] == 1:
844     link_env.Append (LIBS=user_options_dict['OPENAL_LIBRARY'])
845     link_env.Append (LIBPATH=user_options_dict['OPENAL_LIBPATH'])
846 link_env.Append (LIBS=platform_libs)
847 link_env.Append (LIBPATH=platform_libpath)
848 if sys.platform == 'darwin':
849     link_env.Append (LINKFLAGS=' -framework Carbon')
850     link_env.Append (LINKFLAGS=' -framework AGL')
851     if user_options_dict['USE_QUICKTIME'] == 1:
852         link_env.Append (LINKFLAGS=' -framework QuickTime')
853 else:
854     link_env.Append (LINKFLAGS=platform_linkflags)
855
856 link_env.BuildDir (root_build_dir, '.', duplicate=0)
857
858 build_date = time.strftime ("%Y-%m-%d")
859 build_time = time.strftime ("%H:%M:%S")
860
861 if user_options_dict['BUILD_BLENDER_DYNAMIC'] == 1:
862     dy_blender = link_env.Copy ()
863     dy_blender.Append (LIBS=user_options_dict['OPENGL_LIBRARY'])
864     dy_blender.Append (LIBPATH=user_options_dict['OPENGL_LIBPATH'])
865     if user_options_dict['USE_BUILDINFO'] == 1:
866         dy_blender.Append (CPPDEFINES = ['BUILD_TIME=\'"%s"\''%(build_time),
867                                          'BUILD_DATE=\'"%s"\''%(build_date),
868                                          'BUILD_TYPE=\'"dynamic"\'',
869                                          'NAN_BUILDINFO',
870                                          'BUILD_PLATFORM=\'"%s"\''%(sys.platform)])
871     d_obj = [dy_blender.Object (root_build_dir+'source/creator/d_buildinfo',
872                                 [root_build_dir+'source/creator/buildinfo.c'])]
873     if sys.platform == 'win32':
874         dy_blender.Program (target='blender',
875                             source=d_obj + ['source/icons/winblender.res'])
876     else:
877         dy_blender.Program (target='blender', source=d_obj)
878 if user_options_dict['BUILD_BLENDER_STATIC'] == 1:
879     st_blender = link_env.Copy ()
880     # The next line is to make sure that the LINKFLAGS are appended at the end
881     # of the link command. This 'trick' is needed because the GL and GLU static
882     # libraries need to be at the end of the command.
883     st_blender.Replace(LINKCOM="$LINK -o $TARGET $SOURCES $_LIBDIRFLAGS $_LIBFLAGS $LINKFLAGS")
884     if user_options_dict['USE_BUILDINFO'] == 1:
885         st_blender.Append (CPPDEFINES = ['BUILD_TIME=\'"%s"\''%(build_time),
886                                          'BUILD_DATE=\'"%s"\''%(build_date),
887                                          'BUILD_TYPE=\'"static"\'',
888                                          'NAN_BUILDINFO',
889                                          'BUILD_PLATFORM=\'"%s"\''%(sys.platform)])
890     st_blender.Append (LINKFLAGS=user_options_dict['OPENGL_STATIC'])
891     s_obj = [st_blender.Object (root_build_dir+'source/creator/s_buildinfo',
892                                 [root_build_dir+'source/creator/buildinfo.c'])]
893     st_blender.Prepend (LIBPATH=['/usr/lib/opengl/xfree/lib'])
894     st_blender.Program (target='blenderstatic', source=s_obj)
895
896 if sys.platform == 'darwin':
897     bundle = Environment ()
898     blender_app = 'blender'
899     bundle.Depends ('#/blender.app/Contents/MacOS/' + blender_app, blender_app)
900     bundle.Command ('#/blender.app/Contents/Info.plist',
901                     '#/source/darwin/blender.app/Contents/Info.plist',
902                     "rm -rf blender.app && " + \
903                     "cp -R source/darwin/blender.app . && " +
904                     "cat $SOURCE | sed s/VERSION/`cat release/VERSION`/ | \
905                                    sed s/DATE/`date +'%Y-%b-%d'`/ \
906                                    > $TARGET")
907     bundle.Command ('blender.app/Contents/MacOS/' + blender_app, blender_app,
908                     'cp $SOURCE $TARGET && ' + \
909                     'chmod +x $TARGET && ' + \
910                     'find $SOURCE -name CVS -prune -exec rm -rf {} \; && ' +
911                     'find $SOURCE -name .DS_Store -exec rm -rf {} \;')