# -*- mode: python; -*- 

import os
import sys
import Configure 


APPNAME = 'lalusb2'
VERSION = '0.1.7'
top  = '.'
out  = 'build'


lib_sources = """
Usb.c UsbInterface.c
"""

lib_headers = """
ftd2xx.h  LALUsb.h  WinTypes.h
"""

def options(ctx):
    
    ctx.load('compiler_cc')
    ctx.load('python')


def configure(conf):

    conf.load('compiler_cc')
    conf.load('python')

    conf.env['CFLAGS'] = ['-fPIC', '-DPIC']
    # conf.env['CFLAGS'] = ['-fPIC']
    
    conf.check_cc(lib='rt')

    # libftd2xx.so.0.4.16
    conf.check_cc(lib = 'ftd2xx', 
                  uselib_store = 'FTDI2xx',
                  libpath = conf.env.PREFIX + '/lib')
    

def build(bld):
    
    liblalusb = bld.shlib(target = 'lalusb20', 
                          source = lib_sources, 
                          includes = '.',
                          use = ['FTDI2xx'],
                          rpath = bld.env.PREFIX + '/lib')

    test245   = bld.program(target = 'test245', 
                            source = ['test245_core.c', 
                                      'time_utils.c', 
                                      'test245.c'], 
                            includes = ['.'],
                            lib = ['rt'], # strange...
                            use = ['rt', 'lalusb20', 'FTDI2xx'],
                            rpath = bld.env.PREFIX + '/lib')
    
    bld.install_files('${PREFIX}/include/dice/', lib_headers)
    
