Merging security-M3 to master
[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 # As in the source code, it includes arduino Time library (C++)
33 # It requires compile the .c with g++
34 if target_os == 'arduino':
35         liboctbstack_env.Replace(CC = env.get('CXX'))
36         liboctbstack_env.Replace(CFLAGS = env.get('CXXFLAGS'))
37
38 ######################################################################
39 # Build flags
40 ######################################################################
41 liboctbstack_env.PrependUnique(CPPPATH = [
42                 '../../extlibs/cjson/',
43                 '../../extlibs/timer/',
44                 'logger/include',
45                 'ocrandom/include',
46                 'stack/include',
47                 'stack/include/internal',
48                 '../oc_logger/include',
49                 'connectivity/lib/libcoap-4.1.1',
50                 'connectivity/inc',
51                 'connectivity/api',
52                 'connectivity/external/inc',
53                 'security/include',
54                 'security/include/internal',
55                 ])
56
57 liboctbstack_env.AppendUnique(LIBS = ['ocsrm'])
58
59 if target_os not in ['arduino', 'windows', 'winrt']:
60         liboctbstack_env.AppendUnique(CPPDEFINES  = ['WITH_POSIX'])
61         liboctbstack_env.AppendUnique(CFLAGS = ['-std=c99'])
62
63 if target_os not in ['windows', 'winrt']:
64         liboctbstack_env.AppendUnique(CFLAGS = ['-Wall'])
65
66 liboctbstack_env.AppendUnique(LIBPATH = [env.get('BUILD_DIR')])
67
68 if target_os in ['android', 'linux', 'tizen']:
69         liboctbstack_env.AppendUnique(LIBS = ['connectivity_abstraction'])
70 liboctbstack_env.AppendUnique(LIBS = ['coap', 'm'])
71
72 if target_os == 'tizen':
73     liboctbstack_env.ParseConfig("pkg-config --cflags --libs uuid")
74
75 if target_os not in ['android', 'arduino', 'windows', 'winrt']:
76         liboctbstack_env.AppendUnique(LIBS = ['pthread'])
77
78 if target_os == 'arduino':
79         liboctbstack_env.AppendUnique(CPPDEFINES = ['NDEBUG', 'WITH_ARDUINO'])
80 elif target_os not in ['darwin','ios']:
81         liboctbstack_env.AppendUnique(CFLAGS = ['-fPIC'])
82 if target_os in ['darwin', 'ios']:
83         env.AppendUnique(CPPDEFINES = ['_DARWIN_C_SOURCE'])
84         liboctbstack_env.AppendUnique(CPPDEFINES = ['_DARWIN_C_SOURCE'])
85         liboctbstack_env.AppendUnique(LIBPATH = [env.get('BUILD_DIR')])
86 if target_os not in ['arduino']:
87         liboctbstack_env.AppendUnique(LINKFLAGS = ['-Wl,--no-undefined'])
88
89 if env.get('SECURED') == '1':
90         liboctbstack_env.AppendUnique(LIBS = ['tinydtls'])
91
92 if env.get('LOGGING'):
93         liboctbstack_env.AppendUnique(CPPDEFINES = ['TB_LOG'])
94
95 liboctbstack_env.Append(LIBS = ['c_common'])
96
97 ######################################################################
98 # Source files and Targets
99 ######################################################################
100 OCTBSTACK_SRC = 'stack/src/'
101 liboctbstack_src = [
102         '../../extlibs/cjson/cJSON.c',
103         '../../extlibs/timer/timer.c',
104         OCTBSTACK_SRC + 'ocstack.c',
105         OCTBSTACK_SRC + 'occlientcb.c',
106         OCTBSTACK_SRC + 'ocresource.c',
107         OCTBSTACK_SRC + 'ocobserve.c',
108         OCTBSTACK_SRC + 'ocserverrequest.c',
109         OCTBSTACK_SRC + 'occollection.c',
110         OCTBSTACK_SRC + 'oicgroup.c',
111         'logger/src/logger.c',
112         'ocrandom/src/ocrandom.c'
113         ]
114
115 if target_os in ['arduino','darwin','ios'] :
116         static_liboctbstack = liboctbstack_env.StaticLibrary('octbstack', liboctbstack_src)
117         liboctbstack_env.InstallTarget(static_liboctbstack, 'liboctbstack')
118 else:
119         static_liboctbstack = liboctbstack_env.StaticLibrary('octbstack', liboctbstack_src)
120         shared_liboctbstack = liboctbstack_env.SharedLibrary('octbstack', liboctbstack_src)
121         liboctbstack_env.InstallTarget([static_liboctbstack, shared_liboctbstack], 'liboctbstack')
122