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