Automatically detect C99 flags for supported compilers.
[platform/upstream/iotivity.git] / resource / csdk / 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(CC = env.get('CXX'))
14         libcoap_env.Replace(CFLAGS = env.get('CXXFLAGS'))
15
16 ######################################################################
17 # Build flags
18 ######################################################################
19 libcoap_env.PrependUnique(CPPPATH = [
20                 '../ocsocket/include',
21                 '../ocmalloc/include',
22                 '../logger/include',
23                 '../ocrandom/include',
24                 '../stack',
25                 '../../oc_logger/include'
26                 ])
27
28 if target_os not in ['arduino', 'windows', 'winrt']:
29         libcoap_env.AppendUnique(CPPDEFINES = ['WITH_POSIX', '_BSD_SOURCE'])
30
31 if target_os not in ['windows', 'winrt']:
32         libcoap_env.AppendUnique(CFLAGS = ['-Wall', '-ffunction-sections',
33                         '-fdata-sections', '-fno-exceptions'])
34
35 if target_os == 'android':
36         libcoap_env.AppendUnique(LIBS = ['log'])
37
38 if target_os == 'arduino':
39         libcoap_env.AppendUnique(CPPDEFINES = ['NDEBUG', 'WITH_ARDUINO'])
40
41 if target_os in ['darwin', 'ios']:
42         libcoap_env.AppendUnique(CPPDEFINES = ['_DARWIN_C_SOURCE'])
43
44 if not env.get('RELEASE'):
45         libcoap_env.AppendUnique(CPPDEFINES = ['TB_LOG'])
46
47 ######################################################################
48 # Source files and Target(s)
49 ######################################################################
50 libcoap_src = [
51         'pdu.c',
52         'net.c',
53         'debug.c',
54         'encode.c',
55         'uri.c',
56         'coap_list.c',
57 #       'resource.c',
58         'hashkey.c',
59     'str.c',
60         'option.c',
61         'async.c',
62         'subscribe.c',
63         'block.c',
64         '../logger/src/logger.c',
65         '../ocrandom/src/ocrandom.c',
66         '../ocmalloc/src/ocmalloc.c',
67         '../../oc_logger/c/oc_logger.c',
68         '../../oc_logger/c/oc_console_logger.c'
69         ]
70
71 if target_os == 'arduino':
72         if env.get('NET') == 'Wifi':
73                 libcoap_src.append(['../ocsocket/src/ocsocket_arduino_wifi.cpp'])
74         else:
75                 libcoap_src.append(['../ocsocket/src/ocsocket_arduino.cpp'])
76 else:
77         libcoap_src.append(['../ocsocket/src/ocsocket.c'])
78
79 if target_os == 'arduino':
80         static_libcoap = libcoap_env.StaticLibrary('libcoap', libcoap_src, OBJPREFIX='libcoap_')
81         libcoap_env.InstallTarget(static_libcoap, 'libcoap')
82 else:
83         static_libcoap = libcoap_env.StaticLibrary('libcoap', libcoap_src, OBJPREFIX='libcoap_')
84         shared_libcoap = libcoap_env.SharedLibrary('libcoap', libcoap_src, OBJPREFIX='libcoap_')
85         libcoap_env.InstallTarget([static_libcoap, shared_libcoap], 'libcoap')