Imported Upstream version 1.0.0
[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 == 'linux':
41         if with_tcp == True:
42                 libcoap_env.AppendUnique(CPPDEFINES = ['WITH_TCP'])
43
44 if target_os == 'android':
45         libcoap_env.AppendUnique(LIBS = ['log'])
46
47 if target_os == 'arduino':
48         libcoap_env.AppendUnique(CPPDEFINES = ['NDEBUG', 'WITH_ARDUINO'])
49
50 if target_os in ['darwin', 'ios']:
51         libcoap_env.AppendUnique(CPPDEFINES = ['_DARWIN_C_SOURCE'])
52
53 if env.get('LOGGING'):
54         libcoap_env.AppendUnique(CPPDEFINES = ['TB_LOG'])
55
56 ######################################################################
57 # Source files and Target(s)
58 ######################################################################
59 libcoap_src = [
60         'pdu.c',
61         'net.c',
62         'debug.c',
63         'encode.c',
64         'uri.c',
65         'coap_list.c',
66         'resource.c',
67         'hashkey.c',
68         'str.c',
69         'option.c',
70         'async.c',
71         'subscribe.c',
72         'block.c'
73         ]
74
75 libcoap = libcoap_env.StaticLibrary('libcoap', libcoap_src, OBJPREFIX='libcoap_')
76
77 libcoap_env.InstallTarget([libcoap], 'libcoap')
78 libcoap_env.UserInstallTargetLib([libcoap], 'libcoap')