# -*- mode: python; coding: utf-8; -*-
#
#  Codezero -- a microkernel for embedded systems.
#
#  Copyright © 2009  B Labs Ltd
#
import os, sys

PROJRELROOT = '../../..'
sys.path.append(PROJRELROOT)

from scripts.config.projpaths import *
from scripts.config.configuration import *

config = configuration_retrieve()
gcc_arch_flag = config.gcc_arch_flag
arch = config.arch

# We assume we are compiling for userspace.
# variant can be specified from cmdline using
# scons variant=xxx
variant = ARGUMENTS.get('variant', 'userspace')
print '\nCompiling for variant: ' + variant + '\n'

builddir = join(BUILDDIR, LIBC_RELDIR)
VariantDir(builddir, os.getcwd(), 0)

env = Environment(CC = config.toolchain_userspace + 'gcc',
		          CCFLAGS = ['-g', '-nostdlib', '-ffreestanding', '-std=gnu99',
                             '-nostdinc', '-Wall', '-Werror', '-march=' + gcc_arch_flag],
        		  LINKFLAGS = ['-nostdlib'],
		          ASFLAGS = ['-D__ASSEMBLY__'],
		          ENV = {'PATH' : os.environ['PATH']},
		          CPPPATH = ['include', LIBDEV_INCLUDE, KERNEL_HEADERS,
                             'include/sys-' + variant + '/arch-' + arch],
                  CPPFLAGS = '-include l4/macros.h')

objects = SConscript('SConscript', exports = { 'env' : env, 'type' : variant },
                     duplicate=0, build_dir = builddir)

