Automatically detect C99 flags for supported compilers.
[platform/upstream/iotivity.git] / resource / csdk / SConscript
1 ##
2 # liboctbstack (share library) build script
3 ##
4 Import('env')
5
6 liboctbstack_env = env.Clone()
7
8 target_os = env.get('TARGET_OS')
9 # As in the source code, it includes arduino Time library (C++)
10 # It requires compile the .c with g++
11 if target_os == 'arduino':
12         liboctbstack_env.Replace(CC = env.get('CXX'))
13         liboctbstack_env.Replace(CFLAGS = env.get('CXXFLAGS'))
14
15 ######################################################################
16 # Build flags
17 ######################################################################
18 liboctbstack_env.PrependUnique(CPPPATH = [
19                 '../../extlibs/cjson/',
20                 '../../extlibs/timer/',
21                 'ocsocket/include',
22                 'logger/include',
23                 'ocrandom/include',
24                 'ocmalloc/include',
25                 'libcoap',
26                 'occoap/include',
27                 'stack/include',
28                 'stack/include/internal',
29                 '../oc_logger/include'
30                 ])
31
32 if target_os not in ['arduino', 'windows', 'winrt']:
33         liboctbstack_env.AppendUnique(CPPDEFINES  = ['WITH_POSIX'])
34
35 if target_os not in ['windows', 'winrt']:
36         liboctbstack_env.AppendUnique(CFLAGS = ['-Wall'])
37
38 liboctbstack_env.AppendUnique(LIBPATH = [env.get('BUILD_DIR')])
39 liboctbstack_env.AppendUnique(LIBS = ['coap', 'm'])
40
41 if target_os == 'arduino':
42         liboctbstack_env.AppendUnique(CPPDEFINES = ['NDEBUG', 'WITH_ARDUINO'])
43
44 if target_os in ['darwin', 'ios']:
45         liboctbstack_env.AppendUnique(CPPDEFINES = ['_DARWIN_C_SOURCE'])
46
47 if not env.get('RELEASE'):
48         liboctbstack_env.AppendUnique(CPPDEFINES = ['TB_LOG'])
49
50 ######################################################################
51 # Source files and Targets
52 ######################################################################
53 OCTBSTACK_SRC = 'stack/src/'
54 liboctbstack_src = [
55         '../../extlibs/cjson/cJSON.c',
56         '../../extlibs/timer/timer.c',
57         'occoap/src/occoap.c',
58         'occoap/src/occoaphelper.c',
59         OCTBSTACK_SRC + 'ocstack.c',
60         OCTBSTACK_SRC + 'occlientcb.c',
61         OCTBSTACK_SRC + 'ocresource.c',
62         OCTBSTACK_SRC + 'ocobserve.c',
63     OCTBSTACK_SRC + 'ocserverrequest.c',
64         OCTBSTACK_SRC + 'occollection.c',
65         OCTBSTACK_SRC + 'ocsecurity.c',
66     OCTBSTACK_SRC + 'oicgroup.c'
67         ]
68 if target_os == 'arduino':
69         static_liboctbstack = liboctbstack_env.StaticLibrary('octbstack', liboctbstack_src)
70         liboctbstack_env.InstallTarget(static_liboctbstack, 'liboctbstack')
71 else:
72         static_liboctbstack = liboctbstack_env.StaticLibrary('octbstack', liboctbstack_src)
73         shared_liboctbstack = liboctbstack_env.SharedLibrary('octbstack', liboctbstack_src)
74         liboctbstack_env.InstallTarget([static_liboctbstack, shared_liboctbstack], 'liboctbstack')