Remote Access base on libstrophe
[platform/upstream/iotivity.git] / resource / csdk / SConscript
1 #******************************************************************
2 #
3 # Copyright 2014 Intel Mobile Communications GmbH All Rights Reserved.
4 #
5 #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
6 #
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
10 #
11 #      http://www.apache.org/licenses/LICENSE-2.0
12 #
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.
18 #
19 #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
20
21 ##
22 # liboctbstack (share library) build script
23 ##
24 Import('env')
25
26 lib_env = env.Clone()
27 SConscript(env.get('SRC_DIR') + '/resource/third_party_libs.scons', 'lib_env')
28
29 liboctbstack_env = lib_env.Clone()
30
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'))
39
40 ######################################################################
41 # Build flags
42 ######################################################################
43 liboctbstack_env.PrependUnique(CPPPATH = [
44                 '../../extlibs/cjson/',
45                 '../../extlibs/timer/',
46                 'logger/include',
47                 'ocrandom/include',
48                 'stack/include',
49                 'stack/include/internal',
50                 '../oc_logger/include',
51                 'connectivity/lib/libcoap-4.1.1',
52                 'connectivity/inc',
53                 'connectivity/api',
54                 'connectivity/external/inc',
55                 'security/include',
56                 'security/include/internal',
57                 ])
58
59 liboctbstack_env.AppendUnique(LIBS = ['ocsrm'])
60
61 if target_os not in ['arduino', 'windows', 'winrt']:
62         liboctbstack_env.AppendUnique(CPPDEFINES  = ['WITH_POSIX'])
63         liboctbstack_env.AppendUnique(CFLAGS = ['-std=c99'])
64
65 if target_os not in ['windows', 'winrt']:
66         liboctbstack_env.AppendUnique(CFLAGS = ['-Wall'])
67
68 liboctbstack_env.AppendUnique(LIBPATH = [env.get('BUILD_DIR')])
69
70 if target_os in ['android', 'linux', 'tizen']:
71         liboctbstack_env.PrependUnique(LIBS = ['connectivity_abstraction'])
72         if with_ra_ibb:
73                 liboctbstack_env.AppendUnique(LIBS = liboctbstack_env['RALIBS'], LIBPATH = liboctbstack_env['RALIBPATH'], RPATH = liboctbstack_env['RARPATH'])
74         else :
75                 if with_ra:
76                         liboctbstack_env.AppendUnique(LIBS = ['ra_xmpp'])
77 liboctbstack_env.AppendUnique(LIBS = ['coap', 'm'])
78
79 if target_os == 'tizen':
80     liboctbstack_env.ParseConfig("pkg-config --cflags --libs uuid")
81
82 if target_os not in ['android', 'arduino', 'windows', 'winrt']:
83         liboctbstack_env.AppendUnique(LIBS = ['pthread'])
84
85 if target_os == 'arduino':
86         liboctbstack_env.AppendUnique(CPPDEFINES = ['NDEBUG', 'WITH_ARDUINO'])
87 elif target_os not in ['darwin','ios']:
88         liboctbstack_env.AppendUnique(CFLAGS = ['-fPIC'])
89 if target_os in ['darwin', 'ios']:
90         env.AppendUnique(CPPDEFINES = ['_DARWIN_C_SOURCE'])
91         liboctbstack_env.AppendUnique(CPPDEFINES = ['_DARWIN_C_SOURCE'])
92         liboctbstack_env.AppendUnique(LIBPATH = [env.get('BUILD_DIR')])
93 if target_os not in ['arduino']:
94         liboctbstack_env.AppendUnique(LINKFLAGS = ['-Wl,--no-undefined'])
95
96 if env.get('SECURED') == '1':
97         liboctbstack_env.AppendUnique(LIBS = ['tinydtls'])
98
99 if env.get('LOGGING'):
100         liboctbstack_env.AppendUnique(CPPDEFINES = ['TB_LOG'])
101
102 liboctbstack_env.Append(LIBS = ['c_common'])
103
104 ######################################################################
105 # Source files and Targets
106 ######################################################################
107 OCTBSTACK_SRC = 'stack/src/'
108 liboctbstack_src = [
109         '../../extlibs/cjson/cJSON.c',
110         '../../extlibs/timer/timer.c',
111         OCTBSTACK_SRC + 'ocstack.c',
112         OCTBSTACK_SRC + 'ocpayload.c',
113         OCTBSTACK_SRC + 'ocpayloadparse.c',
114         OCTBSTACK_SRC + 'ocpayloadconvert.c',
115         OCTBSTACK_SRC + 'occlientcb.c',
116         OCTBSTACK_SRC + 'ocresource.c',
117         OCTBSTACK_SRC + 'ocobserve.c',
118         OCTBSTACK_SRC + 'ocserverrequest.c',
119         OCTBSTACK_SRC + 'occollection.c',
120         OCTBSTACK_SRC + 'oicgroup.c',
121         'logger/src/logger.c',
122         'ocrandom/src/ocrandom.c'
123         ]
124
125 liboctbstack_src.extend(env['cbor_files'])
126
127 if target_os in ['arduino','darwin','ios'] :
128         static_liboctbstack = liboctbstack_env.StaticLibrary('octbstack', liboctbstack_src)
129         liboctbstack_env.InstallTarget(static_liboctbstack, 'liboctbstack')
130         liboctbstack_env.UserInstallTargetLib(static_liboctbstack, 'liboctbstack')
131 else:
132         static_liboctbstack = liboctbstack_env.StaticLibrary('octbstack', liboctbstack_src)
133         shared_liboctbstack = liboctbstack_env.SharedLibrary('octbstack', liboctbstack_src)
134         liboctbstack_env.InstallTarget([static_liboctbstack, shared_liboctbstack], 'liboctbstack')
135         liboctbstack_env.UserInstallTargetLib([static_liboctbstack, shared_liboctbstack], 'liboctbstack')
136