Fix x86 and x86_64 build errors
[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 not in ['android', 'arduino', 'windows', 'winrt']:
42         liboctbstack_env.AppendUnique(LIBS = ['pthread'])
43
44 if target_os == 'arduino':
45         liboctbstack_env.AppendUnique(CPPDEFINES = ['NDEBUG', 'WITH_ARDUINO'])
46
47 if target_os in ['darwin', 'ios']:
48         liboctbstack_env.AppendUnique(CPPDEFINES = ['_DARWIN_C_SOURCE'])
49
50 if not env.get('RELEASE'):
51         liboctbstack_env.AppendUnique(CPPDEFINES = ['TB_LOG'])
52
53 ######################################################################
54 # Source files and Targets
55 ######################################################################
56 OCTBSTACK_SRC = 'stack/src/'
57 liboctbstack_src = [
58         '../../extlibs/cjson/cJSON.c',
59         '../../extlibs/timer/timer.c',
60         'occoap/src/occoap.c',
61         'occoap/src/occoaphelper.c',
62         OCTBSTACK_SRC + 'ocstack.c',
63         OCTBSTACK_SRC + 'occlientcb.c',
64         OCTBSTACK_SRC + 'ocresource.c',
65         OCTBSTACK_SRC + 'ocobserve.c',
66     OCTBSTACK_SRC + 'ocserverrequest.c',
67         OCTBSTACK_SRC + 'occollection.c',
68         OCTBSTACK_SRC + 'ocsecurity.c',
69     OCTBSTACK_SRC + 'oicgroup.c'
70         ]
71 if target_os in ['arduino','darwin','ios'] :
72         static_liboctbstack = liboctbstack_env.StaticLibrary('octbstack', liboctbstack_src)
73         liboctbstack_env.InstallTarget(static_liboctbstack, 'liboctbstack')
74 else:
75         static_liboctbstack = liboctbstack_env.StaticLibrary('octbstack', liboctbstack_src)
76         shared_liboctbstack = liboctbstack_env.SharedLibrary('octbstack', liboctbstack_src)
77         liboctbstack_env.InstallTarget([static_liboctbstack, shared_liboctbstack], 'liboctbstack')