project('SIMDe', 'c', 'cpp',
        default_options: ['c_std=c99'],
        license: 'MIT',
        version: '0.7.2')
# also update SIMDE_VESION_* in simde/simde-common.h

cc = meson.get_compiler('c')
cxx = meson.get_compiler('cpp')

simde_neon_families = [
  'aba',
  'abd',
  'abdl',
  'abs',
  'add',
  'addl',
  'addlv',
  'addl_high',
  'addv',
  'addw',
  'addw_high',
  'and',
  'bic',
  'bsl',
  'cagt',
  'ceq',
  'ceqz',
  'cge',
  'cgez',
  'cgt',
  'cgtz',
  'cle',
  'cls',
  'clez',
  'clt',
  'cltz',
  'clz',
  'cnt',
  'cvt',
  'combine',
  'create',
  'dot',
  'dot_lane',
  'dup_n',
  'dup_lane',
  'eor',
  'ext',
  'get_high',
  'get_lane',
  'get_low',
  'hadd',
  'hsub',
  'ld1',
  'ld3',
  'ld4',
  'max',
  'maxnm',
  'maxv',
  'min',
  'minnm',
  'minv',
  'mla',
  'mla_n',
  'mlal',
  'mlal_high',
  'mlal_n',
  'mls',
  'mlsl',
  'mlsl_high',
  'mlsl_n',
  'movl',
  'movl_high',
  'movn',
  'movn_high',
  'mul',
  'mul_lane',
  'mul_n',
  'mull',
  'mull_high',
  'mull_n',
  'mvn',
  'neg',
  'orn',
  'orr',
  'padal',
  'padd',
  'paddl',
  'pmax',
  'pmin',
  'qadd',
  'qabs',
  'qdmulh',
  'qdmull',
  'qrdmulh',
  'qrdmulh_n',
  'qmovn',
  'qmovn_high',
  'qmovun',
  'qneg',
  'qshl',
  'qsub',
  'qtbl',
  'qtbx',
  'rbit',
  'reinterpret',
  'rev16',
  'rev32',
  'rev64',
  'rhadd',
  'rnd',
  'rndi',
  'rndm',
  'rndn',
  'rndp',
  'rshl',
  'rshr_n',
  'rsra_n',
  'set_lane',
  'shl',
  'shl_n',
  'shr_n',
  'sra_n',
  'st1',
  'st1_lane',
  'st3',
  'st4',
  'sub',
  'subl',
  'subw',
  'subw_high',
  'tbl',
  'tbx',
  'trn1',
  'trn2',
  'trn',
  'tst',
  'uqadd',
  'uzp1',
  'uzp2',
  'uzp',
  'zip1',
  'zip2',
  'zip',
]

simde_avx512_families = [
  '2intersect',
  'abs',
  'add',
  'adds',
  'and',
  'andnot',
  'avg',
  'blend',
  'broadcast',
  'cast',
  'cmp',
  'cmpeq',
  'cmpge',
  'cmpgt',
  'cmple',
  'cmplt',
  'copysign',
  'cvt',
  'cvts',
  'div',
  'extract',
  'fmadd',
  'fmsub',
  'fnmadd',
  'fnmsub',
  'insert',
  'kshift',
  'load',
  'loadu',
  'lzcnt',
  'madd',
  'maddubs',
  'max',
  'min',
  'mov',
  'mov_mask',
  'movm',
  'mul',
  'mulhi',
  'mulhrs',
  'mullo',
  'negate',
  'or',
  'packs',
  'packus',
  'permutexvar',
  'permutex2var',
  'sad',
  'set',
  'set1',
  'set4',
  'setr',
  'setr4',
  'setzero',
  'setone',
  'shuffle',
  'sll',
  'slli',
  'sllv',
  'sqrt',
  'sra',
  'srai',
  'srav',
  'srl',
  'srli',
  'srlv',
  'store',
  'storeu',
  'sub',
  'subs',
  'test',
  'unpacklo',
  'unpackhi',
  'xor',
  'xorsign',
]

if not meson.is_subproject() and get_option('tests')
  subdir('test')
endif

simde_neon_family_headers = ['simde/arm/neon/types.h']
foreach neon_family : simde_neon_families
  simde_neon_family_headers += 'simde/arm/neon/' + neon_family + '.h'
endforeach

simde_avx512_family_headers = ['simde/x86/avx512/types.h']
foreach avx512_family : simde_avx512_families
  simde_avx512_family_headers += 'simde/x86/avx512/' + avx512_family + '.h'
endforeach

if not meson.is_subproject()
  install_headers(
    files([
      'simde/check.h',
      'simde/debug-trap.h',
      'simde/hedley.h',
      'simde/simde-align.h',
      'simde/simde-arch.h',
      'simde/simde-common.h',
      'simde/simde-constify.h',
      'simde/simde-detect-clang.h',
      'simde/simde-diagnostic.h',
      'simde/simde-features.h',
      'simde/simde-math.h',
      'simde/simde-complex.h',
      ]),
    subdir: 'simde')

  install_headers(
    files([
      'simde/x86/avx2.h',
      'simde/x86/avx.h',
      'simde/x86/clmul.h',
      'simde/x86/fma.h',
      'simde/x86/gfni.h',
      'simde/x86/mmx.h',
      'simde/x86/sse2.h',
      'simde/x86/sse3.h',
      'simde/x86/sse4.1.h',
      'simde/x86/sse4.2.h',
      'simde/x86/sse.h',
      'simde/x86/ssse3.h',
      'simde/x86/svml.h',
      'simde/x86/xop.h',
      ]),
    subdir: 'simde/x86')

  install_headers(
    files(simde_avx512_family_headers),
    subdir: 'simde/x86/avx512')

  install_headers(
    files([
      'simde/arm/neon.h',
      ]),
    subdir: 'simde/arm')

  install_headers(
    files(simde_neon_family_headers),
    subdir: 'simde/arm/neon')

  import('pkgconfig').generate(
    version : meson.project_version(),
    name : 'SIMDe',
    filebase : 'simde',
    description : 'Portable SIMD wrapper library')
endif

simde_dep = declare_dependency(
  include_directories : include_directories('.'),
  version : meson.project_version())
