blob: 1edafc342b7120b9253cd03dd2ee9df7b146da83 [file] [log] [blame]
Benjamin Petersonfbeb6b62008-05-26 16:04:49 +00001dnl ***********************************************
2dnl * Please run autoreconf to test your changes! *
3dnl ***********************************************
Martin v. Löwis88afe662002-10-26 13:47:44 +00004
5# Set VERSION so we only need to edit in one place (i.e., here)
Pablo Galindod4fe0982020-05-19 03:33:01 +01006m4_define(PYTHON_VERSION, 3.10)
Martin v. Löwis88afe662002-10-26 13:47:44 +00007
Eitan Adler24f68462018-09-14 15:55:20 -07008AC_PREREQ([2.69])
Alexandre Vassalottib89910f2009-07-18 00:33:23 +00009
Eitan Adler24f68462018-09-14 15:55:20 -070010AC_INIT([python],[PYTHON_VERSION],[https://bugs.python.org/])
Benjamin Peterson8c6f88e2011-05-31 20:52:17 -050011
Christian Heimesff5be6e2018-01-20 13:19:21 +010012AC_CONFIG_MACRO_DIR(m4)
13
Trent Nelson4d4ec652012-10-16 08:51:24 -040014AC_SUBST(BASECPPFLAGS)
Martin Panterc5ee3ca2016-09-12 01:32:03 +000015if test "$srcdir" != . -a "$srcdir" != "$(pwd)"; then
Trent Nelson4d4ec652012-10-16 08:51:24 -040016 # If we're building out-of-tree, we need to make sure the following
17 # resources get picked up before their $srcdir counterparts.
18 # Objects/ -> typeslots.inc
Lysandros Nikolaou314858e2020-06-20 21:07:25 +030019 # Include/ -> Python-ast.h
Trent Nelson4d4ec652012-10-16 08:51:24 -040020 # Python/ -> importlib.h
21 # (A side effect of this is that these resources will automatically be
22 # regenerated when building out-of-tree, regardless of whether or not
23 # the $srcdir counterpart is up-to-date. This is an acceptable trade
24 # off.)
25 BASECPPFLAGS="-IObjects -IInclude -IPython"
26else
27 BASECPPFLAGS=""
28fi
29
Ned Deily5c4b0d02017-03-04 00:19:55 -050030AC_SUBST(GITVERSION)
31AC_SUBST(GITTAG)
32AC_SUBST(GITBRANCH)
Benjamin Peterson8c6f88e2011-05-31 20:52:17 -050033
Victor Stinner5facdbb2017-05-02 21:42:48 +020034if test -e $srcdir/.git
Benjamin Peterson8c6f88e2011-05-31 20:52:17 -050035then
Ned Deily5c4b0d02017-03-04 00:19:55 -050036AC_CHECK_PROG(HAS_GIT, git, found, not-found)
Benjamin Peterson8c6f88e2011-05-31 20:52:17 -050037else
Ned Deily5c4b0d02017-03-04 00:19:55 -050038HAS_GIT=no-repository
Benjamin Peterson8c6f88e2011-05-31 20:52:17 -050039fi
Ned Deily5c4b0d02017-03-04 00:19:55 -050040if test $HAS_GIT = found
Benjamin Peterson8c6f88e2011-05-31 20:52:17 -050041then
Xiang Zhang4c855572018-08-20 22:36:19 +080042 GITVERSION="git --git-dir \$(srcdir)/.git rev-parse --short HEAD"
43 GITTAG="git --git-dir \$(srcdir)/.git describe --all --always --dirty"
44 GITBRANCH="git --git-dir \$(srcdir)/.git name-rev --name-only HEAD"
Benjamin Peterson8c6f88e2011-05-31 20:52:17 -050045else
Ned Deily5c4b0d02017-03-04 00:19:55 -050046 GITVERSION=""
47 GITTAG=""
48 GITBRANCH=""
Benjamin Peterson8c6f88e2011-05-31 20:52:17 -050049fi
50
Martin v. Löwis88afe662002-10-26 13:47:44 +000051AC_CONFIG_SRCDIR([Include/object.h])
Martin v. Löwis4f1cd8b2001-07-26 13:41:06 +000052AC_CONFIG_HEADER(pyconfig.h)
Guido van Rossum627b2d71993-12-24 10:39:16 +000053
Matthias Kloseca2f6ec2012-03-15 21:30:11 +010054AC_CANONICAL_HOST
doko@python.orga10e4a92013-01-25 18:45:12 +010055AC_SUBST(build)
56AC_SUBST(host)
Matthias Kloseca2f6ec2012-03-15 21:30:11 +010057
Ned Deilyfcbc2462014-08-22 13:32:49 -070058# pybuilddir.txt will be created by --generate-posix-vars in the Makefile
59rm -f pybuilddir.txt
60
Victor Stinnera5c62a82017-05-03 18:21:48 +020061AC_CHECK_PROGS(PYTHON_FOR_REGEN, python$PACKAGE_VERSION python3 python, python3)
62AC_SUBST(PYTHON_FOR_REGEN)
Xavier de Gayefd0d5932016-07-26 12:48:08 +020063
doko@ubuntu.com1abe1c52012-06-30 20:42:45 +020064if test "$cross_compiling" = yes; then
65 AC_MSG_CHECKING([for python interpreter for cross build])
66 if test -z "$PYTHON_FOR_BUILD"; then
67 for interp in python$PACKAGE_VERSION python3 python; do
68 which $interp >/dev/null 2>&1 || continue
Xavier de Gaye4afd1432016-07-07 18:00:22 +020069 if $interp -c "import sys;sys.exit(not '.'.join(str(n) for n in sys.version_info@<:@:2@:>@) == '$PACKAGE_VERSION')"; then
doko@ubuntu.com1abe1c52012-06-30 20:42:45 +020070 break
71 fi
72 interp=
73 done
74 if test x$interp = x; then
75 AC_MSG_ERROR([python$PACKAGE_VERSION interpreter not found])
76 fi
77 AC_MSG_RESULT($interp)
Xavier de Gaye92dec542016-09-11 22:22:24 +020078 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
doko@ubuntu.com1abe1c52012-06-30 20:42:45 +020079 fi
Christian Heimes954ac032012-12-12 13:10:21 +010080elif test "$cross_compiling" = maybe; then
81 AC_MSG_ERROR([Cross compiling required --host=HOST-TUPLE and --build=ARCH])
doko@ubuntu.com1abe1c52012-06-30 20:42:45 +020082else
83 PYTHON_FOR_BUILD='./$(BUILDPYTHON) -E'
84fi
85AC_SUBST(PYTHON_FOR_BUILD)
86
Benjamin Petersond23f8222009-04-05 19:13:16 +000087dnl Ensure that if prefix is specified, it does not end in a slash. If
88dnl it does, we get path names containing '//' which is both ugly and
89dnl can cause trouble.
90
91dnl Last slash shouldn't be stripped if prefix=/
92if test "$prefix" != "/"; then
93 prefix=`echo "$prefix" | sed -e 's/\/$//g'`
Victor Stinner1b80b242016-04-12 22:34:58 +020094fi
Benjamin Petersond23f8222009-04-05 19:13:16 +000095
Martin v. Löwis8316feb2003-06-14 07:48:07 +000096dnl This is for stuff that absolutely must end up in pyconfig.h.
97dnl Please use pyport.h instead, if possible.
Martin v. Löwisbddf5a52002-11-11 13:37:28 +000098AH_TOP([
99#ifndef Py_PYCONFIG_H
100#define Py_PYCONFIG_H
101])
Martin v. Löwis11437992002-04-12 09:54:03 +0000102AH_BOTTOM([
Martin v. Löwis11437992002-04-12 09:54:03 +0000103/* Define the macros needed if on a UnixWare 7.x system. */
104#if defined(__USLC__) && defined(__SCO_VERSION__)
105#define STRICT_SYSV_CURSES /* Don't use ncurses extensions */
106#endif
Martin v. Löwisbddf5a52002-11-11 13:37:28 +0000107
108#endif /*Py_PYCONFIG_H*/
Martin v. Löwis11437992002-04-12 09:54:03 +0000109])
110
Martin v. Löwis8316feb2003-06-14 07:48:07 +0000111# We don't use PACKAGE_ variables, and they cause conflicts
112# with other autoconf-based packages that include Python.h
113grep -v 'define PACKAGE_' <confdefs.h >confdefs.h.new
114rm confdefs.h
115mv confdefs.h.new confdefs.h
116
Guido van Rossum642b6781997-07-19 19:35:41 +0000117AC_SUBST(VERSION)
Martin v. Löwis88afe662002-10-26 13:47:44 +0000118VERSION=PYTHON_VERSION
Guido van Rossum642b6781997-07-19 19:35:41 +0000119
Georg Brandlde7d8342010-09-03 22:19:07 +0000120# Version number of Python's own shared library file.
Martin v. Löwis1142de32002-03-29 16:28:31 +0000121AC_SUBST(SOVERSION)
122SOVERSION=1.0
123
Martin v. Löwis6f18a3c2002-07-20 08:51:52 +0000124# The later defininition of _XOPEN_SOURCE disables certain features
125# on Linux, so we need _GNU_SOURCE to re-enable them (makedev, tm_zone).
126AC_DEFINE(_GNU_SOURCE, 1, [Define on Linux to activate all library features])
127
Martin v. Löwisbcd93962003-05-03 10:32:18 +0000128# The later defininition of _XOPEN_SOURCE and _POSIX_C_SOURCE disables
129# certain features on NetBSD, so we need _NETBSD_SOURCE to re-enable
130# them.
131AC_DEFINE(_NETBSD_SOURCE, 1, [Define on NetBSD to activate all library features])
132
Andrew MacIntyreabccf412003-07-02 13:53:25 +0000133# The later defininition of _XOPEN_SOURCE and _POSIX_C_SOURCE disables
134# certain features on FreeBSD, so we need __BSD_VISIBLE to re-enable
135# them.
136AC_DEFINE(__BSD_VISIBLE, 1, [Define on FreeBSD to activate all library features])
137
Martin v. Löwisd6320502004-08-12 13:45:08 +0000138# The later defininition of _XOPEN_SOURCE and _POSIX_C_SOURCE disables
Georg Brandlfcaf9102008-07-16 02:17:56 +0000139# certain features on Mac OS X, so we need _DARWIN_C_SOURCE to re-enable
140# them.
141AC_DEFINE(_DARWIN_C_SOURCE, 1, [Define on Darwin to activate all library features])
142
143
Martin v. Löwise981a4e2002-11-11 13:26:51 +0000144define_xopen_source=yes
Martin v. Löwis6f18a3c2002-07-20 08:51:52 +0000145
Neil Schemenauer4edbc2a2001-03-22 00:34:03 +0000146# Arguments passed to configure.
147AC_SUBST(CONFIG_ARGS)
148CONFIG_ARGS="$ac_configure_args"
149
Ronald Oussoren8af24c12010-02-07 12:03:42 +0000150AC_MSG_CHECKING([for --enable-universalsdk])
Thomas Wouters477c8d52006-05-27 19:21:47 +0000151AC_ARG_ENABLE(universalsdk,
Anthony Shaw2de064e2020-01-14 17:40:10 +1100152 AS_HELP_STRING([--enable-universalsdk@<:@=SDKDIR@:>@],
153 [create a universal binary build.
154 SDKDIR specifies which macOS SDK should be used to perform the build,
155 see Mac/README.rst. (default is no)]),
Thomas Wouters477c8d52006-05-27 19:21:47 +0000156[
157 case $enableval in
158 yes)
Eitan Adlerb5c246f2018-06-02 07:16:19 -0700159 # Locate the best usable SDK, see Mac/README for more
Ned Deilycbfb9a52012-06-23 16:02:19 -0700160 # information
161 enableval="`/usr/bin/xcodebuild -version -sdk macosx Path 2>/dev/null`"
Ned Deily87adb6e2013-10-18 21:09:56 -0700162 if ! ( echo $enableval | grep -E '\.sdk' 1>/dev/null )
Ronald Oussoren8af24c12010-02-07 12:03:42 +0000163 then
Ned Deilycbfb9a52012-06-23 16:02:19 -0700164 enableval=/Developer/SDKs/MacOSX10.4u.sdk
165 if test ! -d "${enableval}"
166 then
167 enableval=/
168 fi
Ronald Oussoren8af24c12010-02-07 12:03:42 +0000169 fi
Thomas Wouters477c8d52006-05-27 19:21:47 +0000170 ;;
171 esac
172 case $enableval in
173 no)
174 UNIVERSALSDK=
175 enable_universalsdk=
176 ;;
177 *)
178 UNIVERSALSDK=$enableval
Ronald Oussoren8af24c12010-02-07 12:03:42 +0000179 if test ! -d "${UNIVERSALSDK}"
180 then
181 AC_MSG_ERROR([--enable-universalsdk specifies non-existing SDK: ${UNIVERSALSDK}])
182 fi
Thomas Wouters477c8d52006-05-27 19:21:47 +0000183 ;;
184 esac
Victor Stinner1b80b242016-04-12 22:34:58 +0200185
Thomas Wouters477c8d52006-05-27 19:21:47 +0000186],[
187 UNIVERSALSDK=
188 enable_universalsdk=
189])
Ronald Oussoren8af24c12010-02-07 12:03:42 +0000190if test -n "${UNIVERSALSDK}"
191then
192 AC_MSG_RESULT(${UNIVERSALSDK})
193else
194 AC_MSG_RESULT(no)
195fi
Thomas Wouters477c8d52006-05-27 19:21:47 +0000196AC_SUBST(UNIVERSALSDK)
197
Benjamin Peterson6794aa32008-07-16 20:33:37 +0000198AC_SUBST(ARCH_RUN_32BIT)
Ned Deily87adb6e2013-10-18 21:09:56 -0700199ARCH_RUN_32BIT=""
Benjamin Peterson6794aa32008-07-16 20:33:37 +0000200
Ned Deilycbfb9a52012-06-23 16:02:19 -0700201# For backward compatibility reasons we prefer to select '32-bit' if available,
202# otherwise use 'intel'
Georg Brandlfcaf9102008-07-16 02:17:56 +0000203UNIVERSAL_ARCHS="32-bit"
Ned Deilycbfb9a52012-06-23 16:02:19 -0700204if test "`uname -s`" = "Darwin"
205then
206 if test -n "${UNIVERSALSDK}"
207 then
Ned Deily87adb6e2013-10-18 21:09:56 -0700208 if test -z "`/usr/bin/file -L "${UNIVERSALSDK}/usr/lib/libSystem.dylib" | grep ppc`"
Ned Deilycbfb9a52012-06-23 16:02:19 -0700209 then
210 UNIVERSAL_ARCHS="intel"
211 fi
212 fi
213fi
214
Ronald Oussoren6f6c5622009-12-24 14:03:19 +0000215AC_SUBST(LIPO_32BIT_FLAGS)
Georg Brandlfcaf9102008-07-16 02:17:56 +0000216AC_MSG_CHECKING(for --with-universal-archs)
217AC_ARG_WITH(universal-archs,
Anthony Shaw2de064e2020-01-14 17:40:10 +1100218 AS_HELP_STRING([--with-universal-archs=ARCH],
219 [specify the kind of universal binary that should be created. this option is
220 only valid when --enable-universalsdk is set; options are:
Ronald Oussoren41761932020-11-08 10:05:27 +0100221 ("universal2", "32-bit", "64-bit", "3-way", "intel", "intel-32", "intel-64", or "all")
Anthony Shaw2de064e2020-01-14 17:40:10 +1100222 see Mac/README.rst]),
Georg Brandlfcaf9102008-07-16 02:17:56 +0000223[
Georg Brandlfcaf9102008-07-16 02:17:56 +0000224 UNIVERSAL_ARCHS="$withval"
225],
Ned Deily87adb6e2013-10-18 21:09:56 -0700226[])
227if test -n "${UNIVERSALSDK}"
228then
229 AC_MSG_RESULT(${UNIVERSAL_ARCHS})
230else
231 AC_MSG_RESULT(no)
232fi
Georg Brandlfcaf9102008-07-16 02:17:56 +0000233
Christian Heimes81ee3ef2008-05-04 22:42:01 +0000234AC_ARG_WITH(framework-name,
Matthias Klose2b8733f2010-04-25 18:34:36 +0000235 AS_HELP_STRING([--with-framework-name=FRAMEWORK],
Anthony Shaw2de064e2020-01-14 17:40:10 +1100236 [specify the name for the python framework on macOS
237 only valid when --enable-framework is set. see Mac/README.rst
238 (default is 'Python')]),
Christian Heimes81ee3ef2008-05-04 22:42:01 +0000239[
240 PYTHONFRAMEWORK=${withval}
241 PYTHONFRAMEWORKDIR=${withval}.framework
242 PYTHONFRAMEWORKIDENTIFIER=org.python.`echo $withval | tr '[A-Z]' '[a-z]'`
243 ],[
244 PYTHONFRAMEWORK=Python
245 PYTHONFRAMEWORKDIR=Python.framework
246 PYTHONFRAMEWORKIDENTIFIER=org.python.python
247])
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000248dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000249AC_ARG_ENABLE(framework,
Anthony Shaw2de064e2020-01-14 17:40:10 +1100250 AS_HELP_STRING([--enable-framework@<:@=INSTALLDIR@:>@],
251 [create a Python.framework rather than a traditional Unix install.
252 optional INSTALLDIR specifies the installation path. see Mac/README.rst
253 (default is no)]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000254[
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000255 case $enableval in
Victor Stinner1b80b242016-04-12 22:34:58 +0200256 yes)
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000257 enableval=/Library/Frameworks
Jack Jansen127e56e2001-09-11 14:41:54 +0000258 esac
259 case $enableval in
260 no)
261 PYTHONFRAMEWORK=
262 PYTHONFRAMEWORKDIR=no-framework
263 PYTHONFRAMEWORKPREFIX=
264 PYTHONFRAMEWORKINSTALLDIR=
Thomas Wouters477c8d52006-05-27 19:21:47 +0000265 FRAMEWORKINSTALLFIRST=
266 FRAMEWORKINSTALLLAST=
Thomas Wouters73e5a5b2006-06-08 15:35:45 +0000267 FRAMEWORKALTINSTALLFIRST=
268 FRAMEWORKALTINSTALLLAST=
Ned Deilyb8f944f2013-11-21 22:42:25 -0800269 FRAMEWORKPYTHONW=
Thomas Wouters73e5a5b2006-06-08 15:35:45 +0000270 if test "x${prefix}" = "xNONE"; then
271 FRAMEWORKUNIXTOOLSPREFIX="${ac_default_prefix}"
272 else
273 FRAMEWORKUNIXTOOLSPREFIX="${prefix}"
274 fi
Jack Jansen127e56e2001-09-11 14:41:54 +0000275 enable_framework=
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000276 ;;
277 *)
Ronald Oussoren86b33c82010-04-30 11:41:56 +0000278 PYTHONFRAMEWORKPREFIX="${enableval}"
Jack Jansen127e56e2001-09-11 14:41:54 +0000279 PYTHONFRAMEWORKINSTALLDIR=$PYTHONFRAMEWORKPREFIX/$PYTHONFRAMEWORKDIR
Thomas Wouters477c8d52006-05-27 19:21:47 +0000280 FRAMEWORKINSTALLFIRST="frameworkinstallstructure"
Ronald Oussorenf6ccbf62009-06-02 10:55:56 +0000281 FRAMEWORKALTINSTALLFIRST="frameworkinstallstructure "
Ronald Oussoren6f6c5622009-12-24 14:03:19 +0000282 FRAMEWORKINSTALLLAST="frameworkinstallmaclib frameworkinstallapps frameworkinstallunixtools"
283 FRAMEWORKALTINSTALLLAST="frameworkinstallmaclib frameworkinstallapps frameworkaltinstallunixtools"
Ned Deilyb8f944f2013-11-21 22:42:25 -0800284 FRAMEWORKPYTHONW="frameworkpythonw"
Ronald Oussoren86b33c82010-04-30 11:41:56 +0000285 FRAMEWORKINSTALLAPPSPREFIX="/Applications"
Georg Brandlfcaf9102008-07-16 02:17:56 +0000286
Thomas Wouters73e5a5b2006-06-08 15:35:45 +0000287 if test "x${prefix}" = "xNONE" ; then
288 FRAMEWORKUNIXTOOLSPREFIX="${ac_default_prefix}"
Ronald Oussoren86b33c82010-04-30 11:41:56 +0000289
Thomas Wouters73e5a5b2006-06-08 15:35:45 +0000290 else
291 FRAMEWORKUNIXTOOLSPREFIX="${prefix}"
292 fi
Ronald Oussoren86b33c82010-04-30 11:41:56 +0000293
294 case "${enableval}" in
295 /System*)
296 FRAMEWORKINSTALLAPPSPREFIX="/Applications"
297 if test "${prefix}" = "NONE" ; then
298 # See below
299 FRAMEWORKUNIXTOOLSPREFIX="/usr"
300 fi
301 ;;
302
303 /Library*)
304 FRAMEWORKINSTALLAPPSPREFIX="/Applications"
305 ;;
306
307 */Library/Frameworks)
308 MDIR="`dirname "${enableval}"`"
309 MDIR="`dirname "${MDIR}"`"
310 FRAMEWORKINSTALLAPPSPREFIX="${MDIR}/Applications"
311
312 if test "${prefix}" = "NONE"; then
Victor Stinner1b80b242016-04-12 22:34:58 +0200313 # User hasn't specified the
Ronald Oussoren86b33c82010-04-30 11:41:56 +0000314 # --prefix option, but wants to install
315 # the framework in a non-default location,
316 # ensure that the compatibility links get
317 # installed relative to that prefix as well
318 # instead of in /usr/local.
319 FRAMEWORKUNIXTOOLSPREFIX="${MDIR}"
320 fi
321 ;;
322
323 *)
324 FRAMEWORKINSTALLAPPSPREFIX="/Applications"
325 ;;
326 esac
327
Jack Jansen127e56e2001-09-11 14:41:54 +0000328 prefix=$PYTHONFRAMEWORKINSTALLDIR/Versions/$VERSION
Thomas Wouters477c8d52006-05-27 19:21:47 +0000329
Christian Heimes81ee3ef2008-05-04 22:42:01 +0000330 # Add files for Mac specific code to the list of output
Thomas Wouters477c8d52006-05-27 19:21:47 +0000331 # files:
Thomas Wouters73e5a5b2006-06-08 15:35:45 +0000332 AC_CONFIG_FILES(Mac/Makefile)
333 AC_CONFIG_FILES(Mac/PythonLauncher/Makefile)
Christian Heimes81ee3ef2008-05-04 22:42:01 +0000334 AC_CONFIG_FILES(Mac/Resources/framework/Info.plist)
335 AC_CONFIG_FILES(Mac/Resources/app/Info.plist)
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000336 esac
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000337 ],[
338 PYTHONFRAMEWORK=
Jack Jansen127e56e2001-09-11 14:41:54 +0000339 PYTHONFRAMEWORKDIR=no-framework
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000340 PYTHONFRAMEWORKPREFIX=
341 PYTHONFRAMEWORKINSTALLDIR=
Thomas Wouters477c8d52006-05-27 19:21:47 +0000342 FRAMEWORKINSTALLFIRST=
343 FRAMEWORKINSTALLLAST=
Thomas Wouters73e5a5b2006-06-08 15:35:45 +0000344 FRAMEWORKALTINSTALLFIRST=
345 FRAMEWORKALTINSTALLLAST=
Ned Deilyb8f944f2013-11-21 22:42:25 -0800346 FRAMEWORKPYTHONW=
Thomas Wouters73e5a5b2006-06-08 15:35:45 +0000347 if test "x${prefix}" = "xNONE" ; then
348 FRAMEWORKUNIXTOOLSPREFIX="${ac_default_prefix}"
349 else
350 FRAMEWORKUNIXTOOLSPREFIX="${prefix}"
351 fi
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000352 enable_framework=
Georg Brandlfcaf9102008-07-16 02:17:56 +0000353
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000354])
355AC_SUBST(PYTHONFRAMEWORK)
Christian Heimes81ee3ef2008-05-04 22:42:01 +0000356AC_SUBST(PYTHONFRAMEWORKIDENTIFIER)
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000357AC_SUBST(PYTHONFRAMEWORKDIR)
358AC_SUBST(PYTHONFRAMEWORKPREFIX)
359AC_SUBST(PYTHONFRAMEWORKINSTALLDIR)
Thomas Wouters477c8d52006-05-27 19:21:47 +0000360AC_SUBST(FRAMEWORKINSTALLFIRST)
361AC_SUBST(FRAMEWORKINSTALLLAST)
Thomas Wouters73e5a5b2006-06-08 15:35:45 +0000362AC_SUBST(FRAMEWORKALTINSTALLFIRST)
363AC_SUBST(FRAMEWORKALTINSTALLLAST)
Ned Deilyb8f944f2013-11-21 22:42:25 -0800364AC_SUBST(FRAMEWORKPYTHONW)
Thomas Wouters73e5a5b2006-06-08 15:35:45 +0000365AC_SUBST(FRAMEWORKUNIXTOOLSPREFIX)
Ronald Oussoren86b33c82010-04-30 11:41:56 +0000366AC_SUBST(FRAMEWORKINSTALLAPPSPREFIX)
Guido van Rossum4b6b5791996-09-09 20:09:34 +0000367
INADA Naoki6b42eb12017-06-29 15:31:38 +0900368AC_DEFINE_UNQUOTED(_PYTHONFRAMEWORK, "${PYTHONFRAMEWORK}", [framework name])
INADA Naokia8f8d5b2017-06-29 00:31:53 +0900369
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000370##AC_ARG_WITH(dyld,
Matthias Klose2b8733f2010-04-25 18:34:36 +0000371## AS_HELP_STRING([--with-dyld],
Anthony Shaw2de064e2020-01-14 17:40:10 +1100372## [use (OpenStep|Rhapsody) dynamic linker]))
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000373##
Guido van Rossumb418f891996-07-30 18:06:02 +0000374# Set name for machine-dependent library files
doko@python.orgeab42bf2013-01-26 18:57:19 +0100375AC_ARG_VAR([MACHDEP], [name for machine-dependent library files])
Guido van Rossumb418f891996-07-30 18:06:02 +0000376AC_MSG_CHECKING(MACHDEP)
377if test -z "$MACHDEP"
378then
Matthias Klosedf2aecb2012-03-15 22:19:28 +0100379 # avoid using uname for cross builds
380 if test "$cross_compiling" = yes; then
doko@python.org44bbbda2013-01-25 14:44:00 +0100381 # ac_sys_system and ac_sys_release are used for setting
382 # a lot of different things including 'define_xopen_source'
383 # in the case statement below.
Matthias Klosedf2aecb2012-03-15 22:19:28 +0100384 case "$host" in
Xavier de Gaye2a352b62017-01-04 21:51:16 +0100385 *-*-linux-android*)
386 ac_sys_system=Linux-android
387 ;;
Matthias Klosedf2aecb2012-03-15 22:19:28 +0100388 *-*-linux*)
389 ac_sys_system=Linux
390 ;;
391 *-*-cygwin*)
392 ac_sys_system=Cygwin
393 ;;
pxinwr32f5fdd2019-02-27 19:09:28 +0800394 *-*-vxworks*)
395 ac_sys_system=VxWorks
396 ;;
Matthias Klosedf2aecb2012-03-15 22:19:28 +0100397 *)
398 # for now, limit cross builds to known configurations
399 MACHDEP="unknown"
400 AC_MSG_ERROR([cross build not supported for $host])
401 esac
402 ac_sys_release=
403 else
Guido van Rossum4b6b5791996-09-09 20:09:34 +0000404 ac_sys_system=`uname -s`
Benjamin Peterson8719ad52009-09-11 22:24:02 +0000405 if test "$ac_sys_system" = "AIX" \
Martin v. Löwis21ee4092002-09-30 16:19:48 +0000406 -o "$ac_sys_system" = "UnixWare" -o "$ac_sys_system" = "OpenUNIX"; then
Guido van Rossum4b6b5791996-09-09 20:09:34 +0000407 ac_sys_release=`uname -v`
Guido van Rossumb418f891996-07-30 18:06:02 +0000408 else
Guido van Rossum4b6b5791996-09-09 20:09:34 +0000409 ac_sys_release=`uname -r`
Guido van Rossumb418f891996-07-30 18:06:02 +0000410 fi
Matthias Klosedf2aecb2012-03-15 22:19:28 +0100411 fi
412 ac_md_system=`echo $ac_sys_system |
413 tr -d '[/ ]' | tr '[[A-Z]]' '[[a-z]]'`
414 ac_md_release=`echo $ac_sys_release |
415 tr -d '[/ ]' | sed 's/^[[A-Z]]\.//' | sed 's/\..*//'`
416 MACHDEP="$ac_md_system$ac_md_release"
Guido van Rossum4b6b5791996-09-09 20:09:34 +0000417
Matthias Klosedf2aecb2012-03-15 22:19:28 +0100418 case $MACHDEP in
Michael Felt9d949f72019-04-12 16:15:32 +0200419 aix*) MACHDEP="aix";;
Victor Stinner7209ff22011-08-21 00:00:16 +0200420 linux*) MACHDEP="linux";;
Andrew M. Kuchling5a3e4cb2001-07-20 19:29:04 +0000421 cygwin*) MACHDEP="cygwin";;
Jack Jansen8a97f4a2001-12-05 23:27:32 +0000422 darwin*) MACHDEP="darwin";;
Guido van Rossumb97ef171997-09-28 05:44:03 +0000423 '') MACHDEP="unknown";;
Matthias Klosedf2aecb2012-03-15 22:19:28 +0100424 esac
Guido van Rossumb418f891996-07-30 18:06:02 +0000425fi
E. M. Brayb1fc4172019-05-24 18:39:39 +0200426AC_MSG_RESULT("$MACHDEP")
doko@ubuntu.com1abe1c52012-06-30 20:42:45 +0200427
428AC_SUBST(_PYTHON_HOST_PLATFORM)
429if test "$cross_compiling" = yes; then
430 case "$host" in
431 *-*-linux*)
432 case "$host_cpu" in
433 arm*)
434 _host_cpu=arm
435 ;;
436 *)
437 _host_cpu=$host_cpu
438 esac
439 ;;
440 *-*-cygwin*)
441 _host_cpu=
442 ;;
pxinwr32f5fdd2019-02-27 19:09:28 +0800443 *-*-vxworks*)
444 _host_cpu=$host_cpu
445 ;;
doko@ubuntu.com1abe1c52012-06-30 20:42:45 +0200446 *)
447 # for now, limit cross builds to known configurations
448 MACHDEP="unknown"
449 AC_MSG_ERROR([cross build not supported for $host])
450 esac
451 _PYTHON_HOST_PLATFORM="$MACHDEP${_host_cpu:+-$_host_cpu}"
452fi
doko@ubuntu.comd3899c12015-04-15 20:23:14 +0200453
Martin v. Löwise981a4e2002-11-11 13:26:51 +0000454# Some systems cannot stand _XOPEN_SOURCE being defined at all; they
455# disable features if it is defined, without any means to access these
456# features as extensions. For these systems, we skip the definition of
457# _XOPEN_SOURCE. Before adding a system to the list to gain access to
458# some feature, make sure there is no alternative way to access this
459# feature. Also, when using wildcards, make sure you have verified the
460# need for not defining _XOPEN_SOURCE on all systems matching the
461# wildcard, and that the wildcard does not include future systems
462# (which may remove their limitations).
463dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
464case $ac_sys_system/$ac_sys_release in
465 # On OpenBSD, select(2) is not available if _XOPEN_SOURCE is defined,
466 # even though select is a POSIX function. Reported by J. Ribbens.
Martin v. Löwis76bafc62003-10-03 13:47:44 +0000467 # Reconfirmed for OpenBSD 3.3 by Zachary Hamm, for 3.4 by Jason Ish.
Martin v. Löwis19ed3c82010-02-15 21:45:06 +0000468 # In addition, Stefan Krah confirms that issue #1244610 exists through
469 # OpenBSD 4.6, but is fixed in 4.7.
Victor Stinner1b80b242016-04-12 22:34:58 +0200470 OpenBSD/2.* | OpenBSD/3.* | OpenBSD/4.@<:@0123456@:>@)
Christian Heimes5b5e81c2007-12-31 16:14:33 +0000471 define_xopen_source=no
472 # OpenBSD undoes our definition of __BSD_VISIBLE if _XOPEN_SOURCE is
473 # also defined. This can be overridden by defining _BSD_SOURCE
474 # As this has a different meaning on Linux, only define it on OpenBSD
475 AC_DEFINE(_BSD_SOURCE, 1, [Define on OpenBSD to activate all library features])
476 ;;
Charles-François Natali54ef40b2011-07-22 23:52:02 +0200477 OpenBSD/*)
Martin v. Löwis7671efc2010-02-15 08:35:16 +0000478 # OpenBSD undoes our definition of __BSD_VISIBLE if _XOPEN_SOURCE is
479 # also defined. This can be overridden by defining _BSD_SOURCE
480 # As this has a different meaning on Linux, only define it on OpenBSD
481 AC_DEFINE(_BSD_SOURCE, 1, [Define on OpenBSD to activate all library features])
482 ;;
Thomas Wouters89f507f2006-12-13 04:49:30 +0000483 # Defining _XOPEN_SOURCE on NetBSD version prior to the introduction of
484 # _NETBSD_SOURCE disables certain features (eg. setgroups). Reported by
485 # Marc Recht
Benjamin Petersonf608c612008-11-16 18:33:53 +0000486 NetBSD/1.5 | NetBSD/1.5.* | NetBSD/1.6 | NetBSD/1.6.* | NetBSD/1.6@<:@A-S@:>@)
Martin v. Löwise981a4e2002-11-11 13:26:51 +0000487 define_xopen_source=no;;
Martin v. Löwis1a415762010-05-28 15:44:20 +0000488 # From the perspective of Solaris, _XOPEN_SOURCE is not so much a
489 # request to enable features supported by the standard as a request
490 # to disable features not supported by the standard. The best way
491 # for Python to use Solaris is simply to leave _XOPEN_SOURCE out
492 # entirely and define __EXTENSIONS__ instead.
493 SunOS/*)
Martin v. Löwisa9d71422003-03-28 18:43:31 +0000494 define_xopen_source=no;;
Martin v. Löwisc2409b42003-05-11 05:53:41 +0000495 # On UnixWare 7, u_long is never defined with _XOPEN_SOURCE,
496 # but used in /usr/include/netinet/tcp.h. Reported by Tim Rice.
Martin v. Löwis253d1f42004-05-07 19:14:14 +0000497 # Reconfirmed for 7.1.4 by Martin v. Loewis.
498 OpenUNIX/8.0.0| UnixWare/7.1.@<:@0-4@:>@)
Martin v. Löwisc2409b42003-05-11 05:53:41 +0000499 define_xopen_source=no;;
500 # On OpenServer 5, u_short is never defined with _XOPEN_SOURCE,
Martin v. Löwis53e73c32003-05-05 05:13:18 +0000501 # but used in struct sockaddr.sa_family. Reported by Tim Rice.
Martin v. Löwisc2409b42003-05-11 05:53:41 +0000502 SCO_SV/3.2)
Martin v. Löwis53e73c32003-05-05 05:13:18 +0000503 define_xopen_source=no;;
Victor Stinner1b80b242016-04-12 22:34:58 +0200504 # On MacOS X 10.2, a bug in ncurses.h means that it craps out if
Martin v. Löwisb37509b2008-11-04 20:45:29 +0000505 # _XOPEN_EXTENDED_SOURCE is defined. Apparently, this is fixed in 10.3, which
506 # identifies itself as Darwin/7.*
507 # On Mac OS X 10.4, defining _POSIX_C_SOURCE or _XOPEN_SOURCE
508 # disables platform specific features beyond repair.
Victor Stinner1b80b242016-04-12 22:34:58 +0200509 # On Mac OS X 10.3, defining _POSIX_C_SOURCE or _XOPEN_SOURCE
Martin v. Löwisb37509b2008-11-04 20:45:29 +0000510 # has no effect, don't bother defining them
511 Darwin/@<:@6789@:>@.*)
Anthony Baxter6169c6b2003-10-04 07:46:23 +0000512 define_xopen_source=no;;
Ronald Oussoren8ea63532020-06-25 16:55:48 +0200513 Darwin/@<:@[12]@:>@@<:@0-9@:>@.*)
Ronald Oussorenb8f11a62010-03-08 07:02:03 +0000514 define_xopen_source=no;;
Trent Mickaf16e8c2004-08-25 23:55:59 +0000515 # On AIX 4 and 5.1, mbstate_t is defined only when _XOPEN_SOURCE == 500 but
516 # used in wcsnrtombs() and mbsnrtowcs() even if _XOPEN_SOURCE is not defined
517 # or has another value. By not (re)defining it, the defaults come in place.
Martin v. Löwisc19c5a62003-11-18 20:00:44 +0000518 AIX/4)
519 define_xopen_source=no;;
Trent Mickaf16e8c2004-08-25 23:55:59 +0000520 AIX/5)
521 if test `uname -r` -eq 1; then
522 define_xopen_source=no
523 fi
524 ;;
Georg Brandlf78e02b2008-06-10 17:40:04 +0000525 # On QNX 6.3.2, defining _XOPEN_SOURCE prevents netdb.h from
526 # defining NI_NUMERICHOST.
527 QNX/6.3.2)
528 define_xopen_source=no
529 ;;
pxinwr32f5fdd2019-02-27 19:09:28 +0800530 # On VxWorks, defining _XOPEN_SOURCE causes compile failures
531 # in network headers still using system V types.
532 VxWorks/*)
533 define_xopen_source=no
534 ;;
Bob Ippolito7026a0a2005-03-28 23:23:47 +0000535
Ian Nortona9edf442020-02-14 03:09:11 +0000536 # On HP-UX, defining _XOPEN_SOURCE to 600 or greater hides
537 # chroot() and other functions
538 hp*|HP*)
539 define_xopen_source=no
540 ;;
541
Martin v. Löwise981a4e2002-11-11 13:26:51 +0000542esac
543
544if test $define_xopen_source = yes
545then
Victor Stinner14d098d2011-09-07 22:29:43 +0200546 # X/Open 7, incorporating POSIX.1-2008
547 AC_DEFINE(_XOPEN_SOURCE, 700,
Martin v. Löwis1a415762010-05-28 15:44:20 +0000548 Define to the level of X/Open that your system supports)
Martin v. Löwis678fc1e2002-11-12 06:04:39 +0000549
550 # On Tru64 Unix 4.0F, defining _XOPEN_SOURCE also requires
551 # definition of _XOPEN_SOURCE_EXTENDED and _POSIX_C_SOURCE, or else
552 # several APIs are not declared. Since this is also needed in some
553 # cases for HP-UX, we define it globally.
Martin v. Löwis1a415762010-05-28 15:44:20 +0000554 AC_DEFINE(_XOPEN_SOURCE_EXTENDED, 1,
555 Define to activate Unix95-and-earlier features)
Martin v. Löwis678fc1e2002-11-12 06:04:39 +0000556
Victor Stinnerd169fdc2011-09-08 00:56:17 +0200557 AC_DEFINE(_POSIX_C_SOURCE, 200809L, Define to activate features from IEEE Stds 1003.1-2008)
Martin v. Löwise981a4e2002-11-11 13:26:51 +0000558fi
559
Christian Heimes647cd872013-12-07 23:39:33 +0100560# On HP-UX mbstate_t requires _INCLUDE__STDC_A1_SOURCE
561case $ac_sys_system in
Christian Heimesb02bcae2013-12-08 15:21:08 +0100562 hp*|HP*)
563 define_stdc_a1=yes;;
564 *)
565 define_stdc_a1=no;;
Christian Heimes647cd872013-12-07 23:39:33 +0100566esac
567
Christian Heimesb02bcae2013-12-08 15:21:08 +0100568if test $define_stdc_a1 = yes
569then
570 AC_DEFINE(_INCLUDE__STDC_A1_SOURCE, 1, Define to include mbstate_t for mbrtowc)
571fi
572
Jack Jansen6b08a402004-06-03 12:41:45 +0000573# Record the configure-time value of MACOSX_DEPLOYMENT_TARGET,
574# it may influence the way we can build extensions, so distutils
575# needs to check it
576AC_SUBST(CONFIGURE_MACOSX_DEPLOYMENT_TARGET)
Thomas Wouters477c8d52006-05-27 19:21:47 +0000577AC_SUBST(EXPORT_MACOSX_DEPLOYMENT_TARGET)
Jack Jansen6b08a402004-06-03 12:41:45 +0000578CONFIGURE_MACOSX_DEPLOYMENT_TARGET=
Thomas Wouters477c8d52006-05-27 19:21:47 +0000579EXPORT_MACOSX_DEPLOYMENT_TARGET='#'
Jack Jansen6b08a402004-06-03 12:41:45 +0000580
Guido van Rossum627b2d71993-12-24 10:39:16 +0000581# checks for alternative programs
Skip Montanarodecc6a42003-01-01 20:07:49 +0000582
583# compiler flags are generated in two sets, BASECFLAGS and OPT. OPT is just
584# for debug/optimization stuff. BASECFLAGS is for flags that are required
585# just to get things to compile and link. Users are free to override OPT
586# when running configure or make. The build should not break if they do.
587# BASECFLAGS should generally not be messed with, however.
588
Guido van Rossum03ad99f1995-03-09 14:09:54 +0000589# If the user switches compilers, we can't believe the cache
590if test ! -z "$ac_cv_prog_CC" -a ! -z "$CC" -a "$CC" != "$ac_cv_prog_CC"
591then
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000592 AC_MSG_ERROR([cached CC is different -- throw away $cache_file
593(it is also a good idea to do 'make clean' before compiling)])
Guido van Rossum03ad99f1995-03-09 14:09:54 +0000594fi
595
Jeffrey Yasskind4fcdb12010-07-09 16:30:58 +0000596# Don't let AC_PROG_CC set the default CFLAGS. It normally sets -g -O2
597# when the compiler supports them, but we don't always want -O2, and
598# we set -g later.
599if test -z "$CFLAGS"; then
600 CFLAGS=
Marc-André Lemburgdf700f02010-04-30 17:29:56 +0000601fi
Ned Deilycbfb9a52012-06-23 16:02:19 -0700602
603if test "$ac_sys_system" = "Darwin"
604then
605 # Compiler selection on MacOSX is more complicated than
Eitan Adlerb5c246f2018-06-02 07:16:19 -0700606 # AC_PROG_CC can handle, see Mac/README for more
Ned Deilycbfb9a52012-06-23 16:02:19 -0700607 # information
608 if test -z "${CC}"
609 then
610 found_gcc=
611 found_clang=
612 as_save_IFS=$IFS; IFS=:
613 for as_dir in $PATH
614 do
615 IFS=$as_save_IFS
Ned Deily14aa00b2017-10-09 13:53:27 -0400616 if test -x "${as_dir}/gcc"; then
Ned Deilycbfb9a52012-06-23 16:02:19 -0700617 if test -z "${found_gcc}"; then
Ned Deily14aa00b2017-10-09 13:53:27 -0400618 found_gcc="${as_dir}/gcc"
Ned Deilycbfb9a52012-06-23 16:02:19 -0700619 fi
620 fi
Ned Deily14aa00b2017-10-09 13:53:27 -0400621 if test -x "${as_dir}/clang"; then
Ned Deilycbfb9a52012-06-23 16:02:19 -0700622 if test -z "${found_clang}"; then
Ned Deily14aa00b2017-10-09 13:53:27 -0400623 found_clang="${as_dir}/clang"
Ned Deilycbfb9a52012-06-23 16:02:19 -0700624 fi
625 fi
626 done
627 IFS=$as_save_IFS
628
629 if test -n "$found_gcc" -a -n "$found_clang"
630 then
631 if test -n "`"$found_gcc" --version | grep llvm-gcc`"
632 then
633 AC_MSG_NOTICE([Detected llvm-gcc, falling back to clang])
634 CC="$found_clang"
635 CXX="$found_clang++"
636 fi
637
638
639 elif test -z "$found_gcc" -a -n "$found_clang"
640 then
641 AC_MSG_NOTICE([No GCC found, use CLANG])
642 CC="$found_clang"
643 CXX="$found_clang++"
644
645 elif test -z "$found_gcc" -a -z "$found_clang"
646 then
647 found_clang=`/usr/bin/xcrun -find clang 2>/dev/null`
648 if test -n "${found_clang}"
649 then
650 AC_MSG_NOTICE([Using clang from Xcode.app])
651 CC="${found_clang}"
652 CXX="`/usr/bin/xcrun -find clang++`"
653
654 # else: use default behaviour
655 fi
656 fi
657 fi
658fi
Jeffrey Yasskind4fcdb12010-07-09 16:30:58 +0000659AC_PROG_CC
doko@ubuntu.comd3899c12015-04-15 20:23:14 +0200660AC_PROG_CPP
661AC_PROG_GREP
Łukasz Langaa785c872016-09-09 17:37:37 -0700662AC_PROG_SED
Martin v. Löwis1d5ecb72001-08-09 10:29:44 +0000663
Thomas Wouters49fd7fa2006-04-21 10:40:58 +0000664AC_SUBST(CXX)
665AC_SUBST(MAINCC)
666AC_MSG_CHECKING(for --with-cxx-main=<compiler>)
667AC_ARG_WITH(cxx_main,
Anthony Shaw2de064e2020-01-14 17:40:10 +1100668 AS_HELP_STRING([--with-cxx-main@<:@=COMPILER@:>@],
669 [compile main() and link Python executable with C++ compiler specified in COMPILER (default is $CXX)]),
Thomas Wouters49fd7fa2006-04-21 10:40:58 +0000670[
Victor Stinner1b80b242016-04-12 22:34:58 +0200671
Thomas Wouters49fd7fa2006-04-21 10:40:58 +0000672 case $withval in
673 no) with_cxx_main=no
674 MAINCC='$(CC)';;
675 yes) with_cxx_main=yes
676 MAINCC='$(CXX)';;
677 *) with_cxx_main=yes
678 MAINCC=$withval
679 if test -z "$CXX"
680 then
681 CXX=$withval
682 fi;;
683 esac], [
684 with_cxx_main=no
685 MAINCC='$(CC)'
686])
687AC_MSG_RESULT($with_cxx_main)
688
689preset_cxx="$CXX"
690if test -z "$CXX"
691then
692 case "$CC" in
doko@ubuntu.com51f65942012-06-30 14:42:46 +0200693 gcc) AC_PATH_TOOL(CXX, [g++], [g++], [notfound]) ;;
694 cc) AC_PATH_TOOL(CXX, [c++], [c++], [notfound]) ;;
695 clang|*/clang) AC_PATH_TOOL(CXX, [clang++], [clang++], [notfound]) ;;
Zachary Ware5af85642015-12-21 12:09:17 -0600696 icc|*/icc) AC_PATH_TOOL(CXX, [icpc], [icpc], [notfound]) ;;
Thomas Wouters49fd7fa2006-04-21 10:40:58 +0000697 esac
698 if test "$CXX" = "notfound"
699 then
700 CXX=""
701 fi
702fi
703if test -z "$CXX"
704then
doko@ubuntu.com51f65942012-06-30 14:42:46 +0200705 AC_CHECK_TOOLS(CXX, $CCC c++ g++ gcc CC cxx cc++ cl, notfound)
Thomas Wouters49fd7fa2006-04-21 10:40:58 +0000706 if test "$CXX" = "notfound"
707 then
708 CXX=""
709 fi
710fi
711if test "$preset_cxx" != "$CXX"
712then
Christian Heimesfe32aec2013-11-20 01:18:26 +0100713 AC_MSG_NOTICE([
Thomas Wouters49fd7fa2006-04-21 10:40:58 +0000714
715 By default, distutils will build C++ extension modules with "$CXX".
716 If this is not intended, then set CXX on the configure command line.
717 ])
718fi
719
720
doko@ubuntu.comd3899c12015-04-15 20:23:14 +0200721MULTIARCH=$($CC --print-multiarch 2>/dev/null)
722AC_SUBST(MULTIARCH)
723
724AC_MSG_CHECKING([for the platform triplet based on compiler characteristics])
725cat >> conftest.c <<EOF
doko@ubuntu.com5cc9c4f2015-04-19 14:44:05 +0200726#undef bfin
727#undef cris
728#undef fr30
doko@ubuntu.comd3899c12015-04-15 20:23:14 +0200729#undef linux
doko@ubuntu.com5cc9c4f2015-04-19 14:44:05 +0200730#undef hppa
731#undef hpux
doko@ubuntu.comd3899c12015-04-15 20:23:14 +0200732#undef i386
doko@ubuntu.com5cc9c4f2015-04-19 14:44:05 +0200733#undef mips
doko@ubuntu.com9abe0492015-04-15 23:31:02 +0200734#undef powerpc
doko@ubuntu.com5cc9c4f2015-04-19 14:44:05 +0200735#undef sparc
doko@ubuntu.comd3899c12015-04-15 20:23:14 +0200736#undef unix
doko@ubuntu.com5c38cb22016-09-01 22:05:20 +0200737#if defined(__ANDROID__)
Xavier de Gaye32cf1ac2016-12-10 17:31:28 +0100738 # Android is not a multiarch system.
doko@ubuntu.com5c38cb22016-09-01 22:05:20 +0200739#elif defined(__linux__)
doko@ubuntu.comd3899c12015-04-15 20:23:14 +0200740# if defined(__x86_64__) && defined(__LP64__)
741 x86_64-linux-gnu
742# elif defined(__x86_64__) && defined(__ILP32__)
743 x86_64-linux-gnux32
744# elif defined(__i386__)
745 i386-linux-gnu
746# elif defined(__aarch64__) && defined(__AARCH64EL__)
747# if defined(__ILP32__)
748 aarch64_ilp32-linux-gnu
749# else
750 aarch64-linux-gnu
751# endif
752# elif defined(__aarch64__) && defined(__AARCH64EB__)
753# if defined(__ILP32__)
754 aarch64_be_ilp32-linux-gnu
755# else
756 aarch64_be-linux-gnu
757# endif
758# elif defined(__alpha__)
759 alpha-linux-gnu
760# elif defined(__ARM_EABI__) && defined(__ARM_PCS_VFP)
761# if defined(__ARMEL__)
762 arm-linux-gnueabihf
763# else
764 armeb-linux-gnueabihf
765# endif
766# elif defined(__ARM_EABI__) && !defined(__ARM_PCS_VFP)
767# if defined(__ARMEL__)
768 arm-linux-gnueabi
769# else
770 armeb-linux-gnueabi
771# endif
772# elif defined(__hppa__)
773 hppa-linux-gnu
774# elif defined(__ia64__)
775 ia64-linux-gnu
776# elif defined(__m68k__) && !defined(__mcoldfire__)
777 m68k-linux-gnu
Matthias Kloseddbe9762018-04-30 19:22:16 +0200778# elif defined(__mips_hard_float) && defined(__mips_isa_rev) && (__mips_isa_rev >=6) && defined(_MIPSEL)
779# if _MIPS_SIM == _ABIO32
780 mipsisa32r6el-linux-gnu
781# elif _MIPS_SIM == _ABIN32
782 mipsisa64r6el-linux-gnuabin32
783# elif _MIPS_SIM == _ABI64
784 mipsisa64r6el-linux-gnuabi64
785# else
786# error unknown platform triplet
787# endif
788# elif defined(__mips_hard_float) && defined(__mips_isa_rev) && (__mips_isa_rev >=6)
789# if _MIPS_SIM == _ABIO32
790 mipsisa32r6-linux-gnu
791# elif _MIPS_SIM == _ABIN32
792 mipsisa64r6-linux-gnuabin32
793# elif _MIPS_SIM == _ABI64
794 mipsisa64r6-linux-gnuabi64
795# else
796# error unknown platform triplet
797# endif
doko@ubuntu.comd3899c12015-04-15 20:23:14 +0200798# elif defined(__mips_hard_float) && defined(_MIPSEL)
799# if _MIPS_SIM == _ABIO32
800 mipsel-linux-gnu
801# elif _MIPS_SIM == _ABIN32
802 mips64el-linux-gnuabin32
803# elif _MIPS_SIM == _ABI64
804 mips64el-linux-gnuabi64
805# else
806# error unknown platform triplet
807# endif
808# elif defined(__mips_hard_float)
809# if _MIPS_SIM == _ABIO32
810 mips-linux-gnu
811# elif _MIPS_SIM == _ABIN32
812 mips64-linux-gnuabin32
813# elif _MIPS_SIM == _ABI64
814 mips64-linux-gnuabi64
815# else
816# error unknown platform triplet
817# endif
818# elif defined(__or1k__)
819 or1k-linux-gnu
820# elif defined(__powerpc__) && defined(__SPE__)
821 powerpc-linux-gnuspe
822# elif defined(__powerpc64__)
823# if defined(__LITTLE_ENDIAN__)
824 powerpc64le-linux-gnu
825# else
826 powerpc64-linux-gnu
827# endif
828# elif defined(__powerpc__)
829 powerpc-linux-gnu
830# elif defined(__s390x__)
831 s390x-linux-gnu
832# elif defined(__s390__)
833 s390-linux-gnu
834# elif defined(__sh__) && defined(__LITTLE_ENDIAN__)
835 sh4-linux-gnu
836# elif defined(__sparc__) && defined(__arch64__)
837 sparc64-linux-gnu
838# elif defined(__sparc__)
839 sparc-linux-gnu
Matthias Kloseddbe9762018-04-30 19:22:16 +0200840# elif defined(__riscv)
841# if __riscv_xlen == 32
842 riscv32-linux-gnu
843# elif __riscv_xlen == 64
844 riscv64-linux-gnu
845# else
846# error unknown platform triplet
847# endif
doko@ubuntu.comd3899c12015-04-15 20:23:14 +0200848# else
849# error unknown platform triplet
850# endif
851#elif defined(__FreeBSD_kernel__)
852# if defined(__LP64__)
853 x86_64-kfreebsd-gnu
854# elif defined(__i386__)
855 i386-kfreebsd-gnu
856# else
857# error unknown platform triplet
858# endif
859#elif defined(__gnu_hurd__)
860 i386-gnu
Ned Deily3b812482015-04-15 17:11:47 -0700861#elif defined(__APPLE__)
862 darwin
pxinwr32f5fdd2019-02-27 19:09:28 +0800863#elif defined(__VXWORKS__)
864 vxworks
doko@ubuntu.comd3899c12015-04-15 20:23:14 +0200865#else
866# error unknown platform triplet
867#endif
868
869EOF
870
Xavier de Gaye3a32bdf2016-07-30 11:28:35 +0200871if $CPP $CPPFLAGS conftest.c >conftest.out 2>/dev/null; then
doko@ubuntu.comd3899c12015-04-15 20:23:14 +0200872 PLATFORM_TRIPLET=`grep -v '^#' conftest.out | grep -v '^ *$' | tr -d ' '`
873 AC_MSG_RESULT([$PLATFORM_TRIPLET])
874else
875 AC_MSG_RESULT([none])
876fi
877rm -f conftest.c conftest.out
878
879if test x$PLATFORM_TRIPLET != x && test x$MULTIARCH != x; then
880 if test x$PLATFORM_TRIPLET != x$MULTIARCH; then
881 AC_MSG_ERROR([internal configure error for the platform triplet, please file a bug report])
882 fi
doko@ubuntu.com75b1cb12016-08-29 20:03:25 +0200883elif test x$PLATFORM_TRIPLET != x && test x$MULTIARCH = x; then
884 MULTIARCH=$PLATFORM_TRIPLET
Victor Stinner1b80b242016-04-12 22:34:58 +0200885fi
doko@ubuntu.comd3899c12015-04-15 20:23:14 +0200886AC_SUBST(PLATFORM_TRIPLET)
doko@ubuntu.com55532312016-06-14 08:55:19 +0200887if test x$MULTIARCH != x; then
888 MULTIARCH_CPPFLAGS="-DMULTIARCH=\\\"$MULTIARCH\\\""
889fi
890AC_SUBST(MULTIARCH_CPPFLAGS)
doko@ubuntu.comd3899c12015-04-15 20:23:14 +0200891
Martin v. Löwis48e14d32011-05-09 07:37:45 +0200892AC_MSG_CHECKING([for -Wl,--no-as-needed])
893save_LDFLAGS="$LDFLAGS"
894LDFLAGS="$LDFLAGS -Wl,--no-as-needed"
895AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
896 [NO_AS_NEEDED="-Wl,--no-as-needed"
897 AC_MSG_RESULT([yes])],
898 [NO_AS_NEEDED=""
899 AC_MSG_RESULT([no])])
900LDFLAGS="$save_LDFLAGS"
901AC_SUBST(NO_AS_NEEDED)
902
903
Martin v. Löwis1d5ecb72001-08-09 10:29:44 +0000904# checks for UNIX variants that set C preprocessor variables
Matthias Kloseaf30c5d2010-04-25 18:43:42 +0000905AC_USE_SYSTEM_EXTENSIONS
Martin v. Löwis1d5ecb72001-08-09 10:29:44 +0000906
Xavier de Gaye95750b12016-07-09 11:05:42 +0200907AC_MSG_CHECKING([for the Android API level])
908cat >> conftest.c <<EOF
909#ifdef __ANDROID__
Xavier de Gaye2a352b62017-01-04 21:51:16 +0100910android_api = __ANDROID_API__
911arm_arch = __ARM_ARCH
Xavier de Gaye95750b12016-07-09 11:05:42 +0200912#else
913#error not Android
914#endif
915EOF
916
917if $CPP $CPPFLAGS conftest.c >conftest.out 2>/dev/null; then
Xavier de Gaye2a352b62017-01-04 21:51:16 +0100918 ANDROID_API_LEVEL=`sed -n -e '/__ANDROID_API__/d' -e 's/^android_api = //p' conftest.out`
919 _arm_arch=`sed -n -e '/__ARM_ARCH/d' -e 's/^arm_arch = //p' conftest.out`
Xavier de Gaye95750b12016-07-09 11:05:42 +0200920 AC_MSG_RESULT([$ANDROID_API_LEVEL])
xdegayec06c22e2017-11-23 11:44:38 +0100921 if test -z "$ANDROID_API_LEVEL"; then
922 echo 'Fatal: you must define __ANDROID_API__'
923 exit 1
924 fi
Xavier de Gaye95750b12016-07-09 11:05:42 +0200925 AC_DEFINE_UNQUOTED(ANDROID_API_LEVEL, $ANDROID_API_LEVEL, [The Android API level.])
Xavier de Gaye2a352b62017-01-04 21:51:16 +0100926
927 AC_MSG_CHECKING([for the Android arm ABI])
928 AC_MSG_RESULT([$_arm_arch])
929 if test "$_arm_arch" = 7; then
930 BASECFLAGS="${BASECFLAGS} -mfloat-abi=softfp -mfpu=vfpv3-d16"
931 LDFLAGS="${LDFLAGS} -march=armv7-a -Wl,--fix-cortex-a8"
932 fi
Xavier de Gaye95750b12016-07-09 11:05:42 +0200933else
934 AC_MSG_RESULT([not Android])
935fi
936rm -f conftest.c conftest.out
937
Martin v. Löwis779ffc02002-12-02 22:17:01 +0000938# Check for unsupported systems
939case $ac_sys_system/$ac_sys_release in
Guido van Rossumcd16bf62007-06-13 18:07:49 +0000940atheos*|Linux*/1*)
Martin v. Löwis779ffc02002-12-02 22:17:01 +0000941 echo This system \($ac_sys_system/$ac_sys_release\) is no longer supported.
942 echo See README for details.
943 exit 1;;
944esac
945
Neil Schemenauer55f0cf32001-01-24 17:24:33 +0000946AC_EXEEXT
Neil Schemenauer3ae1d0a2001-01-27 06:54:42 +0000947AC_MSG_CHECKING(for --with-suffix)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000948AC_ARG_WITH(suffix,
Anthony Shaw2de064e2020-01-14 17:40:10 +1100949 AS_HELP_STRING([--with-suffix=SUFFIX], [set executable suffix to SUFFIX (default is '.exe')]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000950[
Neil Schemenauer3ae1d0a2001-01-27 06:54:42 +0000951 case $withval in
952 no) EXEEXT=;;
953 yes) EXEEXT=.exe;;
954 *) EXEEXT=$withval;;
955 esac])
956AC_MSG_RESULT($EXEEXT)
Jack Jansen1999ef42001-12-06 21:47:20 +0000957
Jack Jansen9a66b6d2001-08-08 13:56:14 +0000958# Test whether we're running on a non-case-sensitive system, in which
959# case we give a warning if no ext is given
Jack Jansen1999ef42001-12-06 21:47:20 +0000960AC_SUBST(BUILDEXEEXT)
961AC_MSG_CHECKING(for case-insensitive build directory)
Jack Jansen3c2c4332002-11-06 13:33:32 +0000962if test ! -d CaseSensitiveTestDir; then
963mkdir CaseSensitiveTestDir
964fi
965
966if test -d casesensitivetestdir
Jack Jansen9a66b6d2001-08-08 13:56:14 +0000967then
Jack Jansen1999ef42001-12-06 21:47:20 +0000968 AC_MSG_RESULT(yes)
969 BUILDEXEEXT=.exe
970else
971 AC_MSG_RESULT(no)
Jack Jansendd19cf82001-12-06 22:36:17 +0000972 BUILDEXEEXT=$EXEEXT
Jack Jansen9a66b6d2001-08-08 13:56:14 +0000973fi
Jack Jansen3c2c4332002-11-06 13:33:32 +0000974rmdir CaseSensitiveTestDir
Guido van Rossumfb842551997-08-06 23:42:07 +0000975
Guido van Rossum84561611997-08-21 00:08:11 +0000976case $ac_sys_system in
977hp*|HP*)
978 case $CC in
Guido van Rossumcd5ff9f2000-09-22 16:15:54 +0000979 cc|*/cc) CC="$CC -Ae";;
Guido van Rossum84561611997-08-21 00:08:11 +0000980 esac;;
981esac
982
Neil Schemenauer61c51152001-01-26 16:18:16 +0000983AC_SUBST(LIBRARY)
984AC_MSG_CHECKING(LIBRARY)
985if test -z "$LIBRARY"
986then
Barry Warsawf040d7d2010-10-18 17:09:07 +0000987 LIBRARY='libpython$(VERSION)$(ABIFLAGS).a'
Neil Schemenauer61c51152001-01-26 16:18:16 +0000988fi
989AC_MSG_RESULT($LIBRARY)
990
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000991# LDLIBRARY is the name of the library to link against (as opposed to the
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000992# name of the library into which to insert object files). BLDLIBRARY is also
993# the library to link against, usually. On Mac OS X frameworks, BLDLIBRARY
994# is blank as the main program is not linked directly against LDLIBRARY.
995# LDLIBRARYDIR is the path to LDLIBRARY, which is made in a subdirectory. On
996# systems without shared libraries, LDLIBRARY is the same as LIBRARY
997# (defined in the Makefiles). On Cygwin LDLIBRARY is the import library,
998# DLLLIBRARY is the shared (i.e., DLL) library.
Victor Stinner1b80b242016-04-12 22:34:58 +0200999#
Martin v. Löwis1142de32002-03-29 16:28:31 +00001000# RUNSHARED is used to run shared python without installed libraries
1001#
1002# INSTSONAME is the name of the shared library that will be use to install
1003# on the system - some systems like version suffix, others don't
Barry Warsaw8cf4eae2010-10-16 01:04:07 +00001004#
1005# LDVERSION is the shared library version number, normally the Python version
1006# with the ABI build flags appended.
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001007AC_SUBST(LDLIBRARY)
Guido van Rossum27552902001-01-23 01:52:26 +00001008AC_SUBST(DLLLIBRARY)
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001009AC_SUBST(BLDLIBRARY)
Martin v. Löwisd1fc34d2010-12-30 14:55:47 +00001010AC_SUBST(PY3LIBRARY)
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001011AC_SUBST(LDLIBRARYDIR)
Martin v. Löwis1142de32002-03-29 16:28:31 +00001012AC_SUBST(INSTSONAME)
1013AC_SUBST(RUNSHARED)
Barry Warsaw8cf4eae2010-10-16 01:04:07 +00001014AC_SUBST(LDVERSION)
Neil Schemenauer61c51152001-01-26 16:18:16 +00001015LDLIBRARY="$LIBRARY"
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001016BLDLIBRARY='$(LDLIBRARY)'
Martin v. Löwis09bdf722002-05-08 08:51:29 +00001017INSTSONAME='$(LDLIBRARY)'
Guido van Rossum27552902001-01-23 01:52:26 +00001018DLLLIBRARY=''
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001019LDLIBRARYDIR=''
Martin v. Löwis1142de32002-03-29 16:28:31 +00001020RUNSHARED=''
Barry Warsaw14d98ac2010-11-24 19:43:47 +00001021LDVERSION="$VERSION"
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001022
Guido van Rossumfb842551997-08-06 23:42:07 +00001023# LINKCC is the command that links the python executable -- default is $(CC).
Martin v. Löwisb7da67a2001-10-18 15:35:38 +00001024# If CXX is set, and if it is needed to link a main function that was
1025# compiled with CXX, LINKCC is CXX instead. Always using CXX is undesirable:
1026# python might then depend on the C++ runtime
Guido van Rossumfb842551997-08-06 23:42:07 +00001027AC_SUBST(LINKCC)
1028AC_MSG_CHECKING(LINKCC)
1029if test -z "$LINKCC"
1030then
Thomas Wouters49fd7fa2006-04-21 10:40:58 +00001031 LINKCC='$(PURIFY) $(MAINCC)'
Guido van Rossumfb842551997-08-06 23:42:07 +00001032 case $ac_sys_system in
Georg Brandlf78e02b2008-06-10 17:40:04 +00001033 QNX*)
1034 # qcc must be used because the other compilers do not
1035 # support -N.
1036 LINKCC=qcc;;
Guido van Rossumfb842551997-08-06 23:42:07 +00001037 esac
1038fi
1039AC_MSG_RESULT($LINKCC)
1040
Stefan Krahe6dcd372020-08-29 17:00:08 +02001041# EXPORTSYMS holds the list of exported symbols for AIX.
1042# EXPORTSFROM holds the module name exporting symbols on AIX.
1043EXPORTSYMS=
1044EXPORTSFROM=
1045AC_SUBST(EXPORTSYMS)
1046AC_SUBST(EXPORTSFROM)
1047AC_MSG_CHECKING(EXPORTSYMS)
1048case $ac_sys_system in
1049AIX*)
1050 EXPORTSYMS="Modules/python.exp"
1051 if test $ac_sys_release -ge 5 -o \
1052 $ac_sys_release -eq 4 -a `uname -r` -ge 2 ; then
1053 EXPORTSFROM=. # the main executable
1054 fi
1055 ;;
1056esac
1057AC_MSG_RESULT($EXPORTSYMS)
1058
Tarek Ziadébe720e02009-05-09 11:55:12 +00001059# GNULD is set to "yes" if the GNU linker is used. If this goes wrong
1060# make sure we default having it set to "no": this is used by
1061# distutils.unixccompiler to know if it should add --enable-new-dtags
1062# to linker command lines, and failing to detect GNU ld simply results
1063# in the same bahaviour as before.
1064AC_SUBST(GNULD)
1065AC_MSG_CHECKING(for GNU ld)
1066ac_prog=ld
1067if test "$GCC" = yes; then
1068 ac_prog=`$CC -print-prog-name=ld`
1069fi
1070case `"$ac_prog" -V 2>&1 < /dev/null` in
1071 *GNU*)
1072 GNULD=yes;;
1073 *)
1074 GNULD=no;;
1075esac
1076AC_MSG_RESULT($GNULD)
1077
Martin v. Löwis1142de32002-03-29 16:28:31 +00001078AC_MSG_CHECKING(for --enable-shared)
1079AC_ARG_ENABLE(shared,
Anthony Shaw2de064e2020-01-14 17:40:10 +11001080 AS_HELP_STRING([--enable-shared], [enable building a shared Python library (default is no)]))
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001081
Martin v. Löwis1142de32002-03-29 16:28:31 +00001082if test -z "$enable_shared"
Victor Stinner1b80b242016-04-12 22:34:58 +02001083then
Martin v. Löwisb51033d2002-05-03 05:53:15 +00001084 case $ac_sys_system in
Antoine Pitrou6103ab12009-10-24 20:11:21 +00001085 CYGWIN*)
Martin v. Löwisb51033d2002-05-03 05:53:15 +00001086 enable_shared="yes";;
1087 *)
1088 enable_shared="no";;
1089 esac
Martin v. Löwis1142de32002-03-29 16:28:31 +00001090fi
1091AC_MSG_RESULT($enable_shared)
1092
Skip Montanaro56f6a4f2004-06-18 02:47:22 +00001093AC_MSG_CHECKING(for --enable-profiling)
1094AC_ARG_ENABLE(profiling,
Anthony Shaw2de064e2020-01-14 17:40:10 +11001095 AS_HELP_STRING([--enable-profiling], [enable C-level code profiling with gprof (default is no)]))
doko@ubuntu.comba015832012-06-30 16:52:05 +02001096if test "x$enable_profiling" = xyes; then
1097 ac_save_cc="$CC"
Benjamin Peterson615ea1a2013-03-26 08:55:37 -04001098 CC="$CC -pg"
doko@ubuntu.comba015832012-06-30 16:52:05 +02001099 AC_LINK_IFELSE([AC_LANG_SOURCE([[int main() { return 0; }]])],
1100 [],
1101 [enable_profiling=no])
1102 CC="$ac_save_cc"
1103else
1104 enable_profiling=no
1105fi
1106AC_MSG_RESULT($enable_profiling)
Skip Montanaro56f6a4f2004-06-18 02:47:22 +00001107
doko@ubuntu.comba015832012-06-30 16:52:05 +02001108if test "x$enable_profiling" = xyes; then
1109 BASECFLAGS="-pg $BASECFLAGS"
1110 LDFLAGS="-pg $LDFLAGS"
1111fi
Martin v. Löwis1142de32002-03-29 16:28:31 +00001112
1113AC_MSG_CHECKING(LDLIBRARY)
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001114
Guido van Rossumb8552162001-09-05 14:58:11 +00001115# MacOSX framework builds need more magic. LDLIBRARY is the dynamic
1116# library that we build, but we do not want to link against it (we
1117# will find it with a -framework option). For this reason there is an
1118# extra variable BLDLIBRARY against which Python and the extension
1119# modules are linked, BLDLIBRARY. This is normally the same as
1120# LDLIBRARY, but empty for MacOSX framework builds.
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001121if test "$enable_framework"
1122then
1123 LDLIBRARY='$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
doko@ubuntu.come5de66e2014-05-07 12:57:44 +02001124 RUNSHARED=DYLD_FRAMEWORK_PATH=`pwd`${DYLD_FRAMEWORK_PATH:+:${DYLD_FRAMEWORK_PATH}}
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001125 BLDLIBRARY=''
1126else
1127 BLDLIBRARY='$(LDLIBRARY)'
Victor Stinner1b80b242016-04-12 22:34:58 +02001128fi
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001129
Martin v. Löwis1142de32002-03-29 16:28:31 +00001130# Other platforms follow
1131if test $enable_shared = "yes"; then
doko@python.org87421192013-01-26 11:39:31 +01001132 PY_ENABLE_SHARED=1
Mark Hammond8235ea12002-07-19 06:55:41 +00001133 AC_DEFINE(Py_ENABLE_SHARED, 1, [Defined if Python is built as a shared library.])
Martin v. Löwis1142de32002-03-29 16:28:31 +00001134 case $ac_sys_system in
Martin v. Löwis1142de32002-03-29 16:28:31 +00001135 CYGWIN*)
Barry Warsaw8cf4eae2010-10-16 01:04:07 +00001136 LDLIBRARY='libpython$(LDVERSION).dll.a'
1137 DLLLIBRARY='libpython$(LDVERSION).dll'
Martin v. Löwis1142de32002-03-29 16:28:31 +00001138 ;;
1139 SunOS*)
Barry Warsaw8cf4eae2010-10-16 01:04:07 +00001140 LDLIBRARY='libpython$(LDVERSION).so'
1141 BLDLIBRARY='-Wl,-R,$(LIBDIR) -L. -lpython$(LDVERSION)'
doko@ubuntu.come5de66e2014-05-07 12:57:44 +02001142 RUNSHARED=LD_LIBRARY_PATH=`pwd`${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
Martin v. Löwis2389c412003-10-31 15:42:07 +00001143 INSTSONAME="$LDLIBRARY".$SOVERSION
Martin v. Löwis9b142aa2011-02-05 20:26:52 +00001144 if test "$with_pydebug" != yes
Martin v. Löwisd1fc34d2010-12-30 14:55:47 +00001145 then
1146 PY3LIBRARY=libpython3.so
1147 fi
Martin v. Löwis1142de32002-03-29 16:28:31 +00001148 ;;
Charles-François Natali749400a2011-07-24 22:41:18 +02001149 Linux*|GNU*|NetBSD*|FreeBSD*|DragonFly*|OpenBSD*)
Barry Warsaw8cf4eae2010-10-16 01:04:07 +00001150 LDLIBRARY='libpython$(LDVERSION).so'
1151 BLDLIBRARY='-L. -lpython$(LDVERSION)'
doko@ubuntu.come5de66e2014-05-07 12:57:44 +02001152 RUNSHARED=LD_LIBRARY_PATH=`pwd`${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
Martin v. Löwis1142de32002-03-29 16:28:31 +00001153 INSTSONAME="$LDLIBRARY".$SOVERSION
Martin v. Löwis9b142aa2011-02-05 20:26:52 +00001154 if test "$with_pydebug" != yes
Martin v. Löwisd1fc34d2010-12-30 14:55:47 +00001155 then
1156 PY3LIBRARY=libpython3.so
1157 fi
Martin v. Löwis1142de32002-03-29 16:28:31 +00001158 ;;
1159 hp*|HP*)
Thomas Wouters477c8d52006-05-27 19:21:47 +00001160 case `uname -m` in
1161 ia64)
Barry Warsaw8cf4eae2010-10-16 01:04:07 +00001162 LDLIBRARY='libpython$(LDVERSION).so'
Thomas Wouters477c8d52006-05-27 19:21:47 +00001163 ;;
1164 *)
Barry Warsaw8cf4eae2010-10-16 01:04:07 +00001165 LDLIBRARY='libpython$(LDVERSION).sl'
Thomas Wouters477c8d52006-05-27 19:21:47 +00001166 ;;
1167 esac
Barry Warsaw8cf4eae2010-10-16 01:04:07 +00001168 BLDLIBRARY='-Wl,+b,$(LIBDIR) -L. -lpython$(LDVERSION)'
doko@ubuntu.come5de66e2014-05-07 12:57:44 +02001169 RUNSHARED=SHLIB_PATH=`pwd`${SHLIB_PATH:+:${SHLIB_PATH}}
Martin v. Löwis1142de32002-03-29 16:28:31 +00001170 ;;
Georg Brandlb1441c72009-01-03 22:33:39 +00001171 Darwin*)
Barry Warsaw8cf4eae2010-10-16 01:04:07 +00001172 LDLIBRARY='libpython$(LDVERSION).dylib'
1173 BLDLIBRARY='-L. -lpython$(LDVERSION)'
doko@ubuntu.come5de66e2014-05-07 12:57:44 +02001174 RUNSHARED=DYLD_LIBRARY_PATH=`pwd`${DYLD_LIBRARY_PATH:+:${DYLD_LIBRARY_PATH}}
Georg Brandlb1441c72009-01-03 22:33:39 +00001175 ;;
Antoine Pitrou8e6b4072010-09-10 19:44:44 +00001176 AIX*)
Barry Warsaw8cf4eae2010-10-16 01:04:07 +00001177 LDLIBRARY='libpython$(LDVERSION).so'
doko@ubuntu.come5de66e2014-05-07 12:57:44 +02001178 RUNSHARED=LIBPATH=`pwd`${LIBPATH:+:${LIBPATH}}
Antoine Pitrou8e6b4072010-09-10 19:44:44 +00001179 ;;
Georg Brandlb1441c72009-01-03 22:33:39 +00001180
Martin v. Löwis1142de32002-03-29 16:28:31 +00001181 esac
Jason Tishler30765592003-09-04 11:04:06 +00001182else # shared is disabled
doko@python.org87421192013-01-26 11:39:31 +01001183 PY_ENABLE_SHARED=0
Jason Tishler30765592003-09-04 11:04:06 +00001184 case $ac_sys_system in
1185 CYGWIN*)
1186 BLDLIBRARY='$(LIBRARY)'
Barry Warsaw8cf4eae2010-10-16 01:04:07 +00001187 LDLIBRARY='libpython$(LDVERSION).dll.a'
Jason Tishler30765592003-09-04 11:04:06 +00001188 ;;
1189 esac
Martin v. Löwis1142de32002-03-29 16:28:31 +00001190fi
1191
doko@ubuntu.com1abe1c52012-06-30 20:42:45 +02001192if test "$cross_compiling" = yes; then
1193 RUNSHARED=
1194fi
1195
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001196AC_MSG_RESULT($LDLIBRARY)
1197
Guido van Rossum433c8ad1994-08-01 12:07:07 +00001198AC_SUBST(AR)
doko@ubuntu.com51f65942012-06-30 14:42:46 +02001199AC_CHECK_TOOLS(AR, ar aal, ar)
Neil Schemenauera42c8272001-03-31 00:01:55 +00001200
Tarek Ziadé5662d3e2009-05-07 21:24:43 +00001201# tweak ARFLAGS only if the user didn't set it on the command line
1202AC_SUBST(ARFLAGS)
1203if test -z "$ARFLAGS"
1204then
Benjamin Petersond15108a2017-09-29 08:42:41 -07001205 ARFLAGS="rcs"
Tarek Ziadé5662d3e2009-05-07 21:24:43 +00001206fi
1207
doko@ubuntu.com58844492012-06-30 18:25:32 +02001208AC_CHECK_TOOLS([READELF], [readelf], [:])
1209if test "$cross_compiling" = yes; then
1210 case "$READELF" in
1211 readelf|:)
1212 AC_MSG_ERROR([readelf for the host is required for cross builds])
1213 ;;
1214 esac
1215fi
1216AC_SUBST(READELF)
1217
Ralf Schmitt023f3a72011-05-31 17:10:03 -05001218
Neil Schemenauera42c8272001-03-31 00:01:55 +00001219case $MACHDEP in
Benjamin Peterson288d1da2017-09-28 22:44:27 -07001220hp*|HP*)
1221 # install -d does not work on HP-UX
Neil Schemenauera42c8272001-03-31 00:01:55 +00001222 if test -z "$INSTALL"
1223 then
1224 INSTALL="${srcdir}/install-sh -c"
1225 fi
1226esac
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00001227AC_PROG_INSTALL
Matthias Klose93a0ef12012-03-15 18:08:34 +01001228AC_PROG_MKDIR_P
Guido van Rossumb418f891996-07-30 18:06:02 +00001229
Guido van Rossumec95c7b1998-08-04 17:59:56 +00001230# Not every filesystem supports hard links
1231AC_SUBST(LN)
1232if test -z "$LN" ; then
1233 case $ac_sys_system in
Guido van Rossumaef734b2001-01-10 21:09:12 +00001234 CYGWIN*) LN="ln -s";;
Guido van Rossumec95c7b1998-08-04 17:59:56 +00001235 *) LN=ln;;
1236 esac
1237fi
1238
Barry Warsaw35f3a2c2010-09-03 18:30:30 +00001239# For calculating the .so ABI tag.
Barry Warsaw8cf4eae2010-10-16 01:04:07 +00001240AC_SUBST(ABIFLAGS)
1241ABIFLAGS=""
Barry Warsaw35f3a2c2010-09-03 18:30:30 +00001242
Fred Drake9f715822001-07-11 06:27:00 +00001243# Check for --with-pydebug
1244AC_MSG_CHECKING(for --with-pydebug)
Victor Stinner1b80b242016-04-12 22:34:58 +02001245AC_ARG_WITH(pydebug,
Anthony Shaw2de064e2020-01-14 17:40:10 +11001246 AS_HELP_STRING([--with-pydebug], [build with Py_DEBUG defined (default is no)]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00001247[
Fred Drake9f715822001-07-11 06:27:00 +00001248if test "$withval" != no
Victor Stinner1b80b242016-04-12 22:34:58 +02001249then
1250 AC_DEFINE(Py_DEBUG, 1,
1251 [Define if you want to build an interpreter with many run-time checks.])
1252 AC_MSG_RESULT(yes);
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001253 Py_DEBUG='true'
Barry Warsaw8cf4eae2010-10-16 01:04:07 +00001254 ABIFLAGS="${ABIFLAGS}d"
Fred Drake9f715822001-07-11 06:27:00 +00001255else AC_MSG_RESULT(no); Py_DEBUG='false'
1256fi],
1257[AC_MSG_RESULT(no)])
1258
Victor Stinnerf4e47032019-04-25 00:56:28 +02001259# Check for --with-trace-refs
1260# --with-trace-refs
1261AC_MSG_CHECKING(for --with-trace-refs)
1262AC_ARG_WITH(trace-refs,
Anthony Shaw2de064e2020-01-14 17:40:10 +11001263 AS_HELP_STRING(
1264 [--with-trace-refs],
1265 [enable tracing references for debugging purpose (default is no)]),,
Victor Stinnerf4e47032019-04-25 00:56:28 +02001266 with_trace_refs=no)
1267AC_MSG_RESULT($with_trace_refs)
1268
1269if test "$with_trace_refs" = "yes"
1270then
1271 AC_DEFINE(Py_TRACE_REFS, 1, [Define if you want to enable tracing references for debugging purpose])
1272fi
1273
1274# Check for --with-assertions.
1275# This allows enabling assertions without Py_DEBUG.
T. Woutersddbfa2c2017-05-23 01:30:49 +02001276assertions='false'
1277AC_MSG_CHECKING(for --with-assertions)
1278AC_ARG_WITH(assertions,
Anthony Shaw2de064e2020-01-14 17:40:10 +11001279 AS_HELP_STRING([--with-assertions],[build with C assertions enabled (default is no)]),
T. Woutersddbfa2c2017-05-23 01:30:49 +02001280[
1281if test "$withval" != no
1282then
1283 assertions='true'
1284fi],
1285[])
1286if test "$assertions" = 'true'; then
1287 AC_MSG_RESULT(yes)
1288elif test "$Py_DEBUG" = 'true'; then
1289 assertions='true'
1290 AC_MSG_RESULT(implied by --with-pydebug)
1291else
1292 AC_MSG_RESULT(no)
1293fi
1294
Brett Cannon63d98bc2016-09-06 17:12:40 -07001295# Enable optimization flags
1296AC_SUBST(DEF_MAKE_ALL_RULE)
1297AC_SUBST(DEF_MAKE_RULE)
1298Py_OPT='false'
Gregory P. Smith ext:(%20%5BGoogle%20Inc.%5D)1016b2f2016-11-20 21:07:42 +00001299AC_MSG_CHECKING(for --enable-optimizations)
Anthony Shaw2de064e2020-01-14 17:40:10 +11001300AC_ARG_ENABLE(optimizations, AS_HELP_STRING(
1301 [--enable-optimizations],
1302 [enable expensive, stable optimizations (PGO, etc.) (default is no)]),
Brett Cannon63d98bc2016-09-06 17:12:40 -07001303[
Alex Wang8cea5922017-03-28 08:50:51 -04001304if test "$enableval" != no
Brett Cannon63d98bc2016-09-06 17:12:40 -07001305then
1306 Py_OPT='true'
1307 AC_MSG_RESULT(yes);
1308else
1309 Py_OPT='false'
1310 AC_MSG_RESULT(no);
1311fi],
1312[AC_MSG_RESULT(no)])
1313if test "$Py_OPT" = 'true' ; then
Gregory P. Smith ext:(%20%5BGoogle%20Inc.%5D)14c7f712016-09-08 22:38:46 +00001314 # Intentionally not forcing Py_LTO='true' here. Too many toolchains do not
1315 # compile working code using it and both test_distutils and test_gdb are
Brett Cannon1d8f7552016-11-03 16:20:00 -07001316 # broken when you do manage to get a toolchain that works with it. People
Gregory P. Smith ext:(%20%5BGoogle%20Inc.%5D)14c7f712016-09-08 22:38:46 +00001317 # who want LTO need to use --with-lto themselves.
Brett Cannon63d98bc2016-09-06 17:12:40 -07001318 DEF_MAKE_ALL_RULE="profile-opt"
Gregory P. Smith799520c2016-09-07 16:10:00 -07001319 REQUIRE_PGO="yes"
Brett Cannon63d98bc2016-09-06 17:12:40 -07001320 DEF_MAKE_RULE="build_all"
Pablo Galindob451b0e2020-10-21 22:46:52 +01001321 case $CC in
1322 *gcc*)
Petr Viktorinc6d7e822020-10-22 18:11:53 +02001323 AX_CHECK_COMPILE_FLAG([-fno-semantic-interposition],[
Pablo Galindob451b0e2020-10-21 22:46:52 +01001324 CFLAGS_NODIST="$CFLAGS_NODIST -fno-semantic-interposition"
1325 LDFLAGS_NODIST="$LDFLAGS_NODIST -fno-semantic-interposition"
Petr Viktorinc6d7e822020-10-22 18:11:53 +02001326 ])
Pablo Galindob451b0e2020-10-21 22:46:52 +01001327 ;;
1328 esac
1329
1330
Brett Cannon63d98bc2016-09-06 17:12:40 -07001331else
1332 DEF_MAKE_ALL_RULE="build_all"
Gregory P. Smith799520c2016-09-07 16:10:00 -07001333 REQUIRE_PGO="no"
Brett Cannon63d98bc2016-09-06 17:12:40 -07001334 DEF_MAKE_RULE="all"
1335fi
1336
Neil Schemenauer4e16a4a2019-07-22 12:54:25 -07001337AC_ARG_VAR(PROFILE_TASK, Python args for PGO generation task)
1338AC_MSG_CHECKING(PROFILE_TASK)
1339if test -z "$PROFILE_TASK"
1340then
1341 PROFILE_TASK='-m test --pgo'
1342fi
1343AC_MSG_RESULT($PROFILE_TASK)
1344
serge-sans-paille5ad36f92018-10-25 01:54:22 +02001345# Make llvm-relatec checks work on systems where llvm tools are not installed with their
1346# normal names in the default $PATH (ie: Ubuntu). They exist under the
1347# non-suffixed name in their versioned llvm directory.
1348
1349llvm_bin_dir=''
1350llvm_path="${PATH}"
1351if test "${CC}" = "clang"
1352then
1353 clang_bin=`which clang`
1354 # Some systems install clang elsewhere as a symlink to the real path
1355 # which is where the related llvm tools are located.
1356 if test -L "${clang_bin}"
1357 then
1358 clang_dir=`dirname "${clang_bin}"`
1359 clang_bin=`readlink "${clang_bin}"`
1360 llvm_bin_dir="${clang_dir}/"`dirname "${clang_bin}"`
1361 llvm_path="${llvm_path}${PATH_SEPARATOR}${llvm_bin_dir}"
1362 fi
1363fi
1364
Gregory P. Smithd82da9f2016-04-15 16:57:04 -07001365# Enable LTO flags
Gregory P. Smithd82da9f2016-04-15 16:57:04 -07001366AC_MSG_CHECKING(for --with-lto)
Anthony Shaw2de064e2020-01-14 17:40:10 +11001367AC_ARG_WITH(lto, AS_HELP_STRING([--with-lto], [enable Link-Time-Optimization in any build (default is no)]),
Gregory P. Smithd82da9f2016-04-15 16:57:04 -07001368[
1369if test "$withval" != no
1370then
1371 Py_LTO='true'
1372 AC_MSG_RESULT(yes);
1373else
1374 Py_LTO='false'
1375 AC_MSG_RESULT(no);
1376fi],
1377[AC_MSG_RESULT(no)])
1378if test "$Py_LTO" = 'true' ; then
1379 case $CC in
1380 *clang*)
serge-sans-paille5ad36f92018-10-25 01:54:22 +02001381 AC_SUBST(LLVM_AR)
Doyle Rowland0519d492019-09-13 09:38:07 -04001382 AC_PATH_TOOL(LLVM_AR, llvm-ar, '', ${llvm_path})
serge-sans-paille5ad36f92018-10-25 01:54:22 +02001383 AC_SUBST(LLVM_AR_FOUND)
1384 if test -n "${LLVM_AR}" -a -x "${LLVM_AR}"
1385 then
1386 LLVM_AR_FOUND="found"
1387 else
1388 LLVM_AR_FOUND="not-found"
1389 fi
1390 if test "$ac_sys_system" = "Darwin" -a "${LLVM_AR_FOUND}" = "not-found"
1391 then
1392 found_llvm_ar=`/usr/bin/xcrun -find llvm-ar 2>/dev/null`
1393 if test -n "${found_llvm_ar}"
1394 then
1395 LLVM_AR='/usr/bin/xcrun llvm-ar'
1396 LLVM_AR_FOUND=found
1397 AC_MSG_NOTICE([llvm-ar found via xcrun: ${LLVM_AR}])
1398 fi
1399 fi
1400 if test $LLVM_AR_FOUND = not-found
1401 then
1402 LLVM_PROFR_ERR=yes
1403 AC_MSG_ERROR([llvm-ar is required for a --with-lto build with clang but could not be found.])
1404 else
1405 LLVM_AR_ERR=no
1406 fi
1407 AR="${LLVM_AR}"
Ned Deily8482ce42016-09-06 15:09:20 -07001408 case $ac_sys_system in
1409 Darwin*)
1410 # Any changes made here should be reflected in the GCC+Darwin case below
1411 LTOFLAGS="-flto -Wl,-export_dynamic"
1412 ;;
1413 *)
1414 LTOFLAGS="-flto"
1415 ;;
1416 esac
Gregory P. Smithd82da9f2016-04-15 16:57:04 -07001417 ;;
1418 *gcc*)
1419 case $ac_sys_system in
1420 Darwin*)
Ned Deily8482ce42016-09-06 15:09:20 -07001421 LTOFLAGS="-flto -Wl,-export_dynamic"
Gregory P. Smithd82da9f2016-04-15 16:57:04 -07001422 ;;
1423 *)
1424 LTOFLAGS="-flto -fuse-linker-plugin -ffat-lto-objects -flto-partition=none"
1425 ;;
1426 esac
1427 ;;
1428 esac
Victor Stinner06fe77a2018-06-19 18:24:58 +02001429
1430 if test "$ac_cv_prog_cc_g" = "yes"
1431 then
1432 # bpo-30345: Add -g to LDFLAGS when compiling with LTO
1433 # to get debug symbols.
1434 LTOFLAGS="$LTOFLAGS -g"
1435 fi
1436
stratakisf92c7aa2018-12-04 15:54:01 +01001437 CFLAGS_NODIST="$CFLAGS_NODIST $LTOFLAGS"
stratakiscf10a752018-12-19 18:19:01 +01001438 LDFLAGS_NODIST="$LDFLAGS_NODIST $LTOFLAGS"
Gregory P. Smithd82da9f2016-04-15 16:57:04 -07001439fi
1440
Brett Cannon7188a3e2015-09-18 15:13:44 -07001441# Enable PGO flags.
1442AC_SUBST(PGO_PROF_GEN_FLAG)
1443AC_SUBST(PGO_PROF_USE_FLAG)
1444AC_SUBST(LLVM_PROF_MERGER)
1445AC_SUBST(LLVM_PROF_FILE)
1446AC_SUBST(LLVM_PROF_ERR)
Gregory P. Smith799520c2016-09-07 16:10:00 -07001447AC_SUBST(LLVM_PROFDATA)
Doyle Rowland0519d492019-09-13 09:38:07 -04001448AC_PATH_TOOL(LLVM_PROFDATA, llvm-profdata, '', ${llvm_path})
Brett Cannon7188a3e2015-09-18 15:13:44 -07001449AC_SUBST(LLVM_PROF_FOUND)
Gregory P. Smith799520c2016-09-07 16:10:00 -07001450if test -n "${LLVM_PROFDATA}" -a -x "${LLVM_PROFDATA}"
1451then
1452 LLVM_PROF_FOUND="found"
1453else
1454 LLVM_PROF_FOUND="not-found"
1455fi
1456if test "$ac_sys_system" = "Darwin" -a "${LLVM_PROF_FOUND}" = "not-found"
1457then
1458 found_llvm_profdata=`/usr/bin/xcrun -find llvm-profdata 2>/dev/null`
1459 if test -n "${found_llvm_profdata}"
1460 then
1461 # llvm-profdata isn't directly in $PATH in some cases.
1462 # https://apple.stackexchange.com/questions/197053/
1463 LLVM_PROFDATA='/usr/bin/xcrun llvm-profdata'
1464 LLVM_PROF_FOUND=found
1465 AC_MSG_NOTICE([llvm-profdata found via xcrun: ${LLVM_PROFDATA}])
1466 fi
1467fi
Brett Cannon7188a3e2015-09-18 15:13:44 -07001468LLVM_PROF_ERR=no
1469case $CC in
1470 *clang*)
1471 # Any changes made here should be reflected in the GCC+Darwin case below
1472 PGO_PROF_GEN_FLAG="-fprofile-instr-generate"
1473 PGO_PROF_USE_FLAG="-fprofile-instr-use=code.profclangd"
Gregory P. Smith799520c2016-09-07 16:10:00 -07001474 LLVM_PROF_MERGER="${LLVM_PROFDATA} merge -output=code.profclangd *.profclangr"
Brett Cannon7188a3e2015-09-18 15:13:44 -07001475 LLVM_PROF_FILE="LLVM_PROFILE_FILE=\"code-%p.profclangr\""
1476 if test $LLVM_PROF_FOUND = not-found
1477 then
1478 LLVM_PROF_ERR=yes
Gregory P. Smith799520c2016-09-07 16:10:00 -07001479 if test "${REQUIRE_PGO}" = "yes"
1480 then
Gregory P. Smith ext:(%20%5BGoogle%20Inc.%5D)1016b2f2016-11-20 21:07:42 +00001481 AC_MSG_ERROR([llvm-profdata is required for a --enable-optimizations build but could not be found.])
Gregory P. Smith799520c2016-09-07 16:10:00 -07001482 fi
Brett Cannon7188a3e2015-09-18 15:13:44 -07001483 fi
1484 ;;
1485 *gcc*)
1486 case $ac_sys_system in
1487 Darwin*)
1488 PGO_PROF_GEN_FLAG="-fprofile-instr-generate"
1489 PGO_PROF_USE_FLAG="-fprofile-instr-use=code.profclangd"
Gregory P. Smith799520c2016-09-07 16:10:00 -07001490 LLVM_PROF_MERGER="${LLVM_PROFDATA} merge -output=code.profclangd *.profclangr"
Brett Cannon7188a3e2015-09-18 15:13:44 -07001491 LLVM_PROF_FILE="LLVM_PROFILE_FILE=\"code-%p.profclangr\""
Gregory P. Smith799520c2016-09-07 16:10:00 -07001492 if test "${LLVM_PROF_FOUND}" = "not-found"
Brett Cannon7188a3e2015-09-18 15:13:44 -07001493 then
1494 LLVM_PROF_ERR=yes
Gregory P. Smith799520c2016-09-07 16:10:00 -07001495 if test "${REQUIRE_PGO}" = "yes"
1496 then
Gregory P. Smith ext:(%20%5BGoogle%20Inc.%5D)1016b2f2016-11-20 21:07:42 +00001497 AC_MSG_ERROR([llvm-profdata is required for a --enable-optimizations build but could not be found.])
Gregory P. Smith799520c2016-09-07 16:10:00 -07001498 fi
Brett Cannon7188a3e2015-09-18 15:13:44 -07001499 fi
1500 ;;
1501 *)
1502 PGO_PROF_GEN_FLAG="-fprofile-generate"
1503 PGO_PROF_USE_FLAG="-fprofile-use -fprofile-correction"
1504 LLVM_PROF_MERGER="true"
1505 LLVM_PROF_FILE=""
1506 ;;
1507 esac
1508 ;;
Zachary Ware5af85642015-12-21 12:09:17 -06001509 *icc*)
1510 PGO_PROF_GEN_FLAG="-prof-gen"
1511 PGO_PROF_USE_FLAG="-prof-use"
1512 LLVM_PROF_MERGER="true"
1513 LLVM_PROF_FILE=""
1514 ;;
Brett Cannon7188a3e2015-09-18 15:13:44 -07001515esac
1516
Skip Montanarodecc6a42003-01-01 20:07:49 +00001517# XXX Shouldn't the code above that fiddles with BASECFLAGS and OPT be
1518# merged with this chunk of code?
1519
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00001520# Optimizer/debugger flags
Skip Montanarodecc6a42003-01-01 20:07:49 +00001521# ------------------------
1522# (The following bit of code is complicated enough - please keep things
1523# indented properly. Just pretend you're editing Python code. ;-)
1524
1525# There are two parallel sets of case statements below, one that checks to
1526# see if OPT was set and one that does BASECFLAGS setting based upon
1527# compiler and platform. BASECFLAGS tweaks need to be made even if the
1528# user set OPT.
1529
Victor Stinner23a683a2019-04-12 21:27:37 +02001530case $CC in
1531 *clang*)
1532 cc_is_clang=1
1533 ;;
1534 *)
1535 if $CC --version 2>&1 | grep -q clang
1536 then
1537 cc_is_clang=1
1538 else
1539 cc_is_clang=
1540 fi
1541esac
1542
Skip Montanarodecc6a42003-01-01 20:07:49 +00001543# tweak OPT based on compiler and platform, only if the user didn't set
1544# it on the command line
Guido van Rossumb418f891996-07-30 18:06:02 +00001545AC_SUBST(OPT)
Victor Stinner826f83f2017-04-28 15:07:10 +02001546AC_SUBST(CFLAGS_ALIASING)
Benjamin Peterson65b4ec52010-03-23 21:02:34 +00001547if test "${OPT-unset}" = "unset"
Guido van Rossumb418f891996-07-30 18:06:02 +00001548then
Skip Montanarodecc6a42003-01-01 20:07:49 +00001549 case $GCC in
1550 yes)
Christian Heimes38053212007-12-14 01:24:44 +00001551 # For gcc 4.x we need to use -fwrapv so lets check if its supported
1552 if "$CC" -v --help 2>/dev/null |grep -- -fwrapv > /dev/null; then
1553 WRAP="-fwrapv"
1554 fi
Stefan Krah962055d2011-09-14 15:14:08 +02001555
Victor Stinner35f3d242017-04-21 12:35:24 +02001556 if test -n "${cc_is_clang}"
1557 then
1558 # Clang also needs -fwrapv
1559 WRAP="-fwrapv"
Victor Stinner826f83f2017-04-28 15:07:10 +02001560 # bpo-30104: disable strict aliasing to compile correctly dtoa.c,
1561 # see Makefile.pre.in for more information
1562 CFLAGS_ALIASING="-fno-strict-aliasing"
Victor Stinner35f3d242017-04-21 12:35:24 +02001563 fi
1564
Skip Montanarodecc6a42003-01-01 20:07:49 +00001565 case $ac_cv_prog_cc_g in
Guido van Rossum2242f2f2001-04-11 20:58:20 +00001566 yes)
Fred Drake9f715822001-07-11 06:27:00 +00001567 if test "$Py_DEBUG" = 'true' ; then
1568 # Optimization messes up debuggers, so turn it off for
1569 # debug builds.
Antoine Pitrou3d6c7842015-02-11 19:39:16 +01001570 if "$CC" -v --help 2>/dev/null |grep -- -Og > /dev/null; then
Victor Stinner28205b22017-04-21 11:24:34 +02001571 OPT="-g -Og -Wall"
Antoine Pitrou3d6c7842015-02-11 19:39:16 +01001572 else
Victor Stinner28205b22017-04-21 11:24:34 +02001573 OPT="-g -O0 -Wall"
Antoine Pitrou3d6c7842015-02-11 19:39:16 +01001574 fi
Fred Drake9f715822001-07-11 06:27:00 +00001575 else
Victor Stinner28205b22017-04-21 11:24:34 +02001576 OPT="-g $WRAP -O3 -Wall"
Skip Montanarodecc6a42003-01-01 20:07:49 +00001577 fi
1578 ;;
Guido van Rossum2242f2f2001-04-11 20:58:20 +00001579 *)
Victor Stinner28205b22017-04-21 11:24:34 +02001580 OPT="-O3 -Wall"
Skip Montanarodecc6a42003-01-01 20:07:49 +00001581 ;;
Fred Drake9f715822001-07-11 06:27:00 +00001582 esac
Victor Stinner28205b22017-04-21 11:24:34 +02001583
Martin v. Löwis21ee4092002-09-30 16:19:48 +00001584 case $ac_sys_system in
Skip Montanarodecc6a42003-01-01 20:07:49 +00001585 SCO_SV*) OPT="$OPT -m486 -DSCO5"
1586 ;;
1587 esac
Fred Drake9f715822001-07-11 06:27:00 +00001588 ;;
Skip Montanarodecc6a42003-01-01 20:07:49 +00001589
Guido van Rossum2242f2f2001-04-11 20:58:20 +00001590 *)
Skip Montanarodecc6a42003-01-01 20:07:49 +00001591 OPT="-O"
1592 ;;
Guido van Rossum2242f2f2001-04-11 20:58:20 +00001593 esac
Guido van Rossum4e8af441994-08-19 15:33:54 +00001594fi
Guido van Rossum627b2d71993-12-24 10:39:16 +00001595
Skip Montanarodecc6a42003-01-01 20:07:49 +00001596AC_SUBST(BASECFLAGS)
Benjamin Petersonacb8c522014-08-09 20:01:49 -07001597AC_SUBST(CFLAGS_NODIST)
stratakiscf10a752018-12-19 18:19:01 +01001598AC_SUBST(LDFLAGS_NODIST)
Georg Brandlfcaf9102008-07-16 02:17:56 +00001599
Ronald Oussoren41761932020-11-08 10:05:27 +01001600# The -arch flags for universal builds on macOS
Georg Brandlfcaf9102008-07-16 02:17:56 +00001601UNIVERSAL_ARCH_FLAGS=
1602AC_SUBST(UNIVERSAL_ARCH_FLAGS)
1603
Skip Montanarodecc6a42003-01-01 20:07:49 +00001604# tweak BASECFLAGS based on compiler and platform
1605case $GCC in
1606yes)
Benjamin Peterson050af5d2016-09-10 17:53:13 -07001607 CFLAGS_NODIST="$CFLAGS_NODIST -std=c99"
Benjamin Petersond1702562016-09-07 12:00:06 -07001608
Serhiy Storchakaea80ffb2016-09-11 21:56:32 +03001609 AC_MSG_CHECKING(for -Wextra)
1610 ac_save_cc="$CC"
1611 CC="$CC -Wextra -Werror"
1612 AC_CACHE_VAL(ac_cv_extra_warnings,
1613 AC_COMPILE_IFELSE(
1614 [
1615 AC_LANG_PROGRAM([[]], [[]])
1616 ],[
1617 ac_cv_extra_warnings=yes
1618 ],[
1619 ac_cv_extra_warnings=no
1620 ]))
1621 CC="$ac_save_cc"
1622 AC_MSG_RESULT($ac_cv_extra_warnings)
1623
1624 if test $ac_cv_extra_warnings = yes
1625 then
1626 CFLAGS_NODIST="$CFLAGS_NODIST -Wextra"
1627 fi
1628
Benjamin Petersone6c9d242010-03-30 17:34:47 +00001629 # Python doesn't violate C99 aliasing rules, but older versions of
1630 # GCC produce warnings for legal Python code. Enable
1631 # -fno-strict-aliasing on versions of GCC that support but produce
1632 # warnings. See Issue3326
1633 AC_MSG_CHECKING(whether $CC accepts and needs -fno-strict-aliasing)
Martin v. Löwis70fedcd2003-07-07 21:26:19 +00001634 ac_save_cc="$CC"
1635 CC="$CC -fno-strict-aliasing"
Benjamin Petersone6c9d242010-03-30 17:34:47 +00001636 save_CFLAGS="$CFLAGS"
1637 AC_CACHE_VAL(ac_cv_no_strict_aliasing,
Matthias Kloseb159a552010-04-25 21:00:44 +00001638 AC_COMPILE_IFELSE(
1639 [
Mark Dickinson8c2b6f12010-05-11 09:23:07 +00001640 AC_LANG_PROGRAM([[]], [[]])
Matthias Kloseb159a552010-04-25 21:00:44 +00001641 ],[
1642 CC="$ac_save_cc -fstrict-aliasing"
1643 CFLAGS="$CFLAGS -Werror -Wstrict-aliasing"
1644 AC_COMPILE_IFELSE(
1645 [
Mark Dickinson8c2b6f12010-05-11 09:23:07 +00001646 AC_LANG_PROGRAM([[void f(int **x) {}]],
1647 [[double *x; f((int **) &x);]])
Matthias Kloseb159a552010-04-25 21:00:44 +00001648 ],[
1649 ac_cv_no_strict_aliasing=no
1650 ],[
1651 ac_cv_no_strict_aliasing=yes
1652 ])
1653 ],[
1654 ac_cv_no_strict_aliasing=no
1655 ]))
Benjamin Petersone6c9d242010-03-30 17:34:47 +00001656 CFLAGS="$save_CFLAGS"
Martin v. Löwis70fedcd2003-07-07 21:26:19 +00001657 CC="$ac_save_cc"
Benjamin Petersone6c9d242010-03-30 17:34:47 +00001658 AC_MSG_RESULT($ac_cv_no_strict_aliasing)
1659 if test $ac_cv_no_strict_aliasing = yes
Martin v. Löwis70fedcd2003-07-07 21:26:19 +00001660 then
1661 BASECFLAGS="$BASECFLAGS -fno-strict-aliasing"
1662 fi
Mark Dickinsonb0e2b4c2008-04-26 20:48:56 +00001663
Zachary Ware5af85642015-12-21 12:09:17 -06001664 # ICC doesn't recognize the option, but only emits a warning
1665 ## XXX does it emit an unused result warning and can it be disabled?
1666 case "$CC" in
1667 *icc*)
1668 ac_cv_disable_unused_result_warning=no
1669 ;;
1670 *)
Benjamin Peterson7ddbf102011-09-23 13:23:22 -04001671 AC_MSG_CHECKING(if we can turn off $CC unused result warning)
1672 ac_save_cc="$CC"
1673 CC="$CC -Wunused-result -Werror"
1674 save_CFLAGS="$CFLAGS"
1675 AC_CACHE_VAL(ac_cv_disable_unused_result_warning,
1676 AC_COMPILE_IFELSE(
1677 [
1678 AC_LANG_PROGRAM([[]], [[]])
1679 ],[
1680 ac_cv_disable_unused_result_warning=yes
1681 ],[
1682 ac_cv_disable_unused_result_warning=no
1683 ]))
1684 CFLAGS="$save_CFLAGS"
1685 CC="$ac_save_cc"
1686 AC_MSG_RESULT($ac_cv_disable_unused_result_warning)
Zachary Ware5af85642015-12-21 12:09:17 -06001687 ;;
1688 esac
Benjamin Peterson7ddbf102011-09-23 13:23:22 -04001689
1690 if test $ac_cv_disable_unused_result_warning = yes
1691 then
1692 BASECFLAGS="$BASECFLAGS -Wno-unused-result"
Serhiy Storchakaea80ffb2016-09-11 21:56:32 +03001693 CFLAGS_NODIST="$CFLAGS_NODIST -Wno-unused-result"
1694 fi
1695
1696 AC_MSG_CHECKING(if we can turn off $CC unused parameter warning)
1697 ac_save_cc="$CC"
1698 CC="$CC -Wunused-parameter -Werror"
1699 AC_CACHE_VAL(ac_cv_disable_unused_parameter_warning,
1700 AC_COMPILE_IFELSE(
1701 [
1702 AC_LANG_PROGRAM([[]], [[]])
1703 ],[
1704 ac_cv_disable_unused_parameter_warning=yes
1705 ],[
1706 ac_cv_disable_unused_parameter_warning=no
1707 ]))
1708 CC="$ac_save_cc"
1709 AC_MSG_RESULT($ac_cv_disable_unused_parameter_warning)
1710
1711 if test $ac_cv_disable_unused_parameter_warning = yes
1712 then
1713 CFLAGS_NODIST="$CFLAGS_NODIST -Wno-unused-parameter"
1714 fi
1715
1716 AC_MSG_CHECKING(if we can turn off $CC missing field initializers warning)
1717 ac_save_cc="$CC"
1718 CC="$CC -Wmissing-field-initializers -Werror"
1719 AC_CACHE_VAL(ac_cv_disable_missing_field_initializers,
1720 AC_COMPILE_IFELSE(
1721 [
1722 AC_LANG_PROGRAM([[]], [[]])
1723 ],[
1724 ac_cv_disable_missing_field_initializers=yes
1725 ],[
1726 ac_cv_disable_missing_field_initializers=no
1727 ]))
1728 CC="$ac_save_cc"
1729 AC_MSG_RESULT($ac_cv_disable_missing_field_initializers)
1730
1731 if test $ac_cv_disable_missing_field_initializers = yes
1732 then
1733 CFLAGS_NODIST="$CFLAGS_NODIST -Wno-missing-field-initializers"
Benjamin Peterson7ddbf102011-09-23 13:23:22 -04001734 fi
1735
Charles-François Natali7f9cc932014-08-01 21:57:49 +01001736 AC_MSG_CHECKING(if we can turn on $CC mixed sign comparison warning)
1737 ac_save_cc="$CC"
1738 CC="$CC -Wsign-compare"
1739 save_CFLAGS="$CFLAGS"
1740 AC_CACHE_VAL(ac_cv_enable_sign_compare_warning,
1741 AC_COMPILE_IFELSE(
1742 [
1743 AC_LANG_PROGRAM([[]], [[]])
1744 ],[
1745 ac_cv_enable_sign_compare_warning=yes
1746 ],[
1747 ac_cv_enable_sign_compare_warning=no
1748 ]))
1749 CFLAGS="$save_CFLAGS"
1750 CC="$ac_save_cc"
1751 AC_MSG_RESULT($ac_cv_enable_sign_compare_warning)
1752
1753 if test $ac_cv_enable_sign_compare_warning = yes
1754 then
1755 BASECFLAGS="$BASECFLAGS -Wsign-compare"
1756 fi
1757
1758 AC_MSG_CHECKING(if we can turn on $CC unreachable code warning)
1759 ac_save_cc="$CC"
1760 CC="$CC -Wunreachable-code"
1761 save_CFLAGS="$CFLAGS"
1762 AC_CACHE_VAL(ac_cv_enable_unreachable_code_warning,
1763 AC_COMPILE_IFELSE(
1764 [
1765 AC_LANG_PROGRAM([[]], [[]])
1766 ],[
1767 ac_cv_enable_unreachable_code_warning=yes
1768 ],[
1769 ac_cv_enable_unreachable_code_warning=no
1770 ]))
1771 CFLAGS="$save_CFLAGS"
1772 CC="$ac_save_cc"
Charles-François Natali7f9cc932014-08-01 21:57:49 +01001773
1774 # Don't enable unreachable code warning in debug mode, since it usually
1775 # results in non-standard code paths.
Ned Deilybec699e2016-03-08 00:28:37 -05001776 # Issue #24324: Unfortunately, the unreachable code warning does not work
1777 # correctly on gcc and has been silently removed from the compiler.
1778 # It is supported on clang but on OS X systems gcc may be an alias
1779 # for clang. Try to determine if the compiler is not really gcc and,
1780 # if so, only then enable the warning.
1781 if test $ac_cv_enable_unreachable_code_warning = yes && \
1782 test "$Py_DEBUG" != "true" && \
1783 test -z "`$CC --version 2>/dev/null | grep 'Free Software Foundation'`"
Charles-François Natali7f9cc932014-08-01 21:57:49 +01001784 then
1785 BASECFLAGS="$BASECFLAGS -Wunreachable-code"
Ned Deilybec699e2016-03-08 00:28:37 -05001786 else
1787 ac_cv_enable_unreachable_code_warning=no
Charles-François Natali7f9cc932014-08-01 21:57:49 +01001788 fi
Ned Deilybec699e2016-03-08 00:28:37 -05001789 AC_MSG_RESULT($ac_cv_enable_unreachable_code_warning)
Charles-François Natali7f9cc932014-08-01 21:57:49 +01001790
INADA Naokie3364842018-06-05 20:40:53 +09001791 AC_MSG_CHECKING(if we can turn on $CC strict-prototypes warning)
1792 ac_save_cc="$CC"
1793 CC="$CC -Werror -Wstrict-prototypes"
1794 AC_CACHE_VAL(ac_cv_enable_enable_strict_prototypes_warning,
1795 AC_COMPILE_IFELSE(
1796 [
1797 AC_LANG_PROGRAM([[]], [[]])
1798 ],[
1799 ac_cv_enable_strict_prototypes_warning=yes
1800 ],[
1801 ac_cv_enable_strict_prototypes_warning=no
1802 ]))
1803 CC="$ac_save_cc"
1804 AC_MSG_RESULT($ac_cv_enable_strict_prototypes_warning)
1805
1806 if test $ac_cv_enable_strict_prototypes_warning = yes
1807 then
1808 CFLAGS_NODIST="$CFLAGS_NODIST -Wstrict-prototypes"
1809 fi
1810
Victor Stinner193ee0a2017-02-06 14:24:00 +01001811 AC_MSG_CHECKING(if we can make implicit function declaration an error in $CC)
1812 ac_save_cc="$CC"
1813 CC="$CC -Werror=implicit-function-declaration"
1814 AC_CACHE_VAL(ac_cv_enable_implicit_function_declaration_error,
1815 AC_COMPILE_IFELSE(
1816 [
1817 AC_LANG_PROGRAM([[]], [[]])
1818 ],[
1819 ac_cv_enable_implicit_function_declaration_error=yes
1820 ],[
1821 ac_cv_enable_implicit_function_declaration_error=no
1822 ]))
1823 CC="$ac_save_cc"
1824 AC_MSG_RESULT($ac_cv_enable_implicit_function_declaration_error)
1825
1826 if test $ac_cv_enable_implicit_function_declaration_error = yes
1827 then
1828 CFLAGS_NODIST="$CFLAGS_NODIST -Werror=implicit-function-declaration"
1829 fi
1830
Vinay Sajip0b60f642019-10-15 08:26:12 +01001831 AC_MSG_CHECKING(if we can use visibility in $CC)
1832 ac_save_cc="$CC"
1833 CC="$CC -fvisibility=hidden"
1834 AC_CACHE_VAL(ac_cv_enable_visibility,
1835 AC_COMPILE_IFELSE(
1836 [
1837 AC_LANG_PROGRAM([[]], [[]])
1838 ],[
1839 ac_cv_enable_visibility=yes
1840 ],[
1841 ac_cv_enable_visibility=no
1842 ]))
1843 CC="$ac_save_cc"
1844 AC_MSG_RESULT($ac_cv_enable_visibility)
1845
1846 if test $ac_cv_enable_visibility = yes
1847 then
1848 CFLAGS_NODIST="$CFLAGS_NODIST -fvisibility=hidden"
1849 fi
1850
Mark Dickinsonb0e2b4c2008-04-26 20:48:56 +00001851 # if using gcc on alpha, use -mieee to get (near) full IEEE 754
1852 # support. Without this, treatment of subnormals doesn't follow
1853 # the standard.
Matthias Klosedf2aecb2012-03-15 22:19:28 +01001854 case $host in
Mark Dickinsonb0e2b4c2008-04-26 20:48:56 +00001855 alpha*)
1856 BASECFLAGS="$BASECFLAGS -mieee"
1857 ;;
1858 esac
1859
Skip Montanarodecc6a42003-01-01 20:07:49 +00001860 case $ac_sys_system in
1861 SCO_SV*)
1862 BASECFLAGS="$BASECFLAGS -m486 -DSCO5"
1863 ;;
Benjamin Peterson67c38e22008-07-17 16:10:34 +00001864
Ned Deily87adb6e2013-10-18 21:09:56 -07001865 Darwin*)
1866 # -Wno-long-double, -no-cpp-precomp, and -mno-fused-madd
1867 # used to be here, but non-Apple gcc doesn't accept them.
1868 if test "${CC}" = gcc
1869 then
1870 AC_MSG_CHECKING(which compiler should be used)
1871 case "${UNIVERSALSDK}" in
1872 */MacOSX10.4u.sdk)
1873 # Build using 10.4 SDK, force usage of gcc when the
1874 # compiler is gcc, otherwise the user will get very
1875 # confusing error messages when building on OSX 10.6
1876 CC=gcc-4.0
1877 CPP=cpp-4.0
1878 ;;
1879 esac
1880 AC_MSG_RESULT($CC)
1881 fi
Benjamin Peterson67c38e22008-07-17 16:10:34 +00001882
Ned Deily87adb6e2013-10-18 21:09:56 -07001883 if test "${enable_universalsdk}"
1884 then
1885 case "$UNIVERSAL_ARCHS" in
1886 32-bit)
1887 UNIVERSAL_ARCH_FLAGS="-arch ppc -arch i386"
1888 LIPO_32BIT_FLAGS=""
1889 ARCH_RUN_32BIT=""
1890 ;;
1891 64-bit)
1892 UNIVERSAL_ARCH_FLAGS="-arch ppc64 -arch x86_64"
1893 LIPO_32BIT_FLAGS=""
1894 ARCH_RUN_32BIT="true"
1895 ;;
1896 all)
1897 UNIVERSAL_ARCH_FLAGS="-arch i386 -arch ppc -arch ppc64 -arch x86_64"
1898 LIPO_32BIT_FLAGS="-extract ppc7400 -extract i386"
1899 ARCH_RUN_32BIT="/usr/bin/arch -i386 -ppc"
1900 ;;
Ronald Oussoren41761932020-11-08 10:05:27 +01001901 universal2)
1902 UNIVERSAL_ARCH_FLAGS="-arch arm64 -arch x86_64"
1903 LIPO_32BIT_FLAGS=""
1904 ARCH_RUN_32BIT="true"
1905 ;;
Ned Deily87adb6e2013-10-18 21:09:56 -07001906 intel)
1907 UNIVERSAL_ARCH_FLAGS="-arch i386 -arch x86_64"
1908 LIPO_32BIT_FLAGS="-extract i386"
1909 ARCH_RUN_32BIT="/usr/bin/arch -i386"
1910 ;;
1911 intel-32)
1912 UNIVERSAL_ARCH_FLAGS="-arch i386"
1913 LIPO_32BIT_FLAGS=""
1914 ARCH_RUN_32BIT=""
1915 ;;
Ned Deily8c9bb722018-01-30 07:42:14 -05001916 intel-64)
1917 UNIVERSAL_ARCH_FLAGS="-arch x86_64"
1918 LIPO_32BIT_FLAGS=""
1919 ARCH_RUN_32BIT="true"
1920 ;;
Ned Deily87adb6e2013-10-18 21:09:56 -07001921 3-way)
1922 UNIVERSAL_ARCH_FLAGS="-arch i386 -arch ppc -arch x86_64"
1923 LIPO_32BIT_FLAGS="-extract ppc7400 -extract i386"
1924 ARCH_RUN_32BIT="/usr/bin/arch -i386 -ppc"
1925 ;;
1926 *)
Ronald Oussoren41761932020-11-08 10:05:27 +01001927 AC_MSG_ERROR([proper usage is --with-universal-arch=universal2|32-bit|64-bit|all|intel|3-way])
Ned Deily87adb6e2013-10-18 21:09:56 -07001928 ;;
1929 esac
Georg Brandlfcaf9102008-07-16 02:17:56 +00001930
Ned Deily87adb6e2013-10-18 21:09:56 -07001931 if test "${UNIVERSALSDK}" != "/"
1932 then
Ned Deily8c9bb722018-01-30 07:42:14 -05001933 CFLAGS="${UNIVERSAL_ARCH_FLAGS} -isysroot ${UNIVERSALSDK} ${CFLAGS}"
1934 LDFLAGS="${UNIVERSAL_ARCH_FLAGS} -isysroot ${UNIVERSALSDK} ${LDFLAGS}"
Ned Deily87adb6e2013-10-18 21:09:56 -07001935 CPPFLAGS="-isysroot ${UNIVERSALSDK} ${CPPFLAGS}"
Ned Deily8c9bb722018-01-30 07:42:14 -05001936 else
1937 CFLAGS="${UNIVERSAL_ARCH_FLAGS} ${CFLAGS}"
1938 LDFLAGS="${UNIVERSAL_ARCH_FLAGS} ${LDFLAGS}"
Ned Deily87adb6e2013-10-18 21:09:56 -07001939 fi
1940 fi
Georg Brandlfcaf9102008-07-16 02:17:56 +00001941
Ned Deily87adb6e2013-10-18 21:09:56 -07001942 # Calculate an appropriate deployment target for this build:
1943 # The deployment target value is used explicitly to enable certain
1944 # features are enabled (such as builtin libedit support for readline)
Raymond Hettinger15f44ab2016-08-30 10:47:49 -07001945 # through the use of Apple's Availability Macros and is used as a
Ned Deily87adb6e2013-10-18 21:09:56 -07001946 # component of the string returned by distutils.get_platform().
1947 #
1948 # Use the value from:
1949 # 1. the MACOSX_DEPLOYMENT_TARGET environment variable if specified
1950 # 2. the operating system version of the build machine if >= 10.6
1951 # 3. If running on OS X 10.3 through 10.5, use the legacy tests
1952 # below to pick either 10.3, 10.4, or 10.5 as the target.
1953 # 4. If we are running on OS X 10.2 or earlier, good luck!
Ronald Oussoren3c064c12009-09-08 07:12:42 +00001954
Ned Deily87adb6e2013-10-18 21:09:56 -07001955 AC_MSG_CHECKING(which MACOSX_DEPLOYMENT_TARGET to use)
Ned Deily36820b62014-06-25 13:44:22 -07001956 cur_target_major=`sw_vers -productVersion | \
1957 sed 's/\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'`
1958 cur_target_minor=`sw_vers -productVersion | \
1959 sed 's/\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'`
1960 cur_target="${cur_target_major}.${cur_target_minor}"
1961 if test ${cur_target_major} -eq 10 && \
1962 test ${cur_target_minor} -ge 3 && \
1963 test ${cur_target_minor} -le 5
Ned Deily87adb6e2013-10-18 21:09:56 -07001964 then
Ned Deily36820b62014-06-25 13:44:22 -07001965 # OS X 10.3 through 10.5
Ned Deily87adb6e2013-10-18 21:09:56 -07001966 cur_target=10.3
1967 if test ${enable_universalsdk}
1968 then
1969 case "$UNIVERSAL_ARCHS" in
1970 all|3-way|intel|64-bit)
1971 # These configurations were first supported in 10.5
1972 cur_target='10.5'
1973 ;;
1974 esac
1975 else
1976 if test `/usr/bin/arch` = "i386"
1977 then
1978 # 10.4 was the first release to support Intel archs
1979 cur_target="10.4"
1980 fi
1981 fi
1982 fi
1983 CONFIGURE_MACOSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET-${cur_target}}
Ronald Oussoren3c064c12009-09-08 07:12:42 +00001984
Ned Deily87adb6e2013-10-18 21:09:56 -07001985 # Make sure that MACOSX_DEPLOYMENT_TARGET is set in the
1986 # environment with a value that is the same as what we'll use
1987 # in the Makefile to ensure that we'll get the same compiler
1988 # environment during configure and build time.
1989 MACOSX_DEPLOYMENT_TARGET="$CONFIGURE_MACOSX_DEPLOYMENT_TARGET"
1990 export MACOSX_DEPLOYMENT_TARGET
1991 EXPORT_MACOSX_DEPLOYMENT_TARGET=''
1992 AC_MSG_RESULT($MACOSX_DEPLOYMENT_TARGET)
Georg Brandlfcaf9102008-07-16 02:17:56 +00001993
Ned Deily87adb6e2013-10-18 21:09:56 -07001994 # end of Darwin* tests
1995 ;;
Skip Montanarodecc6a42003-01-01 20:07:49 +00001996 esac
1997 ;;
1998
1999*)
2000 case $ac_sys_system in
2001 OpenUNIX*|UnixWare*)
2002 BASECFLAGS="$BASECFLAGS -K pentium,host,inline,loop_unroll,alloca "
2003 ;;
2004 SCO_SV*)
2005 BASECFLAGS="$BASECFLAGS -belf -Ki486 -DSCO5"
2006 ;;
2007 esac
2008 ;;
2009esac
2010
Zachary Ware5af85642015-12-21 12:09:17 -06002011case "$CC" in
2012*icc*)
Stefan Krah84a79172020-09-04 22:33:17 +02002013 # ICC needs -fp-model strict or floats behave badly
Zachary Ware5af85642015-12-21 12:09:17 -06002014 CFLAGS_NODIST="$CFLAGS_NODIST -fp-model strict"
2015 ;;
Stefan Krah84a79172020-09-04 22:33:17 +02002016*xlc*)
2017 CFLAGS_NODIST="$CFLAGS_NODIST -qalias=noansi -qmaxmem=-1"
2018 ;;
Zachary Ware5af85642015-12-21 12:09:17 -06002019esac
2020
T. Woutersddbfa2c2017-05-23 01:30:49 +02002021if test "$assertions" = 'true'; then
Fred Drakee1ceaa02001-12-04 20:55:47 +00002022 :
2023else
2024 OPT="-DNDEBUG $OPT"
2025fi
2026
Guido van Rossum6f2260e1996-09-09 16:21:03 +00002027if test "$ac_arch_flags"
Guido van Rossumc5a39031996-07-31 17:35:03 +00002028then
Skip Montanarodecc6a42003-01-01 20:07:49 +00002029 BASECFLAGS="$BASECFLAGS $ac_arch_flags"
Guido van Rossumc5a39031996-07-31 17:35:03 +00002030fi
Guido van Rossum5739e7e1995-01-20 16:50:53 +00002031
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002032# On some compilers, pthreads are available without further options
2033# (e.g. MacOS X). On some of these systems, the compiler will not
2034# complain if unaccepted options are passed (e.g. gcc on Mac OS X).
2035# So we have to see first whether pthreads are available without
2036# options before we can check whether -Kpthread improves anything.
2037AC_MSG_CHECKING(whether pthreads are available without options)
2038AC_CACHE_VAL(ac_cv_pthread_is_default,
Matthias Kloseb159a552010-04-25 21:00:44 +00002039[AC_RUN_IFELSE([AC_LANG_SOURCE([[
Stefan Krah7dba5942012-11-22 22:49:11 +01002040#include <stdio.h>
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002041#include <pthread.h>
2042
2043void* routine(void* p){return NULL;}
2044
2045int main(){
2046 pthread_t p;
2047 if(pthread_create(&p,NULL,routine,NULL)!=0)
2048 return 1;
Jack Jansen4f8d0542002-03-08 13:43:01 +00002049 (void)pthread_detach(p);
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002050 return 0;
2051}
Matthias Kloseb159a552010-04-25 21:00:44 +00002052]])],[
Skip Montanarod8d39a02003-07-10 20:44:10 +00002053 ac_cv_pthread_is_default=yes
2054 ac_cv_kthread=no
2055 ac_cv_pthread=no
Matthias Kloseb159a552010-04-25 21:00:44 +00002056],[ac_cv_pthread_is_default=no],[ac_cv_pthread_is_default=no])
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002057])
2058AC_MSG_RESULT($ac_cv_pthread_is_default)
2059
2060
Victor Stinner1b80b242016-04-12 22:34:58 +02002061if test $ac_cv_pthread_is_default = yes
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002062then
2063 ac_cv_kpthread=no
2064else
Martin v. Löwis130fb172001-07-19 11:00:41 +00002065# -Kpthread, if available, provides the right #defines
2066# and linker options to make pthread_create available
Martin v. Löwis260aecc2001-10-07 08:14:41 +00002067# Some compilers won't report that they do not support -Kpthread,
2068# so we need to run a program to see whether it really made the
2069# function available.
Martin v. Löwis130fb172001-07-19 11:00:41 +00002070AC_MSG_CHECKING(whether $CC accepts -Kpthread)
2071AC_CACHE_VAL(ac_cv_kpthread,
2072[ac_save_cc="$CC"
2073CC="$CC -Kpthread"
Matthias Kloseb159a552010-04-25 21:00:44 +00002074AC_RUN_IFELSE([AC_LANG_SOURCE([[
Stefan Krah7dba5942012-11-22 22:49:11 +01002075#include <stdio.h>
Martin v. Löwis260aecc2001-10-07 08:14:41 +00002076#include <pthread.h>
2077
2078void* routine(void* p){return NULL;}
2079
2080int main(){
2081 pthread_t p;
2082 if(pthread_create(&p,NULL,routine,NULL)!=0)
2083 return 1;
Jack Jansen4f8d0542002-03-08 13:43:01 +00002084 (void)pthread_detach(p);
Martin v. Löwis260aecc2001-10-07 08:14:41 +00002085 return 0;
2086}
Matthias Kloseb159a552010-04-25 21:00:44 +00002087]])],[ac_cv_kpthread=yes],[ac_cv_kpthread=no],[ac_cv_kpthread=no])
Martin v. Löwis130fb172001-07-19 11:00:41 +00002088CC="$ac_save_cc"])
Martin v. Löwis130fb172001-07-19 11:00:41 +00002089AC_MSG_RESULT($ac_cv_kpthread)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002090fi
Martin v. Löwis130fb172001-07-19 11:00:41 +00002091
Skip Montanarod8d39a02003-07-10 20:44:10 +00002092if test $ac_cv_kpthread = no -a $ac_cv_pthread_is_default = no
Martin v. Löwis5f433f02003-05-05 05:05:30 +00002093then
2094# -Kthread, if available, provides the right #defines
2095# and linker options to make pthread_create available
2096# Some compilers won't report that they do not support -Kthread,
2097# so we need to run a program to see whether it really made the
2098# function available.
2099AC_MSG_CHECKING(whether $CC accepts -Kthread)
2100AC_CACHE_VAL(ac_cv_kthread,
2101[ac_save_cc="$CC"
2102CC="$CC -Kthread"
Matthias Kloseb159a552010-04-25 21:00:44 +00002103AC_RUN_IFELSE([AC_LANG_SOURCE([[
Stefan Krah7dba5942012-11-22 22:49:11 +01002104#include <stdio.h>
Martin v. Löwis5f433f02003-05-05 05:05:30 +00002105#include <pthread.h>
2106
2107void* routine(void* p){return NULL;}
2108
2109int main(){
2110 pthread_t p;
2111 if(pthread_create(&p,NULL,routine,NULL)!=0)
2112 return 1;
2113 (void)pthread_detach(p);
2114 return 0;
2115}
Matthias Kloseb159a552010-04-25 21:00:44 +00002116]])],[ac_cv_kthread=yes],[ac_cv_kthread=no],[ac_cv_kthread=no])
Martin v. Löwis5f433f02003-05-05 05:05:30 +00002117CC="$ac_save_cc"])
2118AC_MSG_RESULT($ac_cv_kthread)
2119fi
2120
Skip Montanarod8d39a02003-07-10 20:44:10 +00002121if test $ac_cv_kthread = no -a $ac_cv_pthread_is_default = no
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002122then
2123# -pthread, if available, provides the right #defines
2124# and linker options to make pthread_create available
2125# Some compilers won't report that they do not support -pthread,
2126# so we need to run a program to see whether it really made the
2127# function available.
2128AC_MSG_CHECKING(whether $CC accepts -pthread)
doko@python.org7981f202013-01-25 15:33:25 +01002129AC_CACHE_VAL(ac_cv_pthread,
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002130[ac_save_cc="$CC"
2131CC="$CC -pthread"
Matthias Kloseb159a552010-04-25 21:00:44 +00002132AC_RUN_IFELSE([AC_LANG_SOURCE([[
Stefan Krah7dba5942012-11-22 22:49:11 +01002133#include <stdio.h>
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002134#include <pthread.h>
2135
2136void* routine(void* p){return NULL;}
2137
2138int main(){
2139 pthread_t p;
2140 if(pthread_create(&p,NULL,routine,NULL)!=0)
2141 return 1;
2142 (void)pthread_detach(p);
2143 return 0;
2144}
Matthias Kloseb159a552010-04-25 21:00:44 +00002145]])],[ac_cv_pthread=yes],[ac_cv_pthread=no],[ac_cv_pthread=no])
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002146CC="$ac_save_cc"])
2147AC_MSG_RESULT($ac_cv_pthread)
2148fi
2149
Martin v. Löwisab1e5852003-06-28 07:46:38 +00002150# If we have set a CC compiler flag for thread support then
2151# check if it works for CXX, too.
2152ac_cv_cxx_thread=no
2153if test ! -z "$CXX"
2154then
2155AC_MSG_CHECKING(whether $CXX also accepts flags for thread support)
2156ac_save_cxx="$CXX"
2157
2158if test "$ac_cv_kpthread" = "yes"
2159then
Victor Stinner1b80b242016-04-12 22:34:58 +02002160 CXX="$CXX -Kpthread"
Martin v. Löwisab1e5852003-06-28 07:46:38 +00002161 ac_cv_cxx_thread=yes
2162elif test "$ac_cv_kthread" = "yes"
2163then
2164 CXX="$CXX -Kthread"
2165 ac_cv_cxx_thread=yes
2166elif test "$ac_cv_pthread" = "yes"
Victor Stinner1b80b242016-04-12 22:34:58 +02002167then
Martin v. Löwisab1e5852003-06-28 07:46:38 +00002168 CXX="$CXX -pthread"
2169 ac_cv_cxx_thread=yes
2170fi
2171
2172if test $ac_cv_cxx_thread = yes
2173then
2174 echo 'void foo();int main(){foo();}void foo(){}' > conftest.$ac_ext
2175 $CXX -c conftest.$ac_ext 2>&5
2176 if $CXX -o conftest$ac_exeext conftest.$ac_objext 2>&5 \
2177 && test -s conftest$ac_exeext && ./conftest$ac_exeext
2178 then
2179 ac_cv_cxx_thread=yes
2180 else
2181 ac_cv_cxx_thread=no
Martin v. Löwisab1e5852003-06-28 07:46:38 +00002182 fi
2183 rm -fr conftest*
Martin v. Löwisab1e5852003-06-28 07:46:38 +00002184fi
Brett Cannonc601e0f2004-11-07 01:24:12 +00002185AC_MSG_RESULT($ac_cv_cxx_thread)
Martin v. Löwisab1e5852003-06-28 07:46:38 +00002186fi
Martin v. Löwis519adae2003-09-20 10:47:47 +00002187CXX="$ac_save_cxx"
Martin v. Löwisab1e5852003-06-28 07:46:38 +00002188
Fred Drakece81d592000-07-09 14:39:29 +00002189dnl # check for ANSI or K&R ("traditional") preprocessor
2190dnl AC_MSG_CHECKING(for C preprocessor type)
Matthias Kloseb159a552010-04-25 21:00:44 +00002191dnl AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Fred Drakece81d592000-07-09 14:39:29 +00002192dnl #define spam(name, doc) {#name, &name, #name "() -- " doc}
2193dnl int foo;
2194dnl struct {char *name; int *addr; char *doc;} desc = spam(foo, "something");
Matthias Kloseb159a552010-04-25 21:00:44 +00002195dnl ]], [[;]])],[cpp_type=ansi],[AC_DEFINE(HAVE_OLD_CPP) cpp_type=traditional])
Fred Drakece81d592000-07-09 14:39:29 +00002196dnl AC_MSG_RESULT($cpp_type)
Guido van Rossum300fda71996-08-19 21:58:16 +00002197
Guido van Rossum627b2d71993-12-24 10:39:16 +00002198# checks for header files
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002199AC_HEADER_STDC
stratakise768c862018-01-23 16:11:24 +01002200AC_CHECK_HEADERS(asm/types.h crypt.h conio.h direct.h dlfcn.h errno.h \
Thomas Wouters0e3f5912006-08-11 14:57:12 +00002201fcntl.h grp.h \
doko@ubuntu.com1a4f5612014-04-17 20:13:44 +02002202ieeefp.h io.h langinfo.h libintl.h process.h pthread.h \
Benjamin Peterson4fe55102016-09-06 11:58:01 -07002203sched.h shadow.h signal.h stropts.h termios.h \
Benjamin Petersonea137402018-09-13 21:57:31 -07002204utime.h \
Jesus Cead8b9ae62011-11-14 19:07:41 +01002205poll.h sys/devpoll.h sys/epoll.h sys/poll.h \
Antoine Pitroubcf2b592012-02-08 23:28:36 +01002206sys/audioio.h sys/xattr.h sys/bsdtty.h sys/event.h sys/file.h sys/ioctl.h \
Martin v. Löwis9d6c6692012-02-03 17:44:58 +01002207sys/kern_control.h sys/loadavg.h sys/lock.h sys/mkdev.h sys/modem.h \
Benjamin Petersonfb2ae152016-12-19 23:54:25 -08002208sys/param.h sys/random.h sys/select.h sys/sendfile.h sys/socket.h sys/statvfs.h \
Martin v. Löwis9d6c6692012-02-03 17:44:58 +01002209sys/stat.h sys/syscall.h sys/sys_domain.h sys/termio.h sys/time.h \
Giampaolo Rodolàc9c2c8b2011-02-25 14:39:16 +00002210sys/times.h sys/types.h sys/uio.h sys/un.h sys/utsname.h sys/wait.h pty.h \
Gregory P. Smith3b1f2c32011-05-15 12:18:23 -07002211libutil.h sys/resource.h netpacket/packet.h sysexits.h bluetooth.h \
Benjamin Peterson93b2dee2016-09-09 10:22:45 -07002212linux/tipc.h linux/random.h spawn.h util.h alloca.h endian.h \
Benjamin Peterson5c0c3252019-11-05 21:58:31 -08002213sys/endian.h sys/sysmacros.h linux/memfd.h linux/wait.h sys/memfd.h sys/mman.h)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002214AC_HEADER_DIRENT
Martin v. Löwisdbe3f762002-10-10 14:27:30 +00002215AC_HEADER_MAJOR
Guido van Rossum627b2d71993-12-24 10:39:16 +00002216
Benjamin Peterson93b2dee2016-09-09 10:22:45 -07002217# bluetooth/bluetooth.h has been known to not compile with -std=c99.
2218# http://permalink.gmane.org/gmane.linux.bluez.kernel/22294
2219SAVE_CFLAGS=$CFLAGS
2220CFLAGS="-std=c99 $CFLAGS"
2221AC_CHECK_HEADERS(bluetooth/bluetooth.h)
2222CFLAGS=$SAVE_CFLAGS
2223
Gregory P. Smith3b1f2c32011-05-15 12:18:23 -07002224# On Darwin (OS X) net/if.h requires sys/socket.h to be imported first.
2225AC_CHECK_HEADERS([net/if.h], [], [],
2226[#include <stdio.h>
2227#ifdef STDC_HEADERS
2228# include <stdlib.h>
2229# include <stddef.h>
2230#else
2231# ifdef HAVE_STDLIB_H
2232# include <stdlib.h>
2233# endif
2234#endif
2235#ifdef HAVE_SYS_SOCKET_H
2236# include <sys/socket.h>
2237#endif
2238])
2239
Martin v. Löwis11017b12006-01-14 18:12:57 +00002240# On Linux, netlink.h requires asm/types.h
2241AC_CHECK_HEADERS(linux/netlink.h,,,[
2242#ifdef HAVE_ASM_TYPES_H
2243#include <asm/types.h>
2244#endif
2245#ifdef HAVE_SYS_SOCKET_H
2246#include <sys/socket.h>
2247#endif
2248])
2249
Bjorn Anderssonbb816512018-09-26 06:47:52 -07002250# On Linux, qrtr.h requires asm/types.h
2251AC_CHECK_HEADERS(linux/qrtr.h,,,[
2252#ifdef HAVE_ASM_TYPES_H
2253#include <asm/types.h>
2254#endif
2255#ifdef HAVE_SYS_SOCKET_H
2256#include <sys/socket.h>
2257#endif
2258])
2259
caaveryeffc12f2017-09-06 18:18:10 -04002260AC_CHECK_HEADERS(linux/vm_sockets.h,,,[
2261#ifdef HAVE_SYS_SOCKET_H
2262#include <sys/socket.h>
2263#endif
2264])
2265
karl ding360371f2020-04-29 15:31:19 -07002266# On Linux, can.h, can/bcm.h, can/j1939.h, can/raw.h require sys/socket.h
2267AC_CHECK_HEADERS(linux/can.h linux/can/bcm.h linux/can/j1939.h linux/can/raw.h,,,[
Charles-François Natali47413c12011-10-06 19:47:44 +02002268#ifdef HAVE_SYS_SOCKET_H
2269#include <sys/socket.h>
2270#endif
2271])
2272
Guido van Rossum627b2d71993-12-24 10:39:16 +00002273# checks for typedefs
Guido van Rossum5739e7e1995-01-20 16:50:53 +00002274was_it_defined=no
2275AC_MSG_CHECKING(for clock_t in time.h)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002276AC_EGREP_HEADER(clock_t, time.h, was_it_defined=yes, [
2277 AC_DEFINE(clock_t, long, [Define to 'long' if <time.h> doesn't define.])
2278])
Guido van Rossum5739e7e1995-01-20 16:50:53 +00002279AC_MSG_RESULT($was_it_defined)
2280
Neal Norwitz11690112002-07-30 01:08:28 +00002281AC_MSG_CHECKING(for makedev)
Jesus Cea740f53a2010-04-28 11:35:30 +00002282AC_LINK_IFELSE([AC_LANG_PROGRAM([[
2283#if defined(MAJOR_IN_MKDEV)
2284#include <sys/mkdev.h>
2285#elif defined(MAJOR_IN_SYSMACROS)
2286#include <sys/sysmacros.h>
2287#else
2288#include <sys/types.h>
2289#endif
2290]], [[
2291 makedev(0, 0) ]])
Matthias Kloseb159a552010-04-25 21:00:44 +00002292],[ac_cv_has_makedev=yes],[ac_cv_has_makedev=no])
Neal Norwitz11690112002-07-30 01:08:28 +00002293AC_MSG_RESULT($ac_cv_has_makedev)
2294if test "$ac_cv_has_makedev" = "yes"; then
2295 AC_DEFINE(HAVE_MAKEDEV, 1, [Define this if you have the makedev macro.])
2296fi
2297
Christian Heimes985ecdc2013-11-20 11:46:18 +01002298# byte swapping
2299AC_MSG_CHECKING(for le64toh)
2300AC_LINK_IFELSE([AC_LANG_PROGRAM([[
2301#ifdef HAVE_ENDIAN_H
2302#include <endian.h>
2303#elif defined(HAVE_SYS_ENDIAN_H)
2304#include <sys/endian.h>
2305#endif
2306]], [[
2307 le64toh(1) ]])
2308],[ac_cv_has_le64toh=yes],[ac_cv_has_le64toh=no])
2309AC_MSG_RESULT($ac_cv_has_le64toh)
2310if test "$ac_cv_has_le64toh" = "yes"; then
2311 AC_DEFINE(HAVE_HTOLE64, 1, [Define this if you have le64toh()])
2312fi
2313
Martin v. Löwis399a6892002-10-04 10:22:02 +00002314use_lfs=yes
doko@ubuntu.com006a56c2016-06-14 10:15:25 +02002315# Don't use largefile support for GNU/Hurd
2316case $ac_sys_system in GNU*)
2317 use_lfs=no
2318esac
2319
Martin v. Löwis399a6892002-10-04 10:22:02 +00002320if test "$use_lfs" = "yes"; then
Guido van Rossum810cc512001-09-09 23:51:39 +00002321# Two defines needed to enable largefile support on various platforms
2322# These may affect some typedefs
Georg Brandl216e4042011-02-19 08:58:23 +00002323case $ac_sys_system/$ac_sys_release in
2324AIX*)
Victor Stinner1b80b242016-04-12 22:34:58 +02002325 AC_DEFINE(_LARGE_FILES, 1,
Georg Brandl216e4042011-02-19 08:58:23 +00002326 [This must be defined on AIX systems to enable large file support.])
2327 ;;
2328esac
Victor Stinner1b80b242016-04-12 22:34:58 +02002329AC_DEFINE(_LARGEFILE_SOURCE, 1,
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002330[This must be defined on some systems to enable large file support.])
2331AC_DEFINE(_FILE_OFFSET_BITS, 64,
2332[This must be set to 64 on some systems to enable large file support.])
Martin v. Löwis399a6892002-10-04 10:22:02 +00002333fi
Guido van Rossum810cc512001-09-09 23:51:39 +00002334
Guido van Rossum300fda71996-08-19 21:58:16 +00002335# Add some code to confdefs.h so that the test for off_t works on SCO
2336cat >> confdefs.h <<\EOF
2337#if defined(SCO_DS)
2338#undef _OFF_T
2339#endif
2340EOF
2341
Guido van Rossumef2255b2000-03-10 22:30:29 +00002342# Type availability checks
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002343AC_TYPE_MODE_T
2344AC_TYPE_OFF_T
2345AC_TYPE_PID_T
Matthias Klosebada4c32010-04-25 21:18:48 +00002346AC_DEFINE_UNQUOTED([RETSIGTYPE],[void],[assume C89 semantics that RETSIGTYPE is always void])
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002347AC_TYPE_SIZE_T
2348AC_TYPE_UID_T
Mark Dickinson983bc162012-12-02 12:11:38 +00002349
Christian Heimes400adb02008-02-01 08:12:03 +00002350AC_CHECK_TYPE(ssize_t,
Matthias Klosec80c93f2010-04-24 17:04:35 +00002351 AC_DEFINE(HAVE_SSIZE_T, 1, [Define if your compiler provides ssize_t]),,)
Stefan Krah1919b7e2012-03-21 18:25:23 +01002352AC_CHECK_TYPE(__uint128_t,
2353 AC_DEFINE(HAVE_GCC_UINT128_T, 1, [Define if your compiler provides __uint128_t]),,)
Guido van Rossum627b2d71993-12-24 10:39:16 +00002354
Guido van Rossumef2255b2000-03-10 22:30:29 +00002355# Sizes of various common basic types
Skip Montanarob9820a32004-01-17 00:16:12 +00002356# ANSI C requires sizeof(char) == 1, so no need to check it
Guido van Rossum3065c942001-09-17 04:03:14 +00002357AC_CHECK_SIZEOF(int, 4)
2358AC_CHECK_SIZEOF(long, 4)
Benjamin Petersoned4aa832016-09-05 17:44:18 -07002359AC_CHECK_SIZEOF(long long, 8)
Guido van Rossum3065c942001-09-17 04:03:14 +00002360AC_CHECK_SIZEOF(void *, 4)
Guido van Rossum3065c942001-09-17 04:03:14 +00002361AC_CHECK_SIZEOF(short, 2)
2362AC_CHECK_SIZEOF(float, 4)
2363AC_CHECK_SIZEOF(double, 8)
2364AC_CHECK_SIZEOF(fpos_t, 4)
Martin v. Löwis18e16552006-02-15 17:27:45 +00002365AC_CHECK_SIZEOF(size_t, 4)
Christian Heimes400adb02008-02-01 08:12:03 +00002366AC_CHECK_SIZEOF(pid_t, 4)
Benjamin Petersondf6ff7b2016-09-06 13:53:14 -07002367AC_CHECK_SIZEOF(uintptr_t)
Guido van Rossumac405f61994-09-12 10:56:06 +00002368
Eitan Adler3055c942018-05-15 22:58:09 -07002369AC_TYPE_LONG_DOUBLE
Travis E. Oliphant9b307842007-10-12 22:06:37 +00002370AC_CHECK_SIZEOF(long double, 16)
Travis E. Oliphant9b307842007-10-12 22:06:37 +00002371
Thomas Woutersb2137042007-02-01 18:02:27 +00002372AC_CHECK_SIZEOF(_Bool, 1)
Thomas Woutersb2137042007-02-01 18:02:27 +00002373
Alexandre Vassalotti0805b4a2009-07-17 05:47:33 +00002374AC_CHECK_SIZEOF(off_t, [], [
2375#ifdef HAVE_SYS_TYPES_H
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00002376#include <sys/types.h>
Alexandre Vassalotti0805b4a2009-07-17 05:47:33 +00002377#endif
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00002378])
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00002379
2380AC_MSG_CHECKING(whether to enable large file support)
Mark Dickinson2df5d282009-12-31 21:22:50 +00002381if test "$ac_cv_sizeof_off_t" -gt "$ac_cv_sizeof_long" -a \
Guido van Rossum8bc1dfd1999-04-10 16:01:48 +00002382 "$ac_cv_sizeof_long_long" -ge "$ac_cv_sizeof_off_t"; then
Victor Stinner1b80b242016-04-12 22:34:58 +02002383 AC_DEFINE(HAVE_LARGEFILE_SUPPORT, 1,
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002384 [Defined to enable large file support when an off_t is bigger than a long
Sergey Fedoseev52c1a6a2019-08-26 20:12:47 +05002385 and long long is at least as big as an off_t. You may need
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002386 to add some flags for configuration and compilation to enable this mode.
2387 (For Solaris and Linux, the necessary defines are already defined.)])
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00002388 AC_MSG_RESULT(yes)
2389else
2390 AC_MSG_RESULT(no)
2391fi
2392
Alexandre Vassalotti0805b4a2009-07-17 05:47:33 +00002393AC_CHECK_SIZEOF(time_t, [], [
2394#ifdef HAVE_SYS_TYPES_H
2395#include <sys/types.h>
2396#endif
2397#ifdef HAVE_TIME_H
Fred Drakea3f6e912000-06-29 20:44:47 +00002398#include <time.h>
Alexandre Vassalotti0805b4a2009-07-17 05:47:33 +00002399#endif
Fred Drakea3f6e912000-06-29 20:44:47 +00002400])
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00002401
Trent Mick635f6fb2000-08-23 21:33:05 +00002402# if have pthread_t then define SIZEOF_PTHREAD_T
Martin v. Löwis123cbd22001-07-19 14:21:10 +00002403ac_save_cc="$CC"
2404if test "$ac_cv_kpthread" = "yes"
2405then CC="$CC -Kpthread"
Martin v. Löwis5f433f02003-05-05 05:05:30 +00002406elif test "$ac_cv_kthread" = "yes"
2407then CC="$CC -Kthread"
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002408elif test "$ac_cv_pthread" = "yes"
2409then CC="$CC -pthread"
Martin v. Löwis123cbd22001-07-19 14:21:10 +00002410fi
Alexandre Vassalotti0805b4a2009-07-17 05:47:33 +00002411
Trent Mick635f6fb2000-08-23 21:33:05 +00002412AC_MSG_CHECKING(for pthread_t)
2413have_pthread_t=no
Matthias Kloseb159a552010-04-25 21:00:44 +00002414AC_COMPILE_IFELSE([
2415 AC_LANG_PROGRAM([[#include <pthread.h>]], [[pthread_t x; x = *(pthread_t*)0;]])
2416],[have_pthread_t=yes],[])
Trent Mick635f6fb2000-08-23 21:33:05 +00002417AC_MSG_RESULT($have_pthread_t)
2418if test "$have_pthread_t" = yes ; then
Alexandre Vassalotti0805b4a2009-07-17 05:47:33 +00002419 AC_CHECK_SIZEOF(pthread_t, [], [
2420#ifdef HAVE_PTHREAD_H
Neal Norwitz6eb37f02003-02-23 23:28:15 +00002421#include <pthread.h>
Alexandre Vassalotti0805b4a2009-07-17 05:47:33 +00002422#endif
Trent Mick635f6fb2000-08-23 21:33:05 +00002423 ])
Trent Mick635f6fb2000-08-23 21:33:05 +00002424fi
Masayuki Yamamoto731e1892017-10-06 19:41:34 +09002425
2426# Issue #25658: POSIX hasn't defined that pthread_key_t is compatible with int.
2427# This checking will be unnecessary after removing deprecated TLS API.
2428AC_CHECK_SIZEOF(pthread_key_t, [], [[#include <pthread.h>]])
2429AC_MSG_CHECKING(whether pthread_key_t is compatible with int)
2430if test "$ac_cv_sizeof_pthread_key_t" -eq "$ac_cv_sizeof_int" ; then
2431 AC_COMPILE_IFELSE(
2432 [AC_LANG_PROGRAM([[#include <pthread.h>]], [[pthread_key_t k; k * 1;]])],
2433 [ac_pthread_key_t_is_arithmetic_type=yes],
2434 [ac_pthread_key_t_is_arithmetic_type=no]
2435 )
2436 AC_MSG_RESULT($ac_pthread_key_t_is_arithmetic_type)
2437 if test "$ac_pthread_key_t_is_arithmetic_type" = yes ; then
2438 AC_DEFINE(PTHREAD_KEY_T_IS_COMPATIBLE_WITH_INT, 1,
2439 [Define if pthread_key_t is compatible with int.])
2440 fi
2441else
2442 AC_MSG_RESULT(no)
2443fi
Martin v. Löwis123cbd22001-07-19 14:21:10 +00002444CC="$ac_save_cc"
Trent Mick635f6fb2000-08-23 21:33:05 +00002445
Bob Ippolito7026a0a2005-03-28 23:23:47 +00002446AC_SUBST(OTHER_LIBTOOL_OPT)
2447case $ac_sys_system/$ac_sys_release in
Victor Stinner1b80b242016-04-12 22:34:58 +02002448 Darwin/@<:@01567@:>@\..*)
Bob Ippolito7026a0a2005-03-28 23:23:47 +00002449 OTHER_LIBTOOL_OPT="-prebind -seg1addr 0x10000000"
2450 ;;
2451 Darwin/*)
2452 OTHER_LIBTOOL_OPT=""
2453 ;;
2454esac
2455
Ronald Oussoren5bbab3e2009-09-06 11:01:15 +00002456
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00002457AC_SUBST(LIBTOOL_CRUFT)
2458case $ac_sys_system/$ac_sys_release in
Victor Stinner1b80b242016-04-12 22:34:58 +02002459 Darwin/@<:@01567@:>@\..*)
Thomas Wouters477c8d52006-05-27 19:21:47 +00002460 LIBTOOL_CRUFT="-framework System -lcc_dynamic"
2461 if test "${enable_universalsdk}"; then
2462 :
2463 else
Ronald Oussorene3da75a2010-02-11 13:38:58 +00002464 LIBTOOL_CRUFT="${LIBTOOL_CRUFT} -arch_only `/usr/bin/arch`"
Thomas Wouters477c8d52006-05-27 19:21:47 +00002465 fi
Jack Jansenb36687a2004-07-16 08:43:47 +00002466 LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -install_name $(PYTHONFRAMEWORKINSTALLDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansena3891ea2001-09-07 14:25:12 +00002467 LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -compatibility_version $(VERSION) -current_version $(VERSION)';;
Guido van Rossum5839e582000-10-09 19:52:35 +00002468 Darwin/*)
Ronald Oussoren9812a6c2010-02-07 11:53:18 +00002469 gcc_version=`gcc -dumpversion`
Bob Ippolito7026a0a2005-03-28 23:23:47 +00002470 if test ${gcc_version} '<' 4.0
2471 then
2472 LIBTOOL_CRUFT="-lcc_dynamic"
Victor Stinner1b80b242016-04-12 22:34:58 +02002473 else
Bob Ippolito7026a0a2005-03-28 23:23:47 +00002474 LIBTOOL_CRUFT=""
2475 fi
Matthias Kloseb159a552010-04-25 21:00:44 +00002476 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Ronald Oussoren5bbab3e2009-09-06 11:01:15 +00002477 #include <unistd.h>
2478 int main(int argc, char*argv[])
2479 {
2480 if (sizeof(long) == 4) {
2481 return 0;
2482 } else {
2483 return 1;
2484 }
Ronald Oussoren3c064c12009-09-08 07:12:42 +00002485 }
Matthias Kloseb159a552010-04-25 21:00:44 +00002486 ]])],[ac_osx_32bit=yes],[ac_osx_32bit=no],[ac_osx_32bit=yes])
Victor Stinner1b80b242016-04-12 22:34:58 +02002487
Ronald Oussoren5bbab3e2009-09-06 11:01:15 +00002488 if test "${ac_osx_32bit}" = "yes"; then
Ronald Oussorene3da75a2010-02-11 13:38:58 +00002489 case `/usr/bin/arch` in
Victor Stinner1b80b242016-04-12 22:34:58 +02002490 i386)
2491 MACOSX_DEFAULT_ARCH="i386"
Ronald Oussoren5bbab3e2009-09-06 11:01:15 +00002492 ;;
Victor Stinner1b80b242016-04-12 22:34:58 +02002493 ppc)
2494 MACOSX_DEFAULT_ARCH="ppc"
Ronald Oussoren5bbab3e2009-09-06 11:01:15 +00002495 ;;
2496 *)
Ronald Oussoren41761932020-11-08 10:05:27 +01002497 AC_MSG_ERROR([Unexpected output of 'arch' on macOS])
Ronald Oussoren5bbab3e2009-09-06 11:01:15 +00002498 ;;
2499 esac
2500 else
Ronald Oussorene3da75a2010-02-11 13:38:58 +00002501 case `/usr/bin/arch` in
Victor Stinner1b80b242016-04-12 22:34:58 +02002502 i386)
2503 MACOSX_DEFAULT_ARCH="x86_64"
Ronald Oussoren5bbab3e2009-09-06 11:01:15 +00002504 ;;
Victor Stinner1b80b242016-04-12 22:34:58 +02002505 ppc)
2506 MACOSX_DEFAULT_ARCH="ppc64"
Ronald Oussoren41761932020-11-08 10:05:27 +01002507 ;;
2508 arm64)
2509 MACOSX_DEFAULT_ARCH="arm64"
Ronald Oussoren5bbab3e2009-09-06 11:01:15 +00002510 ;;
2511 *)
Ronald Oussoren41761932020-11-08 10:05:27 +01002512 AC_MSG_ERROR([Unexpected output of 'arch' on macOS])
Ronald Oussoren5bbab3e2009-09-06 11:01:15 +00002513 ;;
2514 esac
2515
Ronald Oussoren5bbab3e2009-09-06 11:01:15 +00002516 fi
2517
2518 LIBTOOL_CRUFT=$LIBTOOL_CRUFT" -lSystem -lSystemStubs -arch_only ${MACOSX_DEFAULT_ARCH}"
Jack Jansenb36687a2004-07-16 08:43:47 +00002519 LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -install_name $(PYTHONFRAMEWORKINSTALLDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansenb6e9cad2001-08-15 01:26:28 +00002520 LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -compatibility_version $(VERSION) -current_version $(VERSION)';;
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00002521esac
Jack Jansenb6e9cad2001-08-15 01:26:28 +00002522AC_MSG_CHECKING(for --enable-framework)
2523if test "$enable_framework"
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00002524then
Skip Montanarodecc6a42003-01-01 20:07:49 +00002525 BASECFLAGS="$BASECFLAGS -fno-common -dynamic"
Victor Stinner1b80b242016-04-12 22:34:58 +02002526 # -F. is needed to allow linking to the framework while
Jack Jansenb6e9cad2001-08-15 01:26:28 +00002527 # in the build location.
Victor Stinner1b80b242016-04-12 22:34:58 +02002528 AC_DEFINE(WITH_NEXT_FRAMEWORK, 1,
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002529 [Define if you want to produce an OpenStep/Rhapsody framework
2530 (shared library plus accessory files).])
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00002531 AC_MSG_RESULT(yes)
Ronald Oussoren99aab652009-06-08 21:22:57 +00002532 if test $enable_shared = "yes"
2533 then
2534 AC_MSG_ERROR([Specifying both --enable-shared and --enable-framework is not supported, use only --enable-framework instead])
2535 fi
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00002536else
2537 AC_MSG_RESULT(no)
2538fi
2539
Jack Jansenb6e9cad2001-08-15 01:26:28 +00002540AC_MSG_CHECKING(for dyld)
Jack Jansen9a66b6d2001-08-08 13:56:14 +00002541case $ac_sys_system/$ac_sys_release in
2542 Darwin/*)
Victor Stinner1b80b242016-04-12 22:34:58 +02002543 AC_DEFINE(WITH_DYLD, 1,
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002544 [Define if you want to use the new-style (Openstep, Rhapsody, MacOS)
2545 dynamic linker (dyld) instead of the old-style (NextStep) dynamic
2546 linker (rld). Dyld is necessary to support frameworks.])
Jack Jansen9a66b6d2001-08-08 13:56:14 +00002547 AC_MSG_RESULT(always on for Darwin)
2548 ;;
2549 *)
Jack Jansenb6e9cad2001-08-15 01:26:28 +00002550 AC_MSG_RESULT(no)
2551 ;;
Jack Jansen9a66b6d2001-08-08 13:56:14 +00002552esac
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00002553
Guido van Rossumac405f61994-09-12 10:56:06 +00002554# Set info about shared libraries.
doko@ubuntu.comd5537d02013-03-21 13:21:49 -07002555AC_SUBST(SHLIB_SUFFIX)
Guido van Rossumac405f61994-09-12 10:56:06 +00002556AC_SUBST(LDSHARED)
Tarek Ziadé03d788d2010-04-03 08:46:49 +00002557AC_SUBST(LDCXXSHARED)
Neil Schemenauerb3531b82001-02-16 04:09:05 +00002558AC_SUBST(BLDSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00002559AC_SUBST(CCSHARED)
2560AC_SUBST(LINKFORSHARED)
Georg Brandlb1441c72009-01-03 22:33:39 +00002561
doko@ubuntu.comd5537d02013-03-21 13:21:49 -07002562# SHLIB_SUFFIX is the extension of shared libraries `(including the dot!)
2563# -- usually .so, .sl on HP-UX, .dll on Cygwin
2564AC_MSG_CHECKING(the extension of shared libraries)
2565if test -z "$SHLIB_SUFFIX"; then
2566 case $ac_sys_system in
2567 hp*|HP*)
2568 case `uname -m` in
2569 ia64) SHLIB_SUFFIX=.so;;
2570 *) SHLIB_SUFFIX=.sl;;
2571 esac
2572 ;;
2573 CYGWIN*) SHLIB_SUFFIX=.dll;;
2574 *) SHLIB_SUFFIX=.so;;
2575 esac
2576fi
2577AC_MSG_RESULT($SHLIB_SUFFIX)
2578
Guido van Rossumac405f61994-09-12 10:56:06 +00002579# LDSHARED is the ld *command* used to create shared library
Benjamin Peterson06930632017-09-04 16:36:05 -07002580# -- "cc -G" on SunOS 5.x.
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00002581# (Shared libraries in this instance are shared modules to be loaded into
2582# Python, as opposed to building Python itself as a shared library.)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002583AC_MSG_CHECKING(LDSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00002584if test -z "$LDSHARED"
2585then
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002586 case $ac_sys_system/$ac_sys_release in
Neil Schemenauerb3531b82001-02-16 04:09:05 +00002587 AIX*)
Martin Panter395733d2016-11-20 07:56:37 +00002588 BLDSHARED="Modules/ld_so_aix \$(CC) -bI:Modules/python.exp"
Martin Panter5de141f2016-08-27 04:00:19 +00002589 LDSHARED="\$(LIBPL)/ld_so_aix \$(CC) -bI:\$(LIBPL)/python.exp"
Neil Schemenauerb3531b82001-02-16 04:09:05 +00002590 ;;
Victor Stinner1b80b242016-04-12 22:34:58 +02002591 SunOS/5*)
Tarek Ziadé03d788d2010-04-03 08:46:49 +00002592 if test "$GCC" = "yes" ; then
2593 LDSHARED='$(CC) -shared'
2594 LDCXXSHARED='$(CXX) -shared'
2595 else
2596 LDSHARED='$(CC) -G'
2597 LDCXXSHARED='$(CXX) -G'
Greg Ward57c9a6632000-05-26 12:22:54 +00002598 fi ;;
Thomas Hellerf44b9a12008-04-04 10:18:23 +00002599 hp*|HP*)
Tarek Ziadé03d788d2010-04-03 08:46:49 +00002600 if test "$GCC" = "yes" ; then
2601 LDSHARED='$(CC) -shared'
2602 LDCXXSHARED='$(CXX) -shared'
2603 else
Rob Boehne9d25bd12017-12-06 11:58:17 -06002604 LDSHARED='$(CC) -b'
2605 LDCXXSHARED='$(CXX) -b'
Thomas Hellerf44b9a12008-04-04 10:18:23 +00002606 fi ;;
Jack Jansen418c3b12001-11-14 10:59:57 +00002607 Darwin/1.3*)
Antoine Pitroud4958c22010-10-13 17:01:10 +00002608 LDSHARED='$(CC) -bundle'
2609 LDCXXSHARED='$(CXX) -bundle'
Jack Jansena3891ea2001-09-07 14:25:12 +00002610 if test "$enable_framework" ; then
2611 # Link against the framework. All externals should be defined.
Jack Jansenda49e192005-01-07 13:08:22 +00002612 BLDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
2613 LDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Tarek Ziadé03d788d2010-04-03 08:46:49 +00002614 LDCXXSHARED="$LDCXXSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansena3891ea2001-09-07 14:25:12 +00002615 else
2616 # No framework. Ignore undefined symbols, assuming they come from Python
Jack Jansen418c3b12001-11-14 10:59:57 +00002617 LDSHARED="$LDSHARED -undefined suppress"
Tarek Ziadé03d788d2010-04-03 08:46:49 +00002618 LDCXXSHARED="$LDCXXSHARED -undefined suppress"
Jack Jansena3891ea2001-09-07 14:25:12 +00002619 fi ;;
Jack Jansen6b08a402004-06-03 12:41:45 +00002620 Darwin/1.4*|Darwin/5.*|Darwin/6.*)
Antoine Pitroud4958c22010-10-13 17:01:10 +00002621 LDSHARED='$(CC) -bundle'
2622 LDCXXSHARED='$(CXX) -bundle'
Jack Jansenb6e9cad2001-08-15 01:26:28 +00002623 if test "$enable_framework" ; then
2624 # Link against the framework. All externals should be defined.
Jack Jansenda49e192005-01-07 13:08:22 +00002625 BLDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
2626 LDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Tarek Ziadé03d788d2010-04-03 08:46:49 +00002627 LDCXXSHARED="$LDCXXSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansenb6e9cad2001-08-15 01:26:28 +00002628 else
Michael W. Hudson0c46c0c2002-03-07 09:58:56 +00002629 # No framework, use the Python app as bundle-loader
2630 BLDSHARED="$LDSHARED "'-bundle_loader $(BUILDPYTHON)'
Jack Jansenc28fc372003-02-25 13:14:43 +00002631 LDSHARED="$LDSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)'
Tarek Ziadé03d788d2010-04-03 08:46:49 +00002632 LDCXXSHARED="$LDCXXSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)'
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00002633 fi ;;
Jack Jansen6b08a402004-06-03 12:41:45 +00002634 Darwin/*)
2635 # Use -undefined dynamic_lookup whenever possible (10.3 and later).
2636 # This allows an extension to be used in any Python
Thomas Wouters89d996e2007-09-08 17:39:28 +00002637
Ned Deily36820b62014-06-25 13:44:22 -07002638 dep_target_major=`echo ${MACOSX_DEPLOYMENT_TARGET} | \
2639 sed 's/\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'`
2640 dep_target_minor=`echo ${MACOSX_DEPLOYMENT_TARGET} | \
2641 sed 's/\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'`
2642 if test ${dep_target_major} -eq 10 && \
2643 test ${dep_target_minor} -le 2
Jack Jansen6b08a402004-06-03 12:41:45 +00002644 then
Ned Deily36820b62014-06-25 13:44:22 -07002645 # building for OS X 10.0 through 10.2
Antoine Pitroud4958c22010-10-13 17:01:10 +00002646 LDSHARED='$(CC) -bundle'
2647 LDCXXSHARED='$(CXX) -bundle'
Jack Jansen6b08a402004-06-03 12:41:45 +00002648 if test "$enable_framework" ; then
2649 # Link against the framework. All externals should be defined.
Jack Jansenda49e192005-01-07 13:08:22 +00002650 BLDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
2651 LDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Tarek Ziadé03d788d2010-04-03 08:46:49 +00002652 LDCXXSHARED="$LDCXXSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansen6b08a402004-06-03 12:41:45 +00002653 else
2654 # No framework, use the Python app as bundle-loader
2655 BLDSHARED="$LDSHARED "'-bundle_loader $(BUILDPYTHON)'
2656 LDSHARED="$LDSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)'
Tarek Ziadé03d788d2010-04-03 08:46:49 +00002657 LDCXXSHARED="$LDCXXSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)'
Jack Jansen6b08a402004-06-03 12:41:45 +00002658 fi
Ned Deily36820b62014-06-25 13:44:22 -07002659 else
2660 # building for OS X 10.3 and later
2661 LDSHARED='$(CC) -bundle -undefined dynamic_lookup'
2662 LDCXXSHARED='$(CXX) -bundle -undefined dynamic_lookup'
2663 BLDSHARED="$LDSHARED"
Jack Jansen6b08a402004-06-03 12:41:45 +00002664 fi
2665 ;;
pxinwr32f5fdd2019-02-27 19:09:28 +08002666 Linux*|GNU*|QNX*|VxWorks*)
Tarek Ziadé03d788d2010-04-03 08:46:49 +00002667 LDSHARED='$(CC) -shared'
2668 LDCXXSHARED='$(CXX) -shared';;
Thomas Wouters1ba5b3b2006-06-08 14:52:47 +00002669 FreeBSD*)
Jeremy Hylton4bcc7c52000-08-31 17:45:35 +00002670 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
Guido van Rossum0286ae82000-08-29 15:06:49 +00002671 then
Antoine Pitroud4958c22010-10-13 17:01:10 +00002672 LDSHARED='$(CC) -shared'
2673 LDCXXSHARED='$(CXX) -shared'
Guido van Rossum0286ae82000-08-29 15:06:49 +00002674 else
Antoine Pitroud4958c22010-10-13 17:01:10 +00002675 LDSHARED="ld -Bshareable"
Guido van Rossum0286ae82000-08-29 15:06:49 +00002676 fi;;
Thomas Wouters1ba5b3b2006-06-08 14:52:47 +00002677 OpenBSD*)
2678 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
2679 then
Antoine Pitroud4958c22010-10-13 17:01:10 +00002680 LDSHARED='$(CC) -shared $(CCSHARED)'
2681 LDCXXSHARED='$(CXX) -shared $(CCSHARED)'
Thomas Wouters1ba5b3b2006-06-08 14:52:47 +00002682 else
2683 case `uname -r` in
2684 [[01]].* | 2.[[0-7]] | 2.[[0-7]].*)
2685 LDSHARED="ld -Bshareable ${LDFLAGS}"
2686 ;;
2687 *)
Antoine Pitroud4958c22010-10-13 17:01:10 +00002688 LDSHARED='$(CC) -shared $(CCSHARED)'
2689 LDCXXSHARED='$(CXX) -shared $(CCSHARED)'
Thomas Wouters1ba5b3b2006-06-08 14:52:47 +00002690 ;;
2691 esac
2692 fi;;
Tarek Ziadé03d788d2010-04-03 08:46:49 +00002693 NetBSD*|DragonFly*)
Antoine Pitrouece919e2011-01-02 20:45:21 +00002694 LDSHARED='$(CC) -shared'
2695 LDCXXSHARED='$(CXX) -shared';;
Martin v. Löwis25ae43b2001-10-07 08:39:18 +00002696 OpenUNIX*|UnixWare*)
Tarek Ziadé03d788d2010-04-03 08:46:49 +00002697 if test "$GCC" = "yes" ; then
2698 LDSHARED='$(CC) -shared'
2699 LDCXXSHARED='$(CXX) -shared'
2700 else
2701 LDSHARED='$(CC) -G'
2702 LDCXXSHARED='$(CXX) -G'
Martin v. Löwisbec19582001-03-21 15:57:54 +00002703 fi;;
Tarek Ziadé03d788d2010-04-03 08:46:49 +00002704 SCO_SV*)
2705 LDSHARED='$(CC) -Wl,-G,-Bexport'
2706 LDCXXSHARED='$(CXX) -Wl,-G,-Bexport';;
2707 CYGWIN*)
2708 LDSHARED="gcc -shared -Wl,--enable-auto-image-base"
2709 LDCXXSHARED="g++ -shared -Wl,--enable-auto-image-base";;
Guido van Rossumac405f61994-09-12 10:56:06 +00002710 *) LDSHARED="ld";;
2711 esac
Guido van Rossumac405f61994-09-12 10:56:06 +00002712fi
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002713AC_MSG_RESULT($LDSHARED)
Tarek Ziadé03d788d2010-04-03 08:46:49 +00002714LDCXXSHARED=${LDCXXSHARED-$LDSHARED}
Neil Schemenauerb3531b82001-02-16 04:09:05 +00002715BLDSHARED=${BLDSHARED-$LDSHARED}
Guido van Rossumac405f61994-09-12 10:56:06 +00002716# CCSHARED are the C *flags* used to create objects to go into a shared
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00002717# library (module) -- this is only needed for a few systems
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002718AC_MSG_CHECKING(CCSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00002719if test -z "$CCSHARED"
2720then
Guido van Rossum6100aaf1997-04-29 21:48:51 +00002721 case $ac_sys_system/$ac_sys_release in
Neil Schemenauer66252162001-02-19 04:47:42 +00002722 SunOS*) if test "$GCC" = yes;
Guido van Rossumd8faa362007-04-27 19:54:29 +00002723 then CCSHARED="-fPIC";
2724 elif test `uname -p` = sparc;
2725 then CCSHARED="-xcode=pic32";
2726 else CCSHARED="-Kpic";
2727 fi;;
Guido van Rossumaf07a441995-02-13 19:45:27 +00002728 hp*|HP*) if test "$GCC" = yes;
Martin v. Löwis703ad702001-09-05 08:36:52 +00002729 then CCSHARED="-fPIC";
Guido van Rossumaf07a441995-02-13 19:45:27 +00002730 else CCSHARED="+z";
2731 fi;;
Xavier de Gaye2a352b62017-01-04 21:51:16 +01002732 Linux-android*) ;;
Martin v. Löwisa6e97582002-01-01 18:41:33 +00002733 Linux*|GNU*) CCSHARED="-fPIC";;
Martin v. Löwis86d66262006-02-17 08:40:11 +00002734 FreeBSD*|NetBSD*|OpenBSD*|DragonFly*) CCSHARED="-fPIC";;
Martin v. Löwis25ae43b2001-10-07 08:39:18 +00002735 OpenUNIX*|UnixWare*)
Martin v. Löwisbec19582001-03-21 15:57:54 +00002736 if test "$GCC" = "yes"
2737 then CCSHARED="-fPIC"
Martin v. Löwis130fb172001-07-19 11:00:41 +00002738 else CCSHARED="-KPIC"
Martin v. Löwisbec19582001-03-21 15:57:54 +00002739 fi;;
Martin v. Löwis21ee4092002-09-30 16:19:48 +00002740 SCO_SV*)
2741 if test "$GCC" = "yes"
2742 then CCSHARED="-fPIC"
2743 else CCSHARED="-Kpic -belf"
2744 fi;;
pxinwr32f5fdd2019-02-27 19:09:28 +08002745 VxWorks*)
2746 CCSHARED="-fpic -D__SO_PICABILINUX__ -ftls-model=global-dynamic"
Guido van Rossumac405f61994-09-12 10:56:06 +00002747 esac
Guido van Rossumac405f61994-09-12 10:56:06 +00002748fi
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002749AC_MSG_RESULT($CCSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00002750# LINKFORSHARED are the flags passed to the $(CC) command that links
Guido van Rossumb65a48e1995-06-14 18:21:23 +00002751# the python executable -- this is only needed for a few systems
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002752AC_MSG_CHECKING(LINKFORSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00002753if test -z "$LINKFORSHARED"
2754then
Guido van Rossum6100aaf1997-04-29 21:48:51 +00002755 case $ac_sys_system/$ac_sys_release in
Neil Schemenauerb3531b82001-02-16 04:09:05 +00002756 AIX*) LINKFORSHARED='-Wl,-bE:Modules/python.exp -lld';;
Guido van Rossum5dab3d81996-12-06 21:18:18 +00002757 hp*|HP*)
Martin v. Löwis1142de32002-03-29 16:28:31 +00002758 LINKFORSHARED="-Wl,-E -Wl,+s";;
2759# LINKFORSHARED="-Wl,-E -Wl,+s -Wl,+b\$(BINLIBDEST)/lib-dynload";;
Xavier de Gaye2a352b62017-01-04 21:51:16 +01002760 Linux-android*) LINKFORSHARED="-pie -Xlinker -export-dynamic";;
Martin v. Löwisa6e97582002-01-01 18:41:33 +00002761 Linux*|GNU*) LINKFORSHARED="-Xlinker -export-dynamic";;
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00002762 # -u libsys_s pulls in all symbols in libsys
Victor Stinner1b80b242016-04-12 22:34:58 +02002763 Darwin/*)
Benjamin Peterson9c80cac2009-05-23 16:34:23 +00002764 LINKFORSHARED="$extra_undefs -framework CoreFoundation"
Ned Deily5bbbc732019-07-02 03:12:18 -04002765
2766 # Issue #18075: the default maximum stack size (8MBytes) is too
2767 # small for the default recursion limit. Increase the stack size
2768 # to ensure that tests don't crash
Ronald Oussoren1a057ba2019-08-01 07:43:07 +02002769 # Note: This matches the value of THREAD_STACK_SIZE in
2770 # thread_pthread.h
Ned Deily5bbbc732019-07-02 03:12:18 -04002771 LINKFORSHARED="-Wl,-stack_size,1000000 $LINKFORSHARED"
2772
Jack Jansenb6e9cad2001-08-15 01:26:28 +00002773 if test "$enable_framework"
2774 then
Jack Jansenda49e192005-01-07 13:08:22 +00002775 LINKFORSHARED="$LINKFORSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansenb6e9cad2001-08-15 01:26:28 +00002776 fi
Raymond Hettingerec6eb362004-11-05 07:02:59 +00002777 LINKFORSHARED="$LINKFORSHARED";;
Martin v. Löwis25ae43b2001-10-07 08:39:18 +00002778 OpenUNIX*|UnixWare*) LINKFORSHARED="-Wl,-Bexport";;
Martin v. Löwis21ee4092002-09-30 16:19:48 +00002779 SCO_SV*) LINKFORSHARED="-Wl,-Bexport";;
Fred Drake02706f52000-09-25 15:08:46 +00002780 ReliantUNIX*) LINKFORSHARED="-W1 -Blargedynsym";;
Victor Stinner1b80b242016-04-12 22:34:58 +02002781 FreeBSD*|NetBSD*|OpenBSD*|DragonFly*)
Guido van Rossumdf693651999-01-07 21:50:41 +00002782 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
2783 then
2784 LINKFORSHARED="-Wl,--export-dynamic"
2785 fi;;
Guido van Rossum2b5ca001998-03-05 15:41:09 +00002786 SunOS/5*) case $CC in
2787 *gcc*)
Martin v. Löwisa4548572002-04-18 14:51:36 +00002788 if $CC -Xlinker --help 2>&1 | grep export-dynamic >/dev/null
Guido van Rossum8f4ceb11997-12-18 23:42:19 +00002789 then
2790 LINKFORSHARED="-Xlinker --export-dynamic"
Guido van Rossum2b5ca001998-03-05 15:41:09 +00002791 fi;;
2792 esac;;
Jason Tishler30765592003-09-04 11:04:06 +00002793 CYGWIN*)
2794 if test $enable_shared = "no"
2795 then
2796 LINKFORSHARED='-Wl,--out-implib=$(LDLIBRARY)'
2797 fi;;
Georg Brandlf78e02b2008-06-10 17:40:04 +00002798 QNX*)
2799 # -Wl,-E causes the symbols to be added to the dynamic
2800 # symbol table so that they can be found when a module
2801 # is loaded. -N 2048K causes the stack size to be set
2802 # to 2048 kilobytes so that the stack doesn't overflow
2803 # when running test_compile.py.
2804 LINKFORSHARED='-Wl,-E -N 2048K';;
pxinwr32f5fdd2019-02-27 19:09:28 +08002805 VxWorks*)
Victor Stinner21a74a92019-04-11 22:28:12 +02002806 LINKFORSHARED='--export-dynamic';;
Guido van Rossumac405f61994-09-12 10:56:06 +00002807 esac
Guido van Rossumac405f61994-09-12 10:56:06 +00002808fi
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002809AC_MSG_RESULT($LINKFORSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00002810
Georg Brandl93de2162008-07-16 02:21:06 +00002811
Neil Schemenauer61c51152001-01-26 16:18:16 +00002812AC_SUBST(CFLAGSFORSHARED)
2813AC_MSG_CHECKING(CFLAGSFORSHARED)
2814if test ! "$LIBRARY" = "$LDLIBRARY"
2815then
Neil Schemenauerd9cf41c2001-01-27 21:39:17 +00002816 case $ac_sys_system in
2817 CYGWIN*)
2818 # Cygwin needs CCSHARED when building extension DLLs
2819 # but not when building the interpreter DLL.
2820 CFLAGSFORSHARED='';;
2821 *)
2822 CFLAGSFORSHARED='$(CCSHARED)'
2823 esac
Neil Schemenauer61c51152001-01-26 16:18:16 +00002824fi
2825AC_MSG_RESULT($CFLAGSFORSHARED)
2826
Martin v. Löwisf90ae202002-06-11 06:22:31 +00002827# SHLIBS are libraries (except -lc and -lm) to link to the python shared
2828# library (with --enable-shared).
2829# For platforms on which shared libraries are not allowed to have unresolved
Martin v. Löwisd6359c52002-08-04 12:38:50 +00002830# symbols, this must be set to $(LIBS) (expanded by make). We do this even
2831# if it is not required, since it creates a dependency of the shared library
2832# to LIBS. This, in turn, means that applications linking the shared libpython
2833# don't need to link LIBS explicitly. The default should be only changed
2834# on systems where this approach causes problems.
Martin v. Löwisf90ae202002-06-11 06:22:31 +00002835AC_SUBST(SHLIBS)
2836AC_MSG_CHECKING(SHLIBS)
2837case "$ac_sys_system" in
Martin v. Löwisf90ae202002-06-11 06:22:31 +00002838 *)
Martin v. Löwisd6359c52002-08-04 12:38:50 +00002839 SHLIBS='$(LIBS)';;
Martin v. Löwisf90ae202002-06-11 06:22:31 +00002840esac
2841AC_MSG_RESULT($SHLIBS)
2842
2843
Guido van Rossum627b2d71993-12-24 10:39:16 +00002844# checks for libraries
Giampaolo Rodolàc9c2c8b2011-02-25 14:39:16 +00002845AC_CHECK_LIB(sendfile, sendfile)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002846AC_CHECK_LIB(dl, dlopen) # Dynamic linking for SunOS/Solaris and SYSV
2847AC_CHECK_LIB(dld, shl_load) # Dynamic linking for HP-UX
Martin v. Löwis519adae2003-09-20 10:47:47 +00002848
Michael Felt0d3ccb42017-12-30 22:39:20 +01002849# checks for uuid.h location
2850AC_CHECK_HEADERS([uuid/uuid.h uuid.h])
2851
Berker Peksag9a10ff42017-11-08 23:09:16 +03002852AC_MSG_CHECKING(for uuid_generate_time_safe)
2853AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <uuid/uuid.h>]], [[
2854#ifndef uuid_generate_time_safe
Berker Peksag0e163d22017-11-09 00:43:14 +03002855void *x = uuid_generate_time_safe
Berker Peksag9a10ff42017-11-08 23:09:16 +03002856#endif
2857]])],
2858 [AC_DEFINE(HAVE_UUID_GENERATE_TIME_SAFE, 1, Define if uuid_generate_time_safe() exists.)
2859 AC_MSG_RESULT(yes)],
2860 [AC_MSG_RESULT(no)]
2861)
2862
Michael Felt0d3ccb42017-12-30 22:39:20 +01002863# AIX provides support for RFC4122 (uuid) in libc.a starting with AIX 6.1 (anno 2007)
David Carlierb4ebaa72018-01-09 19:38:07 +00002864# FreeBSD and OpenBSD provides support as well
2865AC_MSG_CHECKING(for uuid_create)
Michael Felt0d3ccb42017-12-30 22:39:20 +01002866AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <uuid.h>]], [[
2867#ifndef uuid_create
2868void *x = uuid_create
2869#endif
2870]])],
David Carlierb4ebaa72018-01-09 19:38:07 +00002871 [AC_DEFINE(HAVE_UUID_CREATE, 1, Define if uuid_create() exists.)
Michael Felt0d3ccb42017-12-30 22:39:20 +01002872 AC_MSG_RESULT(yes)],
2873 [AC_MSG_RESULT(no)]
2874)
2875
Serhiy Storchaka17d88302018-05-25 01:45:09 +03002876# Little-endian FreeBSD, OpenBSD and NetBSD needs encoding into an octet
2877# stream in big-endian byte-order
2878AC_MSG_CHECKING(for uuid_enc_be)
2879AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <uuid.h>]], [[
2880#ifndef uuid_enc_be
Ned Deilyced0adb2018-06-09 18:19:57 -04002881void *x = uuid_enc_be
Serhiy Storchaka17d88302018-05-25 01:45:09 +03002882#endif
2883]])],
2884 [AC_DEFINE(HAVE_UUID_ENC_BE, 1, Define if uuid_enc_be() exists.)
2885 AC_MSG_RESULT(yes)],
2886 [AC_MSG_RESULT(no)]
2887)
2888
Serhiy Storchaka9e78dc22017-11-11 19:18:28 +02002889# 'Real Time' functions on Solaris
2890# posix4 on Solaris 2.6
2891# pthread (first!) on Linux
2892AC_SEARCH_LIBS(sem_init, pthread rt posix4)
Martin v. Löwis519adae2003-09-20 10:47:47 +00002893
Martin v. Löwis19d17342003-06-14 21:03:05 +00002894# check if we need libintl for locale functions
2895AC_CHECK_LIB(intl, textdomain,
Brett Cannonc6d936e2009-06-07 20:09:53 +00002896 [AC_DEFINE(WITH_LIBINTL, 1,
2897 [Define to 1 if libintl is needed for locale functions.])
2898 LIBS="-lintl $LIBS"])
Guido van Rossum0eefa3f1999-11-16 15:57:37 +00002899
2900# checks for system dependent C++ extensions support
2901case "$ac_sys_system" in
2902 AIX*) AC_MSG_CHECKING(for genuine AIX C++ extensions support)
Matthias Kloseb159a552010-04-25 21:00:44 +00002903 AC_LINK_IFELSE([
Georg Brandl59e87bd2011-02-15 19:48:59 +00002904 AC_LANG_PROGRAM([[#include <load.h>]],
Matthias Kloseb159a552010-04-25 21:00:44 +00002905 [[loadAndInit("", 0, "")]])
2906 ],[
2907 AC_DEFINE(AIX_GENUINE_CPLUSPLUS, 1,
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002908 [Define for AIX if your compiler is a genuine IBM xlC/xlC_r
2909 and you want support for AIX C++ shared extension modules.])
Matthias Kloseb159a552010-04-25 21:00:44 +00002910 AC_MSG_RESULT(yes)
2911 ],[
2912 AC_MSG_RESULT(no)
Michael Felt39afa2d2019-12-15 15:17:53 +01002913 ])
2914dnl The AIX_BUILDDATE is obtained from the kernel fileset - bos.mp64
2915# BUILD_GNU_TYPE + AIX_BUILDDATE are used to construct the platform_tag
2916# of the AIX system used to build/package Python executable. This tag serves
2917# as a baseline for bdist module packages
2918 AC_MSG_CHECKING(for the system builddate)
2919 AIX_BUILDDATE=$(lslpp -Lcq bos.mp64 | awk -F: '{ print $NF }')
2920 AC_DEFINE_UNQUOTED([AIX_BUILDDATE], [$AIX_BUILDDATE],
2921 [BUILD_GNU_TYPE + AIX_BUILDDATE are used to construct the PEP425 tag of the build system.])
2922 AC_MSG_RESULT($AIX_BUILDDATE)
2923 ;;
Guido van Rossum0eefa3f1999-11-16 15:57:37 +00002924 *) ;;
2925esac
2926
Christian Heimes985ecdc2013-11-20 11:46:18 +01002927# check for systems that require aligned memory access
2928AC_MSG_CHECKING(aligned memory access is required)
Benjamin Petersone4f961b2017-04-14 09:36:45 -07002929AC_CACHE_VAL(ac_cv_aligned_required,
2930[AC_RUN_IFELSE([AC_LANG_SOURCE([[
Christian Heimes985ecdc2013-11-20 11:46:18 +01002931int main()
2932{
2933 char s[16];
2934 int i, *p1, *p2;
2935 for (i=0; i < 16; i++)
2936 s[i] = i;
2937 p1 = (int*)(s+1);
2938 p2 = (int*)(s+2);
2939 if (*p1 == *p2)
2940 return 1;
2941 return 0;
Benjamin Petersone4f961b2017-04-14 09:36:45 -07002942}]])],
2943[ac_cv_aligned_required=no],
2944[ac_cv_aligned_required=yes],
2945[ac_cv_aligned_required=yes])
2946])
2947AC_MSG_RESULT($ac_cv_aligned_required)
2948if test "$ac_cv_aligned_required" = yes ; then
Christian Heimes985ecdc2013-11-20 11:46:18 +01002949 AC_DEFINE([HAVE_ALIGNED_REQUIRED], [1],
2950 [Define if aligned memory access is required])
2951fi
Christian Heimes985ecdc2013-11-20 11:46:18 +01002952
2953# str, bytes and memoryview hash algorithm
2954AH_TEMPLATE(Py_HASH_ALGORITHM,
2955 [Define hash algorithm for str, bytes and memoryview.
2956 SipHash24: 1, FNV: 2, externally defined: 0])
2957
2958AC_MSG_CHECKING(for --with-hash-algorithm)
2959dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
2960AC_ARG_WITH(hash_algorithm,
2961 AS_HELP_STRING([--with-hash-algorithm=@<:@fnv|siphash24@:>@],
Anthony Shaw2de064e2020-01-14 17:40:10 +11002962 [select hash algorithm for use in Python/pyhash.c (default is SipHash24)]),
Christian Heimes985ecdc2013-11-20 11:46:18 +01002963[
2964AC_MSG_RESULT($withval)
2965case "$withval" in
2966 siphash24)
2967 AC_DEFINE(Py_HASH_ALGORITHM, 1)
2968 ;;
2969 fnv)
2970 AC_DEFINE(Py_HASH_ALGORITHM, 2)
2971 ;;
2972 *)
2973 AC_MSG_ERROR([unknown hash algorithm '$withval'])
2974 ;;
2975esac
2976],
2977[AC_MSG_RESULT(default)])
2978
Paul Ganssle62972d92020-05-16 04:20:06 -04002979validate_tzpath() {
2980 # Checks that each element of hte path is an absolute path
2981 if test -z "$1"; then
2982 # Empty string is allowed: it indicates no system TZPATH
2983 return 0
2984 fi
2985
2986 # Bad paths are those that don't start with /
2987 dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
2988 if ( echo $1 | grep -qE '(^|:)(@<:@^/@:>@|$)' ); then
2989 AC_MSG_ERROR([--with-tzpath must contain only absolute paths, not $1])
2990 return 1;
2991 fi
2992}
2993
2994TZPATH="/usr/share/zoneinfo:/usr/lib/zoneinfo:/usr/share/lib/zoneinfo:/etc/zoneinfo"
2995AC_MSG_CHECKING(for --with-tzpath)
2996AC_ARG_WITH(tzpath,
2997 AS_HELP_STRING([--with-tzpath=<list of absolute paths separated by pathsep>]
2998 [Select the default time zone search path for zoneinfo.TZPATH]),
2999[
3000case "$withval" in
3001 yes)
3002 AC_MSG_ERROR([--with-tzpath requires a value])
3003 ;;
3004 *)
3005 validate_tzpath "$withval"
3006 TZPATH="$withval"
3007 AC_MSG_RESULT("$withval")
3008 ;;
3009esac
3010],
3011[validate_tzpath "$TZPATH"
3012 AC_MSG_RESULT("$TZPATH")])
3013AC_SUBST(TZPATH)
3014
Charles-François Natalid30b0222014-05-08 23:08:51 +01003015AC_MSG_CHECKING(for --with-address-sanitizer)
3016AC_ARG_WITH(address_sanitizer,
3017 AS_HELP_STRING([--with-address-sanitizer],
Anthony Shaw2de064e2020-01-14 17:40:10 +11003018 [enable AddressSanitizer memory error detector, 'asan' (default is no)]),
Charles-François Natalid30b0222014-05-08 23:08:51 +01003019[
3020AC_MSG_RESULT($withval)
3021BASECFLAGS="-fsanitize=address -fno-omit-frame-pointer $BASECFLAGS"
3022LDFLAGS="-fsanitize=address $LDFLAGS"
Gregory P. Smith1584a002018-11-12 12:07:14 -08003023# ASan works by controlling memory allocation, our own malloc interferes.
3024with_pymalloc="no"
3025],
3026[AC_MSG_RESULT(no)])
3027
3028AC_MSG_CHECKING(for --with-memory-sanitizer)
3029AC_ARG_WITH(memory_sanitizer,
3030 AS_HELP_STRING([--with-memory-sanitizer],
Anthony Shaw2de064e2020-01-14 17:40:10 +11003031 [enable MemorySanitizer allocation error detector, 'msan' (default is no)]),
Gregory P. Smith1584a002018-11-12 12:07:14 -08003032[
3033AC_MSG_RESULT($withval)
3034BASECFLAGS="-fsanitize=memory -fsanitize-memory-track-origins=2 -fno-omit-frame-pointer $BASECFLAGS"
3035LDFLAGS="-fsanitize=memory -fsanitize-memory-track-origins=2 $LDFLAGS"
3036# MSan works by controlling memory allocation, our own malloc interferes.
3037with_pymalloc="no"
3038],
3039[AC_MSG_RESULT(no)])
3040
3041AC_MSG_CHECKING(for --with-undefined-behavior-sanitizer)
3042AC_ARG_WITH(undefined_behavior_sanitizer,
3043 AS_HELP_STRING([--with-undefined-behavior-sanitizer],
Anthony Shaw2de064e2020-01-14 17:40:10 +11003044 [enable UndefinedBehaviorSanitizer undefined behaviour detector, 'ubsan' (default is no)]),
Gregory P. Smith1584a002018-11-12 12:07:14 -08003045[
3046AC_MSG_RESULT($withval)
3047BASECFLAGS="-fsanitize=undefined $BASECFLAGS"
3048LDFLAGS="-fsanitize=undefined $LDFLAGS"
Charles-François Natalid30b0222014-05-08 23:08:51 +01003049],
3050[AC_MSG_RESULT(no)])
3051
Guido van Rossum70c7f481998-03-26 18:44:10 +00003052# Most SVR4 platforms (e.g. Solaris) need -lsocket and -lnsl.
Guido van Rossumf618d2c1995-01-17 16:36:13 +00003053AC_CHECK_LIB(nsl, t_open, [LIBS="-lnsl $LIBS"]) # SVR4
Guido van Rossumf618d2c1995-01-17 16:36:13 +00003054AC_CHECK_LIB(socket, socket, [LIBS="-lsocket $LIBS"], [], $LIBS) # SVR4 sockets
Skip Montanarob9949db2004-01-17 04:04:13 +00003055
Guido van Rossumc5a39031996-07-31 17:35:03 +00003056AC_MSG_CHECKING(for --with-libs)
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00003057AC_ARG_WITH(libs,
Anthony Shaw2de064e2020-01-14 17:40:10 +11003058 AS_HELP_STRING([--with-libs='lib1 ...'], [link against additional libs (default is no)]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003059[
Guido van Rossumc5a39031996-07-31 17:35:03 +00003060AC_MSG_RESULT($withval)
3061LIBS="$withval $LIBS"
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003062],
3063[AC_MSG_RESULT(no)])
Guido van Rossum627b2d71993-12-24 10:39:16 +00003064
Benjamin Peterson0f3cde12014-12-15 00:00:23 -05003065PKG_PROG_PKG_CONFIG
Benjamin Peterson0f64b0b2010-03-09 21:49:52 +00003066
Benjamin Petersonb2d90462009-12-31 03:23:10 +00003067# Check for use of the system expat library
3068AC_MSG_CHECKING(for --with-system-expat)
3069AC_ARG_WITH(system_expat,
Anthony Shaw2de064e2020-01-14 17:40:10 +11003070 AS_HELP_STRING([--with-system-expat], [build pyexpat module using an installed expat library, see Doc/library/pyexpat.rst (default is no)]),
Benjamin Peterson79263252010-10-31 16:50:44 +00003071 [],
3072 [with_system_expat="no"])
Benjamin Petersonb2d90462009-12-31 03:23:10 +00003073
3074AC_MSG_RESULT($with_system_expat)
3075
Thomas Wouters49fd7fa2006-04-21 10:40:58 +00003076# Check for use of the system libffi library
3077AC_MSG_CHECKING(for --with-system-ffi)
3078AC_ARG_WITH(system_ffi,
Anthony Shaw2de064e2020-01-14 17:40:10 +11003079 AS_HELP_STRING([--with-system-ffi], [build _ctypes module using an installed ffi library, see Doc/library/ctypes.rst (default is system-dependent)]),,,)
Zachary Ware935043d2016-09-09 17:01:21 -07003080
Zachary Waref40d4dd2016-09-17 01:25:24 -05003081if test "$ac_sys_system" = "Darwin"
3082then
3083 case "$with_system_ffi" in
3084 "")
3085 with_system_ffi="no"
3086 ;;
3087 yes|no)
3088 ;;
3089 *)
3090 AC_MSG_ERROR([--with-system-ffi accepts no arguments])
3091 ;;
3092 esac
3093 AC_MSG_RESULT($with_system_ffi)
3094else
3095 AC_MSG_RESULT(yes)
3096 if test "$with_system_ffi" != ""
3097 then
3098 AC_MSG_WARN([--with(out)-system-ffi is ignored on this platform])
3099 fi
3100 with_system_ffi="yes"
3101fi
Thomas Wouters49fd7fa2006-04-21 10:40:58 +00003102
Benjamin Peterson0f64b0b2010-03-09 21:49:52 +00003103if test "$with_system_ffi" = "yes" && test -n "$PKG_CONFIG"; then
Benjamin Petersond78735d2010-01-01 16:04:23 +00003104 LIBFFI_INCLUDEDIR="`"$PKG_CONFIG" libffi --cflags-only-I 2>/dev/null | sed -e 's/^-I//;s/ *$//'`"
3105else
3106 LIBFFI_INCLUDEDIR=""
3107fi
3108AC_SUBST(LIBFFI_INCLUDEDIR)
3109
Stefan Krah60187b52012-03-23 19:06:27 +01003110# Check for use of the system libmpdec library
3111AC_MSG_CHECKING(for --with-system-libmpdec)
3112AC_ARG_WITH(system_libmpdec,
Anthony Shaw2de064e2020-01-14 17:40:10 +11003113 AS_HELP_STRING([--with-system-libmpdec], [build _decimal module using an installed libmpdec library, see Doc/library/decimal.rst (default is no)]),
Stefan Krah60187b52012-03-23 19:06:27 +01003114 [],
3115 [with_system_libmpdec="no"])
3116
3117AC_MSG_RESULT($with_system_libmpdec)
3118
Stefan Krah815280e2020-02-29 19:43:42 +01003119# Check whether _decimal should use a coroutine-local or thread-local context
3120AC_MSG_CHECKING(for --with-decimal-contextvar)
3121AC_ARG_WITH(decimal_contextvar,
3122 AS_HELP_STRING([--with-decimal-contextvar], [build _decimal module using a coroutine-local rather than a thread-local context (default is yes)]),
3123 [],
3124 [with_decimal_contextvar="yes"])
3125
3126if test "$with_decimal_contextvar" != "no"
3127then
3128 AC_DEFINE(WITH_DECIMAL_CONTEXTVAR, 1,
3129 [Define if you want build the _decimal module using a coroutine-local rather than a thread-local context])
3130fi
3131
3132AC_MSG_RESULT($with_decimal_contextvar)
3133
Benjamin Peterson076ed002010-10-31 17:11:02 +00003134# Check for support for loadable sqlite extensions
3135AC_MSG_CHECKING(for --enable-loadable-sqlite-extensions)
3136AC_ARG_ENABLE(loadable-sqlite-extensions,
Anthony Shaw2de064e2020-01-14 17:40:10 +11003137 AS_HELP_STRING([--enable-loadable-sqlite-extensions],
3138 [support loadable extensions in _sqlite module, see Doc/library/sqlite3.rst (default is no)]),
Benjamin Peterson076ed002010-10-31 17:11:02 +00003139 [],
3140 [enable_loadable_sqlite_extensions="no"])
3141
3142AC_MSG_RESULT($enable_loadable_sqlite_extensions)
3143
Ned Deilyd819b932013-09-06 01:07:05 -07003144# Check for --with-tcltk-includes=path and --with-tcltk-libs=path
3145AC_SUBST(TCLTK_INCLUDES)
3146AC_SUBST(TCLTK_LIBS)
3147AC_MSG_CHECKING(for --with-tcltk-includes)
3148AC_ARG_WITH(tcltk-includes,
3149 AS_HELP_STRING([--with-tcltk-includes='-I...'], [override search for Tcl and Tk include files]),
3150 [],
3151 [with_tcltk_includes="default"])
3152AC_MSG_RESULT($with_tcltk_includes)
3153AC_MSG_CHECKING(for --with-tcltk-libs)
3154AC_ARG_WITH(tcltk-libs,
3155 AS_HELP_STRING([--with-tcltk-libs='-L...'], [override search for Tcl and Tk libs]),
3156 [],
3157 [with_tcltk_libs="default"])
3158AC_MSG_RESULT($with_tcltk_libs)
3159if test "x$with_tcltk_includes" = xdefault || test "x$with_tcltk_libs" = xdefault
3160then
3161 if test "x$with_tcltk_includes" != "x$with_tcltk_libs"
3162 then
3163 AC_MSG_ERROR([use both --with-tcltk-includes='...' and --with-tcltk-libs='...' or neither])
3164 fi
3165 TCLTK_INCLUDES=""
3166 TCLTK_LIBS=""
3167else
3168 TCLTK_INCLUDES="$with_tcltk_includes"
3169 TCLTK_LIBS="$with_tcltk_libs"
3170fi
3171
Matthias Klose55708cc2009-04-30 08:06:49 +00003172# Check for --with-dbmliborder
3173AC_MSG_CHECKING(for --with-dbmliborder)
3174AC_ARG_WITH(dbmliborder,
Anthony Shaw2de064e2020-01-14 17:40:10 +11003175 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'.]),
Matthias Klose55708cc2009-04-30 08:06:49 +00003176[
3177if test x$with_dbmliborder = xyes
3178then
3179AC_MSG_ERROR([proper usage is --with-dbmliborder=db1:db2:...])
3180else
3181 for db in `echo $with_dbmliborder | sed 's/:/ /g'`; do
3182 if test x$db != xndbm && test x$db != xgdbm && test x$db != xbdb
3183 then
3184 AC_MSG_ERROR([proper usage is --with-dbmliborder=db1:db2:...])
3185 fi
3186 done
3187fi])
3188AC_MSG_RESULT($with_dbmliborder)
3189
Martin v. Löwis11437992002-04-12 09:54:03 +00003190# Templates for things AC_DEFINEd more than once.
3191# For a single AC_DEFINE, no template is needed.
Martin v. Löwis11437992002-04-12 09:54:03 +00003192AH_TEMPLATE(_REENTRANT,
3193 [Define to force use of thread-safe errno, h_errno, and other functions])
Martin v. Löwis11437992002-04-12 09:54:03 +00003194
Antoine Pitroua6a4dc82017-09-07 18:56:24 +02003195if test "$ac_cv_pthread_is_default" = yes
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00003196then
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00003197 # Defining _REENTRANT on system with POSIX threads should not hurt.
3198 AC_DEFINE(_REENTRANT)
3199 posix_threads=yes
Jesús Cea52d1b862019-09-28 03:44:32 +02003200 if test "$ac_sys_system" = "SunOS"; then
3201 CFLAGS="$CFLAGS -D_REENTRANT"
3202 fi
Martin v. Löwis130fb172001-07-19 11:00:41 +00003203elif test "$ac_cv_kpthread" = "yes"
3204then
3205 CC="$CC -Kpthread"
Martin v. Löwis519adae2003-09-20 10:47:47 +00003206 if test "$ac_cv_cxx_thread" = "yes"; then
3207 CXX="$CXX -Kpthread"
3208 fi
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00003209 posix_threads=yes
Martin v. Löwis5f433f02003-05-05 05:05:30 +00003210elif test "$ac_cv_kthread" = "yes"
3211then
3212 CC="$CC -Kthread"
Martin v. Löwis519adae2003-09-20 10:47:47 +00003213 if test "$ac_cv_cxx_thread" = "yes"; then
3214 CXX="$CXX -Kthread"
3215 fi
Martin v. Löwis5f433f02003-05-05 05:05:30 +00003216 posix_threads=yes
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00003217elif test "$ac_cv_pthread" = "yes"
3218then
3219 CC="$CC -pthread"
Martin v. Löwis519adae2003-09-20 10:47:47 +00003220 if test "$ac_cv_cxx_thread" = "yes"; then
3221 CXX="$CXX -pthread"
3222 fi
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00003223 posix_threads=yes
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00003224else
Martin v. Löwis130fb172001-07-19 11:00:41 +00003225 if test ! -z "$withval" -a -d "$withval"
3226 then LDFLAGS="$LDFLAGS -L$withval"
3227 fi
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00003228
3229 # According to the POSIX spec, a pthreads implementation must
Matthias Klosea2542be2004-08-16 11:35:51 +00003230 # define _POSIX_THREADS in unistd.h. Some apparently don't
3231 # (e.g. gnu pth with pthread emulation)
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00003232 AC_MSG_CHECKING(for _POSIX_THREADS in unistd.h)
3233 AC_EGREP_CPP(yes,
Neal Norwitz6eb37f02003-02-23 23:28:15 +00003234 [
3235#include <unistd.h>
3236#ifdef _POSIX_THREADS
3237yes
3238#endif
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00003239 ], unistd_defines_pthreads=yes, unistd_defines_pthreads=no)
3240 AC_MSG_RESULT($unistd_defines_pthreads)
3241
Martin v. Löwis130fb172001-07-19 11:00:41 +00003242 AC_DEFINE(_REENTRANT)
Martin v. Löwis8158b5a2001-10-08 13:17:28 +00003243 # Just looking for pthread_create in libpthread is not enough:
3244 # on HP/UX, pthread.h renames pthread_create to a different symbol name.
3245 # So we really have to include pthread.h, and then link.
3246 _libs=$LIBS
3247 LIBS="$LIBS -lpthread"
3248 AC_MSG_CHECKING([for pthread_create in -lpthread])
Stefan Krah7dba5942012-11-22 22:49:11 +01003249 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
3250#include <stdio.h>
3251#include <pthread.h>
Martin v. Löwis8158b5a2001-10-08 13:17:28 +00003252
Matthias Kloseb159a552010-04-25 21:00:44 +00003253void * start_routine (void *arg) { exit (0); }]], [[
3254pthread_create (NULL, NULL, start_routine, NULL)]])],[
Martin v. Löwis8158b5a2001-10-08 13:17:28 +00003255 AC_MSG_RESULT(yes)
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00003256 posix_threads=yes
Antoine Pitroua6a4dc82017-09-07 18:56:24 +02003257 ],[
Martin v. Löwis8158b5a2001-10-08 13:17:28 +00003258 LIBS=$_libs
Antoine Pitroua6a4dc82017-09-07 18:56:24 +02003259 AC_CHECK_FUNC(pthread_detach, [
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00003260 posix_threads=yes
Antoine Pitroua6a4dc82017-09-07 18:56:24 +02003261 ],[
3262 AC_CHECK_LIB(pthreads, pthread_create, [
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00003263 posix_threads=yes
Martin v. Löwis130fb172001-07-19 11:00:41 +00003264 LIBS="$LIBS -lpthreads"
Antoine Pitroua6a4dc82017-09-07 18:56:24 +02003265 ], [
3266 AC_CHECK_LIB(c_r, pthread_create, [
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00003267 posix_threads=yes
Martin v. Löwis130fb172001-07-19 11:00:41 +00003268 LIBS="$LIBS -lc_r"
Antoine Pitroua6a4dc82017-09-07 18:56:24 +02003269 ], [
3270 AC_CHECK_LIB(pthread, __pthread_create_system, [
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00003271 posix_threads=yes
Martin v. Löwis130fb172001-07-19 11:00:41 +00003272 LIBS="$LIBS -lpthread"
Antoine Pitroua6a4dc82017-09-07 18:56:24 +02003273 ], [
3274 AC_CHECK_LIB(cma, pthread_create, [
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00003275 posix_threads=yes
Martin v. Löwis130fb172001-07-19 11:00:41 +00003276 LIBS="$LIBS -lcma"
Antoine Pitroua6a4dc82017-09-07 18:56:24 +02003277 ],[
3278 AC_MSG_ERROR([could not find pthreads on your system])
3279 ])
Antoine Pitrou37009202011-07-08 23:47:50 +02003280 ])])])])])
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00003281
Antoine Pitroua6a4dc82017-09-07 18:56:24 +02003282 AC_CHECK_LIB(mpc, usconfig, [
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00003283 LIBS="$LIBS -lmpc"
Antoine Pitroua6a4dc82017-09-07 18:56:24 +02003284 ])
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00003285
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00003286fi
3287
3288if test "$posix_threads" = "yes"; then
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00003289 if test "$unistd_defines_pthreads" = "no"; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003290 AC_DEFINE(_POSIX_THREADS, 1,
Victor Stinner1b80b242016-04-12 22:34:58 +02003291 [Define if you have POSIX threads,
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003292 and your system does not define that.])
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00003293 fi
3294
Martin v. Löwisdfc33fd2003-01-21 10:14:41 +00003295 # Bug 662787: Using semaphores causes unexplicable hangs on Solaris 8.
3296 case $ac_sys_system/$ac_sys_release in
Charles-François Natali996f6062011-07-21 19:45:31 +02003297 SunOS/5.6) AC_DEFINE(HAVE_PTHREAD_DESTRUCTOR, 1,
Matthias Klosec80c93f2010-04-24 17:04:35 +00003298 [Defined for Solaris 2.6 bug in pthread header.])
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00003299 ;;
Martin v. Löwisdfc33fd2003-01-21 10:14:41 +00003300 SunOS/5.8) AC_DEFINE(HAVE_BROKEN_POSIX_SEMAPHORES, 1,
Matthias Klosec80c93f2010-04-24 17:04:35 +00003301 [Define if the Posix semaphores do not work on your system])
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00003302 ;;
Charles-François Natali996f6062011-07-21 19:45:31 +02003303 AIX/*) AC_DEFINE(HAVE_BROKEN_POSIX_SEMAPHORES, 1,
Matthias Klosec80c93f2010-04-24 17:04:35 +00003304 [Define if the Posix semaphores do not work on your system])
Christian Heimes7b3ce6a2008-01-31 14:31:45 +00003305 ;;
Martin v. Löwisdfc33fd2003-01-21 10:14:41 +00003306 esac
3307
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00003308 AC_MSG_CHECKING(if PTHREAD_SCOPE_SYSTEM is supported)
3309 AC_CACHE_VAL(ac_cv_pthread_system_supported,
Stefan Krah7dba5942012-11-22 22:49:11 +01003310 [AC_RUN_IFELSE([AC_LANG_SOURCE([[
3311 #include <stdio.h>
3312 #include <pthread.h>
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00003313 void *foo(void *parm) {
3314 return NULL;
3315 }
3316 main() {
3317 pthread_attr_t attr;
Martin v. Löwisa82d3472002-02-24 16:05:05 +00003318 pthread_t id;
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00003319 if (pthread_attr_init(&attr)) exit(-1);
3320 if (pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM)) exit(-1);
Martin v. Löwisa82d3472002-02-24 16:05:05 +00003321 if (pthread_create(&id, &attr, foo, NULL)) exit(-1);
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00003322 exit(0);
Matthias Kloseb159a552010-04-25 21:00:44 +00003323 }]])],
3324 [ac_cv_pthread_system_supported=yes],
3325 [ac_cv_pthread_system_supported=no],
3326 [ac_cv_pthread_system_supported=no])
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00003327 ])
3328 AC_MSG_RESULT($ac_cv_pthread_system_supported)
3329 if test "$ac_cv_pthread_system_supported" = "yes"; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003330 AC_DEFINE(PTHREAD_SYSTEM_SCHED_SUPPORTED, 1, [Defined if PTHREAD_SCOPE_SYSTEM supported.])
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00003331 fi
Jason Tishlerfac083d2003-07-22 15:20:49 +00003332 AC_CHECK_FUNCS(pthread_sigmask,
3333 [case $ac_sys_system in
3334 CYGWIN*)
3335 AC_DEFINE(HAVE_BROKEN_PTHREAD_SIGMASK, 1,
3336 [Define if pthread_sigmask() does not work on your system.])
3337 ;;
3338 esac])
pdoxe14679c2017-10-05 00:01:56 -07003339 AC_CHECK_FUNCS(pthread_getcpuclockid)
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00003340fi
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003341
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00003342
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00003343# Check for enable-ipv6
Martin v. Löwis11437992002-04-12 09:54:03 +00003344AH_TEMPLATE(ENABLE_IPV6, [Define if --enable-ipv6 is specified])
Martin v. Löwisa5f8bb52001-09-05 08:22:34 +00003345AC_MSG_CHECKING([if --enable-ipv6 is specified])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00003346AC_ARG_ENABLE(ipv6,
Anthony Shaw2de064e2020-01-14 17:40:10 +11003347 AS_HELP_STRING([--enable-ipv6],
3348 [enable ipv6 (with ipv4) support, see Doc/library/socket.rst (default is yes if supported)]),
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00003349[ case "$enableval" in
3350 no)
3351 AC_MSG_RESULT(no)
3352 ipv6=no
3353 ;;
3354 *) AC_MSG_RESULT(yes)
3355 AC_DEFINE(ENABLE_IPV6)
3356 ipv6=yes
3357 ;;
3358 esac ],
3359
Martin v. Löwisa5f8bb52001-09-05 08:22:34 +00003360[
3361dnl the check does not work on cross compilation case...
Charles-François Natalif6fd7942013-01-08 19:49:42 +01003362 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ /* AF_INET6 available check */
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00003363#include <sys/types.h>
Charles-François Natalif6fd7942013-01-08 19:49:42 +01003364#include <sys/socket.h>]],
3365[[int domain = AF_INET6;]])],[
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00003366 AC_MSG_RESULT(yes)
Matthias Kloseb159a552010-04-25 21:00:44 +00003367 ipv6=yes
3368],[
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00003369 AC_MSG_RESULT(no)
3370 ipv6=no
Matthias Kloseb159a552010-04-25 21:00:44 +00003371])
Martin v. Löwisa5f8bb52001-09-05 08:22:34 +00003372
3373if test "$ipv6" = "yes"; then
3374 AC_MSG_CHECKING(if RFC2553 API is available)
Matthias Kloseb159a552010-04-25 21:00:44 +00003375 AC_COMPILE_IFELSE([
3376 AC_LANG_PROGRAM([[#include <sys/types.h>
3377#include <netinet/in.h>]],
3378 [[struct sockaddr_in6 x;
3379 x.sin6_scope_id;]])
3380 ],[
3381 AC_MSG_RESULT(yes)
3382 ipv6=yes
3383 ],[
3384 AC_MSG_RESULT(no, IPv6 disabled)
3385 ipv6=no
3386 ])
Martin v. Löwisa5f8bb52001-09-05 08:22:34 +00003387fi
3388
3389if test "$ipv6" = "yes"; then
3390 AC_DEFINE(ENABLE_IPV6)
3391fi
3392])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00003393
3394ipv6type=unknown
3395ipv6lib=none
3396ipv6trylibc=no
3397
3398if test "$ipv6" = "yes"; then
3399 AC_MSG_CHECKING([ipv6 stack type])
Guido van Rossumb8552162001-09-05 14:58:11 +00003400 for i in inria kame linux-glibc linux-inet6 solaris toshiba v6d zeta;
3401 do
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00003402 case $i in
3403 inria)
3404 dnl http://www.kame.net/
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00003405 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00003406#include <netinet/in.h>
3407#ifdef IPV6_INRIA_VERSION
3408yes
3409#endif],
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00003410 [ipv6type=$i])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00003411 ;;
3412 kame)
3413 dnl http://www.kame.net/
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00003414 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00003415#include <netinet/in.h>
3416#ifdef __KAME__
3417yes
3418#endif],
3419 [ipv6type=$i;
3420 ipv6lib=inet6
3421 ipv6libdir=/usr/local/v6/lib
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00003422 ipv6trylibc=yes])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00003423 ;;
3424 linux-glibc)
3425 dnl http://www.v6.linux.or.jp/
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00003426 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00003427#include <features.h>
3428#if defined(__GLIBC__) && ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1) || (__GLIBC__ > 2))
3429yes
3430#endif],
3431 [ipv6type=$i;
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00003432 ipv6trylibc=yes])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00003433 ;;
3434 linux-inet6)
3435 dnl http://www.v6.linux.or.jp/
3436 if test -d /usr/inet6; then
3437 ipv6type=$i
3438 ipv6lib=inet6
3439 ipv6libdir=/usr/inet6/lib
Skip Montanarodecc6a42003-01-01 20:07:49 +00003440 BASECFLAGS="-I/usr/inet6/include $BASECFLAGS"
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00003441 fi
3442 ;;
3443 solaris)
3444 if test -f /etc/netconfig; then
Antoine Pitrouf3fcd9f2011-01-03 18:53:50 +00003445 if $GREP -q tcp6 /etc/netconfig; then
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00003446 ipv6type=$i
3447 ipv6trylibc=yes
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00003448 fi
3449 fi
3450 ;;
3451 toshiba)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00003452 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00003453#include <sys/param.h>
3454#ifdef _TOSHIBA_INET6
3455yes
3456#endif],
3457 [ipv6type=$i;
3458 ipv6lib=inet6;
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00003459 ipv6libdir=/usr/local/v6/lib])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00003460 ;;
3461 v6d)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00003462 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00003463#include </usr/local/v6/include/sys/v6config.h>
3464#ifdef __V6D__
3465yes
3466#endif],
3467 [ipv6type=$i;
3468 ipv6lib=v6;
3469 ipv6libdir=/usr/local/v6/lib;
Skip Montanarodecc6a42003-01-01 20:07:49 +00003470 BASECFLAGS="-I/usr/local/v6/include $BASECFLAGS"])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00003471 ;;
3472 zeta)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00003473 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00003474#include <sys/param.h>
3475#ifdef _ZETA_MINAMI_INET6
3476yes
3477#endif],
3478 [ipv6type=$i;
3479 ipv6lib=inet6;
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00003480 ipv6libdir=/usr/local/v6/lib])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00003481 ;;
3482 esac
3483 if test "$ipv6type" != "unknown"; then
3484 break
3485 fi
3486 done
3487 AC_MSG_RESULT($ipv6type)
3488fi
3489
3490if test "$ipv6" = "yes" -a "$ipv6lib" != "none"; then
3491 if test -d $ipv6libdir -a -f $ipv6libdir/lib$ipv6lib.a; then
3492 LIBS="-L$ipv6libdir -l$ipv6lib $LIBS"
3493 echo "using lib$ipv6lib"
3494 else
3495 if test $ipv6trylibc = "yes"; then
3496 echo "using libc"
3497 else
3498 echo 'Fatal: no $ipv6lib library found. cannot continue.'
3499 echo "You need to fetch lib$ipv6lib.a from appropriate"
3500 echo 'ipv6 kit and compile beforehand.'
3501 exit 1
3502 fi
3503 fi
3504fi
3505
Larry Hastingsa6cc5512015-04-13 17:48:40 -04003506AC_MSG_CHECKING(for CAN_RAW_FD_FRAMES)
3507AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ /* CAN_RAW_FD_FRAMES available check */
3508#include <linux/can/raw.h>]],
3509[[int can_raw_fd_frames = CAN_RAW_FD_FRAMES;]])],[
3510 AC_DEFINE(HAVE_LINUX_CAN_RAW_FD_FRAMES, 1, [Define if compiling using Linux 3.6 or later.])
3511 AC_MSG_RESULT(yes)
3512],[
3513 AC_MSG_RESULT(no)
3514])
3515
Zackery Spytz97e0de02020-04-09 06:03:49 -06003516AC_MSG_CHECKING(for CAN_RAW_JOIN_FILTERS)
3517AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3518#include <linux/can/raw.h>]],
3519[[int can_raw_join_filters = CAN_RAW_JOIN_FILTERS;]])],[
3520 AC_DEFINE(HAVE_LINUX_CAN_RAW_JOIN_FILTERS, 1, [Define if compiling using Linux 4.1 or later.])
3521 AC_MSG_RESULT(yes)
3522],[
3523 AC_MSG_RESULT(no)
3524])
3525
Martin v. Löwisa3fb4f72002-06-09 13:33:54 +00003526# Check for --with-doc-strings
3527AC_MSG_CHECKING(for --with-doc-strings)
3528AC_ARG_WITH(doc-strings,
Anthony Shaw2de064e2020-01-14 17:40:10 +11003529 AS_HELP_STRING([--with-doc-strings], [enable documentation strings (default is yes)]))
Martin v. Löwisa3fb4f72002-06-09 13:33:54 +00003530
3531if test -z "$with_doc_strings"
3532then with_doc_strings="yes"
3533fi
3534if test "$with_doc_strings" != "no"
3535then
3536 AC_DEFINE(WITH_DOC_STRINGS, 1,
3537 [Define if you want documentation strings in extension modules])
3538fi
3539AC_MSG_RESULT($with_doc_strings)
3540
Martin v. Löwisf30d60e2004-06-08 08:17:44 +00003541# Check for Python-specific malloc support
Neil Schemenauera35c6882001-02-27 04:45:05 +00003542AC_MSG_CHECKING(for --with-pymalloc)
3543AC_ARG_WITH(pymalloc,
Anthony Shaw2de064e2020-01-14 17:40:10 +11003544 AS_HELP_STRING([--with-pymalloc], [enable specialized mallocs (default is yes)]))
Neil Schemenauer16c22972002-03-22 15:34:49 +00003545
3546if test -z "$with_pymalloc"
Barry Warsaw35f3a2c2010-09-03 18:30:30 +00003547then
3548 with_pymalloc="yes"
Neil Schemenauer16c22972002-03-22 15:34:49 +00003549fi
3550if test "$with_pymalloc" != "no"
3551then
Victor Stinner1b80b242016-04-12 22:34:58 +02003552 AC_DEFINE(WITH_PYMALLOC, 1,
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003553 [Define if you want to compile in Python-specific mallocs])
Neil Schemenauer16c22972002-03-22 15:34:49 +00003554fi
3555AC_MSG_RESULT($with_pymalloc)
Neil Schemenauera35c6882001-02-27 04:45:05 +00003556
Nick Coghlan6ea41862017-06-11 13:16:15 +10003557# Check for --with-c-locale-coercion
3558AC_MSG_CHECKING(for --with-c-locale-coercion)
3559AC_ARG_WITH(c-locale-coercion,
Anthony Shaw2de064e2020-01-14 17:40:10 +11003560 AS_HELP_STRING([--with-c-locale-coercion],
3561 [enable C locale coercion to a UTF-8 based locale (default is yes)]))
Nick Coghlan6ea41862017-06-11 13:16:15 +10003562
3563if test -z "$with_c_locale_coercion"
3564then
3565 with_c_locale_coercion="yes"
3566fi
3567if test "$with_c_locale_coercion" != "no"
3568then
3569 AC_DEFINE(PY_COERCE_C_LOCALE, 1,
3570 [Define if you want to coerce the C locale to a UTF-8 based locale])
3571fi
3572AC_MSG_RESULT($with_c_locale_coercion)
3573
Benjamin Peterson05159c42009-12-03 03:01:27 +00003574# Check for Valgrind support
3575AC_MSG_CHECKING([for --with-valgrind])
3576AC_ARG_WITH([valgrind],
Anthony Shaw2de064e2020-01-14 17:40:10 +11003577 AS_HELP_STRING([--with-valgrind], [enable Valgrind support (default is no)]),,
Benjamin Peterson05159c42009-12-03 03:01:27 +00003578 with_valgrind=no)
3579AC_MSG_RESULT([$with_valgrind])
3580if test "$with_valgrind" != no; then
3581 AC_CHECK_HEADER([valgrind/valgrind.h],
3582 [AC_DEFINE([WITH_VALGRIND], 1, [Define if you want pymalloc to be disabled when running under valgrind])],
3583 [AC_MSG_ERROR([Valgrind support requested but headers not available])]
3584 )
Jeffrey Yasskin39370832010-05-03 19:29:34 +00003585 OPT="-DDYNAMIC_ANNOTATIONS_ENABLED=1 $OPT"
Benjamin Peterson05159c42009-12-03 03:01:27 +00003586fi
3587
Łukasz Langaa785c872016-09-09 17:37:37 -07003588# Check for DTrace support
3589AC_MSG_CHECKING(for --with-dtrace)
3590AC_ARG_WITH(dtrace,
Anthony Shaw2de064e2020-01-14 17:40:10 +11003591 AS_HELP_STRING([--with-dtrace],[enable DTrace support (default is no)]),,
Łukasz Langaa785c872016-09-09 17:37:37 -07003592 with_dtrace=no)
3593AC_MSG_RESULT($with_dtrace)
3594
3595AC_SUBST(DTRACE)
3596AC_SUBST(DFLAGS)
3597AC_SUBST(DTRACE_HEADERS)
3598AC_SUBST(DTRACE_OBJS)
3599DTRACE=
Łukasz Langaa785c872016-09-09 17:37:37 -07003600DTRACE_HEADERS=
3601DTRACE_OBJS=
3602
3603if test "$with_dtrace" = "yes"
3604then
3605 AC_PATH_PROG(DTRACE, [dtrace], [not found])
3606 if test "$DTRACE" = "not found"; then
3607 AC_MSG_ERROR([dtrace command not found on \$PATH])
3608 fi
3609 AC_DEFINE(WITH_DTRACE, 1, [Define if you want to compile in DTrace support])
3610 DTRACE_HEADERS="Include/pydtrace_probes.h"
3611
3612 # On OS X, DTrace providers do not need to be explicitly compiled and
3613 # linked into the binary. Correspondingly, dtrace(1) is missing the ELF
3614 # generation flag '-G'. We check for presence of this flag, rather than
3615 # hardcoding support by OS, in the interest of robustness.
3616 AC_CACHE_CHECK([whether DTrace probes require linking],
3617 [ac_cv_dtrace_link], [dnl
3618 ac_cv_dtrace_link=no
Jakub Kulík5c8f5372019-01-24 18:29:48 +01003619 echo 'BEGIN{}' > conftest.d
Petr Viktorin3c97e1e2020-03-11 14:27:42 +01003620 "$DTRACE" $DFLAGS -G -s conftest.d -o conftest.o > /dev/null 2>&1 && \
Łukasz Langaa785c872016-09-09 17:37:37 -07003621 ac_cv_dtrace_link=yes
3622 ])
3623 if test "$ac_cv_dtrace_link" = "yes"; then
3624 DTRACE_OBJS="Python/pydtrace.o"
3625 fi
3626fi
3627
Guido van Rossum68242b51996-05-28 22:53:03 +00003628# -I${DLINCLDIR} is added to the compile rule for importdl.o
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003629AC_SUBST(DLINCLDIR)
Guido van Rossum98935bf2001-09-05 19:13:16 +00003630DLINCLDIR=.
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003631
Guido van Rossume97ee181999-12-20 21:27:22 +00003632# the dlopen() function means we might want to use dynload_shlib.o. some
3633# platforms, such as AIX, have dlopen(), but don't want to use it.
Thomas Wouters3a584202000-08-05 23:28:51 +00003634AC_CHECK_FUNCS(dlopen)
Guido van Rossume97ee181999-12-20 21:27:22 +00003635
3636# DYNLOADFILE specifies which dynload_*.o file we will use for dynamic
3637# loading of modules.
3638AC_SUBST(DYNLOADFILE)
3639AC_MSG_CHECKING(DYNLOADFILE)
3640if test -z "$DYNLOADFILE"
3641then
3642 case $ac_sys_system/$ac_sys_release in
Guido van Rossume97ee181999-12-20 21:27:22 +00003643 hp*|HP*) DYNLOADFILE="dynload_hpux.o";;
Guido van Rossume97ee181999-12-20 21:27:22 +00003644 *)
3645 # use dynload_shlib.c and dlopen() if we have it; otherwise stub
3646 # out any dynamic loading
3647 if test "$ac_cv_func_dlopen" = yes
3648 then DYNLOADFILE="dynload_shlib.o"
3649 else DYNLOADFILE="dynload_stub.o"
3650 fi
3651 ;;
3652 esac
3653fi
3654AC_MSG_RESULT($DYNLOADFILE)
3655if test "$DYNLOADFILE" != "dynload_stub.o"
3656then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003657 AC_DEFINE(HAVE_DYNAMIC_LOADING, 1,
3658 [Defined when any dynamic module loading is enabled.])
Guido van Rossume97ee181999-12-20 21:27:22 +00003659fi
3660
Jack Jansenc49e5b72001-06-19 15:00:23 +00003661# MACHDEP_OBJS can be set to platform-specific object files needed by Python
3662
3663AC_SUBST(MACHDEP_OBJS)
3664AC_MSG_CHECKING(MACHDEP_OBJS)
3665if test -z "$MACHDEP_OBJS"
3666then
Jack Jansenb6e9cad2001-08-15 01:26:28 +00003667 MACHDEP_OBJS=$extra_machdep_objs
3668else
3669 MACHDEP_OBJS="$MACHDEP_OBJS $extra_machdep_objs"
Jack Jansenc49e5b72001-06-19 15:00:23 +00003670fi
doko@ubuntu.com9c7817e2012-06-30 17:05:13 +02003671if test -z "$MACHDEP_OBJS"; then
3672 AC_MSG_RESULT([none])
3673else
3674 AC_MSG_RESULT([$MACHDEP_OBJS])
3675fi
Jack Jansenc49e5b72001-06-19 15:00:23 +00003676
Guido van Rossum627b2d71993-12-24 10:39:16 +00003677# checks for library functions
Antoine Pitroub1c54962010-10-14 15:05:38 +00003678AC_CHECK_FUNCS(alarm accept4 setitimer getitimer bind_textdomain_codeset chown \
Kyle Evans1800c602020-10-11 15:18:53 -05003679 clock confstr close_range copy_file_range ctermid dup3 execv explicit_bzero \
3680 explicit_memset faccessat fchmod fchmodat fchown fchownat \
Jakub Kulíke20134f2019-09-11 17:11:57 +02003681 fdwalk fexecve fdopendir fork fpathconf fstatat ftime ftruncate futimesat \
Victor Stinner4d6a3d62014-12-21 01:16:38 +01003682 futimens futimes gai_strerror getentropy \
William Grzybowski23e65b22018-09-07 09:06:15 -03003683 getgrgid_r getgrnam_r \
Ross Lagerwallb0ae53d2011-06-10 07:30:30 +02003684 getgrouplist getgroups getlogin getloadavg getpeername getpgid getpid \
William Grzybowski23e65b22018-09-07 09:06:15 -03003685 getpriority getresuid getresgid getpwent getpwnam_r getpwuid_r getspnam getspent getsid getwd \
xdegaye5ad7ef82017-11-23 11:13:22 +01003686 if_nameindex \
Benjamin Petersonbed04b62019-09-09 05:13:00 -07003687 initgroups kill killpg lchown lockf linkat lstat lutimes mmap \
David Carlierd8b75512019-05-29 11:58:11 +01003688 memrchr mbrtowc mkdirat mkfifo \
Zackery Spytz02db6962019-05-27 10:48:17 -06003689 madvise mkfifoat mknod mknodat mktime mremap nice openat pathconf pause pipe2 plock poll \
Joannah Nanjekye92b83222019-01-16 16:29:26 +03003690 posix_fallocate posix_fadvise posix_spawn posix_spawnp pread preadv preadv2 \
Victor Stinnerb8d12622020-01-24 14:05:48 +01003691 pthread_condattr_setclock pthread_init pthread_kill pwrite pwritev pwritev2 \
Inada Naoki001fee12019-02-20 10:00:09 +09003692 readlink readlinkat readv realpath renameat \
Victor Stinnerb8d12622020-01-24 14:05:48 +01003693 sem_open sem_timedwait sem_getvalue sem_unlink sendfile setegid seteuid \
Antoine Pitrou061cfb52011-02-28 22:25:22 +00003694 setgid sethostname \
Giampaolo Rodolà18e8bcb2011-02-25 20:57:54 +00003695 setlocale setregid setreuid setresuid setresgid setsid setpgid setpgrp setpriority setuid setvbuf \
Charles-François Nataliea0d5fc2011-09-06 19:03:35 +02003696 sched_get_priority_max sched_setaffinity sched_setscheduler sched_setparam \
3697 sched_rr_get_interval \
Antoine Pitrou9d3627e2018-05-04 13:00:50 +02003698 sigaction sigaltstack sigfillset siginterrupt sigpending sigrelse \
Michael Osipov48ce4892018-08-23 15:27:19 +02003699 sigtimedwait sigwait sigwaitinfo snprintf strftime strlcpy strsignal symlinkat sync \
Michael W. Hudson34f20ea2002-05-27 15:08:24 +00003700 sysconf tcgetpgrp tcsetpgrp tempnam timegm times tmpfile tmpnam tmpnam_r \
Alexey Izbyshev976da902020-10-24 03:47:01 +03003701 truncate uname unlinkat utimensat utimes vfork waitid waitpid wait3 wait4 \
pxinwrf2d7ac72019-05-21 18:46:37 +08003702 wcscoll wcsftime wcsxfrm wmemcmp writev _getpty rtpSpawn)
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00003703
Benjamin Peterson40caa052018-09-12 15:52:40 -07003704# Force lchmod off for Linux. Linux disallows changing the mode of symbolic
3705# links. Some libc implementations have a stub lchmod implementation that always
3706# returns an error.
3707if test "$MACHDEP" != linux; then
Benjamin Petersoned709d52018-09-12 17:22:11 -07003708 AC_CHECK_FUNCS(lchmod)
Benjamin Peterson40caa052018-09-12 15:52:40 -07003709fi
3710
Gregory P. Smithdf300d52012-01-21 18:20:15 -08003711AC_CHECK_DECL(dirfd,
3712 AC_DEFINE(HAVE_DIRFD, 1,
3713 Define if you have the 'dirfd' function or macro.), ,
3714 [#include <sys/types.h>
3715 #include <dirent.h>])
3716
Martin v. Löwisc8ad7cc2002-11-11 13:23:45 +00003717# For some functions, having a definition is not sufficient, since
3718# we want to take their address.
3719AC_MSG_CHECKING(for chroot)
Matthias Kloseb159a552010-04-25 21:00:44 +00003720AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[void *x=chroot]])],
3721 [AC_DEFINE(HAVE_CHROOT, 1, Define if you have the 'chroot' function.)
3722 AC_MSG_RESULT(yes)],
3723 [AC_MSG_RESULT(no)
3724])
Martin v. Löwisc8ad7cc2002-11-11 13:23:45 +00003725AC_MSG_CHECKING(for link)
Matthias Kloseb159a552010-04-25 21:00:44 +00003726AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[void *x=link]])],
3727 [AC_DEFINE(HAVE_LINK, 1, Define if you have the 'link' function.)
3728 AC_MSG_RESULT(yes)],
3729 [AC_MSG_RESULT(no)
3730])
Martin v. Löwisc8ad7cc2002-11-11 13:23:45 +00003731AC_MSG_CHECKING(for symlink)
Matthias Kloseb159a552010-04-25 21:00:44 +00003732AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[void *x=symlink]])],
3733 [AC_DEFINE(HAVE_SYMLINK, 1, Define if you have the 'symlink' function.)
3734 AC_MSG_RESULT(yes)],
3735 [AC_MSG_RESULT(no)
3736])
Martin v. Löwisa64988c2003-09-20 15:30:20 +00003737AC_MSG_CHECKING(for fchdir)
Matthias Kloseb159a552010-04-25 21:00:44 +00003738AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[void *x=fchdir]])],
3739 [AC_DEFINE(HAVE_FCHDIR, 1, Define if you have the 'fchdir' function.)
3740 AC_MSG_RESULT(yes)],
3741 [AC_MSG_RESULT(no)
3742])
Martin v. Löwisa64988c2003-09-20 15:30:20 +00003743AC_MSG_CHECKING(for fsync)
Matthias Kloseb159a552010-04-25 21:00:44 +00003744AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[void *x=fsync]])],
3745 [AC_DEFINE(HAVE_FSYNC, 1, Define if you have the 'fsync' function.)
3746 AC_MSG_RESULT(yes)],
3747 [AC_MSG_RESULT(no)
3748])
Martin v. Löwisa64988c2003-09-20 15:30:20 +00003749AC_MSG_CHECKING(for fdatasync)
Matthias Kloseb159a552010-04-25 21:00:44 +00003750AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[void *x=fdatasync]])],
3751 [AC_DEFINE(HAVE_FDATASYNC, 1, Define if you have the 'fdatasync' function.)
3752 AC_MSG_RESULT(yes)],
3753 [AC_MSG_RESULT(no)
3754])
Christian Heimes4fbc72b2008-03-22 00:47:35 +00003755AC_MSG_CHECKING(for epoll)
Matthias Kloseb159a552010-04-25 21:00:44 +00003756AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/epoll.h>]], [[void *x=epoll_create]])],
3757 [AC_DEFINE(HAVE_EPOLL, 1, Define if you have the 'epoll' functions.)
3758 AC_MSG_RESULT(yes)],
3759 [AC_MSG_RESULT(no)
3760])
Benjamin Peterson95c16622011-12-27 15:36:32 -06003761AC_MSG_CHECKING(for epoll_create1)
3762AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/epoll.h>]], [[void *x=epoll_create1]])],
3763 [AC_DEFINE(HAVE_EPOLL_CREATE1, 1, Define if you have the 'epoll_create1' function.)
3764 AC_MSG_RESULT(yes)],
3765 [AC_MSG_RESULT(no)
3766])
Christian Heimes4fbc72b2008-03-22 00:47:35 +00003767AC_MSG_CHECKING(for kqueue)
Matthias Kloseb159a552010-04-25 21:00:44 +00003768AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Christian Heimes4fbc72b2008-03-22 00:47:35 +00003769#include <sys/types.h>
3770#include <sys/event.h>
Matthias Kloseb159a552010-04-25 21:00:44 +00003771 ]], [[int x=kqueue()]])],
3772 [AC_DEFINE(HAVE_KQUEUE, 1, Define if you have the 'kqueue' functions.)
3773 AC_MSG_RESULT(yes)],
3774 [AC_MSG_RESULT(no)
3775])
Christian Heimesb7bd5df2013-10-22 11:21:54 +02003776AC_MSG_CHECKING(for prlimit)
3777AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3778#include <sys/time.h>
3779#include <sys/resource.h>
3780 ]], [[void *x=prlimit]])],
3781 [AC_DEFINE(HAVE_PRLIMIT, 1, Define if you have the 'prlimit' functions.)
3782 AC_MSG_RESULT(yes)],
3783 [AC_MSG_RESULT(no)
3784])
Ronald Oussoren41761932020-11-08 10:05:27 +01003785AC_MSG_CHECKING(for _dyld_shared_cache_contains_path)
3786AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <mach-o/dyld.h>]], [[void *x=_dyld_shared_cache_contains_path]])],
3787 [AC_DEFINE(HAVE_DYLD_SHARED_CACHE_CONTAINS_PATH, 1, Define if you have the '_dyld_shared_cache_contains_path' function.)
3788 AC_MSG_RESULT(yes)],
3789 [AC_MSG_RESULT(no)
3790])
Christian Heimesb7bd5df2013-10-22 11:21:54 +02003791
Zackery Spytz43fdbd22019-05-29 13:57:07 -06003792AC_MSG_CHECKING(for memfd_create)
3793AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3794#ifdef HAVE_SYS_MMAN_H
3795#include <sys/mman.h>
3796#endif
3797#ifdef HAVE_SYS_MEMFD_H
3798#include <sys/memfd.h>
3799#endif
3800]], [[void *x=memfd_create]])],
3801 [AC_DEFINE(HAVE_MEMFD_CREATE, 1, Define if you have the 'memfd_create' function.)
3802 AC_MSG_RESULT(yes)],
3803 [AC_MSG_RESULT(no)
3804])
3805
Martin v. Löwisd5843682002-11-21 20:41:28 +00003806# On some systems (eg. FreeBSD 5), we would find a definition of the
3807# functions ctermid_r, setgroups in the library, but no prototype
3808# (e.g. because we use _XOPEN_SOURCE). See whether we can take their
3809# address to avoid compiler warnings and potential miscompilations
3810# because of the missing prototypes.
3811
3812AC_MSG_CHECKING(for ctermid_r)
Matthias Kloseb159a552010-04-25 21:00:44 +00003813AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwisd5843682002-11-21 20:41:28 +00003814#include <stdio.h>
Matthias Kloseb159a552010-04-25 21:00:44 +00003815]], [[void* p = ctermid_r]])],
3816 [AC_DEFINE(HAVE_CTERMID_R, 1, Define if you have the 'ctermid_r' function.)
3817 AC_MSG_RESULT(yes)],
3818 [AC_MSG_RESULT(no)
3819])
Martin v. Löwisd5843682002-11-21 20:41:28 +00003820
Antoine Pitroua4e4ae22010-09-10 18:39:00 +00003821AC_CACHE_CHECK([for flock declaration], [ac_cv_flock_decl],
3822 [AC_COMPILE_IFELSE(
3823 [AC_LANG_PROGRAM(
3824 [#include <sys/file.h>],
3825 [void* p = flock]
3826 )],
3827 [ac_cv_flock_decl=yes],
3828 [ac_cv_flock_decl=no]
3829 )
Matthias Kloseb159a552010-04-25 21:00:44 +00003830])
Antoine Pitroua4e4ae22010-09-10 18:39:00 +00003831if test "x${ac_cv_flock_decl}" = xyes; then
3832 AC_CHECK_FUNCS(flock,,
3833 AC_CHECK_LIB(bsd,flock,
3834 [AC_DEFINE(HAVE_FLOCK)
3835 AC_DEFINE(FLOCK_NEEDS_LIBBSD, 1, Define if flock needs to be linked with bsd library.)
3836 ])
3837 )
Antoine Pitroua3000072010-09-07 14:52:42 +00003838fi
Martin v. Löwisf26d63b2003-03-30 17:23:49 +00003839
3840AC_MSG_CHECKING(for getpagesize)
Matthias Kloseb159a552010-04-25 21:00:44 +00003841AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwisf26d63b2003-03-30 17:23:49 +00003842#include <unistd.h>
Matthias Kloseb159a552010-04-25 21:00:44 +00003843]], [[void* p = getpagesize]])],
3844 [AC_DEFINE(HAVE_GETPAGESIZE, 1, Define if you have the 'getpagesize' function.)
3845 AC_MSG_RESULT(yes)],
3846 [AC_MSG_RESULT(no)
3847])
Martin v. Löwisf26d63b2003-03-30 17:23:49 +00003848
Victor Stinner984890f2011-11-24 13:53:38 +01003849AC_MSG_CHECKING(for broken unsetenv)
3850AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3851#include <stdlib.h>
3852]], [[int res = unsetenv("DUMMY")]])],
3853 [AC_MSG_RESULT(no)],
3854 [AC_DEFINE(HAVE_BROKEN_UNSETENV, 1, Define if `unsetenv` does not return an int.)
3855 AC_MSG_RESULT(yes)
3856])
3857
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00003858dnl check for true
3859AC_CHECK_PROGS(TRUE, true, /bin/true)
3860
Martin v. Löwis95c419b2003-05-03 12:10:48 +00003861dnl On some systems (e.g. Solaris 9), hstrerror and inet_aton are in -lresolv
3862dnl On others, they are in the C library, so we to take no action
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00003863AC_CHECK_LIB(c, inet_aton, [$ac_cv_prog_TRUE],
Martin v. Löwis95c419b2003-05-03 12:10:48 +00003864 AC_CHECK_LIB(resolv, inet_aton)
3865)
3866
Christian Heimesd0764e22007-12-04 15:00:33 +00003867# On Tru64, chflags seems to be present, but calling it will
3868# exit Python
Benjamin Petersoned68afa2010-01-30 19:36:43 +00003869AC_CACHE_CHECK([for chflags], [ac_cv_have_chflags], [dnl
Ned Deily3eb67d52011-06-28 00:00:28 -07003870AC_RUN_IFELSE([AC_LANG_SOURCE([[
Christian Heimesd0764e22007-12-04 15:00:33 +00003871#include <sys/stat.h>
3872#include <unistd.h>
3873int main(int argc, char*argv[])
3874{
3875 if(chflags(argv[0], 0) != 0)
3876 return 1;
3877 return 0;
3878}
Ned Deily3eb67d52011-06-28 00:00:28 -07003879]])],
Matthias Kloseb159a552010-04-25 21:00:44 +00003880[ac_cv_have_chflags=yes],
3881[ac_cv_have_chflags=no],
3882[ac_cv_have_chflags=cross])
Benjamin Petersoned68afa2010-01-30 19:36:43 +00003883])
3884if test "$ac_cv_have_chflags" = cross ; then
3885 AC_CHECK_FUNC([chflags], [ac_cv_have_chflags="yes"], [ac_cv_have_chflags="no"])
3886fi
3887if test "$ac_cv_have_chflags" = yes ; then
Ned Deily3eb67d52011-06-28 00:00:28 -07003888 AC_DEFINE(HAVE_CHFLAGS, 1, [Define to 1 if you have the 'chflags' function.])
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00003889fi
Christian Heimesd0764e22007-12-04 15:00:33 +00003890
Benjamin Petersoned68afa2010-01-30 19:36:43 +00003891AC_CACHE_CHECK([for lchflags], [ac_cv_have_lchflags], [dnl
Ned Deily3eb67d52011-06-28 00:00:28 -07003892AC_RUN_IFELSE([AC_LANG_SOURCE([[
Christian Heimesd0764e22007-12-04 15:00:33 +00003893#include <sys/stat.h>
3894#include <unistd.h>
3895int main(int argc, char*argv[])
3896{
3897 if(lchflags(argv[0], 0) != 0)
3898 return 1;
3899 return 0;
3900}
Ned Deily3eb67d52011-06-28 00:00:28 -07003901]])],[ac_cv_have_lchflags=yes],[ac_cv_have_lchflags=no],[ac_cv_have_lchflags=cross])
Benjamin Petersoned68afa2010-01-30 19:36:43 +00003902])
3903if test "$ac_cv_have_lchflags" = cross ; then
3904 AC_CHECK_FUNC([lchflags], [ac_cv_have_lchflags="yes"], [ac_cv_have_lchflags="no"])
3905fi
3906if test "$ac_cv_have_lchflags" = yes ; then
Ned Deily3eb67d52011-06-28 00:00:28 -07003907 AC_DEFINE(HAVE_LCHFLAGS, 1, [Define to 1 if you have the 'lchflags' function.])
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00003908fi
Christian Heimesd0764e22007-12-04 15:00:33 +00003909
Thomas Wouters0e3f5912006-08-11 14:57:12 +00003910dnl Check if system zlib has *Copy() functions
3911dnl
3912dnl On MacOSX the linker will search for dylibs on the entire linker path
3913dnl before searching for static libraries. setup.py adds -Wl,-search_paths_first
3914dnl to revert to a more traditional unix behaviour and make it possible to
3915dnl override the system libz with a local static library of libz. Temporarily
3916dnl add that flag to our CFLAGS as well to ensure that we check the version
Victor Stinner1b80b242016-04-12 22:34:58 +02003917dnl of libz that will be used by setup.py.
3918dnl The -L/usr/local/lib is needed as wel to get the same compilation
Thomas Wouters0e3f5912006-08-11 14:57:12 +00003919dnl environment as setup.py (and leaving it out can cause configure to use the
3920dnl wrong version of the library)
3921case $ac_sys_system/$ac_sys_release in
Victor Stinner1b80b242016-04-12 22:34:58 +02003922Darwin/*)
Thomas Wouters0e3f5912006-08-11 14:57:12 +00003923 _CUR_CFLAGS="${CFLAGS}"
3924 _CUR_LDFLAGS="${LDFLAGS}"
3925 CFLAGS="${CFLAGS} -Wl,-search_paths_first"
3926 LDFLAGS="${LDFLAGS} -Wl,-search_paths_first -L/usr/local/lib"
3927 ;;
3928esac
3929
Matthias Klosec80c93f2010-04-24 17:04:35 +00003930AC_CHECK_LIB(z, inflateCopy, AC_DEFINE(HAVE_ZLIB_COPY, 1, [Define if the zlib library has inflateCopy]))
Thomas Wouters0e3f5912006-08-11 14:57:12 +00003931
3932case $ac_sys_system/$ac_sys_release in
Victor Stinner1b80b242016-04-12 22:34:58 +02003933Darwin/*)
Thomas Wouters0e3f5912006-08-11 14:57:12 +00003934 CFLAGS="${_CUR_CFLAGS}"
3935 LDFLAGS="${_CUR_LDFLAGS}"
3936 ;;
3937esac
3938
Martin v. Löwise9416172003-05-03 10:12:45 +00003939AC_MSG_CHECKING(for hstrerror)
Matthias Kloseb159a552010-04-25 21:00:44 +00003940AC_LINK_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwise9416172003-05-03 10:12:45 +00003941#include <netdb.h>
Matthias Kloseb159a552010-04-25 21:00:44 +00003942]], [[void* p = hstrerror; hstrerror(0)]])],
3943 [AC_DEFINE(HAVE_HSTRERROR, 1, Define if you have the 'hstrerror' function.)
3944 AC_MSG_RESULT(yes)],
3945 [AC_MSG_RESULT(no)
3946])
Martin v. Löwise9416172003-05-03 10:12:45 +00003947
3948AC_MSG_CHECKING(for inet_aton)
Matthias Kloseb159a552010-04-25 21:00:44 +00003949AC_LINK_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwis86d66262006-02-17 08:40:11 +00003950#include <sys/types.h>
Martin v. Löwise9416172003-05-03 10:12:45 +00003951#include <sys/socket.h>
3952#include <netinet/in.h>
3953#include <arpa/inet.h>
Matthias Kloseb159a552010-04-25 21:00:44 +00003954]], [[void* p = inet_aton;inet_aton(0,0)]])],
3955 [AC_DEFINE(HAVE_INET_ATON, 1, Define if you have the 'inet_aton' function.)
3956 AC_MSG_RESULT(yes)],
3957 [AC_MSG_RESULT(no)
3958])
Martin v. Löwise9416172003-05-03 10:12:45 +00003959
3960AC_MSG_CHECKING(for inet_pton)
Matthias Kloseb159a552010-04-25 21:00:44 +00003961AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwisf2e488d2003-05-05 22:00:11 +00003962#include <sys/types.h>
Martin v. Löwise9416172003-05-03 10:12:45 +00003963#include <sys/socket.h>
3964#include <netinet/in.h>
3965#include <arpa/inet.h>
Matthias Kloseb159a552010-04-25 21:00:44 +00003966]], [[void* p = inet_pton]])],
3967 [AC_DEFINE(HAVE_INET_PTON, 1, Define if you have the 'inet_pton' function.)
3968 AC_MSG_RESULT(yes)],
3969 [AC_MSG_RESULT(no)
3970])
Martin v. Löwise9416172003-05-03 10:12:45 +00003971
Martin v. Löwisd6640d42003-07-06 09:29:52 +00003972# On some systems, setgroups is in unistd.h, on others, in grp.h
Martin v. Löwisd5843682002-11-21 20:41:28 +00003973AC_MSG_CHECKING(for setgroups)
Matthias Kloseb159a552010-04-25 21:00:44 +00003974AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwisf2e488d2003-05-05 22:00:11 +00003975#include <unistd.h>
Martin v. Löwisd6640d42003-07-06 09:29:52 +00003976#ifdef HAVE_GRP_H
3977#include <grp.h>
3978#endif
Matthias Kloseb159a552010-04-25 21:00:44 +00003979]], [[void* p = setgroups]])],
3980 [AC_DEFINE(HAVE_SETGROUPS, 1, Define if you have the 'setgroups' function.)
3981 AC_MSG_RESULT(yes)],
3982 [AC_MSG_RESULT(no)
3983])
Martin v. Löwisd5843682002-11-21 20:41:28 +00003984
Fred Drake8cef4cf2000-06-28 16:40:38 +00003985# check for openpty and forkpty
3986
Victor Stinner1b80b242016-04-12 22:34:58 +02003987AC_CHECK_FUNCS(openpty,,
Martin v. Löwisfd9a72a2006-01-08 10:07:33 +00003988 AC_CHECK_LIB(util,openpty,
3989 [AC_DEFINE(HAVE_OPENPTY) LIBS="$LIBS -lutil"],
3990 AC_CHECK_LIB(bsd,openpty, [AC_DEFINE(HAVE_OPENPTY) LIBS="$LIBS -lbsd"])
3991 )
3992)
Victor Stinner1b80b242016-04-12 22:34:58 +02003993AC_CHECK_FUNCS(forkpty,,
3994 AC_CHECK_LIB(util,forkpty,
Martin v. Löwisfd9a72a2006-01-08 10:07:33 +00003995 [AC_DEFINE(HAVE_FORKPTY) LIBS="$LIBS -lutil"],
3996 AC_CHECK_LIB(bsd,forkpty, [AC_DEFINE(HAVE_FORKPTY) LIBS="$LIBS -lbsd"])
3997 )
3998)
Fred Drake8cef4cf2000-06-28 16:40:38 +00003999
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00004000# check for long file support functions
4001AC_CHECK_FUNCS(fseek64 fseeko fstatvfs ftell64 ftello statvfs)
4002
wasiher5798f782020-07-27 12:28:45 +09004003AC_REPLACE_FUNCS(dup2)
Victor Stinner1b80b242016-04-12 22:34:58 +02004004AC_CHECK_FUNCS(getpgrp,
Matthias Kloseb159a552010-04-25 21:00:44 +00004005 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[getpgrp(0);]])],
4006 [AC_DEFINE(GETPGRP_HAVE_ARG, 1, [Define if getpgrp() must be called as getpgrp(0).])],
4007 [])
Martin v. Löwisc45929e2002-04-06 10:10:49 +00004008)
Jack Jansen150753c2003-03-29 22:07:47 +00004009AC_CHECK_FUNCS(setpgrp,
Matthias Kloseb159a552010-04-25 21:00:44 +00004010 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[setpgrp(0,0);]])],
4011 [AC_DEFINE(SETPGRP_HAVE_ARG, 1, [Define if setpgrp() must be called as setpgrp(0, 0).])],
4012 [])
Martin v. Löwisc45929e2002-04-06 10:10:49 +00004013)
Guido van Rossum627b2d71993-12-24 10:39:16 +00004014
Gregory P. Smith387512c2018-12-30 15:42:32 -08004015# We search for both crypt and crypt_r as one or the other may be defined
4016# This gets us our -lcrypt in LIBS when required on the target platform.
4017AC_SEARCH_LIBS(crypt, crypt)
4018AC_SEARCH_LIBS(crypt_r, crypt)
4019
4020AC_CHECK_FUNC(crypt_r,
4021 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4022#define _GNU_SOURCE /* Required for crypt_r()'s prototype in glibc. */
4023#include <crypt.h>
4024]], [[
4025struct crypt_data d;
4026char *r = crypt_r("", "", &d);
4027]])],
4028 [AC_DEFINE(HAVE_CRYPT_R, 1, [Define if you have the crypt_r() function.])],
4029 [])
4030)
4031
Victor Stinnere0be4232011-10-25 13:06:09 +02004032AC_CHECK_FUNCS(clock_gettime, [], [
4033 AC_CHECK_LIB(rt, clock_gettime, [
Victor Stinner7efb8332014-08-29 15:41:08 +02004034 LIBS="$LIBS -lrt"
Victor Stinnere0be4232011-10-25 13:06:09 +02004035 AC_DEFINE(HAVE_CLOCK_GETTIME, 1)
4036 AC_DEFINE(TIMEMODULE_LIB, [rt],
4037 [Library needed by timemodule.c: librt may be needed for clock_gettime()])
4038 ])
4039])
4040
4041AC_CHECK_FUNCS(clock_getres, [], [
4042 AC_CHECK_LIB(rt, clock_getres, [
4043 AC_DEFINE(HAVE_CLOCK_GETRES, 1)
4044 ])
4045])
4046
Benjamin Peterson37098cd2016-09-13 22:55:09 -07004047AC_CHECK_FUNCS(clock_settime, [], [
4048 AC_CHECK_LIB(rt, clock_settime, [
4049 AC_DEFINE(HAVE_CLOCK_SETTIME, 1)
4050 ])
4051])
4052
Martin v. Löwisdbe3f762002-10-10 14:27:30 +00004053AC_MSG_CHECKING(for major, minor, and makedev)
Matthias Kloseb159a552010-04-25 21:00:44 +00004054AC_LINK_IFELSE([AC_LANG_PROGRAM([[
Neal Norwitz6eb37f02003-02-23 23:28:15 +00004055#if defined(MAJOR_IN_MKDEV)
4056#include <sys/mkdev.h>
4057#elif defined(MAJOR_IN_SYSMACROS)
4058#include <sys/sysmacros.h>
4059#else
4060#include <sys/types.h>
4061#endif
Matthias Kloseb159a552010-04-25 21:00:44 +00004062]], [[
Martin v. Löwisdbe3f762002-10-10 14:27:30 +00004063 makedev(major(0),minor(0));
Matthias Kloseb159a552010-04-25 21:00:44 +00004064]])],[
Martin v. Löwisdbe3f762002-10-10 14:27:30 +00004065 AC_DEFINE(HAVE_DEVICE_MACROS, 1,
4066 [Define to 1 if you have the device macros.])
4067 AC_MSG_RESULT(yes)
4068],[
4069 AC_MSG_RESULT(no)
4070])
Martin v. Löwis861a65b2001-10-24 14:36:00 +00004071
4072# On OSF/1 V5.1, getaddrinfo is available, but a define
Victor Stinner1b80b242016-04-12 22:34:58 +02004073# for [no]getaddrinfo in netdb.h.
Martin v. Löwis861a65b2001-10-24 14:36:00 +00004074AC_MSG_CHECKING(for getaddrinfo)
Matthias Kloseb159a552010-04-25 21:00:44 +00004075AC_LINK_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwisc010b6d2001-11-09 17:50:52 +00004076#include <sys/types.h>
Martin v. Löwis861a65b2001-10-24 14:36:00 +00004077#include <sys/socket.h>
4078#include <netdb.h>
Martin v. Löwisc010b6d2001-11-09 17:50:52 +00004079#include <stdio.h>
Matthias Kloseb159a552010-04-25 21:00:44 +00004080]], [[getaddrinfo(NULL, NULL, NULL, NULL);]])],
4081[have_getaddrinfo=yes],
4082[have_getaddrinfo=no])
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00004083AC_MSG_RESULT($have_getaddrinfo)
4084if test $have_getaddrinfo = yes
4085then
4086 AC_MSG_CHECKING(getaddrinfo bug)
4087 AC_CACHE_VAL(ac_cv_buggy_getaddrinfo,
Matthias Kloseb159a552010-04-25 21:00:44 +00004088 AC_RUN_IFELSE([AC_LANG_SOURCE([[[
Stefan Krah19c21392012-11-22 23:47:32 +01004089#include <stdio.h>
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00004090#include <sys/types.h>
4091#include <netdb.h>
4092#include <string.h>
4093#include <sys/socket.h>
4094#include <netinet/in.h>
4095
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00004096int main()
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00004097{
4098 int passive, gaierr, inet4 = 0, inet6 = 0;
4099 struct addrinfo hints, *ai, *aitop;
4100 char straddr[INET6_ADDRSTRLEN], strport[16];
4101
4102 for (passive = 0; passive <= 1; passive++) {
4103 memset(&hints, 0, sizeof(hints));
4104 hints.ai_family = AF_UNSPEC;
4105 hints.ai_flags = passive ? AI_PASSIVE : 0;
4106 hints.ai_socktype = SOCK_STREAM;
Hye-Shik Chang54f94392004-04-14 07:55:31 +00004107 hints.ai_protocol = IPPROTO_TCP;
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00004108 if ((gaierr = getaddrinfo(NULL, "54321", &hints, &aitop)) != 0) {
4109 (void)gai_strerror(gaierr);
4110 goto bad;
4111 }
4112 for (ai = aitop; ai; ai = ai->ai_next) {
4113 if (ai->ai_addr == NULL ||
4114 ai->ai_addrlen == 0 ||
4115 getnameinfo(ai->ai_addr, ai->ai_addrlen,
4116 straddr, sizeof(straddr), strport, sizeof(strport),
4117 NI_NUMERICHOST|NI_NUMERICSERV) != 0) {
4118 goto bad;
4119 }
4120 switch (ai->ai_family) {
4121 case AF_INET:
4122 if (strcmp(strport, "54321") != 0) {
4123 goto bad;
4124 }
4125 if (passive) {
4126 if (strcmp(straddr, "0.0.0.0") != 0) {
4127 goto bad;
4128 }
4129 } else {
4130 if (strcmp(straddr, "127.0.0.1") != 0) {
4131 goto bad;
4132 }
4133 }
4134 inet4++;
4135 break;
4136 case AF_INET6:
4137 if (strcmp(strport, "54321") != 0) {
4138 goto bad;
4139 }
4140 if (passive) {
4141 if (strcmp(straddr, "::") != 0) {
4142 goto bad;
4143 }
4144 } else {
4145 if (strcmp(straddr, "::1") != 0) {
4146 goto bad;
4147 }
4148 }
4149 inet6++;
4150 break;
4151 case AF_UNSPEC:
4152 goto bad;
4153 break;
4154 default:
4155 /* another family support? */
4156 break;
4157 }
4158 }
Benjamin Peterson01c340d2016-09-06 15:54:24 -07004159 freeaddrinfo(aitop);
4160 aitop = NULL;
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00004161 }
4162
4163 if (!(inet4 == 0 || inet4 == 2))
4164 goto bad;
4165 if (!(inet6 == 0 || inet6 == 2))
4166 goto bad;
4167
4168 if (aitop)
4169 freeaddrinfo(aitop);
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00004170 return 0;
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00004171
4172 bad:
4173 if (aitop)
4174 freeaddrinfo(aitop);
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00004175 return 1;
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00004176}
Matthias Kloseb159a552010-04-25 21:00:44 +00004177]]])],
4178[ac_cv_buggy_getaddrinfo=no],
4179[ac_cv_buggy_getaddrinfo=yes],
Matthias Klose96350132012-03-15 20:42:23 +01004180[
4181if test "${enable_ipv6+set}" = set; then
4182 ac_cv_buggy_getaddrinfo="no -- configured with --(en|dis)able-ipv6"
4183else
4184 ac_cv_buggy_getaddrinfo=yes
4185fi]))
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00004186fi
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00004187
Benjamin Petersond4694ed2010-11-01 01:44:30 +00004188AC_MSG_RESULT($ac_cv_buggy_getaddrinfo)
4189
doko@ubuntu.com9c7817e2012-06-30 17:05:13 +02004190if test $have_getaddrinfo = no || test "$ac_cv_buggy_getaddrinfo" = yes
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00004191then
4192 if test $ipv6 = yes
4193 then
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00004194 echo 'Fatal: You must get working getaddrinfo() function.'
4195 echo ' or you can specify "--disable-ipv6"'.
4196 exit 1
4197 fi
Martin v. Löwis861a65b2001-10-24 14:36:00 +00004198else
Martin v. Löwisc45929e2002-04-06 10:10:49 +00004199 AC_DEFINE(HAVE_GETADDRINFO, 1, [Define if you have the getaddrinfo function.])
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00004200fi
Benjamin Petersond4694ed2010-11-01 01:44:30 +00004201
Thomas Woutersb0db85a2001-08-08 10:39:03 +00004202AC_CHECK_FUNCS(getnameinfo)
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00004203
Guido van Rossum627b2d71993-12-24 10:39:16 +00004204# checks for structures
Guido van Rossum76be6ed1995-01-02 18:33:54 +00004205AC_HEADER_TIME
Guido van Rossum627b2d71993-12-24 10:39:16 +00004206AC_STRUCT_TM
Guido van Rossum76be6ed1995-01-02 18:33:54 +00004207AC_STRUCT_TIMEZONE
Martin v. Löwis60a5d722002-10-16 20:28:25 +00004208AC_CHECK_MEMBERS([struct stat.st_rdev])
4209AC_CHECK_MEMBERS([struct stat.st_blksize])
Hye-Shik Chang5f937a72005-06-02 13:09:30 +00004210AC_CHECK_MEMBERS([struct stat.st_flags])
Martin v. Löwisebd9d5b2005-08-09 15:00:59 +00004211AC_CHECK_MEMBERS([struct stat.st_gen])
4212AC_CHECK_MEMBERS([struct stat.st_birthtime])
Martin Panterd887d1f2016-03-18 02:36:41 +00004213AC_CHECK_MEMBERS([struct stat.st_blocks])
Stefan Krah267b6392016-04-26 01:09:18 +02004214AC_CHECK_MEMBERS([struct passwd.pw_gecos, struct passwd.pw_passwd], [], [], [[
4215 #include <sys/types.h>
4216 #include <pwd.h>
4217]])
Zachary Waree999e962016-10-01 01:06:51 -05004218# Issue #21085: In Cygwin, siginfo_t does not have si_band field.
4219AC_CHECK_MEMBERS([siginfo_t.si_band], [], [], [[#include <signal.h>]])
Guido van Rossum76be6ed1995-01-02 18:33:54 +00004220
4221AC_MSG_CHECKING(for time.h that defines altzone)
Matthias Kloseb159a552010-04-25 21:00:44 +00004222AC_CACHE_VAL(ac_cv_header_time_altzone,[
4223 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <time.h>]], [[return altzone;]])],
4224 [ac_cv_header_time_altzone=yes],
4225 [ac_cv_header_time_altzone=no])
4226 ])
Guido van Rossum76be6ed1995-01-02 18:33:54 +00004227AC_MSG_RESULT($ac_cv_header_time_altzone)
4228if test $ac_cv_header_time_altzone = yes; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00004229 AC_DEFINE(HAVE_ALTZONE, 1, [Define this if your time.h defines altzone.])
Guido van Rossum76be6ed1995-01-02 18:33:54 +00004230fi
4231
Guido van Rossum5739e7e1995-01-20 16:50:53 +00004232was_it_defined=no
4233AC_MSG_CHECKING(whether sys/select.h and sys/time.h may both be included)
Matthias Kloseb159a552010-04-25 21:00:44 +00004234AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Guido van Rossum433c8ad1994-08-01 12:07:07 +00004235#include <sys/types.h>
4236#include <sys/select.h>
4237#include <sys/time.h>
Matthias Kloseb159a552010-04-25 21:00:44 +00004238]], [[;]])],[
Martin v. Löwisc45929e2002-04-06 10:10:49 +00004239 AC_DEFINE(SYS_SELECT_WITH_SYS_TIME, 1,
4240 [Define if you can safely include both <sys/select.h> and <sys/time.h>
Victor Stinner1b80b242016-04-12 22:34:58 +02004241 (which you can't on SCO ODT 3.0).])
Martin v. Löwisc45929e2002-04-06 10:10:49 +00004242 was_it_defined=yes
Matthias Kloseb159a552010-04-25 21:00:44 +00004243],[])
Guido van Rossum5739e7e1995-01-20 16:50:53 +00004244AC_MSG_RESULT($was_it_defined)
Guido van Rossum627b2d71993-12-24 10:39:16 +00004245
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00004246AC_MSG_CHECKING(for addrinfo)
4247AC_CACHE_VAL(ac_cv_struct_addrinfo,
Matthias Kloseb159a552010-04-25 21:00:44 +00004248AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <netdb.h>]], [[struct addrinfo a]])],
4249 [ac_cv_struct_addrinfo=yes],
4250 [ac_cv_struct_addrinfo=no]))
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00004251AC_MSG_RESULT($ac_cv_struct_addrinfo)
4252if test $ac_cv_struct_addrinfo = yes; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00004253 AC_DEFINE(HAVE_ADDRINFO, 1, [struct addrinfo (netdb.h)])
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00004254fi
4255
4256AC_MSG_CHECKING(for sockaddr_storage)
4257AC_CACHE_VAL(ac_cv_struct_sockaddr_storage,
Matthias Kloseb159a552010-04-25 21:00:44 +00004258AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00004259# include <sys/types.h>
Matthias Kloseb159a552010-04-25 21:00:44 +00004260# include <sys/socket.h>]], [[struct sockaddr_storage s]])],
4261 [ac_cv_struct_sockaddr_storage=yes],
4262 [ac_cv_struct_sockaddr_storage=no]))
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00004263AC_MSG_RESULT($ac_cv_struct_sockaddr_storage)
4264if test $ac_cv_struct_sockaddr_storage = yes; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00004265 AC_DEFINE(HAVE_SOCKADDR_STORAGE, 1, [struct sockaddr_storage (sys/socket.h)])
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00004266fi
4267
Christian Heimesdffa3942016-09-05 23:54:41 +02004268AC_MSG_CHECKING(for sockaddr_alg)
4269AC_CACHE_VAL(ac_cv_struct_sockaddr_alg,
4270AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4271# include <sys/types.h>
4272# include <sys/socket.h>
4273# include <linux/if_alg.h>]], [[struct sockaddr_alg s]])],
4274 [ac_cv_struct_sockaddr_alg=yes],
4275 [ac_cv_struct_sockaddr_alg=no]))
4276AC_MSG_RESULT($ac_cv_struct_sockaddr_alg)
4277if test $ac_cv_struct_sockaddr_alg = yes; then
4278 AC_DEFINE(HAVE_SOCKADDR_ALG, 1, [struct sockaddr_alg (linux/if_alg.h)])
4279fi
4280
Guido van Rossum627b2d71993-12-24 10:39:16 +00004281# checks for compiler characteristics
Guido van Rossum433c8ad1994-08-01 12:07:07 +00004282
Guido van Rossum76be6ed1995-01-02 18:33:54 +00004283AC_C_CHAR_UNSIGNED
Guido van Rossum76be6ed1995-01-02 18:33:54 +00004284AC_C_CONST
Guido van Rossum433c8ad1994-08-01 12:07:07 +00004285
Guido van Rossum5739e7e1995-01-20 16:50:53 +00004286works=no
Guido van Rossum5739e7e1995-01-20 16:50:53 +00004287AC_MSG_CHECKING(for working signed char)
Matthias Kloseb159a552010-04-25 21:00:44 +00004288AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[signed char c;]])],
4289 [works=yes],
4290 [AC_DEFINE(signed, , [Define to empty if the keyword does not work.])]
Martin v. Löwisc45929e2002-04-06 10:10:49 +00004291)
Guido van Rossum5739e7e1995-01-20 16:50:53 +00004292AC_MSG_RESULT($works)
Guido van Rossum433c8ad1994-08-01 12:07:07 +00004293
Guido van Rossum5739e7e1995-01-20 16:50:53 +00004294have_prototypes=no
4295AC_MSG_CHECKING(for prototypes)
Matthias Kloseb159a552010-04-25 21:00:44 +00004296AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[int foo(int x) { return 0; }]], [[return foo(10);]])],
Victor Stinner1b80b242016-04-12 22:34:58 +02004297 [AC_DEFINE(HAVE_PROTOTYPES, 1,
4298 [Define if your compiler supports function prototype])
Matthias Kloseb159a552010-04-25 21:00:44 +00004299 have_prototypes=yes],
4300 []
4301)
Guido van Rossum5739e7e1995-01-20 16:50:53 +00004302AC_MSG_RESULT($have_prototypes)
Guido van Rossum433c8ad1994-08-01 12:07:07 +00004303
Guido van Rossum5739e7e1995-01-20 16:50:53 +00004304works=no
4305AC_MSG_CHECKING(for variable length prototypes and stdarg.h)
Matthias Kloseb159a552010-04-25 21:00:44 +00004306AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Guido van Rossum433c8ad1994-08-01 12:07:07 +00004307#include <stdarg.h>
Guido van Rossum3f13e481996-08-30 20:58:11 +00004308int foo(int x, ...) {
4309 va_list va;
4310 va_start(va, x);
4311 va_arg(va, int);
4312 va_arg(va, char *);
4313 va_arg(va, double);
4314 return 0;
4315}
Matthias Kloseb159a552010-04-25 21:00:44 +00004316]], [[return foo(10, "", 3.14);]])],[
Martin v. Löwisc45929e2002-04-06 10:10:49 +00004317 AC_DEFINE(HAVE_STDARG_PROTOTYPES, 1,
4318 [Define if your compiler supports variable length function prototypes
Victor Stinner1b80b242016-04-12 22:34:58 +02004319 (e.g. void fprintf(FILE *, char *, ...);) *and* <stdarg.h>])
Martin v. Löwisc45929e2002-04-06 10:10:49 +00004320 works=yes
Matthias Kloseb159a552010-04-25 21:00:44 +00004321],[])
Guido van Rossum5739e7e1995-01-20 16:50:53 +00004322AC_MSG_RESULT($works)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00004323
Dave Cole331708b2004-08-09 04:51:41 +00004324# check for socketpair
4325AC_MSG_CHECKING(for socketpair)
Matthias Kloseb159a552010-04-25 21:00:44 +00004326AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Dave Cole331708b2004-08-09 04:51:41 +00004327#include <sys/types.h>
4328#include <sys/socket.h>
Matthias Kloseb159a552010-04-25 21:00:44 +00004329]], [[void *x=socketpair]])],
4330 [AC_DEFINE(HAVE_SOCKETPAIR, 1, [Define if you have the 'socketpair' function.])
4331 AC_MSG_RESULT(yes)],
4332 [AC_MSG_RESULT(no)]
Dave Cole331708b2004-08-09 04:51:41 +00004333)
4334
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00004335# check if sockaddr has sa_len member
4336AC_MSG_CHECKING(if sockaddr has sa_len member)
Matthias Kloseb159a552010-04-25 21:00:44 +00004337AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
4338#include <sys/socket.h>]], [[struct sockaddr x;
4339x.sa_len = 0;]])],
4340 [AC_MSG_RESULT(yes)
4341 AC_DEFINE(HAVE_SOCKADDR_SA_LEN, 1, [Define if sockaddr has sa_len member])],
4342 [AC_MSG_RESULT(no)]
4343)
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00004344
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00004345# sigh -- gethostbyname_r is a mess; it can have 3, 5 or 6 arguments :-(
Martin v. Löwis11437992002-04-12 09:54:03 +00004346AH_TEMPLATE(HAVE_GETHOSTBYNAME_R,
4347 [Define this if you have some version of gethostbyname_r()])
4348
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00004349AC_CHECK_FUNC(gethostbyname_r, [
4350 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
4351 AC_MSG_CHECKING([gethostbyname_r with 6 args])
4352 OLD_CFLAGS=$CFLAGS
4353 CFLAGS="$CFLAGS $MY_CPPFLAGS $MY_THREAD_CPPFLAGS $MY_CFLAGS"
Matthias Kloseb159a552010-04-25 21:00:44 +00004354 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00004355# include <netdb.h>
Matthias Kloseb159a552010-04-25 21:00:44 +00004356 ]], [[
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00004357 char *name;
4358 struct hostent *he, *res;
4359 char buffer[2048];
4360 int buflen = 2048;
4361 int h_errnop;
4362
4363 (void) gethostbyname_r(name, he, buffer, buflen, &res, &h_errnop)
Matthias Kloseb159a552010-04-25 21:00:44 +00004364 ]])],[
Guido van Rossum8db7d8b1999-03-23 16:40:33 +00004365 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00004366 AC_DEFINE(HAVE_GETHOSTBYNAME_R_6_ARG, 1,
4367 [Define this if you have the 6-arg version of gethostbyname_r().])
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00004368 AC_MSG_RESULT(yes)
Matthias Kloseb159a552010-04-25 21:00:44 +00004369 ],[
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00004370 AC_MSG_RESULT(no)
4371 AC_MSG_CHECKING([gethostbyname_r with 5 args])
Matthias Kloseb159a552010-04-25 21:00:44 +00004372 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00004373# include <netdb.h>
Matthias Kloseb159a552010-04-25 21:00:44 +00004374 ]], [[
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00004375 char *name;
4376 struct hostent *he;
Matthias Kloseb159a552010-04-25 21:00:44 +00004377 char buffer[2048];
4378 int buflen = 2048;
4379 int h_errnop;
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00004380
Matthias Kloseb159a552010-04-25 21:00:44 +00004381 (void) gethostbyname_r(name, he, buffer, buflen, &h_errnop)
4382 ]])],
4383 [
Guido van Rossum8db7d8b1999-03-23 16:40:33 +00004384 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
Matthias Kloseb159a552010-04-25 21:00:44 +00004385 AC_DEFINE(HAVE_GETHOSTBYNAME_R_5_ARG, 1,
4386 [Define this if you have the 5-arg version of gethostbyname_r().])
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00004387 AC_MSG_RESULT(yes)
4388 ], [
4389 AC_MSG_RESULT(no)
Matthias Kloseb159a552010-04-25 21:00:44 +00004390 AC_MSG_CHECKING([gethostbyname_r with 3 args])
4391 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4392# include <netdb.h>
4393 ]], [[
4394 char *name;
4395 struct hostent *he;
4396 struct hostent_data data;
4397
4398 (void) gethostbyname_r(name, he, &data);
4399 ]])],
4400 [
4401 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
4402 AC_DEFINE(HAVE_GETHOSTBYNAME_R_3_ARG, 1,
4403 [Define this if you have the 3-arg version of gethostbyname_r().])
4404 AC_MSG_RESULT(yes)
4405 ], [
4406 AC_MSG_RESULT(no)
4407 ])
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00004408 ])
4409 ])
4410 CFLAGS=$OLD_CFLAGS
4411], [
Thomas Wouters3a584202000-08-05 23:28:51 +00004412 AC_CHECK_FUNCS(gethostbyname)
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00004413])
4414AC_SUBST(HAVE_GETHOSTBYNAME_R_6_ARG)
4415AC_SUBST(HAVE_GETHOSTBYNAME_R_5_ARG)
4416AC_SUBST(HAVE_GETHOSTBYNAME_R_3_ARG)
Guido van Rossum8db7d8b1999-03-23 16:40:33 +00004417AC_SUBST(HAVE_GETHOSTBYNAME_R)
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00004418AC_SUBST(HAVE_GETHOSTBYNAME)
4419
Guido van Rossum627b2d71993-12-24 10:39:16 +00004420# checks for system services
4421# (none yet)
4422
Guido van Rossum76be6ed1995-01-02 18:33:54 +00004423# Linux requires this for correct f.p. operations
Jeremy Hyltonbe28f5b2000-07-27 21:03:04 +00004424AC_CHECK_FUNC(__fpu_control,
4425 [],
4426 [AC_CHECK_LIB(ieee, __fpu_control)
4427])
Guido van Rossum627b2d71993-12-24 10:39:16 +00004428
Guido van Rossum433c8ad1994-08-01 12:07:07 +00004429# check for --with-libm=...
4430AC_SUBST(LIBM)
Guido van Rossum4b6b5791996-09-09 20:09:34 +00004431case $ac_sys_system in
Guido van Rossum3dc0a512000-10-05 18:00:06 +00004432Darwin) ;;
Guido van Rossum4b6b5791996-09-09 20:09:34 +00004433*) LIBM=-lm
4434esac
Guido van Rossum93274221997-05-09 02:42:00 +00004435AC_MSG_CHECKING(for --with-libm=STRING)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00004436AC_ARG_WITH(libm,
Anthony Shaw2de064e2020-01-14 17:40:10 +11004437 AS_HELP_STRING([--with-libm=STRING], [override libm math library to STRING (default is system-dependent)]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00004438[
Guido van Rossum93274221997-05-09 02:42:00 +00004439if test "$withval" = no
4440then LIBM=
4441 AC_MSG_RESULT(force LIBM empty)
4442elif test "$withval" != yes
Guido van Rossum433c8ad1994-08-01 12:07:07 +00004443then LIBM=$withval
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00004444 AC_MSG_RESULT(set LIBM="$withval")
4445else AC_MSG_ERROR([proper usage is --with-libm=STRING])
Guido van Rossum93274221997-05-09 02:42:00 +00004446fi],
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00004447[AC_MSG_RESULT(default LIBM="$LIBM")])
Guido van Rossum433c8ad1994-08-01 12:07:07 +00004448
4449# check for --with-libc=...
4450AC_SUBST(LIBC)
Guido van Rossum93274221997-05-09 02:42:00 +00004451AC_MSG_CHECKING(for --with-libc=STRING)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00004452AC_ARG_WITH(libc,
Anthony Shaw2de064e2020-01-14 17:40:10 +11004453 AS_HELP_STRING([--with-libc=STRING], [override libc C library to STRING (default is system-dependent)]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00004454[
Guido van Rossum93274221997-05-09 02:42:00 +00004455if test "$withval" = no
4456then LIBC=
4457 AC_MSG_RESULT(force LIBC empty)
4458elif test "$withval" != yes
Guido van Rossum433c8ad1994-08-01 12:07:07 +00004459then LIBC=$withval
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00004460 AC_MSG_RESULT(set LIBC="$withval")
4461else AC_MSG_ERROR([proper usage is --with-libc=STRING])
Guido van Rossum93274221997-05-09 02:42:00 +00004462fi],
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00004463[AC_MSG_RESULT(default LIBC="$LIBC")])
Guido van Rossum433c8ad1994-08-01 12:07:07 +00004464
Stefan Krah1919b7e2012-03-21 18:25:23 +01004465# **************************************
4466# * Check for gcc x64 inline assembler *
4467# **************************************
4468
4469AC_MSG_CHECKING(for x64 gcc inline assembler)
Stefan Krahe31db2a2015-07-02 20:27:56 +02004470AC_LINK_IFELSE( [AC_LANG_PROGRAM([[]], [[
Stefan Krah1919b7e2012-03-21 18:25:23 +01004471 __asm__ __volatile__ ("movq %rcx, %rax");
4472]])],[have_gcc_asm_for_x64=yes],[have_gcc_asm_for_x64=no])
4473AC_MSG_RESULT($have_gcc_asm_for_x64)
4474if test "$have_gcc_asm_for_x64" = yes
4475then
4476 AC_DEFINE(HAVE_GCC_ASM_FOR_X64, 1,
4477 [Define if we can use x64 gcc inline assembler])
4478fi
4479
Mark Dickinsonb08a53a2009-04-16 19:52:09 +00004480# **************************************************
4481# * Check for various properties of floating point *
4482# **************************************************
Christian Heimes81ee3ef2008-05-04 22:42:01 +00004483
Ross Burton2a9c3802018-09-19 07:25:48 +01004484AX_C_FLOAT_WORDS_BIGENDIAN
4485if test "$ax_cv_c_float_words_bigendian" = "yes"
Mark Dickinsonb08a53a2009-04-16 19:52:09 +00004486then
4487 AC_DEFINE(DOUBLE_IS_BIG_ENDIAN_IEEE754, 1,
4488 [Define if C doubles are 64-bit IEEE 754 binary format, stored
4489 with the most significant byte first])
Ross Burton2a9c3802018-09-19 07:25:48 +01004490elif test "$ax_cv_c_float_words_bigendian" = "no"
Mark Dickinsonb08a53a2009-04-16 19:52:09 +00004491then
Ross Burton2a9c3802018-09-19 07:25:48 +01004492 AC_DEFINE(DOUBLE_IS_LITTLE_ENDIAN_IEEE754, 1,
4493 [Define if C doubles are 64-bit IEEE 754 binary format, stored
4494 with the least significant byte first])
4495else
4496 # Some ARM platforms use a mixed-endian representation for doubles.
4497 # While Python doesn't currently have full support for these platforms
4498 # (see e.g., issue 1762561), we can at least make sure that float <-> string
4499 # conversions work.
4500 # FLOAT_WORDS_BIGENDIAN doesnt actually detect this case, but if it's not big
4501 # or little, then it must be this?
Mark Dickinsonb08a53a2009-04-16 19:52:09 +00004502 AC_DEFINE(DOUBLE_IS_ARM_MIXED_ENDIAN_IEEE754, 1,
4503 [Define if C doubles are 64-bit IEEE 754 binary format, stored
4504 in ARM mixed-endian order (byte order 45670123)])
4505fi
4506
Mark Dickinson7abf8d42009-04-18 20:17:52 +00004507# The short float repr introduced in Python 3.1 requires the
4508# correctly-rounded string <-> double conversion functions from
4509# Python/dtoa.c, which in turn require that the FPU uses 53-bit
4510# rounding; this is a problem on x86, where the x87 FPU has a default
Mark Dickinsonf4243f62009-11-15 13:47:27 +00004511# rounding precision of 64 bits. For gcc/x86, we can fix this by
Mark Dickinson7abf8d42009-04-18 20:17:52 +00004512# using inline assembler to get and set the x87 FPU control word.
Mark Dickinsonf4243f62009-11-15 13:47:27 +00004513
4514# This inline assembler syntax may also work for suncc and icc,
4515# so we try it on all platforms.
4516
4517AC_MSG_CHECKING(whether we can use gcc inline assembler to get and set x87 control word)
Stefan Krahe31db2a2015-07-02 20:27:56 +02004518AC_LINK_IFELSE( [AC_LANG_PROGRAM([[]], [[
Mark Dickinsonf4243f62009-11-15 13:47:27 +00004519 unsigned short cw;
4520 __asm__ __volatile__ ("fnstcw %0" : "=m" (cw));
4521 __asm__ __volatile__ ("fldcw %0" : : "m" (cw));
Matthias Kloseb159a552010-04-25 21:00:44 +00004522]])],[have_gcc_asm_for_x87=yes],[have_gcc_asm_for_x87=no])
Mark Dickinsonf4243f62009-11-15 13:47:27 +00004523AC_MSG_RESULT($have_gcc_asm_for_x87)
4524if test "$have_gcc_asm_for_x87" = yes
Mark Dickinsonb08a53a2009-04-16 19:52:09 +00004525then
Mark Dickinsonf4243f62009-11-15 13:47:27 +00004526 AC_DEFINE(HAVE_GCC_ASM_FOR_X87, 1,
4527 [Define if we can use gcc inline assembler to get and set x87 control word])
Mark Dickinsonb08a53a2009-04-16 19:52:09 +00004528fi
Christian Heimes81ee3ef2008-05-04 22:42:01 +00004529
Benjamin Peterson8bdeb162014-04-17 00:00:31 -04004530AC_MSG_CHECKING(whether we can use gcc inline assembler to get and set mc68881 fpcr)
Stefan Krahe31db2a2015-07-02 20:27:56 +02004531AC_LINK_IFELSE( [AC_LANG_PROGRAM([[]], [[
Benjamin Peterson8bdeb162014-04-17 00:00:31 -04004532 unsigned int fpcr;
4533 __asm__ __volatile__ ("fmove.l %%fpcr,%0" : "=g" (fpcr));
4534 __asm__ __volatile__ ("fmove.l %0,%%fpcr" : : "g" (fpcr));
4535]])],[have_gcc_asm_for_mc68881=yes],[have_gcc_asm_for_mc68881=no])
4536AC_MSG_RESULT($have_gcc_asm_for_mc68881)
4537if test "$have_gcc_asm_for_mc68881" = yes
4538then
4539 AC_DEFINE(HAVE_GCC_ASM_FOR_MC68881, 1,
4540 [Define if we can use gcc inline assembler to get and set mc68881 fpcr])
4541fi
4542
Mark Dickinson3dc7c6a2009-01-04 15:09:02 +00004543# Detect whether system arithmetic is subject to x87-style double
4544# rounding issues. The result of this test has little meaning on non
4545# IEEE 754 platforms. On IEEE 754, test should return 1 if rounding
4546# mode is round-to-nearest and double rounding issues are present, and
4547# 0 otherwise. See http://bugs.python.org/issue2937 for more info.
4548AC_MSG_CHECKING(for x87-style double rounding)
Mark Dickinsonb08a53a2009-04-16 19:52:09 +00004549# $BASECFLAGS may affect the result
4550ac_save_cc="$CC"
4551CC="$CC $BASECFLAGS"
Matthias Kloseb159a552010-04-25 21:00:44 +00004552AC_RUN_IFELSE([AC_LANG_SOURCE([[
Mark Dickinson3dc7c6a2009-01-04 15:09:02 +00004553#include <stdlib.h>
4554#include <math.h>
4555int main() {
4556 volatile double x, y, z;
4557 /* 1./(1-2**-53) -> 1+2**-52 (correct), 1.0 (double rounding) */
4558 x = 0.99999999999999989; /* 1-2**-53 */
4559 y = 1./x;
4560 if (y != 1.)
4561 exit(0);
4562 /* 1e16+2.99999 -> 1e16+2. (correct), 1e16+4. (double rounding) */
4563 x = 1e16;
4564 y = 2.99999;
4565 z = x + y;
4566 if (z != 1e16+4.)
4567 exit(0);
4568 /* both tests show evidence of double rounding */
4569 exit(1);
4570}
Matthias Kloseb159a552010-04-25 21:00:44 +00004571]])],
4572[ac_cv_x87_double_rounding=no],
4573[ac_cv_x87_double_rounding=yes],
4574[ac_cv_x87_double_rounding=no])
Mark Dickinsonb08a53a2009-04-16 19:52:09 +00004575CC="$ac_save_cc"
Mark Dickinson3dc7c6a2009-01-04 15:09:02 +00004576AC_MSG_RESULT($ac_cv_x87_double_rounding)
4577if test "$ac_cv_x87_double_rounding" = yes
4578then
4579 AC_DEFINE(X87_DOUBLE_ROUNDING, 1,
4580 [Define if arithmetic is subject to x87-style double rounding issue])
4581fi
4582
Mark Dickinsonb08a53a2009-04-16 19:52:09 +00004583# ************************************
4584# * Check for mathematical functions *
4585# ************************************
4586
4587LIBS_SAVE=$LIBS
4588LIBS="$LIBS $LIBM"
4589
Mark Dickinson7edecdd2010-11-20 10:09:56 +00004590AC_CHECK_FUNCS([acosh asinh atanh copysign erf erfc expm1 finite gamma])
Victor Stinner8f9f8d62011-05-09 12:45:41 +02004591AC_CHECK_FUNCS([hypot lgamma log1p log2 round tgamma])
Mark Dickinson7edecdd2010-11-20 10:09:56 +00004592AC_CHECK_DECLS([isinf, isnan, isfinite], [], [], [[#include <math.h>]])
4593
Mark Dickinsona614f042009-11-28 12:48:43 +00004594# For multiprocessing module, check that sem_open
4595# actually works. For FreeBSD versions <= 7.2,
4596# the kernel module that provides POSIX semaphores
4597# isn't loaded by default, so an attempt to call
4598# sem_open results in a 'Signal 12' error.
4599AC_MSG_CHECKING(whether POSIX semaphores are enabled)
4600AC_CACHE_VAL(ac_cv_posix_semaphores_enabled,
Matthias Kloseb159a552010-04-25 21:00:44 +00004601AC_RUN_IFELSE([AC_LANG_SOURCE([[
Mark Dickinsona614f042009-11-28 12:48:43 +00004602#include <unistd.h>
4603#include <fcntl.h>
4604#include <stdio.h>
4605#include <semaphore.h>
4606#include <sys/stat.h>
4607
4608int main(void) {
4609 sem_t *a = sem_open("/autoconf", O_CREAT, S_IRUSR|S_IWUSR, 0);
4610 if (a == SEM_FAILED) {
4611 perror("sem_open");
4612 return 1;
4613 }
4614 sem_close(a);
Mark Dickinsonba79b352009-12-13 21:10:57 +00004615 sem_unlink("/autoconf");
Mark Dickinsona614f042009-11-28 12:48:43 +00004616 return 0;
4617}
Matthias Kloseb159a552010-04-25 21:00:44 +00004618]])],
4619[ac_cv_posix_semaphores_enabled=yes],
4620[ac_cv_posix_semaphores_enabled=no],
4621[ac_cv_posix_semaphores_enabled=yes])
Mark Dickinsona614f042009-11-28 12:48:43 +00004622)
4623AC_MSG_RESULT($ac_cv_posix_semaphores_enabled)
4624if test $ac_cv_posix_semaphores_enabled = no
4625then
4626 AC_DEFINE(POSIX_SEMAPHORES_NOT_ENABLED, 1,
4627 [Define if POSIX semaphores aren't enabled on your system])
4628fi
4629
Mark Dickinson10683072009-04-18 21:18:19 +00004630# Multiprocessing check for broken sem_getvalue
4631AC_MSG_CHECKING(for broken sem_getvalue)
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00004632AC_CACHE_VAL(ac_cv_broken_sem_getvalue,
Matthias Kloseb159a552010-04-25 21:00:44 +00004633AC_RUN_IFELSE([AC_LANG_SOURCE([[
Mark Dickinson10683072009-04-18 21:18:19 +00004634#include <unistd.h>
4635#include <fcntl.h>
4636#include <stdio.h>
4637#include <semaphore.h>
4638#include <sys/stat.h>
4639
4640int main(void){
Mark Dickinsonba79b352009-12-13 21:10:57 +00004641 sem_t *a = sem_open("/autocftw", O_CREAT, S_IRUSR|S_IWUSR, 0);
Mark Dickinson10683072009-04-18 21:18:19 +00004642 int count;
4643 int res;
4644 if(a==SEM_FAILED){
4645 perror("sem_open");
4646 return 1;
4647
4648 }
4649 res = sem_getvalue(a, &count);
4650 sem_close(a);
Mark Dickinsonba79b352009-12-13 21:10:57 +00004651 sem_unlink("/autocftw");
Mark Dickinson10683072009-04-18 21:18:19 +00004652 return res==-1 ? 1 : 0;
4653}
Matthias Kloseb159a552010-04-25 21:00:44 +00004654]])],
4655[ac_cv_broken_sem_getvalue=no],
4656[ac_cv_broken_sem_getvalue=yes],
4657[ac_cv_broken_sem_getvalue=yes])
Mark Dickinson10683072009-04-18 21:18:19 +00004658)
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00004659AC_MSG_RESULT($ac_cv_broken_sem_getvalue)
4660if test $ac_cv_broken_sem_getvalue = yes
4661then
4662 AC_DEFINE(HAVE_BROKEN_SEM_GETVALUE, 1,
4663 [define to 1 if your sem_getvalue is broken.])
4664fi
Mark Dickinson10683072009-04-18 21:18:19 +00004665
Michael Feltc5ae1692017-12-19 13:58:49 +01004666AC_CHECK_DECLS([RTLD_LAZY, RTLD_NOW, RTLD_GLOBAL, RTLD_LOCAL, RTLD_NODELETE, RTLD_NOLOAD, RTLD_DEEPBIND, RTLD_MEMBER], [], [], [[#include <dlfcn.h>]])
Serhiy Storchakac2f7d872016-05-04 09:44:44 +03004667
Mark Dickinsonbd792642009-03-18 20:06:12 +00004668# determine what size digit to use for Python's longs
4669AC_MSG_CHECKING([digit size for Python's longs])
4670AC_ARG_ENABLE(big-digits,
Anthony Shaw2de064e2020-01-14 17:40:10 +11004671AS_HELP_STRING([--enable-big-digits@<:@=15|30@:>@],[use big digits (30 or 15 bits) for Python longs (default is system-dependent)]]),
Mark Dickinsonbd792642009-03-18 20:06:12 +00004672[case $enable_big_digits in
4673yes)
4674 enable_big_digits=30 ;;
4675no)
4676 enable_big_digits=15 ;;
4677[15|30])
4678 ;;
4679*)
4680 AC_MSG_ERROR([bad value $enable_big_digits for --enable-big-digits; value should be 15 or 30]) ;;
4681esac
4682AC_MSG_RESULT($enable_big_digits)
4683AC_DEFINE_UNQUOTED(PYLONG_BITS_IN_DIGIT, $enable_big_digits, [Define as the preferred size in bits of long digits])
4684],
4685[AC_MSG_RESULT(no value specified)])
4686
Guido van Rossumef2255b2000-03-10 22:30:29 +00004687# check for wchar.h
Martin v. Löwisc45929e2002-04-06 10:10:49 +00004688AC_CHECK_HEADER(wchar.h, [
Victor Stinner1b80b242016-04-12 22:34:58 +02004689 AC_DEFINE(HAVE_WCHAR_H, 1,
4690 [Define if the compiler provides a wchar.h header file.])
Martin v. Löwisc45929e2002-04-06 10:10:49 +00004691 wchar_h="yes"
4692],
Guido van Rossumef2255b2000-03-10 22:30:29 +00004693wchar_h="no"
4694)
4695
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00004696# determine wchar_t size
4697if test "$wchar_h" = yes
4698then
Guido van Rossum67b26592001-10-20 14:21:45 +00004699 AC_CHECK_SIZEOF(wchar_t, 4, [#include <wchar.h>])
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00004700fi
4701
Martin v. Löwisfa3bdea2003-09-04 18:50:54 +00004702AC_MSG_CHECKING(for UCS-4 tcl)
4703have_ucs4_tcl=no
Matthias Kloseb159a552010-04-25 21:00:44 +00004704AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwisfa3bdea2003-09-04 18:50:54 +00004705#include <tcl.h>
4706#if TCL_UTF_MAX != 6
4707# error "NOT UCS4_TCL"
Matthias Kloseb159a552010-04-25 21:00:44 +00004708#endif]], [[]])],[
Martin v. Löwisfa3bdea2003-09-04 18:50:54 +00004709 AC_DEFINE(HAVE_UCS4_TCL, 1, [Define this if you have tcl and TCL_UTF_MAX==6])
4710 have_ucs4_tcl=yes
Matthias Kloseb159a552010-04-25 21:00:44 +00004711],[])
Martin v. Löwisfa3bdea2003-09-04 18:50:54 +00004712AC_MSG_RESULT($have_ucs4_tcl)
4713
Marc-André Lemburgd7160f82003-09-22 11:14:40 +00004714# check whether wchar_t is signed or not
4715if test "$wchar_h" = yes
4716then
4717 # check whether wchar_t is signed or not
4718 AC_MSG_CHECKING(whether wchar_t is signed)
4719 AC_CACHE_VAL(ac_cv_wchar_t_signed, [
Matthias Kloseb159a552010-04-25 21:00:44 +00004720 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Marc-André Lemburgd7160f82003-09-22 11:14:40 +00004721 #include <wchar.h>
4722 int main()
4723 {
Thomas Wouters49fd7fa2006-04-21 10:40:58 +00004724 /* Success: exit code 0 */
4725 exit((((wchar_t) -1) < ((wchar_t) 0)) ? 0 : 1);
Marc-André Lemburgd7160f82003-09-22 11:14:40 +00004726 }
Matthias Kloseb159a552010-04-25 21:00:44 +00004727 ]])],
4728 [ac_cv_wchar_t_signed=yes],
4729 [ac_cv_wchar_t_signed=no],
4730 [ac_cv_wchar_t_signed=yes])])
Marc-André Lemburgd7160f82003-09-22 11:14:40 +00004731 AC_MSG_RESULT($ac_cv_wchar_t_signed)
4732fi
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00004733
Michael Osipov3738fad2018-08-24 18:17:19 +02004734AC_MSG_CHECKING(whether wchar_t is usable)
Georg Brandl52d168a2008-01-07 18:10:24 +00004735# wchar_t is only usable if it maps to an unsigned type
Martin v. Löwisd63a3b82011-09-28 07:41:54 +02004736if test "$ac_cv_sizeof_wchar_t" -ge 2 \
Matthias Klose7dbeed72004-12-24 08:22:17 +00004737 -a "$ac_cv_wchar_t_signed" = "no"
Georg Brandl52d168a2008-01-07 18:10:24 +00004738then
Georg Brandl52d168a2008-01-07 18:10:24 +00004739 AC_DEFINE(HAVE_USABLE_WCHAR_T, 1,
4740 [Define if you have a useable wchar_t type defined in wchar.h; useable
4741 means wchar_t must be an unsigned type with at least 16 bits. (see
4742 Include/unicodeobject.h).])
Michael Osipov3738fad2018-08-24 18:17:19 +02004743 AC_MSG_RESULT(yes)
Georg Brandl52d168a2008-01-07 18:10:24 +00004744else
Michael Osipov3738fad2018-08-24 18:17:19 +02004745 AC_MSG_RESULT(no)
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00004746fi
Guido van Rossumef2255b2000-03-10 22:30:29 +00004747
4748# check for endianness
4749AC_C_BIGENDIAN
4750
Barry Warsaw35f3a2c2010-09-03 18:30:30 +00004751# ABI version string for Python extension modules. This appears between the
4752# periods in shared library file names, e.g. foo.<SOABI>.so. It is calculated
4753# from the following attributes which affect the ABI of this Python build (in
4754# this order):
4755#
4756# * The Python implementation (always 'cpython-' for us)
4757# * The major and minor version numbers
4758# * --with-pydebug (adds a 'd')
Barry Warsaw35f3a2c2010-09-03 18:30:30 +00004759#
4760# Thus for example, Python 3.2 built with wide unicode, pydebug, and pymalloc,
Georg Brandlde7d8342010-09-03 22:19:07 +00004761# would get a shared library ABI version tag of 'cpython-32dmu' and shared
4762# libraries would be named 'foo.cpython-32dmu.so'.
Victor Stinner6c44fde2019-04-24 16:10:09 +02004763#
4764# In Python 3.2 and older, --with-wide-unicode added a 'u' flag.
4765# In Python 3.7 and older, --with-pymalloc added a 'm' flag.
Barry Warsaw35f3a2c2010-09-03 18:30:30 +00004766AC_SUBST(SOABI)
Barry Warsaw8cf4eae2010-10-16 01:04:07 +00004767AC_MSG_CHECKING(ABIFLAGS)
4768AC_MSG_RESULT($ABIFLAGS)
Barry Warsaw35f3a2c2010-09-03 18:30:30 +00004769AC_MSG_CHECKING(SOABI)
doko@ubuntu.comd3899c12015-04-15 20:23:14 +02004770SOABI='cpython-'`echo $VERSION | tr -d .`${ABIFLAGS}${PLATFORM_TRIPLET:+-$PLATFORM_TRIPLET}
Barry Warsaw35f3a2c2010-09-03 18:30:30 +00004771AC_MSG_RESULT($SOABI)
4772
Victor Stinner6d13e5b2019-04-26 18:56:19 +02004773# Release and debug (Py_DEBUG) ABI are compatible, but not Py_TRACE_REFS ABI
4774if test "$Py_DEBUG" = 'true' -a "$with_trace_refs" != "yes"; then
Victor Stinner5422e3c2019-04-26 01:40:00 +02004775 # Similar to SOABI but remove "d" flag from ABIFLAGS
4776 AC_SUBST(ALT_SOABI)
4777 ALT_SOABI='cpython-'`echo $VERSION | tr -d .``echo $ABIFLAGS | tr -d d`${PLATFORM_TRIPLET:+-$PLATFORM_TRIPLET}
4778 AC_DEFINE_UNQUOTED(ALT_SOABI, "${ALT_SOABI}",
4779 [Alternative SOABI used in debug build to load C extensions built in release mode])
4780fi
4781
doko@ubuntu.comd5537d02013-03-21 13:21:49 -07004782AC_SUBST(EXT_SUFFIX)
4783case $ac_sys_system in
pxinwr32f5fdd2019-02-27 19:09:28 +08004784 Linux*|GNU*|Darwin|VxWorks)
doko@ubuntu.comd5537d02013-03-21 13:21:49 -07004785 EXT_SUFFIX=.${SOABI}${SHLIB_SUFFIX};;
4786 *)
4787 EXT_SUFFIX=${SHLIB_SUFFIX};;
4788esac
4789
Barry Warsaw8cf4eae2010-10-16 01:04:07 +00004790AC_MSG_CHECKING(LDVERSION)
4791LDVERSION='$(VERSION)$(ABIFLAGS)'
4792AC_MSG_RESULT($LDVERSION)
4793
E. M. Brayc994c8f2019-05-24 17:33:47 +02004794# On Android and Cygwin the shared libraries must be linked with libpython.
xdegaye254b3092019-04-29 09:27:40 +02004795AC_SUBST(LIBPYTHON)
E. M. Brayb1fc4172019-05-24 18:39:39 +02004796if test -n "$ANDROID_API_LEVEL" -o "$MACHDEP" = "cygwin"; then
xdegaye254b3092019-04-29 09:27:40 +02004797 LIBPYTHON="-lpython${VERSION}${ABIFLAGS}"
E. M. Brayb1fc4172019-05-24 18:39:39 +02004798else
4799 LIBPYTHON=''
xdegaye254b3092019-04-29 09:27:40 +02004800fi
4801
Victor Stinner8510f432020-03-10 09:53:09 +01004802
Victor Stinner51ae31e2020-06-09 15:32:43 +02004803AC_SUBST(BINLIBDEST)
4804BINLIBDEST='$(LIBDIR)/python$(VERSION)'
4805
4806
4807# Check for --with-platlibdir
Victor Stinner8510f432020-03-10 09:53:09 +01004808# /usr/$LIDIRNAME/python$VERSION
4809AC_SUBST(PLATLIBDIR)
4810PLATLIBDIR="lib"
4811AC_MSG_CHECKING(for --with-platlibdir)
4812AC_ARG_WITH(platlibdir,
4813 AS_HELP_STRING([--with-platlibdir=DIRNAME],
4814 [Python library directory name (default is "lib")]),
4815[
4816# ignore 3 options:
4817# --with-platlibdir
4818# --with-platlibdir=
4819# --without-platlibdir
4820if test -n "$withval" -a "$withval" != yes -a "$withval" != no
4821then
4822 AC_MSG_RESULT(yes)
4823 PLATLIBDIR="$withval"
Victor Stinner51ae31e2020-06-09 15:32:43 +02004824 BINLIBDEST='${exec_prefix}/${PLATLIBDIR}/python$(VERSION)'
Victor Stinner8510f432020-03-10 09:53:09 +01004825else
4826 AC_MSG_RESULT(no)
4827fi],
4828[AC_MSG_RESULT(no)])
4829
4830
doko@python.org87421192013-01-26 11:39:31 +01004831dnl define LIBPL after ABIFLAGS and LDVERSION is defined.
4832AC_SUBST(PY_ENABLE_SHARED)
doko@ubuntu.com55532312016-06-14 08:55:19 +02004833if test x$PLATFORM_TRIPLET = x; then
Victor Stinner8510f432020-03-10 09:53:09 +01004834 LIBPL='$(prefix)'"/${PLATLIBDIR}/python${VERSION}/config-${LDVERSION}"
doko@ubuntu.com55532312016-06-14 08:55:19 +02004835else
Victor Stinner8510f432020-03-10 09:53:09 +01004836 LIBPL='$(prefix)'"/${PLATLIBDIR}/python${VERSION}/config-${LDVERSION}-${PLATFORM_TRIPLET}"
doko@ubuntu.com55532312016-06-14 08:55:19 +02004837fi
doko@python.org87421192013-01-26 11:39:31 +01004838AC_SUBST(LIBPL)
4839
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00004840# Check whether right shifting a negative integer extends the sign bit
4841# or fills with zeros (like the Cray J90, according to Tim Peters).
4842AC_MSG_CHECKING(whether right shift extends the sign bit)
Vladimir Marangozova6180282000-07-12 05:05:06 +00004843AC_CACHE_VAL(ac_cv_rshift_extends_sign, [
Matthias Kloseb159a552010-04-25 21:00:44 +00004844AC_RUN_IFELSE([AC_LANG_SOURCE([[
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00004845int main()
4846{
Vladimir Marangozova6180282000-07-12 05:05:06 +00004847 exit(((-1)>>3 == -1) ? 0 : 1);
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00004848}
Matthias Kloseb159a552010-04-25 21:00:44 +00004849]])],
4850[ac_cv_rshift_extends_sign=yes],
4851[ac_cv_rshift_extends_sign=no],
4852[ac_cv_rshift_extends_sign=yes])])
Vladimir Marangozova6180282000-07-12 05:05:06 +00004853AC_MSG_RESULT($ac_cv_rshift_extends_sign)
4854if test "$ac_cv_rshift_extends_sign" = no
4855then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00004856 AC_DEFINE(SIGNED_RIGHT_SHIFT_ZERO_FILLS, 1,
4857 [Define if i>>j for signed int i does not extend the sign bit
4858 when i < 0])
Vladimir Marangozova6180282000-07-12 05:05:06 +00004859fi
4860
Guido van Rossumcadfaec2001-01-05 14:45:49 +00004861# check for getc_unlocked and related locking functions
4862AC_MSG_CHECKING(for getc_unlocked() and friends)
4863AC_CACHE_VAL(ac_cv_have_getc_unlocked, [
Matthias Kloseb159a552010-04-25 21:00:44 +00004864AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <stdio.h>]], [[
Guido van Rossumcadfaec2001-01-05 14:45:49 +00004865 FILE *f = fopen("/dev/null", "r");
4866 flockfile(f);
4867 getc_unlocked(f);
4868 funlockfile(f);
Matthias Kloseb159a552010-04-25 21:00:44 +00004869]])],[ac_cv_have_getc_unlocked=yes],[ac_cv_have_getc_unlocked=no])])
Guido van Rossumcadfaec2001-01-05 14:45:49 +00004870AC_MSG_RESULT($ac_cv_have_getc_unlocked)
4871if test "$ac_cv_have_getc_unlocked" = yes
4872then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00004873 AC_DEFINE(HAVE_GETC_UNLOCKED, 1,
4874 [Define this if you have flockfile(), getc_unlocked(), and funlockfile()])
Guido van Rossumcadfaec2001-01-05 14:45:49 +00004875fi
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00004876
Neal Norwitzfe8e3d92006-01-07 21:07:20 +00004877# check where readline lives
Martin v. Löwis82bca632006-02-10 20:49:30 +00004878# save the value of LIBS so we don't actually link Python with readline
4879LIBS_no_readline=$LIBS
Gregory P. Smith18820942008-09-07 06:24:49 +00004880
4881# On some systems we need to link readline to a termcap compatible
4882# library. NOTE: Keep the precedence of listed libraries synchronised
4883# with setup.py.
4884py_cv_lib_readline=no
4885AC_MSG_CHECKING([how to link readline libs])
doko@ubuntu.comf2967c72012-06-30 17:32:23 +02004886for py_libtermcap in "" tinfo ncursesw ncurses curses termcap; do
Gregory P. Smith18820942008-09-07 06:24:49 +00004887 if test -z "$py_libtermcap"; then
4888 READLINE_LIBS="-lreadline"
4889 else
4890 READLINE_LIBS="-lreadline -l$py_libtermcap"
4891 fi
4892 LIBS="$READLINE_LIBS $LIBS_no_readline"
4893 AC_LINK_IFELSE(
4894 [AC_LANG_CALL([],[readline])],
4895 [py_cv_lib_readline=yes])
4896 if test $py_cv_lib_readline = yes; then
4897 break
4898 fi
4899done
4900# Uncomment this line if you want to use READINE_LIBS in Makefile or scripts
4901#AC_SUBST([READLINE_LIBS])
Gregory P. Smith97515912008-09-07 19:23:19 +00004902if test $py_cv_lib_readline = no; then
Gregory P. Smith18820942008-09-07 06:24:49 +00004903 AC_MSG_RESULT([none])
4904else
4905 AC_MSG_RESULT([$READLINE_LIBS])
4906 AC_DEFINE(HAVE_LIBREADLINE, 1,
4907 [Define if you have the readline library (-lreadline).])
Neal Norwitzfe8e3d92006-01-07 21:07:20 +00004908fi
4909
Guido van Rossumfaf5e4d2002-12-30 16:25:41 +00004910# check for readline 2.2
Matthias Kloseb159a552010-04-25 21:00:44 +00004911AC_PREPROC_IFELSE([AC_LANG_SOURCE([[#include <readline/readline.h>]])],
4912 [have_readline=yes],
4913 [have_readline=no]
4914)
Guido van Rossumfaf5e4d2002-12-30 16:25:41 +00004915if test $have_readline = yes
4916then
4917 AC_EGREP_HEADER([extern int rl_completion_append_character;],
4918 [readline/readline.h],
4919 AC_DEFINE(HAVE_RL_COMPLETION_APPEND_CHARACTER, 1,
4920 [Define if you have readline 2.2]), )
Antoine Pitroud5131772009-10-26 19:22:14 +00004921 AC_EGREP_HEADER([extern int rl_completion_suppress_append;],
4922 [readline/readline.h],
4923 AC_DEFINE(HAVE_RL_COMPLETION_SUPPRESS_APPEND, 1,
4924 [Define if you have rl_completion_suppress_append]), )
Guido van Rossumfaf5e4d2002-12-30 16:25:41 +00004925fi
4926
Martin v. Löwis0daad592001-09-30 21:09:59 +00004927# check for readline 4.0
4928AC_CHECK_LIB(readline, rl_pre_input_hook,
Martin v. Löwisc45929e2002-04-06 10:10:49 +00004929 AC_DEFINE(HAVE_RL_PRE_INPUT_HOOK, 1,
Gregory P. Smith18820942008-09-07 06:24:49 +00004930 [Define if you have readline 4.0]), ,$READLINE_LIBS)
Martin v. Löwis0daad592001-09-30 21:09:59 +00004931
Thomas Wouters89d996e2007-09-08 17:39:28 +00004932# also in 4.0
4933AC_CHECK_LIB(readline, rl_completion_display_matches_hook,
4934 AC_DEFINE(HAVE_RL_COMPLETION_DISPLAY_MATCHES_HOOK, 1,
Gregory P. Smith18820942008-09-07 06:24:49 +00004935 [Define if you have readline 4.0]), ,$READLINE_LIBS)
Thomas Wouters89d996e2007-09-08 17:39:28 +00004936
Martin Panter5dbbf1a2016-04-03 02:54:58 +00004937# also in 4.0, but not in editline
4938AC_CHECK_LIB(readline, rl_resize_terminal,
4939 AC_DEFINE(HAVE_RL_RESIZE_TERMINAL, 1,
4940 [Define if you have readline 4.0]), ,$READLINE_LIBS)
4941
Guido van Rossum353ae582001-07-10 16:45:32 +00004942# check for readline 4.2
4943AC_CHECK_LIB(readline, rl_completion_matches,
Martin v. Löwisc45929e2002-04-06 10:10:49 +00004944 AC_DEFINE(HAVE_RL_COMPLETION_MATCHES, 1,
Gregory P. Smith18820942008-09-07 06:24:49 +00004945 [Define if you have readline 4.2]), ,$READLINE_LIBS)
Guido van Rossum353ae582001-07-10 16:45:32 +00004946
Michael W. Hudson30ea2f22004-07-07 17:44:12 +00004947# also in readline 4.2
Matthias Kloseb159a552010-04-25 21:00:44 +00004948AC_PREPROC_IFELSE([AC_LANG_SOURCE([[#include <readline/readline.h>]])],
4949 [have_readline=yes],
4950 [have_readline=no]
4951)
Michael W. Hudson30ea2f22004-07-07 17:44:12 +00004952if test $have_readline = yes
4953then
4954 AC_EGREP_HEADER([extern int rl_catch_signals;],
4955 [readline/readline.h],
4956 AC_DEFINE(HAVE_RL_CATCH_SIGNAL, 1,
4957 [Define if you can turn off readline's signal handling.]), )
4958fi
4959
Benjamin Petersond1e22ba2014-11-26 14:35:12 -06004960AC_CHECK_LIB(readline, append_history,
4961 AC_DEFINE(HAVE_RL_APPEND_HISTORY, 1,
4962 [Define if readline supports append_history]), ,$READLINE_LIBS)
4963
Martin v. Löwis82bca632006-02-10 20:49:30 +00004964# End of readline checks: restore LIBS
4965LIBS=$LIBS_no_readline
4966
Thomas Wouterse38b2f12001-07-11 22:35:31 +00004967AC_MSG_CHECKING(for broken nice())
4968AC_CACHE_VAL(ac_cv_broken_nice, [
Matthias Kloseb159a552010-04-25 21:00:44 +00004969AC_RUN_IFELSE([AC_LANG_SOURCE([[
ngie-eign90c6fac2019-02-25 21:34:24 -08004970#include <stdlib.h>
4971#include <unistd.h>
Thomas Wouterse38b2f12001-07-11 22:35:31 +00004972int main()
4973{
4974 int val1 = nice(1);
4975 if (val1 != -1 && val1 == nice(2))
4976 exit(0);
4977 exit(1);
4978}
Matthias Kloseb159a552010-04-25 21:00:44 +00004979]])],
4980[ac_cv_broken_nice=yes],
4981[ac_cv_broken_nice=no],
4982[ac_cv_broken_nice=no])])
Thomas Wouterse38b2f12001-07-11 22:35:31 +00004983AC_MSG_RESULT($ac_cv_broken_nice)
4984if test "$ac_cv_broken_nice" = yes
4985then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00004986 AC_DEFINE(HAVE_BROKEN_NICE, 1,
4987 [Define if nice() returns success/failure instead of the new priority.])
Thomas Wouterse38b2f12001-07-11 22:35:31 +00004988fi
4989
Nicholas Bastine62c5c82004-03-21 23:45:42 +00004990AC_MSG_CHECKING(for broken poll())
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00004991AC_CACHE_VAL(ac_cv_broken_poll,
Matthias Kloseb159a552010-04-25 21:00:44 +00004992AC_RUN_IFELSE([AC_LANG_SOURCE([[
Nicholas Bastine62c5c82004-03-21 23:45:42 +00004993#include <poll.h>
4994
Alexandre Vassalottiaee170a2009-07-17 06:24:33 +00004995int main()
4996{
Nicholas Bastine62c5c82004-03-21 23:45:42 +00004997 struct pollfd poll_struct = { 42, POLLIN|POLLPRI|POLLOUT, 0 };
Alexandre Vassalottiaee170a2009-07-17 06:24:33 +00004998 int poll_test;
4999
Nicholas Bastine62c5c82004-03-21 23:45:42 +00005000 close (42);
5001
Alexandre Vassalottiaee170a2009-07-17 06:24:33 +00005002 poll_test = poll(&poll_struct, 1, 0);
Nicholas Bastine62c5c82004-03-21 23:45:42 +00005003 if (poll_test < 0)
Alexandre Vassalottiaee170a2009-07-17 06:24:33 +00005004 return 0;
Nicholas Bastine62c5c82004-03-21 23:45:42 +00005005 else if (poll_test == 0 && poll_struct.revents != POLLNVAL)
Alexandre Vassalottiaee170a2009-07-17 06:24:33 +00005006 return 0;
Nicholas Bastine62c5c82004-03-21 23:45:42 +00005007 else
Alexandre Vassalottiaee170a2009-07-17 06:24:33 +00005008 return 1;
5009}
Matthias Kloseb159a552010-04-25 21:00:44 +00005010]])],
5011[ac_cv_broken_poll=yes],
5012[ac_cv_broken_poll=no],
5013[ac_cv_broken_poll=no]))
Nicholas Bastine62c5c82004-03-21 23:45:42 +00005014AC_MSG_RESULT($ac_cv_broken_poll)
5015if test "$ac_cv_broken_poll" = yes
5016then
5017 AC_DEFINE(HAVE_BROKEN_POLL, 1,
5018 [Define if poll() sets errno on invalid file descriptors.])
5019fi
5020
Brett Cannon43802422005-02-10 20:48:03 +00005021# check tzset(3) exists and works like we expect it to
Guido van Rossumd11b62e2003-03-14 21:51:36 +00005022AC_MSG_CHECKING(for working tzset())
5023AC_CACHE_VAL(ac_cv_working_tzset, [
Matthias Kloseb159a552010-04-25 21:00:44 +00005024AC_RUN_IFELSE([AC_LANG_SOURCE([[
Guido van Rossumd11b62e2003-03-14 21:51:36 +00005025#include <stdlib.h>
5026#include <time.h>
Brett Cannon18367812003-09-19 00:59:16 +00005027#include <string.h>
Brett Cannon43802422005-02-10 20:48:03 +00005028
5029#if HAVE_TZNAME
5030extern char *tzname[];
5031#endif
5032
Guido van Rossumd11b62e2003-03-14 21:51:36 +00005033int main()
5034{
Brett Cannon18367812003-09-19 00:59:16 +00005035 /* Note that we need to ensure that not only does tzset(3)
5036 do 'something' with localtime, but it works as documented
5037 in the library reference and as expected by the test suite.
Brett Cannon43802422005-02-10 20:48:03 +00005038 This includes making sure that tzname is set properly if
5039 tm->tm_zone does not exist since it is the alternative way
5040 of getting timezone info.
Brett Cannon18367812003-09-19 00:59:16 +00005041
Victor Stinner1b80b242016-04-12 22:34:58 +02005042 Red Hat 6.2 doesn't understand the southern hemisphere
Brett Cannon43802422005-02-10 20:48:03 +00005043 after New Year's Day.
Brett Cannon18367812003-09-19 00:59:16 +00005044 */
5045
Brett Cannon43802422005-02-10 20:48:03 +00005046 time_t groundhogday = 1044144000; /* GMT-based */
Brett Cannon18367812003-09-19 00:59:16 +00005047 time_t midyear = groundhogday + (365 * 24 * 3600 / 2);
5048
Neal Norwitz7f2588c2003-04-11 15:35:53 +00005049 putenv("TZ=UTC+0");
Guido van Rossumd11b62e2003-03-14 21:51:36 +00005050 tzset();
Brett Cannon18367812003-09-19 00:59:16 +00005051 if (localtime(&groundhogday)->tm_hour != 0)
5052 exit(1);
Brett Cannon43802422005-02-10 20:48:03 +00005053#if HAVE_TZNAME
5054 /* For UTC, tzname[1] is sometimes "", sometimes " " */
Victor Stinner1b80b242016-04-12 22:34:58 +02005055 if (strcmp(tzname[0], "UTC") ||
Brett Cannon43802422005-02-10 20:48:03 +00005056 (tzname[1][0] != 0 && tzname[1][0] != ' '))
5057 exit(1);
5058#endif
Brett Cannon18367812003-09-19 00:59:16 +00005059
Neal Norwitz7f2588c2003-04-11 15:35:53 +00005060 putenv("TZ=EST+5EDT,M4.1.0,M10.5.0");
Guido van Rossumd11b62e2003-03-14 21:51:36 +00005061 tzset();
Brett Cannon18367812003-09-19 00:59:16 +00005062 if (localtime(&groundhogday)->tm_hour != 19)
Guido van Rossumd11b62e2003-03-14 21:51:36 +00005063 exit(1);
Brett Cannon43802422005-02-10 20:48:03 +00005064#if HAVE_TZNAME
5065 if (strcmp(tzname[0], "EST") || strcmp(tzname[1], "EDT"))
5066 exit(1);
5067#endif
Brett Cannon18367812003-09-19 00:59:16 +00005068
5069 putenv("TZ=AEST-10AEDT-11,M10.5.0,M3.5.0");
5070 tzset();
5071 if (localtime(&groundhogday)->tm_hour != 11)
5072 exit(1);
Brett Cannon43802422005-02-10 20:48:03 +00005073#if HAVE_TZNAME
5074 if (strcmp(tzname[0], "AEST") || strcmp(tzname[1], "AEDT"))
5075 exit(1);
5076#endif
5077
5078#if HAVE_STRUCT_TM_TM_ZONE
Brett Cannon18367812003-09-19 00:59:16 +00005079 if (strcmp(localtime(&groundhogday)->tm_zone, "AEDT"))
5080 exit(1);
5081 if (strcmp(localtime(&midyear)->tm_zone, "AEST"))
5082 exit(1);
Brett Cannon43802422005-02-10 20:48:03 +00005083#endif
Brett Cannon18367812003-09-19 00:59:16 +00005084
Guido van Rossumd11b62e2003-03-14 21:51:36 +00005085 exit(0);
5086}
Matthias Kloseb159a552010-04-25 21:00:44 +00005087]])],
5088[ac_cv_working_tzset=yes],
5089[ac_cv_working_tzset=no],
5090[ac_cv_working_tzset=no])])
Guido van Rossumd11b62e2003-03-14 21:51:36 +00005091AC_MSG_RESULT($ac_cv_working_tzset)
5092if test "$ac_cv_working_tzset" = yes
5093then
5094 AC_DEFINE(HAVE_WORKING_TZSET, 1,
5095 [Define if tzset() actually switches the local timezone in a meaningful way.])
5096fi
5097
Martin v. Löwis94717ed2002-09-09 14:24:16 +00005098# Look for subsecond timestamps in struct stat
5099AC_MSG_CHECKING(for tv_nsec in struct stat)
5100AC_CACHE_VAL(ac_cv_stat_tv_nsec,
Matthias Kloseb159a552010-04-25 21:00:44 +00005101AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/stat.h>]], [[
Martin v. Löwis94717ed2002-09-09 14:24:16 +00005102struct stat st;
5103st.st_mtim.tv_nsec = 1;
Matthias Kloseb159a552010-04-25 21:00:44 +00005104]])],
5105[ac_cv_stat_tv_nsec=yes],
5106[ac_cv_stat_tv_nsec=no]))
Martin v. Löwis94717ed2002-09-09 14:24:16 +00005107AC_MSG_RESULT($ac_cv_stat_tv_nsec)
5108if test "$ac_cv_stat_tv_nsec" = yes
5109then
5110 AC_DEFINE(HAVE_STAT_TV_NSEC, 1,
5111 [Define if you have struct stat.st_mtim.tv_nsec])
5112fi
5113
Martin v. Löwisebd9d5b2005-08-09 15:00:59 +00005114# Look for BSD style subsecond timestamps in struct stat
5115AC_MSG_CHECKING(for tv_nsec2 in struct stat)
5116AC_CACHE_VAL(ac_cv_stat_tv_nsec2,
Matthias Kloseb159a552010-04-25 21:00:44 +00005117AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/stat.h>]], [[
Martin v. Löwisebd9d5b2005-08-09 15:00:59 +00005118struct stat st;
5119st.st_mtimespec.tv_nsec = 1;
Matthias Kloseb159a552010-04-25 21:00:44 +00005120]])],
5121[ac_cv_stat_tv_nsec2=yes],
5122[ac_cv_stat_tv_nsec2=no]))
Martin v. Löwisebd9d5b2005-08-09 15:00:59 +00005123AC_MSG_RESULT($ac_cv_stat_tv_nsec2)
5124if test "$ac_cv_stat_tv_nsec2" = yes
5125then
5126 AC_DEFINE(HAVE_STAT_TV_NSEC2, 1,
5127 [Define if you have struct stat.st_mtimensec])
5128fi
5129
doko@ubuntu.com1a4f5612014-04-17 20:13:44 +02005130# first curses header check
doko@ubuntu.com9dc823d2012-07-07 03:06:42 +02005131ac_save_cppflags="$CPPFLAGS"
Xavier de Gayee13c3202016-12-13 16:04:14 +01005132if test "$cross_compiling" = no; then
5133 CPPFLAGS="$CPPFLAGS -I/usr/include/ncursesw"
5134fi
doko@ubuntu.com1a4f5612014-04-17 20:13:44 +02005135
5136AC_CHECK_HEADERS(curses.h ncurses.h)
5137
5138# On Solaris, term.h requires curses.h
5139AC_CHECK_HEADERS(term.h,,,[
5140#ifdef HAVE_CURSES_H
5141#include <curses.h>
5142#endif
5143])
5144
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00005145# On HP/UX 11.0, mvwdelch is a block with a return statement
5146AC_MSG_CHECKING(whether mvwdelch is an expression)
5147AC_CACHE_VAL(ac_cv_mvwdelch_is_expression,
Matthias Kloseb159a552010-04-25 21:00:44 +00005148AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <curses.h>]], [[
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00005149 int rtn;
5150 rtn = mvwdelch(0,0,0);
Matthias Kloseb159a552010-04-25 21:00:44 +00005151]])],
5152[ac_cv_mvwdelch_is_expression=yes],
5153[ac_cv_mvwdelch_is_expression=no]))
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00005154AC_MSG_RESULT($ac_cv_mvwdelch_is_expression)
5155
5156if test "$ac_cv_mvwdelch_is_expression" = yes
5157then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00005158 AC_DEFINE(MVWDELCH_IS_EXPRESSION, 1,
5159 [Define if mvwdelch in curses.h is an expression.])
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00005160fi
5161
Masayuki Yamamoto8bc7d632017-11-01 21:05:26 +09005162# Issue #25720: ncurses has introduced the NCURSES_OPAQUE symbol making opaque
5163# structs since version 5.7. If the macro is defined as zero before including
5164# [n]curses.h, ncurses will expose fields of the structs regardless of the
5165# configuration.
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00005166AC_MSG_CHECKING(whether WINDOW has _flags)
5167AC_CACHE_VAL(ac_cv_window_has_flags,
Masayuki Yamamoto8bc7d632017-11-01 21:05:26 +09005168AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
5169 #define NCURSES_OPAQUE 0
5170 #include <curses.h>
5171]], [[
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00005172 WINDOW *w;
5173 w->_flags = 0;
Matthias Kloseb159a552010-04-25 21:00:44 +00005174]])],
5175[ac_cv_window_has_flags=yes],
5176[ac_cv_window_has_flags=no]))
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00005177AC_MSG_RESULT($ac_cv_window_has_flags)
5178
5179
5180if test "$ac_cv_window_has_flags" = yes
5181then
Victor Stinner1b80b242016-04-12 22:34:58 +02005182 AC_DEFINE(WINDOW_HAS_FLAGS, 1,
Martin v. Löwisc45929e2002-04-06 10:10:49 +00005183 [Define if WINDOW in curses.h offers a field _flags.])
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00005184fi
5185
Masayuki Yamamoto8bc7d632017-11-01 21:05:26 +09005186AC_MSG_CHECKING(for is_pad)
5187AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <curses.h>]], [[
5188#ifndef is_pad
5189void *x=is_pad
5190#endif
5191]])],
5192 [AC_DEFINE(HAVE_CURSES_IS_PAD, 1, Define if you have the 'is_pad' function or macro.)
5193 AC_MSG_RESULT(yes)],
5194 [AC_MSG_RESULT(no)]
5195)
5196
Thomas Wouters0e3f5912006-08-11 14:57:12 +00005197AC_MSG_CHECKING(for is_term_resized)
Matthias Kloseb159a552010-04-25 21:00:44 +00005198AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <curses.h>]], [[void *x=is_term_resized]])],
5199 [AC_DEFINE(HAVE_CURSES_IS_TERM_RESIZED, 1, Define if you have the 'is_term_resized' function.)
5200 AC_MSG_RESULT(yes)],
5201 [AC_MSG_RESULT(no)]
Thomas Wouters0e3f5912006-08-11 14:57:12 +00005202)
Martin v. Löwis24a880b2002-12-31 12:55:15 +00005203
Thomas Wouters0e3f5912006-08-11 14:57:12 +00005204AC_MSG_CHECKING(for resize_term)
Matthias Kloseb159a552010-04-25 21:00:44 +00005205AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <curses.h>]], [[void *x=resize_term]])],
5206 [AC_DEFINE(HAVE_CURSES_RESIZE_TERM, 1, Define if you have the 'resize_term' function.)
5207 AC_MSG_RESULT(yes)],
5208 [AC_MSG_RESULT(no)]
Thomas Wouters0e3f5912006-08-11 14:57:12 +00005209)
5210
5211AC_MSG_CHECKING(for resizeterm)
Matthias Kloseb159a552010-04-25 21:00:44 +00005212AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <curses.h>]], [[void *x=resizeterm]])],
5213 [AC_DEFINE(HAVE_CURSES_RESIZETERM, 1, Define if you have the 'resizeterm' function.)
5214 AC_MSG_RESULT(yes)],
5215 [AC_MSG_RESULT(no)]
Thomas Wouters0e3f5912006-08-11 14:57:12 +00005216)
Serhiy Storchakabaac01e2017-10-31 13:56:44 +02005217
5218AC_MSG_CHECKING(for immedok)
5219AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <curses.h>]], [[
5220#ifndef immedok
5221void *x=immedok
5222#endif
5223]])],
5224 [AC_DEFINE(HAVE_CURSES_IMMEDOK, 1, Define if you have the 'immedok' function.)
5225 AC_MSG_RESULT(yes)],
5226 [AC_MSG_RESULT(no)]
5227)
5228
5229AC_MSG_CHECKING(for syncok)
5230AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <curses.h>]], [[
5231#ifndef syncok
5232void *x=syncok
5233#endif
5234]])],
5235 [AC_DEFINE(HAVE_CURSES_SYNCOK, 1, Define if you have the 'syncok' function.)
5236 AC_MSG_RESULT(yes)],
5237 [AC_MSG_RESULT(no)]
5238)
5239
Serhiy Storchaka894ebd02017-11-01 14:34:20 +02005240AC_MSG_CHECKING(for wchgat)
5241AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <curses.h>]], [[
5242#ifndef wchgat
5243void *x=wchgat
5244#endif
5245]])],
5246 [AC_DEFINE(HAVE_CURSES_WCHGAT, 1, Define if you have the 'wchgat' function.)
5247 AC_MSG_RESULT(yes)],
5248 [AC_MSG_RESULT(no)]
5249)
5250
Serhiy Storchakabaac01e2017-10-31 13:56:44 +02005251AC_MSG_CHECKING(for filter)
5252AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <curses.h>]], [[
5253#ifndef filter
5254void *x=filter
5255#endif
5256]])],
5257 [AC_DEFINE(HAVE_CURSES_FILTER, 1, Define if you have the 'filter' function.)
5258 AC_MSG_RESULT(yes)],
5259 [AC_MSG_RESULT(no)]
5260)
5261
5262AC_MSG_CHECKING(for has_key)
5263AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <curses.h>]], [[
5264#ifndef has_key
5265void *x=has_key
5266#endif
5267]])],
5268 [AC_DEFINE(HAVE_CURSES_HAS_KEY, 1, Define if you have the 'has_key' function.)
5269 AC_MSG_RESULT(yes)],
5270 [AC_MSG_RESULT(no)]
5271)
5272
5273AC_MSG_CHECKING(for typeahead)
5274AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <curses.h>]], [[
5275#ifndef typeahead
5276void *x=typeahead
5277#endif
5278]])],
5279 [AC_DEFINE(HAVE_CURSES_TYPEAHEAD, 1, Define if you have the 'typeahead' function.)
5280 AC_MSG_RESULT(yes)],
5281 [AC_MSG_RESULT(no)]
5282)
5283
5284AC_MSG_CHECKING(for use_env)
5285AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <curses.h>]], [[
5286#ifndef use_env
5287void *x=use_env
5288#endif
5289]])],
5290 [AC_DEFINE(HAVE_CURSES_USE_ENV, 1, Define if you have the 'use_env' function.)
5291 AC_MSG_RESULT(yes)],
5292 [AC_MSG_RESULT(no)]
5293)
doko@ubuntu.com9dc823d2012-07-07 03:06:42 +02005294# last curses configure check
5295CPPFLAGS=$ac_save_cppflags
Thomas Wouters0e3f5912006-08-11 14:57:12 +00005296
doko@ubuntu.comb457b9b2012-06-30 19:28:16 +02005297AC_MSG_NOTICE([checking for device files])
Thomas Wouters89f507f2006-12-13 04:49:30 +00005298
doko@ubuntu.comb457b9b2012-06-30 19:28:16 +02005299dnl NOTE: Inform user how to proceed with files when cross compiling.
5300if test "x$cross_compiling" = xyes; then
5301 if test "${ac_cv_file__dev_ptmx+set}" != set; then
5302 AC_MSG_CHECKING([for /dev/ptmx])
5303 AC_MSG_RESULT([not set])
5304 AC_MSG_ERROR([set ac_cv_file__dev_ptmx to yes/no in your CONFIG_SITE file when cross compiling])
5305 fi
5306 if test "${ac_cv_file__dev_ptc+set}" != set; then
5307 AC_MSG_CHECKING([for /dev/ptc])
5308 AC_MSG_RESULT([not set])
5309 AC_MSG_ERROR([set ac_cv_file__dev_ptc to yes/no in your CONFIG_SITE file when cross compiling])
5310 fi
Thomas Wouters89f507f2006-12-13 04:49:30 +00005311fi
5312
doko@ubuntu.comb457b9b2012-06-30 19:28:16 +02005313AC_CHECK_FILE(/dev/ptmx, [], [])
5314if test "x$ac_cv_file__dev_ptmx" = xyes; then
5315 AC_DEFINE(HAVE_DEV_PTMX, 1,
5316 [Define to 1 if you have the /dev/ptmx device file.])
5317fi
5318AC_CHECK_FILE(/dev/ptc, [], [])
5319if test "x$ac_cv_file__dev_ptc" = xyes; then
Thomas Wouters89f507f2006-12-13 04:49:30 +00005320 AC_DEFINE(HAVE_DEV_PTC, 1,
doko@ubuntu.comb457b9b2012-06-30 19:28:16 +02005321 [Define to 1 if you have the /dev/ptc device file.])
Thomas Wouters89f507f2006-12-13 04:49:30 +00005322fi
Neal Norwitz865400f2003-03-21 01:42:58 +00005323
Ronald Oussoren3c1928a2009-11-19 17:15:31 +00005324if test $ac_sys_system = Darwin
5325then
5326 LIBS="$LIBS -framework CoreFoundation"
5327fi
Mark Dickinson6ce4a9a2009-11-16 17:00:11 +00005328
Benjamin Peterson8f326b22009-12-13 02:10:36 +00005329AC_CACHE_CHECK([for %zd printf() format support], ac_cv_have_size_t_format, [dnl
Matthias Kloseb159a552010-04-25 21:00:44 +00005330AC_RUN_IFELSE([AC_LANG_SOURCE([[
Alexandre Vassalottie5091f62009-07-17 06:41:02 +00005331#include <stdio.h>
Thomas Wouters477c8d52006-05-27 19:21:47 +00005332#include <stddef.h>
5333#include <string.h>
5334
Christian Heimes2c181612007-12-17 20:04:13 +00005335#ifdef HAVE_SYS_TYPES_H
5336#include <sys/types.h>
5337#endif
Thomas Wouters89f507f2006-12-13 04:49:30 +00005338
5339#ifdef HAVE_SSIZE_T
5340typedef ssize_t Py_ssize_t;
5341#elif SIZEOF_VOID_P == SIZEOF_LONG
5342typedef long Py_ssize_t;
5343#else
5344typedef int Py_ssize_t;
5345#endif
Thomas Wouters477c8d52006-05-27 19:21:47 +00005346
Christian Heimes2c181612007-12-17 20:04:13 +00005347int main()
5348{
5349 char buffer[256];
5350
Thomas Wouters477c8d52006-05-27 19:21:47 +00005351 if(sprintf(buffer, "%zd", (size_t)123) < 0)
5352 return 1;
5353
Thomas Wouters89f507f2006-12-13 04:49:30 +00005354 if (strcmp(buffer, "123"))
Thomas Wouters477c8d52006-05-27 19:21:47 +00005355 return 1;
Thomas Wouters89f507f2006-12-13 04:49:30 +00005356
5357 if (sprintf(buffer, "%zd", (Py_ssize_t)-123) < 0)
5358 return 1;
5359
5360 if (strcmp(buffer, "-123"))
5361 return 1;
5362
Thomas Wouters477c8d52006-05-27 19:21:47 +00005363 return 0;
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00005364}
Matthias Kloseb159a552010-04-25 21:00:44 +00005365]])],
5366 [ac_cv_have_size_t_format=yes],
5367 [ac_cv_have_size_t_format=no],
5368 [ac_cv_have_size_t_format="cross -- assuming yes"
5369])])
Benjamin Peterson8f326b22009-12-13 02:10:36 +00005370if test "$ac_cv_have_size_t_format" != no ; then
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00005371 AC_DEFINE(PY_FORMAT_SIZE_T, "z",
5372 [Define to printf format modifier for Py_ssize_t])
5373fi
Thomas Wouters477c8d52006-05-27 19:21:47 +00005374
Martin v. Löwis01c04012002-11-11 14:58:44 +00005375AC_CHECK_TYPE(socklen_t,,
5376 AC_DEFINE(socklen_t,int,
Matthias Klosec80c93f2010-04-24 17:04:35 +00005377 [Define to `int' if <sys/socket.h> does not define.]),[
Martin v. Löwis01c04012002-11-11 14:58:44 +00005378#ifdef HAVE_SYS_TYPES_H
5379#include <sys/types.h>
5380#endif
Guido van Rossum95713eb2000-05-18 20:53:31 +00005381#ifdef HAVE_SYS_SOCKET_H
5382#include <sys/socket.h>
5383#endif
Martin v. Löwis01c04012002-11-11 14:58:44 +00005384])
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00005385
Antoine Pitroufff95302008-09-03 18:58:51 +00005386AC_MSG_CHECKING(for broken mbstowcs)
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00005387AC_CACHE_VAL(ac_cv_broken_mbstowcs,
Matthias Kloseb159a552010-04-25 21:00:44 +00005388AC_RUN_IFELSE([AC_LANG_SOURCE([[
Stefan Krah19c21392012-11-22 23:47:32 +01005389#include <stdio.h>
Antoine Pitroufff95302008-09-03 18:58:51 +00005390#include<stdlib.h>
5391int main() {
5392 size_t len = -1;
5393 const char *str = "text";
5394 len = mbstowcs(NULL, str, 0);
5395 return (len != 4);
5396}
Matthias Kloseb159a552010-04-25 21:00:44 +00005397]])],
5398[ac_cv_broken_mbstowcs=no],
5399[ac_cv_broken_mbstowcs=yes],
5400[ac_cv_broken_mbstowcs=no]))
Antoine Pitroufff95302008-09-03 18:58:51 +00005401AC_MSG_RESULT($ac_cv_broken_mbstowcs)
5402if test "$ac_cv_broken_mbstowcs" = yes
5403then
5404 AC_DEFINE(HAVE_BROKEN_MBSTOWCS, 1,
Victor Stinner1b80b242016-04-12 22:34:58 +02005405 [Define if mbstowcs(NULL, "text", 0) does not return the number of
Antoine Pitroufff95302008-09-03 18:58:51 +00005406 wide chars that would be converted.])
5407fi
5408
Antoine Pitroub52ec782009-01-25 16:34:23 +00005409# Check for --with-computed-gotos
5410AC_MSG_CHECKING(for --with-computed-gotos)
5411AC_ARG_WITH(computed-gotos,
Anthony Shaw2de064e2020-01-14 17:40:10 +11005412 AS_HELP_STRING([--with-computed-gotos],
5413 [enable computed gotos in evaluation loop (enabled by default on supported compilers)]),
Antoine Pitroub52ec782009-01-25 16:34:23 +00005414[
Antoine Pitrou042b1282010-08-13 21:15:58 +00005415if test "$withval" = yes
Victor Stinner1b80b242016-04-12 22:34:58 +02005416then
Antoine Pitroub52ec782009-01-25 16:34:23 +00005417 AC_DEFINE(USE_COMPUTED_GOTOS, 1,
Victor Stinner1b80b242016-04-12 22:34:58 +02005418 [Define if you want to use computed gotos in ceval.c.])
Antoine Pitroub52ec782009-01-25 16:34:23 +00005419 AC_MSG_RESULT(yes)
Antoine Pitrou042b1282010-08-13 21:15:58 +00005420fi
5421if test "$withval" = no
Victor Stinner1b80b242016-04-12 22:34:58 +02005422then
Antoine Pitrou042b1282010-08-13 21:15:58 +00005423 AC_DEFINE(USE_COMPUTED_GOTOS, 0,
Victor Stinner1b80b242016-04-12 22:34:58 +02005424 [Define if you want to use computed gotos in ceval.c.])
Antoine Pitrou042b1282010-08-13 21:15:58 +00005425 AC_MSG_RESULT(no)
5426fi
5427],
5428[AC_MSG_RESULT(no value specified)])
Antoine Pitroub52ec782009-01-25 16:34:23 +00005429
Matthias Kloseb17289e2012-03-15 19:51:34 +01005430AC_MSG_CHECKING(whether $CC supports computed gotos)
5431AC_CACHE_VAL(ac_cv_computed_gotos,
5432AC_RUN_IFELSE([AC_LANG_SOURCE([[[
5433int main(int argc, char **argv)
5434{
5435 static void *targets[1] = { &&LABEL1 };
5436 goto LABEL2;
5437LABEL1:
5438 return 0;
5439LABEL2:
5440 goto *targets[0];
5441 return 1;
5442}
5443]]])],
5444[ac_cv_computed_gotos=yes],
5445[ac_cv_computed_gotos=no],
5446[if test "${with_computed_gotos+set}" = set; then
5447 ac_cv_computed_gotos="$with_computed_gotos -- configured --with(out)-computed-gotos"
5448 else
5449 ac_cv_computed_gotos=no
5450 fi]))
5451AC_MSG_RESULT($ac_cv_computed_gotos)
5452case "$ac_cv_computed_gotos" in yes*)
5453 AC_DEFINE(HAVE_COMPUTED_GOTOS, 1,
5454 [Define if the C compiler supports computed gotos.])
5455esac
5456
R. David Murraye16cda92010-10-15 23:12:57 +00005457case $ac_sys_system in
Victor Stinner1b80b242016-04-12 22:34:58 +02005458AIX*)
R. David Murraye16cda92010-10-15 23:12:57 +00005459 AC_DEFINE(HAVE_BROKEN_PIPE_BUF, 1, [Define if the system reports an invalid PIPE_BUF value.]) ;;
5460esac
Antoine Pitroub52ec782009-01-25 16:34:23 +00005461
Jesus Cea6a792292010-05-03 21:18:48 +00005462
Martin v. Löwis06f15bb2001-12-02 13:02:32 +00005463AC_SUBST(THREADHEADERS)
5464
5465for h in `(cd $srcdir;echo Python/thread_*.h)`
5466do
5467 THREADHEADERS="$THREADHEADERS \$(srcdir)/$h"
5468done
5469
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00005470AC_SUBST(SRCDIRS)
Pablo Galindo1ed83ad2020-06-11 17:30:46 +01005471SRCDIRS="Parser Objects Python Modules Modules/_io Programs"
Andrew M. Kuchling8abedde2001-01-26 22:55:24 +00005472AC_MSG_CHECKING(for build directories)
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00005473for dir in $SRCDIRS; do
5474 if test ! -d $dir; then
5475 mkdir $dir
Fred Drake884d3ba2000-11-02 17:52:56 +00005476 fi
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00005477done
5478AC_MSG_RESULT(done)
Fred Drake036144d2000-10-26 17:09:35 +00005479
Stefan Krah1919b7e2012-03-21 18:25:23 +01005480# Availability of -O2:
5481AC_MSG_CHECKING(for -O2)
5482saved_cflags="$CFLAGS"
5483CFLAGS="-O2"
5484AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
5485]])],[have_O2=yes],[have_O2=no])
5486AC_MSG_RESULT($have_O2)
5487CFLAGS="$saved_cflags"
5488
5489# _FORTIFY_SOURCE wrappers for memmove and bcopy are incorrect:
5490# http://sourceware.org/ml/libc-alpha/2010-12/msg00009.html
5491AC_MSG_CHECKING(for glibc _FORTIFY_SOURCE/memmove bug)
5492saved_cflags="$CFLAGS"
5493CFLAGS="-O2 -D_FORTIFY_SOURCE=2"
5494if test "$have_O2" = no; then
5495 CFLAGS=""
5496fi
5497AC_RUN_IFELSE([AC_LANG_SOURCE([[
5498#include <stdio.h>
5499#include <stdlib.h>
5500#include <string.h>
5501void foo(void *p, void *q) { memmove(p, q, 19); }
5502int main() {
5503 char a[32] = "123456789000000000";
5504 foo(&a[9], a);
5505 if (strcmp(a, "123456789123456789000000000") != 0)
5506 return 1;
5507 foo(a, &a[9]);
5508 if (strcmp(a, "123456789000000000") != 0)
5509 return 1;
5510 return 0;
5511}
5512]])],
5513[have_glibc_memmove_bug=no],
5514[have_glibc_memmove_bug=yes],
5515[have_glibc_memmove_bug=undefined])
5516CFLAGS="$saved_cflags"
5517AC_MSG_RESULT($have_glibc_memmove_bug)
5518if test "$have_glibc_memmove_bug" = yes; then
5519 AC_DEFINE(HAVE_GLIBC_MEMMOVE_BUG, 1,
5520 [Define if glibc has incorrect _FORTIFY_SOURCE wrappers
5521 for memmove and bcopy.])
5522fi
5523
5524if test "$have_gcc_asm_for_x87" = yes; then
5525 # Some versions of gcc miscompile inline asm:
5526 # http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46491
5527 # http://gcc.gnu.org/ml/gcc/2010-11/msg00366.html
5528 case $CC in
5529 *gcc*)
5530 AC_MSG_CHECKING(for gcc ipa-pure-const bug)
5531 saved_cflags="$CFLAGS"
5532 CFLAGS="-O2"
5533 AC_RUN_IFELSE([AC_LANG_SOURCE([[
5534 __attribute__((noinline)) int
5535 foo(int *p) {
5536 int r;
5537 asm ( "movl \$6, (%1)\n\t"
5538 "xorl %0, %0\n\t"
5539 : "=r" (r) : "r" (p) : "memory"
5540 );
5541 return r;
5542 }
5543 int main() {
5544 int p = 8;
5545 if ((foo(&p) ? : p) != 6)
5546 return 1;
5547 return 0;
5548 }
5549 ]])],
5550 [have_ipa_pure_const_bug=no],
5551 [have_ipa_pure_const_bug=yes],
5552 [have_ipa_pure_const_bug=undefined])
5553 CFLAGS="$saved_cflags"
5554 AC_MSG_RESULT($have_ipa_pure_const_bug)
5555 if test "$have_ipa_pure_const_bug" = yes; then
5556 AC_DEFINE(HAVE_IPA_PURE_CONST_BUG, 1,
5557 [Define if gcc has the ipa-pure-const bug.])
5558 fi
5559 ;;
5560 esac
5561fi
5562
Victor Stinner4f5366e2015-01-09 02:13:19 +01005563# Check for stdatomic.h
5564AC_MSG_CHECKING(for stdatomic.h)
5565AC_LINK_IFELSE(
5566[
5567 AC_LANG_SOURCE([[
5568 #include <stdatomic.h>
Victor Stinner028f7342019-10-22 21:53:50 +02005569 atomic_int int_var;
5570 atomic_uintptr_t uintptr_var;
Victor Stinner4f5366e2015-01-09 02:13:19 +01005571 int main() {
Victor Stinner028f7342019-10-22 21:53:50 +02005572 atomic_store_explicit(&int_var, 5, memory_order_relaxed);
5573 atomic_store_explicit(&uintptr_var, 0, memory_order_relaxed);
5574 int loaded_value = atomic_load_explicit(&int_var, memory_order_seq_cst);
Victor Stinner4f5366e2015-01-09 02:13:19 +01005575 return 0;
5576 }
5577 ]])
5578],[have_stdatomic_h=yes],[have_stdatomic_h=no])
5579
5580AC_MSG_RESULT($have_stdatomic_h)
5581
5582if test "$have_stdatomic_h" = yes; then
Victor Stinner923e06f2015-01-14 16:01:46 +01005583 AC_DEFINE(HAVE_STD_ATOMIC, 1,
Victor Stinner028f7342019-10-22 21:53:50 +02005584 [Has stdatomic.h with atomic_int and atomic_uintptr_t])
Victor Stinner4f5366e2015-01-09 02:13:19 +01005585fi
5586
5587# Check for GCC >= 4.7 __atomic builtins
5588AC_MSG_CHECKING(for GCC >= 4.7 __atomic builtins)
5589AC_LINK_IFELSE(
5590[
5591 AC_LANG_SOURCE([[
5592 volatile int val = 1;
5593 int main() {
5594 __atomic_load_n(&val, __ATOMIC_SEQ_CST);
5595 return 0;
5596 }
5597 ]])
5598],[have_builtin_atomic=yes],[have_builtin_atomic=no])
5599
5600AC_MSG_RESULT($have_builtin_atomic)
5601
5602if test "$have_builtin_atomic" = yes; then
5603 AC_DEFINE(HAVE_BUILTIN_ATOMIC, 1, [Has builtin atomics])
5604fi
5605
Ned Deily322f5ba2013-11-21 23:01:59 -08005606# ensurepip option
5607AC_MSG_CHECKING(for ensurepip)
5608AC_ARG_WITH(ensurepip,
Anthony Shaw2de064e2020-01-14 17:40:10 +11005609 [AS_HELP_STRING([--with-ensurepip@<:@=install|upgrade|no@:>@],
5610 ["install" or "upgrade" using bundled pip (default is upgrade)])],
Ned Deily322f5ba2013-11-21 23:01:59 -08005611 [],
5612 [with_ensurepip=upgrade])
5613AS_CASE($with_ensurepip,
5614 [yes|upgrade],[ENSUREPIP=upgrade],
5615 [install],[ENSUREPIP=install],
5616 [no],[ENSUREPIP=no],
5617 [AC_MSG_ERROR([--with-ensurepip=upgrade|install|no])])
5618AC_MSG_RESULT($ENSUREPIP)
5619AC_SUBST(ENSUREPIP)
5620
Victor Stinner35a97c02015-03-08 02:59:09 +01005621# check if the dirent structure of a d_type field and DT_UNKNOWN is defined
5622AC_MSG_CHECKING(if the dirent structure of a d_type field)
5623AC_LINK_IFELSE(
5624[
5625 AC_LANG_SOURCE([[
5626 #include <dirent.h>
5627
5628 int main() {
5629 struct dirent entry;
5630 return entry.d_type == DT_UNKNOWN;
5631 }
5632 ]])
5633],[have_dirent_d_type=yes],[have_dirent_d_type=no])
5634AC_MSG_RESULT($have_dirent_d_type)
5635
5636if test "$have_dirent_d_type" = yes; then
5637 AC_DEFINE(HAVE_DIRENT_D_TYPE, 1,
5638 [Define to 1 if the dirent structure has a d_type field])
5639fi
5640
Victor Stinner9eb57c52015-03-19 22:21:49 +01005641# check if the Linux getrandom() syscall is available
5642AC_MSG_CHECKING(for the Linux getrandom() syscall)
5643AC_LINK_IFELSE(
5644[
5645 AC_LANG_SOURCE([[
Victor Stinner1b80b242016-04-12 22:34:58 +02005646 #include <unistd.h>
Victor Stinner9eb57c52015-03-19 22:21:49 +01005647 #include <sys/syscall.h>
Victor Stinnerdddf4842016-06-07 11:21:42 +02005648 #include <linux/random.h>
Victor Stinner9eb57c52015-03-19 22:21:49 +01005649
5650 int main() {
Victor Stinner9eb57c52015-03-19 22:21:49 +01005651 char buffer[1];
Victor Stinner3abf44e2015-09-18 15:38:37 +02005652 const size_t buflen = sizeof(buffer);
Victor Stinnerdddf4842016-06-07 11:21:42 +02005653 const int flags = GRND_NONBLOCK;
5654 /* ignore the result, Python checks for ENOSYS and EAGAIN at runtime */
Victor Stinner3abf44e2015-09-18 15:38:37 +02005655 (void)syscall(SYS_getrandom, buffer, buflen, flags);
Victor Stinner9eb57c52015-03-19 22:21:49 +01005656 return 0;
5657 }
5658 ]])
5659],[have_getrandom_syscall=yes],[have_getrandom_syscall=no])
5660AC_MSG_RESULT($have_getrandom_syscall)
5661
5662if test "$have_getrandom_syscall" = yes; then
5663 AC_DEFINE(HAVE_GETRANDOM_SYSCALL, 1,
5664 [Define to 1 if the Linux getrandom() syscall is available])
5665fi
5666
Victor Stinner3abf44e2015-09-18 15:38:37 +02005667# check if the getrandom() function is available
5668# the test was written for the Solaris function of <sys/random.h>
5669AC_MSG_CHECKING(for the getrandom() function)
5670AC_LINK_IFELSE(
5671[
5672 AC_LANG_SOURCE([[
5673 #include <sys/random.h>
5674
5675 int main() {
5676 char buffer[1];
5677 const size_t buflen = sizeof(buffer);
5678 const int flags = 0;
5679 /* ignore the result, Python checks for ENOSYS at runtime */
5680 (void)getrandom(buffer, buflen, flags);
5681 return 0;
5682 }
5683 ]])
5684],[have_getrandom=yes],[have_getrandom=no])
5685AC_MSG_RESULT($have_getrandom)
5686
5687if test "$have_getrandom" = yes; then
5688 AC_DEFINE(HAVE_GETRANDOM, 1,
5689 [Define to 1 if the getrandom() function is available])
5690fi
5691
Neil Schemenauer5741c452019-02-08 10:48:46 -08005692# checks for POSIX shared memory, used by Modules/_multiprocessing/posixshmem.c
5693# shm_* may only be available if linking against librt
5694save_LIBS="$LIBS"
5695save_includes_default="$ac_includes_default"
5696AC_SEARCH_LIBS(shm_open, rt)
5697if test "$ac_cv_search_shm_open" = "-lrt"; then
5698 AC_DEFINE(SHM_NEEDS_LIBRT, 1,
5699 [Define to 1 if you must link with -lrt for shm_open().])
5700fi
5701AC_CHECK_HEADERS(sys/mman.h)
5702# temporarily override ac_includes_default for AC_CHECK_FUNCS below
5703ac_includes_default="\
5704${ac_includes_default}
5705#ifndef __cplusplus
5706# ifdef HAVE_SYS_MMAN_H
5707# include <sys/mman.h>
5708# endif
5709#endif
5710"
5711AC_CHECK_FUNCS([shm_open shm_unlink])
5712# we don't want to link with librt always, restore LIBS
5713LIBS="$save_LIBS"
5714ac_includes_default="$save_includes_default"
5715
Christian Heimesff5be6e2018-01-20 13:19:21 +01005716# Check for usable OpenSSL
5717AX_CHECK_OPENSSL([have_openssl=yes],[have_openssl=no])
5718
5719if test "$have_openssl" = yes; then
5720 AC_MSG_CHECKING([for X509_VERIFY_PARAM_set1_host in libssl])
5721
5722 save_LIBS="$LIBS"
5723 save_LDFLAGS="$LDFLAGS"
5724 save_CPPFLAGS="$CPPFLAGS"
5725 LDFLAGS="$LDFLAGS $OPENSSL_LDFLAGS"
5726 LIBS="$OPENSSL_LIBS $LIBS"
5727 CPPFLAGS="$OPENSSL_INCLUDES $CPPFLAGS"
5728
5729 AC_LINK_IFELSE([AC_LANG_PROGRAM([
5730 [#include <openssl/x509_vfy.h>]
5731 ], [
5732 [X509_VERIFY_PARAM *p = X509_VERIFY_PARAM_new();]
5733 [X509_VERIFY_PARAM_set1_host(p, "localhost", 0);]
5734 [X509_VERIFY_PARAM_set1_ip_asc(p, "127.0.0.1");]
5735 [X509_VERIFY_PARAM_set_hostflags(p, 0);]
5736 ])
5737 ],
5738 [
5739 ac_cv_has_x509_verify_param_set1_host=yes
5740 ],
5741 [
5742 ac_cv_has_x509_verify_param_set1_host=no
5743 ])
5744 AC_MSG_RESULT($ac_cv_has_x509_verify_param_set1_host)
5745 if test "$ac_cv_has_x509_verify_param_set1_host" = "yes"; then
5746 AC_DEFINE(HAVE_X509_VERIFY_PARAM_SET1_HOST, 1,
5747 [Define if libssl has X509_VERIFY_PARAM_set1_host and related function])
5748 fi
5749
5750 CPPFLAGS="$save_CPPFLAGS"
5751 LDFLAGS="$save_LDFLAGS"
5752 LIBS="$save_LIBS"
5753fi
5754
Christian Heimes892d66e2018-01-29 14:10:18 +01005755# ssl module default cipher suite string
5756AH_TEMPLATE(PY_SSL_DEFAULT_CIPHERS,
5757 [Default cipher suites list for ssl module.
5758 1: Python's preferred selection, 2: leave OpenSSL defaults untouched, 0: custom string])
5759AH_TEMPLATE(PY_SSL_DEFAULT_CIPHER_STRING,
5760 [Cipher suite string for PY_SSL_DEFAULT_CIPHERS=0]
5761)
5762
5763AC_MSG_CHECKING(for --with-ssl-default-suites)
5764AC_ARG_WITH(ssl-default-suites,
5765 AS_HELP_STRING([--with-ssl-default-suites=@<:@python|openssl|STRING@:>@],
Anthony Shaw2de064e2020-01-14 17:40:10 +11005766 [override default cipher suites string,
Christian Heimes892d66e2018-01-29 14:10:18 +01005767 python: use Python's preferred selection (default),
5768 openssl: leave OpenSSL's defaults untouched,
5769 STRING: use a custom string,
Anthony Shaw2de064e2020-01-14 17:40:10 +11005770 PROTOCOL_SSLv2 ignores the setting, see Doc/library/ssl.rst]),
Christian Heimes892d66e2018-01-29 14:10:18 +01005771[
5772AC_MSG_RESULT($withval)
5773case "$withval" in
5774 python)
5775 AC_DEFINE(PY_SSL_DEFAULT_CIPHERS, 1)
5776 ;;
5777 openssl)
5778 AC_DEFINE(PY_SSL_DEFAULT_CIPHERS, 2)
5779 ;;
5780 *)
5781 AC_DEFINE(PY_SSL_DEFAULT_CIPHERS, 0)
5782 AC_DEFINE_UNQUOTED(PY_SSL_DEFAULT_CIPHER_STRING, "$withval")
5783 ;;
5784esac
5785],
5786[
5787AC_MSG_RESULT(python)
5788AC_DEFINE(PY_SSL_DEFAULT_CIPHERS, 1)
5789])
5790
Christian Heimes9b60e552020-05-15 23:54:53 +02005791# builtin hash modules
5792default_hashlib_hashes="md5,sha1,sha256,sha512,sha3,blake2"
5793AC_DEFINE([PY_BUILTIN_HASHLIB_HASHES], [], [enabled builtin hash modules]
5794)
5795AC_MSG_CHECKING(for --with-builtin-hashlib-hashes)
5796AC_ARG_WITH(builtin-hashlib-hashes,
5797 AS_HELP_STRING([--with-builtin-hashlib-hashes=md5,sha1,sha256,sha512,sha3,blake2],
5798 [builtin hash modules,
5799 md5, sha1, sha256, sha512, sha3 (with shake), blake2]),
5800[
5801case "$withval" in
5802 yes)
5803 withval=$default_hashlib_hashes
5804 ;;
5805 no)
5806 withval=""
5807 ;;
5808esac
5809AC_MSG_RESULT($withval)
5810AC_DEFINE_UNQUOTED(PY_BUILTIN_HASHLIB_HASHES, "$withval")
5811],
5812[
5813AC_MSG_RESULT($default_hashlib_hashes);
5814AC_DEFINE_UNQUOTED(PY_BUILTIN_HASHLIB_HASHES, "$default_hashlib_hashes")
5815])
5816
Victor Stinnerc5fa3642020-05-05 16:41:11 +02005817# --with-experimental-isolated-subinterpreters
5818AH_TEMPLATE(EXPERIMENTAL_ISOLATED_SUBINTERPRETERS,
5819 [Better isolate subinterpreters, experimental build mode.])
5820AC_MSG_CHECKING(for --with-experimental-isolated-subinterpreters)
5821AC_ARG_WITH(experimental-isolated-subinterpreters,
5822 AS_HELP_STRING([--with-experimental-isolated-subinterpreters],
5823 [better isolate subinterpreters, experimental build mode (default is no)]),
5824[
5825if test "$withval" != no
5826then
5827 AC_MSG_RESULT(yes);
5828 AC_DEFINE(EXPERIMENTAL_ISOLATED_SUBINTERPRETERS)
5829else
5830 AC_MSG_RESULT(no);
5831fi],
5832[AC_MSG_RESULT(no)])
5833
Christian Heimes892d66e2018-01-29 14:10:18 +01005834
Guido van Rossum627b2d71993-12-24 10:39:16 +00005835# generate output files
Victor Stinner0a8e5722019-05-23 03:30:23 +02005836AC_CONFIG_FILES(Makefile.pre Misc/python.pc Misc/python-embed.pc Misc/python-config.sh)
Antoine Pitrou8e6b4072010-09-10 19:44:44 +00005837AC_CONFIG_FILES([Modules/ld_so_aix], [chmod +x Modules/ld_so_aix])
Martin v. Löwis88afe662002-10-26 13:47:44 +00005838AC_OUTPUT
Neil Schemenauer61c51152001-01-26 16:18:16 +00005839
Christian Heimes75ed8902013-11-20 01:11:18 +01005840echo "creating Modules/Setup.local" >&AS_MESSAGE_FD
Neil Schemenauer61c51152001-01-26 16:18:16 +00005841if test ! -f Modules/Setup.local
5842then
5843 echo "# Edit this file for local setup changes" >Modules/Setup.local
5844fi
5845
Christian Heimes75ed8902013-11-20 01:11:18 +01005846echo "creating Makefile" >&AS_MESSAGE_FD
Neil Schemenauer61c51152001-01-26 16:18:16 +00005847$SHELL $srcdir/Modules/makesetup -c $srcdir/Modules/config.c.in \
Antoine Pitroua6a4dc82017-09-07 18:56:24 +02005848 -s Modules \
Antoine Pitrou961d54c2018-07-16 19:03:03 +02005849 Modules/Setup.local $srcdir/Modules/Setup
Neil Schemenauer66252162001-02-19 04:47:42 +00005850mv config.c Modules
Brett Cannon63d98bc2016-09-06 17:12:40 -07005851
5852if test "$Py_OPT" = 'false' -a "$Py_DEBUG" != 'true'; then
5853 echo "" >&AS_MESSAGE_FD
5854 echo "" >&AS_MESSAGE_FD
Brett Cannonb4e5fee2017-06-09 13:56:57 -07005855 echo "If you want a release build with all stable optimizations active (PGO, etc)," >&AS_MESSAGE_FD
Gregory P. Smith ext:(%20%5BGoogle%20Inc.%5D)1016b2f2016-11-20 21:07:42 +00005856 echo "please run ./configure --enable-optimizations" >&AS_MESSAGE_FD
Brett Cannon63d98bc2016-09-06 17:12:40 -07005857 echo "" >&AS_MESSAGE_FD
5858 echo "" >&AS_MESSAGE_FD
5859fi
5860