Imported Upstream version 1.0.1
[platform/upstream/iotivity.git] / resource / csdk / SConscript
1 #******************************************************************
2 #
3 # Copyright 2014 Intel Mobile Communications GmbH 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 # liboctbstack (share library) build script
23 ##
24 Import('env')
25
26 lib_env = env.Clone()
27 SConscript(env.get('SRC_DIR') + '/resource/third_party_libs.scons', 'lib_env')
28
29 liboctbstack_env = lib_env.Clone()
30
31 target_os = env.get('TARGET_OS')
32 with_ra = env.get('WITH_RA')
33 # As in the source code, it includes arduino Time library (C++)
34 # It requires compile the .c with g++
35 if target_os == 'arduino':
36         liboctbstack_env.Replace(CC = env.get('CXX'))
37         liboctbstack_env.Replace(CFLAGS = env.get('CXXFLAGS'))
38
39 ######################################################################
40 # Build flags
41 ######################################################################
42 liboctbstack_env.PrependUnique(CPPPATH = [
43                 '../../extlibs/cjson/',
44                 '../../extlibs/timer/',
45                 'logger/include',
46                 'stack/include',
47                 'stack/include/internal',
48                 '../oc_logger/include',
49                 'connectivity/lib/libcoap-4.1.1',
50                 'connectivity/inc',
51                 'connectivity/api',
52                 'connectivity/external/inc',
53                 'security/include',
54                 'security/include/internal',
55                 ])
56
57 liboctbstack_env.AppendUnique(LIBS = ['ocsrm'])
58
59 if target_os not in ['arduino', 'windows', 'winrt']:
60         liboctbstack_env.AppendUnique(CPPDEFINES  = ['WITH_POSIX'])
61         liboctbstack_env.AppendUnique(CFLAGS = ['-std=c99'])
62
63 if liboctbstack_env.get('ROUTING') == 'GW':
64         liboctbstack_env.AppendUnique(CPPDEFINES = ['ROUTING_GATEWAY'])
65 elif liboctbstack_env.get('ROUTING') == 'EP':
66         liboctbstack_env.AppendUnique(CPPDEFINES = ['ROUTING_EP'])
67
68 if target_os not in ['windows', 'winrt']:
69         liboctbstack_env.AppendUnique(CFLAGS = ['-Wall'])
70
71 liboctbstack_env.AppendUnique(LIBPATH = [env.get('BUILD_DIR')])
72
73 if target_os in ['android', 'linux', 'tizen']:
74         liboctbstack_env.PrependUnique(LIBS = ['connectivity_abstraction'])
75
76         if with_ra:
77                 liboctbstack_env.AppendUnique(LIBS = ['ra_xmpp'])
78
79 liboctbstack_env.AppendUnique(LIBS = ['coap', 'm'])
80
81 if target_os in ['tizen', 'linux']:
82         liboctbstack_env.ParseConfig("pkg-config --cflags --libs uuid")
83
84 if target_os not in ['android', 'arduino', 'windows', 'winrt']:
85         liboctbstack_env.AppendUnique(LIBS = ['pthread'])
86
87 if target_os == 'arduino':
88         liboctbstack_env.AppendUnique(CPPDEFINES = ['NDEBUG', 'WITH_ARDUINO'])
89 elif target_os not in ['darwin','ios']:
90         liboctbstack_env.AppendUnique(CFLAGS = ['-fPIC'])
91 if target_os in ['darwin', 'ios']:
92         env.AppendUnique(CPPDEFINES = ['_DARWIN_C_SOURCE'])
93         liboctbstack_env.AppendUnique(CPPDEFINES = ['_DARWIN_C_SOURCE'])
94         liboctbstack_env.AppendUnique(LIBPATH = [env.get('BUILD_DIR')])
95 if target_os not in ['arduino']:
96         liboctbstack_env.AppendUnique(LINKFLAGS = ['-Wl,--no-undefined'])
97
98 if env.get('SECURED') == '1':
99         liboctbstack_env.AppendUnique(LIBS = ['tinydtls'])
100
101 if env.get('LOGGING'):
102         liboctbstack_env.AppendUnique(CPPDEFINES = ['TB_LOG'])
103
104 if env.get('DTLS_WITH_X509') == '1':
105         liboctbstack_env.AppendUnique(CPPDEFINES = ['__WITH_X509__'])
106
107 liboctbstack_env.Append(LIBS = ['c_common'])
108
109 if liboctbstack_env.get('ROUTING') in ['GW', 'EP']:
110         liboctbstack_env.Prepend(LIBS = ['routingmanager'])
111
112 ######################################################################
113 # Source files and Targets
114 ######################################################################
115 OCTBSTACK_SRC = 'stack/src/'
116 liboctbstack_src = [
117         '../../extlibs/cjson/cJSON.c',
118         '../../extlibs/timer/timer.c',
119         OCTBSTACK_SRC + 'ocstack.c',
120         OCTBSTACK_SRC + 'ocpayload.c',
121         OCTBSTACK_SRC + 'ocpayloadparse.c',
122         OCTBSTACK_SRC + 'ocpayloadconvert.c',
123         OCTBSTACK_SRC + 'occlientcb.c',
124         OCTBSTACK_SRC + 'ocresource.c',
125         OCTBSTACK_SRC + 'ocobserve.c',
126         OCTBSTACK_SRC + 'ocserverrequest.c',
127         OCTBSTACK_SRC + 'occollection.c',
128         OCTBSTACK_SRC + 'oicgroup.c',
129         'logger/src/logger.c',
130         OCTBSTACK_SRC + "rdpayload.c"
131         ]
132
133 liboctbstack_src.extend(env['cbor_files'])
134
135 if target_os in ['arduino','darwin','ios'] :
136         static_liboctbstack = liboctbstack_env.StaticLibrary('octbstack', liboctbstack_src)
137         liboctbstack_env.InstallTarget(static_liboctbstack, 'liboctbstack')
138         liboctbstack_env.UserInstallTargetLib(static_liboctbstack, 'liboctbstack')
139         liboctbstack_env.UserInstallTargetHeader('stack/include/ocstackconfig.h', 'resource', 'ocstackconfig.h')
140         liboctbstack_env.UserInstallTargetHeader('stack/include/octypes.h', 'resource', 'octypes.h')
141 else:
142         static_liboctbstack = liboctbstack_env.StaticLibrary('octbstack', liboctbstack_src)
143         shared_liboctbstack = liboctbstack_env.SharedLibrary('octbstack', liboctbstack_src)
144         liboctbstack_env.InstallTarget([static_liboctbstack, shared_liboctbstack], 'liboctbstack')
145         liboctbstack_env.UserInstallTargetLib([static_liboctbstack, shared_liboctbstack], 'liboctbstack')
146         liboctbstack_env.UserInstallTargetHeader('stack/include/ocstackconfig.h', 'resource', 'ocstackconfig.h')
147         liboctbstack_env.UserInstallTargetHeader('stack/include/octypes.h', 'resource', 'octypes.h')
148         liboctbstack_env.UserInstallTargetHeader('stack/include/ocstack.h', 'resource', 'ocstack.h')
149