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(env.get('SRC_DIR') + '/resource/third_party_libs.scons', 'lib_env')
29 liboctbstack_env = lib_env.Clone()
31 target_os = env.get('TARGET_OS')
32 with_ra = env.get('WITH_RA')
33 with_ra_ibb = env.get('WITH_RA_IBB')
34 with_tcp = env.get('WITH_TCP')
35 # As in the source code, it includes arduino Time library (C++)
36 # It requires compile the .c with g++
37 if target_os == 'arduino':
38 liboctbstack_env.Replace(CC = env.get('CXX'))
39 liboctbstack_env.Replace(CFLAGS = env.get('CXXFLAGS'))
41 ######################################################################
43 ######################################################################
44 liboctbstack_env.PrependUnique(CPPPATH = [
45 '../../extlibs/cjson/',
46 '../../extlibs/timer/',
49 'stack/include/internal',
50 '../oc_logger/include',
51 'connectivity/lib/libcoap-4.1.1',
52 'connectivity/common/inc',
55 'connectivity/external/inc',
57 'security/include/internal',
60 if target_os not in ['arduino', 'windows', 'winrt']:
61 liboctbstack_env.AppendUnique(CPPDEFINES = ['WITH_POSIX'])
62 liboctbstack_env.AppendUnique(CFLAGS = ['-std=c99'])
64 if liboctbstack_env.get('ROUTING') == 'GW':
65 liboctbstack_env.AppendUnique(CPPDEFINES = ['ROUTING_GATEWAY'])
66 elif liboctbstack_env.get('ROUTING') == 'EP':
67 liboctbstack_env.AppendUnique(CPPDEFINES = ['ROUTING_EP'])
69 if target_os not in ['windows', 'winrt']:
70 liboctbstack_env.AppendUnique(CFLAGS = ['-Wall'])
72 liboctbstack_env.AppendUnique(LIBPATH = [env.get('BUILD_DIR')])
74 if target_os in ['android', 'linux', 'tizen']:
75 liboctbstack_env.PrependUnique(LIBS = ['connectivity_abstraction'])
78 liboctbstack_env.AppendUnique(LIBS = liboctbstack_env['RALIBS'], LIBPATH = liboctbstack_env['RALIBPATH'], RPATH = liboctbstack_env['RARPATH'])
81 liboctbstack_env.AppendUnique(LIBS = ['ra_xmpp'])
83 liboctbstack_env.AppendUnique(LIBS = ['coap', 'm'])
84 liboctbstack_env.PrependUnique(LIBS = ['ocsrm'])
86 if target_os in ['tizen', 'linux']:
87 liboctbstack_env.ParseConfig("pkg-config --cflags --libs uuid")
89 if target_os not in ['android', 'arduino', 'windows', 'winrt']:
90 liboctbstack_env.AppendUnique(LIBS = ['pthread'])
92 if target_os == 'arduino':
93 liboctbstack_env.AppendUnique(CPPDEFINES = ['NDEBUG', 'WITH_ARDUINO'])
94 elif target_os not in ['darwin','ios']:
95 liboctbstack_env.AppendUnique(CFLAGS = ['-fPIC'])
96 if target_os in ['darwin', 'ios']:
97 env.AppendUnique(CPPDEFINES = ['_DARWIN_C_SOURCE'])
98 liboctbstack_env.AppendUnique(CPPDEFINES = ['_DARWIN_C_SOURCE'])
99 liboctbstack_env.AppendUnique(LIBPATH = [env.get('BUILD_DIR')])
100 if target_os not in ['arduino']:
101 liboctbstack_env.AppendUnique(LINKFLAGS = ['-Wl,--no-undefined'])
103 if env.get('SECURED') == '1':
104 liboctbstack_env.AppendUnique(LIBS = ['tinydtls'])
106 if env.get('LOGGING'):
107 liboctbstack_env.AppendUnique(CPPDEFINES = ['TB_LOG'])
109 if env.get('DTLS_WITH_X509') == '1':
110 liboctbstack_env.AppendUnique(CPPDEFINES = ['__WITH_X509__'])
112 if env.get('WITH_RD') == '1':
113 liboctbstack_env.PrependUnique(CPPPATH = ['../../service/resource-directory/include'])
114 liboctbstack_env.AppendUnique(CPPDEFINES = ['-DWITH_RD'])
115 liboctbstack_env.AppendUnique(LIBS = ['resource_directory'])
117 liboctbstack_env.Append(LIBS = ['c_common'])
119 if liboctbstack_env.get('ROUTING') in ['GW', 'EP']:
120 liboctbstack_env.Prepend(LIBS = ['routingmanager'])
122 ######################################################################
123 # Source files and Targets
124 ######################################################################
125 OCTBSTACK_SRC = 'stack/src/'
127 '../../extlibs/cjson/cJSON.c',
128 '../../extlibs/timer/timer.c',
129 OCTBSTACK_SRC + 'ocstack.c',
130 OCTBSTACK_SRC + 'ocpayload.c',
131 OCTBSTACK_SRC + 'ocpayloadparse.c',
132 OCTBSTACK_SRC + 'ocpayloadconvert.c',
133 OCTBSTACK_SRC + 'occlientcb.c',
134 OCTBSTACK_SRC + 'ocresource.c',
135 OCTBSTACK_SRC + 'ocobserve.c',
136 OCTBSTACK_SRC + 'ocserverrequest.c',
137 OCTBSTACK_SRC + 'occollection.c',
138 OCTBSTACK_SRC + 'oicgroup.c',
139 OCTBSTACK_SRC + "rdpayload.c"
143 liboctbstack_src.append(OCTBSTACK_SRC + 'oickeepalive.c')
145 liboctbstack_src.extend(env['cbor_files'])
147 if target_os in ['arduino','darwin','ios'] :
148 static_liboctbstack = liboctbstack_env.StaticLibrary('octbstack', liboctbstack_src)
149 liboctbstack_env.InstallTarget(static_liboctbstack, 'liboctbstack')
150 liboctbstack_env.UserInstallTargetLib(static_liboctbstack, 'liboctbstack')
151 liboctbstack_env.UserInstallTargetHeader('stack/include/ocstackconfig.h', 'resource', 'ocstackconfig.h')
152 liboctbstack_env.UserInstallTargetHeader('stack/include/octypes.h', 'resource', 'octypes.h')
154 static_liboctbstack = liboctbstack_env.StaticLibrary('octbstack', liboctbstack_src)
155 shared_liboctbstack = liboctbstack_env.SharedLibrary('octbstack', liboctbstack_src)
156 liboctbstack_env.InstallTarget([static_liboctbstack, shared_liboctbstack], 'liboctbstack')
157 liboctbstack_env.UserInstallTargetLib([static_liboctbstack, shared_liboctbstack], 'liboctbstack')
158 liboctbstack_env.UserInstallTargetHeader('stack/include/ocstackconfig.h', 'resource', 'ocstackconfig.h')
159 liboctbstack_env.UserInstallTargetHeader('stack/include/octypes.h', 'resource', 'octypes.h')
160 liboctbstack_env.UserInstallTargetHeader('stack/include/ocstack.h', 'resource', 'ocstack.h')
161 liboctbstack_env.UserInstallTargetHeader('stack/include/ocpresence.h', 'resource', 'ocpresence.h')