replace : iotivity -> iotivity-sec
[platform/upstream/iotivity.git] / resource / src / SConscript
1 #******************************************************************
2 #
3 # Copyright 2014 Intel Mobile Communications GmbH 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 # OCLib (share library) build script
23 ##
24 import os
25 thread_env = SConscript('#build_common/thread.scons')
26 lib_env = thread_env.Clone()
27
28 # Add third party libraries
29 SConscript('#resource/third_party_libs.scons', 'lib_env')
30
31 oclib_env = lib_env.Clone()
32 secured = oclib_env.get('SECURED')
33 target_os = oclib_env.get('TARGET_OS')
34 with_cloud = oclib_env.get('WITH_CLOUD')
35 with_mq = oclib_env.get('WITH_MQ')
36 ble_custom_adv = oclib_env.get('BLE_CUSTOM_ADV')
37
38 ######################################################################
39 # Build flags
40 ######################################################################
41 with_upstream_libcoap = oclib_env.get('WITH_UPSTREAM_LIBCOAP')
42 if with_upstream_libcoap == '1':
43         # For bring up purposes only, we manually copy the forked version to where the unforked version is downloaded.
44         oclib_env.AppendUnique(CPPPATH = ['#extlibs/libcoap/libcoap/include'])
45 else:
46         # For bring up purposes only, the forked version will live here.
47         oclib_env.AppendUnique(CPPPATH = ['../csdk/connectivity/lib/libcoap-4.1.1/include'])
48
49 oclib_env.AppendUnique(CPPPATH = [
50                 '../include/',
51                 '../csdk/stack/include',
52                 '../c_common/ocrandom/include',
53                 '../csdk/logger/include',
54                 '../oc_logger/include',
55                 '../csdk/connectivity/api'
56                 ])
57
58 oclib_env.AppendUnique(LIBPATH = [oclib_env.get('BUILD_DIR')])
59
60 oclib_env.AppendUnique(LIBS = ['oc_logger'])
61 oclib_env.PrependUnique(LIBS = ['octbstack', 'connectivity_abstraction', 'ocsrm'])
62
63 if 'g++' in oclib_env.get('CXX'):
64         oclib_env.AppendUnique(CXXFLAGS = ['-std=c++0x'])
65         oclib_env.AppendUnique(CXXFLAGS = ['-Wall'])
66         oclib_env.AppendUnique(CXXFLAGS = ['-fPIC'])
67
68 if target_os not in ['darwin', 'ios', 'windows']:
69         oclib_env.AppendUnique(LINKFLAGS = ['-Wl,--no-undefined'])
70
71 if target_os == 'android':
72     oclib_env.AppendUnique(CXXFLAGS = ['-frtti', '-fexceptions'])
73     oclib_env.AppendUnique(LIBS = ['boost_thread', 'gnustl_shared', 'log'])
74     oclib_env.AppendUnique(LINKFLAGS = ['-Wl,-soname,liboc.so'])
75
76 if target_os == 'tizen':
77         oclib_env.AppendUnique(CPPDEFINES = ['__TIZEN__'])
78 if target_os in ['linux', 'tizen']:
79         oclib_env.ParseConfig('pkg-config --cflags --libs sqlite3')
80
81 if target_os in ['linux'] and oclib_env.get('SIMULATOR', False):
82     oclib_env.Append( RPATH = oclib_env.Literal('\\$$ORIGIN'))
83
84 if target_os in ['msys_nt', 'windows']:
85         oclib_env.AppendUnique(LIBPATH = [os.path.join(oclib_env.get('BUILD_DIR'), 'resource', 'oc_logger')])
86         oclib_env.AppendUnique(LIBPATH = [os.path.join(oclib_env.get('BUILD_DIR'), 'resource', 'csdk')])
87         oclib_env.AppendUnique(LIBS=['octbstack', 'logger', 'oc_logger','connectivity_abstraction', 'ocsrm', 'c_common', 'routingmanager'])
88         oclib_env.AppendUnique(LIBS=[ 'coap', 'ws2_32' ,'iphlpapi'])
89         if secured == '1':
90                 oclib_env.AppendUnique(LIBS=['mbedtls', 'mbedx509','mbedcrypto'])
91
92 if with_cloud:
93         oclib_env.AppendUnique(CPPDEFINES = ['WITH_CLOUD'])
94
95 if ble_custom_adv == True:
96                 env.AppendUnique(CPPDEFINES = ['BLE_CUSTOM_ADVERTISE'])
97
98 if 'SUB' in with_mq:
99         oclib_env.AppendUnique(CPPDEFINES = ['MQ_SUBSCRIBER', 'WITH_MQ'])
100
101 if 'PUB' in with_mq:
102         oclib_env.AppendUnique(CPPDEFINES = ['MQ_PUBLISHER', 'WITH_MQ'])
103
104 if 'BROKER' in with_mq:
105         oclib_env.AppendUnique(CPPDEFINES = ['MQ_BROKER', 'WITH_MQ'])
106
107 ######################################################################
108 # Source files and Targets
109 ######################################################################
110 oclib_src = [
111                 'OCPlatform.cpp',
112                 'OCPlatform_impl.cpp',
113                 'OCResource.cpp',
114                 'OCUtilities.cpp',
115                 'OCException.cpp',
116                 'OCRepresentation.cpp',
117                 'InProcServerWrapper.cpp',
118                 'InProcClientWrapper.cpp',
119                 'OCResourceRequest.cpp',
120                 'CAManager.cpp',
121                 'OCDirectPairing.cpp'
122         ]
123
124 if with_cloud:
125         oclib_src = oclib_src + ['OCAccountManager.cpp']
126
127 if target_os in ['windows','ios']:
128         oclib_src = oclib_src + ['OCApi.cpp']
129         # TODO: Add OC_EXPORT prefixes to enable DLL generation
130         oclib = oclib_env.StaticLibrary('oc', oclib_src)
131 else:
132         oclib = oclib_env.SharedLibrary('oc', oclib_src)
133 oclib_env.InstallTarget(oclib, 'oc')
134 oclib_env.UserInstallTargetLib(oclib, 'oc')
135 header_dir = os.path.join(oclib_env.get('SRC_DIR') , 'resource' , 'include') + os.sep
136
137 oclib_env.UserInstallTargetHeader(header_dir + 'OCApi.h', 'resource', 'OCApi.h')
138 oclib_env.UserInstallTargetHeader(header_dir + 'OCHeaderOption.h', 'resource', 'OCHeaderOption.h')
139 oclib_env.UserInstallTargetHeader(header_dir + 'OCException.h', 'resource', 'OCException.h')
140 oclib_env.UserInstallTargetHeader(header_dir + 'StringConstants.h', 'resource', 'StringConstants.h')
141
142 oclib_env.UserInstallTargetHeader(header_dir + 'OCPlatform.h', 'resource', 'OCPlatform.h')
143 oclib_env.UserInstallTargetHeader(header_dir + 'OCPlatform_impl.h', 'resource', 'OCPlatform_impl.h')
144 oclib_env.UserInstallTargetHeader(header_dir + 'WrapperFactory.h', 'resource', 'WrapperFactory.h')
145 oclib_env.UserInstallTargetHeader(header_dir + 'IClientWrapper.h', 'resource', 'IClientWrapper.h')
146 oclib_env.UserInstallTargetHeader(header_dir + 'IServerWrapper.h', 'resource', 'IServerWrapper.h')
147 oclib_env.UserInstallTargetHeader(header_dir + 'OutOfProcClientWrapper.h', 'resource', 'OutOfProcClientWrapper.h')
148 oclib_env.UserInstallTargetHeader(header_dir + 'OutOfProcServerWrapper.h', 'resource', 'OutOfProcServerWrapper.h')
149 oclib_env.UserInstallTargetHeader(header_dir + 'InProcClientWrapper.h', 'resource', 'InProcClientWrapper.h')
150 oclib_env.UserInstallTargetHeader(header_dir + 'InProcServerWrapper.h', 'resource', 'InProcServerWrapper.h')
151 oclib_env.UserInstallTargetHeader(header_dir + 'InitializeException.h', 'resource', 'InitializeException.h')
152 oclib_env.UserInstallTargetHeader(header_dir + 'ResourceInitException.h', 'resource', 'ResourceInitException.h')
153
154 oclib_env.UserInstallTargetHeader(header_dir + 'OCRepresentation.h', 'resource', 'OCRepresentation.h')
155 oclib_env.UserInstallTargetHeader(header_dir + 'AttributeValue.h', 'resource', 'AttributeValue.h')
156
157 oclib_env.UserInstallTargetHeader(header_dir + 'OCResource.h', 'resource', 'OCResource.h')
158 oclib_env.UserInstallTargetHeader(header_dir + 'OCResourceRequest.h', 'resource', 'OCResourceRequest.h')
159 oclib_env.UserInstallTargetHeader(header_dir + 'OCResourceResponse.h', 'resource', 'OCResourceResponse.h')
160 oclib_env.UserInstallTargetHeader(header_dir + 'OCUtilities.h', 'resource', 'OCUtilities.h')
161
162 oclib_env.UserInstallTargetHeader(header_dir + 'CAManager.h', 'resource', 'CAManager.h')
163 oclib_env.UserInstallTargetHeader(header_dir + 'OCDirectPairing.h', 'resource', 'OCDirectPairing.h')
164
165 if with_cloud:
166         oclib_env.UserInstallTargetHeader(header_dir + 'OCAccountManager.h', 'resource', 'OCAccountManager.h')
167
168 # Add Provisioning library
169 if target_os in ['linux', 'android', 'tizen', 'ios'] and secured == '1':
170         SConscript('../provisioning/SConscript')