Prepare for merge. Improved consistency and style.
[platform/upstream/iotivity.git] / resource / csdk / security / provisioning / SConscript
1 # //******************************************************************
2 # //
3 # // Copyright 2015 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 Import('env')
23
24 provisioning_env = env.Clone()
25 root_dir = './../../../../'
26
27 ######################################################################
28 # Build flags
29 ######################################################################
30 provisioning_env.AppendUnique(CPPPATH = [
31                 '../../stack/include',
32                 '../../stack/include/internal',
33                 '../../../c_common/ocrandom/include',
34                 '../../logger/include',
35                 '../../../oc_logger/include',
36                 '../../ocmalloc/include',
37                 'include',
38                 'include/internal',
39                 'include/oxm',
40                 '../../resource/csdk/security/include',
41                 '../../../../extlibs/cjson/',
42                 '../../../../../extlibs/tinydtls/',
43                 '../../connectivity/inc',
44                 '../../connectivity/external/inc',
45                 '../../connectivity/common/inc',
46                 '../../connectivity/lib/libcoap-4.1.1',
47                 '../../connectivity/api',
48                 '../include',
49                 '../include/internal',
50                 '../../../../extlibs/tinydtls/ecc',
51                 '../../../../extlibs/tinydtls/sha2',
52                 '../../../../extlibs/asn1cert',
53                 'ck_manager/include'
54                 ])
55 target_os = env.get('TARGET_OS')
56
57 if target_os != 'tizen':
58         provisioning_env.AppendUnique(CPPPATH = ['../../../../extlibs/sqlite3'])
59
60 provisioning_env.AppendUnique(CPPDEFINES= ['__WITH_DTLS__'])
61 if target_os not in ['windows']:
62         provisioning_env.AppendUnique(CFLAGS = ['-std=c99'])
63 if target_os not in ['windows', 'msys_nt']:
64         provisioning_env.AppendUnique(CXXFLAGS = ['-std=c++0x', '-Wall', '-pthread'])
65
66         # Note: 'pthread' is in libc for android. On other platform, if use
67         # new gcc(>4.9?) it isn't required, otherwise, it's required
68         if target_os != 'android':
69                 provisioning_env.AppendUnique(LIBS = ['-lpthread', '-ldl'])
70
71 provisioning_env.AppendUnique(LIBPATH = [env.get('BUILD_DIR')])
72 provisioning_env.PrependUnique(LIBS = ['oc', 'octbstack', 'oc_logger', 'connectivity_abstraction', 'coap'])
73
74 provisioning_env.AppendUnique(LIBS = ['tinydtls'])
75
76 if env.get('DTLS_WITH_X509') == '1':
77         provisioning_env.AppendUnique(LIBS = ['CKManager', 'asn1'])
78
79 if target_os not in ['msys_nt', 'windows', 'android']:
80         provisioning_env.ParseConfig('pkg-config --libs glib-2.0')
81
82 if target_os in ['windows', 'msys_nt']:
83         provisioning_env.AppendUnique(LIBS = ['ws2_32', 'advapi32', 'iphlpapi', 'timer'])
84
85 if target_os == 'tizen':
86         provisioning_env.ParseConfig('pkg-config --cflags --libs sqlite3')
87
88 if target_os == 'android':
89         provisioning_env.AppendUnique(CXXFLAGS = ['-frtti', '-fexceptions'])
90         provisioning_env.AppendUnique(LIBS = ['gnustl_static'])
91
92         if not env.get('RELEASE'):
93                 provisioning_env.AppendUnique(CPPDEFINES = ['TB_LOG'])
94
95 if target_os in ['darwin', 'ios']:
96         provisioning_env.AppendUnique(CPPDEFINES = ['_DARWIN_C_SOURCE'])
97
98 ######################################################################
99 # Source files and Targets
100 ######################################################################
101 provisioning_src = [
102         'src/pmutility.c',
103         'src/credentialgenerator.c',
104         'src/ownershiptransfermanager.c',
105         'src/secureresourceprovider.c',
106         'src/ocprovisioningmanager.c',
107         'src/oxmjustworks.c',
108         'src/oxmrandompin.c',
109         'src/provisioningdatabasemanager.c' ]
110
111 if target_os != 'tizen':
112         provisioning_src = provisioning_src + [root_dir+'/extlibs/sqlite3/sqlite3.c' ]
113
114 if target_os == 'windows':
115         # TODO: Add OC_EXPORT annotations and enable generation of Windows DLL
116         provisioningserver = provisioning_env.StaticLibrary('ocpmapi', provisioning_src)
117 else:
118         provisioningserver = provisioning_env.SharedLibrary('ocpmapi', provisioning_src)
119
120 provisioning_env.InstallTarget(provisioningserver, 'ocpmapi')
121 provisioning_env.UserInstallTargetLib(provisioningserver, 'ocpmapi')
122
123 if env.get('DTLS_WITH_X509') == '1':
124         SConscript('ck_manager/SConscript')
125
126 if target_os in ['linux', 'msys_nt', 'windows']:
127         SConscript('sample/SConscript')
128