Adding BPY sound module to projectfiles (MSVC 6.0)
[blender-staging.git] / SConstruct
1 #!/usr/bin/env python
2 import string
3 import os
4 import time
5 import sys
6 from distutils import sysconfig
7 import SCons.Script
8
9 appname = ''
10 playername = ''
11 config_guess = ''
12
13 if hex(sys.hexversion) < 0x2030000:
14         print ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
15         print
16         print "You need at least Python 2.3 to build Blender with SCons"
17         print
18         print ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
19         sys.exit()
20
21 if sys.platform != 'win32':
22         sys.stdout = os.popen("tee build.log", "w")
23         sys.stderr = sys.stdout
24         # guess at the platform, used to maintain the tarball naming scheme
25         config_guess = os.popen("SRCHOME=source/ source/tools/guess/guessconfig").read()[:-1]
26 else:
27         config_guess = "windows"
28         
29 if sys.platform == 'darwin':
30         appname = 'blender'
31         playername = 'blenderplayer'
32 else:
33         appname = 'blender$PROGSUFFIX'
34         playername = 'blenderplayer$PROGSUFFIX'
35
36 # This is a flag to determine whether to read all sconscripts and
37 # set up the build environments or not
38 # when issuing 'scons clean' this is set to 1
39 # and all reading is skipped and a 'clean' target
40 # will clean the root_build_dir from all
41 # object files
42 enable_clean = 0
43
44 all_args = sys.argv[1:]
45 parser =  SCons.Script.OptParser()
46 options, targets = parser.parse_args(all_args)
47 if ('clean' in targets):
48         enable_clean = 1
49         
50 # Build directory.
51 root_build_dir = '..' + os.sep + 'build' + os.sep + sys.platform + os.sep
52
53 # Create the build directory. SCons does this automatically, but since we
54 # don't want to put scons-generated .sconsign files in the source tree, but in
55 # the root_build_dir, we have to create that dir ourselves before SCons tries
56 # to access/create the file containing .sconsign data.
57 if os.path.isdir (root_build_dir) == 0:
58     os.makedirs (root_build_dir)
59
60 # User configurable options file. This can be controlled by the user by running
61 # scons with the following argument: CONFIG=user_config_options_file
62 config_file = ARGUMENTS.get('CONFIG', 'config.opts')
63
64 # Blender version.
65 version='2.34'
66 shortversion = '234' # for wininst target -> nsis installer creation
67
68 sdl_env = Environment ()
69 freetype_env = Environment ()
70 env = Environment ()
71
72 if sys.platform == 'linux2' or sys.platform == 'linux-i386':
73     use_international = 'false'
74     use_gameengine = 'true'
75     use_openal = 'false'
76     use_fmod = 'false'
77     use_quicktime = 'false'
78     use_sumo = 'true'
79     use_ode = 'false'
80     use_buildinfo = 'true'
81     build_blender_dynamic = 'true'
82     build_blender_static = 'false'
83     build_blender_player = 'true'
84     build_blender_plugin = 'false'
85     release_flags = ['-O2']
86     debug_flags = ['-O2', '-g']
87     extra_flags = ['-pipe', '-funsigned-char']
88     cxxflags = []
89     defines = []
90     warn_flags = ['-Wall', '-W']
91     window_system = 'X11'
92     platform_libs = ['m', 'util', 'stdc++']
93     platform_libpath = []
94     platform_linkflags = ['-pthread']
95     extra_includes = []
96     # z library information
97     z_lib = ['z']
98     z_libpath = ['/usr/lib']
99     z_include = ['/usr/include']
100     # png library information
101     png_lib = ['png']
102     png_libpath = ['/usr/lib']
103     png_include = ['/usr/include']
104     # jpeg library information
105     jpeg_lib = ['jpeg']
106     jpeg_libpath = ['/usr/lib']
107     jpeg_include = ['/usr/include']
108     # OpenGL library information
109     opengl_lib = ['GL', 'GLU']
110     opengl_static = ['/usr/lib/libGL.a', '/usr/lib/libGLU.a']
111     opengl_libpath = ['/usr/lib', '/usr/X11R6/lib']
112     opengl_include = ['/usr/include']
113     # SDL library information
114     sdl_env.ParseConfig ('sdl-config --cflags --libs')
115     sdl_cflags = sdl_env.Dictionary()['CCFLAGS']
116     sdl_include = sdl_env.Dictionary()['CPPPATH']
117     sdl_libpath = sdl_env.Dictionary()['LIBPATH']
118     sdl_lib = sdl_env.Dictionary()['LIBS']
119     # SOLID library information
120     solid_lib = []                                              # TODO
121     solid_libpath = []                                          # TODO
122     solid_include = ['#extern/solid']
123     qhull_lib = []                                              # TODO
124     qhull_libpath = []                                          # TODO
125     qhull_include = ['#extern/qhull/include']
126     # ODE library information
127     ode_lib = ['ode']
128     ode_libpath = ['#../lib/linux-glibc2.2.5-i386/ode/lib']
129     ode_include = ['#../lib/linux-glibc2.2.5-i386/ode/include']
130     # Python library information
131     python_lib = ['python%d.%d' % sys.version_info[0:2]]
132     python_libpath = [sysconfig.get_python_lib (0, 1) + '/config']
133     python_include = [sysconfig.get_python_inc ()]
134     python_linkflags = Split (sysconfig.get_config_var('LINKFORSHARED'))
135     # International support information
136     ftgl_lib = ['ftgl']
137     ftgl_libpath = ['#../lib/linux-glibc2.2.5-i386/ftgl/lib']
138     ftgl_include = ['#../lib/linux-glibc2.2.5-i386/ftgl/include']
139     freetype_env.ParseConfig ('pkg-config --cflags --libs freetype2 2>/dev/null || freetype-config --cflags --libs 2>/dev/null')
140     freetype_lib = freetype_env.Dictionary()['LIBS']
141     freetype_libpath = freetype_env.Dictionary()['LIBPATH']
142     freetype_include = freetype_env.Dictionary()['CPPPATH']
143     gettext_lib = []
144     gettext_libpath = []
145     gettext_include = []
146     # OpenAL library information
147     openal_lib = ['openal']
148     openal_libpath = ['/usr/lib']
149     openal_include = ['/usr/include']
150
151 elif sys.platform == 'darwin':
152     use_international = 'true'
153     use_gameengine = 'true'
154     use_openal = 'true'
155     use_fmod = 'false'
156     use_quicktime = 'true'
157     use_precomp = 'true'
158     use_sumo = 'true'
159     use_ode = 'false'
160     use_buildinfo = 'true'
161     build_blender_dynamic = 'true'
162     build_blender_static = 'false'
163     build_blender_player = 'true'
164     build_blender_plugin = 'false'
165     # TODO: replace darwin-6.1-powerpc with the actual directiory on the
166     #       build machine
167     # darwin-6.1 is the name of cvs precomp folder
168     # a symbolic link named darwin-X.Y-powerpc must be manually done
169     #for now. X-Y is darwin kernel rev number
170     darwin_precomp = '#../lib/darwin-6.1-powerpc/'
171     fink_path = '/sw/'
172     # TODO : try -mpowerpc -mpowerpc-gopt -mpowerpc-gfxopt optims
173     #           doing actual profiling
174     extra_flags = ['-pipe', '-fPIC', '-funsigned-char', '-ffast-math', '-mpowerpc'] 
175     
176     # , '-malign-natural'] malign is causing problems with jpeg lib but worth a 1-2% speedup
177     #'-force_cpusubtype_ALL', '-mpowerpc-gpopt', 
178     cxxflags = []
179     defines = ['_THREAD_SAFE' ]
180     if use_quicktime == 'true':
181         defines += ['WITH_QUICKTIME']
182     warn_flags = ['-Wall']    # , '-W'
183     release_flags = ['-O3']
184     debug_flags = ['-g']
185     window_system = 'CARBON'
186     # z library information
187     z_lib = ['z']
188     z_libpath = []
189     z_include = []
190     # TODO : add a flag to allow each lib to be build from fink or precomp
191     #        without having to have to specify the path manually in config.opts.    
192     # png library information
193     png_lib = ['libpng']
194     png_libpath = [darwin_precomp + 'png/lib']
195     png_include = [darwin_precomp + 'png/include']
196     # jpeg library information
197     jpeg_lib = ['libjpeg']
198     jpeg_libpath = [darwin_precomp + 'jpeg/lib']
199     jpeg_include = [darwin_precomp + 'jpeg/include']
200     # OpenGL library information
201     opengl_lib = ['GL', 'GLU']
202     opengl_static = []
203     opengl_libpath = []
204     opengl_include = []
205     # SDL specific stuff.
206     sdl_env.ParseConfig ('sdl-config --cflags --libs')
207     sdl_cflags = sdl_env.Dictionary()['CCFLAGS']
208     # Want to use precompiled libraries?
209     if use_precomp == 'true':
210         sdl_include = [darwin_precomp + 'sdl/include']
211         sdl_libpath = [darwin_precomp + 'sdl/lib']
212         sdl_lib = ['libSDL.a']
213     platform_libs = ['stdc++'] 
214     extra_includes = ['/sw/include']
215     platform_libpath = ['/System/Library/Frameworks/OpenGL.framework/Libraries']
216     platform_linkflags = []
217     # SOLID library information
218     solid_lib = ['libsolid']                                          
219     solid_libpath = [darwin_precomp + 'solid/lib']                                          
220     solid_include = [darwin_precomp + 'solid/include']
221     qhull_lib = ['libqhull']                                          
222     qhull_libpath = [darwin_precomp + 'qhull/lib']                                          
223     qhull_include = [darwin_precomp + 'qhull/include']
224     # ODE library information
225     ode_lib = ['libode']                                             
226     ode_libpath = [darwin_precomp + 'ode/lib']                                          
227     ode_include = [darwin_precomp + 'ode/include/ode']
228     # Python variables.
229     # TODO : fill vars differently if we are on 10.2 or 10.3
230     # python_lib = ['python%d.%d' % sys.version_info[0:2]]
231     # python_libpath = [sysconfig.get_python_lib (0, 1) + '/config']
232     # python_include = [sysconfig.get_python_inc ()]
233     # python_linkflags = Split (sysconfig.get_config_var('LINKFORSHARED'))
234     python_lib = []
235     python_libpath = ['/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/config']
236     python_include = ['/System/Library/Frameworks/Python.framework/Versions/2.3/include/python2.3']
237     python_linkflags = ['-u', '__dummy', '-u', '_PyMac_Error', 
238                         '-framework', 'System',
239                         '-framework', 'Python',
240                         '-framework', 'CoreServices',
241                         '-framework', 'Foundation',
242                         '-framework', 'OpenGL']
243     # International stuff
244     ftgl_lib = ['ftgl']
245     ftgl_libpath = [darwin_precomp + 'ftgl/lib']
246     ftgl_include = [darwin_precomp + 'ftgl/include']
247     freetype_lib = ['libfreetype']
248     freetype_libpath = [darwin_precomp + 'freetype/lib']
249     freetype_include = [darwin_precomp + 'freetype/include']
250     gettext_lib = ['libintl']
251     gettext_libpath = [darwin_precomp + 'gettext/lib']
252     gettext_include = [darwin_precomp + 'gettext/include']
253     # OpenAL library information
254     openal_lib = ['libopenal']
255     openal_libpath = [darwin_precomp + 'openal/lib']
256     openal_include = [darwin_precomp + 'openal/include']
257
258 elif sys.platform == 'cygwin':
259     use_international = 'false'
260     use_gameengine = 'false'
261     use_openal = 'false'
262     use_fmod = 'false'
263     use_quicktime = 'false'
264     use_sumo = 'false'
265     use_ode = 'false'
266     use_buildinfo = 'false'
267     build_blender_dynamic = 'true'
268     build_blender_static = 'false'
269     build_blender_player = 'false'
270     build_blender_plugin = 'false'
271     release_flags = ['-O2']
272     debug_flags = ['-O2', '-g']
273     extra_flags = ['-pipe', '-mno-cygwin', '-mwindows', '-funsigned-char']
274     cxxflags = []
275     defines = ['FREE_WINDOWS']
276     warn_flags = ['-Wall', '-Wno-char-subscripts']
277     platform_libs = ['png', 'jpeg', 'netapi32',
278                      'opengl32', 'glu32', 'winmm',
279                      'mingw32']
280     platform_libpath = ['/usr/lib/w32api', '/lib/w32api']
281     platform_linkflags = ['-mwindows', '-mno-cygwin', '-mconsole']
282     window_system = 'WIN32'
283     extra_includes = []
284     # z library information
285     z_lib = ['z']
286     z_libpath = ['#../lib/windows/zlib/lib']
287     z_include = ['#../lib/windows/zlib/include']
288     # png library information
289     png_lib = ['png']
290     png_libpath = ['#../lib/windows/png/lib']
291     png_include = ['#../lib/windows/png/include']
292     # jpeg library information
293     jpeg_lib = ['jpeg']
294     jpeg_libpath = ['#../lib/windows/jpeg/lib']
295     jpeg_include = ['#../lib/windows/jpeg/include']
296     # OpenGL library information
297     opengl_lib = ['opengl32', 'glu32']
298     opengl_static = []
299     opengl_libpath = []
300     opengl_include = []
301     # SDL specific stuff.
302     sdl_include = ['#../lib/windows/sdl/include']
303     sdl_libpath = ['#../lib/windows/sdl/lib']
304     sdl_lib = ['SDL']
305     sdl_cflags = []
306     #sdl_cflags = '-DWIN32'
307     # SOLID library information
308     solid_lib = []                                              # TODO
309     solid_libpath = []                                          # TODO
310     solid_include = ['#extern/solid']
311     qhull_lib = []                                              # TODO
312     qhull_libpath = []                                          # TODO
313     qhull_include = ['#extern/qhull/include']
314     # ODE library information
315     ode_lib = ['ode']
316     ode_libpath = ['#../lib/windows/gcc/ode/lib']
317     ode_include = ['#../lib/windows/gcc/ode/include']
318     # Python library information
319     python_include = ['#../lib/windows/python/include/python2.2']
320     python_libpath = ['#../lib/windows/python/lib']
321     python_lib = ['python22']
322     python_linkflags = []
323     # International stuff
324     ftgl_lib = ['ftgl']
325     ftgl_libpath = ['#../lib/windows/gcc/ftgl/lib']
326     ftgl_include = ['#../lib/windows/gcc/ftgl/include']
327     freetype_lib = ['freetype']
328     freetype_libpath = ['#../lib/windows/gcc/freetype/lib']
329     freetype_include = ['#../lib/windows/gcc/freetype/include']
330     gettext_lib = []
331     gettext_libpath = []
332     gettext_include = []
333     # OpenAL library information
334     openal_lib = []
335     openal_libpath = []
336     openal_include = []
337
338 elif sys.platform == 'win32':
339     use_international = 'true'
340     use_gameengine = 'true'
341     use_openal = 'true'
342     use_fmod = 'false'
343     use_quicktime = 'true'
344     use_sumo = 'true'
345     use_ode = 'false'
346     use_buildinfo = 'true'
347     build_blender_dynamic = 'true'
348     build_blender_static = 'false'
349     build_blender_player = 'true'
350     build_blender_plugin = 'false'
351     release_flags = ['/Og', '/Ot', '/Ob1', '/Op', '/G6']
352     debug_flags = ['/Zi', '/Fr${TARGET.base}.sbr']
353     extra_flags = ['/EHsc', '/J', '/W3', '/Gd', '/MT']
354     cxxflags = []
355     defines = ['WIN32', '_CONSOLE']
356     defines += ['WITH_QUICKTIME']
357     defines += ['_LIB', 'USE_OPENAL']
358     defines += ['FTGL_LIBRARY_STATIC']
359     warn_flags = []
360     platform_libs = [ 'qtmlClient', 'soundsystem',
361                      'ws2_32', 'dxguid', 'vfw32', 'winmm',
362                      'iconv', 'kernel32', 'user32', 'gdi32',
363                      'winspool', 'comdlg32', 'advapi32', 'shell32',
364                      'ole32', 'oleaut32', 'uuid', 'odbc32', 'odbccp32',
365                      'libcmt', 'libc']
366     platform_libpath = ['#../lib/windows/iconv/lib',
367                         '#../lib/windows/QTDevWin/Libraries']
368     platform_linkflags = [
369                         '/SUBSYSTEM:CONSOLE',
370                         '/MACHINE:IX86',
371                         '/ENTRY:mainCRTStartup',
372                         '/INCREMENTAL:NO',
373                         '/NODEFAULTLIB:"msvcprt.lib"',
374                         '/NODEFAULTLIB:"glut32.lib"',
375                         '/NODEFAULTLIB:"libcd.lib"',
376                         #'/NODEFAULTLIB:"libc.lib"',
377                         '/NODEFAULTLIB:"libcpd.lib"',
378                         '/NODEFAULTLIB:"libcp.lib"',
379                         '/NODEFAULTLIB:"libcmtd.lib"',
380                         ]
381     window_system = 'WIN32'
382     extra_includes = []
383     if use_quicktime == 'true':
384         extra_includes += ['#../lib/windows/QTDevWin/CIncludes']
385     # z library information
386     z_lib = ['libz_st']
387     z_libpath = ['#../lib/windows/zlib/lib']
388     z_include = ['#../lib/windows/zlib/include']
389     # png library information
390     png_lib = ['libpng_st']
391     png_libpath = ['#../lib/windows/png/lib']
392     png_include = ['#../lib/windows/png/include']
393     # jpeg library information
394     jpeg_lib = ['libjpeg']
395     jpeg_libpath = ['#../lib/windows/jpeg/lib']
396     jpeg_include = ['#../lib/windows/jpeg/include']
397     # OpenGL library information
398     opengl_lib = ['opengl32', 'glu32']
399     opengl_static = []
400     opengl_libpath = []
401     opengl_include = ['/usr/include']
402     # SDL library information
403     sdl_include = ['#../lib/windows/sdl/include']
404     sdl_libpath = ['#../lib/windows/sdl/lib']
405     sdl_lib = ['SDL']
406     sdl_cflags = []
407     window_system = 'WIN32'
408     # SOLID library information
409     solid_lib = ['extern/solid']
410     solid_libpath = ['#../lib/windows/solid/lib']
411     solid_include = ['#extern/solid']
412     qhull_lib = ['qhull']
413     qhull_libpath = ['#../lib/windows/qhull/lib']
414     qhull_include = ['#extern/qhull/include']
415     # ODE library information
416     ode_lib = []                                                # TODO
417     ode_libpath = ['#../lib/windows/ode/lib']
418     ode_include = ['#../lib/windows/ode/include']
419     # Python lib name
420     python_include = ['#../lib/windows/python/include/python2.3']
421     python_libpath = ['#../lib/windows/python/lib']
422     python_lib = ['python23']
423     python_linkflags = []
424     # International stuff
425     ftgl_lib = ['ftgl_static_ST']
426     ftgl_libpath = ['#../lib/windows/ftgl/lib']
427     ftgl_include = ['#../lib/windows/ftgl/include']
428     freetype_lib = ['freetype2ST']
429     freetype_libpath = ['#../lib/windows/freetype/lib']
430     freetype_include = ['#../lib/windows/freetype/include']
431     gettext_lib = ['gnu_gettext']
432     gettext_libpath = ['#../lib/windows/gettext/lib']
433     gettext_include = ['#../lib/windows/gettext/include']
434     # OpenAL library information
435     openal_lib = ['openal_static']
436     openal_libpath = ['#../lib/windows/openal/lib']
437     openal_include = ['#../lib/windows/openal/include']
438
439 elif string.find (sys.platform, 'sunos') != -1:
440     use_international = 'true'
441     use_gameengine = 'false'
442     use_openal = 'false'
443     use_fmod = 'false'
444     use_quicktime = 'false'
445     use_sumo = 'false'
446     use_ode = 'false'
447     use_buildinfo = 'false'
448     build_blender_dynamic = 'true'
449     build_blender_static = 'false'
450     build_blender_player = 'false'
451     build_blender_plugin = 'false'
452     release_flags = ['-O2']
453     debug_flags = ['-O2', '-g']
454     extra_flags = ['-pipe', '-fPIC', '-funsigned-char', '-DSUN_OGL_NO_VERTEX_MACROS']
455     cxxflags = []
456     defines = []
457     warn_flags = ['-Wall', '-W']
458     window_system = 'X11'
459     platform_libs = ['stdc++', 'dl', 'm']
460     platform_libpath = []
461     platform_linkflags = []
462     extra_includes = []
463     # z library information
464     z_lib = ['z']
465     z_libpath = []
466     z_include = []
467     # png library information
468     png_lib = ['png']
469     png_libpath = []
470     png_include = []
471     # jpeg library information
472     jpeg_lib = ['jpeg']
473     jpeg_libpath = []
474     jpeg_include = []
475     # OpenGL library information
476     opengl_lib = ['GL', 'GLU', 'X11']
477     opengl_static = []
478     opengl_libpath = ['/usr/openwin/include']
479     opengl_include = ['/usr/openwin/lib']
480     # SDL library information
481     sdl_env.ParseConfig ('sdl-config --cflags --libs')
482     sdl_cflags = sdl_env.Dictionary()['CCFLAGS']
483     sdl_include = sdl_env.Dictionary()['CPPPATH']
484     sdl_libpath = sdl_env.Dictionary()['LIBPATH']
485     sdl_lib = sdl_env.Dictionary()['LIBS']
486     # SOLID library information
487     solid_lib = []                                              # TODO
488     solid_libpath = []                                          # TODO
489     solid_include = ['#extern/solid']
490     qhull_lib = []                                              # TODO
491     qhull_libpath = []                                          # TODO
492     qhull_include = ['#extern/qhull/include']
493     # ODE library information
494     ode_lib = []                                                # TODO
495     ode_libpath = []                                            # TODO
496     ode_include = ['#extern/ode/dist/include/ode']
497     # Python variables.
498     python_lib = ['python%d.%d' % sys.version_info[0:2]]
499     python_libpath = [sysconfig.get_python_lib (0, 1) + '/config']
500     python_include = [sysconfig.get_python_inc ()]
501     python_linkflags = []
502     # International support information
503     ftgl_lib = ['ftgl']
504     ftgl_libpath = ['#../lib/solaris-2.8-sparc/ftgl/lib']
505     ftgl_include = ['#../lib/solaris-2.8-sparc/ftgl/include']
506     freetype_lib = ['freetype']
507     freetype_libpath = ['#../lib/solaris-2.8-sparc/freetype/lib']
508     freetype_include = ['#../lib/solaris-2.8-sparc/freetype/include']
509     gettext_lib = []
510     gettext_libpath = []
511     gettext_include = []
512     # OpenAL library information
513     openal_lib = []
514     openal_libpath = []
515     openal_include = []
516
517 elif string.find (sys.platform, 'irix') != -1:
518     use_international = 'false'
519     use_gameengine = 'false'
520     use_openal = 'false'
521     use_fmod = 'false'
522     use_quicktime = 'false'
523     use_sumo = 'false'
524     use_ode = 'false'
525     use_buildinfo = 'false'
526     build_blender_dynamic = 'true'
527     build_blender_static = 'false'
528     build_blender_player = 'false'
529     build_blender_plugin = 'false'
530     irix_precomp = '#../lib/irix-6.5-mips'
531     extra_flags = ['-n32', '-mips3', '-Xcpluscomm']
532     cxxflags = ['-n32', '-mips3', '-Xcpluscomm', '-LANG:std']
533     cxxflags += ['-LANG:libc_in_namespace_std=off']
534     
535     window_system = 'X11'
536     release_flags = ['-O2', '-OPT:Olimit=0']
537     debug_flags = ['-O2', '-g']
538     defines = []
539     warn_flags = ['-fullwarn', '-woff', '1001,1110,1201,1209,1355,1424,1681,3201']
540     platform_libs = ['movieGL', 'Xmu', 'Xext', 'X11',
541                      'c', 'm', 'dmedia', 'cl', 'audio',
542                      'Cio', 'pthread']
543     platform_libpath = ['/usr/lib32/mips3',
544                         '/lib/freeware/lib32',
545                         '/usr/lib32']
546     platform_linkflags = ['-mips3', '-n32']
547     extra_includes = ['/usr/freeware/include',
548                       '/usr/include']
549     # z library information
550     z_lib = ['z']
551     z_libpath = []
552     z_include = []
553     # png library information
554     png_lib = ['png']
555     png_libpath = [irix_precomp + '/png/lib']
556     png_include = [irix_precomp + '/png/include']
557     # jpeg library information
558     jpeg_lib = ['jpeg']
559     jpeg_libpath = [irix_precomp + '/jpeg/lib']
560     jpeg_include = [irix_precomp + '/jpeg/include']
561     # OpenGL library information
562     opengl_lib = ['GL', 'GLU']
563     opengl_static = []
564     opengl_libpath = []
565     opengl_include = []
566     # SDL library information
567     sdl_cflags = []
568     sdl_include = [irix_precomp + '/sdl/include/SDL']
569     sdl_libpath = [irix_precomp + '/sdl/lib']
570     sdl_lib = ['SDL', 'libSDL.a']
571     # SOLID library information
572     solid_lib = []                                              # TODO
573     solid_libpath = []                                          # TODO
574     solid_include = [irix_precomp + '/solid/include']
575     qhull_lib = []                                              # TODO
576     qhull_libpath = []                                          # TODO
577     qhull_include = ['#extern/qhull/include']
578     # ODE library information
579     ode_lib = []                                                # TODO
580     ode_libpath = []                                            # TODO
581     ode_include = [irix_precomp + '/ode/include']
582     # Python library information
583     python_libpath = [irix_precomp + '/python/lib/python2.2/config']
584     python_include = [irix_precomp + '/python/include/python2.2']
585     python_lib = ['python2.2']
586     python_linkflags = []
587     # International support information
588     ftgl_lib = ['ftgl']
589     ftgl_libpath = [irix_precomp + '/ftgl/lib']
590     ftgl_include = [irix_precomp + '/ftgl/include']
591     freetype_lib = ['freetype']
592     freetype_libpath = [irix_precomp + '/freetype/lib']
593     freetype_include = [irix_precomp + '/freetype/include']
594     gettext_lib = []
595     gettext_libpath = []
596     gettext_include = []
597     # OpenAL library information
598     openal_lib = []
599     openal_libpath = []
600     openal_include = []
601
602 elif string.find (sys.platform, 'hp-ux') != -1:
603     window_system = 'X11'
604     defines = []
605
606 elif sys.platform=='openbsd3':
607     print "Building for OpenBSD 3.x"
608     use_international = 'false'
609     use_gameengine = 'false'
610     use_openal = 'false'
611     use_fmod = 'false'
612     use_quicktime = 'false'
613     use_sumo = 'false'
614     use_ode = 'false'
615     use_buildinfo = 'true'
616     build_blender_dynamic = 'true'
617     build_blender_static = 'false'
618     build_blender_player = 'false'
619     build_blender_plugin = 'false'
620     release_flags = ['-O2']
621     debug_flags = ['-O2', '-g']
622     extra_flags = ['-pipe', '-fPIC', '-funsigned-char']
623     cxxflags = []
624     defines = []
625     warn_flags = ['-Wall','-W']
626     window_system = 'X11'
627     platform_libs = ['m', 'stdc++', 'pthread', 'util']
628     platform_libpath = []
629     platform_linkflags = []
630     extra_includes = []
631     z_lib = ['z']
632     z_libpath = ['/usr/lib']
633     z_include = ['/usr/include']
634     # png library information
635     png_lib = ['png']
636     png_libpath = ['/usr/local/lib']
637     png_include = ['/usr/local/include']
638     # jpeg library information
639     jpeg_lib = ['jpeg']
640     jpeg_libpath = ['/usr/local/lib']
641     jpeg_include = ['/usr/local/include']
642     # OpenGL library information
643     opengl_lib = ['GL', 'GLU']
644     opengl_static = ['/usr/lib/libGL.a', '/usr/lib/libGLU.a']
645     opengl_libpath = ['/usr/lib', '/usr/X11R6/lib']
646     opengl_include = ['/usr/X11R6/include/']
647     # SDL library information
648     sdl_env.ParseConfig ('sdl-config --cflags --libs')
649     sdl_cflags = sdl_env.Dictionary()['CCFLAGS']
650     sdl_include = sdl_env.Dictionary()['CPPPATH']
651     sdl_libpath = sdl_env.Dictionary()['LIBPATH']
652     sdl_lib = sdl_env.Dictionary()['LIBS']
653     # SOLID library information
654     solid_lib = []                     # TODO
655     solid_libpath = []        # TODO
656     solid_include = ['#extern/solid']
657     qhull_lib = []       # TODO
658     qhull_libpath = []  # TODO
659     qhull_include = ['#extern/qhull/include']
660     # ODE library information
661     ode_lib = ['ode']
662     ode_libpath = ['#../lib/linux-glibc2.2.5-i386/ode/lib']
663     ode_include = ['#../lib/linux-glibc2.2.5-i386/ode/include']
664     # Python library information
665     python_lib = ['python%d.%d' % sys.version_info[0:2]]
666     python_libpath = [sysconfig.get_python_lib (0, 1) + '/config']
667     python_include = [sysconfig.get_python_inc ()]
668     python_linkflags = []
669     # International support information
670     ftgl_lib = ['ftgl']
671     ftgl_libpath = ['#../lib/linux-glibc2.2.5-i386/ftgl/lib']
672     ftgl_include = ['#../lib/linux-glibc2.2.5-i386/ftgl/include']
673     freetype_env.ParseConfig('pkg-config --cflags --libs freetype2')
674     freetype_lib = freetype_env.Dictionary()['LIBS']
675     freetype_libpath = freetype_env.Dictionary()['LIBPATH']
676     freetype_include = freetype_env.Dictionary()['CPPPATH']
677     gettext_lib = []
678     gettext_libpath = []
679     gettext_include = []
680     # OpenAL library information
681     openal_lib = ['openal']
682     openal_libpath = ['/usr/lib']
683     openal_include = ['/usr/include']
684     
685 elif sys.platform=='freebsd4' or sys.platform=='freebsd5':
686     print "Building for FreeBSD"
687     use_international = 'false'
688     use_gameengine = 'false'
689     use_openal = 'false'
690     use_fmod = 'false'
691     use_quicktime = 'false'
692     use_sumo = 'false'
693     use_ode = 'false'
694     use_buildinfo = 'true'
695     build_blender_dynamic = 'true'
696     build_blender_static = 'false'
697     build_blender_player = 'false'
698     build_blender_plugin = 'false'
699     release_flags = ['-O2']
700     debug_flags = ['-O2', '-g']
701     extra_flags = ['-pipe', '-fPIC', '-funsigned-char']
702     cxxflags = []
703     defines = []
704     warn_flags = ['-Wall','-W']
705     window_system = 'X11'
706     platform_libs = ['m', 'stdc++', 'util']
707     platform_libpath = []
708     platform_linkflags = ['-pthread']
709     extra_includes = []
710     z_lib = ['z']
711     z_libpath = ['/usr/lib']
712     z_include = ['/usr/include']
713     # png library information
714     png_lib = ['png']
715     png_libpath = ['/usr/local/lib']
716     png_include = ['/usr/local/include']
717     # jpeg library information
718     jpeg_lib = ['jpeg']
719     jpeg_libpath = ['/usr/local/lib']
720     jpeg_include = ['/usr/local/include']
721     # OpenGL library information
722     opengl_lib = ['GL', 'GLU']
723     opengl_static = ['/usr/lib/libGL.a', '/usr/lib/libGLU.a']
724     opengl_libpath = ['/usr/lib', '/usr/X11R6/lib']
725     opengl_include = ['/usr/X11R6/include/']
726     # SDL library information
727     sdl_env.ParseConfig ('sdl11-config --cflags --libs')
728     sdl_cflags = sdl_env.Dictionary()['CCFLAGS']
729     sdl_include = sdl_env.Dictionary()['CPPPATH']
730     sdl_libpath = ['/usr/local/include/SDL11']
731     sdl_lib = sdl_env.Dictionary()['LIBS']
732     # SOLID library information
733     solid_lib = []                     # TODO
734     solid_libpath = []        # TODO
735     solid_include = ['#extern/solid']
736     qhull_lib = []       # TODO
737     qhull_libpath = []  # TODO
738     qhull_include = ['#extern/qhull/include']
739     # ODE library information
740     ode_lib = ['ode']
741     ode_libpath = ['#../lib/linux-glibc2.2.5-i386/ode/lib']
742     ode_include = ['#../lib/linux-glibc2.2.5-i386/ode/include']
743     # Python library information
744     python_lib = ['python%d.%d' % sys.version_info[0:2]]
745     python_libpath = [sysconfig.get_python_lib (0, 1) + '/config']
746     python_include = [sysconfig.get_python_inc ()]
747     python_linkflags = []
748     # International support information
749     ftgl_lib = ['ftgl']
750     ftgl_libpath = ['#../lib/linux-glibc2.2.5-i386/ftgl/lib']
751     ftgl_include = ['#../lib/linux-glibc2.2.5-i386/ftgl/include']
752     freetype_env.ParseConfig('pkg-config --cflags --libs freetype2')
753     freetype_lib = freetype_env.Dictionary()['LIBS']
754     freetype_libpath = freetype_env.Dictionary()['LIBPATH']
755     freetype_include = freetype_env.Dictionary()['CPPPATH']
756     gettext_lib = []
757     gettext_libpath = []
758     gettext_include = []
759     # OpenAL library information
760     openal_lib = ['openal']
761     openal_libpath = ['/usr/lib']
762     openal_include = ['/usr/include']
763
764 else:
765     print "Unknown platform %s"%sys.platform
766     exit
767
768 #-----------------------------------------------------------------------------
769 # End of platform specific section
770 #-----------------------------------------------------------------------------
771
772 #-----------------------------------------------------------------------------
773 # User configurable options to be saved in a config file.
774 #-----------------------------------------------------------------------------
775 # Checking for an existing config file - use that one if it exists,
776 # otherwise create one.
777 my_defines = []
778 my_ccflags = []
779 my_cxxflags = []
780 my_ldflags = []
781 if os.path.exists (config_file):
782     print "Using config file: " + config_file
783 else:
784     print "Creating new config file: " + config_file
785     env_dict = env.Dictionary()
786     config=open (config_file, 'w')
787     config.write ("# Configuration file containing user definable options.\n")
788     config.write ("VERSION = '2.33-cvs'\n")
789     config.write ("BUILD_BINARY = 'release'\n")
790     config.write ("USE_BUILDINFO = %r\n"%(use_buildinfo))
791     config.write ("BUILD_BLENDER_DYNAMIC = %r\n"%(build_blender_dynamic))
792     config.write ("BUILD_BLENDER_STATIC = %r\n"%(build_blender_static))
793     config.write ("BUILD_BLENDER_PLAYER = %r\n"%(build_blender_player))
794     config.write ("BUILD_BLENDER_PLUGIN = %r\n"%(build_blender_plugin))
795     config.write ("BUILD_DIR = %r\n"%(root_build_dir))
796     
797     config.write ("\n# Extra compiler flags can be defined here.\n")
798     config.write ("DEFINES = %s\n"%(my_defines))
799     config.write ("CCFLAGS = %s\n"%(my_ccflags))
800     config.write ("CXXFLAGS = %s\n"%(my_cxxflags))
801     config.write ("LDFLAGS = %s\n"%(my_ldflags))
802
803     config.write ("USE_INTERNATIONAL = %r\n"%(use_international))
804     config.write ("BUILD_GAMEENGINE = %r\n"%(use_gameengine))
805     if use_ode == 'true':
806         config.write ("USE_PHYSICS = 'ode'\n")
807     else:
808         config.write ("USE_PHYSICS = 'solid'\n")
809     config.write ("USE_OPENAL = %r\n"%(use_openal))
810     config.write ("USE_FMOD = %r\n"%(use_fmod))
811     config.write ("USE_QUICKTIME = %r\n"%(use_quicktime))
812     config.write ("\n# Compiler information.\n")
813     config.write ("HOST_CC = %r\n"%(env_dict['CC']))
814     config.write ("HOST_CXX = %r\n"%(env_dict['CXX']))
815     config.write ("TARGET_CC = %r\n"%(env_dict['CC']))
816     config.write ("TARGET_CXX = %r\n"%(env_dict['CXX']))
817     config.write ("TARGET_AR = %r\n"%(env_dict['AR']))
818     config.write ("PATH = %r\n"%(os.environ['PATH']))
819     config.write ("\n# External library information.\n")
820     config.write ("PLATFORM_LIBS = %r\n"%(platform_libs))
821     config.write ("PLATFORM_LIBPATH = %r\n"%(platform_libpath))
822     config.write ("PLATFORM_LINKFLAGS = %r\n"%(platform_linkflags))
823     config.write ("PYTHON_INCLUDE = %r\n"%(python_include))
824     config.write ("PYTHON_LIBPATH = %r\n"%(python_libpath))
825     config.write ("PYTHON_LIBRARY = %r\n"%(python_lib))
826     config.write ("PYTHON_LINKFLAGS = %r\n"%(python_linkflags))
827     config.write ("SDL_CFLAGS = %r\n"%(sdl_cflags))
828     config.write ("SDL_INCLUDE = %r\n"%(sdl_include))
829     config.write ("SDL_LIBPATH = %r\n"%(sdl_libpath))
830     config.write ("SDL_LIBRARY = %r\n"%(sdl_lib))
831     config.write ("Z_INCLUDE = %r\n"%(z_include))
832     config.write ("Z_LIBPATH = %r\n"%(z_libpath))
833     config.write ("Z_LIBRARY = %r\n"%(z_lib))
834     config.write ("PNG_INCLUDE = %r\n"%(png_include))
835     config.write ("PNG_LIBPATH = %r\n"%(png_libpath))
836     config.write ("PNG_LIBRARY = %r\n"%(png_lib))
837     config.write ("JPEG_INCLUDE = %r\n"%(jpeg_include))
838     config.write ("JPEG_LIBPATH = %r\n"%(jpeg_libpath))
839     config.write ("JPEG_LIBRARY = %r\n"%(jpeg_lib))
840     config.write ("OPENGL_INCLUDE = %r\n"%(opengl_include))
841     config.write ("OPENGL_LIBPATH = %r\n"%(opengl_libpath))
842     config.write ("OPENGL_LIBRARY = %r\n"%(opengl_lib))
843     config.write ("OPENGL_STATIC = %r\n"%(opengl_static))
844     config.write ("\n# The following information is only necessary when you've enabled support for\n")
845     config.write ("# the game engine.\n")
846     config.write ("SOLID_INCLUDE = %r\n"%(solid_include))
847     config.write ("SOLID_LIBPATH = %r\n"%(solid_libpath))
848     config.write ("SOLID_LIBRARY = %r\n"%(solid_lib))
849     config.write ("QHULL_INCLUDE = %r\n"%(qhull_include))
850     config.write ("QHULL_LIBPATH = %r\n"%(qhull_libpath))
851     config.write ("QHULL_LIBRARY = %r\n"%(qhull_lib))
852     config.write ("ODE_INCLUDE = %r\n"%(ode_include))
853     config.write ("ODE_LIBPATH = %r\n"%(ode_libpath))
854     config.write ("ODE_LIBRARY = %r\n"%(ode_lib))
855     config.write ("OPENAL_INCLUDE = %r\n"%(openal_include))
856     config.write ("OPENAL_LIBPATH = %r\n"%(openal_libpath))
857     config.write ("OPENAL_LIBRARY = %r\n"%(openal_lib))
858     config.write ("\n# The following information is only necessary when building with\n")
859     config.write ("# internationalization support.\n");
860     config.write ("FTGL_INCLUDE = %r\n"%(ftgl_include))
861     config.write ("FTGL_LIBPATH = %r\n"%(ftgl_libpath))
862     config.write ("FTGL_LIBRARY = %r\n"%(ftgl_lib))
863     config.write ("FREETYPE_INCLUDE = %r\n"%(freetype_include))
864     config.write ("FREETYPE_LIBPATH = %r\n"%(freetype_libpath))
865     config.write ("FREETYPE_LIBRARY = %r\n"%(freetype_lib))
866     config.write ("GETTEXT_INCLUDE = %r\n"%(gettext_include))
867     config.write ("GETTEXT_LIBPATH = %r\n"%(gettext_libpath))
868     config.write ("GETTEXT_LIBRARY = %r\n"%(gettext_lib))
869     config.close ()
870
871 #-----------------------------------------------------------------------------
872 # Read the options from the config file and update the various necessary flags
873 #-----------------------------------------------------------------------------
874 list_opts = []
875 user_options_env = Environment ()
876 user_options = Options (config_file)
877 user_options.AddOptions (
878         ('VERSION', 'Blender version', version),
879         (EnumOption ('BUILD_BINARY', 'release',
880                      'Select a release or debug binary.',
881                      allowed_values = ('release', 'debug'))),
882         (BoolOption ('USE_BUILDINFO',
883                      'Set to 1 if you want to add build information.',
884                      'false')),
885         (BoolOption ('BUILD_BLENDER_DYNAMIC',
886                      'Set to 1 if you want to build blender with hardware accellerated OpenGL support.',
887                      'true')),
888         (BoolOption ('BUILD_BLENDER_STATIC',
889                      'Set to 1 if you want to build blender with software OpenGL support.',
890                      'false')),
891         (BoolOption ('BUILD_BLENDER_PLAYER',
892                      'Set to 1 if you want to build the blender player.',
893                      'false')),
894         (BoolOption ('BUILD_BLENDER_PLUGIN',
895                      'Set to 1 if you want to build the blender plugin.',
896                      'false')),
897         ('BUILD_DIR', 'Target directory for intermediate files.',
898                      root_build_dir),
899         (BoolOption ('USE_INTERNATIONAL',
900                      'Set to 1 to have international support.',
901                      'false')),
902         (EnumOption ('USE_PHYSICS', 'solid',
903                      'Select which physics engine to use.',
904                      allowed_values = ('ode', 'solid'))),
905         (BoolOption ('BUILD_GAMEENGINE',
906                      'Set to 1 to build blender with game engine support.',
907                      'false')),
908         (BoolOption ('USE_OPENAL',
909                      'Set to 1 to build the game engine with OpenAL support.',
910                      'false')),
911         (BoolOption ('USE_FMOD',
912                      'Set to 1 to build the game engine with FMod support.',
913                      'false')),
914         (BoolOption ('USE_QUICKTIME',
915                      'Set to 1 to add support for QuickTime.',
916                      'false')),
917         ('HOST_CC', 'C compiler for the host platfor. This is the same as target platform when not cross compiling.'),
918         ('HOST_CXX', 'C++ compiler for the host platform. This is the same as target platform when not cross compiling.'),
919         ('TARGET_CC', 'C compiler for the target platform.'),
920         ('TARGET_CXX', 'C++ compiler for the target platform.'),
921         ('TARGET_AR', 'Linker command for linking libraries.'),
922         ('PATH', 'Standard search path'),
923         ('PLATFORM_LIBS', 'Platform specific libraries.'),
924         ('PLATFORM_LIBPATH', 'Platform specific library link path.'),
925         ('PLATFORM_LINKFLAGS', 'Platform specific linkflags'),
926         ('PYTHON_INCLUDE', 'Include directory for Python header files.'),
927         ('PYTHON_LIBPATH', 'Library path where the Python lib is located.'),
928         ('PYTHON_LIBRARY', 'Python library name.'),
929         ('PYTHON_LINKFLAGS', 'Python specific linkflags.'),
930         ('SDL_CFLAGS', 'Necessary CFLAGS when using sdl functionality.'),
931         ('SDL_INCLUDE', 'Include directory for SDL header files.'),
932         ('SDL_LIBPATH', 'Library path where the SDL library is located.'),
933         ('SDL_LIBRARY', 'SDL library name.'),
934         ('Z_INCLUDE', 'Include directory for zlib header files.'),
935         ('Z_LIBPATH', 'Library path where the zlib library is located.'),
936         ('Z_LIBRARY', 'Z library name.'),
937         ('PNG_INCLUDE', 'Include directory for png header files.'),
938         ('PNG_LIBPATH', 'Library path where the png library is located.'),
939         ('PNG_LIBRARY', 'png library name.'),
940         ('JPEG_INCLUDE', 'Include directory for jpeg header files.'),
941         ('JPEG_LIBPATH', 'Library path where the jpeg library is located.'),
942         ('JPEG_LIBRARY', 'jpeg library name.'),
943         ('OPENGL_INCLUDE', 'Include directory for OpenGL header files.'),
944         ('OPENGL_LIBPATH', 'Library path where the OpenGL libraries are located.'),
945         ('OPENGL_LIBRARY', 'OpenGL library names.'),
946         ('OPENGL_STATIC', 'Linker flags for static linking of Open GL.'),
947         ('SOLID_INCLUDE', 'Include directory for SOLID header files.'),
948         ('SOLID_LIBPATH', 'Library path where the SOLID library is located.'),
949         ('SOLID_LIBRARY', 'SOLID library name.'),
950         ('QHULL_INCLUDE', 'Include directory for QHULL header files.'),
951         ('QHULL_LIBPATH', 'Library path where the QHULL library is located.'),
952         ('QHULL_LIBRARY', 'QHULL library name.'),
953         ('ODE_INCLUDE', 'Include directory for ODE header files.'),
954         ('ODE_LIBPATH', 'Library path where the ODE library is located.'),
955         ('ODE_LIBRARY', 'ODE library name.'),
956         ('OPENAL_INCLUDE', 'Include directory for OpenAL header files.'),
957         ('OPENAL_LIBPATH', 'Library path where the OpenAL library is located.'),
958         ('OPENAL_LIBRARY', 'OpenAL library name.'),
959         ('FTGL_INCLUDE', 'Include directory for ftgl header files.'),
960         ('FTGL_LIBPATH', 'Library path where the ftgl library is located.'),
961         ('FTGL_LIBRARY', 'ftgl library name.'),
962         ('FREETYPE_INCLUDE', 'Include directory for freetype2 header files.'),
963         ('FREETYPE_LIBPATH', 'Library path where the freetype2 library is located.'),
964         ('FREETYPE_LIBRARY', 'Freetype2 library name.'),
965         ('GETTEXT_INCLUDE', 'Include directory for gettext header files.'),
966         ('GETTEXT_LIBPATH', 'Library path where the gettext library is located.'),
967         ('GETTEXT_LIBRARY', 'gettext library name.'),
968
969         ('DEFINES', 'Extra Preprocessor defines.'),
970         ('CCFLAGS', 'Extra C Compiler flags.'),
971         ('CXXFLAGS','Extra C++ Compiler flags.'),
972         ('LDFLAGS', 'Extra Linker flags.')
973     )
974 user_options.Update (user_options_env)
975 user_options_dict = user_options_env.Dictionary()
976
977 root_build_dir = user_options_dict['BUILD_DIR']
978     
979 if user_options_dict['BUILD_GAMEENGINE'] == 1:
980     defines += ['GAMEBLENDER=1']
981     if user_options_dict['USE_PHYSICS'] == 'ode':
982         defines += ['USE_ODE']
983     else:
984         defines += ['USE_SUMO_SOLID']
985 else:
986     defines += ['GAMEBLENDER=0']
987
988 if user_options_dict['BUILD_BINARY'] == 'release':
989     cflags = extra_flags + release_flags + warn_flags
990     defines += ['NDEBUG']
991 else:
992     cflags = extra_flags + debug_flags + warn_flags
993     if sys.platform == 'win32':
994         #defines += ['_DEBUG'] specifying this makes msvc want to link to python22_d.lib??
995         platform_linkflags += ['/DEBUG','/PDB:blender.pdb']
996
997 defines += user_options_dict['DEFINES']
998 cflags += user_options_dict['CCFLAGS']
999 cxxflags += user_options_dict['CXXFLAGS']
1000 platform_linkflags += user_options_dict['LDFLAGS']
1001
1002 #-----------------------------------------------------------------------------
1003 # Generic library generation environment. This one is the basis for each
1004 # library.
1005 #-----------------------------------------------------------------------------
1006 library_env = env.Copy ()
1007 library_env.Replace (CC = user_options_dict['TARGET_CC'])
1008 library_env.Replace (CXX = user_options_dict['TARGET_CXX'])
1009 library_env.Replace (PATH = user_options_dict['PATH'])
1010 library_env.Replace (AR = user_options_dict['TARGET_AR'])
1011 library_env.Append (CCFLAGS = cflags)
1012 library_env.Append (CXXFLAGS = cxxflags)
1013 library_env.Append (CPPDEFINES = defines)
1014 library_env.SConsignFile (root_build_dir+'scons-signatures')
1015
1016 #-----------------------------------------------------------------------------
1017 # Settings to be exported to other SConscript files
1018 #-----------------------------------------------------------------------------
1019
1020 if enable_clean==0: # only read SConscripts when not cleaning, this to cut overhead
1021         Export ('cflags')
1022         Export ('defines')
1023         Export ('window_system')
1024         Export ('extra_includes')
1025         Export ('user_options_dict')
1026         Export ('library_env')
1027         
1028         BuildDir (root_build_dir+'/extern', 'extern', duplicate=0)
1029         SConscript (root_build_dir+'extern/SConscript')
1030         BuildDir (root_build_dir+'/intern', 'intern', duplicate=0)
1031         SConscript (root_build_dir+'intern/SConscript')
1032         BuildDir (root_build_dir+'/source', 'source', duplicate=0)
1033         SConscript (root_build_dir+'source/SConscript')
1034         
1035         libpath = (['#'+root_build_dir+'/lib'])
1036         
1037         link_env = library_env.Copy ()
1038         link_env.Append (LIBPATH=libpath)
1039
1040
1041 def common_libs(env):
1042         """
1043         Append to env all libraries that are common to Blender and Blenderplayer
1044         """
1045         env.Append (LIBS=[
1046                 'blender_blenloader',
1047                 'blender_readblenfile',
1048                 'blender_img',
1049                 'blender_blenkernel',
1050                 'blender_blenpluginapi',
1051                 'blender_imbuf',
1052                 'blender_avi',
1053                 'blender_blenlib',
1054                 'blender_makesdna',
1055                 'blender_kernel',
1056                 'blender_GHOST',
1057                 'blender_STR',
1058                 'blender_guardedalloc',
1059                 'blender_CTR',
1060                 'blender_MEM',
1061                 'blender_MT',
1062                 'blender_BMF',
1063                 'soundsystem'])
1064         if user_options_dict['USE_QUICKTIME'] == 1:
1065                 env.Append (LIBS=['blender_quicktime'])
1066
1067
1068 def international_libs(env):
1069         """
1070         Append international font support libraries
1071         """
1072         if user_options_dict['USE_INTERNATIONAL'] == 1:
1073                 env.Append (LIBS=user_options_dict['FREETYPE_LIBRARY'])
1074                 env.Append (LIBPATH=user_options_dict['FREETYPE_LIBPATH'])
1075                 env.Append (LIBS=['blender_FTF'])
1076                 env.Append (LIBS=user_options_dict['FTGL_LIBRARY'])
1077                 env.Append (LIBPATH=user_options_dict['FTGL_LIBPATH'])
1078                 env.Append (LIBS=user_options_dict['FREETYPE_LIBRARY'])
1079
1080 def blender_libs(env):
1081         """
1082         Blender only libs (not in player)
1083         """
1084         env.Append( LIBS=['blender_creator',
1085                 'blender_blendersrc',
1086                 'blender_render',
1087                 'blender_yafray',
1088                 'blender_renderconverter',
1089                 'blender_radiosity',
1090                 'blender_LOD',
1091                 'blender_BSP',
1092                 'blender_blenkernel',
1093                 'blender_IK',
1094                 'blender_ONL'])
1095
1096 def ketsji_libs(env):
1097         """
1098         Game Engine libs
1099         """
1100         if user_options_dict['BUILD_GAMEENGINE'] == 1:
1101                 env.Append (LIBS=['KX_blenderhook',
1102                                 'KX_converter',
1103                                 'PHY_Dummy',
1104                                 'PHY_Physics',
1105                                 'KX_ketsji',
1106                                 'SCA_GameLogic',
1107                                 'RAS_rasterizer',
1108                                 'RAS_OpenGLRasterizer',
1109                                 'blender_expressions',
1110                                 'SG_SceneGraph',
1111                                 'blender_MT',
1112                                 'KX_blenderhook',
1113                                 'KX_network',
1114                                 'blender_kernel',
1115                                 'NG_network',
1116                                 'NG_loopbacknetwork'])
1117                 if user_options_dict['USE_PHYSICS'] == 'solid':
1118                         env.Append (LIBS=['PHY_Sumo', 'PHY_Physics', 'blender_MT', 'extern_solid', 'extern_qhull'])
1119                 else:
1120                         env.Append (LIBS=['PHY_Ode',
1121                                         'PHY_Physics'])
1122                         env.Append (LIBS=user_options_dict['ODE_LIBRARY'])
1123                         env.Append (LIBPATH=user_options_dict['ODE_LIBPATH'])
1124
1125 def player_libs(env):
1126         """
1127         Player libraries
1128         """
1129         env.Append (LIBS=['GPG_ghost',
1130                         'GPC_common'])
1131
1132 def player_libs2(env):
1133         """
1134         Link order shenannigans: these libs are added after common_libs
1135         """
1136         env.Append (LIBS=['blender_blenkernel_blc',
1137                         'soundsystem'])
1138
1139 def winblenderres(env):
1140         """
1141         build the windows icon resource file
1142         """
1143         if sys.platform == 'win32':
1144                 env.RES(['source/icons/winblender.rc'])
1145
1146 def system_libs(env):
1147         """
1148         System libraries: Python, SDL, PNG, JPEG, Gettext, OpenAL, Carbon
1149         """
1150         env.Append (LIBS=['blender_python'])
1151         env.Append (LIBS=user_options_dict['PYTHON_LIBRARY'])
1152         env.Append (LIBPATH=user_options_dict['PYTHON_LIBPATH'])
1153         env.Append (LINKFLAGS=user_options_dict['PYTHON_LINKFLAGS'])
1154         env.Append (LIBS=user_options_dict['SDL_LIBRARY'])
1155         env.Append (LIBPATH=user_options_dict['SDL_LIBPATH'])
1156         env.Append (LIBS=user_options_dict['PNG_LIBRARY'])
1157         env.Append (LIBPATH=user_options_dict['PNG_LIBPATH'])
1158         env.Append (LIBS=user_options_dict['JPEG_LIBRARY'])
1159         env.Append (LIBPATH=user_options_dict['JPEG_LIBPATH'])
1160         env.Append (LIBS=user_options_dict['GETTEXT_LIBRARY'])
1161         env.Append (LIBPATH=user_options_dict['GETTEXT_LIBPATH'])
1162         env.Append (LIBS=user_options_dict['Z_LIBRARY'])
1163         env.Append (LIBPATH=user_options_dict['Z_LIBPATH'])
1164         if user_options_dict['USE_OPENAL'] == 1:
1165                 env.Append (LIBS=user_options_dict['OPENAL_LIBRARY'])
1166                 env.Append (LIBPATH=user_options_dict['OPENAL_LIBPATH'])
1167         env.Append (LIBS=user_options_dict['PLATFORM_LIBS'])
1168         env.Append (LIBPATH=user_options_dict['PLATFORM_LIBPATH'])
1169         if sys.platform == 'darwin':
1170                 env.Append (LINKFLAGS='-framework')
1171                 env.Append (LINKFLAGS='Carbon')
1172                 env.Append (LINKFLAGS='-framework')
1173                 env.Append (LINKFLAGS='AGL')
1174                 env.Append (LINKFLAGS='-framework')
1175                 env.Append (LINKFLAGS='AudioUnit')
1176                 env.Append (LINKFLAGS='-framework')
1177                 env.Append (LINKFLAGS='AudioToolbox')
1178                 env.Append (LINKFLAGS='-framework')
1179                 env.Append (LINKFLAGS='CoreAudio')
1180                 if user_options_dict['USE_QUICKTIME'] == 1:
1181                         env.Append (LINKFLAGS='-framework')
1182                         env.Append (LINKFLAGS='QuickTime')
1183         else:
1184                 env.Append (LINKFLAGS=user_options_dict['PLATFORM_LINKFLAGS'])
1185         env.BuildDir (root_build_dir, '.', duplicate=0)
1186
1187 def buildinfo(env, build_type):
1188         """
1189         Generate a buildinfo object
1190         """
1191         build_date = time.strftime ("%Y-%m-%d")
1192         build_time = time.strftime ("%H:%M:%S")
1193         obj = []
1194         if user_options_dict['USE_BUILDINFO'] == 1:
1195                 if sys.platform=='win32':
1196                         build_info_file = open("source/creator/winbuildinfo.h", 'w')
1197                         build_info_file.write("char *build_date=\"%s\";\n"%build_date)
1198                         build_info_file.write("char *build_time=\"%s\";\n"%build_time)
1199                         build_info_file.write("char *build_platform=\"win32\";\n")
1200                         build_info_file.write("char *build_type=\"%s\";\n"%build_type)
1201                         build_info_file.close()
1202                         env.Append (CPPDEFINES = ['NAN_BUILDINFO', 'BUILD_DATE'])
1203                 else:
1204                         env.Append (CPPDEFINES = ['BUILD_TIME=\'"%s"\''%(build_time),
1205                                                         'BUILD_DATE=\'"%s"\''%(build_date),
1206                                                         'BUILD_TYPE=\'"dynamic"\'',
1207                                                         'NAN_BUILDINFO',
1208                                                         'BUILD_PLATFORM=\'"%s"\''%(sys.platform)])
1209                 obj = [env.Object (root_build_dir+'source/creator/%s_buildinfo'%build_type,
1210                                                 [root_build_dir+'source/creator/buildinfo.c'])]
1211         return obj
1212         
1213 def cleanCVS():
1214         """
1215         walks the dist dir and removes all CVS dirs
1216         """
1217         
1218         try:
1219                 import shutil
1220         except:
1221                 print "no shutil available"
1222                 print "make sure you use python 2.3"
1223                 print
1224                 return 0
1225         
1226         startdir = os.getcwd()
1227         
1228         for root, dirs, files in os.walk("dist", topdown=False):
1229                 for name in dirs:
1230                         if name in ['CVS']:
1231                                 if os.path.isdir(root + "/" + name):
1232                                         shutil.rmtree(root + "/" + name)
1233         
1234         os.chdir(startdir)
1235         
1236         return 1
1237
1238 def preparedist():
1239         """
1240         Prepare a directory for creating either archives or the installer
1241         """
1242         
1243         try:
1244                 import shutil
1245                 import time
1246                 import stat
1247         except:
1248                 print "no shutil available"
1249                 print "make sure you use python 2.3"
1250                 print
1251                 return 0
1252         
1253         startdir = os.getcwd()
1254         
1255         if os.path.isdir("dist") == 0:
1256                 os.makedirs("dist")
1257         else:
1258                 shutil.rmtree("dist") # make sure we don't get old cruft
1259                 os.makedirs("dist")
1260         
1261         # first copy binaries
1262         
1263         if sys.platform == 'win32':
1264                 shutil.copy("blender.exe", "dist/blender.exe")
1265                 if user_options_dict['BUILD_BLENDER_PLAYER'] == 1:
1266                         shutil.copy("blenderplayer.exe", "dist/blenderplayer.exe")
1267                 shutil.copy("../lib/windows/python/lib/python23.dll", "dist/python23.dll")
1268                 shutil.copy("../lib/windows/sdl/lib/SDL.dll", "dist/SDL.dll")
1269                 shutil.copy("../lib/windows/gettext/lib/gnu_gettext.dll", "dist/gnu_gettext.dll")
1270         elif sys.platform in ['linux2', 'linux-i386', 'freebsd4', 'freebsd5']:
1271                 shutil.copy("blender", "dist/blender")
1272                 if user_options_dict['BUILD_BLENDER_PLAYER'] == 1:
1273                         shutil.copy("blenderplayer", "dist/blenderplayer")
1274         else:
1275                 print "update preparedist() for your platform!"
1276                 return 0
1277         
1278         # now copy .blender and necessary extras for it
1279         if os.path.isdir("dist/.blender"):
1280                 shutil.rmtree("dist/.blender")
1281         os.chdir("bin")
1282         shutil.copytree(".blender/", "../dist/.blender")
1283         os.chdir(startdir)
1284         if os.path.isdir("dist/.blender/scripts"):
1285                 shutil.rmtree("dist/.blender/scripts")
1286         if os.path.isdir("dist/.blender/bpydata"):
1287                 shutil.rmtree("dist/.blender/bpydata")
1288                 
1289         os.makedirs("dist/.blender/bpydata")
1290         shutil.copy("release/bpydata/readme.txt", "dist/.blender/bpydata/readme.txt")
1291         shutil.copy("release/bpydata/KUlang.txt", "dist/.blender/bpydata/KUlang.txt")
1292         
1293         os.chdir("release")
1294         shutil.copytree("scripts/", "../dist/.blender/scripts")
1295         
1296         # finally copy auxiliaries (readme, license, etc.)
1297         if sys.platform == 'win32':
1298                 shutil.copy("windows/extra/Help.url", "../dist/Help.url")
1299                 shutil.copy("windows/extra/Python23.zip", "../dist/Python23.zip")
1300                 shutil.copy("windows/extra/zlib.pyd", "../dist/zlib.pyd")
1301         shutil.copy("text/copyright.txt", "../dist/copyright.txt")
1302         shutil.copy("text/blender.html", "../dist/blender.html")
1303         shutil.copy("text/GPL-license.txt", "../dist/GPL-license.txt")
1304         shutil.copy("text/Python-license.txt", "../dist/Python-license.txt")
1305         
1306         reltext = "release_" + string.join(version.split("."), '') + ".txt"
1307         shutil.copy("text/" + reltext, "../dist/" + reltext)
1308         
1309         os.chdir(startdir)
1310         
1311         if cleanCVS()==0:
1312                 return 0
1313         return 1
1314
1315 def finalisedist(zipname):
1316         """
1317         Fetch the package created and remove temp dir
1318         """
1319         
1320         try:
1321                 import shutil
1322         except:
1323                 print "no shutil available"
1324                 print "make sure you use python 2.3"
1325                 print
1326                 return 0
1327         
1328         #shutil.copy("dist/" + zipname, zipname)
1329         #shutil.rmtree("dist")
1330         
1331         return 1
1332
1333 def add2arc(arc, file):
1334         if sys.platform == 'win32':
1335                 arc.write(file)
1336         else:
1337                 arc.add(file)
1338
1339                 
1340 def appit(target, source, env):
1341         if sys.platform == 'darwin':
1342                 import shutil
1343                 import commands
1344                 import os.path
1345                                                 
1346                 target = 'blender' 
1347                 sourceinfo = "source/darwin/%s.app/Contents/Info.plist"%target
1348                 targetinfo = "%s.app/Contents/Info.plist"%target
1349
1350                 cmd = '%s.app'%target
1351                 if os.path.isdir(cmd):
1352                         shutil.rmtree('%s.app'%target)
1353                 shutil.copytree("source/darwin/%s.app"%target, '%s.app'%target)
1354                 cmd = "cat %s | sed s/VERSION/`cat release/VERSION`/ | sed s/DATE/`date +'%%Y-%%b-%%d'`/ > %s"%(sourceinfo,targetinfo)
1355                 commands.getoutput(cmd)
1356                 cmd = 'cp %s %s.app/Contents/MacOS/%s'%(target, target, target)
1357                 commands.getoutput(cmd)
1358                 if  user_options_dict['BUILD_BINARY'] == 'debug':
1359                         print "building debug"
1360                 else :
1361                         cmd = 'strip -u -r %s.app/Contents/MacOS/%s'%(target, target)
1362                         commands.getoutput(cmd)
1363                 cmd = '%s.app/Contents/Resources/'%target
1364                 shutil.copy('bin/.blender/.bfont.ttf', cmd)
1365                 shutil.copy('bin/.blender/.Blanguages', cmd)
1366                 cmd = 'cp -R bin/.blender/locale %s.app/Contents/Resources/'%target
1367                 commands.getoutput(cmd) 
1368                 cmd = 'mkdir %s.app/Contents/MacOS/.blender'%target
1369                 commands.getoutput(cmd)
1370                 cmd = 'cp -R release/bpydata %s.app/Contents/MacOS/.blender'%target
1371                 commands.getoutput(cmd)
1372                 cmd = 'cp -R release/scripts %s.app/Contents/MacOS/.blender/'%target
1373                 commands.getoutput(cmd)
1374                 cmd = 'cp -R release/plugins %s.app/Contents/Resources/'%target 
1375                 commands.getoutput(cmd)
1376                 cmd = 'chmod +x  %s.app/Contents/MacOS/%s'%(target, target)
1377                 commands.getoutput(cmd)
1378                 cmd = 'find %s.app -name CVS -prune -exec rm -rf {} \;'%target
1379                 commands.getoutput(cmd)
1380                 cmd = 'find %s.app -name .DS_Store -exec rm -rf {} \;'%target
1381                 commands.getoutput(cmd)
1382                 
1383                 if user_options_dict['BUILD_BLENDER_PLAYER'] == 1:
1384                         target = 'blenderplayer' 
1385                         sourceinfo = "source/darwin/%s.app/Contents/Info.plist"%target
1386                         targetinfo = "%s.app/Contents/Info.plist"%target
1387
1388                         cmd = '%s.app'%target
1389                         if os.path.isdir(cmd):
1390                                 shutil.rmtree('%s.app'%target)
1391                         shutil.copytree("source/darwin/%s.app"%target, '%s.app'%target)
1392                         cmd = "cat %s | sed s/VERSION/`cat release/VERSION`/ | sed s/DATE/`date +'%%Y-%%b-%%d'`/ > %s"%(sourceinfo,targetinfo)
1393                         commands.getoutput(cmd)
1394                         cmd = 'cp %s %s.app/Contents/MacOS/%s'%(target, target, target)
1395                         commands.getoutput(cmd)
1396                         if  user_options_dict['BUILD_BINARY'] == 'debug':
1397                                 print "building debug player"
1398                         else :
1399                                 cmd = 'strip -u -r %s.app/Contents/MacOS/%s'%(target, target)
1400                                 commands.getoutput(cmd)
1401                         cmd = '%s.app/Contents/Resources/'%target
1402                         shutil.copy('bin/.blender/.bfont.ttf', cmd)
1403                         shutil.copy('bin/.blender/.Blanguages', cmd)
1404                         cmd = 'cp -R bin/.blender/locale %s.app/Contents/Resources/'%target
1405                         commands.getoutput(cmd)
1406                         cmd = 'cp -R release/bpydata %s.app/Contents/MacOS/.blender'%target
1407                         commands.getoutput(cmd)
1408                         cmd = 'cp -R release/scripts %s.app/Contents/MacOS/.blender/'%target
1409                         commands.getoutput(cmd)
1410                         cmd = 'cp -R release/plugins %s.app/Contents/Resources/'%target 
1411                         commands.getoutput(cmd)
1412                         cmd = 'chmod +x  %s.app/Contents/MacOS/%s'%(target, target)
1413                         commands.getoutput(cmd)
1414                         cmd = 'find %s.app -name CVS -prune -exec rm -rf {} \;'%target
1415                         commands.getoutput(cmd)
1416                         cmd = 'find %s.app -name .DS_Store -exec rm -rf {} \;'%target
1417                         commands.getoutput(cmd)
1418                 
1419         else:
1420                 print "This target is for the Os X platform only"
1421
1422 def zipit(env, target, source):
1423         try:
1424                 if sys.platform == 'win32':
1425                         import zipfile
1426                 else:
1427                         import tarfile
1428         except:
1429                 if sys.platform == 'win32':
1430                         print "no zipfile module found"
1431                 else:
1432                         print "no tarfile module found"
1433                         print "make sure you use python 2.3"
1434                 print
1435                 return
1436         
1437         import shutil
1438         import glob
1439         import time
1440         
1441         startdir = os.getcwd()
1442         pf=""
1443         zipext = ""
1444         zipname = ""
1445         
1446         today = time.strftime("%Y%m%d", time.gmtime()) # get time in the form 20040714
1447         
1448         if preparedist()==0:
1449                 print "check output for error"
1450                 return
1451         
1452         if sys.platform == 'win32':
1453                 zipext += ".zip"
1454                 pf = "windows"
1455         elif sys.platform == 'linux2' or sys.platform == 'linux-i386':
1456                 zipext += ".tar.gz"
1457                 pf = "linux"
1458         elif sys.platform == 'freebsd4':
1459                 zipext += ".tar.gz"
1460                 pf = "freebsd4"
1461         elif sys.platform == 'freebsd5':
1462                 zipext += ".tar.gz"
1463                 pf = "freebsd5"
1464         
1465         if user_options_dict['BUILD_BINARY'] == 'release':
1466                 blendname = "blender-" + version + "-" + config_guess
1467         else:
1468                 blendname = "bf_blender_" + pf + "_" + today
1469         
1470         zipname = blendname + zipext
1471
1472         if os.path.isdir(blendname):
1473                 shutil.rmtree(blendname)
1474         shutil.move(startdir + os.sep + "dist", blendname)
1475
1476         print
1477         if sys.platform == 'win32':
1478                 print "Create the zip!"
1479         else:
1480                 print "Create the tarball!"
1481         print
1482         
1483         if sys.platform == 'win32':
1484                 thezip = zipfile.ZipFile(zipname, 'w', zipfile.ZIP_DEFLATED)
1485         else:
1486                 thezip = tarfile.open(zipname, 'w:gz')
1487         
1488         for root, dirs, files in os.walk(blendname, topdown=False):
1489                 for name in files:
1490                         if name in [zipname]:
1491                                 print "skipping self"
1492                         else:
1493                                 file = root + "/" + name
1494                                 print "adding: " + file
1495                                 add2arc(thezip, file)
1496         
1497         thezip.close()
1498         
1499         os.chdir(startdir)
1500         shutil.move(blendname, startdir + os.sep + "dist")
1501         
1502         if finalisedist(zipname)==0:
1503                 print "encountered an error in finalisedist"
1504                 print
1505                 return
1506         
1507         print
1508         print "Blender has been successfully packaged"
1509         print "You can find the file %s in the root source directory"%zipname
1510         print
1511         
1512
1513 def printadd(env, target, source):
1514         """
1515         Print warning message if platform hasn't been added to zipit() yet
1516         """
1517         
1518         print
1519         print "############"
1520         print 
1521         print "Make sure zipit() works for your platform:"
1522         print "  - binaries to copy (naming?)"
1523         print "  - possible libraries?"
1524         print "  - archive format?"
1525         print
1526         print "After you've corrected zipit() for your"
1527         print "platform, be sure to add a proper elif"
1528         print "at the end of BlenderRelease"
1529         print
1530         print "Blender is now ready and can be found in"
1531         print "root of the source distribution, but it"
1532         print "hasn't been packaged neatly. Make sure you"
1533         print "get the right files"
1534         print
1535         print "/jesterKing"
1536         print
1537         
1538
1539 def noaction(env, target, source):
1540         print "Empty action"
1541
1542 def DoClean(dir2clean):
1543         """
1544         Do a removal of the root_build_dir the fast way
1545         """
1546         
1547         import shutil
1548         print
1549         print "start the clean"
1550         dirs = os.listdir(dir2clean)
1551         for dir in dirs:
1552                 if os.path.isdir(dir2clean + "/" + dir) == 1:
1553                         print "clean dir %s"%(dir2clean+"/" + dir)
1554                         shutil.rmtree(dir2clean+"/" + dir)
1555         print "done"
1556
1557 def BlenderDefault(target):
1558         """
1559         The default Blender build.
1560         """
1561         def_env = Environment()
1562         default = def_env.Command('nozip', 'blender$PROGSUFFIX', noaction)
1563         if user_options_dict['BUILD_BLENDER_PLAYER'] == 1:
1564                 def_env.Depends(default, 'blenderplayer$PROGSUFFIX')
1565         def_env.Alias(".", default)
1566
1567 def donsis(env, target, source):
1568         """
1569         Create a Windows installer with NSIS
1570         """
1571         print
1572         print "Creating the Windows installer"
1573         print
1574         
1575         startdir = os.getcwd()
1576         
1577         if preparedist()==0:
1578                 print "check output for error"
1579                 return
1580         
1581         os.chdir("release/windows/installer")
1582         
1583         nsis = open("00.sconsblender.nsi", 'r')
1584         nsis_cnt = str(nsis.read())
1585         nsis.close()
1586         
1587         # do root
1588         rootlist = []
1589         rootdir = os.listdir(startdir + "\\dist")
1590         for rootitem in rootdir:
1591                 if os.path.isdir(startdir + "\\dist\\" + rootitem) == 0:
1592                         rootlist.append("File " + startdir + "\\dist\\" + rootitem)
1593         rootstring = string.join(rootlist, "\n  ")
1594         rootstring += "\n\n"
1595         nsis_cnt = string.replace(nsis_cnt, "[ROOTDIRCONTS]", rootstring)
1596         
1597         # do delete items
1598         delrootlist = []
1599         for rootitem in rootdir:
1600                 if os.path.isdir(startdir + "\\dist\\" + rootitem) == 0:
1601                         delrootlist.append("Delete $INSTDIR\\" + rootitem)
1602         delrootstring = string.join(delrootlist, "\n ")
1603         delrootstring += "\n"
1604         nsis_cnt = string.replace(nsis_cnt, "[DELROOTDIRCONTS]", delrootstring)
1605         
1606         # do scripts
1607         scriptlist = []
1608         scriptdir = os.listdir(startdir + "\\dist\\.blender\\scripts")
1609         for scriptitem in scriptdir:
1610                 if os.path.isdir(startdir + "\\dist\\.blender\\scripts\\" + scriptitem) == 0:
1611                         scriptlist.append("File " + startdir + "\\dist\\.blender\\scripts\\" + scriptitem)
1612         scriptstring = string.join(scriptlist, "\n  ")
1613         scriptstring += "\n\n"
1614         nsis_cnt = string.replace(nsis_cnt, "[SCRIPTCONTS]", scriptstring)
1615         
1616         # do bpycontents
1617         bpydatalist = []
1618         bpydatadir = os.listdir(startdir + "\\dist\\.blender\\bpydata")
1619         for bpydataitem in bpydatadir:
1620                 if os.path.isdir(startdir + "\\dist\\.blender\\bpydata\\" + bpydataitem) == 0:
1621                         bpydatalist.append("File " + startdir + "\\dist\\.blender\\bpydata\\" + bpydataitem)
1622         bpydatastring = string.join(bpydatalist, "\n  ")
1623         bpydatastring += "\n\n"
1624         nsis_cnt = string.replace(nsis_cnt, "[BPYCONTS]", bpydatastring)
1625         
1626         # do dotblender
1627         dotblendlist = []
1628         dotblenddir = os.listdir(startdir+"\\dist\\.blender")
1629         for dotblenditem in dotblenddir:
1630                 if os.path.isdir(startdir + "\\dist\\.blender\\" + dotblenditem) == 0:
1631                         dotblendlist.append("File " + startdir + "\\dist\\.blender\\" + dotblenditem)
1632         dotblendstring = string.join(dotblendlist, "\n  ")
1633         dotblendstring += "\n\n"
1634         nsis_cnt = string.replace(nsis_cnt, "[DOTBLENDERCONTS]", dotblendstring)
1635         
1636         # do language files
1637         langlist = []
1638         langfiles = []
1639         langdir = os.listdir(startdir + "\\dist\\.blender\\locale")
1640         for langitem in langdir:
1641                 if os.path.isdir(startdir + "\\dist\\.blender\\locale\\" + langitem) == 1:
1642                         langfiles.append("SetOutPath $BLENDERHOME\\.blender\\locale\\" + langitem + "\\LC_MESSAGES")
1643                         langfiles.append("File " + startdir + "\\dist\\.blender\\locale\\" + langitem + "\\LC_MESSAGES\\blender.mo")
1644         langstring = string.join(langfiles, "\n  ")
1645         langstring += "\n\n"
1646         nsis_cnt = string.replace(nsis_cnt, "[LANGUAGECONTS]", langstring)
1647         
1648         # var replacements
1649         nsis_cnt = string.replace(nsis_cnt, "DISTDIR", startdir + "\\dist")
1650         nsis_cnt = string.replace(nsis_cnt, "SHORTVER", shortversion)
1651         nsis_cnt = string.replace(nsis_cnt, "VERSION", version)
1652         
1653         new_nsis = open("00.blender_tmp.nsi", 'w')
1654         new_nsis.write(nsis_cnt)
1655         new_nsis.close()
1656         
1657         sys.stdout = os.popen("makensis 00.blender_tmp.nsi", 'w')
1658         
1659         os.chdir(startdir)
1660         
1661         
1662 def BlenderNSIS(target):
1663         """
1664         Entry for creating Windows installer
1665         """
1666         if sys.platform == 'win32':
1667                 inst_env = Environment()
1668                 nsis_inst = inst_env.Command('nsisinstaller', 'blender$PROGSUFFIX', donsis)
1669                 if user_options_dict['BUILD_BLENDER_PLAYER'] == 1:
1670                         inst_env.Depends(nsis_inst, 'blenderplayer$PROGSUFFIX')
1671                 inst_env.Alias("wininst", nsis_inst)
1672         else:
1673                 print "This target is for the win32 platform only "
1674
1675 def BlenderRelease(target):
1676         """
1677         Make a Release package (tarball, zip, bundle).
1678         
1679         target = Name of package to make (string)
1680         eg: BlenderRelease('blender')
1681         """
1682         
1683         if sys.platform == 'darwin':
1684                 app_env = Environment()
1685                 Mappit = app_env.Command('appit', appname, appit)
1686                 if user_options_dict['BUILD_BLENDER_PLAYER'] == 1:
1687                         app_env.Depends(Mappit, playername)
1688                 app_env.Alias("release", Mappit)
1689         elif sys.platform in ['win32', 'linux2', 'linux-i386', 'freebsd4', 'freebsd5']:
1690                 release_env = Environment()
1691                 releaseit = release_env.Command('blenderrelease', appname, zipit)
1692                 if user_options_dict['BUILD_BLENDER_PLAYER'] == 1:
1693                         release_env.Depends(releaseit, playername)
1694                 release_env.Alias("release", releaseit)
1695         else:
1696                 release_env = Environment()
1697                 releaseit = release_env.Command('blender.tar.gz', appname, printadd)
1698                 if user_options_dict['BUILD_BLENDER_PLAYER'] == 1:
1699                         release_env.Depends(releaseit, playername)
1700                 release_env.Alias("release", releaseit)
1701
1702 if enable_clean == 0:
1703
1704         
1705         if user_options_dict['BUILD_BLENDER_DYNAMIC'] == 1:
1706                 dy_blender = link_env.Copy ()
1707                 if sys.platform=='win32':
1708                         winblenderres(dy_blender)
1709                 blender_libs(dy_blender)
1710                 common_libs(dy_blender)
1711                 international_libs(dy_blender)
1712                 ketsji_libs(dy_blender)
1713                 system_libs(dy_blender)
1714                 dy_blender.Append (LIBS=user_options_dict['OPENGL_LIBRARY'])
1715                 dy_blender.Append (LIBPATH=user_options_dict['OPENGL_LIBPATH'])
1716                 dy_blender.Append (CPPPATH=user_options_dict['OPENGL_INCLUDE'])
1717                 d_obj = buildinfo(dy_blender, "dynamic")
1718                 if sys.platform == 'win32':
1719                         dy_blender.Program (target='blender',
1720                                                 source=d_obj + ['source/icons/winblender.res'])
1721                 else:
1722                         if sys.platform == 'cygwin':
1723                                 dy_blender.Replace (CC='g++')
1724                         dy_blender.Program (target='blender', source=d_obj)
1725         
1726         if user_options_dict['BUILD_BLENDER_STATIC'] == 1:
1727                 st_blender = link_env.Copy ()
1728                 if sys.platform=='win32':
1729                         winblenderres(st_blender)
1730                 blender_libs(st_blender)
1731                 common_libs(st_blender)
1732                 international_libs(st_blender)
1733                 ketsji_libs(st_blender)
1734                 system_libs(st_blender)
1735                 # The next line is to make sure that the LINKFLAGS are appended at the end
1736                 # of the link command. This 'trick' is needed because the GL and GLU static
1737                 # libraries need to be at the end of the command.
1738                 st_blender.Replace(LINKCOM="$LINK -o $TARGET $SOURCES $_LIBDIRFLAGS $_LIBFLAGS $LINKFLAGS")
1739                 s_obj = buildinfo(st_blender, "static")
1740                 st_blender.Append (LINKFLAGS=user_options_dict['OPENGL_STATIC'])
1741                 st_blender.Append (CPPPATH=user_options_dict['OPENGL_INCLUDE'])
1742                 st_blender.Prepend (LIBPATH=['/usr/lib/opengl/xfree/lib'])
1743                 st_blender.Program (target='blenderstatic', source=s_obj)
1744         
1745         if sys.platform=='win32':
1746                 if user_options_dict['BUILD_BINARY']=='debug':
1747                         browser = Environment()
1748                         browser_tmp = root_build_dir+'bscmake.tmp'
1749                         browser.Command ('blender.bsc', 'blender$PROGSUFFIX',
1750                                 ['dir /b/s '+root_build_dir+'*.sbr >'+browser_tmp,
1751                                  'bscmake /nologo /n /oblender.bsc @'+browser_tmp,
1752                                  'del '+browser_tmp])
1753         
1754         if user_options_dict['BUILD_BLENDER_PLAYER'] == 1 and user_options_dict['BUILD_GAMEENGINE'] == 1:
1755                 player_blender = link_env.Copy()
1756                 player_libs(player_blender)
1757                 common_libs(player_blender)
1758                 international_libs(player_blender)
1759                 ketsji_libs(player_blender)
1760                 player_libs2(player_blender)
1761                 system_libs(player_blender)
1762                 player_blender.Append (LIBS=user_options_dict['OPENGL_LIBRARY'])
1763                 player_blender.Append (LIBPATH=user_options_dict['OPENGL_LIBPATH'])
1764                 player_blender.Append (CPPPATH=user_options_dict['OPENGL_INCLUDE'])
1765                 d_obj = buildinfo(player_blender, "player")
1766                 if sys.platform == 'win32':
1767                         player_blender.Program (target='blenderplayer',
1768                                                 source=d_obj + ['source/icons/winblender.res'])
1769                 else:
1770                         if sys.platform == 'cygwin':
1771                                 player_blender.Replace (CC='g++')
1772                         player_blender.Program (target='blenderplayer', source=d_obj)
1773                 if sys.platform=='win32':
1774                         if user_options_dict['BUILD_BINARY']=='debug':
1775                                 browser = Environment()
1776                                 browser_tmp = root_build_dir+'bscmake.tmp'
1777                                 browser.Command ('blenderplayer.bsc', 'blenderplayer$PROGSUFFIX',
1778                                 ['dir /b/s '+root_build_dir+'*.sbr >'+browser_tmp,
1779                                 'bscmake /nologo /n /oblenderplayer.bsc @'+browser_tmp,
1780                                 'del '+browser_tmp])
1781
1782         release_target = env.Alias("release", BlenderRelease(appname))
1783         default_target = env.Alias("default", BlenderDefault(appname))
1784         wininst_target = env.Alias("winist", BlenderNSIS(appname))
1785                 
1786 else: # only clean target to prevent any building
1787         clean_target = env.Alias("clean", DoClean(root_build_dir))
1788         Default("clean")
1789
1790 if enable_clean == 0: # only set up dependencies when not cleaning
1791         if sys.platform == 'darwin':
1792                 Default("release")
1793         else:
1794                 Default("default")
1795
1796         if sys.platform == 'win32':
1797                 if user_options_dict['BUILD_BLENDER_PLAYER'] == 1:
1798                         env.Depends(wininst_target, playername)
1799                 env.Depends(wininst_target, appname)
1800         
1801         if user_options_dict['BUILD_BLENDER_PLAYER'] == 1:
1802                 env.Depends(release_target, playername)
1803         env.Depends(release_target, appname)
1804         
1805         if user_options_dict['BUILD_BLENDER_PLAYER'] == 1:
1806                 env.Depends(default_target, playername)
1807         env.Depends(default_target, appname)
1808