'build xen
make_opts
additional options to make, if any'

def build(self, make_opts='', logfile='', extraversion='autotest'):

    self.log('running    build')
    os_dep.commands('gcc', 'make')
    os.environ['XEN_EXTRAVERSION'] = ('-unstable-%s' % extraversion)
    if (logfile == ''):
        logfile = os.path.join(self.log_dir, 'xen_build')
    os.chdir(self.build_dir)
    self.log(('log_dir:    %s    ' % self.log_dir))
    self.job.logging.tee_redirect_debug_dir(self.log_dir, log_name=logfile)
    targets = ['xen', 'tools']
    threads = (2 * utils.count_cpus())
    for t in targets:
        build_string = ('make    -j    %d    %s    %s' % (threads, make_opts, t))
        self.log(('build_string:    %s' % build_string))
        utils.system(build_string)
    if (self.kjob is None):
        self.log("prep-ing    xen'ified    kernel    source    tree")
        utils.system('make    prep-kernels')
        v = self.get_xen_kernel_build_ver()
        self.log(('building    xen    kernel    version:    %s' % v))
        kernel_base_tree = os.path.join(self.build_dir, ('linux-%s' % self.get_xen_kernel_build_ver()))
        self.log(('kernel_base_tree    =    %s' % kernel_base_tree))
        self.fix_up_xen_kernel_makefile(kernel_base_tree)
        self.kjob = self.job.kernel(kernel_base_tree)
        c = (self.build_dir + '/buildconfigs/linux-defconfig_xen0_x86_32')
        self.log(('using    kernel    config:    %s    ' % c))
        self.kjob.config(c)
        self.kjob.set_build_target('vmlinuz')
        self.kjob.set_build_image((self.job.tmpdir + '/build/linux/vmlinuz'))
    self.kjob.build()
    self.job.logging.restore()
    xen_version = self.get_xen_build_ver()
    self.log(('BUILD    VERSION:    Xen:    %s    Kernel:%s' % (xen_version, self.kjob.get_kernel_build_ver())))
