option(
    'use_sdl2_net',
    type: 'boolean',
    value: true,
    description: 'Enable networking features via SDL2_net (modem, ipx)',
)

option(
    'use_opengl',
    type: 'boolean',
    value: true,
    description: 'Enable OpenGL support',
)

option(
    'use_fluidsynth',
    type: 'boolean',
    value: true,
    description: 'Enable built-in MIDI support via FluidSynth',
)

option(
    'use_mt32emu',
    type: 'boolean',
    value: true,
    description: 'Enable built-in MT-32 emulation support',
)

option(
    'use_slirp',
    type: 'boolean',
    value: true,
    description: 'Enable Ethernet emulation using Libslirp',
)

option(
    'tracy',
    type: 'boolean',
    value: false,
    description: 'Enable profiling using Tracy',
)

# This option exists only for rare situations when Linux developer cannot
# install ALSA library headers on their machine.
#
# 'auto' translates to 'true' on Linux systems and 'false' everywhere else.
#
option(
    'use_alsa',
    type: 'combo',
    choices: ['auto', 'true', 'false'],
    value: 'auto',
    description: 'Enable ALSA MIDI support',
)

# This option lets packagers control whether ManyMouse uses the optional X Input
# 2.0 protocol. Because this requires a full X11 library stack, it's useful for
# distributions that either come with a full X11 environment (and want to make
# this a hard dependency), or for those without an X11 environment but may still
# have X11 in their build bots (and don't want this pulled in by accident).
#
option(
    'use_xinput2',
    type: 'combo',
    choices: ['auto', 'true', 'false'],
    value: 'auto',
    description: 'Let ManyMouse use the X Input 2.0 protocol.',
)

# The meson.build either uses zlib-ng if its found as a system library or
# compiles it as a built-in (provided CMake is available and Meson is at
# least version 1.3.0), in that order.
#
# The built-in will use native SIMD instructions by default, however if you're
# targeting a range of hardware then set this to the most conservative set of
# SIMD instructions for your needs. For example, if you want to be sure your
# binary runs on Intel's Core 2 Duo, set: meson setup -Duse_zlib_ng=sse2,ssse3
#
# To disable zlib-ng use -Duse_zlib_ng=false
# To only use the built-in: --wrap-mode=forcefallback or --force-fallback-for=zlib-ng
#
option(
    'use_zlib_ng',
    type: 'array',
    choices: [
        # Disable zlib-ng; use good old zlib.
        'false',
        
        # Native (default) enables those instruction sets supported
        # by Meson's build-target machine, which is often the local
        # system (unless you're cross-compiling).
        # Only guaranteed when the built-in is used.
        'native',

        # Enable x86 and x86-64 instruction sets.
        # Only guaranteed when the built-in is used.
        'avx2',
        'avx512',
        'avx512vnni',
        'sse2',
        'ssse3',
        'sse42',
        'pclmulqdq',
        'vpclmulqdq',

        # Enable Arm instruction sets.
        # Only guaranteed when the built-in is used.
        'acle',
        'neon',
        'armv6',

        # Enable POWER and PowerPC instruction sets.
        # Only guaranteed when the built-in is used.
        'altivec',
        'power8',

        # Enable the RISC-V "V" (vector) instruction set.
        # Only guaranteed when the built-in is used.
        'rvv',

        # Enable the IBM Z instruction sets.
        # Only guaranteed when the built-in is used.
        'crc32_vx',
        'dfltcc_deflate',
        'dfltcc_inflate',
    ],
    value: ['native'],
    description: 'Enable zlib-ng with SIMD optimizations',
)

option(
    'enable_debugger',
    type: 'combo',
    choices: ['normal', 'heavy', 'none'],
    value: 'none',
    description: 'Build emulator with internal debugger feature.',
)

option(
    'dynamic_core',
    type: 'combo',
    choices: ['auto', 'dyn-x86', 'dynrec', 'none'],
    value: 'auto',
    description: 'Select the dynamic core implementation.',
)

option(
    'pagesize',
    type: 'integer',
    value: 0,
    description: 'Set host memory pagesize in bytes (skip detection)',
)

# Per-page write-or-execute (W^X) permissions
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# This option lets packagers control if dynamic core memory pages are flagged
# with write-or-execute (W^X) permissions on a per-page basis.

# Platforms that support W^X in hardware can do this with near-zero overhead,
# where as slower platforms like PowerPC and 32-bit ARM SBCs might experience
# signficant performance overhead with this enabled.
#
# Defaults per-platform are in the "src/cpu/meson.build" file, and should
# be OK. However, if you find them to be wrong, please follow the next steps
# to check if per-page W^X is both unecessary and costly.
#
#  1) Create two builds:
#       meson setup -Dper_page_w_or_x=enabled  build/with_per_page_w_or_x
#       meson setup -Dper_page_w_or_x=disabled build/without_per_page_w_or_x
#
#  2) For each build, launch and switch to the dynamic by entering "core dynamic"
#     at the Z:\> prompt.  If the build without per-page W^X crashes, then stop
#     here: your platforms needs W^X.
#
#  3) If the build without per-page W^X didn't crash, now compare how much
#     host CPU usage they both consume using your task manager or 'top'.
#     If their usages are about the same, then your platform has fast support
#     for per-page W^X, so stop here (the defaults are fine).
#
#  4) If the build without per-page W^X is using less CPU usage, then you
#     should build with "-Dper_page_w_or_x=disabled". Please also inform
#     the maintenance team so they can make this the new default for your
#     platform.
#
option(
    'per_page_w_or_x',
    type: 'feature',
    value: 'auto',
    description: 'Flag dynamic core memory write-or-execute (W^X) per-page.',
)

# Use this option for selectively switching dependencies to look for static
# libraries first. This behaves differently than passing
# -Ddefault_library=static (which will turn on static linking for dependencies
# built from wraps, but still attempt dynamic linking for system-installed
# libraries).
#
# This is NOT guaranteed to work - the end results will vary depending on your
# OS, installed libraries, and dependencies of those libraries.
#
option(
    'try_static_libs',
    type: 'array',
    choices: [
        'fluidsynth',
        'glib',
        'iir',
        'mt32emu',
        'opusfile',
        'png',
        'sdl2',
        'sdl2_net',
        'slirp',
        'speexdsp',
        'tracy',
        'zlib',
    ],
    value: [],
    description: 'Attempt to statically link selected libraries.',
)

option(
    'unit_tests',
    type: 'feature',
    value: 'auto',
    description: 'Build unit tests. Auto skips for release builds.',
)

option(
    'narrowing_warnings',
    type: 'boolean',
    value: false,
    description: 'Warn about implicit type narrowing',
)

option(
    'autovec_info',
    type: 'boolean',
    value: false,
    description: 'Inform about auto-vectorizion results',
)

option(
    'asm',
    type: 'boolean',
    value: false,
    description: 'Save intermediate assembly output',
)

option(
    'time_trace',
    type: 'boolean',
    value: false,
    description: 'Time build events, for use with the Clang Build Analyzer tool',
)
