1 #******************************************************************
3 # Copyright 2014 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 #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
22 # liboctbstack (share library) build script
27 SConscript('#resource/third_party_libs.scons', 'lib_env')
29 liboctbstack_env = lib_env.Clone()
31 target_os = env.get('TARGET_OS')
32 rd_mode = env.get('RD_MODE')
33 with_ra = env.get('WITH_RA')
34 with_ra_ibb = env.get('WITH_RA_IBB')
35 with_tcp = env.get('WITH_TCP')
36 with_mq = env.get('WITH_MQ')
37 # As in the source code, it includes arduino Time library (C++)
38 # It requires compile the .c with g++
39 if target_os == 'arduino':
40 liboctbstack_env.Replace(CC = env.get('CXX'))
41 liboctbstack_env.Replace(CFLAGS = env.get('CXXFLAGS'))
43 ######################################################################
45 ######################################################################
46 liboctbstack_env.PrependUnique(CPPPATH = [
47 '../../extlibs/cjson/',
48 '../../extlibs/timer/',
51 'stack/include/internal',
52 '../oc_logger/include',
53 'connectivity/lib/libcoap-4.1.1',
54 'connectivity/common/inc',
57 'connectivity/external/inc',
59 'security/include/internal',
60 'security/provisioning/include',
64 liboctbstack_env.AppendUnique(CPPDEFINES = ['MQ_SUBSCRIBER', 'WITH_MQ'])
66 liboctbstack_env.AppendUnique(CPPDEFINES = ['MQ_PUBLISHER', 'WITH_MQ'])
67 if 'BROKER' in with_mq:
68 liboctbstack_env.AppendUnique(CPPDEFINES = ['MQ_BROKER', 'WITH_MQ'])
70 if target_os not in ['arduino', 'windows']:
71 liboctbstack_env.AppendUnique(CPPDEFINES = ['WITH_POSIX'])
72 liboctbstack_env.AppendUnique(CFLAGS = ['-std=c99'])
74 if liboctbstack_env.get('ROUTING') == 'GW':
75 liboctbstack_env.AppendUnique(CPPDEFINES = ['ROUTING_GATEWAY'])
76 elif liboctbstack_env.get('ROUTING') == 'EP':
77 liboctbstack_env.AppendUnique(CPPDEFINES = ['ROUTING_EP'])
79 if target_os not in ['windows']:
80 liboctbstack_env.AppendUnique(CFLAGS = ['-Wall'])
82 liboctbstack_env.AppendUnique(LIBPATH = [env.get('BUILD_DIR')])
84 liboctbstack_env.PrependUnique(LIBS = ['ocsrm', 'coap'])
85 if target_os in ['android', 'linux', 'tizen', 'msys_nt', 'windows']:
86 liboctbstack_env.PrependUnique(LIBS = ['connectivity_abstraction'])
89 liboctbstack_env.AppendUnique(LIBS = liboctbstack_env['RALIBS'], LIBPATH = liboctbstack_env['RALIBPATH'], RPATH = liboctbstack_env['RARPATH'])
92 liboctbstack_env.AppendUnique(LIBS = ['ra_xmpp'])
94 if target_os in ['windows', 'msys_nt']:
95 liboctbstack_env.AppendUnique(CPPDEFINES = ['OC_EXPORT_DLL'])
96 liboctbstack_env.AppendUnique(LIBS = ['ws2_32', 'advapi32', 'iphlpapi'])
98 liboctbstack_env.AppendUnique(LIBS = ['m'])
100 if target_os in ['tizen', 'linux']:
101 liboctbstack_env.ParseConfig("pkg-config --cflags --libs uuid")
103 if target_os == 'arduino':
104 liboctbstack_env.AppendUnique(CPPDEFINES = ['NDEBUG', 'WITH_ARDUINO'])
105 elif target_os not in ['darwin','ios', 'msys_nt', 'windows']:
106 liboctbstack_env.AppendUnique(CFLAGS = ['-fPIC'])
107 if target_os in ['darwin', 'ios']:
108 env.AppendUnique(CPPDEFINES = ['_DARWIN_C_SOURCE'])
109 liboctbstack_env.AppendUnique(CPPDEFINES = ['_DARWIN_C_SOURCE'])
110 liboctbstack_env.AppendUnique(LIBPATH = [env.get('BUILD_DIR')])
111 if target_os not in ['arduino', 'windows']:
112 liboctbstack_env.AppendUnique(LINKFLAGS = ['-Wl,--no-undefined'])
113 if target_os == 'android':
114 liboctbstack_env.AppendUnique(LINKFLAGS = ['-Wl,-soname,liboctbstack.so'])
116 if env.get('SECURED') == '1':
117 liboctbstack_env.AppendUnique(LIBS = ['tinydtls'])
119 if env.get('LOGGING'):
120 liboctbstack_env.AppendUnique(CPPDEFINES = ['TB_LOG'])
122 if env.get('DTLS_WITH_X509') == '1':
123 liboctbstack_env.AppendUnique(CPPDEFINES = ['__WITH_X509__'])
125 liboctbstack_env.Append(LIBS = ['c_common'])
127 if liboctbstack_env.get('ROUTING') in ['GW', 'EP']:
128 liboctbstack_env.Prepend(LIBS = ['routingmanager'])
130 ######################################################################
131 # Source files and Targets
132 ######################################################################
133 OCTBSTACK_SRC = 'stack/src/'
135 '../../extlibs/cjson/cJSON.c',
136 '../../extlibs/timer/timer.c',
137 OCTBSTACK_SRC + 'ocstack.c',
138 OCTBSTACK_SRC + 'ocpayload.c',
139 OCTBSTACK_SRC + 'ocpayloadparse.c',
140 OCTBSTACK_SRC + 'ocpayloadconvert.c',
141 OCTBSTACK_SRC + 'occlientcb.c',
142 OCTBSTACK_SRC + 'ocresource.c',
143 OCTBSTACK_SRC + 'ocobserve.c',
144 OCTBSTACK_SRC + 'ocserverrequest.c',
145 OCTBSTACK_SRC + 'occollection.c',
146 OCTBSTACK_SRC + 'oicgroup.c'
149 if 'CLIENT' in rd_mode or 'SERVER' in rd_mode:
150 liboctbstack_src.append(OCTBSTACK_SRC + 'rdpayload.c')
151 liboctbstack_src.append(OCTBSTACK_SRC + 'oicresourcedirectory.c')
152 if 'CLIENT' in rd_mode:
153 liboctbstack_env.AppendUnique(CPPDEFINES = ['RD_CLIENT'])
154 if 'SERVER' in rd_mode:
155 liboctbstack_env.AppendUnique(CPPDEFINES = ['RD_SERVER'])
158 liboctbstack_src.append(OCTBSTACK_SRC + 'oickeepalive.c')
160 liboctbstack_src.extend(env['cbor_files'])
162 if target_os == 'windows':
163 liboctbstack_env.AppendUnique(CPPDEFINES = ['CBOR_API=__declspec(dllexport)',
164 'CBOR_PRIVATE_API=__declspec(dllexport)'
167 static_liboctbstack = liboctbstack_env.StaticLibrary('octbstack', liboctbstack_src)
168 octbstack_libs = Flatten(static_liboctbstack)
170 if target_os not in ['arduino','darwin','ios'] :
171 shared_liboctbstack = liboctbstack_env.SharedLibrary('octbstack', liboctbstack_src)
172 octbstack_libs += Flatten(shared_liboctbstack)
173 liboctbstack_env.UserInstallTargetHeader('stack/include/ocstack.h', 'resource', 'ocstack.h')
174 liboctbstack_env.UserInstallTargetHeader('stack/include/ocpresence.h', 'resource', 'ocpresence.h')
176 liboctbstack_env.InstallTarget(octbstack_libs, 'octbstack')
177 liboctbstack_env.UserInstallTargetLib(octbstack_libs, 'octbstack')
179 liboctbstack_env.UserInstallTargetHeader('stack/include/ocstackconfig.h', 'resource', 'ocstackconfig.h')
180 liboctbstack_env.UserInstallTargetHeader('stack/include/octypes.h', 'resource', 'octypes.h')