Imported Upstream version 1.0.1
[platform/upstream/iotivity.git] / resource / csdk / security / SConscript
1 # //******************************************************************
2 # //
3 # // Copyright 2015 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 # libocsrm (share library) build script
22 ##
23
24 Import('env')
25
26 lib_env = env.Clone()
27 SConscript(env.get('SRC_DIR') + '/resource/third_party_libs.scons', 'lib_env')
28
29 libocsrm_env = lib_env.Clone()
30
31 target_os = env.get('TARGET_OS')
32 # As in the source code, it includes arduino Time library (C++)
33 # It requires compile the .c with g++
34 if target_os == 'arduino':
35         libocsrm_env.Replace(CC = env.get('CXX'))
36         libocsrm_env.Replace(CFLAGS = env.get('CXXFLAGS'))
37
38 ######################################################################
39 # Build flags
40 ######################################################################
41 libocsrm_env.PrependUnique(CPPPATH = [
42                 '../../../extlibs/cjson/',
43                 '../../../extlibs/tinydtls/',
44                 '../logger/include',
45                 '../../c_common/ocrandom/include',
46                 '../stack/include',
47                 '../stack/include/internal',
48                 '../../oc_logger/include',
49                 '../connectivity/lib/libcoap-4.1.1',
50                 '../connectivity/external/inc',
51                 '../connectivity/common/inc',
52                 '../connectivity/inc',
53                 '../connectivity/api',
54                 '../security/include',
55                 '../security/include/internal'
56                 ])
57
58 if target_os not in ['arduino', 'windows', 'winrt']:
59         libocsrm_env.AppendUnique(CPPDEFINES  = ['WITH_POSIX'])
60         libocsrm_env.AppendUnique(CFLAGS = ['-std=c99'])
61         libocsrm_env.AppendUnique(CPPDEFINES = ['HAVE_STRINGS_H'])
62
63 if target_os not in ['windows', 'winrt']:
64         libocsrm_env.AppendUnique(CFLAGS = ['-Wall'])
65
66 libocsrm_env.AppendUnique(LIBPATH = [env.get('BUILD_DIR')])
67 libocsrm_env.AppendUnique(LIBS = ['coap', 'm'])
68
69 if target_os == 'arduino':
70         libocsrm_env.AppendUnique(CPPDEFINES = ['NDEBUG', 'WITH_ARDUINO'])
71 else:
72         libocsrm_env.AppendUnique(CFLAGS = ['-fPIC'])
73
74 if target_os in ['darwin', 'ios']:
75         libocsrm_env.AppendUnique(CPPDEFINES = ['_DARWIN_C_SOURCE'])
76         libocsrm_env.AppendUnique(LIBPATH = [env.get('BUILD_DIR')])
77         libocsrm_env.AppendUnique(LIBS = ['coap'])
78
79 if not env.get('RELEASE'):
80         libocsrm_env.AppendUnique(CPPDEFINES = ['TB_LOG'])
81
82 if env.get('DTLS_WITH_X509') == '1':
83         libocsrm_env.AppendUnique(CPPDEFINES = ['__WITH_X509__'])
84
85 ######################################################################
86 # Source files and Targets
87 ######################################################################
88 OCSRM_SRC = 'src/'
89 if env.get('SECURED') == '1':
90         libocsrm_src = [
91                 OCSRM_SRC + 'secureresourcemanager.c',
92                 OCSRM_SRC + 'resourcemanager.c',
93                 OCSRM_SRC + 'aclresource.c',
94                 OCSRM_SRC + 'amaclresource.c',
95                 OCSRM_SRC + 'amsmgr.c',
96                 OCSRM_SRC + 'pstatresource.c',
97                 OCSRM_SRC + 'doxmresource.c',
98                 OCSRM_SRC + 'credresource.c',
99                 OCSRM_SRC + 'svcresource.c',
100                 OCSRM_SRC + 'policyengine.c',
101                 OCSRM_SRC + 'psinterface.c',
102                 OCSRM_SRC + 'srmresourcestrings.c',
103                 OCSRM_SRC + 'srmutility.c',
104                 OCSRM_SRC + 'iotvticalendar.c',
105                 OCSRM_SRC + 'oxmpincommon.c',
106                 OCSRM_SRC + 'base64.c',
107                 #pbkdf2.c is required to PIN based OxM only.
108                 #But we did not use a separate build options to prevent the build command becomes complicated.
109                 OCSRM_SRC + 'pbkdf2.c'
110                 ]
111 else:
112         libocsrm_src = [
113                 OCSRM_SRC + 'secureresourcemanager.c',
114                 OCSRM_SRC + 'resourcemanager.c',
115                 OCSRM_SRC + 'aclresource.c',
116                 OCSRM_SRC + 'amaclresource.c',
117                 OCSRM_SRC + 'amsmgr.c',
118                 OCSRM_SRC + 'pstatresource.c',
119                 OCSRM_SRC + 'doxmresource.c',
120                 OCSRM_SRC + 'credresource.c',
121                 OCSRM_SRC + 'svcresource.c',
122                 OCSRM_SRC + 'policyengine.c',
123                 OCSRM_SRC + 'psinterface.c',
124                 OCSRM_SRC + 'srmresourcestrings.c',
125                 OCSRM_SRC + 'srmutility.c',
126                 OCSRM_SRC + 'iotvticalendar.c',
127                 OCSRM_SRC + 'base64.c'
128                 ]
129
130 if env.get('DTLS_WITH_X509') == '1' and env.get('SECURED') == '1':
131         crl_src = [OCSRM_SRC + 'crlresource.c']
132         libocsrm_src  = libocsrm_src + crl_src
133
134
135 libocsrm = libocsrm_env.StaticLibrary('libocsrm', libocsrm_src)
136
137 libocsrm_env.InstallTarget(libocsrm, 'libocsrm')
138 libocsrm_env.UserInstallTargetLib(libocsrm, 'libocsrm')
139
140 if target_os in ['linux', 'android', 'tizen'] and env.get('SECURED') == '1':
141         SConscript('provisioning/SConscript')
142