1 |
2 |
drasko |
# -*- mode: python; coding: utf-8; -*-
|
2 |
|
|
#
|
3 |
|
|
# Codezero -- a microkernel for embedded systems.
|
4 |
|
|
#
|
5 |
|
|
# Copyright © 2009 B Labs Ltd
|
6 |
|
|
|
7 |
|
|
import os, sys, shelve
|
8 |
|
|
from os.path import join
|
9 |
|
|
|
10 |
|
|
from config.configuration import *
|
11 |
|
|
from config.projpaths import *
|
12 |
|
|
|
13 |
|
|
config = configuration_retrieve()
|
14 |
|
|
arch = config.arch
|
15 |
|
|
platform = config.platform
|
16 |
|
|
gcc_arch_flag = config.gcc_arch_flag
|
17 |
|
|
|
18 |
|
|
variant = 'baremetal'
|
19 |
|
|
|
20 |
|
|
# Locally important paths are here
|
21 |
|
|
LIBC_PATH = 'loader/libs/c'
|
22 |
|
|
LIBC_LIBPATH = LIBC_PATH
|
23 |
|
|
LIBC_INCPATH = ['#' + join(LIBC_PATH, 'include'), \
|
24 |
|
|
'#' + join(LIBC_PATH, 'include/arch/' + arch)]
|
25 |
|
|
|
26 |
|
|
LIBDEV_PATH = 'conts/libdev'
|
27 |
|
|
LIBDEV_INCPATH = ['#' + join(LIBDEV_PATH, 'include'),]
|
28 |
|
|
|
29 |
|
|
LIBELF_PATH = 'loader/libs/elf'
|
30 |
|
|
LIBELF_LIBPATH = LIBELF_PATH
|
31 |
|
|
LIBELF_INCPATH = '#' + join(LIBELF_PATH, 'include')
|
32 |
|
|
|
33 |
|
|
env = Environment(CC = config.toolchain_kernel + 'gcc',
|
34 |
|
|
AR = config.toolchain_kernel + 'ar',
|
35 |
|
|
RANLIB = config.toolchain_kernel + 'ranlib',
|
36 |
|
|
# We don't use -nostdinc because sometimes we need standard headers,
|
37 |
|
|
# such as stdarg.h e.g. for variable args, as in printk().
|
38 |
|
|
CCFLAGS = ['-g', '-nostdlib', '-ffreestanding', '-std=gnu99', '-Wall', \
|
39 |
5 |
drasko |
'-Werror'],
|
40 |
2 |
drasko |
LINKFLAGS = ['-nostdlib', '-T' + join(BUILDDIR, 'loader/linker.lds'), "-u_start"],
|
41 |
|
|
ASFLAGS = ['-D__ASSEMBLY__'],
|
42 |
|
|
PROGSUFFIX = '.elf',
|
43 |
|
|
ENV = {'PATH' : os.environ['PATH']},
|
44 |
|
|
LIBS = ['gcc', 'elf', 'libdev-baremetal', 'c-baremetal', 'gcc'],
|
45 |
|
|
LIBPATH = [join(join('build', LIBDEV_PATH), 'sys-' + variant), \
|
46 |
|
|
join('build', LIBELF_PATH), join('build', LIBC_PATH)],
|
47 |
|
|
CPPPATH = ['#include', LIBDEV_INCPATH, LIBC_INCPATH, LIBELF_INCPATH],
|
48 |
|
|
CPPFLAGS = '-include l4/config.h -include l4/macros.h -include l4/types.h -D__KERNEL__')
|
49 |
|
|
|
50 |
|
|
libdev = SConscript('conts/libdev/SConscript', \
|
51 |
|
|
exports = { 'env' : env, 'arch' : arch, 'platform' : platform, 'type' : variant}, \
|
52 |
|
|
duplicate = 0, variant_dir = 'build/conts/libdev/sys-' + variant)
|
53 |
|
|
libc = SConscript('loader/libs/c/SConscript', \
|
54 |
|
|
exports = { 'env' : env, 'arch' : arch, 'platform' : platform, 'type' : variant}, \
|
55 |
|
|
duplicate = 0, variant_dir = 'build/loader/libs/c')
|
56 |
|
|
libelf = SConscript('loader/libs/elf/SConscript', exports = { 'env' : env }, \
|
57 |
|
|
duplicate = 0, variant_dir = 'build/loader/libs/elf')
|
58 |
|
|
|
59 |
|
|
loader_objs = SConscript('loader/SConscript', exports = { 'env' : env }, \
|
60 |
|
|
duplicate = 0, variant_dir = 'build/loader')
|
61 |
|
|
|
62 |
|
|
final_elf = env.Program('build/final.elf', [libelf + libc + loader_objs])
|
63 |
|
|
Depends(loader_objs, libelf)
|
64 |
|
|
Depends(loader_objs, libc)
|