1dnl *************************************************** 2dnl * Please run autoreconf -if to test your changes! * 3dnl *************************************************** 4dnl 5dnl Python's configure script requires autoconf 2.69 and autoconf-archive. 6dnl 7 8# Set VERSION so we only need to edit in one place (i.e., here) 9m4_define(PYTHON_VERSION, 3.9) 10 11AC_PREREQ([2.69]) 12 13AC_INIT([python],[PYTHON_VERSION],[https://bugs.python.org/]) 14 15m4_ifdef( 16 [AX_C_FLOAT_WORDS_BIGENDIAN], 17 [], 18 [AC_MSG_ERROR([Please install autoconf-archive package and re-run autoreconf])] 19) 20 21AC_SUBST(BASECPPFLAGS) 22if test "$srcdir" != . -a "$srcdir" != "$(pwd)"; then 23 # If we're building out-of-tree, we need to make sure the following 24 # resources get picked up before their $srcdir counterparts. 25 # Objects/ -> typeslots.inc 26 # Include/ -> Python-ast.h, graminit.h 27 # Python/ -> importlib.h 28 # (A side effect of this is that these resources will automatically be 29 # regenerated when building out-of-tree, regardless of whether or not 30 # the $srcdir counterpart is up-to-date. This is an acceptable trade 31 # off.) 32 BASECPPFLAGS="-IObjects -IInclude -IPython" 33else 34 BASECPPFLAGS="" 35fi 36 37AC_SUBST(GITVERSION) 38AC_SUBST(GITTAG) 39AC_SUBST(GITBRANCH) 40 41if test -e $srcdir/.git 42then 43AC_CHECK_PROG(HAS_GIT, git, found, not-found) 44else 45HAS_GIT=no-repository 46fi 47if test $HAS_GIT = found 48then 49 GITVERSION="git --git-dir \$(srcdir)/.git rev-parse --short HEAD" 50 GITTAG="git --git-dir \$(srcdir)/.git describe --all --always --dirty" 51 GITBRANCH="git --git-dir \$(srcdir)/.git name-rev --name-only HEAD" 52else 53 GITVERSION="" 54 GITTAG="" 55 GITBRANCH="" 56fi 57 58AC_CONFIG_SRCDIR([Include/object.h]) 59AC_CONFIG_HEADER(pyconfig.h) 60 61AC_CANONICAL_HOST 62AC_SUBST(build) 63AC_SUBST(host) 64 65# pybuilddir.txt will be created by --generate-posix-vars in the Makefile 66rm -f pybuilddir.txt 67 68AC_CHECK_PROGS(PYTHON_FOR_REGEN, python$PACKAGE_VERSION python3 python, python3) 69AC_SUBST(PYTHON_FOR_REGEN) 70 71if test "$cross_compiling" = yes; then 72 AC_MSG_CHECKING([for python interpreter for cross build]) 73 if test -z "$PYTHON_FOR_BUILD"; then 74 for interp in python$PACKAGE_VERSION python3 python; do 75 which $interp >/dev/null 2>&1 || continue 76 if $interp -c "import sys;sys.exit(not '.'.join(str(n) for n in sys.version_info@<:@:2@:>@) == '$PACKAGE_VERSION')"; then 77 break 78 fi 79 interp= 80 done 81 if test x$interp = x; then 82 AC_MSG_ERROR([python$PACKAGE_VERSION interpreter not found]) 83 fi 84 AC_MSG_RESULT($interp) 85 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) '$interp 86 fi 87elif test "$cross_compiling" = maybe; then 88 AC_MSG_ERROR([Cross compiling required --host=HOST-TUPLE and --build=ARCH]) 89else 90 PYTHON_FOR_BUILD='./$(BUILDPYTHON) -E' 91fi 92AC_SUBST(PYTHON_FOR_BUILD) 93 94dnl Ensure that if prefix is specified, it does not end in a slash. If 95dnl it does, we get path names containing '//' which is both ugly and 96dnl can cause trouble. 97 98dnl Last slash shouldn't be stripped if prefix=/ 99if test "$prefix" != "/"; then 100 prefix=`echo "$prefix" | sed -e 's/\/$//g'` 101fi 102 103dnl This is for stuff that absolutely must end up in pyconfig.h. 104dnl Please use pyport.h instead, if possible. 105AH_TOP([ 106#ifndef Py_PYCONFIG_H 107#define Py_PYCONFIG_H 108]) 109AH_BOTTOM([ 110/* Define the macros needed if on a UnixWare 7.x system. */ 111#if defined(__USLC__) && defined(__SCO_VERSION__) 112#define STRICT_SYSV_CURSES /* Don't use ncurses extensions */ 113#endif 114 115#endif /*Py_PYCONFIG_H*/ 116]) 117 118# We don't use PACKAGE_ variables, and they cause conflicts 119# with other autoconf-based packages that include Python.h 120grep -v 'define PACKAGE_' <confdefs.h >confdefs.h.new 121rm confdefs.h 122mv confdefs.h.new confdefs.h 123 124AC_SUBST(VERSION) 125VERSION=PYTHON_VERSION 126 127# Version number of Python's own shared library file. 128AC_SUBST(SOVERSION) 129SOVERSION=1.0 130 131# The later defininition of _XOPEN_SOURCE disables certain features 132# on Linux, so we need _GNU_SOURCE to re-enable them (makedev, tm_zone). 133AC_DEFINE(_GNU_SOURCE, 1, [Define on Linux to activate all library features]) 134 135# The later defininition of _XOPEN_SOURCE and _POSIX_C_SOURCE disables 136# certain features on NetBSD, so we need _NETBSD_SOURCE to re-enable 137# them. 138AC_DEFINE(_NETBSD_SOURCE, 1, [Define on NetBSD to activate all library features]) 139 140# The later defininition of _XOPEN_SOURCE and _POSIX_C_SOURCE disables 141# certain features on FreeBSD, so we need __BSD_VISIBLE to re-enable 142# them. 143AC_DEFINE(__BSD_VISIBLE, 1, [Define on FreeBSD to activate all library features]) 144 145# The later defininition of _XOPEN_SOURCE and _POSIX_C_SOURCE disables 146# certain features on Mac OS X, so we need _DARWIN_C_SOURCE to re-enable 147# them. 148AC_DEFINE(_DARWIN_C_SOURCE, 1, [Define on Darwin to activate all library features]) 149 150 151define_xopen_source=yes 152 153# Arguments passed to configure. 154AC_SUBST(CONFIG_ARGS) 155CONFIG_ARGS="$ac_configure_args" 156 157AC_MSG_CHECKING([for --enable-universalsdk]) 158AC_ARG_ENABLE(universalsdk, 159 AS_HELP_STRING([--enable-universalsdk@<:@=SDKDIR@:>@], 160 [create a universal binary build. 161 SDKDIR specifies which macOS SDK should be used to perform the build, 162 see Mac/README.rst. (default is no)]), 163[ 164 case $enableval in 165 yes) 166 # Locate the best usable SDK, see Mac/README for more 167 # information 168 enableval="`/usr/bin/xcodebuild -version -sdk macosx Path 2>/dev/null`" 169 if ! ( echo $enableval | grep -E '\.sdk' 1>/dev/null ) 170 then 171 enableval=/Developer/SDKs/MacOSX10.4u.sdk 172 if test ! -d "${enableval}" 173 then 174 enableval=/ 175 fi 176 fi 177 ;; 178 esac 179 case $enableval in 180 no) 181 UNIVERSALSDK= 182 enable_universalsdk= 183 ;; 184 *) 185 UNIVERSALSDK=$enableval 186 if test ! -d "${UNIVERSALSDK}" 187 then 188 AC_MSG_ERROR([--enable-universalsdk specifies non-existing SDK: ${UNIVERSALSDK}]) 189 fi 190 ;; 191 esac 192 193],[ 194 UNIVERSALSDK= 195 enable_universalsdk= 196]) 197if test -n "${UNIVERSALSDK}" 198then 199 AC_MSG_RESULT(${UNIVERSALSDK}) 200else 201 AC_MSG_RESULT(no) 202fi 203AC_SUBST(UNIVERSALSDK) 204 205AC_SUBST(ARCH_RUN_32BIT) 206ARCH_RUN_32BIT="" 207 208# For backward compatibility reasons we prefer to select '32-bit' if available, 209# otherwise use 'intel' 210UNIVERSAL_ARCHS="32-bit" 211if test "`uname -s`" = "Darwin" 212then 213 if test -n "${UNIVERSALSDK}" 214 then 215 if test -z "`/usr/bin/file -L "${UNIVERSALSDK}/usr/lib/libSystem.dylib" | grep ppc`" 216 then 217 UNIVERSAL_ARCHS="intel" 218 fi 219 fi 220fi 221 222AC_SUBST(LIPO_32BIT_FLAGS) 223AC_SUBST(LIPO_INTEL64_FLAGS) 224AC_MSG_CHECKING(for --with-universal-archs) 225AC_ARG_WITH(universal-archs, 226 AS_HELP_STRING([--with-universal-archs=ARCH], 227 [specify the kind of macOS universal binary that should be created. 228 This option is only valid when --enable-universalsdk is set; options are: 229 ("universal2", "intel-64", "intel-32", "intel", "32-bit", 230 "64-bit", "3-way", or "all") 231 see Mac/README.rst]), 232[ 233 UNIVERSAL_ARCHS="$withval" 234], 235[]) 236if test -n "${UNIVERSALSDK}" 237then 238 AC_MSG_RESULT(${UNIVERSAL_ARCHS}) 239else 240 AC_MSG_RESULT(no) 241fi 242 243AC_ARG_WITH(framework-name, 244 AS_HELP_STRING([--with-framework-name=FRAMEWORK], 245 [specify the name for the python framework on macOS 246 only valid when --enable-framework is set. see Mac/README.rst 247 (default is 'Python')]), 248[ 249 PYTHONFRAMEWORK=${withval} 250 PYTHONFRAMEWORKDIR=${withval}.framework 251 PYTHONFRAMEWORKIDENTIFIER=org.python.`echo $withval | tr '[A-Z]' '[a-z]'` 252 ],[ 253 PYTHONFRAMEWORK=Python 254 PYTHONFRAMEWORKDIR=Python.framework 255 PYTHONFRAMEWORKIDENTIFIER=org.python.python 256]) 257dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output 258AC_ARG_ENABLE(framework, 259 AS_HELP_STRING([--enable-framework@<:@=INSTALLDIR@:>@], 260 [create a Python.framework rather than a traditional Unix install. 261 optional INSTALLDIR specifies the installation path. see Mac/README.rst 262 (default is no)]), 263[ 264 case $enableval in 265 yes) 266 enableval=/Library/Frameworks 267 esac 268 case $enableval in 269 no) 270 PYTHONFRAMEWORK= 271 PYTHONFRAMEWORKDIR=no-framework 272 PYTHONFRAMEWORKPREFIX= 273 PYTHONFRAMEWORKINSTALLDIR= 274 FRAMEWORKINSTALLFIRST= 275 FRAMEWORKINSTALLLAST= 276 FRAMEWORKALTINSTALLFIRST= 277 FRAMEWORKALTINSTALLLAST= 278 FRAMEWORKPYTHONW= 279 if test "x${prefix}" = "xNONE"; then 280 FRAMEWORKUNIXTOOLSPREFIX="${ac_default_prefix}" 281 else 282 FRAMEWORKUNIXTOOLSPREFIX="${prefix}" 283 fi 284 enable_framework= 285 ;; 286 *) 287 PYTHONFRAMEWORKPREFIX="${enableval}" 288 PYTHONFRAMEWORKINSTALLDIR=$PYTHONFRAMEWORKPREFIX/$PYTHONFRAMEWORKDIR 289 FRAMEWORKINSTALLFIRST="frameworkinstallstructure" 290 FRAMEWORKALTINSTALLFIRST="frameworkinstallstructure " 291 FRAMEWORKINSTALLLAST="frameworkinstallmaclib frameworkinstallapps frameworkinstallunixtools" 292 FRAMEWORKALTINSTALLLAST="frameworkinstallmaclib frameworkinstallapps frameworkaltinstallunixtools" 293 FRAMEWORKPYTHONW="frameworkpythonw" 294 FRAMEWORKINSTALLAPPSPREFIX="/Applications" 295 296 if test "x${prefix}" = "xNONE" ; then 297 FRAMEWORKUNIXTOOLSPREFIX="${ac_default_prefix}" 298 299 else 300 FRAMEWORKUNIXTOOLSPREFIX="${prefix}" 301 fi 302 303 case "${enableval}" in 304 /System*) 305 FRAMEWORKINSTALLAPPSPREFIX="/Applications" 306 if test "${prefix}" = "NONE" ; then 307 # See below 308 FRAMEWORKUNIXTOOLSPREFIX="/usr" 309 fi 310 ;; 311 312 /Library*) 313 FRAMEWORKINSTALLAPPSPREFIX="/Applications" 314 ;; 315 316 */Library/Frameworks) 317 MDIR="`dirname "${enableval}"`" 318 MDIR="`dirname "${MDIR}"`" 319 FRAMEWORKINSTALLAPPSPREFIX="${MDIR}/Applications" 320 321 if test "${prefix}" = "NONE"; then 322 # User hasn't specified the 323 # --prefix option, but wants to install 324 # the framework in a non-default location, 325 # ensure that the compatibility links get 326 # installed relative to that prefix as well 327 # instead of in /usr/local. 328 FRAMEWORKUNIXTOOLSPREFIX="${MDIR}" 329 fi 330 ;; 331 332 *) 333 FRAMEWORKINSTALLAPPSPREFIX="/Applications" 334 ;; 335 esac 336 337 prefix=$PYTHONFRAMEWORKINSTALLDIR/Versions/$VERSION 338 339 # Add files for Mac specific code to the list of output 340 # files: 341 AC_CONFIG_FILES(Mac/Makefile) 342 AC_CONFIG_FILES(Mac/PythonLauncher/Makefile) 343 AC_CONFIG_FILES(Mac/Resources/framework/Info.plist) 344 AC_CONFIG_FILES(Mac/Resources/app/Info.plist) 345 esac 346 ],[ 347 PYTHONFRAMEWORK= 348 PYTHONFRAMEWORKDIR=no-framework 349 PYTHONFRAMEWORKPREFIX= 350 PYTHONFRAMEWORKINSTALLDIR= 351 FRAMEWORKINSTALLFIRST= 352 FRAMEWORKINSTALLLAST= 353 FRAMEWORKALTINSTALLFIRST= 354 FRAMEWORKALTINSTALLLAST= 355 FRAMEWORKPYTHONW= 356 if test "x${prefix}" = "xNONE" ; then 357 FRAMEWORKUNIXTOOLSPREFIX="${ac_default_prefix}" 358 else 359 FRAMEWORKUNIXTOOLSPREFIX="${prefix}" 360 fi 361 enable_framework= 362 363]) 364AC_SUBST(PYTHONFRAMEWORK) 365AC_SUBST(PYTHONFRAMEWORKIDENTIFIER) 366AC_SUBST(PYTHONFRAMEWORKDIR) 367AC_SUBST(PYTHONFRAMEWORKPREFIX) 368AC_SUBST(PYTHONFRAMEWORKINSTALLDIR) 369AC_SUBST(FRAMEWORKINSTALLFIRST) 370AC_SUBST(FRAMEWORKINSTALLLAST) 371AC_SUBST(FRAMEWORKALTINSTALLFIRST) 372AC_SUBST(FRAMEWORKALTINSTALLLAST) 373AC_SUBST(FRAMEWORKPYTHONW) 374AC_SUBST(FRAMEWORKUNIXTOOLSPREFIX) 375AC_SUBST(FRAMEWORKINSTALLAPPSPREFIX) 376 377AC_DEFINE_UNQUOTED(_PYTHONFRAMEWORK, "${PYTHONFRAMEWORK}", [framework name]) 378 379##AC_ARG_WITH(dyld, 380## AS_HELP_STRING([--with-dyld], 381## [use (OpenStep|Rhapsody) dynamic linker])) 382## 383# Set name for machine-dependent library files 384AC_ARG_VAR([MACHDEP], [name for machine-dependent library files]) 385AC_MSG_CHECKING(MACHDEP) 386if test -z "$MACHDEP" 387then 388 # avoid using uname for cross builds 389 if test "$cross_compiling" = yes; then 390 # ac_sys_system and ac_sys_release are used for setting 391 # a lot of different things including 'define_xopen_source' 392 # in the case statement below. 393 case "$host" in 394 *-*-linux-android*) 395 ac_sys_system=Linux-android 396 ;; 397 *-*-linux*) 398 ac_sys_system=Linux 399 ;; 400 *-*-cygwin*) 401 ac_sys_system=Cygwin 402 ;; 403 *-*-vxworks*) 404 ac_sys_system=VxWorks 405 ;; 406 *) 407 # for now, limit cross builds to known configurations 408 MACHDEP="unknown" 409 AC_MSG_ERROR([cross build not supported for $host]) 410 esac 411 ac_sys_release= 412 else 413 ac_sys_system=`uname -s` 414 if test "$ac_sys_system" = "AIX" \ 415 -o "$ac_sys_system" = "UnixWare" -o "$ac_sys_system" = "OpenUNIX"; then 416 ac_sys_release=`uname -v` 417 else 418 ac_sys_release=`uname -r` 419 fi 420 fi 421 ac_md_system=`echo $ac_sys_system | 422 tr -d '[/ ]' | tr '[[A-Z]]' '[[a-z]]'` 423 ac_md_release=`echo $ac_sys_release | 424 tr -d '[/ ]' | sed 's/^[[A-Z]]\.//' | sed 's/\..*//'` 425 MACHDEP="$ac_md_system$ac_md_release" 426 427 case $MACHDEP in 428 aix*) MACHDEP="aix";; 429 linux*) MACHDEP="linux";; 430 cygwin*) MACHDEP="cygwin";; 431 darwin*) MACHDEP="darwin";; 432 '') MACHDEP="unknown";; 433 esac 434fi 435AC_MSG_RESULT("$MACHDEP") 436 437AC_SUBST(_PYTHON_HOST_PLATFORM) 438if test "$cross_compiling" = yes; then 439 case "$host" in 440 *-*-linux*) 441 case "$host_cpu" in 442 arm*) 443 _host_cpu=arm 444 ;; 445 *) 446 _host_cpu=$host_cpu 447 esac 448 ;; 449 *-*-cygwin*) 450 _host_cpu= 451 ;; 452 *-*-vxworks*) 453 _host_cpu=$host_cpu 454 ;; 455 *) 456 # for now, limit cross builds to known configurations 457 MACHDEP="unknown" 458 AC_MSG_ERROR([cross build not supported for $host]) 459 esac 460 _PYTHON_HOST_PLATFORM="$MACHDEP${_host_cpu:+-$_host_cpu}" 461fi 462 463# Some systems cannot stand _XOPEN_SOURCE being defined at all; they 464# disable features if it is defined, without any means to access these 465# features as extensions. For these systems, we skip the definition of 466# _XOPEN_SOURCE. Before adding a system to the list to gain access to 467# some feature, make sure there is no alternative way to access this 468# feature. Also, when using wildcards, make sure you have verified the 469# need for not defining _XOPEN_SOURCE on all systems matching the 470# wildcard, and that the wildcard does not include future systems 471# (which may remove their limitations). 472dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output 473case $ac_sys_system/$ac_sys_release in 474 # On OpenBSD, select(2) is not available if _XOPEN_SOURCE is defined, 475 # even though select is a POSIX function. Reported by J. Ribbens. 476 # Reconfirmed for OpenBSD 3.3 by Zachary Hamm, for 3.4 by Jason Ish. 477 # In addition, Stefan Krah confirms that issue #1244610 exists through 478 # OpenBSD 4.6, but is fixed in 4.7. 479 OpenBSD/2.* | OpenBSD/3.* | OpenBSD/4.@<:@0123456@:>@) 480 define_xopen_source=no 481 # OpenBSD undoes our definition of __BSD_VISIBLE if _XOPEN_SOURCE is 482 # also defined. This can be overridden by defining _BSD_SOURCE 483 # As this has a different meaning on Linux, only define it on OpenBSD 484 AC_DEFINE(_BSD_SOURCE, 1, [Define on OpenBSD to activate all library features]) 485 ;; 486 OpenBSD/*) 487 # OpenBSD undoes our definition of __BSD_VISIBLE if _XOPEN_SOURCE is 488 # also defined. This can be overridden by defining _BSD_SOURCE 489 # As this has a different meaning on Linux, only define it on OpenBSD 490 AC_DEFINE(_BSD_SOURCE, 1, [Define on OpenBSD to activate all library features]) 491 ;; 492 # Defining _XOPEN_SOURCE on NetBSD version prior to the introduction of 493 # _NETBSD_SOURCE disables certain features (eg. setgroups). Reported by 494 # Marc Recht 495 NetBSD/1.5 | NetBSD/1.5.* | NetBSD/1.6 | NetBSD/1.6.* | NetBSD/1.6@<:@A-S@:>@) 496 define_xopen_source=no;; 497 # From the perspective of Solaris, _XOPEN_SOURCE is not so much a 498 # request to enable features supported by the standard as a request 499 # to disable features not supported by the standard. The best way 500 # for Python to use Solaris is simply to leave _XOPEN_SOURCE out 501 # entirely and define __EXTENSIONS__ instead. 502 SunOS/*) 503 define_xopen_source=no;; 504 # On UnixWare 7, u_long is never defined with _XOPEN_SOURCE, 505 # but used in /usr/include/netinet/tcp.h. Reported by Tim Rice. 506 # Reconfirmed for 7.1.4 by Martin v. Loewis. 507 OpenUNIX/8.0.0| UnixWare/7.1.@<:@0-4@:>@) 508 define_xopen_source=no;; 509 # On OpenServer 5, u_short is never defined with _XOPEN_SOURCE, 510 # but used in struct sockaddr.sa_family. Reported by Tim Rice. 511 SCO_SV/3.2) 512 define_xopen_source=no;; 513 # On MacOS X 10.2, a bug in ncurses.h means that it craps out if 514 # _XOPEN_EXTENDED_SOURCE is defined. Apparently, this is fixed in 10.3, which 515 # identifies itself as Darwin/7.* 516 # On Mac OS X 10.4, defining _POSIX_C_SOURCE or _XOPEN_SOURCE 517 # disables platform specific features beyond repair. 518 # On Mac OS X 10.3, defining _POSIX_C_SOURCE or _XOPEN_SOURCE 519 # has no effect, don't bother defining them 520 Darwin/@<:@6789@:>@.*) 521 define_xopen_source=no;; 522 Darwin/@<:@[12]@:>@@<:@0-9@:>@.*) 523 define_xopen_source=no;; 524 # On AIX 4 and 5.1, mbstate_t is defined only when _XOPEN_SOURCE == 500 but 525 # used in wcsnrtombs() and mbsnrtowcs() even if _XOPEN_SOURCE is not defined 526 # or has another value. By not (re)defining it, the defaults come in place. 527 AIX/4) 528 define_xopen_source=no;; 529 AIX/5) 530 if test `uname -r` -eq 1; then 531 define_xopen_source=no 532 fi 533 ;; 534 # On QNX 6.3.2, defining _XOPEN_SOURCE prevents netdb.h from 535 # defining NI_NUMERICHOST. 536 QNX/6.3.2) 537 define_xopen_source=no 538 ;; 539 # On VxWorks, defining _XOPEN_SOURCE causes compile failures 540 # in network headers still using system V types. 541 VxWorks/*) 542 define_xopen_source=no 543 ;; 544 545 # On HP-UX, defining _XOPEN_SOURCE to 600 or greater hides 546 # chroot() and other functions 547 hp*|HP*) 548 define_xopen_source=no 549 ;; 550 551esac 552 553if test $define_xopen_source = yes 554then 555 # X/Open 7, incorporating POSIX.1-2008 556 AC_DEFINE(_XOPEN_SOURCE, 700, 557 Define to the level of X/Open that your system supports) 558 559 # On Tru64 Unix 4.0F, defining _XOPEN_SOURCE also requires 560 # definition of _XOPEN_SOURCE_EXTENDED and _POSIX_C_SOURCE, or else 561 # several APIs are not declared. Since this is also needed in some 562 # cases for HP-UX, we define it globally. 563 AC_DEFINE(_XOPEN_SOURCE_EXTENDED, 1, 564 Define to activate Unix95-and-earlier features) 565 566 AC_DEFINE(_POSIX_C_SOURCE, 200809L, Define to activate features from IEEE Stds 1003.1-2008) 567fi 568 569# On HP-UX mbstate_t requires _INCLUDE__STDC_A1_SOURCE 570case $ac_sys_system in 571 hp*|HP*) 572 define_stdc_a1=yes;; 573 *) 574 define_stdc_a1=no;; 575esac 576 577if test $define_stdc_a1 = yes 578then 579 AC_DEFINE(_INCLUDE__STDC_A1_SOURCE, 1, Define to include mbstate_t for mbrtowc) 580fi 581 582# Record the configure-time value of MACOSX_DEPLOYMENT_TARGET, 583# it may influence the way we can build extensions, so distutils 584# needs to check it 585AC_SUBST(CONFIGURE_MACOSX_DEPLOYMENT_TARGET) 586AC_SUBST(EXPORT_MACOSX_DEPLOYMENT_TARGET) 587CONFIGURE_MACOSX_DEPLOYMENT_TARGET= 588EXPORT_MACOSX_DEPLOYMENT_TARGET='#' 589 590# checks for alternative programs 591 592# compiler flags are generated in two sets, BASECFLAGS and OPT. OPT is just 593# for debug/optimization stuff. BASECFLAGS is for flags that are required 594# just to get things to compile and link. Users are free to override OPT 595# when running configure or make. The build should not break if they do. 596# BASECFLAGS should generally not be messed with, however. 597 598# If the user switches compilers, we can't believe the cache 599if test ! -z "$ac_cv_prog_CC" -a ! -z "$CC" -a "$CC" != "$ac_cv_prog_CC" 600then 601 AC_MSG_ERROR([cached CC is different -- throw away $cache_file 602(it is also a good idea to do 'make clean' before compiling)]) 603fi 604 605# Don't let AC_PROG_CC set the default CFLAGS. It normally sets -g -O2 606# when the compiler supports them, but we don't always want -O2, and 607# we set -g later. 608if test -z "$CFLAGS"; then 609 CFLAGS= 610fi 611 612if test "$ac_sys_system" = "Darwin" 613then 614 # Compiler selection on MacOSX is more complicated than 615 # AC_PROG_CC can handle, see Mac/README for more 616 # information 617 if test -z "${CC}" 618 then 619 found_gcc= 620 found_clang= 621 as_save_IFS=$IFS; IFS=: 622 for as_dir in $PATH 623 do 624 IFS=$as_save_IFS 625 if test -x "${as_dir}/gcc"; then 626 if test -z "${found_gcc}"; then 627 found_gcc="${as_dir}/gcc" 628 fi 629 fi 630 if test -x "${as_dir}/clang"; then 631 if test -z "${found_clang}"; then 632 found_clang="${as_dir}/clang" 633 fi 634 fi 635 done 636 IFS=$as_save_IFS 637 638 if test -n "$found_gcc" -a -n "$found_clang" 639 then 640 if test -n "`"$found_gcc" --version | grep llvm-gcc`" 641 then 642 AC_MSG_NOTICE([Detected llvm-gcc, falling back to clang]) 643 CC="$found_clang" 644 CXX="$found_clang++" 645 fi 646 647 648 elif test -z "$found_gcc" -a -n "$found_clang" 649 then 650 AC_MSG_NOTICE([No GCC found, use CLANG]) 651 CC="$found_clang" 652 CXX="$found_clang++" 653 654 elif test -z "$found_gcc" -a -z "$found_clang" 655 then 656 found_clang=`/usr/bin/xcrun -find clang 2>/dev/null` 657 if test -n "${found_clang}" 658 then 659 AC_MSG_NOTICE([Using clang from Xcode.app]) 660 CC="${found_clang}" 661 CXX="`/usr/bin/xcrun -find clang++`" 662 663 # else: use default behaviour 664 fi 665 fi 666 fi 667fi 668AC_PROG_CC 669AC_PROG_CPP 670AC_PROG_GREP 671AC_PROG_SED 672 673AC_SUBST(CXX) 674AC_SUBST(MAINCC) 675AC_MSG_CHECKING(for --with-cxx-main=<compiler>) 676AC_ARG_WITH(cxx_main, 677 AS_HELP_STRING([--with-cxx-main@<:@=COMPILER@:>@], 678 [compile main() and link Python executable with C++ compiler specified in COMPILER (default is $CXX)]), 679[ 680 681 case $withval in 682 no) with_cxx_main=no 683 MAINCC='$(CC)';; 684 yes) with_cxx_main=yes 685 MAINCC='$(CXX)';; 686 *) with_cxx_main=yes 687 MAINCC=$withval 688 if test -z "$CXX" 689 then 690 CXX=$withval 691 fi;; 692 esac], [ 693 with_cxx_main=no 694 MAINCC='$(CC)' 695]) 696AC_MSG_RESULT($with_cxx_main) 697 698preset_cxx="$CXX" 699if test -z "$CXX" 700then 701 case "$CC" in 702 gcc) AC_PATH_TOOL(CXX, [g++], [g++], [notfound]) ;; 703 cc) AC_PATH_TOOL(CXX, [c++], [c++], [notfound]) ;; 704 clang|*/clang) AC_PATH_TOOL(CXX, [clang++], [clang++], [notfound]) ;; 705 icc|*/icc) AC_PATH_TOOL(CXX, [icpc], [icpc], [notfound]) ;; 706 esac 707 if test "$CXX" = "notfound" 708 then 709 CXX="" 710 fi 711fi 712if test -z "$CXX" 713then 714 AC_CHECK_TOOLS(CXX, $CCC c++ g++ gcc CC cxx cc++ cl, notfound) 715 if test "$CXX" = "notfound" 716 then 717 CXX="" 718 fi 719fi 720if test "$preset_cxx" != "$CXX" 721then 722 AC_MSG_NOTICE([ 723 724 By default, distutils will build C++ extension modules with "$CXX". 725 If this is not intended, then set CXX on the configure command line. 726 ]) 727fi 728 729 730AC_MSG_CHECKING([for the platform triplet based on compiler characteristics]) 731cat >> conftest.c <<EOF 732#undef bfin 733#undef cris 734#undef fr30 735#undef linux 736#undef hppa 737#undef hpux 738#undef i386 739#undef mips 740#undef powerpc 741#undef sparc 742#undef unix 743#if defined(__ANDROID__) 744 # Android is not a multiarch system. 745#elif defined(__linux__) 746# if defined(__x86_64__) && defined(__LP64__) 747 x86_64-linux-gnu 748# elif defined(__x86_64__) && defined(__ILP32__) 749 x86_64-linux-gnux32 750# elif defined(__i386__) 751 i386-linux-gnu 752# elif defined(__aarch64__) && defined(__AARCH64EL__) 753# if defined(__ILP32__) 754 aarch64_ilp32-linux-gnu 755# else 756 aarch64-linux-gnu 757# endif 758# elif defined(__aarch64__) && defined(__AARCH64EB__) 759# if defined(__ILP32__) 760 aarch64_be_ilp32-linux-gnu 761# else 762 aarch64_be-linux-gnu 763# endif 764# elif defined(__alpha__) 765 alpha-linux-gnu 766# elif defined(__ARM_EABI__) && defined(__ARM_PCS_VFP) 767# if defined(__ARMEL__) 768 arm-linux-gnueabihf 769# else 770 armeb-linux-gnueabihf 771# endif 772# elif defined(__ARM_EABI__) && !defined(__ARM_PCS_VFP) 773# if defined(__ARMEL__) 774 arm-linux-gnueabi 775# else 776 armeb-linux-gnueabi 777# endif 778# elif defined(__hppa__) 779 hppa-linux-gnu 780# elif defined(__ia64__) 781 ia64-linux-gnu 782# elif defined(__m68k__) && !defined(__mcoldfire__) 783 m68k-linux-gnu 784# elif defined(__mips_hard_float) && defined(__mips_isa_rev) && (__mips_isa_rev >=6) && defined(_MIPSEL) 785# if _MIPS_SIM == _ABIO32 786 mipsisa32r6el-linux-gnu 787# elif _MIPS_SIM == _ABIN32 788 mipsisa64r6el-linux-gnuabin32 789# elif _MIPS_SIM == _ABI64 790 mipsisa64r6el-linux-gnuabi64 791# else 792# error unknown platform triplet 793# endif 794# elif defined(__mips_hard_float) && defined(__mips_isa_rev) && (__mips_isa_rev >=6) 795# if _MIPS_SIM == _ABIO32 796 mipsisa32r6-linux-gnu 797# elif _MIPS_SIM == _ABIN32 798 mipsisa64r6-linux-gnuabin32 799# elif _MIPS_SIM == _ABI64 800 mipsisa64r6-linux-gnuabi64 801# else 802# error unknown platform triplet 803# endif 804# elif defined(__mips_hard_float) && defined(_MIPSEL) 805# if _MIPS_SIM == _ABIO32 806 mipsel-linux-gnu 807# elif _MIPS_SIM == _ABIN32 808 mips64el-linux-gnuabin32 809# elif _MIPS_SIM == _ABI64 810 mips64el-linux-gnuabi64 811# else 812# error unknown platform triplet 813# endif 814# elif defined(__mips_hard_float) 815# if _MIPS_SIM == _ABIO32 816 mips-linux-gnu 817# elif _MIPS_SIM == _ABIN32 818 mips64-linux-gnuabin32 819# elif _MIPS_SIM == _ABI64 820 mips64-linux-gnuabi64 821# else 822# error unknown platform triplet 823# endif 824# elif defined(__or1k__) 825 or1k-linux-gnu 826# elif defined(__powerpc__) && defined(__SPE__) 827 powerpc-linux-gnuspe 828# elif defined(__powerpc64__) 829# if defined(__LITTLE_ENDIAN__) 830 powerpc64le-linux-gnu 831# else 832 powerpc64-linux-gnu 833# endif 834# elif defined(__powerpc__) 835 powerpc-linux-gnu 836# elif defined(__s390x__) 837 s390x-linux-gnu 838# elif defined(__s390__) 839 s390-linux-gnu 840# elif defined(__sh__) && defined(__LITTLE_ENDIAN__) 841 sh4-linux-gnu 842# elif defined(__sparc__) && defined(__arch64__) 843 sparc64-linux-gnu 844# elif defined(__sparc__) 845 sparc-linux-gnu 846# elif defined(__riscv) 847# if __riscv_xlen == 32 848 riscv32-linux-gnu 849# elif __riscv_xlen == 64 850 riscv64-linux-gnu 851# else 852# error unknown platform triplet 853# endif 854# else 855# error unknown platform triplet 856# endif 857#elif defined(__FreeBSD_kernel__) 858# if defined(__LP64__) 859 x86_64-kfreebsd-gnu 860# elif defined(__i386__) 861 i386-kfreebsd-gnu 862# else 863# error unknown platform triplet 864# endif 865#elif defined(__gnu_hurd__) 866 i386-gnu 867#elif defined(__APPLE__) 868 darwin 869#elif defined(__VXWORKS__) 870 vxworks 871#else 872# error unknown platform triplet 873#endif 874 875EOF 876 877if $CPP $CPPFLAGS conftest.c >conftest.out 2>/dev/null; then 878 PLATFORM_TRIPLET=`grep -v '^#' conftest.out | grep -v '^ *$' | tr -d ' '` 879 AC_MSG_RESULT([$PLATFORM_TRIPLET]) 880else 881 AC_MSG_RESULT([none]) 882fi 883rm -f conftest.c conftest.out 884 885if test x$PLATFORM_TRIPLET != xdarwin; then 886 MULTIARCH=$($CC --print-multiarch 2>/dev/null) 887fi 888AC_SUBST(MULTIARCH) 889 890if test x$PLATFORM_TRIPLET != x && test x$MULTIARCH != x; then 891 if test x$PLATFORM_TRIPLET != x$MULTIARCH; then 892 AC_MSG_ERROR([internal configure error for the platform triplet, please file a bug report]) 893 fi 894elif test x$PLATFORM_TRIPLET != x && test x$MULTIARCH = x; then 895 MULTIARCH=$PLATFORM_TRIPLET 896fi 897AC_SUBST(PLATFORM_TRIPLET) 898if test x$MULTIARCH != x; then 899 MULTIARCH_CPPFLAGS="-DMULTIARCH=\\\"$MULTIARCH\\\"" 900fi 901AC_SUBST(MULTIARCH_CPPFLAGS) 902 903AC_MSG_CHECKING([for -Wl,--no-as-needed]) 904save_LDFLAGS="$LDFLAGS" 905LDFLAGS="$LDFLAGS -Wl,--no-as-needed" 906AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[]])], 907 [NO_AS_NEEDED="-Wl,--no-as-needed" 908 AC_MSG_RESULT([yes])], 909 [NO_AS_NEEDED="" 910 AC_MSG_RESULT([no])]) 911LDFLAGS="$save_LDFLAGS" 912AC_SUBST(NO_AS_NEEDED) 913 914 915# checks for UNIX variants that set C preprocessor variables 916AC_USE_SYSTEM_EXTENSIONS 917 918AC_MSG_CHECKING([for the Android API level]) 919cat >> conftest.c <<EOF 920#ifdef __ANDROID__ 921android_api = __ANDROID_API__ 922arm_arch = __ARM_ARCH 923#else 924#error not Android 925#endif 926EOF 927 928if $CPP $CPPFLAGS conftest.c >conftest.out 2>/dev/null; then 929 ANDROID_API_LEVEL=`sed -n -e '/__ANDROID_API__/d' -e 's/^android_api = //p' conftest.out` 930 _arm_arch=`sed -n -e '/__ARM_ARCH/d' -e 's/^arm_arch = //p' conftest.out` 931 AC_MSG_RESULT([$ANDROID_API_LEVEL]) 932 if test -z "$ANDROID_API_LEVEL"; then 933 echo 'Fatal: you must define __ANDROID_API__' 934 exit 1 935 fi 936 AC_DEFINE_UNQUOTED(ANDROID_API_LEVEL, $ANDROID_API_LEVEL, [The Android API level.]) 937 938 AC_MSG_CHECKING([for the Android arm ABI]) 939 AC_MSG_RESULT([$_arm_arch]) 940 if test "$_arm_arch" = 7; then 941 BASECFLAGS="${BASECFLAGS} -mfloat-abi=softfp -mfpu=vfpv3-d16" 942 LDFLAGS="${LDFLAGS} -march=armv7-a -Wl,--fix-cortex-a8" 943 fi 944else 945 AC_MSG_RESULT([not Android]) 946fi 947rm -f conftest.c conftest.out 948 949# Check for unsupported systems 950case $ac_sys_system/$ac_sys_release in 951atheos*|Linux*/1*) 952 echo This system \($ac_sys_system/$ac_sys_release\) is no longer supported. 953 echo See README for details. 954 exit 1;; 955esac 956 957AC_EXEEXT 958AC_MSG_CHECKING(for --with-suffix) 959AC_ARG_WITH(suffix, 960 AS_HELP_STRING([--with-suffix=SUFFIX], [set executable suffix to SUFFIX (default is '.exe')]), 961[ 962 case $withval in 963 no) EXEEXT=;; 964 yes) EXEEXT=.exe;; 965 *) EXEEXT=$withval;; 966 esac]) 967AC_MSG_RESULT($EXEEXT) 968 969# Test whether we're running on a non-case-sensitive system, in which 970# case we give a warning if no ext is given 971AC_SUBST(BUILDEXEEXT) 972AC_MSG_CHECKING(for case-insensitive build directory) 973if test ! -d CaseSensitiveTestDir; then 974mkdir CaseSensitiveTestDir 975fi 976 977if test -d casesensitivetestdir 978then 979 AC_MSG_RESULT(yes) 980 BUILDEXEEXT=.exe 981else 982 AC_MSG_RESULT(no) 983 BUILDEXEEXT=$EXEEXT 984fi 985rmdir CaseSensitiveTestDir 986 987case $ac_sys_system in 988hp*|HP*) 989 case $CC in 990 cc|*/cc) CC="$CC -Ae";; 991 esac;; 992esac 993 994AC_SUBST(LIBRARY) 995AC_MSG_CHECKING(LIBRARY) 996if test -z "$LIBRARY" 997then 998 LIBRARY='libpython$(VERSION)$(ABIFLAGS).a' 999fi 1000AC_MSG_RESULT($LIBRARY) 1001 1002# LDLIBRARY is the name of the library to link against (as opposed to the 1003# name of the library into which to insert object files). BLDLIBRARY is also 1004# the library to link against, usually. On Mac OS X frameworks, BLDLIBRARY 1005# is blank as the main program is not linked directly against LDLIBRARY. 1006# LDLIBRARYDIR is the path to LDLIBRARY, which is made in a subdirectory. On 1007# systems without shared libraries, LDLIBRARY is the same as LIBRARY 1008# (defined in the Makefiles). On Cygwin LDLIBRARY is the import library, 1009# DLLLIBRARY is the shared (i.e., DLL) library. 1010# 1011# RUNSHARED is used to run shared python without installed libraries 1012# 1013# INSTSONAME is the name of the shared library that will be use to install 1014# on the system - some systems like version suffix, others don't 1015# 1016# LDVERSION is the shared library version number, normally the Python version 1017# with the ABI build flags appended. 1018AC_SUBST(LDLIBRARY) 1019AC_SUBST(DLLLIBRARY) 1020AC_SUBST(BLDLIBRARY) 1021AC_SUBST(PY3LIBRARY) 1022AC_SUBST(LDLIBRARYDIR) 1023AC_SUBST(INSTSONAME) 1024AC_SUBST(RUNSHARED) 1025AC_SUBST(LDVERSION) 1026LDLIBRARY="$LIBRARY" 1027BLDLIBRARY='$(LDLIBRARY)' 1028INSTSONAME='$(LDLIBRARY)' 1029DLLLIBRARY='' 1030LDLIBRARYDIR='' 1031RUNSHARED='' 1032LDVERSION="$VERSION" 1033 1034# LINKCC is the command that links the python executable -- default is $(CC). 1035# If CXX is set, and if it is needed to link a main function that was 1036# compiled with CXX, LINKCC is CXX instead. Always using CXX is undesirable: 1037# python might then depend on the C++ runtime 1038AC_SUBST(LINKCC) 1039AC_MSG_CHECKING(LINKCC) 1040if test -z "$LINKCC" 1041then 1042 LINKCC='$(PURIFY) $(MAINCC)' 1043 case $ac_sys_system in 1044 QNX*) 1045 # qcc must be used because the other compilers do not 1046 # support -N. 1047 LINKCC=qcc;; 1048 esac 1049fi 1050AC_MSG_RESULT($LINKCC) 1051 1052# EXPORTSYMS holds the list of exported symbols for AIX. 1053# EXPORTSFROM holds the module name exporting symbols on AIX. 1054EXPORTSYMS= 1055EXPORTSFROM= 1056AC_SUBST(EXPORTSYMS) 1057AC_SUBST(EXPORTSFROM) 1058AC_MSG_CHECKING(EXPORTSYMS) 1059case $ac_sys_system in 1060AIX*) 1061 EXPORTSYMS="Modules/python.exp" 1062 if test $ac_sys_release -ge 5 -o \ 1063 $ac_sys_release -eq 4 -a `uname -r` -ge 2 ; then 1064 EXPORTSFROM=. # the main executable 1065 fi 1066 ;; 1067esac 1068AC_MSG_RESULT($EXPORTSYMS) 1069 1070# GNULD is set to "yes" if the GNU linker is used. If this goes wrong 1071# make sure we default having it set to "no": this is used by 1072# distutils.unixccompiler to know if it should add --enable-new-dtags 1073# to linker command lines, and failing to detect GNU ld simply results 1074# in the same bahaviour as before. 1075AC_SUBST(GNULD) 1076AC_MSG_CHECKING(for GNU ld) 1077ac_prog=ld 1078if test "$GCC" = yes; then 1079 ac_prog=`$CC -print-prog-name=ld` 1080fi 1081case `"$ac_prog" -V 2>&1 < /dev/null` in 1082 *GNU*) 1083 GNULD=yes;; 1084 *) 1085 GNULD=no;; 1086esac 1087AC_MSG_RESULT($GNULD) 1088 1089AC_MSG_CHECKING(for --enable-shared) 1090AC_ARG_ENABLE(shared, 1091 AS_HELP_STRING([--enable-shared], [enable building a shared Python library (default is no)])) 1092 1093if test -z "$enable_shared" 1094then 1095 case $ac_sys_system in 1096 CYGWIN*) 1097 enable_shared="yes";; 1098 *) 1099 enable_shared="no";; 1100 esac 1101fi 1102AC_MSG_RESULT($enable_shared) 1103 1104AC_MSG_CHECKING(for --enable-profiling) 1105AC_ARG_ENABLE(profiling, 1106 AS_HELP_STRING([--enable-profiling], [enable C-level code profiling with gprof (default is no)])) 1107if test "x$enable_profiling" = xyes; then 1108 ac_save_cc="$CC" 1109 CC="$CC -pg" 1110 AC_LINK_IFELSE([AC_LANG_SOURCE([[int main() { return 0; }]])], 1111 [], 1112 [enable_profiling=no]) 1113 CC="$ac_save_cc" 1114else 1115 enable_profiling=no 1116fi 1117AC_MSG_RESULT($enable_profiling) 1118 1119if test "x$enable_profiling" = xyes; then 1120 BASECFLAGS="-pg $BASECFLAGS" 1121 LDFLAGS="-pg $LDFLAGS" 1122fi 1123 1124AC_MSG_CHECKING(LDLIBRARY) 1125 1126# MacOSX framework builds need more magic. LDLIBRARY is the dynamic 1127# library that we build, but we do not want to link against it (we 1128# will find it with a -framework option). For this reason there is an 1129# extra variable BLDLIBRARY against which Python and the extension 1130# modules are linked, BLDLIBRARY. This is normally the same as 1131# LDLIBRARY, but empty for MacOSX framework builds. 1132if test "$enable_framework" 1133then 1134 LDLIBRARY='$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)' 1135 RUNSHARED=DYLD_FRAMEWORK_PATH=`pwd`${DYLD_FRAMEWORK_PATH:+:${DYLD_FRAMEWORK_PATH}} 1136 BLDLIBRARY='' 1137else 1138 BLDLIBRARY='$(LDLIBRARY)' 1139fi 1140 1141# Other platforms follow 1142if test $enable_shared = "yes"; then 1143 PY_ENABLE_SHARED=1 1144 AC_DEFINE(Py_ENABLE_SHARED, 1, [Defined if Python is built as a shared library.]) 1145 case $ac_sys_system in 1146 CYGWIN*) 1147 LDLIBRARY='libpython$(LDVERSION).dll.a' 1148 DLLLIBRARY='libpython$(LDVERSION).dll' 1149 ;; 1150 SunOS*) 1151 LDLIBRARY='libpython$(LDVERSION).so' 1152 BLDLIBRARY='-Wl,-R,$(LIBDIR) -L. -lpython$(LDVERSION)' 1153 RUNSHARED=LD_LIBRARY_PATH=`pwd`${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}} 1154 INSTSONAME="$LDLIBRARY".$SOVERSION 1155 if test "$with_pydebug" != yes 1156 then 1157 PY3LIBRARY=libpython3.so 1158 fi 1159 ;; 1160 Linux*|GNU*|NetBSD*|FreeBSD*|DragonFly*|OpenBSD*) 1161 LDLIBRARY='libpython$(LDVERSION).so' 1162 BLDLIBRARY='-L. -lpython$(LDVERSION)' 1163 RUNSHARED=LD_LIBRARY_PATH=`pwd`${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}} 1164 INSTSONAME="$LDLIBRARY".$SOVERSION 1165 if test "$with_pydebug" != yes 1166 then 1167 PY3LIBRARY=libpython3.so 1168 fi 1169 ;; 1170 hp*|HP*) 1171 case `uname -m` in 1172 ia64) 1173 LDLIBRARY='libpython$(LDVERSION).so' 1174 ;; 1175 *) 1176 LDLIBRARY='libpython$(LDVERSION).sl' 1177 ;; 1178 esac 1179 BLDLIBRARY='-Wl,+b,$(LIBDIR) -L. -lpython$(LDVERSION)' 1180 RUNSHARED=SHLIB_PATH=`pwd`${SHLIB_PATH:+:${SHLIB_PATH}} 1181 ;; 1182 Darwin*) 1183 LDLIBRARY='libpython$(LDVERSION).dylib' 1184 BLDLIBRARY='-L. -lpython$(LDVERSION)' 1185 RUNSHARED=DYLD_LIBRARY_PATH=`pwd`${DYLD_LIBRARY_PATH:+:${DYLD_LIBRARY_PATH}} 1186 ;; 1187 AIX*) 1188 LDLIBRARY='libpython$(LDVERSION).so' 1189 RUNSHARED=LIBPATH=`pwd`${LIBPATH:+:${LIBPATH}} 1190 ;; 1191 1192 esac 1193else # shared is disabled 1194 PY_ENABLE_SHARED=0 1195 case $ac_sys_system in 1196 CYGWIN*) 1197 BLDLIBRARY='$(LIBRARY)' 1198 LDLIBRARY='libpython$(LDVERSION).dll.a' 1199 ;; 1200 esac 1201fi 1202 1203if test "$cross_compiling" = yes; then 1204 RUNSHARED= 1205fi 1206 1207AC_MSG_RESULT($LDLIBRARY) 1208 1209AC_SUBST(AR) 1210AC_CHECK_TOOLS(AR, ar aal, ar) 1211 1212# tweak ARFLAGS only if the user didn't set it on the command line 1213AC_SUBST(ARFLAGS) 1214if test -z "$ARFLAGS" 1215then 1216 ARFLAGS="rcs" 1217fi 1218 1219AC_CHECK_TOOLS([READELF], [readelf], [:]) 1220if test "$cross_compiling" = yes; then 1221 case "$READELF" in 1222 readelf|:) 1223 AC_MSG_ERROR([readelf for the host is required for cross builds]) 1224 ;; 1225 esac 1226fi 1227AC_SUBST(READELF) 1228 1229 1230case $MACHDEP in 1231hp*|HP*) 1232 # install -d does not work on HP-UX 1233 if test -z "$INSTALL" 1234 then 1235 INSTALL="${srcdir}/install-sh -c" 1236 fi 1237esac 1238AC_PROG_INSTALL 1239AC_PROG_MKDIR_P 1240 1241# Not every filesystem supports hard links 1242AC_SUBST(LN) 1243if test -z "$LN" ; then 1244 case $ac_sys_system in 1245 CYGWIN*) LN="ln -s";; 1246 *) LN=ln;; 1247 esac 1248fi 1249 1250# For calculating the .so ABI tag. 1251AC_SUBST(ABIFLAGS) 1252ABIFLAGS="" 1253 1254# Check for --with-pydebug 1255AC_MSG_CHECKING(for --with-pydebug) 1256AC_ARG_WITH(pydebug, 1257 AS_HELP_STRING([--with-pydebug], [build with Py_DEBUG defined (default is no)]), 1258[ 1259if test "$withval" != no 1260then 1261 AC_DEFINE(Py_DEBUG, 1, 1262 [Define if you want to build an interpreter with many run-time checks.]) 1263 AC_MSG_RESULT(yes); 1264 Py_DEBUG='true' 1265 ABIFLAGS="${ABIFLAGS}d" 1266else AC_MSG_RESULT(no); Py_DEBUG='false' 1267fi], 1268[AC_MSG_RESULT(no)]) 1269 1270# Check for --with-trace-refs 1271# --with-trace-refs 1272AC_MSG_CHECKING(for --with-trace-refs) 1273AC_ARG_WITH(trace-refs, 1274 AS_HELP_STRING( 1275 [--with-trace-refs], 1276 [enable tracing references for debugging purpose (default is no)]),, 1277 with_trace_refs=no) 1278AC_MSG_RESULT($with_trace_refs) 1279 1280if test "$with_trace_refs" = "yes" 1281then 1282 AC_DEFINE(Py_TRACE_REFS, 1, [Define if you want to enable tracing references for debugging purpose]) 1283fi 1284 1285# Check for --with-assertions. 1286# This allows enabling assertions without Py_DEBUG. 1287assertions='false' 1288AC_MSG_CHECKING(for --with-assertions) 1289AC_ARG_WITH(assertions, 1290 AS_HELP_STRING([--with-assertions],[build with C assertions enabled (default is no)]), 1291[ 1292if test "$withval" != no 1293then 1294 assertions='true' 1295fi], 1296[]) 1297if test "$assertions" = 'true'; then 1298 AC_MSG_RESULT(yes) 1299elif test "$Py_DEBUG" = 'true'; then 1300 assertions='true' 1301 AC_MSG_RESULT(implied by --with-pydebug) 1302else 1303 AC_MSG_RESULT(no) 1304fi 1305 1306# Enable optimization flags 1307AC_SUBST(DEF_MAKE_ALL_RULE) 1308AC_SUBST(DEF_MAKE_RULE) 1309Py_OPT='false' 1310AC_MSG_CHECKING(for --enable-optimizations) 1311AC_ARG_ENABLE(optimizations, AS_HELP_STRING( 1312 [--enable-optimizations], 1313 [enable expensive, stable optimizations (PGO, etc.) (default is no)]), 1314[ 1315if test "$enableval" != no 1316then 1317 Py_OPT='true' 1318 AC_MSG_RESULT(yes); 1319else 1320 Py_OPT='false' 1321 AC_MSG_RESULT(no); 1322fi], 1323[AC_MSG_RESULT(no)]) 1324if test "$Py_OPT" = 'true' ; then 1325 # Intentionally not forcing Py_LTO='true' here. Too many toolchains do not 1326 # compile working code using it and both test_distutils and test_gdb are 1327 # broken when you do manage to get a toolchain that works with it. People 1328 # who want LTO need to use --with-lto themselves. 1329 DEF_MAKE_ALL_RULE="profile-opt" 1330 REQUIRE_PGO="yes" 1331 DEF_MAKE_RULE="build_all" 1332else 1333 DEF_MAKE_ALL_RULE="build_all" 1334 REQUIRE_PGO="no" 1335 DEF_MAKE_RULE="all" 1336fi 1337 1338AC_ARG_VAR(PROFILE_TASK, Python args for PGO generation task) 1339AC_MSG_CHECKING(PROFILE_TASK) 1340if test -z "$PROFILE_TASK" 1341then 1342 PROFILE_TASK='-m test --pgo' 1343fi 1344AC_MSG_RESULT($PROFILE_TASK) 1345 1346# Make llvm-relatec checks work on systems where llvm tools are not installed with their 1347# normal names in the default $PATH (ie: Ubuntu). They exist under the 1348# non-suffixed name in their versioned llvm directory. 1349 1350llvm_bin_dir='' 1351llvm_path="${PATH}" 1352if test "${CC}" = "clang" 1353then 1354 clang_bin=`which clang` 1355 # Some systems install clang elsewhere as a symlink to the real path 1356 # which is where the related llvm tools are located. 1357 if test -L "${clang_bin}" 1358 then 1359 clang_dir=`dirname "${clang_bin}"` 1360 clang_bin=`readlink "${clang_bin}"` 1361 llvm_bin_dir="${clang_dir}/"`dirname "${clang_bin}"` 1362 llvm_path="${llvm_path}${PATH_SEPARATOR}${llvm_bin_dir}" 1363 fi 1364fi 1365 1366# Enable LTO flags 1367AC_MSG_CHECKING(for --with-lto) 1368AC_ARG_WITH(lto, AS_HELP_STRING([--with-lto], [enable Link-Time-Optimization in any build (default is no)]), 1369[ 1370if test "$withval" != no 1371then 1372 Py_LTO='true' 1373 AC_MSG_RESULT(yes); 1374else 1375 Py_LTO='false' 1376 AC_MSG_RESULT(no); 1377fi], 1378[AC_MSG_RESULT(no)]) 1379if test "$Py_LTO" = 'true' ; then 1380 case $CC in 1381 *clang*) 1382 AC_SUBST(LLVM_AR) 1383 AC_PATH_TOOL(LLVM_AR, llvm-ar, '', ${llvm_path}) 1384 AC_SUBST(LLVM_AR_FOUND) 1385 if test -n "${LLVM_AR}" -a -x "${LLVM_AR}" 1386 then 1387 LLVM_AR_FOUND="found" 1388 else 1389 LLVM_AR_FOUND="not-found" 1390 fi 1391 if test "$ac_sys_system" = "Darwin" -a "${LLVM_AR_FOUND}" = "not-found" 1392 then 1393 # The Apple-supplied ar in Xcode or the Command Line Tools is apparently sufficient 1394 found_llvm_ar=`/usr/bin/xcrun -find ar 2>/dev/null` 1395 if test -n "${found_llvm_ar}" 1396 then 1397 LLVM_AR='/usr/bin/xcrun ar' 1398 LLVM_AR_FOUND=found 1399 AC_MSG_NOTICE([llvm-ar found via xcrun: ${LLVM_AR}]) 1400 fi 1401 fi 1402 if test $LLVM_AR_FOUND = not-found 1403 then 1404 LLVM_PROFR_ERR=yes 1405 AC_MSG_ERROR([llvm-ar is required for a --with-lto build with clang but could not be found.]) 1406 else 1407 LLVM_AR_ERR=no 1408 fi 1409 AR="${LLVM_AR}" 1410 case $ac_sys_system in 1411 Darwin*) 1412 # Any changes made here should be reflected in the GCC+Darwin case below 1413 LTOFLAGS="-flto -Wl,-export_dynamic" 1414 LTOCFLAGS="-flto" 1415 ;; 1416 *) 1417 LTOFLAGS="-flto" 1418 ;; 1419 esac 1420 ;; 1421 *gcc*) 1422 case $ac_sys_system in 1423 Darwin*) 1424 LTOFLAGS="-flto -Wl,-export_dynamic" 1425 LTOCFLAGS="-flto" 1426 ;; 1427 *) 1428 LTOFLAGS="-flto -fuse-linker-plugin -ffat-lto-objects -flto-partition=none" 1429 ;; 1430 esac 1431 ;; 1432 esac 1433 1434 if test "$ac_cv_prog_cc_g" = "yes" 1435 then 1436 # bpo-30345: Add -g to LDFLAGS when compiling with LTO 1437 # to get debug symbols. 1438 LTOFLAGS="$LTOFLAGS -g" 1439 fi 1440 1441 CFLAGS_NODIST="$CFLAGS_NODIST ${LTOCFLAGS-$LTOFLAGS}" 1442 LDFLAGS_NODIST="$LDFLAGS_NODIST $LTOFLAGS" 1443fi 1444 1445# Enable PGO flags. 1446AC_SUBST(PGO_PROF_GEN_FLAG) 1447AC_SUBST(PGO_PROF_USE_FLAG) 1448AC_SUBST(LLVM_PROF_MERGER) 1449AC_SUBST(LLVM_PROF_FILE) 1450AC_SUBST(LLVM_PROF_ERR) 1451AC_SUBST(LLVM_PROFDATA) 1452AC_PATH_TOOL(LLVM_PROFDATA, llvm-profdata, '', ${llvm_path}) 1453AC_SUBST(LLVM_PROF_FOUND) 1454if test -n "${LLVM_PROFDATA}" -a -x "${LLVM_PROFDATA}" 1455then 1456 LLVM_PROF_FOUND="found" 1457else 1458 LLVM_PROF_FOUND="not-found" 1459fi 1460if test "$ac_sys_system" = "Darwin" -a "${LLVM_PROF_FOUND}" = "not-found" 1461then 1462 found_llvm_profdata=`/usr/bin/xcrun -find llvm-profdata 2>/dev/null` 1463 if test -n "${found_llvm_profdata}" 1464 then 1465 # llvm-profdata isn't directly in $PATH in some cases. 1466 # https://apple.stackexchange.com/questions/197053/ 1467 LLVM_PROFDATA='/usr/bin/xcrun llvm-profdata' 1468 LLVM_PROF_FOUND=found 1469 AC_MSG_NOTICE([llvm-profdata found via xcrun: ${LLVM_PROFDATA}]) 1470 fi 1471fi 1472LLVM_PROF_ERR=no 1473case $CC in 1474 *clang*) 1475 # Any changes made here should be reflected in the GCC+Darwin case below 1476 PGO_PROF_GEN_FLAG="-fprofile-instr-generate" 1477 PGO_PROF_USE_FLAG="-fprofile-instr-use=code.profclangd" 1478 LLVM_PROF_MERGER="${LLVM_PROFDATA} merge -output=code.profclangd *.profclangr" 1479 LLVM_PROF_FILE="LLVM_PROFILE_FILE=\"code-%p.profclangr\"" 1480 if test $LLVM_PROF_FOUND = not-found 1481 then 1482 LLVM_PROF_ERR=yes 1483 if test "${REQUIRE_PGO}" = "yes" 1484 then 1485 AC_MSG_ERROR([llvm-profdata is required for a --enable-optimizations build but could not be found.]) 1486 fi 1487 fi 1488 ;; 1489 *gcc*) 1490 case $ac_sys_system in 1491 Darwin*) 1492 PGO_PROF_GEN_FLAG="-fprofile-instr-generate" 1493 PGO_PROF_USE_FLAG="-fprofile-instr-use=code.profclangd" 1494 LLVM_PROF_MERGER="${LLVM_PROFDATA} merge -output=code.profclangd *.profclangr" 1495 LLVM_PROF_FILE="LLVM_PROFILE_FILE=\"code-%p.profclangr\"" 1496 if test "${LLVM_PROF_FOUND}" = "not-found" 1497 then 1498 LLVM_PROF_ERR=yes 1499 if test "${REQUIRE_PGO}" = "yes" 1500 then 1501 AC_MSG_ERROR([llvm-profdata is required for a --enable-optimizations build but could not be found.]) 1502 fi 1503 fi 1504 ;; 1505 *) 1506 PGO_PROF_GEN_FLAG="-fprofile-generate" 1507 PGO_PROF_USE_FLAG="-fprofile-use -fprofile-correction" 1508 LLVM_PROF_MERGER="true" 1509 LLVM_PROF_FILE="" 1510 ;; 1511 esac 1512 ;; 1513 *icc*) 1514 PGO_PROF_GEN_FLAG="-prof-gen" 1515 PGO_PROF_USE_FLAG="-prof-use" 1516 LLVM_PROF_MERGER="true" 1517 LLVM_PROF_FILE="" 1518 ;; 1519esac 1520 1521# XXX Shouldn't the code above that fiddles with BASECFLAGS and OPT be 1522# merged with this chunk of code? 1523 1524# Optimizer/debugger flags 1525# ------------------------ 1526# (The following bit of code is complicated enough - please keep things 1527# indented properly. Just pretend you're editing Python code. ;-) 1528 1529# There are two parallel sets of case statements below, one that checks to 1530# see if OPT was set and one that does BASECFLAGS setting based upon 1531# compiler and platform. BASECFLAGS tweaks need to be made even if the 1532# user set OPT. 1533 1534case $CC in 1535 *clang*) 1536 cc_is_clang=1 1537 ;; 1538 *) 1539 if $CC --version 2>&1 | grep -q clang 1540 then 1541 cc_is_clang=1 1542 else 1543 cc_is_clang= 1544 fi 1545esac 1546 1547# tweak OPT based on compiler and platform, only if the user didn't set 1548# it on the command line 1549AC_SUBST(OPT) 1550AC_SUBST(CFLAGS_ALIASING) 1551if test "${OPT-unset}" = "unset" 1552then 1553 case $GCC in 1554 yes) 1555 # For gcc 4.x we need to use -fwrapv so lets check if its supported 1556 if "$CC" -v --help 2>/dev/null |grep -- -fwrapv > /dev/null; then 1557 WRAP="-fwrapv" 1558 fi 1559 1560 if test -n "${cc_is_clang}" 1561 then 1562 # Clang also needs -fwrapv 1563 WRAP="-fwrapv" 1564 # bpo-30104: disable strict aliasing to compile correctly dtoa.c, 1565 # see Makefile.pre.in for more information 1566 CFLAGS_ALIASING="-fno-strict-aliasing" 1567 fi 1568 1569 case $ac_cv_prog_cc_g in 1570 yes) 1571 if test "$Py_DEBUG" = 'true' ; then 1572 # Optimization messes up debuggers, so turn it off for 1573 # debug builds. 1574 if "$CC" -v --help 2>/dev/null |grep -- -Og > /dev/null; then 1575 OPT="-g -Og -Wall" 1576 else 1577 OPT="-g -O0 -Wall" 1578 fi 1579 else 1580 OPT="-g $WRAP -O3 -Wall" 1581 fi 1582 ;; 1583 *) 1584 OPT="-O3 -Wall" 1585 ;; 1586 esac 1587 1588 case $ac_sys_system in 1589 SCO_SV*) OPT="$OPT -m486 -DSCO5" 1590 ;; 1591 esac 1592 ;; 1593 1594 *) 1595 OPT="-O" 1596 ;; 1597 esac 1598fi 1599 1600AC_SUBST(BASECFLAGS) 1601AC_SUBST(CFLAGS_NODIST) 1602AC_SUBST(LDFLAGS_NODIST) 1603 1604# The -arch flags for universal builds on macOS 1605UNIVERSAL_ARCH_FLAGS= 1606AC_SUBST(UNIVERSAL_ARCH_FLAGS) 1607 1608# tweak BASECFLAGS based on compiler and platform 1609case $GCC in 1610yes) 1611 CFLAGS_NODIST="$CFLAGS_NODIST -std=c99" 1612 1613 AC_MSG_CHECKING(for -Wextra) 1614 ac_save_cc="$CC" 1615 CC="$CC -Wextra -Werror" 1616 AC_CACHE_VAL(ac_cv_extra_warnings, 1617 AC_COMPILE_IFELSE( 1618 [ 1619 AC_LANG_PROGRAM([[]], [[]]) 1620 ],[ 1621 ac_cv_extra_warnings=yes 1622 ],[ 1623 ac_cv_extra_warnings=no 1624 ])) 1625 CC="$ac_save_cc" 1626 AC_MSG_RESULT($ac_cv_extra_warnings) 1627 1628 if test $ac_cv_extra_warnings = yes 1629 then 1630 CFLAGS_NODIST="$CFLAGS_NODIST -Wextra" 1631 fi 1632 1633 # Python doesn't violate C99 aliasing rules, but older versions of 1634 # GCC produce warnings for legal Python code. Enable 1635 # -fno-strict-aliasing on versions of GCC that support but produce 1636 # warnings. See Issue3326 1637 AC_MSG_CHECKING(whether $CC accepts and needs -fno-strict-aliasing) 1638 ac_save_cc="$CC" 1639 CC="$CC -fno-strict-aliasing" 1640 save_CFLAGS="$CFLAGS" 1641 AC_CACHE_VAL(ac_cv_no_strict_aliasing, 1642 AC_COMPILE_IFELSE( 1643 [ 1644 AC_LANG_PROGRAM([[]], [[]]) 1645 ],[ 1646 CC="$ac_save_cc -fstrict-aliasing" 1647 CFLAGS="$CFLAGS -Werror -Wstrict-aliasing" 1648 AC_COMPILE_IFELSE( 1649 [ 1650 AC_LANG_PROGRAM([[void f(int **x) {}]], 1651 [[double *x; f((int **) &x);]]) 1652 ],[ 1653 ac_cv_no_strict_aliasing=no 1654 ],[ 1655 ac_cv_no_strict_aliasing=yes 1656 ]) 1657 ],[ 1658 ac_cv_no_strict_aliasing=no 1659 ])) 1660 CFLAGS="$save_CFLAGS" 1661 CC="$ac_save_cc" 1662 AC_MSG_RESULT($ac_cv_no_strict_aliasing) 1663 if test $ac_cv_no_strict_aliasing = yes 1664 then 1665 BASECFLAGS="$BASECFLAGS -fno-strict-aliasing" 1666 fi 1667 1668 # ICC doesn't recognize the option, but only emits a warning 1669 ## XXX does it emit an unused result warning and can it be disabled? 1670 case "$CC" in 1671 *icc*) 1672 ac_cv_disable_unused_result_warning=no 1673 ;; 1674 *) 1675 AC_MSG_CHECKING(if we can turn off $CC unused result warning) 1676 ac_save_cc="$CC" 1677 CC="$CC -Wunused-result -Werror" 1678 save_CFLAGS="$CFLAGS" 1679 AC_CACHE_VAL(ac_cv_disable_unused_result_warning, 1680 AC_COMPILE_IFELSE( 1681 [ 1682 AC_LANG_PROGRAM([[]], [[]]) 1683 ],[ 1684 ac_cv_disable_unused_result_warning=yes 1685 ],[ 1686 ac_cv_disable_unused_result_warning=no 1687 ])) 1688 CFLAGS="$save_CFLAGS" 1689 CC="$ac_save_cc" 1690 AC_MSG_RESULT($ac_cv_disable_unused_result_warning) 1691 ;; 1692 esac 1693 1694 if test $ac_cv_disable_unused_result_warning = yes 1695 then 1696 BASECFLAGS="$BASECFLAGS -Wno-unused-result" 1697 CFLAGS_NODIST="$CFLAGS_NODIST -Wno-unused-result" 1698 fi 1699 1700 AC_MSG_CHECKING(if we can turn off $CC unused parameter warning) 1701 ac_save_cc="$CC" 1702 CC="$CC -Wunused-parameter -Werror" 1703 AC_CACHE_VAL(ac_cv_disable_unused_parameter_warning, 1704 AC_COMPILE_IFELSE( 1705 [ 1706 AC_LANG_PROGRAM([[]], [[]]) 1707 ],[ 1708 ac_cv_disable_unused_parameter_warning=yes 1709 ],[ 1710 ac_cv_disable_unused_parameter_warning=no 1711 ])) 1712 CC="$ac_save_cc" 1713 AC_MSG_RESULT($ac_cv_disable_unused_parameter_warning) 1714 1715 if test $ac_cv_disable_unused_parameter_warning = yes 1716 then 1717 CFLAGS_NODIST="$CFLAGS_NODIST -Wno-unused-parameter" 1718 fi 1719 1720 AC_MSG_CHECKING(if we can turn off $CC missing field initializers warning) 1721 ac_save_cc="$CC" 1722 CC="$CC -Wmissing-field-initializers -Werror" 1723 AC_CACHE_VAL(ac_cv_disable_missing_field_initializers, 1724 AC_COMPILE_IFELSE( 1725 [ 1726 AC_LANG_PROGRAM([[]], [[]]) 1727 ],[ 1728 ac_cv_disable_missing_field_initializers=yes 1729 ],[ 1730 ac_cv_disable_missing_field_initializers=no 1731 ])) 1732 CC="$ac_save_cc" 1733 AC_MSG_RESULT($ac_cv_disable_missing_field_initializers) 1734 1735 if test $ac_cv_disable_missing_field_initializers = yes 1736 then 1737 CFLAGS_NODIST="$CFLAGS_NODIST -Wno-missing-field-initializers" 1738 fi 1739 1740 AC_MSG_CHECKING(if we can turn on $CC mixed sign comparison warning) 1741 ac_save_cc="$CC" 1742 CC="$CC -Wsign-compare" 1743 save_CFLAGS="$CFLAGS" 1744 AC_CACHE_VAL(ac_cv_enable_sign_compare_warning, 1745 AC_COMPILE_IFELSE( 1746 [ 1747 AC_LANG_PROGRAM([[]], [[]]) 1748 ],[ 1749 ac_cv_enable_sign_compare_warning=yes 1750 ],[ 1751 ac_cv_enable_sign_compare_warning=no 1752 ])) 1753 CFLAGS="$save_CFLAGS" 1754 CC="$ac_save_cc" 1755 AC_MSG_RESULT($ac_cv_enable_sign_compare_warning) 1756 1757 if test $ac_cv_enable_sign_compare_warning = yes 1758 then 1759 BASECFLAGS="$BASECFLAGS -Wsign-compare" 1760 fi 1761 1762 AC_MSG_CHECKING(if we can turn on $CC unreachable code warning) 1763 ac_save_cc="$CC" 1764 CC="$CC -Wunreachable-code" 1765 save_CFLAGS="$CFLAGS" 1766 AC_CACHE_VAL(ac_cv_enable_unreachable_code_warning, 1767 AC_COMPILE_IFELSE( 1768 [ 1769 AC_LANG_PROGRAM([[]], [[]]) 1770 ],[ 1771 ac_cv_enable_unreachable_code_warning=yes 1772 ],[ 1773 ac_cv_enable_unreachable_code_warning=no 1774 ])) 1775 CFLAGS="$save_CFLAGS" 1776 CC="$ac_save_cc" 1777 1778 # Don't enable unreachable code warning in debug mode, since it usually 1779 # results in non-standard code paths. 1780 # Issue #24324: Unfortunately, the unreachable code warning does not work 1781 # correctly on gcc and has been silently removed from the compiler. 1782 # It is supported on clang but on OS X systems gcc may be an alias 1783 # for clang. Try to determine if the compiler is not really gcc and, 1784 # if so, only then enable the warning. 1785 if test $ac_cv_enable_unreachable_code_warning = yes && \ 1786 test "$Py_DEBUG" != "true" && \ 1787 test -z "`$CC --version 2>/dev/null | grep 'Free Software Foundation'`" 1788 then 1789 BASECFLAGS="$BASECFLAGS -Wunreachable-code" 1790 else 1791 ac_cv_enable_unreachable_code_warning=no 1792 fi 1793 AC_MSG_RESULT($ac_cv_enable_unreachable_code_warning) 1794 1795 AC_MSG_CHECKING(if we can turn on $CC strict-prototypes warning) 1796 ac_save_cc="$CC" 1797 CC="$CC -Werror -Wstrict-prototypes" 1798 AC_CACHE_VAL(ac_cv_enable_enable_strict_prototypes_warning, 1799 AC_COMPILE_IFELSE( 1800 [ 1801 AC_LANG_PROGRAM([[]], [[]]) 1802 ],[ 1803 ac_cv_enable_strict_prototypes_warning=yes 1804 ],[ 1805 ac_cv_enable_strict_prototypes_warning=no 1806 ])) 1807 CC="$ac_save_cc" 1808 AC_MSG_RESULT($ac_cv_enable_strict_prototypes_warning) 1809 1810 if test $ac_cv_enable_strict_prototypes_warning = yes 1811 then 1812 CFLAGS_NODIST="$CFLAGS_NODIST -Wstrict-prototypes" 1813 fi 1814 1815 AC_MSG_CHECKING(if we can make implicit function declaration an error in $CC) 1816 ac_save_cc="$CC" 1817 CC="$CC -Werror=implicit-function-declaration" 1818 AC_CACHE_VAL(ac_cv_enable_implicit_function_declaration_error, 1819 AC_COMPILE_IFELSE( 1820 [ 1821 AC_LANG_PROGRAM([[]], [[]]) 1822 ],[ 1823 ac_cv_enable_implicit_function_declaration_error=yes 1824 ],[ 1825 ac_cv_enable_implicit_function_declaration_error=no 1826 ])) 1827 CC="$ac_save_cc" 1828 AC_MSG_RESULT($ac_cv_enable_implicit_function_declaration_error) 1829 1830 if test $ac_cv_enable_implicit_function_declaration_error = yes 1831 then 1832 CFLAGS_NODIST="$CFLAGS_NODIST -Werror=implicit-function-declaration" 1833 fi 1834 1835 AC_MSG_CHECKING(if we can use visibility in $CC) 1836 ac_save_cc="$CC" 1837 CC="$CC -fvisibility=hidden" 1838 AC_CACHE_VAL(ac_cv_enable_visibility, 1839 AC_COMPILE_IFELSE( 1840 [ 1841 AC_LANG_PROGRAM([[]], [[]]) 1842 ],[ 1843 ac_cv_enable_visibility=yes 1844 ],[ 1845 ac_cv_enable_visibility=no 1846 ])) 1847 CC="$ac_save_cc" 1848 AC_MSG_RESULT($ac_cv_enable_visibility) 1849 1850 if test $ac_cv_enable_visibility = yes 1851 then 1852 CFLAGS_NODIST="$CFLAGS_NODIST -fvisibility=hidden" 1853 fi 1854 1855 # if using gcc on alpha, use -mieee to get (near) full IEEE 754 1856 # support. Without this, treatment of subnormals doesn't follow 1857 # the standard. 1858 case $host in 1859 alpha*) 1860 BASECFLAGS="$BASECFLAGS -mieee" 1861 ;; 1862 esac 1863 1864 case $ac_sys_system in 1865 SCO_SV*) 1866 BASECFLAGS="$BASECFLAGS -m486 -DSCO5" 1867 ;; 1868 1869 Darwin*) 1870 # -Wno-long-double, -no-cpp-precomp, and -mno-fused-madd 1871 # used to be here, but non-Apple gcc doesn't accept them. 1872 if test "${CC}" = gcc 1873 then 1874 AC_MSG_CHECKING(which compiler should be used) 1875 case "${UNIVERSALSDK}" in 1876 */MacOSX10.4u.sdk) 1877 # Build using 10.4 SDK, force usage of gcc when the 1878 # compiler is gcc, otherwise the user will get very 1879 # confusing error messages when building on OSX 10.6 1880 CC=gcc-4.0 1881 CPP=cpp-4.0 1882 ;; 1883 esac 1884 AC_MSG_RESULT($CC) 1885 fi 1886 1887 LIPO_INTEL64_FLAGS="" 1888 if test "${enable_universalsdk}" 1889 then 1890 case "$UNIVERSAL_ARCHS" in 1891 32-bit) 1892 UNIVERSAL_ARCH_FLAGS="-arch ppc -arch i386" 1893 LIPO_32BIT_FLAGS="" 1894 ARCH_RUN_32BIT="" 1895 ;; 1896 64-bit) 1897 UNIVERSAL_ARCH_FLAGS="-arch ppc64 -arch x86_64" 1898 LIPO_32BIT_FLAGS="" 1899 ARCH_RUN_32BIT="true" 1900 ;; 1901 all) 1902 UNIVERSAL_ARCH_FLAGS="-arch i386 -arch ppc -arch ppc64 -arch x86_64" 1903 LIPO_32BIT_FLAGS="-extract ppc7400 -extract i386" 1904 ARCH_RUN_32BIT="/usr/bin/arch -i386 -ppc" 1905 ;; 1906 universal2) 1907 UNIVERSAL_ARCH_FLAGS="-arch arm64 -arch x86_64" 1908 LIPO_32BIT_FLAGS="" 1909 LIPO_INTEL64_FLAGS="-extract x86_64" 1910 ARCH_RUN_32BIT="true" 1911 ;; 1912 intel) 1913 UNIVERSAL_ARCH_FLAGS="-arch i386 -arch x86_64" 1914 LIPO_32BIT_FLAGS="-extract i386" 1915 ARCH_RUN_32BIT="/usr/bin/arch -i386" 1916 ;; 1917 intel-32) 1918 UNIVERSAL_ARCH_FLAGS="-arch i386" 1919 LIPO_32BIT_FLAGS="" 1920 ARCH_RUN_32BIT="" 1921 ;; 1922 intel-64) 1923 UNIVERSAL_ARCH_FLAGS="-arch x86_64" 1924 LIPO_32BIT_FLAGS="" 1925 ARCH_RUN_32BIT="true" 1926 ;; 1927 3-way) 1928 UNIVERSAL_ARCH_FLAGS="-arch i386 -arch ppc -arch x86_64" 1929 LIPO_32BIT_FLAGS="-extract ppc7400 -extract i386" 1930 ARCH_RUN_32BIT="/usr/bin/arch -i386 -ppc" 1931 ;; 1932 *) 1933 AC_MSG_ERROR([proper usage is --with-universal-arch=universal2|32-bit|64-bit|all|intel|3-way]) 1934 ;; 1935 esac 1936 1937 if test "${UNIVERSALSDK}" != "/" 1938 then 1939 CFLAGS="${UNIVERSAL_ARCH_FLAGS} -isysroot ${UNIVERSALSDK} ${CFLAGS}" 1940 LDFLAGS="${UNIVERSAL_ARCH_FLAGS} -isysroot ${UNIVERSALSDK} ${LDFLAGS}" 1941 CPPFLAGS="-isysroot ${UNIVERSALSDK} ${CPPFLAGS}" 1942 else 1943 CFLAGS="${UNIVERSAL_ARCH_FLAGS} ${CFLAGS}" 1944 LDFLAGS="${UNIVERSAL_ARCH_FLAGS} ${LDFLAGS}" 1945 fi 1946 fi 1947 1948 # Calculate an appropriate deployment target for this build: 1949 # The deployment target value is used explicitly to enable certain 1950 # features are enabled (such as builtin libedit support for readline) 1951 # through the use of Apple's Availability Macros and is used as a 1952 # component of the string returned by distutils.get_platform(). 1953 # 1954 # Use the value from: 1955 # 1. the MACOSX_DEPLOYMENT_TARGET environment variable if specified 1956 # 2. the operating system version of the build machine if >= 10.6 1957 # 3. If running on OS X 10.3 through 10.5, use the legacy tests 1958 # below to pick either 10.3, 10.4, or 10.5 as the target. 1959 # 4. If we are running on OS X 10.2 or earlier, good luck! 1960 1961 AC_MSG_CHECKING(which MACOSX_DEPLOYMENT_TARGET to use) 1962 cur_target_major=`sw_vers -productVersion | \ 1963 sed 's/\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'` 1964 cur_target_minor=`sw_vers -productVersion | \ 1965 sed 's/\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'` 1966 cur_target="${cur_target_major}.${cur_target_minor}" 1967 if test ${cur_target_major} -eq 10 && \ 1968 test ${cur_target_minor} -ge 3 && \ 1969 test ${cur_target_minor} -le 5 1970 then 1971 # OS X 10.3 through 10.5 1972 cur_target=10.3 1973 if test ${enable_universalsdk} 1974 then 1975 case "$UNIVERSAL_ARCHS" in 1976 all|3-way|intel|64-bit) 1977 # These configurations were first supported in 10.5 1978 cur_target='10.5' 1979 ;; 1980 esac 1981 else 1982 if test `/usr/bin/arch` = "i386" 1983 then 1984 # 10.4 was the first release to support Intel archs 1985 cur_target="10.4" 1986 fi 1987 fi 1988 fi 1989 CONFIGURE_MACOSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET-${cur_target}} 1990 1991 # Make sure that MACOSX_DEPLOYMENT_TARGET is set in the 1992 # environment with a value that is the same as what we'll use 1993 # in the Makefile to ensure that we'll get the same compiler 1994 # environment during configure and build time. 1995 MACOSX_DEPLOYMENT_TARGET="$CONFIGURE_MACOSX_DEPLOYMENT_TARGET" 1996 export MACOSX_DEPLOYMENT_TARGET 1997 EXPORT_MACOSX_DEPLOYMENT_TARGET='' 1998 AC_MSG_RESULT($MACOSX_DEPLOYMENT_TARGET) 1999 2000 AC_MSG_CHECKING(if specified universal architectures work) 2001 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <stdio.h>]], [[printf("%d", 42);]])], 2002 [AC_MSG_RESULT(yes)], 2003 [AC_MSG_RESULT(no) 2004 AC_MSG_ERROR(check config.log and use the '--with-universal-archs' option) 2005 ]) 2006 2007 # end of Darwin* tests 2008 ;; 2009 esac 2010 ;; 2011 2012*) 2013 case $ac_sys_system in 2014 OpenUNIX*|UnixWare*) 2015 BASECFLAGS="$BASECFLAGS -K pentium,host,inline,loop_unroll,alloca " 2016 ;; 2017 SCO_SV*) 2018 BASECFLAGS="$BASECFLAGS -belf -Ki486 -DSCO5" 2019 ;; 2020 esac 2021 ;; 2022esac 2023 2024case "$CC" in 2025*icc*) 2026 # ICC needs -fp-model strict or floats behave badly 2027 CFLAGS_NODIST="$CFLAGS_NODIST -fp-model strict" 2028 ;; 2029*xlc*) 2030 CFLAGS_NODIST="$CFLAGS_NODIST -qalias=noansi -qmaxmem=-1" 2031 ;; 2032esac 2033 2034if test "$assertions" = 'true'; then 2035 : 2036else 2037 OPT="-DNDEBUG $OPT" 2038fi 2039 2040if test "$ac_arch_flags" 2041then 2042 BASECFLAGS="$BASECFLAGS $ac_arch_flags" 2043fi 2044 2045# On some compilers, pthreads are available without further options 2046# (e.g. MacOS X). On some of these systems, the compiler will not 2047# complain if unaccepted options are passed (e.g. gcc on Mac OS X). 2048# So we have to see first whether pthreads are available without 2049# options before we can check whether -Kpthread improves anything. 2050AC_MSG_CHECKING(whether pthreads are available without options) 2051AC_CACHE_VAL(ac_cv_pthread_is_default, 2052[AC_RUN_IFELSE([AC_LANG_SOURCE([[ 2053#include <stdio.h> 2054#include <pthread.h> 2055 2056void* routine(void* p){return NULL;} 2057 2058int main(){ 2059 pthread_t p; 2060 if(pthread_create(&p,NULL,routine,NULL)!=0) 2061 return 1; 2062 (void)pthread_detach(p); 2063 return 0; 2064} 2065]])],[ 2066 ac_cv_pthread_is_default=yes 2067 ac_cv_kthread=no 2068 ac_cv_pthread=no 2069],[ac_cv_pthread_is_default=no],[ac_cv_pthread_is_default=no]) 2070]) 2071AC_MSG_RESULT($ac_cv_pthread_is_default) 2072 2073 2074if test $ac_cv_pthread_is_default = yes 2075then 2076 ac_cv_kpthread=no 2077else 2078# -Kpthread, if available, provides the right #defines 2079# and linker options to make pthread_create available 2080# Some compilers won't report that they do not support -Kpthread, 2081# so we need to run a program to see whether it really made the 2082# function available. 2083AC_MSG_CHECKING(whether $CC accepts -Kpthread) 2084AC_CACHE_VAL(ac_cv_kpthread, 2085[ac_save_cc="$CC" 2086CC="$CC -Kpthread" 2087AC_RUN_IFELSE([AC_LANG_SOURCE([[ 2088#include <stdio.h> 2089#include <pthread.h> 2090 2091void* routine(void* p){return NULL;} 2092 2093int main(){ 2094 pthread_t p; 2095 if(pthread_create(&p,NULL,routine,NULL)!=0) 2096 return 1; 2097 (void)pthread_detach(p); 2098 return 0; 2099} 2100]])],[ac_cv_kpthread=yes],[ac_cv_kpthread=no],[ac_cv_kpthread=no]) 2101CC="$ac_save_cc"]) 2102AC_MSG_RESULT($ac_cv_kpthread) 2103fi 2104 2105if test $ac_cv_kpthread = no -a $ac_cv_pthread_is_default = no 2106then 2107# -Kthread, if available, provides the right #defines 2108# and linker options to make pthread_create available 2109# Some compilers won't report that they do not support -Kthread, 2110# so we need to run a program to see whether it really made the 2111# function available. 2112AC_MSG_CHECKING(whether $CC accepts -Kthread) 2113AC_CACHE_VAL(ac_cv_kthread, 2114[ac_save_cc="$CC" 2115CC="$CC -Kthread" 2116AC_RUN_IFELSE([AC_LANG_SOURCE([[ 2117#include <stdio.h> 2118#include <pthread.h> 2119 2120void* routine(void* p){return NULL;} 2121 2122int main(){ 2123 pthread_t p; 2124 if(pthread_create(&p,NULL,routine,NULL)!=0) 2125 return 1; 2126 (void)pthread_detach(p); 2127 return 0; 2128} 2129]])],[ac_cv_kthread=yes],[ac_cv_kthread=no],[ac_cv_kthread=no]) 2130CC="$ac_save_cc"]) 2131AC_MSG_RESULT($ac_cv_kthread) 2132fi 2133 2134if test $ac_cv_kthread = no -a $ac_cv_pthread_is_default = no 2135then 2136# -pthread, if available, provides the right #defines 2137# and linker options to make pthread_create available 2138# Some compilers won't report that they do not support -pthread, 2139# so we need to run a program to see whether it really made the 2140# function available. 2141AC_MSG_CHECKING(whether $CC accepts -pthread) 2142AC_CACHE_VAL(ac_cv_pthread, 2143[ac_save_cc="$CC" 2144CC="$CC -pthread" 2145AC_RUN_IFELSE([AC_LANG_SOURCE([[ 2146#include <stdio.h> 2147#include <pthread.h> 2148 2149void* routine(void* p){return NULL;} 2150 2151int main(){ 2152 pthread_t p; 2153 if(pthread_create(&p,NULL,routine,NULL)!=0) 2154 return 1; 2155 (void)pthread_detach(p); 2156 return 0; 2157} 2158]])],[ac_cv_pthread=yes],[ac_cv_pthread=no],[ac_cv_pthread=no]) 2159CC="$ac_save_cc"]) 2160AC_MSG_RESULT($ac_cv_pthread) 2161fi 2162 2163# If we have set a CC compiler flag for thread support then 2164# check if it works for CXX, too. 2165ac_cv_cxx_thread=no 2166if test ! -z "$CXX" 2167then 2168AC_MSG_CHECKING(whether $CXX also accepts flags for thread support) 2169ac_save_cxx="$CXX" 2170 2171if test "$ac_cv_kpthread" = "yes" 2172then 2173 CXX="$CXX -Kpthread" 2174 ac_cv_cxx_thread=yes 2175elif test "$ac_cv_kthread" = "yes" 2176then 2177 CXX="$CXX -Kthread" 2178 ac_cv_cxx_thread=yes 2179elif test "$ac_cv_pthread" = "yes" 2180then 2181 CXX="$CXX -pthread" 2182 ac_cv_cxx_thread=yes 2183fi 2184 2185if test $ac_cv_cxx_thread = yes 2186then 2187 echo 'void foo();int main(){foo();}void foo(){}' > conftest.$ac_ext 2188 $CXX -c conftest.$ac_ext 2>&5 2189 if $CXX -o conftest$ac_exeext conftest.$ac_objext 2>&5 \ 2190 && test -s conftest$ac_exeext && ./conftest$ac_exeext 2191 then 2192 ac_cv_cxx_thread=yes 2193 else 2194 ac_cv_cxx_thread=no 2195 fi 2196 rm -fr conftest* 2197fi 2198AC_MSG_RESULT($ac_cv_cxx_thread) 2199fi 2200CXX="$ac_save_cxx" 2201 2202dnl # check for ANSI or K&R ("traditional") preprocessor 2203dnl AC_MSG_CHECKING(for C preprocessor type) 2204dnl AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 2205dnl #define spam(name, doc) {#name, &name, #name "() -- " doc} 2206dnl int foo; 2207dnl struct {char *name; int *addr; char *doc;} desc = spam(foo, "something"); 2208dnl ]], [[;]])],[cpp_type=ansi],[AC_DEFINE(HAVE_OLD_CPP) cpp_type=traditional]) 2209dnl AC_MSG_RESULT($cpp_type) 2210 2211# checks for header files 2212AC_HEADER_STDC 2213AC_CHECK_HEADERS(asm/types.h crypt.h conio.h direct.h dlfcn.h errno.h \ 2214fcntl.h grp.h \ 2215ieeefp.h io.h langinfo.h libintl.h process.h pthread.h \ 2216sched.h shadow.h signal.h stropts.h termios.h \ 2217utime.h \ 2218poll.h sys/devpoll.h sys/epoll.h sys/poll.h \ 2219sys/audioio.h sys/xattr.h sys/bsdtty.h sys/event.h sys/file.h sys/ioctl.h \ 2220sys/kern_control.h sys/loadavg.h sys/lock.h sys/mkdev.h sys/modem.h \ 2221sys/param.h sys/random.h sys/select.h sys/sendfile.h sys/socket.h sys/statvfs.h \ 2222sys/stat.h sys/syscall.h sys/sys_domain.h sys/termio.h sys/time.h \ 2223sys/times.h sys/types.h sys/uio.h sys/un.h sys/utsname.h sys/wait.h pty.h \ 2224libutil.h sys/resource.h netpacket/packet.h sysexits.h bluetooth.h \ 2225linux/tipc.h linux/random.h spawn.h util.h alloca.h endian.h \ 2226sys/endian.h sys/sysmacros.h linux/memfd.h linux/wait.h sys/memfd.h sys/mman.h) 2227AC_HEADER_DIRENT 2228AC_HEADER_MAJOR 2229 2230# bluetooth/bluetooth.h has been known to not compile with -std=c99. 2231# http://permalink.gmane.org/gmane.linux.bluez.kernel/22294 2232SAVE_CFLAGS=$CFLAGS 2233CFLAGS="-std=c99 $CFLAGS" 2234AC_CHECK_HEADERS(bluetooth/bluetooth.h) 2235CFLAGS=$SAVE_CFLAGS 2236 2237# On Darwin (OS X) net/if.h requires sys/socket.h to be imported first. 2238AC_CHECK_HEADERS([net/if.h], [], [], 2239[#include <stdio.h> 2240#ifdef STDC_HEADERS 2241# include <stdlib.h> 2242# include <stddef.h> 2243#else 2244# ifdef HAVE_STDLIB_H 2245# include <stdlib.h> 2246# endif 2247#endif 2248#ifdef HAVE_SYS_SOCKET_H 2249# include <sys/socket.h> 2250#endif 2251]) 2252 2253# On Linux, netlink.h requires asm/types.h 2254AC_CHECK_HEADERS(linux/netlink.h,,,[ 2255#ifdef HAVE_ASM_TYPES_H 2256#include <asm/types.h> 2257#endif 2258#ifdef HAVE_SYS_SOCKET_H 2259#include <sys/socket.h> 2260#endif 2261]) 2262 2263# On Linux, qrtr.h requires asm/types.h 2264AC_CHECK_HEADERS(linux/qrtr.h,,,[ 2265#ifdef HAVE_ASM_TYPES_H 2266#include <asm/types.h> 2267#endif 2268#ifdef HAVE_SYS_SOCKET_H 2269#include <sys/socket.h> 2270#endif 2271]) 2272 2273AC_CHECK_HEADERS(linux/vm_sockets.h,,,[ 2274#ifdef HAVE_SYS_SOCKET_H 2275#include <sys/socket.h> 2276#endif 2277]) 2278 2279# On Linux, can.h, can/bcm.h, can/j1939.h, can/raw.h require sys/socket.h 2280AC_CHECK_HEADERS(linux/can.h linux/can/bcm.h linux/can/j1939.h linux/can/raw.h,,,[ 2281#ifdef HAVE_SYS_SOCKET_H 2282#include <sys/socket.h> 2283#endif 2284]) 2285 2286# checks for typedefs 2287was_it_defined=no 2288AC_MSG_CHECKING(for clock_t in time.h) 2289AC_EGREP_HEADER(clock_t, time.h, was_it_defined=yes, [ 2290 AC_DEFINE(clock_t, long, [Define to 'long' if <time.h> doesn't define.]) 2291]) 2292AC_MSG_RESULT($was_it_defined) 2293 2294AC_MSG_CHECKING(for makedev) 2295AC_LINK_IFELSE([AC_LANG_PROGRAM([[ 2296#if defined(MAJOR_IN_MKDEV) 2297#include <sys/mkdev.h> 2298#elif defined(MAJOR_IN_SYSMACROS) 2299#include <sys/sysmacros.h> 2300#else 2301#include <sys/types.h> 2302#endif 2303]], [[ 2304 makedev(0, 0) ]]) 2305],[ac_cv_has_makedev=yes],[ac_cv_has_makedev=no]) 2306AC_MSG_RESULT($ac_cv_has_makedev) 2307if test "$ac_cv_has_makedev" = "yes"; then 2308 AC_DEFINE(HAVE_MAKEDEV, 1, [Define this if you have the makedev macro.]) 2309fi 2310 2311# byte swapping 2312AC_MSG_CHECKING(for le64toh) 2313AC_LINK_IFELSE([AC_LANG_PROGRAM([[ 2314#ifdef HAVE_ENDIAN_H 2315#include <endian.h> 2316#elif defined(HAVE_SYS_ENDIAN_H) 2317#include <sys/endian.h> 2318#endif 2319]], [[ 2320 le64toh(1) ]]) 2321],[ac_cv_has_le64toh=yes],[ac_cv_has_le64toh=no]) 2322AC_MSG_RESULT($ac_cv_has_le64toh) 2323if test "$ac_cv_has_le64toh" = "yes"; then 2324 AC_DEFINE(HAVE_HTOLE64, 1, [Define this if you have le64toh()]) 2325fi 2326 2327use_lfs=yes 2328# Don't use largefile support for GNU/Hurd 2329case $ac_sys_system in GNU*) 2330 use_lfs=no 2331esac 2332 2333if test "$use_lfs" = "yes"; then 2334# Two defines needed to enable largefile support on various platforms 2335# These may affect some typedefs 2336case $ac_sys_system/$ac_sys_release in 2337AIX*) 2338 AC_DEFINE(_LARGE_FILES, 1, 2339 [This must be defined on AIX systems to enable large file support.]) 2340 ;; 2341esac 2342AC_DEFINE(_LARGEFILE_SOURCE, 1, 2343[This must be defined on some systems to enable large file support.]) 2344AC_DEFINE(_FILE_OFFSET_BITS, 64, 2345[This must be set to 64 on some systems to enable large file support.]) 2346fi 2347 2348# Add some code to confdefs.h so that the test for off_t works on SCO 2349cat >> confdefs.h <<\EOF 2350#if defined(SCO_DS) 2351#undef _OFF_T 2352#endif 2353EOF 2354 2355# Type availability checks 2356AC_TYPE_MODE_T 2357AC_TYPE_OFF_T 2358AC_TYPE_PID_T 2359AC_DEFINE_UNQUOTED([RETSIGTYPE],[void],[assume C89 semantics that RETSIGTYPE is always void]) 2360AC_TYPE_SIZE_T 2361AC_TYPE_UID_T 2362 2363AC_CHECK_TYPE(ssize_t, 2364 AC_DEFINE(HAVE_SSIZE_T, 1, [Define if your compiler provides ssize_t]),,) 2365AC_CHECK_TYPE(__uint128_t, 2366 AC_DEFINE(HAVE_GCC_UINT128_T, 1, [Define if your compiler provides __uint128_t]),,) 2367 2368# Sizes of various common basic types 2369# ANSI C requires sizeof(char) == 1, so no need to check it 2370AC_CHECK_SIZEOF(int, 4) 2371AC_CHECK_SIZEOF(long, 4) 2372AC_CHECK_SIZEOF(long long, 8) 2373AC_CHECK_SIZEOF(void *, 4) 2374AC_CHECK_SIZEOF(short, 2) 2375AC_CHECK_SIZEOF(float, 4) 2376AC_CHECK_SIZEOF(double, 8) 2377AC_CHECK_SIZEOF(fpos_t, 4) 2378AC_CHECK_SIZEOF(size_t, 4) 2379AC_CHECK_SIZEOF(pid_t, 4) 2380AC_CHECK_SIZEOF(uintptr_t) 2381 2382AC_TYPE_LONG_DOUBLE 2383AC_CHECK_SIZEOF(long double, 16) 2384 2385AC_CHECK_SIZEOF(_Bool, 1) 2386 2387AC_CHECK_SIZEOF(off_t, [], [ 2388#ifdef HAVE_SYS_TYPES_H 2389#include <sys/types.h> 2390#endif 2391]) 2392 2393AC_MSG_CHECKING(whether to enable large file support) 2394if test "$ac_cv_sizeof_off_t" -gt "$ac_cv_sizeof_long" -a \ 2395 "$ac_cv_sizeof_long_long" -ge "$ac_cv_sizeof_off_t"; then 2396 AC_DEFINE(HAVE_LARGEFILE_SUPPORT, 1, 2397 [Defined to enable large file support when an off_t is bigger than a long 2398 and long long is at least as big as an off_t. You may need 2399 to add some flags for configuration and compilation to enable this mode. 2400 (For Solaris and Linux, the necessary defines are already defined.)]) 2401 AC_MSG_RESULT(yes) 2402else 2403 AC_MSG_RESULT(no) 2404fi 2405 2406AC_CHECK_SIZEOF(time_t, [], [ 2407#ifdef HAVE_SYS_TYPES_H 2408#include <sys/types.h> 2409#endif 2410#ifdef HAVE_TIME_H 2411#include <time.h> 2412#endif 2413]) 2414 2415# if have pthread_t then define SIZEOF_PTHREAD_T 2416ac_save_cc="$CC" 2417if test "$ac_cv_kpthread" = "yes" 2418then CC="$CC -Kpthread" 2419elif test "$ac_cv_kthread" = "yes" 2420then CC="$CC -Kthread" 2421elif test "$ac_cv_pthread" = "yes" 2422then CC="$CC -pthread" 2423fi 2424 2425AC_MSG_CHECKING(for pthread_t) 2426have_pthread_t=no 2427AC_COMPILE_IFELSE([ 2428 AC_LANG_PROGRAM([[#include <pthread.h>]], [[pthread_t x; x = *(pthread_t*)0;]]) 2429],[have_pthread_t=yes],[]) 2430AC_MSG_RESULT($have_pthread_t) 2431if test "$have_pthread_t" = yes ; then 2432 AC_CHECK_SIZEOF(pthread_t, [], [ 2433#ifdef HAVE_PTHREAD_H 2434#include <pthread.h> 2435#endif 2436 ]) 2437fi 2438 2439# Issue #25658: POSIX hasn't defined that pthread_key_t is compatible with int. 2440# This checking will be unnecessary after removing deprecated TLS API. 2441AC_CHECK_SIZEOF(pthread_key_t, [], [[#include <pthread.h>]]) 2442AC_MSG_CHECKING(whether pthread_key_t is compatible with int) 2443if test "$ac_cv_sizeof_pthread_key_t" -eq "$ac_cv_sizeof_int" ; then 2444 AC_COMPILE_IFELSE( 2445 [AC_LANG_PROGRAM([[#include <pthread.h>]], [[pthread_key_t k; k * 1;]])], 2446 [ac_pthread_key_t_is_arithmetic_type=yes], 2447 [ac_pthread_key_t_is_arithmetic_type=no] 2448 ) 2449 AC_MSG_RESULT($ac_pthread_key_t_is_arithmetic_type) 2450 if test "$ac_pthread_key_t_is_arithmetic_type" = yes ; then 2451 AC_DEFINE(PTHREAD_KEY_T_IS_COMPATIBLE_WITH_INT, 1, 2452 [Define if pthread_key_t is compatible with int.]) 2453 fi 2454else 2455 AC_MSG_RESULT(no) 2456fi 2457CC="$ac_save_cc" 2458 2459AC_SUBST(OTHER_LIBTOOL_OPT) 2460case $ac_sys_system/$ac_sys_release in 2461 Darwin/@<:@01567@:>@\..*) 2462 OTHER_LIBTOOL_OPT="-prebind -seg1addr 0x10000000" 2463 ;; 2464 Darwin/*) 2465 OTHER_LIBTOOL_OPT="" 2466 ;; 2467esac 2468 2469 2470AC_SUBST(LIBTOOL_CRUFT) 2471case $ac_sys_system/$ac_sys_release in 2472 Darwin/@<:@01567@:>@\..*) 2473 LIBTOOL_CRUFT="-framework System -lcc_dynamic" 2474 if test "${enable_universalsdk}"; then 2475 : 2476 else 2477 LIBTOOL_CRUFT="${LIBTOOL_CRUFT} -arch_only `/usr/bin/arch`" 2478 fi 2479 LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -install_name $(PYTHONFRAMEWORKINSTALLDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)' 2480 LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -compatibility_version $(VERSION) -current_version $(VERSION)';; 2481 Darwin/*) 2482 gcc_version=`gcc -dumpversion` 2483 if test ${gcc_version} '<' 4.0 2484 then 2485 LIBTOOL_CRUFT="-lcc_dynamic" 2486 else 2487 LIBTOOL_CRUFT="" 2488 fi 2489 AC_RUN_IFELSE([AC_LANG_SOURCE([[ 2490 #include <unistd.h> 2491 int main(int argc, char*argv[]) 2492 { 2493 if (sizeof(long) == 4) { 2494 return 0; 2495 } else { 2496 return 1; 2497 } 2498 } 2499 ]])],[ac_osx_32bit=yes],[ac_osx_32bit=no],[ac_osx_32bit=yes]) 2500 2501 if test "${ac_osx_32bit}" = "yes"; then 2502 case `/usr/bin/arch` in 2503 i386) 2504 MACOSX_DEFAULT_ARCH="i386" 2505 ;; 2506 ppc) 2507 MACOSX_DEFAULT_ARCH="ppc" 2508 ;; 2509 *) 2510 AC_MSG_ERROR([Unexpected output of 'arch' on macOS]) 2511 ;; 2512 esac 2513 else 2514 case `/usr/bin/arch` in 2515 i386) 2516 MACOSX_DEFAULT_ARCH="x86_64" 2517 ;; 2518 ppc) 2519 MACOSX_DEFAULT_ARCH="ppc64" 2520 ;; 2521 arm64) 2522 MACOSX_DEFAULT_ARCH="arm64" 2523 ;; 2524 *) 2525 AC_MSG_ERROR([Unexpected output of 'arch' on macOS]) 2526 ;; 2527 esac 2528 2529 fi 2530 2531 LIBTOOL_CRUFT=$LIBTOOL_CRUFT" -lSystem -lSystemStubs -arch_only ${MACOSX_DEFAULT_ARCH}" 2532 LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -install_name $(PYTHONFRAMEWORKINSTALLDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)' 2533 LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -compatibility_version $(VERSION) -current_version $(VERSION)';; 2534esac 2535AC_MSG_CHECKING(for --enable-framework) 2536if test "$enable_framework" 2537then 2538 BASECFLAGS="$BASECFLAGS -fno-common -dynamic" 2539 # -F. is needed to allow linking to the framework while 2540 # in the build location. 2541 AC_DEFINE(WITH_NEXT_FRAMEWORK, 1, 2542 [Define if you want to produce an OpenStep/Rhapsody framework 2543 (shared library plus accessory files).]) 2544 AC_MSG_RESULT(yes) 2545 if test $enable_shared = "yes" 2546 then 2547 AC_MSG_ERROR([Specifying both --enable-shared and --enable-framework is not supported, use only --enable-framework instead]) 2548 fi 2549else 2550 AC_MSG_RESULT(no) 2551fi 2552 2553AC_MSG_CHECKING(for dyld) 2554case $ac_sys_system/$ac_sys_release in 2555 Darwin/*) 2556 AC_DEFINE(WITH_DYLD, 1, 2557 [Define if you want to use the new-style (Openstep, Rhapsody, MacOS) 2558 dynamic linker (dyld) instead of the old-style (NextStep) dynamic 2559 linker (rld). Dyld is necessary to support frameworks.]) 2560 AC_MSG_RESULT(always on for Darwin) 2561 ;; 2562 *) 2563 AC_MSG_RESULT(no) 2564 ;; 2565esac 2566 2567# Set info about shared libraries. 2568AC_SUBST(SHLIB_SUFFIX) 2569AC_SUBST(LDSHARED) 2570AC_SUBST(LDCXXSHARED) 2571AC_SUBST(BLDSHARED) 2572AC_SUBST(CCSHARED) 2573AC_SUBST(LINKFORSHARED) 2574 2575# SHLIB_SUFFIX is the extension of shared libraries `(including the dot!) 2576# -- usually .so, .sl on HP-UX, .dll on Cygwin 2577AC_MSG_CHECKING(the extension of shared libraries) 2578if test -z "$SHLIB_SUFFIX"; then 2579 case $ac_sys_system in 2580 hp*|HP*) 2581 case `uname -m` in 2582 ia64) SHLIB_SUFFIX=.so;; 2583 *) SHLIB_SUFFIX=.sl;; 2584 esac 2585 ;; 2586 CYGWIN*) SHLIB_SUFFIX=.dll;; 2587 *) SHLIB_SUFFIX=.so;; 2588 esac 2589fi 2590AC_MSG_RESULT($SHLIB_SUFFIX) 2591 2592# LDSHARED is the ld *command* used to create shared library 2593# -- "cc -G" on SunOS 5.x. 2594# (Shared libraries in this instance are shared modules to be loaded into 2595# Python, as opposed to building Python itself as a shared library.) 2596AC_MSG_CHECKING(LDSHARED) 2597if test -z "$LDSHARED" 2598then 2599 case $ac_sys_system/$ac_sys_release in 2600 AIX*) 2601 BLDSHARED="Modules/ld_so_aix \$(CC) -bI:Modules/python.exp" 2602 LDSHARED="\$(LIBPL)/ld_so_aix \$(CC) -bI:\$(LIBPL)/python.exp" 2603 ;; 2604 SunOS/5*) 2605 if test "$GCC" = "yes" ; then 2606 LDSHARED='$(CC) -shared' 2607 LDCXXSHARED='$(CXX) -shared' 2608 else 2609 LDSHARED='$(CC) -G' 2610 LDCXXSHARED='$(CXX) -G' 2611 fi ;; 2612 hp*|HP*) 2613 if test "$GCC" = "yes" ; then 2614 LDSHARED='$(CC) -shared' 2615 LDCXXSHARED='$(CXX) -shared' 2616 else 2617 LDSHARED='$(CC) -b' 2618 LDCXXSHARED='$(CXX) -b' 2619 fi ;; 2620 Darwin/1.3*) 2621 LDSHARED='$(CC) -bundle' 2622 LDCXXSHARED='$(CXX) -bundle' 2623 if test "$enable_framework" ; then 2624 # Link against the framework. All externals should be defined. 2625 BLDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)' 2626 LDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)' 2627 LDCXXSHARED="$LDCXXSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)' 2628 else 2629 # No framework. Ignore undefined symbols, assuming they come from Python 2630 LDSHARED="$LDSHARED -undefined suppress" 2631 LDCXXSHARED="$LDCXXSHARED -undefined suppress" 2632 fi ;; 2633 Darwin/1.4*|Darwin/5.*|Darwin/6.*) 2634 LDSHARED='$(CC) -bundle' 2635 LDCXXSHARED='$(CXX) -bundle' 2636 if test "$enable_framework" ; then 2637 # Link against the framework. All externals should be defined. 2638 BLDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)' 2639 LDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)' 2640 LDCXXSHARED="$LDCXXSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)' 2641 else 2642 # No framework, use the Python app as bundle-loader 2643 BLDSHARED="$LDSHARED "'-bundle_loader $(BUILDPYTHON)' 2644 LDSHARED="$LDSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)' 2645 LDCXXSHARED="$LDCXXSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)' 2646 fi ;; 2647 Darwin/*) 2648 # Use -undefined dynamic_lookup whenever possible (10.3 and later). 2649 # This allows an extension to be used in any Python 2650 2651 dep_target_major=`echo ${MACOSX_DEPLOYMENT_TARGET} | \ 2652 sed 's/\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'` 2653 dep_target_minor=`echo ${MACOSX_DEPLOYMENT_TARGET} | \ 2654 sed 's/\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'` 2655 if test ${dep_target_major} -eq 10 && \ 2656 test ${dep_target_minor} -le 2 2657 then 2658 # building for OS X 10.0 through 10.2 2659 LDSHARED='$(CC) -bundle' 2660 LDCXXSHARED='$(CXX) -bundle' 2661 if test "$enable_framework" ; then 2662 # Link against the framework. All externals should be defined. 2663 BLDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)' 2664 LDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)' 2665 LDCXXSHARED="$LDCXXSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)' 2666 else 2667 # No framework, use the Python app as bundle-loader 2668 BLDSHARED="$LDSHARED "'-bundle_loader $(BUILDPYTHON)' 2669 LDSHARED="$LDSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)' 2670 LDCXXSHARED="$LDCXXSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)' 2671 fi 2672 else 2673 # building for OS X 10.3 and later 2674 LDSHARED='$(CC) -bundle -undefined dynamic_lookup' 2675 LDCXXSHARED='$(CXX) -bundle -undefined dynamic_lookup' 2676 BLDSHARED="$LDSHARED" 2677 fi 2678 ;; 2679 Linux*|GNU*|QNX*|VxWorks*) 2680 LDSHARED='$(CC) -shared' 2681 LDCXXSHARED='$(CXX) -shared';; 2682 FreeBSD*) 2683 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]] 2684 then 2685 LDSHARED='$(CC) -shared' 2686 LDCXXSHARED='$(CXX) -shared' 2687 else 2688 LDSHARED="ld -Bshareable" 2689 fi;; 2690 OpenBSD*) 2691 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]] 2692 then 2693 LDSHARED='$(CC) -shared $(CCSHARED)' 2694 LDCXXSHARED='$(CXX) -shared $(CCSHARED)' 2695 else 2696 case `uname -r` in 2697 [[01]].* | 2.[[0-7]] | 2.[[0-7]].*) 2698 LDSHARED="ld -Bshareable ${LDFLAGS}" 2699 ;; 2700 *) 2701 LDSHARED='$(CC) -shared $(CCSHARED)' 2702 LDCXXSHARED='$(CXX) -shared $(CCSHARED)' 2703 ;; 2704 esac 2705 fi;; 2706 NetBSD*|DragonFly*) 2707 LDSHARED='$(CC) -shared' 2708 LDCXXSHARED='$(CXX) -shared';; 2709 OpenUNIX*|UnixWare*) 2710 if test "$GCC" = "yes" ; then 2711 LDSHARED='$(CC) -shared' 2712 LDCXXSHARED='$(CXX) -shared' 2713 else 2714 LDSHARED='$(CC) -G' 2715 LDCXXSHARED='$(CXX) -G' 2716 fi;; 2717 SCO_SV*) 2718 LDSHARED='$(CC) -Wl,-G,-Bexport' 2719 LDCXXSHARED='$(CXX) -Wl,-G,-Bexport';; 2720 CYGWIN*) 2721 LDSHARED="gcc -shared -Wl,--enable-auto-image-base" 2722 LDCXXSHARED="g++ -shared -Wl,--enable-auto-image-base";; 2723 *) LDSHARED="ld";; 2724 esac 2725fi 2726AC_MSG_RESULT($LDSHARED) 2727LDCXXSHARED=${LDCXXSHARED-$LDSHARED} 2728BLDSHARED=${BLDSHARED-$LDSHARED} 2729# CCSHARED are the C *flags* used to create objects to go into a shared 2730# library (module) -- this is only needed for a few systems 2731AC_MSG_CHECKING(CCSHARED) 2732if test -z "$CCSHARED" 2733then 2734 case $ac_sys_system/$ac_sys_release in 2735 SunOS*) if test "$GCC" = yes; 2736 then CCSHARED="-fPIC"; 2737 elif test `uname -p` = sparc; 2738 then CCSHARED="-xcode=pic32"; 2739 else CCSHARED="-Kpic"; 2740 fi;; 2741 hp*|HP*) if test "$GCC" = yes; 2742 then CCSHARED="-fPIC"; 2743 else CCSHARED="+z"; 2744 fi;; 2745 Linux-android*) ;; 2746 Linux*|GNU*) CCSHARED="-fPIC";; 2747 FreeBSD*|NetBSD*|OpenBSD*|DragonFly*) CCSHARED="-fPIC";; 2748 OpenUNIX*|UnixWare*) 2749 if test "$GCC" = "yes" 2750 then CCSHARED="-fPIC" 2751 else CCSHARED="-KPIC" 2752 fi;; 2753 SCO_SV*) 2754 if test "$GCC" = "yes" 2755 then CCSHARED="-fPIC" 2756 else CCSHARED="-Kpic -belf" 2757 fi;; 2758 VxWorks*) 2759 CCSHARED="-fpic -D__SO_PICABILINUX__ -ftls-model=global-dynamic" 2760 esac 2761fi 2762AC_MSG_RESULT($CCSHARED) 2763# LINKFORSHARED are the flags passed to the $(CC) command that links 2764# the python executable -- this is only needed for a few systems 2765AC_MSG_CHECKING(LINKFORSHARED) 2766if test -z "$LINKFORSHARED" 2767then 2768 case $ac_sys_system/$ac_sys_release in 2769 AIX*) LINKFORSHARED='-Wl,-bE:Modules/python.exp -lld';; 2770 hp*|HP*) 2771 LINKFORSHARED="-Wl,-E -Wl,+s";; 2772# LINKFORSHARED="-Wl,-E -Wl,+s -Wl,+b\$(BINLIBDEST)/lib-dynload";; 2773 Linux-android*) LINKFORSHARED="-pie -Xlinker -export-dynamic";; 2774 Linux*|GNU*) LINKFORSHARED="-Xlinker -export-dynamic";; 2775 # -u libsys_s pulls in all symbols in libsys 2776 Darwin/*) 2777 LINKFORSHARED="$extra_undefs -framework CoreFoundation" 2778 2779 # Issue #18075: the default maximum stack size (8MBytes) is too 2780 # small for the default recursion limit. Increase the stack size 2781 # to ensure that tests don't crash 2782 # Note: This matches the value of THREAD_STACK_SIZE in 2783 # thread_pthread.h 2784 LINKFORSHARED="-Wl,-stack_size,1000000 $LINKFORSHARED" 2785 2786 if test "$enable_framework" 2787 then 2788 LINKFORSHARED="$LINKFORSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)' 2789 fi 2790 LINKFORSHARED="$LINKFORSHARED";; 2791 OpenUNIX*|UnixWare*) LINKFORSHARED="-Wl,-Bexport";; 2792 SCO_SV*) LINKFORSHARED="-Wl,-Bexport";; 2793 ReliantUNIX*) LINKFORSHARED="-W1 -Blargedynsym";; 2794 FreeBSD*|NetBSD*|OpenBSD*|DragonFly*) 2795 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]] 2796 then 2797 LINKFORSHARED="-Wl,--export-dynamic" 2798 fi;; 2799 SunOS/5*) case $CC in 2800 *gcc*) 2801 if $CC -Xlinker --help 2>&1 | grep export-dynamic >/dev/null 2802 then 2803 LINKFORSHARED="-Xlinker --export-dynamic" 2804 fi;; 2805 esac;; 2806 CYGWIN*) 2807 if test $enable_shared = "no" 2808 then 2809 LINKFORSHARED='-Wl,--out-implib=$(LDLIBRARY)' 2810 fi;; 2811 QNX*) 2812 # -Wl,-E causes the symbols to be added to the dynamic 2813 # symbol table so that they can be found when a module 2814 # is loaded. -N 2048K causes the stack size to be set 2815 # to 2048 kilobytes so that the stack doesn't overflow 2816 # when running test_compile.py. 2817 LINKFORSHARED='-Wl,-E -N 2048K';; 2818 VxWorks*) 2819 LINKFORSHARED='--export-dynamic';; 2820 esac 2821fi 2822AC_MSG_RESULT($LINKFORSHARED) 2823 2824 2825AC_SUBST(CFLAGSFORSHARED) 2826AC_MSG_CHECKING(CFLAGSFORSHARED) 2827if test ! "$LIBRARY" = "$LDLIBRARY" 2828then 2829 case $ac_sys_system in 2830 CYGWIN*) 2831 # Cygwin needs CCSHARED when building extension DLLs 2832 # but not when building the interpreter DLL. 2833 CFLAGSFORSHARED='';; 2834 *) 2835 CFLAGSFORSHARED='$(CCSHARED)' 2836 esac 2837fi 2838AC_MSG_RESULT($CFLAGSFORSHARED) 2839 2840# SHLIBS are libraries (except -lc and -lm) to link to the python shared 2841# library (with --enable-shared). 2842# For platforms on which shared libraries are not allowed to have unresolved 2843# symbols, this must be set to $(LIBS) (expanded by make). We do this even 2844# if it is not required, since it creates a dependency of the shared library 2845# to LIBS. This, in turn, means that applications linking the shared libpython 2846# don't need to link LIBS explicitly. The default should be only changed 2847# on systems where this approach causes problems. 2848AC_SUBST(SHLIBS) 2849AC_MSG_CHECKING(SHLIBS) 2850case "$ac_sys_system" in 2851 *) 2852 SHLIBS='$(LIBS)';; 2853esac 2854AC_MSG_RESULT($SHLIBS) 2855 2856 2857# checks for libraries 2858AC_CHECK_LIB(sendfile, sendfile) 2859AC_CHECK_LIB(dl, dlopen) # Dynamic linking for SunOS/Solaris and SYSV 2860AC_CHECK_LIB(dld, shl_load) # Dynamic linking for HP-UX 2861 2862# checks for uuid.h location 2863AC_CHECK_HEADERS([uuid/uuid.h uuid.h]) 2864 2865AC_MSG_CHECKING(for uuid_generate_time_safe) 2866AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <uuid/uuid.h>]], [[ 2867#ifndef uuid_generate_time_safe 2868void *x = uuid_generate_time_safe 2869#endif 2870]])], 2871 [AC_DEFINE(HAVE_UUID_GENERATE_TIME_SAFE, 1, Define if uuid_generate_time_safe() exists.) 2872 AC_MSG_RESULT(yes)], 2873 [AC_MSG_RESULT(no)] 2874) 2875 2876# check for libuuid from util-linux 2877save_LIBS=$LIBS 2878AC_CHECK_LIB([uuid], [uuid_generate_time]) 2879LIBS=$save_LIBS 2880 2881# AIX provides support for RFC4122 (uuid) in libc.a starting with AIX 6.1 (anno 2007) 2882# FreeBSD and OpenBSD provides support in libc as well. 2883AC_MSG_CHECKING(for uuid_create) 2884AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <uuid.h>]], [[ 2885#ifndef uuid_create 2886void *x = uuid_create 2887#endif 2888]])], 2889 [AC_DEFINE(HAVE_UUID_CREATE, 1, Define if uuid_create() exists.) 2890 AC_MSG_RESULT(yes)], 2891 [AC_MSG_RESULT(no)] 2892) 2893 2894# Little-endian FreeBSD, OpenBSD and NetBSD needs encoding into an octet 2895# stream in big-endian byte-order 2896AC_MSG_CHECKING(for uuid_enc_be) 2897AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <uuid.h>]], [[ 2898#ifndef uuid_enc_be 2899void *x = uuid_enc_be 2900#endif 2901]])], 2902 [AC_DEFINE(HAVE_UUID_ENC_BE, 1, Define if uuid_enc_be() exists.) 2903 AC_MSG_RESULT(yes)], 2904 [AC_MSG_RESULT(no)] 2905) 2906 2907# 'Real Time' functions on Solaris 2908# posix4 on Solaris 2.6 2909# pthread (first!) on Linux 2910AC_SEARCH_LIBS(sem_init, pthread rt posix4) 2911 2912# check if we need libintl for locale functions 2913AC_CHECK_LIB(intl, textdomain, 2914 [AC_DEFINE(WITH_LIBINTL, 1, 2915 [Define to 1 if libintl is needed for locale functions.]) 2916 LIBS="-lintl $LIBS"]) 2917 2918# checks for system dependent C++ extensions support 2919case "$ac_sys_system" in 2920 AIX*) AC_MSG_CHECKING(for genuine AIX C++ extensions support) 2921 AC_LINK_IFELSE([ 2922 AC_LANG_PROGRAM([[#include <load.h>]], 2923 [[loadAndInit("", 0, "")]]) 2924 ],[ 2925 AC_DEFINE(AIX_GENUINE_CPLUSPLUS, 1, 2926 [Define for AIX if your compiler is a genuine IBM xlC/xlC_r 2927 and you want support for AIX C++ shared extension modules.]) 2928 AC_MSG_RESULT(yes) 2929 ],[ 2930 AC_MSG_RESULT(no) 2931 ]) 2932dnl The AIX_BUILDDATE is obtained from the kernel fileset - bos.mp64 2933# BUILD_GNU_TYPE + AIX_BUILDDATE are used to construct the platform_tag 2934# of the AIX system used to build/package Python executable. This tag serves 2935# as a baseline for bdist module packages 2936 AC_MSG_CHECKING(for the system builddate) 2937 AIX_BUILDDATE=$(lslpp -Lcq bos.mp64 | awk -F: '{ print $NF }') 2938 AC_DEFINE_UNQUOTED([AIX_BUILDDATE], [$AIX_BUILDDATE], 2939 [BUILD_GNU_TYPE + AIX_BUILDDATE are used to construct the PEP425 tag of the build system.]) 2940 AC_MSG_RESULT($AIX_BUILDDATE) 2941 ;; 2942 *) ;; 2943esac 2944 2945# check for systems that require aligned memory access 2946AC_MSG_CHECKING(aligned memory access is required) 2947AC_CACHE_VAL(ac_cv_aligned_required, 2948[AC_RUN_IFELSE([AC_LANG_SOURCE([[ 2949int main() 2950{ 2951 char s[16]; 2952 int i, *p1, *p2; 2953 for (i=0; i < 16; i++) 2954 s[i] = i; 2955 p1 = (int*)(s+1); 2956 p2 = (int*)(s+2); 2957 if (*p1 == *p2) 2958 return 1; 2959 return 0; 2960}]])], 2961[ac_cv_aligned_required=no], 2962[ac_cv_aligned_required=yes], 2963[ac_cv_aligned_required=yes]) 2964]) 2965AC_MSG_RESULT($ac_cv_aligned_required) 2966if test "$ac_cv_aligned_required" = yes ; then 2967 AC_DEFINE([HAVE_ALIGNED_REQUIRED], [1], 2968 [Define if aligned memory access is required]) 2969fi 2970 2971# str, bytes and memoryview hash algorithm 2972AH_TEMPLATE(Py_HASH_ALGORITHM, 2973 [Define hash algorithm for str, bytes and memoryview. 2974 SipHash24: 1, FNV: 2, externally defined: 0]) 2975 2976AC_MSG_CHECKING(for --with-hash-algorithm) 2977dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output 2978AC_ARG_WITH(hash_algorithm, 2979 AS_HELP_STRING([--with-hash-algorithm=@<:@fnv|siphash24@:>@], 2980 [select hash algorithm for use in Python/pyhash.c (default is SipHash24)]), 2981[ 2982AC_MSG_RESULT($withval) 2983case "$withval" in 2984 siphash24) 2985 AC_DEFINE(Py_HASH_ALGORITHM, 1) 2986 ;; 2987 fnv) 2988 AC_DEFINE(Py_HASH_ALGORITHM, 2) 2989 ;; 2990 *) 2991 AC_MSG_ERROR([unknown hash algorithm '$withval']) 2992 ;; 2993esac 2994], 2995[AC_MSG_RESULT(default)]) 2996 2997validate_tzpath() { 2998 # Checks that each element of hte path is an absolute path 2999 if test -z "$1"; then 3000 # Empty string is allowed: it indicates no system TZPATH 3001 return 0 3002 fi 3003 3004 # Bad paths are those that don't start with / 3005 dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output 3006 if ( echo $1 | grep -qE '(^|:)(@<:@^/@:>@|$)' ); then 3007 AC_MSG_ERROR([--with-tzpath must contain only absolute paths, not $1]) 3008 return 1; 3009 fi 3010} 3011 3012TZPATH="/usr/share/zoneinfo:/usr/lib/zoneinfo:/usr/share/lib/zoneinfo:/etc/zoneinfo" 3013AC_MSG_CHECKING(for --with-tzpath) 3014AC_ARG_WITH(tzpath, 3015 AS_HELP_STRING([--with-tzpath=<list of absolute paths separated by pathsep>] 3016 [Select the default time zone search path for zoneinfo.TZPATH]), 3017[ 3018case "$withval" in 3019 yes) 3020 AC_MSG_ERROR([--with-tzpath requires a value]) 3021 ;; 3022 *) 3023 validate_tzpath "$withval" 3024 TZPATH="$withval" 3025 AC_MSG_RESULT("$withval") 3026 ;; 3027esac 3028], 3029[validate_tzpath "$TZPATH" 3030 AC_MSG_RESULT("$TZPATH")]) 3031AC_SUBST(TZPATH) 3032 3033AC_MSG_CHECKING(for --with-address-sanitizer) 3034AC_ARG_WITH(address_sanitizer, 3035 AS_HELP_STRING([--with-address-sanitizer], 3036 [enable AddressSanitizer memory error detector, 'asan' (default is no)]), 3037[ 3038AC_MSG_RESULT($withval) 3039BASECFLAGS="-fsanitize=address -fno-omit-frame-pointer $BASECFLAGS" 3040LDFLAGS="-fsanitize=address $LDFLAGS" 3041# ASan works by controlling memory allocation, our own malloc interferes. 3042with_pymalloc="no" 3043], 3044[AC_MSG_RESULT(no)]) 3045 3046AC_MSG_CHECKING(for --with-memory-sanitizer) 3047AC_ARG_WITH(memory_sanitizer, 3048 AS_HELP_STRING([--with-memory-sanitizer], 3049 [enable MemorySanitizer allocation error detector, 'msan' (default is no)]), 3050[ 3051AC_MSG_RESULT($withval) 3052BASECFLAGS="-fsanitize=memory -fsanitize-memory-track-origins=2 -fno-omit-frame-pointer $BASECFLAGS" 3053LDFLAGS="-fsanitize=memory -fsanitize-memory-track-origins=2 $LDFLAGS" 3054# MSan works by controlling memory allocation, our own malloc interferes. 3055with_pymalloc="no" 3056], 3057[AC_MSG_RESULT(no)]) 3058 3059AC_MSG_CHECKING(for --with-undefined-behavior-sanitizer) 3060AC_ARG_WITH(undefined_behavior_sanitizer, 3061 AS_HELP_STRING([--with-undefined-behavior-sanitizer], 3062 [enable UndefinedBehaviorSanitizer undefined behaviour detector, 'ubsan' (default is no)]), 3063[ 3064AC_MSG_RESULT($withval) 3065BASECFLAGS="-fsanitize=undefined $BASECFLAGS" 3066LDFLAGS="-fsanitize=undefined $LDFLAGS" 3067], 3068[AC_MSG_RESULT(no)]) 3069 3070# Most SVR4 platforms (e.g. Solaris) need -lsocket and -lnsl. 3071AC_CHECK_LIB(nsl, t_open, [LIBS="-lnsl $LIBS"]) # SVR4 3072AC_CHECK_LIB(socket, socket, [LIBS="-lsocket $LIBS"], [], $LIBS) # SVR4 sockets 3073 3074AC_MSG_CHECKING(for --with-libs) 3075AC_ARG_WITH(libs, 3076 AS_HELP_STRING([--with-libs='lib1 ...'], [link against additional libs (default is no)]), 3077[ 3078AC_MSG_RESULT($withval) 3079LIBS="$withval $LIBS" 3080], 3081[AC_MSG_RESULT(no)]) 3082 3083PKG_PROG_PKG_CONFIG 3084 3085# Check for use of the system expat library 3086AC_MSG_CHECKING(for --with-system-expat) 3087AC_ARG_WITH(system_expat, 3088 AS_HELP_STRING([--with-system-expat], [build pyexpat module using an installed expat library, see Doc/library/pyexpat.rst (default is no)]), 3089 [], 3090 [with_system_expat="no"]) 3091 3092AC_MSG_RESULT($with_system_expat) 3093 3094# Check for use of the system libffi library 3095AC_MSG_CHECKING(for --with-system-ffi) 3096AC_ARG_WITH(system_ffi, 3097 AS_HELP_STRING([--with-system-ffi], [build _ctypes module using an installed ffi library, see Doc/library/ctypes.rst (default is system-dependent)]),,,) 3098 3099if test "$ac_sys_system" = "Darwin" 3100then 3101 case "$with_system_ffi" in 3102 "") 3103 with_system_ffi="no" 3104 ;; 3105 yes|no) 3106 ;; 3107 *) 3108 AC_MSG_ERROR([--with-system-ffi accepts no arguments]) 3109 ;; 3110 esac 3111 AC_MSG_RESULT($with_system_ffi) 3112else 3113 AC_MSG_RESULT(yes) 3114 if test "$with_system_ffi" != "" 3115 then 3116 AC_MSG_WARN([--with(out)-system-ffi is ignored on this platform]) 3117 fi 3118 with_system_ffi="yes" 3119fi 3120 3121if test "$with_system_ffi" = "yes" && test -n "$PKG_CONFIG"; then 3122 LIBFFI_INCLUDEDIR="`"$PKG_CONFIG" libffi --cflags-only-I 2>/dev/null | sed -e 's/^-I//;s/ *$//'`" 3123else 3124 LIBFFI_INCLUDEDIR="" 3125fi 3126AC_SUBST(LIBFFI_INCLUDEDIR) 3127 3128# Check for use of the system libmpdec library 3129AC_MSG_CHECKING(for --with-system-libmpdec) 3130AC_ARG_WITH(system_libmpdec, 3131 AS_HELP_STRING([--with-system-libmpdec], [build _decimal module using an installed libmpdec library, see Doc/library/decimal.rst (default is no)]), 3132 [], 3133 [with_system_libmpdec="no"]) 3134 3135AC_MSG_RESULT($with_system_libmpdec) 3136 3137# Check whether _decimal should use a coroutine-local or thread-local context 3138AC_MSG_CHECKING(for --with-decimal-contextvar) 3139AC_ARG_WITH(decimal_contextvar, 3140 AS_HELP_STRING([--with-decimal-contextvar], [build _decimal module using a coroutine-local rather than a thread-local context (default is yes)]), 3141 [], 3142 [with_decimal_contextvar="yes"]) 3143 3144if test "$with_decimal_contextvar" != "no" 3145then 3146 AC_DEFINE(WITH_DECIMAL_CONTEXTVAR, 1, 3147 [Define if you want build the _decimal module using a coroutine-local rather than a thread-local context]) 3148fi 3149 3150AC_MSG_RESULT($with_decimal_contextvar) 3151 3152# Check for support for loadable sqlite extensions 3153AC_MSG_CHECKING(for --enable-loadable-sqlite-extensions) 3154AC_ARG_ENABLE(loadable-sqlite-extensions, 3155 AS_HELP_STRING([--enable-loadable-sqlite-extensions], 3156 [support loadable extensions in _sqlite module, see Doc/library/sqlite3.rst (default is no)]), 3157 [], 3158 [enable_loadable_sqlite_extensions="no"]) 3159 3160AC_MSG_RESULT($enable_loadable_sqlite_extensions) 3161 3162# Check for --with-tcltk-includes=path and --with-tcltk-libs=path 3163AC_SUBST(TCLTK_INCLUDES) 3164AC_SUBST(TCLTK_LIBS) 3165AC_MSG_CHECKING(for --with-tcltk-includes) 3166AC_ARG_WITH(tcltk-includes, 3167 AS_HELP_STRING([--with-tcltk-includes='-I...'], [override search for Tcl and Tk include files]), 3168 [], 3169 [with_tcltk_includes="default"]) 3170AC_MSG_RESULT($with_tcltk_includes) 3171AC_MSG_CHECKING(for --with-tcltk-libs) 3172AC_ARG_WITH(tcltk-libs, 3173 AS_HELP_STRING([--with-tcltk-libs='-L...'], [override search for Tcl and Tk libs]), 3174 [], 3175 [with_tcltk_libs="default"]) 3176AC_MSG_RESULT($with_tcltk_libs) 3177if test "x$with_tcltk_includes" = xdefault || test "x$with_tcltk_libs" = xdefault 3178then 3179 if test "x$with_tcltk_includes" != "x$with_tcltk_libs" 3180 then 3181 AC_MSG_ERROR([use both --with-tcltk-includes='...' and --with-tcltk-libs='...' or neither]) 3182 fi 3183 TCLTK_INCLUDES="" 3184 TCLTK_LIBS="" 3185else 3186 TCLTK_INCLUDES="$with_tcltk_includes" 3187 TCLTK_LIBS="$with_tcltk_libs" 3188fi 3189 3190# Check for --with-dbmliborder 3191AC_MSG_CHECKING(for --with-dbmliborder) 3192AC_ARG_WITH(dbmliborder, 3193 AS_HELP_STRING([--with-dbmliborder=db1:db2:...], [override order to check db backends for dbm; a valid value is a colon separated string with the backend names `ndbm', `gdbm' and `bdb'.]), 3194[ 3195if test x$with_dbmliborder = xyes 3196then 3197AC_MSG_ERROR([proper usage is --with-dbmliborder=db1:db2:...]) 3198else 3199 for db in `echo $with_dbmliborder | sed 's/:/ /g'`; do 3200 if test x$db != xndbm && test x$db != xgdbm && test x$db != xbdb 3201 then 3202 AC_MSG_ERROR([proper usage is --with-dbmliborder=db1:db2:...]) 3203 fi 3204 done 3205fi]) 3206AC_MSG_RESULT($with_dbmliborder) 3207 3208# Templates for things AC_DEFINEd more than once. 3209# For a single AC_DEFINE, no template is needed. 3210AH_TEMPLATE(_REENTRANT, 3211 [Define to force use of thread-safe errno, h_errno, and other functions]) 3212 3213if test "$ac_cv_pthread_is_default" = yes 3214then 3215 # Defining _REENTRANT on system with POSIX threads should not hurt. 3216 AC_DEFINE(_REENTRANT) 3217 posix_threads=yes 3218 if test "$ac_sys_system" = "SunOS"; then 3219 CFLAGS="$CFLAGS -D_REENTRANT" 3220 fi 3221elif test "$ac_cv_kpthread" = "yes" 3222then 3223 CC="$CC -Kpthread" 3224 if test "$ac_cv_cxx_thread" = "yes"; then 3225 CXX="$CXX -Kpthread" 3226 fi 3227 posix_threads=yes 3228elif test "$ac_cv_kthread" = "yes" 3229then 3230 CC="$CC -Kthread" 3231 if test "$ac_cv_cxx_thread" = "yes"; then 3232 CXX="$CXX -Kthread" 3233 fi 3234 posix_threads=yes 3235elif test "$ac_cv_pthread" = "yes" 3236then 3237 CC="$CC -pthread" 3238 if test "$ac_cv_cxx_thread" = "yes"; then 3239 CXX="$CXX -pthread" 3240 fi 3241 posix_threads=yes 3242else 3243 if test ! -z "$withval" -a -d "$withval" 3244 then LDFLAGS="$LDFLAGS -L$withval" 3245 fi 3246 3247 # According to the POSIX spec, a pthreads implementation must 3248 # define _POSIX_THREADS in unistd.h. Some apparently don't 3249 # (e.g. gnu pth with pthread emulation) 3250 AC_MSG_CHECKING(for _POSIX_THREADS in unistd.h) 3251 AC_EGREP_CPP(yes, 3252 [ 3253#include <unistd.h> 3254#ifdef _POSIX_THREADS 3255yes 3256#endif 3257 ], unistd_defines_pthreads=yes, unistd_defines_pthreads=no) 3258 AC_MSG_RESULT($unistd_defines_pthreads) 3259 3260 AC_DEFINE(_REENTRANT) 3261 # Just looking for pthread_create in libpthread is not enough: 3262 # on HP/UX, pthread.h renames pthread_create to a different symbol name. 3263 # So we really have to include pthread.h, and then link. 3264 _libs=$LIBS 3265 LIBS="$LIBS -lpthread" 3266 AC_MSG_CHECKING([for pthread_create in -lpthread]) 3267 AC_LINK_IFELSE([AC_LANG_PROGRAM([[ 3268#include <stdio.h> 3269#include <pthread.h> 3270 3271void * start_routine (void *arg) { exit (0); }]], [[ 3272pthread_create (NULL, NULL, start_routine, NULL)]])],[ 3273 AC_MSG_RESULT(yes) 3274 posix_threads=yes 3275 ],[ 3276 LIBS=$_libs 3277 AC_CHECK_FUNC(pthread_detach, [ 3278 posix_threads=yes 3279 ],[ 3280 AC_CHECK_LIB(pthreads, pthread_create, [ 3281 posix_threads=yes 3282 LIBS="$LIBS -lpthreads" 3283 ], [ 3284 AC_CHECK_LIB(c_r, pthread_create, [ 3285 posix_threads=yes 3286 LIBS="$LIBS -lc_r" 3287 ], [ 3288 AC_CHECK_LIB(pthread, __pthread_create_system, [ 3289 posix_threads=yes 3290 LIBS="$LIBS -lpthread" 3291 ], [ 3292 AC_CHECK_LIB(cma, pthread_create, [ 3293 posix_threads=yes 3294 LIBS="$LIBS -lcma" 3295 ],[ 3296 AC_MSG_ERROR([could not find pthreads on your system]) 3297 ]) 3298 ])])])])]) 3299 3300 AC_CHECK_LIB(mpc, usconfig, [ 3301 LIBS="$LIBS -lmpc" 3302 ]) 3303 3304fi 3305 3306if test "$posix_threads" = "yes"; then 3307 if test "$unistd_defines_pthreads" = "no"; then 3308 AC_DEFINE(_POSIX_THREADS, 1, 3309 [Define if you have POSIX threads, 3310 and your system does not define that.]) 3311 fi 3312 3313 # Bug 662787: Using semaphores causes unexplicable hangs on Solaris 8. 3314 case $ac_sys_system/$ac_sys_release in 3315 SunOS/5.6) AC_DEFINE(HAVE_PTHREAD_DESTRUCTOR, 1, 3316 [Defined for Solaris 2.6 bug in pthread header.]) 3317 ;; 3318 SunOS/5.8) AC_DEFINE(HAVE_BROKEN_POSIX_SEMAPHORES, 1, 3319 [Define if the Posix semaphores do not work on your system]) 3320 ;; 3321 AIX/*) AC_DEFINE(HAVE_BROKEN_POSIX_SEMAPHORES, 1, 3322 [Define if the Posix semaphores do not work on your system]) 3323 ;; 3324 esac 3325 3326 AC_MSG_CHECKING(if PTHREAD_SCOPE_SYSTEM is supported) 3327 AC_CACHE_VAL(ac_cv_pthread_system_supported, 3328 [AC_RUN_IFELSE([AC_LANG_SOURCE([[ 3329 #include <stdio.h> 3330 #include <pthread.h> 3331 void *foo(void *parm) { 3332 return NULL; 3333 } 3334 main() { 3335 pthread_attr_t attr; 3336 pthread_t id; 3337 if (pthread_attr_init(&attr)) return (-1); 3338 if (pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM)) return (-1); 3339 if (pthread_create(&id, &attr, foo, NULL)) return (-1); 3340 return (0); 3341 }]])], 3342 [ac_cv_pthread_system_supported=yes], 3343 [ac_cv_pthread_system_supported=no], 3344 [ac_cv_pthread_system_supported=no]) 3345 ]) 3346 AC_MSG_RESULT($ac_cv_pthread_system_supported) 3347 if test "$ac_cv_pthread_system_supported" = "yes"; then 3348 AC_DEFINE(PTHREAD_SYSTEM_SCHED_SUPPORTED, 1, [Defined if PTHREAD_SCOPE_SYSTEM supported.]) 3349 fi 3350 AC_CHECK_FUNCS(pthread_sigmask, 3351 [case $ac_sys_system in 3352 CYGWIN*) 3353 AC_DEFINE(HAVE_BROKEN_PTHREAD_SIGMASK, 1, 3354 [Define if pthread_sigmask() does not work on your system.]) 3355 ;; 3356 esac]) 3357 AC_CHECK_FUNCS(pthread_getcpuclockid) 3358fi 3359 3360 3361# Check for enable-ipv6 3362AH_TEMPLATE(ENABLE_IPV6, [Define if --enable-ipv6 is specified]) 3363AC_MSG_CHECKING([if --enable-ipv6 is specified]) 3364AC_ARG_ENABLE(ipv6, 3365 AS_HELP_STRING([--enable-ipv6], 3366 [enable ipv6 (with ipv4) support, see Doc/library/socket.rst (default is yes if supported)]), 3367[ case "$enableval" in 3368 no) 3369 AC_MSG_RESULT(no) 3370 ipv6=no 3371 ;; 3372 *) AC_MSG_RESULT(yes) 3373 AC_DEFINE(ENABLE_IPV6) 3374 ipv6=yes 3375 ;; 3376 esac ], 3377 3378[ 3379dnl the check does not work on cross compilation case... 3380 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ /* AF_INET6 available check */ 3381#include <sys/types.h> 3382#include <sys/socket.h>]], 3383[[int domain = AF_INET6;]])],[ 3384 AC_MSG_RESULT(yes) 3385 ipv6=yes 3386],[ 3387 AC_MSG_RESULT(no) 3388 ipv6=no 3389]) 3390 3391if test "$ipv6" = "yes"; then 3392 AC_MSG_CHECKING(if RFC2553 API is available) 3393 AC_COMPILE_IFELSE([ 3394 AC_LANG_PROGRAM([[#include <sys/types.h> 3395#include <netinet/in.h>]], 3396 [[struct sockaddr_in6 x; 3397 x.sin6_scope_id;]]) 3398 ],[ 3399 AC_MSG_RESULT(yes) 3400 ipv6=yes 3401 ],[ 3402 AC_MSG_RESULT(no, IPv6 disabled) 3403 ipv6=no 3404 ]) 3405fi 3406 3407if test "$ipv6" = "yes"; then 3408 AC_DEFINE(ENABLE_IPV6) 3409fi 3410]) 3411 3412ipv6type=unknown 3413ipv6lib=none 3414ipv6trylibc=no 3415 3416if test "$ipv6" = "yes"; then 3417 AC_MSG_CHECKING([ipv6 stack type]) 3418 for i in inria kame linux-glibc linux-inet6 solaris toshiba v6d zeta; 3419 do 3420 case $i in 3421 inria) 3422 dnl http://www.kame.net/ 3423 AC_EGREP_CPP(yes, [ 3424#include <netinet/in.h> 3425#ifdef IPV6_INRIA_VERSION 3426yes 3427#endif], 3428 [ipv6type=$i]) 3429 ;; 3430 kame) 3431 dnl http://www.kame.net/ 3432 AC_EGREP_CPP(yes, [ 3433#include <netinet/in.h> 3434#ifdef __KAME__ 3435yes 3436#endif], 3437 [ipv6type=$i; 3438 ipv6lib=inet6 3439 ipv6libdir=/usr/local/v6/lib 3440 ipv6trylibc=yes]) 3441 ;; 3442 linux-glibc) 3443 dnl http://www.v6.linux.or.jp/ 3444 AC_EGREP_CPP(yes, [ 3445#include <features.h> 3446#if defined(__GLIBC__) && ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1) || (__GLIBC__ > 2)) 3447yes 3448#endif], 3449 [ipv6type=$i; 3450 ipv6trylibc=yes]) 3451 ;; 3452 linux-inet6) 3453 dnl http://www.v6.linux.or.jp/ 3454 if test -d /usr/inet6; then 3455 ipv6type=$i 3456 ipv6lib=inet6 3457 ipv6libdir=/usr/inet6/lib 3458 BASECFLAGS="-I/usr/inet6/include $BASECFLAGS" 3459 fi 3460 ;; 3461 solaris) 3462 if test -f /etc/netconfig; then 3463 if $GREP -q tcp6 /etc/netconfig; then 3464 ipv6type=$i 3465 ipv6trylibc=yes 3466 fi 3467 fi 3468 ;; 3469 toshiba) 3470 AC_EGREP_CPP(yes, [ 3471#include <sys/param.h> 3472#ifdef _TOSHIBA_INET6 3473yes 3474#endif], 3475 [ipv6type=$i; 3476 ipv6lib=inet6; 3477 ipv6libdir=/usr/local/v6/lib]) 3478 ;; 3479 v6d) 3480 AC_EGREP_CPP(yes, [ 3481#include </usr/local/v6/include/sys/v6config.h> 3482#ifdef __V6D__ 3483yes 3484#endif], 3485 [ipv6type=$i; 3486 ipv6lib=v6; 3487 ipv6libdir=/usr/local/v6/lib; 3488 BASECFLAGS="-I/usr/local/v6/include $BASECFLAGS"]) 3489 ;; 3490 zeta) 3491 AC_EGREP_CPP(yes, [ 3492#include <sys/param.h> 3493#ifdef _ZETA_MINAMI_INET6 3494yes 3495#endif], 3496 [ipv6type=$i; 3497 ipv6lib=inet6; 3498 ipv6libdir=/usr/local/v6/lib]) 3499 ;; 3500 esac 3501 if test "$ipv6type" != "unknown"; then 3502 break 3503 fi 3504 done 3505 AC_MSG_RESULT($ipv6type) 3506fi 3507 3508if test "$ipv6" = "yes" -a "$ipv6lib" != "none"; then 3509 if test -d $ipv6libdir -a -f $ipv6libdir/lib$ipv6lib.a; then 3510 LIBS="-L$ipv6libdir -l$ipv6lib $LIBS" 3511 echo "using lib$ipv6lib" 3512 else 3513 if test $ipv6trylibc = "yes"; then 3514 echo "using libc" 3515 else 3516 echo 'Fatal: no $ipv6lib library found. cannot continue.' 3517 echo "You need to fetch lib$ipv6lib.a from appropriate" 3518 echo 'ipv6 kit and compile beforehand.' 3519 exit 1 3520 fi 3521 fi 3522fi 3523 3524AC_MSG_CHECKING(for CAN_RAW_FD_FRAMES) 3525AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ /* CAN_RAW_FD_FRAMES available check */ 3526#include <linux/can/raw.h>]], 3527[[int can_raw_fd_frames = CAN_RAW_FD_FRAMES;]])],[ 3528 AC_DEFINE(HAVE_LINUX_CAN_RAW_FD_FRAMES, 1, [Define if compiling using Linux 3.6 or later.]) 3529 AC_MSG_RESULT(yes) 3530],[ 3531 AC_MSG_RESULT(no) 3532]) 3533 3534AC_MSG_CHECKING(for CAN_RAW_JOIN_FILTERS) 3535AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 3536#include <linux/can/raw.h>]], 3537[[int can_raw_join_filters = CAN_RAW_JOIN_FILTERS;]])],[ 3538 AC_DEFINE(HAVE_LINUX_CAN_RAW_JOIN_FILTERS, 1, [Define if compiling using Linux 4.1 or later.]) 3539 AC_MSG_RESULT(yes) 3540],[ 3541 AC_MSG_RESULT(no) 3542]) 3543 3544# Check for --with-doc-strings 3545AC_MSG_CHECKING(for --with-doc-strings) 3546AC_ARG_WITH(doc-strings, 3547 AS_HELP_STRING([--with-doc-strings], [enable documentation strings (default is yes)])) 3548 3549if test -z "$with_doc_strings" 3550then with_doc_strings="yes" 3551fi 3552if test "$with_doc_strings" != "no" 3553then 3554 AC_DEFINE(WITH_DOC_STRINGS, 1, 3555 [Define if you want documentation strings in extension modules]) 3556fi 3557AC_MSG_RESULT($with_doc_strings) 3558 3559# Check for Python-specific malloc support 3560AC_MSG_CHECKING(for --with-pymalloc) 3561AC_ARG_WITH(pymalloc, 3562 AS_HELP_STRING([--with-pymalloc], [enable specialized mallocs (default is yes)])) 3563 3564if test -z "$with_pymalloc" 3565then 3566 with_pymalloc="yes" 3567fi 3568if test "$with_pymalloc" != "no" 3569then 3570 AC_DEFINE(WITH_PYMALLOC, 1, 3571 [Define if you want to compile in Python-specific mallocs]) 3572fi 3573AC_MSG_RESULT($with_pymalloc) 3574 3575# Check for --with-c-locale-coercion 3576AC_MSG_CHECKING(for --with-c-locale-coercion) 3577AC_ARG_WITH(c-locale-coercion, 3578 AS_HELP_STRING([--with-c-locale-coercion], 3579 [enable C locale coercion to a UTF-8 based locale (default is yes)])) 3580 3581if test -z "$with_c_locale_coercion" 3582then 3583 with_c_locale_coercion="yes" 3584fi 3585if test "$with_c_locale_coercion" != "no" 3586then 3587 AC_DEFINE(PY_COERCE_C_LOCALE, 1, 3588 [Define if you want to coerce the C locale to a UTF-8 based locale]) 3589fi 3590AC_MSG_RESULT($with_c_locale_coercion) 3591 3592# Check for Valgrind support 3593AC_MSG_CHECKING([for --with-valgrind]) 3594AC_ARG_WITH([valgrind], 3595 AS_HELP_STRING([--with-valgrind], [enable Valgrind support (default is no)]),, 3596 with_valgrind=no) 3597AC_MSG_RESULT([$with_valgrind]) 3598if test "$with_valgrind" != no; then 3599 AC_CHECK_HEADER([valgrind/valgrind.h], 3600 [AC_DEFINE([WITH_VALGRIND], 1, [Define if you want pymalloc to be disabled when running under valgrind])], 3601 [AC_MSG_ERROR([Valgrind support requested but headers not available])] 3602 ) 3603 OPT="-DDYNAMIC_ANNOTATIONS_ENABLED=1 $OPT" 3604fi 3605 3606# Check for DTrace support 3607AC_MSG_CHECKING(for --with-dtrace) 3608AC_ARG_WITH(dtrace, 3609 AS_HELP_STRING([--with-dtrace],[enable DTrace support (default is no)]),, 3610 with_dtrace=no) 3611AC_MSG_RESULT($with_dtrace) 3612 3613AC_SUBST(DTRACE) 3614AC_SUBST(DFLAGS) 3615AC_SUBST(DTRACE_HEADERS) 3616AC_SUBST(DTRACE_OBJS) 3617DTRACE= 3618DTRACE_HEADERS= 3619DTRACE_OBJS= 3620 3621if test "$with_dtrace" = "yes" 3622then 3623 AC_PATH_PROG(DTRACE, [dtrace], [not found]) 3624 if test "$DTRACE" = "not found"; then 3625 AC_MSG_ERROR([dtrace command not found on \$PATH]) 3626 fi 3627 AC_DEFINE(WITH_DTRACE, 1, [Define if you want to compile in DTrace support]) 3628 DTRACE_HEADERS="Include/pydtrace_probes.h" 3629 3630 # On OS X, DTrace providers do not need to be explicitly compiled and 3631 # linked into the binary. Correspondingly, dtrace(1) is missing the ELF 3632 # generation flag '-G'. We check for presence of this flag, rather than 3633 # hardcoding support by OS, in the interest of robustness. 3634 AC_CACHE_CHECK([whether DTrace probes require linking], 3635 [ac_cv_dtrace_link], [dnl 3636 ac_cv_dtrace_link=no 3637 echo 'BEGIN{}' > conftest.d 3638 "$DTRACE" $DFLAGS -G -s conftest.d -o conftest.o > /dev/null 2>&1 && \ 3639 ac_cv_dtrace_link=yes 3640 ]) 3641 if test "$ac_cv_dtrace_link" = "yes"; then 3642 DTRACE_OBJS="Python/pydtrace.o" 3643 fi 3644fi 3645 3646# -I${DLINCLDIR} is added to the compile rule for importdl.o 3647AC_SUBST(DLINCLDIR) 3648DLINCLDIR=. 3649 3650# the dlopen() function means we might want to use dynload_shlib.o. some 3651# platforms, such as AIX, have dlopen(), but don't want to use it. 3652AC_CHECK_FUNCS(dlopen) 3653 3654# DYNLOADFILE specifies which dynload_*.o file we will use for dynamic 3655# loading of modules. 3656AC_SUBST(DYNLOADFILE) 3657AC_MSG_CHECKING(DYNLOADFILE) 3658if test -z "$DYNLOADFILE" 3659then 3660 case $ac_sys_system/$ac_sys_release in 3661 AIX*) # Use dynload_shlib.c and dlopen() if we have it; otherwise dynload_aix.c 3662 if test "$ac_cv_func_dlopen" = yes 3663 then DYNLOADFILE="dynload_shlib.o" 3664 else DYNLOADFILE="dynload_aix.o" 3665 fi 3666 ;; 3667 hp*|HP*) DYNLOADFILE="dynload_hpux.o";; 3668 *) 3669 # use dynload_shlib.c and dlopen() if we have it; otherwise stub 3670 # out any dynamic loading 3671 if test "$ac_cv_func_dlopen" = yes 3672 then DYNLOADFILE="dynload_shlib.o" 3673 else DYNLOADFILE="dynload_stub.o" 3674 fi 3675 ;; 3676 esac 3677fi 3678AC_MSG_RESULT($DYNLOADFILE) 3679if test "$DYNLOADFILE" != "dynload_stub.o" 3680then 3681 AC_DEFINE(HAVE_DYNAMIC_LOADING, 1, 3682 [Defined when any dynamic module loading is enabled.]) 3683fi 3684 3685# MACHDEP_OBJS can be set to platform-specific object files needed by Python 3686 3687AC_SUBST(MACHDEP_OBJS) 3688AC_MSG_CHECKING(MACHDEP_OBJS) 3689if test -z "$MACHDEP_OBJS" 3690then 3691 MACHDEP_OBJS=$extra_machdep_objs 3692else 3693 MACHDEP_OBJS="$MACHDEP_OBJS $extra_machdep_objs" 3694fi 3695if test -z "$MACHDEP_OBJS"; then 3696 AC_MSG_RESULT([none]) 3697else 3698 AC_MSG_RESULT([$MACHDEP_OBJS]) 3699fi 3700 3701# checks for library functions 3702AC_CHECK_FUNCS(alarm accept4 setitimer getitimer bind_textdomain_codeset chown \ 3703 clock confstr close_range copy_file_range ctermid dup3 execv explicit_bzero \ 3704 explicit_memset faccessat fchmod fchmodat fchown fchownat \ 3705 fdwalk fexecve fdopendir fork fpathconf fstatat ftime ftruncate futimesat \ 3706 futimens futimes gai_strerror getentropy \ 3707 getgrgid_r getgrnam_r \ 3708 getgrouplist getgroups getlogin getloadavg getpeername getpgid getpid \ 3709 getpriority getresuid getresgid getpwent getpwnam_r getpwuid_r getspnam getspent getsid getwd \ 3710 if_nameindex \ 3711 initgroups kill killpg lchown lockf linkat lstat lutimes mmap \ 3712 memrchr mbrtowc mkdirat mkfifo \ 3713 madvise mkfifoat mknod mknodat mktime mremap nice openat pathconf pause pipe2 plock poll \ 3714 posix_fallocate posix_fadvise posix_spawn posix_spawnp pread preadv preadv2 \ 3715 pthread_condattr_setclock pthread_init pthread_kill pwrite pwritev pwritev2 \ 3716 readlink readlinkat readv realpath renameat \ 3717 sem_open sem_timedwait sem_clockwait sem_getvalue sem_unlink sendfile setegid seteuid \ 3718 setgid sethostname \ 3719 setlocale setregid setreuid setresuid setresgid setsid setpgid setpgrp setpriority setuid setvbuf \ 3720 sched_get_priority_max sched_setaffinity sched_setscheduler sched_setparam \ 3721 sched_rr_get_interval \ 3722 sigaction sigaltstack sigfillset siginterrupt sigpending sigrelse \ 3723 sigtimedwait sigwait sigwaitinfo snprintf strftime strlcpy strsignal symlinkat sync \ 3724 sysconf tcgetpgrp tcsetpgrp tempnam timegm times tmpfile tmpnam tmpnam_r \ 3725 truncate uname unlinkat utimensat utimes waitid waitpid wait3 wait4 \ 3726 wcscoll wcsftime wcsxfrm wmemcmp writev _getpty rtpSpawn) 3727 3728# Force lchmod off for Linux. Linux disallows changing the mode of symbolic 3729# links. Some libc implementations have a stub lchmod implementation that always 3730# returns an error. 3731if test "$MACHDEP" != linux; then 3732 AC_CHECK_FUNCS(lchmod) 3733fi 3734 3735AC_CHECK_DECL(dirfd, 3736 AC_DEFINE(HAVE_DIRFD, 1, 3737 Define if you have the 'dirfd' function or macro.), , 3738 [#include <sys/types.h> 3739 #include <dirent.h>]) 3740 3741# For some functions, having a definition is not sufficient, since 3742# we want to take their address. 3743AC_MSG_CHECKING(for chroot) 3744AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[void *x=chroot]])], 3745 [AC_DEFINE(HAVE_CHROOT, 1, Define if you have the 'chroot' function.) 3746 AC_MSG_RESULT(yes)], 3747 [AC_MSG_RESULT(no) 3748]) 3749AC_MSG_CHECKING(for link) 3750AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[void *x=link]])], 3751 [AC_DEFINE(HAVE_LINK, 1, Define if you have the 'link' function.) 3752 AC_MSG_RESULT(yes)], 3753 [AC_MSG_RESULT(no) 3754]) 3755AC_MSG_CHECKING(for symlink) 3756AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[void *x=symlink]])], 3757 [AC_DEFINE(HAVE_SYMLINK, 1, Define if you have the 'symlink' function.) 3758 AC_MSG_RESULT(yes)], 3759 [AC_MSG_RESULT(no) 3760]) 3761AC_MSG_CHECKING(for fchdir) 3762AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[void *x=fchdir]])], 3763 [AC_DEFINE(HAVE_FCHDIR, 1, Define if you have the 'fchdir' function.) 3764 AC_MSG_RESULT(yes)], 3765 [AC_MSG_RESULT(no) 3766]) 3767AC_MSG_CHECKING(for fsync) 3768AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[void *x=fsync]])], 3769 [AC_DEFINE(HAVE_FSYNC, 1, Define if you have the 'fsync' function.) 3770 AC_MSG_RESULT(yes)], 3771 [AC_MSG_RESULT(no) 3772]) 3773AC_MSG_CHECKING(for fdatasync) 3774AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[void *x=fdatasync]])], 3775 [AC_DEFINE(HAVE_FDATASYNC, 1, Define if you have the 'fdatasync' function.) 3776 AC_MSG_RESULT(yes)], 3777 [AC_MSG_RESULT(no) 3778]) 3779AC_MSG_CHECKING(for epoll) 3780AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/epoll.h>]], [[void *x=epoll_create]])], 3781 [AC_DEFINE(HAVE_EPOLL, 1, Define if you have the 'epoll' functions.) 3782 AC_MSG_RESULT(yes)], 3783 [AC_MSG_RESULT(no) 3784]) 3785AC_MSG_CHECKING(for epoll_create1) 3786AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/epoll.h>]], [[void *x=epoll_create1]])], 3787 [AC_DEFINE(HAVE_EPOLL_CREATE1, 1, Define if you have the 'epoll_create1' function.) 3788 AC_MSG_RESULT(yes)], 3789 [AC_MSG_RESULT(no) 3790]) 3791AC_MSG_CHECKING(for kqueue) 3792AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 3793#include <sys/types.h> 3794#include <sys/event.h> 3795 ]], [[int x=kqueue()]])], 3796 [AC_DEFINE(HAVE_KQUEUE, 1, Define if you have the 'kqueue' functions.) 3797 AC_MSG_RESULT(yes)], 3798 [AC_MSG_RESULT(no) 3799]) 3800AC_MSG_CHECKING(for prlimit) 3801AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 3802#include <sys/time.h> 3803#include <sys/resource.h> 3804 ]], [[void *x=prlimit]])], 3805 [AC_DEFINE(HAVE_PRLIMIT, 1, Define if you have the 'prlimit' functions.) 3806 AC_MSG_RESULT(yes)], 3807 [AC_MSG_RESULT(no) 3808]) 3809AC_MSG_CHECKING(for _dyld_shared_cache_contains_path) 3810AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <mach-o/dyld.h>]], [[void *x=_dyld_shared_cache_contains_path]])], 3811 [AC_DEFINE(HAVE_DYLD_SHARED_CACHE_CONTAINS_PATH, 1, Define if you have the '_dyld_shared_cache_contains_path' function.) 3812 AC_MSG_RESULT(yes)], 3813 [AC_MSG_RESULT(no) 3814]) 3815 3816AC_MSG_CHECKING(for memfd_create) 3817AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 3818#ifdef HAVE_SYS_MMAN_H 3819#include <sys/mman.h> 3820#endif 3821#ifdef HAVE_SYS_MEMFD_H 3822#include <sys/memfd.h> 3823#endif 3824]], [[void *x=memfd_create]])], 3825 [AC_DEFINE(HAVE_MEMFD_CREATE, 1, Define if you have the 'memfd_create' function.) 3826 AC_MSG_RESULT(yes)], 3827 [AC_MSG_RESULT(no) 3828]) 3829 3830# On some systems (eg. FreeBSD 5), we would find a definition of the 3831# functions ctermid_r, setgroups in the library, but no prototype 3832# (e.g. because we use _XOPEN_SOURCE). See whether we can take their 3833# address to avoid compiler warnings and potential miscompilations 3834# because of the missing prototypes. 3835 3836AC_MSG_CHECKING(for ctermid_r) 3837AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 3838#include <stdio.h> 3839]], [[void* p = ctermid_r]])], 3840 [AC_DEFINE(HAVE_CTERMID_R, 1, Define if you have the 'ctermid_r' function.) 3841 AC_MSG_RESULT(yes)], 3842 [AC_MSG_RESULT(no) 3843]) 3844 3845AC_CACHE_CHECK([for flock declaration], [ac_cv_flock_decl], 3846 [AC_COMPILE_IFELSE( 3847 [AC_LANG_PROGRAM( 3848 [#include <sys/file.h>], 3849 [void* p = flock] 3850 )], 3851 [ac_cv_flock_decl=yes], 3852 [ac_cv_flock_decl=no] 3853 ) 3854]) 3855if test "x${ac_cv_flock_decl}" = xyes; then 3856 AC_CHECK_FUNCS(flock,, 3857 AC_CHECK_LIB(bsd,flock, 3858 [AC_DEFINE(HAVE_FLOCK) 3859 AC_DEFINE(FLOCK_NEEDS_LIBBSD, 1, Define if flock needs to be linked with bsd library.) 3860 ]) 3861 ) 3862fi 3863 3864AC_MSG_CHECKING(for getpagesize) 3865AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 3866#include <unistd.h> 3867]], [[void* p = getpagesize]])], 3868 [AC_DEFINE(HAVE_GETPAGESIZE, 1, Define if you have the 'getpagesize' function.) 3869 AC_MSG_RESULT(yes)], 3870 [AC_MSG_RESULT(no) 3871]) 3872 3873AC_MSG_CHECKING(for broken unsetenv) 3874AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 3875#include <stdlib.h> 3876]], [[int res = unsetenv("DUMMY")]])], 3877 [AC_MSG_RESULT(no)], 3878 [AC_DEFINE(HAVE_BROKEN_UNSETENV, 1, Define if `unsetenv` does not return an int.) 3879 AC_MSG_RESULT(yes) 3880]) 3881 3882dnl check for true 3883AC_CHECK_PROGS(TRUE, true, /bin/true) 3884 3885dnl On some systems (e.g. Solaris 9), hstrerror and inet_aton are in -lresolv 3886dnl On others, they are in the C library, so we to take no action 3887AC_CHECK_LIB(c, inet_aton, [$ac_cv_prog_TRUE], 3888 AC_CHECK_LIB(resolv, inet_aton) 3889) 3890 3891# On Tru64, chflags seems to be present, but calling it will 3892# exit Python 3893AC_CACHE_CHECK([for chflags], [ac_cv_have_chflags], [dnl 3894AC_RUN_IFELSE([AC_LANG_SOURCE([[ 3895#include <sys/stat.h> 3896#include <unistd.h> 3897int main(int argc, char*argv[]) 3898{ 3899 if(chflags(argv[0], 0) != 0) 3900 return 1; 3901 return 0; 3902} 3903]])], 3904[ac_cv_have_chflags=yes], 3905[ac_cv_have_chflags=no], 3906[ac_cv_have_chflags=cross]) 3907]) 3908if test "$ac_cv_have_chflags" = cross ; then 3909 AC_CHECK_FUNC([chflags], [ac_cv_have_chflags="yes"], [ac_cv_have_chflags="no"]) 3910fi 3911if test "$ac_cv_have_chflags" = yes ; then 3912 AC_DEFINE(HAVE_CHFLAGS, 1, [Define to 1 if you have the 'chflags' function.]) 3913fi 3914 3915AC_CACHE_CHECK([for lchflags], [ac_cv_have_lchflags], [dnl 3916AC_RUN_IFELSE([AC_LANG_SOURCE([[ 3917#include <sys/stat.h> 3918#include <unistd.h> 3919int main(int argc, char*argv[]) 3920{ 3921 if(lchflags(argv[0], 0) != 0) 3922 return 1; 3923 return 0; 3924} 3925]])],[ac_cv_have_lchflags=yes],[ac_cv_have_lchflags=no],[ac_cv_have_lchflags=cross]) 3926]) 3927if test "$ac_cv_have_lchflags" = cross ; then 3928 AC_CHECK_FUNC([lchflags], [ac_cv_have_lchflags="yes"], [ac_cv_have_lchflags="no"]) 3929fi 3930if test "$ac_cv_have_lchflags" = yes ; then 3931 AC_DEFINE(HAVE_LCHFLAGS, 1, [Define to 1 if you have the 'lchflags' function.]) 3932fi 3933 3934dnl Check if system zlib has *Copy() functions 3935dnl 3936dnl On MacOSX the linker will search for dylibs on the entire linker path 3937dnl before searching for static libraries. setup.py adds -Wl,-search_paths_first 3938dnl to revert to a more traditional unix behaviour and make it possible to 3939dnl override the system libz with a local static library of libz. Temporarily 3940dnl add that flag to our CFLAGS as well to ensure that we check the version 3941dnl of libz that will be used by setup.py. 3942dnl The -L/usr/local/lib is needed as wel to get the same compilation 3943dnl environment as setup.py (and leaving it out can cause configure to use the 3944dnl wrong version of the library) 3945case $ac_sys_system/$ac_sys_release in 3946Darwin/*) 3947 _CUR_CFLAGS="${CFLAGS}" 3948 _CUR_LDFLAGS="${LDFLAGS}" 3949 CFLAGS="${CFLAGS} -Wl,-search_paths_first" 3950 LDFLAGS="${LDFLAGS} -Wl,-search_paths_first -L/usr/local/lib" 3951 ;; 3952esac 3953 3954AC_CHECK_LIB(z, inflateCopy, AC_DEFINE(HAVE_ZLIB_COPY, 1, [Define if the zlib library has inflateCopy])) 3955 3956case $ac_sys_system/$ac_sys_release in 3957Darwin/*) 3958 CFLAGS="${_CUR_CFLAGS}" 3959 LDFLAGS="${_CUR_LDFLAGS}" 3960 ;; 3961esac 3962 3963AC_MSG_CHECKING(for hstrerror) 3964AC_LINK_IFELSE([AC_LANG_PROGRAM([[ 3965#include <netdb.h> 3966]], [[void* p = hstrerror; hstrerror(0)]])], 3967 [AC_DEFINE(HAVE_HSTRERROR, 1, Define if you have the 'hstrerror' function.) 3968 AC_MSG_RESULT(yes)], 3969 [AC_MSG_RESULT(no) 3970]) 3971 3972AC_MSG_CHECKING(for inet_aton) 3973AC_LINK_IFELSE([AC_LANG_PROGRAM([[ 3974#include <sys/types.h> 3975#include <sys/socket.h> 3976#include <netinet/in.h> 3977#include <arpa/inet.h> 3978]], [[void* p = inet_aton;inet_aton(0,0)]])], 3979 [AC_DEFINE(HAVE_INET_ATON, 1, Define if you have the 'inet_aton' function.) 3980 AC_MSG_RESULT(yes)], 3981 [AC_MSG_RESULT(no) 3982]) 3983 3984AC_MSG_CHECKING(for inet_pton) 3985AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 3986#include <sys/types.h> 3987#include <sys/socket.h> 3988#include <netinet/in.h> 3989#include <arpa/inet.h> 3990]], [[void* p = inet_pton]])], 3991 [AC_DEFINE(HAVE_INET_PTON, 1, Define if you have the 'inet_pton' function.) 3992 AC_MSG_RESULT(yes)], 3993 [AC_MSG_RESULT(no) 3994]) 3995 3996# On some systems, setgroups is in unistd.h, on others, in grp.h 3997AC_MSG_CHECKING(for setgroups) 3998AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 3999#include <unistd.h> 4000#ifdef HAVE_GRP_H 4001#include <grp.h> 4002#endif 4003]], [[void* p = setgroups]])], 4004 [AC_DEFINE(HAVE_SETGROUPS, 1, Define if you have the 'setgroups' function.) 4005 AC_MSG_RESULT(yes)], 4006 [AC_MSG_RESULT(no) 4007]) 4008 4009# check for openpty and forkpty 4010 4011AC_CHECK_FUNCS(openpty,, 4012 AC_CHECK_LIB(util,openpty, 4013 [AC_DEFINE(HAVE_OPENPTY) LIBS="$LIBS -lutil"], 4014 AC_CHECK_LIB(bsd,openpty, [AC_DEFINE(HAVE_OPENPTY) LIBS="$LIBS -lbsd"]) 4015 ) 4016) 4017AC_CHECK_FUNCS(forkpty,, 4018 AC_CHECK_LIB(util,forkpty, 4019 [AC_DEFINE(HAVE_FORKPTY) LIBS="$LIBS -lutil"], 4020 AC_CHECK_LIB(bsd,forkpty, [AC_DEFINE(HAVE_FORKPTY) LIBS="$LIBS -lbsd"]) 4021 ) 4022) 4023 4024# check for long file support functions 4025AC_CHECK_FUNCS(fseek64 fseeko fstatvfs ftell64 ftello statvfs) 4026 4027AC_REPLACE_FUNCS(dup2 strdup) 4028AC_CHECK_FUNCS(getpgrp, 4029 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[getpgrp(0);]])], 4030 [AC_DEFINE(GETPGRP_HAVE_ARG, 1, [Define if getpgrp() must be called as getpgrp(0).])], 4031 []) 4032) 4033AC_CHECK_FUNCS(setpgrp, 4034 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[setpgrp(0,0);]])], 4035 [AC_DEFINE(SETPGRP_HAVE_ARG, 1, [Define if setpgrp() must be called as setpgrp(0, 0).])], 4036 []) 4037) 4038 4039# We search for both crypt and crypt_r as one or the other may be defined 4040# This gets us our -lcrypt in LIBS when required on the target platform. 4041AC_SEARCH_LIBS(crypt, crypt) 4042AC_SEARCH_LIBS(crypt_r, crypt) 4043 4044AC_CHECK_FUNC(crypt_r, 4045 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 4046#define _GNU_SOURCE /* Required for crypt_r()'s prototype in glibc. */ 4047#include <crypt.h> 4048]], [[ 4049struct crypt_data d; 4050char *r = crypt_r("", "", &d); 4051]])], 4052 [AC_DEFINE(HAVE_CRYPT_R, 1, [Define if you have the crypt_r() function.])], 4053 []) 4054) 4055 4056AC_CHECK_FUNCS(clock_gettime, [], [ 4057 AC_CHECK_LIB(rt, clock_gettime, [ 4058 LIBS="$LIBS -lrt" 4059 AC_DEFINE(HAVE_CLOCK_GETTIME, 1) 4060 AC_DEFINE(TIMEMODULE_LIB, [rt], 4061 [Library needed by timemodule.c: librt may be needed for clock_gettime()]) 4062 ]) 4063]) 4064 4065AC_CHECK_FUNCS(clock_getres, [], [ 4066 AC_CHECK_LIB(rt, clock_getres, [ 4067 AC_DEFINE(HAVE_CLOCK_GETRES, 1) 4068 ]) 4069]) 4070 4071AC_CHECK_FUNCS(clock_settime, [], [ 4072 AC_CHECK_LIB(rt, clock_settime, [ 4073 AC_DEFINE(HAVE_CLOCK_SETTIME, 1) 4074 ]) 4075]) 4076 4077AC_MSG_CHECKING(for major, minor, and makedev) 4078AC_LINK_IFELSE([AC_LANG_PROGRAM([[ 4079#if defined(MAJOR_IN_MKDEV) 4080#include <sys/mkdev.h> 4081#elif defined(MAJOR_IN_SYSMACROS) 4082#include <sys/sysmacros.h> 4083#else 4084#include <sys/types.h> 4085#endif 4086]], [[ 4087 makedev(major(0),minor(0)); 4088]])],[ 4089 AC_DEFINE(HAVE_DEVICE_MACROS, 1, 4090 [Define to 1 if you have the device macros.]) 4091 AC_MSG_RESULT(yes) 4092],[ 4093 AC_MSG_RESULT(no) 4094]) 4095 4096# On OSF/1 V5.1, getaddrinfo is available, but a define 4097# for [no]getaddrinfo in netdb.h. 4098AC_MSG_CHECKING(for getaddrinfo) 4099AC_LINK_IFELSE([AC_LANG_PROGRAM([[ 4100#include <sys/types.h> 4101#include <sys/socket.h> 4102#include <netdb.h> 4103#include <stdio.h> 4104]], [[getaddrinfo(NULL, NULL, NULL, NULL);]])], 4105[have_getaddrinfo=yes], 4106[have_getaddrinfo=no]) 4107AC_MSG_RESULT($have_getaddrinfo) 4108if test $have_getaddrinfo = yes 4109then 4110 AC_MSG_CHECKING(getaddrinfo bug) 4111 AC_CACHE_VAL(ac_cv_buggy_getaddrinfo, 4112 AC_RUN_IFELSE([AC_LANG_SOURCE([[[ 4113#include <stdio.h> 4114#include <sys/types.h> 4115#include <netdb.h> 4116#include <string.h> 4117#include <sys/socket.h> 4118#include <netinet/in.h> 4119 4120int main() 4121{ 4122 int passive, gaierr, inet4 = 0, inet6 = 0; 4123 struct addrinfo hints, *ai, *aitop; 4124 char straddr[INET6_ADDRSTRLEN], strport[16]; 4125 4126 for (passive = 0; passive <= 1; passive++) { 4127 memset(&hints, 0, sizeof(hints)); 4128 hints.ai_family = AF_UNSPEC; 4129 hints.ai_flags = passive ? AI_PASSIVE : 0; 4130 hints.ai_socktype = SOCK_STREAM; 4131 hints.ai_protocol = IPPROTO_TCP; 4132 if ((gaierr = getaddrinfo(NULL, "54321", &hints, &aitop)) != 0) { 4133 (void)gai_strerror(gaierr); 4134 goto bad; 4135 } 4136 for (ai = aitop; ai; ai = ai->ai_next) { 4137 if (ai->ai_addr == NULL || 4138 ai->ai_addrlen == 0 || 4139 getnameinfo(ai->ai_addr, ai->ai_addrlen, 4140 straddr, sizeof(straddr), strport, sizeof(strport), 4141 NI_NUMERICHOST|NI_NUMERICSERV) != 0) { 4142 goto bad; 4143 } 4144 switch (ai->ai_family) { 4145 case AF_INET: 4146 if (strcmp(strport, "54321") != 0) { 4147 goto bad; 4148 } 4149 if (passive) { 4150 if (strcmp(straddr, "0.0.0.0") != 0) { 4151 goto bad; 4152 } 4153 } else { 4154 if (strcmp(straddr, "127.0.0.1") != 0) { 4155 goto bad; 4156 } 4157 } 4158 inet4++; 4159 break; 4160 case AF_INET6: 4161 if (strcmp(strport, "54321") != 0) { 4162 goto bad; 4163 } 4164 if (passive) { 4165 if (strcmp(straddr, "::") != 0) { 4166 goto bad; 4167 } 4168 } else { 4169 if (strcmp(straddr, "::1") != 0) { 4170 goto bad; 4171 } 4172 } 4173 inet6++; 4174 break; 4175 case AF_UNSPEC: 4176 goto bad; 4177 break; 4178 default: 4179 /* another family support? */ 4180 break; 4181 } 4182 } 4183 freeaddrinfo(aitop); 4184 aitop = NULL; 4185 } 4186 4187 if (!(inet4 == 0 || inet4 == 2)) 4188 goto bad; 4189 if (!(inet6 == 0 || inet6 == 2)) 4190 goto bad; 4191 4192 if (aitop) 4193 freeaddrinfo(aitop); 4194 return 0; 4195 4196 bad: 4197 if (aitop) 4198 freeaddrinfo(aitop); 4199 return 1; 4200} 4201]]])], 4202[ac_cv_buggy_getaddrinfo=no], 4203[ac_cv_buggy_getaddrinfo=yes], 4204[ 4205if test "${enable_ipv6+set}" = set; then 4206 ac_cv_buggy_getaddrinfo="no -- configured with --(en|dis)able-ipv6" 4207else 4208 ac_cv_buggy_getaddrinfo=yes 4209fi])) 4210fi 4211 4212AC_MSG_RESULT($ac_cv_buggy_getaddrinfo) 4213 4214if test $have_getaddrinfo = no || test "$ac_cv_buggy_getaddrinfo" = yes 4215then 4216 if test $ipv6 = yes 4217 then 4218 echo 'Fatal: You must get working getaddrinfo() function.' 4219 echo ' or you can specify "--disable-ipv6"'. 4220 exit 1 4221 fi 4222else 4223 AC_DEFINE(HAVE_GETADDRINFO, 1, [Define if you have the getaddrinfo function.]) 4224fi 4225 4226AC_CHECK_FUNCS(getnameinfo) 4227 4228# checks for structures 4229AC_HEADER_TIME 4230AC_STRUCT_TM 4231AC_STRUCT_TIMEZONE 4232AC_CHECK_MEMBERS([struct stat.st_rdev]) 4233AC_CHECK_MEMBERS([struct stat.st_blksize]) 4234AC_CHECK_MEMBERS([struct stat.st_flags]) 4235AC_CHECK_MEMBERS([struct stat.st_gen]) 4236AC_CHECK_MEMBERS([struct stat.st_birthtime]) 4237AC_CHECK_MEMBERS([struct stat.st_blocks]) 4238AC_CHECK_MEMBERS([struct passwd.pw_gecos, struct passwd.pw_passwd], [], [], [[ 4239 #include <sys/types.h> 4240 #include <pwd.h> 4241]]) 4242# Issue #21085: In Cygwin, siginfo_t does not have si_band field. 4243AC_CHECK_MEMBERS([siginfo_t.si_band], [], [], [[#include <signal.h>]]) 4244 4245AC_MSG_CHECKING(for time.h that defines altzone) 4246AC_CACHE_VAL(ac_cv_header_time_altzone,[ 4247 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <time.h>]], [[return altzone;]])], 4248 [ac_cv_header_time_altzone=yes], 4249 [ac_cv_header_time_altzone=no]) 4250 ]) 4251AC_MSG_RESULT($ac_cv_header_time_altzone) 4252if test $ac_cv_header_time_altzone = yes; then 4253 AC_DEFINE(HAVE_ALTZONE, 1, [Define this if your time.h defines altzone.]) 4254fi 4255 4256was_it_defined=no 4257AC_MSG_CHECKING(whether sys/select.h and sys/time.h may both be included) 4258AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 4259#include <sys/types.h> 4260#include <sys/select.h> 4261#include <sys/time.h> 4262]], [[;]])],[ 4263 AC_DEFINE(SYS_SELECT_WITH_SYS_TIME, 1, 4264 [Define if you can safely include both <sys/select.h> and <sys/time.h> 4265 (which you can't on SCO ODT 3.0).]) 4266 was_it_defined=yes 4267],[]) 4268AC_MSG_RESULT($was_it_defined) 4269 4270AC_MSG_CHECKING(for addrinfo) 4271AC_CACHE_VAL(ac_cv_struct_addrinfo, 4272AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <netdb.h>]], [[struct addrinfo a]])], 4273 [ac_cv_struct_addrinfo=yes], 4274 [ac_cv_struct_addrinfo=no])) 4275AC_MSG_RESULT($ac_cv_struct_addrinfo) 4276if test $ac_cv_struct_addrinfo = yes; then 4277 AC_DEFINE(HAVE_ADDRINFO, 1, [struct addrinfo (netdb.h)]) 4278fi 4279 4280AC_MSG_CHECKING(for sockaddr_storage) 4281AC_CACHE_VAL(ac_cv_struct_sockaddr_storage, 4282AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 4283# include <sys/types.h> 4284# include <sys/socket.h>]], [[struct sockaddr_storage s]])], 4285 [ac_cv_struct_sockaddr_storage=yes], 4286 [ac_cv_struct_sockaddr_storage=no])) 4287AC_MSG_RESULT($ac_cv_struct_sockaddr_storage) 4288if test $ac_cv_struct_sockaddr_storage = yes; then 4289 AC_DEFINE(HAVE_SOCKADDR_STORAGE, 1, [struct sockaddr_storage (sys/socket.h)]) 4290fi 4291 4292AC_MSG_CHECKING(for sockaddr_alg) 4293AC_CACHE_VAL(ac_cv_struct_sockaddr_alg, 4294AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 4295# include <sys/types.h> 4296# include <sys/socket.h> 4297# include <linux/if_alg.h>]], [[struct sockaddr_alg s]])], 4298 [ac_cv_struct_sockaddr_alg=yes], 4299 [ac_cv_struct_sockaddr_alg=no])) 4300AC_MSG_RESULT($ac_cv_struct_sockaddr_alg) 4301if test $ac_cv_struct_sockaddr_alg = yes; then 4302 AC_DEFINE(HAVE_SOCKADDR_ALG, 1, [struct sockaddr_alg (linux/if_alg.h)]) 4303fi 4304 4305# checks for compiler characteristics 4306 4307AC_C_CHAR_UNSIGNED 4308AC_C_CONST 4309 4310works=no 4311AC_MSG_CHECKING(for working signed char) 4312AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[signed char c;]])], 4313 [works=yes], 4314 [AC_DEFINE(signed, , [Define to empty if the keyword does not work.])] 4315) 4316AC_MSG_RESULT($works) 4317 4318have_prototypes=no 4319AC_MSG_CHECKING(for prototypes) 4320AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[int foo(int x) { return 0; }]], [[return foo(10);]])], 4321 [AC_DEFINE(HAVE_PROTOTYPES, 1, 4322 [Define if your compiler supports function prototype]) 4323 have_prototypes=yes], 4324 [] 4325) 4326AC_MSG_RESULT($have_prototypes) 4327 4328works=no 4329AC_MSG_CHECKING(for variable length prototypes and stdarg.h) 4330AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 4331#include <stdarg.h> 4332int foo(int x, ...) { 4333 va_list va; 4334 va_start(va, x); 4335 va_arg(va, int); 4336 va_arg(va, char *); 4337 va_arg(va, double); 4338 return 0; 4339} 4340]], [[return foo(10, "", 3.14);]])],[ 4341 AC_DEFINE(HAVE_STDARG_PROTOTYPES, 1, 4342 [Define if your compiler supports variable length function prototypes 4343 (e.g. void fprintf(FILE *, char *, ...);) *and* <stdarg.h>]) 4344 works=yes 4345],[]) 4346AC_MSG_RESULT($works) 4347 4348# check for socketpair 4349AC_MSG_CHECKING(for socketpair) 4350AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 4351#include <sys/types.h> 4352#include <sys/socket.h> 4353]], [[void *x=socketpair]])], 4354 [AC_DEFINE(HAVE_SOCKETPAIR, 1, [Define if you have the 'socketpair' function.]) 4355 AC_MSG_RESULT(yes)], 4356 [AC_MSG_RESULT(no)] 4357) 4358 4359# check if sockaddr has sa_len member 4360AC_MSG_CHECKING(if sockaddr has sa_len member) 4361AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h> 4362#include <sys/socket.h>]], [[struct sockaddr x; 4363x.sa_len = 0;]])], 4364 [AC_MSG_RESULT(yes) 4365 AC_DEFINE(HAVE_SOCKADDR_SA_LEN, 1, [Define if sockaddr has sa_len member])], 4366 [AC_MSG_RESULT(no)] 4367) 4368 4369# sigh -- gethostbyname_r is a mess; it can have 3, 5 or 6 arguments :-( 4370AH_TEMPLATE(HAVE_GETHOSTBYNAME_R, 4371 [Define this if you have some version of gethostbyname_r()]) 4372 4373AC_CHECK_FUNC(gethostbyname_r, [ 4374 AC_DEFINE(HAVE_GETHOSTBYNAME_R) 4375 AC_MSG_CHECKING([gethostbyname_r with 6 args]) 4376 OLD_CFLAGS=$CFLAGS 4377 CFLAGS="$CFLAGS $MY_CPPFLAGS $MY_THREAD_CPPFLAGS $MY_CFLAGS" 4378 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 4379# include <netdb.h> 4380 ]], [[ 4381 char *name; 4382 struct hostent *he, *res; 4383 char buffer[2048]; 4384 int buflen = 2048; 4385 int h_errnop; 4386 4387 (void) gethostbyname_r(name, he, buffer, buflen, &res, &h_errnop) 4388 ]])],[ 4389 AC_DEFINE(HAVE_GETHOSTBYNAME_R) 4390 AC_DEFINE(HAVE_GETHOSTBYNAME_R_6_ARG, 1, 4391 [Define this if you have the 6-arg version of gethostbyname_r().]) 4392 AC_MSG_RESULT(yes) 4393 ],[ 4394 AC_MSG_RESULT(no) 4395 AC_MSG_CHECKING([gethostbyname_r with 5 args]) 4396 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 4397# include <netdb.h> 4398 ]], [[ 4399 char *name; 4400 struct hostent *he; 4401 char buffer[2048]; 4402 int buflen = 2048; 4403 int h_errnop; 4404 4405 (void) gethostbyname_r(name, he, buffer, buflen, &h_errnop) 4406 ]])], 4407 [ 4408 AC_DEFINE(HAVE_GETHOSTBYNAME_R) 4409 AC_DEFINE(HAVE_GETHOSTBYNAME_R_5_ARG, 1, 4410 [Define this if you have the 5-arg version of gethostbyname_r().]) 4411 AC_MSG_RESULT(yes) 4412 ], [ 4413 AC_MSG_RESULT(no) 4414 AC_MSG_CHECKING([gethostbyname_r with 3 args]) 4415 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 4416# include <netdb.h> 4417 ]], [[ 4418 char *name; 4419 struct hostent *he; 4420 struct hostent_data data; 4421 4422 (void) gethostbyname_r(name, he, &data); 4423 ]])], 4424 [ 4425 AC_DEFINE(HAVE_GETHOSTBYNAME_R) 4426 AC_DEFINE(HAVE_GETHOSTBYNAME_R_3_ARG, 1, 4427 [Define this if you have the 3-arg version of gethostbyname_r().]) 4428 AC_MSG_RESULT(yes) 4429 ], [ 4430 AC_MSG_RESULT(no) 4431 ]) 4432 ]) 4433 ]) 4434 CFLAGS=$OLD_CFLAGS 4435], [ 4436 AC_CHECK_FUNCS(gethostbyname) 4437]) 4438AC_SUBST(HAVE_GETHOSTBYNAME_R_6_ARG) 4439AC_SUBST(HAVE_GETHOSTBYNAME_R_5_ARG) 4440AC_SUBST(HAVE_GETHOSTBYNAME_R_3_ARG) 4441AC_SUBST(HAVE_GETHOSTBYNAME_R) 4442AC_SUBST(HAVE_GETHOSTBYNAME) 4443 4444# checks for system services 4445# (none yet) 4446 4447# Linux requires this for correct f.p. operations 4448AC_CHECK_FUNC(__fpu_control, 4449 [], 4450 [AC_CHECK_LIB(ieee, __fpu_control) 4451]) 4452 4453# check for --with-libm=... 4454AC_SUBST(LIBM) 4455case $ac_sys_system in 4456Darwin) ;; 4457*) LIBM=-lm 4458esac 4459AC_MSG_CHECKING(for --with-libm=STRING) 4460AC_ARG_WITH(libm, 4461 AS_HELP_STRING([--with-libm=STRING], [override libm math library to STRING (default is system-dependent)]), 4462[ 4463if test "$withval" = no 4464then LIBM= 4465 AC_MSG_RESULT(force LIBM empty) 4466elif test "$withval" != yes 4467then LIBM=$withval 4468 AC_MSG_RESULT(set LIBM="$withval") 4469else AC_MSG_ERROR([proper usage is --with-libm=STRING]) 4470fi], 4471[AC_MSG_RESULT(default LIBM="$LIBM")]) 4472 4473# check for --with-libc=... 4474AC_SUBST(LIBC) 4475AC_MSG_CHECKING(for --with-libc=STRING) 4476AC_ARG_WITH(libc, 4477 AS_HELP_STRING([--with-libc=STRING], [override libc C library to STRING (default is system-dependent)]), 4478[ 4479if test "$withval" = no 4480then LIBC= 4481 AC_MSG_RESULT(force LIBC empty) 4482elif test "$withval" != yes 4483then LIBC=$withval 4484 AC_MSG_RESULT(set LIBC="$withval") 4485else AC_MSG_ERROR([proper usage is --with-libc=STRING]) 4486fi], 4487[AC_MSG_RESULT(default LIBC="$LIBC")]) 4488 4489# ************************************** 4490# * Check for gcc x64 inline assembler * 4491# ************************************** 4492 4493AC_MSG_CHECKING(for x64 gcc inline assembler) 4494AC_LINK_IFELSE( [AC_LANG_PROGRAM([[]], [[ 4495 __asm__ __volatile__ ("movq %rcx, %rax"); 4496]])],[have_gcc_asm_for_x64=yes],[have_gcc_asm_for_x64=no]) 4497AC_MSG_RESULT($have_gcc_asm_for_x64) 4498if test "$have_gcc_asm_for_x64" = yes 4499then 4500 AC_DEFINE(HAVE_GCC_ASM_FOR_X64, 1, 4501 [Define if we can use x64 gcc inline assembler]) 4502fi 4503 4504# ************************************************** 4505# * Check for various properties of floating point * 4506# ************************************************** 4507 4508AX_C_FLOAT_WORDS_BIGENDIAN 4509if test "$ax_cv_c_float_words_bigendian" = "yes" 4510then 4511 AC_DEFINE(DOUBLE_IS_BIG_ENDIAN_IEEE754, 1, 4512 [Define if C doubles are 64-bit IEEE 754 binary format, stored 4513 with the most significant byte first]) 4514elif test "$ax_cv_c_float_words_bigendian" = "no" 4515then 4516 AC_DEFINE(DOUBLE_IS_LITTLE_ENDIAN_IEEE754, 1, 4517 [Define if C doubles are 64-bit IEEE 754 binary format, stored 4518 with the least significant byte first]) 4519else 4520 # Some ARM platforms use a mixed-endian representation for doubles. 4521 # While Python doesn't currently have full support for these platforms 4522 # (see e.g., issue 1762561), we can at least make sure that float <-> string 4523 # conversions work. 4524 # FLOAT_WORDS_BIGENDIAN doesnt actually detect this case, but if it's not big 4525 # or little, then it must be this? 4526 AC_DEFINE(DOUBLE_IS_ARM_MIXED_ENDIAN_IEEE754, 1, 4527 [Define if C doubles are 64-bit IEEE 754 binary format, stored 4528 in ARM mixed-endian order (byte order 45670123)]) 4529fi 4530 4531# The short float repr introduced in Python 3.1 requires the 4532# correctly-rounded string <-> double conversion functions from 4533# Python/dtoa.c, which in turn require that the FPU uses 53-bit 4534# rounding; this is a problem on x86, where the x87 FPU has a default 4535# rounding precision of 64 bits. For gcc/x86, we can fix this by 4536# using inline assembler to get and set the x87 FPU control word. 4537 4538# This inline assembler syntax may also work for suncc and icc, 4539# so we try it on all platforms. 4540 4541AC_MSG_CHECKING(whether we can use gcc inline assembler to get and set x87 control word) 4542AC_LINK_IFELSE( [AC_LANG_PROGRAM([[]], [[ 4543 unsigned short cw; 4544 __asm__ __volatile__ ("fnstcw %0" : "=m" (cw)); 4545 __asm__ __volatile__ ("fldcw %0" : : "m" (cw)); 4546]])],[have_gcc_asm_for_x87=yes],[have_gcc_asm_for_x87=no]) 4547AC_MSG_RESULT($have_gcc_asm_for_x87) 4548if test "$have_gcc_asm_for_x87" = yes 4549then 4550 AC_DEFINE(HAVE_GCC_ASM_FOR_X87, 1, 4551 [Define if we can use gcc inline assembler to get and set x87 control word]) 4552fi 4553 4554AC_MSG_CHECKING(whether we can use gcc inline assembler to get and set mc68881 fpcr) 4555AC_LINK_IFELSE( [AC_LANG_PROGRAM([[]], [[ 4556 unsigned int fpcr; 4557 __asm__ __volatile__ ("fmove.l %%fpcr,%0" : "=g" (fpcr)); 4558 __asm__ __volatile__ ("fmove.l %0,%%fpcr" : : "g" (fpcr)); 4559]])],[have_gcc_asm_for_mc68881=yes],[have_gcc_asm_for_mc68881=no]) 4560AC_MSG_RESULT($have_gcc_asm_for_mc68881) 4561if test "$have_gcc_asm_for_mc68881" = yes 4562then 4563 AC_DEFINE(HAVE_GCC_ASM_FOR_MC68881, 1, 4564 [Define if we can use gcc inline assembler to get and set mc68881 fpcr]) 4565fi 4566 4567# Detect whether system arithmetic is subject to x87-style double 4568# rounding issues. The result of this test has little meaning on non 4569# IEEE 754 platforms. On IEEE 754, test should return 1 if rounding 4570# mode is round-to-nearest and double rounding issues are present, and 4571# 0 otherwise. See http://bugs.python.org/issue2937 for more info. 4572AC_MSG_CHECKING(for x87-style double rounding) 4573# $BASECFLAGS may affect the result 4574ac_save_cc="$CC" 4575CC="$CC $BASECFLAGS" 4576AC_RUN_IFELSE([AC_LANG_SOURCE([[ 4577#include <stdlib.h> 4578#include <math.h> 4579int main() { 4580 volatile double x, y, z; 4581 /* 1./(1-2**-53) -> 1+2**-52 (correct), 1.0 (double rounding) */ 4582 x = 0.99999999999999989; /* 1-2**-53 */ 4583 y = 1./x; 4584 if (y != 1.) 4585 exit(0); 4586 /* 1e16+2.99999 -> 1e16+2. (correct), 1e16+4. (double rounding) */ 4587 x = 1e16; 4588 y = 2.99999; 4589 z = x + y; 4590 if (z != 1e16+4.) 4591 exit(0); 4592 /* both tests show evidence of double rounding */ 4593 exit(1); 4594} 4595]])], 4596[ac_cv_x87_double_rounding=no], 4597[ac_cv_x87_double_rounding=yes], 4598[ac_cv_x87_double_rounding=no]) 4599CC="$ac_save_cc" 4600AC_MSG_RESULT($ac_cv_x87_double_rounding) 4601if test "$ac_cv_x87_double_rounding" = yes 4602then 4603 AC_DEFINE(X87_DOUBLE_ROUNDING, 1, 4604 [Define if arithmetic is subject to x87-style double rounding issue]) 4605fi 4606 4607# ************************************ 4608# * Check for mathematical functions * 4609# ************************************ 4610 4611LIBS_SAVE=$LIBS 4612LIBS="$LIBS $LIBM" 4613 4614AC_CHECK_FUNCS([acosh asinh atanh copysign erf erfc expm1 finite gamma]) 4615AC_CHECK_FUNCS([hypot lgamma log1p log2 round tgamma]) 4616AC_CHECK_DECLS([isinf, isnan, isfinite], [], [], [[#include <math.h>]]) 4617 4618# For multiprocessing module, check that sem_open 4619# actually works. For FreeBSD versions <= 7.2, 4620# the kernel module that provides POSIX semaphores 4621# isn't loaded by default, so an attempt to call 4622# sem_open results in a 'Signal 12' error. 4623AC_MSG_CHECKING(whether POSIX semaphores are enabled) 4624AC_CACHE_VAL(ac_cv_posix_semaphores_enabled, 4625AC_RUN_IFELSE([AC_LANG_SOURCE([[ 4626#include <unistd.h> 4627#include <fcntl.h> 4628#include <stdio.h> 4629#include <semaphore.h> 4630#include <sys/stat.h> 4631 4632int main(void) { 4633 sem_t *a = sem_open("/autoconf", O_CREAT, S_IRUSR|S_IWUSR, 0); 4634 if (a == SEM_FAILED) { 4635 perror("sem_open"); 4636 return 1; 4637 } 4638 sem_close(a); 4639 sem_unlink("/autoconf"); 4640 return 0; 4641} 4642]])], 4643[ac_cv_posix_semaphores_enabled=yes], 4644[ac_cv_posix_semaphores_enabled=no], 4645[ac_cv_posix_semaphores_enabled=yes]) 4646) 4647AC_MSG_RESULT($ac_cv_posix_semaphores_enabled) 4648if test $ac_cv_posix_semaphores_enabled = no 4649then 4650 AC_DEFINE(POSIX_SEMAPHORES_NOT_ENABLED, 1, 4651 [Define if POSIX semaphores aren't enabled on your system]) 4652fi 4653 4654# Multiprocessing check for broken sem_getvalue 4655AC_MSG_CHECKING(for broken sem_getvalue) 4656AC_CACHE_VAL(ac_cv_broken_sem_getvalue, 4657AC_RUN_IFELSE([AC_LANG_SOURCE([[ 4658#include <unistd.h> 4659#include <fcntl.h> 4660#include <stdio.h> 4661#include <semaphore.h> 4662#include <sys/stat.h> 4663 4664int main(void){ 4665 sem_t *a = sem_open("/autocftw", O_CREAT, S_IRUSR|S_IWUSR, 0); 4666 int count; 4667 int res; 4668 if(a==SEM_FAILED){ 4669 perror("sem_open"); 4670 return 1; 4671 4672 } 4673 res = sem_getvalue(a, &count); 4674 sem_close(a); 4675 sem_unlink("/autocftw"); 4676 return res==-1 ? 1 : 0; 4677} 4678]])], 4679[ac_cv_broken_sem_getvalue=no], 4680[ac_cv_broken_sem_getvalue=yes], 4681[ac_cv_broken_sem_getvalue=yes]) 4682) 4683AC_MSG_RESULT($ac_cv_broken_sem_getvalue) 4684if test $ac_cv_broken_sem_getvalue = yes 4685then 4686 AC_DEFINE(HAVE_BROKEN_SEM_GETVALUE, 1, 4687 [define to 1 if your sem_getvalue is broken.]) 4688fi 4689 4690AC_CHECK_DECLS([RTLD_LAZY, RTLD_NOW, RTLD_GLOBAL, RTLD_LOCAL, RTLD_NODELETE, RTLD_NOLOAD, RTLD_DEEPBIND, RTLD_MEMBER], [], [], [[#include <dlfcn.h>]]) 4691 4692# determine what size digit to use for Python's longs 4693AC_MSG_CHECKING([digit size for Python's longs]) 4694AC_ARG_ENABLE(big-digits, 4695AS_HELP_STRING([--enable-big-digits@<:@=15|30@:>@],[use big digits (30 or 15 bits) for Python longs (default is system-dependent)]]), 4696[case $enable_big_digits in 4697yes) 4698 enable_big_digits=30 ;; 4699no) 4700 enable_big_digits=15 ;; 4701[15|30]) 4702 ;; 4703*) 4704 AC_MSG_ERROR([bad value $enable_big_digits for --enable-big-digits; value should be 15 or 30]) ;; 4705esac 4706AC_MSG_RESULT($enable_big_digits) 4707AC_DEFINE_UNQUOTED(PYLONG_BITS_IN_DIGIT, $enable_big_digits, [Define as the preferred size in bits of long digits]) 4708], 4709[AC_MSG_RESULT(no value specified)]) 4710 4711# check for wchar.h 4712AC_CHECK_HEADER(wchar.h, [ 4713 AC_DEFINE(HAVE_WCHAR_H, 1, 4714 [Define if the compiler provides a wchar.h header file.]) 4715 wchar_h="yes" 4716], 4717wchar_h="no" 4718) 4719 4720# determine wchar_t size 4721if test "$wchar_h" = yes 4722then 4723 AC_CHECK_SIZEOF(wchar_t, 4, [#include <wchar.h>]) 4724fi 4725 4726AC_MSG_CHECKING(for UCS-4 tcl) 4727have_ucs4_tcl=no 4728AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 4729#include <tcl.h> 4730#if TCL_UTF_MAX != 6 4731# error "NOT UCS4_TCL" 4732#endif]], [[]])],[ 4733 AC_DEFINE(HAVE_UCS4_TCL, 1, [Define this if you have tcl and TCL_UTF_MAX==6]) 4734 have_ucs4_tcl=yes 4735],[]) 4736AC_MSG_RESULT($have_ucs4_tcl) 4737 4738# check whether wchar_t is signed or not 4739if test "$wchar_h" = yes 4740then 4741 # check whether wchar_t is signed or not 4742 AC_MSG_CHECKING(whether wchar_t is signed) 4743 AC_CACHE_VAL(ac_cv_wchar_t_signed, [ 4744 AC_RUN_IFELSE([AC_LANG_SOURCE([[ 4745 #include <wchar.h> 4746 int main() 4747 { 4748 /* Success: exit code 0 */ 4749 return ((((wchar_t) -1) < ((wchar_t) 0)) ? 0 : 1); 4750 } 4751 ]])], 4752 [ac_cv_wchar_t_signed=yes], 4753 [ac_cv_wchar_t_signed=no], 4754 [ac_cv_wchar_t_signed=yes])]) 4755 AC_MSG_RESULT($ac_cv_wchar_t_signed) 4756fi 4757 4758AC_MSG_CHECKING(whether wchar_t is usable) 4759# wchar_t is only usable if it maps to an unsigned type 4760if test "$ac_cv_sizeof_wchar_t" -ge 2 \ 4761 -a "$ac_cv_wchar_t_signed" = "no" 4762then 4763 AC_DEFINE(HAVE_USABLE_WCHAR_T, 1, 4764 [Define if you have a useable wchar_t type defined in wchar.h; useable 4765 means wchar_t must be an unsigned type with at least 16 bits. (see 4766 Include/unicodeobject.h).]) 4767 AC_MSG_RESULT(yes) 4768else 4769 AC_MSG_RESULT(no) 4770fi 4771 4772case $ac_sys_system/$ac_sys_release in 4773SunOS/*) 4774 if test -f /etc/os-release; then 4775 OS_NAME=$(awk -F= '/^NAME=/ {print substr($2,2,length($2)-2)}' /etc/os-release) 4776 if test "x$OS_NAME" = "xOracle Solaris"; then 4777 # bpo-43667: In Oracle Solaris, the internal form of wchar_t in 4778 # non-Unicode locales is not Unicode and hence cannot be used directly. 4779 # https://docs.oracle.com/cd/E37838_01/html/E61053/gmwke.html 4780 AC_DEFINE(HAVE_NON_UNICODE_WCHAR_T_REPRESENTATION, 1, 4781 [Define if the internal form of wchar_t in non-Unicode locales 4782 is not Unicode.]) 4783 fi 4784 fi 4785 ;; 4786esac 4787 4788# check for endianness 4789AC_C_BIGENDIAN 4790 4791# ABI version string for Python extension modules. This appears between the 4792# periods in shared library file names, e.g. foo.<SOABI>.so. It is calculated 4793# from the following attributes which affect the ABI of this Python build (in 4794# this order): 4795# 4796# * The Python implementation (always 'cpython-' for us) 4797# * The major and minor version numbers 4798# * --with-pydebug (adds a 'd') 4799# 4800# Thus for example, Python 3.2 built with wide unicode, pydebug, and pymalloc, 4801# would get a shared library ABI version tag of 'cpython-32dmu' and shared 4802# libraries would be named 'foo.cpython-32dmu.so'. 4803# 4804# In Python 3.2 and older, --with-wide-unicode added a 'u' flag. 4805# In Python 3.7 and older, --with-pymalloc added a 'm' flag. 4806AC_SUBST(SOABI) 4807AC_MSG_CHECKING(ABIFLAGS) 4808AC_MSG_RESULT($ABIFLAGS) 4809AC_MSG_CHECKING(SOABI) 4810SOABI='cpython-'`echo $VERSION | tr -d .`${ABIFLAGS}${PLATFORM_TRIPLET:+-$PLATFORM_TRIPLET} 4811AC_MSG_RESULT($SOABI) 4812 4813# Release and debug (Py_DEBUG) ABI are compatible, but not Py_TRACE_REFS ABI 4814if test "$Py_DEBUG" = 'true' -a "$with_trace_refs" != "yes"; then 4815 # Similar to SOABI but remove "d" flag from ABIFLAGS 4816 AC_SUBST(ALT_SOABI) 4817 ALT_SOABI='cpython-'`echo $VERSION | tr -d .``echo $ABIFLAGS | tr -d d`${PLATFORM_TRIPLET:+-$PLATFORM_TRIPLET} 4818 AC_DEFINE_UNQUOTED(ALT_SOABI, "${ALT_SOABI}", 4819 [Alternative SOABI used in debug build to load C extensions built in release mode]) 4820fi 4821 4822AC_SUBST(EXT_SUFFIX) 4823EXT_SUFFIX=.${SOABI}${SHLIB_SUFFIX} 4824 4825AC_MSG_CHECKING(LDVERSION) 4826LDVERSION='$(VERSION)$(ABIFLAGS)' 4827AC_MSG_RESULT($LDVERSION) 4828 4829# On Android and Cygwin the shared libraries must be linked with libpython. 4830AC_SUBST(LIBPYTHON) 4831if test -n "$ANDROID_API_LEVEL" -o "$MACHDEP" = "cygwin"; then 4832 LIBPYTHON="-lpython${VERSION}${ABIFLAGS}" 4833else 4834 LIBPYTHON='' 4835fi 4836 4837 4838AC_SUBST(BINLIBDEST) 4839BINLIBDEST='$(LIBDIR)/python$(VERSION)' 4840 4841 4842# Check for --with-platlibdir 4843# /usr/$LIDIRNAME/python$VERSION 4844AC_SUBST(PLATLIBDIR) 4845PLATLIBDIR="lib" 4846AC_MSG_CHECKING(for --with-platlibdir) 4847AC_ARG_WITH(platlibdir, 4848 AS_HELP_STRING([--with-platlibdir=DIRNAME], 4849 [Python library directory name (default is "lib")]), 4850[ 4851# ignore 3 options: 4852# --with-platlibdir 4853# --with-platlibdir= 4854# --without-platlibdir 4855if test -n "$withval" -a "$withval" != yes -a "$withval" != no 4856then 4857 AC_MSG_RESULT(yes) 4858 PLATLIBDIR="$withval" 4859 BINLIBDEST='${exec_prefix}/${PLATLIBDIR}/python$(VERSION)' 4860else 4861 AC_MSG_RESULT(no) 4862fi], 4863[AC_MSG_RESULT(no)]) 4864 4865 4866dnl define LIBPL after ABIFLAGS and LDVERSION is defined. 4867AC_SUBST(PY_ENABLE_SHARED) 4868if test x$PLATFORM_TRIPLET = x; then 4869 LIBPL='$(prefix)'"/${PLATLIBDIR}/python${VERSION}/config-${LDVERSION}" 4870else 4871 LIBPL='$(prefix)'"/${PLATLIBDIR}/python${VERSION}/config-${LDVERSION}-${PLATFORM_TRIPLET}" 4872fi 4873AC_SUBST(LIBPL) 4874 4875# Check whether right shifting a negative integer extends the sign bit 4876# or fills with zeros (like the Cray J90, according to Tim Peters). 4877AC_MSG_CHECKING(whether right shift extends the sign bit) 4878AC_CACHE_VAL(ac_cv_rshift_extends_sign, [ 4879AC_RUN_IFELSE([AC_LANG_SOURCE([[ 4880int main() 4881{ 4882 return (((-1)>>3 == -1) ? 0 : 1); 4883} 4884]])], 4885[ac_cv_rshift_extends_sign=yes], 4886[ac_cv_rshift_extends_sign=no], 4887[ac_cv_rshift_extends_sign=yes])]) 4888AC_MSG_RESULT($ac_cv_rshift_extends_sign) 4889if test "$ac_cv_rshift_extends_sign" = no 4890then 4891 AC_DEFINE(SIGNED_RIGHT_SHIFT_ZERO_FILLS, 1, 4892 [Define if i>>j for signed int i does not extend the sign bit 4893 when i < 0]) 4894fi 4895 4896# check for getc_unlocked and related locking functions 4897AC_MSG_CHECKING(for getc_unlocked() and friends) 4898AC_CACHE_VAL(ac_cv_have_getc_unlocked, [ 4899AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <stdio.h>]], [[ 4900 FILE *f = fopen("/dev/null", "r"); 4901 flockfile(f); 4902 getc_unlocked(f); 4903 funlockfile(f); 4904]])],[ac_cv_have_getc_unlocked=yes],[ac_cv_have_getc_unlocked=no])]) 4905AC_MSG_RESULT($ac_cv_have_getc_unlocked) 4906if test "$ac_cv_have_getc_unlocked" = yes 4907then 4908 AC_DEFINE(HAVE_GETC_UNLOCKED, 1, 4909 [Define this if you have flockfile(), getc_unlocked(), and funlockfile()]) 4910fi 4911 4912# check where readline lives 4913# save the value of LIBS so we don't actually link Python with readline 4914LIBS_no_readline=$LIBS 4915 4916# On some systems we need to link readline to a termcap compatible 4917# library. NOTE: Keep the precedence of listed libraries synchronised 4918# with setup.py. 4919py_cv_lib_readline=no 4920AC_MSG_CHECKING([how to link readline libs]) 4921for py_libtermcap in "" tinfo ncursesw ncurses curses termcap; do 4922 if test -z "$py_libtermcap"; then 4923 READLINE_LIBS="-lreadline" 4924 else 4925 READLINE_LIBS="-lreadline -l$py_libtermcap" 4926 fi 4927 LIBS="$READLINE_LIBS $LIBS_no_readline" 4928 AC_LINK_IFELSE( 4929 [AC_LANG_CALL([],[readline])], 4930 [py_cv_lib_readline=yes]) 4931 if test $py_cv_lib_readline = yes; then 4932 break 4933 fi 4934done 4935# Uncomment this line if you want to use READINE_LIBS in Makefile or scripts 4936#AC_SUBST([READLINE_LIBS]) 4937if test $py_cv_lib_readline = no; then 4938 AC_MSG_RESULT([none]) 4939else 4940 AC_MSG_RESULT([$READLINE_LIBS]) 4941 AC_DEFINE(HAVE_LIBREADLINE, 1, 4942 [Define if you have the readline library (-lreadline).]) 4943fi 4944 4945# check for readline 2.2 4946AC_PREPROC_IFELSE([AC_LANG_SOURCE([[#include <readline/readline.h>]])], 4947 [have_readline=yes], 4948 [have_readline=no] 4949) 4950if test $have_readline = yes 4951then 4952 AC_EGREP_HEADER([extern int rl_completion_append_character;], 4953 [readline/readline.h], 4954 AC_DEFINE(HAVE_RL_COMPLETION_APPEND_CHARACTER, 1, 4955 [Define if you have readline 2.2]), ) 4956 AC_EGREP_HEADER([extern int rl_completion_suppress_append;], 4957 [readline/readline.h], 4958 AC_DEFINE(HAVE_RL_COMPLETION_SUPPRESS_APPEND, 1, 4959 [Define if you have rl_completion_suppress_append]), ) 4960fi 4961 4962# check for readline 4.0 4963AC_CHECK_LIB(readline, rl_pre_input_hook, 4964 AC_DEFINE(HAVE_RL_PRE_INPUT_HOOK, 1, 4965 [Define if you have readline 4.0]), ,$READLINE_LIBS) 4966 4967# also in 4.0 4968AC_CHECK_LIB(readline, rl_completion_display_matches_hook, 4969 AC_DEFINE(HAVE_RL_COMPLETION_DISPLAY_MATCHES_HOOK, 1, 4970 [Define if you have readline 4.0]), ,$READLINE_LIBS) 4971 4972# also in 4.0, but not in editline 4973AC_CHECK_LIB(readline, rl_resize_terminal, 4974 AC_DEFINE(HAVE_RL_RESIZE_TERMINAL, 1, 4975 [Define if you have readline 4.0]), ,$READLINE_LIBS) 4976 4977# check for readline 4.2 4978AC_CHECK_LIB(readline, rl_completion_matches, 4979 AC_DEFINE(HAVE_RL_COMPLETION_MATCHES, 1, 4980 [Define if you have readline 4.2]), ,$READLINE_LIBS) 4981 4982# also in readline 4.2 4983AC_PREPROC_IFELSE([AC_LANG_SOURCE([[#include <readline/readline.h>]])], 4984 [have_readline=yes], 4985 [have_readline=no] 4986) 4987if test $have_readline = yes 4988then 4989 AC_EGREP_HEADER([extern int rl_catch_signals;], 4990 [readline/readline.h], 4991 AC_DEFINE(HAVE_RL_CATCH_SIGNAL, 1, 4992 [Define if you can turn off readline's signal handling.]), ) 4993fi 4994 4995AC_CHECK_LIB(readline, append_history, 4996 AC_DEFINE(HAVE_RL_APPEND_HISTORY, 1, 4997 [Define if readline supports append_history]), ,$READLINE_LIBS) 4998 4999# End of readline checks: restore LIBS 5000LIBS=$LIBS_no_readline 5001 5002AC_MSG_CHECKING(for broken nice()) 5003AC_CACHE_VAL(ac_cv_broken_nice, [ 5004AC_RUN_IFELSE([AC_LANG_SOURCE([[ 5005#include <stdlib.h> 5006#include <unistd.h> 5007int main() 5008{ 5009 int val1 = nice(1); 5010 if (val1 != -1 && val1 == nice(2)) 5011 exit(0); 5012 exit(1); 5013} 5014]])], 5015[ac_cv_broken_nice=yes], 5016[ac_cv_broken_nice=no], 5017[ac_cv_broken_nice=no])]) 5018AC_MSG_RESULT($ac_cv_broken_nice) 5019if test "$ac_cv_broken_nice" = yes 5020then 5021 AC_DEFINE(HAVE_BROKEN_NICE, 1, 5022 [Define if nice() returns success/failure instead of the new priority.]) 5023fi 5024 5025AC_MSG_CHECKING(for broken poll()) 5026AC_CACHE_VAL(ac_cv_broken_poll, 5027AC_RUN_IFELSE([AC_LANG_SOURCE([[ 5028#include <poll.h> 5029#include <unistd.h> 5030 5031int main() 5032{ 5033 struct pollfd poll_struct = { 42, POLLIN|POLLPRI|POLLOUT, 0 }; 5034 int poll_test; 5035 5036 close (42); 5037 5038 poll_test = poll(&poll_struct, 1, 0); 5039 if (poll_test < 0) 5040 return 0; 5041 else if (poll_test == 0 && poll_struct.revents != POLLNVAL) 5042 return 0; 5043 else 5044 return 1; 5045} 5046]])], 5047[ac_cv_broken_poll=yes], 5048[ac_cv_broken_poll=no], 5049[ac_cv_broken_poll=no])) 5050AC_MSG_RESULT($ac_cv_broken_poll) 5051if test "$ac_cv_broken_poll" = yes 5052then 5053 AC_DEFINE(HAVE_BROKEN_POLL, 1, 5054 [Define if poll() sets errno on invalid file descriptors.]) 5055fi 5056 5057# check tzset(3) exists and works like we expect it to 5058AC_MSG_CHECKING(for working tzset()) 5059AC_CACHE_VAL(ac_cv_working_tzset, [ 5060AC_RUN_IFELSE([AC_LANG_SOURCE([[ 5061#include <stdlib.h> 5062#include <time.h> 5063#include <string.h> 5064 5065#if HAVE_TZNAME 5066extern char *tzname[]; 5067#endif 5068 5069int main() 5070{ 5071 /* Note that we need to ensure that not only does tzset(3) 5072 do 'something' with localtime, but it works as documented 5073 in the library reference and as expected by the test suite. 5074 This includes making sure that tzname is set properly if 5075 tm->tm_zone does not exist since it is the alternative way 5076 of getting timezone info. 5077 5078 Red Hat 6.2 doesn't understand the southern hemisphere 5079 after New Year's Day. 5080 */ 5081 5082 time_t groundhogday = 1044144000; /* GMT-based */ 5083 time_t midyear = groundhogday + (365 * 24 * 3600 / 2); 5084 5085 putenv("TZ=UTC+0"); 5086 tzset(); 5087 if (localtime(&groundhogday)->tm_hour != 0) 5088 exit(1); 5089#if HAVE_TZNAME 5090 /* For UTC, tzname[1] is sometimes "", sometimes " " */ 5091 if (strcmp(tzname[0], "UTC") || 5092 (tzname[1][0] != 0 && tzname[1][0] != ' ')) 5093 exit(1); 5094#endif 5095 5096 putenv("TZ=EST+5EDT,M4.1.0,M10.5.0"); 5097 tzset(); 5098 if (localtime(&groundhogday)->tm_hour != 19) 5099 exit(1); 5100#if HAVE_TZNAME 5101 if (strcmp(tzname[0], "EST") || strcmp(tzname[1], "EDT")) 5102 exit(1); 5103#endif 5104 5105 putenv("TZ=AEST-10AEDT-11,M10.5.0,M3.5.0"); 5106 tzset(); 5107 if (localtime(&groundhogday)->tm_hour != 11) 5108 exit(1); 5109#if HAVE_TZNAME 5110 if (strcmp(tzname[0], "AEST") || strcmp(tzname[1], "AEDT")) 5111 exit(1); 5112#endif 5113 5114#if HAVE_STRUCT_TM_TM_ZONE 5115 if (strcmp(localtime(&groundhogday)->tm_zone, "AEDT")) 5116 exit(1); 5117 if (strcmp(localtime(&midyear)->tm_zone, "AEST")) 5118 exit(1); 5119#endif 5120 5121 exit(0); 5122} 5123]])], 5124[ac_cv_working_tzset=yes], 5125[ac_cv_working_tzset=no], 5126[ac_cv_working_tzset=no])]) 5127AC_MSG_RESULT($ac_cv_working_tzset) 5128if test "$ac_cv_working_tzset" = yes 5129then 5130 AC_DEFINE(HAVE_WORKING_TZSET, 1, 5131 [Define if tzset() actually switches the local timezone in a meaningful way.]) 5132fi 5133 5134# Look for subsecond timestamps in struct stat 5135AC_MSG_CHECKING(for tv_nsec in struct stat) 5136AC_CACHE_VAL(ac_cv_stat_tv_nsec, 5137AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/stat.h>]], [[ 5138struct stat st; 5139st.st_mtim.tv_nsec = 1; 5140]])], 5141[ac_cv_stat_tv_nsec=yes], 5142[ac_cv_stat_tv_nsec=no])) 5143AC_MSG_RESULT($ac_cv_stat_tv_nsec) 5144if test "$ac_cv_stat_tv_nsec" = yes 5145then 5146 AC_DEFINE(HAVE_STAT_TV_NSEC, 1, 5147 [Define if you have struct stat.st_mtim.tv_nsec]) 5148fi 5149 5150# Look for BSD style subsecond timestamps in struct stat 5151AC_MSG_CHECKING(for tv_nsec2 in struct stat) 5152AC_CACHE_VAL(ac_cv_stat_tv_nsec2, 5153AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/stat.h>]], [[ 5154struct stat st; 5155st.st_mtimespec.tv_nsec = 1; 5156]])], 5157[ac_cv_stat_tv_nsec2=yes], 5158[ac_cv_stat_tv_nsec2=no])) 5159AC_MSG_RESULT($ac_cv_stat_tv_nsec2) 5160if test "$ac_cv_stat_tv_nsec2" = yes 5161then 5162 AC_DEFINE(HAVE_STAT_TV_NSEC2, 1, 5163 [Define if you have struct stat.st_mtimensec]) 5164fi 5165 5166# first curses header check 5167ac_save_cppflags="$CPPFLAGS" 5168if test "$cross_compiling" = no; then 5169 CPPFLAGS="$CPPFLAGS -I/usr/include/ncursesw" 5170fi 5171 5172AC_CHECK_HEADERS(curses.h ncurses.h) 5173 5174# On Solaris, term.h requires curses.h 5175AC_CHECK_HEADERS(term.h,,,[ 5176#ifdef HAVE_CURSES_H 5177#include <curses.h> 5178#endif 5179]) 5180 5181# On HP/UX 11.0, mvwdelch is a block with a return statement 5182AC_MSG_CHECKING(whether mvwdelch is an expression) 5183AC_CACHE_VAL(ac_cv_mvwdelch_is_expression, 5184AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <curses.h>]], [[ 5185 int rtn; 5186 rtn = mvwdelch(0,0,0); 5187]])], 5188[ac_cv_mvwdelch_is_expression=yes], 5189[ac_cv_mvwdelch_is_expression=no])) 5190AC_MSG_RESULT($ac_cv_mvwdelch_is_expression) 5191 5192if test "$ac_cv_mvwdelch_is_expression" = yes 5193then 5194 AC_DEFINE(MVWDELCH_IS_EXPRESSION, 1, 5195 [Define if mvwdelch in curses.h is an expression.]) 5196fi 5197 5198# Issue #25720: ncurses has introduced the NCURSES_OPAQUE symbol making opaque 5199# structs since version 5.7. If the macro is defined as zero before including 5200# [n]curses.h, ncurses will expose fields of the structs regardless of the 5201# configuration. 5202AC_MSG_CHECKING(whether WINDOW has _flags) 5203AC_CACHE_VAL(ac_cv_window_has_flags, 5204AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 5205 #define NCURSES_OPAQUE 0 5206 #include <curses.h> 5207]], [[ 5208 WINDOW *w; 5209 w->_flags = 0; 5210]])], 5211[ac_cv_window_has_flags=yes], 5212[ac_cv_window_has_flags=no])) 5213AC_MSG_RESULT($ac_cv_window_has_flags) 5214 5215 5216if test "$ac_cv_window_has_flags" = yes 5217then 5218 AC_DEFINE(WINDOW_HAS_FLAGS, 1, 5219 [Define if WINDOW in curses.h offers a field _flags.]) 5220fi 5221 5222AC_MSG_CHECKING(for is_pad) 5223AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <curses.h>]], [[ 5224#ifndef is_pad 5225void *x=is_pad 5226#endif 5227]])], 5228 [AC_DEFINE(HAVE_CURSES_IS_PAD, 1, Define if you have the 'is_pad' function or macro.) 5229 AC_MSG_RESULT(yes)], 5230 [AC_MSG_RESULT(no)] 5231) 5232 5233AC_MSG_CHECKING(for is_term_resized) 5234AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <curses.h>]], [[void *x=is_term_resized]])], 5235 [AC_DEFINE(HAVE_CURSES_IS_TERM_RESIZED, 1, Define if you have the 'is_term_resized' function.) 5236 AC_MSG_RESULT(yes)], 5237 [AC_MSG_RESULT(no)] 5238) 5239 5240AC_MSG_CHECKING(for resize_term) 5241AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <curses.h>]], [[void *x=resize_term]])], 5242 [AC_DEFINE(HAVE_CURSES_RESIZE_TERM, 1, Define if you have the 'resize_term' function.) 5243 AC_MSG_RESULT(yes)], 5244 [AC_MSG_RESULT(no)] 5245) 5246 5247AC_MSG_CHECKING(for resizeterm) 5248AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <curses.h>]], [[void *x=resizeterm]])], 5249 [AC_DEFINE(HAVE_CURSES_RESIZETERM, 1, Define if you have the 'resizeterm' function.) 5250 AC_MSG_RESULT(yes)], 5251 [AC_MSG_RESULT(no)] 5252) 5253 5254AC_MSG_CHECKING(for immedok) 5255AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <curses.h>]], [[ 5256#ifndef immedok 5257void *x=immedok 5258#endif 5259]])], 5260 [AC_DEFINE(HAVE_CURSES_IMMEDOK, 1, Define if you have the 'immedok' function.) 5261 AC_MSG_RESULT(yes)], 5262 [AC_MSG_RESULT(no)] 5263) 5264 5265AC_MSG_CHECKING(for syncok) 5266AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <curses.h>]], [[ 5267#ifndef syncok 5268void *x=syncok 5269#endif 5270]])], 5271 [AC_DEFINE(HAVE_CURSES_SYNCOK, 1, Define if you have the 'syncok' function.) 5272 AC_MSG_RESULT(yes)], 5273 [AC_MSG_RESULT(no)] 5274) 5275 5276AC_MSG_CHECKING(for wchgat) 5277AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <curses.h>]], [[ 5278#ifndef wchgat 5279void *x=wchgat 5280#endif 5281]])], 5282 [AC_DEFINE(HAVE_CURSES_WCHGAT, 1, Define if you have the 'wchgat' function.) 5283 AC_MSG_RESULT(yes)], 5284 [AC_MSG_RESULT(no)] 5285) 5286 5287AC_MSG_CHECKING(for filter) 5288AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <curses.h>]], [[ 5289#ifndef filter 5290void *x=filter 5291#endif 5292]])], 5293 [AC_DEFINE(HAVE_CURSES_FILTER, 1, Define if you have the 'filter' function.) 5294 AC_MSG_RESULT(yes)], 5295 [AC_MSG_RESULT(no)] 5296) 5297 5298AC_MSG_CHECKING(for has_key) 5299AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <curses.h>]], [[ 5300#ifndef has_key 5301void *x=has_key 5302#endif 5303]])], 5304 [AC_DEFINE(HAVE_CURSES_HAS_KEY, 1, Define if you have the 'has_key' function.) 5305 AC_MSG_RESULT(yes)], 5306 [AC_MSG_RESULT(no)] 5307) 5308 5309AC_MSG_CHECKING(for typeahead) 5310AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <curses.h>]], [[ 5311#ifndef typeahead 5312void *x=typeahead 5313#endif 5314]])], 5315 [AC_DEFINE(HAVE_CURSES_TYPEAHEAD, 1, Define if you have the 'typeahead' function.) 5316 AC_MSG_RESULT(yes)], 5317 [AC_MSG_RESULT(no)] 5318) 5319 5320AC_MSG_CHECKING(for use_env) 5321AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <curses.h>]], [[ 5322#ifndef use_env 5323void *x=use_env 5324#endif 5325]])], 5326 [AC_DEFINE(HAVE_CURSES_USE_ENV, 1, Define if you have the 'use_env' function.) 5327 AC_MSG_RESULT(yes)], 5328 [AC_MSG_RESULT(no)] 5329) 5330# last curses configure check 5331CPPFLAGS=$ac_save_cppflags 5332 5333AC_MSG_NOTICE([checking for device files]) 5334 5335dnl NOTE: Inform user how to proceed with files when cross compiling. 5336if test "x$cross_compiling" = xyes; then 5337 if test "${ac_cv_file__dev_ptmx+set}" != set; then 5338 AC_MSG_CHECKING([for /dev/ptmx]) 5339 AC_MSG_RESULT([not set]) 5340 AC_MSG_ERROR([set ac_cv_file__dev_ptmx to yes/no in your CONFIG_SITE file when cross compiling]) 5341 fi 5342 if test "${ac_cv_file__dev_ptc+set}" != set; then 5343 AC_MSG_CHECKING([for /dev/ptc]) 5344 AC_MSG_RESULT([not set]) 5345 AC_MSG_ERROR([set ac_cv_file__dev_ptc to yes/no in your CONFIG_SITE file when cross compiling]) 5346 fi 5347fi 5348 5349AC_CHECK_FILE(/dev/ptmx, [], []) 5350if test "x$ac_cv_file__dev_ptmx" = xyes; then 5351 AC_DEFINE(HAVE_DEV_PTMX, 1, 5352 [Define to 1 if you have the /dev/ptmx device file.]) 5353fi 5354AC_CHECK_FILE(/dev/ptc, [], []) 5355if test "x$ac_cv_file__dev_ptc" = xyes; then 5356 AC_DEFINE(HAVE_DEV_PTC, 1, 5357 [Define to 1 if you have the /dev/ptc device file.]) 5358fi 5359 5360if test $ac_sys_system = Darwin 5361then 5362 LIBS="$LIBS -framework CoreFoundation" 5363fi 5364 5365AC_CACHE_CHECK([for %zd printf() format support], ac_cv_have_size_t_format, [dnl 5366AC_RUN_IFELSE([AC_LANG_SOURCE([[ 5367#include <stdio.h> 5368#include <stddef.h> 5369#include <string.h> 5370 5371#ifdef HAVE_SYS_TYPES_H 5372#include <sys/types.h> 5373#endif 5374 5375#ifdef HAVE_SSIZE_T 5376typedef ssize_t Py_ssize_t; 5377#elif SIZEOF_VOID_P == SIZEOF_LONG 5378typedef long Py_ssize_t; 5379#else 5380typedef int Py_ssize_t; 5381#endif 5382 5383int main() 5384{ 5385 char buffer[256]; 5386 5387 if(sprintf(buffer, "%zd", (size_t)123) < 0) 5388 return 1; 5389 5390 if (strcmp(buffer, "123")) 5391 return 1; 5392 5393 if (sprintf(buffer, "%zd", (Py_ssize_t)-123) < 0) 5394 return 1; 5395 5396 if (strcmp(buffer, "-123")) 5397 return 1; 5398 5399 return 0; 5400} 5401]])], 5402 [ac_cv_have_size_t_format=yes], 5403 [ac_cv_have_size_t_format=no], 5404 [ac_cv_have_size_t_format="cross -- assuming yes" 5405])]) 5406if test "$ac_cv_have_size_t_format" != no ; then 5407 AC_DEFINE(PY_FORMAT_SIZE_T, "z", 5408 [Define to printf format modifier for Py_ssize_t]) 5409fi 5410 5411AC_CHECK_TYPE(socklen_t,, 5412 AC_DEFINE(socklen_t,int, 5413 [Define to `int' if <sys/socket.h> does not define.]),[ 5414#ifdef HAVE_SYS_TYPES_H 5415#include <sys/types.h> 5416#endif 5417#ifdef HAVE_SYS_SOCKET_H 5418#include <sys/socket.h> 5419#endif 5420]) 5421 5422AC_MSG_CHECKING(for broken mbstowcs) 5423AC_CACHE_VAL(ac_cv_broken_mbstowcs, 5424AC_RUN_IFELSE([AC_LANG_SOURCE([[ 5425#include <stdio.h> 5426#include<stdlib.h> 5427int main() { 5428 size_t len = -1; 5429 const char *str = "text"; 5430 len = mbstowcs(NULL, str, 0); 5431 return (len != 4); 5432} 5433]])], 5434[ac_cv_broken_mbstowcs=no], 5435[ac_cv_broken_mbstowcs=yes], 5436[ac_cv_broken_mbstowcs=no])) 5437AC_MSG_RESULT($ac_cv_broken_mbstowcs) 5438if test "$ac_cv_broken_mbstowcs" = yes 5439then 5440 AC_DEFINE(HAVE_BROKEN_MBSTOWCS, 1, 5441 [Define if mbstowcs(NULL, "text", 0) does not return the number of 5442 wide chars that would be converted.]) 5443fi 5444 5445# Check for --with-computed-gotos 5446AC_MSG_CHECKING(for --with-computed-gotos) 5447AC_ARG_WITH(computed-gotos, 5448 AS_HELP_STRING([--with-computed-gotos], 5449 [enable computed gotos in evaluation loop (enabled by default on supported compilers)]), 5450[ 5451if test "$withval" = yes 5452then 5453 AC_DEFINE(USE_COMPUTED_GOTOS, 1, 5454 [Define if you want to use computed gotos in ceval.c.]) 5455 AC_MSG_RESULT(yes) 5456fi 5457if test "$withval" = no 5458then 5459 AC_DEFINE(USE_COMPUTED_GOTOS, 0, 5460 [Define if you want to use computed gotos in ceval.c.]) 5461 AC_MSG_RESULT(no) 5462fi 5463], 5464[AC_MSG_RESULT(no value specified)]) 5465 5466AC_MSG_CHECKING(whether $CC supports computed gotos) 5467AC_CACHE_VAL(ac_cv_computed_gotos, 5468AC_RUN_IFELSE([AC_LANG_SOURCE([[[ 5469int main(int argc, char **argv) 5470{ 5471 static void *targets[1] = { &&LABEL1 }; 5472 goto LABEL2; 5473LABEL1: 5474 return 0; 5475LABEL2: 5476 goto *targets[0]; 5477 return 1; 5478} 5479]]])], 5480[ac_cv_computed_gotos=yes], 5481[ac_cv_computed_gotos=no], 5482[if test "${with_computed_gotos+set}" = set; then 5483 ac_cv_computed_gotos="$with_computed_gotos -- configured --with(out)-computed-gotos" 5484 else 5485 ac_cv_computed_gotos=no 5486 fi])) 5487AC_MSG_RESULT($ac_cv_computed_gotos) 5488case "$ac_cv_computed_gotos" in yes*) 5489 AC_DEFINE(HAVE_COMPUTED_GOTOS, 1, 5490 [Define if the C compiler supports computed gotos.]) 5491esac 5492 5493case $ac_sys_system in 5494AIX*) 5495 AC_DEFINE(HAVE_BROKEN_PIPE_BUF, 1, [Define if the system reports an invalid PIPE_BUF value.]) ;; 5496esac 5497 5498 5499AC_SUBST(THREADHEADERS) 5500 5501for h in `(cd $srcdir;echo Python/thread_*.h)` 5502do 5503 THREADHEADERS="$THREADHEADERS \$(srcdir)/$h" 5504done 5505 5506AC_SUBST(SRCDIRS) 5507SRCDIRS="Parser Parser/pegen Objects Python Modules Modules/_io Programs" 5508AC_MSG_CHECKING(for build directories) 5509for dir in $SRCDIRS; do 5510 if test ! -d $dir; then 5511 mkdir $dir 5512 fi 5513done 5514AC_MSG_RESULT(done) 5515 5516# Availability of -O2: 5517AC_MSG_CHECKING(for -O2) 5518saved_cflags="$CFLAGS" 5519CFLAGS="-O2" 5520AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[ 5521]])],[have_O2=yes],[have_O2=no]) 5522AC_MSG_RESULT($have_O2) 5523CFLAGS="$saved_cflags" 5524 5525# _FORTIFY_SOURCE wrappers for memmove and bcopy are incorrect: 5526# http://sourceware.org/ml/libc-alpha/2010-12/msg00009.html 5527AC_MSG_CHECKING(for glibc _FORTIFY_SOURCE/memmove bug) 5528saved_cflags="$CFLAGS" 5529CFLAGS="-O2 -D_FORTIFY_SOURCE=2" 5530if test "$have_O2" = no; then 5531 CFLAGS="" 5532fi 5533AC_RUN_IFELSE([AC_LANG_SOURCE([[ 5534#include <stdio.h> 5535#include <stdlib.h> 5536#include <string.h> 5537void foo(void *p, void *q) { memmove(p, q, 19); } 5538int main() { 5539 char a[32] = "123456789000000000"; 5540 foo(&a[9], a); 5541 if (strcmp(a, "123456789123456789000000000") != 0) 5542 return 1; 5543 foo(a, &a[9]); 5544 if (strcmp(a, "123456789000000000") != 0) 5545 return 1; 5546 return 0; 5547} 5548]])], 5549[have_glibc_memmove_bug=no], 5550[have_glibc_memmove_bug=yes], 5551[have_glibc_memmove_bug=undefined]) 5552CFLAGS="$saved_cflags" 5553AC_MSG_RESULT($have_glibc_memmove_bug) 5554if test "$have_glibc_memmove_bug" = yes; then 5555 AC_DEFINE(HAVE_GLIBC_MEMMOVE_BUG, 1, 5556 [Define if glibc has incorrect _FORTIFY_SOURCE wrappers 5557 for memmove and bcopy.]) 5558fi 5559 5560if test "$have_gcc_asm_for_x87" = yes; then 5561 # Some versions of gcc miscompile inline asm: 5562 # http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46491 5563 # http://gcc.gnu.org/ml/gcc/2010-11/msg00366.html 5564 case $CC in 5565 *gcc*) 5566 AC_MSG_CHECKING(for gcc ipa-pure-const bug) 5567 saved_cflags="$CFLAGS" 5568 CFLAGS="-O2" 5569 AC_RUN_IFELSE([AC_LANG_SOURCE([[ 5570 __attribute__((noinline)) int 5571 foo(int *p) { 5572 int r; 5573 asm ( "movl \$6, (%1)\n\t" 5574 "xorl %0, %0\n\t" 5575 : "=r" (r) : "r" (p) : "memory" 5576 ); 5577 return r; 5578 } 5579 int main() { 5580 int p = 8; 5581 if ((foo(&p) ? : p) != 6) 5582 return 1; 5583 return 0; 5584 } 5585 ]])], 5586 [have_ipa_pure_const_bug=no], 5587 [have_ipa_pure_const_bug=yes], 5588 [have_ipa_pure_const_bug=undefined]) 5589 CFLAGS="$saved_cflags" 5590 AC_MSG_RESULT($have_ipa_pure_const_bug) 5591 if test "$have_ipa_pure_const_bug" = yes; then 5592 AC_DEFINE(HAVE_IPA_PURE_CONST_BUG, 1, 5593 [Define if gcc has the ipa-pure-const bug.]) 5594 fi 5595 ;; 5596 esac 5597fi 5598 5599# Check for stdatomic.h 5600AC_MSG_CHECKING(for stdatomic.h) 5601AC_LINK_IFELSE( 5602[ 5603 AC_LANG_SOURCE([[ 5604 #include <stdatomic.h> 5605 atomic_int int_var; 5606 atomic_uintptr_t uintptr_var; 5607 int main() { 5608 atomic_store_explicit(&int_var, 5, memory_order_relaxed); 5609 atomic_store_explicit(&uintptr_var, 0, memory_order_relaxed); 5610 int loaded_value = atomic_load_explicit(&int_var, memory_order_seq_cst); 5611 return 0; 5612 } 5613 ]]) 5614],[have_stdatomic_h=yes],[have_stdatomic_h=no]) 5615 5616AC_MSG_RESULT($have_stdatomic_h) 5617 5618if test "$have_stdatomic_h" = yes; then 5619 AC_DEFINE(HAVE_STD_ATOMIC, 1, 5620 [Has stdatomic.h with atomic_int and atomic_uintptr_t]) 5621fi 5622 5623# Check for GCC >= 4.7 __atomic builtins 5624AC_MSG_CHECKING(for GCC >= 4.7 __atomic builtins) 5625AC_LINK_IFELSE( 5626[ 5627 AC_LANG_SOURCE([[ 5628 volatile int val = 1; 5629 int main() { 5630 __atomic_load_n(&val, __ATOMIC_SEQ_CST); 5631 return 0; 5632 } 5633 ]]) 5634],[have_builtin_atomic=yes],[have_builtin_atomic=no]) 5635 5636AC_MSG_RESULT($have_builtin_atomic) 5637 5638if test "$have_builtin_atomic" = yes; then 5639 AC_DEFINE(HAVE_BUILTIN_ATOMIC, 1, [Has builtin atomics]) 5640fi 5641 5642# ensurepip option 5643AC_MSG_CHECKING(for ensurepip) 5644AC_ARG_WITH(ensurepip, 5645 [AS_HELP_STRING([--with-ensurepip@<:@=install|upgrade|no@:>@], 5646 ["install" or "upgrade" using bundled pip (default is upgrade)])], 5647 [], 5648 [with_ensurepip=upgrade]) 5649AS_CASE($with_ensurepip, 5650 [yes|upgrade],[ENSUREPIP=upgrade], 5651 [install],[ENSUREPIP=install], 5652 [no],[ENSUREPIP=no], 5653 [AC_MSG_ERROR([--with-ensurepip=upgrade|install|no])]) 5654AC_MSG_RESULT($ENSUREPIP) 5655AC_SUBST(ENSUREPIP) 5656 5657# check if the dirent structure of a d_type field and DT_UNKNOWN is defined 5658AC_MSG_CHECKING(if the dirent structure of a d_type field) 5659AC_LINK_IFELSE( 5660[ 5661 AC_LANG_SOURCE([[ 5662 #include <dirent.h> 5663 5664 int main() { 5665 struct dirent entry; 5666 return entry.d_type == DT_UNKNOWN; 5667 } 5668 ]]) 5669],[have_dirent_d_type=yes],[have_dirent_d_type=no]) 5670AC_MSG_RESULT($have_dirent_d_type) 5671 5672if test "$have_dirent_d_type" = yes; then 5673 AC_DEFINE(HAVE_DIRENT_D_TYPE, 1, 5674 [Define to 1 if the dirent structure has a d_type field]) 5675fi 5676 5677# check if the Linux getrandom() syscall is available 5678AC_MSG_CHECKING(for the Linux getrandom() syscall) 5679AC_LINK_IFELSE( 5680[ 5681 AC_LANG_SOURCE([[ 5682 #include <unistd.h> 5683 #include <sys/syscall.h> 5684 #include <linux/random.h> 5685 5686 int main() { 5687 char buffer[1]; 5688 const size_t buflen = sizeof(buffer); 5689 const int flags = GRND_NONBLOCK; 5690 /* ignore the result, Python checks for ENOSYS and EAGAIN at runtime */ 5691 (void)syscall(SYS_getrandom, buffer, buflen, flags); 5692 return 0; 5693 } 5694 ]]) 5695],[have_getrandom_syscall=yes],[have_getrandom_syscall=no]) 5696AC_MSG_RESULT($have_getrandom_syscall) 5697 5698if test "$have_getrandom_syscall" = yes; then 5699 AC_DEFINE(HAVE_GETRANDOM_SYSCALL, 1, 5700 [Define to 1 if the Linux getrandom() syscall is available]) 5701fi 5702 5703# check if the getrandom() function is available 5704# the test was written for the Solaris function of <sys/random.h> 5705AC_MSG_CHECKING(for the getrandom() function) 5706AC_LINK_IFELSE( 5707[ 5708 AC_LANG_SOURCE([[ 5709 #include <sys/random.h> 5710 5711 int main() { 5712 char buffer[1]; 5713 const size_t buflen = sizeof(buffer); 5714 const int flags = 0; 5715 /* ignore the result, Python checks for ENOSYS at runtime */ 5716 (void)getrandom(buffer, buflen, flags); 5717 return 0; 5718 } 5719 ]]) 5720],[have_getrandom=yes],[have_getrandom=no]) 5721AC_MSG_RESULT($have_getrandom) 5722 5723if test "$have_getrandom" = yes; then 5724 AC_DEFINE(HAVE_GETRANDOM, 1, 5725 [Define to 1 if the getrandom() function is available]) 5726fi 5727 5728# checks for POSIX shared memory, used by Modules/_multiprocessing/posixshmem.c 5729# shm_* may only be available if linking against librt 5730save_LIBS="$LIBS" 5731save_includes_default="$ac_includes_default" 5732AC_SEARCH_LIBS(shm_open, rt) 5733if test "$ac_cv_search_shm_open" = "-lrt"; then 5734 AC_DEFINE(SHM_NEEDS_LIBRT, 1, 5735 [Define to 1 if you must link with -lrt for shm_open().]) 5736fi 5737AC_CHECK_HEADERS(sys/mman.h) 5738# temporarily override ac_includes_default for AC_CHECK_FUNCS below 5739ac_includes_default="\ 5740${ac_includes_default} 5741#ifndef __cplusplus 5742# ifdef HAVE_SYS_MMAN_H 5743# include <sys/mman.h> 5744# endif 5745#endif 5746" 5747AC_CHECK_FUNCS([shm_open shm_unlink]) 5748# we don't want to link with librt always, restore LIBS 5749LIBS="$save_LIBS" 5750ac_includes_default="$save_includes_default" 5751 5752# Check for usable OpenSSL 5753AX_CHECK_OPENSSL([have_openssl=yes],[have_openssl=no]) 5754 5755if test "$have_openssl" = yes; then 5756 AC_MSG_CHECKING([for X509_VERIFY_PARAM_set1_host in libssl]) 5757 5758 save_LIBS="$LIBS" 5759 save_LDFLAGS="$LDFLAGS" 5760 save_CPPFLAGS="$CPPFLAGS" 5761 LDFLAGS="$LDFLAGS $OPENSSL_LDFLAGS" 5762 LIBS="$OPENSSL_LIBS $LIBS" 5763 CPPFLAGS="$OPENSSL_INCLUDES $CPPFLAGS" 5764 5765 AC_LINK_IFELSE([AC_LANG_PROGRAM([ 5766 [#include <openssl/x509_vfy.h>] 5767 ], [ 5768 [X509_VERIFY_PARAM *p = X509_VERIFY_PARAM_new();] 5769 [X509_VERIFY_PARAM_set1_host(p, "localhost", 0);] 5770 [X509_VERIFY_PARAM_set1_ip_asc(p, "127.0.0.1");] 5771 [X509_VERIFY_PARAM_set_hostflags(p, 0);] 5772 ]) 5773 ], 5774 [ 5775 ac_cv_has_x509_verify_param_set1_host=yes 5776 ], 5777 [ 5778 ac_cv_has_x509_verify_param_set1_host=no 5779 ]) 5780 AC_MSG_RESULT($ac_cv_has_x509_verify_param_set1_host) 5781 if test "$ac_cv_has_x509_verify_param_set1_host" = "yes"; then 5782 AC_DEFINE(HAVE_X509_VERIFY_PARAM_SET1_HOST, 1, 5783 [Define if libssl has X509_VERIFY_PARAM_set1_host and related function]) 5784 fi 5785 5786 CPPFLAGS="$save_CPPFLAGS" 5787 LDFLAGS="$save_LDFLAGS" 5788 LIBS="$save_LIBS" 5789fi 5790 5791# ssl module default cipher suite string 5792AH_TEMPLATE(PY_SSL_DEFAULT_CIPHERS, 5793 [Default cipher suites list for ssl module. 5794 1: Python's preferred selection, 2: leave OpenSSL defaults untouched, 0: custom string]) 5795AH_TEMPLATE(PY_SSL_DEFAULT_CIPHER_STRING, 5796 [Cipher suite string for PY_SSL_DEFAULT_CIPHERS=0] 5797) 5798 5799AC_MSG_CHECKING(for --with-ssl-default-suites) 5800AC_ARG_WITH(ssl-default-suites, 5801 AS_HELP_STRING([--with-ssl-default-suites=@<:@python|openssl|STRING@:>@], 5802 [override default cipher suites string, 5803 python: use Python's preferred selection (default), 5804 openssl: leave OpenSSL's defaults untouched, 5805 STRING: use a custom string, 5806 PROTOCOL_SSLv2 ignores the setting, see Doc/library/ssl.rst]), 5807[ 5808AC_MSG_RESULT($withval) 5809case "$withval" in 5810 python) 5811 AC_DEFINE(PY_SSL_DEFAULT_CIPHERS, 1) 5812 ;; 5813 openssl) 5814 AC_DEFINE(PY_SSL_DEFAULT_CIPHERS, 2) 5815 ;; 5816 *) 5817 AC_DEFINE(PY_SSL_DEFAULT_CIPHERS, 0) 5818 AC_DEFINE_UNQUOTED(PY_SSL_DEFAULT_CIPHER_STRING, "$withval") 5819 ;; 5820esac 5821], 5822[ 5823AC_MSG_RESULT(python) 5824AC_DEFINE(PY_SSL_DEFAULT_CIPHERS, 1) 5825]) 5826 5827# builtin hash modules 5828default_hashlib_hashes="md5,sha1,sha256,sha512,sha3,blake2" 5829AC_DEFINE([PY_BUILTIN_HASHLIB_HASHES], [], [enabled builtin hash modules] 5830) 5831AC_MSG_CHECKING(for --with-builtin-hashlib-hashes) 5832AC_ARG_WITH(builtin-hashlib-hashes, 5833 AS_HELP_STRING([--with-builtin-hashlib-hashes=md5,sha1,sha256,sha512,sha3,blake2], 5834 [builtin hash modules, 5835 md5, sha1, sha256, sha512, sha3 (with shake), blake2]), 5836[ 5837case "$withval" in 5838 yes) 5839 withval=$default_hashlib_hashes 5840 ;; 5841 no) 5842 withval="" 5843 ;; 5844esac 5845AC_MSG_RESULT($withval) 5846AC_DEFINE_UNQUOTED(PY_BUILTIN_HASHLIB_HASHES, "$withval") 5847], 5848[ 5849AC_MSG_RESULT($default_hashlib_hashes); 5850AC_DEFINE_UNQUOTED(PY_BUILTIN_HASHLIB_HASHES, "$default_hashlib_hashes") 5851]) 5852 5853# generate output files 5854AC_CONFIG_FILES(Makefile.pre Misc/python.pc Misc/python-embed.pc Misc/python-config.sh) 5855AC_CONFIG_FILES([Modules/ld_so_aix], [chmod +x Modules/ld_so_aix]) 5856AC_OUTPUT 5857 5858echo "creating Modules/Setup.local" >&AS_MESSAGE_FD 5859if test ! -f Modules/Setup.local 5860then 5861 echo "# Edit this file for local setup changes" >Modules/Setup.local 5862fi 5863 5864echo "creating Makefile" >&AS_MESSAGE_FD 5865$SHELL $srcdir/Modules/makesetup -c $srcdir/Modules/config.c.in \ 5866 -s Modules \ 5867 Modules/Setup.local $srcdir/Modules/Setup 5868mv config.c Modules 5869 5870if test "$Py_OPT" = 'false' -a "$Py_DEBUG" != 'true'; then 5871 echo "" >&AS_MESSAGE_FD 5872 echo "" >&AS_MESSAGE_FD 5873 echo "If you want a release build with all stable optimizations active (PGO, etc)," >&AS_MESSAGE_FD 5874 echo "please run ./configure --enable-optimizations" >&AS_MESSAGE_FD 5875 echo "" >&AS_MESSAGE_FD 5876 echo "" >&AS_MESSAGE_FD 5877fi 5878 5879