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

Subversion Repositories c0or1k

[/] [c0or1k/] [trunk/] [conts/] [posix/] [test0/] [SConstruct] - Blame information for rev 6

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

Line No. Rev Author Line
1 2 drasko
#
2
# User space application build script
3
#
4
# Copyright (C) 2007 Bahadir Balban
5
#
6
import os
7
import sys
8
import shutil
9
from os.path import join
10
from glob import glob
11
from configure import *
12
 
13
config = configuration_retrieve()
14
 
15
task_name = "test0"
16
 
17
# The root directory of the repository where this file resides:
18
project_root = "../.."
19
tools_root = join(project_root, "tools")
20
prev_image = join(project_root, "tasks/fs0/fs0.axf")
21
libs_path = join(project_root, "libs")
22
ld_script = "include/linker.lds"
23
physical_base_ld_script = "include/physical_base.lds"
24
 
25
# Libc situation:
26
# Libposix has uClibc (and therefore posix) headers.
27
# NICTA libc implements printf for us for now.
28
# Libposix implements posix calls for us, e.g. mmap.
29
# In conclusion nicta libc and libposix complement each other
30
# they should not clash. In future libposix will be part of uclibc
31
# and uclibc will be used.
32
 
33
# libc paths:
34
libc_variant = "userspace"
35
libc_libpath = join(libs_path, "c/build/%s" % libc_variant)
36
libc_incpath = join(libc_libpath, "include")
37
libc_crt0 = join(libs_path, "c/build/crt/sys-userspace/arch-arm/crt0.o")
38
libc_name = "c-%s" % libc_variant
39
 
40
# libposix paths:
41
libposix_libpath = "../libposix"
42
libposix_incpath = "../libposix/include/posix"
43
 
44
# libl4 paths:
45
libl4_path = "../libl4"
46
libl4_incpath = join(libl4_path, "include")
47
 
48
# kernel paths:
49
kernel_incpath = join(project_root, "include")
50
 
51
# If crt0 is in its library path, it becomes hard to link with it.
52
# For instance the linker script must use an absolute path for it.
53
def copy_crt0(source, target, env):
54
        os.system("cp " + str(source[0]) + " " + str(target[0]))
55
 
56
def get_physical_base(source, target, env):
57
        os.system(join(tools_root, "pyelf/readelf.py --first-free-page " + \
58
                  prev_image + " >> " + physical_base_ld_script))
59
 
60
# The kernel build environment
61
env = Environment(CC = config.toolchain_userspace + 'gcc',
62
                  # We don't use -nostdinc because sometimes we need standard headers,
63
                  # such as stdarg.h e.g. for variable args, as in printk().
64
                  CCFLAGS = ['-g', '-nostdlib', '-ffreestanding', '-std=gnu99', '-Wall', '-Werror'],
65
                  LINKFLAGS = ['-nostdlib', '-T' + ld_script, "-L" + libc_libpath, "-L" + libl4_path, \
66
                                  '-L' + libposix_libpath],
67
                  ASFLAGS = ['-D__ASSEMBLY__'],
68
                  PROGSUFFIX = '.axf',                  # The suffix to use for final executable
69
                  ENV = {'PATH' : os.environ['PATH']},  # Inherit shell path
70
                  LIBS = [libc_name, 'gcc', libc_name, 'libl4', 'libposix', libc_name],
71
                  CPPFLAGS = "-D__USERSPACE__",
72
                  CPPPATH = ['#include', libl4_incpath, libposix_incpath, kernel_incpath])
73
 
74
 
75
test_exec_ld_script = "include/test_exec_linker.lds"
76
# The kernel build environment:
77
test_exec_env = Environment(CC = config.toolchain_userspace + 'gcc',
78
                  # We don't use -nostdinc because sometimes we need standard headers,
79
                  # such as stdarg.h e.g. for variable args, as in printk().
80
                  CCFLAGS = ['-O3', '-nostdlib', '-ffreestanding', '-std=gnu99', '-Wall', '-Werror'],
81
                  LINKFLAGS = ['-nostdlib', '-T' + test_exec_ld_script, "-L" + libc_libpath, "-L" + libl4_path, \
82
                                  '-L' + libposix_libpath],
83
                  ASFLAGS = ['-D__ASSEMBLY__'],
84
                  PROGSUFFIX = '.axf',                  # The suffix to use for final executable
85
                  ENV = {'PATH' : os.environ['PATH']},  # Inherit shell path
86
                  LIBS = [libc_name, 'gcc', libc_name, 'libl4', 'libposix', libc_name],
87
                  CPPFLAGS = "-D__USERSPACE__",
88
                  CPPPATH = ['#include', libl4_incpath, libposix_incpath, kernel_incpath])
89
 
90
src = [glob("src/*.c"), glob("*.c"), glob("*.S"), glob("src/arch/arm/*.c"), glob("../libcont/*.c")]
91
objs = env.Object(src)
92
physical_base = env.Command(physical_base_ld_script, prev_image, get_physical_base)
93
crt0_copied = env.Command("crt0.o", libc_crt0, copy_crt0)
94
 
95
test_exec_src = [glob("src/test_exec/*.c")]
96
test_exec_objs = test_exec_env.Object(test_exec_src)
97
test_exec_name = "test_exec"
98
test_exec = test_exec_env.Program(test_exec_name, test_exec_objs + [crt0_copied])
99
test_exec_env.Alias(test_exec_name, test_exec)
100
 
101
env.Depends(objs, test_exec)
102
task = env.Program(task_name, objs + [crt0_copied])
103
env.Alias(task_name, task)
104
 
105
# I find this to be a BUG related to SCons. SCons is still good compared to
106
# notoriously horrible makefiles, but it could have been better.
107
# if test_exec doesn't depend on physical_base, test_exec is compiled but
108
# task complains that physical_base is not there. However we already declared
109
# its dependency below.
110
 
111
env.Depends(test_exec, physical_base)
112
env.Depends(task, physical_base)

powered by: WebSVN 2.1.0

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