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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
|
# #####################################################################
# User configuration.
LITMUS_KERNEL = '../litmus2008'
# #####################################################################
# Internal configuration.
DEBUG_FLAGS = '-Wall -g -Wdeclaration-after-statement'
API_FLAGS = '-D_XOPEN_SOURCE=600 -D_GNU_SOURCE'
X86_32_FLAGS = '-m32'
X86_64_FLAGS = '-m64'
V9_FLAGS = '-mcpu=v9 -m64'
SUPPORTED_ARCHS = {
'sparc64' : V9_FLAGS,
'i686' : X86_32_FLAGS,
'i386' : X86_32_FLAGS,
'x86_64' : X86_64_FLAGS,
}
KERNEL_INCLUDE = '%s/include/' % LITMUS_KERNEL
INCLUDE_DIRS = 'include/ ' + KERNEL_INCLUDE
# #####################################################################
# Build checks.
nrSrc = """#include <linux/unistd.h>
int main(int argc, char **argv)
{
return __NR_set_rt_task_param;
}
"""
def CheckASMLink(context):
context.Message('Checking for asm/ link in kernel include/... ')
result = context.TryLink(nrSrc, '.c')
context.Result(result)
return result
# #####################################################################
# Build configuration.
from os import uname, environ
# sanity check
(ostype, _, _, _, arch) = uname()
if ostype != 'Linux':
print 'Error: Building liblitmus is only supported on Linux.'
Exit(1)
# override arch if ARCH is set in environment or command line
if 'ARCH' in ARGUMENTS:
arch = ARGUMENTS['ARCH']
elif 'ARCH' in environ:
arch = environ['ARCH']
if arch not in SUPPORTED_ARCHS:
print 'Error: Building ft_tools is only supported for the following', \
'architectures: %s.' % ', '.join(sorted(SUPPORTED_ARCHS))
Exit(1)
else:
arch_flags = Split(SUPPORTED_ARCHS[arch])
env = Environment(
CC = 'gcc',
CPPPATH = Split(INCLUDE_DIRS),
CCFLAGS = Split(DEBUG_FLAGS) + Split(API_FLAGS) + arch_flags,
LINKFLAGS = arch_flags,
)
# Check compile environment
if not env.GetOption('clean'):
print 'Building %s binaries.' % arch
# Check for kernel headers.
conf = Configure(env, custom_tests = {'CheckASMLink' : CheckASMLink})
if not conf.CheckCHeader('litmus/rt_param.h'):
print "Error: Canot find kernel headers in '%s'." % LITMUS_KERNEL
print "Please ensure that LITMUS_KERNEL in SConstruct", \
"contains a valid path."
Exit(1)
if not conf.CheckASMLink():
print "Error: The LITMUS^RT syscall numbers are not available."
print "Please ensure sure that the kernel in '%s' is configured." \
% LITMUS_KERNEL
Exit(1)
env = conf.Finish()
# link with libst
st = env.Clone(
LIBS = 'st',
LIBPATH = '.'
)
# link with liblitmus
rt = env.Clone(
LIBS = 'litmus',
LIBPATH = '.'
)
rt.Append(LINKFLAGS = '-static')
# link with math lib
rtm = rt.Clone()
rtm.Append(LIBS = ['m'])
# multithreaded real-time tasks
mtrt = rt.Clone()
mtrt.Append(LINKFLAGS = '-pthread')
# #####################################################################
# Targets: liblitmus libst
# All the files in src/ are part of the library.
env.Library('litmus',
['src/kernel_iface.c', 'src/litmus.c',
'src/syscalls.c', 'src/task.c'])
env.Library('st', ['src/sched_trace.c'])
# #####################################################################
# Targets: simple tools that do not depend on liblitmus
env.Program('cycles', 'bin/cycles.c')
# #####################################################################
# Targets: tools that depend on liblitmus
rt.Program('base_task', 'bin/base_task.c')
mtrt.Program('base_mt_task', 'bin/base_mt_task.c')
rt.Program('wait_test', 'bin/wait_test.c')
rt.Program('mode_test', 'bin/mode_test.c')
rt.Program('np_test', 'bin/np_test.c')
rt.Program('rt_launch', ['bin/rt_launch.c', 'bin/common.c'])
rt.Program('rtspin', ['bin/rtspin.c', 'bin/common.c'])
rt.Program('release_ts', 'bin/release_ts.c')
rtm.Program('measure_syscall', 'bin/null_call.c')
st.Program('showst', 'bin/showst.c')
|