# build boot sector.
#
# (C) 2011 KATO Takeshi
#

sect_asflags = [
    '-m64',
    '-fno-exceptions',
    '-fomit-frame-pointer',
    '-Os',
]

sect_includes = ['../include']

sect_linkflags = [
    '-nostdlib',
    '-static',
    '-Wl,-Ttext=0x7c3e',
]

linker_script = 'bootsect.ld'


def build(x):
	sect_target = x.path.find_or_declare('bootsect')

	sect_linkflags.append(
	    '-Wl,-T,' + x.path.find_node(linker_script).abspath())
	x.add_manual_dependency(
	    sect_target, x.path.find_node(linker_script))

	x(  features  = 'c cprogram asm',
	    target    = sect_target,
	    source    = 'bootsect.S',
	    includes  = sect_includes,
	    asflags   = sect_asflags,
	    linkflags = sect_linkflags,
	)

