51f6fd6617c7ba702e2ff3d17422673d9b444d1c
[platform/upstream/iotivity.git] / resource / csdk / resource-directory / SConscript
1 #******************************************************************
2 #
3 # Copyright 2015 Samsung Electronics All Rights Reserved.
4 #
5 #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
6 #
7 # Licensed under the Apache License, Version 2.0 (the "License");
8 # you may not use this file except in compliance with the License.
9 # You may obtain a copy of the License at
10 #
11 #      http://www.apache.org/licenses/LICENSE-2.0
12 #
13 # Unless required by applicable law or agreed to in writing, software
14 # distributed under the License is distributed on an "AS IS" BASIS,
15 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 # See the License for the specific language governing permissions and
17 # limitations under the License.
18 #
19 #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
20
21 ##
22 # Resource Directory build script
23 ##
24
25 Import('env')
26 rd_env = env.Clone()
27
28 if rd_env.get('LOGGING'):
29     rd_env.AppendUnique(CPPDEFINES = ['-DTB_LOG'])
30
31 target_os = env.get('TARGET_OS')
32 src_dir = env.get('SRC_DIR')
33 rd_mode = env.get('RD_MODE')
34
35 ######################################################################
36 # Build flags
37 ######################################################################
38 rd_env.AppendUnique(CPPPATH = ['include',
39                                 'src/internal',
40                                 '../include',
41                                 '../stack/include',
42                                 '../../include',
43                                 '../logger/include',
44                                 '../../oc_logger/include',
45 ])
46
47 if 'CLIENT' in rd_mode:
48     rd_env.AppendUnique(CPPDEFINES = ['RD_CLIENT'])
49 if 'SERVER' in rd_mode:
50     rd_env.AppendUnique(CPPDEFINES = ['RD_SERVER'])
51
52 rd_env.PrependUnique(LIBPATH = [rd_env.get('BUILD_DIR')])
53 if target_os != 'android':
54     rd_env.PrependUnique(RPATH = [rd_env.get('BUILD_DIR')])
55 rd_env.PrependUnique(LIBS = ['octbstack', 'oc', 'oc_logger'])
56
57 if target_os not in ['windows']:
58     rd_env.AppendUnique(CXXFLAGS = ['-O2', '-g', '-Wall', '-Wextra', '-std=c++0x'])
59
60 if target_os == 'android':
61     rd_env.AppendUnique(CXXFLAGS = ['-frtti', '-fexceptions'])
62     rd_env.AppendUnique(LINKFLAGS = ['-Wl,-soname,libresource_directory.so'])
63     rd_env.AppendUnique(LIBS = ['gnustl_static'])
64     if not env.get('RELEASE'):
65         rd_env.AppendUnique(LIBS = ['log'])
66
67 if target_os in ['linux', 'tizen']:
68     rd_env.ParseConfig('pkg-config --cflags --libs sqlite3')
69 else:
70     rd_env.AppendUnique(CPPPATH = ['../../../extlibs/sqlite3'])
71
72 ######################################################################
73 # Source files and Targets
74 ######################################################################
75 RD_SRC_DIR = 'src/'
76 rd_src = []
77
78 if 'SERVER' in rd_mode:
79     rd_src += [
80         RD_SRC_DIR + 'internal/rd_database.c',
81         RD_SRC_DIR + 'rd_server.c',
82         ]
83     if target_os not in ['linux', 'tizen'] :
84         rd_src += [ '../../../extlibs/sqlite3/sqlite3.c' ]
85
86 if 'CLIENT' in rd_mode:
87     rd_src += [RD_SRC_DIR + 'rd_client.c',]
88     if target_os not in ['arduino','darwin','ios', 'windows', 'winrt']:
89         rd_src += [ RD_SRC_DIR + 'RDClient.cpp',]
90
91 if target_os not in ['arduino', 'darwin', 'ios', 'windows', 'winrt']:
92     rdsdk_shared = rd_env.SharedLibrary('resource_directory', rd_src)
93     rdsdk_static = rd_env.StaticLibrary('resource_directory', rd_src)
94     rdsdk = Flatten([rdsdk_static, rdsdk_shared])
95 else :
96     rdsdk = rd_env.StaticLibrary('resource_directory', rd_src)
97 rd_env.InstallTarget(rdsdk, 'resource_directory')
98 rd_env.UserInstallTargetLib(rdsdk, 'resource_directory')
99
100 if 'CLIENT' in rd_mode:
101     rd_env.UserInstallTargetHeader('include/rd_client.h', 'resource', 'rd_client.h')
102     rd_env.UserInstallTargetHeader('include/RDClient.h', 'resource', 'RDClient.h')
103
104 if 'SERVER' in rd_mode:
105     rd_env.UserInstallTargetHeader('include/rd_server.h', 'resource', 'rd_server.h')
106     rd_env.UserInstallTargetHeader('include/rd_database.h', 'resource', 'rd_database.h')
107
108 ######################################################################
109 # Samples for the resource directory
110 ######################################################################
111 if target_os in ['linux']:
112     SConscript('samples/SConscript')
113
114 ######################################################################
115 # Build UnitTests of the Resource Directory
116 ################################################ ######################
117 if target_os in ['linux']:
118     SConscript('unittests/SConscript')