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