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

def build(bld):
    common_libsources = [
        'JackActivationCount.cpp',
        'JackAPI.cpp',
        'JackClient.cpp',
        'JackConnectionManager.cpp',
        'ringbuffer.c',
        'JackError.cpp',
        'JackFrameTimer.cpp',
        'JackGraphManager.cpp',
        'JackPort.cpp',
        'JackPosixSemaphore.cpp',
        'JackFifo.cpp',
        'JackPortType.cpp',
        'JackAudioPort.cpp',
        'JackMidiPort.cpp',
        'JackMidiAPI.cpp',
        'JackEngineControl.cpp',
        'JackPosixThread.cpp',
        'JackShmMem.cpp',
        'shm.c',
        'JackSocket.cpp',
        'JackTime.c',
        'JackGlobals.cpp',
        'JackDebugClient.cpp',
        'JackTransportEngine.cpp',
        'timestamps.c',
        'JackTools.cpp',
        'JackMessageBuffer.cpp',
        'JackProcessSync.cpp'
        ]
    
    serverlib = bld.create_obj('cpp', 'shlib')
    serverlib.features.append('cc')
    serverlib.defines = 'HAVE_CONFIG_H'
    serverlib.includes = ['.', './jack', '..', '../linux']
    serverlib.name         = 'serverlib'
    serverlib.target       = 'jackserver'
    serverlib.source = [] + common_libsources
    serverlib.source += [
        'JackAudioDriver.cpp',
        'JackDriver.cpp',
        'JackEngine.cpp',
        'JackExternalClient.cpp',
        'JackFreewheelDriver.cpp',
        'JackInternalClient.cpp',
        'JackLoopbackDriver.cpp',
        'JackServer.cpp',
        'JackThreadedDriver.cpp',
        'JackSocketServerChannel.cpp',
        'JackSocketNotifyChannel.cpp',
        'JackSocketServerNotifyChannel.cpp',
        'JackServerAPI.cpp',
        'JackDriverLoader.cpp',
        'JackServerGlobals.cpp',
        'JackControl.cpp',
        ]
    serverlib.vnum = bld.env()['JACK_API_VERSION']

    clientlib = bld.create_obj('cpp', 'shlib')
    clientlib.features.append('cc')
    clientlib.defines = 'HAVE_CONFIG_H'
    if bld.env()['BUILD_JACKDBUS'] == True:
        clientlib.uselib = ['DBUS-1']
    clientlib.includes = ['.', './jack', '..', '../linux']
    clientlib.name         = 'clientlib'
    clientlib.target       = 'jack'
    clientlib.source = [] + common_libsources
    clientlib.source += [
        'JackLibClient.cpp',
        'JackLibAPI.cpp',
        'JackSocketClientChannel.cpp',
        'JackServerLaunch.cpp', 
        ]
    clientlib.vnum = bld.env()['JACK_API_VERSION']

    install_files('PREFIX', 'jack', 'jack/*.h')
