this restores building on mingw with Collada support, also it restores cross compilin...
[blender.git] / SConstruct
1 #!/usr/bin/env python
2 # $Id$
3 # ***** BEGIN GPL LICENSE BLOCK *****
4 #
5 # This program is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU General Public License
7 # as published by the Free Software Foundation; either version 2
8 # of the License, or (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software Foundation,
17 # Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
18 #
19 # The Original Code is Copyright (C) 2006, Blender Foundation
20 # All rights reserved.
21 #
22 # The Original Code is: all of this file.
23 #
24 # Contributor(s): Nathan Letwory.
25 #
26 # ***** END GPL LICENSE BLOCK *****
27 #
28 # Main entry-point for the SCons building system
29 # Set up some custom actions and target/argument handling
30 # Then read all SConscripts and build
31
32 import platform as pltfrm
33
34 # Need a better way to do this. Automagical maybe is not the best thing, maybe it is.
35 if pltfrm.architecture()[0] == '64bit':
36         bitness = 64
37 else:
38         bitness = 32
39
40 import sys
41 import os
42 import os.path
43 import string
44 import shutil
45 import glob
46 import re
47 from tempfile import mkdtemp
48
49 import tools.Blender
50 import tools.btools
51 import tools.bcolors
52
53 EnsureSConsVersion(1,0,0)
54
55 BlenderEnvironment = tools.Blender.BlenderEnvironment
56 btools = tools.btools
57 B = tools.Blender
58
59 ### globals ###
60 platform = sys.platform
61 quickie = None
62 quickdebug = None
63
64 ##### BEGIN SETUP #####
65
66 B.possible_types = ['core', 'player', 'intern', 'extern']
67
68 B.binarykind = ['blender' , 'blenderplayer']
69 ##################################
70 # target and argument validation #
71 ##################################
72 # XX cheating for BF_FANCY, we check for BF_FANCY before args are validated
73 use_color = ARGUMENTS.get('BF_FANCY', '1')
74 if platform=='win32':
75         use_color = None
76
77 if not use_color=='1':
78         B.bc.disable()
79         
80  #on defaut white Os X terminal, some colors are totally unlegible
81 if platform=='darwin':
82         B.bc.OKGREEN = '\033[34m'
83         B.bc.WARNING = '\033[36m'
84
85 # arguments
86 print B.bc.HEADER+'Command-line arguments'+B.bc.ENDC
87 B.arguments = btools.validate_arguments(ARGUMENTS, B.bc)
88 btools.print_arguments(B.arguments, B.bc)
89
90 # targets
91 print B.bc.HEADER+'Command-line targets'+B.bc.ENDC
92 B.targets = btools.validate_targets(COMMAND_LINE_TARGETS, B.bc)
93 btools.print_targets(B.targets, B.bc)
94
95 ##########################
96 # setting up environment #
97 ##########################
98
99 # handling cmd line arguments & config file
100
101 # first check cmdline for toolset and we create env to work on
102 quickie = B.arguments.get('BF_QUICK', None)
103 quickdebug = B.arguments.get('BF_QUICKDEBUG', None)
104
105 if quickdebug:
106         B.quickdebug=string.split(quickdebug, ',')
107 else:
108         B.quickdebug=[]
109
110 if quickie:
111         B.quickie=string.split(quickie,',')
112 else:
113         B.quickie=[]
114         
115 toolset = B.arguments.get('BF_TOOLSET', None)
116 if toolset:
117         print "Using " + toolset
118         if toolset=='mstoolkit':
119                 env = BlenderEnvironment(ENV = os.environ)
120                 env.Tool('mstoolkit', ['tools'])
121         else:
122                 env = BlenderEnvironment(tools=[toolset], ENV = os.environ)
123                 # xxx commented out, as was supressing warnings under mingw..
124                 #if env:
125                 #       btools.SetupSpawn(env)
126 else:
127         if bitness==64 and platform=='win32':
128                 env = BlenderEnvironment(ENV = os.environ, MSVS_ARCH='amd64')
129         else:
130                 env = BlenderEnvironment(ENV = os.environ)
131
132 if not env:
133         print "Could not create a build environment"
134         Exit()
135
136
137 cc = B.arguments.get('CC', None)
138 cxx = B.arguments.get('CXX', None)
139 if cc:
140         env['CC'] = cc
141 if cxx:
142         env['CXX'] = cxx
143
144 if env['CC'] in ['cl', 'cl.exe'] and sys.platform=='win32':
145         if bitness == 64:
146                 platform = 'win64-vc'
147         else:
148                 platform = 'win32-vc'
149 elif env['CC'] in ['gcc'] and sys.platform=='win32':
150         platform = 'win32-mingw'
151
152 env.SConscriptChdir(0)
153
154 crossbuild = B.arguments.get('BF_CROSS', None)
155 if crossbuild and platform not in ('win32-vc', 'win64-vc'):
156         platform = 'linuxcross'
157
158 env['OURPLATFORM'] = platform
159
160 configfile = 'config'+os.sep+platform+'-config.py'
161
162 if os.path.exists(configfile):
163         print B.bc.OKGREEN + "Using config file: " + B.bc.ENDC + configfile
164 else:
165         print B.bc.FAIL + configfile + " doesn't exist" + B.bc.ENDC
166
167 if crossbuild and env['PLATFORM'] != 'win32':
168         print B.bc.HEADER+"Preparing for crossbuild"+B.bc.ENDC
169         env.Tool('crossmingw', ['tools'])
170         # todo: determine proper libs/includes etc.
171         # Needed for gui programs, console programs should do without it
172
173         # Now we don't need this option to have console window
174         # env.Append(LINKFLAGS=['-mwindows'])
175
176 userconfig = B.arguments.get('BF_CONFIG', 'user-config.py')
177 # first read platform config. B.arguments will override
178 optfiles = [configfile]
179 if os.path.exists(userconfig):
180         print B.bc.OKGREEN + "Using user-config file: " + B.bc.ENDC + userconfig
181         optfiles += [userconfig]
182 else:
183         print B.bc.WARNING + userconfig + " not found, no user overrides" + B.bc.ENDC
184
185 opts = btools.read_opts(optfiles, B.arguments)
186 opts.Update(env)
187
188 if not env['BF_FANCY']:
189         B.bc.disable()
190
191 SetOption('num_jobs', int(env['BF_NUMJOBS']))
192 print "Build with %d parallel jobs" % (GetOption('num_jobs'))
193
194 # BLENDERPATH is a unix only option to enable typical style paths this is
195 # spesifically a data-dir, which is used a lot but cant replace BF_INSTALLDIR
196 # because the blender binary is installed in $BF_INSTALLDIR/bin/blender
197
198 if env['WITH_BF_FHS']:
199         BLENDERPATH = os.path.join(env['BF_INSTALLDIR'], 'share', 'blender', env['BF_VERSION'])
200 else:
201         BLENDERPATH = env['BF_INSTALLDIR']
202
203 # disable elbeem (fluidsim) compilation?
204 if env['BF_NO_ELBEEM'] == 1:
205         env['CPPFLAGS'].append('-DDISABLE_ELBEEM')
206         env['CXXFLAGS'].append('-DDISABLE_ELBEEM')
207         env['CCFLAGS'].append('-DDISABLE_ELBEEM')
208
209 if env['WITH_BF_OPENMP'] == 1:
210                 if env['OURPLATFORM'] in ('win32-vc', 'win64-vc'):
211                                 env['CCFLAGS'].append('/openmp')
212                                 env['CPPFLAGS'].append('/openmp')
213                                 env['CXXFLAGS'].append('/openmp')
214                 else:
215                         if env['CC'].endswith('icc'): # to be able to handle CC=/opt/bla/icc case
216                                 env.Append(LINKFLAGS=['-openmp', '-static-intel'])
217                                 env['CCFLAGS'].append('-openmp')
218                                 env['CPPFLAGS'].append('-openmp')
219                                 env['CXXFLAGS'].append('-openmp')
220                         else:
221                                 env.Append(CCFLAGS=['-fopenmp']) 
222                                 env.Append(CPPFLAGS=['-fopenmp'])
223                                 env.Append(CXXFLAGS=['-fopenmp'])
224
225 if env['WITH_GHOST_COCOA'] == True:
226         env.Append(CFLAGS=['-DGHOST_COCOA']) 
227         env.Append(CXXFLAGS=['-DGHOST_COCOA'])
228         env.Append(CPPFLAGS=['-DGHOST_COCOA'])
229     
230 if env['USE_QTKIT'] == True:
231         env.Append(CFLAGS=['-DUSE_QTKIT']) 
232         env.Append(CXXFLAGS=['-DUSE_QTKIT'])
233         env.Append(CPPFLAGS=['-DUSE_QTKIT'])
234
235 #check for additional debug libnames
236
237 if env.has_key('BF_DEBUG_LIBS'):
238         B.quickdebug += env['BF_DEBUG_LIBS']
239
240 printdebug = B.arguments.get('BF_LISTDEBUG', 0)
241
242 # see if this linux distro has libalut
243
244 if env['OURPLATFORM'] == 'linux2' :
245         if env['WITH_BF_OPENAL']:
246                 mylib_test_source_file = """
247                 #include "AL/alut.h"
248                 int main(int argc, char **argv)
249                 {
250                         alutGetMajorVersion();
251                         return 0;
252                 }
253                 """
254
255                 def CheckFreeAlut(context,env):
256                         context.Message( B.bc.OKGREEN + "Linux platform detected:\n  checking for FreeAlut... " + B.bc.ENDC )
257                         env['LIBS'] = 'alut'
258                         result = context.TryLink(mylib_test_source_file, '.c')
259                         context.Result(result)
260                         return result
261
262                 env2 = env.Clone( LIBPATH = env['BF_OPENAL'] ) 
263                 sconf_temp = mkdtemp()
264                 conf = Configure( env2, {'CheckFreeAlut' : CheckFreeAlut}, sconf_temp, '/dev/null' )
265                 if conf.CheckFreeAlut( env2 ):
266                         env['BF_OPENAL_LIB'] += ' alut'
267                 del env2
268                 root = ''
269                 for root, dirs, files in os.walk(sconf_temp, topdown=False):
270                         for name in files:
271                                 os.remove(os.path.join(root, name))
272                         for name in dirs:
273                                 os.rmdir(os.path.join(root, name))
274                 if root: os.rmdir(root)
275
276 if len(B.quickdebug) > 0 and printdebug != 0:
277         print B.bc.OKGREEN + "Buildings these libs with debug symbols:" + B.bc.ENDC
278         for l in B.quickdebug:
279                 print "\t" + l
280
281 # remove stdc++ from LLIBS if we are building a statc linked CXXFLAGS
282 if env['WITH_BF_STATICCXX']:
283         if 'stdc++' in env['LLIBS']:
284                 env['LLIBS'].remove('stdc++')
285         else:
286                 print '\tcould not remove stdc++ library from LLIBS, WITH_BF_STATICCXX may not work for your platform'
287
288 # check target for blenderplayer. Set WITH_BF_PLAYER if found on cmdline
289 if 'blenderplayer' in B.targets:
290         env['WITH_BF_PLAYER'] = True
291
292 if 'blendernogame' in B.targets:
293         env['WITH_BF_GAMEENGINE'] = False
294
295 if 'blenderlite' in B.targets:
296         target_env_defs = {}
297         target_env_defs['WITH_BF_GAMEENGINE'] = False
298         target_env_defs['WITH_BF_OPENAL'] = False
299         target_env_defs['WITH_BF_OPENEXR'] = False
300         target_env_defs['WITH_BF_ICONV'] = False
301         target_env_defs['WITH_BF_INTERNATIONAL'] = False
302         target_env_defs['WITH_BF_OPENJPEG'] = False
303         target_env_defs['WITH_BF_FFMPEG'] = False
304         target_env_defs['WITH_BF_QUICKTIME'] = False
305         target_env_defs['WITH_BF_REDCODE'] = False
306         target_env_defs['WITH_BF_DDS'] = False
307         target_env_defs['WITH_BF_ZLIB'] = False
308         target_env_defs['WITH_BF_SDL'] = False
309         target_env_defs['WITH_BF_JPEG'] = False
310         target_env_defs['WITH_BF_PNG'] = False
311         target_env_defs['WITH_BF_BULLET'] = False
312         target_env_defs['WITH_BF_BINRELOC'] = False
313         target_env_defs['BF_BUILDINFO'] = False
314         target_env_defs['BF_NO_ELBEEM'] = True
315         target_env_defs['WITH_BF_PYTHON'] = False
316         
317         # Merge blenderlite, let command line to override
318         for k,v in target_env_defs.iteritems():
319                 if k not in B.arguments:
320                         env[k] = v
321
322 if env['WITH_BF_SDL'] == False and env['OURPLATFORM'] in ('win32-vc', 'win32-ming', 'win64-vc'):
323         env['PLATFORM_LINKFLAGS'].remove('/ENTRY:mainCRTStartup')
324         env['PLATFORM_LINKFLAGS'].append('/ENTRY:main')
325
326 # lastly we check for root_build_dir ( we should not do before, otherwise we might do wrong builddir
327 B.root_build_dir = env['BF_BUILDDIR']
328 B.doc_build_dir = os.path.join(BLENDERPATH, 'doc')
329 if not B.root_build_dir[-1]==os.sep:
330         B.root_build_dir += os.sep
331 if not B.doc_build_dir[-1]==os.sep:
332         B.doc_build_dir += os.sep
333         
334 # We do a shortcut for clean when no quicklist is given: just delete
335 # builddir without reading in SConscripts
336 do_clean = None
337 if 'clean' in B.targets:
338         do_clean = True
339
340 if not quickie and do_clean:
341         if os.path.exists(B.doc_build_dir):
342                 print B.bc.HEADER+'Cleaning doc dir...'+B.bc.ENDC
343                 dirs = os.listdir(B.doc_build_dir)
344                 for entry in dirs:
345                         if os.path.isdir(B.doc_build_dir + entry) == 1:
346                                 print "clean dir %s"%(B.doc_build_dir+entry)
347                                 shutil.rmtree(B.doc_build_dir+entry)
348                         else: # remove file
349                                 print "remove file %s"%(B.doc_build_dir+entry)
350                                 os.remove(B.root_build_dir+entry)
351         if os.path.exists(B.root_build_dir):
352                 print B.bc.HEADER+'Cleaning build dir...'+B.bc.ENDC
353                 dirs = os.listdir(B.root_build_dir)
354                 for entry in dirs:
355                         if os.path.isdir(B.root_build_dir + entry) == 1:
356                                 print "clean dir %s"%(B.root_build_dir+entry)
357                                 shutil.rmtree(B.root_build_dir+entry)
358                         else: # remove file
359                                 print "remove file %s"%(B.root_build_dir+entry)
360                                 os.remove(B.root_build_dir+entry)
361                 for confile in ['extern/ffmpeg/config.mak', 'extern/x264/config.mak',
362                                 'extern/xvidcore/build/generic/platform.inc', 'extern/ffmpeg/include']:
363                         if os.path.exists(confile):
364                                 print "clean file %s"%confile
365                                 if os.path.isdir(confile):
366                                         for root, dirs, files in os.walk(confile):
367                                                 for name in files:
368                                                         os.remove(os.path.join(root, name))
369                                 else:
370                                         os.remove(confile)
371                 print B.bc.OKGREEN+'...done'+B.bc.ENDC
372         else:
373                 print B.bc.HEADER+'Already Clean, nothing to do.'+B.bc.ENDC
374         Exit()
375
376 if not os.path.isdir ( B.root_build_dir):
377         os.makedirs ( B.root_build_dir )
378         os.makedirs ( B.root_build_dir + 'source' )
379         os.makedirs ( B.root_build_dir + 'intern' )
380         os.makedirs ( B.root_build_dir + 'extern' )
381         os.makedirs ( B.root_build_dir + 'lib' )
382         os.makedirs ( B.root_build_dir + 'bin' )
383 if not os.path.isdir(B.doc_build_dir) and env['WITH_BF_DOCS']:
384         os.makedirs ( B.doc_build_dir )
385
386 Help(opts.GenerateHelpText(env))
387
388 # default is new quieter output, but if you need to see the 
389 # commands, do 'scons BF_QUIET=0'
390 bf_quietoutput = B.arguments.get('BF_QUIET', '1')
391 if env['BF_QUIET']:
392         B.set_quiet_output(env)
393 else:
394         if toolset=='msvc':
395                 B.msvc_hack(env)
396
397 print B.bc.HEADER+'Building in '+B.bc.ENDC+B.root_build_dir
398 env.SConsignFile(B.root_build_dir+'scons-signatures')
399 B.init_lib_dict()
400
401 ##### END SETUP ##########
402
403 Export('env')
404
405 BuildDir(B.root_build_dir+'/intern', 'intern', duplicate=0)
406 SConscript(B.root_build_dir+'/intern/SConscript')
407 BuildDir(B.root_build_dir+'/extern', 'extern', duplicate=0)
408 SConscript(B.root_build_dir+'/extern/SConscript')
409 BuildDir(B.root_build_dir+'/source', 'source', duplicate=0)
410 SConscript(B.root_build_dir+'/source/SConscript')
411
412 # now that we have read all SConscripts, we know what
413 # libraries will be built. Create list of
414 # libraries to give as objects to linking phase
415 mainlist = []
416 for tp in B.possible_types:
417         if not tp == 'player':
418                 mainlist += B.create_blender_liblist(env, tp)
419
420 if B.arguments.get('BF_PRIORITYLIST', '0')=='1':
421         B.propose_priorities()
422
423 dobj = B.buildinfo(env, "dynamic") + B.resources
424 thestatlibs, thelibincs = B.setup_staticlibs(env)
425 thesyslibs = B.setup_syslibs(env)
426
427 if 'blender' in B.targets or not env['WITH_BF_NOBLENDER']:
428         env.BlenderProg(B.root_build_dir, "blender", dobj + mainlist, [], thestatlibs + thesyslibs, [B.root_build_dir+'/lib'] + thelibincs, 'blender')
429 if env['WITH_BF_PLAYER']:
430         playerlist = B.create_blender_liblist(env, 'player')
431         playerlist += B.create_blender_liblist(env, 'intern')
432         playerlist += B.create_blender_liblist(env, 'extern')
433         env.BlenderProg(B.root_build_dir, "blenderplayer", dobj + playerlist, [], thestatlibs + thesyslibs, [B.root_build_dir+'/lib'] + thelibincs, 'blenderplayer')
434
435 ##### Now define some targets
436
437
438 #------------ INSTALL
439
440 #-- binaries
441 blenderinstall = []
442 if  env['OURPLATFORM']=='darwin':
443         for prg in B.program_list:
444                 bundle = '%s.app' % prg[0]
445                 bundledir = os.path.dirname(bundle)
446                 for dp, dn, df in os.walk(bundle):
447                         if '.svn' in dn:
448                                 dn.remove('.svn')
449                         dir=env['BF_INSTALLDIR']+dp[len(bundledir):]
450                         source=[dp+os.sep+f for f in df]
451                         blenderinstall.append(env.Install(dir=dir,source=source))
452 else:
453         if env['WITH_BF_FHS']:  dir= os.path.join(env['BF_INSTALLDIR'], 'bin')
454         else:                                   dir= env['BF_INSTALLDIR']
455         
456         blenderinstall = env.Install(dir=dir, source=B.program_list)
457
458 #-- .blender
459 #- dont do .blender and scripts for darwin, it is already in the bundle
460 dotblendlist = []
461 dottargetlist = []
462 scriptinstall = []
463
464 if  env['OURPLATFORM']!='darwin':
465                 for dp, dn, df in os.walk('bin/.blender'):
466                         if '.svn' in dn:
467                                 dn.remove('.svn')
468                         
469                         for f in df:
470                                 if not env['WITH_BF_INTERNATIONAL']:
471                                         if 'locale' in dp:
472                                                 continue
473                                         if f == '.Blanguages':
474                                                 continue
475                                 if not env['WITH_BF_FREETYPE']:
476                                         if f.endswith('.ttf'):
477                                                 continue
478                                 
479                                 dotblendlist.append(os.path.join(dp, f))
480                                 if env['WITH_BF_FHS']:  dir= os.path.join(*([BLENDERPATH] + dp.split(os.sep)[2:]))      # skip bin/.blender
481                                 else:                                   dir= os.path.join(*([BLENDERPATH] + dp.split(os.sep)[1:]))      # skip bin
482                                 
483                                 # print dir+ os.sep + f
484                                 print dir
485                                 dottargetlist.append(dir + os.sep + f)
486                                         
487
488                 dotblenderinstall = []
489                 for targetdir,srcfile in zip(dottargetlist, dotblendlist):
490                         td, tf = os.path.split(targetdir)
491                         dotblenderinstall.append(env.Install(dir=td, source=srcfile))
492                 
493                 if env['WITH_BF_PYTHON']:
494                         #-- .blender/scripts
495                         scriptpaths=['release/scripts']
496                         for scriptpath in scriptpaths:
497                                 for dp, dn, df in os.walk(scriptpath):
498                                         if '.svn' in dn:
499                                                 dn.remove('.svn')
500                                         
501                                         if env['WITH_BF_FHS']:          dir = BLENDERPATH
502                                         else:                                           dir = os.path.join(env['BF_INSTALLDIR'], '.blender')                            
503                                         dir += os.sep + os.path.basename(scriptpath) + dp[len(scriptpath):]
504                                         
505                                         source=[os.path.join(dp, f) for f in df if f[-3:]!='pyc']
506                                         scriptinstall.append(env.Install(dir=dir,source=source))
507
508 #-- icons
509 if env['OURPLATFORM']=='linux2':
510         iconlist = []
511         icontargetlist = []
512
513         for tp, tn, tf in os.walk('release/freedesktop/icons'):
514                 if '.svn' in tn:
515                         tn.remove('.svn')
516                 for f in tf:
517                         iconlist.append(os.path.join(tp, f))
518                         icontargetlist.append( os.path.join(*([BLENDERPATH] + tp.split(os.sep)[2:] + [f])) )
519
520         iconinstall = []
521         for targetdir,srcfile in zip(icontargetlist, iconlist):
522                 td, tf = os.path.split(targetdir)
523                 iconinstall.append(env.Install(dir=td, source=srcfile))
524
525 # dlls for linuxcross
526 # TODO - add more libs, for now this lets blenderlite run
527 if env['OURPLATFORM']=='linuxcross':
528         dir=env['BF_INSTALLDIR']
529         source = []
530
531         if env['WITH_BF_OPENMP']:
532                 source += ['../lib/windows/pthreads/lib/pthreadGC2.dll']
533
534         scriptinstall.append(env.Install(dir=dir, source=source))
535
536 #-- plugins
537 pluglist = []
538 plugtargetlist = []
539 for tp, tn, tf in os.walk('release/plugins'):
540         if '.svn' in tn:
541                 tn.remove('.svn')
542         df = tp[8:] # remove 'release/'
543         for f in tf:
544                 pluglist.append(os.path.join(tp, f))
545                 plugtargetlist.append( os.path.join(BLENDERPATH, df, f) )
546
547
548 # header files for plugins
549 pluglist.append('source/blender/blenpluginapi/documentation.h')
550 plugtargetlist.append(os.path.join(BLENDERPATH, 'plugins', 'include', 'documentation.h'))
551 pluglist.append('source/blender/blenpluginapi/externdef.h')
552 plugtargetlist.append(os.path.join(BLENDERPATH, 'plugins', 'include', 'externdef.h'))
553 pluglist.append('source/blender/blenpluginapi/floatpatch.h')
554 plugtargetlist.append(os.path.join(BLENDERPATH, 'plugins', 'include', 'floatpatch.h'))
555 pluglist.append('source/blender/blenpluginapi/iff.h')
556 plugtargetlist.append(os.path.join(BLENDERPATH, 'plugins', 'include', 'iff.h'))
557 pluglist.append('source/blender/blenpluginapi/plugin.h')
558 plugtargetlist.append(os.path.join(BLENDERPATH, 'plugins', 'include', 'plugin.h'))
559 pluglist.append('source/blender/blenpluginapi/util.h')
560 plugtargetlist.append(os.path.join(BLENDERPATH, 'plugins', 'include', 'util.h'))
561 pluglist.append('source/blender/blenpluginapi/plugin.DEF')
562 plugtargetlist.append(os.path.join(BLENDERPATH, 'plugins', 'include', 'plugin.def'))
563
564 plugininstall = []
565 for targetdir,srcfile in zip(plugtargetlist, pluglist):
566         td, tf = os.path.split(targetdir)
567         plugininstall.append(env.Install(dir=td, source=srcfile))
568
569 textlist = []
570 texttargetlist = []
571 for tp, tn, tf in os.walk('release/text'):
572         if '.svn' in tn:
573                 tn.remove('.svn')
574         for f in tf:
575                 textlist.append(tp+os.sep+f)
576
577 textinstall = env.Install(dir=BLENDERPATH, source=textlist)
578
579 if  env['OURPLATFORM']=='darwin':
580                 allinstall = [blenderinstall, plugininstall, textinstall]
581 elif env['OURPLATFORM']=='linux2':
582                 allinstall = [blenderinstall, dotblenderinstall, scriptinstall, plugininstall, textinstall, iconinstall]
583 else:
584                 allinstall = [blenderinstall, dotblenderinstall, scriptinstall, plugininstall, textinstall]
585
586 if env['OURPLATFORM'] in ('win32-vc', 'win32-mingw', 'win64-vc', 'linuxcross'):
587         dllsources = []
588
589         if not env['OURPLATFORM'] in ('win32-mingw', 'win64-vc', 'linuxcross'):
590                 # For MinGW and linuxcross static linking will be used
591                 dllsources += ['${LCGDIR}/gettext/lib/gnu_gettext.dll']
592
593         dllsources += ['${BF_PNG_LIBPATH}/libpng.dll',
594                         '${BF_ZLIB_LIBPATH}/zlib.dll',
595                         '${BF_TIFF_LIBPATH}/${BF_TIFF_LIB}.dll']
596
597         if env['OURPLATFORM'] != 'linuxcross':
598                 # pthreads library is already added
599                 dllsources += ['${BF_PTHREADS_LIBPATH}/${BF_PTHREADS_LIB}.dll']
600
601         if env['WITH_BF_SDL']:
602                 if env['OURPLATFORM'] == 'win64-vc':
603                         pass # we link statically already to SDL on win64
604                 else:
605                         dllsources.append('${BF_SDL_LIBPATH}/SDL.dll')
606
607         if env['WITH_BF_PYTHON']:
608                 if env['BF_DEBUG']:
609                         dllsources.append('${BF_PYTHON_LIBPATH}/${BF_PYTHON_DLL}_d.dll')
610                 else:
611                         dllsources.append('${BF_PYTHON_LIBPATH}/${BF_PYTHON_DLL}.dll')
612
613         if env['WITH_BF_ICONV']:
614                 if env['OURPLATFORM'] == 'win64-vc':
615                         pass # we link statically to iconv on win64
616                 elif not env['OURPLATFORM'] in ('win32-mingw', 'linuxcross'):
617                         #gettext for MinGW and cross-compilation is compiled staticly
618                         dllsources += ['${BF_ICONV_LIBPATH}/iconv.dll']
619
620         if env['WITH_BF_OPENAL']:
621                 dllsources.append('${LCGDIR}/openal/lib/OpenAL32.dll')
622                 dllsources.append('${LCGDIR}/openal/lib/wrap_oal.dll')
623
624         if env['WITH_BF_SNDFILE']:
625                 dllsources.append('${LCGDIR}/sndfile/lib/libsndfile-1.dll')
626
627         if env['WITH_BF_FFMPEG']:
628                 dllsources += ['${BF_FFMPEG_LIBPATH}/avcodec-52.dll',
629                                         '${BF_FFMPEG_LIBPATH}/avformat-52.dll',
630                                         '${BF_FFMPEG_LIBPATH}/avdevice-52.dll',
631                                         '${BF_FFMPEG_LIBPATH}/avutil-50.dll',
632                                         '${BF_FFMPEG_LIBPATH}/swscale-0.dll']
633
634                 if env['OURPLATFORM'] != 'linuxcross':
635                         #
636                         # TODO: Does it mean we haven't got support of this codecs if
637                         #       we're using cross-compilation?
638                         #       Or in case of native compilation this libraries are
639                         #       unneccessary to?
640                         #
641                         dllsources += ['${LCGDIR}/ffmpeg/lib/libfaac-0.dll',
642                                                         '${LCGDIR}/ffmpeg/lib/libfaad-2.dll',
643                                                         '${LCGDIR}/ffmpeg/lib/libmp3lame-0.dll',
644                                                         '${LCGDIR}/ffmpeg/lib/libx264-67.dll']
645
646         if env['WITH_BF_JACK']:
647                 dllsources += ['${LCGDIR}/jack/lib/libjack.dll']
648         windlls = env.Install(dir=env['BF_INSTALLDIR'], source = dllsources)
649         allinstall += windlls
650
651 installtarget = env.Alias('install', allinstall)
652 bininstalltarget = env.Alias('install-bin', blenderinstall)
653
654 nsisaction = env.Action(btools.NSIS_Installer, btools.NSIS_print)
655 nsiscmd = env.Command('nsisinstaller', None, nsisaction)
656 nsisalias = env.Alias('nsis', nsiscmd)
657
658 if 'blender' in B.targets:
659         blenderexe= env.Alias('blender', B.program_list)
660         Depends(blenderexe,installtarget)
661
662 if env['WITH_BF_PLAYER']:
663         blenderplayer = env.Alias('blenderplayer', B.program_list)
664         Depends(blenderplayer,installtarget)
665
666 if not env['WITH_BF_GAMEENGINE']:
667         blendernogame = env.Alias('blendernogame', B.program_list)
668         Depends(blendernogame,installtarget)
669
670 if 'blenderlite' in B.targets:
671         blenderlite = env.Alias('blenderlite', B.program_list)
672         Depends(blenderlite,installtarget)
673
674 Depends(nsiscmd, allinstall)
675
676 Default(B.program_list)
677
678 if not env['WITHOUT_BF_INSTALL']:
679                 Default(installtarget)
680
681 #------------ EPYDOC
682 if env['WITH_BF_DOCS']:
683     try:
684         import epydoc
685     except ImportError:
686         epydoc = None
687
688     if epydoc:
689         SConscript('source/gameengine/PyDoc/SConscript')
690     else:
691         print "No epydoc install detected, Python API and Gameengine API Docs will not be generated "
692
693