3 opts
= Options('scache.conf')
4 ### These options are global defaults.
5 ### If you want to change your options locally,
6 ### give them to SCons on the command line, or
7 ### edit scache.conf. Don't edit them here.
9 ('CC', 'Set the C compiler to use'),
10 ('AS', 'Set the NASM executable name'),
11 ('LINK', 'Set the linker to use'),
12 ('CFLAGS', 'Set the C compiler flags', '-ffreestanding -m32 -O3 -Wall -std=c99 -pedantic'),
13 ('ASFLAGS', 'Set the assembler flags', ''),
14 ('LINKFLAGS', 'Set the linker flags', '-ffreestanding -nostdlib -Wl,--gc-sections,-m,elf_i386'),
15 ('BUILDDIR', 'Set the sub-directory to put object files in', 'build'),
16 BoolOption('verbose', 'Show full commands during the build process', False),
19 env
= Environment(options
= opts
, tools
=['default', 'nasm'])
20 Help(opts
.GenerateHelpText(env
))
21 opts
.Save('scache.conf', env
)
24 def check_nasm32(context
):
25 """check whether nasm uses -f elf or -f elf32"""
26 context
.Message('Checking for nasm -f elf32... ')
27 context
.env
['ASFLAGS'] = '-f elf32'
28 result
= context
.TryCompile('', '.asm')
29 context
.Result(result
)
32 def check_stack_prot(context
):
33 """check whether gcc supports -fno-stack-protector"""
34 context
.Message('Checking for -fno-stack-protector... ')
35 context
.env
['CFLAGS'] = '-fno-stack-protector'
36 result
= context
.TryCompile('', '.c')
37 context
.Result(result
)
42 if not env
.GetOption('clean'):
43 ### RUN TESTS AND CONFIGURE ENVIRONMENT ###
44 conf
= Configure(env
, custom_tests
= OurTests
.__dict
__)
46 # Does NASM want '-f elf' or '-f elf32' ?
47 if conf
.check_nasm32():
48 env
['ASFLAGS'] = old_env
['ASFLAGS'] + ' -f elf32'
50 env
['ASFLAGS'] = old_env
['ASFLAGS'] + ' -f elf'
52 # If the compiler has -fno-stack-protector, we need to disable
53 # it to stop gcc inserting stack protection code (which doesn't
55 if conf
.check_stack_prot():
56 env
['CFLAGS'] = old_env
['CFLAGS'] + ' -fno-stack-protector'
58 env
['CFLAGS'] = old_env
['CFLAGS']
62 # set nice pretty messages
63 if not env
['verbose']:
64 env
['CCCOMSTR'] = ' Compiling \e[32m$TARGET\e[0m'
65 env
['ASCOMSTR'] = ' Assembling \e[32m$TARGET\e[0m'
66 env
['LINKCOMSTR'] = ' Linking \e[32m$TARGET\e[0m'
67 env
['ARCOMSTR'] = ' Archiving \e[32m$TARGET\e[0m'
68 env
['RANLIBCOMSTR'] = ' Indexing \e[32m$TARGET\e[0m'
69 env
['NMCOMSTR'] = ' Creating map \e[32m$TARGET\e[0m'
71 SConscript('SConscript',
73 build_dir
= env
['BUILDDIR'],
77 env
.Clean('.', ['config.log', '.sconf_temp'])