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