IOT-1583: Removing /W3 warning from resource/csdk/security.
[iotivity.git] / resource / csdk / security / SConscript
1 # //******************************************************************
2 # //
3 # // Copyright 2015 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 # libocsrm (static library) build script
22 ##
23
24 Import('env')
25 import os
26
27 libocsrm_env = env.Clone()
28
29 target_os = libocsrm_env.get('TARGET_OS')
30
31 ######################################################################
32 # Build flags
33 ######################################################################
34 with_upstream_libcoap = libocsrm_env.get('WITH_UPSTREAM_LIBCOAP')
35 if with_upstream_libcoap == '1':
36         # For bring up purposes only, we manually copy the forked version to where the unforked version is downloaded.
37         libocsrm_env.AppendUnique(CPPPATH = ['#extlibs/libcoap/libcoap/include'])
38 else:
39         # For bring up purposes only, the forked version will live here.
40         libocsrm_env.AppendUnique(CPPPATH = ['#/resource/connectivity/lib/libcoap-4.1.1/include'])
41
42 libocsrm_env.PrependUnique(CPPPATH = [
43                 '#/extlibs/tinydtls',
44                 '#/resource/csdk/logger/include',
45                 '#/resource/c_common/ocrandom/include',
46                 '#/resource/csdk/include',
47                 '#/resource/csdk/stack/include',
48                 '#/resource/csdk/stack/include/internal',
49                 '#/resource/oc_logger/include',
50                 '#/resource/csdk/connectivity/external/inc',
51                 '#/resource/csdk/connectivity/common/inc',
52                 '#/resource/csdk/connectivity/inc',
53                 '#/resource/csdk/connectivity/api',
54                 '#/resource/csdk/security/include',
55                 '#/resource/csdk/security/include/internal',
56                 '#/resource/csdk/security/provisioning/include'
57                 ])
58
59 if target_os in ['windows', 'msys_nt']:
60         libocsrm_env.AppendUnique(LIBPATH = [os.path.join(libocsrm_env.get('BUILD_DIR'), 'resource', 'oc_logger')])
61         libocsrm_env.AppendUnique(CCFLAGS=['/W3', '/WX'])
62
63 if target_os in ['linux', 'android', 'tizen', 'msys_nt', 'windows'] and libocsrm_env.get('SECURED') == '1':
64         SConscript('provisioning/SConscript', 'libocsrm_env')
65
66 if target_os in ['linux', 'windows', 'darwin'] and libocsrm_env.get('SECURED') == '1':
67         SConscript('tool/SConscript', 'libocsrm_env')
68
69 # As in the source code, it includes arduino Time library (C++)
70 # It requires compile the .c with g++
71 if target_os == 'arduino':
72         libocsrm_env.Replace(CC = libocsrm_env.get('CXX'))
73         libocsrm_env.Replace(CFLAGS = libocsrm_env.get('CXXFLAGS'))
74
75 if target_os not in ['arduino', 'windows']:
76         libocsrm_env.AppendUnique(CPPDEFINES  = ['WITH_POSIX', '_GNU_SOURCE'])
77         libocsrm_env.AppendUnique(CFLAGS = ['-std=c99', '-Wall'])
78
79 libocsrm_env.AppendUnique(LIBPATH = [libocsrm_env.get('BUILD_DIR')])
80 libocsrm_env.AppendUnique(LIBS = ['coap'])
81
82 if target_os == 'arduino':
83         libocsrm_env.AppendUnique(CPPDEFINES = ['NDEBUG', 'WITH_ARDUINO'])
84 elif target_os not in ['windows', 'msys_nt']:
85         libocsrm_env.AppendUnique(CFLAGS = ['-fPIC'])
86         libocsrm_env.AppendUnique(LIBS = ['m'])
87
88 if target_os in ['darwin', 'ios']:
89         libocsrm_env.AppendUnique(CPPDEFINES = ['_DARWIN_C_SOURCE'])
90
91 if env.get('LOGGING'):
92         libocsrm_env.AppendUnique(CPPDEFINES = ['TB_LOG'])
93
94 if env.get('MULTIPLE_OWNER') == '1':
95         libocsrm_env.AppendUnique(CPPDEFINES=['MULTIPLE_OWNER'])
96
97 ######################################################################
98 # Source files and Targets
99 ######################################################################
100 OCSRM_SRC = 'src/'
101 libocsrm_src = [
102         OCSRM_SRC + 'secureresourcemanager.c',
103         OCSRM_SRC + 'resourcemanager.c',
104         OCSRM_SRC + 'aclresource.c',
105         OCSRM_SRC + 'verresource.c',
106         OCSRM_SRC + 'amaclresource.c',
107         OCSRM_SRC + 'amsmgr.c',
108         OCSRM_SRC + 'pstatresource.c',
109         OCSRM_SRC + 'doxmresource.c',
110         OCSRM_SRC + 'credresource.c',
111         OCSRM_SRC + 'svcresource.c',
112         OCSRM_SRC + 'pconfresource.c',
113         OCSRM_SRC + 'dpairingresource.c',
114         OCSRM_SRC + 'policyengine.c',
115         OCSRM_SRC + 'psinterface.c',
116         OCSRM_SRC + 'srmresourcestrings.c',
117         OCSRM_SRC + 'srmutility.c',
118         OCSRM_SRC + 'iotvticalendar.c',
119         OCSRM_SRC + 'base64.c',
120         OCSRM_SRC + 'directpairing.c'
121         ]
122
123 if libocsrm_env.get('SECURED') == '1':
124         libocsrm_src = libocsrm_src + [OCSRM_SRC + 'oxmpincommon.c', OCSRM_SRC + 'pbkdf2.c']
125         libocsrm_src = libocsrm_src + [OCSRM_SRC + 'crlresource.c', OCSRM_SRC + 'pkix_interface.c']
126         libocsrm_src = libocsrm_src + [OCSRM_SRC + 'oxmverifycommon.c']
127
128 if target_os in ['windows', 'msys_nt']:
129         libocsrm_src  = libocsrm_src + [OCSRM_SRC + 'strptime.c']
130
131
132 libocsrm_src.extend(env['cbor_files'])
133
134 # Insert a hack for Arduino, whose compiler may not support all defines expected
135 # by tinycbor
136 if target_os in ['arduino']:
137         libocsrm_env.AppendUnique(CPPDEFINES = ['INT64_MAX=0x7FFFFFFFFFFFFFFF'])
138
139 libocsrm_conf = Configure(libocsrm_env)
140 if libocsrm_conf.CheckFunc('strptime'):
141         libocsrm_conf.env.AppendUnique(CPPDEFINES = ['HAVE_STRPTIME'])
142 libocsrm_env = libocsrm_conf.Finish()
143
144 libocsrm = libocsrm_env.StaticLibrary('ocsrm', libocsrm_src)
145
146 libocsrm_env.InstallTarget(libocsrm, 'ocsrm')