project('SIMDe', 'c', 'cpp',
        default_options: ['c_std=c99'],
        license: 'MIT',
        meson_version : '>=0.54.0',
        version: '0.7.3')
# 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',
  'addhn',
  'addl',
  'addlv',
  'addl_high',
  'addv',
  'addw',
  'addw_high',
  'and',
  'bcax',
  'bic',
  'bsl',
  'cage',
  'cagt',
  'ceq',
  'ceqz',
  'cge',
  'cgez',
  'cgt',
  'cgtz',
  'cle',
  'cls',
  'clez',
  'clt',
  'cltz',
  'clz',
  'cmla',
  'cmla_rot90',
  'cmla_rot180',
  'cmla_rot270',
  'cnt',
  'cvt',
  'combine',
  'create',
  'dot',
  'dot_lane',
  'dup_n',
  'dup_lane',
  'eor',
  'ext',
  'fma',
  'fma_lane',
  'fma_n',
  'get_high',
  'get_lane',
  'get_low',
  'hadd',
  'hsub',
  'ld1',
  'ld1_dup',
  'ld1_lane',
  'ld2',
  'ld3',
  'ld4',
  'ld4_lane',
  'max',
  'maxnm',
  'maxv',
  'min',
  'minnm',
  'minv',
  'mla',
  'mla_n',
  'mlal',
  'mlal_high',
  'mlal_lane',
  'mlal_n',
  'mls',
  'mls_n',
  'mlsl',
  'mlsl_high',
  'mlsl_lane',
  'mlsl_n',
  'movl',
  'movl_high',
  'movn',
  'movn_high',
  'mul',
  'mul_lane',
  'mul_n',
  'mull',
  'mull_high',
  'mull_lane',
  'mull_n',
  'mvn',
  'neg',
  'orn',
  'orr',
  'padal',
  'padd',
  'paddl',
  'pmax',
  'pmin',
  'qadd',
  'qabs',
  'qdmulh',
  'qdmulh_lane',
  'qdmulh_n',
  'qdmull',
  'qrdmulh',
  'qrdmulh_lane',
  'qrdmulh_n',
  'qrshrn_n',
  'qrshrun_n',
  'qmovn',
  'qmovn_high',
  'qmovun',
  'qneg',
  'qshl',
  'qshlu_n',
  'qshrn_n',
  'qshrun_n',
  'qsub',
  'qtbl',
  'qtbx',
  'rbit',
  'recpe',
  'recps',
  'reinterpret',
  'rev16',
  'rev32',
  'rev64',
  'rhadd',
  'rnd',
  'rndi',
  'rndm',
  'rndn',
  'rndp',
  'rshl',
  'rshr_n',
  'rshrn_n',
  'rsqrte',
  'rsqrts',
  'rsra_n',
  'set_lane',
  'shl',
  'shl_n',
  'shll_n',
  'shr_n',
  'shrn_n',
  'sqadd',
  'sra_n',
  'sri_n',
  'st1',
  'st1_lane',
  'st2',
  'st2_lane',
  'st3',
  'st3_lane',
  'st4',
  'st4_lane',
  'sub',
  'subhn',
  'subl',
  'subw',
  'subw_high',
  'tbl',
  'tbx',
  'trn1',
  'trn2',
  'trn',
  'tst',
  'uqadd',
  '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',
  'dbsad',
  'div',
  'dpbf16',
  'dpbusd',
  'dpbusds',
  'dpwssd',
  'dpwssds',
  'expand',
  'extract',
  'fixupimm',
  'fixupimm_round',
  'flushsubnormal',
  'fmadd',
  'fmsub',
  'fnmadd',
  'fnmsub',
  'insert',
  'kshift',
  'load',
  'loadu',
  'lzcnt',
  'madd',
  'maddubs',
  'max',
  'min',
  'mov',
  'mov_mask',
  'movm',
  'mul',
  'mulhi',
  'mulhrs',
  'mullo',
  'multishift',
  'negate',
  'or',
  'packs',
  'packus',
  'permutexvar',
  'permutex2var',
  'popcnt',
  'range',
  'range_round',
  '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-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-f16.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/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())
