modify build script for provisioning
[platform/upstream/iotivity.git] / resource / provisioning / examples / 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 # Examples build script
23 ##
24 Import('env')
25 # Add third party libraries
26 lib_env = env.Clone()
27 SConscript(env.get('SRC_DIR') + '/resource/third_party_libs.scons', 'lib_env')
28
29 examples_env = lib_env.Clone()
30
31 ######################################################################
32 # Build flags
33 ######################################################################
34 examples_env.AppendUnique(CPPPATH = [
35         '../../include/',
36         '../../csdk/stack/include',
37         '../../csdk/logger/include',
38         '../../oc_logger/include',
39         '../../csdk/security/include',
40         '../../csdk/security/provisioning/include',
41         '../../csdk/security/provisioning/include/oxm',
42         '../../csdk/security/provisioning/include/internal'
43                 ])
44
45 target_os = env.get('TARGET_OS')
46 if target_os not in ['windows', 'winrt']:
47         examples_env.AppendUnique(CXXFLAGS = ['-std=c++0x', '-Wall', '-pthread'])
48
49         # Note: 'pthread' is in libc for android. On other platform, if use
50         # new gcc(>4.9?) it isn't required, otherwise, it's required
51         if target_os != 'android':
52                 examples_env.AppendUnique(LIBS = ['-lpthread', '-ldl'])
53
54 examples_env.AppendUnique(LIBPATH = [env.get('BUILD_DIR')])
55 examples_env.AppendUnique(RPATH = [env.get('BUILD_DIR')])
56 examples_env.PrependUnique(LIBS = ['ocprovision', 'oc', 'ocpmapi', 'octbstack',
57                                     'oc_logger', 'connectivity_abstraction', 'coap'])
58 if env.get('SECURED') == '1':
59     examples_env.AppendUnique(LIBS = ['tinydtls'])
60 if env.get('DTLS_WITH_X509') == '1':
61         examples_env.AppendUnique(LIBS = ['CKManager'])
62         examples_env.AppendUnique(LIBS = ['asn1'])
63
64 if target_os == 'android':
65         examples_env.AppendUnique(CXXFLAGS = ['-frtti', '-fexceptions'])
66         examples_env.AppendUnique(LIBS = ['gnustl_shared'])
67
68         if not env.get('RELEASE'):
69                 examples_env.AppendUnique(LIBS = ['log'])
70
71 if target_os in ['darwin', 'ios']:
72         examples_env.AppendUnique(CPPDEFINES = ['_DARWIN_C_SOURCE'])
73
74 if target_os == 'tizen':
75         examples_env.ParseConfig('pkg-config --libs sqlite3')
76
77 ######################################################################
78 # Source files and Targets
79 ######################################################################
80 provisioningclient = examples_env.Program('provisioningclient', 'provisioningclient.cpp')
81
82 clientjson = examples_env.Install(env.get('BUILD_DIR') + '/resource/provisioning/examples/',
83                                 env.get('SRC_DIR') + '/resource/provisioning/examples/' + 'oic_svr_db_client.json')
84
85 Alias("examples", [provisioningclient, clientjson])
86 env.AppendTarget('examples')