2 # libcoap (share library) build script
7 libcoap_env = env.Clone()
9 target_os = env.get('TARGET_OS')
10 ca_transport = env.get('TARGET_TRANSPORT')
11 with_tcp = env.get('WITH_TCP')
12 # As in the source code(C) includes arduino Time library head file(C++)
13 # It requires compile the .c with g++
14 if target_os == 'arduino':
15 libcoap_env.Replace(CFLAGS = env.get('CXXFLAGS'))
17 ######################################################################
19 ######################################################################
20 libcoap_env.PrependUnique(CPPPATH = [
22 env.get('ARDUINO_HOME')+'/',
23 env.get('ARDUINO_HOME')+'/hardware/arduino/avr/cores/arduino',
24 env.get('ARDUINO_HOME')+'/hardware/tools/avr/avr/include/',
25 env.get('ARDUINO_HOME')+'/hardware/arduino/avr/variants/mega',
26 env.get('ARDUINO_HOME')+'/libraries/Time/Time',
27 env.get('ARDUINO_HOME')+'/libraries/TimedAction',
28 env.get('ARDUINO_HOME')+'/hardware/arduino/avr/libraries/SPI',
29 env.get('ARDUINO_HOME')+'/libraries/Ethernet/src/utility',
32 if target_os not in ['arduino', 'windows', 'winrt']:
33 libcoap_env.AppendUnique(CPPDEFINES = ['WITH_POSIX', '_DEFAULT_SOURCE'])
34 libcoap_env.AppendUnique(CFLAGS = ['-std=gnu99','-fPIC'])
36 if target_os not in ['windows', 'winrt']:
37 libcoap_env.AppendUnique(CFLAGS = ['-Wall', '-ffunction-sections',
38 '-fdata-sections', '-fno-exceptions'])
40 if target_os in ['linux', 'tizen', 'android', 'ios']:
42 libcoap_env.AppendUnique(CPPDEFINES = ['WITH_TCP'])
44 if target_os in ['linux', 'tizen', 'android', 'arduino']:
45 libcoap_env.AppendUnique(LIBS = ['log'])
46 if (('BLE' in ca_transport) or ('BT' in ca_transport) or ('ALL' in ca_transport)):
47 libcoap_env.AppendUnique(CPPDEFINES = ['WITH_TCP'])
49 if target_os == 'arduino':
50 libcoap_env.AppendUnique(CPPDEFINES = ['NDEBUG', 'WITH_ARDUINO'])
52 if target_os in ['darwin', 'ios']:
53 libcoap_env.AppendUnique(CPPDEFINES = ['_DARWIN_C_SOURCE'])
55 if env.get('LOGGING'):
56 libcoap_env.AppendUnique(CPPDEFINES = ['TB_LOG'])
58 ######################################################################
59 # Source files and Target(s)
60 ######################################################################
77 libcoap = libcoap_env.StaticLibrary('libcoap', libcoap_src, OBJPREFIX='libcoap_')
79 libcoap_env.InstallTarget([libcoap], 'libcoap')