tag unused vars.
[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 # store path to tools
50 toolpath=os.path.join(".", "build_files", "scons", "tools")
51
52 # needed for importing tools
53 sys.path.append(toolpath)
54
55 import Blender
56 import btools
57 import bcolors
58
59 EnsureSConsVersion(1,0,0)
60
61 BlenderEnvironment = Blender.BlenderEnvironment
62 B = Blender
63
64 VERSION = btools.VERSION # This is used in creating the local config directories
65
66 ### globals ###
67 platform = sys.platform
68 quickie = None
69 quickdebug = None
70
71 ##### BEGIN SETUP #####
72
73 B.possible_types = ['core', 'player', 'player2', 'intern', 'extern']
74
75 B.binarykind = ['blender' , 'blenderplayer']
76 ##################################
77 # target and argument validation #
78 ##################################
79 # XX cheating for BF_FANCY, we check for BF_FANCY before args are validated
80 use_color = ARGUMENTS.get('BF_FANCY', '1')
81 if platform=='win32':
82     use_color = None
83
84 if not use_color=='1':
85     B.bc.disable()
86     
87  #on defaut white Os X terminal, some colors are totally unlegible
88 if platform=='darwin':
89     B.bc.OKGREEN = '\033[34m'
90     B.bc.WARNING = '\033[36m'
91
92 # arguments
93 print B.bc.HEADER+'Command-line arguments'+B.bc.ENDC
94 B.arguments = btools.validate_arguments(ARGUMENTS, B.bc)
95 btools.print_arguments(B.arguments, B.bc)
96
97 # targets
98 print B.bc.HEADER+'Command-line targets'+B.bc.ENDC
99 B.targets = btools.validate_targets(COMMAND_LINE_TARGETS, B.bc)
100 btools.print_targets(B.targets, B.bc)
101
102 ##########################
103 # setting up environment #
104 ##########################
105
106 # handling cmd line arguments & config file
107
108 # first check cmdline for toolset and we create env to work on
109 quickie = B.arguments.get('BF_QUICK', None)
110 quickdebug = B.arguments.get('BF_QUICKDEBUG', None)
111
112 if quickdebug:
113     B.quickdebug=string.split(quickdebug, ',')
114 else:
115     B.quickdebug=[]
116
117 if quickie:
118     B.quickie=string.split(quickie,',')
119 else:
120     B.quickie=[]
121     
122 toolset = B.arguments.get('BF_TOOLSET', None)
123 if toolset:
124     print "Using " + toolset
125     if toolset=='mstoolkit':
126         env = BlenderEnvironment(ENV = os.environ)
127         env.Tool('mstoolkit', [toolpath])
128     else:
129         env = BlenderEnvironment(tools=[toolset], ENV = os.environ)
130         # xxx commented out, as was supressing warnings under mingw..
131         #if env:
132         #    btools.SetupSpawn(env)
133 else:
134     if bitness==64 and platform=='win32':
135         env = BlenderEnvironment(ENV = os.environ, MSVS_ARCH='amd64')
136     else:
137         env = BlenderEnvironment(ENV = os.environ)
138
139 if not env:
140     print "Could not create a build environment"
141     Exit()
142
143
144 cc = B.arguments.get('CC', None)
145 cxx = B.arguments.get('CXX', None)
146 if cc:
147     env['CC'] = cc
148 if cxx:
149     env['CXX'] = cxx
150
151 if env['CC'] in ['cl', 'cl.exe'] and sys.platform=='win32':
152     if bitness == 64:
153         platform = 'win64-vc'
154     else:
155         platform = 'win32-vc'
156 elif env['CC'] in ['gcc'] and sys.platform=='win32':
157     platform = 'win32-mingw'
158
159 env.SConscriptChdir(0)
160
161 crossbuild = B.arguments.get('BF_CROSS', None)
162 if crossbuild and platform not in ('win32-vc', 'win64-vc'):
163     platform = 'linuxcross'
164
165 env['OURPLATFORM'] = platform
166
167 configfile = os.path.join("build_files", "scons", "config", platform + "-config.py")
168
169 if os.path.exists(configfile):
170     print B.bc.OKGREEN + "Using config file: " + B.bc.ENDC + configfile
171 else:
172     print B.bc.FAIL + configfile + " doesn't exist" + B.bc.ENDC
173
174 if crossbuild and env['PLATFORM'] != 'win32':
175     print B.bc.HEADER+"Preparing for crossbuild"+B.bc.ENDC
176     env.Tool('crossmingw', [toolpath])
177     # todo: determine proper libs/includes etc.
178     # Needed for gui programs, console programs should do without it
179
180     # Now we don't need this option to have console window
181     # env.Append(LINKFLAGS=['-mwindows'])
182
183 userconfig = B.arguments.get('BF_CONFIG', 'user-config.py')
184 # first read platform config. B.arguments will override
185 optfiles = [configfile]
186 if os.path.exists(userconfig):
187     print B.bc.OKGREEN + "Using user-config file: " + B.bc.ENDC + userconfig
188     optfiles += [userconfig]
189 else:
190     print B.bc.WARNING + userconfig + " not found, no user overrides" + B.bc.ENDC
191
192 opts = btools.read_opts(env, optfiles, B.arguments)
193 opts.Update(env)
194
195 if not env['BF_FANCY']:
196     B.bc.disable()
197
198
199 # remove install dir so old and new files are not mixed.
200 # NOTE: only do the scripts directory for now, otherwise is too disruptive for developers
201 # TODO: perhaps we need an option (off by default) to not do this altogether...
202 if not env['WITHOUT_BF_INSTALL'] and not env['WITHOUT_BF_OVERWRITE_INSTALL']:
203     scriptsDir = os.path.join(env['BF_INSTALLDIR'], VERSION, 'scripts')
204     if os.path.isdir(scriptsDir):
205         print B.bc.OKGREEN + "Clearing installation directory%s: %s" % (B.bc.ENDC, os.path.abspath(scriptsDir))
206         shutil.rmtree(scriptsDir)
207
208
209 SetOption('num_jobs', int(env['BF_NUMJOBS']))
210 print B.bc.OKGREEN + "Build with parallel jobs%s: %s" % (B.bc.ENDC, GetOption('num_jobs'))
211 print B.bc.OKGREEN + "Build with debug symbols%s: %s" % (B.bc.ENDC, env['BF_DEBUG'])
212
213 if 'blenderlite' in B.targets:
214     target_env_defs = {}
215     target_env_defs['WITH_BF_GAMEENGINE'] = False
216     target_env_defs['WITH_BF_OPENAL'] = False
217     target_env_defs['WITH_BF_OPENEXR'] = False
218     target_env_defs['WITH_BF_OPENMP'] = False
219     target_env_defs['WITH_BF_ICONV'] = False
220     target_env_defs['WITH_BF_INTERNATIONAL'] = False
221     target_env_defs['WITH_BF_OPENJPEG'] = False
222     target_env_defs['WITH_BF_FFMPEG'] = False
223     target_env_defs['WITH_BF_QUICKTIME'] = False
224     target_env_defs['WITH_BF_REDCODE'] = False
225     target_env_defs['WITH_BF_DDS'] = False
226     target_env_defs['WITH_BF_CINEON'] = False
227     target_env_defs['WITH_BF_HDR'] = False
228     target_env_defs['WITH_BF_ZLIB'] = False
229     target_env_defs['WITH_BF_SDL'] = False
230     target_env_defs['WITH_BF_JPEG'] = False
231     target_env_defs['WITH_BF_PNG'] = False
232     target_env_defs['WITH_BF_BULLET'] = False
233     target_env_defs['WITH_BF_BINRELOC'] = False
234     target_env_defs['BF_BUILDINFO'] = False
235     target_env_defs['BF_NO_ELBEEM'] = True
236     target_env_defs['WITH_BF_PYTHON'] = False
237     
238     # Merge blenderlite, let command line to override
239     for k,v in target_env_defs.iteritems():
240         if k not in B.arguments:
241             env[k] = v
242
243
244 if env['WITH_BF_OPENMP'] == 1:
245         if env['OURPLATFORM'] in ('win32-vc', 'win64-vc'):
246                 env['CCFLAGS'].append('/openmp')
247                 env['CPPFLAGS'].append('/openmp')
248                 env['CXXFLAGS'].append('/openmp')
249         else:
250             if env['CC'].endswith('icc'): # to be able to handle CC=/opt/bla/icc case
251                 env.Append(LINKFLAGS=['-openmp', '-static-intel'])
252                 env['CCFLAGS'].append('-openmp')
253                 env['CPPFLAGS'].append('-openmp')
254                 env['CXXFLAGS'].append('-openmp')
255             else:
256                 env.Append(CCFLAGS=['-fopenmp']) 
257                 env.Append(CPPFLAGS=['-fopenmp'])
258                 env.Append(CXXFLAGS=['-fopenmp'])
259
260 if env['WITH_GHOST_COCOA'] == True:
261     env.Append(CFLAGS=['-DGHOST_COCOA']) 
262     env.Append(CXXFLAGS=['-DGHOST_COCOA'])
263     env.Append(CPPFLAGS=['-DGHOST_COCOA'])
264     
265 if env['USE_QTKIT'] == True:
266     env.Append(CFLAGS=['-DUSE_QTKIT']) 
267     env.Append(CXXFLAGS=['-DUSE_QTKIT'])
268     env.Append(CPPFLAGS=['-DUSE_QTKIT'])
269
270 #check for additional debug libnames
271
272 if env.has_key('BF_DEBUG_LIBS'):
273     B.quickdebug += env['BF_DEBUG_LIBS']
274
275 printdebug = B.arguments.get('BF_LISTDEBUG', 0)
276
277 if len(B.quickdebug) > 0 and printdebug != 0:
278     print B.bc.OKGREEN + "Buildings these libs with debug symbols:" + B.bc.ENDC
279     for l in B.quickdebug:
280         print "\t" + l
281
282 # remove stdc++ from LLIBS if we are building a statc linked CXXFLAGS
283 if env['WITH_BF_STATICCXX']:
284     if 'stdc++' in env['LLIBS']:
285         env['LLIBS'].remove('stdc++')
286     else:
287         print '\tcould not remove stdc++ library from LLIBS, WITH_BF_STATICCXX may not work for your platform'
288
289 # check target for blenderplayer. Set WITH_BF_PLAYER if found on cmdline
290 if 'blenderplayer' in B.targets:
291     env['WITH_BF_PLAYER'] = True
292
293 if 'blendernogame' in B.targets:
294     env['WITH_BF_GAMEENGINE'] = False
295
296 # disable elbeem (fluidsim) compilation?
297 if env['BF_NO_ELBEEM'] == 1:
298     env['CPPFLAGS'].append('-DDISABLE_ELBEEM')
299     env['CXXFLAGS'].append('-DDISABLE_ELBEEM')
300     env['CCFLAGS'].append('-DDISABLE_ELBEEM')
301
302 if env['WITH_BF_SDL'] == False and env['OURPLATFORM'] in ('win32-vc', 'win32-ming', 'win64-vc'):
303     env['PLATFORM_LINKFLAGS'].remove('/ENTRY:mainCRTStartup')
304     env['PLATFORM_LINKFLAGS'].append('/ENTRY:main')
305
306 # lastly we check for root_build_dir ( we should not do before, otherwise we might do wrong builddir
307 B.root_build_dir = env['BF_BUILDDIR']
308 B.doc_build_dir = os.path.join(env['BF_INSTALLDIR'], 'doc')
309 if not B.root_build_dir[-1]==os.sep:
310     B.root_build_dir += os.sep
311 if not B.doc_build_dir[-1]==os.sep:
312     B.doc_build_dir += os.sep
313     
314 # We do a shortcut for clean when no quicklist is given: just delete
315 # builddir without reading in SConscripts
316 do_clean = None
317 if 'clean' in B.targets:
318     do_clean = True
319
320 if not quickie and do_clean:
321     if os.path.exists(B.doc_build_dir):
322         print B.bc.HEADER+'Cleaning doc dir...'+B.bc.ENDC
323         dirs = os.listdir(B.doc_build_dir)
324         for entry in dirs:
325             if os.path.isdir(B.doc_build_dir + entry) == 1:
326                 print "clean dir %s"%(B.doc_build_dir+entry)
327                 shutil.rmtree(B.doc_build_dir+entry)
328             else: # remove file
329                 print "remove file %s"%(B.doc_build_dir+entry)
330                 os.remove(B.root_build_dir+entry)
331     if os.path.exists(B.root_build_dir):
332         print B.bc.HEADER+'Cleaning build dir...'+B.bc.ENDC
333         dirs = os.listdir(B.root_build_dir)
334         for entry in dirs:
335             if os.path.isdir(B.root_build_dir + entry) == 1:
336                 print "clean dir %s"%(B.root_build_dir+entry)
337                 shutil.rmtree(B.root_build_dir+entry)
338             else: # remove file
339                 print "remove file %s"%(B.root_build_dir+entry)
340                 os.remove(B.root_build_dir+entry)
341         for confile in ['extern/ffmpeg/config.mak', 'extern/x264/config.mak',
342                 'extern/xvidcore/build/generic/platform.inc', 'extern/ffmpeg/include']:
343             if os.path.exists(confile):
344                 print "clean file %s"%confile
345                 if os.path.isdir(confile):
346                     for root, dirs, files in os.walk(confile):
347                         for name in files:
348                             os.remove(os.path.join(root, name))
349                 else:
350                     os.remove(confile)
351         print B.bc.OKGREEN+'...done'+B.bc.ENDC
352     else:
353         print B.bc.HEADER+'Already Clean, nothing to do.'+B.bc.ENDC
354     Exit()
355
356 if not os.path.isdir ( B.root_build_dir):
357     os.makedirs ( B.root_build_dir )
358     os.makedirs ( B.root_build_dir + 'source' )
359     os.makedirs ( B.root_build_dir + 'intern' )
360     os.makedirs ( B.root_build_dir + 'extern' )
361     os.makedirs ( B.root_build_dir + 'lib' )
362     os.makedirs ( B.root_build_dir + 'bin' )
363 # # Docs not working with epy anymore
364 # if not os.path.isdir(B.doc_build_dir) and env['WITH_BF_DOCS']:
365 #     os.makedirs ( B.doc_build_dir )
366
367 Help(opts.GenerateHelpText(env))
368
369 # default is new quieter output, but if you need to see the 
370 # commands, do 'scons BF_QUIET=0'
371 bf_quietoutput = B.arguments.get('BF_QUIET', '1')
372 if env['BF_QUIET']:
373     B.set_quiet_output(env)
374 else:
375     if toolset=='msvc':
376         B.msvc_hack(env)
377
378 print B.bc.HEADER+'Building in: ' + B.bc.ENDC + os.path.abspath(B.root_build_dir)
379 env.SConsignFile(B.root_build_dir+'scons-signatures')
380 B.init_lib_dict()
381
382 ##### END SETUP ##########
383
384 Export('env')
385
386 BuildDir(B.root_build_dir+'/intern', 'intern', duplicate=0)
387 SConscript(B.root_build_dir+'/intern/SConscript')
388 BuildDir(B.root_build_dir+'/extern', 'extern', duplicate=0)
389 SConscript(B.root_build_dir+'/extern/SConscript')
390 BuildDir(B.root_build_dir+'/source', 'source', duplicate=0)
391 SConscript(B.root_build_dir+'/source/SConscript')
392
393 # now that we have read all SConscripts, we know what
394 # libraries will be built. Create list of
395 # libraries to give as objects to linking phase
396 mainlist = []
397 for tp in B.possible_types:
398     if (not tp == 'player') and (not tp == 'player2'):
399         mainlist += B.create_blender_liblist(env, tp)
400
401 if B.arguments.get('BF_PRIORITYLIST', '0')=='1':
402     B.propose_priorities()
403
404 dobj = B.buildinfo(env, "dynamic") + B.resources
405 thestatlibs, thelibincs = B.setup_staticlibs(env)
406 thesyslibs = B.setup_syslibs(env)
407
408 if 'blender' in B.targets or not env['WITH_BF_NOBLENDER']:
409     env.BlenderProg(B.root_build_dir, "blender", mainlist + thestatlibs + dobj, thesyslibs, [B.root_build_dir+'/lib'] + thelibincs, 'blender')
410 if env['WITH_BF_PLAYER']:
411     playerlist = B.create_blender_liblist(env, 'player')
412     playerlist += B.create_blender_liblist(env, 'player2')
413     playerlist += B.create_blender_liblist(env, 'intern')
414     playerlist += B.create_blender_liblist(env, 'extern')
415     env.BlenderProg(B.root_build_dir, "blenderplayer",  playerlist + thestatlibs + dobj, thesyslibs, [B.root_build_dir+'/lib'] + thelibincs, 'blenderplayer')
416
417 ##### Now define some targets
418
419
420 #------------ INSTALL
421
422 #-- binaries
423 blenderinstall = []
424 if  env['OURPLATFORM']=='darwin':
425     for prg in B.program_list:
426         bundle = '%s.app' % prg[0]
427         bundledir = os.path.dirname(bundle)
428         for dp, dn, df in os.walk(bundle):
429             if '.svn' in dn:
430                 dn.remove('.svn')
431             if '_svn' in dn:
432                 dn.remove('_svn')
433             dir=env['BF_INSTALLDIR']+dp[len(bundledir):]
434             source=[dp+os.sep+f for f in df]
435             blenderinstall.append(env.Install(dir=dir,source=source))
436 else:
437     blenderinstall = env.Install(dir=env['BF_INSTALLDIR'], source=B.program_list)
438
439 #-- local path = config files in install dir: installdir\VERSION
440 #- dont do config and scripts for darwin, it is already in the bundle
441 dotblendlist = []
442 datafileslist = []
443 datafilestargetlist = []
444 dottargetlist = []
445 scriptinstall = []
446
447 if  env['OURPLATFORM']!='darwin':
448         for dp, dn, df in os.walk('bin/.blender'):
449             if '.svn' in dn:
450                 dn.remove('.svn')
451             if '_svn' in dn:
452                 dn.remove('_svn')
453             
454             for f in df:
455                 if not env['WITH_BF_INTERNATIONAL']:
456                     if 'locale' in dp:
457                         continue
458                     if f == '.Blanguages':
459                         continue
460                 if not env['WITH_BF_FREETYPE']:
461                     if f.endswith('.ttf'):
462                         continue
463                 
464                 if 'locale' in dp:
465                     datafileslist.append(os.path.join(dp,f))
466                     dir= os.path.join(*([env['BF_INSTALLDIR']] + [VERSION] + ['datafiles'] + dp.split(os.sep)[1:]))    # skip bin
467                     datafilestargetlist.append(dir + os.sep + f)
468
469                 else:
470                     dotblendlist.append(os.path.join(dp, f))
471                     dir= os.path.join(*([env['BF_INSTALLDIR']] + [VERSION] + ['config'] + dp.split(os.sep)[1:]))    # skip bin
472                     dottargetlist.append(dir + os.sep + f)
473                     
474         dotblenderinstall = []
475         for targetdir,srcfile in zip(dottargetlist, dotblendlist):
476             td, tf = os.path.split(targetdir)
477             dotblenderinstall.append(env.Install(dir=td, source=srcfile))
478         for targetdir,srcfile in zip(datafilestargetlist, datafileslist):
479             td, tf = os.path.split(targetdir)
480             dotblenderinstall.append(env.Install(dir=td, source=srcfile))
481         
482         if env['WITH_BF_PYTHON']:
483             #-- local/VERSION/scripts
484             scriptpaths=['release/scripts']
485             for scriptpath in scriptpaths:
486                 for dp, dn, df in os.walk(scriptpath):
487                     if '.svn' in dn:
488                         dn.remove('.svn')
489                     if '_svn' in dn:
490                         dn.remove('_svn')
491                     
492                     dir = os.path.join(env['BF_INSTALLDIR'], VERSION)
493                     dir += os.sep + os.path.basename(scriptpath) + dp[len(scriptpath):]
494                     
495                     source=[os.path.join(dp, f) for f in df if f[-3:]!='pyc']
496                     # To ensure empty dirs are created too
497                     if len(source)==0:
498                         env.Execute(Mkdir(dir))
499                     scriptinstall.append(env.Install(dir=dir,source=source))
500
501 #-- icons
502 if env['OURPLATFORM']=='linux2':
503     iconlist = []
504     icontargetlist = []
505
506     for tp, tn, tf in os.walk('release/freedesktop/icons'):
507         if '.svn' in tn:
508             tn.remove('.svn')
509         if '_svn' in tn:
510             tn.remove('_svn')
511         for f in tf:
512             iconlist.append(os.path.join(tp, f))
513             icontargetlist.append( os.path.join(*([env['BF_INSTALLDIR']] + tp.split(os.sep)[2:] + [f])) )
514
515     iconinstall = []
516     for targetdir,srcfile in zip(icontargetlist, iconlist):
517         td, tf = os.path.split(targetdir)
518         iconinstall.append(env.Install(dir=td, source=srcfile))
519
520 # dlls for linuxcross
521 # TODO - add more libs, for now this lets blenderlite run
522 if env['OURPLATFORM']=='linuxcross':
523     dir=env['BF_INSTALLDIR']
524     source = []
525
526     if env['WITH_BF_OPENMP']:
527         source += ['../lib/windows/pthreads/lib/pthreadGC2.dll']
528
529     scriptinstall.append(env.Install(dir=dir, source=source))
530
531 #-- plugins
532 pluglist = []
533 plugtargetlist = []
534 for tp, tn, tf in os.walk('release/plugins'):
535     if '.svn' in tn:
536         tn.remove('.svn')
537     if '_svn' in tn:
538         tn.remove('_svn')
539     df = tp[8:] # remove 'release/'
540     for f in tf:
541         pluglist.append(os.path.join(tp, f))
542         plugtargetlist.append( os.path.join(env['BF_INSTALLDIR'], VERSION, df, f) )
543
544
545 # header files for plugins
546 pluglist.append('source/blender/blenpluginapi/documentation.h')
547 plugtargetlist.append(os.path.join(env['BF_INSTALLDIR'], VERSION, 'plugins', 'include', 'documentation.h'))
548 pluglist.append('source/blender/blenpluginapi/externdef.h')
549 plugtargetlist.append(os.path.join(env['BF_INSTALLDIR'], VERSION, 'plugins', 'include', 'externdef.h'))
550 pluglist.append('source/blender/blenpluginapi/floatpatch.h')
551 plugtargetlist.append(os.path.join(env['BF_INSTALLDIR'], VERSION, 'plugins', 'include', 'floatpatch.h'))
552 pluglist.append('source/blender/blenpluginapi/iff.h')
553 plugtargetlist.append(os.path.join(env['BF_INSTALLDIR'], VERSION, 'plugins', 'include', 'iff.h'))
554 pluglist.append('source/blender/blenpluginapi/plugin.h')
555 plugtargetlist.append(os.path.join(env['BF_INSTALLDIR'], VERSION, 'plugins', 'include', 'plugin.h'))
556 pluglist.append('source/blender/blenpluginapi/util.h')
557 plugtargetlist.append(os.path.join(env['BF_INSTALLDIR'], VERSION, 'plugins', 'include', 'util.h'))
558 pluglist.append('source/blender/blenpluginapi/plugin.DEF')
559 plugtargetlist.append(os.path.join(env['BF_INSTALLDIR'], VERSION, 'plugins', 'include', 'plugin.def'))
560
561 plugininstall = []
562 for targetdir,srcfile in zip(plugtargetlist, pluglist):
563     td, tf = os.path.split(targetdir)
564     plugininstall.append(env.Install(dir=td, source=srcfile))
565
566 textlist = []
567 texttargetlist = []
568 for tp, tn, tf in os.walk('release/text'):
569     if '.svn' in tn:
570         tn.remove('.svn')
571     if '_svn' in tn:
572         tn.remove('_svn')
573     for f in tf:
574         textlist.append(tp+os.sep+f)
575
576 textinstall = env.Install(dir=env['BF_INSTALLDIR'], source=textlist)
577
578 if  env['OURPLATFORM']=='darwin':
579         allinstall = [blenderinstall, plugininstall, textinstall]
580 elif env['OURPLATFORM']=='linux2':
581         allinstall = [blenderinstall, dotblenderinstall, scriptinstall, plugininstall, textinstall, iconinstall]
582 else:
583         allinstall = [blenderinstall, dotblenderinstall, scriptinstall, plugininstall, textinstall]
584
585 if env['OURPLATFORM'] in ('win32-vc', 'win32-mingw', 'win64-vc', 'linuxcross'):
586     dllsources = []
587
588     if not env['OURPLATFORM'] in ('win32-mingw', 'win64-vc', 'linuxcross'):
589         # For MinGW and linuxcross static linking will be used
590         dllsources += ['${LCGDIR}/gettext/lib/gnu_gettext.dll']
591
592     #currently win64-vc doesn't appear to have libpng.dll
593     if env['OURPLATFORM'] != 'win64-vc':
594         dllsources += ['${BF_PNG_LIBPATH}/libpng.dll']
595
596     dllsources += ['${BF_ZLIB_LIBPATH}/zlib.dll']
597     # Used when linking to libtiff was dynamic
598     # keep it here until compilation on all platform would be ok
599     # dllsources += ['${BF_TIFF_LIBPATH}/${BF_TIFF_LIB}.dll']
600
601     if env['OURPLATFORM'] != 'linuxcross':
602         # pthreads library is already added
603         dllsources += ['${BF_PTHREADS_LIBPATH}/${BF_PTHREADS_LIB}.dll']
604
605     if env['WITH_BF_SDL']:
606         if env['OURPLATFORM'] == 'win64-vc':
607             pass # we link statically already to SDL on win64
608         else:
609             dllsources.append('${BF_SDL_LIBPATH}/SDL.dll')
610
611     if env['WITH_BF_PYTHON']:
612         if env['BF_DEBUG']:
613             dllsources.append('${BF_PYTHON_LIBPATH}/${BF_PYTHON_DLL}_d.dll')
614         else:
615             dllsources.append('${BF_PYTHON_LIBPATH}/${BF_PYTHON_DLL}.dll')
616
617     if env['WITH_BF_ICONV']:
618         if env['OURPLATFORM'] == 'win64-vc':
619             pass # we link statically to iconv on win64
620         elif not env['OURPLATFORM'] in ('win32-mingw', 'linuxcross'):
621             #gettext for MinGW and cross-compilation is compiled staticly
622             dllsources += ['${BF_ICONV_LIBPATH}/iconv.dll']
623
624     if env['WITH_BF_OPENAL']:
625         dllsources.append('${LCGDIR}/openal/lib/OpenAL32.dll')
626         dllsources.append('${LCGDIR}/openal/lib/wrap_oal.dll')
627
628     if env['WITH_BF_SNDFILE']:
629         dllsources.append('${LCGDIR}/sndfile/lib/libsndfile-1.dll')
630
631     if env['WITH_BF_FFMPEG']:
632         dllsources += ['${BF_FFMPEG_LIBPATH}/avcodec-52.dll',
633                     '${BF_FFMPEG_LIBPATH}/avformat-52.dll',
634                     '${BF_FFMPEG_LIBPATH}/avdevice-52.dll',
635                     '${BF_FFMPEG_LIBPATH}/avutil-50.dll',
636                     '${BF_FFMPEG_LIBPATH}/swscale-0.dll']
637     windlls = env.Install(dir=env['BF_INSTALLDIR'], source = dllsources)
638     allinstall += windlls
639
640 installtarget = env.Alias('install', allinstall)
641 bininstalltarget = env.Alias('install-bin', blenderinstall)
642
643 nsisaction = env.Action(btools.NSIS_Installer, btools.NSIS_print)
644 nsiscmd = env.Command('nsisinstaller', None, nsisaction)
645 nsisalias = env.Alias('nsis', nsiscmd)
646
647 if 'blender' in B.targets:
648     blenderexe= env.Alias('blender', B.program_list)
649     Depends(blenderexe,installtarget)
650
651 if env['WITH_BF_PLAYER']:
652     blenderplayer = env.Alias('blenderplayer', B.program_list)
653     Depends(blenderplayer,installtarget)
654
655 if not env['WITH_BF_GAMEENGINE']:
656     blendernogame = env.Alias('blendernogame', B.program_list)
657     Depends(blendernogame,installtarget)
658
659 if 'blenderlite' in B.targets:
660     blenderlite = env.Alias('blenderlite', B.program_list)
661     Depends(blenderlite,installtarget)
662
663 Depends(nsiscmd, allinstall)
664
665 Default(B.program_list)
666
667 if not env['WITHOUT_BF_INSTALL']:
668         Default(installtarget)