# -*- python -*-
#
#  SConstruct wrapper around python's standard build tools
#

import os
from os.path import join, realpath
#if os.name == 'nt':
#    import sys
#    sys.path.append(join('C:', os.sep, 'Program Files', 'Larch', 'bin', 'library.zip'))

from SCons.Environment import Environment

env  = Environment()

## figure out where to install the larch bits
import larch
#installdir = larch.site_config.larchdir
installdir = larch.larchlib.larchdir
dlldir =  larch.larchlib.get_dlldir()
if os.name == 'nt':
    env.PrependENVPath('PATH', os.environ['PATH'])
    env.PrependENVPath('VS90COMNTOOLS', os.environ['VS90COMNTOOLS'])




b = Builder(action='python setup.py build_ext --inplace',
            chdir=1)
env.Append(BUILDERS = {'MyBuild' : b})
env.MyBuild('_feffpathwrapper.so', 'feffpath_wrap.c')
#env.Command('_feffpathwrapper.so', 'feffpath_wrap.c', ['python setup.py build_ext --inplace'])
env.Depends('_feffpathwrapper.so', join('..','..','src','GENFMT','libfeffpath'+env['SHLIBSUFFIX']))


plugin_dir = join(installdir,'plugins','xafs')
module_dir = join(installdir,'modules')
dll_dir    = join(installdir,'dlls',dlldir)

# env.Install( plugin_dir, "scatteringpath.py",)
# env.Install( module_dir, "feffpathwrapper.py",)
# env.Install( dll_dir,    "_feffpathwrapper.so",)

# env.Alias('install', [plugin_dir, module_dir, dll_dir] )

