clutter_clutter_includesubdir = clutter_includesubdir / 'clutter'
clutter_clutter_includedir = clutter_includedir / 'clutter'

clutter_headers = [
  'clutter.h',
  'clutter-action.h',
  'clutter-actor-accessible.h',
  'clutter-actor-meta.h',
  'clutter-actor.h',
  'clutter-align-constraint.h',
  'clutter-animatable.h',
  'clutter-backend.h',
  'clutter-bind-constraint.h',
  'clutter-binding-pool.h',
  'clutter-bin-layout.h',
  'clutter-blur-effect.h',
  'clutter-box-layout.h',
  'clutter-brightness-contrast-effect.h',
  'clutter-click-gesture.h',
  'clutter-clone.h',
  'clutter-color-manager.h',
  'clutter-color-state.h',
  'clutter-color-state-icc.h',
  'clutter-color-state-params.h',
  'clutter-colorize-effect.h',
  'clutter-constraint.h',
  'clutter-content.h',
  'clutter-context.h',
  'clutter-deform-effect.h',
  'clutter-desaturate-effect.h',
  'clutter-effect.h',
  'clutter-enums.h',
  'clutter-event.h',
  'clutter-fixed-layout.h',
  'clutter-flow-layout.h',
  'clutter-focus.h',
  'clutter-frame-clock.h',
  'clutter-frame.h',
  'clutter-gesture.h',
  'clutter-grab.h',
  'clutter-grid-layout.h',
  'clutter-input-device.h',
  'clutter-input-device-tool.h',
  'clutter-input-focus.h',
  'clutter-input-method.h',
  'clutter-interval.h',
  'clutter-keyframe-transition.h',
  'clutter-key-focus.h',
  'clutter-keymap.h',
  'clutter-keysyms.h',
  'clutter-keyval.h',
  'clutter-layout-manager.h',
  'clutter-layout-meta.h',
  'clutter-long-press-gesture.h',
  'clutter-macros.h',
  'clutter-main.h',
  'clutter-offscreen-effect.h',
  'clutter-page-turn-effect.h',
  'clutter-paint-context.h',
  'clutter-paint-nodes.h',
  'clutter-paint-node.h',
  'clutter-pan-gesture.h',
  'clutter-pick-context.h',
  'clutter-pipeline-cache.h',
  'clutter-press-gesture.h',
  'clutter-property-transition.h',
  'clutter-seat.h',
  'clutter-settings.h',
  'clutter-shader-effect.h',
  'clutter-shader-types.h',
  'clutter-sprite.h',
  'clutter-snap-constraint.h',
  'clutter-stage.h',
  'clutter-stage-view.h',
  'clutter-texture-content.h',
  'clutter-timeline.h',
  'clutter-transition-group.h',
  'clutter-transition.h',
  'clutter-types.h',
  'clutter-virtual-input-device.h',
]

