libsysprof_public_sources = [
  'sysprof-battery-charge.c',
  'sysprof-bundled-symbolizer.c',
  'sysprof-callgraph-frame.c',
  'sysprof-callgraph-symbol.c',
  'sysprof-callgraph.c',
  'sysprof-callgraph-categorize.c',
  'sysprof-categories.c',
  'sysprof-category-summary.c',
  'sysprof-cpu-info.c',
  'sysprof-cpu-usage.c',
  'sysprof-dbus-monitor.c',
  'sysprof-diagnostic.c',
  'sysprof-disk-usage.c',
  'sysprof-document-allocation.c',
  'sysprof-document-counter-value.c',
  'sysprof-document-counter.c',
  'sysprof-document-ctrdef.c',
  'sysprof-document-ctrset.c',
  'sysprof-document-dbus-message.c',
  'sysprof-document-exit.c',
  'sysprof-document-file-chunk.c',
  'sysprof-document-file.c',
  'sysprof-document-fork.c',
  'sysprof-document-frame.c',
  'sysprof-document-jitmap.c',
  'sysprof-document-loader.c',
  'sysprof-document-log.c',
  'sysprof-document-mark.c',
  'sysprof-document-metadata.c',
  'sysprof-document-mmap.c',
  'sysprof-document-overlay.c',
  'sysprof-document-process.c',
  'sysprof-document-sample.c',
  'sysprof-document-traceable.c',
  'sysprof-document.c',
  'sysprof-elf-symbolizer.c',
  'sysprof-energy-usage.c',
  'sysprof-instrument.c',
  'sysprof-jitmap-symbolizer.c',
  'sysprof-kallsyms-symbolizer.c',
  'sysprof-malloc-tracing.c',
  'sysprof-mark-catalog.c',
  'sysprof-memory-usage.c',
  'sysprof-multi-symbolizer.c',
  'sysprof-network-usage.c',
  'sysprof-no-symbolizer.c',
  'sysprof-power-profile.c',
  'sysprof-profiler.c',
  'sysprof-proxied-instrument.c',
  'sysprof-recording.c',
  'sysprof-sampler.c',
  'sysprof-scheduler-details.c',
  'sysprof-spawnable.c',
  'sysprof-subprocess-output.c',
  'sysprof-symbol.c',
  'sysprof-symbolizer.c',
  'sysprof-symbols-bundle.c',
  'sysprof-system-logs.c',
  'sysprof-thread-info.c',
  'sysprof-time-span.c',
  'sysprof-tracefd-consumer.c',
  'sysprof-tracer.c',
]

libsysprof_public_headers = [
  'sysprof.h',
  'sysprof-battery-charge.h',
  'sysprof-bundled-symbolizer.h',
  'sysprof-callgraph-frame.h',
  'sysprof-callgraph-symbol.h',
  'sysprof-callgraph.h',
  'sysprof-category-summary.h',
  'sysprof-cpu-info.h',
  'sysprof-cpu-usage.h',
  'sysprof-dbus-monitor.h',
  'sysprof-diagnostic.h',
  'sysprof-disk-usage.h',
  'sysprof-document-allocation.h',
  'sysprof-document-counter-value.h',
  'sysprof-document-counter.h',
  'sysprof-document-ctrdef.h',
  'sysprof-document-ctrset.h',
  'sysprof-document-dbus-message.h',
  'sysprof-document-exit.h',
  'sysprof-document-file-chunk.h',
  'sysprof-document-file.h',
  'sysprof-document-fork.h',
  'sysprof-document-frame.h',
  'sysprof-document-jitmap.h',
  'sysprof-document-loader.h',
  'sysprof-document-log.h',
  'sysprof-document-mark.h',
  'sysprof-document-metadata.h',
  'sysprof-document-mmap.h',
  'sysprof-document-overlay.h',
  'sysprof-document-process.h',
  'sysprof-document-sample.h',
  'sysprof-document-traceable.h',
  'sysprof-document.h',
  'sysprof-elf-symbolizer.h',
  'sysprof-energy-usage.h',
  'sysprof-instrument.h',
  'sysprof-jitmap-symbolizer.h',
  'sysprof-kallsyms-symbolizer.h',
  'sysprof-malloc-tracing.h',
  'sysprof-mark-catalog.h',
  'sysprof-memory-usage.h',
  'sysprof-mount.h',
  'sysprof-multi-symbolizer.h',
  'sysprof-network-usage.h',
  'sysprof-no-symbolizer.h',
  'sysprof-power-profile.h',
  'sysprof-profiler.h',
  'sysprof-proxied-instrument.h',
  'sysprof-recording.h',
  'sysprof-sampler.h',
  'sysprof-scheduler-details.h',
  'sysprof-spawnable.h',
  'sysprof-subprocess-output.h',
  'sysprof-symbol.h',
  'sysprof-symbolizer.h',
  'sysprof-symbols-bundle.h',
  'sysprof-system-logs.h',
  'sysprof-thread-info.h',
  'sysprof-time-span.h',
  'sysprof-tracefd-consumer.h',
  'sysprof-tracer.h',
]

