2 # libcoap (share library) build script
7 libcoap_env = env.Clone()
9 target_os = env.get('TARGET_OS')
10 # As in the source code(C) includes arduino Time library head file(C++)
11 # It requires compile the .c with g++
12 if target_os == 'arduino':
13 libcoap_env.Replace(CC = env.get('CXX'))
14 libcoap_env.Replace(CFLAGS = env.get('CXXFLAGS'))
16 ######################################################################
18 ######################################################################
19 libcoap_env.PrependUnique(CPPPATH = [
20 '../ocsocket/include',
21 '../ocmalloc/include',
23 '../ocrandom/include',
25 '../../oc_logger/include'
28 if target_os not in ['arduino', 'windows', 'winrt']:
29 libcoap_env.AppendUnique(CPPDEFINES = ['WITH_POSIX'])
30 libcoap_env.AppendUnique(CFLAGS = ['-std=gnu99', '-fPIC'])
32 if target_os not in ['windows', 'winrt']:
33 libcoap_env.AppendUnique(CFLAGS = ['-Wall', '-ffunction-sections',
34 '-fdata-sections', '-fno-exceptions'])
36 if target_os == 'android':
37 libcoap_env.AppendUnique(LIBS = ['log'])
39 if target_os == 'arduino':
40 libcoap_env.AppendUnique(CPPDEFINES = ['NDEBUG', 'WITH_ARDUINO'])
42 if target_os in ['darwin', 'ios']:
43 libcoap_env.AppendUnique(CPPDEFINES = ['_DARWIN_C_SOURCE'])
45 if not env.get('RELEASE'):
46 libcoap_env.AppendUnique(CPPDEFINES = ['TB_LOG'])
48 ######################################################################
49 # Source files and Target(s)
50 ######################################################################
65 # '../logger/src/logger.c',
66 # '../ocrandom/src/ocrandom.c',
67 # '../ocmalloc/src/ocmalloc.c',
68 # '../../oc_logger/c/oc_logger.c',
69 # '../../oc_logger/c/oc_console_logger.c'
72 if target_os == 'arduino':
73 libcoap = libcoap_env.StaticLibrary('libcoap', libcoap_src, OBJPREFIX='libcoap_')
75 libcoap = libcoap_env.SharedLibrary('libcoap', libcoap_src, OBJPREFIX='libcoap_')
77 libcoap_env.InstallTarget(libcoap, 'libcoap')