clutter_sources = [
  'clutter-accessibility.c',
  'clutter-action.c',
  'clutter-actor-box.c',
  'clutter-actor-accessible.c',
  'clutter-actor-meta.c',
  'clutter-actor.c',
  'clutter-align-constraint.c',
  'clutter-animatable.c',
  'clutter-backend.c',
  'clutter-base-types.c',
  'clutter-bind-constraint.c',
  'clutter-binding-pool.c',
  'clutter-bin-layout.c',
  'clutter-blur.c',
  'clutter-blur-effect.c',
  'clutter-box-layout.c',
  'clutter-brightness-contrast-effect.c',
  'clutter-click-gesture.c',
  'clutter-clone.c',
  'clutter-color-manager.c',
  'clutter-color-state.c',
  'clutter-color-state-icc.c',
  'clutter-color-state-params.c',
  'clutter-colorize-effect.c',
  'clutter-constraint.c',
  'clutter-content.c',
  'clutter-context.c',
  'clutter-damage-history.c',
  'clutter-deform-effect.c',
  'clutter-desaturate-effect.c',
  'clutter-effect.c',
  'clutter-event.c',
  'clutter-fixed-layout.c',
  'clutter-flatten-effect.c',
  'clutter-flow-layout.c',
  'clutter-focus.c',
  'clutter-frame-clock.c',
  'clutter-frame.c',
  'clutter-gesture.c',
  'clutter-grab.c',
  'clutter-grid-layout.c',
  'clutter-input-device.c',
  'clutter-input-device-tool.c',
  'clutter-input-focus.c',
  'clutter-input-method.c',
  'clutter-input-pointer-a11y.c',
  'clutter-input-only-action.c',
  'clutter-input-only-actor.c',
  'clutter-virtual-input-device.c',
  'clutter-interval.c',
  'clutter-interval-progress.c',
  'clutter-keyframe-transition.c',
  'clutter-keymap.c',
  'clutter-keysyms-table.c',
  'clutter-keyval.c',
  'clutter-key-focus.c',
  'clutter-layout-manager.c',
  'clutter-layout-meta.c',
  'clutter-long-press-gesture.c',
  'clutter-main.c',
  'clutter-offscreen-effect.c',
  'clutter-page-turn-effect.c',
  'clutter-paint-context.c',
  'clutter-paint-nodes.c',
  'clutter-paint-node.c',
  'clutter-pan-gesture.c',
  'clutter-pick-context.c',
  'clutter-pick-stack.c',
  'clutter-pipeline-cache.c',
  'clutter-press-gesture.c',
  'clutter-property-transition.c',
  'clutter-seat.c',
  'clutter-settings.c',
  'clutter-shader-effect.c',
  'clutter-shader-types.c',
  'clutter-snap-constraint.c',
  'clutter-sprite.c',
  'clutter-stage-accessible.c',
  'clutter-stage.c',
  'clutter-stage-manager-accessible.c',
  'clutter-stage-manager.c',
  'clutter-stage-view.c',
  'clutter-stage-window.c',
  'clutter-texture-content.c',
  'clutter-transition-group.c',
  'clutter-transition.c',
  'clutter-timeline.c',
  'clutter-util.c',
  'clutter-paint-volume.c',
]

clutter_private_headers = [
  'clutter-accessibility-private.h',
  'clutter-actor-meta-private.h',
  'clutter-actor-private.h',
  'clutter-backend-private.h',
  'clutter-blur-private.h',
  'clutter-constraint-private.h',
  'clutter-content-private.h',
  'clutter-context-private.h',
  'clutter-damage-history.h',
  'clutter-debug.h',
  'clutter-easing.h',
  'clutter-effect-private.h',
  'clutter-event-private.h',
  'clutter-flatten-effect.h',
  'clutter-focus-private.h',
  'clutter-frame-private.h',
  'clutter-input-device-private.h',
  'clutter-input-focus-private.h',
  'clutter-input-method-private.h',
  'clutter-input-pointer-a11y-private.h',
  'clutter-input-only-action.h',
  'clutter-input-only-actor.h',
  'clutter-keymap-private.h',
  'clutter-mutter.h',
  'clutter-paint-context-private.h',
  'clutter-paint-node-private.h',
  'clutter-paint-volume-private.h',
  'clutter-private.h',
  'clutter-settings-private.h',
  'clutter-sprite-private.h',
  'clutter-stage-accessible-private.h',
  'clutter-stage-manager-accessible-private.h',
  'clutter-stage-manager-private.h',
  'clutter-stage-private.h',
  'clutter-stage-view-private.h',
  'clutter-stage-window.h',
  'clutter-timeline-private.h',
]

clutter_fonts_headers = [
  'pango/clutter-actor-pango.h',
  'pango/clutter-text.h',
  'pango/clutter-text-buffer.h',
  'pango/clutter-text-node.h',
]

clutter_fonts_sources = [
  'pango/clutter-pango-display-list.c',
  'pango/clutter-pango-glyph-cache.c',
  'pango/clutter-pango-pipeline-cache.c',
  'pango/clutter-pango-render.c',
  'pango/clutter-text.c',
  'pango/clutter-text-accessible.c',
  'pango/clutter-text-buffer.c',
  'pango/clutter-text-node.c',
]

clutter_fonts_private_headers = [
  'pango/clutter-pango-display-list.h',
  'pango/clutter-pango-glyph-cache.h',
  'pango/clutter-pango-pipeline-cache.h',
  'pango/clutter-pango-private.h',
  'pango/clutter-text-accessible-private.h',
]