libsysprof_private_sources = [
  'mapped-ring-buffer-source.c',
  'sysprof-address-layout.c',
  'sysprof-controlfd-instrument.c',
  'sysprof-descendants-model.c',
  'sysprof-document-bitset-index.c',
  'sysprof-document-symbols.c',
  'sysprof-elf-loader.c',
  'sysprof-elf.c',
  'sysprof-leak-detector.c',
  'sysprof-maps-parser.c',
  'sysprof-mount-device.c',
  'sysprof-mount-namespace.c',
  'sysprof-mount.c',
  'sysprof-perf-event-stream.c',
  'sysprof-podman.c',
  'sysprof-process-info.c',
  'sysprof-strings.c',
  'sysprof-symbol-cache.c',
  'timsort/gtktimsort.c',
]

if polkit_dep.found()
  libsysprof_private_sources += ['sysprof-polkit.c']
endif

if host_machine.system() == 'linux'
  libsysprof_private_sources += ['sysprof-linux-instrument.c']
endif

if libsystemd_dep.found()
  libsysprof_private_sources += ['sysprof-journald-source.c']
endif

libsysprof_enum_headers = [
  'sysprof-callgraph.h',
  'sysprof-recording.h',
]

libsysprof_enums = gnome.mkenums_simple('sysprof-enums',
     body_prefix: '#include "config.h"',
   header_prefix: '#include "sysprof-version-macros.h"',
       decorator: '_SYSPROF_EXTERN',
         sources: libsysprof_enum_headers,
  install_header: true,
     install_dir: sysprof_header_dir,
)

libsysprof_resources = gnome.compile_resources('libsysprof-resources', 'libsysprof.gresource.xml',
  source_dir: 'resources',
      c_name: 'libsysprof',
)

libsysprof_deps = [
  gio_dep,
  gio_unix_dep,
  dependency('libdex-1', version: dex_req_version),
  dependency('json-glib-1.0'),

  libsystemd_dep,
  polkit_dep,

  libeggbitset_static_dep,
  libelfparser_static_dep,
  liblinereader_static_dep,
  libsysprof_capture_dep,
]

libsysprof_static = static_library(
  'sysprof-@0@'.format(soname_major_version),
  libsysprof_public_sources +
  libsysprof_private_sources +
  libsysprof_enums,
  libsysprof_resources,

    include_directories: [include_directories('.'),
                          libsysprof_capture_include_dirs],
           dependencies: libsysprof_deps,
  gnu_symbol_visibility: 'hidden',
)

libsysprof_static_dep = declare_dependency(
              sources: libsysprof_enums,
            link_with: libsysprof_static,
         dependencies: libsysprof_deps,
  include_directories: [include_directories('.'),
                        libsysprof_capture_include_dirs],
)

libsysprof = library('sysprof-@0@'.format(soname_major_version),
           dependencies: [libsysprof_static_dep],
  gnu_symbol_visibility: 'hidden',
                version: '@0@.0.0'.format(soname_major_version),
        darwin_versions: '@0@.0'.format(soname_major_version),
                install: get_option('libsysprof'),
)

libsysprof_dep = declare_dependency(
            link_with: libsysprof,
         dependencies: libsysprof_deps,
  include_directories: [include_directories('.'), libsysprof_capture_include_dirs],
)
meson.override_dependency('sysprof-@0@'.format(soname_major_version), libsysprof_dep)

pkgconfig.generate(libsysprof,
            subdirs: [sysprof_header_subdir],
        description: 'A library for recording and analyzing system performance',
           requires: ['gio-2.0'],
          variables: ['datadir=' + datadir_for_pc_file],
)

install_headers(libsysprof_public_headers, subdir: sysprof_header_subdir)

if get_option('tests')
  subdir('tests')
endif
