linker.ld: use all .data* and .bss* sections
[marionette.git] / SConstruct
blob4ca7349324c067f2f1da25504267f2142cd2c805
1 import os
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.
8 opts.AddOptions(
9 ('CC', 'Set the C compiler to use'),
10 ('AS', 'Set the assembler to use'),
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(
20 options = opts,
21 tools=['default'],
22 ENV = os.environ)
23 Help(opts.GenerateHelpText(env))
24 opts.Save('scache.conf', env)
26 class OurTests:
27 def check_stack_prot(context):
28 """check whether gcc supports -fno-stack-protector"""
29 context.Message('Checking for -fno-stack-protector... ')
30 context.env['CFLAGS'] = '-fno-stack-protector'
31 result = context.TryCompile('', '.c')
32 context.Result(result)
33 return result
35 old_env = env.Clone()
37 if not env.GetOption('clean'):
38 ### RUN TESTS AND CONFIGURE ENVIRONMENT ###
39 conf = Configure(env, custom_tests = OurTests.__dict__)
41 # If the compiler has -fno-stack-protector, we need to disable
42 # it to stop gcc inserting stack protection code (which doesn't
43 # work in a kernel)
44 if conf.check_stack_prot():
45 env['CFLAGS'] = old_env['CFLAGS'] + ' -fno-stack-protector'
46 else:
47 env['CFLAGS'] = old_env['CFLAGS']
49 env = conf.Finish()
51 # set nice pretty messages
52 if not env['verbose']:
53 env['CCCOMSTR'] = ' Compiling \e[32m$TARGET\e[0m'
54 env['ASPPCOMSTR'] = ' Assembling \e[32m$TARGET\e[0m'
55 env['LINKCOMSTR'] = ' Linking \e[32m$TARGET\e[0m'
56 env['ARCOMSTR'] = ' Archiving \e[32m$TARGET\e[0m'
57 env['RANLIBCOMSTR'] = ' Indexing \e[32m$TARGET\e[0m'
58 env['NMCOMSTR'] = ' Creating map \e[32m$TARGET\e[0m'
60 SConscript('SConscript',
61 exports = ['env'],
62 build_dir = env['BUILDDIR'],
63 duplicate = 0)
65 # clean config data
66 env.Clean('.', ['config.log', '.sconf_temp'])