scons option - WITHOUT_BF_OVERWRITE_INSTALL
[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 import platform as pltfrm
33
34 # Need a better way to do this. Automagical maybe is not the best thing, maybe it is.
35 if pltfrm.architecture()[0] == '64bit':
36         bitness = 64
37 else:
38         bitness = 32
39
40 import sys
41 import os
42 import os.path
43 import string
44 import shutil
45 import glob
46 import re
47 from tempfile import mkdtemp
48
49 import tools.Blender
50 import tools.btools
51 import tools.bcolors
52
53 EnsureSConsVersion(1,0,0)
54
55 BlenderEnvironment = tools.Blender.BlenderEnvironment
56 btools = tools.btools
57 B = tools.Blender
58
59 ### globals ###
60 platform = sys.platform
61 quickie = None
62 quickdebug = None
63
64 ##### BEGIN SETUP #####
65
66 B.possible_types = ['core', 'player', 'intern', 'extern']
67
68 B.binarykind = ['blender' , 'blenderplayer']
69 ##################################
70 # target and argument validation #
71 ##################################
72 # XX cheating for BF_FANCY, we check for BF_FANCY before args are validated
73 use_color = ARGUMENTS.get('BF_FANCY', '1')
74 if platform=='win32':
75         use_color = None
76
77 if not use_color=='1':
78         B.bc.disable()
79         
80  #on defaut white Os X terminal, some colors are totally unlegible
81 if platform=='darwin':
82         B.bc.OKGREEN = '\033[34m'
83         B.bc.WARNING = '\033[36m'
84
85 # arguments
86 print B.bc.HEADER+'Command-line arguments'+B.bc.ENDC
87 B.arguments = btools.validate_arguments(ARGUMENTS, B.bc)
88 btools.print_arguments(B.arguments, B.bc)
89
90 # targets
91 print B.bc.HEADER+'Command-line targets'+B.bc.ENDC
92 B.targets = btools.validate_targets(COMMAND_LINE_TARGETS, B.bc)
93 btools.print_targets(B.targets, B.bc)
94
95 ##########################
96 # setting up environment #
97 ##########################
98
99 # handling cmd line arguments & config file
100
101 # first check cmdline for toolset and we create env to work on
102 quickie = B.arguments.get('BF_QUICK', None)
103 quickdebug = B.arguments.get('BF_QUICKDEBUG', None)
104
105 if quickdebug:
106         B.quickdebug=string.split(quickdebug, ',')
107 else:
108         B.quickdebug=[]
109
110 if quickie:
111         B.quickie=string.split(quickie,',')
112 else:
113         B.quickie=[]
114         
115 toolset = B.arguments.get('BF_TOOLSET', None)
116 if toolset:
117         print "Using " + toolset
118         if toolset=='mstoolkit':
119                 env = BlenderEnvironment(ENV = os.environ)
120                 env.Tool('mstoolkit', ['tools'])
121         else:
122                 env = BlenderEnvironment(tools=[toolset], ENV = os.environ)
123                 # xxx commented out, as was supressing warnings under mingw..
124                 #if env:
125                 #       btools.SetupSpawn(env)
126 else:
127         if bitness==64 and platform=='win32':
128                 env = BlenderEnvironment(ENV = os.environ, MSVS_ARCH='amd64')
129         else:
130                 env = BlenderEnvironment(ENV = os.environ)
131
132 if not env:
133         print "Could not create a build environment"
134         Exit()
135
136
137 cc = B.arguments.get('CC', None)
138 cxx = B.arguments.get('CXX', None)
139 if cc:
140         env['CC'] = cc
141 if cxx:
142         env['CXX'] = cxx
143
144 if env['CC'] in ['cl', 'cl.exe'] and sys.platform=='win32':
145         if bitness == 64:
146                 platform = 'win64-vc'
147         else:
148                 platform = 'win32-vc'
149 elif env['CC'] in ['gcc'] and sys.platform=='win32':
150         platform = 'win32-mingw'
151
152 env.SConscriptChdir(0)
153
154 crossbuild = B.arguments.get('BF_CROSS', None)
155 if crossbuild and platform not in ('win32-vc', 'win64-vc'):
156         platform = 'linuxcross'
157
158 env['OURPLATFORM'] = platform
159
160 configfile = 'config'+os.sep+platform+'-config.py'
161
162 if os.path.exists(configfile):
163         print B.bc.OKGREEN + "Using config file: " + B.bc.ENDC + configfile
164 else:
165         print B.bc.FAIL + configfile + " doesn't exist" + B.bc.ENDC
166
167 if crossbuild and env['PLATFORM'] != 'win32':
168         print B.bc.HEADER+"Preparing for crossbuild"+B.bc.ENDC
169         env.Tool('crossmingw', ['tools'])
170         # todo: determine proper libs/includes etc.
171         # Needed for gui programs, console programs should do without it
172
173         # Now we don't need this option to have console window
174         # env.Append(LINKFLAGS=['-mwindows'])
175
176 userconfig = B.arguments.get('BF_CONFIG', 'user-config.py')
177 # first read platform config. B.arguments will override
178 optfiles = [configfile]
179 if os.path.exists(userconfig):
180         print B.bc.OKGREEN + "Using user-config file: " + B.bc.ENDC + userconfig
181         optfiles += [userconfig]
182 else:
183         print B.bc.WARNING + userconfig + " not found, no user overrides" + B.bc.ENDC
184
185 opts = btools.read_opts(optfiles, B.arguments)
186 opts.Update(env)
187
188 if not env['BF_FANCY']:
189         B.bc.disable()
190
191
192 # remove install dir so old and new files are not mixed.
193 # NOTE: only do the scripts directory for now, otherwise is too disruptive for developers
194 # TODO: perhaps we need an option (off by default) to not do this altogether...
195 if not env['WITHOUT_BF_INSTALL'] and not env['WITHOUT_BF_OVERWRITE_INSTALL']:
196         if os.path.isdir(env['BF_INSTALLDIR']):
197                 print B.bc.OKGREEN + "Clearing installation directory%s: %s" % (B.bc.ENDC, os.path.abspath(env['BF_INSTALLDIR']))
198                 shutil.rmtree(env['BF_INSTALLDIR'])
199
200
201 SetOption('num_jobs', int(env['BF_NUMJOBS']))
202 print B.bc.OKGREEN + "Build with parallel jobs%s: %s" % (B.bc.ENDC, GetOption('num_jobs'))
203
204 # BLENDERPATH is a unix only option to enable typical style paths this is
205 # spesifically a data-dir, which is used a lot but cant replace BF_INSTALLDIR
206 # because the blender binary is installed in $BF_INSTALLDIR/bin/blender
207
208 if env['WITH_BF_FHS']:
209         BLENDERPATH = os.path.join(env['BF_INSTALLDIR'], 'share', 'blender', env['BF_VERSION'])
210 else:
211         BLENDERPATH = env['BF_INSTALLDIR']
212
213 if env['WITH_BF_OPENMP'] == 1:
214                 if env['OURPLATFORM'] in ('win32-vc', 'win64-vc'):
215                                 env['CCFLAGS'].append('/openmp')
216                                 env['CPPFLAGS'].append('/openmp')
217                                 env['CXXFLAGS'].append('/openmp')
218                 else:
219                         if env['CC'].endswith('icc'): # to be able to handle CC=/opt/bla/icc case
220                                 env.Append(LINKFLAGS=['-openmp', '-static-intel'])
221                                 env['CCFLAGS'].append('-openmp')
222                                 env['CPPFLAGS'].append('-openmp')
223                                 env['CXXFLAGS'].append('-openmp')
224                         else:
225                                 env.Append(CCFLAGS=['-fopenmp']) 
226                                 env.Append(CPPFLAGS=['-fopenmp'])
227                                 env.Append(CXXFLAGS=['-fopenmp'])
228
229 if env['WITH_GHOST_COCOA'] == True:
230         env.Append(CFLAGS=['-DGHOST_COCOA']) 
231         env.Append(CXXFLAGS=['-DGHOST_COCOA'])
232         env.Append(CPPFLAGS=['-DGHOST_COCOA'])
233     
234 if env['USE_QTKIT'] == True:
235         env.Append(CFLAGS=['-DUSE_QTKIT']) 
236         env.Append(CXXFLAGS=['-DUSE_QTKIT'])
237         env.Append(CPPFLAGS=['-DUSE_QTKIT'])
238
239 #check for additional debug libnames
240
241 if env.has_key('BF_DEBUG_LIBS'):
242         B.quickdebug += env['BF_DEBUG_LIBS']
243
244 printdebug = B.arguments.get('BF_LISTDEBUG', 0)
245
246 # see if this linux distro has libalut
247
248 if env['OURPLATFORM'] == 'linux2' :
249         if env['WITH_BF_OPENAL']:
250                 mylib_test_source_file = """
251                 #include "AL/alut.h"
252                 int main(int argc, char **argv)
253                 {
254                         alutGetMajorVersion();
255                         return 0;
256                 }
257                 """
258
259                 def CheckFreeAlut(context,env):
260                         context.Message( B.bc.OKGREEN + "Linux platform detected:\n  checking for FreeAlut... " + B.bc.ENDC )
261                         env['LIBS'] = 'alut'
262                         result = context.TryLink(mylib_test_source_file, '.c')
263                         context.Result(result)
264                         return result
265
266                 env2 = env.Clone( LIBPATH = env['BF_OPENAL'] ) 
267                 sconf_temp = mkdtemp()
268                 conf = Configure( env2, {'CheckFreeAlut' : CheckFreeAlut}, sconf_temp, '/dev/null' )
269                 if conf.CheckFreeAlut( env2 ):
270                         env['BF_OPENAL_LIB'] += ' alut'
271                 del env2
272                 root = ''
273                 for root, dirs, files in os.walk(sconf_temp, topdown=False):
274                         for name in files:
275                                 os.remove(os.path.join(root, name))
276                         for name in dirs:
277                                 os.rmdir(os.path.join(root, name))
278                 if root: os.rmdir(root)
279
280 if len(B.quickdebug) > 0 and printdebug != 0:
281         print B.bc.OKGREEN + "Buildings these libs with debug symbols:" + B.bc.ENDC
282         for l in B.quickdebug:
283                 print "\t" + l
284
285 # remove stdc++ from LLIBS if we are building a statc linked CXXFLAGS
286 if env['WITH_BF_STATICCXX']:
287         if 'stdc++' in env['LLIBS']:
288                 env['LLIBS'].remove('stdc++')
289         else:
290                 print '\tcould not remove stdc++ library from LLIBS, WITH_BF_STATICCXX may not work for your platform'
291
292 # check target for blenderplayer. Set WITH_BF_PLAYER if found on cmdline
293 if 'blenderplayer' in B.targets:
294         env['WITH_BF_PLAYER'] = True
295
296 if 'blendernogame' in B.targets:
297         env['WITH_BF_GAMEENGINE'] = False
298
299 if 'blenderlite' in B.targets:
300         target_env_defs = {}
301         target_env_defs['WITH_BF_GAMEENGINE'] = False
302         target_env_defs['WITH_BF_OPENAL'] = False
303         target_env_defs['WITH_BF_OPENEXR'] = False
304         target_env_defs['WITH_BF_ICONV'] = False
305         target_env_defs['WITH_BF_INTERNATIONAL'] = False
306         target_env_defs['WITH_BF_OPENJPEG'] = False
307         target_env_defs['WITH_BF_FFMPEG'] = False
308         target_env_defs['WITH_BF_QUICKTIME'] = False
309         target_env_defs['WITH_BF_REDCODE'] = False
310         target_env_defs['WITH_BF_DDS'] = False
311         target_env_defs['WITH_BF_ZLIB'] = False
312         target_env_defs['WITH_BF_SDL'] = False
313         target_env_defs['WITH_BF_JPEG'] = False
314         target_env_defs['WITH_BF_PNG'] = False
315         target_env_defs['WITH_BF_BULLET'] = False
316         target_env_defs['WITH_BF_BINRELOC'] = False
317         target_env_defs['BF_BUILDINFO'] = False
318         target_env_defs['BF_NO_ELBEEM'] = True
319         target_env_defs['WITH_BF_PYTHON'] = False
320         
321         # Merge blenderlite, let command line to override
322         for k,v in target_env_defs.iteritems():
323                 if k not in B.arguments:
324                         env[k] = v
325
326 # disable elbeem (fluidsim) compilation?
327 if env['BF_NO_ELBEEM'] == 1:
328         env['CPPFLAGS'].append('-DDISABLE_ELBEEM')
329         env['CXXFLAGS'].append('-DDISABLE_ELBEEM')
330         env['CCFLAGS'].append('-DDISABLE_ELBEEM')
331
332 if env['WITH_BF_SDL'] == False and env['OURPLATFORM'] in ('win32-vc', 'win32-ming', 'win64-vc'):
333         env['PLATFORM_LINKFLAGS'].remove('/ENTRY:mainCRTStartup')
334         env['PLATFORM_LINKFLAGS'].append('/ENTRY:main')
335
336 # lastly we check for root_build_dir ( we should not do before, otherwise we might do wrong builddir
337 B.root_build_dir = env['BF_BUILDDIR']
338 B.doc_build_dir = os.path.join(BLENDERPATH, 'doc')
339 if not B.root_build_dir[-1]==os.sep:
340         B.root_build_dir += os.sep
341 if not B.doc_build_dir[-1]==os.sep:
342         B.doc_build_dir += os.sep
343         
344 # We do a shortcut for clean when no quicklist is given: just delete
345 # builddir without reading in SConscripts
346 do_clean = None
347 if 'clean' in B.targets:
348         do_clean = True
349
350 if not quickie and do_clean:
351         if os.path.exists(B.doc_build_dir):
352                 print B.bc.HEADER+'Cleaning doc dir...'+B.bc.ENDC
353                 dirs = os.listdir(B.doc_build_dir)
354                 for entry in dirs:
355                         if os.path.isdir(B.doc_build_dir + entry) == 1:
356                                 print "clean dir %s"%(B.doc_build_dir+entry)
357                                 shutil.rmtree(B.doc_build_dir+entry)
358                         else: # remove file
359                                 print "remove file %s"%(B.doc_build_dir+entry)
360                                 os.remove(B.root_build_dir+entry)
361         if os.path.exists(B.root_build_dir):
362                 print B.bc.HEADER+'Cleaning build dir...'+B.bc.ENDC
363                 dirs = os.listdir(B.root_build_dir)
364                 for entry in dirs:
365                         if os.path.isdir(B.root_build_dir + entry) == 1:
366                                 print "clean dir %s"%(B.root_build_dir+entry)
367                                 shutil.rmtree(B.root_build_dir+entry)
368                         else: # remove file
369                                 print "remove file %s"%(B.root_build_dir+entry)
370                                 os.remove(B.root_build_dir+entry)
371                 for confile in ['extern/ffmpeg/config.mak', 'extern/x264/config.mak',
372                                 'extern/xvidcore/build/generic/platform.inc', 'extern/ffmpeg/include']:
373                         if os.path.exists(confile):
374                                 print "clean file %s"%confile
375                                 if os.path.isdir(confile):
376                                         for root, dirs, files in os.walk(confile):
377                                                 for name in files:
378                                                         os.remove(os.path.join(root, name))
379                                 else:
380                                         os.remove(confile)
381                 print B.bc.OKGREEN+'...done'+B.bc.ENDC
382         else:
383                 print B.bc.HEADER+'Already Clean, nothing to do.'+B.bc.ENDC
384         Exit()
385
386 if not os.path.isdir ( B.root_build_dir):
387         os.makedirs ( B.root_build_dir )
388         os.makedirs ( B.root_build_dir + 'source' )
389         os.makedirs ( B.root_build_dir + 'intern' )
390         os.makedirs ( B.root_build_dir + 'extern' )
391         os.makedirs ( B.root_build_dir + 'lib' )
392         os.makedirs ( B.root_build_dir + 'bin' )
393 if not os.path.isdir(B.doc_build_dir) and env['WITH_BF_DOCS']:
394         os.makedirs ( B.doc_build_dir )
395
396 Help(opts.GenerateHelpText(env))
397
398 # default is new quieter output, but if you need to see the 
399 # commands, do 'scons BF_QUIET=0'
400 bf_quietoutput = B.arguments.get('BF_QUIET', '1')
401 if env['BF_QUIET']:
402         B.set_quiet_output(env)
403 else:
404         if toolset=='msvc':
405                 B.msvc_hack(env)
406
407 print B.bc.HEADER+'Building in: ' + B.bc.ENDC + os.path.abspath(B.root_build_dir)
408 env.SConsignFile(B.root_build_dir+'scons-signatures')
409 B.init_lib_dict()
410
411 ##### END SETUP ##########
412
413 Export('env')
414
415 BuildDir(B.root_build_dir+'/intern', 'intern', duplicate=0)
416 SConscript(B.root_build_dir+'/intern/SConscript')
417 BuildDir(B.root_build_dir+'/extern', 'extern', duplicate=0)
418 SConscript(B.root_build_dir+'/extern/SConscript')
419 BuildDir(B.root_build_dir+'/source', 'source', duplicate=0)
420 SConscript(B.root_build_dir+'/source/SConscript')
421
422 # now that we have read all SConscripts, we know what
423 # libraries will be built. Create list of
424 # libraries to give as objects to linking phase
425 mainlist = []
426 for tp in B.possible_types:
427         if not tp == 'player':
428                 mainlist += B.create_blender_liblist(env, tp)
429
430 if B.arguments.get('BF_PRIORITYLIST', '0')=='1':
431         B.propose_priorities()
432
433 dobj = B.buildinfo(env, "dynamic") + B.resources
434 thestatlibs, thelibincs = B.setup_staticlibs(env)
435 thesyslibs = B.setup_syslibs(env)
436
437 if 'blender' in B.targets or not env['WITH_BF_NOBLENDER']:
438         env.BlenderProg(B.root_build_dir, "blender", dobj + mainlist, [], thestatlibs + thesyslibs, [B.root_build_dir+'/lib'] + thelibincs, 'blender')
439 if env['WITH_BF_PLAYER']:
440         playerlist = B.create_blender_liblist(env, 'player')
441         playerlist += B.create_blender_liblist(env, 'intern')
442         playerlist += B.create_blender_liblist(env, 'extern')
443         env.BlenderProg(B.root_build_dir, "blenderplayer", dobj + playerlist, [], thestatlibs + thesyslibs, [B.root_build_dir+'/lib'] + thelibincs, 'blenderplayer')
444
445 ##### Now define some targets
446
447
448 #------------ INSTALL
449
450 #-- binaries
451 blenderinstall = []
452 if  env['OURPLATFORM']=='darwin':
453         for prg in B.program_list:
454                 bundle = '%s.app' % prg[0]
455                 bundledir = os.path.dirname(bundle)
456                 for dp, dn, df in os.walk(bundle):
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         if env['WITH_BF_FHS']:  dir= os.path.join(env['BF_INSTALLDIR'], 'bin')
464         else:                                   dir= env['BF_INSTALLDIR']
465         
466         blenderinstall = env.Install(dir=dir, source=B.program_list)
467
468 #-- .blender
469 #- dont do .blender and scripts for darwin, it is already in the bundle
470 dotblendlist = []
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                         
479                         for f in df:
480                                 if not env['WITH_BF_INTERNATIONAL']:
481                                         if 'locale' in dp:
482                                                 continue
483                                         if f == '.Blanguages':
484                                                 continue
485                                 if not env['WITH_BF_FREETYPE']:
486                                         if f.endswith('.ttf'):
487                                                 continue
488                                 
489                                 dotblendlist.append(os.path.join(dp, f))
490                                 if env['WITH_BF_FHS']:  dir= os.path.join(*([BLENDERPATH] + dp.split(os.sep)[2:]))      # skip bin/.blender
491                                 else:                                   dir= os.path.join(*([BLENDERPATH] + dp.split(os.sep)[1:]))      # skip bin
492                                 
493                                 # print dir+ os.sep + f
494                                 print dir
495                                 dottargetlist.append(dir + os.sep + f)
496                                         
497
498                 dotblenderinstall = []
499                 for targetdir,srcfile in zip(dottargetlist, dotblendlist):
500                         td, tf = os.path.split(targetdir)
501                         dotblenderinstall.append(env.Install(dir=td, source=srcfile))
502                 
503                 if env['WITH_BF_PYTHON']:
504                         #-- .blender/scripts
505                         scriptpaths=['release/scripts']
506                         for scriptpath in scriptpaths:
507                                 for dp, dn, df in os.walk(scriptpath):
508                                         if '.svn' in dn:
509                                                 dn.remove('.svn')
510                                         
511                                         if env['WITH_BF_FHS']:          dir = BLENDERPATH
512                                         else:                                           dir = os.path.join(env['BF_INSTALLDIR'], '.blender')                            
513                                         dir += os.sep + os.path.basename(scriptpath) + dp[len(scriptpath):]
514                                         
515                                         source=[os.path.join(dp, f) for f in df if f[-3:]!='pyc']
516                                         scriptinstall.append(env.Install(dir=dir,source=source))
517
518 #-- icons
519 if env['OURPLATFORM']=='linux2':
520         iconlist = []
521         icontargetlist = []
522
523         for tp, tn, tf in os.walk('release/freedesktop/icons'):
524                 if '.svn' in tn:
525                         tn.remove('.svn')
526                 for f in tf:
527                         iconlist.append(os.path.join(tp, f))
528                         icontargetlist.append( os.path.join(*([BLENDERPATH] + tp.split(os.sep)[2:] + [f])) )
529
530         iconinstall = []
531         for targetdir,srcfile in zip(icontargetlist, iconlist):
532                 td, tf = os.path.split(targetdir)
533                 iconinstall.append(env.Install(dir=td, source=srcfile))
534
535 # dlls for linuxcross
536 # TODO - add more libs, for now this lets blenderlite run
537 if env['OURPLATFORM']=='linuxcross':
538         dir=env['BF_INSTALLDIR']
539         source = []
540
541         if env['WITH_BF_OPENMP']:
542                 source += ['../lib/windows/pthreads/lib/pthreadGC2.dll']
543
544         scriptinstall.append(env.Install(dir=dir, source=source))
545
546 #-- plugins
547 pluglist = []
548 plugtargetlist = []
549 for tp, tn, tf in os.walk('release/plugins'):
550         if '.svn' in tn:
551                 tn.remove('.svn')
552         df = tp[8:] # remove 'release/'
553         for f in tf:
554                 pluglist.append(os.path.join(tp, f))
555                 plugtargetlist.append( os.path.join(BLENDERPATH, df, f) )
556
557
558 # header files for plugins
559 pluglist.append('source/blender/blenpluginapi/documentation.h')
560 plugtargetlist.append(os.path.join(BLENDERPATH, 'plugins', 'include', 'documentation.h'))
561 pluglist.append('source/blender/blenpluginapi/externdef.h')
562 plugtargetlist.append(os.path.join(BLENDERPATH, 'plugins', 'include', 'externdef.h'))
563 pluglist.append('source/blender/blenpluginapi/floatpatch.h')
564 plugtargetlist.append(os.path.join(BLENDERPATH, 'plugins', 'include', 'floatpatch.h'))
565 pluglist.append('source/blender/blenpluginapi/iff.h')
566 plugtargetlist.append(os.path.join(BLENDERPATH, 'plugins', 'include', 'iff.h'))
567 pluglist.append('source/blender/blenpluginapi/plugin.h')
568 plugtargetlist.append(os.path.join(BLENDERPATH, 'plugins', 'include', 'plugin.h'))
569 pluglist.append('source/blender/blenpluginapi/util.h')
570 plugtargetlist.append(os.path.join(BLENDERPATH, 'plugins', 'include', 'util.h'))
571 pluglist.append('source/blender/blenpluginapi/plugin.DEF')
572 plugtargetlist.append(os.path.join(BLENDERPATH, 'plugins', 'include', 'plugin.def'))
573
574 plugininstall = []
575 for targetdir,srcfile in zip(plugtargetlist, pluglist):
576         td, tf = os.path.split(targetdir)
577         plugininstall.append(env.Install(dir=td, source=srcfile))
578
579 textlist = []
580 texttargetlist = []
581 for tp, tn, tf in os.walk('release/text'):
582         if '.svn' in tn:
583                 tn.remove('.svn')
584         for f in tf:
585                 textlist.append(tp+os.sep+f)
586
587 textinstall = env.Install(dir=BLENDERPATH, source=textlist)
588
589 if  env['OURPLATFORM']=='darwin':
590                 allinstall = [blenderinstall, plugininstall, textinstall]
591 elif env['OURPLATFORM']=='linux2':
592                 allinstall = [blenderinstall, dotblenderinstall, scriptinstall, plugininstall, textinstall, iconinstall]
593 else:
594                 allinstall = [blenderinstall, dotblenderinstall, scriptinstall, plugininstall, textinstall]
595
596 if env['OURPLATFORM'] in ('win32-vc', 'win32-mingw', 'win64-vc', 'linuxcross'):
597         dllsources = []
598
599         if not env['OURPLATFORM'] in ('win32-mingw', 'win64-vc', 'linuxcross'):
600                 # For MinGW and linuxcross static linking will be used
601                 dllsources += ['${LCGDIR}/gettext/lib/gnu_gettext.dll']
602
603         #currently win64-vc doesn't appear to have libpng.dll
604         if env['OURPLATFORM'] != 'win64-vc':
605                 dllsources += ['${BF_PNG_LIBPATH}/libpng.dll',
606                                 '${BF_ZLIB_LIBPATH}/zlib.dll']
607
608         dllsources += ['${BF_TIFF_LIBPATH}/${BF_TIFF_LIB}.dll']
609
610         if env['OURPLATFORM'] != 'linuxcross':
611                 # pthreads library is already added
612                 dllsources += ['${BF_PTHREADS_LIBPATH}/${BF_PTHREADS_LIB}.dll']
613
614         if env['WITH_BF_SDL']:
615                 if env['OURPLATFORM'] == 'win64-vc':
616                         pass # we link statically already to SDL on win64
617                 else:
618                         dllsources.append('${BF_SDL_LIBPATH}/SDL.dll')
619
620         if env['WITH_BF_PYTHON']:
621                 if env['BF_DEBUG']:
622                         dllsources.append('${BF_PYTHON_LIBPATH}/${BF_PYTHON_DLL}_d.dll')
623                 else:
624                         dllsources.append('${BF_PYTHON_LIBPATH}/${BF_PYTHON_DLL}.dll')
625
626         if env['WITH_BF_ICONV']:
627                 if env['OURPLATFORM'] == 'win64-vc':
628                         pass # we link statically to iconv on win64
629                 elif not env['OURPLATFORM'] in ('win32-mingw', 'linuxcross'):
630                         #gettext for MinGW and cross-compilation is compiled staticly
631                         dllsources += ['${BF_ICONV_LIBPATH}/iconv.dll']
632
633         if env['WITH_BF_OPENAL']:
634                 dllsources.append('${LCGDIR}/openal/lib/OpenAL32.dll')
635                 dllsources.append('${LCGDIR}/openal/lib/wrap_oal.dll')
636
637         if env['WITH_BF_SNDFILE']:
638                 dllsources.append('${LCGDIR}/sndfile/lib/libsndfile-1.dll')
639
640         if env['WITH_BF_FFMPEG']:
641                 dllsources += ['${BF_FFMPEG_LIBPATH}/avcodec-52.dll',
642                                         '${BF_FFMPEG_LIBPATH}/avformat-52.dll',
643                                         '${BF_FFMPEG_LIBPATH}/avdevice-52.dll',
644                                         '${BF_FFMPEG_LIBPATH}/avutil-50.dll',
645                                         '${BF_FFMPEG_LIBPATH}/swscale-0.dll']
646
647                 if env['OURPLATFORM'] != 'linuxcross':
648                         #
649                         # TODO: Does it mean we haven't got support of this codecs if
650                         #       we're using cross-compilation?
651                         #       Or in case of native compilation this libraries are
652                         #       unneccessary to?
653                         #
654                         dllsources += ['${LCGDIR}/ffmpeg/lib/libfaac-0.dll',
655                                                         '${LCGDIR}/ffmpeg/lib/libfaad-2.dll',
656                                                         '${LCGDIR}/ffmpeg/lib/libmp3lame-0.dll',
657                                                         '${LCGDIR}/ffmpeg/lib/libx264-67.dll']
658
659         if env['WITH_BF_JACK']:
660                 dllsources += ['${LCGDIR}/jack/lib/libjack.dll']
661         windlls = env.Install(dir=env['BF_INSTALLDIR'], source = dllsources)
662         allinstall += windlls
663
664 installtarget = env.Alias('install', allinstall)
665 bininstalltarget = env.Alias('install-bin', blenderinstall)
666
667 nsisaction = env.Action(btools.NSIS_Installer, btools.NSIS_print)
668 nsiscmd = env.Command('nsisinstaller', None, nsisaction)
669 nsisalias = env.Alias('nsis', nsiscmd)
670
671 if 'blender' in B.targets:
672         blenderexe= env.Alias('blender', B.program_list)
673         Depends(blenderexe,installtarget)
674
675 if env['WITH_BF_PLAYER']:
676         blenderplayer = env.Alias('blenderplayer', B.program_list)
677         Depends(blenderplayer,installtarget)
678
679 if not env['WITH_BF_GAMEENGINE']:
680         blendernogame = env.Alias('blendernogame', B.program_list)
681         Depends(blendernogame,installtarget)
682
683 if 'blenderlite' in B.targets:
684         blenderlite = env.Alias('blenderlite', B.program_list)
685         Depends(blenderlite,installtarget)
686
687 Depends(nsiscmd, allinstall)
688
689 Default(B.program_list)
690
691 if not env['WITHOUT_BF_INSTALL']:
692                 Default(installtarget)
693
694 #------------ EPYDOC
695 if env['WITH_BF_DOCS']:
696     try:
697         import epydoc
698     except ImportError:
699         epydoc = None
700
701     if epydoc:
702         SConscript('source/gameengine/PyDoc/SConscript')
703     else:
704         print "No epydoc install detected, Python API and Gameengine API Docs will not be generated "
705
706