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 # As in the source code, it includes arduino Time library (C++)
35 # It requires compile the .c with g++
36 if target_os == 'arduino':
37 liboctbstack_env.Replace(CC = env.get('CXX'))
38 liboctbstack_env.Replace(CFLAGS = env.get('CXXFLAGS'))
40 ######################################################################
42 ######################################################################
43 liboctbstack_env.PrependUnique(CPPPATH = [
44 '../../extlibs/cjson/',
45 '../../extlibs/timer/',
48 'stack/include/internal',
49 '../oc_logger/include',
50 'connectivity/lib/libcoap-4.1.1',
53 'connectivity/external/inc',
55 'security/include/internal',
58 if target_os not in ['arduino', 'windows', 'winrt']:
59 liboctbstack_env.AppendUnique(CPPDEFINES = ['WITH_POSIX'])
60 liboctbstack_env.AppendUnique(CFLAGS = ['-std=c99'])
62 if liboctbstack_env.get('ROUTING') == 'GW':
63 liboctbstack_env.AppendUnique(CPPDEFINES = ['ROUTING_GATEWAY'])
64 elif liboctbstack_env.get('ROUTING') == 'EP':
65 liboctbstack_env.AppendUnique(CPPDEFINES = ['ROUTING_EP'])
67 if target_os not in ['windows', 'winrt']:
68 liboctbstack_env.AppendUnique(CFLAGS = ['-Wall'])
70 liboctbstack_env.AppendUnique(LIBPATH = [env.get('BUILD_DIR')])
72 if target_os in ['android', 'linux', 'tizen']:
73 liboctbstack_env.PrependUnique(LIBS = ['connectivity_abstraction'])
76 liboctbstack_env.AppendUnique(LIBS = liboctbstack_env['RALIBS'], LIBPATH = liboctbstack_env['RALIBPATH'], RPATH = liboctbstack_env['RARPATH'])
79 liboctbstack_env.AppendUnique(LIBS = ['ra_xmpp'])
81 liboctbstack_env.AppendUnique(LIBS = ['coap', 'm'])
82 liboctbstack_env.PrependUnique(LIBS = ['ocsrm'])
84 if target_os in ['tizen', 'linux']:
85 liboctbstack_env.ParseConfig("pkg-config --cflags --libs uuid")
87 if target_os not in ['android', 'arduino', 'windows', 'winrt']:
88 liboctbstack_env.AppendUnique(LIBS = ['pthread'])
90 if target_os == 'arduino':
91 liboctbstack_env.AppendUnique(CPPDEFINES = ['NDEBUG', 'WITH_ARDUINO'])
92 elif target_os not in ['darwin','ios']:
93 liboctbstack_env.AppendUnique(CFLAGS = ['-fPIC'])
94 if target_os in ['darwin', 'ios']:
95 env.AppendUnique(CPPDEFINES = ['_DARWIN_C_SOURCE'])
96 liboctbstack_env.AppendUnique(CPPDEFINES = ['_DARWIN_C_SOURCE'])
97 liboctbstack_env.AppendUnique(LIBPATH = [env.get('BUILD_DIR')])
98 if target_os not in ['arduino']:
99 liboctbstack_env.AppendUnique(LINKFLAGS = ['-Wl,--no-undefined'])
101 if env.get('SECURED') == '1':
102 liboctbstack_env.AppendUnique(LIBS = ['tinydtls'])
104 if env.get('LOGGING'):
105 liboctbstack_env.AppendUnique(CPPDEFINES = ['TB_LOG'])
107 if env.get('DTLS_WITH_X509') == '1':
108 liboctbstack_env.AppendUnique(CPPDEFINES = ['__WITH_X509__'])
110 if env.get('WITH_RD') == '1':
111 liboctbstack_env.PrependUnique(CPPPATH = ['../../service/resource-directory/include'])
112 liboctbstack_env.AppendUnique(CPPDEFINES = ['-DWITH_RD'])
113 liboctbstack_env.AppendUnique(LIBS = ['resource_directory'])
115 liboctbstack_env.Append(LIBS = ['c_common'])
117 if liboctbstack_env.get('ROUTING') in ['GW', 'EP']:
118 liboctbstack_env.Prepend(LIBS = ['routingmanager'])
120 ######################################################################
121 # Source files and Targets
122 ######################################################################
123 OCTBSTACK_SRC = 'stack/src/'
125 '../../extlibs/cjson/cJSON.c',
126 '../../extlibs/timer/timer.c',
127 OCTBSTACK_SRC + 'ocstack.c',
128 OCTBSTACK_SRC + 'ocpayload.c',
129 OCTBSTACK_SRC + 'ocpayloadparse.c',
130 OCTBSTACK_SRC + 'ocpayloadconvert.c',
131 OCTBSTACK_SRC + 'occlientcb.c',
132 OCTBSTACK_SRC + 'ocresource.c',
133 OCTBSTACK_SRC + 'ocobserve.c',
134 OCTBSTACK_SRC + 'ocserverrequest.c',
135 OCTBSTACK_SRC + 'occollection.c',
136 OCTBSTACK_SRC + 'oicgroup.c',
137 OCTBSTACK_SRC + "rdpayload.c"
140 liboctbstack_src.extend(env['cbor_files'])
142 if target_os in ['arduino','darwin','ios'] :
143 static_liboctbstack = liboctbstack_env.StaticLibrary('octbstack', liboctbstack_src)
144 liboctbstack_env.InstallTarget(static_liboctbstack, 'liboctbstack')
145 liboctbstack_env.UserInstallTargetLib(static_liboctbstack, 'liboctbstack')
146 liboctbstack_env.UserInstallTargetHeader('stack/include/ocstackconfig.h', 'resource', 'ocstackconfig.h')
147 liboctbstack_env.UserInstallTargetHeader('stack/include/octypes.h', 'resource', 'octypes.h')
149 static_liboctbstack = liboctbstack_env.StaticLibrary('octbstack', liboctbstack_src)
150 shared_liboctbstack = liboctbstack_env.SharedLibrary('octbstack', liboctbstack_src)
151 liboctbstack_env.InstallTarget([static_liboctbstack, shared_liboctbstack], 'liboctbstack')
152 liboctbstack_env.UserInstallTargetLib([static_liboctbstack, shared_liboctbstack], 'liboctbstack')
153 liboctbstack_env.UserInstallTargetHeader('stack/include/ocstackconfig.h', 'resource', 'ocstackconfig.h')
154 liboctbstack_env.UserInstallTargetHeader('stack/include/octypes.h', 'resource', 'octypes.h')