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