TLS support
[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 import os
26
27 lib_env = env.Clone()
28 SConscript('#resource/third_party_libs.scons', 'lib_env')
29
30 libocsrm_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         libocsrm_env.Replace(CC = env.get('CXX'))
37         libocsrm_env.Replace(CFLAGS = env.get('CXXFLAGS'))
38
39 ######################################################################
40 # Build flags
41 ######################################################################
42 libocsrm_env.PrependUnique(CPPPATH = [
43                 '../../../extlibs/cjson/',
44                 '../../../extlibs/tinydtls/',
45                 '../logger/include',
46                 '../../c_common/ocrandom/include',
47                 '../stack/include',
48                 '../stack/include/internal',
49                 '../../oc_logger/include',
50                 '../connectivity/lib/libcoap-4.1.1',
51                 '../connectivity/external/inc',
52                 '../connectivity/common/inc',
53                 '../connectivity/inc/pkix',
54                 '../connectivity/inc',
55                 '../connectivity/api',
56                 '../security/include',
57                 '../security/include/internal',
58                 '../security/provisioning/include'
59                 ])
60
61 if target_os not in ['arduino', 'windows']:
62         libocsrm_env.AppendUnique(CPPDEFINES  = ['WITH_POSIX'])
63         libocsrm_env.AppendUnique(CFLAGS = ['-std=c99', '-Wall'])
64
65 libocsrm_env.AppendUnique(LIBPATH = [env.get('BUILD_DIR')])
66 libocsrm_env.AppendUnique(LIBS = ['coap'])
67
68 if target_os == 'arduino':
69         libocsrm_env.AppendUnique(CPPDEFINES = ['NDEBUG', 'WITH_ARDUINO'])
70 elif target_os not in ['windows', 'msys_nt']:
71         libocsrm_env.AppendUnique(CFLAGS = ['-fPIC'])
72         libocsrm_env.AppendUnique(LIBS = ['m'])
73
74 if target_os in ['windows', 'msys_nt']:
75         libocsrm_env.AppendUnique(LIBPATH = [os.path.join(env.get('BUILD_DIR'), 'resource', 'oc_logger')])
76
77 if target_os in ['darwin', 'ios']:
78         libocsrm_env.AppendUnique(CPPDEFINES = ['_DARWIN_C_SOURCE'])
79         libocsrm_env.AppendUnique(LIBPATH = [env.get('BUILD_DIR')])
80         libocsrm_env.AppendUnique(LIBS = ['coap'])
81
82 if env.get('LOGGING'):
83         libocsrm_env.AppendUnique(CPPDEFINES = ['TB_LOG'])
84
85 if env.get('DTLS_WITH_X509') == '1':
86         libocsrm_env.AppendUnique(CPPDEFINES = ['__WITH_X509__'])
87
88 ######################################################################
89 # Source files and Targets
90 ######################################################################
91 OCSRM_SRC = 'src/'
92 libocsrm_src = [
93         OCSRM_SRC + 'secureresourcemanager.c',
94         OCSRM_SRC + 'resourcemanager.c',
95         OCSRM_SRC + 'aclresource.c',
96         OCSRM_SRC + 'verresource.c',
97         OCSRM_SRC + 'amaclresource.c',
98         OCSRM_SRC + 'amsmgr.c',
99         OCSRM_SRC + 'pstatresource.c',
100         OCSRM_SRC + 'doxmresource.c',
101         OCSRM_SRC + 'credresource.c',
102         OCSRM_SRC + 'svcresource.c',
103         OCSRM_SRC + 'pconfresource.c',
104         OCSRM_SRC + 'dpairingresource.c',
105         OCSRM_SRC + 'policyengine.c',
106         OCSRM_SRC + 'psinterface.c',
107         OCSRM_SRC + 'srmresourcestrings.c',
108         OCSRM_SRC + 'srmutility.c',
109         OCSRM_SRC + 'iotvticalendar.c',
110         OCSRM_SRC + 'base64.c',
111         OCSRM_SRC + 'directpairing.c'
112         ]
113
114 if env.get('SECURED') == '1':
115         libocsrm_src  = libocsrm_src + [OCSRM_SRC + 'oxmpincommon.c', OCSRM_SRC + 'pbkdf2.c']
116
117 if target_os in ['windows', 'msys_nt']:
118         libocsrm_src  = libocsrm_src + [OCSRM_SRC + 'strptime.c']
119
120 if (env.get('DTLS_WITH_X509') == '1' or env.get('WITH_TCP') == True) and env.get('SECURED') == '1':
121         crl_src = [OCSRM_SRC + 'crlresource.c']
122         libocsrm_src  = libocsrm_src + crl_src
123
124 libocsrm_conf = Configure(libocsrm_env)
125 if libocsrm_conf.CheckFunc('strptime'):
126         libocsrm_conf.env.AppendUnique(CPPDEFINES = ['HAVE_STRPTIME'])
127 libocsrm_env = libocsrm_conf.Finish()
128
129 libocsrm = libocsrm_env.StaticLibrary('ocsrm', libocsrm_src)
130
131 libocsrm_env.InstallTarget(libocsrm, 'ocsrm')
132
133 if target_os in ['linux', 'android', 'tizen', 'msys_nt', 'windows'] and env.get('SECURED') == '1':
134         SConscript('provisioning/SConscript')
135
136 if target_os in ['linux'] and env.get('SECURED') == '1':
137         SConscript('tool/SConscript')