/*
 *  SPDX-License-Identifier: GPL-2.0-or-later
 *
 *  Copyright (C) 2020-2024  The DOSBox Staging Team
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License along
 *  with this program; if not, write to the Free Software Foundation, Inc.,
 *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 */

#ifndef DOSBOX_CONFIG_H
#define DOSBOX_CONFIG_H

// This file is a template for the Meson build process.
//
// Placeholders surrounded by '@' characters are substituted with concrete
// values at the start of the build process, and a file `config.cpp` is
// written to the build output directory.

// Git hash of the build
#define BUILD_GIT_HASH "@git_hash@"

/* Operating System
 */

// Defined if compiling for OS from BSD family
#mesondefine BSD

// Defined if compiling for Linux (non-Android)
#mesondefine LINUX

// Defined if compiling for macOS
#mesondefine MACOSX

// Defined if compiling for Windows (any option)
#ifndef WIN32
#mesondefine WIN32
#endif

/* CPU and FPU emulation
 *
 * These defines are mostly relevant to modules src/cpu/ and src/fpu/
 */

// The type of cpu this target has
#mesondefine C_TARGETCPU

// Define to 1 if target CPU supports unaligned memory access
#mesondefine C_UNALIGNED_MEMORY

// Define to 1 if the target platform needs per-page dynamic core write or execute (W^X) tagging
#mesondefine C_PER_PAGE_W_OR_X

// Define to 1 to use x86/x86_64 dynamic cpu core
// Can not be used together with C_DYNREC
#mesondefine C_DYNAMIC_X86

// Define to 1 to use recompiling cpu core
// Can not be used together with C_DYNAMIC_X86
#mesondefine C_DYNREC

// Define to 1 to enable floating point emulation
#mesondefine C_FPU

// Define to 1 to use  fpu core implemented in x86 assembler
#mesondefine C_FPU_X86

// TODO Define to 1 to use inlined memory functions in cpu core
#define C_CORE_INLINE 1

/* Emulator features
 *
 * Turn on or off optional emulator features that depend on external libraries.
 * This way it's easier to port or package on a new platform, where these
 * libraries might be missing.
 */

// Define to 1 to enable internal modem emulation (using SDL2_net)
#mesondefine C_MODEM

// Define to 1 to enable IPX over Internet networking (using SDL2_net)
#mesondefine C_IPX

// Enable serial port passthrough support
#mesondefine C_DIRECTSERIAL

// Define to 1 to use opengl display output support
#mesondefine C_OPENGL

// Define to 1 to enable FluidSynth integration (built-in MIDI synth)
#mesondefine C_FLUIDSYNTH

// Define to 1 to enable libslirp Ethernet support
#mesondefine C_SLIRP

// Define to 1 to enable Novell NE 2000 NIC emulation
#mesondefine C_NE2000

// Define to 1 to enable the Tracy profiling server
#mesondefine C_TRACY

// Define to 1 to enable internal debugger (using ncurses or pdcurses)
#mesondefine C_DEBUG

// Define to 1 to enable heavy debugging (requires C_DEBUG)
#mesondefine C_HEAVY_DEBUG

// Define to 1 to enable MT-32 emulator
#mesondefine C_MT32EMU

// Define to 1 to enable mouse mapping support
#mesondefine C_MANYMOUSE

// ManyMouse optionally supports the X Input 2.0 protocol (regardless of OS). It
// uses the following define to definitively indicate if it should or shouldn't
// use the X Input 2.0 protocol. If this is left undefined, then ManyMouse makes
// an assumption about availability based on OS type.
#mesondefine SUPPORT_XINPUT2

// Compiler supports Core Audio headers
#mesondefine C_COREAUDIO

// Compiler supports Core MIDI headers
#mesondefine C_COREMIDI

// Compiler supports Core Foundation headers
#mesondefine C_COREFOUNDATION

// Compiler supports Core Services headers
#mesondefine C_CORESERVICES

// Define to 1 to enable ALSA MIDI support
#mesondefine C_ALSA

/* Compiler features and extensions
 *
 * These are defines for compiler features we can't reliably verify during
 * compilation time.
 */

#mesondefine C_HAS_BUILTIN_EXPECT

/* Defines for checking availability of standard functions and structs.
 *
 * Sometimes available functions, structs, or struct fields differ slightly
 * between operating systems.
 */

// Define to 1 when zlib-ng support is provided by the system
#mesondefine C_SYSTEM_ZLIB_NG

// Defined if function clock_gettime is available
#mesondefine HAVE_CLOCK_GETTIME

// Defined if function __builtin_available is available
#mesondefine HAVE_BUILTIN_AVAILABLE

// Defined if function __builtin___clear_cache is available
#mesondefine HAVE_BUILTIN_CLEAR_CACHE

// Defined if function mprotect is available
#mesondefine HAVE_MPROTECT

// Defined if function mmap is available
#mesondefine HAVE_MMAP

// Defined if mmap flag MAPJIT is available
#mesondefine HAVE_MAP_JIT

// Defined if function pthread_jit_write_protect_np is available
#mesondefine HAVE_PTHREAD_WRITE_PROTECT_NP

// Defined if function sys_icache_invalidate is available
#mesondefine HAVE_SYS_ICACHE_INVALIDATE

// Defined if function pthread_setname_np is available
#mesondefine HAVE_PTHREAD_SETNAME_NP

// Defind if function setpriority is available
#mesondefine HAVE_SETPRIORITY

// Defind if function strnlen is available
#mesondefine HAVE_STRNLEN

// field d_type in struct dirent is not defined in POSIX
// Some OSes do not implement it (e.g. Haiku)
#mesondefine HAVE_STRUCT_DIRENT_D_TYPE



/* Available headers
 *
 * Checks for non-POSIX headers and POSIX headers not supported on Windows.
 */

#mesondefine HAVE_LIBGEN_H
#mesondefine HAVE_NETINET_IN_H
#mesondefine HAVE_PWD_H
#define HAVE_STDLIB_H 1
#mesondefine HAVE_STRINGS_H
#mesondefine HAVE_SYS_SOCKET_H
#define HAVE_SYS_TYPES_H 1
#mesondefine HAVE_SYS_XATTR_H

/* Hardware-related defines
 */

// Define to 1 when host/target processor uses big endian byte ordering
#mesondefine WORDS_BIGENDIAN

// Non-4K page size (only on selected architectures)
#mesondefine PAGESIZE

/* Windows-related defines
 */

// Prevent <windows.h> from clobbering std::min and std::max
#mesondefine NOMINMAX

// Enables mathematical constants (such as M_PI) in Windows math.h header
// https://docs.microsoft.com/en-us/cpp/c-runtime-library/math-constants
#mesondefine _USE_MATH_DEFINES

// Modern MSVC provides POSIX-like routines, so prefer that over built-in
#mesondefine HAVE_STRNLEN

// Holds the "--datadir" specified during project setup. This can
// be used as a fallback if the user hasn't populated their
// XDG_DATA_HOME or XDG_DATA_DIRS to include the --datadir.
#mesondefine CUSTOM_DATADIR

#endif
