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(env.get('SRC_DIR') + '/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',
54 '../connectivity/api',
55 '../security/include',
56 '../security/include/internal',
57 '../security/provisioning/include'
60 if target_os not in ['arduino', 'windows']:
61 libocsrm_env.AppendUnique(CPPDEFINES = ['WITH_POSIX'])
62 libocsrm_env.AppendUnique(CFLAGS = ['-std=c99', '-Wall'])
64 libocsrm_env.AppendUnique(LIBPATH = [env.get('BUILD_DIR')])
65 libocsrm_env.AppendUnique(LIBS = ['coap'])
67 if target_os == 'arduino':
68 libocsrm_env.AppendUnique(CPPDEFINES = ['NDEBUG', 'WITH_ARDUINO'])
69 elif target_os not in ['windows', 'msys_nt']:
70 libocsrm_env.AppendUnique(CFLAGS = ['-fPIC'])
71 libocsrm_env.AppendUnique(LIBS = ['m'])
73 if target_os in ['windows', 'msys_nt']:
74 libocsrm_env.AppendUnique(LIBPATH = [os.path.join(env.get('BUILD_DIR'), 'resource', 'oc_logger')])
76 if target_os in ['darwin', 'ios']:
77 libocsrm_env.AppendUnique(CPPDEFINES = ['_DARWIN_C_SOURCE'])
78 libocsrm_env.AppendUnique(LIBPATH = [env.get('BUILD_DIR')])
79 libocsrm_env.AppendUnique(LIBS = ['coap'])
81 if env.get('LOGGING'):
82 libocsrm_env.AppendUnique(CPPDEFINES = ['TB_LOG'])
84 if env.get('DTLS_WITH_X509') == '1':
85 libocsrm_env.AppendUnique(CPPDEFINES = ['__WITH_X509__'])
87 ######################################################################
88 # Source files and Targets
89 ######################################################################
92 OCSRM_SRC + 'secureresourcemanager.c',
93 OCSRM_SRC + 'resourcemanager.c',
94 OCSRM_SRC + 'aclresource.c',
95 OCSRM_SRC + 'verresource.c',
96 OCSRM_SRC + 'amaclresource.c',
97 OCSRM_SRC + 'amsmgr.c',
98 OCSRM_SRC + 'pstatresource.c',
99 OCSRM_SRC + 'doxmresource.c',
100 OCSRM_SRC + 'credresource.c',
101 OCSRM_SRC + 'svcresource.c',
102 OCSRM_SRC + 'pconfresource.c',
103 OCSRM_SRC + 'dpairingresource.c',
104 OCSRM_SRC + 'policyengine.c',
105 OCSRM_SRC + 'psinterface.c',
106 OCSRM_SRC + 'srmresourcestrings.c',
107 OCSRM_SRC + 'srmutility.c',
108 OCSRM_SRC + 'iotvticalendar.c',
109 OCSRM_SRC + 'base64.c',
110 OCSRM_SRC + 'directpairing.c'
113 if env.get('SECURED') == '1':
114 libocsrm_src = libocsrm_src + [OCSRM_SRC + 'oxmpincommon.c', OCSRM_SRC + 'pbkdf2.c']
116 if target_os in ['windows', 'msys_nt']:
117 libocsrm_src = libocsrm_src + [OCSRM_SRC + 'strptime.c']
119 if env.get('DTLS_WITH_X509') == '1' and env.get('SECURED') == '1':
120 crl_src = [OCSRM_SRC + 'crlresource.c']
121 libocsrm_src = libocsrm_src + crl_src
123 libocsrm_conf = Configure(libocsrm_env)
124 if libocsrm_conf.CheckFunc('strptime'):
125 libocsrm_conf.env.AppendUnique(CPPDEFINES = ['HAVE_STRPTIME'])
126 libocsrm_env = libocsrm_conf.Finish()
128 libocsrm = libocsrm_env.StaticLibrary('ocsrm', libocsrm_src)
130 libocsrm_env.InstallTarget(libocsrm, 'ocsrm')
132 if target_os in ['linux', 'android', 'tizen', 'msys_nt', 'windows'] and env.get('SECURED') == '1':
133 SConscript('provisioning/SConscript')
135 if target_os in ['linux'] and env.get('SECURED') == '1':
136 SConscript('tool/SConscript')