Imported Upstream version 1.2.0
[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 import os
26
27 lib_env = env.Clone()
28 SConscript('#resource/third_party_libs.scons', 'lib_env')
29
30 libocsrm_env = lib_env.Clone()
31
32 target_os = libocsrm_env.get('TARGET_OS')
33 # As in the source code, it includes arduino Time library (C++)
34 # It requires compile the .c with g++
35 if target_os == 'arduino':
36         libocsrm_env.Replace(CC = libocsrm_env.get('CXX'))
37         libocsrm_env.Replace(CFLAGS = libocsrm_env.get('CXXFLAGS'))
38
39 ######################################################################
40 # Build flags
41 ######################################################################
42 with_upstream_libcoap = libocsrm_env.get('WITH_UPSTREAM_LIBCOAP')
43 if with_upstream_libcoap == '1':
44         # For bring up purposes only, we manually copy the forked version to where the unforked version is downloaded.
45         libocsrm_env.AppendUnique(CPPPATH = ['#extlibs/libcoap/libcoap/include'])
46 else:
47         # For bring up purposes only, the forked version will live here.
48         libocsrm_env.AppendUnique(CPPPATH = ['../connectivity/lib/libcoap-4.1.1/include'])
49
50 libocsrm_env.PrependUnique(CPPPATH = [
51                 '../../../extlibs/cjson/',
52                 '../../../extlibs/tinydtls/',
53                 '../logger/include',
54                 '../../c_common/ocrandom/include',
55                 '../stack/include',
56                 '../stack/include/internal',
57                 '../../oc_logger/include',
58                 '../connectivity/external/inc',
59                 '../connectivity/common/inc',
60                 '../connectivity/inc',
61                 '../connectivity/api',
62                 '../security/include',
63                 '../security/include/internal',
64                 '../security/provisioning/include'
65                 ])
66
67 if target_os not in ['arduino', 'windows']:
68         libocsrm_env.AppendUnique(CPPDEFINES  = ['WITH_POSIX', '_GNU_SOURCE'])
69         libocsrm_env.AppendUnique(CFLAGS = ['-std=c99', '-Wall'])
70
71 libocsrm_env.AppendUnique(LIBPATH = [libocsrm_env.get('BUILD_DIR')])
72 libocsrm_env.AppendUnique(LIBS = ['coap'])
73
74 if target_os == 'arduino':
75         libocsrm_env.AppendUnique(CPPDEFINES = ['NDEBUG', 'WITH_ARDUINO'])
76 elif target_os not in ['windows', 'msys_nt']:
77         libocsrm_env.AppendUnique(CFLAGS = ['-fPIC'])
78         libocsrm_env.AppendUnique(LIBS = ['m'])
79
80 if target_os in ['windows', 'msys_nt']:
81         libocsrm_env.AppendUnique(LIBPATH = [os.path.join(libocsrm_env.get('BUILD_DIR'), 'resource', 'oc_logger')])
82
83 if target_os in ['darwin', 'ios']:
84         libocsrm_env.AppendUnique(CPPDEFINES = ['_DARWIN_C_SOURCE'])
85         libocsrm_env.AppendUnique(LIBPATH = [libocsrm_env.get('BUILD_DIR')])
86         libocsrm_env.AppendUnique(LIBS = ['coap'])
87
88 if env.get('LOGGING'):
89         libocsrm_env.AppendUnique(CPPDEFINES = ['TB_LOG'])
90
91 if env.get('MULTIPLE_OWNER') == '1':
92         libocsrm_env.AppendUnique(CPPDEFINES=['_ENABLE_MULTIPLE_OWNER_'])
93
94 ######################################################################
95 # Source files and Targets
96 ######################################################################
97 OCSRM_SRC = 'src/'
98 libocsrm_src = [
99         OCSRM_SRC + 'secureresourcemanager.c',
100         OCSRM_SRC + 'resourcemanager.c',
101         OCSRM_SRC + 'aclresource.c',
102         OCSRM_SRC + 'verresource.c',
103         OCSRM_SRC + 'amaclresource.c',
104         OCSRM_SRC + 'amsmgr.c',
105         OCSRM_SRC + 'pstatresource.c',
106         OCSRM_SRC + 'doxmresource.c',
107         OCSRM_SRC + 'credresource.c',
108         OCSRM_SRC + 'svcresource.c',
109         OCSRM_SRC + 'pconfresource.c',
110         OCSRM_SRC + 'dpairingresource.c',
111         OCSRM_SRC + 'policyengine.c',
112         OCSRM_SRC + 'psinterface.c',
113         OCSRM_SRC + 'srmresourcestrings.c',
114         OCSRM_SRC + 'srmutility.c',
115         OCSRM_SRC + 'iotvticalendar.c',
116         OCSRM_SRC + 'base64.c',
117         OCSRM_SRC + 'directpairing.c'
118         ]
119
120 if libocsrm_env.get('SECURED') == '1':
121         libocsrm_src = libocsrm_src + [OCSRM_SRC + 'oxmpincommon.c', OCSRM_SRC + 'pbkdf2.c']
122         libocsrm_src  = libocsrm_src + [OCSRM_SRC + 'crlresource.c', OCSRM_SRC + 'pkix_interface.c']
123
124 if target_os in ['windows', 'msys_nt']:
125         libocsrm_src  = libocsrm_src + [OCSRM_SRC + 'strptime.c']
126
127
128 libocsrm_src.extend(env['cbor_files'])
129
130 # Insert a hack for Arduino, whose compiler may not support all defines expected
131 # by tinycbor
132 if target_os in ['arduino']:
133         libocsrm_env.AppendUnique(CPPDEFINES = ['INT64_MAX=0x7FFFFFFFFFFFFFFF'])
134
135 libocsrm_conf = Configure(libocsrm_env)
136 if libocsrm_conf.CheckFunc('strptime'):
137         libocsrm_conf.env.AppendUnique(CPPDEFINES = ['HAVE_STRPTIME'])
138 libocsrm_env = libocsrm_conf.Finish()
139
140 libocsrm = libocsrm_env.StaticLibrary('ocsrm', libocsrm_src)
141
142 libocsrm_env.InstallTarget(libocsrm, 'ocsrm')
143
144 if target_os in ['linux', 'android', 'tizen', 'msys_nt', 'windows'] and libocsrm_env.get('SECURED') == '1':
145         SConscript('provisioning/SConscript')
146
147 if target_os in ['linux'] and libocsrm_env.get('SECURED') == '1':
148         SConscript('tool/SConscript')