Fixed memory leak detected by valgrind
[platform/upstream/iotivity.git] / service / third_party_libs.scons
1 #******************************************************************
2 #
3 # Copyright 2014 Samsung Electronics All Rights Reserved.
4 #
5 #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
6 #
7 # Licensed under the Apache License, Version 2.0 (the "License");
8 # you may not use this file except in compliance with the License.
9 # You may obtain a copy of the License at
10 #
11 #      http://www.apache.org/licenses/LICENSE-2.0
12 #
13 # Unless required by applicable law or agreed to in writing, software
14 # distributed under the License is distributed on an "AS IS" BASIS,
15 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 # See the License for the specific language governing permissions and
17 # limitations under the License.
18 #
19 #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
20
21 ######################################################################
22 # This script manages third party libraries
23 #
24 # Note: The paths must keep consistent with oic-resource
25 ######################################################################
26 import os
27 import platform
28
29 Import('env', 'lib_env')
30
31 target_os = env.get('TARGET_OS')
32 target_arch = env.get('TARGET_ARCH')
33 src_dir = env.get('SRC_DIR')
34
35 resource_path = src_dir + '/resource'
36
37 ######################################################################
38 # Check dependent packages (Linux only)
39 ######################################################################
40 if target_os in ['linux']:
41     if not env.GetOption('help') and not env.GetOption('clean'):
42         if target_arch != platform.machine():
43             print '''
44 *********************************** Warning ***********************************
45 * You are trying cross build, please make sure (%s) version libraries are
46 * installed!                                                                  *
47 *******************************************************************************
48 ''' % target_arch
49
50         conf = Configure(lib_env.Clone(LIBS=[]))
51
52         if target_os not in ['tizen'] and not conf.CheckLib('boost_thread', language='C++'):
53             print 'Did not find boost_thread, exiting!'
54             Exit(1)
55
56         if target_os not in ['tizen'] and not conf.CheckLib('boost_system', language='C++'):
57             print 'Did not find boost_system, exiting!'
58             Exit(1)
59
60         conf.Finish()
61
62 ######################################################################
63 # The 'include' path of external libraries
64 ######################################################################
65 lib_env.AppendUnique(CPPPATH=[
66     resource_path, resource_path + '/include',
67     resource_path + '/oc_logger/include', resource_path + '/csdk/include',
68     resource_path + '/csdk/stack/include',
69     resource_path + '/c_common/ocrandom/include',
70     resource_path + '/csdk/logger/include'
71 ])
72
73 ######################################################################
74 # The path of third party libraries binary
75 ######################################################################
76 if target_os == 'android':
77     if target_arch == 'armeabi-v7a-hard':
78         target_arch = 'armeabi-v7a'
79
80     if target_arch not in ['x86', 'x86_64', 'armeabi', 'armeabi-v7a']:
81         if not env.GetOption('help') and not env.GetOption('clean'):
82             print '''
83 *********************************** Warning ***********************************
84 * current only x86, x86_64, armeabi, armeabi-v7a libraries are provided!      *
85 *******************************************************************************
86 '''
87     else:
88         # Too much boost warning, suppress the warning
89         lib_env.AppendUnique(CCFLAGS=['-w'])
90
91 elif target_os == 'ios':
92     lib_env.AppendUnique(FRAMEWORKPATH=[src_dir + '/extlibs/boost/ios/framework'])
93     lib_env.AppendUnique(FRAMEWORKS=['boost'])
94 elif target_os == 'darwin':
95     lib_env.AppendUnique(CPPPATH=['/usr/local/include'])
96     lib_env.AppendUnique(LIBPATH=['/usr/local/lib'])
97 elif target_os == 'windows':
98     boost_path = os.path.join(src_dir, 'extlibs', 'boost', 'boost')
99     lib_env.AppendUnique(CPPPATH=[boost_path])
100
101 Import('env')
102 lib_env.AppendUnique(LIBPATH=env.get('BUILD_DIR'))