gegl_common_sources = files(
  'absolute.c',
  'alpha-clip.c',
  'alien-map.c',
  'bevel.c',
  'bilateral-filter.c',
  'bloom.c',
  'box-blur.c',
  'brightness-contrast.c',
  'buffer-sink.c',
  'buffer-source.c',
  'c2g.c',
  'checkerboard.c',
  'color-assimilation-grid.c',
  'color-enhance.c',
  'color-overlay.c',
  'color-rotate.c',
  'color-temperature.c',
  'color-warp.c',
  'color.c',
  'component-extract.c',
  'contrast-curve.c',
  'convolution-matrix.c',
  'copy-buffer.c',
  'difference-of-gaussians.c',
  'display.c',
  'dither.c',
  'domain-transform.c',
  'dropshadow.c',
  'edge-neon.c',
  'edge-sobel.c',
  'exp-combine.c',
  'exposure.c',
  'fattal02.c',
  'gaussian-blur.c',
  'gblur-1d.c',
  'gegl-buffer-load-op.c',
  'gegl-buffer-save-op.c',
  'gegl.c',
  'grey.c',
  'grid.c',
  'high-pass.c',
  'hue-chroma.c',
  'icc-load.c',
  'icc-save.c',
  'image-compare.c',
  'image-gradient.c',
  'inner-glow.c',
  'introspect.c',
  'invert-gamma.c',
  'invert-linear.c',
  'layer.c',
  'levels.c',
  'linear-gradient.c',
  'little-planet.c',
  'local-threshold.c',
  'long-shadow.c',
  'magick-load.c',
  'mantiuk06.c',
  'map-absolute.c',
  'map-relative.c',
  'matting-global.c',
  'mblur.c',
  'mean-curvature-blur.c',
  'median-blur.c',
  'mirrors.c',
  'mix.c',
  'mono-mixer.c',
  'motion-blur-linear.c',
  'negative-darkroom.c',
  'newsprint.c',
  'noise-cell.c',
  'noise-cie-lch.c',
  'noise-hsv.c',
  'noise-hurl.c',
  'noise-perlin.c',
  'noise-pick.c',
  'noise-reduction.c',
  'noise-rgb.c',
  'noise-simplex.c',
  'noise-spread.c',
  'normal-map.c',
  'opacity.c',
  'open-buffer.c',
  'over.c',
  'pack.c',
  'panorama-projection.c',
  'pixelize.c',
  'posterize.c',
  'radial-gradient.c',
  'rectangle.c',
  'recursive-transform.c',
  'reinhard05.c',
  'remap.c',
  'rgb-clip.c',
  'saturation.c',
  'save.c',
  'sepia.c',
  'slic.c',
  'snn-mean.c',
  'spherize.c',
  'stress.c',
  'stretch-contrast-hsv.c',
  'stretch-contrast.c',
  'styles.c',
  'svg-huerotate.c',
  'svg-luminancetoalpha.c',
  'svg-matrix.c',
  'svg-saturate.c',
  'threshold.c',
  'tile-seamless.c',
  'tile.c',
  'unpremultiply.c',
  'unsharp-mask.c',
  'value-invert.c',
  'vignette.c',
  'waterpixels.c',
  'watershed-transform.c',
  'wavelet-blur-1d.c',
  'wavelet-blur.c',
  'weighted-blend.c',
  'write-buffer.c',
)

gegl_common_sources += custom_target('module_common.c',
  input : [ gegl_common_sources ],
  output: [ 'module_common.c' ],
  command: [
    gen_loader,
    '@INPUT@',
  ],
  capture: true
)

gegl_common = shared_library('gegl-common',
  gegl_common_sources,
  opencl_headers,
  include_directories: [ rootInclude, geglInclude, ],
  dependencies: [
    babl,
    glib,
    json_glib,
    math,
    openmp,
  ],
  link_with: [
    gegl_lib,
  ],
  c_args: [
    '-DGEGL_OP_BUNDLE',
  ],
  name_prefix: '',
  install: true,
  install_dir: get_option('libdir') / api_name,
)

gegl_operations += gegl_common

if host_cpu_family == 'x86_64'

  gegl_common_x86_64_v2 = shared_library('gegl-common-x86_64-v2',
    gegl_common_sources, opencl_headers,
    include_directories: [ rootInclude, geglInclude, ],
    dependencies: [ babl, glib, json_glib, math, openmp, ],
    link_with: [ gegl_lib, ],
    c_args: [ '-DGEGL_OP_BUNDLE' ] + x86_64_v2_flags,
    name_prefix: '',
    install: true,
    install_dir: get_option('libdir') / api_name,
  )
  gegl_operations += gegl_common_x86_64_v2

  gegl_common_x86_64_v3 = shared_library('gegl-common-x86_64-v3',
    gegl_common_sources, opencl_headers,
    include_directories: [ rootInclude, geglInclude, ],
    dependencies: [ babl, glib, json_glib, math, openmp, ],
    link_with: [ gegl_lib, ],
    c_args: [ '-DGEGL_OP_BUNDLE' ] + x86_64_v3_flags,
    name_prefix: '',
    install: true,
    install_dir: get_option('libdir') / api_name,
  )
  
  gegl_operations += gegl_common_x86_64_v3
elif host_cpu_family == 'arm'

  gegl_common_arm_neon = shared_library('gegl-common-arm-neon',
    gegl_common_sources, opencl_headers,
    include_directories: [ rootInclude, geglInclude, ],
    dependencies: [ babl, glib, json_glib, math, openmp, ],
    link_with: [ gegl_lib, ],
    c_args: [ '-DGEGL_OP_BUNDLE' ] + arm_neon_flags,
    name_prefix: '',
    install: true,
    install_dir: get_option('libdir') / api_name,
  )
  gegl_operations += gegl_common_arm_neon
endif
