diff --git a/third/python-cmake/.circleci/config.yml b/third/python-cmake/.circleci/config.yml new file mode 100644 index 00000000..00fae535 --- /dev/null +++ b/third/python-cmake/.circleci/config.yml @@ -0,0 +1,217 @@ +version: 2.1 + +orbs: + win: circleci/windows@2.4 + +jobs: + build-test-python: + parameters: + python_version: + description: "Python version specified as X.Y.Z" + type: string + python_arch: + description: "Python arch specified as x64 or x86" + type: string + working_directory: /work + docker: + - image: dockcross/linux-<< parameters.python_arch >> + steps: + - checkout + - run: + name: Install Dependencies + command: | + sudo apt-get update + sudo apt-get install -y \ + libbz2-dev \ + libdb-dev \ + libffi-dev \ + libgdbm-compat-dev \ + libgdbm-dev \ + liblzma-dev \ + libncursesw5-dev \ + libreadline-dev \ + libsqlite3-dev \ + libssl-dev \ + tcl-dev \ + tk-dev + - run: + name: download dashboard scripts + command: | + git clone git@github.com:python-cmake-buildsystem/python-cmake-buildsystem --branch dashboard --depth 1 scripts + - run: + name: build and test + command: | + set -e + ctest --timeout 360 -S /work/scripts/circle_dashboard.cmake -VV + environment: + PY_VERSION: << parameters.python_version >> + + build-test-python-win: + parameters: + python_version: + description: "Python version specified as X.Y.Z" + type: string + python_arch: + description: "Python arch specified as x64 or Win32" + type: string + generator: + description: "CMake generator" + type: string + executor: + name: win/default + shell: powershell.exe + working_directory: C:/Users/circleci/project/src + steps: + - checkout + - run: + name: Install dependencies + command: | + choco install --no-progress cmake + if (-not $?) { throw "Failed to install CMake" } + - run: + name: download dashboard scripts + command: | + git clone git@github.com:python-cmake-buildsystem/python-cmake-buildsystem --branch dashboard --depth 1 ../scripts + - run: + name: build and test + command: | + $Env:PATH += ";C:\Program Files\CMake\bin" + ctest -C $Env:CONFIGURATION -S C:/Users/circleci/project/scripts/circle_win_dashboard.cmake -VV + environment: + PY_VERSION: << parameters.python_version >> + CONFIGURATION: Release + GENERATOR: << parameters.generator >> + PLATFORM: << parameters.python_arch >> + +workflows: + build-and-test: + jobs: + # 3.12.10 + - build-test-python: + name: python-3.12.10-x64 + python_version: 3.12.10 + python_arch: x64 + + - build-test-python: + name: python-3.12.10-x86 + python_version: 3.12.10 + python_arch: x86 + + # 3.11.12 + - build-test-python: + name: python-3.11.12-x64 + python_version: 3.11.12 + python_arch: x64 + + - build-test-python: + name: python-3.11.12-x86 + python_version: 3.11.12 + python_arch: x86 + + # 3.10.17 + - build-test-python: + name: python-3.10.17-x64 + python_version: 3.10.17 + python_arch: x64 + + - build-test-python: + name: python-3.10.17-x86 + python_version: 3.10.17 + python_arch: x86 + + # 3.9.22 + - build-test-python: + name: python-3.9.22-x64 + python_version: 3.9.22 + python_arch: x64 + + - build-test-python: + name: python-3.9.22-x86 + python_version: 3.9.22 + python_arch: x86 + + # 3.8.20 + - build-test-python: + name: python-3.8.20-x64 + python_version: 3.8.20 + python_arch: x64 + + - build-test-python: + name: python-3.8.20-x86 + python_version: 3.8.20 + python_arch: x86 + + # 3.7.17 + - build-test-python: + name: python-3.7.17-x64 + python_version: 3.7.17 + python_arch: x64 + + - build-test-python: + name: python-3.7.17-x86 + python_version: 3.7.17 + python_arch: x86 + + # 3.6.15 + - build-test-python: + name: python-3.6.15-x64 + python_version: 3.6.15 + python_arch: x64 + + - build-test-python: + name: python-3.6.15-x86 + python_version: 3.6.15 + python_arch: x86 + + + build-and-test-win: + jobs: + # 3.12.10 + - build-test-python-win: + name: python-3.12.10-win-x64 + python_version: 3.12.10 + python_arch: x64 + generator: "Visual Studio 16 2019" + + # 3.11.12 + - build-test-python-win: + name: python-3.11.12-win-x64 + python_version: 3.11.12 + python_arch: x64 + generator: "Visual Studio 16 2019" + + # 3.10.17 + - build-test-python-win: + name: python-3.10.17-win-x64 + python_version: 3.10.17 + python_arch: x64 + generator: "Visual Studio 16 2019" + + # 3.9.22 + - build-test-python-win: + name: python-3.9.22-win-x64 + python_version: 3.9.22 + python_arch: x64 + generator: "Visual Studio 16 2019" + + # 3.8.20 + - build-test-python-win: + name: python-3.8.20-win-x64 + python_version: 3.8.20 + python_arch: x64 + generator: "Visual Studio 16 2019" + + # 3.7.17 + - build-test-python-win: + name: python-3.7.17-win-x64 + python_version: 3.7.17 + python_arch: x64 + generator: "Visual Studio 16 2019" + + # 3.6.15 + - build-test-python-win: + name: python-3.6.15-win-x64 + python_version: 3.6.15 + python_arch: x64 + generator: "Visual Studio 16 2019" + diff --git a/third/python-cmake/.git-blame-ignore-revs b/third/python-cmake/.git-blame-ignore-revs new file mode 100644 index 00000000..be4519af --- /dev/null +++ b/third/python-cmake/.git-blame-ignore-revs @@ -0,0 +1,27 @@ +# +# This file lists revisions that should be ignored when considering +# attribution for the actual code written. Code style changes should +# not be considered as modifications with regards to attribution. +# +# To see clean and meaningful blame information. +# $ git blame important.py --ignore-revs-file .git-blame-ignore-revs +# +# To configure git to automatically ignore revisions listed in a file on every call to git blame. +# $ git config blame.ignoreRevsFile .git-blame-ignore-revs +# +# Ignore changes introduced when doing global file format changes + +# style: Strip trailing spaces from CMake files +69065ad9923a96440d4542ca31ade487fd5d386b +# style: Indent add_python_extension parameters anticipating updates +c978a31af114d512fd30c974f6f4137f5982336d +# style: Indent add_python_extension parameters anticipating updates +12eb75b97df18c28af676503976969eda768d098 +# style: Indent add_python_extension parameters anticipating updates +08bf81fe995484092de5d40ca528de377d18c17f +# style: Dedent extension inclusion anticipating use of IS_PY variable +568146eb073f4ba9c4304dd7b510a17cb53c91f5 +# style: Indent parameter associated with python3 dll anticipating updates +bb0eb202b170b97003e4b3636e982408fed65fb2 +# style: Indent add_python_extension parameters anticipating updates +6708b3e446189164badfe465bb8df7447a96a0ff diff --git a/third/python-cmake/.gitattributes b/third/python-cmake/.gitattributes new file mode 100644 index 00000000..9812ceb1 --- /dev/null +++ b/third/python-cmake/.gitattributes @@ -0,0 +1 @@ +*.patch text eol=lf diff --git a/third/python-cmake/.github/dependabot.yml b/third/python-cmake/.github/dependabot.yml new file mode 100644 index 00000000..95d11d8c --- /dev/null +++ b/third/python-cmake/.github/dependabot.yml @@ -0,0 +1,9 @@ +version: 2 +updates: + + # Maintain dependencies for GitHub Actions + - package-ecosystem: "github-actions" + directory: "/" + schedule: + # Check for updates to GitHub Actions every week + interval: "weekly" diff --git a/third/python-cmake/.github/workflows/CI.yml b/third/python-cmake/.github/workflows/CI.yml new file mode 100644 index 00000000..552b404f --- /dev/null +++ b/third/python-cmake/.github/workflows/CI.yml @@ -0,0 +1,74 @@ +name: CI + +on: + pull_request: + push: + branches: + - master + +jobs: + tests: + runs-on: ${{ matrix.runs-on }} + strategy: + fail-fast: false + matrix: + runs-on: [macos-latest] + python-version: [3.7.17, 3.8.20, 3.9.22, 3.10.17, 3.11.12, 3.12.10] + include: + - runs-on: macos-latest + c-compiler: "clang" + cxx-compiler: "clang++" + initial-dashboard-cache: "CMAKE_OSX_DEPLOYMENT_TARGET:STRING=10.13" + + name: python-${{ matrix.python-version }}-${{ matrix.runs-on }} + steps: + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + with: + fetch-depth: 0 + path: src + + - name: Setup cmake + uses: jwlawson/actions-setup-cmake@3a6cbe35ba64df7ca70c51365c4aff65db9a9037 # v2.1.1 + with: + cmake-version: 3.20.6 + + - name: Setup ninja + uses: ashutoshvarma/setup-ninja@66ad2db9ed7d211c065daeeb849e9c8c895773c9 # master + with: + version: 1.10.0 + + - name: Download dashboard script + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + with: + repository: 'python-cmake-buildsystem/python-cmake-buildsystem' + ref: dashboard + fetch-depth: 0 + path: scripts + + - name: Writing initial dashboard cache + shell: bash + run: | + cat > scripts/initial-dashboard-cache.txt << EOF + ${{ matrix.initial-dashboard-cache }} + EOF + cat scripts/initial-dashboard-cache.txt + + - name: Build & Test + run: ctest --timeout 360 -S scripts/github_actions_dashboard.cmake -VV + env: + PY_VERSION: ${{ matrix.python-version }} + CC: ${{ matrix.c-compiler }} + CXX: ${{ matrix.cxx-compiler }} + + pass: # This job does nothing and is only used for the branch protection + if: always() + needs: + - tests + + runs-on: ubuntu-latest + + steps: + - name: Decide whether the needed jobs succeeded or failed + uses: re-actors/alls-green@2765efec08f0fd63e83ad900f5fd75646be69ff6 # v1.2.2 + with: + jobs: ${{ toJSON(needs) }} diff --git a/third/python-cmake/.gitignore b/third/python-cmake/.gitignore new file mode 100644 index 00000000..42569f02 --- /dev/null +++ b/third/python-cmake/.gitignore @@ -0,0 +1,45 @@ +# Ignore in source build files and directories ... +/cmake_install.cmake +/CMakeBuild +/CMakeCache.txt +/CMakeFiles +/CTestTestfile.cmake +/DartConfiguration.tcl +/install_manifest.txt +Makefile + +/bin +/lib +/Misc/ +/share/ + +# Ignore all dotfiles... +.* +!.git-blame-ignore-revs +!.gitattributes +!.circleci +!.github/ + +# Ignore all back-up files... +*~ +*.bak + +# except for .gitignore +!.gitignore + +# Exclude QtCreator files +CMakeLists.txt.user* + +# Ignore ctags file +tags + +# Ignore pyc files +*.pyc + +# Ignore Python source directories +cython-*/ +Python-*/ + +# Ignore Python source archives +Python-*.tgz +Python-*.zip diff --git a/third/python-cmake/CMakeLists.txt b/third/python-cmake/CMakeLists.txt new file mode 100644 index 00000000..730e0fa2 --- /dev/null +++ b/third/python-cmake/CMakeLists.txt @@ -0,0 +1,939 @@ +cmake_minimum_required(VERSION 3.20.6) + +set(PYTHON_VERSION "3.12.10" CACHE STRING "The version of Python to build.") + +string(REPLACE "." ";" VERSION_LIST ${PYTHON_VERSION}) +list(GET VERSION_LIST 0 PY_VERSION_MAJOR) +list(GET VERSION_LIST 1 PY_VERSION_MINOR) +list(GET VERSION_LIST 2 PY_VERSION_PATCH) +set(PY_VERSION "${PY_VERSION_MAJOR}.${PY_VERSION_MINOR}.${PY_VERSION_PATCH}") + +if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) + set(CMAKE_CONFIGURATION_TYPES Release CACHE STRING "Release configuration" FORCE) + set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build." FORCE) + # Set the possible values of build type for cmake-gui + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Release") +endif() + +if(APPLE) + set(_msg "Checking which MACOSX_DEPLOYMENT_TARGET to use") + message(STATUS "${_msg}") + include(cmake/PythonAutoDetectOSX.cmake) + set(MACOSX_DEPLOYMENT_TARGET ${CMAKE_OSX_DEPLOYMENT_TARGET}) + message(STATUS "${_msg} - ${MACOSX_DEPLOYMENT_TARGET}") +endif() + +project(Python C ASM) + +if(NOT DEFINED CMAKE_MACOSX_RPATH) + set(CMAKE_MACOSX_RPATH "") +endif() +if(NOT DEFINED CMAKE_BUILD_WITH_INSTALL_NAME_DIR) + set(CMAKE_BUILD_WITH_INSTALL_NAME_DIR ON) +endif() + +# Include helper functions +include(cmake/Extensions.cmake) +include(CMakeDependentOption) +include(CMakeParseArguments) +include(CTest) + +# Options +option(DOWNLOAD_SOURCES "Automatically download the Python sources" ON) +set(_build_libpython_shared_default 0) +set(_build_libpython_shared_desc "Build libpython as a shared library") + +if(DEFINED BUILD_SHARED OR DEFINED BUILD_STATIC) + message(AUTHOR_WARNING "Deprecated options `BUILD_SHARED` or `BUILD_STATIC` are set, " + "please change configure options to use `BUILD_LIBPYTHON_SHARED` instead.") + if(BUILD_SHARED AND BUILD_STATIC) + message(AUTHOR_WARNING "Both BUILD_SHARED and BUILD_STATIC options are set to ON. Forcing BUILD_SHARED to OFF") + endif() + if(BUILD_STATIC) + set(_build_libpython_shared_default 0) + set(_build_libpython_shared_desc "Intialized from `BUILD_STATIC` (deprecated)") + elseif(BUILD_SHARED) + set(_build_libpython_shared_default 1) + set(_build_libpython_shared_desc "Intialized from `BUILD_SHARED` (deprecated)") + endif() + message(AUTHOR_WARNING "Unsetting cache variables BUILD_SHARED and BUILD_STATIC") + unset(BUILD_SHARED CACHE) + unset(BUILD_STATIC CACHE) +endif() + +option(BUILD_LIBPYTHON_SHARED ${_build_libpython_shared_desc} ${_build_libpython_shared_default}) +option(BUILD_EXTENSIONS_AS_BUILTIN "Default all modules as builtin to libpython" OFF) +option(USE_LIB64 "Search for dependencies and install to prefix/lib64 instead of prefix/lib" OFF) +if(WIN32) + option(INSTALL_WINDOWS_TRADITIONAL "Install the executable and extensions in the traditional location" OFF) +else() + set(INSTALL_WINDOWS_TRADITIONAL OFF) +endif() + +if(WIN32 AND PY_VERSION VERSION_GREATER_EQUAL "3.10") + if(DEFINED BUILD_WININST) + message(AUTHOR_WARNING "BUILD_WININST option is *NOT* supported with Python >= 3.10. Current version is ${PY_VERSION}") + message(AUTHOR_WARNING "Unsetting cache variable BUILD_WININST") + unset(BUILD_WININST CACHE) + endif() + if(DEFINED BUILD_WININST_ALWAYS) + message(AUTHOR_WARNING "BUILD_WININST_ALWAYS option is *NOT* supported with Python >= 3.10. Current version is ${PY_VERSION}") + message(AUTHOR_WARNING "Unsetting cache variable BUILD_WININST_ALWAYS") + unset(BUILD_WININST_ALWAYS CACHE) + endif() +endif() + +if(WIN32 AND PY_VERSION VERSION_LESS "3.10") + set(_build_wininst_default ON) + if(CMAKE_CROSSCOMPILING) + set(_build_wininst_default OFF) + endif() + option(BUILD_WININST "Build 'Windows Installer' program for distutils if not already provided in the source tree." ${_build_wininst_default}) + cmake_dependent_option(BUILD_WININST_ALWAYS "Always build 'Windows installer' program even if provided in the source tree." OFF "BUILD_WININST" OFF) +else() + set(BUILD_WININST OFF) + set(BUILD_WININST_ALWAYS OFF) +endif() + +option(INSTALL_DEVELOPMENT "Install files required to develop C extensions" ON) +option(INSTALL_MANUAL "Install man files" ON) +option(INSTALL_TEST "Install test files" ON) + +# Append an item to a string if it does not already contain it. Any additional +# arguments are treated as extra "set" arguments +macro(append_if_absent VARNAME VALUE) + if(NOT ${VARNAME} MATCHES "(^| )${VALUE}($| )") + if(${VARNAME}) + set(${VARNAME} "${${VARNAME}} ${VALUE}" ${ARGN}) + else() + set(${VARNAME} "${VALUE}" ${ARGN}) + endif() + endif() +endmacro() + +option(USE_SYSTEM_LIBRARIES "Use system libraries" ON) + +# Set platform dependent defaults +set(_use_builtin_zlib_default OFF) +set(_use_system_zlib_default ON) +if(WIN32 AND "${PY_VERSION}" VERSION_LESS "3.7.0") + set(_use_builtin_zlib_default ON) + set(_use_system_zlib_default OFF) +endif() + +cmake_dependent_option(USE_SYSTEM_BZip2 "Use system BZip2" ON "USE_SYSTEM_LIBRARIES" OFF) +cmake_dependent_option(USE_SYSTEM_Curses "Use system Curses" ON "USE_SYSTEM_LIBRARIES" OFF) +cmake_dependent_option(USE_SYSTEM_EXPAT "Use system EXPAT" ON "USE_SYSTEM_LIBRARIES" OFF) +cmake_dependent_option(USE_SYSTEM_LibFFI "Use system LibFFI" ON "USE_SYSTEM_LIBRARIES" OFF) +cmake_dependent_option(USE_SYSTEM_OpenSSL "Use system OpenSSL" ON "USE_SYSTEM_LIBRARIES" OFF) +cmake_dependent_option(USE_SYSTEM_TCL "Use system TCL" ON "USE_SYSTEM_LIBRARIES" OFF) +cmake_dependent_option(USE_SYSTEM_ZLIB "Use system ZLIB" ${_use_system_zlib_default} "USE_SYSTEM_LIBRARIES" OFF) +cmake_dependent_option(USE_SYSTEM_GDBM "Use system GDBM" ON "USE_SYSTEM_LIBRARIES" OFF) +cmake_dependent_option(USE_SYSTEM_READLINE "Use system READLINE" ON "USE_SYSTEM_LIBRARIES" OFF) +cmake_dependent_option(USE_SYSTEM_SQLite3 "Use system SQLITE3" ON "USE_SYSTEM_LIBRARIES" OFF) +cmake_dependent_option(USE_SYSTEM_LIBMPDEC "Use system LIBMPDEC" OFF "USE_SYSTEM_LIBRARIES" OFF) + +cmake_dependent_option(USE_BUILTIN_ZLIB "Use builtin ZLIB" ${_use_builtin_zlib_default} "NOT USE_SYSTEM_ZLIB" OFF) + +option(USE_LIBEDIT "Use libedit instead of readline" OFF) + +option(WITH_TSC "profile with the Pentium timestamp counter" OFF) +option(ENABLE_IPV6 "Enable IP v6" ON) +option(WITH_DOC_STRINGS "Enable if you want documentation strings in extension modules" ON) +set(Py_DEBUG OFF) # TODO - Build debugging interpreter +option(WITH_PYMALLOC "Define if you want to compile in Python-specific mallocs" ON) +if(UNIX) + option(WITH_STATIC_DEPENDENCIES "Restrict extensions and external dependencies to static libraries" OFF) + if(WITH_STATIC_DEPENDENCIES) + set(_reason " because of WITH_STATIC_DEPENDENCIES=ON") + + set(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_STATIC_LIBRARY_SUFFIX}) + message(STATUS "Setting CMAKE_FIND_LIBRARY_SUFFIXES to \"${CMAKE_STATIC_LIBRARY_SUFFIX}\"${_reason}") + + set(BUILD_EXTENSIONS_AS_BUILTIN ON CACHE BOOL "Forced to ON${_reason}" FORCE) + message(STATUS "Setting BUILD_EXTENSIONS_AS_BUILTIN to ON${_reason}") + + set(BUILD_LIBPYTHON_SHARED OFF CACHE BOOL "Forced to OFF${_reason}" FORCE) + message(STATUS "Setting BUILD_LIBPYTHON_SHARED to OFF${_reason}") + + append_if_absent(CMAKE_EXE_LINKER_FLAGS "-static") + message(STATUS "Appending -static to CMAKE_EXE_LINKER_FLAGS${_reason}") + endif() +else() + set(WITH_STATIC_DEPENDENCIES 0) +endif() + +# Detect source directory +set(_landmark "pyconfig.h.in") # CMake will look for this file. +if(NOT (SRC_DIR AND EXISTS ${SRC_DIR}/${_landmark})) + foreach(dirname + ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/cpython-${PY_VERSION} + ${CMAKE_CURRENT_SOURCE_DIR}/Python-${PY_VERSION} + ${CMAKE_CURRENT_BINARY_DIR}/../cpython-${PY_VERSION} + ${CMAKE_CURRENT_BINARY_DIR}/../Python-${PY_VERSION}) + set(SRC_DIR ${dirname}) + if(EXISTS ${SRC_DIR}/${_landmark}) + break() + endif() + endforeach() +endif() + +# Download sources +get_filename_component(_parent_dir ${CMAKE_CURRENT_BINARY_DIR} PATH) +string(REGEX REPLACE "[a-z]+[1-9]$" "" _py_version_patch_no_rc ${PY_VERSION_PATCH}) +set(_py_version_no_rc "${PY_VERSION_MAJOR}.${PY_VERSION_MINOR}.${_py_version_patch_no_rc}") +set(_download_link "https://www.python.org/ftp/python/${_py_version_no_rc}/Python-${PY_VERSION}.tgz") +# Variable below represent the set of available python version. +# 3.5.x +set(_download_3.5.1_md5 "be78e48cdfc1a7ad90efff146dce6cfe") +set(_download_3.5.2_md5 "3fe8434643a78630c61c6464fe2e7e72") +set(_download_3.5.3_md5 "6192f0e45f02575590760e68c621a488") +set(_download_3.5.4_md5 "2ed4802b7a2a7e40d2e797272bf388ec") +set(_download_3.5.5_md5 "7c825b747d25c11e669e99b912398585") +set(_download_3.5.6_md5 "99a7e803633a627b264a42ce976d8c19") +set(_download_3.5.7_md5 "92f4c16c55429bf986f5ab45fe3a6659") +set(_download_3.5.8_md5 "c52ac1fc37e5daebb08069ea0e27d293") +set(_download_3.5.9_md5 "5a58675043bde569d235f41dadeada42") +set(_download_3.5.10_md5 "01a2d18075243bef5ef3363f62bf3247") +# 3.6.x +set(_download_3.6.0_md5 "3f7062ccf8be76491884d0e47ac8b251") +set(_download_3.6.1_md5 "2d0fc9f3a5940707590e07f03ecb08b9") +set(_download_3.6.2_md5 "e1a36bfffdd1d3a780b1825daf16e56c") +set(_download_3.6.3_md5 "e9180c69ed9a878a4a8a3ab221e32fa9") +set(_download_3.6.4_md5 "9de6494314ea199e3633211696735f65") +set(_download_3.6.5_md5 "ab25d24b1f8cc4990ade979f6dc37883") +set(_download_3.6.6_md5 "9a080a86e1a8d85e45eee4b1cd0a18a2") +set(_download_3.6.7_md5 "c83551d83bf015134b4b2249213f3f85") +set(_download_3.6.8_md5 "48f393a04c2e66c77bfc114e589ec630") +set(_download_3.6.9_md5 "ff7cdaef4846c89c1ec0d7b709bbd54d") +set(_download_3.6.10_md5 "df5f494ef9fbb03a0264d1e9d406aada") +set(_download_3.6.11_md5 "74763db01ec961ff194eea9ccc001a80") +set(_download_3.6.12_md5 "00c3346f314072fcc810d4a51d06f04e") +set(_download_3.6.13_md5 "92fcbf417c691d42c47a3d82f9c255fd") +set(_download_3.6.14_md5 "54a320cffe046bbbe4321896d67bde2b") +set(_download_3.6.15_md5 "f9e6f91c754a604f4fc6f6c7683723fb") +# 3.7.x +set(_download_3.7.0_md5 "41b6595deb4147a1ed517a7d9a580271") +set(_download_3.7.1_md5 "99f78ecbfc766ea449c4d9e7eda19e83") +set(_download_3.7.2_md5 "02a75015f7cd845e27b85192bb0ca4cb") +set(_download_3.7.3_md5 "2ee10f25e3d1b14215d56c3882486fcf") +set(_download_3.7.4_md5 "68111671e5b2db4aef7b9ab01bf0f9be") +set(_download_3.7.5_md5 "1cd071f78ff6d9c7524c95303a3057aa") +set(_download_3.7.6_md5 "3ef90f064506dd85b4b4ab87a7a83d44") +set(_download_3.7.7_md5 "d348d978a5387512fbc7d7d52dd3a5ef") +set(_download_3.7.8_md5 "4d5b16e8c15be38eb0f4b8f04eb68cd0") +set(_download_3.7.9_md5 "bcd9f22cf531efc6f06ca6b9b2919bd4") +set(_download_3.7.10_md5 "0b19e34a6dabc4bf15fdcdf9e77e9856") +set(_download_3.7.11_md5 "a7e66953dba909d395755b3f2e491f6e") +set(_download_3.7.12_md5 "6fe83678c085a7735a943cf1e4d41c14") +set(_download_3.7.13_md5 "e0d3321026d4a5f3a3890b5d821ad762") +set(_download_3.7.14_md5 "dd65d6708e9c28a9e4fd2e986776ad14") +set(_download_3.7.15_md5 "beff0cd66129ad1761632aafd72ac866") +set(_download_3.7.16_md5 "f21656b51c9907fc6993b64ef216d994") +set(_download_3.7.17_md5 "19726591b0fb1a9658de68955fa8392a") +# 3.8.x +set(_download_3.8.0_md5 "e18a9d1a0a6d858b9787e03fc6fdaa20") +set(_download_3.8.1_md5 "f215fa2f55a78de739c1787ec56b2bcd") +set(_download_3.8.2_md5 "f9f3768f757e34b342dbc06b41cbc844") +set(_download_3.8.3_md5 "a7c10a2ac9d62de75a0ca5204e2e7d07") +set(_download_3.8.4_md5 "387e63fe42c40a29e3408ce231315516") +set(_download_3.8.5_md5 "e2f52bcf531c8cc94732c0b6ff933ff0") +set(_download_3.8.6_md5 "ea132d6f449766623eee886966c7d41f") +set(_download_3.8.7_md5 "e1f40f4fc9ccc781fcbf8d4e86c46660") +set(_download_3.8.8_md5 "d3af3b87e134c01c7f054205703adda2") +set(_download_3.8.9_md5 "41a5eaa15818cee7ea59e578564a2629") +set(_download_3.8.10_md5 "83d71c304acab6c678e86e239b42fa7e") +set(_download_3.8.11_md5 "f22ef46ebf8d15d8e495a237277bf2fa") +set(_download_3.8.12_md5 "f7890dd43302daa5fcb7b0254b4d0f33") +set(_download_3.8.13_md5 "3c49180c6b43df3519849b7e390af0b9") +set(_download_3.8.14_md5 "a82168eb586e19122b747b84038825f2") +set(_download_3.8.15_md5 "28b111e1e97a9e5acb62e1d153f188d9") +set(_download_3.8.16_md5 "060040f864f1003b849b33393c9605df") +set(_download_3.8.17_md5 "d3e789ab828016927a122a0ae9b0e6b0") +set(_download_3.8.18_md5 "1c611d70ba4d0ec32da3a364490fc6f4") +set(_download_3.8.19_md5 "5e3188ce73865fa4545d9e3e89bcd26c") +set(_download_3.8.20_md5 "7e0ff9088be5a3c2fd9b7d8b4b632b5e") +# 3.9.x +set(_download_3.9.0_md5 "e19e75ec81dd04de27797bf3f9d918fd") +set(_download_3.9.1_md5 "429ae95d24227f8fa1560684fad6fca7") +set(_download_3.9.2_md5 "8cf053206beeca72c7ee531817dc24c7") +# 3.9.3: This release has been recalled. See https://www.python.org/downloads/release/python-393/ +set(_download_3.9.4_md5 "cc8507b3799ed4d8baa7534cd8d5b35f") +set(_download_3.9.5_md5 "364158b3113cf8ac8db7868ce40ebc7b") +set(_download_3.9.6_md5 "798b9d3e866e1906f6e32203c4c560fa") +set(_download_3.9.7_md5 "5f463f30b1fdcb545f156583630318b3") +set(_download_3.9.8_md5 "83419bd73655813223c2cf2afb11f83c") +set(_download_3.9.9_md5 "a2da2a456c078db131734ff62de10ed5") +set(_download_3.9.10_md5 "1440acb71471e2394befdb30b1a958d1") +set(_download_3.9.11_md5 "daca49063ced330eb933a0fb437dee50") +set(_download_3.9.12_md5 "abc7f7f83ea8614800b73c45cf3262d3") +set(_download_3.9.13_md5 "eafda83543bad127cadef4d288fdab87") +set(_download_3.9.14_md5 "324a9dcaaa11b2b0dafe5614e8f01145") +set(_download_3.9.15_md5 "3e13283a5f4e089db508bf81b60a5cca") +set(_download_3.9.16_md5 "38c99c7313f416dcf3238f5cf444c6c2") +set(_download_3.9.17_md5 "ded6379983f364cf790793ca24dcfe3e") +set(_download_3.9.18_md5 "c3a3e67e35838cadca247237a5a279a7") +set(_download_3.9.19_md5 "b4d723903d0a8266b110c3da2f992416") +set(_download_3.9.20_md5 "896c19e5815ba990a3d1261502ea9f83") +set(_download_3.9.21_md5 "e61b3568082b57d55fd74cfc7ca020b4") +set(_download_3.9.22_md5 "8fe76e248a0e149ac23e8e4886397475") +# 3.10.x +set(_download_3.10.0_md5 "729e36388ae9a832b01cf9138921b383") +set(_download_3.10.1_md5 "91822157a97da16203877400c810d93e") +set(_download_3.10.2_md5 "67c92270be6701f4a6fed57c4530139b") +set(_download_3.10.3_md5 "f276ffcd05bccafe46da023d0a5bb04a") +set(_download_3.10.4_md5 "7011fa5e61dc467ac9a98c3d62cfe2be") +set(_download_3.10.5_md5 "d87193c077541e22f892ff1353fac76c") +set(_download_3.10.6_md5 "d76638ca8bf57e44ef0841d2cde557a0") +set(_download_3.10.7_md5 "1aea68575c0e97bc83ff8225977b0d46") +set(_download_3.10.8_md5 "fbe3fff11893916ad1756b15c8a48834") +set(_download_3.10.9_md5 "25eb3686327c157dcb8ac9f01105c306") +set(_download_3.10.10_md5 "6dbe644dd1a520d9853cf6648084c346") +set(_download_3.10.11_md5 "7e25e2f158b1259e271a45a249cb24bb") +set(_download_3.10.12_md5 "1d64320e0b0df6e9ab7e611bacb2178d") +set(_download_3.10.13_md5 "cbcad7f5e759176bf8ce8a5f9d487087") +set(_download_3.10.14_md5 "f67d78c8323a18fe6b945914c51a7aa6") +set(_download_3.10.15_md5 "b6a2b570ea75ef55f50bfe79d778eb01") +set(_download_3.10.16_md5 "2515d8571c6fdd7fc620aa9e1cc6d202") +set(_download_3.10.17_md5 "763324aa2b396ee10a51bfa6c645d8e9") +# 3.11.x +set(_download_3.11.0_md5 "c5f77f1ea256dc5bdb0897eeb4d35bb0") +set(_download_3.11.1_md5 "5c986b2865979b393aa50a31c65b64e8") +set(_download_3.11.2_md5 "f6b5226ccba5ae1ca9376aaba0b0f673") +set(_download_3.11.3_md5 "016ba65bc80411f9ec20c614ab385e81") +set(_download_3.11.4_md5 "bf6ec50f2f3bfa6ffbdb385286f2c628") +set(_download_3.11.5_md5 "b628f21aae5e2c3006a12380905bb640") +set(_download_3.11.6_md5 "ed23dadb9f1b9fd2e4e7d78619685c79") +set(_download_3.11.7_md5 "ef61f81ec82c490484219c7f0ec96783") +set(_download_3.11.8_md5 "7fb0bfaa2f6aae4aadcdb51abe957825") +set(_download_3.11.9_md5 "bfd4d3bfeac4216ce35d7a503bf02d5c") +set(_download_3.11.10_md5 "35c36069a43dd57a7e9915deba0f864e") +set(_download_3.11.11_md5 "9a5b43fcc06810b8ae924b0a080e6569") +set(_download_3.11.12_md5 "b8bb496014f05f5be180fab74810f40b") +# 3.12.x +set(_download_3.12.0_md5 "d6eda3e1399cef5dfde7c4f319b0596c") +set(_download_3.12.1_md5 "51c5c22dcbc698483734dff5c8028606") +set(_download_3.12.2_md5 "4e64a004f8ad9af1a75607cfd0d5a8c8") +set(_download_3.12.3_md5 "3c5498a34d5226c9b746b1199f0bf2d9") +set(_download_3.12.4_md5 "ead819dab6d165937138daa9e51ccb54") +set(_download_3.12.5_md5 "d23d56b51d36a9d51b2b13d30c849d00") +set(_download_3.12.6_md5 "c2f1dd5c8807ee50b778684b7958ee28") +set(_download_3.12.7_md5 "5d0c0e4c6a022a87165a9addcd869109") +set(_download_3.12.8_md5 "304473cf367fa65e450edf4b06b55fcc") +set(_download_3.12.9_md5 "ce613c72fa9b32fb4f109762d61b249b") +set(_download_3.12.10_md5 "35c03f014408e26e2b06d576c19cac54") + +set(_extracted_dir "Python-${PY_VERSION}") + +if(NOT EXISTS ${SRC_DIR}/${_landmark} AND DOWNLOAD_SOURCES) + get_filename_component(_filename ${_download_link} NAME) + set(_archive_filepath ${CMAKE_CURRENT_BINARY_DIR}/../${_filename}) + if(EXISTS "${_archive_filepath}") + message(STATUS "${_filename} already downloaded") + else() + message(STATUS "Downloading ${_download_link}") + if(NOT DEFINED _download_${PY_VERSION}_md5) + message(FATAL_ERROR "Selected PY_VERSION [${PY_VERSION}] is not associated with any checksum. Consider updating this CMakeLists.txt setting _download_${PY_VERSION}_md5 variable") + endif() + file( + DOWNLOAD ${_download_link} ${_archive_filepath} + EXPECTED_MD5 ${_download_${PY_VERSION}_md5} + SHOW_PROGRESS + ) + endif() + + message(STATUS "Extracting ${_filename}") + execute_process(COMMAND ${CMAKE_COMMAND} -E tar xfz ${_archive_filepath} + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/.. + RESULT_VARIABLE rv) + if(NOT rv EQUAL 0) + message(FATAL_ERROR "error: extraction of '${_filename}' failed") + endif() + set(SRC_DIR ${CMAKE_CURRENT_BINARY_DIR}/../${_extracted_dir}) +endif() + +get_filename_component(SRC_DIR "${SRC_DIR}" ABSOLUTE) +if(NOT EXISTS ${SRC_DIR}/${_landmark}) + message(FATAL_ERROR "Failed to locate python source. +The searched locations were: + + /cpython-${PY_VERSION} + /Python-${PY_VERSION} + /../cpython-${PY_VERSION} + /../Python-${PY_VERSION} + +You could try to: + 1) download ${_download_link} + 2) extract the archive in folder: ${_parent_dir} + 3) Check that file \"${_parent_dir}/${_extracted_dir}/${_landmark}\" exists. + 4) re-configure. +If you already downloaded the source, you could try to re-configure this project passing -DSRC_DIR:PATH=/path/to/Python-{PY_VERSION} using cmake or adding an PATH entry named SRC_DIR from cmake-gui.") +endif() +message(STATUS "SRC_DIR: ${SRC_DIR}") + +# Extract version string from python source (Copied from FindPythonLibs.cmake) +file(STRINGS "${SRC_DIR}/Include/patchlevel.h" python_version_str + REGEX "^#define[ \t]+PY_VERSION[ \t]+\"[^\"]+\"") +string(REGEX REPLACE "^#define[ \t]+PY_VERSION[ \t]+\"([^\"]+)\".*" "\\1" + PY_VERSION_LONG "${python_version_str}") + +# Extract version info and set variables PY_VERSION, PY_VERSION_(MAJOR|MINOR|PATCH), PY_RELEASE_(LEVEL|SERIAL) +include(cmake/PythonExtractVersionInfo.cmake) +python_extract_version_info( + VERSION_STRING "${PY_VERSION_LONG}" + ) +message(STATUS "PY_VERSION : ${PY_VERSION}") +message(STATUS "PY_VERSION_LONG: ${PY_VERSION_LONG}") + +# Extract "Field3" value and set variable PY_FIELD3_VALUE +python_compute_release_field3_value( + VERSION_PATCH "${PY_VERSION_PATCH}" + RELEASE_LEVEL "${PY_RELEASE_LEVEL}" + RELEASE_SERIAL "${PY_RELEASE_SERIAL}" +) +message(STATUS "PY_FIELD3_VALUE: ${PY_FIELD3_VALUE}") + +# Check version +if(NOT DEFINED _download_${PY_VERSION_LONG}_md5) + message(WARNING "warning: selected python version '${PY_VERSION_LONG}' is not tested.") +endif() +if(NOT "${PYTHON_VERSION}" STREQUAL "${PY_VERSION}") + message(STATUS "Overwriting PYTHON_VERSION with value read from 'patchlevel.h': ${PYTHON_VERSION} -> ${PY_VERSION}") + set(PYTHON_VERSION "${PY_VERSION}" CACHE STRING "The version of Python to build." FORCE) +endif() + +# Apply patches +option(PYTHON_APPLY_PATCHES "Apply patches" ON) +if(PYTHON_APPLY_PATCHES) + include(cmake/PythonApplyPatches.cmake) +endif() + +# Enable CXX language to support building of _distutils_findvs extension +if(WIN32) + enable_language(CXX) +endif() + +# Options depending of the python version + if(DEFINED USE_SYSTEM_DB) + message(AUTHOR_WARNING "USE_SYSTEM_DB option is *NOT* supported with Python 3. Current version is ${PY_VERSION}") + endif() + + if(DEFINED Py_USING_UNICODE) + message(AUTHOR_WARNING "Py_USING_UNICODE option is *NOT* supported with Python 3. Current version is ${PY_VERSION}") + endif() + +if(PY_VERSION VERSION_GREATER_EQUAL "3.7") + option(WITH_C_LOCALE_COERCION "Enable C locale coercion to a UTF-8 based locale" ON) +else() + if(DEFINED WITH_C_LOCALE_COERCION) + message(AUTHOR_WARNING "WITH_C_LOCALE_COERCION option is *NOT* supported with Python < 3.7. Current version is ${PY_VERSION}") + endif() +endif() + +# See "Improving performance in Python 2.7" - http://lwn.net/Articles/646888/ +option(WITH_COMPUTED_GOTOS "Improve performance enabling the computed goto based dispatch" OFF) +set(USE_COMPUTED_GOTOS ${WITH_COMPUTED_GOTOS}) + +set(WITH_HASH_ALGORITHM "default" CACHE STRING "Define hash algorithm for str, bytes and memoryview.") +set_property(CACHE WITH_HASH_ALGORITHM PROPERTY STRINGS "default" "siphash24" "fnv") + +if(PY_VERSION VERSION_LESS "3.7") + option(WITH_THREAD "Compile in rudimentary thread support" ON) +else() + if(DEFINED WITH_THREAD) + message(AUTHOR_WARNING "WITH_THREAD option is *NOT* supported. Threading is always built-in with Python >= 3.7. Current version is ${PY_VERSION}") + endif() +endif() + +if(PY_VERSION VERSION_GREATER_EQUAL "3.10") + option(WITH_VALGRIND "Enable to disable pymalloc when running under valgrind" OFF) +else() + if(DEFINED WITH_VALGRIND) + message(AUTHOR_WARNING "WITH_VALGRIND option is *NOT* supported with Python < 3.10. Current version is ${PY_VERSION}") + endif() +endif() + +if(PY_VERSION VERSION_GREATER_EQUAL "3.7") +set(WITH_SSL_DEFAULT_SUITES "python" CACHE STRING "Override default cipher suites string: python, openssl or a custom string") +if("${WITH_SSL_DEFAULT_SUITES}" STREQUAL "python") + set(PY_SSL_DEFAULT_CIPHERS 1) +elseif("${WITH_SSL_DEFAULT_SUITES}" STREQUAL "openssl") + set(PY_SSL_DEFAULT_CIPHERS 2) +else() + set(PY_SSL_DEFAULT_CIPHERS 0) + set(PY_SSL_DEFAULT_CIPHER_STRING "${WITH_SSL_DEFAULT_SUITES}") +endif() +message(STATUS "Setting PY_SSL_DEFAULT_CIPHER_STRING to '${WITH_SSL_DEFAULT_SUITES}'") +endif() + +if(PY_VERSION VERSION_GREATER_EQUAL "3.8") + option(WITH_DECIMAL_CONTEXTVAR "Build _decimal module using a coroutine-local rather than a thread-local context" ON) +else() + if(DEFINED WITH_DECIMAL_CONTEXTVAR) + message(AUTHOR_WARNING "WITH_DECIMAL_CONTEXTVAR option is *NOT* supported with Python < 3.8. Current version is ${PY_VERSION}") + endif() +endif() + +if(PY_VERSION VERSION_GREATER_EQUAL "3.8") + option(WITH_TRACE_REFS "Enable tracing references for debugging purpose" OFF) +else() + if(DEFINED WITH_TRACE_REFS) + message(AUTHOR_WARNING "WITH_TRACE_REFS option is *NOT* supported with Python < 3.8. Current version is ${PY_VERSION}") + endif() +endif() + +# This is the major version number of Python +set(LIBPYTHON_VERSION ${PY_VERSION_MAJOR}.${PY_VERSION_MINOR}) +if(WIN32) + set(LIBPYTHON_VERSION ${PY_VERSION_MAJOR}${PY_VERSION_MINOR}) +endif() +set(LIBPYTHON python${LIBPYTHON_VERSION}) + +# Proceed to the configure checks +include(cmake/ConfigureChecks.cmake) + +# Set PYTHONHOME +set(LIBDIR "Lib") # See Lib/distutils/sysconfig.py - function 'get_python_lib' +if(UNIX) + set(LIBDIR "lib") +endif() +if(USE_LIB64) + set_property(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS ON) + set(LIBDIR "lib64") +endif() +set(PYTHONHOME "${LIBDIR}") +if(UNIX) + set(PYTHONHOME "${PYTHONHOME}/${LIBPYTHON}") +endif() + +# Install tree directory +set(BIN_INSTALL_DIR bin) # Contains the python executable +if(INSTALL_WINDOWS_TRADITIONAL) + set(BIN_INSTALL_DIR .) # Contains the python executable +endif() +set(LD_VERSION ${LIBPYTHON_VERSION}${ABIFLAGS}) +set(CONFIG_INSTALL_DIR share/${LIBPYTHON}) +set(EXTENSION_INSTALL_DIR ${PYTHONHOME}/lib-dynload) + +if (${LIBPYTHON_VERSION} GREATER 3.1) + set(LIB_CONFIG_INSTALL_DIR ${PYTHONHOME}/config-${LD_VERSION}) +else() + set(LIB_CONFIG_INSTALL_DIR ${PYTHONHOME}/config) +endif() + +if(INSTALL_WINDOWS_TRADITIONAL) + set(EXTENSION_INSTALL_DIR DLLs) +endif() +set(INCLUDE_INSTALL_DIR include/python${LD_VERSION}) +if(MSVC) + set(INCLUDE_INSTALL_DIR include) +endif() +# Build tree directory +set(BIN_BUILD_DIR ${PROJECT_BINARY_DIR}/bin) +set(CONFIG_BUILD_DIR ${PROJECT_BINARY_DIR}/${CONFIG_INSTALL_DIR}) +set(EXTENSION_BUILD_DIR ${PROJECT_BINARY_DIR}/${PYTHONHOME}/lib-dynload) +set(INCLUDE_BUILD_DIR ${SRC_DIR}/Include) + +set(ARCHIVEDIR "libs") # Contains the static (*.a) and import libraries (*.lib) + +# Directories specific to 'libpython' +set(LIBPYTHON_LIBDIR ${LIBDIR}) +set(LIBPYTHON_ARCHIVEDIR ${LIBDIR}) +set(LIBPYTHON_STATIC_ARCHIVEDIR ${LIBDIR}) +if(WIN32) + set(LIBPYTHON_LIBDIR ${BIN_INSTALL_DIR}) + set(LIBPYTHON_ARCHIVEDIR ${ARCHIVEDIR}) + set(LIBPYTHON_STATIC_ARCHIVEDIR static-${ARCHIVEDIR}) +endif() + +set(EXTRA_PYTHONPATH "" CACHE STRING + "A colon (:) separated list of extra paths to add to the PYTHONPATH") + +# Configure 'pyconfig.h' +if(UNIX) + set(PYCONFIG_BUILD_DIR ${BIN_BUILD_DIR}) + configure_file(cmake/config-unix/pyconfig.h.in + ${PYCONFIG_BUILD_DIR}/pyconfig.h) +elseif(WIN32) + set(PYCONFIG_BUILD_DIR ${SRC_DIR}/PC) # In a windows build tree, 'pyconfig.h' is NOT required to + # live along side the python executable. + # See function '_init_posix()' and '_init_non_posix()' + # in 'Lib/sysconfig.py' + if(MINGW) + set(PYCONFIG_BUILD_DIR cmake/config-mingw) + endif() +endif() + +# Install 'pyconfig.h' +if(INSTALL_DEVELOPMENT) + install(FILES ${PYCONFIG_BUILD_DIR}/pyconfig.h + DESTINATION ${INCLUDE_INSTALL_DIR}/ + COMPONENT Development) +endif() + +# Set include directories +include_directories(${INCLUDE_BUILD_DIR}) +include_directories(${INCLUDE_BUILD_DIR}/internal) +include_directories(${PYCONFIG_BUILD_DIR}) +include_directories(${SRC_DIR}/Python) +include_directories(${SRC_DIR}) # Introduced in Python 3.11 for "Python/frozen_modules/.h" + +# Set cflags used by all components +if(CMAKE_C_COMPILER_ID MATCHES GNU) + if(PY_VERSION VERSION_GREATER_EQUAL "3.11") + append_if_absent(CMAKE_C_FLAGS "-std=c11") + elseif(PY_VERSION VERSION_GREATER_EQUAL "3.6") + append_if_absent(CMAKE_C_FLAGS "-std=c99") + endif() + append_if_absent(CMAKE_C_FLAGS "-Wall") + append_if_absent(CMAKE_C_FLAGS "-Wstrict-prototypes") + append_if_absent(CMAKE_C_FLAGS "-fno-strict-aliasing") + append_if_absent(CMAKE_C_FLAGS "-fwrapv") + append_if_absent(CMAKE_C_FLAGS "-g") +elseif(CMAKE_C_COMPILER_ID MATCHES Clang) + append_if_absent(CMAKE_C_FLAGS "-Wall") + append_if_absent(CMAKE_C_FLAGS "-g") +elseif(CMAKE_C_COMPILER_ID MATCHES Intel) + append_if_absent(CMAKE_C_FLAGS "-Wall") + append_if_absent(CMAKE_C_FLAGS "-no-ansi-alias") +elseif(CMAKE_C_COMPILER_ID MATCHES PGI) + append_if_absent(CMAKE_C_FLAGS "-alias=traditional") +endif() + +if(MSVC) + append_if_absent(CMAKE_C_FLAGS "/Zm200") + string(REPLACE "/Ob2" "/Ob1" CMAKE_C_FLAGS_RELEASE ${CMAKE_C_FLAGS_RELEASE}) # InlineFunctionExpansion=1 + set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}" CACHE STRING "Flags used by the compiler during release builds" FORCE) +endif() + +# Useful additional variables that extensions can use. +if(CMAKE_SYSTEM MATCHES Linux) + set(LINUX ON) +else() + set(LINUX OFF) +endif() + +# Clear PythonTargets.cmake +file(WRITE ${CONFIG_BUILD_DIR}/PythonTargets.cmake "") + +# Define python executable wrapper command to ensure +# python executable resolves the expected python library. +set(PYTHON_WRAPPER_COMMAND ) +if(BUILD_LIBPYTHON_SHARED AND UNIX) + set(_envvar LD_LIBRARY_PATH) + if(APPLE) + set(_envvar DYLD_LIBRARY_PATH) + endif() + set(PYTHON_WRAPPER_COMMAND env ${_envvar}=${PROJECT_BINARY_DIR}/${LIBPYTHON_LIBDIR}) +endif() + +# Add extension modules +set(extensions_enabled "" CACHE INTERNAL "" FORCE) +set(extensions_disabled "" CACHE INTERNAL "" FORCE) +add_subdirectory(cmake/extensions CMakeBuild/extensions) + +# Add the other subdirectories +add_subdirectory(cmake/libpython CMakeBuild/libpython) +add_subdirectory(cmake/python CMakeBuild/python) +add_subdirectory(cmake/include CMakeBuild/include) +add_subdirectory(cmake/lib CMakeBuild/lib) +add_subdirectory(cmake/tools CMakeBuild/tools) +if(BUILD_WININST) + add_subdirectory(cmake/PC/bdist_wininst CMakeBuild/bdist_wininst) +endif() +if(WIN32) + add_subdirectory(cmake/PC/launcher CMakeBuild/launcher) +endif() + +# Ensure the "_testcapi" extension introduced in Python 3.12 can find +# find "Python3.lib" as it is specified in "PC/pyconfig." using +# `pragma comment(lib,"python3.lib")`. +if(WIN32 AND TARGET extension_testcapi) + set(libpython_output_dir "${PROJECT_BINARY_DIR}/CMakeBuild/libpython/$") + target_link_directories(extension_testcapi PRIVATE ${libpython_output_dir}) + # Ensure import library is generated before linking the extension + add_dependencies(extension_testcapi libpython3-shared) +endif() + +# Add target to run "Argument Clinic" over all source files +add_custom_target(clinic + COMMAND python ${SRC_DIR}/Tools/clinic/clinic.py --make + DEPENDS python + WORKING_DIRECTORY ${SRC_DIR} + COMMENT "Running 'Argument Clinic' over all source files" + VERBATIM +) + +# Add target to generate 'Include/graminit.h' and 'Python/graminit.c' +if(PY_VERSION VERSION_GREATER_EQUAL "3.8") + set(generate_graminit_command python -m Parser.pgen) +else() + set(generate_graminit_command pgen) +endif() +add_custom_target(generate_graminit + COMMAND ${generate_graminit_command} + ${SRC_DIR}/Grammar/Grammar + $<$:${SRC_DIR}/Grammar/Tokens> + ${PROJECT_BINARY_DIR}/CMakeFiles/graminit.h + ${PROJECT_BINARY_DIR}/CMakeFiles/graminit.c + COMMAND ${CMAKE_COMMAND} -E copy_if_different + ${PROJECT_BINARY_DIR}/CMakeFiles/graminit.h + ${SRC_DIR}/Include/graminit.h + COMMAND ${CMAKE_COMMAND} -E copy_if_different + ${PROJECT_BINARY_DIR}/CMakeFiles/graminit.c + ${SRC_DIR}/Python/graminit.c + DEPENDS $,python,pgen> + WORKING_DIRECTORY ${PROJECT_BINARY_DIR} + COMMENT "Generating '${SRC_DIR}/Include/graminit.h' and '${SRC_DIR}/Python/graminit.c'." + VERBATIM +) + +if(PY_VERSION VERSION_GREATER_EQUAL "3.9") +# Add target to generate `Tools/peg_generator/pegen/grammar_parser.py` +add_custom_target(generate_pegen_metaparser + COMMAND ${CMAKE_COMMAND} -E env PYTHONPATH=${SRC_DIR}/Tools/peg_generator + ${CMAKE_CROSSCOMPILING_EMULATOR} $ -m pegen + -q python + ${SRC_DIR}/Tools/peg_generator/pegen/metagrammar.gram + -o ${PROJECT_BINARY_DIR}/CMakeFiles/grammar_parser.py + COMMAND ${CMAKE_COMMAND} -E copy_if_different + ${PROJECT_BINARY_DIR}/CMakeFiles/grammar_parser.py + ${SRC_DIR}/Tools/peg_generator/pegen/grammar_parser.py + DEPENDS python + WORKING_DIRECTORY ${PROJECT_BINARY_DIR} + COMMENT "Generating '${SRC_DIR}/Tools/peg_generator/pegen/grammar_parser.py'" + VERBATIM +) + +# Add target to generate `Parser/pegen/parse.c` +add_custom_target(generate_pegen_parse + COMMAND ${CMAKE_COMMAND} -E env PYTHONPATH=${SRC_DIR}/Tools/peg_generator + ${CMAKE_CROSSCOMPILING_EMULATOR} $ -m pegen + -q c + ${SRC_DIR}/Grammar/python.gram + ${SRC_DIR}/Grammar/Tokens + -o ${PROJECT_BINARY_DIR}/CMakeFiles/parse.c + COMMAND ${CMAKE_COMMAND} -E copy_if_different + ${PROJECT_BINARY_DIR}/CMakeFiles/parse.c + ${SRC_DIR}/Parser/pegen/parse.c + DEPENDS python + WORKING_DIRECTORY ${PROJECT_BINARY_DIR} + COMMENT "Generating '${SRC_DIR}/Parser/pegen/parse.c'" + VERBATIM +) +endif() + +# Add target to generate 'opcode.h' header file +add_custom_target(generate_opcode_h + COMMAND python ${SRC_DIR}/Tools/scripts/generate_opcode_h.py + ${SRC_DIR}/Lib/opcode.py + ${PROJECT_BINARY_DIR}/CMakeFiles/opcode.h + COMMAND ${CMAKE_COMMAND} -E copy_if_different + ${PROJECT_BINARY_DIR}/CMakeFiles/opcode.h + ${SRC_DIR}/Include/opcode.h + DEPENDS python + WORKING_DIRECTORY ${PROJECT_BINARY_DIR} + COMMENT "Generating '${SRC_DIR}/Include/opcode.h'." + VERBATIM +) + +# Add target to generate 'Include/Python-ast.h' from 'Python.asdl' +add_custom_target(generate_python_ast_h + COMMAND python ${SRC_DIR}/Parser/asdl_c.py + -h ${SRC_DIR}/Include + ${SRC_DIR}/Parser/Python.asdl + DEPENDS python + WORKING_DIRECTORY ${PROJECT_BINARY_DIR} + COMMENT "Generating '${SRC_DIR}/Include/Python-ast.h'" + VERBATIM +) + +# Add target to generate 'Python/Python-ast.c' from 'Python.asdl' +add_custom_target(generate_python_ast_c + COMMAND python ${SRC_DIR}/Parser/asdl_c.py + -c ${SRC_DIR}/Python + ${SRC_DIR}/Parser/Python.asdl + DEPENDS python + WORKING_DIRECTORY ${PROJECT_BINARY_DIR} + COMMENT "Generating '${SRC_DIR}/Python/Python-ast.c'" + VERBATIM +) + +# If needed, copy 'asdl.py' and 'Python.asdl' into build directory so that 'test_asdl_parser' passes. +set(_asdl_subdir ${LIBDIR}) +if(WIN32) + set(_asdl_subdir ) +endif() +file(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/${LIBDIR}/Parser) +configure_file( + ${SRC_DIR}/Parser/Python.asdl + ${PROJECT_BINARY_DIR}/${_asdl_subdir}/Parser/Python.asdl + COPYONLY +) +configure_file( + ${SRC_DIR}/Parser/asdl.py + ${PROJECT_BINARY_DIR}/${_asdl_subdir}/Parser/asdl.py + COPYONLY +) + +show_extension_summary() + +if(UNIX) + + # python.pc + configure_file(cmake/python.pc.in + ${PROJECT_BINARY_DIR}/Misc/python-${LIBPYTHON_VERSION}.pc @ONLY) + configure_file(cmake/python.pc.in + ${PROJECT_BINARY_DIR}/Misc/python-${PY_VERSION_MAJOR}.pc @ONLY) + configure_file(cmake/python.pc.in + ${PROJECT_BINARY_DIR}/Misc/python.pc @ONLY) + if(INSTALL_DEVELOPMENT) + install(FILES + ${PROJECT_BINARY_DIR}/Misc/python-${LIBPYTHON_VERSION}.pc + ${PROJECT_BINARY_DIR}/Misc/python-${PY_VERSION_MAJOR}.pc + ${PROJECT_BINARY_DIR}/Misc/python.pc + DESTINATION lib/pkgconfig + COMPONENT Development) + endif() + + # Makefile + set(MAKEFILE_LDSHARED_FLAGS "-shared") + if(APPLE) + set(MAKEFILE_LDSHARED_FLAGS "-dynamiclib -headerpad_max_install_names -undefined dynamic_lookup") + endif() + configure_file(cmake/makefile-variables.in + ${BIN_BUILD_DIR}/Makefile @ONLY) + if(INSTALL_DEVELOPMENT) + install(FILES ${BIN_BUILD_DIR}/Makefile + DESTINATION ${LIB_CONFIG_INSTALL_DIR} + RENAME Makefile + COMPONENT Development) + endif() + + # Utility scripts + if(INSTALL_DEVELOPMENT) + install(FILES ${SRC_DIR}/install-sh ${SRC_DIR}/Modules/makesetup + DESTINATION ${LIB_CONFIG_INSTALL_DIR} + COMPONENT Development) + endif() + + # Install manual + if(INSTALL_MANUAL) + set(_install_man FILES ${SRC_DIR}/Misc/python.man DESTINATION share/man/man1 COMPONENT Runtime) + install(${_install_man} RENAME python${LIBPYTHON_VERSION}.1) + install(${_install_man} RENAME python${PY_VERSION_MAJOR}.1) + endif() + +endif() + +# Create an empty lib-dynload folder, even if we don't have any extensions +# to go in there. bin/python uses this to auto-determine the exec_prefix +# and properly generate the _sysconfigdata.py +file(MAKE_DIRECTORY "${EXTENSION_BUILD_DIR}") +install(DIRECTORY DESTINATION ${EXTENSION_INSTALL_DIR}) + +if(BUILD_TESTING) + set(SUPPORTED_TEST_RESOURCES network) + message(STATUS "Supported test resources: ${SUPPORTED_TEST_RESOURCES}") + + list(JOIN SUPPORTED_TEST_RESOURCES "," regrtest_resources) + + set(TESTOPTS + # Command line option "-l/--findleaks" of regrtest is deprecated since Python 3.7 and + # removed in Python 3.11. It is superseded by --fail-env-changed. + $,--fail-env-changed,-l> + # Comma-separated list of words indicating the resources to test + -u ${regrtest_resources} + ) + set(TESTPROG ${PROJECT_BINARY_DIR}/${PYTHONHOME}/test/regrtest.py) + set(TESTPYTHONOPTS ) + set(TESTPYTHON $ ${TESTPYTHONOPTS}) + set(TESTPYTHON ${CMAKE_CROSSCOMPILING_EMULATOR} ${TESTPYTHON}) + include(cmake/UnitTests.cmake) + foreach(unittest ${unittests}) + set(EXTRATESTOPTS -v) + # XXX Running 'test_doctest' in verbose mode always return 1 + if(unittest STREQUAL "test_doctest") + set(EXTRATESTOPTS ) + endif() + add_test(NAME ${unittest} COMMAND ${PYTHON_WRAPPER_COMMAND} ${TESTPYTHON} ${TESTPROG} ${TESTOPTS} ${EXTRATESTOPTS} ${unittest}) + endforeach() + + function(add_cmakescript_test testname script) + add_test(cmake_${testname}_test ${CMAKE_COMMAND} + -DTEST_${testname}:BOOL=ON + -P ${PROJECT_SOURCE_DIR}/${script}) + set_tests_properties(cmake_${testname}_test PROPERTIES + LABELS CMake + PASS_REGULAR_EXPRESSION "SUCCESS") + endfunction() + add_cmakescript_test( + python_extract_version_info + cmake/PythonExtractVersionInfo.cmake + ) + add_cmakescript_test( + python_compute_release_field3_value + cmake/PythonExtractVersionInfo.cmake + ) +endif() + +include(CMakePackageConfigHelpers) + +# Configure 'PythonConfig.cmake' for a build tree +set(CONFIG_DIR_CONFIG ${CONFIG_BUILD_DIR}) +set(INCLUDE_DIR_CONFIG ${INCLUDE_BUILD_DIR}) +set(PYTHON_CONFIG_CODE "####### Expanded from \@PYTHON_CONFIG_CODE\@ #######\n") +set(PYTHON_CONFIG_CODE "${PYTHON_CONFIG_CODE}list(APPEND PYTHON_INCLUDE_DIR \"${PYCONFIG_BUILD_DIR}\")\n") +set(PYTHON_CONFIG_CODE "${PYTHON_CONFIG_CODE}##################################################") +set(python_config ${CONFIG_BUILD_DIR}/PythonConfig.cmake) +configure_package_config_file( + cmake/PythonConfig.cmake.in + ${python_config} + INSTALL_DESTINATION ${PROJECT_BINARY_DIR} + PATH_VARS CONFIG_DIR_CONFIG INCLUDE_DIR_CONFIG + NO_CHECK_REQUIRED_COMPONENTS_MACRO +) + +# Configure 'PythonConfig.cmake' for an install tree +set(CONFIG_DIR_CONFIG ${CONFIG_INSTALL_DIR}) +set(INCLUDE_DIR_CONFIG ${INCLUDE_INSTALL_DIR}) +set(PYTHON_CONFIG_CODE "") +set(python_install_config ${PROJECT_BINARY_DIR}/CMakeFiles/PythonConfig.cmake) +configure_package_config_file( + cmake/PythonConfig.cmake.in + ${python_install_config} + INSTALL_DESTINATION ${CMAKE_INSTALL_PREFIX}/${CONFIG_INSTALL_DIR} + PATH_VARS CONFIG_DIR_CONFIG INCLUDE_DIR_CONFIG + NO_CHECK_REQUIRED_COMPONENTS_MACRO +) + +# Configure 'PythonTargets.cmake' and 'PythonConfigVersion.cmake +get_property(PYTHON_TARGETS GLOBAL PROPERTY PYTHON_TARGETS) +export(TARGETS ${PYTHON_TARGETS} APPEND FILE ${CONFIG_BUILD_DIR}/PythonTargets.cmake) + +set(python_config_version ${CONFIG_BUILD_DIR}/PythonConfigVersion.cmake) +write_basic_package_version_file( + ${python_config_version} + VERSION ${PY_VERSION} + COMPATIBILITY SameMajorVersion +) + +if(INSTALL_DEVELOPMENT) + # Install 'PythonTargets.cmake', 'PythonConfig.cmake' and 'PythonConfigVersion.cmake + install(EXPORT PythonTargets + FILE PythonTargets.cmake + DESTINATION ${CONFIG_INSTALL_DIR} COMPONENT Development) + + install( + FILES ${python_install_config} ${python_config_version} + DESTINATION ${CONFIG_INSTALL_DIR} COMPONENT Development + ) +endif() + +# Install License +set(license_destination ${PYTHONHOME}) +if(INSTALL_WINDOWS_TRADITIONAL) + set(license_destination .) +endif() +install(FILES ${SRC_DIR}/LICENSE DESTINATION ${license_destination} COMPONENT Runtime RENAME LICENSE.txt) diff --git a/third/python-cmake/CONTRIBUTING.md b/third/python-cmake/CONTRIBUTING.md new file mode 100644 index 00000000..43ab4b01 --- /dev/null +++ b/third/python-cmake/CONTRIBUTING.md @@ -0,0 +1,32 @@ +Contributing +------------ + +[fork]: https://github.com/github/VisualStudio/fork +[pr]: https://github.com/github/VisualStudio/compare +[code-of-conduct]: http://todogroup.org/opencodeofconduct/#VisualStudio/opensource@github.com +[readme]: https://github.com/github/VisualStudio#build + +Hi there! We're thrilled that you'd like to contribute to this project. Your help is essential for keeping it great. + +This project adheres to the [Open Code of Conduct][code-of-conduct]. By participating, you are expected to uphold this code. + +Submitting a pull request +------------------------- + +0. [Fork][] and clone the repository (see Build Instructions in the [README][readme]) +0. Create a new branch: `git checkout -b my-branch-name` +0. Make your change, add tests, and make sure the tests still pass +0. Push to your fork and [submit a pull request][pr] +0. Pat your self on the back and wait for your pull request to be reviewed and merged. + +Here are a few things you can do that will increase the likelihood of your pull request being accepted: + +- Follow the existing code's style. +- Keep your change as focused as possible. If there are multiple changes you would like to make that are not dependent upon each other, consider submitting them as separate pull requests. +- Write a [good commit message](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html). + +## Resources + +- [Contributing to Open Source on GitHub](https://guides.github.com/activities/contributing-to-open-source/) +- [Using Pull Requests](https://help.github.com/articles/using-pull-requests/) +- [GitHub Help](https://help.github.com) diff --git a/third/python-cmake/CTestConfig.cmake b/third/python-cmake/CTestConfig.cmake new file mode 100644 index 00000000..8153e354 --- /dev/null +++ b/third/python-cmake/CTestConfig.cmake @@ -0,0 +1,8 @@ +set(CTEST_PROJECT_NAME "Python") +set(CTEST_NIGHTLY_START_TIME "3:00:00 UTC") + +set(CTEST_DROP_METHOD "https") +set(CTEST_DROP_SITE "open.cdash.org") +set(CTEST_DROP_LOCATION "/submit.php?project=CPython") +set(CTEST_DROP_SITE_CDASH TRUE) +set(CTEST_TEST_TIMEOUT "60") diff --git a/third/python-cmake/LICENSE_Apache_20 b/third/python-cmake/LICENSE_Apache_20 new file mode 100644 index 00000000..10efdfbd --- /dev/null +++ b/third/python-cmake/LICENSE_Apache_20 @@ -0,0 +1,192 @@ +Apache License +Version 2.0, January 2004 +http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + +"License" shall mean the terms and conditions for use, reproduction, and +distribution as defined by Sections 1 through 9 of this document. + +"Licensor" shall mean the copyright owner or entity authorized by the copyright +owner that is granting the License. + +"Legal Entity" shall mean the union of the acting entity and all other entities +that control, are controlled by, or are under common control with that entity. +For the purposes of this definition, "control" means (i) the power, direct or +indirect, to cause the direction or management of such entity, whether by +contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the +outstanding shares, or (iii) beneficial ownership of such entity. + +"You" (or "Your") shall mean an individual or Legal Entity exercising +permissions granted by this License. + +"Source" form shall mean the preferred form for making modifications, including +but not limited to software source code, documentation source, and configuration +files. + +"Object" form shall mean any form resulting from mechanical transformation or +translation of a Source form, including but not limited to compiled object code, +generated documentation, and conversions to other media types. + +"Work" shall mean the work of authorship, whether in Source or Object form, made +available under the License, as indicated by a copyright notice that is included +in or attached to the work (an example is provided in the Appendix below). + +"Derivative Works" shall mean any work, whether in Source or Object form, that +is based on (or derived from) the Work and for which the editorial revisions, +annotations, elaborations, or other modifications represent, as a whole, an +original work of authorship. For the purposes of this License, Derivative Works +shall not include works that remain separable from, or merely link (or bind by +name) to the interfaces of, the Work and Derivative Works thereof. + +"Contribution" shall mean any work of authorship, including the original version +of the Work and any modifications or additions to that Work or Derivative Works +thereof, that is intentionally submitted to Licensor for inclusion in the Work +by the copyright owner or by an individual or Legal Entity authorized to submit +on behalf of the copyright owner. For the purposes of this definition, +"submitted" means any form of electronic, verbal, or written communication sent +to the Licensor or its representatives, including but not limited to +communication on electronic mailing lists, source code control systems, and +issue tracking systems that are managed by, or on behalf of, the Licensor for +the purpose of discussing and improving the Work, but excluding communication +that is conspicuously marked or otherwise designated in writing by the copyright +owner as "Not a Contribution." + +"Contributor" shall mean Licensor and any individual or Legal Entity on behalf +of whom a Contribution has been received by Licensor and subsequently +incorporated within the Work. + +2. Grant of Copyright License. + +Subject to the terms and conditions of this License, each Contributor hereby +grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, +irrevocable copyright license to reproduce, prepare Derivative Works of, +publicly display, publicly perform, sublicense, and distribute the Work and such +Derivative Works in Source or Object form. + +3. Grant of Patent License. + +Subject to the terms and conditions of this License, each Contributor hereby +grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, +irrevocable (except as stated in this section) patent license to make, have +made, use, offer to sell, sell, import, and otherwise transfer the Work, where +such license applies only to those patent claims licensable by such Contributor +that are necessarily infringed by their Contribution(s) alone or by combination +of their Contribution(s) with the Work to which such Contribution(s) was +submitted. If You institute patent litigation against any entity (including a +cross-claim or counterclaim in a lawsuit) alleging that the Work or a +Contribution incorporated within the Work constitutes direct or contributory +patent infringement, then any patent licenses granted to You under this License +for that Work shall terminate as of the date such litigation is filed. + +4. Redistribution. + +You may reproduce and distribute copies of the Work or Derivative Works thereof +in any medium, with or without modifications, and in Source or Object form, +provided that You meet the following conditions: + +You must give any other recipients of the Work or Derivative Works a copy of +this License; and +You must cause any modified files to carry prominent notices stating that You +changed the files; and +You must retain, in the Source form of any Derivative Works that You distribute, +all copyright, patent, trademark, and attribution notices from the Source form +of the Work, excluding those notices that do not pertain to any part of the +Derivative Works; and +If the Work includes a "NOTICE" text file as part of its distribution, then any +Derivative Works that You distribute must include a readable copy of the +attribution notices contained within such NOTICE file, excluding those notices +that do not pertain to any part of the Derivative Works, in at least one of the +following places: within a NOTICE text file distributed as part of the +Derivative Works; within the Source form or documentation, if provided along +with the Derivative Works; or, within a display generated by the Derivative +Works, if and wherever such third-party notices normally appear. The contents of +the NOTICE file are for informational purposes only and do not modify the +License. You may add Your own attribution notices within Derivative Works that +You distribute, alongside or as an addendum to the NOTICE text from the Work, +provided that such additional attribution notices cannot be construed as +modifying the License. +You may add Your own copyright statement to Your modifications and may provide +additional or different license terms and conditions for use, reproduction, or +distribution of Your modifications, or for any such Derivative Works as a whole, +provided Your use, reproduction, and distribution of the Work otherwise complies +with the conditions stated in this License. + +5. Submission of Contributions. + +Unless You explicitly state otherwise, any Contribution intentionally submitted +for inclusion in the Work by You to the Licensor shall be under the terms and +conditions of this License, without any additional terms or conditions. +Notwithstanding the above, nothing herein shall supersede or modify the terms of +any separate license agreement you may have executed with Licensor regarding +such Contributions. + +6. Trademarks. + +This License does not grant permission to use the trade names, trademarks, +service marks, or product names of the Licensor, except as required for +reasonable and customary use in describing the origin of the Work and +reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. + +Unless required by applicable law or agreed to in writing, Licensor provides the +Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, +including, without limitation, any warranties or conditions of TITLE, +NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are +solely responsible for determining the appropriateness of using or +redistributing the Work and assume any risks associated with Your exercise of +permissions under this License. + +8. Limitation of Liability. + +In no event and under no legal theory, whether in tort (including negligence), +contract, or otherwise, unless required by applicable law (such as deliberate +and grossly negligent acts) or agreed to in writing, shall any Contributor be +liable to You for damages, including any direct, indirect, special, incidental, +or consequential damages of any character arising as a result of this License or +out of the use or inability to use the Work (including but not limited to +damages for loss of goodwill, work stoppage, computer failure or malfunction, or +any and all other commercial damages or losses), even if such Contributor has +been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. + +While redistributing the Work or Derivative Works thereof, You may choose to +offer, and charge a fee for, acceptance of support, warranty, indemnity, or +other liability obligations and/or rights consistent with this License. However, +in accepting such obligations, You may act only on Your own behalf and on Your +sole responsibility, not on behalf of any other Contributor, and only if You +agree to indemnify, defend, and hold each Contributor harmless for any liability +incurred by, or claims asserted against, such Contributor by reason of your +accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work + +To apply the Apache License to your work, attach the following boilerplate +notice, with the fields enclosed by brackets "[]" replaced with your own +identifying information. (Don't include the brackets!) The text should be +enclosed in the appropriate comment syntax for the file format. We also +recommend that a file or class name and description of purpose be included on +the same "printed page" as the copyright notice for easier identification within +third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + diff --git a/third/python-cmake/README.rst b/third/python-cmake/README.rst new file mode 100644 index 00000000..c4bf4e7e --- /dev/null +++ b/third/python-cmake/README.rst @@ -0,0 +1,280 @@ +CPython CMake Buildsystem +========================= + +Overview +-------- + +A replacement buildsystem for CPython. + +This `CMake `_ buildsystem has the following advantages: + +* No compiled program for the target architecture is used in the build + itself. This makes **cross-compiling** easier, less error prone, and + reduces manual steps. + +* Same build information for all platforms - there's no need to maintain the + autotools configuration separately from four different MSVC project files. + +* Support for other build systems and IDE's like `Ninja + `_, `Sublime Text + `_, and many others. + +* Easily build C-extensions against other C/C++ libraries built with CMake. + +* It's much faster to compile: 7 seconds instead of 58 seconds in my + unscientific test. + +Usage +----- + +How to use this buildsystem: + +1. Checkout the buildsystem + +.. code:: bash + + cd ~/scratch + git clone git://github.com/python-cmake-buildsystem/python-cmake-buildsystem + +2. Build + +.. code:: bash + + # Unix + cd ~/scratch + mkdir -p python-build && mkdir -p python-install + cd python-build + cmake -DCMAKE_INSTALL_PREFIX:PATH=${HOME}/scratch/python-install ../python-cmake-buildsystem + make -j10 + make install + + # Windows + cd %HOME%/scratch + mkdir python-build + mkdir python-install + cd python-build + cmake -G "Visual Studio 16 2019" -A x64 -DCMAKE_INSTALL_PREFIX:PATH=%HOME%/scratch/python-install ../python-cmake-buildsystem + cmake --build . --config Release -- /m + cmake --build . --config Release --target INSTALL + +.. note:: + + By default, the build system will download the python 3.11.12 source from + http://www.python.org/ftp/python/ + + +CMake Options +------------- + +You can pass options to CMake to control the way Python is built. You only +need to give each option once - they get saved in `CMakeCache.txt`. Pass +options on the commandline with `-DOPTION=VALUE`, or use the "ccmake" gui. + +:: + + PYTHON_VERSION=major.minor.patch (defaults to 3.12.10) + The version of Python to build. + + PYTHON_APPLY_PATCHES=ON|OFF (defaults to ON) + Apply patches required to build CPython based on the system and compiler + found when configuring the project. Note that when cross-compiling, patches + coresponding to the target system are applied. + Patches can be found in "patches" directory. + + CMAKE_BUILD_TYPE=Debug|Release + Build with debugging symbols or with optimisations. + + CMAKE_INSTALL_PREFIX= (defaults to /usr/local) + Path in which to install Python. + + DOWNLOAD_SOURCES=ON|OFF (defaults to ON) + Download, check MD5 sum and extract python sources in the parent directory. + Source archive is downloaded from http://www.python.org/ftp/python + + BUILD_LIBPYTHON_SHARED=ON|OFF (defaults to OFF) + Build libpython as a shared library (.so or .dll) or a static library + (.a). + + Note that Python extensions are always built as shared libraries. On + Windows it is not possible to build shared .dll extensions against a + static libpython, so you must build any extensions you want into libpython + itself (see the BUILTIN flags below). + + BUILD_EXTENSIONS_AS_BUILTIN=ON|OFF (defaults to OFF) + If enabled, all extensions are statically compiled into the built python + libraries (static and/or shared). + + Note that all previously set BUILTIN_ options are ignored and + reset to their original value. + + WITH_STATIC_DEPENDENCIES=ON|OFF (defaults to OFF, available only on UNIX) + If this is set to ON then cmake will compile statically libpython and all + extensions. External dependencies (ncurses, sqlite, ...) will be builtin + only if they are available as static libraries. + + BUILD_WININST=ON|OFF (only for windows, defaults to ON if not crosscompiling) + If enabled, build the 'Windows Installer' program for distutils if not + already provided in the source tree. + + BUILD_WININST_ALWAYS=ON|OFF (only for windows, defaults to OFF) + If enabled, always build 'Windows Installer' program for distutils even + if it is already provided in the source tree. + + INSTALL_DEVELOPMENT=ON|OFF (defaults to ON) + If enabled, install files required to develop C extensions. + + INSTALL_MANUAL=ON|OFF (defaults to ON) + If enabled, install manuals. + + INSTALL_TEST=ON|OFF (defaults to ON) + If enabled, install test files. + + ENABLE_=ON|OFF (defaults to ON) + BUILTIN_=ON|OFF (defaults to OFF except for POSIX, PWD and + NT extensions which are builtin by default) + These two options control how individual python extensions are built. + is the name of the extension in upper case, and without any + leading underscore (_). + + All extensions are enabled by default, but some might depend on system + libraries and will get disabled if they're not available (a list of + extensions that didn't have all their prerequisites available will be + printed when you run cmake). + + By default extensions are compiled as separate shared libraries (.so or + .dll files) and installed in lib/pythonX.Y/lib-dynload. If you set + BUILTIN_ to ON then the extension is compiled into libpython + instead. + + USE_LIB64=ON|OFF (defaults to OFF) + If this is set to ON then cmake will look for dependencies in lib64 as + well as lib directories. Compiled python extensions will also be + installed into lib64/pythonX.Y/lib-dynload instead of + lib/pythonX.Y/lib-dynload. + + Py_USING_UNICODE (only for python2, defaults to ON) + Enable unicode support. By default, ucs2 is used. It can be + forced to ucs4 setting Py_UNICODE_SIZE to 4. + + WITH_C_LOCALE_COERCION (only for python3.7 and above, default to ON) + Enable C locale coercion to a UTF-8 based locale. + + WITH_DECIMAL_CONTEXTVAR (only for python3.8 and above, default to ON) + Build _decimal module using a coroutine-local rather than a thread-local context. + + WITH_TRACE_REFS (only for python3.8 and above, default to OFF) + Enable tracing references for debugging purpose + + WITH_SSL_DEFAULT_SUITES (only for python3.7 and above, default to "python") + Override default cipher suites string: + * python: use Python's preferred selection (default) + * openssl: leave OpenSSL's defaults untouched + * STRING: use a custom string, PROTOCOL_SSLv2 ignores the setting + + EXTRA_PYTHONPATH=dir1:dir2 (defaults to "") + Colon (:) separated list of extra directories to add to the compiled-in + PYTHONPATH. + + USE_SYSTEM_LIBRARIES=ON|OFF (defaults to ON) + If set to OFF, no attempt to detect system libraries will be done. + Options documented below allow to enable/disable detection of particular + libraries. + + USE_SYSTEM_Curses=ON|OFF (defaults to ON) + If set to OFF, no attempt to detect Curses libraries will be done. + Associated python extensions are: CURSES, CURSES_PANEL, READLINE + Following CMake variables can manually be set: CURSES_LIBRARIES, PANEL_LIBRARIES + + USE_SYSTEM_EXPAT=ON|OFF (defaults to ON) + If set to OFF, no attempt to detect Expat libraries will be done. + Associated python extensions are: ELEMENTTREE, PYEXPAT + Following CMake variables can manually be set: EXPAT_LIBRARIES, EXPAT_INCLUDE_DIRS + + USE_SYSTEM_LibFFI=ON|OFF (defaults to ON) + If set to OFF, no attempt to detect libffi libraries will be done. + Associated python extensions are: CTYPES + Following CMake variables can manually be set: LibFFI_LIBRARY and LibFFI_INCLUDE_DIR + + USE_SYSTEM_OpenSSL=ON|OFF (defaults to ON) + If set to OFF, no attempt to detect OpenSSL libraries will be done. + Associated python extensions are: HASHLIB, SSL, MD5, SHA, SHA256, SHA512 + Following CMake variables can manually be set: OPENSSL_INCLUDE_DIR, OPENSSL_LIBRARIES + If [OPENSSL_INCLUDE_DIR, OPENSSL_LIBRARIES] are found, extensions [HASHLIB, SSL] will be built + If [OPENSSL_INCLUDE_DIR, OPENSSL_LIBRARIES] are NOT found, extensions [SHA, SHA256, SHA512] will be built + + USE_SYSTEM_TCL=ON|OFF (defaults to ON) + If set to OFF, no attempt to detect Tcl libraries will be done. + Associated python extensions are: TKINTER + Following CMake variables can manually be set: TCL_LIBRARY, TK_LIBRARY, TCL_INCLUDE_PATH, TK_INCLUDE_PATH + + USE_SYSTEM_ZLIB=ON|OFF (defaults to ON) + If set to OFF, no attempt to detect ZLIB libraries will be done. + Associated python extensions are: BINASCII, ZLIB + Following CMake variables can manually be set: ZLIB_LIBRARY, ZLIB_INCLUDE_DIR, ZLIB_ROOT + ZLIB_ROOT should be set only if USE_SYSTEM_ZLIB is ON + If [ZLIB_LIBRARY, ZLIB_INCLUDE_DIR] are found, extensions [BINASCII] will be built with ZLIB_CRC32 + + USE_SYSTEM_DB=ON|OFF (defaults to ON) + If set to OFF, no attempt to detect DB libraries will be done. + Associated python extensions are: BSDDB + Following CMake variables can manually be set: DB_INCLUDE_PATH, DB_LIBRARY + + USE_SYSTEM_GDBM=ON|OFF (defaults to ON) + If set to OFF, no attempt to detect GDBM libraries will be done. + Associated python extensions are: DBM, GDBM + Following CMake variables can manually be set: GDBM_INCLUDE_PATH, GDBM_LIBRARY, GDBM_COMPAT_LIBRARY, NDBM_TAG, _INCLUDE_PATH + + USE_SYSTEM_LZMA=ON|OFF (defaults to ON) + If set to OFF, no attempt to detect LZMA libraries will be done. + Associated python extensions are: LZMA + Following CMake variables can manually be set: LZMA_INCLUDE_PATH, LZMA_LIBRARY + + USE_SYSTEM_READLINE=ON|OFF (defaults to ON) + If set to OFF, no attempt to detect Readline libraries will be done. + Associated python extensions are: READLINE + Following CMake variables can manually be set: READLINE_INCLUDE_PATH, READLINE_LIBRARY + + USE_SYSTEM_SQLite3=ON|OFF (defaults to ON) + If set to OFF, no attempt to detect SQLite3 libraries will be done. + Associated python extensions are: SQLITE3 + Following CMake variables can manually be set: SQLite3_INCLUDE_DIR, SQLite3_LIBRARY + + CMAKE_OSX_SDK (MacOSX, default is autodetected, e.g 'macosx10.06') + By default, the variable is automatically set running `xcrun` and/or `xcodebuild`. Note that its + value can also be explicitly set when doing a clean configuration either by adding a cache entry in + `cmake-gui` or by passing the argument `-DCMAKE_OSX_SDK:STRING=macosx10.6` when running `cmake`. + Then, this variable is used to initialize `CMAKE_OSX_SYSROOT`, `CMAKE_OSX_DEPLOYMENT_TARGET` + and `MACOSX_DEPLOYMENT_TARGET` variables. + +Licenses +-------- + +Materials in this repository are distributed under the following licenses: + + All software is licensed under the Apache 2.0 License. + See `LICENSE_Apache_20 `_ file for details. + + +FAQ +--- + +Why Apache 2.0 License? +....................... + +From the python.org wiki, the answer to the question `What if I want to +contribute my code to the PSF +`_ +mentions that if code is going to end up in Python or the standard library, +the PSF will require you to license code under "Academic Free License" or +"Apache License 2.0". + +Which python versions are supported? +.................................... + +This project supports building multiple versions of CPython 3. +See current list of supported version in top-level `CMakeLists.txt `_. + +Support for building CPython 2.7 was retired in April 2025. Archived version associated with tag [v2.7](https://github.com/python-cmake-buildsystem/python-cmake-buildsystem/releases/tag/v2.7). + +Since this repository is maintained separately from `python/CPython `_ itself, +it needs to be manually updated whenever there is a new release of Python. diff --git a/third/python-cmake/cmake/ConfigureChecks.cmake b/third/python-cmake/cmake/ConfigureChecks.cmake new file mode 100644 index 00000000..5ed2c5b7 --- /dev/null +++ b/third/python-cmake/cmake/ConfigureChecks.cmake @@ -0,0 +1,3162 @@ +include(CheckCSourceCompiles) +include(CheckCSourceRuns) +include(CheckIncludeFiles) +include(CheckTypeSize) +include(CMakePushCheckState) +include(CheckStructHasMember) +include(CheckFunctionExists) +include(CheckLibraryExists) +include(CheckSymbolExists) +include(CheckVariableExists) +include(cmake/PlatformTest.cmake) +include(TestBigEndian) + +message(STATUS "The system name is ${CMAKE_SYSTEM_NAME}") +message(STATUS "The system processor is ${CMAKE_SYSTEM_PROCESSOR}") +message(STATUS "The system version is ${CMAKE_SYSTEM_VERSION}") + +# Find any dependencies + +set(HAVE_LIBB2 0) # See https://github.com/python-cmake-buildsystem/python-cmake-buildsystem/issues/393 + +if(USE_SYSTEM_BZip2) + find_package(BZip2) # https://cmake.org/cmake/help/latest/module/FindBZip2.html +endif() +message(STATUS "BZIP2_INCLUDE_DIR=${BZIP2_INCLUDE_DIR}") +message(STATUS "BZIP2_LIBRARIES=${BZIP2_LIBRARIES}") +set(HAVE_BZLIB_H "${BZIP2_INCLUDE_DIR}") # Python 3.11 + +if(USE_SYSTEM_Curses) + + message(STATUS "") + set(_msg "Looking for curses with Unicode support") + message(STATUS "${_msg}") + set(CURSES_NEED_WIDE TRUE) + find_package(Curses) # https://cmake.org/cmake/help/latest/module/FindCurses.html + if(Curses_FOUND) + message(STATUS "${_msg} - found") + else() + message(STATUS "${_msg} - not found") + endif() + + # Python 3.12 + if(Curses_FOUND) + set(HAVE_NCURSESW 1) + else() + set(HAVE_NCURSESW 0) + endif() + + if(NOT Curses_FOUND) + message(STATUS "") + set(_msg "Looking for curses without Unicode support") + message(STATUS "${_msg}") + set(CURSES_NEED_WIDE FALSE) + find_package(Curses) + if(Curses_FOUND) + message(STATUS "${_msg} - found") + else() + message(STATUS "${_msg} - not found") + endif() + endif() + + find_library(PANEL_LIBRARY NAMES panel) + set(PANEL_LIBRARIES ${PANEL_LIBRARY}) + if(WITH_STATIC_DEPENDENCIES) + find_library(TINFO_LIBRARY NAMES tinfo) + find_library(GPM_LIBRARY NAMES gpm) + endif() +endif() +message(STATUS "") +message(STATUS "CURSES_LIBRARIES=${CURSES_LIBRARIES}") +message(STATUS "PANEL_LIBRARIES=${PANEL_LIBRARIES}") +if(WITH_STATIC_DEPENDENCIES) + message(STATUS "TINFO_LIBRARY=${TINFO_LIBRARY}") + message(STATUS "GPM_LIBRARY=${GPM_LIBRARY}") +endif() +message(STATUS "") + +if(USE_SYSTEM_EXPAT) + find_package(EXPAT) # https://cmake.org/cmake/help/latest/module/FindEXPAT.html +endif() +message(STATUS "EXPAT_LIBRARIES=${EXPAT_LIBRARIES}") +message(STATUS "EXPAT_INCLUDE_DIRS=${EXPAT_INCLUDE_DIRS}") + +if(USE_SYSTEM_LibFFI) + find_path(LibFFI_INCLUDE_DIR ffi.h) + find_library(LibFFI_LIBRARY NAMES ffi libffi) + message(STATUS "LibFFI_INCLUDE_DIR=${LibFFI_INCLUDE_DIR}") + message(STATUS "LibFFI_LIBRARY=${LibFFI_LIBRARY}") +endif() +set(HAVE_LIBFFI ${LibFFI_LIBRARY}) # Python 3.12 + +if(USE_SYSTEM_LIBMPDEC) + find_library(LIBMPDEC_LIBRARY NAMES mpdec libmpdec) + set(LIBMPDEC_LIBRARIES ${LIBMPDEC_LIBRARY}) + message(STATUS "LIBMPDEC_LIBRARIES=${LIBMPDEC_LIBRARIES}") + find_path(LIBMPDEC_INCLUDE_DIR mpdecimal.h) + message(STATUS "LIBMPDEC_INCLUDE_DIR=${LIBMPDEC_INCLUDE_DIR}") +endif() + +if(USE_SYSTEM_OpenSSL) + find_package(OpenSSL 0.9.7) # https://cmake.org/cmake/help/latest/module/FindOpenSSL.html + message(STATUS "OPENSSL_LIBRARIES=${OPENSSL_LIBRARIES}") + message(STATUS "OPENSSL_INCLUDE_DIR=${OPENSSL_INCLUDE_DIR}") +endif() + +if(USE_SYSTEM_TCL) + find_package(TCL ${_tcl_version}) + + if(TCL_FOUND) + set(tk_h_path "${TK_INCLUDE_PATH}/tk.h") + + file(STRINGS "${tk_h_path}" tk_version_str REGEX "^#define[\t ]+TK_PATCH_LEVEL[\t ]+\".*\".*") + string(REGEX REPLACE "^#define[\t ]+TK_PATCH_LEVEL[\t ]+\"([^\"]*)\".*" "\\1" TK_PATCH_LEVEL "${tk_version_str}") + + if(TK_PATCH_LEVEL) + message(STATUS "TK_PATCH_LEVEL: ${TK_PATCH_LEVEL}") + + set(_tk_expected_version) + if(PY_VERSION VERSION_GREATER_EQUAL "3.11") + set(_tk_expected_version "8.5.12") + elseif(PY_VERSION VERSION_GREATER_EQUAL "3.5") + set(_tk_expected_version "8.4") + else() + set(_tk_expected_version "8.3.1") + endif() + + if("${TK_PATCH_LEVEL}" VERSION_LESS "${_tk_expected_version}") + message(WARNING "TCL version check failed. Version ${TK_PATCH_LEVEL} was found, at least version ${_tk_expected_version} is required") + message(AUTHOR_WARNING "Unsetting cache variable TK_LIBRARY") + unset(TK_LIBRARY CACHE) + message(AUTHOR_WARNING "Unsetting cache variable TK_INCLUDE_PATH") + unset(TK_INCLUDE_PATH CACHE) + endif() + else() + message(WARNING "Could not find TK_PATCH_LEVEL in ${tk_h_path}") + endif() + endif() +endif() + +if(UNIX) + # Only needed by _tkinter + find_package(X11) +endif() + +if(USE_SYSTEM_ZLIB) + find_package(ZLIB) # https://cmake.org/cmake/help/latest/module/FindZLIB.html + message(STATUS "ZLIB_INCLUDE_DIRS=${ZLIB_INCLUDE_DIRS}") + message(STATUS "ZLIB_LIBRARIES=${ZLIB_LIBRARIES}") +endif() +set(HAVE_ZLIB_H ${ZLIB_INCLUDE_DIRS}) # Python 3.11 + +if(USE_SYSTEM_DB) + find_path(DB_INCLUDE_PATH db.h) + find_library(DB_LIBRARY NAMES db-4.8) + message(STATUS "DB_INCLUDE_PATH=${DB_INCLUDE_PATH}") + message(STATUS "DB_LIBRARY=${DB_LIBRARY}") +endif() +set(HAVE_DB_H ${DB_INCLUDE_PATH}) # Python 3.11 +set(HAVE_LIBDB ${DB_LIBRARY}) # Python 3.11 + +if(USE_SYSTEM_GDBM) + find_path(GDBM_INCLUDE_PATH gdbm.h) + set(HAVE_GDBM_H ${GDBM_INCLUDE_PATH}) # Python 3.11 + find_library(GDBM_LIBRARY gdbm) + find_library(GDBM_COMPAT_LIBRARY gdbm_compat) + set(HAVE_LIBGDBM_COMPAT ${GDBM_COMPAT_LIBRARY}) # Python 3.11 + find_path(NDBM_INCLUDE_PATH ndbm.h) + set(HAVE_NDBM_H ${NDBM_INCLUDE_PATH}) # Python 3.11 + + if(NDBM_INCLUDE_PATH) + set(NDBM_TAG NDBM) + set(NDBM_USE NDBM) + find_library(NDBM_LIBRARY ndbm) + set(HAVE_LIBNDBM ${NDBM_LIBRARY}) # Python 3.11 + else() + set(NDBM_USE GDBM_COMPAT) + find_path(GDBM_NDBM_INCLUDE_PATH gdbm/ndbm.h) + set(HAVE_GDBM_NDBM_H ${GDBM_NDBM_INCLUDE_PATH}) # Python 3.11 + if(GDBM_NDBM_INCLUDE_PATH) + set(NDBM_TAG GDBM_NDBM) + else() + find_path(GDBM_DASH_NDBM_INCLUDE_PATH gdbm-ndbm.h) + set(HAVE_GDBM_DASH_NDBM_H ${GDBM_DASH_NDBM_INCLUDE_PATH}) # Python 3.11 + if(GDBM_DASH_NDBM_INCLUDE_PATH) + set(NDBM_TAG GDBM_DASH_NDBM) + endif() + endif() + endif() +endif() +message(STATUS "GDBM_INCLUDE_PATH=${GDBM_INCLUDE_PATH}") +message(STATUS "GDBM_LIBRARY=${GDBM_LIBRARY}") +message(STATUS "GDBM_COMPAT_LIBRARY=${GDBM_COMPAT_LIBRARY}") +message(STATUS "NDBM_TAG=${NDBM_TAG}") +message(STATUS "NDBM_USE=${NDBM_USE}") +message(STATUS "_INCLUDE_PATH=${${NDBM_TAG}_INCLUDE_PATH}") + +find_path(LZMA_INCLUDE_PATH lzma.h) +find_library(LZMA_LIBRARY lzma) +message(STATUS "LZMA_INCLUDE_PATH=${LZMA_INCLUDE_PATH}") +message(STATUS "LZMA_LIBRARY=${LZMA_LIBRARY}") +set(HAVE_LZMA_H ${LZMA_INCLUDE_PATH}) # Python 3.11 + +if(USE_SYSTEM_READLINE) + if(USE_LIBEDIT) + find_path(READLINE_INCLUDE_PATH editline/readline.h) + set(HAVE_EDITLINE_READLINE_H ${READLINE_INCLUDE_PATH}) # Python 3.12 + find_library(READLINE_LIBRARY edit) + else() + find_path(READLINE_INCLUDE_PATH readline/readline.h) + set(HAVE_READLINE_READLINE_H ${READLINE_INCLUDE_PATH}) # Python 3.12 + find_library(READLINE_LIBRARY readline) + endif() +endif() +message(STATUS "READLINE_INCLUDE_PATH=${READLINE_INCLUDE_PATH}") +message(STATUS "READLINE_LIBRARY=${READLINE_LIBRARY}") + +if(DEFINED SQLITE3_INCLUDE_PATH) + message(AUTHOR_WARNING "Setting SQLITE3_INCLUDE_PATH is deprecated. SQLite3_INCLUDE_DIR should be set instead.") + set(SQLite3_INCLUDE_DIR ${SQLITE3_INCLUDE_PATH}) +endif() +if(DEFINED SQLITE3_LIBRARY) + message(AUTHOR_WARNING "Setting SQLITE3_LIBRARY is deprecated. SQLite3_LIBRARY should be set instead.") + set(SQLite3_LIBRARY ${SQLITE3_LIBRARY}) +endif() +if(USE_SYSTEM_SQLite3) + find_package(SQLite3) # https://cmake.org/cmake/help/latest/module/FindSQLite3.html +endif() +set(SQLite3_INCLUDE_DIRS ${SQLite3_INCLUDE_DIR}) +set(SQLite3_LIBRARIES ${SQLite3_LIBRARY}) +message(STATUS "SQLite3_INCLUDE_DIRS=${SQLite3_INCLUDE_DIRS}") +message(STATUS "SQLite3_LIBRARIES=${SQLite3_LIBRARIES}") +set(HAVE_LIBSQLITE3 ${SQLite3_LIBRARIES}) # Python 3.11 + +find_path(TIRPC_RPC_INCLUDE_PATH rpc.h PATHS "/usr/include/tirpc/rpc") +set(HAVE_RPC_RPC_H ${TIRPC_RPC_INCLUDE_PATH}) # Python 3.11 +find_library(TIRPC_LIBRARY tirpc) + +find_library(UUID_LIBRARY uuid) + +if(WIN32) + set(M_LIBRARIES ) + set(HAVE_LIBM 1) + # From PC/pyconfig.h: + # This is a manually maintained version used for the Watcom, + # Borland and Microsoft Visual C++ compilers. It is a + # standard part of the Python distribution. +else() + +set(_msg "Checking WITH_HASH_ALGORITHM option") +message(STATUS "${_msg}") +if(WITH_HASH_ALGORITHM STREQUAL "default") + set(Py_HASH_ALGORITHM 0) +elseif(WITH_HASH_ALGORITHM STREQUAL "siphash24") + set(Py_HASH_ALGORITHM 1) +elseif(WITH_HASH_ALGORITHM STREQUAL "fnv") + set(Py_HASH_ALGORITHM 2) +else() + message(FATAL_ERROR "Unknown hash algorithm '${Py_HASH_ALGORITHM}'") +endif() +message(STATUS "${_msg} [${WITH_HASH_ALGORITHM}]") + +# ABI version string for Python extension modules. This appears between the +# periods in shared library file names, e.g. foo..so. It is calculated +# from the following attributes which affect the ABI of this Python build (in +# this order): +# +# * The Python implementation (always 'cpython-' for us) +# * The major and minor version numbers +# * --with-pydebug (adds a 'd') +# +# Thus for example, Python 3.2 built with wide unicode, pydebug, and pymalloc, +# would get a shared library ABI version tag of 'cpython-32dmu' and shared +# libraries would be named 'foo.cpython-32dmu.so'. +# +# In Python 3.2 and older, --with-wide-unicode added a 'u' flag. +# In Python 3.7 and older, --with-pymalloc added a 'm' flag. + +set(_msg "Checking ABIFLAGS") +set(ABIFLAGS ) +if(Py_DEBUG) + set(ABIFLAGS "${ABIFLAGS}d") +endif() +if(WITH_PYMALLOC AND PY_VERSION VERSION_LESS "3.8") + set(ABIFLAGS "${ABIFLAGS}m") +endif() +message(STATUS "${_msg} - ${ABIFLAGS}") + +set(_msg "Checking SOABI") +if(NOT DEFINED PLATFORM_TRIPLET) + try_run(PLATFORM_RUN PLATFORM_COMPILE + ${PROJECT_BINARY_DIR} ${PROJECT_SOURCE_DIR}/cmake/platform.c + RUN_OUTPUT_VARIABLE PLATFORM_TRIPLET) + if(NOT PLATFORM_COMPILE) + message(FATAL_ERROR "We could not determine the platform. Please clean the ${CMAKE_PROJECT_NAME} environment and try again...") + endif() +endif() +set(SOABI "cpython-${PY_VERSION_MAJOR}${PY_VERSION_MINOR}${ABIFLAGS}") +if(PLATFORM_TRIPLET) + set(SOABI "${SOABI}-${PLATFORM_TRIPLET}") +endif() + +message(STATUS "${_msg} - ${SOABI}") + +if(PY_VERSION VERSION_GREATER_EQUAL "3.8") + +# Alternative SOABI used in debug build to load C extensions built in release mode +# Release and debug (Py_DEBUG) ABI are compatible, but not Py_TRACE_REFS ABI +if(Py_DEBUG AND NOT WITH_TRACE_REFS) + string(REPLACE "d" "" ALT_ABIFLAGS "${ABIFLAGS}") + set(ALT_SOABI "cpython-${PY_VERSION_MAJOR}${PY_VERSION_MINOR}${ALT_ABIFLAGS}") + if(PLATFORM_TRIPLET) + set(ALT_SOABI "${ALT_SOABI}-${PLATFORM_TRIPLET}") + endif() +endif() + +endif() + +macro(ADD_COND var cond item) + if(${cond}) + set(${var} ${${var}} ${item}) + endif() +endmacro() + +set(CMAKE_REQUIRED_DEFINITIONS ) + +# Convenient macro allowing to conditonally update CMAKE_REQUIRED_DEFINITIONS +macro(set_required_def var value) + set(${var} ${value}) + list(APPEND CMAKE_REQUIRED_DEFINITIONS "-D${var}=${value}") +endmacro() + +# Emulate AC_HEADER_DIRENT +check_include_files(dirent.h HAVE_DIRENT_H) +if(NOT HAVE_DIRENT_H) + check_include_files(sys/ndir.h HAVE_SYS_NDIR_H) + set(CMAKE_EXTRA_INCLUDE_FILES "sys/dir.h") + check_type_size(DIR HAVE_SYS_DIR_H) + check_include_files(ndir.h HAVE_NDIR_H) +endif() + check_symbol_exists("dirfd" "sys/types.h;dirent.h" HAVE_DIRFD) + +check_include_files(alloca.h HAVE_ALLOCA_H) # libffi and cpython +check_include_files(asm/types.h HAVE_ASM_TYPES_H) +check_include_files(arpa/inet.h HAVE_ARPA_INET_H) +check_include_files(bluetooth/bluetooth.h HAVE_BLUETOOTH_BLUETOOTH_H) +check_include_files(bluetooth.h HAVE_BLUETOOTH_H) +check_include_files(conio.h HAVE_CONIO_H) +check_include_files(crypt.h HAVE_CRYPT_H) +check_include_files(curses.h HAVE_CURSES_H) +check_include_files(direct.h HAVE_DIRECT_H) +check_include_files(dlfcn.h HAVE_DLFCN_H) # libffi and cpython +check_include_files(errno.h HAVE_ERRNO_H) +check_include_files(fcntl.h HAVE_FCNTL_H) +check_include_files(fpu_control.h HAVE_FPU_CONTROL_H) +check_include_files(grp.h HAVE_GRP_H) +check_include_files(ieeefp.h HAVE_IEEEFP_H) +check_include_files(inttypes.h HAVE_INTTYPES_H) # libffi and cpython +check_include_files(io.h HAVE_IO_H) +check_include_files(langinfo.h HAVE_LANGINFO_H) +check_include_files(libintl.h HAVE_LIBINTL_H) +check_include_files(libutil.h HAVE_LIBUTIL_H) +check_include_files(linux/tipc.h HAVE_LINUX_TIPC_H) +check_include_files(linux/auxvec.h HAVE_LINUX_AUXVEC_H) # Python 3.10 +check_include_files(locale.h HAVE_LOCALE_H) + +check_include_files(sys/socket.h HAVE_SYS_SOCKET_H) +check_include_files(sys/soundcard.h> HAVE_SYS_SOUNDCARD_H) # Python 3.11 + +set(LINUX_NETLINK_HEADERS) +add_cond(LINUX_NETLINK_HEADERS HAVE_ASM_TYPES_H asm/types.h) +add_cond(LINUX_NETLINK_HEADERS HAVE_SYS_SOCKET_H sys/socket.h) +set(LINUX_NETLINK_HEADERS ${LINUX_NETLINK_HEADERS} linux/netlink.h) +check_include_files("${LINUX_NETLINK_HEADERS}" HAVE_LINUX_NETLINK_H) + +set(LINUX_QRTR_HEADERS) +add_cond(LINUX_QRTR_HEADERS HAVE_ASM_TYPES_H asm/types.h) +add_cond(LINUX_QRTR_HEADERS HAVE_SYS_SOCKET_H sys/socket.h) +set(LINUX_QRTR_HEADERS ${LINUX_QRTR_HEADERS} linux/qrtr.h) +check_include_files("${LINUX_QRTR_HEADERS}" HAVE_LINUX_QRTR_H) + +# On Linux, can.h and can/raw.h require sys/socket.h +set(LINUX_CAN_HEADERS) +add_cond(LINUX_CAN_HEADERS HAVE_SYS_SOCKET_H sys/socket.h) +check_include_files("${LINUX_CAN_HEADERS};linux/can.h" HAVE_LINUX_CAN_H) +check_include_files("${LINUX_CAN_HEADERS};linux/can/bcm.h" HAVE_LINUX_CAN_BCM_H) +check_include_files("${LINUX_CAN_HEADERS};linux/can/j1939.h" HAVE_LINUX_CAN_J1939_H) +check_include_files("${LINUX_CAN_HEADERS};linux/can/raw.h" HAVE_LINUX_CAN_RAW_H) +check_include_files("${LINUX_CAN_HEADERS};netcan/can.h" HAVE_NETCAN_CAN_H) # Python 3.11 + +set(LINUX_VM_SOCKETS_HEADERS) +add_cond(LINUX_VM_SOCKETS_HEADERS HAVE_SYS_SOCKET_H sys/socket.h) +check_include_files("${LINUX_VM_SOCKETS_HEADERS};linux/vm_sockets.h" HAVE_LINUX_VM_SOCKETS_H) + +check_include_files(mach-o/dyld.h HAVE_MACH_O_DYLD_H) +check_include_files(memory.h HAVE_MEMORY_H) # libffi and cpython +check_include_files(minix/config.h HAVE_MINIX_CONFIG_H) +check_include_files(ncurses.h HAVE_NCURSES_H) +check_include_files(ncurses/panel.h HAVE_NCURSES_PANEL_H) +check_include_files(netdb.h HAVE_NETDB_H) +check_include_files(net/ethernet.h HAVE_NET_ETHERNET_H) # Python 3.12 +check_include_files(netinet/in.h HAVE_NETINET_IN_H) +check_include_files(netpacket/packet.h HAVE_NETPACKET_PACKET_H) +check_include_files(panel.h HAVE_PANEL_H) +check_include_files(poll.h HAVE_POLL_H) +check_include_files(process.h HAVE_PROCESS_H) +check_include_files(pthread.h HAVE_PTHREAD_H) +check_include_files(pty.h HAVE_PTY_H) +check_include_files(pwd.h HAVE_PWD_H) +if(USE_LIBEDIT) + check_include_files("stdio.h;editline/readline.h" HAVE_READLINE_READLINE_H) +else() + check_include_files("stdio.h;readline/readline.h" HAVE_READLINE_READLINE_H) +endif() +check_include_files(semaphore.h HAVE_SEMAPHORE_H) +check_include_files(setjmp.h HAVE_SETJMP_H) # Python 3.11 +check_include_files(shadow.h HAVE_SHADOW_H) +check_include_files(signal.h HAVE_SIGNAL_H) +check_include_files(spawn.h HAVE_SPAWN_H) +check_include_files(stdint.h HAVE_STDINT_H) # libffi and cpython +check_include_files(stdio.h HAVE_STDIO_H) # Python 3.12 +check_include_files(stdlib.h HAVE_STDLIB_H) # libffi and cpython +check_include_files(strings.h HAVE_STRINGS_H) # libffi and cpython +check_include_files(string.h HAVE_STRING_H) # libffi and cpython +check_include_files(stropts.h HAVE_STROPTS_H) +check_include_files(sysexits.h HAVE_SYSEXITS_H) +check_include_files(syslog.h HAVE_SYSLOG_H) # Python 3.11 +check_include_files(sys/audioio.h HAVE_SYS_AUDIOIO_H) +check_include_files(sys/auxv.h HAVE_SYS_AUXV_H) # Python 3.10 +check_include_files(sys/bsdtty.h HAVE_SYS_BSDTTY_H) +check_include_files(sys/epoll.h HAVE_SYS_EPOLL_H) +check_include_files(sys/eventfd.h HAVE_SYS_EVENTFD_H) # Python 3.10 +check_include_files(sys/event.h HAVE_SYS_EVENT_H) +check_include_files(sys/file.h HAVE_SYS_FILE_H) +check_include_files(sys/loadavg.h HAVE_SYS_LOADAVG_H) +check_include_files(sys/lock.h HAVE_SYS_LOCK_H) +check_include_files(sys/sysmacros.h HAVE_SYS_SYSMACROS_H) +set(MAJOR_IN_SYSMACROS ${HAVE_SYS_SYSMACROS_H}) +check_include_files(sys/mkdev.h HAVE_SYS_MKDEV_H) +set(MAJOR_IN_MKDEV ${HAVE_SYS_MKDEV_H}) +check_include_files(sys/mman.h HAVE_SYS_MMAN_H) # libffi and cpython +check_include_files(sys/modem.h HAVE_SYS_MODEM_H) +check_include_files(sys/param.h HAVE_SYS_PARAM_H) +check_include_files(sys/pidfd.h HAVE_SYS_PIDFD_H) # Python 3.12 +check_include_files(sys/poll.h HAVE_SYS_POLL_H) +check_include_files(sys/random.h HAVE_SYS_RANDOM_H) +check_include_files(sys/resource.h HAVE_SYS_RESOURCE_H) +check_include_files(sys/select.h HAVE_SYS_SELECT_H) +check_include_files(sys/statvfs.h HAVE_SYS_STATVFS_H) +check_include_files(sys/stat.h HAVE_SYS_STAT_H) # libffi and cpython +check_include_files(sys/timeb.h HAVE_SYS_TIMEB_H) +check_include_files(sys/termio.h HAVE_SYS_TERMIO_H) +check_include_files(sys/times.h HAVE_SYS_TIMES_H) +check_include_files(sys/time.h HAVE_SYS_TIME_H) +check_include_files(sys/types.h HAVE_SYS_TYPES_H) # libffi and cpython +check_include_files(sys/un.h HAVE_SYS_UN_H) +check_include_files(sys/utsname.h HAVE_SYS_UTSNAME_H) +check_include_files(sys/wait.h HAVE_SYS_WAIT_H) +check_include_files(termios.h HAVE_TERMIOS_H) +check_include_files(term.h HAVE_TERM_H) +check_include_files(unistd.h HAVE_UNISTD_H) # libffi and cpython +check_include_files(util.h HAVE_UTIL_H) +check_include_files(utime.h HAVE_UTIME_H) +check_include_files(utmp.h HAVE_UTMP_H) # Python 3.11 +check_include_files(wchar.h HAVE_WCHAR_H) +check_include_files("stdlib.h;stdarg.h;string.h;float.h" STDC_HEADERS) # libffi and cpython + +check_include_files(stdarg.h HAVE_STDARG_PROTOTYPES) + +check_include_files(endian.h HAVE_ENDIAN_H) +check_include_files(sched.h HAVE_SCHED_H) +check_include_files(linux/fs.h HAVE_LINUX_FS_H) # Python 3.12 +check_include_files(linux/limits.h HAVE_LINUX_LIMITS_H) # Python 3.11 +check_include_files(linux/memfd.h HAVE_LINUX_MEMFD_H) +check_include_files(linux/random.h HAVE_LINUX_RANDOM_H) +check_include_files(linux/soundcard.h HAVE_LINUX_SOUNDCARD_H) # Python 3.11 +check_include_files(linux/wait.h HAVE_LINUX_WAIT_H) +check_include_files(sys/devpoll.h HAVE_SYS_DEVPOLL_H) +check_include_files(sys/endian.h HAVE_SYS_ENDIAN_H) +check_include_files(sys/ioctl.h HAVE_SYS_IOCTL_H) +check_include_files(sys/memfd.h HAVE_SYS_MEMFD_H) +check_include_files("sys/types.h;sys/kern_control.h" HAVE_SYS_KERN_CONTROL_H) +check_include_files(sys/sendfile.h HAVE_SYS_SENDFILE_H) +check_include_files(sys/syscall.h HAVE_SYS_SYSCALL_H) +check_include_files(sys/sys_domain.h HAVE_SYS_SYS_DOMAIN_H) +check_include_files(sys/uio.h HAVE_SYS_UIO_H) +check_include_files(sys/xattr.h HAVE_SYS_XATTR_H) + +# On Darwin (OS X) net/if.h requires sys/socket.h to be imported first. +set(NET_IF_HEADERS stdio.h) +if(STDC_HEADERS) + set(NET_IF_HEADERS stdlib.h stddef.h) +else() + add_cond(NET_IF_HEADERS HAVE_STDLIB_H stdlib.h) +endif() +add_cond(NET_IF_HEADERS HAVE_SYS_SOCKET_H sys/socket.h) +list(APPEND NET_IF_HEADERS net/if.h) +check_include_files("${NET_IF_HEADERS}" HAVE_NET_IF_H) + +find_file(HAVE_DEV_PTMX NAMES /dev/ptmx PATHS / NO_DEFAULT_PATH) +find_file(HAVE_DEV_PTC NAMES /dev/ptc PATHS / NO_DEFAULT_PATH) +message(STATUS "ptmx: ${HAVE_DEV_PTMX} ptc: ${HAVE_DEV_PTC}") + +find_library(HAVE_LIBCURSES curses) +find_library(HAVE_LIBCRYPT crypt) +if(NOT DEFINED HAVE_LIBDL) + set(HAVE_LIBDL ${CMAKE_DL_LIBS} CACHE STRING "Name of library containing dlopen and dlcose.") +endif() +find_library(HAVE_LIBDLD dld) +find_library(HAVE_LIBINTL intl) + +set(M_LIBRARIES ) +check_function_exists("acosh" HAVE_BUILTIN_ACOSH) +if(HAVE_BUILTIN_ACOSH) + # Math functions are builtin the environment (e.g emscripten) + set(M_LIBRARIES ) + set(HAVE_LIBM 1) +else() + find_library(HAVE_LIBM m) + set(M_LIBRARIES ${HAVE_LIBM}) +endif() + +find_library(HAVE_LIBNCURSES ncurses) +find_library(HAVE_LIBNSL nsl) +if(USE_LIBEDIT) + find_library(HAVE_LIBREADLINE edit) +else() + find_library(HAVE_LIBREADLINE readline) +endif() +find_library(HAVE_LIBSENDFILE sendfile) +find_library(HAVE_LIBTERMCAP termcap) + +set(LIBUTIL_LIBRARIES ) +set(LIBUTIL_EXPECTED 1) + +if(CMAKE_SYSTEM MATCHES "VxWorks\\-7$") + set(LIBUTIL_EXPECTED 0) + set(HAVE_LIBUTIL 0) +endif() + +if(LIBUTIL_EXPECTED) + check_function_exists("openpty" HAVE_BUILTIN_OPENPTY) + if(HAVE_BUILTIN_OPENPTY) + # Libutil functions are builtin the environment (e.g emscripten) + set(LIBUTIL_LIBRARIES ) + set(HAVE_LIBUTIL 1) + else() + if(NOT DEFINED HAVE_LIBUTIL OR "${HAVE_LIBUTIL}" STREQUAL "") + find_library(HAVE_LIBUTIL util) + message(STATUS "Found libutil: ${HAVE_LIBUTIL}") + endif() + if(HAVE_LIBUTIL) + set(LIBUTIL_LIBRARIES ${HAVE_LIBUTIL}) + endif() + endif() + if(NOT HAVE_LIBUTIL) + message(FATAL_ERROR "Could NOT find libutil (missing: HAVE_LIBUTIL)") + endif() +endif() + +if(APPLE) + find_library(HAVE_LIBCOREFOUNDATION CoreFoundation) + find_library(HAVE_LIBSYSTEMCONFIGURATION SystemConfiguration) +endif() + +if(WITH_THREAD OR PY_VERSION VERSION_GREATER_EQUAL "3.7") + set(CMAKE_HAVE_PTHREAD_H ${HAVE_PTHREAD_H}) # Skip checking for header a second time. + find_package(Threads) + if(CMAKE_HAVE_LIBC_CREATE) + set_required_def(_REENTRANT 1) + endif() +endif() + +if(WITH_VALGRIND AND PY_VERSION VERSION_GREATER_EQUAL "3.10") + check_include_files(valgrind/valgrind.h HAVE_VALGRIND_VALGRIND_H) + if(NOT HAVE_VALGRIND_VALGRIND_H) + message(FATAL_ERROR "Valgrind support requested but headers not available") + endif() + set(DYNAMIC_ANNOTATIONS_ENABLED 1) +else() + set(DYNAMIC_ANNOTATIONS_ENABLED 0) +endif() + +set(check_src ${PROJECT_BINARY_DIR}/CMakeFiles/ac_cv_lib_crypto_RAND_egd.c) +file(WRITE ${check_src} "/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern \"C\" +#endif +char RAND_egd (); +int main () { return RAND_egd (); } +") +cmake_push_check_state() +list(APPEND CMAKE_REQUIRED_LIBRARIES crypto) +python_platform_test( + HAVE_RAND_EGD + "Checking for RAND_egd in -lcrypto" + ${check_src} + DIRECT + ) +cmake_pop_check_state() + +set_required_def(_POSIX_THREADS 1) # Define on Linux as it is required for threading +set_required_def(_POSIX_SOURCE 1) # Define on Linux in order for 'stat' and other things to work. +set_required_def(_GNU_SOURCE 1) # Define on Linux to activate all library features +set_required_def(_NETBSD_SOURCE 1) # Define on NetBSD to activate all library features +set_required_def(__BSD_VISIBLE 1) # Define on FreeBSD to activate all library features +set_required_def(_BSD_TYPES 1) # Define on Irix to enable u_int +set_required_def(_DARWIN_C_SOURCE 1) # Define on Darwin to activate all library features + +set_required_def(_ALL_SOURCE 1) # Enable extensions on AIX 3, Interix. +set_required_def(_POSIX_PTHREAD_SEMANTICS 1) # Enable threading extensions on Solaris. +set_required_def(_TANDEM_SOURCE 1) # Enable extensions on HP NonStop. + +set_required_def(__EXTENSIONS__ 1) # Defined on Solaris to see additional function prototypes. + + +if(HAVE_MINIX_CONFIG_H) + set_required_def(_POSIX_1_SOURCE 2) # Define to 2 if the system does not provide POSIX.1 features except with this defined. + set_required_def(_MINIX 1) # Define to 1 if on MINIX. +endif() + +message(STATUS "Checking for XOPEN_SOURCE") + +# Some systems cannot stand _XOPEN_SOURCE being defined at all; they +# disable features if it is defined, without any means to access these +# features as extensions. For these systems, we skip the definition of +# _XOPEN_SOURCE. Before adding a system to the list to gain access to +# some feature, make sure there is no alternative way to access this +# feature. Also, when using wildcards, make sure you have verified the +# need for not defining _XOPEN_SOURCE on all systems matching the +# wildcard, and that the wildcard does not include future systems +# (which may remove their limitations). +set(define_xopen_source 1) + +# On OpenBSD, select(2) is not available if _XOPEN_SOURCE is defined, +# even though select is a POSIX function. Reported by J. Ribbens. +# Reconfirmed for OpenBSD 3.3 by Zachary Hamm, for 3.4 by Jason Ish. +# In addition, Stefan Krah confirms that issue #1244610 exists through +# OpenBSD 4.6, but is fixed in 4.7. +if(CMAKE_SYSTEM MATCHES "OpenBSD\\-2\\." + OR CMAKE_SYSTEM MATCHES "OpenBSD\\-3\\." + OR CMAKE_SYSTEM MATCHES "OpenBSD\\-4\\.[0-6]$") + + #OpenBSD/2.* | OpenBSD/3.* | OpenBSD/4.@<:@0123456@:>@ + + set(define_xopen_source 0) + + # OpenBSD undoes our definition of __BSD_VISIBLE if _XOPEN_SOURCE is + # also defined. This can be overridden by defining _BSD_SOURCE + # As this has a different meaning on Linux, only define it on OpenBSD + set_required_def(_BSD_SOURCE 1) # Define on OpenBSD to activate all library features + +elseif(CMAKE_SYSTEM MATCHES OpenBSD) + + # OpenBSD/* + + # OpenBSD undoes our definition of __BSD_VISIBLE if _XOPEN_SOURCE is + # also defined. This can be overridden by defining _BSD_SOURCE + # As this has a different meaning on Linux, only define it on OpenBSD + set_required_def(_BSD_SOURCE 1) # Define on OpenBSD to activate all library features + +elseif(CMAKE_SYSTEM MATCHES "NetBSD\\-1\\.5$" + OR CMAKE_SYSTEM MATCHES "NetBSD\\-1\\.5\\." + OR CMAKE_SYSTEM MATCHES "NetBSD\\-1\\.6$" + OR CMAKE_SYSTEM MATCHES "NetBSD\\-1\\.6\\." + OR CMAKE_SYSTEM MATCHES "NetBSD\\-1\\.6[A-S]$") + + # NetBSD/1.5 | NetBSD/1.5.* | NetBSD/1.6 | NetBSD/1.6.* | NetBSD/1.6@<:@A-S@:>@ + + # Defining _XOPEN_SOURCE on NetBSD version prior to the introduction of + # _NETBSD_SOURCE disables certain features (eg. setgroups). Reported by + # Marc Recht + set(define_xopen_source 0) + +elseif(CMAKE_SYSTEM MATCHES SunOS) + + # SunOS/*) + + # From the perspective of Solaris, _XOPEN_SOURCE is not so much a + # request to enable features supported by the standard as a request + # to disable features not supported by the standard. The best way + # for Python to use Solaris is simply to leave _XOPEN_SOURCE out + # entirely and define __EXTENSIONS__ instead. + + set(define_xopen_source 0) + +elseif(CMAKE_SYSTEM MATCHES "OpenUNIX\\-8\\.0\\.0$" + OR CMAKE_SYSTEM MATCHES "UnixWare\\-7\\.1\\.[0-4]$") + + # OpenUNIX/8.0.0| UnixWare/7.1.@<:@0-4@:>@ + + # On UnixWare 7, u_long is never defined with _XOPEN_SOURCE, + # but used in /usr/include/netinet/tcp.h. Reported by Tim Rice. + # Reconfirmed for 7.1.4 by Martin v. Loewis. + + set(define_xopen_source 0) + +elseif(CMAKE_SYSTEM MATCHES "SCO_SV\\-3\\.2$") + + # SCO_SV/3.2 + + # On OpenServer 5, u_short is never defined with _XOPEN_SOURCE, + # but used in struct sockaddr.sa_family. Reported by Tim Rice. + + set(define_xopen_source 0) + +elseif(CMAKE_SYSTEM MATCHES "FreeBSD\\-4\\.") + + # FreeBSD/4.* + + # On FreeBSD 4, the math functions C89 does not cover are never defined + # with _XOPEN_SOURCE and __BSD_VISIBLE does not re-enable them. + + set(define_xopen_source 0) + +elseif(CMAKE_SYSTEM MATCHES "Darwin\\-[6789]\\." + OR CMAKE_SYSTEM MATCHES "Darwin\\-1[0-9]\\.") + + # Darwin/@<:@6789@:>@.*) + # Darwin/1@<:@0-9@:>@.* + + # On MacOS X 10.2, a bug in ncurses.h means that it craps out if + # _XOPEN_EXTENDED_SOURCE is defined. Apparently, this is fixed in 10.3, which + # identifies itself as Darwin/7.* + # On Mac OS X 10.4, defining _POSIX_C_SOURCE or _XOPEN_SOURCE + # disables platform specific features beyond repair. + # On Mac OS X 10.3, defining _POSIX_C_SOURCE or _XOPEN_SOURCE + # has no effect, don't bother defining them + + set(define_xopen_source 0) + +elseif(CMAKE_SYSTEM MATCHES "AIX\\-4$" + OR CMAKE_SYSTEM MATCHES "AIX\\-5\\.1$") + # On AIX 4 and 5.1, mbstate_t is defined only when _XOPEN_SOURCE == 500 but + # used in wcsnrtombs() and mbsnrtowcs() even if _XOPEN_SOURCE is not defined + # or has another value. By not (re)defining it, the defaults come in place. + + set(define_xopen_source 0) + +elseif(CMAKE_SYSTEM MATCHES "QNX\\-6\\.3\\.2$") + + # QNX/6.3.2 + + # On QNX 6.3.2, defining _XOPEN_SOURCE prevents netdb.h from + # defining NI_NUMERICHOST. + + set(define_xopen_source 0) + +elseif(CMAKE_SYSTEM MATCHES "VxWorks\\-7$") + + # VxWorks-7 + + # On VxWorks-7, defining _XOPEN_SOURCE or _POSIX_C_SOURCE + # leads to a failure in select.h because sys/types.h fails + # to define FD_SETSIZE. + # Reported by Martin Oberhuber as V7COR-4651. + + set(define_xopen_source 0) + +endif() + +if(define_xopen_source) + message(STATUS "Checking for XOPEN_SOURCE - yes") + set_required_def(_XOPEN_SOURCE_EXTENDED 1) # Define to activate Unix95-and-earlier features + set_required_def(_XOPEN_SOURCE 700) # Define to the level of X/Open that your system supports + set_required_def(_POSIX_C_SOURCE 200809L) # Define to activate features from IEEE Stds 1003.1-2008 +else() + message(STATUS "Checking for XOPEN_SOURCE - no") +endif() + + +message(STATUS "Checking for Large File Support") +set(use_lfs 1) # Consider disabling "lfs" if porting to Solaris (2.6 to 9) with gcc 2.95. + # See associated test in configure.in +if(use_lfs) + message(STATUS "Checking for Large File Support - yes") + if(CMAKE_SYSTEM MATCHES AIX) + set_required_def(_LARGE_FILES 1) # This must be defined on AIX systems to enable large file support. + endif() + set_required_def(_LARGEFILE_SOURCE 1) # This must be defined on some systems to enable large file support. + set_required_def(_FILE_OFFSET_BITS 64) # This must be set to 64 on some systems to enable large file support. +else() + message(STATUS "Checking for Large File Support - no") +endif() + +# CMAKE_EXTRA_INCLUDE_FILES is used in CheckTypeSize +set(CMAKE_EXTRA_INCLUDE_FILES stdio.h) + +add_cond(CMAKE_REQUIRED_LIBRARIES HAVE_LIBM "${M_LIBRARIES}") +add_cond(CMAKE_REQUIRED_LIBRARIES HAVE_LIBINTL ${HAVE_LIBINTL}) +add_cond(CMAKE_REQUIRED_LIBRARIES HAVE_LIBUTIL "${LIBUTIL_LIBRARIES}") +add_cond(CMAKE_EXTRA_INCLUDE_FILES HAVE_WCHAR_H wchar.h) + +TEST_BIG_ENDIAN(WORDS_BIGENDIAN) + +# Checking whether float word ordering is bigendian +if(NOT FLOAT_WORDS_BIGENDIAN_COMPILED) + set(description "Checking whether float word ordering is bigendian") + message(STATUS "${description}") + + set(check_executable ${PROJECT_BINARY_DIR}/CMakeFiles/ax_cv_c_float_words_bigendian) + set(check_src ${PROJECT_BINARY_DIR}/CMakeFiles/ax_cv_c_float_words_bigendian.c) + file(WRITE ${check_src} [==[#include + static double m[] = {9.090423496703681e+223, 0.0}; + int main (int argc, char *argv[]) + { + m[atoi (argv[1])] += atof (argv[2]); + return m[atoi (argv[3])] > 0.0; + } + ]==] + ) + try_compile(FLOAT_WORDS_BIGENDIAN_COMPILED + ${CMAKE_CURRENT_BINARY_DIR} + ${check_src} + COPY_FILE ${check_executable} + ) + if(NOT FLOAT_WORDS_BIGENDIAN_COMPILED) + message(WARNING "Failed to compile FLOAT_WORDS_BIGENDIAN executable") + else() + file(STRINGS ${check_executable} output REGEX "(noonsees|seesnoon)") + if("${output}" STREQUAL "noonsees") + message(STATUS "${description} - yes") + set(FLOAT_WORDS_BIGENDIAN 1) + elseif("${output}" STREQUAL "seesnoon") + message(STATUS "${description} - no") + set(FLOAT_WORDS_BIGENDIAN 0) + endif() + endif() + if(NOT DEFINED FLOAT_WORDS_BIGENDIAN) + message(FATAL_ERROR "Unknown float word ordering. You need to manually set FLOAT_WORDS_BIGENDIAN CMake option to 0 or 1 according to your system.") + endif() +endif() + +# Assume C89 semantics that RETSIGTYPE is always void +set(RETSIGTYPE "void") + +check_type_size(double SIZEOF_DOUBLE) # libffi and cpython +check_type_size(float SIZEOF_FLOAT) +check_type_size(fpos_t SIZEOF_FPOS_T) +check_type_size(int SIZEOF_INT) +check_type_size(long SIZEOF_LONG) +check_type_size("long double" SIZEOF_LONG_DOUBLE) +set(HAVE_LONG_DOUBLE ${SIZEOF_LONG_DOUBLE}) # libffi and cpython +check_type_size("long long" SIZEOF_LONG_LONG) +set(HAVE_LONG_LONG ${SIZEOF_LONG_LONG}) +check_type_size(off_t SIZEOF_OFF_T) +check_type_size(pid_t SIZEOF_PID_T) +check_type_size(pthread_t SIZEOF_PTHREAD_T) +check_type_size(short SIZEOF_SHORT) +check_type_size(size_t SIZEOF_SIZE_T) +check_type_size(ssize_t HAVE_SSIZE_T) +check_type_size(time_t SIZEOF_TIME_T) +check_type_size(uintptr_t SIZEOF_UINTPTR_T) +set(HAVE_UINTPTR_T ${SIZEOF_UINTPTR_T}) +check_type_size("void *" SIZEOF_VOID_P) +check_type_size(wchar_t SIZEOF_WCHAR_T) +check_type_size(_Bool SIZEOF__BOOL) + +function(_check_type_alignof type) + string(TOUPPER "${type}" type_upper) + + if(NOT DEFINED ALIGNOF_${type_upper}) + foreach(alignment IN ITEMS 1 2 4 8 16 32 64) + set(check_src "${PROJECT_BINARY_DIR}/CMakeFiles/check_alignof_${type}_${alignment}.c") + file(WRITE "${check_src}" " + #include // For alignof + #include // For max_align_t + _Static_assert(alignof(${type}) == ${alignment}, \"alignof(${type}) != ${alignment}\"); + int main(void) { return 0; } + ") + try_compile(ALIGNOF_${type_upper}_${alignment}_COMPILED + "${CMAKE_CURRENT_BINARY_DIR}" + "${check_src}" + C_STANDARD 11 + ) + + set(description "Checking alignof(${type}) == ${alignment}") + message(STATUS "${description}") + + if(ALIGNOF_${type_upper}_${alignment}_COMPILED) + message(STATUS "${description} - yes") + set(ALIGNOF_${type_upper} ${alignment} CACHE INTERNAL "Detected alignment of ${type}") + break() + else() + message(STATUS "${description} - no") + endif() + endforeach() + endif() +endfunction() + +_check_type_alignof(long) # Python 3.10 +_check_type_alignof(size_t) # Python 3.10 +_check_type_alignof(max_align_t) # Python 3.12 + +set(HAVE_C99_BOOL ${SIZEOF__BOOL}) + +# libffi specific: Check whether more than one size of the long double type is supported +# TODO +set(HAVE_LONG_DOUBLE_VARIANT 0) + +# TODO Improve AIX support setting AIX_GENUINE_CPLUSPLUS and AIX_BUILDDATE +# See https://github.com/python-cmake-buildsystem/python-cmake-buildsystem/issues/296 +set(AIX_GENUINE_CPLUSPLUS 0) + +set(WITH_DYLD 0) +set(WITH_NEXT_FRAMEWORK 0) +if(APPLE) + set(WITH_DYLD 1) + set(WITH_NEXT_FRAMEWORK 0) # TODO: See --enable-framework option. +endif() +set(PYTHONFRAMEWORK "") + +if(HAVE_LONG_LONG) + if(SIZEOF_OFF_T GREATER SIZEOF_LONG + AND (SIZEOF_LONG_LONG GREATER SIZEOF_OFF_T OR SIZEOF_LONG_LONG EQUAL SIZEOF_OFF_T)) + set(HAVE_LARGEFILE_SUPPORT 1) + endif() + +endif() + +set(WITH_FREELISTS 0) +if(PY_VERSION VERSION_GREATER_EQUAL "3.11") + set(WITH_FREELISTS 1) +endif() + + +set(CFG_HEADERS ) + +add_cond(CFG_HEADERS HAVE_SYS_EPOLL_H sys/epoll.h) +add_cond(CFG_HEADERS HAVE_SYS_EVENTFD_H sys/eventfd.h) +add_cond(CFG_HEADERS HAVE_SYS_EVENT_H sys/event.h) +add_cond(CFG_HEADERS HAVE_SYS_RANDOM_H sys/random.h) +add_cond(CFG_HEADERS HAVE_SYS_SYSMACROS_H sys/sysmacros.h) +add_cond(CFG_HEADERS HAVE_SYS_TYPES_H sys/types.h) +add_cond(CFG_HEADERS HAVE_SYS_TIME_H sys/time.h) +add_cond(CFG_HEADERS HAVE_SYS_FILE_H sys/file.h) +add_cond(CFG_HEADERS HAVE_SYS_PIDFD_H sys/pidfd.h) +add_cond(CFG_HEADERS HAVE_SYS_POLL_H sys/poll.h) +add_cond(CFG_HEADERS HAVE_SYS_STATVFS_H sys/statvfs.h) +add_cond(CFG_HEADERS HAVE_SYS_STAT_H sys/stat.h) +add_cond(CFG_HEADERS HAVE_SYS_LOCK_H sys/lock.h) +add_cond(CFG_HEADERS HAVE_SYS_TIMEB_H sys/timeb.h) +add_cond(CFG_HEADERS HAVE_SYS_TIMES_H sys/times.h) +add_cond(CFG_HEADERS HAVE_SYS_UIO_H sys/uio.h) +add_cond(CFG_HEADERS HAVE_SYS_UTSNAME_H sys/utsname.h) +add_cond(CFG_HEADERS HAVE_SYS_MMAN_H sys/mman.h) +add_cond(CFG_HEADERS HAVE_SYS_SOCKET_H sys/socket.h) +add_cond(CFG_HEADERS HAVE_SYS_WAIT_H sys/wait.h) +add_cond(CFG_HEADERS HAVE_PWD_H pwd.h) +add_cond(CFG_HEADERS HAVE_GRP_H grp.h) +add_cond(CFG_HEADERS HAVE_SHADOW_H shadow.h) +add_cond(CFG_HEADERS HAVE_INTTYPES_H inttypes.h) +add_cond(CFG_HEADERS HAVE_LOCALE_H locale.h) +add_cond(CFG_HEADERS HAVE_LIBINTL_H libintl.h) +add_cond(CFG_HEADERS HAVE_FCNTL_H fcntl.h) +add_cond(CFG_HEADERS HAVE_PTY_H pty.h) +add_cond(CFG_HEADERS HAVE_SIGNAL_H signal.h) +add_cond(CFG_HEADERS HAVE_STDINT_H stdint.h) +add_cond(CFG_HEADERS HAVE_STDIO_H stdio.h) +add_cond(CFG_HEADERS HAVE_STDLIB_H stdlib.h) +add_cond(CFG_HEADERS HAVE_STRING_H string.h) +add_cond(CFG_HEADERS HAVE_UTIL_H util.h) +add_cond(CFG_HEADERS HAVE_UNISTD_H unistd.h) +add_cond(CFG_HEADERS HAVE_UTIME_H utime.h) +add_cond(CFG_HEADERS HAVE_WCHAR_H wchar.h) +add_cond(CFG_HEADERS HAVE_DIRENT_H dirent.h) +add_cond(CFG_HEADERS HAVE_ENDIAN_H endian.h) +add_cond(CFG_HEADERS HAVE_LINUX_MEMFD_H linux/memfd.h) +add_cond(CFG_HEADERS HAVE_LINUX_WAIT_H linux/wait.h) +add_cond(CFG_HEADERS HAVE_MACH_O_DYLD_H mach-o/dyld.h) +add_cond(CFG_HEADERS HAVE_NET_IF_H net/if.h) +add_cond(CFG_HEADERS HAVE_SCHED_H sched.h) +add_cond(CFG_HEADERS HAVE_SPAWN_H spawn.h) +add_cond(CFG_HEADERS HAVE_SYS_ENDIAN_H sys/endian.h) +add_cond(CFG_HEADERS HAVE_SYS_MEMFD_H sys/memfd.h) +add_cond(CFG_HEADERS HAVE_SYS_RESOURCE_H sys/resource.h) +add_cond(CFG_HEADERS HAVE_SYS_SENDFILE_H sys/sendfile.h) +add_cond(CFG_HEADERS HAVE_SYS_TIME_H sys/time.h) + +if(HAVE_PTY_H) + set(CFG_HEADERS ${CFG_HEADERS} pty.h utmp.h) +endif() + +set(CFG_HEADERS ${CFG_HEADERS} time.h stdio.h math.h) + +check_symbol_exists(alarm "${CFG_HEADERS}" HAVE_ALARM) +check_symbol_exists(alloca "${CFG_HEADERS}" HAVE_ALLOCA) # libffi and cpython +check_symbol_exists(altzone "${CFG_HEADERS}" HAVE_ALTZONE) +check_symbol_exists(bind "${CFG_HEADERS}" HAVE_BIND) # Python 3.11 +check_symbol_exists(bind_textdomain_codeset "${CFG_HEADERS}" HAVE_BIND_TEXTDOMAIN_CODESET) +check_symbol_exists(chflags "${CFG_HEADERS}" HAVE_CHFLAGS) +check_symbol_exists(chmod "${CFG_HEADERS}" HAVE_CHMOD) # Python 3.11 +check_symbol_exists(chown "${CFG_HEADERS}" HAVE_CHOWN) +check_symbol_exists(chroot "${CFG_HEADERS}" HAVE_CHROOT) +check_symbol_exists(clock "${CFG_HEADERS}" HAVE_CLOCK) +check_symbol_exists(confstr "${CFG_HEADERS}" HAVE_CONFSTR) +check_symbol_exists(connect "${CFG_HEADERS}" HAVE_CONNECT) # Python 3.11 +check_symbol_exists(ctermid "${CFG_HEADERS}" HAVE_CTERMID) +check_symbol_exists(ctermid_r "${CFG_HEADERS}" HAVE_CTERMID_R) +check_symbol_exists(dup "${CFG_HEADERS}" HAVE_DUP) # Python 3.11 +check_symbol_exists(dup2 "${CFG_HEADERS}" HAVE_DUP2) +check_symbol_exists(epoll_create "${CFG_HEADERS}" HAVE_EPOLL) +check_symbol_exists(epoll_create1 "${CFG_HEADERS}" HAVE_EPOLL_CREATE1) +check_symbol_exists(execv "${CFG_HEADERS}" HAVE_EXECV) +check_symbol_exists(fchdir "${CFG_HEADERS}" HAVE_FCHDIR) +check_symbol_exists(fchmod "${CFG_HEADERS}" HAVE_FCHMOD) +check_symbol_exists(fchown "${CFG_HEADERS}" HAVE_FCHOWN) +check_symbol_exists(fdatasync "${CFG_HEADERS}" HAVE_FDATASYNC) +check_symbol_exists(flock "${CFG_HEADERS}" HAVE_FLOCK) +if(NOT HAVE_FLOCK) + check_library_exists(bsd flock "" FLOCK_NEEDS_LIBBSD) +endif() +check_symbol_exists(fork "${CFG_HEADERS}" HAVE_FORK) +check_symbol_exists(fork1 "${CFG_HEADERS}" HAVE_FORK1) # Python 3.11 +check_symbol_exists(forkpty "${CFG_HEADERS}" HAVE_FORKPTY) +check_symbol_exists(fpathconf "${CFG_HEADERS}" HAVE_FPATHCONF) +cmake_push_check_state() +set(CFG_HEADERS_SAVE ${CFG_HEADERS}) +add_cond(CFG_HEADERS HAVE_FPU_CONTROL_H fpu_control.h) +check_symbol_exists(__fpu_control "${CFG_HEADERS}" HAVE___FPU_CONTROL) +if(NOT HAVE___FPU_CONTROL) + check_library_exists(ieee __fpu_control "" HAVE_LIBIEEE) +endif() +set(CFG_HEADERS ${CFG_HEADERS_SAVE}) +cmake_pop_check_state() +check_symbol_exists(fseek64 "${CFG_HEADERS}" HAVE_FSEEK64) +check_symbol_exists(fseeko "${CFG_HEADERS}" HAVE_FSEEKO) +check_symbol_exists(fstatvfs "${CFG_HEADERS}" HAVE_FSTATVFS) +check_symbol_exists(fsync "${CFG_HEADERS}" HAVE_FSYNC) +check_symbol_exists(ftell64 "${CFG_HEADERS}" HAVE_FTELL64) +check_symbol_exists(ftello "${CFG_HEADERS}" HAVE_FTELLO) +check_symbol_exists(ftime "${CFG_HEADERS}" HAVE_FTIME) +check_symbol_exists(ftruncate "${CFG_HEADERS}" HAVE_FTRUNCATE) +check_symbol_exists(getc_unlocked "${CFG_HEADERS}" HAVE_GETC_UNLOCKED) +check_symbol_exists(getegid "${CFG_HEADERS}" HAVE_GETEGID) # Python 3.11 +check_symbol_exists(geteuid "${CFG_HEADERS}" HAVE_GETEUID) # Python 3.11 +check_symbol_exists(getgid "${CFG_HEADERS}" HAVE_GETGID) # Python 3.11 +check_symbol_exists(getgroups "${CFG_HEADERS}" HAVE_GETGROUPS) +check_symbol_exists(getitimer "${CFG_HEADERS}" HAVE_GETITIMER) +check_symbol_exists(getloadavg "${CFG_HEADERS}" HAVE_GETLOADAVG) +check_symbol_exists(getlogin "${CFG_HEADERS}" HAVE_GETLOGIN) +check_symbol_exists(getpagesize "${CFG_HEADERS}" HAVE_GETPAGESIZE) +check_symbol_exists(getpgid "${CFG_HEADERS}" HAVE_GETPGID) +check_symbol_exists(getpgrp "${CFG_HEADERS}" HAVE_GETPGRP) +check_symbol_exists(getpid "${CFG_HEADERS}" HAVE_GETPID) +check_symbol_exists(getppid "${CFG_HEADERS}" HAVE_GETPPID) # Python 3.11 +python_check_function(getpriority HAVE_GETPRIORITY) +check_symbol_exists(getpwent "${CFG_HEADERS}" HAVE_GETPWENT) +check_symbol_exists(getresgid "${CFG_HEADERS}" HAVE_GETRESGID) +check_symbol_exists(getresuid "${CFG_HEADERS}" HAVE_GETRESUID) +check_symbol_exists(getrusage "${CFG_HEADERS}" HAVE_GETRUSAGE) # Python 3.11 +check_symbol_exists(getsid "${CFG_HEADERS}" HAVE_GETSID) +check_symbol_exists(getsockname "${CFG_HEADERS}" HAVE_GETSOCKNAME) # Python 3.11 +check_symbol_exists(getspent "${CFG_HEADERS}" HAVE_GETSPENT) +check_symbol_exists(getspnam "${CFG_HEADERS}" HAVE_GETSPNAM) +check_symbol_exists(gettimeofday "${CFG_HEADERS}" HAVE_GETTIMEOFDAY) +check_symbol_exists(getuid "${CFG_HEADERS}" HAVE_GETUID) # Python 3.11 +check_symbol_exists(getwd "${CFG_HEADERS}" HAVE_GETWD) +check_symbol_exists(hypot "${CFG_HEADERS}" HAVE_HYPOT) +check_symbol_exists(initgroups "${CFG_HEADERS}" HAVE_INITGROUPS) +check_symbol_exists(kill "${CFG_HEADERS}" HAVE_KILL) +check_symbol_exists(killpg "${CFG_HEADERS}" HAVE_KILLPG) +check_symbol_exists(kqueue "${CFG_HEADERS}" HAVE_KQUEUE) +check_symbol_exists(lchflags "${CFG_HEADERS}" HAVE_LCHFLAGS) +python_check_function(lchmod HAVE_LCHMOD) +check_symbol_exists(lchown "${CFG_HEADERS}" HAVE_LCHOWN) +check_symbol_exists(link "${CFG_HEADERS}" HAVE_LINK) +check_symbol_exists(listen "${CFG_HEADERS}" HAVE_LISTEN) # Python 3.11 +check_symbol_exists(login_tty "${CFG_HEADERS}" HAVE_LOGIN_TTY) # Python 3.11 +check_symbol_exists(lstat "${CFG_HEADERS}" HAVE_LSTAT) +check_symbol_exists(makedev "${CFG_HEADERS}" HAVE_MAKEDEV) +check_symbol_exists(memcpy "${CFG_HEADERS}" HAVE_MEMCPY) # libffi and cpython +check_symbol_exists(memmove "${CFG_HEADERS}" HAVE_MEMMOVE) +check_symbol_exists(mkfifo "${CFG_HEADERS}" HAVE_MKFIFO) +check_symbol_exists(mknod "${CFG_HEADERS}" HAVE_MKNOD) +check_symbol_exists(mktime "${CFG_HEADERS}" HAVE_MKTIME) +check_symbol_exists(mmap "${CFG_HEADERS}" HAVE_MMAP) # libffi and cpython +check_symbol_exists(mremap "${CFG_HEADERS}" HAVE_MREMAP) +check_symbol_exists(nice "${CFG_HEADERS}" HAVE_NICE) +check_symbol_exists(opendir "${CFG_HEADERS}" HAVE_OPENDIR) # Python 3.11 +check_symbol_exists(openpty "${CFG_HEADERS}" HAVE_OPENPTY) +check_symbol_exists(pathconf "${CFG_HEADERS}" HAVE_PATHCONF) +check_symbol_exists(pause "${CFG_HEADERS}" HAVE_PAUSE) +check_symbol_exists(plock "${CFG_HEADERS}" HAVE_PLOCK) +check_symbol_exists(poll "${CFG_HEADERS}" HAVE_POLL) +check_symbol_exists(putenv "${CFG_HEADERS}" HAVE_PUTENV) +check_symbol_exists(readlink "${CFG_HEADERS}" HAVE_READLINK) +check_symbol_exists(realpath "${CFG_HEADERS}" HAVE_REALPATH) +check_symbol_exists(recvfrom "${CFG_HEADERS}" HAVE_RECVFROM) # Python 3.11 +check_symbol_exists(select "${CFG_HEADERS}" HAVE_SELECT) +check_symbol_exists(sendto "${CFG_HEADERS}" HAVE_SENDTO) # Python 3.11 +check_symbol_exists(setegid "${CFG_HEADERS}" HAVE_SETEGID) +check_symbol_exists(seteuid "${CFG_HEADERS}" HAVE_SETEUID) +check_symbol_exists(setgid "${CFG_HEADERS}" HAVE_SETGID) +check_symbol_exists(setgroups "${CFG_HEADERS}" HAVE_SETGROUPS) +check_symbol_exists(setitimer "${CFG_HEADERS}" HAVE_SETITIMER) +check_symbol_exists(setlocale "${CFG_HEADERS}" HAVE_SETLOCALE) +check_symbol_exists(setpgid "${CFG_HEADERS}" HAVE_SETPGID) +check_symbol_exists(setpgrp "${CFG_HEADERS}" HAVE_SETPGRP) +check_symbol_exists(setregid "${CFG_HEADERS}" HAVE_SETREGID) +check_symbol_exists(setreuid "${CFG_HEADERS}" HAVE_SETREUID) +check_symbol_exists(setresgid "${CFG_HEADERS}" HAVE_SETRESGID) +check_symbol_exists(setresuid "${CFG_HEADERS}" HAVE_SETRESUID) +check_symbol_exists(setsid "${CFG_HEADERS}" HAVE_SETSID) +check_symbol_exists(setsockopt "${CFG_HEADERS}" HAVE_SETSOCKOPT) # Python 3.11 +check_symbol_exists(setuid "${CFG_HEADERS}" HAVE_SETUID) +check_symbol_exists(setvbuf "${CFG_HEADERS}" HAVE_SETVBUF) +check_symbol_exists(shutdown "${CFG_HEADERS}" HAVE_SHUTDOWN) # Python 3.11 +check_symbol_exists(sigaction "${CFG_HEADERS}" HAVE_SIGACTION) +check_symbol_exists(siginterrupt "${CFG_HEADERS}" HAVE_SIGINTERRUPT) +check_symbol_exists(sigrelse "${CFG_HEADERS}" HAVE_SIGRELSE) +check_symbol_exists(snprintf "${CFG_HEADERS}" HAVE_SNPRINTF) +check_symbol_exists(socket "${CFG_HEADERS}" HAVE_SOCKET) # Python 3.11 +check_symbol_exists(socketpair "${CFG_HEADERS}" HAVE_SOCKETPAIR) +check_symbol_exists(splice "${CFG_HEADERS}" HAVE_SPLICE) # Python 3.10 +check_symbol_exists(statvfs "${CFG_HEADERS}" HAVE_STATVFS) +check_symbol_exists(strdup "${CFG_HEADERS}" HAVE_STRDUP) +check_symbol_exists(strftime "${CFG_HEADERS}" HAVE_STRFTIME) +check_symbol_exists(symlink "${CFG_HEADERS}" HAVE_SYMLINK) +check_symbol_exists(sysconf "${CFG_HEADERS}" HAVE_SYSCONF) +check_symbol_exists(system "${CFG_HEADERS}" HAVE_SYSTEM) # Python 3.11 +check_symbol_exists(tcgetpgrp "${CFG_HEADERS}" HAVE_TCGETPGRP) +check_symbol_exists(tcsetpgrp "${CFG_HEADERS}" HAVE_TCSETPGRP) +check_symbol_exists(tempnam "${CFG_HEADERS}" HAVE_TEMPNAM) +check_symbol_exists(timegm "${CFG_HEADERS}" HAVE_TIMEGM) +check_symbol_exists(times "${CFG_HEADERS}" HAVE_TIMES) +check_symbol_exists(tmpfile "${CFG_HEADERS}" HAVE_TMPFILE) +check_symbol_exists(tmpnam "${CFG_HEADERS}" HAVE_TMPNAM) +check_symbol_exists(tmpnam_r "${CFG_HEADERS}" HAVE_TMPNAM_R) +check_symbol_exists(truncate "${CFG_HEADERS}" HAVE_TRUNCATE) +check_symbol_exists(ttyname "${CFG_HEADERS}" HAVE_TTYNAME) # Python 3.11 +check_symbol_exists(ttyname_r "${CFG_HEADERS}" HAVE_TTYNAME_R) # Python 3.12 +check_symbol_exists(umask "${CFG_HEADERS}" HAVE_UMASK) # Python 3.11 +check_symbol_exists(uname "${CFG_HEADERS}" HAVE_UNAME) +check_symbol_exists(unsetenv "${CFG_HEADERS}" HAVE_UNSETENV) +check_symbol_exists(utimes "${CFG_HEADERS}" HAVE_UTIMES) +check_symbol_exists(wait "${CFG_HEADERS}" HAVE_WAIT) # Python 3.11 +check_symbol_exists(wait3 "${CFG_HEADERS}" HAVE_WAIT3) +check_symbol_exists(wait4 "${CFG_HEADERS}" HAVE_WAIT4) +check_symbol_exists(waitpid "${CFG_HEADERS}" HAVE_WAITPID) +check_symbol_exists(wcscoll "${CFG_HEADERS}" HAVE_WCSCOLL) +check_symbol_exists(_getpty "${CFG_HEADERS}" HAVE__GETPTY) + +check_symbol_exists(accept "${CFG_HEADERS}" HAVE_ACCEPT) # Python 3.11 +check_symbol_exists(accept4 "${CFG_HEADERS}" HAVE_ACCEPT4) +check_symbol_exists(close_range "${CFG_HEADERS}" HAVE_CLOSE_RANGE) # Python 3.10 +check_symbol_exists(copy_file_range "${CFG_HEADERS}" HAVE_COPY_FILE_RANGE) +check_symbol_exists(dup3 "${CFG_HEADERS}" HAVE_DUP3) +check_symbol_exists(_dyld_shared_cache_contains_path "${CFG_HEADERS}" HAVE_DYLD_SHARED_CACHE_CONTAINS_PATH) +check_symbol_exists(explicit_bzero "${CFG_HEADERS}" HAVE_EXPLICIT_BZERO) +check_symbol_exists(explicit_memset "${CFG_HEADERS}" HAVE_EXPLICIT_MEMSET) +check_symbol_exists(eventfd "${CFG_HEADERS}" HAVE_EVENTFD) # Python 3.10 +check_symbol_exists(faccessat "${CFG_HEADERS}" HAVE_FACCESSAT) +check_symbol_exists(fchmodat "${CFG_HEADERS}" HAVE_FCHMODAT) +check_symbol_exists(fchownat "${CFG_HEADERS}" HAVE_FCHOWNAT) +check_symbol_exists(fdwalk "${CFG_HEADERS}" HAVE_FDWALK) +check_symbol_exists(fexecve "${CFG_HEADERS}" HAVE_FEXECVE) +check_symbol_exists(fdopendir "${CFG_HEADERS}" HAVE_FDOPENDIR) +check_symbol_exists(fstatat "${CFG_HEADERS}" HAVE_FSTATAT) +check_symbol_exists(futimens "${CFG_HEADERS}" HAVE_FUTIMENS) +check_symbol_exists(futimes "${CFG_HEADERS}" HAVE_FUTIMES) +check_symbol_exists(futimesat "${CFG_HEADERS}" HAVE_FUTIMESAT) +check_symbol_exists(getentropy "${CFG_HEADERS}" HAVE_GETENTROPY) +python_check_function(getpriority HAVE_GETPRIORITY) +check_symbol_exists(getgrgid "${CFG_HEADERS}" HAVE_GETGRGID) # Python 3.11 +check_symbol_exists(getgrgid_r "${CFG_HEADERS}" HAVE_GETGRGID_R) +check_symbol_exists(getgrnam_r "${CFG_HEADERS}" HAVE_GETGRNAM_R) +check_symbol_exists(getgrouplist "${CFG_HEADERS}" HAVE_GETGROUPLIST) +check_symbol_exists(getpwnam_r "${CFG_HEADERS}" HAVE_GETPWNAM_R) +check_symbol_exists(getpwuid "${CFG_HEADERS}" HAVE_GETPWUID) # Python 3.11 +check_symbol_exists(getpwuid_r "${CFG_HEADERS}" HAVE_GETPWUID_R) +check_symbol_exists(htole64 "${CFG_HEADERS}" HAVE_HTOLE64) +check_symbol_exists(if_nameindex "${CFG_HEADERS}" HAVE_IF_NAMEINDEX) +check_symbol_exists(linkat "${CFG_HEADERS}" HAVE_LINKAT) +check_symbol_exists(lockf "${CFG_HEADERS}" HAVE_LOCKF) +check_symbol_exists(lutimes "${CFG_HEADERS}" HAVE_LUTIMES) +check_symbol_exists(madvise "${CFG_HEADERS}" HAVE_MADVISE) +check_symbol_exists(mbrtowc "${CFG_HEADERS}" HAVE_MBRTOWC) +check_symbol_exists(memfd_create "${CFG_HEADERS}" HAVE_MEMFD_CREATE) +check_symbol_exists(memrchr "${CFG_HEADERS}" HAVE_MEMRCHR) +check_symbol_exists(mkdirat "${CFG_HEADERS}" HAVE_MKDIRAT) +check_symbol_exists(mkfifoat "${CFG_HEADERS}" HAVE_MKFIFOAT) +check_symbol_exists(mknodat "${CFG_HEADERS}" HAVE_MKNODAT) +check_symbol_exists(openat "${CFG_HEADERS}" HAVE_OPENAT) +check_symbol_exists(pipe "${CFG_HEADERS}" HAVE_PIPE) # Python 3.11 +check_symbol_exists(pipe2 "${CFG_HEADERS}" HAVE_PIPE2) +check_symbol_exists(posix_fadvise "${CFG_HEADERS}" HAVE_POSIX_FADVISE) +check_symbol_exists(posix_fallocate "${CFG_HEADERS}" HAVE_POSIX_FALLOCATE) +check_symbol_exists(posix_spawn "${CFG_HEADERS}" HAVE_POSIX_SPAWN) +check_symbol_exists(posix_spawnp "${CFG_HEADERS}" HAVE_POSIX_SPAWNP) +check_symbol_exists(pread "${CFG_HEADERS}" HAVE_PREAD) +check_symbol_exists(preadv "${CFG_HEADERS}" HAVE_PREADV) +check_symbol_exists(preadv2 "${CFG_HEADERS}" HAVE_PREADV2) +check_symbol_exists(prlimit "${CFG_HEADERS}" HAVE_PRLIMIT) + +cmake_push_check_state() +list(APPEND CMAKE_REQUIRED_LIBRARIES pthread) +check_symbol_exists(pthread_kill "${CFG_HEADERS}" HAVE_PTHREAD_KILL) +cmake_pop_check_state() + +check_symbol_exists(pwrite "${CFG_HEADERS}" HAVE_PWRITE) +check_symbol_exists(pwritev "${CFG_HEADERS}" HAVE_PWRITEV) +check_symbol_exists(pwritev2 "${CFG_HEADERS}" HAVE_PWRITEV2) +check_symbol_exists(readlinkat "${CFG_HEADERS}" HAVE_READLINKAT) +check_symbol_exists(readv "${CFG_HEADERS}" HAVE_READV) +check_symbol_exists(renameat "${CFG_HEADERS}" HAVE_RENAMEAT) +check_symbol_exists(rtpSpawn "${CFG_HEADERS}" HAVE_RTPSPAWN) +check_symbol_exists(sched_rr_get_interval "${CFG_HEADERS}" HAVE_SCHED_RR_GET_INTERVAL) +check_symbol_exists(sched_setaffinity "${CFG_HEADERS}" HAVE_SCHED_SETAFFINITY) +check_symbol_exists(sched_setparam "${CFG_HEADERS}" HAVE_SCHED_SETPARAM) +check_symbol_exists(sched_setscheduler "${CFG_HEADERS}" HAVE_SCHED_SETSCHEDULER) +check_symbol_exists(sendfile "${CFG_HEADERS}" HAVE_SENDFILE) +check_symbol_exists(sethostname "${CFG_HEADERS}" HAVE_SETHOSTNAME) +check_symbol_exists(setpriority "${CFG_HEADERS}" HAVE_SETPRIORITY) +check_symbol_exists(sched_get_priority_max "${CFG_HEADERS}" HAVE_SCHED_GET_PRIORITY_MAX) +check_symbol_exists(sigaltstack "${CFG_HEADERS}" HAVE_SIGALTSTACK) +check_symbol_exists(sigfillset "${CFG_HEADERS}" HAVE_SIGFILLSET) +check_symbol_exists(sigpending "${CFG_HEADERS}" HAVE_SIGPENDING) +check_symbol_exists(strsignal "${CFG_HEADERS}" HAVE_STRSIGNAL) +check_symbol_exists(sigtimedwait "${CFG_HEADERS}" HAVE_SIGTIMEDWAIT) +check_symbol_exists(sigwait "${CFG_HEADERS}" HAVE_SIGWAIT) +check_symbol_exists(sigwaitinfo "${CFG_HEADERS}" HAVE_SIGWAITINFO) +check_symbol_exists(strlcpy "${CFG_HEADERS}" HAVE_STRLCPY) +check_symbol_exists(symlinkat "${CFG_HEADERS}" HAVE_SYMLINKAT) +check_symbol_exists(sync "${CFG_HEADERS}" HAVE_SYNC) +check_symbol_exists(unlinkat "${CFG_HEADERS}" HAVE_UNLINKAT) +check_symbol_exists(utimensat "${CFG_HEADERS}" HAVE_UTIMENSAT) +check_symbol_exists(vfork "${CFG_HEADERS}" HAVE_VFORK) # Python 3.10 +check_symbol_exists(waitid "${CFG_HEADERS}" HAVE_WAITID) +check_symbol_exists(wcsftime "${CFG_HEADERS}" HAVE_WCSFTIME) +check_symbol_exists(wcsxfrm "${CFG_HEADERS}" HAVE_WCSXFRM) +check_symbol_exists(wmemcmp "${CFG_HEADERS}" HAVE_WMEMCMP) +check_symbol_exists(writev "${CFG_HEADERS}" HAVE_WRITEV) + +# check for namespace functions +check_symbol_exists(setns "${CFG_HEADERS}" HAVE_SETNS) # Python 3.12 +check_symbol_exists(unshare "${CFG_HEADERS}" HAVE_UNSHARE) # Python 3.12 + +check_struct_has_member("struct stat" st_mtim.tv_nsec "${CFG_HEADERS}" HAVE_STAT_TV_NSEC) +check_struct_has_member("struct stat" st_mtimespec.tv_nsec "${CFG_HEADERS}" HAVE_STAT_TV_NSEC2) +check_struct_has_member("struct stat" st_birthtime "${CFG_HEADERS}" HAVE_STRUCT_STAT_ST_BIRTHTIME) +check_struct_has_member("struct stat" st_blksize "${CFG_HEADERS}" HAVE_STRUCT_STAT_ST_BLKSIZE) +check_struct_has_member("struct stat" st_blocks "${CFG_HEADERS}" HAVE_STRUCT_STAT_ST_BLOCKS) +set(HAVE_ST_BLOCKS ${HAVE_STRUCT_STAT_ST_BLOCKS}) +check_struct_has_member("struct stat" st_flags "${CFG_HEADERS}" HAVE_STRUCT_STAT_ST_FLAGS) +check_struct_has_member("struct stat" st_gen "${CFG_HEADERS}" HAVE_STRUCT_STAT_ST_GEN) +check_struct_has_member("struct stat" st_rdev "${CFG_HEADERS}" HAVE_STRUCT_STAT_ST_RDEV) + +check_struct_has_member("struct passwd" pw_gecos "${CFG_HEADERS}" HAVE_STRUCT_PASSWD_PW_GECOS) +check_struct_has_member("struct passwd" pw_passwd "${CFG_HEADERS}" HAVE_STRUCT_PASSWD_PW_PASSWD) + +check_struct_has_member("siginfo_t" si_band "${CFG_HEADERS}" HAVE_SIGINFO_T_SI_BAND) + +####################################################################### +# +# Check for shm +# +####################################################################### +if(PY_VERSION VERSION_GREATER_EQUAL "3.8") + +foreach(func IN ITEMS shm_open shm_unlink) + string(TOUPPER ${func} _func_upper) + check_symbol_exists(${func} "${CFG_HEADERS}" HAVE_${_func_upper}) + if(NOT HAVE_${_func_upper}) + cmake_push_check_state() + list(APPEND CMAKE_REQUIRED_LIBRARIES rt) + check_symbol_exists(${func} "${CFG_HEADERS}" HAVE_${_func_upper}_IN_RT) + cmake_pop_check_state() + set(SHM_NEEDS_LIBRT ${HAVE_${_func_upper}_IN_RT}) + set(HAVE_${_func_upper} ${HAVE_${_func_upper}_IN_RT}) + endif() +endforeach() + +endif() + +####################################################################### +# +# Check for gcc x64 inline assembler +# +####################################################################### + +# Check for x64 gcc inline assembler +set(check_src ${PROJECT_BINARY_DIR}/CMakeFiles/have_gcc_asm_for_x64.c) +file(WRITE ${check_src} "int main () { + __asm__ __volatile__ (\"movq %rcx, %rax\"); +} +") +python_platform_test( + HAVE_GCC_ASM_FOR_X64 + "Checking for x64 gcc inline assembler" + ${check_src} + DIRECT + ) + +####################################################################### +# +# Check for various properties of floating point +# +####################################################################### + +# Check whether C doubles are little-endian IEEE 754 binary64 +set(check_src ${PROJECT_BINARY_DIR}/CMakeFiles/ac_cv_little_endian_double.c) +file(WRITE ${check_src} "#include +int main() { + double x = 9006104071832581.0; + if (memcmp(&x, \"\\x05\\x04\\x03\\x02\\x01\\xff\\x3f\\x43\", 8) == 0) + return 0; + else + return 1; +} +") +python_platform_test_run( + DOUBLE_IS_LITTLE_ENDIAN_IEEE754 + "Checking whether C doubles are little-endian IEEE 754 binary64" + ${check_src} + DIRECT + ) + +# Check whether C doubles are big-endian IEEE 754 binary64 +set(check_src ${PROJECT_BINARY_DIR}/CMakeFiles/ac_cv_big_endian_double.c) +file(WRITE ${check_src} "#include +int main() { + double x = 9006104071832581.0; + if (memcmp(&x, \"\\x43\\x3f\\xff\\x01\\x02\\x03\\x04\\x05\", 8) == 0) + return 0; + else + return 1; +} +") +python_platform_test_run( + DOUBLE_IS_BIG_ENDIAN_IEEE754 + "Checking whether C doubles are big-endian IEEE 754 binary64" + ${check_src} + DIRECT + ) + +# Check whether C doubles are ARM mixed-endian IEEE 754 binary64 +set(check_src ${PROJECT_BINARY_DIR}/CMakeFiles/ac_cv_mixed_endian_double.c) +file(WRITE ${check_src} "#include +int main() { + double x = 9006104071832581.0; + if (memcmp(&x, \"\\x01\\xff\\x3f\\x43\\x05\\x04\\x03\\x02\", 8) == 0) + return 0; + else + return 1; +} +") +python_platform_test_run( + DOUBLE_IS_ARM_MIXED_ENDIAN_IEEE754 + "Checking doubles are ARM mixed-endian IEEE 754 binary64" + ${check_src} + DIRECT + ) + +# The short float repr introduced in Python 3.1 requires the +# correctly-rounded string <-> double conversion functions from +# Python/dtoa.c, which in turn require that the FPU uses 53-bit +# rounding; this is a problem on x86, where the x87 FPU has a default +# rounding precision of 64 bits. For gcc/x86, we can fix this by +# using inline assembler to get and set the x87 FPU control word. + +# This inline assembler syntax may also work for suncc and icc, +# so we try it on all platforms. + +# Check whether we can use gcc inline assembler to get and set x87 control word +set(check_src ${PROJECT_BINARY_DIR}/CMakeFiles/have_gcc_asm_for_x87.c) +file(WRITE ${check_src} "int main() { + unsigned short cw; + __asm__ __volatile__ (\"fnstcw %0\" : \"=m\" (cw)); + __asm__ __volatile__ (\"fldcw %0\" : : \"m\" (cw)); +} +") +python_platform_test( + HAVE_GCC_ASM_FOR_X87 + "Checking whether we can use gcc inline assembler to get and set x87 control word" + ${check_src} + DIRECT + ) + +# Python 3.12 +cmake_push_check_state() +add_cond(CMAKE_REQUIRED_LIBRARIES HAVE_LIBFFI ${LibFFI_LIBRARY}) +add_cond(CMAKE_REQUIRED_INCLUDES LibFFI_INCLUDE_DIR ${LibFFI_INCLUDE_DIR}) +check_symbol_exists(ffi_call "ffi.h" HAVE_FFI_CALL) +check_symbol_exists(ffi_closure_alloc "ffi.h" HAVE_FFI_CLOSURE_ALLOC) +check_symbol_exists(ffi_prep_cif_var "ffi.h" HAVE_FFI_PREP_CIF_VAR) +check_symbol_exists(ffi_prep_closure_loc "ffi.h" HAVE_FFI_PREP_CLOSURE_LOC) +cmake_pop_check_state() + +# libffi specific: Cannot use PROT_EXEC on this target, so, we revert to alternative means +# XXX In autoconf system, it was set to true if target matches *arm*-apple-darwin* +if(NOT DEFINED FFI_EXEC_TRAMPOLINE_TABLE) + set(FFI_EXEC_TRAMPOLINE_TABLE 0) +endif() + +# libffi specific: Define this if you want to enable pax emulated trampolines +# On PaX enable kernels that have MPROTECT enable we can't use PROT_EXEC. +# XXX Add option 'FFI_MMAP_EXEC_EMUTRAMP_PAX'. +if(NOT DEFINED FFI_MMAP_EXEC_EMUTRAMP_PAX) + set(FFI_MMAP_EXEC_EMUTRAMP_PAX 0) +endif() + +# libffi specific: Check whether read-only mmap of a plain file works +if(NOT DEFINED HAVE_MMAP_FILE) + set(msg "Checking whether read-only mmap of a plain file works") + message(STATUS "${msg}") + set(value 1) + set(status "yes") + if(NOT HAVE_SYS_MMAN_H OR NOT HAVE_MMAP) + set(value 0) + set(status "no") + endif() + message(STATUS "${msg} - ${status}") + set(HAVE_MMAP_FILE "${value}" CACHE INTERNAL "Have support for mmap_file") +endif() + +# libffi specific: check whether mmap works +# XXX Add a system to this blacklist if +# mmap(0, stat_size, PROT_READ, MAP_PRIVATE, fd, 0) doesn't return a +# memory area containing the same data that you'd get if you applied +# read() to the same fd. The only system known to have a problem here +# is VMS, where text files have record structure. + +# libffi specific: Check whether assembler supports .ascii. +set(check_src ${PROJECT_BINARY_DIR}/CMakeFiles/have_as_ascii_pseudo_op.c) +file(WRITE ${check_src} " +int main () { +asm (\".ascii \\\"string\\\"\"); +return 0; +} +") +python_platform_test( + HAVE_AS_ASCII_PSEUDO_OP + "Checking whether assembler supports .ascii" + ${check_src} + DIRECT + ) + +# libffi specific: Check whether assembler supports .cfi_* directives +set(check_src ${PROJECT_BINARY_DIR}/CMakeFiles/have_as_cfi_pseudo_op.c) +file(WRITE ${check_src} " +asm(\".cfi_startproc\\n\\t.cfi_endproc\"); +int main (){return 0;} +") +python_platform_test( + HAVE_AS_CFI_PSEUDO_OP + "Checking whether assembler supports .cfi_* directives" + ${check_src} + DIRECT + ) + +# libffi specific: Check whether assembler supports .string. +set(check_src ${PROJECT_BINARY_DIR}/CMakeFiles/have_as_string_pseudo_op.c) +file(WRITE ${check_src} " +int main () { +asm (\".string \\\"string\\\"\"); +return 0; +} +") +python_platform_test( + HAVE_AS_STRING_PSEUDO_OP + "Checking whether assembler supports .string" + ${check_src} + DIRECT + ) + +# libffi specific: Check whether assembler supports unwind section type. +# TODO +set(HAVE_AS_X86_64_UNWIND_SECTION_TYPE 1) + +# libffi specific: Check whether assembler supports PC relative relocs +set(check_src ${PROJECT_BINARY_DIR}/CMakeFiles/have_as_x86_pcrel.c) +file(WRITE ${check_src} "int main() { + __asm__ __volatile__ (\".text; ha: nop; .data; .long ha-.; .text\"); +} +") +python_platform_test( + HAVE_AS_X86_PCREL + "Checking whether assembler supports PC relative relocs" + ${check_src} + DIRECT + ) + +# libffi specific: Check whether .eh_frame sections should be read-only. +# TODO +set(HAVE_RO_EH_FRAME 1) + +# libffi specific: Check whether symbols are underscored +# TODO +set(SYMBOL_UNDERSCORE 0) + +# libffi specific: Check compiler for symbol visibility support +check_c_source_compiles(" + __attribute__((visibility(\"default\"))) + int bar(void) {}; + int main() {bar();}" + HAVE_HIDDEN_VISIBILITY_ATTRIBUTE) + +# libffi specific: Check system for MAP_ANONYMOUS +check_c_source_compiles(" +#include +#include +#include + +#ifndef MAP_ANONYMOUS +#define MAP_ANONYMOUS MAP_ANON +#endif + +int main() {int a = MAP_ANONYMOUS;}" +HAVE_MMAP_ANON) + +# libffi specific: Check for /dev/zero support for anonymous memory maps +check_c_source_runs(" +#include +#include +#include +#include +int main(void) { + int devzero; + void *retval; + devzero = open(\"/dev/zero\", O_RDWR); + if (-1 == devzero) { + exit(1); + } + retval = mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_SHARED, devzero, 0); + if (retval == (void *)-1) { + exit(1); + } + exit(0); +}" HAVE_MMAP_DEV_ZERO) + +# Check whether we can use gcc inline assembler to get and set mc68881 fpcr +set(check_src ${PROJECT_BINARY_DIR}/CMakeFiles/have_gcc_asm_for_mc68881.c) +file(WRITE ${check_src} "int main() { + unsigned int fpcr; + __asm__ __volatile__ (\"fmove.l %%fpcr,%0\" : \"=g\" (fpcr)); + __asm__ __volatile__ (\"fmove.l %0,%%fpcr\" : : \"g\" (fpcr)); +} +") +python_platform_test( + HAVE_GCC_ASM_FOR_MC68881 + "Checking whether we can use gcc inline assembler to get and set mc68881 fpcr" + ${check_src} + DIRECT + ) + +# Check for x87-style double rounding +set(check_src ${PROJECT_BINARY_DIR}/CMakeFiles/ac_cv_x87_double_rounding.c) +file(WRITE ${check_src} "#include +#include +int main() { + volatile double x, y, z; + /* 1./(1-2**-53) -> 1+2**-52 (correct), 1.0 (double rounding) */ + x = 0.99999999999999989; /* 1-2**-53 */ + y = 1./x; + if (y != 1.) + exit(0); + /* 1e16+2.99999 -> 1e16+2. (correct), 1e16+4. (double rounding) */ + x = 1e16; + y = 2.99999; + z = x + y; + if (z != 1e16+4.) + exit(0); + /* both tests show evidence of double rounding */ + exit(1); +} +") +python_platform_test_run( + X87_DOUBLE_ROUNDING + "Checking for x87-style double rounding" + ${check_src} + INVERT + ) + +####################################################################### +# +# Check for crypt functions +# +####################################################################### + +# We search for both crypt and crypt_r as one or the other may be defined +# This gets us our -lcrypt in CMAKE_REQUIRED_LIBRARIES when required on +# the target platform. + +cmake_push_check_state() +set(check_src ${PROJECT_BINARY_DIR}/CMakeFiles/ac_cv_lib_crypt_crypt.c) +file(WRITE ${check_src} "/* Override any GCC internal prototype to avoid an error. +Use char because int might match the return type of a GCC +builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern \"C\" +#endif +char crypt (); +int main () { return crypt (); } +") +list(APPEND CMAKE_REQUIRED_LIBRARIES crypt) +python_platform_test( + HAVE_CRYPT + "Checking for crypt in -lcrypt" + ${check_src} + DIRECT + ) +cmake_pop_check_state() + +cmake_push_check_state() +set(check_src ${PROJECT_BINARY_DIR}/CMakeFiles/ac_cv_lib_crypt_crypt_r.c) +file(WRITE ${check_src} "/* Override any GCC internal prototype to avoid an error. +Use char because int might match the return type of a GCC +builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern \"C\" +#endif +char crypt_r (); +int main () { return crypt_r (); } +") +list(APPEND CMAKE_REQUIRED_LIBRARIES crypt) +python_platform_test( + HAVE_CRYPT + "Checking for crypt_r in -lcrypt" + ${check_src} + DIRECT + ) +cmake_pop_check_state() + +add_cond(CMAKE_REQUIRED_LIBRARIES HAVE_CRYPT crypt) + +if(HAVE_CRYPT_H) + check_c_source_compiles(" +#define _GNU_SOURCE /* Required for crypt_r()'s prototype in glibc. */ +#include +int main(void){ + struct crypt_data d; + char *r = crypt_r(\"\", \"\", &d); }" HAVE_CRYPT_R) +endif() + +####################################################################### +# +# Check for mathematical functions +# +####################################################################### + +cmake_push_check_state() + +# Check whether tanh preserves the sign of zero +set(check_src ${PROJECT_BINARY_DIR}/CMakeFiles/ac_cv_tanh_preserves_zero_sign.c) +file(WRITE ${check_src} "#include +#include +int main() { + /* return 0 if either negative zeros don't exist + on this platform or if negative zeros exist + and tanh(-0.) == -0. */ + if (atan2(0., -1.) == atan2(-0., -1.) || + atan2(tanh(-0.), -1.) == atan2(-0., -1.)) exit(0); + else exit(1); +} +") +python_platform_test_run( + TANH_PRESERVES_ZERO_SIGN + "Checking whether tanh preserves the sign of zero" + ${check_src} + DIRECT + ) + +# Check whether log1p drops the sign of negative zero +set(check_src ${PROJECT_BINARY_DIR}/CMakeFiles/ac_cv_log1p_drops_zero_sign.c) +file(WRITE ${check_src} "#include +#include +int main() { + /* Fail if the signs of log1p(-0.) and -0. can be distinguished. */ + if (atan2(log1p(-0.), -1.) == atan2(-0., -1.)) + return 0; + else + return 1; +} +") +python_platform_test_run( + LOG1P_DROPS_ZERO_SIGN + "Checking whether log1p drops the sign of negative zero" + ${check_src} + INVERT + ) + +set(_funcs acosh asinh atanh copysign erf erfc expm1 finite gamma + hypot lgamma log1p round tgamma + log2 + ) +foreach(func ${_funcs}) + string(TOUPPER ${func} _func_upper) + check_function_exists(${func} HAVE_${_func_upper}) +endforeach() + +foreach(decl isinf isnan isfinite) + string(TOUPPER ${decl} _decl_upper) + check_symbol_exists(${decl} "math.h" HAVE_DECL_${_decl_upper}) +endforeach() + +cmake_pop_check_state() + +####################################################################### +# +# time +# +####################################################################### +check_struct_has_member("struct tm" tm_zone "${CFG_HEADERS}" HAVE_STRUCT_TM_TM_ZONE) +check_struct_has_member("struct tm" tm_zone "${CFG_HEADERS}" HAVE_STRUCT_TM_TM_ZONE) +set(HAVE_TM_ZONE ${HAVE_STRUCT_TM_TM_ZONE}) + +if(NOT HAVE_STRUCT_TM_TM_ZONE) + check_variable_exists(tzname HAVE_TZNAME) + check_symbol_exists(tzname "time.h" HAVE_DECL_TZNAME) +else() + set(HAVE_TZNAME 0) + set(HAVE_DECL_TZNAME 0) +endif() + +set(CMAKE_EXTRA_INCLUDE_FILES "time.h") +check_type_size("struct tm" TM_IN_TIME) +unset(CMAKE_EXTRA_INCLUDE_FILES) +if(TM_IN_TIME) + set(TM_IN_SYS_TIME 0) +else() + set(TM_IN_SYS_TIME 1) +endif() +check_c_source_compiles("#include \n #include \n #include \n int main() {if ((struct tm *) 0) return 0;}" TIME_WITH_SYS_TIME) +check_c_source_compiles("#include \n #include \n #include \n int main(){return 0;}" SYS_SELECT_WITH_SYS_TIME) + +check_c_source_compiles("#include \n int main() {gettimeofday((struct timeval*)0,(struct timezone*)0);}" GETTIMEOFDAY_WITH_TZ) + +if(GETTIMEOFDAY_WITH_TZ) + set(GETTIMEOFDAY_NO_TZ 0) +else() + set(GETTIMEOFDAY_NO_TZ 1) +endif() + +if(APPLE) + cmake_push_check_state() + set(CMAKE_REQUIRED_FLAGS "-Wl,-no_weak_imports") + CHECK_C_SOURCE_COMPILES("int main(void) { return 0; }" SUPPORT_NO_WEAK_IMPORT_FLAG) + cmake_pop_check_state() +else() + set(SUPPORT_NO_WEAK_IMPORT_FLAG 0) +endif() + +cmake_push_check_state() +set(check_src ${PROJECT_BINARY_DIR}/CMakeFiles/clock_getres.c) +file(WRITE ${check_src} " +#include +#include +int main() { return clock_getres(0, NULL); } +") +if(SUPPORT_NO_WEAK_IMPORT_FLAG) + set(CMAKE_REQUIRED_FLAGS "-Wl,-no_weak_imports") +endif() +python_platform_test( + HAVE_CLOCK_GETRES + "Checking for clock_getres" + ${check_src} + DIRECT + ) +cmake_pop_check_state() + +if(NOT HAVE_CLOCK_GETRES) + cmake_push_check_state() + set(check_src ${PROJECT_BINARY_DIR}/CMakeFiles/ac_cv_lib_rt_clock_getres.c) + file(WRITE ${check_src} "/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ + #ifdef __cplusplus + extern \"C\" + #endif + char clock_getres (); + int main () { return clock_getres (); } + ") + list(APPEND CMAKE_REQUIRED_LIBRARIES rt) + python_platform_test( + HAVE_CLOCK_GETRES + "Checking for clock_getres in -lrt" + ${check_src} + DIRECT + ) + cmake_pop_check_state() +endif() + +cmake_push_check_state() +set(check_src ${PROJECT_BINARY_DIR}/CMakeFiles/clock_gettime.c) +file(WRITE ${check_src} " +#include +#include +int main() { return clock_gettime(0, NULL); } +") +if(SUPPORT_NO_WEAK_IMPORT_FLAG) + set(CMAKE_REQUIRED_FLAGS "-Wl,-no_weak_imports") +endif() +python_platform_test( + HAVE_CLOCK_GETTIME + "Checking for clock_gettime" + ${check_src} + DIRECT + ) +cmake_pop_check_state() +if(NOT HAVE_CLOCK_GETTIME) + cmake_push_check_state() + set(check_src ${PROJECT_BINARY_DIR}/CMakeFiles/ac_cv_lib_rt_clock_gettime.c) + file(WRITE ${check_src} "/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ + #ifdef __cplusplus + extern \"C\" + #endif + char clock_gettime (); + int main () { return clock_gettime (); } + ") + list(APPEND CMAKE_REQUIRED_LIBRARIES rt) + python_platform_test( + HAVE_CLOCK_GETTIME + "Checking for clock_gettime in -lrt" + ${check_src} + DIRECT + ) + cmake_pop_check_state() + if(HAVE_CLOCK_GETTIME) + set(TIMEMODULE_LIB rt) + endif() +endif() + +cmake_push_check_state() +set(check_src ${PROJECT_BINARY_DIR}/CMakeFiles/clock_settime.c) +file(WRITE ${check_src} " +#include +#include +int main() { return clock_settime(0, NULL); } +") +if(SUPPORT_NO_WEAK_IMPORT_FLAG) + set(CMAKE_REQUIRED_FLAGS "-Wl,-no_weak_imports") +endif() +python_platform_test( + HAVE_CLOCK_SETTIME + "Checking for clock_settime" + ${check_src} + DIRECT + ) +cmake_pop_check_state() +if(NOT HAVE_CLOCK_SETTIME) + cmake_push_check_state() + set(check_src ${PROJECT_BINARY_DIR}/CMakeFiles/ac_cv_lib_rt_clock_settime.c) + file(WRITE ${check_src} "/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ + #ifdef __cplusplus + extern \"C\" + #endif + char clock_gettime (); + int main () { return clock_settime (); } + ") + list(APPEND CMAKE_REQUIRED_LIBRARIES rt) + python_platform_test( + HAVE_CLOCK_SETTIME + "Checking for clock_settime in -lrt" + ${check_src} + DIRECT + ) + cmake_pop_check_state() + if(HAVE_CLOCK_SETTIME) + set(TIMEMODULE_LIB rt) + endif() +endif() + +if(NOT HAVE_CLOCK_NANOSLEEP) + cmake_push_check_state() + set(check_src ${PROJECT_BINARY_DIR}/CMakeFiles/ac_cv_lib_rt_clock_nanosleep.c) + file(WRITE ${check_src} "/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ + #ifdef __cplusplus + extern \"C\" + #endif + char clock_nanosleep (); + int main () { return clock_nanosleep (); } + ") + list(APPEND CMAKE_REQUIRED_LIBRARIES rt) + python_platform_test( + HAVE_CLOCK_NANOSLEEP + "Checking for clock_nanosleep in -lrt" + ${check_src} + DIRECT + ) + cmake_pop_check_state() +endif() + +if(NOT HAVE_NANOSLEEP) + cmake_push_check_state() + set(check_src ${PROJECT_BINARY_DIR}/CMakeFiles/ac_cv_lib_rt_nanosleep.c) + file(WRITE ${check_src} "/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ + #ifdef __cplusplus + extern \"C\" + #endif + char nanosleep (); + int main () { return nanosleep (); } + ") + list(APPEND CMAKE_REQUIRED_LIBRARIES rt) + python_platform_test( + HAVE_NANOSLEEP + "Checking for nanosleep in -lrt" + ${check_src} + DIRECT + ) + cmake_pop_check_state() +endif() + +####################################################################### +# +# unicode +# +####################################################################### + +# Check for UCS-4 tcl +set(check_src ${PROJECT_BINARY_DIR}/CMakeFiles/have_ucs4_tcl.c) +file(WRITE ${check_src} "#include +#if TCL_UTF_MAX != 6 +# error \"NOT UCS4_TCL\" +#endif +int main () { return 0; } +") +python_platform_test( + HAVE_UCS4_TCL + "Checking for UCS-4 tcl" + ${check_src} + DIRECT + ) + +#ucs2 +set(HAVE_USABLE_WCHAR_T 0) + +if(PY_VERSION VERSION_LESS "3.3") + if(NOT DEFINED Py_UNICODE_SIZE) + if(HAVE_UCS4_TCL) + message(STATUS "Defaulting Py_UNICODE_SIZE to 4 because HAVE_UCS4_TCL is set") + set(Py_UNICODE_SIZE 4) + else() + # Py_UNICODE defaults to two-byte mode + set(Py_UNICODE_SIZE 2) + endif() + endif() + + if("${Py_UNICODE_SIZE}" STREQUAL "${SIZEOF_WCHAR_T}") + set(PY_UNICODE_TYPE wchar_t) + set(HAVE_USABLE_WCHAR_T 1) + message(STATUS "Using wchar_t for unicode [Py_UNICODE_SIZE: ${Py_UNICODE_SIZE}]") + else() + + if("${Py_UNICODE_SIZE}" STREQUAL "${SIZEOF_SHORT}") + set(PY_UNICODE_TYPE "unsigned short") + set(HAVE_USABLE_WCHAR_T 0) + message(STATUS "Using unsigned short for unicode [Py_UNICODE_SIZE: ${Py_UNICODE_SIZE}]") + else() + + if("${Py_UNICODE_SIZE}" STREQUAL "${SIZEOF_LONG}") + set(PY_UNICODE_TYPE "unsigned long") + set(HAVE_USABLE_WCHAR_T 0) + message(STATUS "Using unsigned long for unicode [Py_UNICODE_SIZE: ${Py_UNICODE_SIZE}]") + else() + message(FATAL_ERROR "No usable unicode type found for [Py_UNICODE_SIZE: ${Py_UNICODE_SIZE}] + Set Py_UNICODE_SIZE to either ${SIZEOF_WCHAR_T}, ${SIZEOF_SHORT} or ${SIZEOF_LONG}") + endif() + endif() + endif() +endif() + +if(PY_VERSION VERSION_GREATER_EQUAL "3.7") +set(PY_COERCE_C_LOCALE ${WITH_C_LOCALE_COERCION}) +endif() + +####################################################################### +# +# uuid tests +# +####################################################################### + +if(PY_VERSION VERSION_GREATER_EQUAL "3.7") + +cmake_push_check_state() +set(CFG_HEADERS_SAVE ${CFG_HEADERS}) + +check_include_files(uuid/uuid.h HAVE_UUID_UUID_H) +check_include_files(uuid.h HAVE_UUID_H) + +add_cond(CFG_HEADERS HAVE_UUID_UUID_H uuid/uuid.h) +add_cond(CFG_HEADERS HAVE_UUID_H uuid.h) + +add_cond(CMAKE_REQUIRED_LIBRARIES UUID_LIBRARY ${UUID_LIBRARY}) + +check_symbol_exists(uuid_create "${CFG_HEADERS}" HAVE_UUID_CREATE) + +if(HAVE_UUID_H) + # Little-endian FreeBSD, OpenBSD and NetBSD needs encoding into an octet + # stream in big-endian byte-order + check_c_source_compiles("#include +int main(void){ + #ifndef uuid_enc_be + uuid_t uuid; + unsigned char buf[sizeof(uuid)]; + uuid_enc_be(buf, &uuid); + #endif +}" HAVE_UUID_ENC_BE) +endif() + +if(HAVE_UUID_UUID_H) + check_c_source_compiles("#include +int main(void){ + #ifndef uuid_generate_time_safe + uuid_t out; + uuid_generate_time_safe(out); + #endif +}" HAVE_UUID_GENERATE_TIME_SAFE) +endif() + +set(CFG_HEADERS ${CFG_HEADERS_SAVE}) +cmake_pop_check_state() + +endif() + +####################################################################### +# +# networking tests +# +####################################################################### +cmake_push_check_state() +set(CFG_HEADERS_SAVE ${CFG_HEADERS}) +add_cond(CFG_HEADERS HAVE_NETDB_H netdb.h) +add_cond(CFG_HEADERS HAVE_NET_ETHERNET_H net/ethernet.h) +add_cond(CFG_HEADERS HAVE_NETINET_IN_H netinet/in.h) +add_cond(CFG_HEADERS HAVE_ARPA_INET_H arpa/inet.h) + +check_symbol_exists(gethostbyname_r "${CFG_HEADERS}" HAVE_GETHOSTBYNAME_R) +if(HAVE_GETHOSTBYNAME_R) + + # Checking gethostbyname_r with 6 args + set(check_src ${PROJECT_BINARY_DIR}/CMakeFiles/have_gethostbyname_r_6_arg.c) + file(WRITE ${check_src} "#include +int main() { + char *name; + struct hostent *he, *res; + char buffer[2048]; + int buflen = 2048; + int h_errnop; + + (void) gethostbyname_r(name, he, buffer, buflen, &res, &h_errnop); + return 0; +} +") + python_platform_test( + HAVE_GETHOSTBYNAME_R_6_ARG + "Checking gethostbyname_r with 6 args" + ${check_src} + DIRECT + ) + if(HAVE_GETHOSTBYNAME_R_6_ARG) + set(HAVE_GETHOSTBYNAME_R 1) + else() + # Checking gethostbyname_r with 5 args + set(check_src ${PROJECT_BINARY_DIR}/CMakeFiles/have_gethostbyname_r_5_arg.c) + file(WRITE ${check_src} "#include +int main() { + char *name; + struct hostent *he; + char buffer[2048]; + int buflen = 2048; + int h_errnop; + + (void) gethostbyname_r(name, he, buffer, buflen, &h_errnop) + return 0; +} +") + python_platform_test( + HAVE_GETHOSTBYNAME_R_5_ARG + "Checking gethostbyname_r with 5 args" + ${check_src} + DIRECT + ) + if(HAVE_GETHOSTBYNAME_R_5_ARG) + set(HAVE_GETHOSTBYNAME_R 1) + else() + # Checking gethostbyname_r with 3 args + set(check_src ${PROJECT_BINARY_DIR}/CMakeFiles/have_gethostbyname_r_3_arg.c) + file(WRITE ${check_src} "#include +int main() { + char *name; + struct hostent *he; + struct hostent_data data; + + (void) gethostbyname_r(name, he, &data); + return 0; +} +") + python_platform_test( + HAVE_GETHOSTBYNAME_R_3_ARG + "Checking gethostbyname_r with 3 args" + ${check_src} + DIRECT + ) + if(HAVE_GETHOSTBYNAME_R_3_ARG) + set(HAVE_GETHOSTBYNAME_R 1) + endif() + endif() + endif() +endif() +check_symbol_exists(gethostbyname "${CFG_HEADERS}" HAVE_GETHOSTBYNAME) + +check_symbol_exists(gai_strerror "${CFG_HEADERS}" HAVE_GAI_STRERROR) +check_symbol_exists(getaddrinfo "${CFG_HEADERS}" HAVE_GETADDRINFO) +check_symbol_exists(gethostname "${CFG_HEADERS}" HAVE_GETHOSTNAME) # Python 3.11 +check_symbol_exists(getnameinfo "${CFG_HEADERS}" HAVE_GETNAMEINFO) +check_symbol_exists(gethostbyaddr "${CFG_HEADERS}" HAVE_GETHOSTBYADDR) # Python 3.11 +check_symbol_exists(getprotobyname "${CFG_HEADERS}" HAVE_GETPROTOBYNAME) # Python 3.11 + +check_symbol_exists(getpeername "${CFG_HEADERS}" HAVE_GETPEERNAME) +check_symbol_exists(getservbyname "${CFG_HEADERS}" HAVE_GETSERVBYNAME) # Python 3.11 +check_symbol_exists(getservbyport "${CFG_HEADERS}" HAVE_GETSERVBYPORT) # Python 3.11 +check_symbol_exists(hstrerror "${CFG_HEADERS}" HAVE_HSTRERROR) +check_symbol_exists(inet_aton "${CFG_HEADERS}" HAVE_INET_ATON) +if(NOT HAVE_INET_ATON) + check_library_exists(resolv inet_aton "" HAVE_LIBRESOLV) +endif() +check_symbol_exists(inet_ntoa "${CFG_HEADERS}" HAVE_INET_NTOA) # Python 3.11 +check_symbol_exists(inet_pton "${CFG_HEADERS}" HAVE_INET_PTON) + +set(CMAKE_EXTRA_INCLUDE_FILES ${CFG_HEADERS}) +check_type_size("struct addrinfo" HAVE_ADDRINFO) +check_struct_has_member("struct sockaddr" sa_len "${CFG_HEADERS}" HAVE_SOCKADDR_SA_LEN ) +check_type_size("struct sockaddr_storage" HAVE_SOCKADDR_STORAGE) +unset(CMAKE_EXTRA_INCLUDE_FILES) + +set(CMAKE_EXTRA_INCLUDE_FILES "sys/types.h" "sys/socket.h" "linux/if_alg.h") +check_type_size("struct sockaddr_alg" HAVE_SOCKADDR_ALG) +unset(CMAKE_EXTRA_INCLUDE_FILES) + +set(CFG_HEADERS ${CFG_HEADERS_SAVE}) +cmake_pop_check_state() + + +####################################################################### +# +# multithreading stuff +# +####################################################################### +cmake_push_check_state() +set(CFG_HEADERS_SAVE ${CFG_HEADERS}) + +set(HAVE_PTHREAD_DESTRUCTOR 0) # for Solaris 2.6 +add_cond(CFG_HEADERS HAVE_PTHREAD_H pthread.h) +add_cond(CMAKE_REQUIRED_LIBRARIES CMAKE_USE_PTHREADS_INIT "${CMAKE_THREAD_LIBS_INIT}") +if(APPLE) + set(HAVE_PTHREAD_INIT ${CMAKE_USE_PTHREADS_INIT}) # See commit message for explanation. +else() + check_symbol_exists(pthread_init "${CFG_HEADERS}" HAVE_PTHREAD_INIT) +endif() +check_symbol_exists(pthread_sigmask "${CFG_HEADERS}" HAVE_PTHREAD_SIGMASK) +check_symbol_exists(pthread_atfork "${CFG_HEADERS}" HAVE_PTHREAD_ATFORK) +check_symbol_exists(pthread_condattr_setclock "${CFG_HEADERS}" HAVE_PTHREAD_CONDATTR_SETCLOCK) +check_symbol_exists(pthread_getcpuclockid "${CFG_HEADERS}" HAVE_PTHREAD_GETCPUCLOCKID) + +add_cond(CFG_HEADERS HAVE_SEMAPHORE_H semaphore.h) +check_symbol_exists(sem_clockwait "${CFG_HEADERS}" HAVE_SEM_CLOCKWAIT) +check_symbol_exists(sem_getvalue "${CFG_HEADERS}" HAVE_SEM_GETVALUE) +check_symbol_exists(sem_open "${CFG_HEADERS}" HAVE_SEM_OPEN) +check_symbol_exists(sem_timedwait "${CFG_HEADERS}" HAVE_SEM_TIMEDWAIT) +check_symbol_exists(sem_unlink "${CFG_HEADERS}" HAVE_SEM_UNLINK) + +# For multiprocessing module, check that sem_open actually works. +set(check_src ${PROJECT_BINARY_DIR}/CMakeFiles/ac_cv_posix_semaphores_enabled.c) +file(WRITE ${check_src} "#include +#include +#include +#include +#include + +int main(void) { + sem_t *a = sem_open(\"/autoconf\", O_CREAT, S_IRUSR|S_IWUSR, 0); + if (a == SEM_FAILED) { + perror(\"sem_open\"); + return 1; + } + sem_close(a); + sem_unlink(\"/autoconf\"); + return 0; +} +") +python_platform_test_run( + POSIX_SEMAPHORES_NOT_ENABLED + "Checking whether POSIX semaphores are enabled" + ${check_src} + INVERT + ) + +# Multiprocessing check for broken sem_getvalue +set(check_src ${PROJECT_BINARY_DIR}/CMakeFiles/have_broken_sem_getvalue.c) +file(WRITE ${check_src} "#include +#include +#include +#include +#include + +int main(void){ + sem_t *a = sem_open(\"/autocftw\", O_CREAT, S_IRUSR|S_IWUSR, 0); + int count; + int res; + if(a==SEM_FAILED){ + perror(\"sem_open\"); + return 1; + + } + res = sem_getvalue(a, &count); + sem_close(a); + sem_unlink(\"/autocftw\"); + return res==-1 ? 1 : 0; +} +") +python_platform_test_run( + HAVE_BROKEN_SEM_GETVALUE + "Checking for broken sem_getvalue" + ${check_src} + INVERT + ) + +set(CFG_HEADERS ${CFG_HEADERS_SAVE}) +cmake_pop_check_state() + +if(CMAKE_SYSTEM MATCHES BlueGene AND PY_VERSION VERSION_LESS "3.7") + # Todo: Display message + set(WITH_THREAD OFF CACHE STRING "System doesn't support multithreading" FORCE) +endif() + + +####################################################################### +# +# ssl tests +# +####################################################################### + +if(OPENSSL_INCLUDE_DIR AND OPENSSL_LIBRARIES) + cmake_push_check_state() + + set(CMAKE_REQUIRED_INCLUDES ${OPENSSL_INCLUDE_DIR}) + set(CMAKE_REQUIRED_LIBRARIES ${OPENSSL_LIBRARIES}) + + # Checking for X509_VERIFY_PARAM_set1_host in libssl + check_c_source_compiles("#include +int main(void){ + X509_VERIFY_PARAM *p = X509_VERIFY_PARAM_new(); + X509_VERIFY_PARAM_set1_host(p, \"localhost\", 0); + X509_VERIFY_PARAM_set1_ip_asc(p, \"127.0.0.1\"); + X509_VERIFY_PARAM_set_hostflags(p, 0); }" HAVE_X509_VERIFY_PARAM_SET1_HOST) + + cmake_pop_check_state() +endif() + + +####################################################################### +# +# readline tests +# +####################################################################### + +# MacOSX 10.4 has a broken readline. Don't try to build +# the readline module unless the user has installed a fixed +# readline package +if(HAVE_READLINE_READLINE_H) + if(APPLE AND CMAKE_OSX_DEPLOYMENT_TARGET + AND "${CMAKE_OSX_DEPLOYMENT_TARGET}" VERSION_LESS "10.5") + check_include_files(readline/rlconf.h HAVE_READLINE_RLCONF_H) + if(NOT HAVE_READLINE_RLCONF_H) + set(HAVE_READLINE_READLINE_H FALSE) + endif() + endif() +endif() +if(HAVE_READLINE_READLINE_H) + cmake_push_check_state() + set(CFG_HEADERS_SAVE ${CFG_HEADERS}) + + if(USE_LIBEDIT) + add_cond(CFG_HEADERS HAVE_READLINE_READLINE_H "editline/readline.h") + else() + add_cond(CFG_HEADERS HAVE_READLINE_READLINE_H "readline/readline.h") + endif() + add_cond(CMAKE_REQUIRED_LIBRARIES HAVE_LIBREADLINE ${HAVE_LIBREADLINE}) + check_symbol_exists(rl_callback_handler_install "${CFG_HEADERS}" HAVE_RL_CALLBACK) + check_symbol_exists(rl_catch_signals "${CFG_HEADERS}" HAVE_RL_CATCH_SIGNAL) + check_symbol_exists(rl_compdisp_func_t "${CFG_HEADERS}" HAVE_RL_COMPDISP_FUNC_T) # Python 3.11 + check_symbol_exists(rl_completion_append_character "${CFG_HEADERS}" HAVE_RL_COMPLETION_APPEND_CHARACTER) + check_symbol_exists(rl_completion_display_matches_hook "${CFG_HEADERS}" HAVE_RL_COMPLETION_DISPLAY_MATCHES_HOOK) + check_symbol_exists(rl_completion_suppress_append "${CFG_HEADERS}" HAVE_RL_COMPLETION_SUPPRESS_APPEND) + check_symbol_exists(rl_completion_matches "${CFG_HEADERS}" HAVE_RL_COMPLETION_MATCHES) + check_symbol_exists(rl_pre_input_hook "${CFG_HEADERS}" HAVE_RL_PRE_INPUT_HOOK) + check_symbol_exists(rl_resize_terminal "${CFG_HEADERS}" HAVE_RL_RESIZE_TERMINAL) + + set(CFG_HEADERS ${CFG_HEADERS_SAVE}) + cmake_pop_check_state() +endif() + + +####################################################################### +# +# curses tests +# +####################################################################### +if(HAVE_CURSES_H) + cmake_push_check_state() + set(CFG_HEADERS_SAVE ${CFG_HEADERS}) + + set(CFG_HEADERS ${CFG_HEADERS} curses.h) + add_cond(CMAKE_REQUIRED_LIBRARIES HAVE_LIBCURSES ${HAVE_LIBCURSES}) + check_symbol_exists(is_term_resized "${CFG_HEADERS}" HAVE_CURSES_IS_TERM_RESIZED) + check_symbol_exists(resizeterm "${CFG_HEADERS}" HAVE_CURSES_RESIZETERM) + check_symbol_exists(resize_term "${CFG_HEADERS}" HAVE_CURSES_RESIZE_TERM) + check_struct_has_member(WINDOW _flags "${CFG_HEADERS}" WINDOW_HAS_FLAGS) + + check_c_source_compiles("#include \n int main() {int i; i = mvwdelch(0,0,0);}" MVWDELCH_IS_EXPRESSION) + + check_symbol_exists(filter "${CFG_HEADERS}" HAVE_CURSES_FILTER) + check_symbol_exists(has_key "${CFG_HEADERS}" HAVE_CURSES_HAS_KEY) + check_symbol_exists(immedok "${CFG_HEADERS}" HAVE_CURSES_IMMEDOK) + check_symbol_exists(is_pad "${CFG_HEADERS}" HAVE_CURSES_IS_PAD) + check_symbol_exists(syncok "${CFG_HEADERS}" HAVE_CURSES_SYNCOK) + check_symbol_exists(typeahead "${CFG_HEADERS}" HAVE_CURSES_TYPEAHEAD) + check_symbol_exists(use_env "${CFG_HEADERS}" HAVE_CURSES_USE_ENV) + check_symbol_exists(wchgat "${CFG_HEADERS}" HAVE_CURSES_WCHGAT) + + set(CFG_HEADERS ${CFG_HEADERS_SAVE}) + cmake_pop_check_state() +endif() + + +####################################################################### +# +# dynamic loading +# +####################################################################### +if(HAVE_DLFCN_H) + cmake_push_check_state() + set(CFG_HEADERS_SAVE ${CFG_HEADERS}) + + set(CFG_HEADERS ${CFG_HEADERS} dlfcn.h) + add_cond(CMAKE_REQUIRED_LIBRARIES HAVE_LIBDL "${HAVE_LIBDL}") + check_symbol_exists(dlopen "${CFG_HEADERS}" HAVE_DLOPEN) + + check_symbol_exists(RTLD_DEEPBIND dlfcn.h HAVE_DECL_RTLD_DEEPBIND) + check_symbol_exists(RTLD_GLOBAL dlfcn.h HAVE_DECL_RTLD_GLOBAL) + check_symbol_exists(RTLD_LAZY dlfcn.h HAVE_DECL_RTLD_LAZY) + check_symbol_exists(RTLD_LOCAL dlfcn.h HAVE_DECL_RTLD_LOCAL) + check_symbol_exists(RTLD_MEMBER dlfcn.h HAVE_DECL_RTLD_MEMBER) + check_symbol_exists(RTLD_NODELETE dlfcn.h HAVE_DECL_RTLD_NODELETE) + check_symbol_exists(RTLD_NOLOAD dlfcn.h HAVE_DECL_RTLD_NOLOAD) + check_symbol_exists(RTLD_NOW dlfcn.h HAVE_DECL_RTLD_NOW) + + set(CFG_HEADERS ${CFG_HEADERS_SAVE}) + cmake_pop_check_state() +endif() + + +if(HAVE_DLOPEN) # OR .... ) + set(HAVE_DYNAMIC_LOADING 1) +else() + set(HAVE_DYNAMIC_LOADING 0) +endif() + + +####################################################################### +# +# check some types +# +####################################################################### +check_type_size("gid_t" HAVE_GID_T) +if(NOT HAVE_GID_T) + set(gid_t int) +else() + set(gid_t 0) +endif() + +check_type_size("mode_t" HAVE_MODE_T) +if(NOT HAVE_MODE_T) + set(mode_t int) +else() + set(mode_t 0) +endif() + +check_type_size("off_t" HAVE_OFF_T) +if(NOT HAVE_OFF_T) + set(off_t "long int") +else() + set(off_t 0) +endif() + +check_type_size("pid_t" HAVE_PID_T) +if(NOT HAVE_PID_T) + set(pid_t int) +else() + set(pid_t 0) +endif() + +check_type_size("size_t" HAVE_SIZE_T) +if(NOT HAVE_SIZE_T) + set(size_t "unsigned int") +else() + set(size_t 0) +endif() + +set(CMAKE_EXTRA_INCLUDE_FILES ${CFG_HEADERS}) +check_type_size("uint64_t" HAVE_UINT64_T) +check_type_size("int64_t" HAVE_INT64_T) +check_type_size("uint32_t" HAVE_UINT32_T) +check_type_size("int32_t" HAVE_INT32_T) +check_type_size("__uint128_t" HAVE_GCC_UINT128_T) +unset(CMAKE_EXTRA_INCLUDE_FILES) + +set(CMAKE_EXTRA_INCLUDE_FILES "sys/socket.h") +check_type_size("socklen_t" HAVE_SOCKLEN_T) +unset(CMAKE_EXTRA_INCLUDE_FILES) +if(NOT HAVE_SOCKLEN_T) + set(socklen int) +else() + set(socklen_t 0) +endif() + +check_type_size("uid_t" HAVE_UID_T) +if(NOT HAVE_UID_T) + set(uid_t int) +else() + set(uid_t 0) +endif() + +set(CMAKE_EXTRA_INCLUDE_FILES "time.h") +check_type_size("clock_t" HAVE_CLOCK_T) +unset(CMAKE_EXTRA_INCLUDE_FILES) +if(NOT HAVE_CLOCK_T) + set(clock_t long) +else() + set(clock_t 0) +endif() + + +check_c_source_compiles("int main() {const int i;}" const_WORKS) +if(NOT const_WORKS) + set(const 1) +else() + set(const 0) +endif() + +check_c_source_compiles("int main() {signed int i;}" signed_WORKS) +if(NOT signed_WORKS) + set(signed 1) +else() + set(signed 0) +endif() + +check_c_source_compiles("int main() {volatile int i;}" volatile_WORKS) +if(NOT volatile_WORKS) + set(volatile 1) +else() + set(volatile 0) +endif() + + +# Check for prototypes +set(check_src ${PROJECT_BINARY_DIR}/CMakeFiles/have_prototypes.c) +file(WRITE ${check_src} "int foo(int x) { return 0; } int main() { return foo(10); }") +python_platform_test( + HAVE_PROTOTYPES + "Checking for prototypes" + ${check_src} + DIRECT + ) + +if(HAVE_STDARG_PROTOTYPES) + set(vaargsHeader "stdarg.h") +else() + set(vaargsHeader "varargs.h") +endif() +check_c_source_compiles("#include <${vaargsHeader}>\n int main() {va_list list1, list2; list1 = list2;}" NOT_VA_LIST_IS_ARRAY) +if(NOT_VA_LIST_IS_ARRAY) + set(VA_LIST_IS_ARRAY 0) +else() + set(VA_LIST_IS_ARRAY 1) +endif() + +# Check whether char is unsigned +set(check_src ${PROJECT_BINARY_DIR}/CMakeFiles/ac_cv_c_char_unsigned.c) +file(WRITE ${check_src} "int main() { static int test_array [1 - 2 * !( ((char) -1) < 0 )]; +test_array [0] = 0; return test_array [0]; return 0; }") +python_platform_test( + HAVE_C_CHAR_UNSIGNED + "Checking whether char is unsigned" + ${check_src} + INVERT + ) +if(HAVE_C_CHAR_UNSIGNED AND NOT CMAKE_C_COMPILER_ID MATCHES "^GNU$") + set(__CHAR_UNSIGNED__ 1) +endif() + +# Check if the dirent structure of a d_type field and DT_UNKNOWN is defined +set(check_src ${PROJECT_BINARY_DIR}/CMakeFiles/have_dirent_d_type.c) +file(WRITE ${check_src} "#include +int main() { + struct dirent entry; + return entry.d_type == DT_UNKNOWN; +} +") +python_platform_test( + HAVE_DIRENT_D_TYPE + "Checking if the dirent structure of a d_type field" + ${check_src} + DIRECT + ) + +# Check if the Linux getrandom() syscall is available +set(check_src ${PROJECT_BINARY_DIR}/CMakeFiles/have_getrandom_syscall.c) +file(WRITE ${check_src} "#include +#include +#include +#include +int main() { + char buffer[1]; + const size_t buflen = sizeof(buffer); + const int flags = 0; + /* ignore the result, Python checks for ENOSYS at runtime */ + (void)syscall(SYS_getrandom, buffer, buflen, flags); + return 0; +} +") +python_platform_test( + HAVE_GETRANDOM_SYSCALL + "Checking for the Linux getrandom() syscall" + ${check_src} + DIRECT + ) + +# check if the getrandom() function is available +# the test was written for the Solaris function of +set(check_src ${PROJECT_BINARY_DIR}/CMakeFiles/have_getrandom.c) +file(WRITE ${check_src} "#include +int main() { + char buffer[1]; + const size_t buflen = sizeof(buffer); + const int flags = 0; + /* ignore the result, Python checks for ENOSYS at runtime */ + (void)getrandom(buffer, buflen, flags); + return 0; +} +") +python_platform_test( + HAVE_GETRANDOM + "Checking for the getrandom() function" + ${check_src} + DIRECT + ) + +####################################################################### +# +# tests for bugs and other stuff +# +####################################################################### + +check_c_source_compiles("#include \n int main() {getpgrp(0);}" GETPGRP_HAVE_ARG) + +check_c_source_compiles("#include \n int main() {setpgrp(0, 0);}" SETPGRP_HAVE_ARG) + +# Check for inline +set(USE_INLINE 0) +foreach(inline_type inline __inline__ __inline) + set(check_src ${PROJECT_BINARY_DIR}/CMakeFiles/ac_cv_c_${inline_type}.c) + file(WRITE ${check_src} "#ifndef __cplusplus + typedef int foo_t; + static ${inline_type} foo_t static_foo () {return 0; } + ${inline_type} foo_t foo () {return 0; } + int main() { return 0; } + #endif + ") + python_platform_test( + HAVE_${inline_type} + "Checking for ${inline_type}" + ${check_src} + DIRECT + ) + if(HAVE_${inline_type}) + set(USE_INLINE 1) + break() + endif() +endforeach() +if(USE_INLINE AND NOT inline_type STREQUAL "inline") + # XXX Need to define as inline +endif() + +# Check for append_history in -lreadline +set(check_src ${PROJECT_BINARY_DIR}/CMakeFiles/ac_cv_lib_readline_append_history.c) +file(WRITE ${check_src} "/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern \"C\" +#endif +char append_history (); +int main () { return append_history (); } +") +cmake_push_check_state() +list(APPEND CMAKE_REQUIRED_LIBRARIES readline) +python_platform_test( + HAVE_RL_APPEND_HISTORY + "Checking for append_history in -lreadline" + ${check_src} + DIRECT + ) +cmake_pop_check_state() + +check_c_source_runs("#include \n int main() { + int val1 = nice(1); + if (val1 != -1 && val1 == nice(2)) exit(0); + exit(1);}" HAVE_BROKEN_NICE) + +check_c_source_runs(" #include + int main () { + struct pollfd poll_struct = { 42, POLLIN|POLLPRI|POLLOUT, 0 }; close (42); + int poll_test = poll (&poll_struct, 1, 0); + if (poll_test < 0) { exit(0); } + else if (poll_test == 0 && poll_struct.revents != POLLNVAL) { exit(0); } + else { exit(1); } }" + HAVE_BROKEN_POLL) + + +# Check tzset(3) exists and works like we expect it to +set(check_src ${PROJECT_BINARY_DIR}/CMakeFiles/ac_cv_working_tzset.c) +file(WRITE ${check_src} "#include +#include +#include + +#if HAVE_TZNAME +extern char *tzname[]; +#endif + +int main() +{ + /* Note that we need to ensure that not only does tzset(3) + do 'something' with localtime, but it works as documented + in the library reference and as expected by the test suite. + This includes making sure that tzname is set properly if + tm->tm_zone does not exist since it is the alternative way + of getting timezone info. + + Red Hat 6.2 doesn't understand the southern hemisphere + after New Year's Day. + */ + + time_t groundhogday = 1044144000; /* GMT-based */ + time_t midyear = groundhogday + (365 * 24 * 3600 / 2); + + putenv(\"TZ=UTC+0\"); + tzset(); + if (localtime(&groundhogday)->tm_hour != 0) + exit(1); +#if HAVE_TZNAME + /* For UTC, tzname[1] is sometimes \"\", sometimes \" \" */ + if (strcmp(tzname[0], \"UTC\") || + (tzname[1][0] != 0 && tzname[1][0] != ' ')) + exit(1); +#endif + + putenv(\"TZ=EST+5EDT,M4.1.0,M10.5.0\"); + tzset(); + if (localtime(&groundhogday)->tm_hour != 19) + exit(1); +#if HAVE_TZNAME + if (strcmp(tzname[0], \"EST\") || strcmp(tzname[1], \"EDT\")) + exit(1); +#endif + + putenv(\"TZ=AEST-10AEDT-11,M10.5.0,M3.5.0\"); + tzset(); + if (localtime(&groundhogday)->tm_hour != 11) + exit(1); +#if HAVE_TZNAME + if (strcmp(tzname[0], \"AEST\") || strcmp(tzname[1], \"AEDT\")) + exit(1); +#endif + +#if HAVE_STRUCT_TM_TM_ZONE + if (strcmp(localtime(&groundhogday)->tm_zone, \"AEDT\")) + exit(1); + if (strcmp(localtime(&midyear)->tm_zone, \"AEST\")) + exit(1); +#endif + + exit(0); +} +") +cmake_push_check_state() +add_cond(CMAKE_REQUIRED_DEFINITIONS HAVE_TZNAME "-DHAVE_TZNAME") +add_cond(CMAKE_REQUIRED_DEFINITIONS HAVE_STRUCT_TM_TM_ZONE "-DHAVE_STRUCT_TM_TM_ZONE") +python_platform_test_run( + HAVE_WORKING_TZSET + "Checking for working tzset()" + ${check_src} + DIRECT + ) +cmake_pop_check_state() + +# Check for broken unsetenv +set(check_src ${PROJECT_BINARY_DIR}/CMakeFiles/have_broken_unsetenv.c) +file(WRITE ${check_src} "#include +int main() { + int res = unsetenv(\"DUMMY\"); +} +") +python_platform_test( + HAVE_BROKEN_UNSETENV + "Checking for broken unsetenv" + ${check_src} + INVERT + ) + +# Define if the system reports an invalid PIPE_BUF value. +set(HAVE_BROKEN_PIPE_BUF 0) +if(CMAKE_SYSTEM MATCHES AIX) + set(HAVE_BROKEN_PIPE_BUF 1) +endif() + +# Define if aligned memory access is required +set(check_src ${PROJECT_BINARY_DIR}/CMakeFiles/aligned_required.c) +file(WRITE ${check_src} "int main() +{ + char s[16]; + int i, *p1, *p2; + for (i=0; i < 16; i++) + s[i] = i; + p1 = (int*)(s+1); + p2 = (int*)(s+2); + if (*p1 == *p2) + return 1; + return 0; +} +") +python_platform_test_run( + HAVE_ALIGNED_REQUIRED + "Checking aligned memory access is required" + ${check_src} + INVERT + ) + +# Define if mbstowcs(NULL, "text", 0) does not return the number of wide +# chars that would be converted. +set(check_src ${PROJECT_BINARY_DIR}/CMakeFiles/ac_cv_broken_mbstowcs.c) +file(WRITE ${check_src} "#include +#include +int main() { + size_t len = -1; + const char *str = \"text\"; + len = mbstowcs(NULL, str, 0); + return (len != 4); +} +") +python_platform_test_run( + HAVE_BROKEN_MBSTOWCS + "Checking for broken mbstowcs" + ${check_src} + INVERT + ) + +# Issue #25658: POSIX hasn't defined that pthread_key_t is compatible with int. +# This checking will be unnecessary after removing deprecated TLS API. +# The cast to long int works around a bug in the HP C Compiler +# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects +# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. +# This bug is HP SR number 8606223364. +if(HAVE_PTHREAD_H) + set(CMAKE_EXTRA_INCLUDE_FILES "pthread.h") + check_type_size(pthread_key_t SIZEOF_PTHREAD_KEY_T) + unset(CMAKE_EXTRA_INCLUDE_FILES) + + if("${SIZEOF_PTHREAD_KEY_T}" STREQUAL "${SIZEOF_INT}") + check_c_source_compiles("#include \n int main(void){pthread_key_t k; k * 1;}" PTHREAD_KEY_T_IS_COMPATIBLE_WITH_INT) + endif() +endif() + +# Check whether the compiler supports computed gotos +set(check_src ${PROJECT_BINARY_DIR}/CMakeFiles/ac_cv_computed_gotos.c) +file(WRITE ${check_src} "int main(int argc, char **argv) + { + static void *targets[1] = { &&LABEL1 }; + goto LABEL2; + LABEL1: + return 0; + LABEL2: + goto *targets[0]; + return 1; + } +") +python_platform_test_run( + HAVE_COMPUTED_GOTOS + "Checking whether ${CMAKE_C_COMPILER_ID} supports computed gotos" + ${check_src} + DIRECT + ) + +# Availability of -O2 +cmake_push_check_state() +list(APPEND CMAKE_REQUIRED_DEFINITIONS -O2) +check_c_source_compiles("int main () {return 0;}" have_O2) +cmake_pop_check_state() + +# _FORTIFY_SOURCE wrappers for memmove and bcopy are incorrect: +# http://sourceware.org/ml/libc-alpha/2010-12/msg00009.html +set(check_src ${PROJECT_BINARY_DIR}/CMakeFiles/have_glibc_memmove_bug.c) +file(WRITE ${check_src} "#include +#include +#include +void foo(void *p, void *q) { memmove(p, q, 19); } +int main() { + char a[32] = \"123456789000000000\"; + foo(&a[9], a); + if (strcmp(a, \"123456789123456789000000000\") != 0) + return 1; + foo(a, &a[9]); + if (strcmp(a, \"123456789000000000\") != 0) + return 1; + return 0; +} +") +cmake_push_check_state() +add_cond(CMAKE_REQUIRED_DEFINITIONS have_O2 "-O2;-D_FORTIFY_SOURCE=2") +python_platform_test_run( + HAVE_GLIBC_MEMMOVE_BUG + "Checking for glibc _FORTIFY_SOURCE/memmove bug" + ${check_src} + INVERT + ) +cmake_pop_check_state() + +# HAVE_IPA_PURE_CONST_BUG +if(HAVE_GCC_ASM_FOR_X87 AND CMAKE_C_COMPILER_ID MATCHES "GNU") + # Some versions of gcc miscompile inline asm: + # http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46491 + # http://gcc.gnu.org/ml/gcc/2010-11/msg00366.html + set(check_src ${PROJECT_BINARY_DIR}/CMakeFiles/have_ipa_pure_const_bug.c) + file(WRITE ${check_src} "__attribute__((noinline)) int + foo(int *p) { + int r; + asm ( \"movl \\$6, (%1)\\n\\t\" + \"xorl %0, %0\\n\\t\" + : \"=r\" (r) : \"r\" (p) : \"memory\" + ); + return r; + } + int main() { + int p = 8; + if ((foo(&p) ? : p) != 6) + return 1; + return 0; + } + ") + python_platform_test_run( + HAVE_IPA_PURE_CONST_BUG + "Checking for gcc ipa-pure-const bug" + ${check_src} + INVERT + ) +endif() + +# Check for stdatomic.h +set(check_src ${PROJECT_BINARY_DIR}/CMakeFiles/have_stdatomic_h.c) +file(WRITE ${check_src} "#include +atomic_int value = ATOMIC_VAR_INIT(1); +_Atomic void *py_atomic_address = (void*) &value; +int main() { + int loaded_value = atomic_load(&value); + return 0; +} +") +python_platform_test( + HAVE_STD_ATOMIC + "Checking for stdatomic.h" + ${check_src} + DIRECT + ) + +# Has builtin atomics +set(check_src ${PROJECT_BINARY_DIR}/CMakeFiles/have_builtin_atomic.c) +file(WRITE ${check_src} "volatile int val = 1; +int main() { + __atomic_load_n(&val, __ATOMIC_SEQ_CST); + return 0; +} +") +python_platform_test( + HAVE_BUILTIN_ATOMIC + "Checking for GCC >= 4.7 __atomic builtins" + ${check_src} + DIRECT + ) + +if(HAVE_LONG_LONG) + # Checking for %lld and %llu printf() format support + set(check_src ${PROJECT_BINARY_DIR}/CMakeFiles/ac_cv_have_long_long_format.c) + file(WRITE ${check_src} "#include +#include +#include + +#ifdef HAVE_SYS_TYPES_H +#include +#endif + +int main() +{ + char buffer[256]; + + if (sprintf(buffer, \"%lld\", (long long)123) < 0) + return 1; + if (strcmp(buffer, \"123\")) + return 1; + + if (sprintf(buffer, \"%lld\", (long long)-123) < 0) + return 1; + if (strcmp(buffer, \"-123\")) + return 1; + + if (sprintf(buffer, \"%llu\", (unsigned long long)123) < 0) + return 1; + if (strcmp(buffer, \"123\")) + return 1; + + return 0; +} +") + cmake_push_check_state() + add_cond(CMAKE_REQUIRED_DEFINITIONS HAVE_SYS_TYPES_H "-DHAVE_SYS_TYPES_H") + python_platform_test_run( + HAVE_LONG_LONG_FORMAT + "Checking for %lld and %llu printf() format support" + ${check_src} + DIRECT + ) + cmake_pop_check_state() + if(HAVE_LONG_LONG_FORMAT) + set(PY_FORMAT_LONG_LONG "ll") + endif() +endif() + + +# Checking for %zd printf() format support +set(check_src ${PROJECT_BINARY_DIR}/CMakeFiles/ac_cv_have_size_t_format.c) +file(WRITE ${check_src} "#include +#include +#include + +#ifdef HAVE_SYS_TYPES_H +#include +#endif + +#ifdef HAVE_SSIZE_T +typedef ssize_t Py_ssize_t; +#elif SIZEOF_VOID_P == SIZEOF_LONG +typedef long Py_ssize_t; +#else +typedef int Py_ssize_t; +#endif + +int main() +{ + char buffer[256]; + if(sprintf(buffer, \"%zd\", (size_t)123) < 0) + return 1; + if (strcmp(buffer, \"123\")) + return 1; + if (sprintf(buffer, \"%zd\", (Py_ssize_t)-123) < 0) + return 1; + if (strcmp(buffer, \"-123\")) + return 1; + return 0; +} +") +cmake_push_check_state() +add_cond(CMAKE_REQUIRED_DEFINITIONS HAVE_SYS_TYPES_H "-DHAVE_SYS_TYPES_H") +add_cond(CMAKE_REQUIRED_DEFINITIONS HAVE_SSIZE_T "-DHAVE_SSIZE_T") +add_cond(CMAKE_REQUIRED_DEFINITIONS SIZEOF_VOID_P "-DSIZEOF_VOID_P=${SIZEOF_VOID_P}") +add_cond(CMAKE_REQUIRED_DEFINITIONS SIZEOF_LONG "-DSIZEOF_LONG=${SIZEOF_LONG}") +python_platform_test_run( + HAVE_SIZE_T_FORMAT + "Checking for %zd printf() format support()" + ${check_src} + DIRECT + ) +cmake_pop_check_state() +if(HAVE_SIZE_T_FORMAT) + set(PY_FORMAT_SIZE_T "z") +endif() + + +########################################################## + +if(ZLIB_LIBRARIES) + cmake_push_check_state() + set(CFG_HEADERS_SAVE ${CFG_HEADERS}) + + set(CFG_HEADERS ${CFG_HEADERS} zlib.h) + add_cond(CMAKE_REQUIRED_INCLUDES ZLIB_INCLUDE_DIRS ${ZLIB_INCLUDE_DIRS}) + add_cond(CMAKE_REQUIRED_LIBRARIES ZLIB_LIBRARIES ${ZLIB_LIBRARIES}) + check_symbol_exists(inflateCopy "${CFG_HEADERS}" HAVE_ZLIB_COPY) + + set(CFG_HEADERS ${CFG_HEADERS_SAVE}) + cmake_pop_check_state() +endif() + +# Check if tirpc static library and its dependencies can be linked statically +# and set TIRPC_LIBRARY_STATIC_DEPENDENCY_REQUIRED and TIRPC_STATIC_LIBRARIES. +# +# If the tirpc static library is built with the gssapi feature, and no gssapi_krb5 +# static library can be found, the python extensions depending on tirpc should be +# disabled +# +# Indeed, minimal support for static linking in krb5 was only re-introduced starting +# with krb5-1.19.2 (see [1]) which may not yet be available (see [2]). +# +# [1] https://github.com/krb5/krb5/commit/af44e8dee9b5bfffb05eb5a9b89c79c02ab7c2ff +# [2] https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=439039 + +set(_tirpc_library_static_dependencies_required 0) +set(_tirpc_static_libraries) + +if(WITH_STATIC_DEPENDENCIES AND TIRPC_LIBRARY) + + # Attempt to find gssapi_krb5 static library + set(__CURRENT_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES}) + set(CMAKE_FIND_LIBRARY_SUFFIXES "${CMAKE_STATIC_LIBRARY_SUFFIX}") + find_library(GSSAPI_KRB5_STATIC_LIBRARY gssapi_krb5) + set(CMAKE_FIND_LIBRARY_SUFFIXES ${__CURRENT_CMAKE_FIND_LIBRARY_SUFFIXES}) + + # Attempt to find gssapi_krb5 shared library + set(__CURRENT_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES}) + if(NOT ${CMAKE_IMPORT_LIBRARY_SUFFIX} STREQUAL "") + set(CMAKE_FIND_LIBRARY_SUFFIXES "${CMAKE_IMPORT_LIBRARY_SUFFIX}") + else() + set(CMAKE_FIND_LIBRARY_SUFFIXES "${CMAKE_SHARED_LIBRARY_SUFFIX}") + endif() + find_library(GSSAPI_KRB5_SHARED_LIBRARY gssapi_krb5) + set(CMAKE_FIND_LIBRARY_SUFFIXES ${__CURRENT_CMAKE_FIND_LIBRARY_SUFFIXES}) + + if(GSSAPI_KRB5_SHARED_LIBRARY) + # Attempt to test if tirpc library is built with the krb5 gssapi feature + # by looking for the symbol "authgss_create" linking against the corresponding + # shared library. + + # Save variables + set(__CURRENT_CMAKE_EXE_LINKER_FLAGS ${CMAKE_EXE_LINKER_FLAGS}) + cmake_push_check_state() + + list(APPEND CMAKE_REQUIRED_LIBRARIES ${TIRPC_LIBRARY}) + add_cond(CMAKE_REQUIRED_LIBRARIES CMAKE_USE_PTHREADS_INIT "${CMAKE_THREAD_LIBS_INIT}") + add_cond(CMAKE_REQUIRED_LIBRARIES GSSAPI_KRB5_SHARED_LIBRARY "${GSSAPI_KRB5_SHARED_LIBRARY}") + + # If any, remove "-static" flags + string(REPLACE "-static" "" _cmake_exe_linker_flags "${CMAKE_EXE_LINKER_FLAGS}") + set(CMAKE_EXE_LINKER_FLAGS ${_cmake_exe_linker_flags} CACHE STRING "" FORCE) + + check_symbol_exists("authgss_create" "tirpc/rpc/auth_gss.h" TIRPC_WITH_AUTHGSS_CREATE) + + # Restore variables + cmake_pop_check_state() + set(CMAKE_EXE_LINKER_FLAGS ${__CURRENT_CMAKE_EXE_LINKER_FLAGS} CACHE STRING "Flags used by the linker during all build types." FORCE) + + if(TIRPC_WITH_AUTHGSS_CREATE) + set(_tirpc_library_static_dependencies_required 1) + set(_tirpc_static_libraries ${GSSAPI_KRB5_STATIC_LIBRARY}) + endif() + else() + # If shared library can't be found, we assume the static library is required. + set(_tirpc_library_static_dependencies_required 1) + set(_tirpc_static_libraries ${GSSAPI_KRB5_STATIC_LIBRARY}) + endif() + +endif() +if(NOT DEFINED TIRPC_LIBRARY_STATIC_DEPENDENCY_REQUIRED) + set(TIRPC_LIBRARY_STATIC_DEPENDENCY_REQUIRED ${_tirpc_library_static_dependencies_required} CACHE BOOL "") + message(STATUS "Setting TIRPC_LIBRARY_STATIC_DEPENDENCY_REQUIRED to ${TIRPC_LIBRARY_STATIC_DEPENDENCY_REQUIRED}") +endif() +if(TIRPC_LIBRARY_STATIC_DEPENDENCY_REQUIRED AND NOT DEFINED TIRPC_STATIC_LIBRARIES) + set(TIRPC_STATIC_LIBRARIES ${_tirpc_static_libraries} CACHE BOOL "") + message(STATUS "Setting TIRPC_STATIC_LIBRARIES to ${TIRPC_STATIC_LIBRARIES}") +endif() + +############################################ + +# Check for CAN_RAW_FD_FRAMES +check_c_source_compiles("#include \n int main () { int can_raw_fd_frames = CAN_RAW_FD_FRAMES; }" HAVE_LINUX_CAN_RAW_FD_FRAMES) + +# Check for CAN_RAW_JOIN_FILTERS +check_c_source_compiles("#include \n int main () { int can_raw_join_filters = CAN_RAW_JOIN_FILTERS; }" HAVE_LINUX_CAN_RAW_JOIN_FILTERS) +endif() + +set(HAVE_OSX105_SDK 0) +if(APPLE) + # Check for OSX 10.5 SDK or later + set(check_src ${PROJECT_BINARY_DIR}/CMakeFiles/have_osx105_sdk.c) + file(WRITE ${check_src} "#include +int main(int argc, char* argv[]){FSIORefNum fRef = 0; return 0;}") + python_platform_test( + HAVE_OSX105_SDK + "Checking for OSX 10.5 SDK or later" + ${check_src} + DIRECT + ) +endif() + +# todo +set(PTHREAD_SYSTEM_SCHED_SUPPORTED 1) +set(HAVE_DEVICE_MACROS ${HAVE_MAKEDEV}) + +# setup the python platform +set(PY_PLATFORM generic) + +if(CMAKE_SYSTEM MATCHES Linux) + if (PY_VERSION VERSION_LESS 3.3) + set(PY_PLATFORM linux2) + else() + set(PY_PLATFORM linux) + endif() +endif() + +if(CMAKE_SYSTEM MATCHES Darwin) + set(PY_PLATFORM darwin) +endif() + +if(CMAKE_SYSTEM MATCHES FreeBSD) + set(PY_PLATFORM freebsd5) # which version to use ? +endif() + +if(CMAKE_SYSTEM MATCHES NetBSD) + set(PY_PLATFORM netbsd1) +endif() + +if(CMAKE_SYSTEM MATCHES AIX) + set(PY_PLATFORM aix4) +endif() + +if(CMAKE_SYSTEM MATCHES BeOS) + set(PY_PLATFORM beos5) +endif() + +if(CMAKE_SYSTEM MATCHES IRIX) + set(PY_PLATFORM irix6) +endif() + +if(CMAKE_SYSTEM MATCHES SunOS) + set(PY_PLATFORM sunos5) +endif() + +if(CMAKE_SYSTEM MATCHES UnixWare) + set(PY_PLATFORM unixware7) +endif() + +if(CMAKE_SYSTEM MATCHES Windows) + set(PY_PLATFORM win32) +endif() + diff --git a/third/python-cmake/cmake/Extensions.cmake b/third/python-cmake/cmake/Extensions.cmake new file mode 100644 index 00000000..45b63f23 --- /dev/null +++ b/third/python-cmake/cmake/Extensions.cmake @@ -0,0 +1,243 @@ +# This function adds a python extension to the buildsystem. +# +# Usage: +# +# add_python_extension( +# extension_name +# SOURCES source1.c source2.c ... +# [ REQUIRES variable1 variable2 ... ] +# [ DEFINITIONS define1 define2 ... ] +# [ LIBRARIES lib1 lib2 ... ] +# [ INCLUDEDIRS dir1 dir2 ... ] +# [ BUILTIN | ALWAYS_BUILTIN | NEVER_BUILTIN ] +# ) +# +# extension_name: the name of the library without any .so extension. +# SOURCES: a list of filenames realtive to the Modules/ directory that make +# up this extension. +# REQUIRES: this extension will not be built unless all the variables listed +# here evaluate to true. You should include any variables you use +# in the LIBRARIES and INCLUDEDIRS sections. +# DEFINITIONS: an optional list of definitions to pass to the compiler while +# building this module. Do not include the -D prefix. +# LIBRARIES: an optional list of additional libraries. +# INCLUDEDIRS: an optional list of additional include directories. +# BUILTIN: if this is set the module will be compiled statically into +# libpython by default. The user can still override by setting +# BUILTIN_[extension_name]=OFF. +# ALWAYS_BUILTIN: if this is set the module will always be compiled statically into +# libpython. +# NEVER_BUILTIN: if this is set the module will never be compiled statically into +# libpython. If WITH_STATIC_DEPENDENCIES is ON, extension is disabled. +# NO_INSTALL: do not install or package the extension. +# +# Two user-settable options are created for each extension added: +# ENABLE_[extension_name] defaults to ON. If set to OFF the extension will +# not be added at all. +# BUILTIN_[extension_name] defaults to the value of +# BUILD_EXTENSIONS_AS_BUILTIN, which defaults to OFF, +# unless BUILTIN is set when calling +# add_python_extension. Adds the extension source +# files to libpython instead of compiling a separate +# library. +# These options convert the extension_name to upper case first and remove any +# leading underscores. So add_python_extension(_foo ...) will create the +# options ENABLE_FOO and BUILTIN_FOO. + +function(add_python_extension name) + set(options BUILTIN ALWAYS_BUILTIN NEVER_BUILTIN NO_INSTALL) + set(oneValueArgs) + set(multiValueArgs REQUIRES SOURCES DEFINITIONS LIBRARIES INCLUDEDIRS) + cmake_parse_arguments(ADD_PYTHON_EXTENSION + "${options}" + "${oneValueArgs}" + "${multiValueArgs}" + ${ARGN} + ) + + # Remove _ from the beginning of the name. + string(REGEX REPLACE "^_" "" pretty_name "${name}") + + # Upper case the name. + string(TOUPPER "${pretty_name}" upper_name) + + # Add a prefix to the target name so it doesn't clash with any system + # libraries that we might want to link against (eg. readline) + set(target_name extension_${pretty_name}) + + set(enable_default ON) + if(ADD_PYTHON_EXTENSION_NEVER_BUILTIN AND WITH_STATIC_DEPENDENCIES) + set(enable_default OFF) + endif() + + # Add options that the user can set to control whether this extension is + # compiled, and whether it is compiled in to libpython itself. + option(ENABLE_${upper_name} + "Controls whether the \"${name}\" extension will be built" + ${enable_default} + ) + if(ENABLE_${upper_name}) + mark_as_advanced(FORCE ENABLE_${upper_name}) + else() + mark_as_advanced(CLEAR ENABLE_${upper_name}) + endif() + + if(ADD_PYTHON_EXTENSION_NEVER_BUILTIN AND WITH_STATIC_DEPENDENCIES AND ENABLE_${upper_name}) + set(reason " because extension is declared as NEVER_BUILTIN and WITH_STATIC_DEPENDENCIES is ON") + set(ENABLE_${upper_name} OFF CACHE BOOL "Forced to OFF${reason}" FORCE) + message(STATUS "Setting ENABLE_${upper_name} to OFF${reason}") + endif() + + # Check all the things we require are found. + set(missing_deps "") + foreach(dep ${ADD_PYTHON_EXTENSION_REQUIRES} ENABLE_${upper_name}) + string(REPLACE " " ";" list_dep ${dep}) + if(NOT (${list_dep})) + set(missing_deps "${missing_deps}${dep} ") + endif() + endforeach() + + if(ADD_PYTHON_EXTENSION_NEVER_BUILTIN) + set(BUILTIN_${upper_name} 0) + elseif(ADD_PYTHON_EXTENSION_ALWAYS_BUILTIN) + set(BUILTIN_${upper_name} 1) + else() + # Add options that the extention is either external to libpython or + # builtin. These will be marked as advanced unless different from default + # values + if(NOT ADD_PYTHON_EXTENSION_BUILTIN) + set(ADD_PYTHON_EXTENSION_BUILTIN ${BUILD_EXTENSIONS_AS_BUILTIN}) + endif() + cmake_dependent_option( + BUILTIN_${upper_name} + "If this is set the \"${name}\" extension will be compiled in to libpython" + ${ADD_PYTHON_EXTENSION_BUILTIN} + "NOT missing_deps" + OFF + ) + if(NOT missing_deps) + if((BUILTIN_${upper_name} AND BUILD_EXTENSIONS_AS_BUILTIN) + OR (NOT BUILTIN_${upper_name} AND NOT BUILD_EXTENSIONS_AS_BUILTIN)) + mark_as_advanced(FORCE BUILTIN_${upper_name}) + else() + mark_as_advanced(CLEAR BUILTIN_${upper_name}) + endif() + endif() + endif() + + # If any dependencies were missing don't include this extension. + if(missing_deps) + string(STRIP "${missing_deps}" missing_deps) + set(extensions_disabled "${extensions_disabled}${name} (not set: ${missing_deps});" + CACHE INTERNAL "" FORCE) + return() + else() + set(extensions_enabled "${extensions_enabled}${name};" CACHE INTERNAL "" FORCE) + endif() + + # Callers to this function provide source files relative to the Modules/ + # directory. We need to get absolute paths for them all. + set(absolute_sources "") + foreach(source ${ADD_PYTHON_EXTENSION_SOURCES}) + get_filename_component(ext ${source} EXT) + + # Treat assembler sources differently + if(ext STREQUAL ".S") + set_source_files_properties(Modules/${source} PROPERTIES LANGUAGE ASM) + endif() + set(absolute_src ${source}) + if(NOT IS_ABSOLUTE ${source}) + set(absolute_src ${SRC_DIR}/Modules/${source}) + endif() + list(APPEND absolute_sources ${absolute_src}) + endforeach() + + if(BUILTIN_${upper_name}) + if(PY_VERSION VERSION_GREATER_EQUAL "3.8") + list(APPEND ADD_PYTHON_EXTENSION_DEFINITIONS Py_BUILD_CORE_BUILTIN) + endif() + # This will be compiled into libpython instead of as a separate library + set_property(GLOBAL APPEND PROPERTY builtin_extensions ${name}) + set_property(GLOBAL APPEND PROPERTY extension_${name}_sources ${absolute_sources}) + set_property(GLOBAL APPEND PROPERTY extension_${name}_link_libraries ${ADD_PYTHON_EXTENSION_LIBRARIES}) + set_property(GLOBAL APPEND PROPERTY extension_${name}_includedirs ${ADD_PYTHON_EXTENSION_INCLUDEDIRS}) + set_property(GLOBAL APPEND PROPERTY extension_${name}_definitions ${ADD_PYTHON_EXTENSION_DEFINITIONS}) + elseif(WIN32 AND NOT BUILD_LIBPYTHON_SHARED) + # Extensions cannot be built against a static libpython on windows + else() + + add_library(${target_name} SHARED ${absolute_sources}) + target_include_directories(${target_name} PUBLIC "${ADD_PYTHON_EXTENSION_INCLUDEDIRS}") + + if(PY_VERSION VERSION_GREATER_EQUAL "3.8") + list(APPEND ADD_PYTHON_EXTENSION_DEFINITIONS Py_BUILD_CORE_MODULE) + endif() + + if(WIN32) + string(REGEX MATCH "Py_LIMITED_API" require_limited_api "${ADD_PYTHON_EXTENSION_DEFINITIONS}") + if(require_limited_api STREQUAL "") + list(APPEND ADD_PYTHON_EXTENSION_LIBRARIES libpython-shared) + else() + list(APPEND ADD_PYTHON_EXTENSION_LIBRARIES libpython3-shared) + endif() + endif() + + target_link_libraries(${target_name} ${ADD_PYTHON_EXTENSION_LIBRARIES}) + + if(WIN32) + #list(APPEND ADD_PYTHON_EXTENSION_DEFINITIONS Py_NO_ENABLE_SHARED) + if(MINGW) + set_target_properties(${target_name} PROPERTIES + LINK_FLAGS -Wl,--enable-auto-import + ) + endif() + set_target_properties(${target_name} PROPERTIES + SUFFIX .pyd + ) + endif() + + if(APPLE) + set_target_properties(${target_name} PROPERTIES + LINK_FLAGS -Wl,-undefined,dynamic_lookup + SUFFIX .so + ) + endif() + + # Turn off the "lib" prefix and add any compiler definitions + set_target_properties(${target_name} PROPERTIES + ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/${ARCHIVEDIR} + LIBRARY_OUTPUT_DIRECTORY ${EXTENSION_BUILD_DIR} + RUNTIME_OUTPUT_DIRECTORY ${EXTENSION_BUILD_DIR} + OUTPUT_NAME "${name}$<$,$>:.${SOABI}>" + PREFIX "" + ) + set_target_properties(${target_name} PROPERTIES + POSITION_INDEPENDENT_CODE ON + ) + + if(ADD_PYTHON_EXTENSION_DEFINITIONS) + set_target_properties(${target_name} PROPERTIES + COMPILE_DEFINITIONS "${ADD_PYTHON_EXTENSION_DEFINITIONS}") + endif() + + if(NOT ADD_PYTHON_EXTENSION_NO_INSTALL) + install(TARGETS ${target_name} + ARCHIVE DESTINATION ${ARCHIVEDIR} + LIBRARY DESTINATION ${EXTENSION_INSTALL_DIR} + RUNTIME DESTINATION ${EXTENSION_INSTALL_DIR}) + endif() + endif() +endfunction() + + +function(show_extension_summary) + if(extensions_disabled) + message(STATUS "") + message(STATUS "The following extensions will NOT be built:") + message(STATUS "") + foreach(line ${extensions_disabled}) + message(STATUS " ${line}") + endforeach() + message(STATUS "") + endif() +endfunction() diff --git a/third/python-cmake/cmake/FindPatch.cmake b/third/python-cmake/cmake/FindPatch.cmake new file mode 100644 index 00000000..b9242aea --- /dev/null +++ b/third/python-cmake/cmake/FindPatch.cmake @@ -0,0 +1,79 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +#.rst: +# FindPatch +# --------- +# +# The module defines the following variables: +# +# ``Patch_EXECUTABLE`` +# Path to patch command-line executable. +# ``Patch_FOUND`` +# True if the patch command-line executable was found. +# +# The following :prop_tgt:`IMPORTED` targets are also defined: +# +# ``Patch::patch`` +# The command-line executable. +# +# Example usage: +# +# .. code-block:: cmake +# +# find_package(Patch) +# if(Patch_FOUND) +# message("Patch found: ${Patch_EXECUTABLE}") +# endif() + +set(_doc "Patch command line executable") +set(_patch_path ) + +if(CMAKE_HOST_WIN32) + set(_patch_path + "$ENV{LOCALAPPDATA}/Programs/Git/bin" + "$ENV{LOCALAPPDATA}/Programs/Git/usr/bin" + "$ENV{APPDATA}/Programs/Git/bin" + "$ENV{APPDATA}/Programs/Git/usr/bin" + ) +endif() + +# First search the PATH +find_program(Patch_EXECUTABLE + NAME patch + PATHS ${_patch_path} + DOC ${_doc} + ) + +if(CMAKE_HOST_WIN32) + # Now look for installations in Git/ directories under typical installation + # prefixes on Windows. + find_program(Patch_EXECUTABLE + NAMES patch + PATH_SUFFIXES Git/usr/bin Git/bin GnuWin32/bin + DOC ${_doc} + ) +endif() + +if(Patch_EXECUTABLE AND NOT TARGET Patch::patch) + add_executable(Patch::patch IMPORTED) + set_property(TARGET Patch::patch PROPERTY IMPORTED_LOCATION ${Patch_EXECUTABLE}) + + execute_process(COMMAND ${Patch_EXECUTABLE} --version + OUTPUT_VARIABLE patch_version + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE + ) + set(_patch_version_regex ".*patch ([0-9]+\\.[0-9]+\\.[0-9]+)") + if(patch_version MATCHES "${_patch_version_regex}") + set(Patch_VERSION ${CMAKE_MATCH_1}) + endif() +endif() + +unset(_patch_path) +unset(_doc) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(Patch + REQUIRED_VARS Patch_EXECUTABLE + VERSION_VAR Patch_VERSION) diff --git a/third/python-cmake/cmake/PC/bdist_wininst/CMakeLists.txt b/third/python-cmake/cmake/PC/bdist_wininst/CMakeLists.txt new file mode 100644 index 00000000..83b37d23 --- /dev/null +++ b/third/python-cmake/cmake/PC/bdist_wininst/CMakeLists.txt @@ -0,0 +1,93 @@ +# For building the bdist_wininst subdir + +include_directories( + ${SRC_DIR}/Include + ${SRC_DIR}/Modules/zlib +) + +set(WININST_HEADERS + ${SRC_DIR}/PC/bdist_wininst/archive.h + ${SRC_DIR}/PC/bdist_wininst/resource.h +) + +set(WININST_SOURCES + ${SRC_DIR}/PC/bdist_wininst/extract.c + ${SRC_DIR}/PC/bdist_wininst/install.c + ${SRC_DIR}/Modules/zlib/adler32.c + ${SRC_DIR}/Modules/zlib/crc32.c + ${SRC_DIR}/Modules/zlib/inffast.c + ${SRC_DIR}/Modules/zlib/inflate.c + ${SRC_DIR}/Modules/zlib/inftrees.c + ${SRC_DIR}/Modules/zlib/zutil.c +) + +# Install tree directory +set(WININST_INSTALL_DIR ${PYTHONHOME}/distutils/command) + +# Build tree directory +set(WININST_BUILD_DIR ${PROJECT_BINARY_DIR}/${WININST_INSTALL_DIR}) + +# Compiler version +set(version "unknown") +foreach(msvcmajver IN ITEMS 90 10 11 12 14) + if(${MSVC${msvcmajver}}) + string(REGEX REPLACE "0$" "" msvcmajver ${msvcmajver}) + set(version "${msvcmajver}.0") + endif() +endforeach() + +# System architecture +set(arch "") +if(CMAKE_SIZEOF_VOID_P EQUAL 8) + set(arch "-amd64") +endif() + +# Set installer executable name +set(WININST_EXE_NAME "wininst-${version}${arch}") +message(STATUS "bdist_wininst: Generated 'Windows Installer' name is '${WININST_EXE_NAME}'") + +# Check if windows installer is already bundled in the source tree +set(_have_wininst_in_source 0) +set(_msg "bdist_wininst: Looking for executable named '${WININST_EXE_NAME}${CMAKE_EXECUTABLE_SUFFIX}' in source tree") +message(STATUS "${_msg}") +set(_expected_wininst ${SRC_DIR}/${WININST_INSTALL_DIR}/${WININST_EXE_NAME}${CMAKE_EXECUTABLE_SUFFIX}) +if(EXISTS ${_expected_wininst}) + set(_have_wininst_in_source 1) + message(STATUS "${_msg} - found \"${_expected_wininst}\"") +else() + message(STATUS "${_msg} - not found") +endif() + +# Skip if installer is already bundled in the source tree and BUILD_WININST_ALWAYS is OFF +set(_configure_reason "") +if(_have_wininst_in_source) + if(NOT BUILD_WININST_ALWAYS) + message(STATUS "bdist_wininst: Skipping installer configuration because it is already provided in the source tree.") + return() + else() + set(_configure_reason " because BUILD_WININST_ALWAYS is ON") + endif() +endif() + +message(STATUS "bdist_wininst: Configuring 'Windows Installer' named '${WININST_EXE_NAME}'${_configure_reason}") + +# Configure installer +add_executable(bdist_wininst WIN32 ${WININST_HEADERS} ${WININST_SOURCES}) +target_link_libraries(bdist_wininst + imagehlp + comctl32 +) +set_target_properties(bdist_wininst PROPERTIES + OUTPUT_NAME ${WININST_EXE_NAME} + RUNTIME_OUTPUT_DIRECTORY ${WININST_BUILD_DIR} +) +if(CMAKE_CONFIGURATION_TYPES) + add_custom_command(TARGET bdist_wininst POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_if_different + $ + ${WININST_BUILD_DIR}/${WININST_EXE_NAME}${CMAKE_EXECUTABLE_SUFFIX} + COMMENT "bdist_wininst: Copying installer into '${WININST_INSTALL_DIR}'" + ) +endif() + +install(TARGETS bdist_wininst DESTINATION ${WININST_INSTALL_DIR}) diff --git a/third/python-cmake/cmake/PC/launcher/CMakeLists.txt b/third/python-cmake/cmake/PC/launcher/CMakeLists.txt new file mode 100644 index 00000000..7ed270e9 --- /dev/null +++ b/third/python-cmake/cmake/PC/launcher/CMakeLists.txt @@ -0,0 +1,139 @@ + +function(_add_executable_without_windows target_name) + # Work around the lack of a "target_remove_definitions()" CMake command by + # explicitly undefining _WINDOWS. The following alternatives are either ineffective + # or not applicable: + # + # (1) Modifying and restoring CMAKE_C_FLAGS does not work reliably, as CMake appears + # to apply cached values during the generation step after the function executes. + # + # (2) Using get_target_property/set_property to manipulate COMPILE_DEFINITIONS + # is ineffective, since /D_WINDOWS is introduced via CMAKE_C_FLAGS and not + # associated with the target's properties. + # + # See: https://gitlab.kitware.com/cmake/cmake/-/issues/19796 + + add_executable(${target_name} ${ARGN}) + + # Note: /U_WINDOWS overrides the implicit /D_WINDOWS flag, resulting in MSVC warning D9025. + # This warning is harmless and cannot be suppressed directly. + target_compile_options(${target_name} PRIVATE /U_WINDOWS) +endfunction() + +# Install tree directory +set(LAUNCHER_INSTALL_DIR ${BIN_BUILD_DIR}) + +# Build tree directory +set(LAUNCHER_BUILD_DIR ${PROJECT_BINARY_DIR}/${LAUNCHER_INSTALL_DIR}) + +set(launcher_targets) + +set(build_venvlauncher 0) +# While support for building "venvlauncher" was introduced in Python 3.3, +# we require at least Python 3.9 to avoid the need to generate "pythonnt_rc.h", +# which was removed in python/cpython@4efc3360c9a ("bpo-41054: Simplify resource compilation on Windows (GH-21004)", 2020-06-24). +if(PY_VERSION VERSION_GREATER_EQUAL "3.9") + set(build_venvlauncher 1) +endif() + +if(build_venvlauncher) + set(target_sources + ${SRC_DIR}/PC/launcher.c + ${SRC_DIR}/PC/pylauncher.rc + ) + set(target_include_dirs + ${SRC_DIR}/PC/ + ) + set(target_libraries + version + ) + + # venvlauncher + set(target_name "venvlauncher") + + _add_executable_without_windows(${target_name} ${target_sources}) + target_include_directories(${target_name} PRIVATE ${target_include_dirs}) + target_link_libraries(${target_name} PRIVATE ${target_libraries}) + target_compile_definitions(${target_name} + PRIVATE + _CONSOLE + _UNICODE + VENV_REDIRECT + PY_ICON # For "PC/pylauncher.rc" + FIELD3=${PY_FIELD3_VALUE} + ) + list(APPEND launcher_targets ${target_name}) + + # venvwlauncher + set(target_name "venvwlauncher") + + add_executable(${target_name} WIN32 ${target_sources}) + target_include_directories(${target_name} PRIVATE ${target_include_dirs}) + target_link_libraries(${target_name} PRIVATE ${target_libraries}) + target_compile_definitions(${target_name} + PRIVATE + _UNICODE + _WINDOWS + VENV_REDIRECT + PYW_ICON # For "PC/pylauncher.rc" + FIELD3=${PY_FIELD3_VALUE} + ) + list(APPEND launcher_targets ${target_name}) +endif() + +set(build_pylauncher 0) +if(PY_VERSION VERSION_GREATER_EQUAL "3.11") + set(build_pylauncher 1) +endif() + +if(build_pylauncher) + set(target_sources + ${SRC_DIR}/PC/launcher2.c + ${SRC_DIR}/PC/pylauncher.rc + ) + set(target_include_dirs + ${SRC_DIR}/PC/ + ) + set(target_libraries + pathcch + shell32 + ) + + # pylauncher + set(target_name "pylauncher") + + _add_executable_without_windows(${target_name} ${target_sources}) + target_include_directories(${target_name} PRIVATE ${target_include_dirs}) + target_link_libraries(${target_name} PRIVATE ${target_libraries}) + target_compile_definitions(${target_name} + PRIVATE + _CONSOLE + _UNICODE + FIELD3=${PY_FIELD3_VALUE} + ) + list(APPEND launcher_targets ${target_name}) + + # pywlauncher + set(target_name "pywlauncher") + + add_executable(${target_name} WIN32 ${target_sources}) + target_include_directories(${target_name} PRIVATE ${target_include_dirs}) + target_link_libraries(${target_name} PRIVATE ${target_libraries}) + target_compile_definitions(${target_name} + PRIVATE + _UNICODE + _WINDOWS + FIELD3=${PY_FIELD3_VALUE} + ) + + list(APPEND launcher_targets ${target_name}) +endif() + +if(launcher_targets) + set_target_properties(${launcher_targets} + PROPERTIES + LINK_FLAGS "/MANIFEST:NO" + RUNTIME_OUTPUT_DIRECTORY ${LAUNCHER_INSTALL_DIR} + ) + install(TARGETS ${launcher_targets} RUNTIME DESTINATION ${BIN_INSTALL_DIR} COMPONENT Runtime) +endif() diff --git a/third/python-cmake/cmake/PlatformTest.cmake b/third/python-cmake/cmake/PlatformTest.cmake new file mode 100644 index 00000000..7c4b44fd --- /dev/null +++ b/third/python-cmake/cmake/PlatformTest.cmake @@ -0,0 +1,187 @@ +include(CMakeExpandImportedTargets) + +macro(python_platform_test var description srcfile invert) + if(NOT DEFINED "${var}_COMPILED") + message(STATUS "${description}") + + set(MACRO_CHECK_FUNCTION_DEFINITIONS + "-D${var} ${CMAKE_REQUIRED_FLAGS}") + if(CMAKE_REQUIRED_LIBRARIES) + # this one translates potentially used imported library targets to their files on disk + CMAKE_EXPAND_IMPORTED_TARGETS(_ADJUSTED_CMAKE_REQUIRED_LIBRARIES LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} CONFIGURATION "${CMAKE_TRY_COMPILE_CONFIGURATION}") + set(CHECK_C_SOURCE_COMPILES_ADD_LIBRARIES + "-DLINK_LIBRARIES:STRING=${_ADJUSTED_CMAKE_REQUIRED_LIBRARIES}") + else() + set(CHECK_C_SOURCE_COMPILES_ADD_LIBRARIES) + endif() + if(CMAKE_REQUIRED_INCLUDES) + set(CHECK_C_SOURCE_COMPILES_ADD_INCLUDES + "-DINCLUDE_DIRECTORIES:STRING=${CMAKE_REQUIRED_INCLUDES}") + else() + set(CHECK_C_SOURCE_COMPILES_ADD_INCLUDES) + endif() + + try_compile(${var}_COMPILED + ${CMAKE_CURRENT_BINARY_DIR} + ${srcfile} + COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} + CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_FUNCTION_DEFINITIONS} + "${CHECK_C_SOURCE_COMPILES_ADD_LIBRARIES}" + "${CHECK_C_SOURCE_COMPILES_ADD_INCLUDES}" + # OUTPUT_VARIABLE OUTPUT # Do NOT use to make cross-compiling easier + ) + if(${invert} MATCHES INVERT) + if(${var}_COMPILED) + message(STATUS "${description} - no") + else() + message(STATUS "${description} - yes") + endif() + else() + if(${var}_COMPILED) + message(STATUS "${description} - yes") + else() + message(STATUS "${description} - no") + endif() + endif() + endif() + if(${invert} MATCHES INVERT) + if(${var}_COMPILED) + SET(${var} 0) + else() + SET(${var} 1) + endif() + else() + if(${var}_COMPILED) + SET(${var} 1) + else() + SET(${var} 0) + endif() + endif() +endmacro() + +macro(python_platform_test_run var description srcfile invert) + if(NOT DEFINED "${var}") + message(STATUS "${description}") + + set(MACRO_CHECK_FUNCTION_DEFINITIONS + "-D${var} ${CMAKE_REQUIRED_FLAGS}") + if(CMAKE_REQUIRED_LIBRARIES) + # this one translates potentially used imported library targets to their files on disk + CMAKE_EXPAND_IMPORTED_TARGETS(_ADJUSTED_CMAKE_REQUIRED_LIBRARIES LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} CONFIGURATION "${CMAKE_TRY_COMPILE_CONFIGURATION}") + set(CHECK_C_SOURCE_COMPILES_ADD_LIBRARIES + "-DLINK_LIBRARIES:STRING=${_ADJUSTED_CMAKE_REQUIRED_LIBRARIES}") + else() + set(CHECK_C_SOURCE_COMPILES_ADD_LIBRARIES) + endif() + if(CMAKE_REQUIRED_INCLUDES) + set(CHECK_C_SOURCE_COMPILES_ADD_INCLUDES + "-DINCLUDE_DIRECTORIES:STRING=${CMAKE_REQUIRED_INCLUDES}") + else() + set(CHECK_C_SOURCE_COMPILES_ADD_INCLUDES) + endif() + + try_run(${var} ${var}_COMPILED + ${CMAKE_CURRENT_BINARY_DIR} + ${srcfile} + COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} + CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_FUNCTION_DEFINITIONS} + -DCMAKE_SKIP_RPATH:BOOL=${CMAKE_SKIP_RPATH} + "${CHECK_C_SOURCE_COMPILES_ADD_LIBRARIES}" + "${CHECK_C_SOURCE_COMPILES_ADD_INCLUDES}" + # OUTPUT_VARIABLE OUTPUT # Do NOT use to make cross-compiling easier + ) + # Note that ${var} will be a 0 return value on success. + if(NOT ${var}_COMPILED) + set(${var} -1 CACHE INTERNAL "${description} failed to compile.") + endif() + + if(${invert} MATCHES INVERT) + if(${var}_COMPILED) + if(${var}) + message(STATUS "${description} - yes") + else() + message(STATUS "${description} - no") + endif() + else() + message(STATUS "${description} - failed to compile") + endif() + else() + if(${var}_COMPILED) + if(${var}) + message(STATUS "${description} - no") + else() + message(STATUS "${description} - yes") + endif() + else() + message(STATUS "${description} - failed to compile") + endif() + endif() + endif() + + if(${invert} MATCHES INVERT) + if(${var}_COMPILED) + if(${var}) + SET(${var} 1) + else() + SET(${var} 0) + endif() + else() + SET(${var} 1) + endif() + else() + if(${var}_COMPILED) + if(${var}) + SET(${var} 0) + else() + SET(${var} 1) + endif() + else() + SET(${var} 0) + endif() + endif() +endmacro() + +macro(python_check_function name var) + set(check_src ${PROJECT_BINARY_DIR}/CMakeFiles/ac_fn_c_check_func_${name}.c) + file(WRITE ${check_src} " +/* Define ${name} to an innocuous variant, in case declares ${name}. + For example, HP-UX 11i declares gettimeofday. */ +#define ${name} innocuous_${name} + +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char ${name} (); below. + Prefer to if __STDC__ is defined, since + exists even on freestanding compilers. */ + +#ifdef __STDC__ +# include +#else +# include +#endif + +#undef ${name} + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern \"C\" +#endif +char ${name} (); +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined __stub_${name} || defined __stub___${name} +choke me +#endif + +int main () { return ${name} (); } +") + + python_platform_test( + ${var} + "Checking for ${name}" + ${check_src} + DIRECT + ) +endmacro() diff --git a/third/python-cmake/cmake/PythonApplyPatches.cmake b/third/python-cmake/cmake/PythonApplyPatches.cmake new file mode 100644 index 00000000..2a422a54 --- /dev/null +++ b/third/python-cmake/cmake/PythonApplyPatches.cmake @@ -0,0 +1,110 @@ + +set(CMAKE_MODULE_PATH + ${CMAKE_CURRENT_LIST_DIR} + ${CMAKE_MODULE_PATH} + ) + +if(NOT DEFINED PATCH_COMMAND) + find_package(Git) + if(Git_FOUND OR GIT_FOUND) + set(PATCH_COMMAND ${GIT_EXECUTABLE} apply --whitespace=fix) + # Initialize Git repo to ensure "git apply" works when source tree + # is located within an already versioned tree. + if(NOT EXISTS "${SRC_DIR}/.git") + execute_process( + COMMAND ${GIT_EXECUTABLE} init + WORKING_DIRECTORY ${SRC_DIR} + RESULT_VARIABLE result + ERROR_VARIABLE error + ERROR_STRIP_TRAILING_WHITESPACE + OUTPUT_QUIET + ) + if(NOT result EQUAL 0) + message(FATAL_ERROR "${output}\n${error}") + endif() + endif() + else() + find_package(Patch) + if(Patch_FOUND OR PATCH_FOUND) + # Since support for git diffs which copy or rename files was + # added in patch 2.7, we can not use older version. + if("${Patch_VERSION}" VERSION_GREATER_EQUAL "2.7.0") + set(PATCH_COMMAND ${Patch_EXECUTABLE} --quiet -p1 -i) + else() + set(_reason "Found Patch executable [${Patch_EXECUTABLE}] version [${Patch_VERSION}] older than 2.7.0 missing support for copy or rename files.") + endif() + endif() + endif() +endif() + +if(NOT DEFINED PATCH_COMMAND) + message(FATAL_ERROR "Could NOT find a suitable version of Git or Patch executable to apply patches. ${_reason}") +endif() + +set(patches_dir "${Python_SOURCE_DIR}/patches") + +function(_apply_patches _subdir) + if(NOT EXISTS ${patches_dir}/${_subdir}) + message(STATUS "Skipping patches: Directory '${patches_dir}/${_subdir}' does not exist") + return() + endif() + file(GLOB _patches RELATIVE ${patches_dir} "${patches_dir}/${_subdir}/*.patch") + if(NOT _patches) + return() + endif() + message(STATUS "") + list(SORT _patches) + foreach(patch IN LISTS _patches) + set(msg "Applying '${patch}'") + message(STATUS "${msg}") + set(applied ${SRC_DIR}/.patches/${patch}.applied) + # Handle case where source tree was patched using the legacy approach. + set(legacy_applied ${PROJECT_BINARY_DIR}/CMakeFiles/patches/${patch}.applied) + if(EXISTS ${legacy_applied}) + set(applied ${legacy_applied}) + endif() + if(EXISTS ${applied}) + message(STATUS "${msg} - skipping (already applied)") + continue() + endif() + execute_process( + COMMAND ${PATCH_COMMAND} ${patches_dir}/${patch} + WORKING_DIRECTORY ${SRC_DIR} + RESULT_VARIABLE result + ERROR_VARIABLE error + ERROR_STRIP_TRAILING_WHITESPACE + OUTPUT_VARIABLE output + OUTPUT_STRIP_TRAILING_WHITESPACE + ) + if(result EQUAL 0) + message(STATUS "${msg} - done") + #get_filename_component(_dir ${applied} DIRECTORY) + get_filename_component(_dir ${applied} PATH) + execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory ${_dir}) + execute_process(COMMAND ${CMAKE_COMMAND} -E touch ${applied}) + else() + message(STATUS "${msg} - failed") + message(FATAL_ERROR "${output}\n${error}") + endif() + endforeach() + message(STATUS "") +endfunction() + +set(_py_version ${PY_VERSION}) + +# Apply patches +_apply_patches("${PY_VERSION_MAJOR}.${PY_VERSION_MINOR}") +_apply_patches("${_py_version}") +_apply_patches("${_py_version}/${CMAKE_SYSTEM_NAME}") +_apply_patches("${_py_version}/${CMAKE_SYSTEM_NAME}-${CMAKE_C_COMPILER_ID}") +set(_version ${CMAKE_C_COMPILER_VERSION}) +if(MSVC) + set(_version ${MSVC_VERSION}) + if ("${MSVC_VERSION}" VERSION_LESS "2000" AND + ("${MSVC_VERSION}" VERSION_GREATER_EQUAL "1900")) + set(_version "1900") + else() + set(_version ${MSVC_VERSION}) + endif() +endif() +_apply_patches("${_py_version}/${CMAKE_SYSTEM_NAME}-${CMAKE_C_COMPILER_ID}/${_version}") diff --git a/third/python-cmake/cmake/PythonAutoDetectOSX.cmake b/third/python-cmake/cmake/PythonAutoDetectOSX.cmake new file mode 100644 index 00000000..0384f805 --- /dev/null +++ b/third/python-cmake/cmake/PythonAutoDetectOSX.cmake @@ -0,0 +1,66 @@ +if(APPLE) + if(NOT CMAKE_OSX_ARCHITECTURES) + set(CMAKE_OSX_ARCHITECTURES "x86_64" CACHE STRING "By default, build for 64-bit") + endif() + + if(NOT CMAKE_OSX_SDK) + execute_process( + COMMAND xcrun + --show-sdk-version + OUTPUT_VARIABLE + SDK_VERSION + RESULT_VARIABLE + res + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE) + # Transform into a two-component string (e.g "10.15.6" -> "10.15") + string(REGEX REPLACE "^([0-9]+\\.[0-9]+).*$" "\\1" SDK_VERSION "${SDK_VERSION}") + if(res) + # Probably running on an older version of XCode, instead try to list all available + # SDKs and extract the version of the first one. + execute_process( + COMMAND xcodebuild + -showsdks + OUTPUT_VARIABLE + xcodebuild_sdks + RESULT_VARIABLE + res + OUTPUT_STRIP_TRAILING_WHITESPACE) + string(REGEX MATCH "sdk macosx([0-9\\. ]+)" output "${xcodebuild_sdks}") + if(res OR output STREQUAL "") + message(FATAL_ERROR "Failed to detect CMAKE_OSX_SDK; please set manually (e.g. \"macosx10.6\")") + endif() + set(SDK_VERSION ${CMAKE_MATCH_1}) + endif() + set(CMAKE_OSX_SDK macosx${SDK_VERSION}) + endif() + + if(NOT CMAKE_OSX_SYSROOT) + execute_process( + COMMAND xcodebuild + -sdk ${CMAKE_OSX_SDK} + -version Path + OUTPUT_VARIABLE + CMAKE_OSX_SYSROOT + RESULT_VARIABLE + res + OUTPUT_STRIP_TRAILING_WHITESPACE) + if(res) + message(FATAL_ERROR "Cannot determine SDK path for SDK: ${CMAKE_OSX_SDK}") + endif() + endif() + if(NOT CMAKE_OSX_DEPLOYMENT_TARGET) + execute_process( + COMMAND xcodebuild + -sdk ${CMAKE_OSX_SDK} + -version SDKVersion + OUTPUT_VARIABLE + CMAKE_OSX_DEPLOYMENT_TARGET + RESULT_VARIABLE + res + OUTPUT_STRIP_TRAILING_WHITESPACE) + if(res) + message(FATAL_ERROR "Cannot determine SDK version for SDK: ${CMAKE_OSX_SDK}") + endif() + endif() +endif() diff --git a/third/python-cmake/cmake/PythonConfig.cmake.in b/third/python-cmake/cmake/PythonConfig.cmake.in new file mode 100644 index 00000000..ee67e96b --- /dev/null +++ b/third/python-cmake/cmake/PythonConfig.cmake.in @@ -0,0 +1,51 @@ +# PYTHON_USE_STATIC_LIB - Set to ON to force the use of the static +# library. Default is OFF. + +@PACKAGE_INIT@ + +set(BUILD_LIBPYTHON_SHARED @BUILD_LIBPYTHON_SHARED@) +if(BUILD_LIBPYTHON_SHARED) + set(PYTHON_BUILD_SHARED 1) + set(PYTHON_BUILD_STATIC 0) +else() + set(PYTHON_BUILD_SHARED 0) + set(PYTHON_BUILD_STATIC 1) +endif() + +set_and_check(PYTHON_CONFIG_DIR "@PACKAGE_CONFIG_DIR_CONFIG@") +set_and_check(PYTHON_INCLUDE_DIR "@PACKAGE_INCLUDE_DIR_CONFIG@") +set_and_check(PYTHON_TARGETS "@PACKAGE_CONFIG_DIR_CONFIG@/PythonTargets.cmake") + +@PYTHON_CONFIG_CODE@ + +if(NOT PYTHON_TARGETS_IMPORTED) + set(PYTHON_TARGETS_IMPORTED 1) + include(${PYTHON_TARGETS}) +endif() + +if(TARGET libpython-shared) + set(PYTHON_LIBRARY_SHARED libpython-shared) +endif() +if(TARGET libpython-static) + set(PYTHON_LIBRARY_STATIC libpython-static) +endif() + +if(NOT Python_USE_STATIC_LIB) + if(PYTHON_LIBRARY_SHARED) + set(PYTHON_LIBRARIES ${PYTHON_LIBRARY_SHARED}) + elseif(PYTHON_LIBRARY_STATIC) + set(PYTHON_LIBRARIES ${PYTHON_LIBRARY_STATIC}) + endif() +else() + if(PYTHON_LIBRARY_STATIC) + set(PYTHON_LIBRARIES ${PYTHON_LIBRARY_STATIC}) + else() + set(PYTHON_LIBRARIES ${PYTHON_LIBRARY_SHARED}) + endif() +endif() + +if(NOT Python_FIND_QUIETLY) + message(STATUS "PYTHON_LIBRARIES set to ${PYTHON_LIBRARIES}") +endif() + +set(PYTHON_INCLUDE_DIRS ${PYTHON_INCLUDE_DIR}) diff --git a/third/python-cmake/cmake/PythonExtractVersionInfo.cmake b/third/python-cmake/cmake/PythonExtractVersionInfo.cmake new file mode 100644 index 00000000..85948d4e --- /dev/null +++ b/third/python-cmake/cmake/PythonExtractVersionInfo.cmake @@ -0,0 +1,269 @@ + +# Given a version string of the form "X.Y.Z[rcN|[a-z]N]", extract +# major, minor, patch version as well as release level (rc, any letter) +# and serial (an integer) +# +# The function will systematically set the following variable in the caller +# scope: +# +# PY_VERSION_MAJOR - X +# PY_VERSION_MINOR - Y +# PY_VERSION_PATCH - Z +# PY_RELEASE_LEVEL - rc, a, b, c, ..., z or an empty string +# PY_RELEASE_SERIAL - an integer or an empty string +# PY_VERSION - X.Y.Z +# +function(python_extract_version_info) + set(options) + set(oneValueArgs + VERSION_STRING + ) + set(multiValueArgs) + cmake_parse_arguments(MY + "${options}" + "${oneValueArgs}" + "${multiValueArgs}" + ${ARGN} + ) + + # Sanity checks + # XXX TBD + + set(version_str ${MY_VERSION_STRING}) + + # version_str : 2.7.14 | 2.7.14rc1 | 3.6.0a4 | 3.7.0b1 + # version_major : 2 | 2 | 3 | 3 + # version_minor : 7 | 7 | 6 | 7 + # version_patch : 14 | 14 | 0 | 0 + # release_level_and_serial: | rc1 | a4 | b1 + # release_level : | rc | a | b + # release_serial : | 1 | 4 | 1 + # version : 2.7.14 | 2.7.14 | 3.6.0 | 3.7.0 + + # Code adpated from FindPythonLibs.cmake + string(REGEX REPLACE "([0-9]+)\\..+" "\\1" version_major ${version_str}) + string(REGEX REPLACE "[0-9]+\\.([0-9]+)\\..+" "\\1" version_minor ${version_str}) + string(REGEX REPLACE "[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" version_patch ${version_str}) + string(REGEX REPLACE "[0-9]+\\.[0-9]+\\.[0-9]+(.*)" "\\1" release_level_and_serial ${version_str}) + string(REGEX REPLACE "([a-z]+)[0-9]+" "\\1" release_level "${release_level_and_serial}") + string(REGEX REPLACE "[a-z]+([0-9]+)" "\\1" release_serial "${release_level_and_serial}") + + set(version "${version_major}.${version_minor}.${version_patch}") + + set(PY_VERSION_MAJOR ${version_major} PARENT_SCOPE) + set(PY_VERSION_MINOR ${version_minor} PARENT_SCOPE) + set(PY_VERSION_PATCH ${version_patch} PARENT_SCOPE) + set(PY_RELEASE_LEVEL ${release_level} PARENT_SCOPE) + set(PY_RELEASE_SERIAL ${release_serial} PARENT_SCOPE) + set(PY_VERSION ${version} PARENT_SCOPE) +endfunction() + +# +# cmake -DTEST_python_extract_version_info:BOOL=ON -P PythonExtractVersionInfo.cmake +# +function(python_extract_version_info_test) + + function(display_output_values) + foreach(varname + VERSION_MAJOR + VERSION_MINOR + VERSION_PATCH + RELEASE_LEVEL + RELEASE_SERIAL + VERSION + ) + message("PY_${varname}: ${PY_${varname}}") + endforeach() + endfunction() + + set(id 1) + set(case${id}_input_version_long "2.7.14") + set(case${id}_expected_PY_VERSION_MAJOR "2") + set(case${id}_expected_PY_VERSION_MINOR "7") + set(case${id}_expected_PY_VERSION_PATCH "14") + set(case${id}_expected_PY_RELEASE_LEVEL "") + set(case${id}_expected_PY_RELEASE_SERIAL "") + set(case${id}_expected_PY_VERSION "2.7.14") + + set(id 2) + set(case${id}_input_version_long "2.7.14rc1") + set(case${id}_expected_PY_VERSION_MAJOR "2") + set(case${id}_expected_PY_VERSION_MINOR "7") + set(case${id}_expected_PY_VERSION_PATCH "14") + set(case${id}_expected_PY_RELEASE_LEVEL "rc") + set(case${id}_expected_PY_RELEASE_SERIAL "1") + set(case${id}_expected_PY_VERSION "2.7.14") + + set(id 3) + set(case${id}_input_version_long "3.6.0a4") + set(case${id}_expected_PY_VERSION_MAJOR "3") + set(case${id}_expected_PY_VERSION_MINOR "6") + set(case${id}_expected_PY_VERSION_PATCH "0") + set(case${id}_expected_PY_RELEASE_LEVEL "a") + set(case${id}_expected_PY_RELEASE_SERIAL "4") + set(case${id}_expected_PY_VERSION "3.6.0") + + set(id 4) + set(case${id}_input_version_long "10.744.42b66") + set(case${id}_expected_PY_VERSION_MAJOR "10") + set(case${id}_expected_PY_VERSION_MINOR "744") + set(case${id}_expected_PY_VERSION_PATCH "42") + set(case${id}_expected_PY_RELEASE_LEVEL "b") + set(case${id}_expected_PY_RELEASE_SERIAL "66") + set(case${id}_expected_PY_VERSION "10.744.42") + + foreach(caseid RANGE 1 ${id}) + set(input "${case${caseid}_input_version_long}") + python_extract_version_info(VERSION_STRING "${input}") + foreach(varname + VERSION_MAJOR + VERSION_MINOR + VERSION_PATCH + RELEASE_LEVEL + RELEASE_SERIAL + VERSION + ) + set(expected_varname "case${caseid}_expected_PY_${varname}") + set(current_varname "PY_${varname}") + if(NOT "${${expected_varname}}" STREQUAL "${${current_varname}}") + message("input: ${input}") + display_output_values() + message(FATAL_ERROR "error: case ${caseid}: \n expected: ${expected_varname} [${${expected_varname}}]\n current: ${current_varname} [${${current_varname}}]") + endif() + endforeach() + endforeach() + + message("SUCCESS") +endfunction() + +if(TEST_python_extract_version_info) + python_extract_version_info_test() +endif() + +# Compute the "Field3" value from a Python version's patch, release level, and serial. +# +# The Field3 value is defined as: +# Field3 = patch * 1000 + release_level_number * 10 + release_serial +# +# Where release_level_number is: +# - 10 for alpha (a) +# - 11 for beta (b) +# - 12 for release candidate (rc) +# - 15 for final (no pre-release tag) +# +# Arguments: +# VERSION_PATCH - Patch version (Z in X.Y.Z) +# RELEASE_LEVEL - One of 'a', 'b', 'rc', or empty +# RELEASE_SERIAL - An integer (or empty for final) +# +# Output: +# Sets variable PY_FIELD3_VALUE in the caller's scope. +function(python_compute_release_field3_value) + set(options) + set(oneValueArgs + VERSION_PATCH + RELEASE_LEVEL + RELEASE_SERIAL + ) + set(multiValueArgs) + cmake_parse_arguments(MY + "${options}" + "${oneValueArgs}" + "${multiValueArgs}" + ${ARGN} + ) + + # Default ReleaseLevelNumber = 15 (final release) + set(_level_number 15) + + # Map release level string to numeric code + if(MY_RELEASE_LEVEL STREQUAL "a") + set(_level_number 10) + elseif(MY_RELEASE_LEVEL STREQUAL "b") + set(_level_number 11) + elseif(MY_RELEASE_LEVEL STREQUAL "rc") + set(_level_number 12) + endif() + + # Fallback for empty serial + if("${MY_RELEASE_SERIAL}" STREQUAL "") + set(MY_RELEASE_SERIAL 0) + endif() + + # Convert to integers + set(_patch "${MY_VERSION_PATCH}") + set(_serial "${MY_RELEASE_SERIAL}") + math(EXPR _field3 "${_patch} * 1000 + ${_level_number} * 10 + ${_serial}") + + # Return in the variable specified by caller + set(PY_FIELD3_VALUE "${_field3}" PARENT_SCOPE) +endfunction() + +# +# cmake -DTEST_python_compute_release_field3_value:BOOL=ON -P PythonExtractVersionInfo.cmake +# +function(python_compute_release_field3_value_test) + + function(display_field3_test_values) + message(" PATCH: ${patch}") + message(" LEVEL: ${level}") + message(" SERIAL: ${serial}") + message(" Expected: ${expected}") + message(" Computed: ${PY_FIELD3_VALUE}") + endfunction() + + set(id 1) + set(case${id}_patch 2) + set(case${id}_level "") # final release + set(case${id}_serial "") # default to 0 + set(case${id}_expected 2150) # 2*1000 + 15*10 + 0 + + set(id 2) + set(case${id}_patch 2) + set(case${id}_level a) + set(case${id}_serial 1) + set(case${id}_expected 2101) # 2*1000 + 10*10 + 1 + + set(id 3) + set(case${id}_patch 5) + set(case${id}_level b) + set(case${id}_serial 0) + set(case${id}_expected 5110) # 5*1000 + 11*10 + 0 + + set(id 4) + set(case${id}_patch 14) + set(case${id}_level rc) + set(case${id}_serial 3) + set(case${id}_expected 14123) # 14*1000 + 12*10 + 3 + + set(id 5) + set(case${id}_patch 0) + set(case${id}_level "") # final + set(case${id}_serial "") # default 0 + set(case${id}_expected 150) # 0 * 1000 + 15 * 10 + 0 + + foreach(caseid RANGE 1 ${id}) + set(patch "${case${caseid}_patch}") + set(level "${case${caseid}_level}") + set(serial "${case${caseid}_serial}") + set(expected "${case${caseid}_expected}") + + python_compute_release_field3_value( + VERSION_PATCH "${patch}" + RELEASE_LEVEL "${level}" + RELEASE_SERIAL "${serial}" + ) + + if(NOT "${PY_FIELD3_VALUE}" STREQUAL "${expected}") + message("FAILED: case ${caseid}") + display_field3_test_values() + message(FATAL_ERROR "Test failed at case ${caseid}") + endif() + endforeach() + + message("SUCCESS") +endfunction() + +if(TEST_python_compute_release_field3_value) + python_compute_release_field3_value_test() +endif() diff --git a/third/python-cmake/cmake/UnitTests.cmake b/third/python-cmake/cmake/UnitTests.cmake new file mode 100644 index 00000000..dcf8f00d --- /dev/null +++ b/third/python-cmake/cmake/UnitTests.cmake @@ -0,0 +1,53 @@ +file(GLOB filenames "${PROJECT_BINARY_DIR}/${PYTHONHOME}/test/test_*.py") +list(SORT filenames) + +set(unittests) +set(skipped_unittests) + +# Since some tests call "support.requires(...)" spliting its arguments +# over multiple lines and the current parsing does not support the arguments +# extraction, the associated resource name is hard-coded below. +set(test_zipfile64_resource "extralargefile") + +foreach(filename IN LISTS filenames) + get_filename_component(unittest ${filename} NAME_WE) + + set(skip_unittest 0) + + # Match only unindented support.requires(...) calls + file(STRINGS "${filename}" matches REGEX "^(support\\.requires|requires)\\([^\\)]*\\)") + + if(matches) # There are support.requires() calls + foreach(match IN LISTS matches) + # Extract the FIRST quoted argument only + string(REGEX MATCH "['\"]([^'\"]*)['\"]" args "${match}") + set(expected_resource ${CMAKE_MATCH_1}) + + # if not in SUPPORTED_TEST_RESOURCES, skip + if(NOT "${expected_resource}" IN_LIST SUPPORTED_TEST_RESOURCES) + set(skip_unittest 1) + break() + endif() + endforeach() + endif() + + # Handle hardcoded resource override (e.g., due to unsupported multi-line call) + if(DEFINED "${unittest}_resource") + set(expected_resource "${${unittest}_resource}") + if(NOT "${expected_resource}" IN_LIST SUPPORTED_TEST_RESOURCES) + set(skip_unittest 1) + endif() + endif() + + if(skip_unittest) + list(APPEND skipped_unittests ${unittest}) + message(STATUS " Ignoring '${unittest}' requiring '${expected_resource}' resource") + continue() + endif() + + list(APPEND unittests ${unittest}) +endforeach() + +list(LENGTH skipped_unittests skippedcount) +list(LENGTH filenames testcount) +message(STATUS "Discovered ${testcount} tests (skipping ${skippedcount})") diff --git a/third/python-cmake/cmake/UpdateSysconfig.cmake b/third/python-cmake/cmake/UpdateSysconfig.cmake new file mode 100644 index 00000000..2d8ba015 --- /dev/null +++ b/third/python-cmake/cmake/UpdateSysconfig.cmake @@ -0,0 +1,44 @@ + +# +# Required by Python >= 2.7.5 +# +# This cmake script allows to adapt the output of sysconfig._generate_posix_vars() +# function to play nice with CMake build system. +# +# 1. Backup original pybuilddir.txt to pybuilddir.txt.backup +# 2. Read the value PYBUILDDIR written in pybuilddir.txt +# 3. Copy the file / to +# 4. Create a new pybuilddir.txt file with +# + +# Sanity checks +foreach(var BIN_BUILD_DIR PYTHON_BINARY_DIR EXTENSION_INSTALL_DIR SYSCONFIGDATA_PY) + if(NOT DEFINED ${var}) + message(FATAL_ERROR "CMake parameter -D${var} is missing !") + endif() +endforeach() + +set(_pybuilddir ${BIN_BUILD_DIR}/pybuilddir.txt) +if(NOT EXISTS ${_pybuilddir}) + message(FATAL_ERROR "File ${_pybuilddir} does NOT exist") +endif() + +# Backup file +if(NOT EXISTS ${_pybuilddir}.backup) + execute_process( + COMMAND ${CMAKE_COMMAND} -E copy + ${_pybuilddir} ${_pybuilddir}.backup + ) +endif() + +# Read PYBUILDDIR value +file(READ ${_pybuilddir}.backup PYBUILDDIR) + +# Copy SYSCONFIGDATA_PY +execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different + ${BIN_BUILD_DIR}/${PYBUILDDIR}/${SYSCONFIGDATA_PY} + ${PYTHON_BINARY_DIR}/${EXTENSION_INSTALL_DIR}/${SYSCONFIGDATA_PY} + ) + +# Create new file +file(WRITE "${_pybuilddir}" "${EXTENSION_INSTALL_DIR}") diff --git a/third/python-cmake/cmake/config-mingw/errmap.h b/third/python-cmake/cmake/config-mingw/errmap.h new file mode 100644 index 00000000..6b6459f6 --- /dev/null +++ b/third/python-cmake/cmake/config-mingw/errmap.h @@ -0,0 +1 @@ +#include "../PC/errmap.h" diff --git a/third/python-cmake/cmake/config-mingw/pyconfig.h b/third/python-cmake/cmake/config-mingw/pyconfig.h new file mode 100644 index 00000000..5ed9e1e3 --- /dev/null +++ b/third/python-cmake/cmake/config-mingw/pyconfig.h @@ -0,0 +1,576 @@ +#ifndef Py_CONFIG_H +#define Py_CONFIG_H + +/* pyconfig.h. NOT Generated automatically by configure. + +This is a manually maintained version (initially based +on "PC/pyconfig.h") used for (i686|x86_64)-w64-mingw32 +toolchains (provided by MXE). + +WINDOWS DEFINES: +The code specific to Windows should be wrapped around one of +the following #defines + +MS_WIN64 - Code specific to the MS Win64 API +MS_WIN32 - Code specific to the MS Win32 (and Win64) API (obsolete, this covers all supported APIs) +MS_WINDOWS - Code specific to Windows, but all versions. +Py_ENABLE_SHARED - Code if the Python core is built as a DLL. + +NOTE: The following symbols are deprecated: +NT, USE_DL_EXPORT, USE_DL_IMPORT, DL_EXPORT, DL_IMPORT +MS_CORE_DLL. + +WIN32 is still required for the locale module. + +*/ + +/* Deprecated USE_DL_EXPORT macro - please use Py_BUILD_CORE */ +#ifdef USE_DL_EXPORT +# define Py_BUILD_CORE +#endif /* USE_DL_EXPORT */ + +/* Define if you have the `hypot' function. [Python <= 3.10] */ +#define HAVE_HYPOT + +#define HAVE_STRFTIME +#define DONT_HAVE_SIG_ALARM +#define DONT_HAVE_SIG_PAUSE +#define LONG_BIT 32 +#define WORD_BIT 32 +#define PREFIX "" +#define EXEC_PREFIX "" + +#define MS_WIN32 /* only support win32 and greater. */ +#define MS_WINDOWS +#ifndef PYTHONPATH +# define PYTHONPATH ".\\DLLs;.\\lib;.\\lib\\plat-win;.\\lib\\lib-tk" +#endif +#define NT_THREADS +#define WITH_THREAD +#ifndef NETSCAPE_PI +#define USE_SOCKET +#endif + +/* ------------------------------------------------------------------------*/ +/* (i686|x86_64)-w64-mingw32 toolchains defines __MINGW32__ */ +#ifndef __MINGW32__ +# error "This file is should be used with MingW compiler" +#endif + +#define _Py_PASTE_VERSION(SUFFIX) \ + ("\n[GCC v" __VERSION__ " " SUFFIX "]") + +#ifndef COMPILER +# ifdef __MINGW64__ +# define COMPILER _Py_PASTE_VERSION("64 bit (AMD64)") +# else +# define COMPILER _Py_PASTE_VERSION("32 bit (i686)") +# endif +#endif /* !COMPILER */ + +/* MinGW defines __MINGWxx__ to differentiate the windows platform types + + Note that for compatibility reasons __MINGW32__ is defined on Win32 + *and* on Win64. For the same reasons, in Python, MS_WIN32 is + defined on Win32 *and* Win64. Win32 only code must therefore be + guarded as follows: + #if defined(MS_WIN32) && !defined(MS_WIN64) +*/ + +#if !defined(MS_WIN64) && defined(__MINGW64__) +# define MS_WIN64 +#endif + +#ifdef MS_WIN64 +# define MS_WINX64 +#endif + +/* set the version macros for the windows headers */ +#ifdef MS_WINX64 +/* 64 bit only runs on XP or greater */ +# define Py_WINVER _WIN32_WINNT_WINXP +# define Py_NTDDI NTDDI_WINXP +#else +/* Python 2.6+ requires Windows 2000 or greater */ +# ifdef _WIN32_WINNT_WIN2K +# define Py_WINVER _WIN32_WINNT_WIN2K +# else +# define Py_WINVER 0x0500 +# endif +# define Py_NTDDI NTDDI_WIN2KSP4 +#endif + +/* We only set these values when building Python - we don't want to force + these values on extensions, as that will affect the prototypes and + structures exposed in the Windows headers. Even when building Python, we + allow a single source file to override this - they may need access to + structures etc so it can optionally use new Windows features if it + determines at runtime they are available. +*/ +#if defined(Py_BUILD_CORE) || defined(Py_BUILD_CORE_MODULE) +# ifndef NTDDI_VERSION +# define NTDDI_VERSION Py_NTDDI +# endif +# ifndef WINVER +# define WINVER Py_WINVER +# endif +# ifndef _WIN32_WINNT +# define _WIN32_WINNT Py_WINVER +# endif +#endif /* defined(Py_BUILD_CORE) || defined(Py_BUILD_CORE_MODULE) */ + +/* Define like size_t, omitting the "unsigned" */ +#define HAVE_SSIZE_T 1 + +#include +#define Py_IS_NAN _isnan +#define Py_IS_INFINITY(X) (!_finite(X) && !_isnan(X)) +#define Py_IS_FINITE(X) _finite(X) +#define copysign _copysign + +#include + +/* ------------------------------------------------------------------------*/ +/* End of compilers - finish up */ + +#define HAVE_IO_H +#define HAVE_SYS_UTIME_H +#define HAVE_TEMPNAM +#define HAVE_TMPFILE +#define HAVE_TMPNAM +#define HAVE_CLOCK +#define HAVE_STRERROR + +#include +#include + +/* 64 bit ints are usually spelt __int64 unless compiler has overridden */ +/* Define this if you have the type long long. [Python <= 3.5] */ +#define HAVE_LONG_LONG 1 +#ifndef PY_LONG_LONG +# define PY_LONG_LONG __int64 +# define PY_LLONG_MAX _I64_MAX +# define PY_LLONG_MIN _I64_MIN +# define PY_ULLONG_MAX _UI64_MAX +#endif + +/* For Windows the Python core is in a DLL by default. Test +Py_NO_ENABLE_SHARED to find out. Also support MS_NO_COREDLL for b/w compat */ +#if !defined(MS_NO_COREDLL) && !defined(Py_NO_ENABLE_SHARED) +# define Py_ENABLE_SHARED 1 /* standard symbol for shared library */ +# define MS_COREDLL /* deprecated old symbol */ +#endif /* !MS_NO_COREDLL && ... */ + +/* All windows compilers that use this header support __declspec */ +#define HAVE_DECLSPEC_DLL + +/* For an MSVC DLL, we can nominate the .lib files used by extensions */ +#ifdef MS_COREDLL +# ifndef Py_BUILD_CORE /* not building the core - must be an ext */ +# if defined(_MSC_VER) + /* So MSVC users need not specify the .lib file in + their Makefile (other compilers are generally + taken care of by distutils.) */ +# ifdef _DEBUG +# pragma comment(lib,"python27_d.lib") +# else +# pragma comment(lib,"python27.lib") +# endif /* _DEBUG */ +# endif /* _MSC_VER */ +# endif /* Py_BUILD_CORE */ +#endif /* MS_COREDLL */ + +#if defined(MS_WIN64) +/* maintain "win32" sys.platform for backward compatibility of Python code, + the Win64 API should be close enough to the Win32 API to make this + preferable */ +# define SIZEOF_VOID_P 8 +# define SIZEOF_TIME_T 8 +# define SIZEOF_OFF_T 4 +# define SIZEOF_FPOS_T 8 +# define SIZEOF_HKEY 8 +# define SIZEOF_SIZE_T 8 +# define ALIGNOF_SIZE_T 8 +/* configure.ac defines HAVE_LARGEFILE_SUPPORT iff HAVE_LONG_LONG, + sizeof(off_t) > sizeof(long), and sizeof(PY_LONG_LONG) >= sizeof(off_t). + On Win64 the second condition is not true, but if fpos_t replaces off_t + then this is true. The uses of HAVE_LARGEFILE_SUPPORT imply that Win64 + should define this. */ +# define HAVE_LARGEFILE_SUPPORT +#elif defined(MS_WIN32) +# define HAVE_LARGEFILE_SUPPORT +# define SIZEOF_VOID_P 4 +# define SIZEOF_OFF_T 4 +# define SIZEOF_FPOS_T 8 +# define SIZEOF_HKEY 4 +# define SIZEOF_SIZE_T 4 +# define ALIGNOF_SIZE_T 4 +# define SIZEOF_TIME_T 8 +#endif + +#ifdef _DEBUG +# define Py_DEBUG +#endif + + +#ifdef MS_WIN32 + +#define SIZEOF_SHORT 2 +#define SIZEOF_INT 4 +#define SIZEOF_LONG 4 +#define ALIGNOF_LONG 4 +#define SIZEOF_LONG_LONG 8 +#define SIZEOF_DOUBLE 8 +#define SIZEOF_FLOAT 4 + +/* Define to 1 if the system has the type `uintptr_t'. [Python <= 3.5] */ +#define HAVE_UINTPTR_T 1 + +#define HAVE_INTPTR_T 1 + +#endif /* MS_WIN32 */ + +/* define signed and unsigned exact-width 32-bit and 64-bit types, used in the + implementation of Python long integers. */ +#ifndef PY_UINT32_T +#if SIZEOF_INT == 4 +/* Define if your compiler provides uint32_t. [Python <= 3.5] */ +#define HAVE_UINT32_T 1 +#define PY_UINT32_T unsigned int +#elif SIZEOF_LONG == 4 +/* Define if your compiler provides uint32_t. [Python <= 3.5] */ +#define HAVE_UINT32_T 1 +#define PY_UINT32_T unsigned long +#endif +#endif + +#ifndef PY_UINT64_T +#if SIZEOF_LONG_LONG == 8 +/* Define if your compiler provides uint64_t. [Python <= 3.5] */ +#define HAVE_UINT64_T 1 +#define PY_UINT64_T unsigned PY_LONG_LONG +#endif +#endif + +#ifndef PY_INT32_T +#if SIZEOF_INT == 4 +/* Define if your compiler provides int32_t. [Python <= 3.5] */ +#define HAVE_INT32_T 1 +#define PY_INT32_T int +#elif SIZEOF_LONG == 4 +/* Define if your compiler provides int32_t. [Python <= 3.5] */ +#define HAVE_INT32_T 1 +#define PY_INT32_T long +#endif +#endif + +#ifndef PY_INT64_T +#if SIZEOF_LONG_LONG == 8 +#define HAVE_INT64_T 1 +#define PY_INT64_T PY_LONG_LONG +#endif +#endif + +/* Fairly standard from here! */ + +/* Define to 1 if you have the `copysign' function. [Python <= 3.10] */ +#define HAVE_COPYSIGN 1 + +/* Define to 1 if you have the `round' function. [Python <= 3.10] */ +#define HAVE_ROUND 1 + +/* Define to 1 if you have the `isinf' macro. [Python <= 3.10] */ +#define HAVE_DECL_ISINF 1 + +/* Define to 1 if you have the `isnan' function. [Python <= 3.10] */ +#define HAVE_DECL_ISNAN 1 + +/* Define if on AIX 3. + System headers sometimes define this. + We just want to avoid a redefinition error message. */ +#ifndef _ALL_SOURCE +/* #undef _ALL_SOURCE */ +#endif + +/* Define to empty if the keyword does not work. */ +/* #define const */ + +/* Define to 1 if you have the header file. */ +#define HAVE_CONIO_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_DIRECT_H 1 + +/* Define if you have dirent.h. */ +#define HAVE_DIRENT_H 1 + +/* Define to the type of elements in the array set by `getgroups'. + Usually this is either `int' or `gid_t'. */ +/* #undef GETGROUPS_T */ + +/* Define to `int' if doesn't define. */ +/* #undef gid_t */ + +/* Define if your struct tm has tm_zone. */ +/* #undef HAVE_TM_ZONE */ + +/* Define if you don't have tm_zone but do have the external array + tzname. */ +#define HAVE_TZNAME + +/* Define to `int' if doesn't define. */ +/* #undef mode_t */ + +/* Define if you don't have dirent.h, but have ndir.h. */ +/* #undef NDIR */ + +/* Define to `long' if doesn't define. */ +/* #undef off_t */ + +/* Define to `int' if doesn't define. */ +/* #undef pid_t */ + +/* Define if the system does not provide POSIX.1 features except + with this defined. */ +/* #undef _POSIX_1_SOURCE */ + +/* Define if you need to in order for stat and other things to work. */ +/* #undef _POSIX_SOURCE */ + +/* Define as the return type of signal handlers (int or void). */ +#define RETSIGTYPE void + +/* Define to `unsigned' if doesn't define. */ +/* #undef size_t */ + +/* Define if you have the ANSI C header files. */ +#define STDC_HEADERS 1 + +/* Define if you don't have dirent.h, but have sys/dir.h. */ +/* #undef SYSDIR */ + +/* Define if you don't have dirent.h, but have sys/ndir.h. */ +/* #undef SYSNDIR */ + +/* Define if you can safely include both and . [Python <= 3.11] */ +/* #undef TIME_WITH_SYS_TIME */ + +/* Define if your declares struct tm. */ +/* #define TM_IN_SYS_TIME 1 */ + +/* Define to `int' if doesn't define. */ +/* #undef uid_t */ + +/* Define if the closedir function returns void instead of int. */ +/* #undef VOID_CLOSEDIR */ + +/* Define if getpgrp() must be called as getpgrp(0) + and (consequently) setpgrp() as setpgrp(0, 0). */ +/* #undef GETPGRP_HAVE_ARGS */ + +/* Define this if your time.h defines altzone */ +/* #define HAVE_ALTZONE */ + +/* Define if you have the putenv function. [Python <= 3.8] */ +#define HAVE_PUTENV + +/* Define if your compiler supports function prototypes */ +#define HAVE_PROTOTYPES + +/* Define if you can safely include both and + (which you can't on SCO ODT 3.0). */ +/* #undef SYS_SELECT_WITH_SYS_TIME */ + +/* Define if you want documentation strings in extension modules */ +#define WITH_DOC_STRINGS 1 + +/* Define if you want to compile in rudimentary thread support */ +/* #undef WITH_THREAD */ + +/* Define if you want to use the GNU readline library */ +/* #define WITH_READLINE 1 */ + +/* Define as the size of the unicode type. [Python 2.7 to 3.2] */ +/* This is enough for unicodeobject.h to do the "right thing" on Windows. */ +#define Py_UNICODE_SIZE 2 + +/* Use Python's own small-block memory-allocator. */ +#define WITH_PYMALLOC 1 + +/* Define if you want to compile in object freelists optimization [Python 3.11] */ +#define WITH_FREELISTS 1 + +/* Define if you have clock. */ +/* #define HAVE_CLOCK */ + +/* Define when any dynamic module loading is enabled */ +#define HAVE_DYNAMIC_LOADING + +/* Define if you have ftime. */ +#define HAVE_FTIME + +/* Define if you have getpeername. */ +#define HAVE_GETPEERNAME + +/* Define if you have getpgrp. */ +/* #undef HAVE_GETPGRP */ + +/* Define if you have getpid. */ +#define HAVE_GETPID + +/* Define if you have gettimeofday. [Python <= 3.8] */ +/* #undef HAVE_GETTIMEOFDAY */ + +/* Define if you have getwd. */ +/* #undef HAVE_GETWD */ + +/* Define if you have lstat. */ +/* #undef HAVE_LSTAT */ + +/* Define if you have the mktime function. */ +#define HAVE_MKTIME + +/* Define if you have nice. */ +/* #undef HAVE_NICE */ + +/* Define if you have readlink. */ +/* #undef HAVE_READLINK */ + +/* Define if you have select. [Python <= 3.6] */ +/* #undef HAVE_SELECT */ + +/* Define if you have setpgid. */ +/* #undef HAVE_SETPGID */ + +/* Define if you have setpgrp. */ +/* #undef HAVE_SETPGRP */ + +/* Define if you have setsid. */ +/* #undef HAVE_SETSID */ + +/* Define if you have setvbuf. */ +#define HAVE_SETVBUF + +/* Define if you have siginterrupt. */ +/* #undef HAVE_SIGINTERRUPT */ + +/* Define if you have symlink. */ +/* #undef HAVE_SYMLINK */ + +/* Define if you have tcgetpgrp. */ +/* #undef HAVE_TCGETPGRP */ + +/* Define if you have tcsetpgrp. */ +/* #undef HAVE_TCSETPGRP */ + +/* Define if you have times. */ +/* #undef HAVE_TIMES */ + +/* Define if you have uname. */ +/* #undef HAVE_UNAME */ + +/* Define if you have waitpid. */ +/* #undef HAVE_WAITPID */ + +/* Define to 1 if you have the `wcscoll' function. */ +#define HAVE_WCSCOLL 1 + +/* Define if the zlib library has inflateCopy */ +#define HAVE_ZLIB_COPY 1 + +/* Define if you have the header file. */ +/* #undef HAVE_DLFCN_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_ERRNO_H 1 + +/* Define if you have the header file. */ +#define HAVE_FCNTL_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_PROCESS_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SIGNAL_H 1 + +/* Define if you have the prototypes. [Python <= 3.11] */ +#define HAVE_STDARG_PROTOTYPES + +/* Define if you have the header file. */ +#define HAVE_STDDEF_H 1 + +/* Define if you have the header file. */ +/* #undef HAVE_SYS_AUDIOIO_H */ + +/* Define if you have the header file. */ +/* #define HAVE_SYS_PARAM_H 1 */ + +/* Define if you have the header file. */ +/* #define HAVE_SYS_SELECT_H 1 */ + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_STAT_H 1 + +/* Define if you have the header file. */ +/* #define HAVE_SYS_TIME_H 1 */ + +/* Define if you have the header file. */ +/* #define HAVE_SYS_TIMES_H 1 */ + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TYPES_H 1 + +/* Define if you have the header file. */ +/* #define HAVE_SYS_UN_H 1 */ + +/* Define if you have the header file. */ +/* #define HAVE_SYS_UTIME_H 1 */ + +/* Define if you have the header file. */ +/* #define HAVE_SYS_UTSNAME_H 1 */ + +/* Define if you have the header file. */ +/* #define HAVE_UNISTD_H 1 */ + +/* Define if you have the header file. */ +/* #define HAVE_UTIME_H 1 */ + +/* Define if the compiler provides a wchar.h header file. */ +#define HAVE_WCHAR_H 1 + +/* Define if you have the dl library (-ldl). */ +/* #undef HAVE_LIBDL */ + +/* Define if you have the mpc library (-lmpc). */ +/* #undef HAVE_LIBMPC */ + +/* Define if you have the nsl library (-lnsl). */ +#define HAVE_LIBNSL 1 + +/* Define if you have the seq library (-lseq). */ +/* #undef HAVE_LIBSEQ */ + +/* Define if you have the socket library (-lsocket). */ +#define HAVE_LIBSOCKET 1 + +/* Define if you have the sun library (-lsun). */ +/* #undef HAVE_LIBSUN */ + +/* Define if you have the termcap library (-ltermcap). */ +/* #undef HAVE_LIBTERMCAP */ + +/* Define if you have the termlib library (-ltermlib). */ +/* #undef HAVE_LIBTERMLIB */ + +/* Define if you have the thread library (-lthread). */ +/* #undef HAVE_LIBTHREAD */ + +/* WinSock does not use a bitmask in select, and uses + socket handles greater than FD_SETSIZE */ +#define Py_SOCKET_FD_CAN_BE_GE_FD_SETSIZE + +/* Define if C doubles are 64-bit IEEE 754 binary format, stored with the + least significant byte first */ +#define DOUBLE_IS_LITTLE_ENDIAN_IEEE754 1 + +#endif /* !Py_CONFIG_H */ diff --git a/third/python-cmake/cmake/config-unix/pyconfig.h.in b/third/python-cmake/cmake/config-unix/pyconfig.h.in new file mode 100644 index 00000000..a6b8484f --- /dev/null +++ b/third/python-cmake/cmake/config-unix/pyconfig.h.in @@ -0,0 +1,2093 @@ +/* pyconfig.h. Generated from pyconfig.h.in by configure. */ +/* pyconfig.h.in. Generated from configure.in by autoheader. */ + + +#ifndef Py_PYCONFIG_H +#define Py_PYCONFIG_H + + +/* Define if building universal (internal helper macro) */ +#cmakedefine AC_APPLE_UNIVERSAL_BUILD 1 + +/* BUILD_GNU_TYPE + AIX_BUILDDATE are used to construct the PEP425 tag of the + build system. [Python 3.9] */ +#cmakedefine AIX_BUILDDATE 1 + +/* Define for AIX if your compiler is a genuine IBM xlC/xlC_r and you want + support for AIX C++ shared extension modules. */ +#cmakedefine AIX_GENUINE_CPLUSPLUS 1 + +/* The normal alignment of `long', in bytes. [Python 3.10] */ +#cmakedefine ALIGNOF_LONG @SIZEOF_LONG@ + +/* The normal alignment of `max_align_t', in bytes. [Python 3.12] */ +#cmakedefine ALIGNOF_MAX_ALIGN_T @ALIGNOF_MAX_ALIGN_T@ + +/* The normal alignment of `size_t', in bytes. [Python 3.10] */ +#cmakedefine ALIGNOF_SIZE_T @SIZEOF_SIZE_T@ + +/* Alternative SOABI used in debug build to load C extensions built in release + mode [Python 3.8] */ +#cmakedefine ALT_SOABI 1 + +/* The Android API level. [Python 3.7] */ +#cmakedefine ANDROID_API_LEVEL 1 + +/* Define if C doubles are 64-bit IEEE 754 binary format, stored in ARM + mixed-endian order (byte order 45670123) */ +#cmakedefine DOUBLE_IS_ARM_MIXED_ENDIAN_IEEE754 1 + +/* Define if C doubles are 64-bit IEEE 754 binary format, stored with the most + significant byte first */ +#cmakedefine DOUBLE_IS_BIG_ENDIAN_IEEE754 1 + +/* Define if C doubles are 64-bit IEEE 754 binary format, stored with the + least significant byte first */ +#cmakedefine DOUBLE_IS_LITTLE_ENDIAN_IEEE754 1 + +/* Define if --enable-ipv6 is specified */ +#cmakedefine ENABLE_IPV6 1 + +/* Define to 1 if your system stores words within floats with the most + significant word first [Python 3.8] */ +#cmakedefine FLOAT_WORDS_BIGENDIAN 1 + +/* Define if flock needs to be linked with bsd library. [Python <= 3.10] */ +#cmakedefine FLOCK_NEEDS_LIBBSD 1 + +/* Define if getpgrp() must be called as getpgrp(0). */ +#cmakedefine GETPGRP_HAVE_ARG 1 + +/* Define if gettimeofday() does not have second (timezone) argument This is + the case on Motorola V4 (R40V4.2) [Python <= 3.8] */ +#cmakedefine GETTIMEOFDAY_NO_TZ 1 + +/* Define to 1 if you have the `accept' function. [Python 3.11] */ +#cmakedefine HAVE_ACCEPT 1 + +/* Define to 1 if you have the `accept4' function. [Python 3] */ +#cmakedefine HAVE_ACCEPT4 1 + +/* Define to 1 if you have the `acosh' function. */ +#cmakedefine HAVE_ACOSH 1 + +/* struct addrinfo (netdb.h) */ +#cmakedefine HAVE_ADDRINFO 1 + +/* Define to 1 if you have the `alarm' function. */ +#cmakedefine HAVE_ALARM 1 + +/* Define if aligned memory access is required [Python 3] */ +#cmakedefine HAVE_ALIGNED_REQUIRED 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_ALLOCA_H 1 + +/* Define this if your time.h defines altzone. */ +#cmakedefine HAVE_ALTZONE 1 + +/* Define to 1 if you have the `asinh' function. */ +#cmakedefine HAVE_ASINH 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_ASM_TYPES_H 1 + +/* Define to 1 if you have the `atanh' function. */ +#cmakedefine HAVE_ATANH 1 + +/* Define to 1 if you have the `bind' function. [Python 3.11] */ +#cmakedefine HAVE_BIND 1 + +/* Define to 1 if you have the `bind_textdomain_codeset' function. */ +#cmakedefine HAVE_BIND_TEXTDOMAIN_CODESET 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_BLUETOOTH_BLUETOOTH_H 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_BLUETOOTH_H 1 + +/* Define if mbstowcs(NULL, "text", 0) does not return the number of wide + chars that would be converted. [Python 3] */ +#cmakedefine HAVE_BROKEN_MBSTOWCS 1 + +/* Define if nice() returns success/failure instead of the new priority. */ +#cmakedefine HAVE_BROKEN_NICE 1 + +/* Define if the system reports an invalid PIPE_BUF value. */ +#cmakedefine HAVE_BROKEN_PIPE_BUF 1 + +/* Define if poll() sets errno on invalid file descriptors. */ +#cmakedefine HAVE_BROKEN_POLL 1 + +/* Define if the Posix semaphores do not work on your system */ +#cmakedefine HAVE_BROKEN_POSIX_SEMAPHORES 1 + +/* Define if pthread_sigmask() does not work on your system. */ +#cmakedefine HAVE_BROKEN_PTHREAD_SIGMASK 1 + +/* define to 1 if your sem_getvalue is broken. */ +#cmakedefine HAVE_BROKEN_SEM_GETVALUE 1 + +/* Define if `unsetenv` does not return an int. */ +#cmakedefine HAVE_BROKEN_UNSETENV 1 + +/* Has builtin __atomic_load_n() and __atomic_store_n() functions [Python 3] */ +#cmakedefine HAVE_BUILTIN_ATOMIC 1 + +/* Define this if you have the type _Bool. [Python <= 3.5] */ +#cmakedefine HAVE_C99_BOOL 1 + +/* Define to 1 if you have the header file. [Python 3.11] */ +#cmakedefine HAVE_BZLIB_H 1 + +/* Define to 1 if you have the 'chflags' function. */ +#cmakedefine HAVE_CHFLAGS 1 + +/* Define to 1 if you have the `chmod' function. [Python 3.11] */ +#cmakedefine HAVE_CHMOD 1 + +/* Define to 1 if you have the `chown' function. */ +#cmakedefine HAVE_CHOWN 1 + +/* Define if you have the 'chroot' function. */ +#cmakedefine HAVE_CHROOT 1 + +/* Define to 1 if you have the `clock' function. */ +#cmakedefine HAVE_CLOCK 1 + +/* Define to 1 if you have the `clock_getres' function. [Python 3] */ +#cmakedefine HAVE_CLOCK_GETRES 1 + +/* Define to 1 if you have the `clock_gettime' function. [Python 3] */ +#cmakedefine HAVE_CLOCK_GETTIME 1 + +/* Define to 1 if you have the `clock_nanosleep' function. [Python 3.11] */ +#cmakedefine HAVE_CLOCK_NANOSLEEP 1 + +/* Define to 1 if you have the `clock_settime' function. [Python 3.6] */ +#cmakedefine HAVE_CLOCK_SETTIME 1 + +/* Define to 1 if you have the `close_range' function. [Python 3.10] */ +#cmakedefine HAVE_CLOSE_RANGE 1 + +/* Define if the C compiler supports computed gotos. */ +#cmakedefine HAVE_COMPUTED_GOTOS 1 + +/* Define to 1 if you have the `confstr' function. */ +#cmakedefine HAVE_CONFSTR 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_CONIO_H 1 + +/* Define to 1 if you have the `connect' function. [Python 3.11] */ +#cmakedefine HAVE_CONNECT 1 + +/* Define to 1 if you have the `copysign' function. [Python <= 3.10] */ +#cmakedefine HAVE_COPYSIGN 1 + +/* Define to 1 if you have the `copy_file_range' function. [Python 3.8] */ +#cmakedefine HAVE_COPY_FILE_RANGE 1 + +/* Define to 1 if you have the header file. [Python 3.6] */ +#cmakedefine HAVE_CRYPT_H 1 + +/* Define if you have the crypt_r() function. [Python 3.7] */ +#cmakedefine HAVE_CRYPT_R 1 + +/* Define to 1 if you have the `ctermid' function. */ +#cmakedefine HAVE_CTERMID 1 + +/* Define if you have the 'ctermid_r' function. */ +#cmakedefine HAVE_CTERMID_R 1 + +/* Define if you have the 'filter' function. [Python 3.6] */ +#cmakedefine HAVE_CURSES_FILTER 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_CURSES_H 1 + +/* Define if you have the 'has_key' function. [Python 3.6] */ +#cmakedefine HAVE_CURSES_HAS_KEY 1 + +/* Define if you have the 'immedok' function. [Python 3.6] */ +#cmakedefine HAVE_CURSES_IMMEDOK 1 + +/* Define if you have the 'is_pad' function or macro. [Python 3.6] */ +#cmakedefine HAVE_CURSES_IS_PAD 1 + +/* Define if you have the 'is_term_resized' function. */ +#cmakedefine HAVE_CURSES_IS_TERM_RESIZED 1 + +/* Define if you have the 'resizeterm' function. */ +#cmakedefine HAVE_CURSES_RESIZETERM 1 + +/* Define if you have the 'resize_term' function. */ +#cmakedefine HAVE_CURSES_RESIZE_TERM 1 + +/* Define if you have the 'syncok' function. [Python 3.6] */ +#cmakedefine HAVE_CURSES_SYNCOK 1 + +/* Define if you have the 'typeahead' function. [Python 3.6] */ +#cmakedefine HAVE_CURSES_TYPEAHEAD 1 + +/* Define if you have the 'use_env' function. [Python 3.6] */ +#cmakedefine HAVE_CURSES_USE_ENV 1 + +/* Define if you have the 'wchgat' function. [Python 3.6] */ +#cmakedefine HAVE_CURSES_WCHGAT 1 + +/* Define to 1 if you have the header file. [Python 3.11] */ +#cmakedefine HAVE_DB_H 1 + +/* Define to 1 if you have the declaration of `isfinite', and to 0 if you + don't. [Python <= 3.10] */ +#cmakedefine HAVE_DECL_ISFINITE 1 + +/* Define to 1 if you have the declaration of `isinf', and to 0 if you don't. + [Python <= 3.10] */ +#cmakedefine HAVE_DECL_ISINF 1 + +/* Define to 1 if you have the declaration of `isnan', and to 0 if you don't. + [Python <= 3.10] */ +#cmakedefine HAVE_DECL_ISNAN 1 + +/* Define to 1 if you have the declaration of `RTLD_DEEPBIND', and to 0 if you + don't. [Python 3.6] */ +#cmakedefine HAVE_DECL_RTLD_DEEPBIND 1 + +/* Define to 1 if you have the declaration of `RTLD_GLOBAL', and to 0 if you + don't. [Python 3.6] */ +#cmakedefine HAVE_DECL_RTLD_GLOBAL 1 + +/* Define to 1 if you have the declaration of `RTLD_LAZY', and to 0 if you + don't. [Python 3.6] */ +#cmakedefine HAVE_DECL_RTLD_LAZY 1 + +/* Define to 1 if you have the declaration of `RTLD_LOCAL', and to 0 if you + don't. [Python 3.6] */ +#cmakedefine HAVE_DECL_RTLD_LOCAL 1 + +/* Define to 1 if you have the declaration of `RTLD_MEMBER', and to 0 if you + don't. [Python 3.7] */ +#cmakedefine HAVE_DECL_RTLD_MEMBER 1 + +/* Define to 1 if you have the declaration of `RTLD_NODELETE', and to 0 if you + don't. [Python 3.6] */ +#cmakedefine HAVE_DECL_RTLD_NODELETE 1 + +/* Define to 1 if you have the declaration of `RTLD_NOLOAD', and to 0 if you + don't. [Python 3.6] */ +#cmakedefine HAVE_DECL_RTLD_NOLOAD 1 + +/* Define to 1 if you have the declaration of `RTLD_NOW', and to 0 if you + don't. [Python 3.6] */ +#cmakedefine HAVE_DECL_RTLD_NOW 1 + +/* Define to 1 if you have the declaration of `tzname', and to 0 if you don't. + */ +#cmakedefine HAVE_DECL_TZNAME 1 + +/* Define to 1 if you have the device macros. */ +#cmakedefine HAVE_DEVICE_MACROS 1 + +/* Define to 1 if you have the /dev/ptc device file. */ +#cmakedefine HAVE_DEV_PTC 1 + +/* Define to 1 if you have the /dev/ptmx device file. */ +#cmakedefine HAVE_DEV_PTMX 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_DIRECT_H 1 + +/* Define to 1 if the dirent structure has a d_type field [Python 3] */ +#cmakedefine HAVE_DIRENT_D_TYPE 1 + +/* Define to 1 if you have the header file, and it defines `DIR'. + */ +#cmakedefine HAVE_DIRENT_H 1 + +/* Define if you have the 'dirfd' function or macro. [Python 3] */ +#cmakedefine HAVE_DIRFD 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_DLFCN_H 1 + +/* Define to 1 if you have the `dlopen' function. */ +#cmakedefine HAVE_DLOPEN 1 + +/* Define to 1 if you have the `dup' function. [Python 3.11] */ +#cmakedefine HAVE_DUP 1 + +/* Define to 1 if you have the `dup2' function. */ +#cmakedefine HAVE_DUP2 1 + +/* Define to 1 if you have the `dup3' function. [Python 3] */ +#cmakedefine HAVE_DUP3 1 + +/* Define if you have the '_dyld_shared_cache_contains_path' function. [Python 3.8] */ +#cmakedefine HAVE_DYLD_SHARED_CACHE_CONTAINS_PATH 1 + +/* Defined when any dynamic module loading is enabled. */ +#cmakedefine HAVE_DYNAMIC_LOADING 1 + +/* Define to 1 if you have the header file. [Python 3.12] */ +#cmakedefine HAVE_EDITLINE_READLINE_H 1 + +/* Define to 1 if you have the header file. [Python 3] */ +#cmakedefine HAVE_ENDIAN_H 1 + +/* Define if you have the 'epoll' functions. */ +#cmakedefine HAVE_EPOLL 1 + +/* Define if you have the 'epoll_create1' function. [Python 3] */ +#cmakedefine HAVE_EPOLL_CREATE1 1 + +/* Define to 1 if you have the `erf' function. */ +#cmakedefine HAVE_ERF 1 + +/* Define to 1 if you have the `erfc' function. */ +#cmakedefine HAVE_ERFC 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_ERRNO_H 1 + +/* Define if you have the 'eventfd' function. [Python 3.10] */ +#cmakedefine HAVE_EVENTFD 1 + +/* Define to 1 if you have the `execv' function. */ +#cmakedefine HAVE_EXECV 1 + +/* Define to 1 if you have the `explicit_bzero' function. [Python 3.8] */ +#cmakedefine HAVE_EXPLICIT_BZERO 1 + +/* Define to 1 if you have the `explicit_memset' function. [Python 3.8] */ +#cmakedefine HAVE_EXPLICIT_MEMSET 1 + +/* Define to 1 if you have the `expm1' function. */ +#cmakedefine HAVE_EXPM1 1 + +/* Define to 1 if you have the `faccessat' function. [Python 3] */ +#cmakedefine HAVE_FACCESSAT 1 + +/* Define if you have the 'fchdir' function. */ +#cmakedefine HAVE_FCHDIR 1 + +/* Define to 1 if you have the `fchmod' function. */ +#cmakedefine HAVE_FCHMOD 1 + +/* Define to 1 if you have the `fchmodat' function. [Python 3] */ +#cmakedefine HAVE_FCHMODAT 1 + +/* Define to 1 if you have the `fchown' function. */ +#cmakedefine HAVE_FCHOWN 1 + +/* Define to 1 if you have the `fchownat' function. [Python 3] */ +#cmakedefine HAVE_FCHOWNAT 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_FCNTL_H 1 + +/* Define if you have the 'fdatasync' function. */ +#cmakedefine HAVE_FDATASYNC 1 + +/* Define to 1 if you have the `fdopendir' function. [Python 3] */ +#cmakedefine HAVE_FDOPENDIR 1 + +/* Define to 1 if you have the `fdwalk' function. [Python 3.8] */ +#cmakedefine HAVE_FDWALK 1 + +/* Define to 1 if you have the `fexecve' function. [Python 3] */ +#cmakedefine HAVE_FEXECVE 1 + +/* Define if you have the 'ffi_closure_alloc' function. [Python 3.12] */ +#cmakedefine HAVE_FFI_CLOSURE_ALLOC 1 + +/* Define if you have the 'ffi_prep_cif_var' function. [Python 3.12] */ +#cmakedefine HAVE_FFI_PREP_CIF_VAR 1 + +/* Define if you have the 'ffi_prep_closure_loc' function. [Python 3.12] */ +#cmakedefine HAVE_FFI_PREP_CLOSURE_LOC 1 + +/* Define to 1 if you have the `finite' function. [Python <= 3.10] */ +#cmakedefine HAVE_FINITE 1 + +/* Define to 1 if you have the `flock' function. */ +#cmakedefine HAVE_FLOCK 1 + +/* Define to 1 if you have the `fork' function. */ +#cmakedefine HAVE_FORK 1 + +/* Define to 1 if you have the `fork1' function. [Python 3.11] */ +#cmakedefine HAVE_FORK1 1 + +/* Define to 1 if you have the `forkpty' function. */ +#cmakedefine HAVE_FORKPTY 1 + +/* Define to 1 if you have the `fpathconf' function. */ +#cmakedefine HAVE_FPATHCONF 1 + +/* Define to 1 if you have the `fseek64' function. */ +#cmakedefine HAVE_FSEEK64 1 + +/* Define to 1 if you have the `fseeko' function. */ +#cmakedefine HAVE_FSEEKO 1 + +/* Define to 1 if you have the `fstatat' function. [Python 3] */ +#cmakedefine HAVE_FSTATAT 1 + +/* Define to 1 if you have the `fstatvfs' function. */ +#cmakedefine HAVE_FSTATVFS 1 + +/* Define if you have the 'fsync' function. */ +#cmakedefine HAVE_FSYNC 1 + +/* Define to 1 if you have the `ftell64' function. */ +#cmakedefine HAVE_FTELL64 1 + +/* Define to 1 if you have the `ftello' function. */ +#cmakedefine HAVE_FTELLO 1 + +/* Define to 1 if you have the `ftime' function. */ +#cmakedefine HAVE_FTIME 1 + +/* Define to 1 if you have the `ftruncate' function. */ +#cmakedefine HAVE_FTRUNCATE 1 + +/* Define to 1 if you have the `futimens' function. [Python 3] */ +#cmakedefine HAVE_FUTIMENS 1 + +/* Define to 1 if you have the `futimes' function. [Python 3] */ +#cmakedefine HAVE_FUTIMES 1 + +/* Define to 1 if you have the `futimesat' function. [Python 3] */ +#cmakedefine HAVE_FUTIMESAT 1 + +/* Define to 1 if you have the `gai_strerror' function. */ +#cmakedefine HAVE_GAI_STRERROR 1 + +/* Define to 1 if you have the `gamma' function. [Python <= 3.10] */ +#cmakedefine HAVE_GAMMA 1 + +/* Define if we can use gcc inline assembler to get and set mc68881 fpcr [Python 3] */ +#cmakedefine HAVE_GCC_ASM_FOR_MC68881 1 + +/* Define if we can use x64 gcc inline assembler [Python 3] */ +#cmakedefine HAVE_GCC_ASM_FOR_X64 1 + +/* Define if we can use gcc inline assembler to get and set x87 control word + */ +#cmakedefine HAVE_GCC_ASM_FOR_X87 1 + +/* Define if your compiler provides __uint128_t [Python 3] */ +#cmakedefine HAVE_GCC_UINT128_T 1 + +/* Define to 1 if you have the header file. [Python 3.11] */ +#cmakedefine HAVE_GDBM_DASH_NDBM_H 1 + +/* Define to 1 if you have the header file. [Python 3.11] */ +#cmakedefine HAVE_GDBM_H 1 + +/* Define to 1 if you have the header file. [Python 3.11] */ +#cmakedefine HAVE_GDBM_NDBM_H 1 + +/* Define if you have the getaddrinfo function. */ +#cmakedefine HAVE_GETADDRINFO 1 + +/* Define this if you have flockfile(), getc_unlocked(), and funlockfile() */ +#cmakedefine HAVE_GETC_UNLOCKED 1 + +/* Define to 1 if you have the `getegid' function. [Python 3.11] */ +#cmakedefine HAVE_GETEGID 1 + +/* Define to 1 if you have the `geteuid' function. [Python 3.11] */ +#cmakedefine HAVE_GETEUID 1 + +/* Define to 1 if you have the `getentropy' function. [Python 3] */ +#cmakedefine HAVE_GETENTROPY 1 + +/* Define to 1 if you have the `getgid' function. [Python 3.11] */ +#cmakedefine HAVE_GETGID 1 + +/* Define to 1 if you have the `getgrgid' function. [Python 3.11] */ +#cmakedefine HAVE_GETGRGID 1 + +/* Define to 1 if you have the `getgrgid_r' function. [Python 3.8] */ +#cmakedefine HAVE_GETGRGID_R 1 + +/* Define to 1 if you have the `getgrnam_r' function. [Python 3.8] */ +#cmakedefine HAVE_GETGRNAM_R 1 + +/* Define to 1 if you have the `getgrouplist' function. [Python 3] */ +#cmakedefine HAVE_GETGROUPLIST 1 + +/* Define to 1 if you have the `getgroups' function. */ +#cmakedefine HAVE_GETGROUPS 1 + +/* Define to 1 if you have the `gethostbyaddr' function. [Python 3.11] */ +#cmakedefine HAVE_GETHOSTBYADDR 1 + +/* Define to 1 if you have the `gethostbyname' function. */ +#cmakedefine HAVE_GETHOSTBYNAME 1 + +/* Define this if you have some version of gethostbyname_r() */ +#cmakedefine HAVE_GETHOSTBYNAME_R 1 + +/* Define this if you have the 3-arg version of gethostbyname_r(). */ +#cmakedefine HAVE_GETHOSTBYNAME_R_3_ARG 1 + +/* Define this if you have the 5-arg version of gethostbyname_r(). */ +#cmakedefine HAVE_GETHOSTBYNAME_R_5_ARG 1 + +/* Define this if you have the 6-arg version of gethostbyname_r(). */ +#cmakedefine HAVE_GETHOSTBYNAME_R_6_ARG 1 + +/* Define if you have the gethostname function. [Python 3.11] */ +#cmakedefine HAVE_GETHOSTNAME 1 + +/* Define to 1 if you have the `getitimer' function. */ +#cmakedefine HAVE_GETITIMER 1 + +/* Define to 1 if you have the `getloadavg' function. */ +#cmakedefine HAVE_GETLOADAVG 1 + +/* Define to 1 if you have the `getlogin' function. */ +#cmakedefine HAVE_GETLOGIN 1 + +/* Define to 1 if you have the `getnameinfo' function. */ +#cmakedefine HAVE_GETNAMEINFO 1 + +/* Define if you have the 'getpagesize' function. */ +#cmakedefine HAVE_GETPAGESIZE 1 + +/* Define to 1 if you have the `getpeername' function. */ +#cmakedefine HAVE_GETPEERNAME 1 + +/* Define to 1 if you have the `getpgid' function. */ +#cmakedefine HAVE_GETPGID 1 + +/* Define to 1 if you have the `getpgrp' function. */ +#cmakedefine HAVE_GETPGRP 1 + +/* Define to 1 if you have the `getpid' function. */ +#cmakedefine HAVE_GETPID 1 + +/* Define if you have the 'getppid' function. [Python 3.11] */ +#cmakedefine HAVE_GETPPID 1 + +/* Define to 1 if you have the `getpriority' function. */ +#cmakedefine HAVE_GETPRIORITY 1 + +/* Define if you have the 'getprotobyname' function. [Python 3.11] */ +#cmakedefine HAVE_GETPROTOBYNAME 1 + +/* Define to 1 if you have the `getpwent' function. */ +#cmakedefine HAVE_GETPWENT 1 + +/* Define to 1 if you have the `getpwnam_r' function. [Python 3.8] */ +#cmakedefine HAVE_GETPWNAM_R 1 + +/* Define to 1 if you have the `getpwuid' function. [Python 3.11] */ +#cmakedefine HAVE_GETPWUID 1 + +/* Define to 1 if you have the `getpwuid_r' function. [Python 3.8] */ +#cmakedefine HAVE_GETPWUID_R 1 + +/* Define to 1 if the getrandom() function is available [Python 3] */ +#cmakedefine HAVE_GETRANDOM 1 + +/* Define to 1 if the Linux getrandom() syscall is available [Python 3] */ +#cmakedefine HAVE_GETRANDOM_SYSCALL 1 + +/* Define to 1 if you have the `getresgid' function. */ +#cmakedefine HAVE_GETRESGID 1 + +/* Define to 1 if you have the `getresuid' function. */ +#cmakedefine HAVE_GETRESUID 1 + +/* Define to 1 if you have the `getrusage' function. [Python 3.11] */ +#cmakedefine HAVE_GETRUSAGE 1 + +/* Define to 1 if you have the `getservbyname' function. [Python 3.11] */ +#cmakedefine HAVE_GETSERVBYNAME 1 + +/* Define if you have the 'getservbyport' function. [Python 3.11] */ +#cmakedefine HAVE_GETSERVBYPORT 1 + +/* Define to 1 if you have the `getsid' function. */ +#cmakedefine HAVE_GETSID 1 + +/* Define to 1 if you have the `getsockname' function. [Python 3.11] */ +#cmakedefine HAVE_GETSOCKNAME 1 + +/* Define to 1 if you have the `getspent' function. */ +#cmakedefine HAVE_GETSPENT 1 + +/* Define to 1 if you have the `getspnam' function. */ +#cmakedefine HAVE_GETSPNAM 1 + +/* Define to 1 if you have the `gettimeofday' function. [Python <= 3.8] */ +#cmakedefine HAVE_GETTIMEOFDAY 1 + +/* Define to 1 if you have the `getuid' function. [Python 3.11] */ +#cmakedefine HAVE_GETUID 1 + +/* Define to 1 if you have the `getwd' function. */ +#cmakedefine HAVE_GETWD 1 + +/* Define if glibc has incorrect _FORTIFY_SOURCE wrappers for memmove and + bcopy. [Python 3] */ +#cmakedefine HAVE_GLIBC_MEMMOVE_BUG 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_GRP_H 1 + +/* Define if you have the 'hstrerror' function. */ +#cmakedefine HAVE_HSTRERROR 1 + +/* Define this if you have le64toh() [Python 3] */ +#cmakedefine HAVE_HTOLE64 1 + +/* Define to 1 if you have the `hypot' function. [Python <= 3.10] */ +#cmakedefine HAVE_HYPOT 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_IEEEFP_H 1 + +/* Define to 1 if you have the `if_nameindex' function. [Python 3] */ +#cmakedefine HAVE_IF_NAMEINDEX 1 + +/* Define if you have the 'inet_aton' function. */ +#cmakedefine HAVE_INET_ATON 1 + +/* Define if you have the 'inet_ntoa' function. [Python 3.11] */ +#cmakedefine HAVE_INET_NTOA 1 + +/* Define if you have the 'inet_pton' function. */ +#cmakedefine HAVE_INET_PTON 1 + +/* Define to 1 if you have the `initgroups' function. */ +#cmakedefine HAVE_INITGROUPS 1 + +/* Define if your compiler provides int32_t. [Python <= 3.5] */ +#cmakedefine HAVE_INT32_T 1 + +/* Define if your compiler provides int64_t. [Python <= 3.5] */ +#cmakedefine HAVE_INT64_T 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_INTTYPES_H 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_IO_H 1 + +/* Define if gcc has the ipa-pure-const bug. [Python 3] */ +#cmakedefine HAVE_IPA_PURE_CONST_BUG 1 + +/* Define to 1 if you have the `kill' function. */ +#cmakedefine HAVE_KILL 1 + +/* Define to 1 if you have the `killpg' function. */ +#cmakedefine HAVE_KILLPG 1 + +/* Define if you have the 'kqueue' functions. */ +#cmakedefine HAVE_KQUEUE 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_LANGINFO_H 1 + +/* Defined to enable large file support when an off_t is bigger than a long + and long long is at least as big as an off_t. You may need to add some + flags for configuration and compilation to enable this mode. (For Solaris + and Linux, the necessary defines are already defined.) */ +#cmakedefine HAVE_LARGEFILE_SUPPORT 1 + +/* Define to 1 if you have the 'lchflags' function. */ +#cmakedefine HAVE_LCHFLAGS 1 + +/* Define to 1 if you have the `lchmod' function. */ +#cmakedefine HAVE_LCHMOD 1 + +/* Define to 1 if you have the `lchown' function. */ +#cmakedefine HAVE_LCHOWN 1 + +/* Define to 1 if you want to build _blake2 module with libb2 [Python 3.11] */ +#cmakedefine HAVE_LIBB2 1 + +/* Define to 1 if you have the `db' library (-ldb). [Python 3.11] */ +#cmakedefine HAVE_LIBDB 1 + +/* Define to 1 if you have the `lgamma' function. [Python <= 3.10] */ +#cmakedefine HAVE_LGAMMA 1 + +/* Define to 1 if you have the `dl' library (-ldl). */ +#cmakedefine HAVE_LIBDL 1 + +/* Define to 1 if you have the `dld' library (-ldld). */ +#cmakedefine HAVE_LIBDLD 1 + +/* Define to 1 if you have the `gdbm_compat' library (-lgdbm_compat). [Python 3.11] */ +#cmakedefine HAVE_LIBGDBM_COMPAT 1 + +/* Define to 1 if you have the `ieee' library (-lieee). */ +#cmakedefine HAVE_LIBIEEE 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_LIBINTL_H 1 + +/* Define to 1 if you have the `ndbm' library (-lndbm). [Python 3.11] */ +#cmakedefine HAVE_LIBNDBM 1 + +/* Define if you have the readline library (-lreadline). [Python <= 3.11] */ +#cmakedefine HAVE_LIBREADLINE 1 + +/* Define to 1 if you have the `resolv' library (-lresolv). */ +#cmakedefine HAVE_LIBRESOLV 1 + +/* Define to 1 if you have the `sendfile' library (-lsendfile). [Python 3] */ +#cmakedefine HAVE_LIBSENDFILE 1 + +/* Define to 1 if you have the `sqlite3' library (-lsqlite3). [Python 3.11] */ +#cmakedefine HAVE_LIBSQLITE3 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_LIBUTIL_H 1 + +/* Define to 1 if you have the `uuid' library (-luuid). [Python 3.9] */ +#cmakedefine HAVE_LIBUUID 1 + +/* Define if you have the 'link' function. */ +#cmakedefine HAVE_LINK 1 + +/* Define to 1 if you have the `linkat' function. [Python 3] */ +#cmakedefine HAVE_LINKAT 1 + +/* Define to 1 if you have the header file. [Python 3.10] */ +#cmakedefine HAVE_LINUX_AUXVEC_H 1 + +/* Define to 1 if you have the header file. [Python 3] */ +#cmakedefine HAVE_LINUX_CAN_BCM_H 1 + +/* Define to 1 if you have the header file. [Python 3] */ +#cmakedefine HAVE_LINUX_CAN_H 1 + +/* Define to 1 if you have the header file. [Python 3.9] */ +#cmakedefine HAVE_LINUX_CAN_J1939_H 1 + +/* Define if compiling using Linux 3.6 or later. [Python 3] */ +#cmakedefine HAVE_LINUX_CAN_RAW_FD_FRAMES 1 + +/* Define to 1 if you have the header file. [Python 3] */ +#cmakedefine HAVE_LINUX_CAN_RAW_H 1 + +/* Define if compiling using Linux 4.1 or later. [Python 3.9] */ +#cmakedefine HAVE_LINUX_CAN_RAW_JOIN_FILTERS 1 + +/* Define to 1 if you have the header file. [Python 3.12] */ +#cmakedefine HAVE_LINUX_FS_H 1 + +/* Define to 1 if you have the header file. [Python 3.11] */ +#cmakedefine HAVE_LINUX_LIMITS_H 1 + +/* Define to 1 if you have the header file. [Python 3.8] */ +#cmakedefine HAVE_LINUX_MEMFD_H 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_LINUX_NETLINK_H 1 + +/* Define to 1 if you have the header file. [Python 3.8] */ +#cmakedefine HAVE_LINUX_QRTR_H 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_LINUX_RANDOM_H 1 + +/* Define to 1 if you have the header file. [Python 3.11] */ +#cmakedefine HAVE_LINUX_SOUNDCARD_H 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_LINUX_TIPC_H 1 + +/* Define to 1 if you have the header file. [Python 3.7] */ +#cmakedefine HAVE_LINUX_VM_SOCKETS_H 1 + +/* Define to 1 if you have the header file. [Python 3.9] */ +#cmakedefine HAVE_LINUX_WAIT_H 1 + +/* Define to 1 if you have the `listen' function. [Python 3.11] */ +#cmakedefine HAVE_LISTEN 1 + +/* Define to 1 if you have the `lockf' function. [Python 3] */ +#cmakedefine HAVE_LOCKF 1 + +/* Define to 1 if you have the `log1p' function. */ +#cmakedefine HAVE_LOG1P 1 + +/* Define to 1 if you have the `log2' function. [Python 3] */ +#cmakedefine HAVE_LOG2 1 + +/* Define to 1 if you have the `login_tty' function. [Python 3.11] */ +#cmakedefine HAVE_LOGIN_TTY 1 + +/* Define this if you have the type long double. */ +#cmakedefine HAVE_LONG_DOUBLE 1 + +/* Define this if you have the type long long. [Python <= 3.5] */ +#cmakedefine HAVE_LONG_LONG 1 + +/* Define to 1 if you have the `lstat' function. */ +#cmakedefine HAVE_LSTAT 1 + +/* Define to 1 if you have the `lutimes' function. [Python 3] */ +#cmakedefine HAVE_LUTIMES 1 + +/* Define to 1 if you have the header file. [Python 3.11] */ +#cmakedefine HAVE_LZMA_H 1 + +/* Define to 1 if you have the `madvise' function. [Python 3.8] */ +#cmakedefine HAVE_MADVISE 1 + +/* Define this if you have the makedev macro. */ +#cmakedefine HAVE_MAKEDEV 1 + +/* Define to 1 if you have the `mbrtowc' function. [Python 3] */ +#cmakedefine HAVE_MBRTOWC 1 + +/* Define if you have the 'memfd_create' function. [Python 3.8] */ +#cmakedefine HAVE_MEMFD_CREATE 1 + +/* Define to 1 if you have the `memmove' function. [Python <= 3.6] */ +#cmakedefine HAVE_MEMMOVE 1 + +/* Define to 1 if you have the header file. [Python <= 3.11] */ +#cmakedefine HAVE_MEMORY_H 1 + +/* Define to 1 if you have the `memrchr' function. [Python 3] */ +#cmakedefine HAVE_MEMRCHR 1 + +/* Define to 1 if you have the header file. [Python 3.12] */ +#cmakedefine HAVE_MINIX_CONFIG_H 1 + +/* Define to 1 if you have the `mkdirat' function. [Python 3] */ +#cmakedefine HAVE_MKDIRAT 1 + +/* Define to 1 if you have the `mkfifo' function. */ +#cmakedefine HAVE_MKFIFO 1 + +/* Define to 1 if you have the `mkfifoat' function. [Python 3] */ +#cmakedefine HAVE_MKFIFOAT 1 + +/* Define to 1 if you have the `mknod' function. */ +#cmakedefine HAVE_MKNOD 1 + +/* Define to 1 if you have the `mknodat' function. [Python 3] */ +#cmakedefine HAVE_MKNODAT 1 + +/* Define to 1 if you have the `mktime' function. */ +#cmakedefine HAVE_MKTIME 1 + +/* Define to 1 if you have the `mmap' function. */ +#cmakedefine HAVE_MMAP 1 + +/* Define to 1 if you have the `mremap' function. */ +#cmakedefine HAVE_MREMAP 1 + +/* Define to 1 if you have the `nanosleep' function. [Python 3.11] */ +#cmakedefine HAVE_NANOSLEEP 1 + +/* Define to 1 if you have the `ncursesw' library. [Python 3.12] */ +#cmakedefine HAVE_NCURSESW 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_NCURSES_H 1 + +/* Define to 1 if you have the header file. [Python 3.11] */ +#cmakedefine HAVE_NDBM_H 1 + +/* Define to 1 if you have the header file, and it defines `DIR'. */ +#cmakedefine HAVE_NDIR_H 1 + +/* Define to 1 if you have the header file. [Python 3.11] */ +#cmakedefine HAVE_NETCAN_CAN_H 1 + +/* Define to 1 if you have the header file. [Python 3.11] */ +#cmakedefine HAVE_NETDB_H 1 + +/* Define to 1 if you have the header file. [Python 3.11] */ +#cmakedefine HAVE_NETINET_IN_H 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_NETPACKET_PACKET_H 1 + +/* Define to 1 if you have the header file. [Python 3.12] */ +#cmakedefine HAVE_NET_ETHERNET_H 1 + +/* Define to 1 if you have the header file. [Python 3] */ +#cmakedefine HAVE_NET_IF_H 1 + +/* Define to 1 if you have the `nice' function. */ +#cmakedefine HAVE_NICE 1 + +/* Define if the internal form of wchar_t in non-Unicode locales is not + Unicode. [Python 3.9] */ +#cmakedefine HAVE_NON_UNICODE_WCHAR_T_REPRESENTATION 1 + +/* Define to 1 if you have the `openat' function. [Python 3] */ +#cmakedefine HAVE_OPENAT 1 + +/* Define to 1 if you have the `opendir' function. [Python 3.11] */ +#cmakedefine HAVE_OPENDIR 1 + +/* Define to 1 if you have the `openpty' function. */ +#cmakedefine HAVE_OPENPTY 1 + +/* Define if compiling using MacOS X 10.5 SDK or later. [Python <= 3.5] */ +#cmakedefine HAVE_OSX105_SDK 1 + +/* Define to 1 if you have the header file. [Python 3.12] */ +#cmakedefine HAVE_PANEL_H 1 + +/* Define to 1 if you have the `pathconf' function. */ +#cmakedefine HAVE_PATHCONF 1 + +/* Define to 1 if you have the `pause' function. */ +#cmakedefine HAVE_PAUSE 1 + +/* Define to 1 if you have the `pipe' function. [Python 3.11] */ +#cmakedefine HAVE_PIPE 1 + +/* Define to 1 if you have the `pipe2' function. [Python 3] */ +#cmakedefine HAVE_PIPE2 1 + +/* Define to 1 if you have the `plock' function. */ +#cmakedefine HAVE_PLOCK 1 + +/* Define to 1 if you have the `poll' function. */ +#cmakedefine HAVE_POLL 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_POLL_H 1 + +/* Define to 1 if you have the `posix_fadvise' function. [Python 3] */ +#cmakedefine HAVE_POSIX_FADVISE 1 + +/* Define to 1 if you have the `posix_fallocate' function. [Python 3] */ +#cmakedefine HAVE_POSIX_FALLOCATE 1 + +/* Define to 1 if you have the `posix_spawn' function. [Python 3.7] */ +#cmakedefine HAVE_POSIX_SPAWN 1 + +/* Define to 1 if you have the `posix_spawnp' function. [Python 3.8] */ +#cmakedefine HAVE_POSIX_SPAWNP 1 + +/* Define to 1 if you have the `pread' function. [Python 3] */ +#cmakedefine HAVE_PREAD 1 + +/* Define to 1 if you have the `preadv' function. [Python 3.7] */ +#cmakedefine HAVE_PREADV 1 + +/* Define to 1 if you have the `preadv2' function. [Python 3.7] */ +#cmakedefine HAVE_PREADV2 1 + +/* Define if you have the 'prlimit' functions. [Python 3] */ +#cmakedefine HAVE_PRLIMIT 1 + +/* Define if you have the '_dyld_shared_cache_contains_path' function. [Python 3.8] */ +#cmakedefine HAVE_DYLD_SHARED_CACHE_CONTAINS_PATH 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_PROCESS_H 1 + +/* Define if your compiler supports function prototype */ +#cmakedefine HAVE_PROTOTYPES 1 + +/* Define to 1 if you have the `pthread_atfork' function. [Python <= 3.6] */ +#cmakedefine HAVE_PTHREAD_ATFORK 1 + +/* Define to 1 if you have the `pthread_condattr_setclock' function. [Python 3.8] */ +#cmakedefine HAVE_PTHREAD_CONDATTR_SETCLOCK 1 + +/* Defined for Solaris 2.6 bug in pthread header. */ +#cmakedefine HAVE_PTHREAD_DESTRUCTOR 1 + +/* Define to 1 if you have the `pthread_getcpuclockid' function. [Python 3.7] */ +#cmakedefine HAVE_PTHREAD_GETCPUCLOCKID 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_PTHREAD_H 1 + +/* Define to 1 if you have the `pthread_init' function. */ +#cmakedefine HAVE_PTHREAD_INIT 1 + +/* Define to 1 if you have the `pthread_kill' function. [Python 3] */ +#cmakedefine HAVE_PTHREAD_KILL 1 + +/* Define to 1 if you have the `pthread_sigmask' function. */ +#cmakedefine HAVE_PTHREAD_SIGMASK 1 + +/* Define if platform requires stubbed pthreads support [Python 3.11] */ +/* #undef HAVE_PTHREAD_STUBS */ + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_PTY_H 1 + +/* Define to 1 if you have the `putenv' function. [Python <= 3.8] */ +#cmakedefine HAVE_PUTENV 1 + +/* Define to 1 if you have the `pwrite' function. [Python 3] */ +#cmakedefine HAVE_PWRITE 1 + +/* Define to 1 if you have the `pwritev' function. [Python 3.7] */ +#cmakedefine HAVE_PWRITEV 1 + +/* Define to 1 if you have the `pwritev2' function. [Python 3.7] */ +#cmakedefine HAVE_PWRITEV2 1 + +/* Define if the libcrypto has RAND_egd [Python 3, Python <= 3.4] */ +#cmakedefine HAVE_RAND_EGD 1 + +/* Define to 1 if you have the header file. [Python 3.12] */ +#cmakedefine HAVE_READLINE_READLINE_H 1 + +/* Define to 1 if you have the `readlink' function. */ +#cmakedefine HAVE_READLINK 1 + +/* Define to 1 if you have the `readlinkat' function. [Python 3] */ +#cmakedefine HAVE_READLINKAT 1 + +/* Define to 1 if you have the `readv' function. [Python 3] */ +#cmakedefine HAVE_READV 1 + +/* Define to 1 if you have the `realpath' function. */ +#cmakedefine HAVE_REALPATH 1 + +/* Define to 1 if you have the `recvfrom' function. [Python 3.11] */ +#cmakedefine HAVE_RECVFROM 1 + +/* Define to 1 if you have the `renameat' function. [Python 3] */ +#cmakedefine HAVE_RENAMEAT 1 + +/* Define if readline supports append_history [Python 3] */ +#cmakedefine HAVE_RL_APPEND_HISTORY 1 + +/* Define if you have readline 2.1 [Python <= 3.6] */ +#cmakedefine HAVE_RL_CALLBACK 1 + +/* Define if you can turn off readline's signal handling. */ +#cmakedefine HAVE_RL_CATCH_SIGNAL 1 + +/* Define if readline supports rl_compdisp_func_t [Python 3.11] */ +#cmakedefine HAVE_RL_COMPDISP_FUNC_T 1 + +/* Define if you have readline 2.2 */ +#cmakedefine HAVE_RL_COMPLETION_APPEND_CHARACTER 1 + +/* Define if you have readline 4.0 */ +#cmakedefine HAVE_RL_COMPLETION_DISPLAY_MATCHES_HOOK 1 + +/* Define if you have readline 4.2 */ +#cmakedefine HAVE_RL_COMPLETION_MATCHES 1 + +/* Define if you have rl_completion_suppress_append */ +#cmakedefine HAVE_RL_COMPLETION_SUPPRESS_APPEND 1 + +/* Define if you have readline 4.0 */ +#cmakedefine HAVE_RL_PRE_INPUT_HOOK 1 + +/* Define if you have readline 4.0 */ +#cmakedefine HAVE_RL_RESIZE_TERMINAL 1 + +/* Define to 1 if you have the `round' function. [Python <= 3.10] */ +#cmakedefine HAVE_ROUND 1 + +/* Define to 1 if you have the header file. [Python 3.11] */ +#cmakedefine HAVE_RPC_RPC_H 1 + +/* Define to 1 if you have the `rtpSpawn' function. [Python 3.8] */ +#cmakedefine HAVE_RTPSPAWN 1 + +/* Define to 1 if you have the `sched_get_priority_max' function. [Python 3] */ +#cmakedefine HAVE_SCHED_GET_PRIORITY_MAX 1 + +/* Define to 1 if you have the header file. [Python 3] */ +#cmakedefine HAVE_SCHED_H 1 + +/* Define to 1 if you have the `sched_rr_get_interval' function. [Python 3] */ +#cmakedefine HAVE_SCHED_RR_GET_INTERVAL 1 + +/* Define to 1 if you have the `sched_setaffinity' function. [Python 3] */ +#cmakedefine HAVE_SCHED_SETAFFINITY 1 + +/* Define to 1 if you have the `sched_setparam' function. [Python 3] */ +#cmakedefine HAVE_SCHED_SETPARAM 1 + +/* Define to 1 if you have the `sched_setscheduler' function. [Python 3] */ +#cmakedefine HAVE_SCHED_SETSCHEDULER 1 + +/* Define to 1 if you have the `select' function. [Python <= 3.6] */ +#cmakedefine HAVE_SELECT 1 + +/* Define to 1 if you have the `sem_clockwait' function. [Python 3.9] */ +#cmakedefine HAVE_SEM_CLOCKWAIT 1 + +/* Define to 1 if you have the `sem_getvalue' function. */ +#cmakedefine HAVE_SEM_GETVALUE 1 + +/* Define to 1 if you have the `sem_open' function. */ +#cmakedefine HAVE_SEM_OPEN 1 + +/* Define to 1 if you have the `sem_timedwait' function. */ +#cmakedefine HAVE_SEM_TIMEDWAIT 1 + +/* Define to 1 if you have the `sem_unlink' function. */ +#cmakedefine HAVE_SEM_UNLINK 1 + +/* Define to 1 if you have the `sendfile' function. [Python 3] */ +#cmakedefine HAVE_SENDFILE 1 + +/* Define to 1 if you have the `sendto' function. [Python 3.11] */ +#cmakedefine HAVE_SENDTO 1 + +/* Define to 1 if you have the `setegid' function. */ +#cmakedefine HAVE_SETEGID 1 + +/* Define to 1 if you have the `seteuid' function. */ +#cmakedefine HAVE_SETEUID 1 + +/* Define to 1 if you have the `setgid' function. */ +#cmakedefine HAVE_SETGID 1 + +/* Define if you have the 'setgroups' function. */ +#cmakedefine HAVE_SETGROUPS 1 + +/* Define to 1 if you have the `sethostname' function. [Python 3] */ +#cmakedefine HAVE_SETHOSTNAME 1 + +/* Define to 1 if you have the `setitimer' function. */ +#cmakedefine HAVE_SETITIMER 1 + +/* Define to 1 if you have the header file. [Python 3.11] */ +#cmakedefine HAVE_SETJMP_H 1 + +/* Define to 1 if you have the `setlocale' function. */ +#cmakedefine HAVE_SETLOCALE 1 + +/* Define to 1 if you have the `setns' function. [Python 3.12] */ +#cmakedefine HAVE_SETNS 1 + +/* Define to 1 if you have the `setpgid' function. */ +#cmakedefine HAVE_SETPGID 1 + +/* Define to 1 if you have the `setpgrp' function. */ +#cmakedefine HAVE_SETPGRP 1 + +/* Define to 1 if you have the `setpriority' function. [Python 3] */ +#cmakedefine HAVE_SETPRIORITY 1 + +/* Define to 1 if you have the `setregid' function. */ +#cmakedefine HAVE_SETREGID 1 + +/* Define to 1 if you have the `setresgid' function. */ +#cmakedefine HAVE_SETRESGID 1 + +/* Define to 1 if you have the `setresuid' function. */ +#cmakedefine HAVE_SETRESUID 1 + +/* Define to 1 if you have the `setreuid' function. */ +#cmakedefine HAVE_SETREUID 1 + +/* Define to 1 if you have the `setsid' function. */ +#cmakedefine HAVE_SETSID 1 + +/* Define to 1 if you have the `setsockopt' function. [Python 3.11] */ +#cmakedefine HAVE_SETSOCKOPT 1 + +/* Define to 1 if you have the `setuid' function. */ +#cmakedefine HAVE_SETUID 1 + +/* Define to 1 if you have the `setvbuf' function. */ +#cmakedefine HAVE_SETVBUF 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_SHADOW_H 1 + +/* Define to 1 if you have the `shm_open' function. [Python 3.8] */ +#cmakedefine HAVE_SHM_OPEN 1 + +/* Define to 1 if you have the `shm_unlink' function. [Python 3.8] */ +#cmakedefine HAVE_SHM_UNLINK 1 + +/* Define to 1 if you have the `shutdown' function. [Python 3.11] */ +#cmakedefine HAVE_SHUTDOWN 1 + +/* Define to 1 if you have the `sigaction' function. */ +#cmakedefine HAVE_SIGACTION 1 + +/* Define to 1 if you have the `sigaltstack' function. [Python 3] */ +#cmakedefine HAVE_SIGALTSTACK 1 + +/* Define to 1 if you have the `sigfillset' function. [Python 3.8] */ +#cmakedefine HAVE_SIGFILLSET 1 + +/* Define to 1 if `si_band' is a member of `siginfo_t'. [Python 3.7] */ +#cmakedefine HAVE_SIGINFO_T_SI_BAND 1 + +/* Define to 1 if you have the `siginterrupt' function. */ +#cmakedefine HAVE_SIGINTERRUPT 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_SIGNAL_H 1 + +/* Define to 1 if you have the `sigpending' function. [Python 3] */ +#cmakedefine HAVE_SIGPENDING 1 + +/* Define to 1 if you have the `sigrelse' function. */ +#cmakedefine HAVE_SIGRELSE 1 + +/* Define to 1 if you have the `sigtimedwait' function. [Python 3] */ +#cmakedefine HAVE_SIGTIMEDWAIT 1 + +/* Define to 1 if you have the `sigwait' function. [Python 3] */ +#cmakedefine HAVE_SIGWAIT 1 + +/* Define to 1 if you have the `sigwaitinfo' function. [Python 3] */ +#cmakedefine HAVE_SIGWAITINFO 1 + +/* Define to 1 if you have the `snprintf' function. */ +#cmakedefine HAVE_SNPRINTF 1 + +/* struct sockaddr_alg (linux/if_alg.h) [Python 3.6] */ +#cmakedefine HAVE_SOCKADDR_ALG 1 + +/* Define if sockaddr has sa_len member */ +#cmakedefine HAVE_SOCKADDR_SA_LEN 1 + +/* struct sockaddr_storage (sys/socket.h) */ +#cmakedefine HAVE_SOCKADDR_STORAGE 1 + +/* Define if you have the 'socket' function. [Python 3.11] */ +#cmakedefine HAVE_SOCKET 1 + +/* Define if you have the 'socketpair' function. */ +#cmakedefine HAVE_SOCKETPAIR 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_SPAWN_H 1 + +/* Define to 1 if you have the `splice' function. [Python 3.10] */ +#cmakedefine HAVE_SPLICE 1 + +/* Define if your compiler provides ssize_t */ +#cmakedefine HAVE_SSIZE_T 1 + +/* Define to 1 if you have the `statvfs' function. */ +#cmakedefine HAVE_STATVFS 1 + +/* Define if you have struct stat.st_mtim.tv_nsec */ +#cmakedefine HAVE_STAT_TV_NSEC 1 + +/* Define if you have struct stat.st_mtimensec */ +#cmakedefine HAVE_STAT_TV_NSEC2 1 + +/* Define if your compiler supports variable length function prototypes (e.g. + void fprintf(FILE *, char *, ...);) *and* [Python <= 3.11] */ +#cmakedefine HAVE_STDARG_PROTOTYPES 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_STDINT_H 1 + +/* Define to 1 if you have the header file. [Python 3.12] */ +#cmakedefine HAVE_STDIO_H 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_STDLIB_H 1 + +/* Has stdatomic.h, atomic_int and _Atomic void* types work [Python 3] */ +#cmakedefine HAVE_STD_ATOMIC 1 + +/* Define to 1 if you have the `strdup' function. [Python <= 3.9] */ +#cmakedefine HAVE_STRDUP 1 + +/* Define to 1 if you have the `strftime' function. */ +#cmakedefine HAVE_STRFTIME 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_STRINGS_H 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_STRING_H 1 + +/* Define to 1 if you have the `strlcpy' function. [Python 3] */ +#cmakedefine HAVE_STRLCPY 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_STROPTS_H 1 + +/* Define to 1 if you have the `strsignal' function. [Python 3.8] */ +#cmakedefine HAVE_STRSIGNAL 1 + +/* Define to 1 if `pw_gecos' is a member of `struct passwd'. [Python 3.6] */ +#cmakedefine HAVE_STRUCT_PASSWD_PW_GECOS 1 + +/* Define to 1 if `pw_passwd' is a member of `struct passwd'. [Python 3.6] */ +#cmakedefine HAVE_STRUCT_PASSWD_PW_PASSWD 1 + +/* Define to 1 if `st_birthtime' is a member of `struct stat'. */ +#cmakedefine HAVE_STRUCT_STAT_ST_BIRTHTIME 1 + +/* Define to 1 if `st_blksize' is a member of `struct stat'. */ +#cmakedefine HAVE_STRUCT_STAT_ST_BLKSIZE 1 + +/* Define to 1 if `st_blocks' is a member of `struct stat'. */ +#cmakedefine HAVE_STRUCT_STAT_ST_BLOCKS 1 + +/* Define to 1 if `st_flags' is a member of `struct stat'. */ +#cmakedefine HAVE_STRUCT_STAT_ST_FLAGS 1 + +/* Define to 1 if `st_gen' is a member of `struct stat'. */ +#cmakedefine HAVE_STRUCT_STAT_ST_GEN 1 + +/* Define to 1 if `st_rdev' is a member of `struct stat'. */ +#cmakedefine HAVE_STRUCT_STAT_ST_RDEV 1 + +/* Define to 1 if `tm_zone' is a member of `struct tm'. */ +#cmakedefine HAVE_STRUCT_TM_TM_ZONE 1 + +/* Define to 1 if your `struct stat' has `st_blocks'. Deprecated, use + `HAVE_STRUCT_STAT_ST_BLOCKS' instead. [Python <= 3.5.1] */ +#cmakedefine HAVE_ST_BLOCKS 1 + +/* Define if you have the 'symlink' function. */ +#cmakedefine HAVE_SYMLINK 1 + +/* Define to 1 if you have the `symlinkat' function. [Python 3] */ +#cmakedefine HAVE_SYMLINKAT 1 + +/* Define to 1 if you have the `sync' function. [Python 3] */ +#cmakedefine HAVE_SYNC 1 + +/* Define to 1 if you have the `sysconf' function. */ +#cmakedefine HAVE_SYSCONF 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_SYSEXITS_H 1 + +/* Define to 1 if you have the header file. [Python 3.11] */ +#cmakedefine HAVE_SYSLOG_H 1 + +/* Define to 1 if you have the `system' function. [Python 3.11] */ +#cmakedefine HAVE_SYSTEM 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_SYS_AUDIOIO_H 1 + +/* Define to 1 if you have the header file. [Python 3.10] */ +#cmakedefine HAVE_SYS_AUXV_H 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_SYS_BSDTTY_H 1 + +/* Define to 1 if you have the header file. [Python 3] */ +#cmakedefine HAVE_SYS_DEVPOLL_H 1 + +/* Define to 1 if you have the header file, and it defines `DIR'. + */ +#cmakedefine HAVE_SYS_DIR_H 1 + +/* Define to 1 if you have the header file. [Python 3] */ +#cmakedefine HAVE_SYS_ENDIAN_H 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_SYS_EPOLL_H 1 + +/* Define to 1 if you have the header file. [Python 3.10] */ +#cmakedefine HAVE_SYS_EVENTFD_H 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_SYS_EVENT_H 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_SYS_FILE_H 1 + +/* Define to 1 if you have the header file. [Python 3] */ +#cmakedefine HAVE_SYS_IOCTL_H 1 + +/* Define to 1 if you have the header file. [Python 3] */ +#cmakedefine HAVE_SYS_KERN_CONTROL_H 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_SYS_LOADAVG_H 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_SYS_LOCK_H 1 + +/* Define to 1 if you have the header file. [Python 3.8] */ +#cmakedefine HAVE_SYS_MEMFD_H 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_SYS_MKDEV_H 1 + +/* Define to 1 if you have the header file. [Python 3.8] */ +#cmakedefine HAVE_SYS_MMAN_H 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_SYS_MODEM_H 1 + +/* Define to 1 if you have the header file, and it defines `DIR'. + */ +#cmakedefine HAVE_SYS_NDIR_H 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_SYS_PARAM_H 1 + +/* Define to 1 if you have the header file. [Python 3.12] */ +#cmakedefine HAVE_SYS_PIDFD_H 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_SYS_POLL_H 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_SYS_RANDOM_H 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_SYS_RESOURCE_H 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_SYS_SELECT_H 1 + +/* Define to 1 if you have the header file. [Python 3] */ +#cmakedefine HAVE_SYS_SENDFILE_H 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_SYS_SOCKET_H 1 + +/* Define to 1 if you have the header file. [Python 3.11] */ +#cmakedefine HAVE_SYS_SOUNDCARD_H 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_SYS_STATVFS_H 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_SYS_STAT_H 1 + +/* Define to 1 if you have the header file. [Python 3] */ +#cmakedefine HAVE_SYS_SYSCALL_H 1 + +/* Define to 1 if you have the header file. [Python 3] */ +#cmakedefine HAVE_SYS_SYS_DOMAIN_H 1 + +/* Define to 1 if you have the header file. [Python 3.6] */ +#cmakedefine HAVE_SYS_SYSMACROS_H 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_SYS_TERMIO_H 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_SYS_TIMES_H 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_SYS_TIME_H 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_SYS_TYPES_H 1 + +/* Define to 1 if you have the header file. [Python 3] */ +#cmakedefine HAVE_SYS_UIO_H 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_SYS_UN_H 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_SYS_UTSNAME_H 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_SYS_WAIT_H 1 + +/* Define to 1 if you have the header file. [Python 3] */ +#cmakedefine HAVE_SYS_XATTR_H 1 + +/* Define to 1 if you have the `tcgetpgrp' function. */ +#cmakedefine HAVE_TCGETPGRP 1 + +/* Define to 1 if you have the `tcsetpgrp' function. */ +#cmakedefine HAVE_TCSETPGRP 1 + +/* Define to 1 if you have the `tempnam' function. */ +#cmakedefine HAVE_TEMPNAM 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_TERMIOS_H 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_TERM_H 1 + +/* Define to 1 if you have the `tgamma' function. [Python <= 3.10] */ +#cmakedefine HAVE_TGAMMA 1 + +/* Define to 1 if you have the `timegm' function. */ +#cmakedefine HAVE_TIMEGM 1 + +/* Define to 1 if you have the `times' function. */ +#cmakedefine HAVE_TIMES 1 + +/* Define to 1 if you have the `tmpfile' function. */ +#cmakedefine HAVE_TMPFILE 1 + +/* Define to 1 if you have the `tmpnam' function. */ +#cmakedefine HAVE_TMPNAM 1 + +/* Define to 1 if you have the `tmpnam_r' function. */ +#cmakedefine HAVE_TMPNAM_R 1 + +/* Define to 1 if your `struct tm' has `tm_zone'. Deprecated, use + `HAVE_STRUCT_TM_TM_ZONE' instead. */ +#cmakedefine HAVE_TM_ZONE 1 + +/* Define to 1 if you have the `truncate' function. */ +#cmakedefine HAVE_TRUNCATE 1 + +/* Define to 1 if you have the `ttyname' function. [Python 3.11] */ +#cmakedefine HAVE_TTYNAME 1 + +/* Define to 1 if you have the `ttyname_r' function. [Python 3.12] */ +#cmakedefine HAVE_TTYNAME_R 1 + +/* Define to 1 if you don't have `tm_zone' but do have the external array + `tzname'. */ +#cmakedefine HAVE_TZNAME 1 + +/* Define this if you have tcl and TCL_UTF_MAX==6 [Python <= 3.10] */ +#cmakedefine HAVE_UCS4_TCL 1 + +/* Define if your compiler provides uint32_t. [Python <= 3.5] */ +#cmakedefine HAVE_UINT32_T 1 + +/* Define if your compiler provides uint64_t. [Python <= 3.5] */ +#cmakedefine HAVE_UINT64_T 1 + +/* Define to 1 if the system has the type `uintptr_t'. [Python <= 3.5] */ +#cmakedefine HAVE_UINTPTR_T 1 + +/* Define to 1 if you have the `umask' function. [Python 3.11] */ +#cmakedefine HAVE_UMASK 1 + +/* Define to 1 if you have the `uname' function. */ +#cmakedefine HAVE_UNAME 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_UNISTD_H 1 + +/* Define to 1 if you have the `unlinkat' function. [Python 3] */ +#cmakedefine HAVE_UNLINKAT 1 + +/* Define to 1 if you have the `unsetenv' function. [Python <= 3.8] */ +#cmakedefine HAVE_UNSETENV 1 + +/* Define to 1 if you have the `unshare' function. [Python 3.12] */ +#cmakedefine HAVE_UNSHARE 1 + +/* Define if you have a useable wchar_t type defined in wchar.h; useable means + wchar_t must be an unsigned type with at least 16 bits. (see + Include/unicodeobject.h). */ +#cmakedefine HAVE_USABLE_WCHAR_T 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_UTIL_H 1 + +/* Define to 1 if you have the `utimensat' function. [Python 3] */ +#cmakedefine HAVE_UTIMENSAT 1 + +/* Define to 1 if you have the `utimes' function. */ +#cmakedefine HAVE_UTIMES 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_UTIME_H 1 + +/* Define to 1 if you have the header file. [Python 3.11] */ +#cmakedefine HAVE_UTMP_H 1 + +/* Define if uuid_create() exists. [Python 3.7] */ +#cmakedefine HAVE_UUID_CREATE 1 + +/* Define if uuid_enc_be() exists. [Python 3.7] */ +#cmakedefine HAVE_UUID_ENC_BE 1 + +/* Define if uuid_generate_time_safe() exists. [Python 3.7] */ +#cmakedefine HAVE_UUID_GENERATE_TIME_SAFE 1 + +/* Define to 1 if you have the header file. [Python 3.7] */ +#cmakedefine HAVE_UUID_H 1 + +/* Define to 1 if you have the header file. [Python 3.7] */ +#cmakedefine HAVE_UUID_UUID_H 1 + +/* Define to 1 if you have the `vfork' function. [Python 3.10] */ +#cmakedefine HAVE_VFORK 1 + +/* Define to 1 if you have the `wait' function. [Python 3.11] */ +#cmakedefine HAVE_WAIT 1 + +/* Define to 1 if you have the `wait3' function. */ +#cmakedefine HAVE_WAIT3 1 + +/* Define to 1 if you have the `wait4' function. */ +#cmakedefine HAVE_WAIT4 1 + +/* Define to 1 if you have the `waitid' function. [Python 3] */ +#cmakedefine HAVE_WAITID 1 + +/* Define to 1 if you have the `waitpid' function. */ +#cmakedefine HAVE_WAITPID 1 + +/* Define if the compiler provides a wchar.h header file. */ +#cmakedefine HAVE_WCHAR_H 1 + +/* Define to 1 if you have the `wcscoll' function. */ +#cmakedefine HAVE_WCSCOLL 1 + +/* Define to 1 if you have the `wcsftime' function. [Python 3] */ +#cmakedefine HAVE_WCSFTIME 1 + +/* Define to 1 if you have the `wcsxfrm' function. [Python 3] */ +#cmakedefine HAVE_WCSXFRM 1 + +/* Define to 1 if you have the `wmemcmp' function. [Python 3] */ +#cmakedefine HAVE_WMEMCMP 1 + +/* Define if tzset() actually switches the local timezone in a meaningful way. + */ +#cmakedefine HAVE_WORKING_TZSET 1 + +/* Define to 1 if you have the `writev' function. [Python 3] */ +#cmakedefine HAVE_WRITEV 1 + +/* Define if libssl has X509_VERIFY_PARAM_set1_host and related function [Python >= 3.7, <= 3.9] */ +#cmakedefine HAVE_X509_VERIFY_PARAM_SET1_HOST 1 + +/* Define if the zlib library has inflateCopy */ +#cmakedefine HAVE_ZLIB_COPY 1 + +/* Define to 1 if you have the header file. [Python 3.11] */ +#cmakedefine HAVE_ZLIB_H 1 + +/* Define to 1 if you have the `_getpty' function. */ +#cmakedefine HAVE__GETPTY 1 + +/* Define if log1p(-0.) is 0. rather than -0. [Python 3] */ +#cmakedefine LOG1P_DROPS_ZERO_SIGN 1 + +/* Define to 1 if `major', `minor', and `makedev' are declared in . + */ +#cmakedefine MAJOR_IN_MKDEV 1 + +/* Define to 1 if `major', `minor', and `makedev' are declared in + . */ +#cmakedefine MAJOR_IN_SYSMACROS 1 + +/* Define if mvwdelch in curses.h is an expression. */ +#cmakedefine MVWDELCH_IS_EXPRESSION 1 + +/* Define to the address where bug reports for this package should be sent. */ +#cmakedefine PACKAGE_BUGREPORT + +/* Define to the full name of this package. */ +#cmakedefine PACKAGE_NAME @PACKAGE_NAME@ + +/* Define to the full name and version of this package. */ +#cmakedefine PACKAGE_STRING @PACKAGE_STRING@ + +/* Define to the one symbol short name of this package. */ +#cmakedefine PACKAGE_TARNAME @PACKAGE_TARNAME@ + +/* Define to the home page for this package. */ +/* #undef PACKAGE_URL */ + +/* Define to the version of this package. */ +#cmakedefine PACKAGE_VERSION @PACKAGE_VERSION@ + +/* Define if POSIX semaphores aren't enabled on your system */ +#cmakedefine POSIX_SEMAPHORES_NOT_ENABLED 1 + +/* Define if pthread_key_t is compatible with int. [Python 3.7] */ +#cmakedefine PTHREAD_KEY_T_IS_COMPATIBLE_WITH_INT 1 + +/* Defined if PTHREAD_SCOPE_SYSTEM supported. */ +#cmakedefine PTHREAD_SYSTEM_SCHED_SUPPORTED 1 + +/* Define as the preferred size in bits of long digits */ +/* #undef PYLONG_BITS_IN_DIGIT */ + +/* Define to printf format modifier for long long type */ +#cmakedefine PY_FORMAT_LONG_LONG "@PY_FORMAT_LONG_LONG@" + +/* Define if you want to coerce the C locale to a UTF-8 based locale */ +#cmakedefine PY_COERCE_C_LOCALE 1 + +/* Define to printf format modifier for Py_ssize_t */ +#cmakedefine PY_FORMAT_SIZE_T "@PY_FORMAT_SIZE_T@" + +/* Default cipher suites list for ssl module. 1: Python's preferred selection, + 2: leave OpenSSL defaults untouched, 0: custom string [Python 3.7] */ +#cmakedefine PY_SSL_DEFAULT_CIPHERS @PY_SSL_DEFAULT_CIPHERS@ + +/* Cipher suite string for PY_SSL_DEFAULT_CIPHERS=0 [Python 3.7] */ +#cmakedefine PY_SSL_DEFAULT_CIPHER_STRING "@PY_SSL_DEFAULT_CIPHER_STRING@" + +/* Define as the integral type used for Unicode representation. [Python 2.7 to 3.2] */ +#cmakedefine PY_UNICODE_TYPE @PY_UNICODE_TYPE@ + +/* Define if you want to build an interpreter with many run-time checks. */ +#cmakedefine Py_DEBUG 1 + +/* Defined if Python is built as a shared library. */ +#cmakedefine Py_ENABLE_SHARED + +/* Define as the size of the unicode type. [Python 2.7 to 3.2] */ +#cmakedefine Py_UNICODE_SIZE @Py_UNICODE_SIZE@ + +/* Define hash algorithm for str, bytes and memoryview. SipHash24: 1, FNV: 2, + externally defined: 0 [Python 3] */ +#cmakedefine Py_HASH_ALGORITHM 1 + +/* Define if you want to enable tracing references for debugging purpose [Python 3.8] */ +#cmakedefine Py_TRACE_REFS 1 + +/* assume C89 semantics that RETSIGTYPE is always void */ +#cmakedefine RETSIGTYPE @RETSIGTYPE@ + +/* Define if setpgrp() must be called as setpgrp(0, 0). */ +#cmakedefine SETPGRP_HAVE_ARG 1 + +/* Define this to be extension of shared libraries (including the dot!).[Python 2.7] */ +#define SHLIB_EXT "@CMAKE_SHARED_MODULE_SUFFIX@" + +/* Define to 1 if you must link with -lrt for shm_open(). [Python 3.8] */ +#cmakedefine SHM_NEEDS_LIBRT 1 + +/* Define if i>>j for signed int i does not extend the sign bit when i < 0 */ +#cmakedefine SIGNED_RIGHT_SHIFT_ZERO_FILLS 1 + +/* The size of `double', as computed by sizeof. */ +#cmakedefine SIZEOF_DOUBLE @SIZEOF_DOUBLE@ + +/* The size of `float', as computed by sizeof. */ +#cmakedefine SIZEOF_FLOAT @SIZEOF_FLOAT@ + +/* The size of `fpos_t', as computed by sizeof. */ +#cmakedefine SIZEOF_FPOS_T @SIZEOF_FPOS_T@ + +/* The size of `int', as computed by sizeof. */ +#cmakedefine SIZEOF_INT @SIZEOF_INT@ + +/* The size of `long', as computed by sizeof. */ +#cmakedefine SIZEOF_LONG @SIZEOF_LONG@ + +/* The size of `long double', as computed by sizeof. */ +#cmakedefine SIZEOF_LONG_DOUBLE @SIZEOF_LONG_DOUBLE@ + +/* The size of `long long', as computed by sizeof. */ +#cmakedefine SIZEOF_LONG_LONG @SIZEOF_LONG_LONG@ + +/* The size of `off_t', as computed by sizeof. */ +#cmakedefine SIZEOF_OFF_T @SIZEOF_OFF_T@ + +/* The size of `pid_t', as computed by sizeof. */ +#cmakedefine SIZEOF_PID_T @SIZEOF_PID_T@ + +/* The size of `pthread_key_t', as computed by sizeof. [Python 3.7] */ +#cmakedefine SIZEOF_PTHREAD_KEY_T @SIZEOF_PTHREAD_KEY_T@ + +/* The size of `pthread_t', as computed by sizeof. */ +#cmakedefine SIZEOF_PTHREAD_T @SIZEOF_PTHREAD_T@ + +/* The size of `short', as computed by sizeof. */ +#cmakedefine SIZEOF_SHORT @SIZEOF_SHORT@ + +/* The size of `size_t', as computed by sizeof. */ +#cmakedefine SIZEOF_SIZE_T @SIZEOF_SIZE_T@ + +/* The size of `time_t', as computed by sizeof. */ +#cmakedefine SIZEOF_TIME_T @SIZEOF_TIME_T@ + +/* The size of `uintptr_t', as computed by sizeof. */ +#cmakedefine SIZEOF_UINTPTR_T @SIZEOF_UINTPTR_T@ + +/* The size of `void *', as computed by sizeof. */ +#cmakedefine SIZEOF_VOID_P @SIZEOF_VOID_P@ + +/* The size of `wchar_t', as computed by sizeof. */ +#cmakedefine SIZEOF_WCHAR_T @SIZEOF_WCHAR_T@ + +/* The size of `_Bool', as computed by sizeof. */ +#cmakedefine SIZEOF__BOOL @SIZEOF__BOOL@ + +/* Define to 1 if you have the ANSI C header files. */ +#cmakedefine STDC_HEADERS 1 + +/* Define if you can safely include both and + (which you can't on SCO ODT 3.0). */ +#cmakedefine SYS_SELECT_WITH_SYS_TIME 1 + +/* Define if tanh(-0.) is -0., or if platform doesn't have signed zeros [Python <= 3.6] */ +#cmakedefine TANH_PRESERVES_ZERO_SIGN 1 + +/* Library needed by timemodule.c: librt may be needed for clock_gettime() */ +#cmakedefine TIMEMODULE_LIB 1 + +/* Define to 1 if you can safely include both and . [Python <= 3.11] */ +#cmakedefine TIME_WITH_SYS_TIME 1 + +/* Define to 1 if your declares `struct tm'. */ +#cmakedefine TM_IN_SYS_TIME 1 + +/* Define if you want to use computed gotos in ceval.c. */ +/* #undef USE_COMPUTED_GOTOS */ + +/* Define to use the C99 inline keyword. [Python 3] */ +#cmakedefine USE_INLINE 1 + +/* Enable extensions on AIX 3, Interix. */ +#ifndef _ALL_SOURCE +#cmakedefine _ALL_SOURCE 1 +#endif +/* Enable GNU extensions on systems that have them. */ +#ifndef _GNU_SOURCE +#cmakedefine _GNU_SOURCE 1 +#endif +/* Enable POSIX-compatible threading on Solaris. */ +#ifndef _POSIX_PTHREAD_SEMANTICS +#cmakedefine _POSIX_PTHREAD_SEMANTICS 1 +#endif +/* Enable extensions on HP NonStop. */ +#ifndef _TANDEM_SOURCE +#cmakedefine _TANDEM_SOURCE 1 +#endif +/* Enable general extensions on Solaris. */ +#ifndef __EXTENSIONS__ +#cmakedefine __EXTENSIONS__ 1 +#endif + +/* Define if a va_list is an array of some kind */ +#cmakedefine VA_LIST_IS_ARRAY 1 + +/* Define if you want SIGFPE handled (see Include/pyfpe.h). */ +#cmakedefine WANT_SIGFPE_HANDLER + +/* Define if you want wctype.h functions to be used instead of the one + supplied by Python itself. (see Include/unicodectype.h). [Python 2.7] */ +#cmakedefine WANT_WCTYPE_FUNCTIONS + +/* Define if WINDOW in curses.h offers a field _flags. */ +#cmakedefine WINDOW_HAS_FLAGS 1 + +/* Define if you want build the _decimal module using a coroutine-local rather + than a thread-local context [Python 3.8] */ +#cmakedefine WITH_DECIMAL_CONTEXTVAR 1 + +/* Define if you want documentation strings in extension modules */ +#cmakedefine WITH_DOC_STRINGS 1 + +/* Define if you want to compile in DTrace support [Python 3.6] */ +#cmakedefine WITH_DTRACE 1 + +/* Define if you want to use the new-style (Openstep, Rhapsody, MacOS) dynamic + linker (dyld) instead of the old-style (NextStep) dynamic linker (rld). + Dyld is necessary to support frameworks. */ +#cmakedefine WITH_DYLD 1 + +/* Define to build the readline module against Editline. [Python 3.10] */ +#cmakedefine WITH_EDITLINE 1 + +/* Define if you want to compile in object freelists optimization [Python 3.11] */ +#cmakedefine WITH_FREELISTS 1 + +/* Define to 1 if libintl is needed for locale functions. */ +#cmakedefine WITH_LIBINTL 1 + +/* Define if you want to produce an OpenStep/Rhapsody framework (shared + library plus accessory files). */ +#cmakedefine WITH_NEXT_FRAMEWORK 1 + +/* Define if you want to compile in Python-specific mallocs */ +#cmakedefine WITH_PYMALLOC 1 + +/* Define if you want pymalloc to be disabled when running under valgrind [Python 3.10] */ +#cmakedefine WITH_VALGRIND 1 + +/* Define if you want to compile in rudimentary thread support */ +#cmakedefine WITH_THREAD 1 + +/* Define to profile with the Pentium timestamp counter */ +#cmakedefine WITH_TSC 1 + +/* Define if you want pymalloc to be disabled when running under valgrind */ +/* #undef WITH_VALGRIND */ + +/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most + significant byte first (like Motorola and SPARC, unlike Intel). */ +#if defined AC_APPLE_UNIVERSAL_BUILD +# if defined __BIG_ENDIAN__ +# define WORDS_BIGENDIAN 1 +# endif +#else +# ifndef WORDS_BIGENDIAN +#cmakedefine WORDS_BIGENDIAN +# endif +#endif + +/* Define if arithmetic is subject to x87-style double rounding issue */ +#cmakedefine X87_DOUBLE_ROUNDING 1 + +/* Define on OpenBSD to activate all library features */ +#cmakedefine _BSD_SOURCE 1 + +/* Define on Irix to enable u_int */ +#cmakedefine _BSD_TYPES 1 + +/* Define on Darwin to activate all library features */ +#cmakedefine _DARWIN_C_SOURCE 1 + +/* This must be set to 64 on some systems to enable large file support. */ +#cmakedefine _FILE_OFFSET_BITS @_FILE_OFFSET_BITS@ + +/* Define on Linux to activate all library features */ +#cmakedefine _GNU_SOURCE 1 + +/* Define to include mbstate_t for mbrtowc */ +#cmakedefine _INCLUDE__STDC_A1_SOURCE 1 + +/* This must be defined on some systems to enable large file support. */ +#ifndef _LARGEFILE_SOURCE +#cmakedefine _LARGEFILE_SOURCE @_LARGEFILE_SOURCE@ +#endif + +/* This must be defined on AIX systems to enable large file support. */ +#cmakedefine _LARGE_FILES + +/* Define to 1 if on MINIX. */ +#cmakedefine _MINIX + +/* Define on NetBSD to activate all library features */ +#cmakedefine _NETBSD_SOURCE 1 + +/* Define _OSF_SOURCE to get the makedev macro. [Python 2.7] */ +#cmakedefine _OSF_SOURCE + +/* Define to 2 if the system does not provide POSIX.1 features except with + this defined. */ +#cmakedefine _POSIX_1_SOURCE + +/* Define to activate features from IEEE Stds [Python 2.7: IEEE Stds 1003.1-2001] or [Python 3.x: IEEE Stds 1003.1-2008]*/ +#cmakedefine _POSIX_C_SOURCE @_POSIX_C_SOURCE@ + +/* Define to 1 if you need to in order for `stat' and other things to work. */ +#cmakedefine _POSIX_SOURCE + +/* Define if you have POSIX threads, and your system does not define that. */ +#cmakedefine _POSIX_THREADS + +/* framework name [Python 3.7] */ +#define _PYTHONFRAMEWORK "@PYTHONFRAMEWORK@" + +/* Define to force use of thread-safe errno, h_errno, and other functions */ +#cmakedefine _REENTRANT 1 + +/* Define for Solaris 2.5.1 so the uint32_t typedef from , + , or is not used. If the typedef were allowed, the + #define below would cause a syntax error. */ +/* #undef _UINT32_T */ + +/* Define for Solaris 2.5.1 so the uint64_t typedef from , + , or is not used. If the typedef were allowed, the + #define below would cause a syntax error. */ +/* #undef _UINT64_T */ + +/* Define to 1 if you want to emulate getpid() on WASI [Python 3.11] */ +/* #undef _WASI_EMULATED_GETPID */ + +/* Define to 1 if you want to emulate process clocks on WASI [Python 3.11] */ +/* #undef _WASI_EMULATED_PROCESS_CLOCKS */ + +/* Define to 1 if you want to emulate signals on WASI [Python 3.11] */ +/* #undef _WASI_EMULATED_SIGNAL */ + +/* Define to the level of X/Open that your system supports */ +#cmakedefine _XOPEN_SOURCE @_XOPEN_SOURCE@ + +/* Define to activate Unix95-and-earlier features */ +#cmakedefine _XOPEN_SOURCE_EXTENDED 1 + +/* Define on FreeBSD to activate all library features */ +#cmakedefine __BSD_VISIBLE 1 + +/* Define to 1 if type `char' is unsigned and you are not using gcc. */ +#ifndef __CHAR_UNSIGNED__ +#cmakedefine __CHAR_UNSIGNED__ +#endif + +/* Define to 'long' if doesn't define. */ +#cmakedefine clock_t @clock_t@ + +/* Define to empty if `const' does not conform to ANSI C. */ +#cmakedefine const + +/* Define to `int' if doesn't define. */ +#cmakedefine gid_t @gid_t@ + +/* Define to `__inline__' or `__inline' if that's what the C compiler + calls it, or to nothing if 'inline' is not supported under any name. */ +#ifndef __cplusplus +/* #undef inline */ +#endif + +/* Define to the type of a signed integer type of width exactly 32 bits if + such a type exists and the standard includes do not define it. */ +/* #undef int32_t */ + +/* Define to the type of a signed integer type of width exactly 64 bits if + such a type exists and the standard includes do not define it. */ +/* #undef int64_t */ + +/* Define to `int' if does not define. */ +#cmakedefine mode_t @mode_t@ + +/* Define to `long int' if does not define. */ +#cmakedefine off_t @off_t@ + +/* Define as a signed integer type capable of holding a process identifier. */ +#cmakedefine pid_t @pid_t@ + +/* Define to empty if the keyword does not work. */ +#cmakedefine signed + +/* Define to `unsigned int' if does not define. */ +#cmakedefine size_t @size_t@ + +/* Define to `int' if does not define. */ +#cmakedefine socklen_t @socklen_t@ + +/* Define to `int' if doesn't define. */ +#cmakedefine uid_t @uid_t@ + +/* Define to the type of an unsigned integer type of width exactly 32 bits if + such a type exists and the standard includes do not define it. */ +/* #undef uint32_t */ + +/* Define to the type of an unsigned integer type of width exactly 64 bits if + such a type exists and the standard includes do not define it. */ +/* #undef uint64_t */ + +/* Define to empty if the keyword does not work. */ +#cmakedefine volatile + + +/* Define the macros needed if on a UnixWare 7.x system. */ +#if defined(__USLC__) && defined(__SCO_VERSION__) +#define STRICT_SYSV_CURSES /* Don't use ncurses extensions */ +#endif + +#define PLATLIBDIR "lib" + +#cmakedefine DYNAMIC_ANNOTATIONS_ENABLED 1 + +#endif /*Py_PYCONFIG_H*/ + diff --git a/third/python-cmake/cmake/config_3.c.in b/third/python-cmake/cmake/config_3.c.in new file mode 100644 index 00000000..f8241351 --- /dev/null +++ b/third/python-cmake/cmake/config_3.c.in @@ -0,0 +1,58 @@ +#include "Python.h" + +#ifdef __cplusplus +extern "C" { +#endif + + +@config_inits@ + +/* -- ADDMODULE MARKER 1 -- */ + +extern PyObject* PyMarshal_Init(void); +extern PyObject* @PyInit_imp@(void); +extern PyObject* PyInit_gc(void); +extern PyObject* PyInit__ast(void); +extern PyObject* _PyWarnings_Init(void); +extern PyObject* PyInit__string(void); + +extern PyObject* PyInit__signal(void); + +struct _inittab _PyImport_Inittab[] = { + +@config_entries@ + +/* -- ADDMODULE MARKER 2 -- */ + + /* This module lives in marshal.c */ + {"marshal", PyMarshal_Init}, + + /* This lives in import.c */ + {"_imp", @PyInit_imp@}, + + /* This lives in Python/Python-ast.c */ + {"_ast", PyInit__ast}, + + /* These entries are here for sys.builtin_module_names */ + {"builtins", NULL}, + {"sys", NULL}, + + /* This lives in gcmodule.c */ + {"gc", PyInit_gc}, + + /* This lives in _warnings.c */ + {"_warnings", _PyWarnings_Init}, + + /* This lives in Objects/unicodeobject.c */ + {"_string", PyInit__string}, + + {"_signal", PyInit__signal}, + + /* Sentinel */ + {0, 0} +}; + + +#ifdef __cplusplus +} +#endif diff --git a/third/python-cmake/cmake/empty.c b/third/python-cmake/cmake/empty.c new file mode 100644 index 00000000..e69de29b diff --git a/third/python-cmake/cmake/extensions/CMakeLists.txt b/third/python-cmake/cmake/extensions/CMakeLists.txt new file mode 100644 index 00000000..10750ccc --- /dev/null +++ b/third/python-cmake/cmake/extensions/CMakeLists.txt @@ -0,0 +1,1204 @@ +set(WIN32_BUILTIN ) +if(WIN32) + set(WIN32_BUILTIN BUILTIN) +endif() + +# Boolean variables intended to be associated with the REQUIRES argument of add_python_extension +set(IS_PY_LESS_3_8 0) +if(PY_VERSION VERSION_LESS "3.8") + set(IS_PY_LESS_3_8 1) +endif() +set(IS_PY_LESS_3_10 0) +if(PY_VERSION VERSION_LESS "3.10") + set(IS_PY_LESS_3_10 1) +endif() +set(IS_PY_LESS_3_12 0) +if(PY_VERSION VERSION_LESS "3.12") + set(IS_PY_LESS_3_12 1) +endif() + +set(IS_PY3_3_OR_GREATER 0) +if(PY_VERSION VERSION_GREATER_EQUAL "3.3") + set(IS_PY3_3_OR_GREATER 1) +endif() +set(IS_PY3_4_OR_GREATER 0) +if(PY_VERSION VERSION_GREATER_EQUAL "3.4") + set(IS_PY3_4_OR_GREATER 1) +endif() +set(IS_PY3_5_OR_GREATER 0) +if(PY_VERSION VERSION_GREATER_EQUAL "3.5") + set(IS_PY3_5_OR_GREATER 1) +endif() +set(IS_PY3_6_OR_GREATER 0) +if(PY_VERSION VERSION_GREATER_EQUAL "3.6") + set(IS_PY3_6_OR_GREATER 1) +endif() +set(IS_PY3_7_OR_GREATER 0) +if(PY_VERSION VERSION_GREATER_EQUAL "3.7") + set(IS_PY3_7_OR_GREATER 1) +endif() +set(IS_PY3_8_OR_GREATER 0) +if(PY_VERSION VERSION_GREATER_EQUAL "3.8") + set(IS_PY3_8_OR_GREATER 1) +endif() +set(IS_PY3_9_OR_GREATER 0) +if(PY_VERSION VERSION_GREATER_EQUAL "3.9") + set(IS_PY3_9_OR_GREATER 1) +endif() +set(IS_PY3_12_OR_GREATER 0) +if(PY_VERSION VERSION_GREATER_EQUAL "3.12") + set(IS_PY3_12_OR_GREATER 1) +endif() + +add_python_extension(array ${WIN32_BUILTIN} SOURCES arraymodule.c) +add_python_extension(audioop ${WIN32_BUILTIN} + REQUIRES + HAVE_LIBM + SOURCES + audioop.c + LIBRARIES + ${M_LIBRARIES} +) +add_python_extension(_bisect ${WIN32_BUILTIN} SOURCES _bisectmodule.c) +add_python_extension(cmath + REQUIRES HAVE_LIBM ${WIN32_BUILTIN} + SOURCES + $<$:_math.c> + cmathmodule.c + LIBRARIES + ${M_LIBRARIES}) +add_python_extension(_codecs_cn ${WIN32_BUILTIN} SOURCES cjkcodecs/_codecs_cn.c) +add_python_extension(_codecs_hk ${WIN32_BUILTIN} SOURCES cjkcodecs/_codecs_hk.c) +add_python_extension(_codecs_iso2022 ${WIN32_BUILTIN} SOURCES cjkcodecs/_codecs_iso2022.c) +add_python_extension(_codecs_jp ${WIN32_BUILTIN} SOURCES cjkcodecs/_codecs_jp.c) +add_python_extension(_codecs_kr ${WIN32_BUILTIN} SOURCES cjkcodecs/_codecs_kr.c) +add_python_extension(_codecs_tw ${WIN32_BUILTIN} SOURCES cjkcodecs/_codecs_tw.c) +add_python_extension(_collections ${WIN32_BUILTIN} BUILTIN SOURCES _collectionsmodule.c) # Container types + +set(crypt_NAME _crypt) +if(PY_VERSION VERSION_LESS 3.3) + set(crypt_NAME crypt) +endif() +add_python_extension(${crypt_NAME} + REQUIRES + HAVE_LIBCRYPT + SOURCES + ${crypt_NAME}module.c + LIBRARIES + ${HAVE_LIBCRYPT} +) + +add_python_extension(_csv ${WIN32_BUILTIN} SOURCES _csv.c) +add_python_extension(_ctypes_test NEVER_BUILTIN REQUIRES HAVE_LIBM SOURCES _ctypes/_ctypes_test.c LIBRARIES ${M_LIBRARIES}) + +add_python_extension(_datetime ${WIN32_BUILTIN} + REQUIRES + HAVE_LIBM + SOURCES + _datetimemodule.c + $<$:timemodule.c> + $<$:_time.c> + LIBRARIES + ${M_LIBRARIES} +) +#if(ENABLE_DATETIME AND CMAKE_C_COMPILER_ID MATCHES GNU) +# set_property(SOURCE ${SRC_DIR}/Modules/datetimemodule.c PROPERTY COMPILE_FLAGS -Wno-unused-value) +#endif() + +add_python_extension(_functools ${WIN32_BUILTIN} BUILTIN SOURCES _functoolsmodule.c DEFINITIONS Py_BUILD_CORE) # Tools for working with functions and callable objects +add_python_extension(_heapq ${WIN32_BUILTIN} SOURCES _heapqmodule.c) + +set(_io_SOURCES + _io/_iomodule.c + _io/bufferedio.c + _io/bytesio.c + _io/fileio.c + _io/iobase.c + _io/stringio.c + _io/textio.c + ) +if(WIN32 AND EXISTS ${SRC_DIR}/Modules/_io/winconsoleio.c) + list(APPEND _io_SOURCES + ${SRC_DIR}/Modules/_io/winconsoleio.c + ) +endif() +add_python_extension(_io ${WIN32_BUILTIN} ALWAYS_BUILTIN SOURCES ${_io_SOURCES} DEFINITIONS Py_BUILD_CORE) + +add_python_extension(itertools ${WIN32_BUILTIN} BUILTIN SOURCES itertoolsmodule.c) # Functions creating iterators for efficient looping +add_python_extension(_json ${WIN32_BUILTIN} SOURCES _json.c) +add_python_extension(_locale ${WIN32_BUILTIN} BUILTIN SOURCES _localemodule.c) # access to ISO C locale support +add_python_extension(_lsprof ${WIN32_BUILTIN} SOURCES _lsprof.c rotatingtree.c) +add_python_extension(math ${WIN32_BUILTIN} + REQUIRES + HAVE_LIBM + SOURCES + $<$:_math.c> + mathmodule.c + LIBRARIES + ${M_LIBRARIES} +) +add_python_extension(mmap ${WIN32_BUILTIN} SOURCES mmapmodule.c) +add_python_extension(_multibytecodec ${WIN32_BUILTIN} SOURCES cjkcodecs/multibytecodec.c) +add_python_extension(parser ${WIN32_BUILTIN} + REQUIRES + IS_PY_LESS_3_10 + SOURCES + parsermodule.c +) +add_python_extension(_random ${WIN32_BUILTIN} SOURCES _randommodule.c) +add_python_extension(_struct ${WIN32_BUILTIN} SOURCES _struct.c) + +add_python_extension(_testcapi NEVER_BUILTIN + SOURCES + _testcapimodule.c + + # Introduced in Python 3.12 + $<$:_testcapi/abstract.c> + $<$:_testcapi/buffer.c> + $<$:_testcapi/bytes.c> + $<$:_testcapi/code.c> + $<$:_testcapi/codec.c> + $<$:_testcapi/complex.c> + $<$:_testcapi/datetime.c> + $<$:_testcapi/dict.c> + $<$:_testcapi/docstring.c> + $<$:_testcapi/exceptions.c> + $<$:_testcapi/file.c> + $<$:_testcapi/float.c> + $<$:_testcapi/gc.c> + $<$:_testcapi/getargs.c> + $<$:_testcapi/heaptype.c> + $<$:_testcapi/immortal.c> + $<$:_testcapi/list.c> + $<$:_testcapi/long.c> + $<$:_testcapi/mem.c> + $<$:_testcapi/numbers.c> + $<$:_testcapi/run.c> + $<$:_testcapi/set.c> + $<$:_testcapi/structmember.c> + $<$:_testcapi/tuple.c> + $<$:_testcapi/unicode.c> + $<$:_testcapi/vectorcall.c> + $<$:_testcapi/watchers.c> + + # Introduced in Python 3.12 and removed in 3.13 + $<$:_testcapi/bytearray.c> + $<$:_testcapi/eval.c> + $<$:_testcapi/heaptype_relative.c> + $<$:_testcapi/import.c> + $<$:_testcapi/pyos.c> + $<$:_testcapi/pytime.c> + $<$:_testcapi/sys.c> + $<$:_testcapi/vectorcall_limited.c> +) + +set(thread_REQUIRES) +if(PY_VERSION VERSION_LESS "3.7") + list(APPEND thread_REQUIRES WITH_THREAD) +endif() +add_python_extension(_thread ALWAYS_BUILTIN + REQUIRES + ${thread_REQUIRES} + SOURCES + ${SRC_DIR}/Modules/_threadmodule.c + DEFINITIONS + Py_BUILD_CORE +) + +add_python_extension(time ${WIN32_BUILTIN} BUILTIN + REQUIRES + HAVE_LIBM + SOURCES + timemodule.c + $<$:_time.c> + DEFINITIONS + Py_BUILD_CORE + LIBRARIES + ${M_LIBRARIES} + ${TIMEMODULE_LIB} +) + +add_python_extension(unicodedata SOURCES unicodedata.c) + +# Register functions to be run at interpreter-shutdown +add_python_extension(atexit BUILTIN + REQUIRES + SOURCES + atexitmodule.c +) +add_python_extension(_codecs BUILTIN SOURCES _codecsmodule.c) # access to the builtin codecs and codec registry +set(operator_NAME _operator) +if(PY_VERSION VERSION_LESS 3.4) + set(operator_NAME operator) +endif() +add_python_extension(${operator_NAME} BUILTIN REQUIRES SOURCES ${operator_NAME}.c) +add_python_extension(faulthandler ALWAYS_BUILTIN + REQUIRES IS_PY3_3_OR_GREATER + SOURCES faulthandler.c +) +add_python_extension(_opcode ${WIN32_BUILTIN} + REQUIRES IS_PY3_4_OR_GREATER + SOURCES _opcode.c +) + +add_python_extension(_pickle ${WIN32_BUILTIN} REQUIRES SOURCES _pickle.c) + +# Fredrik Lundh's new regular expressions +add_python_extension(_sre BUILTIN + SOURCES + $<$:_sre.c> + $<$:_sre/sre.c> +) + +# stat.h interface +add_python_extension(_stat BUILTIN + REQUIRES IS_PY3_4_OR_GREATER + SOURCES _stat.c +) + +add_python_extension(_symtable BUILTIN SOURCES symtablemodule.c) + +# Python PEP-3118 (buffer protocol) test module +add_python_extension(_testbuffer + REQUIRES IS_PY3_3_OR_GREATER + SOURCES _testbuffer.c +) + +# Test loading multiple modules from one compiled file (http://bugs.python.org/issue16421) +add_python_extension(_testimportmultiple + REQUIRES IS_PY3_4_OR_GREATER + SOURCES _testimportmultiple.c +) +# Test multi-phase extension module init (PEP 489) +add_python_extension(_testmultiphase + REQUIRES IS_PY3_5_OR_GREATER + SOURCES _testmultiphase.c +) +# debug tool to trace memory blocks allocated by Python +add_python_extension(_tracemalloc ALWAYS_BUILTIN + REQUIRES IS_PY3_4_OR_GREATER + SOURCES + ${SRC_DIR}/$,Python,Modules>/hashtable.c + _tracemalloc.c +) +add_python_extension(_weakref ALWAYS_BUILTIN SOURCES _weakref.c) +math(EXPR _limited_api_version "${PY_VERSION_MAJOR} * 100 + ${PY_VERSION_MINOR}") +add_python_extension(xxlimited REQUIRES BUILD_TESTING + SOURCES xxlimited.c + DEFINITIONS $<$:Py_LIMITED_API=0x${_limited_api_version}0000> + NO_INSTALL +) +add_python_extension(xxsubtype BUILTIN SOURCES xxsubtype.c) + +# The zipimport module is always imported at startup. Having it as a +# builtin module avoids some bootstrapping problems and reduces overhead. +add_python_extension(zipimport ALWAYS_BUILTIN + REQUIRES + IS_PY_LESS_3_8 + SOURCES + zipimport.c + DEFINITIONS + Py_BUILD_CORE +) + +# Python 3.6 +# asyncio speedups +add_python_extension(_asyncio + REQUIRES + IS_PY3_6_OR_GREATER + SOURCES + _asynciomodule.c +) +# blake module +set(_blake2_SOURCES + _blake2/blake2module.c + _blake2/blake2b_impl.c + _blake2/blake2s_impl.c +) +add_python_extension(_blake2 ${WIN32_BUILTIN} + REQUIRES + IS_PY3_6_OR_GREATER + SOURCES + ${_blake2_SOURCES} +) +add_python_extension(_sha3 ${WIN32_BUILTIN} + REQUIRES + IS_PY3_6_OR_GREATER + IS_PY_LESS_3_12 + SOURCES + _sha3/sha3module.c +) +add_python_extension(_testconsole ${WIN32_BUILTIN} + REQUIRES + IS_PY3_6_OR_GREATER + WIN32 + SOURCES + ../PC/_testconsole.c +) + +# Python 3.7 +add_python_extension(_abc BUILTIN + REQUIRES + IS_PY3_7_OR_GREATER + SOURCES + _abc.c +) +add_python_extension(_contextvars ${WIN32_BUILTIN} + REQUIRES + IS_PY3_7_OR_GREATER + SOURCES + _contextvarsmodule.c +) +add_python_extension(_queue + REQUIRES + IS_PY3_7_OR_GREATER + SOURCES + _queuemodule.c +) +add_python_extension(_uuid + REQUIRES + IS_PY3_7_OR_GREATER + UUID_LIBRARY + "HAVE_UUID_H OR HAVE_UUID_UUID_H" + SOURCES + _uuidmodule.c + LIBRARIES + ${UUID_LIBRARY} +) +add_python_extension(_xxtestfuzz + REQUIRES + IS_PY3_7_OR_GREATER + SOURCES + _xxtestfuzz/_xxtestfuzz.c + _xxtestfuzz/fuzzer.c +) + +# Python 3.8 +set(_wide_char_modifier "L") +add_python_extension(_testinternalcapi + REQUIRES + IS_PY3_8_OR_GREATER + SOURCES + _testinternalcapi.c + DEFINITIONS + "PY3_DLLNAME=${_wide_char_modifier}\"python3$<$:_d>\"" +) + +# Python 3.9 +add_python_extension(_peg_parser ALWAYS_BUILTIN + REQUIRES + IS_PY3_9_OR_GREATER + IS_PY_LESS_3_10 + SOURCES + _peg_parser.c +) + +# Python Argument Clinic functional test module +add_python_extension(_testclinic + REQUIRES + "PY_VERSION VERSION_GREATER_EQUAL 3.10.10" + SOURCES + _testclinic.c +) + +# Python 3.12 +add_python_extension(_testsinglephase BUILTIN + REQUIRES + IS_PY3_12_OR_GREATER + SOURCES + _testsinglephase.c +) + +# Python interface to subinterpreter C-API. +add_python_extension(_xxsubinterpreters ${WIN32_BUILTIN} + REQUIRES + IS_PY3_8_OR_GREATER + SOURCES + _xxsubinterpretersmodule.c +) + +# UNIX-only extensions +add_python_extension(fcntl REQUIRES UNIX SOURCES fcntlmodule.c) +add_python_extension(grp REQUIRES UNIX SOURCES grpmodule.c) + +set(nis_REQUIRES UNIX HAVE_LIBNSL) +set(nis_LIBRARIES ${HAVE_LIBNSL}) +set(nis_INCLUDEDIRS ) +if(TIRPC_LIBRARY AND TIRPC_RPC_INCLUDE_PATH) + # if rpc.h is provided by libtirpc (instead of being provided by glibc). See python/cpython#5137 + list(APPEND nis_LIBRARIES ${TIRPC_LIBRARY}) + list(APPEND nis_INCLUDEDIRS ${TIRPC_RPC_INCLUDE_PATH}/../) + if(WITH_STATIC_DEPENDENCIES AND TIRPC_LIBRARY_STATIC_DEPENDENCY_REQUIRED) + list(APPEND nis_REQUIRES TIRPC_STATIC_LIBRARIES) + list(APPEND nis_LIBRARIES ${TIRPC_STATIC_LIBRARIES}) + endif() +endif() +add_python_extension(nis + REQUIRES + ${nis_REQUIRES} + SOURCES + nismodule.c + LIBRARIES + ${nis_LIBRARIES} + INCLUDEDIRS + ${nis_INCLUDEDIRS} +) + +add_python_extension(posix REQUIRES UNIX ALWAYS_BUILTIN SOURCES posixmodule.c DEFINITIONS Py_BUILD_CORE) +add_python_extension(pwd REQUIRES UNIX BUILTIN SOURCES pwdmodule.c) # this is needed to find out the user's home dir if $HOME is not set +add_python_extension(resource REQUIRES UNIX SOURCES resource.c) +add_python_extension(spwd + REQUIRES + UNIX + HAVE_GETSPNAM + HAVE_GETSPENT + SOURCES + spwdmodule.c +) +add_python_extension(syslog REQUIRES UNIX SOURCES syslogmodule.c) +add_python_extension(termios REQUIRES UNIX SOURCES termios.c) + +# Python3: UNIX-only extensions +add_python_extension(errno BUILTIN UNIX SOURCES errnomodule.c) +add_python_extension(_posixsubprocess REQUIRES UNIX SOURCES _posixsubprocess.c) + +# MacOSX-only extensions +set(_scproxy3_SOURCES ${SRC_DIR}/Modules/_scproxy.c) +add_python_extension(_scproxy + REQUIRES APPLE HAVE_LIBCOREFOUNDATION HAVE_LIBSYSTEMCONFIGURATION + SOURCES ${_scproxy${PY_VERSION_MAJOR}_SOURCES} + LIBRARIES ${HAVE_LIBSYSTEMCONFIGURATION} ${HAVE_LIBCOREFOUNDATION} +) + +# Linux-only extensions +add_python_extension(ossaudiodev + REQUIRES + LINUX + SOURCES + ossaudiodev.c +) + +# Python 3.8: UNIX-only extensions +set(_posixshmem_LIBRARIES) +if(HAVE_SHM_OPEN_IN_RT) + list(APPEND _posixshmem_LIBRARIES rt) +endif() +add_python_extension(_posixshmem + REQUIRES + IS_PY3_8_OR_GREATER + UNIX + SOURCES + _multiprocessing/posixshmem.c + LIBRARIES + ${_posixshmem_LIBRARIES} +) + +# Windows-only extensions +add_python_extension(_msi + REQUIRES + WIN32 + SOURCES + ${SRC_DIR}/PC/_msi.c + DEFINITIONS + $<$:NEEDS_PY_IDENTIFIER> + LIBRARIES + cabinet.lib + msi.lib + rpcrt4.lib +) +add_python_extension(msvcrt REQUIRES MSVC BUILTIN SOURCES ${SRC_DIR}/PC/msvcrtmodule.c) +add_python_extension(nt REQUIRES WIN32 ALWAYS_BUILTIN SOURCES posixmodule.c) + +add_python_extension(winreg REQUIRES WIN32 BUILTIN SOURCES ${SRC_DIR}/PC/winreg.c) + +# Python3: Windows-only extensions +add_python_extension(_overlapped + REQUIRES + WIN32 + SOURCES + ${SRC_DIR}/Modules/overlapped.c + LIBRARIES + ws2_32 + $<$:pathcch> +) +add_python_extension(_winapi REQUIRES WIN32 BUILTIN SOURCES ${SRC_DIR}/Modules/_winapi.c) + +set(HAS_DISTUTILS_FINDVS_MODULE_SRC 0) +set(module_src ${SRC_DIR}/PC/_findvs.cpp) +if(EXISTS ${module_src}) + set(HAS_DISTUTILS_FINDVS_MODULE_SRC 1) +endif() +add_python_extension(_distutils_findvs REQUIRES WIN32 HAS_DISTUTILS_FINDVS_MODULE_SRC SOURCES ${module_src}) + +add_python_extension(_wmi + REQUIRES + IS_PY3_12_OR_GREATER + WIN32 + SOURCES + ${SRC_DIR}/PC/_wmimodule.cpp + LIBRARIES + propsys + wbemuuid +) + +# Multiprocessing is different on unix and windows +if(UNIX) + set(_multiprocessing3_SOURCES ) + if(HAVE_SEM_OPEN AND NOT POSIX_SEMAPHORES_NOT_ENABLED) + list(APPEND _multiprocessing${PY_VERSION_MAJOR}_SOURCES + _multiprocessing/semaphore.c + ) + endif() + set(_multiprocessing_REQUIRES) + if(PY_VERSION VERSION_LESS "3.7") + list(APPEND _multiprocessing_REQUIRES WITH_THREAD) + endif() + add_python_extension(_multiprocessing + SOURCES + _multiprocessing/multiprocessing.c + ${_multiprocessing${PY_VERSION_MAJOR}_SOURCES} + REQUIRES + ${_multiprocessing_REQUIRES} + ) +elseif(WIN32) + set(_multiprocessing3_SOURCES ) + add_python_extension(_multiprocessing + SOURCES + _multiprocessing/multiprocessing.c + _multiprocessing/semaphore.c + ${_multiprocessing${PY_VERSION_MAJOR}_SOURCES} + LIBRARIES + ws2_32 + ) +endif() + +# Select needs winsock on Windows +if(WIN32) + add_python_extension(select SOURCES selectmodule.c LIBRARIES ws2_32) +else() + add_python_extension(select SOURCES selectmodule.c) +endif() + +# Socket is different on Windows +set(_socket_SOURCES socketmodule.c) +if(WIN32) + add_python_extension(_socket + REQUIRES + HAVE_LIBM + SOURCES + ${_socket_SOURCES} + DEFINITIONS + EAI_ADDRFAMILY + HAVE_SOCKADDR_STORAGE + HAVE_ADDRINFO + LIBRARIES + ws2_32 + ${M_LIBRARIES} + $<$:iphlpapi> + $<$:Rpcrt4> + ) +else() + add_python_extension(_socket + REQUIRES + HAVE_LIBM + SOURCES + ${_socket_SOURCES} + LIBRARIES + ${M_LIBRARIES} + ) +endif() + +set(_libffi_system_dir ${CMAKE_SYSTEM_PROCESSOR}) +if("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "i686") + set(_libffi_system_dir "x86") +elseif("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "x86_64" OR "${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "amd64") + set(_libffi_system_dir "x86") +elseif("${CMAKE_SYSTEM_PROCESSOR}" MATCHES "arm") + set(_libffi_system_dir "arm") +endif() +# Common ctypes sources +set(ctypes_COMMON_SOURCES + _ctypes/_ctypes.c + _ctypes/callbacks.c + _ctypes/callproc.c + _ctypes/stgdict.c + _ctypes/cfield.c +) + +if( + (WIN32 AND PY_VERSION VERSION_GREATER_EQUAL "3.8") + OR + (LINUX AND PY_VERSION VERSION_GREATER_EQUAL "3.7") + OR + (APPLE AND PY_VERSION VERSION_GREATER_EQUAL "3.12") + ) + # If found, build ctypes against ffi library + # * on Windows for python >= 3.8 + # * on Linux for python >= 3.7 + # * on macOS for python >= 3.12 + set(ctypes_malloc_closure 0) + if(APPLE AND PY_VERSION VERSION_GREATER_EQUAL "3.12") + set(ctypes_malloc_closure 1) + endif() + set(_ctypes_REQUIRES) + if(UNIX AND PY_VERSION VERSION_GREATER_EQUAL "3.12") + list(APPEND _ctypes_REQUIRES HAVE_FFI_CALL) + endif() + set(ffi_building 0) + set(ffi_static_build 0) + get_filename_component(_ffi_library_name ${LibFFI_LIBRARY} NAME) + # Linking against the static library on Windows requires defining "FFI_BUILDING" + # See ffi.h for more details. + # As of Libffi v3.4.5, linking against the static library on Windows requires defining "FFI_STATIC_BUILD" + # See ffi.h.in for more details. + if(WIN32 AND _ffi_library_name MATCHES "^ffi_static") + set(ffi_building 1) + set(ffi_static_build 1) + endif() + add_python_extension(_ctypes + REQUIRES + LibFFI_INCLUDE_DIR + LibFFI_LIBRARY + ${_ctypes_REQUIRES} + SOURCES + ${ctypes_COMMON_SOURCES} + $<$:_ctypes/malloc_closure.c> + DEFINITIONS + Py_BUILD_CORE_MODULE + $<$:USING_MALLOC_CLOSURE_DOT_C=1> + $<$:FFI_BUILDING> + $<$:FFI_STATIC_BUILD> + INCLUDEDIRS + ${LibFFI_INCLUDE_DIR} + LIBRARIES + ${LibFFI_LIBRARY} + ) +else() +# ctypes is different on Windows +if(WIN32) + if(MINGW) + add_python_extension(_ctypes + SOURCES + ${ctypes_COMMON_SOURCES} + _ctypes/libffi_mingw/closures.c + _ctypes/libffi_mingw/debug.c + _ctypes/libffi_mingw/prep_cif.c + _ctypes/libffi_mingw/raw_api.c + _ctypes/libffi_mingw/${_libffi_system_dir}/ffi.c + _ctypes/libffi_mingw/${_libffi_system_dir}/win32.S + INCLUDEDIRS + ${SRC_DIR}/Modules/_ctypes/libffi/src/${_libffi_system_dir} + ${SRC_DIR}/Modules/_ctypes/libffi/include + DEFINITIONS + X86_WIN32 + ) + else() # Visual Studio + if(${CMAKE_SIZEOF_VOID_P} EQUAL 8) + enable_language(ASM_MASM) + set(_ctype_arch_impl win64.asm) + else() + set(_ctype_arch_impl win32.c) + endif() + add_python_extension(_ctypes + SOURCES + ${ctypes_COMMON_SOURCES} + _ctypes/malloc_closure.c + _ctypes/libffi_msvc/prep_cif.c + _ctypes/libffi_msvc/ffi.c + _ctypes/libffi_msvc/${_ctype_arch_impl} + REQUIRES + BUILD_LIBPYTHON_SHARED + INCLUDEDIRS + ${SRC_DIR}/Modules/_ctypes/libffi_msvc + ) + endif() +else() + if(APPLE) + add_python_extension(_ctypes + SOURCES + ${ctypes_COMMON_SOURCES} + _ctypes/malloc_closure.c + _ctypes/darwin/dlfcn_simple.c + _ctypes/libffi_osx/ffi.c + _ctypes/libffi_osx/x86/darwin64.S + _ctypes/libffi_osx/x86/x86-darwin.S + _ctypes/libffi_osx/x86/x86-ffi_darwin.c + _ctypes/libffi_osx/x86/x86-ffi64.c + INCLUDEDIRS + ${SRC_DIR}/Modules/_ctypes/libffi_osx/include + ${SRC_DIR}/Modules/_ctypes/darwin + DEFINITIONS + MACOSX + ) + else() + if("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "x86_64") + set(_libffi_system_extra_src + _ctypes/libffi/src/${_libffi_system_dir}/ffi64.c + _ctypes/libffi/src/${_libffi_system_dir}/unix64.S + ) + elseif("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "i686") + set(_libffi_system_extra_src + _ctypes/libffi/src/${_libffi_system_dir}/win32.S + ) + endif() + # To facilitate an eventual contribution of the configuration + # of fficonfig.h to the upstream project, corresponding tests + # in ConfigureChecks.cmake are labeled using this convention: + # * "libffi specific" + # * "libffi and cpython" + set(LIBFFI_VERSION "3.1") + configure_file( + ${PROJECT_SOURCE_DIR}/cmake/fficonfig.h.in + ${INCLUDE_BUILD_DIR}/fficonfig.h + ) + add_python_extension(_ctypes + SOURCES + ${ctypes_COMMON_SOURCES} + _ctypes/libffi/src/closures.c + _ctypes/libffi/src/prep_cif.c + _ctypes/libffi/src/${_libffi_system_dir}/ffi.c + _ctypes/libffi/src/${_libffi_system_dir}/sysv.S + ${_libffi_system_extra_src} + INCLUDEDIRS + ${SRC_DIR}/Modules/_ctypes/libffi/src/${_libffi_system_dir} + ${SRC_DIR}/Modules/_ctypes/libffi/include + ${INCLUDE_BUILD_DIR} # For fficonfig.h + ${PROJECT_SOURCE_DIR}/cmake # For ffi.h + ) + endif() +endif() +endif() + +# Python3: _decimal +set(libmpdec_config_x64 CONFIG_64 ASM) +set(libmpdec_config_uint128 CONFIG_64 ANSI HAVE_UINT128_T) +set(libmpdec_config_ansi64 CONFIG_64 ANSI) +set(libmpdec_config_ppro CONFIG_32 PPRO ASM) +set(libmpdec_config_ansi32 CONFIG_32 PPRO) # XXX Is ANSI needed here ? +set(libmpdec_config_ansi_legacy CONFIG_32 ANSI LEGACY_COMPILER) +set(libmpdec_config_universal UNIVERSAL) + +if(USE_SYSTEM_LIBMPDEC) + set(_decimal_REQUIRES REQUIRES LIBMPDEC_LIBRARIES LIBMPDEC_INCLUDE_DIR) + set(_decimal_LIBRARIES LIBRARIES ${LIBMPDEC_LIBRARIES}) + set(_decimal_EXTRA_SOURCES ) + set(_decimal_INCLUDEDIRS INCLUDEDIRS ${LIBMPDEC_INCLUDE_DIR}) +else() + set(_decimal_REQUIRES ) + set(_decimal_EXTRA_SOURCES + _decimal/libmpdec/basearith.c + _decimal/libmpdec/constants.c + _decimal/libmpdec/context.c + _decimal/libmpdec/convolute.c + _decimal/libmpdec/crt.c + _decimal/libmpdec/difradix2.c + _decimal/libmpdec/fnt.c + _decimal/libmpdec/fourstep.c + _decimal/libmpdec/io.c + _decimal/libmpdec/mpdecimal.c + _decimal/libmpdec/numbertheory.c + _decimal/libmpdec/sixstep.c + _decimal/libmpdec/transpose.c + + # Removed in Python 3.9 + $<$:_decimal/libmpdec/memory.c> + + # Introduced in Python 3.9 + $<$:_decimal/libmpdec/mpalloc.c> + ) + if(WIN32) + if(${CMAKE_SIZEOF_VOID_P} EQUAL 8) + enable_language(ASM_MASM) + list(APPEND _decimal_EXTRA_SOURCES + _decimal/libmpdec/vcdiv64.asm + ) + endif() + endif() + set(_decimal_INCLUDEDIRS INCLUDEDIRS ${SRC_DIR}/Modules/_decimal/libmpdec) +endif() +set(libmpdec_config ) +set(_decimal_compile_flags ) +if(APPLE) + # Universal here means: build with the same options Python + # was built with. + set(libmpdec_config universal) +elseif(${CMAKE_SIZEOF_VOID_P} EQUAL 8) + if(HAVE_GCC_ASM_FOR_X64) + set(libmpdec_config x64) + elseif(HAVE_GCC_UINT128_T) + set(libmpdec_config uint128) + else() + set(libmpdec_config ansi64) + endif() +elseif(${CMAKE_SIZEOF_VOID_P} EQUAL 4) + if(HAVE_GCC_ASM_FOR_X87 AND + (CMAKE_C_COMPILER_ID MATCHES "GNU" OR CMAKE_C_COMPILER_ID MATCHES "Clang") + AND NOT CMAKE_SYSTEM MATCHES SunOS + ) + # solaris: problems with register allocation. + # icc >= 11.0 works as well. + set(libmpdec_config ppro) + list(APPEND _decimal_compile_flags "-Wno-unknown-pragmas") + else() + set(libmpdec_config ansi32) + endif() +else() + message(FATAL_ERROR "extension_decimal: unsupported architecture") +endif() + +# Workarounds for toolchain bugs: +if(HAVE_IPA_PURE_CONST_BUG) + # Some versions of gcc miscompile inline asm: + # http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46491 + # http://gcc.gnu.org/ml/gcc/2010-11/msg00366.html + list(APPEND _decimal_compile_flags "-fno-ipa-pure-const") +endif() +if(HAVE_GLIBC_MEMMOVE_BUG) + # _FORTIFY_SOURCE wrappers for memmove and bcopy are incorrect: + # http://sourceware.org/ml/libc-alpha/2010-12/msg00009.html + # XXX Implement missing logic +# undef_macros.append('_FORTIFY_SOURCE') +endif() + +if(NOT WITH_THREAD AND PY_VERSION VERSION_LESS "3.7") + # Faster version without thread local contexts: + list(APPEND libmpdec_config_${libmpdec_config} + WITHOUT_THREADS + ) +endif() + +if(WIN32) + list(APPEND libmpdec_config_${libmpdec_config} + _CRT_SECURE_NO_WARNINGS MASM + ) +endif() + +# Uncomment for extra functionality: +#list(APPEND libmpdec_config_${libmpdec_config} EXTRA_FUNCTIONALITY) + +if(ENABLE_DECIMAL) + message(STATUS "extension_decimal: libmpdec_config [${libmpdec_config}]") +endif() +add_python_extension(_decimal + REQUIRES + IS_PY3_3_OR_GREATER + SOURCES + _decimal/_decimal.c + _decimal/docstrings.h + ${_decimal_EXTRA_SOURCES} + DEFINITIONS ${libmpdec_config_${libmpdec_config}} + ${_decimal_REQUIRES} + ${_decimal_LIBRARIES} + ${_decimal_INCLUDEDIRS} +) +if(_decimal_compile_flags AND ENABLE_DECIMAL AND TARGET extension_decimal AND NOT BUILTIN_DECIMAL) + set_target_properties(extension_decimal PROPERTIES COMPILE_FLAGS ${_decimal_compile_flags}) +endif() + +# Build expat using the system expat if it's installed, otherwise use the +# builtin version. +if(EXPAT_LIBRARIES AND EXPAT_INCLUDE_DIRS) + add_python_extension(pyexpat + SOURCES pyexpat.c + LIBRARIES ${EXPAT_LIBRARIES} + INCLUDEDIRS ${EXPAT_INCLUDE_DIRS} + ) + add_python_extension(_elementtree + SOURCES _elementtree.c + LIBRARIES ${EXPAT_LIBRARIES} + INCLUDEDIRS ${EXPAT_INCLUDE_DIRS} + ) +else() + set(_pyexpat_definitions XML_STATIC) + set(_pyexpat_SOURCES + pyexpat.c + expat/xmlparse.c + expat/xmlrole.c + expat/xmltok.c + ) + if(UNIX) + list(APPEND _pyexpat_definitions HAVE_EXPAT_CONFIG_H) + # bpo-30947: Python uses best available entropy sources to + # call XML_SetHashSalt(), expat entropy sources are not needed + list(APPEND _pyexpat_definitions XML_POOR_ENTROPY) + elseif(WIN32) + list(APPEND _pyexpat_definitions COMPILED_FROM_DSP) + if(EXISTS "${SRC_DIR}/Modules/expat/loadlibrary.c") + list(APPEND _pyexpat_SOURCES "${SRC_DIR}/Modules/expat/loadlibrary.c") + endif() + endif() + add_python_extension(pyexpat + SOURCES ${_pyexpat_SOURCES} + DEFINITIONS ${_pyexpat_definitions} + INCLUDEDIRS ${SRC_DIR}/Modules/expat + ) + set(_elementtree_definitions USE_PYEXPAT_CAPI) + if(WIN32) + list(APPEND _elementtree_definitions COMPILED_FROM_DSP) + endif() + add_python_extension(_elementtree + SOURCES _elementtree.c + DEFINITIONS ${_elementtree_definitions} + INCLUDEDIRS ${SRC_DIR}/Modules/expat + ) +endif() + +# We always compile these even when OpenSSL is available (issue #14693). +# It's harmless and the object code is tiny (40-50 KB per module, +# only loaded when actually used). +add_python_extension(_md5 ${WIN32_BUILTIN} + SOURCES + md5module.c + $<$:_hacl/Hacl_Hash_MD5.c> + INCLUDEDIRS + $<$:${SRC_DIR}/Modules/_hacl/include> + DEFINITIONS + $<$,$>:_BSD_SOURCE> + $<$,$>:_DEFAULT_SOURCE> +) +add_python_extension(_sha1 ${WIN32_BUILTIN} + SOURCES + sha1module.c + $<$:_hacl/Hacl_Hash_SHA1.c> + INCLUDEDIRS + $<$:${SRC_DIR}/Modules/_hacl/include> + DEFINITIONS + $<$,$>:_BSD_SOURCE> + $<$,$>:_DEFAULT_SOURCE> +) + +# Removed in Python 3.12 +add_python_extension(_sha256 ${WIN32_BUILTIN} + REQUIRES + IS_PY_LESS_3_12 + SOURCES + sha256module.c +) +add_python_extension(_sha512 ${WIN32_BUILTIN} + REQUIRES + IS_PY_LESS_3_12 + SOURCES + sha512module.c +) + +# Python 3.12 +add_python_extension(_sha2 ${WIN32_BUILTIN} + REQUIRES + IS_PY3_12_OR_GREATER + SOURCES + sha2module.c + _hacl/Hacl_Hash_SHA2.c + INCLUDEDIRS + ${SRC_DIR}/Modules/_hacl/include + DEFINITIONS + $<$:_BSD_SOURCE> + $<$:_DEFAULT_SOURCE> +) +add_python_extension(_sha3 ${WIN32_BUILTIN} + REQUIRES + IS_PY3_12_OR_GREATER + SOURCES + sha3module.c + $<$:_hacl/Hacl_Hash_SHA3.c> + INCLUDEDIRS + $<$:${SRC_DIR}/Modules/_hacl/include> + DEFINITIONS + $<$:_BSD_SOURCE> + $<$:_DEFAULT_SOURCE> +) +add_python_extension(_tokenize ALWAYS_BUILTIN + REQUIRES + IS_PY3_12_OR_GREATER + SOURCES + ${SRC_DIR}/Python/Python-tokenize.c +) +add_python_extension(_typing ALWAYS_BUILTIN + REQUIRES + IS_PY3_12_OR_GREATER + SOURCES + _typingmodule.c +) +add_python_extension(_xxinterpchannels ALWAYS_BUILTIN + REQUIRES + IS_PY3_12_OR_GREATER + SOURCES + _xxinterpchannelsmodule.c +) + +# Extensions that depend on other libraries +set(binascii_REQUIRES "") +set(binascii_DEFINITIONS "") +set(binascii_LIBRARIES "") +set(binascii_INCLUDEDIRS "") +if(ZLIB_LIBRARY) + list(APPEND binascii_REQUIRES ZLIB_INCLUDE_DIR) + list(APPEND binascii_DEFINITIONS USE_ZLIB_CRC32) + list(APPEND binascii_LIBRARIES ${ZLIB_LIBRARY}) + list(APPEND binascii_INCLUDEDIRS ${ZLIB_INCLUDE_DIR}) +endif() +add_python_extension(binascii + REQUIRES ${binascii_REQUIRES} + ${WIN32_BUILTIN} + SOURCES binascii.c + DEFINITIONS ${binascii_DEFINITIONS} + LIBRARIES ${binascii_LIBRARIES} + INCLUDEDIRS ${binascii_INCLUDEDIRS} +) +add_python_extension(_bz2 + REQUIRES BZIP2_LIBRARIES BZIP2_INCLUDE_DIR + SOURCES _bz2module.c + LIBRARIES ${BZIP2_LIBRARIES} + INCLUDEDIRS ${BZIP2_INCLUDE_DIR} +) +set(curses_common_REQUIRES CURSES_LIBRARIES) +set(curses_common_LIBRARIES ${CURSES_LIBRARIES}) +if(WITH_STATIC_DEPENDENCIES) + list(APPEND curses_common_REQUIRES TINFO_LIBRARY GPM_LIBRARY) + list(APPEND curses_common_LIBRARIES ${TINFO_LIBRARY} ${GPM_LIBRARY}) +endif() +add_python_extension(_curses_panel + REQUIRES ${curses_common_REQUIRES} PANEL_LIBRARIES "HAVE_PANEL_H OR HAVE_NCURSES_PANEL_H" + SOURCES _curses_panel.c + LIBRARIES ${curses_common_LIBRARIES} ${PANEL_LIBRARIES} +) +add_python_extension(_curses + REQUIRES ${curses_common_REQUIRES} + SOURCES _cursesmodule.c + LIBRARIES ${curses_common_LIBRARIES} +) +add_python_extension(_dbm + REQUIRES NDBM_TAG GDBM_LIBRARY GDBM_COMPAT_LIBRARY + SOURCES _dbmmodule.c + DEFINITIONS + HAVE_${NDBM_TAG}_H + USE_${NDBM_USE} # Python 3.11 + LIBRARIES + ${GDBM_LIBRARY} + ${GDBM_COMPAT_LIBRARY} + INCLUDEDIRS + ${${NDBM_TAG}_INCLUDE_PATH} +) +add_python_extension(_gdbm + REQUIRES GDBM_INCLUDE_PATH GDBM_LIBRARY GDBM_COMPAT_LIBRARY + SOURCES _gdbmmodule.c + DEFINITIONS HAVE_GDBM_DASH_NDBM_H + LIBRARIES ${GDBM_LIBRARY} + INCLUDEDIRS ${GDBM_INCLUDE_PATH} +) +add_python_extension(_hashlib + REQUIRES OPENSSL_INCLUDE_DIR OPENSSL_LIBRARIES + IS_PY3_5_OR_GREATER + SOURCES _hashopenssl.c + LIBRARIES ${OPENSSL_LIBRARIES} + INCLUDEDIRS ${OPENSSL_INCLUDE_DIR} +) +if(ENABLE_HASHLIB AND CMAKE_C_COMPILER_ID MATCHES GNU) + set_property(SOURCE ${SRC_DIR}/Modules/_hashopenssl.c PROPERTY COMPILE_FLAGS -Wno-deprecated-declarations) +endif() +# lzma module was introduced in Python 3.3 +add_python_extension(_lzma + REQUIRES LZMA_INCLUDE_PATH LZMA_LIBRARY IS_PY3_3_OR_GREATER + SOURCES _lzmamodule.c + DEFINITIONS MODULE_NAME="lzma" LZMA_API_STATIC=1 + INCLUDEDIRS ${LZMA_INCLUDE_PATH} + LIBRARIES ${LZMA_LIBRARY} +) +set(readline_DEFINITIONS "") +if(USE_LIBEDIT) + if(PY_VERSION VERSION_GREATER_EQUAL "3.10") + list(APPEND readline_DEFINITIONS WITH_EDITLINE) + endif() +endif() +add_python_extension(readline + REQUIRES READLINE_INCLUDE_PATH READLINE_LIBRARY CURSES_LIBRARIES HAVE_READLINE_READLINE_H + SOURCES readline.c + DEFINITIONS ${readline_DEFINITIONS} + LIBRARIES ${READLINE_LIBRARY} ${CURSES_LIBRARIES} + INCLUDEDIRS ${READLINE_INCLUDE_PATH} +) +add_python_extension(_sqlite3 + REQUIRES SQLite3_INCLUDE_DIRS SQLite3_LIBRARIES + SOURCES + # Removed in Python 3.11 + $<$:_sqlite/cache.c> + + _sqlite/connection.c + _sqlite/cursor.c + _sqlite/microprotocols.c + _sqlite/module.c + _sqlite/prepare_protocol.c + _sqlite/row.c + _sqlite/statement.c + _sqlite/util.c + + # Introduced in Python 3.11 + $<$:_sqlite/blob.c> + + DEFINITIONS + MODULE_NAME="sqlite3" + SQLITE_OMIT_LOAD_EXTENSION=1 + INCLUDEDIRS + ${SQLite3_INCLUDE_DIRS} + LIBRARIES + ${SQLite3_LIBRARIES} + $<$:Rpcrt4> # For supporting when SQLITE_WIN32_USE_UUID is enabled +) +if(ENABLE_SQLITE3 AND CMAKE_C_COMPILER_ID MATCHES GNU) + set_property(SOURCE ${SRC_DIR}/Modules/_sqlite/module.c PROPERTY COMPILE_FLAGS -Wno-deprecated-declarations) +endif() +set(_ssl_LIBRARIES ${OPENSSL_LIBRARIES}) +if(WIN32) + list(APPEND _ssl_LIBRARIES Crypt32 ws2_32) +endif() +set(_ssl_SOURCES _ssl.c) +if(WIN32) + list(APPEND _ssl_SOURCES ${OPENSSL_INCLUDE_DIR}/openssl/applink.c) +endif() +add_python_extension(_ssl + REQUIRES OPENSSL_INCLUDE_DIR OPENSSL_LIBRARIES + IS_PY3_5_OR_GREATER + SOURCES ${_ssl_SOURCES} + LIBRARIES ${_ssl_LIBRARIES} + INCLUDEDIRS ${OPENSSL_INCLUDE_DIR} +) +set(_tkinter_REQUIRES TCL_LIBRARY TK_LIBRARY TCL_INCLUDE_PATH TK_INCLUDE_PATH) +set(_tkinter_LIBRARIES ${TCL_LIBRARY} ${TK_LIBRARY}) +set(_tkinter_INCLUDEDIRS ${TCL_INCLUDE_PATH} ${TK_INCLUDE_PATH}) +if(UNIX) + list(APPEND _tkinter_REQUIRES X11_INCLUDE_DIR X11_LIBRARIES) + list(APPEND _tkinter_LIBRARIES ${X11_LIBRARIES}) + list(APPEND _tkinter_INCLUDEDIRS ${X11_INCLUDE_DIR}) +endif() +add_python_extension(_tkinter + REQUIRES ${_tkinter_REQUIRES} + SOURCES _tkinter.c tkappinit.c + DEFINITIONS WITH_APPINIT=1 + LIBRARIES ${_tkinter_LIBRARIES} + INCLUDEDIRS ${_tkinter_INCLUDEDIRS} +) +if(NOT USE_BUILTIN_ZLIB) + add_python_extension(zlib + REQUIRES ZLIB_LIBRARY ZLIB_INCLUDE_DIR + SOURCES zlibmodule.c + LIBRARIES ${ZLIB_LIBRARY} + INCLUDEDIRS ${ZLIB_INCLUDE_DIR} + ) +else() + add_python_extension(zlib BUILTIN + REQUIRES + SOURCES + zlibmodule.c + zlib/adler32.c + zlib/compress.c + zlib/crc32.c + zlib/deflate.c + zlib/infback.c + zlib/inffast.c + zlib/inflate.c + zlib/inftrees.c + zlib/trees.c + zlib/uncompr.c + zlib/zutil.c + INCLUDEDIRS ${SRC_DIR}/Modules/zlib + ) +endif() diff --git a/third/python-cmake/cmake/ffi.h b/third/python-cmake/cmake/ffi.h new file mode 100644 index 00000000..91f287a1 --- /dev/null +++ b/third/python-cmake/cmake/ffi.h @@ -0,0 +1,402 @@ +/* -----------------------------------------------------------------*-C-*- + libffi 3.0.10rc0 - Copyright (c) 1996-2003, 2007, 2008 Red Hat, Inc. + + Permission is hereby granted, free of charge, to any person obtaining + a copy of this software and associated documentation files (the + ``Software''), to deal in the Software without restriction, including + without limitation the rights to use, copy, modify, merge, publish, + distribute, sublicense, and/or sell copies of the Software, and to + permit persons to whom the Software is furnished to do so, subject to + the following conditions: + + The above copyright notice and this permission notice shall be included + in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, + EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + DEALINGS IN THE SOFTWARE. + + ----------------------------------------------------------------------- */ + +/* ------------------------------------------------------------------- + The basic API is described in the README file. + + The raw API is designed to bypass some of the argument packing + and unpacking on architectures for which it can be avoided. + + The closure API allows interpreted functions to be packaged up + inside a C function pointer, so that they can be called as C functions, + with no understanding on the client side that they are interpreted. + It can also be used in other cases in which it is necessary to package + up a user specified parameter and a function pointer as a single + function pointer. + + The closure API must be implemented in order to get its functionality, + e.g. for use by gij. Routines are provided to emulate the raw API + if the underlying platform doesn't allow faster implementation. + + More details on the raw and cloure API can be found in: + + http://gcc.gnu.org/ml/java/1999-q3/msg00138.html + + and + + http://gcc.gnu.org/ml/java/1999-q3/msg00174.html + -------------------------------------------------------------------- */ + +#ifndef LIBFFI_H +#define LIBFFI_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* Specify which architecture libffi is configured for. */ +#define X86_64 + +/* ---- System configuration information --------------------------------- */ + +#include + +#ifndef LIBFFI_ASM + +#ifdef _MSC_VER +#define __attribute__(X) +#endif + +#include +#include + +/* LONG_LONG_MAX is not always defined (not if STRICT_ANSI, for example). + But we can find it either under the correct ANSI name, or under GNU + C's internal name. */ +#ifdef LONG_LONG_MAX +# define FFI_LONG_LONG_MAX LONG_LONG_MAX +#else +# ifdef LLONG_MAX +# define FFI_LONG_LONG_MAX LLONG_MAX +# else +# ifdef __GNUC__ +# define FFI_LONG_LONG_MAX __LONG_LONG_MAX__ +# endif +# endif +#endif + +/* The closure code assumes that this works on pointers, i.e. a size_t */ +/* can hold a pointer. */ + +typedef struct _ffi_type +{ + size_t size; + unsigned short alignment; + unsigned short type; + struct _ffi_type **elements; +} ffi_type; + +#ifndef LIBFFI_HIDE_BASIC_TYPES +#if SCHAR_MAX == 127 +# define ffi_type_uchar ffi_type_uint8 +# define ffi_type_schar ffi_type_sint8 +#else + #error "char size not supported" +#endif + +#if SHRT_MAX == 32767 +# define ffi_type_ushort ffi_type_uint16 +# define ffi_type_sshort ffi_type_sint16 +#elif SHRT_MAX == 2147483647 +# define ffi_type_ushort ffi_type_uint32 +# define ffi_type_sshort ffi_type_sint32 +#else + #error "short size not supported" +#endif + +#if INT_MAX == 32767 +# define ffi_type_uint ffi_type_uint16 +# define ffi_type_sint ffi_type_sint16 +#elif INT_MAX == 2147483647 +# define ffi_type_uint ffi_type_uint32 +# define ffi_type_sint ffi_type_sint32 +#elif INT_MAX == 9223372036854775807 +# define ffi_type_uint ffi_type_uint64 +# define ffi_type_sint ffi_type_sint64 +#else + #error "int size not supported" +#endif + +#if LONG_MAX == 2147483647 +# if FFI_LONG_LONG_MAX != 9223372036854775807 + #error "no 64-bit data type supported" +# endif +#elif LONG_MAX != 9223372036854775807 + #error "long size not supported" +#endif + +#if LONG_MAX == 2147483647 +# define ffi_type_ulong ffi_type_uint32 +# define ffi_type_slong ffi_type_sint32 +#elif LONG_MAX == 9223372036854775807 +# define ffi_type_ulong ffi_type_uint64 +# define ffi_type_slong ffi_type_sint64 +#else + #error "long size not supported" +#endif + +/* These are defined in types.c */ +extern ffi_type ffi_type_void; +extern ffi_type ffi_type_uint8; +extern ffi_type ffi_type_sint8; +extern ffi_type ffi_type_uint16; +extern ffi_type ffi_type_sint16; +extern ffi_type ffi_type_uint32; +extern ffi_type ffi_type_sint32; +extern ffi_type ffi_type_uint64; +extern ffi_type ffi_type_sint64; +extern ffi_type ffi_type_float; +extern ffi_type ffi_type_double; +extern ffi_type ffi_type_pointer; + +#if 1 +extern ffi_type ffi_type_longdouble; +#else +#define ffi_type_longdouble ffi_type_double +#endif +#endif /* LIBFFI_HIDE_BASIC_TYPES */ + +typedef enum { + FFI_OK = 0, + FFI_BAD_TYPEDEF, + FFI_BAD_ABI +} ffi_status; + +typedef unsigned FFI_TYPE; + +typedef struct { + ffi_abi abi; + unsigned nargs; + ffi_type **arg_types; + ffi_type *rtype; + unsigned bytes; + unsigned flags; +#ifdef FFI_EXTRA_CIF_FIELDS + FFI_EXTRA_CIF_FIELDS; +#endif +} ffi_cif; + +/* ---- Definitions for the raw API -------------------------------------- */ + +#ifndef FFI_SIZEOF_ARG +# if LONG_MAX == 2147483647 +# define FFI_SIZEOF_ARG 4 +# elif LONG_MAX == 9223372036854775807 +# define FFI_SIZEOF_ARG 8 +# endif +#endif + +#ifndef FFI_SIZEOF_JAVA_RAW +# define FFI_SIZEOF_JAVA_RAW FFI_SIZEOF_ARG +#endif + +typedef union { + ffi_sarg sint; + ffi_arg uint; + float flt; + char data[FFI_SIZEOF_ARG]; + void* ptr; +} ffi_raw; + +#if FFI_SIZEOF_JAVA_RAW == 4 && FFI_SIZEOF_ARG == 8 +/* This is a special case for mips64/n32 ABI (and perhaps others) where + sizeof(void *) is 4 and FFI_SIZEOF_ARG is 8. */ +typedef union { + signed int sint; + unsigned int uint; + float flt; + char data[FFI_SIZEOF_JAVA_RAW]; + void* ptr; +} ffi_java_raw; +#else +typedef ffi_raw ffi_java_raw; +#endif + + +void ffi_raw_call (ffi_cif *cif, + void (*fn)(void), + void *rvalue, + ffi_raw *avalue); + +void ffi_ptrarray_to_raw (ffi_cif *cif, void **args, ffi_raw *raw); +void ffi_raw_to_ptrarray (ffi_cif *cif, ffi_raw *raw, void **args); +size_t ffi_raw_size (ffi_cif *cif); + +/* This is analogous to the raw API, except it uses Java parameter */ +/* packing, even on 64-bit machines. I.e. on 64-bit machines */ +/* longs and doubles are followed by an empty 64-bit word. */ + +void ffi_java_raw_call (ffi_cif *cif, + void (*fn)(void), + void *rvalue, + ffi_java_raw *avalue); + +void ffi_java_ptrarray_to_raw (ffi_cif *cif, void **args, ffi_java_raw *raw); +void ffi_java_raw_to_ptrarray (ffi_cif *cif, ffi_java_raw *raw, void **args); +size_t ffi_java_raw_size (ffi_cif *cif); + +/* ---- Definitions for closures ----------------------------------------- */ + +#if FFI_CLOSURES + +#ifdef _MSC_VER +__declspec(align(8)) +#endif +typedef struct { + char tramp[FFI_TRAMPOLINE_SIZE]; + ffi_cif *cif; + void (*fun)(ffi_cif*,void*,void**,void*); + void *user_data; +#ifdef __GNUC__ +} ffi_closure __attribute__((aligned (8))); +#else +} ffi_closure; +#endif + +void *ffi_closure_alloc (size_t size, void **code); +void ffi_closure_free (void *); + +ffi_status +ffi_prep_closure (ffi_closure*, + ffi_cif *, + void (*fun)(ffi_cif*,void*,void**,void*), + void *user_data); + +ffi_status +ffi_prep_closure_loc (ffi_closure*, + ffi_cif *, + void (*fun)(ffi_cif*,void*,void**,void*), + void *user_data, + void*codeloc); + +typedef struct { + char tramp[FFI_TRAMPOLINE_SIZE]; + + ffi_cif *cif; + +#if !FFI_NATIVE_RAW_API + + /* if this is enabled, then a raw closure has the same layout + as a regular closure. We use this to install an intermediate + handler to do the transaltion, void** -> ffi_raw*. */ + + void (*translate_args)(ffi_cif*,void*,void**,void*); + void *this_closure; + +#endif + + void (*fun)(ffi_cif*,void*,ffi_raw*,void*); + void *user_data; + +} ffi_raw_closure; + +typedef struct { + char tramp[FFI_TRAMPOLINE_SIZE]; + + ffi_cif *cif; + +#if !FFI_NATIVE_RAW_API + + /* if this is enabled, then a raw closure has the same layout + as a regular closure. We use this to install an intermediate + handler to do the transaltion, void** -> ffi_raw*. */ + + void (*translate_args)(ffi_cif*,void*,void**,void*); + void *this_closure; + +#endif + + void (*fun)(ffi_cif*,void*,ffi_java_raw*,void*); + void *user_data; + +} ffi_java_raw_closure; + +ffi_status +ffi_prep_raw_closure (ffi_raw_closure*, + ffi_cif *cif, + void (*fun)(ffi_cif*,void*,ffi_raw*,void*), + void *user_data); + +ffi_status +ffi_prep_raw_closure_loc (ffi_raw_closure*, + ffi_cif *cif, + void (*fun)(ffi_cif*,void*,ffi_raw*,void*), + void *user_data, + void *codeloc); + +ffi_status +ffi_prep_java_raw_closure (ffi_java_raw_closure*, + ffi_cif *cif, + void (*fun)(ffi_cif*,void*,ffi_java_raw*,void*), + void *user_data); + +ffi_status +ffi_prep_java_raw_closure_loc (ffi_java_raw_closure*, + ffi_cif *cif, + void (*fun)(ffi_cif*,void*,ffi_java_raw*,void*), + void *user_data, + void *codeloc); + +#endif /* FFI_CLOSURES */ + +/* ---- Public interface definition -------------------------------------- */ + +ffi_status ffi_prep_cif(ffi_cif *cif, + ffi_abi abi, + unsigned int nargs, + ffi_type *rtype, + ffi_type **atypes); + +void ffi_call(ffi_cif *cif, + void (*fn)(void), + void *rvalue, + void **avalue); + +/* Useful for eliminating compiler warnings */ +#define FFI_FN(f) ((void (*)(void))f) + +/* ---- Definitions shared with assembly code ---------------------------- */ + +#endif + +/* If these change, update src/mips/ffitarget.h. */ +#define FFI_TYPE_VOID 0 +#define FFI_TYPE_INT 1 +#define FFI_TYPE_FLOAT 2 +#define FFI_TYPE_DOUBLE 3 +#if 1 +#define FFI_TYPE_LONGDOUBLE 4 +#else +#define FFI_TYPE_LONGDOUBLE FFI_TYPE_DOUBLE +#endif +#define FFI_TYPE_UINT8 5 +#define FFI_TYPE_SINT8 6 +#define FFI_TYPE_UINT16 7 +#define FFI_TYPE_SINT16 8 +#define FFI_TYPE_UINT32 9 +#define FFI_TYPE_SINT32 10 +#define FFI_TYPE_UINT64 11 +#define FFI_TYPE_SINT64 12 +#define FFI_TYPE_STRUCT 13 +#define FFI_TYPE_POINTER 14 + +/* This should always refer to the last type code (for sanity checks) */ +#define FFI_TYPE_LAST FFI_TYPE_POINTER + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/third/python-cmake/cmake/fficonfig.h.in b/third/python-cmake/cmake/fficonfig.h.in new file mode 100644 index 00000000..c38ad2d3 --- /dev/null +++ b/third/python-cmake/cmake/fficonfig.h.in @@ -0,0 +1,207 @@ +/* fficonfig.h. Generated from fficonfig.h.in by configure. */ +/* fficonfig.h.in. Generated from configure.ac by autoheader. */ + +/* Define if building universal (internal helper macro) */ +/* #undef AC_APPLE_UNIVERSAL_BUILD */ + +/* Define to one of `_getb67', `GETB67', `getb67' for Cray-2 and Cray-YMP + systems. This function is required for `alloca.c' support on those systems. + */ +/* #undef CRAY_STACKSEG_END */ + +/* Define to 1 if using `alloca.c'. */ +/* #undef C_ALLOCA */ + +/* Define to the flags needed for the .section .eh_frame directive. */ +#define EH_FRAME_FLAGS "aw" + +/* Define this if you want extra debugging. */ +/* #undef FFI_DEBUG */ + +/* Cannot use PROT_EXEC on this target, so, we revert to alternative means */ +#cmakedefine FFI_EXEC_TRAMPOLINE_TABLE 1 + +/* Define this if you want to enable pax emulated trampolines */ +#cmakedefine FFI_MMAP_EXEC_EMUTRAMP_PAX 1 + +/* Cannot use malloc on this target, so, we revert to alternative means */ +/* #undef FFI_MMAP_EXEC_WRIT */ + +/* Define this if you do not want support for the raw API. */ +/* #undef FFI_NO_RAW_API */ + +/* Define this if you do not want support for aggregate types. */ +/* #undef FFI_NO_STRUCTS */ + +/* Define to 1 if you have `alloca', as a function or macro. */ +#cmakedefine HAVE_ALLOCA 1 + +/* Define to 1 if you have and it should be used (not on Ultrix). + */ +#cmakedefine HAVE_ALLOCA_H 1 + +/* Define if your assembler supports .ascii. */ +#cmakedefine HAVE_AS_ASCII_PSEUDO_OP 1 + +/* Define if your assembler supports .cfi_* directives. */ +#cmakedefine HAVE_AS_CFI_PSEUDO_OP 1 + +/* Define if your assembler supports .register. */ +/* #undef HAVE_AS_REGISTER_PSEUDO_OP */ + +/* Define if your assembler and linker support unaligned PC relative relocs. + */ +/* #undef HAVE_AS_SPARC_UA_PCREL */ + +/* Define if your assembler supports .string. */ +#cmakedefine HAVE_AS_STRING_PSEUDO_OP 1 + +/* Define if your assembler supports unwind section type. */ +#cmakedefine HAVE_AS_X86_64_UNWIND_SECTION_TYPE 1 + +/* Define if your assembler supports PC relative relocs. */ +#cmakedefine HAVE_AS_X86_PCREL 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_DLFCN_H 1 + +/* Define if __attribute__((visibility("hidden"))) is supported. */ +#cmakedefine HAVE_HIDDEN_VISIBILITY_ATTRIBUTE 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_INTTYPES_H 1 + +/* Define if you have the long double type and it is bigger than a double */ +#cmakedefine HAVE_LONG_DOUBLE 1 + +/* Define if you support more than one size of the long double type */ +#cmakedefine HAVE_LONG_DOUBLE_VARIANT 1 + +/* Define to 1 if you have the `memcpy' function. */ +#cmakedefine HAVE_MEMCPY 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_MEMORY_H 1 + +/* Define to 1 if you have the `mmap' function. */ +#cmakedefine HAVE_MMAP 1 + +/* Define if mmap with MAP_ANON(YMOUS) works. */ +#cmakedefine HAVE_MMAP_ANON 1 + +/* Define if mmap of /dev/zero works. */ +#cmakedefine HAVE_MMAP_DEV_ZERO 1 + +/* Define if read-only mmap of a plain file works. */ +#cmakedefine HAVE_MMAP_FILE 1 + +/* Define if .eh_frame sections should be read-only. */ +#cmakedefine HAVE_RO_EH_FRAME 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_STDINT_H 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_STDLIB_H 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_STRINGS_H 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_STRING_H 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_SYS_MMAN_H 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_SYS_STAT_H 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_SYS_TYPES_H 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_UNISTD_H 1 + +/* Define to 1 if your C compiler doesn't accept -c and -o together. */ +/* #undef NO_MINUS_C_MINUS_O */ + +/* Name of package */ +#define PACKAGE "libffi" + +/* Define to the address where bug reports for this package should be sent. */ +#define PACKAGE_BUGREPORT "http://github.com/atgreen/libffi/issues" + +/* Define to the full name of this package. */ +#define PACKAGE_NAME "libffi" + +/* Define to the full name and version of this package. */ +#define PACKAGE_STRING "libffi @LIBFFI_VERSION@" + +/* Define to the one symbol short name of this package. */ +#define PACKAGE_TARNAME "libffi" + +/* Define to the home page for this package. */ +#define PACKAGE_URL "" + +/* Define to the version of this package. */ +#define PACKAGE_VERSION "@LIBFFI_VERSION@" + +/* The size of `double', as computed by sizeof. */ +#cmakedefine SIZEOF_DOUBLE @SIZEOF_DOUBLE@ + +/* The size of `long double', as computed by sizeof. */ +#cmakedefine SIZEOF_LONG_DOUBLE @SIZEOF_LONG_DOUBLE@ + +/* The size of `size_t', as computed by sizeof. */ +#define SIZEOF_SIZE_T @SIZEOF_SIZE_T@ + +/* If using the C implementation of alloca, define if you know the + direction of stack growth for your system; otherwise it will be + automatically deduced at runtime. + STACK_DIRECTION > 0 => grows toward higher addresses + STACK_DIRECTION < 0 => grows toward lower addresses + STACK_DIRECTION = 0 => direction of growth unknown */ +/* #undef STACK_DIRECTION */ + +/* Define to 1 if you have the ANSI C header files. */ +#cmakedefine STDC_HEADERS 1 + +/* Define if symbols are underscored. */ +#cmakedefine SYMBOL_UNDERSCORE 1 + +/* Define this if you are using Purify and want to suppress spurious messages. + */ +/* #undef USING_PURIFY */ + +/* Version number of package */ +#define VERSION "@LIBFFI_VERSION@" + +/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most + significant byte first (like Motorola and SPARC, unlike Intel). */ +#if defined AC_APPLE_UNIVERSAL_BUILD +# if defined __BIG_ENDIAN__ +# define WORDS_BIGENDIAN 1 +# endif +#else +# ifndef WORDS_BIGENDIAN +/* # undef WORDS_BIGENDIAN */ +# endif +#endif + +/* Define to `unsigned int' if does not define. */ +/* #undef size_t */ + +#ifdef HAVE_HIDDEN_VISIBILITY_ATTRIBUTE +#ifdef LIBFFI_ASM +#define FFI_HIDDEN(name) .hidden name +#else +#define FFI_HIDDEN __attribute__ ((visibility ("hidden"))) +#endif +#else +#ifdef LIBFFI_ASM +#define FFI_HIDDEN(name) +#else +#define FFI_HIDDEN +#endif +#endif + diff --git a/third/python-cmake/cmake/include/CMakeLists.txt b/third/python-cmake/cmake/include/CMakeLists.txt new file mode 100644 index 00000000..f75ede6e --- /dev/null +++ b/third/python-cmake/cmake/include/CMakeLists.txt @@ -0,0 +1,14 @@ +# Install all the header files in Include/ + +set(includedir ${INCLUDE_BUILD_DIR}) +file(GLOB_RECURSE hfiles RELATIVE ${includedir} "${includedir}/*") + +foreach(file ${hfiles}) + get_filename_component(path ${file} PATH) + if(WIN32) + file(COPY ${includedir}/${file} DESTINATION ${PROJECT_BINARY_DIR}/${INCLUDE_INSTALL_DIR}/${path}) + endif() + if(INSTALL_DEVELOPMENT) + install(FILES ${includedir}/${file} DESTINATION ${INCLUDE_INSTALL_DIR}/${path} COMPONENT Development) + endif() +endforeach() diff --git a/third/python-cmake/cmake/lib/CMakeLists.txt b/third/python-cmake/cmake/lib/CMakeLists.txt new file mode 100644 index 00000000..ac97ab4b --- /dev/null +++ b/third/python-cmake/cmake/lib/CMakeLists.txt @@ -0,0 +1,56 @@ +# Install all the python module source from Lib/ + +set(libdir ${SRC_DIR}/Lib) +file(GLOB_RECURSE libfiles RELATIVE ${libdir} "${libdir}/*") + +if(UNIX) + set(plat_subdir "plat-linux") +endif() + +foreach(file ${libfiles}) + # Don't install files for other platforms + string(REGEX MATCH "^plat-" is_platform_file "${file}") + if(plat_subdir) + string(REGEX MATCH "^${plat_subdir}" is_matching_platform_file "${file}") + endif() + + # Exclude tests if BUILD_TESTING is OFF + string(REGEX MATCH "^test" is_test "${file}") + set(include_file 1) + + if(is_test AND (NOT BUILD_TESTING OR NOT INSTALL_TEST)) + set(include_file 0) + endif() + + if(include_file AND (NOT is_platform_file OR is_matching_platform_file)) + get_filename_component(path ${file} PATH) + + # Copy lib files to build tree + file(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/${PYTHONHOME}/${path}) + file(COPY ${libdir}/${file} DESTINATION ${PROJECT_BINARY_DIR}/${PYTHONHOME}/${path}) + + # Install + install(FILES ${libdir}/${file} DESTINATION ${PYTHONHOME}/${path}) + + endif() +endforeach() + +# Generate grammar tables in install directory +# XXX Should a custom target be added to generate file at built time ? +install(CODE "find_program( + PYTHON_EXECUTABLE python + HINTS \$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${BIN_INSTALL_DIR} + NO_DEFAULT_PATH) +set(wrapper) +if(UNIX) + set(_envvar LD_LIBRARY_PATH) + if(APPLE) + set(_envvar DYLD_LIBRARY_PATH) + endif() + set(wrapper env \${_envvar}=\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${LIBPYTHON_LIBDIR}) +endif() +execute_process(COMMAND \${wrapper} \${PYTHON_EXECUTABLE} -m lib2to3.pgen2.driver + \$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${PYTHONHOME}/lib2to3/Grammar.txt) +execute_process(COMMAND \${wrapper} \${PYTHON_EXECUTABLE} -m lib2to3.pgen2.driver + \$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${PYTHONHOME}/lib2to3/PatternGrammar.txt) +") diff --git a/third/python-cmake/cmake/libpython/CMakeLists.txt b/third/python-cmake/cmake/libpython/CMakeLists.txt new file mode 100644 index 00000000..c344b674 --- /dev/null +++ b/third/python-cmake/cmake/libpython/CMakeLists.txt @@ -0,0 +1,1045 @@ +add_definitions(-DPy_BUILD_CORE) +add_definitions(-DPy_BUILD_CORE_BUILTIN) +add_definitions(-DNDEBUG) + +set(MODULE_SOURCES # Equivalent to MODULE_OBJS in Makefile.pre + ${SRC_DIR}/Modules/gcmodule.c + ${SRC_DIR}/Modules/main.c +) +if(UNIX OR PY_VERSION VERSION_LESS "3.11") + list(APPEND MODULE_SOURCES + ${PROJECT_BINARY_DIR}/CMakeFiles/config.c + ) +endif() +if(UNIX) + list(APPEND MODULE_SOURCES + # Starting with Python 3.11 "Modules/getpath.c" is deepfrozen and later appended to LIBPYTHON_SOURCES + $<$:${SRC_DIR}/Modules/getpath.c> + ) + set(PYTHONPATH "${EXTRA_PYTHONPATH}:lib-dynload:plat-${PY_PLATFORM}") + if(PY_VERSION VERSION_GREATER_EQUAL "3.11") + set(PYTHONPATH "${PYTHONPATH}:lib/python${PY_VERSION_MAJOR}.${PY_VERSION_MINOR}") + set(PYTHONPATH "${PYTHONPATH}:lib/python${PY_VERSION_MAJOR}.${PY_VERSION_MINOR}/lib-dynload") + endif() + if(ENABLE_TKINTER) + set(PYTHONPATH "${PYTHONPATH}:lib-tk") + endif() + set_property( + SOURCE ${SRC_DIR}/Modules/getpath.c + PROPERTY COMPILE_DEFINITIONS + PREFIX="${CMAKE_INSTALL_PREFIX}" + EXEC_PREFIX="${CMAKE_INSTALL_PREFIX}" + VERSION="${PY_VERSION_MAJOR}.${PY_VERSION_MINOR}" + VPATH="." + PYTHONPATH="${PYTHONPATH}" + PLATLIBDIR="${LIBDIR}" # Introduced in Python 3.11 + ) +endif() + +# Removed in Python 3.11 +if(WIN32 AND PY_VERSION VERSION_LESS "3.11") + list(APPEND MODULE_SOURCES + ${SRC_DIR}/PC/getpathp.c + ) + # HACK To workaround limitation in escaping logic of CMake, the pythonpath + # separator is conditionally set depending of the version of Visual Studio. + # See http://cmake.org/Bug/view.php?id=14073 + if( ("${MSVC_VERSION}" VERSION_GREATER "1599") AND ("${CMAKE_GENERATOR}" MATCHES "^Visual Studio") ) + set(PATHSEP "%3B") + elseif( (${MSVC}) AND ("${CMAKE_GENERATOR}" MATCHES "^Ninja") ) + set(PATHSEP "\;") + elseif( (${MSVC}) AND ("${CMAKE_GENERATOR}" MATCHES "^NMake") ) + set(PATHSEP "\;") + elseif(MINGW) + set(PATHSEP "\;") + else() + set(PATHSEP ";") + endif() + string(REPLACE "/" "\\\\" PYTHONHOME_ESCAPED ${PYTHONHOME}) + string(REPLACE "/" "\\\\" EXTENSION_INSTALL_DIR_ESCAPED ${EXTENSION_INSTALL_DIR}) + set(PYTHONPATH "${EXTRA_PYTHONPATH}") + set(PYTHONPATH "${PYTHONPATH}${PATHSEP}.\\\\${PYTHONHOME_ESCAPED}") + set(PYTHONPATH "${PYTHONPATH}${PATHSEP}.\\\\${EXTENSION_INSTALL_DIR_ESCAPED}") + set(PYTHONPATH "${PYTHONPATH}${PATHSEP}.\\\\${EXTENSION_INSTALL_DIR_ESCAPED}\\\\${CMAKE_CFG_INTDIR}") + set(PYTHONPATH "${PYTHONPATH}${PATHSEP}.\\\\${PYTHONHOME_ESCAPED}\\\\plat-${PY_PLATFORM}") + if(ENABLE_TKINTER) + set(PYTHONPATH "${PYTHONPATH}${PATHSEP}.\\\\${PYTHONHOME_ESCAPED}\\\\lib-tk") + endif() + + set(_wide_char_modifier "L") + + set_property( + SOURCE ${SRC_DIR}/PC/getpathp.c + PROPERTY COMPILE_DEFINITIONS + "LANDMARK=${_wide_char_modifier}\"${PYTHONHOME_ESCAPED}\\\\os.py\"" + "PYTHONPATH=${_wide_char_modifier}\"${PYTHONPATH}\"" + "PY3_DLLNAME=${_wide_char_modifier}\"python3$<$:_d>\"" + ) +endif() + +set(PARSER_COMMON_SOURCES # Equivalent to POBJS in Makefile.pre + ${SRC_DIR}/Parser/parser.c + + # Removed in Python 3.8 + $<$:${SRC_DIR}/Parser/bitset.c> + $<$:${SRC_DIR}/Parser/firstsets.c> + $<$:${SRC_DIR}/Parser/grammar.c> + $<$:${SRC_DIR}/Parser/metagrammar.c> + $<$:${SRC_DIR}/Parser/pgen.c> + + # Introduced in Python 3.8 + $<$:${SRC_DIR}/Parser/myreadline.c> + $<$:${SRC_DIR}/Parser/token.c> + $<$:${SRC_DIR}/Parser/tokenizer.c> + + # Introduced in Python 3.8 and removed in Python 3.10 + $<$,$>:${SRC_DIR}/Parser/parsetok.c> + + # Introduced in Python 3.9 and removed in Python 3.10 + $<$:${SRC_DIR}/Parser/pegen/pegen.c> + $<$:${SRC_DIR}/Parser/pegen/parse.c> + $<$:${SRC_DIR}/Parser/pegen/parse_string.c> + $<$:${SRC_DIR}/Parser/pegen/peg_api.c> + + # Removed in Python 3.10 + $<$:${SRC_DIR}/Parser/acceler.c> + $<$:${SRC_DIR}/Parser/grammar1.c> + $<$:${SRC_DIR}/Parser/listnode.c> + $<$:${SRC_DIR}/Parser/node.c> + + # Introduced in Python 3.10 + $<$:${SRC_DIR}/Parser/peg_api.c> + $<$:${SRC_DIR}/Parser/pegen.c> + $<$:${SRC_DIR}/Parser/string_parser.c> + + # Introduced in Python 3.11 + $<$:${SRC_DIR}/Parser/action_helpers.c> + $<$:${SRC_DIR}/Parser/pegen_errors.c> +) + +set(OBJECT_COMMON_SOURCES # Equivalent to OBJECT_OBJS in Makefile.pre + # Removed in Python 3.12 + $<$:${SRC_DIR}/Objects/accu.c> + + ${SRC_DIR}/Objects/bytesobject.c + $<$:${SRC_DIR}/PC/invalid_parameter_handler.c> + ${SRC_DIR}/Objects/abstract.c + ${SRC_DIR}/Objects/boolobject.c + ${SRC_DIR}/Objects/bytearrayobject.c + ${SRC_DIR}/Objects/bytes_methods.c + ${SRC_DIR}/Objects/capsule.c + ${SRC_DIR}/Objects/cellobject.c + ${SRC_DIR}/Objects/classobject.c + ${SRC_DIR}/Objects/codeobject.c + ${SRC_DIR}/Objects/complexobject.c + ${SRC_DIR}/Objects/descrobject.c + ${SRC_DIR}/Objects/dictobject.c + ${SRC_DIR}/Objects/enumobject.c + ${SRC_DIR}/Objects/exceptions.c + ${SRC_DIR}/Objects/fileobject.c + ${SRC_DIR}/Objects/floatobject.c + ${SRC_DIR}/Objects/frameobject.c + ${SRC_DIR}/Objects/funcobject.c + ${SRC_DIR}/Objects/genobject.c + ${SRC_DIR}/Objects/iterobject.c + ${SRC_DIR}/Objects/listobject.c + ${SRC_DIR}/Objects/longobject.c + ${SRC_DIR}/Objects/memoryobject.c + ${SRC_DIR}/Objects/methodobject.c + ${SRC_DIR}/Objects/moduleobject.c + ${SRC_DIR}/Objects/object.c + ${SRC_DIR}/Objects/obmalloc.c + ${SRC_DIR}/Objects/rangeobject.c + ${SRC_DIR}/Objects/setobject.c + ${SRC_DIR}/Objects/sliceobject.c + ${SRC_DIR}/Objects/structseq.c + ${SRC_DIR}/Objects/tupleobject.c + ${SRC_DIR}/Objects/typeobject.c + ${SRC_DIR}/Objects/unicodectype.c + ${SRC_DIR}/Objects/unicodeobject.c + ${SRC_DIR}/Objects/weakrefobject.c + + # Introduced in Python 3.3 + $<$:${SRC_DIR}/Objects/namespaceobject.c> + + # Introduced in Python 3.5 + $<$:${SRC_DIR}/Objects/odictobject.c> + + # Introduced in Python 3.7 + $<$:${SRC_DIR}/Objects/call.c> + + # Introduced in Python 3.8 + $<$:${SRC_DIR}/Objects/interpreteridobject.c> + $<$:${SRC_DIR}/Objects/picklebufobject.c> + + # Introduced in Python 3.9 + $<$:${SRC_DIR}/Objects/genericaliasobject.c> + + # Introduced in Python 3.10 + $<$:${SRC_DIR}/Objects/unionobject.c> + + # Introduced in Python 3.12 + $<$:${SRC_DIR}/Objects/typevarobject.c> +) + +if(CMAKE_C_COMPILER_ID MATCHES GNU) + foreach(filename class complex float int method string type unicode weakref) + set_property(SOURCE ${SRC_DIR}/Objects/${filename}object.c PROPERTY COMPILE_FLAGS -Wno-unused-value) + endforeach() +endif() + +set(DYNLOAD_SOURCES + ) + +if(UNIX AND HAVE_DLOPEN) + list(APPEND DYNLOAD_SOURCES + ${SRC_DIR}/Python/dynload_shlib.c + ) + set_property( + SOURCE ${SRC_DIR}/Python/dynload_shlib.c + PROPERTY COMPILE_DEFINITIONS + SOABI="${SOABI}" + #MULTIARCH + ) +elseif(WIN32) + list(APPEND DYNLOAD_SOURCES + $<$:${SRC_DIR}/PC/dl_nt.c> + ${SRC_DIR}/Python/dynload_win.c + ) + set(ms_dll_id "${PY_VERSION_MAJOR}.${PY_VERSION_MINOR}") + if(${CMAKE_SIZEOF_VOID_P} EQUAL 4) + set(ms_dll_id "${ms_dll_id}-32") + endif() + set_property( + SOURCE ${SRC_DIR}/PC/dl_nt.c + PROPERTY COMPILE_DEFINITIONS + Py_ENABLE_SHARED + MS_DLL_ID="${ms_dll_id}" + ) + set(_wide_char_modifier "L") + set_property( + SOURCE ${SRC_DIR}/Python/dynload_win.c + PROPERTY COMPILE_DEFINITIONS + "PY3_DLLNAME=${_wide_char_modifier}\"python3$<$:_d>\"" # Python 3.11 + ) +endif() + +set(PYTHON_COMMON_SOURCES + ${DYNLOAD_SOURCES} + ${SRC_DIR}/Python/dynamic_annotations.c + ${SRC_DIR}/Python/fileutils.c + ${SRC_DIR}/Python/pystrtod.c + ${SRC_DIR}/Python/pytime.c + ${SRC_DIR}/Python/asdl.c + ${SRC_DIR}/Python/ast.c + ${SRC_DIR}/Python/bltinmodule.c + ${SRC_DIR}/Python/ceval.c + ${SRC_DIR}/Python/codecs.c + ${SRC_DIR}/Python/compile.c + ${SRC_DIR}/Python/dtoa.c + ${SRC_DIR}/Python/errors.c + ${SRC_DIR}/Python/formatter_unicode.c + ${SRC_DIR}/Python/future.c + ${SRC_DIR}/Python/getargs.c + ${SRC_DIR}/Python/getcompiler.c + ${SRC_DIR}/Python/getcopyright.c + ${SRC_DIR}/Python/getopt.c + ${SRC_DIR}/Python/getplatform.c + ${SRC_DIR}/Python/getversion.c + ${SRC_DIR}/Python/import.c + ${SRC_DIR}/Python/importdl.c + ${SRC_DIR}/Python/marshal.c + ${SRC_DIR}/Python/modsupport.c + ${SRC_DIR}/Python/mysnprintf.c + ${SRC_DIR}/Python/mystrtoul.c + ${SRC_DIR}/Python/pyarena.c + ${SRC_DIR}/Python/pyctype.c + ${SRC_DIR}/Python/pyfpe.c + ${SRC_DIR}/Python/pymath.c + ${SRC_DIR}/Python/pystate.c + ${SRC_DIR}/Python/pystrcmp.c + ${SRC_DIR}/Python/Python-ast.c + ${SRC_DIR}/Python/pythonrun.c + ${SRC_DIR}/Python/structmember.c + ${SRC_DIR}/Python/symtable.c + ${SRC_DIR}/Python/sysmodule.c + ${SRC_DIR}/Python/traceback.c + ${SRC_DIR}/Python/_warnings.c + + # Introduced in Python 3.4 + $<$:${SRC_DIR}/Python/pyhash.c> + + # Introduced in Python 3.5 + $<$:${SRC_DIR}/Python/pylifecycle.c> + $<$:${SRC_DIR}/Python/pystrhex.c> + + # Removed in Python 3.7 + $<$:${SRC_DIR}/Python/random.c> + + # Introduced in Python 3.7 + $<$:${SRC_DIR}/Python/ast_opt.c> + $<$:${SRC_DIR}/Python/ast_unparse.c> + $<$:${SRC_DIR}/Python/bootstrap_hash.c> + $<$:${SRC_DIR}/Python/context.c> + $<$:${SRC_DIR}/Python/hamt.c> + $<$:${SRC_DIR}/Python/pathconfig.c> + $<$,$>:${SRC_DIR}/Python/thread.c> + + # Introduced in Python 3.8 + $<$:${SRC_DIR}/Python/initconfig.c> + $<$:${SRC_DIR}/Python/preconfig.c> + + # Removed in Python 3.10 + $<$:${SRC_DIR}/Python/graminit.c> + $<$:${SRC_DIR}/Python/peephole.c> + + # Introduced in Python 3.10 + $<$:${SRC_DIR}/Python/suggestions.c> + + # Introduced in Python 3.11 + $<$:${SRC_DIR}/Python/Python-tokenize.c> + $<$:${SRC_DIR}/Python/frame.c> + $<$:${SRC_DIR}/Python/specialize.c> + + # Introduced in Python 3.12 + $<$:${SRC_DIR}/Python/assemble.c> + $<$:${SRC_DIR}/Python/ceval_gil.c> + $<$:${SRC_DIR}/Python/flowgraph.c> + $<$:${SRC_DIR}/Python/instrumentation.c> + $<$:${SRC_DIR}/Python/intrinsics.c> + $<$:${SRC_DIR}/Python/legacy_tracing.c> + $<$:${SRC_DIR}/Python/perf_trampoline.c> + $<$:${SRC_DIR}/Python/tracemalloc.c> +) + +if(UNIX) + list(APPEND PYTHON_COMMON_SOURCES + ${SRC_DIR}/Python/frozenmain.c + ) +else() + list(APPEND PYTHON_COMMON_SOURCES + # Removed in Python 3.11 + $<$:${SRC_DIR}/Python/frozen.c> + ) +endif() + +if(UNIX OR MINGW) + set_property( + SOURCE ${SRC_DIR}/Python/getplatform.c + PROPERTY COMPILE_DEFINITIONS + PLATFORM="${PY_PLATFORM}" + ) +endif() +if(UNIX OR MINGW OR PY_VERSION VERSION_GREATER_EQUAL "3.11") + set_property( + SOURCE ${SRC_DIR}/Python/sysmodule.c + PROPERTY COMPILE_DEFINITIONS + VPATH="..\\\\.." # Python 3.11 + ABIFLAGS="${ABIFLAGS}" + ) +endif() + +# Introduced in Python 3.10 and removed in Python 3.11 +if(WIN32 AND "${PY_VERSION_MAJOR}.${PY_VERSION_MINOR}" VERSION_EQUAL "3.10") + set(_wide_char_modifier "L") + set_property( + SOURCE ${SRC_DIR}/Python/pathconfig.c + PROPERTY COMPILE_DEFINITIONS + "PY3_DLLNAME=${_wide_char_modifier}\"python3$<$:_d>\"" + ) +endif() + +list(APPEND MODULE_SOURCES + ${SRC_DIR}/Modules/signalmodule.c +) + +set(LIBPYTHON_OMIT_FROZEN_SOURCES + ${SRC_DIR}/Modules/getbuildinfo.c + ${MODULE_SOURCES} + ${OBJECT_COMMON_SOURCES} + ${PARSER_COMMON_SOURCES} + ${PYTHON_COMMON_SOURCES} + + $<$:${SRC_DIR}/Parser/myreadline.c> + $<$:${SRC_DIR}/Parser/parsetok.c> + $<$:${SRC_DIR}/Parser/tokenizer.c> +) + +# List of builtin extensions +get_property(builtin_extensions GLOBAL PROPERTY builtin_extensions) + +# Collect builtin extension sources +set(builtin_extension_sources) +foreach(name ${builtin_extensions}) + get_property(extension_${name}_sources GLOBAL PROPERTY extension_${name}_sources) + list(APPEND builtin_extension_sources ${extension_${name}_sources}) +endforeach() + +# XXX Associate Py_NO_ENABLE_SHARED with "_ctypes/callbacks.c" if corresponding +# extension is builtin. +if(WIN32) + foreach(src ${builtin_extension_sources}) + get_filename_component(filename ${src} NAME) + if(${filename} STREQUAL "callbacks.c") + set_property(SOURCE ${src} APPEND PROPERTY COMPILE_DEFINITIONS Py_NO_ENABLE_SHARED) + endif() + endforeach() +endif() +list(APPEND LIBPYTHON_OMIT_FROZEN_SOURCES ${builtin_extension_sources}) + +# Collect builtin extension link libraries +set(builtin_link_libraries) +foreach(name ${builtin_extensions}) + get_property(extension_${name}_link_libraries GLOBAL PROPERTY extension_${name}_link_libraries) + list(APPEND builtin_link_libraries ${extension_${name}_link_libraries}) +endforeach() + +# Collect builtin extension includedirs +set(builtin_includedirs) +foreach(name ${builtin_extensions}) + get_property(extension_${name}_includedirs GLOBAL PROPERTY extension_${name}_includedirs) + list(APPEND builtin_includedirs ${extension_${name}_includedirs}) +endforeach() + +# Collect builtin extension definitions +set(builtin_compile_definitions_without_py_limited_api) +foreach(name ${builtin_extensions}) + get_property(extension_${name}_definitions GLOBAL PROPERTY extension_${name}_definitions) + if(extension_${name}_definitions) + set_property(SOURCE ${extension_${name}_sources} + APPEND PROPERTY COMPILE_DEFINITIONS ${extension_${name}_definitions}) + # Workaround for CMake issue #26993 (https://gitlab.kitware.com/cmake/cmake/-/issues/26993): + # Generator expressions are not supported in the SOURCE argument of set_property(). + # Collect compile definitions here to propagate them via target_compile_definitions(). + if(NOT ${name} STREQUAL "xxlimited") + list(APPEND builtin_compile_definitions_without_py_limited_api ${extension_${name}_definitions}) + endif() + endif() +endforeach() + +include_directories(${builtin_includedirs}) + +# Create the parts of config.c for platform-specific and user-controlled +# builtin modules. +set(init_return_type "PyObject*") +set(init_prefix "PyInit_") + +set(config_inits "") +set(config_entries "") +foreach(ext ${builtin_extensions}) + set(config_inits "${config_inits}extern ${init_return_type} ${init_prefix}${ext}(void);\n") + set(config_entries "${config_entries} {\"${ext}\", ${init_prefix}${ext}},\n") +endforeach() + +if(PY_VERSION VERSION_GREATER_EQUAL "3.7") + set(PyInit_imp "PyInit__imp") +else() + set(PyInit_imp "PyInit_imp") +endif() + +configure_file( + ${PROJECT_SOURCE_DIR}/cmake/config_${PY_VERSION_MAJOR}.c.in + ${PROJECT_BINARY_DIR}/CMakeFiles/config.c + ) + +if(WIN32 AND PY_VERSION VERSION_GREATER_EQUAL "3.11") +set(config_inits "") +set(minimal_builtin_extensions _codecs _collections _io _imp _sre _thread _tracemalloc _weakref errno faulthandler itertools time) +if(PY_VERSION VERSION_GREATER_EQUAL "3.12") + list(APPEND minimal_builtin_extensions _typing _winapi) +endif() +if(WIN32) + list(APPEND minimal_builtin_extensions nt winreg) + set(config_inits "${config_inits}/* Define extern variables omitted from minimal builds */\n") + set(config_inits "${config_inits}void *PyWin_DLLhModule = NULL;\n\n") +endif() +set(config_entries "") +foreach(ext IN LISTS minimal_builtin_extensions) + set(config_inits "${config_inits}extern ${init_return_type} ${init_prefix}${ext}(void);\n") + set(config_entries "${config_entries} {\"${ext}\", ${init_prefix}${ext}},\n") +endforeach() +configure_file( + ${PROJECT_SOURCE_DIR}/cmake/config_${PY_VERSION_MAJOR}.c.in + ${PROJECT_BINARY_DIR}/CMakeFiles/config_minimal.c + ) +endif() + +# Collect libpython target libraries +set(LIBPYTHON_TARGET_LIBRARIES + ${builtin_link_libraries} + ) +if(HAVE_LIBDL) + list(APPEND LIBPYTHON_TARGET_LIBRARIES ${HAVE_LIBDL}) +endif() +if(WITH_THREAD OR PY_VERSION VERSION_GREATER_EQUAL "3.7") + list(APPEND LIBPYTHON_TARGET_LIBRARIES ${CMAKE_THREAD_LIBS_INIT}) +endif() +if(UNIX) + list(APPEND LIBPYTHON_TARGET_LIBRARIES ${LIBUTIL_LIBRARIES} ${M_LIBRARIES}) +endif() +if(WIN32) + list(APPEND LIBPYTHON_TARGET_LIBRARIES + ws2_32 # Required by signalmodule + $<$:version> # Required by sysmodule + $<$:shlwapi> # Required by PC/getpathp + $<$:pathcch> + $<$:bcrypt> # Required by bootstrap_hash + ) +endif() + +set(LIBPYTHON_FROZEN_SOURCES ) + +# Build _freeze_importlib executable +add_executable(_freeze_importlib + + # Introduced in Python 3.3 and removed in Python 3.11 + $<$,$>:${SRC_DIR}/$,Programs,Modules>/_freeze_importlib.c> + + # Introduced in Python 3.11 + $<$:${SRC_DIR}/Programs/_freeze_module.c> + $<$:${SRC_DIR}/Modules/getpath_noop.c> + $<$,$>:${PROJECT_BINARY_DIR}/CMakeFiles/config_minimal.c> + + ${LIBPYTHON_OMIT_FROZEN_SOURCES} + ) +target_link_libraries(_freeze_importlib ${LIBPYTHON_TARGET_LIBRARIES}) +if(builtin_compile_definitions_without_py_limited_api) + # Workaround for CMake issue #26993 (https://gitlab.kitware.com/cmake/cmake/-/issues/26993): + # Explicitly propagate built-in extension definitions to this target. + # These would otherwise be lost due to generator expression limitations in set_property(). + target_compile_definitions(_freeze_importlib PRIVATE ${builtin_compile_definitions_without_py_limited_api}) +endif() +target_compile_definitions(_freeze_importlib + PUBLIC + Py_NO_ENABLE_SHARED +) + +# Freeze modules for Python < 3.11 +if(PY_VERSION VERSION_LESS "3.11") +set(LIBPYTHON_FROZEN_SOURCES + ${SRC_DIR}/Python/importlib_external.h + ${SRC_DIR}/Python/importlib.h + $<$:${SRC_DIR}/Python/importlib_zipimport.h> +) +add_custom_command( + OUTPUT ${LIBPYTHON_FROZEN_SOURCES} + COMMAND + _freeze_importlib + $<$:importlib._bootstrap_external> + ${SRC_DIR}/Lib/importlib/_bootstrap_external.py + ${SRC_DIR}/Python/importlib_external.h + COMMAND + _freeze_importlib + $<$:importlib._bootstrap> + ${SRC_DIR}/Lib/importlib/_bootstrap.py + ${SRC_DIR}/Python/importlib.h + DEPENDS + _freeze_importlib + ${SRC_DIR}/Lib/importlib/_bootstrap_external.py + ${SRC_DIR}/Lib/importlib/_bootstrap.py +) + +if(PY_VERSION VERSION_GREATER_EQUAL "3.8") + add_custom_command( + OUTPUT ${LIBPYTHON_FROZEN_SOURCES} + COMMAND + _freeze_importlib + zipimport + ${SRC_DIR}/Lib/zipimport.py + ${SRC_DIR}/Python/importlib_zipimport.h + DEPENDS + ${SRC_DIR}/Lib/zipimport.py + APPEND + ) +endif() +endif() + +# Freeze modules for Python >= 3.11 +if(PY_VERSION VERSION_GREATER_EQUAL "3.11") + +set(LIBPYTHON_FROZEN_SOURCES + ${SRC_DIR}/Python/frozen_modules/importlib._bootstrap.h + ${SRC_DIR}/Python/frozen_modules/importlib._bootstrap_external.h + ${SRC_DIR}/Python/frozen_modules/zipimport.h + ${SRC_DIR}/Python/frozen_modules/abc.h + ${SRC_DIR}/Python/frozen_modules/codecs.h + ${SRC_DIR}/Python/frozen_modules/io.h + ${SRC_DIR}/Python/frozen_modules/_collections_abc.h + ${SRC_DIR}/Python/frozen_modules/_sitebuiltins.h + ${SRC_DIR}/Python/frozen_modules/genericpath.h + ${SRC_DIR}/Python/frozen_modules/ntpath.h + ${SRC_DIR}/Python/frozen_modules/posixpath.h + ${SRC_DIR}/Python/frozen_modules/os.h + ${SRC_DIR}/Python/frozen_modules/site.h + ${SRC_DIR}/Python/frozen_modules/stat.h + ${SRC_DIR}/Python/frozen_modules/importlib.util.h + ${SRC_DIR}/Python/frozen_modules/importlib.machinery.h + ${SRC_DIR}/Python/frozen_modules/runpy.h + ${SRC_DIR}/Python/frozen_modules/__hello__.h + ${SRC_DIR}/Python/frozen_modules/__phello__.h + ${SRC_DIR}/Python/frozen_modules/__phello__.ham.h + ${SRC_DIR}/Python/frozen_modules/__phello__.ham.eggs.h + ${SRC_DIR}/Python/frozen_modules/__phello__.spam.h + ${SRC_DIR}/Python/frozen_modules/frozen_only.h + ${SRC_DIR}/Python/frozen_modules/getpath.h +) +add_custom_command( + OUTPUT ${LIBPYTHON_FROZEN_SOURCES} + COMMAND + _freeze_importlib + importlib._bootstrap + ${SRC_DIR}/Lib/importlib/_bootstrap.py + ${SRC_DIR}/Python/frozen_modules/importlib._bootstrap.h + COMMAND + _freeze_importlib + importlib._bootstrap_external + ${SRC_DIR}/Lib/importlib/_bootstrap_external.py + ${SRC_DIR}/Python/frozen_modules/importlib._bootstrap_external.h + COMMAND + _freeze_importlib + zipimport + ${SRC_DIR}/Lib/zipimport.py + ${SRC_DIR}/Python/frozen_modules/zipimport.h + COMMAND + _freeze_importlib + abc + ${SRC_DIR}/Lib/abc.py + ${SRC_DIR}/Python/frozen_modules/abc.h + COMMAND + _freeze_importlib + codecs + ${SRC_DIR}/Lib/codecs.py + ${SRC_DIR}/Python/frozen_modules/codecs.h + COMMAND + _freeze_importlib + io + ${SRC_DIR}/Lib/io.py + ${SRC_DIR}/Python/frozen_modules/io.h + COMMAND + _freeze_importlib + _collections_abc + ${SRC_DIR}/Lib/_collections_abc.py + ${SRC_DIR}/Python/frozen_modules/_collections_abc.h + COMMAND + _freeze_importlib + _sitebuiltins + ${SRC_DIR}/Lib/_sitebuiltins.py + ${SRC_DIR}/Python/frozen_modules/_sitebuiltins.h + COMMAND + _freeze_importlib + genericpath + ${SRC_DIR}/Lib/genericpath.py + ${SRC_DIR}/Python/frozen_modules/genericpath.h + COMMAND + _freeze_importlib + ntpath + ${SRC_DIR}/Lib/ntpath.py + ${SRC_DIR}/Python/frozen_modules/ntpath.h + COMMAND + _freeze_importlib + posixpath + ${SRC_DIR}/Lib/posixpath.py + ${SRC_DIR}/Python/frozen_modules/posixpath.h + COMMAND + _freeze_importlib + os + ${SRC_DIR}/Lib/os.py + ${SRC_DIR}/Python/frozen_modules/os.h + COMMAND + _freeze_importlib + site + ${SRC_DIR}/Lib/site.py + ${SRC_DIR}/Python/frozen_modules/site.h + COMMAND + _freeze_importlib + stat + ${SRC_DIR}/Lib/stat.py + ${SRC_DIR}/Python/frozen_modules/stat.h + COMMAND + _freeze_importlib + importlib.util + ${SRC_DIR}/Lib/importlib/util.py + ${SRC_DIR}/Python/frozen_modules/importlib.util.h + COMMAND + _freeze_importlib + importlib.machinery + ${SRC_DIR}/Lib/importlib/machinery.py + ${SRC_DIR}/Python/frozen_modules/importlib.machinery.h + COMMAND + _freeze_importlib + runpy + ${SRC_DIR}/Lib/runpy.py + ${SRC_DIR}/Python/frozen_modules/runpy.h + COMMAND + _freeze_importlib + __hello__ + ${SRC_DIR}/Lib/__hello__.py + ${SRC_DIR}/Python/frozen_modules/__hello__.h + COMMAND + _freeze_importlib + __phello__ + ${SRC_DIR}/Lib/__phello__/__init__.py + ${SRC_DIR}/Python/frozen_modules/__phello__.h + COMMAND + _freeze_importlib + __phello__.ham + ${SRC_DIR}/Lib/__phello__/ham/__init__.py + ${SRC_DIR}/Python/frozen_modules/__phello__.ham.h + COMMAND + _freeze_importlib + __phello__.ham.eggs + ${SRC_DIR}/Lib/__phello__/ham/eggs.py + ${SRC_DIR}/Python/frozen_modules/__phello__.ham.eggs.h + COMMAND + _freeze_importlib + __phello__.spam + ${SRC_DIR}/Lib/__phello__/spam.py + ${SRC_DIR}/Python/frozen_modules/__phello__.spam.h + COMMAND + _freeze_importlib + frozen_only + ${SRC_DIR}/Tools/freeze/flag.py + ${SRC_DIR}/Python/frozen_modules/frozen_only.h + COMMAND + _freeze_importlib + getpath + ${SRC_DIR}/Modules/getpath.py + ${SRC_DIR}/Python/frozen_modules/getpath.h + DEPENDS + _freeze_importlib + ${SRC_DIR}/Lib/importlib/_bootstrap.py + ${SRC_DIR}/Lib/importlib/_bootstrap_external.py + ${SRC_DIR}/Lib/zipimport.py + ${SRC_DIR}/Lib/abc.py + ${SRC_DIR}/Lib/codecs.py + ${SRC_DIR}/Lib/io.py + ${SRC_DIR}/Lib/_collections_abc.py + ${SRC_DIR}/Lib/_sitebuiltins.py + ${SRC_DIR}/Lib/genericpath.py + ${SRC_DIR}/Lib/ntpath.py + ${SRC_DIR}/Lib/posixpath.py + ${SRC_DIR}/Lib/os.py + ${SRC_DIR}/Lib/site.py + ${SRC_DIR}/Lib/stat.py + ${SRC_DIR}/Lib/importlib/util.py + ${SRC_DIR}/Lib/importlib/machinery.py + ${SRC_DIR}/Lib/runpy.py + ${SRC_DIR}/Lib/__hello__.py + ${SRC_DIR}/Lib/__phello__/__init__.py + ${SRC_DIR}/Lib/__phello__/ham/__init__.py + ${SRC_DIR}/Lib/__phello__/ham/eggs.py + ${SRC_DIR}/Lib/__phello__/spam.py + ${SRC_DIR}/Tools/freeze/flag.py + ${SRC_DIR}/Modules/getpath.py + ) +endif() + +# This is a convenience target allowing to regenerate +# the frozen sources. +add_custom_target(freeze_modules DEPENDS + ${LIBPYTHON_FROZEN_SOURCES} +) + +set(LIBPYTHON_DEEPFREEZE_SOURCES ) + +if(PY_VERSION VERSION_GREATER_EQUAL "3.11") + +# Build _bootstrap_python executable +add_executable(_bootstrap_python + ${SRC_DIR}/Programs/_bootstrap_python.c + ${SRC_DIR}/Modules/getpath.c + $<$:${PROJECT_BINARY_DIR}/CMakeFiles/config_minimal.c> + ${LIBPYTHON_OMIT_FROZEN_SOURCES} + ${LIBPYTHON_FROZEN_SOURCES} +) +target_link_libraries(_bootstrap_python ${LIBPYTHON_TARGET_LIBRARIES}) +if(builtin_compile_definitions_without_py_limited_api) + # Workaround for CMake issue #26993 (https://gitlab.kitware.com/cmake/cmake/-/issues/26993): + # Explicitly propagate built-in extension definitions to this target. + # These would otherwise be lost due to generator expression limitations in set_property(). + target_compile_definitions(_bootstrap_python PRIVATE ${builtin_compile_definitions_without_py_limited_api}) +endif() +target_compile_definitions(_bootstrap_python + PUBLIC + Py_NO_ENABLE_SHARED +) + +list(APPEND LIBPYTHON_DEEPFREEZE_SOURCES + ${SRC_DIR}/Python/deepfreeze/deepfreeze.c +) + +set(DEEPFREEZE_PY ${SRC_DIR}/Tools/$,build,scripts>/deepfreeze.py) + +add_custom_command( + OUTPUT ${LIBPYTHON_DEEPFREEZE_SOURCES} + COMMAND + _bootstrap_python + ${DEEPFREEZE_PY} + "${SRC_DIR}/Python/frozen_modules/importlib._bootstrap.h:importlib._bootstrap" + "${SRC_DIR}/Python/frozen_modules/importlib._bootstrap_external.h:importlib._bootstrap_external" + "${SRC_DIR}/Python/frozen_modules/zipimport.h:zipimport" + "${SRC_DIR}/Python/frozen_modules/abc.h:abc" + "${SRC_DIR}/Python/frozen_modules/codecs.h:codecs" + "${SRC_DIR}/Python/frozen_modules/io.h:io" + "${SRC_DIR}/Python/frozen_modules/_collections_abc.h:_collections_abc" + "${SRC_DIR}/Python/frozen_modules/_sitebuiltins.h:_sitebuiltins" + "${SRC_DIR}/Python/frozen_modules/genericpath.h:genericpath" + "${SRC_DIR}/Python/frozen_modules/ntpath.h:ntpath" + "${SRC_DIR}/Python/frozen_modules/posixpath.h:posixpath" + "${SRC_DIR}/Python/frozen_modules/os.h:os" + "${SRC_DIR}/Python/frozen_modules/site.h:site" + "${SRC_DIR}/Python/frozen_modules/stat.h:stat" + "${SRC_DIR}/Python/frozen_modules/importlib.util.h:importlib.util" + "${SRC_DIR}/Python/frozen_modules/importlib.machinery.h:importlib.machinery" + "${SRC_DIR}/Python/frozen_modules/runpy.h:runpy" + "${SRC_DIR}/Python/frozen_modules/__hello__.h:__hello__" + "${SRC_DIR}/Python/frozen_modules/__phello__.h:__phello__" + "${SRC_DIR}/Python/frozen_modules/__phello__.ham.h:__phello__.ham" + "${SRC_DIR}/Python/frozen_modules/__phello__.ham.eggs.h:__phello__.ham.eggs" + "${SRC_DIR}/Python/frozen_modules/__phello__.spam.h:__phello__.spam" + "${SRC_DIR}/Python/frozen_modules/frozen_only.h:frozen_only" + "-o" "${LIBPYTHON_DEEPFREEZE_SOURCES}" + DEPENDS + ${DEEPFREEZE_PY} + ${LIBPYTHON_FROZEN_SOURCES} +) + +# This is a convenience target allowing to regenerate +# the deepfreeze sources. +add_custom_target(deepfreeze_modules DEPENDS + ${LIBPYTHON_DEEPFREEZE_SOURCES} +) +endif() + +if(PY_VERSION VERSION_LESS "3.8") +# Build pgen executable +add_executable(pgen + ${PARSER_COMMON_SOURCES} + ${SRC_DIR}/Python/dynamic_annotations.c + ${SRC_DIR}/Objects/obmalloc.c + ${SRC_DIR}/Python/mysnprintf.c + ${SRC_DIR}/Python/pyctype.c + ${SRC_DIR}/Parser/tokenizer_pgen.c + ${SRC_DIR}/Parser/printgrammar.c + ${SRC_DIR}/Parser/pgenmain.c + + # Removed in Python 3.10 but excluded starting with Python 3.3 when the new parser + # was introduced. + # See cpython/cpython@1ed83adb0e9 ("bpo-40939: Remove the old parser (GH-20768)", 2020-06-11) + $<$:${SRC_DIR}/Parser/parsetok.c> + + # Introduced in Python 3.3 + $<$:${SRC_DIR}/Parser/parsetok_pgen.c> +) +if(builtin_compile_definitions_without_py_limited_api) + # Workaround for CMake issue #26993 (https://gitlab.kitware.com/cmake/cmake/-/issues/26993): + # Explicitly propagate built-in extension definitions to this target. + # These would otherwise be lost due to generator expression limitations in set_property(). + target_compile_definitions(pgen PRIVATE ${builtin_compile_definitions_without_py_limited_api}) +endif() +endif() + +# Collect libpython sources +set(LIBPYTHON_SOURCES + ${LIBPYTHON_OMIT_FROZEN_SOURCES} + ${LIBPYTHON_FROZEN_SOURCES} + ${LIBPYTHON_DEEPFREEZE_SOURCES} + $<$,$>:${SRC_DIR}/Python/frozen.c> + + # Introduced in Python 3.11 + $<$:${SRC_DIR}/Modules/getpath.c> + $<$:${SRC_DIR}/Modules/_typingmodule.c> + $<$,$>:${PROJECT_BINARY_DIR}/CMakeFiles/config.c> + $<$,$>:${SRC_DIR}/PC/dl_nt.c> +) +if(WIN32 AND PY_VERSION VERSION_GREATER_EQUAL "3.11") + set(PYTHONPATH "${EXTRA_PYTHONPATH}\\\;${LIBDIR}\\\\lib-dynload") + set(PYTHONPATH "${PYTHONPATH}\\\;${LIBDIR}\\\\lib-dynload\\\\$") + + set(_wide_char_modifier "L") + + set_property( + SOURCE ${SRC_DIR}/Modules/getpath.c + PROPERTY COMPILE_DEFINITIONS + PREFIX=NULL + EXEC_PREFIX=NULL + VERSION="${PY_VERSION_MAJOR}.${PY_VERSION_MINOR}" + VPATH="..\\\\.." + PYDEBUGEXT="$<$:_d>" + PLATLIBDIR="${LIBDIR}" + PYTHONPATH="${_wide_char_modifier}${PYTHONPATH}" + ) + set_property( + SOURCE ${SRC_DIR}/PC/dl_nt.c + PROPERTY COMPILE_DEFINITIONS + Py_ENABLE_SHARED + MS_DLL_ID="${ms_dll_id}" + ) +endif() + +# Build python libraries +function(add_libpython name type install component) + add_library(${name} ${type} ${LIBPYTHON_SOURCES}) + target_link_libraries(${name} ${LIBPYTHON_TARGET_LIBRARIES}) + + if(MSVC) + # Explicitly disable COMDAT folding. Note that this was not required + # in the original "pcbuild.sln" solution file because it was side effect + # of having "/Zi" flag set. + set_target_properties(${name} PROPERTIES LINK_FLAGS /OPT:NOICF) + endif() + + set_target_properties(${name} PROPERTIES + OUTPUT_NAME ${LIBPYTHON}${ABIFLAGS} + LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/${LIBPYTHON_LIBDIR} + RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/${LIBPYTHON_LIBDIR} + INSTALL_NAME_DIR ${CMAKE_INSTALL_PREFIX}/${LIBPYTHON_LIBDIR} + ) + set_target_properties(${name} PROPERTIES + POSITION_INDEPENDENT_CODE ON + ) + + if(builtin_compile_definitions_without_py_limited_api) + # Workaround for CMake issue #26993 (https://gitlab.kitware.com/cmake/cmake/-/issues/26993): + # Explicitly propagate built-in extension definitions to this target. + # These would otherwise be lost due to generator expression limitations in set_property(). + target_compile_definitions(${name} PRIVATE ${builtin_compile_definitions_without_py_limited_api}) + endif() + + # Export target + set_property(GLOBAL APPEND PROPERTY PYTHON_TARGETS ${name}) + + if(install) + install(TARGETS ${name} EXPORT PythonTargets + ARCHIVE DESTINATION ${LIBPYTHON_ARCHIVEDIR} + LIBRARY DESTINATION ${LIBPYTHON_LIBDIR} + RUNTIME DESTINATION ${LIBPYTHON_LIBDIR} + COMPONENT ${component} + ) + endif() +endfunction() + +if(BUILD_LIBPYTHON_SHARED) + add_libpython(libpython-shared SHARED 1 Runtime) + set_target_properties(libpython-shared PROPERTIES + ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/${LIBPYTHON_ARCHIVEDIR} + ) + if(APPLE) + # HACK For python <= 2.7.3, this fix link error related to undefined _environ symbol and + # is equivalent to solution implemented in commit http://hg.python.org/cpython/rev/864b983 + # The property is set here because source file properties can't be in one directory + # and used to build a target in an other directory. + set_property( + SOURCE ${SRC_DIR}/Modules/posixmodule.c + APPEND PROPERTY COMPILE_DEFINITIONS WITH_NEXT_FRAMEWORK) + endif() + + set(targetname "libpython3-shared") + + if(MSVC AND PY_VERSION VERSION_LESS "3.10") + # XXX Add BuildPython3_dDef + + # Generate 'python3stub.def' + set(pythonstub_def ${PROJECT_BINARY_DIR}/${LIBPYTHON_ARCHIVEDIR}/${CMAKE_CFG_INTDIR}/python3stub.def) + add_custom_command( + OUTPUT ${pythonstub_def} + COMMAND ${CMAKE_COMMAND} + -DINPUT_DEF_FILE:PATH=${SRC_DIR}/PC/python3.def + -DOUTPUT_DEF_FILE:PATH=${PROJECT_BINARY_DIR}/CMakeFiles/python3stub.def + -P ${CMAKE_CURRENT_SOURCE_DIR}/generate_libpythonstub_def.cmake + COMMAND ${CMAKE_COMMAND} -E copy_if_different + ${PROJECT_BINARY_DIR}/CMakeFiles/python3stub.def + ${pythonstub_def} + ) + add_custom_target(generate_libpython3stub_def DEPENDS ${pythonstub_def}) + + # Build 'python3stub.lib' before linking 'python3.dll' + set(python3stub_lib ${PROJECT_BINARY_DIR}/${LIBPYTHON_ARCHIVEDIR}/${CMAKE_CFG_INTDIR}/python3stub.lib) + set(machine X86) + if(${CMAKE_SIZEOF_VOID_P} EQUAL 8) + set(machine X64) + endif() + add_custom_command( + OUTPUT ${python3stub_lib} + COMMAND lib /nologo /def:${pythonstub_def} /out:${python3stub_lib} /MACHINE:${machine} + COMMENT "Rebuilding python3stub.lib" + DEPENDS generate_libpython3stub_def + VERBATIM + ) + add_custom_target(generate_libpython3stub_lib DEPENDS ${python3stub_lib}) + endif() + + if(MSVC) + # Build 'python3.dll' + add_library(${targetname} SHARED + ${SRC_DIR}/PC/python3dll.c + + # Removed in Python 3.10 + $<$:${SRC_DIR}/PC/python3.def> + ) + set_target_properties(${targetname} PROPERTIES + OUTPUT_NAME python3 + LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/${LIBPYTHON_LIBDIR} + RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/${LIBPYTHON_LIBDIR} + INSTALL_NAME_DIR ${CMAKE_INSTALL_PREFIX}/${LIBPYTHON_LIBDIR} + ) + if(PY_VERSION VERSION_LESS "3.10") + add_dependencies(${targetname} generate_libpython3stub_lib) + endif() + + target_link_libraries(${targetname} + libpython-shared + + # Removed in Python 3.10 + $<$:${python3stub_lib}> + ) + + if(PY_VERSION VERSION_GREATER_EQUAL "3.10") + set_property( + SOURCE ${SRC_DIR}/PC/python3dll.c + PROPERTY COMPILE_DEFINITIONS + "PYTHON_DLL_NAME=\"python${PY_VERSION_MAJOR}${PY_VERSION_MINOR}$<$:_d>\"" + ) + endif() + endif() + + if(UNIX AND NOT APPLE) + add_library(${targetname} SHARED ${PROJECT_SOURCE_DIR}/cmake/empty.c) + set_target_properties(${targetname} PROPERTIES + LINK_FLAGS "-Wl,--no-as-needed" + OUTPUT_NAME python3 + LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/${LIBPYTHON_LIBDIR} + RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/${LIBPYTHON_LIBDIR} + INSTALL_NAME_DIR ${CMAKE_INSTALL_PREFIX}/${LIBPYTHON_LIBDIR} + ) + target_link_libraries(${targetname} libpython-shared) + endif() + + # Export target + if(TARGET ${targetname}) + set_property(GLOBAL APPEND PROPERTY PYTHON_TARGETS ${targetname}) + + install(TARGETS ${targetname} EXPORT PythonTargets + ARCHIVE DESTINATION ${LIBPYTHON_ARCHIVEDIR} + LIBRARY DESTINATION ${LIBPYTHON_LIBDIR} + RUNTIME DESTINATION ${LIBPYTHON_LIBDIR} + ) + endif() + +endif() + +if(NOT BUILD_LIBPYTHON_SHARED) + add_libpython(libpython-static STATIC ${INSTALL_DEVELOPMENT} Development) + target_compile_definitions(libpython-static + PUBLIC + Py_NO_ENABLE_SHARED + ) + set_target_properties(libpython-static PROPERTIES + ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/${LIBPYTHON_STATIC_ARCHIVEDIR} + ) + if(INSTALL_DEVELOPMENT) + install(TARGETS libpython-static + ARCHIVE DESTINATION ${PYTHONHOME}/config/ + COMPONENT Development) + endif() +endif() diff --git a/third/python-cmake/cmake/libpython/generate_libpythonstub_def.cmake b/third/python-cmake/cmake/libpython/generate_libpythonstub_def.cmake new file mode 100644 index 00000000..d828c3c7 --- /dev/null +++ b/third/python-cmake/cmake/libpython/generate_libpythonstub_def.cmake @@ -0,0 +1,16 @@ +# Sanity checks +foreach(varname INPUT_DEF_FILE OUTPUT_DEF_FILE) + if(NOT DEFINED ${varname}) + message(FATAL_ERROR "Variable '${varname}' is not defined.") + endif() +endforeach() + +file(STRINGS ${INPUT_DEF_FILE} def_lines REGEX "^ (.+)=.+$") +set(stub_def_lines "EXPORTS\n") +foreach(line IN LISTS def_lines) + string(REGEX MATCH "^ (.+)=.+$" output ${line}) + if(NOT "${output}" STREQUAL "") + set(stub_def_lines "${stub_def_lines}${CMAKE_MATCH_1}\n") + endif() +endforeach() +file(WRITE ${OUTPUT_DEF_FILE} "${stub_def_lines}") diff --git a/third/python-cmake/cmake/makefile-variables.in b/third/python-cmake/cmake/makefile-variables.in new file mode 100644 index 00000000..5dd942cb --- /dev/null +++ b/third/python-cmake/cmake/makefile-variables.in @@ -0,0 +1,203 @@ +# === Variables set by makesetup === + +MODOBJS= +MODLIBS= + +# === Variables set by configure +VERSION= @LIBPYTHON_VERSION@ +srcdir= @SRC_DIR@ + + +CC= @CMAKE_C_COMPILER@ @CMAKE_C_COMPILER_ARG1@ -pthread +CXX= @CMAKE_CXX_COMPILER@ @CMAKE_CXX_COMPILER_ARG1@ -pthread +MAINCC= $(CC) +LINKCC= $(PURIFY) $(MAINCC) +AR= @CMAKE_AR@ +RANLIB= @CMAKE_RANLIB@ +SOABI= @SOABI@ +LDVERSION= $(VERSION)$(ABIFLAGS) +SVNVERSION= svnversion $(srcdir) +HGVERSION= +HGTAG= +HGBRANCH= + +GNULD= yes + +# Shell used by make (some versions default to the login shell, which is bad) +SHELL= /bin/sh + +# Use this to make a link between python$(VERSION) and python in $(BINDIR) +LN= ln + +# Portable install script (configure doesn't always guess right) +INSTALL= /usr/bin/install -c +INSTALL_PROGRAM=${INSTALL} +INSTALL_SCRIPT= ${INSTALL} +INSTALL_DATA= ${INSTALL} -m 644 +# Shared libraries must be installed with executable mode on some systems; +# rather than figuring out exactly which, we always give them executable mode. +# Also, making them read-only seems to be a good idea... +INSTALL_SHARED= ${INSTALL} -m 555 + +MAKESETUP= $(srcdir)/Modules/makesetup + +# Compiler options +OPT= @CMAKE_C_FLAGS@ -DNDEBUG +BASECFLAGS= -Wno-unused-result -Wsign-compare -Wunreachable-code +CFLAGS= @CMAKE_C_FLAGS@ +# Both CPPFLAGS and LDFLAGS need to contain the shell's value for setup.py to +# be able to build extension modules using the directories specified in the +# environment variables +CPPFLAGS= @CMAKE_CXX_FLAGS@ +LDFLAGS= +LDLAST= +SGI_ABI= +CCSHARED= -fPIC +LINKFORSHARED= -Xlinker -export-dynamic +ARFLAGS= rc +# Extra C flags added for building the interpreter object files. +CFLAGSFORSHARED= +# C flags used for building the interpreter object files +PY_CFLAGS= @CMAKE_C_FLAGS@ -DPy_BUILD_CORE + + +# Machine-dependent subdirectories +MACHDEP= @PY_PLATFORM@ + +# Install prefix for architecture-independent files +prefix= @CMAKE_INSTALL_PREFIX@ + +# Install prefix for architecture-dependent files +exec_prefix= ${prefix} + +# Install prefix for data files +datarootdir= ${prefix}/share + +# Expanded directories +BINDIR= ${exec_prefix}/bin +LIBDIR= ${exec_prefix}/lib +MANDIR= ${datarootdir}/man +INCLUDEDIR= ${prefix}/include +CONFINCLUDEDIR= $(exec_prefix)/include +SCRIPTDIR= $(prefix)/lib +ABIFLAGS= @ABIFLAGS@ + +# Detailed destination directories +BINLIBDEST= $(LIBDIR)/python$(VERSION) +LIBDEST= $(SCRIPTDIR)/python$(VERSION) +INCLUDEPY= $(INCLUDEDIR)/python$(LDVERSION) +CONFINCLUDEPY= $(CONFINCLUDEDIR)/python$(LDVERSION) +LIBP= $(LIBDIR)/python$(VERSION) + +# Symbols used for using shared libraries +SHLIB_SUFFIX= .so +EXT_SUFFIX= .$(SOABI).so +SO= .so +LDSHARED= $(CC) @MAKEFILE_LDSHARED_FLAGS@ $(LDFLAGS) +BLDSHARED= $(CC) @MAKEFILE_LDSHARED_FLAGS@ $(LDFLAGS) +LDCXXSHARED= $(CXX) @MAKEFILE_LDSHARED_FLAGS@ +DESTSHARED= $(BINLIBDEST)/lib-dynload + +# Executable suffix (.exe on Windows and Mac OS X) +EXE= @CMAKE_EXECUTABLE_SUFFIX@ +BUILDEXE= @CMAKE_EXECUTABLE_SUFFIX@ + +# Short name and location for Mac OS X Python framework +UNIVERSALSDK= +PYTHONFRAMEWORK= +PYTHONFRAMEWORKDIR= no-framework +PYTHONFRAMEWORKPREFIX= +PYTHONFRAMEWORKINSTALLDIR= +# Deployment target selected during configure, to be checked +# by distutils. The export statement is needed to ensure that the +# deployment target is active during build. +MACOSX_DEPLOYMENT_TARGET=@CMAKE_OSX_DEPLOYMENT_TARGET@ +#export MACOSX_DEPLOYMENT_TARGET + +# Environment to run shared python without installed libraries +RUNSHARED= + +# Modes for directories, executables and data files created by the +# install process. Default to user-only-writable for all file types. +DIRMODE= 755 +EXEMODE= 755 +FILEMODE= 644 + +# configure script arguments +CONFIG_ARGS= '--prefix' '@CMAKE_INSTALL_PREFIX@' + +# Subdirectories with code +SRCDIRS= Parser Grammar Objects Python Modules Mac + +# Other subdirectories +SUBDIRSTOO= Include Lib Misc Demo + +# Files and directories to be distributed +CONFIGFILES= configure configure.in acconfig.h pyconfig.h.in Makefile.pre.in +DISTFILES= README ChangeLog $(CONFIGFILES) +DISTDIRS= $(SUBDIRS) $(SUBDIRSTOO) Ext-dummy +DIST= $(DISTFILES) $(DISTDIRS) + +LIBRARY= libpython$(VERSION)$(ABIFLAGS).a +LDLIBRARY= libpython$(VERSION)$(ABIFLAGS).a +BLDLIBRARY= $(LDLIBRARY) +DLLLIBRARY= +LDLIBRARYDIR= +INSTSONAME= $(LDLIBRARY) + + +LIBS= -lpthread -ldl -lutil +LIBM= -lm +LIBC= +SYSLIBS= $(LIBM) $(LIBC) +SHLIBS= $(LIBS) + +PYTHON= python$(EXE) +BUILDPYTHON= python$(BUILDEXE) + +PYTHON_FOR_BUILD=./$(BUILDPYTHON) -E +_PYTHON_HOST_PLATFORM= +BUILD_GNU_TYPE= x86_64-unknown-linux-gnu +HOST_GNU_TYPE= x86_64-unknown-linux-gnu + +# === Definitions added by makesetup === + +LOCALMODLIBS= +BASEMODLIBS= +GLHACK=-Dclear=__GLclear +PYTHONPATH=$(COREPYTHONPATH) +COREPYTHONPATH=$(DESTPATH)$(SITEPATH)$(TESTPATH)$(MACHDEPPATH)$(EXTRAMACHDEPPATH)$(TKPATH)$(OLDPATH) +OLDPATH=:lib-old +TKPATH=:lib-tk +EXTRAMACHDEPPATH= +MACHDEPPATH=:plat-$(MACHDEP) +TESTPATH= +SITEPATH= +DESTPATH= +MACHDESTLIB=$(BINLIBDEST) +DESTLIB=$(LIBDEST) + + +LIBFFI_INCLUDEDIR= + + +######################################################################### +# Rules + +# This rule is here for OPENSTEP/Rhapsody/MacOSX. It builds a temporary +# minimal framework (not including the Lib directory and such) in the current +# directory. +RESSRCDIR=Mac/Resources/framework + +# Install the library +PLATDIR= plat-$(MACHDEP) +EXTRAPLATDIR= +EXTRAMACHDEPPATH= + +# Install the library and miscellaneous stuff needed for extending/embedding +# This goes into $(exec_prefix) +LIBPL= $(LIBP)/config + +# pkgconfig directory +LIBPC= $(LIBDIR)/pkgconfig + diff --git a/third/python-cmake/cmake/platform.c b/third/python-cmake/cmake/platform.c new file mode 100644 index 00000000..4c827896 --- /dev/null +++ b/third/python-cmake/cmake/platform.c @@ -0,0 +1,125 @@ +// Based on code in Python's `configure` script (see conftest.c) + +#include + +#undef bfin +#undef cris +#undef fr30 +#undef linux +#undef hppa +#undef hpux +#undef i386 +#undef mips +#undef powerpc +#undef sparc +#undef unix + +char *PLATFORM_TRIPLET = + +#if defined(__linux__) +# if defined(__x86_64__) && defined(__LP64__) + "x86_64-linux-gnu" +# elif defined(__x86_64__) && defined(__ILP32__) + "x86_64-linux-gnux32" +# elif defined(__i386__) + "i386-linux-gnu" +# elif defined(__aarch64__) && defined(__AARCH64EL__) +# if defined(__ILP32__) + "aarch64_ilp32-linux-gnu" +# else + "aarch64-linux-gnu" +# endif +# elif defined(__aarch64__) && defined(__AARCH64EB__) +# if defined(__ILP32__) + "aarch64_be_ilp32-linux-gnu" +# else + "aarch64_be-linux-gnu" +# endif +# elif defined(__alpha__) + "alpha-linux-gnu" +# elif defined(__ARM_EABI__) && defined(__ARM_PCS_VFP) +# if defined(__ARMEL__) + "arm-linux-gnueabihf" +# else + "armeb-linux-gnueabihf" +# endif +# elif defined(__ARM_EABI__) && !defined(__ARM_PCS_VFP) +# if defined(__ARMEL__) + "arm-linux-gnueabi" +# else + "armeb-linux-gnueabi" +# endif +# elif defined(__hppa__) + "hppa-linux-gnu" +# elif defined(__ia64__) + "ia64-linux-gnu" +# elif defined(__m68k__) && !defined(__mcoldfire__) + "m68k-linux-gnu" +# elif defined(__mips_hard_float) && defined(_MIPSEL) +# if _MIPS_SIM == _ABIO32 + "mipsel-linux-gnu" +# elif _MIPS_SIM == _ABIN32 + "mips64el-linux-gnuabin32" +# elif _MIPS_SIM == _ABI64 + "mips64el-linux-gnuabi64" +# else +# "unknown platform triplet" +# endif +# elif defined(__mips_hard_float) +# if _MIPS_SIM == _ABIO32 + "mips-linux-gnu" +# elif _MIPS_SIM == _ABIN32 + "mips64-linux-gnuabin32" +# elif _MIPS_SIM == _ABI64 + "mips64-linux-gnuabi64" +# else +# "unknown platform triplet" +# endif +# elif defined(__or1k__) + "or1k-linux-gnu" +# elif defined(__powerpc__) && defined(__SPE__) + "powerpc-linux-gnuspe" +# elif defined(__powerpc64__) +# if defined(__LITTLE_ENDIAN__) + "powerpc64le-linux-gnu" +# else + "powerpc64-linux-gnu" +# endif +# elif defined(__powerpc__) + "powerpc-linux-gnu" +# elif defined(__s390x__) + "s390x-linux-gnu" +# elif defined(__s390__) + "s390-linux-gnu" +# elif defined(__sh__) && defined(__LITTLE_ENDIAN__) + "sh4-linux-gnu" +# elif defined(__sparc__) && defined(__arch64__) + "sparc64-linux-gnu" +# elif defined(__sparc__) + "sparc-linux-gnu" +# else +# "unknown platform triplet" +# endif +#elif defined(__FreeBSD_kernel__) +# if defined(__LP64__) + "x86_64-kfreebsd-gnu" +# elif defined(__i386__) + "i386-kfreebsd-gnu" +# else +# "unknown platform triplet" +# endif +#elif defined(__gnu_hurd__) + "i386-gnu" +#elif defined(__APPLE__) + "darwin" +#else +# "unknown platform triplet" +#endif + ; + +int main() +{ + printf("%s", PLATFORM_TRIPLET); + + return 0; +} diff --git a/third/python-cmake/cmake/python.pc.in b/third/python-cmake/cmake/python.pc.in new file mode 100644 index 00000000..fba2c5ea --- /dev/null +++ b/third/python-cmake/cmake/python.pc.in @@ -0,0 +1,12 @@ +prefix=@CMAKE_INSTALL_PREFIX@ +exec_prefix=${prefix} +libdir=${exec_prefix}/lib +includedir=${prefix}/include + +Name: Python +Description: Python library +Requires: +Version: @LIBPYTHON_VERSION@ +Libs.private: -lpthread -ldl -lutil +Libs: -L${libdir} -l@LIBPYTHON@ +Cflags: -I${includedir}/@LIBPYTHON@ diff --git a/third/python-cmake/cmake/python/CMakeLists.txt b/third/python-cmake/cmake/python/CMakeLists.txt new file mode 100644 index 00000000..cfbe1a11 --- /dev/null +++ b/third/python-cmake/cmake/python/CMakeLists.txt @@ -0,0 +1,107 @@ +set(PYTHON_SOURCES + ${SRC_DIR}/$,Programs,Modules>/python.c +) + +add_executable(python ${PYTHON_SOURCES}) +set_property( + TARGET python + PROPERTY RUNTIME_OUTPUT_DIRECTORY ${BIN_BUILD_DIR} + ) +target_compile_definitions(python PRIVATE Py_BUILD_CORE) +add_definitions(-DPy_BUILD_CORE) + +# Link against the shared libpython if it was built, otherwise use the static +# version. +if(BUILD_LIBPYTHON_SHARED) + target_link_libraries(python libpython-shared) +else() + target_link_libraries(python libpython-static) + set_target_properties(python PROPERTIES + COMPILE_DEFINITIONS Py_NO_ENABLE_SHARED + ENABLE_EXPORTS ON + ) +endif() + +if(MSVC) + set_target_properties(python PROPERTIES LINK_FLAGS /STACK:2000000) +endif() + +# Export target +set_property(GLOBAL APPEND PROPERTY PYTHON_TARGETS python) + +install(TARGETS python EXPORT PythonTargets RUNTIME DESTINATION ${BIN_INSTALL_DIR} COMPONENT Runtime) + +# See "is_python_build()" in sysconfig.py +add_custom_command(TARGET python PRE_BUILD + COMMAND ${CMAKE_COMMAND} -E make_directory ${BIN_BUILD_DIR}/${CMAKE_CFG_INTDIR}/Modules + COMMAND ${CMAKE_COMMAND} -E touch ${BIN_BUILD_DIR}/${CMAKE_CFG_INTDIR}/Modules/Setup.local + COMMENT "Creating '${BIN_INSTALL_DIR}/${CMAKE_CFG_INTDIR}/Modules/Setup.local'" + ) + +if(WIN32) + # See "get_config_h_filename()" in sysconfig.py + add_custom_command(TARGET python POST_BUILD + COMMAND ${CMAKE_COMMAND} -E make_directory ${BIN_BUILD_DIR}/${CMAKE_CFG_INTDIR}/PC + COMMAND ${CMAKE_COMMAND} -E copy_if_different ${SRC_DIR}/PC/pyconfig.h ${BIN_BUILD_DIR}/${CMAKE_CFG_INTDIR}/PC/pyconfig.h + COMMENT "Copying 'pyconfig.h' to '${BIN_INSTALL_DIR}/${CMAKE_CFG_INTDIR}/PC'" + ) +endif() + +if(UNIX) + # Setup landmark allowing to run the interpreter from a build tree. See 'getpath.c' for details. + set(_sysconfigdata_py "_sysconfigdata.py") + if("${PY_VERSION}" VERSION_GREATER_EQUAL "3.6.0") + # XXX Add support for _PYTHON_SYSCONFIGDATA_NAME env. variable + set(MULTIARCH "") + set(_sysconfigdata_py "_sysconfigdata_${ABIFLAGS}_${PY_PLATFORM}_${MULTIARCH}.py") + endif() + add_custom_command( + OUTPUT ${BIN_BUILD_DIR}/pybuilddir.txt ${EXTENSION_BUILD_DIR}/${_sysconfigdata_py} + COMMAND ${PYTHON_WRAPPER_COMMAND} + ${CMAKE_CROSSCOMPILING_EMULATOR} $ -E -S -m sysconfig --generate-posix-vars + COMMAND ${CMAKE_COMMAND} + -DBIN_BUILD_DIR:PATH=${BIN_BUILD_DIR} + -DSYSCONFIGDATA_PY:STRING=${_sysconfigdata_py} + -DPYTHON_BINARY_DIR:PATH=${PROJECT_BINARY_DIR} + -DEXTENSION_INSTALL_DIR:PATH=${EXTENSION_INSTALL_DIR} + -P ${PROJECT_SOURCE_DIR}/cmake/UpdateSysconfig.cmake + COMMENT "Relocate ${_sysconfigdata_py} and update pybuilddir.txt" + WORKING_DIRECTORY ${BIN_BUILD_DIR} + DEPENDS python + ) + add_custom_target(update_sysconfig ALL + DEPENDS ${BIN_BUILD_DIR}/pybuilddir.txt ${EXTENSION_BUILD_DIR}/${_sysconfigdata_py} + ) + install(FILES ${EXTENSION_BUILD_DIR}/${_sysconfigdata_py} + DESTINATION ${PYTHONHOME}/) +endif() + +if(UNIX AND NOT CMAKE_CROSSCOMPILING) + install(CODE +"message(STATUS \"Creating Python executable symlinks...\") +execute_process( + COMMAND \${CMAKE_COMMAND} -E create_symlink python + python${PY_VERSION_MAJOR} + COMMAND \${CMAKE_COMMAND} -E create_symlink python + python${PY_VERSION_MAJOR}.${PY_VERSION_MINOR} + WORKING_DIRECTORY + \$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${BIN_INSTALL_DIR} + )" +) +endif() + +# Copy up the gdb python hooks into a position where they can be automatically +# loaded by gdb during Lib/test/test_gdb.py +# +# Distributors are likely to want to install this somewhere else e.g. relative +# to the stripped DWARF data for the shared library. + +set(SRC_GDB_HOOKS ${SRC_DIR}/Tools/gdb/libpython.py) +configure_file( + ${SRC_GDB_HOOKS} + ${BIN_BUILD_DIR}/python-gdb.py + COPYONLY +) +if(INSTALL_DEVELOPMENT) + install(FILES ${SRC_GDB_HOOKS} DESTINATION ${BIN_INSTALL_DIR} COMPONENT Development) +endif() diff --git a/third/python-cmake/cmake/tools/CMakeLists.txt b/third/python-cmake/cmake/tools/CMakeLists.txt new file mode 100644 index 00000000..f0b0350b --- /dev/null +++ b/third/python-cmake/cmake/tools/CMakeLists.txt @@ -0,0 +1,13 @@ +set(files) + +if(PY_VERSION VERSION_GREATER_EQUAL "3.6") +list(APPEND files + Tools/scripts/run_tests.py +) +endif() + +foreach(file IN LISTS files) + get_filename_component(path ${file} PATH) + file(COPY ${SRC_DIR}/${file} DESTINATION ${PROJECT_BINARY_DIR}/${LIBDIR}/${path}) + install(FILES ${SRC_DIR}/${file} DESTINATION ${LIBDIR}/${path}) +endforeach() diff --git a/third/python-cmake/patches/3.11/0001-_bootstrap_python-Fix-execution-on-windows-disabling.patch b/third/python-cmake/patches/3.11/0001-_bootstrap_python-Fix-execution-on-windows-disabling.patch new file mode 100644 index 00000000..0bbb8d12 --- /dev/null +++ b/third/python-cmake/patches/3.11/0001-_bootstrap_python-Fix-execution-on-windows-disabling.patch @@ -0,0 +1,51 @@ +From 50a9d90c04eb672d35d516b32c802760a0736a23 Mon Sep 17 00:00:00 2001 +From: Jean-Christophe Fillion-Robin +Date: Tue, 13 May 2025 20:36:35 -0400 +Subject: [PATCH] _bootstrap_python: Fix execution on windows disabling site + import + +This workaround the lack of `sys.winver` attribute addressing the following +error: + +``` + Generating C:/path/to/Python-3.11.12/Python/deepfreeze/deepfreeze.c +CUSTOMBUILD : Fatal Python error : init_import_site: Failed to import the site module [C:\path\to\pycbs-3.11-build\CMakeBuild\libpython\libpython-shared.vcxproj] + Python runtime state: initialized + Traceback (most recent call last): + File "C:\path\to\pycbs-3.11-build\Lib\site.py", line 626, in + main() + File "C:\path\to\pycbs-3.11-build\Lib\site.py", line 612, in main + known_paths = addusersitepackages(known_paths) + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + File "C:\path\to\pycbs-3.11-build\Lib\site.py", line 350, in addusersitepackages + user_site = getusersitepackages() + ^^^^^^^^^^^^^^^^^^^^^ + File "C:\path\to\pycbs-3.11-build\Lib\site.py", line 337, in getusersitepackages + USER_SITE = _get_path(userbase) + ^^^^^^^^^^^^^^^^^^^ + File "C:\path\to\pycbs-3.11-build\Lib\site.py", line 302, in _get_path + ver_nodot = sys.winver.replace('.', '') + ^^^^^^^^^^ + AttributeError: module 'sys' has no attribute 'winver' +``` +--- + Programs/_bootstrap_python.c | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/Programs/_bootstrap_python.c b/Programs/_bootstrap_python.c +index 6ecbf0c72b5..136c187758d 100644 +--- a/Programs/_bootstrap_python.c ++++ b/Programs/_bootstrap_python.c +@@ -72,6 +72,9 @@ main(int argc, char **argv) + // add current script dir to sys.path + config.isolated = 0; + config.safe_path = 0; ++#ifdef MS_WINDOWS ++ config.site_import = 0; ++#endif + + #ifdef MS_WINDOWS + status = PyConfig_SetArgv(&config, argc, argv); +-- +2.48.1 + diff --git a/third/python-cmake/patches/3.11/0002-getpath-Update-build-directory-assumptions-based-on-.patch b/third/python-cmake/patches/3.11/0002-getpath-Update-build-directory-assumptions-based-on-.patch new file mode 100644 index 00000000..c1172fa4 --- /dev/null +++ b/third/python-cmake/patches/3.11/0002-getpath-Update-build-directory-assumptions-based-on-.patch @@ -0,0 +1,105 @@ +From 646608c7fd9f8ff0c97bb587b6273b1791604e2a Mon Sep 17 00:00:00 2001 +From: Jean-Christophe Fillion-Robin +Date: Fri, 30 May 2025 14:54:08 -0400 +Subject: [PATCH] getpath: Update build directory assumptions based on + python-cmake-buildsystem + +This ensures the following tests pass: +- `test_sys` (`SysModuleTest.test_stdlib_dir`) +- `test_frozen` (`TestFrozen.test_unfrozen_submodule_in_frozen_package`) +--- + Lib/test/test_getpath.py | 12 ++++++------ + Modules/getpath.py | 10 +++++++--- + 2 files changed, 13 insertions(+), 9 deletions(-) + +diff --git a/Lib/test/test_getpath.py b/Lib/test/test_getpath.py +index 5208374e200..3a3168a6dbb 100644 +--- a/Lib/test/test_getpath.py ++++ b/Lib/test/test_getpath.py +@@ -278,7 +278,7 @@ def test_buildpath_posix(self): + ns.add_known_xfile("/home/cpython/python") + ns.add_known_xfile("/usr/local/bin/python") + ns.add_known_file("/home/cpython/pybuilddir.txt", ["build/lib.linux-x86_64-9.8"]) +- ns.add_known_file("/home/cpython/Lib/os.py") ++ ns.add_known_file("/home/cpython/lib/python9.8/os.py") + ns.add_known_dir("/home/cpython/lib-dynload") + expected = dict( + executable="/home/cpython/python", +@@ -290,7 +290,7 @@ def test_buildpath_posix(self): + module_search_paths_set=1, + module_search_paths=[ + "/usr/local/lib/python98.zip", +- "/home/cpython/Lib", ++ "/home/cpython/lib/python9.8", + "/home/cpython/build/lib.linux-x86_64-9.8", + ], + ) +@@ -402,7 +402,7 @@ def test_symlink_buildpath_posix(self): + ns.add_known_link("/linkfrom/python", "/home/cpython/python") + ns.add_known_xfile("/usr/local/bin/python") + ns.add_known_file("/home/cpython/pybuilddir.txt", ["build/lib.linux-x86_64-9.8"]) +- ns.add_known_file("/home/cpython/Lib/os.py") ++ ns.add_known_file("/home/cpython/lib/python9.8/os.py") + ns.add_known_dir("/home/cpython/lib-dynload") + expected = dict( + executable="/linkfrom/python", +@@ -414,7 +414,7 @@ def test_symlink_buildpath_posix(self): + module_search_paths_set=1, + module_search_paths=[ + "/usr/local/lib/python98.zip", +- "/home/cpython/Lib", ++ "/home/cpython/lib/python9.8", + "/home/cpython/build/lib.linux-x86_64-9.8", + ], + ) +@@ -709,7 +709,7 @@ def test_symlink_buildpath_macos(self): + ns.add_known_link("/linkfrom/python", "/home/cpython/python") + ns.add_known_xfile("/usr/local/bin/python") + ns.add_known_file("/home/cpython/pybuilddir.txt", ["build/lib.macos-9.8"]) +- ns.add_known_file("/home/cpython/Lib/os.py") ++ ns.add_known_file("/home/cpython/lib/python9.8/os.py") + ns.add_known_dir("/home/cpython/lib-dynload") + expected = dict( + executable="/linkfrom/python", +@@ -721,7 +721,7 @@ def test_symlink_buildpath_macos(self): + module_search_paths_set=1, + module_search_paths=[ + "/usr/local/lib/python98.zip", +- "/home/cpython/Lib", ++ "/home/cpython/lib/python9.8", + "/home/cpython/build/lib.macos-9.8", + ], + ) +diff --git a/Modules/getpath.py b/Modules/getpath.py +index dceeed7702c..775614f531d 100644 +--- a/Modules/getpath.py ++++ b/Modules/getpath.py +@@ -180,7 +180,7 @@ + STDLIB_SUBDIR = f'{platlibdir}/python{VERSION_MAJOR}.{VERSION_MINOR}' + STDLIB_LANDMARKS = [f'{STDLIB_SUBDIR}/os.py', f'{STDLIB_SUBDIR}/os.pyc'] + PLATSTDLIB_LANDMARK = f'{platlibdir}/python{VERSION_MAJOR}.{VERSION_MINOR}/lib-dynload' +- BUILDSTDLIB_LANDMARKS = ['Lib/os.py'] ++ BUILDSTDLIB_LANDMARKS = [f'lib/python{VERSION_MAJOR}.{VERSION_MINOR}/os.py'] + VENV_LANDMARK = 'pyvenv.cfg' + ZIP_LANDMARK = f'{platlibdir}/python{VERSION_MAJOR}{VERSION_MINOR}.zip' + DELIM = ':' +@@ -491,10 +491,14 @@ def search_up(prefix, *landmarks, test=isfile): + else: + build_stdlib_prefix = search_up(build_prefix, *BUILDSTDLIB_LANDMARKS) + # Always use the build prefix for stdlib ++ if os_name == 'nt': ++ lib = 'Lib' ++ else: ++ lib = f'lib/python{VERSION_MAJOR}.{VERSION_MINOR}' + if build_stdlib_prefix: +- stdlib_dir = joinpath(build_stdlib_prefix, 'Lib') ++ stdlib_dir = joinpath(build_stdlib_prefix, lib) + else: +- stdlib_dir = joinpath(build_prefix, 'Lib') ++ stdlib_dir = joinpath(build_prefix, lib) + # Only use the build prefix for prefix if it hasn't already been set + if not prefix: + prefix = build_stdlib_prefix +-- +2.48.1 + diff --git a/third/python-cmake/patches/3.11/README.rst b/third/python-cmake/patches/3.11/README.rst new file mode 100644 index 00000000..5aea2bea --- /dev/null +++ b/third/python-cmake/patches/3.11/README.rst @@ -0,0 +1 @@ +* ``0001-_bootstrap_python-Fix-execution-on-windows-disabling.patch``: _bootstrap_python: Fix execution on windows disabling site import. diff --git a/third/python-cmake/patches/3.12/0001-_bootstrap_python-Fix-execution-on-windows-disabling.patch b/third/python-cmake/patches/3.12/0001-_bootstrap_python-Fix-execution-on-windows-disabling.patch new file mode 100644 index 00000000..f5cc927a --- /dev/null +++ b/third/python-cmake/patches/3.12/0001-_bootstrap_python-Fix-execution-on-windows-disabling.patch @@ -0,0 +1,51 @@ +From ca2fd1a78562f904f4f5d7046cac9276c2ad2afa Mon Sep 17 00:00:00 2001 +From: Jean-Christophe Fillion-Robin +Date: Tue, 13 May 2025 20:36:35 -0400 +Subject: [PATCH] _bootstrap_python: Fix execution on windows disabling site + import + +This works around the lack of `sys.winver` attribute addressing the following +error: + +``` + Generating C:/path/to/Python-3.12.10/Python/deepfreeze/deepfreeze.c +CUSTOMBUILD : Fatal Python error : init_import_site: Failed to import the site module [C:\path o\pycbs-3.12-build\CMakeBuild\libpython\libpython-shared.vcxproj] + Python runtime state: initialized + Traceback (most recent call last): + File "C:\path o\pycbs-3.12-build\Lib\site.py", line 636, in + main() + File "C:\path o\pycbs-3.12-build\Lib\site.py", line 622, in main + known_paths = addusersitepackages(known_paths) + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + File "C:\path o\pycbs-3.12-build\Lib\site.py", line 361, in addusersitepackages + user_site = getusersitepackages() + ^^^^^^^^^^^^^^^^^^^^^ + File "C:\path o\pycbs-3.12-build\Lib\site.py", line 348, in getusersitepackages + USER_SITE = _get_path(userbase) + ^^^^^^^^^^^^^^^^^^^ + File "C:\path o\pycbs-3.12-build\Lib\site.py", line 313, in _get_path + ver_nodot = sys.winver.replace('.', '') + ^^^^^^^^^^ + AttributeError: module 'sys' has no attribute 'winver' +``` +--- + Programs/_bootstrap_python.c | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/Programs/_bootstrap_python.c b/Programs/_bootstrap_python.c +index 6c388fc7033..edbe2847904 100644 +--- a/Programs/_bootstrap_python.c ++++ b/Programs/_bootstrap_python.c +@@ -76,6 +76,9 @@ main(int argc, char **argv) + // add current script dir to sys.path + config.isolated = 0; + config.safe_path = 0; ++#ifdef MS_WINDOWS ++ config.site_import = 0; ++#endif + + #ifdef MS_WINDOWS + status = PyConfig_SetArgv(&config, argc, argv); +-- +2.48.1 + diff --git a/third/python-cmake/patches/3.12/0002-getpath-Update-build-directory-assumptions-based-on-.patch b/third/python-cmake/patches/3.12/0002-getpath-Update-build-directory-assumptions-based-on-.patch new file mode 100644 index 00000000..150bccc6 --- /dev/null +++ b/third/python-cmake/patches/3.12/0002-getpath-Update-build-directory-assumptions-based-on-.patch @@ -0,0 +1,105 @@ +From b8d5fa3e61e2f1f8d07f8b8291c281cbdd02c4ad Mon Sep 17 00:00:00 2001 +From: Jean-Christophe Fillion-Robin +Date: Fri, 30 May 2025 14:54:08 -0400 +Subject: [PATCH] getpath: Update build directory assumptions based on + python-cmake-buildsystem + +This ensures the following tests pass: +- `test_sys` (`SysModuleTest.test_stdlib_dir`) +- `test_frozen` (`TestFrozen.test_unfrozen_submodule_in_frozen_package`) +--- + Lib/test/test_getpath.py | 12 ++++++------ + Modules/getpath.py | 10 +++++++--- + 2 files changed, 13 insertions(+), 9 deletions(-) + +diff --git a/Lib/test/test_getpath.py b/Lib/test/test_getpath.py +index b9cbe1d92c4..374bfeef5f9 100644 +--- a/Lib/test/test_getpath.py ++++ b/Lib/test/test_getpath.py +@@ -304,7 +304,7 @@ def test_buildpath_posix(self): + ns.add_known_xfile("/home/cpython/python") + ns.add_known_xfile("/usr/local/bin/python") + ns.add_known_file("/home/cpython/pybuilddir.txt", ["build/lib.linux-x86_64-9.8"]) +- ns.add_known_file("/home/cpython/Lib/os.py") ++ ns.add_known_file("/home/cpython/lib/python9.8/os.py") + ns.add_known_dir("/home/cpython/lib-dynload") + expected = dict( + executable="/home/cpython/python", +@@ -316,7 +316,7 @@ def test_buildpath_posix(self): + module_search_paths_set=1, + module_search_paths=[ + "/usr/local/lib/python98.zip", +- "/home/cpython/Lib", ++ "/home/cpython/lib/python9.8", + "/home/cpython/build/lib.linux-x86_64-9.8", + ], + ) +@@ -492,7 +492,7 @@ def test_symlink_buildpath_posix(self): + ns.add_known_link("/linkfrom/python", "/home/cpython/python") + ns.add_known_xfile("/usr/local/bin/python") + ns.add_known_file("/home/cpython/pybuilddir.txt", ["build/lib.linux-x86_64-9.8"]) +- ns.add_known_file("/home/cpython/Lib/os.py") ++ ns.add_known_file("/home/cpython/lib/python9.8/os.py") + ns.add_known_dir("/home/cpython/lib-dynload") + expected = dict( + executable="/linkfrom/python", +@@ -504,7 +504,7 @@ def test_symlink_buildpath_posix(self): + module_search_paths_set=1, + module_search_paths=[ + "/usr/local/lib/python98.zip", +- "/home/cpython/Lib", ++ "/home/cpython/lib/python9.8", + "/home/cpython/build/lib.linux-x86_64-9.8", + ], + ) +@@ -799,7 +799,7 @@ def test_symlink_buildpath_macos(self): + ns.add_known_link("/linkfrom/python", "/home/cpython/python") + ns.add_known_xfile("/usr/local/bin/python") + ns.add_known_file("/home/cpython/pybuilddir.txt", ["build/lib.macos-9.8"]) +- ns.add_known_file("/home/cpython/Lib/os.py") ++ ns.add_known_file("/home/cpython/lib/python9.8/os.py") + ns.add_known_dir("/home/cpython/lib-dynload") + expected = dict( + executable="/linkfrom/python", +@@ -811,7 +811,7 @@ def test_symlink_buildpath_macos(self): + module_search_paths_set=1, + module_search_paths=[ + "/usr/local/lib/python98.zip", +- "/home/cpython/Lib", ++ "/home/cpython/lib/python9.8", + "/home/cpython/build/lib.macos-9.8", + ], + ) +diff --git a/Modules/getpath.py b/Modules/getpath.py +index 9913fcba497..abe87164a4d 100644 +--- a/Modules/getpath.py ++++ b/Modules/getpath.py +@@ -180,7 +180,7 @@ + STDLIB_SUBDIR = f'{platlibdir}/python{VERSION_MAJOR}.{VERSION_MINOR}' + STDLIB_LANDMARKS = [f'{STDLIB_SUBDIR}/os.py', f'{STDLIB_SUBDIR}/os.pyc'] + PLATSTDLIB_LANDMARK = f'{platlibdir}/python{VERSION_MAJOR}.{VERSION_MINOR}/lib-dynload' +- BUILDSTDLIB_LANDMARKS = ['Lib/os.py'] ++ BUILDSTDLIB_LANDMARKS = [f'lib/python{VERSION_MAJOR}.{VERSION_MINOR}/os.py'] + VENV_LANDMARK = 'pyvenv.cfg' + ZIP_LANDMARK = f'{platlibdir}/python{VERSION_MAJOR}{VERSION_MINOR}.zip' + DELIM = ':' +@@ -510,10 +510,14 @@ def search_up(prefix, *landmarks, test=isfile): + else: + build_stdlib_prefix = search_up(build_prefix, *BUILDSTDLIB_LANDMARKS) + # Always use the build prefix for stdlib ++ if os_name == 'nt': ++ lib = 'Lib' ++ else: ++ lib = f'lib/python{VERSION_MAJOR}.{VERSION_MINOR}' + if build_stdlib_prefix: +- stdlib_dir = joinpath(build_stdlib_prefix, 'Lib') ++ stdlib_dir = joinpath(build_stdlib_prefix, lib) + else: +- stdlib_dir = joinpath(build_prefix, 'Lib') ++ stdlib_dir = joinpath(build_prefix, lib) + # Only use the build prefix for prefix if it hasn't already been set + if not prefix: + prefix = build_stdlib_prefix +-- +2.48.1 + diff --git a/third/python-cmake/patches/3.12/README.rst b/third/python-cmake/patches/3.12/README.rst new file mode 100644 index 00000000..ac02024a --- /dev/null +++ b/third/python-cmake/patches/3.12/README.rst @@ -0,0 +1,4 @@ +* ``0001-_bootstrap_python-Fix-execution-on-windows-disabling.patch``: _bootstrap_python: Fix execution on windows disabling site import. + +* ``0002-getpath-Update-build-directory-assumptions-based-on-.patch``: getpath: Update build directory assumptions based on + python-cmake-buildsystem diff --git a/third/python-cmake/patches/3.5/0001-Prevent-incorrect-include-of-io.h-and-memory.h-found.patch b/third/python-cmake/patches/3.5/0001-Prevent-incorrect-include-of-io.h-and-memory.h-found.patch new file mode 100644 index 00000000..0fb497d8 --- /dev/null +++ b/third/python-cmake/patches/3.5/0001-Prevent-incorrect-include-of-io.h-and-memory.h-found.patch @@ -0,0 +1,86 @@ +From 2d8a07e976859c7e8582ed8f4d7849f7e8b8a68c Mon Sep 17 00:00:00 2001 +From: Jean-Christophe Fillion-Robin +Date: Mon, 6 Nov 2017 09:56:43 -0500 +Subject: [PATCH 1/3] Prevent incorrect include of "io.h" and "memory.h" found + in libmpdec directory + +This commit improves support for building python with built-in extensions +on windows where the header provided by libmpdec would be included instead +of the system one. +--- + Modules/_decimal/libmpdec/basearith.c | 2 +- + Modules/_decimal/libmpdec/io.c | 4 ++-- + Modules/_decimal/libmpdec/memory.c | 2 +- + Modules/_decimal/libmpdec/{io.h => mpd_io.h} | 0 + Modules/_decimal/libmpdec/{memory.h => mpd_memory.h} | 0 + Modules/_decimal/libmpdec/mpdecimal.c | 2 +- + 6 files changed, 5 insertions(+), 5 deletions(-) + rename Modules/_decimal/libmpdec/{io.h => mpd_io.h} (100%) + rename Modules/_decimal/libmpdec/{memory.h => mpd_memory.h} (100%) + +diff --git a/Modules/_decimal/libmpdec/basearith.c b/Modules/_decimal/libmpdec/basearith.c +index 35de6b8..c0953a3 100644 +--- a/Modules/_decimal/libmpdec/basearith.c ++++ b/Modules/_decimal/libmpdec/basearith.c +@@ -32,7 +32,7 @@ + #include + #include + #include "constants.h" +-#include "memory.h" ++#include "mpd_memory.h" + #include "typearith.h" + #include "basearith.h" + +diff --git a/Modules/_decimal/libmpdec/io.c b/Modules/_decimal/libmpdec/io.c +index a45a429..f517264 100644 +--- a/Modules/_decimal/libmpdec/io.c ++++ b/Modules/_decimal/libmpdec/io.c +@@ -37,9 +37,9 @@ + #include + #include "bits.h" + #include "constants.h" +-#include "memory.h" ++#include "mpd_memory.h" + #include "typearith.h" +-#include "io.h" ++#include "mpd_io.h" + + + /* This file contains functions for decimal <-> string conversions, including +diff --git a/Modules/_decimal/libmpdec/memory.c b/Modules/_decimal/libmpdec/memory.c +index 0f41fe5..f4140b2 100644 +--- a/Modules/_decimal/libmpdec/memory.c ++++ b/Modules/_decimal/libmpdec/memory.c +@@ -30,7 +30,7 @@ + #include + #include + #include "typearith.h" +-#include "memory.h" ++#include "mpd_memory.h" + + + /* Guaranteed minimum allocation for a coefficient. May be changed once +diff --git a/Modules/_decimal/libmpdec/io.h b/Modules/_decimal/libmpdec/mpd_io.h +similarity index 100% +rename from Modules/_decimal/libmpdec/io.h +rename to Modules/_decimal/libmpdec/mpd_io.h +diff --git a/Modules/_decimal/libmpdec/memory.h b/Modules/_decimal/libmpdec/mpd_memory.h +similarity index 100% +rename from Modules/_decimal/libmpdec/memory.h +rename to Modules/_decimal/libmpdec/mpd_memory.h +diff --git a/Modules/_decimal/libmpdec/mpdecimal.c b/Modules/_decimal/libmpdec/mpdecimal.c +index 593f9f5..2fd8b33 100644 +--- a/Modules/_decimal/libmpdec/mpdecimal.c ++++ b/Modules/_decimal/libmpdec/mpdecimal.c +@@ -36,7 +36,7 @@ + #include "bits.h" + #include "convolute.h" + #include "crt.h" +-#include "memory.h" ++#include "mpd_memory.h" + #include "typearith.h" + #include "umodarith.h" + +-- +2.5.0 + diff --git a/third/python-cmake/patches/3.5/0002-Prevent-duplicated-OverlappedType-symbols-with-built.patch b/third/python-cmake/patches/3.5/0002-Prevent-duplicated-OverlappedType-symbols-with-built.patch new file mode 100644 index 00000000..c2345baf --- /dev/null +++ b/third/python-cmake/patches/3.5/0002-Prevent-duplicated-OverlappedType-symbols-with-built.patch @@ -0,0 +1,65 @@ +From 8f6f95702bb5b58021e91385392c5c507cf22d31 Mon Sep 17 00:00:00 2001 +From: Jean-Christophe Fillion-Robin +Date: Mon, 6 Nov 2017 10:37:50 -0500 +Subject: [PATCH 2/3] Prevent duplicated OverlappedType symbols with built-in + extension on windows + +This commit improves support for building python with built-in extensions +on windows where the symbol from overlapped.c would clash with the one +from _winapi.c +--- + Modules/_winapi.c | 10 +++++----- + 1 file changed, 5 insertions(+), 5 deletions(-) + +diff --git a/Modules/_winapi.c b/Modules/_winapi.c +index edc6cf4..c9b0049 100644 +--- a/Modules/_winapi.c ++++ b/Modules/_winapi.c +@@ -147,7 +147,7 @@ overlapped_dealloc(OverlappedObject *self) + + /*[clinic input] + module _winapi +-class _winapi.Overlapped "OverlappedObject *" "&OverlappedType" ++class _winapi.Overlapped "OverlappedObject *" "&WinApiOverlappedType" + [clinic start generated code]*/ + /*[clinic end generated code: output=da39a3ee5e6b4b0d input=c13d3f5fd1dabb84]*/ + +@@ -295,7 +295,7 @@ static PyMemberDef overlapped_members[] = { + {NULL} + }; + +-PyTypeObject OverlappedType = { ++PyTypeObject WinApiOverlappedType = { + PyVarObject_HEAD_INIT(NULL, 0) + /* tp_name */ "_winapi.Overlapped", + /* tp_basicsize */ sizeof(OverlappedObject), +@@ -341,7 +341,7 @@ new_overlapped(HANDLE handle) + { + OverlappedObject *self; + +- self = PyObject_New(OverlappedObject, &OverlappedType); ++ self = PyObject_New(OverlappedObject, &WinApiOverlappedType); + if (!self) + return NULL; + self->handle = handle; +@@ -1517,7 +1517,7 @@ PyInit__winapi(void) + PyObject *d; + PyObject *m; + +- if (PyType_Ready(&OverlappedType) < 0) ++ if (PyType_Ready(&WinApiOverlappedType) < 0) + return NULL; + + m = PyModule_Create(&winapi_module); +@@ -1525,7 +1525,7 @@ PyInit__winapi(void) + return NULL; + d = PyModule_GetDict(m); + +- PyDict_SetItemString(d, "Overlapped", (PyObject *) &OverlappedType); ++ PyDict_SetItemString(d, "Overlapped", (PyObject *) &WinApiOverlappedType); + + /* constants */ + WINAPI_CONSTANT(F_DWORD, CREATE_NEW_CONSOLE); +-- +2.5.0 + diff --git a/third/python-cmake/patches/3.5/0003-mpdecimal-Export-inlined-functions-to-support-extens.patch b/third/python-cmake/patches/3.5/0003-mpdecimal-Export-inlined-functions-to-support-extens.patch new file mode 100644 index 00000000..14a84ddb --- /dev/null +++ b/third/python-cmake/patches/3.5/0003-mpdecimal-Export-inlined-functions-to-support-extens.patch @@ -0,0 +1,36 @@ +From 69f55ccb4b9c5c1c34dc3d3ed8612574e7d65dc5 Mon Sep 17 00:00:00 2001 +From: Jean-Christophe Fillion-Robin +Date: Mon, 6 Nov 2017 11:27:32 -0500 +Subject: [PATCH 3/3] mpdecimal: Export inlined functions to support extension + built-in on windows + +This commit ensures that symbols are available when building _freeze_importlib +with all extensions built-in on windows. + +It addresses the following link error associated +with CMakeBuild\libpython\_freeze_importlib.vcxproj: + + 3>_decimal.obj : error LNK2019: unresolved external symbol _mpd_del referenced in function _PyDec_AsTuple + 3>io.obj : error LNK2001: unresolved external symbol _mpd_del + 3>basearith.obj : error LNK2019: unresolved external symbol _mpd_uint_zero referenced in function __mpd_baseshiftl + 3>io.obj : error LNK2019: unresolved external symbol _mpd_qresize referenced in function _mpd_qset_string +--- + Modules/_decimal/libmpdec/mpdecimal.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/Modules/_decimal/libmpdec/mpdecimal.c b/Modules/_decimal/libmpdec/mpdecimal.c +index 2fd8b33..a0d707a 100644 +--- a/Modules/_decimal/libmpdec/mpdecimal.c ++++ b/Modules/_decimal/libmpdec/mpdecimal.c +@@ -54,7 +54,7 @@ + + + #if defined(_MSC_VER) +- #define ALWAYS_INLINE __forceinline ++ #define ALWAYS_INLINE extern __forceinline + #elif defined(LEGACY_COMPILER) + #define ALWAYS_INLINE + #undef inline +-- +2.5.0 + diff --git a/third/python-cmake/patches/3.5/README.rst b/third/python-cmake/patches/3.5/README.rst new file mode 100644 index 00000000..cfcc2317 --- /dev/null +++ b/third/python-cmake/patches/3.5/README.rst @@ -0,0 +1,10 @@ +* ``0001-Prevent-incorrect-include-of-io.h-and-memory.h-found.patch``: Rename header files found in + ``Modules/_decimal/libmpdec`` directory to avoid conflicts with system headers of the same name. + +* ``0002-Prevent-duplicated-OverlappedType-symbols-with-built.patch``: Prevent duplicated OverlappedType + symbols with built-in extension on Windows. + +* ``0003-mpdecimal-Export-inlined-functions-to-support-extens.patch``: Export inlined functions to + support extension built-in on Windows. + + diff --git a/third/python-cmake/patches/3.6.15/0001-bpo-35519-Rename-test.bisect-to-test.bisect_cmd-GH-1.patch b/third/python-cmake/patches/3.6.15/0001-bpo-35519-Rename-test.bisect-to-test.bisect_cmd-GH-1.patch new file mode 100644 index 00000000..8437e12d --- /dev/null +++ b/third/python-cmake/patches/3.6.15/0001-bpo-35519-Rename-test.bisect-to-test.bisect_cmd-GH-1.patch @@ -0,0 +1,45 @@ +From 8880127d669a170e0dad55631bc2fa03ceed51dd Mon Sep 17 00:00:00 2001 +From: Victor Stinner +Date: Mon, 17 Dec 2018 22:06:10 +0100 +Subject: [PATCH] bpo-35519: Rename test.bisect to test.bisect_cmd (GH-11200) + +Rename test.bisect module to test.bisect_cmd to avoid conflict with +bisect module when running directly a test like +"./python Lib/test/test_xmlrpc.py". +--- + Lib/test/{bisect.py => bisect_cmd.py} | 0 + Lib/test/support/__init__.py | 2 +- + .../NEWS.d/next/Tests/2018-12-17-16-41-45.bpo-35519.RR3L_w.rst | 3 +++ + 3 files changed, 4 insertions(+), 1 deletion(-) + rename Lib/test/{bisect.py => bisect_cmd.py} (100%) + create mode 100644 Misc/NEWS.d/next/Tests/2018-12-17-16-41-45.bpo-35519.RR3L_w.rst + +diff --git a/Lib/test/bisect.py b/Lib/test/bisect_cmd.py +similarity index 100% +rename from Lib/test/bisect.py +rename to Lib/test/bisect_cmd.py +diff --git a/Lib/test/support/__init__.py b/Lib/test/support/__init__.py +index 66c0fed8411..b40135bc8b9 100644 +--- a/Lib/test/support/__init__.py ++++ b/Lib/test/support/__init__.py +@@ -1972,7 +1972,7 @@ def set_match_tests(patterns): + patterns = () + elif all(map(_is_full_match_test, patterns)): + # Simple case: all patterns are full test identifier. +- # The test.bisect utility only uses such full test identifiers. ++ # The test.bisect_cmd utility only uses such full test identifiers. + func = set(patterns).__contains__ + else: + regex = '|'.join(map(fnmatch.translate, patterns)) +diff --git a/Misc/NEWS.d/next/Tests/2018-12-17-16-41-45.bpo-35519.RR3L_w.rst b/Misc/NEWS.d/next/Tests/2018-12-17-16-41-45.bpo-35519.RR3L_w.rst +new file mode 100644 +index 00000000000..e108dd877e1 +--- /dev/null ++++ b/Misc/NEWS.d/next/Tests/2018-12-17-16-41-45.bpo-35519.RR3L_w.rst +@@ -0,0 +1,3 @@ ++Rename :mod:`test.bisect` module to :mod:`test.bisect_cmd` to avoid conflict ++with :mod:`bisect` module when running directly a test like ++``./python Lib/test/test_xmlrpc.py``. +-- +2.48.1 + diff --git a/third/python-cmake/patches/3.6.15/README.rst b/third/python-cmake/patches/3.6.15/README.rst new file mode 100644 index 00000000..1cea1ceb --- /dev/null +++ b/third/python-cmake/patches/3.6.15/README.rst @@ -0,0 +1 @@ +* ``0001-bpo-35519-Rename-test.bisect-to-test.bisect_cmd-GH-1.patch``: bpo-35519: Rename test.bisect to test.bisect_cmd (GH-11200) diff --git a/third/python-cmake/patches/3.6/0001-Prevent-incorrect-include-of-io.h-found-in-libmpdec-.patch b/third/python-cmake/patches/3.6/0001-Prevent-incorrect-include-of-io.h-found-in-libmpdec-.patch new file mode 100644 index 00000000..0e37554f --- /dev/null +++ b/third/python-cmake/patches/3.6/0001-Prevent-incorrect-include-of-io.h-found-in-libmpdec-.patch @@ -0,0 +1,35 @@ +From 9ec49ea39b57e69722d82b41594479a896c65ae2 Mon Sep 17 00:00:00 2001 +From: Jean-Christophe Fillion-Robin +Date: Mon, 6 Nov 2017 21:44:29 -0500 +Subject: [PATCH 1/3] Prevent incorrect include of "io.h" found in libmpdec + directory + +This commit improves support for building python with built-in extensions +on windows where the header provided by libmpdec would be included instead +of the system one. +--- + Modules/_decimal/libmpdec/io.c | 2 +- + Modules/_decimal/libmpdec/{io.h => mpd_io.h} | 0 + 2 files changed, 1 insertion(+), 1 deletion(-) + rename Modules/_decimal/libmpdec/{io.h => mpd_io.h} (100%) + +diff --git a/Modules/_decimal/libmpdec/io.c b/Modules/_decimal/libmpdec/io.c +index 3aadfb0..1cc719a 100644 +--- a/Modules/_decimal/libmpdec/io.c ++++ b/Modules/_decimal/libmpdec/io.c +@@ -38,7 +38,7 @@ + #include "bits.h" + #include "constants.h" + #include "typearith.h" +-#include "io.h" ++#include "mpd_io.h" + + + /* This file contains functions for decimal <-> string conversions, including +diff --git a/Modules/_decimal/libmpdec/io.h b/Modules/_decimal/libmpdec/mpd_io.h +similarity index 100% +rename from Modules/_decimal/libmpdec/io.h +rename to Modules/_decimal/libmpdec/mpd_io.h +-- +2.5.0 + diff --git a/third/python-cmake/patches/3.6/0002-Prevent-duplicated-OverlappedType-symbols-with-built.patch b/third/python-cmake/patches/3.6/0002-Prevent-duplicated-OverlappedType-symbols-with-built.patch new file mode 100644 index 00000000..6fd360a5 --- /dev/null +++ b/third/python-cmake/patches/3.6/0002-Prevent-duplicated-OverlappedType-symbols-with-built.patch @@ -0,0 +1,65 @@ +From d96bfdc9f531eaefdab931f6b2830278c2dc0226 Mon Sep 17 00:00:00 2001 +From: Jean-Christophe Fillion-Robin +Date: Mon, 6 Nov 2017 10:37:50 -0500 +Subject: [PATCH 2/3] Prevent duplicated OverlappedType symbols with built-in + extension on windows + +This commit improves support for building python with built-in extensions +on windows where the symbol from overlapped.c would clash with the one +from _winapi.c +--- + Modules/_winapi.c | 10 +++++----- + 1 file changed, 5 insertions(+), 5 deletions(-) + +diff --git a/Modules/_winapi.c b/Modules/_winapi.c +index 1606f0d..d81215f 100644 +--- a/Modules/_winapi.c ++++ b/Modules/_winapi.c +@@ -147,7 +147,7 @@ overlapped_dealloc(OverlappedObject *self) + + /*[clinic input] + module _winapi +-class _winapi.Overlapped "OverlappedObject *" "&OverlappedType" ++class _winapi.Overlapped "OverlappedObject *" "&WinApiOverlappedType" + [clinic start generated code]*/ + /*[clinic end generated code: output=da39a3ee5e6b4b0d input=c13d3f5fd1dabb84]*/ + +@@ -295,7 +295,7 @@ static PyMemberDef overlapped_members[] = { + {NULL} + }; + +-PyTypeObject OverlappedType = { ++PyTypeObject WinApiOverlappedType = { + PyVarObject_HEAD_INIT(NULL, 0) + /* tp_name */ "_winapi.Overlapped", + /* tp_basicsize */ sizeof(OverlappedObject), +@@ -341,7 +341,7 @@ new_overlapped(HANDLE handle) + { + OverlappedObject *self; + +- self = PyObject_New(OverlappedObject, &OverlappedType); ++ self = PyObject_New(OverlappedObject, &WinApiOverlappedType); + if (!self) + return NULL; + self->handle = handle; +@@ -1537,7 +1537,7 @@ PyInit__winapi(void) + PyObject *d; + PyObject *m; + +- if (PyType_Ready(&OverlappedType) < 0) ++ if (PyType_Ready(&WinApiOverlappedType) < 0) + return NULL; + + m = PyModule_Create(&winapi_module); +@@ -1545,7 +1545,7 @@ PyInit__winapi(void) + return NULL; + d = PyModule_GetDict(m); + +- PyDict_SetItemString(d, "Overlapped", (PyObject *) &OverlappedType); ++ PyDict_SetItemString(d, "Overlapped", (PyObject *) &WinApiOverlappedType); + + /* constants */ + WINAPI_CONSTANT(F_DWORD, CREATE_NEW_CONSOLE); +-- +2.5.0 + diff --git a/third/python-cmake/patches/3.6/0003-mpdecimal-Export-inlined-functions-to-support-extens.patch b/third/python-cmake/patches/3.6/0003-mpdecimal-Export-inlined-functions-to-support-extens.patch new file mode 100644 index 00000000..eaa49dc0 --- /dev/null +++ b/third/python-cmake/patches/3.6/0003-mpdecimal-Export-inlined-functions-to-support-extens.patch @@ -0,0 +1,36 @@ +From 12cd7e4b43f85822d8ab0531cb3097e5f32bd5ff Mon Sep 17 00:00:00 2001 +From: Jean-Christophe Fillion-Robin +Date: Mon, 6 Nov 2017 11:27:32 -0500 +Subject: [PATCH 3/3] mpdecimal: Export inlined functions to support extension + built-in on windows + +This commit ensures that symbols are available when building _freeze_importlib +with all extensions built-in on windows. + +It addresses the following link error associated +with CMakeBuild\libpython\_freeze_importlib.vcxproj: + + 3>_decimal.obj : error LNK2019: unresolved external symbol _mpd_del referenced in function _PyDec_AsTuple + 3>io.obj : error LNK2001: unresolved external symbol _mpd_del + 3>basearith.obj : error LNK2019: unresolved external symbol _mpd_uint_zero referenced in function __mpd_baseshiftl + 3>io.obj : error LNK2019: unresolved external symbol _mpd_qresize referenced in function _mpd_qset_string +--- + Modules/_decimal/libmpdec/mpdecimal.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/Modules/_decimal/libmpdec/mpdecimal.c b/Modules/_decimal/libmpdec/mpdecimal.c +index 328ab92..5812bcd 100644 +--- a/Modules/_decimal/libmpdec/mpdecimal.c ++++ b/Modules/_decimal/libmpdec/mpdecimal.c +@@ -54,7 +54,7 @@ + + + #if defined(_MSC_VER) +- #define ALWAYS_INLINE __forceinline ++ #define ALWAYS_INLINE extern __forceinline + #elif defined(LEGACY_COMPILER) + #define ALWAYS_INLINE + #undef inline +-- +2.5.0 + diff --git a/third/python-cmake/patches/3.6/0004-Fix-Windows-build-of-Python-for-latest-WinSDK.patch b/third/python-cmake/patches/3.6/0004-Fix-Windows-build-of-Python-for-latest-WinSDK.patch new file mode 100644 index 00000000..ed778347 --- /dev/null +++ b/third/python-cmake/patches/3.6/0004-Fix-Windows-build-of-Python-for-latest-WinSDK.patch @@ -0,0 +1,26 @@ +From ca436844d5dddcb0156ada7fadc9fa4c38d8bcbe Mon Sep 17 00:00:00 2001 +From: Jean-Christophe Fillion-Robin +Date: Fri, 12 Apr 2019 16:36:42 -0400 +Subject: [PATCH 4/4] Fix Windows build of Python for latest WinSDK. + +This is a partial backport of https://github.com/python/cpython/commit/df4852cbe4b757e8b79506d73a09ec8a1b595970 +--- + Modules/_io/_iomodule.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/Modules/_io/_iomodule.c b/Modules/_io/_iomodule.c +index f4d3cbd49f..f7ad176990 100644 +--- a/Modules/_io/_iomodule.c ++++ b/Modules/_io/_iomodule.c +@@ -21,7 +21,7 @@ + #endif /* HAVE_SYS_STAT_H */ + + #ifdef MS_WINDOWS +-#include ++#include + #endif + + /* Various interned strings */ +-- +2.11.0 + diff --git a/third/python-cmake/patches/3.6/README.rst b/third/python-cmake/patches/3.6/README.rst new file mode 100644 index 00000000..612e7d59 --- /dev/null +++ b/third/python-cmake/patches/3.6/README.rst @@ -0,0 +1,12 @@ +* ``0001-Prevent-incorrect-include-of-io.h-found-in-libmpdec-.patch``: Rename header files found in + ``Modules/_decimal/libmpdec`` directory to avoid conflicts with system headers of the same name. + +* ``0002-Prevent-duplicated-OverlappedType-symbols-with-built.patch``: Prevent duplicated OverlappedType + symbols with built-in extension on Windows. + +* ``0003-mpdecimal-Export-inlined-functions-to-support-extens.patch``: Export inlined functions to + support extension built-in on Windows. + +* ``0004-Fix-Windows-build-of-Python-for-latest-WinSDK.patch``: Fix build of iomodule using + Visual Studio >= 2017. It is a partial backport of commit [python/cpython@df4852c](https://github.com/python/cpython/commit/df4852cbe4b757e8b79506d73a09ec8a1b595970) + originally associated with [CPython GH-6874](https://github.com/python/cpython/pull/6874). diff --git a/third/python-cmake/patches/README.rst b/third/python-cmake/patches/README.rst new file mode 100644 index 00000000..f005bcfd --- /dev/null +++ b/third/python-cmake/patches/README.rst @@ -0,0 +1,50 @@ +CPython Patches +=============== + +Fixes and improvements to CPython should first be contributed upstream. The +`Python Developer’s Guide `_ is a great +resource to guide you through the process. + +That said, there are few scenarios where using `python-cmake-buildsystem` to +patch CPython is relevant. Learn more about these at https://github.com/python-cmake-buildsystem/cpython. + +By default, patches are applied at configuration time. Setting the option +``PYTHON_APPLY_PATCHES`` to ``OFF`` allows to change this. Note that the +build system keep track which patches have been applied. + +Each patch is documented by adding an entry to the `README.rst` file +found in the same directory (or a parent directory). Whenever possible, +references to `bugs.python.org `_(bpo) issues, +corresponding `GitHub PRs `_ and +any related discussions on forums or mailing lists are also provided. + +Patches are organized per python version. Patches specific to a system, +a system+compiler, or a system+compiler+compiler_version are organized in +corresponding sub-directories:: + + patches/. + patches/ + patches// + patches//- + patches//-/ + +where + +* ```` is of the form ``X.Y.Z`` + +* ```` is a value like ``Darwin``, ``Linux`` or ``Windows``. See + corresponding CMake documentation for more details. + +* ```` is a valid like ``Clang``, ``GNU`` or ``MSVC``. See + corresponding CMake documentation for more details. + +* ```` is set to the value of ``CMAKE_C_COMPILER_VERSION`` (e.g ``5.2.1``) + except when using Microsoft compiler where it is set to the value of ``MSVC_VERSION`` (e.g ``1900``). + +Before being applied, patches are sorted alphabetically. This ensures that +patch starting with `0001-` is applied before the one starting with `0002-`. + + +Note that for historical reasons, there are still patches found in ``cmake/patches`` +and ``cmake/patches-win32`` subdirectories. These will gradually be organized as +described above.