OpenCores
URL https://opencores.org/ocsvn/c0or1k/c0or1k/trunk

Subversion Repositories c0or1k

[/] [c0or1k/] [trunk/] [SConstruct] - Blame information for rev 2

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 drasko
# -*- mode: python; coding: utf-8; -*-
2
#
3
#  Codezero -- Virtualization microkernel for embedded systems.
4
#
5
#  Copyright © 2009  B Labs Ltd
6
#
7
import os, shelve
8
import configure
9
from configure import *
10
from os.path import *
11
 
12
config = configuration_retrieve()
13
arch = config.arch
14
subarch = config.subarch
15
platform = config.platform
16
gcc_arch_flag = config.gcc_arch_flag
17
all_syms = config.all
18
builddir='build/codezero/'
19
 
20
 
21
# Generate kernel linker script at runtime using template file.
22
def generate_kernel_linker_script(target, source, env):
23
    linker_in = source[0]
24
    linker_out = target[0]
25
 
26
    cmd = config.toolchain_kernel + "cpp -D__CPP__ " + \
27
          "-I%s -imacros l4/macros.h -imacros %s -imacros %s -C -P %s -o %s" % \
28
                ('include', 'l4/platform/'+ platform + '/offsets.h', \
29
                 'l4/glue/' + arch + '/memlayout.h', linker_in, linker_out)
30
    os.system(cmd)
31
 
32
create_kernel_linker = Command(join(builddir, 'include/l4/arch/arm/linker.lds'), \
33
                               join(PROJROOT, 'include/l4/arch/arm/linker.lds.in'), \
34
                               generate_kernel_linker_script)
35
 
36
'''
37
# Generate linker file with physical addresses,
38
# to be used for debug purpose only
39
def generate_kernel_phys_linker_script(target, source, env):
40
    phys_linker_in = source[0]
41
    phys_linker_out = target[0]
42
 
43
    cmd = config.toolchain_kernel + "cpp -D__CPP__ " + \
44
          "-I%s -imacros l4/macros.h -imacros %s -imacros %s -C -P %s -o %s" % \
45
                ('include', 'l4/platform/'+ platform + '/offsets.h', \
46
                 'l4/glue/' + arch + '/memlayout.h', phys_linker_in, phys_linker_out)
47
    os.system(cmd)
48
 
49
create_kernel_phys_linker = Command(join(builddir, 'include/physlink.lds'), \
50
                               join(PROJROOT, 'include/l4/arch/arm/linker.lds.in'), \
51
                               generate_kernel_phys_linker_script)
52
'''
53
 
54
env = Environment(CC = config.toolchain_kernel + 'gcc',
55
                  AR = config.toolchain_kernel + 'ar',
56
                  RANLIB = config.toolchain_kernel + 'ranlib',
57
                  # We don't use -nostdinc because sometimes we need standard headers,
58
                  # such as stdarg.h e.g. for variable args, as in printk().
59
                  CCFLAGS = ['-g', '-nostdlib', '-ffreestanding', '-std=gnu99', '-Wall', \
60
                             '-Werror', '-march=' + gcc_arch_flag],
61
                  LINKFLAGS = ['-nostdlib', '-T' + join(builddir, 'include/l4/arch/arm/linker.lds')],
62
                  ASFLAGS = ['-D__ASSEMBLY__', '-march=' + gcc_arch_flag],
63
                  PROGSUFFIX = '.elf',                  # The suffix to use for final executable
64
                  ENV = {'PATH' : os.environ['PATH']},  # Inherit shell path
65
                  LIBS = 'gcc',                         # libgcc.a - This is required for division routines.
66
                  CPPPATH = ["#include"],
67
                  CPPFLAGS = '-include l4/config.h -include l4/macros.h -include l4/types.h -D__KERNEL__')
68
 
69
objects = []
70
 
71
objects += SConscript('src/generic/SConscript',
72
                      exports = {'symbols' : all_syms, 'env' : env},
73
                      duplicate=0, build_dir=builddir + 'generic')
74
 
75
objects += SConscript('src/glue/' + arch + '/SConscript',
76
                      exports = {'symbols' : all_syms, 'env' : env},
77
                      duplicate=0, build_dir=builddir + 'glue' + '/' + arch)
78
 
79
objects += SConscript('src/arch/' + arch + '/SConscript',
80
                      exports = {'symbols' : all_syms, 'env' : env},
81
                      duplicate=0, build_dir=builddir + 'arch/' + arch)
82
 
83
objects += SConscript('src/arch/' + arch + '/' + subarch + '/SConscript',
84
                      exports = {'symbols' : all_syms, 'env' : env},
85
                      duplicate=0, build_dir=builddir + 'arch/' + arch + '/' + subarch)
86
 
87
objects += SConscript('src/lib/SConscript',
88
                      exports = {'symbols' : all_syms, 'env' : env},
89
                      duplicate=0, build_dir=builddir + 'lib')
90
 
91
objects += SConscript('src/api/SConscript',
92
                      exports = {'symbols' : all_syms, 'env' : env},
93
                      duplicate=0, build_dir=builddir + 'api')
94
 
95
objects += SConscript('src/drivers/SConscript',
96
                      exports = {'symbols' : all_syms, 'env' : env, 'platform' : platform,'bdir' : 'driver/'},
97
                      duplicate=0, build_dir=builddir)
98
 
99
objects += SConscript('src/platform/' + platform + '/SConscript',
100
                      exports = {'symbols' : all_syms, 'env' : env,'platform' : platform}, duplicate=0,
101
                      build_dir=builddir + 'platform' + '/' +platform)
102
 
103
kernel_elf = env.Program(BUILDDIR + '/kernel.elf', objects)
104
#env_phys = env.Clone()
105
#env_phys.Replace(LINKFLAGS = ['-nostdlib', '-T' + join(builddir, 'include/physlink.lds')])
106
#env_phys.Program(BUILDDIR + '/kernel_phys.elf', objects)
107
 
108
Alias('kernel', kernel_elf)
109
Depends(kernel_elf, objects)
110
Depends(objects, create_kernel_linker)
111
#Depends(objects, create_kernel_phys_linker)
112
Depends(objects, 'include/l4/config.h')
113
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.