api_version = '0.1'

libbreezy_sources = [
  'libbreezy.c',
]

libbreezy_headers = [
  'libbreezy.h',
  'libbreezy_private.h',
  'decls.h',
]

version_split = meson.project_version().split('.')
MAJOR_VERSION = version_split[0]
MINOR_VERSION = version_split[1]
MICRO_VERSION = version_split[2]

version_conf = configuration_data()
version_conf.set('VERSION', meson.project_version())
version_conf.set('MAJOR_VERSION', MAJOR_VERSION)
version_conf.set('MINOR_VERSION', MINOR_VERSION)
version_conf.set('MICRO_VERSION', MICRO_VERSION)

configure_file(
  input: 'libbreezy-version.h.in',
  output: 'libbreezy-version.h',
  configuration: version_conf,
  install: true,
  install_dir: join_paths(get_option('includedir'), 'libbreezy')
)

libbreezy_deps = [
  dependency ('python3-embed', required : true),
]

libbreezy_lib = shared_library('libbreezy-' + api_version,
  libbreezy_sources,
  dependencies: libbreezy_deps,
  install: true,
)

install_headers(libbreezy_headers, subdir: 'libbreezy')

pkg = import('pkgconfig')

pkg.generate(
  description: 'C wrapper for Breezy',
    libraries: libbreezy_lib,
         name: 'libbreezy',
     filebase: 'libbreezy-' + api_version,
      version: meson.project_version(),
      subdirs: 'libbreezy',
     requires: ['python3','breezy'],
  install_dir: join_paths(get_option('libdir'), 'pkgconfig')
)
