import os
Import('env')
local = env.Clone()

driver  = local.Mzc('make-driver', 'make-driver.ss')

slinker_builder = Builder(action = \
     'tools/slinker/make-driver --driver-script $TARGET.base')
#    'tools/slinker/make-driver --driver-script ${_remove_ext(TARGET)}',
#    _remove_ext = lambda x: os.path.splitext(x.path)[0])
#local = local.Clone(BUILDERS = {'slinker_builder' : slinker_builder })
local['BUILDERS']['slinker_builder'] = slinker_builder

slinker_ss  = local.slinker_builder('slinker.ss', 'slinker.sxml')
library2_ss = local.slinker_builder('library2.ss', 'library2.sxml')

# Make things depend on the driver so that files are rebuilt when the driver is
# edited
local.Depends(slinker_ss, driver)
local.Depends(library2_ss, driver)

slinker     = local.Mzc('slinker', 'slinker.ss')
library2    = local.Mzc('library2', 'library2.ss')

local.Depends(slinker, driver)
local.Depends(library2, driver)

env['SLINKER']  = slinker
env['slinker']  = slinker[0].path
env['LIBRARY2'] = library2
env['library2'] = library2[0].path
env.AppendENVPath('SKROCPATH', os.path.dirname(slinker[0].abspath))
