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