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

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

simde_neon_families = [
  'aba',
  'abal',
  'abal_high',
  'abd',
  'abdl',
  'abdl_high',
  'abs',
  'add',
  'addhn',
  'addhn_high',
  'addl',
  'addlv',
  'addl_high',
  'addv',
  'addw',
  'addw_high',
  'aes',
  'and',
  'bcax',
  'bic',
  'bsl',
  'cadd_rot270',
  'cadd_rot90',
  'cage',
  'cagt',
  'cale',
  'calt',
  'ceq',
  'ceqz',
  'cge',
  'cgez',
  'cgt',
  'cgtz',
  'cle',
  'cls',
  'clez',
  'clt',
  'cltz',
  'clz',
  'cmla',
  'cmla_lane',
  'cmla_rot180',
  'cmla_rot180_lane',
  'cmla_rot270',
  'cmla_rot270_lane',
  'cmla_rot90',
  'cmla_rot90_lane',
  'cnt',
  'cvt',
  'cvt_n',
  'cvtm',
  'cvtn',
  'cvtp',
  'combine',
  'copy_lane',
  'crc32',
  'create',
  'div',
  'dot',
  'dot_lane',
  'dup_n',
  'dup_lane',
  'eor',
  'ext',
  'fma',
  'fma_lane',
  'fma_n',
  'fmlal',
  'fmlsl',
  'fms',
  'fms_lane',
  'fms_n',
  'get_high',
  'get_lane',
  'get_low',
  'hadd',
  'hsub',
  'ld1_dup',
  'ld1_lane',
  'ld1_x2',
  'ld1_x3',
  'ld1_x4',
  'ld1q_x2',
  'ld1q_x3',
  'ld1q_x4',
  'ld1',
  'ld2',
  'ld2_dup',
  'ld2_lane',
  'ld3',
  'ld3_dup',
  'ld3_lane',
  'ld4',
  'ld4_dup',
  'ld4_lane',
  'max',
  'maxnm',
  'maxnmv',
  'maxv',
  'min',
  'minnm',
  'minnmv',
  'minv',
  'mla',
  'mla_lane',
  'mla_n',
  'mlal',
  'mlal_high',
  'mlal_high_lane',
  'mlal_high_n',
  'mlal_lane',
  'mlal_n',
  'mls',
  'mls_lane',
  'mls_n',
  'mlsl',
  'mlsl_high',
  'mlsl_high_lane',
  'mlsl_high_n',
  'mlsl_lane',
  'mlsl_n',
  'mmlaq',
  'movl',
  'movl_high',
  'movn',
  'movn_high',
  'mul',
  'mul_lane',
  'mul_n',
  'mull',
  'mull_high',
  'mull_high_lane',
  'mull_high_n',
  'mull_lane',
  'mull_n',
  'mulx',
  'mulx_lane',
  'mulx_n',
  'mvn',
  'neg',
  'orn',
  'orr',
  'padal',
  'padd',
  'paddl',
  'pmax',
  'pmaxnm',
  'pmin',
  'pminnm',
  'qadd',
  'qabs',
  'qdmlal',
  'qdmlal_high',
  'qdmlal_high_lane',
  'qdmlal_high_n',
  'qdmlal_lane',
  'qdmlal_n',
  'qdmlsl',
  'qdmlsl_high',
  'qdmlsl_high_lane',
  'qdmlsl_high_n',
  'qdmlsl_lane',
  'qdmlsl_n',
  'qdmulh',
  'qdmulh_lane',
  'qdmulh_n',
  'qdmull',
  'qdmull_high',
  'qdmull_high_lane',
  'qdmull_high_n',
  'qdmull_lane',
  'qdmull_n',
  'qrdmlah',
  'qrdmlah_lane',
  'qrdmlsh',
  'qrdmlsh_lane',
  'qrdmulh',
  'qrdmulh_lane',
  'qrdmulh_n',
  'qrshl',
  'qrshrn_high_n',
  'qrshrn_n',
  'qrshrun_high_n',
  'qrshrun_n',
  'qmovn',
  'qmovn_high',
  'qmovun',
  'qmovun_high',
  'qneg',
  'qshl',
  'qshl_n',
  'qshlu_n',
  'qshrn_high_n',
  'qshrn_n',
  'qshrun_high_n',
  'qshrun_n',
  'qsub',
  'qtbl',
  'qtbx',
  'raddhn',
  'raddhn_high',
  'rax',
  'rbit',
  'recpe',
  'recps',
  'recpx',
  'reinterpret',
  'rev16',
  'rev32',
  'rev64',
  'rhadd',
  'rnd',
  'rnd32x',
  'rnd32z',
  'rnd64x',
  'rnd64z',
  'rnda',
  'rndi',
  'rndm',
  'rndn',
  'rndp',
  'rndx',
  'rshl',
  'rshr_n',
  'rshrn_high_n',
  'rshrn_n',
  'rsqrte',
  'rsqrts',
  'rsra_n',
  'rsubhn',
  'rsubhn_high',
  'set_lane',
  'sha1',
  'sha256',
  'sha512',
  'shl',
  'shl_n',
  'shll_high_n',
  'shll_n',
  'shr_n',
  'shrn_high_n',
  'shrn_n',
  'sli_n',
  'sm3',
  'sm4',
  'sqadd',
  'sqrt',
  'sra_n',
  'sri_n',
  'st1',
  'st1_lane',
  'st1_x2',
  'st1_x3',
  'st1_x4',
  'st1q_x2',
  'st1q_x3',
  'st1q_x4',
  'st2',
  'st2_lane',
  'st3',
  'st3_lane',
  'st4',
  'st4_lane',
  'sub',
  'subhn',
  'subhn_high',
  'subl',
  'subl_high',
  'subw',
  'subw_high',
  'sudot_lane',
  'tbl',
  'tbx',
  'trn1',
  'trn2',
  'trn',
  'tst',
  'uqadd',
  'usdot',
  'usdot_lane',
  'uzp1',
  'uzp2',
  'uzp',
  'xar',
  'zip1',
  'zip2',
  'zip',
]

