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