Merge branch 'upstream' into tizen
[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 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'))
16
17 ######################################################################
18 # Build flags
19 ######################################################################
20         libcoap_env.PrependUnique(CPPPATH = [
21                 './',
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',
30                 ])
31
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'])
35
36 if target_os not in ['windows', 'winrt']:
37         libcoap_env.AppendUnique(CFLAGS = ['-Wall', '-ffunction-sections',
38                         '-fdata-sections', '-fno-exceptions'])
39
40 if target_os in ['linux', 'tizen', 'android', 'ios']:
41         if with_tcp == True:
42                 libcoap_env.AppendUnique(CPPDEFINES = ['WITH_TCP'])
43
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'])
48
49 if target_os == 'arduino':
50         libcoap_env.AppendUnique(CPPDEFINES = ['NDEBUG', 'WITH_ARDUINO'])
51
52 if target_os in ['darwin', 'ios']:
53         libcoap_env.AppendUnique(CPPDEFINES = ['_DARWIN_C_SOURCE'])
54
55 if env.get('LOGGING'):
56         libcoap_env.AppendUnique(CPPDEFINES = ['TB_LOG'])
57
58 ######################################################################
59 # Source files and Target(s)
60 ######################################################################
61 libcoap_src = [
62         'pdu.c',
63         'net.c',
64         'debug.c',
65         'encode.c',
66         'uri.c',
67         'coap_list.c',
68         'resource.c',
69         'hashkey.c',
70         'str.c',
71         'option.c',
72         'async.c',
73         'subscribe.c',
74         'block.c'
75         ]
76
77 libcoap = libcoap_env.StaticLibrary('libcoap', libcoap_src, OBJPREFIX='libcoap_')
78
79 libcoap_env.InstallTarget([libcoap], 'libcoap')
80 libcoap_env.UserInstallTargetLib([libcoap], 'libcoap')