# Main executable sources (no longer includes VNC server implementations)
sources = files(
  'main.c',
  'rf-streamer.c',
  'rf-session.c',
  'rf-converter.c',
  'rf-vnc-server.c'
)

headers = files(
  'rf-streamer.h',
  'rf-session.h',
  'rf-converter.h',
  'rf-vnc-server.h'
)

dependencies = []
cc = meson.get_compiler('c')
m = cc.find_library('m')
glib = dependency('glib-2.0', required: true)
gio = dependency('gio-2.0', required: true)
gio_unix = dependency('gio-unix-2.0', required: true)
gmodule = dependency('gmodule-2.0', required: true)
gobject = dependency('gobject-2.0', required: true)
epoxy = dependency('epoxy', required: true)
xkbcommon = dependency('xkbcommon', required: true)
dependencies += [
  m,
  glib,
  gio,
  gio_unix,
  gmodule,
  gobject,
  epoxy,
  xkbcommon,
  mvmath_dep,
  reframe_common_dep
]

include_directories = []
# For `config.h`.
include_directories += include_directories('..')

executable(
  meson.project_name() + '-server',
  sources: sources,
  dependencies: dependencies,
  include_directories: include_directories,
  install: true
)

lvnc_sources = files('rf-lvnc-server.c')

lvnc_headers = files('rf-lvnc-server.h')

lvnc_dependencies = []
libvncserver = dependency('libvncserver', required: true)
lvnc_dependencies += [
  glib,
  gio,
  gmodule,
  gobject,
  libvncserver,
  reframe_common_dep
]

shared_module(
  meson.project_name() + '-libvncserver',
  sources: lvnc_sources,
  dependencies: lvnc_dependencies,
  include_directories: include_directories,
  install: true,
  install_dir: moduledir / 'vnc'
)

if get_option('neatvnc') and neatvnc.found()
  nvnc_sources = files('rf-nvnc-server.c')

  nvnc_headers = files('rf-nvnc-server.h')

  nvnc_dependencies = []
  libdrm = dependency('libdrm', required: true)
  aml = dependency('aml', required: true)
  pixman = dependency('pixman-1', required: true)
  nvnc_dependencies += [
    glib,
    gio,
    gmodule,
    gobject,
    libdrm,
    neatvnc,
    aml,
    pixman,
    reframe_common_dep
  ]

  shared_module(
    meson.project_name() + '-neatvnc',
    sources: nvnc_sources,
    dependencies: nvnc_dependencies,
    include_directories: include_directories,
    install: true,
    install_dir: moduledir / 'vnc'
  )
endif
