#ifndef BOTAN_BUILD_CONFIG_H_
#define BOTAN_BUILD_CONFIG_H_

/**
* @file  build.h
* @brief Build configuration for Botan %{version}
*
* Automatically generated from
* '%{command_line}'
*
* Target
*  - Compiler: %{cxx} %{cxx_abi_flags} %{cc_lang_flags} %{cc_compile_flags}
*  - Arch: %{arch}
*  - OS: %{os}
*/

/**
 * @defgroup buildinfo Build Information
 */

/**
 * @ingroup buildinfo
 * @defgroup buildinfo_version Build version information
 * @{
 */

#define BOTAN_VERSION_MAJOR %{version_major}
#define BOTAN_VERSION_MINOR %{version_minor}
#define BOTAN_VERSION_PATCH %{version_patch}
#define BOTAN_VERSION_DATESTAMP %{version_datestamp}

%{if version_suffix}
#define BOTAN_VERSION_SUFFIX %{version_suffix}
#define BOTAN_VERSION_SUFFIX_STR "%{version_suffix}"
%{endif}

#define BOTAN_VERSION_RELEASE_TYPE "%{release_type}"

#define BOTAN_VERSION_VC_REVISION "%{version_vc_rev}"

#define BOTAN_DISTRIBUTION_INFO "%{distribution_info}"

/**
 * @}
 */

/**
 * @ingroup buildinfo
 * @defgroup buildinfo_configuration Build configurations
 * @{
 */

/** How many bits per limb in a BigInt */
#define BOTAN_MP_WORD_BITS %{mp_bits}

%{if fuzzer_mode}
/** Disables certain validation checks to ease fuzzability of the library
 * @warning This causes the library build to be insecure, hence, it must not be
 *          used in a production environment!
 */
#define BOTAN_UNSAFE_FUZZER_MODE
%{endif}
%{if fuzzer_type}
#define BOTAN_FUZZERS_ARE_BEING_BUILT
#define BOTAN_FUZZER_IS_%{fuzzer_type}
%{endif}

#define BOTAN_INSTALL_PREFIX R"(%{prefix})"
#define BOTAN_INSTALL_HEADER_DIR R"(%{includedir}/botan-%{version_major})"
#define BOTAN_INSTALL_LIB_DIR R"(%{libdir})"
#define BOTAN_LIB_LINK "%{link_to}"
#define BOTAN_LINK_FLAGS "%{cxx_abi_flags}"

%{if system_cert_bundle}
#define BOTAN_SYSTEM_CERT_BUNDLE "%{system_cert_bundle}"
%{endif}

#ifndef BOTAN_DLL
  #define BOTAN_DLL %{visibility_attribute}
#endif

/* Target identification and feature test macros */

#define BOTAN_TARGET_OS_IS_%{os_name|upper}

%{for os_features}
#define BOTAN_TARGET_OS_HAS_%{i|upper}
%{endfor}

#define BOTAN_BUILD_COMPILER_IS_%{cc_macro}

%{if cxx_supports_gcc_inline_asm}
#define BOTAN_USE_GCC_INLINE_ASM
%{endif}

%{for sanitizer_types}
#define BOTAN_HAS_SANITIZER_%{i|upper}
%{endfor}

#define BOTAN_TARGET_ARCH "%{arch}"
#define BOTAN_TARGET_ARCH_IS_%{arch|upper}
%{if endian}
#define BOTAN_TARGET_CPU_IS_%{endian|upper}_ENDIAN
%{endif}
%{if cpu_family}
#define BOTAN_TARGET_CPU_IS_%{cpu_family|upper}_FAMILY
%{endif}
%{if cpu_is_64bit}
#define BOTAN_TARGET_CPU_HAS_NATIVE_64BIT
%{endif}

%{for cpu_features}
#define BOTAN_TARGET_SUPPORTS_%{i|upper}
%{endfor}

%{if with_valgrind}
#define BOTAN_HAS_VALGRIND
%{endif}

%{if with_debug_asserts}
#define BOTAN_ENABLE_DEBUG_ASSERTS
%{endif}

