Clear scons installation directory when WITHOUT_BF_INSTALL is disabled.
[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 if not env['WITHOUT_BF_INSTALL']:
194     if os.path.isdir(env['BF_INSTALLDIR']):
195         print B.bc.OKGREEN + "Clearing installation directory%s: %s" % (B.bc.ENDC, os.path.abspath(env['BF_INSTALLDIR']))
196         shutil.rmtree(env['BF_INSTALLDIR'])
197
198
199 SetOption('num_jobs', int(env['BF_NUMJOBS']))
200 print B.bc.OKGREEN + "Build with parallel jobs%s: %s" % (B.bc.ENDC, GetOption('num_jobs'))
201
202 # BLENDERPATH is a unix only option to enable typical style paths this is
203 # spesifically a data-dir, which is used a lot but cant replace BF_INSTALLDIR
204 # because the blender binary is installed in $BF_INSTALLDIR/bin/blender
205
206 if env['WITH_BF_FHS']:
207         BLENDERPATH = os.path.join(env['BF_INSTALLDIR'], 'share', 'blender', env['BF_VERSION'])
208 else:
209         BLENDERPATH = env['BF_INSTALLDIR']
210
211 if env['WITH_BF_OPENMP'] == 1:
212                 if env['OURPLATFORM'] in ('win32-vc', 'win64-vc'):
213                                 env['CCFLAGS'].append('/openmp')
214                                 env['CPPFLAGS'].append('/openmp')
215                                 env['CXXFLAGS'].append('/openmp')
216                 else:
217                         if env['CC'].endswith('icc'): # to be able to handle CC=/opt/bla/icc case
218                                 env.Append(LINKFLAGS=['-openmp', '-static-intel'])
219                                 env['CCFLAGS'].append('-openmp')
220                                 env['CPPFLAGS'].append('-openmp')
221                                 env['CXXFLAGS'].append('-openmp')
222                         else:
223                                 env.Append(CCFLAGS=['-fopenmp']) 
224                                 env.Append(CPPFLAGS=['-fopenmp'])
225                                 env.Append(CXXFLAGS=['-fopenmp'])
226
227 if env['WITH_GHOST_COCOA'] == True:
228         env.Append(CFLAGS=['-DGHOST_COCOA']) 
229         env.Append(CXXFLAGS=['-DGHOST_COCOA'])
230         env.Append(CPPFLAGS=['-DGHOST_COCOA'])
231     
232 if env['USE_QTKIT'] == True:
233         env.Append(CFLAGS=['-DUSE_QTKIT']) 
234         env.Append(CXXFLAGS=['-DUSE_QTKIT'])
235         env.Append(CPPFLAGS=['-DUSE_QTKIT'])
236
237 #check for additional debug libnames
238
239 if env.has_key('BF_DEBUG_LIBS'):
240         B.quickdebug += env['BF_DEBUG_LIBS']
241
242 printdebug = B.arguments.get('BF_LISTDEBUG', 0)
243
244 # see if this linux distro has libalut
245
246 if env['OURPLATFORM'] == 'linux2' :
247         if env['WITH_BF_OPENAL']:
248                 mylib_test_source_file = """
249                 #include "AL/alut.h"
250                 int main(int argc, char **argv)
251                 {
252                         alutGetMajorVersion();
253                         return 0;
254                 }
255                 """
256
257                 def CheckFreeAlut(context,env):
258                         context.Message( B.bc.OKGREEN + "Linux platform detected:\n  checking for FreeAlut... " + B.bc.ENDC )
259                         env['LIBS'] = 'alut'
260                         result = context.TryLink(mylib_test_source_file, '.c')
261                         context.Result(result)
262                         return result
263
264                 env2 = env.Clone( LIBPATH = env['BF_OPENAL'] ) 
265                 sconf_temp = mkdtemp()
266                 conf = Configure( env2, {'CheckFreeAlut' : CheckFreeAlut}, sconf_temp, '/dev/null' )
267                 if conf.CheckFreeAlut( env2 ):
268                         env['BF_OPENAL_LIB'] += ' alut'
269                 del env2
270                 root = ''
271                 for root, dirs, files in os.walk(sconf_temp, topdown=False):
272                         for name in files:
273                                 os.remove(os.path.join(root, name))
274                         for name in dirs:
275                                 os.rmdir(os.path.join(root, name))
276                 if root: os.rmdir(root)
277
278 if len(B.quickdebug) > 0 and printdebug != 0:
279         print B.bc.OKGREEN + "Buildings these libs with debug symbols:" + B.bc.ENDC
280         for l in B.quickdebug:
281                 print "\t" + l
282
283 # remove stdc++ from LLIBS if we are building a statc linked CXXFLAGS
284 if env['WITH_BF_STATICCXX']:
285         if 'stdc++' in env['LLIBS']:
286                 env['LLIBS'].remove('stdc++')
287         else:
288                 print '\tcould not remove stdc++ library from LLIBS, WITH_BF_STATICCXX may not work for your platform'
289
290 # check target for blenderplayer. Set WITH_BF_PLAYER if found on cmdline
291 if 'blenderplayer' in B.targets:
292         env['WITH_BF_PLAYER'] = True
293
294 if 'blendernogame' in B.targets:
295         env['WITH_BF_GAMEENGINE'] = False
296
297 if 'blenderlite' in B.targets:
298         target_env_defs = {}
299         target_env_defs['WITH_BF_GAMEENGINE'] = False
300         target_env_defs['WITH_BF_OPENAL'] = False
301         target_env_defs['WITH_BF_OPENEXR'] = False
302         target_env_defs['WITH_BF_ICONV'] = False
303         target_env_defs['WITH_BF_INTERNATIONAL'] = False
304         target_env_defs['WITH_BF_OPENJPEG'] = False
305         target_env_defs['WITH_BF_FFMPEG'] = False
306         target_env_defs['WITH_BF_QUICKTIME'] = False
307         target_env_defs['WITH_BF_REDCODE'] = False
308         target_env_defs['WITH_BF_DDS'] = False
309         target_env_defs['WITH_BF_ZLIB'] = False
310         target_env_defs['WITH_BF_SDL'] = False
311         target_env_defs['WITH_BF_JPEG'] = False
312         target_env_defs['WITH_BF_PNG'] = False
313         target_env_defs['WITH_BF_BULLET'] = False
314         target_env_defs['WITH_BF_BINRELOC'] = False
315         target_env_defs['BF_BUILDINFO'] = False
316         target_env_defs['BF_NO_ELBEEM'] = True
317         target_env_defs['WITH_BF_PYTHON'] = False
318         
319         # Merge blenderlite, let command line to override
320         for k,v in target_env_defs.iteritems():
321                 if k not in B.arguments:
322                         env[k] = v
323
324 # disable elbeem (fluidsim) compilation?
325 if env['BF_NO_ELBEEM'] == 1:
326         env['CPPFLAGS'].append('-DDISABLE_ELBEEM')
327         env['CXXFLAGS'].append('-DDISABLE_ELBEEM')
328         env['CCFLAGS'].append('-DDISABLE_ELBEEM')
329
330 if env['WITH_BF_SDL'] == False and env['OURPLATFORM'] in ('win32-vc', 'win32-ming', 'win64-vc'):
331         env['PLATFORM_LINKFLAGS'].remove('/ENTRY:mainCRTStartup')
332         env['PLATFORM_LINKFLAGS'].append('/ENTRY:main')
333
334 # lastly we check for root_build_dir ( we should not do before, otherwise we might do wrong builddir
335 B.root_build_dir = env['BF_BUILDDIR']
336 B.doc_build_dir = os.path.join(BLENDERPATH, 'doc')
337 if not B.root_build_dir[-1]==os.sep:
338         B.root_build_dir += os.sep
339 if not B.doc_build_dir[-1]==os.sep:
340         B.doc_build_dir += os.sep
341         
342 # We do a shortcut for clean when no quicklist is given: just delete
343 # builddir without reading in SConscripts
344 do_clean = None
345 if 'clean' in B.targets:
346         do_clean = True
347
348 if not quickie and do_clean:
349         if os.path.exists(B.doc_build_dir):
350                 print B.bc.HEADER+'Cleaning doc dir...'+B.bc.ENDC
351                 dirs = os.listdir(B.doc_build_dir)
352                 for entry in dirs:
353                         if os.path.isdir(B.doc_build_dir + entry) == 1:
354                                 print "clean dir %s"%(B.doc_build_dir+entry)
355                                 shutil.rmtree(B.doc_build_dir+entry)
356                         else: # remove file
357                                 print "remove file %s"%(B.doc_build_dir+entry)
358                                 os.remove(B.root_build_dir+entry)
359         if os.path.exists(B.root_build_dir):
360                 print B.bc.HEADER+'Cleaning build dir...'+B.bc.ENDC
361                 dirs = os.listdir(B.root_build_dir)
362                 for entry in dirs:
363                         if os.path.isdir(B.root_build_dir + entry) == 1:
364                                 print "clean dir %s"%(B.root_build_dir+entry)
365                                 shutil.rmtree(B.root_build_dir+entry)
366                         else: # remove file
367                                 print "remove file %s"%(B.root_build_dir+entry)
368                                 os.remove(B.root_build_dir+entry)
369                 for confile in ['extern/ffmpeg/config.mak', 'extern/x264/config.mak',
370                                 'extern/xvidcore/build/generic/platform.inc', 'extern/ffmpeg/include']:
371                         if os.path.exists(confile):
372                                 print "clean file %s"%confile
373                                 if os.path.isdir(confile):
374                                         for root, dirs, files in os.walk(confile):
375                                                 for name in files:
376                                                         os.remove(os.path.join(root, name))
377                                 else:
378                                         os.remove(confile)
379                 print B.bc.OKGREEN+'...done'+B.bc.ENDC
380         else:
381                 print B.bc.HEADER+'Already Clean, nothing to do.'+B.bc.ENDC
382         Exit()
383
384 if not os.path.isdir ( B.root_build_dir):
385         os.makedirs ( B.root_build_dir )
386         os.makedirs ( B.root_build_dir + 'source' )
387         os.makedirs ( B.root_build_dir + 'intern' )
388         os.makedirs ( B.root_build_dir + 'extern' )
389         os.makedirs ( B.root_build_dir + 'lib' )
390         os.makedirs ( B.root_build_dir + 'bin' )
391 if not os.path.isdir(B.doc_build_dir) and env['WITH_BF_DOCS']:
392         os.makedirs ( B.doc_build_dir )
393
394 Help(opts.GenerateHelpText(env))
395
396 # default is new quieter output, but if you need to see the 
397 # commands, do 'scons BF_QUIET=0'
398 bf_quietoutput = B.arguments.get('BF_QUIET', '1')
399 if env['BF_QUIET']:
400         B.set_quiet_output(env)
401 else:
402         if toolset=='msvc':
403                 B.msvc_hack(env)
404
405 print B.bc.HEADER+'Building in: ' + B.bc.ENDC + os.path.abspath(B.root_build_dir)
406 env.SConsignFile(B.root_build_dir+'scons-signatures')
407 B.init_lib_dict()
408
409 ##### END SETUP ##########
410
411 Export('env')
412
413 BuildDir(B.root_build_dir+'/intern', 'intern', duplicate=0)
414 SConscript(B.root_build_dir+'/intern/SConscript')
415 BuildDir(B.root_build_dir+'/extern', 'extern', duplicate=0)
416 SConscript(B.root_build_dir+'/extern/SConscript')
417 BuildDir(B.root_build_dir+'/source', 'source', duplicate=0)
418 SConscript(B.root_build_dir+'/source/SConscript')
419
420 # now that we have read all SConscripts, we know what
421 # libraries will be built. Create list of
422 # libraries to give as objects to linking phase
423 mainlist = []
424 for tp in B.possible_types:
425         if not tp == 'player':
426                 mainlist += B.create_blender_liblist(env, tp)
427
428 if B.arguments.get('BF_PRIORITYLIST', '0')=='1':
429         B.propose_priorities()
430
431 dobj = B.buildinfo(env, "dynamic") + B.resources
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", dobj + mainlist, [], thestatlibs + 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, '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                         dir=env['BF_INSTALLDIR']+dp[len(bundledir):]
458                         source=[dp+os.sep+f for f in df]
459                         blenderinstall.append(env.Install(dir=dir,source=source))
460 else:
461         if env['WITH_BF_FHS']:  dir= os.path.join(env['BF_INSTALLDIR'], 'bin')
462         else:                                   dir= env['BF_INSTALLDIR']
463         
464         blenderinstall = env.Install(dir=dir, source=B.program_list)
465
466 #-- .blender
467 #- dont do .blender and scripts for darwin, it is already in the bundle
468 dotblendlist = []
469 dottargetlist = []
470 scriptinstall = []
471
472 if  env['OURPLATFORM']!='darwin':
473                 for dp, dn, df in os.walk('bin/.blender'):
474                         if '.svn' in dn:
475                                 dn.remove('.svn')
476                         
477                         for f in df:
478                                 if not env['WITH_BF_INTERNATIONAL']:
479                                         if 'locale' in dp:
480                                                 continue
481                                         if f == '.Blanguages':
482                                                 continue
483                                 if not env['WITH_BF_FREETYPE']:
484                                         if f.endswith('.ttf'):
485                                                 continue
486                                 
487                                 dotblendlist.append(os.path.join(dp, f))
488                                 if env['WITH_BF_FHS']:  dir= os.path.join(*([BLENDERPATH] + dp.split(os.sep)[2:]))      # skip bin/.blender
489                                 else:                                   dir= os.path.join(*([BLENDERPATH] + dp.split(os.sep)[1:]))      # skip bin
490                                 
491                                 # print dir+ os.sep + f
492                                 print dir
493                                 dottargetlist.append(dir + os.sep + f)
494                                         
495
496                 dotblenderinstall = []
497                 for targetdir,srcfile in zip(dottargetlist, dotblendlist):
498                         td, tf = os.path.split(targetdir)
499                         dotblenderinstall.append(env.Install(dir=td, source=srcfile))
500                 
501                 if env['WITH_BF_PYTHON']:
502                         #-- .blender/scripts
503                         scriptpaths=['release/scripts']
504                         for scriptpath in scriptpaths:
505                                 for dp, dn, df in os.walk(scriptpath):
506                                         if '.svn' in dn:
507                                                 dn.remove('.svn')
508                                         
509                                         if env['WITH_BF_FHS']:          dir = BLENDERPATH
510                                         else:                                           dir = os.path.join(env['BF_INSTALLDIR'], '.blender')                            
511                                         dir += os.sep + os.path.basename(scriptpath) + dp[len(scriptpath):]
512                                         
513                                         source=[os.path.join(dp, f) for f in df if f[-3:]!='pyc']
514                                         scriptinstall.append(env.Install(dir=dir,source=source))
515
516 #-- icons
517 if env['OURPLATFORM']=='linux2':
518         iconlist = []
519         icontargetlist = []
520
521         for tp, tn, tf in os.walk('release/freedesktop/icons'):
522                 if '.svn' in tn:
523                         tn.remove('.svn')
524                 for f in tf:
525                         iconlist.append(os.path.join(tp, f))
526                         icontargetlist.append( os.path.join(*([BLENDERPATH] + tp.split(os.sep)[2:] + [f])) )
527
528         iconinstall = []
529         for targetdir,srcfile in zip(icontargetlist, iconlist):
530                 td, tf = os.path.split(targetdir)
531                 iconinstall.append(env.Install(dir=td, source=srcfile))
532
533 # dlls for linuxcross
534 # TODO - add more libs, for now this lets blenderlite run
535 if env['OURPLATFORM']=='linuxcross':
536         dir=env['BF_INSTALLDIR']
537         source = []
538
539         if env['WITH_BF_OPENMP']:
540                 source += ['../lib/windows/pthreads/lib/pthreadGC2.dll']
541
542         scriptinstall.append(env.Install(dir=dir, source=source))
543
544 #-- plugins
545 pluglist = []
546 plugtargetlist = []
547 for tp, tn, tf in os.walk('release/plugins'):
548         if '.svn' in tn:
549                 tn.remove('.svn')
550         df = tp[8:] # remove 'release/'
551         for f in tf:
552                 pluglist.append(os.path.join(tp, f))
553                 plugtargetlist.append( os.path.join(BLENDERPATH, df, f) )
554
555
556 # header files for plugins
557 pluglist.append('source/blender/blenpluginapi/documentation.h')
558 plugtargetlist.append(os.path.join(BLENDERPATH, 'plugins', 'include', 'documentation.h'))
559 pluglist.append('source/blender/blenpluginapi/externdef.h')
560 plugtargetlist.append(os.path.join(BLENDERPATH, 'plugins', 'include', 'externdef.h'))
561 pluglist.append('source/blender/blenpluginapi/floatpatch.h')
562 plugtargetlist.append(os.path.join(BLENDERPATH, 'plugins', 'include', 'floatpatch.h'))
563 pluglist.append('source/blender/blenpluginapi/iff.h')
564 plugtargetlist.append(os.path.join(BLENDERPATH, 'plugins', 'include', 'iff.h'))
565 pluglist.append('source/blender/blenpluginapi/plugin.h')
566 plugtargetlist.append(os.path.join(BLENDERPATH, 'plugins', 'include', 'plugin.h'))
567 pluglist.append('source/blender/blenpluginapi/util.h')
568 plugtargetlist.append(os.path.join(BLENDERPATH, 'plugins', 'include', 'util.h'))
569 pluglist.append('source/blender/blenpluginapi/plugin.DEF')
570 plugtargetlist.append(os.path.join(BLENDERPATH, 'plugins', 'include', 'plugin.def'))
571
572 plugininstall = []
573 for targetdir,srcfile in zip(plugtargetlist, pluglist):
574         td, tf = os.path.split(targetdir)
575         plugininstall.append(env.Install(dir=td, source=srcfile))
576
577 textlist = []
578 texttargetlist = []
579 for tp, tn, tf in os.walk('release/text'):
580         if '.svn' in tn:
581                 tn.remove('.svn')
582         for f in tf:
583                 textlist.append(tp+os.sep+f)
584
585 textinstall = env.Install(dir=BLENDERPATH, source=textlist)
586
587 if  env['OURPLATFORM']=='darwin':
588                 allinstall = [blenderinstall, plugininstall, textinstall]
589 elif env['OURPLATFORM']=='linux2':
590                 allinstall = [blenderinstall, dotblenderinstall, scriptinstall, plugininstall, textinstall, iconinstall]
591 else:
592                 allinstall = [blenderinstall, dotblenderinstall, scriptinstall, plugininstall, textinstall]
593
594 if env['OURPLATFORM'] in ('win32-vc', 'win32-mingw', 'win64-vc', 'linuxcross'):
595         dllsources = []
596
597         if not env['OURPLATFORM'] in ('win32-mingw', 'win64-vc', 'linuxcross'):
598                 # For MinGW and linuxcross static linking will be used
599                 dllsources += ['${LCGDIR}/gettext/lib/gnu_gettext.dll']
600
601         #currently win64-vc doesn't appear to have libpng.dll
602         if env['OURPLATFORM'] != 'win64-vc':
603                 dllsources += ['${BF_PNG_LIBPATH}/libpng.dll',
604                                 '${BF_ZLIB_LIBPATH}/zlib.dll']
605
606         dllsources += ['${BF_TIFF_LIBPATH}/${BF_TIFF_LIB}.dll']
607
608         if env['OURPLATFORM'] != 'linuxcross':
609                 # pthreads library is already added
610                 dllsources += ['${BF_PTHREADS_LIBPATH}/${BF_PTHREADS_LIB}.dll']
611
612         if env['WITH_BF_SDL']:
613                 if env['OURPLATFORM'] == 'win64-vc':
614                         pass # we link statically already to SDL on win64
615                 else:
616                         dllsources.append('${BF_SDL_LIBPATH}/SDL.dll')
617
618         if env['WITH_BF_PYTHON']:
619                 if env['BF_DEBUG']:
620                         dllsources.append('${BF_PYTHON_LIBPATH}/${BF_PYTHON_DLL}_d.dll')
621                 else:
622                         dllsources.append('${BF_PYTHON_LIBPATH}/${BF_PYTHON_DLL}.dll')
623
624         if env['WITH_BF_ICONV']:
625                 if env['OURPLATFORM'] == 'win64-vc':
626                         pass # we link statically to iconv on win64
627                 elif not env['OURPLATFORM'] in ('win32-mingw', 'linuxcross'):
628                         #gettext for MinGW and cross-compilation is compiled staticly
629                         dllsources += ['${BF_ICONV_LIBPATH}/iconv.dll']
630
631         if env['WITH_BF_OPENAL']:
632                 dllsources.append('${LCGDIR}/openal/lib/OpenAL32.dll')
633                 dllsources.append('${LCGDIR}/openal/lib/wrap_oal.dll')
634
635         if env['WITH_BF_SNDFILE']:
636                 dllsources.append('${LCGDIR}/sndfile/lib/libsndfile-1.dll')
637
638         if env['WITH_BF_FFMPEG']:
639                 dllsources += ['${BF_FFMPEG_LIBPATH}/avcodec-52.dll',
640                                         '${BF_FFMPEG_LIBPATH}/avformat-52.dll',
641                                         '${BF_FFMPEG_LIBPATH}/avdevice-52.dll',
642                                         '${BF_FFMPEG_LIBPATH}/avutil-50.dll',
643                                         '${BF_FFMPEG_LIBPATH}/swscale-0.dll']
644
645                 if env['OURPLATFORM'] != 'linuxcross':
646                         #
647                         # TODO: Does it mean we haven't got support of this codecs if
648                         #       we're using cross-compilation?
649                         #       Or in case of native compilation this libraries are
650                         #       unneccessary to?
651                         #
652                         dllsources += ['${LCGDIR}/ffmpeg/lib/libfaac-0.dll',
653                                                         '${LCGDIR}/ffmpeg/lib/libfaad-2.dll',
654                                                         '${LCGDIR}/ffmpeg/lib/libmp3lame-0.dll',
655                                                         '${LCGDIR}/ffmpeg/lib/libx264-67.dll']
656
657         if env['WITH_BF_JACK']:
658                 dllsources += ['${LCGDIR}/jack/lib/libjack.dll']
659         windlls = env.Install(dir=env['BF_INSTALLDIR'], source = dllsources)
660         allinstall += windlls
661
662 installtarget = env.Alias('install', allinstall)
663 bininstalltarget = env.Alias('install-bin', blenderinstall)
664
665 nsisaction = env.Action(btools.NSIS_Installer, btools.NSIS_print)
666 nsiscmd = env.Command('nsisinstaller', None, nsisaction)
667 nsisalias = env.Alias('nsis', nsiscmd)
668
669 if 'blender' in B.targets:
670         blenderexe= env.Alias('blender', B.program_list)
671         Depends(blenderexe,installtarget)
672
673 if env['WITH_BF_PLAYER']:
674         blenderplayer = env.Alias('blenderplayer', B.program_list)
675         Depends(blenderplayer,installtarget)
676
677 if not env['WITH_BF_GAMEENGINE']:
678         blendernogame = env.Alias('blendernogame', B.program_list)
679         Depends(blendernogame,installtarget)
680
681 if 'blenderlite' in B.targets:
682         blenderlite = env.Alias('blenderlite', B.program_list)
683         Depends(blenderlite,installtarget)
684
685 Depends(nsiscmd, allinstall)
686
687 Default(B.program_list)
688
689 if not env['WITHOUT_BF_INSTALL']:
690                 Default(installtarget)
691
692 #------------ EPYDOC
693 if env['WITH_BF_DOCS']:
694     try:
695         import epydoc
696     except ImportError:
697         epydoc = None
698
699     if epydoc:
700         SConscript('source/gameengine/PyDoc/SConscript')
701     else:
702         print "No epydoc install detected, Python API and Gameengine API Docs will not be generated "
703
704