1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
#
# (C) COPYRIGHT 2010-2012 ARM Limited. All rights reserved.
#
# This program is free software and is provided to you under the terms of the
# GNU General Public License version 2 as published by the Free Software
# Foundation, and any use by you of this program is subject to the terms
# of such GNU licence.
#
# A copy of the licence is included with the program, and can also be obtained
# from Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
# Boston, MA 02110-1301, USA.
#
#
import os
import re
Import('env')
# If KDS is built into the kernel already we skip building the module ourselves
linux_config_file = os.path.normpath(os.environ['KDIR']) + '/.config'
search_term = '^[\ ]*CONFIG_KDS[\ ]*=[\ ]*y'
build_kds = 1
for line in open(linux_config_file, 'r'):
if re.search(search_term, line):
# KDS in kernel. Do not build KDS kernel module but
# still allow for building kds_test module.
build_kds = 0
if env['v'] != '1':
env['MAKECOMSTR'] = '[MAKE] ${SOURCE.dir}'
src = [Glob('#kernel/drivers/base/kds/*.c'), Glob('#kernel/include/linux/*.h'), Glob('#kernel/drivers/base/kds/K*')]
env.Append( CPPPATH = '#kernel/include' )
arch = env['arch']
# translate into something Linux understands
if arch == 'x86_32':
arch = 'x86'
elif 'arm' in arch:
arch = 'arm'
if Glob('tests/sconscript'):
SConscript( 'tests/sconscript' )
if env.GetOption('clean') :
# Clean KDS module
if build_kds:
env.Execute(Action("make ARCH=%s clean" % arch, '[CLEAN] kds'))
cmd = env.Command('$STATIC_LIB_PATH/kds.ko', src, [])
env.ProgTarget('kds', cmd)
# Clean KDS test module
if (int(env['unit']) == 1):
cmdTest = env.Command('$STATIC_LIB_PATH/kds_test.ko', src, [])
env.ProgTarget('kds', cmdTest)
else:
# Build KDS module
if build_kds:
makeAction=Action("cd ${SOURCE.dir} && make kds ARCH=%s && cp kds.ko $STATIC_LIB_PATH/" % arch, '$MAKECOMSTR')
cmd = env.Command('$STATIC_LIB_PATH/kds.ko', src, [makeAction])
env.ProgTarget('kds', cmd)
# Build KDS test module
if int(env['unit']) == 1:
makeActionTest=Action("cd ${SOURCE.dir} && make kds_test ARCH=%s && cp kds_test.ko $STATIC_LIB_PATH/" %arch, '$MAKECOMSTR')
cmdTest = env.Command('$STATIC_LIB_PATH/kds_test.ko', src, [makeActionTest])
env.ProgTarget('kds', cmdTest)
if build_kds:
Depends(cmdTest, cmd)
|