simde_sve_families = [
  'add',
  'and',
  'cnt',
  'cmplt',
  'dup',
  'ld1',
  'ptest',
  'ptrue',
  'qadd',
  'sel',
  'st1',
  'sub',
  'reinterpret',
  'whilelt'
]

simde_avx512_families = [
  '2intersect',
  '4dpwssd',
  '4dpwssds',
  'abs',
  'add',
  'adds',
  'and',
  'andnot',
  'avg',
  'bitshuffle',
  'blend',
  'broadcast',
  'cast',
  'cmp',
  'cmpeq',
  'cmpge',
  'cmpgt',
  'cmple',
  'cmplt',
  'cmpneq',
  'compress',
  'conflict',
  'copysign',
  'cvt',
  'cvtt',
  'cvts',
  'cvtus',
  'dbsad',
  'div',
  'dpbf16',
  'dpbusd',
  'dpbusds',
  'dpwssd',
  'dpwssds',
  'expand',
  'extract',
  'fixupimm',
  'fixupimm_round',
  'flushsubnormal',
  'fmadd',
  'fmsub',
  'fnmadd',
  'fnmsub',
  'fpclass',
  'gather',
  'insert',
  'kand',
  'kshift',
  'knot',
  'kxor',
  'load',
  'loadu',
  'lzcnt',
  'madd',
  'maddubs',
  'max',
  'min',
  'mov',
  'mov_mask',
  'movm',
  'mul',
  'mulhi',
  'mulhrs',
  'mullo',
  'multishift',
  'negate',
  'or',
  'packs',
  'packus',
  'permutex',
  'permutexvar',
  'permutex2var',
  'popcnt',
  'range',
  'range_round',
  'rcp',
  'reduce',
  'rol',
  'rolv',
  'ror',
  'rorv',
  'round',
  'roundscale',
  'roundscale_round',
  'sad',
  'scalef',
  'set',
  'set1',
  'set4',
  'setr',
  'setr4',
  'setzero',
  'setone',
  'shldv',
  'shuffle',
  'sll',
  'slli',
  'sllv',
  'sqrt',
  'sra',
  'srai',
  'srav',
  'srl',
  'srli',
  'srlv',
  'store',
  'storeu',
  'sub',
  'subs',
  'ternarylogic',
  'test',
  'testn',
  'unpacklo',
  'unpackhi',
  'xor',
  'xorsign',
]

simde_msa_families = [
  'add_a',
  'adds',
  'adds_a',
  'addv',
  'addvi',
  'and',
  'andi',
  'ld',
  'madd',
  'st',
  'subv',
]

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_sve_family_headers = ['simde/arm/sve/types.h']
foreach sve_family : simde_sve_families
  simde_sve_family_headers += 'simde/arm/sve/' + sve_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

simde_msa_family_headers = ['simde/mips/msa/types.h']
foreach msa_family : simde_msa_families
  simde_msa_family_headers += 'simde/mips/msa/' + msa_family + '.h'
endforeach

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

  install_headers(
    files([
      'simde/x86/aes.h',
      'simde/x86/avx512.h',
      'simde/x86/avx2.h',
      'simde/x86/avx.h',
      'simde/x86/clmul.h',
      'simde/x86/fma.h',
      'simde/x86/f16c.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',
      'simde/arm/sve.h',
      ]),
    subdir: 'simde/arm')

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

  install_headers(
    files(simde_sve_family_headers),
    subdir: 'simde/arm/sve')

  install_headers(
    files([
      'simde/wasm/simd128.h',
      'simde/wasm/relaxed-simd.h',
      ]),
    subdir: 'simde/wasm')

  install_headers(
    files([
      'simde/mips/msa.h',
      ]),
    subdir: 'simde/mips')

  install_headers(
    files(simde_msa_family_headers),
    subdir: 'simde/mips/msa')

  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())
