Merge branch 'master' into windows-port
[platform/upstream/iotivity.git] / extlibs / boost / SConscript
1 import os, string, sys, subprocess
2
3 Import('env')
4
5 boost_env = env.Clone()
6
7 modules = ['thread','program_options', 'system', 'date_time']
8
9 target_os = env.get('TARGET_OS')
10 target_arch = env.get('TARGET_ARCH')
11 src_dir = env.get('SRC_DIR')
12
13 boost_version   = '1.60.0'
14
15 # TODO: Remove coupling between build scripts and 1_58_0 version for Android
16 if target_os in ['android']:
17     boost_version   = '1.58.0'
18
19 boost_base_name  = 'boost_'+string.replace(boost_version,'.','_')
20 boost_arch_name  = boost_base_name+'.zip'
21 boost_b2_name    = boost_base_name+os.sep+'b2'
22 boost_url       = 'http://downloads.sourceforge.net/project/boost/boost/'+boost_version+'/'+boost_arch_name+'?r=&ts=1421801329&use_mirror=iweb'
23
24 boost_dir = os.path.join(src_dir, 'extlibs','boost')
25 boost_bootstrap = os.path.join(boost_dir,'bootstrap.bat')
26
27 if 'linux' == target_os :
28     # Check for Boost libraries in /usr/boost
29     print 'TODO: Perform platform check for linux'
30     raise SCons.Errors.EnvironmentError('Unsupported platform')
31
32 elif target_os in ['windows']:
33     if not os.path.exists(boost_bootstrap) and target_os == 'windows':
34         # TODO: Enable installation of Boost via SConscript
35         print '''
36 *********************************** Error: ****************************************
37 * Please download boost from the following website:
38 *
39 *   ''' + boost_url + '''
40 *
41 * and extract the contents directly into:
42 *
43 *    ''' + boost_dir + '''
44 *
45 * such that you can find:
46 *
47 * ''' + boost_bootstrap + '''
48 *
49 ***********************************************************************************
50 '''
51         Exit(1)
52
53 elif target_os in ['android']:
54     env.Tool('URLDownload',    toolpath=['../../tools/scons'])
55     env.Tool('UnpackAll',      toolpath=['../../tools/scons'])
56     env.Tool('BoostBootstrap', toolpath=['../../tools/scons'])
57     env.Tool('BoostBuild',     toolpath=['../../tools/scons'])
58
59     host_os = sys.platform
60
61     if host_os == 'linux2' :
62         boost_bootstrap = boost_base_name+os.sep+'bootstrap.sh'
63     else :
64         msg="Host platform (%s) is currently not supported for boost builds" % host_os
65         raise SCons.Errors.EnvironmentError(msg)
66
67     if not os.path.exists(boost_arch_name) and not os.path.exists(boost_base_name):
68         boost_arch_name = env.URLDownload(boost_arch_name, boost_url)
69
70     if not os.path.exists(boost_base_name):
71         boost_arch_name = env.UnpackAll(boost_bootstrap, boost_arch_name)
72
73     boost_b2  = env.BoostBootstrap(boost_b2_name, boost_arch_name)
74
75     dep_sys_root = env['DEP_SYS_ROOT']
76     dep_src_dir =  dep_sys_root + os.sep + 'include'
77     dep_lib_dir =  dep_sys_root + os.sep + 'lib'
78
79     boost_targets = [
80         os.path.join(dep_src_dir, 'boost', 'config.hpp'),
81         os.path.join(dep_src_dir, 'boost', 'variant.hpp'),
82         os.path.join(dep_src_dir, 'boost', 'program_options.hpp'),
83         os.path.join(dep_src_dir, 'boost', 'thread.hpp'),
84         os.path.join(dep_src_dir, 'boost', 'date_time.hpp'),
85         os.path.join(dep_src_dir, 'libboost_thread.a'),        
86         os.path.join(dep_src_dir, 'libboost_date_time.a'),
87         os.path.join(dep_src_dir, 'libboost_atomic.a'),
88         os.path.join(dep_src_dir, 'libboost_system.a'),
89         os.path.join(dep_src_dir, 'libboost_program_options.a')
90         ]
91
92     boost_build = env.BoostBuild(boost_targets, boost_b2, PREFIX=dep_sys_root, MODULES=modules)
93