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 (share library) build script
28 SConscript('#resource/third_party_libs.scons', 'lib_env')
30 libocsrm_env = lib_env.Clone()
32 target_os = 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 = env.get('CXX'))
37 libocsrm_env.Replace(CFLAGS = env.get('CXXFLAGS'))
39 ######################################################################
41 ######################################################################
42 libocsrm_env.PrependUnique(CPPPATH = [
43 '../../../extlibs/cjson/',
44 '../../../extlibs/tinydtls/',
46 '../../c_common/ocrandom/include',
48 '../stack/include/internal',
49 '../../oc_logger/include',
50 '../connectivity/lib/libcoap-4.1.1',
51 '../connectivity/external/inc',
52 '../connectivity/common/inc',
53 '../connectivity/inc/pkix',
54 '../connectivity/inc',
55 '../connectivity/api',
56 '../security/include',
57 '../security/include/internal',
58 '../security/provisioning/include'
61 if target_os not in ['arduino', 'windows']:
62 libocsrm_env.AppendUnique(CPPDEFINES = ['WITH_POSIX'])
63 libocsrm_env.AppendUnique(CFLAGS = ['-std=c99', '-Wall'])
65 libocsrm_env.AppendUnique(LIBPATH = [env.get('BUILD_DIR')])
66 libocsrm_env.AppendUnique(LIBS = ['coap'])
68 if target_os == 'arduino':
69 libocsrm_env.AppendUnique(CPPDEFINES = ['NDEBUG', 'WITH_ARDUINO'])
70 elif target_os not in ['windows', 'msys_nt']:
71 libocsrm_env.AppendUnique(CFLAGS = ['-fPIC'])
72 libocsrm_env.AppendUnique(LIBS = ['m'])
74 if target_os in ['windows', 'msys_nt']:
75 libocsrm_env.AppendUnique(LIBPATH = [os.path.join(env.get('BUILD_DIR'), 'resource', 'oc_logger')])
77 if target_os in ['darwin', 'ios']:
78 libocsrm_env.AppendUnique(CPPDEFINES = ['_DARWIN_C_SOURCE'])
79 libocsrm_env.AppendUnique(LIBPATH = [env.get('BUILD_DIR')])
80 libocsrm_env.AppendUnique(LIBS = ['coap'])
82 if env.get('LOGGING'):
83 libocsrm_env.AppendUnique(CPPDEFINES = ['TB_LOG'])
85 if env.get('DTLS_WITH_X509') == '1':
86 libocsrm_env.AppendUnique(CPPDEFINES = ['__WITH_X509__'])
88 ######################################################################
89 # Source files and Targets
90 ######################################################################
93 OCSRM_SRC + 'secureresourcemanager.c',
94 OCSRM_SRC + 'resourcemanager.c',
95 OCSRM_SRC + 'aclresource.c',
96 OCSRM_SRC + 'verresource.c',
97 OCSRM_SRC + 'amaclresource.c',
98 OCSRM_SRC + 'amsmgr.c',
99 OCSRM_SRC + 'pstatresource.c',
100 OCSRM_SRC + 'doxmresource.c',
101 OCSRM_SRC + 'credresource.c',
102 OCSRM_SRC + 'svcresource.c',
103 OCSRM_SRC + 'pconfresource.c',
104 OCSRM_SRC + 'dpairingresource.c',
105 OCSRM_SRC + 'policyengine.c',
106 OCSRM_SRC + 'psinterface.c',
107 OCSRM_SRC + 'srmresourcestrings.c',
108 OCSRM_SRC + 'srmutility.c',
109 OCSRM_SRC + 'iotvticalendar.c',
110 OCSRM_SRC + 'base64.c',
111 OCSRM_SRC + 'directpairing.c'
114 if libocsrm_env.get('SECURED') == '1':
115 if target_os in ['tizen']:
116 libocsrm_env.ParseConfig('pkg-config --cflags --libs sqlite3')
118 libocsrm_env.AppendUnique(CPPPATH = ['../../../extlibs/sqlite3'])
119 libocsrm_src = libocsrm_src + ['../../../extlibs/sqlite3/sqlite3.c']
120 libocsrm_src = libocsrm_src + [OCSRM_SRC + 'provisioningdatabasemanager.c']
121 libocsrm_src = libocsrm_src + [OCSRM_SRC + 'oxmpincommon.c', OCSRM_SRC + 'pbkdf2.c']
123 if target_os in ['windows', 'msys_nt']:
124 libocsrm_src = libocsrm_src + [OCSRM_SRC + 'strptime.c']
126 if (env.get('DTLS_WITH_X509') == '1' or env.get('WITH_TCP') == True) and env.get('SECURED') == '1':
127 crl_src = [OCSRM_SRC + 'crlresource.c']
128 libocsrm_src = libocsrm_src + crl_src
130 libocsrm_conf = Configure(libocsrm_env)
131 if libocsrm_conf.CheckFunc('strptime'):
132 libocsrm_conf.env.AppendUnique(CPPDEFINES = ['HAVE_STRPTIME'])
133 libocsrm_env = libocsrm_conf.Finish()
135 libocsrm = libocsrm_env.StaticLibrary('ocsrm', libocsrm_src)
137 libocsrm_env.InstallTarget(libocsrm, 'ocsrm')
139 if target_os in ['linux', 'android', 'tizen', 'msys_nt', 'windows'] and env.get('SECURED') == '1':
140 SConscript('provisioning/SConscript')
142 if target_os in ['linux'] and env.get('SECURED') == '1':
143 SConscript('tool/SConscript')