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