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