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