Imported Upstream version 0.9.1
[platform/upstream/iotivity.git] / extlibs / tinydtls / SConscript
1 # *****************************************************************
2 #
3 #  Copyright 2015 Samsung Electronics 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 # Tinydtls build script
22 ##
23
24 Import('env')
25
26 print "Reading Tinydtls folder script"
27
28 target_os = env.get('TARGET_OS')
29
30 if(target_os) == 'arduino':
31         env.Replace(CFLAGS = env.get('CXXFLAGS'))
32
33 root_dir = './'
34
35 tinydtls_src_path = root_dir
36
37 env.AppendUnique(CPPPATH = [root_dir])
38 env.AppendUnique(CPPPATH = [root_dir+'aes/'])
39 env.AppendUnique(CPPPATH = [root_dir+'ecc/'])
40 env.AppendUnique(CPPPATH = [root_dir+'sha2/'])
41
42 if target_os not in ['arduino', 'windows', 'winrt']:
43         env.AppendUnique(CPPDEFINES = ['HAVE_SYS_TIME_H'])
44
45 ######################################################################
46 # Source files and Target(s)
47 ######################################################################
48 tinydtls_src = [
49                 'dtls.c',
50                 'crypto.c',
51                 'ccm.c',
52                 'hmac.c',
53                 'netq.c',
54                 'peer.c',
55                 'dtls_time.c',
56                 'session.c',
57                 'aes/rijndael.c',
58                 'ecc/ecc.c',
59                 'sha2/sha2.c',
60         ]
61
62 env.AppendUnique(TINYDTLS_SRC = tinydtls_src)
63
64 if not env.get('RELEASE'):
65         if(target_os) not in ['android', 'arduino']:
66                 env.AppendUnique(TINYDTLS_SRC = ['debug.c'])
67 else:
68         env.AppendUnique(CPPDEFINES = ['NDEBUG'])
69
70 env.AppendUnique(CPPDEFINES = ['DTLSV12',  'WITH_SHA256', 'DTLS_CHECK_CONTENTTYPE'])
71
72 libtinydtls = env.StaticLibrary('libtinydtls', env.get('TINYDTLS_SRC'), OBJPREFIX='libtinydtls_')
73
74 ######################################################################
75 # Generate tinydtls samples
76 #
77 # Note:
78 # Currently there is a bug in debug.h/debug.c which fails compilation
79 # of tinydtls samples in release mode. This bug is being tracked in 
80 # IOT-395
81 ######################################################################
82 if not env.get('RELEASE'):
83         samples_env = env.Clone()
84
85         if target_os not in ['arduino', 'windows', 'winrt']:
86                 samples_env.AppendUnique(CPPDEFINES = ['_GNU_SOURCE'])
87
88         dtlsserver = samples_env.Program('dtls-server', ['tests/dtls-server.c'])
89         dtlsclient = samples_env.Program('dtls-client', ['tests/dtls-client.c'])
90
91         samples_env.AppendUnique(LIBPATH = [env.get('BUILD_DIR')])
92         samples_env.PrependUnique(LIBS = ['tinydtls'])
93
94         Alias("samples", [dtlsserver, dtlsclient])
95         samples_env.AppendTarget('samples')
96
97 env.InstallTarget(libtinydtls, 'libtinydtls');
98