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