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