82041417f93122b38661d0772c4524abad0480fc
[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     libocsrm_env.AppendUnique(CPPPATH=['#extlibs/libcoap/libcoap/include'])
37 else:
38     libocsrm_env.AppendUnique(CPPPATH=['#/resource/csdk/connectivity/lib/libcoap-4.1.1/include'])
39
40 libocsrm_env.PrependUnique(CPPPATH=[
41     '#/extlibs/mbedtls/mbedtls/include',
42     '#/resource/csdk/logger/include',
43     '#/resource/c_common/ocrandom/include',
44     '#/resource/csdk/include',
45     '#/resource/csdk/stack/include',
46     '#/resource/csdk/stack/include/internal',
47     '#/resource/oc_logger/include',
48     '#/resource/csdk/connectivity/external/inc',
49     '#/resource/csdk/connectivity/common/inc',
50     '#/resource/csdk/connectivity/inc',
51     '#/resource/csdk/connectivity/api',
52     '#/resource/csdk/security/include',
53     '#/resource/csdk/security/include/internal',
54     '#/resource/csdk/security/provisioning/include',
55     '#/extlibs/mbedtls/mbedtls/include'
56 ])
57
58 if target_os in ['windows', 'msys_nt']:
59     libocsrm_env.AppendUnique(LIBPATH=[
60         os.path.join(libocsrm_env.get('BUILD_DIR'), 'resource', 'oc_logger')
61     ])
62     libocsrm_env.AppendUnique(CCFLAGS=['/W4'])
63
64 if libocsrm_env.get('SECURED') == '1':
65     if target_os in ['linux', 'android', 'tizen', 'msys_nt', 'windows']:
66         SConscript('provisioning/SConscript', 'libocsrm_env')
67
68     if target_os in ['linux', 'tizen', 'windows', 'darwin']:
69         SConscript('tool/SConscript', 'libocsrm_env')
70
71 if target_os not in ['windows']:
72     libocsrm_env.AppendUnique(CPPDEFINES=['WITH_POSIX', '_GNU_SOURCE'])
73     libocsrm_env.AppendUnique(CFLAGS=['-std=c99', '-Wall'])
74
75 libocsrm_env.AppendUnique(LIBS=['coap'])
76
77 if target_os not in ['windows', 'msys_nt']:
78     libocsrm_env.AppendUnique(CFLAGS=['-fPIC'])
79     libocsrm_env.AppendUnique(LIBS=['m'])
80
81 if target_os in ['darwin', 'ios']:
82     libocsrm_env.AppendUnique(CPPDEFINES=['_DARWIN_C_SOURCE'])
83
84 if env.get('LOGGING'):
85     libocsrm_env.AppendUnique(CPPDEFINES=['TB_LOG'])
86
87 if env.get('MULTIPLE_OWNER') == '1':
88     libocsrm_env.AppendUnique(CPPDEFINES=['MULTIPLE_OWNER'])
89
90 ######################################################################
91 # Source files and Targets
92 ######################################################################
93 OCSRM_SRC = 'src/'
94 libocsrm_src = [
95     OCSRM_SRC + 'secureresourcemanager.c',
96     OCSRM_SRC + 'resourcemanager.c',
97     OCSRM_SRC + 'aclresource.c',
98     OCSRM_SRC + 'amaclresource.c',
99     OCSRM_SRC + 'pstatresource.c',
100     OCSRM_SRC + 'spresource.c',
101     OCSRM_SRC + 'doxmresource.c',
102     OCSRM_SRC + 'credresource.c',
103     OCSRM_SRC + 'policyengine.c',
104     OCSRM_SRC + 'psinterface.c',
105     OCSRM_SRC + 'srmresourcestrings.c',
106     OCSRM_SRC + 'srmutility.c',
107     OCSRM_SRC + 'iotvticalendar.c',
108     OCSRM_SRC + 'base64.c',
109     OCSRM_SRC + 'deviceonboardingstate.c'
110 ]
111
112 if libocsrm_env.get('SECURED') == '1':
113     libocsrm_src = libocsrm_src + [
114         OCSRM_SRC + 'oxmpincommon.c',
115         OCSRM_SRC + 'pbkdf2.c'
116     ]
117     libocsrm_src = libocsrm_src + [
118         OCSRM_SRC + 'crlresource.c',
119         OCSRM_SRC + 'pkix_interface.c'
120     ]
121     libocsrm_src = libocsrm_src + [OCSRM_SRC + 'oxmverifycommon.c']
122     libocsrm_src = libocsrm_src + [
123         OCSRM_SRC + 'certhelpers.c',
124         OCSRM_SRC + 'occertutility.c'
125     ]
126     libocsrm_src = libocsrm_src + [OCSRM_SRC + 'csrresource.c']
127     libocsrm_src = libocsrm_src + [OCSRM_SRC + 'rolesresource.c']
128     libocsrm_src = libocsrm_src + [OCSRM_SRC + 'ocsecurity.c']
129
130 if target_os in ['windows', 'msys_nt']:
131     libocsrm_src = libocsrm_src + [OCSRM_SRC + 'strptime.c']
132
133 libocsrm_src.extend(env['cbor_files'])
134
135 libocsrm = libocsrm_env.StaticLibrary('ocsrm', libocsrm_src)
136
137 libocsrm_env.InstallTarget(libocsrm, 'ocsrm')
138 libocsrm_env.UserInstallTargetHeader(
139     'include/experimental/securevirtualresourcetypes.h',
140     'resource/stack/experimental', 'securevirtualresourcetypes.h')
141 libocsrm_env.UserInstallTargetHeader(
142     'include/experimental/doxmresource.h',
143     'resource/stack/experimental', 'doxmresource.h')