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

def configure(conf):
    conf.check_pkg('dbus-1')

    e = conf.create_header_configurator()
    e.name = 'expat.h'
    e.define = 'HAVE_EXPAT'
    e.run()

    if conf.is_defined('HAVE_EXPAT'):
        conf.env['LIB_EXPAT'] = ['expat']

    conf.env['BUILD_JACKDBUS'] = conf.is_defined('HAVE_EXPAT') and conf.is_defined('HAVE_DBUS_1')

def build(bld):
    if bld.env()["BUILD_JACKDBUS"] != True:
        return

    obj = bld.create_obj('cc', 'program')
    obj.includes = ['.', '../../common', '../../common/jack']
    obj.source = [
        'jackdbus.c',
        'controller.c',
        'controller_iface_configure.c',
        'controller_iface_control.c',
        'controller_iface_introspectable.c',
        'controller_iface_patchbay.c',
        'controller_iface_transport.c',
        'xml.c',
        'xml_expat.c',
        #'xml_libxml.c',
        #'xml_nop.c',
        'xml_write_raw.c',
        'sigsegv.c',
        ]
    obj.uselib = 'PTHREAD DL RT DBUS-1 EXPAT'
    obj.uselib_local = 'serverlib'
    obj.target       = 'jackdbus'
