blob: 8a31cc87526341d20fd1d66ad0f61f7b2a748c86 [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 DEF_MAKE_ALL_RULE="profile-opt"
Gregory P. Smith794b2912016-09-08 00:07:40 -07001387 REQUIRE_PGO="yes"
Gregory P. Smith6d8fdfc2016-09-07 23:28:23 -07001388 DEF_MAKE_RULE="build_all"
1389else
1390 DEF_MAKE_ALL_RULE="build_all"
Gregory P. Smith794b2912016-09-08 00:07:40 -07001391 REQUIRE_PGO="no"
Gregory P. Smith6d8fdfc2016-09-07 23:28:23 -07001392 DEF_MAKE_RULE="all"
1393fi
1394
1395
Gregory P. Smith ext:(%20%5BGoogle%20Inc.%5D)c543a0f2016-06-02 23:44:40 +00001396# Enable LTO flags
1397AC_SUBST(LTOFLAGS)
1398AC_MSG_CHECKING(for --with-lto)
1399AC_ARG_WITH(lto, AS_HELP_STRING([--with-lto], [Enable Link Time Optimization in PGO builds. Disabled by default.]),
1400[
1401if test "$withval" != no
1402then
1403 Py_LTO='true'
1404 AC_MSG_RESULT(yes);
1405else
1406 Py_LTO='false'
1407 AC_MSG_RESULT(no);
1408fi],
1409[AC_MSG_RESULT(no)])
1410if test "$Py_LTO" = 'true' ; then
1411 case $CC in
1412 *clang*)
1413 # Any changes made here should be reflected in the GCC+Darwin case below
1414 LTOFLAGS="-flto"
1415 ;;
1416 *gcc*)
1417 case $ac_sys_system in
1418 Darwin*)
1419 LTOFLAGS="-flto"
1420 ;;
1421 *)
1422 LTOFLAGS="-flto -fuse-linker-plugin -ffat-lto-objects -flto-partition=none"
1423 ;;
1424 esac
1425 ;;
1426 esac
1427fi
1428
1429
Brett Cannon4ff151a2015-09-18 15:09:42 -07001430# Enable PGO flags.
1431AC_SUBST(PGO_PROF_GEN_FLAG)
1432AC_SUBST(PGO_PROF_USE_FLAG)
1433AC_SUBST(LLVM_PROF_MERGER)
1434AC_SUBST(LLVM_PROF_FILE)
1435AC_SUBST(LLVM_PROF_ERR)
Gregory P. Smith794b2912016-09-08 00:07:40 -07001436# Make this work on systems where llvm tools are not installed with their
1437# normal names in the default $PATH (ie: Ubuntu). They exist under the
1438# non-suffixed name in their versioned llvm directory.
1439llvm_bin_dir=''
1440llvm_path="${PATH}"
1441if test "${CC}" = "clang"
1442then
1443 clang_bin=`which clang`
1444 # Some systems install clang elsewhere as a symlink to the real path
1445 # which is where the related llvm tools are located.
1446 if test -L "${clang_bin}"
1447 then
1448 clang_dir=`dirname "${clang_bin}"`
1449 clang_bin=`readlink "${clang_bin}"`
1450 llvm_bin_dir="${clang_dir}/"`dirname "${clang_bin}"`
1451 llvm_path="${llvm_path}${PATH_SEPARATOR}${llvm_bin_dir}"
1452 fi
1453fi
1454AC_SUBST(LLVM_PROFDATA)
1455AC_PATH_TARGET_TOOL(LLVM_PROFDATA, llvm-profdata, '', ${llvm_path})
Brett Cannon4ff151a2015-09-18 15:09:42 -07001456AC_SUBST(LLVM_PROF_FOUND)
Gregory P. Smith794b2912016-09-08 00:07:40 -07001457if test -n "${LLVM_PROFDATA}" -a -x "${LLVM_PROFDATA}"
1458then
1459 LLVM_PROF_FOUND="found"
1460else
1461 LLVM_PROF_FOUND="not-found"
1462fi
1463if test "$ac_sys_system" = "Darwin" -a "${LLVM_PROF_FOUND}" = "not-found"
1464then
1465 found_llvm_profdata=`/usr/bin/xcrun -find llvm-profdata 2>/dev/null`
1466 if test -n "${found_llvm_profdata}"
1467 then
1468 # llvm-profdata isn't directly in $PATH in some cases.
1469 # https://apple.stackexchange.com/questions/197053/
1470 LLVM_PROFDATA='/usr/bin/xcrun llvm-profdata'
1471 LLVM_PROF_FOUND=found
1472 AC_MSG_NOTICE([llvm-profdata found via xcrun: ${LLVM_PROFDATA}])
1473 fi
1474fi
Brett Cannon4ff151a2015-09-18 15:09:42 -07001475LLVM_PROF_ERR=no
1476case $CC in
1477 *clang*)
1478 # Any changes made here should be reflected in the GCC+Darwin case below
1479 PGO_PROF_GEN_FLAG="-fprofile-instr-generate"
1480 PGO_PROF_USE_FLAG="-fprofile-instr-use=code.profclangd"
Gregory P. Smith794b2912016-09-08 00:07:40 -07001481 LLVM_PROF_MERGER="${LLVM_PROFDATA} merge -output=code.profclangd *.profclangr"
Brett Cannon4ff151a2015-09-18 15:09:42 -07001482 LLVM_PROF_FILE="LLVM_PROFILE_FILE=\"code-%p.profclangr\""
1483 if test $LLVM_PROF_FOUND = not-found
1484 then
1485 LLVM_PROF_ERR=yes
Gregory P. Smith794b2912016-09-08 00:07:40 -07001486 if test "${REQUIRE_PGO}" = "yes"
1487 then
Gregory P. Smith ext:(%20%5BGoogle%20Inc.%5D)b9999152016-11-20 21:19:36 +00001488 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 -07001489 fi
Brett Cannon4ff151a2015-09-18 15:09:42 -07001490 fi
1491 ;;
1492 *gcc*)
1493 case $ac_sys_system in
1494 Darwin*)
1495 PGO_PROF_GEN_FLAG="-fprofile-instr-generate"
1496 PGO_PROF_USE_FLAG="-fprofile-instr-use=code.profclangd"
Gregory P. Smith794b2912016-09-08 00:07:40 -07001497 LLVM_PROF_MERGER="${LLVM_PROFDATA} merge -output=code.profclangd *.profclangr"
Brett Cannon4ff151a2015-09-18 15:09:42 -07001498 LLVM_PROF_FILE="LLVM_PROFILE_FILE=\"code-%p.profclangr\""
Gregory P. Smith794b2912016-09-08 00:07:40 -07001499 if test "${LLVM_PROF_FOUND}" = "not-found"
Brett Cannon4ff151a2015-09-18 15:09:42 -07001500 then
1501 LLVM_PROF_ERR=yes
Gregory P. Smith794b2912016-09-08 00:07:40 -07001502 if test "${REQUIRE_PGO}" = "yes"
1503 then
Gregory P. Smith ext:(%20%5BGoogle%20Inc.%5D)b9999152016-11-20 21:19:36 +00001504 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 -07001505 fi
Brett Cannon4ff151a2015-09-18 15:09:42 -07001506 fi
1507 ;;
1508 *)
1509 PGO_PROF_GEN_FLAG="-fprofile-generate"
1510 PGO_PROF_USE_FLAG="-fprofile-use -fprofile-correction"
1511 LLVM_PROF_MERGER="true"
1512 LLVM_PROF_FILE=""
1513 ;;
1514 esac
1515 ;;
Zachary Ware6ed42ea2015-12-21 11:43:03 -06001516 *icc*)
1517 PGO_PROF_GEN_FLAG="-prof-gen"
1518 PGO_PROF_USE_FLAG="-prof-use"
1519 LLVM_PROF_MERGER="true"
1520 LLVM_PROF_FILE=""
1521 ;;
Brett Cannon4ff151a2015-09-18 15:09:42 -07001522esac
1523
1524
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00001525# On some compilers, pthreads are available without further options
1526# (e.g. MacOS X). On some of these systems, the compiler will not
1527# complain if unaccepted options are passed (e.g. gcc on Mac OS X).
1528# So we have to see first whether pthreads are available without
1529# options before we can check whether -Kpthread improves anything.
1530AC_MSG_CHECKING(whether pthreads are available without options)
1531AC_CACHE_VAL(ac_cv_pthread_is_default,
Matthias Klosec511b472010-05-08 11:01:39 +00001532[AC_RUN_IFELSE([AC_LANG_SOURCE([[
Stefan Krahae66ca62012-11-22 22:36:57 +01001533#include <stdio.h>
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00001534#include <pthread.h>
1535
1536void* routine(void* p){return NULL;}
1537
1538int main(){
1539 pthread_t p;
1540 if(pthread_create(&p,NULL,routine,NULL)!=0)
1541 return 1;
Jack Jansen4f8d0542002-03-08 13:43:01 +00001542 (void)pthread_detach(p);
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00001543 return 0;
1544}
Matthias Klosec511b472010-05-08 11:01:39 +00001545]])],[
Skip Montanarod8d39a02003-07-10 20:44:10 +00001546 ac_cv_pthread_is_default=yes
1547 ac_cv_kthread=no
1548 ac_cv_pthread=no
Matthias Klosec511b472010-05-08 11:01:39 +00001549],[ac_cv_pthread_is_default=no],[ac_cv_pthread_is_default=no])
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00001550])
1551AC_MSG_RESULT($ac_cv_pthread_is_default)
1552
1553
1554if test $ac_cv_pthread_is_default = yes
1555then
1556 ac_cv_kpthread=no
1557else
Martin v. Löwis130fb172001-07-19 11:00:41 +00001558# -Kpthread, if available, provides the right #defines
1559# and linker options to make pthread_create available
Martin v. Löwis260aecc2001-10-07 08:14:41 +00001560# Some compilers won't report that they do not support -Kpthread,
1561# so we need to run a program to see whether it really made the
1562# function available.
Martin v. Löwis130fb172001-07-19 11:00:41 +00001563AC_MSG_CHECKING(whether $CC accepts -Kpthread)
1564AC_CACHE_VAL(ac_cv_kpthread,
1565[ac_save_cc="$CC"
1566CC="$CC -Kpthread"
Matthias Klosec511b472010-05-08 11:01:39 +00001567AC_RUN_IFELSE([AC_LANG_SOURCE([[
Stefan Krahae66ca62012-11-22 22:36:57 +01001568#include <stdio.h>
Martin v. Löwis260aecc2001-10-07 08:14:41 +00001569#include <pthread.h>
1570
1571void* routine(void* p){return NULL;}
1572
1573int main(){
1574 pthread_t p;
1575 if(pthread_create(&p,NULL,routine,NULL)!=0)
1576 return 1;
Jack Jansen4f8d0542002-03-08 13:43:01 +00001577 (void)pthread_detach(p);
Martin v. Löwis260aecc2001-10-07 08:14:41 +00001578 return 0;
1579}
Matthias Klosec511b472010-05-08 11:01:39 +00001580]])],[ac_cv_kpthread=yes],[ac_cv_kpthread=no],[ac_cv_kpthread=no])
Martin v. Löwis130fb172001-07-19 11:00:41 +00001581CC="$ac_save_cc"])
Martin v. Löwis130fb172001-07-19 11:00:41 +00001582AC_MSG_RESULT($ac_cv_kpthread)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00001583fi
Martin v. Löwis130fb172001-07-19 11:00:41 +00001584
Skip Montanarod8d39a02003-07-10 20:44:10 +00001585if test $ac_cv_kpthread = no -a $ac_cv_pthread_is_default = no
Martin v. Löwis5f433f02003-05-05 05:05:30 +00001586then
1587# -Kthread, if available, provides the right #defines
1588# and linker options to make pthread_create available
1589# Some compilers won't report that they do not support -Kthread,
1590# so we need to run a program to see whether it really made the
1591# function available.
1592AC_MSG_CHECKING(whether $CC accepts -Kthread)
1593AC_CACHE_VAL(ac_cv_kthread,
1594[ac_save_cc="$CC"
1595CC="$CC -Kthread"
Matthias Klosec511b472010-05-08 11:01:39 +00001596AC_RUN_IFELSE([AC_LANG_SOURCE([[
Stefan Krahae66ca62012-11-22 22:36:57 +01001597#include <stdio.h>
Martin v. Löwis5f433f02003-05-05 05:05:30 +00001598#include <pthread.h>
1599
1600void* routine(void* p){return NULL;}
1601
1602int main(){
1603 pthread_t p;
1604 if(pthread_create(&p,NULL,routine,NULL)!=0)
1605 return 1;
1606 (void)pthread_detach(p);
1607 return 0;
1608}
Matthias Klosec511b472010-05-08 11:01:39 +00001609]])],[ac_cv_kthread=yes],[ac_cv_kthread=no],[ac_cv_kthread=no])
Martin v. Löwis5f433f02003-05-05 05:05:30 +00001610CC="$ac_save_cc"])
1611AC_MSG_RESULT($ac_cv_kthread)
1612fi
1613
Skip Montanarod8d39a02003-07-10 20:44:10 +00001614if test $ac_cv_kthread = no -a $ac_cv_pthread_is_default = no
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00001615then
1616# -pthread, if available, provides the right #defines
1617# and linker options to make pthread_create available
1618# Some compilers won't report that they do not support -pthread,
1619# so we need to run a program to see whether it really made the
1620# function available.
1621AC_MSG_CHECKING(whether $CC accepts -pthread)
doko@python.orgfa3f9a32013-01-25 15:32:31 +01001622AC_CACHE_VAL(ac_cv_pthread,
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00001623[ac_save_cc="$CC"
1624CC="$CC -pthread"
Matthias Klosec511b472010-05-08 11:01:39 +00001625AC_RUN_IFELSE([AC_LANG_SOURCE([[
Stefan Krahae66ca62012-11-22 22:36:57 +01001626#include <stdio.h>
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00001627#include <pthread.h>
1628
1629void* routine(void* p){return NULL;}
1630
1631int main(){
1632 pthread_t p;
1633 if(pthread_create(&p,NULL,routine,NULL)!=0)
1634 return 1;
1635 (void)pthread_detach(p);
1636 return 0;
1637}
Matthias Klosec511b472010-05-08 11:01:39 +00001638]])],[ac_cv_pthread=yes],[ac_cv_pthread=no],[ac_cv_pthread=no])
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00001639CC="$ac_save_cc"])
1640AC_MSG_RESULT($ac_cv_pthread)
1641fi
1642
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001643# If we have set a CC compiler flag for thread support then
1644# check if it works for CXX, too.
1645ac_cv_cxx_thread=no
1646if test ! -z "$CXX"
1647then
1648AC_MSG_CHECKING(whether $CXX also accepts flags for thread support)
1649ac_save_cxx="$CXX"
1650
1651if test "$ac_cv_kpthread" = "yes"
1652then
Martin v. Löwis519adae2003-09-20 10:47:47 +00001653 CXX="$CXX -Kpthread"
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001654 ac_cv_cxx_thread=yes
1655elif test "$ac_cv_kthread" = "yes"
1656then
1657 CXX="$CXX -Kthread"
1658 ac_cv_cxx_thread=yes
1659elif test "$ac_cv_pthread" = "yes"
1660then
1661 CXX="$CXX -pthread"
1662 ac_cv_cxx_thread=yes
1663fi
1664
1665if test $ac_cv_cxx_thread = yes
1666then
1667 echo 'void foo();int main(){foo();}void foo(){}' > conftest.$ac_ext
1668 $CXX -c conftest.$ac_ext 2>&5
1669 if $CXX -o conftest$ac_exeext conftest.$ac_objext 2>&5 \
1670 && test -s conftest$ac_exeext && ./conftest$ac_exeext
1671 then
1672 ac_cv_cxx_thread=yes
1673 else
1674 ac_cv_cxx_thread=no
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001675 fi
1676 rm -fr conftest*
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001677fi
Brett Cannonc601e0f2004-11-07 01:24:12 +00001678AC_MSG_RESULT($ac_cv_cxx_thread)
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001679fi
Martin v. Löwis519adae2003-09-20 10:47:47 +00001680CXX="$ac_save_cxx"
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001681
Fred Drakece81d592000-07-09 14:39:29 +00001682dnl # check for ANSI or K&R ("traditional") preprocessor
1683dnl AC_MSG_CHECKING(for C preprocessor type)
Matthias Klosec511b472010-05-08 11:01:39 +00001684dnl AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Fred Drakece81d592000-07-09 14:39:29 +00001685dnl #define spam(name, doc) {#name, &name, #name "() -- " doc}
1686dnl int foo;
1687dnl struct {char *name; int *addr; char *doc;} desc = spam(foo, "something");
Matthias Klosec511b472010-05-08 11:01:39 +00001688dnl ]], [[;]])],[cpp_type=ansi],[AC_DEFINE(HAVE_OLD_CPP) cpp_type=traditional])
Fred Drakece81d592000-07-09 14:39:29 +00001689dnl AC_MSG_RESULT($cpp_type)
Guido van Rossum300fda71996-08-19 21:58:16 +00001690
Guido van Rossum627b2d71993-12-24 10:39:16 +00001691# checks for header files
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001692AC_HEADER_STDC
doko@ubuntu.comf27ec3e2014-04-17 20:11:19 +02001693AC_CHECK_HEADERS(asm/types.h conio.h direct.h dlfcn.h errno.h \
Martin v. Löwis0e8bd7e2006-06-10 12:23:46 +00001694fcntl.h grp.h \
doko@ubuntu.comf27ec3e2014-04-17 20:11:19 +02001695ieeefp.h io.h langinfo.h libintl.h poll.h process.h pthread.h \
Martin v. Löwis40e9aed2006-10-02 15:20:37 +00001696shadow.h signal.h stdint.h stropts.h termios.h thread.h \
Martin v. Löwis14e73b12003-01-01 09:51:12 +00001697unistd.h utime.h \
Christian Heimes0e9ab5f2008-03-21 23:49:44 +00001698sys/audioio.h sys/bsdtty.h sys/epoll.h sys/event.h sys/file.h sys/loadavg.h \
1699sys/lock.h sys/mkdev.h sys/modem.h \
Benjamin Peterson6b1c9092016-12-19 23:54:25 -08001700sys/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 +00001701sys/termio.h sys/time.h \
Martin v. Löwis0e8bd7e2006-06-10 12:23:46 +00001702sys/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 +00001703sys/resource.h netpacket/packet.h sysexits.h bluetooth.h \
Christian Heimesffa70112017-09-05 17:08:45 +02001704bluetooth/bluetooth.h linux/tipc.h spawn.h util.h alloca.h sys/sysmacros.h)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001705AC_HEADER_DIRENT
Martin v. Löwisdbe3f762002-10-10 14:27:30 +00001706AC_HEADER_MAJOR
Guido van Rossum627b2d71993-12-24 10:39:16 +00001707
Martin v. Löwis11017b12006-01-14 18:12:57 +00001708# On Linux, netlink.h requires asm/types.h
1709AC_CHECK_HEADERS(linux/netlink.h,,,[
1710#ifdef HAVE_ASM_TYPES_H
1711#include <asm/types.h>
1712#endif
1713#ifdef HAVE_SYS_SOCKET_H
1714#include <sys/socket.h>
1715#endif
1716])
1717
Guido van Rossum627b2d71993-12-24 10:39:16 +00001718# checks for typedefs
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001719was_it_defined=no
1720AC_MSG_CHECKING(for clock_t in time.h)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001721AC_EGREP_HEADER(clock_t, time.h, was_it_defined=yes, [
1722 AC_DEFINE(clock_t, long, [Define to 'long' if <time.h> doesn't define.])
1723])
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001724AC_MSG_RESULT($was_it_defined)
1725
Neal Norwitz11690112002-07-30 01:08:28 +00001726# Check whether using makedev requires defining _OSF_SOURCE
1727AC_MSG_CHECKING(for makedev)
Matthias Klosec511b472010-05-08 11:01:39 +00001728AC_LINK_IFELSE([AC_LANG_PROGRAM([[
Jesus Cea616de772010-04-28 10:32:30 +00001729#if defined(MAJOR_IN_MKDEV)
1730#include <sys/mkdev.h>
1731#elif defined(MAJOR_IN_SYSMACROS)
1732#include <sys/sysmacros.h>
1733#else
1734#include <sys/types.h>
Matthias Klosec511b472010-05-08 11:01:39 +00001735#endif ]], [[ makedev(0, 0) ]])],
1736[ac_cv_has_makedev=yes],
1737[ac_cv_has_makedev=no])
Neal Norwitz11690112002-07-30 01:08:28 +00001738if test "$ac_cv_has_makedev" = "no"; then
1739 # we didn't link, try if _OSF_SOURCE will allow us to link
Matthias Klosec511b472010-05-08 11:01:39 +00001740 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
Neal Norwitz6eb37f02003-02-23 23:28:15 +00001741#define _OSF_SOURCE 1
1742#include <sys/types.h>
Matthias Klosec511b472010-05-08 11:01:39 +00001743 ]], [[ makedev(0, 0) ]])],
1744[ac_cv_has_makedev=yes],
1745[ac_cv_has_makedev=no])
Neal Norwitz11690112002-07-30 01:08:28 +00001746 if test "$ac_cv_has_makedev" = "yes"; then
1747 AC_DEFINE(_OSF_SOURCE, 1, [Define _OSF_SOURCE to get the makedev macro.])
1748 fi
1749fi
1750AC_MSG_RESULT($ac_cv_has_makedev)
1751if test "$ac_cv_has_makedev" = "yes"; then
1752 AC_DEFINE(HAVE_MAKEDEV, 1, [Define this if you have the makedev macro.])
1753fi
1754
Martin v. Löwis399a6892002-10-04 10:22:02 +00001755# Enabling LFS on Solaris (2.6 to 9) with gcc 2.95 triggers a bug in
1756# the system headers: If _XOPEN_SOURCE and _LARGEFILE_SOURCE are
1757# defined, but the compiler does not support pragma redefine_extname,
1758# and _LARGEFILE64_SOURCE is not defined, the headers refer to 64-bit
1759# structures (such as rlimit64) without declaring them. As a
1760# work-around, disable LFS on such configurations
1761
1762use_lfs=yes
1763AC_MSG_CHECKING(Solaris LFS bug)
Matthias Klosec511b472010-05-08 11:01:39 +00001764AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwis399a6892002-10-04 10:22:02 +00001765#define _LARGEFILE_SOURCE 1
1766#define _FILE_OFFSET_BITS 64
1767#include <sys/resource.h>
Matthias Klosec511b472010-05-08 11:01:39 +00001768]], [[struct rlimit foo;]])],[sol_lfs_bug=no],[sol_lfs_bug=yes])
Martin v. Löwis399a6892002-10-04 10:22:02 +00001769AC_MSG_RESULT($sol_lfs_bug)
1770if test "$sol_lfs_bug" = "yes"; then
1771 use_lfs=no
1772fi
1773
1774if test "$use_lfs" = "yes"; then
Guido van Rossum810cc512001-09-09 23:51:39 +00001775# Two defines needed to enable largefile support on various platforms
1776# These may affect some typedefs
Georg Brandl94800df2011-02-25 11:09:02 +00001777case $ac_sys_system/$ac_sys_release in
1778AIX*)
1779 AC_DEFINE(_LARGE_FILES, 1,
1780 [This must be defined on AIX systems to enable large file support.])
1781 ;;
1782esac
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001783AC_DEFINE(_LARGEFILE_SOURCE, 1,
1784[This must be defined on some systems to enable large file support.])
1785AC_DEFINE(_FILE_OFFSET_BITS, 64,
1786[This must be set to 64 on some systems to enable large file support.])
Martin v. Löwis399a6892002-10-04 10:22:02 +00001787fi
Guido van Rossum810cc512001-09-09 23:51:39 +00001788
Guido van Rossum300fda71996-08-19 21:58:16 +00001789# Add some code to confdefs.h so that the test for off_t works on SCO
1790cat >> confdefs.h <<\EOF
1791#if defined(SCO_DS)
1792#undef _OFF_T
1793#endif
1794EOF
1795
Guido van Rossumef2255b2000-03-10 22:30:29 +00001796# Type availability checks
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001797AC_TYPE_MODE_T
1798AC_TYPE_OFF_T
1799AC_TYPE_PID_T
Matthias Klosecbf54b12010-05-08 11:04:18 +00001800AC_DEFINE_UNQUOTED([RETSIGTYPE],[void],[assume C89 semantics that RETSIGTYPE is always void])
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001801AC_TYPE_SIZE_T
1802AC_TYPE_UID_T
Mark Dickinson17c50cd2012-12-02 13:13:56 +00001803
1804# There are two separate checks for each of the exact-width integer types we
1805# need. First we check whether the type is available using the usual
1806# AC_CHECK_TYPE macro with the default includes (which includes <inttypes.h>
1807# and <stdint.h> where available). We then also use the special type checks of
1808# the form AC_TYPE_UINT32_T, which in the case that uint32_t is not available
1809# directly, #define's uint32_t to be a suitable type.
1810
1811AC_CHECK_TYPE(uint32_t,
1812 AC_DEFINE(HAVE_UINT32_T, 1, [Define if your compiler provides uint32_t.]),,)
Mark Dickinsonefc82f72009-03-20 15:51:55 +00001813AC_TYPE_UINT32_T
Mark Dickinson17c50cd2012-12-02 13:13:56 +00001814
1815AC_CHECK_TYPE(uint64_t,
1816 AC_DEFINE(HAVE_UINT64_T, 1, [Define if your compiler provides uint64_t.]),,)
Mark Dickinsonefc82f72009-03-20 15:51:55 +00001817AC_TYPE_UINT64_T
Mark Dickinson17c50cd2012-12-02 13:13:56 +00001818
1819AC_CHECK_TYPE(int32_t,
1820 AC_DEFINE(HAVE_INT32_T, 1, [Define if your compiler provides int32_t.]),,)
Mark Dickinsonefc82f72009-03-20 15:51:55 +00001821AC_TYPE_INT32_T
Mark Dickinson17c50cd2012-12-02 13:13:56 +00001822
1823AC_CHECK_TYPE(int64_t,
1824 AC_DEFINE(HAVE_INT64_T, 1, [Define if your compiler provides int64_t.]),,)
Mark Dickinsonefc82f72009-03-20 15:51:55 +00001825AC_TYPE_INT64_T
Mark Dickinson17c50cd2012-12-02 13:13:56 +00001826
Christian Heimes951cc0f2008-01-31 23:08:23 +00001827AC_CHECK_TYPE(ssize_t,
Matthias Klose5183ebd2010-04-24 16:38:36 +00001828 AC_DEFINE(HAVE_SSIZE_T, 1, [Define if your compiler provides ssize_t]),,)
Guido van Rossum627b2d71993-12-24 10:39:16 +00001829
Guido van Rossumef2255b2000-03-10 22:30:29 +00001830# Sizes of various common basic types
Skip Montanarob9820a32004-01-17 00:16:12 +00001831# ANSI C requires sizeof(char) == 1, so no need to check it
Guido van Rossum3065c942001-09-17 04:03:14 +00001832AC_CHECK_SIZEOF(int, 4)
1833AC_CHECK_SIZEOF(long, 4)
1834AC_CHECK_SIZEOF(void *, 4)
Guido van Rossum3065c942001-09-17 04:03:14 +00001835AC_CHECK_SIZEOF(short, 2)
1836AC_CHECK_SIZEOF(float, 4)
1837AC_CHECK_SIZEOF(double, 8)
1838AC_CHECK_SIZEOF(fpos_t, 4)
Martin v. Löwis18e16552006-02-15 17:27:45 +00001839AC_CHECK_SIZEOF(size_t, 4)
Christian Heimes951cc0f2008-01-31 23:08:23 +00001840AC_CHECK_SIZEOF(pid_t, 4)
Guido van Rossumac405f61994-09-12 10:56:06 +00001841
Guido van Rossumec95c7b1998-08-04 17:59:56 +00001842AC_MSG_CHECKING(for long long support)
1843have_long_long=no
Matthias Klosec511b472010-05-08 11:01:39 +00001844AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[long long x; x = (long long)0;]])],[
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001845 AC_DEFINE(HAVE_LONG_LONG, 1, [Define this if you have the type long long.])
1846 have_long_long=yes
Matthias Klosec511b472010-05-08 11:01:39 +00001847],[])
Guido van Rossumec95c7b1998-08-04 17:59:56 +00001848AC_MSG_RESULT($have_long_long)
Guido van Rossum8bc1dfd1999-04-10 16:01:48 +00001849if test "$have_long_long" = yes ; then
Guido van Rossum3065c942001-09-17 04:03:14 +00001850AC_CHECK_SIZEOF(long long, 8)
Guido van Rossumec95c7b1998-08-04 17:59:56 +00001851fi
1852
Travis E. Oliphant711c9e92008-06-06 22:33:21 +00001853AC_MSG_CHECKING(for long double support)
1854have_long_double=no
Matthias Klosec511b472010-05-08 11:01:39 +00001855AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[long double x; x = (long double)0;]])],[
Travis E. Oliphant711c9e92008-06-06 22:33:21 +00001856 AC_DEFINE(HAVE_LONG_DOUBLE, 1, [Define this if you have the type long double.])
1857 have_long_double=yes
Matthias Klosec511b472010-05-08 11:01:39 +00001858],[])
Travis E. Oliphant711c9e92008-06-06 22:33:21 +00001859AC_MSG_RESULT($have_long_double)
Mark Dickinsondc1688a2008-06-27 22:20:14 +00001860if test "$have_long_double" = yes ; then
Travis E. Oliphant711c9e92008-06-06 22:33:21 +00001861AC_CHECK_SIZEOF(long double, 12)
1862fi
1863
Martin v. Löwisaef4c6b2007-01-21 09:33:07 +00001864AC_MSG_CHECKING(for _Bool support)
1865have_c99_bool=no
Matthias Klosec511b472010-05-08 11:01:39 +00001866AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[_Bool x; x = (_Bool)0;]])],[
Martin v. Löwisaef4c6b2007-01-21 09:33:07 +00001867 AC_DEFINE(HAVE_C99_BOOL, 1, [Define this if you have the type _Bool.])
1868 have_c99_bool=yes
Matthias Klosec511b472010-05-08 11:01:39 +00001869],[])
Martin v. Löwisaef4c6b2007-01-21 09:33:07 +00001870AC_MSG_RESULT($have_c99_bool)
1871if test "$have_c99_bool" = yes ; then
1872AC_CHECK_SIZEOF(_Bool, 1)
1873fi
1874
Martin v. Löwisebe26702006-10-02 14:55:51 +00001875AC_CHECK_TYPES(uintptr_t,
1876 [AC_CHECK_SIZEOF(uintptr_t, 4)],
Martin v. Löwis40e9aed2006-10-02 15:20:37 +00001877 [], [#ifdef HAVE_STDINT_H
1878 #include <stdint.h>
Antoine Pitrou7be5a652010-10-10 08:14:41 +00001879 #endif
1880 #ifdef HAVE_INTTYPES_H
1881 #include <inttypes.h>
Martin v. Löwis40e9aed2006-10-02 15:20:37 +00001882 #endif])
Martin v. Löwisebe26702006-10-02 14:55:51 +00001883
Alexandre Vassalotti856782e2009-07-17 04:59:05 +00001884AC_CHECK_SIZEOF(off_t, [], [
1885#ifdef HAVE_SYS_TYPES_H
1886#include <sys/types.h>
1887#endif
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001888])
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001889
1890AC_MSG_CHECKING(whether to enable large file support)
Mark Dickinson0ef0b912009-12-31 21:11:48 +00001891if test "$have_long_long" = yes
1892then
1893if test "$ac_cv_sizeof_off_t" -gt "$ac_cv_sizeof_long" -a \
Guido van Rossum8bc1dfd1999-04-10 16:01:48 +00001894 "$ac_cv_sizeof_long_long" -ge "$ac_cv_sizeof_off_t"; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001895 AC_DEFINE(HAVE_LARGEFILE_SUPPORT, 1,
1896 [Defined to enable large file support when an off_t is bigger than a long
1897 and long long is available and at least as big as an off_t. You may need
1898 to add some flags for configuration and compilation to enable this mode.
1899 (For Solaris and Linux, the necessary defines are already defined.)])
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001900 AC_MSG_RESULT(yes)
1901else
1902 AC_MSG_RESULT(no)
1903fi
Mark Dickinson0ef0b912009-12-31 21:11:48 +00001904else
1905 AC_MSG_RESULT(no)
1906fi
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001907
Alexandre Vassalotti856782e2009-07-17 04:59:05 +00001908AC_CHECK_SIZEOF(time_t, [], [
1909#ifdef HAVE_SYS_TYPES_H
1910#include <sys/types.h>
1911#endif
1912#ifdef HAVE_TIME_H
1913#include <time.h>
1914#endif
Fred Drakea3f6e912000-06-29 20:44:47 +00001915])
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001916
Trent Mick635f6fb2000-08-23 21:33:05 +00001917# if have pthread_t then define SIZEOF_PTHREAD_T
Martin v. Löwis123cbd22001-07-19 14:21:10 +00001918ac_save_cc="$CC"
1919if test "$ac_cv_kpthread" = "yes"
1920then CC="$CC -Kpthread"
Martin v. Löwis5f433f02003-05-05 05:05:30 +00001921elif test "$ac_cv_kthread" = "yes"
1922then CC="$CC -Kthread"
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00001923elif test "$ac_cv_pthread" = "yes"
1924then CC="$CC -pthread"
Martin v. Löwis123cbd22001-07-19 14:21:10 +00001925fi
Trent Mick635f6fb2000-08-23 21:33:05 +00001926AC_MSG_CHECKING(for pthread_t)
1927have_pthread_t=no
Matthias Klosec511b472010-05-08 11:01:39 +00001928AC_COMPILE_IFELSE([
1929 AC_LANG_PROGRAM([[#include <pthread.h>]], [[pthread_t x; x = *(pthread_t*)0;]])
1930],[have_pthread_t=yes],[])
Trent Mick635f6fb2000-08-23 21:33:05 +00001931AC_MSG_RESULT($have_pthread_t)
1932if test "$have_pthread_t" = yes ; then
Alexandre Vassalotti856782e2009-07-17 04:59:05 +00001933 AC_CHECK_SIZEOF(pthread_t, [], [
1934#ifdef HAVE_PTHREAD_H
1935#include <pthread.h>
1936#endif
Trent Mick635f6fb2000-08-23 21:33:05 +00001937 ])
Trent Mick635f6fb2000-08-23 21:33:05 +00001938fi
Martin v. Löwis123cbd22001-07-19 14:21:10 +00001939CC="$ac_save_cc"
Trent Mick635f6fb2000-08-23 21:33:05 +00001940
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001941AC_MSG_CHECKING(for --enable-toolbox-glue)
1942AC_ARG_ENABLE(toolbox-glue,
Matthias Klose22520ea2010-05-08 10:14:46 +00001943 AS_HELP_STRING([--enable-toolbox-glue], [disable/enable MacOSX glue code for extensions]))
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001944
1945if test -z "$enable_toolbox_glue"
1946then
1947 case $ac_sys_system/$ac_sys_release in
1948 Darwin/*)
1949 enable_toolbox_glue="yes";;
1950 *)
1951 enable_toolbox_glue="no";;
1952 esac
1953fi
1954case "$enable_toolbox_glue" in
1955yes)
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001956 extra_machdep_objs="Python/mactoolboxglue.o"
Raymond Hettingerec6eb362004-11-05 07:02:59 +00001957 extra_undefs="-u _PyMac_Error"
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001958 AC_DEFINE(USE_TOOLBOX_OBJECT_GLUE, 1,
1959 [Define if you want to use MacPython modules on MacOSX in unix-Python.])
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001960 ;;
1961*)
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001962 extra_machdep_objs=""
Jack Jansen591cbed2001-08-15 13:55:15 +00001963 extra_undefs=""
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001964 ;;
1965esac
1966AC_MSG_RESULT($enable_toolbox_glue)
1967
Ronald Oussoren0d236eb2008-06-06 21:31:33 +00001968
Bob Ippolito7026a0a2005-03-28 23:23:47 +00001969AC_SUBST(OTHER_LIBTOOL_OPT)
1970case $ac_sys_system/$ac_sys_release in
Anthony Baxter82201742006-04-09 15:07:40 +00001971 Darwin/@<:@01567@:>@\..*)
Bob Ippolito7026a0a2005-03-28 23:23:47 +00001972 OTHER_LIBTOOL_OPT="-prebind -seg1addr 0x10000000"
1973 ;;
1974 Darwin/*)
1975 OTHER_LIBTOOL_OPT=""
1976 ;;
1977esac
1978
Ronald Oussoren25967582009-09-06 10:00:26 +00001979
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001980AC_SUBST(LIBTOOL_CRUFT)
1981case $ac_sys_system/$ac_sys_release in
Anthony Baxter82201742006-04-09 15:07:40 +00001982 Darwin/@<:@01567@:>@\..*)
Ronald Oussoren988117f2006-04-29 11:31:35 +00001983 LIBTOOL_CRUFT="-framework System -lcc_dynamic"
1984 if test "${enable_universalsdk}"; then
1985 :
1986 else
Ronald Oussorenbc0e83c2010-02-11 13:26:54 +00001987 LIBTOOL_CRUFT="${LIBTOOL_CRUFT} -arch_only `/usr/bin/arch`"
Ronald Oussoren988117f2006-04-29 11:31:35 +00001988 fi
Jack Jansenb36687a2004-07-16 08:43:47 +00001989 LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -install_name $(PYTHONFRAMEWORKINSTALLDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansena3891ea2001-09-07 14:25:12 +00001990 LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -compatibility_version $(VERSION) -current_version $(VERSION)';;
Guido van Rossum5839e582000-10-09 19:52:35 +00001991 Darwin/*)
Ronald Oussorena55af9a2010-01-17 16:25:57 +00001992 gcc_version=`gcc -dumpversion`
Bob Ippolito7026a0a2005-03-28 23:23:47 +00001993 if test ${gcc_version} '<' 4.0
1994 then
1995 LIBTOOL_CRUFT="-lcc_dynamic"
1996 else
1997 LIBTOOL_CRUFT=""
1998 fi
Matthias Klosec511b472010-05-08 11:01:39 +00001999 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Ronald Oussoren25967582009-09-06 10:00:26 +00002000 #include <unistd.h>
2001 int main(int argc, char*argv[])
2002 {
2003 if (sizeof(long) == 4) {
2004 return 0;
2005 } else {
2006 return 1;
2007 }
Ronald Oussoren84ddd722009-09-08 07:17:10 +00002008 }
Matthias Klosec511b472010-05-08 11:01:39 +00002009 ]])],[ac_osx_32bit=yes],[ac_osx_32bit=no],[ac_osx_32bit=yes])
Ronald Oussoren25967582009-09-06 10:00:26 +00002010
2011 if test "${ac_osx_32bit}" = "yes"; then
Ronald Oussorenbc0e83c2010-02-11 13:26:54 +00002012 case `/usr/bin/arch` in
Ronald Oussoren25967582009-09-06 10:00:26 +00002013 i386)
2014 MACOSX_DEFAULT_ARCH="i386"
2015 ;;
2016 ppc)
2017 MACOSX_DEFAULT_ARCH="ppc"
2018 ;;
2019 *)
2020 AC_MSG_ERROR([Unexpected output of 'arch' on OSX])
2021 ;;
2022 esac
2023 else
Ronald Oussorenbc0e83c2010-02-11 13:26:54 +00002024 case `/usr/bin/arch` in
Ronald Oussoren25967582009-09-06 10:00:26 +00002025 i386)
2026 MACOSX_DEFAULT_ARCH="x86_64"
2027 ;;
2028 ppc)
2029 MACOSX_DEFAULT_ARCH="ppc64"
2030 ;;
2031 *)
2032 AC_MSG_ERROR([Unexpected output of 'arch' on OSX])
2033 ;;
2034 esac
2035
2036 #ARCH_RUN_32BIT="true"
2037 fi
2038
2039 LIBTOOL_CRUFT=$LIBTOOL_CRUFT" -lSystem -lSystemStubs -arch_only ${MACOSX_DEFAULT_ARCH}"
Jack Jansenb36687a2004-07-16 08:43:47 +00002040 LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -install_name $(PYTHONFRAMEWORKINSTALLDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansenb6e9cad2001-08-15 01:26:28 +00002041 LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -compatibility_version $(VERSION) -current_version $(VERSION)';;
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00002042esac
2043
Jack Jansenb6e9cad2001-08-15 01:26:28 +00002044AC_MSG_CHECKING(for --enable-framework)
2045if test "$enable_framework"
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00002046then
Skip Montanarodecc6a42003-01-01 20:07:49 +00002047 BASECFLAGS="$BASECFLAGS -fno-common -dynamic"
Jack Jansenb6e9cad2001-08-15 01:26:28 +00002048 # -F. is needed to allow linking to the framework while
2049 # in the build location.
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002050 AC_DEFINE(WITH_NEXT_FRAMEWORK, 1,
2051 [Define if you want to produce an OpenStep/Rhapsody framework
2052 (shared library plus accessory files).])
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00002053 AC_MSG_RESULT(yes)
Ronald Oussoren450d5612009-06-08 21:12:41 +00002054 if test $enable_shared = "yes"
2055 then
Ronald Oussoren9ebd2422009-09-29 13:00:44 +00002056 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 +00002057 fi
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00002058else
2059 AC_MSG_RESULT(no)
2060fi
2061
Jack Jansenb6e9cad2001-08-15 01:26:28 +00002062AC_MSG_CHECKING(for dyld)
Jack Jansen9a66b6d2001-08-08 13:56:14 +00002063case $ac_sys_system/$ac_sys_release in
2064 Darwin/*)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002065 AC_DEFINE(WITH_DYLD, 1,
2066 [Define if you want to use the new-style (Openstep, Rhapsody, MacOS)
2067 dynamic linker (dyld) instead of the old-style (NextStep) dynamic
2068 linker (rld). Dyld is necessary to support frameworks.])
Jack Jansen9a66b6d2001-08-08 13:56:14 +00002069 AC_MSG_RESULT(always on for Darwin)
2070 ;;
2071 *)
Jack Jansenb6e9cad2001-08-15 01:26:28 +00002072 AC_MSG_RESULT(no)
2073 ;;
Jack Jansen9a66b6d2001-08-08 13:56:14 +00002074esac
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00002075
Guido van Rossumac405f61994-09-12 10:56:06 +00002076# Set info about shared libraries.
Guido van Rossumac405f61994-09-12 10:56:06 +00002077AC_SUBST(SO)
2078AC_SUBST(LDSHARED)
Tarek Ziadé00002952010-04-03 08:37:59 +00002079AC_SUBST(LDCXXSHARED)
Neil Schemenauerb3531b82001-02-16 04:09:05 +00002080AC_SUBST(BLDSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00002081AC_SUBST(CCSHARED)
2082AC_SUBST(LINKFORSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00002083# SO is the extension of shared libraries `(including the dot!)
Guido van Rossumaef734b2001-01-10 21:09:12 +00002084# -- usually .so, .sl on HP-UX, .dll on Cygwin
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002085AC_MSG_CHECKING(SO)
Guido van Rossumac405f61994-09-12 10:56:06 +00002086if test -z "$SO"
2087then
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002088 case $ac_sys_system in
Neal Norwitz58e28882006-05-19 07:00:58 +00002089 hp*|HP*)
2090 case `uname -m` in
2091 ia64) SO=.so;;
2092 *) SO=.sl;;
2093 esac
2094 ;;
Guido van Rossumaef734b2001-01-10 21:09:12 +00002095 CYGWIN*) SO=.dll;;
Guido van Rossum4b6b5791996-09-09 20:09:34 +00002096 *) SO=.so;;
Guido van Rossumac405f61994-09-12 10:56:06 +00002097 esac
Martin v. Löwis368de8f2003-06-14 14:46:38 +00002098else
2099 # this might also be a termcap variable, see #610332
2100 echo
2101 echo '====================================================================='
2102 echo '+ +'
2103 echo '+ WARNING: You have set SO in your environment. +'
2104 echo '+ Do you really mean to change the extension for shared libraries? +'
2105 echo '+ Continuing in 10 seconds to let you to ponder. +'
2106 echo '+ +'
2107 echo '====================================================================='
2108 sleep 10
Guido van Rossumac405f61994-09-12 10:56:06 +00002109fi
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002110AC_MSG_RESULT($SO)
Ronald Oussoren79f90492009-01-02 10:44:46 +00002111
Neal Norwitz58e28882006-05-19 07:00:58 +00002112AC_DEFINE_UNQUOTED(SHLIB_EXT, "$SO", [Define this to be extension of shared libraries (including the dot!).])
Guido van Rossumac405f61994-09-12 10:56:06 +00002113# LDSHARED is the ld *command* used to create shared library
Skip Montanaroce59c042004-01-17 14:19:44 +00002114# -- "cc -G" on SunOS 5.x, "ld -shared" on IRIX 5
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00002115# (Shared libraries in this instance are shared modules to be loaded into
2116# Python, as opposed to building Python itself as a shared library.)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002117AC_MSG_CHECKING(LDSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00002118if test -z "$LDSHARED"
2119then
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002120 case $ac_sys_system/$ac_sys_release in
Neil Schemenauerb3531b82001-02-16 04:09:05 +00002121 AIX*)
Martin Panterf75a2eb2016-11-20 09:31:41 +00002122 BLDSHARED="Modules/ld_so_aix \$(CC) -bI:Modules/python.exp"
Guido van Rossumce608b02001-09-28 15:59:38 +00002123 LDSHARED="\$(BINLIBDEST)/config/ld_so_aix \$(CC) -bI:\$(BINLIBDEST)/config/python.exp"
Neil Schemenauerb3531b82001-02-16 04:09:05 +00002124 ;;
2125 BeOS*)
2126 BLDSHARED="\$(srcdir)/Modules/ld_so_beos $LDLIBRARY"
Guido van Rossumce608b02001-09-28 15:59:38 +00002127 LDSHARED="\$(BINLIBDEST)/config/ld_so_beos \$(LIBDIR)/$LDLIBRARY"
Neil Schemenauerb3531b82001-02-16 04:09:05 +00002128 ;;
Guido van Rossum6100aaf1997-04-29 21:48:51 +00002129 IRIX/5*) LDSHARED="ld -shared";;
Guido van Rossum91922671997-10-09 20:24:13 +00002130 IRIX*/6*) LDSHARED="ld ${SGI_ABI} -shared -all";;
Greg Ward57c9a662000-05-26 12:22:54 +00002131 SunOS/5*)
Tarek Ziadé00002952010-04-03 08:37:59 +00002132 if test "$GCC" = "yes" ; then
2133 LDSHARED='$(CC) -shared'
2134 LDCXXSHARED='$(CXX) -shared'
2135 else
2136 LDSHARED='$(CC) -G'
2137 LDCXXSHARED='$(CXX) -G'
Greg Ward57c9a662000-05-26 12:22:54 +00002138 fi ;;
Thomas Hellerdc96a772008-04-04 10:07:55 +00002139 hp*|HP*)
Tarek Ziadé00002952010-04-03 08:37:59 +00002140 if test "$GCC" = "yes" ; then
2141 LDSHARED='$(CC) -shared'
2142 LDCXXSHARED='$(CXX) -shared'
2143 else
2144 LDSHARED='ld -b'
Thomas Hellerdc96a772008-04-04 10:07:55 +00002145 fi ;;
Guido van Rossum71001e41995-01-26 00:44:03 +00002146 OSF*) LDSHARED="ld -shared -expect_unresolved \"*\"";;
Jack Jansen418c3b12001-11-14 10:59:57 +00002147 Darwin/1.3*)
Stefan Krah3a3e2032010-11-28 15:30:05 +00002148 LDSHARED='$(CC) -bundle'
2149 LDCXXSHARED='$(CXX) -bundle'
Jack Jansena3891ea2001-09-07 14:25:12 +00002150 if test "$enable_framework" ; then
2151 # Link against the framework. All externals should be defined.
Jack Jansenda49e192005-01-07 13:08:22 +00002152 BLDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
2153 LDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Tarek Ziadé00002952010-04-03 08:37:59 +00002154 LDCXXSHARED="$LDCXXSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansena3891ea2001-09-07 14:25:12 +00002155 else
2156 # No framework. Ignore undefined symbols, assuming they come from Python
Jack Jansen418c3b12001-11-14 10:59:57 +00002157 LDSHARED="$LDSHARED -undefined suppress"
Tarek Ziadé00002952010-04-03 08:37:59 +00002158 LDCXXSHARED="$LDCXXSHARED -undefined suppress"
Jack Jansena3891ea2001-09-07 14:25:12 +00002159 fi ;;
Jack Jansen6b08a402004-06-03 12:41:45 +00002160 Darwin/1.4*|Darwin/5.*|Darwin/6.*)
Stefan Krah3a3e2032010-11-28 15:30:05 +00002161 LDSHARED='$(CC) -bundle'
2162 LDCXXSHARED='$(CXX) -bundle'
Jack Jansenb6e9cad2001-08-15 01:26:28 +00002163 if test "$enable_framework" ; then
2164 # Link against the framework. All externals should be defined.
Jack Jansenda49e192005-01-07 13:08:22 +00002165 BLDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
2166 LDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Tarek Ziadé00002952010-04-03 08:37:59 +00002167 LDCXXSHARED="$LDCXXSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansenb6e9cad2001-08-15 01:26:28 +00002168 else
Michael W. Hudson0c46c0c2002-03-07 09:58:56 +00002169 # No framework, use the Python app as bundle-loader
2170 BLDSHARED="$LDSHARED "'-bundle_loader $(BUILDPYTHON)'
Jack Jansenc28fc372003-02-25 13:14:43 +00002171 LDSHARED="$LDSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)'
Tarek Ziadé00002952010-04-03 08:37:59 +00002172 LDCXXSHARED="$LDCXXSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)'
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00002173 fi ;;
Jack Jansen6b08a402004-06-03 12:41:45 +00002174 Darwin/*)
2175 # Use -undefined dynamic_lookup whenever possible (10.3 and later).
2176 # This allows an extension to be used in any Python
Ronald Oussoren38f1b982007-09-02 09:46:07 +00002177
Ned Deilyc40b9032014-06-25 13:48:46 -07002178 dep_target_major=`echo ${MACOSX_DEPLOYMENT_TARGET} | \
2179 sed 's/\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'`
2180 dep_target_minor=`echo ${MACOSX_DEPLOYMENT_TARGET} | \
2181 sed 's/\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'`
2182 if test ${dep_target_major} -eq 10 && \
2183 test ${dep_target_minor} -le 2
Jack Jansen6b08a402004-06-03 12:41:45 +00002184 then
Ned Deilyc40b9032014-06-25 13:48:46 -07002185 # building for OS X 10.0 through 10.2
Stefan Krah3a3e2032010-11-28 15:30:05 +00002186 LDSHARED='$(CC) -bundle'
2187 LDCXXSHARED='$(CXX) -bundle'
Jack Jansen6b08a402004-06-03 12:41:45 +00002188 if test "$enable_framework" ; then
2189 # Link against the framework. All externals should be defined.
Jack Jansenda49e192005-01-07 13:08:22 +00002190 BLDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
2191 LDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Tarek Ziadé00002952010-04-03 08:37:59 +00002192 LDCXXSHARED="$LDCXXSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansen6b08a402004-06-03 12:41:45 +00002193 else
2194 # No framework, use the Python app as bundle-loader
2195 BLDSHARED="$LDSHARED "'-bundle_loader $(BUILDPYTHON)'
2196 LDSHARED="$LDSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)'
Tarek Ziadé00002952010-04-03 08:37:59 +00002197 LDCXXSHARED="$LDCXXSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)'
Jack Jansen6b08a402004-06-03 12:41:45 +00002198 fi
Ned Deilyc40b9032014-06-25 13:48:46 -07002199 else
2200 # building for OS X 10.3 and later
2201 if test "${enable_universalsdk}"; then
2202 LDFLAGS="${UNIVERSAL_ARCH_FLAGS} -isysroot ${UNIVERSALSDK} ${LDFLAGS}"
2203 fi
2204 LDSHARED='$(CC) -bundle -undefined dynamic_lookup'
2205 LDCXXSHARED='$(CXX) -bundle -undefined dynamic_lookup'
2206 BLDSHARED="$LDSHARED"
Jack Jansen6b08a402004-06-03 12:41:45 +00002207 fi
2208 ;;
Tarek Ziadé00002952010-04-03 08:37:59 +00002209 Linux*|GNU*|QNX*)
2210 LDSHARED='$(CC) -shared'
2211 LDCXXSHARED='$(CXX) -shared';;
2212 BSD/OS*/4*)
2213 LDSHARED="gcc -shared"
2214 LDCXXSHARED="g++ -shared";;
Martin v. Löwis222c5152006-06-03 07:37:13 +00002215 FreeBSD*)
Jeremy Hylton4bcc7c52000-08-31 17:45:35 +00002216 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
Guido van Rossum0286ae82000-08-29 15:06:49 +00002217 then
Stefan Krah3a3e2032010-11-28 15:30:05 +00002218 LDSHARED='$(CC) -shared'
2219 LDCXXSHARED='$(CXX) -shared'
Guido van Rossum0286ae82000-08-29 15:06:49 +00002220 else
Stefan Krah3a3e2032010-11-28 15:30:05 +00002221 LDSHARED="ld -Bshareable"
Guido van Rossum0286ae82000-08-29 15:06:49 +00002222 fi;;
Martin v. Löwis222c5152006-06-03 07:37:13 +00002223 OpenBSD*)
2224 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
2225 then
Stefan Krah3a3e2032010-11-28 15:30:05 +00002226 LDSHARED='$(CC) -shared $(CCSHARED)'
2227 LDCXXSHARED='$(CXX) -shared $(CCSHARED)'
Martin v. Löwis222c5152006-06-03 07:37:13 +00002228 else
2229 case `uname -r` in
2230 [[01]].* | 2.[[0-7]] | 2.[[0-7]].*)
2231 LDSHARED="ld -Bshareable ${LDFLAGS}"
2232 ;;
2233 *)
Stefan Krah3a3e2032010-11-28 15:30:05 +00002234 LDSHARED='$(CC) -shared $(CCSHARED)'
2235 LDCXXSHARED='$(CXX) -shared $(CCSHARED)'
Martin v. Löwis222c5152006-06-03 07:37:13 +00002236 ;;
2237 esac
2238 fi;;
Tarek Ziadé00002952010-04-03 08:37:59 +00002239 NetBSD*|DragonFly*)
Antoine Pitroucb402772011-01-02 20:51:34 +00002240 LDSHARED='$(CC) -shared'
2241 LDCXXSHARED='$(CXX) -shared';;
Martin v. Löwis25ae43b2001-10-07 08:39:18 +00002242 OpenUNIX*|UnixWare*)
Tarek Ziadé00002952010-04-03 08:37:59 +00002243 if test "$GCC" = "yes" ; then
2244 LDSHARED='$(CC) -shared'
2245 LDCXXSHARED='$(CXX) -shared'
2246 else
2247 LDSHARED='$(CC) -G'
2248 LDCXXSHARED='$(CXX) -G'
Martin v. Löwisbec19582001-03-21 15:57:54 +00002249 fi;;
Tarek Ziadé00002952010-04-03 08:37:59 +00002250 SCO_SV*)
2251 LDSHARED='$(CC) -Wl,-G,-Bexport'
2252 LDCXXSHARED='$(CXX) -Wl,-G,-Bexport';;
2253 CYGWIN*)
2254 LDSHARED="gcc -shared -Wl,--enable-auto-image-base"
2255 LDCXXSHARED="g++ -shared -Wl,--enable-auto-image-base";;
2256 atheos*)
2257 LDSHARED="gcc -shared"
2258 LDCXXSHARED="g++ -shared";;
Guido van Rossumac405f61994-09-12 10:56:06 +00002259 *) LDSHARED="ld";;
2260 esac
Guido van Rossumac405f61994-09-12 10:56:06 +00002261fi
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002262AC_MSG_RESULT($LDSHARED)
Tarek Ziadé00002952010-04-03 08:37:59 +00002263LDCXXSHARED=${LDCXXSHARED-$LDSHARED}
Neil Schemenauerb3531b82001-02-16 04:09:05 +00002264BLDSHARED=${BLDSHARED-$LDSHARED}
Guido van Rossumac405f61994-09-12 10:56:06 +00002265# CCSHARED are the C *flags* used to create objects to go into a shared
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00002266# library (module) -- this is only needed for a few systems
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002267AC_MSG_CHECKING(CCSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00002268if test -z "$CCSHARED"
2269then
Guido van Rossum6100aaf1997-04-29 21:48:51 +00002270 case $ac_sys_system/$ac_sys_release in
Neil Schemenauer66252162001-02-19 04:47:42 +00002271 SunOS*) if test "$GCC" = yes;
Martin v. Löwiseb623572007-03-12 10:50:39 +00002272 then CCSHARED="-fPIC";
2273 elif test `uname -p` = sparc;
2274 then CCSHARED="-xcode=pic32";
2275 else CCSHARED="-Kpic";
2276 fi;;
Guido van Rossumaf07a441995-02-13 19:45:27 +00002277 hp*|HP*) if test "$GCC" = yes;
Martin v. Löwis703ad702001-09-05 08:36:52 +00002278 then CCSHARED="-fPIC";
Guido van Rossumaf07a441995-02-13 19:45:27 +00002279 else CCSHARED="+z";
2280 fi;;
Martin v. Löwisa6e97582002-01-01 18:41:33 +00002281 Linux*|GNU*) CCSHARED="-fPIC";;
Guido van Rossumf5957ea1999-10-05 21:59:33 +00002282 BSD/OS*/4*) CCSHARED="-fpic";;
Martin v. Löwis86d66262006-02-17 08:40:11 +00002283 FreeBSD*|NetBSD*|OpenBSD*|DragonFly*) CCSHARED="-fPIC";;
Martin v. Löwis25ae43b2001-10-07 08:39:18 +00002284 OpenUNIX*|UnixWare*)
Martin v. Löwisbec19582001-03-21 15:57:54 +00002285 if test "$GCC" = "yes"
2286 then CCSHARED="-fPIC"
Martin v. Löwis130fb172001-07-19 11:00:41 +00002287 else CCSHARED="-KPIC"
Martin v. Löwisbec19582001-03-21 15:57:54 +00002288 fi;;
Martin v. Löwis21ee4092002-09-30 16:19:48 +00002289 SCO_SV*)
2290 if test "$GCC" = "yes"
2291 then CCSHARED="-fPIC"
2292 else CCSHARED="-Kpic -belf"
2293 fi;;
Guido van Rossum2b5ca001998-03-05 15:41:09 +00002294 IRIX*/6*) case $CC in
2295 *gcc*) CCSHARED="-shared";;
Guido van Rossumee21f411998-04-20 18:51:54 +00002296 *) CCSHARED="";;
Guido van Rossum2b5ca001998-03-05 15:41:09 +00002297 esac;;
Martin v. Löwisf90ae202002-06-11 06:22:31 +00002298 atheos*) CCSHARED="-fPIC";;
Guido van Rossumac405f61994-09-12 10:56:06 +00002299 esac
Guido van Rossumac405f61994-09-12 10:56:06 +00002300fi
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002301AC_MSG_RESULT($CCSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00002302# LINKFORSHARED are the flags passed to the $(CC) command that links
Guido van Rossumb65a48e1995-06-14 18:21:23 +00002303# the python executable -- this is only needed for a few systems
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002304AC_MSG_CHECKING(LINKFORSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00002305if test -z "$LINKFORSHARED"
2306then
Guido van Rossum6100aaf1997-04-29 21:48:51 +00002307 case $ac_sys_system/$ac_sys_release in
Neil Schemenauerb3531b82001-02-16 04:09:05 +00002308 AIX*) LINKFORSHARED='-Wl,-bE:Modules/python.exp -lld';;
Guido van Rossum5dab3d81996-12-06 21:18:18 +00002309 hp*|HP*)
Martin v. Löwis1142de32002-03-29 16:28:31 +00002310 LINKFORSHARED="-Wl,-E -Wl,+s";;
2311# LINKFORSHARED="-Wl,-E -Wl,+s -Wl,+b\$(BINLIBDEST)/lib-dynload";;
Guido van Rossumf5957ea1999-10-05 21:59:33 +00002312 BSD/OS/4*) LINKFORSHARED="-Xlinker -export-dynamic";;
Martin v. Löwisa6e97582002-01-01 18:41:33 +00002313 Linux*|GNU*) LINKFORSHARED="-Xlinker -export-dynamic";;
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00002314 # -u libsys_s pulls in all symbols in libsys
Jack Jansenb6e9cad2001-08-15 01:26:28 +00002315 Darwin/*)
Raymond Hettingerec6eb362004-11-05 07:02:59 +00002316 # -u _PyMac_Error is needed to pull in the mac toolbox glue,
2317 # which is
Jack Jansenb6e9cad2001-08-15 01:26:28 +00002318 # not used by the core itself but which needs to be in the core so
2319 # that dynamically loaded extension modules have access to it.
Jack Jansen97e3f002003-02-23 22:59:01 +00002320 # -prebind is no longer used, because it actually seems to give a
2321 # slowdown in stead of a speedup, maybe due to the large number of
2322 # dynamic loads Python does.
Raymond Hettingerec6eb362004-11-05 07:02:59 +00002323
2324 LINKFORSHARED="$extra_undefs"
Jack Jansenb6e9cad2001-08-15 01:26:28 +00002325 if test "$enable_framework"
2326 then
Jack Jansenda49e192005-01-07 13:08:22 +00002327 LINKFORSHARED="$LINKFORSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansenb6e9cad2001-08-15 01:26:28 +00002328 fi
Raymond Hettingerec6eb362004-11-05 07:02:59 +00002329 LINKFORSHARED="$LINKFORSHARED";;
Martin v. Löwis25ae43b2001-10-07 08:39:18 +00002330 OpenUNIX*|UnixWare*) LINKFORSHARED="-Wl,-Bexport";;
Martin v. Löwis21ee4092002-09-30 16:19:48 +00002331 SCO_SV*) LINKFORSHARED="-Wl,-Bexport";;
Fred Drake02706f52000-09-25 15:08:46 +00002332 ReliantUNIX*) LINKFORSHARED="-W1 -Blargedynsym";;
Martin v. Löwis86d66262006-02-17 08:40:11 +00002333 FreeBSD*|NetBSD*|OpenBSD*|DragonFly*)
Guido van Rossumdf693651999-01-07 21:50:41 +00002334 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
2335 then
2336 LINKFORSHARED="-Wl,--export-dynamic"
2337 fi;;
Guido van Rossum2b5ca001998-03-05 15:41:09 +00002338 SunOS/5*) case $CC in
2339 *gcc*)
Martin v. Löwisa4548572002-04-18 14:51:36 +00002340 if $CC -Xlinker --help 2>&1 | grep export-dynamic >/dev/null
Guido van Rossum8f4ceb11997-12-18 23:42:19 +00002341 then
2342 LINKFORSHARED="-Xlinker --export-dynamic"
Guido van Rossum2b5ca001998-03-05 15:41:09 +00002343 fi;;
2344 esac;;
Jason Tishler30765592003-09-04 11:04:06 +00002345 CYGWIN*)
2346 if test $enable_shared = "no"
2347 then
2348 LINKFORSHARED='-Wl,--out-implib=$(LDLIBRARY)'
2349 fi;;
Martin v. Löwis8c255e42008-05-23 15:06:50 +00002350 QNX*)
2351 # -Wl,-E causes the symbols to be added to the dynamic
2352 # symbol table so that they can be found when a module
2353 # is loaded. -N 2048K causes the stack size to be set
2354 # to 2048 kilobytes so that the stack doesn't overflow
2355 # when running test_compile.py.
2356 LINKFORSHARED='-Wl,-E -N 2048K';;
Guido van Rossumac405f61994-09-12 10:56:06 +00002357 esac
Guido van Rossumac405f61994-09-12 10:56:06 +00002358fi
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002359AC_MSG_RESULT($LINKFORSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00002360
Ronald Oussoren0d236eb2008-06-06 21:31:33 +00002361
Neil Schemenauer61c51152001-01-26 16:18:16 +00002362AC_SUBST(CFLAGSFORSHARED)
2363AC_MSG_CHECKING(CFLAGSFORSHARED)
2364if test ! "$LIBRARY" = "$LDLIBRARY"
2365then
Neil Schemenauerd9cf41c2001-01-27 21:39:17 +00002366 case $ac_sys_system in
2367 CYGWIN*)
2368 # Cygwin needs CCSHARED when building extension DLLs
2369 # but not when building the interpreter DLL.
2370 CFLAGSFORSHARED='';;
2371 *)
2372 CFLAGSFORSHARED='$(CCSHARED)'
2373 esac
Neil Schemenauer61c51152001-01-26 16:18:16 +00002374fi
2375AC_MSG_RESULT($CFLAGSFORSHARED)
2376
Martin v. Löwisf90ae202002-06-11 06:22:31 +00002377# SHLIBS are libraries (except -lc and -lm) to link to the python shared
2378# library (with --enable-shared).
2379# For platforms on which shared libraries are not allowed to have unresolved
Martin v. Löwisd6359c52002-08-04 12:38:50 +00002380# symbols, this must be set to $(LIBS) (expanded by make). We do this even
2381# if it is not required, since it creates a dependency of the shared library
2382# to LIBS. This, in turn, means that applications linking the shared libpython
2383# don't need to link LIBS explicitly. The default should be only changed
2384# on systems where this approach causes problems.
Martin v. Löwisf90ae202002-06-11 06:22:31 +00002385AC_SUBST(SHLIBS)
2386AC_MSG_CHECKING(SHLIBS)
2387case "$ac_sys_system" in
Martin v. Löwisf90ae202002-06-11 06:22:31 +00002388 *)
Martin v. Löwisd6359c52002-08-04 12:38:50 +00002389 SHLIBS='$(LIBS)';;
Martin v. Löwisf90ae202002-06-11 06:22:31 +00002390esac
2391AC_MSG_RESULT($SHLIBS)
2392
2393
Guido van Rossum627b2d71993-12-24 10:39:16 +00002394# checks for libraries
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002395AC_CHECK_LIB(dl, dlopen) # Dynamic linking for SunOS/Solaris and SYSV
2396AC_CHECK_LIB(dld, shl_load) # Dynamic linking for HP-UX
Martin v. Löwis519adae2003-09-20 10:47:47 +00002397
Skip Montanaro4d756af2008-12-01 01:55:22 +00002398# only check for sem_init if thread support is requested
Martin v. Löwis519adae2003-09-20 10:47:47 +00002399if test "$with_threads" = "yes" -o -z "$with_threads"; then
2400 AC_SEARCH_LIBS(sem_init, pthread rt posix4) # 'Real Time' functions on Solaris
2401 # posix4 on Solaris 2.6
2402 # pthread (first!) on Linux
2403fi
2404
Martin v. Löwis19d17342003-06-14 21:03:05 +00002405# check if we need libintl for locale functions
2406AC_CHECK_LIB(intl, textdomain,
2407 AC_DEFINE(WITH_LIBINTL, 1,
2408 [Define to 1 if libintl is needed for locale functions.]))
Guido van Rossum0eefa3f1999-11-16 15:57:37 +00002409
2410# checks for system dependent C++ extensions support
2411case "$ac_sys_system" in
2412 AIX*) AC_MSG_CHECKING(for genuine AIX C++ extensions support)
Matthias Klosec511b472010-05-08 11:01:39 +00002413 AC_LINK_IFELSE([
Georg Brandl94800df2011-02-25 11:09:02 +00002414 AC_LANG_PROGRAM([[#include <load.h>]],
Matthias Klosec511b472010-05-08 11:01:39 +00002415 [[loadAndInit("", 0, "")]])
2416 ],[
2417 AC_DEFINE(AIX_GENUINE_CPLUSPLUS, 1,
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002418 [Define for AIX if your compiler is a genuine IBM xlC/xlC_r
2419 and you want support for AIX C++ shared extension modules.])
Matthias Klosec511b472010-05-08 11:01:39 +00002420 AC_MSG_RESULT(yes)
2421 ],[
2422 AC_MSG_RESULT(no)
2423 ]);;
Guido van Rossum0eefa3f1999-11-16 15:57:37 +00002424 *) ;;
2425esac
2426
Guido van Rossum70c7f481998-03-26 18:44:10 +00002427# Most SVR4 platforms (e.g. Solaris) need -lsocket and -lnsl.
Guido van Rossumec95c7b1998-08-04 17:59:56 +00002428# BeOS' sockets are stashed in libnet.
Guido van Rossumf618d2c1995-01-17 16:36:13 +00002429AC_CHECK_LIB(nsl, t_open, [LIBS="-lnsl $LIBS"]) # SVR4
Guido van Rossumf618d2c1995-01-17 16:36:13 +00002430AC_CHECK_LIB(socket, socket, [LIBS="-lsocket $LIBS"], [], $LIBS) # SVR4 sockets
Skip Montanarob9949db2004-01-17 04:04:13 +00002431
Jeremy Hyltoncb25d5e2000-07-27 21:23:28 +00002432case "$ac_sys_system" in
2433BeOS*)
Guido van Rossumec95c7b1998-08-04 17:59:56 +00002434AC_CHECK_LIB(net, socket, [LIBS="-lnet $LIBS"], [], $LIBS) # BeOS
2435;;
2436esac
Guido van Rossum70c7f481998-03-26 18:44:10 +00002437
Guido van Rossumc5a39031996-07-31 17:35:03 +00002438AC_MSG_CHECKING(for --with-libs)
Barry Warsawc0d24d82000-06-29 16:12:00 +00002439AC_ARG_WITH(libs,
Matthias Klose22520ea2010-05-08 10:14:46 +00002440 AS_HELP_STRING([--with-libs='lib1 ...'], [link against additional libs]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002441[
Guido van Rossumc5a39031996-07-31 17:35:03 +00002442AC_MSG_RESULT($withval)
2443LIBS="$withval $LIBS"
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002444],
2445[AC_MSG_RESULT(no)])
Guido van Rossum627b2d71993-12-24 10:39:16 +00002446
Benjamin Peterson64e8f6e2014-12-15 00:00:23 -05002447PKG_PROG_PKG_CONFIG
Benjamin Petersone9e07bf2010-03-09 21:46:54 +00002448
Benjamin Peterson2c196742009-12-31 03:17:18 +00002449# Check for use of the system expat library
2450AC_MSG_CHECKING(for --with-system-expat)
2451AC_ARG_WITH(system_expat,
Benjamin Petersonf2d1b2a2010-10-31 16:53:53 +00002452 AS_HELP_STRING([--with-system-expat], [build pyexpat module using an installed expat library]),
2453 [],
2454 [with_system_expat="no"])
Benjamin Peterson2c196742009-12-31 03:17:18 +00002455
2456AC_MSG_RESULT($with_system_expat)
2457
Martin v. Löwis9176fc12006-04-11 11:12:43 +00002458# Check for use of the system libffi library
2459AC_MSG_CHECKING(for --with-system-ffi)
2460AC_ARG_WITH(system_ffi,
Benjamin Petersonf2d1b2a2010-10-31 16:53:53 +00002461 AS_HELP_STRING([--with-system-ffi], [build _ctypes module using an installed ffi library]),
2462 [],
2463 [with_system_ffi="no"])
Martin v. Löwis9176fc12006-04-11 11:12:43 +00002464
Benjamin Petersone9e07bf2010-03-09 21:46:54 +00002465if test "$with_system_ffi" = "yes" && test -n "$PKG_CONFIG"; then
Benjamin Peterson1c335e62010-01-01 15:16:29 +00002466 LIBFFI_INCLUDEDIR="`"$PKG_CONFIG" libffi --cflags-only-I 2>/dev/null | sed -e 's/^-I//;s/ *$//'`"
2467else
2468 LIBFFI_INCLUDEDIR=""
2469fi
2470AC_SUBST(LIBFFI_INCLUDEDIR)
2471
Martin v. Löwis9176fc12006-04-11 11:12:43 +00002472AC_MSG_RESULT($with_system_ffi)
2473
Ned Deilya2a9f572013-10-25 00:30:10 -07002474# Check for --with-tcltk-includes=path and --with-tcltk-libs=path
2475AC_SUBST(TCLTK_INCLUDES)
2476AC_SUBST(TCLTK_LIBS)
2477AC_MSG_CHECKING(for --with-tcltk-includes)
2478AC_ARG_WITH(tcltk-includes,
2479 AS_HELP_STRING([--with-tcltk-includes='-I...'], [override search for Tcl and Tk include files]),
2480 [],
2481 [with_tcltk_includes="default"])
2482AC_MSG_RESULT($with_tcltk_includes)
2483AC_MSG_CHECKING(for --with-tcltk-libs)
2484AC_ARG_WITH(tcltk-libs,
2485 AS_HELP_STRING([--with-tcltk-libs='-L...'], [override search for Tcl and Tk libs]),
2486 [],
2487 [with_tcltk_libs="default"])
2488AC_MSG_RESULT($with_tcltk_libs)
2489if test "x$with_tcltk_includes" = xdefault || test "x$with_tcltk_libs" = xdefault
2490then
2491 if test "x$with_tcltk_includes" != "x$with_tcltk_libs"
2492 then
2493 AC_MSG_ERROR([use both --with-tcltk-includes='...' and --with-tcltk-libs='...' or neither])
2494 fi
2495 TCLTK_INCLUDES=""
2496 TCLTK_LIBS=""
2497else
2498 TCLTK_INCLUDES="$with_tcltk_includes"
2499 TCLTK_LIBS="$with_tcltk_libs"
2500fi
2501
Matthias Klose10cbe482009-04-29 17:18:19 +00002502# Check for --with-dbmliborder
2503AC_MSG_CHECKING(for --with-dbmliborder)
2504AC_ARG_WITH(dbmliborder,
Matthias Klose22520ea2010-05-08 10:14:46 +00002505 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 +00002506[
2507if test x$with_dbmliborder = xyes
2508then
2509AC_MSG_ERROR([proper usage is --with-dbmliborder=db1:db2:...])
2510else
2511 for db in `echo $with_dbmliborder | sed 's/:/ /g'`; do
2512 if test x$db != xndbm && test x$db != xgdbm && test x$db != xbdb
2513 then
2514 AC_MSG_ERROR([proper usage is --with-dbmliborder=db1:db2:...])
2515 fi
2516 done
Matthias Klose61dbdb92009-04-29 20:09:50 +00002517fi])
2518AC_MSG_RESULT($with_dbmliborder)
Matthias Klose10cbe482009-04-29 17:18:19 +00002519
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00002520# Determine if signalmodule should be used.
2521AC_SUBST(USE_SIGNAL_MODULE)
2522AC_SUBST(SIGNAL_OBJS)
2523AC_MSG_CHECKING(for --with-signal-module)
2524AC_ARG_WITH(signal-module,
Matthias Klose22520ea2010-05-08 10:14:46 +00002525 AS_HELP_STRING([--with-signal-module], [disable/enable signal module]))
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00002526
2527if test -z "$with_signal_module"
2528then with_signal_module="yes"
2529fi
2530AC_MSG_RESULT($with_signal_module)
2531
2532if test "${with_signal_module}" = "yes"; then
2533 USE_SIGNAL_MODULE=""
2534 SIGNAL_OBJS=""
2535else
2536 USE_SIGNAL_MODULE="#"
2537 SIGNAL_OBJS="Parser/intrcheck.o Python/sigcheck.o"
2538fi
2539
Guido van Rossum3d15bd82001-01-10 18:53:48 +00002540# This is used to generate Setup.config
Guido van Rossum009f7871997-12-04 00:51:42 +00002541AC_SUBST(USE_THREAD_MODULE)
Barry Warsawc0d24d82000-06-29 16:12:00 +00002542USE_THREAD_MODULE=""
Guido van Rossum009f7871997-12-04 00:51:42 +00002543
Guido van Rossum54d93d41997-01-22 20:51:58 +00002544AC_MSG_CHECKING(for --with-dec-threads)
2545AC_SUBST(LDLAST)
2546AC_ARG_WITH(dec-threads,
Matthias Klose22520ea2010-05-08 10:14:46 +00002547 AS_HELP_STRING([--with-dec-threads], [use DEC Alpha/OSF1 thread-safe libraries]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002548[
Barry Warsawc0d24d82000-06-29 16:12:00 +00002549AC_MSG_RESULT($withval)
Guido van Rossum54d93d41997-01-22 20:51:58 +00002550LDLAST=-threads
Guido van Rossumf78abae1997-01-21 22:02:36 +00002551if test "${with_thread+set}" != set; then
Guido van Rossum54d93d41997-01-22 20:51:58 +00002552 with_thread="$withval";
2553fi],
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002554[AC_MSG_RESULT(no)])
Guido van Rossum54d93d41997-01-22 20:51:58 +00002555
Martin v. Löwis11437992002-04-12 09:54:03 +00002556# Templates for things AC_DEFINEd more than once.
2557# For a single AC_DEFINE, no template is needed.
2558AH_TEMPLATE(C_THREADS,[Define if you have the Mach cthreads package])
2559AH_TEMPLATE(_REENTRANT,
2560 [Define to force use of thread-safe errno, h_errno, and other functions])
2561AH_TEMPLATE(WITH_THREAD,
2562 [Define if you want to compile in rudimentary thread support])
2563
Guido van Rossum54d93d41997-01-22 20:51:58 +00002564AC_MSG_CHECKING(for --with-threads)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002565dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
Barry Warsawc0d24d82000-06-29 16:12:00 +00002566AC_ARG_WITH(threads,
Matthias Klose22520ea2010-05-08 10:14:46 +00002567 AS_HELP_STRING([--with(out)-threads@<:@=DIRECTORY@:>@], [disable/enable thread support]))
Guido van Rossum54d93d41997-01-22 20:51:58 +00002568
Barry Warsawc0d24d82000-06-29 16:12:00 +00002569# --with-thread is deprecated, but check for it anyway
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002570dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
Barry Warsawa0f3c5c2000-06-30 16:39:35 +00002571AC_ARG_WITH(thread,
Matthias Klose22520ea2010-05-08 10:14:46 +00002572 AS_HELP_STRING([--with(out)-thread@<:@=DIRECTORY@:>@], [deprecated; use --with(out)-threads]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002573 [with_threads=$with_thread])
Barry Warsawc0d24d82000-06-29 16:12:00 +00002574
2575if test -z "$with_threads"
2576then with_threads="yes"
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002577fi
Barry Warsawc0d24d82000-06-29 16:12:00 +00002578AC_MSG_RESULT($with_threads)
Guido van Rossum6400c261997-05-22 20:34:27 +00002579
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002580AC_SUBST(THREADOBJ)
Barry Warsawc0d24d82000-06-29 16:12:00 +00002581if test "$with_threads" = "no"
2582then
2583 USE_THREAD_MODULE="#"
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002584elif test "$ac_cv_pthread_is_default" = yes
2585then
2586 AC_DEFINE(WITH_THREAD)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002587 # Defining _REENTRANT on system with POSIX threads should not hurt.
2588 AC_DEFINE(_REENTRANT)
2589 posix_threads=yes
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002590 THREADOBJ="Python/thread.o"
Martin v. Löwis130fb172001-07-19 11:00:41 +00002591elif test "$ac_cv_kpthread" = "yes"
2592then
2593 CC="$CC -Kpthread"
Martin v. Löwis519adae2003-09-20 10:47:47 +00002594 if test "$ac_cv_cxx_thread" = "yes"; then
2595 CXX="$CXX -Kpthread"
2596 fi
Martin v. Löwis130fb172001-07-19 11:00:41 +00002597 AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002598 posix_threads=yes
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002599 THREADOBJ="Python/thread.o"
Martin v. Löwis5f433f02003-05-05 05:05:30 +00002600elif test "$ac_cv_kthread" = "yes"
2601then
2602 CC="$CC -Kthread"
Martin v. Löwis519adae2003-09-20 10:47:47 +00002603 if test "$ac_cv_cxx_thread" = "yes"; then
2604 CXX="$CXX -Kthread"
2605 fi
Martin v. Löwis5f433f02003-05-05 05:05:30 +00002606 AC_DEFINE(WITH_THREAD)
2607 posix_threads=yes
2608 THREADOBJ="Python/thread.o"
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002609elif test "$ac_cv_pthread" = "yes"
2610then
2611 CC="$CC -pthread"
Martin v. Löwis519adae2003-09-20 10:47:47 +00002612 if test "$ac_cv_cxx_thread" = "yes"; then
2613 CXX="$CXX -pthread"
2614 fi
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002615 AC_DEFINE(WITH_THREAD)
2616 posix_threads=yes
2617 THREADOBJ="Python/thread.o"
Barry Warsawc0d24d82000-06-29 16:12:00 +00002618else
Martin v. Löwis130fb172001-07-19 11:00:41 +00002619 if test ! -z "$with_threads" -a -d "$with_threads"
2620 then LDFLAGS="$LDFLAGS -L$with_threads"
2621 fi
2622 if test ! -z "$withval" -a -d "$withval"
2623 then LDFLAGS="$LDFLAGS -L$withval"
2624 fi
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002625
2626 # According to the POSIX spec, a pthreads implementation must
Matthias Klosea2542be2004-08-16 11:35:51 +00002627 # define _POSIX_THREADS in unistd.h. Some apparently don't
2628 # (e.g. gnu pth with pthread emulation)
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002629 AC_MSG_CHECKING(for _POSIX_THREADS in unistd.h)
2630 AC_EGREP_CPP(yes,
Neal Norwitz6eb37f02003-02-23 23:28:15 +00002631 [
2632#include <unistd.h>
2633#ifdef _POSIX_THREADS
2634yes
2635#endif
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002636 ], unistd_defines_pthreads=yes, unistd_defines_pthreads=no)
2637 AC_MSG_RESULT($unistd_defines_pthreads)
2638
Martin v. Löwis130fb172001-07-19 11:00:41 +00002639 AC_DEFINE(_REENTRANT)
Martin v. Löwisa6e97582002-01-01 18:41:33 +00002640 AC_CHECK_HEADER(cthreads.h, [AC_DEFINE(WITH_THREAD)
2641 AC_DEFINE(C_THREADS)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002642 AC_DEFINE(HURD_C_THREADS, 1,
2643 [Define if you are using Mach cthreads directly under /include])
Martin v. Löwisa6e97582002-01-01 18:41:33 +00002644 LIBS="$LIBS -lthreads"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002645 THREADOBJ="Python/thread.o"],[
Martin v. Löwis130fb172001-07-19 11:00:41 +00002646 AC_CHECK_HEADER(mach/cthreads.h, [AC_DEFINE(WITH_THREAD)
2647 AC_DEFINE(C_THREADS)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002648 AC_DEFINE(MACH_C_THREADS, 1,
2649 [Define if you are using Mach cthreads under mach /])
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002650 THREADOBJ="Python/thread.o"],[
Martin v. Löwis130fb172001-07-19 11:00:41 +00002651 AC_MSG_CHECKING(for --with-pth)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002652 AC_ARG_WITH([pth],
Matthias Klose22520ea2010-05-08 10:14:46 +00002653 AS_HELP_STRING([--with-pth], [use GNU pth threading libraries]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002654 [AC_MSG_RESULT($withval)
2655 AC_DEFINE([WITH_THREAD])
2656 AC_DEFINE([HAVE_PTH], 1,
2657 [Define if you have GNU PTH threads.])
2658 LIBS="-lpth $LIBS"
2659 THREADOBJ="Python/thread.o"],
2660 [AC_MSG_RESULT(no)
Martin v. Löwis8158b5a2001-10-08 13:17:28 +00002661
2662 # Just looking for pthread_create in libpthread is not enough:
2663 # on HP/UX, pthread.h renames pthread_create to a different symbol name.
2664 # So we really have to include pthread.h, and then link.
2665 _libs=$LIBS
2666 LIBS="$LIBS -lpthread"
2667 AC_MSG_CHECKING([for pthread_create in -lpthread])
Stefan Krahae66ca62012-11-22 22:36:57 +01002668 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
2669#include <stdio.h>
2670#include <pthread.h>
Martin v. Löwis8158b5a2001-10-08 13:17:28 +00002671
Matthias Klosec511b472010-05-08 11:01:39 +00002672void * start_routine (void *arg) { exit (0); }]], [[
2673pthread_create (NULL, NULL, start_routine, NULL)]])],[
Martin v. Löwis8158b5a2001-10-08 13:17:28 +00002674 AC_MSG_RESULT(yes)
2675 AC_DEFINE(WITH_THREAD)
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002676 posix_threads=yes
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002677 THREADOBJ="Python/thread.o"],[
Martin v. Löwis8158b5a2001-10-08 13:17:28 +00002678 LIBS=$_libs
Martin v. Löwis130fb172001-07-19 11:00:41 +00002679 AC_CHECK_FUNC(pthread_detach, [AC_DEFINE(WITH_THREAD)
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002680 posix_threads=yes
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002681 THREADOBJ="Python/thread.o"],[
Martin v. Löwisf90ae202002-06-11 06:22:31 +00002682 AC_CHECK_HEADER(atheos/threads.h, [AC_DEFINE(WITH_THREAD)
2683 AC_DEFINE(ATHEOS_THREADS, 1,
2684 [Define this if you have AtheOS threads.])
2685 THREADOBJ="Python/thread.o"],[
Martin v. Löwis130fb172001-07-19 11:00:41 +00002686 AC_CHECK_HEADER(kernel/OS.h, [AC_DEFINE(WITH_THREAD)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002687 AC_DEFINE(BEOS_THREADS, 1,
2688 [Define this if you have BeOS threads.])
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002689 THREADOBJ="Python/thread.o"],[
Martin v. Löwis130fb172001-07-19 11:00:41 +00002690 AC_CHECK_LIB(pthreads, pthread_create, [AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002691 posix_threads=yes
Martin v. Löwis130fb172001-07-19 11:00:41 +00002692 LIBS="$LIBS -lpthreads"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002693 THREADOBJ="Python/thread.o"], [
Martin v. Löwis130fb172001-07-19 11:00:41 +00002694 AC_CHECK_LIB(c_r, pthread_create, [AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002695 posix_threads=yes
Martin v. Löwis130fb172001-07-19 11:00:41 +00002696 LIBS="$LIBS -lc_r"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002697 THREADOBJ="Python/thread.o"], [
Martin v. Löwis130fb172001-07-19 11:00:41 +00002698 AC_CHECK_LIB(pthread, __pthread_create_system, [AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002699 posix_threads=yes
Martin v. Löwis130fb172001-07-19 11:00:41 +00002700 LIBS="$LIBS -lpthread"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002701 THREADOBJ="Python/thread.o"], [
Martin v. Löwis130fb172001-07-19 11:00:41 +00002702 AC_CHECK_LIB(cma, pthread_create, [AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002703 posix_threads=yes
Martin v. Löwis130fb172001-07-19 11:00:41 +00002704 LIBS="$LIBS -lcma"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002705 THREADOBJ="Python/thread.o"],[
Martin v. Löwis130fb172001-07-19 11:00:41 +00002706 USE_THREAD_MODULE="#"])
Skip Montanarof8712e52004-01-17 03:04:46 +00002707 ])])])])])])])])])])
Barry Warsawc0d24d82000-06-29 16:12:00 +00002708
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002709 AC_CHECK_LIB(mpc, usconfig, [AC_DEFINE(WITH_THREAD)
2710 LIBS="$LIBS -lmpc"
2711 THREADOBJ="Python/thread.o"
2712 USE_THREAD_MODULE=""])
2713
2714 if test "$posix_threads" != "yes"; then
2715 AC_CHECK_LIB(thread, thr_create, [AC_DEFINE(WITH_THREAD)
2716 LIBS="$LIBS -lthread"
2717 THREADOBJ="Python/thread.o"
2718 USE_THREAD_MODULE=""])
2719 fi
2720
2721 if test "$USE_THREAD_MODULE" != "#"
2722 then
2723 # If the above checks didn't disable threads, (at least) OSF1
2724 # needs this '-threads' argument during linking.
2725 case $ac_sys_system in
2726 OSF1) LDLAST=-threads;;
2727 esac
2728 fi
2729fi
2730
2731if test "$posix_threads" = "yes"; then
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002732 if test "$unistd_defines_pthreads" = "no"; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002733 AC_DEFINE(_POSIX_THREADS, 1,
2734 [Define if you have POSIX threads,
2735 and your system does not define that.])
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002736 fi
2737
Martin v. Löwisdfc33fd2003-01-21 10:14:41 +00002738 # Bug 662787: Using semaphores causes unexplicable hangs on Solaris 8.
2739 case $ac_sys_system/$ac_sys_release in
Charles-François Natali4929eb92011-07-21 19:41:04 +02002740 SunOS/5.6) AC_DEFINE(HAVE_PTHREAD_DESTRUCTOR, 1,
Matthias Klose5183ebd2010-04-24 16:38:36 +00002741 [Defined for Solaris 2.6 bug in pthread header.])
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002742 ;;
Martin v. Löwisdfc33fd2003-01-21 10:14:41 +00002743 SunOS/5.8) AC_DEFINE(HAVE_BROKEN_POSIX_SEMAPHORES, 1,
Matthias Klose5183ebd2010-04-24 16:38:36 +00002744 [Define if the Posix semaphores do not work on your system])
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002745 ;;
Charles-François Natali4929eb92011-07-21 19:41:04 +02002746 AIX/*) AC_DEFINE(HAVE_BROKEN_POSIX_SEMAPHORES, 1,
Matthias Klose5183ebd2010-04-24 16:38:36 +00002747 [Define if the Posix semaphores do not work on your system])
Christian Heimescba36bb2008-01-30 22:54:18 +00002748 ;;
Martin v. Löwisdfc33fd2003-01-21 10:14:41 +00002749 esac
2750
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002751 AC_MSG_CHECKING(if PTHREAD_SCOPE_SYSTEM is supported)
2752 AC_CACHE_VAL(ac_cv_pthread_system_supported,
Stefan Krahae66ca62012-11-22 22:36:57 +01002753 [AC_RUN_IFELSE([AC_LANG_SOURCE([[
2754 #include <stdio.h>
2755 #include <pthread.h>
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002756 void *foo(void *parm) {
2757 return NULL;
2758 }
2759 main() {
2760 pthread_attr_t attr;
Martin v. Löwisa82d3472002-02-24 16:05:05 +00002761 pthread_t id;
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002762 if (pthread_attr_init(&attr)) exit(-1);
2763 if (pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM)) exit(-1);
Martin v. Löwisa82d3472002-02-24 16:05:05 +00002764 if (pthread_create(&id, &attr, foo, NULL)) exit(-1);
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002765 exit(0);
Matthias Klosec511b472010-05-08 11:01:39 +00002766 }]])],
2767 [ac_cv_pthread_system_supported=yes],
2768 [ac_cv_pthread_system_supported=no],
2769 [ac_cv_pthread_system_supported=no])
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002770 ])
2771 AC_MSG_RESULT($ac_cv_pthread_system_supported)
2772 if test "$ac_cv_pthread_system_supported" = "yes"; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002773 AC_DEFINE(PTHREAD_SYSTEM_SCHED_SUPPORTED, 1, [Defined if PTHREAD_SCOPE_SYSTEM supported.])
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002774 fi
Jason Tishlerfac083d2003-07-22 15:20:49 +00002775 AC_CHECK_FUNCS(pthread_sigmask,
2776 [case $ac_sys_system in
2777 CYGWIN*)
2778 AC_DEFINE(HAVE_BROKEN_PTHREAD_SIGMASK, 1,
2779 [Define if pthread_sigmask() does not work on your system.])
2780 ;;
2781 esac])
Christian Heimes0d604cf2013-08-21 13:26:05 +02002782 AC_CHECK_FUNCS(pthread_atfork)
Barry Warsawc0d24d82000-06-29 16:12:00 +00002783fi
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002784
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002785
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002786# Check for enable-ipv6
Martin v. Löwis11437992002-04-12 09:54:03 +00002787AH_TEMPLATE(ENABLE_IPV6, [Define if --enable-ipv6 is specified])
Martin v. Löwisa5f8bb52001-09-05 08:22:34 +00002788AC_MSG_CHECKING([if --enable-ipv6 is specified])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002789AC_ARG_ENABLE(ipv6,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002790[ --enable-ipv6 Enable ipv6 (with ipv4) support
2791 --disable-ipv6 Disable ipv6 support],
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002792[ case "$enableval" in
2793 no)
2794 AC_MSG_RESULT(no)
2795 ipv6=no
2796 ;;
2797 *) AC_MSG_RESULT(yes)
2798 AC_DEFINE(ENABLE_IPV6)
2799 ipv6=yes
2800 ;;
2801 esac ],
2802
Martin v. Löwisa5f8bb52001-09-05 08:22:34 +00002803[
2804dnl the check does not work on cross compilation case...
Charles-François Natalibe2b9072013-01-08 19:47:00 +01002805 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ /* AF_INET6 available check */
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002806#include <sys/types.h>
Charles-François Natalibe2b9072013-01-08 19:47:00 +01002807#include <sys/socket.h>]],
2808[[int domain = AF_INET6;]])],[
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002809 AC_MSG_RESULT(yes)
Matthias Klosec511b472010-05-08 11:01:39 +00002810 ipv6=yes
2811],[
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002812 AC_MSG_RESULT(no)
2813 ipv6=no
Matthias Klosec511b472010-05-08 11:01:39 +00002814])
Martin v. Löwisa5f8bb52001-09-05 08:22:34 +00002815
2816if test "$ipv6" = "yes"; then
2817 AC_MSG_CHECKING(if RFC2553 API is available)
Matthias Klosec511b472010-05-08 11:01:39 +00002818 AC_COMPILE_IFELSE([
2819 AC_LANG_PROGRAM([[#include <sys/types.h>
2820#include <netinet/in.h>]],
2821 [[struct sockaddr_in6 x;
2822 x.sin6_scope_id;]])
2823 ],[
2824 AC_MSG_RESULT(yes)
2825 ipv6=yes
2826 ],[
2827 AC_MSG_RESULT(no, IPv6 disabled)
2828 ipv6=no
2829 ])
Martin v. Löwisa5f8bb52001-09-05 08:22:34 +00002830fi
2831
2832if test "$ipv6" = "yes"; then
2833 AC_DEFINE(ENABLE_IPV6)
2834fi
2835])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002836
2837ipv6type=unknown
2838ipv6lib=none
2839ipv6trylibc=no
2840
2841if test "$ipv6" = "yes"; then
2842 AC_MSG_CHECKING([ipv6 stack type])
Guido van Rossumb8552162001-09-05 14:58:11 +00002843 for i in inria kame linux-glibc linux-inet6 solaris toshiba v6d zeta;
2844 do
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002845 case $i in
2846 inria)
2847 dnl http://www.kame.net/
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002848 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002849#include <netinet/in.h>
2850#ifdef IPV6_INRIA_VERSION
2851yes
2852#endif],
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002853 [ipv6type=$i])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002854 ;;
2855 kame)
2856 dnl http://www.kame.net/
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002857 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002858#include <netinet/in.h>
2859#ifdef __KAME__
2860yes
2861#endif],
2862 [ipv6type=$i;
2863 ipv6lib=inet6
2864 ipv6libdir=/usr/local/v6/lib
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002865 ipv6trylibc=yes])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002866 ;;
2867 linux-glibc)
2868 dnl http://www.v6.linux.or.jp/
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002869 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002870#include <features.h>
2871#if defined(__GLIBC__) && ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1) || (__GLIBC__ > 2))
2872yes
2873#endif],
2874 [ipv6type=$i;
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002875 ipv6trylibc=yes])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002876 ;;
2877 linux-inet6)
2878 dnl http://www.v6.linux.or.jp/
2879 if test -d /usr/inet6; then
2880 ipv6type=$i
2881 ipv6lib=inet6
2882 ipv6libdir=/usr/inet6/lib
Skip Montanarodecc6a42003-01-01 20:07:49 +00002883 BASECFLAGS="-I/usr/inet6/include $BASECFLAGS"
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002884 fi
2885 ;;
2886 solaris)
2887 if test -f /etc/netconfig; then
Antoine Pitrou31e85952011-01-03 18:57:14 +00002888 if $GREP -q tcp6 /etc/netconfig; then
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002889 ipv6type=$i
2890 ipv6trylibc=yes
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002891 fi
2892 fi
2893 ;;
2894 toshiba)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002895 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002896#include <sys/param.h>
2897#ifdef _TOSHIBA_INET6
2898yes
2899#endif],
2900 [ipv6type=$i;
2901 ipv6lib=inet6;
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002902 ipv6libdir=/usr/local/v6/lib])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002903 ;;
2904 v6d)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002905 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002906#include </usr/local/v6/include/sys/v6config.h>
2907#ifdef __V6D__
2908yes
2909#endif],
2910 [ipv6type=$i;
2911 ipv6lib=v6;
2912 ipv6libdir=/usr/local/v6/lib;
Skip Montanarodecc6a42003-01-01 20:07:49 +00002913 BASECFLAGS="-I/usr/local/v6/include $BASECFLAGS"])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002914 ;;
2915 zeta)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002916 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002917#include <sys/param.h>
2918#ifdef _ZETA_MINAMI_INET6
2919yes
2920#endif],
2921 [ipv6type=$i;
2922 ipv6lib=inet6;
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002923 ipv6libdir=/usr/local/v6/lib])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002924 ;;
2925 esac
2926 if test "$ipv6type" != "unknown"; then
2927 break
2928 fi
2929 done
2930 AC_MSG_RESULT($ipv6type)
2931fi
2932
2933if test "$ipv6" = "yes" -a "$ipv6lib" != "none"; then
2934 if test -d $ipv6libdir -a -f $ipv6libdir/lib$ipv6lib.a; then
2935 LIBS="-L$ipv6libdir -l$ipv6lib $LIBS"
2936 echo "using lib$ipv6lib"
2937 else
2938 if test $ipv6trylibc = "yes"; then
2939 echo "using libc"
2940 else
2941 echo 'Fatal: no $ipv6lib library found. cannot continue.'
2942 echo "You need to fetch lib$ipv6lib.a from appropriate"
2943 echo 'ipv6 kit and compile beforehand.'
2944 exit 1
2945 fi
2946 fi
2947fi
2948
Ronald Oussoren0d236eb2008-06-06 21:31:33 +00002949AC_MSG_CHECKING(for OSX 10.5 SDK or later)
Matthias Klosec511b472010-05-08 11:01:39 +00002950AC_COMPILE_IFELSE([
Mark Dickinson0712b562010-05-08 19:13:21 +00002951 AC_LANG_PROGRAM([[#include <Carbon/Carbon.h>]], [[FSIORefNum fRef = 0]])
Matthias Klosec511b472010-05-08 11:01:39 +00002952],[
Matthias Klose5183ebd2010-04-24 16:38:36 +00002953 AC_DEFINE(HAVE_OSX105_SDK, 1, [Define if compiling using MacOS X 10.5 SDK or later.])
Matthias Klosec511b472010-05-08 11:01:39 +00002954 AC_MSG_RESULT(yes)
2955],[
Ronald Oussoren0d236eb2008-06-06 21:31:33 +00002956 AC_MSG_RESULT(no)
Matthias Klosec511b472010-05-08 11:01:39 +00002957])
Ronald Oussoren0d236eb2008-06-06 21:31:33 +00002958
Martin v. Löwisa3fb4f72002-06-09 13:33:54 +00002959# Check for --with-doc-strings
2960AC_MSG_CHECKING(for --with-doc-strings)
2961AC_ARG_WITH(doc-strings,
Matthias Klose22520ea2010-05-08 10:14:46 +00002962 AS_HELP_STRING([--with(out)-doc-strings], [disable/enable documentation strings]))
Martin v. Löwisa3fb4f72002-06-09 13:33:54 +00002963
2964if test -z "$with_doc_strings"
2965then with_doc_strings="yes"
2966fi
2967if test "$with_doc_strings" != "no"
2968then
2969 AC_DEFINE(WITH_DOC_STRINGS, 1,
2970 [Define if you want documentation strings in extension modules])
2971fi
2972AC_MSG_RESULT($with_doc_strings)
2973
Neil Schemenauera35c6882001-02-27 04:45:05 +00002974# Check for Python-specific malloc support
Martin v. Löwisf30d60e2004-06-08 08:17:44 +00002975AC_MSG_CHECKING(for --with-tsc)
2976AC_ARG_WITH(tsc,
Matthias Klose22520ea2010-05-08 10:14:46 +00002977 AS_HELP_STRING([--with(out)-tsc],[enable/disable timestamp counter profile]),[
Martin v. Löwisf30d60e2004-06-08 08:17:44 +00002978if test "$withval" != no
2979then
2980 AC_DEFINE(WITH_TSC, 1,
2981 [Define to profile with the Pentium timestamp counter])
2982 AC_MSG_RESULT(yes)
2983else AC_MSG_RESULT(no)
2984fi],
2985[AC_MSG_RESULT(no)])
2986
2987# Check for Python-specific malloc support
Neil Schemenauera35c6882001-02-27 04:45:05 +00002988AC_MSG_CHECKING(for --with-pymalloc)
2989AC_ARG_WITH(pymalloc,
Matthias Klose22520ea2010-05-08 10:14:46 +00002990 AS_HELP_STRING([--with(out)-pymalloc], [disable/enable specialized mallocs]))
Neil Schemenauer16c22972002-03-22 15:34:49 +00002991
2992if test -z "$with_pymalloc"
2993then with_pymalloc="yes"
2994fi
2995if test "$with_pymalloc" != "no"
2996then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002997 AC_DEFINE(WITH_PYMALLOC, 1,
2998 [Define if you want to compile in Python-specific mallocs])
Neil Schemenauer16c22972002-03-22 15:34:49 +00002999fi
3000AC_MSG_RESULT($with_pymalloc)
Neil Schemenauera35c6882001-02-27 04:45:05 +00003001
Benjamin Peterson91c12eb2009-12-03 02:52:39 +00003002# Check for Valgrind support
3003AC_MSG_CHECKING([for --with-valgrind])
3004AC_ARG_WITH([valgrind],
Matthias Klose22520ea2010-05-08 10:14:46 +00003005 AS_HELP_STRING([--with-valgrind], [Enable Valgrind support]),,
Benjamin Peterson91c12eb2009-12-03 02:52:39 +00003006 with_valgrind=no)
3007AC_MSG_RESULT([$with_valgrind])
3008if test "$with_valgrind" != no; then
3009 AC_CHECK_HEADER([valgrind/valgrind.h],
3010 [AC_DEFINE([WITH_VALGRIND], 1, [Define if you want pymalloc to be disabled when running under valgrind])],
3011 [AC_MSG_ERROR([Valgrind support requested but headers not available])]
3012 )
3013fi
3014
Barry Warsawef82cd72000-06-30 16:21:01 +00003015# Check for --with-wctype-functions
3016AC_MSG_CHECKING(for --with-wctype-functions)
3017AC_ARG_WITH(wctype-functions,
Matthias Klose22520ea2010-05-08 10:14:46 +00003018 AS_HELP_STRING([--with-wctype-functions], [use wctype.h functions]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003019[
Barry Warsawef82cd72000-06-30 16:21:01 +00003020if test "$withval" != no
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003021then
3022 AC_DEFINE(WANT_WCTYPE_FUNCTIONS, 1,
3023 [Define if you want wctype.h functions to be used instead of the
3024 one supplied by Python itself. (see Include/unicodectype.h).])
3025 AC_MSG_RESULT(yes)
Barry Warsawef82cd72000-06-30 16:21:01 +00003026else AC_MSG_RESULT(no)
3027fi],
3028[AC_MSG_RESULT(no)])
3029
Guido van Rossum68242b51996-05-28 22:53:03 +00003030# -I${DLINCLDIR} is added to the compile rule for importdl.o
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003031AC_SUBST(DLINCLDIR)
Guido van Rossum98935bf2001-09-05 19:13:16 +00003032DLINCLDIR=.
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003033
Guido van Rossume97ee181999-12-20 21:27:22 +00003034# the dlopen() function means we might want to use dynload_shlib.o. some
3035# platforms, such as AIX, have dlopen(), but don't want to use it.
Thomas Wouters3a584202000-08-05 23:28:51 +00003036AC_CHECK_FUNCS(dlopen)
Guido van Rossume97ee181999-12-20 21:27:22 +00003037
3038# DYNLOADFILE specifies which dynload_*.o file we will use for dynamic
3039# loading of modules.
3040AC_SUBST(DYNLOADFILE)
3041AC_MSG_CHECKING(DYNLOADFILE)
3042if test -z "$DYNLOADFILE"
3043then
3044 case $ac_sys_system/$ac_sys_release in
Martin v. Löwisc19c5a62003-11-18 20:00:44 +00003045 AIX*) # Use dynload_shlib.c and dlopen() if we have it; otherwise dynload_aix.c
3046 if test "$ac_cv_func_dlopen" = yes
3047 then DYNLOADFILE="dynload_shlib.o"
3048 else DYNLOADFILE="dynload_aix.o"
3049 fi
3050 ;;
Guido van Rossume97ee181999-12-20 21:27:22 +00003051 BeOS*) DYNLOADFILE="dynload_beos.o";;
3052 hp*|HP*) DYNLOADFILE="dynload_hpux.o";;
Anthony Baxter82201742006-04-09 15:07:40 +00003053 # Use dynload_next.c only on 10.2 and below, which don't have native dlopen()
3054 Darwin/@<:@0156@:>@\..*) DYNLOADFILE="dynload_next.o";;
Martin v. Löwisf90ae202002-06-11 06:22:31 +00003055 atheos*) DYNLOADFILE="dynload_atheos.o";;
Guido van Rossume97ee181999-12-20 21:27:22 +00003056 *)
3057 # use dynload_shlib.c and dlopen() if we have it; otherwise stub
3058 # out any dynamic loading
3059 if test "$ac_cv_func_dlopen" = yes
3060 then DYNLOADFILE="dynload_shlib.o"
3061 else DYNLOADFILE="dynload_stub.o"
3062 fi
3063 ;;
3064 esac
3065fi
3066AC_MSG_RESULT($DYNLOADFILE)
3067if test "$DYNLOADFILE" != "dynload_stub.o"
3068then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003069 AC_DEFINE(HAVE_DYNAMIC_LOADING, 1,
3070 [Defined when any dynamic module loading is enabled.])
Guido van Rossume97ee181999-12-20 21:27:22 +00003071fi
3072
Jack Jansenc49e5b72001-06-19 15:00:23 +00003073# MACHDEP_OBJS can be set to platform-specific object files needed by Python
3074
3075AC_SUBST(MACHDEP_OBJS)
3076AC_MSG_CHECKING(MACHDEP_OBJS)
3077if test -z "$MACHDEP_OBJS"
3078then
Jack Jansenb6e9cad2001-08-15 01:26:28 +00003079 MACHDEP_OBJS=$extra_machdep_objs
3080else
3081 MACHDEP_OBJS="$MACHDEP_OBJS $extra_machdep_objs"
Jack Jansenc49e5b72001-06-19 15:00:23 +00003082fi
Jack Jansenb6e9cad2001-08-15 01:26:28 +00003083AC_MSG_RESULT(MACHDEP_OBJS)
Jack Jansenc49e5b72001-06-19 15:00:23 +00003084
Guido van Rossum627b2d71993-12-24 10:39:16 +00003085# checks for library functions
Martin v. Löwisaef18b12008-03-24 13:31:16 +00003086AC_CHECK_FUNCS(alarm setitimer getitimer bind_textdomain_codeset chown \
3087 clock confstr ctermid execv fchmod fchown fork fpathconf ftime ftruncate \
Martin v. Löwis438b5342002-12-27 10:16:42 +00003088 gai_strerror getgroups getlogin getloadavg getpeername getpgid getpid \
Benjamin Peterson27c269a2014-12-26 11:09:00 -06003089 getentropy \
Martin v. Löwis50ea4562009-11-27 13:56:01 +00003090 getpriority getresuid getresgid getpwent getspnam getspent getsid getwd \
Benjamin Petersond16e01c2014-02-04 10:20:26 -05003091 initgroups kill killpg lchmod lchown lstat mkfifo mknod mktime mmap \
Martin v. Löwisa5f09072002-10-11 05:37:59 +00003092 mremap nice pathconf pause plock poll pthread_init \
Guido van Rossum162e38c2003-02-19 15:25:10 +00003093 putenv readlink realpath \
Jesse Noller355b1262009-04-02 00:03:28 +00003094 select sem_open sem_timedwait sem_getvalue sem_unlink setegid seteuid \
3095 setgid \
Martin v. Löwis4daacb12003-03-28 18:37:01 +00003096 setlocale setregid setreuid setsid setpgid setpgrp setuid setvbuf snprintf \
Martin v. Löwis50ea4562009-11-27 13:56:01 +00003097 setlocale setregid setreuid setresuid setresgid \
3098 setsid setpgid setpgrp setuid setvbuf snprintf \
Skip Montanaro7e11a012004-02-07 12:55:46 +00003099 sigaction siginterrupt sigrelse strftime \
Michael W. Hudson34f20ea2002-05-27 15:08:24 +00003100 sysconf tcgetpgrp tcsetpgrp tempnam timegm times tmpfile tmpnam tmpnam_r \
Neal Norwitz05a45592006-03-20 06:30:08 +00003101 truncate uname unsetenv utimes waitpid wait3 wait4 wcscoll _getpty)
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00003102
Martin v. Löwisc8ad7cc2002-11-11 13:23:45 +00003103# For some functions, having a definition is not sufficient, since
3104# we want to take their address.
3105AC_MSG_CHECKING(for chroot)
Matthias Klosec511b472010-05-08 11:01:39 +00003106AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[void *x=chroot]])],
3107 [AC_DEFINE(HAVE_CHROOT, 1, Define if you have the 'chroot' function.)
3108 AC_MSG_RESULT(yes)],
3109 [AC_MSG_RESULT(no)
3110])
Martin v. Löwisc8ad7cc2002-11-11 13:23:45 +00003111AC_MSG_CHECKING(for link)
Matthias Klosec511b472010-05-08 11:01:39 +00003112AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[void *x=link]])],
3113 [AC_DEFINE(HAVE_LINK, 1, Define if you have the 'link' function.)
3114 AC_MSG_RESULT(yes)],
3115 [AC_MSG_RESULT(no)
3116])
Martin v. Löwisc8ad7cc2002-11-11 13:23:45 +00003117AC_MSG_CHECKING(for symlink)
Matthias Klosec511b472010-05-08 11:01:39 +00003118AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[void *x=symlink]])],
3119 [AC_DEFINE(HAVE_SYMLINK, 1, Define if you have the 'symlink' function.)
3120 AC_MSG_RESULT(yes)],
3121 [AC_MSG_RESULT(no)
3122])
Martin v. Löwisa64988c2003-09-20 15:30:20 +00003123AC_MSG_CHECKING(for fchdir)
Matthias Klosec511b472010-05-08 11:01:39 +00003124AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[void *x=fchdir]])],
3125 [AC_DEFINE(HAVE_FCHDIR, 1, Define if you have the 'fchdir' function.)
3126 AC_MSG_RESULT(yes)],
3127 [AC_MSG_RESULT(no)
3128])
Martin v. Löwisa64988c2003-09-20 15:30:20 +00003129AC_MSG_CHECKING(for fsync)
Matthias Klosec511b472010-05-08 11:01:39 +00003130AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[void *x=fsync]])],
3131 [AC_DEFINE(HAVE_FSYNC, 1, Define if you have the 'fsync' function.)
3132 AC_MSG_RESULT(yes)],
3133 [AC_MSG_RESULT(no)
3134])
Martin v. Löwisa64988c2003-09-20 15:30:20 +00003135AC_MSG_CHECKING(for fdatasync)
Matthias Klosec511b472010-05-08 11:01:39 +00003136AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[void *x=fdatasync]])],
3137 [AC_DEFINE(HAVE_FDATASYNC, 1, Define if you have the 'fdatasync' function.)
3138 AC_MSG_RESULT(yes)],
3139 [AC_MSG_RESULT(no)
3140])
Christian Heimes0e9ab5f2008-03-21 23:49:44 +00003141AC_MSG_CHECKING(for epoll)
Matthias Klosec511b472010-05-08 11:01:39 +00003142AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/epoll.h>]], [[void *x=epoll_create]])],
3143 [AC_DEFINE(HAVE_EPOLL, 1, Define if you have the 'epoll' functions.)
3144 AC_MSG_RESULT(yes)],
3145 [AC_MSG_RESULT(no)
3146])
Christian Heimes0e9ab5f2008-03-21 23:49:44 +00003147AC_MSG_CHECKING(for kqueue)
Matthias Klosec511b472010-05-08 11:01:39 +00003148AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Christian Heimes0e9ab5f2008-03-21 23:49:44 +00003149#include <sys/types.h>
3150#include <sys/event.h>
Matthias Klosec511b472010-05-08 11:01:39 +00003151 ]], [[int x=kqueue()]])],
3152 [AC_DEFINE(HAVE_KQUEUE, 1, Define if you have the 'kqueue' functions.)
3153 AC_MSG_RESULT(yes)],
3154 [AC_MSG_RESULT(no)
3155])
Martin v. Löwisd5843682002-11-21 20:41:28 +00003156# On some systems (eg. FreeBSD 5), we would find a definition of the
3157# functions ctermid_r, setgroups in the library, but no prototype
3158# (e.g. because we use _XOPEN_SOURCE). See whether we can take their
3159# address to avoid compiler warnings and potential miscompilations
3160# because of the missing prototypes.
3161
3162AC_MSG_CHECKING(for ctermid_r)
Matthias Klosec511b472010-05-08 11:01:39 +00003163AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwisd5843682002-11-21 20:41:28 +00003164#include <stdio.h>
Matthias Klosec511b472010-05-08 11:01:39 +00003165]], [[void* p = ctermid_r]])],
3166 [AC_DEFINE(HAVE_CTERMID_R, 1, Define if you have the 'ctermid_r' function.)
3167 AC_MSG_RESULT(yes)],
3168 [AC_MSG_RESULT(no)
3169])
Martin v. Löwisd5843682002-11-21 20:41:28 +00003170
Antoine Pitroub170f172010-09-10 18:47:36 +00003171AC_CACHE_CHECK([for flock declaration], [ac_cv_flock_decl],
3172 [AC_COMPILE_IFELSE(
3173 [AC_LANG_PROGRAM(
3174 [#include <sys/file.h>],
3175 [void* p = flock]
3176 )],
3177 [ac_cv_flock_decl=yes],
3178 [ac_cv_flock_decl=no]
3179 )
Matthias Klosec511b472010-05-08 11:01:39 +00003180])
Antoine Pitroub170f172010-09-10 18:47:36 +00003181if test "x${ac_cv_flock_decl}" = xyes; then
3182 AC_CHECK_FUNCS(flock,,
3183 AC_CHECK_LIB(bsd,flock,
3184 [AC_DEFINE(HAVE_FLOCK)
3185 AC_DEFINE(FLOCK_NEEDS_LIBBSD, 1, Define if flock needs to be linked with bsd library.)
3186 ])
3187 )
Antoine Pitrou85729812010-09-07 14:55:24 +00003188fi
Martin v. Löwisf26d63b2003-03-30 17:23:49 +00003189
3190AC_MSG_CHECKING(for getpagesize)
Matthias Klosec511b472010-05-08 11:01:39 +00003191AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwisf26d63b2003-03-30 17:23:49 +00003192#include <unistd.h>
Matthias Klosec511b472010-05-08 11:01:39 +00003193]], [[void* p = getpagesize]])],
3194 [AC_DEFINE(HAVE_GETPAGESIZE, 1, Define if you have the 'getpagesize' function.)
3195 AC_MSG_RESULT(yes)],
3196 [AC_MSG_RESULT(no)
3197])
Martin v. Löwisf26d63b2003-03-30 17:23:49 +00003198
Charles-François Natali93a11752011-11-27 13:01:35 +01003199AC_MSG_CHECKING(for broken unsetenv)
3200AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3201#include <stdlib.h>
3202]], [[int res = unsetenv("DUMMY")]])],
3203 [AC_MSG_RESULT(no)],
3204 [AC_DEFINE(HAVE_BROKEN_UNSETENV, 1, Define if `unsetenv` does not return an int.)
3205 AC_MSG_RESULT(yes)
3206])
3207
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00003208dnl check for true
3209AC_CHECK_PROGS(TRUE, true, /bin/true)
3210
Martin v. Löwis95c419b2003-05-03 12:10:48 +00003211dnl On some systems (e.g. Solaris 9), hstrerror and inet_aton are in -lresolv
3212dnl On others, they are in the C library, so we to take no action
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00003213AC_CHECK_LIB(c, inet_aton, [$ac_cv_prog_TRUE],
Martin v. Löwis95c419b2003-05-03 12:10:48 +00003214 AC_CHECK_LIB(resolv, inet_aton)
3215)
3216
Martin v. Löwisa51d5c82007-12-04 08:37:59 +00003217# On Tru64, chflags seems to be present, but calling it will
3218# exit Python
Gregory P. Smithbb213892009-11-02 01:37:37 +00003219AC_CACHE_CHECK([for chflags], [ac_cv_have_chflags], [dnl
Ned Deily43e10542011-06-27 23:41:53 -07003220AC_RUN_IFELSE([AC_LANG_SOURCE([[
Martin v. Löwisa51d5c82007-12-04 08:37:59 +00003221#include <sys/stat.h>
3222#include <unistd.h>
3223int main(int argc, char*argv[])
3224{
3225 if(chflags(argv[0], 0) != 0)
3226 return 1;
3227 return 0;
3228}
Ned Deily43e10542011-06-27 23:41:53 -07003229]])],
Matthias Klosec511b472010-05-08 11:01:39 +00003230[ac_cv_have_chflags=yes],
3231[ac_cv_have_chflags=no],
3232[ac_cv_have_chflags=cross])
Gregory P. Smithbb213892009-11-02 01:37:37 +00003233])
3234if test "$ac_cv_have_chflags" = cross ; then
3235 AC_CHECK_FUNC([chflags], [ac_cv_have_chflags="yes"], [ac_cv_have_chflags="no"])
3236fi
3237if test "$ac_cv_have_chflags" = yes ; then
Ned Deily43e10542011-06-27 23:41:53 -07003238 AC_DEFINE(HAVE_CHFLAGS, 1, [Define to 1 if you have the 'chflags' function.])
Alexandre Vassalotti00900892009-07-17 05:26:39 +00003239fi
Martin v. Löwisa51d5c82007-12-04 08:37:59 +00003240
Gregory P. Smithbb213892009-11-02 01:37:37 +00003241AC_CACHE_CHECK([for lchflags], [ac_cv_have_lchflags], [dnl
Ned Deily43e10542011-06-27 23:41:53 -07003242AC_RUN_IFELSE([AC_LANG_SOURCE([[
Martin v. Löwisa51d5c82007-12-04 08:37:59 +00003243#include <sys/stat.h>
3244#include <unistd.h>
3245int main(int argc, char*argv[])
3246{
3247 if(lchflags(argv[0], 0) != 0)
3248 return 1;
3249 return 0;
3250}
Ned Deily43e10542011-06-27 23:41:53 -07003251]])],[ac_cv_have_lchflags=yes],[ac_cv_have_lchflags=no],[ac_cv_have_lchflags=cross])
Gregory P. Smithbb213892009-11-02 01:37:37 +00003252])
3253if test "$ac_cv_have_lchflags" = cross ; then
3254 AC_CHECK_FUNC([lchflags], [ac_cv_have_lchflags="yes"], [ac_cv_have_lchflags="no"])
3255fi
3256if test "$ac_cv_have_lchflags" = yes ; then
Ned Deily43e10542011-06-27 23:41:53 -07003257 AC_DEFINE(HAVE_LCHFLAGS, 1, [Define to 1 if you have the 'lchflags' function.])
Alexandre Vassalotti00900892009-07-17 05:26:39 +00003258fi
Martin v. Löwisa51d5c82007-12-04 08:37:59 +00003259
Neal Norwitz6e73aaa2006-06-12 03:33:09 +00003260dnl Check if system zlib has *Copy() functions
Ronald Oussorenf8752642006-07-06 10:13:35 +00003261dnl
3262dnl On MacOSX the linker will search for dylibs on the entire linker path
3263dnl before searching for static libraries. setup.py adds -Wl,-search_paths_first
3264dnl to revert to a more traditional unix behaviour and make it possible to
3265dnl override the system libz with a local static library of libz. Temporarily
3266dnl add that flag to our CFLAGS as well to ensure that we check the version
3267dnl of libz that will be used by setup.py.
3268dnl The -L/usr/local/lib is needed as wel to get the same compilation
3269dnl environment as setup.py (and leaving it out can cause configure to use the
3270dnl wrong version of the library)
3271case $ac_sys_system/$ac_sys_release in
3272Darwin/*)
3273 _CUR_CFLAGS="${CFLAGS}"
3274 _CUR_LDFLAGS="${LDFLAGS}"
3275 CFLAGS="${CFLAGS} -Wl,-search_paths_first"
3276 LDFLAGS="${LDFLAGS} -Wl,-search_paths_first -L/usr/local/lib"
3277 ;;
3278esac
3279
Matthias Klose5183ebd2010-04-24 16:38:36 +00003280AC_CHECK_LIB(z, inflateCopy, AC_DEFINE(HAVE_ZLIB_COPY, 1, [Define if the zlib library has inflateCopy]))
Neal Norwitz6e73aaa2006-06-12 03:33:09 +00003281
Ronald Oussorenf8752642006-07-06 10:13:35 +00003282case $ac_sys_system/$ac_sys_release in
3283Darwin/*)
3284 CFLAGS="${_CUR_CFLAGS}"
3285 LDFLAGS="${_CUR_LDFLAGS}"
3286 ;;
3287esac
3288
Martin v. Löwise9416172003-05-03 10:12:45 +00003289AC_MSG_CHECKING(for hstrerror)
Matthias Klosec511b472010-05-08 11:01:39 +00003290AC_LINK_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwise9416172003-05-03 10:12:45 +00003291#include <netdb.h>
Matthias Klosec511b472010-05-08 11:01:39 +00003292]], [[void* p = hstrerror; hstrerror(0)]])],
3293 [AC_DEFINE(HAVE_HSTRERROR, 1, Define if you have the 'hstrerror' function.)
3294 AC_MSG_RESULT(yes)],
3295 [AC_MSG_RESULT(no)
3296])
Martin v. Löwise9416172003-05-03 10:12:45 +00003297
3298AC_MSG_CHECKING(for inet_aton)
Matthias Klosec511b472010-05-08 11:01:39 +00003299AC_LINK_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwis86d66262006-02-17 08:40:11 +00003300#include <sys/types.h>
Martin v. Löwise9416172003-05-03 10:12:45 +00003301#include <sys/socket.h>
3302#include <netinet/in.h>
3303#include <arpa/inet.h>
Matthias Klosec511b472010-05-08 11:01:39 +00003304]], [[void* p = inet_aton;inet_aton(0,0)]])],
3305 [AC_DEFINE(HAVE_INET_ATON, 1, Define if you have the 'inet_aton' function.)
3306 AC_MSG_RESULT(yes)],
3307 [AC_MSG_RESULT(no)
3308])
Martin v. Löwise9416172003-05-03 10:12:45 +00003309
3310AC_MSG_CHECKING(for inet_pton)
Matthias Klosec511b472010-05-08 11:01:39 +00003311AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwisf2e488d2003-05-05 22:00:11 +00003312#include <sys/types.h>
Martin v. Löwise9416172003-05-03 10:12:45 +00003313#include <sys/socket.h>
3314#include <netinet/in.h>
3315#include <arpa/inet.h>
Matthias Klosec511b472010-05-08 11:01:39 +00003316]], [[void* p = inet_pton]])],
3317 [AC_DEFINE(HAVE_INET_PTON, 1, Define if you have the 'inet_pton' function.)
3318 AC_MSG_RESULT(yes)],
3319 [AC_MSG_RESULT(no)
3320])
Martin v. Löwise9416172003-05-03 10:12:45 +00003321
Martin v. Löwisd6640d42003-07-06 09:29:52 +00003322# On some systems, setgroups is in unistd.h, on others, in grp.h
Martin v. Löwisd5843682002-11-21 20:41:28 +00003323AC_MSG_CHECKING(for setgroups)
Matthias Klosec511b472010-05-08 11:01:39 +00003324AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwisf2e488d2003-05-05 22:00:11 +00003325#include <unistd.h>
Martin v. Löwisd6640d42003-07-06 09:29:52 +00003326#ifdef HAVE_GRP_H
3327#include <grp.h>
3328#endif
Matthias Klosec511b472010-05-08 11:01:39 +00003329]], [[void* p = setgroups]])],
3330 [AC_DEFINE(HAVE_SETGROUPS, 1, Define if you have the 'setgroups' function.)
3331 AC_MSG_RESULT(yes)],
3332 [AC_MSG_RESULT(no)
3333])
Martin v. Löwisd5843682002-11-21 20:41:28 +00003334
Fred Drake8cef4cf2000-06-28 16:40:38 +00003335# check for openpty and forkpty
3336
Martin v. Löwisfd9a72a2006-01-08 10:07:33 +00003337AC_CHECK_FUNCS(openpty,,
3338 AC_CHECK_LIB(util,openpty,
3339 [AC_DEFINE(HAVE_OPENPTY) LIBS="$LIBS -lutil"],
3340 AC_CHECK_LIB(bsd,openpty, [AC_DEFINE(HAVE_OPENPTY) LIBS="$LIBS -lbsd"])
3341 )
3342)
3343AC_CHECK_FUNCS(forkpty,,
3344 AC_CHECK_LIB(util,forkpty,
3345 [AC_DEFINE(HAVE_FORKPTY) LIBS="$LIBS -lutil"],
3346 AC_CHECK_LIB(bsd,forkpty, [AC_DEFINE(HAVE_FORKPTY) LIBS="$LIBS -lbsd"])
3347 )
3348)
Fred Drake8cef4cf2000-06-28 16:40:38 +00003349
Brett Cannonaa5778d2008-03-18 04:09:00 +00003350# Stuff for expat.
3351AC_CHECK_FUNCS(memmove)
3352
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00003353# check for long file support functions
3354AC_CHECK_FUNCS(fseek64 fseeko fstatvfs ftell64 ftello statvfs)
3355
Brett Cannonaa5778d2008-03-18 04:09:00 +00003356AC_REPLACE_FUNCS(dup2 getcwd strdup)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003357AC_CHECK_FUNCS(getpgrp,
Matthias Klosec511b472010-05-08 11:01:39 +00003358 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[getpgrp(0);]])],
3359 [AC_DEFINE(GETPGRP_HAVE_ARG, 1, [Define if getpgrp() must be called as getpgrp(0).])],
3360 [])
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003361)
Jack Jansen150753c2003-03-29 22:07:47 +00003362AC_CHECK_FUNCS(setpgrp,
Matthias Klosec511b472010-05-08 11:01:39 +00003363 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[setpgrp(0,0);]])],
3364 [AC_DEFINE(SETPGRP_HAVE_ARG, 1, [Define if setpgrp() must be called as setpgrp(0, 0).])],
3365 [])
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003366)
3367AC_CHECK_FUNCS(gettimeofday,
Matthias Klosec511b472010-05-08 11:01:39 +00003368 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/time.h>]],
3369 [[gettimeofday((struct timeval*)0,(struct timezone*)0);]])],
3370 [],
3371 [AC_DEFINE(GETTIMEOFDAY_NO_TZ, 1,
3372 [Define if gettimeofday() does not have second (timezone) argument
3373 This is the case on Motorola V4 (R40V4.2)])
3374 ])
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003375)
Guido van Rossum627b2d71993-12-24 10:39:16 +00003376
Martin v. Löwisdbe3f762002-10-10 14:27:30 +00003377AC_MSG_CHECKING(for major, minor, and makedev)
Matthias Klosec511b472010-05-08 11:01:39 +00003378AC_LINK_IFELSE([AC_LANG_PROGRAM([[
Neal Norwitz6eb37f02003-02-23 23:28:15 +00003379#if defined(MAJOR_IN_MKDEV)
3380#include <sys/mkdev.h>
3381#elif defined(MAJOR_IN_SYSMACROS)
3382#include <sys/sysmacros.h>
3383#else
3384#include <sys/types.h>
3385#endif
Matthias Klosec511b472010-05-08 11:01:39 +00003386]], [[
Martin v. Löwisdbe3f762002-10-10 14:27:30 +00003387 makedev(major(0),minor(0));
Matthias Klosec511b472010-05-08 11:01:39 +00003388]])],[
Martin v. Löwisdbe3f762002-10-10 14:27:30 +00003389 AC_DEFINE(HAVE_DEVICE_MACROS, 1,
3390 [Define to 1 if you have the device macros.])
3391 AC_MSG_RESULT(yes)
3392],[
3393 AC_MSG_RESULT(no)
3394])
Martin v. Löwis861a65b2001-10-24 14:36:00 +00003395
3396# On OSF/1 V5.1, getaddrinfo is available, but a define
3397# for [no]getaddrinfo in netdb.h.
3398AC_MSG_CHECKING(for getaddrinfo)
Matthias Klosec511b472010-05-08 11:01:39 +00003399AC_LINK_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwisc010b6d2001-11-09 17:50:52 +00003400#include <sys/types.h>
Martin v. Löwis861a65b2001-10-24 14:36:00 +00003401#include <sys/socket.h>
3402#include <netdb.h>
Martin v. Löwisc010b6d2001-11-09 17:50:52 +00003403#include <stdio.h>
Matthias Klosec511b472010-05-08 11:01:39 +00003404]], [[getaddrinfo(NULL, NULL, NULL, NULL);]])],
3405[have_getaddrinfo=yes],
3406[have_getaddrinfo=no])
Alexandre Vassalotti00900892009-07-17 05:26:39 +00003407AC_MSG_RESULT($have_getaddrinfo)
3408if test $have_getaddrinfo = yes
3409then
3410 AC_MSG_CHECKING(getaddrinfo bug)
3411 AC_CACHE_VAL(ac_cv_buggy_getaddrinfo,
Matthias Klosec511b472010-05-08 11:01:39 +00003412 AC_RUN_IFELSE([AC_LANG_SOURCE([[[
Stefan Krah0afe4e42012-11-22 23:56:51 +01003413#include <stdio.h>
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003414#include <sys/types.h>
3415#include <netdb.h>
3416#include <string.h>
3417#include <sys/socket.h>
3418#include <netinet/in.h>
3419
Alexandre Vassalotti00900892009-07-17 05:26:39 +00003420int main()
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003421{
3422 int passive, gaierr, inet4 = 0, inet6 = 0;
3423 struct addrinfo hints, *ai, *aitop;
3424 char straddr[INET6_ADDRSTRLEN], strport[16];
3425
3426 for (passive = 0; passive <= 1; passive++) {
3427 memset(&hints, 0, sizeof(hints));
3428 hints.ai_family = AF_UNSPEC;
3429 hints.ai_flags = passive ? AI_PASSIVE : 0;
3430 hints.ai_socktype = SOCK_STREAM;
Hye-Shik Chang54f94392004-04-14 07:55:31 +00003431 hints.ai_protocol = IPPROTO_TCP;
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003432 if ((gaierr = getaddrinfo(NULL, "54321", &hints, &aitop)) != 0) {
3433 (void)gai_strerror(gaierr);
3434 goto bad;
3435 }
3436 for (ai = aitop; ai; ai = ai->ai_next) {
3437 if (ai->ai_addr == NULL ||
3438 ai->ai_addrlen == 0 ||
3439 getnameinfo(ai->ai_addr, ai->ai_addrlen,
3440 straddr, sizeof(straddr), strport, sizeof(strport),
3441 NI_NUMERICHOST|NI_NUMERICSERV) != 0) {
3442 goto bad;
3443 }
3444 switch (ai->ai_family) {
3445 case AF_INET:
3446 if (strcmp(strport, "54321") != 0) {
3447 goto bad;
3448 }
3449 if (passive) {
3450 if (strcmp(straddr, "0.0.0.0") != 0) {
3451 goto bad;
3452 }
3453 } else {
3454 if (strcmp(straddr, "127.0.0.1") != 0) {
3455 goto bad;
3456 }
3457 }
3458 inet4++;
3459 break;
3460 case AF_INET6:
3461 if (strcmp(strport, "54321") != 0) {
3462 goto bad;
3463 }
3464 if (passive) {
3465 if (strcmp(straddr, "::") != 0) {
3466 goto bad;
3467 }
3468 } else {
3469 if (strcmp(straddr, "::1") != 0) {
3470 goto bad;
3471 }
3472 }
3473 inet6++;
3474 break;
3475 case AF_UNSPEC:
3476 goto bad;
3477 break;
3478 default:
3479 /* another family support? */
3480 break;
3481 }
3482 }
Benjamin Petersond34677c2016-09-06 15:54:24 -07003483 freeaddrinfo(aitop);
3484 aitop = NULL;
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003485 }
3486
3487 if (!(inet4 == 0 || inet4 == 2))
3488 goto bad;
3489 if (!(inet6 == 0 || inet6 == 2))
3490 goto bad;
3491
3492 if (aitop)
3493 freeaddrinfo(aitop);
Alexandre Vassalotti00900892009-07-17 05:26:39 +00003494 return 0;
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003495
3496 bad:
3497 if (aitop)
3498 freeaddrinfo(aitop);
Alexandre Vassalotti00900892009-07-17 05:26:39 +00003499 return 1;
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003500}
Matthias Klosec511b472010-05-08 11:01:39 +00003501]]])],
3502[ac_cv_buggy_getaddrinfo=no],
3503[ac_cv_buggy_getaddrinfo=yes],
doko@python.orgd65e2ba2013-01-31 23:52:03 +01003504[
3505if test "${enable_ipv6+set}" = set; then
3506 ac_cv_buggy_getaddrinfo="no -- configured with --(en|dis)able-ipv6"
3507else
3508 ac_cv_buggy_getaddrinfo=yes
3509fi]))
Alexandre Vassalotti00900892009-07-17 05:26:39 +00003510fi
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003511
Benjamin Peterson75fed812010-11-01 01:47:19 +00003512AC_MSG_RESULT($ac_cv_buggy_getaddrinfo)
3513
Mark Dickinson0ef0b912009-12-31 21:11:48 +00003514if test $have_getaddrinfo = no -o "$ac_cv_buggy_getaddrinfo" = yes
Alexandre Vassalotti00900892009-07-17 05:26:39 +00003515then
3516 if test $ipv6 = yes
3517 then
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003518 echo 'Fatal: You must get working getaddrinfo() function.'
3519 echo ' or you can specify "--disable-ipv6"'.
3520 exit 1
3521 fi
Martin v. Löwis861a65b2001-10-24 14:36:00 +00003522else
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003523 AC_DEFINE(HAVE_GETADDRINFO, 1, [Define if you have the getaddrinfo function.])
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003524fi
Benjamin Peterson75fed812010-11-01 01:47:19 +00003525
Thomas Woutersb0db85a2001-08-08 10:39:03 +00003526AC_CHECK_FUNCS(getnameinfo)
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003527
Guido van Rossum627b2d71993-12-24 10:39:16 +00003528# checks for structures
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003529AC_HEADER_TIME
Guido van Rossum627b2d71993-12-24 10:39:16 +00003530AC_STRUCT_TM
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003531AC_STRUCT_TIMEZONE
Martin v. Löwis60a5d722002-10-16 20:28:25 +00003532AC_CHECK_MEMBERS([struct stat.st_rdev])
3533AC_CHECK_MEMBERS([struct stat.st_blksize])
Hye-Shik Chang5f937a72005-06-02 13:09:30 +00003534AC_CHECK_MEMBERS([struct stat.st_flags])
Martin v. Löwisebd9d5b2005-08-09 15:00:59 +00003535AC_CHECK_MEMBERS([struct stat.st_gen])
3536AC_CHECK_MEMBERS([struct stat.st_birthtime])
Martin Pantera45120d2016-03-18 02:36:41 +00003537AC_CHECK_MEMBERS([struct stat.st_blocks])
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003538
3539AC_MSG_CHECKING(for time.h that defines altzone)
Matthias Klosec511b472010-05-08 11:01:39 +00003540AC_CACHE_VAL(ac_cv_header_time_altzone,[
3541 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <time.h>]], [[return altzone;]])],
3542 [ac_cv_header_time_altzone=yes],
3543 [ac_cv_header_time_altzone=no])
3544 ])
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003545AC_MSG_RESULT($ac_cv_header_time_altzone)
3546if test $ac_cv_header_time_altzone = yes; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003547 AC_DEFINE(HAVE_ALTZONE, 1, [Define this if your time.h defines altzone.])
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003548fi
3549
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003550was_it_defined=no
3551AC_MSG_CHECKING(whether sys/select.h and sys/time.h may both be included)
Matthias Klosec511b472010-05-08 11:01:39 +00003552AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003553#include <sys/types.h>
3554#include <sys/select.h>
3555#include <sys/time.h>
Matthias Klosec511b472010-05-08 11:01:39 +00003556]], [[;]])],[
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003557 AC_DEFINE(SYS_SELECT_WITH_SYS_TIME, 1,
3558 [Define if you can safely include both <sys/select.h> and <sys/time.h>
3559 (which you can't on SCO ODT 3.0).])
3560 was_it_defined=yes
Matthias Klosec511b472010-05-08 11:01:39 +00003561],[])
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003562AC_MSG_RESULT($was_it_defined)
Guido van Rossum627b2d71993-12-24 10:39:16 +00003563
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003564AC_MSG_CHECKING(for addrinfo)
3565AC_CACHE_VAL(ac_cv_struct_addrinfo,
Matthias Klosec511b472010-05-08 11:01:39 +00003566AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <netdb.h>]], [[struct addrinfo a]])],
3567 [ac_cv_struct_addrinfo=yes],
3568 [ac_cv_struct_addrinfo=no]))
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003569AC_MSG_RESULT($ac_cv_struct_addrinfo)
3570if test $ac_cv_struct_addrinfo = yes; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003571 AC_DEFINE(HAVE_ADDRINFO, 1, [struct addrinfo (netdb.h)])
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003572fi
3573
3574AC_MSG_CHECKING(for sockaddr_storage)
3575AC_CACHE_VAL(ac_cv_struct_sockaddr_storage,
Matthias Klosec511b472010-05-08 11:01:39 +00003576AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003577# include <sys/types.h>
Matthias Klosec511b472010-05-08 11:01:39 +00003578# include <sys/socket.h>]], [[struct sockaddr_storage s]])],
3579 [ac_cv_struct_sockaddr_storage=yes],
3580 [ac_cv_struct_sockaddr_storage=no]))
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003581AC_MSG_RESULT($ac_cv_struct_sockaddr_storage)
3582if test $ac_cv_struct_sockaddr_storage = yes; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003583 AC_DEFINE(HAVE_SOCKADDR_STORAGE, 1, [struct sockaddr_storage (sys/socket.h)])
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003584fi
3585
Guido van Rossum627b2d71993-12-24 10:39:16 +00003586# checks for compiler characteristics
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003587
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003588AC_C_CHAR_UNSIGNED
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003589AC_C_CONST
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003590
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003591works=no
3592AC_MSG_CHECKING(for working volatile)
Matthias Klosec511b472010-05-08 11:01:39 +00003593AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[volatile int x; x = 0;]])],
3594 [works=yes],
3595 [AC_DEFINE(volatile, , [Define to empty if the keyword does not work.])]
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003596)
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003597AC_MSG_RESULT($works)
Guido van Rossumdabb11b1994-10-11 15:04:27 +00003598
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003599works=no
3600AC_MSG_CHECKING(for working signed char)
Matthias Klosec511b472010-05-08 11:01:39 +00003601AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[signed char c;]])],
3602 [works=yes],
3603 [AC_DEFINE(signed, , [Define to empty if the keyword does not work.])]
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003604)
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003605AC_MSG_RESULT($works)
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003606
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003607have_prototypes=no
3608AC_MSG_CHECKING(for prototypes)
Matthias Klosec511b472010-05-08 11:01:39 +00003609AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[int foo(int x) { return 0; }]], [[return foo(10);]])],
3610 [AC_DEFINE(HAVE_PROTOTYPES, 1,
3611 [Define if your compiler supports function prototype])
3612 have_prototypes=yes],
3613 []
3614)
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003615AC_MSG_RESULT($have_prototypes)
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003616
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003617works=no
3618AC_MSG_CHECKING(for variable length prototypes and stdarg.h)
Matthias Klosec511b472010-05-08 11:01:39 +00003619AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003620#include <stdarg.h>
Guido van Rossum3f13e481996-08-30 20:58:11 +00003621int foo(int x, ...) {
3622 va_list va;
3623 va_start(va, x);
3624 va_arg(va, int);
3625 va_arg(va, char *);
3626 va_arg(va, double);
3627 return 0;
3628}
Matthias Klosec511b472010-05-08 11:01:39 +00003629]], [[return foo(10, "", 3.14);]])],[
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003630 AC_DEFINE(HAVE_STDARG_PROTOTYPES, 1,
3631 [Define if your compiler supports variable length function prototypes
3632 (e.g. void fprintf(FILE *, char *, ...);) *and* <stdarg.h>])
3633 works=yes
Matthias Klosec511b472010-05-08 11:01:39 +00003634],[])
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003635AC_MSG_RESULT($works)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003636
Dave Cole331708b2004-08-09 04:51:41 +00003637# check for socketpair
3638AC_MSG_CHECKING(for socketpair)
Matthias Klosec511b472010-05-08 11:01:39 +00003639AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Dave Cole331708b2004-08-09 04:51:41 +00003640#include <sys/types.h>
3641#include <sys/socket.h>
Matthias Klosec511b472010-05-08 11:01:39 +00003642]], [[void *x=socketpair]])],
3643 [AC_DEFINE(HAVE_SOCKETPAIR, 1, [Define if you have the 'socketpair' function.])
3644 AC_MSG_RESULT(yes)],
3645 [AC_MSG_RESULT(no)]
Dave Cole331708b2004-08-09 04:51:41 +00003646)
3647
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003648# check if sockaddr has sa_len member
3649AC_MSG_CHECKING(if sockaddr has sa_len member)
Matthias Klosec511b472010-05-08 11:01:39 +00003650AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
3651#include <sys/socket.h>]], [[struct sockaddr x;
3652x.sa_len = 0;]])],
3653 [AC_MSG_RESULT(yes)
3654 AC_DEFINE(HAVE_SOCKADDR_SA_LEN, 1, [Define if sockaddr has sa_len member])],
3655 [AC_MSG_RESULT(no)]
3656)
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003657
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003658va_list_is_array=no
3659AC_MSG_CHECKING(whether va_list is an array)
Matthias Klosec511b472010-05-08 11:01:39 +00003660AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003661#ifdef HAVE_STDARG_PROTOTYPES
3662#include <stdarg.h>
3663#else
3664#include <varargs.h>
3665#endif
Matthias Klosec511b472010-05-08 11:01:39 +00003666]], [[va_list list1, list2; list1 = list2;]])],[],[
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003667 AC_DEFINE(VA_LIST_IS_ARRAY, 1, [Define if a va_list is an array of some kind])
3668 va_list_is_array=yes
3669])
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003670AC_MSG_RESULT($va_list_is_array)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003671
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003672# sigh -- gethostbyname_r is a mess; it can have 3, 5 or 6 arguments :-(
Martin v. Löwis11437992002-04-12 09:54:03 +00003673AH_TEMPLATE(HAVE_GETHOSTBYNAME_R,
3674 [Define this if you have some version of gethostbyname_r()])
3675
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003676AC_CHECK_FUNC(gethostbyname_r, [
3677 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
3678 AC_MSG_CHECKING([gethostbyname_r with 6 args])
3679 OLD_CFLAGS=$CFLAGS
3680 CFLAGS="$CFLAGS $MY_CPPFLAGS $MY_THREAD_CPPFLAGS $MY_CFLAGS"
Matthias Klosec511b472010-05-08 11:01:39 +00003681 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003682# include <netdb.h>
Matthias Klosec511b472010-05-08 11:01:39 +00003683 ]], [[
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003684 char *name;
3685 struct hostent *he, *res;
3686 char buffer[2048];
3687 int buflen = 2048;
3688 int h_errnop;
3689
3690 (void) gethostbyname_r(name, he, buffer, buflen, &res, &h_errnop)
Matthias Klosec511b472010-05-08 11:01:39 +00003691 ]])],[
Guido van Rossum8db7d8b1999-03-23 16:40:33 +00003692 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003693 AC_DEFINE(HAVE_GETHOSTBYNAME_R_6_ARG, 1,
3694 [Define this if you have the 6-arg version of gethostbyname_r().])
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003695 AC_MSG_RESULT(yes)
Matthias Klosec511b472010-05-08 11:01:39 +00003696 ],[
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003697 AC_MSG_RESULT(no)
3698 AC_MSG_CHECKING([gethostbyname_r with 5 args])
Matthias Klosec511b472010-05-08 11:01:39 +00003699 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003700# include <netdb.h>
Matthias Klosec511b472010-05-08 11:01:39 +00003701 ]], [[
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003702 char *name;
3703 struct hostent *he;
Matthias Klosec511b472010-05-08 11:01:39 +00003704 char buffer[2048];
3705 int buflen = 2048;
3706 int h_errnop;
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003707
Matthias Klosec511b472010-05-08 11:01:39 +00003708 (void) gethostbyname_r(name, he, buffer, buflen, &h_errnop)
3709 ]])],
3710 [
Guido van Rossum8db7d8b1999-03-23 16:40:33 +00003711 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
Matthias Klosec511b472010-05-08 11:01:39 +00003712 AC_DEFINE(HAVE_GETHOSTBYNAME_R_5_ARG, 1,
3713 [Define this if you have the 5-arg version of gethostbyname_r().])
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003714 AC_MSG_RESULT(yes)
3715 ], [
3716 AC_MSG_RESULT(no)
Matthias Klosec511b472010-05-08 11:01:39 +00003717 AC_MSG_CHECKING([gethostbyname_r with 3 args])
3718 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3719# include <netdb.h>
3720 ]], [[
3721 char *name;
3722 struct hostent *he;
3723 struct hostent_data data;
3724
3725 (void) gethostbyname_r(name, he, &data);
3726 ]])],
3727 [
3728 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
3729 AC_DEFINE(HAVE_GETHOSTBYNAME_R_3_ARG, 1,
3730 [Define this if you have the 3-arg version of gethostbyname_r().])
3731 AC_MSG_RESULT(yes)
3732 ], [
3733 AC_MSG_RESULT(no)
3734 ])
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003735 ])
3736 ])
3737 CFLAGS=$OLD_CFLAGS
3738], [
Thomas Wouters3a584202000-08-05 23:28:51 +00003739 AC_CHECK_FUNCS(gethostbyname)
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003740])
3741AC_SUBST(HAVE_GETHOSTBYNAME_R_6_ARG)
3742AC_SUBST(HAVE_GETHOSTBYNAME_R_5_ARG)
3743AC_SUBST(HAVE_GETHOSTBYNAME_R_3_ARG)
Guido van Rossum8db7d8b1999-03-23 16:40:33 +00003744AC_SUBST(HAVE_GETHOSTBYNAME_R)
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003745AC_SUBST(HAVE_GETHOSTBYNAME)
3746
Guido van Rossum627b2d71993-12-24 10:39:16 +00003747# checks for system services
3748# (none yet)
3749
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003750# Linux requires this for correct f.p. operations
Jeremy Hyltonbe28f5b2000-07-27 21:03:04 +00003751AC_CHECK_FUNC(__fpu_control,
3752 [],
3753 [AC_CHECK_LIB(ieee, __fpu_control)
3754])
Guido van Rossum627b2d71993-12-24 10:39:16 +00003755
Guido van Rossum93274221997-05-09 02:42:00 +00003756# Check for --with-fpectl
Guido van Rossum93274221997-05-09 02:42:00 +00003757AC_MSG_CHECKING(for --with-fpectl)
Barry Warsawc0d24d82000-06-29 16:12:00 +00003758AC_ARG_WITH(fpectl,
Matthias Klose22520ea2010-05-08 10:14:46 +00003759 AS_HELP_STRING([--with-fpectl], [enable SIGFPE catching]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003760[
Guido van Rossum93274221997-05-09 02:42:00 +00003761if test "$withval" != no
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003762then
3763 AC_DEFINE(WANT_SIGFPE_HANDLER, 1,
3764 [Define if you want SIGFPE handled (see Include/pyfpe.h).])
3765 AC_MSG_RESULT(yes)
Guido van Rossum93274221997-05-09 02:42:00 +00003766else AC_MSG_RESULT(no)
Guido van Rossumef2255b2000-03-10 22:30:29 +00003767fi],
3768[AC_MSG_RESULT(no)])
Guido van Rossum93274221997-05-09 02:42:00 +00003769
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003770# check for --with-libm=...
3771AC_SUBST(LIBM)
Guido van Rossum4b6b5791996-09-09 20:09:34 +00003772case $ac_sys_system in
Guido van Rossum3dc0a512000-10-05 18:00:06 +00003773Darwin) ;;
Guido van Rossumec95c7b1998-08-04 17:59:56 +00003774BeOS) ;;
Guido van Rossum4b6b5791996-09-09 20:09:34 +00003775*) LIBM=-lm
3776esac
Guido van Rossum93274221997-05-09 02:42:00 +00003777AC_MSG_CHECKING(for --with-libm=STRING)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003778AC_ARG_WITH(libm,
Matthias Klose22520ea2010-05-08 10:14:46 +00003779 AS_HELP_STRING([--with-libm=STRING], [math library]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003780[
Guido van Rossum93274221997-05-09 02:42:00 +00003781if test "$withval" = no
3782then LIBM=
3783 AC_MSG_RESULT(force LIBM empty)
3784elif test "$withval" != yes
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003785then LIBM=$withval
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003786 AC_MSG_RESULT(set LIBM="$withval")
3787else AC_MSG_ERROR([proper usage is --with-libm=STRING])
Guido van Rossum93274221997-05-09 02:42:00 +00003788fi],
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003789[AC_MSG_RESULT(default LIBM="$LIBM")])
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003790
3791# check for --with-libc=...
3792AC_SUBST(LIBC)
Guido van Rossum93274221997-05-09 02:42:00 +00003793AC_MSG_CHECKING(for --with-libc=STRING)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003794AC_ARG_WITH(libc,
Matthias Klose22520ea2010-05-08 10:14:46 +00003795 AS_HELP_STRING([--with-libc=STRING], [C library]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003796[
Guido van Rossum93274221997-05-09 02:42:00 +00003797if test "$withval" = no
3798then LIBC=
3799 AC_MSG_RESULT(force LIBC empty)
3800elif test "$withval" != yes
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003801then LIBC=$withval
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003802 AC_MSG_RESULT(set LIBC="$withval")
3803else AC_MSG_ERROR([proper usage is --with-libc=STRING])
Guido van Rossum93274221997-05-09 02:42:00 +00003804fi],
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003805[AC_MSG_RESULT(default LIBC="$LIBC")])
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003806
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003807# **************************************************
3808# * Check for various properties of floating point *
3809# **************************************************
Mark Dickinson265d7382008-04-21 22:32:24 +00003810
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003811AC_MSG_CHECKING(whether C doubles are little-endian IEEE 754 binary64)
3812AC_CACHE_VAL(ac_cv_little_endian_double, [
Matthias Klosec511b472010-05-08 11:01:39 +00003813AC_RUN_IFELSE([AC_LANG_SOURCE([[
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003814#include <string.h>
3815int main() {
3816 double x = 9006104071832581.0;
3817 if (memcmp(&x, "\x05\x04\x03\x02\x01\xff\x3f\x43", 8) == 0)
3818 return 0;
3819 else
3820 return 1;
3821}
Matthias Klosec511b472010-05-08 11:01:39 +00003822]])],
3823[ac_cv_little_endian_double=yes],
3824[ac_cv_little_endian_double=no],
3825[ac_cv_little_endian_double=no])])
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003826AC_MSG_RESULT($ac_cv_little_endian_double)
3827if test "$ac_cv_little_endian_double" = yes
3828then
3829 AC_DEFINE(DOUBLE_IS_LITTLE_ENDIAN_IEEE754, 1,
3830 [Define if C doubles are 64-bit IEEE 754 binary format, stored
3831 with the least significant byte first])
3832fi
3833
3834AC_MSG_CHECKING(whether C doubles are big-endian IEEE 754 binary64)
3835AC_CACHE_VAL(ac_cv_big_endian_double, [
Matthias Klosec511b472010-05-08 11:01:39 +00003836AC_RUN_IFELSE([AC_LANG_SOURCE([[
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003837#include <string.h>
3838int main() {
3839 double x = 9006104071832581.0;
3840 if (memcmp(&x, "\x43\x3f\xff\x01\x02\x03\x04\x05", 8) == 0)
3841 return 0;
3842 else
3843 return 1;
3844}
Matthias Klosec511b472010-05-08 11:01:39 +00003845]])],
3846[ac_cv_big_endian_double=yes],
3847[ac_cv_big_endian_double=no],
3848[ac_cv_big_endian_double=no])])
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003849AC_MSG_RESULT($ac_cv_big_endian_double)
3850if test "$ac_cv_big_endian_double" = yes
3851then
3852 AC_DEFINE(DOUBLE_IS_BIG_ENDIAN_IEEE754, 1,
3853 [Define if C doubles are 64-bit IEEE 754 binary format, stored
3854 with the most significant byte first])
3855fi
3856
3857# Some ARM platforms use a mixed-endian representation for doubles.
3858# While Python doesn't currently have full support for these platforms
3859# (see e.g., issue 1762561), we can at least make sure that float <-> string
3860# conversions work.
3861AC_MSG_CHECKING(whether C doubles are ARM mixed-endian IEEE 754 binary64)
3862AC_CACHE_VAL(ac_cv_mixed_endian_double, [
Matthias Klosec511b472010-05-08 11:01:39 +00003863AC_RUN_IFELSE([AC_LANG_SOURCE([[
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003864#include <string.h>
3865int main() {
3866 double x = 9006104071832581.0;
3867 if (memcmp(&x, "\x01\xff\x3f\x43\x05\x04\x03\x02", 8) == 0)
3868 return 0;
3869 else
3870 return 1;
3871}
Matthias Klosec511b472010-05-08 11:01:39 +00003872]])],
3873[ac_cv_mixed_endian_double=yes],
3874[ac_cv_mixed_endian_double=no],
3875[ac_cv_mixed_endian_double=no])])
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003876AC_MSG_RESULT($ac_cv_mixed_endian_double)
3877if test "$ac_cv_mixed_endian_double" = yes
3878then
3879 AC_DEFINE(DOUBLE_IS_ARM_MIXED_ENDIAN_IEEE754, 1,
3880 [Define if C doubles are 64-bit IEEE 754 binary format, stored
3881 in ARM mixed-endian order (byte order 45670123)])
3882fi
3883
3884# The short float repr introduced in Python 3.1 requires the
3885# correctly-rounded string <-> double conversion functions from
3886# Python/dtoa.c, which in turn require that the FPU uses 53-bit
3887# rounding; this is a problem on x86, where the x87 FPU has a default
Mark Dickinsona548dee2009-11-15 13:12:43 +00003888# rounding precision of 64 bits. For gcc/x86, we can fix this by
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003889# using inline assembler to get and set the x87 FPU control word.
Mark Dickinsona548dee2009-11-15 13:12:43 +00003890
3891# This inline assembler syntax may also work for suncc and icc,
3892# so we try it on all platforms.
3893
3894AC_MSG_CHECKING(whether we can use gcc inline assembler to get and set x87 control word)
Stefan Krah99e36b92015-07-03 15:30:54 +02003895AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
Mark Dickinsona548dee2009-11-15 13:12:43 +00003896 unsigned short cw;
3897 __asm__ __volatile__ ("fnstcw %0" : "=m" (cw));
3898 __asm__ __volatile__ ("fldcw %0" : : "m" (cw));
Matthias Klosec511b472010-05-08 11:01:39 +00003899]])],[have_gcc_asm_for_x87=yes],[have_gcc_asm_for_x87=no])
Mark Dickinsona548dee2009-11-15 13:12:43 +00003900AC_MSG_RESULT($have_gcc_asm_for_x87)
3901if test "$have_gcc_asm_for_x87" = yes
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003902then
Mark Dickinsona548dee2009-11-15 13:12:43 +00003903 AC_DEFINE(HAVE_GCC_ASM_FOR_X87, 1,
3904 [Define if we can use gcc inline assembler to get and set x87 control word])
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003905fi
Mark Dickinson7a3d8642008-04-22 00:54:27 +00003906
Mark Dickinson04b27232009-01-04 12:29:36 +00003907# Detect whether system arithmetic is subject to x87-style double
3908# rounding issues. The result of this test has little meaning on non
3909# IEEE 754 platforms. On IEEE 754, test should return 1 if rounding
3910# mode is round-to-nearest and double rounding issues are present, and
3911# 0 otherwise. See http://bugs.python.org/issue2937 for more info.
3912AC_MSG_CHECKING(for x87-style double rounding)
Mark Dickinson99abd142009-10-24 13:44:16 +00003913# $BASECFLAGS may affect the result
3914ac_save_cc="$CC"
3915CC="$CC $BASECFLAGS"
Matthias Klosec511b472010-05-08 11:01:39 +00003916AC_RUN_IFELSE([AC_LANG_SOURCE([[
Mark Dickinson04b27232009-01-04 12:29:36 +00003917#include <stdlib.h>
3918#include <math.h>
3919int main() {
3920 volatile double x, y, z;
3921 /* 1./(1-2**-53) -> 1+2**-52 (correct), 1.0 (double rounding) */
3922 x = 0.99999999999999989; /* 1-2**-53 */
3923 y = 1./x;
3924 if (y != 1.)
3925 exit(0);
3926 /* 1e16+2.99999 -> 1e16+2. (correct), 1e16+4. (double rounding) */
3927 x = 1e16;
3928 y = 2.99999;
3929 z = x + y;
3930 if (z != 1e16+4.)
3931 exit(0);
3932 /* both tests show evidence of double rounding */
3933 exit(1);
3934}
Matthias Klosec511b472010-05-08 11:01:39 +00003935]])],
3936[ac_cv_x87_double_rounding=no],
3937[ac_cv_x87_double_rounding=yes],
3938[ac_cv_x87_double_rounding=no])
Mark Dickinson99abd142009-10-24 13:44:16 +00003939CC="$ac_save_cc"
Mark Dickinson04b27232009-01-04 12:29:36 +00003940AC_MSG_RESULT($ac_cv_x87_double_rounding)
3941if test "$ac_cv_x87_double_rounding" = yes
3942then
3943 AC_DEFINE(X87_DOUBLE_ROUNDING, 1,
3944 [Define if arithmetic is subject to x87-style double rounding issue])
3945fi
3946
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003947# ************************************
3948# * Check for mathematical functions *
3949# ************************************
3950
3951LIBS_SAVE=$LIBS
3952LIBS="$LIBS $LIBM"
3953
Mark Dickinsonc63392c2009-11-28 13:13:13 +00003954# On FreeBSD 6.2, it appears that tanh(-0.) returns 0. instead of
3955# -0. on some architectures.
3956AC_MSG_CHECKING(whether tanh preserves the sign of zero)
3957AC_CACHE_VAL(ac_cv_tanh_preserves_zero_sign, [
Matthias Klosec511b472010-05-08 11:01:39 +00003958AC_RUN_IFELSE([AC_LANG_SOURCE([[
Mark Dickinsonc63392c2009-11-28 13:13:13 +00003959#include <math.h>
3960#include <stdlib.h>
3961int main() {
3962 /* return 0 if either negative zeros don't exist
3963 on this platform or if negative zeros exist
3964 and tanh(-0.) == -0. */
3965 if (atan2(0., -1.) == atan2(-0., -1.) ||
3966 atan2(tanh(-0.), -1.) == atan2(-0., -1.)) exit(0);
3967 else exit(1);
3968}
Matthias Klosec511b472010-05-08 11:01:39 +00003969]])],
3970[ac_cv_tanh_preserves_zero_sign=yes],
3971[ac_cv_tanh_preserves_zero_sign=no],
3972[ac_cv_tanh_preserves_zero_sign=no])])
Mark Dickinsonc63392c2009-11-28 13:13:13 +00003973AC_MSG_RESULT($ac_cv_tanh_preserves_zero_sign)
3974if test "$ac_cv_tanh_preserves_zero_sign" = yes
3975then
3976 AC_DEFINE(TANH_PRESERVES_ZERO_SIGN, 1,
3977 [Define if tanh(-0.) is -0., or if platform doesn't have signed zeros])
3978fi
3979
3980AC_CHECK_FUNCS([acosh asinh atanh copysign erf erfc expm1 finite gamma])
3981AC_CHECK_FUNCS([hypot lgamma log1p round tgamma])
3982AC_CHECK_DECLS([isinf, isnan, isfinite], [], [], [[#include <math.h>]])
3983
3984LIBS=$LIBS_SAVE
3985
Mark Dickinsonc4920e82009-11-20 19:30:22 +00003986# For multiprocessing module, check that sem_open
3987# actually works. For FreeBSD versions <= 7.2,
3988# the kernel module that provides POSIX semaphores
3989# isn't loaded by default, so an attempt to call
3990# sem_open results in a 'Signal 12' error.
3991AC_MSG_CHECKING(whether POSIX semaphores are enabled)
3992AC_CACHE_VAL(ac_cv_posix_semaphores_enabled,
Matthias Klosec511b472010-05-08 11:01:39 +00003993AC_RUN_IFELSE([AC_LANG_SOURCE([[
Mark Dickinsonc4920e82009-11-20 19:30:22 +00003994#include <unistd.h>
3995#include <fcntl.h>
3996#include <stdio.h>
3997#include <semaphore.h>
3998#include <sys/stat.h>
3999
4000int main(void) {
4001 sem_t *a = sem_open("/autoconf", O_CREAT, S_IRUSR|S_IWUSR, 0);
4002 if (a == SEM_FAILED) {
4003 perror("sem_open");
4004 return 1;
4005 }
4006 sem_close(a);
Mark Dickinson59dc89e2009-12-13 21:06:06 +00004007 sem_unlink("/autoconf");
Mark Dickinsonc4920e82009-11-20 19:30:22 +00004008 return 0;
4009}
Matthias Klosec511b472010-05-08 11:01:39 +00004010]])],
4011[ac_cv_posix_semaphores_enabled=yes],
4012[ac_cv_posix_semaphores_enabled=no],
4013[ac_cv_posix_semaphores_enabled=yes])
Mark Dickinsonc4920e82009-11-20 19:30:22 +00004014)
4015AC_MSG_RESULT($ac_cv_posix_semaphores_enabled)
4016if test $ac_cv_posix_semaphores_enabled = no
4017then
Mark Dickinson5afa6d42009-11-28 10:44:20 +00004018 AC_DEFINE(POSIX_SEMAPHORES_NOT_ENABLED, 1,
4019 [Define if POSIX semaphores aren't enabled on your system])
Mark Dickinsonc4920e82009-11-20 19:30:22 +00004020fi
4021
Jesse Noller355b1262009-04-02 00:03:28 +00004022# Multiprocessing check for broken sem_getvalue
4023AC_MSG_CHECKING(for broken sem_getvalue)
Alexandre Vassalotti00900892009-07-17 05:26:39 +00004024AC_CACHE_VAL(ac_cv_broken_sem_getvalue,
Matthias Klosec511b472010-05-08 11:01:39 +00004025AC_RUN_IFELSE([AC_LANG_SOURCE([[
Jesse Noller355b1262009-04-02 00:03:28 +00004026#include <unistd.h>
4027#include <fcntl.h>
4028#include <stdio.h>
4029#include <semaphore.h>
4030#include <sys/stat.h>
4031
4032int main(void){
Mark Dickinson59dc89e2009-12-13 21:06:06 +00004033 sem_t *a = sem_open("/autocftw", O_CREAT, S_IRUSR|S_IWUSR, 0);
Jesse Noller355b1262009-04-02 00:03:28 +00004034 int count;
4035 int res;
4036 if(a==SEM_FAILED){
4037 perror("sem_open");
4038 return 1;
4039
4040 }
4041 res = sem_getvalue(a, &count);
4042 sem_close(a);
Mark Dickinson59dc89e2009-12-13 21:06:06 +00004043 sem_unlink("/autocftw");
Jesse Noller355b1262009-04-02 00:03:28 +00004044 return res==-1 ? 1 : 0;
4045}
Matthias Klosec511b472010-05-08 11:01:39 +00004046]])],
4047[ac_cv_broken_sem_getvalue=no],
4048[ac_cv_broken_sem_getvalue=yes],
4049[ac_cv_broken_sem_getvalue=yes])
Jesse Noller355b1262009-04-02 00:03:28 +00004050)
Alexandre Vassalotti00900892009-07-17 05:26:39 +00004051AC_MSG_RESULT($ac_cv_broken_sem_getvalue)
4052if test $ac_cv_broken_sem_getvalue = yes
4053then
4054 AC_DEFINE(HAVE_BROKEN_SEM_GETVALUE, 1,
4055 [define to 1 if your sem_getvalue is broken.])
4056fi
Mark Dickinson04b27232009-01-04 12:29:36 +00004057
Mark Dickinsonefc82f72009-03-20 15:51:55 +00004058# determine what size digit to use for Python's longs
4059AC_MSG_CHECKING([digit size for Python's longs])
4060AC_ARG_ENABLE(big-digits,
Matthias Klose22520ea2010-05-08 10:14:46 +00004061AS_HELP_STRING([--enable-big-digits@<:@=BITS@:>@],[use big digits for Python longs [[BITS=30]]]),
Mark Dickinsonefc82f72009-03-20 15:51:55 +00004062[case $enable_big_digits in
4063yes)
4064 enable_big_digits=30 ;;
4065no)
4066 enable_big_digits=15 ;;
4067[15|30])
4068 ;;
4069*)
4070 AC_MSG_ERROR([bad value $enable_big_digits for --enable-big-digits; value should be 15 or 30]) ;;
4071esac
4072AC_MSG_RESULT($enable_big_digits)
4073AC_DEFINE_UNQUOTED(PYLONG_BITS_IN_DIGIT, $enable_big_digits, [Define as the preferred size in bits of long digits])
4074],
4075[AC_MSG_RESULT(no value specified)])
4076
Guido van Rossumef2255b2000-03-10 22:30:29 +00004077# check for wchar.h
Martin v. Löwisc45929e2002-04-06 10:10:49 +00004078AC_CHECK_HEADER(wchar.h, [
4079 AC_DEFINE(HAVE_WCHAR_H, 1,
4080 [Define if the compiler provides a wchar.h header file.])
4081 wchar_h="yes"
4082],
Guido van Rossumef2255b2000-03-10 22:30:29 +00004083wchar_h="no"
4084)
4085
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00004086# determine wchar_t size
4087if test "$wchar_h" = yes
4088then
Guido van Rossum67b26592001-10-20 14:21:45 +00004089 AC_CHECK_SIZEOF(wchar_t, 4, [#include <wchar.h>])
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00004090fi
4091
Martin v. Löwisfa3bdea2003-09-04 18:50:54 +00004092AC_MSG_CHECKING(for UCS-4 tcl)
4093have_ucs4_tcl=no
Matthias Klosec511b472010-05-08 11:01:39 +00004094AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwisfa3bdea2003-09-04 18:50:54 +00004095#include <tcl.h>
4096#if TCL_UTF_MAX != 6
4097# error "NOT UCS4_TCL"
Matthias Klosec511b472010-05-08 11:01:39 +00004098#endif]], [[]])],[
Martin v. Löwisfa3bdea2003-09-04 18:50:54 +00004099 AC_DEFINE(HAVE_UCS4_TCL, 1, [Define this if you have tcl and TCL_UTF_MAX==6])
4100 have_ucs4_tcl=yes
Matthias Klosec511b472010-05-08 11:01:39 +00004101],[])
Martin v. Löwisfa3bdea2003-09-04 18:50:54 +00004102AC_MSG_RESULT($have_ucs4_tcl)
4103
Marc-André Lemburgd7160f82003-09-22 11:14:40 +00004104# check whether wchar_t is signed or not
4105if test "$wchar_h" = yes
4106then
4107 # check whether wchar_t is signed or not
4108 AC_MSG_CHECKING(whether wchar_t is signed)
4109 AC_CACHE_VAL(ac_cv_wchar_t_signed, [
Matthias Klosec511b472010-05-08 11:01:39 +00004110 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Marc-André Lemburgd7160f82003-09-22 11:14:40 +00004111 #include <wchar.h>
4112 int main()
4113 {
Martin v. Löwis44fe0e42006-04-11 07:15:30 +00004114 /* Success: exit code 0 */
4115 exit((((wchar_t) -1) < ((wchar_t) 0)) ? 0 : 1);
Marc-André Lemburgd7160f82003-09-22 11:14:40 +00004116 }
Matthias Klosec511b472010-05-08 11:01:39 +00004117 ]])],
4118 [ac_cv_wchar_t_signed=yes],
4119 [ac_cv_wchar_t_signed=no],
4120 [ac_cv_wchar_t_signed=yes])])
Marc-André Lemburgd7160f82003-09-22 11:14:40 +00004121 AC_MSG_RESULT($ac_cv_wchar_t_signed)
4122fi
4123
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00004124AC_MSG_CHECKING(what type to use for unicode)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00004125dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00004126AC_ARG_ENABLE(unicode,
Benjamin Peterson66556b02010-05-25 02:23:32 +00004127 AS_HELP_STRING([--enable-unicode@<:@=ucs@<:@24@:>@@:>@], [Enable Unicode strings (default is ucs2)]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00004128 [],
4129 [enable_unicode=yes])
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00004130
4131if test $enable_unicode = yes
4132then
Martin v. Löwisfd917792001-06-27 20:22:04 +00004133 # Without any arguments, Py_UNICODE defaults to two-byte mode
Martin v. Löwisfa3bdea2003-09-04 18:50:54 +00004134 case "$have_ucs4_tcl" in
4135 yes) enable_unicode="ucs4"
4136 ;;
4137 *) enable_unicode="ucs2"
4138 ;;
4139 esac
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00004140fi
4141
Martin v. Löwis0036cba2002-04-12 09:58:45 +00004142AH_TEMPLATE(Py_UNICODE_SIZE,
4143 [Define as the size of the unicode type.])
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00004144case "$enable_unicode" in
4145ucs2) unicode_size="2"
4146 AC_DEFINE(Py_UNICODE_SIZE,2)
4147 ;;
4148ucs4) unicode_size="4"
4149 AC_DEFINE(Py_UNICODE_SIZE,4)
4150 ;;
Martin v. Löwised11a5d2012-05-20 10:42:17 +02004151no) ;; # To allow --disable-unicode
Ezio Melotti5820efb2010-02-27 00:05:42 +00004152*) AC_MSG_ERROR([invalid value for --enable-unicode. Use either ucs2 or ucs4 (lowercase).]) ;;
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00004153esac
4154
Martin v. Löwis11437992002-04-12 09:54:03 +00004155AH_TEMPLATE(PY_UNICODE_TYPE,
4156 [Define as the integral type used for Unicode representation.])
Martin v. Löwis0036cba2002-04-12 09:58:45 +00004157
Martin v. Löwis339d0f72001-08-17 18:39:25 +00004158AC_SUBST(UNICODE_OBJS)
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00004159if test "$enable_unicode" = "no"
4160then
Martin v. Löwis339d0f72001-08-17 18:39:25 +00004161 UNICODE_OBJS=""
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00004162 AC_MSG_RESULT(not used)
4163else
Martin v. Löwis339d0f72001-08-17 18:39:25 +00004164 UNICODE_OBJS="Objects/unicodeobject.o Objects/unicodectype.o"
Martin v. Löwisc45929e2002-04-06 10:10:49 +00004165 AC_DEFINE(Py_USING_UNICODE, 1,
4166 [Define if you want to have a Unicode type.])
Marc-André Lemburgd7160f82003-09-22 11:14:40 +00004167
4168 # wchar_t is only usable if it maps to an unsigned type
4169 if test "$unicode_size" = "$ac_cv_sizeof_wchar_t" \
Matthias Klose7dbeed72004-12-24 08:22:17 +00004170 -a "$ac_cv_wchar_t_signed" = "no"
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00004171 then
4172 PY_UNICODE_TYPE="wchar_t"
Martin v. Löwisc45929e2002-04-06 10:10:49 +00004173 AC_DEFINE(HAVE_USABLE_WCHAR_T, 1,
4174 [Define if you have a useable wchar_t type defined in wchar.h; useable
Marc-André Lemburgd7160f82003-09-22 11:14:40 +00004175 means wchar_t must be an unsigned type with at least 16 bits. (see
Martin v. Löwisc45929e2002-04-06 10:10:49 +00004176 Include/unicodeobject.h).])
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00004177 AC_DEFINE(PY_UNICODE_TYPE,wchar_t)
4178 elif test "$ac_cv_sizeof_short" = "$unicode_size"
4179 then
4180 PY_UNICODE_TYPE="unsigned short"
4181 AC_DEFINE(PY_UNICODE_TYPE,unsigned short)
4182 elif test "$ac_cv_sizeof_long" = "$unicode_size"
4183 then
4184 PY_UNICODE_TYPE="unsigned long"
4185 AC_DEFINE(PY_UNICODE_TYPE,unsigned long)
4186 else
4187 PY_UNICODE_TYPE="no type found"
4188 fi
4189 AC_MSG_RESULT($PY_UNICODE_TYPE)
4190fi
Guido van Rossumef2255b2000-03-10 22:30:29 +00004191
4192# check for endianness
4193AC_C_BIGENDIAN
4194
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00004195# Check whether right shifting a negative integer extends the sign bit
4196# or fills with zeros (like the Cray J90, according to Tim Peters).
4197AC_MSG_CHECKING(whether right shift extends the sign bit)
Vladimir Marangozova6180282000-07-12 05:05:06 +00004198AC_CACHE_VAL(ac_cv_rshift_extends_sign, [
Matthias Klosec511b472010-05-08 11:01:39 +00004199AC_RUN_IFELSE([AC_LANG_SOURCE([[
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00004200int main()
4201{
Vladimir Marangozova6180282000-07-12 05:05:06 +00004202 exit(((-1)>>3 == -1) ? 0 : 1);
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00004203}
Matthias Klosec511b472010-05-08 11:01:39 +00004204]])],
4205[ac_cv_rshift_extends_sign=yes],
4206[ac_cv_rshift_extends_sign=no],
4207[ac_cv_rshift_extends_sign=yes])])
Vladimir Marangozova6180282000-07-12 05:05:06 +00004208AC_MSG_RESULT($ac_cv_rshift_extends_sign)
4209if test "$ac_cv_rshift_extends_sign" = no
4210then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00004211 AC_DEFINE(SIGNED_RIGHT_SHIFT_ZERO_FILLS, 1,
4212 [Define if i>>j for signed int i does not extend the sign bit
4213 when i < 0])
Vladimir Marangozova6180282000-07-12 05:05:06 +00004214fi
4215
Guido van Rossumcadfaec2001-01-05 14:45:49 +00004216# check for getc_unlocked and related locking functions
4217AC_MSG_CHECKING(for getc_unlocked() and friends)
4218AC_CACHE_VAL(ac_cv_have_getc_unlocked, [
Matthias Klosec511b472010-05-08 11:01:39 +00004219AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <stdio.h>]], [[
Guido van Rossumcadfaec2001-01-05 14:45:49 +00004220 FILE *f = fopen("/dev/null", "r");
4221 flockfile(f);
4222 getc_unlocked(f);
4223 funlockfile(f);
Matthias Klosec511b472010-05-08 11:01:39 +00004224]])],[ac_cv_have_getc_unlocked=yes],[ac_cv_have_getc_unlocked=no])])
Guido van Rossumcadfaec2001-01-05 14:45:49 +00004225AC_MSG_RESULT($ac_cv_have_getc_unlocked)
4226if test "$ac_cv_have_getc_unlocked" = yes
4227then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00004228 AC_DEFINE(HAVE_GETC_UNLOCKED, 1,
4229 [Define this if you have flockfile(), getc_unlocked(), and funlockfile()])
Guido van Rossumcadfaec2001-01-05 14:45:49 +00004230fi
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00004231
Neal Norwitzfe8e3d92006-01-07 21:07:20 +00004232# check where readline lives
Martin v. Löwis82bca632006-02-10 20:49:30 +00004233# save the value of LIBS so we don't actually link Python with readline
4234LIBS_no_readline=$LIBS
Gregory P. Smith980b99b2008-09-07 05:15:18 +00004235
4236# On some systems we need to link readline to a termcap compatible
4237# library. NOTE: Keep the precedence of listed libraries synchronised
4238# with setup.py.
4239py_cv_lib_readline=no
4240AC_MSG_CHECKING([how to link readline libs])
4241for py_libtermcap in "" ncursesw ncurses curses termcap; do
4242 if test -z "$py_libtermcap"; then
4243 READLINE_LIBS="-lreadline"
4244 else
4245 READLINE_LIBS="-lreadline -l$py_libtermcap"
4246 fi
4247 LIBS="$READLINE_LIBS $LIBS_no_readline"
4248 AC_LINK_IFELSE(
4249 [AC_LANG_CALL([],[readline])],
4250 [py_cv_lib_readline=yes])
4251 if test $py_cv_lib_readline = yes; then
4252 break
4253 fi
4254done
4255# Uncomment this line if you want to use READINE_LIBS in Makefile or scripts
4256#AC_SUBST([READLINE_LIBS])
Gregory P. Smith29ec7502008-09-07 19:18:16 +00004257if test $py_cv_lib_readline = no; then
Gregory P. Smith980b99b2008-09-07 05:15:18 +00004258 AC_MSG_RESULT([none])
4259else
4260 AC_MSG_RESULT([$READLINE_LIBS])
4261 AC_DEFINE(HAVE_LIBREADLINE, 1,
4262 [Define if you have the readline library (-lreadline).])
Neal Norwitzfe8e3d92006-01-07 21:07:20 +00004263fi
4264
Michael W. Hudson30ea2f22004-07-07 17:44:12 +00004265# check for readline 2.1
4266AC_CHECK_LIB(readline, rl_callback_handler_install,
4267 AC_DEFINE(HAVE_RL_CALLBACK, 1,
Gregory P. Smithff7b2d52008-09-03 05:57:48 +00004268 [Define if you have readline 2.1]), ,$READLINE_LIBS)
Michael W. Hudson30ea2f22004-07-07 17:44:12 +00004269
Guido van Rossumfaf5e4d2002-12-30 16:25:41 +00004270# check for readline 2.2
Matthias Klosec511b472010-05-08 11:01:39 +00004271AC_PREPROC_IFELSE([AC_LANG_SOURCE([[#include <readline/readline.h>]])],
4272 [have_readline=yes],
4273 [have_readline=no]
4274)
Guido van Rossumfaf5e4d2002-12-30 16:25:41 +00004275if test $have_readline = yes
4276then
4277 AC_EGREP_HEADER([extern int rl_completion_append_character;],
4278 [readline/readline.h],
4279 AC_DEFINE(HAVE_RL_COMPLETION_APPEND_CHARACTER, 1,
4280 [Define if you have readline 2.2]), )
Antoine Pitroud9ff74e2009-10-26 19:16:46 +00004281 AC_EGREP_HEADER([extern int rl_completion_suppress_append;],
4282 [readline/readline.h],
4283 AC_DEFINE(HAVE_RL_COMPLETION_SUPPRESS_APPEND, 1,
4284 [Define if you have rl_completion_suppress_append]), )
Guido van Rossumfaf5e4d2002-12-30 16:25:41 +00004285fi
4286
Martin v. Löwis0daad592001-09-30 21:09:59 +00004287# check for readline 4.0
4288AC_CHECK_LIB(readline, rl_pre_input_hook,
Martin v. Löwisc45929e2002-04-06 10:10:49 +00004289 AC_DEFINE(HAVE_RL_PRE_INPUT_HOOK, 1,
Gregory P. Smithff7b2d52008-09-03 05:57:48 +00004290 [Define if you have readline 4.0]), ,$READLINE_LIBS)
Martin v. Löwis0daad592001-09-30 21:09:59 +00004291
Martin v. Löwis58bd49f2007-09-04 13:13:14 +00004292# also in 4.0
4293AC_CHECK_LIB(readline, rl_completion_display_matches_hook,
4294 AC_DEFINE(HAVE_RL_COMPLETION_DISPLAY_MATCHES_HOOK, 1,
Gregory P. Smithff7b2d52008-09-03 05:57:48 +00004295 [Define if you have readline 4.0]), ,$READLINE_LIBS)
Martin v. Löwis58bd49f2007-09-04 13:13:14 +00004296
Martin Pantera70c3232016-04-03 02:54:58 +00004297# also in 4.0, but not in editline
4298AC_CHECK_LIB(readline, rl_resize_terminal,
4299 AC_DEFINE(HAVE_RL_RESIZE_TERMINAL, 1,
4300 [Define if you have readline 4.0]), ,$READLINE_LIBS)
4301
Guido van Rossum353ae582001-07-10 16:45:32 +00004302# check for readline 4.2
4303AC_CHECK_LIB(readline, rl_completion_matches,
Martin v. Löwisc45929e2002-04-06 10:10:49 +00004304 AC_DEFINE(HAVE_RL_COMPLETION_MATCHES, 1,
Gregory P. Smithff7b2d52008-09-03 05:57:48 +00004305 [Define if you have readline 4.2]), ,$READLINE_LIBS)
Guido van Rossum353ae582001-07-10 16:45:32 +00004306
Michael W. Hudson30ea2f22004-07-07 17:44:12 +00004307# also in readline 4.2
Matthias Klosec511b472010-05-08 11:01:39 +00004308AC_PREPROC_IFELSE([AC_LANG_SOURCE([[#include <readline/readline.h>]])],
4309 [have_readline=yes],
4310 [have_readline=no]
4311)
Michael W. Hudson30ea2f22004-07-07 17:44:12 +00004312if test $have_readline = yes
4313then
4314 AC_EGREP_HEADER([extern int rl_catch_signals;],
4315 [readline/readline.h],
4316 AC_DEFINE(HAVE_RL_CATCH_SIGNAL, 1,
4317 [Define if you can turn off readline's signal handling.]), )
4318fi
4319
Martin v. Löwis82bca632006-02-10 20:49:30 +00004320# End of readline checks: restore LIBS
4321LIBS=$LIBS_no_readline
4322
Thomas Wouterse38b2f12001-07-11 22:35:31 +00004323AC_MSG_CHECKING(for broken nice())
4324AC_CACHE_VAL(ac_cv_broken_nice, [
Matthias Klosec511b472010-05-08 11:01:39 +00004325AC_RUN_IFELSE([AC_LANG_SOURCE([[
Thomas Wouterse38b2f12001-07-11 22:35:31 +00004326int main()
4327{
4328 int val1 = nice(1);
4329 if (val1 != -1 && val1 == nice(2))
4330 exit(0);
4331 exit(1);
4332}
Matthias Klosec511b472010-05-08 11:01:39 +00004333]])],
4334[ac_cv_broken_nice=yes],
4335[ac_cv_broken_nice=no],
4336[ac_cv_broken_nice=no])])
Thomas Wouterse38b2f12001-07-11 22:35:31 +00004337AC_MSG_RESULT($ac_cv_broken_nice)
4338if test "$ac_cv_broken_nice" = yes
4339then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00004340 AC_DEFINE(HAVE_BROKEN_NICE, 1,
4341 [Define if nice() returns success/failure instead of the new priority.])
Thomas Wouterse38b2f12001-07-11 22:35:31 +00004342fi
4343
Nicholas Bastine62c5c82004-03-21 23:45:42 +00004344AC_MSG_CHECKING(for broken poll())
Alexandre Vassalotti00900892009-07-17 05:26:39 +00004345AC_CACHE_VAL(ac_cv_broken_poll,
Matthias Klosec511b472010-05-08 11:01:39 +00004346AC_RUN_IFELSE([AC_LANG_SOURCE([[
Nicholas Bastine62c5c82004-03-21 23:45:42 +00004347#include <poll.h>
4348
Alexandre Vassalotti66da2632009-07-17 06:17:33 +00004349int main()
4350{
Nicholas Bastine62c5c82004-03-21 23:45:42 +00004351 struct pollfd poll_struct = { 42, POLLIN|POLLPRI|POLLOUT, 0 };
Alexandre Vassalotti66da2632009-07-17 06:17:33 +00004352 int poll_test;
4353
Nicholas Bastine62c5c82004-03-21 23:45:42 +00004354 close (42);
4355
Alexandre Vassalotti66da2632009-07-17 06:17:33 +00004356 poll_test = poll(&poll_struct, 1, 0);
Nicholas Bastine62c5c82004-03-21 23:45:42 +00004357 if (poll_test < 0)
Alexandre Vassalotti66da2632009-07-17 06:17:33 +00004358 return 0;
Nicholas Bastine62c5c82004-03-21 23:45:42 +00004359 else if (poll_test == 0 && poll_struct.revents != POLLNVAL)
Alexandre Vassalotti66da2632009-07-17 06:17:33 +00004360 return 0;
Nicholas Bastine62c5c82004-03-21 23:45:42 +00004361 else
Alexandre Vassalotti66da2632009-07-17 06:17:33 +00004362 return 1;
4363}
Matthias Klosec511b472010-05-08 11:01:39 +00004364]])],
4365[ac_cv_broken_poll=yes],
4366[ac_cv_broken_poll=no],
4367[ac_cv_broken_poll=no]))
Nicholas Bastine62c5c82004-03-21 23:45:42 +00004368AC_MSG_RESULT($ac_cv_broken_poll)
4369if test "$ac_cv_broken_poll" = yes
4370then
4371 AC_DEFINE(HAVE_BROKEN_POLL, 1,
4372 [Define if poll() sets errno on invalid file descriptors.])
4373fi
4374
Brett Cannon43802422005-02-10 20:48:03 +00004375# Before we can test tzset, we need to check if struct tm has a tm_zone
4376# (which is not required by ISO C or UNIX spec) and/or if we support
4377# tzname[]
4378AC_STRUCT_TIMEZONE
Nicholas Bastine62c5c82004-03-21 23:45:42 +00004379
Brett Cannon43802422005-02-10 20:48:03 +00004380# check tzset(3) exists and works like we expect it to
Guido van Rossumd11b62e2003-03-14 21:51:36 +00004381AC_MSG_CHECKING(for working tzset())
4382AC_CACHE_VAL(ac_cv_working_tzset, [
Matthias Klosec511b472010-05-08 11:01:39 +00004383AC_RUN_IFELSE([AC_LANG_SOURCE([[
Guido van Rossumd11b62e2003-03-14 21:51:36 +00004384#include <stdlib.h>
4385#include <time.h>
Brett Cannon18367812003-09-19 00:59:16 +00004386#include <string.h>
Brett Cannon43802422005-02-10 20:48:03 +00004387
4388#if HAVE_TZNAME
4389extern char *tzname[];
4390#endif
4391
Guido van Rossumd11b62e2003-03-14 21:51:36 +00004392int main()
4393{
Brett Cannon18367812003-09-19 00:59:16 +00004394 /* Note that we need to ensure that not only does tzset(3)
4395 do 'something' with localtime, but it works as documented
4396 in the library reference and as expected by the test suite.
Brett Cannon43802422005-02-10 20:48:03 +00004397 This includes making sure that tzname is set properly if
4398 tm->tm_zone does not exist since it is the alternative way
4399 of getting timezone info.
Brett Cannon18367812003-09-19 00:59:16 +00004400
4401 Red Hat 6.2 doesn't understand the southern hemisphere
Brett Cannon43802422005-02-10 20:48:03 +00004402 after New Year's Day.
Brett Cannon18367812003-09-19 00:59:16 +00004403 */
4404
Brett Cannon43802422005-02-10 20:48:03 +00004405 time_t groundhogday = 1044144000; /* GMT-based */
Brett Cannon18367812003-09-19 00:59:16 +00004406 time_t midyear = groundhogday + (365 * 24 * 3600 / 2);
4407
Neal Norwitz7f2588c2003-04-11 15:35:53 +00004408 putenv("TZ=UTC+0");
Guido van Rossumd11b62e2003-03-14 21:51:36 +00004409 tzset();
Brett Cannon18367812003-09-19 00:59:16 +00004410 if (localtime(&groundhogday)->tm_hour != 0)
4411 exit(1);
Brett Cannon43802422005-02-10 20:48:03 +00004412#if HAVE_TZNAME
4413 /* For UTC, tzname[1] is sometimes "", sometimes " " */
4414 if (strcmp(tzname[0], "UTC") ||
4415 (tzname[1][0] != 0 && tzname[1][0] != ' '))
4416 exit(1);
4417#endif
Brett Cannon18367812003-09-19 00:59:16 +00004418
Neal Norwitz7f2588c2003-04-11 15:35:53 +00004419 putenv("TZ=EST+5EDT,M4.1.0,M10.5.0");
Guido van Rossumd11b62e2003-03-14 21:51:36 +00004420 tzset();
Brett Cannon18367812003-09-19 00:59:16 +00004421 if (localtime(&groundhogday)->tm_hour != 19)
Guido van Rossumd11b62e2003-03-14 21:51:36 +00004422 exit(1);
Brett Cannon43802422005-02-10 20:48:03 +00004423#if HAVE_TZNAME
4424 if (strcmp(tzname[0], "EST") || strcmp(tzname[1], "EDT"))
4425 exit(1);
4426#endif
Brett Cannon18367812003-09-19 00:59:16 +00004427
4428 putenv("TZ=AEST-10AEDT-11,M10.5.0,M3.5.0");
4429 tzset();
4430 if (localtime(&groundhogday)->tm_hour != 11)
4431 exit(1);
Brett Cannon43802422005-02-10 20:48:03 +00004432#if HAVE_TZNAME
4433 if (strcmp(tzname[0], "AEST") || strcmp(tzname[1], "AEDT"))
4434 exit(1);
4435#endif
4436
4437#if HAVE_STRUCT_TM_TM_ZONE
Brett Cannon18367812003-09-19 00:59:16 +00004438 if (strcmp(localtime(&groundhogday)->tm_zone, "AEDT"))
4439 exit(1);
4440 if (strcmp(localtime(&midyear)->tm_zone, "AEST"))
4441 exit(1);
Brett Cannon43802422005-02-10 20:48:03 +00004442#endif
Brett Cannon18367812003-09-19 00:59:16 +00004443
Guido van Rossumd11b62e2003-03-14 21:51:36 +00004444 exit(0);
4445}
Matthias Klosec511b472010-05-08 11:01:39 +00004446]])],
4447[ac_cv_working_tzset=yes],
4448[ac_cv_working_tzset=no],
4449[ac_cv_working_tzset=no])])
Guido van Rossumd11b62e2003-03-14 21:51:36 +00004450AC_MSG_RESULT($ac_cv_working_tzset)
4451if test "$ac_cv_working_tzset" = yes
4452then
4453 AC_DEFINE(HAVE_WORKING_TZSET, 1,
4454 [Define if tzset() actually switches the local timezone in a meaningful way.])
4455fi
4456
Martin v. Löwis94717ed2002-09-09 14:24:16 +00004457# Look for subsecond timestamps in struct stat
4458AC_MSG_CHECKING(for tv_nsec in struct stat)
4459AC_CACHE_VAL(ac_cv_stat_tv_nsec,
Matthias Klosec511b472010-05-08 11:01:39 +00004460AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/stat.h>]], [[
Martin v. Löwis94717ed2002-09-09 14:24:16 +00004461struct stat st;
4462st.st_mtim.tv_nsec = 1;
Matthias Klosec511b472010-05-08 11:01:39 +00004463]])],
4464[ac_cv_stat_tv_nsec=yes],
4465[ac_cv_stat_tv_nsec=no]))
Martin v. Löwis94717ed2002-09-09 14:24:16 +00004466AC_MSG_RESULT($ac_cv_stat_tv_nsec)
4467if test "$ac_cv_stat_tv_nsec" = yes
4468then
4469 AC_DEFINE(HAVE_STAT_TV_NSEC, 1,
4470 [Define if you have struct stat.st_mtim.tv_nsec])
4471fi
4472
Martin v. Löwisebd9d5b2005-08-09 15:00:59 +00004473# Look for BSD style subsecond timestamps in struct stat
4474AC_MSG_CHECKING(for tv_nsec2 in struct stat)
4475AC_CACHE_VAL(ac_cv_stat_tv_nsec2,
Matthias Klosec511b472010-05-08 11:01:39 +00004476AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/stat.h>]], [[
Martin v. Löwisebd9d5b2005-08-09 15:00:59 +00004477struct stat st;
4478st.st_mtimespec.tv_nsec = 1;
Matthias Klosec511b472010-05-08 11:01:39 +00004479]])],
4480[ac_cv_stat_tv_nsec2=yes],
4481[ac_cv_stat_tv_nsec2=no]))
Martin v. Löwisebd9d5b2005-08-09 15:00:59 +00004482AC_MSG_RESULT($ac_cv_stat_tv_nsec2)
4483if test "$ac_cv_stat_tv_nsec2" = yes
4484then
4485 AC_DEFINE(HAVE_STAT_TV_NSEC2, 1,
4486 [Define if you have struct stat.st_mtimensec])
4487fi
4488
doko@ubuntu.comf27ec3e2014-04-17 20:11:19 +02004489# first curses configure check
4490ac_save_cppflags="$CPPFLAGS"
4491CPPFLAGS="$CPPFLAGS -I/usr/include/ncursesw"
4492
4493AC_CHECK_HEADERS(curses.h ncurses.h)
4494
4495# On Solaris, term.h requires curses.h
4496AC_CHECK_HEADERS(term.h,,,[
4497#ifdef HAVE_CURSES_H
4498#include <curses.h>
4499#endif
4500])
4501
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00004502# On HP/UX 11.0, mvwdelch is a block with a return statement
4503AC_MSG_CHECKING(whether mvwdelch is an expression)
4504AC_CACHE_VAL(ac_cv_mvwdelch_is_expression,
Matthias Klosec511b472010-05-08 11:01:39 +00004505AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <curses.h>]], [[
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00004506 int rtn;
4507 rtn = mvwdelch(0,0,0);
Matthias Klosec511b472010-05-08 11:01:39 +00004508]])],
4509[ac_cv_mvwdelch_is_expression=yes],
4510[ac_cv_mvwdelch_is_expression=no]))
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00004511AC_MSG_RESULT($ac_cv_mvwdelch_is_expression)
4512
4513if test "$ac_cv_mvwdelch_is_expression" = yes
4514then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00004515 AC_DEFINE(MVWDELCH_IS_EXPRESSION, 1,
4516 [Define if mvwdelch in curses.h is an expression.])
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00004517fi
4518
4519AC_MSG_CHECKING(whether WINDOW has _flags)
4520AC_CACHE_VAL(ac_cv_window_has_flags,
Matthias Klosec511b472010-05-08 11:01:39 +00004521AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <curses.h>]], [[
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00004522 WINDOW *w;
4523 w->_flags = 0;
Matthias Klosec511b472010-05-08 11:01:39 +00004524]])],
4525[ac_cv_window_has_flags=yes],
4526[ac_cv_window_has_flags=no]))
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00004527AC_MSG_RESULT($ac_cv_window_has_flags)
4528
4529
4530if test "$ac_cv_window_has_flags" = yes
4531then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00004532 AC_DEFINE(WINDOW_HAS_FLAGS, 1,
4533 [Define if WINDOW in curses.h offers a field _flags.])
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00004534fi
4535
Walter Dörwald4994d952006-06-19 08:07:50 +00004536AC_MSG_CHECKING(for is_term_resized)
Matthias Klosec511b472010-05-08 11:01:39 +00004537AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <curses.h>]], [[void *x=is_term_resized]])],
4538 [AC_DEFINE(HAVE_CURSES_IS_TERM_RESIZED, 1, Define if you have the 'is_term_resized' function.)
4539 AC_MSG_RESULT(yes)],
4540 [AC_MSG_RESULT(no)]
Walter Dörwald4994d952006-06-19 08:07:50 +00004541)
4542
Walter Dörwald05fdbf12006-06-19 08:14:09 +00004543AC_MSG_CHECKING(for resize_term)
Matthias Klosec511b472010-05-08 11:01:39 +00004544AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <curses.h>]], [[void *x=resize_term]])],
4545 [AC_DEFINE(HAVE_CURSES_RESIZE_TERM, 1, Define if you have the 'resize_term' function.)
4546 AC_MSG_RESULT(yes)],
4547 [AC_MSG_RESULT(no)]
Walter Dörwald4994d952006-06-19 08:07:50 +00004548)
4549
Walter Dörwald05fdbf12006-06-19 08:14:09 +00004550AC_MSG_CHECKING(for resizeterm)
Matthias Klosec511b472010-05-08 11:01:39 +00004551AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <curses.h>]], [[void *x=resizeterm]])],
4552 [AC_DEFINE(HAVE_CURSES_RESIZETERM, 1, Define if you have the 'resizeterm' function.)
4553 AC_MSG_RESULT(yes)],
4554 [AC_MSG_RESULT(no)]
Walter Dörwald4994d952006-06-19 08:07:50 +00004555)
doko@ubuntu.comf27ec3e2014-04-17 20:11:19 +02004556# last curses configure check
4557CPPFLAGS=$ac_save_cppflags
Walter Dörwald4994d952006-06-19 08:07:50 +00004558
doko@python.orgd65e2ba2013-01-31 23:52:03 +01004559AC_MSG_NOTICE([checking for device files])
Martin v. Löwisfefbc202006-10-17 18:59:23 +00004560
doko@python.orgd65e2ba2013-01-31 23:52:03 +01004561dnl NOTE: Inform user how to proceed with files when cross compiling.
4562if test "x$cross_compiling" = xyes; then
4563 if test "${ac_cv_file__dev_ptmx+set}" != set; then
4564 AC_MSG_CHECKING([for /dev/ptmx])
4565 AC_MSG_RESULT([not set])
4566 AC_MSG_ERROR([set ac_cv_file__dev_ptmx to yes/no in your CONFIG_SITE file when cross compiling])
4567 fi
4568 if test "${ac_cv_file__dev_ptc+set}" != set; then
4569 AC_MSG_CHECKING([for /dev/ptc])
4570 AC_MSG_RESULT([not set])
4571 AC_MSG_ERROR([set ac_cv_file__dev_ptc to yes/no in your CONFIG_SITE file when cross compiling])
4572 fi
Martin v. Löwisfefbc202006-10-17 18:59:23 +00004573fi
4574
doko@python.orgd65e2ba2013-01-31 23:52:03 +01004575AC_CHECK_FILE(/dev/ptmx, [], [])
4576if test "x$ac_cv_file__dev_ptmx" = xyes; then
4577 AC_DEFINE(HAVE_DEV_PTMX, 1,
4578 [Define to 1 if you have the /dev/ptmx device file.])
4579fi
4580AC_CHECK_FILE(/dev/ptc, [], [])
4581if test "x$ac_cv_file__dev_ptc" = xyes; then
Martin v. Löwisfefbc202006-10-17 18:59:23 +00004582 AC_DEFINE(HAVE_DEV_PTC, 1,
doko@python.orgd65e2ba2013-01-31 23:52:03 +01004583 [Define to 1 if you have the /dev/ptc device file.])
Martin v. Löwisfefbc202006-10-17 18:59:23 +00004584fi
Neal Norwitz865400f2003-03-21 01:42:58 +00004585
Mark Dickinson82864d12009-11-15 16:18:58 +00004586if test "$have_long_long" = yes
4587then
4588 AC_MSG_CHECKING(for %lld and %llu printf() format support)
4589 AC_CACHE_VAL(ac_cv_have_long_long_format,
Matthias Klosec511b472010-05-08 11:01:39 +00004590 AC_RUN_IFELSE([AC_LANG_SOURCE([[[
Mark Dickinson82864d12009-11-15 16:18:58 +00004591 #include <stdio.h>
4592 #include <stddef.h>
4593 #include <string.h>
4594
4595 #ifdef HAVE_SYS_TYPES_H
4596 #include <sys/types.h>
4597 #endif
4598
4599 int main()
4600 {
4601 char buffer[256];
4602
4603 if (sprintf(buffer, "%lld", (long long)123) < 0)
4604 return 1;
4605 if (strcmp(buffer, "123"))
4606 return 1;
4607
4608 if (sprintf(buffer, "%lld", (long long)-123) < 0)
4609 return 1;
4610 if (strcmp(buffer, "-123"))
4611 return 1;
4612
4613 if (sprintf(buffer, "%llu", (unsigned long long)123) < 0)
4614 return 1;
4615 if (strcmp(buffer, "123"))
4616 return 1;
4617
4618 return 0;
4619 }
Matthias Klosec511b472010-05-08 11:01:39 +00004620 ]]])],
4621 [ac_cv_have_long_long_format=yes],
4622 [ac_cv_have_long_long_format=no],
doko@python.orgd65e2ba2013-01-31 23:52:03 +01004623 [ac_cv_have_long_long_format="cross -- assuming no"
4624 if test x$GCC = xyes; then
4625 save_CFLAGS=$CFLAGS
4626 CFLAGS="$CFLAGS -Werror -Wformat"
4627 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4628 #include <stdio.h>
4629 #include <stddef.h>
4630 ]], [[
4631 char *buffer;
4632 sprintf(buffer, "%lld", (long long)123);
4633 sprintf(buffer, "%lld", (long long)-123);
4634 sprintf(buffer, "%llu", (unsigned long long)123);
4635 ]])],
4636 ac_cv_have_long_long_format=yes
4637 )
4638 CFLAGS=$save_CFLAGS
4639 fi])
Mark Dickinson82864d12009-11-15 16:18:58 +00004640 )
4641 AC_MSG_RESULT($ac_cv_have_long_long_format)
4642fi
4643
Mark Dickinson5ce84742009-12-31 20:48:04 +00004644if test "$ac_cv_have_long_long_format" = yes
Mark Dickinson82864d12009-11-15 16:18:58 +00004645then
4646 AC_DEFINE(PY_FORMAT_LONG_LONG, "ll",
4647 [Define to printf format modifier for long long type])
4648fi
4649
Ronald Oussoren315cd0c2009-11-19 16:25:21 +00004650if test $ac_sys_system = Darwin
4651then
4652 LIBS="$LIBS -framework CoreFoundation"
4653fi
4654
Mark Dickinson82864d12009-11-15 16:18:58 +00004655
Gregory P. Smithd8cb2d92009-11-02 02:02:38 +00004656AC_CACHE_CHECK([for %zd printf() format support], ac_cv_have_size_t_format, [dnl
Matthias Klosec511b472010-05-08 11:01:39 +00004657AC_RUN_IFELSE([AC_LANG_SOURCE([[
Alexandre Vassalottie7cf1182009-07-17 06:33:51 +00004658#include <stdio.h>
Brett Cannon09d12362006-05-11 05:11:33 +00004659#include <stddef.h>
4660#include <string.h>
4661
Christian Heimesdb3d6cb2007-12-16 21:39:43 +00004662#ifdef HAVE_SYS_TYPES_H
4663#include <sys/types.h>
4664#endif
Neal Norwitz4a8fbdb2006-09-22 08:16:26 +00004665
4666#ifdef HAVE_SSIZE_T
4667typedef ssize_t Py_ssize_t;
4668#elif SIZEOF_VOID_P == SIZEOF_LONG
4669typedef long Py_ssize_t;
4670#else
4671typedef int Py_ssize_t;
4672#endif
Brett Cannon09d12362006-05-11 05:11:33 +00004673
Christian Heimesdb3d6cb2007-12-16 21:39:43 +00004674int main()
4675{
4676 char buffer[256];
4677
Brett Cannon09d12362006-05-11 05:11:33 +00004678 if(sprintf(buffer, "%zd", (size_t)123) < 0)
4679 return 1;
4680
Neal Norwitz4a8fbdb2006-09-22 08:16:26 +00004681 if (strcmp(buffer, "123"))
Brett Cannon09d12362006-05-11 05:11:33 +00004682 return 1;
Neal Norwitz4a8fbdb2006-09-22 08:16:26 +00004683
4684 if (sprintf(buffer, "%zd", (Py_ssize_t)-123) < 0)
4685 return 1;
4686
4687 if (strcmp(buffer, "-123"))
4688 return 1;
4689
Brett Cannon09d12362006-05-11 05:11:33 +00004690 return 0;
Alexandre Vassalotti00900892009-07-17 05:26:39 +00004691}
Matthias Klosec511b472010-05-08 11:01:39 +00004692]])],
4693[ac_cv_have_size_t_format=yes],
4694[ac_cv_have_size_t_format=no],
4695[ac_cv_have_size_t_format="cross -- assuming yes"
4696])])
Gregory P. Smithd8cb2d92009-11-02 02:02:38 +00004697if test "$ac_cv_have_size_t_format" != no ; then
Alexandre Vassalotti00900892009-07-17 05:26:39 +00004698 AC_DEFINE(PY_FORMAT_SIZE_T, "z",
4699 [Define to printf format modifier for Py_ssize_t])
4700fi
Brett Cannon09d12362006-05-11 05:11:33 +00004701
Martin v. Löwis01c04012002-11-11 14:58:44 +00004702AC_CHECK_TYPE(socklen_t,,
4703 AC_DEFINE(socklen_t,int,
Matthias Klose5183ebd2010-04-24 16:38:36 +00004704 [Define to `int' if <sys/socket.h> does not define.]),[
Martin v. Löwis01c04012002-11-11 14:58:44 +00004705#ifdef HAVE_SYS_TYPES_H
4706#include <sys/types.h>
4707#endif
Guido van Rossum95713eb2000-05-18 20:53:31 +00004708#ifdef HAVE_SYS_SOCKET_H
4709#include <sys/socket.h>
4710#endif
Martin v. Löwis01c04012002-11-11 14:58:44 +00004711])
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00004712
R. David Murray1d9d16e2010-10-16 00:43:13 +00004713case $ac_sys_system in
4714AIX*)
4715 AC_DEFINE(HAVE_BROKEN_PIPE_BUF, 1, [Define if the system reports an invalid PIPE_BUF value.]) ;;
4716esac
4717
4718
Martin v. Löwis06f15bb2001-12-02 13:02:32 +00004719AC_SUBST(THREADHEADERS)
4720
4721for h in `(cd $srcdir;echo Python/thread_*.h)`
4722do
4723 THREADHEADERS="$THREADHEADERS \$(srcdir)/$h"
4724done
4725
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00004726AC_SUBST(SRCDIRS)
Victor Stinner5f4056a2017-04-28 03:41:40 +02004727SRCDIRS="Parser Objects Python Modules"
Andrew M. Kuchling8abedde2001-01-26 22:55:24 +00004728AC_MSG_CHECKING(for build directories)
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00004729for dir in $SRCDIRS; do
4730 if test ! -d $dir; then
4731 mkdir $dir
Fred Drake884d3ba2000-11-02 17:52:56 +00004732 fi
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00004733done
Benjamin Peterson2c992a02015-05-28 12:45:31 -05004734
4735# BEGIN_COMPUTED_GOTO
4736# Check for --with-computed-gotos
4737AC_MSG_CHECKING(for --with-computed-gotos)
4738AC_ARG_WITH(computed-gotos,
4739 AS_HELP_STRING([--with(out)-computed-gotos],
4740 [Use computed gotos in evaluation loop (enabled by default on supported compilers)]),
4741[
4742if test "$withval" = yes
4743then
4744 AC_DEFINE(USE_COMPUTED_GOTOS, 1,
4745 [Define if you want to use computed gotos in ceval.c.])
4746 AC_MSG_RESULT(yes)
4747fi
4748if test "$withval" = no
4749then
4750 AC_DEFINE(USE_COMPUTED_GOTOS, 0,
4751 [Define if you want to use computed gotos in ceval.c.])
4752 AC_MSG_RESULT(no)
4753fi
4754],
4755[AC_MSG_RESULT(no value specified)])
4756
4757AC_MSG_CHECKING(whether $CC supports computed gotos)
4758AC_CACHE_VAL(ac_cv_computed_gotos,
4759AC_RUN_IFELSE([AC_LANG_SOURCE([[[
4760int main(int argc, char **argv)
4761{
4762 static void *targets[1] = { &&LABEL1 };
4763 goto LABEL2;
4764LABEL1:
4765 return 0;
4766LABEL2:
4767 goto *targets[0];
4768 return 1;
4769}
4770]]])],
4771[ac_cv_computed_gotos=yes],
4772[ac_cv_computed_gotos=no],
4773[if test "${with_computed_gotos+set}" = set; then
4774 ac_cv_computed_gotos="$with_computed_gotos -- configured --with(out)-computed-gotos"
4775 else
4776 ac_cv_computed_gotos=no
4777 fi]))
4778AC_MSG_RESULT($ac_cv_computed_gotos)
4779case "$ac_cv_computed_gotos" in yes*)
4780 AC_DEFINE(HAVE_COMPUTED_GOTOS, 1,
4781 [Define if the C compiler supports computed gotos.])
4782esac
4783# END_COMPUTED_GOTO
4784
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00004785AC_MSG_RESULT(done)
Fred Drake036144d2000-10-26 17:09:35 +00004786
Ned Deily3f1d0b32014-11-20 02:11:03 -08004787# ensurepip option
4788AC_MSG_CHECKING(for ensurepip)
4789AC_ARG_WITH(ensurepip,
4790 [AS_HELP_STRING([--with(out)-ensurepip=@<:@=OPTION@:>@],
4791 ["install" or "upgrade" using bundled pip, default is "no"])],
4792 [],
4793 [with_ensurepip=no])
4794AS_CASE($with_ensurepip,
4795 [yes|upgrade],[ENSUREPIP=upgrade],
4796 [install],[ENSUREPIP=install],
4797 [no],[ENSUREPIP=no],
4798 [AC_MSG_ERROR([--with-ensurepip=upgrade|install|no])])
4799AC_MSG_RESULT($ENSUREPIP)
4800AC_SUBST(ENSUREPIP)
4801
Guido van Rossum627b2d71993-12-24 10:39:16 +00004802# generate output files
Antoine Pitrouf2caeed2009-05-24 20:23:57 +00004803AC_CONFIG_FILES(Makefile.pre Modules/Setup.config Misc/python.pc)
Antoine Pitrouaabdceb2010-09-10 20:03:17 +00004804AC_CONFIG_FILES([Modules/ld_so_aix], [chmod +x Modules/ld_so_aix])
Martin v. Löwis88afe662002-10-26 13:47:44 +00004805AC_OUTPUT
Neil Schemenauer61c51152001-01-26 16:18:16 +00004806
Martin v. Löwisf7afe952006-04-14 15:16:15 +00004807echo "creating Modules/Setup"
Neil Schemenauer61c51152001-01-26 16:18:16 +00004808if test ! -f Modules/Setup
4809then
4810 cp $srcdir/Modules/Setup.dist Modules/Setup
4811fi
4812
Martin v. Löwisf7afe952006-04-14 15:16:15 +00004813echo "creating Modules/Setup.local"
Neil Schemenauer61c51152001-01-26 16:18:16 +00004814if test ! -f Modules/Setup.local
4815then
4816 echo "# Edit this file for local setup changes" >Modules/Setup.local
4817fi
4818
4819echo "creating Makefile"
4820$SHELL $srcdir/Modules/makesetup -c $srcdir/Modules/config.c.in \
4821 -s Modules Modules/Setup.config \
Neil Schemenauerf8b71c52001-04-21 17:41:16 +00004822 Modules/Setup.local Modules/Setup
Skip Montanaro7221d932007-08-22 19:02:16 +00004823
4824case $ac_sys_system in
4825BeOS)
4826 AC_MSG_WARN([
4827
4828 Support for BeOS is deprecated as of Python 2.6.
4829 See PEP 11 for the gory details.
4830 ])
4831 ;;
4832*) ;;
4833esac
4834
Neil Schemenauer66252162001-02-19 04:47:42 +00004835mv config.c Modules
Gregory P. Smith6d8fdfc2016-09-07 23:28:23 -07004836
4837if test "$Py_OPT" = 'false' -a "$Py_DEBUG" != 'true'; then
4838 echo "" >&AS_MESSAGE_FD
4839 echo "" >&AS_MESSAGE_FD
4840 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 +00004841 echo "please run ./configure --enable-optimizations" >&AS_MESSAGE_FD
Gregory P. Smith6d8fdfc2016-09-07 23:28:23 -07004842 echo "" >&AS_MESSAGE_FD
4843 echo "" >&AS_MESSAGE_FD
4844fi