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