#! /usr/bin/env python
# encoding: utf-8
# Ricard Marxer 2008

import os, sys

def set_options(opt):
	opt.tool_options('compiler_cxx')
       	opt.tool_options('python')


def configure(conf):
	conf.check_tool('compiler_cxx python')
        conf.check_python_version((2,4,2))
	conf.check_python_headers()
	conf.check_tool('swig', tooldir = 'src/swig')
	conf.check_swig_version('1.3.27')

        try:
                conf.check_python_module('numpy')
        except Configure.ConfigurationError:
                print "(module ''numpy'' not found, but we ignore it)"


def build(bld):
        obj = bld.new_task_gen(
                features = 'cxx cshlib pyext',
                uselib = 'FFTW3 FFMPEG SAMPLERATE EIGEN',
                source = 'loudia.i',
                target = '_loudia',
                swig_flags = '-c++ -python -Wall -w509 -I..',
                swig_includes = '..',
                includes = '..',
                name         = 'pyloudia',
                want_libtool = 1,
                vnum         = '0.1',
                uselib_local = 'loudia'
        )

        # fix for waf/python2.6 install paths
        major, minor, _, _, _ = sys.version_info
        if major >= 2 and minor >= 6:
                bld.env['PYTHONDIR'] = bld.env['PYTHONDIR'].replace('site-packages', 'dist-packages')

        bld.env['PYTHONDIR'] = os.path.join(bld.env['PYTHONDIR'], 'loudia')
        bld.install_as('${PYTHONDIR}/__init__.py', 'loudia.py')
