1 dnl ************************************************************
2 dnl * Please run autoreconf -ivf -Werror to test your changes! *
3 dnl ************************************************************
5 dnl Python's configure script requires autoconf 2.71, autoconf-archive,
6 dnl aclocal 1.16, and pkg-config.
8 dnl It is recommended to use the Tools/build/regen-configure.sh shell script
9 dnl to regenerate the configure script.
12 # Set VERSION so we only need to edit in one place (i.e., here)
13 m4_define([PYTHON_VERSION], [3.13])
17 AC_INIT([python],[PYTHON_VERSION],[https://github.com/python/cpython/issues/])
20 [AX_C_FLOAT_WORDS_BIGENDIAN],
22 [AC_MSG_ERROR([Please install autoconf-archive package and re-run autoreconf])]
25 [PKG_PROG_PKG_CONFIG],
27 [AC_MSG_ERROR([Please install pkgconf's m4 macro package and re-run autoreconf])]
30 dnl Helpers for saving and restoring environment variables:
31 dnl - _SAVE_VAR([VAR]) Helper for SAVE_ENV; stores VAR as save_VAR
32 dnl - _RESTORE_VAR([VAR]) Helper for RESTORE_ENV; restores VAR from save_VAR
33 dnl - SAVE_ENV Saves CFLAGS, LDFLAGS, LIBS, and CPPFLAGS
34 dnl - RESTORE_ENV Restores CFLAGS, LDFLAGS, LIBS, and CPPFLAGS
35 dnl - WITH_SAVE_ENV([SCRIPT]) Runs SCRIPT wrapped with SAVE_ENV/RESTORE_ENV
36 AC_DEFUN([_SAVE_VAR], [AS_VAR_COPY([save_][$1], [$1])])dnl
37 AC_DEFUN([_RESTORE_VAR], [AS_VAR_COPY([$1], [save_][$1])])dnl
40 [_SAVE_VAR([CPPFLAGS])]
41 [_SAVE_VAR([LDFLAGS])]
44 AC_DEFUN([RESTORE_ENV],
45 [_RESTORE_VAR([CFLAGS])]
46 [_RESTORE_VAR([CPPFLAGS])]
47 [_RESTORE_VAR([LDFLAGS])]
48 [_RESTORE_VAR([LIBS])]
50 AC_DEFUN([WITH_SAVE_ENV],
56 dnl PY_CHECK_FUNC(FUNCTION, [INCLUDES], [AC_DEFINE-VAR])
57 AC_DEFUN([PY_CHECK_FUNC],
58 [ AS_VAR_PUSHDEF([py_var], [ac_cv_func_$1])
59 AS_VAR_PUSHDEF([py_define], m4_ifblank([$3], [[HAVE_]m4_toupper($1)], [$3]))
64 [AC_LANG_PROGRAM([$2], [void *x=$1])],
65 [AS_VAR_SET([py_var], [yes])],
66 [AS_VAR_SET([py_var], [no])])]
71 [AC_DEFINE([py_define], [1], [Define if you have the '$1' function.])])
72 AS_VAR_POPDEF([py_var])
73 AS_VAR_POPDEF([py_define])
76 dnl PY_CHECK_LIB(LIBRARY, FUNCTION, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND], [OTHER-LIBRARIES])
77 dnl Like AC_CHECK_LIB() but does not modify LIBS
78 AC_DEFUN([PY_CHECK_LIB],
79 [AS_VAR_COPY([py_check_lib_save_LIBS], [LIBS])]
80 [AC_CHECK_LIB([$1], [$2], [$3], [$4], [$5])]
81 [AS_VAR_COPY([LIBS], [py_check_lib_save_LIBS])]
84 dnl PY_CHECK_EMSCRIPTEN_PORT(PKG_VAR, [EMPORT_ARGS])
85 dnl Use Emscripten port unless user passes ${PKG_VAR}_CFLAGS
86 dnl or ${PKG_VAR}_LIBS to configure.
87 AC_DEFUN([PY_CHECK_EMSCRIPTEN_PORT], [
88 AS_VAR_PUSHDEF([py_cflags], [$1_CFLAGS])
89 AS_VAR_PUSHDEF([py_libs], [$1_LIBS])
90 AS_IF([test "$ac_sys_system" = "Emscripten" -a -z "$py_cflags" -a -z "$py_libs"], [
94 AS_VAR_POPDEF([py_cflags])
95 AS_VAR_POPDEF([py_libs])
98 AC_SUBST([BASECPPFLAGS])
99 if test "$srcdir" != . -a "$srcdir" != "$(pwd)"; then
100 # If we're building out-of-tree, we need to make sure the following
101 # resources get picked up before their $srcdir counterparts.
102 # Objects/ -> typeslots.inc
103 # Include/ -> Python.h
104 # (A side effect of this is that these resources will automatically be
105 # regenerated when building out-of-tree, regardless of whether or not
106 # the $srcdir counterpart is up-to-date. This is an acceptable trade
108 BASECPPFLAGS="-IObjects -IInclude -IPython"
113 AC_SUBST([GITVERSION])
115 AC_SUBST([GITBRANCH])
117 if test -e $srcdir/.git
119 AC_CHECK_PROG([HAS_GIT], [git], [found], [not-found])
121 HAS_GIT=no-repository
123 if test $HAS_GIT = found
125 GITVERSION="git --git-dir \$(srcdir)/.git rev-parse --short HEAD"
126 GITTAG="git --git-dir \$(srcdir)/.git describe --all --always --dirty"
127 GITBRANCH="git --git-dir \$(srcdir)/.git name-rev --name-only HEAD"
134 AC_CONFIG_SRCDIR([Include/object.h])
135 AC_CONFIG_HEADERS([pyconfig.h])
141 AS_VAR_IF([cross_compiling], [maybe],
142 [AC_MSG_ERROR([Cross compiling required --host=HOST-TUPLE and --build=ARCH])]
145 # pybuilddir.txt will be created by --generate-posix-vars in the Makefile
148 AC_ARG_WITH([build-python],
149 [AS_HELP_STRING([--with-build-python=python]PYTHON_VERSION,
150 [path to build python binary for cross compiling (default: _bootstrap_python or python]PYTHON_VERSION[)])],
152 AC_MSG_CHECKING([for --with-build-python])
154 AS_VAR_IF([with_build_python], [yes], [with_build_python=python$PACKAGE_VERSION])
155 AS_VAR_IF([with_build_python], [no], [AC_MSG_ERROR([invalid --with-build-python option: expected path or "yes", not "no"])])
157 if ! $(command -v "$with_build_python" >/dev/null 2>&1); then
158 AC_MSG_ERROR([invalid or missing build python binary "$with_build_python"])
160 build_python_ver=$($with_build_python -c "import sys; print(f'{sys.version_info.major}.{sys.version_info.minor}')")
161 if test "$build_python_ver" != "$PACKAGE_VERSION"; then
162 AC_MSG_ERROR(["$with_build_python" has incompatible version $build_python_ver (expected: $PACKAGE_VERSION)])
164 dnl Build Python interpreter is used for regeneration and freezing.
165 ac_cv_prog_PYTHON_FOR_REGEN=$with_build_python
166 PYTHON_FOR_FREEZE="$with_build_python"
167 PYTHON_FOR_BUILD='_PYTHON_PROJECT_BASE=$(abs_builddir) _PYTHON_HOST_PLATFORM=$(_PYTHON_HOST_PLATFORM) PYTHONPATH=$(shell test -f pybuilddir.txt && echo $(abs_builddir)/`cat pybuilddir.txt`:)$(srcdir)/Lib _PYTHON_SYSCONFIGDATA_NAME=_sysconfigdata_$(ABIFLAGS)_$(MACHDEP)_$(MULTIARCH) '$with_build_python
168 AC_MSG_RESULT([$with_build_python])
170 AS_VAR_IF([cross_compiling], [yes],
171 [AC_MSG_ERROR([Cross compiling requires --with-build-python])]
173 PYTHON_FOR_BUILD='./$(BUILDPYTHON) -E'
174 PYTHON_FOR_FREEZE="./_bootstrap_python"
177 AC_SUBST([PYTHON_FOR_BUILD])
179 AC_MSG_CHECKING([for Python interpreter freezing])
180 AC_MSG_RESULT([$PYTHON_FOR_FREEZE])
181 AC_SUBST([PYTHON_FOR_FREEZE])
183 AS_VAR_IF([cross_compiling], [yes],
185 dnl external build Python, freezing depends on Programs/_freeze_module.py
186 FREEZE_MODULE_BOOTSTRAP='$(PYTHON_FOR_FREEZE) $(srcdir)/Programs/_freeze_module.py'
187 FREEZE_MODULE_BOOTSTRAP_DEPS='$(srcdir)/Programs/_freeze_module.py'
188 FREEZE_MODULE='$(FREEZE_MODULE_BOOTSTRAP)'
189 FREEZE_MODULE_DEPS='$(FREEZE_MODULE_BOOTSTRAP_DEPS)'
190 PYTHON_FOR_BUILD_DEPS=''
193 dnl internal build tools also depend on Programs/_freeze_module and _bootstrap_python.
194 FREEZE_MODULE_BOOTSTRAP='./Programs/_freeze_module'
195 FREEZE_MODULE_BOOTSTRAP_DEPS="Programs/_freeze_module"
196 FREEZE_MODULE='$(PYTHON_FOR_FREEZE) $(srcdir)/Programs/_freeze_module.py'
197 FREEZE_MODULE_DEPS="_bootstrap_python \$(srcdir)/Programs/_freeze_module.py"
198 PYTHON_FOR_BUILD_DEPS='$(BUILDPYTHON)'
201 AC_SUBST([FREEZE_MODULE_BOOTSTRAP])
202 AC_SUBST([FREEZE_MODULE_BOOTSTRAP_DEPS])
203 AC_SUBST([FREEZE_MODULE])
204 AC_SUBST([FREEZE_MODULE_DEPS])
205 AC_SUBST([PYTHON_FOR_BUILD_DEPS])
207 AC_CHECK_PROGS([PYTHON_FOR_REGEN],
208 [python$PACKAGE_VERSION python3.13 python3.12 python3.11 python3.10 python3 python],
210 AC_SUBST([PYTHON_FOR_REGEN])
212 AC_MSG_CHECKING([Python for regen version])
213 if command -v "$PYTHON_FOR_REGEN" >/dev/null 2>&1; then
214 AC_MSG_RESULT([$($PYTHON_FOR_REGEN -V 2>/dev/null)])
216 AC_MSG_RESULT([missing])
219 dnl Ensure that if prefix is specified, it does not end in a slash. If
220 dnl it does, we get path names containing '//' which is both ugly and
221 dnl can cause trouble.
223 dnl Last slash shouldn't be stripped if prefix=/
224 if test "$prefix" != "/"; then
225 prefix=`echo "$prefix" | sed -e 's/\/$//g'`
228 dnl This is for stuff that absolutely must end up in pyconfig.h.
229 dnl Please use pyport.h instead, if possible.
231 #ifndef Py_PYCONFIG_H
232 #define Py_PYCONFIG_H
235 /* Define the macros needed if on a UnixWare 7.x system. */
236 #if defined(__USLC__) && defined(__SCO_VERSION__)
237 #define STRICT_SYSV_CURSES /* Don't use ncurses extensions */
240 #endif /*Py_PYCONFIG_H*/
243 # We don't use PACKAGE_ variables, and they cause conflicts
244 # with other autoconf-based packages that include Python.h
245 grep -v 'define PACKAGE_' <confdefs.h >confdefs.h.new
247 mv confdefs.h.new confdefs.h
250 VERSION=PYTHON_VERSION
252 # Version number of Python's own shared library file.
253 AC_SUBST([SOVERSION])
256 # The later definition of _XOPEN_SOURCE and _POSIX_C_SOURCE disables
257 # certain features on NetBSD, so we need _NETBSD_SOURCE to re-enable
259 AC_DEFINE([_NETBSD_SOURCE], [1],
260 [Define on NetBSD to activate all library features])
262 # The later definition of _XOPEN_SOURCE and _POSIX_C_SOURCE disables
263 # certain features on FreeBSD, so we need __BSD_VISIBLE to re-enable
265 AC_DEFINE([__BSD_VISIBLE], [1],
266 [Define on FreeBSD to activate all library features])
268 # The later definition of _XOPEN_SOURCE and _POSIX_C_SOURCE disables
269 # certain features on Mac OS X, so we need _DARWIN_C_SOURCE to re-enable
271 AC_DEFINE([_DARWIN_C_SOURCE], [1],
272 [Define on Darwin to activate all library features])
275 define_xopen_source=yes
277 # Arguments passed to configure.
278 AC_SUBST([CONFIG_ARGS])
279 CONFIG_ARGS="$ac_configure_args"
281 dnl Allow users to disable pkg-config or require pkg-config
282 AC_ARG_WITH([pkg-config],
283 [AS_HELP_STRING([[--with-pkg-config=[yes|no|check]]],
284 [use pkg-config to detect build options (default is check)])],
286 [with_pkg_config=check]
288 AS_CASE([$with_pkg_config],
290 if test -z "$PKG_CONFIG"; then
291 dnl invalidate stale config.cache values
292 AS_UNSET([PKG_CONFIG])
293 AS_UNSET([ac_cv_path_ac_pt_PKG_CONFIG])
294 AS_UNSET([ac_cv_prog_ac_ct_PKG_CONFIG])
300 dnl force AX_CHECK_OPENSSL to ignore pkg-config
301 ac_cv_path_ac_pt_PKG_CONFIG=''
302 ac_cv_prog_ac_ct_PKG_CONFIG=''
304 [AC_MSG_ERROR([invalid argument --with-pkg-config=$with_pkg_config])]
306 if test "$with_pkg_config" = yes -a -z "$PKG_CONFIG"; then
307 AC_MSG_ERROR([pkg-config is required])]
310 # Set name for machine-dependent library files
311 AC_ARG_VAR([MACHDEP], [name for machine-dependent library files])
312 AC_MSG_CHECKING([MACHDEP])
313 if test -z "$MACHDEP"
315 # avoid using uname for cross builds
316 if test "$cross_compiling" = yes; then
317 # ac_sys_system and ac_sys_release are used for setting
318 # a lot of different things including 'define_xopen_source'
319 # in the case statement below.
322 ac_sys_system=Linux-android
334 ac_sys_system=VxWorks
337 ac_sys_system=Emscripten
343 # for now, limit cross builds to known configurations
345 AC_MSG_ERROR([cross build not supported for $host])
349 ac_sys_system=`uname -s`
350 if test "$ac_sys_system" = "AIX" \
351 -o "$ac_sys_system" = "UnixWare" -o "$ac_sys_system" = "OpenUNIX"; then
352 ac_sys_release=`uname -v`
354 ac_sys_release=`uname -r`
357 ac_md_system=`echo $ac_sys_system |
358 tr -d '[/ ]' | tr '[[A-Z]]' '[[a-z]]'`
359 ac_md_release=`echo $ac_sys_release |
360 tr -d '[/ ]' | sed 's/^[[A-Z]]\.//' | sed 's/\..*//'`
361 MACHDEP="$ac_md_system$ac_md_release"
364 aix*) MACHDEP="aix";;
365 linux-android*) MACHDEP="android";;
366 linux*) MACHDEP="linux";;
367 cygwin*) MACHDEP="cygwin";;
368 darwin*) MACHDEP="darwin";;
369 '') MACHDEP="unknown";;
372 if test "$ac_sys_system" = "SunOS"; then
373 # For Solaris, there isn't an OS version specific macro defined
374 # in most compilers, so we define one here.
375 SUNOS_VERSION=`echo $ac_sys_release | sed -e 's!\.\([0-9]\)$!.0\1!g' | tr -d '.'`
376 AC_DEFINE_UNQUOTED([Py_SUNOS_VERSION], [$SUNOS_VERSION],
377 [The version of SunOS/Solaris as reported by `uname -r' without the dot.])
380 AC_MSG_RESULT(["$MACHDEP"])
382 # On cross-compile builds, configure will look for a host-specific compiler by
383 # prepending the user-provided host triple to the required binary name.
385 # On iOS, this results in binaries like "arm64-apple-ios12.0-simulator-gcc",
386 # which isn't a binary that exists, and isn't very convenient, as it contains the
387 # iOS version. As the default cross-compiler name won't exist, configure falls
388 # back to gcc, which *definitely* won't work. We're providing wrapper scripts for
389 # these tools; the binary names of these scripts are better defaults than "gcc".
390 # This only requires that the user put the platform scripts folder (e.g.,
391 # "iOS/Resources/bin") in their path, rather than defining platform-specific
392 # names/paths for AR, CC, CPP, and CXX explicitly; and if the user forgets to
393 # either put the platform scripts folder in the path, or specify CC etc,
394 # configure will fail.
395 if test -z "$AR"; then
397 aarch64-apple-ios*-simulator) AR=arm64-apple-ios-simulator-ar ;;
398 aarch64-apple-ios*) AR=arm64-apple-ios-ar ;;
399 x86_64-apple-ios*-simulator) AR=x86_64-apple-ios-simulator-ar ;;
403 if test -z "$CC"; then
405 aarch64-apple-ios*-simulator) CC=arm64-apple-ios-simulator-clang ;;
406 aarch64-apple-ios*) CC=arm64-apple-ios-clang ;;
407 x86_64-apple-ios*-simulator) CC=x86_64-apple-ios-simulator-clang ;;
411 if test -z "$CPP"; then
413 aarch64-apple-ios*-simulator) CPP=arm64-apple-ios-simulator-cpp ;;
414 aarch64-apple-ios*) CPP=arm64-apple-ios-cpp ;;
415 x86_64-apple-ios*-simulator) CPP=x86_64-apple-ios-simulator-cpp ;;
419 if test -z "$CXX"; then
421 aarch64-apple-ios*-simulator) CXX=arm64-apple-ios-simulator-clang ;;
422 aarch64-apple-ios*) CXX=arm64-apple-ios-clang ;;
423 x86_64-apple-ios*-simulator) CXX=x86_64-apple-ios-simulator-clang ;;
428 AC_MSG_CHECKING([for --enable-universalsdk])
429 AC_ARG_ENABLE([universalsdk],
430 AS_HELP_STRING([--enable-universalsdk@<:@=SDKDIR@:>@],
431 [create a universal binary build.
432 SDKDIR specifies which macOS SDK should be used to perform the build,
433 see Mac/README.rst. (default is no)]),
437 # Locate the best usable SDK, see Mac/README for more
439 enableval="`/usr/bin/xcodebuild -version -sdk macosx Path 2>/dev/null`"
440 if ! ( echo $enableval | grep -E '\.sdk' 1>/dev/null )
442 enableval=/Developer/SDKs/MacOSX10.4u.sdk
443 if test ! -d "${enableval}"
456 UNIVERSALSDK=$enableval
457 if test ! -d "${UNIVERSALSDK}"
459 AC_MSG_ERROR([--enable-universalsdk specifies non-existing SDK: ${UNIVERSALSDK}])
468 if test -n "${UNIVERSALSDK}"
470 AC_MSG_RESULT([${UNIVERSALSDK}])
474 AC_SUBST([UNIVERSALSDK])
476 AC_SUBST([ARCH_RUN_32BIT])
479 # For backward compatibility reasons we prefer to select '32-bit' if available,
480 # otherwise use 'intel'
481 UNIVERSAL_ARCHS="32-bit"
482 if test "`uname -s`" = "Darwin"
484 if test -n "${UNIVERSALSDK}"
486 if test -z "`/usr/bin/file -L "${UNIVERSALSDK}/usr/lib/libSystem.dylib" | grep ppc`"
488 UNIVERSAL_ARCHS="intel"
493 AC_SUBST([LIPO_32BIT_FLAGS])
494 AC_SUBST([LIPO_INTEL64_FLAGS])
495 AC_MSG_CHECKING([for --with-universal-archs])
496 AC_ARG_WITH([universal-archs],
497 AS_HELP_STRING([--with-universal-archs=ARCH],
498 [specify the kind of macOS universal binary that should be created.
499 This option is only valid when --enable-universalsdk is set; options are:
500 ("universal2", "intel-64", "intel-32", "intel", "32-bit",
501 "64-bit", "3-way", or "all")
502 see Mac/README.rst]),
504 UNIVERSAL_ARCHS="$withval"
507 if test -n "${UNIVERSALSDK}"
509 AC_MSG_RESULT([${UNIVERSAL_ARCHS}])
514 AC_ARG_WITH([framework-name],
515 AS_HELP_STRING([--with-framework-name=FRAMEWORK],
516 [specify the name for the python framework on macOS
517 only valid when --enable-framework is set. see Mac/README.rst
518 (default is 'Python')]),
520 PYTHONFRAMEWORK=${withval}
521 PYTHONFRAMEWORKDIR=${withval}.framework
522 PYTHONFRAMEWORKIDENTIFIER=org.python.`echo $withval | tr '[A-Z]' '[a-z]'`
524 PYTHONFRAMEWORK=Python
525 PYTHONFRAMEWORKDIR=Python.framework
526 PYTHONFRAMEWORKIDENTIFIER=org.python.python
528 dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
529 AC_ARG_ENABLE([framework],
530 AS_HELP_STRING([--enable-framework@<:@=INSTALLDIR@:>@],
531 [create a Python.framework rather than a traditional Unix install.
532 optional INSTALLDIR specifies the installation path. see Mac/README.rst
537 case $ac_sys_system in
538 Darwin) enableval=/Library/Frameworks ;;
539 iOS) enableval=iOS/Frameworks/\$\(MULTIARCH\) ;;
540 *) AC_MSG_ERROR([Unknown platform for framework build])
546 case $ac_sys_system in
547 iOS) AC_MSG_ERROR([iOS builds must use --enable-framework]) ;;
550 PYTHONFRAMEWORKDIR=no-framework
551 PYTHONFRAMEWORKPREFIX=
552 PYTHONFRAMEWORKINSTALLDIR=
553 PYTHONFRAMEWORKINSTALLNAMEPREFIX=
555 FRAMEWORKINSTALLFIRST=
556 FRAMEWORKINSTALLLAST=
557 FRAMEWORKALTINSTALLFIRST=
558 FRAMEWORKALTINSTALLLAST=
560 INSTALLTARGETS="commoninstall bininstall maninstall"
562 if test "x${prefix}" = "xNONE"; then
563 FRAMEWORKUNIXTOOLSPREFIX="${ac_default_prefix}"
565 FRAMEWORKUNIXTOOLSPREFIX="${prefix}"
571 PYTHONFRAMEWORKPREFIX="${enableval}"
572 PYTHONFRAMEWORKINSTALLDIR=$PYTHONFRAMEWORKPREFIX/$PYTHONFRAMEWORKDIR
574 case $ac_sys_system in #(
576 FRAMEWORKINSTALLFIRST="frameworkinstallversionedstructure"
577 FRAMEWORKALTINSTALLFIRST="frameworkinstallversionedstructure "
578 FRAMEWORKINSTALLLAST="frameworkinstallmaclib frameworkinstallapps frameworkinstallunixtools"
579 FRAMEWORKALTINSTALLLAST="frameworkinstallmaclib frameworkinstallapps frameworkaltinstallunixtools"
580 FRAMEWORKPYTHONW="frameworkpythonw"
581 FRAMEWORKINSTALLAPPSPREFIX="/Applications"
582 INSTALLTARGETS="commoninstall bininstall maninstall"
584 if test "x${prefix}" = "xNONE" ; then
585 FRAMEWORKUNIXTOOLSPREFIX="${ac_default_prefix}"
588 FRAMEWORKUNIXTOOLSPREFIX="${prefix}"
591 case "${enableval}" in
593 FRAMEWORKINSTALLAPPSPREFIX="/Applications"
594 if test "${prefix}" = "NONE" ; then
596 FRAMEWORKUNIXTOOLSPREFIX="/usr"
601 FRAMEWORKINSTALLAPPSPREFIX="/Applications"
604 */Library/Frameworks)
605 MDIR="`dirname "${enableval}"`"
606 MDIR="`dirname "${MDIR}"`"
607 FRAMEWORKINSTALLAPPSPREFIX="${MDIR}/Applications"
609 if test "${prefix}" = "NONE"; then
610 # User hasn't specified the
611 # --prefix option, but wants to install
612 # the framework in a non-default location,
613 # ensure that the compatibility links get
614 # installed relative to that prefix as well
615 # instead of in /usr/local.
616 FRAMEWORKUNIXTOOLSPREFIX="${MDIR}"
621 FRAMEWORKINSTALLAPPSPREFIX="/Applications"
625 prefix=$PYTHONFRAMEWORKINSTALLDIR/Versions/$VERSION
626 PYTHONFRAMEWORKINSTALLNAMEPREFIX=${prefix}
627 RESSRCDIR=Mac/Resources/framework
629 # Add files for Mac specific code to the list of output
631 AC_CONFIG_FILES([Mac/Makefile])
632 AC_CONFIG_FILES([Mac/PythonLauncher/Makefile])
633 AC_CONFIG_FILES([Mac/Resources/framework/Info.plist])
634 AC_CONFIG_FILES([Mac/Resources/app/Info.plist])
637 FRAMEWORKINSTALLFIRST="frameworkinstallunversionedstructure"
638 FRAMEWORKALTINSTALLFIRST="frameworkinstallunversionedstructure "
639 FRAMEWORKINSTALLLAST="frameworkinstallmobileheaders"
640 FRAMEWORKALTINSTALLLAST="frameworkinstallmobileheaders"
642 INSTALLTARGETS="libinstall inclinstall sharedinstall"
644 prefix=$PYTHONFRAMEWORKPREFIX
645 PYTHONFRAMEWORKINSTALLNAMEPREFIX="@rpath/$PYTHONFRAMEWORKDIR"
646 RESSRCDIR=iOS/Resources
648 AC_CONFIG_FILES([iOS/Resources/Info.plist])
651 AC_MSG_ERROR([Unknown platform for framework build])
656 case $ac_sys_system in
657 iOS) AC_MSG_ERROR([iOS builds must use --enable-framework]) ;;
660 PYTHONFRAMEWORKDIR=no-framework
661 PYTHONFRAMEWORKPREFIX=
662 PYTHONFRAMEWORKINSTALLDIR=
663 PYTHONFRAMEWORKINSTALLNAMEPREFIX=
665 FRAMEWORKINSTALLFIRST=
666 FRAMEWORKINSTALLLAST=
667 FRAMEWORKALTINSTALLFIRST=
668 FRAMEWORKALTINSTALLLAST=
670 INSTALLTARGETS="commoninstall bininstall maninstall"
671 if test "x${prefix}" = "xNONE" ; then
672 FRAMEWORKUNIXTOOLSPREFIX="${ac_default_prefix}"
674 FRAMEWORKUNIXTOOLSPREFIX="${prefix}"
679 AC_SUBST([PYTHONFRAMEWORK])
680 AC_SUBST([PYTHONFRAMEWORKIDENTIFIER])
681 AC_SUBST([PYTHONFRAMEWORKDIR])
682 AC_SUBST([PYTHONFRAMEWORKPREFIX])
683 AC_SUBST([PYTHONFRAMEWORKINSTALLDIR])
684 AC_SUBST([PYTHONFRAMEWORKINSTALLNAMEPREFIX])
685 AC_SUBST([RESSRCDIR])
686 AC_SUBST([FRAMEWORKINSTALLFIRST])
687 AC_SUBST([FRAMEWORKINSTALLLAST])
688 AC_SUBST([FRAMEWORKALTINSTALLFIRST])
689 AC_SUBST([FRAMEWORKALTINSTALLLAST])
690 AC_SUBST([FRAMEWORKPYTHONW])
691 AC_SUBST([FRAMEWORKUNIXTOOLSPREFIX])
692 AC_SUBST([FRAMEWORKINSTALLAPPSPREFIX])
693 AC_SUBST([INSTALLTARGETS])
695 AC_DEFINE_UNQUOTED([_PYTHONFRAMEWORK], ["${PYTHONFRAMEWORK}"],
698 AC_SUBST([_PYTHON_HOST_PLATFORM])
699 if test "$cross_compiling" = yes; then
707 _host_ident=$host_cpu
714 _host_os=`echo $host | cut -d '-' -f3`
715 _host_device=`echo $host | cut -d '-' -f4`
716 _host_device=${_host_device:=os}
718 # IPHONEOS_DEPLOYMENT_TARGET is the minimum supported iOS version
719 IPHONEOS_DEPLOYMENT_TARGET=${_host_os:3}
720 IPHONEOS_DEPLOYMENT_TARGET=${IPHONEOS_DEPLOYMENT_TARGET:=12.0}
724 _host_ident=${IPHONEOS_DEPLOYMENT_TARGET}-arm64-iphone${_host_device}
727 _host_ident=${IPHONEOS_DEPLOYMENT_TARGET}-$host_cpu-iphone${_host_device}
732 _host_ident=$host_cpu
734 wasm32-*-* | wasm64-*-*)
735 _host_ident=$host_cpu
738 # for now, limit cross builds to known configurations
740 AC_MSG_ERROR([cross build not supported for $host])
742 _PYTHON_HOST_PLATFORM="$MACHDEP${_host_ident:+-$_host_ident}"
745 # Some systems cannot stand _XOPEN_SOURCE being defined at all; they
746 # disable features if it is defined, without any means to access these
747 # features as extensions. For these systems, we skip the definition of
748 # _XOPEN_SOURCE. Before adding a system to the list to gain access to
749 # some feature, make sure there is no alternative way to access this
750 # feature. Also, when using wildcards, make sure you have verified the
751 # need for not defining _XOPEN_SOURCE on all systems matching the
752 # wildcard, and that the wildcard does not include future systems
753 # (which may remove their limitations).
754 dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
755 case $ac_sys_system/$ac_sys_release in
756 # On OpenBSD, select(2) is not available if _XOPEN_SOURCE is defined,
757 # even though select is a POSIX function. Reported by J. Ribbens.
758 # Reconfirmed for OpenBSD 3.3 by Zachary Hamm, for 3.4 by Jason Ish.
759 # In addition, Stefan Krah confirms that issue #1244610 exists through
760 # OpenBSD 4.6, but is fixed in 4.7.
761 OpenBSD/2.* | OpenBSD/3.* | OpenBSD/4.@<:@0123456@:>@)
762 define_xopen_source=no
763 # OpenBSD undoes our definition of __BSD_VISIBLE if _XOPEN_SOURCE is
764 # also defined. This can be overridden by defining _BSD_SOURCE
765 # As this has a different meaning on Linux, only define it on OpenBSD
766 AC_DEFINE([_BSD_SOURCE], [1],
767 [Define on OpenBSD to activate all library features])
770 # OpenBSD undoes our definition of __BSD_VISIBLE if _XOPEN_SOURCE is
771 # also defined. This can be overridden by defining _BSD_SOURCE
772 # As this has a different meaning on Linux, only define it on OpenBSD
773 AC_DEFINE([_BSD_SOURCE], [1],
774 [Define on OpenBSD to activate all library features])
776 # Defining _XOPEN_SOURCE on NetBSD version prior to the introduction of
777 # _NETBSD_SOURCE disables certain features (eg. setgroups). Reported by
779 NetBSD/1.5 | NetBSD/1.5.* | NetBSD/1.6 | NetBSD/1.6.* | NetBSD/1.6@<:@A-S@:>@)
780 define_xopen_source=no;;
781 # From the perspective of Solaris, _XOPEN_SOURCE is not so much a
782 # request to enable features supported by the standard as a request
783 # to disable features not supported by the standard. The best way
784 # for Python to use Solaris is simply to leave _XOPEN_SOURCE out
785 # entirely and define __EXTENSIONS__ instead.
787 define_xopen_source=no;;
788 # On UnixWare 7, u_long is never defined with _XOPEN_SOURCE,
789 # but used in /usr/include/netinet/tcp.h. Reported by Tim Rice.
790 # Reconfirmed for 7.1.4 by Martin v. Loewis.
791 OpenUNIX/8.0.0| UnixWare/7.1.@<:@0-4@:>@)
792 define_xopen_source=no;;
793 # On OpenServer 5, u_short is never defined with _XOPEN_SOURCE,
794 # but used in struct sockaddr.sa_family. Reported by Tim Rice.
796 define_xopen_source=no;;
797 # On MacOS X 10.2, a bug in ncurses.h means that it craps out if
798 # _XOPEN_EXTENDED_SOURCE is defined. Apparently, this is fixed in 10.3, which
799 # identifies itself as Darwin/7.*
800 # On Mac OS X 10.4, defining _POSIX_C_SOURCE or _XOPEN_SOURCE
801 # disables platform specific features beyond repair.
802 # On Mac OS X 10.3, defining _POSIX_C_SOURCE or _XOPEN_SOURCE
803 # has no effect, don't bother defining them
804 Darwin/@<:@6789@:>@.*)
805 define_xopen_source=no;;
806 Darwin/@<:@[12]@:>@@<:@0-9@:>@.*)
807 define_xopen_source=no;;
808 # On iOS, defining _POSIX_C_SOURCE also disables platform specific features.
810 define_xopen_source=no;;
811 # On QNX 6.3.2, defining _XOPEN_SOURCE prevents netdb.h from
812 # defining NI_NUMERICHOST.
814 define_xopen_source=no
816 # On VxWorks, defining _XOPEN_SOURCE causes compile failures
817 # in network headers still using system V types.
819 define_xopen_source=no
822 # On HP-UX, defining _XOPEN_SOURCE to 600 or greater hides
823 # chroot() and other functions
825 define_xopen_source=no
830 if test $define_xopen_source = yes
832 # X/Open 7, incorporating POSIX.1-2008
833 AC_DEFINE([_XOPEN_SOURCE], [700],
834 [Define to the level of X/Open that your system supports])
836 # On Tru64 Unix 4.0F, defining _XOPEN_SOURCE also requires
837 # definition of _XOPEN_SOURCE_EXTENDED and _POSIX_C_SOURCE, or else
838 # several APIs are not declared. Since this is also needed in some
839 # cases for HP-UX, we define it globally.
840 AC_DEFINE([_XOPEN_SOURCE_EXTENDED], [1],
841 [Define to activate Unix95-and-earlier features])
843 AC_DEFINE([_POSIX_C_SOURCE], [200809L],
844 [Define to activate features from IEEE Stds 1003.1-2008])
847 # On HP-UX mbstate_t requires _INCLUDE__STDC_A1_SOURCE
848 case $ac_sys_system in
855 if test $define_stdc_a1 = yes
857 AC_DEFINE([_INCLUDE__STDC_A1_SOURCE], [1],
858 [Define to include mbstate_t for mbrtowc])
861 # Record the configure-time value of MACOSX_DEPLOYMENT_TARGET,
862 # it may influence the way we can build extensions, so distutils
864 AC_SUBST([CONFIGURE_MACOSX_DEPLOYMENT_TARGET])
865 AC_SUBST([EXPORT_MACOSX_DEPLOYMENT_TARGET])
866 CONFIGURE_MACOSX_DEPLOYMENT_TARGET=
867 EXPORT_MACOSX_DEPLOYMENT_TARGET='#'
869 # Record the value of IPHONEOS_DEPLOYMENT_TARGET enforced by the selected host triple.
870 AC_SUBST([IPHONEOS_DEPLOYMENT_TARGET])
872 # checks for alternative programs
874 # compiler flags are generated in two sets, BASECFLAGS and OPT. OPT is just
875 # for debug/optimization stuff. BASECFLAGS is for flags that are required
876 # just to get things to compile and link. Users are free to override OPT
877 # when running configure or make. The build should not break if they do.
878 # BASECFLAGS should generally not be messed with, however.
880 # If the user switches compilers, we can't believe the cache
881 if test ! -z "$ac_cv_prog_CC" -a ! -z "$CC" -a "$CC" != "$ac_cv_prog_CC"
883 AC_MSG_ERROR([cached CC is different -- throw away $cache_file
884 (it is also a good idea to do 'make clean' before compiling)])
887 # Don't let AC_PROG_CC set the default CFLAGS. It normally sets -g -O2
888 # when the compiler supports them, but we don't always want -O2, and
890 if test -z "$CFLAGS"; then
894 dnl Emscripten SDK and WASI SDK default to wasm32.
895 dnl On Emscripten use MEMORY64 setting to build target wasm64-emscripten.
898 [wasm64-*-emscripten], [
899 AS_VAR_APPEND([CFLAGS], [" -sMEMORY64=1"])
900 AS_VAR_APPEND([LDFLAGS], [" -sMEMORY64=1"])
904 dnl Add the compiler flag for the iOS minimum supported OS version.
905 AS_CASE([$ac_sys_system],
907 AS_VAR_APPEND([CFLAGS], [" -mios-version-min=${IPHONEOS_DEPLOYMENT_TARGET}"])
908 AS_VAR_APPEND([LDFLAGS], [" -mios-version-min=${IPHONEOS_DEPLOYMENT_TARGET}"])
912 if test "$ac_sys_system" = "Darwin"
915 AC_CHECK_PROG([HAS_XCRUN], [xcrun], [yes], [missing])
916 AC_MSG_CHECKING([macOS SDKROOT])
917 if test -z "$SDKROOT"; then
919 if test "$HAS_XCRUN" = "yes"; then
920 dnl detect with Xcode
921 SDKROOT=$(xcrun --show-sdk-path)
927 AC_MSG_RESULT([$SDKROOT])
929 # Compiler selection on MacOSX is more complicated than
930 # AC_PROG_CC can handle, see Mac/README for more
936 as_save_IFS=$IFS; IFS=:
940 if test -x "${as_dir}/gcc"; then
941 if test -z "${found_gcc}"; then
942 found_gcc="${as_dir}/gcc"
945 if test -x "${as_dir}/clang"; then
946 if test -z "${found_clang}"; then
947 found_clang="${as_dir}/clang"
953 if test -n "$found_gcc" -a -n "$found_clang"
955 if test -n "`"$found_gcc" --version | grep llvm-gcc`"
957 AC_MSG_NOTICE([Detected llvm-gcc, falling back to clang])
963 elif test -z "$found_gcc" -a -n "$found_clang"
965 AC_MSG_NOTICE([No GCC found, use CLANG])
969 elif test -z "$found_gcc" -a -z "$found_clang"
971 found_clang=`/usr/bin/xcrun -find clang 2>/dev/null`
972 if test -n "${found_clang}"
974 AC_MSG_NOTICE([Using clang from Xcode.app])
976 CXX="`/usr/bin/xcrun -find clang++`"
978 # else: use default behaviour
989 dnl detect compiler name
990 dnl check for xlc before clang, newer xlc's can use clang as frontend.
991 dnl check for GCC last, other compilers set __GNUC__, too.
992 dnl msvc is listed for completeness.
993 AC_CACHE_CHECK([for CC compiler name], [ac_cv_cc_name], [
994 cat > conftest.c <<EOF
995 #if defined(__EMSCRIPTEN__)
997 #elif defined(__INTEL_COMPILER) || defined(__ICC)
999 #elif defined(__ibmxl__) || defined(__xlc__) || defined(__xlC__)
1001 #elif defined(_MSC_VER)
1003 #elif defined(__clang__)
1005 #elif defined(__GNUC__)
1008 # error unknown compiler
1012 if $CPP $CPPFLAGS conftest.c >conftest.out 2>/dev/null; then
1013 ac_cv_cc_name=`grep -v '^#' conftest.out | grep -v '^ *$' | tr -d ' '`
1014 if test $(expr "//$CC" : '.*/\(.*\)') = "mpicc"; then
1015 ac_cv_cc_name="mpicc"
1018 ac_cv_cc_name="unknown"
1020 rm -f conftest.c conftest.out
1023 # checks for UNIX variants that set C preprocessor variables
1024 # may set _GNU_SOURCE, __EXTENSIONS__, _POSIX_PTHREAD_SEMANTICS,
1025 # _POSIX_SOURCE, _POSIX_1_SOURCE, and more
1026 AC_USE_SYSTEM_EXTENSIONS
1028 AC_CACHE_CHECK([for GCC compatible compiler],
1030 [AC_PREPROC_IFELSE([AC_LANG_SOURCE([
1031 #if !defined(__GNUC__)
1032 #error "not GCC compatible"
1034 /* GCC compatible! */
1037 [ac_cv_gcc_compat=yes],
1038 [ac_cv_gcc_compat=no])])
1046 gcc) AC_PATH_TOOL([CXX], [g++], [g++], [notfound]) ;;
1047 cc) AC_PATH_TOOL([CXX], [c++], [c++], [notfound]) ;;
1048 clang|*/clang) AC_PATH_TOOL([CXX], [clang++], [clang++], [notfound]) ;;
1049 icc|*/icc) AC_PATH_TOOL([CXX], [icpc], [icpc], [notfound]) ;;
1051 if test "$CXX" = "notfound"
1058 AC_CHECK_TOOLS([CXX], [$CCC c++ g++ gcc CC cxx cc++ cl], [notfound])
1059 if test "$CXX" = "notfound"
1064 if test "$preset_cxx" != "$CXX"
1068 By default, distutils will build C++ extension modules with "$CXX".
1069 If this is not intended, then set CXX on the configure command line.
1074 AC_MSG_CHECKING([for the platform triplet based on compiler characteristics])
1075 if $CPP $CPPFLAGS $srcdir/Misc/platform_triplet.c >conftest.out 2>/dev/null; then
1076 PLATFORM_TRIPLET=`grep '^PLATFORM_TRIPLET=' conftest.out | tr -d ' '`
1077 PLATFORM_TRIPLET="${PLATFORM_TRIPLET@%:@PLATFORM_TRIPLET=}"
1078 AC_MSG_RESULT([$PLATFORM_TRIPLET])
1080 AC_MSG_RESULT([none])
1084 dnl On some platforms, using a true "triplet" for MULTIARCH would be redundant.
1085 dnl For example, `arm64-apple-darwin` is redundant, because there isn't a
1086 dnl non-Apple Darwin. Including the CPU architecture can also be potentially
1087 dnl redundant - on macOS, for example, it's possible to do a single compile
1088 dnl pass that includes multiple architectures, so it would be misleading for
1089 dnl MULTIARCH (and thus the sysconfigdata module name) to include a single CPU
1090 dnl architecture. PLATFORM_TRIPLET will be a pair or single value for these
1092 AC_MSG_CHECKING([for multiarch])
1093 AS_CASE([$ac_sys_system],
1094 [Darwin*], [MULTIARCH=""],
1095 [iOS], [MULTIARCH=""],
1096 [FreeBSD*], [MULTIARCH=""],
1097 [MULTIARCH=$($CC --print-multiarch 2>/dev/null)]
1099 AC_SUBST([MULTIARCH])
1101 if test x$PLATFORM_TRIPLET != x && test x$MULTIARCH != x; then
1102 if test x$PLATFORM_TRIPLET != x$MULTIARCH; then
1103 AC_MSG_ERROR([internal configure error for the platform triplet, please file a bug report])
1105 elif test x$PLATFORM_TRIPLET != x && test x$MULTIARCH = x; then
1106 MULTIARCH=$PLATFORM_TRIPLET
1108 AC_SUBST([PLATFORM_TRIPLET])
1109 AC_MSG_RESULT([$MULTIARCH])
1111 dnl Even if we *do* include the CPU architecture in the MULTIARCH value, some
1112 dnl platforms don't need the CPU architecture in the SOABI tag. These platforms
1113 dnl will have multiple sysconfig modules (one for each CPU architecture), but
1114 dnl use a single "fat" binary at runtime. SOABI_PLATFORM is the component of
1115 dnl the PLATFORM_TRIPLET that will be used in binary module extensions.
1116 AS_CASE([$ac_sys_system],
1117 [iOS], [SOABI_PLATFORM=`echo "$PLATFORM_TRIPLET" | cut -d '-' -f2`],
1118 [SOABI_PLATFORM=$PLATFORM_TRIPLET]
1121 if test x$MULTIARCH != x; then
1122 MULTIARCH_CPPFLAGS="-DMULTIARCH=\\\"$MULTIARCH\\\""
1124 AC_SUBST([MULTIARCH_CPPFLAGS])
1126 dnl Support tiers according to https://peps.python.org/pep-0011/
1128 dnl NOTE: Windows support tiers are defined in PC/pyconfig.h.
1130 AC_MSG_CHECKING([for PEP 11 support tier])
1131 AS_CASE([$host/$ac_cv_cc_name],
1132 [x86_64-*-linux-gnu/gcc], [PY_SUPPORT_TIER=1], dnl Linux on AMD64, any vendor, glibc, gcc
1133 [x86_64-apple-darwin*/clang], [PY_SUPPORT_TIER=1], dnl macOS on Intel, any version
1134 [aarch64-apple-darwin*/clang], [PY_SUPPORT_TIER=1], dnl macOS on M1, any version
1135 [i686-pc-windows-msvc/msvc], [PY_SUPPORT_TIER=1], dnl 32bit Windows on Intel, MSVC
1136 [x86_64-pc-windows-msvc/msvc], [PY_SUPPORT_TIER=1], dnl 64bit Windows on AMD64, MSVC
1138 [aarch64-*-linux-gnu/gcc], [PY_SUPPORT_TIER=2], dnl Linux ARM64, glibc, gcc+clang
1139 [aarch64-*-linux-gnu/clang], [PY_SUPPORT_TIER=2],
1140 [powerpc64le-*-linux-gnu/gcc], [PY_SUPPORT_TIER=2], dnl Linux on PPC64 little endian, glibc, gcc
1141 [wasm32-unknown-wasi/clang], [PY_SUPPORT_TIER=2], dnl WebAssembly System Interface, clang
1142 [x86_64-*-linux-gnu/clang], [PY_SUPPORT_TIER=2], dnl Linux on AMD64, any vendor, glibc, clang
1144 [aarch64-pc-windows-msvc/msvc], [PY_SUPPORT_TIER=3], dnl Windows ARM64, MSVC
1145 [armv7l-*-linux-gnueabihf/gcc], [PY_SUPPORT_TIER=3], dnl ARMv7 LE with hardware floats, any vendor, glibc, gcc
1146 [powerpc64le-*-linux-gnu/clang], [PY_SUPPORT_TIER=3], dnl Linux on PPC64 little endian, glibc, clang
1147 [s390x-*-linux-gnu/gcc], [PY_SUPPORT_TIER=3], dnl Linux on 64bit s390x (big endian), glibc, gcc
1148 [x86_64-*-freebsd*/clang], [PY_SUPPORT_TIER=3], dnl FreeBSD on AMD64
1149 [aarch64-apple-ios*-simulator/clang], [PY_SUPPORT_TIER=3], dnl iOS Simulator on arm64
1150 [aarch64-apple-ios*/clang], [PY_SUPPORT_TIER=3], dnl iOS on ARM64
1154 AS_CASE([$PY_SUPPORT_TIER],
1155 [1], [AC_MSG_RESULT([$host/$ac_cv_cc_name has tier 1 (supported)])],
1156 [2], [AC_MSG_RESULT([$host/$ac_cv_cc_name has tier 2 (supported)])],
1157 [3], [AC_MSG_RESULT([$host/$ac_cv_cc_name has tier 3 (partially supported)])],
1158 [AC_MSG_WARN([$host/$ac_cv_cc_name is not supported])]
1161 AC_DEFINE_UNQUOTED([PY_SUPPORT_TIER], [$PY_SUPPORT_TIER], [PEP 11 Support tier (1, 2, 3 or 0 for unsupported)])
1163 AC_CACHE_CHECK([for -Wl,--no-as-needed], [ac_cv_wl_no_as_needed], [
1164 save_LDFLAGS="$LDFLAGS"
1165 AS_VAR_APPEND([LDFLAGS], [" -Wl,--no-as-needed"])
1166 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
1167 [NO_AS_NEEDED="-Wl,--no-as-needed"
1168 ac_cv_wl_no_as_needed=yes],
1170 ac_cv_wl_no_as_needed=no])
1171 LDFLAGS="$save_LDFLAGS"
1173 AC_SUBST([NO_AS_NEEDED])
1175 AC_MSG_CHECKING([for the Android API level])
1176 cat > conftest.c <<EOF
1178 android_api = __ANDROID_API__
1179 arm_arch = __ARM_ARCH
1185 if $CPP $CPPFLAGS conftest.c >conftest.out 2>/dev/null; then
1186 ANDROID_API_LEVEL=`sed -n -e '/__ANDROID_API__/d' -e 's/^android_api = //p' conftest.out`
1187 _arm_arch=`sed -n -e '/__ARM_ARCH/d' -e 's/^arm_arch = //p' conftest.out`
1188 AC_MSG_RESULT([$ANDROID_API_LEVEL])
1189 if test -z "$ANDROID_API_LEVEL"; then
1190 AC_MSG_ERROR([Fatal: you must define __ANDROID_API__])
1192 AC_DEFINE_UNQUOTED([ANDROID_API_LEVEL], [$ANDROID_API_LEVEL],
1193 [The Android API level.])
1195 AC_MSG_CHECKING([for the Android arm ABI])
1196 AC_MSG_RESULT([$_arm_arch])
1197 if test "$_arm_arch" = 7; then
1198 BASECFLAGS="${BASECFLAGS} -mfloat-abi=softfp -mfpu=vfpv3-d16"
1199 LDFLAGS="${LDFLAGS} -march=armv7-a -Wl,--fix-cortex-a8"
1202 AC_MSG_RESULT([not Android])
1204 rm -f conftest.c conftest.out
1206 # Check for unsupported systems
1207 AS_CASE([$ac_sys_system/$ac_sys_release],
1208 [atheos*|Linux*/1*], [
1209 AC_MSG_ERROR([m4_normalize([
1210 This system \($ac_sys_system/$ac_sys_release\) is no longer supported.
1211 See README for details.
1216 AC_MSG_CHECKING([for --with-emscripten-target])
1217 AC_ARG_WITH([emscripten-target],
1218 [AS_HELP_STRING([--with-emscripten-target=@<:@browser|node@:>@], [Emscripten platform])],
1220 AS_VAR_IF([ac_sys_system], [Emscripten], [
1221 AS_CASE([$with_emscripten_target],
1222 [browser], [ac_sys_emscripten_target=browser],
1223 [node], [ac_sys_emscripten_target=node],
1224 dnl Debug builds with source map / dwarf symbols. Py_DEBUG builds easily
1225 dnl run out of stack space. Detached sybmols and map prohibit some
1226 dnl optimizations and increase file size. Options are undocumented so we
1227 dnl are free to remove them in the future.
1228 [browser-debug], [ac_sys_emscripten_target=browser-debug],
1229 [node-debug], [ac_sys_emscripten_target=node-debug],
1230 [AC_MSG_ERROR([Invalid argument: --with-emscripten-target=browser|node])]
1233 AC_MSG_ERROR([--with-emscripten-target only applies to Emscripten])
1236 AS_VAR_IF([ac_sys_system], [Emscripten], [ac_sys_emscripten_target=browser])
1238 AC_MSG_RESULT([$ac_sys_emscripten_target])
1240 dnl On Emscripten dlopen() requires -s MAIN_MODULE and -fPIC. The flags
1241 dnl disables dead code elimination and increases the size of the WASM module
1242 dnl by about 1.5 to 2MB. MAIN_MODULE defines __wasm_mutable_globals__.
1243 dnl See https://emscripten.org/docs/compiling/Dynamic-Linking.html
1244 AC_MSG_CHECKING([for --enable-wasm-dynamic-linking])
1245 AC_ARG_ENABLE([wasm-dynamic-linking],
1246 [AS_HELP_STRING([--enable-wasm-dynamic-linking],
1247 [Enable dynamic linking support for WebAssembly (default is no)])],
1249 AS_CASE([$ac_sys_system],
1251 [WASI], [AC_MSG_ERROR([WASI dynamic linking is not implemented yet.])],
1252 [AC_MSG_ERROR([--enable-wasm-dynamic-linking only applies to Emscripten and WASI])]
1255 enable_wasm_dynamic_linking=missing
1257 AC_MSG_RESULT([$enable_wasm_dynamic_linking])
1259 AC_MSG_CHECKING([for --enable-wasm-pthreads])
1260 AC_ARG_ENABLE([wasm-pthreads],
1261 [AS_HELP_STRING([--enable-wasm-pthreads],
1262 [Enable pthread emulation for WebAssembly (default is no)])],
1264 AS_CASE([$ac_sys_system],
1267 [AC_MSG_ERROR([--enable-wasm-pthreads only applies to Emscripten and WASI])]
1270 enable_wasm_pthreads=missing
1272 AC_MSG_RESULT([$enable_wasm_pthreads])
1274 AC_MSG_CHECKING([for --with-suffix])
1275 AC_ARG_WITH([suffix],
1276 [AS_HELP_STRING([--with-suffix=SUFFIX], [set executable suffix to SUFFIX (default is empty, yes is mapped to '.exe')])],
1278 AS_CASE([$with_suffix],
1280 [yes], [EXEEXT=.exe],
1281 [EXEEXT=$with_suffix]
1284 AS_CASE([$ac_sys_system/$ac_sys_emscripten_target],
1285 [Emscripten/browser*], [EXEEXT=.js],
1286 [Emscripten/node*], [EXEEXT=.js],
1287 [WASI/*], [EXEEXT=.wasm],
1291 AC_MSG_RESULT([$EXEEXT])
1293 # Test whether we're running on a non-case-sensitive system, in which
1294 # case we give a warning if no ext is given
1295 AC_SUBST([BUILDEXEEXT])
1296 AC_MSG_CHECKING([for case-insensitive build directory])
1297 if test ! -d CaseSensitiveTestDir; then
1298 mkdir CaseSensitiveTestDir
1301 if test -d casesensitivetestdir && test -z "$EXEEXT"
1303 AC_MSG_RESULT([yes])
1309 rmdir CaseSensitiveTestDir
1311 case $ac_sys_system in
1314 cc|*/cc) CC="$CC -Ae";;
1319 AC_MSG_CHECKING([LIBRARY])
1320 if test -z "$LIBRARY"
1322 LIBRARY='libpython$(VERSION)$(ABIFLAGS).a'
1324 AC_MSG_RESULT([$LIBRARY])
1326 # LDLIBRARY is the name of the library to link against (as opposed to the
1327 # name of the library into which to insert object files). BLDLIBRARY is also
1328 # the library to link against, usually. On Mac OS X frameworks, BLDLIBRARY
1329 # is blank as the main program is not linked directly against LDLIBRARY.
1330 # LDLIBRARYDIR is the path to LDLIBRARY, which is made in a subdirectory. On
1331 # systems without shared libraries, LDLIBRARY is the same as LIBRARY
1332 # (defined in the Makefiles). On Cygwin LDLIBRARY is the import library,
1333 # DLLLIBRARY is the shared (i.e., DLL) library.
1335 # RUNSHARED is used to run shared python without installed libraries
1337 # INSTSONAME is the name of the shared library that will be use to install
1338 # on the system - some systems like version suffix, others don't
1340 # LDVERSION is the shared library version number, normally the Python version
1341 # with the ABI build flags appended.
1342 AC_SUBST([LDLIBRARY])
1343 AC_SUBST([DLLLIBRARY])
1344 AC_SUBST([BLDLIBRARY])
1345 AC_SUBST([PY3LIBRARY])
1346 AC_SUBST([LDLIBRARYDIR])
1347 AC_SUBST([INSTSONAME])
1348 AC_SUBST([RUNSHARED])
1349 AC_SUBST([LDVERSION])
1350 LDLIBRARY="$LIBRARY"
1351 BLDLIBRARY='$(LDLIBRARY)'
1352 INSTSONAME='$(LDLIBRARY)'
1356 LDVERSION="$VERSION"
1358 # LINKCC is the command that links the python executable -- default is $(CC).
1359 # If CXX is set, and if it is needed to link a main function that was
1360 # compiled with CXX, LINKCC is CXX instead. Always using CXX is undesirable:
1361 # python might then depend on the C++ runtime
1363 AC_MSG_CHECKING([LINKCC])
1364 if test -z "$LINKCC"
1366 LINKCC='$(PURIFY) $(CC)'
1367 case $ac_sys_system in
1369 # qcc must be used because the other compilers do not
1374 AC_MSG_RESULT([$LINKCC])
1376 # EXPORTSYMS holds the list of exported symbols for AIX.
1377 # EXPORTSFROM holds the module name exporting symbols on AIX.
1380 AC_SUBST([EXPORTSYMS])
1381 AC_SUBST([EXPORTSFROM])
1382 AC_MSG_CHECKING([EXPORTSYMS])
1383 case $ac_sys_system in
1385 EXPORTSYMS="Modules/python.exp"
1386 EXPORTSFROM=. # the main executable
1389 AC_MSG_RESULT([$EXPORTSYMS])
1391 # GNULD is set to "yes" if the GNU linker is used. If this goes wrong
1392 # make sure we default having it set to "no": this is used by
1393 # distutils.unixccompiler to know if it should add --enable-new-dtags
1394 # to linker command lines, and failing to detect GNU ld simply results
1395 # in the same behaviour as before.
1397 AC_MSG_CHECKING([for GNU ld])
1399 if test "$GCC" = yes; then
1400 ac_prog=`$CC -print-prog-name=ld`
1402 case `"$ac_prog" -V 2>&1 < /dev/null` in
1408 AC_MSG_RESULT([$GNULD])
1410 AC_MSG_CHECKING([for --enable-shared])
1411 AC_ARG_ENABLE([shared],
1412 AS_HELP_STRING([--enable-shared], [enable building a shared Python library (default is no)]))
1414 if test -z "$enable_shared"
1416 case $ac_sys_system in
1418 enable_shared="yes";;
1420 enable_shared="no";;
1423 AC_MSG_RESULT([$enable_shared])
1425 # --with-static-libpython
1427 AC_MSG_CHECKING([for --with-static-libpython])
1428 AC_ARG_WITH([static-libpython],
1429 AS_HELP_STRING([--without-static-libpython],
1430 [do not build libpythonMAJOR.MINOR.a and do not install python.o (default is yes)]),
1432 if test "$withval" = no
1434 AC_MSG_RESULT([no]);
1437 AC_MSG_RESULT([yes]);
1439 [AC_MSG_RESULT([yes])])
1440 AC_SUBST([STATIC_LIBPYTHON])
1442 AC_MSG_CHECKING([for --enable-profiling])
1443 AC_ARG_ENABLE([profiling],
1444 AS_HELP_STRING([--enable-profiling], [enable C-level code profiling with gprof (default is no)]))
1445 if test "x$enable_profiling" = xyes; then
1448 AC_LINK_IFELSE([AC_LANG_SOURCE([[int main(void) { return 0; }]])],
1450 [enable_profiling=no])
1455 AC_MSG_RESULT([$enable_profiling])
1457 if test "x$enable_profiling" = xyes; then
1458 BASECFLAGS="-pg $BASECFLAGS"
1459 LDFLAGS="-pg $LDFLAGS"
1462 AC_MSG_CHECKING([LDLIBRARY])
1464 # Apple framework builds need more magic. LDLIBRARY is the dynamic
1465 # library that we build, but we do not want to link against it (we
1466 # will find it with a -framework option). For this reason there is an
1467 # extra variable BLDLIBRARY against which Python and the extension
1468 # modules are linked, BLDLIBRARY. This is normally the same as
1469 # LDLIBRARY, but empty for MacOSX framework builds. iOS does the same,
1470 # but uses a non-versioned framework layout.
1471 if test "$enable_framework"
1473 case $ac_sys_system in
1475 LDLIBRARY='$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)';;
1477 LDLIBRARY='$(PYTHONFRAMEWORKDIR)/$(PYTHONFRAMEWORK)';;
1479 AC_MSG_ERROR([Unknown platform for framework build]);;
1482 RUNSHARED=DYLD_FRAMEWORK_PATH=`pwd`${DYLD_FRAMEWORK_PATH:+:${DYLD_FRAMEWORK_PATH}}
1484 BLDLIBRARY='$(LDLIBRARY)'
1487 # Other platforms follow
1488 if test $enable_shared = "yes"; then
1490 AC_DEFINE([Py_ENABLE_SHARED], [1],
1491 [Defined if Python is built as a shared library.])
1492 case $ac_sys_system in
1494 LDLIBRARY='libpython$(LDVERSION).dll.a'
1495 BLDLIBRARY='-L. -lpython$(LDVERSION)'
1496 DLLLIBRARY='libpython$(LDVERSION).dll'
1499 LDLIBRARY='libpython$(LDVERSION).so'
1500 BLDLIBRARY='-Wl,-R,$(LIBDIR) -L. -lpython$(LDVERSION)'
1501 RUNSHARED=LD_LIBRARY_PATH=`pwd`${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
1502 INSTSONAME="$LDLIBRARY".$SOVERSION
1503 if test "$with_pydebug" != yes
1505 PY3LIBRARY=libpython3.so
1508 Linux*|GNU*|NetBSD*|FreeBSD*|DragonFly*|OpenBSD*|VxWorks*)
1509 LDLIBRARY='libpython$(LDVERSION).so'
1510 BLDLIBRARY='-L. -lpython$(LDVERSION)'
1511 RUNSHARED=LD_LIBRARY_PATH=`pwd`${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
1513 # The Android Gradle plugin will only package libraries whose names end
1515 if test "$ac_sys_system" != "Linux-android"; then
1516 INSTSONAME="$LDLIBRARY".$SOVERSION
1519 if test "$with_pydebug" != yes
1521 PY3LIBRARY=libpython3.so
1527 LDLIBRARY='libpython$(LDVERSION).so'
1530 LDLIBRARY='libpython$(LDVERSION).sl'
1533 BLDLIBRARY='-Wl,+b,$(LIBDIR) -L. -lpython$(LDVERSION)'
1534 RUNSHARED=SHLIB_PATH=`pwd`${SHLIB_PATH:+:${SHLIB_PATH}}
1537 LDLIBRARY='libpython$(LDVERSION).dylib'
1538 BLDLIBRARY='-L. -lpython$(LDVERSION)'
1539 RUNSHARED=DYLD_LIBRARY_PATH=`pwd`${DYLD_LIBRARY_PATH:+:${DYLD_LIBRARY_PATH}}
1542 LDLIBRARY='libpython$(LDVERSION).dylib'
1545 LDLIBRARY='libpython$(LDVERSION).so'
1546 RUNSHARED=LIBPATH=`pwd`${LIBPATH:+:${LIBPATH}}
1550 else # shared is disabled
1552 case $ac_sys_system in
1554 BLDLIBRARY='$(LIBRARY)'
1555 LDLIBRARY='libpython$(LDVERSION).dll.a'
1559 AC_MSG_RESULT([$LDLIBRARY])
1561 if test "$cross_compiling" = yes; then
1565 AC_MSG_CHECKING([HOSTRUNNER])
1566 AC_ARG_VAR([HOSTRUNNER], [Program to run CPython for the host platform])
1567 if test -z "$HOSTRUNNER"
1569 AS_CASE([$ac_sys_system/$ac_sys_emscripten_target],
1570 [Emscripten/node*], [
1571 AC_PATH_TOOL([NODE], [node], [node])
1573 # bigint for ctypes c_longlong, c_longdouble
1574 # no longer available in Node 16
1575 AC_CACHE_CHECK([for node --experimental-wasm-bigint], [ac_cv_tool_node_wasm_bigint], [
1576 if $NODE -v --experimental-wasm-bigint > /dev/null 2>&1; then
1577 ac_cv_tool_node_wasm_bigint=yes
1579 ac_cv_tool_node_wasm_bigint=no
1582 AS_VAR_IF([ac_cv_tool_node_wasm_bigint], [yes], [
1583 AS_VAR_APPEND([HOSTRUNNER], [" --experimental-wasm-bigint"])
1586 AS_VAR_IF([enable_wasm_pthreads], [yes], [
1587 AS_VAR_APPEND([HOSTRUNNER], [" --experimental-wasm-threads"])
1588 # no longer available in Node 16
1589 AC_CACHE_CHECK([for node --experimental-wasm-bulk-memory], [ac_cv_tool_node_wasm_bulk_memory], [
1590 if $NODE -v --experimental-wasm-bulk-memory > /dev/null 2>&1; then
1591 ac_cv_tool_node_wasm_bulk_memory=yes
1593 ac_cv_tool_node_wasm_bulk_memory=no
1596 AS_VAR_IF([ac_cv_tool_node_wasm_bulk_memory], [yes], [
1597 AS_VAR_APPEND([HOSTRUNNER], [" --experimental-wasm-bulk-memory"])
1601 AS_VAR_IF([host_cpu], [wasm64], [AS_VAR_APPEND([HOSTRUNNER], [" --experimental-wasm-memory64"])])
1603 dnl TODO: support other WASI runtimes
1604 dnl wasmtime starts the proces with "/" as CWD. For OOT builds add the
1605 dnl directory containing _sysconfigdata to PYTHONPATH.
1606 [WASI/*], [HOSTRUNNER='wasmtime run --wasm max-wasm-stack=8388608 --wasi preview2 --env PYTHONPATH=/$(shell realpath --relative-to $(abs_srcdir) $(abs_builddir))/$(shell cat pybuilddir.txt):/Lib --dir $(srcdir)::/'],
1610 AC_SUBST([HOSTRUNNER])
1611 AC_MSG_RESULT([$HOSTRUNNER])
1613 if test -n "$HOSTRUNNER"; then
1614 dnl Pass hostrunner variable as env var in order to expand shell expressions.
1615 PYTHON_FOR_BUILD="_PYTHON_HOSTRUNNER='$HOSTRUNNER' $PYTHON_FOR_BUILD"
1618 # LIBRARY_DEPS, LINK_PYTHON_OBJS and LINK_PYTHON_DEPS variable
1619 AS_CASE([$ac_sys_system/$ac_sys_emscripten_target],
1620 [Emscripten/browser*], [LIBRARY_DEPS='$(PY3LIBRARY) $(WASM_STDLIB) python.html python.worker.js'],
1621 [LIBRARY_DEPS='$(PY3LIBRARY) $(EXPORTSYMS)']
1623 LINK_PYTHON_DEPS='$(LIBRARY_DEPS)'
1624 if test "$PY_ENABLE_SHARED" = 1 || test "$enable_framework" ; then
1625 LIBRARY_DEPS="\$(LDLIBRARY) $LIBRARY_DEPS"
1626 if test "$STATIC_LIBPYTHON" = 1; then
1627 LIBRARY_DEPS="\$(LIBRARY) $LIBRARY_DEPS"
1629 # Link Python program to the shared library
1630 LINK_PYTHON_OBJS='$(BLDLIBRARY)'
1632 if test "$STATIC_LIBPYTHON" = 0; then
1633 # Build Python needs object files but don't need to build
1634 # Python static library
1635 LINK_PYTHON_DEPS="$LIBRARY_DEPS \$(LIBRARY_OBJS)"
1637 LIBRARY_DEPS="\$(LIBRARY) $LIBRARY_DEPS"
1638 # Link Python program to object files
1639 LINK_PYTHON_OBJS='$(LIBRARY_OBJS)'
1641 AC_SUBST([LIBRARY_DEPS])
1642 AC_SUBST([LINK_PYTHON_DEPS])
1643 AC_SUBST([LINK_PYTHON_OBJS])
1647 AC_CHECK_TOOLS([AR], [ar aal], [ar])
1649 # tweak ARFLAGS only if the user didn't set it on the command line
1651 if test -z "$ARFLAGS"
1658 # install -d does not work on HP-UX
1659 if test -z "$INSTALL"
1661 INSTALL="${srcdir}/install-sh -c"
1667 # Not every filesystem supports hard links
1669 if test -z "$LN" ; then
1670 case $ac_sys_system in
1671 CYGWIN*) LN="ln -s";;
1676 # For calculating the .so ABI tag.
1677 AC_SUBST([ABIFLAGS])
1680 # Check for --disable-gil
1682 AC_MSG_CHECKING([for --disable-gil])
1683 AC_ARG_ENABLE([gil],
1684 [AS_HELP_STRING([--disable-gil], [enable experimental support for running without the GIL (default is no)])],
1685 [AS_VAR_IF([enable_gil], [yes], [disable_gil=no], [disable_gil=yes])], [disable_gil=no]
1687 AC_MSG_RESULT([$disable_gil])
1689 if test "$disable_gil" = "yes"
1691 AC_DEFINE([Py_GIL_DISABLED], [1],
1692 [Define if you want to disable the GIL])
1693 # Add "t" for "threaded"
1694 ABIFLAGS="${ABIFLAGS}t"
1697 # Check for --with-pydebug
1698 AC_MSG_CHECKING([for --with-pydebug])
1699 AC_ARG_WITH([pydebug],
1700 [AS_HELP_STRING([--with-pydebug], [build with Py_DEBUG defined (default is no)]) ],
1702 if test "$withval" != no
1704 AC_DEFINE([Py_DEBUG], [1],
1705 [Define if you want to build an interpreter with many run-time checks.])
1706 AC_MSG_RESULT([yes]);
1708 ABIFLAGS="${ABIFLAGS}d"
1709 else AC_MSG_RESULT([no]); Py_DEBUG='false'
1711 [AC_MSG_RESULT([no])])
1713 # Check for --with-trace-refs
1715 AC_MSG_CHECKING([for --with-trace-refs])
1716 AC_ARG_WITH([trace-refs],
1717 [AS_HELP_STRING([--with-trace-refs], [enable tracing references for debugging purpose (default is no)])],
1718 [], [with_trace_refs=no]
1720 AC_MSG_RESULT([$with_trace_refs])
1722 if test "$with_trace_refs" = "yes"
1724 AC_DEFINE([Py_TRACE_REFS], [1],
1725 [Define if you want to enable tracing references for debugging purpose])
1729 # Check for --enable-pystats
1730 AC_MSG_CHECKING([for --enable-pystats])
1731 AC_ARG_ENABLE([pystats],
1734 [enable internal statistics gathering (default is no)]
1736 [], [enable_pystats=no]
1738 AC_MSG_RESULT([$enable_pystats])
1740 AS_VAR_IF([enable_pystats], [yes], [
1741 AC_DEFINE([Py_STATS], [1], [Define if you want to enable internal statistics gathering.])
1744 # Check for --with-assertions.
1745 # This allows enabling assertions without Py_DEBUG.
1747 AC_MSG_CHECKING([for --with-assertions])
1748 AC_ARG_WITH([assertions],
1749 AS_HELP_STRING([--with-assertions],[build with C assertions enabled (default is no)]),
1751 if test "$withval" != no
1756 if test "$assertions" = 'true'; then
1757 AC_MSG_RESULT([yes])
1758 elif test "$Py_DEBUG" = 'true'; then
1760 AC_MSG_RESULT([implied by --with-pydebug])
1765 # Check for --enable-experimental-jit:
1766 AC_MSG_CHECKING([for --enable-experimental-jit])
1767 AC_ARG_ENABLE([experimental-jit],
1768 [AS_HELP_STRING([--enable-experimental-jit],
1769 [build the experimental just-in-time compiler (default is no)])],
1771 [enable_experimental_jit=no])
1772 AS_VAR_IF([enable_experimental_jit],
1775 [AS_VAR_APPEND([CFLAGS_NODIST], [" -D_Py_JIT"])
1776 AS_VAR_SET([REGEN_JIT_COMMAND],
1777 ["\$(PYTHON_FOR_REGEN) \$(srcdir)/Tools/jit/build.py $host"])
1778 AS_VAR_SET([JIT_STENCILS_H], ["jit_stencils.h"])
1779 AS_VAR_IF([Py_DEBUG],
1781 [AS_VAR_APPEND([REGEN_JIT_COMMAND], [" --debug"])],
1783 AC_SUBST([REGEN_JIT_COMMAND])
1784 AC_SUBST([JIT_STENCILS_H])
1785 AC_MSG_RESULT([$enable_experimental_jit])
1787 # Enable optimization flags
1788 AC_SUBST([DEF_MAKE_ALL_RULE])
1789 AC_SUBST([DEF_MAKE_RULE])
1791 AC_MSG_CHECKING([for --enable-optimizations])
1792 AC_ARG_ENABLE([optimizations], AS_HELP_STRING(
1793 [--enable-optimizations],
1794 [enable expensive, stable optimizations (PGO, etc.) (default is no)]),
1796 if test "$enableval" != no
1799 AC_MSG_RESULT([yes]);
1802 AC_MSG_RESULT([no]);
1804 [AC_MSG_RESULT([no])])
1806 if test "$Py_OPT" = 'true' ; then
1807 # Intentionally not forcing Py_LTO='true' here. Too many toolchains do not
1808 # compile working code using it and both test_distutils and test_gdb are
1809 # broken when you do manage to get a toolchain that works with it. People
1810 # who want LTO need to use --with-lto themselves.
1811 DEF_MAKE_ALL_RULE="profile-opt"
1813 DEF_MAKE_RULE="build_all"
1816 AX_CHECK_COMPILE_FLAG([-fno-semantic-interposition],[
1817 CFLAGS_NODIST="$CFLAGS_NODIST -fno-semantic-interposition"
1818 LDFLAGS_NODIST="$LDFLAGS_NODIST -fno-semantic-interposition"
1822 elif test "$ac_sys_system" = "Emscripten" -o "$ac_sys_system" = "WASI"; then
1823 dnl Emscripten does not support shared extensions yet. Build
1824 dnl "python.[js,wasm]", "pybuilddir.txt", and "platform" files.
1825 DEF_MAKE_ALL_RULE="build_wasm"
1829 DEF_MAKE_ALL_RULE="build_all"
1834 AC_ARG_VAR([PROFILE_TASK], [Python args for PGO generation task])
1835 AC_MSG_CHECKING([PROFILE_TASK])
1836 if test -z "$PROFILE_TASK"
1838 PROFILE_TASK='-m test --pgo --timeout=$(TESTTIMEOUT)'
1840 AC_MSG_RESULT([$PROFILE_TASK])
1842 # Make llvm-related checks work on systems where llvm tools are not installed with their
1843 # normal names in the default $PATH (ie: Ubuntu). They exist under the
1844 # non-suffixed name in their versioned llvm directory.
1848 if test "${CC}" = "clang"
1850 clang_bin=`which clang`
1851 # Some systems install clang elsewhere as a symlink to the real path
1852 # which is where the related llvm tools are located.
1853 if test -L "${clang_bin}"
1855 clang_dir=`dirname "${clang_bin}"`
1856 clang_bin=`readlink "${clang_bin}"`
1857 llvm_bin_dir="${clang_dir}/"`dirname "${clang_bin}"`
1858 llvm_path="${llvm_path}${PATH_SEPARATOR}${llvm_bin_dir}"
1863 AC_MSG_CHECKING([for --with-lto])
1865 [AS_HELP_STRING([--with-lto=@<:@full|thin|no|yes@:>@], [enable Link-Time-Optimization in any build (default is no)])],
1870 Py_LTO_POLICY='full'
1871 AC_MSG_RESULT([yes])
1875 Py_LTO_POLICY='thin'
1876 AC_MSG_RESULT([yes])
1880 Py_LTO_POLICY='default'
1881 AC_MSG_RESULT([yes])
1889 AC_MSG_ERROR([unknown lto option: '$withval'])
1893 [AC_MSG_RESULT([no])])
1894 if test "$Py_LTO" = 'true' ; then
1897 LDFLAGS_NOLTO="-fno-lto"
1898 dnl Clang linker requires -flto in order to link objects with LTO information.
1899 dnl Thin LTO is faster and works for object files with full LTO information, too.
1900 AX_CHECK_COMPILE_FLAG([-flto=thin],[LDFLAGS_NOLTO="-flto=thin"],[LDFLAGS_NOLTO="-flto"])
1902 AC_PATH_TOOL([LLVM_AR], [llvm-ar], [''], [${llvm_path}])
1903 AC_SUBST([LLVM_AR_FOUND])
1904 if test -n "${LLVM_AR}" -a -x "${LLVM_AR}"
1906 LLVM_AR_FOUND="found"
1908 LLVM_AR_FOUND="not-found"
1910 if test "$ac_sys_system" = "Darwin" -a "${LLVM_AR_FOUND}" = "not-found"
1912 # The Apple-supplied ar in Xcode or the Command Line Tools is apparently sufficient
1913 found_llvm_ar=`/usr/bin/xcrun -find ar 2>/dev/null`
1914 if test -n "${found_llvm_ar}"
1916 LLVM_AR='/usr/bin/xcrun ar'
1918 AC_MSG_NOTICE([llvm-ar found via xcrun: ${LLVM_AR}])
1921 if test $LLVM_AR_FOUND = not-found
1924 AC_MSG_ERROR([llvm-ar is required for a --with-lto build with clang but could not be found.])
1929 case $ac_sys_system in
1931 # Any changes made here should be reflected in the GCC+Darwin case below
1932 if test $Py_LTO_POLICY = default
1934 # Check that ThinLTO is accepted.
1935 AX_CHECK_COMPILE_FLAG([-flto=thin],[
1936 LTOFLAGS="-flto=thin -Wl,-export_dynamic -Wl,-object_path_lto,\"\$@\".lto"
1937 LTOCFLAGS="-flto=thin"
1939 LTOFLAGS="-flto -Wl,-export_dynamic -Wl,-object_path_lto,\"\$@\".lto"
1944 LTOFLAGS="-flto=${Py_LTO_POLICY} -Wl,-export_dynamic -Wl,-object_path_lto,\"\$@\".lto"
1945 LTOCFLAGS="-flto=${Py_LTO_POLICY}"
1949 if test $Py_LTO_POLICY = default
1951 # Check that ThinLTO is accepted
1952 AX_CHECK_COMPILE_FLAG([-flto=thin],[LTOFLAGS="-flto=thin"],[LTOFLAGS="-flto"])
1954 LTOFLAGS="-flto=${Py_LTO_POLICY}"
1960 if test "$Py_LTO_POLICY" != "default"; then
1961 AC_MSG_ERROR([emcc supports only default lto.])
1967 if test $Py_LTO_POLICY = thin
1969 AC_MSG_ERROR([thin lto is not supported under gcc compiler.])
1971 dnl flag to disable lto during linking
1972 LDFLAGS_NOLTO="-fno-lto"
1973 case $ac_sys_system in
1975 LTOFLAGS="-flto -Wl,-export_dynamic -Wl,-object_path_lto,\"\$@\".lto"
1979 LTOFLAGS="-flto -fuse-linker-plugin -ffat-lto-objects -flto-partition=none"
1985 if test "$ac_cv_prog_cc_g" = "yes"
1987 # bpo-30345: Add -g to LDFLAGS when compiling with LTO
1988 # to get debug symbols.
1989 LTOFLAGS="$LTOFLAGS -g"
1992 CFLAGS_NODIST="$CFLAGS_NODIST ${LTOCFLAGS-$LTOFLAGS}"
1993 LDFLAGS_NODIST="$LDFLAGS_NODIST $LTOFLAGS"
1997 AC_SUBST([PGO_PROF_GEN_FLAG])
1998 AC_SUBST([PGO_PROF_USE_FLAG])
1999 AC_SUBST([LLVM_PROF_MERGER])
2000 AC_SUBST([LLVM_PROF_FILE])
2001 AC_SUBST([LLVM_PROF_ERR])
2002 AC_SUBST([LLVM_PROFDATA])
2003 AC_PATH_TOOL([LLVM_PROFDATA], [llvm-profdata], [''], [${llvm_path}])
2004 AC_SUBST([LLVM_PROF_FOUND])
2005 if test -n "${LLVM_PROFDATA}" -a -x "${LLVM_PROFDATA}"
2007 LLVM_PROF_FOUND="found"
2009 LLVM_PROF_FOUND="not-found"
2011 if test "$ac_sys_system" = "Darwin" -a "${LLVM_PROF_FOUND}" = "not-found"
2013 found_llvm_profdata=`/usr/bin/xcrun -find llvm-profdata 2>/dev/null`
2014 if test -n "${found_llvm_profdata}"
2016 # llvm-profdata isn't directly in $PATH in some cases.
2017 # https://apple.stackexchange.com/questions/197053/
2018 LLVM_PROFDATA='/usr/bin/xcrun llvm-profdata'
2019 LLVM_PROF_FOUND=found
2020 AC_MSG_NOTICE([llvm-profdata found via xcrun: ${LLVM_PROFDATA}])
2025 # GNU Autoconf recommends the use of expr instead of basename.
2026 AS_VAR_SET([CC_BASENAME], [$(expr "//$CC" : '.*/\(.*\)')])
2027 case "$CC_BASENAME" in
2029 # Any changes made here should be reflected in the GCC+Darwin case below
2030 PGO_PROF_GEN_FLAG="-fprofile-instr-generate"
2031 PGO_PROF_USE_FLAG="-fprofile-instr-use=\"\$(shell pwd)/code.profclangd\""
2032 LLVM_PROF_MERGER=m4_normalize("
2033 ${LLVM_PROFDATA} merge
2034 -output=\"\$(shell pwd)/code.profclangd\"
2035 \"\$(shell pwd)\"/*.profclangr
2037 LLVM_PROF_FILE="LLVM_PROFILE_FILE=\"\$(shell pwd)/code-%p.profclangr\""
2038 if test $LLVM_PROF_FOUND = not-found
2041 if test "${REQUIRE_PGO}" = "yes"
2043 AC_MSG_ERROR([llvm-profdata is required for a --enable-optimizations build but could not be found.])
2048 case $ac_sys_system in
2050 PGO_PROF_GEN_FLAG="-fprofile-instr-generate"
2051 PGO_PROF_USE_FLAG="-fprofile-instr-use=\"\$(shell pwd)/code.profclangd\""
2052 LLVM_PROF_MERGER=m4_normalize("
2053 ${LLVM_PROFDATA} merge
2054 -output=\"\$(shell pwd)/code.profclangd\"
2055 \"\$(shell pwd)\"/*.profclangr
2057 LLVM_PROF_FILE="LLVM_PROFILE_FILE=\"\$(shell pwd)/code-%p.profclangr\""
2058 if test "${LLVM_PROF_FOUND}" = "not-found"
2061 if test "${REQUIRE_PGO}" = "yes"
2063 AC_MSG_ERROR([llvm-profdata is required for a --enable-optimizations build but could not be found.])
2068 PGO_PROF_GEN_FLAG="-fprofile-generate"
2069 PGO_PROF_USE_FLAG="-fprofile-use -fprofile-correction"
2070 LLVM_PROF_MERGER="true"
2076 PGO_PROF_GEN_FLAG="-prof-gen"
2077 PGO_PROF_USE_FLAG="-prof-use"
2078 LLVM_PROF_MERGER="true"
2083 # BOLT optimization. Always configured after PGO since it always runs after PGO.
2085 AC_MSG_CHECKING([for --enable-bolt])
2086 AC_ARG_ENABLE([bolt], [AS_HELP_STRING(
2088 [enable usage of the llvm-bolt post-link optimizer (default is no)])],
2090 if test "$enableval" != no
2093 AC_MSG_RESULT([yes]);
2096 AC_MSG_RESULT([no]);
2098 [AC_MSG_RESULT([no])])
2100 AC_SUBST([PREBOLT_RULE])
2101 if test "$Py_BOLT" = 'true' ; then
2102 PREBOLT_RULE="${DEF_MAKE_ALL_RULE}"
2103 DEF_MAKE_ALL_RULE="bolt-opt"
2104 DEF_MAKE_RULE="build_all"
2106 # -fno-reorder-blocks-and-partition is required for bolt to work.
2107 # Possibly GCC only.
2108 AX_CHECK_COMPILE_FLAG([-fno-reorder-blocks-and-partition],[
2109 CFLAGS_NODIST="$CFLAGS_NODIST -fno-reorder-blocks-and-partition"
2112 # These flags are required for bolt to work:
2113 LDFLAGS_NODIST="$LDFLAGS_NODIST -Wl,--emit-relocs"
2115 # These flags are required to get good performance from bolt:
2116 CFLAGS_NODIST="$CFLAGS_NODIST -fno-pie"
2117 # We want to add these no-pie flags to linking executables but not shared libraries:
2118 LINKCC="$LINKCC -fno-pie -no-pie"
2119 AC_SUBST([LLVM_BOLT])
2120 AC_PATH_TOOL([LLVM_BOLT], [llvm-bolt], [''], [${llvm_path}])
2121 if test -n "${LLVM_BOLT}" -a -x "${LLVM_BOLT}"
2123 AC_MSG_RESULT(["Found llvm-bolt"])
2125 AC_MSG_ERROR([llvm-bolt is required for a --enable-bolt build but could not be found.])
2128 AC_SUBST([MERGE_FDATA])
2129 AC_PATH_TOOL([MERGE_FDATA], [merge-fdata], [''], [${llvm_path}])
2130 if test -n "${MERGE_FDATA}" -a -x "${MERGE_FDATA}"
2132 AC_MSG_RESULT(["Found merge-fdata"])
2134 AC_MSG_ERROR([merge-fdata is required for a --enable-bolt build but could not be found.])
2138 dnl Enable BOLT of libpython if built.
2139 AC_SUBST([BOLT_BINARIES])
2140 BOLT_BINARIES='$(BUILDPYTHON)'
2141 AS_VAR_IF([enable_shared], [yes], [
2142 BOLT_BINARIES="${BOLT_BINARIES} \$(INSTSONAME)"
2146 [BOLT_INSTRUMENT_FLAGS],
2147 [Arguments to llvm-bolt when instrumenting binaries]
2149 AC_MSG_CHECKING([BOLT_INSTRUMENT_FLAGS])
2150 if test -z "${BOLT_INSTRUMENT_FLAGS}"
2152 BOLT_INSTRUMENT_FLAGS=
2154 AC_MSG_RESULT([$BOLT_INSTRUMENT_FLAGS])
2158 [Arguments to llvm-bolt when creating a BOLT optimized binary]
2160 AC_MSG_CHECKING([BOLT_APPLY_FLAGS])
2161 if test -z "${BOLT_APPLY_FLAGS}"
2166 -update-debug-sections
2167 -reorder-blocks=ext-tsp
2168 -reorder-functions=hfsort+
2173 -reorder-functions-use-hot-size
2175 -jump-tables=aggressive
2177 -indirect-call-promotion=all
2184 AC_MSG_RESULT([$BOLT_APPLY_FLAGS])
2186 # XXX Shouldn't the code above that fiddles with BASECFLAGS and OPT be
2187 # merged with this chunk of code?
2189 # Optimizer/debugger flags
2190 # ------------------------
2191 # (The following bit of code is complicated enough - please keep things
2192 # indented properly. Just pretend you're editing Python code. ;-)
2194 # There are two parallel sets of case statements below, one that checks to
2195 # see if OPT was set and one that does BASECFLAGS setting based upon
2196 # compiler and platform. BASECFLAGS tweaks need to be made even if the
2204 if $CC --version 2>&1 | grep -q clang
2212 dnl Historically, some of our code assumed that signed integer overflow
2213 dnl is defined behaviour via twos-complement.
2214 dnl Set STRICT_OVERFLOW_CFLAGS and NO_STRICT_OVERFLOW_CFLAGS depending on compiler support.
2215 dnl Pass the latter to modules that depend on such behaviour.
2217 CFLAGS="-fstrict-overflow -fno-strict-overflow"
2218 AC_CACHE_CHECK([if $CC supports -fstrict-overflow and -fno-strict-overflow],
2219 [ac_cv_cc_supports_fstrict_overflow],
2221 [AC_LANG_PROGRAM([[]], [[]])],
2222 [ac_cv_cc_supports_fstrict_overflow=yes],
2223 [ac_cv_cc_supports_fstrict_overflow=no]
2226 _RESTORE_VAR([CFLAGS])
2228 AS_VAR_IF([ac_cv_cc_supports_fstrict_overflow], [yes],
2229 [STRICT_OVERFLOW_CFLAGS="-fstrict-overflow"
2230 NO_STRICT_OVERFLOW_CFLAGS="-fno-strict-overflow"],
2231 [STRICT_OVERFLOW_CFLAGS=""
2232 NO_STRICT_OVERFLOW_CFLAGS=""])
2234 AC_MSG_CHECKING([for --with-strict-overflow])
2235 AC_ARG_WITH([strict-overflow],
2237 [--with-strict-overflow],
2238 [if 'yes', add -fstrict-overflow to CFLAGS, else add -fno-strict-overflow (default is no)]
2242 [ac_cv_cc_supports_fstrict_overflow], [no],
2243 [AC_MSG_WARN([--with-strict-overflow=yes requires a compiler that supports -fstrict-overflow])],
2247 [with_strict_overflow=no]
2249 AC_MSG_RESULT([$with_strict_overflow])
2251 # Check if CC supports -Og optimization level
2254 AC_CACHE_CHECK([if $CC supports -Og optimization level],
2255 [ac_cv_cc_supports_og],
2258 AC_LANG_PROGRAM([[]], [[]])
2260 ac_cv_cc_supports_og=yes
2262 ac_cv_cc_supports_og=no
2265 _RESTORE_VAR([CFLAGS])
2267 # Optimization messes up debuggers, so turn it off for
2269 PYDEBUG_CFLAGS="-O0"
2270 AS_VAR_IF([ac_cv_cc_supports_og], [yes],
2271 [PYDEBUG_CFLAGS="-Og"])
2273 # tweak OPT based on compiler and platform, only if the user didn't set
2274 # it on the command line
2276 AC_SUBST([CFLAGS_ALIASING])
2277 if test "${OPT-unset}" = "unset"
2281 if test -n "${cc_is_clang}"
2283 # bpo-30104: disable strict aliasing to compile correctly dtoa.c,
2284 # see Makefile.pre.in for more information
2285 CFLAGS_ALIASING="-fno-strict-aliasing"
2288 case $ac_cv_prog_cc_g in
2290 if test "$Py_DEBUG" = 'true' ; then
2291 OPT="-g $PYDEBUG_CFLAGS -Wall"
2301 case $ac_sys_system in
2302 SCO_SV*) OPT="$OPT -m486 -DSCO5"
2314 AS_CASE([$ac_sys_system],
2316 dnl build with WASM debug info if either Py_DEBUG is set or the target is
2317 dnl node-debug or browser-debug.
2318 AS_VAR_IF([Py_DEBUG], [yes], [wasm_debug=yes], [wasm_debug=no])
2320 dnl Start with 20 MB and allow to grow
2321 AS_VAR_APPEND([LDFLAGS_NODIST], [" -sALLOW_MEMORY_GROWTH -sTOTAL_MEMORY=20971520"])
2323 dnl map int64_t and uint64_t to JS bigint
2324 AS_VAR_APPEND([LDFLAGS_NODIST], [" -sWASM_BIGINT"])
2326 dnl Include file system support
2327 AS_VAR_APPEND([LDFLAGS_NODIST], [" -sFORCE_FILESYSTEM -lidbfs.js -lnodefs.js -lproxyfs.js -lworkerfs.js"])
2329 AS_VAR_IF([enable_wasm_dynamic_linking], [yes], [
2330 AS_VAR_APPEND([LINKFORSHARED], [" -sMAIN_MODULE"])
2333 AS_VAR_IF([enable_wasm_pthreads], [yes], [
2334 AS_VAR_APPEND([CFLAGS_NODIST], [" -pthread"])
2335 AS_VAR_APPEND([LDFLAGS_NODIST], [" -sUSE_PTHREADS"])
2336 AS_VAR_APPEND([LINKFORSHARED], [" -sPROXY_TO_PTHREAD"])
2339 AS_CASE([$ac_sys_emscripten_target],
2341 AS_VAR_IF([ac_sys_emscripten_target], [browser-debug], [wasm_debug=yes])
2342 AS_VAR_APPEND([LINKFORSHARED], [" --preload-file=\$(WASM_ASSETS_DIR)"])
2343 WASM_ASSETS_DIR=".\$(prefix)"
2344 WASM_STDLIB="\$(WASM_ASSETS_DIR)/local/lib/python\$(VERSION)/os.py"
2345 dnl separate-dwarf does not seem to work in Chrome DevTools Support.
2346 WASM_LINKFORSHARED_DEBUG="-gsource-map --emit-symbol-map"
2349 AS_VAR_IF([ac_sys_emscripten_target], [node-debug], [wasm_debug=yes])
2350 AS_VAR_APPEND([LDFLAGS_NODIST], [" -sALLOW_MEMORY_GROWTH -sNODERAWFS"])
2351 AS_VAR_APPEND([LINKFORSHARED], [" -sEXIT_RUNTIME"])
2352 WASM_LINKFORSHARED_DEBUG="-gseparate-dwarf --emit-symbol-map"
2356 AS_VAR_IF([wasm_debug], [yes], [
2357 AS_VAR_APPEND([LDFLAGS_NODIST], [" -sASSERTIONS"])
2358 AS_VAR_APPEND([LINKFORSHARED], [" $WASM_LINKFORSHARED_DEBUG"])
2360 AS_VAR_APPEND([LINKFORSHARED], [" -O2 -g0"])
2364 AC_DEFINE([_WASI_EMULATED_SIGNAL], [1], [Define to 1 if you want to emulate signals on WASI])
2365 AC_DEFINE([_WASI_EMULATED_GETPID], [1], [Define to 1 if you want to emulate getpid() on WASI])
2366 AC_DEFINE([_WASI_EMULATED_PROCESS_CLOCKS], [1], [Define to 1 if you want to emulate process clocks on WASI])
2367 LIBS="$LIBS -lwasi-emulated-signal -lwasi-emulated-getpid -lwasi-emulated-process-clocks"
2368 echo "#define _WASI_EMULATED_SIGNAL 1" >> confdefs.h
2370 AS_VAR_IF([enable_wasm_pthreads], [yes], [
2371 # Note: update CFLAGS because ac_compile/ac_link needs this too.
2372 # without this, configure fails to find pthread_create, sem_init,
2373 # etc because they are only available in the sysroot for
2374 # wasm32-wasi-threads.
2375 # Note: wasi-threads requires --import-memory.
2376 # Note: wasi requires --export-memory.
2377 # Note: --export-memory is implicit unless --import-memory is given
2378 # Note: this requires LLVM >= 16.
2379 AS_VAR_APPEND([CFLAGS], [" -target wasm32-wasi-threads -pthread"])
2380 AS_VAR_APPEND([CFLAGS_NODIST], [" -target wasm32-wasi-threads -pthread"])
2381 AS_VAR_APPEND([LDFLAGS_NODIST], [" -target wasm32-wasi-threads -pthread"])
2382 AS_VAR_APPEND([LDFLAGS_NODIST], [" -Wl,--import-memory"])
2383 AS_VAR_APPEND([LDFLAGS_NODIST], [" -Wl,--export-memory"])
2384 AS_VAR_APPEND([LDFLAGS_NODIST], [" -Wl,--max-memory=10485760"])
2387 dnl gh-117645: Set the memory size to 20 MiB, the stack size to 8 MiB,
2388 dnl and move the stack first.
2389 dnl https://github.com/WebAssembly/wasi-libc/issues/233
2390 AS_VAR_APPEND([LDFLAGS_NODIST], [" -z stack-size=8388608 -Wl,--stack-first -Wl,--initial-memory=20971520"])
2394 AS_CASE([$enable_wasm_dynamic_linking],
2395 [yes], [ac_cv_func_dlopen=yes],
2396 [no], [ac_cv_func_dlopen=no],
2400 AC_SUBST([BASECFLAGS])
2401 AC_SUBST([CFLAGS_NODIST])
2402 AC_SUBST([LDFLAGS_NODIST])
2403 AC_SUBST([LDFLAGS_NOLTO])
2404 AC_SUBST([WASM_ASSETS_DIR])
2405 AC_SUBST([WASM_STDLIB])
2407 # The -arch flags for universal builds on macOS
2408 UNIVERSAL_ARCH_FLAGS=
2409 AC_SUBST([UNIVERSAL_ARCH_FLAGS])
2411 dnl PY_CHECK_CC_WARNING(ENABLE, WARNING, [MSG])
2412 AC_DEFUN([PY_CHECK_CC_WARNING], [
2413 AS_VAR_PUSHDEF([py_var], [ac_cv_$1_]m4_normalize($2)[_warning])
2414 AC_CACHE_CHECK([m4_ifblank([$3], [if we can $1 $CC $2 warning], [$3])], [py_var], [
2415 AS_VAR_COPY([py_cflags], [CFLAGS])
2416 AS_VAR_APPEND([CFLAGS], ["-W$2 -Werror"])
2417 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
2418 [AS_VAR_SET([py_var], [yes])],
2419 [AS_VAR_SET([py_var], [no])])
2420 AS_VAR_COPY([CFLAGS], [py_cflags])
2422 AS_VAR_POPDEF([py_var])
2425 # tweak BASECFLAGS based on compiler and platform
2426 AS_VAR_IF([with_strict_overflow], [yes],
2427 [BASECFLAGS="$BASECFLAGS $STRICT_OVERFLOW_CFLAGS"],
2428 [BASECFLAGS="$BASECFLAGS $NO_STRICT_OVERFLOW_CFLAGS"])
2432 CFLAGS_NODIST="$CFLAGS_NODIST -std=c11"
2434 PY_CHECK_CC_WARNING([enable], [extra], [if we can add -Wextra])
2435 AS_VAR_IF([ac_cv_enable_extra_warning], [yes],
2436 [CFLAGS_NODIST="$CFLAGS_NODIST -Wextra"])
2438 # Python doesn't violate C99 aliasing rules, but older versions of
2439 # GCC produce warnings for legal Python code. Enable
2440 # -fno-strict-aliasing on versions of GCC that support but produce
2441 # warnings. See Issue3326
2443 CC="$CC -fno-strict-aliasing"
2444 save_CFLAGS="$CFLAGS"
2445 AC_CACHE_CHECK([whether $CC accepts and needs -fno-strict-aliasing],
2446 [ac_cv_no_strict_aliasing],
2449 AC_LANG_PROGRAM([[]], [[]])
2451 CC="$ac_save_cc -fstrict-aliasing"
2452 CFLAGS="$CFLAGS -Werror -Wstrict-aliasing"
2455 AC_LANG_PROGRAM([[void f(int **x) {}]],
2456 [[double *x; f((int **) &x);]])
2458 ac_cv_no_strict_aliasing=no
2460 ac_cv_no_strict_aliasing=yes
2463 ac_cv_no_strict_aliasing=no
2465 CFLAGS="$save_CFLAGS"
2467 AS_VAR_IF([ac_cv_no_strict_aliasing], [yes],
2468 [BASECFLAGS="$BASECFLAGS -fno-strict-aliasing"])
2470 # ICC doesn't recognize the option, but only emits a warning
2471 ## XXX does it emit an unused result warning and can it be disabled?
2472 AS_CASE(["$CC_BASENAME"],
2473 [*icc*], [ac_cv_disable_unused_result_warning=no]
2474 [PY_CHECK_CC_WARNING([disable], [unused-result])])
2475 AS_VAR_IF([ac_cv_disable_unused_result_warning], [yes],
2476 [BASECFLAGS="$BASECFLAGS -Wno-unused-result"
2477 CFLAGS_NODIST="$CFLAGS_NODIST -Wno-unused-result"])
2479 PY_CHECK_CC_WARNING([disable], [unused-parameter])
2480 AS_VAR_IF([ac_cv_disable_unused_parameter_warning], [yes],
2481 [CFLAGS_NODIST="$CFLAGS_NODIST -Wno-unused-parameter"])
2483 PY_CHECK_CC_WARNING([disable], [int-conversion])
2484 AS_VAR_IF([ac_cv_disable_int_conversion], [yes],
2485 [CFLAGS_NODIST="$CFLAGS_NODIST -Wno-int-conversion"])
2487 PY_CHECK_CC_WARNING([disable], [missing-field-initializers])
2488 AS_VAR_IF([ac_cv_disable_missing_field_initializers_warning], [yes],
2489 [CFLAGS_NODIST="$CFLAGS_NODIST -Wno-missing-field-initializers"])
2491 PY_CHECK_CC_WARNING([enable], [sign-compare])
2492 AS_VAR_IF([ac_cv_enable_sign_compare_warning], [yes],
2493 [BASECFLAGS="$BASECFLAGS -Wsign-compare"])
2495 PY_CHECK_CC_WARNING([enable], [unreachable-code])
2496 # Don't enable unreachable code warning in debug mode, since it usually
2497 # results in non-standard code paths.
2498 # Issue #24324: Unfortunately, the unreachable code warning does not work
2499 # correctly on gcc and has been silently removed from the compiler.
2500 # It is supported on clang but on OS X systems gcc may be an alias
2501 # for clang. Try to determine if the compiler is not really gcc and,
2502 # if so, only then enable the warning.
2503 if test $ac_cv_enable_unreachable_code_warning = yes && \
2504 test "$Py_DEBUG" != "true" && \
2505 test -z "`$CC --version 2>/dev/null | grep 'Free Software Foundation'`"
2507 BASECFLAGS="$BASECFLAGS -Wunreachable-code"
2509 ac_cv_enable_unreachable_code_warning=no
2512 PY_CHECK_CC_WARNING([enable], [strict-prototypes])
2513 AS_VAR_IF([ac_cv_enable_strict_prototypes_warning], [yes],
2514 [CFLAGS_NODIST="$CFLAGS_NODIST -Wstrict-prototypes"])
2517 CC="$CC -Werror=implicit-function-declaration"
2518 AC_CACHE_CHECK([if we can make implicit function declaration an error in $CC],
2519 [ac_cv_enable_implicit_function_declaration_error],
2522 AC_LANG_PROGRAM([[]], [[]])
2524 ac_cv_enable_implicit_function_declaration_error=yes
2526 ac_cv_enable_implicit_function_declaration_error=no
2530 AS_VAR_IF([ac_cv_enable_implicit_function_declaration_error], [yes],
2531 [CFLAGS_NODIST="$CFLAGS_NODIST -Werror=implicit-function-declaration"])
2534 CC="$CC -fvisibility=hidden"
2535 AC_CACHE_CHECK([if we can use visibility in $CC], [ac_cv_enable_visibility],
2538 AC_LANG_PROGRAM([[]], [[]])
2540 ac_cv_enable_visibility=yes
2542 ac_cv_enable_visibility=no
2546 AS_VAR_IF([ac_cv_enable_visibility], [yes],
2547 [CFLAGS_NODIST="$CFLAGS_NODIST -fvisibility=hidden"])
2549 # if using gcc on alpha, use -mieee to get (near) full IEEE 754
2550 # support. Without this, treatment of subnormals doesn't follow
2554 BASECFLAGS="$BASECFLAGS -mieee"
2558 case $ac_sys_system in
2560 BASECFLAGS="$BASECFLAGS -m486 -DSCO5"
2564 # -Wno-long-double, -no-cpp-precomp, and -mno-fused-madd
2565 # used to be here, but non-Apple gcc doesn't accept them.
2566 if test "${CC}" = gcc
2568 AC_MSG_CHECKING([which compiler should be used])
2569 case "${UNIVERSALSDK}" in
2571 # Build using 10.4 SDK, force usage of gcc when the
2572 # compiler is gcc, otherwise the user will get very
2573 # confusing error messages when building on OSX 10.6
2578 AC_MSG_RESULT([$CC])
2581 LIPO_INTEL64_FLAGS=""
2582 if test "${enable_universalsdk}"
2584 case "$UNIVERSAL_ARCHS" in
2586 UNIVERSAL_ARCH_FLAGS="-arch ppc -arch i386"
2591 UNIVERSAL_ARCH_FLAGS="-arch ppc64 -arch x86_64"
2593 ARCH_RUN_32BIT="true"
2596 UNIVERSAL_ARCH_FLAGS="-arch i386 -arch ppc -arch ppc64 -arch x86_64"
2597 LIPO_32BIT_FLAGS="-extract ppc7400 -extract i386"
2598 ARCH_RUN_32BIT="/usr/bin/arch -i386 -ppc"
2601 UNIVERSAL_ARCH_FLAGS="-arch arm64 -arch x86_64"
2603 LIPO_INTEL64_FLAGS="-extract x86_64"
2604 ARCH_RUN_32BIT="true"
2607 UNIVERSAL_ARCH_FLAGS="-arch i386 -arch x86_64"
2608 LIPO_32BIT_FLAGS="-extract i386"
2609 ARCH_RUN_32BIT="/usr/bin/arch -i386"
2612 UNIVERSAL_ARCH_FLAGS="-arch i386"
2617 UNIVERSAL_ARCH_FLAGS="-arch x86_64"
2619 ARCH_RUN_32BIT="true"
2622 UNIVERSAL_ARCH_FLAGS="-arch i386 -arch ppc -arch x86_64"
2623 LIPO_32BIT_FLAGS="-extract ppc7400 -extract i386"
2624 ARCH_RUN_32BIT="/usr/bin/arch -i386 -ppc"
2627 AC_MSG_ERROR([proper usage is --with-universal-arch=universal2|32-bit|64-bit|all|intel|3-way])
2631 if test "${UNIVERSALSDK}" != "/"
2633 CFLAGS="${UNIVERSAL_ARCH_FLAGS} -isysroot ${UNIVERSALSDK} ${CFLAGS}"
2634 LDFLAGS="${UNIVERSAL_ARCH_FLAGS} -isysroot ${UNIVERSALSDK} ${LDFLAGS}"
2635 CPPFLAGS="-isysroot ${UNIVERSALSDK} ${CPPFLAGS}"
2637 CFLAGS="${UNIVERSAL_ARCH_FLAGS} ${CFLAGS}"
2638 LDFLAGS="${UNIVERSAL_ARCH_FLAGS} ${LDFLAGS}"
2642 # Calculate an appropriate deployment target for this build:
2643 # The deployment target value is used explicitly to enable certain
2644 # features are enabled (such as builtin libedit support for readline)
2645 # through the use of Apple's Availability Macros and is used as a
2646 # component of the string returned by distutils.get_platform().
2648 # Use the value from:
2649 # 1. the MACOSX_DEPLOYMENT_TARGET environment variable if specified
2650 # 2. the operating system version of the build machine if >= 10.6
2651 # 3. If running on OS X 10.3 through 10.5, use the legacy tests
2652 # below to pick either 10.3, 10.4, or 10.5 as the target.
2653 # 4. If we are running on OS X 10.2 or earlier, good luck!
2655 AC_MSG_CHECKING([which MACOSX_DEPLOYMENT_TARGET to use])
2656 cur_target_major=`sw_vers -productVersion | \
2657 sed 's/\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'`
2658 cur_target_minor=`sw_vers -productVersion | \
2659 sed 's/\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'`
2660 cur_target="${cur_target_major}.${cur_target_minor}"
2661 if test ${cur_target_major} -eq 10 && \
2662 test ${cur_target_minor} -ge 3 && \
2663 test ${cur_target_minor} -le 5
2665 # OS X 10.3 through 10.5
2667 if test ${enable_universalsdk}
2669 case "$UNIVERSAL_ARCHS" in
2670 all|3-way|intel|64-bit)
2671 # These configurations were first supported in 10.5
2676 if test `/usr/bin/arch` = "i386"
2678 # 10.4 was the first release to support Intel archs
2683 CONFIGURE_MACOSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET-${cur_target}}
2685 # Make sure that MACOSX_DEPLOYMENT_TARGET is set in the
2686 # environment with a value that is the same as what we'll use
2687 # in the Makefile to ensure that we'll get the same compiler
2688 # environment during configure and build time.
2689 MACOSX_DEPLOYMENT_TARGET="$CONFIGURE_MACOSX_DEPLOYMENT_TARGET"
2690 export MACOSX_DEPLOYMENT_TARGET
2691 EXPORT_MACOSX_DEPLOYMENT_TARGET=''
2692 AC_MSG_RESULT([$MACOSX_DEPLOYMENT_TARGET])
2694 AC_MSG_CHECKING([if specified universal architectures work])
2695 AC_LINK_IFELSE([AC_LANG_PROGRAM([[@%:@include <stdio.h>]], [[printf("%d", 42);]])],
2696 [AC_MSG_RESULT([yes])],
2697 [AC_MSG_RESULT([no])
2698 AC_MSG_ERROR([check config.log and use the '--with-universal-archs' option])
2701 # end of Darwin* tests
2707 case $ac_sys_system in
2708 OpenUNIX*|UnixWare*)
2709 BASECFLAGS="$BASECFLAGS -K pentium,host,inline,loop_unroll,alloca "
2712 BASECFLAGS="$BASECFLAGS -belf -Ki486 -DSCO5"
2718 case "$CC_BASENAME" in
2720 CFLAGS_NODIST="$CFLAGS_NODIST"
2723 # ICC needs -fp-model strict or floats behave badly
2724 CFLAGS_NODIST="$CFLAGS_NODIST -fp-model strict"
2727 CFLAGS_NODIST="$CFLAGS_NODIST -qalias=noansi -qmaxmem=-1"
2731 if test "$assertions" = 'true'; then
2737 if test "$ac_arch_flags"
2739 BASECFLAGS="$BASECFLAGS $ac_arch_flags"
2742 # On some compilers, pthreads are available without further options
2743 # (e.g. MacOS X). On some of these systems, the compiler will not
2744 # complain if unaccepted options are passed (e.g. gcc on Mac OS X).
2745 # So we have to see first whether pthreads are available without
2746 # options before we can check whether -Kpthread improves anything.
2747 AC_CACHE_CHECK([whether pthreads are available without options],
2748 [ac_cv_pthread_is_default],
2749 [AC_RUN_IFELSE([AC_LANG_SOURCE([[
2751 #include <pthread.h>
2753 void* routine(void* p){return NULL;}
2757 if(pthread_create(&p,NULL,routine,NULL)!=0)
2759 (void)pthread_detach(p);
2763 ac_cv_pthread_is_default=yes
2766 ],[ac_cv_pthread_is_default=no],[ac_cv_pthread_is_default=no])
2770 if test $ac_cv_pthread_is_default = yes
2774 # -Kpthread, if available, provides the right #defines
2775 # and linker options to make pthread_create available
2776 # Some compilers won't report that they do not support -Kpthread,
2777 # so we need to run a program to see whether it really made the
2778 # function available.
2779 AC_CACHE_CHECK([whether $CC accepts -Kpthread], [ac_cv_kpthread],
2782 AC_RUN_IFELSE([AC_LANG_SOURCE([[
2784 #include <pthread.h>
2786 void* routine(void* p){return NULL;}
2790 if(pthread_create(&p,NULL,routine,NULL)!=0)
2792 (void)pthread_detach(p);
2795 ]])],[ac_cv_kpthread=yes],[ac_cv_kpthread=no],[ac_cv_kpthread=no])
2799 if test $ac_cv_kpthread = no -a $ac_cv_pthread_is_default = no
2801 # -Kthread, if available, provides the right #defines
2802 # and linker options to make pthread_create available
2803 # Some compilers won't report that they do not support -Kthread,
2804 # so we need to run a program to see whether it really made the
2805 # function available.
2806 AC_CACHE_CHECK([whether $CC accepts -Kthread], [ac_cv_kthread],
2809 AC_RUN_IFELSE([AC_LANG_SOURCE([[
2811 #include <pthread.h>
2813 void* routine(void* p){return NULL;}
2817 if(pthread_create(&p,NULL,routine,NULL)!=0)
2819 (void)pthread_detach(p);
2822 ]])],[ac_cv_kthread=yes],[ac_cv_kthread=no],[ac_cv_kthread=no])
2826 if test $ac_cv_kthread = no -a $ac_cv_pthread_is_default = no
2828 # -pthread, if available, provides the right #defines
2829 # and linker options to make pthread_create available
2830 # Some compilers won't report that they do not support -pthread,
2831 # so we need to run a program to see whether it really made the
2832 # function available.
2833 AC_CACHE_CHECK([whether $CC accepts -pthread], [ac_cv_pthread],
2836 AC_RUN_IFELSE([AC_LANG_SOURCE([[
2838 #include <pthread.h>
2840 void* routine(void* p){return NULL;}
2844 if(pthread_create(&p,NULL,routine,NULL)!=0)
2846 (void)pthread_detach(p);
2849 ]])],[ac_cv_pthread=yes],[ac_cv_pthread=no],[ac_cv_pthread=no])
2853 # If we have set a CC compiler flag for thread support then
2854 # check if it works for CXX, too.
2857 AC_CACHE_CHECK([whether $CXX also accepts flags for thread support], [ac_cv_cxx_thread],
2860 if test "$ac_cv_kpthread" = "yes"
2862 CXX="$CXX -Kpthread"
2863 ac_cv_cxx_thread=yes
2864 elif test "$ac_cv_kthread" = "yes"
2867 ac_cv_cxx_thread=yes
2868 elif test "$ac_cv_pthread" = "yes"
2871 ac_cv_cxx_thread=yes
2876 if test $ac_cv_cxx_thread = yes
2878 echo 'void foo();int main(){foo();}void foo(){}' > conftest.$ac_ext
2879 $CXX -c conftest.$ac_ext 2>&5
2880 if $CXX -o conftest$ac_exeext conftest.$ac_objext 2>&5 \
2881 && test -s conftest$ac_exeext && ./conftest$ac_exeext
2883 ac_cv_cxx_thread=yes
2889 CXX="$ac_save_cxx"])
2894 dnl # check for ANSI or K&R ("traditional") preprocessor
2895 dnl AC_MSG_CHECKING(for C preprocessor type)
2896 dnl AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
2897 dnl #define spam(name, doc) {#name, &name, #name "() -- " doc}
2899 dnl struct {char *name; int *addr; char *doc;} desc = spam(foo, "something");
2900 dnl ]], [[;]])],[cpp_type=ansi],[AC_DEFINE(HAVE_OLD_CPP) cpp_type=traditional])
2901 dnl AC_MSG_RESULT($cpp_type)
2903 dnl autoconf 2.71 deprecates STDC_HEADERS, keep for backwards compatibility
2904 dnl assume C99 compilers provide ANSI C headers
2905 AC_DEFINE([STDC_HEADERS], [1],
2906 [Define to 1 if you have the ANSI C header files.])
2908 # checks for header files
2909 AC_CHECK_HEADERS([ \
2910 alloca.h asm/types.h bluetooth.h conio.h direct.h dlfcn.h endian.h errno.h fcntl.h grp.h \
2911 io.h langinfo.h libintl.h libutil.h linux/auxvec.h sys/auxv.h linux/fs.h linux/limits.h linux/memfd.h \
2912 linux/random.h linux/soundcard.h \
2913 linux/tipc.h linux/wait.h netdb.h net/ethernet.h netinet/in.h netpacket/packet.h poll.h process.h pthread.h pty.h \
2914 sched.h setjmp.h shadow.h signal.h spawn.h stropts.h sys/audioio.h sys/bsdtty.h sys/devpoll.h \
2915 sys/endian.h sys/epoll.h sys/event.h sys/eventfd.h sys/file.h sys/ioctl.h sys/kern_control.h \
2916 sys/loadavg.h sys/lock.h sys/memfd.h sys/mkdev.h sys/mman.h sys/modem.h sys/param.h sys/poll.h \
2917 sys/random.h sys/resource.h sys/select.h sys/sendfile.h sys/socket.h sys/soundcard.h sys/stat.h \
2918 sys/statvfs.h sys/sys_domain.h sys/syscall.h sys/sysmacros.h sys/termio.h sys/time.h sys/times.h sys/timerfd.h \
2919 sys/types.h sys/uio.h sys/un.h sys/utsname.h sys/wait.h sys/xattr.h sysexits.h syslog.h \
2920 termios.h util.h utime.h utmp.h \
2925 # bluetooth/bluetooth.h has been known to not compile with -std=c99.
2926 # http://permalink.gmane.org/gmane.linux.bluez.kernel/22294
2928 CFLAGS="-std=c99 $CFLAGS"
2929 AC_CHECK_HEADERS([bluetooth/bluetooth.h])
2932 # On Darwin (OS X) net/if.h requires sys/socket.h to be imported first.
2933 AC_CHECK_HEADERS([net/if.h], [], [],
2937 #ifdef HAVE_SYS_SOCKET_H
2938 # include <sys/socket.h>
2942 # On Linux, netlink.h requires asm/types.h
2943 # On FreeBSD, netlink.h is located in netlink/netlink.h
2944 AC_CHECK_HEADERS([linux/netlink.h netlink/netlink.h], [], [], [
2945 #ifdef HAVE_ASM_TYPES_H
2946 #include <asm/types.h>
2948 #ifdef HAVE_SYS_SOCKET_H
2949 #include <sys/socket.h>
2953 # On Linux, qrtr.h requires asm/types.h
2954 AC_CHECK_HEADERS([linux/qrtr.h], [], [], [
2955 #ifdef HAVE_ASM_TYPES_H
2956 #include <asm/types.h>
2958 #ifdef HAVE_SYS_SOCKET_H
2959 #include <sys/socket.h>
2963 AC_CHECK_HEADERS([linux/vm_sockets.h], [], [], [
2964 #ifdef HAVE_SYS_SOCKET_H
2965 #include <sys/socket.h>
2969 # On Linux, can.h, can/bcm.h, can/j1939.h, can/raw.h require sys/socket.h
2970 # On NetBSD, netcan/can.h requires sys/socket.h
2972 [linux/can.h linux/can/bcm.h linux/can/j1939.h linux/can/raw.h netcan/can.h],
2974 #ifdef HAVE_SYS_SOCKET_H
2975 #include <sys/socket.h>
2979 # Check for clock_t in time.h.
2980 AC_CHECK_TYPES([clock_t], [],
2981 [AC_DEFINE([clock_t], [long],
2982 [Define to 'long' if <time.h> does not define clock_t.])],
2983 [@%:@include <time.h>])
2985 AC_CACHE_CHECK([for makedev], [ac_cv_func_makedev], [
2986 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
2987 #if defined(MAJOR_IN_MKDEV)
2988 #include <sys/mkdev.h>
2989 #elif defined(MAJOR_IN_SYSMACROS)
2990 #include <sys/sysmacros.h>
2992 #include <sys/types.h>
2996 ],[ac_cv_func_makedev=yes],[ac_cv_func_makedev=no])
2999 AS_VAR_IF([ac_cv_func_makedev], [yes], [
3000 AC_DEFINE([HAVE_MAKEDEV], [1],
3001 [Define this if you have the makedev macro.])
3005 AC_CACHE_CHECK([for le64toh], [ac_cv_func_le64toh], [
3006 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
3007 #ifdef HAVE_ENDIAN_H
3009 #elif defined(HAVE_SYS_ENDIAN_H)
3010 #include <sys/endian.h>
3014 ],[ac_cv_func_le64toh=yes],[ac_cv_func_le64toh=no])
3017 AS_VAR_IF([ac_cv_func_le64toh], [yes], [
3018 AC_DEFINE([HAVE_HTOLE64], [1],
3019 [Define this if you have le64toh()])
3023 # Don't use largefile support for GNU/Hurd
3024 case $ac_sys_system in GNU*)
3028 if test "$use_lfs" = "yes"; then
3029 # Two defines needed to enable largefile support on various platforms
3030 # These may affect some typedefs
3031 case $ac_sys_system/$ac_sys_release in
3033 AC_DEFINE([_LARGE_FILES], [1],
3034 [This must be defined on AIX systems to enable large file support.])
3037 AC_DEFINE([_LARGEFILE_SOURCE], [1],
3038 [This must be defined on some systems to enable large file support.])
3039 AC_DEFINE([_FILE_OFFSET_BITS], [64],
3040 [This must be set to 64 on some systems to enable large file support.])
3043 # Add some code to confdefs.h so that the test for off_t works on SCO
3044 cat >> confdefs.h <<\EOF
3050 # Type availability checks
3054 AC_DEFINE_UNQUOTED([RETSIGTYPE],[void],[assume C89 semantics that RETSIGTYPE is always void])
3058 AC_CHECK_TYPES([ssize_t])
3059 AC_CHECK_TYPES([__uint128_t],
3060 [AC_DEFINE([HAVE_GCC_UINT128_T], [1],
3061 [Define if your compiler provides __uint128_t])])
3063 # Sizes and alignments of various common basic types
3064 # ANSI C requires sizeof(char) == 1, so no need to check it
3065 AC_CHECK_SIZEOF([int], [4])
3066 AC_CHECK_SIZEOF([long], [4])
3067 AC_CHECK_ALIGNOF([long])
3068 AC_CHECK_SIZEOF([long long], [8])
3069 AC_CHECK_SIZEOF([void *], [4])
3070 AC_CHECK_SIZEOF([short], [2])
3071 AC_CHECK_SIZEOF([float], [4])
3072 AC_CHECK_SIZEOF([double], [8])
3073 AC_CHECK_SIZEOF([fpos_t], [4])
3074 AC_CHECK_SIZEOF([size_t], [4])
3075 AC_CHECK_ALIGNOF([size_t])
3076 AC_CHECK_SIZEOF([pid_t], [4])
3077 AC_CHECK_SIZEOF([uintptr_t])
3078 AC_CHECK_ALIGNOF([max_align_t])
3081 AC_CHECK_SIZEOF([long double], [16])
3083 AC_CHECK_SIZEOF([_Bool], [1])
3085 AC_CHECK_SIZEOF([off_t], [], [
3086 #ifdef HAVE_SYS_TYPES_H
3087 #include <sys/types.h>
3091 AC_MSG_CHECKING([whether to enable large file support])
3092 if test "$ac_cv_sizeof_off_t" -gt "$ac_cv_sizeof_long" -a \
3093 "$ac_cv_sizeof_long_long" -ge "$ac_cv_sizeof_off_t"; then
3094 have_largefile_support="yes"
3096 have_largefile_support="no"
3098 dnl LFS does not work with Emscripten 3.1
3099 AS_CASE([$ac_sys_system],
3100 [Emscripten], [have_largefile_support="no"]
3102 AS_VAR_IF([have_largefile_support], [yes], [
3103 AC_DEFINE([HAVE_LARGEFILE_SUPPORT], [1],
3104 [Defined to enable large file support when an off_t is bigger than a long
3105 and long long is at least as big as an off_t. You may need
3106 to add some flags for configuration and compilation to enable this mode.
3107 (For Solaris and Linux, the necessary defines are already defined.)])
3108 AC_MSG_RESULT([yes])
3113 AC_CHECK_SIZEOF([time_t], [], [
3114 #ifdef HAVE_SYS_TYPES_H
3115 #include <sys/types.h>
3122 # if have pthread_t then define SIZEOF_PTHREAD_T
3124 if test "$ac_cv_kpthread" = "yes"
3125 then CC="$CC -Kpthread"
3126 elif test "$ac_cv_kthread" = "yes"
3127 then CC="$CC -Kthread"
3128 elif test "$ac_cv_pthread" = "yes"
3129 then CC="$CC -pthread"
3132 AC_CACHE_CHECK([for pthread_t], [ac_cv_have_pthread_t], [
3134 AC_LANG_PROGRAM([[@%:@include <pthread.h>]], [[pthread_t x; x = *(pthread_t*)0;]])
3135 ], [ac_cv_have_pthread_t=yes], [ac_cv_have_pthread_t=no])
3137 AS_VAR_IF([ac_cv_have_pthread_t], [yes], [
3138 AC_CHECK_SIZEOF([pthread_t], [], [
3139 #ifdef HAVE_PTHREAD_H
3140 #include <pthread.h>
3145 # Issue #25658: POSIX hasn't defined that pthread_key_t is compatible with int.
3146 # This checking will be unnecessary after removing deprecated TLS API.
3147 AC_CHECK_SIZEOF([pthread_key_t], [], [[@%:@include <pthread.h>]])
3148 AC_CACHE_CHECK([whether pthread_key_t is compatible with int], [ac_cv_pthread_key_t_is_arithmetic_type], [
3149 if test "$ac_cv_sizeof_pthread_key_t" -eq "$ac_cv_sizeof_int" ; then
3151 [AC_LANG_PROGRAM([[@%:@include <pthread.h>]], [[pthread_key_t k; k * 1;]])],
3152 [ac_cv_pthread_key_t_is_arithmetic_type=yes],
3153 [ac_cv_pthread_key_t_is_arithmetic_type=no]
3156 ac_cv_pthread_key_t_is_arithmetic_type=no
3159 AS_VAR_IF([ac_cv_pthread_key_t_is_arithmetic_type], [yes], [
3160 AC_DEFINE([PTHREAD_KEY_T_IS_COMPATIBLE_WITH_INT], [1],
3161 [Define if pthread_key_t is compatible with int.])
3166 AC_MSG_CHECKING([for --enable-framework])
3167 if test "$enable_framework"
3169 BASECFLAGS="$BASECFLAGS -fno-common -dynamic"
3170 # -F. is needed to allow linking to the framework while
3171 # in the build location.
3172 AC_DEFINE([WITH_NEXT_FRAMEWORK], [1],
3173 [Define if you want to produce an OpenStep/Rhapsody framework
3174 (shared library plus accessory files).])
3175 AC_MSG_RESULT([yes])
3176 if test $enable_shared = "yes"
3178 AC_MSG_ERROR([Specifying both --enable-shared and --enable-framework is not supported, use only --enable-framework instead])
3184 # Check for --with-dsymutil
3185 AC_SUBST([DSYMUTIL])
3186 AC_SUBST([DSYMUTIL_PATH])
3189 AC_MSG_CHECKING([for --with-dsymutil])
3194 [link debug information into final executable with dsymutil in macOS (default is no)]
3197 if test "$withval" != no
3199 if test "$MACHDEP" != "darwin"; then
3200 AC_MSG_ERROR([dsymutil debug linking is only available in macOS.])
3202 AC_MSG_RESULT([yes]);
3204 else AC_MSG_RESULT([no]); DSYMUTIL=
3206 [AC_MSG_RESULT([no])])
3208 if test "$DSYMUTIL"; then
3209 AC_PATH_PROG([DSYMUTIL_PATH], [dsymutil], [not found])
3210 if test "$DSYMUTIL_PATH" = "not found"; then
3211 AC_MSG_ERROR([dsymutil command not found on \$PATH])
3215 AC_MSG_CHECKING([for dyld])
3216 case $ac_sys_system/$ac_sys_release in
3218 AC_DEFINE([WITH_DYLD], [1],
3219 [Define if you want to use the new-style (Openstep, Rhapsody, MacOS)
3220 dynamic linker (dyld) instead of the old-style (NextStep) dynamic
3221 linker (rld). Dyld is necessary to support frameworks.])
3222 AC_MSG_RESULT([always on for Darwin])
3229 AC_MSG_CHECKING([for --with-address-sanitizer])
3230 AC_ARG_WITH([address_sanitizer],
3231 AS_HELP_STRING([--with-address-sanitizer],
3232 [enable AddressSanitizer memory error detector, 'asan' (default is no)]),
3234 AC_MSG_RESULT([$withval])
3235 BASECFLAGS="-fsanitize=address -fno-omit-frame-pointer $BASECFLAGS"
3236 LDFLAGS="-fsanitize=address $LDFLAGS"
3237 # ASan works by controlling memory allocation, our own malloc interferes.
3240 [AC_MSG_RESULT([no])])
3242 AC_MSG_CHECKING([for --with-memory-sanitizer])
3246 [--with-memory-sanitizer],
3247 [enable MemorySanitizer allocation error detector, 'msan' (default is no)]
3250 AC_MSG_RESULT([$withval])
3251 AX_CHECK_COMPILE_FLAG([-fsanitize=memory],[
3252 BASECFLAGS="-fsanitize=memory -fsanitize-memory-track-origins=2 -fno-omit-frame-pointer $BASECFLAGS"
3253 LDFLAGS="-fsanitize=memory -fsanitize-memory-track-origins=2 $LDFLAGS"
3254 ],[AC_MSG_ERROR([The selected compiler doesn't support memory sanitizer])])
3255 # MSan works by controlling memory allocation, our own malloc interferes.
3258 [AC_MSG_RESULT([no])])
3260 AC_MSG_CHECKING([for --with-undefined-behavior-sanitizer])
3262 [undefined_behavior_sanitizer],
3264 [--with-undefined-behavior-sanitizer],
3265 [enable UndefinedBehaviorSanitizer undefined behaviour detector, 'ubsan' (default is no)]
3268 AC_MSG_RESULT([$withval])
3269 BASECFLAGS="-fsanitize=undefined $BASECFLAGS"
3270 LDFLAGS="-fsanitize=undefined $LDFLAGS"
3278 AC_MSG_CHECKING([for --with-thread-sanitizer])
3282 [--with-thread-sanitizer],
3283 [enable ThreadSanitizer data race detector, 'tsan' (default is no)]
3286 AC_MSG_RESULT([$withval])
3287 BASECFLAGS="-fsanitize=thread $BASECFLAGS"
3288 LDFLAGS="-fsanitize=thread $LDFLAGS"
3296 # Set info about shared libraries.
3297 AC_SUBST([SHLIB_SUFFIX])
3298 AC_SUBST([LDSHARED])
3299 AC_SUBST([LDCXXSHARED])
3300 AC_SUBST([BLDSHARED])
3301 AC_SUBST([CCSHARED])
3302 AC_SUBST([LINKFORSHARED])
3304 # SHLIB_SUFFIX is the extension of shared libraries `(including the dot!)
3305 # -- usually .so, .sl on HP-UX, .dll on Cygwin
3306 AC_MSG_CHECKING([the extension of shared libraries])
3307 if test -z "$SHLIB_SUFFIX"; then
3308 case $ac_sys_system in
3311 ia64) SHLIB_SUFFIX=.so;;
3312 *) SHLIB_SUFFIX=.sl;;
3315 CYGWIN*) SHLIB_SUFFIX=.dll;;
3316 *) SHLIB_SUFFIX=.so;;
3319 AC_MSG_RESULT([$SHLIB_SUFFIX])
3321 # LDSHARED is the ld *command* used to create shared library
3322 # -- "cc -G" on SunOS 5.x.
3323 # (Shared libraries in this instance are shared modules to be loaded into
3324 # Python, as opposed to building Python itself as a shared library.)
3325 AC_MSG_CHECKING([LDSHARED])
3326 if test -z "$LDSHARED"
3328 case $ac_sys_system/$ac_sys_release in
3330 BLDSHARED="Modules/ld_so_aix \$(CC) -bI:Modules/python.exp"
3331 LDSHARED="\$(LIBPL)/ld_so_aix \$(CC) -bI:\$(LIBPL)/python.exp"
3334 if test "$GCC" = "yes" ; then
3335 LDSHARED='$(CC) -shared'
3336 LDCXXSHARED='$(CXX) -shared'
3339 LDCXXSHARED='$(CXX) -G'
3342 if test "$GCC" = "yes" ; then
3343 LDSHARED='$(CC) -shared'
3344 LDCXXSHARED='$(CXX) -shared'
3347 LDCXXSHARED='$(CXX) -b'
3350 LDSHARED='$(CC) -bundle'
3351 LDCXXSHARED='$(CXX) -bundle'
3352 if test "$enable_framework" ; then
3353 # Link against the framework. All externals should be defined.
3354 BLDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
3355 LDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
3356 LDCXXSHARED="$LDCXXSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
3358 # No framework. Ignore undefined symbols, assuming they come from Python
3359 LDSHARED="$LDSHARED -undefined suppress"
3360 LDCXXSHARED="$LDCXXSHARED -undefined suppress"
3362 Darwin/1.4*|Darwin/5.*|Darwin/6.*)
3363 LDSHARED='$(CC) -bundle'
3364 LDCXXSHARED='$(CXX) -bundle'
3365 if test "$enable_framework" ; then
3366 # Link against the framework. All externals should be defined.
3367 BLDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
3368 LDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
3369 LDCXXSHARED="$LDCXXSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
3371 # No framework, use the Python app as bundle-loader
3372 BLDSHARED="$LDSHARED "'-bundle_loader $(BUILDPYTHON)'
3373 LDSHARED="$LDSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)'
3374 LDCXXSHARED="$LDCXXSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)'
3377 # Use -undefined dynamic_lookup whenever possible (10.3 and later).
3378 # This allows an extension to be used in any Python
3380 dep_target_major=`echo ${MACOSX_DEPLOYMENT_TARGET} | \
3381 sed 's/\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'`
3382 dep_target_minor=`echo ${MACOSX_DEPLOYMENT_TARGET} | \
3383 sed 's/\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'`
3384 if test ${dep_target_major} -eq 10 && \
3385 test ${dep_target_minor} -le 2
3387 # building for OS X 10.0 through 10.2
3388 AC_MSG_ERROR([MACOSX_DEPLOYMENT_TARGET too old ($MACOSX_DEPLOYMENT_TARGET), only 10.3 or later is supported])
3390 # building for OS X 10.3 and later
3391 LDSHARED='$(CC) -bundle -undefined dynamic_lookup'
3392 LDCXXSHARED='$(CXX) -bundle -undefined dynamic_lookup'
3393 BLDSHARED="$LDSHARED"
3397 LDSHARED='$(CC) -dynamiclib -F . -framework $(PYTHONFRAMEWORK)'
3398 LDCXXSHARED='$(CXX) -dynamiclib -F . -framework $(PYTHONFRAMEWORK)'
3399 BLDSHARED="$LDSHARED"
3402 LDSHARED='$(CC) -shared'
3403 LDCXXSHARED='$(CXX) -shared';;
3404 Linux*|GNU*|QNX*|VxWorks*|Haiku*)
3405 LDSHARED='$(CC) -shared'
3406 LDCXXSHARED='$(CXX) -shared';;
3408 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
3410 LDSHARED='$(CC) -shared'
3411 LDCXXSHARED='$(CXX) -shared'
3413 LDSHARED="ld -Bshareable"
3416 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
3418 LDSHARED='$(CC) -shared $(CCSHARED)'
3419 LDCXXSHARED='$(CXX) -shared $(CCSHARED)'
3422 [[01]].* | 2.[[0-7]] | 2.[[0-7]].*)
3423 LDSHARED="ld -Bshareable ${LDFLAGS}"
3426 LDSHARED='$(CC) -shared $(CCSHARED)'
3427 LDCXXSHARED='$(CXX) -shared $(CCSHARED)'
3432 LDSHARED='$(CC) -shared'
3433 LDCXXSHARED='$(CXX) -shared';;
3434 OpenUNIX*|UnixWare*)
3435 if test "$GCC" = "yes" ; then
3436 LDSHARED='$(CC) -shared'
3437 LDCXXSHARED='$(CXX) -shared'
3440 LDCXXSHARED='$(CXX) -G'
3443 LDSHARED='$(CC) -Wl,-G,-Bexport'
3444 LDCXXSHARED='$(CXX) -Wl,-G,-Bexport';;
3446 AS_VAR_IF([enable_wasm_dynamic_linking], [yes], [
3447 dnl not iplemented yet
3450 LDSHARED="gcc -shared -Wl,--enable-auto-image-base"
3451 LDCXXSHARED="g++ -shared -Wl,--enable-auto-image-base";;
3456 dnl Emscripten's emconfigure sets LDSHARED. Set BLDSHARED outside the
3457 dnl test -z $LDSHARED block to configure BLDSHARED for side module support.
3458 if test "$enable_wasm_dynamic_linking" = "yes" -a "$ac_sys_system" = "Emscripten"; then
3459 BLDSHARED='$(CC) -shared -sSIDE_MODULE=1'
3462 AC_MSG_RESULT([$LDSHARED])
3463 LDCXXSHARED=${LDCXXSHARED-$LDSHARED}
3465 AC_MSG_CHECKING([BLDSHARED flags])
3466 BLDSHARED=${BLDSHARED-$LDSHARED}
3467 AC_MSG_RESULT([$BLDSHARED])
3469 # CCSHARED are the C *flags* used to create objects to go into a shared
3470 # library (module) -- this is only needed for a few systems
3471 AC_MSG_CHECKING([CCSHARED])
3472 if test -z "$CCSHARED"
3474 case $ac_sys_system/$ac_sys_release in
3475 SunOS*) if test "$GCC" = yes;
3476 then CCSHARED="-fPIC";
3477 elif test `uname -p` = sparc;
3478 then CCSHARED="-xcode=pic32";
3479 else CCSHARED="-Kpic";
3481 hp*|HP*) if test "$GCC" = yes;
3482 then CCSHARED="-fPIC";
3485 Linux*|GNU*) CCSHARED="-fPIC";;
3487 AS_VAR_IF([enable_wasm_dynamic_linking], [yes], [
3490 FreeBSD*|NetBSD*|OpenBSD*|DragonFly*) CCSHARED="-fPIC";;
3491 Haiku*) CCSHARED="-fPIC";;
3492 OpenUNIX*|UnixWare*)
3493 if test "$GCC" = "yes"
3494 then CCSHARED="-fPIC"
3495 else CCSHARED="-KPIC"
3498 if test "$GCC" = "yes"
3499 then CCSHARED="-fPIC"
3500 else CCSHARED="-Kpic -belf"
3503 CCSHARED="-fpic -D__SO_PICABILINUX__ -ftls-model=global-dynamic"
3506 AC_MSG_RESULT([$CCSHARED])
3507 # LINKFORSHARED are the flags passed to the $(CC) command that links
3508 # the python executable -- this is only needed for a few systems
3509 AC_MSG_CHECKING([LINKFORSHARED])
3510 if test -z "$LINKFORSHARED"
3512 case $ac_sys_system/$ac_sys_release in
3513 AIX*) LINKFORSHARED='-Wl,-bE:Modules/python.exp -lld';;
3515 LINKFORSHARED="-Wl,-E -Wl,+s";;
3516 # LINKFORSHARED="-Wl,-E -Wl,+s -Wl,+b\$(BINLIBDEST)/lib-dynload";;
3517 Linux-android*) LINKFORSHARED="-pie -Xlinker -export-dynamic";;
3518 Linux*|GNU*) LINKFORSHARED="-Xlinker -export-dynamic";;
3519 # -u libsys_s pulls in all symbols in libsys
3521 LINKFORSHARED="$extra_undefs -framework CoreFoundation"
3523 # Issue #18075: the default maximum stack size (8MBytes) is too
3524 # small for the default recursion limit. Increase the stack size
3525 # to ensure that tests don't crash
3526 stack_size="1000000" # 16 MB
3527 if test "$with_ubsan" = "yes"
3529 # Undefined behavior sanitizer requires an even deeper stack
3530 stack_size="4000000" # 64 MB
3533 AC_DEFINE_UNQUOTED([THREAD_STACK_SIZE],
3535 [Custom thread stack size depending on chosen sanitizer runtimes.])
3537 if test $ac_sys_system = "Darwin"; then
3538 LINKFORSHARED="-Wl,-stack_size,$stack_size $LINKFORSHARED"
3540 if test "$enable_framework"; then
3541 LINKFORSHARED="$LINKFORSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
3543 LINKFORSHARED="$LINKFORSHARED"
3544 elif test $ac_sys_system = "iOS"; then
3545 LINKFORSHARED="-Wl,-stack_size,$stack_size $LINKFORSHARED "'$(PYTHONFRAMEWORKDIR)/$(PYTHONFRAMEWORK)'
3548 OpenUNIX*|UnixWare*) LINKFORSHARED="-Wl,-Bexport";;
3549 SCO_SV*) LINKFORSHARED="-Wl,-Bexport";;
3550 ReliantUNIX*) LINKFORSHARED="-W1 -Blargedynsym";;
3551 FreeBSD*|NetBSD*|OpenBSD*|DragonFly*)
3552 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
3554 LINKFORSHARED="-Wl,--export-dynamic"
3556 SunOS/5*) case $CC in
3558 if $CC -Xlinker --help 2>&1 | grep export-dynamic >/dev/null
3560 LINKFORSHARED="-Xlinker --export-dynamic"
3564 if test $enable_shared = "no"
3566 LINKFORSHARED='-Wl,--out-implib=$(LDLIBRARY)'
3569 # -Wl,-E causes the symbols to be added to the dynamic
3570 # symbol table so that they can be found when a module
3571 # is loaded. -N 2048K causes the stack size to be set
3572 # to 2048 kilobytes so that the stack doesn't overflow
3573 # when running test_compile.py.
3574 LINKFORSHARED='-Wl,-E -N 2048K';;
3576 LINKFORSHARED='-Wl,-export-dynamic';;
3579 AC_MSG_RESULT([$LINKFORSHARED])
3582 AC_SUBST([CFLAGSFORSHARED])
3583 AC_MSG_CHECKING([CFLAGSFORSHARED])
3584 if test ! "$LIBRARY" = "$LDLIBRARY"
3586 case $ac_sys_system in
3588 # Cygwin needs CCSHARED when building extension DLLs
3589 # but not when building the interpreter DLL.
3590 CFLAGSFORSHARED='';;
3592 CFLAGSFORSHARED='$(CCSHARED)'
3596 dnl WASM dynamic linking requires -fPIC.
3597 AS_VAR_IF([enable_wasm_dynamic_linking], [yes], [
3598 CFLAGSFORSHARED='$(CCSHARED)'
3601 AC_MSG_RESULT([$CFLAGSFORSHARED])
3603 # SHLIBS are libraries (except -lc and -lm) to link to the python shared
3604 # library (with --enable-shared).
3605 # For platforms on which shared libraries are not allowed to have unresolved
3606 # symbols, this must be set to $(LIBS) (expanded by make). We do this even
3607 # if it is not required, since it creates a dependency of the shared library
3608 # to LIBS. This, in turn, means that applications linking the shared libpython
3609 # don't need to link LIBS explicitly. The default should be only changed
3610 # on systems where this approach causes problems.
3612 AC_MSG_CHECKING([SHLIBS])
3613 case "$ac_sys_system" in
3617 AC_MSG_RESULT([$SHLIBS])
3619 dnl perf trampoline is Linux specific and requires an arch-specific
3620 dnl trampoline in asssembly.
3621 AC_MSG_CHECKING([perf trampoline])
3622 AS_CASE([$PLATFORM_TRIPLET],
3623 [x86_64-linux-gnu], [perf_trampoline=yes],
3624 [aarch64-linux-gnu], [perf_trampoline=yes],
3625 [perf_trampoline=no]
3627 AC_MSG_RESULT([$perf_trampoline])
3629 AS_VAR_IF([perf_trampoline], [yes], [
3630 AC_DEFINE([PY_HAVE_PERF_TRAMPOLINE], [1], [Define to 1 if you have the perf trampoline.])
3631 PERF_TRAMPOLINE_OBJ=Python/asm_trampoline.o
3633 dnl perf needs frame pointers for unwinding, include compiler option in debug builds
3634 AS_VAR_IF([Py_DEBUG], [true], [
3635 AS_VAR_APPEND([BASECFLAGS], [" -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer"])
3638 AC_SUBST([PERF_TRAMPOLINE_OBJ])
3640 # checks for libraries
3641 AC_CHECK_LIB([sendfile], [sendfile])
3642 AC_CHECK_LIB([dl], [dlopen]) # Dynamic linking for SunOS/Solaris and SYSV
3643 AC_CHECK_LIB([dld], [shl_load]) # Dynamic linking for HP-UX
3646 dnl check for uuid dependencies
3647 AH_TEMPLATE([HAVE_UUID_H], [Define to 1 if you have the <uuid.h> header file.])
3648 AH_TEMPLATE([HAVE_UUID_UUID_H], [Define to 1 if you have the <uuid/uuid.h> header file.])
3649 AH_TEMPLATE([HAVE_UUID_GENERATE_TIME_SAFE], [Define if uuid_generate_time_safe() exists.])
3652 dnl AIX provides support for RFC4122 (uuid) in libc.a starting with AIX 6.1
3653 dnl (anno 2007). FreeBSD and OpenBSD provides support in libc as well.
3654 dnl Little-endian FreeBSD, OpenBSD and NetBSD needs encoding into an octet
3655 dnl stream in big-endian byte-order
3656 AC_CHECK_HEADERS([uuid.h],
3657 [AC_CHECK_FUNCS([uuid_create uuid_enc_be],
3659 LIBUUID_CFLAGS=${LIBUUID_CFLAGS-""}
3660 LIBUUID_LIBS=${LIBUUID_LIBS-""}
3664 AS_VAR_IF([have_uuid], [missing], [
3666 [LIBUUID], [uuid >= 2.20],
3667 [dnl linux-util's libuuid has uuid_generate_time_safe() since v2.20 (2011)
3668 dnl and provides <uuid.h>.
3670 AC_DEFINE([HAVE_UUID_H], [1])
3671 AC_DEFINE([HAVE_UUID_GENERATE_TIME_SAFE], [1])
3674 CPPFLAGS="$CPPFLAGS $LIBUUID_CFLAGS"
3675 LDFLAGS="$LDFLAGS $LIBUUID_LIBS"
3676 AC_CHECK_HEADERS([uuid/uuid.h], [
3677 PY_CHECK_LIB([uuid], [uuid_generate_time], [have_uuid=yes])
3678 PY_CHECK_LIB([uuid], [uuid_generate_time_safe],
3680 AC_DEFINE([HAVE_UUID_GENERATE_TIME_SAFE], [1]) ]) ])
3681 AS_VAR_IF([have_uuid], [yes], [
3682 LIBUUID_CFLAGS=${LIBUUID_CFLAGS-""}
3683 LIBUUID_LIBS=${LIBUUID_LIBS-"-luuid"}
3690 dnl macOS has uuid/uuid.h but uuid_generate_time is in libc
3691 AS_VAR_IF([have_uuid], [missing], [
3692 AC_CHECK_HEADERS([uuid/uuid.h], [
3693 AC_CHECK_FUNC([uuid_generate_time], [
3695 LIBUUID_CFLAGS=${LIBUUID_CFLAGS-""}
3696 LIBUUID_LIBS=${LIBUUID_LIBS-""}
3701 AS_VAR_IF([have_uuid], [missing], [have_uuid=no])
3703 # 'Real Time' functions on Solaris
3704 # posix4 on Solaris 2.6
3705 # pthread (first!) on Linux
3706 AC_SEARCH_LIBS([sem_init], [pthread rt posix4])
3708 # check if we need libintl for locale functions
3709 AC_CHECK_LIB([intl], [textdomain],
3710 [AC_DEFINE([WITH_LIBINTL], [1],
3711 [Define to 1 if libintl is needed for locale functions.])
3712 LIBS="-lintl $LIBS"])
3714 # checks for system dependent C++ extensions support
3715 case "$ac_sys_system" in
3716 AIX*) AC_MSG_CHECKING([for genuine AIX C++ extensions support])
3718 AC_LANG_PROGRAM([[@%:@include <load.h>]],
3719 [[loadAndInit("", 0, "")]])
3721 AC_DEFINE([AIX_GENUINE_CPLUSPLUS], [1],
3722 [Define for AIX if your compiler is a genuine IBM xlC/xlC_r
3723 and you want support for AIX C++ shared extension modules.])
3724 AC_MSG_RESULT([yes])
3728 dnl The AIX_BUILDDATE is obtained from the kernel fileset - bos.mp64
3729 # BUILD_GNU_TYPE + AIX_BUILDDATE are used to construct the platform_tag
3730 # of the AIX system used to build/package Python executable. This tag serves
3731 # as a baseline for bdist module packages
3732 AC_MSG_CHECKING([for the system builddate])
3733 AIX_BUILDDATE=$(lslpp -Lcq bos.mp64 | awk -F: '{ print $NF }')
3734 AC_DEFINE_UNQUOTED([AIX_BUILDDATE], [$AIX_BUILDDATE],
3735 [BUILD_GNU_TYPE + AIX_BUILDDATE are used to construct the PEP425 tag of the build system.])
3736 AC_MSG_RESULT([$AIX_BUILDDATE])
3741 # check for systems that require aligned memory access
3742 AC_CACHE_CHECK([aligned memory access is required], [ac_cv_aligned_required],
3743 [AC_RUN_IFELSE([AC_LANG_SOURCE([[
3748 for (i=0; i < 16; i++)
3756 [ac_cv_aligned_required=no],
3757 [ac_cv_aligned_required=yes],
3759 # "yes" changes the hash function to FNV, which causes problems with Numba
3760 # (https://github.com/numba/numba/blob/0.59.0/numba/cpython/hashing.py#L470).
3761 if test "$ac_sys_system" = "Linux-android"; then
3762 ac_cv_aligned_required=no
3764 ac_cv_aligned_required=yes
3767 if test "$ac_cv_aligned_required" = yes ; then
3768 AC_DEFINE([HAVE_ALIGNED_REQUIRED], [1],
3769 [Define if aligned memory access is required])
3772 # str, bytes and memoryview hash algorithm
3773 AH_TEMPLATE([Py_HASH_ALGORITHM],
3774 [Define hash algorithm for str, bytes and memoryview.
3775 SipHash24: 1, FNV: 2, SipHash13: 3, externally defined: 0])
3777 AC_MSG_CHECKING([for --with-hash-algorithm])
3778 dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
3782 [--with-hash-algorithm=@<:@fnv|siphash13|siphash24@:>@],
3783 [select hash algorithm for use in Python/pyhash.c (default is SipHash13)]
3786 AC_MSG_RESULT([$withval])
3789 AC_DEFINE([Py_HASH_ALGORITHM], [3])
3792 AC_DEFINE([Py_HASH_ALGORITHM], [1])
3795 AC_DEFINE([Py_HASH_ALGORITHM], [2])
3798 AC_MSG_ERROR([unknown hash algorithm '$withval'])
3802 [AC_MSG_RESULT([default])])
3805 # Checks that each element of the path is an absolute path
3806 if test -z "$1"; then
3807 # Empty string is allowed: it indicates no system TZPATH
3811 # Bad paths are those that don't start with /
3812 dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
3813 if ( echo $1 | grep '\(^\|:\)\(@<:@^/@:>@\|$\)' > /dev/null); then
3814 AC_MSG_ERROR([--with-tzpath must contain only absolute paths, not $1])
3819 TZPATH="/usr/share/zoneinfo:/usr/lib/zoneinfo:/usr/share/lib/zoneinfo:/etc/zoneinfo"
3820 AC_MSG_CHECKING([for --with-tzpath])
3824 [--with-tzpath=<list of absolute paths separated by pathsep>],
3825 [Select the default time zone search path for zoneinfo.TZPATH]
3830 AC_MSG_ERROR([--with-tzpath requires a value])
3833 validate_tzpath "$withval"
3835 AC_MSG_RESULT(["$withval"])
3839 [validate_tzpath "$TZPATH"
3840 AC_MSG_RESULT(["$TZPATH"])])
3843 # Most SVR4 platforms (e.g. Solaris) need -lsocket and -lnsl.
3844 AC_CHECK_LIB([nsl], [t_open], [LIBS="-lnsl $LIBS"]) # SVR4
3845 AC_CHECK_LIB([socket], [socket], [LIBS="-lsocket $LIBS"], [], $LIBS) # SVR4 sockets
3847 case $ac_sys_system/$ac_sys_release in
3849 AC_CHECK_LIB([network], [socket], [LIBS="-lnetwork $LIBS"], [], [$LIBS])
3853 AC_MSG_CHECKING([for --with-libs])
3857 [--with-libs='lib1 ...'],
3858 [link against additional libs (default is no)]
3861 AC_MSG_RESULT([$withval])
3862 LIBS="$withval $LIBS"
3864 [AC_MSG_RESULT([no])])
3866 # Check for use of the system expat library
3867 AC_MSG_CHECKING([for --with-system-expat])
3871 [--with-system-expat],
3872 [build pyexpat module using an installed expat library, see Doc/library/pyexpat.rst (default is no)]
3873 )], [], [with_system_expat="no"])
3875 AC_MSG_RESULT([$with_system_expat])
3877 AS_VAR_IF([with_system_expat], [yes], [
3878 LIBEXPAT_CFLAGS=${LIBEXPAT_CFLAGS-""}
3879 LIBEXPAT_LDFLAGS=${LIBEXPAT_LDFLAGS-"-lexpat"}
3882 LIBEXPAT_CFLAGS="-I\$(srcdir)/Modules/expat"
3883 LIBEXPAT_LDFLAGS="-lm \$(LIBEXPAT_A)"
3884 LIBEXPAT_INTERNAL="\$(LIBEXPAT_HEADERS) \$(LIBEXPAT_A)"
3887 AC_SUBST([LIBEXPAT_CFLAGS])
3888 AC_SUBST([LIBEXPAT_INTERNAL])
3892 AS_VAR_IF([ac_sys_system], [Darwin], [
3894 CFLAGS="-I${SDKROOT}/usr/include/ffi $CFLAGS"
3895 AC_CHECK_HEADER([ffi.h], [
3896 AC_CHECK_LIB([ffi], [ffi_call], [
3897 dnl use ffi from SDK root
3899 LIBFFI_CFLAGS="-I${SDKROOT}/usr/include/ffi -DUSING_APPLE_OS_LIBFFI=1"
3905 AS_VAR_IF([have_libffi], [missing], [
3906 PKG_CHECK_MODULES([LIBFFI], [libffi], [have_libffi=yes], [
3908 CPPFLAGS="$CPPFLAGS $LIBFFI_CFLAGS"
3909 LDFLAGS="$LDFLAGS $LIBFFI_LIBS"
3910 AC_CHECK_HEADER([ffi.h], [
3911 AC_CHECK_LIB([ffi], [ffi_call], [
3913 LIBFFI_CFLAGS=${LIBFFI_CFLAGS-""}
3914 LIBFFI_LIBS=${LIBFFI_LIBS-"-lffi"}
3915 ], [have_libffi=no])
3921 AS_VAR_IF([have_libffi], [yes], [
3922 ctypes_malloc_closure=no
3923 AS_CASE([$ac_sys_system],
3925 dnl when do we need USING_APPLE_OS_LIBFFI?
3926 ctypes_malloc_closure=yes
3929 ctypes_malloc_closure=yes
3931 [sunos5], [AS_VAR_APPEND([LIBFFI_LIBS], [" -mimpure-text"])]
3933 AS_VAR_IF([ctypes_malloc_closure], [yes], [
3934 MODULE__CTYPES_MALLOC_CLOSURE=_ctypes/malloc_closure.c
3935 AS_VAR_APPEND([LIBFFI_CFLAGS], [" -DUSING_MALLOC_CLOSURE_DOT_C=1"])
3937 AC_SUBST([MODULE__CTYPES_MALLOC_CLOSURE])
3939 dnl HAVE_LIBDL: for dlopen, see gh-76828
3940 AS_VAR_IF([ac_cv_lib_dl_dlopen], [yes], [AS_VAR_APPEND([LIBFFI_LIBS], [" -ldl"])])
3943 CFLAGS="$LIBFFI_CFLAGS $CFLAGS"
3944 LDFLAGS="$LIBFFI_LIBS $LDFLAGS"
3946 PY_CHECK_FUNC([ffi_prep_cif_var], [@%:@include <ffi.h>])
3947 PY_CHECK_FUNC([ffi_prep_closure_loc], [@%:@include <ffi.h>])
3948 PY_CHECK_FUNC([ffi_closure_alloc], [@%:@include <ffi.h>])
3952 # Check for use of the system libmpdec library
3953 AC_MSG_CHECKING([for --with-system-libmpdec])
3957 [--with-system-libmpdec],
3958 [build _decimal module using an installed libmpdec library, see Doc/library/decimal.rst (default is no)]
3961 [with_system_libmpdec="no"])
3962 AC_MSG_RESULT([$with_system_libmpdec])
3964 AS_VAR_IF([with_system_libmpdec], [yes], [
3965 LIBMPDEC_CFLAGS=${LIBMPDEC_CFLAGS-""}
3966 LIBMPDEC_LDFLAGS=${LIBMPDEC_LDFLAGS-"-lmpdec"}
3969 LIBMPDEC_CFLAGS="-I\$(srcdir)/Modules/_decimal/libmpdec"
3970 LIBMPDEC_LDFLAGS="-lm \$(LIBMPDEC_A)"
3971 LIBMPDEC_INTERNAL="\$(LIBMPDEC_HEADERS) \$(LIBMPDEC_A)"
3973 dnl Disable forced inlining in debug builds, see GH-94847
3974 AS_VAR_IF([with_pydebug], [yes], [
3975 AS_VAR_APPEND([LIBMPDEC_CFLAGS], [" -DTEST_COVERAGE"])
3979 AC_SUBST([LIBMPDEC_CFLAGS])
3980 AC_SUBST([LIBMPDEC_INTERNAL])
3982 # Check whether _decimal should use a coroutine-local or thread-local context
3983 AC_MSG_CHECKING([for --with-decimal-contextvar])
3985 [decimal_contextvar],
3987 [--with-decimal-contextvar],
3988 [build _decimal module using a coroutine-local rather than a thread-local context (default is yes)]
3991 [with_decimal_contextvar="yes"])
3993 if test "$with_decimal_contextvar" != "no"
3995 AC_DEFINE([WITH_DECIMAL_CONTEXTVAR], [1],
3996 [Define if you want build the _decimal module using a coroutine-local rather than a thread-local context])
3999 AC_MSG_RESULT([$with_decimal_contextvar])
4001 # Check for libmpdec machine flavor
4002 AC_MSG_CHECKING([for decimal libmpdec machine])
4003 AS_CASE([$ac_sys_system],
4004 [Darwin*], [libmpdec_system=Darwin],
4005 [SunOS*], [libmpdec_system=sunos],
4006 [libmpdec_system=other]
4009 libmpdec_machine=unknown
4010 if test "$libmpdec_system" = Darwin; then
4011 # universal here means: build libmpdec with the same arch options
4012 # the python interpreter was built with
4013 libmpdec_machine=universal
4014 elif test $ac_cv_sizeof_size_t -eq 8; then
4015 if test "$ac_cv_gcc_asm_for_x64" = yes; then
4016 libmpdec_machine=x64
4017 elif test "$ac_cv_type___uint128_t" = yes; then
4018 libmpdec_machine=uint128
4020 libmpdec_machine=ansi64
4022 elif test $ac_cv_sizeof_size_t -eq 4; then
4023 if test "$ac_cv_gcc_asm_for_x87" = yes -a "$libmpdec_system" != sunos; then
4025 [*gcc*], [libmpdec_machine=ppro],
4026 [*clang*], [libmpdec_machine=ppro],
4027 [libmpdec_machine=ansi32]
4030 libmpdec_machine=ansi32
4033 AC_MSG_RESULT([$libmpdec_machine])
4035 AS_CASE([$libmpdec_machine],
4036 [x64], [AS_VAR_APPEND([LIBMPDEC_CFLAGS], [" -DCONFIG_64=1 -DASM=1"])],
4037 [uint128], [AS_VAR_APPEND([LIBMPDEC_CFLAGS], [" -DCONFIG_64=1 -DANSI=1 -DHAVE_UINT128_T=1"])],
4038 [ansi64], [AS_VAR_APPEND([LIBMPDEC_CFLAGS], [" -DCONFIG_64=1 -DANSI=1"])],
4039 [ppro], [AS_VAR_APPEND([LIBMPDEC_CFLAGS], [" -DCONFIG_32=1 -DANSI=1 -DASM=1 -Wno-unknown-pragmas"])],
4040 [ansi32], [AS_VAR_APPEND([LIBMPDEC_CFLAGS], [" -DCONFIG_32=1 -DANSI=1"])],
4041 [ansi-legacy], [AS_VAR_APPEND([LIBMPDEC_CFLAGS], [" -DCONFIG_32=1 -DANSI=1 -DLEGACY_COMPILER=1"])],
4042 [universal], [AS_VAR_APPEND([LIBMPDEC_CFLAGS], [" -DUNIVERSAL=1"])],
4043 [AC_MSG_ERROR([_decimal: unsupported architecture])]
4046 if test "$have_ipa_pure_const_bug" = yes; then
4047 # Some versions of gcc miscompile inline asm:
4048 # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=46491
4049 # https://gcc.gnu.org/ml/gcc/2010-11/msg00366.html
4050 AS_VAR_APPEND([LIBMPDEC_CFLAGS], [" -fno-ipa-pure-const"])
4053 if test "$have_glibc_memmove_bug" = yes; then
4054 # _FORTIFY_SOURCE wrappers for memmove and bcopy are incorrect:
4055 # https://sourceware.org/ml/libc-alpha/2010-12/msg00009.html
4056 AS_VAR_APPEND([LIBMPDEC_CFLAGS], [" -U_FORTIFY_SOURCE"])
4060 dnl detect sqlite3 from Emscripten emport
4061 PY_CHECK_EMSCRIPTEN_PORT([LIBSQLITE3], [-sUSE_SQLITE3])
4063 dnl Check for SQLite library. Use pkg-config if available.
4065 [LIBSQLITE3], [sqlite3 >= 3.15.2], [], [
4066 LIBSQLITE3_CFLAGS=${LIBSQLITE3_CFLAGS-""}
4067 LIBSQLITE3_LIBS=${LIBSQLITE3_LIBS-"-lsqlite3"}
4070 AS_VAR_APPEND([LIBSQLITE3_CFLAGS], [' -I$(srcdir)/Modules/_sqlite'])
4072 dnl PY_CHECK_SQLITE_FUNC(FUNCTION, IF-FOUND, IF-NOT-FOUND)
4073 AC_DEFUN([PY_CHECK_SQLITE_FUNC], [
4074 AC_CHECK_LIB([sqlite3], [$1], [$2], [
4075 m4_ifblank([$3], [have_supported_sqlite3=no], [$3])
4080 dnl bpo-45774/GH-29507: The CPP check in AC_CHECK_HEADER can fail on FreeBSD,
4081 dnl hence CPPFLAGS instead of CFLAGS.
4082 CPPFLAGS="$CPPFLAGS $LIBSQLITE3_CFLAGS"
4083 LDFLAGS="$LIBSQLITE3_LIBS $LDFLAGS"
4085 AC_CHECK_HEADER([sqlite3.h], [
4090 #include <sqlite3.h>
4091 #if SQLITE_VERSION_NUMBER < 3015002
4092 # error "SQLite 3.15.2 or higher required"
4096 have_supported_sqlite3=yes
4097 dnl Check that required functions are in place. A lot of stuff may be
4098 dnl omitted with SQLITE_OMIT_* compile time defines.
4099 PY_CHECK_SQLITE_FUNC([sqlite3_bind_double])
4100 PY_CHECK_SQLITE_FUNC([sqlite3_column_decltype])
4101 PY_CHECK_SQLITE_FUNC([sqlite3_column_double])
4102 PY_CHECK_SQLITE_FUNC([sqlite3_complete])
4103 PY_CHECK_SQLITE_FUNC([sqlite3_progress_handler])
4104 PY_CHECK_SQLITE_FUNC([sqlite3_result_double])
4105 PY_CHECK_SQLITE_FUNC([sqlite3_set_authorizer])
4106 PY_CHECK_SQLITE_FUNC([sqlite3_trace_v2], [], [
4107 PY_CHECK_SQLITE_FUNC([sqlite3_trace])
4109 PY_CHECK_SQLITE_FUNC([sqlite3_value_double])
4110 AC_CHECK_LIB([sqlite3], [sqlite3_load_extension],
4111 [have_sqlite3_load_extension=yes],
4112 [have_sqlite3_load_extension=no]
4114 AC_CHECK_LIB([sqlite3], [sqlite3_serialize], [
4116 [PY_SQLITE_HAVE_SERIALIZE], [1],
4117 [Define if SQLite was compiled with the serialize API]
4121 have_supported_sqlite3=no
4126 dnl Check for support for loadable sqlite extensions
4127 AC_MSG_CHECKING([for --enable-loadable-sqlite-extensions])
4128 AC_ARG_ENABLE([loadable-sqlite-extensions],
4130 [--enable-loadable-sqlite-extensions], [
4131 support loadable extensions in the sqlite3 module, see
4132 Doc/library/sqlite3.rst (default is no)
4135 AS_VAR_IF([have_sqlite3_load_extension], [no], [
4136 AC_MSG_RESULT([n/a])
4137 AC_MSG_WARN([Your version of SQLite does not support loadable extensions])
4139 AC_MSG_RESULT([yes])
4141 [PY_SQLITE_ENABLE_LOAD_EXTENSION], [1],
4142 [Define to 1 to build the sqlite module with loadable extensions support.]
4151 dnl Detect Tcl/Tk. Use pkg-config if available.
4155 "tcl >= 8.5.12 tk >= 8.5.12" \
4158 "tcl8.5 >= 8.5.12 tk8.5 >= 8.5.12" \
4159 "tcl85 >= 8.5.12 tk85 >= 8.5.12" \
4161 PKG_CHECK_EXISTS([$_QUERY], [
4162 PKG_CHECK_MODULES([TCLTK], [$_QUERY], [found_tcltk=yes], [found_tcltk=no])
4164 AS_VAR_IF([found_tcltk], [yes], [break])
4167 AS_VAR_IF([found_tcltk], [no], [
4168 TCLTK_CFLAGS=${TCLTK_CFLAGS-""}
4169 TCLTK_LIBS=${TCLTK_LIBS-""}
4172 dnl FreeBSD has an X11 dependency which is not implicitly resolved.
4173 AS_CASE([$ac_sys_system],
4175 PKG_CHECK_EXISTS([x11], [
4176 PKG_CHECK_MODULES([X11], [x11], [
4177 TCLTK_CFLAGS="$TCLTK_CFLAGS $X11_CFLAGS"
4178 TCLTK_LIBS="$TCLTK_LIBS $X11_LIBS"
4185 CPPFLAGS="$CPPFLAGS $TCLTK_CFLAGS"
4186 LIBS="$TCLTK_LIBS $LDFLAGS"
4192 #if defined(TK_HEX_VERSION)
4193 # if TK_HEX_VERSION < 0x0805020c
4194 # error "Tk older than 8.5.12 not supported"
4197 #if (TCL_MAJOR_VERSION < 8) || \
4198 ((TCL_MAJOR_VERSION == 8) && (TCL_MINOR_VERSION < 5)) || \
4199 ((TCL_MAJOR_VERSION == 8) && (TCL_MINOR_VERSION == 5) && (TCL_RELEASE_SERIAL < 12))
4200 # error "Tcl older than 8.5.12 not supported"
4202 #if (TK_MAJOR_VERSION < 8) || \
4203 ((TK_MAJOR_VERSION == 8) && (TK_MINOR_VERSION < 5)) || \
4204 ((TK_MAJOR_VERSION == 8) && (TK_MINOR_VERSION == 5) && (TK_RELEASE_SERIAL < 12))
4205 # error "Tk older than 8.5.12 not supported"
4208 void *x1 = Tcl_Init;
4213 dnl The X11/xlib.h file bundled in the Tk sources can cause function
4214 dnl prototype warnings from the compiler. Since we cannot easily fix
4215 dnl that, suppress the warnings here instead.
4216 AS_VAR_APPEND([TCLTK_CFLAGS], [" -Wno-strict-prototypes -DWITH_APPINIT=1"])
4222 dnl check for _gdbmmodule dependencies
4223 dnl NOTE: gdbm does not provide a pkgconf file.
4224 AC_ARG_VAR([GDBM_CFLAGS], [C compiler flags for gdbm])
4225 AC_ARG_VAR([GDBM_LIBS], [additional linker flags for gdbm])
4227 CPPFLAGS="$CPPFLAGS $GDBM_CFLAGS"
4228 LDFLAGS="$GDBM_LIBS $LDFLAGS"
4229 AC_CHECK_HEADERS([gdbm.h], [
4230 AC_CHECK_LIB([gdbm], [gdbm_open], [
4232 GDBM_LIBS=${GDBM_LIBS-"-lgdbm"}
4237 dnl check for _dbmmodule.c dependencies
4238 dnl ndbm, gdbm_compat, libdb
4239 AC_CHECK_HEADERS([ndbm.h], [
4241 AC_SEARCH_LIBS([dbm_open], [ndbm gdbm_compat])
4245 AC_MSG_CHECKING([for ndbm presence and linker args])
4246 AS_CASE([$ac_cv_search_dbm_open],
4247 [*ndbm*|*gdbm_compat*], [
4248 dbm_ndbm="$ac_cv_search_dbm_open"
4255 [no], [have_ndbm=no]
4257 AC_MSG_RESULT([$have_ndbm ($dbm_ndbm)])
4259 dnl "gdbm-ndbm.h" and "gdbm/ndbm.h" are both normalized to "gdbm_ndbm_h"
4260 dnl unset ac_cv_header_gdbm_ndbm_h to prevent false positive cache hits.
4261 AS_UNSET([ac_cv_header_gdbm_ndbm_h])
4262 AC_CACHE_VAL([ac_cv_header_gdbm_slash_ndbm_h], [
4265 [ac_cv_header_gdbm_slash_ndbm_h=yes], [ac_cv_header_gdbm_slash_ndbm_h=no]
4268 AS_VAR_IF([ac_cv_header_gdbm_slash_ndbm_h], [yes], [
4269 AC_DEFINE([HAVE_GDBM_NDBM_H], [1], [Define to 1 if you have the <gdbm/ndbm.h> header file.])
4272 AS_UNSET([ac_cv_header_gdbm_ndbm_h])
4273 AC_CACHE_VAL([ac_cv_header_gdbm_dash_ndbm_h], [
4276 [ac_cv_header_gdbm_dash_ndbm_h=yes], [ac_cv_header_gdbm_dash_ndbm_h=no]
4279 AS_VAR_IF([ac_cv_header_gdbm_dash_ndbm_h], [yes], [
4280 AC_DEFINE([HAVE_GDBM_DASH_NDBM_H], [1], [Define to 1 if you have the <gdbm-ndbm.h> header file.])
4282 AS_UNSET([ac_cv_header_gdbm_ndbm_h])
4284 if test "$ac_cv_header_gdbm_slash_ndbm_h" = yes -o "$ac_cv_header_gdbm_dash_ndbm_h" = yes; then
4285 AS_UNSET([ac_cv_search_dbm_open])
4287 AC_SEARCH_LIBS([dbm_open], [gdbm_compat], [have_gdbm_compat=yes], [have_gdbm_compat=no])
4291 # Check for libdb >= 5 with dbm_open()
4292 # db.h re-defines the name of the function
4293 AC_CHECK_HEADERS([db.h], [
4294 AC_CACHE_CHECK([for libdb], [ac_cv_have_libdb], [
4297 AC_LINK_IFELSE([AC_LANG_PROGRAM([
4298 #define DB_DBM_HSEARCH 1
4300 #if DB_VERSION_MAJOR < 5
4301 #error "dh.h: DB_VERSION_MAJOR < 5 is not supported."
4303 ], [DBM *dbm = dbm_open(NULL, 0, 0)])
4304 ], [ac_cv_have_libdb=yes], [ac_cv_have_libdb=no])
4307 AS_VAR_IF([ac_cv_have_libdb], [yes], [
4308 AC_DEFINE([HAVE_LIBDB], [1], [Define to 1 if you have the `db' library (-ldb).])
4312 # Check for --with-dbmliborder
4313 AC_MSG_CHECKING([for --with-dbmliborder])
4317 [--with-dbmliborder=db1:db2:...],
4318 [override order to check db backends for dbm; a valid value is a colon separated string with the backend names `ndbm', `gdbm' and `bdb'.]
4320 [], [with_dbmliborder=gdbm:ndbm:bdb])
4322 have_gdbm_dbmliborder=no
4325 for db in $with_dbmliborder; do
4328 [gdbm], [have_gdbm_dbmliborder=yes],
4330 [with_dbmliborder=error]
4334 AS_VAR_IF([with_dbmliborder], [error], [
4335 AC_MSG_ERROR([proper usage is --with-dbmliborder=db1:db2:... (gdbm:ndbm:bdb)])
4337 AC_MSG_RESULT([$with_dbmliborder])
4339 AC_MSG_CHECKING([for _dbm module CFLAGS and LIBS])
4343 for db in $with_dbmliborder; do
4346 if test "$have_ndbm" = yes; then
4347 DBM_CFLAGS="-DUSE_NDBM"
4348 DBM_LIBS="$dbm_ndbm"
4354 if test "$have_gdbm_compat" = yes; then
4355 DBM_CFLAGS="-DUSE_GDBM_COMPAT"
4356 DBM_LIBS="-lgdbm_compat"
4362 if test "$ac_cv_have_libdb" = yes; then
4363 DBM_CFLAGS="-DUSE_BERKDB"
4372 AC_MSG_RESULT([$DBM_CFLAGS $DBM_LIBS])
4374 # Templates for things AC_DEFINEd more than once.
4375 # For a single AC_DEFINE, no template is needed.
4376 AH_TEMPLATE([_REENTRANT],
4377 [Define to force use of thread-safe errno, h_errno, and other functions])
4379 if test "$ac_cv_pthread_is_default" = yes
4381 # Defining _REENTRANT on system with POSIX threads should not hurt.
4382 AC_DEFINE([_REENTRANT])
4384 if test "$ac_sys_system" = "SunOS"; then
4385 CFLAGS="$CFLAGS -D_REENTRANT"
4387 elif test "$ac_cv_kpthread" = "yes"
4390 if test "$ac_cv_cxx_thread" = "yes"; then
4391 CXX="$CXX -Kpthread"
4394 elif test "$ac_cv_kthread" = "yes"
4397 if test "$ac_cv_cxx_thread" = "yes"; then
4401 elif test "$ac_cv_pthread" = "yes"
4404 if test "$ac_cv_cxx_thread" = "yes"; then
4409 if test ! -z "$withval" -a -d "$withval"
4410 then LDFLAGS="$LDFLAGS -L$withval"
4413 # According to the POSIX spec, a pthreads implementation must
4414 # define _POSIX_THREADS in unistd.h. Some apparently don't
4415 # (e.g. gnu pth with pthread emulation)
4416 AC_MSG_CHECKING([for _POSIX_THREADS in unistd.h])
4417 AX_CHECK_DEFINE([unistd.h], [_POSIX_THREADS],
4418 [unistd_defines_pthreads=yes],
4419 [unistd_defines_pthreads=no])
4420 AC_MSG_RESULT([$unistd_defines_pthreads])
4422 AC_DEFINE([_REENTRANT])
4423 # Just looking for pthread_create in libpthread is not enough:
4424 # on HP/UX, pthread.h renames pthread_create to a different symbol name.
4425 # So we really have to include pthread.h, and then link.
4427 LIBS="$LIBS -lpthread"
4428 AC_MSG_CHECKING([for pthread_create in -lpthread])
4429 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
4432 #include <pthread.h>
4434 void * start_routine (void *arg) { exit (0); }]], [[
4435 pthread_create (NULL, NULL, start_routine, NULL)]])],[
4436 AC_MSG_RESULT([yes])
4440 AC_CHECK_FUNC([pthread_detach], [
4443 AC_CHECK_LIB([pthreads], [pthread_create], [
4445 LIBS="$LIBS -lpthreads"
4447 AC_CHECK_LIB([c_r], [pthread_create], [
4451 AC_CHECK_LIB([pthread], [__pthread_create_system], [
4453 LIBS="$LIBS -lpthread"
4455 AC_CHECK_LIB([cma], [pthread_create], [
4459 AS_CASE([$ac_sys_system],
4460 [WASI], [posix_threads=stub],
4461 [AC_MSG_ERROR([could not find pthreads on your system])]
4465 AC_CHECK_LIB([mpc], [usconfig], [
4471 if test "$posix_threads" = "yes"; then
4472 if test "$unistd_defines_pthreads" = "no"; then
4473 AC_DEFINE([_POSIX_THREADS], [1],
4474 [Define if you have POSIX threads,
4475 and your system does not define that.])
4478 # Bug 662787: Using semaphores causes unexplicable hangs on Solaris 8.
4479 case $ac_sys_system/$ac_sys_release in
4480 SunOS/5.6) AC_DEFINE([HAVE_PTHREAD_DESTRUCTOR], [1],
4481 [Defined for Solaris 2.6 bug in pthread header.])
4483 SunOS/5.8) AC_DEFINE([HAVE_BROKEN_POSIX_SEMAPHORES], [1],
4484 [Define if the Posix semaphores do not work on your system])
4486 AIX/*) AC_DEFINE([HAVE_BROKEN_POSIX_SEMAPHORES], [1],
4487 [Define if the Posix semaphores do not work on your system])
4489 NetBSD/*) AC_DEFINE([HAVE_BROKEN_POSIX_SEMAPHORES], [1],
4490 [Define if the Posix semaphores do not work on your system])
4494 AC_CACHE_CHECK([if PTHREAD_SCOPE_SYSTEM is supported], [ac_cv_pthread_system_supported],
4495 [AC_RUN_IFELSE([AC_LANG_SOURCE([[
4497 #include <pthread.h>
4498 void *foo(void *parm) {
4502 pthread_attr_t attr;
4504 if (pthread_attr_init(&attr)) return (-1);
4505 if (pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM)) return (-1);
4506 if (pthread_create(&id, &attr, foo, NULL)) return (-1);
4509 [ac_cv_pthread_system_supported=yes],
4510 [ac_cv_pthread_system_supported=no],
4511 [ac_cv_pthread_system_supported=no])
4513 if test "$ac_cv_pthread_system_supported" = "yes"; then
4514 AC_DEFINE([PTHREAD_SYSTEM_SCHED_SUPPORTED], [1],
4515 [Defined if PTHREAD_SCOPE_SYSTEM supported.])
4517 AC_CHECK_FUNCS([pthread_sigmask],
4518 [case $ac_sys_system in
4520 AC_DEFINE([HAVE_BROKEN_PTHREAD_SIGMASK], [1],
4521 [Define if pthread_sigmask() does not work on your system.])
4524 AC_CHECK_FUNCS([pthread_getcpuclockid])
4527 AS_VAR_IF([posix_threads], [stub], [
4528 AC_DEFINE([HAVE_PTHREAD_STUBS], [1], [Define if platform requires stubbed pthreads support])
4531 # Check for enable-ipv6
4532 AH_TEMPLATE([ENABLE_IPV6], [Define if --enable-ipv6 is specified])
4533 AC_MSG_CHECKING([if --enable-ipv6 is specified])
4534 AC_ARG_ENABLE([ipv6],
4537 [enable ipv6 (with ipv4) support, see Doc/library/socket.rst (default is yes if supported)]
4539 [ case "$enableval" in
4544 *) AC_MSG_RESULT([yes])
4545 AC_DEFINE([ENABLE_IPV6])
4551 dnl the check does not work on cross compilation case...
4552 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ /* AF_INET6 available check */
4553 #include <sys/types.h>
4554 @%:@include <sys/socket.h>]],
4555 [[int domain = AF_INET6;]])],[
4561 AS_CASE([$ac_sys_system],
4565 AC_MSG_RESULT([$ipv6])
4567 if test "$ipv6" = "yes"; then
4568 AC_MSG_CHECKING([if RFC2553 API is available])
4570 AC_LANG_PROGRAM([[#include <sys/types.h>
4571 @%:@include <netinet/in.h>]],
4572 [[struct sockaddr_in6 x;
4575 AC_MSG_RESULT([yes])
4578 AC_MSG_RESULT([no], [IPv6 disabled])
4583 if test "$ipv6" = "yes"; then
4584 AC_DEFINE([ENABLE_IPV6])
4592 if test "$ipv6" = yes -a "$cross_compiling" = no; then
4593 for i in inria kame linux-glibc linux-inet6 solaris toshiba v6d zeta;
4597 dnl http://www.kame.net/
4598 AX_CHECK_DEFINE([netinet/in.h], [IPV6_INRIA_VERSION], [ipv6type=$i])
4601 dnl http://www.kame.net/
4602 AX_CHECK_DEFINE([netinet/in.h], [__KAME__],
4605 ipv6libdir=/usr/local/v6/lib
4609 dnl Advanced IPv6 support was added to glibc 2.1 in 1999.
4610 AX_CHECK_DEFINE([features.h], [__GLIBC__],
4615 dnl http://www.v6.linux.or.jp/
4616 if test -d /usr/inet6; then
4619 ipv6libdir=/usr/inet6/lib
4620 BASECFLAGS="-I/usr/inet6/include $BASECFLAGS"
4624 if test -f /etc/netconfig; then
4625 if $GREP -q tcp6 /etc/netconfig; then
4632 AX_CHECK_DEFINE([sys/param.h], [_TOSHIBA_INET6],
4635 ipv6libdir=/usr/local/v6/lib])
4638 AX_CHECK_DEFINE([/usr/local/v6/include/sys/v6config.h], [__V6D__],
4641 ipv6libdir=/usr/local/v6/lib
4642 BASECFLAGS="-I/usr/local/v6/include $BASECFLAGS"])
4645 AX_CHECK_DEFINE([sys/param.h], [_ZETA_MINAMI_INET6],
4648 ipv6libdir=/usr/local/v6/lib])
4651 if test "$ipv6type" != "unknown"; then
4655 AC_MSG_CHECKING([ipv6 stack type])
4656 AC_MSG_RESULT([$ipv6type])
4659 if test "$ipv6" = "yes" -a "$ipv6lib" != "none"; then
4660 AC_MSG_CHECKING([ipv6 library])
4661 if test -d $ipv6libdir -a -f $ipv6libdir/lib$ipv6lib.a; then
4662 LIBS="-L$ipv6libdir -l$ipv6lib $LIBS"
4663 AC_MSG_RESULT([lib$ipv6lib])
4665 AS_VAR_IF([ipv6trylibc], [yes], [
4666 AC_MSG_RESULT([libc])
4668 AC_MSG_ERROR([m4_normalize([
4669 No $ipv6lib library found; cannot continue.
4670 You need to fetch lib$ipv6lib.a from appropriate
4671 ipv6 kit and compile beforehand.
4678 AC_CACHE_CHECK([CAN_RAW_FD_FRAMES], [ac_cv_can_raw_fd_frames], [
4679 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ /* CAN_RAW_FD_FRAMES available check */
4680 @%:@include <linux/can/raw.h>]],
4681 [[int can_raw_fd_frames = CAN_RAW_FD_FRAMES;]])],
4682 [ac_cv_can_raw_fd_frames=yes],
4683 [ac_cv_can_raw_fd_frames=no])
4685 AS_VAR_IF([ac_cv_can_raw_fd_frames], [yes], [
4686 AC_DEFINE([HAVE_LINUX_CAN_RAW_FD_FRAMES], [1],
4687 [Define if compiling using Linux 3.6 or later.])
4690 AC_CACHE_CHECK([for CAN_RAW_JOIN_FILTERS], [ac_cv_can_raw_join_filters], [
4691 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4692 @%:@include <linux/can/raw.h>]],
4693 [[int can_raw_join_filters = CAN_RAW_JOIN_FILTERS;]])],
4694 [ac_cv_can_raw_join_filters=yes],
4695 [ac_cv_can_raw_join_filters=no])
4697 AS_VAR_IF([ac_cv_can_raw_join_filters], [yes], [
4698 AC_DEFINE([HAVE_LINUX_CAN_RAW_JOIN_FILTERS], [1],
4699 [Define if compiling using Linux 4.1 or later.])
4702 # Check for --with-doc-strings
4703 AC_MSG_CHECKING([for --with-doc-strings])
4706 [AS_HELP_STRING([--with-doc-strings], [enable documentation strings (default is yes)])])
4708 if test -z "$with_doc_strings"
4709 then with_doc_strings="yes"
4711 if test "$with_doc_strings" != "no"
4713 AC_DEFINE([WITH_DOC_STRINGS], [1],
4714 [Define if you want documentation strings in extension modules])
4716 AC_MSG_RESULT([$with_doc_strings])
4718 # Check for stdatomic.h, required for mimalloc.
4719 AC_CACHE_CHECK([for stdatomic.h], [ac_cv_header_stdatomic_h], [
4723 #include <stdatomic.h>
4725 atomic_uintptr_t uintptr_var;
4727 atomic_store_explicit(&int_var, 5, memory_order_relaxed);
4728 atomic_store_explicit(&uintptr_var, 0, memory_order_relaxed);
4729 int loaded_value = atomic_load_explicit(&int_var, memory_order_seq_cst);
4733 ],[ac_cv_header_stdatomic_h=yes],[ac_cv_header_stdatomic_h=no])
4736 AS_VAR_IF([ac_cv_header_stdatomic_h], [yes], [
4737 AC_DEFINE(HAVE_STD_ATOMIC, 1,
4738 [Has stdatomic.h with atomic_int and atomic_uintptr_t])
4741 # Check for GCC >= 4.7 and clang __atomic builtin functions
4742 AC_CACHE_CHECK([for builtin __atomic_load_n and __atomic_store_n functions], [ac_cv_builtin_atomic], [
4748 __atomic_store_n(&val, 1, __ATOMIC_SEQ_CST);
4749 (void)__atomic_load_n(&val, __ATOMIC_SEQ_CST);
4753 ],[ac_cv_builtin_atomic=yes],[ac_cv_builtin_atomic=no])
4756 AS_VAR_IF([ac_cv_builtin_atomic], [yes], [
4757 AC_DEFINE(HAVE_BUILTIN_ATOMIC, 1, [Has builtin __atomic_load_n() and __atomic_store_n() functions])
4761 AC_MSG_CHECKING([for --with-mimalloc])
4762 AC_ARG_WITH([mimalloc],
4763 [AS_HELP_STRING([--with-mimalloc],
4764 [build with mimalloc memory allocator (default is yes if C11 stdatomic.h is available.)])],
4766 [with_mimalloc="$ac_cv_header_stdatomic_h"]
4769 if test "$with_mimalloc" != no; then
4770 if test "$ac_cv_header_stdatomic_h" != yes; then
4771 # mimalloc-atomic.h wants C11 stdatomic.h on POSIX
4772 AC_MSG_ERROR([mimalloc requires stdatomic.h, use --without-mimalloc to disable mimalloc.])
4775 AC_DEFINE([WITH_MIMALLOC], [1], [Define if you want to compile in mimalloc memory allocator.])
4776 AC_SUBST([MIMALLOC_HEADERS], ['$(MIMALLOC_HEADERS)'])
4777 elif test "$disable_gil" = "yes"; then
4778 AC_MSG_ERROR([--disable-gil requires mimalloc memory allocator (--with-mimalloc).])
4781 AC_MSG_RESULT([$with_mimalloc])
4782 AC_SUBST([INSTALL_MIMALLOC], [$with_mimalloc])
4783 AC_SUBST([MIMALLOC_HEADERS])
4785 # Check for Python-specific malloc support
4786 AC_MSG_CHECKING([for --with-pymalloc])
4789 [AS_HELP_STRING([--with-pymalloc], [enable specialized mallocs (default is yes)])])
4791 if test -z "$with_pymalloc"
4793 dnl default to yes except for wasm32-emscripten and wasm32-wasi.
4794 AS_CASE([$ac_sys_system],
4795 [Emscripten], [with_pymalloc="no"],
4796 [WASI], [with_pymalloc="no"],
4797 [with_pymalloc="yes"]
4800 if test "$with_pymalloc" != "no"
4802 AC_DEFINE([WITH_PYMALLOC], [1],
4803 [Define if you want to compile in Python-specific mallocs])
4805 AC_MSG_RESULT([$with_pymalloc])
4807 # Check whether objects such as float, tuple and dict are using
4808 # freelists to optimization memory allocation.
4809 AC_MSG_CHECKING([for --with-freelists])
4812 [AS_HELP_STRING([--with-freelists], [enable object freelists (default is yes)])])
4814 if test -z "$with_freelists"
4816 with_freelists="yes"
4818 if test "$with_freelists" != "no"
4820 AC_DEFINE([WITH_FREELISTS], [1],
4821 [Define if you want to compile in object freelists optimization])
4823 AC_MSG_RESULT([$with_freelists])
4825 # Check for --with-c-locale-coercion
4826 AC_MSG_CHECKING([for --with-c-locale-coercion])
4828 [c-locale-coercion],
4829 [AS_HELP_STRING([--with-c-locale-coercion], [enable C locale coercion to a UTF-8 based locale (default is yes)])])
4831 if test -z "$with_c_locale_coercion"
4833 with_c_locale_coercion="yes"
4835 if test "$with_c_locale_coercion" != "no"
4837 AC_DEFINE([PY_COERCE_C_LOCALE], [1],
4838 [Define if you want to coerce the C locale to a UTF-8 based locale])
4840 AC_MSG_RESULT([$with_c_locale_coercion])
4842 # Check for Valgrind support
4843 AC_MSG_CHECKING([for --with-valgrind])
4846 [AS_HELP_STRING([--with-valgrind], [enable Valgrind support (default is no)])],
4847 [], [with_valgrind=no]
4849 AC_MSG_RESULT([$with_valgrind])
4850 if test "$with_valgrind" != no; then
4851 AC_CHECK_HEADER([valgrind/valgrind.h],
4852 [AC_DEFINE([WITH_VALGRIND], 1, [Define if you want pymalloc to be disabled when running under valgrind])],
4853 [AC_MSG_ERROR([Valgrind support requested but headers not available])]
4855 OPT="-DDYNAMIC_ANNOTATIONS_ENABLED=1 $OPT"
4858 # Check for DTrace support
4859 AC_MSG_CHECKING([for --with-dtrace])
4862 [AS_HELP_STRING([--with-dtrace], [enable DTrace support (default is no)])],
4863 [], [with_dtrace=no])
4864 AC_MSG_RESULT([$with_dtrace])
4868 AC_SUBST([DTRACE_HEADERS])
4869 AC_SUBST([DTRACE_OBJS])
4874 if test "$with_dtrace" = "yes"
4876 AC_PATH_PROG([DTRACE], [dtrace], [not found])
4877 if test "$DTRACE" = "not found"; then
4878 AC_MSG_ERROR([dtrace command not found on \$PATH])
4880 AC_DEFINE([WITH_DTRACE], [1],
4881 [Define if you want to compile in DTrace support])
4882 DTRACE_HEADERS="Include/pydtrace_probes.h"
4884 # On OS X, DTrace providers do not need to be explicitly compiled and
4885 # linked into the binary. Correspondingly, dtrace(1) is missing the ELF
4886 # generation flag '-G'. We check for presence of this flag, rather than
4887 # hardcoding support by OS, in the interest of robustness.
4888 AC_CACHE_CHECK([whether DTrace probes require linking],
4889 [ac_cv_dtrace_link], [dnl
4890 ac_cv_dtrace_link=no
4891 echo 'BEGIN{}' > conftest.d
4892 "$DTRACE" $DFLAGS -G -s conftest.d -o conftest.o > /dev/null 2>&1 && \
4893 ac_cv_dtrace_link=yes
4895 if test "$ac_cv_dtrace_link" = "yes"; then
4896 DTRACE_OBJS="Python/pydtrace.o"
4900 dnl Platform-specific C and header files.
4904 AS_CASE([$ac_sys_system],
4906 AS_VAR_APPEND([PLATFORM_OBJS], [' Python/emscripten_signal.o Python/emscripten_trampoline.o'])
4907 AS_VAR_APPEND([PLATFORM_HEADERS], [' $(srcdir)/Include/internal/pycore_emscripten_signal.h $(srcdir)/Include/internal/pycore_emscripten_trampoline.h'])
4910 AC_SUBST([PLATFORM_HEADERS])
4911 AC_SUBST([PLATFORM_OBJS])
4913 # -I${DLINCLDIR} is added to the compile rule for importdl.o
4914 AC_SUBST([DLINCLDIR])
4917 # the dlopen() function means we might want to use dynload_shlib.o. some
4918 # platforms have dlopen(), but don't want to use it.
4919 AC_CHECK_FUNCS([dlopen])
4921 # DYNLOADFILE specifies which dynload_*.o file we will use for dynamic
4922 # loading of modules.
4923 AC_SUBST([DYNLOADFILE])
4924 AC_MSG_CHECKING([DYNLOADFILE])
4925 if test -z "$DYNLOADFILE"
4927 case $ac_sys_system/$ac_sys_release in
4928 hp*|HP*) DYNLOADFILE="dynload_hpux.o";;
4930 # use dynload_shlib.c and dlopen() if we have it; otherwise stub
4931 # out any dynamic loading
4932 if test "$ac_cv_func_dlopen" = yes
4933 then DYNLOADFILE="dynload_shlib.o"
4934 else DYNLOADFILE="dynload_stub.o"
4939 AC_MSG_RESULT([$DYNLOADFILE])
4940 if test "$DYNLOADFILE" != "dynload_stub.o"
4942 AC_DEFINE([HAVE_DYNAMIC_LOADING], [1],
4943 [Defined when any dynamic module loading is enabled.])
4946 # MACHDEP_OBJS can be set to platform-specific object files needed by Python
4948 AC_SUBST([MACHDEP_OBJS])
4949 AC_MSG_CHECKING([MACHDEP_OBJS])
4950 if test -z "$MACHDEP_OBJS"
4952 MACHDEP_OBJS=$extra_machdep_objs
4954 MACHDEP_OBJS="$MACHDEP_OBJS $extra_machdep_objs"
4956 if test -z "$MACHDEP_OBJS"; then
4957 AC_MSG_RESULT([none])
4959 AC_MSG_RESULT([$MACHDEP_OBJS])
4962 if test "$ac_sys_system" = "Linux-android"; then
4963 # When these functions are used in an unprivileged process, they crash rather
4964 # than returning an error.
4965 blocked_funcs="chroot initgroups setegid seteuid setgid sethostname
4966 setregid setresgid setresuid setreuid setuid"
4968 # These functions are unimplemented and always return an error
4969 # (https://android.googlesource.com/platform/system/sepolicy/+/refs/heads/android13-release/public/domain.te#1044)
4970 blocked_funcs="$blocked_funcs sem_open sem_unlink"
4972 # Before API level 23, when fchmodat is called with the unimplemented flag
4973 # AT_SYMLINK_NOFOLLOW, instead of returning ENOTSUP as it should, it actually
4974 # follows the symlink.
4975 if test "$ANDROID_API_LEVEL" -lt 23; then
4976 blocked_funcs="$blocked_funcs fchmodat"
4979 for name in $blocked_funcs; do
4980 AS_VAR_PUSHDEF([func_var], [ac_cv_func_$name])
4981 AS_VAR_SET([func_var], [no])
4982 AS_VAR_POPDEF([func_var])
4986 # checks for library functions
4988 accept4 alarm bind_textdomain_codeset chmod chown clock closefrom close_range confstr \
4989 copy_file_range ctermid dup dup3 execv explicit_bzero explicit_memset \
4990 faccessat fchmod fchmodat fchown fchownat fdopendir fdwalk fexecve \
4991 fork fork1 fpathconf fstatat ftime ftruncate futimens futimes futimesat \
4992 gai_strerror getegid geteuid getgid getgrent getgrgid getgrgid_r \
4993 getgrnam_r getgrouplist gethostname getitimer getloadavg getlogin \
4994 getpeername getpgid getpid getppid getpriority _getpty \
4995 getpwent getpwnam_r getpwuid getpwuid_r getresgid getresuid getrusage getsid getspent \
4996 getspnam getuid getwd grantpt if_nameindex initgroups kill killpg lchown linkat \
4997 lockf lstat lutimes madvise mbrtowc memrchr mkdirat mkfifo mkfifoat \
4998 mknod mknodat mktime mmap mremap nice openat opendir pathconf pause pipe \
4999 pipe2 plock poll posix_fadvise posix_fallocate posix_openpt posix_spawn posix_spawnp \
5000 posix_spawn_file_actions_addclosefrom_np \
5001 pread preadv preadv2 process_vm_readv pthread_cond_timedwait_relative_np pthread_condattr_setclock pthread_init \
5002 pthread_kill ptsname ptsname_r pwrite pwritev pwritev2 readlink readlinkat readv realpath renameat \
5003 rtpSpawn sched_get_priority_max sched_rr_get_interval sched_setaffinity \
5004 sched_setparam sched_setscheduler sem_clockwait sem_getvalue sem_open \
5005 sem_timedwait sem_unlink sendfile setegid seteuid setgid sethostname \
5006 setitimer setlocale setpgid setpgrp setpriority setregid setresgid \
5007 setresuid setreuid setsid setuid setvbuf shutdown sigaction sigaltstack \
5008 sigfillset siginterrupt sigpending sigrelse sigtimedwait sigwait \
5009 sigwaitinfo snprintf splice strftime strlcpy strsignal symlinkat sync \
5010 sysconf tcgetpgrp tcsetpgrp tempnam timegm times tmpfile \
5011 tmpnam tmpnam_r truncate ttyname umask uname unlinkat unlockpt utimensat utimes vfork \
5012 wait wait3 wait4 waitid waitpid wcscoll wcsftime wcsxfrm wmemcmp writev \
5015 # Force lchmod off for Linux. Linux disallows changing the mode of symbolic
5016 # links. Some libc implementations have a stub lchmod implementation that always
5018 if test "$MACHDEP" != linux; then
5019 AC_CHECK_FUNCS([lchmod])
5022 # iOS defines some system methods that can be linked (so they are
5023 # found by configure), but either raise a compilation error (because the
5024 # header definition prevents usage - autoconf doesn't use the headers), or
5025 # raise an error if used at runtime. Force these symbols off.
5026 if test "$ac_sys_system" != "iOS" ; then
5027 AC_CHECK_FUNCS([getentropy getgroups system])
5030 AC_CHECK_DECL([dirfd],
5031 [AC_DEFINE([HAVE_DIRFD], [1],
5032 [Define if you have the 'dirfd' function or macro.])],
5034 [@%:@include <sys/types.h>
5035 @%:@include <dirent.h>])
5037 # For some functions, having a definition is not sufficient, since
5038 # we want to take their address.
5039 PY_CHECK_FUNC([chroot], [@%:@include <unistd.h>])
5040 PY_CHECK_FUNC([link], [@%:@include <unistd.h>])
5041 PY_CHECK_FUNC([symlink], [@%:@include <unistd.h>])
5042 PY_CHECK_FUNC([fchdir], [@%:@include <unistd.h>])
5043 PY_CHECK_FUNC([fsync], [@%:@include <unistd.h>])
5044 PY_CHECK_FUNC([fdatasync], [@%:@include <unistd.h>])
5045 PY_CHECK_FUNC([epoll_create], [@%:@include <sys/epoll.h>], [HAVE_EPOLL])
5046 PY_CHECK_FUNC([epoll_create1], [@%:@include <sys/epoll.h>])
5047 PY_CHECK_FUNC([kqueue],[
5048 #include <sys/types.h>
5049 #include <sys/event.h>
5051 PY_CHECK_FUNC([prlimit], [
5052 #include <sys/time.h>
5053 #include <sys/resource.h>
5056 PY_CHECK_FUNC([_dyld_shared_cache_contains_path], [@%:@include <mach-o/dyld.h>], [HAVE_DYLD_SHARED_CACHE_CONTAINS_PATH])
5058 PY_CHECK_FUNC([memfd_create], [
5059 #ifdef HAVE_SYS_MMAN_H
5060 #include <sys/mman.h>
5062 #ifdef HAVE_SYS_MEMFD_H
5063 #include <sys/memfd.h>
5067 PY_CHECK_FUNC([eventfd], [
5068 #ifdef HAVE_SYS_EVENTFD_H
5069 #include <sys/eventfd.h>
5073 PY_CHECK_FUNC([timerfd_create], [
5074 #ifdef HAVE_SYS_TIMERFD_H
5075 #include <sys/timerfd.h>
5078 [HAVE_TIMERFD_CREATE])
5080 # On some systems (eg. FreeBSD 5), we would find a definition of the
5081 # functions ctermid_r, setgroups in the library, but no prototype
5082 # (e.g. because we use _XOPEN_SOURCE). See whether we can take their
5083 # address to avoid compiler warnings and potential miscompilations
5084 # because of the missing prototypes.
5086 PY_CHECK_FUNC([ctermid_r], [@%:@include <stdio.h>])
5088 AC_CACHE_CHECK([for flock declaration], [ac_cv_flock_decl],
5091 [@%:@include <sys/file.h>],
5094 [ac_cv_flock_decl=yes],
5095 [ac_cv_flock_decl=no]
5098 dnl Linking with libbsd may be necessary on AIX for flock function.
5099 AS_VAR_IF([ac_cv_flock_decl], [yes],
5100 [AC_CHECK_FUNCS([flock], [],
5101 [AC_CHECK_LIB([bsd], [flock], [FCNTL_LIBS="-lbsd"])])])
5103 PY_CHECK_FUNC([getpagesize], [@%:@include <unistd.h>])
5105 AC_CACHE_CHECK([for broken unsetenv], [ac_cv_broken_unsetenv],
5108 [@%:@include <stdlib.h>],
5109 [int res = unsetenv("DUMMY")])],
5110 [ac_cv_broken_unsetenv=no],
5111 [ac_cv_broken_unsetenv=yes]
5114 AS_VAR_IF([ac_cv_broken_unsetenv], [yes], [
5115 AC_DEFINE([HAVE_BROKEN_UNSETENV], [1],
5116 [Define if 'unsetenv' does not return an int.])
5120 AC_CHECK_PROGS([TRUE], [true], [/bin/true])
5122 dnl On some systems (e.g. Solaris 9), hstrerror and inet_aton are in -lresolv
5123 dnl On others, they are in the C library, so we to take no action
5124 AC_CHECK_LIB([c], [inet_aton], [$ac_cv_prog_TRUE],
5125 AC_CHECK_LIB([resolv], [inet_aton])
5128 # On Tru64, chflags seems to be present, but calling it will
5130 AC_CACHE_CHECK([for chflags], [ac_cv_have_chflags], [dnl
5131 AC_RUN_IFELSE([AC_LANG_SOURCE([[
5132 #include <sys/stat.h>
5134 int main(int argc, char *argv[])
5136 if(chflags(argv[0], 0) != 0)
5141 [ac_cv_have_chflags=yes],
5142 [ac_cv_have_chflags=no],
5143 [ac_cv_have_chflags=cross])
5145 if test "$ac_cv_have_chflags" = cross ; then
5146 AC_CHECK_FUNC([chflags], [ac_cv_have_chflags="yes"], [ac_cv_have_chflags="no"])
5148 if test "$ac_cv_have_chflags" = yes ; then
5149 AC_DEFINE([HAVE_CHFLAGS], [1],
5150 [Define to 1 if you have the 'chflags' function.])
5153 AC_CACHE_CHECK([for lchflags], [ac_cv_have_lchflags], [dnl
5154 AC_RUN_IFELSE([AC_LANG_SOURCE([[
5155 #include <sys/stat.h>
5157 int main(int argc, char *argv[])
5159 if(lchflags(argv[0], 0) != 0)
5163 ]])],[ac_cv_have_lchflags=yes],[ac_cv_have_lchflags=no],[ac_cv_have_lchflags=cross])
5165 if test "$ac_cv_have_lchflags" = cross ; then
5166 AC_CHECK_FUNC([lchflags], [ac_cv_have_lchflags="yes"], [ac_cv_have_lchflags="no"])
5168 if test "$ac_cv_have_lchflags" = yes ; then
5169 AC_DEFINE([HAVE_LCHFLAGS], [1],
5170 [Define to 1 if you have the 'lchflags' function.])
5173 dnl Check for compression libraries
5174 AH_TEMPLATE([HAVE_ZLIB_COPY], [Define if the zlib library has inflateCopy])
5176 dnl detect zlib from Emscripten emport
5177 PY_CHECK_EMSCRIPTEN_PORT([ZLIB], [-sUSE_ZLIB])
5179 PKG_CHECK_MODULES([ZLIB], [zlib >= 1.2.0], [
5181 dnl zlib 1.2.0 (2003) added inflateCopy
5182 AC_DEFINE([HAVE_ZLIB_COPY], [1])
5185 CPPFLAGS="$CPPFLAGS $ZLIB_CFLAGS"
5186 LDFLAGS="$LDFLAGS $ZLIB_LIBS"
5187 AC_CHECK_HEADERS([zlib.h], [
5188 PY_CHECK_LIB([z], [gzread], [have_zlib=yes], [have_zlib=no])
5190 AS_VAR_IF([have_zlib], [yes], [
5191 ZLIB_CFLAGS=${ZLIB_CFLAGS-""}
5192 ZLIB_LIBS=${ZLIB_LIBS-"-lz"}
5193 PY_CHECK_LIB([z], [inflateCopy], [AC_DEFINE([HAVE_ZLIB_COPY], [1])])
5198 dnl binascii can use zlib for optimized crc32.
5199 AS_VAR_IF([have_zlib], [yes], [
5200 BINASCII_CFLAGS="-DUSE_ZLIB_CRC32 $ZLIB_CFLAGS"
5201 BINASCII_LIBS="$ZLIB_LIBS"
5204 dnl detect bzip2 from Emscripten emport
5205 PY_CHECK_EMSCRIPTEN_PORT([BZIP2], [-sUSE_BZIP2])
5207 PKG_CHECK_MODULES([BZIP2], [bzip2], [have_bzip2=yes], [
5209 CPPFLAGS="$CPPFLAGS $BZIP2_CFLAGS"
5210 LDFLAGS="$LDFLAGS $BZIP2_LIBS"
5211 AC_CHECK_HEADERS([bzlib.h], [
5212 AC_CHECK_LIB([bz2], [BZ2_bzCompress], [have_bzip2=yes], [have_bzip2=no])
5214 AS_VAR_IF([have_bzip2], [yes], [
5215 BZIP2_CFLAGS=${BZIP2_CFLAGS-""}
5216 BZIP2_LIBS=${BZIP2_LIBS-"-lbz2"}
5221 PKG_CHECK_MODULES([LIBLZMA], [liblzma], [have_liblzma=yes], [
5223 CPPFLAGS="$CPPFLAGS $LIBLZMA_CFLAGS"
5224 LDFLAGS="$LDFLAGS $LIBLZMA_LIBS"
5225 AC_CHECK_HEADERS([lzma.h], [
5226 AC_CHECK_LIB([lzma], [lzma_easy_encoder], [have_liblzma=yes], [have_liblzma=no])
5227 ], [have_liblzma=no])
5228 AS_VAR_IF([have_liblzma], [yes], [
5229 LIBLZMA_CFLAGS=${LIBLZMA_CFLAGS-""}
5230 LIBLZMA_LIBS=${LIBLZMA_LIBS-"-llzma"}
5235 dnl PY_CHECK_NETDB_FUNC(FUNCTION)
5236 AC_DEFUN([PY_CHECK_NETDB_FUNC], [PY_CHECK_FUNC([$1], [@%:@include <netdb.h>])])
5238 PY_CHECK_NETDB_FUNC([hstrerror])
5239 dnl not available in WASI yet
5240 PY_CHECK_NETDB_FUNC([getservbyname])
5241 PY_CHECK_NETDB_FUNC([getservbyport])
5242 PY_CHECK_NETDB_FUNC([gethostbyname])
5243 PY_CHECK_NETDB_FUNC([gethostbyaddr])
5244 PY_CHECK_NETDB_FUNC([getprotobyname])
5246 dnl PY_CHECK_SOCKET_FUNC(FUNCTION)
5247 AC_DEFUN([PY_CHECK_SOCKET_FUNC], [PY_CHECK_FUNC([$1], [
5248 #include <sys/types.h>
5249 #include <sys/socket.h>
5250 #include <netinet/in.h>
5251 #include <arpa/inet.h>
5254 PY_CHECK_SOCKET_FUNC([inet_aton])
5255 PY_CHECK_SOCKET_FUNC([inet_ntoa])
5256 PY_CHECK_SOCKET_FUNC([inet_pton])
5257 dnl not available in WASI yet
5258 PY_CHECK_SOCKET_FUNC([getpeername])
5259 PY_CHECK_SOCKET_FUNC([getsockname])
5260 PY_CHECK_SOCKET_FUNC([accept])
5261 PY_CHECK_SOCKET_FUNC([bind])
5262 PY_CHECK_SOCKET_FUNC([connect])
5263 PY_CHECK_SOCKET_FUNC([listen])
5264 PY_CHECK_SOCKET_FUNC([recvfrom])
5265 PY_CHECK_SOCKET_FUNC([sendto])
5266 PY_CHECK_SOCKET_FUNC([setsockopt])
5267 PY_CHECK_SOCKET_FUNC([socket])
5269 # On some systems, setgroups is in unistd.h, on others, in grp.h
5270 PY_CHECK_FUNC([setgroups], [
5277 # check for openpty, login_tty, and forkpty
5279 AC_CHECK_FUNCS([openpty], [],
5280 [AC_CHECK_LIB([util], [openpty],
5281 [AC_DEFINE([HAVE_OPENPTY]) LIBS="$LIBS -lutil"],
5282 [AC_CHECK_LIB([bsd], [openpty],
5283 [AC_DEFINE([HAVE_OPENPTY]) LIBS="$LIBS -lbsd"])])])
5284 AC_SEARCH_LIBS([login_tty], [util],
5285 [AC_DEFINE([HAVE_LOGIN_TTY], [1], [Define to 1 if you have the `login_tty' function.])]
5287 AC_CHECK_FUNCS([forkpty], [],
5288 [AC_CHECK_LIB([util], [forkpty],
5289 [AC_DEFINE([HAVE_FORKPTY]) LIBS="$LIBS -lutil"],
5290 [AC_CHECK_LIB([bsd], [forkpty],
5291 [AC_DEFINE([HAVE_FORKPTY]) LIBS="$LIBS -lbsd"])])])
5293 # check for long file support functions
5294 AC_CHECK_FUNCS([fseek64 fseeko fstatvfs ftell64 ftello statvfs])
5296 AC_REPLACE_FUNCS([dup2])
5297 AC_CHECK_FUNCS([getpgrp],
5299 [AC_LANG_PROGRAM([@%:@include <unistd.h>],
5301 [AC_DEFINE([GETPGRP_HAVE_ARG], [1],
5302 [Define if getpgrp() must be called as getpgrp(0).])],
5304 AC_CHECK_FUNCS([setpgrp],
5306 [AC_LANG_PROGRAM([@%:@include <unistd.h>],
5308 [AC_DEFINE([SETPGRP_HAVE_ARG], [1],
5309 [Define if setpgrp() must be called as setpgrp(0, 0).])],
5312 # check for namespace functions
5313 AC_CHECK_FUNCS([setns unshare])
5315 AC_CHECK_FUNCS([clock_gettime], [], [
5316 AC_CHECK_LIB([rt], [clock_gettime], [
5318 AC_DEFINE([HAVE_CLOCK_GETTIME], [1])
5319 AC_DEFINE([TIMEMODULE_LIB], [rt],
5320 [Library needed by timemodule.c: librt may be needed for clock_gettime()])
5324 AC_CHECK_FUNCS([clock_getres], [], [
5325 AC_CHECK_LIB([rt], [clock_getres], [
5326 AC_DEFINE([HAVE_CLOCK_GETRES], [1])
5330 # On Android and iOS, clock_settime can be linked (so it is found by
5331 # configure), but when used in an unprivileged process, it crashes rather than
5332 # returning an error. Force the symbol off.
5333 if test "$ac_sys_system" != "Linux-android" && test "$ac_sys_system" != "iOS"
5335 AC_CHECK_FUNCS([clock_settime], [], [
5336 AC_CHECK_LIB([rt], [clock_settime], [
5337 AC_DEFINE([HAVE_CLOCK_SETTIME], [1])
5342 # On Android before API level 23, clock_nanosleep returns the wrong value when
5343 # interrupted by a signal (https://issuetracker.google.com/issues/216495770).
5344 if ! { test "$ac_sys_system" = "Linux-android" &&
5345 test "$ANDROID_API_LEVEL" -lt 23; }; then
5346 AC_CHECK_FUNCS([clock_nanosleep], [], [
5347 AC_CHECK_LIB([rt], [clock_nanosleep], [
5348 AC_DEFINE([HAVE_CLOCK_NANOSLEEP], [1])
5353 AC_CHECK_FUNCS([nanosleep], [], [
5354 AC_CHECK_LIB([rt], [nanosleep], [
5355 AC_DEFINE([HAVE_NANOSLEEP], [1])
5359 AC_CACHE_CHECK([for major, minor, and makedev], [ac_cv_device_macros], [
5360 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
5361 #if defined(MAJOR_IN_MKDEV)
5362 #include <sys/mkdev.h>
5363 #elif defined(MAJOR_IN_SYSMACROS)
5364 #include <sys/types.h>
5365 #include <sys/sysmacros.h>
5367 #include <sys/types.h>
5370 makedev(major(0),minor(0));
5371 ]])],[ac_cv_device_macros=yes], [ac_cv_device_macros=no])
5373 AS_VAR_IF([ac_cv_device_macros], [yes], [
5374 AC_DEFINE([HAVE_DEVICE_MACROS], [1],
5375 [Define to 1 if you have the device macros.])
5378 dnl no longer used, now always defined for backwards compatibility
5379 AC_DEFINE([SYS_SELECT_WITH_SYS_TIME], [1],
5380 [Define if you can safely include both <sys/select.h> and <sys/time.h>
5381 (which you can't on SCO ODT 3.0).])
5383 # On OSF/1 V5.1, getaddrinfo is available, but a define
5384 # for [no]getaddrinfo in netdb.h.
5385 AC_CACHE_CHECK([for getaddrinfo], [ac_cv_func_getaddrinfo], [
5386 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
5387 #include <sys/types.h>
5388 #include <sys/socket.h>
5391 ]], [[getaddrinfo(NULL, NULL, NULL, NULL);]])],
5392 [ac_cv_func_getaddrinfo=yes],
5393 [ac_cv_func_getaddrinfo=no])
5396 AS_VAR_IF([ac_cv_func_getaddrinfo], [yes], [
5397 AC_CACHE_CHECK([getaddrinfo bug], [ac_cv_buggy_getaddrinfo],
5398 AC_RUN_IFELSE([AC_LANG_SOURCE([[[
5400 #include <sys/types.h>
5403 #include <sys/socket.h>
5404 #include <netinet/in.h>
5408 int passive, gaierr, inet4 = 0, inet6 = 0;
5409 struct addrinfo hints, *ai, *aitop;
5410 char straddr[INET6_ADDRSTRLEN], strport[16];
5412 for (passive = 0; passive <= 1; passive++) {
5413 memset(&hints, 0, sizeof(hints));
5414 hints.ai_family = AF_UNSPEC;
5415 hints.ai_flags = passive ? AI_PASSIVE : 0;
5416 hints.ai_socktype = SOCK_STREAM;
5417 hints.ai_protocol = IPPROTO_TCP;
5418 if ((gaierr = getaddrinfo(NULL, "54321", &hints, &aitop)) != 0) {
5419 (void)gai_strerror(gaierr);
5422 for (ai = aitop; ai; ai = ai->ai_next) {
5423 if (ai->ai_addr == NULL ||
5424 ai->ai_addrlen == 0 ||
5425 getnameinfo(ai->ai_addr, ai->ai_addrlen,
5426 straddr, sizeof(straddr), strport, sizeof(strport),
5427 NI_NUMERICHOST|NI_NUMERICSERV) != 0) {
5430 switch (ai->ai_family) {
5432 if (strcmp(strport, "54321") != 0) {
5436 if (strcmp(straddr, "0.0.0.0") != 0) {
5440 if (strcmp(straddr, "127.0.0.1") != 0) {
5447 if (strcmp(strport, "54321") != 0) {
5451 if (strcmp(straddr, "::") != 0) {
5455 if (strcmp(straddr, "::1") != 0) {
5465 /* another family support? */
5469 freeaddrinfo(aitop);
5473 if (!(inet4 == 0 || inet4 == 2))
5475 if (!(inet6 == 0 || inet6 == 2))
5479 freeaddrinfo(aitop);
5484 freeaddrinfo(aitop);
5488 [ac_cv_buggy_getaddrinfo=no],
5489 [ac_cv_buggy_getaddrinfo=yes],
5491 if test "$ac_sys_system" = "Linux-android" || test "$ac_sys_system" = "iOS"; then
5492 ac_cv_buggy_getaddrinfo="no"
5493 elif test "${enable_ipv6+set}" = set; then
5494 ac_cv_buggy_getaddrinfo="no -- configured with --(en|dis)able-ipv6"
5496 ac_cv_buggy_getaddrinfo=yes
5499 dnl if ac_cv_func_getaddrinfo
5502 if test "$ac_cv_func_getaddrinfo" = no -o "$ac_cv_buggy_getaddrinfo" = yes
5504 AS_VAR_IF([ipv6], [yes], [
5505 AC_MSG_ERROR([m4_normalize([
5506 You must get working getaddrinfo() function
5507 or pass the "--disable-ipv6" option to configure.
5511 AC_DEFINE([HAVE_GETADDRINFO], [1],
5512 [Define if you have the getaddrinfo function.])
5515 AC_CHECK_FUNCS([getnameinfo])
5517 # checks for structures
5520 AC_CHECK_MEMBERS([struct stat.st_rdev])
5521 AC_CHECK_MEMBERS([struct stat.st_blksize])
5522 AC_CHECK_MEMBERS([struct stat.st_flags])
5523 AC_CHECK_MEMBERS([struct stat.st_gen])
5524 AC_CHECK_MEMBERS([struct stat.st_birthtime])
5525 AC_CHECK_MEMBERS([struct stat.st_blocks])
5526 AC_CHECK_MEMBERS([struct passwd.pw_gecos, struct passwd.pw_passwd], [], [], [[
5527 #include <sys/types.h>
5530 # Issue #21085: In Cygwin, siginfo_t does not have si_band field.
5531 AC_CHECK_MEMBERS([siginfo_t.si_band], [], [], [[@%:@include <signal.h>]])
5533 AC_CACHE_CHECK([for time.h that defines altzone], [ac_cv_header_time_altzone], [
5534 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[@%:@include <time.h>]], [[return altzone;]])],
5535 [ac_cv_header_time_altzone=yes],
5536 [ac_cv_header_time_altzone=no])
5538 if test $ac_cv_header_time_altzone = yes; then
5539 AC_DEFINE([HAVE_ALTZONE], [1],
5540 [Define this if your time.h defines altzone.])
5543 AC_CACHE_CHECK([for addrinfo], [ac_cv_struct_addrinfo],
5544 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[@%:@include <netdb.h>]], [[struct addrinfo a]])],
5545 [ac_cv_struct_addrinfo=yes],
5546 [ac_cv_struct_addrinfo=no]))
5547 if test $ac_cv_struct_addrinfo = yes; then
5548 AC_DEFINE([HAVE_ADDRINFO], [1], [struct addrinfo (netdb.h)])
5551 AC_CACHE_CHECK([for sockaddr_storage], [ac_cv_struct_sockaddr_storage],
5552 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
5553 # include <sys/types.h>
5554 @%:@ include <sys/socket.h>]], [[struct sockaddr_storage s]])],
5555 [ac_cv_struct_sockaddr_storage=yes],
5556 [ac_cv_struct_sockaddr_storage=no]))
5557 if test $ac_cv_struct_sockaddr_storage = yes; then
5558 AC_DEFINE([HAVE_SOCKADDR_STORAGE], [1],
5559 [struct sockaddr_storage (sys/socket.h)])
5562 AC_CACHE_CHECK([for sockaddr_alg], [ac_cv_struct_sockaddr_alg],
5563 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
5564 # include <sys/types.h>
5565 # include <sys/socket.h>
5566 @%:@ include <linux/if_alg.h>]], [[struct sockaddr_alg s]])],
5567 [ac_cv_struct_sockaddr_alg=yes],
5568 [ac_cv_struct_sockaddr_alg=no]))
5569 if test $ac_cv_struct_sockaddr_alg = yes; then
5570 AC_DEFINE([HAVE_SOCKADDR_ALG], [1],
5571 [struct sockaddr_alg (linux/if_alg.h)])
5574 # checks for compiler characteristics
5578 AC_CACHE_CHECK([for working signed char], [ac_cv_working_signed_char_c], [
5579 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[signed char c;]])],
5580 [ac_cv_working_signed_char_c=yes], [ac_cv_working_signed_char_c=no])
5582 AS_VAR_IF([ac_cv_working_signed_char_c], [no], [
5583 AC_DEFINE([signed], [], [Define to empty if the keyword does not work.])
5586 AC_CACHE_CHECK([for prototypes], [ac_cv_function_prototypes], [
5587 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[int foo(int x) { return 0; }]], [[return foo(10);]])],
5588 [ac_cv_function_prototypes=yes], [ac_cv_function_prototypes=no])
5590 AS_VAR_IF([ac_cv_function_prototypes], [yes], [
5591 AC_DEFINE([HAVE_PROTOTYPES], [1],
5592 [Define if your compiler supports function prototype])
5596 # check for socketpair
5597 PY_CHECK_FUNC([socketpair], [
5598 #include <sys/types.h>
5599 #include <sys/socket.h>
5602 # check if sockaddr has sa_len member
5603 AC_CACHE_CHECK([if sockaddr has sa_len member], [ac_cv_struct_sockaddr_sa_len], [
5604 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
5605 @%:@include <sys/socket.h>]], [[struct sockaddr x;
5607 [ac_cv_struct_sockaddr_sa_len=yes], [ac_cv_struct_sockaddr_sa_len=no])
5609 AS_VAR_IF([ac_cv_struct_sockaddr_sa_len], [yes], [
5610 AC_DEFINE([HAVE_SOCKADDR_SA_LEN], [1],
5611 [Define if sockaddr has sa_len member])
5614 # sigh -- gethostbyname_r is a mess; it can have 3, 5 or 6 arguments :-(
5615 AH_TEMPLATE([HAVE_GETHOSTBYNAME_R],
5616 [Define this if you have some version of gethostbyname_r()])
5618 AC_CHECK_FUNC([gethostbyname_r],
5619 [AC_DEFINE([HAVE_GETHOSTBYNAME_R])
5620 AC_MSG_CHECKING([gethostbyname_r with 6 args])
5622 CFLAGS="$CFLAGS $MY_CPPFLAGS $MY_THREAD_CPPFLAGS $MY_CFLAGS"
5623 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
5627 struct hostent *he, *res;
5632 (void) gethostbyname_r(name, he, buffer, buflen, &res, &h_errnop)
5634 AC_DEFINE([HAVE_GETHOSTBYNAME_R])
5635 AC_DEFINE([HAVE_GETHOSTBYNAME_R_6_ARG], [1],
5636 [Define this if you have the 6-arg version of gethostbyname_r().])
5637 AC_MSG_RESULT([yes])
5640 AC_MSG_CHECKING([gethostbyname_r with 5 args])
5641 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
5650 (void) gethostbyname_r(name, he, buffer, buflen, &h_errnop)
5653 AC_DEFINE([HAVE_GETHOSTBYNAME_R])
5654 AC_DEFINE([HAVE_GETHOSTBYNAME_R_5_ARG], [1],
5655 [Define this if you have the 5-arg version of gethostbyname_r().])
5656 AC_MSG_RESULT([yes])
5659 AC_MSG_CHECKING([gethostbyname_r with 3 args])
5660 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
5665 struct hostent_data data;
5667 (void) gethostbyname_r(name, he, &data);
5670 AC_DEFINE([HAVE_GETHOSTBYNAME_R])
5671 AC_DEFINE([HAVE_GETHOSTBYNAME_R_3_ARG], [1],
5672 [Define this if you have the 3-arg version of gethostbyname_r().])
5673 AC_MSG_RESULT([yes])
5681 AC_CHECK_FUNCS([gethostbyname])
5683 AC_SUBST([HAVE_GETHOSTBYNAME_R_6_ARG])
5684 AC_SUBST([HAVE_GETHOSTBYNAME_R_5_ARG])
5685 AC_SUBST([HAVE_GETHOSTBYNAME_R_3_ARG])
5686 AC_SUBST([HAVE_GETHOSTBYNAME_R])
5687 AC_SUBST([HAVE_GETHOSTBYNAME])
5689 # checks for system services
5692 # Linux requires this for correct f.p. operations
5693 AC_CHECK_FUNC([__fpu_control],
5695 [AC_CHECK_LIB([ieee], [__fpu_control])
5698 # check for --with-libm=...
5700 case $ac_sys_system in
5704 AC_MSG_CHECKING([for --with-libm=STRING])
5706 [AS_HELP_STRING([--with-libm=STRING], [override libm math library to STRING (default is system-dependent)])],
5708 if test "$withval" = no
5710 AC_MSG_RESULT([force LIBM empty])
5711 elif test "$withval" != yes
5713 AC_MSG_RESULT([set LIBM="$withval"])
5714 else AC_MSG_ERROR([proper usage is --with-libm=STRING])
5716 [AC_MSG_RESULT([default LIBM="$LIBM"])])
5718 # check for --with-libc=...
5720 AC_MSG_CHECKING([for --with-libc=STRING])
5722 [AS_HELP_STRING([--with-libc=STRING], [override libc C library to STRING (default is system-dependent)])],
5724 if test "$withval" = no
5726 AC_MSG_RESULT([force LIBC empty])
5727 elif test "$withval" != yes
5729 AC_MSG_RESULT([set LIBC="$withval"])
5730 else AC_MSG_ERROR([proper usage is --with-libc=STRING])
5732 [AC_MSG_RESULT([default LIBC="$LIBC"])])
5734 # **************************************
5735 # * Check for gcc x64 inline assembler *
5736 # **************************************
5739 AC_CACHE_CHECK([for x64 gcc inline assembler], [ac_cv_gcc_asm_for_x64], [
5740 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
5741 __asm__ __volatile__ ("movq %rcx, %rax");
5742 ]])],[ac_cv_gcc_asm_for_x64=yes],[ac_cv_gcc_asm_for_x64=no])
5745 AS_VAR_IF([ac_cv_gcc_asm_for_x64], [yes], [
5746 AC_DEFINE([HAVE_GCC_ASM_FOR_X64], [1],
5747 [Define if we can use x64 gcc inline assembler])
5750 # **************************************************
5751 # * Check for various properties of floating point *
5752 # **************************************************
5754 AX_C_FLOAT_WORDS_BIGENDIAN
5755 if test "$ax_cv_c_float_words_bigendian" = "yes"
5757 AC_DEFINE([DOUBLE_IS_BIG_ENDIAN_IEEE754], [1],
5758 [Define if C doubles are 64-bit IEEE 754 binary format, stored
5759 with the most significant byte first])
5760 elif test "$ax_cv_c_float_words_bigendian" = "no"
5762 AC_DEFINE([DOUBLE_IS_LITTLE_ENDIAN_IEEE754], [1],
5763 [Define if C doubles are 64-bit IEEE 754 binary format, stored
5764 with the least significant byte first])
5766 # Some ARM platforms use a mixed-endian representation for doubles.
5767 # While Python doesn't currently have full support for these platforms
5768 # (see e.g., issue 1762561), we can at least make sure that float <-> string
5770 # FLOAT_WORDS_BIGENDIAN doesnt actually detect this case, but if it's not big
5771 # or little, then it must be this?
5772 AC_DEFINE([DOUBLE_IS_ARM_MIXED_ENDIAN_IEEE754], [1],
5773 [Define if C doubles are 64-bit IEEE 754 binary format, stored
5774 in ARM mixed-endian order (byte order 45670123)])
5777 # The short float repr introduced in Python 3.1 requires the
5778 # correctly-rounded string <-> double conversion functions from
5779 # Python/dtoa.c, which in turn require that the FPU uses 53-bit
5780 # rounding; this is a problem on x86, where the x87 FPU has a default
5781 # rounding precision of 64 bits. For gcc/x86, we can fix this by
5782 # using inline assembler to get and set the x87 FPU control word.
5784 # This inline assembler syntax may also work for suncc and icc,
5785 # so we try it on all platforms.
5787 AC_CACHE_CHECK([whether we can use gcc inline assembler to get and set x87 control word], [ac_cv_gcc_asm_for_x87], [
5788 AC_LINK_IFELSE( [AC_LANG_PROGRAM([[]], [[
5790 __asm__ __volatile__ ("fnstcw %0" : "=m" (cw));
5791 __asm__ __volatile__ ("fldcw %0" : : "m" (cw));
5792 ]])],[ac_cv_gcc_asm_for_x87=yes],[ac_cv_gcc_asm_for_x87=no])
5794 AS_VAR_IF([ac_cv_gcc_asm_for_x87], [yes], [
5795 AC_DEFINE([HAVE_GCC_ASM_FOR_X87], [1],
5796 [Define if we can use gcc inline assembler to get and set x87 control word])
5799 AC_CACHE_CHECK([whether we can use gcc inline assembler to get and set mc68881 fpcr], [ac_cv_gcc_asm_for_mc68881], [
5800 AC_LINK_IFELSE( [AC_LANG_PROGRAM([[]], [[
5802 __asm__ __volatile__ ("fmove.l %%fpcr,%0" : "=g" (fpcr));
5803 __asm__ __volatile__ ("fmove.l %0,%%fpcr" : : "g" (fpcr));
5804 ]])],[ac_cv_gcc_asm_for_mc68881=yes],[ac_cv_gcc_asm_for_mc68881=no])
5806 AS_VAR_IF([ac_cv_gcc_asm_for_mc68881], [yes], [
5807 AC_DEFINE([HAVE_GCC_ASM_FOR_MC68881], [1],
5808 [Define if we can use gcc inline assembler to get and set mc68881 fpcr])
5811 # Detect whether system arithmetic is subject to x87-style double
5812 # rounding issues. The result of this test has little meaning on non
5813 # IEEE 754 platforms. On IEEE 754, test should return 1 if rounding
5814 # mode is round-to-nearest and double rounding issues are present, and
5815 # 0 otherwise. See https://github.com/python/cpython/issues/47186 for more info.
5816 AC_CACHE_CHECK([for x87-style double rounding], [ac_cv_x87_double_rounding], [
5817 # $BASECFLAGS may affect the result
5819 CC="$CC $BASECFLAGS"
5820 AC_RUN_IFELSE([AC_LANG_SOURCE([[
5824 volatile double x, y, z;
5825 /* 1./(1-2**-53) -> 1+2**-52 (correct), 1.0 (double rounding) */
5826 x = 0.99999999999999989; /* 1-2**-53 */
5830 /* 1e16+2.99999 -> 1e16+2. (correct), 1e16+4. (double rounding) */
5836 /* both tests show evidence of double rounding */
5840 [ac_cv_x87_double_rounding=no],
5841 [ac_cv_x87_double_rounding=yes],
5842 [ac_cv_x87_double_rounding=no])
5846 AS_VAR_IF([ac_cv_x87_double_rounding], [yes], [
5847 AC_DEFINE([X87_DOUBLE_ROUNDING], [1],
5848 [Define if arithmetic is subject to x87-style double rounding issue])
5851 # ************************************
5852 # * Check for mathematical functions *
5853 # ************************************
5859 [acosh asinh atanh erf erfc expm1 log1p log2],
5861 [AC_MSG_ERROR([Python requires C99 compatible libm])]
5865 dnl For multiprocessing module, check that sem_open
5866 dnl actually works. For FreeBSD versions <= 7.2,
5867 dnl the kernel module that provides POSIX semaphores
5868 dnl isn't loaded by default, so an attempt to call
5869 dnl sem_open results in a 'Signal 12' error.
5870 AC_CACHE_CHECK([whether POSIX semaphores are enabled], [ac_cv_posix_semaphores_enabled],
5876 #include <semaphore.h>
5877 #include <sys/stat.h>
5880 sem_t *a = sem_open("/autoconf", O_CREAT, S_IRUSR|S_IWUSR, 0);
5881 if (a == SEM_FAILED) {
5886 sem_unlink("/autoconf");
5891 [ac_cv_posix_semaphores_enabled=yes],
5892 [ac_cv_posix_semaphores_enabled=no],
5893 [ac_cv_posix_semaphores_enabled=yes])
5895 AS_VAR_IF([ac_cv_posix_semaphores_enabled], [no], [
5897 [POSIX_SEMAPHORES_NOT_ENABLED], [1],
5898 [Define if POSIX semaphores aren't enabled on your system]
5902 dnl Multiprocessing check for broken sem_getvalue
5903 AC_CACHE_CHECK([for broken sem_getvalue], [ac_cv_broken_sem_getvalue],
5909 #include <semaphore.h>
5910 #include <sys/stat.h>
5913 sem_t *a = sem_open("/autocftw", O_CREAT, S_IRUSR|S_IWUSR, 0);
5921 res = sem_getvalue(a, &count);
5923 sem_unlink("/autocftw");
5924 return res==-1 ? 1 : 0;
5928 [ac_cv_broken_sem_getvalue=no],
5929 [ac_cv_broken_sem_getvalue=yes],
5930 [ac_cv_broken_sem_getvalue=yes])
5932 AS_VAR_IF([ac_cv_broken_sem_getvalue], [yes], [
5934 [HAVE_BROKEN_SEM_GETVALUE], [1],
5935 [define to 1 if your sem_getvalue is broken.]
5939 AC_CHECK_DECLS([RTLD_LAZY, RTLD_NOW, RTLD_GLOBAL, RTLD_LOCAL, RTLD_NODELETE, RTLD_NOLOAD, RTLD_DEEPBIND, RTLD_MEMBER], [], [], [[@%:@include <dlfcn.h>]])
5941 # determine what size digit to use for Python's longs
5942 AC_MSG_CHECKING([digit size for Python's longs])
5943 AC_ARG_ENABLE([big-digits],
5944 AS_HELP_STRING([--enable-big-digits@<:@=15|30@:>@],[use big digits (30 or 15 bits) for Python longs (default is 30)]]),
5945 [case $enable_big_digits in
5947 enable_big_digits=30 ;;
5949 enable_big_digits=15 ;;
5953 AC_MSG_ERROR([bad value $enable_big_digits for --enable-big-digits; value should be 15 or 30]) ;;
5955 AC_MSG_RESULT([$enable_big_digits])
5956 AC_DEFINE_UNQUOTED([PYLONG_BITS_IN_DIGIT], [$enable_big_digits],
5957 [Define as the preferred size in bits of long digits])
5959 [AC_MSG_RESULT([no value specified])])
5962 AC_CHECK_HEADER([wchar.h], [
5963 AC_DEFINE([HAVE_WCHAR_H], [1],
5964 [Define if the compiler provides a wchar.h header file.])
5970 # determine wchar_t size
5971 if test "$wchar_h" = yes
5973 AC_CHECK_SIZEOF([wchar_t], [4], [m4_normalize([
5978 # check whether wchar_t is signed or not
5979 if test "$wchar_h" = yes
5981 # check whether wchar_t is signed or not
5982 AC_CACHE_CHECK([whether wchar_t is signed], [ac_cv_wchar_t_signed], [
5983 AC_RUN_IFELSE([AC_LANG_SOURCE([[
5987 /* Success: exit code 0 */
5988 return ((((wchar_t) -1) < ((wchar_t) 0)) ? 0 : 1);
5991 [ac_cv_wchar_t_signed=yes],
5992 [ac_cv_wchar_t_signed=no],
5993 [ac_cv_wchar_t_signed=yes])])
5996 AC_MSG_CHECKING([whether wchar_t is usable])
5997 # wchar_t is only usable if it maps to an unsigned type
5998 if test "$ac_cv_sizeof_wchar_t" -ge 2 \
5999 -a "$ac_cv_wchar_t_signed" = "no"
6001 AC_DEFINE([HAVE_USABLE_WCHAR_T], [1],
6002 [Define if you have a useable wchar_t type defined in wchar.h; useable
6003 means wchar_t must be an unsigned type with at least 16 bits. (see
6004 Include/unicodeobject.h).])
6005 AC_MSG_RESULT([yes])
6010 case $ac_sys_system/$ac_sys_release in
6012 if test -f /etc/os-release; then
6013 OS_NAME=$(awk -F= '/^NAME=/ {print substr($2,2,length($2)-2)}' /etc/os-release)
6014 if test "x$OS_NAME" = "xOracle Solaris"; then
6015 # bpo-43667: In Oracle Solaris, the internal form of wchar_t in
6016 # non-Unicode locales is not Unicode and hence cannot be used directly.
6017 # https://docs.oracle.com/cd/E37838_01/html/E61053/gmwke.html
6018 AC_DEFINE([HAVE_NON_UNICODE_WCHAR_T_REPRESENTATION], [1],
6019 [Define if the internal form of wchar_t in non-Unicode locales
6026 # check for endianness
6029 # ABI version string for Python extension modules. This appears between the
6030 # periods in shared library file names, e.g. foo.<SOABI>.so. It is calculated
6031 # from the following attributes which affect the ABI of this Python build (in
6034 # * The Python implementation (always 'cpython-' for us)
6035 # * The major and minor version numbers
6036 # * --disable-gil (adds a 't')
6037 # * --with-pydebug (adds a 'd')
6039 # Thus for example, Python 3.2 built with wide unicode, pydebug, and pymalloc,
6040 # would get a shared library ABI version tag of 'cpython-32dmu' and shared
6041 # libraries would be named 'foo.cpython-32dmu.so'.
6043 # In Python 3.2 and older, --with-wide-unicode added a 'u' flag.
6044 # In Python 3.7 and older, --with-pymalloc added a 'm' flag.
6046 AC_MSG_CHECKING([ABIFLAGS])
6047 AC_MSG_RESULT([$ABIFLAGS])
6048 AC_MSG_CHECKING([SOABI])
6049 SOABI='cpython-'`echo $VERSION | tr -d .`${ABIFLAGS}${SOABI_PLATFORM:+-$SOABI_PLATFORM}
6050 AC_MSG_RESULT([$SOABI])
6052 # Release build, debug build (Py_DEBUG), and trace refs build (Py_TRACE_REFS)
6053 # are ABI compatible
6054 if test "$Py_DEBUG" = 'true'; then
6055 # Similar to SOABI but remove "d" flag from ABIFLAGS
6056 AC_SUBST([ALT_SOABI])
6057 ALT_SOABI='cpython-'`echo $VERSION | tr -d .``echo $ABIFLAGS | tr -d d`${SOABI_PLATFORM:+-$SOABI_PLATFORM}
6058 AC_DEFINE_UNQUOTED([ALT_SOABI], ["${ALT_SOABI}"],
6059 [Alternative SOABI used in debug build to load C extensions built in release mode])
6062 AC_SUBST([EXT_SUFFIX])
6063 EXT_SUFFIX=.${SOABI}${SHLIB_SUFFIX}
6065 AC_MSG_CHECKING([LDVERSION])
6066 LDVERSION='$(VERSION)$(ABIFLAGS)'
6067 AC_MSG_RESULT([$LDVERSION])
6069 # Configure the flags and dependencies used when compiling shared modules
6070 AC_SUBST([MODULE_DEPS_SHARED])
6071 AC_SUBST([MODULE_LDFLAGS])
6072 MODULE_DEPS_SHARED='$(MODULE_DEPS_STATIC) $(EXPORTSYMS)'
6075 # On Android and Cygwin the shared libraries must be linked with libpython.
6076 if test "$PY_ENABLE_SHARED" = "1" && ( test -n "$ANDROID_API_LEVEL" || test "$MACHDEP" = "cygwin"); then
6077 MODULE_DEPS_SHARED="$MODULE_DEPS_SHARED \$(LDLIBRARY)"
6078 MODULE_LDFLAGS="\$(BLDLIBRARY)"
6081 # On iOS the shared libraries must be linked with the Python framework
6082 if test "$ac_sys_system" = "iOS"; then
6083 MODULE_DEPS_SHARED="$MODULE_DEPS_SHARED \$(PYTHONFRAMEWORKDIR)/\$(PYTHONFRAMEWORK)"
6087 AC_SUBST([BINLIBDEST])
6088 BINLIBDEST='$(LIBDIR)/python$(VERSION)'
6091 # Check for --with-platlibdir
6092 # /usr/$LIDIRNAME/python$VERSION
6093 AC_SUBST([PLATLIBDIR])
6095 AC_MSG_CHECKING([for --with-platlibdir])
6099 [--with-platlibdir=DIRNAME],
6100 [Python library directory name (default is "lib")]
6105 # --with-platlibdir=
6106 # --without-platlibdir
6107 if test -n "$withval" -a "$withval" != yes -a "$withval" != no
6109 AC_MSG_RESULT([yes])
6110 PLATLIBDIR="$withval"
6111 BINLIBDEST='${exec_prefix}/${PLATLIBDIR}/python$(VERSION)'
6115 [AC_MSG_RESULT([no])])
6118 dnl define LIBPL after ABIFLAGS and LDVERSION is defined.
6119 AC_SUBST([PY_ENABLE_SHARED])
6120 if test x$PLATFORM_TRIPLET = x; then
6121 LIBPL='$(prefix)'"/${PLATLIBDIR}/python${VERSION}/config-${LDVERSION}"
6123 LIBPL='$(prefix)'"/${PLATLIBDIR}/python${VERSION}/config-${LDVERSION}-${PLATFORM_TRIPLET}"
6127 # Check for --with-wheel-pkg-dir=PATH
6128 AC_SUBST([WHEEL_PKG_DIR])
6130 AC_MSG_CHECKING([for --with-wheel-pkg-dir])
6134 [--with-wheel-pkg-dir=PATH],
6135 [Directory of wheel packages used by ensurepip (default: none)]
6138 if test -n "$withval"; then
6139 AC_MSG_RESULT([yes])
6140 WHEEL_PKG_DIR="$withval"
6144 [AC_MSG_RESULT([no])])
6146 # Check whether right shifting a negative integer extends the sign bit
6147 # or fills with zeros (like the Cray J90, according to Tim Peters).
6148 AC_CACHE_CHECK([whether right shift extends the sign bit], [ac_cv_rshift_extends_sign], [
6149 AC_RUN_IFELSE([AC_LANG_SOURCE([[
6152 return (((-1)>>3 == -1) ? 0 : 1);
6155 [ac_cv_rshift_extends_sign=yes],
6156 [ac_cv_rshift_extends_sign=no],
6157 [ac_cv_rshift_extends_sign=yes])])
6158 if test "$ac_cv_rshift_extends_sign" = no
6160 AC_DEFINE([SIGNED_RIGHT_SHIFT_ZERO_FILLS], [1],
6161 [Define if i>>j for signed int i does not extend the sign bit
6165 # check for getc_unlocked and related locking functions
6166 AC_CACHE_CHECK([for getc_unlocked() and friends], [ac_cv_have_getc_unlocked], [
6167 AC_LINK_IFELSE([AC_LANG_PROGRAM([[@%:@include <stdio.h>]], [[
6168 FILE *f = fopen("/dev/null", "r");
6172 ]])],[ac_cv_have_getc_unlocked=yes],[ac_cv_have_getc_unlocked=no])])
6173 if test "$ac_cv_have_getc_unlocked" = yes
6175 AC_DEFINE([HAVE_GETC_UNLOCKED], [1],
6176 [Define this if you have flockfile(), getc_unlocked(), and funlockfile()])
6179 dnl Check for libreadline and libedit
6180 dnl - libreadline provides "readline/readline.h" header and "libreadline"
6181 dnl shared library. pkg-config file is readline.pc
6182 dnl - libedit provides "editline/readline.h" header and "libedit" shared
6183 dnl library. pkg-config file ins libedit.pc
6184 dnl - editline is not supported ("readline.h" and "libeditline" shared library)
6186 dnl NOTE: In the past we checked if readline needs an additional termcap
6187 dnl library (tinfo ncursesw ncurses termcap). We now assume that libreadline
6188 dnl or readline.pc provide correct linker information.
6190 AH_TEMPLATE([WITH_EDITLINE], [Define to build the readline module against libedit.])
6194 [AS_HELP_STRING([--with(out)-readline@<:@=editline|readline|no@:>@],
6195 [use libedit for backend or disable readline module])],
6197 AS_CASE([$with_readline],
6198 [editline|edit], [with_readline=edit],
6199 [yes|readline], [with_readline=readline],
6201 [AC_MSG_ERROR([proper usage is --with(out)-readline@<:@=editline|readline|no@:>@])]
6204 [with_readline=readline]
6207 AS_VAR_IF([with_readline], [readline], [
6208 PKG_CHECK_MODULES([LIBREADLINE], [readline], [
6209 LIBREADLINE=readline
6210 READLINE_CFLAGS=$LIBREADLINE_CFLAGS
6211 READLINE_LIBS=$LIBREADLINE_LIBS
6214 CPPFLAGS="$CPPFLAGS $LIBREADLINE_CFLAGS"
6215 LDFLAGS="$LDFLAGS $LIBREADLINE_LIBS"
6216 AC_CHECK_HEADERS([readline/readline.h], [
6217 AC_CHECK_LIB([readline], [readline], [
6218 LIBREADLINE=readline
6219 READLINE_CFLAGS=${LIBREADLINE_CFLAGS-""}
6220 READLINE_LIBS=${LIBREADLINE_LIBS-"-lreadline"}
6221 ], [with_readline=no])
6222 ], [with_readline=no])
6227 AS_VAR_IF([with_readline], [edit], [
6228 PKG_CHECK_MODULES([LIBEDIT], [libedit], [
6229 AC_DEFINE([WITH_EDITLINE], [1])
6231 READLINE_CFLAGS=$LIBEDIT_CFLAGS
6232 READLINE_LIBS=$LIBEDIT_LIBS
6235 CPPFLAGS="$CPPFLAGS $LIBEDIT_CFLAGS"
6236 LDFLAGS="$LDFLAGS $LIBEDIT_LIBS"
6237 AC_CHECK_HEADERS([editline/readline.h], [
6238 AC_CHECK_LIB([edit], [readline], [
6240 AC_DEFINE([WITH_EDITLINE], [1])
6241 READLINE_CFLAGS=${LIBEDIT_CFLAGS-""}
6242 READLINE_LIBS=${LIBEDIT_LIBS-"-ledit"}
6243 ], [with_readline=no])
6244 ], [with_readline=no])
6249 dnl pyconfig.h defines _XOPEN_SOURCE=700
6250 READLINE_CFLAGS=$(echo $READLINE_CFLAGS | sed 's/-D_XOPEN_SOURCE=600//g')
6252 AC_MSG_CHECKING([how to link readline])
6253 AS_VAR_IF([with_readline], [no], [
6256 AC_MSG_RESULT([$with_readline (CFLAGS: $READLINE_CFLAGS, LIBS: $READLINE_LIBS)])
6259 CPPFLAGS="$CPPFLAGS $READLINE_CFLAGS"
6260 LIBS="$READLINE_LIBS $LIBS"
6263 m4_define([readline_includes], [
6264 #include <stdio.h> /* Must be first for Gnu Readline */
6265 #ifdef WITH_EDITLINE
6266 # include <editline/readline.h>
6268 # include <readline/readline.h>
6269 # include <readline/history.h>
6273 # check for readline 2.2
6274 AC_CHECK_DECL([rl_completion_append_character], [
6275 AC_DEFINE([HAVE_RL_COMPLETION_APPEND_CHARACTER], [1], [Define if you have readline 2.2])
6276 ], [], [readline_includes])
6278 AC_CHECK_DECL([rl_completion_suppress_append], [
6279 AC_DEFINE([HAVE_RL_COMPLETION_SUPPRESS_APPEND], [1], [Define if you have rl_completion_suppress_append])
6280 ], [], [readline_includes])
6282 # check for readline 4.0
6283 AC_CACHE_CHECK([for rl_pre_input_hook in -l$LIBREADLINE], [ac_cv_readline_rl_pre_input_hook], [
6285 [AC_LANG_PROGRAM([readline_includes], [void *x = rl_pre_input_hook])],
6286 [ac_cv_readline_rl_pre_input_hook=yes], [ac_cv_readline_rl_pre_input_hook=no]
6289 AS_VAR_IF([ac_cv_readline_rl_pre_input_hook], [yes], [
6290 AC_DEFINE([HAVE_RL_PRE_INPUT_HOOK], [1], [Define if you have readline 4.0])
6294 AC_CACHE_CHECK([for rl_completion_display_matches_hook in -l$LIBREADLINE], [ac_cv_readline_rl_completion_display_matches_hook], [
6296 [AC_LANG_PROGRAM([readline_includes], [void *x = rl_completion_display_matches_hook])],
6297 [ac_cv_readline_rl_completion_display_matches_hook=yes], [ac_cv_readline_rl_completion_display_matches_hook=no]
6300 AS_VAR_IF([ac_cv_readline_rl_completion_display_matches_hook], [yes], [
6301 AC_DEFINE([HAVE_RL_COMPLETION_DISPLAY_MATCHES_HOOK], [1], [Define if you have readline 4.0])
6304 # also in 4.0, but not in editline
6305 AC_CACHE_CHECK([for rl_resize_terminal in -l$LIBREADLINE], [ac_cv_readline_rl_resize_terminal], [
6307 [AC_LANG_PROGRAM([readline_includes], [void *x = rl_resize_terminal])],
6308 [ac_cv_readline_rl_resize_terminal=yes], [ac_cv_readline_rl_resize_terminal=no]
6311 AS_VAR_IF([ac_cv_readline_rl_resize_terminal], [yes], [
6312 AC_DEFINE([HAVE_RL_RESIZE_TERMINAL], [1], [Define if you have readline 4.0])
6315 # check for readline 4.2
6316 AC_CACHE_CHECK([for rl_completion_matches in -l$LIBREADLINE], [ac_cv_readline_rl_completion_matches], [
6318 [AC_LANG_PROGRAM([readline_includes], [void *x = rl_completion_matches])],
6319 [ac_cv_readline_rl_completion_matches=yes], [ac_cv_readline_rl_completion_matches=no]
6322 AS_VAR_IF([ac_cv_readline_rl_completion_matches], [yes], [
6323 AC_DEFINE([HAVE_RL_COMPLETION_MATCHES], [1], [Define if you have readline 4.2])
6326 # also in readline 4.2
6327 AC_CHECK_DECL([rl_catch_signals], [
6328 AC_DEFINE([HAVE_RL_CATCH_SIGNAL], [1], [Define if you can turn off readline's signal handling.])
6329 ], [], [readline_includes])
6331 AC_CACHE_CHECK([for append_history in -l$LIBREADLINE], [ac_cv_readline_append_history], [
6333 [AC_LANG_PROGRAM([readline_includes], [void *x = append_history])],
6334 [ac_cv_readline_append_history=yes], [ac_cv_readline_append_history=no]
6337 AS_VAR_IF([ac_cv_readline_append_history], [yes], [
6338 AC_DEFINE([HAVE_RL_APPEND_HISTORY], [1], [Define if readline supports append_history])
6341 # in readline as well as newer editline (April 2023)
6342 AC_CHECK_TYPES([rl_compdisp_func_t], [], [], [readline_includes])
6344 # Some editline versions declare rl_startup_hook as taking no args, others
6345 # declare it as taking 2.
6346 AC_CACHE_CHECK([if rl_startup_hook takes arguments], [ac_cv_readline_rl_startup_hook_takes_args], [
6348 [AC_LANG_PROGRAM([readline_includes]
6349 [extern int test_hook_func(const char *text, int state);],
6350 [rl_startup_hook=test_hook_func;])],
6351 [ac_cv_readline_rl_startup_hook_takes_args=yes],
6352 [ac_cv_readline_rl_startup_hook_takes_args=no]
6355 AS_VAR_IF([ac_cv_readline_rl_startup_hook_takes_args], [yes], [
6356 AC_DEFINE([Py_RL_STARTUP_HOOK_TAKES_ARGS], [1], [Define if rl_startup_hook takes arguments])
6359 m4_undefine([readline_includes])
6360 ])dnl WITH_SAVE_ENV()
6363 AC_CACHE_CHECK([for broken nice()], [ac_cv_broken_nice], [
6364 AC_RUN_IFELSE([AC_LANG_SOURCE([[
6370 if (val1 != -1 && val1 == nice(2))
6375 [ac_cv_broken_nice=yes],
6376 [ac_cv_broken_nice=no],
6377 [ac_cv_broken_nice=no])])
6378 if test "$ac_cv_broken_nice" = yes
6380 AC_DEFINE([HAVE_BROKEN_NICE], [1],
6381 [Define if nice() returns success/failure instead of the new priority.])
6384 AC_CACHE_CHECK([for broken poll()], [ac_cv_broken_poll],
6385 AC_RUN_IFELSE([AC_LANG_SOURCE([[
6391 struct pollfd poll_struct = { 42, POLLIN|POLLPRI|POLLOUT, 0 };
6396 poll_test = poll(&poll_struct, 1, 0);
6399 else if (poll_test == 0 && poll_struct.revents != POLLNVAL)
6405 [ac_cv_broken_poll=yes],
6406 [ac_cv_broken_poll=no],
6407 [ac_cv_broken_poll=no]))
6408 if test "$ac_cv_broken_poll" = yes
6410 AC_DEFINE([HAVE_BROKEN_POLL], [1],
6411 [Define if poll() sets errno on invalid file descriptors.])
6414 # check tzset(3) exists and works like we expect it to
6415 AC_CACHE_CHECK([for working tzset()], [ac_cv_working_tzset], [
6416 AC_RUN_IFELSE([AC_LANG_SOURCE([[
6422 extern char *tzname[];
6427 /* Note that we need to ensure that not only does tzset(3)
6428 do 'something' with localtime, but it works as documented
6429 in the library reference and as expected by the test suite.
6430 This includes making sure that tzname is set properly if
6431 tm->tm_zone does not exist since it is the alternative way
6432 of getting timezone info.
6434 Red Hat 6.2 doesn't understand the southern hemisphere
6435 after New Year's Day.
6438 time_t groundhogday = 1044144000; /* GMT-based */
6439 time_t midyear = groundhogday + (365 * 24 * 3600 / 2);
6443 if (localtime(&groundhogday)->tm_hour != 0)
6446 /* For UTC, tzname[1] is sometimes "", sometimes " " */
6447 if (strcmp(tzname[0], "UTC") ||
6448 (tzname[1][0] != 0 && tzname[1][0] != ' '))
6452 putenv("TZ=EST+5EDT,M4.1.0,M10.5.0");
6454 if (localtime(&groundhogday)->tm_hour != 19)
6457 if (strcmp(tzname[0], "EST") || strcmp(tzname[1], "EDT"))
6461 putenv("TZ=AEST-10AEDT-11,M10.5.0,M3.5.0");
6463 if (localtime(&groundhogday)->tm_hour != 11)
6466 if (strcmp(tzname[0], "AEST") || strcmp(tzname[1], "AEDT"))
6470 #if HAVE_STRUCT_TM_TM_ZONE
6471 if (strcmp(localtime(&groundhogday)->tm_zone, "AEDT"))
6473 if (strcmp(localtime(&midyear)->tm_zone, "AEST"))
6480 [ac_cv_working_tzset=yes],
6481 [ac_cv_working_tzset=no],
6482 [ac_cv_working_tzset=no])])
6483 if test "$ac_cv_working_tzset" = yes
6485 AC_DEFINE([HAVE_WORKING_TZSET], [1],
6486 [Define if tzset() actually switches the local timezone in a meaningful way.])
6489 # Look for subsecond timestamps in struct stat
6490 AC_CACHE_CHECK([for tv_nsec in struct stat], [ac_cv_stat_tv_nsec],
6491 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[@%:@include <sys/stat.h>]], [[
6493 st.st_mtim.tv_nsec = 1;
6495 [ac_cv_stat_tv_nsec=yes],
6496 [ac_cv_stat_tv_nsec=no]))
6497 if test "$ac_cv_stat_tv_nsec" = yes
6499 AC_DEFINE([HAVE_STAT_TV_NSEC], [1],
6500 [Define if you have struct stat.st_mtim.tv_nsec])
6503 # Look for BSD style subsecond timestamps in struct stat
6504 AC_CACHE_CHECK([for tv_nsec2 in struct stat], [ac_cv_stat_tv_nsec2],
6505 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[@%:@include <sys/stat.h>]], [[
6507 st.st_mtimespec.tv_nsec = 1;
6509 [ac_cv_stat_tv_nsec2=yes],
6510 [ac_cv_stat_tv_nsec2=no]))
6511 if test "$ac_cv_stat_tv_nsec2" = yes
6513 AC_DEFINE([HAVE_STAT_TV_NSEC2], [1],
6514 [Define if you have struct stat.st_mtimensec])
6517 dnl check for ncurses/ncursesw and panel/panelw
6518 dnl NOTE: old curses is not detected.
6519 dnl have_curses=[no, ncursesw, ncurses]
6520 dnl have_panel=[no, panelw, panel]
6524 AH_TEMPLATE([HAVE_NCURSESW], [Define to 1 if you have the `ncursesw' library.])
6525 AC_CHECK_HEADERS([curses.h ncurses.h])
6527 AS_VAR_IF([ac_cv_header_ncurses_h], [yes], [
6528 if test "$ac_sys_system" != "Darwin"; then
6529 dnl On macOS, there is no separate /usr/lib/libncursesw nor libpanelw.
6530 PKG_CHECK_MODULES([CURSES], [ncursesw], [
6531 AC_DEFINE([HAVE_NCURSESW], [1])
6532 have_curses=ncursesw
6535 AC_CHECK_LIB([ncursesw], [initscr], [
6536 AC_DEFINE([HAVE_NCURSESW], [1])
6537 have_curses=ncursesw
6538 CURSES_CFLAGS=${CURSES_CFLAGS-""}
6539 CURSES_LIBS=${CURSES_LIBS-"-lncursesw"}
6545 AS_VAR_IF([have_curses], [no], [
6546 PKG_CHECK_MODULES([CURSES], [ncurses], [
6550 AC_CHECK_LIB([ncurses], [initscr], [
6552 CURSES_CFLAGS=${CURSES_CFLAGS-""}
6553 CURSES_LIBS=${CURSES_LIBS-"-lncurses"}
6559 ])dnl ac_cv_header_ncurses_h = yes
6561 dnl remove _XOPEN_SOURCE macro from curses cflags. pyconfig.h sets
6562 dnl the macro to 700.
6563 CURSES_CFLAGS=$(echo $CURSES_CFLAGS | sed 's/-D_XOPEN_SOURCE=600//g')
6565 if test "$have_curses" != no -a "$ac_sys_system" = "Darwin"; then
6566 dnl On macOS, there is no separate /usr/lib/libncursesw nor libpanelw.
6567 dnl System-supplied ncurses combines libncurses/libpanel and supports wide
6568 dnl characters, so we can use it like ncursesw.
6569 dnl If a locally-supplied version of libncursesw is found, we will use that.
6570 dnl There should also be a libpanelw.
6571 dnl _XOPEN_SOURCE defines are usually excluded for macOS, but we need
6572 dnl _XOPEN_SOURCE_EXTENDED here for ncurses wide char support.
6574 AS_VAR_APPEND([CURSES_CFLAGS], [" -D_XOPEN_SOURCE_EXTENDED=1"])
6575 AC_DEFINE([HAVE_NCURSESW], [1])
6578 dnl TODO: detect "curses" and special cases tinfo, terminfo, or termcap
6580 AC_MSG_CHECKING([curses module flags])
6581 AS_VAR_IF([have_curses], [no], [
6584 AC_MSG_RESULT([$have_curses (CFLAGS: $CURSES_CFLAGS, LIBS: $CURSES_LIBS)])
6587 dnl check for ncurses' panel/panelw library
6588 AC_CHECK_HEADERS([panel.h])
6590 AS_VAR_IF([ac_cv_header_panel_h], [yes], [
6592 if test "$ac_sys_system" != "Darwin"; then
6593 dnl On macOS, there is no separate /usr/lib/libncursesw nor libpanelw.
6594 AS_VAR_IF([have_curses], [ncursesw], [
6595 PKG_CHECK_MODULES([PANEL], [panelw], [
6599 AC_CHECK_LIB([panelw], [update_panels], [
6601 PANEL_CFLAGS=${PANEL_CFLAGS-""}
6602 PANEL_LIBS=${PANEL_LIBS-"-lpanelw"}
6609 AS_VAR_IF([have_curses], [ncurses], [
6610 PKG_CHECK_MODULES([PANEL], [panel], [
6614 AC_CHECK_LIB([panel], [update_panels], [
6616 PANEL_CFLAGS=${PANEL_CFLAGS-""}
6617 PANEL_LIBS=${PANEL_LIBS-"-lpanel"}
6623 ])dnl ac_cv_header_panel_h = yes
6625 dnl pyconfig.h defines _XOPEN_SOURCE=700
6626 PANEL_CFLAGS=$(echo $PANEL_CFLAGS | sed 's/-D_XOPEN_SOURCE=600//g')
6628 AC_MSG_CHECKING([panel flags])
6629 AS_VAR_IF([have_panel], [no], [
6632 AC_MSG_RESULT([$have_panel (CFLAGS: $PANEL_CFLAGS, LIBS: $PANEL_LIBS)])
6635 # first curses header check
6636 ac_save_cppflags="$CPPFLAGS"
6637 if test "$cross_compiling" = no; then
6638 CPPFLAGS="$CPPFLAGS -I/usr/include/ncursesw"
6641 # On Solaris, term.h requires curses.h
6642 AC_CHECK_HEADERS([term.h], [], [], [
6643 #ifdef HAVE_CURSES_H
6648 # On HP/UX 11.0, mvwdelch is a block with a return statement
6649 AC_CACHE_CHECK([whether mvwdelch is an expression], [ac_cv_mvwdelch_is_expression],
6650 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[@%:@include <curses.h>]], [[
6652 rtn = mvwdelch(0,0,0);
6654 [ac_cv_mvwdelch_is_expression=yes],
6655 [ac_cv_mvwdelch_is_expression=no]))
6657 if test "$ac_cv_mvwdelch_is_expression" = yes
6659 AC_DEFINE([MVWDELCH_IS_EXPRESSION], [1],
6660 [Define if mvwdelch in curses.h is an expression.])
6663 # Issue #25720: ncurses has introduced the NCURSES_OPAQUE symbol making opaque
6664 # structs since version 5.7. If the macro is defined as zero before including
6665 # [n]curses.h, ncurses will expose fields of the structs regardless of the
6667 AC_CACHE_CHECK([whether WINDOW has _flags], [ac_cv_window_has_flags],
6668 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
6669 #define NCURSES_OPAQUE 0
6675 [ac_cv_window_has_flags=yes],
6676 [ac_cv_window_has_flags=no]))
6679 if test "$ac_cv_window_has_flags" = yes
6681 AC_DEFINE([WINDOW_HAS_FLAGS], [1],
6682 [Define if WINDOW in curses.h offers a field _flags.])
6685 dnl PY_CHECK_CURSES_FUNC(FUNCTION)
6686 AC_DEFUN([PY_CHECK_CURSES_FUNC],
6687 [ AS_VAR_PUSHDEF([py_var], [ac_cv_lib_curses_$1])
6688 AS_VAR_PUSHDEF([py_define], [HAVE_CURSES_]m4_toupper($1))
6690 [for curses function $1],
6694 [@%:@include <curses.h>], [
6699 [AS_VAR_SET([py_var], [yes])],
6700 [AS_VAR_SET([py_var], [no])])]
6705 [AC_DEFINE([py_define], [1], [Define if you have the '$1' function.])])
6706 AS_VAR_POPDEF([py_var])
6707 AS_VAR_POPDEF([py_define])
6710 PY_CHECK_CURSES_FUNC([is_pad])
6711 PY_CHECK_CURSES_FUNC([is_term_resized])
6712 PY_CHECK_CURSES_FUNC([resize_term])
6713 PY_CHECK_CURSES_FUNC([resizeterm])
6714 PY_CHECK_CURSES_FUNC([immedok])
6715 PY_CHECK_CURSES_FUNC([syncok])
6716 PY_CHECK_CURSES_FUNC([wchgat])
6717 PY_CHECK_CURSES_FUNC([filter])
6718 PY_CHECK_CURSES_FUNC([has_key])
6719 PY_CHECK_CURSES_FUNC([typeahead])
6720 PY_CHECK_CURSES_FUNC([use_env])
6721 CPPFLAGS=$ac_save_cppflags
6723 AC_MSG_NOTICE([checking for device files])
6725 dnl NOTE: Inform user how to proceed with files when cross compiling.
6726 dnl Some cross-compile builds are predictable; they won't ever
6727 dnl have /dev/ptmx or /dev/ptc, so we can set them explicitly.
6728 if test "$ac_sys_system" = "Linux-android" || test "$ac_sys_system" = "iOS"; then
6729 ac_cv_file__dev_ptmx=no
6730 ac_cv_file__dev_ptc=no
6732 if test "x$cross_compiling" = xyes; then
6733 if test "${ac_cv_file__dev_ptmx+set}" != set; then
6734 AC_MSG_CHECKING([for /dev/ptmx])
6735 AC_MSG_RESULT([not set])
6736 AC_MSG_ERROR([set ac_cv_file__dev_ptmx to yes/no in your CONFIG_SITE file when cross compiling])
6738 if test "${ac_cv_file__dev_ptc+set}" != set; then
6739 AC_MSG_CHECKING([for /dev/ptc])
6740 AC_MSG_RESULT([not set])
6741 AC_MSG_ERROR([set ac_cv_file__dev_ptc to yes/no in your CONFIG_SITE file when cross compiling])
6745 AC_CHECK_FILE([/dev/ptmx], [], [])
6746 if test "x$ac_cv_file__dev_ptmx" = xyes; then
6747 AC_DEFINE([HAVE_DEV_PTMX], [1],
6748 [Define to 1 if you have the /dev/ptmx device file.])
6750 AC_CHECK_FILE([/dev/ptc], [], [])
6751 if test "x$ac_cv_file__dev_ptc" = xyes; then
6752 AC_DEFINE([HAVE_DEV_PTC], [1],
6753 [Define to 1 if you have the /dev/ptc device file.])
6757 if test $ac_sys_system = Darwin
6759 LIBS="$LIBS -framework CoreFoundation"
6762 AC_CHECK_TYPES([socklen_t], [],
6763 [AC_DEFINE([socklen_t], [int],
6764 [Define to 'int' if <sys/socket.h> does not define.])], [
6765 #ifdef HAVE_SYS_TYPES_H
6766 #include <sys/types.h>
6768 #ifdef HAVE_SYS_SOCKET_H
6769 #include <sys/socket.h>
6773 AC_CACHE_CHECK([for broken mbstowcs], [ac_cv_broken_mbstowcs],
6774 AC_RUN_IFELSE([AC_LANG_SOURCE([[
6780 const char *str = "text";
6781 len = mbstowcs(NULL, str, 0);
6785 [ac_cv_broken_mbstowcs=no],
6786 [ac_cv_broken_mbstowcs=yes],
6787 [ac_cv_broken_mbstowcs=no]))
6788 if test "$ac_cv_broken_mbstowcs" = yes
6790 AC_DEFINE([HAVE_BROKEN_MBSTOWCS], [1],
6791 [Define if mbstowcs(NULL, "text", 0) does not return the number of
6792 wide chars that would be converted.])
6795 # Check for --with-computed-gotos
6796 AC_MSG_CHECKING([for --with-computed-gotos])
6800 [--with-computed-gotos],
6801 [enable computed gotos in evaluation loop (enabled by default on supported compilers)]
6804 if test "$withval" = yes
6806 AC_DEFINE([USE_COMPUTED_GOTOS], [1],
6807 [Define if you want to use computed gotos in ceval.c.])
6808 AC_MSG_RESULT([yes])
6810 if test "$withval" = no
6812 AC_DEFINE([USE_COMPUTED_GOTOS], [0],
6813 [Define if you want to use computed gotos in ceval.c.])
6817 [AC_MSG_RESULT([no value specified])])
6819 AC_CACHE_CHECK([whether $CC supports computed gotos], [ac_cv_computed_gotos],
6820 AC_RUN_IFELSE([AC_LANG_SOURCE([[[
6821 int main(int argc, char **argv)
6823 static void *targets[1] = { &&LABEL1 };
6832 [ac_cv_computed_gotos=yes],
6833 [ac_cv_computed_gotos=no],
6834 [if test "${with_computed_gotos+set}" = set; then
6835 ac_cv_computed_gotos="$with_computed_gotos -- configured --with(out)-computed-gotos"
6837 ac_cv_computed_gotos=no
6839 case "$ac_cv_computed_gotos" in yes*)
6840 AC_DEFINE([HAVE_COMPUTED_GOTOS], [1],
6841 [Define if the C compiler supports computed gotos.])
6844 case $ac_sys_system in
6846 AC_DEFINE([HAVE_BROKEN_PIPE_BUF], [1],
6847 [Define if the system reports an invalid PIPE_BUF value.]) ;;
6851 AC_SUBST([THREADHEADERS])
6853 for h in `(cd $srcdir;echo Python/thread_*.h)`
6855 THREADHEADERS="$THREADHEADERS \$(srcdir)/$h"
6864 Modules/_decimal/libmpdec \
6867 Modules/_multiprocessing \
6871 Modules/_testinternalcapi \
6872 Modules/_testlimitedcapi \
6873 Modules/_xxtestfuzz \
6878 Objects/mimalloc/prim \
6884 Python/frozen_modules"
6885 AC_MSG_CHECKING([for build directories])
6886 for dir in $SRCDIRS; do
6887 if test ! -d $dir; then
6891 AC_MSG_RESULT([done])
6893 # Availability of -O2:
6894 AC_CACHE_CHECK([for -O2], [ac_cv_compile_o2], [
6895 saved_cflags="$CFLAGS"
6897 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [])], [ac_cv_compile_o2=yes], [ac_cv_compile_o2=no])
6898 CFLAGS="$saved_cflags"
6901 # _FORTIFY_SOURCE wrappers for memmove and bcopy are incorrect:
6902 # http://sourceware.org/ml/libc-alpha/2010-12/msg00009.html
6903 AC_MSG_CHECKING([for glibc _FORTIFY_SOURCE/memmove bug])
6904 saved_cflags="$CFLAGS"
6905 CFLAGS="-O2 -D_FORTIFY_SOURCE=2"
6906 if test "$ac_cv_compile_o2" = no; then
6909 AC_RUN_IFELSE([AC_LANG_SOURCE([[
6913 void foo(void *p, void *q) { memmove(p, q, 19); }
6915 char a[32] = "123456789000000000";
6917 if (strcmp(a, "123456789123456789000000000") != 0)
6920 if (strcmp(a, "123456789000000000") != 0)
6925 [have_glibc_memmove_bug=no],
6926 [have_glibc_memmove_bug=yes],
6927 [have_glibc_memmove_bug=undefined])
6928 CFLAGS="$saved_cflags"
6929 AC_MSG_RESULT([$have_glibc_memmove_bug])
6930 if test "$have_glibc_memmove_bug" = yes; then
6931 AC_DEFINE([HAVE_GLIBC_MEMMOVE_BUG], [1],
6932 [Define if glibc has incorrect _FORTIFY_SOURCE wrappers
6933 for memmove and bcopy.])
6936 if test "$ac_cv_gcc_asm_for_x87" = yes; then
6937 # Some versions of gcc miscompile inline asm:
6938 # http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46491
6939 # http://gcc.gnu.org/ml/gcc/2010-11/msg00366.html
6942 AC_MSG_CHECKING([for gcc ipa-pure-const bug])
6943 saved_cflags="$CFLAGS"
6945 AC_RUN_IFELSE([AC_LANG_SOURCE([[
6946 __attribute__((noinline)) int
6949 asm ( "movl \$6, (%1)\n\t"
6951 : "=r" (r) : "r" (p) : "memory"
6957 if ((foo(&p) ? : p) != 6)
6962 [have_ipa_pure_const_bug=no],
6963 [have_ipa_pure_const_bug=yes],
6964 [have_ipa_pure_const_bug=undefined])
6965 CFLAGS="$saved_cflags"
6966 AC_MSG_RESULT([$have_ipa_pure_const_bug])
6967 if test "$have_ipa_pure_const_bug" = yes; then
6968 AC_DEFINE([HAVE_IPA_PURE_CONST_BUG], [1],
6969 [Define if gcc has the ipa-pure-const bug.])
6976 AC_MSG_CHECKING([for ensurepip])
6977 AC_ARG_WITH([ensurepip],
6978 [AS_HELP_STRING([--with-ensurepip@<:@=install|upgrade|no@:>@],
6979 ["install" or "upgrade" using bundled pip (default is upgrade)])],
6982 AS_CASE([$ac_sys_system],
6983 [Emscripten], [with_ensurepip=no],
6984 [WASI], [with_ensurepip=no],
6985 [iOS], [with_ensurepip=no],
6986 [with_ensurepip=upgrade]
6989 AS_CASE([$with_ensurepip],
6990 [yes|upgrade],[ENSUREPIP=upgrade],
6991 [install],[ENSUREPIP=install],
6992 [no],[ENSUREPIP=no],
6993 [AC_MSG_ERROR([--with-ensurepip=upgrade|install|no])])
6994 AC_MSG_RESULT([$ENSUREPIP])
6995 AC_SUBST([ENSUREPIP])
6997 # check if the dirent structure of a d_type field and DT_UNKNOWN is defined
6998 AC_CACHE_CHECK([if the dirent structure of a d_type field], [ac_cv_dirent_d_type], [
7005 struct dirent entry;
7006 return entry.d_type == DT_UNKNOWN;
7009 ],[ac_cv_dirent_d_type=yes],[ac_cv_dirent_d_type=no])
7012 AS_VAR_IF([ac_cv_dirent_d_type], [yes], [
7013 AC_DEFINE([HAVE_DIRENT_D_TYPE], [1],
7014 [Define to 1 if the dirent structure has a d_type field])
7017 # check if the Linux getrandom() syscall is available
7018 AC_CACHE_CHECK([for the Linux getrandom() syscall], [ac_cv_getrandom_syscall], [
7024 #include <sys/syscall.h>
7025 #include <linux/random.h>
7029 const size_t buflen = sizeof(buffer);
7030 const int flags = GRND_NONBLOCK;
7031 /* ignore the result, Python checks for ENOSYS and EAGAIN at runtime */
7032 (void)syscall(SYS_getrandom, buffer, buflen, flags);
7036 ],[ac_cv_getrandom_syscall=yes],[ac_cv_getrandom_syscall=no])
7039 AS_VAR_IF([ac_cv_getrandom_syscall], [yes], [
7040 AC_DEFINE([HAVE_GETRANDOM_SYSCALL], [1],
7041 [Define to 1 if the Linux getrandom() syscall is available])
7044 # check if the getrandom() function is available
7045 # the test was written for the Solaris function of <sys/random.h>
7046 AC_CACHE_CHECK([for the getrandom() function], [ac_cv_func_getrandom], [
7051 #include <sys/random.h>
7055 const size_t buflen = sizeof(buffer);
7056 const int flags = 0;
7057 /* ignore the result, Python checks for ENOSYS at runtime */
7058 (void)getrandom(buffer, buflen, flags);
7062 ],[ac_cv_func_getrandom=yes],[ac_cv_func_getrandom=no])
7065 AS_VAR_IF([ac_cv_func_getrandom], [yes], [
7066 AC_DEFINE([HAVE_GETRANDOM], [1],
7067 [Define to 1 if the getrandom() function is available])
7070 # checks for POSIX shared memory, used by Modules/_multiprocessing/posixshmem.c
7071 # shm_* may only be available if linking against librt
7072 POSIXSHMEM_CFLAGS='-I$(srcdir)/Modules/_multiprocessing'
7074 AC_SEARCH_LIBS([shm_open], [rt])
7075 AS_VAR_IF([ac_cv_search_shm_open], [-lrt], [POSIXSHMEM_LIBS="-lrt"])
7077 dnl Temporarily override ac_includes_default for AC_CHECK_FUNCS below.
7078 _SAVE_VAR([ac_includes_default])
7079 ac_includes_default="\
7080 ${ac_includes_default}
7082 # ifdef HAVE_SYS_MMAN_H
7083 # include <sys/mman.h>
7087 AC_CHECK_FUNCS([shm_open shm_unlink], [have_posix_shmem=yes], [have_posix_shmem=no])
7088 _RESTORE_VAR([ac_includes_default])
7091 # Check for usable OpenSSL
7092 AX_CHECK_OPENSSL([have_openssl=yes],[have_openssl=no])
7094 # rpath to libssl and libcrypto
7095 AS_VAR_IF([GNULD], [yes], [
7096 rpath_arg="-Wl,--enable-new-dtags,-rpath="
7098 if test "$ac_sys_system" = "Darwin"
7100 rpath_arg="-Wl,-rpath,"
7102 rpath_arg="-Wl,-rpath="
7106 AC_MSG_CHECKING([for --with-openssl-rpath])
7107 AC_ARG_WITH([openssl-rpath],
7108 AS_HELP_STRING([--with-openssl-rpath=@<:@DIR|auto|no@:>@],
7109 [Set runtime library directory (rpath) for OpenSSL libraries,
7110 no (default): don't set rpath,
7111 auto: auto-detect rpath from --with-openssl and pkg-config,
7112 DIR: set an explicit rpath
7115 [with_openssl_rpath=no]
7117 AS_CASE([$with_openssl_rpath],
7120 dnl look for linker directories
7121 for arg in "$OPENSSL_LDFLAGS"; do
7123 [-L*], [OPENSSL_LDFLAGS_RPATH="$OPENSSL_LDFLAGS_RPATH ${rpath_arg}$(echo $arg | cut -c3-)"]
7127 [no], [OPENSSL_RPATH=],
7129 [test -d "$with_openssl_rpath"],
7131 OPENSSL_RPATH="$with_openssl_rpath"
7132 OPENSSL_LDFLAGS_RPATH="${rpath_arg}$with_openssl_rpath"
7134 AC_MSG_ERROR([--with-openssl-rpath "$with_openssl_rpath" is not a directory]))
7137 AC_MSG_RESULT([$OPENSSL_RPATH])
7139 # This static linking is NOT OFFICIALLY SUPPORTED and not advertised.
7140 # Requires static OpenSSL build with position-independent code. Some features
7141 # like DSO engines or external OSSL providers don't work. Only tested with GCC
7142 # and clang on X86_64.
7143 AS_VAR_IF([PY_UNSUPPORTED_OPENSSL_BUILD], [static], [
7144 AC_MSG_CHECKING([for unsupported static openssl build])
7146 for arg in $OPENSSL_LIBS; do
7149 libname=$(echo $arg | cut -c3-)
7150 new_OPENSSL_LIBS="$new_OPENSSL_LIBS -l:lib${libname}.a -Wl,--exclude-libs,lib${libname}.a"
7152 [new_OPENSSL_LIBS="$new_OPENSSL_LIBS $arg"]
7155 dnl include libz for OpenSSL build flavors with compression support
7156 OPENSSL_LIBS="$new_OPENSSL_LIBS $ZLIB_LIBS"
7157 AC_MSG_RESULT([$OPENSSL_LIBS])
7160 dnl AX_CHECK_OPENSSL does not export libcrypto-only libs
7162 for arg in $OPENSSL_LIBS; do
7164 [-l*ssl*|-Wl*ssl*], [],
7165 [LIBCRYPTO_LIBS="$LIBCRYPTO_LIBS $arg"]
7169 # check if OpenSSL libraries work as expected
7171 LIBS="$LIBS $OPENSSL_LIBS"
7172 CFLAGS="$CFLAGS $OPENSSL_INCLUDES"
7173 LDFLAGS="$LDFLAGS $OPENSSL_LDFLAGS $OPENSSL_LDFLAGS_RPATH"
7175 AC_CACHE_CHECK([whether OpenSSL provides required ssl module APIs], [ac_cv_working_openssl_ssl], [
7176 AC_LINK_IFELSE([AC_LANG_PROGRAM([
7177 #include <openssl/opensslv.h>
7178 #include <openssl/ssl.h>
7179 #if OPENSSL_VERSION_NUMBER < 0x10101000L
7180 #error "OpenSSL >= 1.1.1 is required"
7182 static void keylog_cb(const SSL *ssl, const char *line) {}
7184 SSL_CTX *ctx = SSL_CTX_new(TLS_client_method());
7185 SSL_CTX_set_keylog_callback(ctx, keylog_cb);
7186 SSL *ssl = SSL_new(ctx);
7187 X509_VERIFY_PARAM *param = SSL_get0_param(ssl);
7188 X509_VERIFY_PARAM_set1_host(param, "python.org", 0);
7191 ])], [ac_cv_working_openssl_ssl=yes], [ac_cv_working_openssl_ssl=no])
7196 LIBS="$LIBS $LIBCRYPTO_LIBS"
7197 CFLAGS="$CFLAGS $OPENSSL_INCLUDES"
7198 LDFLAGS="$LDFLAGS $OPENSSL_LDFLAGS $OPENSSL_LDFLAGS_RPATH"
7200 AC_CACHE_CHECK([whether OpenSSL provides required hashlib module APIs], [ac_cv_working_openssl_hashlib], [
7201 AC_LINK_IFELSE([AC_LANG_PROGRAM([
7202 #include <openssl/opensslv.h>
7203 #include <openssl/evp.h>
7204 #if OPENSSL_VERSION_NUMBER < 0x10101000L
7205 #error "OpenSSL >= 1.1.1 is required"
7208 OBJ_nid2sn(NID_md5);
7209 OBJ_nid2sn(NID_sha1);
7210 OBJ_nid2sn(NID_sha3_512);
7211 OBJ_nid2sn(NID_blake2b512);
7212 EVP_PBE_scrypt(NULL, 0, NULL, 0, 2, 8, 1, 0, NULL, 0);
7213 ])], [ac_cv_working_openssl_hashlib=yes], [ac_cv_working_openssl_hashlib=no])
7217 # ssl module default cipher suite string
7218 AH_TEMPLATE([PY_SSL_DEFAULT_CIPHERS],
7219 [Default cipher suites list for ssl module.
7220 1: Python's preferred selection, 2: leave OpenSSL defaults untouched, 0: custom string])
7221 AH_TEMPLATE([PY_SSL_DEFAULT_CIPHER_STRING],
7222 [Cipher suite string for PY_SSL_DEFAULT_CIPHERS=0]
7225 AC_MSG_CHECKING([for --with-ssl-default-suites])
7227 [ssl-default-suites],
7229 [--with-ssl-default-suites=@<:@python|openssl|STRING@:>@],
7230 [override default cipher suites string,
7231 python: use Python's preferred selection (default),
7232 openssl: leave OpenSSL's defaults untouched,
7233 STRING: use a custom string,
7234 python and STRING also set TLS 1.2 as minimum TLS version]
7237 AC_MSG_RESULT([$withval])
7240 AC_DEFINE([PY_SSL_DEFAULT_CIPHERS], [1])
7243 AC_DEFINE([PY_SSL_DEFAULT_CIPHERS], [2])
7246 AC_DEFINE([PY_SSL_DEFAULT_CIPHERS], [0])
7247 AC_DEFINE_UNQUOTED([PY_SSL_DEFAULT_CIPHER_STRING], ["$withval"])
7252 AC_MSG_RESULT([python])
7253 AC_DEFINE([PY_SSL_DEFAULT_CIPHERS], [1])
7256 # builtin hash modules
7257 default_hashlib_hashes="md5,sha1,sha2,sha3,blake2"
7258 AC_DEFINE([PY_BUILTIN_HASHLIB_HASHES], [], [enabled builtin hash modules]
7260 AC_MSG_CHECKING([for --with-builtin-hashlib-hashes])
7262 [builtin-hashlib-hashes],
7264 [--with-builtin-hashlib-hashes=md5,sha1,sha2,sha3,blake2],
7265 [builtin hash modules, md5, sha1, sha2, sha3 (with shake), blake2]
7268 AS_CASE([$with_builtin_hashlib_hashes],
7269 [yes], [with_builtin_hashlib_hashes=$default_hashlib_hashes],
7270 [no], [with_builtin_hashlib_hashes=""]
7272 ], [with_builtin_hashlib_hashes=$default_hashlib_hashes])
7274 AC_MSG_RESULT([$with_builtin_hashlib_hashes])
7275 AC_DEFINE_UNQUOTED([PY_BUILTIN_HASHLIB_HASHES],
7276 ["$with_builtin_hashlib_hashes"])
7280 for builtin_hash in $with_builtin_hashlib_hashes; do
7281 AS_CASE([$builtin_hash],
7282 [md5], [with_builtin_md5=yes],
7283 [sha1], [with_builtin_sha1=yes],
7284 [sha2], [with_builtin_sha2=yes],
7285 [sha3], [with_builtin_sha3=yes],
7286 [blake2], [with_builtin_blake2=yes]
7291 dnl libb2 for blake2. _blake2 module falls back to vendored copy.
7292 AS_VAR_IF([with_builtin_blake2], [yes], [
7293 PKG_CHECK_MODULES([LIBB2], [libb2], [
7295 AC_DEFINE([HAVE_LIBB2], [1],
7296 [Define to 1 if you want to build _blake2 module with libb2])
7300 # Check whether to disable test modules. Once set, setup.py will not build
7301 # test extension modules and "make install" will not install test suites.
7302 AC_MSG_CHECKING([for --disable-test-modules])
7303 AC_ARG_ENABLE([test-modules],
7304 [AS_HELP_STRING([--disable-test-modules], [don't build nor install test modules])], [
7305 AS_VAR_IF([enable_test_modules], [yes], [TEST_MODULES=yes], [TEST_MODULES=no])
7307 AS_CASE([$ac_sys_system/$ac_sys_emscripten_target],
7308 [Emscripten/browser*], [TEST_MODULES=no],
7312 AC_MSG_RESULT([$TEST_MODULES])
7313 AC_SUBST([TEST_MODULES])
7315 # gh-109054: Check if -latomic is needed to get <pyatomic.h> atomic functions.
7316 # On Linux aarch64, GCC may require programs and libraries to be linked
7317 # explicitly to libatomic. Call _Py_atomic_or_uint64() which may require
7318 # libatomic __atomic_fetch_or_8(), or not, depending on the C compiler and the
7321 # gh-112779: On RISC-V, GCC 12 and earlier require libatomic support for 1-byte
7322 # and 2-byte operations, but not for 8-byte operations.
7324 # Avoid #include <Python.h> or #include <pyport.h>. The <Python.h> header
7325 # requires <pyconfig.h> header which is only written below by AC_OUTPUT below.
7326 # If the check is done after AC_OUTPUT, modifying LIBS has no effect
7327 # anymore. <pyport.h> cannot be included alone, it's designed to be included
7328 # by <Python.h>: it expects other includes and macros to be defined.
7329 _SAVE_VAR([CPPFLAGS])
7330 CPPFLAGS="${BASECPPFLAGS} -I. -I${srcdir}/Include ${CPPFLAGS}"
7332 AC_CACHE_CHECK([whether libatomic is needed by <pyatomic.h>],
7333 [ac_cv_libatomic_needed],
7334 [AC_RUN_IFELSE([AC_LANG_SOURCE([[
7335 // pyatomic.h needs uint64_t and Py_ssize_t types
7336 #include <stdint.h> // int64_t, intptr_t
7337 #ifdef HAVE_SYS_TYPES_H
7338 # include <sys/types.h> // ssize_t
7340 // Code adapted from Include/pyport.h
7342 typedef ssize_t Py_ssize_t;
7343 #elif SIZEOF_VOID_P == SIZEOF_SIZE_T
7344 typedef intptr_t Py_ssize_t;
7346 # error "unable to define Py_ssize_t"
7349 #include "pyatomic.h"
7354 _Py_atomic_store_uint64(&value, 2);
7355 if (_Py_atomic_or_uint64(&value, 8) != 2) {
7358 if (_Py_atomic_load_uint64(&value) != 10) {
7361 uint8_t byte = 0xb8;
7362 if (_Py_atomic_or_uint8(&byte, 0x2d) != 0xb8) {
7365 if (_Py_atomic_load_uint8(&byte) != 0xbd) {
7368 return 0; // all good
7371 [ac_cv_libatomic_needed=no], dnl build succeeded
7372 [ac_cv_libatomic_needed=yes], dnl build failed
7373 [ac_cv_libatomic_needed=no]) dnl cross compilation
7376 AS_VAR_IF([ac_cv_libatomic_needed], [yes],
7377 [LIBS="${LIBS} -latomic"
7378 LIBATOMIC=${LIBATOMIC-"-latomic"}])
7379 _RESTORE_VAR([CPPFLAGS])
7383 AC_DEFUN([PY_STDLIB_MOD_SET_NA], [
7384 m4_foreach([mod], [$@], [
7385 AS_VAR_SET([py_cv_module_]mod, [n/a])])
7388 # stdlib not available
7389 dnl Modules that are not available on some platforms
7390 AS_CASE([$ac_sys_system],
7391 [AIX], [PY_STDLIB_MOD_SET_NA([_scproxy])],
7392 [VxWorks*], [PY_STDLIB_MOD_SET_NA([_scproxy], [termios], [grp])],
7393 dnl The _scproxy module is available on macOS
7396 dnl subprocess and multiprocessing are not supported (no fork syscall).
7397 dnl curses and tkinter user interface are not available.
7398 dnl gdbm and nis aren't available
7399 dnl Stub implementations are provided for pwd, grp etc APIs
7400 PY_STDLIB_MOD_SET_NA(
7417 [CYGWIN*], [PY_STDLIB_MOD_SET_NA([_scproxy])],
7418 [QNX*], [PY_STDLIB_MOD_SET_NA([_scproxy])],
7419 [FreeBSD*], [PY_STDLIB_MOD_SET_NA([_scproxy])],
7420 [Emscripten|WASI], [
7421 dnl subprocess and multiprocessing are not supported (no fork syscall).
7422 dnl curses and tkinter user interface are not available.
7423 dnl dbm and gdbm aren't available, too.
7424 dnl Emscripten and WASI provide only stubs for pwd, grp APIs.
7425 dnl resource functions (get/setrusage) are stubs, too.
7426 PY_STDLIB_MOD_SET_NA(
7444 AS_CASE([$ac_sys_system/$ac_sys_emscripten_target],
7445 [Emscripten/browser*], [
7446 dnl These modules are not particularly useful in browsers.
7447 PY_STDLIB_MOD_SET_NA(
7453 [Emscripten/node*], [],
7455 dnl WASI SDK 15.0 does not support file locking, mmap, and more.
7456 dnl Test modules that must be compiled as shared libraries are not supported
7457 dnl (see Modules/Setup.stdlib.in).
7458 PY_STDLIB_MOD_SET_NA(
7460 [_testexternalinspection],
7461 [_testimportmultiple],
7473 [PY_STDLIB_MOD_SET_NA([_scproxy])]
7476 dnl AC_MSG_NOTICE([m4_set_list([_PY_STDLIB_MOD_SET_NA])])
7478 dnl Default value for Modules/Setup.stdlib build type
7479 AS_CASE([$host_cpu],
7480 [wasm32|wasm64], [MODULE_BUILDTYPE=static],
7481 [MODULE_BUILDTYPE=${MODULE_BUILDTYPE:-shared}]
7483 AC_SUBST([MODULE_BUILDTYPE])
7485 dnl _MODULE_BLOCK_ADD([VAR], [VALUE])
7486 dnl internal: adds $1=quote($2) to MODULE_BLOCK
7487 AC_DEFUN([_MODULE_BLOCK_ADD], [AS_VAR_APPEND([MODULE_BLOCK], ["$1=_AS_QUOTE([$2])$as_nl"])])
7490 dnl Check for stdlib extension modules
7491 dnl PY_STDLIB_MOD([NAME], [ENABLED-TEST], [SUPPORTED-TEST], [CFLAGS], [LDFLAGS])
7492 dnl sets MODULE_$NAME_STATE based on PY_STDLIB_MOD_SET_NA(), ENABLED-TEST,
7493 dnl and SUPPORTED_TEST. ENABLED-TEST and SUPPORTED-TEST default to true if
7495 dnl n/a: marked unavailable on platform by PY_STDLIB_MOD_SET_NA()
7496 dnl yes: enabled and supported
7497 dnl missing: enabled and not supported
7498 dnl disabled: not enabled
7499 dnl sets MODULE_$NAME_CFLAGS and MODULE_$NAME_LDFLAGS
7500 AC_DEFUN([PY_STDLIB_MOD], [
7501 AC_MSG_CHECKING([for stdlib extension module $1])
7502 m4_pushdef([modcond], [MODULE_]m4_toupper([$1]))dnl
7503 m4_pushdef([modstate], [py_cv_module_$1])dnl
7504 dnl Check if module has been disabled by PY_STDLIB_MOD_SET_NA()
7505 AS_IF([test "$modstate" != "n/a"], [
7506 AS_IF([m4_ifblank([$2], [true], [$2])],
7507 [AS_IF([m4_ifblank([$3], [true], [$3])], [modstate=yes], [modstate=missing])],
7508 [modstate=disabled])
7510 _MODULE_BLOCK_ADD(modcond[_STATE], [$modstate])
7511 AS_VAR_IF([modstate], [yes], [
7512 m4_ifblank([$4], [], [_MODULE_BLOCK_ADD([MODULE_]m4_toupper([$1])[_CFLAGS], [$4])])
7513 m4_ifblank([$5], [], [_MODULE_BLOCK_ADD([MODULE_]m4_toupper([$1])[_LDFLAGS], [$5])])
7515 AM_CONDITIONAL(modcond, [test "$modstate" = yes])
7516 AC_MSG_RESULT([$modstate])
7517 m4_popdef([modcond])dnl
7518 m4_popdef([modstate])dnl
7521 dnl Define simple stdlib extension module
7522 dnl Always enable unless the module is disabled by PY_STDLIB_MOD_SET_NA
7523 dnl PY_STDLIB_MOD_SIMPLE([NAME], [CFLAGS], [LDFLAGS])
7524 dnl cflags and ldflags are optional
7525 AC_DEFUN([PY_STDLIB_MOD_SIMPLE], [
7526 m4_pushdef([modcond], [MODULE_]m4_toupper([$1]))dnl
7527 m4_pushdef([modstate], [py_cv_module_$1])dnl
7528 dnl Check if module has been disabled by PY_STDLIB_MOD_SET_NA()
7529 AS_IF([test "$modstate" != "n/a"], [modstate=yes])
7530 AM_CONDITIONAL(modcond, [test "$modstate" = yes])
7531 _MODULE_BLOCK_ADD(modcond[_STATE], [$modstate])
7532 AS_VAR_IF([modstate], [yes], [
7533 m4_ifblank([$2], [], [_MODULE_BLOCK_ADD([MODULE_]m4_toupper([$1])[_CFLAGS], [$2])])
7534 m4_ifblank([$3], [], [_MODULE_BLOCK_ADD([MODULE_]m4_toupper([$1])[_LDFLAGS], [$3])])
7536 m4_popdef([modcond])dnl
7537 m4_popdef([modstate])dnl
7540 dnl static modules in Modules/Setup.bootstrap
7541 PY_STDLIB_MOD_SIMPLE([_io], [-I\$(srcdir)/Modules/_io], [])
7542 PY_STDLIB_MOD_SIMPLE([time], [], [$TIMEMODULE_LIB])
7544 dnl always enabled extension modules
7545 PY_STDLIB_MOD_SIMPLE([array])
7546 PY_STDLIB_MOD_SIMPLE([_asyncio])
7547 PY_STDLIB_MOD_SIMPLE([_bisect])
7548 PY_STDLIB_MOD_SIMPLE([_contextvars])
7549 PY_STDLIB_MOD_SIMPLE([_csv])
7550 PY_STDLIB_MOD_SIMPLE([_heapq])
7551 PY_STDLIB_MOD_SIMPLE([_json])
7552 PY_STDLIB_MOD_SIMPLE([_lsprof])
7553 PY_STDLIB_MOD_SIMPLE([_opcode])
7554 PY_STDLIB_MOD_SIMPLE([_pickle])
7555 PY_STDLIB_MOD_SIMPLE([_posixsubprocess])
7556 PY_STDLIB_MOD_SIMPLE([_queue])
7557 PY_STDLIB_MOD_SIMPLE([_random])
7558 PY_STDLIB_MOD_SIMPLE([select])
7559 PY_STDLIB_MOD_SIMPLE([_struct])
7560 PY_STDLIB_MOD_SIMPLE([_typing])
7561 PY_STDLIB_MOD_SIMPLE([_interpreters])
7562 PY_STDLIB_MOD_SIMPLE([_interpchannels])
7563 PY_STDLIB_MOD_SIMPLE([_interpqueues])
7564 PY_STDLIB_MOD_SIMPLE([_zoneinfo])
7566 dnl multiprocessing modules
7567 PY_STDLIB_MOD([_multiprocessing],
7568 [], [test "$ac_cv_func_sem_unlink" = "yes"],
7569 [-I\$(srcdir)/Modules/_multiprocessing])
7570 PY_STDLIB_MOD([_posixshmem],
7571 [], [test "$have_posix_shmem" = "yes"],
7572 [$POSIXSHMEM_CFLAGS], [$POSIXSHMEM_LIBS])
7575 PY_STDLIB_MOD_SIMPLE([_statistics], [], [$LIBM])
7576 PY_STDLIB_MOD_SIMPLE([cmath], [], [$LIBM])
7577 PY_STDLIB_MOD_SIMPLE([math], [], [$LIBM])
7579 dnl needs libm and on some platforms librt
7580 PY_STDLIB_MOD_SIMPLE([_datetime], [], [$TIMEMODULE_LIB $LIBM])
7582 dnl modules with some unix dependencies
7583 PY_STDLIB_MOD([fcntl],
7584 [], [test "$ac_cv_header_sys_ioctl_h" = "yes" -a "$ac_cv_header_fcntl_h" = "yes"],
7586 PY_STDLIB_MOD([mmap],
7587 [], [test "$ac_cv_header_sys_mman_h" = "yes" -a "$ac_cv_header_sys_stat_h" = "yes"])
7588 PY_STDLIB_MOD([_socket],
7589 [], m4_flatten([test "$ac_cv_header_sys_socket_h" = "yes"
7590 -a "$ac_cv_header_sys_types_h" = "yes"
7591 -a "$ac_cv_header_netinet_in_h" = "yes"]))
7593 dnl platform specific extensions
7594 PY_STDLIB_MOD([grp], [],
7595 [test "$ac_cv_func_getgrent" = "yes" &&
7596 { test "$ac_cv_func_getgrgid" = "yes" || test "$ac_cv_func_getgrgid_r" = "yes"; }])
7597 PY_STDLIB_MOD([pwd], [], [test "$ac_cv_func_getpwuid" = yes -o "$ac_cv_func_getpwuid_r" = yes])
7598 PY_STDLIB_MOD([resource], [], [test "$ac_cv_header_sys_resource_h" = yes])
7599 PY_STDLIB_MOD([_scproxy],
7600 [test "$ac_sys_system" = "Darwin"], [],
7601 [], [-framework SystemConfiguration -framework CoreFoundation])
7602 PY_STDLIB_MOD([syslog], [], [test "$ac_cv_header_syslog_h" = yes])
7603 PY_STDLIB_MOD([termios], [], [test "$ac_cv_header_termios_h" = yes])
7605 dnl _elementtree loads libexpat via CAPI hook in pyexpat
7606 PY_STDLIB_MOD([pyexpat],
7607 [], [test "$ac_cv_header_sys_time_h" = "yes"],
7608 [$LIBEXPAT_CFLAGS], [$LIBEXPAT_LDFLAGS])
7609 PY_STDLIB_MOD([_elementtree], [], [], [$LIBEXPAT_CFLAGS], [])
7610 PY_STDLIB_MOD_SIMPLE([_codecs_cn])
7611 PY_STDLIB_MOD_SIMPLE([_codecs_hk])
7612 PY_STDLIB_MOD_SIMPLE([_codecs_iso2022])
7613 PY_STDLIB_MOD_SIMPLE([_codecs_jp])
7614 PY_STDLIB_MOD_SIMPLE([_codecs_kr])
7615 PY_STDLIB_MOD_SIMPLE([_codecs_tw])
7616 PY_STDLIB_MOD_SIMPLE([_multibytecodec])
7617 PY_STDLIB_MOD_SIMPLE([unicodedata])
7619 dnl By default we always compile these even when OpenSSL is available
7620 dnl (issue #14693). The modules are small.
7621 PY_STDLIB_MOD([_md5],
7622 [test "$with_builtin_md5" = yes], [],
7623 [-I\$(srcdir)/Modules/_hacl/include -I\$(srcdir)/Modules/_hacl/internal -D_BSD_SOURCE -D_DEFAULT_SOURCE])
7624 PY_STDLIB_MOD([_sha1],
7625 [test "$with_builtin_sha1" = yes], [],
7626 [-I\$(srcdir)/Modules/_hacl/include -I\$(srcdir)/Modules/_hacl/internal -D_BSD_SOURCE -D_DEFAULT_SOURCE])
7627 PY_STDLIB_MOD([_sha2],
7628 [test "$with_builtin_sha2" = yes], [],
7629 [-I\$(srcdir)/Modules/_hacl/include -I\$(srcdir)/Modules/_hacl/internal -D_BSD_SOURCE -D_DEFAULT_SOURCE])
7630 PY_STDLIB_MOD([_sha3], [test "$with_builtin_sha3" = yes])
7631 PY_STDLIB_MOD([_blake2],
7632 [test "$with_builtin_blake2" = yes], [],
7633 [$LIBB2_CFLAGS], [$LIBB2_LIBS])
7635 PY_STDLIB_MOD([_ctypes],
7636 [], [test "$have_libffi" = yes],
7637 [$NO_STRICT_OVERFLOW_CFLAGS $LIBFFI_CFLAGS], [$LIBFFI_LIBS])
7638 PY_STDLIB_MOD([_curses],
7639 [], [test "$have_curses" != "no"],
7640 [$CURSES_CFLAGS], [$CURSES_LIBS]
7642 PY_STDLIB_MOD([_curses_panel],
7643 [], [test "$have_panel" != "no"],
7644 [$PANEL_CFLAGS $CURSES_CFLAGS], [$PANEL_LIBS $CURSES_LIBS]
7646 PY_STDLIB_MOD([_decimal], [], [], [$LIBMPDEC_CFLAGS], [$LIBMPDEC_LDFLAGS])
7647 PY_STDLIB_MOD([_dbm],
7648 [test -n "$with_dbmliborder"], [test "$have_dbm" != "no"],
7649 [$DBM_CFLAGS], [$DBM_LIBS])
7650 PY_STDLIB_MOD([_gdbm],
7651 [test "$have_gdbm_dbmliborder" = yes], [test "$have_gdbm" = yes],
7652 [$GDBM_CFLAGS], [$GDBM_LIBS])
7653 PY_STDLIB_MOD([readline],
7654 [], [test "$with_readline" != "no"],
7655 [$READLINE_CFLAGS], [$READLINE_LIBS])
7656 PY_STDLIB_MOD([_sqlite3],
7657 [test "$have_sqlite3" = "yes"],
7658 [test "$have_supported_sqlite3" = "yes"],
7659 [$LIBSQLITE3_CFLAGS], [$LIBSQLITE3_LIBS])
7660 PY_STDLIB_MOD([_tkinter],
7661 [], [test "$have_tcltk" = "yes"],
7662 [$TCLTK_CFLAGS], [$TCLTK_LIBS])
7663 PY_STDLIB_MOD([_uuid],
7664 [], [test "$have_uuid" = "yes"],
7665 [$LIBUUID_CFLAGS], [$LIBUUID_LIBS])
7667 dnl compression libs
7668 PY_STDLIB_MOD([zlib], [], [test "$have_zlib" = yes],
7669 [$ZLIB_CFLAGS], [$ZLIB_LIBS])
7670 dnl binascii can use zlib for optimized crc32.
7671 PY_STDLIB_MOD_SIMPLE([binascii], [$BINASCII_CFLAGS], [$BINASCII_LIBS])
7672 PY_STDLIB_MOD([_bz2], [], [test "$have_bzip2" = yes],
7673 [$BZIP2_CFLAGS], [$BZIP2_LIBS])
7674 PY_STDLIB_MOD([_lzma], [], [test "$have_liblzma" = yes],
7675 [$LIBLZMA_CFLAGS], [$LIBLZMA_LIBS])
7677 dnl OpenSSL bindings
7678 PY_STDLIB_MOD([_ssl], [], [test "$ac_cv_working_openssl_ssl" = yes],
7679 [$OPENSSL_INCLUDES], [$OPENSSL_LDFLAGS $OPENSSL_LDFLAGS_RPATH $OPENSSL_LIBS])
7680 PY_STDLIB_MOD([_hashlib], [], [test "$ac_cv_working_openssl_hashlib" = yes],
7681 [$OPENSSL_INCLUDES], [$OPENSSL_LDFLAGS $OPENSSL_LDFLAGS_RPATH $LIBCRYPTO_LIBS])
7684 PY_STDLIB_MOD([_testcapi],
7685 [test "$TEST_MODULES" = yes],
7686 dnl Modules/_testcapi needs -latomic for 32bit AIX build
7687 [], [], [$LIBATOMIC])
7688 PY_STDLIB_MOD([_testclinic], [test "$TEST_MODULES" = yes])
7689 PY_STDLIB_MOD([_testclinic_limited], [test "$TEST_MODULES" = yes])
7690 PY_STDLIB_MOD([_testlimitedcapi], [test "$TEST_MODULES" = yes])
7691 PY_STDLIB_MOD([_testinternalcapi], [test "$TEST_MODULES" = yes])
7692 PY_STDLIB_MOD([_testbuffer], [test "$TEST_MODULES" = yes])
7693 PY_STDLIB_MOD([_testimportmultiple], [test "$TEST_MODULES" = yes], [test "$ac_cv_func_dlopen" = yes])
7694 PY_STDLIB_MOD([_testmultiphase], [test "$TEST_MODULES" = yes], [test "$ac_cv_func_dlopen" = yes])
7695 PY_STDLIB_MOD([_testsinglephase], [test "$TEST_MODULES" = yes], [test "$ac_cv_func_dlopen" = yes])
7696 PY_STDLIB_MOD([_testexternalinspection], [test "$TEST_MODULES" = yes])
7697 PY_STDLIB_MOD([xxsubtype], [test "$TEST_MODULES" = yes])
7698 PY_STDLIB_MOD([_xxtestfuzz], [test "$TEST_MODULES" = yes])
7699 PY_STDLIB_MOD([_ctypes_test],
7700 [test "$TEST_MODULES" = yes], [test "$have_libffi" = yes -a "$ac_cv_func_dlopen" = yes],
7703 dnl Limited API template modules.
7704 dnl Emscripten does not support shared libraries yet.
7705 PY_STDLIB_MOD([xxlimited], [test "$TEST_MODULES" = yes], [test "$ac_cv_func_dlopen" = yes])
7706 PY_STDLIB_MOD([xxlimited_35], [test "$TEST_MODULES" = yes], [test "$ac_cv_func_dlopen" = yes])
7708 # substitute multiline block, must come after last PY_STDLIB_MOD()
7709 AC_SUBST([MODULE_BLOCK])
7711 # generate output files
7712 AC_CONFIG_FILES(m4_normalize([
7715 Misc/python-embed.pc
7716 Misc/python-config.sh
7718 AC_CONFIG_FILES(m4_normalize([
7719 Modules/Setup.bootstrap
7720 Modules/Setup.stdlib
7722 AC_CONFIG_FILES([Modules/ld_so_aix], [chmod +x Modules/ld_so_aix])
7723 # Generate files like pyconfig.h
7726 AC_MSG_NOTICE([creating Modules/Setup.local])
7727 if test ! -f Modules/Setup.local
7729 echo "# Edit this file for local setup changes" >Modules/Setup.local
7732 AC_MSG_NOTICE([creating Makefile])
7733 $SHELL $srcdir/Modules/makesetup -c $srcdir/Modules/config.c.in \
7735 Modules/Setup.local Modules/Setup.stdlib Modules/Setup.bootstrap $srcdir/Modules/Setup
7736 if test $? -ne 0; then
7737 AC_MSG_ERROR([makesetup failed])
7742 if test -z "$PKG_CONFIG"; then
7743 AC_MSG_WARN([pkg-config is missing. Some dependencies may not be detected correctly.])
7746 if test "$Py_OPT" = 'false' -a "$Py_DEBUG" != 'true'; then
7749 If you want a release build with all stable optimizations active (PGO, etc),
7750 please run ./configure --enable-optimizations
7754 AS_VAR_IF([PY_SUPPORT_TIER], [0], [AC_MSG_WARN([
7756 Platform "$host" with compiler "$ac_cv_cc_name" is not supported by the
7757 CPython core team, see https://peps.python.org/pep-0011/ for more information.
7760 if test "$ac_cv_header_stdatomic_h" != "yes"; then
7761 AC_MSG_NOTICE(m4_normalize([
7762 Your compiler or platform does have a working C11 stdatomic.h. A future
7763 version of Python may require stdatomic.h.