jamid_includedirs = include_directories(
    '../..'
)

jamid_sources = files(
    'main.cpp'
)

jamid_targets = []
jamid_targets += custom_target('callmanager.adaptor',
    command: [progsdbuscppxml2cpp, '@INPUT@', '--adaptor=@OUTPUT@'],
    input: 'cx.ring.Ring.CallManager.xml',
    output: 'dbuscallmanager.adaptor.h'
)

jamid_targets += custom_target('configurationmanager.adaptor',
    command: [progsdbuscppxml2cpp, '@INPUT@', '--adaptor=@OUTPUT@'],
    input: 'cx.ring.Ring.ConfigurationManager.xml',
    output: 'dbusconfigurationmanager.adaptor.h'
)

jamid_targets += custom_target('instance.adaptor',
    command: [progsdbuscppxml2cpp, '@INPUT@', '--adaptor=@OUTPUT@'],
    input: 'cx.ring.Ring.Instance.xml',
    output: 'dbusinstance.adaptor.h'
)

jamid_targets += custom_target('presencemanager.adaptor',
    command: [progsdbuscppxml2cpp, '@INPUT@', '--adaptor=@OUTPUT@'],
    input: 'cx.ring.Ring.PresenceManager.xml',
    output: 'dbuspresencemanager.adaptor.h'
)

jamid_targets += custom_target('networkservicemanager.adaptor',
    command: [progsdbuscppxml2cpp, '@INPUT@', '--adaptor=@OUTPUT@'],
    input: 'cx.ring.Ring.NetworkServiceManager.xml',
    output: 'dbusnetworkservicemanager.adaptor.h'
)

if conf.get('ENABLE_VIDEO')
    jamid_targets += custom_target('videomanager.adaptor',
        command: [progsdbuscppxml2cpp, '@INPUT@', '--adaptor=@OUTPUT@'],
        input: 'cx.ring.Ring.VideoManager.xml',
        output: 'dbusvideomanager.adaptor.h'
    )
endif

if conf.get('ENABLE_PLUGIN')
    jamid_targets += custom_target('pluginmanagerinterface.adaptor',
        command: [progsdbuscppxml2cpp, '@INPUT@', '--adaptor=@OUTPUT@'],
        input: 'cx.ring.Ring.PluginManagerInterface.xml',
        output: 'dbuspluginmanagerinterface.adaptor.h'
    )
endif

if progpod2man.found()
    jamid_targets += custom_target('jamid.man',
        command: [progpod2man, '--section=1', '--release='+meson.project_version(), '--center', '""', '@INPUT@', '@OUTPUT@'],
        input: '../../man/jamid.pod',
        output: 'jamid.1',
        install: true,
        install_dir: get_option('mandir') / 'man1'
    )
endif

jamid = executable('jamid',
    jamid_targets,
    include_directories: jamid_includedirs,
    sources: jamid_sources,
    dependencies: [depsdbuscpp, depjami],
    install: true,
    install_dir: get_option('libexecdir')
)

configure_file(
    configuration: {'LIBEXECDIR': get_option('prefix') / get_option('libexecdir')},
    input: 'net.jami.daemon.service.in',
    output: 'cx.ring.Ring.service',
    install: true,
    install_dir: get_option('datadir') / 'dbus-1' / 'services'
)

install_data(
    'cx.ring.Ring.CallManager.xml',
    'cx.ring.Ring.ConfigurationManager.xml',
    'cx.ring.Ring.Instance.xml',
    'cx.ring.Ring.NetworkServiceManager.xml',
    'cx.ring.Ring.PresenceManager.xml',
    install_dir: get_option('datadir') / 'dbus-1' / 'interfaces'
)
if conf.get('ENABLE_VIDEO')
    install_data(
        'cx.ring.Ring.VideoManager.xml',
        install_dir: get_option('datadir') / 'dbus-1' / 'interfaces'
    )
endif
if conf.get('ENABLE_PLUGIN')
    install_data(
        'cx.ring.Ring.PluginManagerInterface.xml',
        install_dir: get_option('datadir') / 'dbus-1' / 'interfaces'
    )
endif
