]> git.ipfire.org Git - thirdparty/Python/cpython.git/blob - configure.ac
docs: clarify csv.DictReader's treatment of the first data row (#118549)
[thirdparty/Python/cpython.git] / configure.ac
1 dnl ************************************************************
2 dnl * Please run autoreconf -ivf -Werror to test your changes! *
3 dnl ************************************************************
4 dnl
5 dnl Python's configure script requires autoconf 2.71, autoconf-archive,
6 dnl aclocal 1.16, and pkg-config.
7 dnl
8 dnl It is recommended to use the Tools/build/regen-configure.sh shell script
9 dnl to regenerate the configure script.
10 dnl
11
12 # Set VERSION so we only need to edit in one place (i.e., here)
13 m4_define([PYTHON_VERSION], [3.13])
14
15 AC_PREREQ([2.71])
16
17 AC_INIT([python],[PYTHON_VERSION],[https://github.com/python/cpython/issues/])
18
19 m4_ifdef(
20 [AX_C_FLOAT_WORDS_BIGENDIAN],
21 [],
22 [AC_MSG_ERROR([Please install autoconf-archive package and re-run autoreconf])]
23 )dnl
24 m4_ifdef(
25 [PKG_PROG_PKG_CONFIG],
26 [],
27 [AC_MSG_ERROR([Please install pkgconf's m4 macro package and re-run autoreconf])]
28 )dnl
29
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
38 AC_DEFUN([SAVE_ENV],
39 [_SAVE_VAR([CFLAGS])]
40 [_SAVE_VAR([CPPFLAGS])]
41 [_SAVE_VAR([LDFLAGS])]
42 [_SAVE_VAR([LIBS])]
43 )dnl
44 AC_DEFUN([RESTORE_ENV],
45 [_RESTORE_VAR([CFLAGS])]
46 [_RESTORE_VAR([CPPFLAGS])]
47 [_RESTORE_VAR([LDFLAGS])]
48 [_RESTORE_VAR([LIBS])]
49 )dnl
50 AC_DEFUN([WITH_SAVE_ENV],
51 [SAVE_ENV]
52 [$1]
53 [RESTORE_ENV]
54 )dnl
55
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]))
60 AC_CACHE_CHECK(
61 [for $1],
62 [py_var],
63 [AC_COMPILE_IFELSE(
64 [AC_LANG_PROGRAM([$2], [void *x=$1])],
65 [AS_VAR_SET([py_var], [yes])],
66 [AS_VAR_SET([py_var], [no])])]
67 )
68 AS_VAR_IF(
69 [py_var],
70 [yes],
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])
74 ])
75
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])]
82 )
83
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"], [
91 py_cflags="$2"
92 py_libs="$2"
93 ])
94 AS_VAR_POPDEF([py_cflags])
95 AS_VAR_POPDEF([py_libs])
96 ])
97
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
107 # off.)
108 BASECPPFLAGS="-IObjects -IInclude -IPython"
109 else
110 BASECPPFLAGS=""
111 fi
112
113 AC_SUBST([GITVERSION])
114 AC_SUBST([GITTAG])
115 AC_SUBST([GITBRANCH])
116
117 if test -e $srcdir/.git
118 then
119 AC_CHECK_PROG([HAS_GIT], [git], [found], [not-found])
120 else
121 HAS_GIT=no-repository
122 fi
123 if test $HAS_GIT = found
124 then
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"
128 else
129 GITVERSION=""
130 GITTAG=""
131 GITBRANCH=""
132 fi
133
134 AC_CONFIG_SRCDIR([Include/object.h])
135 AC_CONFIG_HEADERS([pyconfig.h])
136
137 AC_CANONICAL_HOST
138 AC_SUBST([build])
139 AC_SUBST([host])
140
141 AS_VAR_IF([cross_compiling], [maybe],
142 [AC_MSG_ERROR([Cross compiling required --host=HOST-TUPLE and --build=ARCH])]
143 )
144
145 # pybuilddir.txt will be created by --generate-posix-vars in the Makefile
146 rm -f pybuilddir.txt
147
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[)])],
151 [
152 AC_MSG_CHECKING([for --with-build-python])
153
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"])])
156
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"])
159 fi
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)])
163 fi
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])
169 ], [
170 AS_VAR_IF([cross_compiling], [yes],
171 [AC_MSG_ERROR([Cross compiling requires --with-build-python])]
172 )
173 PYTHON_FOR_BUILD='./$(BUILDPYTHON) -E'
174 PYTHON_FOR_FREEZE="./_bootstrap_python"
175 ]
176 )
177 AC_SUBST([PYTHON_FOR_BUILD])
178
179 AC_MSG_CHECKING([for Python interpreter freezing])
180 AC_MSG_RESULT([$PYTHON_FOR_FREEZE])
181 AC_SUBST([PYTHON_FOR_FREEZE])
182
183 AS_VAR_IF([cross_compiling], [yes],
184 [
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=''
191 ],
192 [
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)'
199 ]
200 )
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])
206
207 AC_CHECK_PROGS([PYTHON_FOR_REGEN],
208 [python$PACKAGE_VERSION python3.13 python3.12 python3.11 python3.10 python3 python],
209 [python3])
210 AC_SUBST([PYTHON_FOR_REGEN])
211
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)])
215 else
216 AC_MSG_RESULT([missing])
217 fi
218
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.
222
223 dnl Last slash shouldn't be stripped if prefix=/
224 if test "$prefix" != "/"; then
225 prefix=`echo "$prefix" | sed -e 's/\/$//g'`
226 fi
227
228 dnl This is for stuff that absolutely must end up in pyconfig.h.
229 dnl Please use pyport.h instead, if possible.
230 AH_TOP([
231 #ifndef Py_PYCONFIG_H
232 #define Py_PYCONFIG_H
233 ])
234 AH_BOTTOM([
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 */
238 #endif
239
240 #endif /*Py_PYCONFIG_H*/
241 ])
242
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
246 rm confdefs.h
247 mv confdefs.h.new confdefs.h
248
249 AC_SUBST([VERSION])
250 VERSION=PYTHON_VERSION
251
252 # Version number of Python's own shared library file.
253 AC_SUBST([SOVERSION])
254 SOVERSION=1.0
255
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
258 # them.
259 AC_DEFINE([_NETBSD_SOURCE], [1],
260 [Define on NetBSD to activate all library features])
261
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
264 # them.
265 AC_DEFINE([__BSD_VISIBLE], [1],
266 [Define on FreeBSD to activate all library features])
267
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
270 # them.
271 AC_DEFINE([_DARWIN_C_SOURCE], [1],
272 [Define on Darwin to activate all library features])
273
274
275 define_xopen_source=yes
276
277 # Arguments passed to configure.
278 AC_SUBST([CONFIG_ARGS])
279 CONFIG_ARGS="$ac_configure_args"
280
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)])],
285 [],
286 [with_pkg_config=check]
287 )
288 AS_CASE([$with_pkg_config],
289 [yes|check], [
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])
295 fi
296 PKG_PROG_PKG_CONFIG
297 ],
298 [no], [
299 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=''
303 ],
304 [AC_MSG_ERROR([invalid argument --with-pkg-config=$with_pkg_config])]
305 )
306 if test "$with_pkg_config" = yes -a -z "$PKG_CONFIG"; then
307 AC_MSG_ERROR([pkg-config is required])]
308 fi
309
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"
314 then
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.
320 case "$host" in
321 *-*-linux-android*)
322 ac_sys_system=Linux-android
323 ;;
324 *-*-linux*)
325 ac_sys_system=Linux
326 ;;
327 *-*-cygwin*)
328 ac_sys_system=Cygwin
329 ;;
330 *-apple-ios*)
331 ac_sys_system=iOS
332 ;;
333 *-*-vxworks*)
334 ac_sys_system=VxWorks
335 ;;
336 *-*-emscripten)
337 ac_sys_system=Emscripten
338 ;;
339 *-*-wasi)
340 ac_sys_system=WASI
341 ;;
342 *)
343 # for now, limit cross builds to known configurations
344 MACHDEP="unknown"
345 AC_MSG_ERROR([cross build not supported for $host])
346 esac
347 ac_sys_release=
348 else
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`
353 else
354 ac_sys_release=`uname -r`
355 fi
356 fi
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"
362
363 case $MACHDEP in
364 aix*) MACHDEP="aix";;
365 linux-android*) MACHDEP="android";;
366 linux*) MACHDEP="linux";;
367 cygwin*) MACHDEP="cygwin";;
368 darwin*) MACHDEP="darwin";;
369 '') MACHDEP="unknown";;
370 esac
371
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.])
378 fi
379 fi
380 AC_MSG_RESULT(["$MACHDEP"])
381
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.
384 #
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
396 case "$host" in
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 ;;
400 *)
401 esac
402 fi
403 if test -z "$CC"; then
404 case "$host" in
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 ;;
408 *)
409 esac
410 fi
411 if test -z "$CPP"; then
412 case "$host" in
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 ;;
416 *)
417 esac
418 fi
419 if test -z "$CXX"; then
420 case "$host" in
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 ;;
424 *)
425 esac
426 fi
427
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)]),
434 [
435 case $enableval in
436 yes)
437 # Locate the best usable SDK, see Mac/README for more
438 # information
439 enableval="`/usr/bin/xcodebuild -version -sdk macosx Path 2>/dev/null`"
440 if ! ( echo $enableval | grep -E '\.sdk' 1>/dev/null )
441 then
442 enableval=/Developer/SDKs/MacOSX10.4u.sdk
443 if test ! -d "${enableval}"
444 then
445 enableval=/
446 fi
447 fi
448 ;;
449 esac
450 case $enableval in
451 no)
452 UNIVERSALSDK=
453 enable_universalsdk=
454 ;;
455 *)
456 UNIVERSALSDK=$enableval
457 if test ! -d "${UNIVERSALSDK}"
458 then
459 AC_MSG_ERROR([--enable-universalsdk specifies non-existing SDK: ${UNIVERSALSDK}])
460 fi
461 ;;
462 esac
463
464 ],[
465 UNIVERSALSDK=
466 enable_universalsdk=
467 ])
468 if test -n "${UNIVERSALSDK}"
469 then
470 AC_MSG_RESULT([${UNIVERSALSDK}])
471 else
472 AC_MSG_RESULT([no])
473 fi
474 AC_SUBST([UNIVERSALSDK])
475
476 AC_SUBST([ARCH_RUN_32BIT])
477 ARCH_RUN_32BIT=""
478
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"
483 then
484 if test -n "${UNIVERSALSDK}"
485 then
486 if test -z "`/usr/bin/file -L "${UNIVERSALSDK}/usr/lib/libSystem.dylib" | grep ppc`"
487 then
488 UNIVERSAL_ARCHS="intel"
489 fi
490 fi
491 fi
492
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]),
503 [
504 UNIVERSAL_ARCHS="$withval"
505 ],
506 [])
507 if test -n "${UNIVERSALSDK}"
508 then
509 AC_MSG_RESULT([${UNIVERSAL_ARCHS}])
510 else
511 AC_MSG_RESULT([no])
512 fi
513
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')]),
519 [
520 PYTHONFRAMEWORK=${withval}
521 PYTHONFRAMEWORKDIR=${withval}.framework
522 PYTHONFRAMEWORKIDENTIFIER=org.python.`echo $withval | tr '[A-Z]' '[a-z]'`
523 ],[
524 PYTHONFRAMEWORK=Python
525 PYTHONFRAMEWORKDIR=Python.framework
526 PYTHONFRAMEWORKIDENTIFIER=org.python.python
527 ])
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
533 (default is no)]),
534 [
535 case $enableval in
536 yes)
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])
541 esac
542 esac
543
544 case $enableval in
545 no)
546 case $ac_sys_system in
547 iOS) AC_MSG_ERROR([iOS builds must use --enable-framework]) ;;
548 *)
549 PYTHONFRAMEWORK=
550 PYTHONFRAMEWORKDIR=no-framework
551 PYTHONFRAMEWORKPREFIX=
552 PYTHONFRAMEWORKINSTALLDIR=
553 PYTHONFRAMEWORKINSTALLNAMEPREFIX=
554 RESSRCDIR=
555 FRAMEWORKINSTALLFIRST=
556 FRAMEWORKINSTALLLAST=
557 FRAMEWORKALTINSTALLFIRST=
558 FRAMEWORKALTINSTALLLAST=
559 FRAMEWORKPYTHONW=
560 INSTALLTARGETS="commoninstall bininstall maninstall"
561
562 if test "x${prefix}" = "xNONE"; then
563 FRAMEWORKUNIXTOOLSPREFIX="${ac_default_prefix}"
564 else
565 FRAMEWORKUNIXTOOLSPREFIX="${prefix}"
566 fi
567 enable_framework=
568 esac
569 ;;
570 *)
571 PYTHONFRAMEWORKPREFIX="${enableval}"
572 PYTHONFRAMEWORKINSTALLDIR=$PYTHONFRAMEWORKPREFIX/$PYTHONFRAMEWORKDIR
573
574 case $ac_sys_system in #(
575 Darwin) :
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"
583
584 if test "x${prefix}" = "xNONE" ; then
585 FRAMEWORKUNIXTOOLSPREFIX="${ac_default_prefix}"
586
587 else
588 FRAMEWORKUNIXTOOLSPREFIX="${prefix}"
589 fi
590
591 case "${enableval}" in
592 /System*)
593 FRAMEWORKINSTALLAPPSPREFIX="/Applications"
594 if test "${prefix}" = "NONE" ; then
595 # See below
596 FRAMEWORKUNIXTOOLSPREFIX="/usr"
597 fi
598 ;;
599
600 /Library*)
601 FRAMEWORKINSTALLAPPSPREFIX="/Applications"
602 ;;
603
604 */Library/Frameworks)
605 MDIR="`dirname "${enableval}"`"
606 MDIR="`dirname "${MDIR}"`"
607 FRAMEWORKINSTALLAPPSPREFIX="${MDIR}/Applications"
608
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}"
617 fi
618 ;;
619
620 *)
621 FRAMEWORKINSTALLAPPSPREFIX="/Applications"
622 ;;
623 esac
624
625 prefix=$PYTHONFRAMEWORKINSTALLDIR/Versions/$VERSION
626 PYTHONFRAMEWORKINSTALLNAMEPREFIX=${prefix}
627 RESSRCDIR=Mac/Resources/framework
628
629 # Add files for Mac specific code to the list of output
630 # files:
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])
635 ;;
636 iOS) :
637 FRAMEWORKINSTALLFIRST="frameworkinstallunversionedstructure"
638 FRAMEWORKALTINSTALLFIRST="frameworkinstallunversionedstructure "
639 FRAMEWORKINSTALLLAST="frameworkinstallmobileheaders"
640 FRAMEWORKALTINSTALLLAST="frameworkinstallmobileheaders"
641 FRAMEWORKPYTHONW=
642 INSTALLTARGETS="libinstall inclinstall sharedinstall"
643
644 prefix=$PYTHONFRAMEWORKPREFIX
645 PYTHONFRAMEWORKINSTALLNAMEPREFIX="@rpath/$PYTHONFRAMEWORKDIR"
646 RESSRCDIR=iOS/Resources
647
648 AC_CONFIG_FILES([iOS/Resources/Info.plist])
649 ;;
650 *)
651 AC_MSG_ERROR([Unknown platform for framework build])
652 ;;
653 esac
654 esac
655 ],[
656 case $ac_sys_system in
657 iOS) AC_MSG_ERROR([iOS builds must use --enable-framework]) ;;
658 *)
659 PYTHONFRAMEWORK=
660 PYTHONFRAMEWORKDIR=no-framework
661 PYTHONFRAMEWORKPREFIX=
662 PYTHONFRAMEWORKINSTALLDIR=
663 PYTHONFRAMEWORKINSTALLNAMEPREFIX=
664 RESSRCDIR=
665 FRAMEWORKINSTALLFIRST=
666 FRAMEWORKINSTALLLAST=
667 FRAMEWORKALTINSTALLFIRST=
668 FRAMEWORKALTINSTALLLAST=
669 FRAMEWORKPYTHONW=
670 INSTALLTARGETS="commoninstall bininstall maninstall"
671 if test "x${prefix}" = "xNONE" ; then
672 FRAMEWORKUNIXTOOLSPREFIX="${ac_default_prefix}"
673 else
674 FRAMEWORKUNIXTOOLSPREFIX="${prefix}"
675 fi
676 enable_framework=
677 esac
678 ])
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])
694
695 AC_DEFINE_UNQUOTED([_PYTHONFRAMEWORK], ["${PYTHONFRAMEWORK}"],
696 [framework name])
697
698 AC_SUBST([_PYTHON_HOST_PLATFORM])
699 if test "$cross_compiling" = yes; then
700 case "$host" in
701 *-*-linux*)
702 case "$host_cpu" in
703 arm*)
704 _host_ident=arm
705 ;;
706 *)
707 _host_ident=$host_cpu
708 esac
709 ;;
710 *-*-cygwin*)
711 _host_ident=
712 ;;
713 *-apple-ios*)
714 _host_os=`echo $host | cut -d '-' -f3`
715 _host_device=`echo $host | cut -d '-' -f4`
716 _host_device=${_host_device:=os}
717
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}
721
722 case "$host_cpu" in
723 aarch64)
724 _host_ident=${IPHONEOS_DEPLOYMENT_TARGET}-arm64-iphone${_host_device}
725 ;;
726 *)
727 _host_ident=${IPHONEOS_DEPLOYMENT_TARGET}-$host_cpu-iphone${_host_device}
728 ;;
729 esac
730 ;;
731 *-*-vxworks*)
732 _host_ident=$host_cpu
733 ;;
734 wasm32-*-* | wasm64-*-*)
735 _host_ident=$host_cpu
736 ;;
737 *)
738 # for now, limit cross builds to known configurations
739 MACHDEP="unknown"
740 AC_MSG_ERROR([cross build not supported for $host])
741 esac
742 _PYTHON_HOST_PLATFORM="$MACHDEP${_host_ident:+-$_host_ident}"
743 fi
744
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])
768 ;;
769 OpenBSD/*)
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])
775 ;;
776 # Defining _XOPEN_SOURCE on NetBSD version prior to the introduction of
777 # _NETBSD_SOURCE disables certain features (eg. setgroups). Reported by
778 # Marc Recht
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.
786 SunOS/*)
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.
795 SCO_SV/3.2)
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.
809 iOS/*)
810 define_xopen_source=no;;
811 # On QNX 6.3.2, defining _XOPEN_SOURCE prevents netdb.h from
812 # defining NI_NUMERICHOST.
813 QNX/6.3.2)
814 define_xopen_source=no
815 ;;
816 # On VxWorks, defining _XOPEN_SOURCE causes compile failures
817 # in network headers still using system V types.
818 VxWorks/*)
819 define_xopen_source=no
820 ;;
821
822 # On HP-UX, defining _XOPEN_SOURCE to 600 or greater hides
823 # chroot() and other functions
824 hp*|HP*)
825 define_xopen_source=no
826 ;;
827
828 esac
829
830 if test $define_xopen_source = yes
831 then
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])
835
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])
842
843 AC_DEFINE([_POSIX_C_SOURCE], [200809L],
844 [Define to activate features from IEEE Stds 1003.1-2008])
845 fi
846
847 # On HP-UX mbstate_t requires _INCLUDE__STDC_A1_SOURCE
848 case $ac_sys_system in
849 hp*|HP*)
850 define_stdc_a1=yes;;
851 *)
852 define_stdc_a1=no;;
853 esac
854
855 if test $define_stdc_a1 = yes
856 then
857 AC_DEFINE([_INCLUDE__STDC_A1_SOURCE], [1],
858 [Define to include mbstate_t for mbrtowc])
859 fi
860
861 # Record the configure-time value of MACOSX_DEPLOYMENT_TARGET,
862 # it may influence the way we can build extensions, so distutils
863 # needs to check it
864 AC_SUBST([CONFIGURE_MACOSX_DEPLOYMENT_TARGET])
865 AC_SUBST([EXPORT_MACOSX_DEPLOYMENT_TARGET])
866 CONFIGURE_MACOSX_DEPLOYMENT_TARGET=
867 EXPORT_MACOSX_DEPLOYMENT_TARGET='#'
868
869 # Record the value of IPHONEOS_DEPLOYMENT_TARGET enforced by the selected host triple.
870 AC_SUBST([IPHONEOS_DEPLOYMENT_TARGET])
871
872 # checks for alternative programs
873
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.
879
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"
882 then
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)])
885 fi
886
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
889 # we set -g later.
890 if test -z "$CFLAGS"; then
891 CFLAGS=
892 fi
893
894 dnl Emscripten SDK and WASI SDK default to wasm32.
895 dnl On Emscripten use MEMORY64 setting to build target wasm64-emscripten.
896 dnl for wasm64.
897 AS_CASE([$host],
898 [wasm64-*-emscripten], [
899 AS_VAR_APPEND([CFLAGS], [" -sMEMORY64=1"])
900 AS_VAR_APPEND([LDFLAGS], [" -sMEMORY64=1"])
901 ],
902 )
903
904 dnl Add the compiler flag for the iOS minimum supported OS version.
905 AS_CASE([$ac_sys_system],
906 [iOS], [
907 AS_VAR_APPEND([CFLAGS], [" -mios-version-min=${IPHONEOS_DEPLOYMENT_TARGET}"])
908 AS_VAR_APPEND([LDFLAGS], [" -mios-version-min=${IPHONEOS_DEPLOYMENT_TARGET}"])
909 ],
910 )
911
912 if test "$ac_sys_system" = "Darwin"
913 then
914 dnl look for SDKROOT
915 AC_CHECK_PROG([HAS_XCRUN], [xcrun], [yes], [missing])
916 AC_MSG_CHECKING([macOS SDKROOT])
917 if test -z "$SDKROOT"; then
918 dnl SDKROOT not set
919 if test "$HAS_XCRUN" = "yes"; then
920 dnl detect with Xcode
921 SDKROOT=$(xcrun --show-sdk-path)
922 else
923 dnl default to root
924 SDKROOT="/"
925 fi
926 fi
927 AC_MSG_RESULT([$SDKROOT])
928
929 # Compiler selection on MacOSX is more complicated than
930 # AC_PROG_CC can handle, see Mac/README for more
931 # information
932 if test -z "${CC}"
933 then
934 found_gcc=
935 found_clang=
936 as_save_IFS=$IFS; IFS=:
937 for as_dir in $PATH
938 do
939 IFS=$as_save_IFS
940 if test -x "${as_dir}/gcc"; then
941 if test -z "${found_gcc}"; then
942 found_gcc="${as_dir}/gcc"
943 fi
944 fi
945 if test -x "${as_dir}/clang"; then
946 if test -z "${found_clang}"; then
947 found_clang="${as_dir}/clang"
948 fi
949 fi
950 done
951 IFS=$as_save_IFS
952
953 if test -n "$found_gcc" -a -n "$found_clang"
954 then
955 if test -n "`"$found_gcc" --version | grep llvm-gcc`"
956 then
957 AC_MSG_NOTICE([Detected llvm-gcc, falling back to clang])
958 CC="$found_clang"
959 CXX="$found_clang++"
960 fi
961
962
963 elif test -z "$found_gcc" -a -n "$found_clang"
964 then
965 AC_MSG_NOTICE([No GCC found, use CLANG])
966 CC="$found_clang"
967 CXX="$found_clang++"
968
969 elif test -z "$found_gcc" -a -z "$found_clang"
970 then
971 found_clang=`/usr/bin/xcrun -find clang 2>/dev/null`
972 if test -n "${found_clang}"
973 then
974 AC_MSG_NOTICE([Using clang from Xcode.app])
975 CC="${found_clang}"
976 CXX="`/usr/bin/xcrun -find clang++`"
977
978 # else: use default behaviour
979 fi
980 fi
981 fi
982 fi
983 AC_PROG_CC
984 AC_PROG_CPP
985 AC_PROG_GREP
986 AC_PROG_SED
987 AC_PROG_EGREP
988
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__)
996 emcc
997 #elif defined(__INTEL_COMPILER) || defined(__ICC)
998 icc
999 #elif defined(__ibmxl__) || defined(__xlc__) || defined(__xlC__)
1000 xlc
1001 #elif defined(_MSC_VER)
1002 msvc
1003 #elif defined(__clang__)
1004 clang
1005 #elif defined(__GNUC__)
1006 gcc
1007 #else
1008 # error unknown compiler
1009 #endif
1010 EOF
1011
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"
1016 fi
1017 else
1018 ac_cv_cc_name="unknown"
1019 fi
1020 rm -f conftest.c conftest.out
1021 ])
1022
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
1027
1028 AC_CACHE_CHECK([for GCC compatible compiler],
1029 [ac_cv_gcc_compat],
1030 [AC_PREPROC_IFELSE([AC_LANG_SOURCE([
1031 #if !defined(__GNUC__)
1032 #error "not GCC compatible"
1033 #else
1034 /* GCC compatible! */
1035 #endif
1036 ], [])],
1037 [ac_cv_gcc_compat=yes],
1038 [ac_cv_gcc_compat=no])])
1039
1040 AC_SUBST([CXX])
1041
1042 preset_cxx="$CXX"
1043 if test -z "$CXX"
1044 then
1045 case "$CC" in
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]) ;;
1050 esac
1051 if test "$CXX" = "notfound"
1052 then
1053 CXX=""
1054 fi
1055 fi
1056 if test -z "$CXX"
1057 then
1058 AC_CHECK_TOOLS([CXX], [$CCC c++ g++ gcc CC cxx cc++ cl], [notfound])
1059 if test "$CXX" = "notfound"
1060 then
1061 CXX=""
1062 fi
1063 fi
1064 if test "$preset_cxx" != "$CXX"
1065 then
1066 AC_MSG_NOTICE([
1067
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.
1070 ])
1071 fi
1072
1073
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])
1079 else
1080 AC_MSG_RESULT([none])
1081 fi
1082 rm -f conftest.out
1083
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
1091 dnl platforms.
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)]
1098 )
1099 AC_SUBST([MULTIARCH])
1100
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])
1104 fi
1105 elif test x$PLATFORM_TRIPLET != x && test x$MULTIARCH = x; then
1106 MULTIARCH=$PLATFORM_TRIPLET
1107 fi
1108 AC_SUBST([PLATFORM_TRIPLET])
1109 AC_MSG_RESULT([$MULTIARCH])
1110
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]
1119 )
1120
1121 if test x$MULTIARCH != x; then
1122 MULTIARCH_CPPFLAGS="-DMULTIARCH=\\\"$MULTIARCH\\\""
1123 fi
1124 AC_SUBST([MULTIARCH_CPPFLAGS])
1125
1126 dnl Support tiers according to https://peps.python.org/pep-0011/
1127 dnl
1128 dnl NOTE: Windows support tiers are defined in PC/pyconfig.h.
1129 dnl
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
1137
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
1143
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
1151 [aarch64-*-linux-android/clang], [PY_SUPPORT_TIER=3], dnl Android on ARM64
1152 [x86_64-*-linux-android/clang], [PY_SUPPORT_TIER=3], dnl Android on AMD64
1153
1154 [PY_SUPPORT_TIER=0]
1155 )
1156
1157 AS_CASE([$PY_SUPPORT_TIER],
1158 [1], [AC_MSG_RESULT([$host/$ac_cv_cc_name has tier 1 (supported)])],
1159 [2], [AC_MSG_RESULT([$host/$ac_cv_cc_name has tier 2 (supported)])],
1160 [3], [AC_MSG_RESULT([$host/$ac_cv_cc_name has tier 3 (partially supported)])],
1161 [AC_MSG_WARN([$host/$ac_cv_cc_name is not supported])]
1162 )
1163
1164 AC_DEFINE_UNQUOTED([PY_SUPPORT_TIER], [$PY_SUPPORT_TIER], [PEP 11 Support tier (1, 2, 3 or 0 for unsupported)])
1165
1166 AC_CACHE_CHECK([for -Wl,--no-as-needed], [ac_cv_wl_no_as_needed], [
1167 save_LDFLAGS="$LDFLAGS"
1168 AS_VAR_APPEND([LDFLAGS], [" -Wl,--no-as-needed"])
1169 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
1170 [NO_AS_NEEDED="-Wl,--no-as-needed"
1171 ac_cv_wl_no_as_needed=yes],
1172 [NO_AS_NEEDED=""
1173 ac_cv_wl_no_as_needed=no])
1174 LDFLAGS="$save_LDFLAGS"
1175 ])
1176 AC_SUBST([NO_AS_NEEDED])
1177
1178 AC_MSG_CHECKING([for the Android API level])
1179 cat > conftest.c <<EOF
1180 #ifdef __ANDROID__
1181 android_api = __ANDROID_API__
1182 arm_arch = __ARM_ARCH
1183 #else
1184 #error not Android
1185 #endif
1186 EOF
1187
1188 if $CPP $CPPFLAGS conftest.c >conftest.out 2>/dev/null; then
1189 ANDROID_API_LEVEL=`sed -n -e '/__ANDROID_API__/d' -e 's/^android_api = //p' conftest.out`
1190 _arm_arch=`sed -n -e '/__ARM_ARCH/d' -e 's/^arm_arch = //p' conftest.out`
1191 AC_MSG_RESULT([$ANDROID_API_LEVEL])
1192 if test -z "$ANDROID_API_LEVEL"; then
1193 AC_MSG_ERROR([Fatal: you must define __ANDROID_API__])
1194 fi
1195 AC_DEFINE_UNQUOTED([ANDROID_API_LEVEL], [$ANDROID_API_LEVEL],
1196 [The Android API level.])
1197
1198 # For __android_log_write() in Python/pylifecycle.c.
1199 LIBS="$LIBS -llog"
1200
1201 AC_MSG_CHECKING([for the Android arm ABI])
1202 AC_MSG_RESULT([$_arm_arch])
1203 if test "$_arm_arch" = 7; then
1204 BASECFLAGS="${BASECFLAGS} -mfloat-abi=softfp -mfpu=vfpv3-d16"
1205 LDFLAGS="${LDFLAGS} -march=armv7-a -Wl,--fix-cortex-a8"
1206 fi
1207 else
1208 AC_MSG_RESULT([not Android])
1209 fi
1210 rm -f conftest.c conftest.out
1211
1212 # Check for unsupported systems
1213 AS_CASE([$ac_sys_system/$ac_sys_release],
1214 [atheos*|Linux*/1*], [
1215 AC_MSG_ERROR([m4_normalize([
1216 This system \($ac_sys_system/$ac_sys_release\) is no longer supported.
1217 See README for details.
1218 ])])
1219 ]
1220 )
1221
1222 AC_MSG_CHECKING([for --with-emscripten-target])
1223 AC_ARG_WITH([emscripten-target],
1224 [AS_HELP_STRING([--with-emscripten-target=@<:@browser|node@:>@], [Emscripten platform])],
1225 [
1226 AS_VAR_IF([ac_sys_system], [Emscripten], [
1227 AS_CASE([$with_emscripten_target],
1228 [browser], [ac_sys_emscripten_target=browser],
1229 [node], [ac_sys_emscripten_target=node],
1230 dnl Debug builds with source map / dwarf symbols. Py_DEBUG builds easily
1231 dnl run out of stack space. Detached sybmols and map prohibit some
1232 dnl optimizations and increase file size. Options are undocumented so we
1233 dnl are free to remove them in the future.
1234 [browser-debug], [ac_sys_emscripten_target=browser-debug],
1235 [node-debug], [ac_sys_emscripten_target=node-debug],
1236 [AC_MSG_ERROR([Invalid argument: --with-emscripten-target=browser|node])]
1237 )
1238 ], [
1239 AC_MSG_ERROR([--with-emscripten-target only applies to Emscripten])
1240 ])
1241 ], [
1242 AS_VAR_IF([ac_sys_system], [Emscripten], [ac_sys_emscripten_target=browser])
1243 ])
1244 AC_MSG_RESULT([$ac_sys_emscripten_target])
1245
1246 dnl On Emscripten dlopen() requires -s MAIN_MODULE and -fPIC. The flags
1247 dnl disables dead code elimination and increases the size of the WASM module
1248 dnl by about 1.5 to 2MB. MAIN_MODULE defines __wasm_mutable_globals__.
1249 dnl See https://emscripten.org/docs/compiling/Dynamic-Linking.html
1250 AC_MSG_CHECKING([for --enable-wasm-dynamic-linking])
1251 AC_ARG_ENABLE([wasm-dynamic-linking],
1252 [AS_HELP_STRING([--enable-wasm-dynamic-linking],
1253 [Enable dynamic linking support for WebAssembly (default is no)])],
1254 [
1255 AS_CASE([$ac_sys_system],
1256 [Emscripten], [],
1257 [WASI], [AC_MSG_ERROR([WASI dynamic linking is not implemented yet.])],
1258 [AC_MSG_ERROR([--enable-wasm-dynamic-linking only applies to Emscripten and WASI])]
1259 )
1260 ], [
1261 enable_wasm_dynamic_linking=missing
1262 ])
1263 AC_MSG_RESULT([$enable_wasm_dynamic_linking])
1264
1265 AC_MSG_CHECKING([for --enable-wasm-pthreads])
1266 AC_ARG_ENABLE([wasm-pthreads],
1267 [AS_HELP_STRING([--enable-wasm-pthreads],
1268 [Enable pthread emulation for WebAssembly (default is no)])],
1269 [
1270 AS_CASE([$ac_sys_system],
1271 [Emscripten], [],
1272 [WASI], [],
1273 [AC_MSG_ERROR([--enable-wasm-pthreads only applies to Emscripten and WASI])]
1274 )
1275 ], [
1276 enable_wasm_pthreads=missing
1277 ])
1278 AC_MSG_RESULT([$enable_wasm_pthreads])
1279
1280 AC_MSG_CHECKING([for --with-suffix])
1281 AC_ARG_WITH([suffix],
1282 [AS_HELP_STRING([--with-suffix=SUFFIX], [set executable suffix to SUFFIX (default is empty, yes is mapped to '.exe')])],
1283 [
1284 AS_CASE([$with_suffix],
1285 [no], [EXEEXT=],
1286 [yes], [EXEEXT=.exe],
1287 [EXEEXT=$with_suffix]
1288 )
1289 ], [
1290 AS_CASE([$ac_sys_system/$ac_sys_emscripten_target],
1291 [Emscripten/browser*], [EXEEXT=.js],
1292 [Emscripten/node*], [EXEEXT=.js],
1293 [WASI/*], [EXEEXT=.wasm],
1294 [EXEEXT=]
1295 )
1296 ])
1297 AC_MSG_RESULT([$EXEEXT])
1298
1299 # Test whether we're running on a non-case-sensitive system, in which
1300 # case we give a warning if no ext is given
1301 AC_SUBST([BUILDEXEEXT])
1302 AC_MSG_CHECKING([for case-insensitive build directory])
1303 if test ! -d CaseSensitiveTestDir; then
1304 mkdir CaseSensitiveTestDir
1305 fi
1306
1307 if test -d casesensitivetestdir && test -z "$EXEEXT"
1308 then
1309 AC_MSG_RESULT([yes])
1310 BUILDEXEEXT=.exe
1311 else
1312 AC_MSG_RESULT([no])
1313 BUILDEXEEXT=$EXEEXT
1314 fi
1315 rmdir CaseSensitiveTestDir
1316
1317 case $ac_sys_system in
1318 hp*|HP*)
1319 case $CC in
1320 cc|*/cc) CC="$CC -Ae";;
1321 esac;;
1322 esac
1323
1324 AC_SUBST([LIBRARY])
1325 AC_MSG_CHECKING([LIBRARY])
1326 if test -z "$LIBRARY"
1327 then
1328 LIBRARY='libpython$(VERSION)$(ABIFLAGS).a'
1329 fi
1330 AC_MSG_RESULT([$LIBRARY])
1331
1332 # LDLIBRARY is the name of the library to link against (as opposed to the
1333 # name of the library into which to insert object files). BLDLIBRARY is also
1334 # the library to link against, usually. On Mac OS X frameworks, BLDLIBRARY
1335 # is blank as the main program is not linked directly against LDLIBRARY.
1336 # LDLIBRARYDIR is the path to LDLIBRARY, which is made in a subdirectory. On
1337 # systems without shared libraries, LDLIBRARY is the same as LIBRARY
1338 # (defined in the Makefiles). On Cygwin LDLIBRARY is the import library,
1339 # DLLLIBRARY is the shared (i.e., DLL) library.
1340 #
1341 # RUNSHARED is used to run shared python without installed libraries
1342 #
1343 # INSTSONAME is the name of the shared library that will be use to install
1344 # on the system - some systems like version suffix, others don't
1345 #
1346 # LDVERSION is the shared library version number, normally the Python version
1347 # with the ABI build flags appended.
1348 AC_SUBST([LDLIBRARY])
1349 AC_SUBST([DLLLIBRARY])
1350 AC_SUBST([BLDLIBRARY])
1351 AC_SUBST([PY3LIBRARY])
1352 AC_SUBST([LDLIBRARYDIR])
1353 AC_SUBST([INSTSONAME])
1354 AC_SUBST([RUNSHARED])
1355 AC_SUBST([LDVERSION])
1356 LDLIBRARY="$LIBRARY"
1357 BLDLIBRARY='$(LDLIBRARY)'
1358 INSTSONAME='$(LDLIBRARY)'
1359 DLLLIBRARY=''
1360 LDLIBRARYDIR=''
1361 RUNSHARED=''
1362 LDVERSION="$VERSION"
1363
1364 # LINKCC is the command that links the python executable -- default is $(CC).
1365 # If CXX is set, and if it is needed to link a main function that was
1366 # compiled with CXX, LINKCC is CXX instead. Always using CXX is undesirable:
1367 # python might then depend on the C++ runtime
1368 AC_SUBST([LINKCC])
1369 AC_MSG_CHECKING([LINKCC])
1370 if test -z "$LINKCC"
1371 then
1372 LINKCC='$(PURIFY) $(CC)'
1373 case $ac_sys_system in
1374 QNX*)
1375 # qcc must be used because the other compilers do not
1376 # support -N.
1377 LINKCC=qcc;;
1378 esac
1379 fi
1380 AC_MSG_RESULT([$LINKCC])
1381
1382 # EXPORTSYMS holds the list of exported symbols for AIX.
1383 # EXPORTSFROM holds the module name exporting symbols on AIX.
1384 EXPORTSYMS=
1385 EXPORTSFROM=
1386 AC_SUBST([EXPORTSYMS])
1387 AC_SUBST([EXPORTSFROM])
1388 AC_MSG_CHECKING([EXPORTSYMS])
1389 case $ac_sys_system in
1390 AIX*)
1391 EXPORTSYMS="Modules/python.exp"
1392 EXPORTSFROM=. # the main executable
1393 ;;
1394 esac
1395 AC_MSG_RESULT([$EXPORTSYMS])
1396
1397 # GNULD is set to "yes" if the GNU linker is used. If this goes wrong
1398 # make sure we default having it set to "no": this is used by
1399 # distutils.unixccompiler to know if it should add --enable-new-dtags
1400 # to linker command lines, and failing to detect GNU ld simply results
1401 # in the same behaviour as before.
1402 AC_SUBST([GNULD])
1403 AC_MSG_CHECKING([for GNU ld])
1404 ac_prog=ld
1405 if test "$GCC" = yes; then
1406 ac_prog=`$CC -print-prog-name=ld`
1407 fi
1408 case `"$ac_prog" -V 2>&1 < /dev/null` in
1409 *GNU*)
1410 GNULD=yes;;
1411 *)
1412 GNULD=no;;
1413 esac
1414 AC_MSG_RESULT([$GNULD])
1415
1416 AC_MSG_CHECKING([for --enable-shared])
1417 AC_ARG_ENABLE([shared],
1418 AS_HELP_STRING([--enable-shared], [enable building a shared Python library (default is no)]))
1419
1420 if test -z "$enable_shared"
1421 then
1422 case $ac_sys_system in
1423 CYGWIN*)
1424 enable_shared="yes";;
1425 *)
1426 enable_shared="no";;
1427 esac
1428 fi
1429 AC_MSG_RESULT([$enable_shared])
1430
1431 # --with-static-libpython
1432 STATIC_LIBPYTHON=1
1433 AC_MSG_CHECKING([for --with-static-libpython])
1434 AC_ARG_WITH([static-libpython],
1435 AS_HELP_STRING([--without-static-libpython],
1436 [do not build libpythonMAJOR.MINOR.a and do not install python.o (default is yes)]),
1437 [
1438 if test "$withval" = no
1439 then
1440 AC_MSG_RESULT([no]);
1441 STATIC_LIBPYTHON=0
1442 else
1443 AC_MSG_RESULT([yes]);
1444 fi],
1445 [AC_MSG_RESULT([yes])])
1446 AC_SUBST([STATIC_LIBPYTHON])
1447
1448 AC_MSG_CHECKING([for --enable-profiling])
1449 AC_ARG_ENABLE([profiling],
1450 AS_HELP_STRING([--enable-profiling], [enable C-level code profiling with gprof (default is no)]))
1451 if test "x$enable_profiling" = xyes; then
1452 ac_save_cc="$CC"
1453 CC="$CC -pg"
1454 AC_LINK_IFELSE([AC_LANG_SOURCE([[int main(void) { return 0; }]])],
1455 [],
1456 [enable_profiling=no])
1457 CC="$ac_save_cc"
1458 else
1459 enable_profiling=no
1460 fi
1461 AC_MSG_RESULT([$enable_profiling])
1462
1463 if test "x$enable_profiling" = xyes; then
1464 BASECFLAGS="-pg $BASECFLAGS"
1465 LDFLAGS="-pg $LDFLAGS"
1466 fi
1467
1468 AC_MSG_CHECKING([LDLIBRARY])
1469
1470 # Apple framework builds need more magic. LDLIBRARY is the dynamic
1471 # library that we build, but we do not want to link against it (we
1472 # will find it with a -framework option). For this reason there is an
1473 # extra variable BLDLIBRARY against which Python and the extension
1474 # modules are linked, BLDLIBRARY. This is normally the same as
1475 # LDLIBRARY, but empty for MacOSX framework builds. iOS does the same,
1476 # but uses a non-versioned framework layout.
1477 if test "$enable_framework"
1478 then
1479 case $ac_sys_system in
1480 Darwin)
1481 LDLIBRARY='$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)';;
1482 iOS)
1483 LDLIBRARY='$(PYTHONFRAMEWORKDIR)/$(PYTHONFRAMEWORK)';;
1484 *)
1485 AC_MSG_ERROR([Unknown platform for framework build]);;
1486 esac
1487 BLDLIBRARY=''
1488 RUNSHARED=DYLD_FRAMEWORK_PATH=`pwd`${DYLD_FRAMEWORK_PATH:+:${DYLD_FRAMEWORK_PATH}}
1489 else
1490 BLDLIBRARY='$(LDLIBRARY)'
1491 fi
1492
1493 # Other platforms follow
1494 if test $enable_shared = "yes"; then
1495 PY_ENABLE_SHARED=1
1496 AC_DEFINE([Py_ENABLE_SHARED], [1],
1497 [Defined if Python is built as a shared library.])
1498 case $ac_sys_system in
1499 CYGWIN*)
1500 LDLIBRARY='libpython$(LDVERSION).dll.a'
1501 BLDLIBRARY='-L. -lpython$(LDVERSION)'
1502 DLLLIBRARY='libpython$(LDVERSION).dll'
1503 ;;
1504 SunOS*)
1505 LDLIBRARY='libpython$(LDVERSION).so'
1506 BLDLIBRARY='-Wl,-R,$(LIBDIR) -L. -lpython$(LDVERSION)'
1507 RUNSHARED=LD_LIBRARY_PATH=`pwd`${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
1508 INSTSONAME="$LDLIBRARY".$SOVERSION
1509 if test "$with_pydebug" != yes
1510 then
1511 PY3LIBRARY=libpython3.so
1512 fi
1513 ;;
1514 Linux*|GNU*|NetBSD*|FreeBSD*|DragonFly*|OpenBSD*|VxWorks*)
1515 LDLIBRARY='libpython$(LDVERSION).so'
1516 BLDLIBRARY='-L. -lpython$(LDVERSION)'
1517 RUNSHARED=LD_LIBRARY_PATH=`pwd`${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
1518
1519 # The Android Gradle plugin will only package libraries whose names end
1520 # with ".so".
1521 if test "$ac_sys_system" != "Linux-android"; then
1522 INSTSONAME="$LDLIBRARY".$SOVERSION
1523 fi
1524
1525 if test "$with_pydebug" != yes
1526 then
1527 PY3LIBRARY=libpython3.so
1528 fi
1529 ;;
1530 hp*|HP*)
1531 case `uname -m` in
1532 ia64)
1533 LDLIBRARY='libpython$(LDVERSION).so'
1534 ;;
1535 *)
1536 LDLIBRARY='libpython$(LDVERSION).sl'
1537 ;;
1538 esac
1539 BLDLIBRARY='-Wl,+b,$(LIBDIR) -L. -lpython$(LDVERSION)'
1540 RUNSHARED=SHLIB_PATH=`pwd`${SHLIB_PATH:+:${SHLIB_PATH}}
1541 ;;
1542 Darwin*)
1543 LDLIBRARY='libpython$(LDVERSION).dylib'
1544 BLDLIBRARY='-L. -lpython$(LDVERSION)'
1545 RUNSHARED=DYLD_LIBRARY_PATH=`pwd`${DYLD_LIBRARY_PATH:+:${DYLD_LIBRARY_PATH}}
1546 ;;
1547 iOS)
1548 LDLIBRARY='libpython$(LDVERSION).dylib'
1549 ;;
1550 AIX*)
1551 LDLIBRARY='libpython$(LDVERSION).so'
1552 RUNSHARED=LIBPATH=`pwd`${LIBPATH:+:${LIBPATH}}
1553 ;;
1554
1555 esac
1556 else # shared is disabled
1557 PY_ENABLE_SHARED=0
1558 case $ac_sys_system in
1559 CYGWIN*)
1560 BLDLIBRARY='$(LIBRARY)'
1561 LDLIBRARY='libpython$(LDVERSION).dll.a'
1562 ;;
1563 esac
1564 fi
1565 AC_MSG_RESULT([$LDLIBRARY])
1566
1567 if test "$cross_compiling" = yes; then
1568 RUNSHARED=
1569 fi
1570
1571 AC_MSG_CHECKING([HOSTRUNNER])
1572 AC_ARG_VAR([HOSTRUNNER], [Program to run CPython for the host platform])
1573 if test -z "$HOSTRUNNER"
1574 then
1575 AS_CASE([$ac_sys_system/$ac_sys_emscripten_target],
1576 [Emscripten/node*], [
1577 AC_PATH_TOOL([NODE], [node], [node])
1578 HOSTRUNNER="$NODE"
1579 # bigint for ctypes c_longlong, c_longdouble
1580 # no longer available in Node 16
1581 AC_CACHE_CHECK([for node --experimental-wasm-bigint], [ac_cv_tool_node_wasm_bigint], [
1582 if $NODE -v --experimental-wasm-bigint > /dev/null 2>&1; then
1583 ac_cv_tool_node_wasm_bigint=yes
1584 else
1585 ac_cv_tool_node_wasm_bigint=no
1586 fi
1587 ])
1588 AS_VAR_IF([ac_cv_tool_node_wasm_bigint], [yes], [
1589 AS_VAR_APPEND([HOSTRUNNER], [" --experimental-wasm-bigint"])
1590 ])
1591
1592 AS_VAR_IF([enable_wasm_pthreads], [yes], [
1593 AS_VAR_APPEND([HOSTRUNNER], [" --experimental-wasm-threads"])
1594 # no longer available in Node 16
1595 AC_CACHE_CHECK([for node --experimental-wasm-bulk-memory], [ac_cv_tool_node_wasm_bulk_memory], [
1596 if $NODE -v --experimental-wasm-bulk-memory > /dev/null 2>&1; then
1597 ac_cv_tool_node_wasm_bulk_memory=yes
1598 else
1599 ac_cv_tool_node_wasm_bulk_memory=no
1600 fi
1601 ])
1602 AS_VAR_IF([ac_cv_tool_node_wasm_bulk_memory], [yes], [
1603 AS_VAR_APPEND([HOSTRUNNER], [" --experimental-wasm-bulk-memory"])
1604 ])
1605 ])
1606
1607 AS_VAR_IF([host_cpu], [wasm64], [AS_VAR_APPEND([HOSTRUNNER], [" --experimental-wasm-memory64"])])
1608 ],
1609 dnl TODO: support other WASI runtimes
1610 dnl wasmtime starts the proces with "/" as CWD. For OOT builds add the
1611 dnl directory containing _sysconfigdata to PYTHONPATH.
1612 [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)::/'],
1613 [HOSTRUNNER='']
1614 )
1615 fi
1616 AC_SUBST([HOSTRUNNER])
1617 AC_MSG_RESULT([$HOSTRUNNER])
1618
1619 if test -n "$HOSTRUNNER"; then
1620 dnl Pass hostrunner variable as env var in order to expand shell expressions.
1621 PYTHON_FOR_BUILD="_PYTHON_HOSTRUNNER='$HOSTRUNNER' $PYTHON_FOR_BUILD"
1622 fi
1623
1624 # LIBRARY_DEPS, LINK_PYTHON_OBJS and LINK_PYTHON_DEPS variable
1625 AS_CASE([$ac_sys_system/$ac_sys_emscripten_target],
1626 [Emscripten/browser*], [LIBRARY_DEPS='$(PY3LIBRARY) $(WASM_STDLIB) python.html python.worker.js'],
1627 [LIBRARY_DEPS='$(PY3LIBRARY) $(EXPORTSYMS)']
1628 )
1629 LINK_PYTHON_DEPS='$(LIBRARY_DEPS)'
1630 if test "$PY_ENABLE_SHARED" = 1 || test "$enable_framework" ; then
1631 LIBRARY_DEPS="\$(LDLIBRARY) $LIBRARY_DEPS"
1632 if test "$STATIC_LIBPYTHON" = 1; then
1633 LIBRARY_DEPS="\$(LIBRARY) $LIBRARY_DEPS"
1634 fi
1635 # Link Python program to the shared library
1636 LINK_PYTHON_OBJS='$(BLDLIBRARY)'
1637 else
1638 if test "$STATIC_LIBPYTHON" = 0; then
1639 # Build Python needs object files but don't need to build
1640 # Python static library
1641 LINK_PYTHON_DEPS="$LIBRARY_DEPS \$(LIBRARY_OBJS)"
1642 fi
1643 LIBRARY_DEPS="\$(LIBRARY) $LIBRARY_DEPS"
1644 # Link Python program to object files
1645 LINK_PYTHON_OBJS='$(LIBRARY_OBJS)'
1646 fi
1647 AC_SUBST([LIBRARY_DEPS])
1648 AC_SUBST([LINK_PYTHON_DEPS])
1649 AC_SUBST([LINK_PYTHON_OBJS])
1650
1651 # ar program
1652 AC_SUBST([AR])
1653 AC_CHECK_TOOLS([AR], [ar aal], [ar])
1654
1655 # tweak ARFLAGS only if the user didn't set it on the command line
1656 AC_SUBST([ARFLAGS])
1657 if test -z "$ARFLAGS"
1658 then
1659 ARFLAGS="rcs"
1660 fi
1661
1662 case $MACHDEP in
1663 hp*|HP*)
1664 # install -d does not work on HP-UX
1665 if test -z "$INSTALL"
1666 then
1667 INSTALL="${srcdir}/install-sh -c"
1668 fi
1669 esac
1670 AC_PROG_INSTALL
1671 AC_PROG_MKDIR_P
1672
1673 # Not every filesystem supports hard links
1674 AC_SUBST([LN])
1675 if test -z "$LN" ; then
1676 case $ac_sys_system in
1677 CYGWIN*) LN="ln -s";;
1678 *) LN=ln;;
1679 esac
1680 fi
1681
1682 # For calculating the .so ABI tag.
1683 AC_SUBST([ABIFLAGS])
1684 ABIFLAGS=""
1685
1686 # Check for --disable-gil
1687 # --disable-gil
1688 AC_MSG_CHECKING([for --disable-gil])
1689 AC_ARG_ENABLE([gil],
1690 [AS_HELP_STRING([--disable-gil], [enable experimental support for running without the GIL (default is no)])],
1691 [AS_VAR_IF([enable_gil], [yes], [disable_gil=no], [disable_gil=yes])], [disable_gil=no]
1692 )
1693 AC_MSG_RESULT([$disable_gil])
1694
1695 if test "$disable_gil" = "yes"
1696 then
1697 AC_DEFINE([Py_GIL_DISABLED], [1],
1698 [Define if you want to disable the GIL])
1699 # Add "t" for "threaded"
1700 ABIFLAGS="${ABIFLAGS}t"
1701 fi
1702
1703 # Check for --with-pydebug
1704 AC_MSG_CHECKING([for --with-pydebug])
1705 AC_ARG_WITH([pydebug],
1706 [AS_HELP_STRING([--with-pydebug], [build with Py_DEBUG defined (default is no)]) ],
1707 [
1708 if test "$withval" != no
1709 then
1710 AC_DEFINE([Py_DEBUG], [1],
1711 [Define if you want to build an interpreter with many run-time checks.])
1712 AC_MSG_RESULT([yes]);
1713 Py_DEBUG='true'
1714 ABIFLAGS="${ABIFLAGS}d"
1715 else AC_MSG_RESULT([no]); Py_DEBUG='false'
1716 fi],
1717 [AC_MSG_RESULT([no])])
1718
1719 # Check for --with-trace-refs
1720 # --with-trace-refs
1721 AC_MSG_CHECKING([for --with-trace-refs])
1722 AC_ARG_WITH([trace-refs],
1723 [AS_HELP_STRING([--with-trace-refs], [enable tracing references for debugging purpose (default is no)])],
1724 [], [with_trace_refs=no]
1725 )
1726 AC_MSG_RESULT([$with_trace_refs])
1727
1728 if test "$with_trace_refs" = "yes"
1729 then
1730 AC_DEFINE([Py_TRACE_REFS], [1],
1731 [Define if you want to enable tracing references for debugging purpose])
1732 fi
1733
1734
1735 # Check for --enable-pystats
1736 AC_MSG_CHECKING([for --enable-pystats])
1737 AC_ARG_ENABLE([pystats],
1738 [AS_HELP_STRING(
1739 [--enable-pystats],
1740 [enable internal statistics gathering (default is no)]
1741 )],
1742 [], [enable_pystats=no]
1743 )
1744 AC_MSG_RESULT([$enable_pystats])
1745
1746 AS_VAR_IF([enable_pystats], [yes], [
1747 AC_DEFINE([Py_STATS], [1], [Define if you want to enable internal statistics gathering.])
1748 ])
1749
1750 # Check for --with-assertions.
1751 # This allows enabling assertions without Py_DEBUG.
1752 assertions='false'
1753 AC_MSG_CHECKING([for --with-assertions])
1754 AC_ARG_WITH([assertions],
1755 AS_HELP_STRING([--with-assertions],[build with C assertions enabled (default is no)]),
1756 [
1757 if test "$withval" != no
1758 then
1759 assertions='true'
1760 fi],
1761 [])
1762 if test "$assertions" = 'true'; then
1763 AC_MSG_RESULT([yes])
1764 elif test "$Py_DEBUG" = 'true'; then
1765 assertions='true'
1766 AC_MSG_RESULT([implied by --with-pydebug])
1767 else
1768 AC_MSG_RESULT([no])
1769 fi
1770
1771 # Check for --enable-experimental-jit:
1772 AC_MSG_CHECKING([for --enable-experimental-jit])
1773 AC_ARG_ENABLE([experimental-jit],
1774 [AS_HELP_STRING([--enable-experimental-jit@<:@=no|yes|yes-off|interpreter@:>@],
1775 [build the experimental just-in-time compiler (default is no)])],
1776 [],
1777 [enable_experimental_jit=no])
1778 case $enable_experimental_jit in
1779 no) jit_flags=""; tier2_flags="" ;;
1780 yes) jit_flags="-D_Py_JIT"; tier2_flags="-D_Py_TIER2=1" ;;
1781 yes-off) jit_flags="-D_Py_JIT"; tier2_flags="-D_Py_TIER2=3" ;;
1782 interpreter) jit_flags=""; tier2_flags="-D_Py_TIER2=4" ;;
1783 interpreter-off) jit_flags=""; tier2_flags="-D_Py_TIER2=6" ;; # Secret option
1784 *) AC_MSG_ERROR(
1785 [invalid argument: --enable-experimental-jit=$enable_experimental_jit; expected no|yes|yes-off|interpreter]) ;;
1786 esac
1787 AS_VAR_IF([tier2_flags],
1788 [],
1789 [],
1790 [AS_VAR_APPEND([CFLAGS_NODIST], [" $tier2_flags"])])
1791 AS_VAR_IF([jit_flags],
1792 [],
1793 [],
1794 [AS_VAR_APPEND([CFLAGS_NODIST], [" $jit_flags"])
1795 AS_VAR_SET([REGEN_JIT_COMMAND],
1796 ["\$(PYTHON_FOR_REGEN) \$(srcdir)/Tools/jit/build.py $host"])
1797 AS_VAR_SET([JIT_STENCILS_H], ["jit_stencils.h"])
1798 AS_VAR_IF([Py_DEBUG],
1799 [true],
1800 [AS_VAR_APPEND([REGEN_JIT_COMMAND], [" --debug"])],
1801 [])])
1802 AC_SUBST([REGEN_JIT_COMMAND])
1803 AC_SUBST([JIT_STENCILS_H])
1804 AC_MSG_RESULT([$tier2_flags $jit_flags])
1805
1806 # Enable optimization flags
1807 AC_SUBST([DEF_MAKE_ALL_RULE])
1808 AC_SUBST([DEF_MAKE_RULE])
1809 Py_OPT='false'
1810 AC_MSG_CHECKING([for --enable-optimizations])
1811 AC_ARG_ENABLE([optimizations], AS_HELP_STRING(
1812 [--enable-optimizations],
1813 [enable expensive, stable optimizations (PGO, etc.) (default is no)]),
1814 [
1815 if test "$enableval" != no
1816 then
1817 Py_OPT='true'
1818 AC_MSG_RESULT([yes]);
1819 else
1820 Py_OPT='false'
1821 AC_MSG_RESULT([no]);
1822 fi],
1823 [AC_MSG_RESULT([no])])
1824
1825 if test "$Py_OPT" = 'true' ; then
1826 # Intentionally not forcing Py_LTO='true' here. Too many toolchains do not
1827 # compile working code using it and both test_distutils and test_gdb are
1828 # broken when you do manage to get a toolchain that works with it. People
1829 # who want LTO need to use --with-lto themselves.
1830 DEF_MAKE_ALL_RULE="profile-opt"
1831 REQUIRE_PGO="yes"
1832 DEF_MAKE_RULE="build_all"
1833 case $CC in
1834 *gcc*)
1835 AX_CHECK_COMPILE_FLAG([-fno-semantic-interposition],[
1836 CFLAGS_NODIST="$CFLAGS_NODIST -fno-semantic-interposition"
1837 LDFLAGS_NODIST="$LDFLAGS_NODIST -fno-semantic-interposition"
1838 ], [], [-Werror])
1839 ;;
1840 esac
1841 elif test "$ac_sys_system" = "Emscripten" -o "$ac_sys_system" = "WASI"; then
1842 dnl Emscripten does not support shared extensions yet. Build
1843 dnl "python.[js,wasm]", "pybuilddir.txt", and "platform" files.
1844 DEF_MAKE_ALL_RULE="build_wasm"
1845 REQUIRE_PGO="no"
1846 DEF_MAKE_RULE="all"
1847 else
1848 DEF_MAKE_ALL_RULE="build_all"
1849 REQUIRE_PGO="no"
1850 DEF_MAKE_RULE="all"
1851 fi
1852
1853 AC_ARG_VAR([PROFILE_TASK], [Python args for PGO generation task])
1854 AC_MSG_CHECKING([PROFILE_TASK])
1855 if test -z "$PROFILE_TASK"
1856 then
1857 PROFILE_TASK='-m test --pgo --timeout=$(TESTTIMEOUT)'
1858 fi
1859 AC_MSG_RESULT([$PROFILE_TASK])
1860
1861 # Make llvm-related checks work on systems where llvm tools are not installed with their
1862 # normal names in the default $PATH (ie: Ubuntu). They exist under the
1863 # non-suffixed name in their versioned llvm directory.
1864
1865 llvm_bin_dir=''
1866 llvm_path="${PATH}"
1867 if test "${CC}" = "clang"
1868 then
1869 clang_bin=`which clang`
1870 # Some systems install clang elsewhere as a symlink to the real path
1871 # which is where the related llvm tools are located.
1872 if test -L "${clang_bin}"
1873 then
1874 clang_dir=`dirname "${clang_bin}"`
1875 clang_bin=`readlink "${clang_bin}"`
1876 llvm_bin_dir="${clang_dir}/"`dirname "${clang_bin}"`
1877 llvm_path="${llvm_path}${PATH_SEPARATOR}${llvm_bin_dir}"
1878 fi
1879 fi
1880
1881 # Enable LTO flags
1882 AC_MSG_CHECKING([for --with-lto])
1883 AC_ARG_WITH([lto],
1884 [AS_HELP_STRING([--with-lto=@<:@full|thin|no|yes@:>@], [enable Link-Time-Optimization in any build (default is no)])],
1885 [
1886 case "$withval" in
1887 full)
1888 Py_LTO='true'
1889 Py_LTO_POLICY='full'
1890 AC_MSG_RESULT([yes])
1891 ;;
1892 thin)
1893 Py_LTO='true'
1894 Py_LTO_POLICY='thin'
1895 AC_MSG_RESULT([yes])
1896 ;;
1897 yes)
1898 Py_LTO='true'
1899 Py_LTO_POLICY='default'
1900 AC_MSG_RESULT([yes])
1901 ;;
1902 no)
1903 Py_LTO='false'
1904 AC_MSG_RESULT([no])
1905 ;;
1906 *)
1907 Py_LTO='false'
1908 AC_MSG_ERROR([unknown lto option: '$withval'])
1909 ;;
1910 esac
1911 ],
1912 [AC_MSG_RESULT([no])])
1913 if test "$Py_LTO" = 'true' ; then
1914 case $CC in
1915 *clang*)
1916 LDFLAGS_NOLTO="-fno-lto"
1917 dnl Clang linker requires -flto in order to link objects with LTO information.
1918 dnl Thin LTO is faster and works for object files with full LTO information, too.
1919 AX_CHECK_COMPILE_FLAG([-flto=thin],[LDFLAGS_NOLTO="-flto=thin"],[LDFLAGS_NOLTO="-flto"])
1920 AC_SUBST([LLVM_AR])
1921 AC_PATH_TOOL([LLVM_AR], [llvm-ar], [''], [${llvm_path}])
1922 AC_SUBST([LLVM_AR_FOUND])
1923 if test -n "${LLVM_AR}" -a -x "${LLVM_AR}"
1924 then
1925 LLVM_AR_FOUND="found"
1926 else
1927 LLVM_AR_FOUND="not-found"
1928 fi
1929 if test "$ac_sys_system" = "Darwin" -a "${LLVM_AR_FOUND}" = "not-found"
1930 then
1931 # The Apple-supplied ar in Xcode or the Command Line Tools is apparently sufficient
1932 found_llvm_ar=`/usr/bin/xcrun -find ar 2>/dev/null`
1933 if test -n "${found_llvm_ar}"
1934 then
1935 LLVM_AR='/usr/bin/xcrun ar'
1936 LLVM_AR_FOUND=found
1937 AC_MSG_NOTICE([llvm-ar found via xcrun: ${LLVM_AR}])
1938 fi
1939 fi
1940 if test $LLVM_AR_FOUND = not-found
1941 then
1942 LLVM_PROFR_ERR=yes
1943 AC_MSG_ERROR([llvm-ar is required for a --with-lto build with clang but could not be found.])
1944 else
1945 LLVM_AR_ERR=no
1946 fi
1947 AR="${LLVM_AR}"
1948 case $ac_sys_system in
1949 Darwin*)
1950 # Any changes made here should be reflected in the GCC+Darwin case below
1951 if test $Py_LTO_POLICY = default
1952 then
1953 # Check that ThinLTO is accepted.
1954 AX_CHECK_COMPILE_FLAG([-flto=thin],[
1955 LTOFLAGS="-flto=thin -Wl,-export_dynamic -Wl,-object_path_lto,\"\$@\".lto"
1956 LTOCFLAGS="-flto=thin"
1957 ],[
1958 LTOFLAGS="-flto -Wl,-export_dynamic -Wl,-object_path_lto,\"\$@\".lto"
1959 LTOCFLAGS="-flto"
1960 ]
1961 )
1962 else
1963 LTOFLAGS="-flto=${Py_LTO_POLICY} -Wl,-export_dynamic -Wl,-object_path_lto,\"\$@\".lto"
1964 LTOCFLAGS="-flto=${Py_LTO_POLICY}"
1965 fi
1966 ;;
1967 *)
1968 if test $Py_LTO_POLICY = default
1969 then
1970 # Check that ThinLTO is accepted
1971 AX_CHECK_COMPILE_FLAG([-flto=thin],[LTOFLAGS="-flto=thin"],[LTOFLAGS="-flto"])
1972 else
1973 LTOFLAGS="-flto=${Py_LTO_POLICY}"
1974 fi
1975 ;;
1976 esac
1977 ;;
1978 *emcc*)
1979 if test "$Py_LTO_POLICY" != "default"; then
1980 AC_MSG_ERROR([emcc supports only default lto.])
1981 fi
1982 LTOFLAGS="-flto"
1983 LTOCFLAGS="-flto"
1984 ;;
1985 *gcc*)
1986 if test $Py_LTO_POLICY = thin
1987 then
1988 AC_MSG_ERROR([thin lto is not supported under gcc compiler.])
1989 fi
1990 dnl flag to disable lto during linking
1991 LDFLAGS_NOLTO="-fno-lto"
1992 case $ac_sys_system in
1993 Darwin*)
1994 LTOFLAGS="-flto -Wl,-export_dynamic -Wl,-object_path_lto,\"\$@\".lto"
1995 LTOCFLAGS="-flto"
1996 ;;
1997 *)
1998 LTOFLAGS="-flto -fuse-linker-plugin -ffat-lto-objects -flto-partition=none"
1999 ;;
2000 esac
2001 ;;
2002 esac
2003
2004 if test "$ac_cv_prog_cc_g" = "yes"
2005 then
2006 # bpo-30345: Add -g to LDFLAGS when compiling with LTO
2007 # to get debug symbols.
2008 LTOFLAGS="$LTOFLAGS -g"
2009 fi
2010
2011 CFLAGS_NODIST="$CFLAGS_NODIST ${LTOCFLAGS-$LTOFLAGS}"
2012 LDFLAGS_NODIST="$LDFLAGS_NODIST $LTOFLAGS"
2013 fi
2014
2015 # Enable PGO flags.
2016 AC_SUBST([PGO_PROF_GEN_FLAG])
2017 AC_SUBST([PGO_PROF_USE_FLAG])
2018 AC_SUBST([LLVM_PROF_MERGER])
2019 AC_SUBST([LLVM_PROF_FILE])
2020 AC_SUBST([LLVM_PROF_ERR])
2021 AC_SUBST([LLVM_PROFDATA])
2022 AC_PATH_TOOL([LLVM_PROFDATA], [llvm-profdata], [''], [${llvm_path}])
2023 AC_SUBST([LLVM_PROF_FOUND])
2024 if test -n "${LLVM_PROFDATA}" -a -x "${LLVM_PROFDATA}"
2025 then
2026 LLVM_PROF_FOUND="found"
2027 else
2028 LLVM_PROF_FOUND="not-found"
2029 fi
2030 if test "$ac_sys_system" = "Darwin" -a "${LLVM_PROF_FOUND}" = "not-found"
2031 then
2032 found_llvm_profdata=`/usr/bin/xcrun -find llvm-profdata 2>/dev/null`
2033 if test -n "${found_llvm_profdata}"
2034 then
2035 # llvm-profdata isn't directly in $PATH in some cases.
2036 # https://apple.stackexchange.com/questions/197053/
2037 LLVM_PROFDATA='/usr/bin/xcrun llvm-profdata'
2038 LLVM_PROF_FOUND=found
2039 AC_MSG_NOTICE([llvm-profdata found via xcrun: ${LLVM_PROFDATA}])
2040 fi
2041 fi
2042 LLVM_PROF_ERR=no
2043
2044 # GNU Autoconf recommends the use of expr instead of basename.
2045 AS_VAR_SET([CC_BASENAME], [$(expr "//$CC" : '.*/\(.*\)')])
2046 case "$CC_BASENAME" in
2047 *clang*)
2048 # Any changes made here should be reflected in the GCC+Darwin case below
2049 PGO_PROF_GEN_FLAG="-fprofile-instr-generate"
2050 PGO_PROF_USE_FLAG="-fprofile-instr-use=\"\$(shell pwd)/code.profclangd\""
2051 LLVM_PROF_MERGER=m4_normalize("
2052 ${LLVM_PROFDATA} merge
2053 -output=\"\$(shell pwd)/code.profclangd\"
2054 \"\$(shell pwd)\"/*.profclangr
2055 ")
2056 LLVM_PROF_FILE="LLVM_PROFILE_FILE=\"\$(shell pwd)/code-%p.profclangr\""
2057 if test $LLVM_PROF_FOUND = not-found
2058 then
2059 LLVM_PROF_ERR=yes
2060 if test "${REQUIRE_PGO}" = "yes"
2061 then
2062 AC_MSG_ERROR([llvm-profdata is required for a --enable-optimizations build but could not be found.])
2063 fi
2064 fi
2065 ;;
2066 *gcc*)
2067 case $ac_sys_system in
2068 Darwin*)
2069 PGO_PROF_GEN_FLAG="-fprofile-instr-generate"
2070 PGO_PROF_USE_FLAG="-fprofile-instr-use=\"\$(shell pwd)/code.profclangd\""
2071 LLVM_PROF_MERGER=m4_normalize("
2072 ${LLVM_PROFDATA} merge
2073 -output=\"\$(shell pwd)/code.profclangd\"
2074 \"\$(shell pwd)\"/*.profclangr
2075 ")
2076 LLVM_PROF_FILE="LLVM_PROFILE_FILE=\"\$(shell pwd)/code-%p.profclangr\""
2077 if test "${LLVM_PROF_FOUND}" = "not-found"
2078 then
2079 LLVM_PROF_ERR=yes
2080 if test "${REQUIRE_PGO}" = "yes"
2081 then
2082 AC_MSG_ERROR([llvm-profdata is required for a --enable-optimizations build but could not be found.])
2083 fi
2084 fi
2085 ;;
2086 *)
2087 PGO_PROF_GEN_FLAG="-fprofile-generate"
2088 PGO_PROF_USE_FLAG="-fprofile-use -fprofile-correction"
2089 LLVM_PROF_MERGER="true"
2090 LLVM_PROF_FILE=""
2091 ;;
2092 esac
2093 ;;
2094 *icc*)
2095 PGO_PROF_GEN_FLAG="-prof-gen"
2096 PGO_PROF_USE_FLAG="-prof-use"
2097 LLVM_PROF_MERGER="true"
2098 LLVM_PROF_FILE=""
2099 ;;
2100 esac
2101
2102 # BOLT optimization. Always configured after PGO since it always runs after PGO.
2103 Py_BOLT='false'
2104 AC_MSG_CHECKING([for --enable-bolt])
2105 AC_ARG_ENABLE([bolt], [AS_HELP_STRING(
2106 [--enable-bolt],
2107 [enable usage of the llvm-bolt post-link optimizer (default is no)])],
2108 [
2109 if test "$enableval" != no
2110 then
2111 Py_BOLT='true'
2112 AC_MSG_RESULT([yes]);
2113 else
2114 Py_BOLT='false'
2115 AC_MSG_RESULT([no]);
2116 fi],
2117 [AC_MSG_RESULT([no])])
2118
2119 AC_SUBST([PREBOLT_RULE])
2120 if test "$Py_BOLT" = 'true' ; then
2121 PREBOLT_RULE="${DEF_MAKE_ALL_RULE}"
2122 DEF_MAKE_ALL_RULE="bolt-opt"
2123 DEF_MAKE_RULE="build_all"
2124
2125 # -fno-reorder-blocks-and-partition is required for bolt to work.
2126 # Possibly GCC only.
2127 AX_CHECK_COMPILE_FLAG([-fno-reorder-blocks-and-partition],[
2128 CFLAGS_NODIST="$CFLAGS_NODIST -fno-reorder-blocks-and-partition"
2129 ])
2130
2131 # These flags are required for bolt to work:
2132 LDFLAGS_NODIST="$LDFLAGS_NODIST -Wl,--emit-relocs"
2133
2134 # These flags are required to get good performance from bolt:
2135 CFLAGS_NODIST="$CFLAGS_NODIST -fno-pie"
2136 # We want to add these no-pie flags to linking executables but not shared libraries:
2137 LINKCC="$LINKCC -fno-pie -no-pie"
2138 AC_SUBST([LLVM_BOLT])
2139 AC_PATH_TOOL([LLVM_BOLT], [llvm-bolt], [''], [${llvm_path}])
2140 if test -n "${LLVM_BOLT}" -a -x "${LLVM_BOLT}"
2141 then
2142 AC_MSG_RESULT(["Found llvm-bolt"])
2143 else
2144 AC_MSG_ERROR([llvm-bolt is required for a --enable-bolt build but could not be found.])
2145 fi
2146
2147 AC_SUBST([MERGE_FDATA])
2148 AC_PATH_TOOL([MERGE_FDATA], [merge-fdata], [''], [${llvm_path}])
2149 if test -n "${MERGE_FDATA}" -a -x "${MERGE_FDATA}"
2150 then
2151 AC_MSG_RESULT(["Found merge-fdata"])
2152 else
2153 AC_MSG_ERROR([merge-fdata is required for a --enable-bolt build but could not be found.])
2154 fi
2155 fi
2156
2157 dnl Enable BOLT of libpython if built.
2158 AC_SUBST([BOLT_BINARIES])
2159 BOLT_BINARIES='$(BUILDPYTHON)'
2160 AS_VAR_IF([enable_shared], [yes], [
2161 BOLT_BINARIES="${BOLT_BINARIES} \$(INSTSONAME)"
2162 ])
2163
2164 AC_ARG_VAR(
2165 [BOLT_INSTRUMENT_FLAGS],
2166 [Arguments to llvm-bolt when instrumenting binaries]
2167 )
2168 AC_MSG_CHECKING([BOLT_INSTRUMENT_FLAGS])
2169 if test -z "${BOLT_INSTRUMENT_FLAGS}"
2170 then
2171 BOLT_INSTRUMENT_FLAGS=
2172 fi
2173 AC_MSG_RESULT([$BOLT_INSTRUMENT_FLAGS])
2174
2175 AC_ARG_VAR(
2176 [BOLT_APPLY_FLAGS],
2177 [Arguments to llvm-bolt when creating a BOLT optimized binary]
2178 )
2179 AC_MSG_CHECKING([BOLT_APPLY_FLAGS])
2180 if test -z "${BOLT_APPLY_FLAGS}"
2181 then
2182 AS_VAR_SET(
2183 [BOLT_APPLY_FLAGS],
2184 [m4_normalize("
2185 -update-debug-sections
2186 -reorder-blocks=ext-tsp
2187 -reorder-functions=hfsort+
2188 -split-functions
2189 -icf=1
2190 -inline-all
2191 -split-eh
2192 -reorder-functions-use-hot-size
2193 -peepholes=none
2194 -jump-tables=aggressive
2195 -inline-ap
2196 -indirect-call-promotion=all
2197 -dyno-stats
2198 -use-gnu-stack
2199 -frame-opt=hot
2200 ")]
2201 )
2202 fi
2203 AC_MSG_RESULT([$BOLT_APPLY_FLAGS])
2204
2205 # XXX Shouldn't the code above that fiddles with BASECFLAGS and OPT be
2206 # merged with this chunk of code?
2207
2208 # Optimizer/debugger flags
2209 # ------------------------
2210 # (The following bit of code is complicated enough - please keep things
2211 # indented properly. Just pretend you're editing Python code. ;-)
2212
2213 # There are two parallel sets of case statements below, one that checks to
2214 # see if OPT was set and one that does BASECFLAGS setting based upon
2215 # compiler and platform. BASECFLAGS tweaks need to be made even if the
2216 # user set OPT.
2217
2218 case $CC in
2219 *clang*)
2220 cc_is_clang=1
2221 ;;
2222 *)
2223 if $CC --version 2>&1 | grep -q clang
2224 then
2225 cc_is_clang=1
2226 else
2227 cc_is_clang=
2228 fi
2229 esac
2230
2231 dnl Historically, some of our code assumed that signed integer overflow
2232 dnl is defined behaviour via twos-complement.
2233 dnl Set STRICT_OVERFLOW_CFLAGS and NO_STRICT_OVERFLOW_CFLAGS depending on compiler support.
2234 dnl Pass the latter to modules that depend on such behaviour.
2235 _SAVE_VAR([CFLAGS])
2236 CFLAGS="-fstrict-overflow -fno-strict-overflow"
2237 AC_CACHE_CHECK([if $CC supports -fstrict-overflow and -fno-strict-overflow],
2238 [ac_cv_cc_supports_fstrict_overflow],
2239 AC_COMPILE_IFELSE(
2240 [AC_LANG_PROGRAM([[]], [[]])],
2241 [ac_cv_cc_supports_fstrict_overflow=yes],
2242 [ac_cv_cc_supports_fstrict_overflow=no]
2243 )
2244 )
2245 _RESTORE_VAR([CFLAGS])
2246
2247 AS_VAR_IF([ac_cv_cc_supports_fstrict_overflow], [yes],
2248 [STRICT_OVERFLOW_CFLAGS="-fstrict-overflow"
2249 NO_STRICT_OVERFLOW_CFLAGS="-fno-strict-overflow"],
2250 [STRICT_OVERFLOW_CFLAGS=""
2251 NO_STRICT_OVERFLOW_CFLAGS=""])
2252
2253 AC_MSG_CHECKING([for --with-strict-overflow])
2254 AC_ARG_WITH([strict-overflow],
2255 AS_HELP_STRING(
2256 [--with-strict-overflow],
2257 [if 'yes', add -fstrict-overflow to CFLAGS, else add -fno-strict-overflow (default is no)]
2258 ),
2259 [
2260 AS_VAR_IF(
2261 [ac_cv_cc_supports_fstrict_overflow], [no],
2262 [AC_MSG_WARN([--with-strict-overflow=yes requires a compiler that supports -fstrict-overflow])],
2263 []
2264 )
2265 ],
2266 [with_strict_overflow=no]
2267 )
2268 AC_MSG_RESULT([$with_strict_overflow])
2269
2270 # Check if CC supports -Og optimization level
2271 _SAVE_VAR([CFLAGS])
2272 CFLAGS="-Og"
2273 AC_CACHE_CHECK([if $CC supports -Og optimization level],
2274 [ac_cv_cc_supports_og],
2275 AC_COMPILE_IFELSE(
2276 [
2277 AC_LANG_PROGRAM([[]], [[]])
2278 ],[
2279 ac_cv_cc_supports_og=yes
2280 ],[
2281 ac_cv_cc_supports_og=no
2282 ])
2283 )
2284 _RESTORE_VAR([CFLAGS])
2285
2286 # Optimization messes up debuggers, so turn it off for
2287 # debug builds.
2288 PYDEBUG_CFLAGS="-O0"
2289 AS_VAR_IF([ac_cv_cc_supports_og], [yes],
2290 [PYDEBUG_CFLAGS="-Og"])
2291
2292 # tweak OPT based on compiler and platform, only if the user didn't set
2293 # it on the command line
2294 AC_SUBST([OPT])
2295 AC_SUBST([CFLAGS_ALIASING])
2296 if test "${OPT-unset}" = "unset"
2297 then
2298 case $GCC in
2299 yes)
2300 if test -n "${cc_is_clang}"
2301 then
2302 # bpo-30104: disable strict aliasing to compile correctly dtoa.c,
2303 # see Makefile.pre.in for more information
2304 CFLAGS_ALIASING="-fno-strict-aliasing"
2305 fi
2306
2307 case $ac_cv_prog_cc_g in
2308 yes)
2309 if test "$Py_DEBUG" = 'true' ; then
2310 OPT="-g $PYDEBUG_CFLAGS -Wall"
2311 else
2312 OPT="-g -O3 -Wall"
2313 fi
2314 ;;
2315 *)
2316 OPT="-O3 -Wall"
2317 ;;
2318 esac
2319
2320 case $ac_sys_system in
2321 SCO_SV*) OPT="$OPT -m486 -DSCO5"
2322 ;;
2323 esac
2324 ;;
2325
2326 *)
2327 OPT="-O"
2328 ;;
2329 esac
2330 fi
2331
2332 # WASM flags
2333 AS_CASE([$ac_sys_system],
2334 [Emscripten], [
2335 dnl build with WASM debug info if either Py_DEBUG is set or the target is
2336 dnl node-debug or browser-debug.
2337 AS_VAR_IF([Py_DEBUG], [yes], [wasm_debug=yes], [wasm_debug=no])
2338
2339 dnl Start with 20 MB and allow to grow
2340 AS_VAR_APPEND([LDFLAGS_NODIST], [" -sALLOW_MEMORY_GROWTH -sTOTAL_MEMORY=20971520"])
2341
2342 dnl map int64_t and uint64_t to JS bigint
2343 AS_VAR_APPEND([LDFLAGS_NODIST], [" -sWASM_BIGINT"])
2344
2345 dnl Include file system support
2346 AS_VAR_APPEND([LDFLAGS_NODIST], [" -sFORCE_FILESYSTEM -lidbfs.js -lnodefs.js -lproxyfs.js -lworkerfs.js"])
2347
2348 AS_VAR_IF([enable_wasm_dynamic_linking], [yes], [
2349 AS_VAR_APPEND([LINKFORSHARED], [" -sMAIN_MODULE"])
2350 ])
2351
2352 AS_VAR_IF([enable_wasm_pthreads], [yes], [
2353 AS_VAR_APPEND([CFLAGS_NODIST], [" -pthread"])
2354 AS_VAR_APPEND([LDFLAGS_NODIST], [" -sUSE_PTHREADS"])
2355 AS_VAR_APPEND([LINKFORSHARED], [" -sPROXY_TO_PTHREAD"])
2356 ])
2357
2358 AS_CASE([$ac_sys_emscripten_target],
2359 [browser*], [
2360 AS_VAR_IF([ac_sys_emscripten_target], [browser-debug], [wasm_debug=yes])
2361 AS_VAR_APPEND([LINKFORSHARED], [" --preload-file=\$(WASM_ASSETS_DIR)"])
2362 WASM_ASSETS_DIR=".\$(prefix)"
2363 WASM_STDLIB="\$(WASM_ASSETS_DIR)/local/lib/python\$(VERSION)/os.py"
2364 dnl separate-dwarf does not seem to work in Chrome DevTools Support.
2365 WASM_LINKFORSHARED_DEBUG="-gsource-map --emit-symbol-map"
2366 ],
2367 [node*], [
2368 AS_VAR_IF([ac_sys_emscripten_target], [node-debug], [wasm_debug=yes])
2369 AS_VAR_APPEND([LDFLAGS_NODIST], [" -sALLOW_MEMORY_GROWTH -sNODERAWFS"])
2370 AS_VAR_APPEND([LINKFORSHARED], [" -sEXIT_RUNTIME"])
2371 WASM_LINKFORSHARED_DEBUG="-gseparate-dwarf --emit-symbol-map"
2372 ]
2373 )
2374
2375 AS_VAR_IF([wasm_debug], [yes], [
2376 AS_VAR_APPEND([LDFLAGS_NODIST], [" -sASSERTIONS"])
2377 AS_VAR_APPEND([LINKFORSHARED], [" $WASM_LINKFORSHARED_DEBUG"])
2378 ], [
2379 AS_VAR_APPEND([LINKFORSHARED], [" -O2 -g0"])
2380 ])
2381 ],
2382 [WASI], [
2383 AC_DEFINE([_WASI_EMULATED_SIGNAL], [1], [Define to 1 if you want to emulate signals on WASI])
2384 AC_DEFINE([_WASI_EMULATED_GETPID], [1], [Define to 1 if you want to emulate getpid() on WASI])
2385 AC_DEFINE([_WASI_EMULATED_PROCESS_CLOCKS], [1], [Define to 1 if you want to emulate process clocks on WASI])
2386 LIBS="$LIBS -lwasi-emulated-signal -lwasi-emulated-getpid -lwasi-emulated-process-clocks"
2387 echo "#define _WASI_EMULATED_SIGNAL 1" >> confdefs.h
2388
2389 AS_VAR_IF([enable_wasm_pthreads], [yes], [
2390 # Note: update CFLAGS because ac_compile/ac_link needs this too.
2391 # without this, configure fails to find pthread_create, sem_init,
2392 # etc because they are only available in the sysroot for
2393 # wasm32-wasi-threads.
2394 # Note: wasi-threads requires --import-memory.
2395 # Note: wasi requires --export-memory.
2396 # Note: --export-memory is implicit unless --import-memory is given
2397 # Note: this requires LLVM >= 16.
2398 AS_VAR_APPEND([CFLAGS], [" -target wasm32-wasi-threads -pthread"])
2399 AS_VAR_APPEND([CFLAGS_NODIST], [" -target wasm32-wasi-threads -pthread"])
2400 AS_VAR_APPEND([LDFLAGS_NODIST], [" -target wasm32-wasi-threads -pthread"])
2401 AS_VAR_APPEND([LDFLAGS_NODIST], [" -Wl,--import-memory"])
2402 AS_VAR_APPEND([LDFLAGS_NODIST], [" -Wl,--export-memory"])
2403 AS_VAR_APPEND([LDFLAGS_NODIST], [" -Wl,--max-memory=10485760"])
2404 ])
2405
2406 dnl gh-117645: Set the memory size to 20 MiB, the stack size to 8 MiB,
2407 dnl and move the stack first.
2408 dnl https://github.com/WebAssembly/wasi-libc/issues/233
2409 AS_VAR_APPEND([LDFLAGS_NODIST], [" -z stack-size=8388608 -Wl,--stack-first -Wl,--initial-memory=20971520"])
2410 ]
2411 )
2412
2413 AS_CASE([$enable_wasm_dynamic_linking],
2414 [yes], [ac_cv_func_dlopen=yes],
2415 [no], [ac_cv_func_dlopen=no],
2416 [missing], []
2417 )
2418
2419 AC_SUBST([BASECFLAGS])
2420 AC_SUBST([CFLAGS_NODIST])
2421 AC_SUBST([LDFLAGS_NODIST])
2422 AC_SUBST([LDFLAGS_NOLTO])
2423 AC_SUBST([WASM_ASSETS_DIR])
2424 AC_SUBST([WASM_STDLIB])
2425
2426 # The -arch flags for universal builds on macOS
2427 UNIVERSAL_ARCH_FLAGS=
2428 AC_SUBST([UNIVERSAL_ARCH_FLAGS])
2429
2430 dnl PY_CHECK_CC_WARNING(ENABLE, WARNING, [MSG])
2431 AC_DEFUN([PY_CHECK_CC_WARNING], [
2432 AS_VAR_PUSHDEF([py_var], [ac_cv_$1_]m4_normalize($2)[_warning])
2433 AC_CACHE_CHECK([m4_ifblank([$3], [if we can $1 $CC $2 warning], [$3])], [py_var], [
2434 AS_VAR_COPY([py_cflags], [CFLAGS])
2435 AS_VAR_APPEND([CFLAGS], ["-W$2 -Werror"])
2436 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
2437 [AS_VAR_SET([py_var], [yes])],
2438 [AS_VAR_SET([py_var], [no])])
2439 AS_VAR_COPY([CFLAGS], [py_cflags])
2440 ])
2441 AS_VAR_POPDEF([py_var])
2442 ])
2443
2444 # tweak BASECFLAGS based on compiler and platform
2445 AS_VAR_IF([with_strict_overflow], [yes],
2446 [BASECFLAGS="$BASECFLAGS $STRICT_OVERFLOW_CFLAGS"],
2447 [BASECFLAGS="$BASECFLAGS $NO_STRICT_OVERFLOW_CFLAGS"])
2448
2449 case $GCC in
2450 yes)
2451 CFLAGS_NODIST="$CFLAGS_NODIST -std=c11"
2452
2453 PY_CHECK_CC_WARNING([enable], [extra], [if we can add -Wextra])
2454 AS_VAR_IF([ac_cv_enable_extra_warning], [yes],
2455 [CFLAGS_NODIST="$CFLAGS_NODIST -Wextra"])
2456
2457 # Python doesn't violate C99 aliasing rules, but older versions of
2458 # GCC produce warnings for legal Python code. Enable
2459 # -fno-strict-aliasing on versions of GCC that support but produce
2460 # warnings. See Issue3326
2461 ac_save_cc="$CC"
2462 CC="$CC -fno-strict-aliasing"
2463 save_CFLAGS="$CFLAGS"
2464 AC_CACHE_CHECK([whether $CC accepts and needs -fno-strict-aliasing],
2465 [ac_cv_no_strict_aliasing],
2466 AC_COMPILE_IFELSE(
2467 [
2468 AC_LANG_PROGRAM([[]], [[]])
2469 ],[
2470 CC="$ac_save_cc -fstrict-aliasing"
2471 CFLAGS="$CFLAGS -Werror -Wstrict-aliasing"
2472 AC_COMPILE_IFELSE(
2473 [
2474 AC_LANG_PROGRAM([[void f(int **x) {}]],
2475 [[double *x; f((int **) &x);]])
2476 ],[
2477 ac_cv_no_strict_aliasing=no
2478 ],[
2479 ac_cv_no_strict_aliasing=yes
2480 ])
2481 ],[
2482 ac_cv_no_strict_aliasing=no
2483 ]))
2484 CFLAGS="$save_CFLAGS"
2485 CC="$ac_save_cc"
2486 AS_VAR_IF([ac_cv_no_strict_aliasing], [yes],
2487 [BASECFLAGS="$BASECFLAGS -fno-strict-aliasing"])
2488
2489 # ICC doesn't recognize the option, but only emits a warning
2490 ## XXX does it emit an unused result warning and can it be disabled?
2491 AS_CASE(["$CC_BASENAME"],
2492 [*icc*], [ac_cv_disable_unused_result_warning=no]
2493 [PY_CHECK_CC_WARNING([disable], [unused-result])])
2494 AS_VAR_IF([ac_cv_disable_unused_result_warning], [yes],
2495 [BASECFLAGS="$BASECFLAGS -Wno-unused-result"
2496 CFLAGS_NODIST="$CFLAGS_NODIST -Wno-unused-result"])
2497
2498 PY_CHECK_CC_WARNING([disable], [unused-parameter])
2499 AS_VAR_IF([ac_cv_disable_unused_parameter_warning], [yes],
2500 [CFLAGS_NODIST="$CFLAGS_NODIST -Wno-unused-parameter"])
2501
2502 PY_CHECK_CC_WARNING([disable], [int-conversion])
2503 AS_VAR_IF([ac_cv_disable_int_conversion], [yes],
2504 [CFLAGS_NODIST="$CFLAGS_NODIST -Wno-int-conversion"])
2505
2506 PY_CHECK_CC_WARNING([disable], [missing-field-initializers])
2507 AS_VAR_IF([ac_cv_disable_missing_field_initializers_warning], [yes],
2508 [CFLAGS_NODIST="$CFLAGS_NODIST -Wno-missing-field-initializers"])
2509
2510 PY_CHECK_CC_WARNING([enable], [sign-compare])
2511 AS_VAR_IF([ac_cv_enable_sign_compare_warning], [yes],
2512 [BASECFLAGS="$BASECFLAGS -Wsign-compare"])
2513
2514 PY_CHECK_CC_WARNING([enable], [unreachable-code])
2515 # Don't enable unreachable code warning in debug mode, since it usually
2516 # results in non-standard code paths.
2517 # Issue #24324: Unfortunately, the unreachable code warning does not work
2518 # correctly on gcc and has been silently removed from the compiler.
2519 # It is supported on clang but on OS X systems gcc may be an alias
2520 # for clang. Try to determine if the compiler is not really gcc and,
2521 # if so, only then enable the warning.
2522 if test $ac_cv_enable_unreachable_code_warning = yes && \
2523 test "$Py_DEBUG" != "true" && \
2524 test -z "`$CC --version 2>/dev/null | grep 'Free Software Foundation'`"
2525 then
2526 BASECFLAGS="$BASECFLAGS -Wunreachable-code"
2527 else
2528 ac_cv_enable_unreachable_code_warning=no
2529 fi
2530
2531 PY_CHECK_CC_WARNING([enable], [strict-prototypes])
2532 AS_VAR_IF([ac_cv_enable_strict_prototypes_warning], [yes],
2533 [CFLAGS_NODIST="$CFLAGS_NODIST -Wstrict-prototypes"])
2534
2535 ac_save_cc="$CC"
2536 CC="$CC -Werror=implicit-function-declaration"
2537 AC_CACHE_CHECK([if we can make implicit function declaration an error in $CC],
2538 [ac_cv_enable_implicit_function_declaration_error],
2539 AC_COMPILE_IFELSE(
2540 [
2541 AC_LANG_PROGRAM([[]], [[]])
2542 ],[
2543 ac_cv_enable_implicit_function_declaration_error=yes
2544 ],[
2545 ac_cv_enable_implicit_function_declaration_error=no
2546 ]))
2547 CC="$ac_save_cc"
2548
2549 AS_VAR_IF([ac_cv_enable_implicit_function_declaration_error], [yes],
2550 [CFLAGS_NODIST="$CFLAGS_NODIST -Werror=implicit-function-declaration"])
2551
2552 ac_save_cc="$CC"
2553 CC="$CC -fvisibility=hidden"
2554 AC_CACHE_CHECK([if we can use visibility in $CC], [ac_cv_enable_visibility],
2555 AC_COMPILE_IFELSE(
2556 [
2557 AC_LANG_PROGRAM([[]], [[]])
2558 ],[
2559 ac_cv_enable_visibility=yes
2560 ],[
2561 ac_cv_enable_visibility=no
2562 ]))
2563 CC="$ac_save_cc"
2564
2565 AS_VAR_IF([ac_cv_enable_visibility], [yes],
2566 [CFLAGS_NODIST="$CFLAGS_NODIST -fvisibility=hidden"])
2567
2568 # if using gcc on alpha, use -mieee to get (near) full IEEE 754
2569 # support. Without this, treatment of subnormals doesn't follow
2570 # the standard.
2571 case $host in
2572 alpha*)
2573 BASECFLAGS="$BASECFLAGS -mieee"
2574 ;;
2575 esac
2576
2577 case $ac_sys_system in
2578 SCO_SV*)
2579 BASECFLAGS="$BASECFLAGS -m486 -DSCO5"
2580 ;;
2581
2582 Darwin*)
2583 # -Wno-long-double, -no-cpp-precomp, and -mno-fused-madd
2584 # used to be here, but non-Apple gcc doesn't accept them.
2585 if test "${CC}" = gcc
2586 then
2587 AC_MSG_CHECKING([which compiler should be used])
2588 case "${UNIVERSALSDK}" in
2589 */MacOSX10.4u.sdk)
2590 # Build using 10.4 SDK, force usage of gcc when the
2591 # compiler is gcc, otherwise the user will get very
2592 # confusing error messages when building on OSX 10.6
2593 CC=gcc-4.0
2594 CPP=cpp-4.0
2595 ;;
2596 esac
2597 AC_MSG_RESULT([$CC])
2598 fi
2599
2600 LIPO_INTEL64_FLAGS=""
2601 if test "${enable_universalsdk}"
2602 then
2603 case "$UNIVERSAL_ARCHS" in
2604 32-bit)
2605 UNIVERSAL_ARCH_FLAGS="-arch ppc -arch i386"
2606 LIPO_32BIT_FLAGS=""
2607 ARCH_RUN_32BIT=""
2608 ;;
2609 64-bit)
2610 UNIVERSAL_ARCH_FLAGS="-arch ppc64 -arch x86_64"
2611 LIPO_32BIT_FLAGS=""
2612 ARCH_RUN_32BIT="true"
2613 ;;
2614 all)
2615 UNIVERSAL_ARCH_FLAGS="-arch i386 -arch ppc -arch ppc64 -arch x86_64"
2616 LIPO_32BIT_FLAGS="-extract ppc7400 -extract i386"
2617 ARCH_RUN_32BIT="/usr/bin/arch -i386 -ppc"
2618 ;;
2619 universal2)
2620 UNIVERSAL_ARCH_FLAGS="-arch arm64 -arch x86_64"
2621 LIPO_32BIT_FLAGS=""
2622 LIPO_INTEL64_FLAGS="-extract x86_64"
2623 ARCH_RUN_32BIT="true"
2624 ;;
2625 intel)
2626 UNIVERSAL_ARCH_FLAGS="-arch i386 -arch x86_64"
2627 LIPO_32BIT_FLAGS="-extract i386"
2628 ARCH_RUN_32BIT="/usr/bin/arch -i386"
2629 ;;
2630 intel-32)
2631 UNIVERSAL_ARCH_FLAGS="-arch i386"
2632 LIPO_32BIT_FLAGS=""
2633 ARCH_RUN_32BIT=""
2634 ;;
2635 intel-64)
2636 UNIVERSAL_ARCH_FLAGS="-arch x86_64"
2637 LIPO_32BIT_FLAGS=""
2638 ARCH_RUN_32BIT="true"
2639 ;;
2640 3-way)
2641 UNIVERSAL_ARCH_FLAGS="-arch i386 -arch ppc -arch x86_64"
2642 LIPO_32BIT_FLAGS="-extract ppc7400 -extract i386"
2643 ARCH_RUN_32BIT="/usr/bin/arch -i386 -ppc"
2644 ;;
2645 *)
2646 AC_MSG_ERROR([proper usage is --with-universal-arch=universal2|32-bit|64-bit|all|intel|3-way])
2647 ;;
2648 esac
2649
2650 if test "${UNIVERSALSDK}" != "/"
2651 then
2652 CFLAGS="${UNIVERSAL_ARCH_FLAGS} -isysroot ${UNIVERSALSDK} ${CFLAGS}"
2653 LDFLAGS="${UNIVERSAL_ARCH_FLAGS} -isysroot ${UNIVERSALSDK} ${LDFLAGS}"
2654 CPPFLAGS="-isysroot ${UNIVERSALSDK} ${CPPFLAGS}"
2655 else
2656 CFLAGS="${UNIVERSAL_ARCH_FLAGS} ${CFLAGS}"
2657 LDFLAGS="${UNIVERSAL_ARCH_FLAGS} ${LDFLAGS}"
2658 fi
2659 fi
2660
2661 # Calculate an appropriate deployment target for this build:
2662 # The deployment target value is used explicitly to enable certain
2663 # features are enabled (such as builtin libedit support for readline)
2664 # through the use of Apple's Availability Macros and is used as a
2665 # component of the string returned by distutils.get_platform().
2666 #
2667 # Use the value from:
2668 # 1. the MACOSX_DEPLOYMENT_TARGET environment variable if specified
2669 # 2. the operating system version of the build machine if >= 10.6
2670 # 3. If running on OS X 10.3 through 10.5, use the legacy tests
2671 # below to pick either 10.3, 10.4, or 10.5 as the target.
2672 # 4. If we are running on OS X 10.2 or earlier, good luck!
2673
2674 AC_MSG_CHECKING([which MACOSX_DEPLOYMENT_TARGET to use])
2675 cur_target_major=`sw_vers -productVersion | \
2676 sed 's/\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'`
2677 cur_target_minor=`sw_vers -productVersion | \
2678 sed 's/\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'`
2679 cur_target="${cur_target_major}.${cur_target_minor}"
2680 if test ${cur_target_major} -eq 10 && \
2681 test ${cur_target_minor} -ge 3 && \
2682 test ${cur_target_minor} -le 5
2683 then
2684 # OS X 10.3 through 10.5
2685 cur_target=10.3
2686 if test ${enable_universalsdk}
2687 then
2688 case "$UNIVERSAL_ARCHS" in
2689 all|3-way|intel|64-bit)
2690 # These configurations were first supported in 10.5
2691 cur_target='10.5'
2692 ;;
2693 esac
2694 else
2695 if test `/usr/bin/arch` = "i386"
2696 then
2697 # 10.4 was the first release to support Intel archs
2698 cur_target="10.4"
2699 fi
2700 fi
2701 fi
2702 CONFIGURE_MACOSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET-${cur_target}}
2703
2704 # Make sure that MACOSX_DEPLOYMENT_TARGET is set in the
2705 # environment with a value that is the same as what we'll use
2706 # in the Makefile to ensure that we'll get the same compiler
2707 # environment during configure and build time.
2708 MACOSX_DEPLOYMENT_TARGET="$CONFIGURE_MACOSX_DEPLOYMENT_TARGET"
2709 export MACOSX_DEPLOYMENT_TARGET
2710 EXPORT_MACOSX_DEPLOYMENT_TARGET=''
2711 AC_MSG_RESULT([$MACOSX_DEPLOYMENT_TARGET])
2712
2713 AC_MSG_CHECKING([if specified universal architectures work])
2714 AC_LINK_IFELSE([AC_LANG_PROGRAM([[@%:@include <stdio.h>]], [[printf("%d", 42);]])],
2715 [AC_MSG_RESULT([yes])],
2716 [AC_MSG_RESULT([no])
2717 AC_MSG_ERROR([check config.log and use the '--with-universal-archs' option])
2718 ])
2719
2720 # end of Darwin* tests
2721 ;;
2722 esac
2723 ;;
2724
2725 *)
2726 case $ac_sys_system in
2727 OpenUNIX*|UnixWare*)
2728 BASECFLAGS="$BASECFLAGS -K pentium,host,inline,loop_unroll,alloca "
2729 ;;
2730 SCO_SV*)
2731 BASECFLAGS="$BASECFLAGS -belf -Ki486 -DSCO5"
2732 ;;
2733 esac
2734 ;;
2735 esac
2736
2737 case "$CC_BASENAME" in
2738 *mpicc*)
2739 CFLAGS_NODIST="$CFLAGS_NODIST"
2740 ;;
2741 *icc*)
2742 # ICC needs -fp-model strict or floats behave badly
2743 CFLAGS_NODIST="$CFLAGS_NODIST -fp-model strict"
2744 ;;
2745 *xlc*)
2746 CFLAGS_NODIST="$CFLAGS_NODIST -qalias=noansi -qmaxmem=-1"
2747 ;;
2748 esac
2749
2750 if test "$assertions" = 'true'; then
2751 :
2752 else
2753 OPT="-DNDEBUG $OPT"
2754 fi
2755
2756 if test "$ac_arch_flags"
2757 then
2758 BASECFLAGS="$BASECFLAGS $ac_arch_flags"
2759 fi
2760
2761 # On some compilers, pthreads are available without further options
2762 # (e.g. MacOS X). On some of these systems, the compiler will not
2763 # complain if unaccepted options are passed (e.g. gcc on Mac OS X).
2764 # So we have to see first whether pthreads are available without
2765 # options before we can check whether -Kpthread improves anything.
2766 AC_CACHE_CHECK([whether pthreads are available without options],
2767 [ac_cv_pthread_is_default],
2768 [AC_RUN_IFELSE([AC_LANG_SOURCE([[
2769 #include <stdio.h>
2770 #include <pthread.h>
2771
2772 void* routine(void* p){return NULL;}
2773
2774 int main(void){
2775 pthread_t p;
2776 if(pthread_create(&p,NULL,routine,NULL)!=0)
2777 return 1;
2778 (void)pthread_detach(p);
2779 return 0;
2780 }
2781 ]])],[
2782 ac_cv_pthread_is_default=yes
2783 ac_cv_kthread=no
2784 ac_cv_pthread=no
2785 ],[ac_cv_pthread_is_default=no],[ac_cv_pthread_is_default=no])
2786 ])
2787
2788
2789 if test $ac_cv_pthread_is_default = yes
2790 then
2791 ac_cv_kpthread=no
2792 else
2793 # -Kpthread, if available, provides the right #defines
2794 # and linker options to make pthread_create available
2795 # Some compilers won't report that they do not support -Kpthread,
2796 # so we need to run a program to see whether it really made the
2797 # function available.
2798 AC_CACHE_CHECK([whether $CC accepts -Kpthread], [ac_cv_kpthread],
2799 [ac_save_cc="$CC"
2800 CC="$CC -Kpthread"
2801 AC_RUN_IFELSE([AC_LANG_SOURCE([[
2802 #include <stdio.h>
2803 #include <pthread.h>
2804
2805 void* routine(void* p){return NULL;}
2806
2807 int main(void){
2808 pthread_t p;
2809 if(pthread_create(&p,NULL,routine,NULL)!=0)
2810 return 1;
2811 (void)pthread_detach(p);
2812 return 0;
2813 }
2814 ]])],[ac_cv_kpthread=yes],[ac_cv_kpthread=no],[ac_cv_kpthread=no])
2815 CC="$ac_save_cc"])
2816 fi
2817
2818 if test $ac_cv_kpthread = no -a $ac_cv_pthread_is_default = no
2819 then
2820 # -Kthread, if available, provides the right #defines
2821 # and linker options to make pthread_create available
2822 # Some compilers won't report that they do not support -Kthread,
2823 # so we need to run a program to see whether it really made the
2824 # function available.
2825 AC_CACHE_CHECK([whether $CC accepts -Kthread], [ac_cv_kthread],
2826 [ac_save_cc="$CC"
2827 CC="$CC -Kthread"
2828 AC_RUN_IFELSE([AC_LANG_SOURCE([[
2829 #include <stdio.h>
2830 #include <pthread.h>
2831
2832 void* routine(void* p){return NULL;}
2833
2834 int main(void){
2835 pthread_t p;
2836 if(pthread_create(&p,NULL,routine,NULL)!=0)
2837 return 1;
2838 (void)pthread_detach(p);
2839 return 0;
2840 }
2841 ]])],[ac_cv_kthread=yes],[ac_cv_kthread=no],[ac_cv_kthread=no])
2842 CC="$ac_save_cc"])
2843 fi
2844
2845 if test $ac_cv_kthread = no -a $ac_cv_pthread_is_default = no
2846 then
2847 # -pthread, if available, provides the right #defines
2848 # and linker options to make pthread_create available
2849 # Some compilers won't report that they do not support -pthread,
2850 # so we need to run a program to see whether it really made the
2851 # function available.
2852 AC_CACHE_CHECK([whether $CC accepts -pthread], [ac_cv_pthread],
2853 [ac_save_cc="$CC"
2854 CC="$CC -pthread"
2855 AC_RUN_IFELSE([AC_LANG_SOURCE([[
2856 #include <stdio.h>
2857 #include <pthread.h>
2858
2859 void* routine(void* p){return NULL;}
2860
2861 int main(void){
2862 pthread_t p;
2863 if(pthread_create(&p,NULL,routine,NULL)!=0)
2864 return 1;
2865 (void)pthread_detach(p);
2866 return 0;
2867 }
2868 ]])],[ac_cv_pthread=yes],[ac_cv_pthread=no],[ac_cv_pthread=no])
2869 CC="$ac_save_cc"])
2870 fi
2871
2872 # If we have set a CC compiler flag for thread support then
2873 # check if it works for CXX, too.
2874 if test ! -z "$CXX"
2875 then
2876 AC_CACHE_CHECK([whether $CXX also accepts flags for thread support], [ac_cv_cxx_thread],
2877 [ac_save_cxx="$CXX"
2878
2879 if test "$ac_cv_kpthread" = "yes"
2880 then
2881 CXX="$CXX -Kpthread"
2882 ac_cv_cxx_thread=yes
2883 elif test "$ac_cv_kthread" = "yes"
2884 then
2885 CXX="$CXX -Kthread"
2886 ac_cv_cxx_thread=yes
2887 elif test "$ac_cv_pthread" = "yes"
2888 then
2889 CXX="$CXX -pthread"
2890 ac_cv_cxx_thread=yes
2891 else
2892 ac_cv_cxx_thread=no
2893 fi
2894
2895 if test $ac_cv_cxx_thread = yes
2896 then
2897 echo 'void foo();int main(){foo();}void foo(){}' > conftest.$ac_ext
2898 $CXX -c conftest.$ac_ext 2>&5
2899 if $CXX -o conftest$ac_exeext conftest.$ac_objext 2>&5 \
2900 && test -s conftest$ac_exeext && ./conftest$ac_exeext
2901 then
2902 ac_cv_cxx_thread=yes
2903 else
2904 ac_cv_cxx_thread=no
2905 fi
2906 rm -fr conftest*
2907 fi
2908 CXX="$ac_save_cxx"])
2909 else
2910 ac_cv_cxx_thread=no
2911 fi
2912
2913 dnl # check for ANSI or K&R ("traditional") preprocessor
2914 dnl AC_MSG_CHECKING(for C preprocessor type)
2915 dnl AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
2916 dnl #define spam(name, doc) {#name, &name, #name "() -- " doc}
2917 dnl int foo;
2918 dnl struct {char *name; int *addr; char *doc;} desc = spam(foo, "something");
2919 dnl ]], [[;]])],[cpp_type=ansi],[AC_DEFINE(HAVE_OLD_CPP) cpp_type=traditional])
2920 dnl AC_MSG_RESULT($cpp_type)
2921
2922 dnl autoconf 2.71 deprecates STDC_HEADERS, keep for backwards compatibility
2923 dnl assume C99 compilers provide ANSI C headers
2924 AC_DEFINE([STDC_HEADERS], [1],
2925 [Define to 1 if you have the ANSI C header files.])
2926
2927 # checks for header files
2928 AC_CHECK_HEADERS([ \
2929 alloca.h asm/types.h bluetooth.h conio.h direct.h dlfcn.h endian.h errno.h fcntl.h grp.h \
2930 io.h langinfo.h libintl.h libutil.h linux/auxvec.h sys/auxv.h linux/fs.h linux/limits.h linux/memfd.h \
2931 linux/random.h linux/soundcard.h \
2932 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 \
2933 sched.h setjmp.h shadow.h signal.h spawn.h stropts.h sys/audioio.h sys/bsdtty.h sys/devpoll.h \
2934 sys/endian.h sys/epoll.h sys/event.h sys/eventfd.h sys/file.h sys/ioctl.h sys/kern_control.h \
2935 sys/loadavg.h sys/lock.h sys/memfd.h sys/mkdev.h sys/mman.h sys/modem.h sys/param.h sys/poll.h \
2936 sys/random.h sys/resource.h sys/select.h sys/sendfile.h sys/socket.h sys/soundcard.h sys/stat.h \
2937 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 \
2938 sys/types.h sys/uio.h sys/un.h sys/utsname.h sys/wait.h sys/xattr.h sysexits.h syslog.h \
2939 termios.h util.h utime.h utmp.h \
2940 ])
2941 AC_HEADER_DIRENT
2942 AC_HEADER_MAJOR
2943
2944 # bluetooth/bluetooth.h has been known to not compile with -std=c99.
2945 # http://permalink.gmane.org/gmane.linux.bluez.kernel/22294
2946 SAVE_CFLAGS=$CFLAGS
2947 CFLAGS="-std=c99 $CFLAGS"
2948 AC_CHECK_HEADERS([bluetooth/bluetooth.h])
2949 CFLAGS=$SAVE_CFLAGS
2950
2951 # On Darwin (OS X) net/if.h requires sys/socket.h to be imported first.
2952 AC_CHECK_HEADERS([net/if.h], [], [],
2953 [#include <stdio.h>
2954 #include <stdlib.h>
2955 #include <stddef.h>
2956 #ifdef HAVE_SYS_SOCKET_H
2957 # include <sys/socket.h>
2958 #endif
2959 ])
2960
2961 # On Linux, netlink.h requires asm/types.h
2962 # On FreeBSD, netlink.h is located in netlink/netlink.h
2963 AC_CHECK_HEADERS([linux/netlink.h netlink/netlink.h], [], [], [
2964 #ifdef HAVE_ASM_TYPES_H
2965 #include <asm/types.h>
2966 #endif
2967 #ifdef HAVE_SYS_SOCKET_H
2968 #include <sys/socket.h>
2969 #endif
2970 ])
2971
2972 # On Linux, qrtr.h requires asm/types.h
2973 AC_CHECK_HEADERS([linux/qrtr.h], [], [], [
2974 #ifdef HAVE_ASM_TYPES_H
2975 #include <asm/types.h>
2976 #endif
2977 #ifdef HAVE_SYS_SOCKET_H
2978 #include <sys/socket.h>
2979 #endif
2980 ])
2981
2982 AC_CHECK_HEADERS([linux/vm_sockets.h], [], [], [
2983 #ifdef HAVE_SYS_SOCKET_H
2984 #include <sys/socket.h>
2985 #endif
2986 ])
2987
2988 # On Linux, can.h, can/bcm.h, can/j1939.h, can/raw.h require sys/socket.h
2989 # On NetBSD, netcan/can.h requires sys/socket.h
2990 AC_CHECK_HEADERS(
2991 [linux/can.h linux/can/bcm.h linux/can/j1939.h linux/can/raw.h netcan/can.h],
2992 [], [], [
2993 #ifdef HAVE_SYS_SOCKET_H
2994 #include <sys/socket.h>
2995 #endif
2996 ])
2997
2998 # Check for clock_t in time.h.
2999 AC_CHECK_TYPES([clock_t], [],
3000 [AC_DEFINE([clock_t], [long],
3001 [Define to 'long' if <time.h> does not define clock_t.])],
3002 [@%:@include <time.h>])
3003
3004 AC_CACHE_CHECK([for makedev], [ac_cv_func_makedev], [
3005 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
3006 #if defined(MAJOR_IN_MKDEV)
3007 #include <sys/mkdev.h>
3008 #elif defined(MAJOR_IN_SYSMACROS)
3009 #include <sys/sysmacros.h>
3010 #else
3011 #include <sys/types.h>
3012 #endif
3013 ]], [[
3014 makedev(0, 0) ]])
3015 ],[ac_cv_func_makedev=yes],[ac_cv_func_makedev=no])
3016 ])
3017
3018 AS_VAR_IF([ac_cv_func_makedev], [yes], [
3019 AC_DEFINE([HAVE_MAKEDEV], [1],
3020 [Define this if you have the makedev macro.])
3021 ])
3022
3023 # byte swapping
3024 AC_CACHE_CHECK([for le64toh], [ac_cv_func_le64toh], [
3025 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
3026 #ifdef HAVE_ENDIAN_H
3027 #include <endian.h>
3028 #elif defined(HAVE_SYS_ENDIAN_H)
3029 #include <sys/endian.h>
3030 #endif
3031 ]], [[
3032 le64toh(1) ]])
3033 ],[ac_cv_func_le64toh=yes],[ac_cv_func_le64toh=no])
3034 ])
3035
3036 AS_VAR_IF([ac_cv_func_le64toh], [yes], [
3037 AC_DEFINE([HAVE_HTOLE64], [1],
3038 [Define this if you have le64toh()])
3039 ])
3040
3041 use_lfs=yes
3042 # Don't use largefile support for GNU/Hurd
3043 case $ac_sys_system in GNU*)
3044 use_lfs=no
3045 esac
3046
3047 if test "$use_lfs" = "yes"; then
3048 # Two defines needed to enable largefile support on various platforms
3049 # These may affect some typedefs
3050 case $ac_sys_system/$ac_sys_release in
3051 AIX*)
3052 AC_DEFINE([_LARGE_FILES], [1],
3053 [This must be defined on AIX systems to enable large file support.])
3054 ;;
3055 esac
3056 AC_DEFINE([_LARGEFILE_SOURCE], [1],
3057 [This must be defined on some systems to enable large file support.])
3058 AC_DEFINE([_FILE_OFFSET_BITS], [64],
3059 [This must be set to 64 on some systems to enable large file support.])
3060 fi
3061
3062 # Add some code to confdefs.h so that the test for off_t works on SCO
3063 cat >> confdefs.h <<\EOF
3064 #if defined(SCO_DS)
3065 #undef _OFF_T
3066 #endif
3067 EOF
3068
3069 # Type availability checks
3070 AC_TYPE_MODE_T
3071 AC_TYPE_OFF_T
3072 AC_TYPE_PID_T
3073 AC_DEFINE_UNQUOTED([RETSIGTYPE],[void],[assume C89 semantics that RETSIGTYPE is always void])
3074 AC_TYPE_SIZE_T
3075 AC_TYPE_UID_T
3076
3077 AC_CHECK_TYPES([ssize_t])
3078 AC_CHECK_TYPES([__uint128_t],
3079 [AC_DEFINE([HAVE_GCC_UINT128_T], [1],
3080 [Define if your compiler provides __uint128_t])])
3081
3082 # Sizes and alignments of various common basic types
3083 # ANSI C requires sizeof(char) == 1, so no need to check it
3084 AC_CHECK_SIZEOF([int], [4])
3085 AC_CHECK_SIZEOF([long], [4])
3086 AC_CHECK_ALIGNOF([long])
3087 AC_CHECK_SIZEOF([long long], [8])
3088 AC_CHECK_SIZEOF([void *], [4])
3089 AC_CHECK_SIZEOF([short], [2])
3090 AC_CHECK_SIZEOF([float], [4])
3091 AC_CHECK_SIZEOF([double], [8])
3092 AC_CHECK_SIZEOF([fpos_t], [4])
3093 AC_CHECK_SIZEOF([size_t], [4])
3094 AC_CHECK_ALIGNOF([size_t])
3095 AC_CHECK_SIZEOF([pid_t], [4])
3096 AC_CHECK_SIZEOF([uintptr_t])
3097 AC_CHECK_ALIGNOF([max_align_t])
3098
3099 AC_TYPE_LONG_DOUBLE
3100 AC_CHECK_SIZEOF([long double], [16])
3101
3102 AC_CHECK_SIZEOF([_Bool], [1])
3103
3104 AC_CHECK_SIZEOF([off_t], [], [
3105 #ifdef HAVE_SYS_TYPES_H
3106 #include <sys/types.h>
3107 #endif
3108 ])
3109
3110 AC_MSG_CHECKING([whether to enable large file support])
3111 if test "$ac_cv_sizeof_off_t" -gt "$ac_cv_sizeof_long" -a \
3112 "$ac_cv_sizeof_long_long" -ge "$ac_cv_sizeof_off_t"; then
3113 have_largefile_support="yes"
3114 else
3115 have_largefile_support="no"
3116 fi
3117 dnl LFS does not work with Emscripten 3.1
3118 AS_CASE([$ac_sys_system],
3119 [Emscripten], [have_largefile_support="no"]
3120 )
3121 AS_VAR_IF([have_largefile_support], [yes], [
3122 AC_DEFINE([HAVE_LARGEFILE_SUPPORT], [1],
3123 [Defined to enable large file support when an off_t is bigger than a long
3124 and long long is at least as big as an off_t. You may need
3125 to add some flags for configuration and compilation to enable this mode.
3126 (For Solaris and Linux, the necessary defines are already defined.)])
3127 AC_MSG_RESULT([yes])
3128 ], [
3129 AC_MSG_RESULT([no])
3130 ])
3131
3132 AC_CHECK_SIZEOF([time_t], [], [
3133 #ifdef HAVE_SYS_TYPES_H
3134 #include <sys/types.h>
3135 #endif
3136 #ifdef HAVE_TIME_H
3137 #include <time.h>
3138 #endif
3139 ])
3140
3141 # if have pthread_t then define SIZEOF_PTHREAD_T
3142 ac_save_cc="$CC"
3143 if test "$ac_cv_kpthread" = "yes"
3144 then CC="$CC -Kpthread"
3145 elif test "$ac_cv_kthread" = "yes"
3146 then CC="$CC -Kthread"
3147 elif test "$ac_cv_pthread" = "yes"
3148 then CC="$CC -pthread"
3149 fi
3150
3151 AC_CACHE_CHECK([for pthread_t], [ac_cv_have_pthread_t], [
3152 AC_COMPILE_IFELSE([
3153 AC_LANG_PROGRAM([[@%:@include <pthread.h>]], [[pthread_t x; x = *(pthread_t*)0;]])
3154 ], [ac_cv_have_pthread_t=yes], [ac_cv_have_pthread_t=no])
3155 ])
3156 AS_VAR_IF([ac_cv_have_pthread_t], [yes], [
3157 AC_CHECK_SIZEOF([pthread_t], [], [
3158 #ifdef HAVE_PTHREAD_H
3159 #include <pthread.h>
3160 #endif
3161 ])
3162 ])
3163
3164 # Issue #25658: POSIX hasn't defined that pthread_key_t is compatible with int.
3165 # This checking will be unnecessary after removing deprecated TLS API.
3166 AC_CHECK_SIZEOF([pthread_key_t], [], [[@%:@include <pthread.h>]])
3167 AC_CACHE_CHECK([whether pthread_key_t is compatible with int], [ac_cv_pthread_key_t_is_arithmetic_type], [
3168 if test "$ac_cv_sizeof_pthread_key_t" -eq "$ac_cv_sizeof_int" ; then
3169 AC_COMPILE_IFELSE(
3170 [AC_LANG_PROGRAM([[@%:@include <pthread.h>]], [[pthread_key_t k; k * 1;]])],
3171 [ac_cv_pthread_key_t_is_arithmetic_type=yes],
3172 [ac_cv_pthread_key_t_is_arithmetic_type=no]
3173 )
3174 else
3175 ac_cv_pthread_key_t_is_arithmetic_type=no
3176 fi
3177 ])
3178 AS_VAR_IF([ac_cv_pthread_key_t_is_arithmetic_type], [yes], [
3179 AC_DEFINE([PTHREAD_KEY_T_IS_COMPATIBLE_WITH_INT], [1],
3180 [Define if pthread_key_t is compatible with int.])
3181 ])
3182
3183 CC="$ac_save_cc"
3184
3185 AC_MSG_CHECKING([for --enable-framework])
3186 if test "$enable_framework"
3187 then
3188 BASECFLAGS="$BASECFLAGS -fno-common -dynamic"
3189 # -F. is needed to allow linking to the framework while
3190 # in the build location.
3191 AC_DEFINE([WITH_NEXT_FRAMEWORK], [1],
3192 [Define if you want to produce an OpenStep/Rhapsody framework
3193 (shared library plus accessory files).])
3194 AC_MSG_RESULT([yes])
3195 if test $enable_shared = "yes"
3196 then
3197 AC_MSG_ERROR([Specifying both --enable-shared and --enable-framework is not supported, use only --enable-framework instead])
3198 fi
3199 else
3200 AC_MSG_RESULT([no])
3201 fi
3202
3203 # Check for --with-dsymutil
3204 AC_SUBST([DSYMUTIL])
3205 AC_SUBST([DSYMUTIL_PATH])
3206 DSYMUTIL=
3207 DSYMUTIL_PATH=
3208 AC_MSG_CHECKING([for --with-dsymutil])
3209 AC_ARG_WITH(
3210 [dsymutil],
3211 [AS_HELP_STRING(
3212 [--with-dsymutil],
3213 [link debug information into final executable with dsymutil in macOS (default is no)]
3214 )],
3215 [
3216 if test "$withval" != no
3217 then
3218 if test "$MACHDEP" != "darwin"; then
3219 AC_MSG_ERROR([dsymutil debug linking is only available in macOS.])
3220 fi
3221 AC_MSG_RESULT([yes]);
3222 DSYMUTIL='true'
3223 else AC_MSG_RESULT([no]); DSYMUTIL=
3224 fi],
3225 [AC_MSG_RESULT([no])])
3226
3227 if test "$DSYMUTIL"; then
3228 AC_PATH_PROG([DSYMUTIL_PATH], [dsymutil], [not found])
3229 if test "$DSYMUTIL_PATH" = "not found"; then
3230 AC_MSG_ERROR([dsymutil command not found on \$PATH])
3231 fi
3232 fi
3233
3234 AC_MSG_CHECKING([for dyld])
3235 case $ac_sys_system/$ac_sys_release in
3236 Darwin/*)
3237 AC_DEFINE([WITH_DYLD], [1],
3238 [Define if you want to use the new-style (Openstep, Rhapsody, MacOS)
3239 dynamic linker (dyld) instead of the old-style (NextStep) dynamic
3240 linker (rld). Dyld is necessary to support frameworks.])
3241 AC_MSG_RESULT([always on for Darwin])
3242 ;;
3243 *)
3244 AC_MSG_RESULT([no])
3245 ;;
3246 esac
3247
3248 AC_MSG_CHECKING([for --with-address-sanitizer])
3249 AC_ARG_WITH([address_sanitizer],
3250 AS_HELP_STRING([--with-address-sanitizer],
3251 [enable AddressSanitizer memory error detector, 'asan' (default is no)]),
3252 [
3253 AC_MSG_RESULT([$withval])
3254 BASECFLAGS="-fsanitize=address -fno-omit-frame-pointer $BASECFLAGS"
3255 LDFLAGS="-fsanitize=address $LDFLAGS"
3256 # ASan works by controlling memory allocation, our own malloc interferes.
3257 with_pymalloc="no"
3258 ],
3259 [AC_MSG_RESULT([no])])
3260
3261 AC_MSG_CHECKING([for --with-memory-sanitizer])
3262 AC_ARG_WITH(
3263 [memory_sanitizer],
3264 [AS_HELP_STRING(
3265 [--with-memory-sanitizer],
3266 [enable MemorySanitizer allocation error detector, 'msan' (default is no)]
3267 )],
3268 [
3269 AC_MSG_RESULT([$withval])
3270 AX_CHECK_COMPILE_FLAG([-fsanitize=memory],[
3271 BASECFLAGS="-fsanitize=memory -fsanitize-memory-track-origins=2 -fno-omit-frame-pointer $BASECFLAGS"
3272 LDFLAGS="-fsanitize=memory -fsanitize-memory-track-origins=2 $LDFLAGS"
3273 ],[AC_MSG_ERROR([The selected compiler doesn't support memory sanitizer])])
3274 # MSan works by controlling memory allocation, our own malloc interferes.
3275 with_pymalloc="no"
3276 ],
3277 [AC_MSG_RESULT([no])])
3278
3279 AC_MSG_CHECKING([for --with-undefined-behavior-sanitizer])
3280 AC_ARG_WITH(
3281 [undefined_behavior_sanitizer],
3282 [AS_HELP_STRING(
3283 [--with-undefined-behavior-sanitizer],
3284 [enable UndefinedBehaviorSanitizer undefined behaviour detector, 'ubsan' (default is no)]
3285 )],
3286 [
3287 AC_MSG_RESULT([$withval])
3288 BASECFLAGS="-fsanitize=undefined $BASECFLAGS"
3289 LDFLAGS="-fsanitize=undefined $LDFLAGS"
3290 with_ubsan="yes"
3291 ],
3292 [
3293 AC_MSG_RESULT([no])
3294 with_ubsan="no"
3295 ])
3296
3297 AC_MSG_CHECKING([for --with-thread-sanitizer])
3298 AC_ARG_WITH(
3299 [thread_sanitizer],
3300 [AS_HELP_STRING(
3301 [--with-thread-sanitizer],
3302 [enable ThreadSanitizer data race detector, 'tsan' (default is no)]
3303 )],
3304 [
3305 AC_MSG_RESULT([$withval])
3306 BASECFLAGS="-fsanitize=thread $BASECFLAGS"
3307 LDFLAGS="-fsanitize=thread $LDFLAGS"
3308 with_tsan="yes"
3309 ],
3310 [
3311 AC_MSG_RESULT([no])
3312 with_tsan="no"
3313 ])
3314
3315 # Set info about shared libraries.
3316 AC_SUBST([SHLIB_SUFFIX])
3317 AC_SUBST([LDSHARED])
3318 AC_SUBST([LDCXXSHARED])
3319 AC_SUBST([BLDSHARED])
3320 AC_SUBST([CCSHARED])
3321 AC_SUBST([LINKFORSHARED])
3322
3323 # SHLIB_SUFFIX is the extension of shared libraries `(including the dot!)
3324 # -- usually .so, .sl on HP-UX, .dll on Cygwin
3325 AC_MSG_CHECKING([the extension of shared libraries])
3326 if test -z "$SHLIB_SUFFIX"; then
3327 case $ac_sys_system in
3328 hp*|HP*)
3329 case `uname -m` in
3330 ia64) SHLIB_SUFFIX=.so;;
3331 *) SHLIB_SUFFIX=.sl;;
3332 esac
3333 ;;
3334 CYGWIN*) SHLIB_SUFFIX=.dll;;
3335 *) SHLIB_SUFFIX=.so;;
3336 esac
3337 fi
3338 AC_MSG_RESULT([$SHLIB_SUFFIX])
3339
3340 # LDSHARED is the ld *command* used to create shared library
3341 # -- "cc -G" on SunOS 5.x.
3342 # (Shared libraries in this instance are shared modules to be loaded into
3343 # Python, as opposed to building Python itself as a shared library.)
3344 AC_MSG_CHECKING([LDSHARED])
3345 if test -z "$LDSHARED"
3346 then
3347 case $ac_sys_system/$ac_sys_release in
3348 AIX*)
3349 BLDSHARED="Modules/ld_so_aix \$(CC) -bI:Modules/python.exp"
3350 LDSHARED="\$(LIBPL)/ld_so_aix \$(CC) -bI:\$(LIBPL)/python.exp"
3351 ;;
3352 SunOS/5*)
3353 if test "$GCC" = "yes" ; then
3354 LDSHARED='$(CC) -shared'
3355 LDCXXSHARED='$(CXX) -shared'
3356 else
3357 LDSHARED='$(CC) -G'
3358 LDCXXSHARED='$(CXX) -G'
3359 fi ;;
3360 hp*|HP*)
3361 if test "$GCC" = "yes" ; then
3362 LDSHARED='$(CC) -shared'
3363 LDCXXSHARED='$(CXX) -shared'
3364 else
3365 LDSHARED='$(CC) -b'
3366 LDCXXSHARED='$(CXX) -b'
3367 fi ;;
3368 Darwin/1.3*)
3369 LDSHARED='$(CC) -bundle'
3370 LDCXXSHARED='$(CXX) -bundle'
3371 if test "$enable_framework" ; then
3372 # Link against the framework. All externals should be defined.
3373 BLDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
3374 LDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
3375 LDCXXSHARED="$LDCXXSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
3376 else
3377 # No framework. Ignore undefined symbols, assuming they come from Python
3378 LDSHARED="$LDSHARED -undefined suppress"
3379 LDCXXSHARED="$LDCXXSHARED -undefined suppress"
3380 fi ;;
3381 Darwin/1.4*|Darwin/5.*|Darwin/6.*)
3382 LDSHARED='$(CC) -bundle'
3383 LDCXXSHARED='$(CXX) -bundle'
3384 if test "$enable_framework" ; then
3385 # Link against the framework. All externals should be defined.
3386 BLDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
3387 LDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
3388 LDCXXSHARED="$LDCXXSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
3389 else
3390 # No framework, use the Python app as bundle-loader
3391 BLDSHARED="$LDSHARED "'-bundle_loader $(BUILDPYTHON)'
3392 LDSHARED="$LDSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)'
3393 LDCXXSHARED="$LDCXXSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)'
3394 fi ;;
3395 Darwin/*)
3396 # Use -undefined dynamic_lookup whenever possible (10.3 and later).
3397 # This allows an extension to be used in any Python
3398
3399 dep_target_major=`echo ${MACOSX_DEPLOYMENT_TARGET} | \
3400 sed 's/\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'`
3401 dep_target_minor=`echo ${MACOSX_DEPLOYMENT_TARGET} | \
3402 sed 's/\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'`
3403 if test ${dep_target_major} -eq 10 && \
3404 test ${dep_target_minor} -le 2
3405 then
3406 # building for OS X 10.0 through 10.2
3407 AC_MSG_ERROR([MACOSX_DEPLOYMENT_TARGET too old ($MACOSX_DEPLOYMENT_TARGET), only 10.3 or later is supported])
3408 else
3409 # building for OS X 10.3 and later
3410 LDSHARED='$(CC) -bundle -undefined dynamic_lookup'
3411 LDCXXSHARED='$(CXX) -bundle -undefined dynamic_lookup'
3412 BLDSHARED="$LDSHARED"
3413 fi
3414 ;;
3415 iOS/*)
3416 LDSHARED='$(CC) -dynamiclib -F . -framework $(PYTHONFRAMEWORK)'
3417 LDCXXSHARED='$(CXX) -dynamiclib -F . -framework $(PYTHONFRAMEWORK)'
3418 BLDSHARED="$LDSHARED"
3419 ;;
3420 Emscripten|WASI)
3421 LDSHARED='$(CC) -shared'
3422 LDCXXSHARED='$(CXX) -shared';;
3423 Linux*|GNU*|QNX*|VxWorks*|Haiku*)
3424 LDSHARED='$(CC) -shared'
3425 LDCXXSHARED='$(CXX) -shared';;
3426 FreeBSD*)
3427 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
3428 then
3429 LDSHARED='$(CC) -shared'
3430 LDCXXSHARED='$(CXX) -shared'
3431 else
3432 LDSHARED="ld -Bshareable"
3433 fi;;
3434 OpenBSD*)
3435 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
3436 then
3437 LDSHARED='$(CC) -shared $(CCSHARED)'
3438 LDCXXSHARED='$(CXX) -shared $(CCSHARED)'
3439 else
3440 case `uname -r` in
3441 [[01]].* | 2.[[0-7]] | 2.[[0-7]].*)
3442 LDSHARED="ld -Bshareable ${LDFLAGS}"
3443 ;;
3444 *)
3445 LDSHARED='$(CC) -shared $(CCSHARED)'
3446 LDCXXSHARED='$(CXX) -shared $(CCSHARED)'
3447 ;;
3448 esac
3449 fi;;
3450 NetBSD*|DragonFly*)
3451 LDSHARED='$(CC) -shared'
3452 LDCXXSHARED='$(CXX) -shared';;
3453 OpenUNIX*|UnixWare*)
3454 if test "$GCC" = "yes" ; then
3455 LDSHARED='$(CC) -shared'
3456 LDCXXSHARED='$(CXX) -shared'
3457 else
3458 LDSHARED='$(CC) -G'
3459 LDCXXSHARED='$(CXX) -G'
3460 fi;;
3461 SCO_SV*)
3462 LDSHARED='$(CC) -Wl,-G,-Bexport'
3463 LDCXXSHARED='$(CXX) -Wl,-G,-Bexport';;
3464 WASI*)
3465 AS_VAR_IF([enable_wasm_dynamic_linking], [yes], [
3466 dnl not iplemented yet
3467 ]);;
3468 CYGWIN*)
3469 LDSHARED="gcc -shared -Wl,--enable-auto-image-base"
3470 LDCXXSHARED="g++ -shared -Wl,--enable-auto-image-base";;
3471 *) LDSHARED="ld";;
3472 esac
3473 fi
3474
3475 dnl Emscripten's emconfigure sets LDSHARED. Set BLDSHARED outside the
3476 dnl test -z $LDSHARED block to configure BLDSHARED for side module support.
3477 if test "$enable_wasm_dynamic_linking" = "yes" -a "$ac_sys_system" = "Emscripten"; then
3478 BLDSHARED='$(CC) -shared -sSIDE_MODULE=1'
3479 fi
3480
3481 AC_MSG_RESULT([$LDSHARED])
3482 LDCXXSHARED=${LDCXXSHARED-$LDSHARED}
3483
3484 AC_MSG_CHECKING([BLDSHARED flags])
3485 BLDSHARED=${BLDSHARED-$LDSHARED}
3486 AC_MSG_RESULT([$BLDSHARED])
3487
3488 # CCSHARED are the C *flags* used to create objects to go into a shared
3489 # library (module) -- this is only needed for a few systems
3490 AC_MSG_CHECKING([CCSHARED])
3491 if test -z "$CCSHARED"
3492 then
3493 case $ac_sys_system/$ac_sys_release in
3494 SunOS*) if test "$GCC" = yes;
3495 then CCSHARED="-fPIC";
3496 elif test `uname -p` = sparc;
3497 then CCSHARED="-xcode=pic32";
3498 else CCSHARED="-Kpic";
3499 fi;;
3500 hp*|HP*) if test "$GCC" = yes;
3501 then CCSHARED="-fPIC";
3502 else CCSHARED="+z";
3503 fi;;
3504 Linux*|GNU*) CCSHARED="-fPIC";;
3505 Emscripten*|WASI*)
3506 AS_VAR_IF([enable_wasm_dynamic_linking], [yes], [
3507 CCSHARED="-fPIC"
3508 ]);;
3509 FreeBSD*|NetBSD*|OpenBSD*|DragonFly*) CCSHARED="-fPIC";;
3510 Haiku*) CCSHARED="-fPIC";;
3511 OpenUNIX*|UnixWare*)
3512 if test "$GCC" = "yes"
3513 then CCSHARED="-fPIC"
3514 else CCSHARED="-KPIC"
3515 fi;;
3516 SCO_SV*)
3517 if test "$GCC" = "yes"
3518 then CCSHARED="-fPIC"
3519 else CCSHARED="-Kpic -belf"
3520 fi;;
3521 VxWorks*)
3522 CCSHARED="-fpic -D__SO_PICABILINUX__ -ftls-model=global-dynamic"
3523 esac
3524 fi
3525 AC_MSG_RESULT([$CCSHARED])
3526 # LINKFORSHARED are the flags passed to the $(CC) command that links
3527 # the python executable -- this is only needed for a few systems
3528 AC_MSG_CHECKING([LINKFORSHARED])
3529 if test -z "$LINKFORSHARED"
3530 then
3531 case $ac_sys_system/$ac_sys_release in
3532 AIX*) LINKFORSHARED='-Wl,-bE:Modules/python.exp -lld';;
3533 hp*|HP*)
3534 LINKFORSHARED="-Wl,-E -Wl,+s";;
3535 # LINKFORSHARED="-Wl,-E -Wl,+s -Wl,+b\$(BINLIBDEST)/lib-dynload";;
3536 Linux-android*) LINKFORSHARED="-pie -Xlinker -export-dynamic";;
3537 Linux*|GNU*) LINKFORSHARED="-Xlinker -export-dynamic";;
3538 # -u libsys_s pulls in all symbols in libsys
3539 Darwin/*|iOS/*)
3540 LINKFORSHARED="$extra_undefs -framework CoreFoundation"
3541
3542 # Issue #18075: the default maximum stack size (8MBytes) is too
3543 # small for the default recursion limit. Increase the stack size
3544 # to ensure that tests don't crash
3545 stack_size="1000000" # 16 MB
3546 if test "$with_ubsan" = "yes"
3547 then
3548 # Undefined behavior sanitizer requires an even deeper stack
3549 stack_size="4000000" # 64 MB
3550 fi
3551
3552 AC_DEFINE_UNQUOTED([THREAD_STACK_SIZE],
3553 [0x$stack_size],
3554 [Custom thread stack size depending on chosen sanitizer runtimes.])
3555
3556 if test $ac_sys_system = "Darwin"; then
3557 LINKFORSHARED="-Wl,-stack_size,$stack_size $LINKFORSHARED"
3558
3559 if test "$enable_framework"; then
3560 LINKFORSHARED="$LINKFORSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
3561 fi
3562 LINKFORSHARED="$LINKFORSHARED"
3563 elif test $ac_sys_system = "iOS"; then
3564 LINKFORSHARED="-Wl,-stack_size,$stack_size $LINKFORSHARED "'$(PYTHONFRAMEWORKDIR)/$(PYTHONFRAMEWORK)'
3565 fi
3566 ;;
3567 OpenUNIX*|UnixWare*) LINKFORSHARED="-Wl,-Bexport";;
3568 SCO_SV*) LINKFORSHARED="-Wl,-Bexport";;
3569 ReliantUNIX*) LINKFORSHARED="-W1 -Blargedynsym";;
3570 FreeBSD*|NetBSD*|OpenBSD*|DragonFly*)
3571 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
3572 then
3573 LINKFORSHARED="-Wl,--export-dynamic"
3574 fi;;
3575 SunOS/5*) case $CC in
3576 *gcc*)
3577 if $CC -Xlinker --help 2>&1 | grep export-dynamic >/dev/null
3578 then
3579 LINKFORSHARED="-Xlinker --export-dynamic"
3580 fi;;
3581 esac;;
3582 CYGWIN*)
3583 if test $enable_shared = "no"
3584 then
3585 LINKFORSHARED='-Wl,--out-implib=$(LDLIBRARY)'
3586 fi;;
3587 QNX*)
3588 # -Wl,-E causes the symbols to be added to the dynamic
3589 # symbol table so that they can be found when a module
3590 # is loaded. -N 2048K causes the stack size to be set
3591 # to 2048 kilobytes so that the stack doesn't overflow
3592 # when running test_compile.py.
3593 LINKFORSHARED='-Wl,-E -N 2048K';;
3594 VxWorks*)
3595 LINKFORSHARED='-Wl,-export-dynamic';;
3596 esac
3597 fi
3598 AC_MSG_RESULT([$LINKFORSHARED])
3599
3600
3601 AC_SUBST([CFLAGSFORSHARED])
3602 AC_MSG_CHECKING([CFLAGSFORSHARED])
3603 if test ! "$LIBRARY" = "$LDLIBRARY"
3604 then
3605 case $ac_sys_system in
3606 CYGWIN*)
3607 # Cygwin needs CCSHARED when building extension DLLs
3608 # but not when building the interpreter DLL.
3609 CFLAGSFORSHARED='';;
3610 *)
3611 CFLAGSFORSHARED='$(CCSHARED)'
3612 esac
3613 fi
3614
3615 dnl WASM dynamic linking requires -fPIC.
3616 AS_VAR_IF([enable_wasm_dynamic_linking], [yes], [
3617 CFLAGSFORSHARED='$(CCSHARED)'
3618 ])
3619
3620 AC_MSG_RESULT([$CFLAGSFORSHARED])
3621
3622 # SHLIBS are libraries (except -lc and -lm) to link to the python shared
3623 # library (with --enable-shared).
3624 # For platforms on which shared libraries are not allowed to have unresolved
3625 # symbols, this must be set to $(LIBS) (expanded by make). We do this even
3626 # if it is not required, since it creates a dependency of the shared library
3627 # to LIBS. This, in turn, means that applications linking the shared libpython
3628 # don't need to link LIBS explicitly. The default should be only changed
3629 # on systems where this approach causes problems.
3630 AC_SUBST([SHLIBS])
3631 AC_MSG_CHECKING([SHLIBS])
3632 case "$ac_sys_system" in
3633 *)
3634 SHLIBS='$(LIBS)';;
3635 esac
3636 AC_MSG_RESULT([$SHLIBS])
3637
3638 dnl perf trampoline is Linux specific and requires an arch-specific
3639 dnl trampoline in asssembly.
3640 AC_MSG_CHECKING([perf trampoline])
3641 AS_CASE([$PLATFORM_TRIPLET],
3642 [x86_64-linux-gnu], [perf_trampoline=yes],
3643 [aarch64-linux-gnu], [perf_trampoline=yes],
3644 [perf_trampoline=no]
3645 )
3646 AC_MSG_RESULT([$perf_trampoline])
3647
3648 AS_VAR_IF([perf_trampoline], [yes], [
3649 AC_DEFINE([PY_HAVE_PERF_TRAMPOLINE], [1], [Define to 1 if you have the perf trampoline.])
3650 PERF_TRAMPOLINE_OBJ=Python/asm_trampoline.o
3651
3652 dnl perf needs frame pointers for unwinding, include compiler option in debug builds
3653 AS_VAR_IF([Py_DEBUG], [true], [
3654 AS_VAR_APPEND([BASECFLAGS], [" -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer"])
3655 ])
3656 ])
3657 AC_SUBST([PERF_TRAMPOLINE_OBJ])
3658
3659 # checks for libraries
3660 AC_CHECK_LIB([sendfile], [sendfile])
3661 AC_CHECK_LIB([dl], [dlopen]) # Dynamic linking for SunOS/Solaris and SYSV
3662 AC_CHECK_LIB([dld], [shl_load]) # Dynamic linking for HP-UX
3663
3664
3665 dnl check for uuid dependencies
3666 AH_TEMPLATE([HAVE_UUID_H], [Define to 1 if you have the <uuid.h> header file.])
3667 AH_TEMPLATE([HAVE_UUID_UUID_H], [Define to 1 if you have the <uuid/uuid.h> header file.])
3668 AH_TEMPLATE([HAVE_UUID_GENERATE_TIME_SAFE], [Define if uuid_generate_time_safe() exists.])
3669 have_uuid=missing
3670
3671 dnl AIX provides support for RFC4122 (uuid) in libc.a starting with AIX 6.1
3672 dnl (anno 2007). FreeBSD and OpenBSD provides support in libc as well.
3673 dnl Little-endian FreeBSD, OpenBSD and NetBSD needs encoding into an octet
3674 dnl stream in big-endian byte-order
3675 AC_CHECK_HEADERS([uuid.h],
3676 [AC_CHECK_FUNCS([uuid_create uuid_enc_be],
3677 [have_uuid=yes
3678 LIBUUID_CFLAGS=${LIBUUID_CFLAGS-""}
3679 LIBUUID_LIBS=${LIBUUID_LIBS-""}
3680 ])
3681 ])
3682
3683 AS_VAR_IF([have_uuid], [missing], [
3684 PKG_CHECK_MODULES(
3685 [LIBUUID], [uuid >= 2.20],
3686 [dnl linux-util's libuuid has uuid_generate_time_safe() since v2.20 (2011)
3687 dnl and provides <uuid.h>.
3688 have_uuid=yes
3689 AC_DEFINE([HAVE_UUID_H], [1])
3690 AC_DEFINE([HAVE_UUID_GENERATE_TIME_SAFE], [1])
3691 ], [
3692 WITH_SAVE_ENV([
3693 CPPFLAGS="$CPPFLAGS $LIBUUID_CFLAGS"
3694 LDFLAGS="$LDFLAGS $LIBUUID_LIBS"
3695 AC_CHECK_HEADERS([uuid/uuid.h], [
3696 PY_CHECK_LIB([uuid], [uuid_generate_time], [have_uuid=yes])
3697 PY_CHECK_LIB([uuid], [uuid_generate_time_safe],
3698 [have_uuid=yes
3699 AC_DEFINE([HAVE_UUID_GENERATE_TIME_SAFE], [1]) ]) ])
3700 AS_VAR_IF([have_uuid], [yes], [
3701 LIBUUID_CFLAGS=${LIBUUID_CFLAGS-""}
3702 LIBUUID_LIBS=${LIBUUID_LIBS-"-luuid"}
3703 ])
3704 ])
3705 ]
3706 )
3707 ])
3708
3709 dnl macOS has uuid/uuid.h but uuid_generate_time is in libc
3710 AS_VAR_IF([have_uuid], [missing], [
3711 AC_CHECK_HEADERS([uuid/uuid.h], [
3712 AC_CHECK_FUNC([uuid_generate_time], [
3713 have_uuid=yes
3714 LIBUUID_CFLAGS=${LIBUUID_CFLAGS-""}
3715 LIBUUID_LIBS=${LIBUUID_LIBS-""}
3716 ])
3717 ])
3718 ])
3719
3720 AS_VAR_IF([have_uuid], [missing], [have_uuid=no])
3721
3722 # 'Real Time' functions on Solaris
3723 # posix4 on Solaris 2.6
3724 # pthread (first!) on Linux
3725 AC_SEARCH_LIBS([sem_init], [pthread rt posix4])
3726
3727 # check if we need libintl for locale functions
3728 AC_CHECK_LIB([intl], [textdomain],
3729 [AC_DEFINE([WITH_LIBINTL], [1],
3730 [Define to 1 if libintl is needed for locale functions.])
3731 LIBS="-lintl $LIBS"])
3732
3733 # checks for system dependent C++ extensions support
3734 case "$ac_sys_system" in
3735 AIX*) AC_MSG_CHECKING([for genuine AIX C++ extensions support])
3736 AC_LINK_IFELSE([
3737 AC_LANG_PROGRAM([[@%:@include <load.h>]],
3738 [[loadAndInit("", 0, "")]])
3739 ],[
3740 AC_DEFINE([AIX_GENUINE_CPLUSPLUS], [1],
3741 [Define for AIX if your compiler is a genuine IBM xlC/xlC_r
3742 and you want support for AIX C++ shared extension modules.])
3743 AC_MSG_RESULT([yes])
3744 ],[
3745 AC_MSG_RESULT([no])
3746 ])
3747 dnl The AIX_BUILDDATE is obtained from the kernel fileset - bos.mp64
3748 # BUILD_GNU_TYPE + AIX_BUILDDATE are used to construct the platform_tag
3749 # of the AIX system used to build/package Python executable. This tag serves
3750 # as a baseline for bdist module packages
3751 AC_MSG_CHECKING([for the system builddate])
3752 AIX_BUILDDATE=$(lslpp -Lcq bos.mp64 | awk -F: '{ print $NF }')
3753 AC_DEFINE_UNQUOTED([AIX_BUILDDATE], [$AIX_BUILDDATE],
3754 [BUILD_GNU_TYPE + AIX_BUILDDATE are used to construct the PEP425 tag of the build system.])
3755 AC_MSG_RESULT([$AIX_BUILDDATE])
3756 ;;
3757 *) ;;
3758 esac
3759
3760 # check for systems that require aligned memory access
3761 AC_CACHE_CHECK([aligned memory access is required], [ac_cv_aligned_required],
3762 [AC_RUN_IFELSE([AC_LANG_SOURCE([[
3763 int main(void)
3764 {
3765 char s[16];
3766 int i, *p1, *p2;
3767 for (i=0; i < 16; i++)
3768 s[i] = i;
3769 p1 = (int*)(s+1);
3770 p2 = (int*)(s+2);
3771 if (*p1 == *p2)
3772 return 1;
3773 return 0;
3774 }]])],
3775 [ac_cv_aligned_required=no],
3776 [ac_cv_aligned_required=yes],
3777 [
3778 # "yes" changes the hash function to FNV, which causes problems with Numba
3779 # (https://github.com/numba/numba/blob/0.59.0/numba/cpython/hashing.py#L470).
3780 if test "$ac_sys_system" = "Linux-android"; then
3781 ac_cv_aligned_required=no
3782 else
3783 ac_cv_aligned_required=yes
3784 fi])
3785 ])
3786 if test "$ac_cv_aligned_required" = yes ; then
3787 AC_DEFINE([HAVE_ALIGNED_REQUIRED], [1],
3788 [Define if aligned memory access is required])
3789 fi
3790
3791 # str, bytes and memoryview hash algorithm
3792 AH_TEMPLATE([Py_HASH_ALGORITHM],
3793 [Define hash algorithm for str, bytes and memoryview.
3794 SipHash24: 1, FNV: 2, SipHash13: 3, externally defined: 0])
3795
3796 AC_MSG_CHECKING([for --with-hash-algorithm])
3797 dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
3798 AC_ARG_WITH(
3799 [hash_algorithm],
3800 [AS_HELP_STRING(
3801 [--with-hash-algorithm=@<:@fnv|siphash13|siphash24@:>@],
3802 [select hash algorithm for use in Python/pyhash.c (default is SipHash13)]
3803 )],
3804 [
3805 AC_MSG_RESULT([$withval])
3806 case "$withval" in
3807 siphash13)
3808 AC_DEFINE([Py_HASH_ALGORITHM], [3])
3809 ;;
3810 siphash24)
3811 AC_DEFINE([Py_HASH_ALGORITHM], [1])
3812 ;;
3813 fnv)
3814 AC_DEFINE([Py_HASH_ALGORITHM], [2])
3815 ;;
3816 *)
3817 AC_MSG_ERROR([unknown hash algorithm '$withval'])
3818 ;;
3819 esac
3820 ],
3821 [AC_MSG_RESULT([default])])
3822
3823 validate_tzpath() {
3824 # Checks that each element of the path is an absolute path
3825 if test -z "$1"; then
3826 # Empty string is allowed: it indicates no system TZPATH
3827 return 0
3828 fi
3829
3830 # Bad paths are those that don't start with /
3831 dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
3832 if ( echo $1 | grep '\(^\|:\)\(@<:@^/@:>@\|$\)' > /dev/null); then
3833 AC_MSG_ERROR([--with-tzpath must contain only absolute paths, not $1])
3834 return 1;
3835 fi
3836 }
3837
3838 TZPATH="/usr/share/zoneinfo:/usr/lib/zoneinfo:/usr/share/lib/zoneinfo:/etc/zoneinfo"
3839 AC_MSG_CHECKING([for --with-tzpath])
3840 AC_ARG_WITH(
3841 [tzpath],
3842 [AS_HELP_STRING(
3843 [--with-tzpath=<list of absolute paths separated by pathsep>],
3844 [Select the default time zone search path for zoneinfo.TZPATH]
3845 )],
3846 [
3847 case "$withval" in
3848 yes)
3849 AC_MSG_ERROR([--with-tzpath requires a value])
3850 ;;
3851 *)
3852 validate_tzpath "$withval"
3853 TZPATH="$withval"
3854 AC_MSG_RESULT(["$withval"])
3855 ;;
3856 esac
3857 ],
3858 [validate_tzpath "$TZPATH"
3859 AC_MSG_RESULT(["$TZPATH"])])
3860 AC_SUBST([TZPATH])
3861
3862 # Most SVR4 platforms (e.g. Solaris) need -lsocket and -lnsl.
3863 AC_CHECK_LIB([nsl], [t_open], [LIBS="-lnsl $LIBS"]) # SVR4
3864 AC_CHECK_LIB([socket], [socket], [LIBS="-lsocket $LIBS"], [], $LIBS) # SVR4 sockets
3865
3866 case $ac_sys_system/$ac_sys_release in
3867 Haiku*)
3868 AC_CHECK_LIB([network], [socket], [LIBS="-lnetwork $LIBS"], [], [$LIBS])
3869 ;;
3870 esac
3871
3872 AC_MSG_CHECKING([for --with-libs])
3873 AC_ARG_WITH(
3874 [libs],
3875 [AS_HELP_STRING(
3876 [--with-libs='lib1 ...'],
3877 [link against additional libs (default is no)]
3878 )],
3879 [
3880 AC_MSG_RESULT([$withval])
3881 LIBS="$withval $LIBS"
3882 ],
3883 [AC_MSG_RESULT([no])])
3884
3885 # Check for use of the system expat library
3886 AC_MSG_CHECKING([for --with-system-expat])
3887 AC_ARG_WITH(
3888 [system_expat],
3889 [AS_HELP_STRING(
3890 [--with-system-expat],
3891 [build pyexpat module using an installed expat library, see Doc/library/pyexpat.rst (default is no)]
3892 )], [], [with_system_expat="no"])
3893
3894 AC_MSG_RESULT([$with_system_expat])
3895
3896 AS_VAR_IF([with_system_expat], [yes], [
3897 LIBEXPAT_CFLAGS=${LIBEXPAT_CFLAGS-""}
3898 LIBEXPAT_LDFLAGS=${LIBEXPAT_LDFLAGS-"-lexpat"}
3899 LIBEXPAT_INTERNAL=
3900 ], [
3901 LIBEXPAT_CFLAGS="-I\$(srcdir)/Modules/expat"
3902 LIBEXPAT_LDFLAGS="-lm \$(LIBEXPAT_A)"
3903 LIBEXPAT_INTERNAL="\$(LIBEXPAT_HEADERS) \$(LIBEXPAT_A)"
3904 ])
3905
3906 AC_SUBST([LIBEXPAT_CFLAGS])
3907 AC_SUBST([LIBEXPAT_INTERNAL])
3908
3909 dnl detect libffi
3910 have_libffi=missing
3911 AS_VAR_IF([ac_sys_system], [Darwin], [
3912 WITH_SAVE_ENV([
3913 CFLAGS="-I${SDKROOT}/usr/include/ffi $CFLAGS"
3914 AC_CHECK_HEADER([ffi.h], [
3915 AC_CHECK_LIB([ffi], [ffi_call], [
3916 dnl use ffi from SDK root
3917 have_libffi=yes
3918 LIBFFI_CFLAGS="-I${SDKROOT}/usr/include/ffi -DUSING_APPLE_OS_LIBFFI=1"
3919 LIBFFI_LIBS="-lffi"
3920 ])
3921 ])
3922 ])
3923 ])
3924 AS_VAR_IF([have_libffi], [missing], [
3925 PKG_CHECK_MODULES([LIBFFI], [libffi], [have_libffi=yes], [
3926 WITH_SAVE_ENV([
3927 CPPFLAGS="$CPPFLAGS $LIBFFI_CFLAGS"
3928 LDFLAGS="$LDFLAGS $LIBFFI_LIBS"
3929 AC_CHECK_HEADER([ffi.h], [
3930 AC_CHECK_LIB([ffi], [ffi_call], [
3931 have_libffi=yes
3932 LIBFFI_CFLAGS=${LIBFFI_CFLAGS-""}
3933 LIBFFI_LIBS=${LIBFFI_LIBS-"-lffi"}
3934 ], [have_libffi=no])
3935 ])
3936 ])
3937 ])
3938 ])
3939
3940 AS_VAR_IF([have_libffi], [yes], [
3941 ctypes_malloc_closure=no
3942 AS_CASE([$ac_sys_system],
3943 [Darwin], [
3944 dnl when do we need USING_APPLE_OS_LIBFFI?
3945 ctypes_malloc_closure=yes
3946 ],
3947 [iOS], [
3948 ctypes_malloc_closure=yes
3949 ],
3950 [sunos5], [AS_VAR_APPEND([LIBFFI_LIBS], [" -mimpure-text"])]
3951 )
3952 AS_VAR_IF([ctypes_malloc_closure], [yes], [
3953 MODULE__CTYPES_MALLOC_CLOSURE=_ctypes/malloc_closure.c
3954 AS_VAR_APPEND([LIBFFI_CFLAGS], [" -DUSING_MALLOC_CLOSURE_DOT_C=1"])
3955 ])
3956 AC_SUBST([MODULE__CTYPES_MALLOC_CLOSURE])
3957
3958 dnl HAVE_LIBDL: for dlopen, see gh-76828
3959 AS_VAR_IF([ac_cv_lib_dl_dlopen], [yes], [AS_VAR_APPEND([LIBFFI_LIBS], [" -ldl"])])
3960
3961 WITH_SAVE_ENV([
3962 CFLAGS="$LIBFFI_CFLAGS $CFLAGS"
3963 LDFLAGS="$LIBFFI_LIBS $LDFLAGS"
3964
3965 PY_CHECK_FUNC([ffi_prep_cif_var], [@%:@include <ffi.h>])
3966 PY_CHECK_FUNC([ffi_prep_closure_loc], [@%:@include <ffi.h>])
3967 PY_CHECK_FUNC([ffi_closure_alloc], [@%:@include <ffi.h>])
3968 ])
3969 ])
3970
3971 # Check for use of the system libmpdec library
3972 AC_MSG_CHECKING([for --with-system-libmpdec])
3973 AC_ARG_WITH(
3974 [system_libmpdec],
3975 [AS_HELP_STRING(
3976 [--with-system-libmpdec],
3977 [build _decimal module using an installed libmpdec library, see Doc/library/decimal.rst (default is no)]
3978 )],
3979 [],
3980 [with_system_libmpdec="no"])
3981 AC_MSG_RESULT([$with_system_libmpdec])
3982
3983 AS_VAR_IF(
3984 [with_system_libmpdec], [yes],
3985 [PKG_CHECK_MODULES(
3986 [LIBMPDEC], [libmpdec], [],
3987 [LIBMPDEC_CFLAGS=${LIBMPDEC_CFLAGS-""}
3988 LIBMPDEC_LIBS=${LIBMPDEC_LIBS-"-lmpdec -lm"}
3989 LIBMPDEC_INTERNAL=])],
3990 [LIBMPDEC_CFLAGS="-I\$(srcdir)/Modules/_decimal/libmpdec"
3991 LIBMPDEC_LIBS="-lm \$(LIBMPDEC_A)"
3992 LIBMPDEC_INTERNAL="\$(LIBMPDEC_HEADERS) \$(LIBMPDEC_A)"])
3993
3994 # Disable forced inlining in debug builds, see GH-94847
3995 AS_VAR_IF(
3996 [with_pydebug], [yes],
3997 [AS_VAR_APPEND([LIBMPDEC_CFLAGS], [" -DTEST_COVERAGE"])])
3998
3999 # Check whether _decimal should use a coroutine-local or thread-local context
4000 AC_MSG_CHECKING([for --with-decimal-contextvar])
4001 AC_ARG_WITH(
4002 [decimal_contextvar],
4003 [AS_HELP_STRING(
4004 [--with-decimal-contextvar],
4005 [build _decimal module using a coroutine-local rather than a thread-local context (default is yes)]
4006 )],
4007 [],
4008 [with_decimal_contextvar="yes"])
4009
4010 if test "$with_decimal_contextvar" != "no"
4011 then
4012 AC_DEFINE([WITH_DECIMAL_CONTEXTVAR], [1],
4013 [Define if you want build the _decimal module using a coroutine-local rather than a thread-local context])
4014 fi
4015
4016 AC_MSG_RESULT([$with_decimal_contextvar])
4017
4018 AS_VAR_IF(
4019 [with_system_libmpdec], [no],
4020 [# Check for libmpdec machine flavor
4021 AC_MSG_CHECKING([for decimal libmpdec machine])
4022 AS_CASE([$ac_sys_system],
4023 [Darwin*], [libmpdec_system=Darwin],
4024 [SunOS*], [libmpdec_system=sunos],
4025 [libmpdec_system=other]
4026 )
4027
4028 libmpdec_machine=unknown
4029 if test "$libmpdec_system" = Darwin; then
4030 # universal here means: build libmpdec with the same arch options
4031 # the python interpreter was built with
4032 libmpdec_machine=universal
4033 elif test $ac_cv_sizeof_size_t -eq 8; then
4034 if test "$ac_cv_gcc_asm_for_x64" = yes; then
4035 libmpdec_machine=x64
4036 elif test "$ac_cv_type___uint128_t" = yes; then
4037 libmpdec_machine=uint128
4038 else
4039 libmpdec_machine=ansi64
4040 fi
4041 elif test $ac_cv_sizeof_size_t -eq 4; then
4042 if test "$ac_cv_gcc_asm_for_x87" = yes -a "$libmpdec_system" != sunos; then
4043 AS_CASE([$CC],
4044 [*gcc*], [libmpdec_machine=ppro],
4045 [*clang*], [libmpdec_machine=ppro],
4046 [libmpdec_machine=ansi32]
4047 )
4048 else
4049 libmpdec_machine=ansi32
4050 fi
4051 fi
4052 AC_MSG_RESULT([$libmpdec_machine])
4053
4054 AS_CASE([$libmpdec_machine],
4055 [x64], [AS_VAR_APPEND([LIBMPDEC_CFLAGS], [" -DCONFIG_64=1 -DASM=1"])],
4056 [uint128], [AS_VAR_APPEND([LIBMPDEC_CFLAGS], [" -DCONFIG_64=1 -DANSI=1 -DHAVE_UINT128_T=1"])],
4057 [ansi64], [AS_VAR_APPEND([LIBMPDEC_CFLAGS], [" -DCONFIG_64=1 -DANSI=1"])],
4058 [ppro], [AS_VAR_APPEND([LIBMPDEC_CFLAGS], [" -DCONFIG_32=1 -DANSI=1 -DASM=1 -Wno-unknown-pragmas"])],
4059 [ansi32], [AS_VAR_APPEND([LIBMPDEC_CFLAGS], [" -DCONFIG_32=1 -DANSI=1"])],
4060 [ansi-legacy], [AS_VAR_APPEND([LIBMPDEC_CFLAGS], [" -DCONFIG_32=1 -DANSI=1 -DLEGACY_COMPILER=1"])],
4061 [universal], [AS_VAR_APPEND([LIBMPDEC_CFLAGS], [" -DUNIVERSAL=1"])],
4062 [AC_MSG_ERROR([_decimal: unsupported architecture])]
4063 )])
4064
4065 if test "$have_ipa_pure_const_bug" = yes; then
4066 # Some versions of gcc miscompile inline asm:
4067 # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=46491
4068 # https://gcc.gnu.org/ml/gcc/2010-11/msg00366.html
4069 AS_VAR_APPEND([LIBMPDEC_CFLAGS], [" -fno-ipa-pure-const"])
4070 fi
4071
4072 if test "$have_glibc_memmove_bug" = yes; then
4073 # _FORTIFY_SOURCE wrappers for memmove and bcopy are incorrect:
4074 # https://sourceware.org/ml/libc-alpha/2010-12/msg00009.html
4075 AS_VAR_APPEND([LIBMPDEC_CFLAGS], [" -U_FORTIFY_SOURCE"])
4076 fi
4077
4078 AC_SUBST([LIBMPDEC_CFLAGS])
4079 AC_SUBST([LIBMPDEC_INTERNAL])
4080
4081
4082 dnl detect sqlite3 from Emscripten emport
4083 PY_CHECK_EMSCRIPTEN_PORT([LIBSQLITE3], [-sUSE_SQLITE3])
4084
4085 dnl Check for SQLite library. Use pkg-config if available.
4086 PKG_CHECK_MODULES(
4087 [LIBSQLITE3], [sqlite3 >= 3.15.2], [], [
4088 LIBSQLITE3_CFLAGS=${LIBSQLITE3_CFLAGS-""}
4089 LIBSQLITE3_LIBS=${LIBSQLITE3_LIBS-"-lsqlite3"}
4090 ]
4091 )
4092 AS_VAR_APPEND([LIBSQLITE3_CFLAGS], [' -I$(srcdir)/Modules/_sqlite'])
4093
4094 dnl PY_CHECK_SQLITE_FUNC(FUNCTION, IF-FOUND, IF-NOT-FOUND)
4095 AC_DEFUN([PY_CHECK_SQLITE_FUNC], [
4096 AC_CHECK_LIB([sqlite3], [$1], [$2], [
4097 m4_ifblank([$3], [have_supported_sqlite3=no], [$3])
4098 ])
4099 ])
4100
4101 WITH_SAVE_ENV([
4102 dnl bpo-45774/GH-29507: The CPP check in AC_CHECK_HEADER can fail on FreeBSD,
4103 dnl hence CPPFLAGS instead of CFLAGS.
4104 CPPFLAGS="$CPPFLAGS $LIBSQLITE3_CFLAGS"
4105 LDFLAGS="$LIBSQLITE3_LIBS $LDFLAGS"
4106
4107 AC_CHECK_HEADER([sqlite3.h], [
4108 have_sqlite3=yes
4109
4110 AC_COMPILE_IFELSE([
4111 AC_LANG_PROGRAM([
4112 #include <sqlite3.h>
4113 #if SQLITE_VERSION_NUMBER < 3015002
4114 # error "SQLite 3.15.2 or higher required"
4115 #endif
4116 ], [])
4117 ], [
4118 have_supported_sqlite3=yes
4119 dnl Check that required functions are in place. A lot of stuff may be
4120 dnl omitted with SQLITE_OMIT_* compile time defines.
4121 PY_CHECK_SQLITE_FUNC([sqlite3_bind_double])
4122 PY_CHECK_SQLITE_FUNC([sqlite3_column_decltype])
4123 PY_CHECK_SQLITE_FUNC([sqlite3_column_double])
4124 PY_CHECK_SQLITE_FUNC([sqlite3_complete])
4125 PY_CHECK_SQLITE_FUNC([sqlite3_progress_handler])
4126 PY_CHECK_SQLITE_FUNC([sqlite3_result_double])
4127 PY_CHECK_SQLITE_FUNC([sqlite3_set_authorizer])
4128 PY_CHECK_SQLITE_FUNC([sqlite3_trace_v2], [], [
4129 PY_CHECK_SQLITE_FUNC([sqlite3_trace])
4130 ])
4131 PY_CHECK_SQLITE_FUNC([sqlite3_value_double])
4132 AC_CHECK_LIB([sqlite3], [sqlite3_load_extension],
4133 [have_sqlite3_load_extension=yes],
4134 [have_sqlite3_load_extension=no]
4135 )
4136 AC_CHECK_LIB([sqlite3], [sqlite3_serialize], [
4137 AC_DEFINE(
4138 [PY_SQLITE_HAVE_SERIALIZE], [1],
4139 [Define if SQLite was compiled with the serialize API]
4140 )
4141 ])
4142 ], [
4143 have_supported_sqlite3=no
4144 ])
4145 ])
4146 ])
4147
4148 dnl Check for support for loadable sqlite extensions
4149 AC_MSG_CHECKING([for --enable-loadable-sqlite-extensions])
4150 AC_ARG_ENABLE([loadable-sqlite-extensions],
4151 AS_HELP_STRING(
4152 [--enable-loadable-sqlite-extensions], [
4153 support loadable extensions in the sqlite3 module, see
4154 Doc/library/sqlite3.rst (default is no)
4155 ]
4156 ), [
4157 AS_VAR_IF([have_sqlite3_load_extension], [no], [
4158 AC_MSG_RESULT([n/a])
4159 AC_MSG_WARN([Your version of SQLite does not support loadable extensions])
4160 ], [
4161 AC_MSG_RESULT([yes])
4162 AC_DEFINE(
4163 [PY_SQLITE_ENABLE_LOAD_EXTENSION], [1],
4164 [Define to 1 to build the sqlite module with loadable extensions support.]
4165 )
4166 ])
4167 ], [
4168 AC_MSG_RESULT([no])
4169 ]
4170 )
4171
4172 dnl
4173 dnl Detect Tcl/Tk. Use pkg-config if available.
4174 dnl
4175 found_tcltk=no
4176 for _QUERY in \
4177 "tcl >= 8.5.12 tk >= 8.5.12" \
4178 "tcl8.6 tk8.6" \
4179 "tcl86 tk86" \
4180 "tcl8.5 >= 8.5.12 tk8.5 >= 8.5.12" \
4181 "tcl85 >= 8.5.12 tk85 >= 8.5.12" \
4182 ; do
4183 PKG_CHECK_EXISTS([$_QUERY], [
4184 PKG_CHECK_MODULES([TCLTK], [$_QUERY], [found_tcltk=yes], [found_tcltk=no])
4185 ])
4186 AS_VAR_IF([found_tcltk], [yes], [break])
4187 done
4188
4189 AS_VAR_IF([found_tcltk], [no], [
4190 TCLTK_CFLAGS=${TCLTK_CFLAGS-""}
4191 TCLTK_LIBS=${TCLTK_LIBS-""}
4192 ])
4193
4194 dnl FreeBSD has an X11 dependency which is not implicitly resolved.
4195 AS_CASE([$ac_sys_system],
4196 [FreeBSD*], [
4197 PKG_CHECK_EXISTS([x11], [
4198 PKG_CHECK_MODULES([X11], [x11], [
4199 TCLTK_CFLAGS="$TCLTK_CFLAGS $X11_CFLAGS"
4200 TCLTK_LIBS="$TCLTK_LIBS $X11_LIBS"
4201 ])
4202 ])
4203 ]
4204 )
4205
4206 WITH_SAVE_ENV([
4207 CPPFLAGS="$CPPFLAGS $TCLTK_CFLAGS"
4208 LIBS="$TCLTK_LIBS $LDFLAGS"
4209
4210 AC_LINK_IFELSE([
4211 AC_LANG_PROGRAM([
4212 #include <tcl.h>
4213 #include <tk.h>
4214 #if defined(TK_HEX_VERSION)
4215 # if TK_HEX_VERSION < 0x0805020c
4216 # error "Tk older than 8.5.12 not supported"
4217 # endif
4218 #endif
4219 #if (TCL_MAJOR_VERSION < 8) || \
4220 ((TCL_MAJOR_VERSION == 8) && (TCL_MINOR_VERSION < 5)) || \
4221 ((TCL_MAJOR_VERSION == 8) && (TCL_MINOR_VERSION == 5) && (TCL_RELEASE_SERIAL < 12))
4222 # error "Tcl older than 8.5.12 not supported"
4223 #endif
4224 #if (TK_MAJOR_VERSION < 8) || \
4225 ((TK_MAJOR_VERSION == 8) && (TK_MINOR_VERSION < 5)) || \
4226 ((TK_MAJOR_VERSION == 8) && (TK_MINOR_VERSION == 5) && (TK_RELEASE_SERIAL < 12))
4227 # error "Tk older than 8.5.12 not supported"
4228 #endif
4229 ], [
4230 void *x1 = Tcl_Init;
4231 void *x2 = Tk_Init;
4232 ])
4233 ], [
4234 have_tcltk=yes
4235 dnl The X11/xlib.h file bundled in the Tk sources can cause function
4236 dnl prototype warnings from the compiler. Since we cannot easily fix
4237 dnl that, suppress the warnings here instead.
4238 AS_VAR_APPEND([TCLTK_CFLAGS], [" -Wno-strict-prototypes -DWITH_APPINIT=1"])
4239 ], [
4240 have_tcltk=no
4241 ])
4242 ])
4243
4244 dnl check for _gdbmmodule dependencies
4245 dnl NOTE: gdbm does not provide a pkgconf file.
4246 AC_ARG_VAR([GDBM_CFLAGS], [C compiler flags for gdbm])
4247 AC_ARG_VAR([GDBM_LIBS], [additional linker flags for gdbm])
4248 WITH_SAVE_ENV([
4249 CPPFLAGS="$CPPFLAGS $GDBM_CFLAGS"
4250 LDFLAGS="$GDBM_LIBS $LDFLAGS"
4251 AC_CHECK_HEADERS([gdbm.h], [
4252 AC_CHECK_LIB([gdbm], [gdbm_open], [
4253 have_gdbm=yes
4254 GDBM_LIBS=${GDBM_LIBS-"-lgdbm"}
4255 ], [have_gdbm=no])
4256 ], [have_gdbm=no])
4257 ])
4258
4259 dnl check for _dbmmodule.c dependencies
4260 dnl ndbm, gdbm_compat, libdb
4261 AC_CHECK_HEADERS([ndbm.h], [
4262 WITH_SAVE_ENV([
4263 AC_SEARCH_LIBS([dbm_open], [ndbm gdbm_compat])
4264 ])
4265 ])
4266
4267 AC_MSG_CHECKING([for ndbm presence and linker args])
4268 AS_CASE([$ac_cv_search_dbm_open],
4269 [*ndbm*|*gdbm_compat*], [
4270 dbm_ndbm="$ac_cv_search_dbm_open"
4271 have_ndbm=yes
4272 ],
4273 [none*], [
4274 dbm_ndbm=""
4275 have_ndbm=yes
4276 ],
4277 [no], [have_ndbm=no]
4278 )
4279 AC_MSG_RESULT([$have_ndbm ($dbm_ndbm)])
4280
4281 dnl "gdbm-ndbm.h" and "gdbm/ndbm.h" are both normalized to "gdbm_ndbm_h"
4282 dnl unset ac_cv_header_gdbm_ndbm_h to prevent false positive cache hits.
4283 AS_UNSET([ac_cv_header_gdbm_ndbm_h])
4284 AC_CACHE_VAL([ac_cv_header_gdbm_slash_ndbm_h], [
4285 AC_CHECK_HEADER(
4286 [gdbm/ndbm.h],
4287 [ac_cv_header_gdbm_slash_ndbm_h=yes], [ac_cv_header_gdbm_slash_ndbm_h=no]
4288 )
4289 ])
4290 AS_VAR_IF([ac_cv_header_gdbm_slash_ndbm_h], [yes], [
4291 AC_DEFINE([HAVE_GDBM_NDBM_H], [1], [Define to 1 if you have the <gdbm/ndbm.h> header file.])
4292 ])
4293
4294 AS_UNSET([ac_cv_header_gdbm_ndbm_h])
4295 AC_CACHE_VAL([ac_cv_header_gdbm_dash_ndbm_h], [
4296 AC_CHECK_HEADER(
4297 [gdbm-ndbm.h],
4298 [ac_cv_header_gdbm_dash_ndbm_h=yes], [ac_cv_header_gdbm_dash_ndbm_h=no]
4299 )
4300 ])
4301 AS_VAR_IF([ac_cv_header_gdbm_dash_ndbm_h], [yes], [
4302 AC_DEFINE([HAVE_GDBM_DASH_NDBM_H], [1], [Define to 1 if you have the <gdbm-ndbm.h> header file.])
4303 ])
4304 AS_UNSET([ac_cv_header_gdbm_ndbm_h])
4305
4306 if test "$ac_cv_header_gdbm_slash_ndbm_h" = yes -o "$ac_cv_header_gdbm_dash_ndbm_h" = yes; then
4307 AS_UNSET([ac_cv_search_dbm_open])
4308 WITH_SAVE_ENV([
4309 AC_SEARCH_LIBS([dbm_open], [gdbm_compat], [have_gdbm_compat=yes], [have_gdbm_compat=no])
4310 ])
4311 fi
4312
4313 # Check for libdb >= 5 with dbm_open()
4314 # db.h re-defines the name of the function
4315 AC_CHECK_HEADERS([db.h], [
4316 AC_CACHE_CHECK([for libdb], [ac_cv_have_libdb], [
4317 WITH_SAVE_ENV([
4318 LIBS="$LIBS -ldb"
4319 AC_LINK_IFELSE([AC_LANG_PROGRAM([
4320 #define DB_DBM_HSEARCH 1
4321 #include <db.h>
4322 #if DB_VERSION_MAJOR < 5
4323 #error "dh.h: DB_VERSION_MAJOR < 5 is not supported."
4324 #endif
4325 ], [DBM *dbm = dbm_open(NULL, 0, 0)])
4326 ], [ac_cv_have_libdb=yes], [ac_cv_have_libdb=no])
4327 ])
4328 ])
4329 AS_VAR_IF([ac_cv_have_libdb], [yes], [
4330 AC_DEFINE([HAVE_LIBDB], [1], [Define to 1 if you have the `db' library (-ldb).])
4331 ])
4332 ])
4333
4334 # Check for --with-dbmliborder
4335 AC_MSG_CHECKING([for --with-dbmliborder])
4336 AC_ARG_WITH(
4337 [dbmliborder],
4338 [AS_HELP_STRING(
4339 [--with-dbmliborder=db1:db2:...],
4340 [override order to check db backends for dbm; a valid value is a colon separated string with the backend names `ndbm', `gdbm' and `bdb'.]
4341 )],
4342 [], [with_dbmliborder=gdbm:ndbm:bdb])
4343
4344 have_gdbm_dbmliborder=no
4345 as_save_IFS=$IFS
4346 IFS=:
4347 for db in $with_dbmliborder; do
4348 AS_CASE([$db],
4349 [ndbm], [],
4350 [gdbm], [have_gdbm_dbmliborder=yes],
4351 [bdb], [],
4352 [with_dbmliborder=error]
4353 )
4354 done
4355 IFS=$as_save_IFS
4356 AS_VAR_IF([with_dbmliborder], [error], [
4357 AC_MSG_ERROR([proper usage is --with-dbmliborder=db1:db2:... (gdbm:ndbm:bdb)])
4358 ])
4359 AC_MSG_RESULT([$with_dbmliborder])
4360
4361 AC_MSG_CHECKING([for _dbm module CFLAGS and LIBS])
4362 have_dbm=no
4363 as_save_IFS=$IFS
4364 IFS=:
4365 for db in $with_dbmliborder; do
4366 case "$db" in
4367 ndbm)
4368 if test "$have_ndbm" = yes; then
4369 DBM_CFLAGS="-DUSE_NDBM"
4370 DBM_LIBS="$dbm_ndbm"
4371 have_dbm=yes
4372 break
4373 fi
4374 ;;
4375 gdbm)
4376 if test "$have_gdbm_compat" = yes; then
4377 DBM_CFLAGS="-DUSE_GDBM_COMPAT"
4378 DBM_LIBS="-lgdbm_compat"
4379 have_dbm=yes
4380 break
4381 fi
4382 ;;
4383 bdb)
4384 if test "$ac_cv_have_libdb" = yes; then
4385 DBM_CFLAGS="-DUSE_BERKDB"
4386 DBM_LIBS="-ldb"
4387 have_dbm=yes
4388 break
4389 fi
4390 ;;
4391 esac
4392 done
4393 IFS=$as_save_IFS
4394 AC_MSG_RESULT([$DBM_CFLAGS $DBM_LIBS])
4395
4396 # Templates for things AC_DEFINEd more than once.
4397 # For a single AC_DEFINE, no template is needed.
4398 AH_TEMPLATE([_REENTRANT],
4399 [Define to force use of thread-safe errno, h_errno, and other functions])
4400
4401 if test "$ac_cv_pthread_is_default" = yes
4402 then
4403 # Defining _REENTRANT on system with POSIX threads should not hurt.
4404 AC_DEFINE([_REENTRANT])
4405 posix_threads=yes
4406 if test "$ac_sys_system" = "SunOS"; then
4407 CFLAGS="$CFLAGS -D_REENTRANT"
4408 fi
4409 elif test "$ac_cv_kpthread" = "yes"
4410 then
4411 CC="$CC -Kpthread"
4412 if test "$ac_cv_cxx_thread" = "yes"; then
4413 CXX="$CXX -Kpthread"
4414 fi
4415 posix_threads=yes
4416 elif test "$ac_cv_kthread" = "yes"
4417 then
4418 CC="$CC -Kthread"
4419 if test "$ac_cv_cxx_thread" = "yes"; then
4420 CXX="$CXX -Kthread"
4421 fi
4422 posix_threads=yes
4423 elif test "$ac_cv_pthread" = "yes"
4424 then
4425 CC="$CC -pthread"
4426 if test "$ac_cv_cxx_thread" = "yes"; then
4427 CXX="$CXX -pthread"
4428 fi
4429 posix_threads=yes
4430 else
4431 if test ! -z "$withval" -a -d "$withval"
4432 then LDFLAGS="$LDFLAGS -L$withval"
4433 fi
4434
4435 # According to the POSIX spec, a pthreads implementation must
4436 # define _POSIX_THREADS in unistd.h. Some apparently don't
4437 # (e.g. gnu pth with pthread emulation)
4438 AC_MSG_CHECKING([for _POSIX_THREADS in unistd.h])
4439 AX_CHECK_DEFINE([unistd.h], [_POSIX_THREADS],
4440 [unistd_defines_pthreads=yes],
4441 [unistd_defines_pthreads=no])
4442 AC_MSG_RESULT([$unistd_defines_pthreads])
4443
4444 AC_DEFINE([_REENTRANT])
4445 # Just looking for pthread_create in libpthread is not enough:
4446 # on HP/UX, pthread.h renames pthread_create to a different symbol name.
4447 # So we really have to include pthread.h, and then link.
4448 _libs=$LIBS
4449 LIBS="$LIBS -lpthread"
4450 AC_MSG_CHECKING([for pthread_create in -lpthread])
4451 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
4452 #include <stdio.h>
4453 #include <stdlib.h>
4454 #include <pthread.h>
4455
4456 void * start_routine (void *arg) { exit (0); }]], [[
4457 pthread_create (NULL, NULL, start_routine, NULL)]])],[
4458 AC_MSG_RESULT([yes])
4459 posix_threads=yes
4460 ],[
4461 LIBS=$_libs
4462 AC_CHECK_FUNC([pthread_detach], [
4463 posix_threads=yes
4464 ],[
4465 AC_CHECK_LIB([pthreads], [pthread_create], [
4466 posix_threads=yes
4467 LIBS="$LIBS -lpthreads"
4468 ], [
4469 AC_CHECK_LIB([c_r], [pthread_create], [
4470 posix_threads=yes
4471 LIBS="$LIBS -lc_r"
4472 ], [
4473 AC_CHECK_LIB([pthread], [__pthread_create_system], [
4474 posix_threads=yes
4475 LIBS="$LIBS -lpthread"
4476 ], [
4477 AC_CHECK_LIB([cma], [pthread_create], [
4478 posix_threads=yes
4479 LIBS="$LIBS -lcma"
4480 ],[
4481 AS_CASE([$ac_sys_system],
4482 [WASI], [posix_threads=stub],
4483 [AC_MSG_ERROR([could not find pthreads on your system])]
4484 )
4485 ])])])])])])
4486
4487 AC_CHECK_LIB([mpc], [usconfig], [
4488 LIBS="$LIBS -lmpc"
4489 ])
4490
4491 fi
4492
4493 if test "$posix_threads" = "yes"; then
4494 if test "$unistd_defines_pthreads" = "no"; then
4495 AC_DEFINE([_POSIX_THREADS], [1],
4496 [Define if you have POSIX threads,
4497 and your system does not define that.])
4498 fi
4499
4500 # Bug 662787: Using semaphores causes unexplicable hangs on Solaris 8.
4501 case $ac_sys_system/$ac_sys_release in
4502 SunOS/5.6) AC_DEFINE([HAVE_PTHREAD_DESTRUCTOR], [1],
4503 [Defined for Solaris 2.6 bug in pthread header.])
4504 ;;
4505 SunOS/5.8) AC_DEFINE([HAVE_BROKEN_POSIX_SEMAPHORES], [1],
4506 [Define if the Posix semaphores do not work on your system])
4507 ;;
4508 AIX/*) AC_DEFINE([HAVE_BROKEN_POSIX_SEMAPHORES], [1],
4509 [Define if the Posix semaphores do not work on your system])
4510 ;;
4511 NetBSD/*) AC_DEFINE([HAVE_BROKEN_POSIX_SEMAPHORES], [1],
4512 [Define if the Posix semaphores do not work on your system])
4513 ;;
4514 esac
4515
4516 AC_CACHE_CHECK([if PTHREAD_SCOPE_SYSTEM is supported], [ac_cv_pthread_system_supported],
4517 [AC_RUN_IFELSE([AC_LANG_SOURCE([[
4518 #include <stdio.h>
4519 #include <pthread.h>
4520 void *foo(void *parm) {
4521 return NULL;
4522 }
4523 int main(void) {
4524 pthread_attr_t attr;
4525 pthread_t id;
4526 if (pthread_attr_init(&attr)) return (-1);
4527 if (pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM)) return (-1);
4528 if (pthread_create(&id, &attr, foo, NULL)) return (-1);
4529 return (0);
4530 }]])],
4531 [ac_cv_pthread_system_supported=yes],
4532 [ac_cv_pthread_system_supported=no],
4533 [ac_cv_pthread_system_supported=no])
4534 ])
4535 if test "$ac_cv_pthread_system_supported" = "yes"; then
4536 AC_DEFINE([PTHREAD_SYSTEM_SCHED_SUPPORTED], [1],
4537 [Defined if PTHREAD_SCOPE_SYSTEM supported.])
4538 fi
4539 AC_CHECK_FUNCS([pthread_sigmask],
4540 [case $ac_sys_system in
4541 CYGWIN*)
4542 AC_DEFINE([HAVE_BROKEN_PTHREAD_SIGMASK], [1],
4543 [Define if pthread_sigmask() does not work on your system.])
4544 ;;
4545 esac])
4546 AC_CHECK_FUNCS([pthread_getcpuclockid])
4547 fi
4548
4549 AS_VAR_IF([posix_threads], [stub], [
4550 AC_DEFINE([HAVE_PTHREAD_STUBS], [1], [Define if platform requires stubbed pthreads support])
4551 ])
4552
4553 # Check for enable-ipv6
4554 AH_TEMPLATE([ENABLE_IPV6], [Define if --enable-ipv6 is specified])
4555 AC_MSG_CHECKING([if --enable-ipv6 is specified])
4556 AC_ARG_ENABLE([ipv6],
4557 [AS_HELP_STRING(
4558 [--enable-ipv6],
4559 [enable ipv6 (with ipv4) support, see Doc/library/socket.rst (default is yes if supported)]
4560 )],
4561 [ case "$enableval" in
4562 no)
4563 AC_MSG_RESULT([no])
4564 ipv6=no
4565 ;;
4566 *) AC_MSG_RESULT([yes])
4567 AC_DEFINE([ENABLE_IPV6])
4568 ipv6=yes
4569 ;;
4570 esac ],
4571
4572 [
4573 dnl the check does not work on cross compilation case...
4574 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ /* AF_INET6 available check */
4575 #include <sys/types.h>
4576 @%:@include <sys/socket.h>]],
4577 [[int domain = AF_INET6;]])],[
4578 ipv6=yes
4579 ],[
4580 ipv6=no
4581 ])
4582
4583 AS_CASE([$ac_sys_system],
4584 [WASI], [ipv6=no]
4585 )
4586
4587 AC_MSG_RESULT([$ipv6])
4588
4589 if test "$ipv6" = "yes"; then
4590 AC_MSG_CHECKING([if RFC2553 API is available])
4591 AC_COMPILE_IFELSE([
4592 AC_LANG_PROGRAM([[#include <sys/types.h>
4593 @%:@include <netinet/in.h>]],
4594 [[struct sockaddr_in6 x;
4595 x.sin6_scope_id;]])
4596 ],[
4597 AC_MSG_RESULT([yes])
4598 ipv6=yes
4599 ],[
4600 AC_MSG_RESULT([no], [IPv6 disabled])
4601 ipv6=no
4602 ])
4603 fi
4604
4605 if test "$ipv6" = "yes"; then
4606 AC_DEFINE([ENABLE_IPV6])
4607 fi
4608 ])
4609
4610 ipv6type=unknown
4611 ipv6lib=none
4612 ipv6trylibc=no
4613
4614 if test "$ipv6" = yes -a "$cross_compiling" = no; then
4615 for i in inria kame linux-glibc linux-inet6 solaris toshiba v6d zeta;
4616 do
4617 case $i in
4618 inria)
4619 dnl http://www.kame.net/
4620 AX_CHECK_DEFINE([netinet/in.h], [IPV6_INRIA_VERSION], [ipv6type=$i])
4621 ;;
4622 kame)
4623 dnl http://www.kame.net/
4624 AX_CHECK_DEFINE([netinet/in.h], [__KAME__],
4625 [ipv6type=$i
4626 ipv6lib=inet6
4627 ipv6libdir=/usr/local/v6/lib
4628 ipv6trylibc=yes])
4629 ;;
4630 linux-glibc)
4631 dnl Advanced IPv6 support was added to glibc 2.1 in 1999.
4632 AX_CHECK_DEFINE([features.h], [__GLIBC__],
4633 [ipv6type=$i
4634 ipv6trylibc=yes])
4635 ;;
4636 linux-inet6)
4637 dnl http://www.v6.linux.or.jp/
4638 if test -d /usr/inet6; then
4639 ipv6type=$i
4640 ipv6lib=inet6
4641 ipv6libdir=/usr/inet6/lib
4642 BASECFLAGS="-I/usr/inet6/include $BASECFLAGS"
4643 fi
4644 ;;
4645 solaris)
4646 if test -f /etc/netconfig; then
4647 if $GREP -q tcp6 /etc/netconfig; then
4648 ipv6type=$i
4649 ipv6trylibc=yes
4650 fi
4651 fi
4652 ;;
4653 toshiba)
4654 AX_CHECK_DEFINE([sys/param.h], [_TOSHIBA_INET6],
4655 [ipv6type=$i
4656 ipv6lib=inet6
4657 ipv6libdir=/usr/local/v6/lib])
4658 ;;
4659 v6d)
4660 AX_CHECK_DEFINE([/usr/local/v6/include/sys/v6config.h], [__V6D__],
4661 [ipv6type=$i
4662 ipv6lib=v6
4663 ipv6libdir=/usr/local/v6/lib
4664 BASECFLAGS="-I/usr/local/v6/include $BASECFLAGS"])
4665 ;;
4666 zeta)
4667 AX_CHECK_DEFINE([sys/param.h], [_ZETA_MINAMI_INET6],
4668 [ipv6type=$i
4669 ipv6lib=inet6
4670 ipv6libdir=/usr/local/v6/lib])
4671 ;;
4672 esac
4673 if test "$ipv6type" != "unknown"; then
4674 break
4675 fi
4676 done
4677 AC_MSG_CHECKING([ipv6 stack type])
4678 AC_MSG_RESULT([$ipv6type])
4679 fi
4680
4681 if test "$ipv6" = "yes" -a "$ipv6lib" != "none"; then
4682 AC_MSG_CHECKING([ipv6 library])
4683 if test -d $ipv6libdir -a -f $ipv6libdir/lib$ipv6lib.a; then
4684 LIBS="-L$ipv6libdir -l$ipv6lib $LIBS"
4685 AC_MSG_RESULT([lib$ipv6lib])
4686 else
4687 AS_VAR_IF([ipv6trylibc], [yes], [
4688 AC_MSG_RESULT([libc])
4689 ], [
4690 AC_MSG_ERROR([m4_normalize([
4691 No $ipv6lib library found; cannot continue.
4692 You need to fetch lib$ipv6lib.a from appropriate
4693 ipv6 kit and compile beforehand.
4694 ])])
4695 ])
4696 fi
4697 fi
4698
4699
4700 AC_CACHE_CHECK([CAN_RAW_FD_FRAMES], [ac_cv_can_raw_fd_frames], [
4701 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ /* CAN_RAW_FD_FRAMES available check */
4702 @%:@include <linux/can/raw.h>]],
4703 [[int can_raw_fd_frames = CAN_RAW_FD_FRAMES;]])],
4704 [ac_cv_can_raw_fd_frames=yes],
4705 [ac_cv_can_raw_fd_frames=no])
4706 ])
4707 AS_VAR_IF([ac_cv_can_raw_fd_frames], [yes], [
4708 AC_DEFINE([HAVE_LINUX_CAN_RAW_FD_FRAMES], [1],
4709 [Define if compiling using Linux 3.6 or later.])
4710 ])
4711
4712 AC_CACHE_CHECK([for CAN_RAW_JOIN_FILTERS], [ac_cv_can_raw_join_filters], [
4713 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4714 @%:@include <linux/can/raw.h>]],
4715 [[int can_raw_join_filters = CAN_RAW_JOIN_FILTERS;]])],
4716 [ac_cv_can_raw_join_filters=yes],
4717 [ac_cv_can_raw_join_filters=no])
4718 ])
4719 AS_VAR_IF([ac_cv_can_raw_join_filters], [yes], [
4720 AC_DEFINE([HAVE_LINUX_CAN_RAW_JOIN_FILTERS], [1],
4721 [Define if compiling using Linux 4.1 or later.])
4722 ])
4723
4724 # Check for --with-doc-strings
4725 AC_MSG_CHECKING([for --with-doc-strings])
4726 AC_ARG_WITH(
4727 [doc-strings],
4728 [AS_HELP_STRING([--with-doc-strings], [enable documentation strings (default is yes)])])
4729
4730 if test -z "$with_doc_strings"
4731 then with_doc_strings="yes"
4732 fi
4733 if test "$with_doc_strings" != "no"
4734 then
4735 AC_DEFINE([WITH_DOC_STRINGS], [1],
4736 [Define if you want documentation strings in extension modules])
4737 fi
4738 AC_MSG_RESULT([$with_doc_strings])
4739
4740 # Check for stdatomic.h, required for mimalloc.
4741 AC_CACHE_CHECK([for stdatomic.h], [ac_cv_header_stdatomic_h], [
4742 AC_LINK_IFELSE(
4743 [
4744 AC_LANG_SOURCE([[
4745 #include <stdatomic.h>
4746 atomic_int int_var;
4747 atomic_uintptr_t uintptr_var;
4748 int main() {
4749 atomic_store_explicit(&int_var, 5, memory_order_relaxed);
4750 atomic_store_explicit(&uintptr_var, 0, memory_order_relaxed);
4751 int loaded_value = atomic_load_explicit(&int_var, memory_order_seq_cst);
4752 return 0;
4753 }
4754 ]])
4755 ],[ac_cv_header_stdatomic_h=yes],[ac_cv_header_stdatomic_h=no])
4756 ])
4757
4758 AS_VAR_IF([ac_cv_header_stdatomic_h], [yes], [
4759 AC_DEFINE(HAVE_STD_ATOMIC, 1,
4760 [Has stdatomic.h with atomic_int and atomic_uintptr_t])
4761 ])
4762
4763 # Check for GCC >= 4.7 and clang __atomic builtin functions
4764 AC_CACHE_CHECK([for builtin __atomic_load_n and __atomic_store_n functions], [ac_cv_builtin_atomic], [
4765 AC_LINK_IFELSE(
4766 [
4767 AC_LANG_SOURCE([[
4768 int val;
4769 int main() {
4770 __atomic_store_n(&val, 1, __ATOMIC_SEQ_CST);
4771 (void)__atomic_load_n(&val, __ATOMIC_SEQ_CST);
4772 return 0;
4773 }
4774 ]])
4775 ],[ac_cv_builtin_atomic=yes],[ac_cv_builtin_atomic=no])
4776 ])
4777
4778 AS_VAR_IF([ac_cv_builtin_atomic], [yes], [
4779 AC_DEFINE(HAVE_BUILTIN_ATOMIC, 1, [Has builtin __atomic_load_n() and __atomic_store_n() functions])
4780 ])
4781
4782 # --with-mimalloc
4783 AC_MSG_CHECKING([for --with-mimalloc])
4784 AC_ARG_WITH([mimalloc],
4785 [AS_HELP_STRING([--with-mimalloc],
4786 [build with mimalloc memory allocator (default is yes if C11 stdatomic.h is available.)])],
4787 [],
4788 [with_mimalloc="$ac_cv_header_stdatomic_h"]
4789 )
4790
4791 if test "$with_mimalloc" != no; then
4792 if test "$ac_cv_header_stdatomic_h" != yes; then
4793 # mimalloc-atomic.h wants C11 stdatomic.h on POSIX
4794 AC_MSG_ERROR([mimalloc requires stdatomic.h, use --without-mimalloc to disable mimalloc.])
4795 fi
4796 with_mimalloc=yes
4797 AC_DEFINE([WITH_MIMALLOC], [1], [Define if you want to compile in mimalloc memory allocator.])
4798 AC_SUBST([MIMALLOC_HEADERS], ['$(MIMALLOC_HEADERS)'])
4799 elif test "$disable_gil" = "yes"; then
4800 AC_MSG_ERROR([--disable-gil requires mimalloc memory allocator (--with-mimalloc).])
4801 fi
4802
4803 AC_MSG_RESULT([$with_mimalloc])
4804 AC_SUBST([INSTALL_MIMALLOC], [$with_mimalloc])
4805 AC_SUBST([MIMALLOC_HEADERS])
4806
4807 # Check for Python-specific malloc support
4808 AC_MSG_CHECKING([for --with-pymalloc])
4809 AC_ARG_WITH(
4810 [pymalloc],
4811 [AS_HELP_STRING([--with-pymalloc], [enable specialized mallocs (default is yes)])])
4812
4813 if test -z "$with_pymalloc"
4814 then
4815 dnl default to yes except for wasm32-emscripten and wasm32-wasi.
4816 AS_CASE([$ac_sys_system],
4817 [Emscripten], [with_pymalloc="no"],
4818 [WASI], [with_pymalloc="no"],
4819 [with_pymalloc="yes"]
4820 )
4821 fi
4822 if test "$with_pymalloc" != "no"
4823 then
4824 AC_DEFINE([WITH_PYMALLOC], [1],
4825 [Define if you want to compile in Python-specific mallocs])
4826 fi
4827 AC_MSG_RESULT([$with_pymalloc])
4828
4829 # Check whether objects such as float, tuple and dict are using
4830 # freelists to optimization memory allocation.
4831 AC_MSG_CHECKING([for --with-freelists])
4832 AC_ARG_WITH(
4833 [freelists],
4834 [AS_HELP_STRING([--with-freelists], [enable object freelists (default is yes)])])
4835
4836 if test -z "$with_freelists"
4837 then
4838 with_freelists="yes"
4839 fi
4840 if test "$with_freelists" != "no"
4841 then
4842 AC_DEFINE([WITH_FREELISTS], [1],
4843 [Define if you want to compile in object freelists optimization])
4844 fi
4845 AC_MSG_RESULT([$with_freelists])
4846
4847 # Check for --with-c-locale-coercion
4848 AC_MSG_CHECKING([for --with-c-locale-coercion])
4849 AC_ARG_WITH(
4850 [c-locale-coercion],
4851 [AS_HELP_STRING([--with-c-locale-coercion], [enable C locale coercion to a UTF-8 based locale (default is yes)])])
4852
4853 if test -z "$with_c_locale_coercion"
4854 then
4855 with_c_locale_coercion="yes"
4856 fi
4857 if test "$with_c_locale_coercion" != "no"
4858 then
4859 AC_DEFINE([PY_COERCE_C_LOCALE], [1],
4860 [Define if you want to coerce the C locale to a UTF-8 based locale])
4861 fi
4862 AC_MSG_RESULT([$with_c_locale_coercion])
4863
4864 # Check for Valgrind support
4865 AC_MSG_CHECKING([for --with-valgrind])
4866 AC_ARG_WITH(
4867 [valgrind],
4868 [AS_HELP_STRING([--with-valgrind], [enable Valgrind support (default is no)])],
4869 [], [with_valgrind=no]
4870 )
4871 AC_MSG_RESULT([$with_valgrind])
4872 if test "$with_valgrind" != no; then
4873 AC_CHECK_HEADER([valgrind/valgrind.h],
4874 [AC_DEFINE([WITH_VALGRIND], 1, [Define if you want pymalloc to be disabled when running under valgrind])],
4875 [AC_MSG_ERROR([Valgrind support requested but headers not available])]
4876 )
4877 OPT="-DDYNAMIC_ANNOTATIONS_ENABLED=1 $OPT"
4878 fi
4879
4880 # Check for DTrace support
4881 AC_MSG_CHECKING([for --with-dtrace])
4882 AC_ARG_WITH(
4883 [dtrace],
4884 [AS_HELP_STRING([--with-dtrace], [enable DTrace support (default is no)])],
4885 [], [with_dtrace=no])
4886 AC_MSG_RESULT([$with_dtrace])
4887
4888 AC_SUBST([DTRACE])
4889 AC_SUBST([DFLAGS])
4890 AC_SUBST([DTRACE_HEADERS])
4891 AC_SUBST([DTRACE_OBJS])
4892 DTRACE=
4893 DTRACE_HEADERS=
4894 DTRACE_OBJS=
4895
4896 if test "$with_dtrace" = "yes"
4897 then
4898 AC_PATH_PROG([DTRACE], [dtrace], [not found])
4899 if test "$DTRACE" = "not found"; then
4900 AC_MSG_ERROR([dtrace command not found on \$PATH])
4901 fi
4902 AC_DEFINE([WITH_DTRACE], [1],
4903 [Define if you want to compile in DTrace support])
4904 DTRACE_HEADERS="Include/pydtrace_probes.h"
4905
4906 # On OS X, DTrace providers do not need to be explicitly compiled and
4907 # linked into the binary. Correspondingly, dtrace(1) is missing the ELF
4908 # generation flag '-G'. We check for presence of this flag, rather than
4909 # hardcoding support by OS, in the interest of robustness.
4910 AC_CACHE_CHECK([whether DTrace probes require linking],
4911 [ac_cv_dtrace_link], [dnl
4912 ac_cv_dtrace_link=no
4913 echo 'BEGIN{}' > conftest.d
4914 "$DTRACE" $DFLAGS -G -s conftest.d -o conftest.o > /dev/null 2>&1 && \
4915 ac_cv_dtrace_link=yes
4916 ])
4917 if test "$ac_cv_dtrace_link" = "yes"; then
4918 DTRACE_OBJS="Python/pydtrace.o"
4919 fi
4920 fi
4921
4922 dnl Platform-specific C and header files.
4923 PLATFORM_HEADERS=
4924 PLATFORM_OBJS=
4925
4926 AS_CASE([$ac_sys_system],
4927 [Emscripten], [
4928 AS_VAR_APPEND([PLATFORM_OBJS], [' Python/emscripten_signal.o Python/emscripten_trampoline.o'])
4929 AS_VAR_APPEND([PLATFORM_HEADERS], [' $(srcdir)/Include/internal/pycore_emscripten_signal.h $(srcdir)/Include/internal/pycore_emscripten_trampoline.h'])
4930 ],
4931 )
4932 AC_SUBST([PLATFORM_HEADERS])
4933 AC_SUBST([PLATFORM_OBJS])
4934
4935 # -I${DLINCLDIR} is added to the compile rule for importdl.o
4936 AC_SUBST([DLINCLDIR])
4937 DLINCLDIR=.
4938
4939 # the dlopen() function means we might want to use dynload_shlib.o. some
4940 # platforms have dlopen(), but don't want to use it.
4941 AC_CHECK_FUNCS([dlopen])
4942
4943 # DYNLOADFILE specifies which dynload_*.o file we will use for dynamic
4944 # loading of modules.
4945 AC_SUBST([DYNLOADFILE])
4946 AC_MSG_CHECKING([DYNLOADFILE])
4947 if test -z "$DYNLOADFILE"
4948 then
4949 case $ac_sys_system/$ac_sys_release in
4950 hp*|HP*) DYNLOADFILE="dynload_hpux.o";;
4951 *)
4952 # use dynload_shlib.c and dlopen() if we have it; otherwise stub
4953 # out any dynamic loading
4954 if test "$ac_cv_func_dlopen" = yes
4955 then DYNLOADFILE="dynload_shlib.o"
4956 else DYNLOADFILE="dynload_stub.o"
4957 fi
4958 ;;
4959 esac
4960 fi
4961 AC_MSG_RESULT([$DYNLOADFILE])
4962 if test "$DYNLOADFILE" != "dynload_stub.o"
4963 then
4964 AC_DEFINE([HAVE_DYNAMIC_LOADING], [1],
4965 [Defined when any dynamic module loading is enabled.])
4966 fi
4967
4968 # MACHDEP_OBJS can be set to platform-specific object files needed by Python
4969
4970 AC_SUBST([MACHDEP_OBJS])
4971 AC_MSG_CHECKING([MACHDEP_OBJS])
4972 if test -z "$MACHDEP_OBJS"
4973 then
4974 MACHDEP_OBJS=$extra_machdep_objs
4975 else
4976 MACHDEP_OBJS="$MACHDEP_OBJS $extra_machdep_objs"
4977 fi
4978 if test -z "$MACHDEP_OBJS"; then
4979 AC_MSG_RESULT([none])
4980 else
4981 AC_MSG_RESULT([$MACHDEP_OBJS])
4982 fi
4983
4984 if test "$ac_sys_system" = "Linux-android"; then
4985 # When these functions are used in an unprivileged process, they crash rather
4986 # than returning an error.
4987 blocked_funcs="chroot initgroups setegid seteuid setgid sethostname
4988 setregid setresgid setresuid setreuid setuid"
4989
4990 # These functions are unimplemented and always return an error
4991 # (https://android.googlesource.com/platform/system/sepolicy/+/refs/heads/android13-release/public/domain.te#1044)
4992 blocked_funcs="$blocked_funcs sem_open sem_unlink"
4993
4994 # Before API level 23, when fchmodat is called with the unimplemented flag
4995 # AT_SYMLINK_NOFOLLOW, instead of returning ENOTSUP as it should, it actually
4996 # follows the symlink.
4997 if test "$ANDROID_API_LEVEL" -lt 23; then
4998 blocked_funcs="$blocked_funcs fchmodat"
4999 fi
5000
5001 for name in $blocked_funcs; do
5002 AS_VAR_PUSHDEF([func_var], [ac_cv_func_$name])
5003 AS_VAR_SET([func_var], [no])
5004 AS_VAR_POPDEF([func_var])
5005 done
5006 fi
5007
5008 # checks for library functions
5009 AC_CHECK_FUNCS([ \
5010 accept4 alarm bind_textdomain_codeset chmod chown clock closefrom close_range confstr \
5011 copy_file_range ctermid dup dup3 execv explicit_bzero explicit_memset \
5012 faccessat fchmod fchmodat fchown fchownat fdopendir fdwalk fexecve \
5013 fork fork1 fpathconf fstatat ftime ftruncate futimens futimes futimesat \
5014 gai_strerror getegid geteuid getgid getgrent getgrgid getgrgid_r \
5015 getgrnam_r getgrouplist gethostname getitimer getloadavg getlogin \
5016 getpeername getpgid getpid getppid getpriority _getpty \
5017 getpwent getpwnam_r getpwuid getpwuid_r getresgid getresuid getrusage getsid getspent \
5018 getspnam getuid getwd grantpt if_nameindex initgroups kill killpg lchown linkat \
5019 lockf lstat lutimes madvise mbrtowc memrchr mkdirat mkfifo mkfifoat \
5020 mknod mknodat mktime mmap mremap nice openat opendir pathconf pause pipe \
5021 pipe2 plock poll posix_fadvise posix_fallocate posix_openpt posix_spawn posix_spawnp \
5022 posix_spawn_file_actions_addclosefrom_np \
5023 pread preadv preadv2 process_vm_readv pthread_cond_timedwait_relative_np pthread_condattr_setclock pthread_init \
5024 pthread_kill ptsname ptsname_r pwrite pwritev pwritev2 readlink readlinkat readv realpath renameat \
5025 rtpSpawn sched_get_priority_max sched_rr_get_interval sched_setaffinity \
5026 sched_setparam sched_setscheduler sem_clockwait sem_getvalue sem_open \
5027 sem_timedwait sem_unlink sendfile setegid seteuid setgid sethostname \
5028 setitimer setlocale setpgid setpgrp setpriority setregid setresgid \
5029 setresuid setreuid setsid setuid setvbuf shutdown sigaction sigaltstack \
5030 sigfillset siginterrupt sigpending sigrelse sigtimedwait sigwait \
5031 sigwaitinfo snprintf splice strftime strlcpy strsignal symlinkat sync \
5032 sysconf tcgetpgrp tcsetpgrp tempnam timegm times tmpfile \
5033 tmpnam tmpnam_r truncate ttyname umask uname unlinkat unlockpt utimensat utimes vfork \
5034 wait wait3 wait4 waitid waitpid wcscoll wcsftime wcsxfrm wmemcmp writev \
5035 ])
5036
5037 # Force lchmod off for Linux. Linux disallows changing the mode of symbolic
5038 # links. Some libc implementations have a stub lchmod implementation that always
5039 # returns an error.
5040 if test "$MACHDEP" != linux; then
5041 AC_CHECK_FUNCS([lchmod])
5042 fi
5043
5044 # iOS defines some system methods that can be linked (so they are
5045 # found by configure), but either raise a compilation error (because the
5046 # header definition prevents usage - autoconf doesn't use the headers), or
5047 # raise an error if used at runtime. Force these symbols off.
5048 if test "$ac_sys_system" != "iOS" ; then
5049 AC_CHECK_FUNCS([getentropy getgroups system])
5050 fi
5051
5052 AC_CHECK_DECL([dirfd],
5053 [AC_DEFINE([HAVE_DIRFD], [1],
5054 [Define if you have the 'dirfd' function or macro.])],
5055 [],
5056 [@%:@include <sys/types.h>
5057 @%:@include <dirent.h>])
5058
5059 # For some functions, having a definition is not sufficient, since
5060 # we want to take their address.
5061 PY_CHECK_FUNC([chroot], [@%:@include <unistd.h>])
5062 PY_CHECK_FUNC([link], [@%:@include <unistd.h>])
5063 PY_CHECK_FUNC([symlink], [@%:@include <unistd.h>])
5064 PY_CHECK_FUNC([fchdir], [@%:@include <unistd.h>])
5065 PY_CHECK_FUNC([fsync], [@%:@include <unistd.h>])
5066 PY_CHECK_FUNC([fdatasync], [@%:@include <unistd.h>])
5067 PY_CHECK_FUNC([epoll_create], [@%:@include <sys/epoll.h>], [HAVE_EPOLL])
5068 PY_CHECK_FUNC([epoll_create1], [@%:@include <sys/epoll.h>])
5069 PY_CHECK_FUNC([kqueue],[
5070 #include <sys/types.h>
5071 #include <sys/event.h>
5072 ])
5073 PY_CHECK_FUNC([prlimit], [
5074 #include <sys/time.h>
5075 #include <sys/resource.h>
5076 ])
5077
5078 PY_CHECK_FUNC([_dyld_shared_cache_contains_path], [@%:@include <mach-o/dyld.h>], [HAVE_DYLD_SHARED_CACHE_CONTAINS_PATH])
5079
5080 PY_CHECK_FUNC([memfd_create], [
5081 #ifdef HAVE_SYS_MMAN_H
5082 #include <sys/mman.h>
5083 #endif
5084 #ifdef HAVE_SYS_MEMFD_H
5085 #include <sys/memfd.h>
5086 #endif
5087 ])
5088
5089 PY_CHECK_FUNC([eventfd], [
5090 #ifdef HAVE_SYS_EVENTFD_H
5091 #include <sys/eventfd.h>
5092 #endif
5093 ])
5094
5095 PY_CHECK_FUNC([timerfd_create], [
5096 #ifdef HAVE_SYS_TIMERFD_H
5097 #include <sys/timerfd.h>
5098 #endif
5099 ],
5100 [HAVE_TIMERFD_CREATE])
5101
5102 # On some systems (eg. FreeBSD 5), we would find a definition of the
5103 # functions ctermid_r, setgroups in the library, but no prototype
5104 # (e.g. because we use _XOPEN_SOURCE). See whether we can take their
5105 # address to avoid compiler warnings and potential miscompilations
5106 # because of the missing prototypes.
5107
5108 PY_CHECK_FUNC([ctermid_r], [@%:@include <stdio.h>])
5109
5110 AC_CACHE_CHECK([for flock declaration], [ac_cv_flock_decl],
5111 [AC_COMPILE_IFELSE(
5112 [AC_LANG_PROGRAM(
5113 [@%:@include <sys/file.h>],
5114 [void* p = flock]
5115 )],
5116 [ac_cv_flock_decl=yes],
5117 [ac_cv_flock_decl=no]
5118 )
5119 ])
5120 dnl Linking with libbsd may be necessary on AIX for flock function.
5121 AS_VAR_IF([ac_cv_flock_decl], [yes],
5122 [AC_CHECK_FUNCS([flock], [],
5123 [AC_CHECK_LIB([bsd], [flock], [FCNTL_LIBS="-lbsd"])])])
5124
5125 PY_CHECK_FUNC([getpagesize], [@%:@include <unistd.h>])
5126
5127 AC_CACHE_CHECK([for broken unsetenv], [ac_cv_broken_unsetenv],
5128 [AC_COMPILE_IFELSE(
5129 [AC_LANG_PROGRAM(
5130 [@%:@include <stdlib.h>],
5131 [int res = unsetenv("DUMMY")])],
5132 [ac_cv_broken_unsetenv=no],
5133 [ac_cv_broken_unsetenv=yes]
5134 )
5135 ])
5136 AS_VAR_IF([ac_cv_broken_unsetenv], [yes], [
5137 AC_DEFINE([HAVE_BROKEN_UNSETENV], [1],
5138 [Define if 'unsetenv' does not return an int.])
5139 ])
5140
5141 dnl check for true
5142 AC_CHECK_PROGS([TRUE], [true], [/bin/true])
5143
5144 dnl On some systems (e.g. Solaris 9), hstrerror and inet_aton are in -lresolv
5145 dnl On others, they are in the C library, so we to take no action
5146 AC_CHECK_LIB([c], [inet_aton], [$ac_cv_prog_TRUE],
5147 AC_CHECK_LIB([resolv], [inet_aton])
5148 )
5149
5150 # On Tru64, chflags seems to be present, but calling it will
5151 # exit Python
5152 AC_CACHE_CHECK([for chflags], [ac_cv_have_chflags], [dnl
5153 AC_RUN_IFELSE([AC_LANG_SOURCE([[
5154 #include <sys/stat.h>
5155 #include <unistd.h>
5156 int main(int argc, char *argv[])
5157 {
5158 if(chflags(argv[0], 0) != 0)
5159 return 1;
5160 return 0;
5161 }
5162 ]])],
5163 [ac_cv_have_chflags=yes],
5164 [ac_cv_have_chflags=no],
5165 [ac_cv_have_chflags=cross])
5166 ])
5167 if test "$ac_cv_have_chflags" = cross ; then
5168 AC_CHECK_FUNC([chflags], [ac_cv_have_chflags="yes"], [ac_cv_have_chflags="no"])
5169 fi
5170 if test "$ac_cv_have_chflags" = yes ; then
5171 AC_DEFINE([HAVE_CHFLAGS], [1],
5172 [Define to 1 if you have the 'chflags' function.])
5173 fi
5174
5175 AC_CACHE_CHECK([for lchflags], [ac_cv_have_lchflags], [dnl
5176 AC_RUN_IFELSE([AC_LANG_SOURCE([[
5177 #include <sys/stat.h>
5178 #include <unistd.h>
5179 int main(int argc, char *argv[])
5180 {
5181 if(lchflags(argv[0], 0) != 0)
5182 return 1;
5183 return 0;
5184 }
5185 ]])],[ac_cv_have_lchflags=yes],[ac_cv_have_lchflags=no],[ac_cv_have_lchflags=cross])
5186 ])
5187 if test "$ac_cv_have_lchflags" = cross ; then
5188 AC_CHECK_FUNC([lchflags], [ac_cv_have_lchflags="yes"], [ac_cv_have_lchflags="no"])
5189 fi
5190 if test "$ac_cv_have_lchflags" = yes ; then
5191 AC_DEFINE([HAVE_LCHFLAGS], [1],
5192 [Define to 1 if you have the 'lchflags' function.])
5193 fi
5194
5195 dnl Check for compression libraries
5196 AH_TEMPLATE([HAVE_ZLIB_COPY], [Define if the zlib library has inflateCopy])
5197
5198 dnl detect zlib from Emscripten emport
5199 PY_CHECK_EMSCRIPTEN_PORT([ZLIB], [-sUSE_ZLIB])
5200
5201 PKG_CHECK_MODULES([ZLIB], [zlib >= 1.2.0], [
5202 have_zlib=yes
5203 dnl zlib 1.2.0 (2003) added inflateCopy
5204 AC_DEFINE([HAVE_ZLIB_COPY], [1])
5205 ], [
5206 WITH_SAVE_ENV([
5207 CPPFLAGS="$CPPFLAGS $ZLIB_CFLAGS"
5208 LDFLAGS="$LDFLAGS $ZLIB_LIBS"
5209 AC_CHECK_HEADERS([zlib.h], [
5210 PY_CHECK_LIB([z], [gzread], [have_zlib=yes], [have_zlib=no])
5211 ], [have_zlib=no])
5212 AS_VAR_IF([have_zlib], [yes], [
5213 ZLIB_CFLAGS=${ZLIB_CFLAGS-""}
5214 ZLIB_LIBS=${ZLIB_LIBS-"-lz"}
5215 PY_CHECK_LIB([z], [inflateCopy], [AC_DEFINE([HAVE_ZLIB_COPY], [1])])
5216 ])
5217 ])
5218 ])
5219
5220 dnl binascii can use zlib for optimized crc32.
5221 AS_VAR_IF([have_zlib], [yes], [
5222 BINASCII_CFLAGS="-DUSE_ZLIB_CRC32 $ZLIB_CFLAGS"
5223 BINASCII_LIBS="$ZLIB_LIBS"
5224 ])
5225
5226 dnl detect bzip2 from Emscripten emport
5227 PY_CHECK_EMSCRIPTEN_PORT([BZIP2], [-sUSE_BZIP2])
5228
5229 PKG_CHECK_MODULES([BZIP2], [bzip2], [have_bzip2=yes], [
5230 WITH_SAVE_ENV([
5231 CPPFLAGS="$CPPFLAGS $BZIP2_CFLAGS"
5232 LDFLAGS="$LDFLAGS $BZIP2_LIBS"
5233 AC_CHECK_HEADERS([bzlib.h], [
5234 AC_CHECK_LIB([bz2], [BZ2_bzCompress], [have_bzip2=yes], [have_bzip2=no])
5235 ], [have_bzip2=no])
5236 AS_VAR_IF([have_bzip2], [yes], [
5237 BZIP2_CFLAGS=${BZIP2_CFLAGS-""}
5238 BZIP2_LIBS=${BZIP2_LIBS-"-lbz2"}
5239 ])
5240 ])
5241 ])
5242
5243 PKG_CHECK_MODULES([LIBLZMA], [liblzma], [have_liblzma=yes], [
5244 WITH_SAVE_ENV([
5245 CPPFLAGS="$CPPFLAGS $LIBLZMA_CFLAGS"
5246 LDFLAGS="$LDFLAGS $LIBLZMA_LIBS"
5247 AC_CHECK_HEADERS([lzma.h], [
5248 AC_CHECK_LIB([lzma], [lzma_easy_encoder], [have_liblzma=yes], [have_liblzma=no])
5249 ], [have_liblzma=no])
5250 AS_VAR_IF([have_liblzma], [yes], [
5251 LIBLZMA_CFLAGS=${LIBLZMA_CFLAGS-""}
5252 LIBLZMA_LIBS=${LIBLZMA_LIBS-"-llzma"}
5253 ])
5254 ])
5255 ])
5256
5257 dnl PY_CHECK_NETDB_FUNC(FUNCTION)
5258 AC_DEFUN([PY_CHECK_NETDB_FUNC], [PY_CHECK_FUNC([$1], [@%:@include <netdb.h>])])
5259
5260 PY_CHECK_NETDB_FUNC([hstrerror])
5261 dnl not available in WASI yet
5262 PY_CHECK_NETDB_FUNC([getservbyname])
5263 PY_CHECK_NETDB_FUNC([getservbyport])
5264 PY_CHECK_NETDB_FUNC([gethostbyname])
5265 PY_CHECK_NETDB_FUNC([gethostbyaddr])
5266 PY_CHECK_NETDB_FUNC([getprotobyname])
5267
5268 dnl PY_CHECK_SOCKET_FUNC(FUNCTION)
5269 AC_DEFUN([PY_CHECK_SOCKET_FUNC], [PY_CHECK_FUNC([$1], [
5270 #include <sys/types.h>
5271 #include <sys/socket.h>
5272 #include <netinet/in.h>
5273 #include <arpa/inet.h>
5274 ])])
5275
5276 PY_CHECK_SOCKET_FUNC([inet_aton])
5277 PY_CHECK_SOCKET_FUNC([inet_ntoa])
5278 PY_CHECK_SOCKET_FUNC([inet_pton])
5279 dnl not available in WASI yet
5280 PY_CHECK_SOCKET_FUNC([getpeername])
5281 PY_CHECK_SOCKET_FUNC([getsockname])
5282 PY_CHECK_SOCKET_FUNC([accept])
5283 PY_CHECK_SOCKET_FUNC([bind])
5284 PY_CHECK_SOCKET_FUNC([connect])
5285 PY_CHECK_SOCKET_FUNC([listen])
5286 PY_CHECK_SOCKET_FUNC([recvfrom])
5287 PY_CHECK_SOCKET_FUNC([sendto])
5288 PY_CHECK_SOCKET_FUNC([setsockopt])
5289 PY_CHECK_SOCKET_FUNC([socket])
5290
5291 # On some systems, setgroups is in unistd.h, on others, in grp.h
5292 PY_CHECK_FUNC([setgroups], [
5293 #include <unistd.h>
5294 #ifdef HAVE_GRP_H
5295 #include <grp.h>
5296 #endif
5297 ])
5298
5299 # check for openpty, login_tty, and forkpty
5300
5301 AC_CHECK_FUNCS([openpty], [],
5302 [AC_CHECK_LIB([util], [openpty],
5303 [AC_DEFINE([HAVE_OPENPTY]) LIBS="$LIBS -lutil"],
5304 [AC_CHECK_LIB([bsd], [openpty],
5305 [AC_DEFINE([HAVE_OPENPTY]) LIBS="$LIBS -lbsd"])])])
5306 AC_SEARCH_LIBS([login_tty], [util],
5307 [AC_DEFINE([HAVE_LOGIN_TTY], [1], [Define to 1 if you have the `login_tty' function.])]
5308 )
5309 AC_CHECK_FUNCS([forkpty], [],
5310 [AC_CHECK_LIB([util], [forkpty],
5311 [AC_DEFINE([HAVE_FORKPTY]) LIBS="$LIBS -lutil"],
5312 [AC_CHECK_LIB([bsd], [forkpty],
5313 [AC_DEFINE([HAVE_FORKPTY]) LIBS="$LIBS -lbsd"])])])
5314
5315 # check for long file support functions
5316 AC_CHECK_FUNCS([fseek64 fseeko fstatvfs ftell64 ftello statvfs])
5317
5318 AC_REPLACE_FUNCS([dup2])
5319 AC_CHECK_FUNCS([getpgrp],
5320 [AC_COMPILE_IFELSE(
5321 [AC_LANG_PROGRAM([@%:@include <unistd.h>],
5322 [getpgrp(0);])],
5323 [AC_DEFINE([GETPGRP_HAVE_ARG], [1],
5324 [Define if getpgrp() must be called as getpgrp(0).])],
5325 [])])
5326 AC_CHECK_FUNCS([setpgrp],
5327 [AC_COMPILE_IFELSE(
5328 [AC_LANG_PROGRAM([@%:@include <unistd.h>],
5329 [setpgrp(0,0);])],
5330 [AC_DEFINE([SETPGRP_HAVE_ARG], [1],
5331 [Define if setpgrp() must be called as setpgrp(0, 0).])],
5332 [])])
5333
5334 # check for namespace functions
5335 AC_CHECK_FUNCS([setns unshare])
5336
5337 AC_CHECK_FUNCS([clock_gettime], [], [
5338 AC_CHECK_LIB([rt], [clock_gettime], [
5339 LIBS="$LIBS -lrt"
5340 AC_DEFINE([HAVE_CLOCK_GETTIME], [1])
5341 AC_DEFINE([TIMEMODULE_LIB], [rt],
5342 [Library needed by timemodule.c: librt may be needed for clock_gettime()])
5343 ])
5344 ])
5345
5346 AC_CHECK_FUNCS([clock_getres], [], [
5347 AC_CHECK_LIB([rt], [clock_getres], [
5348 AC_DEFINE([HAVE_CLOCK_GETRES], [1])
5349 ])
5350 ])
5351
5352 # On Android and iOS, clock_settime can be linked (so it is found by
5353 # configure), but when used in an unprivileged process, it crashes rather than
5354 # returning an error. Force the symbol off.
5355 if test "$ac_sys_system" != "Linux-android" && test "$ac_sys_system" != "iOS"
5356 then
5357 AC_CHECK_FUNCS([clock_settime], [], [
5358 AC_CHECK_LIB([rt], [clock_settime], [
5359 AC_DEFINE([HAVE_CLOCK_SETTIME], [1])
5360 ])
5361 ])
5362 fi
5363
5364 # On Android before API level 23, clock_nanosleep returns the wrong value when
5365 # interrupted by a signal (https://issuetracker.google.com/issues/216495770).
5366 if ! { test "$ac_sys_system" = "Linux-android" &&
5367 test "$ANDROID_API_LEVEL" -lt 23; }; then
5368 AC_CHECK_FUNCS([clock_nanosleep], [], [
5369 AC_CHECK_LIB([rt], [clock_nanosleep], [
5370 AC_DEFINE([HAVE_CLOCK_NANOSLEEP], [1])
5371 ])
5372 ])
5373 fi
5374
5375 AC_CHECK_FUNCS([nanosleep], [], [
5376 AC_CHECK_LIB([rt], [nanosleep], [
5377 AC_DEFINE([HAVE_NANOSLEEP], [1])
5378 ])
5379 ])
5380
5381 AC_CACHE_CHECK([for major, minor, and makedev], [ac_cv_device_macros], [
5382 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
5383 #if defined(MAJOR_IN_MKDEV)
5384 #include <sys/mkdev.h>
5385 #elif defined(MAJOR_IN_SYSMACROS)
5386 #include <sys/types.h>
5387 #include <sys/sysmacros.h>
5388 #else
5389 #include <sys/types.h>
5390 #endif
5391 ]], [[
5392 makedev(major(0),minor(0));
5393 ]])],[ac_cv_device_macros=yes], [ac_cv_device_macros=no])
5394 ])
5395 AS_VAR_IF([ac_cv_device_macros], [yes], [
5396 AC_DEFINE([HAVE_DEVICE_MACROS], [1],
5397 [Define to 1 if you have the device macros.])
5398 ])
5399
5400 dnl no longer used, now always defined for backwards compatibility
5401 AC_DEFINE([SYS_SELECT_WITH_SYS_TIME], [1],
5402 [Define if you can safely include both <sys/select.h> and <sys/time.h>
5403 (which you can't on SCO ODT 3.0).])
5404
5405 # On OSF/1 V5.1, getaddrinfo is available, but a define
5406 # for [no]getaddrinfo in netdb.h.
5407 AC_CACHE_CHECK([for getaddrinfo], [ac_cv_func_getaddrinfo], [
5408 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
5409 #include <sys/types.h>
5410 #include <sys/socket.h>
5411 #include <netdb.h>
5412 #include <stdio.h>
5413 ]], [[getaddrinfo(NULL, NULL, NULL, NULL);]])],
5414 [ac_cv_func_getaddrinfo=yes],
5415 [ac_cv_func_getaddrinfo=no])
5416 ])
5417
5418 AS_VAR_IF([ac_cv_func_getaddrinfo], [yes], [
5419 AC_CACHE_CHECK([getaddrinfo bug], [ac_cv_buggy_getaddrinfo],
5420 AC_RUN_IFELSE([AC_LANG_SOURCE([[[
5421 #include <stdio.h>
5422 #include <sys/types.h>
5423 #include <netdb.h>
5424 #include <string.h>
5425 #include <sys/socket.h>
5426 #include <netinet/in.h>
5427
5428 int main(void)
5429 {
5430 int passive, gaierr, inet4 = 0, inet6 = 0;
5431 struct addrinfo hints, *ai, *aitop;
5432 char straddr[INET6_ADDRSTRLEN], strport[16];
5433
5434 for (passive = 0; passive <= 1; passive++) {
5435 memset(&hints, 0, sizeof(hints));
5436 hints.ai_family = AF_UNSPEC;
5437 hints.ai_flags = passive ? AI_PASSIVE : 0;
5438 hints.ai_socktype = SOCK_STREAM;
5439 hints.ai_protocol = IPPROTO_TCP;
5440 if ((gaierr = getaddrinfo(NULL, "54321", &hints, &aitop)) != 0) {
5441 (void)gai_strerror(gaierr);
5442 goto bad;
5443 }
5444 for (ai = aitop; ai; ai = ai->ai_next) {
5445 if (ai->ai_addr == NULL ||
5446 ai->ai_addrlen == 0 ||
5447 getnameinfo(ai->ai_addr, ai->ai_addrlen,
5448 straddr, sizeof(straddr), strport, sizeof(strport),
5449 NI_NUMERICHOST|NI_NUMERICSERV) != 0) {
5450 goto bad;
5451 }
5452 switch (ai->ai_family) {
5453 case AF_INET:
5454 if (strcmp(strport, "54321") != 0) {
5455 goto bad;
5456 }
5457 if (passive) {
5458 if (strcmp(straddr, "0.0.0.0") != 0) {
5459 goto bad;
5460 }
5461 } else {
5462 if (strcmp(straddr, "127.0.0.1") != 0) {
5463 goto bad;
5464 }
5465 }
5466 inet4++;
5467 break;
5468 case AF_INET6:
5469 if (strcmp(strport, "54321") != 0) {
5470 goto bad;
5471 }
5472 if (passive) {
5473 if (strcmp(straddr, "::") != 0) {
5474 goto bad;
5475 }
5476 } else {
5477 if (strcmp(straddr, "::1") != 0) {
5478 goto bad;
5479 }
5480 }
5481 inet6++;
5482 break;
5483 case AF_UNSPEC:
5484 goto bad;
5485 break;
5486 default:
5487 /* another family support? */
5488 break;
5489 }
5490 }
5491 freeaddrinfo(aitop);
5492 aitop = NULL;
5493 }
5494
5495 if (!(inet4 == 0 || inet4 == 2))
5496 goto bad;
5497 if (!(inet6 == 0 || inet6 == 2))
5498 goto bad;
5499
5500 if (aitop)
5501 freeaddrinfo(aitop);
5502 return 0;
5503
5504 bad:
5505 if (aitop)
5506 freeaddrinfo(aitop);
5507 return 1;
5508 }
5509 ]]])],
5510 [ac_cv_buggy_getaddrinfo=no],
5511 [ac_cv_buggy_getaddrinfo=yes],
5512 [
5513 if test "$ac_sys_system" = "Linux-android" || test "$ac_sys_system" = "iOS"; then
5514 ac_cv_buggy_getaddrinfo="no"
5515 elif test "${enable_ipv6+set}" = set; then
5516 ac_cv_buggy_getaddrinfo="no -- configured with --(en|dis)able-ipv6"
5517 else
5518 ac_cv_buggy_getaddrinfo=yes
5519 fi]))
5520
5521 dnl if ac_cv_func_getaddrinfo
5522 ])
5523
5524 if test "$ac_cv_func_getaddrinfo" = no -o "$ac_cv_buggy_getaddrinfo" = yes
5525 then
5526 AS_VAR_IF([ipv6], [yes], [
5527 AC_MSG_ERROR([m4_normalize([
5528 You must get working getaddrinfo() function
5529 or pass the "--disable-ipv6" option to configure.
5530 ])])
5531 ])
5532 else
5533 AC_DEFINE([HAVE_GETADDRINFO], [1],
5534 [Define if you have the getaddrinfo function.])
5535 fi
5536
5537 AC_CHECK_FUNCS([getnameinfo])
5538
5539 # checks for structures
5540 AC_STRUCT_TM
5541 AC_STRUCT_TIMEZONE
5542 AC_CHECK_MEMBERS([struct stat.st_rdev])
5543 AC_CHECK_MEMBERS([struct stat.st_blksize])
5544 AC_CHECK_MEMBERS([struct stat.st_flags])
5545 AC_CHECK_MEMBERS([struct stat.st_gen])
5546 AC_CHECK_MEMBERS([struct stat.st_birthtime])
5547 AC_CHECK_MEMBERS([struct stat.st_blocks])
5548 AC_CHECK_MEMBERS([struct passwd.pw_gecos, struct passwd.pw_passwd], [], [], [[
5549 #include <sys/types.h>
5550 #include <pwd.h>
5551 ]])
5552 # Issue #21085: In Cygwin, siginfo_t does not have si_band field.
5553 AC_CHECK_MEMBERS([siginfo_t.si_band], [], [], [[@%:@include <signal.h>]])
5554
5555 AC_CACHE_CHECK([for time.h that defines altzone], [ac_cv_header_time_altzone], [
5556 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[@%:@include <time.h>]], [[return altzone;]])],
5557 [ac_cv_header_time_altzone=yes],
5558 [ac_cv_header_time_altzone=no])
5559 ])
5560 if test $ac_cv_header_time_altzone = yes; then
5561 AC_DEFINE([HAVE_ALTZONE], [1],
5562 [Define this if your time.h defines altzone.])
5563 fi
5564
5565 AC_CACHE_CHECK([for addrinfo], [ac_cv_struct_addrinfo],
5566 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[@%:@include <netdb.h>]], [[struct addrinfo a]])],
5567 [ac_cv_struct_addrinfo=yes],
5568 [ac_cv_struct_addrinfo=no]))
5569 if test $ac_cv_struct_addrinfo = yes; then
5570 AC_DEFINE([HAVE_ADDRINFO], [1], [struct addrinfo (netdb.h)])
5571 fi
5572
5573 AC_CACHE_CHECK([for sockaddr_storage], [ac_cv_struct_sockaddr_storage],
5574 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
5575 # include <sys/types.h>
5576 @%:@ include <sys/socket.h>]], [[struct sockaddr_storage s]])],
5577 [ac_cv_struct_sockaddr_storage=yes],
5578 [ac_cv_struct_sockaddr_storage=no]))
5579 if test $ac_cv_struct_sockaddr_storage = yes; then
5580 AC_DEFINE([HAVE_SOCKADDR_STORAGE], [1],
5581 [struct sockaddr_storage (sys/socket.h)])
5582 fi
5583
5584 AC_CACHE_CHECK([for sockaddr_alg], [ac_cv_struct_sockaddr_alg],
5585 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
5586 # include <sys/types.h>
5587 # include <sys/socket.h>
5588 @%:@ include <linux/if_alg.h>]], [[struct sockaddr_alg s]])],
5589 [ac_cv_struct_sockaddr_alg=yes],
5590 [ac_cv_struct_sockaddr_alg=no]))
5591 if test $ac_cv_struct_sockaddr_alg = yes; then
5592 AC_DEFINE([HAVE_SOCKADDR_ALG], [1],
5593 [struct sockaddr_alg (linux/if_alg.h)])
5594 fi
5595
5596 # checks for compiler characteristics
5597
5598 AC_C_CONST
5599
5600 AC_CACHE_CHECK([for working signed char], [ac_cv_working_signed_char_c], [
5601 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[signed char c;]])],
5602 [ac_cv_working_signed_char_c=yes], [ac_cv_working_signed_char_c=no])
5603 ])
5604 AS_VAR_IF([ac_cv_working_signed_char_c], [no], [
5605 AC_DEFINE([signed], [], [Define to empty if the keyword does not work.])
5606 ])
5607
5608 AC_CACHE_CHECK([for prototypes], [ac_cv_function_prototypes], [
5609 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[int foo(int x) { return 0; }]], [[return foo(10);]])],
5610 [ac_cv_function_prototypes=yes], [ac_cv_function_prototypes=no])
5611 ])
5612 AS_VAR_IF([ac_cv_function_prototypes], [yes], [
5613 AC_DEFINE([HAVE_PROTOTYPES], [1],
5614 [Define if your compiler supports function prototype])
5615 ])
5616
5617
5618 # check for socketpair
5619 PY_CHECK_FUNC([socketpair], [
5620 #include <sys/types.h>
5621 #include <sys/socket.h>
5622 ])
5623
5624 # check if sockaddr has sa_len member
5625 AC_CACHE_CHECK([if sockaddr has sa_len member], [ac_cv_struct_sockaddr_sa_len], [
5626 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
5627 @%:@include <sys/socket.h>]], [[struct sockaddr x;
5628 x.sa_len = 0;]])],
5629 [ac_cv_struct_sockaddr_sa_len=yes], [ac_cv_struct_sockaddr_sa_len=no])
5630 ])
5631 AS_VAR_IF([ac_cv_struct_sockaddr_sa_len], [yes], [
5632 AC_DEFINE([HAVE_SOCKADDR_SA_LEN], [1],
5633 [Define if sockaddr has sa_len member])
5634 ])
5635
5636 # sigh -- gethostbyname_r is a mess; it can have 3, 5 or 6 arguments :-(
5637 AH_TEMPLATE([HAVE_GETHOSTBYNAME_R],
5638 [Define this if you have some version of gethostbyname_r()])
5639
5640 AC_CHECK_FUNC([gethostbyname_r],
5641 [AC_DEFINE([HAVE_GETHOSTBYNAME_R])
5642 AC_MSG_CHECKING([gethostbyname_r with 6 args])
5643 OLD_CFLAGS=$CFLAGS
5644 CFLAGS="$CFLAGS $MY_CPPFLAGS $MY_THREAD_CPPFLAGS $MY_CFLAGS"
5645 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
5646 # include <netdb.h>
5647 ]], [[
5648 char *name;
5649 struct hostent *he, *res;
5650 char buffer[2048];
5651 int buflen = 2048;
5652 int h_errnop;
5653
5654 (void) gethostbyname_r(name, he, buffer, buflen, &res, &h_errnop)
5655 ]])],[
5656 AC_DEFINE([HAVE_GETHOSTBYNAME_R])
5657 AC_DEFINE([HAVE_GETHOSTBYNAME_R_6_ARG], [1],
5658 [Define this if you have the 6-arg version of gethostbyname_r().])
5659 AC_MSG_RESULT([yes])
5660 ],[
5661 AC_MSG_RESULT([no])
5662 AC_MSG_CHECKING([gethostbyname_r with 5 args])
5663 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
5664 # include <netdb.h>
5665 ]], [[
5666 char *name;
5667 struct hostent *he;
5668 char buffer[2048];
5669 int buflen = 2048;
5670 int h_errnop;
5671
5672 (void) gethostbyname_r(name, he, buffer, buflen, &h_errnop)
5673 ]])],
5674 [
5675 AC_DEFINE([HAVE_GETHOSTBYNAME_R])
5676 AC_DEFINE([HAVE_GETHOSTBYNAME_R_5_ARG], [1],
5677 [Define this if you have the 5-arg version of gethostbyname_r().])
5678 AC_MSG_RESULT([yes])
5679 ], [
5680 AC_MSG_RESULT([no])
5681 AC_MSG_CHECKING([gethostbyname_r with 3 args])
5682 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
5683 # include <netdb.h>
5684 ]], [[
5685 char *name;
5686 struct hostent *he;
5687 struct hostent_data data;
5688
5689 (void) gethostbyname_r(name, he, &data);
5690 ]])],
5691 [
5692 AC_DEFINE([HAVE_GETHOSTBYNAME_R])
5693 AC_DEFINE([HAVE_GETHOSTBYNAME_R_3_ARG], [1],
5694 [Define this if you have the 3-arg version of gethostbyname_r().])
5695 AC_MSG_RESULT([yes])
5696 ], [
5697 AC_MSG_RESULT([no])
5698 ])
5699 ])
5700 ])
5701 CFLAGS=$OLD_CFLAGS
5702 ], [
5703 AC_CHECK_FUNCS([gethostbyname])
5704 ])
5705 AC_SUBST([HAVE_GETHOSTBYNAME_R_6_ARG])
5706 AC_SUBST([HAVE_GETHOSTBYNAME_R_5_ARG])
5707 AC_SUBST([HAVE_GETHOSTBYNAME_R_3_ARG])
5708 AC_SUBST([HAVE_GETHOSTBYNAME_R])
5709 AC_SUBST([HAVE_GETHOSTBYNAME])
5710
5711 # checks for system services
5712 # (none yet)
5713
5714 # Linux requires this for correct f.p. operations
5715 AC_CHECK_FUNC([__fpu_control],
5716 [],
5717 [AC_CHECK_LIB([ieee], [__fpu_control])
5718 ])
5719
5720 # check for --with-libm=...
5721 AC_SUBST([LIBM])
5722 case $ac_sys_system in
5723 Darwin) ;;
5724 *) LIBM=-lm
5725 esac
5726 AC_MSG_CHECKING([for --with-libm=STRING])
5727 AC_ARG_WITH([libm],
5728 [AS_HELP_STRING([--with-libm=STRING], [override libm math library to STRING (default is system-dependent)])],
5729 [
5730 if test "$withval" = no
5731 then LIBM=
5732 AC_MSG_RESULT([force LIBM empty])
5733 elif test "$withval" != yes
5734 then LIBM=$withval
5735 AC_MSG_RESULT([set LIBM="$withval"])
5736 else AC_MSG_ERROR([proper usage is --with-libm=STRING])
5737 fi],
5738 [AC_MSG_RESULT([default LIBM="$LIBM"])])
5739
5740 # check for --with-libc=...
5741 AC_SUBST([LIBC])
5742 AC_MSG_CHECKING([for --with-libc=STRING])
5743 AC_ARG_WITH([libc],
5744 [AS_HELP_STRING([--with-libc=STRING], [override libc C library to STRING (default is system-dependent)])],
5745 [
5746 if test "$withval" = no
5747 then LIBC=
5748 AC_MSG_RESULT([force LIBC empty])
5749 elif test "$withval" != yes
5750 then LIBC=$withval
5751 AC_MSG_RESULT([set LIBC="$withval"])
5752 else AC_MSG_ERROR([proper usage is --with-libc=STRING])
5753 fi],
5754 [AC_MSG_RESULT([default LIBC="$LIBC"])])
5755
5756 # **************************************
5757 # * Check for gcc x64 inline assembler *
5758 # **************************************
5759
5760
5761 AC_CACHE_CHECK([for x64 gcc inline assembler], [ac_cv_gcc_asm_for_x64], [
5762 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
5763 __asm__ __volatile__ ("movq %rcx, %rax");
5764 ]])],[ac_cv_gcc_asm_for_x64=yes],[ac_cv_gcc_asm_for_x64=no])
5765 ])
5766
5767 AS_VAR_IF([ac_cv_gcc_asm_for_x64], [yes], [
5768 AC_DEFINE([HAVE_GCC_ASM_FOR_X64], [1],
5769 [Define if we can use x64 gcc inline assembler])
5770 ])
5771
5772 # **************************************************
5773 # * Check for various properties of floating point *
5774 # **************************************************
5775
5776 AX_C_FLOAT_WORDS_BIGENDIAN
5777 if test "$ax_cv_c_float_words_bigendian" = "yes"
5778 then
5779 AC_DEFINE([DOUBLE_IS_BIG_ENDIAN_IEEE754], [1],
5780 [Define if C doubles are 64-bit IEEE 754 binary format, stored
5781 with the most significant byte first])
5782 elif test "$ax_cv_c_float_words_bigendian" = "no"
5783 then
5784 AC_DEFINE([DOUBLE_IS_LITTLE_ENDIAN_IEEE754], [1],
5785 [Define if C doubles are 64-bit IEEE 754 binary format, stored
5786 with the least significant byte first])
5787 else
5788 # Some ARM platforms use a mixed-endian representation for doubles.
5789 # While Python doesn't currently have full support for these platforms
5790 # (see e.g., issue 1762561), we can at least make sure that float <-> string
5791 # conversions work.
5792 # FLOAT_WORDS_BIGENDIAN doesnt actually detect this case, but if it's not big
5793 # or little, then it must be this?
5794 AC_DEFINE([DOUBLE_IS_ARM_MIXED_ENDIAN_IEEE754], [1],
5795 [Define if C doubles are 64-bit IEEE 754 binary format, stored
5796 in ARM mixed-endian order (byte order 45670123)])
5797 fi
5798
5799 # The short float repr introduced in Python 3.1 requires the
5800 # correctly-rounded string <-> double conversion functions from
5801 # Python/dtoa.c, which in turn require that the FPU uses 53-bit
5802 # rounding; this is a problem on x86, where the x87 FPU has a default
5803 # rounding precision of 64 bits. For gcc/x86, we can fix this by
5804 # using inline assembler to get and set the x87 FPU control word.
5805
5806 # This inline assembler syntax may also work for suncc and icc,
5807 # so we try it on all platforms.
5808
5809 AC_CACHE_CHECK([whether we can use gcc inline assembler to get and set x87 control word], [ac_cv_gcc_asm_for_x87], [
5810 AC_LINK_IFELSE( [AC_LANG_PROGRAM([[]], [[
5811 unsigned short cw;
5812 __asm__ __volatile__ ("fnstcw %0" : "=m" (cw));
5813 __asm__ __volatile__ ("fldcw %0" : : "m" (cw));
5814 ]])],[ac_cv_gcc_asm_for_x87=yes],[ac_cv_gcc_asm_for_x87=no])
5815 ])
5816 AS_VAR_IF([ac_cv_gcc_asm_for_x87], [yes], [
5817 AC_DEFINE([HAVE_GCC_ASM_FOR_X87], [1],
5818 [Define if we can use gcc inline assembler to get and set x87 control word])
5819 ])
5820
5821 AC_CACHE_CHECK([whether we can use gcc inline assembler to get and set mc68881 fpcr], [ac_cv_gcc_asm_for_mc68881], [
5822 AC_LINK_IFELSE( [AC_LANG_PROGRAM([[]], [[
5823 unsigned int fpcr;
5824 __asm__ __volatile__ ("fmove.l %%fpcr,%0" : "=g" (fpcr));
5825 __asm__ __volatile__ ("fmove.l %0,%%fpcr" : : "g" (fpcr));
5826 ]])],[ac_cv_gcc_asm_for_mc68881=yes],[ac_cv_gcc_asm_for_mc68881=no])
5827 ])
5828 AS_VAR_IF([ac_cv_gcc_asm_for_mc68881], [yes], [
5829 AC_DEFINE([HAVE_GCC_ASM_FOR_MC68881], [1],
5830 [Define if we can use gcc inline assembler to get and set mc68881 fpcr])
5831 ])
5832
5833 # Detect whether system arithmetic is subject to x87-style double
5834 # rounding issues. The result of this test has little meaning on non
5835 # IEEE 754 platforms. On IEEE 754, test should return 1 if rounding
5836 # mode is round-to-nearest and double rounding issues are present, and
5837 # 0 otherwise. See https://github.com/python/cpython/issues/47186 for more info.
5838 AC_CACHE_CHECK([for x87-style double rounding], [ac_cv_x87_double_rounding], [
5839 # $BASECFLAGS may affect the result
5840 ac_save_cc="$CC"
5841 CC="$CC $BASECFLAGS"
5842 AC_RUN_IFELSE([AC_LANG_SOURCE([[
5843 #include <stdlib.h>
5844 #include <math.h>
5845 int main(void) {
5846 volatile double x, y, z;
5847 /* 1./(1-2**-53) -> 1+2**-52 (correct), 1.0 (double rounding) */
5848 x = 0.99999999999999989; /* 1-2**-53 */
5849 y = 1./x;
5850 if (y != 1.)
5851 exit(0);
5852 /* 1e16+2.99999 -> 1e16+2. (correct), 1e16+4. (double rounding) */
5853 x = 1e16;
5854 y = 2.99999;
5855 z = x + y;
5856 if (z != 1e16+4.)
5857 exit(0);
5858 /* both tests show evidence of double rounding */
5859 exit(1);
5860 }
5861 ]])],
5862 [ac_cv_x87_double_rounding=no],
5863 [ac_cv_x87_double_rounding=yes],
5864 [ac_cv_x87_double_rounding=no])
5865 CC="$ac_save_cc"
5866 ])
5867
5868 AS_VAR_IF([ac_cv_x87_double_rounding], [yes], [
5869 AC_DEFINE([X87_DOUBLE_ROUNDING], [1],
5870 [Define if arithmetic is subject to x87-style double rounding issue])
5871 ])
5872
5873 # ************************************
5874 # * Check for mathematical functions *
5875 # ************************************
5876
5877 LIBS_SAVE=$LIBS
5878 LIBS="$LIBS $LIBM"
5879
5880 AC_CHECK_FUNCS(
5881 [acosh asinh atanh erf erfc expm1 log1p log2],
5882 [],
5883 [AC_MSG_ERROR([Python requires C99 compatible libm])]
5884 )
5885 LIBS=$LIBS_SAVE
5886
5887 dnl For multiprocessing module, check that sem_open
5888 dnl actually works. For FreeBSD versions <= 7.2,
5889 dnl the kernel module that provides POSIX semaphores
5890 dnl isn't loaded by default, so an attempt to call
5891 dnl sem_open results in a 'Signal 12' error.
5892 AC_CACHE_CHECK([whether POSIX semaphores are enabled], [ac_cv_posix_semaphores_enabled],
5893 AC_RUN_IFELSE([
5894 AC_LANG_SOURCE([
5895 #include <unistd.h>
5896 #include <fcntl.h>
5897 #include <stdio.h>
5898 #include <semaphore.h>
5899 #include <sys/stat.h>
5900
5901 int main(void) {
5902 sem_t *a = sem_open("/autoconf", O_CREAT, S_IRUSR|S_IWUSR, 0);
5903 if (a == SEM_FAILED) {
5904 perror("sem_open");
5905 return 1;
5906 }
5907 sem_close(a);
5908 sem_unlink("/autoconf");
5909 return 0;
5910 }
5911 ])
5912 ],
5913 [ac_cv_posix_semaphores_enabled=yes],
5914 [ac_cv_posix_semaphores_enabled=no],
5915 [ac_cv_posix_semaphores_enabled=yes])
5916 )
5917 AS_VAR_IF([ac_cv_posix_semaphores_enabled], [no], [
5918 AC_DEFINE(
5919 [POSIX_SEMAPHORES_NOT_ENABLED], [1],
5920 [Define if POSIX semaphores aren't enabled on your system]
5921 )
5922 ])
5923
5924 dnl Multiprocessing check for broken sem_getvalue
5925 AC_CACHE_CHECK([for broken sem_getvalue], [ac_cv_broken_sem_getvalue],
5926 AC_RUN_IFELSE([
5927 AC_LANG_SOURCE([
5928 #include <unistd.h>
5929 #include <fcntl.h>
5930 #include <stdio.h>
5931 #include <semaphore.h>
5932 #include <sys/stat.h>
5933
5934 int main(void){
5935 sem_t *a = sem_open("/autocftw", O_CREAT, S_IRUSR|S_IWUSR, 0);
5936 int count;
5937 int res;
5938 if(a==SEM_FAILED){
5939 perror("sem_open");
5940 return 1;
5941
5942 }
5943 res = sem_getvalue(a, &count);
5944 sem_close(a);
5945 sem_unlink("/autocftw");
5946 return res==-1 ? 1 : 0;
5947 }
5948 ])
5949 ],
5950 [ac_cv_broken_sem_getvalue=no],
5951 [ac_cv_broken_sem_getvalue=yes],
5952 [ac_cv_broken_sem_getvalue=yes])
5953 )
5954 AS_VAR_IF([ac_cv_broken_sem_getvalue], [yes], [
5955 AC_DEFINE(
5956 [HAVE_BROKEN_SEM_GETVALUE], [1],
5957 [define to 1 if your sem_getvalue is broken.]
5958 )
5959 ])
5960
5961 AC_CHECK_DECLS([RTLD_LAZY, RTLD_NOW, RTLD_GLOBAL, RTLD_LOCAL, RTLD_NODELETE, RTLD_NOLOAD, RTLD_DEEPBIND, RTLD_MEMBER], [], [], [[@%:@include <dlfcn.h>]])
5962
5963 # determine what size digit to use for Python's longs
5964 AC_MSG_CHECKING([digit size for Python's longs])
5965 AC_ARG_ENABLE([big-digits],
5966 AS_HELP_STRING([--enable-big-digits@<:@=15|30@:>@],[use big digits (30 or 15 bits) for Python longs (default is 30)]]),
5967 [case $enable_big_digits in
5968 yes)
5969 enable_big_digits=30 ;;
5970 no)
5971 enable_big_digits=15 ;;
5972 [15|30])
5973 ;;
5974 *)
5975 AC_MSG_ERROR([bad value $enable_big_digits for --enable-big-digits; value should be 15 or 30]) ;;
5976 esac
5977 AC_MSG_RESULT([$enable_big_digits])
5978 AC_DEFINE_UNQUOTED([PYLONG_BITS_IN_DIGIT], [$enable_big_digits],
5979 [Define as the preferred size in bits of long digits])
5980 ],
5981 [AC_MSG_RESULT([no value specified])])
5982
5983 # check for wchar.h
5984 AC_CHECK_HEADER([wchar.h], [
5985 AC_DEFINE([HAVE_WCHAR_H], [1],
5986 [Define if the compiler provides a wchar.h header file.])
5987 wchar_h="yes"
5988 ],
5989 wchar_h="no"
5990 )
5991
5992 # determine wchar_t size
5993 if test "$wchar_h" = yes
5994 then
5995 AC_CHECK_SIZEOF([wchar_t], [4], [m4_normalize([
5996 #include <wchar.h>
5997 ])])
5998 fi
5999
6000 # check whether wchar_t is signed or not
6001 if test "$wchar_h" = yes
6002 then
6003 # check whether wchar_t is signed or not
6004 AC_CACHE_CHECK([whether wchar_t is signed], [ac_cv_wchar_t_signed], [
6005 AC_RUN_IFELSE([AC_LANG_SOURCE([[
6006 #include <wchar.h>
6007 int main()
6008 {
6009 /* Success: exit code 0 */
6010 return ((((wchar_t) -1) < ((wchar_t) 0)) ? 0 : 1);
6011 }
6012 ]])],
6013 [ac_cv_wchar_t_signed=yes],
6014 [ac_cv_wchar_t_signed=no],
6015 [ac_cv_wchar_t_signed=yes])])
6016 fi
6017
6018 AC_MSG_CHECKING([whether wchar_t is usable])
6019 # wchar_t is only usable if it maps to an unsigned type
6020 if test "$ac_cv_sizeof_wchar_t" -ge 2 \
6021 -a "$ac_cv_wchar_t_signed" = "no"
6022 then
6023 AC_DEFINE([HAVE_USABLE_WCHAR_T], [1],
6024 [Define if you have a useable wchar_t type defined in wchar.h; useable
6025 means wchar_t must be an unsigned type with at least 16 bits. (see
6026 Include/unicodeobject.h).])
6027 AC_MSG_RESULT([yes])
6028 else
6029 AC_MSG_RESULT([no])
6030 fi
6031
6032 case $ac_sys_system/$ac_sys_release in
6033 SunOS/*)
6034 if test -f /etc/os-release; then
6035 OS_NAME=$(awk -F= '/^NAME=/ {print substr($2,2,length($2)-2)}' /etc/os-release)
6036 if test "x$OS_NAME" = "xOracle Solaris"; then
6037 # bpo-43667: In Oracle Solaris, the internal form of wchar_t in
6038 # non-Unicode locales is not Unicode and hence cannot be used directly.
6039 # https://docs.oracle.com/cd/E37838_01/html/E61053/gmwke.html
6040 AC_DEFINE([HAVE_NON_UNICODE_WCHAR_T_REPRESENTATION], [1],
6041 [Define if the internal form of wchar_t in non-Unicode locales
6042 is not Unicode.])
6043 fi
6044 fi
6045 ;;
6046 esac
6047
6048 # check for endianness
6049 AC_C_BIGENDIAN
6050
6051 # ABI version string for Python extension modules. This appears between the
6052 # periods in shared library file names, e.g. foo.<SOABI>.so. It is calculated
6053 # from the following attributes which affect the ABI of this Python build (in
6054 # this order):
6055 #
6056 # * The Python implementation (always 'cpython-' for us)
6057 # * The major and minor version numbers
6058 # * --disable-gil (adds a 't')
6059 # * --with-pydebug (adds a 'd')
6060 #
6061 # Thus for example, Python 3.2 built with wide unicode, pydebug, and pymalloc,
6062 # would get a shared library ABI version tag of 'cpython-32dmu' and shared
6063 # libraries would be named 'foo.cpython-32dmu.so'.
6064 #
6065 # In Python 3.2 and older, --with-wide-unicode added a 'u' flag.
6066 # In Python 3.7 and older, --with-pymalloc added a 'm' flag.
6067 AC_SUBST([SOABI])
6068 AC_MSG_CHECKING([ABIFLAGS])
6069 AC_MSG_RESULT([$ABIFLAGS])
6070 AC_MSG_CHECKING([SOABI])
6071 SOABI='cpython-'`echo $VERSION | tr -d .`${ABIFLAGS}${SOABI_PLATFORM:+-$SOABI_PLATFORM}
6072 AC_MSG_RESULT([$SOABI])
6073
6074 # Release build, debug build (Py_DEBUG), and trace refs build (Py_TRACE_REFS)
6075 # are ABI compatible
6076 if test "$Py_DEBUG" = 'true'; then
6077 # Similar to SOABI but remove "d" flag from ABIFLAGS
6078 AC_SUBST([ALT_SOABI])
6079 ALT_SOABI='cpython-'`echo $VERSION | tr -d .``echo $ABIFLAGS | tr -d d`${SOABI_PLATFORM:+-$SOABI_PLATFORM}
6080 AC_DEFINE_UNQUOTED([ALT_SOABI], ["${ALT_SOABI}"],
6081 [Alternative SOABI used in debug build to load C extensions built in release mode])
6082 fi
6083
6084 AC_SUBST([EXT_SUFFIX])
6085 EXT_SUFFIX=.${SOABI}${SHLIB_SUFFIX}
6086
6087 AC_MSG_CHECKING([LDVERSION])
6088 LDVERSION='$(VERSION)$(ABIFLAGS)'
6089 AC_MSG_RESULT([$LDVERSION])
6090
6091 # Configure the flags and dependencies used when compiling shared modules
6092 AC_SUBST([MODULE_DEPS_SHARED])
6093 AC_SUBST([MODULE_LDFLAGS])
6094 MODULE_DEPS_SHARED='$(MODULE_DEPS_STATIC) $(EXPORTSYMS)'
6095 MODULE_LDFLAGS=''
6096
6097 # On Android and Cygwin the shared libraries must be linked with libpython.
6098 if test "$PY_ENABLE_SHARED" = "1" && ( test -n "$ANDROID_API_LEVEL" || test "$MACHDEP" = "cygwin"); then
6099 MODULE_DEPS_SHARED="$MODULE_DEPS_SHARED \$(LDLIBRARY)"
6100 MODULE_LDFLAGS="\$(BLDLIBRARY)"
6101 fi
6102
6103 # On iOS the shared libraries must be linked with the Python framework
6104 if test "$ac_sys_system" = "iOS"; then
6105 MODULE_DEPS_SHARED="$MODULE_DEPS_SHARED \$(PYTHONFRAMEWORKDIR)/\$(PYTHONFRAMEWORK)"
6106 fi
6107
6108
6109 AC_SUBST([BINLIBDEST])
6110 BINLIBDEST='$(LIBDIR)/python$(VERSION)'
6111
6112
6113 # Check for --with-platlibdir
6114 # /usr/$LIDIRNAME/python$VERSION
6115 AC_SUBST([PLATLIBDIR])
6116 PLATLIBDIR="lib"
6117 AC_MSG_CHECKING([for --with-platlibdir])
6118 AC_ARG_WITH(
6119 [platlibdir],
6120 [AS_HELP_STRING(
6121 [--with-platlibdir=DIRNAME],
6122 [Python library directory name (default is "lib")]
6123 )],
6124 [
6125 # ignore 3 options:
6126 # --with-platlibdir
6127 # --with-platlibdir=
6128 # --without-platlibdir
6129 if test -n "$withval" -a "$withval" != yes -a "$withval" != no
6130 then
6131 AC_MSG_RESULT([yes])
6132 PLATLIBDIR="$withval"
6133 BINLIBDEST='${exec_prefix}/${PLATLIBDIR}/python$(VERSION)'
6134 else
6135 AC_MSG_RESULT([no])
6136 fi],
6137 [AC_MSG_RESULT([no])])
6138
6139
6140 dnl define LIBPL after ABIFLAGS and LDVERSION is defined.
6141 AC_SUBST([PY_ENABLE_SHARED])
6142 if test x$PLATFORM_TRIPLET = x; then
6143 LIBPL='$(prefix)'"/${PLATLIBDIR}/python${VERSION}/config-${LDVERSION}"
6144 else
6145 LIBPL='$(prefix)'"/${PLATLIBDIR}/python${VERSION}/config-${LDVERSION}-${PLATFORM_TRIPLET}"
6146 fi
6147 AC_SUBST([LIBPL])
6148
6149 # Check for --with-wheel-pkg-dir=PATH
6150 AC_SUBST([WHEEL_PKG_DIR])
6151 WHEEL_PKG_DIR=""
6152 AC_MSG_CHECKING([for --with-wheel-pkg-dir])
6153 AC_ARG_WITH(
6154 [wheel-pkg-dir],
6155 [AS_HELP_STRING(
6156 [--with-wheel-pkg-dir=PATH],
6157 [Directory of wheel packages used by ensurepip (default: none)]
6158 )],
6159 [
6160 if test -n "$withval"; then
6161 AC_MSG_RESULT([yes])
6162 WHEEL_PKG_DIR="$withval"
6163 else
6164 AC_MSG_RESULT([no])
6165 fi],
6166 [AC_MSG_RESULT([no])])
6167
6168 # Check whether right shifting a negative integer extends the sign bit
6169 # or fills with zeros (like the Cray J90, according to Tim Peters).
6170 AC_CACHE_CHECK([whether right shift extends the sign bit], [ac_cv_rshift_extends_sign], [
6171 AC_RUN_IFELSE([AC_LANG_SOURCE([[
6172 int main(void)
6173 {
6174 return (((-1)>>3 == -1) ? 0 : 1);
6175 }
6176 ]])],
6177 [ac_cv_rshift_extends_sign=yes],
6178 [ac_cv_rshift_extends_sign=no],
6179 [ac_cv_rshift_extends_sign=yes])])
6180 if test "$ac_cv_rshift_extends_sign" = no
6181 then
6182 AC_DEFINE([SIGNED_RIGHT_SHIFT_ZERO_FILLS], [1],
6183 [Define if i>>j for signed int i does not extend the sign bit
6184 when i < 0])
6185 fi
6186
6187 # check for getc_unlocked and related locking functions
6188 AC_CACHE_CHECK([for getc_unlocked() and friends], [ac_cv_have_getc_unlocked], [
6189 AC_LINK_IFELSE([AC_LANG_PROGRAM([[@%:@include <stdio.h>]], [[
6190 FILE *f = fopen("/dev/null", "r");
6191 flockfile(f);
6192 getc_unlocked(f);
6193 funlockfile(f);
6194 ]])],[ac_cv_have_getc_unlocked=yes],[ac_cv_have_getc_unlocked=no])])
6195 if test "$ac_cv_have_getc_unlocked" = yes
6196 then
6197 AC_DEFINE([HAVE_GETC_UNLOCKED], [1],
6198 [Define this if you have flockfile(), getc_unlocked(), and funlockfile()])
6199 fi
6200
6201 dnl Check for libreadline and libedit
6202 dnl - libreadline provides "readline/readline.h" header and "libreadline"
6203 dnl shared library. pkg-config file is readline.pc
6204 dnl - libedit provides "editline/readline.h" header and "libedit" shared
6205 dnl library. pkg-config file ins libedit.pc
6206 dnl - editline is not supported ("readline.h" and "libeditline" shared library)
6207 dnl
6208 dnl NOTE: In the past we checked if readline needs an additional termcap
6209 dnl library (tinfo ncursesw ncurses termcap). We now assume that libreadline
6210 dnl or readline.pc provide correct linker information.
6211
6212 AH_TEMPLATE([WITH_EDITLINE], [Define to build the readline module against libedit.])
6213
6214 AC_ARG_WITH(
6215 [readline],
6216 [AS_HELP_STRING([--with(out)-readline@<:@=editline|readline|no@:>@],
6217 [use libedit for backend or disable readline module])],
6218 [
6219 AS_CASE([$with_readline],
6220 [editline|edit], [with_readline=edit],
6221 [yes|readline], [with_readline=readline],
6222 [no], [],
6223 [AC_MSG_ERROR([proper usage is --with(out)-readline@<:@=editline|readline|no@:>@])]
6224 )
6225 ],
6226 [with_readline=readline]
6227 )
6228
6229 AS_VAR_IF([with_readline], [readline], [
6230 PKG_CHECK_MODULES([LIBREADLINE], [readline], [
6231 LIBREADLINE=readline
6232 READLINE_CFLAGS=$LIBREADLINE_CFLAGS
6233 READLINE_LIBS=$LIBREADLINE_LIBS
6234 ], [
6235 WITH_SAVE_ENV([
6236 CPPFLAGS="$CPPFLAGS $LIBREADLINE_CFLAGS"
6237 LDFLAGS="$LDFLAGS $LIBREADLINE_LIBS"
6238 AC_CHECK_HEADERS([readline/readline.h], [
6239 AC_CHECK_LIB([readline], [readline], [
6240 LIBREADLINE=readline
6241 READLINE_CFLAGS=${LIBREADLINE_CFLAGS-""}
6242 READLINE_LIBS=${LIBREADLINE_LIBS-"-lreadline"}
6243 ], [with_readline=no])
6244 ], [with_readline=no])
6245 ])
6246 ])
6247 ])
6248
6249 AS_VAR_IF([with_readline], [edit], [
6250 PKG_CHECK_MODULES([LIBEDIT], [libedit], [
6251 AC_DEFINE([WITH_EDITLINE], [1])
6252 LIBREADLINE=edit
6253 READLINE_CFLAGS=$LIBEDIT_CFLAGS
6254 READLINE_LIBS=$LIBEDIT_LIBS
6255 ], [
6256 WITH_SAVE_ENV([
6257 CPPFLAGS="$CPPFLAGS $LIBEDIT_CFLAGS"
6258 LDFLAGS="$LDFLAGS $LIBEDIT_LIBS"
6259 AC_CHECK_HEADERS([editline/readline.h], [
6260 AC_CHECK_LIB([edit], [readline], [
6261 LIBREADLINE=edit
6262 AC_DEFINE([WITH_EDITLINE], [1])
6263 READLINE_CFLAGS=${LIBEDIT_CFLAGS-""}
6264 READLINE_LIBS=${LIBEDIT_LIBS-"-ledit"}
6265 ], [with_readline=no])
6266 ], [with_readline=no])
6267 ])
6268 ])
6269 ])
6270
6271 dnl pyconfig.h defines _XOPEN_SOURCE=700
6272 READLINE_CFLAGS=$(echo $READLINE_CFLAGS | sed 's/-D_XOPEN_SOURCE=600//g')
6273
6274 AC_MSG_CHECKING([how to link readline])
6275 AS_VAR_IF([with_readline], [no], [
6276 AC_MSG_RESULT([no])
6277 ], [
6278 AC_MSG_RESULT([$with_readline (CFLAGS: $READLINE_CFLAGS, LIBS: $READLINE_LIBS)])
6279
6280 WITH_SAVE_ENV([
6281 CPPFLAGS="$CPPFLAGS $READLINE_CFLAGS"
6282 LIBS="$READLINE_LIBS $LIBS"
6283 LIBS_SAVE=$LIBS
6284
6285 m4_define([readline_includes], [
6286 #include <stdio.h> /* Must be first for Gnu Readline */
6287 #ifdef WITH_EDITLINE
6288 # include <editline/readline.h>
6289 #else
6290 # include <readline/readline.h>
6291 # include <readline/history.h>
6292 #endif
6293 ])
6294
6295 # check for readline 2.2
6296 AC_CHECK_DECL([rl_completion_append_character], [
6297 AC_DEFINE([HAVE_RL_COMPLETION_APPEND_CHARACTER], [1], [Define if you have readline 2.2])
6298 ], [], [readline_includes])
6299
6300 AC_CHECK_DECL([rl_completion_suppress_append], [
6301 AC_DEFINE([HAVE_RL_COMPLETION_SUPPRESS_APPEND], [1], [Define if you have rl_completion_suppress_append])
6302 ], [], [readline_includes])
6303
6304 # check for readline 4.0
6305 AC_CACHE_CHECK([for rl_pre_input_hook in -l$LIBREADLINE], [ac_cv_readline_rl_pre_input_hook], [
6306 AC_LINK_IFELSE(
6307 [AC_LANG_PROGRAM([readline_includes], [void *x = rl_pre_input_hook])],
6308 [ac_cv_readline_rl_pre_input_hook=yes], [ac_cv_readline_rl_pre_input_hook=no]
6309 )
6310 ])
6311 AS_VAR_IF([ac_cv_readline_rl_pre_input_hook], [yes], [
6312 AC_DEFINE([HAVE_RL_PRE_INPUT_HOOK], [1], [Define if you have readline 4.0])
6313 ])
6314
6315 # also in 4.0
6316 AC_CACHE_CHECK([for rl_completion_display_matches_hook in -l$LIBREADLINE], [ac_cv_readline_rl_completion_display_matches_hook], [
6317 AC_LINK_IFELSE(
6318 [AC_LANG_PROGRAM([readline_includes], [void *x = rl_completion_display_matches_hook])],
6319 [ac_cv_readline_rl_completion_display_matches_hook=yes], [ac_cv_readline_rl_completion_display_matches_hook=no]
6320 )
6321 ])
6322 AS_VAR_IF([ac_cv_readline_rl_completion_display_matches_hook], [yes], [
6323 AC_DEFINE([HAVE_RL_COMPLETION_DISPLAY_MATCHES_HOOK], [1], [Define if you have readline 4.0])
6324 ])
6325
6326 # also in 4.0, but not in editline
6327 AC_CACHE_CHECK([for rl_resize_terminal in -l$LIBREADLINE], [ac_cv_readline_rl_resize_terminal], [
6328 AC_LINK_IFELSE(
6329 [AC_LANG_PROGRAM([readline_includes], [void *x = rl_resize_terminal])],
6330 [ac_cv_readline_rl_resize_terminal=yes], [ac_cv_readline_rl_resize_terminal=no]
6331 )
6332 ])
6333 AS_VAR_IF([ac_cv_readline_rl_resize_terminal], [yes], [
6334 AC_DEFINE([HAVE_RL_RESIZE_TERMINAL], [1], [Define if you have readline 4.0])
6335 ])
6336
6337 # check for readline 4.2
6338 AC_CACHE_CHECK([for rl_completion_matches in -l$LIBREADLINE], [ac_cv_readline_rl_completion_matches], [
6339 AC_LINK_IFELSE(
6340 [AC_LANG_PROGRAM([readline_includes], [void *x = rl_completion_matches])],
6341 [ac_cv_readline_rl_completion_matches=yes], [ac_cv_readline_rl_completion_matches=no]
6342 )
6343 ])
6344 AS_VAR_IF([ac_cv_readline_rl_completion_matches], [yes], [
6345 AC_DEFINE([HAVE_RL_COMPLETION_MATCHES], [1], [Define if you have readline 4.2])
6346 ])
6347
6348 # also in readline 4.2
6349 AC_CHECK_DECL([rl_catch_signals], [
6350 AC_DEFINE([HAVE_RL_CATCH_SIGNAL], [1], [Define if you can turn off readline's signal handling.])
6351 ], [], [readline_includes])
6352
6353 AC_CACHE_CHECK([for append_history in -l$LIBREADLINE], [ac_cv_readline_append_history], [
6354 AC_LINK_IFELSE(
6355 [AC_LANG_PROGRAM([readline_includes], [void *x = append_history])],
6356 [ac_cv_readline_append_history=yes], [ac_cv_readline_append_history=no]
6357 )
6358 ])
6359 AS_VAR_IF([ac_cv_readline_append_history], [yes], [
6360 AC_DEFINE([HAVE_RL_APPEND_HISTORY], [1], [Define if readline supports append_history])
6361 ])
6362
6363 # in readline as well as newer editline (April 2023)
6364 AC_CHECK_TYPES([rl_compdisp_func_t], [], [], [readline_includes])
6365
6366 # Some editline versions declare rl_startup_hook as taking no args, others
6367 # declare it as taking 2.
6368 AC_CACHE_CHECK([if rl_startup_hook takes arguments], [ac_cv_readline_rl_startup_hook_takes_args], [
6369 AC_COMPILE_IFELSE(
6370 [AC_LANG_PROGRAM([readline_includes]
6371 [extern int test_hook_func(const char *text, int state);],
6372 [rl_startup_hook=test_hook_func;])],
6373 [ac_cv_readline_rl_startup_hook_takes_args=yes],
6374 [ac_cv_readline_rl_startup_hook_takes_args=no]
6375 )
6376 ])
6377 AS_VAR_IF([ac_cv_readline_rl_startup_hook_takes_args], [yes], [
6378 AC_DEFINE([Py_RL_STARTUP_HOOK_TAKES_ARGS], [1], [Define if rl_startup_hook takes arguments])
6379 ])
6380
6381 m4_undefine([readline_includes])
6382 ])dnl WITH_SAVE_ENV()
6383 ])
6384
6385 AC_CACHE_CHECK([for broken nice()], [ac_cv_broken_nice], [
6386 AC_RUN_IFELSE([AC_LANG_SOURCE([[
6387 #include <stdlib.h>
6388 #include <unistd.h>
6389 int main(void)
6390 {
6391 int val1 = nice(1);
6392 if (val1 != -1 && val1 == nice(2))
6393 exit(0);
6394 exit(1);
6395 }
6396 ]])],
6397 [ac_cv_broken_nice=yes],
6398 [ac_cv_broken_nice=no],
6399 [ac_cv_broken_nice=no])])
6400 if test "$ac_cv_broken_nice" = yes
6401 then
6402 AC_DEFINE([HAVE_BROKEN_NICE], [1],
6403 [Define if nice() returns success/failure instead of the new priority.])
6404 fi
6405
6406 AC_CACHE_CHECK([for broken poll()], [ac_cv_broken_poll],
6407 AC_RUN_IFELSE([AC_LANG_SOURCE([[
6408 #include <poll.h>
6409 #include <unistd.h>
6410
6411 int main(void)
6412 {
6413 struct pollfd poll_struct = { 42, POLLIN|POLLPRI|POLLOUT, 0 };
6414 int poll_test;
6415
6416 close (42);
6417
6418 poll_test = poll(&poll_struct, 1, 0);
6419 if (poll_test < 0)
6420 return 0;
6421 else if (poll_test == 0 && poll_struct.revents != POLLNVAL)
6422 return 0;
6423 else
6424 return 1;
6425 }
6426 ]])],
6427 [ac_cv_broken_poll=yes],
6428 [ac_cv_broken_poll=no],
6429 [ac_cv_broken_poll=no]))
6430 if test "$ac_cv_broken_poll" = yes
6431 then
6432 AC_DEFINE([HAVE_BROKEN_POLL], [1],
6433 [Define if poll() sets errno on invalid file descriptors.])
6434 fi
6435
6436 # check tzset(3) exists and works like we expect it to
6437 AC_CACHE_CHECK([for working tzset()], [ac_cv_working_tzset], [
6438 AC_RUN_IFELSE([AC_LANG_SOURCE([[
6439 #include <stdlib.h>
6440 #include <time.h>
6441 #include <string.h>
6442
6443 #if HAVE_TZNAME
6444 extern char *tzname[];
6445 #endif
6446
6447 int main(void)
6448 {
6449 /* Note that we need to ensure that not only does tzset(3)
6450 do 'something' with localtime, but it works as documented
6451 in the library reference and as expected by the test suite.
6452 This includes making sure that tzname is set properly if
6453 tm->tm_zone does not exist since it is the alternative way
6454 of getting timezone info.
6455
6456 Red Hat 6.2 doesn't understand the southern hemisphere
6457 after New Year's Day.
6458 */
6459
6460 time_t groundhogday = 1044144000; /* GMT-based */
6461 time_t midyear = groundhogday + (365 * 24 * 3600 / 2);
6462
6463 putenv("TZ=UTC+0");
6464 tzset();
6465 if (localtime(&groundhogday)->tm_hour != 0)
6466 exit(1);
6467 #if HAVE_TZNAME
6468 /* For UTC, tzname[1] is sometimes "", sometimes " " */
6469 if (strcmp(tzname[0], "UTC") ||
6470 (tzname[1][0] != 0 && tzname[1][0] != ' '))
6471 exit(1);
6472 #endif
6473
6474 putenv("TZ=EST+5EDT,M4.1.0,M10.5.0");
6475 tzset();
6476 if (localtime(&groundhogday)->tm_hour != 19)
6477 exit(1);
6478 #if HAVE_TZNAME
6479 if (strcmp(tzname[0], "EST") || strcmp(tzname[1], "EDT"))
6480 exit(1);
6481 #endif
6482
6483 putenv("TZ=AEST-10AEDT-11,M10.5.0,M3.5.0");
6484 tzset();
6485 if (localtime(&groundhogday)->tm_hour != 11)
6486 exit(1);
6487 #if HAVE_TZNAME
6488 if (strcmp(tzname[0], "AEST") || strcmp(tzname[1], "AEDT"))
6489 exit(1);
6490 #endif
6491
6492 #if HAVE_STRUCT_TM_TM_ZONE
6493 if (strcmp(localtime(&groundhogday)->tm_zone, "AEDT"))
6494 exit(1);
6495 if (strcmp(localtime(&midyear)->tm_zone, "AEST"))
6496 exit(1);
6497 #endif
6498
6499 exit(0);
6500 }
6501 ]])],
6502 [ac_cv_working_tzset=yes],
6503 [ac_cv_working_tzset=no],
6504 [ac_cv_working_tzset=no])])
6505 if test "$ac_cv_working_tzset" = yes
6506 then
6507 AC_DEFINE([HAVE_WORKING_TZSET], [1],
6508 [Define if tzset() actually switches the local timezone in a meaningful way.])
6509 fi
6510
6511 # Look for subsecond timestamps in struct stat
6512 AC_CACHE_CHECK([for tv_nsec in struct stat], [ac_cv_stat_tv_nsec],
6513 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[@%:@include <sys/stat.h>]], [[
6514 struct stat st;
6515 st.st_mtim.tv_nsec = 1;
6516 ]])],
6517 [ac_cv_stat_tv_nsec=yes],
6518 [ac_cv_stat_tv_nsec=no]))
6519 if test "$ac_cv_stat_tv_nsec" = yes
6520 then
6521 AC_DEFINE([HAVE_STAT_TV_NSEC], [1],
6522 [Define if you have struct stat.st_mtim.tv_nsec])
6523 fi
6524
6525 # Look for BSD style subsecond timestamps in struct stat
6526 AC_CACHE_CHECK([for tv_nsec2 in struct stat], [ac_cv_stat_tv_nsec2],
6527 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[@%:@include <sys/stat.h>]], [[
6528 struct stat st;
6529 st.st_mtimespec.tv_nsec = 1;
6530 ]])],
6531 [ac_cv_stat_tv_nsec2=yes],
6532 [ac_cv_stat_tv_nsec2=no]))
6533 if test "$ac_cv_stat_tv_nsec2" = yes
6534 then
6535 AC_DEFINE([HAVE_STAT_TV_NSEC2], [1],
6536 [Define if you have struct stat.st_mtimensec])
6537 fi
6538
6539 dnl check for ncurses/ncursesw and panel/panelw
6540 dnl NOTE: old curses is not detected.
6541 dnl have_curses=[no, ncursesw, ncurses]
6542 dnl have_panel=[no, panelw, panel]
6543 have_curses=no
6544 have_panel=no
6545
6546 AH_TEMPLATE([HAVE_NCURSESW], [Define to 1 if you have the `ncursesw' library.])
6547 AC_CHECK_HEADERS([curses.h ncurses.h])
6548
6549 AS_VAR_IF([ac_cv_header_ncurses_h], [yes], [
6550 if test "$ac_sys_system" != "Darwin"; then
6551 dnl On macOS, there is no separate /usr/lib/libncursesw nor libpanelw.
6552 PKG_CHECK_MODULES([CURSES], [ncursesw], [
6553 AC_DEFINE([HAVE_NCURSESW], [1])
6554 have_curses=ncursesw
6555 ], [
6556 WITH_SAVE_ENV([
6557 AC_CHECK_LIB([ncursesw], [initscr], [
6558 AC_DEFINE([HAVE_NCURSESW], [1])
6559 have_curses=ncursesw
6560 CURSES_CFLAGS=${CURSES_CFLAGS-""}
6561 CURSES_LIBS=${CURSES_LIBS-"-lncursesw"}
6562 ])
6563 ])
6564 ])
6565 fi
6566
6567 AS_VAR_IF([have_curses], [no], [
6568 PKG_CHECK_MODULES([CURSES], [ncurses], [
6569 have_curses=ncurses
6570 ], [
6571 WITH_SAVE_ENV([
6572 AC_CHECK_LIB([ncurses], [initscr], [
6573 have_curses=ncurses
6574 CURSES_CFLAGS=${CURSES_CFLAGS-""}
6575 CURSES_LIBS=${CURSES_LIBS-"-lncurses"}
6576 ])
6577 ])
6578 ])
6579 ])
6580
6581 ])dnl ac_cv_header_ncurses_h = yes
6582
6583 dnl remove _XOPEN_SOURCE macro from curses cflags. pyconfig.h sets
6584 dnl the macro to 700.
6585 CURSES_CFLAGS=$(echo $CURSES_CFLAGS | sed 's/-D_XOPEN_SOURCE=600//g')
6586
6587 if test "$have_curses" != no -a "$ac_sys_system" = "Darwin"; then
6588 dnl On macOS, there is no separate /usr/lib/libncursesw nor libpanelw.
6589 dnl System-supplied ncurses combines libncurses/libpanel and supports wide
6590 dnl characters, so we can use it like ncursesw.
6591 dnl If a locally-supplied version of libncursesw is found, we will use that.
6592 dnl There should also be a libpanelw.
6593 dnl _XOPEN_SOURCE defines are usually excluded for macOS, but we need
6594 dnl _XOPEN_SOURCE_EXTENDED here for ncurses wide char support.
6595
6596 AS_VAR_APPEND([CURSES_CFLAGS], [" -D_XOPEN_SOURCE_EXTENDED=1"])
6597 AC_DEFINE([HAVE_NCURSESW], [1])
6598 fi
6599
6600 dnl TODO: detect "curses" and special cases tinfo, terminfo, or termcap
6601
6602 AC_MSG_CHECKING([curses module flags])
6603 AS_VAR_IF([have_curses], [no], [
6604 AC_MSG_RESULT([no])
6605 ], [
6606 AC_MSG_RESULT([$have_curses (CFLAGS: $CURSES_CFLAGS, LIBS: $CURSES_LIBS)])
6607 ])
6608
6609 dnl check for ncurses' panel/panelw library
6610 AC_CHECK_HEADERS([panel.h])
6611
6612 AS_VAR_IF([ac_cv_header_panel_h], [yes], [
6613
6614 if test "$ac_sys_system" != "Darwin"; then
6615 dnl On macOS, there is no separate /usr/lib/libncursesw nor libpanelw.
6616 AS_VAR_IF([have_curses], [ncursesw], [
6617 PKG_CHECK_MODULES([PANEL], [panelw], [
6618 have_panel=panelw
6619 ], [
6620 WITH_SAVE_ENV([
6621 AC_CHECK_LIB([panelw], [update_panels], [
6622 have_panel=panelw
6623 PANEL_CFLAGS=${PANEL_CFLAGS-""}
6624 PANEL_LIBS=${PANEL_LIBS-"-lpanelw"}
6625 ])
6626 ])
6627 ])
6628 ])
6629 fi
6630
6631 AS_VAR_IF([have_curses], [ncurses], [
6632 PKG_CHECK_MODULES([PANEL], [panel], [
6633 have_panel=panel
6634 ], [
6635 WITH_SAVE_ENV([
6636 AC_CHECK_LIB([panel], [update_panels], [
6637 have_panel=panel
6638 PANEL_CFLAGS=${PANEL_CFLAGS-""}
6639 PANEL_LIBS=${PANEL_LIBS-"-lpanel"}
6640 ])
6641 ])
6642 ])
6643 ])
6644
6645 ])dnl ac_cv_header_panel_h = yes
6646
6647 dnl pyconfig.h defines _XOPEN_SOURCE=700
6648 PANEL_CFLAGS=$(echo $PANEL_CFLAGS | sed 's/-D_XOPEN_SOURCE=600//g')
6649
6650 AC_MSG_CHECKING([panel flags])
6651 AS_VAR_IF([have_panel], [no], [
6652 AC_MSG_RESULT([no])
6653 ], [
6654 AC_MSG_RESULT([$have_panel (CFLAGS: $PANEL_CFLAGS, LIBS: $PANEL_LIBS)])
6655 ])
6656
6657 # first curses header check
6658 ac_save_cppflags="$CPPFLAGS"
6659 if test "$cross_compiling" = no; then
6660 CPPFLAGS="$CPPFLAGS -I/usr/include/ncursesw"
6661 fi
6662
6663 # On Solaris, term.h requires curses.h
6664 AC_CHECK_HEADERS([term.h], [], [], [
6665 #ifdef HAVE_CURSES_H
6666 #include <curses.h>
6667 #endif
6668 ])
6669
6670 # On HP/UX 11.0, mvwdelch is a block with a return statement
6671 AC_CACHE_CHECK([whether mvwdelch is an expression], [ac_cv_mvwdelch_is_expression],
6672 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[@%:@include <curses.h>]], [[
6673 int rtn;
6674 rtn = mvwdelch(0,0,0);
6675 ]])],
6676 [ac_cv_mvwdelch_is_expression=yes],
6677 [ac_cv_mvwdelch_is_expression=no]))
6678
6679 if test "$ac_cv_mvwdelch_is_expression" = yes
6680 then
6681 AC_DEFINE([MVWDELCH_IS_EXPRESSION], [1],
6682 [Define if mvwdelch in curses.h is an expression.])
6683 fi
6684
6685 # Issue #25720: ncurses has introduced the NCURSES_OPAQUE symbol making opaque
6686 # structs since version 5.7. If the macro is defined as zero before including
6687 # [n]curses.h, ncurses will expose fields of the structs regardless of the
6688 # configuration.
6689 AC_CACHE_CHECK([whether WINDOW has _flags], [ac_cv_window_has_flags],
6690 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
6691 #define NCURSES_OPAQUE 0
6692 #include <curses.h>
6693 ]], [[
6694 WINDOW *w;
6695 w->_flags = 0;
6696 ]])],
6697 [ac_cv_window_has_flags=yes],
6698 [ac_cv_window_has_flags=no]))
6699
6700
6701 if test "$ac_cv_window_has_flags" = yes
6702 then
6703 AC_DEFINE([WINDOW_HAS_FLAGS], [1],
6704 [Define if WINDOW in curses.h offers a field _flags.])
6705 fi
6706
6707 dnl PY_CHECK_CURSES_FUNC(FUNCTION)
6708 AC_DEFUN([PY_CHECK_CURSES_FUNC],
6709 [ AS_VAR_PUSHDEF([py_var], [ac_cv_lib_curses_$1])
6710 AS_VAR_PUSHDEF([py_define], [HAVE_CURSES_]m4_toupper($1))
6711 AC_CACHE_CHECK(
6712 [for curses function $1],
6713 [py_var],
6714 [AC_COMPILE_IFELSE(
6715 [AC_LANG_PROGRAM(
6716 [@%:@include <curses.h>], [
6717 #ifndef $1
6718 void *x=$1
6719 #endif
6720 ])],
6721 [AS_VAR_SET([py_var], [yes])],
6722 [AS_VAR_SET([py_var], [no])])]
6723 )
6724 AS_VAR_IF(
6725 [py_var],
6726 [yes],
6727 [AC_DEFINE([py_define], [1], [Define if you have the '$1' function.])])
6728 AS_VAR_POPDEF([py_var])
6729 AS_VAR_POPDEF([py_define])
6730 ])
6731
6732 PY_CHECK_CURSES_FUNC([is_pad])
6733 PY_CHECK_CURSES_FUNC([is_term_resized])
6734 PY_CHECK_CURSES_FUNC([resize_term])
6735 PY_CHECK_CURSES_FUNC([resizeterm])
6736 PY_CHECK_CURSES_FUNC([immedok])
6737 PY_CHECK_CURSES_FUNC([syncok])
6738 PY_CHECK_CURSES_FUNC([wchgat])
6739 PY_CHECK_CURSES_FUNC([filter])
6740 PY_CHECK_CURSES_FUNC([has_key])
6741 PY_CHECK_CURSES_FUNC([typeahead])
6742 PY_CHECK_CURSES_FUNC([use_env])
6743 CPPFLAGS=$ac_save_cppflags
6744
6745 AC_MSG_NOTICE([checking for device files])
6746
6747 dnl NOTE: Inform user how to proceed with files when cross compiling.
6748 dnl Some cross-compile builds are predictable; they won't ever
6749 dnl have /dev/ptmx or /dev/ptc, so we can set them explicitly.
6750 if test "$ac_sys_system" = "Linux-android" || test "$ac_sys_system" = "iOS"; then
6751 ac_cv_file__dev_ptmx=no
6752 ac_cv_file__dev_ptc=no
6753 else
6754 if test "x$cross_compiling" = xyes; then
6755 if test "${ac_cv_file__dev_ptmx+set}" != set; then
6756 AC_MSG_CHECKING([for /dev/ptmx])
6757 AC_MSG_RESULT([not set])
6758 AC_MSG_ERROR([set ac_cv_file__dev_ptmx to yes/no in your CONFIG_SITE file when cross compiling])
6759 fi
6760 if test "${ac_cv_file__dev_ptc+set}" != set; then
6761 AC_MSG_CHECKING([for /dev/ptc])
6762 AC_MSG_RESULT([not set])
6763 AC_MSG_ERROR([set ac_cv_file__dev_ptc to yes/no in your CONFIG_SITE file when cross compiling])
6764 fi
6765 fi
6766
6767 AC_CHECK_FILE([/dev/ptmx], [], [])
6768 if test "x$ac_cv_file__dev_ptmx" = xyes; then
6769 AC_DEFINE([HAVE_DEV_PTMX], [1],
6770 [Define to 1 if you have the /dev/ptmx device file.])
6771 fi
6772 AC_CHECK_FILE([/dev/ptc], [], [])
6773 if test "x$ac_cv_file__dev_ptc" = xyes; then
6774 AC_DEFINE([HAVE_DEV_PTC], [1],
6775 [Define to 1 if you have the /dev/ptc device file.])
6776 fi
6777 fi
6778
6779 if test $ac_sys_system = Darwin
6780 then
6781 LIBS="$LIBS -framework CoreFoundation"
6782 fi
6783
6784 AC_CHECK_TYPES([socklen_t], [],
6785 [AC_DEFINE([socklen_t], [int],
6786 [Define to 'int' if <sys/socket.h> does not define.])], [
6787 #ifdef HAVE_SYS_TYPES_H
6788 #include <sys/types.h>
6789 #endif
6790 #ifdef HAVE_SYS_SOCKET_H
6791 #include <sys/socket.h>
6792 #endif
6793 ])
6794
6795 AC_CACHE_CHECK([for broken mbstowcs], [ac_cv_broken_mbstowcs],
6796 AC_RUN_IFELSE([AC_LANG_SOURCE([[
6797 #include <stddef.h>
6798 #include <stdio.h>
6799 #include <stdlib.h>
6800 int main(void) {
6801 size_t len = -1;
6802 const char *str = "text";
6803 len = mbstowcs(NULL, str, 0);
6804 return (len != 4);
6805 }
6806 ]])],
6807 [ac_cv_broken_mbstowcs=no],
6808 [ac_cv_broken_mbstowcs=yes],
6809 [ac_cv_broken_mbstowcs=no]))
6810 if test "$ac_cv_broken_mbstowcs" = yes
6811 then
6812 AC_DEFINE([HAVE_BROKEN_MBSTOWCS], [1],
6813 [Define if mbstowcs(NULL, "text", 0) does not return the number of
6814 wide chars that would be converted.])
6815 fi
6816
6817 # Check for --with-computed-gotos
6818 AC_MSG_CHECKING([for --with-computed-gotos])
6819 AC_ARG_WITH(
6820 [computed-gotos],
6821 [AS_HELP_STRING(
6822 [--with-computed-gotos],
6823 [enable computed gotos in evaluation loop (enabled by default on supported compilers)]
6824 )],
6825 [
6826 if test "$withval" = yes
6827 then
6828 AC_DEFINE([USE_COMPUTED_GOTOS], [1],
6829 [Define if you want to use computed gotos in ceval.c.])
6830 AC_MSG_RESULT([yes])
6831 fi
6832 if test "$withval" = no
6833 then
6834 AC_DEFINE([USE_COMPUTED_GOTOS], [0],
6835 [Define if you want to use computed gotos in ceval.c.])
6836 AC_MSG_RESULT([no])
6837 fi
6838 ],
6839 [AC_MSG_RESULT([no value specified])])
6840
6841 AC_CACHE_CHECK([whether $CC supports computed gotos], [ac_cv_computed_gotos],
6842 AC_RUN_IFELSE([AC_LANG_SOURCE([[[
6843 int main(int argc, char **argv)
6844 {
6845 static void *targets[1] = { &&LABEL1 };
6846 goto LABEL2;
6847 LABEL1:
6848 return 0;
6849 LABEL2:
6850 goto *targets[0];
6851 return 1;
6852 }
6853 ]]])],
6854 [ac_cv_computed_gotos=yes],
6855 [ac_cv_computed_gotos=no],
6856 [if test "${with_computed_gotos+set}" = set; then
6857 ac_cv_computed_gotos="$with_computed_gotos -- configured --with(out)-computed-gotos"
6858 else
6859 ac_cv_computed_gotos=no
6860 fi]))
6861 case "$ac_cv_computed_gotos" in yes*)
6862 AC_DEFINE([HAVE_COMPUTED_GOTOS], [1],
6863 [Define if the C compiler supports computed gotos.])
6864 esac
6865
6866 case $ac_sys_system in
6867 AIX*)
6868 AC_DEFINE([HAVE_BROKEN_PIPE_BUF], [1],
6869 [Define if the system reports an invalid PIPE_BUF value.]) ;;
6870 esac
6871
6872
6873 AC_SUBST([THREADHEADERS])
6874
6875 for h in `(cd $srcdir;echo Python/thread_*.h)`
6876 do
6877 THREADHEADERS="$THREADHEADERS \$(srcdir)/$h"
6878 done
6879
6880 AC_SUBST([SRCDIRS])
6881 SRCDIRS="\
6882 Modules \
6883 Modules/_blake2 \
6884 Modules/_ctypes \
6885 Modules/_decimal \
6886 Modules/_decimal/libmpdec \
6887 Modules/_hacl \
6888 Modules/_io \
6889 Modules/_multiprocessing \
6890 Modules/_sqlite \
6891 Modules/_sre \
6892 Modules/_testcapi \
6893 Modules/_testinternalcapi \
6894 Modules/_testlimitedcapi \
6895 Modules/_xxtestfuzz \
6896 Modules/cjkcodecs \
6897 Modules/expat \
6898 Objects \
6899 Objects/mimalloc \
6900 Objects/mimalloc/prim \
6901 Parser \
6902 Parser/tokenizer \
6903 Parser/lexer \
6904 Programs \
6905 Python \
6906 Python/frozen_modules"
6907 AC_MSG_CHECKING([for build directories])
6908 for dir in $SRCDIRS; do
6909 if test ! -d $dir; then
6910 mkdir $dir
6911 fi
6912 done
6913 AC_MSG_RESULT([done])
6914
6915 # Availability of -O2:
6916 AC_CACHE_CHECK([for -O2], [ac_cv_compile_o2], [
6917 saved_cflags="$CFLAGS"
6918 CFLAGS="-O2"
6919 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [])], [ac_cv_compile_o2=yes], [ac_cv_compile_o2=no])
6920 CFLAGS="$saved_cflags"
6921 ])
6922
6923 # _FORTIFY_SOURCE wrappers for memmove and bcopy are incorrect:
6924 # http://sourceware.org/ml/libc-alpha/2010-12/msg00009.html
6925 AC_MSG_CHECKING([for glibc _FORTIFY_SOURCE/memmove bug])
6926 saved_cflags="$CFLAGS"
6927 CFLAGS="-O2 -D_FORTIFY_SOURCE=2"
6928 if test "$ac_cv_compile_o2" = no; then
6929 CFLAGS=""
6930 fi
6931 AC_RUN_IFELSE([AC_LANG_SOURCE([[
6932 #include <stdio.h>
6933 #include <stdlib.h>
6934 #include <string.h>
6935 void foo(void *p, void *q) { memmove(p, q, 19); }
6936 int main(void) {
6937 char a[32] = "123456789000000000";
6938 foo(&a[9], a);
6939 if (strcmp(a, "123456789123456789000000000") != 0)
6940 return 1;
6941 foo(a, &a[9]);
6942 if (strcmp(a, "123456789000000000") != 0)
6943 return 1;
6944 return 0;
6945 }
6946 ]])],
6947 [have_glibc_memmove_bug=no],
6948 [have_glibc_memmove_bug=yes],
6949 [have_glibc_memmove_bug=undefined])
6950 CFLAGS="$saved_cflags"
6951 AC_MSG_RESULT([$have_glibc_memmove_bug])
6952 if test "$have_glibc_memmove_bug" = yes; then
6953 AC_DEFINE([HAVE_GLIBC_MEMMOVE_BUG], [1],
6954 [Define if glibc has incorrect _FORTIFY_SOURCE wrappers
6955 for memmove and bcopy.])
6956 fi
6957
6958 if test "$ac_cv_gcc_asm_for_x87" = yes; then
6959 # Some versions of gcc miscompile inline asm:
6960 # http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46491
6961 # http://gcc.gnu.org/ml/gcc/2010-11/msg00366.html
6962 case $CC in
6963 *gcc*)
6964 AC_MSG_CHECKING([for gcc ipa-pure-const bug])
6965 saved_cflags="$CFLAGS"
6966 CFLAGS="-O2"
6967 AC_RUN_IFELSE([AC_LANG_SOURCE([[
6968 __attribute__((noinline)) int
6969 foo(int *p) {
6970 int r;
6971 asm ( "movl \$6, (%1)\n\t"
6972 "xorl %0, %0\n\t"
6973 : "=r" (r) : "r" (p) : "memory"
6974 );
6975 return r;
6976 }
6977 int main(void) {
6978 int p = 8;
6979 if ((foo(&p) ? : p) != 6)
6980 return 1;
6981 return 0;
6982 }
6983 ]])],
6984 [have_ipa_pure_const_bug=no],
6985 [have_ipa_pure_const_bug=yes],
6986 [have_ipa_pure_const_bug=undefined])
6987 CFLAGS="$saved_cflags"
6988 AC_MSG_RESULT([$have_ipa_pure_const_bug])
6989 if test "$have_ipa_pure_const_bug" = yes; then
6990 AC_DEFINE([HAVE_IPA_PURE_CONST_BUG], [1],
6991 [Define if gcc has the ipa-pure-const bug.])
6992 fi
6993 ;;
6994 esac
6995 fi
6996
6997 # ensurepip option
6998 AC_MSG_CHECKING([for ensurepip])
6999 AC_ARG_WITH([ensurepip],
7000 [AS_HELP_STRING([--with-ensurepip@<:@=install|upgrade|no@:>@],
7001 ["install" or "upgrade" using bundled pip (default is upgrade)])],
7002 [],
7003 [
7004 AS_CASE([$ac_sys_system],
7005 [Emscripten], [with_ensurepip=no],
7006 [WASI], [with_ensurepip=no],
7007 [iOS], [with_ensurepip=no],
7008 [with_ensurepip=upgrade]
7009 )
7010 ])
7011 AS_CASE([$with_ensurepip],
7012 [yes|upgrade],[ENSUREPIP=upgrade],
7013 [install],[ENSUREPIP=install],
7014 [no],[ENSUREPIP=no],
7015 [AC_MSG_ERROR([--with-ensurepip=upgrade|install|no])])
7016 AC_MSG_RESULT([$ENSUREPIP])
7017 AC_SUBST([ENSUREPIP])
7018
7019 # check if the dirent structure of a d_type field and DT_UNKNOWN is defined
7020 AC_CACHE_CHECK([if the dirent structure of a d_type field], [ac_cv_dirent_d_type], [
7021 AC_LINK_IFELSE(
7022 [
7023 AC_LANG_SOURCE([[
7024 #include <dirent.h>
7025
7026 int main(void) {
7027 struct dirent entry;
7028 return entry.d_type == DT_UNKNOWN;
7029 }
7030 ]])
7031 ],[ac_cv_dirent_d_type=yes],[ac_cv_dirent_d_type=no])
7032 ])
7033
7034 AS_VAR_IF([ac_cv_dirent_d_type], [yes], [
7035 AC_DEFINE([HAVE_DIRENT_D_TYPE], [1],
7036 [Define to 1 if the dirent structure has a d_type field])
7037 ])
7038
7039 # check if the Linux getrandom() syscall is available
7040 AC_CACHE_CHECK([for the Linux getrandom() syscall], [ac_cv_getrandom_syscall], [
7041 AC_LINK_IFELSE(
7042 [
7043 AC_LANG_SOURCE([[
7044 #include <stddef.h>
7045 #include <unistd.h>
7046 #include <sys/syscall.h>
7047 #include <linux/random.h>
7048
7049 int main(void) {
7050 char buffer[1];
7051 const size_t buflen = sizeof(buffer);
7052 const int flags = GRND_NONBLOCK;
7053 /* ignore the result, Python checks for ENOSYS and EAGAIN at runtime */
7054 (void)syscall(SYS_getrandom, buffer, buflen, flags);
7055 return 0;
7056 }
7057 ]])
7058 ],[ac_cv_getrandom_syscall=yes],[ac_cv_getrandom_syscall=no])
7059 ])
7060
7061 AS_VAR_IF([ac_cv_getrandom_syscall], [yes], [
7062 AC_DEFINE([HAVE_GETRANDOM_SYSCALL], [1],
7063 [Define to 1 if the Linux getrandom() syscall is available])
7064 ])
7065
7066 # check if the getrandom() function is available
7067 # the test was written for the Solaris function of <sys/random.h>
7068 AC_CACHE_CHECK([for the getrandom() function], [ac_cv_func_getrandom], [
7069 AC_LINK_IFELSE(
7070 [
7071 AC_LANG_SOURCE([[
7072 #include <stddef.h>
7073 #include <sys/random.h>
7074
7075 int main(void) {
7076 char buffer[1];
7077 const size_t buflen = sizeof(buffer);
7078 const int flags = 0;
7079 /* ignore the result, Python checks for ENOSYS at runtime */
7080 (void)getrandom(buffer, buflen, flags);
7081 return 0;
7082 }
7083 ]])
7084 ],[ac_cv_func_getrandom=yes],[ac_cv_func_getrandom=no])
7085 ])
7086
7087 AS_VAR_IF([ac_cv_func_getrandom], [yes], [
7088 AC_DEFINE([HAVE_GETRANDOM], [1],
7089 [Define to 1 if the getrandom() function is available])
7090 ])
7091
7092 # checks for POSIX shared memory, used by Modules/_multiprocessing/posixshmem.c
7093 # shm_* may only be available if linking against librt
7094 POSIXSHMEM_CFLAGS='-I$(srcdir)/Modules/_multiprocessing'
7095 WITH_SAVE_ENV([
7096 AC_SEARCH_LIBS([shm_open], [rt])
7097 AS_VAR_IF([ac_cv_search_shm_open], [-lrt], [POSIXSHMEM_LIBS="-lrt"])
7098
7099 dnl Temporarily override ac_includes_default for AC_CHECK_FUNCS below.
7100 _SAVE_VAR([ac_includes_default])
7101 ac_includes_default="\
7102 ${ac_includes_default}
7103 #ifndef __cplusplus
7104 # ifdef HAVE_SYS_MMAN_H
7105 # include <sys/mman.h>
7106 # endif
7107 #endif
7108 "
7109 AC_CHECK_FUNCS([shm_open shm_unlink], [have_posix_shmem=yes], [have_posix_shmem=no])
7110 _RESTORE_VAR([ac_includes_default])
7111 ])
7112
7113 # Check for usable OpenSSL
7114 AX_CHECK_OPENSSL([have_openssl=yes],[have_openssl=no])
7115
7116 # rpath to libssl and libcrypto
7117 AS_VAR_IF([GNULD], [yes], [
7118 rpath_arg="-Wl,--enable-new-dtags,-rpath="
7119 ], [
7120 if test "$ac_sys_system" = "Darwin"
7121 then
7122 rpath_arg="-Wl,-rpath,"
7123 else
7124 rpath_arg="-Wl,-rpath="
7125 fi
7126 ])
7127
7128 AC_MSG_CHECKING([for --with-openssl-rpath])
7129 AC_ARG_WITH([openssl-rpath],
7130 AS_HELP_STRING([--with-openssl-rpath=@<:@DIR|auto|no@:>@],
7131 [Set runtime library directory (rpath) for OpenSSL libraries,
7132 no (default): don't set rpath,
7133 auto: auto-detect rpath from --with-openssl and pkg-config,
7134 DIR: set an explicit rpath
7135 ]),
7136 [],
7137 [with_openssl_rpath=no]
7138 )
7139 AS_CASE([$with_openssl_rpath],
7140 [auto|yes], [
7141 OPENSSL_RPATH=auto
7142 dnl look for linker directories
7143 for arg in "$OPENSSL_LDFLAGS"; do
7144 AS_CASE([$arg],
7145 [-L*], [OPENSSL_LDFLAGS_RPATH="$OPENSSL_LDFLAGS_RPATH ${rpath_arg}$(echo $arg | cut -c3-)"]
7146 )
7147 done
7148 ],
7149 [no], [OPENSSL_RPATH=],
7150 [AS_IF(
7151 [test -d "$with_openssl_rpath"],
7152 [
7153 OPENSSL_RPATH="$with_openssl_rpath"
7154 OPENSSL_LDFLAGS_RPATH="${rpath_arg}$with_openssl_rpath"
7155 ],
7156 AC_MSG_ERROR([--with-openssl-rpath "$with_openssl_rpath" is not a directory]))
7157 ]
7158 )
7159 AC_MSG_RESULT([$OPENSSL_RPATH])
7160
7161 # This static linking is NOT OFFICIALLY SUPPORTED and not advertised.
7162 # Requires static OpenSSL build with position-independent code. Some features
7163 # like DSO engines or external OSSL providers don't work. Only tested with GCC
7164 # and clang on X86_64.
7165 AS_VAR_IF([PY_UNSUPPORTED_OPENSSL_BUILD], [static], [
7166 AC_MSG_CHECKING([for unsupported static openssl build])
7167 new_OPENSSL_LIBS=
7168 for arg in $OPENSSL_LIBS; do
7169 AS_CASE([$arg],
7170 [-l*], [
7171 libname=$(echo $arg | cut -c3-)
7172 new_OPENSSL_LIBS="$new_OPENSSL_LIBS -l:lib${libname}.a -Wl,--exclude-libs,lib${libname}.a"
7173 ],
7174 [new_OPENSSL_LIBS="$new_OPENSSL_LIBS $arg"]
7175 )
7176 done
7177 dnl include libz for OpenSSL build flavors with compression support
7178 OPENSSL_LIBS="$new_OPENSSL_LIBS $ZLIB_LIBS"
7179 AC_MSG_RESULT([$OPENSSL_LIBS])
7180 ])
7181
7182 dnl AX_CHECK_OPENSSL does not export libcrypto-only libs
7183 LIBCRYPTO_LIBS=
7184 for arg in $OPENSSL_LIBS; do
7185 AS_CASE([$arg],
7186 [-l*ssl*|-Wl*ssl*], [],
7187 [LIBCRYPTO_LIBS="$LIBCRYPTO_LIBS $arg"]
7188 )
7189 done
7190
7191 # check if OpenSSL libraries work as expected
7192 WITH_SAVE_ENV([
7193 LIBS="$LIBS $OPENSSL_LIBS"
7194 CFLAGS="$CFLAGS $OPENSSL_INCLUDES"
7195 LDFLAGS="$LDFLAGS $OPENSSL_LDFLAGS $OPENSSL_LDFLAGS_RPATH"
7196
7197 AC_CACHE_CHECK([whether OpenSSL provides required ssl module APIs], [ac_cv_working_openssl_ssl], [
7198 AC_LINK_IFELSE([AC_LANG_PROGRAM([
7199 #include <openssl/opensslv.h>
7200 #include <openssl/ssl.h>
7201 #if OPENSSL_VERSION_NUMBER < 0x10101000L
7202 #error "OpenSSL >= 1.1.1 is required"
7203 #endif
7204 static void keylog_cb(const SSL *ssl, const char *line) {}
7205 ], [
7206 SSL_CTX *ctx = SSL_CTX_new(TLS_client_method());
7207 SSL_CTX_set_keylog_callback(ctx, keylog_cb);
7208 SSL *ssl = SSL_new(ctx);
7209 X509_VERIFY_PARAM *param = SSL_get0_param(ssl);
7210 X509_VERIFY_PARAM_set1_host(param, "python.org", 0);
7211 SSL_free(ssl);
7212 SSL_CTX_free(ctx);
7213 ])], [ac_cv_working_openssl_ssl=yes], [ac_cv_working_openssl_ssl=no])
7214 ])
7215 ])
7216
7217 WITH_SAVE_ENV([
7218 LIBS="$LIBS $LIBCRYPTO_LIBS"
7219 CFLAGS="$CFLAGS $OPENSSL_INCLUDES"
7220 LDFLAGS="$LDFLAGS $OPENSSL_LDFLAGS $OPENSSL_LDFLAGS_RPATH"
7221
7222 AC_CACHE_CHECK([whether OpenSSL provides required hashlib module APIs], [ac_cv_working_openssl_hashlib], [
7223 AC_LINK_IFELSE([AC_LANG_PROGRAM([
7224 #include <openssl/opensslv.h>
7225 #include <openssl/evp.h>
7226 #if OPENSSL_VERSION_NUMBER < 0x10101000L
7227 #error "OpenSSL >= 1.1.1 is required"
7228 #endif
7229 ], [
7230 OBJ_nid2sn(NID_md5);
7231 OBJ_nid2sn(NID_sha1);
7232 OBJ_nid2sn(NID_sha3_512);
7233 OBJ_nid2sn(NID_blake2b512);
7234 EVP_PBE_scrypt(NULL, 0, NULL, 0, 2, 8, 1, 0, NULL, 0);
7235 ])], [ac_cv_working_openssl_hashlib=yes], [ac_cv_working_openssl_hashlib=no])
7236 ])
7237 ])
7238
7239 # ssl module default cipher suite string
7240 AH_TEMPLATE([PY_SSL_DEFAULT_CIPHERS],
7241 [Default cipher suites list for ssl module.
7242 1: Python's preferred selection, 2: leave OpenSSL defaults untouched, 0: custom string])
7243 AH_TEMPLATE([PY_SSL_DEFAULT_CIPHER_STRING],
7244 [Cipher suite string for PY_SSL_DEFAULT_CIPHERS=0]
7245 )
7246
7247 AC_MSG_CHECKING([for --with-ssl-default-suites])
7248 AC_ARG_WITH(
7249 [ssl-default-suites],
7250 [AS_HELP_STRING(
7251 [--with-ssl-default-suites=@<:@python|openssl|STRING@:>@],
7252 [override default cipher suites string,
7253 python: use Python's preferred selection (default),
7254 openssl: leave OpenSSL's defaults untouched,
7255 STRING: use a custom string,
7256 python and STRING also set TLS 1.2 as minimum TLS version]
7257 )],
7258 [
7259 AC_MSG_RESULT([$withval])
7260 case "$withval" in
7261 python)
7262 AC_DEFINE([PY_SSL_DEFAULT_CIPHERS], [1])
7263 ;;
7264 openssl)
7265 AC_DEFINE([PY_SSL_DEFAULT_CIPHERS], [2])
7266 ;;
7267 *)
7268 AC_DEFINE([PY_SSL_DEFAULT_CIPHERS], [0])
7269 AC_DEFINE_UNQUOTED([PY_SSL_DEFAULT_CIPHER_STRING], ["$withval"])
7270 ;;
7271 esac
7272 ],
7273 [
7274 AC_MSG_RESULT([python])
7275 AC_DEFINE([PY_SSL_DEFAULT_CIPHERS], [1])
7276 ])
7277
7278 # builtin hash modules
7279 default_hashlib_hashes="md5,sha1,sha2,sha3,blake2"
7280 AC_DEFINE([PY_BUILTIN_HASHLIB_HASHES], [], [enabled builtin hash modules]
7281 )
7282 AC_MSG_CHECKING([for --with-builtin-hashlib-hashes])
7283 AC_ARG_WITH(
7284 [builtin-hashlib-hashes],
7285 [AS_HELP_STRING(
7286 [--with-builtin-hashlib-hashes=md5,sha1,sha2,sha3,blake2],
7287 [builtin hash modules, md5, sha1, sha2, sha3 (with shake), blake2]
7288 )],
7289 [
7290 AS_CASE([$with_builtin_hashlib_hashes],
7291 [yes], [with_builtin_hashlib_hashes=$default_hashlib_hashes],
7292 [no], [with_builtin_hashlib_hashes=""]
7293 )
7294 ], [with_builtin_hashlib_hashes=$default_hashlib_hashes])
7295
7296 AC_MSG_RESULT([$with_builtin_hashlib_hashes])
7297 AC_DEFINE_UNQUOTED([PY_BUILTIN_HASHLIB_HASHES],
7298 ["$with_builtin_hashlib_hashes"])
7299
7300 as_save_IFS=$IFS
7301 IFS=,
7302 for builtin_hash in $with_builtin_hashlib_hashes; do
7303 AS_CASE([$builtin_hash],
7304 [md5], [with_builtin_md5=yes],
7305 [sha1], [with_builtin_sha1=yes],
7306 [sha2], [with_builtin_sha2=yes],
7307 [sha3], [with_builtin_sha3=yes],
7308 [blake2], [with_builtin_blake2=yes]
7309 )
7310 done
7311 IFS=$as_save_IFS
7312
7313 dnl libb2 for blake2. _blake2 module falls back to vendored copy.
7314 AS_VAR_IF([with_builtin_blake2], [yes], [
7315 PKG_CHECK_MODULES([LIBB2], [libb2], [
7316 have_libb2=yes
7317 AC_DEFINE([HAVE_LIBB2], [1],
7318 [Define to 1 if you want to build _blake2 module with libb2])
7319 ], [have_libb2=no])
7320 ])
7321
7322 # Check whether to disable test modules. Once set, setup.py will not build
7323 # test extension modules and "make install" will not install test suites.
7324 AC_MSG_CHECKING([for --disable-test-modules])
7325 AC_ARG_ENABLE([test-modules],
7326 [AS_HELP_STRING([--disable-test-modules], [don't build nor install test modules])], [
7327 AS_VAR_IF([enable_test_modules], [yes], [TEST_MODULES=yes], [TEST_MODULES=no])
7328 ], [
7329 AS_CASE([$ac_sys_system/$ac_sys_emscripten_target],
7330 [Emscripten/browser*], [TEST_MODULES=no],
7331 [TEST_MODULES=yes]
7332 )
7333 ])
7334 AC_MSG_RESULT([$TEST_MODULES])
7335 AC_SUBST([TEST_MODULES])
7336
7337 # gh-109054: Check if -latomic is needed to get <pyatomic.h> atomic functions.
7338 # On Linux aarch64, GCC may require programs and libraries to be linked
7339 # explicitly to libatomic. Call _Py_atomic_or_uint64() which may require
7340 # libatomic __atomic_fetch_or_8(), or not, depending on the C compiler and the
7341 # compiler flags.
7342 #
7343 # gh-112779: On RISC-V, GCC 12 and earlier require libatomic support for 1-byte
7344 # and 2-byte operations, but not for 8-byte operations.
7345 #
7346 # Avoid #include <Python.h> or #include <pyport.h>. The <Python.h> header
7347 # requires <pyconfig.h> header which is only written below by AC_OUTPUT below.
7348 # If the check is done after AC_OUTPUT, modifying LIBS has no effect
7349 # anymore. <pyport.h> cannot be included alone, it's designed to be included
7350 # by <Python.h>: it expects other includes and macros to be defined.
7351 _SAVE_VAR([CPPFLAGS])
7352 CPPFLAGS="${BASECPPFLAGS} -I. -I${srcdir}/Include ${CPPFLAGS}"
7353
7354 AC_CACHE_CHECK([whether libatomic is needed by <pyatomic.h>],
7355 [ac_cv_libatomic_needed],
7356 [AC_RUN_IFELSE([AC_LANG_SOURCE([[
7357 // pyatomic.h needs uint64_t and Py_ssize_t types
7358 #include <stdint.h> // int64_t, intptr_t
7359 #ifdef HAVE_SYS_TYPES_H
7360 # include <sys/types.h> // ssize_t
7361 #endif
7362 // Code adapted from Include/pyport.h
7363 #if HAVE_SSIZE_T
7364 typedef ssize_t Py_ssize_t;
7365 #elif SIZEOF_VOID_P == SIZEOF_SIZE_T
7366 typedef intptr_t Py_ssize_t;
7367 #else
7368 # error "unable to define Py_ssize_t"
7369 #endif
7370
7371 #include "pyatomic.h"
7372
7373 int main()
7374 {
7375 uint64_t value;
7376 _Py_atomic_store_uint64(&value, 2);
7377 if (_Py_atomic_or_uint64(&value, 8) != 2) {
7378 return 1; // error
7379 }
7380 if (_Py_atomic_load_uint64(&value) != 10) {
7381 return 1; // error
7382 }
7383 uint8_t byte = 0xb8;
7384 if (_Py_atomic_or_uint8(&byte, 0x2d) != 0xb8) {
7385 return 1; // error
7386 }
7387 if (_Py_atomic_load_uint8(&byte) != 0xbd) {
7388 return 1; // error
7389 }
7390 return 0; // all good
7391 }
7392 ]])],
7393 [ac_cv_libatomic_needed=no], dnl build succeeded
7394 [ac_cv_libatomic_needed=yes], dnl build failed
7395 [ac_cv_libatomic_needed=no]) dnl cross compilation
7396 ])
7397
7398 AS_VAR_IF([ac_cv_libatomic_needed], [yes],
7399 [LIBS="${LIBS} -latomic"
7400 LIBATOMIC=${LIBATOMIC-"-latomic"}])
7401 _RESTORE_VAR([CPPFLAGS])
7402
7403
7404 # stdlib
7405 AC_DEFUN([PY_STDLIB_MOD_SET_NA], [
7406 m4_foreach([mod], [$@], [
7407 AS_VAR_SET([py_cv_module_]mod, [n/a])])
7408 ])
7409
7410 # stdlib not available
7411 dnl Modules that are not available on some platforms
7412 AS_CASE([$ac_sys_system],
7413 [AIX], [PY_STDLIB_MOD_SET_NA([_scproxy])],
7414 [VxWorks*], [PY_STDLIB_MOD_SET_NA([_scproxy], [termios], [grp])],
7415 dnl The _scproxy module is available on macOS
7416 [Darwin], [],
7417 [iOS], [
7418 dnl subprocess and multiprocessing are not supported (no fork syscall).
7419 dnl curses and tkinter user interface are not available.
7420 dnl gdbm and nis aren't available
7421 dnl Stub implementations are provided for pwd, grp etc APIs
7422 PY_STDLIB_MOD_SET_NA(
7423 [_curses],
7424 [_curses_panel],
7425 [_gdbm],
7426 [_multiprocessing],
7427 [_posixshmem],
7428 [_posixsubprocess],
7429 [_scproxy],
7430 [_tkinter],
7431 [grp],
7432 [nis],
7433 [readline],
7434 [pwd],
7435 [spwd],
7436 [syslog],
7437 )
7438 ],
7439 [CYGWIN*], [PY_STDLIB_MOD_SET_NA([_scproxy])],
7440 [QNX*], [PY_STDLIB_MOD_SET_NA([_scproxy])],
7441 [FreeBSD*], [PY_STDLIB_MOD_SET_NA([_scproxy])],
7442 [Emscripten|WASI], [
7443 dnl subprocess and multiprocessing are not supported (no fork syscall).
7444 dnl curses and tkinter user interface are not available.
7445 dnl dbm and gdbm aren't available, too.
7446 dnl Emscripten and WASI provide only stubs for pwd, grp APIs.
7447 dnl resource functions (get/setrusage) are stubs, too.
7448 PY_STDLIB_MOD_SET_NA(
7449 [_curses],
7450 [_curses_panel],
7451 [_dbm],
7452 [_gdbm],
7453 [_multiprocessing],
7454 [_posixshmem],
7455 [_posixsubprocess],
7456 [_scproxy],
7457 [_tkinter],
7458 [_interpreters],
7459 [_interpchannels],
7460 [_interpqueues],
7461 [grp],
7462 [pwd],
7463 [resource],
7464 [syslog],
7465 )
7466 AS_CASE([$ac_sys_system/$ac_sys_emscripten_target],
7467 [Emscripten/browser*], [
7468 dnl These modules are not particularly useful in browsers.
7469 PY_STDLIB_MOD_SET_NA(
7470 [fcntl],
7471 [readline],
7472 [termios],
7473 )
7474 ],
7475 [Emscripten/node*], [],
7476 [WASI/*], [
7477 dnl WASI SDK 15.0 does not support file locking, mmap, and more.
7478 dnl Test modules that must be compiled as shared libraries are not supported
7479 dnl (see Modules/Setup.stdlib.in).
7480 PY_STDLIB_MOD_SET_NA(
7481 [_ctypes_test],
7482 [_testexternalinspection],
7483 [_testimportmultiple],
7484 [_testmultiphase],
7485 [_testsinglephase],
7486 [fcntl],
7487 [mmap],
7488 [termios],
7489 [xxlimited],
7490 [xxlimited_35],
7491 )
7492 ]
7493 )
7494 ],
7495 [PY_STDLIB_MOD_SET_NA([_scproxy])]
7496 )
7497
7498 dnl AC_MSG_NOTICE([m4_set_list([_PY_STDLIB_MOD_SET_NA])])
7499
7500 dnl Default value for Modules/Setup.stdlib build type
7501 AS_CASE([$host_cpu],
7502 [wasm32|wasm64], [MODULE_BUILDTYPE=static],
7503 [MODULE_BUILDTYPE=${MODULE_BUILDTYPE:-shared}]
7504 )
7505 AC_SUBST([MODULE_BUILDTYPE])
7506
7507 dnl _MODULE_BLOCK_ADD([VAR], [VALUE])
7508 dnl internal: adds $1=quote($2) to MODULE_BLOCK
7509 AC_DEFUN([_MODULE_BLOCK_ADD], [AS_VAR_APPEND([MODULE_BLOCK], ["$1=_AS_QUOTE([$2])$as_nl"])])
7510 MODULE_BLOCK=
7511
7512 dnl Check for stdlib extension modules
7513 dnl PY_STDLIB_MOD([NAME], [ENABLED-TEST], [SUPPORTED-TEST], [CFLAGS], [LDFLAGS])
7514 dnl sets MODULE_$NAME_STATE based on PY_STDLIB_MOD_SET_NA(), ENABLED-TEST,
7515 dnl and SUPPORTED_TEST. ENABLED-TEST and SUPPORTED-TEST default to true if
7516 dnl empty.
7517 dnl n/a: marked unavailable on platform by PY_STDLIB_MOD_SET_NA()
7518 dnl yes: enabled and supported
7519 dnl missing: enabled and not supported
7520 dnl disabled: not enabled
7521 dnl sets MODULE_$NAME_CFLAGS and MODULE_$NAME_LDFLAGS
7522 AC_DEFUN([PY_STDLIB_MOD], [
7523 AC_MSG_CHECKING([for stdlib extension module $1])
7524 m4_pushdef([modcond], [MODULE_]m4_toupper([$1]))dnl
7525 m4_pushdef([modstate], [py_cv_module_$1])dnl
7526 dnl Check if module has been disabled by PY_STDLIB_MOD_SET_NA()
7527 AS_IF([test "$modstate" != "n/a"], [
7528 AS_IF([m4_ifblank([$2], [true], [$2])],
7529 [AS_IF([m4_ifblank([$3], [true], [$3])], [modstate=yes], [modstate=missing])],
7530 [modstate=disabled])
7531 ])
7532 _MODULE_BLOCK_ADD(modcond[_STATE], [$modstate])
7533 AS_VAR_IF([modstate], [yes], [
7534 m4_ifblank([$4], [], [_MODULE_BLOCK_ADD([MODULE_]m4_toupper([$1])[_CFLAGS], [$4])])
7535 m4_ifblank([$5], [], [_MODULE_BLOCK_ADD([MODULE_]m4_toupper([$1])[_LDFLAGS], [$5])])
7536 ])
7537 AM_CONDITIONAL(modcond, [test "$modstate" = yes])
7538 AC_MSG_RESULT([$modstate])
7539 m4_popdef([modcond])dnl
7540 m4_popdef([modstate])dnl
7541 ])
7542
7543 dnl Define simple stdlib extension module
7544 dnl Always enable unless the module is disabled by PY_STDLIB_MOD_SET_NA
7545 dnl PY_STDLIB_MOD_SIMPLE([NAME], [CFLAGS], [LDFLAGS])
7546 dnl cflags and ldflags are optional
7547 AC_DEFUN([PY_STDLIB_MOD_SIMPLE], [
7548 m4_pushdef([modcond], [MODULE_]m4_toupper([$1]))dnl
7549 m4_pushdef([modstate], [py_cv_module_$1])dnl
7550 dnl Check if module has been disabled by PY_STDLIB_MOD_SET_NA()
7551 AS_IF([test "$modstate" != "n/a"], [modstate=yes])
7552 AM_CONDITIONAL(modcond, [test "$modstate" = yes])
7553 _MODULE_BLOCK_ADD(modcond[_STATE], [$modstate])
7554 AS_VAR_IF([modstate], [yes], [
7555 m4_ifblank([$2], [], [_MODULE_BLOCK_ADD([MODULE_]m4_toupper([$1])[_CFLAGS], [$2])])
7556 m4_ifblank([$3], [], [_MODULE_BLOCK_ADD([MODULE_]m4_toupper([$1])[_LDFLAGS], [$3])])
7557 ])
7558 m4_popdef([modcond])dnl
7559 m4_popdef([modstate])dnl
7560 ])
7561
7562 dnl static modules in Modules/Setup.bootstrap
7563 PY_STDLIB_MOD_SIMPLE([_io], [-I\$(srcdir)/Modules/_io], [])
7564 PY_STDLIB_MOD_SIMPLE([time], [], [$TIMEMODULE_LIB])
7565
7566 dnl always enabled extension modules
7567 PY_STDLIB_MOD_SIMPLE([array])
7568 PY_STDLIB_MOD_SIMPLE([_asyncio])
7569 PY_STDLIB_MOD_SIMPLE([_bisect])
7570 PY_STDLIB_MOD_SIMPLE([_contextvars])
7571 PY_STDLIB_MOD_SIMPLE([_csv])
7572 PY_STDLIB_MOD_SIMPLE([_heapq])
7573 PY_STDLIB_MOD_SIMPLE([_json])
7574 PY_STDLIB_MOD_SIMPLE([_lsprof])
7575 PY_STDLIB_MOD_SIMPLE([_opcode])
7576 PY_STDLIB_MOD_SIMPLE([_pickle])
7577 PY_STDLIB_MOD_SIMPLE([_posixsubprocess])
7578 PY_STDLIB_MOD_SIMPLE([_queue])
7579 PY_STDLIB_MOD_SIMPLE([_random])
7580 PY_STDLIB_MOD_SIMPLE([select])
7581 PY_STDLIB_MOD_SIMPLE([_struct])
7582 PY_STDLIB_MOD_SIMPLE([_typing])
7583 PY_STDLIB_MOD_SIMPLE([_interpreters])
7584 PY_STDLIB_MOD_SIMPLE([_interpchannels])
7585 PY_STDLIB_MOD_SIMPLE([_interpqueues])
7586 PY_STDLIB_MOD_SIMPLE([_zoneinfo])
7587
7588 dnl multiprocessing modules
7589 PY_STDLIB_MOD([_multiprocessing],
7590 [], [test "$ac_cv_func_sem_unlink" = "yes"],
7591 [-I\$(srcdir)/Modules/_multiprocessing])
7592 PY_STDLIB_MOD([_posixshmem],
7593 [], [test "$have_posix_shmem" = "yes"],
7594 [$POSIXSHMEM_CFLAGS], [$POSIXSHMEM_LIBS])
7595
7596 dnl needs libm
7597 PY_STDLIB_MOD_SIMPLE([_statistics], [], [$LIBM])
7598 PY_STDLIB_MOD_SIMPLE([cmath], [], [$LIBM])
7599 PY_STDLIB_MOD_SIMPLE([math], [], [$LIBM])
7600
7601 dnl needs libm and on some platforms librt
7602 PY_STDLIB_MOD_SIMPLE([_datetime], [], [$TIMEMODULE_LIB $LIBM])
7603
7604 dnl modules with some unix dependencies
7605 PY_STDLIB_MOD([fcntl],
7606 [], [test "$ac_cv_header_sys_ioctl_h" = "yes" -a "$ac_cv_header_fcntl_h" = "yes"],
7607 [], [$FCNTL_LIBS])
7608 PY_STDLIB_MOD([mmap],
7609 [], [test "$ac_cv_header_sys_mman_h" = "yes" -a "$ac_cv_header_sys_stat_h" = "yes"])
7610 PY_STDLIB_MOD([_socket],
7611 [], m4_flatten([test "$ac_cv_header_sys_socket_h" = "yes"
7612 -a "$ac_cv_header_sys_types_h" = "yes"
7613 -a "$ac_cv_header_netinet_in_h" = "yes"]))
7614
7615 dnl platform specific extensions
7616 PY_STDLIB_MOD([grp], [],
7617 [test "$ac_cv_func_getgrent" = "yes" &&
7618 { test "$ac_cv_func_getgrgid" = "yes" || test "$ac_cv_func_getgrgid_r" = "yes"; }])
7619 PY_STDLIB_MOD([pwd], [], [test "$ac_cv_func_getpwuid" = yes -o "$ac_cv_func_getpwuid_r" = yes])
7620 PY_STDLIB_MOD([resource], [], [test "$ac_cv_header_sys_resource_h" = yes])
7621 PY_STDLIB_MOD([_scproxy],
7622 [test "$ac_sys_system" = "Darwin"], [],
7623 [], [-framework SystemConfiguration -framework CoreFoundation])
7624 PY_STDLIB_MOD([syslog], [], [test "$ac_cv_header_syslog_h" = yes])
7625 PY_STDLIB_MOD([termios], [], [test "$ac_cv_header_termios_h" = yes])
7626
7627 dnl _elementtree loads libexpat via CAPI hook in pyexpat
7628 PY_STDLIB_MOD([pyexpat],
7629 [], [test "$ac_cv_header_sys_time_h" = "yes"],
7630 [$LIBEXPAT_CFLAGS], [$LIBEXPAT_LDFLAGS])
7631 PY_STDLIB_MOD([_elementtree], [], [], [$LIBEXPAT_CFLAGS], [])
7632 PY_STDLIB_MOD_SIMPLE([_codecs_cn])
7633 PY_STDLIB_MOD_SIMPLE([_codecs_hk])
7634 PY_STDLIB_MOD_SIMPLE([_codecs_iso2022])
7635 PY_STDLIB_MOD_SIMPLE([_codecs_jp])
7636 PY_STDLIB_MOD_SIMPLE([_codecs_kr])
7637 PY_STDLIB_MOD_SIMPLE([_codecs_tw])
7638 PY_STDLIB_MOD_SIMPLE([_multibytecodec])
7639 PY_STDLIB_MOD_SIMPLE([unicodedata])
7640
7641 dnl By default we always compile these even when OpenSSL is available
7642 dnl (issue #14693). The modules are small.
7643 PY_STDLIB_MOD([_md5],
7644 [test "$with_builtin_md5" = yes], [],
7645 [-I\$(srcdir)/Modules/_hacl/include -I\$(srcdir)/Modules/_hacl/internal -D_BSD_SOURCE -D_DEFAULT_SOURCE])
7646 PY_STDLIB_MOD([_sha1],
7647 [test "$with_builtin_sha1" = yes], [],
7648 [-I\$(srcdir)/Modules/_hacl/include -I\$(srcdir)/Modules/_hacl/internal -D_BSD_SOURCE -D_DEFAULT_SOURCE])
7649 PY_STDLIB_MOD([_sha2],
7650 [test "$with_builtin_sha2" = yes], [],
7651 [-I\$(srcdir)/Modules/_hacl/include -I\$(srcdir)/Modules/_hacl/internal -D_BSD_SOURCE -D_DEFAULT_SOURCE])
7652 PY_STDLIB_MOD([_sha3], [test "$with_builtin_sha3" = yes])
7653 PY_STDLIB_MOD([_blake2],
7654 [test "$with_builtin_blake2" = yes], [],
7655 [$LIBB2_CFLAGS], [$LIBB2_LIBS])
7656
7657 PY_STDLIB_MOD([_ctypes],
7658 [], [test "$have_libffi" = yes],
7659 [$NO_STRICT_OVERFLOW_CFLAGS $LIBFFI_CFLAGS], [$LIBFFI_LIBS])
7660 PY_STDLIB_MOD([_curses],
7661 [], [test "$have_curses" != "no"],
7662 [$CURSES_CFLAGS], [$CURSES_LIBS]
7663 )
7664 PY_STDLIB_MOD([_curses_panel],
7665 [], [test "$have_panel" != "no"],
7666 [$PANEL_CFLAGS $CURSES_CFLAGS], [$PANEL_LIBS $CURSES_LIBS]
7667 )
7668 PY_STDLIB_MOD([_decimal], [], [], [$LIBMPDEC_CFLAGS], [$LIBMPDEC_LIBS])
7669 PY_STDLIB_MOD([_dbm],
7670 [test -n "$with_dbmliborder"], [test "$have_dbm" != "no"],
7671 [$DBM_CFLAGS], [$DBM_LIBS])
7672 PY_STDLIB_MOD([_gdbm],
7673 [test "$have_gdbm_dbmliborder" = yes], [test "$have_gdbm" = yes],
7674 [$GDBM_CFLAGS], [$GDBM_LIBS])
7675 PY_STDLIB_MOD([readline],
7676 [], [test "$with_readline" != "no"],
7677 [$READLINE_CFLAGS], [$READLINE_LIBS])
7678 PY_STDLIB_MOD([_sqlite3],
7679 [test "$have_sqlite3" = "yes"],
7680 [test "$have_supported_sqlite3" = "yes"],
7681 [$LIBSQLITE3_CFLAGS], [$LIBSQLITE3_LIBS])
7682 PY_STDLIB_MOD([_tkinter],
7683 [], [test "$have_tcltk" = "yes"],
7684 [$TCLTK_CFLAGS], [$TCLTK_LIBS])
7685 PY_STDLIB_MOD([_uuid],
7686 [], [test "$have_uuid" = "yes"],
7687 [$LIBUUID_CFLAGS], [$LIBUUID_LIBS])
7688
7689 dnl compression libs
7690 PY_STDLIB_MOD([zlib], [], [test "$have_zlib" = yes],
7691 [$ZLIB_CFLAGS], [$ZLIB_LIBS])
7692 dnl binascii can use zlib for optimized crc32.
7693 PY_STDLIB_MOD_SIMPLE([binascii], [$BINASCII_CFLAGS], [$BINASCII_LIBS])
7694 PY_STDLIB_MOD([_bz2], [], [test "$have_bzip2" = yes],
7695 [$BZIP2_CFLAGS], [$BZIP2_LIBS])
7696 PY_STDLIB_MOD([_lzma], [], [test "$have_liblzma" = yes],
7697 [$LIBLZMA_CFLAGS], [$LIBLZMA_LIBS])
7698
7699 dnl OpenSSL bindings
7700 PY_STDLIB_MOD([_ssl], [], [test "$ac_cv_working_openssl_ssl" = yes],
7701 [$OPENSSL_INCLUDES], [$OPENSSL_LDFLAGS $OPENSSL_LDFLAGS_RPATH $OPENSSL_LIBS])
7702 PY_STDLIB_MOD([_hashlib], [], [test "$ac_cv_working_openssl_hashlib" = yes],
7703 [$OPENSSL_INCLUDES], [$OPENSSL_LDFLAGS $OPENSSL_LDFLAGS_RPATH $LIBCRYPTO_LIBS])
7704
7705 dnl test modules
7706 PY_STDLIB_MOD([_testcapi],
7707 [test "$TEST_MODULES" = yes],
7708 dnl Modules/_testcapi needs -latomic for 32bit AIX build
7709 [], [], [$LIBATOMIC])
7710 PY_STDLIB_MOD([_testclinic], [test "$TEST_MODULES" = yes])
7711 PY_STDLIB_MOD([_testclinic_limited], [test "$TEST_MODULES" = yes])
7712 PY_STDLIB_MOD([_testlimitedcapi], [test "$TEST_MODULES" = yes])
7713 PY_STDLIB_MOD([_testinternalcapi], [test "$TEST_MODULES" = yes])
7714 PY_STDLIB_MOD([_testbuffer], [test "$TEST_MODULES" = yes])
7715 PY_STDLIB_MOD([_testimportmultiple], [test "$TEST_MODULES" = yes], [test "$ac_cv_func_dlopen" = yes])
7716 PY_STDLIB_MOD([_testmultiphase], [test "$TEST_MODULES" = yes], [test "$ac_cv_func_dlopen" = yes])
7717 PY_STDLIB_MOD([_testsinglephase], [test "$TEST_MODULES" = yes], [test "$ac_cv_func_dlopen" = yes])
7718 PY_STDLIB_MOD([_testexternalinspection], [test "$TEST_MODULES" = yes])
7719 PY_STDLIB_MOD([xxsubtype], [test "$TEST_MODULES" = yes])
7720 PY_STDLIB_MOD([_xxtestfuzz], [test "$TEST_MODULES" = yes])
7721 PY_STDLIB_MOD([_ctypes_test],
7722 [test "$TEST_MODULES" = yes], [test "$have_libffi" = yes -a "$ac_cv_func_dlopen" = yes],
7723 [], [$LIBM])
7724
7725 dnl Limited API template modules.
7726 dnl Emscripten does not support shared libraries yet.
7727 PY_STDLIB_MOD([xxlimited], [test "$TEST_MODULES" = yes], [test "$ac_cv_func_dlopen" = yes])
7728 PY_STDLIB_MOD([xxlimited_35], [test "$TEST_MODULES" = yes], [test "$ac_cv_func_dlopen" = yes])
7729
7730 # substitute multiline block, must come after last PY_STDLIB_MOD()
7731 AC_SUBST([MODULE_BLOCK])
7732
7733 # generate output files
7734 AC_CONFIG_FILES(m4_normalize([
7735 Makefile.pre
7736 Misc/python.pc
7737 Misc/python-embed.pc
7738 Misc/python-config.sh
7739 ]))
7740 AC_CONFIG_FILES(m4_normalize([
7741 Modules/Setup.bootstrap
7742 Modules/Setup.stdlib
7743 ]))
7744 AC_CONFIG_FILES([Modules/ld_so_aix], [chmod +x Modules/ld_so_aix])
7745 # Generate files like pyconfig.h
7746 AC_OUTPUT
7747
7748 AC_MSG_NOTICE([creating Modules/Setup.local])
7749 if test ! -f Modules/Setup.local
7750 then
7751 echo "# Edit this file for local setup changes" >Modules/Setup.local
7752 fi
7753
7754 AC_MSG_NOTICE([creating Makefile])
7755 $SHELL $srcdir/Modules/makesetup -c $srcdir/Modules/config.c.in \
7756 -s Modules \
7757 Modules/Setup.local Modules/Setup.stdlib Modules/Setup.bootstrap $srcdir/Modules/Setup
7758 if test $? -ne 0; then
7759 AC_MSG_ERROR([makesetup failed])
7760 fi
7761
7762 mv config.c Modules
7763
7764 if test -z "$PKG_CONFIG"; then
7765 AC_MSG_WARN([pkg-config is missing. Some dependencies may not be detected correctly.])
7766 fi
7767
7768 if test "$Py_OPT" = 'false' -a "$Py_DEBUG" != 'true'; then
7769 AC_MSG_NOTICE([
7770
7771 If you want a release build with all stable optimizations active (PGO, etc),
7772 please run ./configure --enable-optimizations
7773 ])
7774 fi
7775
7776 AS_VAR_IF([PY_SUPPORT_TIER], [0], [AC_MSG_WARN([
7777
7778 Platform "$host" with compiler "$ac_cv_cc_name" is not supported by the
7779 CPython core team, see https://peps.python.org/pep-0011/ for more information.
7780 ])])
7781
7782 if test "$ac_cv_header_stdatomic_h" != "yes"; then
7783 AC_MSG_NOTICE(m4_normalize([
7784 Your compiler or platform does have a working C11 stdatomic.h. A future
7785 version of Python may require stdatomic.h.
7786 ]))
7787 fi