aboutsummaryrefslogtreecommitdiffstats
path: root/SConstruct
diff options
context:
space:
mode:
Diffstat (limited to 'SConstruct')
-rw-r--r--SConstruct232
1 files changed, 0 insertions, 232 deletions
diff --git a/SConstruct b/SConstruct
deleted file mode 100644
index c41e41e..0000000
--- a/SConstruct
+++ /dev/null
@@ -1,232 +0,0 @@
1Help("""
2=============================================
3liblitmus --- The LITMUS^RT Userspace Library
4
5There are a number of user-configurable build
6variables. These can either be set on the
7command line (e.g., scons ARCH=x86) or read
8from a local configuration file (.config).
9
10Run 'scons --dump-config' to see the final
11build configuration.
12
13""")
14
15import os
16(ostype, _, _, _, arch) = os.uname()
17
18# sanity check
19if ostype != 'Linux':
20 print 'Error: Building liblitmus is only supported on Linux.'
21 Exit(1)
22
23
24# #####################################################################
25# Internal configuration.
26DEBUG_FLAGS = '-Wall -g -Wdeclaration-after-statement'
27API_FLAGS = '-D_XOPEN_SOURCE=600 -D_GNU_SOURCE'
28X86_32_FLAGS = '-m32'
29X86_64_FLAGS = '-m64'
30V9_FLAGS = '-mcpu=v9 -m64'
31
32SUPPORTED_ARCHS = {
33 'sparc64' : V9_FLAGS,
34 'x86' : X86_32_FLAGS,
35 'x86_64' : X86_64_FLAGS,
36}
37
38ARCH_ALIAS = {
39 'i686' : 'x86'
40}
41
42# name of the directory that has the arch headers in the Linux source
43INCLUDE_ARCH = {
44 'sparc64' : 'sparc',
45 'x86' : 'x86',
46 'x86_64' : 'x86',
47}
48
49INCLUDE_DIRS = [
50 # library headers
51 'include/',
52 # Linux kernel headers
53 '${LITMUS_KERNEL}/include/',
54 # Linux architecture-specific kernel headers
55 '$LITMUS_KERNEL/arch/${INCLUDE_ARCH}/include'
56 ]
57
58# #####################################################################
59# User configuration.
60
61vars = Variables('.config', ARGUMENTS)
62
63vars.AddVariables(
64 PathVariable('LITMUS_KERNEL',
65 'Where to find the LITMUS^RT kernel.',
66 '../litmus2010'),
67
68 EnumVariable('ARCH',
69 'Target architecture.',
70 arch,
71 SUPPORTED_ARCHS.keys() + ARCH_ALIAS.keys()),
72)
73
74AddOption('--dump-config',
75 dest='dump',
76 action='store_true',
77 default=False,
78 help="dump the build configuration and exit")
79
80# #####################################################################
81# Build configuration.
82
83env = Environment(variables = vars)
84
85# Check what we are building for.
86arch = env['ARCH']
87
88# replace if the arch has an alternative name
89if arch in ARCH_ALIAS:
90 arch = ARCH_ALIAS[arch]
91 env['ARCH'] = arch
92
93# Get include directory for arch.
94env['INCLUDE_ARCH'] = INCLUDE_ARCH[arch]
95
96arch_flags = Split(SUPPORTED_ARCHS[arch])
97dbg_flags = Split(DEBUG_FLAGS)
98api_flags = Split(API_FLAGS)
99
100# Set up environment
101env.Replace(
102 CC = 'gcc',
103 CPPPATH = INCLUDE_DIRS,
104 CCFLAGS = dbg_flags + api_flags + arch_flags,
105 LINKFLAGS = arch_flags,
106)
107
108def dump_config(env):
109 def dump(key):
110 print "%15s = %s" % (key, env.subst("${%s}" % key))
111
112 dump('ARCH')
113 dump('LITMUS_KERNEL')
114 dump('CPPPATH')
115 dump('CCFLAGS')
116 dump('LINKFLAGS')
117
118if GetOption('dump'):
119 print "\n"
120 print "Build Configuration:"
121 dump_config(env)
122 print "\n"
123 Exit(0)
124
125# #####################################################################
126# Build checks.
127
128def CheckSyscallNr(context):
129 context.Message('Checking for LITMUS^RT syscall numbers... ')
130 nrSrc = """
131#include <linux/unistd.h>
132int main(int argc, char **argv)
133{
134 return __NR_set_rt_task_param;
135}
136"""
137 result = context.TryLink(nrSrc, '.c')
138 context.Result(result)
139 return result
140
141
142def abort(msg, help=None):
143 print "Error: %s" % env.subst(msg)
144 print "-" * 80
145 print "This is the build configuration in use:"
146 dump_config(env)
147 if help:
148 print "-" * 80
149 print env.subst(help)
150 print "\n"
151 Exit(1)
152
153# Check compile environment
154if not (env.GetOption('clean') or env.GetOption('help')):
155 print env.subst('Building ${ARCH} binaries.')
156 # Check for kernel headers.
157 conf = Configure(env, custom_tests = {'CheckSyscallNr' : CheckSyscallNr})
158
159 conf.CheckCHeader('linux/unistd.h') or \
160 abort("Cannot find kernel headers in '$LITMUS_KERNEL'",
161 "Please ensure that LITMUS_KERNEL in .config is set to a valid path.")
162
163 conf.CheckCHeader('litmus/rt_param.h') or \
164 abort("Cannot find LITMUS^RT headers in '$LITMUS_KERNEL'",
165 "Please ensure sure that the kernel in '$LITMUS_KERNEL'"
166 " is a LITMUS^RT kernel.")
167
168 conf.CheckSyscallNr() or \
169 abort("The LITMUS^RT syscall numbers are not available.",
170 "Please ensure sure that the kernel in '$LITMUS_KERNEL'"
171 " is a LITMUS^RT kernel.")
172
173 env = conf.Finish()
174
175# #####################################################################
176# Derived environments
177
178# link with liblitmus
179rt = env.Clone(
180 LIBS = Split('litmus rt'),
181 LIBPATH = '.'
182)
183rt.Append(LINKFLAGS = '-static')
184
185
186# link with math lib
187rtm = rt.Clone()
188rtm.Append(LIBS = ['m'])
189
190# multithreaded real-time tasks
191mtrt = rt.Clone()
192mtrt.Append(LINKFLAGS = '-pthread')
193
194# #####################################################################
195# Targets: liblitmus
196# All the files in src/ are part of the library.
197env.Library('litmus',
198 ['src/kernel_iface.c', 'src/litmus.c',
199 'src/syscalls.c', 'src/task.c'])
200
201# #####################################################################
202# Targets: simple tools that do not depend on liblitmus
203env.Program('cycles', 'bin/cycles.c')
204
205# #####################################################################
206# Targets: tools that depend on liblitmus
207rt.Program('base_task', 'bin/base_task.c')
208mtrt.Program('base_mt_task', 'bin/base_mt_task.c')
209rt.Program('rt_launch', ['bin/rt_launch.c', 'bin/common.c'])
210rt.Program('rtspin', ['bin/rtspin.c', 'bin/common.c'])
211rt.Program('release_ts', 'bin/release_ts.c')
212rtm.Program('measure_syscall', 'bin/null_call.c')
213
214
215# #####################################################################
216# Test suite.
217
218mkc = Builder(action = 'tests/make_catalog.py $SOURCES > $TARGET')
219test = mtrt.Clone()
220test.Append(BUILDERS = {'TestCatalog' : mkc})
221test.Append(CPPPATH = ['tests/'])
222
223catalog = test.TestCatalog('tests/__test_catalog.inc', Glob('tests/*.c'))
224test.Program('runtests', Glob('tests/*.c'))
225
226# #####################################################################
227# Additional Help
228
229Help("Build Variables\n")
230Help("---------------\n")
231Help(vars.GenerateHelpText(env))
232