1 # //******************************************************************
3 # // Copyright 2015 Intel Mobile Communications GmbH All Rights Reserved.
5 # //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
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
11 # // http://www.apache.org/licenses/LICENSE-2.0
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.
19 # //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
21 # libocsrm (static library) build script
27 libocsrm_env = env.Clone()
29 target_os = libocsrm_env.get('TARGET_OS')
31 ######################################################################
33 ######################################################################
34 with_upstream_libcoap = libocsrm_env.get('WITH_UPSTREAM_LIBCOAP')
35 if with_upstream_libcoap == '1':
36 # For bring up purposes only, we manually copy the forked version to where the unforked version is downloaded.
37 libocsrm_env.AppendUnique(CPPPATH = ['#extlibs/libcoap/libcoap/include'])
39 # For bring up purposes only, the forked version will live here.
40 libocsrm_env.AppendUnique(CPPPATH = ['#/resource/csdk/connectivity/lib/libcoap-4.1.1/include'])
42 libocsrm_env.PrependUnique(CPPPATH = [
43 '#/extlibs/mbedtls/mbedtls/include',
44 '#/resource/csdk/logger/include',
45 '#/resource/c_common/ocrandom/include',
46 '#/resource/csdk/include',
47 '#/resource/csdk/stack/include',
48 '#/resource/csdk/stack/include/internal',
49 '#/resource/oc_logger/include',
50 '#/resource/csdk/connectivity/external/inc',
51 '#/resource/csdk/connectivity/common/inc',
52 '#/resource/csdk/connectivity/inc',
53 '#/resource/csdk/connectivity/api',
54 '#/resource/csdk/security/include',
55 '#/resource/csdk/security/include/internal',
56 '#/resource/csdk/security/provisioning/include',
57 '#/extlibs/mbedtls/mbedtls/include'
60 if target_os in ['windows', 'msys_nt']:
61 libocsrm_env.AppendUnique(LIBPATH = [os.path.join(libocsrm_env.get('BUILD_DIR'), 'resource', 'oc_logger')])
62 # Enable W4 but disable the following warnings:
63 # - warning C4201: nonstandard extension used: nameless struct/union
64 # - Disabled due to the widespread usage in internal IoTivity components as well as external libs.
65 # - warning C4232: nonstandard extension used: 'read': address of dllimport 'fread' is not static, identity not guaranteed
66 # - fread, frwrite, etc are provided by the platform and cannot be changed.
67 libocsrm_env.AppendUnique(CCFLAGS=['/wd4201', '/wd4232', '/W4', '/WX'])
69 if target_os in ['linux', 'android', 'tizen', 'msys_nt', 'windows'] and libocsrm_env.get('SECURED') == '1':
70 SConscript('provisioning/SConscript', 'libocsrm_env')
72 if target_os in ['linux', 'windows', 'darwin'] and libocsrm_env.get('SECURED') == '1':
73 SConscript('tool/SConscript', 'libocsrm_env')
75 # As in the source code, it includes arduino Time library (C++)
76 # It requires compile the .c with g++
77 if target_os == 'arduino':
78 libocsrm_env.Replace(CC = libocsrm_env.get('CXX'))
79 libocsrm_env.Replace(CFLAGS = libocsrm_env.get('CXXFLAGS'))
81 if target_os not in ['arduino', 'windows']:
82 libocsrm_env.AppendUnique(CPPDEFINES = ['WITH_POSIX', '_GNU_SOURCE'])
83 libocsrm_env.AppendUnique(CFLAGS = ['-std=c99', '-Wall'])
85 libocsrm_env.AppendUnique(LIBPATH = [libocsrm_env.get('BUILD_DIR')])
86 libocsrm_env.AppendUnique(LIBS = ['coap'])
88 if target_os == 'arduino':
89 libocsrm_env.AppendUnique(CPPDEFINES = ['NDEBUG', 'WITH_ARDUINO'])
90 elif target_os not in ['windows', 'msys_nt']:
91 libocsrm_env.AppendUnique(CFLAGS = ['-fPIC'])
92 libocsrm_env.AppendUnique(LIBS = ['m'])
94 if target_os in ['darwin', 'ios']:
95 libocsrm_env.AppendUnique(CPPDEFINES = ['_DARWIN_C_SOURCE'])
97 if env.get('LOGGING'):
98 libocsrm_env.AppendUnique(CPPDEFINES = ['TB_LOG'])
100 if env.get('MULTIPLE_OWNER') == '1':
101 libocsrm_env.AppendUnique(CPPDEFINES=['MULTIPLE_OWNER'])
103 ######################################################################
104 # Source files and Targets
105 ######################################################################
108 OCSRM_SRC + 'secureresourcemanager.c',
109 OCSRM_SRC + 'resourcemanager.c',
110 OCSRM_SRC + 'aclresource.c',
111 OCSRM_SRC + 'verresource.c',
112 OCSRM_SRC + 'amaclresource.c',
113 OCSRM_SRC + 'pstatresource.c',
114 OCSRM_SRC + 'doxmresource.c',
115 OCSRM_SRC + 'credresource.c',
116 OCSRM_SRC + 'svcresource.c',
117 OCSRM_SRC + 'pconfresource.c',
118 OCSRM_SRC + 'dpairingresource.c',
119 OCSRM_SRC + 'policyengine.c',
120 OCSRM_SRC + 'psinterface.c',
121 OCSRM_SRC + 'srmresourcestrings.c',
122 OCSRM_SRC + 'srmutility.c',
123 OCSRM_SRC + 'iotvticalendar.c',
124 OCSRM_SRC + 'base64.c',
125 OCSRM_SRC + 'directpairing.c'
128 if libocsrm_env.get('SECURED') == '1':
129 libocsrm_src = libocsrm_src + [OCSRM_SRC + 'oxmpincommon.c', OCSRM_SRC + 'pbkdf2.c']
130 libocsrm_src = libocsrm_src + [OCSRM_SRC + 'crlresource.c', OCSRM_SRC + 'pkix_interface.c']
131 libocsrm_src = libocsrm_src + [OCSRM_SRC + 'oxmverifycommon.c']
133 if target_os in ['windows', 'msys_nt']:
134 libocsrm_src = libocsrm_src + [OCSRM_SRC + 'strptime.c']
136 libocsrm_src.extend(env['cbor_files'])
138 # Insert a hack for Arduino, whose compiler may not support all defines expected
140 if target_os in ['arduino']:
141 libocsrm_env.AppendUnique(CPPDEFINES = ['INT64_MAX=0x7FFFFFFFFFFFFFFF'])
143 libocsrm = libocsrm_env.StaticLibrary('ocsrm', libocsrm_src)
145 libocsrm_env.InstallTarget(libocsrm, 'ocsrm')