2 # libcoap (share library) build script
7 libcoap_env = env.Clone()
9 target_os = env.get('TARGET_OS')
11 # As in the source code(C) includes arduino Time library head file(C++)
12 # It requires compile the .c with g++
13 if target_os == 'arduino':
14 libcoap_env.Replace(CFLAGS = env.get('CXXFLAGS'))
16 ######################################################################
18 ######################################################################
19 libcoap_env.PrependUnique(CPPPATH = [
21 env.get('ARDUINO_HOME')+'/',
22 env.get('ARDUINO_HOME')+'/hardware/arduino/avr/cores/arduino',
23 env.get('ARDUINO_HOME')+'/hardware/tools/avr/avr/include/',
24 env.get('ARDUINO_HOME')+'/hardware/arduino/avr/variants/mega',
25 env.get('ARDUINO_HOME')+'/libraries/Time/Time',
26 env.get('ARDUINO_HOME')+'/libraries/TimedAction',
27 env.get('ARDUINO_HOME')+'/hardware/arduino/avr/libraries/SPI',
28 env.get('ARDUINO_HOME')+'/libraries/Ethernet/src/utility',
31 if target_os not in ['arduino', 'windows', 'winrt']:
32 libcoap_env.AppendUnique(CPPDEFINES = ['WITH_POSIX'])
33 libcoap_env.AppendUnique(CFLAGS = ['-std=gnu99','-fPIC'])
35 if target_os not in ['windows', 'winrt']:
36 libcoap_env.AppendUnique(CFLAGS = ['-Wall', '-ffunction-sections',
37 '-fdata-sections', '-fno-exceptions'])
39 if target_os == 'android':
40 libcoap_env.AppendUnique(LIBS = ['log'])
42 if target_os == 'arduino':
43 libcoap_env.AppendUnique(CPPDEFINES = ['NDEBUG', 'WITH_ARDUINO'])
45 if target_os in ['darwin', 'ios']:
46 libcoap_env.AppendUnique(CPPDEFINES = ['_DARWIN_C_SOURCE'])
48 if env.get('LOGGING'):
49 libcoap_env.AppendUnique(CPPDEFINES = ['TB_LOG'])
51 ######################################################################
52 # Source files and Target(s)
53 ######################################################################
70 libcoap = libcoap_env.StaticLibrary('libcoap', libcoap_src, OBJPREFIX='libcoap_')
72 libcoap_env.InstallTarget(libcoap, 'libcoap')