Imported Upstream version 0.9.2
[platform/upstream/iotivity.git] / resource / csdk / connectivity / lib / libcoap-4.1.1 / SConscript
1 ##
2 # libcoap (share library) build script
3 ##
4
5 Import('env')
6
7 libcoap_env = env.Clone()
8
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(CFLAGS = env.get('CXXFLAGS'))
14
15 ######################################################################
16 # Build flags
17 ######################################################################
18         libcoap_env.PrependUnique(CPPPATH = [
19                 './',
20                 env.get('ARDUINO_HOME')+'/',
21                 env.get('ARDUINO_HOME')+'/hardware/arduino/avr/cores/arduino',
22                 env.get('ARDUINO_HOME')+'/hardware/tools/avr/avr/include/',
23                 env.get('ARDUINO_HOME')+'/hardware/arduino/avr/variants/mega',
24                 env.get('ARDUINO_HOME')+'/libraries/Time/Time',
25                 env.get('ARDUINO_HOME')+'/libraries/TimedAction',
26                 env.get('ARDUINO_HOME')+'/hardware/arduino/avr/libraries/SPI',
27                 env.get('ARDUINO_HOME')+'/libraries/Ethernet/src/utility',
28                 ])
29
30 if target_os not in ['arduino', 'windows', 'winrt']:
31         libcoap_env.AppendUnique(CPPDEFINES = ['WITH_POSIX', '_BSD_SOURCE'])
32         libcoap_env.AppendUnique(CFLAGS = ['-std=gnu99','-fPIC'])
33
34 if target_os not in ['windows', 'winrt']:
35         libcoap_env.AppendUnique(CFLAGS = ['-Wall', '-ffunction-sections',
36                         '-fdata-sections', '-fno-exceptions'])
37
38 if target_os == 'android':
39         libcoap_env.AppendUnique(LIBS = ['log'])
40
41 if target_os == 'arduino':
42         libcoap_env.AppendUnique(CPPDEFINES = ['NDEBUG', 'WITH_ARDUINO'])
43
44 if target_os in ['darwin', 'ios']:
45         libcoap_env.AppendUnique(CPPDEFINES = ['_DARWIN_C_SOURCE'])
46
47 if env.get('LOGGING'):
48         libcoap_env.AppendUnique(CPPDEFINES = ['TB_LOG'])
49
50 ######################################################################
51 # Source files and Target(s)
52 ######################################################################
53 libcoap_src = [
54         'pdu.c',
55         'net.c',
56         'debug.c',
57         'encode.c',
58         'uri.c',
59         'coap_list.c',
60         'resource.c',
61         'hashkey.c',
62         'str.c',
63         'option.c',
64         'async.c',
65         'subscribe.c',
66         'block.c'
67         ]
68
69 libcoap = libcoap_env.StaticLibrary('libcoap', libcoap_src, OBJPREFIX='libcoap_')
70
71 libcoap_env.InstallTarget([libcoap], 'libcoap')
72 libcoap_env.UserInstallTargetLib([libcoap], 'libcoap')