1 # *****************************************************************
3 # Copyright 2015 Samsung Electronics All Rights Reserved.
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
11 # http://www.apache.org/licenses/LICENSE-2.0
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.
19 # *****************************************************************/
21 # Tinydtls build script
26 print "Reading Tinydtls folder script"
28 target_os = env.get('TARGET_OS')
30 if(target_os) == 'arduino':
31 env.Replace(CFLAGS = env.get('CXXFLAGS'))
34 tinydtls_src_path = root_dir
36 dtls_env = env.Clone()
38 dtls_env.PrependUnique(CPPPATH = [root_dir])
39 dtls_env.AppendUnique(CPPPATH = [root_dir+'aes/'])
40 dtls_env.AppendUnique(CPPPATH = [root_dir+'ecc/'])
41 dtls_env.AppendUnique(CPPPATH = [root_dir+'sha2/'])
43 if target_os not in ['arduino', 'windows', 'winrt']:
44 dtls_env.AppendUnique(CPPDEFINES = ['HAVE_SYS_TIME_H'])
46 ######################################################################
47 # Source files and Target(s)
48 ######################################################################
63 dtls_env.AppendUnique(TINYDTLS_SRC = tinydtls_src)
65 if not dtls_env.get('RELEASE'):
66 if(target_os) not in ['arduino']:
67 dtls_env.AppendUnique(TINYDTLS_SRC = ['debug.c'])
69 dtls_env.AppendUnique(CPPDEFINES = ['NDEBUG'])
71 dtls_env.AppendUnique(CPPDEFINES = ['NDEBUG'])
73 dtls_env.AppendUnique(CPPDEFINES = ['DTLSV12', 'WITH_SHA256', 'DTLS_CHECK_CONTENTTYPE', 'SHA2_USE_INTTYPES_H'])
76 libtinydtls = dtls_env.StaticLibrary('libtinydtls', dtls_env.get('TINYDTLS_SRC'), OBJPREFIX='libtinydtls_')
78 ######################################################################
79 # Generate tinydtls samples
82 # Currently there is a bug in debug.h/debug.c which fails compilation
83 # of tinydtls samples in release mode. This bug is being tracked in
85 ######################################################################
86 if not env.get('RELEASE'):
87 samples_env = dtls_env.Clone()
89 if target_os not in ['arduino', 'windows', 'winrt']:
90 samples_env.AppendUnique(CPPDEFINES = ['_GNU_SOURCE'])
92 dtlsserver = samples_env.Program('dtls-server', ['tests/dtls-server.c'])
93 dtlsclient = samples_env.Program('dtls-client', ['tests/dtls-client.c'])
95 samples_env.AppendUnique(LIBPATH = [env.get('BUILD_DIR')])
96 samples_env.PrependUnique(LIBS = ['tinydtls'])
98 Alias("samples", [dtlsserver, dtlsclient])
100 samples_env.AppendTarget('samples')
102 dtls_env.InstallTarget(libtinydtls, 'libtinydtls');