-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSConstruct
More file actions
73 lines (57 loc) · 1.85 KB
/
SConstruct
File metadata and controls
73 lines (57 loc) · 1.85 KB
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
from glob import glob
from sys import byteorder
#
# Commandline options
#
opts = Options()
opts.Add(
'prefix', 'Installation prefix.', '/usr')
opts.Add(
'staging', 'Staging directory to install to. Useful for packaging.', '')
opts.Add(BoolOption(
'debug', 'Build with debugging symbols and optimization turned off.', 0))
#
# Core environment
#
env = Environment(options = opts, CCFLAGS=['-Wall', '-Werror', '-std=gnu99'])
Help(opts.GenerateHelpText(env))
#
# "Autoconf" configuration
#
if not env.GetOption('clean'):
conf = Configure(env)
if not conf.CheckLibWithHeader('usb', 'usb.h', 'C'):
print 'Could not find libusb, which is required by libnxt.'
Exit(1)
env = conf.Finish()
# Detect the system's endianness
orders = {
'big': '_NXT_BIG_ENDIAN',
'little': '_NXT_LITTLE_ENDIAN',
}
env.Append(CCFLAGS = '-D%s' % orders[byteorder])
# Set debugging or optimization flags
if env['debug']:
env.Append(CCFLAGS = ['-g', '-ggdb', '-O0'])
else:
env.Append(CCFLAGS = ['-O3'])
#
# Actual build rules.
#
env.Command('flash_routine.h',
'flash_routine.h.base',
'./make_flash_header.py')
libnxt_sources = [x for x in glob('*.c') if not x.startswith('main_')]
libnxt_a = env.StaticLibrary('nxt', libnxt_sources, LIBS='usb')
libnxt_so = env.SharedLibrary('nxt', libnxt_sources, LIBS='usb')
prog_libs = ['usb', libnxt_so]
fwflash = env.Program('fwflash', 'main_fwflash.c', LIBS=prog_libs)
fwexec = env.Program('fwexec', 'main_fwexec.c', LIBS=prog_libs)
env.Default(libnxt_a, libnxt_so, fwflash, fwexec)
#
# Installation rules
#
install_root = env['staging'] + env['prefix']
install_libs = env.Install(install_root + '/lib', [libnxt_a, libnxt_so])
install_bins = env.Install(install_root + '/bin', [fwflash, fwexec])
env.Alias('install', [install_libs, install_bins])