# Last Change: Mon Nov 03 06:00 PM 2008 J
# vim:syntax=python
from os.path import join
from numpy.distutils.misc_util import get_numpy_include_dirs, get_pkg_info
from distutils.sysconfig import get_python_inc
from numscons import GetNumpyEnvironment, CheckF77LAPACK, CheckF77Clib
from numscons import write_info

env = GetNumpyEnvironment(ARGUMENTS)
env.PrependUnique(CPPPATH=[get_numpy_include_dirs(), get_python_inc(),
                           env["PYEXTCPPPATH"]])

#=======================
# Starting Configuration
#=======================
config = env.NumpyConfigure(custom_tests = {'CheckLAPACK' : CheckF77LAPACK})

#-----------------
# Checking Lapack
#-----------------
st = config.CheckLAPACK()
if not st:
    has_lapack = 0
else:
    has_lapack = 1

config.Finish()
write_info(env)


#==========
#  Build
#==========

env.NumpyPythonExtension('ckdtree', source = ['ckdtree.c'])

env.NumpyPythonExtension('_distance_wrap',
                         source = [join('src', 'distance_wrap.c'),
                                   join('src', 'distance.c')])

# Build qhull
src = [join('qhull', 'src', s) for s in [
    'geom2.c', 'geom.c', 'global.c', 'io.c', 'libqhull.c',
    'mem.c', 'merge.c', 'poly2.c', 'poly.c', 'qset.c',
    'random.c', 'rboxlib.c', 'stat.c', 'user.c', 'usermem.c',
    'userprintf.c']]

env.NumpyPythonExtension('qhull', source = ['qhull.c'] + src)
