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