Imported Upstream version 1.0.0
[platform/upstream/iotivity.git] / extlibs / asn1cert / SConscript
1 ##
2 # Script to generate ASN.1 source code.
3 # If asn1 compiler is not installed get it and install it.
4 #
5 ##
6
7 import os
8
9 Import('env')
10
11 asn1_env = env.Clone()
12
13 target_os = asn1_env.get('TARGET_OS')
14 src_dir = asn1_env.get('SRC_DIR')
15
16 targets_need_asn1 = ['linux']
17 asn1c_dir      = src_dir + '/extlibs/asn1cert/asn1c-0.9.27'
18 asn1c_gz_file = src_dir + '/extlibs/asn1cert/asn1c-0.9.27.tar.gz'
19 asn1c_url      = 'http://lionet.info/soft/asn1c-0.9.27.tar.gz'
20 asn1c_file = src_dir + '/extlibs/asn1cert/asn1c-0.9.27/asn1c/asn1c'
21
22 if target_os in targets_need_asn1:
23         print '*** Checking for installation of asn1c-0.9.27 ***'
24
25         if not os.path.exists(asn1c_dir):
26                 # If the asn1 gz file is not already present, download it
27                 if not os.path.exists(asn1c_gz_file):
28                         asn1c_gz = asn1_env.Download(asn1c_gz_file, asn1c_url)
29                 else:
30                         asn1c_gz = asn1c_gz_file
31
32                 # Ungz asn1c
33                 print 'Unzipping asn1 compiler'
34                 asn1_env.UnpackAll(asn1c_dir, asn1c_gz)
35         if os.path.exists(asn1c_dir):
36                 if not os.path.exists(asn1c_file):
37                         # Run configure on asn1
38                         print 'Configuring asn1 compiler'
39                         if asn1_env.get('CROSS_COMPILE'):
40                                 asn1_env.Configure(asn1c_dir, './configure --host=' + asn1_env['CROSS_COMPILE'])
41                         else:
42                                 asn1_env.Configure(asn1c_dir, './configure')
43
44                         # Run make on asn1
45                         print 'Making asn1 compiler'
46                         asn1_env.Configure(asn1c_dir, 'make')
47         print 'Generating Source Code:'
48         asn1_env.Configure(src_dir + '/extlibs/asn1cert', './asn1c-0.9.27/asn1c/asn1c certificate.asn')
49         asn1_env.Configure(src_dir + '/extlibs/asn1cert', './asn1c-0.9.27/asn1c/asn1c crl.asn')
50         asn1_env.Configure(src_dir + '/extlibs/asn1cert', './asn1c-0.9.27/asn1c/asn1c csr.asn')
51         asn1_env.Configure(src_dir + '/extlibs/asn1cert', 'rm converter-sample.c')
52
53         #Build asn1 as static library
54         asn1_src = Glob('*.c')
55         asn1_lib = asn1_env.StaticLibrary('asn1', asn1_src)
56         asn1_env.InstallTarget(asn1_lib, 'libasn1')
57