diff --git a/SConstruct b/SConstruct index d512d51..b61d85a 100644 --- a/SConstruct +++ b/SConstruct @@ -4,9 +4,44 @@ # # Copyright © 2009 B Labs Ltd # -import os -import configure +import os, shelve +from configure import configure_kernel -if 'configure' in COMMAND_LINE_TARGETS: - cml2_configure("configs/arm.cml") + + +env = Environment(CC = 'arm-none-eabi-gcc', + # We don't use -nostdinc because sometimes we need standard headers, + # such as stdarg.h e.g. for variable args, as in printk(). + CCFLAGS = ['-g', '-mcpu=arm926ej-s', '-nostdlib', '-ffreestanding', \ + '-std=gnu99', '-Wall', '-Werror'], + LINKFLAGS = ['-nostdlib', '-T' + "include/l4/arch/arm/linker.lds"], + ASFLAGS = ['-D__ASSEMBLY__'], + PROGSUFFIX = '.elf', # The suffix to use for final executable + ENV = {'PATH' : os.environ['PATH']}, # Inherit shell path + LIBS = 'gcc', # libgcc.a - This is required for division routines. + CPPPATH = "#include", + CPPFLAGS = '-include l4/config.h -include l4/macros.h -include l4/types.h -D__KERNEL__') + +config_shelve = shelve.open("build/configdata/configuration") +configuration = config_shelve["cml2_config"] +cf = configuration + +sources = \ + Glob('src/api/*.[cS]') + \ + Glob('src/generic/*.[cS]') + \ + Glob('src/lib/*.[cS]') + \ + Glob('src/arch/' + cf['ARCH'] + '/*.[cS]') + \ + Glob('src/arch/' + cf['ARCH'] + '/' + cf['SUBARCH'] +'/*.[cS]') + \ + Glob('src/glue/' + cf['ARCH'] + '/*.[cS]') + \ + Glob('src/platform/' + cf['PLATFORM'] + '/*.[cS]') + +for item in cf['DRIVER'] : + path = 'src/drivers/' + item + if not os.path.isdir(path): + feature , device = item.split ( '/' ) + raise ValueError, 'Driver ' + device + ' for ' + feature + ' not available.' + sources += Glob(path + '/*.[cS]') + +objects = env.Object(sources) +startAxf = env.Program('start.axf', objects) diff --git a/configure.py b/configure.py index 9f22ae2..3be3ac7 100755 --- a/configure.py +++ b/configure.py @@ -1,21 +1,40 @@ #! /usr/bin/env python2.6 # -*- mode: python; coding: utf-8; -*- -import os +import os, sys, shelve, shutil from os.path import join PROJROOT = os.getcwd() BUILDDIR = join(PROJROOT, "build") TOOLSDIR = join(PROJROOT, "tools") CML2TOOLSDIR = join(TOOLSDIR, "cml2-tools") -CML2RULES = join(BUILDDIR, "cml2_rules.out") +CML2RULES = join(BUILDDIR, "cml2_rules.out") CML2_CONFIG_PROPERTIES = join(BUILDDIR, "cml2_config.out") CML2_CONFIG_H = join(BUILDDIR, "cml2_config.h") - - +CONFIG_H = join(BUILDDIR, "l4/config.h") +CONFIG_DATA_DIR = join(BUILDDIR, "configdata") +CONFIG_DATA_FILENAME = "configuration" +CONFIG_DATA = join(CONFIG_DATA_DIR, CONFIG_DATA_FILENAME) configuration = {} -def cml2_rest(): +def save_configuration(configuration): + if not os.path.exists(CONFIG_DATA_DIR): + os.mkdir(CONFIG_DATA_DIR) + + config_shelve = shelve.open(CONFIG_DATA) + config_shelve["cml2_config"] = configuration + config_shelve.close() + +def cml2_process(cml2_conf_props): + config_items = {} + with file(cml2_conf_props) as config_file: + for line in config_file: + item = line.split('=') + if len(item) == 2: + config_items[item[0].strip()] = (item[1].strip() == 'y') + return config_items + +def cml2_config_to_symbols(): config_h_path = BUILDDIR + '/l4/config.h' config_data = cml2_process(CML2_CONFIG_PROPERTIES) @@ -37,29 +56,28 @@ def cml2_rest(): except KeyError: configuration[items[0]] = [] configuration[items[0]].append(path) - with open(config_h_path, "w+") as config_h: - config_h.write("#define __ARCH__ " + configuration['ARCH']) - config_h.write("#define __PLATFORM__" + configuration['PLATFORM']) - config_h.write("#define __SUBARCH__" + configuration['SUBARCH']) - print configuration - -def cml2_process(cml2_conf_props): - config_items = {} - with file(cml2_conf_props) as config_file: - for line in config_file: - item = line.split('=') - if len(item) == 2: - config_items[item[0].strip()] = (item[1].strip() == 'y') - return config_items + with open(config_h_path, "a") as config_h: + config_h.write("#define __ARCH__ " + configuration['ARCH'] + '\n') + config_h.write("#define __PLATFORM__ " + configuration['PLATFORM'] + '\n') + config_h.write("#define __SUBARCH__ " + configuration['SUBARCH'] + '\n') + return configuration def cml2_configure(cml2_config_file): os.system(CML2TOOLSDIR + '/cmlcompile.py -o ' + CML2RULES + ' ' + cml2_config_file) os.system(CML2TOOLSDIR + '/cmlconfigure.py -c -o ' + CML2_CONFIG_PROPERTIES + ' ' + CML2RULES) os.system(TOOLSDIR + '/cml2header.py -o ' + CML2_CONFIG_H + ' -i ' + CML2_CONFIG_PROPERTIES) + if not os.path.exists("build/l4"): + os.mkdir("build/l4") + shutil.copy(CML2_CONFIG_H, CONFIG_H) -def main(): - cml2_configure("configs/arm.cml") - cml2_rest() +def configure_kernel(cml_file): + if not os.path.exists(BUILDDIR): + os.mkdir(BUILDDIR) + + cml2_configure(cml_file) + configuration = cml2_config_to_symbols() + save_configuration(configuration) + return configuration if __name__ == "__main__": - main() + configure_kernel("configs/arm.cml")