Common adapter for DTLS/TLS
[platform/upstream/iotivity.git] / extlibs / mbedtls / SConscript
1 #******************************************************************
2 #
3 # Copyright 2016 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 Import('env')
22
23 import os
24 import sys
25
26 target_os = env.get('TARGET_OS')
27 root_dir = env.get('SRC_DIR')
28 mbedtls_dir = os.path.join(root_dir, 'extlibs','mbedtls','mbedtls/')
29
30 if not os.path.exists(mbedtls_dir):
31     print '''
32 *********************************** Error: ****************************************
33 * Please download mbedtls using the following command:                            *
34 *     $ git clone https://github.com/ARMmbed/mbedtls.git extlibs/mbedtls/mbedtls  *
35 ***********************************************************************************
36  '''
37     Exit(1)
38 #Apply patch to enable TLS_ECDH_ANON_WITH_AES_128_CBC_SHA256 ciphersuite and server identity hint
39 #For tizen platform patch is applied by gbsbuild script
40 if target_os != 'tizen':
41     start_dir = os.getcwd()
42     os.chdir(mbedtls_dir)
43     cmd = 'git checkout development && git reset --hard ad249f509fd62a3bbea7ccd1fef605dbd482a7bd && git apply --whitespace=fix ../ocf.patch'
44     os.system(cmd)
45     os.chdir(start_dir)
46
47
48 mbedtls_env = env.Clone()
49 mbedtls_env.PrependUnique(CPPPATH = [mbedtls_dir])
50 mbedtls_env.AppendUnique(CPPPATH = [mbedtls_dir+'include/'])
51 mbedtls_env.AppendUnique(CFLAGS = ['-fPIC', '-Wall'])
52
53 ######################################################################
54 # Source files and Target(s)
55 ######################################################################
56 mbedtls_src = [
57                 'mbedtls/library/debug.c',
58                 'mbedtls/library/net.c',
59                 'mbedtls/library/ssl_cache.c',
60                 'mbedtls/library/ssl_ciphersuites.c',
61                 'mbedtls/library/ssl_cli.c',
62                 'mbedtls/library/ssl_cookie.c',
63                 'mbedtls/library/ssl_srv.c',
64                 'mbedtls/library/ssl_ticket.c',
65                 'mbedtls/library/ssl_tls.c'
66         ]
67
68
69 mbedcrypto_src = [
70                     'mbedtls/library/aes.c',
71                     'mbedtls/library/aesni.c',
72                     'mbedtls/library/arc4.c',
73                     'mbedtls/library/asn1parse.c',
74                     'mbedtls/library/asn1write.c',
75                     'mbedtls/library/base64.c',
76                     'mbedtls/library/bignum.c',
77                     'mbedtls/library/blowfish.c',
78                     'mbedtls/library/camellia.c',
79                     'mbedtls/library/ccm.c',
80                     'mbedtls/library/cipher.c',
81                     'mbedtls/library/cipher_wrap.c',
82                     'mbedtls/library/ctr_drbg.c',
83                     'mbedtls/library/des.c',
84                     'mbedtls/library/dhm.c',
85                     'mbedtls/library/ecdh.c',
86                     'mbedtls/library/ecdsa.c',
87                     'mbedtls/library/ecjpake.c',
88                     'mbedtls/library/ecp.c',
89                     'mbedtls/library/ecp_curves.c',
90                     'mbedtls/library/entropy.c',
91                     'mbedtls/library/entropy_poll.c',
92                     'mbedtls/library/error.c',
93                     'mbedtls/library/gcm.c',
94                     'mbedtls/library/havege.c',
95                     'mbedtls/library/hmac_drbg.c',
96                     'mbedtls/library/md.c',
97                     'mbedtls/library/md2.c',
98                     'mbedtls/library/md4.c',
99                     'mbedtls/library/md5.c',
100                     'mbedtls/library/md_wrap.c',
101                     'mbedtls/library/memory_buffer_alloc.c',
102                     'mbedtls/library/oid.c',
103                     'mbedtls/library/padlock.c',
104                     'mbedtls/library/pem.c',
105                     'mbedtls/library/pk.c',
106                     'mbedtls/library/pk_wrap.c',
107                     'mbedtls/library/pkcs12.c',
108                     'mbedtls/library/pkcs5.c',
109                     'mbedtls/library/pkparse.c',
110                     'mbedtls/library/pkwrite.c',
111                     'mbedtls/library/platform.c',
112                     'mbedtls/library/ripemd160.c',
113                     'mbedtls/library/rsa.c',
114                     'mbedtls/library/sha1.c',
115                     'mbedtls/library/sha256.c',
116                     'mbedtls/library/sha512.c',
117                     'mbedtls/library/threading.c',
118                     'mbedtls/library/timing.c',
119                     'mbedtls/library/version.c',
120                     'mbedtls/library/version_features.c',
121                     'mbedtls/library/xtea.c'
122         ]
123
124 mbeX509_src = [
125                 'mbedtls/library/certs.c',
126                 'mbedtls/library/pkcs11.c',
127                 'mbedtls/library/x509.c',
128                 'mbedtls/library/x509_create.c',
129                 'mbedtls/library/x509_crl.c',
130                 'mbedtls/library/x509_crt.c',
131                 'mbedtls/library/x509_csr.c',
132                 'mbedtls/library/x509write_crt.c',
133                 'mbedtls/library/x509write_csr.c'
134         ]
135
136 mbedcrypto_env = mbedtls_env.Clone()
137 static_libmbedcrypto = mbedcrypto_env.StaticLibrary('mbedcrypto', mbedcrypto_src)
138 mbedcrypto_env.InstallTarget(static_libmbedcrypto, 'mbedcrypto')
139
140 mbex509_env = mbedtls_env.Clone()
141 mbex509_env.AppendUnique(LIBS = ['mbedcrypto'])
142 static_libmbedx509 = mbex509_env.StaticLibrary('mbedx509', mbeX509_src)
143 mbex509_env.InstallTarget(static_libmbedx509, 'mbedx509')
144
145
146 mbedtls_env.AppendUnique(LIBS = ['mbedx509', 'mbedcrypto'])
147 static_libmbedtls = mbedtls_env.StaticLibrary('mbedtls', mbedtls_src)
148 mbedtls_env.InstallTarget(static_libmbedtls, 'mbedtls')