blob: 344d9b0367334363452019e78adea369cc9047ac [file] [log] [blame]
Benjamin Petersond7c77842008-05-26 13:01:25 +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)
Martin v. Löwis174440b2008-10-03 08:59:41 +00006m4_define(PYTHON_VERSION, 2.7)
Martin v. Löwis88afe662002-10-26 13:47:44 +00007
Georg Brandl71f4fbb2011-02-25 11:04:50 +00008AC_PREREQ(2.65)
Alexandre Vassalotti130ae152009-07-18 00:31:06 +00009
Guido van Rossum76be6ed1995-01-02 18:33:54 +000010AC_REVISION($Revision$)
Benjamin Petersoncc8929b2016-08-03 22:01:32 -070011AC_INIT(python, PYTHON_VERSION, https://bugs.python.org/)
Martin v. Löwis88afe662002-10-26 13:47:44 +000012AC_CONFIG_SRCDIR([Include/object.h])
Martin v. Löwis4f1cd8b2001-07-26 13:41:06 +000013AC_CONFIG_HEADER(pyconfig.h)
Guido van Rossum627b2d71993-12-24 10:39:16 +000014
doko@python.orgd65e2ba2013-01-31 23:52:03 +010015AC_CANONICAL_HOST
16AC_SUBST(build)
17AC_SUBST(host)
18
Ned Deily983df862014-08-22 13:30:59 -070019# pybuilddir.txt will be created by --generate-posix-vars in the Makefile
20rm -f pybuilddir.txt
21
Victor Stinner8a19eb22017-05-05 03:14:23 +020022AC_CHECK_PROGS(PYTHON_FOR_REGEN, python$PACKAGE_VERSION python3 python, python3)
23AC_SUBST(PYTHON_FOR_REGEN)
24
doko@python.orgd65e2ba2013-01-31 23:52:03 +010025if test "$cross_compiling" = yes; then
26 AC_MSG_CHECKING([for python interpreter for cross build])
27 if test -z "$PYTHON_FOR_BUILD"; then
28 for interp in python$PACKAGE_VERSION python2 python; do
29 which $interp >/dev/null 2>&1 || continue
30 if $interp -c 'import sys;sys.exit(not (sys.version_info@<:@:2@:>@ >= (2,7) and sys.version_info@<:@0@:>@ < 3))'; then
31 break
32 fi
33 interp=
34 done
35 if test x$interp = x; then
36 AC_MSG_ERROR([python$PACKAGE_VERSION interpreter not found])
37 fi
38 AC_MSG_RESULT($interp)
doko@ubuntu.com9e7ece22015-04-13 21:55:08 +020039 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:$(srcdir)/Lib/$(PLATDIR) '$interp
doko@python.orgd65e2ba2013-01-31 23:52:03 +010040 fi
41elif test "$cross_compiling" = maybe; then
42 AC_MSG_ERROR([Cross compiling required --host=HOST-TUPLE and --build=ARCH])
43else
44 PYTHON_FOR_BUILD='./$(BUILDPYTHON) -E'
45fi
46AC_SUBST(PYTHON_FOR_BUILD)
47
Georg Brandlbcd64a32009-03-31 21:45:18 +000048dnl Ensure that if prefix is specified, it does not end in a slash. If
49dnl it does, we get path names containing '//' which is both ugly and
50dnl can cause trouble.
51
52dnl Last slash shouldn't be stripped if prefix=/
53if test "$prefix" != "/"; then
54 prefix=`echo "$prefix" | sed -e 's/\/$//g'`
55fi
56
Martin v. Löwis8316feb2003-06-14 07:48:07 +000057dnl This is for stuff that absolutely must end up in pyconfig.h.
58dnl Please use pyport.h instead, if possible.
Martin v. Löwisbddf5a52002-11-11 13:37:28 +000059AH_TOP([
60#ifndef Py_PYCONFIG_H
61#define Py_PYCONFIG_H
62])
Martin v. Löwis11437992002-04-12 09:54:03 +000063AH_BOTTOM([
Martin v. Löwis11437992002-04-12 09:54:03 +000064/* Define the macros needed if on a UnixWare 7.x system. */
65#if defined(__USLC__) && defined(__SCO_VERSION__)
66#define STRICT_SYSV_CURSES /* Don't use ncurses extensions */
67#endif
Martin v. Löwisbddf5a52002-11-11 13:37:28 +000068
69#endif /*Py_PYCONFIG_H*/
Martin v. Löwis11437992002-04-12 09:54:03 +000070])
71
Martin v. Löwis8316feb2003-06-14 07:48:07 +000072# We don't use PACKAGE_ variables, and they cause conflicts
73# with other autoconf-based packages that include Python.h
74grep -v 'define PACKAGE_' <confdefs.h >confdefs.h.new
75rm confdefs.h
76mv confdefs.h.new confdefs.h
77
Guido van Rossum642b6781997-07-19 19:35:41 +000078AC_SUBST(VERSION)
Martin v. Löwis88afe662002-10-26 13:47:44 +000079VERSION=PYTHON_VERSION
Guido van Rossum642b6781997-07-19 19:35:41 +000080
Martin v. Löwis1142de32002-03-29 16:28:31 +000081AC_SUBST(SOVERSION)
82SOVERSION=1.0
83
Martin v. Löwis6f18a3c2002-07-20 08:51:52 +000084# The later defininition of _XOPEN_SOURCE disables certain features
85# on Linux, so we need _GNU_SOURCE to re-enable them (makedev, tm_zone).
86AC_DEFINE(_GNU_SOURCE, 1, [Define on Linux to activate all library features])
87
Martin v. Löwisbcd93962003-05-03 10:32:18 +000088# The later defininition of _XOPEN_SOURCE and _POSIX_C_SOURCE disables
89# certain features on NetBSD, so we need _NETBSD_SOURCE to re-enable
90# them.
91AC_DEFINE(_NETBSD_SOURCE, 1, [Define on NetBSD to activate all library features])
92
Andrew MacIntyreabccf412003-07-02 13:53:25 +000093# The later defininition of _XOPEN_SOURCE and _POSIX_C_SOURCE disables
94# certain features on FreeBSD, so we need __BSD_VISIBLE to re-enable
95# them.
96AC_DEFINE(__BSD_VISIBLE, 1, [Define on FreeBSD to activate all library features])
97
Martin v. Löwisd6320502004-08-12 13:45:08 +000098# The later defininition of _XOPEN_SOURCE and _POSIX_C_SOURCE disables
99# u_int on Irix 5.3. Defining _BSD_TYPES brings it back.
100AC_DEFINE(_BSD_TYPES, 1, [Define on Irix to enable u_int])
101
Ronald Oussoren5640ce22008-06-05 12:58:24 +0000102# The later defininition of _XOPEN_SOURCE and _POSIX_C_SOURCE disables
103# certain features on Mac OS X, so we need _DARWIN_C_SOURCE to re-enable
104# them.
105AC_DEFINE(_DARWIN_C_SOURCE, 1, [Define on Darwin to activate all library features])
106
107
Martin v. Löwise981a4e2002-11-11 13:26:51 +0000108define_xopen_source=yes
Martin v. Löwis6f18a3c2002-07-20 08:51:52 +0000109
Neil Schemenauer4edbc2a2001-03-22 00:34:03 +0000110# Arguments passed to configure.
111AC_SUBST(CONFIG_ARGS)
112CONFIG_ARGS="$ac_configure_args"
113
Ronald Oussoren3c0a1262010-01-17 19:27:57 +0000114AC_MSG_CHECKING([for --enable-universalsdk])
Ronald Oussoren988117f2006-04-29 11:31:35 +0000115AC_ARG_ENABLE(universalsdk,
Matthias Klose22520ea2010-05-08 10:14:46 +0000116 AS_HELP_STRING([--enable-universalsdk@<:@=SDKDIR@:>@], [Build against Mac OS X 10.4u SDK (ppc/i386)]),
Ronald Oussoren988117f2006-04-29 11:31:35 +0000117[
118 case $enableval in
119 yes)
120 enableval=/Developer/SDKs/MacOSX10.4u.sdk
Ronald Oussoren3c0a1262010-01-17 19:27:57 +0000121 if test ! -d "${enableval}"
122 then
123 enableval=/
124 fi
Ronald Oussoren988117f2006-04-29 11:31:35 +0000125 ;;
126 esac
127 case $enableval in
128 no)
129 UNIVERSALSDK=
130 enable_universalsdk=
131 ;;
132 *)
133 UNIVERSALSDK=$enableval
Ronald Oussoren3c0a1262010-01-17 19:27:57 +0000134 if test ! -d "${UNIVERSALSDK}"
135 then
136 AC_MSG_ERROR([--enable-universalsdk specifies non-existing SDK: ${UNIVERSALSDK}])
137 fi
Ronald Oussoren988117f2006-04-29 11:31:35 +0000138 ;;
139 esac
Ronald Oussoren3c0a1262010-01-17 19:27:57 +0000140
Ronald Oussoren988117f2006-04-29 11:31:35 +0000141],[
142 UNIVERSALSDK=
143 enable_universalsdk=
144])
Ronald Oussoren3c0a1262010-01-17 19:27:57 +0000145if test -n "${UNIVERSALSDK}"
146then
147 AC_MSG_RESULT(${UNIVERSALSDK})
148else
149 AC_MSG_RESULT(no)
150fi
Ronald Oussoren988117f2006-04-29 11:31:35 +0000151AC_SUBST(UNIVERSALSDK)
152
Benjamin Peterson0e6ea5d2008-07-16 20:17:04 +0000153AC_SUBST(ARCH_RUN_32BIT)
Ned Deily8e60f6e2013-05-30 00:14:29 -0700154ARCH_RUN_32BIT=""
Benjamin Peterson0e6ea5d2008-07-16 20:17:04 +0000155
Ronald Oussoren5640ce22008-06-05 12:58:24 +0000156UNIVERSAL_ARCHS="32-bit"
Ronald Oussoren92919a62009-12-24 13:30:58 +0000157AC_SUBST(LIPO_32BIT_FLAGS)
Ronald Oussoren5640ce22008-06-05 12:58:24 +0000158AC_MSG_CHECKING(for --with-universal-archs)
159AC_ARG_WITH(universal-archs,
Matthias Klose22520ea2010-05-08 10:14:46 +0000160 AS_HELP_STRING([--with-universal-archs=ARCH], [select architectures for universal build ("32-bit", "64-bit", "3-way", "intel" or "all")]),
Ronald Oussoren5640ce22008-06-05 12:58:24 +0000161[
162 AC_MSG_RESULT($withval)
163 UNIVERSAL_ARCHS="$withval"
Ronald Oussoren9ebd2422009-09-29 13:00:44 +0000164 if test "${enable_universalsdk}" ; then
165 :
166 else
167 AC_MSG_ERROR([--with-universal-archs without --enable-universalsdk. See Mac/README])
168 fi
Ronald Oussoren5640ce22008-06-05 12:58:24 +0000169],
170[
171 AC_MSG_RESULT(32-bit)
172])
173
174
175
Ronald Oussoren580c7fe2008-05-02 19:45:11 +0000176AC_ARG_WITH(framework-name,
Matthias Klose22520ea2010-05-08 10:14:46 +0000177 AS_HELP_STRING([--with-framework-name=FRAMEWORK],
Matthias Klose5183ebd2010-04-24 16:38:36 +0000178 [specify an alternate name of the framework built with --enable-framework]),
Ronald Oussoren580c7fe2008-05-02 19:45:11 +0000179[
Ronald Oussoren9ebd2422009-09-29 13:00:44 +0000180 if test "${enable_framework}"; then
181 :
182 else
183 AC_MSG_ERROR([--with-framework-name without --enable-framework. See Mac/README])
184 fi
Ronald Oussoren580c7fe2008-05-02 19:45:11 +0000185 PYTHONFRAMEWORK=${withval}
186 PYTHONFRAMEWORKDIR=${withval}.framework
187 PYTHONFRAMEWORKIDENTIFIER=org.python.`echo $withval | tr '[A-Z]' '[a-z]'`
188 ],[
189 PYTHONFRAMEWORK=Python
190 PYTHONFRAMEWORKDIR=Python.framework
191 PYTHONFRAMEWORKIDENTIFIER=org.python.python
192])
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000193dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000194AC_ARG_ENABLE(framework,
Matthias Klose22520ea2010-05-08 10:14:46 +0000195 AS_HELP_STRING([--enable-framework@<:@=INSTALLDIR@:>@], [Build (MacOSX|Darwin) framework]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000196[
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000197 case $enableval in
198 yes)
199 enableval=/Library/Frameworks
Jack Jansen127e56e2001-09-11 14:41:54 +0000200 esac
201 case $enableval in
202 no)
203 PYTHONFRAMEWORK=
204 PYTHONFRAMEWORKDIR=no-framework
205 PYTHONFRAMEWORKPREFIX=
206 PYTHONFRAMEWORKINSTALLDIR=
Ronald Oussoren567a8ff2006-05-26 11:43:26 +0000207 FRAMEWORKINSTALLFIRST=
208 FRAMEWORKINSTALLLAST=
Ronald Oussoren5b787322006-06-06 19:50:24 +0000209 FRAMEWORKALTINSTALLFIRST=
210 FRAMEWORKALTINSTALLLAST=
Ronald Oussoren2db3a8f2006-06-07 19:06:01 +0000211 if test "x${prefix}" = "xNONE"; then
212 FRAMEWORKUNIXTOOLSPREFIX="${ac_default_prefix}"
213 else
214 FRAMEWORKUNIXTOOLSPREFIX="${prefix}"
215 fi
Jack Jansen127e56e2001-09-11 14:41:54 +0000216 enable_framework=
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000217 ;;
218 *)
Ronald Oussoren01d149f2010-04-30 11:20:14 +0000219 PYTHONFRAMEWORKPREFIX="${enableval}"
Jack Jansen127e56e2001-09-11 14:41:54 +0000220 PYTHONFRAMEWORKINSTALLDIR=$PYTHONFRAMEWORKPREFIX/$PYTHONFRAMEWORKDIR
Ronald Oussoren567a8ff2006-05-26 11:43:26 +0000221 FRAMEWORKINSTALLFIRST="frameworkinstallstructure"
Ronald Oussoren5640ce22008-06-05 12:58:24 +0000222 FRAMEWORKALTINSTALLFIRST="frameworkinstallstructure bininstall maninstall"
Ronald Oussoren92919a62009-12-24 13:30:58 +0000223 FRAMEWORKINSTALLLAST="frameworkinstallmaclib frameworkinstallapps frameworkinstallunixtools"
224 FRAMEWORKALTINSTALLLAST="frameworkinstallmaclib frameworkinstallapps frameworkaltinstallunixtools"
Ronald Oussoren01d149f2010-04-30 11:20:14 +0000225 FRAMEWORKINSTALLAPPSPREFIX="/Applications"
Ronald Oussoren5640ce22008-06-05 12:58:24 +0000226
Ronald Oussoren2db3a8f2006-06-07 19:06:01 +0000227 if test "x${prefix}" = "xNONE" ; then
228 FRAMEWORKUNIXTOOLSPREFIX="${ac_default_prefix}"
Ronald Oussoren01d149f2010-04-30 11:20:14 +0000229
Ronald Oussoren2db3a8f2006-06-07 19:06:01 +0000230 else
231 FRAMEWORKUNIXTOOLSPREFIX="${prefix}"
232 fi
Ronald Oussoren01d149f2010-04-30 11:20:14 +0000233
234 case "${enableval}" in
235 /System*)
236 FRAMEWORKINSTALLAPPSPREFIX="/Applications"
237 if test "${prefix}" = "NONE" ; then
238 # See below
239 FRAMEWORKUNIXTOOLSPREFIX="/usr"
240 fi
241 ;;
242
243 /Library*)
244 FRAMEWORKINSTALLAPPSPREFIX="/Applications"
245 ;;
246
247 */Library/Frameworks)
248 MDIR="`dirname "${enableval}"`"
249 MDIR="`dirname "${MDIR}"`"
250 FRAMEWORKINSTALLAPPSPREFIX="${MDIR}/Applications"
251
252 if test "${prefix}" = "NONE"; then
253 # User hasn't specified the
254 # --prefix option, but wants to install
255 # the framework in a non-default location,
256 # ensure that the compatibility links get
257 # installed relative to that prefix as well
258 # instead of in /usr/local.
259 FRAMEWORKUNIXTOOLSPREFIX="${MDIR}"
260 fi
261 ;;
262
263 *)
264 FRAMEWORKINSTALLAPPSPREFIX="/Applications"
265 ;;
266 esac
267
Jack Jansen127e56e2001-09-11 14:41:54 +0000268 prefix=$PYTHONFRAMEWORKINSTALLDIR/Versions/$VERSION
Ronald Oussoren836b0392006-05-14 19:56:34 +0000269
Ronald Oussoren580c7fe2008-05-02 19:45:11 +0000270 # Add files for Mac specific code to the list of output
Ronald Oussoren836b0392006-05-14 19:56:34 +0000271 # files:
Ronald Oussoren2db3a8f2006-06-07 19:06:01 +0000272 AC_CONFIG_FILES(Mac/Makefile)
273 AC_CONFIG_FILES(Mac/PythonLauncher/Makefile)
274 AC_CONFIG_FILES(Mac/IDLE/Makefile)
Ronald Oussoren580c7fe2008-05-02 19:45:11 +0000275 AC_CONFIG_FILES(Mac/Resources/framework/Info.plist)
276 AC_CONFIG_FILES(Mac/Resources/app/Info.plist)
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000277 esac
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000278 ],[
279 PYTHONFRAMEWORK=
Jack Jansen127e56e2001-09-11 14:41:54 +0000280 PYTHONFRAMEWORKDIR=no-framework
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000281 PYTHONFRAMEWORKPREFIX=
282 PYTHONFRAMEWORKINSTALLDIR=
Ronald Oussoren567a8ff2006-05-26 11:43:26 +0000283 FRAMEWORKINSTALLFIRST=
284 FRAMEWORKINSTALLLAST=
Ronald Oussoren5b787322006-06-06 19:50:24 +0000285 FRAMEWORKALTINSTALLFIRST=
286 FRAMEWORKALTINSTALLLAST=
Ronald Oussoren2db3a8f2006-06-07 19:06:01 +0000287 if test "x${prefix}" = "xNONE" ; then
288 FRAMEWORKUNIXTOOLSPREFIX="${ac_default_prefix}"
289 else
290 FRAMEWORKUNIXTOOLSPREFIX="${prefix}"
291 fi
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000292 enable_framework=
Ronald Oussoren5640ce22008-06-05 12:58:24 +0000293
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000294])
295AC_SUBST(PYTHONFRAMEWORK)
Ronald Oussoren580c7fe2008-05-02 19:45:11 +0000296AC_SUBST(PYTHONFRAMEWORKIDENTIFIER)
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000297AC_SUBST(PYTHONFRAMEWORKDIR)
298AC_SUBST(PYTHONFRAMEWORKPREFIX)
299AC_SUBST(PYTHONFRAMEWORKINSTALLDIR)
Ronald Oussoren567a8ff2006-05-26 11:43:26 +0000300AC_SUBST(FRAMEWORKINSTALLFIRST)
301AC_SUBST(FRAMEWORKINSTALLLAST)
Ronald Oussoren5b787322006-06-06 19:50:24 +0000302AC_SUBST(FRAMEWORKALTINSTALLFIRST)
303AC_SUBST(FRAMEWORKALTINSTALLLAST)
304AC_SUBST(FRAMEWORKUNIXTOOLSPREFIX)
Ronald Oussoren01d149f2010-04-30 11:20:14 +0000305AC_SUBST(FRAMEWORKINSTALLAPPSPREFIX)
Guido van Rossum4b6b5791996-09-09 20:09:34 +0000306
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000307##AC_ARG_WITH(dyld,
Matthias Klose22520ea2010-05-08 10:14:46 +0000308## AS_HELP_STRING([--with-dyld],
309## [Use (OpenStep|Rhapsody) dynamic linker]))
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000310##
Guido van Rossumb418f891996-07-30 18:06:02 +0000311# Set name for machine-dependent library files
312AC_SUBST(MACHDEP)
313AC_MSG_CHECKING(MACHDEP)
314if test -z "$MACHDEP"
315then
doko@python.orgd65e2ba2013-01-31 23:52:03 +0100316 # avoid using uname for cross builds
317 if test "$cross_compiling" = yes; then
318 # ac_sys_system and ac_sys_release are only used for setting
319 # `define_xopen_source' in the case statement below. For the
320 # current supported cross builds, this macro is not adjusted.
321 case "$host" in
322 *-*-linux*)
323 ac_sys_system=Linux
324 ;;
325 *-*-cygwin*)
326 ac_sys_system=Cygwin
327 ;;
328 *)
329 # for now, limit cross builds to known configurations
330 MACHDEP="unknown"
331 AC_MSG_ERROR([cross build not supported for $host])
332 esac
333 ac_sys_release=
334 else
Guido van Rossum4b6b5791996-09-09 20:09:34 +0000335 ac_sys_system=`uname -s`
Georg Brandlfe18a112009-09-04 07:55:14 +0000336 if test "$ac_sys_system" = "AIX" \
Martin v. Löwis21ee4092002-09-30 16:19:48 +0000337 -o "$ac_sys_system" = "UnixWare" -o "$ac_sys_system" = "OpenUNIX"; then
Guido van Rossum4b6b5791996-09-09 20:09:34 +0000338 ac_sys_release=`uname -v`
Guido van Rossumb418f891996-07-30 18:06:02 +0000339 else
Guido van Rossum4b6b5791996-09-09 20:09:34 +0000340 ac_sys_release=`uname -r`
Guido van Rossumb418f891996-07-30 18:06:02 +0000341 fi
doko@python.orgd65e2ba2013-01-31 23:52:03 +0100342 fi
343 ac_md_system=`echo $ac_sys_system |
344 tr -d '[/ ]' | tr '[[A-Z]]' '[[a-z]]'`
345 ac_md_release=`echo $ac_sys_release |
346 tr -d '[/ ]' | sed 's/^[[A-Z]]\.//' | sed 's/\..*//'`
347 MACHDEP="$ac_md_system$ac_md_release"
Guido van Rossum4b6b5791996-09-09 20:09:34 +0000348
doko@python.orgd65e2ba2013-01-31 23:52:03 +0100349 case $MACHDEP in
Victor Stinneracacbaa2011-08-20 14:02:38 +0200350 linux*) MACHDEP="linux2";;
Andrew M. Kuchling5a3e4cb2001-07-20 19:29:04 +0000351 cygwin*) MACHDEP="cygwin";;
Jack Jansen8a97f4a2001-12-05 23:27:32 +0000352 darwin*) MACHDEP="darwin";;
Martin v. Löwisf90ae202002-06-11 06:22:31 +0000353 atheos*) MACHDEP="atheos";;
Martin v. Löwisf3322282003-07-13 09:46:13 +0000354 irix646) MACHDEP="irix6";;
Guido van Rossumb97ef171997-09-28 05:44:03 +0000355 '') MACHDEP="unknown";;
doko@python.orgd65e2ba2013-01-31 23:52:03 +0100356 esac
357fi
358
359AC_SUBST(_PYTHON_HOST_PLATFORM)
360if test "$cross_compiling" = yes; then
361 case "$host" in
362 *-*-linux*)
363 case "$host_cpu" in
364 arm*)
365 _host_cpu=arm
366 ;;
367 *)
368 _host_cpu=$host_cpu
369 esac
370 ;;
371 *-*-cygwin*)
372 _host_cpu=
373 ;;
374 *)
375 # for now, limit cross builds to known configurations
376 MACHDEP="unknown"
377 AC_MSG_ERROR([cross build not supported for $host])
Guido van Rossumb418f891996-07-30 18:06:02 +0000378 esac
doko@python.orgd65e2ba2013-01-31 23:52:03 +0100379 _PYTHON_HOST_PLATFORM="$MACHDEP${_host_cpu:+-$_host_cpu}"
Guido van Rossumb418f891996-07-30 18:06:02 +0000380fi
Jack Jansen83f898c2002-12-30 22:23:40 +0000381
Martin v. Löwise981a4e2002-11-11 13:26:51 +0000382# Some systems cannot stand _XOPEN_SOURCE being defined at all; they
383# disable features if it is defined, without any means to access these
384# features as extensions. For these systems, we skip the definition of
385# _XOPEN_SOURCE. Before adding a system to the list to gain access to
386# some feature, make sure there is no alternative way to access this
387# feature. Also, when using wildcards, make sure you have verified the
388# need for not defining _XOPEN_SOURCE on all systems matching the
389# wildcard, and that the wildcard does not include future systems
390# (which may remove their limitations).
391dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
392case $ac_sys_system/$ac_sys_release in
393 # On OpenBSD, select(2) is not available if _XOPEN_SOURCE is defined,
394 # even though select is a POSIX function. Reported by J. Ribbens.
Martin v. Löwis76bafc62003-10-03 13:47:44 +0000395 # Reconfirmed for OpenBSD 3.3 by Zachary Hamm, for 3.4 by Jason Ish.
Martin v. Löwis7875ef62010-02-15 21:41:12 +0000396 # In addition, Stefan Krah confirms that issue #1244610 exists through
397 # OpenBSD 4.6, but is fixed in 4.7.
Charles-François Natali97781b02011-07-22 23:43:42 +0200398 OpenBSD/2.* | OpenBSD/3.* | OpenBSD/4.@<:@0123456@:>@)
Martin v. Löwiscb78de62007-12-29 18:49:21 +0000399 define_xopen_source=no
400 # OpenBSD undoes our definition of __BSD_VISIBLE if _XOPEN_SOURCE is
401 # also defined. This can be overridden by defining _BSD_SOURCE
402 # As this has a different meaning on Linux, only define it on OpenBSD
403 AC_DEFINE(_BSD_SOURCE, 1, [Define on OpenBSD to activate all library features])
404 ;;
Charles-François Natali97781b02011-07-22 23:43:42 +0200405 OpenBSD/*)
Martin v. Löwis5e2dd862010-02-15 08:32:00 +0000406 # OpenBSD undoes our definition of __BSD_VISIBLE if _XOPEN_SOURCE is
407 # also defined. This can be overridden by defining _BSD_SOURCE
408 # As this has a different meaning on Linux, only define it on OpenBSD
409 AC_DEFINE(_BSD_SOURCE, 1, [Define on OpenBSD to activate all library features])
410 ;;
Martin v. Löwis4d542ec2006-11-25 15:39:19 +0000411 # Defining _XOPEN_SOURCE on NetBSD version prior to the introduction of
412 # _NETBSD_SOURCE disables certain features (eg. setgroups). Reported by
413 # Marc Recht
Georg Brandl4b9bcfc2008-11-16 08:00:17 +0000414 NetBSD/1.5 | NetBSD/1.5.* | NetBSD/1.6 | NetBSD/1.6.* | NetBSD/1.6@<:@A-S@:>@)
Martin v. Löwis4d542ec2006-11-25 15:39:19 +0000415 define_xopen_source=no;;
Martin v. Löwisb41afb52010-05-28 15:28:47 +0000416 # From the perspective of Solaris, _XOPEN_SOURCE is not so much a
417 # request to enable features supported by the standard as a request
418 # to disable features not supported by the standard. The best way
419 # for Python to use Solaris is simply to leave _XOPEN_SOURCE out
420 # entirely and define __EXTENSIONS__ instead.
421 SunOS/*)
Martin v. Löwisa9d71422003-03-28 18:43:31 +0000422 define_xopen_source=no;;
Martin v. Löwisc2409b42003-05-11 05:53:41 +0000423 # On UnixWare 7, u_long is never defined with _XOPEN_SOURCE,
424 # but used in /usr/include/netinet/tcp.h. Reported by Tim Rice.
Martin v. Löwis253d1f42004-05-07 19:14:14 +0000425 # Reconfirmed for 7.1.4 by Martin v. Loewis.
426 OpenUNIX/8.0.0| UnixWare/7.1.@<:@0-4@:>@)
Martin v. Löwisc2409b42003-05-11 05:53:41 +0000427 define_xopen_source=no;;
428 # On OpenServer 5, u_short is never defined with _XOPEN_SOURCE,
Martin v. Löwis53e73c32003-05-05 05:13:18 +0000429 # but used in struct sockaddr.sa_family. Reported by Tim Rice.
Martin v. Löwisc2409b42003-05-11 05:53:41 +0000430 SCO_SV/3.2)
Martin v. Löwis53e73c32003-05-05 05:13:18 +0000431 define_xopen_source=no;;
Martin v. Löwisbb86d832008-11-04 20:40:09 +0000432 # On FreeBSD 4, the math functions C89 does not cover are never defined
433 # with _XOPEN_SOURCE and __BSD_VISIBLE does not re-enable them.
434 FreeBSD/4.*)
435 define_xopen_source=no;;
436 # On MacOS X 10.2, a bug in ncurses.h means that it craps out if
437 # _XOPEN_EXTENDED_SOURCE is defined. Apparently, this is fixed in 10.3, which
438 # identifies itself as Darwin/7.*
439 # On Mac OS X 10.4, defining _POSIX_C_SOURCE or _XOPEN_SOURCE
440 # disables platform specific features beyond repair.
441 # On Mac OS X 10.3, defining _POSIX_C_SOURCE or _XOPEN_SOURCE
442 # has no effect, don't bother defining them
443 Darwin/@<:@6789@:>@.*)
Anthony Baxter6169c6b2003-10-04 07:46:23 +0000444 define_xopen_source=no;;
Ronald Oussorena55af9a2010-01-17 16:25:57 +0000445 Darwin/1@<:@0-9@:>@.*)
446 define_xopen_source=no;;
Trent Mickaf16e8c2004-08-25 23:55:59 +0000447 # On AIX 4 and 5.1, mbstate_t is defined only when _XOPEN_SOURCE == 500 but
448 # used in wcsnrtombs() and mbsnrtowcs() even if _XOPEN_SOURCE is not defined
449 # or has another value. By not (re)defining it, the defaults come in place.
Martin v. Löwisc19c5a62003-11-18 20:00:44 +0000450 AIX/4)
451 define_xopen_source=no;;
Trent Mickaf16e8c2004-08-25 23:55:59 +0000452 AIX/5)
453 if test `uname -r` -eq 1; then
454 define_xopen_source=no
455 fi
456 ;;
Martin v. Löwis8c255e42008-05-23 15:06:50 +0000457 # On QNX 6.3.2, defining _XOPEN_SOURCE prevents netdb.h from
458 # defining NI_NUMERICHOST.
459 QNX/6.3.2)
460 define_xopen_source=no
461 ;;
Martin v. Löwisa0588362006-04-04 06:03:50 +0000462
Martin v. Löwise981a4e2002-11-11 13:26:51 +0000463esac
464
465if test $define_xopen_source = yes
466then
Martin v. Löwisb41afb52010-05-28 15:28:47 +0000467 AC_DEFINE(_XOPEN_SOURCE, 600,
468 Define to the level of X/Open that your system supports)
Martin v. Löwis678fc1e2002-11-12 06:04:39 +0000469
470 # On Tru64 Unix 4.0F, defining _XOPEN_SOURCE also requires
471 # definition of _XOPEN_SOURCE_EXTENDED and _POSIX_C_SOURCE, or else
472 # several APIs are not declared. Since this is also needed in some
473 # cases for HP-UX, we define it globally.
Martin v. Löwisb41afb52010-05-28 15:28:47 +0000474 AC_DEFINE(_XOPEN_SOURCE_EXTENDED, 1,
475 Define to activate Unix95-and-earlier features)
Martin v. Löwis678fc1e2002-11-12 06:04:39 +0000476
Bob Ippolito7026a0a2005-03-28 23:23:47 +0000477 AC_DEFINE(_POSIX_C_SOURCE, 200112L, Define to activate features from IEEE Stds 1003.1-2001)
478
Martin v. Löwise981a4e2002-11-11 13:26:51 +0000479fi
480
Guido van Rossum91922671997-10-09 20:24:13 +0000481#
482# SGI compilers allow the specification of the both the ABI and the
483# ISA on the command line. Depending on the values of these switches,
Martin Panterb1d867f2016-05-26 05:28:50 +0000484# different and often incompatible code will be generated.
Guido van Rossum91922671997-10-09 20:24:13 +0000485#
486# The SGI_ABI variable can be used to modify the CC and LDFLAGS and
487# thus supply support for various ABI/ISA combinations. The MACHDEP
488# variable is also adjusted.
489#
490AC_SUBST(SGI_ABI)
491if test ! -z "$SGI_ABI"
492then
493 CC="cc $SGI_ABI"
494 LDFLAGS="$SGI_ABI $LDFLAGS"
495 MACHDEP=`echo "${MACHDEP}${SGI_ABI}" | sed 's/ *//g'`
496fi
Guido van Rossumb418f891996-07-30 18:06:02 +0000497AC_MSG_RESULT($MACHDEP)
498
doko@ubuntu.com9e7ece22015-04-13 21:55:08 +0200499AC_SUBST(PLATDIR)
500PLATDIR=plat-$MACHDEP
501
Jack Jansen83f898c2002-12-30 22:23:40 +0000502# And add extra plat-mac for darwin
503AC_SUBST(EXTRAPLATDIR)
Jack Jansen7b59b422003-03-17 15:44:10 +0000504AC_SUBST(EXTRAMACHDEPPATH)
Jack Jansen83f898c2002-12-30 22:23:40 +0000505AC_MSG_CHECKING(EXTRAPLATDIR)
506if test -z "$EXTRAPLATDIR"
507then
508 case $MACHDEP in
Jack Jansen7b59b422003-03-17 15:44:10 +0000509 darwin)
510 EXTRAPLATDIR="\$(PLATMACDIRS)"
511 EXTRAMACHDEPPATH="\$(PLATMACPATH)"
512 ;;
513 *)
514 EXTRAPLATDIR=""
515 EXTRAMACHDEPPATH=""
516 ;;
Jack Jansen83f898c2002-12-30 22:23:40 +0000517 esac
518fi
519AC_MSG_RESULT($EXTRAPLATDIR)
520
Jack Jansen6b08a402004-06-03 12:41:45 +0000521# Record the configure-time value of MACOSX_DEPLOYMENT_TARGET,
522# it may influence the way we can build extensions, so distutils
523# needs to check it
524AC_SUBST(CONFIGURE_MACOSX_DEPLOYMENT_TARGET)
Ronald Oussoren988117f2006-04-29 11:31:35 +0000525AC_SUBST(EXPORT_MACOSX_DEPLOYMENT_TARGET)
Jack Jansen6b08a402004-06-03 12:41:45 +0000526CONFIGURE_MACOSX_DEPLOYMENT_TARGET=
Ronald Oussoren988117f2006-04-29 11:31:35 +0000527EXPORT_MACOSX_DEPLOYMENT_TARGET='#'
Jack Jansen6b08a402004-06-03 12:41:45 +0000528
Guido van Rossum627b2d71993-12-24 10:39:16 +0000529# checks for alternative programs
Skip Montanarodecc6a42003-01-01 20:07:49 +0000530
531# compiler flags are generated in two sets, BASECFLAGS and OPT. OPT is just
532# for debug/optimization stuff. BASECFLAGS is for flags that are required
533# just to get things to compile and link. Users are free to override OPT
534# when running configure or make. The build should not break if they do.
535# BASECFLAGS should generally not be messed with, however.
536
537# XXX shouldn't some/most/all of this code be merged with the stuff later
538# on that fiddles with OPT and BASECFLAGS?
Guido van Rossum5739e7e1995-01-20 16:50:53 +0000539AC_MSG_CHECKING(for --without-gcc)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000540AC_ARG_WITH(gcc,
Matthias Klose22520ea2010-05-08 10:14:46 +0000541 AS_HELP_STRING([--without-gcc], [never use gcc]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000542[
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000543 case $withval in
Skip Montanaro516144f2009-01-04 10:36:58 +0000544 no) CC=${CC:-cc}
Guido van Rossum5739e7e1995-01-20 16:50:53 +0000545 without_gcc=yes;;
546 yes) CC=gcc
547 without_gcc=no;;
548 *) CC=$withval
549 without_gcc=$withval;;
Guido van Rossum55a214e1995-09-13 17:48:09 +0000550 esac], [
Guido van Rossumb418f891996-07-30 18:06:02 +0000551 case $ac_sys_system in
Antoine Pitrou285cd162010-09-21 15:23:17 +0000552 AIX*) CC=${CC:-xlc_r}
Neil Schemenauerb3531b82001-02-16 04:09:05 +0000553 without_gcc=;;
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000554 BeOS*)
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000555 case $BE_HOST_CPU in
556 ppc)
Fred Drake5790be12000-10-09 17:06:13 +0000557 CC=mwcc
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000558 without_gcc=yes
Skip Montanarodecc6a42003-01-01 20:07:49 +0000559 BASECFLAGS="$BASECFLAGS -export pragma"
560 OPT="$OPT -O"
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000561 LDFLAGS="$LDFLAGS -nodup"
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000562 ;;
563 x86)
Fred Drake5790be12000-10-09 17:06:13 +0000564 CC=gcc
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000565 without_gcc=no
Skip Montanarodecc6a42003-01-01 20:07:49 +0000566 OPT="$OPT -O"
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000567 ;;
568 *)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000569 AC_MSG_ERROR([Unknown BeOS platform "$BE_HOST_CPU"])
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000570 ;;
571 esac
Neil Schemenauerb3531b82001-02-16 04:09:05 +0000572 AR="\$(srcdir)/Modules/ar_beos"
573 RANLIB=:
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000574 ;;
Martin v. Löwis130fb172001-07-19 11:00:41 +0000575 *) without_gcc=no;;
Guido van Rossum55a214e1995-09-13 17:48:09 +0000576 esac])
Guido van Rossum5739e7e1995-01-20 16:50:53 +0000577AC_MSG_RESULT($without_gcc)
578
Zachary Ware6ed42ea2015-12-21 11:43:03 -0600579AC_MSG_CHECKING(for --with-icc)
580AC_ARG_WITH(icc,
581 AS_HELP_STRING([--with-icc], [build with icc]),
582[
583 case $withval in
584 no) CC=${CC:-cc}
585 with_icc=no;;
586 yes) CC=icc
587 CXX=icpc
588 with_icc=yes;;
589 *) CC=$withval
590 with_icc=$withval;;
591 esac], [
592 with_icc=no])
593AC_MSG_RESULT($with_icc)
594
Guido van Rossum03ad99f1995-03-09 14:09:54 +0000595# If the user switches compilers, we can't believe the cache
596if test ! -z "$ac_cv_prog_CC" -a ! -z "$CC" -a "$CC" != "$ac_cv_prog_CC"
597then
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000598 AC_MSG_ERROR([cached CC is different -- throw away $cache_file
599(it is also a good idea to do 'make clean' before compiling)])
Guido van Rossum03ad99f1995-03-09 14:09:54 +0000600fi
601
Trent Nelson15daa352012-12-13 06:46:39 +0000602if test "$MACHDEP" = "irix6" && test "$CC" != "gcc"; then
603 # Normally, MIPSpro CC treats #error directives as warnings, which means
604 # a successful exit code is returned (0). This is a problem because IRIX
605 # has a bunch of system headers with this guard at the top:
606 #
607 # #ifndef __c99
608 # #error This header file is to be used only for c99 mode compilations
609 # #else
610 #
611 # When autoconf tests for such a header, like stdint.h, this happens:
612 #
613 # configure:4619: cc -c conftest.c >&5
614 # cc-1035 cc: WARNING File = /usr/include/stdint.h, Line = 5
615 # #error directive: This header file is to be used only for c99 mode
616 # compilations
617 #
618 # #error This header file is to be used only for c99 mode compilations
619 # ^
620 #
621 # configure:4619: $? = 0
622 # configure:4619: result: yes
623 #
624 # Therefore, we use `-diag_error 1035` to have the compiler treat the
625 # warning as an error, which causes cc to return a non-zero result,
626 # which autoconf can interpret correctly.
627 CFLAGS="$CFLAGS -diag_error 1035"
628 # Whilst we're here, we might as well make sure CXX defaults to something
629 # sensible if we're not using gcc.
630 if test -z "$CXX"; then
631 CXX="CC"
632 fi
633fi
634
Marc-André Lemburg6d5e5792010-04-30 17:20:14 +0000635# If the user set CFLAGS, use this instead of the automatically
636# determined setting
637preset_cflags="$CFLAGS"
Guido van Rossum627b2d71993-12-24 10:39:16 +0000638AC_PROG_CC
Marc-André Lemburg6d5e5792010-04-30 17:20:14 +0000639if test ! -z "$preset_cflags"
640then
641 CFLAGS=$preset_cflags
642fi
Martin v. Löwis1d5ecb72001-08-09 10:29:44 +0000643
Martin v. Löwis0f48d982006-04-14 14:34:26 +0000644AC_SUBST(CXX)
645AC_SUBST(MAINCC)
646AC_MSG_CHECKING(for --with-cxx-main=<compiler>)
647AC_ARG_WITH(cxx_main,
Matthias Klose22520ea2010-05-08 10:14:46 +0000648 AS_HELP_STRING([--with-cxx-main=<compiler>],
Martin v. Löwis0f48d982006-04-14 14:34:26 +0000649 [compile main() and link python executable with C++ compiler]),
650[
651
652 case $withval in
653 no) with_cxx_main=no
654 MAINCC='$(CC)';;
655 yes) with_cxx_main=yes
656 MAINCC='$(CXX)';;
657 *) with_cxx_main=yes
658 MAINCC=$withval
659 if test -z "$CXX"
660 then
661 CXX=$withval
662 fi;;
663 esac], [
664 with_cxx_main=no
665 MAINCC='$(CC)'
666])
667AC_MSG_RESULT($with_cxx_main)
668
669preset_cxx="$CXX"
670if test -z "$CXX"
671then
672 case "$CC" in
doko@python.orgd65e2ba2013-01-31 23:52:03 +0100673 gcc) AC_PATH_TOOL(CXX, [g++], [g++], [notfound]) ;;
674 cc) AC_PATH_TOOL(CXX, [c++], [c++], [notfound]) ;;
Martin v. Löwis0f48d982006-04-14 14:34:26 +0000675 esac
676 if test "$CXX" = "notfound"
677 then
678 CXX=""
679 fi
680fi
681if test -z "$CXX"
682then
doko@python.orgd65e2ba2013-01-31 23:52:03 +0100683 AC_CHECK_TOOLS(CXX, $CCC c++ g++ gcc CC cxx cc++ cl, notfound)
Martin v. Löwis0f48d982006-04-14 14:34:26 +0000684 if test "$CXX" = "notfound"
685 then
686 CXX=""
687 fi
688fi
689if test "$preset_cxx" != "$CXX"
690then
691 AC_MSG_WARN([
692
693 By default, distutils will build C++ extension modules with "$CXX".
694 If this is not intended, then set CXX on the configure command line.
695 ])
696fi
697
doko@python.org4e63fbe2013-01-25 13:08:27 +0100698MULTIARCH=$($CC --print-multiarch 2>/dev/null)
699AC_SUBST(MULTIARCH)
700
Martin v. Löwis0f48d982006-04-14 14:34:26 +0000701
Martin v. Löwis1d5ecb72001-08-09 10:29:44 +0000702# checks for UNIX variants that set C preprocessor variables
Matthias Klose9f8e0c12010-05-08 10:17:27 +0000703AC_USE_SYSTEM_EXTENSIONS
Martin v. Löwis1d5ecb72001-08-09 10:29:44 +0000704
Martin v. Löwis779ffc02002-12-02 22:17:01 +0000705# Check for unsupported systems
706case $ac_sys_system/$ac_sys_release in
Brett Cannon19fab762007-06-02 03:02:29 +0000707atheos*|Linux*/1*)
Martin v. Löwis779ffc02002-12-02 22:17:01 +0000708 echo This system \($ac_sys_system/$ac_sys_release\) is no longer supported.
709 echo See README for details.
710 exit 1;;
711esac
712
Neil Schemenauer55f0cf32001-01-24 17:24:33 +0000713AC_EXEEXT
Neil Schemenauer3ae1d0a2001-01-27 06:54:42 +0000714AC_MSG_CHECKING(for --with-suffix)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000715AC_ARG_WITH(suffix,
Matthias Klose22520ea2010-05-08 10:14:46 +0000716 AS_HELP_STRING([--with-suffix=.exe], [set executable suffix]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000717[
Neil Schemenauer3ae1d0a2001-01-27 06:54:42 +0000718 case $withval in
719 no) EXEEXT=;;
720 yes) EXEEXT=.exe;;
721 *) EXEEXT=$withval;;
722 esac])
723AC_MSG_RESULT($EXEEXT)
Jack Jansen1999ef42001-12-06 21:47:20 +0000724
Jack Jansen9a66b6d2001-08-08 13:56:14 +0000725# Test whether we're running on a non-case-sensitive system, in which
726# case we give a warning if no ext is given
Jack Jansen1999ef42001-12-06 21:47:20 +0000727AC_SUBST(BUILDEXEEXT)
728AC_MSG_CHECKING(for case-insensitive build directory)
Jack Jansen3c2c4332002-11-06 13:33:32 +0000729if test ! -d CaseSensitiveTestDir; then
730mkdir CaseSensitiveTestDir
731fi
732
733if test -d casesensitivetestdir
Jack Jansen9a66b6d2001-08-08 13:56:14 +0000734then
Jack Jansen1999ef42001-12-06 21:47:20 +0000735 AC_MSG_RESULT(yes)
736 BUILDEXEEXT=.exe
737else
738 AC_MSG_RESULT(no)
Jack Jansendd19cf82001-12-06 22:36:17 +0000739 BUILDEXEEXT=$EXEEXT
Jack Jansen9a66b6d2001-08-08 13:56:14 +0000740fi
Jack Jansen3c2c4332002-11-06 13:33:32 +0000741rmdir CaseSensitiveTestDir
Guido van Rossumfb842551997-08-06 23:42:07 +0000742
Guido van Rossumdd997f71998-10-07 19:58:26 +0000743case $MACHDEP in
744bsdos*)
745 case $CC in
746 gcc) CC="$CC -D_HAVE_BSDI";;
747 esac;;
748esac
749
Guido van Rossum84561611997-08-21 00:08:11 +0000750case $ac_sys_system in
751hp*|HP*)
752 case $CC in
Guido van Rossumcd5ff9f2000-09-22 16:15:54 +0000753 cc|*/cc) CC="$CC -Ae";;
Guido van Rossum84561611997-08-21 00:08:11 +0000754 esac;;
Martin v. Löwise8964d42001-03-06 12:09:07 +0000755SunOS*)
756 # Some functions have a prototype only with that define, e.g. confstr
Martin v. Löwisc45929e2002-04-06 10:10:49 +0000757 AC_DEFINE(__EXTENSIONS__, 1, [Defined on Solaris to see additional function prototypes.])
Martin v. Löwise8964d42001-03-06 12:09:07 +0000758 ;;
Guido van Rossum84561611997-08-21 00:08:11 +0000759esac
760
Martin v. Löwise8964d42001-03-06 12:09:07 +0000761
Neil Schemenauer61c51152001-01-26 16:18:16 +0000762AC_SUBST(LIBRARY)
763AC_MSG_CHECKING(LIBRARY)
764if test -z "$LIBRARY"
765then
766 LIBRARY='libpython$(VERSION).a'
767fi
768AC_MSG_RESULT($LIBRARY)
769
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000770# LDLIBRARY is the name of the library to link against (as opposed to the
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000771# name of the library into which to insert object files). BLDLIBRARY is also
772# the library to link against, usually. On Mac OS X frameworks, BLDLIBRARY
773# is blank as the main program is not linked directly against LDLIBRARY.
774# LDLIBRARYDIR is the path to LDLIBRARY, which is made in a subdirectory. On
775# systems without shared libraries, LDLIBRARY is the same as LIBRARY
776# (defined in the Makefiles). On Cygwin LDLIBRARY is the import library,
777# DLLLIBRARY is the shared (i.e., DLL) library.
778#
Martin v. Löwis1142de32002-03-29 16:28:31 +0000779# RUNSHARED is used to run shared python without installed libraries
780#
781# INSTSONAME is the name of the shared library that will be use to install
782# on the system - some systems like version suffix, others don't
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000783AC_SUBST(LDLIBRARY)
Guido van Rossum27552902001-01-23 01:52:26 +0000784AC_SUBST(DLLLIBRARY)
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000785AC_SUBST(BLDLIBRARY)
786AC_SUBST(LDLIBRARYDIR)
Martin v. Löwis1142de32002-03-29 16:28:31 +0000787AC_SUBST(INSTSONAME)
788AC_SUBST(RUNSHARED)
Neil Schemenauer61c51152001-01-26 16:18:16 +0000789LDLIBRARY="$LIBRARY"
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000790BLDLIBRARY='$(LDLIBRARY)'
Martin v. Löwis09bdf722002-05-08 08:51:29 +0000791INSTSONAME='$(LDLIBRARY)'
Guido van Rossum27552902001-01-23 01:52:26 +0000792DLLLIBRARY=''
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000793LDLIBRARYDIR=''
Martin v. Löwis1142de32002-03-29 16:28:31 +0000794RUNSHARED=''
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000795
Guido van Rossumfb842551997-08-06 23:42:07 +0000796# LINKCC is the command that links the python executable -- default is $(CC).
Martin v. Löwisb7da67a2001-10-18 15:35:38 +0000797# If CXX is set, and if it is needed to link a main function that was
798# compiled with CXX, LINKCC is CXX instead. Always using CXX is undesirable:
799# python might then depend on the C++ runtime
Fred Drake5790be12000-10-09 17:06:13 +0000800# This is altered for AIX in order to build the export list before
Guido van Rossumec95c7b1998-08-04 17:59:56 +0000801# linking.
Guido van Rossumfb842551997-08-06 23:42:07 +0000802AC_SUBST(LINKCC)
803AC_MSG_CHECKING(LINKCC)
804if test -z "$LINKCC"
805then
Martin v. Löwis0f48d982006-04-14 14:34:26 +0000806 LINKCC='$(PURIFY) $(MAINCC)'
Guido van Rossumfb842551997-08-06 23:42:07 +0000807 case $ac_sys_system in
808 AIX*)
Neal Norwitz0b27ff92003-03-31 15:53:49 +0000809 exp_extra="\"\""
810 if test $ac_sys_release -ge 5 -o \
811 $ac_sys_release -eq 4 -a `uname -r` -ge 2 ; then
812 exp_extra="."
813 fi
814 LINKCC="\$(srcdir)/Modules/makexp_aix Modules/python.exp $exp_extra \$(LIBRARY); $LINKCC";;
Martin v. Löwis8c255e42008-05-23 15:06:50 +0000815 QNX*)
816 # qcc must be used because the other compilers do not
817 # support -N.
818 LINKCC=qcc;;
Guido van Rossumfb842551997-08-06 23:42:07 +0000819 esac
820fi
821AC_MSG_RESULT($LINKCC)
822
Tarek Ziadée2be83d2009-05-09 08:28:53 +0000823# GNULD is set to "yes" if the GNU linker is used. If this goes wrong
824# make sure we default having it set to "no": this is used by
825# distutils.unixccompiler to know if it should add --enable-new-dtags
826# to linker command lines, and failing to detect GNU ld simply results
827# in the same bahaviour as before.
828AC_SUBST(GNULD)
829AC_MSG_CHECKING(for GNU ld)
830ac_prog=ld
831if test "$GCC" = yes; then
832 ac_prog=`$CC -print-prog-name=ld`
833fi
834case `"$ac_prog" -V 2>&1 < /dev/null` in
835 *GNU*)
836 GNULD=yes;;
837 *)
838 GNULD=no;;
839esac
840AC_MSG_RESULT($GNULD)
841
Martin v. Löwis1142de32002-03-29 16:28:31 +0000842AC_MSG_CHECKING(for --enable-shared)
843AC_ARG_ENABLE(shared,
Matthias Klose22520ea2010-05-08 10:14:46 +0000844 AS_HELP_STRING([--enable-shared], [disable/enable building shared python library]))
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000845
Martin v. Löwis1142de32002-03-29 16:28:31 +0000846if test -z "$enable_shared"
847then
Martin v. Löwisb51033d2002-05-03 05:53:15 +0000848 case $ac_sys_system in
Martin v. Löwisf90ae202002-06-11 06:22:31 +0000849 CYGWIN* | atheos*)
Martin v. Löwisb51033d2002-05-03 05:53:15 +0000850 enable_shared="yes";;
851 *)
852 enable_shared="no";;
853 esac
Martin v. Löwis1142de32002-03-29 16:28:31 +0000854fi
855AC_MSG_RESULT($enable_shared)
856
Skip Montanaro56f6a4f2004-06-18 02:47:22 +0000857AC_MSG_CHECKING(for --enable-profiling)
858AC_ARG_ENABLE(profiling,
doko@python.orgd65e2ba2013-01-31 23:52:03 +0100859 AS_HELP_STRING([--enable-profiling], [enable C-level code profiling]))
860if test "x$enable_profiling" = xyes; then
861 ac_save_cc="$CC"
Benjamin Petersonb9be7bb2013-03-26 08:55:37 -0400862 CC="$CC -pg"
doko@python.orgd65e2ba2013-01-31 23:52:03 +0100863 AC_LINK_IFELSE([AC_LANG_SOURCE([[int main() { return 0; }]])],
864 [],
865 [enable_profiling=no])
866 CC="$ac_save_cc"
867else
868 enable_profiling=no
869fi
870AC_MSG_RESULT($enable_profiling)
Skip Montanaro56f6a4f2004-06-18 02:47:22 +0000871
doko@python.orgd65e2ba2013-01-31 23:52:03 +0100872if test "x$enable_profiling" = xyes; then
873 BASECFLAGS="-pg $BASECFLAGS"
874 LDFLAGS="-pg $LDFLAGS"
875fi
Martin v. Löwis1142de32002-03-29 16:28:31 +0000876
877AC_MSG_CHECKING(LDLIBRARY)
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000878
Guido van Rossumb8552162001-09-05 14:58:11 +0000879# MacOSX framework builds need more magic. LDLIBRARY is the dynamic
880# library that we build, but we do not want to link against it (we
881# will find it with a -framework option). For this reason there is an
882# extra variable BLDLIBRARY against which Python and the extension
883# modules are linked, BLDLIBRARY. This is normally the same as
884# LDLIBRARY, but empty for MacOSX framework builds.
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000885if test "$enable_framework"
886then
887 LDLIBRARY='$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
doko@ubuntu.com9ba90c92014-05-07 04:41:26 +0200888 RUNSHARED=DYLD_FRAMEWORK_PATH=`pwd`${DYLD_FRAMEWORK_PATH:+:${DYLD_FRAMEWORK_PATH}}
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000889 BLDLIBRARY=''
890else
891 BLDLIBRARY='$(LDLIBRARY)'
892fi
893
Martin v. Löwis1142de32002-03-29 16:28:31 +0000894# Other platforms follow
895if test $enable_shared = "yes"; then
Mark Hammond8235ea12002-07-19 06:55:41 +0000896 AC_DEFINE(Py_ENABLE_SHARED, 1, [Defined if Python is built as a shared library.])
Martin v. Löwis1142de32002-03-29 16:28:31 +0000897 case $ac_sys_system in
898 BeOS*)
899 LDLIBRARY='libpython$(VERSION).so'
900 ;;
901 CYGWIN*)
902 LDLIBRARY='libpython$(VERSION).dll.a'
903 DLLLIBRARY='libpython$(VERSION).dll'
904 ;;
905 SunOS*)
906 LDLIBRARY='libpython$(VERSION).so'
Martin v. Löwisd141a8c2003-06-14 15:20:28 +0000907 BLDLIBRARY='-Wl,-R,$(LIBDIR) -L. -lpython$(VERSION)'
doko@ubuntu.com9ba90c92014-05-07 04:41:26 +0200908 RUNSHARED=LD_LIBRARY_PATH=`pwd`${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
Martin v. Löwis2389c412003-10-31 15:42:07 +0000909 INSTSONAME="$LDLIBRARY".$SOVERSION
Martin v. Löwis1142de32002-03-29 16:28:31 +0000910 ;;
Charles-François Natali3de8c732011-07-24 22:33:35 +0200911 Linux*|GNU*|NetBSD*|FreeBSD*|DragonFly*|OpenBSD*)
Martin v. Löwis1142de32002-03-29 16:28:31 +0000912 LDLIBRARY='libpython$(VERSION).so'
913 BLDLIBRARY='-L. -lpython$(VERSION)'
doko@ubuntu.com9ba90c92014-05-07 04:41:26 +0200914 RUNSHARED=LD_LIBRARY_PATH=`pwd`${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
Hye-Shik Chang33761492004-10-26 09:53:46 +0000915 case $ac_sys_system in
916 FreeBSD*)
917 SOVERSION=`echo $SOVERSION|cut -d "." -f 1`
918 ;;
919 esac
Martin v. Löwis1142de32002-03-29 16:28:31 +0000920 INSTSONAME="$LDLIBRARY".$SOVERSION
921 ;;
922 hp*|HP*)
Neal Norwitz58e28882006-05-19 07:00:58 +0000923 case `uname -m` in
924 ia64)
925 LDLIBRARY='libpython$(VERSION).so'
926 ;;
927 *)
928 LDLIBRARY='libpython$(VERSION).sl'
929 ;;
930 esac
Martin v. Löwis1142de32002-03-29 16:28:31 +0000931 BLDLIBRARY='-Wl,+b,$(LIBDIR) -L. -lpython$(VERSION)'
doko@ubuntu.com9ba90c92014-05-07 04:41:26 +0200932 RUNSHARED=SHLIB_PATH=`pwd`${SHLIB_PATH:+:${SHLIB_PATH}}
Martin v. Löwis1142de32002-03-29 16:28:31 +0000933 ;;
934 OSF*)
935 LDLIBRARY='libpython$(VERSION).so'
Neal Norwitz671b9e32006-01-09 07:07:12 +0000936 BLDLIBRARY='-rpath $(LIBDIR) -L. -lpython$(VERSION)'
doko@ubuntu.com9ba90c92014-05-07 04:41:26 +0200937 RUNSHARED=LD_LIBRARY_PATH=`pwd`${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
Martin v. Löwis1142de32002-03-29 16:28:31 +0000938 ;;
Martin v. Löwisf90ae202002-06-11 06:22:31 +0000939 atheos*)
940 LDLIBRARY='libpython$(VERSION).so'
941 BLDLIBRARY='-L. -lpython$(VERSION)'
942 RUNSHARED=DLL_PATH=`pwd`:${DLL_PATH:-/atheos/sys/libs:/atheos/autolnk/lib}
943 ;;
Ronald Oussoren79f90492009-01-02 10:44:46 +0000944 Darwin*)
945 LDLIBRARY='libpython$(VERSION).dylib'
946 BLDLIBRARY='-L. -lpython$(VERSION)'
doko@ubuntu.com9ba90c92014-05-07 04:41:26 +0200947 RUNSHARED=DYLD_LIBRARY_PATH=`pwd`${DYLD_LIBRARY_PATH:+:${DYLD_LIBRARY_PATH}}
Ronald Oussoren79f90492009-01-02 10:44:46 +0000948 ;;
Antoine Pitrouaabdceb2010-09-10 20:03:17 +0000949 AIX*)
950 LDLIBRARY='libpython$(VERSION).so'
doko@ubuntu.com9ba90c92014-05-07 04:41:26 +0200951 RUNSHARED=LIBPATH=`pwd`${LIBPATH:+:${LIBPATH}}
Antoine Pitrouaabdceb2010-09-10 20:03:17 +0000952 ;;
Ronald Oussoren79f90492009-01-02 10:44:46 +0000953
Martin v. Löwis1142de32002-03-29 16:28:31 +0000954 esac
Jason Tishler30765592003-09-04 11:04:06 +0000955else # shared is disabled
956 case $ac_sys_system in
957 CYGWIN*)
958 BLDLIBRARY='$(LIBRARY)'
959 LDLIBRARY='libpython$(VERSION).dll.a'
960 ;;
961 esac
Martin v. Löwis1142de32002-03-29 16:28:31 +0000962fi
963
doko@python.orgd65e2ba2013-01-31 23:52:03 +0100964if test "$cross_compiling" = yes; then
965 RUNSHARED=
966fi
967
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000968AC_MSG_RESULT($LDLIBRARY)
969
Guido van Rossum627b2d71993-12-24 10:39:16 +0000970AC_PROG_RANLIB
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000971AC_SUBST(AR)
doko@python.orgd65e2ba2013-01-31 23:52:03 +0100972AC_CHECK_TOOLS(AR, ar aal, ar)
Neil Schemenauera42c8272001-03-31 00:01:55 +0000973
Tarek Ziadé99f660a2009-05-07 21:20:34 +0000974# tweak ARFLAGS only if the user didn't set it on the command line
975AC_SUBST(ARFLAGS)
976if test -z "$ARFLAGS"
977then
978 ARFLAGS="rc"
979fi
980
Victor Stinner2c7085f2017-05-02 16:55:50 +0200981AC_SUBST(GITVERSION)
982AC_SUBST(GITTAG)
983AC_SUBST(GITBRANCH)
Martin v. Löwisdea59e52006-01-05 10:00:36 +0000984
Victor Stinnerdf569252017-05-03 00:05:45 +0200985if test -e $srcdir/.git
Georg Brandl3a5508e2011-03-06 10:42:21 +0100986then
Victor Stinner2c7085f2017-05-02 16:55:50 +0200987AC_CHECK_PROG(HAS_GIT, git, found, not-found)
Georg Brandl3a5508e2011-03-06 10:42:21 +0100988else
Victor Stinner2c7085f2017-05-02 16:55:50 +0200989HAS_GIT=no-repository
990fi
991if test $HAS_GIT = found
992then
993 GITVERSION="git -C \$(srcdir) rev-parse --short HEAD"
994 GITTAG="git -C \$(srcdir) describe --all --always --dirty"
995 GITBRANCH="git -C \$(srcdir) name-rev --name-only HEAD"
996else
997 GITVERSION=""
998 GITTAG=""
999 GITBRANCH=""
Georg Brandl3a5508e2011-03-06 10:42:21 +01001000fi
1001
Neil Schemenauera42c8272001-03-31 00:01:55 +00001002case $MACHDEP in
Neil Schemenaueraf5567f2001-10-21 22:32:04 +00001003bsdos*|hp*|HP*)
1004 # install -d does not work on BSDI or HP-UX
Neil Schemenauera42c8272001-03-31 00:01:55 +00001005 if test -z "$INSTALL"
1006 then
1007 INSTALL="${srcdir}/install-sh -c"
1008 fi
1009esac
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00001010AC_PROG_INSTALL
Trent Nelsonf6407a12012-08-30 14:56:13 +00001011AC_PROG_MKDIR_P
Guido van Rossumb418f891996-07-30 18:06:02 +00001012
Guido van Rossumec95c7b1998-08-04 17:59:56 +00001013# Not every filesystem supports hard links
1014AC_SUBST(LN)
1015if test -z "$LN" ; then
1016 case $ac_sys_system in
1017 BeOS*) LN="ln -s";;
Guido van Rossumaef734b2001-01-10 21:09:12 +00001018 CYGWIN*) LN="ln -s";;
Martin v. Löwisf90ae202002-06-11 06:22:31 +00001019 atheos*) LN="ln -s";;
Guido van Rossumec95c7b1998-08-04 17:59:56 +00001020 *) LN=ln;;
1021 esac
1022fi
1023
Fred Drake9f715822001-07-11 06:27:00 +00001024# Check for --with-pydebug
1025AC_MSG_CHECKING(for --with-pydebug)
1026AC_ARG_WITH(pydebug,
Matthias Klose22520ea2010-05-08 10:14:46 +00001027 AS_HELP_STRING([--with-pydebug], [build with Py_DEBUG defined]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00001028[
Fred Drake9f715822001-07-11 06:27:00 +00001029if test "$withval" != no
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001030then
1031 AC_DEFINE(Py_DEBUG, 1,
1032 [Define if you want to build an interpreter with many run-time checks.])
1033 AC_MSG_RESULT(yes);
1034 Py_DEBUG='true'
Fred Drake9f715822001-07-11 06:27:00 +00001035else AC_MSG_RESULT(no); Py_DEBUG='false'
1036fi],
1037[AC_MSG_RESULT(no)])
1038
Skip Montanarodecc6a42003-01-01 20:07:49 +00001039# XXX Shouldn't the code above that fiddles with BASECFLAGS and OPT be
1040# merged with this chunk of code?
1041
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00001042# Optimizer/debugger flags
Skip Montanarodecc6a42003-01-01 20:07:49 +00001043# ------------------------
1044# (The following bit of code is complicated enough - please keep things
1045# indented properly. Just pretend you're editing Python code. ;-)
1046
1047# There are two parallel sets of case statements below, one that checks to
1048# see if OPT was set and one that does BASECFLAGS setting based upon
1049# compiler and platform. BASECFLAGS tweaks need to be made even if the
1050# user set OPT.
1051
1052# tweak OPT based on compiler and platform, only if the user didn't set
1053# it on the command line
Guido van Rossumb418f891996-07-30 18:06:02 +00001054AC_SUBST(OPT)
Benjamin Petersond4b721b2010-03-23 20:58:37 +00001055if test "${OPT-unset}" = "unset"
Guido van Rossumb418f891996-07-30 18:06:02 +00001056then
Skip Montanarodecc6a42003-01-01 20:07:49 +00001057 case $GCC in
1058 yes)
Skip Montanaro288a5be2006-04-13 02:00:56 +00001059 if test "$CC" != 'g++' ; then
1060 STRICT_PROTO="-Wstrict-prototypes"
1061 fi
Guido van Rossum7c862f82007-12-13 20:50:10 +00001062 # For gcc 4.x we need to use -fwrapv so lets check if its supported
1063 if "$CC" -v --help 2>/dev/null |grep -- -fwrapv > /dev/null; then
1064 WRAP="-fwrapv"
1065 fi
Stefan Krah503e5e12011-09-14 15:19:42 +02001066
1067 # Clang also needs -fwrapv
Stefan Krah2bc1e8f2011-12-08 22:26:06 +01001068 case $CC in
1069 *clang*) WRAP="-fwrapv"
1070 ;;
1071 esac
Stefan Krah503e5e12011-09-14 15:19:42 +02001072
Skip Montanarodecc6a42003-01-01 20:07:49 +00001073 case $ac_cv_prog_cc_g in
Guido van Rossum2242f2f2001-04-11 20:58:20 +00001074 yes)
Fred Drake9f715822001-07-11 06:27:00 +00001075 if test "$Py_DEBUG" = 'true' ; then
1076 # Optimization messes up debuggers, so turn it off for
1077 # debug builds.
Mark Dickinsond2f3e3f2010-05-05 22:23:58 +00001078 OPT="-g -O0 -Wall $STRICT_PROTO"
Fred Drake9f715822001-07-11 06:27:00 +00001079 else
Guido van Rossum7c862f82007-12-13 20:50:10 +00001080 OPT="-g $WRAP -O3 -Wall $STRICT_PROTO"
Skip Montanarodecc6a42003-01-01 20:07:49 +00001081 fi
1082 ;;
Guido van Rossum2242f2f2001-04-11 20:58:20 +00001083 *)
Skip Montanaro288a5be2006-04-13 02:00:56 +00001084 OPT="-O3 -Wall $STRICT_PROTO"
Skip Montanarodecc6a42003-01-01 20:07:49 +00001085 ;;
Fred Drake9f715822001-07-11 06:27:00 +00001086 esac
Martin v. Löwis21ee4092002-09-30 16:19:48 +00001087 case $ac_sys_system in
Skip Montanarodecc6a42003-01-01 20:07:49 +00001088 SCO_SV*) OPT="$OPT -m486 -DSCO5"
1089 ;;
1090 esac
Fred Drake9f715822001-07-11 06:27:00 +00001091 ;;
Skip Montanarodecc6a42003-01-01 20:07:49 +00001092
Guido van Rossum2242f2f2001-04-11 20:58:20 +00001093 *)
Skip Montanarodecc6a42003-01-01 20:07:49 +00001094 OPT="-O"
1095 ;;
Guido van Rossum2242f2f2001-04-11 20:58:20 +00001096 esac
Guido van Rossum4e8af441994-08-19 15:33:54 +00001097fi
Guido van Rossum627b2d71993-12-24 10:39:16 +00001098
Skip Montanarodecc6a42003-01-01 20:07:49 +00001099AC_SUBST(BASECFLAGS)
Ronald Oussoren5640ce22008-06-05 12:58:24 +00001100
1101# The -arch flags for universal builds on OSX
1102UNIVERSAL_ARCH_FLAGS=
1103AC_SUBST(UNIVERSAL_ARCH_FLAGS)
1104
Skip Montanarodecc6a42003-01-01 20:07:49 +00001105# tweak BASECFLAGS based on compiler and platform
1106case $GCC in
1107yes)
Martin v. Löwis70fedcd2003-07-07 21:26:19 +00001108 # Python violates C99 rules, by casting between incompatible
1109 # pointer types. GCC may generate bad code as a result of that,
1110 # so use -fno-strict-aliasing if supported.
1111 AC_MSG_CHECKING(whether $CC accepts -fno-strict-aliasing)
1112 ac_save_cc="$CC"
1113 CC="$CC -fno-strict-aliasing"
Alexandre Vassalotti00900892009-07-17 05:26:39 +00001114 AC_CACHE_VAL(ac_cv_no_strict_aliasing_ok,
Matthias Klosec511b472010-05-08 11:01:39 +00001115 AC_COMPILE_IFELSE(
Mark Dickinson5e13e292010-05-11 08:55:06 +00001116 [AC_LANG_PROGRAM([[]], [[]])],
Matthias Klosec511b472010-05-08 11:01:39 +00001117 [ac_cv_no_strict_aliasing_ok=yes],
1118 [ac_cv_no_strict_aliasing_ok=no]))
Martin v. Löwis70fedcd2003-07-07 21:26:19 +00001119 CC="$ac_save_cc"
1120 AC_MSG_RESULT($ac_cv_no_strict_aliasing_ok)
1121 if test $ac_cv_no_strict_aliasing_ok = yes
1122 then
1123 BASECFLAGS="$BASECFLAGS -fno-strict-aliasing"
1124 fi
Mark Dickinson65134662008-04-25 16:11:04 +00001125
1126 # if using gcc on alpha, use -mieee to get (near) full IEEE 754
1127 # support. Without this, treatment of subnormals doesn't follow
1128 # the standard.
doko@python.orgd65e2ba2013-01-31 23:52:03 +01001129 case $host in
Mark Dickinson65134662008-04-25 16:11:04 +00001130 alpha*)
1131 BASECFLAGS="$BASECFLAGS -mieee"
1132 ;;
1133 esac
1134
Skip Montanarodecc6a42003-01-01 20:07:49 +00001135 case $ac_sys_system in
1136 SCO_SV*)
1137 BASECFLAGS="$BASECFLAGS -m486 -DSCO5"
1138 ;;
1139 # is there any other compiler on Darwin besides gcc?
1140 Darwin*)
Jeffrey Yasskin1b4e45b2008-03-17 14:40:53 +00001141 # -Wno-long-double, -no-cpp-precomp, and -mno-fused-madd
1142 # used to be here, but non-Apple gcc doesn't accept them.
Ronald Oussorena55af9a2010-01-17 16:25:57 +00001143 if test "${CC}" = gcc
1144 then
1145 AC_MSG_CHECKING(which compiler should be used)
1146 case "${UNIVERSALSDK}" in
1147 */MacOSX10.4u.sdk)
1148 # Build using 10.4 SDK, force usage of gcc when the
1149 # compiler is gcc, otherwise the user will get very
1150 # confusing error messages when building on OSX 10.6
1151 CC=gcc-4.0
1152 CPP=cpp-4.0
1153 ;;
1154 esac
1155 AC_MSG_RESULT($CC)
Ronald Oussoren988117f2006-04-29 11:31:35 +00001156 fi
1157
Benjamin Peterson4347c442008-07-17 15:59:24 +00001158 # Calculate the right deployment target for this build.
1159 #
Ned Deilyc40b9032014-06-25 13:48:46 -07001160 cur_target_major=`sw_vers -productVersion | \
1161 sed 's/\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'`
1162 cur_target_minor=`sw_vers -productVersion | \
1163 sed 's/\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'`
1164 cur_target="${cur_target_major}.${cur_target_minor}"
1165 if test ${cur_target_major} -eq 10 && \
1166 test ${cur_target_minor} -ge 3
1167 then
Benjamin Peterson4347c442008-07-17 15:59:24 +00001168 cur_target=10.3
Ronald Oussoren25967582009-09-06 10:00:26 +00001169 if test ${enable_universalsdk}; then
1170 if test "${UNIVERSAL_ARCHS}" = "all"; then
1171 # Ensure that the default platform for a
1172 # 4-way universal build is OSX 10.5,
1173 # that's the first OS release where
1174 # 4-way builds make sense.
1175 cur_target='10.5'
Ronald Oussoren23d92532009-09-07 06:12:00 +00001176
1177 elif test "${UNIVERSAL_ARCHS}" = "3-way"; then
1178 cur_target='10.5'
1179
1180 elif test "${UNIVERSAL_ARCHS}" = "intel"; then
1181 cur_target='10.5'
1182
1183 elif test "${UNIVERSAL_ARCHS}" = "64-bit"; then
1184 cur_target='10.5'
Ronald Oussoren25967582009-09-06 10:00:26 +00001185 fi
1186 else
Ronald Oussorenbc0e83c2010-02-11 13:26:54 +00001187 if test `/usr/bin/arch` = "i386"; then
Ronald Oussoren25967582009-09-06 10:00:26 +00001188 # On Intel macs default to a deployment
1189 # target of 10.4, that's the first OSX
1190 # release with Intel support.
1191 cur_target="10.4"
1192 fi
1193 fi
Benjamin Peterson4347c442008-07-17 15:59:24 +00001194 fi
1195 CONFIGURE_MACOSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET-${cur_target}}
1196
1197 # Make sure that MACOSX_DEPLOYMENT_TARGET is set in the
1198 # environment with a value that is the same as what we'll use
1199 # in the Makefile to ensure that we'll get the same compiler
1200 # environment during configure and build time.
1201 MACOSX_DEPLOYMENT_TARGET="$CONFIGURE_MACOSX_DEPLOYMENT_TARGET"
1202 export MACOSX_DEPLOYMENT_TARGET
1203 EXPORT_MACOSX_DEPLOYMENT_TARGET=''
1204
Ronald Oussorena55af9a2010-01-17 16:25:57 +00001205 if test "${enable_universalsdk}"; then
1206 UNIVERSAL_ARCH_FLAGS=""
1207 if test "$UNIVERSAL_ARCHS" = "32-bit" ; then
1208 UNIVERSAL_ARCH_FLAGS="-arch ppc -arch i386"
1209 ARCH_RUN_32BIT=""
Ronald Oussoren75912852010-04-08 08:13:31 +00001210 LIPO_32BIT_FLAGS=""
Ronald Oussorena55af9a2010-01-17 16:25:57 +00001211
1212 elif test "$UNIVERSAL_ARCHS" = "64-bit" ; then
1213 UNIVERSAL_ARCH_FLAGS="-arch ppc64 -arch x86_64"
1214 LIPO_32BIT_FLAGS=""
1215 ARCH_RUN_32BIT="true"
1216
1217 elif test "$UNIVERSAL_ARCHS" = "all" ; then
1218 UNIVERSAL_ARCH_FLAGS="-arch i386 -arch ppc -arch ppc64 -arch x86_64"
1219 LIPO_32BIT_FLAGS="-extract ppc7400 -extract i386"
Ronald Oussoren92397ce2010-01-17 19:32:00 +00001220 ARCH_RUN_32BIT="/usr/bin/arch -i386 -ppc"
Ronald Oussorena55af9a2010-01-17 16:25:57 +00001221
1222 elif test "$UNIVERSAL_ARCHS" = "intel" ; then
1223 UNIVERSAL_ARCH_FLAGS="-arch i386 -arch x86_64"
1224 LIPO_32BIT_FLAGS="-extract i386"
Ronald Oussoren92397ce2010-01-17 19:32:00 +00001225 ARCH_RUN_32BIT="/usr/bin/arch -i386"
Ronald Oussorena55af9a2010-01-17 16:25:57 +00001226
1227 elif test "$UNIVERSAL_ARCHS" = "3-way" ; then
1228 UNIVERSAL_ARCH_FLAGS="-arch i386 -arch ppc -arch x86_64"
1229 LIPO_32BIT_FLAGS="-extract ppc7400 -extract i386"
Ronald Oussoren9922f172010-02-11 13:19:34 +00001230 ARCH_RUN_32BIT="/usr/bin/arch -i386 -ppc"
Ronald Oussorena55af9a2010-01-17 16:25:57 +00001231
1232 else
1233 AC_MSG_ERROR([proper usage is --with-universal-arch=32-bit|64-bit|all|intel|3-way])
1234
1235 fi
1236
1237
Ronald Oussoren974eb5e2010-04-18 17:59:37 +00001238 CFLAGS="${UNIVERSAL_ARCH_FLAGS} ${CFLAGS}"
1239 if test "${UNIVERSALSDK}" != "/"
1240 then
1241 CPPFLAGS="-isysroot ${UNIVERSALSDK} ${CPPFLAGS}"
1242 LDFLAGS="-isysroot ${UNIVERSALSDK} ${LDFLAGS}"
1243 CFLAGS="-isysroot ${UNIVERSALSDK} ${CFLAGS}"
Ronald Oussorena55af9a2010-01-17 16:25:57 +00001244 fi
1245
1246 fi
1247
1248
Skip Montanarodecc6a42003-01-01 20:07:49 +00001249 ;;
Neal Norwitzdedeeaa2006-03-31 06:54:45 +00001250 OSF*)
1251 BASECFLAGS="$BASECFLAGS -mieee"
1252 ;;
Skip Montanarodecc6a42003-01-01 20:07:49 +00001253 esac
1254 ;;
1255
1256*)
1257 case $ac_sys_system in
1258 OpenUNIX*|UnixWare*)
1259 BASECFLAGS="$BASECFLAGS -K pentium,host,inline,loop_unroll,alloca "
1260 ;;
Neal Norwitzb44f1652003-05-26 14:11:55 +00001261 OSF*)
1262 BASECFLAGS="$BASECFLAGS -ieee -std"
1263 ;;
Skip Montanarodecc6a42003-01-01 20:07:49 +00001264 SCO_SV*)
1265 BASECFLAGS="$BASECFLAGS -belf -Ki486 -DSCO5"
1266 ;;
1267 esac
1268 ;;
1269esac
1270
Zachary Ware6ed42ea2015-12-21 11:43:03 -06001271# ICC needs -fp-model strict or floats behave badly
1272case "$CC" in
1273*icc*)
1274 BASECFLAGS="$BASECFLAGS -fp-model strict"
1275 ;;
1276esac
1277
Fred Drakee1ceaa02001-12-04 20:55:47 +00001278if test "$Py_DEBUG" = 'true'; then
1279 :
1280else
1281 OPT="-DNDEBUG $OPT"
1282fi
1283
Guido van Rossum6f2260e1996-09-09 16:21:03 +00001284if test "$ac_arch_flags"
Guido van Rossumc5a39031996-07-31 17:35:03 +00001285then
Skip Montanarodecc6a42003-01-01 20:07:49 +00001286 BASECFLAGS="$BASECFLAGS $ac_arch_flags"
Guido van Rossumc5a39031996-07-31 17:35:03 +00001287fi
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001288
Neal Norwitz020c46a2006-01-07 21:39:28 +00001289# disable check for icc since it seems to pass, but generates a warning
1290if test "$CC" = icc
1291then
1292 ac_cv_opt_olimit_ok=no
1293fi
1294
Guido van Rossum91922671997-10-09 20:24:13 +00001295AC_MSG_CHECKING(whether $CC accepts -OPT:Olimit=0)
1296AC_CACHE_VAL(ac_cv_opt_olimit_ok,
1297[ac_save_cc="$CC"
1298CC="$CC -OPT:Olimit=0"
Matthias Klosec511b472010-05-08 11:01:39 +00001299AC_COMPILE_IFELSE(
Mark Dickinson5e13e292010-05-11 08:55:06 +00001300 [AC_LANG_PROGRAM([[]], [[]])],
Matthias Klosec511b472010-05-08 11:01:39 +00001301 [ac_cv_opt_olimit_ok=yes],
1302 [ac_cv_opt_olimit_ok=no]
Gregory P. Smithec3b8bd2009-11-01 21:02:52 +00001303 )
Guido van Rossum91922671997-10-09 20:24:13 +00001304CC="$ac_save_cc"])
1305AC_MSG_RESULT($ac_cv_opt_olimit_ok)
Guido van Rossum2efa34b1997-10-23 17:43:11 +00001306if test $ac_cv_opt_olimit_ok = yes; then
Guido van Rossum5839e582000-10-09 19:52:35 +00001307 case $ac_sys_system in
Skip Montanarodecc6a42003-01-01 20:07:49 +00001308 # XXX is this branch needed? On MacOSX 10.2.2 the result of the
1309 # olimit_ok test is "no". Is it "yes" in some other Darwin-esque
1310 # environment?
1311 Darwin*)
1312 ;;
Trent Nelson34562e12012-10-17 18:01:12 -04001313 # XXX thankfully this useless troublemaker of a flag has been
1314 # eradicated in the 3.x line. For now, make sure it isn't picked
1315 # up by any of our other platforms that use CC.
1316 AIX*|SunOS*|HP-UX*|IRIX*)
1317 ;;
Skip Montanarodecc6a42003-01-01 20:07:49 +00001318 *)
1319 BASECFLAGS="$BASECFLAGS -OPT:Olimit=0"
1320 ;;
Guido van Rossum5839e582000-10-09 19:52:35 +00001321 esac
Guido van Rossumf8678121998-07-07 21:05:09 +00001322else
1323 AC_MSG_CHECKING(whether $CC accepts -Olimit 1500)
1324 AC_CACHE_VAL(ac_cv_olimit_ok,
1325 [ac_save_cc="$CC"
1326 CC="$CC -Olimit 1500"
Matthias Klosec511b472010-05-08 11:01:39 +00001327 AC_COMPILE_IFELSE(
Mark Dickinson5e13e292010-05-11 08:55:06 +00001328 [AC_LANG_PROGRAM([[]], [[]])],
Matthias Klosec511b472010-05-08 11:01:39 +00001329 [ac_cv_olimit_ok=yes],
1330 [ac_cv_olimit_ok=no]
Gregory P. Smithec3b8bd2009-11-01 21:02:52 +00001331 )
Guido van Rossumf8678121998-07-07 21:05:09 +00001332 CC="$ac_save_cc"])
1333 AC_MSG_RESULT($ac_cv_olimit_ok)
1334 if test $ac_cv_olimit_ok = yes; then
Stefan Krah67473262012-11-29 00:17:05 +01001335 case $ac_sys_system in
1336 # Issue #16534: On HP-UX ac_cv_olimit_ok=yes is a false positive.
1337 HP-UX*)
1338 ;;
1339 *)
1340 BASECFLAGS="$BASECFLAGS -Olimit 1500"
1341 ;;
1342 esac
Guido van Rossumf8678121998-07-07 21:05:09 +00001343 fi
Guido van Rossum201afe51997-05-14 21:14:44 +00001344fi
Guido van Rossumf8678121998-07-07 21:05:09 +00001345
Martin v. Löwisaac13162006-10-19 10:58:46 +00001346# Check whether GCC supports PyArg_ParseTuple format
1347if test "$GCC" = "yes"
1348then
1349 AC_MSG_CHECKING(whether gcc supports ParseTuple __format__)
1350 save_CFLAGS=$CFLAGS
Benjamin Petersonc8759662013-05-11 13:00:05 -05001351 CFLAGS="$CFLAGS -Werror -Wformat"
Matthias Klosec511b472010-05-08 11:01:39 +00001352 AC_COMPILE_IFELSE([
1353 AC_LANG_PROGRAM([[void f(char*,...)__attribute((format(PyArg_ParseTuple, 1, 2)));]], [[]])
1354 ],[
1355 AC_DEFINE(HAVE_ATTRIBUTE_FORMAT_PARSETUPLE, 1,
1356 [Define if GCC supports __attribute__((format(PyArg_ParseTuple, 2, 3)))])
1357 AC_MSG_RESULT(yes)
1358 ],[
1359 AC_MSG_RESULT(no)
1360 ])
Martin v. Löwisc1d75972006-10-19 16:01:37 +00001361 CFLAGS=$save_CFLAGS
Martin v. Löwisaac13162006-10-19 10:58:46 +00001362fi
1363
Brett Cannon4ff151a2015-09-18 15:09:42 -07001364
Gregory P. Smith6d8fdfc2016-09-07 23:28:23 -07001365# Enable optimization flags
1366AC_SUBST(DEF_MAKE_ALL_RULE)
1367AC_SUBST(DEF_MAKE_RULE)
1368Py_OPT='false'
Gregory P. Smith ext:(%20%5BGoogle%20Inc.%5D)b9999152016-11-20 21:19:36 +00001369AC_MSG_CHECKING(for --enable-optimizations)
1370AC_ARG_ENABLE(optimizations, AS_HELP_STRING([--enable-optimizations], [Enable expensive optimizations (PGO, maybe LTO, etc). Disabled by default.]),
Gregory P. Smith6d8fdfc2016-09-07 23:28:23 -07001371[
INADA Naoki6a04ef72017-03-29 01:50:48 +09001372if test "$enableval" != no
Gregory P. Smith6d8fdfc2016-09-07 23:28:23 -07001373then
1374 Py_OPT='true'
1375 AC_MSG_RESULT(yes);
1376else
1377 Py_OPT='false'
1378 AC_MSG_RESULT(no);
1379fi],
1380[AC_MSG_RESULT(no)])
1381if test "$Py_OPT" = 'true' ; then
Gregory P. Smith ext:(%20%5BGoogle%20Inc.%5D)9cbfa792016-09-08 22:44:44 +00001382 # Intentionally not forcing Py_LTO='true' here. Too many toolchains do not
1383 # compile working code using it and both test_distutils and test_gdb are
1384 # broken when you do managed to get a toolchain that works with it. People
1385 # who want LTO need to use --with-lto themselves.
Gregory P. Smith6d8fdfc2016-09-07 23:28:23 -07001386 Py_LTO='true'
1387 DEF_MAKE_ALL_RULE="profile-opt"
Gregory P. Smith794b2912016-09-08 00:07:40 -07001388 REQUIRE_PGO="yes"
Gregory P. Smith6d8fdfc2016-09-07 23:28:23 -07001389 DEF_MAKE_RULE="build_all"
1390else
1391 DEF_MAKE_ALL_RULE="build_all"
Gregory P. Smith794b2912016-09-08 00:07:40 -07001392 REQUIRE_PGO="no"
Gregory P. Smith6d8fdfc2016-09-07 23:28:23 -07001393 DEF_MAKE_RULE="all"
1394fi
1395
1396
Gregory P. Smith ext:(%20%5BGoogle%20Inc.%5D)c543a0f2016-06-02 23:44:40 +00001397# Enable LTO flags
1398AC_SUBST(LTOFLAGS)
1399AC_MSG_CHECKING(for --with-lto)
1400AC_ARG_WITH(lto, AS_HELP_STRING([--with-lto], [Enable Link Time Optimization in PGO builds. Disabled by default.]),
1401[
1402if test "$withval" != no
1403then
1404 Py_LTO='true'
1405 AC_MSG_RESULT(yes);
1406else
1407 Py_LTO='false'
1408 AC_MSG_RESULT(no);
1409fi],
1410[AC_MSG_RESULT(no)])
1411if test "$Py_LTO" = 'true' ; then
1412 case $CC in
1413 *clang*)
1414 # Any changes made here should be reflected in the GCC+Darwin case below
1415 LTOFLAGS="-flto"
1416 ;;
1417 *gcc*)
1418 case $ac_sys_system in
1419 Darwin*)
1420 LTOFLAGS="-flto"
1421 ;;
1422 *)
1423 LTOFLAGS="-flto -fuse-linker-plugin -ffat-lto-objects -flto-partition=none"
1424 ;;
1425 esac
1426 ;;
1427 esac
1428fi
1429
1430
Brett Cannon4ff151a2015-09-18 15:09:42 -07001431# Enable PGO flags.
1432AC_SUBST(PGO_PROF_GEN_FLAG)
1433AC_SUBST(PGO_PROF_USE_FLAG)
1434AC_SUBST(LLVM_PROF_MERGER)
1435AC_SUBST(LLVM_PROF_FILE)
1436AC_SUBST(LLVM_PROF_ERR)
Gregory P. Smith794b2912016-09-08 00:07:40 -07001437# Make this work on systems where llvm tools are not installed with their
1438# normal names in the default $PATH (ie: Ubuntu). They exist under the
1439# non-suffixed name in their versioned llvm directory.
1440llvm_bin_dir=''
1441llvm_path="${PATH}"
1442if test "${CC}" = "clang"
1443then
1444 clang_bin=`which clang`
1445 # Some systems install clang elsewhere as a symlink to the real path
1446 # which is where the related llvm tools are located.
1447 if test -L "${clang_bin}"
1448 then
1449 clang_dir=`dirname "${clang_bin}"`
1450 clang_bin=`readlink "${clang_bin}"`
1451 llvm_bin_dir="${clang_dir}/"`dirname "${clang_bin}"`
1452 llvm_path="${llvm_path}${PATH_SEPARATOR}${llvm_bin_dir}"
1453 fi
1454fi
1455AC_SUBST(LLVM_PROFDATA)
1456AC_PATH_TARGET_TOOL(LLVM_PROFDATA, llvm-profdata, '', ${llvm_path})
Brett Cannon4ff151a2015-09-18 15:09:42 -07001457AC_SUBST(LLVM_PROF_FOUND)
Gregory P. Smith794b2912016-09-08 00:07:40 -07001458if test -n "${LLVM_PROFDATA}" -a -x "${LLVM_PROFDATA}"
1459then
1460 LLVM_PROF_FOUND="found"
1461else
1462 LLVM_PROF_FOUND="not-found"
1463fi
1464if test "$ac_sys_system" = "Darwin" -a "${LLVM_PROF_FOUND}" = "not-found"
1465then
1466 found_llvm_profdata=`/usr/bin/xcrun -find llvm-profdata 2>/dev/null`
1467 if test -n "${found_llvm_profdata}"
1468 then
1469 # llvm-profdata isn't directly in $PATH in some cases.
1470 # https://apple.stackexchange.com/questions/197053/
1471 LLVM_PROFDATA='/usr/bin/xcrun llvm-profdata'
1472 LLVM_PROF_FOUND=found
1473 AC_MSG_NOTICE([llvm-profdata found via xcrun: ${LLVM_PROFDATA}])
1474 fi
1475fi
Brett Cannon4ff151a2015-09-18 15:09:42 -07001476LLVM_PROF_ERR=no
1477case $CC in
1478 *clang*)
1479 # Any changes made here should be reflected in the GCC+Darwin case below
1480 PGO_PROF_GEN_FLAG="-fprofile-instr-generate"
1481 PGO_PROF_USE_FLAG="-fprofile-instr-use=code.profclangd"
Gregory P. Smith794b2912016-09-08 00:07:40 -07001482 LLVM_PROF_MERGER="${LLVM_PROFDATA} merge -output=code.profclangd *.profclangr"
Brett Cannon4ff151a2015-09-18 15:09:42 -07001483 LLVM_PROF_FILE="LLVM_PROFILE_FILE=\"code-%p.profclangr\""
1484 if test $LLVM_PROF_FOUND = not-found
1485 then
1486 LLVM_PROF_ERR=yes
Gregory P. Smith794b2912016-09-08 00:07:40 -07001487 if test "${REQUIRE_PGO}" = "yes"
1488 then
Gregory P. Smith ext:(%20%5BGoogle%20Inc.%5D)b9999152016-11-20 21:19:36 +00001489 AC_MSG_ERROR([llvm-profdata is required for a --enable-optimizations build but could not be found.])
Gregory P. Smith794b2912016-09-08 00:07:40 -07001490 fi
Brett Cannon4ff151a2015-09-18 15:09:42 -07001491 fi
1492 ;;
1493 *gcc*)
1494 case $ac_sys_system in
1495 Darwin*)
1496 PGO_PROF_GEN_FLAG="-fprofile-instr-generate"
1497 PGO_PROF_USE_FLAG="-fprofile-instr-use=code.profclangd"
Gregory P. Smith794b2912016-09-08 00:07:40 -07001498 LLVM_PROF_MERGER="${LLVM_PROFDATA} merge -output=code.profclangd *.profclangr"
Brett Cannon4ff151a2015-09-18 15:09:42 -07001499 LLVM_PROF_FILE="LLVM_PROFILE_FILE=\"code-%p.profclangr\""
Gregory P. Smith794b2912016-09-08 00:07:40 -07001500 if test "${LLVM_PROF_FOUND}" = "not-found"
Brett Cannon4ff151a2015-09-18 15:09:42 -07001501 then
1502 LLVM_PROF_ERR=yes
Gregory P. Smith794b2912016-09-08 00:07:40 -07001503 if test "${REQUIRE_PGO}" = "yes"
1504 then
Gregory P. Smith ext:(%20%5BGoogle%20Inc.%5D)b9999152016-11-20 21:19:36 +00001505 AC_MSG_ERROR([llvm-profdata is required for a --enable-optimizations build but could not be found.])
Gregory P. Smith794b2912016-09-08 00:07:40 -07001506 fi
Brett Cannon4ff151a2015-09-18 15:09:42 -07001507 fi
1508 ;;
1509 *)
1510 PGO_PROF_GEN_FLAG="-fprofile-generate"
1511 PGO_PROF_USE_FLAG="-fprofile-use -fprofile-correction"
1512 LLVM_PROF_MERGER="true"
1513 LLVM_PROF_FILE=""
1514 ;;
1515 esac
1516 ;;
Zachary Ware6ed42ea2015-12-21 11:43:03 -06001517 *icc*)
1518 PGO_PROF_GEN_FLAG="-prof-gen"
1519 PGO_PROF_USE_FLAG="-prof-use"
1520 LLVM_PROF_MERGER="true"
1521 LLVM_PROF_FILE=""
1522 ;;
Brett Cannon4ff151a2015-09-18 15:09:42 -07001523esac
1524
1525
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00001526# On some compilers, pthreads are available without further options
1527# (e.g. MacOS X). On some of these systems, the compiler will not
1528# complain if unaccepted options are passed (e.g. gcc on Mac OS X).
1529# So we have to see first whether pthreads are available without
1530# options before we can check whether -Kpthread improves anything.
1531AC_MSG_CHECKING(whether pthreads are available without options)
1532AC_CACHE_VAL(ac_cv_pthread_is_default,
Matthias Klosec511b472010-05-08 11:01:39 +00001533[AC_RUN_IFELSE([AC_LANG_SOURCE([[
Stefan Krahae66ca62012-11-22 22:36:57 +01001534#include <stdio.h>
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00001535#include <pthread.h>
1536
1537void* routine(void* p){return NULL;}
1538
1539int main(){
1540 pthread_t p;
1541 if(pthread_create(&p,NULL,routine,NULL)!=0)
1542 return 1;
Jack Jansen4f8d0542002-03-08 13:43:01 +00001543 (void)pthread_detach(p);
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00001544 return 0;
1545}
Matthias Klosec511b472010-05-08 11:01:39 +00001546]])],[
Skip Montanarod8d39a02003-07-10 20:44:10 +00001547 ac_cv_pthread_is_default=yes
1548 ac_cv_kthread=no
1549 ac_cv_pthread=no
Matthias Klosec511b472010-05-08 11:01:39 +00001550],[ac_cv_pthread_is_default=no],[ac_cv_pthread_is_default=no])
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00001551])
1552AC_MSG_RESULT($ac_cv_pthread_is_default)
1553
1554
1555if test $ac_cv_pthread_is_default = yes
1556then
1557 ac_cv_kpthread=no
1558else
Martin v. Löwis130fb172001-07-19 11:00:41 +00001559# -Kpthread, if available, provides the right #defines
1560# and linker options to make pthread_create available
Martin v. Löwis260aecc2001-10-07 08:14:41 +00001561# Some compilers won't report that they do not support -Kpthread,
1562# so we need to run a program to see whether it really made the
1563# function available.
Martin v. Löwis130fb172001-07-19 11:00:41 +00001564AC_MSG_CHECKING(whether $CC accepts -Kpthread)
1565AC_CACHE_VAL(ac_cv_kpthread,
1566[ac_save_cc="$CC"
1567CC="$CC -Kpthread"
Matthias Klosec511b472010-05-08 11:01:39 +00001568AC_RUN_IFELSE([AC_LANG_SOURCE([[
Stefan Krahae66ca62012-11-22 22:36:57 +01001569#include <stdio.h>
Martin v. Löwis260aecc2001-10-07 08:14:41 +00001570#include <pthread.h>
1571
1572void* routine(void* p){return NULL;}
1573
1574int main(){
1575 pthread_t p;
1576 if(pthread_create(&p,NULL,routine,NULL)!=0)
1577 return 1;
Jack Jansen4f8d0542002-03-08 13:43:01 +00001578 (void)pthread_detach(p);
Martin v. Löwis260aecc2001-10-07 08:14:41 +00001579 return 0;
1580}
Matthias Klosec511b472010-05-08 11:01:39 +00001581]])],[ac_cv_kpthread=yes],[ac_cv_kpthread=no],[ac_cv_kpthread=no])
Martin v. Löwis130fb172001-07-19 11:00:41 +00001582CC="$ac_save_cc"])
Martin v. Löwis130fb172001-07-19 11:00:41 +00001583AC_MSG_RESULT($ac_cv_kpthread)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00001584fi
Martin v. Löwis130fb172001-07-19 11:00:41 +00001585
Skip Montanarod8d39a02003-07-10 20:44:10 +00001586if test $ac_cv_kpthread = no -a $ac_cv_pthread_is_default = no
Martin v. Löwis5f433f02003-05-05 05:05:30 +00001587then
1588# -Kthread, if available, provides the right #defines
1589# and linker options to make pthread_create available
1590# Some compilers won't report that they do not support -Kthread,
1591# so we need to run a program to see whether it really made the
1592# function available.
1593AC_MSG_CHECKING(whether $CC accepts -Kthread)
1594AC_CACHE_VAL(ac_cv_kthread,
1595[ac_save_cc="$CC"
1596CC="$CC -Kthread"
Matthias Klosec511b472010-05-08 11:01:39 +00001597AC_RUN_IFELSE([AC_LANG_SOURCE([[
Stefan Krahae66ca62012-11-22 22:36:57 +01001598#include <stdio.h>
Martin v. Löwis5f433f02003-05-05 05:05:30 +00001599#include <pthread.h>
1600
1601void* routine(void* p){return NULL;}
1602
1603int main(){
1604 pthread_t p;
1605 if(pthread_create(&p,NULL,routine,NULL)!=0)
1606 return 1;
1607 (void)pthread_detach(p);
1608 return 0;
1609}
Matthias Klosec511b472010-05-08 11:01:39 +00001610]])],[ac_cv_kthread=yes],[ac_cv_kthread=no],[ac_cv_kthread=no])
Martin v. Löwis5f433f02003-05-05 05:05:30 +00001611CC="$ac_save_cc"])
1612AC_MSG_RESULT($ac_cv_kthread)
1613fi
1614
Skip Montanarod8d39a02003-07-10 20:44:10 +00001615if test $ac_cv_kthread = no -a $ac_cv_pthread_is_default = no
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00001616then
1617# -pthread, if available, provides the right #defines
1618# and linker options to make pthread_create available
1619# Some compilers won't report that they do not support -pthread,
1620# so we need to run a program to see whether it really made the
1621# function available.
1622AC_MSG_CHECKING(whether $CC accepts -pthread)
doko@python.orgfa3f9a32013-01-25 15:32:31 +01001623AC_CACHE_VAL(ac_cv_pthread,
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00001624[ac_save_cc="$CC"
1625CC="$CC -pthread"
Matthias Klosec511b472010-05-08 11:01:39 +00001626AC_RUN_IFELSE([AC_LANG_SOURCE([[
Stefan Krahae66ca62012-11-22 22:36:57 +01001627#include <stdio.h>
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00001628#include <pthread.h>
1629
1630void* routine(void* p){return NULL;}
1631
1632int main(){
1633 pthread_t p;
1634 if(pthread_create(&p,NULL,routine,NULL)!=0)
1635 return 1;
1636 (void)pthread_detach(p);
1637 return 0;
1638}
Matthias Klosec511b472010-05-08 11:01:39 +00001639]])],[ac_cv_pthread=yes],[ac_cv_pthread=no],[ac_cv_pthread=no])
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00001640CC="$ac_save_cc"])
1641AC_MSG_RESULT($ac_cv_pthread)
1642fi
1643
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001644# If we have set a CC compiler flag for thread support then
1645# check if it works for CXX, too.
1646ac_cv_cxx_thread=no
1647if test ! -z "$CXX"
1648then
1649AC_MSG_CHECKING(whether $CXX also accepts flags for thread support)
1650ac_save_cxx="$CXX"
1651
1652if test "$ac_cv_kpthread" = "yes"
1653then
Martin v. Löwis519adae2003-09-20 10:47:47 +00001654 CXX="$CXX -Kpthread"
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001655 ac_cv_cxx_thread=yes
1656elif test "$ac_cv_kthread" = "yes"
1657then
1658 CXX="$CXX -Kthread"
1659 ac_cv_cxx_thread=yes
1660elif test "$ac_cv_pthread" = "yes"
1661then
1662 CXX="$CXX -pthread"
1663 ac_cv_cxx_thread=yes
1664fi
1665
1666if test $ac_cv_cxx_thread = yes
1667then
1668 echo 'void foo();int main(){foo();}void foo(){}' > conftest.$ac_ext
1669 $CXX -c conftest.$ac_ext 2>&5
1670 if $CXX -o conftest$ac_exeext conftest.$ac_objext 2>&5 \
1671 && test -s conftest$ac_exeext && ./conftest$ac_exeext
1672 then
1673 ac_cv_cxx_thread=yes
1674 else
1675 ac_cv_cxx_thread=no
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001676 fi
1677 rm -fr conftest*
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001678fi
Brett Cannonc601e0f2004-11-07 01:24:12 +00001679AC_MSG_RESULT($ac_cv_cxx_thread)
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001680fi
Martin v. Löwis519adae2003-09-20 10:47:47 +00001681CXX="$ac_save_cxx"
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001682
Fred Drakece81d592000-07-09 14:39:29 +00001683dnl # check for ANSI or K&R ("traditional") preprocessor
1684dnl AC_MSG_CHECKING(for C preprocessor type)
Matthias Klosec511b472010-05-08 11:01:39 +00001685dnl AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Fred Drakece81d592000-07-09 14:39:29 +00001686dnl #define spam(name, doc) {#name, &name, #name "() -- " doc}
1687dnl int foo;
1688dnl struct {char *name; int *addr; char *doc;} desc = spam(foo, "something");
Matthias Klosec511b472010-05-08 11:01:39 +00001689dnl ]], [[;]])],[cpp_type=ansi],[AC_DEFINE(HAVE_OLD_CPP) cpp_type=traditional])
Fred Drakece81d592000-07-09 14:39:29 +00001690dnl AC_MSG_RESULT($cpp_type)
Guido van Rossum300fda71996-08-19 21:58:16 +00001691
Guido van Rossum627b2d71993-12-24 10:39:16 +00001692# checks for header files
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001693AC_HEADER_STDC
doko@ubuntu.comf27ec3e2014-04-17 20:11:19 +02001694AC_CHECK_HEADERS(asm/types.h conio.h direct.h dlfcn.h errno.h \
Martin v. Löwis0e8bd7e2006-06-10 12:23:46 +00001695fcntl.h grp.h \
doko@ubuntu.comf27ec3e2014-04-17 20:11:19 +02001696ieeefp.h io.h langinfo.h libintl.h poll.h process.h pthread.h \
Martin v. Löwis40e9aed2006-10-02 15:20:37 +00001697shadow.h signal.h stdint.h stropts.h termios.h thread.h \
Martin v. Löwis14e73b12003-01-01 09:51:12 +00001698unistd.h utime.h \
Christian Heimes0e9ab5f2008-03-21 23:49:44 +00001699sys/audioio.h sys/bsdtty.h sys/epoll.h sys/event.h sys/file.h sys/loadavg.h \
1700sys/lock.h sys/mkdev.h sys/modem.h \
Benjamin Peterson6b1c9092016-12-19 23:54:25 -08001701sys/param.h sys/poll.h sys/random.h sys/select.h sys/socket.h sys/statvfs.h sys/stat.h \
Martin v. Löwis8c255e42008-05-23 15:06:50 +00001702sys/termio.h sys/time.h \
Martin v. Löwis0e8bd7e2006-06-10 12:23:46 +00001703sys/times.h sys/types.h sys/un.h sys/utsname.h sys/wait.h pty.h libutil.h \
Martin v. Löwis0347a9a2006-10-27 07:06:52 +00001704sys/resource.h netpacket/packet.h sysexits.h bluetooth.h \
Christian Heimesffa70112017-09-05 17:08:45 +02001705bluetooth/bluetooth.h linux/tipc.h spawn.h util.h alloca.h sys/sysmacros.h)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001706AC_HEADER_DIRENT
Martin v. Löwisdbe3f762002-10-10 14:27:30 +00001707AC_HEADER_MAJOR
Guido van Rossum627b2d71993-12-24 10:39:16 +00001708
Martin v. Löwis11017b12006-01-14 18:12:57 +00001709# On Linux, netlink.h requires asm/types.h
1710AC_CHECK_HEADERS(linux/netlink.h,,,[
1711#ifdef HAVE_ASM_TYPES_H
1712#include <asm/types.h>
1713#endif
1714#ifdef HAVE_SYS_SOCKET_H
1715#include <sys/socket.h>
1716#endif
1717])
1718
Guido van Rossum627b2d71993-12-24 10:39:16 +00001719# checks for typedefs
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001720was_it_defined=no
1721AC_MSG_CHECKING(for clock_t in time.h)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001722AC_EGREP_HEADER(clock_t, time.h, was_it_defined=yes, [
1723 AC_DEFINE(clock_t, long, [Define to 'long' if <time.h> doesn't define.])
1724])
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001725AC_MSG_RESULT($was_it_defined)
1726
Neal Norwitz11690112002-07-30 01:08:28 +00001727# Check whether using makedev requires defining _OSF_SOURCE
1728AC_MSG_CHECKING(for makedev)
Matthias Klosec511b472010-05-08 11:01:39 +00001729AC_LINK_IFELSE([AC_LANG_PROGRAM([[
Jesus Cea616de772010-04-28 10:32:30 +00001730#if defined(MAJOR_IN_MKDEV)
1731#include <sys/mkdev.h>
1732#elif defined(MAJOR_IN_SYSMACROS)
1733#include <sys/sysmacros.h>
1734#else
1735#include <sys/types.h>
Matthias Klosec511b472010-05-08 11:01:39 +00001736#endif ]], [[ makedev(0, 0) ]])],
1737[ac_cv_has_makedev=yes],
1738[ac_cv_has_makedev=no])
Neal Norwitz11690112002-07-30 01:08:28 +00001739if test "$ac_cv_has_makedev" = "no"; then
1740 # we didn't link, try if _OSF_SOURCE will allow us to link
Matthias Klosec511b472010-05-08 11:01:39 +00001741 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
Neal Norwitz6eb37f02003-02-23 23:28:15 +00001742#define _OSF_SOURCE 1
1743#include <sys/types.h>
Matthias Klosec511b472010-05-08 11:01:39 +00001744 ]], [[ makedev(0, 0) ]])],
1745[ac_cv_has_makedev=yes],
1746[ac_cv_has_makedev=no])
Neal Norwitz11690112002-07-30 01:08:28 +00001747 if test "$ac_cv_has_makedev" = "yes"; then
1748 AC_DEFINE(_OSF_SOURCE, 1, [Define _OSF_SOURCE to get the makedev macro.])
1749 fi
1750fi
1751AC_MSG_RESULT($ac_cv_has_makedev)
1752if test "$ac_cv_has_makedev" = "yes"; then
1753 AC_DEFINE(HAVE_MAKEDEV, 1, [Define this if you have the makedev macro.])
1754fi
1755
Martin v. Löwis399a6892002-10-04 10:22:02 +00001756# Enabling LFS on Solaris (2.6 to 9) with gcc 2.95 triggers a bug in
1757# the system headers: If _XOPEN_SOURCE and _LARGEFILE_SOURCE are
1758# defined, but the compiler does not support pragma redefine_extname,
1759# and _LARGEFILE64_SOURCE is not defined, the headers refer to 64-bit
1760# structures (such as rlimit64) without declaring them. As a
1761# work-around, disable LFS on such configurations
1762
1763use_lfs=yes
1764AC_MSG_CHECKING(Solaris LFS bug)
Matthias Klosec511b472010-05-08 11:01:39 +00001765AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwis399a6892002-10-04 10:22:02 +00001766#define _LARGEFILE_SOURCE 1
1767#define _FILE_OFFSET_BITS 64
1768#include <sys/resource.h>
Matthias Klosec511b472010-05-08 11:01:39 +00001769]], [[struct rlimit foo;]])],[sol_lfs_bug=no],[sol_lfs_bug=yes])
Martin v. Löwis399a6892002-10-04 10:22:02 +00001770AC_MSG_RESULT($sol_lfs_bug)
1771if test "$sol_lfs_bug" = "yes"; then
1772 use_lfs=no
1773fi
1774
1775if test "$use_lfs" = "yes"; then
Guido van Rossum810cc512001-09-09 23:51:39 +00001776# Two defines needed to enable largefile support on various platforms
1777# These may affect some typedefs
Georg Brandl94800df2011-02-25 11:09:02 +00001778case $ac_sys_system/$ac_sys_release in
1779AIX*)
1780 AC_DEFINE(_LARGE_FILES, 1,
1781 [This must be defined on AIX systems to enable large file support.])
1782 ;;
1783esac
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001784AC_DEFINE(_LARGEFILE_SOURCE, 1,
1785[This must be defined on some systems to enable large file support.])
1786AC_DEFINE(_FILE_OFFSET_BITS, 64,
1787[This must be set to 64 on some systems to enable large file support.])
Martin v. Löwis399a6892002-10-04 10:22:02 +00001788fi
Guido van Rossum810cc512001-09-09 23:51:39 +00001789
Guido van Rossum300fda71996-08-19 21:58:16 +00001790# Add some code to confdefs.h so that the test for off_t works on SCO
1791cat >> confdefs.h <<\EOF
1792#if defined(SCO_DS)
1793#undef _OFF_T
1794#endif
1795EOF
1796
Guido van Rossumef2255b2000-03-10 22:30:29 +00001797# Type availability checks
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001798AC_TYPE_MODE_T
1799AC_TYPE_OFF_T
1800AC_TYPE_PID_T
Matthias Klosecbf54b12010-05-08 11:04:18 +00001801AC_DEFINE_UNQUOTED([RETSIGTYPE],[void],[assume C89 semantics that RETSIGTYPE is always void])
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001802AC_TYPE_SIZE_T
1803AC_TYPE_UID_T
Mark Dickinson17c50cd2012-12-02 13:13:56 +00001804
1805# There are two separate checks for each of the exact-width integer types we
1806# need. First we check whether the type is available using the usual
1807# AC_CHECK_TYPE macro with the default includes (which includes <inttypes.h>
1808# and <stdint.h> where available). We then also use the special type checks of
1809# the form AC_TYPE_UINT32_T, which in the case that uint32_t is not available
1810# directly, #define's uint32_t to be a suitable type.
1811
1812AC_CHECK_TYPE(uint32_t,
1813 AC_DEFINE(HAVE_UINT32_T, 1, [Define if your compiler provides uint32_t.]),,)
Mark Dickinsonefc82f72009-03-20 15:51:55 +00001814AC_TYPE_UINT32_T
Mark Dickinson17c50cd2012-12-02 13:13:56 +00001815
1816AC_CHECK_TYPE(uint64_t,
1817 AC_DEFINE(HAVE_UINT64_T, 1, [Define if your compiler provides uint64_t.]),,)
Mark Dickinsonefc82f72009-03-20 15:51:55 +00001818AC_TYPE_UINT64_T
Mark Dickinson17c50cd2012-12-02 13:13:56 +00001819
1820AC_CHECK_TYPE(int32_t,
1821 AC_DEFINE(HAVE_INT32_T, 1, [Define if your compiler provides int32_t.]),,)
Mark Dickinsonefc82f72009-03-20 15:51:55 +00001822AC_TYPE_INT32_T
Mark Dickinson17c50cd2012-12-02 13:13:56 +00001823
1824AC_CHECK_TYPE(int64_t,
1825 AC_DEFINE(HAVE_INT64_T, 1, [Define if your compiler provides int64_t.]),,)
Mark Dickinsonefc82f72009-03-20 15:51:55 +00001826AC_TYPE_INT64_T
Mark Dickinson17c50cd2012-12-02 13:13:56 +00001827
Christian Heimes951cc0f2008-01-31 23:08:23 +00001828AC_CHECK_TYPE(ssize_t,
Matthias Klose5183ebd2010-04-24 16:38:36 +00001829 AC_DEFINE(HAVE_SSIZE_T, 1, [Define if your compiler provides ssize_t]),,)
Guido van Rossum627b2d71993-12-24 10:39:16 +00001830
Guido van Rossumef2255b2000-03-10 22:30:29 +00001831# Sizes of various common basic types
Skip Montanarob9820a32004-01-17 00:16:12 +00001832# ANSI C requires sizeof(char) == 1, so no need to check it
Guido van Rossum3065c942001-09-17 04:03:14 +00001833AC_CHECK_SIZEOF(int, 4)
1834AC_CHECK_SIZEOF(long, 4)
1835AC_CHECK_SIZEOF(void *, 4)
Guido van Rossum3065c942001-09-17 04:03:14 +00001836AC_CHECK_SIZEOF(short, 2)
1837AC_CHECK_SIZEOF(float, 4)
1838AC_CHECK_SIZEOF(double, 8)
1839AC_CHECK_SIZEOF(fpos_t, 4)
Martin v. Löwis18e16552006-02-15 17:27:45 +00001840AC_CHECK_SIZEOF(size_t, 4)
Christian Heimes951cc0f2008-01-31 23:08:23 +00001841AC_CHECK_SIZEOF(pid_t, 4)
Guido van Rossumac405f61994-09-12 10:56:06 +00001842
Guido van Rossumec95c7b1998-08-04 17:59:56 +00001843AC_MSG_CHECKING(for long long support)
1844have_long_long=no
Matthias Klosec511b472010-05-08 11:01:39 +00001845AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[long long x; x = (long long)0;]])],[
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001846 AC_DEFINE(HAVE_LONG_LONG, 1, [Define this if you have the type long long.])
1847 have_long_long=yes
Matthias Klosec511b472010-05-08 11:01:39 +00001848],[])
Guido van Rossumec95c7b1998-08-04 17:59:56 +00001849AC_MSG_RESULT($have_long_long)
Guido van Rossum8bc1dfd1999-04-10 16:01:48 +00001850if test "$have_long_long" = yes ; then
Guido van Rossum3065c942001-09-17 04:03:14 +00001851AC_CHECK_SIZEOF(long long, 8)
Guido van Rossumec95c7b1998-08-04 17:59:56 +00001852fi
1853
Travis E. Oliphant711c9e92008-06-06 22:33:21 +00001854AC_MSG_CHECKING(for long double support)
1855have_long_double=no
Matthias Klosec511b472010-05-08 11:01:39 +00001856AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[long double x; x = (long double)0;]])],[
Travis E. Oliphant711c9e92008-06-06 22:33:21 +00001857 AC_DEFINE(HAVE_LONG_DOUBLE, 1, [Define this if you have the type long double.])
1858 have_long_double=yes
Matthias Klosec511b472010-05-08 11:01:39 +00001859],[])
Travis E. Oliphant711c9e92008-06-06 22:33:21 +00001860AC_MSG_RESULT($have_long_double)
Mark Dickinsondc1688a2008-06-27 22:20:14 +00001861if test "$have_long_double" = yes ; then
Travis E. Oliphant711c9e92008-06-06 22:33:21 +00001862AC_CHECK_SIZEOF(long double, 12)
1863fi
1864
Martin v. Löwisaef4c6b2007-01-21 09:33:07 +00001865AC_MSG_CHECKING(for _Bool support)
1866have_c99_bool=no
Matthias Klosec511b472010-05-08 11:01:39 +00001867AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[_Bool x; x = (_Bool)0;]])],[
Martin v. Löwisaef4c6b2007-01-21 09:33:07 +00001868 AC_DEFINE(HAVE_C99_BOOL, 1, [Define this if you have the type _Bool.])
1869 have_c99_bool=yes
Matthias Klosec511b472010-05-08 11:01:39 +00001870],[])
Martin v. Löwisaef4c6b2007-01-21 09:33:07 +00001871AC_MSG_RESULT($have_c99_bool)
1872if test "$have_c99_bool" = yes ; then
1873AC_CHECK_SIZEOF(_Bool, 1)
1874fi
1875
Martin v. Löwisebe26702006-10-02 14:55:51 +00001876AC_CHECK_TYPES(uintptr_t,
1877 [AC_CHECK_SIZEOF(uintptr_t, 4)],
Martin v. Löwis40e9aed2006-10-02 15:20:37 +00001878 [], [#ifdef HAVE_STDINT_H
1879 #include <stdint.h>
Antoine Pitrou7be5a652010-10-10 08:14:41 +00001880 #endif
1881 #ifdef HAVE_INTTYPES_H
1882 #include <inttypes.h>
Martin v. Löwis40e9aed2006-10-02 15:20:37 +00001883 #endif])
Martin v. Löwisebe26702006-10-02 14:55:51 +00001884
Alexandre Vassalotti856782e2009-07-17 04:59:05 +00001885AC_CHECK_SIZEOF(off_t, [], [
1886#ifdef HAVE_SYS_TYPES_H
1887#include <sys/types.h>
1888#endif
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001889])
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001890
1891AC_MSG_CHECKING(whether to enable large file support)
Mark Dickinson0ef0b912009-12-31 21:11:48 +00001892if test "$have_long_long" = yes
1893then
1894if test "$ac_cv_sizeof_off_t" -gt "$ac_cv_sizeof_long" -a \
Guido van Rossum8bc1dfd1999-04-10 16:01:48 +00001895 "$ac_cv_sizeof_long_long" -ge "$ac_cv_sizeof_off_t"; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001896 AC_DEFINE(HAVE_LARGEFILE_SUPPORT, 1,
1897 [Defined to enable large file support when an off_t is bigger than a long
1898 and long long is available and at least as big as an off_t. You may need
1899 to add some flags for configuration and compilation to enable this mode.
1900 (For Solaris and Linux, the necessary defines are already defined.)])
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001901 AC_MSG_RESULT(yes)
1902else
1903 AC_MSG_RESULT(no)
1904fi
Mark Dickinson0ef0b912009-12-31 21:11:48 +00001905else
1906 AC_MSG_RESULT(no)
1907fi
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001908
Alexandre Vassalotti856782e2009-07-17 04:59:05 +00001909AC_CHECK_SIZEOF(time_t, [], [
1910#ifdef HAVE_SYS_TYPES_H
1911#include <sys/types.h>
1912#endif
1913#ifdef HAVE_TIME_H
1914#include <time.h>
1915#endif
Fred Drakea3f6e912000-06-29 20:44:47 +00001916])
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001917
Trent Mick635f6fb2000-08-23 21:33:05 +00001918# if have pthread_t then define SIZEOF_PTHREAD_T
Martin v. Löwis123cbd22001-07-19 14:21:10 +00001919ac_save_cc="$CC"
1920if test "$ac_cv_kpthread" = "yes"
1921then CC="$CC -Kpthread"
Martin v. Löwis5f433f02003-05-05 05:05:30 +00001922elif test "$ac_cv_kthread" = "yes"
1923then CC="$CC -Kthread"
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00001924elif test "$ac_cv_pthread" = "yes"
1925then CC="$CC -pthread"
Martin v. Löwis123cbd22001-07-19 14:21:10 +00001926fi
Trent Mick635f6fb2000-08-23 21:33:05 +00001927AC_MSG_CHECKING(for pthread_t)
1928have_pthread_t=no
Matthias Klosec511b472010-05-08 11:01:39 +00001929AC_COMPILE_IFELSE([
1930 AC_LANG_PROGRAM([[#include <pthread.h>]], [[pthread_t x; x = *(pthread_t*)0;]])
1931],[have_pthread_t=yes],[])
Trent Mick635f6fb2000-08-23 21:33:05 +00001932AC_MSG_RESULT($have_pthread_t)
1933if test "$have_pthread_t" = yes ; then
Alexandre Vassalotti856782e2009-07-17 04:59:05 +00001934 AC_CHECK_SIZEOF(pthread_t, [], [
1935#ifdef HAVE_PTHREAD_H
1936#include <pthread.h>
1937#endif
Trent Mick635f6fb2000-08-23 21:33:05 +00001938 ])
Trent Mick635f6fb2000-08-23 21:33:05 +00001939fi
Martin v. Löwis123cbd22001-07-19 14:21:10 +00001940CC="$ac_save_cc"
Trent Mick635f6fb2000-08-23 21:33:05 +00001941
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001942AC_MSG_CHECKING(for --enable-toolbox-glue)
1943AC_ARG_ENABLE(toolbox-glue,
Matthias Klose22520ea2010-05-08 10:14:46 +00001944 AS_HELP_STRING([--enable-toolbox-glue], [disable/enable MacOSX glue code for extensions]))
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001945
1946if test -z "$enable_toolbox_glue"
1947then
1948 case $ac_sys_system/$ac_sys_release in
1949 Darwin/*)
1950 enable_toolbox_glue="yes";;
1951 *)
1952 enable_toolbox_glue="no";;
1953 esac
1954fi
1955case "$enable_toolbox_glue" in
1956yes)
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001957 extra_machdep_objs="Python/mactoolboxglue.o"
Raymond Hettingerec6eb362004-11-05 07:02:59 +00001958 extra_undefs="-u _PyMac_Error"
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001959 AC_DEFINE(USE_TOOLBOX_OBJECT_GLUE, 1,
1960 [Define if you want to use MacPython modules on MacOSX in unix-Python.])
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001961 ;;
1962*)
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001963 extra_machdep_objs=""
Jack Jansen591cbed2001-08-15 13:55:15 +00001964 extra_undefs=""
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001965 ;;
1966esac
1967AC_MSG_RESULT($enable_toolbox_glue)
1968
Ronald Oussoren0d236eb2008-06-06 21:31:33 +00001969
Bob Ippolito7026a0a2005-03-28 23:23:47 +00001970AC_SUBST(OTHER_LIBTOOL_OPT)
1971case $ac_sys_system/$ac_sys_release in
Anthony Baxter82201742006-04-09 15:07:40 +00001972 Darwin/@<:@01567@:>@\..*)
Bob Ippolito7026a0a2005-03-28 23:23:47 +00001973 OTHER_LIBTOOL_OPT="-prebind -seg1addr 0x10000000"
1974 ;;
1975 Darwin/*)
1976 OTHER_LIBTOOL_OPT=""
1977 ;;
1978esac
1979
Ronald Oussoren25967582009-09-06 10:00:26 +00001980
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001981AC_SUBST(LIBTOOL_CRUFT)
1982case $ac_sys_system/$ac_sys_release in
Anthony Baxter82201742006-04-09 15:07:40 +00001983 Darwin/@<:@01567@:>@\..*)
Ronald Oussoren988117f2006-04-29 11:31:35 +00001984 LIBTOOL_CRUFT="-framework System -lcc_dynamic"
1985 if test "${enable_universalsdk}"; then
1986 :
1987 else
Ronald Oussorenbc0e83c2010-02-11 13:26:54 +00001988 LIBTOOL_CRUFT="${LIBTOOL_CRUFT} -arch_only `/usr/bin/arch`"
Ronald Oussoren988117f2006-04-29 11:31:35 +00001989 fi
Jack Jansenb36687a2004-07-16 08:43:47 +00001990 LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -install_name $(PYTHONFRAMEWORKINSTALLDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansena3891ea2001-09-07 14:25:12 +00001991 LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -compatibility_version $(VERSION) -current_version $(VERSION)';;
Guido van Rossum5839e582000-10-09 19:52:35 +00001992 Darwin/*)
Ronald Oussorena55af9a2010-01-17 16:25:57 +00001993 gcc_version=`gcc -dumpversion`
Bob Ippolito7026a0a2005-03-28 23:23:47 +00001994 if test ${gcc_version} '<' 4.0
1995 then
1996 LIBTOOL_CRUFT="-lcc_dynamic"
1997 else
1998 LIBTOOL_CRUFT=""
1999 fi
Matthias Klosec511b472010-05-08 11:01:39 +00002000 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Ronald Oussoren25967582009-09-06 10:00:26 +00002001 #include <unistd.h>
2002 int main(int argc, char*argv[])
2003 {
2004 if (sizeof(long) == 4) {
2005 return 0;
2006 } else {
2007 return 1;
2008 }
Ronald Oussoren84ddd722009-09-08 07:17:10 +00002009 }
Matthias Klosec511b472010-05-08 11:01:39 +00002010 ]])],[ac_osx_32bit=yes],[ac_osx_32bit=no],[ac_osx_32bit=yes])
Ronald Oussoren25967582009-09-06 10:00:26 +00002011
2012 if test "${ac_osx_32bit}" = "yes"; then
Ronald Oussorenbc0e83c2010-02-11 13:26:54 +00002013 case `/usr/bin/arch` in
Ronald Oussoren25967582009-09-06 10:00:26 +00002014 i386)
2015 MACOSX_DEFAULT_ARCH="i386"
2016 ;;
2017 ppc)
2018 MACOSX_DEFAULT_ARCH="ppc"
2019 ;;
2020 *)
2021 AC_MSG_ERROR([Unexpected output of 'arch' on OSX])
2022 ;;
2023 esac
2024 else
Ronald Oussorenbc0e83c2010-02-11 13:26:54 +00002025 case `/usr/bin/arch` in
Ronald Oussoren25967582009-09-06 10:00:26 +00002026 i386)
2027 MACOSX_DEFAULT_ARCH="x86_64"
2028 ;;
2029 ppc)
2030 MACOSX_DEFAULT_ARCH="ppc64"
2031 ;;
2032 *)
2033 AC_MSG_ERROR([Unexpected output of 'arch' on OSX])
2034 ;;
2035 esac
2036
2037 #ARCH_RUN_32BIT="true"
2038 fi
2039
2040 LIBTOOL_CRUFT=$LIBTOOL_CRUFT" -lSystem -lSystemStubs -arch_only ${MACOSX_DEFAULT_ARCH}"
Jack Jansenb36687a2004-07-16 08:43:47 +00002041 LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -install_name $(PYTHONFRAMEWORKINSTALLDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansenb6e9cad2001-08-15 01:26:28 +00002042 LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -compatibility_version $(VERSION) -current_version $(VERSION)';;
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00002043esac
2044
Jack Jansenb6e9cad2001-08-15 01:26:28 +00002045AC_MSG_CHECKING(for --enable-framework)
2046if test "$enable_framework"
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00002047then
Skip Montanarodecc6a42003-01-01 20:07:49 +00002048 BASECFLAGS="$BASECFLAGS -fno-common -dynamic"
Jack Jansenb6e9cad2001-08-15 01:26:28 +00002049 # -F. is needed to allow linking to the framework while
2050 # in the build location.
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002051 AC_DEFINE(WITH_NEXT_FRAMEWORK, 1,
2052 [Define if you want to produce an OpenStep/Rhapsody framework
2053 (shared library plus accessory files).])
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00002054 AC_MSG_RESULT(yes)
Ronald Oussoren450d5612009-06-08 21:12:41 +00002055 if test $enable_shared = "yes"
2056 then
Ronald Oussoren9ebd2422009-09-29 13:00:44 +00002057 AC_MSG_ERROR([Specifying both --enable-shared and --enable-framework is not supported, use only --enable-framework instead. See Mac/README.])
Ronald Oussoren450d5612009-06-08 21:12:41 +00002058 fi
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00002059else
2060 AC_MSG_RESULT(no)
2061fi
2062
Jack Jansenb6e9cad2001-08-15 01:26:28 +00002063AC_MSG_CHECKING(for dyld)
Jack Jansen9a66b6d2001-08-08 13:56:14 +00002064case $ac_sys_system/$ac_sys_release in
2065 Darwin/*)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002066 AC_DEFINE(WITH_DYLD, 1,
2067 [Define if you want to use the new-style (Openstep, Rhapsody, MacOS)
2068 dynamic linker (dyld) instead of the old-style (NextStep) dynamic
2069 linker (rld). Dyld is necessary to support frameworks.])
Jack Jansen9a66b6d2001-08-08 13:56:14 +00002070 AC_MSG_RESULT(always on for Darwin)
2071 ;;
2072 *)
Jack Jansenb6e9cad2001-08-15 01:26:28 +00002073 AC_MSG_RESULT(no)
2074 ;;
Jack Jansen9a66b6d2001-08-08 13:56:14 +00002075esac
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00002076
Guido van Rossumac405f61994-09-12 10:56:06 +00002077# Set info about shared libraries.
Guido van Rossumac405f61994-09-12 10:56:06 +00002078AC_SUBST(SO)
2079AC_SUBST(LDSHARED)
Tarek Ziadé00002952010-04-03 08:37:59 +00002080AC_SUBST(LDCXXSHARED)
Neil Schemenauerb3531b82001-02-16 04:09:05 +00002081AC_SUBST(BLDSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00002082AC_SUBST(CCSHARED)
2083AC_SUBST(LINKFORSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00002084# SO is the extension of shared libraries `(including the dot!)
Guido van Rossumaef734b2001-01-10 21:09:12 +00002085# -- usually .so, .sl on HP-UX, .dll on Cygwin
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002086AC_MSG_CHECKING(SO)
Guido van Rossumac405f61994-09-12 10:56:06 +00002087if test -z "$SO"
2088then
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002089 case $ac_sys_system in
Neal Norwitz58e28882006-05-19 07:00:58 +00002090 hp*|HP*)
2091 case `uname -m` in
2092 ia64) SO=.so;;
2093 *) SO=.sl;;
2094 esac
2095 ;;
Guido van Rossumaef734b2001-01-10 21:09:12 +00002096 CYGWIN*) SO=.dll;;
Guido van Rossum4b6b5791996-09-09 20:09:34 +00002097 *) SO=.so;;
Guido van Rossumac405f61994-09-12 10:56:06 +00002098 esac
Martin v. Löwis368de8f2003-06-14 14:46:38 +00002099else
2100 # this might also be a termcap variable, see #610332
2101 echo
2102 echo '====================================================================='
2103 echo '+ +'
2104 echo '+ WARNING: You have set SO in your environment. +'
2105 echo '+ Do you really mean to change the extension for shared libraries? +'
2106 echo '+ Continuing in 10 seconds to let you to ponder. +'
2107 echo '+ +'
2108 echo '====================================================================='
2109 sleep 10
Guido van Rossumac405f61994-09-12 10:56:06 +00002110fi
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002111AC_MSG_RESULT($SO)
Ronald Oussoren79f90492009-01-02 10:44:46 +00002112
Neal Norwitz58e28882006-05-19 07:00:58 +00002113AC_DEFINE_UNQUOTED(SHLIB_EXT, "$SO", [Define this to be extension of shared libraries (including the dot!).])
Guido van Rossumac405f61994-09-12 10:56:06 +00002114# LDSHARED is the ld *command* used to create shared library
Skip Montanaroce59c042004-01-17 14:19:44 +00002115# -- "cc -G" on SunOS 5.x, "ld -shared" on IRIX 5
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00002116# (Shared libraries in this instance are shared modules to be loaded into
2117# Python, as opposed to building Python itself as a shared library.)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002118AC_MSG_CHECKING(LDSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00002119if test -z "$LDSHARED"
2120then
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002121 case $ac_sys_system/$ac_sys_release in
Neil Schemenauerb3531b82001-02-16 04:09:05 +00002122 AIX*)
Martin Panterf75a2eb2016-11-20 09:31:41 +00002123 BLDSHARED="Modules/ld_so_aix \$(CC) -bI:Modules/python.exp"
Guido van Rossumce608b02001-09-28 15:59:38 +00002124 LDSHARED="\$(BINLIBDEST)/config/ld_so_aix \$(CC) -bI:\$(BINLIBDEST)/config/python.exp"
Neil Schemenauerb3531b82001-02-16 04:09:05 +00002125 ;;
2126 BeOS*)
2127 BLDSHARED="\$(srcdir)/Modules/ld_so_beos $LDLIBRARY"
Guido van Rossumce608b02001-09-28 15:59:38 +00002128 LDSHARED="\$(BINLIBDEST)/config/ld_so_beos \$(LIBDIR)/$LDLIBRARY"
Neil Schemenauerb3531b82001-02-16 04:09:05 +00002129 ;;
Guido van Rossum6100aaf1997-04-29 21:48:51 +00002130 IRIX/5*) LDSHARED="ld -shared";;
Guido van Rossum91922671997-10-09 20:24:13 +00002131 IRIX*/6*) LDSHARED="ld ${SGI_ABI} -shared -all";;
Greg Ward57c9a662000-05-26 12:22:54 +00002132 SunOS/5*)
Tarek Ziadé00002952010-04-03 08:37:59 +00002133 if test "$GCC" = "yes" ; then
2134 LDSHARED='$(CC) -shared'
2135 LDCXXSHARED='$(CXX) -shared'
2136 else
2137 LDSHARED='$(CC) -G'
2138 LDCXXSHARED='$(CXX) -G'
Greg Ward57c9a662000-05-26 12:22:54 +00002139 fi ;;
Thomas Hellerdc96a772008-04-04 10:07:55 +00002140 hp*|HP*)
Tarek Ziadé00002952010-04-03 08:37:59 +00002141 if test "$GCC" = "yes" ; then
2142 LDSHARED='$(CC) -shared'
2143 LDCXXSHARED='$(CXX) -shared'
2144 else
2145 LDSHARED='ld -b'
Thomas Hellerdc96a772008-04-04 10:07:55 +00002146 fi ;;
Guido van Rossum71001e41995-01-26 00:44:03 +00002147 OSF*) LDSHARED="ld -shared -expect_unresolved \"*\"";;
Jack Jansen418c3b12001-11-14 10:59:57 +00002148 Darwin/1.3*)
Stefan Krah3a3e2032010-11-28 15:30:05 +00002149 LDSHARED='$(CC) -bundle'
2150 LDCXXSHARED='$(CXX) -bundle'
Jack Jansena3891ea2001-09-07 14:25:12 +00002151 if test "$enable_framework" ; then
2152 # Link against the framework. All externals should be defined.
Jack Jansenda49e192005-01-07 13:08:22 +00002153 BLDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
2154 LDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Tarek Ziadé00002952010-04-03 08:37:59 +00002155 LDCXXSHARED="$LDCXXSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansena3891ea2001-09-07 14:25:12 +00002156 else
2157 # No framework. Ignore undefined symbols, assuming they come from Python
Jack Jansen418c3b12001-11-14 10:59:57 +00002158 LDSHARED="$LDSHARED -undefined suppress"
Tarek Ziadé00002952010-04-03 08:37:59 +00002159 LDCXXSHARED="$LDCXXSHARED -undefined suppress"
Jack Jansena3891ea2001-09-07 14:25:12 +00002160 fi ;;
Jack Jansen6b08a402004-06-03 12:41:45 +00002161 Darwin/1.4*|Darwin/5.*|Darwin/6.*)
Stefan Krah3a3e2032010-11-28 15:30:05 +00002162 LDSHARED='$(CC) -bundle'
2163 LDCXXSHARED='$(CXX) -bundle'
Jack Jansenb6e9cad2001-08-15 01:26:28 +00002164 if test "$enable_framework" ; then
2165 # Link against the framework. All externals should be defined.
Jack Jansenda49e192005-01-07 13:08:22 +00002166 BLDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
2167 LDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Tarek Ziadé00002952010-04-03 08:37:59 +00002168 LDCXXSHARED="$LDCXXSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansenb6e9cad2001-08-15 01:26:28 +00002169 else
Michael W. Hudson0c46c0c2002-03-07 09:58:56 +00002170 # No framework, use the Python app as bundle-loader
2171 BLDSHARED="$LDSHARED "'-bundle_loader $(BUILDPYTHON)'
Jack Jansenc28fc372003-02-25 13:14:43 +00002172 LDSHARED="$LDSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)'
Tarek Ziadé00002952010-04-03 08:37:59 +00002173 LDCXXSHARED="$LDCXXSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)'
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00002174 fi ;;
Jack Jansen6b08a402004-06-03 12:41:45 +00002175 Darwin/*)
2176 # Use -undefined dynamic_lookup whenever possible (10.3 and later).
2177 # This allows an extension to be used in any Python
Ronald Oussoren38f1b982007-09-02 09:46:07 +00002178
Ned Deilyc40b9032014-06-25 13:48:46 -07002179 dep_target_major=`echo ${MACOSX_DEPLOYMENT_TARGET} | \
2180 sed 's/\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'`
2181 dep_target_minor=`echo ${MACOSX_DEPLOYMENT_TARGET} | \
2182 sed 's/\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'`
2183 if test ${dep_target_major} -eq 10 && \
2184 test ${dep_target_minor} -le 2
Jack Jansen6b08a402004-06-03 12:41:45 +00002185 then
Ned Deilyc40b9032014-06-25 13:48:46 -07002186 # building for OS X 10.0 through 10.2
Stefan Krah3a3e2032010-11-28 15:30:05 +00002187 LDSHARED='$(CC) -bundle'
2188 LDCXXSHARED='$(CXX) -bundle'
Jack Jansen6b08a402004-06-03 12:41:45 +00002189 if test "$enable_framework" ; then
2190 # Link against the framework. All externals should be defined.
Jack Jansenda49e192005-01-07 13:08:22 +00002191 BLDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
2192 LDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Tarek Ziadé00002952010-04-03 08:37:59 +00002193 LDCXXSHARED="$LDCXXSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansen6b08a402004-06-03 12:41:45 +00002194 else
2195 # No framework, use the Python app as bundle-loader
2196 BLDSHARED="$LDSHARED "'-bundle_loader $(BUILDPYTHON)'
2197 LDSHARED="$LDSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)'
Tarek Ziadé00002952010-04-03 08:37:59 +00002198 LDCXXSHARED="$LDCXXSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)'
Jack Jansen6b08a402004-06-03 12:41:45 +00002199 fi
Ned Deilyc40b9032014-06-25 13:48:46 -07002200 else
2201 # building for OS X 10.3 and later
2202 if test "${enable_universalsdk}"; then
2203 LDFLAGS="${UNIVERSAL_ARCH_FLAGS} -isysroot ${UNIVERSALSDK} ${LDFLAGS}"
2204 fi
2205 LDSHARED='$(CC) -bundle -undefined dynamic_lookup'
2206 LDCXXSHARED='$(CXX) -bundle -undefined dynamic_lookup'
2207 BLDSHARED="$LDSHARED"
Jack Jansen6b08a402004-06-03 12:41:45 +00002208 fi
2209 ;;
Tarek Ziadé00002952010-04-03 08:37:59 +00002210 Linux*|GNU*|QNX*)
2211 LDSHARED='$(CC) -shared'
2212 LDCXXSHARED='$(CXX) -shared';;
2213 BSD/OS*/4*)
2214 LDSHARED="gcc -shared"
2215 LDCXXSHARED="g++ -shared";;
Martin v. Löwis222c5152006-06-03 07:37:13 +00002216 FreeBSD*)
Jeremy Hylton4bcc7c52000-08-31 17:45:35 +00002217 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
Guido van Rossum0286ae82000-08-29 15:06:49 +00002218 then
Stefan Krah3a3e2032010-11-28 15:30:05 +00002219 LDSHARED='$(CC) -shared'
2220 LDCXXSHARED='$(CXX) -shared'
Guido van Rossum0286ae82000-08-29 15:06:49 +00002221 else
Stefan Krah3a3e2032010-11-28 15:30:05 +00002222 LDSHARED="ld -Bshareable"
Guido van Rossum0286ae82000-08-29 15:06:49 +00002223 fi;;
Martin v. Löwis222c5152006-06-03 07:37:13 +00002224 OpenBSD*)
2225 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
2226 then
Stefan Krah3a3e2032010-11-28 15:30:05 +00002227 LDSHARED='$(CC) -shared $(CCSHARED)'
2228 LDCXXSHARED='$(CXX) -shared $(CCSHARED)'
Martin v. Löwis222c5152006-06-03 07:37:13 +00002229 else
2230 case `uname -r` in
2231 [[01]].* | 2.[[0-7]] | 2.[[0-7]].*)
2232 LDSHARED="ld -Bshareable ${LDFLAGS}"
2233 ;;
2234 *)
Stefan Krah3a3e2032010-11-28 15:30:05 +00002235 LDSHARED='$(CC) -shared $(CCSHARED)'
2236 LDCXXSHARED='$(CXX) -shared $(CCSHARED)'
Martin v. Löwis222c5152006-06-03 07:37:13 +00002237 ;;
2238 esac
2239 fi;;
Tarek Ziadé00002952010-04-03 08:37:59 +00002240 NetBSD*|DragonFly*)
Antoine Pitroucb402772011-01-02 20:51:34 +00002241 LDSHARED='$(CC) -shared'
2242 LDCXXSHARED='$(CXX) -shared';;
Martin v. Löwis25ae43b2001-10-07 08:39:18 +00002243 OpenUNIX*|UnixWare*)
Tarek Ziadé00002952010-04-03 08:37:59 +00002244 if test "$GCC" = "yes" ; then
2245 LDSHARED='$(CC) -shared'
2246 LDCXXSHARED='$(CXX) -shared'
2247 else
2248 LDSHARED='$(CC) -G'
2249 LDCXXSHARED='$(CXX) -G'
Martin v. Löwisbec19582001-03-21 15:57:54 +00002250 fi;;
Tarek Ziadé00002952010-04-03 08:37:59 +00002251 SCO_SV*)
2252 LDSHARED='$(CC) -Wl,-G,-Bexport'
2253 LDCXXSHARED='$(CXX) -Wl,-G,-Bexport';;
2254 CYGWIN*)
2255 LDSHARED="gcc -shared -Wl,--enable-auto-image-base"
2256 LDCXXSHARED="g++ -shared -Wl,--enable-auto-image-base";;
2257 atheos*)
2258 LDSHARED="gcc -shared"
2259 LDCXXSHARED="g++ -shared";;
Guido van Rossumac405f61994-09-12 10:56:06 +00002260 *) LDSHARED="ld";;
2261 esac
Guido van Rossumac405f61994-09-12 10:56:06 +00002262fi
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002263AC_MSG_RESULT($LDSHARED)
Tarek Ziadé00002952010-04-03 08:37:59 +00002264LDCXXSHARED=${LDCXXSHARED-$LDSHARED}
Neil Schemenauerb3531b82001-02-16 04:09:05 +00002265BLDSHARED=${BLDSHARED-$LDSHARED}
Guido van Rossumac405f61994-09-12 10:56:06 +00002266# CCSHARED are the C *flags* used to create objects to go into a shared
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00002267# library (module) -- this is only needed for a few systems
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002268AC_MSG_CHECKING(CCSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00002269if test -z "$CCSHARED"
2270then
Guido van Rossum6100aaf1997-04-29 21:48:51 +00002271 case $ac_sys_system/$ac_sys_release in
Neil Schemenauer66252162001-02-19 04:47:42 +00002272 SunOS*) if test "$GCC" = yes;
Martin v. Löwiseb623572007-03-12 10:50:39 +00002273 then CCSHARED="-fPIC";
2274 elif test `uname -p` = sparc;
2275 then CCSHARED="-xcode=pic32";
2276 else CCSHARED="-Kpic";
2277 fi;;
Guido van Rossumaf07a441995-02-13 19:45:27 +00002278 hp*|HP*) if test "$GCC" = yes;
Martin v. Löwis703ad702001-09-05 08:36:52 +00002279 then CCSHARED="-fPIC";
Guido van Rossumaf07a441995-02-13 19:45:27 +00002280 else CCSHARED="+z";
2281 fi;;
Martin v. Löwisa6e97582002-01-01 18:41:33 +00002282 Linux*|GNU*) CCSHARED="-fPIC";;
Guido van Rossumf5957ea1999-10-05 21:59:33 +00002283 BSD/OS*/4*) CCSHARED="-fpic";;
Martin v. Löwis86d66262006-02-17 08:40:11 +00002284 FreeBSD*|NetBSD*|OpenBSD*|DragonFly*) CCSHARED="-fPIC";;
Martin v. Löwis25ae43b2001-10-07 08:39:18 +00002285 OpenUNIX*|UnixWare*)
Martin v. Löwisbec19582001-03-21 15:57:54 +00002286 if test "$GCC" = "yes"
2287 then CCSHARED="-fPIC"
Martin v. Löwis130fb172001-07-19 11:00:41 +00002288 else CCSHARED="-KPIC"
Martin v. Löwisbec19582001-03-21 15:57:54 +00002289 fi;;
Martin v. Löwis21ee4092002-09-30 16:19:48 +00002290 SCO_SV*)
2291 if test "$GCC" = "yes"
2292 then CCSHARED="-fPIC"
2293 else CCSHARED="-Kpic -belf"
2294 fi;;
Guido van Rossum2b5ca001998-03-05 15:41:09 +00002295 IRIX*/6*) case $CC in
2296 *gcc*) CCSHARED="-shared";;
Guido van Rossumee21f411998-04-20 18:51:54 +00002297 *) CCSHARED="";;
Guido van Rossum2b5ca001998-03-05 15:41:09 +00002298 esac;;
Martin v. Löwisf90ae202002-06-11 06:22:31 +00002299 atheos*) CCSHARED="-fPIC";;
Guido van Rossumac405f61994-09-12 10:56:06 +00002300 esac
Guido van Rossumac405f61994-09-12 10:56:06 +00002301fi
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002302AC_MSG_RESULT($CCSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00002303# LINKFORSHARED are the flags passed to the $(CC) command that links
Guido van Rossumb65a48e1995-06-14 18:21:23 +00002304# the python executable -- this is only needed for a few systems
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002305AC_MSG_CHECKING(LINKFORSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00002306if test -z "$LINKFORSHARED"
2307then
Guido van Rossum6100aaf1997-04-29 21:48:51 +00002308 case $ac_sys_system/$ac_sys_release in
Neil Schemenauerb3531b82001-02-16 04:09:05 +00002309 AIX*) LINKFORSHARED='-Wl,-bE:Modules/python.exp -lld';;
Guido van Rossum5dab3d81996-12-06 21:18:18 +00002310 hp*|HP*)
Martin v. Löwis1142de32002-03-29 16:28:31 +00002311 LINKFORSHARED="-Wl,-E -Wl,+s";;
2312# LINKFORSHARED="-Wl,-E -Wl,+s -Wl,+b\$(BINLIBDEST)/lib-dynload";;
Guido van Rossumf5957ea1999-10-05 21:59:33 +00002313 BSD/OS/4*) LINKFORSHARED="-Xlinker -export-dynamic";;
Martin v. Löwisa6e97582002-01-01 18:41:33 +00002314 Linux*|GNU*) LINKFORSHARED="-Xlinker -export-dynamic";;
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00002315 # -u libsys_s pulls in all symbols in libsys
Jack Jansenb6e9cad2001-08-15 01:26:28 +00002316 Darwin/*)
Raymond Hettingerec6eb362004-11-05 07:02:59 +00002317 # -u _PyMac_Error is needed to pull in the mac toolbox glue,
2318 # which is
Jack Jansenb6e9cad2001-08-15 01:26:28 +00002319 # not used by the core itself but which needs to be in the core so
2320 # that dynamically loaded extension modules have access to it.
Jack Jansen97e3f002003-02-23 22:59:01 +00002321 # -prebind is no longer used, because it actually seems to give a
2322 # slowdown in stead of a speedup, maybe due to the large number of
2323 # dynamic loads Python does.
Raymond Hettingerec6eb362004-11-05 07:02:59 +00002324
2325 LINKFORSHARED="$extra_undefs"
Jack Jansenb6e9cad2001-08-15 01:26:28 +00002326 if test "$enable_framework"
2327 then
Jack Jansenda49e192005-01-07 13:08:22 +00002328 LINKFORSHARED="$LINKFORSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansenb6e9cad2001-08-15 01:26:28 +00002329 fi
Raymond Hettingerec6eb362004-11-05 07:02:59 +00002330 LINKFORSHARED="$LINKFORSHARED";;
Martin v. Löwis25ae43b2001-10-07 08:39:18 +00002331 OpenUNIX*|UnixWare*) LINKFORSHARED="-Wl,-Bexport";;
Martin v. Löwis21ee4092002-09-30 16:19:48 +00002332 SCO_SV*) LINKFORSHARED="-Wl,-Bexport";;
Fred Drake02706f52000-09-25 15:08:46 +00002333 ReliantUNIX*) LINKFORSHARED="-W1 -Blargedynsym";;
Martin v. Löwis86d66262006-02-17 08:40:11 +00002334 FreeBSD*|NetBSD*|OpenBSD*|DragonFly*)
Guido van Rossumdf693651999-01-07 21:50:41 +00002335 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
2336 then
2337 LINKFORSHARED="-Wl,--export-dynamic"
2338 fi;;
Guido van Rossum2b5ca001998-03-05 15:41:09 +00002339 SunOS/5*) case $CC in
2340 *gcc*)
Martin v. Löwisa4548572002-04-18 14:51:36 +00002341 if $CC -Xlinker --help 2>&1 | grep export-dynamic >/dev/null
Guido van Rossum8f4ceb11997-12-18 23:42:19 +00002342 then
2343 LINKFORSHARED="-Xlinker --export-dynamic"
Guido van Rossum2b5ca001998-03-05 15:41:09 +00002344 fi;;
2345 esac;;
Jason Tishler30765592003-09-04 11:04:06 +00002346 CYGWIN*)
2347 if test $enable_shared = "no"
2348 then
2349 LINKFORSHARED='-Wl,--out-implib=$(LDLIBRARY)'
2350 fi;;
Martin v. Löwis8c255e42008-05-23 15:06:50 +00002351 QNX*)
2352 # -Wl,-E causes the symbols to be added to the dynamic
2353 # symbol table so that they can be found when a module
2354 # is loaded. -N 2048K causes the stack size to be set
2355 # to 2048 kilobytes so that the stack doesn't overflow
2356 # when running test_compile.py.
2357 LINKFORSHARED='-Wl,-E -N 2048K';;
Guido van Rossumac405f61994-09-12 10:56:06 +00002358 esac
Guido van Rossumac405f61994-09-12 10:56:06 +00002359fi
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002360AC_MSG_RESULT($LINKFORSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00002361
Ronald Oussoren0d236eb2008-06-06 21:31:33 +00002362
Neil Schemenauer61c51152001-01-26 16:18:16 +00002363AC_SUBST(CFLAGSFORSHARED)
2364AC_MSG_CHECKING(CFLAGSFORSHARED)
2365if test ! "$LIBRARY" = "$LDLIBRARY"
2366then
Neil Schemenauerd9cf41c2001-01-27 21:39:17 +00002367 case $ac_sys_system in
2368 CYGWIN*)
2369 # Cygwin needs CCSHARED when building extension DLLs
2370 # but not when building the interpreter DLL.
2371 CFLAGSFORSHARED='';;
2372 *)
2373 CFLAGSFORSHARED='$(CCSHARED)'
2374 esac
Neil Schemenauer61c51152001-01-26 16:18:16 +00002375fi
2376AC_MSG_RESULT($CFLAGSFORSHARED)
2377
Martin v. Löwisf90ae202002-06-11 06:22:31 +00002378# SHLIBS are libraries (except -lc and -lm) to link to the python shared
2379# library (with --enable-shared).
2380# For platforms on which shared libraries are not allowed to have unresolved
Martin v. Löwisd6359c52002-08-04 12:38:50 +00002381# symbols, this must be set to $(LIBS) (expanded by make). We do this even
2382# if it is not required, since it creates a dependency of the shared library
2383# to LIBS. This, in turn, means that applications linking the shared libpython
2384# don't need to link LIBS explicitly. The default should be only changed
2385# on systems where this approach causes problems.
Martin v. Löwisf90ae202002-06-11 06:22:31 +00002386AC_SUBST(SHLIBS)
2387AC_MSG_CHECKING(SHLIBS)
2388case "$ac_sys_system" in
Martin v. Löwisf90ae202002-06-11 06:22:31 +00002389 *)
Martin v. Löwisd6359c52002-08-04 12:38:50 +00002390 SHLIBS='$(LIBS)';;
Martin v. Löwisf90ae202002-06-11 06:22:31 +00002391esac
2392AC_MSG_RESULT($SHLIBS)
2393
2394
Guido van Rossum627b2d71993-12-24 10:39:16 +00002395# checks for libraries
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002396AC_CHECK_LIB(dl, dlopen) # Dynamic linking for SunOS/Solaris and SYSV
2397AC_CHECK_LIB(dld, shl_load) # Dynamic linking for HP-UX
Martin v. Löwis519adae2003-09-20 10:47:47 +00002398
Skip Montanaro4d756af2008-12-01 01:55:22 +00002399# only check for sem_init if thread support is requested
Martin v. Löwis519adae2003-09-20 10:47:47 +00002400if test "$with_threads" = "yes" -o -z "$with_threads"; then
2401 AC_SEARCH_LIBS(sem_init, pthread rt posix4) # 'Real Time' functions on Solaris
2402 # posix4 on Solaris 2.6
2403 # pthread (first!) on Linux
2404fi
2405
Martin v. Löwis19d17342003-06-14 21:03:05 +00002406# check if we need libintl for locale functions
2407AC_CHECK_LIB(intl, textdomain,
2408 AC_DEFINE(WITH_LIBINTL, 1,
2409 [Define to 1 if libintl is needed for locale functions.]))
Guido van Rossum0eefa3f1999-11-16 15:57:37 +00002410
2411# checks for system dependent C++ extensions support
2412case "$ac_sys_system" in
2413 AIX*) AC_MSG_CHECKING(for genuine AIX C++ extensions support)
Matthias Klosec511b472010-05-08 11:01:39 +00002414 AC_LINK_IFELSE([
Georg Brandl94800df2011-02-25 11:09:02 +00002415 AC_LANG_PROGRAM([[#include <load.h>]],
Matthias Klosec511b472010-05-08 11:01:39 +00002416 [[loadAndInit("", 0, "")]])
2417 ],[
2418 AC_DEFINE(AIX_GENUINE_CPLUSPLUS, 1,
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002419 [Define for AIX if your compiler is a genuine IBM xlC/xlC_r
2420 and you want support for AIX C++ shared extension modules.])
Matthias Klosec511b472010-05-08 11:01:39 +00002421 AC_MSG_RESULT(yes)
2422 ],[
2423 AC_MSG_RESULT(no)
2424 ]);;
Guido van Rossum0eefa3f1999-11-16 15:57:37 +00002425 *) ;;
2426esac
2427
Guido van Rossum70c7f481998-03-26 18:44:10 +00002428# Most SVR4 platforms (e.g. Solaris) need -lsocket and -lnsl.
Guido van Rossumec95c7b1998-08-04 17:59:56 +00002429# BeOS' sockets are stashed in libnet.
Guido van Rossumf618d2c1995-01-17 16:36:13 +00002430AC_CHECK_LIB(nsl, t_open, [LIBS="-lnsl $LIBS"]) # SVR4
Guido van Rossumf618d2c1995-01-17 16:36:13 +00002431AC_CHECK_LIB(socket, socket, [LIBS="-lsocket $LIBS"], [], $LIBS) # SVR4 sockets
Skip Montanarob9949db2004-01-17 04:04:13 +00002432
Jeremy Hyltoncb25d5e2000-07-27 21:23:28 +00002433case "$ac_sys_system" in
2434BeOS*)
Guido van Rossumec95c7b1998-08-04 17:59:56 +00002435AC_CHECK_LIB(net, socket, [LIBS="-lnet $LIBS"], [], $LIBS) # BeOS
2436;;
2437esac
Guido van Rossum70c7f481998-03-26 18:44:10 +00002438
Guido van Rossumc5a39031996-07-31 17:35:03 +00002439AC_MSG_CHECKING(for --with-libs)
Barry Warsawc0d24d82000-06-29 16:12:00 +00002440AC_ARG_WITH(libs,
Matthias Klose22520ea2010-05-08 10:14:46 +00002441 AS_HELP_STRING([--with-libs='lib1 ...'], [link against additional libs]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002442[
Guido van Rossumc5a39031996-07-31 17:35:03 +00002443AC_MSG_RESULT($withval)
2444LIBS="$withval $LIBS"
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002445],
2446[AC_MSG_RESULT(no)])
Guido van Rossum627b2d71993-12-24 10:39:16 +00002447
Benjamin Peterson64e8f6e2014-12-15 00:00:23 -05002448PKG_PROG_PKG_CONFIG
Benjamin Petersone9e07bf2010-03-09 21:46:54 +00002449
Benjamin Peterson2c196742009-12-31 03:17:18 +00002450# Check for use of the system expat library
2451AC_MSG_CHECKING(for --with-system-expat)
2452AC_ARG_WITH(system_expat,
Benjamin Petersonf2d1b2a2010-10-31 16:53:53 +00002453 AS_HELP_STRING([--with-system-expat], [build pyexpat module using an installed expat library]),
2454 [],
2455 [with_system_expat="no"])
Benjamin Peterson2c196742009-12-31 03:17:18 +00002456
2457AC_MSG_RESULT($with_system_expat)
2458
Martin v. Löwis9176fc12006-04-11 11:12:43 +00002459# Check for use of the system libffi library
2460AC_MSG_CHECKING(for --with-system-ffi)
2461AC_ARG_WITH(system_ffi,
Benjamin Petersonf2d1b2a2010-10-31 16:53:53 +00002462 AS_HELP_STRING([--with-system-ffi], [build _ctypes module using an installed ffi library]),
2463 [],
2464 [with_system_ffi="no"])
Martin v. Löwis9176fc12006-04-11 11:12:43 +00002465
Benjamin Petersone9e07bf2010-03-09 21:46:54 +00002466if test "$with_system_ffi" = "yes" && test -n "$PKG_CONFIG"; then
Benjamin Peterson1c335e62010-01-01 15:16:29 +00002467 LIBFFI_INCLUDEDIR="`"$PKG_CONFIG" libffi --cflags-only-I 2>/dev/null | sed -e 's/^-I//;s/ *$//'`"
2468else
2469 LIBFFI_INCLUDEDIR=""
2470fi
2471AC_SUBST(LIBFFI_INCLUDEDIR)
2472
Martin v. Löwis9176fc12006-04-11 11:12:43 +00002473AC_MSG_RESULT($with_system_ffi)
2474
Ned Deilya2a9f572013-10-25 00:30:10 -07002475# Check for --with-tcltk-includes=path and --with-tcltk-libs=path
2476AC_SUBST(TCLTK_INCLUDES)
2477AC_SUBST(TCLTK_LIBS)
2478AC_MSG_CHECKING(for --with-tcltk-includes)
2479AC_ARG_WITH(tcltk-includes,
2480 AS_HELP_STRING([--with-tcltk-includes='-I...'], [override search for Tcl and Tk include files]),
2481 [],
2482 [with_tcltk_includes="default"])
2483AC_MSG_RESULT($with_tcltk_includes)
2484AC_MSG_CHECKING(for --with-tcltk-libs)
2485AC_ARG_WITH(tcltk-libs,
2486 AS_HELP_STRING([--with-tcltk-libs='-L...'], [override search for Tcl and Tk libs]),
2487 [],
2488 [with_tcltk_libs="default"])
2489AC_MSG_RESULT($with_tcltk_libs)
2490if test "x$with_tcltk_includes" = xdefault || test "x$with_tcltk_libs" = xdefault
2491then
2492 if test "x$with_tcltk_includes" != "x$with_tcltk_libs"
2493 then
2494 AC_MSG_ERROR([use both --with-tcltk-includes='...' and --with-tcltk-libs='...' or neither])
2495 fi
2496 TCLTK_INCLUDES=""
2497 TCLTK_LIBS=""
2498else
2499 TCLTK_INCLUDES="$with_tcltk_includes"
2500 TCLTK_LIBS="$with_tcltk_libs"
2501fi
2502
Matthias Klose10cbe482009-04-29 17:18:19 +00002503# Check for --with-dbmliborder
2504AC_MSG_CHECKING(for --with-dbmliborder)
2505AC_ARG_WITH(dbmliborder,
Matthias Klose22520ea2010-05-08 10:14:46 +00002506 AS_HELP_STRING([--with-dbmliborder=db1:db2:...], [order to check db backends for dbm. Valid value is a colon separated string with the backend names `ndbm', `gdbm' and `bdb'.]),
Matthias Klose10cbe482009-04-29 17:18:19 +00002507[
2508if test x$with_dbmliborder = xyes
2509then
2510AC_MSG_ERROR([proper usage is --with-dbmliborder=db1:db2:...])
2511else
2512 for db in `echo $with_dbmliborder | sed 's/:/ /g'`; do
2513 if test x$db != xndbm && test x$db != xgdbm && test x$db != xbdb
2514 then
2515 AC_MSG_ERROR([proper usage is --with-dbmliborder=db1:db2:...])
2516 fi
2517 done
Matthias Klose61dbdb92009-04-29 20:09:50 +00002518fi])
2519AC_MSG_RESULT($with_dbmliborder)
Matthias Klose10cbe482009-04-29 17:18:19 +00002520
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00002521# Determine if signalmodule should be used.
2522AC_SUBST(USE_SIGNAL_MODULE)
2523AC_SUBST(SIGNAL_OBJS)
2524AC_MSG_CHECKING(for --with-signal-module)
2525AC_ARG_WITH(signal-module,
Matthias Klose22520ea2010-05-08 10:14:46 +00002526 AS_HELP_STRING([--with-signal-module], [disable/enable signal module]))
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00002527
2528if test -z "$with_signal_module"
2529then with_signal_module="yes"
2530fi
2531AC_MSG_RESULT($with_signal_module)
2532
2533if test "${with_signal_module}" = "yes"; then
2534 USE_SIGNAL_MODULE=""
2535 SIGNAL_OBJS=""
2536else
2537 USE_SIGNAL_MODULE="#"
2538 SIGNAL_OBJS="Parser/intrcheck.o Python/sigcheck.o"
2539fi
2540
Guido van Rossum3d15bd82001-01-10 18:53:48 +00002541# This is used to generate Setup.config
Guido van Rossum009f7871997-12-04 00:51:42 +00002542AC_SUBST(USE_THREAD_MODULE)
Barry Warsawc0d24d82000-06-29 16:12:00 +00002543USE_THREAD_MODULE=""
Guido van Rossum009f7871997-12-04 00:51:42 +00002544
Guido van Rossum54d93d41997-01-22 20:51:58 +00002545AC_MSG_CHECKING(for --with-dec-threads)
2546AC_SUBST(LDLAST)
2547AC_ARG_WITH(dec-threads,
Matthias Klose22520ea2010-05-08 10:14:46 +00002548 AS_HELP_STRING([--with-dec-threads], [use DEC Alpha/OSF1 thread-safe libraries]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002549[
Barry Warsawc0d24d82000-06-29 16:12:00 +00002550AC_MSG_RESULT($withval)
Guido van Rossum54d93d41997-01-22 20:51:58 +00002551LDLAST=-threads
Guido van Rossumf78abae1997-01-21 22:02:36 +00002552if test "${with_thread+set}" != set; then
Guido van Rossum54d93d41997-01-22 20:51:58 +00002553 with_thread="$withval";
2554fi],
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002555[AC_MSG_RESULT(no)])
Guido van Rossum54d93d41997-01-22 20:51:58 +00002556
Martin v. Löwis11437992002-04-12 09:54:03 +00002557# Templates for things AC_DEFINEd more than once.
2558# For a single AC_DEFINE, no template is needed.
2559AH_TEMPLATE(C_THREADS,[Define if you have the Mach cthreads package])
2560AH_TEMPLATE(_REENTRANT,
2561 [Define to force use of thread-safe errno, h_errno, and other functions])
2562AH_TEMPLATE(WITH_THREAD,
2563 [Define if you want to compile in rudimentary thread support])
2564
Guido van Rossum54d93d41997-01-22 20:51:58 +00002565AC_MSG_CHECKING(for --with-threads)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002566dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
Barry Warsawc0d24d82000-06-29 16:12:00 +00002567AC_ARG_WITH(threads,
Matthias Klose22520ea2010-05-08 10:14:46 +00002568 AS_HELP_STRING([--with(out)-threads@<:@=DIRECTORY@:>@], [disable/enable thread support]))
Guido van Rossum54d93d41997-01-22 20:51:58 +00002569
Barry Warsawc0d24d82000-06-29 16:12:00 +00002570# --with-thread is deprecated, but check for it anyway
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002571dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
Barry Warsawa0f3c5c2000-06-30 16:39:35 +00002572AC_ARG_WITH(thread,
Matthias Klose22520ea2010-05-08 10:14:46 +00002573 AS_HELP_STRING([--with(out)-thread@<:@=DIRECTORY@:>@], [deprecated; use --with(out)-threads]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002574 [with_threads=$with_thread])
Barry Warsawc0d24d82000-06-29 16:12:00 +00002575
2576if test -z "$with_threads"
2577then with_threads="yes"
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002578fi
Barry Warsawc0d24d82000-06-29 16:12:00 +00002579AC_MSG_RESULT($with_threads)
Guido van Rossum6400c261997-05-22 20:34:27 +00002580
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002581AC_SUBST(THREADOBJ)
Barry Warsawc0d24d82000-06-29 16:12:00 +00002582if test "$with_threads" = "no"
2583then
2584 USE_THREAD_MODULE="#"
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002585elif test "$ac_cv_pthread_is_default" = yes
2586then
2587 AC_DEFINE(WITH_THREAD)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002588 # Defining _REENTRANT on system with POSIX threads should not hurt.
2589 AC_DEFINE(_REENTRANT)
2590 posix_threads=yes
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002591 THREADOBJ="Python/thread.o"
Martin v. Löwis130fb172001-07-19 11:00:41 +00002592elif test "$ac_cv_kpthread" = "yes"
2593then
2594 CC="$CC -Kpthread"
Martin v. Löwis519adae2003-09-20 10:47:47 +00002595 if test "$ac_cv_cxx_thread" = "yes"; then
2596 CXX="$CXX -Kpthread"
2597 fi
Martin v. Löwis130fb172001-07-19 11:00:41 +00002598 AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002599 posix_threads=yes
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002600 THREADOBJ="Python/thread.o"
Martin v. Löwis5f433f02003-05-05 05:05:30 +00002601elif test "$ac_cv_kthread" = "yes"
2602then
2603 CC="$CC -Kthread"
Martin v. Löwis519adae2003-09-20 10:47:47 +00002604 if test "$ac_cv_cxx_thread" = "yes"; then
2605 CXX="$CXX -Kthread"
2606 fi
Martin v. Löwis5f433f02003-05-05 05:05:30 +00002607 AC_DEFINE(WITH_THREAD)
2608 posix_threads=yes
2609 THREADOBJ="Python/thread.o"
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002610elif test "$ac_cv_pthread" = "yes"
2611then
2612 CC="$CC -pthread"
Martin v. Löwis519adae2003-09-20 10:47:47 +00002613 if test "$ac_cv_cxx_thread" = "yes"; then
2614 CXX="$CXX -pthread"
2615 fi
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002616 AC_DEFINE(WITH_THREAD)
2617 posix_threads=yes
2618 THREADOBJ="Python/thread.o"
Barry Warsawc0d24d82000-06-29 16:12:00 +00002619else
Martin v. Löwis130fb172001-07-19 11:00:41 +00002620 if test ! -z "$with_threads" -a -d "$with_threads"
2621 then LDFLAGS="$LDFLAGS -L$with_threads"
2622 fi
2623 if test ! -z "$withval" -a -d "$withval"
2624 then LDFLAGS="$LDFLAGS -L$withval"
2625 fi
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002626
2627 # According to the POSIX spec, a pthreads implementation must
Matthias Klosea2542be2004-08-16 11:35:51 +00002628 # define _POSIX_THREADS in unistd.h. Some apparently don't
2629 # (e.g. gnu pth with pthread emulation)
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002630 AC_MSG_CHECKING(for _POSIX_THREADS in unistd.h)
2631 AC_EGREP_CPP(yes,
Neal Norwitz6eb37f02003-02-23 23:28:15 +00002632 [
2633#include <unistd.h>
2634#ifdef _POSIX_THREADS
2635yes
2636#endif
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002637 ], unistd_defines_pthreads=yes, unistd_defines_pthreads=no)
2638 AC_MSG_RESULT($unistd_defines_pthreads)
2639
Martin v. Löwis130fb172001-07-19 11:00:41 +00002640 AC_DEFINE(_REENTRANT)
Martin v. Löwisa6e97582002-01-01 18:41:33 +00002641 AC_CHECK_HEADER(cthreads.h, [AC_DEFINE(WITH_THREAD)
2642 AC_DEFINE(C_THREADS)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002643 AC_DEFINE(HURD_C_THREADS, 1,
2644 [Define if you are using Mach cthreads directly under /include])
Martin v. Löwisa6e97582002-01-01 18:41:33 +00002645 LIBS="$LIBS -lthreads"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002646 THREADOBJ="Python/thread.o"],[
Martin v. Löwis130fb172001-07-19 11:00:41 +00002647 AC_CHECK_HEADER(mach/cthreads.h, [AC_DEFINE(WITH_THREAD)
2648 AC_DEFINE(C_THREADS)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002649 AC_DEFINE(MACH_C_THREADS, 1,
2650 [Define if you are using Mach cthreads under mach /])
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002651 THREADOBJ="Python/thread.o"],[
Martin v. Löwis130fb172001-07-19 11:00:41 +00002652 AC_MSG_CHECKING(for --with-pth)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002653 AC_ARG_WITH([pth],
Matthias Klose22520ea2010-05-08 10:14:46 +00002654 AS_HELP_STRING([--with-pth], [use GNU pth threading libraries]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002655 [AC_MSG_RESULT($withval)
2656 AC_DEFINE([WITH_THREAD])
2657 AC_DEFINE([HAVE_PTH], 1,
2658 [Define if you have GNU PTH threads.])
2659 LIBS="-lpth $LIBS"
2660 THREADOBJ="Python/thread.o"],
2661 [AC_MSG_RESULT(no)
Martin v. Löwis8158b5a2001-10-08 13:17:28 +00002662
2663 # Just looking for pthread_create in libpthread is not enough:
2664 # on HP/UX, pthread.h renames pthread_create to a different symbol name.
2665 # So we really have to include pthread.h, and then link.
2666 _libs=$LIBS
2667 LIBS="$LIBS -lpthread"
2668 AC_MSG_CHECKING([for pthread_create in -lpthread])
Stefan Krahae66ca62012-11-22 22:36:57 +01002669 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
2670#include <stdio.h>
2671#include <pthread.h>
Martin v. Löwis8158b5a2001-10-08 13:17:28 +00002672
Matthias Klosec511b472010-05-08 11:01:39 +00002673void * start_routine (void *arg) { exit (0); }]], [[
2674pthread_create (NULL, NULL, start_routine, NULL)]])],[
Martin v. Löwis8158b5a2001-10-08 13:17:28 +00002675 AC_MSG_RESULT(yes)
2676 AC_DEFINE(WITH_THREAD)
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002677 posix_threads=yes
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002678 THREADOBJ="Python/thread.o"],[
Martin v. Löwis8158b5a2001-10-08 13:17:28 +00002679 LIBS=$_libs
Martin v. Löwis130fb172001-07-19 11:00:41 +00002680 AC_CHECK_FUNC(pthread_detach, [AC_DEFINE(WITH_THREAD)
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002681 posix_threads=yes
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002682 THREADOBJ="Python/thread.o"],[
Martin v. Löwisf90ae202002-06-11 06:22:31 +00002683 AC_CHECK_HEADER(atheos/threads.h, [AC_DEFINE(WITH_THREAD)
2684 AC_DEFINE(ATHEOS_THREADS, 1,
2685 [Define this if you have AtheOS threads.])
2686 THREADOBJ="Python/thread.o"],[
Martin v. Löwis130fb172001-07-19 11:00:41 +00002687 AC_CHECK_HEADER(kernel/OS.h, [AC_DEFINE(WITH_THREAD)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002688 AC_DEFINE(BEOS_THREADS, 1,
2689 [Define this if you have BeOS threads.])
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002690 THREADOBJ="Python/thread.o"],[
Martin v. Löwis130fb172001-07-19 11:00:41 +00002691 AC_CHECK_LIB(pthreads, pthread_create, [AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002692 posix_threads=yes
Martin v. Löwis130fb172001-07-19 11:00:41 +00002693 LIBS="$LIBS -lpthreads"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002694 THREADOBJ="Python/thread.o"], [
Martin v. Löwis130fb172001-07-19 11:00:41 +00002695 AC_CHECK_LIB(c_r, pthread_create, [AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002696 posix_threads=yes
Martin v. Löwis130fb172001-07-19 11:00:41 +00002697 LIBS="$LIBS -lc_r"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002698 THREADOBJ="Python/thread.o"], [
Martin v. Löwis130fb172001-07-19 11:00:41 +00002699 AC_CHECK_LIB(pthread, __pthread_create_system, [AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002700 posix_threads=yes
Martin v. Löwis130fb172001-07-19 11:00:41 +00002701 LIBS="$LIBS -lpthread"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002702 THREADOBJ="Python/thread.o"], [
Martin v. Löwis130fb172001-07-19 11:00:41 +00002703 AC_CHECK_LIB(cma, pthread_create, [AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002704 posix_threads=yes
Martin v. Löwis130fb172001-07-19 11:00:41 +00002705 LIBS="$LIBS -lcma"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002706 THREADOBJ="Python/thread.o"],[
Martin v. Löwis130fb172001-07-19 11:00:41 +00002707 USE_THREAD_MODULE="#"])
Skip Montanarof8712e52004-01-17 03:04:46 +00002708 ])])])])])])])])])])
Barry Warsawc0d24d82000-06-29 16:12:00 +00002709
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002710 AC_CHECK_LIB(mpc, usconfig, [AC_DEFINE(WITH_THREAD)
2711 LIBS="$LIBS -lmpc"
2712 THREADOBJ="Python/thread.o"
2713 USE_THREAD_MODULE=""])
2714
2715 if test "$posix_threads" != "yes"; then
2716 AC_CHECK_LIB(thread, thr_create, [AC_DEFINE(WITH_THREAD)
2717 LIBS="$LIBS -lthread"
2718 THREADOBJ="Python/thread.o"
2719 USE_THREAD_MODULE=""])
2720 fi
2721
2722 if test "$USE_THREAD_MODULE" != "#"
2723 then
2724 # If the above checks didn't disable threads, (at least) OSF1
2725 # needs this '-threads' argument during linking.
2726 case $ac_sys_system in
2727 OSF1) LDLAST=-threads;;
2728 esac
2729 fi
2730fi
2731
2732if test "$posix_threads" = "yes"; then
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002733 if test "$unistd_defines_pthreads" = "no"; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002734 AC_DEFINE(_POSIX_THREADS, 1,
2735 [Define if you have POSIX threads,
2736 and your system does not define that.])
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002737 fi
2738
Martin v. Löwisdfc33fd2003-01-21 10:14:41 +00002739 # Bug 662787: Using semaphores causes unexplicable hangs on Solaris 8.
2740 case $ac_sys_system/$ac_sys_release in
Charles-François Natali4929eb92011-07-21 19:41:04 +02002741 SunOS/5.6) AC_DEFINE(HAVE_PTHREAD_DESTRUCTOR, 1,
Matthias Klose5183ebd2010-04-24 16:38:36 +00002742 [Defined for Solaris 2.6 bug in pthread header.])
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002743 ;;
Martin v. Löwisdfc33fd2003-01-21 10:14:41 +00002744 SunOS/5.8) AC_DEFINE(HAVE_BROKEN_POSIX_SEMAPHORES, 1,
Matthias Klose5183ebd2010-04-24 16:38:36 +00002745 [Define if the Posix semaphores do not work on your system])
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002746 ;;
Charles-François Natali4929eb92011-07-21 19:41:04 +02002747 AIX/*) AC_DEFINE(HAVE_BROKEN_POSIX_SEMAPHORES, 1,
Matthias Klose5183ebd2010-04-24 16:38:36 +00002748 [Define if the Posix semaphores do not work on your system])
Christian Heimescba36bb2008-01-30 22:54:18 +00002749 ;;
Martin v. Löwisdfc33fd2003-01-21 10:14:41 +00002750 esac
2751
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002752 AC_MSG_CHECKING(if PTHREAD_SCOPE_SYSTEM is supported)
2753 AC_CACHE_VAL(ac_cv_pthread_system_supported,
Stefan Krahae66ca62012-11-22 22:36:57 +01002754 [AC_RUN_IFELSE([AC_LANG_SOURCE([[
2755 #include <stdio.h>
2756 #include <pthread.h>
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002757 void *foo(void *parm) {
2758 return NULL;
2759 }
2760 main() {
2761 pthread_attr_t attr;
Martin v. Löwisa82d3472002-02-24 16:05:05 +00002762 pthread_t id;
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002763 if (pthread_attr_init(&attr)) exit(-1);
2764 if (pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM)) exit(-1);
Martin v. Löwisa82d3472002-02-24 16:05:05 +00002765 if (pthread_create(&id, &attr, foo, NULL)) exit(-1);
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002766 exit(0);
Matthias Klosec511b472010-05-08 11:01:39 +00002767 }]])],
2768 [ac_cv_pthread_system_supported=yes],
2769 [ac_cv_pthread_system_supported=no],
2770 [ac_cv_pthread_system_supported=no])
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002771 ])
2772 AC_MSG_RESULT($ac_cv_pthread_system_supported)
2773 if test "$ac_cv_pthread_system_supported" = "yes"; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002774 AC_DEFINE(PTHREAD_SYSTEM_SCHED_SUPPORTED, 1, [Defined if PTHREAD_SCOPE_SYSTEM supported.])
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002775 fi
Jason Tishlerfac083d2003-07-22 15:20:49 +00002776 AC_CHECK_FUNCS(pthread_sigmask,
2777 [case $ac_sys_system in
2778 CYGWIN*)
2779 AC_DEFINE(HAVE_BROKEN_PTHREAD_SIGMASK, 1,
2780 [Define if pthread_sigmask() does not work on your system.])
2781 ;;
2782 esac])
Christian Heimes0d604cf2013-08-21 13:26:05 +02002783 AC_CHECK_FUNCS(pthread_atfork)
Barry Warsawc0d24d82000-06-29 16:12:00 +00002784fi
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002785
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002786
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002787# Check for enable-ipv6
Martin v. Löwis11437992002-04-12 09:54:03 +00002788AH_TEMPLATE(ENABLE_IPV6, [Define if --enable-ipv6 is specified])
Martin v. Löwisa5f8bb52001-09-05 08:22:34 +00002789AC_MSG_CHECKING([if --enable-ipv6 is specified])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002790AC_ARG_ENABLE(ipv6,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002791[ --enable-ipv6 Enable ipv6 (with ipv4) support
2792 --disable-ipv6 Disable ipv6 support],
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002793[ case "$enableval" in
2794 no)
2795 AC_MSG_RESULT(no)
2796 ipv6=no
2797 ;;
2798 *) AC_MSG_RESULT(yes)
2799 AC_DEFINE(ENABLE_IPV6)
2800 ipv6=yes
2801 ;;
2802 esac ],
2803
Martin v. Löwisa5f8bb52001-09-05 08:22:34 +00002804[
2805dnl the check does not work on cross compilation case...
Charles-François Natalibe2b9072013-01-08 19:47:00 +01002806 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ /* AF_INET6 available check */
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002807#include <sys/types.h>
Charles-François Natalibe2b9072013-01-08 19:47:00 +01002808#include <sys/socket.h>]],
2809[[int domain = AF_INET6;]])],[
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002810 AC_MSG_RESULT(yes)
Matthias Klosec511b472010-05-08 11:01:39 +00002811 ipv6=yes
2812],[
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002813 AC_MSG_RESULT(no)
2814 ipv6=no
Matthias Klosec511b472010-05-08 11:01:39 +00002815])
Martin v. Löwisa5f8bb52001-09-05 08:22:34 +00002816
2817if test "$ipv6" = "yes"; then
2818 AC_MSG_CHECKING(if RFC2553 API is available)
Matthias Klosec511b472010-05-08 11:01:39 +00002819 AC_COMPILE_IFELSE([
2820 AC_LANG_PROGRAM([[#include <sys/types.h>
2821#include <netinet/in.h>]],
2822 [[struct sockaddr_in6 x;
2823 x.sin6_scope_id;]])
2824 ],[
2825 AC_MSG_RESULT(yes)
2826 ipv6=yes
2827 ],[
2828 AC_MSG_RESULT(no, IPv6 disabled)
2829 ipv6=no
2830 ])
Martin v. Löwisa5f8bb52001-09-05 08:22:34 +00002831fi
2832
2833if test "$ipv6" = "yes"; then
2834 AC_DEFINE(ENABLE_IPV6)
2835fi
2836])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002837
2838ipv6type=unknown
2839ipv6lib=none
2840ipv6trylibc=no
2841
2842if test "$ipv6" = "yes"; then
2843 AC_MSG_CHECKING([ipv6 stack type])
Guido van Rossumb8552162001-09-05 14:58:11 +00002844 for i in inria kame linux-glibc linux-inet6 solaris toshiba v6d zeta;
2845 do
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002846 case $i in
2847 inria)
2848 dnl http://www.kame.net/
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002849 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002850#include <netinet/in.h>
2851#ifdef IPV6_INRIA_VERSION
2852yes
2853#endif],
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002854 [ipv6type=$i])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002855 ;;
2856 kame)
2857 dnl http://www.kame.net/
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002858 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002859#include <netinet/in.h>
2860#ifdef __KAME__
2861yes
2862#endif],
2863 [ipv6type=$i;
2864 ipv6lib=inet6
2865 ipv6libdir=/usr/local/v6/lib
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002866 ipv6trylibc=yes])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002867 ;;
2868 linux-glibc)
2869 dnl http://www.v6.linux.or.jp/
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002870 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002871#include <features.h>
2872#if defined(__GLIBC__) && ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1) || (__GLIBC__ > 2))
2873yes
2874#endif],
2875 [ipv6type=$i;
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002876 ipv6trylibc=yes])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002877 ;;
2878 linux-inet6)
2879 dnl http://www.v6.linux.or.jp/
2880 if test -d /usr/inet6; then
2881 ipv6type=$i
2882 ipv6lib=inet6
2883 ipv6libdir=/usr/inet6/lib
Skip Montanarodecc6a42003-01-01 20:07:49 +00002884 BASECFLAGS="-I/usr/inet6/include $BASECFLAGS"
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002885 fi
2886 ;;
2887 solaris)
2888 if test -f /etc/netconfig; then
Antoine Pitrou31e85952011-01-03 18:57:14 +00002889 if $GREP -q tcp6 /etc/netconfig; then
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002890 ipv6type=$i
2891 ipv6trylibc=yes
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002892 fi
2893 fi
2894 ;;
2895 toshiba)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002896 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002897#include <sys/param.h>
2898#ifdef _TOSHIBA_INET6
2899yes
2900#endif],
2901 [ipv6type=$i;
2902 ipv6lib=inet6;
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002903 ipv6libdir=/usr/local/v6/lib])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002904 ;;
2905 v6d)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002906 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002907#include </usr/local/v6/include/sys/v6config.h>
2908#ifdef __V6D__
2909yes
2910#endif],
2911 [ipv6type=$i;
2912 ipv6lib=v6;
2913 ipv6libdir=/usr/local/v6/lib;
Skip Montanarodecc6a42003-01-01 20:07:49 +00002914 BASECFLAGS="-I/usr/local/v6/include $BASECFLAGS"])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002915 ;;
2916 zeta)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002917 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002918#include <sys/param.h>
2919#ifdef _ZETA_MINAMI_INET6
2920yes
2921#endif],
2922 [ipv6type=$i;
2923 ipv6lib=inet6;
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002924 ipv6libdir=/usr/local/v6/lib])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002925 ;;
2926 esac
2927 if test "$ipv6type" != "unknown"; then
2928 break
2929 fi
2930 done
2931 AC_MSG_RESULT($ipv6type)
2932fi
2933
2934if test "$ipv6" = "yes" -a "$ipv6lib" != "none"; then
2935 if test -d $ipv6libdir -a -f $ipv6libdir/lib$ipv6lib.a; then
2936 LIBS="-L$ipv6libdir -l$ipv6lib $LIBS"
2937 echo "using lib$ipv6lib"
2938 else
2939 if test $ipv6trylibc = "yes"; then
2940 echo "using libc"
2941 else
2942 echo 'Fatal: no $ipv6lib library found. cannot continue.'
2943 echo "You need to fetch lib$ipv6lib.a from appropriate"
2944 echo 'ipv6 kit and compile beforehand.'
2945 exit 1
2946 fi
2947 fi
2948fi
2949
Ronald Oussoren0d236eb2008-06-06 21:31:33 +00002950AC_MSG_CHECKING(for OSX 10.5 SDK or later)
Matthias Klosec511b472010-05-08 11:01:39 +00002951AC_COMPILE_IFELSE([
Mark Dickinson0712b562010-05-08 19:13:21 +00002952 AC_LANG_PROGRAM([[#include <Carbon/Carbon.h>]], [[FSIORefNum fRef = 0]])
Matthias Klosec511b472010-05-08 11:01:39 +00002953],[
Matthias Klose5183ebd2010-04-24 16:38:36 +00002954 AC_DEFINE(HAVE_OSX105_SDK, 1, [Define if compiling using MacOS X 10.5 SDK or later.])
Matthias Klosec511b472010-05-08 11:01:39 +00002955 AC_MSG_RESULT(yes)
2956],[
Ronald Oussoren0d236eb2008-06-06 21:31:33 +00002957 AC_MSG_RESULT(no)
Matthias Klosec511b472010-05-08 11:01:39 +00002958])
Ronald Oussoren0d236eb2008-06-06 21:31:33 +00002959
Martin v. Löwisa3fb4f72002-06-09 13:33:54 +00002960# Check for --with-doc-strings
2961AC_MSG_CHECKING(for --with-doc-strings)
2962AC_ARG_WITH(doc-strings,
Matthias Klose22520ea2010-05-08 10:14:46 +00002963 AS_HELP_STRING([--with(out)-doc-strings], [disable/enable documentation strings]))
Martin v. Löwisa3fb4f72002-06-09 13:33:54 +00002964
2965if test -z "$with_doc_strings"
2966then with_doc_strings="yes"
2967fi
2968if test "$with_doc_strings" != "no"
2969then
2970 AC_DEFINE(WITH_DOC_STRINGS, 1,
2971 [Define if you want documentation strings in extension modules])
2972fi
2973AC_MSG_RESULT($with_doc_strings)
2974
Neil Schemenauera35c6882001-02-27 04:45:05 +00002975# Check for Python-specific malloc support
Martin v. Löwisf30d60e2004-06-08 08:17:44 +00002976AC_MSG_CHECKING(for --with-tsc)
2977AC_ARG_WITH(tsc,
Matthias Klose22520ea2010-05-08 10:14:46 +00002978 AS_HELP_STRING([--with(out)-tsc],[enable/disable timestamp counter profile]),[
Martin v. Löwisf30d60e2004-06-08 08:17:44 +00002979if test "$withval" != no
2980then
2981 AC_DEFINE(WITH_TSC, 1,
2982 [Define to profile with the Pentium timestamp counter])
2983 AC_MSG_RESULT(yes)
2984else AC_MSG_RESULT(no)
2985fi],
2986[AC_MSG_RESULT(no)])
2987
2988# Check for Python-specific malloc support
Neil Schemenauera35c6882001-02-27 04:45:05 +00002989AC_MSG_CHECKING(for --with-pymalloc)
2990AC_ARG_WITH(pymalloc,
Matthias Klose22520ea2010-05-08 10:14:46 +00002991 AS_HELP_STRING([--with(out)-pymalloc], [disable/enable specialized mallocs]))
Neil Schemenauer16c22972002-03-22 15:34:49 +00002992
2993if test -z "$with_pymalloc"
2994then with_pymalloc="yes"
2995fi
2996if test "$with_pymalloc" != "no"
2997then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002998 AC_DEFINE(WITH_PYMALLOC, 1,
2999 [Define if you want to compile in Python-specific mallocs])
Neil Schemenauer16c22972002-03-22 15:34:49 +00003000fi
3001AC_MSG_RESULT($with_pymalloc)
Neil Schemenauera35c6882001-02-27 04:45:05 +00003002
Benjamin Peterson91c12eb2009-12-03 02:52:39 +00003003# Check for Valgrind support
3004AC_MSG_CHECKING([for --with-valgrind])
3005AC_ARG_WITH([valgrind],
Matthias Klose22520ea2010-05-08 10:14:46 +00003006 AS_HELP_STRING([--with-valgrind], [Enable Valgrind support]),,
Benjamin Peterson91c12eb2009-12-03 02:52:39 +00003007 with_valgrind=no)
3008AC_MSG_RESULT([$with_valgrind])
3009if test "$with_valgrind" != no; then
3010 AC_CHECK_HEADER([valgrind/valgrind.h],
3011 [AC_DEFINE([WITH_VALGRIND], 1, [Define if you want pymalloc to be disabled when running under valgrind])],
3012 [AC_MSG_ERROR([Valgrind support requested but headers not available])]
3013 )
3014fi
3015
Barry Warsawef82cd72000-06-30 16:21:01 +00003016# Check for --with-wctype-functions
3017AC_MSG_CHECKING(for --with-wctype-functions)
3018AC_ARG_WITH(wctype-functions,
Matthias Klose22520ea2010-05-08 10:14:46 +00003019 AS_HELP_STRING([--with-wctype-functions], [use wctype.h functions]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003020[
Barry Warsawef82cd72000-06-30 16:21:01 +00003021if test "$withval" != no
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003022then
3023 AC_DEFINE(WANT_WCTYPE_FUNCTIONS, 1,
3024 [Define if you want wctype.h functions to be used instead of the
3025 one supplied by Python itself. (see Include/unicodectype.h).])
3026 AC_MSG_RESULT(yes)
Barry Warsawef82cd72000-06-30 16:21:01 +00003027else AC_MSG_RESULT(no)
3028fi],
3029[AC_MSG_RESULT(no)])
3030
Guido van Rossum68242b51996-05-28 22:53:03 +00003031# -I${DLINCLDIR} is added to the compile rule for importdl.o
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003032AC_SUBST(DLINCLDIR)
Guido van Rossum98935bf2001-09-05 19:13:16 +00003033DLINCLDIR=.
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003034
Guido van Rossume97ee181999-12-20 21:27:22 +00003035# the dlopen() function means we might want to use dynload_shlib.o. some
3036# platforms, such as AIX, have dlopen(), but don't want to use it.
Thomas Wouters3a584202000-08-05 23:28:51 +00003037AC_CHECK_FUNCS(dlopen)
Guido van Rossume97ee181999-12-20 21:27:22 +00003038
3039# DYNLOADFILE specifies which dynload_*.o file we will use for dynamic
3040# loading of modules.
3041AC_SUBST(DYNLOADFILE)
3042AC_MSG_CHECKING(DYNLOADFILE)
3043if test -z "$DYNLOADFILE"
3044then
3045 case $ac_sys_system/$ac_sys_release in
Martin v. Löwisc19c5a62003-11-18 20:00:44 +00003046 AIX*) # Use dynload_shlib.c and dlopen() if we have it; otherwise dynload_aix.c
3047 if test "$ac_cv_func_dlopen" = yes
3048 then DYNLOADFILE="dynload_shlib.o"
3049 else DYNLOADFILE="dynload_aix.o"
3050 fi
3051 ;;
Guido van Rossume97ee181999-12-20 21:27:22 +00003052 BeOS*) DYNLOADFILE="dynload_beos.o";;
3053 hp*|HP*) DYNLOADFILE="dynload_hpux.o";;
Anthony Baxter82201742006-04-09 15:07:40 +00003054 # Use dynload_next.c only on 10.2 and below, which don't have native dlopen()
3055 Darwin/@<:@0156@:>@\..*) DYNLOADFILE="dynload_next.o";;
Martin v. Löwisf90ae202002-06-11 06:22:31 +00003056 atheos*) DYNLOADFILE="dynload_atheos.o";;
Guido van Rossume97ee181999-12-20 21:27:22 +00003057 *)
3058 # use dynload_shlib.c and dlopen() if we have it; otherwise stub
3059 # out any dynamic loading
3060 if test "$ac_cv_func_dlopen" = yes
3061 then DYNLOADFILE="dynload_shlib.o"
3062 else DYNLOADFILE="dynload_stub.o"
3063 fi
3064 ;;
3065 esac
3066fi
3067AC_MSG_RESULT($DYNLOADFILE)
3068if test "$DYNLOADFILE" != "dynload_stub.o"
3069then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003070 AC_DEFINE(HAVE_DYNAMIC_LOADING, 1,
3071 [Defined when any dynamic module loading is enabled.])
Guido van Rossume97ee181999-12-20 21:27:22 +00003072fi
3073
Jack Jansenc49e5b72001-06-19 15:00:23 +00003074# MACHDEP_OBJS can be set to platform-specific object files needed by Python
3075
3076AC_SUBST(MACHDEP_OBJS)
3077AC_MSG_CHECKING(MACHDEP_OBJS)
3078if test -z "$MACHDEP_OBJS"
3079then
Jack Jansenb6e9cad2001-08-15 01:26:28 +00003080 MACHDEP_OBJS=$extra_machdep_objs
3081else
3082 MACHDEP_OBJS="$MACHDEP_OBJS $extra_machdep_objs"
Jack Jansenc49e5b72001-06-19 15:00:23 +00003083fi
Jack Jansenb6e9cad2001-08-15 01:26:28 +00003084AC_MSG_RESULT(MACHDEP_OBJS)
Jack Jansenc49e5b72001-06-19 15:00:23 +00003085
Guido van Rossum627b2d71993-12-24 10:39:16 +00003086# checks for library functions
Martin v. Löwisaef18b12008-03-24 13:31:16 +00003087AC_CHECK_FUNCS(alarm setitimer getitimer bind_textdomain_codeset chown \
3088 clock confstr ctermid execv fchmod fchown fork fpathconf ftime ftruncate \
Martin v. Löwis438b5342002-12-27 10:16:42 +00003089 gai_strerror getgroups getlogin getloadavg getpeername getpgid getpid \
Benjamin Peterson27c269a2014-12-26 11:09:00 -06003090 getentropy \
Martin v. Löwis50ea4562009-11-27 13:56:01 +00003091 getpriority getresuid getresgid getpwent getspnam getspent getsid getwd \
Benjamin Petersond16e01c2014-02-04 10:20:26 -05003092 initgroups kill killpg lchmod lchown lstat mkfifo mknod mktime mmap \
Martin v. Löwisa5f09072002-10-11 05:37:59 +00003093 mremap nice pathconf pause plock poll pthread_init \
Guido van Rossum162e38c2003-02-19 15:25:10 +00003094 putenv readlink realpath \
Jesse Noller355b1262009-04-02 00:03:28 +00003095 select sem_open sem_timedwait sem_getvalue sem_unlink setegid seteuid \
3096 setgid \
Martin v. Löwis4daacb12003-03-28 18:37:01 +00003097 setlocale setregid setreuid setsid setpgid setpgrp setuid setvbuf snprintf \
Martin v. Löwis50ea4562009-11-27 13:56:01 +00003098 setlocale setregid setreuid setresuid setresgid \
3099 setsid setpgid setpgrp setuid setvbuf snprintf \
Skip Montanaro7e11a012004-02-07 12:55:46 +00003100 sigaction siginterrupt sigrelse strftime \
Michael W. Hudson34f20ea2002-05-27 15:08:24 +00003101 sysconf tcgetpgrp tcsetpgrp tempnam timegm times tmpfile tmpnam tmpnam_r \
Neal Norwitz05a45592006-03-20 06:30:08 +00003102 truncate uname unsetenv utimes waitpid wait3 wait4 wcscoll _getpty)
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00003103
Martin v. Löwisc8ad7cc2002-11-11 13:23:45 +00003104# For some functions, having a definition is not sufficient, since
3105# we want to take their address.
3106AC_MSG_CHECKING(for chroot)
Matthias Klosec511b472010-05-08 11:01:39 +00003107AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[void *x=chroot]])],
3108 [AC_DEFINE(HAVE_CHROOT, 1, Define if you have the 'chroot' function.)
3109 AC_MSG_RESULT(yes)],
3110 [AC_MSG_RESULT(no)
3111])
Martin v. Löwisc8ad7cc2002-11-11 13:23:45 +00003112AC_MSG_CHECKING(for link)
Matthias Klosec511b472010-05-08 11:01:39 +00003113AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[void *x=link]])],
3114 [AC_DEFINE(HAVE_LINK, 1, Define if you have the 'link' function.)
3115 AC_MSG_RESULT(yes)],
3116 [AC_MSG_RESULT(no)
3117])
Martin v. Löwisc8ad7cc2002-11-11 13:23:45 +00003118AC_MSG_CHECKING(for symlink)
Matthias Klosec511b472010-05-08 11:01:39 +00003119AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[void *x=symlink]])],
3120 [AC_DEFINE(HAVE_SYMLINK, 1, Define if you have the 'symlink' function.)
3121 AC_MSG_RESULT(yes)],
3122 [AC_MSG_RESULT(no)
3123])
Martin v. Löwisa64988c2003-09-20 15:30:20 +00003124AC_MSG_CHECKING(for fchdir)
Matthias Klosec511b472010-05-08 11:01:39 +00003125AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[void *x=fchdir]])],
3126 [AC_DEFINE(HAVE_FCHDIR, 1, Define if you have the 'fchdir' function.)
3127 AC_MSG_RESULT(yes)],
3128 [AC_MSG_RESULT(no)
3129])
Martin v. Löwisa64988c2003-09-20 15:30:20 +00003130AC_MSG_CHECKING(for fsync)
Matthias Klosec511b472010-05-08 11:01:39 +00003131AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[void *x=fsync]])],
3132 [AC_DEFINE(HAVE_FSYNC, 1, Define if you have the 'fsync' function.)
3133 AC_MSG_RESULT(yes)],
3134 [AC_MSG_RESULT(no)
3135])
Martin v. Löwisa64988c2003-09-20 15:30:20 +00003136AC_MSG_CHECKING(for fdatasync)
Matthias Klosec511b472010-05-08 11:01:39 +00003137AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[void *x=fdatasync]])],
3138 [AC_DEFINE(HAVE_FDATASYNC, 1, Define if you have the 'fdatasync' function.)
3139 AC_MSG_RESULT(yes)],
3140 [AC_MSG_RESULT(no)
3141])
Christian Heimes0e9ab5f2008-03-21 23:49:44 +00003142AC_MSG_CHECKING(for epoll)
Matthias Klosec511b472010-05-08 11:01:39 +00003143AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/epoll.h>]], [[void *x=epoll_create]])],
3144 [AC_DEFINE(HAVE_EPOLL, 1, Define if you have the 'epoll' functions.)
3145 AC_MSG_RESULT(yes)],
3146 [AC_MSG_RESULT(no)
3147])
Christian Heimes0e9ab5f2008-03-21 23:49:44 +00003148AC_MSG_CHECKING(for kqueue)
Matthias Klosec511b472010-05-08 11:01:39 +00003149AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Christian Heimes0e9ab5f2008-03-21 23:49:44 +00003150#include <sys/types.h>
3151#include <sys/event.h>
Matthias Klosec511b472010-05-08 11:01:39 +00003152 ]], [[int x=kqueue()]])],
3153 [AC_DEFINE(HAVE_KQUEUE, 1, Define if you have the 'kqueue' functions.)
3154 AC_MSG_RESULT(yes)],
3155 [AC_MSG_RESULT(no)
3156])
Martin v. Löwisd5843682002-11-21 20:41:28 +00003157# On some systems (eg. FreeBSD 5), we would find a definition of the
3158# functions ctermid_r, setgroups in the library, but no prototype
3159# (e.g. because we use _XOPEN_SOURCE). See whether we can take their
3160# address to avoid compiler warnings and potential miscompilations
3161# because of the missing prototypes.
3162
3163AC_MSG_CHECKING(for ctermid_r)
Matthias Klosec511b472010-05-08 11:01:39 +00003164AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwisd5843682002-11-21 20:41:28 +00003165#include <stdio.h>
Matthias Klosec511b472010-05-08 11:01:39 +00003166]], [[void* p = ctermid_r]])],
3167 [AC_DEFINE(HAVE_CTERMID_R, 1, Define if you have the 'ctermid_r' function.)
3168 AC_MSG_RESULT(yes)],
3169 [AC_MSG_RESULT(no)
3170])
Martin v. Löwisd5843682002-11-21 20:41:28 +00003171
Antoine Pitroub170f172010-09-10 18:47:36 +00003172AC_CACHE_CHECK([for flock declaration], [ac_cv_flock_decl],
3173 [AC_COMPILE_IFELSE(
3174 [AC_LANG_PROGRAM(
3175 [#include <sys/file.h>],
3176 [void* p = flock]
3177 )],
3178 [ac_cv_flock_decl=yes],
3179 [ac_cv_flock_decl=no]
3180 )
Matthias Klosec511b472010-05-08 11:01:39 +00003181])
Antoine Pitroub170f172010-09-10 18:47:36 +00003182if test "x${ac_cv_flock_decl}" = xyes; then
3183 AC_CHECK_FUNCS(flock,,
3184 AC_CHECK_LIB(bsd,flock,
3185 [AC_DEFINE(HAVE_FLOCK)
3186 AC_DEFINE(FLOCK_NEEDS_LIBBSD, 1, Define if flock needs to be linked with bsd library.)
3187 ])
3188 )
Antoine Pitrou85729812010-09-07 14:55:24 +00003189fi
Martin v. Löwisf26d63b2003-03-30 17:23:49 +00003190
3191AC_MSG_CHECKING(for getpagesize)
Matthias Klosec511b472010-05-08 11:01:39 +00003192AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwisf26d63b2003-03-30 17:23:49 +00003193#include <unistd.h>
Matthias Klosec511b472010-05-08 11:01:39 +00003194]], [[void* p = getpagesize]])],
3195 [AC_DEFINE(HAVE_GETPAGESIZE, 1, Define if you have the 'getpagesize' function.)
3196 AC_MSG_RESULT(yes)],
3197 [AC_MSG_RESULT(no)
3198])
Martin v. Löwisf26d63b2003-03-30 17:23:49 +00003199
Charles-François Natali93a11752011-11-27 13:01:35 +01003200AC_MSG_CHECKING(for broken unsetenv)
3201AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3202#include <stdlib.h>
3203]], [[int res = unsetenv("DUMMY")]])],
3204 [AC_MSG_RESULT(no)],
3205 [AC_DEFINE(HAVE_BROKEN_UNSETENV, 1, Define if `unsetenv` does not return an int.)
3206 AC_MSG_RESULT(yes)
3207])
3208
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00003209dnl check for true
3210AC_CHECK_PROGS(TRUE, true, /bin/true)
3211
Martin v. Löwis95c419b2003-05-03 12:10:48 +00003212dnl On some systems (e.g. Solaris 9), hstrerror and inet_aton are in -lresolv
3213dnl On others, they are in the C library, so we to take no action
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00003214AC_CHECK_LIB(c, inet_aton, [$ac_cv_prog_TRUE],
Martin v. Löwis95c419b2003-05-03 12:10:48 +00003215 AC_CHECK_LIB(resolv, inet_aton)
3216)
3217
Martin v. Löwisa51d5c82007-12-04 08:37:59 +00003218# On Tru64, chflags seems to be present, but calling it will
3219# exit Python
Gregory P. Smithbb213892009-11-02 01:37:37 +00003220AC_CACHE_CHECK([for chflags], [ac_cv_have_chflags], [dnl
Ned Deily43e10542011-06-27 23:41:53 -07003221AC_RUN_IFELSE([AC_LANG_SOURCE([[
Martin v. Löwisa51d5c82007-12-04 08:37:59 +00003222#include <sys/stat.h>
3223#include <unistd.h>
3224int main(int argc, char*argv[])
3225{
3226 if(chflags(argv[0], 0) != 0)
3227 return 1;
3228 return 0;
3229}
Ned Deily43e10542011-06-27 23:41:53 -07003230]])],
Matthias Klosec511b472010-05-08 11:01:39 +00003231[ac_cv_have_chflags=yes],
3232[ac_cv_have_chflags=no],
3233[ac_cv_have_chflags=cross])
Gregory P. Smithbb213892009-11-02 01:37:37 +00003234])
3235if test "$ac_cv_have_chflags" = cross ; then
3236 AC_CHECK_FUNC([chflags], [ac_cv_have_chflags="yes"], [ac_cv_have_chflags="no"])
3237fi
3238if test "$ac_cv_have_chflags" = yes ; then
Ned Deily43e10542011-06-27 23:41:53 -07003239 AC_DEFINE(HAVE_CHFLAGS, 1, [Define to 1 if you have the 'chflags' function.])
Alexandre Vassalotti00900892009-07-17 05:26:39 +00003240fi
Martin v. Löwisa51d5c82007-12-04 08:37:59 +00003241
Gregory P. Smithbb213892009-11-02 01:37:37 +00003242AC_CACHE_CHECK([for lchflags], [ac_cv_have_lchflags], [dnl
Ned Deily43e10542011-06-27 23:41:53 -07003243AC_RUN_IFELSE([AC_LANG_SOURCE([[
Martin v. Löwisa51d5c82007-12-04 08:37:59 +00003244#include <sys/stat.h>
3245#include <unistd.h>
3246int main(int argc, char*argv[])
3247{
3248 if(lchflags(argv[0], 0) != 0)
3249 return 1;
3250 return 0;
3251}
Ned Deily43e10542011-06-27 23:41:53 -07003252]])],[ac_cv_have_lchflags=yes],[ac_cv_have_lchflags=no],[ac_cv_have_lchflags=cross])
Gregory P. Smithbb213892009-11-02 01:37:37 +00003253])
3254if test "$ac_cv_have_lchflags" = cross ; then
3255 AC_CHECK_FUNC([lchflags], [ac_cv_have_lchflags="yes"], [ac_cv_have_lchflags="no"])
3256fi
3257if test "$ac_cv_have_lchflags" = yes ; then
Ned Deily43e10542011-06-27 23:41:53 -07003258 AC_DEFINE(HAVE_LCHFLAGS, 1, [Define to 1 if you have the 'lchflags' function.])
Alexandre Vassalotti00900892009-07-17 05:26:39 +00003259fi
Martin v. Löwisa51d5c82007-12-04 08:37:59 +00003260
Neal Norwitz6e73aaa2006-06-12 03:33:09 +00003261dnl Check if system zlib has *Copy() functions
Ronald Oussorenf8752642006-07-06 10:13:35 +00003262dnl
3263dnl On MacOSX the linker will search for dylibs on the entire linker path
3264dnl before searching for static libraries. setup.py adds -Wl,-search_paths_first
3265dnl to revert to a more traditional unix behaviour and make it possible to
3266dnl override the system libz with a local static library of libz. Temporarily
3267dnl add that flag to our CFLAGS as well to ensure that we check the version
3268dnl of libz that will be used by setup.py.
3269dnl The -L/usr/local/lib is needed as wel to get the same compilation
3270dnl environment as setup.py (and leaving it out can cause configure to use the
3271dnl wrong version of the library)
3272case $ac_sys_system/$ac_sys_release in
3273Darwin/*)
3274 _CUR_CFLAGS="${CFLAGS}"
3275 _CUR_LDFLAGS="${LDFLAGS}"
3276 CFLAGS="${CFLAGS} -Wl,-search_paths_first"
3277 LDFLAGS="${LDFLAGS} -Wl,-search_paths_first -L/usr/local/lib"
3278 ;;
3279esac
3280
Matthias Klose5183ebd2010-04-24 16:38:36 +00003281AC_CHECK_LIB(z, inflateCopy, AC_DEFINE(HAVE_ZLIB_COPY, 1, [Define if the zlib library has inflateCopy]))
Neal Norwitz6e73aaa2006-06-12 03:33:09 +00003282
Ronald Oussorenf8752642006-07-06 10:13:35 +00003283case $ac_sys_system/$ac_sys_release in
3284Darwin/*)
3285 CFLAGS="${_CUR_CFLAGS}"
3286 LDFLAGS="${_CUR_LDFLAGS}"
3287 ;;
3288esac
3289
Martin v. Löwise9416172003-05-03 10:12:45 +00003290AC_MSG_CHECKING(for hstrerror)
Matthias Klosec511b472010-05-08 11:01:39 +00003291AC_LINK_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwise9416172003-05-03 10:12:45 +00003292#include <netdb.h>
Matthias Klosec511b472010-05-08 11:01:39 +00003293]], [[void* p = hstrerror; hstrerror(0)]])],
3294 [AC_DEFINE(HAVE_HSTRERROR, 1, Define if you have the 'hstrerror' function.)
3295 AC_MSG_RESULT(yes)],
3296 [AC_MSG_RESULT(no)
3297])
Martin v. Löwise9416172003-05-03 10:12:45 +00003298
3299AC_MSG_CHECKING(for inet_aton)
Matthias Klosec511b472010-05-08 11:01:39 +00003300AC_LINK_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwis86d66262006-02-17 08:40:11 +00003301#include <sys/types.h>
Martin v. Löwise9416172003-05-03 10:12:45 +00003302#include <sys/socket.h>
3303#include <netinet/in.h>
3304#include <arpa/inet.h>
Matthias Klosec511b472010-05-08 11:01:39 +00003305]], [[void* p = inet_aton;inet_aton(0,0)]])],
3306 [AC_DEFINE(HAVE_INET_ATON, 1, Define if you have the 'inet_aton' function.)
3307 AC_MSG_RESULT(yes)],
3308 [AC_MSG_RESULT(no)
3309])
Martin v. Löwise9416172003-05-03 10:12:45 +00003310
3311AC_MSG_CHECKING(for inet_pton)
Matthias Klosec511b472010-05-08 11:01:39 +00003312AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwisf2e488d2003-05-05 22:00:11 +00003313#include <sys/types.h>
Martin v. Löwise9416172003-05-03 10:12:45 +00003314#include <sys/socket.h>
3315#include <netinet/in.h>
3316#include <arpa/inet.h>
Matthias Klosec511b472010-05-08 11:01:39 +00003317]], [[void* p = inet_pton]])],
3318 [AC_DEFINE(HAVE_INET_PTON, 1, Define if you have the 'inet_pton' function.)
3319 AC_MSG_RESULT(yes)],
3320 [AC_MSG_RESULT(no)
3321])
Martin v. Löwise9416172003-05-03 10:12:45 +00003322
Martin v. Löwisd6640d42003-07-06 09:29:52 +00003323# On some systems, setgroups is in unistd.h, on others, in grp.h
Martin v. Löwisd5843682002-11-21 20:41:28 +00003324AC_MSG_CHECKING(for setgroups)
Matthias Klosec511b472010-05-08 11:01:39 +00003325AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwisf2e488d2003-05-05 22:00:11 +00003326#include <unistd.h>
Martin v. Löwisd6640d42003-07-06 09:29:52 +00003327#ifdef HAVE_GRP_H
3328#include <grp.h>
3329#endif
Matthias Klosec511b472010-05-08 11:01:39 +00003330]], [[void* p = setgroups]])],
3331 [AC_DEFINE(HAVE_SETGROUPS, 1, Define if you have the 'setgroups' function.)
3332 AC_MSG_RESULT(yes)],
3333 [AC_MSG_RESULT(no)
3334])
Martin v. Löwisd5843682002-11-21 20:41:28 +00003335
Fred Drake8cef4cf2000-06-28 16:40:38 +00003336# check for openpty and forkpty
3337
Martin v. Löwisfd9a72a2006-01-08 10:07:33 +00003338AC_CHECK_FUNCS(openpty,,
3339 AC_CHECK_LIB(util,openpty,
3340 [AC_DEFINE(HAVE_OPENPTY) LIBS="$LIBS -lutil"],
3341 AC_CHECK_LIB(bsd,openpty, [AC_DEFINE(HAVE_OPENPTY) LIBS="$LIBS -lbsd"])
3342 )
3343)
3344AC_CHECK_FUNCS(forkpty,,
3345 AC_CHECK_LIB(util,forkpty,
3346 [AC_DEFINE(HAVE_FORKPTY) LIBS="$LIBS -lutil"],
3347 AC_CHECK_LIB(bsd,forkpty, [AC_DEFINE(HAVE_FORKPTY) LIBS="$LIBS -lbsd"])
3348 )
3349)
Fred Drake8cef4cf2000-06-28 16:40:38 +00003350
Brett Cannonaa5778d2008-03-18 04:09:00 +00003351# Stuff for expat.
3352AC_CHECK_FUNCS(memmove)
3353
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00003354# check for long file support functions
3355AC_CHECK_FUNCS(fseek64 fseeko fstatvfs ftell64 ftello statvfs)
3356
Brett Cannonaa5778d2008-03-18 04:09:00 +00003357AC_REPLACE_FUNCS(dup2 getcwd strdup)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003358AC_CHECK_FUNCS(getpgrp,
Matthias Klosec511b472010-05-08 11:01:39 +00003359 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[getpgrp(0);]])],
3360 [AC_DEFINE(GETPGRP_HAVE_ARG, 1, [Define if getpgrp() must be called as getpgrp(0).])],
3361 [])
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003362)
Jack Jansen150753c2003-03-29 22:07:47 +00003363AC_CHECK_FUNCS(setpgrp,
Matthias Klosec511b472010-05-08 11:01:39 +00003364 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[setpgrp(0,0);]])],
3365 [AC_DEFINE(SETPGRP_HAVE_ARG, 1, [Define if setpgrp() must be called as setpgrp(0, 0).])],
3366 [])
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003367)
3368AC_CHECK_FUNCS(gettimeofday,
Matthias Klosec511b472010-05-08 11:01:39 +00003369 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/time.h>]],
3370 [[gettimeofday((struct timeval*)0,(struct timezone*)0);]])],
3371 [],
3372 [AC_DEFINE(GETTIMEOFDAY_NO_TZ, 1,
3373 [Define if gettimeofday() does not have second (timezone) argument
3374 This is the case on Motorola V4 (R40V4.2)])
3375 ])
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003376)
Guido van Rossum627b2d71993-12-24 10:39:16 +00003377
Martin v. Löwisdbe3f762002-10-10 14:27:30 +00003378AC_MSG_CHECKING(for major, minor, and makedev)
Matthias Klosec511b472010-05-08 11:01:39 +00003379AC_LINK_IFELSE([AC_LANG_PROGRAM([[
Neal Norwitz6eb37f02003-02-23 23:28:15 +00003380#if defined(MAJOR_IN_MKDEV)
3381#include <sys/mkdev.h>
3382#elif defined(MAJOR_IN_SYSMACROS)
3383#include <sys/sysmacros.h>
3384#else
3385#include <sys/types.h>
3386#endif
Matthias Klosec511b472010-05-08 11:01:39 +00003387]], [[
Martin v. Löwisdbe3f762002-10-10 14:27:30 +00003388 makedev(major(0),minor(0));
Matthias Klosec511b472010-05-08 11:01:39 +00003389]])],[
Martin v. Löwisdbe3f762002-10-10 14:27:30 +00003390 AC_DEFINE(HAVE_DEVICE_MACROS, 1,
3391 [Define to 1 if you have the device macros.])
3392 AC_MSG_RESULT(yes)
3393],[
3394 AC_MSG_RESULT(no)
3395])
Martin v. Löwis861a65b2001-10-24 14:36:00 +00003396
3397# On OSF/1 V5.1, getaddrinfo is available, but a define
3398# for [no]getaddrinfo in netdb.h.
3399AC_MSG_CHECKING(for getaddrinfo)
Matthias Klosec511b472010-05-08 11:01:39 +00003400AC_LINK_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwisc010b6d2001-11-09 17:50:52 +00003401#include <sys/types.h>
Martin v. Löwis861a65b2001-10-24 14:36:00 +00003402#include <sys/socket.h>
3403#include <netdb.h>
Martin v. Löwisc010b6d2001-11-09 17:50:52 +00003404#include <stdio.h>
Matthias Klosec511b472010-05-08 11:01:39 +00003405]], [[getaddrinfo(NULL, NULL, NULL, NULL);]])],
3406[have_getaddrinfo=yes],
3407[have_getaddrinfo=no])
Alexandre Vassalotti00900892009-07-17 05:26:39 +00003408AC_MSG_RESULT($have_getaddrinfo)
3409if test $have_getaddrinfo = yes
3410then
3411 AC_MSG_CHECKING(getaddrinfo bug)
3412 AC_CACHE_VAL(ac_cv_buggy_getaddrinfo,
Matthias Klosec511b472010-05-08 11:01:39 +00003413 AC_RUN_IFELSE([AC_LANG_SOURCE([[[
Stefan Krah0afe4e42012-11-22 23:56:51 +01003414#include <stdio.h>
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003415#include <sys/types.h>
3416#include <netdb.h>
3417#include <string.h>
3418#include <sys/socket.h>
3419#include <netinet/in.h>
3420
Alexandre Vassalotti00900892009-07-17 05:26:39 +00003421int main()
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003422{
3423 int passive, gaierr, inet4 = 0, inet6 = 0;
3424 struct addrinfo hints, *ai, *aitop;
3425 char straddr[INET6_ADDRSTRLEN], strport[16];
3426
3427 for (passive = 0; passive <= 1; passive++) {
3428 memset(&hints, 0, sizeof(hints));
3429 hints.ai_family = AF_UNSPEC;
3430 hints.ai_flags = passive ? AI_PASSIVE : 0;
3431 hints.ai_socktype = SOCK_STREAM;
Hye-Shik Chang54f94392004-04-14 07:55:31 +00003432 hints.ai_protocol = IPPROTO_TCP;
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003433 if ((gaierr = getaddrinfo(NULL, "54321", &hints, &aitop)) != 0) {
3434 (void)gai_strerror(gaierr);
3435 goto bad;
3436 }
3437 for (ai = aitop; ai; ai = ai->ai_next) {
3438 if (ai->ai_addr == NULL ||
3439 ai->ai_addrlen == 0 ||
3440 getnameinfo(ai->ai_addr, ai->ai_addrlen,
3441 straddr, sizeof(straddr), strport, sizeof(strport),
3442 NI_NUMERICHOST|NI_NUMERICSERV) != 0) {
3443 goto bad;
3444 }
3445 switch (ai->ai_family) {
3446 case AF_INET:
3447 if (strcmp(strport, "54321") != 0) {
3448 goto bad;
3449 }
3450 if (passive) {
3451 if (strcmp(straddr, "0.0.0.0") != 0) {
3452 goto bad;
3453 }
3454 } else {
3455 if (strcmp(straddr, "127.0.0.1") != 0) {
3456 goto bad;
3457 }
3458 }
3459 inet4++;
3460 break;
3461 case AF_INET6:
3462 if (strcmp(strport, "54321") != 0) {
3463 goto bad;
3464 }
3465 if (passive) {
3466 if (strcmp(straddr, "::") != 0) {
3467 goto bad;
3468 }
3469 } else {
3470 if (strcmp(straddr, "::1") != 0) {
3471 goto bad;
3472 }
3473 }
3474 inet6++;
3475 break;
3476 case AF_UNSPEC:
3477 goto bad;
3478 break;
3479 default:
3480 /* another family support? */
3481 break;
3482 }
3483 }
Benjamin Petersond34677c2016-09-06 15:54:24 -07003484 freeaddrinfo(aitop);
3485 aitop = NULL;
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003486 }
3487
3488 if (!(inet4 == 0 || inet4 == 2))
3489 goto bad;
3490 if (!(inet6 == 0 || inet6 == 2))
3491 goto bad;
3492
3493 if (aitop)
3494 freeaddrinfo(aitop);
Alexandre Vassalotti00900892009-07-17 05:26:39 +00003495 return 0;
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003496
3497 bad:
3498 if (aitop)
3499 freeaddrinfo(aitop);
Alexandre Vassalotti00900892009-07-17 05:26:39 +00003500 return 1;
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003501}
Matthias Klosec511b472010-05-08 11:01:39 +00003502]]])],
3503[ac_cv_buggy_getaddrinfo=no],
3504[ac_cv_buggy_getaddrinfo=yes],
doko@python.orgd65e2ba2013-01-31 23:52:03 +01003505[
3506if test "${enable_ipv6+set}" = set; then
3507 ac_cv_buggy_getaddrinfo="no -- configured with --(en|dis)able-ipv6"
3508else
3509 ac_cv_buggy_getaddrinfo=yes
3510fi]))
Alexandre Vassalotti00900892009-07-17 05:26:39 +00003511fi
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003512
Benjamin Peterson75fed812010-11-01 01:47:19 +00003513AC_MSG_RESULT($ac_cv_buggy_getaddrinfo)
3514
Mark Dickinson0ef0b912009-12-31 21:11:48 +00003515if test $have_getaddrinfo = no -o "$ac_cv_buggy_getaddrinfo" = yes
Alexandre Vassalotti00900892009-07-17 05:26:39 +00003516then
3517 if test $ipv6 = yes
3518 then
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003519 echo 'Fatal: You must get working getaddrinfo() function.'
3520 echo ' or you can specify "--disable-ipv6"'.
3521 exit 1
3522 fi
Martin v. Löwis861a65b2001-10-24 14:36:00 +00003523else
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003524 AC_DEFINE(HAVE_GETADDRINFO, 1, [Define if you have the getaddrinfo function.])
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003525fi
Benjamin Peterson75fed812010-11-01 01:47:19 +00003526
Thomas Woutersb0db85a2001-08-08 10:39:03 +00003527AC_CHECK_FUNCS(getnameinfo)
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003528
Guido van Rossum627b2d71993-12-24 10:39:16 +00003529# checks for structures
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003530AC_HEADER_TIME
Guido van Rossum627b2d71993-12-24 10:39:16 +00003531AC_STRUCT_TM
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003532AC_STRUCT_TIMEZONE
Martin v. Löwis60a5d722002-10-16 20:28:25 +00003533AC_CHECK_MEMBERS([struct stat.st_rdev])
3534AC_CHECK_MEMBERS([struct stat.st_blksize])
Hye-Shik Chang5f937a72005-06-02 13:09:30 +00003535AC_CHECK_MEMBERS([struct stat.st_flags])
Martin v. Löwisebd9d5b2005-08-09 15:00:59 +00003536AC_CHECK_MEMBERS([struct stat.st_gen])
3537AC_CHECK_MEMBERS([struct stat.st_birthtime])
Martin Pantera45120d2016-03-18 02:36:41 +00003538AC_CHECK_MEMBERS([struct stat.st_blocks])
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003539
3540AC_MSG_CHECKING(for time.h that defines altzone)
Matthias Klosec511b472010-05-08 11:01:39 +00003541AC_CACHE_VAL(ac_cv_header_time_altzone,[
3542 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <time.h>]], [[return altzone;]])],
3543 [ac_cv_header_time_altzone=yes],
3544 [ac_cv_header_time_altzone=no])
3545 ])
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003546AC_MSG_RESULT($ac_cv_header_time_altzone)
3547if test $ac_cv_header_time_altzone = yes; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003548 AC_DEFINE(HAVE_ALTZONE, 1, [Define this if your time.h defines altzone.])
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003549fi
3550
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003551was_it_defined=no
3552AC_MSG_CHECKING(whether sys/select.h and sys/time.h may both be included)
Matthias Klosec511b472010-05-08 11:01:39 +00003553AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003554#include <sys/types.h>
3555#include <sys/select.h>
3556#include <sys/time.h>
Matthias Klosec511b472010-05-08 11:01:39 +00003557]], [[;]])],[
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003558 AC_DEFINE(SYS_SELECT_WITH_SYS_TIME, 1,
3559 [Define if you can safely include both <sys/select.h> and <sys/time.h>
3560 (which you can't on SCO ODT 3.0).])
3561 was_it_defined=yes
Matthias Klosec511b472010-05-08 11:01:39 +00003562],[])
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003563AC_MSG_RESULT($was_it_defined)
Guido van Rossum627b2d71993-12-24 10:39:16 +00003564
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003565AC_MSG_CHECKING(for addrinfo)
3566AC_CACHE_VAL(ac_cv_struct_addrinfo,
Matthias Klosec511b472010-05-08 11:01:39 +00003567AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <netdb.h>]], [[struct addrinfo a]])],
3568 [ac_cv_struct_addrinfo=yes],
3569 [ac_cv_struct_addrinfo=no]))
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003570AC_MSG_RESULT($ac_cv_struct_addrinfo)
3571if test $ac_cv_struct_addrinfo = yes; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003572 AC_DEFINE(HAVE_ADDRINFO, 1, [struct addrinfo (netdb.h)])
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003573fi
3574
3575AC_MSG_CHECKING(for sockaddr_storage)
3576AC_CACHE_VAL(ac_cv_struct_sockaddr_storage,
Matthias Klosec511b472010-05-08 11:01:39 +00003577AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003578# include <sys/types.h>
Matthias Klosec511b472010-05-08 11:01:39 +00003579# include <sys/socket.h>]], [[struct sockaddr_storage s]])],
3580 [ac_cv_struct_sockaddr_storage=yes],
3581 [ac_cv_struct_sockaddr_storage=no]))
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003582AC_MSG_RESULT($ac_cv_struct_sockaddr_storage)
3583if test $ac_cv_struct_sockaddr_storage = yes; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003584 AC_DEFINE(HAVE_SOCKADDR_STORAGE, 1, [struct sockaddr_storage (sys/socket.h)])
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003585fi
3586
Guido van Rossum627b2d71993-12-24 10:39:16 +00003587# checks for compiler characteristics
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003588
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003589AC_C_CHAR_UNSIGNED
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003590AC_C_CONST
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003591
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003592works=no
3593AC_MSG_CHECKING(for working volatile)
Matthias Klosec511b472010-05-08 11:01:39 +00003594AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[volatile int x; x = 0;]])],
3595 [works=yes],
3596 [AC_DEFINE(volatile, , [Define to empty if the keyword does not work.])]
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003597)
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003598AC_MSG_RESULT($works)
Guido van Rossumdabb11b1994-10-11 15:04:27 +00003599
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003600works=no
3601AC_MSG_CHECKING(for working signed char)
Matthias Klosec511b472010-05-08 11:01:39 +00003602AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[signed char c;]])],
3603 [works=yes],
3604 [AC_DEFINE(signed, , [Define to empty if the keyword does not work.])]
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003605)
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003606AC_MSG_RESULT($works)
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003607
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003608have_prototypes=no
3609AC_MSG_CHECKING(for prototypes)
Matthias Klosec511b472010-05-08 11:01:39 +00003610AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[int foo(int x) { return 0; }]], [[return foo(10);]])],
3611 [AC_DEFINE(HAVE_PROTOTYPES, 1,
3612 [Define if your compiler supports function prototype])
3613 have_prototypes=yes],
3614 []
3615)
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003616AC_MSG_RESULT($have_prototypes)
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003617
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003618works=no
3619AC_MSG_CHECKING(for variable length prototypes and stdarg.h)
Matthias Klosec511b472010-05-08 11:01:39 +00003620AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003621#include <stdarg.h>
Guido van Rossum3f13e481996-08-30 20:58:11 +00003622int foo(int x, ...) {
3623 va_list va;
3624 va_start(va, x);
3625 va_arg(va, int);
3626 va_arg(va, char *);
3627 va_arg(va, double);
3628 return 0;
3629}
Matthias Klosec511b472010-05-08 11:01:39 +00003630]], [[return foo(10, "", 3.14);]])],[
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003631 AC_DEFINE(HAVE_STDARG_PROTOTYPES, 1,
3632 [Define if your compiler supports variable length function prototypes
3633 (e.g. void fprintf(FILE *, char *, ...);) *and* <stdarg.h>])
3634 works=yes
Matthias Klosec511b472010-05-08 11:01:39 +00003635],[])
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003636AC_MSG_RESULT($works)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003637
Dave Cole331708b2004-08-09 04:51:41 +00003638# check for socketpair
3639AC_MSG_CHECKING(for socketpair)
Matthias Klosec511b472010-05-08 11:01:39 +00003640AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Dave Cole331708b2004-08-09 04:51:41 +00003641#include <sys/types.h>
3642#include <sys/socket.h>
Matthias Klosec511b472010-05-08 11:01:39 +00003643]], [[void *x=socketpair]])],
3644 [AC_DEFINE(HAVE_SOCKETPAIR, 1, [Define if you have the 'socketpair' function.])
3645 AC_MSG_RESULT(yes)],
3646 [AC_MSG_RESULT(no)]
Dave Cole331708b2004-08-09 04:51:41 +00003647)
3648
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003649# check if sockaddr has sa_len member
3650AC_MSG_CHECKING(if sockaddr has sa_len member)
Matthias Klosec511b472010-05-08 11:01:39 +00003651AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
3652#include <sys/socket.h>]], [[struct sockaddr x;
3653x.sa_len = 0;]])],
3654 [AC_MSG_RESULT(yes)
3655 AC_DEFINE(HAVE_SOCKADDR_SA_LEN, 1, [Define if sockaddr has sa_len member])],
3656 [AC_MSG_RESULT(no)]
3657)
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003658
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003659va_list_is_array=no
3660AC_MSG_CHECKING(whether va_list is an array)
Matthias Klosec511b472010-05-08 11:01:39 +00003661AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003662#ifdef HAVE_STDARG_PROTOTYPES
3663#include <stdarg.h>
3664#else
3665#include <varargs.h>
3666#endif
Matthias Klosec511b472010-05-08 11:01:39 +00003667]], [[va_list list1, list2; list1 = list2;]])],[],[
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003668 AC_DEFINE(VA_LIST_IS_ARRAY, 1, [Define if a va_list is an array of some kind])
3669 va_list_is_array=yes
3670])
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003671AC_MSG_RESULT($va_list_is_array)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003672
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003673# sigh -- gethostbyname_r is a mess; it can have 3, 5 or 6 arguments :-(
Martin v. Löwis11437992002-04-12 09:54:03 +00003674AH_TEMPLATE(HAVE_GETHOSTBYNAME_R,
3675 [Define this if you have some version of gethostbyname_r()])
3676
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003677AC_CHECK_FUNC(gethostbyname_r, [
3678 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
3679 AC_MSG_CHECKING([gethostbyname_r with 6 args])
3680 OLD_CFLAGS=$CFLAGS
3681 CFLAGS="$CFLAGS $MY_CPPFLAGS $MY_THREAD_CPPFLAGS $MY_CFLAGS"
Matthias Klosec511b472010-05-08 11:01:39 +00003682 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003683# include <netdb.h>
Matthias Klosec511b472010-05-08 11:01:39 +00003684 ]], [[
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003685 char *name;
3686 struct hostent *he, *res;
3687 char buffer[2048];
3688 int buflen = 2048;
3689 int h_errnop;
3690
3691 (void) gethostbyname_r(name, he, buffer, buflen, &res, &h_errnop)
Matthias Klosec511b472010-05-08 11:01:39 +00003692 ]])],[
Guido van Rossum8db7d8b1999-03-23 16:40:33 +00003693 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003694 AC_DEFINE(HAVE_GETHOSTBYNAME_R_6_ARG, 1,
3695 [Define this if you have the 6-arg version of gethostbyname_r().])
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003696 AC_MSG_RESULT(yes)
Matthias Klosec511b472010-05-08 11:01:39 +00003697 ],[
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003698 AC_MSG_RESULT(no)
3699 AC_MSG_CHECKING([gethostbyname_r with 5 args])
Matthias Klosec511b472010-05-08 11:01:39 +00003700 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003701# include <netdb.h>
Matthias Klosec511b472010-05-08 11:01:39 +00003702 ]], [[
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003703 char *name;
3704 struct hostent *he;
Matthias Klosec511b472010-05-08 11:01:39 +00003705 char buffer[2048];
3706 int buflen = 2048;
3707 int h_errnop;
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003708
Matthias Klosec511b472010-05-08 11:01:39 +00003709 (void) gethostbyname_r(name, he, buffer, buflen, &h_errnop)
3710 ]])],
3711 [
Guido van Rossum8db7d8b1999-03-23 16:40:33 +00003712 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
Matthias Klosec511b472010-05-08 11:01:39 +00003713 AC_DEFINE(HAVE_GETHOSTBYNAME_R_5_ARG, 1,
3714 [Define this if you have the 5-arg version of gethostbyname_r().])
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003715 AC_MSG_RESULT(yes)
3716 ], [
3717 AC_MSG_RESULT(no)
Matthias Klosec511b472010-05-08 11:01:39 +00003718 AC_MSG_CHECKING([gethostbyname_r with 3 args])
3719 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3720# include <netdb.h>
3721 ]], [[
3722 char *name;
3723 struct hostent *he;
3724 struct hostent_data data;
3725
3726 (void) gethostbyname_r(name, he, &data);
3727 ]])],
3728 [
3729 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
3730 AC_DEFINE(HAVE_GETHOSTBYNAME_R_3_ARG, 1,
3731 [Define this if you have the 3-arg version of gethostbyname_r().])
3732 AC_MSG_RESULT(yes)
3733 ], [
3734 AC_MSG_RESULT(no)
3735 ])
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003736 ])
3737 ])
3738 CFLAGS=$OLD_CFLAGS
3739], [
Thomas Wouters3a584202000-08-05 23:28:51 +00003740 AC_CHECK_FUNCS(gethostbyname)
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003741])
3742AC_SUBST(HAVE_GETHOSTBYNAME_R_6_ARG)
3743AC_SUBST(HAVE_GETHOSTBYNAME_R_5_ARG)
3744AC_SUBST(HAVE_GETHOSTBYNAME_R_3_ARG)
Guido van Rossum8db7d8b1999-03-23 16:40:33 +00003745AC_SUBST(HAVE_GETHOSTBYNAME_R)
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003746AC_SUBST(HAVE_GETHOSTBYNAME)
3747
Guido van Rossum627b2d71993-12-24 10:39:16 +00003748# checks for system services
3749# (none yet)
3750
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003751# Linux requires this for correct f.p. operations
Jeremy Hyltonbe28f5b2000-07-27 21:03:04 +00003752AC_CHECK_FUNC(__fpu_control,
3753 [],
3754 [AC_CHECK_LIB(ieee, __fpu_control)
3755])
Guido van Rossum627b2d71993-12-24 10:39:16 +00003756
Guido van Rossum93274221997-05-09 02:42:00 +00003757# Check for --with-fpectl
Guido van Rossum93274221997-05-09 02:42:00 +00003758AC_MSG_CHECKING(for --with-fpectl)
Barry Warsawc0d24d82000-06-29 16:12:00 +00003759AC_ARG_WITH(fpectl,
Matthias Klose22520ea2010-05-08 10:14:46 +00003760 AS_HELP_STRING([--with-fpectl], [enable SIGFPE catching]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003761[
Guido van Rossum93274221997-05-09 02:42:00 +00003762if test "$withval" != no
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003763then
3764 AC_DEFINE(WANT_SIGFPE_HANDLER, 1,
3765 [Define if you want SIGFPE handled (see Include/pyfpe.h).])
3766 AC_MSG_RESULT(yes)
Guido van Rossum93274221997-05-09 02:42:00 +00003767else AC_MSG_RESULT(no)
Guido van Rossumef2255b2000-03-10 22:30:29 +00003768fi],
3769[AC_MSG_RESULT(no)])
Guido van Rossum93274221997-05-09 02:42:00 +00003770
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003771# check for --with-libm=...
3772AC_SUBST(LIBM)
Guido van Rossum4b6b5791996-09-09 20:09:34 +00003773case $ac_sys_system in
Guido van Rossum3dc0a512000-10-05 18:00:06 +00003774Darwin) ;;
Guido van Rossumec95c7b1998-08-04 17:59:56 +00003775BeOS) ;;
Guido van Rossum4b6b5791996-09-09 20:09:34 +00003776*) LIBM=-lm
3777esac
Guido van Rossum93274221997-05-09 02:42:00 +00003778AC_MSG_CHECKING(for --with-libm=STRING)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003779AC_ARG_WITH(libm,
Matthias Klose22520ea2010-05-08 10:14:46 +00003780 AS_HELP_STRING([--with-libm=STRING], [math library]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003781[
Guido van Rossum93274221997-05-09 02:42:00 +00003782if test "$withval" = no
3783then LIBM=
3784 AC_MSG_RESULT(force LIBM empty)
3785elif test "$withval" != yes
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003786then LIBM=$withval
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003787 AC_MSG_RESULT(set LIBM="$withval")
3788else AC_MSG_ERROR([proper usage is --with-libm=STRING])
Guido van Rossum93274221997-05-09 02:42:00 +00003789fi],
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003790[AC_MSG_RESULT(default LIBM="$LIBM")])
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003791
3792# check for --with-libc=...
3793AC_SUBST(LIBC)
Guido van Rossum93274221997-05-09 02:42:00 +00003794AC_MSG_CHECKING(for --with-libc=STRING)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003795AC_ARG_WITH(libc,
Matthias Klose22520ea2010-05-08 10:14:46 +00003796 AS_HELP_STRING([--with-libc=STRING], [C library]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003797[
Guido van Rossum93274221997-05-09 02:42:00 +00003798if test "$withval" = no
3799then LIBC=
3800 AC_MSG_RESULT(force LIBC empty)
3801elif test "$withval" != yes
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003802then LIBC=$withval
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003803 AC_MSG_RESULT(set LIBC="$withval")
3804else AC_MSG_ERROR([proper usage is --with-libc=STRING])
Guido van Rossum93274221997-05-09 02:42:00 +00003805fi],
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003806[AC_MSG_RESULT(default LIBC="$LIBC")])
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003807
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003808# **************************************************
3809# * Check for various properties of floating point *
3810# **************************************************
Mark Dickinson265d7382008-04-21 22:32:24 +00003811
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003812AC_MSG_CHECKING(whether C doubles are little-endian IEEE 754 binary64)
3813AC_CACHE_VAL(ac_cv_little_endian_double, [
Matthias Klosec511b472010-05-08 11:01:39 +00003814AC_RUN_IFELSE([AC_LANG_SOURCE([[
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003815#include <string.h>
3816int main() {
3817 double x = 9006104071832581.0;
3818 if (memcmp(&x, "\x05\x04\x03\x02\x01\xff\x3f\x43", 8) == 0)
3819 return 0;
3820 else
3821 return 1;
3822}
Matthias Klosec511b472010-05-08 11:01:39 +00003823]])],
3824[ac_cv_little_endian_double=yes],
3825[ac_cv_little_endian_double=no],
3826[ac_cv_little_endian_double=no])])
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003827AC_MSG_RESULT($ac_cv_little_endian_double)
3828if test "$ac_cv_little_endian_double" = yes
3829then
3830 AC_DEFINE(DOUBLE_IS_LITTLE_ENDIAN_IEEE754, 1,
3831 [Define if C doubles are 64-bit IEEE 754 binary format, stored
3832 with the least significant byte first])
3833fi
3834
3835AC_MSG_CHECKING(whether C doubles are big-endian IEEE 754 binary64)
3836AC_CACHE_VAL(ac_cv_big_endian_double, [
Matthias Klosec511b472010-05-08 11:01:39 +00003837AC_RUN_IFELSE([AC_LANG_SOURCE([[
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003838#include <string.h>
3839int main() {
3840 double x = 9006104071832581.0;
3841 if (memcmp(&x, "\x43\x3f\xff\x01\x02\x03\x04\x05", 8) == 0)
3842 return 0;
3843 else
3844 return 1;
3845}
Matthias Klosec511b472010-05-08 11:01:39 +00003846]])],
3847[ac_cv_big_endian_double=yes],
3848[ac_cv_big_endian_double=no],
3849[ac_cv_big_endian_double=no])])
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003850AC_MSG_RESULT($ac_cv_big_endian_double)
3851if test "$ac_cv_big_endian_double" = yes
3852then
3853 AC_DEFINE(DOUBLE_IS_BIG_ENDIAN_IEEE754, 1,
3854 [Define if C doubles are 64-bit IEEE 754 binary format, stored
3855 with the most significant byte first])
3856fi
3857
3858# Some ARM platforms use a mixed-endian representation for doubles.
3859# While Python doesn't currently have full support for these platforms
3860# (see e.g., issue 1762561), we can at least make sure that float <-> string
3861# conversions work.
3862AC_MSG_CHECKING(whether C doubles are ARM mixed-endian IEEE 754 binary64)
3863AC_CACHE_VAL(ac_cv_mixed_endian_double, [
Matthias Klosec511b472010-05-08 11:01:39 +00003864AC_RUN_IFELSE([AC_LANG_SOURCE([[
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003865#include <string.h>
3866int main() {
3867 double x = 9006104071832581.0;
3868 if (memcmp(&x, "\x01\xff\x3f\x43\x05\x04\x03\x02", 8) == 0)
3869 return 0;
3870 else
3871 return 1;
3872}
Matthias Klosec511b472010-05-08 11:01:39 +00003873]])],
3874[ac_cv_mixed_endian_double=yes],
3875[ac_cv_mixed_endian_double=no],
3876[ac_cv_mixed_endian_double=no])])
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003877AC_MSG_RESULT($ac_cv_mixed_endian_double)
3878if test "$ac_cv_mixed_endian_double" = yes
3879then
3880 AC_DEFINE(DOUBLE_IS_ARM_MIXED_ENDIAN_IEEE754, 1,
3881 [Define if C doubles are 64-bit IEEE 754 binary format, stored
3882 in ARM mixed-endian order (byte order 45670123)])
3883fi
3884
3885# The short float repr introduced in Python 3.1 requires the
3886# correctly-rounded string <-> double conversion functions from
3887# Python/dtoa.c, which in turn require that the FPU uses 53-bit
3888# rounding; this is a problem on x86, where the x87 FPU has a default
Mark Dickinsona548dee2009-11-15 13:12:43 +00003889# rounding precision of 64 bits. For gcc/x86, we can fix this by
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003890# using inline assembler to get and set the x87 FPU control word.
Mark Dickinsona548dee2009-11-15 13:12:43 +00003891
3892# This inline assembler syntax may also work for suncc and icc,
3893# so we try it on all platforms.
3894
3895AC_MSG_CHECKING(whether we can use gcc inline assembler to get and set x87 control word)
Stefan Krah99e36b92015-07-03 15:30:54 +02003896AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
Mark Dickinsona548dee2009-11-15 13:12:43 +00003897 unsigned short cw;
3898 __asm__ __volatile__ ("fnstcw %0" : "=m" (cw));
3899 __asm__ __volatile__ ("fldcw %0" : : "m" (cw));
Matthias Klosec511b472010-05-08 11:01:39 +00003900]])],[have_gcc_asm_for_x87=yes],[have_gcc_asm_for_x87=no])
Mark Dickinsona548dee2009-11-15 13:12:43 +00003901AC_MSG_RESULT($have_gcc_asm_for_x87)
3902if test "$have_gcc_asm_for_x87" = yes
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003903then
Mark Dickinsona548dee2009-11-15 13:12:43 +00003904 AC_DEFINE(HAVE_GCC_ASM_FOR_X87, 1,
3905 [Define if we can use gcc inline assembler to get and set x87 control word])
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003906fi
Mark Dickinson7a3d8642008-04-22 00:54:27 +00003907
Mark Dickinson04b27232009-01-04 12:29:36 +00003908# Detect whether system arithmetic is subject to x87-style double
3909# rounding issues. The result of this test has little meaning on non
3910# IEEE 754 platforms. On IEEE 754, test should return 1 if rounding
3911# mode is round-to-nearest and double rounding issues are present, and
3912# 0 otherwise. See http://bugs.python.org/issue2937 for more info.
3913AC_MSG_CHECKING(for x87-style double rounding)
Mark Dickinson99abd142009-10-24 13:44:16 +00003914# $BASECFLAGS may affect the result
3915ac_save_cc="$CC"
3916CC="$CC $BASECFLAGS"
Matthias Klosec511b472010-05-08 11:01:39 +00003917AC_RUN_IFELSE([AC_LANG_SOURCE([[
Mark Dickinson04b27232009-01-04 12:29:36 +00003918#include <stdlib.h>
3919#include <math.h>
3920int main() {
3921 volatile double x, y, z;
3922 /* 1./(1-2**-53) -> 1+2**-52 (correct), 1.0 (double rounding) */
3923 x = 0.99999999999999989; /* 1-2**-53 */
3924 y = 1./x;
3925 if (y != 1.)
3926 exit(0);
3927 /* 1e16+2.99999 -> 1e16+2. (correct), 1e16+4. (double rounding) */
3928 x = 1e16;
3929 y = 2.99999;
3930 z = x + y;
3931 if (z != 1e16+4.)
3932 exit(0);
3933 /* both tests show evidence of double rounding */
3934 exit(1);
3935}
Matthias Klosec511b472010-05-08 11:01:39 +00003936]])],
3937[ac_cv_x87_double_rounding=no],
3938[ac_cv_x87_double_rounding=yes],
3939[ac_cv_x87_double_rounding=no])
Mark Dickinson99abd142009-10-24 13:44:16 +00003940CC="$ac_save_cc"
Mark Dickinson04b27232009-01-04 12:29:36 +00003941AC_MSG_RESULT($ac_cv_x87_double_rounding)
3942if test "$ac_cv_x87_double_rounding" = yes
3943then
3944 AC_DEFINE(X87_DOUBLE_ROUNDING, 1,
3945 [Define if arithmetic is subject to x87-style double rounding issue])
3946fi
3947
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003948# ************************************
3949# * Check for mathematical functions *
3950# ************************************
3951
3952LIBS_SAVE=$LIBS
3953LIBS="$LIBS $LIBM"
3954
Mark Dickinsonc63392c2009-11-28 13:13:13 +00003955# On FreeBSD 6.2, it appears that tanh(-0.) returns 0. instead of
3956# -0. on some architectures.
3957AC_MSG_CHECKING(whether tanh preserves the sign of zero)
3958AC_CACHE_VAL(ac_cv_tanh_preserves_zero_sign, [
Matthias Klosec511b472010-05-08 11:01:39 +00003959AC_RUN_IFELSE([AC_LANG_SOURCE([[
Mark Dickinsonc63392c2009-11-28 13:13:13 +00003960#include <math.h>
3961#include <stdlib.h>
3962int main() {
3963 /* return 0 if either negative zeros don't exist
3964 on this platform or if negative zeros exist
3965 and tanh(-0.) == -0. */
3966 if (atan2(0., -1.) == atan2(-0., -1.) ||
3967 atan2(tanh(-0.), -1.) == atan2(-0., -1.)) exit(0);
3968 else exit(1);
3969}
Matthias Klosec511b472010-05-08 11:01:39 +00003970]])],
3971[ac_cv_tanh_preserves_zero_sign=yes],
3972[ac_cv_tanh_preserves_zero_sign=no],
3973[ac_cv_tanh_preserves_zero_sign=no])])
Mark Dickinsonc63392c2009-11-28 13:13:13 +00003974AC_MSG_RESULT($ac_cv_tanh_preserves_zero_sign)
3975if test "$ac_cv_tanh_preserves_zero_sign" = yes
3976then
3977 AC_DEFINE(TANH_PRESERVES_ZERO_SIGN, 1,
3978 [Define if tanh(-0.) is -0., or if platform doesn't have signed zeros])
3979fi
3980
3981AC_CHECK_FUNCS([acosh asinh atanh copysign erf erfc expm1 finite gamma])
3982AC_CHECK_FUNCS([hypot lgamma log1p round tgamma])
3983AC_CHECK_DECLS([isinf, isnan, isfinite], [], [], [[#include <math.h>]])
3984
3985LIBS=$LIBS_SAVE
3986
Mark Dickinsonc4920e82009-11-20 19:30:22 +00003987# For multiprocessing module, check that sem_open
3988# actually works. For FreeBSD versions <= 7.2,
3989# the kernel module that provides POSIX semaphores
3990# isn't loaded by default, so an attempt to call
3991# sem_open results in a 'Signal 12' error.
3992AC_MSG_CHECKING(whether POSIX semaphores are enabled)
3993AC_CACHE_VAL(ac_cv_posix_semaphores_enabled,
Matthias Klosec511b472010-05-08 11:01:39 +00003994AC_RUN_IFELSE([AC_LANG_SOURCE([[
Mark Dickinsonc4920e82009-11-20 19:30:22 +00003995#include <unistd.h>
3996#include <fcntl.h>
3997#include <stdio.h>
3998#include <semaphore.h>
3999#include <sys/stat.h>
4000
4001int main(void) {
4002 sem_t *a = sem_open("/autoconf", O_CREAT, S_IRUSR|S_IWUSR, 0);
4003 if (a == SEM_FAILED) {
4004 perror("sem_open");
4005 return 1;
4006 }
4007 sem_close(a);
Mark Dickinson59dc89e2009-12-13 21:06:06 +00004008 sem_unlink("/autoconf");
Mark Dickinsonc4920e82009-11-20 19:30:22 +00004009 return 0;
4010}
Matthias Klosec511b472010-05-08 11:01:39 +00004011]])],
4012[ac_cv_posix_semaphores_enabled=yes],
4013[ac_cv_posix_semaphores_enabled=no],
4014[ac_cv_posix_semaphores_enabled=yes])
Mark Dickinsonc4920e82009-11-20 19:30:22 +00004015)
4016AC_MSG_RESULT($ac_cv_posix_semaphores_enabled)
4017if test $ac_cv_posix_semaphores_enabled = no
4018then
Mark Dickinson5afa6d42009-11-28 10:44:20 +00004019 AC_DEFINE(POSIX_SEMAPHORES_NOT_ENABLED, 1,
4020 [Define if POSIX semaphores aren't enabled on your system])
Mark Dickinsonc4920e82009-11-20 19:30:22 +00004021fi
4022
Jesse Noller355b1262009-04-02 00:03:28 +00004023# Multiprocessing check for broken sem_getvalue
4024AC_MSG_CHECKING(for broken sem_getvalue)
Alexandre Vassalotti00900892009-07-17 05:26:39 +00004025AC_CACHE_VAL(ac_cv_broken_sem_getvalue,
Matthias Klosec511b472010-05-08 11:01:39 +00004026AC_RUN_IFELSE([AC_LANG_SOURCE([[
Jesse Noller355b1262009-04-02 00:03:28 +00004027#include <unistd.h>
4028#include <fcntl.h>
4029#include <stdio.h>
4030#include <semaphore.h>
4031#include <sys/stat.h>
4032
4033int main(void){
Mark Dickinson59dc89e2009-12-13 21:06:06 +00004034 sem_t *a = sem_open("/autocftw", O_CREAT, S_IRUSR|S_IWUSR, 0);
Jesse Noller355b1262009-04-02 00:03:28 +00004035 int count;
4036 int res;
4037 if(a==SEM_FAILED){
4038 perror("sem_open");
4039 return 1;
4040
4041 }
4042 res = sem_getvalue(a, &count);
4043 sem_close(a);
Mark Dickinson59dc89e2009-12-13 21:06:06 +00004044 sem_unlink("/autocftw");
Jesse Noller355b1262009-04-02 00:03:28 +00004045 return res==-1 ? 1 : 0;
4046}
Matthias Klosec511b472010-05-08 11:01:39 +00004047]])],
4048[ac_cv_broken_sem_getvalue=no],
4049[ac_cv_broken_sem_getvalue=yes],
4050[ac_cv_broken_sem_getvalue=yes])
Jesse Noller355b1262009-04-02 00:03:28 +00004051)
Alexandre Vassalotti00900892009-07-17 05:26:39 +00004052AC_MSG_RESULT($ac_cv_broken_sem_getvalue)
4053if test $ac_cv_broken_sem_getvalue = yes
4054then
4055 AC_DEFINE(HAVE_BROKEN_SEM_GETVALUE, 1,
4056 [define to 1 if your sem_getvalue is broken.])
4057fi
Mark Dickinson04b27232009-01-04 12:29:36 +00004058
Mark Dickinsonefc82f72009-03-20 15:51:55 +00004059# determine what size digit to use for Python's longs
4060AC_MSG_CHECKING([digit size for Python's longs])
4061AC_ARG_ENABLE(big-digits,
Matthias Klose22520ea2010-05-08 10:14:46 +00004062AS_HELP_STRING([--enable-big-digits@<:@=BITS@:>@],[use big digits for Python longs [[BITS=30]]]),
Mark Dickinsonefc82f72009-03-20 15:51:55 +00004063[case $enable_big_digits in
4064yes)
4065 enable_big_digits=30 ;;
4066no)
4067 enable_big_digits=15 ;;
4068[15|30])
4069 ;;
4070*)
4071 AC_MSG_ERROR([bad value $enable_big_digits for --enable-big-digits; value should be 15 or 30]) ;;
4072esac
4073AC_MSG_RESULT($enable_big_digits)
4074AC_DEFINE_UNQUOTED(PYLONG_BITS_IN_DIGIT, $enable_big_digits, [Define as the preferred size in bits of long digits])
4075],
4076[AC_MSG_RESULT(no value specified)])
4077
Guido van Rossumef2255b2000-03-10 22:30:29 +00004078# check for wchar.h
Martin v. Löwisc45929e2002-04-06 10:10:49 +00004079AC_CHECK_HEADER(wchar.h, [
4080 AC_DEFINE(HAVE_WCHAR_H, 1,
4081 [Define if the compiler provides a wchar.h header file.])
4082 wchar_h="yes"
4083],
Guido van Rossumef2255b2000-03-10 22:30:29 +00004084wchar_h="no"
4085)
4086
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00004087# determine wchar_t size
4088if test "$wchar_h" = yes
4089then
Guido van Rossum67b26592001-10-20 14:21:45 +00004090 AC_CHECK_SIZEOF(wchar_t, 4, [#include <wchar.h>])
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00004091fi
4092
Martin v. Löwisfa3bdea2003-09-04 18:50:54 +00004093AC_MSG_CHECKING(for UCS-4 tcl)
4094have_ucs4_tcl=no
Matthias Klosec511b472010-05-08 11:01:39 +00004095AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwisfa3bdea2003-09-04 18:50:54 +00004096#include <tcl.h>
4097#if TCL_UTF_MAX != 6
4098# error "NOT UCS4_TCL"
Matthias Klosec511b472010-05-08 11:01:39 +00004099#endif]], [[]])],[
Martin v. Löwisfa3bdea2003-09-04 18:50:54 +00004100 AC_DEFINE(HAVE_UCS4_TCL, 1, [Define this if you have tcl and TCL_UTF_MAX==6])
4101 have_ucs4_tcl=yes
Matthias Klosec511b472010-05-08 11:01:39 +00004102],[])
Martin v. Löwisfa3bdea2003-09-04 18:50:54 +00004103AC_MSG_RESULT($have_ucs4_tcl)
4104
Marc-André Lemburgd7160f82003-09-22 11:14:40 +00004105# check whether wchar_t is signed or not
4106if test "$wchar_h" = yes
4107then
4108 # check whether wchar_t is signed or not
4109 AC_MSG_CHECKING(whether wchar_t is signed)
4110 AC_CACHE_VAL(ac_cv_wchar_t_signed, [
Matthias Klosec511b472010-05-08 11:01:39 +00004111 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Marc-André Lemburgd7160f82003-09-22 11:14:40 +00004112 #include <wchar.h>
4113 int main()
4114 {
Martin v. Löwis44fe0e42006-04-11 07:15:30 +00004115 /* Success: exit code 0 */
4116 exit((((wchar_t) -1) < ((wchar_t) 0)) ? 0 : 1);
Marc-André Lemburgd7160f82003-09-22 11:14:40 +00004117 }
Matthias Klosec511b472010-05-08 11:01:39 +00004118 ]])],
4119 [ac_cv_wchar_t_signed=yes],
4120 [ac_cv_wchar_t_signed=no],
4121 [ac_cv_wchar_t_signed=yes])])
Marc-André Lemburgd7160f82003-09-22 11:14:40 +00004122 AC_MSG_RESULT($ac_cv_wchar_t_signed)
4123fi
4124
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00004125AC_MSG_CHECKING(what type to use for unicode)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00004126dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00004127AC_ARG_ENABLE(unicode,
Benjamin Peterson66556b02010-05-25 02:23:32 +00004128 AS_HELP_STRING([--enable-unicode@<:@=ucs@<:@24@:>@@:>@], [Enable Unicode strings (default is ucs2)]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00004129 [],
4130 [enable_unicode=yes])
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00004131
4132if test $enable_unicode = yes
4133then
Martin v. Löwisfd917792001-06-27 20:22:04 +00004134 # Without any arguments, Py_UNICODE defaults to two-byte mode
Martin v. Löwisfa3bdea2003-09-04 18:50:54 +00004135 case "$have_ucs4_tcl" in
4136 yes) enable_unicode="ucs4"
4137 ;;
4138 *) enable_unicode="ucs2"
4139 ;;
4140 esac
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00004141fi
4142
Martin v. Löwis0036cba2002-04-12 09:58:45 +00004143AH_TEMPLATE(Py_UNICODE_SIZE,
4144 [Define as the size of the unicode type.])
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00004145case "$enable_unicode" in
4146ucs2) unicode_size="2"
4147 AC_DEFINE(Py_UNICODE_SIZE,2)
4148 ;;
4149ucs4) unicode_size="4"
4150 AC_DEFINE(Py_UNICODE_SIZE,4)
4151 ;;
Martin v. Löwised11a5d2012-05-20 10:42:17 +02004152no) ;; # To allow --disable-unicode
Ezio Melotti5820efb2010-02-27 00:05:42 +00004153*) AC_MSG_ERROR([invalid value for --enable-unicode. Use either ucs2 or ucs4 (lowercase).]) ;;
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00004154esac
4155
Martin v. Löwis11437992002-04-12 09:54:03 +00004156AH_TEMPLATE(PY_UNICODE_TYPE,
4157 [Define as the integral type used for Unicode representation.])
Martin v. Löwis0036cba2002-04-12 09:58:45 +00004158
Martin v. Löwis339d0f72001-08-17 18:39:25 +00004159AC_SUBST(UNICODE_OBJS)
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00004160if test "$enable_unicode" = "no"
4161then
Martin v. Löwis339d0f72001-08-17 18:39:25 +00004162 UNICODE_OBJS=""
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00004163 AC_MSG_RESULT(not used)
4164else
Martin v. Löwis339d0f72001-08-17 18:39:25 +00004165 UNICODE_OBJS="Objects/unicodeobject.o Objects/unicodectype.o"
Martin v. Löwisc45929e2002-04-06 10:10:49 +00004166 AC_DEFINE(Py_USING_UNICODE, 1,
4167 [Define if you want to have a Unicode type.])
Marc-André Lemburgd7160f82003-09-22 11:14:40 +00004168
4169 # wchar_t is only usable if it maps to an unsigned type
4170 if test "$unicode_size" = "$ac_cv_sizeof_wchar_t" \
Matthias Klose7dbeed72004-12-24 08:22:17 +00004171 -a "$ac_cv_wchar_t_signed" = "no"
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00004172 then
4173 PY_UNICODE_TYPE="wchar_t"
Martin v. Löwisc45929e2002-04-06 10:10:49 +00004174 AC_DEFINE(HAVE_USABLE_WCHAR_T, 1,
4175 [Define if you have a useable wchar_t type defined in wchar.h; useable
Marc-André Lemburgd7160f82003-09-22 11:14:40 +00004176 means wchar_t must be an unsigned type with at least 16 bits. (see
Martin v. Löwisc45929e2002-04-06 10:10:49 +00004177 Include/unicodeobject.h).])
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00004178 AC_DEFINE(PY_UNICODE_TYPE,wchar_t)
4179 elif test "$ac_cv_sizeof_short" = "$unicode_size"
4180 then
4181 PY_UNICODE_TYPE="unsigned short"
4182 AC_DEFINE(PY_UNICODE_TYPE,unsigned short)
4183 elif test "$ac_cv_sizeof_long" = "$unicode_size"
4184 then
4185 PY_UNICODE_TYPE="unsigned long"
4186 AC_DEFINE(PY_UNICODE_TYPE,unsigned long)
4187 else
4188 PY_UNICODE_TYPE="no type found"
4189 fi
4190 AC_MSG_RESULT($PY_UNICODE_TYPE)
4191fi
Guido van Rossumef2255b2000-03-10 22:30:29 +00004192
4193# check for endianness
4194AC_C_BIGENDIAN
4195
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00004196# Check whether right shifting a negative integer extends the sign bit
4197# or fills with zeros (like the Cray J90, according to Tim Peters).
4198AC_MSG_CHECKING(whether right shift extends the sign bit)
Vladimir Marangozova6180282000-07-12 05:05:06 +00004199AC_CACHE_VAL(ac_cv_rshift_extends_sign, [
Matthias Klosec511b472010-05-08 11:01:39 +00004200AC_RUN_IFELSE([AC_LANG_SOURCE([[
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00004201int main()
4202{
Vladimir Marangozova6180282000-07-12 05:05:06 +00004203 exit(((-1)>>3 == -1) ? 0 : 1);
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00004204}
Matthias Klosec511b472010-05-08 11:01:39 +00004205]])],
4206[ac_cv_rshift_extends_sign=yes],
4207[ac_cv_rshift_extends_sign=no],
4208[ac_cv_rshift_extends_sign=yes])])
Vladimir Marangozova6180282000-07-12 05:05:06 +00004209AC_MSG_RESULT($ac_cv_rshift_extends_sign)
4210if test "$ac_cv_rshift_extends_sign" = no
4211then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00004212 AC_DEFINE(SIGNED_RIGHT_SHIFT_ZERO_FILLS, 1,
4213 [Define if i>>j for signed int i does not extend the sign bit
4214 when i < 0])
Vladimir Marangozova6180282000-07-12 05:05:06 +00004215fi
4216
Guido van Rossumcadfaec2001-01-05 14:45:49 +00004217# check for getc_unlocked and related locking functions
4218AC_MSG_CHECKING(for getc_unlocked() and friends)
4219AC_CACHE_VAL(ac_cv_have_getc_unlocked, [
Matthias Klosec511b472010-05-08 11:01:39 +00004220AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <stdio.h>]], [[
Guido van Rossumcadfaec2001-01-05 14:45:49 +00004221 FILE *f = fopen("/dev/null", "r");
4222 flockfile(f);
4223 getc_unlocked(f);
4224 funlockfile(f);
Matthias Klosec511b472010-05-08 11:01:39 +00004225]])],[ac_cv_have_getc_unlocked=yes],[ac_cv_have_getc_unlocked=no])])
Guido van Rossumcadfaec2001-01-05 14:45:49 +00004226AC_MSG_RESULT($ac_cv_have_getc_unlocked)
4227if test "$ac_cv_have_getc_unlocked" = yes
4228then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00004229 AC_DEFINE(HAVE_GETC_UNLOCKED, 1,
4230 [Define this if you have flockfile(), getc_unlocked(), and funlockfile()])
Guido van Rossumcadfaec2001-01-05 14:45:49 +00004231fi
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00004232
Neal Norwitzfe8e3d92006-01-07 21:07:20 +00004233# check where readline lives
Martin v. Löwis82bca632006-02-10 20:49:30 +00004234# save the value of LIBS so we don't actually link Python with readline
4235LIBS_no_readline=$LIBS
Gregory P. Smith980b99b2008-09-07 05:15:18 +00004236
4237# On some systems we need to link readline to a termcap compatible
4238# library. NOTE: Keep the precedence of listed libraries synchronised
4239# with setup.py.
4240py_cv_lib_readline=no
4241AC_MSG_CHECKING([how to link readline libs])
4242for py_libtermcap in "" ncursesw ncurses curses termcap; do
4243 if test -z "$py_libtermcap"; then
4244 READLINE_LIBS="-lreadline"
4245 else
4246 READLINE_LIBS="-lreadline -l$py_libtermcap"
4247 fi
4248 LIBS="$READLINE_LIBS $LIBS_no_readline"
4249 AC_LINK_IFELSE(
4250 [AC_LANG_CALL([],[readline])],
4251 [py_cv_lib_readline=yes])
4252 if test $py_cv_lib_readline = yes; then
4253 break
4254 fi
4255done
4256# Uncomment this line if you want to use READINE_LIBS in Makefile or scripts
4257#AC_SUBST([READLINE_LIBS])
Gregory P. Smith29ec7502008-09-07 19:18:16 +00004258if test $py_cv_lib_readline = no; then
Gregory P. Smith980b99b2008-09-07 05:15:18 +00004259 AC_MSG_RESULT([none])
4260else
4261 AC_MSG_RESULT([$READLINE_LIBS])
4262 AC_DEFINE(HAVE_LIBREADLINE, 1,
4263 [Define if you have the readline library (-lreadline).])
Neal Norwitzfe8e3d92006-01-07 21:07:20 +00004264fi
4265
Michael W. Hudson30ea2f22004-07-07 17:44:12 +00004266# check for readline 2.1
4267AC_CHECK_LIB(readline, rl_callback_handler_install,
4268 AC_DEFINE(HAVE_RL_CALLBACK, 1,
Gregory P. Smithff7b2d52008-09-03 05:57:48 +00004269 [Define if you have readline 2.1]), ,$READLINE_LIBS)
Michael W. Hudson30ea2f22004-07-07 17:44:12 +00004270
Guido van Rossumfaf5e4d2002-12-30 16:25:41 +00004271# check for readline 2.2
Matthias Klosec511b472010-05-08 11:01:39 +00004272AC_PREPROC_IFELSE([AC_LANG_SOURCE([[#include <readline/readline.h>]])],
4273 [have_readline=yes],
4274 [have_readline=no]
4275)
Guido van Rossumfaf5e4d2002-12-30 16:25:41 +00004276if test $have_readline = yes
4277then
4278 AC_EGREP_HEADER([extern int rl_completion_append_character;],
4279 [readline/readline.h],
4280 AC_DEFINE(HAVE_RL_COMPLETION_APPEND_CHARACTER, 1,
4281 [Define if you have readline 2.2]), )
Antoine Pitroud9ff74e2009-10-26 19:16:46 +00004282 AC_EGREP_HEADER([extern int rl_completion_suppress_append;],
4283 [readline/readline.h],
4284 AC_DEFINE(HAVE_RL_COMPLETION_SUPPRESS_APPEND, 1,
4285 [Define if you have rl_completion_suppress_append]), )
Guido van Rossumfaf5e4d2002-12-30 16:25:41 +00004286fi
4287
Martin v. Löwis0daad592001-09-30 21:09:59 +00004288# check for readline 4.0
4289AC_CHECK_LIB(readline, rl_pre_input_hook,
Martin v. Löwisc45929e2002-04-06 10:10:49 +00004290 AC_DEFINE(HAVE_RL_PRE_INPUT_HOOK, 1,
Gregory P. Smithff7b2d52008-09-03 05:57:48 +00004291 [Define if you have readline 4.0]), ,$READLINE_LIBS)
Martin v. Löwis0daad592001-09-30 21:09:59 +00004292
Martin v. Löwis58bd49f2007-09-04 13:13:14 +00004293# also in 4.0
4294AC_CHECK_LIB(readline, rl_completion_display_matches_hook,
4295 AC_DEFINE(HAVE_RL_COMPLETION_DISPLAY_MATCHES_HOOK, 1,
Gregory P. Smithff7b2d52008-09-03 05:57:48 +00004296 [Define if you have readline 4.0]), ,$READLINE_LIBS)
Martin v. Löwis58bd49f2007-09-04 13:13:14 +00004297
Martin Pantera70c3232016-04-03 02:54:58 +00004298# also in 4.0, but not in editline
4299AC_CHECK_LIB(readline, rl_resize_terminal,
4300 AC_DEFINE(HAVE_RL_RESIZE_TERMINAL, 1,
4301 [Define if you have readline 4.0]), ,$READLINE_LIBS)
4302
Guido van Rossum353ae582001-07-10 16:45:32 +00004303# check for readline 4.2
4304AC_CHECK_LIB(readline, rl_completion_matches,
Martin v. Löwisc45929e2002-04-06 10:10:49 +00004305 AC_DEFINE(HAVE_RL_COMPLETION_MATCHES, 1,
Gregory P. Smithff7b2d52008-09-03 05:57:48 +00004306 [Define if you have readline 4.2]), ,$READLINE_LIBS)
Guido van Rossum353ae582001-07-10 16:45:32 +00004307
Michael W. Hudson30ea2f22004-07-07 17:44:12 +00004308# also in readline 4.2
Matthias Klosec511b472010-05-08 11:01:39 +00004309AC_PREPROC_IFELSE([AC_LANG_SOURCE([[#include <readline/readline.h>]])],
4310 [have_readline=yes],
4311 [have_readline=no]
4312)
Michael W. Hudson30ea2f22004-07-07 17:44:12 +00004313if test $have_readline = yes
4314then
4315 AC_EGREP_HEADER([extern int rl_catch_signals;],
4316 [readline/readline.h],
4317 AC_DEFINE(HAVE_RL_CATCH_SIGNAL, 1,
4318 [Define if you can turn off readline's signal handling.]), )
4319fi
4320
Martin v. Löwis82bca632006-02-10 20:49:30 +00004321# End of readline checks: restore LIBS
4322LIBS=$LIBS_no_readline
4323
Thomas Wouterse38b2f12001-07-11 22:35:31 +00004324AC_MSG_CHECKING(for broken nice())
4325AC_CACHE_VAL(ac_cv_broken_nice, [
Matthias Klosec511b472010-05-08 11:01:39 +00004326AC_RUN_IFELSE([AC_LANG_SOURCE([[
Thomas Wouterse38b2f12001-07-11 22:35:31 +00004327int main()
4328{
4329 int val1 = nice(1);
4330 if (val1 != -1 && val1 == nice(2))
4331 exit(0);
4332 exit(1);
4333}
Matthias Klosec511b472010-05-08 11:01:39 +00004334]])],
4335[ac_cv_broken_nice=yes],
4336[ac_cv_broken_nice=no],
4337[ac_cv_broken_nice=no])])
Thomas Wouterse38b2f12001-07-11 22:35:31 +00004338AC_MSG_RESULT($ac_cv_broken_nice)
4339if test "$ac_cv_broken_nice" = yes
4340then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00004341 AC_DEFINE(HAVE_BROKEN_NICE, 1,
4342 [Define if nice() returns success/failure instead of the new priority.])
Thomas Wouterse38b2f12001-07-11 22:35:31 +00004343fi
4344
Nicholas Bastine62c5c82004-03-21 23:45:42 +00004345AC_MSG_CHECKING(for broken poll())
Alexandre Vassalotti00900892009-07-17 05:26:39 +00004346AC_CACHE_VAL(ac_cv_broken_poll,
Matthias Klosec511b472010-05-08 11:01:39 +00004347AC_RUN_IFELSE([AC_LANG_SOURCE([[
Nicholas Bastine62c5c82004-03-21 23:45:42 +00004348#include <poll.h>
4349
Alexandre Vassalotti66da2632009-07-17 06:17:33 +00004350int main()
4351{
Nicholas Bastine62c5c82004-03-21 23:45:42 +00004352 struct pollfd poll_struct = { 42, POLLIN|POLLPRI|POLLOUT, 0 };
Alexandre Vassalotti66da2632009-07-17 06:17:33 +00004353 int poll_test;
4354
Nicholas Bastine62c5c82004-03-21 23:45:42 +00004355 close (42);
4356
Alexandre Vassalotti66da2632009-07-17 06:17:33 +00004357 poll_test = poll(&poll_struct, 1, 0);
Nicholas Bastine62c5c82004-03-21 23:45:42 +00004358 if (poll_test < 0)
Alexandre Vassalotti66da2632009-07-17 06:17:33 +00004359 return 0;
Nicholas Bastine62c5c82004-03-21 23:45:42 +00004360 else if (poll_test == 0 && poll_struct.revents != POLLNVAL)
Alexandre Vassalotti66da2632009-07-17 06:17:33 +00004361 return 0;
Nicholas Bastine62c5c82004-03-21 23:45:42 +00004362 else
Alexandre Vassalotti66da2632009-07-17 06:17:33 +00004363 return 1;
4364}
Matthias Klosec511b472010-05-08 11:01:39 +00004365]])],
4366[ac_cv_broken_poll=yes],
4367[ac_cv_broken_poll=no],
4368[ac_cv_broken_poll=no]))
Nicholas Bastine62c5c82004-03-21 23:45:42 +00004369AC_MSG_RESULT($ac_cv_broken_poll)
4370if test "$ac_cv_broken_poll" = yes
4371then
4372 AC_DEFINE(HAVE_BROKEN_POLL, 1,
4373 [Define if poll() sets errno on invalid file descriptors.])
4374fi
4375
Brett Cannon43802422005-02-10 20:48:03 +00004376# Before we can test tzset, we need to check if struct tm has a tm_zone
4377# (which is not required by ISO C or UNIX spec) and/or if we support
4378# tzname[]
4379AC_STRUCT_TIMEZONE
Nicholas Bastine62c5c82004-03-21 23:45:42 +00004380
Brett Cannon43802422005-02-10 20:48:03 +00004381# check tzset(3) exists and works like we expect it to
Guido van Rossumd11b62e2003-03-14 21:51:36 +00004382AC_MSG_CHECKING(for working tzset())
4383AC_CACHE_VAL(ac_cv_working_tzset, [
Matthias Klosec511b472010-05-08 11:01:39 +00004384AC_RUN_IFELSE([AC_LANG_SOURCE([[
Guido van Rossumd11b62e2003-03-14 21:51:36 +00004385#include <stdlib.h>
4386#include <time.h>
Brett Cannon18367812003-09-19 00:59:16 +00004387#include <string.h>
Brett Cannon43802422005-02-10 20:48:03 +00004388
4389#if HAVE_TZNAME
4390extern char *tzname[];
4391#endif
4392
Guido van Rossumd11b62e2003-03-14 21:51:36 +00004393int main()
4394{
Brett Cannon18367812003-09-19 00:59:16 +00004395 /* Note that we need to ensure that not only does tzset(3)
4396 do 'something' with localtime, but it works as documented
4397 in the library reference and as expected by the test suite.
Brett Cannon43802422005-02-10 20:48:03 +00004398 This includes making sure that tzname is set properly if
4399 tm->tm_zone does not exist since it is the alternative way
4400 of getting timezone info.
Brett Cannon18367812003-09-19 00:59:16 +00004401
4402 Red Hat 6.2 doesn't understand the southern hemisphere
Brett Cannon43802422005-02-10 20:48:03 +00004403 after New Year's Day.
Brett Cannon18367812003-09-19 00:59:16 +00004404 */
4405
Brett Cannon43802422005-02-10 20:48:03 +00004406 time_t groundhogday = 1044144000; /* GMT-based */
Brett Cannon18367812003-09-19 00:59:16 +00004407 time_t midyear = groundhogday + (365 * 24 * 3600 / 2);
4408
Neal Norwitz7f2588c2003-04-11 15:35:53 +00004409 putenv("TZ=UTC+0");
Guido van Rossumd11b62e2003-03-14 21:51:36 +00004410 tzset();
Brett Cannon18367812003-09-19 00:59:16 +00004411 if (localtime(&groundhogday)->tm_hour != 0)
4412 exit(1);
Brett Cannon43802422005-02-10 20:48:03 +00004413#if HAVE_TZNAME
4414 /* For UTC, tzname[1] is sometimes "", sometimes " " */
4415 if (strcmp(tzname[0], "UTC") ||
4416 (tzname[1][0] != 0 && tzname[1][0] != ' '))
4417 exit(1);
4418#endif
Brett Cannon18367812003-09-19 00:59:16 +00004419
Neal Norwitz7f2588c2003-04-11 15:35:53 +00004420 putenv("TZ=EST+5EDT,M4.1.0,M10.5.0");
Guido van Rossumd11b62e2003-03-14 21:51:36 +00004421 tzset();
Brett Cannon18367812003-09-19 00:59:16 +00004422 if (localtime(&groundhogday)->tm_hour != 19)
Guido van Rossumd11b62e2003-03-14 21:51:36 +00004423 exit(1);
Brett Cannon43802422005-02-10 20:48:03 +00004424#if HAVE_TZNAME
4425 if (strcmp(tzname[0], "EST") || strcmp(tzname[1], "EDT"))
4426 exit(1);
4427#endif
Brett Cannon18367812003-09-19 00:59:16 +00004428
4429 putenv("TZ=AEST-10AEDT-11,M10.5.0,M3.5.0");
4430 tzset();
4431 if (localtime(&groundhogday)->tm_hour != 11)
4432 exit(1);
Brett Cannon43802422005-02-10 20:48:03 +00004433#if HAVE_TZNAME
4434 if (strcmp(tzname[0], "AEST") || strcmp(tzname[1], "AEDT"))
4435 exit(1);
4436#endif
4437
4438#if HAVE_STRUCT_TM_TM_ZONE
Brett Cannon18367812003-09-19 00:59:16 +00004439 if (strcmp(localtime(&groundhogday)->tm_zone, "AEDT"))
4440 exit(1);
4441 if (strcmp(localtime(&midyear)->tm_zone, "AEST"))
4442 exit(1);
Brett Cannon43802422005-02-10 20:48:03 +00004443#endif
Brett Cannon18367812003-09-19 00:59:16 +00004444
Guido van Rossumd11b62e2003-03-14 21:51:36 +00004445 exit(0);
4446}
Matthias Klosec511b472010-05-08 11:01:39 +00004447]])],
4448[ac_cv_working_tzset=yes],
4449[ac_cv_working_tzset=no],
4450[ac_cv_working_tzset=no])])
Guido van Rossumd11b62e2003-03-14 21:51:36 +00004451AC_MSG_RESULT($ac_cv_working_tzset)
4452if test "$ac_cv_working_tzset" = yes
4453then
4454 AC_DEFINE(HAVE_WORKING_TZSET, 1,
4455 [Define if tzset() actually switches the local timezone in a meaningful way.])
4456fi
4457
Martin v. Löwis94717ed2002-09-09 14:24:16 +00004458# Look for subsecond timestamps in struct stat
4459AC_MSG_CHECKING(for tv_nsec in struct stat)
4460AC_CACHE_VAL(ac_cv_stat_tv_nsec,
Matthias Klosec511b472010-05-08 11:01:39 +00004461AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/stat.h>]], [[
Martin v. Löwis94717ed2002-09-09 14:24:16 +00004462struct stat st;
4463st.st_mtim.tv_nsec = 1;
Matthias Klosec511b472010-05-08 11:01:39 +00004464]])],
4465[ac_cv_stat_tv_nsec=yes],
4466[ac_cv_stat_tv_nsec=no]))
Martin v. Löwis94717ed2002-09-09 14:24:16 +00004467AC_MSG_RESULT($ac_cv_stat_tv_nsec)
4468if test "$ac_cv_stat_tv_nsec" = yes
4469then
4470 AC_DEFINE(HAVE_STAT_TV_NSEC, 1,
4471 [Define if you have struct stat.st_mtim.tv_nsec])
4472fi
4473
Martin v. Löwisebd9d5b2005-08-09 15:00:59 +00004474# Look for BSD style subsecond timestamps in struct stat
4475AC_MSG_CHECKING(for tv_nsec2 in struct stat)
4476AC_CACHE_VAL(ac_cv_stat_tv_nsec2,
Matthias Klosec511b472010-05-08 11:01:39 +00004477AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/stat.h>]], [[
Martin v. Löwisebd9d5b2005-08-09 15:00:59 +00004478struct stat st;
4479st.st_mtimespec.tv_nsec = 1;
Matthias Klosec511b472010-05-08 11:01:39 +00004480]])],
4481[ac_cv_stat_tv_nsec2=yes],
4482[ac_cv_stat_tv_nsec2=no]))
Martin v. Löwisebd9d5b2005-08-09 15:00:59 +00004483AC_MSG_RESULT($ac_cv_stat_tv_nsec2)
4484if test "$ac_cv_stat_tv_nsec2" = yes
4485then
4486 AC_DEFINE(HAVE_STAT_TV_NSEC2, 1,
4487 [Define if you have struct stat.st_mtimensec])
4488fi
4489
doko@ubuntu.comf27ec3e2014-04-17 20:11:19 +02004490# first curses configure check
4491ac_save_cppflags="$CPPFLAGS"
4492CPPFLAGS="$CPPFLAGS -I/usr/include/ncursesw"
4493
4494AC_CHECK_HEADERS(curses.h ncurses.h)
4495
4496# On Solaris, term.h requires curses.h
4497AC_CHECK_HEADERS(term.h,,,[
4498#ifdef HAVE_CURSES_H
4499#include <curses.h>
4500#endif
4501])
4502
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00004503# On HP/UX 11.0, mvwdelch is a block with a return statement
4504AC_MSG_CHECKING(whether mvwdelch is an expression)
4505AC_CACHE_VAL(ac_cv_mvwdelch_is_expression,
Matthias Klosec511b472010-05-08 11:01:39 +00004506AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <curses.h>]], [[
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00004507 int rtn;
4508 rtn = mvwdelch(0,0,0);
Matthias Klosec511b472010-05-08 11:01:39 +00004509]])],
4510[ac_cv_mvwdelch_is_expression=yes],
4511[ac_cv_mvwdelch_is_expression=no]))
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00004512AC_MSG_RESULT($ac_cv_mvwdelch_is_expression)
4513
4514if test "$ac_cv_mvwdelch_is_expression" = yes
4515then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00004516 AC_DEFINE(MVWDELCH_IS_EXPRESSION, 1,
4517 [Define if mvwdelch in curses.h is an expression.])
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00004518fi
4519
4520AC_MSG_CHECKING(whether WINDOW has _flags)
4521AC_CACHE_VAL(ac_cv_window_has_flags,
Matthias Klosec511b472010-05-08 11:01:39 +00004522AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <curses.h>]], [[
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00004523 WINDOW *w;
4524 w->_flags = 0;
Matthias Klosec511b472010-05-08 11:01:39 +00004525]])],
4526[ac_cv_window_has_flags=yes],
4527[ac_cv_window_has_flags=no]))
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00004528AC_MSG_RESULT($ac_cv_window_has_flags)
4529
4530
4531if test "$ac_cv_window_has_flags" = yes
4532then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00004533 AC_DEFINE(WINDOW_HAS_FLAGS, 1,
4534 [Define if WINDOW in curses.h offers a field _flags.])
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00004535fi
4536
Walter Dörwald4994d952006-06-19 08:07:50 +00004537AC_MSG_CHECKING(for is_term_resized)
Matthias Klosec511b472010-05-08 11:01:39 +00004538AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <curses.h>]], [[void *x=is_term_resized]])],
4539 [AC_DEFINE(HAVE_CURSES_IS_TERM_RESIZED, 1, Define if you have the 'is_term_resized' function.)
4540 AC_MSG_RESULT(yes)],
4541 [AC_MSG_RESULT(no)]
Walter Dörwald4994d952006-06-19 08:07:50 +00004542)
4543
Walter Dörwald05fdbf12006-06-19 08:14:09 +00004544AC_MSG_CHECKING(for resize_term)
Matthias Klosec511b472010-05-08 11:01:39 +00004545AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <curses.h>]], [[void *x=resize_term]])],
4546 [AC_DEFINE(HAVE_CURSES_RESIZE_TERM, 1, Define if you have the 'resize_term' function.)
4547 AC_MSG_RESULT(yes)],
4548 [AC_MSG_RESULT(no)]
Walter Dörwald4994d952006-06-19 08:07:50 +00004549)
4550
Walter Dörwald05fdbf12006-06-19 08:14:09 +00004551AC_MSG_CHECKING(for resizeterm)
Matthias Klosec511b472010-05-08 11:01:39 +00004552AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <curses.h>]], [[void *x=resizeterm]])],
4553 [AC_DEFINE(HAVE_CURSES_RESIZETERM, 1, Define if you have the 'resizeterm' function.)
4554 AC_MSG_RESULT(yes)],
4555 [AC_MSG_RESULT(no)]
Walter Dörwald4994d952006-06-19 08:07:50 +00004556)
doko@ubuntu.comf27ec3e2014-04-17 20:11:19 +02004557# last curses configure check
4558CPPFLAGS=$ac_save_cppflags
Walter Dörwald4994d952006-06-19 08:07:50 +00004559
doko@python.orgd65e2ba2013-01-31 23:52:03 +01004560AC_MSG_NOTICE([checking for device files])
Martin v. Löwisfefbc202006-10-17 18:59:23 +00004561
doko@python.orgd65e2ba2013-01-31 23:52:03 +01004562dnl NOTE: Inform user how to proceed with files when cross compiling.
4563if test "x$cross_compiling" = xyes; then
4564 if test "${ac_cv_file__dev_ptmx+set}" != set; then
4565 AC_MSG_CHECKING([for /dev/ptmx])
4566 AC_MSG_RESULT([not set])
4567 AC_MSG_ERROR([set ac_cv_file__dev_ptmx to yes/no in your CONFIG_SITE file when cross compiling])
4568 fi
4569 if test "${ac_cv_file__dev_ptc+set}" != set; then
4570 AC_MSG_CHECKING([for /dev/ptc])
4571 AC_MSG_RESULT([not set])
4572 AC_MSG_ERROR([set ac_cv_file__dev_ptc to yes/no in your CONFIG_SITE file when cross compiling])
4573 fi
Martin v. Löwisfefbc202006-10-17 18:59:23 +00004574fi
4575
doko@python.orgd65e2ba2013-01-31 23:52:03 +01004576AC_CHECK_FILE(/dev/ptmx, [], [])
4577if test "x$ac_cv_file__dev_ptmx" = xyes; then
4578 AC_DEFINE(HAVE_DEV_PTMX, 1,
4579 [Define to 1 if you have the /dev/ptmx device file.])
4580fi
4581AC_CHECK_FILE(/dev/ptc, [], [])
4582if test "x$ac_cv_file__dev_ptc" = xyes; then
Martin v. Löwisfefbc202006-10-17 18:59:23 +00004583 AC_DEFINE(HAVE_DEV_PTC, 1,
doko@python.orgd65e2ba2013-01-31 23:52:03 +01004584 [Define to 1 if you have the /dev/ptc device file.])
Martin v. Löwisfefbc202006-10-17 18:59:23 +00004585fi
Neal Norwitz865400f2003-03-21 01:42:58 +00004586
Mark Dickinson82864d12009-11-15 16:18:58 +00004587if test "$have_long_long" = yes
4588then
4589 AC_MSG_CHECKING(for %lld and %llu printf() format support)
4590 AC_CACHE_VAL(ac_cv_have_long_long_format,
Matthias Klosec511b472010-05-08 11:01:39 +00004591 AC_RUN_IFELSE([AC_LANG_SOURCE([[[
Mark Dickinson82864d12009-11-15 16:18:58 +00004592 #include <stdio.h>
4593 #include <stddef.h>
4594 #include <string.h>
4595
4596 #ifdef HAVE_SYS_TYPES_H
4597 #include <sys/types.h>
4598 #endif
4599
4600 int main()
4601 {
4602 char buffer[256];
4603
4604 if (sprintf(buffer, "%lld", (long long)123) < 0)
4605 return 1;
4606 if (strcmp(buffer, "123"))
4607 return 1;
4608
4609 if (sprintf(buffer, "%lld", (long long)-123) < 0)
4610 return 1;
4611 if (strcmp(buffer, "-123"))
4612 return 1;
4613
4614 if (sprintf(buffer, "%llu", (unsigned long long)123) < 0)
4615 return 1;
4616 if (strcmp(buffer, "123"))
4617 return 1;
4618
4619 return 0;
4620 }
Matthias Klosec511b472010-05-08 11:01:39 +00004621 ]]])],
4622 [ac_cv_have_long_long_format=yes],
4623 [ac_cv_have_long_long_format=no],
doko@python.orgd65e2ba2013-01-31 23:52:03 +01004624 [ac_cv_have_long_long_format="cross -- assuming no"
4625 if test x$GCC = xyes; then
4626 save_CFLAGS=$CFLAGS
4627 CFLAGS="$CFLAGS -Werror -Wformat"
4628 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4629 #include <stdio.h>
4630 #include <stddef.h>
4631 ]], [[
4632 char *buffer;
4633 sprintf(buffer, "%lld", (long long)123);
4634 sprintf(buffer, "%lld", (long long)-123);
4635 sprintf(buffer, "%llu", (unsigned long long)123);
4636 ]])],
4637 ac_cv_have_long_long_format=yes
4638 )
4639 CFLAGS=$save_CFLAGS
4640 fi])
Mark Dickinson82864d12009-11-15 16:18:58 +00004641 )
4642 AC_MSG_RESULT($ac_cv_have_long_long_format)
4643fi
4644
Mark Dickinson5ce84742009-12-31 20:48:04 +00004645if test "$ac_cv_have_long_long_format" = yes
Mark Dickinson82864d12009-11-15 16:18:58 +00004646then
4647 AC_DEFINE(PY_FORMAT_LONG_LONG, "ll",
4648 [Define to printf format modifier for long long type])
4649fi
4650
Ronald Oussoren315cd0c2009-11-19 16:25:21 +00004651if test $ac_sys_system = Darwin
4652then
4653 LIBS="$LIBS -framework CoreFoundation"
4654fi
4655
Mark Dickinson82864d12009-11-15 16:18:58 +00004656
Gregory P. Smithd8cb2d92009-11-02 02:02:38 +00004657AC_CACHE_CHECK([for %zd printf() format support], ac_cv_have_size_t_format, [dnl
Matthias Klosec511b472010-05-08 11:01:39 +00004658AC_RUN_IFELSE([AC_LANG_SOURCE([[
Alexandre Vassalottie7cf1182009-07-17 06:33:51 +00004659#include <stdio.h>
Brett Cannon09d12362006-05-11 05:11:33 +00004660#include <stddef.h>
4661#include <string.h>
4662
Christian Heimesdb3d6cb2007-12-16 21:39:43 +00004663#ifdef HAVE_SYS_TYPES_H
4664#include <sys/types.h>
4665#endif
Neal Norwitz4a8fbdb2006-09-22 08:16:26 +00004666
4667#ifdef HAVE_SSIZE_T
4668typedef ssize_t Py_ssize_t;
4669#elif SIZEOF_VOID_P == SIZEOF_LONG
4670typedef long Py_ssize_t;
4671#else
4672typedef int Py_ssize_t;
4673#endif
Brett Cannon09d12362006-05-11 05:11:33 +00004674
Christian Heimesdb3d6cb2007-12-16 21:39:43 +00004675int main()
4676{
4677 char buffer[256];
4678
Brett Cannon09d12362006-05-11 05:11:33 +00004679 if(sprintf(buffer, "%zd", (size_t)123) < 0)
4680 return 1;
4681
Neal Norwitz4a8fbdb2006-09-22 08:16:26 +00004682 if (strcmp(buffer, "123"))
Brett Cannon09d12362006-05-11 05:11:33 +00004683 return 1;
Neal Norwitz4a8fbdb2006-09-22 08:16:26 +00004684
4685 if (sprintf(buffer, "%zd", (Py_ssize_t)-123) < 0)
4686 return 1;
4687
4688 if (strcmp(buffer, "-123"))
4689 return 1;
4690
Brett Cannon09d12362006-05-11 05:11:33 +00004691 return 0;
Alexandre Vassalotti00900892009-07-17 05:26:39 +00004692}
Matthias Klosec511b472010-05-08 11:01:39 +00004693]])],
4694[ac_cv_have_size_t_format=yes],
4695[ac_cv_have_size_t_format=no],
4696[ac_cv_have_size_t_format="cross -- assuming yes"
4697])])
Gregory P. Smithd8cb2d92009-11-02 02:02:38 +00004698if test "$ac_cv_have_size_t_format" != no ; then
Alexandre Vassalotti00900892009-07-17 05:26:39 +00004699 AC_DEFINE(PY_FORMAT_SIZE_T, "z",
4700 [Define to printf format modifier for Py_ssize_t])
4701fi
Brett Cannon09d12362006-05-11 05:11:33 +00004702
Martin v. Löwis01c04012002-11-11 14:58:44 +00004703AC_CHECK_TYPE(socklen_t,,
4704 AC_DEFINE(socklen_t,int,
Matthias Klose5183ebd2010-04-24 16:38:36 +00004705 [Define to `int' if <sys/socket.h> does not define.]),[
Martin v. Löwis01c04012002-11-11 14:58:44 +00004706#ifdef HAVE_SYS_TYPES_H
4707#include <sys/types.h>
4708#endif
Guido van Rossum95713eb2000-05-18 20:53:31 +00004709#ifdef HAVE_SYS_SOCKET_H
4710#include <sys/socket.h>
4711#endif
Martin v. Löwis01c04012002-11-11 14:58:44 +00004712])
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00004713
R. David Murray1d9d16e2010-10-16 00:43:13 +00004714case $ac_sys_system in
4715AIX*)
4716 AC_DEFINE(HAVE_BROKEN_PIPE_BUF, 1, [Define if the system reports an invalid PIPE_BUF value.]) ;;
4717esac
4718
4719
Martin v. Löwis06f15bb2001-12-02 13:02:32 +00004720AC_SUBST(THREADHEADERS)
4721
4722for h in `(cd $srcdir;echo Python/thread_*.h)`
4723do
4724 THREADHEADERS="$THREADHEADERS \$(srcdir)/$h"
4725done
4726
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00004727AC_SUBST(SRCDIRS)
Victor Stinner5f4056a2017-04-28 03:41:40 +02004728SRCDIRS="Parser Objects Python Modules"
Andrew M. Kuchling8abedde2001-01-26 22:55:24 +00004729AC_MSG_CHECKING(for build directories)
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00004730for dir in $SRCDIRS; do
4731 if test ! -d $dir; then
4732 mkdir $dir
Fred Drake884d3ba2000-11-02 17:52:56 +00004733 fi
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00004734done
Benjamin Peterson2c992a02015-05-28 12:45:31 -05004735
4736# BEGIN_COMPUTED_GOTO
4737# Check for --with-computed-gotos
4738AC_MSG_CHECKING(for --with-computed-gotos)
4739AC_ARG_WITH(computed-gotos,
4740 AS_HELP_STRING([--with(out)-computed-gotos],
4741 [Use computed gotos in evaluation loop (enabled by default on supported compilers)]),
4742[
4743if test "$withval" = yes
4744then
4745 AC_DEFINE(USE_COMPUTED_GOTOS, 1,
4746 [Define if you want to use computed gotos in ceval.c.])
4747 AC_MSG_RESULT(yes)
4748fi
4749if test "$withval" = no
4750then
4751 AC_DEFINE(USE_COMPUTED_GOTOS, 0,
4752 [Define if you want to use computed gotos in ceval.c.])
4753 AC_MSG_RESULT(no)
4754fi
4755],
4756[AC_MSG_RESULT(no value specified)])
4757
4758AC_MSG_CHECKING(whether $CC supports computed gotos)
4759AC_CACHE_VAL(ac_cv_computed_gotos,
4760AC_RUN_IFELSE([AC_LANG_SOURCE([[[
4761int main(int argc, char **argv)
4762{
4763 static void *targets[1] = { &&LABEL1 };
4764 goto LABEL2;
4765LABEL1:
4766 return 0;
4767LABEL2:
4768 goto *targets[0];
4769 return 1;
4770}
4771]]])],
4772[ac_cv_computed_gotos=yes],
4773[ac_cv_computed_gotos=no],
4774[if test "${with_computed_gotos+set}" = set; then
4775 ac_cv_computed_gotos="$with_computed_gotos -- configured --with(out)-computed-gotos"
4776 else
4777 ac_cv_computed_gotos=no
4778 fi]))
4779AC_MSG_RESULT($ac_cv_computed_gotos)
4780case "$ac_cv_computed_gotos" in yes*)
4781 AC_DEFINE(HAVE_COMPUTED_GOTOS, 1,
4782 [Define if the C compiler supports computed gotos.])
4783esac
4784# END_COMPUTED_GOTO
4785
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00004786AC_MSG_RESULT(done)
Fred Drake036144d2000-10-26 17:09:35 +00004787
Ned Deily3f1d0b32014-11-20 02:11:03 -08004788# ensurepip option
4789AC_MSG_CHECKING(for ensurepip)
4790AC_ARG_WITH(ensurepip,
4791 [AS_HELP_STRING([--with(out)-ensurepip=@<:@=OPTION@:>@],
4792 ["install" or "upgrade" using bundled pip, default is "no"])],
4793 [],
4794 [with_ensurepip=no])
4795AS_CASE($with_ensurepip,
4796 [yes|upgrade],[ENSUREPIP=upgrade],
4797 [install],[ENSUREPIP=install],
4798 [no],[ENSUREPIP=no],
4799 [AC_MSG_ERROR([--with-ensurepip=upgrade|install|no])])
4800AC_MSG_RESULT($ENSUREPIP)
4801AC_SUBST(ENSUREPIP)
4802
Guido van Rossum627b2d71993-12-24 10:39:16 +00004803# generate output files
Antoine Pitrouf2caeed2009-05-24 20:23:57 +00004804AC_CONFIG_FILES(Makefile.pre Modules/Setup.config Misc/python.pc)
Antoine Pitrouaabdceb2010-09-10 20:03:17 +00004805AC_CONFIG_FILES([Modules/ld_so_aix], [chmod +x Modules/ld_so_aix])
Martin v. Löwis88afe662002-10-26 13:47:44 +00004806AC_OUTPUT
Neil Schemenauer61c51152001-01-26 16:18:16 +00004807
Martin v. Löwisf7afe952006-04-14 15:16:15 +00004808echo "creating Modules/Setup"
Neil Schemenauer61c51152001-01-26 16:18:16 +00004809if test ! -f Modules/Setup
4810then
4811 cp $srcdir/Modules/Setup.dist Modules/Setup
4812fi
4813
Martin v. Löwisf7afe952006-04-14 15:16:15 +00004814echo "creating Modules/Setup.local"
Neil Schemenauer61c51152001-01-26 16:18:16 +00004815if test ! -f Modules/Setup.local
4816then
4817 echo "# Edit this file for local setup changes" >Modules/Setup.local
4818fi
4819
4820echo "creating Makefile"
4821$SHELL $srcdir/Modules/makesetup -c $srcdir/Modules/config.c.in \
4822 -s Modules Modules/Setup.config \
Neil Schemenauerf8b71c52001-04-21 17:41:16 +00004823 Modules/Setup.local Modules/Setup
Skip Montanaro7221d932007-08-22 19:02:16 +00004824
4825case $ac_sys_system in
4826BeOS)
4827 AC_MSG_WARN([
4828
4829 Support for BeOS is deprecated as of Python 2.6.
4830 See PEP 11 for the gory details.
4831 ])
4832 ;;
4833*) ;;
4834esac
4835
Neil Schemenauer66252162001-02-19 04:47:42 +00004836mv config.c Modules
Gregory P. Smith6d8fdfc2016-09-07 23:28:23 -07004837
4838if test "$Py_OPT" = 'false' -a "$Py_DEBUG" != 'true'; then
4839 echo "" >&AS_MESSAGE_FD
4840 echo "" >&AS_MESSAGE_FD
4841 echo "If you want a release build with all optimizations active (LTO, PGO, etc),"
Gregory P. Smith ext:(%20%5BGoogle%20Inc.%5D)b9999152016-11-20 21:19:36 +00004842 echo "please run ./configure --enable-optimizations" >&AS_MESSAGE_FD
Gregory P. Smith6d8fdfc2016-09-07 23:28:23 -07004843 echo "" >&AS_MESSAGE_FD
4844 echo "" >&AS_MESSAGE_FD
4845fi