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