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 # 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 liboctbstack_env.Replace(CC = env.get('CXX'))
37 liboctbstack_env.Replace(CFLAGS = env.get('CXXFLAGS'))
39 ######################################################################
41 ######################################################################
42 liboctbstack_env.PrependUnique(CPPPATH = [
43 '../../extlibs/cjson/',
44 '../../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 liboctbstack_env.AppendUnique(LIBS = ['ocsrm'])
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'])
77 liboctbstack_env.AppendUnique(LIBS = ['ra_xmpp'])
79 liboctbstack_env.AppendUnique(LIBS = ['coap', 'm'])
81 if target_os == 'tizen':
82 liboctbstack_env.ParseConfig("pkg-config --cflags --libs uuid")
84 if target_os not in ['android', 'arduino', 'windows', 'winrt']:
85 liboctbstack_env.AppendUnique(LIBS = ['pthread'])
87 if target_os == 'arduino':
88 liboctbstack_env.AppendUnique(CPPDEFINES = ['NDEBUG', 'WITH_ARDUINO'])
89 elif target_os not in ['darwin','ios']:
90 liboctbstack_env.AppendUnique(CFLAGS = ['-fPIC'])
91 if target_os in ['darwin', 'ios']:
92 env.AppendUnique(CPPDEFINES = ['_DARWIN_C_SOURCE'])
93 liboctbstack_env.AppendUnique(CPPDEFINES = ['_DARWIN_C_SOURCE'])
94 liboctbstack_env.AppendUnique(LIBPATH = [env.get('BUILD_DIR')])
95 if target_os not in ['arduino']:
96 liboctbstack_env.AppendUnique(LINKFLAGS = ['-Wl,--no-undefined'])
98 if env.get('SECURED') == '1':
99 liboctbstack_env.AppendUnique(LIBS = ['tinydtls'])
101 if env.get('LOGGING'):
102 liboctbstack_env.AppendUnique(CPPDEFINES = ['TB_LOG'])
104 liboctbstack_env.Append(LIBS = ['c_common'])
106 if liboctbstack_env.get('ROUTING') in ['GW', 'EP']:
107 liboctbstack_env.Prepend(LIBS = ['routingmanager'])
109 ######################################################################
110 # Source files and Targets
111 ######################################################################
112 OCTBSTACK_SRC = 'stack/src/'
114 '../../extlibs/cjson/cJSON.c',
115 '../../extlibs/timer/timer.c',
116 OCTBSTACK_SRC + 'ocstack.c',
117 OCTBSTACK_SRC + 'ocpayload.c',
118 OCTBSTACK_SRC + 'ocpayloadparse.c',
119 OCTBSTACK_SRC + 'ocpayloadconvert.c',
120 OCTBSTACK_SRC + 'occlientcb.c',
121 OCTBSTACK_SRC + 'ocresource.c',
122 OCTBSTACK_SRC + 'ocobserve.c',
123 OCTBSTACK_SRC + 'ocserverrequest.c',
124 OCTBSTACK_SRC + 'occollection.c',
125 OCTBSTACK_SRC + 'oicgroup.c',
126 'logger/src/logger.c',
127 'ocrandom/src/ocrandom.c'
130 liboctbstack_src.extend(env['cbor_files'])
132 if target_os in ['arduino','darwin','ios'] :
133 static_liboctbstack = liboctbstack_env.StaticLibrary('octbstack', liboctbstack_src)
134 liboctbstack_env.InstallTarget(static_liboctbstack, 'liboctbstack')
135 liboctbstack_env.UserInstallTargetLib(static_liboctbstack, 'liboctbstack')
136 liboctbstack_env.UserInstallTargetHeader('stack/include/ocstackconfig.h', 'resource', 'ocstackconfig.h')
137 liboctbstack_env.UserInstallTargetHeader('stack/include/octypes.h', 'resource', 'octypes.h')
139 static_liboctbstack = liboctbstack_env.StaticLibrary('octbstack', liboctbstack_src)
140 shared_liboctbstack = liboctbstack_env.SharedLibrary('octbstack', liboctbstack_src)
141 liboctbstack_env.InstallTarget([static_liboctbstack, shared_liboctbstack], 'liboctbstack')
142 liboctbstack_env.UserInstallTargetLib([static_liboctbstack, shared_liboctbstack], 'liboctbstack')
143 liboctbstack_env.UserInstallTargetHeader('stack/include/ocstackconfig.h', 'resource', 'ocstackconfig.h')
144 liboctbstack_env.UserInstallTargetHeader('stack/include/octypes.h', 'resource', 'octypes.h')
145 liboctbstack_env.UserInstallTargetHeader('stack/include/ocstack.h', 'resource', 'ocstack.h')