# ***************************************************************** # # Copyright 2015 Samsung Electronics All Rights Reserved. # # # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # # *****************************************************************/ ## # Tinydtls build script ## Import('env') print "Reading Tinydtls folder script" target_os = env.get('TARGET_OS') if(target_os) == 'arduino': env.Replace(CFLAGS = env.get('CXXFLAGS')) root_dir = './' tinydtls_src_path = root_dir dtls_env = env.Clone() dtls_env.PrependUnique(CPPPATH = [root_dir]) dtls_env.AppendUnique(CPPPATH = [root_dir+'aes/']) dtls_env.AppendUnique(CPPPATH = [root_dir+'ecc/']) dtls_env.AppendUnique(CPPPATH = [root_dir+'sha2/']) ###################################################################### # Source files and Target(s) ###################################################################### tinydtls_src = [ 'dtls.c', 'crypto.c', 'ccm.c', 'hmac.c', 'netq.c', 'peer.c', 'dtls_time.c', 'session.c', 'aes/rijndael.c', 'ecc/ecc.c', 'sha2/sha2.c', ] if not dtls_env.get('RELEASE'): if(target_os) not in ['arduino']: tinydtls_src += ['debug.c'] else: dtls_env.AppendUnique(CPPDEFINES = ['NDEBUG']) else: dtls_env.AppendUnique(CPPDEFINES = ['NDEBUG']) dtls_env.AppendUnique(CPPDEFINES = ['DTLSV12', 'WITH_SHA256', 'DTLS_CHECK_CONTENTTYPE', 'SHA2_USE_INTTYPES_H']) env.AppendUnique(CPPDEFINES = ['SHA2_USE_INTTYPES_H']) libtinydtls = dtls_env.StaticLibrary('tinydtls', tinydtls_src, OBJPREFIX='libtinydtls_') ###################################################################### # Generate tinydtls samples # # Note: # Currently there is a bug in debug.h/debug.c which fails compilation # of tinydtls samples in release mode. This bug is being tracked in # IOT-395 ###################################################################### if not env.get('RELEASE'): samples_env = dtls_env.Clone() if target_os not in ['arduino', 'windows']: samples_env.AppendUnique(CPPDEFINES = ['_GNU_SOURCE']) dtlsserver = samples_env.Program('dtls-server', ['tests/dtls-server.c']) dtlsclient = samples_env.Program('dtls-client', ['tests/dtls-client.c']) samples_env.AppendUnique(LIBPATH = [env.get('BUILD_DIR')]) samples_env.PrependUnique(LIBS = ['tinydtls']) if target_os in ['windows', 'msys_nt']: samples_env.AppendUnique(LIBS = ['ws2_32', 'iphlpapi', 'advapi32', 'bcrypt']) Alias("samples", [dtlsserver, dtlsclient]) samples_env.AppendTarget('samples') dtls_env.InstallTarget(libtinydtls, 'tinydtls');