Move unittest file to test folder to sync with existing folder structure
[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
25 Import('env')
26
27 lib_env = env.Clone()
28 SConscript(env.get('SRC_DIR') + '/resource/third_party_libs.scons', 'lib_env')
29
30 liboctbstack_env = lib_env.Clone()
31
32 target_os = env.get('TARGET_OS')
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'))
38
39 ######################################################################
40 # Build flags
41 ######################################################################
42 liboctbstack_env.PrependUnique(CPPPATH = [
43                 '../../extlibs/cjson/',
44                 'logger/include',
45                 'ocrandom/include',
46                 'ocmalloc/include',
47                 'stack/include',
48                 'stack/include/internal',
49                 '../oc_logger/include',
50                 'connectivity/lib/libcoap-4.1.1',
51                 'connectivity/inc',
52                 'connectivity/api',
53                 'security/include',
54                 'security/include/internal',
55                 ])
56
57 if target_os not in ['arduino', 'windows', 'winrt']:
58         liboctbstack_env.AppendUnique(CPPDEFINES  = ['WITH_POSIX'])
59         liboctbstack_env.AppendUnique(CFLAGS = ['-std=c99'])
60
61 if target_os not in ['windows', 'winrt']:
62         liboctbstack_env.AppendUnique(CFLAGS = ['-Wall'])
63
64 liboctbstack_env.AppendUnique(LIBPATH = [env.get('BUILD_DIR')])
65 liboctbstack_env.AppendUnique(LIBS = ['coap', 'm'])
66
67 liboctbstack_env.AppendUnique(CPPDEFINES = ['CA_SEC_MERGE_WORKAROUND'])
68
69 if target_os == 'arduino':
70         liboctbstack_env.AppendUnique(CPPDEFINES = ['NDEBUG', 'WITH_ARDUINO'])
71 else:
72         liboctbstack_env.AppendUnique(CFLAGS = ['-fPIC'])
73
74 if target_os in ['darwin', 'ios']:
75         liboctbstack_env.AppendUnique(CPPDEFINES = ['_DARWIN_C_SOURCE'])
76         liboctbstack_env.AppendUnique(LIBPATH = [env.get('BUILD_DIR')])
77         liboctbstack_env.AppendUnique(LIBS = ['coap'])
78
79 if env.get('LOGGING'):
80         liboctbstack_env.AppendUnique(CPPDEFINES = ['TB_LOG'])
81
82 ######################################################################
83 # Source files and Targets
84 ######################################################################
85 OCTBSTACK_SRC = 'stack/src/'
86 liboctbstack_src = [
87         '../../extlibs/cjson/cJSON.c',
88         OCTBSTACK_SRC + 'ocstack.c',
89         OCTBSTACK_SRC + 'occlientcb.c',
90         OCTBSTACK_SRC + 'ocresource.c',
91         OCTBSTACK_SRC + 'ocobserve.c',
92         OCTBSTACK_SRC + 'ocserverrequest.c',
93         OCTBSTACK_SRC + 'occollection.c',
94         OCTBSTACK_SRC + 'oicgroup.c',
95         'security/src/ocsecurity.c',
96         'logger/src/logger.c',
97         'ocrandom/src/ocrandom.c',
98         'ocmalloc/src/ocmalloc.c'
99         ]
100 if target_os == 'arduino':
101         liboctbstack = liboctbstack_env.StaticLibrary('octbstack', liboctbstack_src)
102 else:
103         liboctbstack = liboctbstack_env.SharedLibrary('octbstack', liboctbstack_src)
104
105 liboctbstack_env.InstallTarget(liboctbstack, 'liboctbstack')
106