fixed ndof library detect for Mac SCons, ndof enabled by default (disabled if lib...
[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 # detect presence of 3D_CONNEXION_CLIENT_LIBRARY for OSX
257 if env['OURPLATFORM']=='darwin':
258     # for now, Mac builders must download and install the driver framework from 3Dconnexion
259     # necessary header file lives here when installed:
260     # /Library/Frameworks/3DconnexionClient.framework/Versions/Current/Headers/ConnexionClientAPI.h
261     if not os.path.exists('/Library/Frameworks/3DconnexionClient.framework'):
262         print "3D_CONNEXION_CLIENT_LIBRARY not found, disabling WITH_BF_3DMOUSE" # avoid build errors !
263         env['WITH_BF_3DMOUSE'] = 0
264
265 if env['WITH_BF_OPENMP'] == 1:
266         if env['OURPLATFORM'] in ('win32-vc', 'win64-vc'):
267                 env['CCFLAGS'].append('/openmp')
268                 env['CPPFLAGS'].append('/openmp')
269                 env['CXXFLAGS'].append('/openmp')
270         else:
271             if env['CC'].endswith('icc'): # to be able to handle CC=/opt/bla/icc case
272                 env.Append(LINKFLAGS=['-openmp', '-static-intel'])
273                 env['CCFLAGS'].append('-openmp')
274                 env['CPPFLAGS'].append('-openmp')
275                 env['CXXFLAGS'].append('-openmp')
276             else:
277                 env.Append(CCFLAGS=['-fopenmp']) 
278                 env.Append(CPPFLAGS=['-fopenmp'])
279                 env.Append(CXXFLAGS=['-fopenmp'])
280
281 if env['WITH_GHOST_COCOA'] == True:
282     env.Append(CFLAGS=['-DGHOST_COCOA']) 
283     env.Append(CXXFLAGS=['-DGHOST_COCOA'])
284     env.Append(CPPFLAGS=['-DGHOST_COCOA'])
285     
286 if env['USE_QTKIT'] == True:
287     env.Append(CFLAGS=['-DUSE_QTKIT']) 
288     env.Append(CXXFLAGS=['-DUSE_QTKIT'])
289     env.Append(CPPFLAGS=['-DUSE_QTKIT'])
290
291 #check for additional debug libnames
292
293 if env.has_key('BF_DEBUG_LIBS'):
294     B.quickdebug += env['BF_DEBUG_LIBS']
295
296 printdebug = B.arguments.get('BF_LISTDEBUG', 0)
297
298 if len(B.quickdebug) > 0 and printdebug != 0:
299     print B.bc.OKGREEN + "Buildings these libs with debug symbols:" + B.bc.ENDC
300     for l in B.quickdebug:
301         print "\t" + l
302
303 # remove stdc++ from LLIBS if we are building a statc linked CXXFLAGS
304 if env['WITH_BF_STATICCXX']:
305     if 'stdc++' in env['LLIBS']:
306         env['LLIBS'].remove('stdc++')
307     else:
308         print '\tcould not remove stdc++ library from LLIBS, WITH_BF_STATICCXX may not work for your platform'
309
310 # check target for blenderplayer. Set WITH_BF_PLAYER if found on cmdline
311 if 'blenderplayer' in B.targets:
312     env['WITH_BF_PLAYER'] = True
313
314 if 'blendernogame' in B.targets:
315     env['WITH_BF_GAMEENGINE'] = False
316
317 # disable elbeem (fluidsim) compilation?
318 if env['BF_NO_ELBEEM'] == 1:
319     env['CPPFLAGS'].append('-DDISABLE_ELBEEM')
320     env['CXXFLAGS'].append('-DDISABLE_ELBEEM')
321     env['CCFLAGS'].append('-DDISABLE_ELBEEM')
322
323 # TODO, make optional
324 env['CPPFLAGS'].append('-DWITH_AUDASPACE')
325 env['CXXFLAGS'].append('-DWITH_AUDASPACE')
326 env['CCFLAGS'].append('-DWITH_AUDASPACE')
327
328 # lastly we check for root_build_dir ( we should not do before, otherwise we might do wrong builddir
329 B.root_build_dir = env['BF_BUILDDIR']
330 B.doc_build_dir = os.path.join(env['BF_INSTALLDIR'], 'doc')
331 if not B.root_build_dir[-1]==os.sep:
332     B.root_build_dir += os.sep
333 if not B.doc_build_dir[-1]==os.sep:
334     B.doc_build_dir += os.sep
335     
336 # We do a shortcut for clean when no quicklist is given: just delete
337 # builddir without reading in SConscripts
338 do_clean = None
339 if 'clean' in B.targets:
340     do_clean = True
341
342 if not quickie and do_clean:
343     if os.path.exists(B.doc_build_dir):
344         print B.bc.HEADER+'Cleaning doc dir...'+B.bc.ENDC
345         dirs = os.listdir(B.doc_build_dir)
346         for entry in dirs:
347             if os.path.isdir(B.doc_build_dir + entry) == 1:
348                 print "clean dir %s"%(B.doc_build_dir+entry)
349                 shutil.rmtree(B.doc_build_dir+entry)
350             else: # remove file
351                 print "remove file %s"%(B.doc_build_dir+entry)
352                 os.remove(B.root_build_dir+entry)
353     if os.path.exists(B.root_build_dir):
354         print B.bc.HEADER+'Cleaning build dir...'+B.bc.ENDC
355         dirs = os.listdir(B.root_build_dir)
356         for entry in dirs:
357             if os.path.isdir(B.root_build_dir + entry) == 1:
358                 print "clean dir %s"%(B.root_build_dir+entry)
359                 shutil.rmtree(B.root_build_dir+entry)
360             else: # remove file
361                 print "remove file %s"%(B.root_build_dir+entry)
362                 os.remove(B.root_build_dir+entry)
363         for confile in ['extern/ffmpeg/config.mak', 'extern/x264/config.mak',
364                 'extern/xvidcore/build/generic/platform.inc', 'extern/ffmpeg/include']:
365             if os.path.exists(confile):
366                 print "clean file %s"%confile
367                 if os.path.isdir(confile):
368                     for root, dirs, files in os.walk(confile):
369                         for name in files:
370                             os.remove(os.path.join(root, name))
371                 else:
372                     os.remove(confile)
373         print B.bc.OKGREEN+'...done'+B.bc.ENDC
374     else:
375         print B.bc.HEADER+'Already Clean, nothing to do.'+B.bc.ENDC
376     Exit()
377
378
379 # ensure python header is found since detection can fail, this could happen
380 # with _any_ library but since we used a fixed python version this tends to
381 # be most problematic.
382 if env['WITH_BF_PYTHON']:
383         py_h = os.path.join(Dir(env.subst('${BF_PYTHON_INC}')).abspath, "Python.h")
384
385         if not os.path.exists(py_h):
386                 print("\nMissing: \"" + env.subst('${BF_PYTHON_INC}') + os.sep + "Python.h\",\n"
387                           "  Set 'BF_PYTHON_INC' to point "
388                           "to a valid python include path.\n  Containing "
389                           "Python.h for python version \"" + env.subst('${BF_PYTHON_VERSION}') + "\"")
390
391                 Exit()
392         del py_h
393
394
395 if not os.path.isdir ( B.root_build_dir):
396     os.makedirs ( B.root_build_dir )
397     os.makedirs ( B.root_build_dir + 'source' )
398     os.makedirs ( B.root_build_dir + 'intern' )
399     os.makedirs ( B.root_build_dir + 'extern' )
400     os.makedirs ( B.root_build_dir + 'lib' )
401     os.makedirs ( B.root_build_dir + 'bin' )
402 # # Docs not working with epy anymore
403 # if not os.path.isdir(B.doc_build_dir) and env['WITH_BF_DOCS']:
404 #     os.makedirs ( B.doc_build_dir )
405
406 Help(opts.GenerateHelpText(env))
407
408 # default is new quieter output, but if you need to see the 
409 # commands, do 'scons BF_QUIET=0'
410 bf_quietoutput = B.arguments.get('BF_QUIET', '1')
411 if env['BF_QUIET']:
412     B.set_quiet_output(env)
413 else:
414     if toolset=='msvc':
415         B.msvc_hack(env)
416
417 print B.bc.HEADER+'Building in: ' + B.bc.ENDC + os.path.abspath(B.root_build_dir)
418 env.SConsignFile(B.root_build_dir+'scons-signatures')
419 B.init_lib_dict()
420
421 ##### END SETUP ##########
422
423 Export('env')
424
425 BuildDir(B.root_build_dir+'/intern', 'intern', duplicate=0)
426 SConscript(B.root_build_dir+'/intern/SConscript')
427 BuildDir(B.root_build_dir+'/extern', 'extern', duplicate=0)
428 SConscript(B.root_build_dir+'/extern/SConscript')
429 BuildDir(B.root_build_dir+'/source', 'source', duplicate=0)
430 SConscript(B.root_build_dir+'/source/SConscript')
431
432 # now that we have read all SConscripts, we know what
433 # libraries will be built. Create list of
434 # libraries to give as objects to linking phase
435 mainlist = []
436 for tp in B.possible_types:
437     if (not tp == 'player') and (not tp == 'player2'):
438         mainlist += B.create_blender_liblist(env, tp)
439
440 if B.arguments.get('BF_PRIORITYLIST', '0')=='1':
441     B.propose_priorities()
442
443 dobj = B.buildinfo(env, "dynamic") + B.resources
444 creob = B.creator(env)
445 thestatlibs, thelibincs = B.setup_staticlibs(env)
446 thesyslibs = B.setup_syslibs(env)
447
448 if 'blender' in B.targets or not env['WITH_BF_NOBLENDER']:
449     env.BlenderProg(B.root_build_dir, "blender", creob + mainlist + thestatlibs + dobj, thesyslibs, [B.root_build_dir+'/lib'] + thelibincs, 'blender')
450 if env['WITH_BF_PLAYER']:
451     playerlist = B.create_blender_liblist(env, 'player')
452     playerlist += B.create_blender_liblist(env, 'player2')
453     playerlist += B.create_blender_liblist(env, 'intern')
454     playerlist += B.create_blender_liblist(env, 'extern')
455     env.BlenderProg(B.root_build_dir, "blenderplayer", dobj + playerlist + thestatlibs, thesyslibs, [B.root_build_dir+'/lib'] + thelibincs, 'blenderplayer')
456
457 ##### Now define some targets
458
459
460 #------------ INSTALL
461
462 #-- binaries
463 blenderinstall = []
464 if  env['OURPLATFORM']=='darwin':
465     for prg in B.program_list:
466         bundle = '%s.app' % prg[0]
467         bundledir = os.path.dirname(bundle)
468         for dp, dn, df in os.walk(bundle):
469             if '.svn' in dn:
470                 dn.remove('.svn')
471             if '_svn' in dn:
472                 dn.remove('_svn')
473             dir=env['BF_INSTALLDIR']+dp[len(bundledir):]
474             source=[dp+os.sep+f for f in df]
475             blenderinstall.append(env.Install(dir=dir,source=source))
476 else:
477     blenderinstall = env.Install(dir=env['BF_INSTALLDIR'], source=B.program_list)
478
479 #-- local path = config files in install dir: installdir\VERSION
480 #- dont do config and scripts for darwin, it is already in the bundle
481 dotblendlist = []
482 datafileslist = []
483 datafilestargetlist = []
484 dottargetlist = []
485 scriptinstall = []
486
487 if  env['OURPLATFORM']!='darwin':
488         for dp, dn, df in os.walk('bin/.blender'):
489             if '.svn' in dn:
490                 dn.remove('.svn')
491             if '_svn' in dn:
492                 dn.remove('_svn')
493             
494             for f in df:
495                 if not env['WITH_BF_INTERNATIONAL']:
496                     if 'locale' in dp:
497                         continue
498                     if f == '.Blanguages':
499                         continue
500                 if not env['WITH_BF_FREETYPE']:
501                     if f.endswith('.ttf'):
502                         continue
503                 
504                 if 'locale' in dp:
505                     datafileslist.append(os.path.join(dp,f))
506                     dir= os.path.join(*([env['BF_INSTALLDIR']] + [VERSION] + ['datafiles'] + dp.split(os.sep)[1:]))    # skip bin
507                     datafilestargetlist.append(dir + os.sep + f)
508
509                 else:
510                     dotblendlist.append(os.path.join(dp, f))
511                     dir= os.path.join(*([env['BF_INSTALLDIR']] + [VERSION] + ['config'] + dp.split(os.sep)[1:]))    # skip bin
512                     dottargetlist.append(dir + os.sep + f)
513                     
514         dotblenderinstall = []
515         for targetdir,srcfile in zip(dottargetlist, dotblendlist):
516             td, tf = os.path.split(targetdir)
517             dotblenderinstall.append(env.Install(dir=td, source=srcfile))
518         for targetdir,srcfile in zip(datafilestargetlist, datafileslist):
519             td, tf = os.path.split(targetdir)
520             dotblenderinstall.append(env.Install(dir=td, source=srcfile))
521         
522         if env['WITH_BF_PYTHON']:
523             #-- local/VERSION/scripts
524             scriptpaths=['release/scripts']
525             for scriptpath in scriptpaths:
526                 for dp, dn, df in os.walk(scriptpath):
527                     if '.svn' in dn:
528                         dn.remove('.svn')
529                     if '_svn' in dn:
530                         dn.remove('_svn')
531                     if '__pycache__' in dn:  # py3.2 cache dir
532                         dn.remove('__pycache__')
533
534                     dir = os.path.join(env['BF_INSTALLDIR'], VERSION)
535                     dir += os.sep + os.path.basename(scriptpath) + dp[len(scriptpath):]
536
537                     source=[os.path.join(dp, f) for f in df if not f.endswith(".pyc")]
538                     # To ensure empty dirs are created too
539                     if len(source)==0:
540                         env.Execute(Mkdir(dir))
541                     scriptinstall.append(env.Install(dir=dir,source=source))
542
543 #-- icons
544 if env['OURPLATFORM']=='linux2':
545     iconlist = []
546     icontargetlist = []
547
548     for tp, tn, tf in os.walk('release/freedesktop/icons'):
549         if '.svn' in tn:
550             tn.remove('.svn')
551         if '_svn' in tn:
552             tn.remove('_svn')
553         for f in tf:
554             iconlist.append(os.path.join(tp, f))
555             icontargetlist.append( os.path.join(*([env['BF_INSTALLDIR']] + tp.split(os.sep)[2:] + [f])) )
556
557     iconinstall = []
558     for targetdir,srcfile in zip(icontargetlist, iconlist):
559         td, tf = os.path.split(targetdir)
560         iconinstall.append(env.Install(dir=td, source=srcfile))
561
562 # dlls for linuxcross
563 # TODO - add more libs, for now this lets blenderlite run
564 if env['OURPLATFORM']=='linuxcross':
565     dir=env['BF_INSTALLDIR']
566     source = []
567
568     if env['WITH_BF_OPENMP']:
569         source += ['../lib/windows/pthreads/lib/pthreadGC2.dll']
570
571     scriptinstall.append(env.Install(dir=dir, source=source))
572
573 #-- plugins
574 pluglist = []
575 plugtargetlist = []
576 for tp, tn, tf in os.walk('release/plugins'):
577     if '.svn' in tn:
578         tn.remove('.svn')
579     if '_svn' in tn:
580         tn.remove('_svn')
581     df = tp[8:] # remove 'release/'
582     for f in tf:
583         pluglist.append(os.path.join(tp, f))
584         plugtargetlist.append( os.path.join(env['BF_INSTALLDIR'], VERSION, df, f) )
585
586
587 # header files for plugins
588 pluglist.append('source/blender/blenpluginapi/documentation.h')
589 plugtargetlist.append(os.path.join(env['BF_INSTALLDIR'], VERSION, 'plugins', 'include', 'documentation.h'))
590 pluglist.append('source/blender/blenpluginapi/externdef.h')
591 plugtargetlist.append(os.path.join(env['BF_INSTALLDIR'], VERSION, 'plugins', 'include', 'externdef.h'))
592 pluglist.append('source/blender/blenpluginapi/floatpatch.h')
593 plugtargetlist.append(os.path.join(env['BF_INSTALLDIR'], VERSION, 'plugins', 'include', 'floatpatch.h'))
594 pluglist.append('source/blender/blenpluginapi/iff.h')
595 plugtargetlist.append(os.path.join(env['BF_INSTALLDIR'], VERSION, 'plugins', 'include', 'iff.h'))
596 pluglist.append('source/blender/blenpluginapi/plugin.h')
597 plugtargetlist.append(os.path.join(env['BF_INSTALLDIR'], VERSION, 'plugins', 'include', 'plugin.h'))
598 pluglist.append('source/blender/blenpluginapi/util.h')
599 plugtargetlist.append(os.path.join(env['BF_INSTALLDIR'], VERSION, 'plugins', 'include', 'util.h'))
600 pluglist.append('source/blender/blenpluginapi/plugin.DEF')
601 plugtargetlist.append(os.path.join(env['BF_INSTALLDIR'], VERSION, 'plugins', 'include', 'plugin.def'))
602
603 plugininstall = []
604 # plugins in blender 2.5 don't work at the moment.
605 #for targetdir,srcfile in zip(plugtargetlist, pluglist):
606 #    td, tf = os.path.split(targetdir)
607 #    plugininstall.append(env.Install(dir=td, source=srcfile))
608
609 textlist = []
610 texttargetlist = []
611 for tp, tn, tf in os.walk('release/text'):
612     if '.svn' in tn:
613         tn.remove('.svn')
614     if '_svn' in tn:
615         tn.remove('_svn')
616     for f in tf:
617         textlist.append(tp+os.sep+f)
618
619 textinstall = env.Install(dir=env['BF_INSTALLDIR'], source=textlist)
620
621 if  env['OURPLATFORM']=='darwin':
622         allinstall = [blenderinstall, plugininstall, textinstall]
623 elif env['OURPLATFORM']=='linux2':
624         allinstall = [blenderinstall, dotblenderinstall, scriptinstall, plugininstall, textinstall, iconinstall]
625 else:
626         allinstall = [blenderinstall, dotblenderinstall, scriptinstall, plugininstall, textinstall]
627
628 if env['OURPLATFORM'] in ('win32-vc', 'win32-mingw', 'win64-vc', 'linuxcross'):
629     dllsources = []
630
631     if not env['OURPLATFORM'] in ('win32-mingw', 'win64-vc', 'linuxcross'):
632         # For MinGW and linuxcross static linking will be used
633         dllsources += ['${LCGDIR}/gettext/lib/gnu_gettext.dll']
634
635     #currently win64-vc doesn't appear to have libpng.dll
636     if env['OURPLATFORM'] != 'win64-vc':
637         dllsources += ['${BF_PNG_LIBPATH}/libpng.dll']
638
639     dllsources += ['${BF_ZLIB_LIBPATH}/zlib.dll']
640     # Used when linking to libtiff was dynamic
641     # keep it here until compilation on all platform would be ok
642     # dllsources += ['${BF_TIFF_LIBPATH}/${BF_TIFF_LIB}.dll']
643
644     if env['OURPLATFORM'] != 'linuxcross':
645         # pthreads library is already added
646         dllsources += ['${BF_PTHREADS_LIBPATH}/${BF_PTHREADS_LIB}.dll']
647
648     if env['WITH_BF_SDL']:
649         if env['OURPLATFORM'] == 'win64-vc':
650             pass # we link statically already to SDL on win64
651         else:
652             dllsources.append('${BF_SDL_LIBPATH}/SDL.dll')
653
654     if env['WITH_BF_PYTHON']:
655         if env['BF_DEBUG']:
656             dllsources.append('${BF_PYTHON_LIBPATH}/${BF_PYTHON_DLL}_d.dll')
657         else:
658             dllsources.append('${BF_PYTHON_LIBPATH}/${BF_PYTHON_DLL}.dll')
659
660     if env['WITH_BF_ICONV']:
661         if env['OURPLATFORM'] == 'win64-vc':
662             pass # we link statically to iconv on win64
663         elif not env['OURPLATFORM'] in ('win32-mingw', 'linuxcross'):
664             #gettext for MinGW and cross-compilation is compiled staticly
665             dllsources += ['${BF_ICONV_LIBPATH}/iconv.dll']
666
667     if env['WITH_BF_OPENAL']:
668         dllsources.append('${LCGDIR}/openal/lib/OpenAL32.dll')
669         dllsources.append('${LCGDIR}/openal/lib/wrap_oal.dll')
670
671     if env['WITH_BF_SNDFILE']:
672         dllsources.append('${LCGDIR}/sndfile/lib/libsndfile-1.dll')
673
674     if env['WITH_BF_FFMPEG']:
675         dllsources += env['BF_FFMPEG_DLL'].split()
676
677     # Since the thumb handler is loaded by Explorer, architecture is
678     # strict: the x86 build fails on x64 Windows. We need to ship
679     # both builds in x86 packages.
680     if bitness == 32:
681         dllsources.append('${LCGDIR}/thumbhandler/lib/BlendThumb.dll')  
682     dllsources.append('${LCGDIR}/thumbhandler/lib/BlendThumb64.dll')
683
684     dllsources.append('#source/icons/blender.exe.manifest')
685
686     windlls = env.Install(dir=env['BF_INSTALLDIR'], source = dllsources)
687     allinstall += windlls
688
689 installtarget = env.Alias('install', allinstall)
690 bininstalltarget = env.Alias('install-bin', blenderinstall)
691
692 nsisaction = env.Action(btools.NSIS_Installer, btools.NSIS_print)
693 nsiscmd = env.Command('nsisinstaller', None, nsisaction)
694 nsisalias = env.Alias('nsis', nsiscmd)
695
696 if 'blender' in B.targets:
697     blenderexe= env.Alias('blender', B.program_list)
698     Depends(blenderexe,installtarget)
699
700 if env['WITH_BF_PLAYER']:
701     blenderplayer = env.Alias('blenderplayer', B.program_list)
702     Depends(blenderplayer,installtarget)
703
704 if not env['WITH_BF_GAMEENGINE']:
705     blendernogame = env.Alias('blendernogame', B.program_list)
706     Depends(blendernogame,installtarget)
707
708 if 'blenderlite' in B.targets:
709     blenderlite = env.Alias('blenderlite', B.program_list)
710     Depends(blenderlite,installtarget)
711
712 Depends(nsiscmd, allinstall)
713
714 buildslave_action = env.Action(btools.buildslave, btools.buildslave_print)
715 buildslave_cmd = env.Command('buildslave_exec', None, buildslave_action)
716 buildslave_alias = env.Alias('buildslave', buildslave_cmd)
717
718 Depends(buildslave_cmd, allinstall)
719
720 Default(B.program_list)
721
722 if not env['WITHOUT_BF_INSTALL']:
723         Default(installtarget)
724