blob: 91a79fd4a40c56cb617bd8c861165805eb92a77a [file] [log] [blame]
#
# (C) COPYRIGHT 2010-2016 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')
#Android uses sync_pt to accomplish KDS functionality.
#Midgard KDS is not used by Android
if env['os'] == 'android':
Return()
# 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
src = [Glob('#kernel/drivers/base/kds/*.c'), Glob('#kernel/include/linux/*.h'), Glob('#kernel/drivers/base/kds/K*')]
env.Append( CPPPATH = '#kernel/include' )
if Glob('tests/sconscript'):
SConscript( 'tests/sconscript' )
if env.GetOption('clean') :
# Clean KDS module
if build_kds or (int(env['unit']) == 1):
env.Execute(Action("make clean", '[CLEAN] kds'))
cmd = env.Command('$STATIC_LIB_PATH/kds.ko', src, [])
env.KernelObjTarget('kds', cmd)
else:
# Build KDS module
if build_kds:
makeAction=Action("cd ${SOURCE.dir} && make kds && cp kds.ko $STATIC_LIB_PATH/", '$MAKECOMSTR')
cmd = env.Command('$STATIC_LIB_PATH/kds.ko', src, [makeAction])
env.KernelObjTarget('kds', cmd)
# Build KDS test module
if int(env['unit']) == 1:
makeActionTest=Action("cd ${SOURCE.dir} && make kds_test && cp kds_test.ko $STATIC_LIB_PATH/", '$MAKECOMSTR')
cmdTest = env.Command('$STATIC_LIB_PATH/kds_test.ko', src, [makeActionTest])
env.KernelObjTarget('kds', cmdTest)
if build_kds:
env.Depends(cmdTest, cmd)