%{if terminate_on_asserts}
#define BOTAN_TERMINATE_ON_ASSERTS
%{endif}

%{if optimize_for_size}
#define BOTAN_OPTIMIZE_FOR_SIZE
%{endif}

/**
 * @}
 */

/**
 * @ingroup buildinfo
 * @defgroup buildinfo_modules Enabled modules and API versions
 * @{
 */

/*
* Module availability definitions
*/
%{for module_defines}
#define BOTAN_HAS_%{i}
%{endfor}

/**
 * @}
 */

/**
 * @addtogroup buildinfo_configuration
 * @{
 */

/** Local/misc configuration options (if any) follow */
%{local_config}

/*
* Things you can edit (but probably shouldn't)
*/

/** How much to allocate for a buffer of no particular size */
#define BOTAN_DEFAULT_BUFFER_SIZE 4096

#if defined(BOTAN_HAS_VALGRIND) || defined(BOTAN_ENABLE_DEBUG_ASSERTS)
   /**
    * @brief Prohibits access to unused memory pages in Botan's memory pool
    *
    * If BOTAN_MEM_POOL_USE_MMU_PROTECTIONS is defined, the Memory_Pool
    * class used for mlock'ed memory will use OS calls to set page
    * permissions so as to prohibit access to pages on the free list, then
    * enable read/write access when the page is set to be used. This will
    * turn (some) use after free bugs into a crash.
    *
    * The additional syscalls have a substantial performance impact, which
    * is why this option is not enabled by default. It is used when built for
    * running in valgrind or debug assertions are enabled.
    */
   #define BOTAN_MEM_POOL_USE_MMU_PROTECTIONS
#endif

/**
* If enabled uses memset via volatile function pointer to zero memory,
* otherwise does a byte at a time write via a volatile pointer.
*/
#define BOTAN_USE_VOLATILE_MEMSET_FOR_ZERO 1

/**
* Normally blinding is performed by choosing a random starting point (plus
* its inverse, of a form appropriate to the algorithm being blinded), and
* then choosing new blinding operands by successive squaring of both
* values. This is much faster than computing a new starting point but
* introduces some possible corelation
*
* To avoid possible leakage problems in long-running processes, the blinder
* periodically reinitializes the sequence. This value specifies how often
* a new sequence should be started.
*/
#define BOTAN_BLINDING_REINIT_INTERVAL 64

/**
* Userspace RNGs like HMAC_DRBG will reseed after a specified number
* of outputs are generated. Set to zero to disable automatic reseeding.
*/
#define BOTAN_RNG_DEFAULT_RESEED_INTERVAL 1024

/** Number of entropy bits polled for reseeding userspace RNGs like HMAC_DRBG */
#define BOTAN_RNG_RESEED_POLL_BITS 256

#define BOTAN_RNG_RESEED_DEFAULT_TIMEOUT std::chrono::milliseconds(50)

/**
* Specifies (in order) the list of entropy sources that will be used
* to seed an in-memory RNG.
*/
#define BOTAN_ENTROPY_DEFAULT_SOURCES \
   { "rdseed", "hwrng", "getentropy", "system_rng", "system_stats" }

/** Multiplier on a block cipher's native parallelism */
#define BOTAN_BLOCK_CIPHER_PAR_MULT 4

/* Check for a common build problem */

#if defined(BOTAN_TARGET_ARCH_IS_X86_64) && ((defined(_MSC_VER) && !defined(_WIN64)) || \
                                             (defined(__clang__) && !defined(__x86_64__)) || \
                                             (defined(__GNUG__) && !defined(__x86_64__)))
    #error "Trying to compile Botan configured as x86_64 with non-x86_64 compiler."
#endif

#if defined(BOTAN_TARGET_ARCH_IS_X86_32) && ((defined(_MSC_VER) && defined(_WIN64)) || \
                                             (defined(__clang__) && !defined(__i386__)) || \
                                             (defined(__GNUG__) && !defined(__i386__)))

    #error "Trying to compile Botan configured as x86_32 with non-x86_32 compiler."
#endif

#endif