if have_fonts
  clutter_sources += clutter_fonts_sources
  clutter_private_headers += clutter_fonts_private_headers
  clutter_headers += [
    'clutter-pango.h',
  ]
endif

clutter_nonintrospected_sources = [
  'clutter-easing.c',
]

clutter_backend_private_headers = []

clutter_built_sources = []
clutter_built_headers = []

clutter_enum_types = gnome.mkenums('clutter-enum-types',
  sources: clutter_headers,
  c_template: 'clutter-enum-types.c.in',
  h_template: 'clutter-enum-types.h.in',
  install_dir: clutter_clutter_includedir,
  install_header: true,
)
clutter_built_sources += clutter_enum_types[0]
clutter_built_headers += clutter_enum_types[1]

clutter_marshal = gnome.genmarshal('clutter-marshal',
  prefix: '_clutter_marshal',
  sources: 'clutter-marshal.list',
  valist_marshallers: true,
  extra_args: ['--quiet'],
  install_dir: clutter_clutter_includedir,
  install_header: true,
)
clutter_built_sources += clutter_marshal[0]
clutter_built_headers += clutter_marshal[1]


sources = [
  clutter_sources,
  clutter_headers,
  clutter_private_headers,
  clutter_nonintrospected_sources,
  clutter_built_sources,
  clutter_built_headers,
]

if have_fonts
  sources += clutter_fonts_headers
endif

libmutter_clutter_name = 'mutter-clutter-' + libmutter_api_version
libmutter_clutter = library(libmutter_clutter_name,
  sources: sources,
  version: '0.0.0',
  soversion: 0,
  c_args: clutter_c_args,
  include_directories: [clutter_includes, top_includepath],
  dependencies: [clutter_deps],
  gnu_symbol_visibility: 'hidden',
  link_with: [
    libmutter_cogl,
  ],
  install_rpath: pkglibdir,
  install_dir: pkglibdir,
  install: true,
)
libmutter_clutter_dep = declare_dependency(
  sources: [clutter_enum_types[1]],
  link_with: libmutter_clutter,
  dependencies: clutter_deps,
)

if have_introspection
  clutter_introspection_args = introspection_args + [
    '-DCLUTTER_SYSCONFDIR="@0@"'.format(prefix / sysconfdir),
    '-DCLUTTER_COMPILATION=1',
    '-DG_LOG_DOMAIN="Clutter"'
  ]
  gi_headers = ['clutter/clutter.h']
  if have_fonts
    gi_headers += [
      'clutter/clutter-pango.h'
    ]
  endif

  sources = [
    clutter_built_sources,
    clutter_built_headers,
    clutter_sources,
    clutter_headers,
  ]
  if have_fonts
    sources += [clutter_fonts_headers]
  endif

  libmutter_clutter_gir = gnome.generate_gir(libmutter_clutter,
    sources: sources,
    nsversion: libmutter_api_version,
    namespace: 'Clutter',
    export_packages: [libmutter_clutter_name],
    includes: [
      libmutter_mtk_gir[0],
      libmutter_cogl_gir[0],
      'GL-1.0',
      'Gio-2.0',
      'GObject-2.0',
      'Atk-1.0',
      'Pango-1.0',
    ],
    dependencies: [cogl_deps],
    header: gi_headers,
    extra_args: clutter_introspection_args,
    kwargs: introspection_common,
  )
endif

install_headers(clutter_headers,
  subdir: clutter_clutter_includesubdir)

if have_fonts
  install_headers(clutter_fonts_headers,
    subdir: clutter_clutter_includesubdir / 'pango')
endif

pkg.generate(libmutter_clutter,
  name: 'Mutters Clutter',
  filebase: libmutter_clutter_name,
  description: 'Mutters Clutter Private Library',
  libraries: [m_dep],
  subdirs: pkgname / 'clutter',
  requires: [clutter_pkg_deps, libmutter_cogl_name, libmutter_mtk_name],
  version: meson.project_version(),
  variables: [
    'apiversion=' + libmutter_api_version,
  ],
  install_dir: pcdir,
)
