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

def create_jack_driver_obj(bld, target, sources, uselib = None):
    driver = bld.new_task_gen('cxx', 'shlib')
    driver.features.append('cc')
    driver.env['shlib_PATTERN'] = 'jack_%s.so'
    #driver.env.append_unique('CXXFLAGS', '-march=i686 -msse3 -ffast-math')
    #driver.env.append_unique('CCFLAGS', '-march=i686  -msse3  -ffast-math')
    driver.defines = 'HAVE_CONFIG_H'
    driver.includes = ['.', '..','../posix', '../common', '../common/jack']
    driver.target = target
    driver.source = sources
    driver.install_path = '${ADDON_DIR}/'
    driver.uselib_local = 'serverlib'
    if uselib:
        driver.uselib = uselib
    return driver

def build(bld):
    jackd = bld.new_task_gen('cxx', 'program')
    jackd.includes = ['.','..', '../posix', '../common/jack', '../common']
    jackd.defines = 'HAVE_CONFIG_H'
    jackd.source = ['../common/Jackdmp.cpp']
    jackd.uselib = 'PTHREAD DL'
    jackd.uselib_local = 'serverlib'
    jackd.target = 'jackd'

    create_jack_driver_obj(bld, 'oss', ['oss/JackOSSDriver.cpp', '../common/memops.c'])

    create_jack_driver_obj(bld, 'boomer', ['oss/JackBoomerDriver.cpp', '../common/memops.c'])

    create_jack_driver_obj(bld, 'dummy', '../common/JackDummyDriver.cpp')

    create_jack_driver_obj(bld, 'net', '../common/JackNetDriver.cpp')

    create_jack_driver_obj(bld, 'loopback', '../common/JackLoopbackDriver.cpp')
