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 == 'linux':
42 libcoap_env.AppendUnique(CPPDEFINES = ['WITH_TCP'])
44 if target_os == 'android':
45 libcoap_env.AppendUnique(LIBS = ['log'])
47 if target_os == 'arduino':
48 libcoap_env.AppendUnique(CPPDEFINES = ['NDEBUG', 'WITH_ARDUINO'])
50 if target_os in ['darwin', 'ios']:
51 libcoap_env.AppendUnique(CPPDEFINES = ['_DARWIN_C_SOURCE'])
53 if env.get('LOGGING'):
54 libcoap_env.AppendUnique(CPPDEFINES = ['TB_LOG'])
56 ######################################################################
57 # Source files and Target(s)
58 ######################################################################
75 libcoap = libcoap_env.StaticLibrary('libcoap', libcoap_src, OBJPREFIX='libcoap_')
77 libcoap_env.InstallTarget([libcoap], 'libcoap')
78 libcoap_env.UserInstallTargetLib([libcoap], 'libcoap')