Imported Upstream version 0.9.2
[platform/upstream/iotivity.git] / resource / csdk / security / SConscript
1 # //******************************************************************
2 # //
3 # // Copyright 2015 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 # libocsrm (share library) build script
22 ##
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 libocsrm_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         libocsrm_env.Replace(CC = env.get('CXX'))
36         libocsrm_env.Replace(CFLAGS = env.get('CXXFLAGS'))
37
38 ######################################################################
39 # Build flags
40 ######################################################################
41 libocsrm_env.PrependUnique(CPPPATH = [
42                 '../../../extlibs/cjson/',
43 #               '../../../extlibs/tinydtls/',
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/external/inc',
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         libocsrm_env.AppendUnique(CPPDEFINES  = ['WITH_POSIX'])
59         libocsrm_env.AppendUnique(CFLAGS = ['-std=c99'])
60         libocsrm_env.AppendUnique(CPPDEFINES = ['HAVE_STRINGS_H'])
61
62 if target_os not in ['windows', 'winrt']:
63         libocsrm_env.AppendUnique(CFLAGS = ['-Wall'])
64
65 libocsrm_env.AppendUnique(LIBPATH = [env.get('BUILD_DIR')])
66 libocsrm_env.AppendUnique(LIBS = ['coap', 'm'])
67
68 if target_os == 'arduino':
69         libocsrm_env.AppendUnique(CPPDEFINES = ['NDEBUG', 'WITH_ARDUINO'])
70 else:
71         libocsrm_env.AppendUnique(CFLAGS = ['-fPIC'])
72
73 if target_os in ['darwin', 'ios']:
74         libocsrm_env.AppendUnique(CPPDEFINES = ['_DARWIN_C_SOURCE'])
75         libocsrm_env.AppendUnique(LIBPATH = [env.get('BUILD_DIR')])
76         libocsrm_env.AppendUnique(LIBS = ['coap'])
77
78 if not env.get('RELEASE'):
79         libocsrm_env.AppendUnique(CPPDEFINES = ['TB_LOG'])
80
81 ######################################################################
82 # Source files and Targets
83 ######################################################################
84 OCSRM_SRC = 'src/'
85 libocsrm_src = [
86         OCSRM_SRC + 'secureresourcemanager.c',
87         OCSRM_SRC + 'resourcemanager.c',
88         OCSRM_SRC + 'aclresource.c',
89         OCSRM_SRC + 'pstatresource.c',
90         OCSRM_SRC + 'doxmresource.c',
91         OCSRM_SRC + 'credresource.c',
92         OCSRM_SRC + 'policyengine.c',
93         OCSRM_SRC + 'psinterface.c',
94         OCSRM_SRC + 'srmresourcestrings.c',
95         OCSRM_SRC + 'srmutility.c',
96         OCSRM_SRC + 'base64.c'
97         ]
98
99 libocsrm = libocsrm_env.StaticLibrary('libocsrm', libocsrm_src)
100
101 libocsrm_env.InstallTarget(libocsrm, 'libocsrm')
102 libocsrm_env.UserInstallTargetLib(libocsrm, 'libocsrm')
103
104 if env.get('SECURED') == '1':
105         SConscript('provisioning/SConscript')
106