Fix memory leak in GHOST Event Manager.
[blender.git] / SConstruct
1 #!/usr/bin/env python
2 #
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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 # TODO: directory copy functions are far too complicated, see:
34 #       http://wiki.blender.org/index.php/User:Ideasman42/SConsNotSimpleInstallingFiles
35
36 import sys
37 import os
38 import os.path
39 import string
40 import shutil
41 import re
42
43 # store path to tools and modules
44 toolpath=os.path.join(".", "build_files", "scons", "tools")
45 modulespath=os.path.join(".", "build_files", "scons", "Modules")
46
47 # needed for importing tools and modules
48 sys.path.append(toolpath)
49 sys.path.append(modulespath)
50
51 import Blender
52 import btools
53
54 EnsureSConsVersion(1,0,0)
55
56 # Before we do anything, let's check if we have a sane os.environ
57 if not btools.check_environ():
58     Exit()
59
60 BlenderEnvironment = Blender.BlenderEnvironment
61 B = Blender
62
63 VERSION = btools.VERSION # This is used in creating the local config directories
64 VERSION_RELEASE_CYCLE = btools.VERSION_RELEASE_CYCLE
65
66 ### globals ###
67 platform = sys.platform
68 quickie = None
69 quickdebug = None
70
71 ##### BEGIN SETUP #####
72
73 B.possible_types = ['core', 'player', 'player2', 'intern', 'extern', 'system']
74
75 B.binarykind = ['blender' , 'blenderplayer']
76 ##################################
77 # target and argument validation #
78 ##################################
79 # XX cheating for BF_FANCY, we check for BF_FANCY before args are validated
80 use_color = ARGUMENTS.get('BF_FANCY', '1')
81 if platform=='win32':
82     use_color = None
83
84 if not use_color=='1':
85     B.bc.disable()
86
87  #on defaut white Os X terminal, some colors are totally unlegible
88 if platform=='darwin':
89     B.bc.OKGREEN = '\033[34m'
90     B.bc.WARNING = '\033[36m'
91
92 # arguments
93 print B.bc.HEADER+'Command-line arguments'+B.bc.ENDC
94 B.arguments = btools.validate_arguments(ARGUMENTS, B.bc)
95 btools.print_arguments(B.arguments, B.bc)
96
97 # targets
98 print B.bc.HEADER+'Command-line targets'+B.bc.ENDC
99 B.targets = btools.validate_targets(COMMAND_LINE_TARGETS, B.bc)
100 btools.print_targets(B.targets, B.bc)
101
102 ##########################
103 # setting up environment #
104 ##########################
105
106 # handling cmd line arguments & config file
107
108 # bitness stuff
109 tempbitness = int(B.arguments.get('BF_BITNESS', B.bitness)) # default to bitness found as per starting python
110 if tempbitness in B.allowed_bitnesses.values() :
111     B.bitness = tempbitness
112
113 # first check cmdline for toolset and we create env to work on
114 quickie = B.arguments.get('BF_QUICK', None)
115 quickdebug = B.arguments.get('BF_QUICKDEBUG', None)
116
117 if quickdebug:
118     B.quickdebug=string.split(quickdebug, ',')
119 else:
120     B.quickdebug=[]
121
122 if quickie:
123     B.quickie=string.split(quickie,',')
124 else:
125     B.quickie=[]
126
127 toolset = B.arguments.get('BF_TOOLSET', None)
128 vcver = B.arguments.get('MSVS_VERSION', '12.0')
129
130 if toolset:
131     print "Using " + toolset
132     if toolset=='mstoolkit':
133         env = BlenderEnvironment(ENV = os.environ)
134         env.Tool('mstoolkit', [toolpath])
135     else:
136         env = BlenderEnvironment(tools=[toolset], ENV = os.environ)
137         if env:
138             btools.SetupSpawn(env)
139 else:
140     if B.bitness==64 and platform=='win32':
141         env = BlenderEnvironment(ENV = os.environ, MSVS_ARCH='amd64', TARGET_ARCH='x86_64', MSVC_VERSION=vcver)
142     else:
143         env = BlenderEnvironment(ENV = os.environ, TARGET_ARCH='x86', MSVC_VERSION=vcver)
144
145 if not env:
146     print "Could not create a build environment"
147     Exit()
148
149 cc = B.arguments.get('CC', None)
150 cxx = B.arguments.get('CXX', None)
151 if cc:
152     env['CC'] = cc
153 if cxx:
154     env['CXX'] = cxx
155
156 if sys.platform=='win32':
157     if env['CC'] in ['cl', 'cl.exe']:
158         platform = 'win64-vc' if B.bitness == 64 else 'win32-vc'
159     elif env['CC'] in ['gcc']:
160         platform = 'win64-mingw' if B.bitness == 64 else 'win32-mingw'
161
162 if 'mingw' in platform:
163     print "Setting custom spawn function"
164     btools.SetupSpawn(env)
165
166 env.SConscriptChdir(0)
167
168 # Remove major kernel version from linux platform.
169 # After Linus switched kernel to new version model this major version
170 # shouldn't take much sense for building rules.
171
172 if re.match('linux[0-9]+', platform):
173     platform = 'linux'
174
175 crossbuild = B.arguments.get('BF_CROSS', None)
176 if crossbuild and platform not in ('win32-vc', 'win64-vc'):
177     platform = 'linuxcross'
178
179 env['OURPLATFORM'] = platform
180
181 configfile = os.path.join("build_files", "scons", "config", platform + "-config.py")
182
183 if os.path.exists(configfile):
184     print B.bc.OKGREEN + "Using config file: " + B.bc.ENDC + configfile
185 else:
186     print B.bc.FAIL + configfile + " doesn't exist" + B.bc.ENDC
187
188 if crossbuild and env['PLATFORM'] != 'win32':
189     print B.bc.HEADER+"Preparing for crossbuild"+B.bc.ENDC
190     env.Tool('crossmingw', [toolpath])
191     # todo: determine proper libs/includes etc.
192     # Needed for gui programs, console programs should do without it
193
194     # Now we don't need this option to have console window
195     # env.Append(LINKFLAGS=['-mwindows'])
196
197 userconfig = B.arguments.get('BF_CONFIG', 'user-config.py')
198 # first read platform config. B.arguments will override
199 optfiles = [configfile]
200 if os.path.exists(userconfig):
201     print B.bc.OKGREEN + "Using user-config file: " + B.bc.ENDC + userconfig
202     optfiles += [userconfig]
203 else:
204     print B.bc.WARNING + userconfig + " not found, no user overrides" + B.bc.ENDC
205
206 opts = btools.read_opts(env, optfiles, B.arguments)
207 opts.Update(env)
208
209 if sys.platform=='win32':
210     if B.bitness==64:
211         env.Append(CPPFLAGS=['-DWIN64']) # -DWIN32 needed too, as it's used all over to target Windows generally
212
213 if env['BF_DEBUG']:
214     env.Append(CPPDEFINES=['_DEBUG', 'DEBUG'])
215 else:
216     env.Append(CPPDEFINES=['NDEBUG'])
217
218 if not env['BF_FANCY']:
219     B.bc.disable()
220
221 if env['WITH_BF_SDL_DYNLOAD']:
222     env['BF_SDL_INC'] = '#extern/sdlew/include/SDL2'
223
224 # remove install dir so old and new files are not mixed.
225 # NOTE: only do the scripts directory for now, otherwise is too disruptive for developers
226 # TODO: perhaps we need an option (off by default) to not do this altogether...
227 if not env['WITHOUT_BF_INSTALL'] and not env['WITHOUT_BF_OVERWRITE_INSTALL']:
228     scriptsDir = os.path.join(env['BF_INSTALLDIR'], VERSION, 'scripts')
229     if os.path.isdir(scriptsDir):
230         print B.bc.OKGREEN + "Clearing installation directory%s: %s" % (B.bc.ENDC, os.path.abspath(scriptsDir))
231         shutil.rmtree(scriptsDir)
232
233
234 SetOption('num_jobs', int(env['BF_NUMJOBS']))
235 print B.bc.OKGREEN + "Build with parallel jobs%s: %s" % (B.bc.ENDC, GetOption('num_jobs'))
236 print B.bc.OKGREEN + "Build with debug symbols%s: %s" % (B.bc.ENDC, env['BF_DEBUG'])
237
238 if 'blenderlite' in B.targets:
239     target_env_defs = {}
240     target_env_defs['WITH_BF_GAMEENGINE'] = False
241     target_env_defs['WITH_BF_CYCLES'] = False
242     target_env_defs['WITH_BF_OPENAL'] = False
243     target_env_defs['WITH_BF_OPENEXR'] = False
244     target_env_defs['WITH_BF_PSD'] = False
245     target_env_defs['WITH_BF_OPENMP'] = False
246     target_env_defs['WITH_BF_ICONV'] = False
247     target_env_defs['WITH_BF_INTERNATIONAL'] = False
248     target_env_defs['WITH_BF_OPENJPEG'] = False
249     target_env_defs['WITH_BF_FFMPEG'] = False
250     target_env_defs['WITH_BF_QUICKTIME'] = False
251     target_env_defs['WITH_BF_REDCODE'] = False
252     target_env_defs['WITH_BF_DDS'] = False
253     target_env_defs['WITH_BF_CINEON'] = False
254     target_env_defs['WITH_BF_FRAMESERVER'] = False
255     target_env_defs['WITH_BF_HDR'] = False
256     target_env_defs['WITH_BF_ZLIB'] = False
257     target_env_defs['WITH_BF_SDL'] = False
258     target_env_defs['WITH_BF_JPEG'] = False
259     target_env_defs['WITH_BF_PNG'] = False
260     target_env_defs['WITH_BF_BULLET'] = False
261     target_env_defs['WITH_BF_BINRELOC'] = False
262     target_env_defs['BF_BUILDINFO'] = False
263     target_env_defs['WITH_BF_FLUID'] = False
264     target_env_defs['WITH_BF_OCEANSIM'] = False
265     target_env_defs['WITH_BF_SMOKE'] = False
266     target_env_defs['WITH_BF_BOOLEAN'] = False
267     target_env_defs['WITH_BF_REMESH'] = False
268     target_env_defs['WITH_BF_PYTHON'] = False
269     target_env_defs['WITH_BF_IME'] = False
270     target_env_defs['WITH_BF_3DMOUSE'] = False
271     target_env_defs['WITH_BF_LIBMV'] = False
272     target_env_defs['WITH_BF_FREESTYLE'] = False
273
274     # Merge blenderlite, let command line to override
275     for k,v in target_env_defs.iteritems():
276         if k not in B.arguments:
277             env[k] = v
278
279 if 'cudakernels' in B.targets:
280     env['WITH_BF_CYCLES'] = True
281     env['WITH_BF_CYCLES_CUDA_BINARIES'] = True
282     env['WITH_BF_PYTHON'] = False
283     env['WITH_BF_LIBMV'] = False
284
285 # Configure paths for automated configuration test programs
286 env['CONFIGUREDIR'] = os.path.abspath(os.path.normpath(os.path.join(env['BF_BUILDDIR'], "sconf_temp")))
287 env['CONFIGURELOG'] = os.path.abspath(os.path.normpath(os.path.join(env['BF_BUILDDIR'], "config.log")))
288
289 #############################################################################
290 ###################    Automatic configuration for OSX     ##################
291 #############################################################################
292
293 if env['OURPLATFORM']=='darwin':
294
295     import commands
296     import subprocess
297
298     command = ["%s"%env['CC'], "--version"]
299     line = btools.get_command_output(command)
300     ver = re.search(r'[0-9]+(\.[0-9]+[svn]+)+', line) or re.search(r'[0-9]+(\.[0-9]+)+', line) # read the "based on LLVM x.xsvn" version here, not the Apple version
301     if ver:
302         env['CCVERSION'] = ver.group(0).strip('svn')
303     frontend = re.search(r'gcc', line) or re.search(r'clang', line) or re.search(r'llvm-gcc', line)  or re.search(r'icc', line)
304     if frontend:
305         env['C_COMPILER_ID'] = frontend.group(0)
306                 
307     vendor = re.search(r'Apple', line)
308     if vendor:
309         C_VENDOR = vendor.group(0)
310     else:
311         C_VENDOR = 'Open Source'
312
313     print B.bc.OKGREEN + "Using Compiler: " + B.bc.ENDC  +  env['C_COMPILER_ID'] + '-' + env['CCVERSION'] + ' ( ' + C_VENDOR + ' )'
314
315     cmd = 'sw_vers -productVersion'
316     MAC_CUR_VER=cmd_res=commands.getoutput(cmd)
317     cmd = 'xcodebuild -version'
318     cmd_xcode=commands.getoutput(cmd)
319     env['XCODE_CUR_VER']=cmd_xcode[6:][:3] # truncate output to major.minor version
320     cmd = 'xcodebuild -showsdks'
321     cmd_sdk=commands.getoutput(cmd)
322     MACOSX_SDK_CHECK=cmd_sdk
323     cmd = 'xcode-select --print-path'
324     XCODE_SELECT_PATH=commands.getoutput(cmd)
325     if XCODE_SELECT_PATH.endswith("/Contents/Developer"):
326         XCODE_BUNDLE=XCODE_SELECT_PATH[:-19]
327     else:
328         XCODE_BUNDLE=XCODE_SELECT_PATH
329
330     print B.bc.OKGREEN + "Detected Xcode version: -- " + B.bc.ENDC + env['XCODE_CUR_VER'] + " --"
331     print B.bc.OKGREEN + "Available SDK's: \n" + B.bc.ENDC + MACOSX_SDK_CHECK.replace('\t', '')
332
333     if env['MACOSX_SDK'] == '': # no set sdk, choosing best one found
334         if 'OS X 10.11' in MACOSX_SDK_CHECK:
335             env['MACOSX_DEPLOYMENT_TARGET'] = '10.6'
336             env['MACOSX_SDK']='/Developer/SDKs/MacOSX10.11.sdk'
337         elif 'OS X 10.10' in MACOSX_SDK_CHECK:
338             env['MACOSX_DEPLOYMENT_TARGET'] = '10.6'
339             env['MACOSX_SDK']='/Developer/SDKs/MacOSX10.10.sdk'
340         elif 'OS X 10.9' in MACOSX_SDK_CHECK:
341             env['MACOSX_DEPLOYMENT_TARGET'] = '10.6'
342             env['MACOSX_SDK']='/Developer/SDKs/MacOSX10.9.sdk'
343         elif 'OS X 10.8' in MACOSX_SDK_CHECK:
344             env['MACOSX_DEPLOYMENT_TARGET'] = '10.6'
345             env['MACOSX_SDK']='/Developer/SDKs/MacOSX10.8.sdk'
346         elif 'OS X 10.7' in MACOSX_SDK_CHECK:
347             env['MACOSX_DEPLOYMENT_TARGET'] = '10.6'
348             env['MACOSX_SDK']='/Developer/SDKs/MacOSX10.7.sdk'
349         elif 'OS X 10.6' in MACOSX_SDK_CHECK:
350             env['MACOSX_DEPLOYMENT_TARGET'] = '10.6'
351             env['MACOSX_SDK']='/Developer/SDKs/MacOSX10.6.sdk'
352         elif 'OS X 10.5' in MACOSX_SDK_CHECK:
353             env['MACOSX_DEPLOYMENT_TARGET'] = '10.5'
354             env['MACOSX_SDK']='/Developer/SDKs/MacOSX10.5.sdk'
355     else:
356         env['MACOSX_SDK']='/Developer/SDKs/MacOSX' + env['MACOSX_SDK'] + '.sdk'
357
358     if env['XCODE_CUR_VER'] >= '4.3':  ## since version 4.3, XCode and developer dir are bundled ##
359          env['MACOSX_SDK'] = XCODE_BUNDLE + '/Contents/Developer/Platforms/MacOSX.platform' +  env['MACOSX_SDK']
360
361     print B.bc.OKGREEN + "Using OSX SDK :" + B.bc.ENDC + env['MACOSX_SDK']
362                 
363     if not env['WITH_OSX_STATICPYTHON'] == 1:
364         # python 3.3 uses Python-framework additionally installed in /Library/Frameworks
365         env['BF_PYTHON'] = '/Library/Frameworks/Python.framework/Versions/'
366         env['BF_PYTHON_INC'] = env['BF_PYTHON'] + env['BF_PYTHON_VERSION'] + '/include/python' + env['BF_PYTHON_VERSION'] + 'm'
367         env['BF_PYTHON_BINARY'] = env['BF_PYTHON'] + env['BF_PYTHON_VERSION'] + '/bin/python' + env['BF_PYTHON_VERSION']
368         env['BF_PYTHON_LIB'] = ''
369         env['BF_PYTHON_LIBPATH'] = env['BF_PYTHON'] + env['BF_PYTHON_VERSION'] + '/lib/python' + env['BF_PYTHON_VERSION'] + '/config-' + env['BF_PYTHON_VERSION'] +'m'
370         env['PLATFORM_LINKFLAGS'] = env['PLATFORM_LINKFLAGS']+['-framework','Python'] # link to python framework
371
372     #Ray trace optimization
373     if env['WITH_BF_RAYOPTIMIZATION'] == 1:
374         if env['MACOSX_ARCHITECTURE'] == 'x86_64' or env['MACOSX_ARCHITECTURE'] == 'i386':
375             env['WITH_BF_RAYOPTIMIZATION'] = 1
376         else:
377             env['WITH_BF_RAYOPTIMIZATION'] = 0
378         if env['MACOSX_ARCHITECTURE'] == 'i386':
379             env['BF_RAYOPTIMIZATION_SSE_FLAGS'] = env['BF_RAYOPTIMIZATION_SSE_FLAGS']+['-msse']
380         elif env['MACOSX_ARCHITECTURE'] == 'x86_64':
381             env['BF_RAYOPTIMIZATION_SSE_FLAGS'] = env['BF_RAYOPTIMIZATION_SSE_FLAGS']+['-msse','-msse2']
382
383     if env['MACOSX_ARCHITECTURE'] == 'x86_64' or env['MACOSX_ARCHITECTURE'] == 'ppc64':
384         ARCH_FLAGS = ['-m64']
385     else:
386         ARCH_FLAGS = ['-m32']
387
388     env.Append(CPPFLAGS=ARCH_FLAGS)
389
390     SDK_FLAGS=['-isysroot',  env['MACOSX_SDK'],'-mmacosx-version-min='+ env['MACOSX_DEPLOYMENT_TARGET'],'-arch',env['MACOSX_ARCHITECTURE']] # always used
391     env['PLATFORM_LINKFLAGS'] = ['-mmacosx-version-min='+ env['MACOSX_DEPLOYMENT_TARGET'],'-isysroot', env['MACOSX_SDK'],'-arch',env['MACOSX_ARCHITECTURE']]+ARCH_FLAGS+env['PLATFORM_LINKFLAGS']
392     env['CCFLAGS']=SDK_FLAGS+env['CCFLAGS']
393     env['CXXFLAGS']=SDK_FLAGS+env['CXXFLAGS']
394
395     #Intel Macs are CoreDuo and Up
396     if env['MACOSX_ARCHITECTURE'] == 'i386' or env['MACOSX_ARCHITECTURE'] == 'x86_64':
397         env['REL_CCFLAGS'] = env['REL_CCFLAGS']+['-msse','-msse2','-msse3']
398         if env['C_COMPILER_ID'] != 'clang' or (env['C_COMPILER_ID'] == 'clang' and env['CCVERSION'] >= '3.3'):
399             env['REL_CCFLAGS'] = env['REL_CCFLAGS']+['-ftree-vectorize'] # clang xcode 4 does not accept flag
400     else:
401         env['CCFLAGS'] =  env['CCFLAGS']+['-fno-strict-aliasing']
402
403     # Intel 64bit Macs are Core2Duo and up
404     if env['MACOSX_ARCHITECTURE'] == 'x86_64':
405         env['REL_CCFLAGS'] = env['REL_CCFLAGS']+['-mssse3']
406
407     if env['C_COMPILER_ID'] == 'clang' and env['CCVERSION'] >= '3.3':
408         env['CCFLAGS'].append('-ftemplate-depth=1024') # only valid for clang bundled with xcode 5
409
410     # 3DconnexionClient.framework, optionally install
411     if env['WITH_BF_3DMOUSE'] == 1:
412         if not os.path.exists('/Library/Frameworks/3DconnexionClient.framework'):
413             env['WITH_BF_3DMOUSE'] = 0
414             print B.bc.OKGREEN + "3DconnexionClient install not found, disabling WITH_BF_3DMOUSE" # avoid build errors !
415         else:
416             env.Append(LINKFLAGS=['-F/Library/Frameworks','-Xlinker','-weak_framework','-Xlinker','3DconnexionClient'])
417             env['BF_3DMOUSE_INC'] = '/Library/Frameworks/3DconnexionClient.framework/Headers'
418             print B.bc.OKGREEN + "Using 3Dconnexion"
419
420     # Jackmp.framework, optionally install
421     if env['WITH_BF_JACK'] == 1:
422         if not os.path.exists('/Library/Frameworks/Jackmp.framework'):
423             env['WITH_BF_JACK'] = 0
424             print B.bc.OKGREEN + "JackOSX install not found, disabling WITH_BF_JACK" # avoid build errors !
425         else:
426             env.Append(LINKFLAGS=['-F/Library/Frameworks','-Xlinker','-weak_framework','-Xlinker','Jackmp'])
427             print B.bc.OKGREEN + "Using Jack"
428
429     if env['WITH_BF_SDL']:
430         env.Append(LINKFLAGS=['-lazy_framework','ForceFeedback'])
431
432     if env['WITH_BF_QUICKTIME'] == 1:
433         env['PLATFORM_LINKFLAGS'] = env['PLATFORM_LINKFLAGS']+['-framework','QTKit']
434
435     #Defaults openMP to true if compiler handles it ( only gcc 4.6.1 and newer )
436     # if your compiler does not have accurate suffix you may have to enable it by hand !
437     if env['WITH_BF_OPENMP'] == 1:
438         if env['C_COMPILER_ID'] == 'gcc' and env['CCVERSION'] >= '4.6.1' or env['C_COMPILER_ID'] == 'clang' and env['CCVERSION'] >= '3.4' and C_VENDOR != 'Apple':
439             env['WITH_BF_OPENMP'] = 1  # multithreading for fluids, cloth, sculpt and smoke
440             print B.bc.OKGREEN + "Using OpenMP"
441             if env['C_COMPILER_ID'] == 'clang' and env['CCVERSION'] >= '3.4':
442                 OSX_OMP_LIBPATH = Dir(env.subst(env['LCGDIR'])).abspath
443                 env.Append(BF_PROGRAM_LINKFLAGS=['-L'+OSX_OMP_LIBPATH+'/openmp/lib','-liomp5'])
444                 env['CCFLAGS'].append('-I'+OSX_OMP_LIBPATH+'/openmp/include') # include for omp.h
445         else:
446             env['WITH_BF_OPENMP'] = 0
447             print B.bc.OKGREEN + "Disabled OpenMP, not supported by compiler"
448
449     if env['WITH_BF_CYCLES_OSL'] == 1:
450         env['WITH_BF_LLVM'] = 1
451         OSX_OSL_LIBPATH = Dir(env.subst(env['BF_OSL_LIBPATH'])).abspath
452         # we need 2 variants of passing the oslexec with the force_load option, string and list type atm
453         if env['C_COMPILER_ID'] == 'gcc' and env['CCVERSION'] >= '4.8' or env['C_COMPILER_ID'] == 'clang' and env['CCVERSION'] >= '3.4':
454             env.Append(LINKFLAGS=['-L'+OSX_OSL_LIBPATH,'-loslcomp','-loslexec','-loslquery'])
455         else:
456             env.Append(LINKFLAGS=['-L'+OSX_OSL_LIBPATH,'-loslcomp','-force_load '+ OSX_OSL_LIBPATH +'/liboslexec.a','-loslquery'])
457         env.Append(BF_PROGRAM_LINKFLAGS=['-Xlinker','-force_load','-Xlinker',OSX_OSL_LIBPATH +'/liboslexec.a'])
458     else:
459         env['WITH_BF_LLVM'] = 0
460
461     if env['WITH_BF_LLVM'] == 0:
462         # Due duplicated generic UTF functions, we pull them either from LLVMSupport or COLLADA
463         env.Append(BF_OPENCOLLADA_LIB=' UTF')
464
465     # Trying to get rid of eventually clashes, we export some symbols explicite as local
466     env.Append(LINKFLAGS=['-Xlinker','-unexported_symbols_list','-Xlinker','./source/creator/osx_locals.map'])
467     
468     #for < 10.7.sdk, SystemStubs needs to be linked
469     if  env['MACOSX_SDK'].endswith("10.6.sdk") or  env['MACOSX_SDK'].endswith("10.5.sdk"):
470         env['LLIBS'].append('SystemStubs')
471
472 #############################################################################
473 ###################  End Automatic configuration for OSX   ##################
474 #############################################################################
475
476 if env['OURPLATFORM'] == 'linux' and not env['C_COMPILER_ID']:
477     command = ["%s"%env['CC'], "--version"]
478     line = btools.get_command_output(command)
479     if line.startswith('gcc'):
480         env['C_COMPILER_ID'] = 'gcc'
481     elif 'clang' in line[0]:
482         env['C_COMPILER_ID'] = 'clang'
483
484 if env['WITH_BF_OPENMP'] == 1:
485         if env['OURPLATFORM'] in ('win32-vc', 'win64-vc'):
486                 env['CCFLAGS'].append('/openmp')
487         else:
488             if env['CC'].endswith('icc'): # to be able to handle CC=/opt/bla/icc case
489                 env.Append(LINKFLAGS=['-openmp', '-static-intel'])
490                 env['CCFLAGS'].append('-openmp')
491             else:
492                 env.Append(CCFLAGS=['-fopenmp'])
493
494 if env['WITH_BF_CPP11']:
495     if env['OURPLATFORM'] in ('win32-vc', 'win64-vc'):
496         # Nothing special is needed, C++11 features are available by default.
497         pass
498     else:
499         env['CXXFLAGS'].append('-std=c++11')
500
501 if env['OURPLATFORM'] in ('win32-vc', 'win64-vc'):
502     # Visual Studio has all standards it supports available by default
503     pass
504 else:
505     # Use C99 + GNU extensions, works with GCC, Clang, ICC
506     env['CFLAGS'].append('-std=gnu99')
507
508 #check for additional debug libnames
509
510 if env.has_key('BF_DEBUG_LIBS'):
511     B.quickdebug += env['BF_DEBUG_LIBS']
512
513 printdebug = B.arguments.get('BF_LISTDEBUG', 0)
514
515 if len(B.quickdebug) > 0 and printdebug != 0:
516     print B.bc.OKGREEN + "Buildings these libs with debug symbols:" + B.bc.ENDC
517     for l in B.quickdebug:
518         print "\t" + l
519
520 # remove stdc++ from LLIBS if we are building a statc linked CXXFLAGS
521 if env['WITH_BF_STATICCXX']:
522     if 'stdc++' in env['LLIBS']:
523         env['LLIBS'].remove('stdc++')
524     else:
525         print '\tcould not remove stdc++ library from LLIBS, WITH_BF_STATICCXX may not work for your platform'
526
527 # audaspace is needed for the game engine
528 if not env['WITH_BF_AUDASPACE']:
529     env['WITH_BF_GAMEENGINE'] = False
530
531 # check target for blenderplayer. Set WITH_BF_PLAYER if found on cmdline
532 if 'blenderplayer' in B.targets:
533     env['WITH_BF_PLAYER'] = True
534
535 if 'blendernogame' in B.targets:
536     env['WITH_BF_GAMEENGINE'] = False
537
538 if not env['WITH_BF_GAMEENGINE']:
539     env['WITH_BF_PLAYER'] = False
540
541 # build without elbeem (fluidsim)?
542 if env['WITH_BF_FLUID'] == 1:
543     env['CPPFLAGS'].append('-DWITH_MOD_FLUID')
544
545 # build with ocean sim?
546 if env['WITH_BF_OCEANSIM'] == 1:
547     env['WITH_BF_FFTW3']  = 1  # ocean needs fftw3 so enable it
548     env['CPPFLAGS'].append('-DWITH_MOD_OCEANSIM')
549
550
551 if btools.ENDIAN == "big":
552     env['CPPFLAGS'].append('-D__BIG_ENDIAN__')
553 else:
554     env['CPPFLAGS'].append('-D__LITTLE_ENDIAN__')
555
556 # TODO, make optional (as with CMake)
557 env['CPPFLAGS'].append('-DWITH_AVI')
558
559 if env['OURPLATFORM'] not in ('win32-vc', 'win64-vc'):
560     env['CPPFLAGS'].append('-DHAVE_STDBOOL_H')
561
562 # Audaspace
563
564 if env['WITH_BF_AUDASPACE']:
565     env['BF_AUDASPACE_C_INC'] = '#intern/audaspace/intern'
566     env['BF_AUDASPACE_PY_INC'] = '#intern/audaspace/intern'
567     env['BF_AUDASPACE_DEF'] = ['WITH_AUDASPACE']
568     env['BF_AUDASPACE_DEF'].append('AUD_DEVICE_H="<AUD_C-API.h>"')
569     env['BF_AUDASPACE_DEF'].append('AUD_SPECIAL_H="<AUD_C-API.h>"')
570     env['BF_AUDASPACE_DEF'].append('AUD_SOUND_H="<AUD_C-API.h>"')
571     env['BF_AUDASPACE_DEF'].append('AUD_HANDLE_H="<AUD_C-API.h>"')
572     env['BF_AUDASPACE_DEF'].append('AUD_SEQUENCE_H="<AUD_C-API.h>"')
573     env['BF_AUDASPACE_DEF'].append('AUD_TYPES_H="<AUD_Space.h>"')
574
575 # OpenGL
576
577 if env['WITH_BF_GL_PROFILE_COMPAT']:
578     env['BF_GL_DEFINITIONS'].append('WITH_GL_PROFILE_COMPAT')
579
580 if env['WITH_BF_GL_PROFILE_CORE']:
581     env['BF_GL_DEFINITIONS'].append('WITH_GL_PROFILE_CORE')
582
583 if env['WITH_BF_GL_PROFILE_ES20']:
584     env['BF_GL_DEFINITIONS'].append('WITH_GL_PROFILE_ES20')
585
586 if env['WITH_BF_GL_EGL']:
587     env['BF_GL_DEFINITIONS'].append('WITH_EGL')
588
589 # GLEW
590
591 if env['WITH_BF_GLEW_MX']:
592     env['BF_GL_DEFINITIONS'].append('WITH_GLEW_MX')
593
594 if env['WITH_BF_GLEW_ES']:
595     env['BF_GLEW_INC'] = '#extern/glew-es/include'
596
597     env['BF_GL_DEFINITIONS'] += ['GLEW_STATIC', 'WITH_GLEW_ES']
598
599     if not env['WITH_BF_GL_PROFILE_ES20']:
600         # No ES functions are needed
601         env['BF_GL_DEFINITIONS'].append('GLEW_NO_ES')
602     elif not (env['WITH_BF_GL_PROFILE_CORE'] or env['WITH_BF_GL_PROFILE_COMPAT']):
603         # ES is enabled, but the other functions are all disabled
604         env['BF_GL_DEFINITIONS'].append('GLEW_ES_ONLY')
605
606     if env['WITH_BF_GL_PROFILE_ES20']:
607         if env['WITH_BF_GL_EGL']:
608             env['BF_GL_DEFINITIONS'].append('GLEW_USE_LIB_ES20')
609
610     if env['WITH_BF_GL_EGL']:
611         env['BF_GL_DEFINITIONS'].append('GLEW_INC_EGL')
612
613 else:
614     env['BF_GLEW_INC'] = '#extern/glew/include'
615
616     env['BF_GL_DEFINITIONS'].append('GLEW_STATIC')
617
618 # lastly we check for root_build_dir ( we should not do before, otherwise we might do wrong builddir
619 B.root_build_dir = env['BF_BUILDDIR']
620 B.doc_build_dir = os.path.join(env['BF_INSTALLDIR'], 'doc')
621 if not B.root_build_dir[-1]==os.sep:
622     B.root_build_dir += os.sep
623 if not B.doc_build_dir[-1]==os.sep:
624     B.doc_build_dir += os.sep
625
626 # We do a shortcut for clean when no quicklist is given: just delete
627 # builddir without reading in SConscripts
628 do_clean = None
629 if 'clean' in B.targets:
630     do_clean = True
631
632 if not quickie and do_clean:
633     if os.path.exists(B.doc_build_dir):
634         print B.bc.HEADER+'Cleaning doc dir...'+B.bc.ENDC
635         dirs = os.listdir(B.doc_build_dir)
636         for entry in dirs:
637             if os.path.isdir(B.doc_build_dir + entry) == 1:
638                 print "clean dir %s"%(B.doc_build_dir+entry)
639                 shutil.rmtree(B.doc_build_dir+entry)
640             else: # remove file
641                 print "remove file %s"%(B.doc_build_dir+entry)
642                 os.remove(B.root_build_dir+entry)
643     if os.path.exists(B.root_build_dir):
644         print B.bc.HEADER+'Cleaning build dir...'+B.bc.ENDC
645         dirs = os.listdir(B.root_build_dir)
646         for entry in dirs:
647             if os.path.isdir(B.root_build_dir + entry) == 1:
648                 print "clean dir %s"%(B.root_build_dir+entry)
649                 shutil.rmtree(B.root_build_dir+entry)
650             else: # remove file
651                 print "remove file %s"%(B.root_build_dir+entry)
652                 os.remove(B.root_build_dir+entry)
653         for confile in ['extern/ffmpeg/config.mak', 'extern/x264/config.mak',
654                 'extern/xvidcore/build/generic/platform.inc', 'extern/ffmpeg/include']:
655             if os.path.exists(confile):
656                 print "clean file %s"%confile
657                 if os.path.isdir(confile):
658                     for root, dirs, files in os.walk(confile):
659                         for name in files:
660                             os.remove(os.path.join(root, name))
661                 else:
662                     os.remove(confile)
663         print B.bc.OKGREEN+'...done'+B.bc.ENDC
664     else:
665         print B.bc.HEADER+'Already Clean, nothing to do.'+B.bc.ENDC
666     Exit()
667
668
669 # ensure python header is found since detection can fail, this could happen
670 # with _any_ library but since we used a fixed python version this tends to
671 # be most problematic.
672 if env['WITH_BF_PYTHON']:
673     found_python_h = found_pyconfig_h = False
674     for bf_python_inc in env.subst('${BF_PYTHON_INC}').split():
675         py_h = os.path.join(Dir(bf_python_inc).abspath, "Python.h")
676         if os.path.exists(py_h):
677             found_python_h = True
678         py_h = os.path.join(Dir(bf_python_inc).abspath, "pyconfig.h")
679         if os.path.exists(py_h):
680             found_pyconfig_h = True
681
682     if not (found_python_h and found_pyconfig_h):
683         print("""\nMissing: Python.h and/or pyconfig.h in "%s"
684          Set 'BF_PYTHON_INC' to point to valid include path(s),
685          containing Python.h and pyconfig.h for Python version "%s".
686
687          Example: python scons/scons.py BF_PYTHON_INC=../Python/include
688               """ % (env.subst('${BF_PYTHON_INC}'), env.subst('${BF_PYTHON_VERSION}')))
689         Exit()
690
691
692 if not os.path.isdir ( B.root_build_dir):
693     os.makedirs ( B.root_build_dir )
694     os.makedirs ( B.root_build_dir + 'source' )
695     os.makedirs ( B.root_build_dir + 'intern' )
696     os.makedirs ( B.root_build_dir + 'extern' )
697     os.makedirs ( B.root_build_dir + 'lib' )
698     os.makedirs ( B.root_build_dir + 'bin' )
699 # # Docs not working with epy anymore
700 # if not os.path.isdir(B.doc_build_dir) and env['WITH_BF_DOCS']:
701 #     os.makedirs ( B.doc_build_dir )
702
703
704 ###################################
705 # Ensure all data files are valid #
706 ###################################
707 if not os.path.isdir ( B.root_build_dir + 'data_headers'):
708     os.makedirs ( B.root_build_dir + 'data_headers' )
709 if not os.path.isdir ( B.root_build_dir + 'data_sources'):
710     os.makedirs ( B.root_build_dir + 'data_sources' )
711 # use for includes
712 env['DATA_HEADERS'] = os.path.join(os.path.abspath(env['BF_BUILDDIR']), "data_headers")
713 env['DATA_SOURCES'] = os.path.join(os.path.abspath(env['BF_BUILDDIR']), "data_sources")
714 def data_to_c(FILE_FROM, FILE_TO, VAR_NAME):
715     if os.sep == "\\":
716         FILE_FROM = FILE_FROM.replace("/", "\\")
717         FILE_TO   = FILE_TO.replace("/", "\\")
718
719     try:
720         # first check if we need to bother.
721         if os.path.exists(FILE_TO):
722             if os.path.getmtime(FILE_FROM) < os.path.getmtime(FILE_TO):
723                 return
724
725         print(B.bc.HEADER + "Generating: " + B.bc.ENDC + "%r" % os.path.basename(FILE_TO))
726         fpin = open(FILE_FROM, "rb")
727         fpin.seek(0, os.SEEK_END)
728         size = fpin.tell()
729         fpin.seek(0)
730
731         fpout = open(FILE_TO, "w")
732         fpout.write("int  %s_size = %d;\n" % (VAR_NAME, size))
733         fpout.write("char %s[] = {\n" % VAR_NAME)
734
735         while size > 0:
736             size -= 1
737             if size % 32 == 31:
738                 fpout.write("\n")
739
740             fpout.write("%3d," % ord(fpin.read(1)))
741         fpout.write("\n  0};\n\n")
742
743         fpin.close()
744         fpout.close()
745     except KeyboardInterrupt:
746         if os.path.exists(FILE_TO):
747             os.remove(FILE_TO)
748         raise KeyboardInterrupt
749
750 def data_to_c_simple(FILE_FROM):
751         filename_only = os.path.basename(FILE_FROM)
752         FILE_TO = os.path.join(env['DATA_SOURCES'], filename_only + ".c")
753         VAR_NAME = "datatoc_" + filename_only.replace(".", "_")
754
755         data_to_c(FILE_FROM, FILE_TO, VAR_NAME)
756
757
758 def data_to_c_simple_icon(PATH_FROM):
759
760     # first handle import
761     import sys
762     path = "source/blender/datatoc"
763     if path not in sys.path:
764         sys.path.append(path)
765
766     # convert the pixmaps to a png
767     import datatoc_icon
768
769     filename_only = os.path.basename(PATH_FROM)
770     FILE_TO_PNG = os.path.join(env['DATA_SOURCES'], filename_only + ".png")
771     FILE_TO = FILE_TO_PNG + ".c"
772     argv = [PATH_FROM, FILE_TO_PNG]
773     try:
774         datatoc_icon.main_ex(argv)
775     except KeyboardInterrupt:
776         if os.path.exists(FILE_TO_PNG):
777             os.remove(FILE_TO_PNG)
778         raise KeyboardInterrupt
779
780     # then the png to a c file
781     data_to_c_simple(FILE_TO_PNG)
782
783
784 if B.targets != ['cudakernels']:
785     data_to_c("source/blender/compositor/operations/COM_OpenCLKernels.cl",
786               B.root_build_dir + "data_headers/COM_OpenCLKernels.cl.h",
787               "datatoc_COM_OpenCLKernels_cl")
788
789     data_to_c_simple("release/datafiles/startup.blend")
790     data_to_c_simple("release/datafiles/preview.blend")
791     data_to_c_simple("release/datafiles/preview_cycles.blend")
792
793     # --- glsl ---
794     data_to_c_simple("source/blender/gpu/shaders/gpu_shader_geometry.glsl")
795
796     data_to_c_simple("source/blender/gpu/shaders/gpu_program_smoke_frag.glsl")
797     data_to_c_simple("source/blender/gpu/shaders/gpu_program_smoke_color_frag.glsl")
798
799     data_to_c_simple("source/blender/gpu/shaders/gpu_shader_basic_frag.glsl")
800     data_to_c_simple("source/blender/gpu/shaders/gpu_shader_basic_vert.glsl")
801     data_to_c_simple("source/blender/gpu/shaders/gpu_shader_material.glsl")
802     data_to_c_simple("source/blender/gpu/shaders/gpu_shader_material.glsl")
803     data_to_c_simple("source/blender/gpu/shaders/gpu_shader_sep_gaussian_blur_frag.glsl")
804     data_to_c_simple("source/blender/gpu/shaders/gpu_shader_sep_gaussian_blur_vert.glsl")
805     data_to_c_simple("source/blender/gpu/shaders/gpu_shader_vertex.glsl")
806     data_to_c_simple("source/blender/gpu/shaders/gpu_shader_vertex_world.glsl")
807     data_to_c_simple("source/blender/gpu/shaders/gpu_shader_vsm_store_frag.glsl")
808     data_to_c_simple("source/blender/gpu/shaders/gpu_shader_vsm_store_vert.glsl")
809     data_to_c_simple("source/blender/gpu/shaders/gpu_shader_fx_ssao_frag.glsl")
810     data_to_c_simple("source/blender/gpu/shaders/gpu_shader_fx_dof_frag.glsl")
811     data_to_c_simple("source/blender/gpu/shaders/gpu_shader_fx_dof_vert.glsl")
812     data_to_c_simple("source/blender/gpu/shaders/gpu_shader_fx_dof_hq_frag.glsl")
813     data_to_c_simple("source/blender/gpu/shaders/gpu_shader_fx_dof_hq_vert.glsl")
814     data_to_c_simple("source/blender/gpu/shaders/gpu_shader_fx_dof_hq_geo.glsl")
815     data_to_c_simple("source/blender/gpu/shaders/gpu_shader_fx_lib.glsl")
816     data_to_c_simple("source/blender/gpu/shaders/gpu_shader_fx_depth_resolve.glsl")
817     data_to_c_simple("source/blender/gpu/shaders/gpu_shader_fx_vert.glsl")
818     data_to_c_simple("intern/opencolorio/gpu_shader_display_transform.glsl")
819     data_to_c_simple("intern/opensubdiv/gpu_shader_opensubd_display.glsl")
820
821     # --- blender ---
822     data_to_c_simple("release/datafiles/bfont.pfb")
823     data_to_c_simple("release/datafiles/bfont.ttf")
824     data_to_c_simple("release/datafiles/bmonofont.ttf")
825
826     data_to_c_simple("release/datafiles/splash.png")
827     data_to_c_simple("release/datafiles/splash_2x.png")
828
829     # data_to_c_simple("release/datafiles/blender_icons16.png")
830     # data_to_c_simple("release/datafiles/blender_icons32.png")
831     data_to_c_simple_icon("release/datafiles/blender_icons16")
832     data_to_c_simple_icon("release/datafiles/blender_icons32")
833
834     data_to_c_simple("release/datafiles/prvicons.png")
835
836     data_to_c_simple("release/datafiles/brushicons/add.png")
837     data_to_c_simple("release/datafiles/brushicons/blob.png")
838     data_to_c_simple("release/datafiles/brushicons/blur.png")
839     data_to_c_simple("release/datafiles/brushicons/clay.png")
840     data_to_c_simple("release/datafiles/brushicons/claystrips.png")
841     data_to_c_simple("release/datafiles/brushicons/clone.png")
842     data_to_c_simple("release/datafiles/brushicons/crease.png")
843     data_to_c_simple("release/datafiles/brushicons/darken.png")
844     data_to_c_simple("release/datafiles/brushicons/draw.png")
845     data_to_c_simple("release/datafiles/brushicons/fill.png")
846     data_to_c_simple("release/datafiles/brushicons/flatten.png")
847     data_to_c_simple("release/datafiles/brushicons/grab.png")
848     data_to_c_simple("release/datafiles/brushicons/inflate.png")
849     data_to_c_simple("release/datafiles/brushicons/layer.png")
850     data_to_c_simple("release/datafiles/brushicons/lighten.png")
851     data_to_c_simple("release/datafiles/brushicons/mask.png")
852     data_to_c_simple("release/datafiles/brushicons/mix.png")
853     data_to_c_simple("release/datafiles/brushicons/multiply.png")
854     data_to_c_simple("release/datafiles/brushicons/nudge.png")
855     data_to_c_simple("release/datafiles/brushicons/pinch.png")
856     data_to_c_simple("release/datafiles/brushicons/scrape.png")
857     data_to_c_simple("release/datafiles/brushicons/smear.png")
858     data_to_c_simple("release/datafiles/brushicons/smooth.png")
859     data_to_c_simple("release/datafiles/brushicons/snake_hook.png")
860     data_to_c_simple("release/datafiles/brushicons/soften.png")
861     data_to_c_simple("release/datafiles/brushicons/subtract.png")
862     data_to_c_simple("release/datafiles/brushicons/texdraw.png")
863     data_to_c_simple("release/datafiles/brushicons/texfill.png")
864     data_to_c_simple("release/datafiles/brushicons/texmask.png")
865     data_to_c_simple("release/datafiles/brushicons/thumb.png")
866     data_to_c_simple("release/datafiles/brushicons/twist.png")
867     data_to_c_simple("release/datafiles/brushicons/vertexdraw.png")
868
869     data_to_c_simple("release/datafiles/matcaps/mc01.jpg")
870     data_to_c_simple("release/datafiles/matcaps/mc02.jpg")
871     data_to_c_simple("release/datafiles/matcaps/mc03.jpg")
872     data_to_c_simple("release/datafiles/matcaps/mc04.jpg")
873     data_to_c_simple("release/datafiles/matcaps/mc05.jpg")
874     data_to_c_simple("release/datafiles/matcaps/mc06.jpg")
875     data_to_c_simple("release/datafiles/matcaps/mc07.jpg")
876     data_to_c_simple("release/datafiles/matcaps/mc08.jpg")
877     data_to_c_simple("release/datafiles/matcaps/mc09.jpg")
878     data_to_c_simple("release/datafiles/matcaps/mc10.jpg")
879     data_to_c_simple("release/datafiles/matcaps/mc11.jpg")
880     data_to_c_simple("release/datafiles/matcaps/mc12.jpg")
881     data_to_c_simple("release/datafiles/matcaps/mc13.jpg")
882     data_to_c_simple("release/datafiles/matcaps/mc14.jpg")
883     data_to_c_simple("release/datafiles/matcaps/mc15.jpg")
884     data_to_c_simple("release/datafiles/matcaps/mc16.jpg")
885     data_to_c_simple("release/datafiles/matcaps/mc17.jpg")
886     data_to_c_simple("release/datafiles/matcaps/mc18.jpg")
887     data_to_c_simple("release/datafiles/matcaps/mc19.jpg")
888     data_to_c_simple("release/datafiles/matcaps/mc20.jpg")
889     data_to_c_simple("release/datafiles/matcaps/mc21.jpg")
890     data_to_c_simple("release/datafiles/matcaps/mc22.jpg")
891     data_to_c_simple("release/datafiles/matcaps/mc23.jpg")
892     data_to_c_simple("release/datafiles/matcaps/mc24.jpg")
893
894 ##### END DATAFILES ##########
895
896 Help(opts.GenerateHelpText(env))
897
898 # default is new quieter output, but if you need to see the
899 # commands, do 'scons BF_QUIET=0'
900 bf_quietoutput = B.arguments.get('BF_QUIET', '1')
901 if env['BF_QUIET']:
902     B.set_quiet_output(env)
903 else:
904     if toolset=='msvc':
905         B.msvc_hack(env)
906
907 print B.bc.HEADER+'Building in: ' + B.bc.ENDC + os.path.abspath(B.root_build_dir)
908 env.SConsignFile(B.root_build_dir+'scons-signatures')
909 B.init_lib_dict()
910
911 ##### END SETUP ##########
912
913 ## Auto-configuration run-time tests
914
915 from FindSharedPtr import FindSharedPtr
916 from FindUnorderedMap import FindUnorderedMap
917
918 conf = Configure(env)
919 old_linkflags = conf.env['LINKFLAGS']
920 conf.env.Append(LINKFLAGS=env['PLATFORM_LINKFLAGS'])
921
922 # Put all tests here
923 FindSharedPtr(conf)
924 FindUnorderedMap(conf)
925
926 conf.env['LINKFLAGS'] = old_linkflags
927 env = conf.Finish()
928
929 # End of auto configuration
930
931 Export('env')
932
933 VariantDir(B.root_build_dir+'/source', 'source', duplicate=0)
934 SConscript(B.root_build_dir+'/source/SConscript')
935 VariantDir(B.root_build_dir+'/intern', 'intern', duplicate=0)
936 SConscript(B.root_build_dir+'/intern/SConscript')
937 VariantDir(B.root_build_dir+'/extern', 'extern', duplicate=0)
938 SConscript(B.root_build_dir+'/extern/SConscript')
939
940 # now that we have read all SConscripts, we know what
941 # libraries will be built. Create list of
942 # libraries to give as objects to linking phase
943 mainlist = []
944 for tp in B.possible_types:
945     if (not tp == 'player') and (not tp == 'player2') and (not tp == 'system'):
946         mainlist += B.create_blender_liblist(env, tp)
947
948 if B.arguments.get('BF_PRIORITYLIST', '0')=='1':
949     B.propose_priorities()
950
951 dobj = B.buildinfo(env, "dynamic") + B.resources
952 creob = B.creator(env)
953 thestatlibs, thelibincs = B.setup_staticlibs(env)
954 thesyslibs = B.setup_syslibs(env)
955
956 if 'blender' in B.targets or not env['WITH_BF_NOBLENDER']:
957     blender_progname = "blender"
958     if env['OURPLATFORM'] in ('win32-vc', 'win32-mingw', 'win64-vc', 'linuxcross'):
959         blender_progname = "blender-app"
960
961         lenv = env.Clone()
962         lenv.Append(LINKFLAGS = env['PLATFORM_LINKFLAGS'])
963         targetpath = B.root_build_dir + '/blender'
964         launcher_obj = [env.Object(B.root_build_dir + 'source/creator/creator/creator_launch_win', ['#source/creator/creator_launch_win.c'])]
965         env.BlenderProg(B.root_build_dir, 'blender', [launcher_obj] + B.resources, ['bf_utfconv'] + thesyslibs, [B.root_build_dir+'/lib'] + thelibincs, 'blender')
966
967     env.BlenderProg(B.root_build_dir, blender_progname, creob + mainlist + thestatlibs + dobj, thesyslibs, [B.root_build_dir+'/lib'] + thelibincs, 'blender')
968 if env['WITH_BF_PLAYER']:
969     playerlist = B.create_blender_liblist(env, 'player')
970     playerlist += B.create_blender_liblist(env, 'player2')
971     playerlist += B.create_blender_liblist(env, 'intern')
972     playerlist += B.create_blender_liblist(env, 'extern')
973     env.BlenderProg(B.root_build_dir, "blenderplayer", dobj + playerlist + thestatlibs, thesyslibs, [B.root_build_dir+'/lib'] + thelibincs, 'blenderplayer')
974
975 ##### Now define some targets
976
977
978 #------------ INSTALL
979
980 #-- binaries
981 blenderinstall = []
982 if  env['OURPLATFORM']=='darwin':
983     for prg in B.program_list:
984         bundle = '%s.app' % prg[0]
985         bundledir = os.path.dirname(bundle)
986         for dp, dn, df in os.walk(bundle):
987             if '.svn' in dn:
988                 dn.remove('.svn')
989             if '_svn' in dn:
990                 dn.remove('_svn')
991             if '.git' in df:
992                 df.remove('.git')
993             dir=env['BF_INSTALLDIR']+dp[len(bundledir):]
994             source=[dp+os.sep+f for f in df]
995             blenderinstall.append(env.Install(dir=dir,source=source))
996 else:
997     blenderinstall = env.Install(dir=env['BF_INSTALLDIR'], source=B.program_list)
998
999 #-- local path = config files in install dir: installdir\VERSION
1000 #- dont do config and scripts for darwin, it is already in the bundle
1001 dotblendlist = []
1002 datafileslist = []
1003 datafilestargetlist = []
1004 dottargetlist = []
1005 scriptinstall = []
1006 cubininstall = []
1007
1008 if env['OURPLATFORM']!='darwin':
1009     dotblenderinstall = []
1010     for targetdir,srcfile in zip(dottargetlist, dotblendlist):
1011         td, tf = os.path.split(targetdir)
1012         dotblenderinstall.append(env.Install(dir=td, source=srcfile))
1013     for targetdir,srcfile in zip(datafilestargetlist, datafileslist):
1014         td, tf = os.path.split(targetdir)
1015         dotblenderinstall.append(env.Install(dir=td, source=srcfile))
1016
1017     if env['OURPLATFORM'] in ('win32-vc', 'win32-mingw', 'win64-vc', 'linuxcross'):
1018         scriptinstall.append(env.InstallAs(env['BF_INSTALLDIR'] + '/blender-app.exe.manifest',
1019                                            'source/icons/blender.exe.manifest'))
1020
1021     if env['WITH_BF_PYTHON']:
1022         #-- local/VERSION/scripts
1023         scriptpaths=['release/scripts']
1024         for scriptpath in scriptpaths:
1025             for dp, dn, df in os.walk(scriptpath):
1026                 if '.git' in df:
1027                     df.remove('.git')
1028                 if '__pycache__' in dn:  # py3.2 cache dir
1029                     dn.remove('__pycache__')
1030
1031                 # only for testing builds
1032                 if VERSION_RELEASE_CYCLE == "release" and "addons_contrib" in dn:
1033                     dn.remove('addons_contrib')
1034
1035                 # do not install freestyle if disabled
1036                 if not env['WITH_BF_FREESTYLE'] and "freestyle" in dn:
1037                     dn.remove("freestyle")
1038
1039                 dir = os.path.join(env['BF_INSTALLDIR'], VERSION)
1040                 dir += os.sep + os.path.basename(scriptpath) + dp[len(scriptpath):]
1041
1042                 source=[os.path.join(dp, f) for f in df if not f.endswith(".pyc")]
1043                 # To ensure empty dirs are created too
1044                 if len(source)==0 and not os.path.exists(dir):
1045                     env.Execute(Mkdir(dir))
1046                 scriptinstall.append(env.Install(dir=dir,source=source))
1047         if env['WITH_BF_CYCLES']:
1048             # cycles python code
1049             dir=os.path.join(env['BF_INSTALLDIR'], VERSION, 'scripts', 'addons','cycles')
1050             source=os.listdir('intern/cycles/blender/addon')
1051             if '__pycache__' in source: source.remove('__pycache__')
1052             source=['intern/cycles/blender/addon/'+s for s in source]
1053             scriptinstall.append(env.Install(dir=dir,source=source))
1054
1055             # cycles kernel code
1056             dir=os.path.join(env['BF_INSTALLDIR'], VERSION, 'scripts', 'addons','cycles', 'kernel')
1057             source=os.listdir('intern/cycles/kernel')
1058             if '__pycache__' in source: source.remove('__pycache__')
1059             source.remove('CMakeLists.txt')
1060             source.remove('SConscript')
1061             source.remove('svm')
1062             source.remove('closure')
1063             source.remove('geom')
1064             source.remove('shaders')
1065             source.remove('osl')
1066             source.remove('split')
1067             source=['intern/cycles/kernel/'+s for s in source]
1068             source.append('intern/cycles/util/util_atomic.h')
1069             source.append('intern/cycles/util/util_color.h')
1070             source.append('intern/cycles/util/util_half.h')
1071             source.append('intern/cycles/util/util_math.h')
1072             source.append('intern/cycles/util/util_math_fast.h')
1073             source.append('intern/cycles/util/util_transform.h')
1074             source.append('intern/cycles/util/util_types.h')
1075             scriptinstall.append(env.Install(dir=dir,source=source))
1076             # svm
1077             dir=os.path.join(env['BF_INSTALLDIR'], VERSION, 'scripts', 'addons','cycles', 'kernel', 'svm')
1078             source=os.listdir('intern/cycles/kernel/svm')
1079             if '__pycache__' in source: source.remove('__pycache__')
1080             source=['intern/cycles/kernel/svm/'+s for s in source]
1081             scriptinstall.append(env.Install(dir=dir,source=source))
1082             # closure
1083             dir=os.path.join(env['BF_INSTALLDIR'], VERSION, 'scripts', 'addons','cycles', 'kernel', 'closure')
1084             source=os.listdir('intern/cycles/kernel/closure')
1085             if '__pycache__' in source: source.remove('__pycache__')
1086             source=['intern/cycles/kernel/closure/'+s for s in source]
1087             scriptinstall.append(env.Install(dir=dir,source=source))
1088             # geom
1089             dir=os.path.join(env['BF_INSTALLDIR'], VERSION, 'scripts', 'addons','cycles', 'kernel', 'geom')
1090             source=os.listdir('intern/cycles/kernel/geom')
1091             if '__pycache__' in source: source.remove('__pycache__')
1092             source=['intern/cycles/kernel/geom/'+s for s in source]
1093             scriptinstall.append(env.Install(dir=dir,source=source))
1094             # split
1095             dir=os.path.join(env['BF_INSTALLDIR'], VERSION, 'scripts', 'addons','cycles', 'kernel', 'split')
1096             source=os.listdir('intern/cycles/kernel/split')
1097             if '__pycache__' in source: source.remove('__pycache__')
1098             source=['intern/cycles/kernel/split/'+s for s in source]
1099             scriptinstall.append(env.Install(dir=dir,source=source))
1100
1101             # licenses
1102             dir=os.path.join(env['BF_INSTALLDIR'], VERSION, 'scripts', 'addons','cycles', 'license')
1103             source=os.listdir('intern/cycles/doc/license')
1104             if '__pycache__' in source: source.remove('__pycache__')
1105             source.remove('CMakeLists.txt')
1106             source=['intern/cycles/doc/license/'+s for s in source]
1107             scriptinstall.append(env.Install(dir=dir,source=source))
1108
1109     if env['WITH_BF_CYCLES']:
1110         # cuda binaries
1111         if env['WITH_BF_CYCLES_CUDA_BINARIES']:
1112             dir=os.path.join(env['BF_INSTALLDIR'], VERSION, 'scripts', 'addons','cycles', 'lib')
1113             for arch in env['BF_CYCLES_CUDA_BINARIES_ARCH']:
1114                 kernel_build_dir = os.path.join(B.root_build_dir, 'intern/cycles/kernel')
1115                 for suffix in ('', '_experimental'):
1116                     cubin_file = os.path.join(kernel_build_dir, "kernel%s_%s.cubin" % (suffix, arch))
1117                     cubininstall.append(env.Install(dir=dir,source=cubin_file))
1118
1119         # osl shaders
1120         if env['WITH_BF_CYCLES_OSL']:
1121             dir=os.path.join(env['BF_INSTALLDIR'], VERSION, 'scripts', 'addons','cycles', 'shader')
1122
1123             osl_source_dir = Dir('./intern/cycles/kernel/shaders').srcnode().path
1124             oso_build_dir = os.path.join(B.root_build_dir, 'intern/cycles/kernel/shaders')
1125
1126             headers='node_color.h node_fresnel.h node_texture.h oslutil.h stdosl.h'.split()
1127             source=['intern/cycles/kernel/shaders/'+s for s in headers]
1128             scriptinstall.append(env.Install(dir=dir,source=source))
1129
1130             for f in os.listdir(osl_source_dir):
1131                 if f.endswith('.osl'):
1132                     oso_file = os.path.join(oso_build_dir, f.replace('.osl', '.oso'))
1133                     scriptinstall.append(env.Install(dir=dir,source=oso_file))
1134
1135     if env['WITH_BF_OCIO']:
1136         colormanagement = os.path.join('release', 'datafiles', 'colormanagement')
1137
1138         for dp, dn, df in os.walk(colormanagement):
1139             dir = os.path.join(env['BF_INSTALLDIR'], VERSION, 'datafiles')
1140             dir += os.sep + os.path.basename(colormanagement) + dp[len(colormanagement):]
1141
1142             source = [os.path.join(dp, f) for f in df if not f.endswith(".pyc")]
1143
1144             # To ensure empty dirs are created too
1145             if len(source) == 0:
1146                 env.Execute(Mkdir(dir))
1147
1148             scriptinstall.append(env.Install(dir=dir,source=source))
1149
1150     if env['WITH_BF_INTERNATIONAL']:
1151         internationalpaths=['release' + os.sep + 'datafiles']
1152
1153         def check_path(path, member):
1154             return (member in path.split(os.sep))
1155
1156         po_dir = os.path.join("release", "datafiles", "locale", "po")
1157
1158         # font files
1159         for intpath in internationalpaths:
1160             for dp, dn, df in os.walk(intpath):
1161                 if '.git' in df:
1162                     df.remove('.git')
1163
1164                 # we only care about release/datafiles/fonts, release/datafiles/locales
1165                 if check_path(dp, "fonts"):
1166                     pass
1167                 else:
1168                     continue
1169
1170                 dir = os.path.join(env['BF_INSTALLDIR'], VERSION)
1171                 dir += os.sep + os.path.basename(intpath) + dp[len(intpath):]
1172
1173                 source=[os.path.join(dp, f) for f in df if not f.endswith(".pyc")]
1174                 # To ensure empty dirs are created too
1175                 if len(source)==0:
1176                     env.Execute(Mkdir(dir))
1177                 scriptinstall.append(env.Install(dir=dir,source=source))
1178
1179         # .mo files
1180         for f in os.listdir(po_dir):
1181             if not f.endswith(".po"):
1182                 continue
1183
1184             locale_name = os.path.splitext(f)[0]
1185
1186             mo_file = os.path.join(B.root_build_dir, "locale", locale_name + ".mo")
1187
1188             dir = os.path.join(env['BF_INSTALLDIR'], VERSION)
1189             dir = os.path.join(dir, "datafiles", "locale", locale_name, "LC_MESSAGES")
1190             scriptinstall.append(env.InstallAs(os.path.join(dir, "blender.mo"), mo_file))
1191
1192         # languages file
1193         dir = os.path.join(env['BF_INSTALLDIR'], VERSION)
1194         dir = os.path.join(dir, "datafiles", "locale")
1195         languages_file = os.path.join("release", "datafiles", "locale", "languages")
1196         scriptinstall.append(env.InstallAs(os.path.join(dir, "languages"), languages_file))
1197
1198 #-- icons
1199 if env['OURPLATFORM']=='linux':
1200     iconlist = []
1201     icontargetlist = []
1202
1203     for tp, tn, tf in os.walk('release/freedesktop/icons'):
1204         for f in tf:
1205             iconlist.append(os.path.join(tp, f))
1206             icontargetlist.append( os.path.join(*([env['BF_INSTALLDIR']] + tp.split(os.sep)[2:] + [f])) )
1207
1208     iconinstall = []
1209     for targetdir,srcfile in zip(icontargetlist, iconlist):
1210         td, tf = os.path.split(targetdir)
1211         iconinstall.append(env.Install(dir=td, source=srcfile))
1212
1213     scriptinstall.append(env.Install(dir=env['BF_INSTALLDIR'], source='release/bin/blender-thumbnailer.py'))
1214
1215 # dlls for linuxcross
1216 # TODO - add more libs, for now this lets blenderlite run
1217 if env['OURPLATFORM']=='linuxcross':
1218     dir=env['BF_INSTALLDIR']
1219     source = []
1220
1221     if env['WITH_BF_OPENMP']:
1222         source += ['../lib/windows/pthreads/lib/pthreadGC2.dll']
1223
1224     scriptinstall.append(env.Install(dir=dir, source=source))
1225
1226 textlist = []
1227 texttargetlist = []
1228 for tp, tn, tf in os.walk('release/text'):
1229     tf.remove("readme.html")
1230     for f in tf:
1231         textlist.append(tp+os.sep+f)
1232
1233 def readme_version_patch():
1234     readme_src = "release/text/readme.html"
1235     readme_dst = os.path.abspath(os.path.normpath(os.path.join(env['BF_BUILDDIR'], "readme.html")))
1236
1237     if not os.path.exists(readme_dst) or (os.path.getmtime(readme_dst) < os.path.getmtime(readme_src)):
1238         f = open(readme_src, "r")
1239         data = f.read()
1240         f.close()
1241
1242         data = data.replace("BLENDER_VERSION", VERSION)
1243         f = open(readme_dst, "w")
1244         f.write(data)
1245         f.close()
1246
1247     textlist.append(readme_dst)
1248
1249 readme_version_patch()
1250 del readme_version_patch
1251
1252
1253 '''Command(
1254     "release/text/readme.html"
1255
1256     )
1257 Command("file.out", "file.in", Copy(env['BF_INSTALLDIR'], "release/text/readme.html"))
1258 '''
1259
1260 # Font licenses
1261 textlist.append('release/datafiles/LICENSE-bfont.ttf.txt')
1262 if env['WITH_BF_INTERNATIONAL']:
1263     textlist += ['release/datafiles/LICENSE-droidsans.ttf.txt', 'release/datafiles/LICENSE-bmonofont-i18n.ttf.txt']
1264
1265 textinstall = env.Install(dir=env['BF_INSTALLDIR'], source=textlist)
1266
1267 if  env['OURPLATFORM']=='darwin':
1268         allinstall = [blenderinstall, textinstall]
1269 elif env['OURPLATFORM']=='linux':
1270         allinstall = [blenderinstall, dotblenderinstall, scriptinstall, textinstall, iconinstall, cubininstall]
1271 else:
1272         allinstall = [blenderinstall, dotblenderinstall, scriptinstall, textinstall, cubininstall]
1273
1274 if env['OURPLATFORM'] in ('win32-vc', 'win32-mingw', 'win64-vc', 'linuxcross'):
1275     dllsources = []
1276
1277     # Used when linking to libtiff was dynamic
1278     # keep it here until compilation on all platform would be ok
1279     # dllsources += ['${BF_TIFF_LIBPATH}/${BF_TIFF_LIB}.dll']
1280
1281     if env['OURPLATFORM'] != 'linuxcross':
1282         # pthreads library is already added
1283         dllsources += ['${BF_PTHREADS_LIBPATH}/${BF_PTHREADS_LIB}.dll']
1284
1285     if env['WITH_BF_SDL']:
1286         dllsources.append('${BF_SDL_LIBPATH}/SDL2.dll')
1287
1288     if env['WITH_BF_PYTHON']:
1289         if env['BF_DEBUG']:
1290             dllsources.append('${BF_PYTHON_LIBPATH}/${BF_PYTHON_DLL}_d.dll')
1291             dllsources.append('${BF_PYTHON_LIBPATH}/sqlite3_d.dll')
1292         else:
1293             dllsources.append('${BF_PYTHON_LIBPATH}/${BF_PYTHON_DLL}.dll')
1294             dllsources.append('${BF_PYTHON_LIBPATH}/sqlite3.dll')
1295
1296     if env['WITH_BF_ICONV']:
1297         if env['OURPLATFORM'] == 'win64-vc':
1298             pass # we link statically to iconv on win64
1299         elif not env['OURPLATFORM'] in ('win32-mingw', 'linuxcross'):
1300             #gettext for MinGW and cross-compilation is compiled staticly
1301             dllsources += ['${BF_ICONV_LIBPATH}/iconv.dll']
1302
1303     if env['WITH_BF_OPENAL']:
1304         dllsources.append('${LCGDIR}/openal/lib/OpenAL32.dll')
1305
1306     if env['WITH_BF_SNDFILE']:
1307         dllsources.append('${LCGDIR}/sndfile/lib/libsndfile-1.dll')
1308
1309     if env['WITH_BF_FFMPEG']:
1310         dllsources += env['BF_FFMPEG_DLL'].split()
1311
1312     # Since the thumb handler is loaded by Explorer, architecture is
1313     # strict: the x86 build fails on x64 Windows. We need to ship
1314     # both builds in x86 packages.
1315     if B.bitness == 32:
1316         dllsources.append('${LCGDIR}/thumbhandler/lib/BlendThumb.dll')
1317     dllsources.append('${LCGDIR}/thumbhandler/lib/BlendThumb64.dll')
1318
1319     if env['WITH_BF_OCIO']:
1320         if not env['OURPLATFORM'] in ('win32-mingw', 'linuxcross'):
1321             dllsources.append('${LCGDIR}/opencolorio/bin/OpenColorIO.dll')
1322
1323         else:
1324             dllsources.append('${LCGDIR}/opencolorio/bin/libOpenColorIO.dll')
1325
1326     dllsources.append('#source/icons/blender.exe.manifest')
1327
1328     windlls = env.Install(dir=env['BF_INSTALLDIR'], source = dllsources)
1329     allinstall += windlls
1330
1331     # TODO(sergey): For unti we've got better way to deal with python binary
1332     if env['WITH_BF_PYTHON']:
1333         py_target = os.path.join(env['BF_INSTALLDIR'], VERSION, 'python', 'bin')
1334         if env['BF_DEBUG']:
1335             allinstall += env.Install(dir=py_target, source = ['${BF_PYTHON_LIBPATH}/${BF_PYTHON_DLL}_d.dll'])
1336         else:
1337             allinstall += env.Install(dir=py_target, source = ['${BF_PYTHON_LIBPATH}/${BF_PYTHON_DLL}.dll'])
1338
1339
1340 if env['OURPLATFORM'] == 'win64-mingw':
1341     dllsources = []
1342
1343     if env['WITH_BF_PYTHON']:
1344         if env['BF_DEBUG']:
1345             dllsources.append('${BF_PYTHON_LIBPATH}/${BF_PYTHON_DLL}_d.dll')
1346         else:
1347             dllsources.append('${BF_PYTHON_LIBPATH}/${BF_PYTHON_DLL}.dll')
1348
1349     if env['WITH_BF_FFMPEG']:
1350         dllsources += env['BF_FFMPEG_DLL'].split()
1351
1352     if env['WITH_BF_OPENAL']:
1353         dllsources.append('${LCGDIR}/openal/lib/OpenAL32.dll')
1354         dllsources.append('${LCGDIR}/openal/lib/wrap_oal.dll')
1355
1356     if env['WITH_BF_SNDFILE']:
1357         dllsources.append('${LCGDIR}/sndfile/lib/libsndfile-1.dll')
1358
1359     if env['WITH_BF_SDL']:
1360         dllsources.append('${LCGDIR}/sdl/lib/SDL.dll')
1361
1362     if(env['WITH_BF_OPENMP']):
1363         dllsources.append('${LCGDIR}/binaries/libgomp-1.dll')
1364
1365     if env['WITH_BF_OCIO']:
1366         dllsources.append('${LCGDIR}/opencolorio/bin/libOpenColorIO.dll')
1367
1368     dllsources.append('${LCGDIR}/thumbhandler/lib/BlendThumb64.dll')
1369     dllsources.append('${LCGDIR}/binaries/libgcc_s_sjlj-1.dll')
1370     dllsources.append('${LCGDIR}/binaries/libwinpthread-1.dll')
1371     dllsources.append('${LCGDIR}/binaries/libstdc++-6.dll')
1372     dllsources.append('#source/icons/blender.exe.manifest')
1373
1374     windlls = env.Install(dir=env['BF_INSTALLDIR'], source = dllsources)
1375     allinstall += windlls
1376
1377 installtarget = env.Alias('install', allinstall)
1378 bininstalltarget = env.Alias('install-bin', blenderinstall)
1379
1380 nsisaction = env.Action(btools.NSIS_Installer, btools.NSIS_print)
1381 nsiscmd = env.Command('nsisinstaller', None, nsisaction)
1382 nsisalias = env.Alias('nsis', nsiscmd)
1383
1384 if 'blender' in B.targets:
1385     blenderexe= env.Alias('blender', B.program_list)
1386     Depends(blenderexe,installtarget)
1387
1388 if env['WITH_BF_PLAYER']:
1389     blenderplayer = env.Alias('blenderplayer', B.program_list)
1390     Depends(blenderplayer,installtarget)
1391
1392 if not env['WITH_BF_GAMEENGINE']:
1393     blendernogame = env.Alias('blendernogame', B.program_list)
1394     Depends(blendernogame,installtarget)
1395
1396 if 'blenderlite' in B.targets:
1397     blenderlite = env.Alias('blenderlite', B.program_list)
1398     Depends(blenderlite,installtarget)
1399
1400 Depends(nsiscmd, allinstall)
1401
1402 buildslave_action = env.Action(btools.buildslave, btools.buildslave_print)
1403 buildslave_cmd = env.Command('buildslave_exec', None, buildslave_action)
1404 buildslave_alias = env.Alias('buildslave', buildslave_cmd)
1405
1406 Depends(buildslave_cmd, allinstall)
1407
1408 cudakernels_action = env.Action(btools.cudakernels, btools.cudakernels_print)
1409 cudakernels_cmd = env.Command('cudakernels_exec', None, cudakernels_action)
1410 cudakernels_alias = env.Alias('cudakernels', cudakernels_cmd)
1411
1412 cudakernel_dir = os.path.join(os.path.abspath(os.path.normpath(B.root_build_dir)), 'intern/cycles/kernel')
1413 cuda_kernels = []
1414
1415 for x in env['BF_CYCLES_CUDA_BINARIES_ARCH']:
1416     cubin = os.path.join(cudakernel_dir, 'kernel_' + x + '.cubin')
1417     cuda_kernels.append(cubin)
1418
1419 Depends(cudakernels_cmd, cuda_kernels)
1420 Depends(cudakernels_cmd, cubininstall)
1421
1422 Default(B.program_list)
1423
1424 if not env['WITHOUT_BF_INSTALL']:
1425         Default(installtarget)
1426