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