blob: 36625f7b82a34366ae0e0ec1a0bb9f976bc11cf9 [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,
Ned Deilyee8e4b62018-04-14 10:37:28 -0400116 AS_HELP_STRING([--enable-universalsdk@<:@=SDKDIR@:>@], [Build fat binary against Mac OS X SDK]),
Ronald Oussoren988117f2006-04-29 11:31:35 +0000117[
118 case $enableval in
119 yes)
Ned Deilyee8e4b62018-04-14 10:37:28 -0400120 # Locate the best usable SDK, see Mac/README.txt for more
121 # information
122 enableval="`/usr/bin/xcodebuild -version -sdk macosx Path 2>/dev/null`"
123 if ! ( echo $enableval | grep -E '\.sdk' 1>/dev/null )
Ronald Oussoren3c0a1262010-01-17 19:27:57 +0000124 then
Ned Deilyee8e4b62018-04-14 10:37:28 -0400125 enableval=/Developer/SDKs/MacOSX10.4u.sdk
126 if test ! -d "${enableval}"
127 then
128 enableval=/
129 fi
Ronald Oussoren3c0a1262010-01-17 19:27:57 +0000130 fi
Ronald Oussoren988117f2006-04-29 11:31:35 +0000131 ;;
132 esac
133 case $enableval in
134 no)
135 UNIVERSALSDK=
136 enable_universalsdk=
137 ;;
138 *)
139 UNIVERSALSDK=$enableval
Ronald Oussoren3c0a1262010-01-17 19:27:57 +0000140 if test ! -d "${UNIVERSALSDK}"
141 then
142 AC_MSG_ERROR([--enable-universalsdk specifies non-existing SDK: ${UNIVERSALSDK}])
143 fi
Ronald Oussoren988117f2006-04-29 11:31:35 +0000144 ;;
145 esac
Ned Deilyee8e4b62018-04-14 10:37:28 -0400146
Ronald Oussoren988117f2006-04-29 11:31:35 +0000147],[
148 UNIVERSALSDK=
149 enable_universalsdk=
150])
Ronald Oussoren3c0a1262010-01-17 19:27:57 +0000151if test -n "${UNIVERSALSDK}"
152then
153 AC_MSG_RESULT(${UNIVERSALSDK})
154else
155 AC_MSG_RESULT(no)
156fi
Ronald Oussoren988117f2006-04-29 11:31:35 +0000157AC_SUBST(UNIVERSALSDK)
158
Benjamin Peterson0e6ea5d2008-07-16 20:17:04 +0000159AC_SUBST(ARCH_RUN_32BIT)
Ned Deily8e60f6e2013-05-30 00:14:29 -0700160ARCH_RUN_32BIT=""
Benjamin Peterson0e6ea5d2008-07-16 20:17:04 +0000161
Ned Deilyee8e4b62018-04-14 10:37:28 -0400162# For backward compatibility reasons we prefer to select '32-bit' if available,
163# otherwise use 'intel'
Ronald Oussoren5640ce22008-06-05 12:58:24 +0000164UNIVERSAL_ARCHS="32-bit"
Ned Deilyee8e4b62018-04-14 10:37:28 -0400165if test "`uname -s`" = "Darwin"
166then
167 if test -n "${UNIVERSALSDK}"
168 then
169 if test -z "`/usr/bin/file -L "${UNIVERSALSDK}/usr/lib/libSystem.dylib" | grep ppc`"
170 then
171 UNIVERSAL_ARCHS="intel"
172 fi
173 fi
174fi
175
Ronald Oussoren92919a62009-12-24 13:30:58 +0000176AC_SUBST(LIPO_32BIT_FLAGS)
Ronald Oussoren5640ce22008-06-05 12:58:24 +0000177AC_MSG_CHECKING(for --with-universal-archs)
178AC_ARG_WITH(universal-archs,
Ned Deilyee8e4b62018-04-14 10:37:28 -0400179 AS_HELP_STRING([--with-universal-archs=ARCH], [select architectures for universal build ("32-bit", "64-bit", "3-way", "intel", "intel-32", "intel-64", or "all")]),
Ronald Oussoren5640ce22008-06-05 12:58:24 +0000180[
Ronald Oussoren5640ce22008-06-05 12:58:24 +0000181 UNIVERSAL_ARCHS="$withval"
182],
Ned Deilyee8e4b62018-04-14 10:37:28 -0400183[])
184if test -n "${UNIVERSALSDK}"
185then
186 AC_MSG_RESULT(${UNIVERSAL_ARCHS})
187else
188 AC_MSG_RESULT(no)
189fi
Ronald Oussoren5640ce22008-06-05 12:58:24 +0000190
Ronald Oussoren580c7fe2008-05-02 19:45:11 +0000191AC_ARG_WITH(framework-name,
Matthias Klose22520ea2010-05-08 10:14:46 +0000192 AS_HELP_STRING([--with-framework-name=FRAMEWORK],
Matthias Klose5183ebd2010-04-24 16:38:36 +0000193 [specify an alternate name of the framework built with --enable-framework]),
Ronald Oussoren580c7fe2008-05-02 19:45:11 +0000194[
Ronald Oussoren9ebd2422009-09-29 13:00:44 +0000195 if test "${enable_framework}"; then
196 :
197 else
198 AC_MSG_ERROR([--with-framework-name without --enable-framework. See Mac/README])
199 fi
Ronald Oussoren580c7fe2008-05-02 19:45:11 +0000200 PYTHONFRAMEWORK=${withval}
201 PYTHONFRAMEWORKDIR=${withval}.framework
202 PYTHONFRAMEWORKIDENTIFIER=org.python.`echo $withval | tr '[A-Z]' '[a-z]'`
203 ],[
204 PYTHONFRAMEWORK=Python
205 PYTHONFRAMEWORKDIR=Python.framework
206 PYTHONFRAMEWORKIDENTIFIER=org.python.python
207])
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000208dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000209AC_ARG_ENABLE(framework,
Matthias Klose22520ea2010-05-08 10:14:46 +0000210 AS_HELP_STRING([--enable-framework@<:@=INSTALLDIR@:>@], [Build (MacOSX|Darwin) framework]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000211[
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000212 case $enableval in
213 yes)
214 enableval=/Library/Frameworks
Jack Jansen127e56e2001-09-11 14:41:54 +0000215 esac
216 case $enableval in
217 no)
218 PYTHONFRAMEWORK=
219 PYTHONFRAMEWORKDIR=no-framework
220 PYTHONFRAMEWORKPREFIX=
221 PYTHONFRAMEWORKINSTALLDIR=
Ronald Oussoren567a8ff2006-05-26 11:43:26 +0000222 FRAMEWORKINSTALLFIRST=
223 FRAMEWORKINSTALLLAST=
Ronald Oussoren5b787322006-06-06 19:50:24 +0000224 FRAMEWORKALTINSTALLFIRST=
225 FRAMEWORKALTINSTALLLAST=
Ronald Oussoren2db3a8f2006-06-07 19:06:01 +0000226 if test "x${prefix}" = "xNONE"; then
227 FRAMEWORKUNIXTOOLSPREFIX="${ac_default_prefix}"
228 else
229 FRAMEWORKUNIXTOOLSPREFIX="${prefix}"
230 fi
Jack Jansen127e56e2001-09-11 14:41:54 +0000231 enable_framework=
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000232 ;;
233 *)
Ronald Oussoren01d149f2010-04-30 11:20:14 +0000234 PYTHONFRAMEWORKPREFIX="${enableval}"
Jack Jansen127e56e2001-09-11 14:41:54 +0000235 PYTHONFRAMEWORKINSTALLDIR=$PYTHONFRAMEWORKPREFIX/$PYTHONFRAMEWORKDIR
Ronald Oussoren567a8ff2006-05-26 11:43:26 +0000236 FRAMEWORKINSTALLFIRST="frameworkinstallstructure"
Ronald Oussoren5640ce22008-06-05 12:58:24 +0000237 FRAMEWORKALTINSTALLFIRST="frameworkinstallstructure bininstall maninstall"
Ronald Oussoren92919a62009-12-24 13:30:58 +0000238 FRAMEWORKINSTALLLAST="frameworkinstallmaclib frameworkinstallapps frameworkinstallunixtools"
239 FRAMEWORKALTINSTALLLAST="frameworkinstallmaclib frameworkinstallapps frameworkaltinstallunixtools"
Ronald Oussoren01d149f2010-04-30 11:20:14 +0000240 FRAMEWORKINSTALLAPPSPREFIX="/Applications"
Ronald Oussoren5640ce22008-06-05 12:58:24 +0000241
Ronald Oussoren2db3a8f2006-06-07 19:06:01 +0000242 if test "x${prefix}" = "xNONE" ; then
243 FRAMEWORKUNIXTOOLSPREFIX="${ac_default_prefix}"
Ronald Oussoren01d149f2010-04-30 11:20:14 +0000244
Ronald Oussoren2db3a8f2006-06-07 19:06:01 +0000245 else
246 FRAMEWORKUNIXTOOLSPREFIX="${prefix}"
247 fi
Ronald Oussoren01d149f2010-04-30 11:20:14 +0000248
249 case "${enableval}" in
250 /System*)
251 FRAMEWORKINSTALLAPPSPREFIX="/Applications"
252 if test "${prefix}" = "NONE" ; then
253 # See below
254 FRAMEWORKUNIXTOOLSPREFIX="/usr"
255 fi
256 ;;
257
258 /Library*)
259 FRAMEWORKINSTALLAPPSPREFIX="/Applications"
260 ;;
261
262 */Library/Frameworks)
263 MDIR="`dirname "${enableval}"`"
264 MDIR="`dirname "${MDIR}"`"
265 FRAMEWORKINSTALLAPPSPREFIX="${MDIR}/Applications"
266
267 if test "${prefix}" = "NONE"; then
268 # User hasn't specified the
269 # --prefix option, but wants to install
270 # the framework in a non-default location,
271 # ensure that the compatibility links get
272 # installed relative to that prefix as well
273 # instead of in /usr/local.
274 FRAMEWORKUNIXTOOLSPREFIX="${MDIR}"
275 fi
276 ;;
277
278 *)
279 FRAMEWORKINSTALLAPPSPREFIX="/Applications"
280 ;;
281 esac
282
Jack Jansen127e56e2001-09-11 14:41:54 +0000283 prefix=$PYTHONFRAMEWORKINSTALLDIR/Versions/$VERSION
Ronald Oussoren836b0392006-05-14 19:56:34 +0000284
Ronald Oussoren580c7fe2008-05-02 19:45:11 +0000285 # Add files for Mac specific code to the list of output
Ronald Oussoren836b0392006-05-14 19:56:34 +0000286 # files:
Ronald Oussoren2db3a8f2006-06-07 19:06:01 +0000287 AC_CONFIG_FILES(Mac/Makefile)
288 AC_CONFIG_FILES(Mac/PythonLauncher/Makefile)
289 AC_CONFIG_FILES(Mac/IDLE/Makefile)
Ronald Oussoren580c7fe2008-05-02 19:45:11 +0000290 AC_CONFIG_FILES(Mac/Resources/framework/Info.plist)
291 AC_CONFIG_FILES(Mac/Resources/app/Info.plist)
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000292 esac
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000293 ],[
294 PYTHONFRAMEWORK=
Jack Jansen127e56e2001-09-11 14:41:54 +0000295 PYTHONFRAMEWORKDIR=no-framework
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000296 PYTHONFRAMEWORKPREFIX=
297 PYTHONFRAMEWORKINSTALLDIR=
Ronald Oussoren567a8ff2006-05-26 11:43:26 +0000298 FRAMEWORKINSTALLFIRST=
299 FRAMEWORKINSTALLLAST=
Ronald Oussoren5b787322006-06-06 19:50:24 +0000300 FRAMEWORKALTINSTALLFIRST=
301 FRAMEWORKALTINSTALLLAST=
Ronald Oussoren2db3a8f2006-06-07 19:06:01 +0000302 if test "x${prefix}" = "xNONE" ; then
303 FRAMEWORKUNIXTOOLSPREFIX="${ac_default_prefix}"
304 else
305 FRAMEWORKUNIXTOOLSPREFIX="${prefix}"
306 fi
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000307 enable_framework=
Ronald Oussoren5640ce22008-06-05 12:58:24 +0000308
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000309])
310AC_SUBST(PYTHONFRAMEWORK)
Ronald Oussoren580c7fe2008-05-02 19:45:11 +0000311AC_SUBST(PYTHONFRAMEWORKIDENTIFIER)
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000312AC_SUBST(PYTHONFRAMEWORKDIR)
313AC_SUBST(PYTHONFRAMEWORKPREFIX)
314AC_SUBST(PYTHONFRAMEWORKINSTALLDIR)
Ronald Oussoren567a8ff2006-05-26 11:43:26 +0000315AC_SUBST(FRAMEWORKINSTALLFIRST)
316AC_SUBST(FRAMEWORKINSTALLLAST)
Ronald Oussoren5b787322006-06-06 19:50:24 +0000317AC_SUBST(FRAMEWORKALTINSTALLFIRST)
318AC_SUBST(FRAMEWORKALTINSTALLLAST)
319AC_SUBST(FRAMEWORKUNIXTOOLSPREFIX)
Ronald Oussoren01d149f2010-04-30 11:20:14 +0000320AC_SUBST(FRAMEWORKINSTALLAPPSPREFIX)
Guido van Rossum4b6b5791996-09-09 20:09:34 +0000321
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000322##AC_ARG_WITH(dyld,
Matthias Klose22520ea2010-05-08 10:14:46 +0000323## AS_HELP_STRING([--with-dyld],
324## [Use (OpenStep|Rhapsody) dynamic linker]))
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000325##
Guido van Rossumb418f891996-07-30 18:06:02 +0000326# Set name for machine-dependent library files
327AC_SUBST(MACHDEP)
328AC_MSG_CHECKING(MACHDEP)
329if test -z "$MACHDEP"
330then
doko@python.orgd65e2ba2013-01-31 23:52:03 +0100331 # avoid using uname for cross builds
332 if test "$cross_compiling" = yes; then
333 # ac_sys_system and ac_sys_release are only used for setting
334 # `define_xopen_source' in the case statement below. For the
335 # current supported cross builds, this macro is not adjusted.
336 case "$host" in
337 *-*-linux*)
338 ac_sys_system=Linux
339 ;;
340 *-*-cygwin*)
341 ac_sys_system=Cygwin
342 ;;
343 *)
344 # for now, limit cross builds to known configurations
345 MACHDEP="unknown"
346 AC_MSG_ERROR([cross build not supported for $host])
347 esac
348 ac_sys_release=
349 else
Guido van Rossum4b6b5791996-09-09 20:09:34 +0000350 ac_sys_system=`uname -s`
Georg Brandlfe18a112009-09-04 07:55:14 +0000351 if test "$ac_sys_system" = "AIX" \
Martin v. Löwis21ee4092002-09-30 16:19:48 +0000352 -o "$ac_sys_system" = "UnixWare" -o "$ac_sys_system" = "OpenUNIX"; then
Guido van Rossum4b6b5791996-09-09 20:09:34 +0000353 ac_sys_release=`uname -v`
Guido van Rossumb418f891996-07-30 18:06:02 +0000354 else
Guido van Rossum4b6b5791996-09-09 20:09:34 +0000355 ac_sys_release=`uname -r`
Guido van Rossumb418f891996-07-30 18:06:02 +0000356 fi
doko@python.orgd65e2ba2013-01-31 23:52:03 +0100357 fi
358 ac_md_system=`echo $ac_sys_system |
359 tr -d '[/ ]' | tr '[[A-Z]]' '[[a-z]]'`
360 ac_md_release=`echo $ac_sys_release |
361 tr -d '[/ ]' | sed 's/^[[A-Z]]\.//' | sed 's/\..*//'`
362 MACHDEP="$ac_md_system$ac_md_release"
Guido van Rossum4b6b5791996-09-09 20:09:34 +0000363
doko@python.orgd65e2ba2013-01-31 23:52:03 +0100364 case $MACHDEP in
Victor Stinneracacbaa2011-08-20 14:02:38 +0200365 linux*) MACHDEP="linux2";;
Andrew M. Kuchling5a3e4cb2001-07-20 19:29:04 +0000366 cygwin*) MACHDEP="cygwin";;
Jack Jansen8a97f4a2001-12-05 23:27:32 +0000367 darwin*) MACHDEP="darwin";;
Martin v. Löwisf90ae202002-06-11 06:22:31 +0000368 atheos*) MACHDEP="atheos";;
Martin v. Löwisf3322282003-07-13 09:46:13 +0000369 irix646) MACHDEP="irix6";;
Guido van Rossumb97ef171997-09-28 05:44:03 +0000370 '') MACHDEP="unknown";;
doko@python.orgd65e2ba2013-01-31 23:52:03 +0100371 esac
372fi
373
374AC_SUBST(_PYTHON_HOST_PLATFORM)
375if test "$cross_compiling" = yes; then
376 case "$host" in
377 *-*-linux*)
378 case "$host_cpu" in
379 arm*)
380 _host_cpu=arm
381 ;;
382 *)
383 _host_cpu=$host_cpu
384 esac
385 ;;
386 *-*-cygwin*)
387 _host_cpu=
388 ;;
389 *)
390 # for now, limit cross builds to known configurations
391 MACHDEP="unknown"
392 AC_MSG_ERROR([cross build not supported for $host])
Guido van Rossumb418f891996-07-30 18:06:02 +0000393 esac
doko@python.orgd65e2ba2013-01-31 23:52:03 +0100394 _PYTHON_HOST_PLATFORM="$MACHDEP${_host_cpu:+-$_host_cpu}"
Guido van Rossumb418f891996-07-30 18:06:02 +0000395fi
Jack Jansen83f898c2002-12-30 22:23:40 +0000396
Martin v. Löwise981a4e2002-11-11 13:26:51 +0000397# Some systems cannot stand _XOPEN_SOURCE being defined at all; they
398# disable features if it is defined, without any means to access these
399# features as extensions. For these systems, we skip the definition of
400# _XOPEN_SOURCE. Before adding a system to the list to gain access to
401# some feature, make sure there is no alternative way to access this
402# feature. Also, when using wildcards, make sure you have verified the
403# need for not defining _XOPEN_SOURCE on all systems matching the
404# wildcard, and that the wildcard does not include future systems
405# (which may remove their limitations).
406dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
407case $ac_sys_system/$ac_sys_release in
408 # On OpenBSD, select(2) is not available if _XOPEN_SOURCE is defined,
409 # even though select is a POSIX function. Reported by J. Ribbens.
Martin v. Löwis76bafc62003-10-03 13:47:44 +0000410 # Reconfirmed for OpenBSD 3.3 by Zachary Hamm, for 3.4 by Jason Ish.
Martin v. Löwis7875ef62010-02-15 21:41:12 +0000411 # In addition, Stefan Krah confirms that issue #1244610 exists through
412 # OpenBSD 4.6, but is fixed in 4.7.
Charles-François Natali97781b02011-07-22 23:43:42 +0200413 OpenBSD/2.* | OpenBSD/3.* | OpenBSD/4.@<:@0123456@:>@)
Martin v. Löwiscb78de62007-12-29 18:49:21 +0000414 define_xopen_source=no
415 # OpenBSD undoes our definition of __BSD_VISIBLE if _XOPEN_SOURCE is
416 # also defined. This can be overridden by defining _BSD_SOURCE
417 # As this has a different meaning on Linux, only define it on OpenBSD
418 AC_DEFINE(_BSD_SOURCE, 1, [Define on OpenBSD to activate all library features])
419 ;;
Charles-François Natali97781b02011-07-22 23:43:42 +0200420 OpenBSD/*)
Martin v. Löwis5e2dd862010-02-15 08:32:00 +0000421 # OpenBSD undoes our definition of __BSD_VISIBLE if _XOPEN_SOURCE is
422 # also defined. This can be overridden by defining _BSD_SOURCE
423 # As this has a different meaning on Linux, only define it on OpenBSD
424 AC_DEFINE(_BSD_SOURCE, 1, [Define on OpenBSD to activate all library features])
425 ;;
Martin v. Löwis4d542ec2006-11-25 15:39:19 +0000426 # Defining _XOPEN_SOURCE on NetBSD version prior to the introduction of
427 # _NETBSD_SOURCE disables certain features (eg. setgroups). Reported by
428 # Marc Recht
Georg Brandl4b9bcfc2008-11-16 08:00:17 +0000429 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 +0000430 define_xopen_source=no;;
Martin v. Löwisb41afb52010-05-28 15:28:47 +0000431 # From the perspective of Solaris, _XOPEN_SOURCE is not so much a
432 # request to enable features supported by the standard as a request
433 # to disable features not supported by the standard. The best way
434 # for Python to use Solaris is simply to leave _XOPEN_SOURCE out
435 # entirely and define __EXTENSIONS__ instead.
436 SunOS/*)
Martin v. Löwisa9d71422003-03-28 18:43:31 +0000437 define_xopen_source=no;;
Martin v. Löwisc2409b42003-05-11 05:53:41 +0000438 # On UnixWare 7, u_long is never defined with _XOPEN_SOURCE,
439 # but used in /usr/include/netinet/tcp.h. Reported by Tim Rice.
Martin v. Löwis253d1f42004-05-07 19:14:14 +0000440 # Reconfirmed for 7.1.4 by Martin v. Loewis.
441 OpenUNIX/8.0.0| UnixWare/7.1.@<:@0-4@:>@)
Martin v. Löwisc2409b42003-05-11 05:53:41 +0000442 define_xopen_source=no;;
443 # On OpenServer 5, u_short is never defined with _XOPEN_SOURCE,
Martin v. Löwis53e73c32003-05-05 05:13:18 +0000444 # but used in struct sockaddr.sa_family. Reported by Tim Rice.
Martin v. Löwisc2409b42003-05-11 05:53:41 +0000445 SCO_SV/3.2)
Martin v. Löwis53e73c32003-05-05 05:13:18 +0000446 define_xopen_source=no;;
Martin v. Löwisbb86d832008-11-04 20:40:09 +0000447 # On FreeBSD 4, the math functions C89 does not cover are never defined
448 # with _XOPEN_SOURCE and __BSD_VISIBLE does not re-enable them.
449 FreeBSD/4.*)
450 define_xopen_source=no;;
451 # On MacOS X 10.2, a bug in ncurses.h means that it craps out if
452 # _XOPEN_EXTENDED_SOURCE is defined. Apparently, this is fixed in 10.3, which
453 # identifies itself as Darwin/7.*
454 # On Mac OS X 10.4, defining _POSIX_C_SOURCE or _XOPEN_SOURCE
455 # disables platform specific features beyond repair.
456 # On Mac OS X 10.3, defining _POSIX_C_SOURCE or _XOPEN_SOURCE
457 # has no effect, don't bother defining them
458 Darwin/@<:@6789@:>@.*)
Anthony Baxter6169c6b2003-10-04 07:46:23 +0000459 define_xopen_source=no;;
Ronald Oussorena55af9a2010-01-17 16:25:57 +0000460 Darwin/1@<:@0-9@:>@.*)
461 define_xopen_source=no;;
Trent Mickaf16e8c2004-08-25 23:55:59 +0000462 # On AIX 4 and 5.1, mbstate_t is defined only when _XOPEN_SOURCE == 500 but
463 # used in wcsnrtombs() and mbsnrtowcs() even if _XOPEN_SOURCE is not defined
464 # or has another value. By not (re)defining it, the defaults come in place.
Martin v. Löwisc19c5a62003-11-18 20:00:44 +0000465 AIX/4)
466 define_xopen_source=no;;
Trent Mickaf16e8c2004-08-25 23:55:59 +0000467 AIX/5)
468 if test `uname -r` -eq 1; then
469 define_xopen_source=no
470 fi
471 ;;
Martin v. Löwis8c255e42008-05-23 15:06:50 +0000472 # On QNX 6.3.2, defining _XOPEN_SOURCE prevents netdb.h from
473 # defining NI_NUMERICHOST.
474 QNX/6.3.2)
475 define_xopen_source=no
476 ;;
Martin v. Löwisa0588362006-04-04 06:03:50 +0000477
Martin v. Löwise981a4e2002-11-11 13:26:51 +0000478esac
479
480if test $define_xopen_source = yes
481then
Martin v. Löwisb41afb52010-05-28 15:28:47 +0000482 AC_DEFINE(_XOPEN_SOURCE, 600,
483 Define to the level of X/Open that your system supports)
Martin v. Löwis678fc1e2002-11-12 06:04:39 +0000484
485 # On Tru64 Unix 4.0F, defining _XOPEN_SOURCE also requires
486 # definition of _XOPEN_SOURCE_EXTENDED and _POSIX_C_SOURCE, or else
487 # several APIs are not declared. Since this is also needed in some
488 # cases for HP-UX, we define it globally.
Martin v. Löwisb41afb52010-05-28 15:28:47 +0000489 AC_DEFINE(_XOPEN_SOURCE_EXTENDED, 1,
490 Define to activate Unix95-and-earlier features)
Martin v. Löwis678fc1e2002-11-12 06:04:39 +0000491
Bob Ippolito7026a0a2005-03-28 23:23:47 +0000492 AC_DEFINE(_POSIX_C_SOURCE, 200112L, Define to activate features from IEEE Stds 1003.1-2001)
493
Martin v. Löwise981a4e2002-11-11 13:26:51 +0000494fi
495
Guido van Rossum91922671997-10-09 20:24:13 +0000496#
497# SGI compilers allow the specification of the both the ABI and the
498# ISA on the command line. Depending on the values of these switches,
Martin Panterb1d867f2016-05-26 05:28:50 +0000499# different and often incompatible code will be generated.
Guido van Rossum91922671997-10-09 20:24:13 +0000500#
501# The SGI_ABI variable can be used to modify the CC and LDFLAGS and
502# thus supply support for various ABI/ISA combinations. The MACHDEP
503# variable is also adjusted.
504#
505AC_SUBST(SGI_ABI)
506if test ! -z "$SGI_ABI"
507then
508 CC="cc $SGI_ABI"
509 LDFLAGS="$SGI_ABI $LDFLAGS"
510 MACHDEP=`echo "${MACHDEP}${SGI_ABI}" | sed 's/ *//g'`
511fi
Guido van Rossumb418f891996-07-30 18:06:02 +0000512AC_MSG_RESULT($MACHDEP)
513
doko@ubuntu.com9e7ece22015-04-13 21:55:08 +0200514AC_SUBST(PLATDIR)
515PLATDIR=plat-$MACHDEP
516
Jack Jansen83f898c2002-12-30 22:23:40 +0000517# And add extra plat-mac for darwin
518AC_SUBST(EXTRAPLATDIR)
Jack Jansen7b59b422003-03-17 15:44:10 +0000519AC_SUBST(EXTRAMACHDEPPATH)
Jack Jansen83f898c2002-12-30 22:23:40 +0000520AC_MSG_CHECKING(EXTRAPLATDIR)
521if test -z "$EXTRAPLATDIR"
522then
523 case $MACHDEP in
Jack Jansen7b59b422003-03-17 15:44:10 +0000524 darwin)
525 EXTRAPLATDIR="\$(PLATMACDIRS)"
526 EXTRAMACHDEPPATH="\$(PLATMACPATH)"
527 ;;
528 *)
529 EXTRAPLATDIR=""
530 EXTRAMACHDEPPATH=""
531 ;;
Jack Jansen83f898c2002-12-30 22:23:40 +0000532 esac
533fi
534AC_MSG_RESULT($EXTRAPLATDIR)
535
Jack Jansen6b08a402004-06-03 12:41:45 +0000536# Record the configure-time value of MACOSX_DEPLOYMENT_TARGET,
537# it may influence the way we can build extensions, so distutils
538# needs to check it
539AC_SUBST(CONFIGURE_MACOSX_DEPLOYMENT_TARGET)
Ronald Oussoren988117f2006-04-29 11:31:35 +0000540AC_SUBST(EXPORT_MACOSX_DEPLOYMENT_TARGET)
Jack Jansen6b08a402004-06-03 12:41:45 +0000541CONFIGURE_MACOSX_DEPLOYMENT_TARGET=
Ronald Oussoren988117f2006-04-29 11:31:35 +0000542EXPORT_MACOSX_DEPLOYMENT_TARGET='#'
Jack Jansen6b08a402004-06-03 12:41:45 +0000543
Guido van Rossum627b2d71993-12-24 10:39:16 +0000544# checks for alternative programs
Skip Montanarodecc6a42003-01-01 20:07:49 +0000545
546# compiler flags are generated in two sets, BASECFLAGS and OPT. OPT is just
547# for debug/optimization stuff. BASECFLAGS is for flags that are required
548# just to get things to compile and link. Users are free to override OPT
549# when running configure or make. The build should not break if they do.
550# BASECFLAGS should generally not be messed with, however.
551
552# XXX shouldn't some/most/all of this code be merged with the stuff later
553# on that fiddles with OPT and BASECFLAGS?
Guido van Rossum5739e7e1995-01-20 16:50:53 +0000554AC_MSG_CHECKING(for --without-gcc)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000555AC_ARG_WITH(gcc,
Matthias Klose22520ea2010-05-08 10:14:46 +0000556 AS_HELP_STRING([--without-gcc], [never use gcc]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000557[
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000558 case $withval in
Skip Montanaro516144f2009-01-04 10:36:58 +0000559 no) CC=${CC:-cc}
Guido van Rossum5739e7e1995-01-20 16:50:53 +0000560 without_gcc=yes;;
561 yes) CC=gcc
562 without_gcc=no;;
563 *) CC=$withval
564 without_gcc=$withval;;
Guido van Rossum55a214e1995-09-13 17:48:09 +0000565 esac], [
Guido van Rossumb418f891996-07-30 18:06:02 +0000566 case $ac_sys_system in
Antoine Pitrou285cd162010-09-21 15:23:17 +0000567 AIX*) CC=${CC:-xlc_r}
Neil Schemenauerb3531b82001-02-16 04:09:05 +0000568 without_gcc=;;
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000569 BeOS*)
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000570 case $BE_HOST_CPU in
571 ppc)
Fred Drake5790be12000-10-09 17:06:13 +0000572 CC=mwcc
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000573 without_gcc=yes
Skip Montanarodecc6a42003-01-01 20:07:49 +0000574 BASECFLAGS="$BASECFLAGS -export pragma"
575 OPT="$OPT -O"
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000576 LDFLAGS="$LDFLAGS -nodup"
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000577 ;;
578 x86)
Fred Drake5790be12000-10-09 17:06:13 +0000579 CC=gcc
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000580 without_gcc=no
Skip Montanarodecc6a42003-01-01 20:07:49 +0000581 OPT="$OPT -O"
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000582 ;;
583 *)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000584 AC_MSG_ERROR([Unknown BeOS platform "$BE_HOST_CPU"])
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000585 ;;
586 esac
Neil Schemenauerb3531b82001-02-16 04:09:05 +0000587 AR="\$(srcdir)/Modules/ar_beos"
588 RANLIB=:
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000589 ;;
Martin v. Löwis130fb172001-07-19 11:00:41 +0000590 *) without_gcc=no;;
Guido van Rossum55a214e1995-09-13 17:48:09 +0000591 esac])
Guido van Rossum5739e7e1995-01-20 16:50:53 +0000592AC_MSG_RESULT($without_gcc)
593
Zachary Ware6ed42ea2015-12-21 11:43:03 -0600594AC_MSG_CHECKING(for --with-icc)
595AC_ARG_WITH(icc,
596 AS_HELP_STRING([--with-icc], [build with icc]),
597[
598 case $withval in
599 no) CC=${CC:-cc}
600 with_icc=no;;
601 yes) CC=icc
602 CXX=icpc
603 with_icc=yes;;
604 *) CC=$withval
605 with_icc=$withval;;
606 esac], [
607 with_icc=no])
608AC_MSG_RESULT($with_icc)
609
Guido van Rossum03ad99f1995-03-09 14:09:54 +0000610# If the user switches compilers, we can't believe the cache
611if test ! -z "$ac_cv_prog_CC" -a ! -z "$CC" -a "$CC" != "$ac_cv_prog_CC"
612then
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000613 AC_MSG_ERROR([cached CC is different -- throw away $cache_file
614(it is also a good idea to do 'make clean' before compiling)])
Guido van Rossum03ad99f1995-03-09 14:09:54 +0000615fi
616
Trent Nelson15daa352012-12-13 06:46:39 +0000617if test "$MACHDEP" = "irix6" && test "$CC" != "gcc"; then
618 # Normally, MIPSpro CC treats #error directives as warnings, which means
619 # a successful exit code is returned (0). This is a problem because IRIX
620 # has a bunch of system headers with this guard at the top:
621 #
622 # #ifndef __c99
623 # #error This header file is to be used only for c99 mode compilations
624 # #else
625 #
626 # When autoconf tests for such a header, like stdint.h, this happens:
627 #
628 # configure:4619: cc -c conftest.c >&5
629 # cc-1035 cc: WARNING File = /usr/include/stdint.h, Line = 5
630 # #error directive: This header file is to be used only for c99 mode
631 # compilations
632 #
633 # #error This header file is to be used only for c99 mode compilations
634 # ^
635 #
636 # configure:4619: $? = 0
637 # configure:4619: result: yes
638 #
639 # Therefore, we use `-diag_error 1035` to have the compiler treat the
640 # warning as an error, which causes cc to return a non-zero result,
641 # which autoconf can interpret correctly.
642 CFLAGS="$CFLAGS -diag_error 1035"
643 # Whilst we're here, we might as well make sure CXX defaults to something
644 # sensible if we're not using gcc.
645 if test -z "$CXX"; then
646 CXX="CC"
647 fi
648fi
649
Marc-André Lemburg6d5e5792010-04-30 17:20:14 +0000650# If the user set CFLAGS, use this instead of the automatically
651# determined setting
652preset_cflags="$CFLAGS"
Guido van Rossum627b2d71993-12-24 10:39:16 +0000653AC_PROG_CC
Marc-André Lemburg6d5e5792010-04-30 17:20:14 +0000654if test ! -z "$preset_cflags"
655then
656 CFLAGS=$preset_cflags
657fi
Martin v. Löwis1d5ecb72001-08-09 10:29:44 +0000658
Martin v. Löwis0f48d982006-04-14 14:34:26 +0000659AC_SUBST(CXX)
660AC_SUBST(MAINCC)
661AC_MSG_CHECKING(for --with-cxx-main=<compiler>)
662AC_ARG_WITH(cxx_main,
Matthias Klose22520ea2010-05-08 10:14:46 +0000663 AS_HELP_STRING([--with-cxx-main=<compiler>],
Martin v. Löwis0f48d982006-04-14 14:34:26 +0000664 [compile main() and link python executable with C++ compiler]),
665[
666
667 case $withval in
668 no) with_cxx_main=no
669 MAINCC='$(CC)';;
670 yes) with_cxx_main=yes
671 MAINCC='$(CXX)';;
672 *) with_cxx_main=yes
673 MAINCC=$withval
674 if test -z "$CXX"
675 then
676 CXX=$withval
677 fi;;
678 esac], [
679 with_cxx_main=no
680 MAINCC='$(CC)'
681])
682AC_MSG_RESULT($with_cxx_main)
683
684preset_cxx="$CXX"
685if test -z "$CXX"
686then
687 case "$CC" in
doko@python.orgd65e2ba2013-01-31 23:52:03 +0100688 gcc) AC_PATH_TOOL(CXX, [g++], [g++], [notfound]) ;;
689 cc) AC_PATH_TOOL(CXX, [c++], [c++], [notfound]) ;;
Martin v. Löwis0f48d982006-04-14 14:34:26 +0000690 esac
691 if test "$CXX" = "notfound"
692 then
693 CXX=""
694 fi
695fi
696if test -z "$CXX"
697then
doko@python.orgd65e2ba2013-01-31 23:52:03 +0100698 AC_CHECK_TOOLS(CXX, $CCC c++ g++ gcc CC cxx cc++ cl, notfound)
Martin v. Löwis0f48d982006-04-14 14:34:26 +0000699 if test "$CXX" = "notfound"
700 then
701 CXX=""
702 fi
703fi
704if test "$preset_cxx" != "$CXX"
705then
706 AC_MSG_WARN([
707
708 By default, distutils will build C++ extension modules with "$CXX".
709 If this is not intended, then set CXX on the configure command line.
710 ])
711fi
712
doko@python.org4e63fbe2013-01-25 13:08:27 +0100713MULTIARCH=$($CC --print-multiarch 2>/dev/null)
714AC_SUBST(MULTIARCH)
715
Martin v. Löwis0f48d982006-04-14 14:34:26 +0000716
Martin v. Löwis1d5ecb72001-08-09 10:29:44 +0000717# checks for UNIX variants that set C preprocessor variables
Matthias Klose9f8e0c12010-05-08 10:17:27 +0000718AC_USE_SYSTEM_EXTENSIONS
Martin v. Löwis1d5ecb72001-08-09 10:29:44 +0000719
Martin v. Löwis779ffc02002-12-02 22:17:01 +0000720# Check for unsupported systems
721case $ac_sys_system/$ac_sys_release in
Brett Cannon19fab762007-06-02 03:02:29 +0000722atheos*|Linux*/1*)
Martin v. Löwis779ffc02002-12-02 22:17:01 +0000723 echo This system \($ac_sys_system/$ac_sys_release\) is no longer supported.
724 echo See README for details.
725 exit 1;;
726esac
727
Neil Schemenauer55f0cf32001-01-24 17:24:33 +0000728AC_EXEEXT
Neil Schemenauer3ae1d0a2001-01-27 06:54:42 +0000729AC_MSG_CHECKING(for --with-suffix)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000730AC_ARG_WITH(suffix,
Matthias Klose22520ea2010-05-08 10:14:46 +0000731 AS_HELP_STRING([--with-suffix=.exe], [set executable suffix]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000732[
Neil Schemenauer3ae1d0a2001-01-27 06:54:42 +0000733 case $withval in
734 no) EXEEXT=;;
735 yes) EXEEXT=.exe;;
736 *) EXEEXT=$withval;;
737 esac])
738AC_MSG_RESULT($EXEEXT)
Jack Jansen1999ef42001-12-06 21:47:20 +0000739
Jack Jansen9a66b6d2001-08-08 13:56:14 +0000740# Test whether we're running on a non-case-sensitive system, in which
741# case we give a warning if no ext is given
Jack Jansen1999ef42001-12-06 21:47:20 +0000742AC_SUBST(BUILDEXEEXT)
743AC_MSG_CHECKING(for case-insensitive build directory)
Jack Jansen3c2c4332002-11-06 13:33:32 +0000744if test ! -d CaseSensitiveTestDir; then
745mkdir CaseSensitiveTestDir
746fi
747
748if test -d casesensitivetestdir
Jack Jansen9a66b6d2001-08-08 13:56:14 +0000749then
Jack Jansen1999ef42001-12-06 21:47:20 +0000750 AC_MSG_RESULT(yes)
751 BUILDEXEEXT=.exe
752else
753 AC_MSG_RESULT(no)
Jack Jansendd19cf82001-12-06 22:36:17 +0000754 BUILDEXEEXT=$EXEEXT
Jack Jansen9a66b6d2001-08-08 13:56:14 +0000755fi
Jack Jansen3c2c4332002-11-06 13:33:32 +0000756rmdir CaseSensitiveTestDir
Guido van Rossumfb842551997-08-06 23:42:07 +0000757
Guido van Rossumdd997f71998-10-07 19:58:26 +0000758case $MACHDEP in
759bsdos*)
760 case $CC in
761 gcc) CC="$CC -D_HAVE_BSDI";;
762 esac;;
763esac
764
Guido van Rossum84561611997-08-21 00:08:11 +0000765case $ac_sys_system in
766hp*|HP*)
767 case $CC in
Guido van Rossumcd5ff9f2000-09-22 16:15:54 +0000768 cc|*/cc) CC="$CC -Ae";;
Guido van Rossum84561611997-08-21 00:08:11 +0000769 esac;;
Martin v. Löwise8964d42001-03-06 12:09:07 +0000770SunOS*)
771 # Some functions have a prototype only with that define, e.g. confstr
Martin v. Löwisc45929e2002-04-06 10:10:49 +0000772 AC_DEFINE(__EXTENSIONS__, 1, [Defined on Solaris to see additional function prototypes.])
Martin v. Löwise8964d42001-03-06 12:09:07 +0000773 ;;
Guido van Rossum84561611997-08-21 00:08:11 +0000774esac
775
Martin v. Löwise8964d42001-03-06 12:09:07 +0000776
Neil Schemenauer61c51152001-01-26 16:18:16 +0000777AC_SUBST(LIBRARY)
778AC_MSG_CHECKING(LIBRARY)
779if test -z "$LIBRARY"
780then
781 LIBRARY='libpython$(VERSION).a'
782fi
783AC_MSG_RESULT($LIBRARY)
784
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000785# LDLIBRARY is the name of the library to link against (as opposed to the
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000786# name of the library into which to insert object files). BLDLIBRARY is also
787# the library to link against, usually. On Mac OS X frameworks, BLDLIBRARY
788# is blank as the main program is not linked directly against LDLIBRARY.
789# LDLIBRARYDIR is the path to LDLIBRARY, which is made in a subdirectory. On
790# systems without shared libraries, LDLIBRARY is the same as LIBRARY
791# (defined in the Makefiles). On Cygwin LDLIBRARY is the import library,
792# DLLLIBRARY is the shared (i.e., DLL) library.
793#
Martin v. Löwis1142de32002-03-29 16:28:31 +0000794# RUNSHARED is used to run shared python without installed libraries
795#
796# INSTSONAME is the name of the shared library that will be use to install
797# on the system - some systems like version suffix, others don't
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000798AC_SUBST(LDLIBRARY)
Guido van Rossum27552902001-01-23 01:52:26 +0000799AC_SUBST(DLLLIBRARY)
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000800AC_SUBST(BLDLIBRARY)
801AC_SUBST(LDLIBRARYDIR)
Martin v. Löwis1142de32002-03-29 16:28:31 +0000802AC_SUBST(INSTSONAME)
803AC_SUBST(RUNSHARED)
Neil Schemenauer61c51152001-01-26 16:18:16 +0000804LDLIBRARY="$LIBRARY"
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000805BLDLIBRARY='$(LDLIBRARY)'
Martin v. Löwis09bdf722002-05-08 08:51:29 +0000806INSTSONAME='$(LDLIBRARY)'
Guido van Rossum27552902001-01-23 01:52:26 +0000807DLLLIBRARY=''
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000808LDLIBRARYDIR=''
Martin v. Löwis1142de32002-03-29 16:28:31 +0000809RUNSHARED=''
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000810
Guido van Rossumfb842551997-08-06 23:42:07 +0000811# LINKCC is the command that links the python executable -- default is $(CC).
Martin v. Löwisb7da67a2001-10-18 15:35:38 +0000812# If CXX is set, and if it is needed to link a main function that was
813# compiled with CXX, LINKCC is CXX instead. Always using CXX is undesirable:
814# python might then depend on the C++ runtime
Fred Drake5790be12000-10-09 17:06:13 +0000815# This is altered for AIX in order to build the export list before
Guido van Rossumec95c7b1998-08-04 17:59:56 +0000816# linking.
Guido van Rossumfb842551997-08-06 23:42:07 +0000817AC_SUBST(LINKCC)
818AC_MSG_CHECKING(LINKCC)
819if test -z "$LINKCC"
820then
Martin v. Löwis0f48d982006-04-14 14:34:26 +0000821 LINKCC='$(PURIFY) $(MAINCC)'
Guido van Rossumfb842551997-08-06 23:42:07 +0000822 case $ac_sys_system in
823 AIX*)
Neal Norwitz0b27ff92003-03-31 15:53:49 +0000824 exp_extra="\"\""
825 if test $ac_sys_release -ge 5 -o \
826 $ac_sys_release -eq 4 -a `uname -r` -ge 2 ; then
827 exp_extra="."
828 fi
829 LINKCC="\$(srcdir)/Modules/makexp_aix Modules/python.exp $exp_extra \$(LIBRARY); $LINKCC";;
Martin v. Löwis8c255e42008-05-23 15:06:50 +0000830 QNX*)
831 # qcc must be used because the other compilers do not
832 # support -N.
833 LINKCC=qcc;;
Guido van Rossumfb842551997-08-06 23:42:07 +0000834 esac
835fi
836AC_MSG_RESULT($LINKCC)
837
Tarek Ziadée2be83d2009-05-09 08:28:53 +0000838# GNULD is set to "yes" if the GNU linker is used. If this goes wrong
839# make sure we default having it set to "no": this is used by
840# distutils.unixccompiler to know if it should add --enable-new-dtags
841# to linker command lines, and failing to detect GNU ld simply results
842# in the same bahaviour as before.
843AC_SUBST(GNULD)
844AC_MSG_CHECKING(for GNU ld)
845ac_prog=ld
846if test "$GCC" = yes; then
847 ac_prog=`$CC -print-prog-name=ld`
848fi
849case `"$ac_prog" -V 2>&1 < /dev/null` in
850 *GNU*)
851 GNULD=yes;;
852 *)
853 GNULD=no;;
854esac
855AC_MSG_RESULT($GNULD)
856
Martin v. Löwis1142de32002-03-29 16:28:31 +0000857AC_MSG_CHECKING(for --enable-shared)
858AC_ARG_ENABLE(shared,
Matthias Klose22520ea2010-05-08 10:14:46 +0000859 AS_HELP_STRING([--enable-shared], [disable/enable building shared python library]))
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000860
Martin v. Löwis1142de32002-03-29 16:28:31 +0000861if test -z "$enable_shared"
862then
Martin v. Löwisb51033d2002-05-03 05:53:15 +0000863 case $ac_sys_system in
Martin v. Löwisf90ae202002-06-11 06:22:31 +0000864 CYGWIN* | atheos*)
Martin v. Löwisb51033d2002-05-03 05:53:15 +0000865 enable_shared="yes";;
866 *)
867 enable_shared="no";;
868 esac
Martin v. Löwis1142de32002-03-29 16:28:31 +0000869fi
870AC_MSG_RESULT($enable_shared)
871
Skip Montanaro56f6a4f2004-06-18 02:47:22 +0000872AC_MSG_CHECKING(for --enable-profiling)
873AC_ARG_ENABLE(profiling,
doko@python.orgd65e2ba2013-01-31 23:52:03 +0100874 AS_HELP_STRING([--enable-profiling], [enable C-level code profiling]))
875if test "x$enable_profiling" = xyes; then
876 ac_save_cc="$CC"
Benjamin Petersonb9be7bb2013-03-26 08:55:37 -0400877 CC="$CC -pg"
doko@python.orgd65e2ba2013-01-31 23:52:03 +0100878 AC_LINK_IFELSE([AC_LANG_SOURCE([[int main() { return 0; }]])],
879 [],
880 [enable_profiling=no])
881 CC="$ac_save_cc"
882else
883 enable_profiling=no
884fi
885AC_MSG_RESULT($enable_profiling)
Skip Montanaro56f6a4f2004-06-18 02:47:22 +0000886
doko@python.orgd65e2ba2013-01-31 23:52:03 +0100887if test "x$enable_profiling" = xyes; then
888 BASECFLAGS="-pg $BASECFLAGS"
889 LDFLAGS="-pg $LDFLAGS"
890fi
Martin v. Löwis1142de32002-03-29 16:28:31 +0000891
892AC_MSG_CHECKING(LDLIBRARY)
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000893
Guido van Rossumb8552162001-09-05 14:58:11 +0000894# MacOSX framework builds need more magic. LDLIBRARY is the dynamic
895# library that we build, but we do not want to link against it (we
896# will find it with a -framework option). For this reason there is an
897# extra variable BLDLIBRARY against which Python and the extension
898# modules are linked, BLDLIBRARY. This is normally the same as
899# LDLIBRARY, but empty for MacOSX framework builds.
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000900if test "$enable_framework"
901then
902 LDLIBRARY='$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
doko@ubuntu.com9ba90c92014-05-07 04:41:26 +0200903 RUNSHARED=DYLD_FRAMEWORK_PATH=`pwd`${DYLD_FRAMEWORK_PATH:+:${DYLD_FRAMEWORK_PATH}}
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000904 BLDLIBRARY=''
905else
906 BLDLIBRARY='$(LDLIBRARY)'
907fi
908
Martin v. Löwis1142de32002-03-29 16:28:31 +0000909# Other platforms follow
910if test $enable_shared = "yes"; then
Mark Hammond8235ea12002-07-19 06:55:41 +0000911 AC_DEFINE(Py_ENABLE_SHARED, 1, [Defined if Python is built as a shared library.])
Martin v. Löwis1142de32002-03-29 16:28:31 +0000912 case $ac_sys_system in
913 BeOS*)
914 LDLIBRARY='libpython$(VERSION).so'
915 ;;
916 CYGWIN*)
917 LDLIBRARY='libpython$(VERSION).dll.a'
918 DLLLIBRARY='libpython$(VERSION).dll'
919 ;;
920 SunOS*)
921 LDLIBRARY='libpython$(VERSION).so'
Martin v. Löwisd141a8c2003-06-14 15:20:28 +0000922 BLDLIBRARY='-Wl,-R,$(LIBDIR) -L. -lpython$(VERSION)'
doko@ubuntu.com9ba90c92014-05-07 04:41:26 +0200923 RUNSHARED=LD_LIBRARY_PATH=`pwd`${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
Martin v. Löwis2389c412003-10-31 15:42:07 +0000924 INSTSONAME="$LDLIBRARY".$SOVERSION
Martin v. Löwis1142de32002-03-29 16:28:31 +0000925 ;;
Charles-François Natali3de8c732011-07-24 22:33:35 +0200926 Linux*|GNU*|NetBSD*|FreeBSD*|DragonFly*|OpenBSD*)
Martin v. Löwis1142de32002-03-29 16:28:31 +0000927 LDLIBRARY='libpython$(VERSION).so'
928 BLDLIBRARY='-L. -lpython$(VERSION)'
doko@ubuntu.com9ba90c92014-05-07 04:41:26 +0200929 RUNSHARED=LD_LIBRARY_PATH=`pwd`${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
Hye-Shik Chang33761492004-10-26 09:53:46 +0000930 case $ac_sys_system in
931 FreeBSD*)
932 SOVERSION=`echo $SOVERSION|cut -d "." -f 1`
933 ;;
934 esac
Martin v. Löwis1142de32002-03-29 16:28:31 +0000935 INSTSONAME="$LDLIBRARY".$SOVERSION
936 ;;
937 hp*|HP*)
Neal Norwitz58e28882006-05-19 07:00:58 +0000938 case `uname -m` in
939 ia64)
940 LDLIBRARY='libpython$(VERSION).so'
941 ;;
942 *)
943 LDLIBRARY='libpython$(VERSION).sl'
944 ;;
945 esac
Martin v. Löwis1142de32002-03-29 16:28:31 +0000946 BLDLIBRARY='-Wl,+b,$(LIBDIR) -L. -lpython$(VERSION)'
doko@ubuntu.com9ba90c92014-05-07 04:41:26 +0200947 RUNSHARED=SHLIB_PATH=`pwd`${SHLIB_PATH:+:${SHLIB_PATH}}
Martin v. Löwis1142de32002-03-29 16:28:31 +0000948 ;;
949 OSF*)
950 LDLIBRARY='libpython$(VERSION).so'
Neal Norwitz671b9e32006-01-09 07:07:12 +0000951 BLDLIBRARY='-rpath $(LIBDIR) -L. -lpython$(VERSION)'
doko@ubuntu.com9ba90c92014-05-07 04:41:26 +0200952 RUNSHARED=LD_LIBRARY_PATH=`pwd`${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
Martin v. Löwis1142de32002-03-29 16:28:31 +0000953 ;;
Martin v. Löwisf90ae202002-06-11 06:22:31 +0000954 atheos*)
955 LDLIBRARY='libpython$(VERSION).so'
956 BLDLIBRARY='-L. -lpython$(VERSION)'
957 RUNSHARED=DLL_PATH=`pwd`:${DLL_PATH:-/atheos/sys/libs:/atheos/autolnk/lib}
958 ;;
Ronald Oussoren79f90492009-01-02 10:44:46 +0000959 Darwin*)
960 LDLIBRARY='libpython$(VERSION).dylib'
961 BLDLIBRARY='-L. -lpython$(VERSION)'
doko@ubuntu.com9ba90c92014-05-07 04:41:26 +0200962 RUNSHARED=DYLD_LIBRARY_PATH=`pwd`${DYLD_LIBRARY_PATH:+:${DYLD_LIBRARY_PATH}}
Ronald Oussoren79f90492009-01-02 10:44:46 +0000963 ;;
Antoine Pitrouaabdceb2010-09-10 20:03:17 +0000964 AIX*)
965 LDLIBRARY='libpython$(VERSION).so'
doko@ubuntu.com9ba90c92014-05-07 04:41:26 +0200966 RUNSHARED=LIBPATH=`pwd`${LIBPATH:+:${LIBPATH}}
Antoine Pitrouaabdceb2010-09-10 20:03:17 +0000967 ;;
Ronald Oussoren79f90492009-01-02 10:44:46 +0000968
Martin v. Löwis1142de32002-03-29 16:28:31 +0000969 esac
Jason Tishler30765592003-09-04 11:04:06 +0000970else # shared is disabled
971 case $ac_sys_system in
972 CYGWIN*)
973 BLDLIBRARY='$(LIBRARY)'
974 LDLIBRARY='libpython$(VERSION).dll.a'
975 ;;
976 esac
Martin v. Löwis1142de32002-03-29 16:28:31 +0000977fi
978
doko@python.orgd65e2ba2013-01-31 23:52:03 +0100979if test "$cross_compiling" = yes; then
980 RUNSHARED=
981fi
982
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000983AC_MSG_RESULT($LDLIBRARY)
984
Guido van Rossum627b2d71993-12-24 10:39:16 +0000985AC_PROG_RANLIB
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000986AC_SUBST(AR)
doko@python.orgd65e2ba2013-01-31 23:52:03 +0100987AC_CHECK_TOOLS(AR, ar aal, ar)
Neil Schemenauera42c8272001-03-31 00:01:55 +0000988
Tarek Ziadé99f660a2009-05-07 21:20:34 +0000989# tweak ARFLAGS only if the user didn't set it on the command line
990AC_SUBST(ARFLAGS)
991if test -z "$ARFLAGS"
992then
993 ARFLAGS="rc"
994fi
995
Victor Stinner2c7085f2017-05-02 16:55:50 +0200996AC_SUBST(GITVERSION)
997AC_SUBST(GITTAG)
998AC_SUBST(GITBRANCH)
Martin v. Löwisdea59e52006-01-05 10:00:36 +0000999
Victor Stinnerdf569252017-05-03 00:05:45 +02001000if test -e $srcdir/.git
Georg Brandl3a5508e2011-03-06 10:42:21 +01001001then
Victor Stinner2c7085f2017-05-02 16:55:50 +02001002AC_CHECK_PROG(HAS_GIT, git, found, not-found)
Georg Brandl3a5508e2011-03-06 10:42:21 +01001003else
Victor Stinner2c7085f2017-05-02 16:55:50 +02001004HAS_GIT=no-repository
1005fi
1006if test $HAS_GIT = found
1007then
1008 GITVERSION="git -C \$(srcdir) rev-parse --short HEAD"
1009 GITTAG="git -C \$(srcdir) describe --all --always --dirty"
1010 GITBRANCH="git -C \$(srcdir) name-rev --name-only HEAD"
1011else
1012 GITVERSION=""
1013 GITTAG=""
1014 GITBRANCH=""
Georg Brandl3a5508e2011-03-06 10:42:21 +01001015fi
1016
Neil Schemenauera42c8272001-03-31 00:01:55 +00001017case $MACHDEP in
Neil Schemenaueraf5567f2001-10-21 22:32:04 +00001018bsdos*|hp*|HP*)
1019 # install -d does not work on BSDI or HP-UX
Neil Schemenauera42c8272001-03-31 00:01:55 +00001020 if test -z "$INSTALL"
1021 then
1022 INSTALL="${srcdir}/install-sh -c"
1023 fi
1024esac
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00001025AC_PROG_INSTALL
Trent Nelsonf6407a12012-08-30 14:56:13 +00001026AC_PROG_MKDIR_P
Guido van Rossumb418f891996-07-30 18:06:02 +00001027
Guido van Rossumec95c7b1998-08-04 17:59:56 +00001028# Not every filesystem supports hard links
1029AC_SUBST(LN)
1030if test -z "$LN" ; then
1031 case $ac_sys_system in
1032 BeOS*) LN="ln -s";;
Guido van Rossumaef734b2001-01-10 21:09:12 +00001033 CYGWIN*) LN="ln -s";;
Martin v. Löwisf90ae202002-06-11 06:22:31 +00001034 atheos*) LN="ln -s";;
Guido van Rossumec95c7b1998-08-04 17:59:56 +00001035 *) LN=ln;;
1036 esac
1037fi
1038
Fred Drake9f715822001-07-11 06:27:00 +00001039# Check for --with-pydebug
1040AC_MSG_CHECKING(for --with-pydebug)
1041AC_ARG_WITH(pydebug,
Matthias Klose22520ea2010-05-08 10:14:46 +00001042 AS_HELP_STRING([--with-pydebug], [build with Py_DEBUG defined]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00001043[
Fred Drake9f715822001-07-11 06:27:00 +00001044if test "$withval" != no
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001045then
1046 AC_DEFINE(Py_DEBUG, 1,
1047 [Define if you want to build an interpreter with many run-time checks.])
1048 AC_MSG_RESULT(yes);
1049 Py_DEBUG='true'
Fred Drake9f715822001-07-11 06:27:00 +00001050else AC_MSG_RESULT(no); Py_DEBUG='false'
1051fi],
1052[AC_MSG_RESULT(no)])
1053
Skip Montanarodecc6a42003-01-01 20:07:49 +00001054# XXX Shouldn't the code above that fiddles with BASECFLAGS and OPT be
1055# merged with this chunk of code?
1056
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00001057# Optimizer/debugger flags
Skip Montanarodecc6a42003-01-01 20:07:49 +00001058# ------------------------
1059# (The following bit of code is complicated enough - please keep things
1060# indented properly. Just pretend you're editing Python code. ;-)
1061
1062# There are two parallel sets of case statements below, one that checks to
1063# see if OPT was set and one that does BASECFLAGS setting based upon
1064# compiler and platform. BASECFLAGS tweaks need to be made even if the
1065# user set OPT.
1066
1067# tweak OPT based on compiler and platform, only if the user didn't set
1068# it on the command line
Guido van Rossumb418f891996-07-30 18:06:02 +00001069AC_SUBST(OPT)
Benjamin Petersond4b721b2010-03-23 20:58:37 +00001070if test "${OPT-unset}" = "unset"
Guido van Rossumb418f891996-07-30 18:06:02 +00001071then
Skip Montanarodecc6a42003-01-01 20:07:49 +00001072 case $GCC in
1073 yes)
Skip Montanaro288a5be2006-04-13 02:00:56 +00001074 if test "$CC" != 'g++' ; then
1075 STRICT_PROTO="-Wstrict-prototypes"
1076 fi
Guido van Rossum7c862f82007-12-13 20:50:10 +00001077 # For gcc 4.x we need to use -fwrapv so lets check if its supported
1078 if "$CC" -v --help 2>/dev/null |grep -- -fwrapv > /dev/null; then
1079 WRAP="-fwrapv"
1080 fi
Stefan Krah503e5e12011-09-14 15:19:42 +02001081
1082 # Clang also needs -fwrapv
Stefan Krah2bc1e8f2011-12-08 22:26:06 +01001083 case $CC in
1084 *clang*) WRAP="-fwrapv"
1085 ;;
1086 esac
Stefan Krah503e5e12011-09-14 15:19:42 +02001087
Skip Montanarodecc6a42003-01-01 20:07:49 +00001088 case $ac_cv_prog_cc_g in
Guido van Rossum2242f2f2001-04-11 20:58:20 +00001089 yes)
Fred Drake9f715822001-07-11 06:27:00 +00001090 if test "$Py_DEBUG" = 'true' ; then
1091 # Optimization messes up debuggers, so turn it off for
1092 # debug builds.
Mark Dickinsond2f3e3f2010-05-05 22:23:58 +00001093 OPT="-g -O0 -Wall $STRICT_PROTO"
Fred Drake9f715822001-07-11 06:27:00 +00001094 else
Guido van Rossum7c862f82007-12-13 20:50:10 +00001095 OPT="-g $WRAP -O3 -Wall $STRICT_PROTO"
Skip Montanarodecc6a42003-01-01 20:07:49 +00001096 fi
1097 ;;
Guido van Rossum2242f2f2001-04-11 20:58:20 +00001098 *)
Skip Montanaro288a5be2006-04-13 02:00:56 +00001099 OPT="-O3 -Wall $STRICT_PROTO"
Skip Montanarodecc6a42003-01-01 20:07:49 +00001100 ;;
Fred Drake9f715822001-07-11 06:27:00 +00001101 esac
Martin v. Löwis21ee4092002-09-30 16:19:48 +00001102 case $ac_sys_system in
Skip Montanarodecc6a42003-01-01 20:07:49 +00001103 SCO_SV*) OPT="$OPT -m486 -DSCO5"
1104 ;;
1105 esac
Fred Drake9f715822001-07-11 06:27:00 +00001106 ;;
Skip Montanarodecc6a42003-01-01 20:07:49 +00001107
Guido van Rossum2242f2f2001-04-11 20:58:20 +00001108 *)
Skip Montanarodecc6a42003-01-01 20:07:49 +00001109 OPT="-O"
1110 ;;
Guido van Rossum2242f2f2001-04-11 20:58:20 +00001111 esac
Guido van Rossum4e8af441994-08-19 15:33:54 +00001112fi
Guido van Rossum627b2d71993-12-24 10:39:16 +00001113
Skip Montanarodecc6a42003-01-01 20:07:49 +00001114AC_SUBST(BASECFLAGS)
Ronald Oussoren5640ce22008-06-05 12:58:24 +00001115
1116# The -arch flags for universal builds on OSX
1117UNIVERSAL_ARCH_FLAGS=
1118AC_SUBST(UNIVERSAL_ARCH_FLAGS)
1119
Skip Montanarodecc6a42003-01-01 20:07:49 +00001120# tweak BASECFLAGS based on compiler and platform
1121case $GCC in
1122yes)
Martin v. Löwis70fedcd2003-07-07 21:26:19 +00001123 # Python violates C99 rules, by casting between incompatible
1124 # pointer types. GCC may generate bad code as a result of that,
1125 # so use -fno-strict-aliasing if supported.
1126 AC_MSG_CHECKING(whether $CC accepts -fno-strict-aliasing)
1127 ac_save_cc="$CC"
1128 CC="$CC -fno-strict-aliasing"
Alexandre Vassalotti00900892009-07-17 05:26:39 +00001129 AC_CACHE_VAL(ac_cv_no_strict_aliasing_ok,
Matthias Klosec511b472010-05-08 11:01:39 +00001130 AC_COMPILE_IFELSE(
Mark Dickinson5e13e292010-05-11 08:55:06 +00001131 [AC_LANG_PROGRAM([[]], [[]])],
Matthias Klosec511b472010-05-08 11:01:39 +00001132 [ac_cv_no_strict_aliasing_ok=yes],
1133 [ac_cv_no_strict_aliasing_ok=no]))
Martin v. Löwis70fedcd2003-07-07 21:26:19 +00001134 CC="$ac_save_cc"
1135 AC_MSG_RESULT($ac_cv_no_strict_aliasing_ok)
1136 if test $ac_cv_no_strict_aliasing_ok = yes
1137 then
1138 BASECFLAGS="$BASECFLAGS -fno-strict-aliasing"
1139 fi
Mark Dickinson65134662008-04-25 16:11:04 +00001140
1141 # if using gcc on alpha, use -mieee to get (near) full IEEE 754
1142 # support. Without this, treatment of subnormals doesn't follow
1143 # the standard.
doko@python.orgd65e2ba2013-01-31 23:52:03 +01001144 case $host in
Mark Dickinson65134662008-04-25 16:11:04 +00001145 alpha*)
1146 BASECFLAGS="$BASECFLAGS -mieee"
1147 ;;
1148 esac
1149
Skip Montanarodecc6a42003-01-01 20:07:49 +00001150 case $ac_sys_system in
1151 SCO_SV*)
1152 BASECFLAGS="$BASECFLAGS -m486 -DSCO5"
1153 ;;
Ned Deilyee8e4b62018-04-14 10:37:28 -04001154 # is there any other compiler on Darwin besides gcc?
1155 Darwin*)
1156 # -Wno-long-double, -no-cpp-precomp, and -mno-fused-madd
1157 # used to be here, but non-Apple gcc doesn't accept them.
1158 if test "${CC}" = gcc
1159 then
1160 AC_MSG_CHECKING(which compiler should be used)
1161 case "${UNIVERSALSDK}" in
1162 */MacOSX10.4u.sdk)
1163 # Build using 10.4 SDK, force usage of gcc when the
1164 # compiler is gcc, otherwise the user will get very
1165 # confusing error messages when building on OSX 10.6
1166 CC=gcc-4.0
1167 CPP=cpp-4.0
1168 ;;
1169 esac
1170 AC_MSG_RESULT($CC)
1171 fi
Ronald Oussoren988117f2006-04-29 11:31:35 +00001172
Ned Deilyee8e4b62018-04-14 10:37:28 -04001173 if test "${enable_universalsdk}"
1174 then
1175 case "$UNIVERSAL_ARCHS" in
1176 32-bit)
1177 UNIVERSAL_ARCH_FLAGS="-arch ppc -arch i386"
1178 LIPO_32BIT_FLAGS=""
1179 ARCH_RUN_32BIT=""
1180 ;;
1181 64-bit)
1182 UNIVERSAL_ARCH_FLAGS="-arch ppc64 -arch x86_64"
1183 LIPO_32BIT_FLAGS=""
1184 ARCH_RUN_32BIT=""
1185 ;;
1186 all)
1187 UNIVERSAL_ARCH_FLAGS="-arch i386 -arch ppc -arch ppc64 -arch x86_64"
1188 LIPO_32BIT_FLAGS="-extract ppc7400 -extract i386"
1189 ARCH_RUN_32BIT="/usr/bin/arch -i386 -ppc"
1190 ;;
1191 intel)
1192 UNIVERSAL_ARCH_FLAGS="-arch i386 -arch x86_64"
1193 LIPO_32BIT_FLAGS="-extract i386"
1194 ARCH_RUN_32BIT="/usr/bin/arch -i386"
1195 ;;
1196 intel-32)
1197 UNIVERSAL_ARCH_FLAGS="-arch i386"
1198 LIPO_32BIT_FLAGS=""
1199 ARCH_RUN_32BIT=""
1200 ;;
1201 intel-64)
1202 UNIVERSAL_ARCH_FLAGS="-arch x86_64"
1203 LIPO_32BIT_FLAGS=""
1204 ARCH_RUN_32BIT=""
1205 ;;
1206 3-way)
1207 UNIVERSAL_ARCH_FLAGS="-arch i386 -arch ppc -arch x86_64"
1208 LIPO_32BIT_FLAGS="-extract ppc7400 -extract i386"
1209 ARCH_RUN_32BIT="/usr/bin/arch -i386 -ppc"
1210 ;;
1211 *)
1212 AC_MSG_ERROR([proper usage is --with-universal-arch=32-bit|64-bit|all|intel|3-way])
1213 ;;
1214 esac
Ronald Oussoren23d92532009-09-07 06:12:00 +00001215
Ned Deilyee8e4b62018-04-14 10:37:28 -04001216 if test "${UNIVERSALSDK}" != "/"
1217 then
1218 CFLAGS="${UNIVERSAL_ARCH_FLAGS} -isysroot ${UNIVERSALSDK} ${CFLAGS}"
1219 LDFLAGS="${UNIVERSAL_ARCH_FLAGS} -isysroot ${UNIVERSALSDK} ${LDFLAGS}"
1220 CPPFLAGS="-isysroot ${UNIVERSALSDK} ${CPPFLAGS}"
1221 else
1222 CFLAGS="${UNIVERSAL_ARCH_FLAGS} ${CFLAGS}"
1223 LDFLAGS="${UNIVERSAL_ARCH_FLAGS} ${LDFLAGS}"
1224 fi
1225 fi
Ronald Oussoren23d92532009-09-07 06:12:00 +00001226
Ned Deilyee8e4b62018-04-14 10:37:28 -04001227 # Calculate an appropriate deployment target for this build:
1228 # The deployment target value is used explicitly to enable certain
1229 # features are enabled (such as builtin libedit support for readline)
1230 # through the use of Apple's Availability Macros and is used as a
1231 # component of the string returned by distutils.get_platform().
1232 #
1233 # Use the value from:
1234 # 1. the MACOSX_DEPLOYMENT_TARGET environment variable if specified
1235 # 2. the operating system version of the build machine if >= 10.6
1236 # 3. If running on OS X 10.3 through 10.5, use the legacy tests
1237 # below to pick either 10.3, 10.4, or 10.5 as the target.
1238 # 4. If we are running on OS X 10.2 or earlier, good luck!
Ronald Oussoren23d92532009-09-07 06:12:00 +00001239
Ned Deilyee8e4b62018-04-14 10:37:28 -04001240 AC_MSG_CHECKING(which MACOSX_DEPLOYMENT_TARGET to use)
1241 cur_target_major=`sw_vers -productVersion | \
1242 sed 's/\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'`
1243 cur_target_minor=`sw_vers -productVersion | \
1244 sed 's/\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'`
1245 cur_target="${cur_target_major}.${cur_target_minor}"
1246 if test ${cur_target_major} -eq 10 && \
1247 test ${cur_target_minor} -ge 3 && \
1248 test ${cur_target_minor} -le 5
1249 then
1250 # OS X 10.3 through 10.5
1251 cur_target=10.3
1252 if test ${enable_universalsdk}
1253 then
1254 case "$UNIVERSAL_ARCHS" in
1255 all|3-way|intel|64-bit)
1256 # These configurations were first supported in 10.5
1257 cur_target='10.5'
1258 ;;
1259 esac
1260 else
1261 if test `/usr/bin/arch` = "i386"
1262 then
1263 # 10.4 was the first release to support Intel archs
1264 cur_target="10.4"
1265 fi
1266 fi
1267 fi
1268 CONFIGURE_MACOSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET-${cur_target}}
Benjamin Peterson4347c442008-07-17 15:59:24 +00001269
Ned Deilyee8e4b62018-04-14 10:37:28 -04001270 # Make sure that MACOSX_DEPLOYMENT_TARGET is set in the
1271 # environment with a value that is the same as what we'll use
1272 # in the Makefile to ensure that we'll get the same compiler
1273 # environment during configure and build time.
1274 MACOSX_DEPLOYMENT_TARGET="$CONFIGURE_MACOSX_DEPLOYMENT_TARGET"
1275 export MACOSX_DEPLOYMENT_TARGET
1276 EXPORT_MACOSX_DEPLOYMENT_TARGET=''
1277 AC_MSG_RESULT($MACOSX_DEPLOYMENT_TARGET)
Ronald Oussorena55af9a2010-01-17 16:25:57 +00001278
Ned Deilyee8e4b62018-04-14 10:37:28 -04001279 # end of Darwin* tests
1280 ;;
Neal Norwitzdedeeaa2006-03-31 06:54:45 +00001281 OSF*)
1282 BASECFLAGS="$BASECFLAGS -mieee"
1283 ;;
Skip Montanarodecc6a42003-01-01 20:07:49 +00001284 esac
1285 ;;
1286
1287*)
1288 case $ac_sys_system in
1289 OpenUNIX*|UnixWare*)
1290 BASECFLAGS="$BASECFLAGS -K pentium,host,inline,loop_unroll,alloca "
1291 ;;
Neal Norwitzb44f1652003-05-26 14:11:55 +00001292 OSF*)
1293 BASECFLAGS="$BASECFLAGS -ieee -std"
1294 ;;
Skip Montanarodecc6a42003-01-01 20:07:49 +00001295 SCO_SV*)
1296 BASECFLAGS="$BASECFLAGS -belf -Ki486 -DSCO5"
1297 ;;
1298 esac
1299 ;;
1300esac
1301
Zachary Ware6ed42ea2015-12-21 11:43:03 -06001302# ICC needs -fp-model strict or floats behave badly
1303case "$CC" in
1304*icc*)
1305 BASECFLAGS="$BASECFLAGS -fp-model strict"
1306 ;;
1307esac
1308
Fred Drakee1ceaa02001-12-04 20:55:47 +00001309if test "$Py_DEBUG" = 'true'; then
1310 :
1311else
1312 OPT="-DNDEBUG $OPT"
1313fi
1314
Guido van Rossum6f2260e1996-09-09 16:21:03 +00001315if test "$ac_arch_flags"
Guido van Rossumc5a39031996-07-31 17:35:03 +00001316then
Skip Montanarodecc6a42003-01-01 20:07:49 +00001317 BASECFLAGS="$BASECFLAGS $ac_arch_flags"
Guido van Rossumc5a39031996-07-31 17:35:03 +00001318fi
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001319
Neal Norwitz020c46a2006-01-07 21:39:28 +00001320# disable check for icc since it seems to pass, but generates a warning
1321if test "$CC" = icc
1322then
1323 ac_cv_opt_olimit_ok=no
1324fi
1325
Guido van Rossum91922671997-10-09 20:24:13 +00001326AC_MSG_CHECKING(whether $CC accepts -OPT:Olimit=0)
1327AC_CACHE_VAL(ac_cv_opt_olimit_ok,
1328[ac_save_cc="$CC"
1329CC="$CC -OPT:Olimit=0"
Matthias Klosec511b472010-05-08 11:01:39 +00001330AC_COMPILE_IFELSE(
Mark Dickinson5e13e292010-05-11 08:55:06 +00001331 [AC_LANG_PROGRAM([[]], [[]])],
Matthias Klosec511b472010-05-08 11:01:39 +00001332 [ac_cv_opt_olimit_ok=yes],
1333 [ac_cv_opt_olimit_ok=no]
Gregory P. Smithec3b8bd2009-11-01 21:02:52 +00001334 )
Guido van Rossum91922671997-10-09 20:24:13 +00001335CC="$ac_save_cc"])
1336AC_MSG_RESULT($ac_cv_opt_olimit_ok)
Guido van Rossum2efa34b1997-10-23 17:43:11 +00001337if test $ac_cv_opt_olimit_ok = yes; then
Guido van Rossum5839e582000-10-09 19:52:35 +00001338 case $ac_sys_system in
Skip Montanarodecc6a42003-01-01 20:07:49 +00001339 # XXX is this branch needed? On MacOSX 10.2.2 the result of the
1340 # olimit_ok test is "no". Is it "yes" in some other Darwin-esque
1341 # environment?
1342 Darwin*)
1343 ;;
Trent Nelson34562e12012-10-17 18:01:12 -04001344 # XXX thankfully this useless troublemaker of a flag has been
1345 # eradicated in the 3.x line. For now, make sure it isn't picked
1346 # up by any of our other platforms that use CC.
1347 AIX*|SunOS*|HP-UX*|IRIX*)
1348 ;;
Skip Montanarodecc6a42003-01-01 20:07:49 +00001349 *)
1350 BASECFLAGS="$BASECFLAGS -OPT:Olimit=0"
1351 ;;
Guido van Rossum5839e582000-10-09 19:52:35 +00001352 esac
Guido van Rossumf8678121998-07-07 21:05:09 +00001353else
1354 AC_MSG_CHECKING(whether $CC accepts -Olimit 1500)
1355 AC_CACHE_VAL(ac_cv_olimit_ok,
1356 [ac_save_cc="$CC"
1357 CC="$CC -Olimit 1500"
Matthias Klosec511b472010-05-08 11:01:39 +00001358 AC_COMPILE_IFELSE(
Mark Dickinson5e13e292010-05-11 08:55:06 +00001359 [AC_LANG_PROGRAM([[]], [[]])],
Matthias Klosec511b472010-05-08 11:01:39 +00001360 [ac_cv_olimit_ok=yes],
1361 [ac_cv_olimit_ok=no]
Gregory P. Smithec3b8bd2009-11-01 21:02:52 +00001362 )
Guido van Rossumf8678121998-07-07 21:05:09 +00001363 CC="$ac_save_cc"])
1364 AC_MSG_RESULT($ac_cv_olimit_ok)
1365 if test $ac_cv_olimit_ok = yes; then
Stefan Krah67473262012-11-29 00:17:05 +01001366 case $ac_sys_system in
1367 # Issue #16534: On HP-UX ac_cv_olimit_ok=yes is a false positive.
1368 HP-UX*)
1369 ;;
1370 *)
1371 BASECFLAGS="$BASECFLAGS -Olimit 1500"
1372 ;;
1373 esac
Guido van Rossumf8678121998-07-07 21:05:09 +00001374 fi
Guido van Rossum201afe51997-05-14 21:14:44 +00001375fi
Guido van Rossumf8678121998-07-07 21:05:09 +00001376
Martin v. Löwisaac13162006-10-19 10:58:46 +00001377# Check whether GCC supports PyArg_ParseTuple format
1378if test "$GCC" = "yes"
1379then
1380 AC_MSG_CHECKING(whether gcc supports ParseTuple __format__)
1381 save_CFLAGS=$CFLAGS
Benjamin Petersonc8759662013-05-11 13:00:05 -05001382 CFLAGS="$CFLAGS -Werror -Wformat"
Matthias Klosec511b472010-05-08 11:01:39 +00001383 AC_COMPILE_IFELSE([
1384 AC_LANG_PROGRAM([[void f(char*,...)__attribute((format(PyArg_ParseTuple, 1, 2)));]], [[]])
1385 ],[
1386 AC_DEFINE(HAVE_ATTRIBUTE_FORMAT_PARSETUPLE, 1,
1387 [Define if GCC supports __attribute__((format(PyArg_ParseTuple, 2, 3)))])
1388 AC_MSG_RESULT(yes)
1389 ],[
1390 AC_MSG_RESULT(no)
1391 ])
Martin v. Löwisc1d75972006-10-19 16:01:37 +00001392 CFLAGS=$save_CFLAGS
Martin v. Löwisaac13162006-10-19 10:58:46 +00001393fi
1394
Brett Cannon4ff151a2015-09-18 15:09:42 -07001395
Gregory P. Smith6d8fdfc2016-09-07 23:28:23 -07001396# Enable optimization flags
1397AC_SUBST(DEF_MAKE_ALL_RULE)
1398AC_SUBST(DEF_MAKE_RULE)
1399Py_OPT='false'
Gregory P. Smith ext:(%20%5BGoogle%20Inc.%5D)b9999152016-11-20 21:19:36 +00001400AC_MSG_CHECKING(for --enable-optimizations)
1401AC_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 -07001402[
INADA Naoki6a04ef72017-03-29 01:50:48 +09001403if test "$enableval" != no
Gregory P. Smith6d8fdfc2016-09-07 23:28:23 -07001404then
1405 Py_OPT='true'
1406 AC_MSG_RESULT(yes);
1407else
1408 Py_OPT='false'
1409 AC_MSG_RESULT(no);
1410fi],
1411[AC_MSG_RESULT(no)])
1412if test "$Py_OPT" = 'true' ; then
Gregory P. Smith ext:(%20%5BGoogle%20Inc.%5D)9cbfa792016-09-08 22:44:44 +00001413 # Intentionally not forcing Py_LTO='true' here. Too many toolchains do not
1414 # compile working code using it and both test_distutils and test_gdb are
1415 # broken when you do managed to get a toolchain that works with it. People
1416 # who want LTO need to use --with-lto themselves.
Gregory P. Smith6d8fdfc2016-09-07 23:28:23 -07001417 DEF_MAKE_ALL_RULE="profile-opt"
Gregory P. Smith794b2912016-09-08 00:07:40 -07001418 REQUIRE_PGO="yes"
Gregory P. Smith6d8fdfc2016-09-07 23:28:23 -07001419 DEF_MAKE_RULE="build_all"
1420else
1421 DEF_MAKE_ALL_RULE="build_all"
Gregory P. Smith794b2912016-09-08 00:07:40 -07001422 REQUIRE_PGO="no"
Gregory P. Smith6d8fdfc2016-09-07 23:28:23 -07001423 DEF_MAKE_RULE="all"
1424fi
1425
1426
Gregory P. Smith ext:(%20%5BGoogle%20Inc.%5D)c543a0f2016-06-02 23:44:40 +00001427# Enable LTO flags
1428AC_SUBST(LTOFLAGS)
1429AC_MSG_CHECKING(for --with-lto)
1430AC_ARG_WITH(lto, AS_HELP_STRING([--with-lto], [Enable Link Time Optimization in PGO builds. Disabled by default.]),
1431[
1432if test "$withval" != no
1433then
1434 Py_LTO='true'
1435 AC_MSG_RESULT(yes);
1436else
1437 Py_LTO='false'
1438 AC_MSG_RESULT(no);
1439fi],
1440[AC_MSG_RESULT(no)])
1441if test "$Py_LTO" = 'true' ; then
1442 case $CC in
1443 *clang*)
1444 # Any changes made here should be reflected in the GCC+Darwin case below
1445 LTOFLAGS="-flto"
1446 ;;
1447 *gcc*)
1448 case $ac_sys_system in
1449 Darwin*)
1450 LTOFLAGS="-flto"
1451 ;;
1452 *)
1453 LTOFLAGS="-flto -fuse-linker-plugin -ffat-lto-objects -flto-partition=none"
1454 ;;
1455 esac
1456 ;;
1457 esac
Victor Stinner319cfb52018-06-22 09:11:33 +02001458
1459 if test "$ac_cv_prog_cc_g" = "yes"
1460 then
1461 # bpo-30345: Add -g to LDFLAGS when compiling with LTO
1462 # to get debug symbols.
1463 LTOFLAGS="$LTOFLAGS -g"
1464 fi
Gregory P. Smith ext:(%20%5BGoogle%20Inc.%5D)c543a0f2016-06-02 23:44:40 +00001465fi
1466
1467
Brett Cannon4ff151a2015-09-18 15:09:42 -07001468# Enable PGO flags.
1469AC_SUBST(PGO_PROF_GEN_FLAG)
1470AC_SUBST(PGO_PROF_USE_FLAG)
1471AC_SUBST(LLVM_PROF_MERGER)
1472AC_SUBST(LLVM_PROF_FILE)
1473AC_SUBST(LLVM_PROF_ERR)
Gregory P. Smith794b2912016-09-08 00:07:40 -07001474# Make this work on systems where llvm tools are not installed with their
1475# normal names in the default $PATH (ie: Ubuntu). They exist under the
1476# non-suffixed name in their versioned llvm directory.
1477llvm_bin_dir=''
1478llvm_path="${PATH}"
1479if test "${CC}" = "clang"
1480then
1481 clang_bin=`which clang`
1482 # Some systems install clang elsewhere as a symlink to the real path
1483 # which is where the related llvm tools are located.
1484 if test -L "${clang_bin}"
1485 then
1486 clang_dir=`dirname "${clang_bin}"`
1487 clang_bin=`readlink "${clang_bin}"`
1488 llvm_bin_dir="${clang_dir}/"`dirname "${clang_bin}"`
1489 llvm_path="${llvm_path}${PATH_SEPARATOR}${llvm_bin_dir}"
1490 fi
1491fi
1492AC_SUBST(LLVM_PROFDATA)
1493AC_PATH_TARGET_TOOL(LLVM_PROFDATA, llvm-profdata, '', ${llvm_path})
Brett Cannon4ff151a2015-09-18 15:09:42 -07001494AC_SUBST(LLVM_PROF_FOUND)
Gregory P. Smith794b2912016-09-08 00:07:40 -07001495if test -n "${LLVM_PROFDATA}" -a -x "${LLVM_PROFDATA}"
1496then
1497 LLVM_PROF_FOUND="found"
1498else
1499 LLVM_PROF_FOUND="not-found"
1500fi
1501if test "$ac_sys_system" = "Darwin" -a "${LLVM_PROF_FOUND}" = "not-found"
1502then
1503 found_llvm_profdata=`/usr/bin/xcrun -find llvm-profdata 2>/dev/null`
1504 if test -n "${found_llvm_profdata}"
1505 then
1506 # llvm-profdata isn't directly in $PATH in some cases.
1507 # https://apple.stackexchange.com/questions/197053/
1508 LLVM_PROFDATA='/usr/bin/xcrun llvm-profdata'
1509 LLVM_PROF_FOUND=found
1510 AC_MSG_NOTICE([llvm-profdata found via xcrun: ${LLVM_PROFDATA}])
1511 fi
1512fi
Brett Cannon4ff151a2015-09-18 15:09:42 -07001513LLVM_PROF_ERR=no
1514case $CC in
1515 *clang*)
1516 # Any changes made here should be reflected in the GCC+Darwin case below
1517 PGO_PROF_GEN_FLAG="-fprofile-instr-generate"
1518 PGO_PROF_USE_FLAG="-fprofile-instr-use=code.profclangd"
Gregory P. Smith794b2912016-09-08 00:07:40 -07001519 LLVM_PROF_MERGER="${LLVM_PROFDATA} merge -output=code.profclangd *.profclangr"
Brett Cannon4ff151a2015-09-18 15:09:42 -07001520 LLVM_PROF_FILE="LLVM_PROFILE_FILE=\"code-%p.profclangr\""
1521 if test $LLVM_PROF_FOUND = not-found
1522 then
1523 LLVM_PROF_ERR=yes
Gregory P. Smith794b2912016-09-08 00:07:40 -07001524 if test "${REQUIRE_PGO}" = "yes"
1525 then
Gregory P. Smith ext:(%20%5BGoogle%20Inc.%5D)b9999152016-11-20 21:19:36 +00001526 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 -07001527 fi
Brett Cannon4ff151a2015-09-18 15:09:42 -07001528 fi
1529 ;;
1530 *gcc*)
1531 case $ac_sys_system in
1532 Darwin*)
1533 PGO_PROF_GEN_FLAG="-fprofile-instr-generate"
1534 PGO_PROF_USE_FLAG="-fprofile-instr-use=code.profclangd"
Gregory P. Smith794b2912016-09-08 00:07:40 -07001535 LLVM_PROF_MERGER="${LLVM_PROFDATA} merge -output=code.profclangd *.profclangr"
Brett Cannon4ff151a2015-09-18 15:09:42 -07001536 LLVM_PROF_FILE="LLVM_PROFILE_FILE=\"code-%p.profclangr\""
Gregory P. Smith794b2912016-09-08 00:07:40 -07001537 if test "${LLVM_PROF_FOUND}" = "not-found"
Brett Cannon4ff151a2015-09-18 15:09:42 -07001538 then
1539 LLVM_PROF_ERR=yes
Gregory P. Smith794b2912016-09-08 00:07:40 -07001540 if test "${REQUIRE_PGO}" = "yes"
1541 then
Gregory P. Smith ext:(%20%5BGoogle%20Inc.%5D)b9999152016-11-20 21:19:36 +00001542 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 -07001543 fi
Brett Cannon4ff151a2015-09-18 15:09:42 -07001544 fi
1545 ;;
1546 *)
1547 PGO_PROF_GEN_FLAG="-fprofile-generate"
1548 PGO_PROF_USE_FLAG="-fprofile-use -fprofile-correction"
1549 LLVM_PROF_MERGER="true"
1550 LLVM_PROF_FILE=""
1551 ;;
1552 esac
1553 ;;
Zachary Ware6ed42ea2015-12-21 11:43:03 -06001554 *icc*)
1555 PGO_PROF_GEN_FLAG="-prof-gen"
1556 PGO_PROF_USE_FLAG="-prof-use"
1557 LLVM_PROF_MERGER="true"
1558 LLVM_PROF_FILE=""
1559 ;;
Brett Cannon4ff151a2015-09-18 15:09:42 -07001560esac
1561
1562
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00001563# On some compilers, pthreads are available without further options
1564# (e.g. MacOS X). On some of these systems, the compiler will not
1565# complain if unaccepted options are passed (e.g. gcc on Mac OS X).
1566# So we have to see first whether pthreads are available without
1567# options before we can check whether -Kpthread improves anything.
1568AC_MSG_CHECKING(whether pthreads are available without options)
1569AC_CACHE_VAL(ac_cv_pthread_is_default,
Matthias Klosec511b472010-05-08 11:01:39 +00001570[AC_RUN_IFELSE([AC_LANG_SOURCE([[
Stefan Krahae66ca62012-11-22 22:36:57 +01001571#include <stdio.h>
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00001572#include <pthread.h>
1573
1574void* routine(void* p){return NULL;}
1575
1576int main(){
1577 pthread_t p;
1578 if(pthread_create(&p,NULL,routine,NULL)!=0)
1579 return 1;
Jack Jansen4f8d0542002-03-08 13:43:01 +00001580 (void)pthread_detach(p);
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00001581 return 0;
1582}
Matthias Klosec511b472010-05-08 11:01:39 +00001583]])],[
Skip Montanarod8d39a02003-07-10 20:44:10 +00001584 ac_cv_pthread_is_default=yes
1585 ac_cv_kthread=no
1586 ac_cv_pthread=no
Matthias Klosec511b472010-05-08 11:01:39 +00001587],[ac_cv_pthread_is_default=no],[ac_cv_pthread_is_default=no])
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00001588])
1589AC_MSG_RESULT($ac_cv_pthread_is_default)
1590
1591
1592if test $ac_cv_pthread_is_default = yes
1593then
1594 ac_cv_kpthread=no
1595else
Martin v. Löwis130fb172001-07-19 11:00:41 +00001596# -Kpthread, if available, provides the right #defines
1597# and linker options to make pthread_create available
Martin v. Löwis260aecc2001-10-07 08:14:41 +00001598# Some compilers won't report that they do not support -Kpthread,
1599# so we need to run a program to see whether it really made the
1600# function available.
Martin v. Löwis130fb172001-07-19 11:00:41 +00001601AC_MSG_CHECKING(whether $CC accepts -Kpthread)
1602AC_CACHE_VAL(ac_cv_kpthread,
1603[ac_save_cc="$CC"
1604CC="$CC -Kpthread"
Matthias Klosec511b472010-05-08 11:01:39 +00001605AC_RUN_IFELSE([AC_LANG_SOURCE([[
Stefan Krahae66ca62012-11-22 22:36:57 +01001606#include <stdio.h>
Martin v. Löwis260aecc2001-10-07 08:14:41 +00001607#include <pthread.h>
1608
1609void* routine(void* p){return NULL;}
1610
1611int main(){
1612 pthread_t p;
1613 if(pthread_create(&p,NULL,routine,NULL)!=0)
1614 return 1;
Jack Jansen4f8d0542002-03-08 13:43:01 +00001615 (void)pthread_detach(p);
Martin v. Löwis260aecc2001-10-07 08:14:41 +00001616 return 0;
1617}
Matthias Klosec511b472010-05-08 11:01:39 +00001618]])],[ac_cv_kpthread=yes],[ac_cv_kpthread=no],[ac_cv_kpthread=no])
Martin v. Löwis130fb172001-07-19 11:00:41 +00001619CC="$ac_save_cc"])
Martin v. Löwis130fb172001-07-19 11:00:41 +00001620AC_MSG_RESULT($ac_cv_kpthread)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00001621fi
Martin v. Löwis130fb172001-07-19 11:00:41 +00001622
Skip Montanarod8d39a02003-07-10 20:44:10 +00001623if test $ac_cv_kpthread = no -a $ac_cv_pthread_is_default = no
Martin v. Löwis5f433f02003-05-05 05:05:30 +00001624then
1625# -Kthread, if available, provides the right #defines
1626# and linker options to make pthread_create available
1627# Some compilers won't report that they do not support -Kthread,
1628# so we need to run a program to see whether it really made the
1629# function available.
1630AC_MSG_CHECKING(whether $CC accepts -Kthread)
1631AC_CACHE_VAL(ac_cv_kthread,
1632[ac_save_cc="$CC"
1633CC="$CC -Kthread"
Matthias Klosec511b472010-05-08 11:01:39 +00001634AC_RUN_IFELSE([AC_LANG_SOURCE([[
Stefan Krahae66ca62012-11-22 22:36:57 +01001635#include <stdio.h>
Martin v. Löwis5f433f02003-05-05 05:05:30 +00001636#include <pthread.h>
1637
1638void* routine(void* p){return NULL;}
1639
1640int main(){
1641 pthread_t p;
1642 if(pthread_create(&p,NULL,routine,NULL)!=0)
1643 return 1;
1644 (void)pthread_detach(p);
1645 return 0;
1646}
Matthias Klosec511b472010-05-08 11:01:39 +00001647]])],[ac_cv_kthread=yes],[ac_cv_kthread=no],[ac_cv_kthread=no])
Martin v. Löwis5f433f02003-05-05 05:05:30 +00001648CC="$ac_save_cc"])
1649AC_MSG_RESULT($ac_cv_kthread)
1650fi
1651
Skip Montanarod8d39a02003-07-10 20:44:10 +00001652if test $ac_cv_kthread = no -a $ac_cv_pthread_is_default = no
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00001653then
1654# -pthread, if available, provides the right #defines
1655# and linker options to make pthread_create available
1656# Some compilers won't report that they do not support -pthread,
1657# so we need to run a program to see whether it really made the
1658# function available.
1659AC_MSG_CHECKING(whether $CC accepts -pthread)
doko@python.orgfa3f9a32013-01-25 15:32:31 +01001660AC_CACHE_VAL(ac_cv_pthread,
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00001661[ac_save_cc="$CC"
1662CC="$CC -pthread"
Matthias Klosec511b472010-05-08 11:01:39 +00001663AC_RUN_IFELSE([AC_LANG_SOURCE([[
Stefan Krahae66ca62012-11-22 22:36:57 +01001664#include <stdio.h>
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00001665#include <pthread.h>
1666
1667void* routine(void* p){return NULL;}
1668
1669int main(){
1670 pthread_t p;
1671 if(pthread_create(&p,NULL,routine,NULL)!=0)
1672 return 1;
1673 (void)pthread_detach(p);
1674 return 0;
1675}
Matthias Klosec511b472010-05-08 11:01:39 +00001676]])],[ac_cv_pthread=yes],[ac_cv_pthread=no],[ac_cv_pthread=no])
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00001677CC="$ac_save_cc"])
1678AC_MSG_RESULT($ac_cv_pthread)
1679fi
1680
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001681# If we have set a CC compiler flag for thread support then
1682# check if it works for CXX, too.
1683ac_cv_cxx_thread=no
1684if test ! -z "$CXX"
1685then
1686AC_MSG_CHECKING(whether $CXX also accepts flags for thread support)
1687ac_save_cxx="$CXX"
1688
1689if test "$ac_cv_kpthread" = "yes"
1690then
Martin v. Löwis519adae2003-09-20 10:47:47 +00001691 CXX="$CXX -Kpthread"
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001692 ac_cv_cxx_thread=yes
1693elif test "$ac_cv_kthread" = "yes"
1694then
1695 CXX="$CXX -Kthread"
1696 ac_cv_cxx_thread=yes
1697elif test "$ac_cv_pthread" = "yes"
1698then
1699 CXX="$CXX -pthread"
1700 ac_cv_cxx_thread=yes
1701fi
1702
1703if test $ac_cv_cxx_thread = yes
1704then
1705 echo 'void foo();int main(){foo();}void foo(){}' > conftest.$ac_ext
1706 $CXX -c conftest.$ac_ext 2>&5
1707 if $CXX -o conftest$ac_exeext conftest.$ac_objext 2>&5 \
1708 && test -s conftest$ac_exeext && ./conftest$ac_exeext
1709 then
1710 ac_cv_cxx_thread=yes
1711 else
1712 ac_cv_cxx_thread=no
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001713 fi
1714 rm -fr conftest*
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001715fi
Brett Cannonc601e0f2004-11-07 01:24:12 +00001716AC_MSG_RESULT($ac_cv_cxx_thread)
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001717fi
Martin v. Löwis519adae2003-09-20 10:47:47 +00001718CXX="$ac_save_cxx"
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001719
Fred Drakece81d592000-07-09 14:39:29 +00001720dnl # check for ANSI or K&R ("traditional") preprocessor
1721dnl AC_MSG_CHECKING(for C preprocessor type)
Matthias Klosec511b472010-05-08 11:01:39 +00001722dnl AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Fred Drakece81d592000-07-09 14:39:29 +00001723dnl #define spam(name, doc) {#name, &name, #name "() -- " doc}
1724dnl int foo;
1725dnl struct {char *name; int *addr; char *doc;} desc = spam(foo, "something");
Matthias Klosec511b472010-05-08 11:01:39 +00001726dnl ]], [[;]])],[cpp_type=ansi],[AC_DEFINE(HAVE_OLD_CPP) cpp_type=traditional])
Fred Drakece81d592000-07-09 14:39:29 +00001727dnl AC_MSG_RESULT($cpp_type)
Guido van Rossum300fda71996-08-19 21:58:16 +00001728
Guido van Rossum627b2d71993-12-24 10:39:16 +00001729# checks for header files
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001730AC_HEADER_STDC
Miss Islington (bot)6ccdad72018-01-24 01:51:39 -08001731AC_CHECK_HEADERS(asm/types.h crypt.h conio.h direct.h dlfcn.h errno.h \
Martin v. Löwis0e8bd7e2006-06-10 12:23:46 +00001732fcntl.h grp.h \
doko@ubuntu.comf27ec3e2014-04-17 20:11:19 +02001733ieeefp.h io.h langinfo.h libintl.h poll.h process.h pthread.h \
Martin v. Löwis40e9aed2006-10-02 15:20:37 +00001734shadow.h signal.h stdint.h stropts.h termios.h thread.h \
Martin v. Löwis14e73b12003-01-01 09:51:12 +00001735unistd.h utime.h \
Christian Heimes0e9ab5f2008-03-21 23:49:44 +00001736sys/audioio.h sys/bsdtty.h sys/epoll.h sys/event.h sys/file.h sys/loadavg.h \
1737sys/lock.h sys/mkdev.h sys/modem.h \
Benjamin Peterson6b1c9092016-12-19 23:54:25 -08001738sys/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 +00001739sys/termio.h sys/time.h \
Martin v. Löwis0e8bd7e2006-06-10 12:23:46 +00001740sys/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 +00001741sys/resource.h netpacket/packet.h sysexits.h bluetooth.h \
Christian Heimesffa70112017-09-05 17:08:45 +02001742bluetooth/bluetooth.h linux/tipc.h spawn.h util.h alloca.h sys/sysmacros.h)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001743AC_HEADER_DIRENT
Martin v. Löwisdbe3f762002-10-10 14:27:30 +00001744AC_HEADER_MAJOR
Guido van Rossum627b2d71993-12-24 10:39:16 +00001745
Martin v. Löwis11017b12006-01-14 18:12:57 +00001746# On Linux, netlink.h requires asm/types.h
1747AC_CHECK_HEADERS(linux/netlink.h,,,[
1748#ifdef HAVE_ASM_TYPES_H
1749#include <asm/types.h>
1750#endif
1751#ifdef HAVE_SYS_SOCKET_H
1752#include <sys/socket.h>
1753#endif
1754])
1755
Guido van Rossum627b2d71993-12-24 10:39:16 +00001756# checks for typedefs
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001757was_it_defined=no
1758AC_MSG_CHECKING(for clock_t in time.h)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001759AC_EGREP_HEADER(clock_t, time.h, was_it_defined=yes, [
1760 AC_DEFINE(clock_t, long, [Define to 'long' if <time.h> doesn't define.])
1761])
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001762AC_MSG_RESULT($was_it_defined)
1763
Neal Norwitz11690112002-07-30 01:08:28 +00001764# Check whether using makedev requires defining _OSF_SOURCE
1765AC_MSG_CHECKING(for makedev)
Matthias Klosec511b472010-05-08 11:01:39 +00001766AC_LINK_IFELSE([AC_LANG_PROGRAM([[
Jesus Cea616de772010-04-28 10:32:30 +00001767#if defined(MAJOR_IN_MKDEV)
1768#include <sys/mkdev.h>
1769#elif defined(MAJOR_IN_SYSMACROS)
1770#include <sys/sysmacros.h>
1771#else
1772#include <sys/types.h>
Matthias Klosec511b472010-05-08 11:01:39 +00001773#endif ]], [[ makedev(0, 0) ]])],
1774[ac_cv_has_makedev=yes],
1775[ac_cv_has_makedev=no])
Neal Norwitz11690112002-07-30 01:08:28 +00001776if test "$ac_cv_has_makedev" = "no"; then
1777 # we didn't link, try if _OSF_SOURCE will allow us to link
Matthias Klosec511b472010-05-08 11:01:39 +00001778 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
Neal Norwitz6eb37f02003-02-23 23:28:15 +00001779#define _OSF_SOURCE 1
1780#include <sys/types.h>
Matthias Klosec511b472010-05-08 11:01:39 +00001781 ]], [[ makedev(0, 0) ]])],
1782[ac_cv_has_makedev=yes],
1783[ac_cv_has_makedev=no])
Neal Norwitz11690112002-07-30 01:08:28 +00001784 if test "$ac_cv_has_makedev" = "yes"; then
1785 AC_DEFINE(_OSF_SOURCE, 1, [Define _OSF_SOURCE to get the makedev macro.])
1786 fi
1787fi
1788AC_MSG_RESULT($ac_cv_has_makedev)
1789if test "$ac_cv_has_makedev" = "yes"; then
1790 AC_DEFINE(HAVE_MAKEDEV, 1, [Define this if you have the makedev macro.])
1791fi
1792
Martin v. Löwis399a6892002-10-04 10:22:02 +00001793# Enabling LFS on Solaris (2.6 to 9) with gcc 2.95 triggers a bug in
1794# the system headers: If _XOPEN_SOURCE and _LARGEFILE_SOURCE are
1795# defined, but the compiler does not support pragma redefine_extname,
1796# and _LARGEFILE64_SOURCE is not defined, the headers refer to 64-bit
1797# structures (such as rlimit64) without declaring them. As a
1798# work-around, disable LFS on such configurations
1799
1800use_lfs=yes
1801AC_MSG_CHECKING(Solaris LFS bug)
Matthias Klosec511b472010-05-08 11:01:39 +00001802AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwis399a6892002-10-04 10:22:02 +00001803#define _LARGEFILE_SOURCE 1
1804#define _FILE_OFFSET_BITS 64
1805#include <sys/resource.h>
Matthias Klosec511b472010-05-08 11:01:39 +00001806]], [[struct rlimit foo;]])],[sol_lfs_bug=no],[sol_lfs_bug=yes])
Martin v. Löwis399a6892002-10-04 10:22:02 +00001807AC_MSG_RESULT($sol_lfs_bug)
1808if test "$sol_lfs_bug" = "yes"; then
1809 use_lfs=no
1810fi
1811
1812if test "$use_lfs" = "yes"; then
Guido van Rossum810cc512001-09-09 23:51:39 +00001813# Two defines needed to enable largefile support on various platforms
1814# These may affect some typedefs
Georg Brandl94800df2011-02-25 11:09:02 +00001815case $ac_sys_system/$ac_sys_release in
1816AIX*)
1817 AC_DEFINE(_LARGE_FILES, 1,
1818 [This must be defined on AIX systems to enable large file support.])
1819 ;;
1820esac
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001821AC_DEFINE(_LARGEFILE_SOURCE, 1,
1822[This must be defined on some systems to enable large file support.])
1823AC_DEFINE(_FILE_OFFSET_BITS, 64,
1824[This must be set to 64 on some systems to enable large file support.])
Martin v. Löwis399a6892002-10-04 10:22:02 +00001825fi
Guido van Rossum810cc512001-09-09 23:51:39 +00001826
Guido van Rossum300fda71996-08-19 21:58:16 +00001827# Add some code to confdefs.h so that the test for off_t works on SCO
1828cat >> confdefs.h <<\EOF
1829#if defined(SCO_DS)
1830#undef _OFF_T
1831#endif
1832EOF
1833
Guido van Rossumef2255b2000-03-10 22:30:29 +00001834# Type availability checks
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001835AC_TYPE_MODE_T
1836AC_TYPE_OFF_T
1837AC_TYPE_PID_T
Matthias Klosecbf54b12010-05-08 11:04:18 +00001838AC_DEFINE_UNQUOTED([RETSIGTYPE],[void],[assume C89 semantics that RETSIGTYPE is always void])
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001839AC_TYPE_SIZE_T
1840AC_TYPE_UID_T
Mark Dickinson17c50cd2012-12-02 13:13:56 +00001841
1842# There are two separate checks for each of the exact-width integer types we
1843# need. First we check whether the type is available using the usual
1844# AC_CHECK_TYPE macro with the default includes (which includes <inttypes.h>
1845# and <stdint.h> where available). We then also use the special type checks of
1846# the form AC_TYPE_UINT32_T, which in the case that uint32_t is not available
1847# directly, #define's uint32_t to be a suitable type.
1848
1849AC_CHECK_TYPE(uint32_t,
1850 AC_DEFINE(HAVE_UINT32_T, 1, [Define if your compiler provides uint32_t.]),,)
Mark Dickinsonefc82f72009-03-20 15:51:55 +00001851AC_TYPE_UINT32_T
Mark Dickinson17c50cd2012-12-02 13:13:56 +00001852
1853AC_CHECK_TYPE(uint64_t,
1854 AC_DEFINE(HAVE_UINT64_T, 1, [Define if your compiler provides uint64_t.]),,)
Mark Dickinsonefc82f72009-03-20 15:51:55 +00001855AC_TYPE_UINT64_T
Mark Dickinson17c50cd2012-12-02 13:13:56 +00001856
1857AC_CHECK_TYPE(int32_t,
1858 AC_DEFINE(HAVE_INT32_T, 1, [Define if your compiler provides int32_t.]),,)
Mark Dickinsonefc82f72009-03-20 15:51:55 +00001859AC_TYPE_INT32_T
Mark Dickinson17c50cd2012-12-02 13:13:56 +00001860
1861AC_CHECK_TYPE(int64_t,
1862 AC_DEFINE(HAVE_INT64_T, 1, [Define if your compiler provides int64_t.]),,)
Mark Dickinsonefc82f72009-03-20 15:51:55 +00001863AC_TYPE_INT64_T
Mark Dickinson17c50cd2012-12-02 13:13:56 +00001864
Christian Heimes951cc0f2008-01-31 23:08:23 +00001865AC_CHECK_TYPE(ssize_t,
Matthias Klose5183ebd2010-04-24 16:38:36 +00001866 AC_DEFINE(HAVE_SSIZE_T, 1, [Define if your compiler provides ssize_t]),,)
Guido van Rossum627b2d71993-12-24 10:39:16 +00001867
Guido van Rossumef2255b2000-03-10 22:30:29 +00001868# Sizes of various common basic types
Skip Montanarob9820a32004-01-17 00:16:12 +00001869# ANSI C requires sizeof(char) == 1, so no need to check it
Guido van Rossum3065c942001-09-17 04:03:14 +00001870AC_CHECK_SIZEOF(int, 4)
1871AC_CHECK_SIZEOF(long, 4)
1872AC_CHECK_SIZEOF(void *, 4)
Guido van Rossum3065c942001-09-17 04:03:14 +00001873AC_CHECK_SIZEOF(short, 2)
1874AC_CHECK_SIZEOF(float, 4)
1875AC_CHECK_SIZEOF(double, 8)
1876AC_CHECK_SIZEOF(fpos_t, 4)
Martin v. Löwis18e16552006-02-15 17:27:45 +00001877AC_CHECK_SIZEOF(size_t, 4)
Christian Heimes951cc0f2008-01-31 23:08:23 +00001878AC_CHECK_SIZEOF(pid_t, 4)
Guido van Rossumac405f61994-09-12 10:56:06 +00001879
Guido van Rossumec95c7b1998-08-04 17:59:56 +00001880AC_MSG_CHECKING(for long long support)
1881have_long_long=no
Matthias Klosec511b472010-05-08 11:01:39 +00001882AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[long long x; x = (long long)0;]])],[
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001883 AC_DEFINE(HAVE_LONG_LONG, 1, [Define this if you have the type long long.])
1884 have_long_long=yes
Matthias Klosec511b472010-05-08 11:01:39 +00001885],[])
Guido van Rossumec95c7b1998-08-04 17:59:56 +00001886AC_MSG_RESULT($have_long_long)
Guido van Rossum8bc1dfd1999-04-10 16:01:48 +00001887if test "$have_long_long" = yes ; then
Guido van Rossum3065c942001-09-17 04:03:14 +00001888AC_CHECK_SIZEOF(long long, 8)
Guido van Rossumec95c7b1998-08-04 17:59:56 +00001889fi
1890
Travis E. Oliphant711c9e92008-06-06 22:33:21 +00001891AC_MSG_CHECKING(for long double support)
1892have_long_double=no
Matthias Klosec511b472010-05-08 11:01:39 +00001893AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[long double x; x = (long double)0;]])],[
Travis E. Oliphant711c9e92008-06-06 22:33:21 +00001894 AC_DEFINE(HAVE_LONG_DOUBLE, 1, [Define this if you have the type long double.])
1895 have_long_double=yes
Matthias Klosec511b472010-05-08 11:01:39 +00001896],[])
Travis E. Oliphant711c9e92008-06-06 22:33:21 +00001897AC_MSG_RESULT($have_long_double)
Mark Dickinsondc1688a2008-06-27 22:20:14 +00001898if test "$have_long_double" = yes ; then
Travis E. Oliphant711c9e92008-06-06 22:33:21 +00001899AC_CHECK_SIZEOF(long double, 12)
1900fi
1901
Martin v. Löwisaef4c6b2007-01-21 09:33:07 +00001902AC_MSG_CHECKING(for _Bool support)
1903have_c99_bool=no
Matthias Klosec511b472010-05-08 11:01:39 +00001904AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[_Bool x; x = (_Bool)0;]])],[
Martin v. Löwisaef4c6b2007-01-21 09:33:07 +00001905 AC_DEFINE(HAVE_C99_BOOL, 1, [Define this if you have the type _Bool.])
1906 have_c99_bool=yes
Matthias Klosec511b472010-05-08 11:01:39 +00001907],[])
Martin v. Löwisaef4c6b2007-01-21 09:33:07 +00001908AC_MSG_RESULT($have_c99_bool)
1909if test "$have_c99_bool" = yes ; then
1910AC_CHECK_SIZEOF(_Bool, 1)
1911fi
1912
Martin v. Löwisebe26702006-10-02 14:55:51 +00001913AC_CHECK_TYPES(uintptr_t,
1914 [AC_CHECK_SIZEOF(uintptr_t, 4)],
Martin v. Löwis40e9aed2006-10-02 15:20:37 +00001915 [], [#ifdef HAVE_STDINT_H
1916 #include <stdint.h>
Antoine Pitrou7be5a652010-10-10 08:14:41 +00001917 #endif
1918 #ifdef HAVE_INTTYPES_H
1919 #include <inttypes.h>
Martin v. Löwis40e9aed2006-10-02 15:20:37 +00001920 #endif])
Martin v. Löwisebe26702006-10-02 14:55:51 +00001921
Alexandre Vassalotti856782e2009-07-17 04:59:05 +00001922AC_CHECK_SIZEOF(off_t, [], [
1923#ifdef HAVE_SYS_TYPES_H
1924#include <sys/types.h>
1925#endif
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001926])
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001927
1928AC_MSG_CHECKING(whether to enable large file support)
Mark Dickinson0ef0b912009-12-31 21:11:48 +00001929if test "$have_long_long" = yes
1930then
1931if test "$ac_cv_sizeof_off_t" -gt "$ac_cv_sizeof_long" -a \
Guido van Rossum8bc1dfd1999-04-10 16:01:48 +00001932 "$ac_cv_sizeof_long_long" -ge "$ac_cv_sizeof_off_t"; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001933 AC_DEFINE(HAVE_LARGEFILE_SUPPORT, 1,
1934 [Defined to enable large file support when an off_t is bigger than a long
1935 and long long is available and at least as big as an off_t. You may need
1936 to add some flags for configuration and compilation to enable this mode.
1937 (For Solaris and Linux, the necessary defines are already defined.)])
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001938 AC_MSG_RESULT(yes)
1939else
1940 AC_MSG_RESULT(no)
1941fi
Mark Dickinson0ef0b912009-12-31 21:11:48 +00001942else
1943 AC_MSG_RESULT(no)
1944fi
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001945
Alexandre Vassalotti856782e2009-07-17 04:59:05 +00001946AC_CHECK_SIZEOF(time_t, [], [
1947#ifdef HAVE_SYS_TYPES_H
1948#include <sys/types.h>
1949#endif
1950#ifdef HAVE_TIME_H
1951#include <time.h>
1952#endif
Fred Drakea3f6e912000-06-29 20:44:47 +00001953])
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001954
Trent Mick635f6fb2000-08-23 21:33:05 +00001955# if have pthread_t then define SIZEOF_PTHREAD_T
Martin v. Löwis123cbd22001-07-19 14:21:10 +00001956ac_save_cc="$CC"
1957if test "$ac_cv_kpthread" = "yes"
1958then CC="$CC -Kpthread"
Martin v. Löwis5f433f02003-05-05 05:05:30 +00001959elif test "$ac_cv_kthread" = "yes"
1960then CC="$CC -Kthread"
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00001961elif test "$ac_cv_pthread" = "yes"
1962then CC="$CC -pthread"
Martin v. Löwis123cbd22001-07-19 14:21:10 +00001963fi
Trent Mick635f6fb2000-08-23 21:33:05 +00001964AC_MSG_CHECKING(for pthread_t)
1965have_pthread_t=no
Matthias Klosec511b472010-05-08 11:01:39 +00001966AC_COMPILE_IFELSE([
1967 AC_LANG_PROGRAM([[#include <pthread.h>]], [[pthread_t x; x = *(pthread_t*)0;]])
1968],[have_pthread_t=yes],[])
Trent Mick635f6fb2000-08-23 21:33:05 +00001969AC_MSG_RESULT($have_pthread_t)
1970if test "$have_pthread_t" = yes ; then
Alexandre Vassalotti856782e2009-07-17 04:59:05 +00001971 AC_CHECK_SIZEOF(pthread_t, [], [
1972#ifdef HAVE_PTHREAD_H
1973#include <pthread.h>
1974#endif
Trent Mick635f6fb2000-08-23 21:33:05 +00001975 ])
Trent Mick635f6fb2000-08-23 21:33:05 +00001976fi
Martin v. Löwis123cbd22001-07-19 14:21:10 +00001977CC="$ac_save_cc"
Trent Mick635f6fb2000-08-23 21:33:05 +00001978
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001979AC_MSG_CHECKING(for --enable-toolbox-glue)
1980AC_ARG_ENABLE(toolbox-glue,
Matthias Klose22520ea2010-05-08 10:14:46 +00001981 AS_HELP_STRING([--enable-toolbox-glue], [disable/enable MacOSX glue code for extensions]))
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001982
1983if test -z "$enable_toolbox_glue"
1984then
1985 case $ac_sys_system/$ac_sys_release in
1986 Darwin/*)
1987 enable_toolbox_glue="yes";;
1988 *)
1989 enable_toolbox_glue="no";;
1990 esac
1991fi
1992case "$enable_toolbox_glue" in
1993yes)
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001994 extra_machdep_objs="Python/mactoolboxglue.o"
Raymond Hettingerec6eb362004-11-05 07:02:59 +00001995 extra_undefs="-u _PyMac_Error"
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001996 AC_DEFINE(USE_TOOLBOX_OBJECT_GLUE, 1,
1997 [Define if you want to use MacPython modules on MacOSX in unix-Python.])
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001998 ;;
1999*)
Jack Jansenb6e9cad2001-08-15 01:26:28 +00002000 extra_machdep_objs=""
Jack Jansen591cbed2001-08-15 13:55:15 +00002001 extra_undefs=""
Jack Jansenb6e9cad2001-08-15 01:26:28 +00002002 ;;
2003esac
2004AC_MSG_RESULT($enable_toolbox_glue)
2005
Ronald Oussoren0d236eb2008-06-06 21:31:33 +00002006
Bob Ippolito7026a0a2005-03-28 23:23:47 +00002007AC_SUBST(OTHER_LIBTOOL_OPT)
2008case $ac_sys_system/$ac_sys_release in
Anthony Baxter82201742006-04-09 15:07:40 +00002009 Darwin/@<:@01567@:>@\..*)
Bob Ippolito7026a0a2005-03-28 23:23:47 +00002010 OTHER_LIBTOOL_OPT="-prebind -seg1addr 0x10000000"
2011 ;;
2012 Darwin/*)
2013 OTHER_LIBTOOL_OPT=""
2014 ;;
2015esac
2016
Ronald Oussoren25967582009-09-06 10:00:26 +00002017
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00002018AC_SUBST(LIBTOOL_CRUFT)
2019case $ac_sys_system/$ac_sys_release in
Anthony Baxter82201742006-04-09 15:07:40 +00002020 Darwin/@<:@01567@:>@\..*)
Ronald Oussoren988117f2006-04-29 11:31:35 +00002021 LIBTOOL_CRUFT="-framework System -lcc_dynamic"
2022 if test "${enable_universalsdk}"; then
2023 :
2024 else
Ronald Oussorenbc0e83c2010-02-11 13:26:54 +00002025 LIBTOOL_CRUFT="${LIBTOOL_CRUFT} -arch_only `/usr/bin/arch`"
Ronald Oussoren988117f2006-04-29 11:31:35 +00002026 fi
Jack Jansenb36687a2004-07-16 08:43:47 +00002027 LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -install_name $(PYTHONFRAMEWORKINSTALLDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansena3891ea2001-09-07 14:25:12 +00002028 LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -compatibility_version $(VERSION) -current_version $(VERSION)';;
Guido van Rossum5839e582000-10-09 19:52:35 +00002029 Darwin/*)
Ronald Oussorena55af9a2010-01-17 16:25:57 +00002030 gcc_version=`gcc -dumpversion`
Bob Ippolito7026a0a2005-03-28 23:23:47 +00002031 if test ${gcc_version} '<' 4.0
2032 then
2033 LIBTOOL_CRUFT="-lcc_dynamic"
2034 else
2035 LIBTOOL_CRUFT=""
2036 fi
Matthias Klosec511b472010-05-08 11:01:39 +00002037 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Ronald Oussoren25967582009-09-06 10:00:26 +00002038 #include <unistd.h>
2039 int main(int argc, char*argv[])
2040 {
2041 if (sizeof(long) == 4) {
2042 return 0;
2043 } else {
2044 return 1;
2045 }
Ronald Oussoren84ddd722009-09-08 07:17:10 +00002046 }
Matthias Klosec511b472010-05-08 11:01:39 +00002047 ]])],[ac_osx_32bit=yes],[ac_osx_32bit=no],[ac_osx_32bit=yes])
Ronald Oussoren25967582009-09-06 10:00:26 +00002048
2049 if test "${ac_osx_32bit}" = "yes"; then
Ronald Oussorenbc0e83c2010-02-11 13:26:54 +00002050 case `/usr/bin/arch` in
Ronald Oussoren25967582009-09-06 10:00:26 +00002051 i386)
2052 MACOSX_DEFAULT_ARCH="i386"
2053 ;;
2054 ppc)
2055 MACOSX_DEFAULT_ARCH="ppc"
2056 ;;
2057 *)
2058 AC_MSG_ERROR([Unexpected output of 'arch' on OSX])
2059 ;;
2060 esac
2061 else
Ronald Oussorenbc0e83c2010-02-11 13:26:54 +00002062 case `/usr/bin/arch` in
Ronald Oussoren25967582009-09-06 10:00:26 +00002063 i386)
2064 MACOSX_DEFAULT_ARCH="x86_64"
2065 ;;
2066 ppc)
2067 MACOSX_DEFAULT_ARCH="ppc64"
2068 ;;
2069 *)
2070 AC_MSG_ERROR([Unexpected output of 'arch' on OSX])
2071 ;;
2072 esac
2073
Ronald Oussoren25967582009-09-06 10:00:26 +00002074 fi
2075
2076 LIBTOOL_CRUFT=$LIBTOOL_CRUFT" -lSystem -lSystemStubs -arch_only ${MACOSX_DEFAULT_ARCH}"
Jack Jansenb36687a2004-07-16 08:43:47 +00002077 LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -install_name $(PYTHONFRAMEWORKINSTALLDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansenb6e9cad2001-08-15 01:26:28 +00002078 LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -compatibility_version $(VERSION) -current_version $(VERSION)';;
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00002079esac
2080
Jack Jansenb6e9cad2001-08-15 01:26:28 +00002081AC_MSG_CHECKING(for --enable-framework)
2082if test "$enable_framework"
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00002083then
Skip Montanarodecc6a42003-01-01 20:07:49 +00002084 BASECFLAGS="$BASECFLAGS -fno-common -dynamic"
Jack Jansenb6e9cad2001-08-15 01:26:28 +00002085 # -F. is needed to allow linking to the framework while
2086 # in the build location.
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002087 AC_DEFINE(WITH_NEXT_FRAMEWORK, 1,
2088 [Define if you want to produce an OpenStep/Rhapsody framework
2089 (shared library plus accessory files).])
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00002090 AC_MSG_RESULT(yes)
Ronald Oussoren450d5612009-06-08 21:12:41 +00002091 if test $enable_shared = "yes"
2092 then
Ronald Oussoren9ebd2422009-09-29 13:00:44 +00002093 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 +00002094 fi
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00002095else
2096 AC_MSG_RESULT(no)
2097fi
2098
Jack Jansenb6e9cad2001-08-15 01:26:28 +00002099AC_MSG_CHECKING(for dyld)
Jack Jansen9a66b6d2001-08-08 13:56:14 +00002100case $ac_sys_system/$ac_sys_release in
2101 Darwin/*)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002102 AC_DEFINE(WITH_DYLD, 1,
2103 [Define if you want to use the new-style (Openstep, Rhapsody, MacOS)
2104 dynamic linker (dyld) instead of the old-style (NextStep) dynamic
2105 linker (rld). Dyld is necessary to support frameworks.])
Jack Jansen9a66b6d2001-08-08 13:56:14 +00002106 AC_MSG_RESULT(always on for Darwin)
2107 ;;
2108 *)
Jack Jansenb6e9cad2001-08-15 01:26:28 +00002109 AC_MSG_RESULT(no)
2110 ;;
Jack Jansen9a66b6d2001-08-08 13:56:14 +00002111esac
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00002112
Guido van Rossumac405f61994-09-12 10:56:06 +00002113# Set info about shared libraries.
Guido van Rossumac405f61994-09-12 10:56:06 +00002114AC_SUBST(SO)
2115AC_SUBST(LDSHARED)
Tarek Ziadé00002952010-04-03 08:37:59 +00002116AC_SUBST(LDCXXSHARED)
Neil Schemenauerb3531b82001-02-16 04:09:05 +00002117AC_SUBST(BLDSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00002118AC_SUBST(CCSHARED)
2119AC_SUBST(LINKFORSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00002120# SO is the extension of shared libraries `(including the dot!)
Guido van Rossumaef734b2001-01-10 21:09:12 +00002121# -- usually .so, .sl on HP-UX, .dll on Cygwin
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002122AC_MSG_CHECKING(SO)
Guido van Rossumac405f61994-09-12 10:56:06 +00002123if test -z "$SO"
2124then
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002125 case $ac_sys_system in
Neal Norwitz58e28882006-05-19 07:00:58 +00002126 hp*|HP*)
2127 case `uname -m` in
2128 ia64) SO=.so;;
2129 *) SO=.sl;;
2130 esac
2131 ;;
Guido van Rossumaef734b2001-01-10 21:09:12 +00002132 CYGWIN*) SO=.dll;;
Guido van Rossum4b6b5791996-09-09 20:09:34 +00002133 *) SO=.so;;
Guido van Rossumac405f61994-09-12 10:56:06 +00002134 esac
Martin v. Löwis368de8f2003-06-14 14:46:38 +00002135else
2136 # this might also be a termcap variable, see #610332
2137 echo
2138 echo '====================================================================='
2139 echo '+ +'
2140 echo '+ WARNING: You have set SO in your environment. +'
2141 echo '+ Do you really mean to change the extension for shared libraries? +'
2142 echo '+ Continuing in 10 seconds to let you to ponder. +'
2143 echo '+ +'
2144 echo '====================================================================='
2145 sleep 10
Guido van Rossumac405f61994-09-12 10:56:06 +00002146fi
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002147AC_MSG_RESULT($SO)
Ronald Oussoren79f90492009-01-02 10:44:46 +00002148
Neal Norwitz58e28882006-05-19 07:00:58 +00002149AC_DEFINE_UNQUOTED(SHLIB_EXT, "$SO", [Define this to be extension of shared libraries (including the dot!).])
Guido van Rossumac405f61994-09-12 10:56:06 +00002150# LDSHARED is the ld *command* used to create shared library
Skip Montanaroce59c042004-01-17 14:19:44 +00002151# -- "cc -G" on SunOS 5.x, "ld -shared" on IRIX 5
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00002152# (Shared libraries in this instance are shared modules to be loaded into
2153# Python, as opposed to building Python itself as a shared library.)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002154AC_MSG_CHECKING(LDSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00002155if test -z "$LDSHARED"
2156then
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002157 case $ac_sys_system/$ac_sys_release in
Neil Schemenauerb3531b82001-02-16 04:09:05 +00002158 AIX*)
Martin Panterf75a2eb2016-11-20 09:31:41 +00002159 BLDSHARED="Modules/ld_so_aix \$(CC) -bI:Modules/python.exp"
Guido van Rossumce608b02001-09-28 15:59:38 +00002160 LDSHARED="\$(BINLIBDEST)/config/ld_so_aix \$(CC) -bI:\$(BINLIBDEST)/config/python.exp"
Neil Schemenauerb3531b82001-02-16 04:09:05 +00002161 ;;
2162 BeOS*)
2163 BLDSHARED="\$(srcdir)/Modules/ld_so_beos $LDLIBRARY"
Guido van Rossumce608b02001-09-28 15:59:38 +00002164 LDSHARED="\$(BINLIBDEST)/config/ld_so_beos \$(LIBDIR)/$LDLIBRARY"
Neil Schemenauerb3531b82001-02-16 04:09:05 +00002165 ;;
Guido van Rossum6100aaf1997-04-29 21:48:51 +00002166 IRIX/5*) LDSHARED="ld -shared";;
Guido van Rossum91922671997-10-09 20:24:13 +00002167 IRIX*/6*) LDSHARED="ld ${SGI_ABI} -shared -all";;
Greg Ward57c9a662000-05-26 12:22:54 +00002168 SunOS/5*)
Tarek Ziadé00002952010-04-03 08:37:59 +00002169 if test "$GCC" = "yes" ; then
2170 LDSHARED='$(CC) -shared'
2171 LDCXXSHARED='$(CXX) -shared'
2172 else
2173 LDSHARED='$(CC) -G'
2174 LDCXXSHARED='$(CXX) -G'
Greg Ward57c9a662000-05-26 12:22:54 +00002175 fi ;;
Thomas Hellerdc96a772008-04-04 10:07:55 +00002176 hp*|HP*)
Tarek Ziadé00002952010-04-03 08:37:59 +00002177 if test "$GCC" = "yes" ; then
2178 LDSHARED='$(CC) -shared'
2179 LDCXXSHARED='$(CXX) -shared'
2180 else
2181 LDSHARED='ld -b'
Thomas Hellerdc96a772008-04-04 10:07:55 +00002182 fi ;;
Guido van Rossum71001e41995-01-26 00:44:03 +00002183 OSF*) LDSHARED="ld -shared -expect_unresolved \"*\"";;
Jack Jansen418c3b12001-11-14 10:59:57 +00002184 Darwin/1.3*)
Stefan Krah3a3e2032010-11-28 15:30:05 +00002185 LDSHARED='$(CC) -bundle'
2186 LDCXXSHARED='$(CXX) -bundle'
Jack Jansena3891ea2001-09-07 14:25:12 +00002187 if test "$enable_framework" ; then
2188 # Link against the framework. All externals should be defined.
Jack Jansenda49e192005-01-07 13:08:22 +00002189 BLDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
2190 LDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Tarek Ziadé00002952010-04-03 08:37:59 +00002191 LDCXXSHARED="$LDCXXSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansena3891ea2001-09-07 14:25:12 +00002192 else
2193 # No framework. Ignore undefined symbols, assuming they come from Python
Jack Jansen418c3b12001-11-14 10:59:57 +00002194 LDSHARED="$LDSHARED -undefined suppress"
Tarek Ziadé00002952010-04-03 08:37:59 +00002195 LDCXXSHARED="$LDCXXSHARED -undefined suppress"
Jack Jansena3891ea2001-09-07 14:25:12 +00002196 fi ;;
Jack Jansen6b08a402004-06-03 12:41:45 +00002197 Darwin/1.4*|Darwin/5.*|Darwin/6.*)
Stefan Krah3a3e2032010-11-28 15:30:05 +00002198 LDSHARED='$(CC) -bundle'
2199 LDCXXSHARED='$(CXX) -bundle'
Jack Jansenb6e9cad2001-08-15 01:26:28 +00002200 if test "$enable_framework" ; then
2201 # Link against the framework. All externals should be defined.
Jack Jansenda49e192005-01-07 13:08:22 +00002202 BLDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
2203 LDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Tarek Ziadé00002952010-04-03 08:37:59 +00002204 LDCXXSHARED="$LDCXXSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansenb6e9cad2001-08-15 01:26:28 +00002205 else
Michael W. Hudson0c46c0c2002-03-07 09:58:56 +00002206 # No framework, use the Python app as bundle-loader
2207 BLDSHARED="$LDSHARED "'-bundle_loader $(BUILDPYTHON)'
Jack Jansenc28fc372003-02-25 13:14:43 +00002208 LDSHARED="$LDSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)'
Tarek Ziadé00002952010-04-03 08:37:59 +00002209 LDCXXSHARED="$LDCXXSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)'
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00002210 fi ;;
Jack Jansen6b08a402004-06-03 12:41:45 +00002211 Darwin/*)
2212 # Use -undefined dynamic_lookup whenever possible (10.3 and later).
2213 # This allows an extension to be used in any Python
Ronald Oussoren38f1b982007-09-02 09:46:07 +00002214
Ned Deilyc40b9032014-06-25 13:48:46 -07002215 dep_target_major=`echo ${MACOSX_DEPLOYMENT_TARGET} | \
2216 sed 's/\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'`
2217 dep_target_minor=`echo ${MACOSX_DEPLOYMENT_TARGET} | \
2218 sed 's/\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'`
2219 if test ${dep_target_major} -eq 10 && \
2220 test ${dep_target_minor} -le 2
Jack Jansen6b08a402004-06-03 12:41:45 +00002221 then
Ned Deilyc40b9032014-06-25 13:48:46 -07002222 # building for OS X 10.0 through 10.2
Stefan Krah3a3e2032010-11-28 15:30:05 +00002223 LDSHARED='$(CC) -bundle'
2224 LDCXXSHARED='$(CXX) -bundle'
Jack Jansen6b08a402004-06-03 12:41:45 +00002225 if test "$enable_framework" ; then
2226 # Link against the framework. All externals should be defined.
Jack Jansenda49e192005-01-07 13:08:22 +00002227 BLDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
2228 LDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Tarek Ziadé00002952010-04-03 08:37:59 +00002229 LDCXXSHARED="$LDCXXSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansen6b08a402004-06-03 12:41:45 +00002230 else
2231 # No framework, use the Python app as bundle-loader
2232 BLDSHARED="$LDSHARED "'-bundle_loader $(BUILDPYTHON)'
2233 LDSHARED="$LDSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)'
Tarek Ziadé00002952010-04-03 08:37:59 +00002234 LDCXXSHARED="$LDCXXSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)'
Jack Jansen6b08a402004-06-03 12:41:45 +00002235 fi
Ned Deilyc40b9032014-06-25 13:48:46 -07002236 else
2237 # building for OS X 10.3 and later
Ned Deilyc40b9032014-06-25 13:48:46 -07002238 LDSHARED='$(CC) -bundle -undefined dynamic_lookup'
2239 LDCXXSHARED='$(CXX) -bundle -undefined dynamic_lookup'
2240 BLDSHARED="$LDSHARED"
Jack Jansen6b08a402004-06-03 12:41:45 +00002241 fi
2242 ;;
Tarek Ziadé00002952010-04-03 08:37:59 +00002243 Linux*|GNU*|QNX*)
2244 LDSHARED='$(CC) -shared'
2245 LDCXXSHARED='$(CXX) -shared';;
2246 BSD/OS*/4*)
2247 LDSHARED="gcc -shared"
2248 LDCXXSHARED="g++ -shared";;
Martin v. Löwis222c5152006-06-03 07:37:13 +00002249 FreeBSD*)
Jeremy Hylton4bcc7c52000-08-31 17:45:35 +00002250 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
Guido van Rossum0286ae82000-08-29 15:06:49 +00002251 then
Stefan Krah3a3e2032010-11-28 15:30:05 +00002252 LDSHARED='$(CC) -shared'
2253 LDCXXSHARED='$(CXX) -shared'
Guido van Rossum0286ae82000-08-29 15:06:49 +00002254 else
Stefan Krah3a3e2032010-11-28 15:30:05 +00002255 LDSHARED="ld -Bshareable"
Guido van Rossum0286ae82000-08-29 15:06:49 +00002256 fi;;
Martin v. Löwis222c5152006-06-03 07:37:13 +00002257 OpenBSD*)
2258 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
2259 then
Stefan Krah3a3e2032010-11-28 15:30:05 +00002260 LDSHARED='$(CC) -shared $(CCSHARED)'
2261 LDCXXSHARED='$(CXX) -shared $(CCSHARED)'
Martin v. Löwis222c5152006-06-03 07:37:13 +00002262 else
2263 case `uname -r` in
2264 [[01]].* | 2.[[0-7]] | 2.[[0-7]].*)
2265 LDSHARED="ld -Bshareable ${LDFLAGS}"
2266 ;;
2267 *)
Stefan Krah3a3e2032010-11-28 15:30:05 +00002268 LDSHARED='$(CC) -shared $(CCSHARED)'
2269 LDCXXSHARED='$(CXX) -shared $(CCSHARED)'
Martin v. Löwis222c5152006-06-03 07:37:13 +00002270 ;;
2271 esac
2272 fi;;
Tarek Ziadé00002952010-04-03 08:37:59 +00002273 NetBSD*|DragonFly*)
Antoine Pitroucb402772011-01-02 20:51:34 +00002274 LDSHARED='$(CC) -shared'
2275 LDCXXSHARED='$(CXX) -shared';;
Martin v. Löwis25ae43b2001-10-07 08:39:18 +00002276 OpenUNIX*|UnixWare*)
Tarek Ziadé00002952010-04-03 08:37:59 +00002277 if test "$GCC" = "yes" ; then
2278 LDSHARED='$(CC) -shared'
2279 LDCXXSHARED='$(CXX) -shared'
2280 else
2281 LDSHARED='$(CC) -G'
2282 LDCXXSHARED='$(CXX) -G'
Martin v. Löwisbec19582001-03-21 15:57:54 +00002283 fi;;
Tarek Ziadé00002952010-04-03 08:37:59 +00002284 SCO_SV*)
2285 LDSHARED='$(CC) -Wl,-G,-Bexport'
2286 LDCXXSHARED='$(CXX) -Wl,-G,-Bexport';;
2287 CYGWIN*)
2288 LDSHARED="gcc -shared -Wl,--enable-auto-image-base"
2289 LDCXXSHARED="g++ -shared -Wl,--enable-auto-image-base";;
2290 atheos*)
2291 LDSHARED="gcc -shared"
2292 LDCXXSHARED="g++ -shared";;
Guido van Rossumac405f61994-09-12 10:56:06 +00002293 *) LDSHARED="ld";;
2294 esac
Guido van Rossumac405f61994-09-12 10:56:06 +00002295fi
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002296AC_MSG_RESULT($LDSHARED)
Tarek Ziadé00002952010-04-03 08:37:59 +00002297LDCXXSHARED=${LDCXXSHARED-$LDSHARED}
Neil Schemenauerb3531b82001-02-16 04:09:05 +00002298BLDSHARED=${BLDSHARED-$LDSHARED}
Guido van Rossumac405f61994-09-12 10:56:06 +00002299# CCSHARED are the C *flags* used to create objects to go into a shared
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00002300# library (module) -- this is only needed for a few systems
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002301AC_MSG_CHECKING(CCSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00002302if test -z "$CCSHARED"
2303then
Guido van Rossum6100aaf1997-04-29 21:48:51 +00002304 case $ac_sys_system/$ac_sys_release in
Neil Schemenauer66252162001-02-19 04:47:42 +00002305 SunOS*) if test "$GCC" = yes;
Martin v. Löwiseb623572007-03-12 10:50:39 +00002306 then CCSHARED="-fPIC";
2307 elif test `uname -p` = sparc;
2308 then CCSHARED="-xcode=pic32";
2309 else CCSHARED="-Kpic";
2310 fi;;
Guido van Rossumaf07a441995-02-13 19:45:27 +00002311 hp*|HP*) if test "$GCC" = yes;
Martin v. Löwis703ad702001-09-05 08:36:52 +00002312 then CCSHARED="-fPIC";
Guido van Rossumaf07a441995-02-13 19:45:27 +00002313 else CCSHARED="+z";
2314 fi;;
Martin v. Löwisa6e97582002-01-01 18:41:33 +00002315 Linux*|GNU*) CCSHARED="-fPIC";;
Guido van Rossumf5957ea1999-10-05 21:59:33 +00002316 BSD/OS*/4*) CCSHARED="-fpic";;
Martin v. Löwis86d66262006-02-17 08:40:11 +00002317 FreeBSD*|NetBSD*|OpenBSD*|DragonFly*) CCSHARED="-fPIC";;
Martin v. Löwis25ae43b2001-10-07 08:39:18 +00002318 OpenUNIX*|UnixWare*)
Martin v. Löwisbec19582001-03-21 15:57:54 +00002319 if test "$GCC" = "yes"
2320 then CCSHARED="-fPIC"
Martin v. Löwis130fb172001-07-19 11:00:41 +00002321 else CCSHARED="-KPIC"
Martin v. Löwisbec19582001-03-21 15:57:54 +00002322 fi;;
Martin v. Löwis21ee4092002-09-30 16:19:48 +00002323 SCO_SV*)
2324 if test "$GCC" = "yes"
2325 then CCSHARED="-fPIC"
2326 else CCSHARED="-Kpic -belf"
2327 fi;;
Guido van Rossum2b5ca001998-03-05 15:41:09 +00002328 IRIX*/6*) case $CC in
2329 *gcc*) CCSHARED="-shared";;
Guido van Rossumee21f411998-04-20 18:51:54 +00002330 *) CCSHARED="";;
Guido van Rossum2b5ca001998-03-05 15:41:09 +00002331 esac;;
Martin v. Löwisf90ae202002-06-11 06:22:31 +00002332 atheos*) CCSHARED="-fPIC";;
Guido van Rossumac405f61994-09-12 10:56:06 +00002333 esac
Guido van Rossumac405f61994-09-12 10:56:06 +00002334fi
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002335AC_MSG_RESULT($CCSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00002336# LINKFORSHARED are the flags passed to the $(CC) command that links
Guido van Rossumb65a48e1995-06-14 18:21:23 +00002337# the python executable -- this is only needed for a few systems
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002338AC_MSG_CHECKING(LINKFORSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00002339if test -z "$LINKFORSHARED"
2340then
Guido van Rossum6100aaf1997-04-29 21:48:51 +00002341 case $ac_sys_system/$ac_sys_release in
Neil Schemenauerb3531b82001-02-16 04:09:05 +00002342 AIX*) LINKFORSHARED='-Wl,-bE:Modules/python.exp -lld';;
Guido van Rossum5dab3d81996-12-06 21:18:18 +00002343 hp*|HP*)
Martin v. Löwis1142de32002-03-29 16:28:31 +00002344 LINKFORSHARED="-Wl,-E -Wl,+s";;
2345# LINKFORSHARED="-Wl,-E -Wl,+s -Wl,+b\$(BINLIBDEST)/lib-dynload";;
Guido van Rossumf5957ea1999-10-05 21:59:33 +00002346 BSD/OS/4*) LINKFORSHARED="-Xlinker -export-dynamic";;
Martin v. Löwisa6e97582002-01-01 18:41:33 +00002347 Linux*|GNU*) LINKFORSHARED="-Xlinker -export-dynamic";;
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00002348 # -u libsys_s pulls in all symbols in libsys
Jack Jansenb6e9cad2001-08-15 01:26:28 +00002349 Darwin/*)
Raymond Hettingerec6eb362004-11-05 07:02:59 +00002350 # -u _PyMac_Error is needed to pull in the mac toolbox glue,
2351 # which is
Jack Jansenb6e9cad2001-08-15 01:26:28 +00002352 # not used by the core itself but which needs to be in the core so
2353 # that dynamically loaded extension modules have access to it.
Jack Jansen97e3f002003-02-23 22:59:01 +00002354 # -prebind is no longer used, because it actually seems to give a
2355 # slowdown in stead of a speedup, maybe due to the large number of
2356 # dynamic loads Python does.
Raymond Hettingerec6eb362004-11-05 07:02:59 +00002357
2358 LINKFORSHARED="$extra_undefs"
Jack Jansenb6e9cad2001-08-15 01:26:28 +00002359 if test "$enable_framework"
2360 then
Jack Jansenda49e192005-01-07 13:08:22 +00002361 LINKFORSHARED="$LINKFORSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansenb6e9cad2001-08-15 01:26:28 +00002362 fi
Raymond Hettingerec6eb362004-11-05 07:02:59 +00002363 LINKFORSHARED="$LINKFORSHARED";;
Martin v. Löwis25ae43b2001-10-07 08:39:18 +00002364 OpenUNIX*|UnixWare*) LINKFORSHARED="-Wl,-Bexport";;
Martin v. Löwis21ee4092002-09-30 16:19:48 +00002365 SCO_SV*) LINKFORSHARED="-Wl,-Bexport";;
Fred Drake02706f52000-09-25 15:08:46 +00002366 ReliantUNIX*) LINKFORSHARED="-W1 -Blargedynsym";;
Martin v. Löwis86d66262006-02-17 08:40:11 +00002367 FreeBSD*|NetBSD*|OpenBSD*|DragonFly*)
Guido van Rossumdf693651999-01-07 21:50:41 +00002368 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
2369 then
2370 LINKFORSHARED="-Wl,--export-dynamic"
2371 fi;;
Guido van Rossum2b5ca001998-03-05 15:41:09 +00002372 SunOS/5*) case $CC in
2373 *gcc*)
Martin v. Löwisa4548572002-04-18 14:51:36 +00002374 if $CC -Xlinker --help 2>&1 | grep export-dynamic >/dev/null
Guido van Rossum8f4ceb11997-12-18 23:42:19 +00002375 then
2376 LINKFORSHARED="-Xlinker --export-dynamic"
Guido van Rossum2b5ca001998-03-05 15:41:09 +00002377 fi;;
2378 esac;;
Jason Tishler30765592003-09-04 11:04:06 +00002379 CYGWIN*)
2380 if test $enable_shared = "no"
2381 then
2382 LINKFORSHARED='-Wl,--out-implib=$(LDLIBRARY)'
2383 fi;;
Martin v. Löwis8c255e42008-05-23 15:06:50 +00002384 QNX*)
2385 # -Wl,-E causes the symbols to be added to the dynamic
2386 # symbol table so that they can be found when a module
2387 # is loaded. -N 2048K causes the stack size to be set
2388 # to 2048 kilobytes so that the stack doesn't overflow
2389 # when running test_compile.py.
2390 LINKFORSHARED='-Wl,-E -N 2048K';;
Guido van Rossumac405f61994-09-12 10:56:06 +00002391 esac
Guido van Rossumac405f61994-09-12 10:56:06 +00002392fi
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002393AC_MSG_RESULT($LINKFORSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00002394
Ronald Oussoren0d236eb2008-06-06 21:31:33 +00002395
Neil Schemenauer61c51152001-01-26 16:18:16 +00002396AC_SUBST(CFLAGSFORSHARED)
2397AC_MSG_CHECKING(CFLAGSFORSHARED)
2398if test ! "$LIBRARY" = "$LDLIBRARY"
2399then
Neil Schemenauerd9cf41c2001-01-27 21:39:17 +00002400 case $ac_sys_system in
2401 CYGWIN*)
2402 # Cygwin needs CCSHARED when building extension DLLs
2403 # but not when building the interpreter DLL.
2404 CFLAGSFORSHARED='';;
2405 *)
2406 CFLAGSFORSHARED='$(CCSHARED)'
2407 esac
Neil Schemenauer61c51152001-01-26 16:18:16 +00002408fi
2409AC_MSG_RESULT($CFLAGSFORSHARED)
2410
Martin v. Löwisf90ae202002-06-11 06:22:31 +00002411# SHLIBS are libraries (except -lc and -lm) to link to the python shared
2412# library (with --enable-shared).
2413# For platforms on which shared libraries are not allowed to have unresolved
Martin v. Löwisd6359c52002-08-04 12:38:50 +00002414# symbols, this must be set to $(LIBS) (expanded by make). We do this even
2415# if it is not required, since it creates a dependency of the shared library
2416# to LIBS. This, in turn, means that applications linking the shared libpython
2417# don't need to link LIBS explicitly. The default should be only changed
2418# on systems where this approach causes problems.
Martin v. Löwisf90ae202002-06-11 06:22:31 +00002419AC_SUBST(SHLIBS)
2420AC_MSG_CHECKING(SHLIBS)
2421case "$ac_sys_system" in
Martin v. Löwisf90ae202002-06-11 06:22:31 +00002422 *)
Martin v. Löwisd6359c52002-08-04 12:38:50 +00002423 SHLIBS='$(LIBS)';;
Martin v. Löwisf90ae202002-06-11 06:22:31 +00002424esac
2425AC_MSG_RESULT($SHLIBS)
2426
2427
Guido van Rossum627b2d71993-12-24 10:39:16 +00002428# checks for libraries
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002429AC_CHECK_LIB(dl, dlopen) # Dynamic linking for SunOS/Solaris and SYSV
2430AC_CHECK_LIB(dld, shl_load) # Dynamic linking for HP-UX
Martin v. Löwis519adae2003-09-20 10:47:47 +00002431
Skip Montanaro4d756af2008-12-01 01:55:22 +00002432# only check for sem_init if thread support is requested
Martin v. Löwis519adae2003-09-20 10:47:47 +00002433if test "$with_threads" = "yes" -o -z "$with_threads"; then
2434 AC_SEARCH_LIBS(sem_init, pthread rt posix4) # 'Real Time' functions on Solaris
2435 # posix4 on Solaris 2.6
2436 # pthread (first!) on Linux
2437fi
2438
Martin v. Löwis19d17342003-06-14 21:03:05 +00002439# check if we need libintl for locale functions
2440AC_CHECK_LIB(intl, textdomain,
2441 AC_DEFINE(WITH_LIBINTL, 1,
2442 [Define to 1 if libintl is needed for locale functions.]))
Guido van Rossum0eefa3f1999-11-16 15:57:37 +00002443
2444# checks for system dependent C++ extensions support
2445case "$ac_sys_system" in
2446 AIX*) AC_MSG_CHECKING(for genuine AIX C++ extensions support)
Matthias Klosec511b472010-05-08 11:01:39 +00002447 AC_LINK_IFELSE([
Georg Brandl94800df2011-02-25 11:09:02 +00002448 AC_LANG_PROGRAM([[#include <load.h>]],
Matthias Klosec511b472010-05-08 11:01:39 +00002449 [[loadAndInit("", 0, "")]])
2450 ],[
2451 AC_DEFINE(AIX_GENUINE_CPLUSPLUS, 1,
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002452 [Define for AIX if your compiler is a genuine IBM xlC/xlC_r
2453 and you want support for AIX C++ shared extension modules.])
Matthias Klosec511b472010-05-08 11:01:39 +00002454 AC_MSG_RESULT(yes)
2455 ],[
2456 AC_MSG_RESULT(no)
2457 ]);;
Guido van Rossum0eefa3f1999-11-16 15:57:37 +00002458 *) ;;
2459esac
2460
Guido van Rossum70c7f481998-03-26 18:44:10 +00002461# Most SVR4 platforms (e.g. Solaris) need -lsocket and -lnsl.
Guido van Rossumec95c7b1998-08-04 17:59:56 +00002462# BeOS' sockets are stashed in libnet.
Guido van Rossumf618d2c1995-01-17 16:36:13 +00002463AC_CHECK_LIB(nsl, t_open, [LIBS="-lnsl $LIBS"]) # SVR4
Guido van Rossumf618d2c1995-01-17 16:36:13 +00002464AC_CHECK_LIB(socket, socket, [LIBS="-lsocket $LIBS"], [], $LIBS) # SVR4 sockets
Skip Montanarob9949db2004-01-17 04:04:13 +00002465
Jeremy Hyltoncb25d5e2000-07-27 21:23:28 +00002466case "$ac_sys_system" in
2467BeOS*)
Guido van Rossumec95c7b1998-08-04 17:59:56 +00002468AC_CHECK_LIB(net, socket, [LIBS="-lnet $LIBS"], [], $LIBS) # BeOS
2469;;
2470esac
Guido van Rossum70c7f481998-03-26 18:44:10 +00002471
Guido van Rossumc5a39031996-07-31 17:35:03 +00002472AC_MSG_CHECKING(for --with-libs)
Barry Warsawc0d24d82000-06-29 16:12:00 +00002473AC_ARG_WITH(libs,
Matthias Klose22520ea2010-05-08 10:14:46 +00002474 AS_HELP_STRING([--with-libs='lib1 ...'], [link against additional libs]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002475[
Guido van Rossumc5a39031996-07-31 17:35:03 +00002476AC_MSG_RESULT($withval)
2477LIBS="$withval $LIBS"
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002478],
2479[AC_MSG_RESULT(no)])
Guido van Rossum627b2d71993-12-24 10:39:16 +00002480
Benjamin Peterson64e8f6e2014-12-15 00:00:23 -05002481PKG_PROG_PKG_CONFIG
Benjamin Petersone9e07bf2010-03-09 21:46:54 +00002482
Benjamin Peterson2c196742009-12-31 03:17:18 +00002483# Check for use of the system expat library
2484AC_MSG_CHECKING(for --with-system-expat)
2485AC_ARG_WITH(system_expat,
Benjamin Petersonf2d1b2a2010-10-31 16:53:53 +00002486 AS_HELP_STRING([--with-system-expat], [build pyexpat module using an installed expat library]),
2487 [],
2488 [with_system_expat="no"])
Benjamin Peterson2c196742009-12-31 03:17:18 +00002489
2490AC_MSG_RESULT($with_system_expat)
2491
Martin v. Löwis9176fc12006-04-11 11:12:43 +00002492# Check for use of the system libffi library
2493AC_MSG_CHECKING(for --with-system-ffi)
2494AC_ARG_WITH(system_ffi,
Benjamin Petersonf2d1b2a2010-10-31 16:53:53 +00002495 AS_HELP_STRING([--with-system-ffi], [build _ctypes module using an installed ffi library]),
2496 [],
2497 [with_system_ffi="no"])
Martin v. Löwis9176fc12006-04-11 11:12:43 +00002498
Benjamin Petersone9e07bf2010-03-09 21:46:54 +00002499if test "$with_system_ffi" = "yes" && test -n "$PKG_CONFIG"; then
Benjamin Peterson1c335e62010-01-01 15:16:29 +00002500 LIBFFI_INCLUDEDIR="`"$PKG_CONFIG" libffi --cflags-only-I 2>/dev/null | sed -e 's/^-I//;s/ *$//'`"
2501else
2502 LIBFFI_INCLUDEDIR=""
2503fi
2504AC_SUBST(LIBFFI_INCLUDEDIR)
2505
Martin v. Löwis9176fc12006-04-11 11:12:43 +00002506AC_MSG_RESULT($with_system_ffi)
2507
Ned Deilya2a9f572013-10-25 00:30:10 -07002508# Check for --with-tcltk-includes=path and --with-tcltk-libs=path
2509AC_SUBST(TCLTK_INCLUDES)
2510AC_SUBST(TCLTK_LIBS)
2511AC_MSG_CHECKING(for --with-tcltk-includes)
2512AC_ARG_WITH(tcltk-includes,
2513 AS_HELP_STRING([--with-tcltk-includes='-I...'], [override search for Tcl and Tk include files]),
2514 [],
2515 [with_tcltk_includes="default"])
2516AC_MSG_RESULT($with_tcltk_includes)
2517AC_MSG_CHECKING(for --with-tcltk-libs)
2518AC_ARG_WITH(tcltk-libs,
2519 AS_HELP_STRING([--with-tcltk-libs='-L...'], [override search for Tcl and Tk libs]),
2520 [],
2521 [with_tcltk_libs="default"])
2522AC_MSG_RESULT($with_tcltk_libs)
2523if test "x$with_tcltk_includes" = xdefault || test "x$with_tcltk_libs" = xdefault
2524then
2525 if test "x$with_tcltk_includes" != "x$with_tcltk_libs"
2526 then
2527 AC_MSG_ERROR([use both --with-tcltk-includes='...' and --with-tcltk-libs='...' or neither])
2528 fi
2529 TCLTK_INCLUDES=""
2530 TCLTK_LIBS=""
2531else
2532 TCLTK_INCLUDES="$with_tcltk_includes"
2533 TCLTK_LIBS="$with_tcltk_libs"
2534fi
2535
Matthias Klose10cbe482009-04-29 17:18:19 +00002536# Check for --with-dbmliborder
2537AC_MSG_CHECKING(for --with-dbmliborder)
2538AC_ARG_WITH(dbmliborder,
Matthias Klose22520ea2010-05-08 10:14:46 +00002539 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 +00002540[
2541if test x$with_dbmliborder = xyes
2542then
2543AC_MSG_ERROR([proper usage is --with-dbmliborder=db1:db2:...])
2544else
2545 for db in `echo $with_dbmliborder | sed 's/:/ /g'`; do
2546 if test x$db != xndbm && test x$db != xgdbm && test x$db != xbdb
2547 then
2548 AC_MSG_ERROR([proper usage is --with-dbmliborder=db1:db2:...])
2549 fi
2550 done
Matthias Klose61dbdb92009-04-29 20:09:50 +00002551fi])
2552AC_MSG_RESULT($with_dbmliborder)
Matthias Klose10cbe482009-04-29 17:18:19 +00002553
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00002554# Determine if signalmodule should be used.
2555AC_SUBST(USE_SIGNAL_MODULE)
2556AC_SUBST(SIGNAL_OBJS)
2557AC_MSG_CHECKING(for --with-signal-module)
2558AC_ARG_WITH(signal-module,
Matthias Klose22520ea2010-05-08 10:14:46 +00002559 AS_HELP_STRING([--with-signal-module], [disable/enable signal module]))
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00002560
2561if test -z "$with_signal_module"
2562then with_signal_module="yes"
2563fi
2564AC_MSG_RESULT($with_signal_module)
2565
2566if test "${with_signal_module}" = "yes"; then
2567 USE_SIGNAL_MODULE=""
2568 SIGNAL_OBJS=""
2569else
2570 USE_SIGNAL_MODULE="#"
2571 SIGNAL_OBJS="Parser/intrcheck.o Python/sigcheck.o"
2572fi
2573
Guido van Rossum3d15bd82001-01-10 18:53:48 +00002574# This is used to generate Setup.config
Guido van Rossum009f7871997-12-04 00:51:42 +00002575AC_SUBST(USE_THREAD_MODULE)
Barry Warsawc0d24d82000-06-29 16:12:00 +00002576USE_THREAD_MODULE=""
Guido van Rossum009f7871997-12-04 00:51:42 +00002577
Guido van Rossum54d93d41997-01-22 20:51:58 +00002578AC_MSG_CHECKING(for --with-dec-threads)
2579AC_SUBST(LDLAST)
2580AC_ARG_WITH(dec-threads,
Matthias Klose22520ea2010-05-08 10:14:46 +00002581 AS_HELP_STRING([--with-dec-threads], [use DEC Alpha/OSF1 thread-safe libraries]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002582[
Barry Warsawc0d24d82000-06-29 16:12:00 +00002583AC_MSG_RESULT($withval)
Guido van Rossum54d93d41997-01-22 20:51:58 +00002584LDLAST=-threads
Guido van Rossumf78abae1997-01-21 22:02:36 +00002585if test "${with_thread+set}" != set; then
Guido van Rossum54d93d41997-01-22 20:51:58 +00002586 with_thread="$withval";
2587fi],
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002588[AC_MSG_RESULT(no)])
Guido van Rossum54d93d41997-01-22 20:51:58 +00002589
Martin v. Löwis11437992002-04-12 09:54:03 +00002590# Templates for things AC_DEFINEd more than once.
2591# For a single AC_DEFINE, no template is needed.
2592AH_TEMPLATE(C_THREADS,[Define if you have the Mach cthreads package])
2593AH_TEMPLATE(_REENTRANT,
2594 [Define to force use of thread-safe errno, h_errno, and other functions])
2595AH_TEMPLATE(WITH_THREAD,
2596 [Define if you want to compile in rudimentary thread support])
2597
Guido van Rossum54d93d41997-01-22 20:51:58 +00002598AC_MSG_CHECKING(for --with-threads)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002599dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
Barry Warsawc0d24d82000-06-29 16:12:00 +00002600AC_ARG_WITH(threads,
Matthias Klose22520ea2010-05-08 10:14:46 +00002601 AS_HELP_STRING([--with(out)-threads@<:@=DIRECTORY@:>@], [disable/enable thread support]))
Guido van Rossum54d93d41997-01-22 20:51:58 +00002602
Barry Warsawc0d24d82000-06-29 16:12:00 +00002603# --with-thread is deprecated, but check for it anyway
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002604dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
Barry Warsawa0f3c5c2000-06-30 16:39:35 +00002605AC_ARG_WITH(thread,
Matthias Klose22520ea2010-05-08 10:14:46 +00002606 AS_HELP_STRING([--with(out)-thread@<:@=DIRECTORY@:>@], [deprecated; use --with(out)-threads]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002607 [with_threads=$with_thread])
Barry Warsawc0d24d82000-06-29 16:12:00 +00002608
2609if test -z "$with_threads"
2610then with_threads="yes"
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002611fi
Barry Warsawc0d24d82000-06-29 16:12:00 +00002612AC_MSG_RESULT($with_threads)
Guido van Rossum6400c261997-05-22 20:34:27 +00002613
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002614AC_SUBST(THREADOBJ)
Barry Warsawc0d24d82000-06-29 16:12:00 +00002615if test "$with_threads" = "no"
2616then
2617 USE_THREAD_MODULE="#"
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002618elif test "$ac_cv_pthread_is_default" = yes
2619then
2620 AC_DEFINE(WITH_THREAD)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002621 # Defining _REENTRANT on system with POSIX threads should not hurt.
2622 AC_DEFINE(_REENTRANT)
2623 posix_threads=yes
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002624 THREADOBJ="Python/thread.o"
Martin v. Löwis130fb172001-07-19 11:00:41 +00002625elif test "$ac_cv_kpthread" = "yes"
2626then
2627 CC="$CC -Kpthread"
Martin v. Löwis519adae2003-09-20 10:47:47 +00002628 if test "$ac_cv_cxx_thread" = "yes"; then
2629 CXX="$CXX -Kpthread"
2630 fi
Martin v. Löwis130fb172001-07-19 11:00:41 +00002631 AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002632 posix_threads=yes
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002633 THREADOBJ="Python/thread.o"
Martin v. Löwis5f433f02003-05-05 05:05:30 +00002634elif test "$ac_cv_kthread" = "yes"
2635then
2636 CC="$CC -Kthread"
Martin v. Löwis519adae2003-09-20 10:47:47 +00002637 if test "$ac_cv_cxx_thread" = "yes"; then
2638 CXX="$CXX -Kthread"
2639 fi
Martin v. Löwis5f433f02003-05-05 05:05:30 +00002640 AC_DEFINE(WITH_THREAD)
2641 posix_threads=yes
2642 THREADOBJ="Python/thread.o"
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002643elif test "$ac_cv_pthread" = "yes"
2644then
2645 CC="$CC -pthread"
Martin v. Löwis519adae2003-09-20 10:47:47 +00002646 if test "$ac_cv_cxx_thread" = "yes"; then
2647 CXX="$CXX -pthread"
2648 fi
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002649 AC_DEFINE(WITH_THREAD)
2650 posix_threads=yes
2651 THREADOBJ="Python/thread.o"
Barry Warsawc0d24d82000-06-29 16:12:00 +00002652else
Martin v. Löwis130fb172001-07-19 11:00:41 +00002653 if test ! -z "$with_threads" -a -d "$with_threads"
2654 then LDFLAGS="$LDFLAGS -L$with_threads"
2655 fi
2656 if test ! -z "$withval" -a -d "$withval"
2657 then LDFLAGS="$LDFLAGS -L$withval"
2658 fi
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002659
2660 # According to the POSIX spec, a pthreads implementation must
Matthias Klosea2542be2004-08-16 11:35:51 +00002661 # define _POSIX_THREADS in unistd.h. Some apparently don't
2662 # (e.g. gnu pth with pthread emulation)
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002663 AC_MSG_CHECKING(for _POSIX_THREADS in unistd.h)
2664 AC_EGREP_CPP(yes,
Neal Norwitz6eb37f02003-02-23 23:28:15 +00002665 [
2666#include <unistd.h>
2667#ifdef _POSIX_THREADS
2668yes
2669#endif
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002670 ], unistd_defines_pthreads=yes, unistd_defines_pthreads=no)
2671 AC_MSG_RESULT($unistd_defines_pthreads)
2672
Martin v. Löwis130fb172001-07-19 11:00:41 +00002673 AC_DEFINE(_REENTRANT)
Martin v. Löwisa6e97582002-01-01 18:41:33 +00002674 AC_CHECK_HEADER(cthreads.h, [AC_DEFINE(WITH_THREAD)
2675 AC_DEFINE(C_THREADS)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002676 AC_DEFINE(HURD_C_THREADS, 1,
2677 [Define if you are using Mach cthreads directly under /include])
Martin v. Löwisa6e97582002-01-01 18:41:33 +00002678 LIBS="$LIBS -lthreads"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002679 THREADOBJ="Python/thread.o"],[
Martin v. Löwis130fb172001-07-19 11:00:41 +00002680 AC_CHECK_HEADER(mach/cthreads.h, [AC_DEFINE(WITH_THREAD)
2681 AC_DEFINE(C_THREADS)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002682 AC_DEFINE(MACH_C_THREADS, 1,
2683 [Define if you are using Mach cthreads under mach /])
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002684 THREADOBJ="Python/thread.o"],[
Martin v. Löwis130fb172001-07-19 11:00:41 +00002685 AC_MSG_CHECKING(for --with-pth)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002686 AC_ARG_WITH([pth],
Matthias Klose22520ea2010-05-08 10:14:46 +00002687 AS_HELP_STRING([--with-pth], [use GNU pth threading libraries]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002688 [AC_MSG_RESULT($withval)
2689 AC_DEFINE([WITH_THREAD])
2690 AC_DEFINE([HAVE_PTH], 1,
2691 [Define if you have GNU PTH threads.])
2692 LIBS="-lpth $LIBS"
2693 THREADOBJ="Python/thread.o"],
2694 [AC_MSG_RESULT(no)
Martin v. Löwis8158b5a2001-10-08 13:17:28 +00002695
2696 # Just looking for pthread_create in libpthread is not enough:
2697 # on HP/UX, pthread.h renames pthread_create to a different symbol name.
2698 # So we really have to include pthread.h, and then link.
2699 _libs=$LIBS
2700 LIBS="$LIBS -lpthread"
2701 AC_MSG_CHECKING([for pthread_create in -lpthread])
Stefan Krahae66ca62012-11-22 22:36:57 +01002702 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
2703#include <stdio.h>
2704#include <pthread.h>
Martin v. Löwis8158b5a2001-10-08 13:17:28 +00002705
Matthias Klosec511b472010-05-08 11:01:39 +00002706void * start_routine (void *arg) { exit (0); }]], [[
2707pthread_create (NULL, NULL, start_routine, NULL)]])],[
Martin v. Löwis8158b5a2001-10-08 13:17:28 +00002708 AC_MSG_RESULT(yes)
2709 AC_DEFINE(WITH_THREAD)
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002710 posix_threads=yes
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002711 THREADOBJ="Python/thread.o"],[
Martin v. Löwis8158b5a2001-10-08 13:17:28 +00002712 LIBS=$_libs
Martin v. Löwis130fb172001-07-19 11:00:41 +00002713 AC_CHECK_FUNC(pthread_detach, [AC_DEFINE(WITH_THREAD)
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002714 posix_threads=yes
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002715 THREADOBJ="Python/thread.o"],[
Martin v. Löwisf90ae202002-06-11 06:22:31 +00002716 AC_CHECK_HEADER(atheos/threads.h, [AC_DEFINE(WITH_THREAD)
2717 AC_DEFINE(ATHEOS_THREADS, 1,
2718 [Define this if you have AtheOS threads.])
2719 THREADOBJ="Python/thread.o"],[
Martin v. Löwis130fb172001-07-19 11:00:41 +00002720 AC_CHECK_HEADER(kernel/OS.h, [AC_DEFINE(WITH_THREAD)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002721 AC_DEFINE(BEOS_THREADS, 1,
2722 [Define this if you have BeOS threads.])
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002723 THREADOBJ="Python/thread.o"],[
Martin v. Löwis130fb172001-07-19 11:00:41 +00002724 AC_CHECK_LIB(pthreads, pthread_create, [AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002725 posix_threads=yes
Martin v. Löwis130fb172001-07-19 11:00:41 +00002726 LIBS="$LIBS -lpthreads"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002727 THREADOBJ="Python/thread.o"], [
Martin v. Löwis130fb172001-07-19 11:00:41 +00002728 AC_CHECK_LIB(c_r, pthread_create, [AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002729 posix_threads=yes
Martin v. Löwis130fb172001-07-19 11:00:41 +00002730 LIBS="$LIBS -lc_r"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002731 THREADOBJ="Python/thread.o"], [
Martin v. Löwis130fb172001-07-19 11:00:41 +00002732 AC_CHECK_LIB(pthread, __pthread_create_system, [AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002733 posix_threads=yes
Martin v. Löwis130fb172001-07-19 11:00:41 +00002734 LIBS="$LIBS -lpthread"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002735 THREADOBJ="Python/thread.o"], [
Martin v. Löwis130fb172001-07-19 11:00:41 +00002736 AC_CHECK_LIB(cma, pthread_create, [AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002737 posix_threads=yes
Martin v. Löwis130fb172001-07-19 11:00:41 +00002738 LIBS="$LIBS -lcma"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002739 THREADOBJ="Python/thread.o"],[
Martin v. Löwis130fb172001-07-19 11:00:41 +00002740 USE_THREAD_MODULE="#"])
Skip Montanarof8712e52004-01-17 03:04:46 +00002741 ])])])])])])])])])])
Barry Warsawc0d24d82000-06-29 16:12:00 +00002742
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002743 AC_CHECK_LIB(mpc, usconfig, [AC_DEFINE(WITH_THREAD)
2744 LIBS="$LIBS -lmpc"
2745 THREADOBJ="Python/thread.o"
2746 USE_THREAD_MODULE=""])
2747
2748 if test "$posix_threads" != "yes"; then
2749 AC_CHECK_LIB(thread, thr_create, [AC_DEFINE(WITH_THREAD)
2750 LIBS="$LIBS -lthread"
2751 THREADOBJ="Python/thread.o"
2752 USE_THREAD_MODULE=""])
2753 fi
2754
2755 if test "$USE_THREAD_MODULE" != "#"
2756 then
2757 # If the above checks didn't disable threads, (at least) OSF1
2758 # needs this '-threads' argument during linking.
2759 case $ac_sys_system in
2760 OSF1) LDLAST=-threads;;
2761 esac
2762 fi
2763fi
2764
2765if test "$posix_threads" = "yes"; then
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002766 if test "$unistd_defines_pthreads" = "no"; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002767 AC_DEFINE(_POSIX_THREADS, 1,
2768 [Define if you have POSIX threads,
2769 and your system does not define that.])
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002770 fi
2771
Martin v. Löwisdfc33fd2003-01-21 10:14:41 +00002772 # Bug 662787: Using semaphores causes unexplicable hangs on Solaris 8.
2773 case $ac_sys_system/$ac_sys_release in
Charles-François Natali4929eb92011-07-21 19:41:04 +02002774 SunOS/5.6) AC_DEFINE(HAVE_PTHREAD_DESTRUCTOR, 1,
Matthias Klose5183ebd2010-04-24 16:38:36 +00002775 [Defined for Solaris 2.6 bug in pthread header.])
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002776 ;;
Martin v. Löwisdfc33fd2003-01-21 10:14:41 +00002777 SunOS/5.8) AC_DEFINE(HAVE_BROKEN_POSIX_SEMAPHORES, 1,
Matthias Klose5183ebd2010-04-24 16:38:36 +00002778 [Define if the Posix semaphores do not work on your system])
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002779 ;;
Charles-François Natali4929eb92011-07-21 19:41:04 +02002780 AIX/*) AC_DEFINE(HAVE_BROKEN_POSIX_SEMAPHORES, 1,
Matthias Klose5183ebd2010-04-24 16:38:36 +00002781 [Define if the Posix semaphores do not work on your system])
Christian Heimescba36bb2008-01-30 22:54:18 +00002782 ;;
Martin v. Löwisdfc33fd2003-01-21 10:14:41 +00002783 esac
2784
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002785 AC_MSG_CHECKING(if PTHREAD_SCOPE_SYSTEM is supported)
2786 AC_CACHE_VAL(ac_cv_pthread_system_supported,
Stefan Krahae66ca62012-11-22 22:36:57 +01002787 [AC_RUN_IFELSE([AC_LANG_SOURCE([[
2788 #include <stdio.h>
2789 #include <pthread.h>
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002790 void *foo(void *parm) {
2791 return NULL;
2792 }
2793 main() {
2794 pthread_attr_t attr;
Martin v. Löwisa82d3472002-02-24 16:05:05 +00002795 pthread_t id;
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002796 if (pthread_attr_init(&attr)) exit(-1);
2797 if (pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM)) exit(-1);
Martin v. Löwisa82d3472002-02-24 16:05:05 +00002798 if (pthread_create(&id, &attr, foo, NULL)) exit(-1);
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002799 exit(0);
Matthias Klosec511b472010-05-08 11:01:39 +00002800 }]])],
2801 [ac_cv_pthread_system_supported=yes],
2802 [ac_cv_pthread_system_supported=no],
2803 [ac_cv_pthread_system_supported=no])
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002804 ])
2805 AC_MSG_RESULT($ac_cv_pthread_system_supported)
2806 if test "$ac_cv_pthread_system_supported" = "yes"; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002807 AC_DEFINE(PTHREAD_SYSTEM_SCHED_SUPPORTED, 1, [Defined if PTHREAD_SCOPE_SYSTEM supported.])
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002808 fi
Jason Tishlerfac083d2003-07-22 15:20:49 +00002809 AC_CHECK_FUNCS(pthread_sigmask,
2810 [case $ac_sys_system in
2811 CYGWIN*)
2812 AC_DEFINE(HAVE_BROKEN_PTHREAD_SIGMASK, 1,
2813 [Define if pthread_sigmask() does not work on your system.])
2814 ;;
2815 esac])
Christian Heimes0d604cf2013-08-21 13:26:05 +02002816 AC_CHECK_FUNCS(pthread_atfork)
Barry Warsawc0d24d82000-06-29 16:12:00 +00002817fi
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002818
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002819
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002820# Check for enable-ipv6
Martin v. Löwis11437992002-04-12 09:54:03 +00002821AH_TEMPLATE(ENABLE_IPV6, [Define if --enable-ipv6 is specified])
Martin v. Löwisa5f8bb52001-09-05 08:22:34 +00002822AC_MSG_CHECKING([if --enable-ipv6 is specified])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002823AC_ARG_ENABLE(ipv6,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002824[ --enable-ipv6 Enable ipv6 (with ipv4) support
2825 --disable-ipv6 Disable ipv6 support],
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002826[ case "$enableval" in
2827 no)
2828 AC_MSG_RESULT(no)
2829 ipv6=no
2830 ;;
2831 *) AC_MSG_RESULT(yes)
2832 AC_DEFINE(ENABLE_IPV6)
2833 ipv6=yes
2834 ;;
2835 esac ],
2836
Martin v. Löwisa5f8bb52001-09-05 08:22:34 +00002837[
2838dnl the check does not work on cross compilation case...
Charles-François Natalibe2b9072013-01-08 19:47:00 +01002839 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ /* AF_INET6 available check */
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002840#include <sys/types.h>
Charles-François Natalibe2b9072013-01-08 19:47:00 +01002841#include <sys/socket.h>]],
2842[[int domain = AF_INET6;]])],[
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002843 AC_MSG_RESULT(yes)
Matthias Klosec511b472010-05-08 11:01:39 +00002844 ipv6=yes
2845],[
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002846 AC_MSG_RESULT(no)
2847 ipv6=no
Matthias Klosec511b472010-05-08 11:01:39 +00002848])
Martin v. Löwisa5f8bb52001-09-05 08:22:34 +00002849
2850if test "$ipv6" = "yes"; then
2851 AC_MSG_CHECKING(if RFC2553 API is available)
Matthias Klosec511b472010-05-08 11:01:39 +00002852 AC_COMPILE_IFELSE([
2853 AC_LANG_PROGRAM([[#include <sys/types.h>
2854#include <netinet/in.h>]],
2855 [[struct sockaddr_in6 x;
2856 x.sin6_scope_id;]])
2857 ],[
2858 AC_MSG_RESULT(yes)
2859 ipv6=yes
2860 ],[
2861 AC_MSG_RESULT(no, IPv6 disabled)
2862 ipv6=no
2863 ])
Martin v. Löwisa5f8bb52001-09-05 08:22:34 +00002864fi
2865
2866if test "$ipv6" = "yes"; then
2867 AC_DEFINE(ENABLE_IPV6)
2868fi
2869])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002870
2871ipv6type=unknown
2872ipv6lib=none
2873ipv6trylibc=no
2874
2875if test "$ipv6" = "yes"; then
2876 AC_MSG_CHECKING([ipv6 stack type])
Guido van Rossumb8552162001-09-05 14:58:11 +00002877 for i in inria kame linux-glibc linux-inet6 solaris toshiba v6d zeta;
2878 do
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002879 case $i in
2880 inria)
2881 dnl http://www.kame.net/
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002882 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002883#include <netinet/in.h>
2884#ifdef IPV6_INRIA_VERSION
2885yes
2886#endif],
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002887 [ipv6type=$i])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002888 ;;
2889 kame)
2890 dnl http://www.kame.net/
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002891 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002892#include <netinet/in.h>
2893#ifdef __KAME__
2894yes
2895#endif],
2896 [ipv6type=$i;
2897 ipv6lib=inet6
2898 ipv6libdir=/usr/local/v6/lib
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002899 ipv6trylibc=yes])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002900 ;;
2901 linux-glibc)
2902 dnl http://www.v6.linux.or.jp/
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002903 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002904#include <features.h>
2905#if defined(__GLIBC__) && ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1) || (__GLIBC__ > 2))
2906yes
2907#endif],
2908 [ipv6type=$i;
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002909 ipv6trylibc=yes])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002910 ;;
2911 linux-inet6)
2912 dnl http://www.v6.linux.or.jp/
2913 if test -d /usr/inet6; then
2914 ipv6type=$i
2915 ipv6lib=inet6
2916 ipv6libdir=/usr/inet6/lib
Skip Montanarodecc6a42003-01-01 20:07:49 +00002917 BASECFLAGS="-I/usr/inet6/include $BASECFLAGS"
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002918 fi
2919 ;;
2920 solaris)
2921 if test -f /etc/netconfig; then
Antoine Pitrou31e85952011-01-03 18:57:14 +00002922 if $GREP -q tcp6 /etc/netconfig; then
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002923 ipv6type=$i
2924 ipv6trylibc=yes
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002925 fi
2926 fi
2927 ;;
2928 toshiba)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002929 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002930#include <sys/param.h>
2931#ifdef _TOSHIBA_INET6
2932yes
2933#endif],
2934 [ipv6type=$i;
2935 ipv6lib=inet6;
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002936 ipv6libdir=/usr/local/v6/lib])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002937 ;;
2938 v6d)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002939 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002940#include </usr/local/v6/include/sys/v6config.h>
2941#ifdef __V6D__
2942yes
2943#endif],
2944 [ipv6type=$i;
2945 ipv6lib=v6;
2946 ipv6libdir=/usr/local/v6/lib;
Skip Montanarodecc6a42003-01-01 20:07:49 +00002947 BASECFLAGS="-I/usr/local/v6/include $BASECFLAGS"])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002948 ;;
2949 zeta)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002950 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002951#include <sys/param.h>
2952#ifdef _ZETA_MINAMI_INET6
2953yes
2954#endif],
2955 [ipv6type=$i;
2956 ipv6lib=inet6;
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002957 ipv6libdir=/usr/local/v6/lib])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002958 ;;
2959 esac
2960 if test "$ipv6type" != "unknown"; then
2961 break
2962 fi
2963 done
2964 AC_MSG_RESULT($ipv6type)
2965fi
2966
2967if test "$ipv6" = "yes" -a "$ipv6lib" != "none"; then
2968 if test -d $ipv6libdir -a -f $ipv6libdir/lib$ipv6lib.a; then
2969 LIBS="-L$ipv6libdir -l$ipv6lib $LIBS"
2970 echo "using lib$ipv6lib"
2971 else
2972 if test $ipv6trylibc = "yes"; then
2973 echo "using libc"
2974 else
2975 echo 'Fatal: no $ipv6lib library found. cannot continue.'
2976 echo "You need to fetch lib$ipv6lib.a from appropriate"
2977 echo 'ipv6 kit and compile beforehand.'
2978 exit 1
2979 fi
2980 fi
2981fi
2982
Ronald Oussoren0d236eb2008-06-06 21:31:33 +00002983AC_MSG_CHECKING(for OSX 10.5 SDK or later)
Matthias Klosec511b472010-05-08 11:01:39 +00002984AC_COMPILE_IFELSE([
Mark Dickinson0712b562010-05-08 19:13:21 +00002985 AC_LANG_PROGRAM([[#include <Carbon/Carbon.h>]], [[FSIORefNum fRef = 0]])
Matthias Klosec511b472010-05-08 11:01:39 +00002986],[
Matthias Klose5183ebd2010-04-24 16:38:36 +00002987 AC_DEFINE(HAVE_OSX105_SDK, 1, [Define if compiling using MacOS X 10.5 SDK or later.])
Matthias Klosec511b472010-05-08 11:01:39 +00002988 AC_MSG_RESULT(yes)
2989],[
Ronald Oussoren0d236eb2008-06-06 21:31:33 +00002990 AC_MSG_RESULT(no)
Matthias Klosec511b472010-05-08 11:01:39 +00002991])
Ronald Oussoren0d236eb2008-06-06 21:31:33 +00002992
Martin v. Löwisa3fb4f72002-06-09 13:33:54 +00002993# Check for --with-doc-strings
2994AC_MSG_CHECKING(for --with-doc-strings)
2995AC_ARG_WITH(doc-strings,
Matthias Klose22520ea2010-05-08 10:14:46 +00002996 AS_HELP_STRING([--with(out)-doc-strings], [disable/enable documentation strings]))
Martin v. Löwisa3fb4f72002-06-09 13:33:54 +00002997
2998if test -z "$with_doc_strings"
2999then with_doc_strings="yes"
3000fi
3001if test "$with_doc_strings" != "no"
3002then
3003 AC_DEFINE(WITH_DOC_STRINGS, 1,
3004 [Define if you want documentation strings in extension modules])
3005fi
3006AC_MSG_RESULT($with_doc_strings)
3007
Neil Schemenauera35c6882001-02-27 04:45:05 +00003008# Check for Python-specific malloc support
Martin v. Löwisf30d60e2004-06-08 08:17:44 +00003009AC_MSG_CHECKING(for --with-tsc)
3010AC_ARG_WITH(tsc,
Matthias Klose22520ea2010-05-08 10:14:46 +00003011 AS_HELP_STRING([--with(out)-tsc],[enable/disable timestamp counter profile]),[
Martin v. Löwisf30d60e2004-06-08 08:17:44 +00003012if test "$withval" != no
3013then
3014 AC_DEFINE(WITH_TSC, 1,
3015 [Define to profile with the Pentium timestamp counter])
3016 AC_MSG_RESULT(yes)
3017else AC_MSG_RESULT(no)
3018fi],
3019[AC_MSG_RESULT(no)])
3020
3021# Check for Python-specific malloc support
Neil Schemenauera35c6882001-02-27 04:45:05 +00003022AC_MSG_CHECKING(for --with-pymalloc)
3023AC_ARG_WITH(pymalloc,
Matthias Klose22520ea2010-05-08 10:14:46 +00003024 AS_HELP_STRING([--with(out)-pymalloc], [disable/enable specialized mallocs]))
Neil Schemenauer16c22972002-03-22 15:34:49 +00003025
3026if test -z "$with_pymalloc"
3027then with_pymalloc="yes"
3028fi
3029if test "$with_pymalloc" != "no"
3030then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003031 AC_DEFINE(WITH_PYMALLOC, 1,
3032 [Define if you want to compile in Python-specific mallocs])
Neil Schemenauer16c22972002-03-22 15:34:49 +00003033fi
3034AC_MSG_RESULT($with_pymalloc)
Neil Schemenauera35c6882001-02-27 04:45:05 +00003035
Benjamin Peterson91c12eb2009-12-03 02:52:39 +00003036# Check for Valgrind support
3037AC_MSG_CHECKING([for --with-valgrind])
3038AC_ARG_WITH([valgrind],
Matthias Klose22520ea2010-05-08 10:14:46 +00003039 AS_HELP_STRING([--with-valgrind], [Enable Valgrind support]),,
Benjamin Peterson91c12eb2009-12-03 02:52:39 +00003040 with_valgrind=no)
3041AC_MSG_RESULT([$with_valgrind])
3042if test "$with_valgrind" != no; then
3043 AC_CHECK_HEADER([valgrind/valgrind.h],
3044 [AC_DEFINE([WITH_VALGRIND], 1, [Define if you want pymalloc to be disabled when running under valgrind])],
3045 [AC_MSG_ERROR([Valgrind support requested but headers not available])]
3046 )
3047fi
3048
Barry Warsawef82cd72000-06-30 16:21:01 +00003049# Check for --with-wctype-functions
3050AC_MSG_CHECKING(for --with-wctype-functions)
3051AC_ARG_WITH(wctype-functions,
Matthias Klose22520ea2010-05-08 10:14:46 +00003052 AS_HELP_STRING([--with-wctype-functions], [use wctype.h functions]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003053[
Barry Warsawef82cd72000-06-30 16:21:01 +00003054if test "$withval" != no
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003055then
3056 AC_DEFINE(WANT_WCTYPE_FUNCTIONS, 1,
3057 [Define if you want wctype.h functions to be used instead of the
3058 one supplied by Python itself. (see Include/unicodectype.h).])
3059 AC_MSG_RESULT(yes)
Barry Warsawef82cd72000-06-30 16:21:01 +00003060else AC_MSG_RESULT(no)
3061fi],
3062[AC_MSG_RESULT(no)])
3063
Guido van Rossum68242b51996-05-28 22:53:03 +00003064# -I${DLINCLDIR} is added to the compile rule for importdl.o
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003065AC_SUBST(DLINCLDIR)
Guido van Rossum98935bf2001-09-05 19:13:16 +00003066DLINCLDIR=.
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003067
Guido van Rossume97ee181999-12-20 21:27:22 +00003068# the dlopen() function means we might want to use dynload_shlib.o. some
3069# platforms, such as AIX, have dlopen(), but don't want to use it.
Thomas Wouters3a584202000-08-05 23:28:51 +00003070AC_CHECK_FUNCS(dlopen)
Guido van Rossume97ee181999-12-20 21:27:22 +00003071
3072# DYNLOADFILE specifies which dynload_*.o file we will use for dynamic
3073# loading of modules.
3074AC_SUBST(DYNLOADFILE)
3075AC_MSG_CHECKING(DYNLOADFILE)
3076if test -z "$DYNLOADFILE"
3077then
3078 case $ac_sys_system/$ac_sys_release in
Martin v. Löwisc19c5a62003-11-18 20:00:44 +00003079 AIX*) # Use dynload_shlib.c and dlopen() if we have it; otherwise dynload_aix.c
3080 if test "$ac_cv_func_dlopen" = yes
3081 then DYNLOADFILE="dynload_shlib.o"
3082 else DYNLOADFILE="dynload_aix.o"
3083 fi
3084 ;;
Guido van Rossume97ee181999-12-20 21:27:22 +00003085 BeOS*) DYNLOADFILE="dynload_beos.o";;
3086 hp*|HP*) DYNLOADFILE="dynload_hpux.o";;
Anthony Baxter82201742006-04-09 15:07:40 +00003087 # Use dynload_next.c only on 10.2 and below, which don't have native dlopen()
3088 Darwin/@<:@0156@:>@\..*) DYNLOADFILE="dynload_next.o";;
Martin v. Löwisf90ae202002-06-11 06:22:31 +00003089 atheos*) DYNLOADFILE="dynload_atheos.o";;
Guido van Rossume97ee181999-12-20 21:27:22 +00003090 *)
3091 # use dynload_shlib.c and dlopen() if we have it; otherwise stub
3092 # out any dynamic loading
3093 if test "$ac_cv_func_dlopen" = yes
3094 then DYNLOADFILE="dynload_shlib.o"
3095 else DYNLOADFILE="dynload_stub.o"
3096 fi
3097 ;;
3098 esac
3099fi
3100AC_MSG_RESULT($DYNLOADFILE)
3101if test "$DYNLOADFILE" != "dynload_stub.o"
3102then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003103 AC_DEFINE(HAVE_DYNAMIC_LOADING, 1,
3104 [Defined when any dynamic module loading is enabled.])
Guido van Rossume97ee181999-12-20 21:27:22 +00003105fi
3106
Jack Jansenc49e5b72001-06-19 15:00:23 +00003107# MACHDEP_OBJS can be set to platform-specific object files needed by Python
3108
3109AC_SUBST(MACHDEP_OBJS)
3110AC_MSG_CHECKING(MACHDEP_OBJS)
3111if test -z "$MACHDEP_OBJS"
3112then
Jack Jansenb6e9cad2001-08-15 01:26:28 +00003113 MACHDEP_OBJS=$extra_machdep_objs
3114else
3115 MACHDEP_OBJS="$MACHDEP_OBJS $extra_machdep_objs"
Jack Jansenc49e5b72001-06-19 15:00:23 +00003116fi
Jack Jansenb6e9cad2001-08-15 01:26:28 +00003117AC_MSG_RESULT(MACHDEP_OBJS)
Jack Jansenc49e5b72001-06-19 15:00:23 +00003118
Guido van Rossum627b2d71993-12-24 10:39:16 +00003119# checks for library functions
Martin v. Löwisaef18b12008-03-24 13:31:16 +00003120AC_CHECK_FUNCS(alarm setitimer getitimer bind_textdomain_codeset chown \
3121 clock confstr ctermid execv fchmod fchown fork fpathconf ftime ftruncate \
Martin v. Löwis438b5342002-12-27 10:16:42 +00003122 gai_strerror getgroups getlogin getloadavg getpeername getpgid getpid \
Benjamin Peterson27c269a2014-12-26 11:09:00 -06003123 getentropy \
Martin v. Löwis50ea4562009-11-27 13:56:01 +00003124 getpriority getresuid getresgid getpwent getspnam getspent getsid getwd \
Benjamin Petersond16e01c2014-02-04 10:20:26 -05003125 initgroups kill killpg lchmod lchown lstat mkfifo mknod mktime mmap \
Martin v. Löwisa5f09072002-10-11 05:37:59 +00003126 mremap nice pathconf pause plock poll pthread_init \
Guido van Rossum162e38c2003-02-19 15:25:10 +00003127 putenv readlink realpath \
Jesse Noller355b1262009-04-02 00:03:28 +00003128 select sem_open sem_timedwait sem_getvalue sem_unlink setegid seteuid \
3129 setgid \
Martin v. Löwis4daacb12003-03-28 18:37:01 +00003130 setlocale setregid setreuid setsid setpgid setpgrp setuid setvbuf snprintf \
Martin v. Löwis50ea4562009-11-27 13:56:01 +00003131 setlocale setregid setreuid setresuid setresgid \
3132 setsid setpgid setpgrp setuid setvbuf snprintf \
Skip Montanaro7e11a012004-02-07 12:55:46 +00003133 sigaction siginterrupt sigrelse strftime \
Michael W. Hudson34f20ea2002-05-27 15:08:24 +00003134 sysconf tcgetpgrp tcsetpgrp tempnam timegm times tmpfile tmpnam tmpnam_r \
Neal Norwitz05a45592006-03-20 06:30:08 +00003135 truncate uname unsetenv utimes waitpid wait3 wait4 wcscoll _getpty)
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00003136
Martin v. Löwisc8ad7cc2002-11-11 13:23:45 +00003137# For some functions, having a definition is not sufficient, since
3138# we want to take their address.
3139AC_MSG_CHECKING(for chroot)
Matthias Klosec511b472010-05-08 11:01:39 +00003140AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[void *x=chroot]])],
3141 [AC_DEFINE(HAVE_CHROOT, 1, Define if you have the 'chroot' function.)
3142 AC_MSG_RESULT(yes)],
3143 [AC_MSG_RESULT(no)
3144])
Martin v. Löwisc8ad7cc2002-11-11 13:23:45 +00003145AC_MSG_CHECKING(for link)
Matthias Klosec511b472010-05-08 11:01:39 +00003146AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[void *x=link]])],
3147 [AC_DEFINE(HAVE_LINK, 1, Define if you have the 'link' function.)
3148 AC_MSG_RESULT(yes)],
3149 [AC_MSG_RESULT(no)
3150])
Martin v. Löwisc8ad7cc2002-11-11 13:23:45 +00003151AC_MSG_CHECKING(for symlink)
Matthias Klosec511b472010-05-08 11:01:39 +00003152AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[void *x=symlink]])],
3153 [AC_DEFINE(HAVE_SYMLINK, 1, Define if you have the 'symlink' function.)
3154 AC_MSG_RESULT(yes)],
3155 [AC_MSG_RESULT(no)
3156])
Martin v. Löwisa64988c2003-09-20 15:30:20 +00003157AC_MSG_CHECKING(for fchdir)
Matthias Klosec511b472010-05-08 11:01:39 +00003158AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[void *x=fchdir]])],
3159 [AC_DEFINE(HAVE_FCHDIR, 1, Define if you have the 'fchdir' function.)
3160 AC_MSG_RESULT(yes)],
3161 [AC_MSG_RESULT(no)
3162])
Martin v. Löwisa64988c2003-09-20 15:30:20 +00003163AC_MSG_CHECKING(for fsync)
Matthias Klosec511b472010-05-08 11:01:39 +00003164AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[void *x=fsync]])],
3165 [AC_DEFINE(HAVE_FSYNC, 1, Define if you have the 'fsync' function.)
3166 AC_MSG_RESULT(yes)],
3167 [AC_MSG_RESULT(no)
3168])
Martin v. Löwisa64988c2003-09-20 15:30:20 +00003169AC_MSG_CHECKING(for fdatasync)
Matthias Klosec511b472010-05-08 11:01:39 +00003170AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[void *x=fdatasync]])],
3171 [AC_DEFINE(HAVE_FDATASYNC, 1, Define if you have the 'fdatasync' function.)
3172 AC_MSG_RESULT(yes)],
3173 [AC_MSG_RESULT(no)
3174])
Christian Heimes0e9ab5f2008-03-21 23:49:44 +00003175AC_MSG_CHECKING(for epoll)
Matthias Klosec511b472010-05-08 11:01:39 +00003176AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/epoll.h>]], [[void *x=epoll_create]])],
3177 [AC_DEFINE(HAVE_EPOLL, 1, Define if you have the 'epoll' functions.)
3178 AC_MSG_RESULT(yes)],
3179 [AC_MSG_RESULT(no)
3180])
Christian Heimes0e9ab5f2008-03-21 23:49:44 +00003181AC_MSG_CHECKING(for kqueue)
Matthias Klosec511b472010-05-08 11:01:39 +00003182AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Christian Heimes0e9ab5f2008-03-21 23:49:44 +00003183#include <sys/types.h>
3184#include <sys/event.h>
Matthias Klosec511b472010-05-08 11:01:39 +00003185 ]], [[int x=kqueue()]])],
3186 [AC_DEFINE(HAVE_KQUEUE, 1, Define if you have the 'kqueue' functions.)
3187 AC_MSG_RESULT(yes)],
3188 [AC_MSG_RESULT(no)
3189])
Martin v. Löwisd5843682002-11-21 20:41:28 +00003190# On some systems (eg. FreeBSD 5), we would find a definition of the
3191# functions ctermid_r, setgroups in the library, but no prototype
3192# (e.g. because we use _XOPEN_SOURCE). See whether we can take their
3193# address to avoid compiler warnings and potential miscompilations
3194# because of the missing prototypes.
3195
3196AC_MSG_CHECKING(for ctermid_r)
Matthias Klosec511b472010-05-08 11:01:39 +00003197AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwisd5843682002-11-21 20:41:28 +00003198#include <stdio.h>
Matthias Klosec511b472010-05-08 11:01:39 +00003199]], [[void* p = ctermid_r]])],
3200 [AC_DEFINE(HAVE_CTERMID_R, 1, Define if you have the 'ctermid_r' function.)
3201 AC_MSG_RESULT(yes)],
3202 [AC_MSG_RESULT(no)
3203])
Martin v. Löwisd5843682002-11-21 20:41:28 +00003204
Antoine Pitroub170f172010-09-10 18:47:36 +00003205AC_CACHE_CHECK([for flock declaration], [ac_cv_flock_decl],
3206 [AC_COMPILE_IFELSE(
3207 [AC_LANG_PROGRAM(
3208 [#include <sys/file.h>],
3209 [void* p = flock]
3210 )],
3211 [ac_cv_flock_decl=yes],
3212 [ac_cv_flock_decl=no]
3213 )
Matthias Klosec511b472010-05-08 11:01:39 +00003214])
Antoine Pitroub170f172010-09-10 18:47:36 +00003215if test "x${ac_cv_flock_decl}" = xyes; then
3216 AC_CHECK_FUNCS(flock,,
3217 AC_CHECK_LIB(bsd,flock,
3218 [AC_DEFINE(HAVE_FLOCK)
3219 AC_DEFINE(FLOCK_NEEDS_LIBBSD, 1, Define if flock needs to be linked with bsd library.)
3220 ])
3221 )
Antoine Pitrou85729812010-09-07 14:55:24 +00003222fi
Martin v. Löwisf26d63b2003-03-30 17:23:49 +00003223
3224AC_MSG_CHECKING(for getpagesize)
Matthias Klosec511b472010-05-08 11:01:39 +00003225AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwisf26d63b2003-03-30 17:23:49 +00003226#include <unistd.h>
Matthias Klosec511b472010-05-08 11:01:39 +00003227]], [[void* p = getpagesize]])],
3228 [AC_DEFINE(HAVE_GETPAGESIZE, 1, Define if you have the 'getpagesize' function.)
3229 AC_MSG_RESULT(yes)],
3230 [AC_MSG_RESULT(no)
3231])
Martin v. Löwisf26d63b2003-03-30 17:23:49 +00003232
Charles-François Natali93a11752011-11-27 13:01:35 +01003233AC_MSG_CHECKING(for broken unsetenv)
3234AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3235#include <stdlib.h>
3236]], [[int res = unsetenv("DUMMY")]])],
3237 [AC_MSG_RESULT(no)],
3238 [AC_DEFINE(HAVE_BROKEN_UNSETENV, 1, Define if `unsetenv` does not return an int.)
3239 AC_MSG_RESULT(yes)
3240])
3241
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00003242dnl check for true
3243AC_CHECK_PROGS(TRUE, true, /bin/true)
3244
Martin v. Löwis95c419b2003-05-03 12:10:48 +00003245dnl On some systems (e.g. Solaris 9), hstrerror and inet_aton are in -lresolv
3246dnl On others, they are in the C library, so we to take no action
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00003247AC_CHECK_LIB(c, inet_aton, [$ac_cv_prog_TRUE],
Martin v. Löwis95c419b2003-05-03 12:10:48 +00003248 AC_CHECK_LIB(resolv, inet_aton)
3249)
3250
Martin v. Löwisa51d5c82007-12-04 08:37:59 +00003251# On Tru64, chflags seems to be present, but calling it will
3252# exit Python
Gregory P. Smithbb213892009-11-02 01:37:37 +00003253AC_CACHE_CHECK([for chflags], [ac_cv_have_chflags], [dnl
Ned Deily43e10542011-06-27 23:41:53 -07003254AC_RUN_IFELSE([AC_LANG_SOURCE([[
Martin v. Löwisa51d5c82007-12-04 08:37:59 +00003255#include <sys/stat.h>
3256#include <unistd.h>
3257int main(int argc, char*argv[])
3258{
3259 if(chflags(argv[0], 0) != 0)
3260 return 1;
3261 return 0;
3262}
Ned Deily43e10542011-06-27 23:41:53 -07003263]])],
Matthias Klosec511b472010-05-08 11:01:39 +00003264[ac_cv_have_chflags=yes],
3265[ac_cv_have_chflags=no],
3266[ac_cv_have_chflags=cross])
Gregory P. Smithbb213892009-11-02 01:37:37 +00003267])
3268if test "$ac_cv_have_chflags" = cross ; then
3269 AC_CHECK_FUNC([chflags], [ac_cv_have_chflags="yes"], [ac_cv_have_chflags="no"])
3270fi
3271if test "$ac_cv_have_chflags" = yes ; then
Ned Deily43e10542011-06-27 23:41:53 -07003272 AC_DEFINE(HAVE_CHFLAGS, 1, [Define to 1 if you have the 'chflags' function.])
Alexandre Vassalotti00900892009-07-17 05:26:39 +00003273fi
Martin v. Löwisa51d5c82007-12-04 08:37:59 +00003274
Gregory P. Smithbb213892009-11-02 01:37:37 +00003275AC_CACHE_CHECK([for lchflags], [ac_cv_have_lchflags], [dnl
Ned Deily43e10542011-06-27 23:41:53 -07003276AC_RUN_IFELSE([AC_LANG_SOURCE([[
Martin v. Löwisa51d5c82007-12-04 08:37:59 +00003277#include <sys/stat.h>
3278#include <unistd.h>
3279int main(int argc, char*argv[])
3280{
3281 if(lchflags(argv[0], 0) != 0)
3282 return 1;
3283 return 0;
3284}
Ned Deily43e10542011-06-27 23:41:53 -07003285]])],[ac_cv_have_lchflags=yes],[ac_cv_have_lchflags=no],[ac_cv_have_lchflags=cross])
Gregory P. Smithbb213892009-11-02 01:37:37 +00003286])
3287if test "$ac_cv_have_lchflags" = cross ; then
3288 AC_CHECK_FUNC([lchflags], [ac_cv_have_lchflags="yes"], [ac_cv_have_lchflags="no"])
3289fi
3290if test "$ac_cv_have_lchflags" = yes ; then
Ned Deily43e10542011-06-27 23:41:53 -07003291 AC_DEFINE(HAVE_LCHFLAGS, 1, [Define to 1 if you have the 'lchflags' function.])
Alexandre Vassalotti00900892009-07-17 05:26:39 +00003292fi
Martin v. Löwisa51d5c82007-12-04 08:37:59 +00003293
Neal Norwitz6e73aaa2006-06-12 03:33:09 +00003294dnl Check if system zlib has *Copy() functions
Ronald Oussorenf8752642006-07-06 10:13:35 +00003295dnl
3296dnl On MacOSX the linker will search for dylibs on the entire linker path
3297dnl before searching for static libraries. setup.py adds -Wl,-search_paths_first
3298dnl to revert to a more traditional unix behaviour and make it possible to
3299dnl override the system libz with a local static library of libz. Temporarily
3300dnl add that flag to our CFLAGS as well to ensure that we check the version
3301dnl of libz that will be used by setup.py.
3302dnl The -L/usr/local/lib is needed as wel to get the same compilation
3303dnl environment as setup.py (and leaving it out can cause configure to use the
3304dnl wrong version of the library)
3305case $ac_sys_system/$ac_sys_release in
3306Darwin/*)
3307 _CUR_CFLAGS="${CFLAGS}"
3308 _CUR_LDFLAGS="${LDFLAGS}"
3309 CFLAGS="${CFLAGS} -Wl,-search_paths_first"
3310 LDFLAGS="${LDFLAGS} -Wl,-search_paths_first -L/usr/local/lib"
3311 ;;
3312esac
3313
Matthias Klose5183ebd2010-04-24 16:38:36 +00003314AC_CHECK_LIB(z, inflateCopy, AC_DEFINE(HAVE_ZLIB_COPY, 1, [Define if the zlib library has inflateCopy]))
Neal Norwitz6e73aaa2006-06-12 03:33:09 +00003315
Ronald Oussorenf8752642006-07-06 10:13:35 +00003316case $ac_sys_system/$ac_sys_release in
3317Darwin/*)
3318 CFLAGS="${_CUR_CFLAGS}"
3319 LDFLAGS="${_CUR_LDFLAGS}"
3320 ;;
3321esac
3322
Martin v. Löwise9416172003-05-03 10:12:45 +00003323AC_MSG_CHECKING(for hstrerror)
Matthias Klosec511b472010-05-08 11:01:39 +00003324AC_LINK_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwise9416172003-05-03 10:12:45 +00003325#include <netdb.h>
Matthias Klosec511b472010-05-08 11:01:39 +00003326]], [[void* p = hstrerror; hstrerror(0)]])],
3327 [AC_DEFINE(HAVE_HSTRERROR, 1, Define if you have the 'hstrerror' function.)
3328 AC_MSG_RESULT(yes)],
3329 [AC_MSG_RESULT(no)
3330])
Martin v. Löwise9416172003-05-03 10:12:45 +00003331
3332AC_MSG_CHECKING(for inet_aton)
Matthias Klosec511b472010-05-08 11:01:39 +00003333AC_LINK_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwis86d66262006-02-17 08:40:11 +00003334#include <sys/types.h>
Martin v. Löwise9416172003-05-03 10:12:45 +00003335#include <sys/socket.h>
3336#include <netinet/in.h>
3337#include <arpa/inet.h>
Matthias Klosec511b472010-05-08 11:01:39 +00003338]], [[void* p = inet_aton;inet_aton(0,0)]])],
3339 [AC_DEFINE(HAVE_INET_ATON, 1, Define if you have the 'inet_aton' function.)
3340 AC_MSG_RESULT(yes)],
3341 [AC_MSG_RESULT(no)
3342])
Martin v. Löwise9416172003-05-03 10:12:45 +00003343
3344AC_MSG_CHECKING(for inet_pton)
Matthias Klosec511b472010-05-08 11:01:39 +00003345AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwisf2e488d2003-05-05 22:00:11 +00003346#include <sys/types.h>
Martin v. Löwise9416172003-05-03 10:12:45 +00003347#include <sys/socket.h>
3348#include <netinet/in.h>
3349#include <arpa/inet.h>
Matthias Klosec511b472010-05-08 11:01:39 +00003350]], [[void* p = inet_pton]])],
3351 [AC_DEFINE(HAVE_INET_PTON, 1, Define if you have the 'inet_pton' function.)
3352 AC_MSG_RESULT(yes)],
3353 [AC_MSG_RESULT(no)
3354])
Martin v. Löwise9416172003-05-03 10:12:45 +00003355
Martin v. Löwisd6640d42003-07-06 09:29:52 +00003356# On some systems, setgroups is in unistd.h, on others, in grp.h
Martin v. Löwisd5843682002-11-21 20:41:28 +00003357AC_MSG_CHECKING(for setgroups)
Matthias Klosec511b472010-05-08 11:01:39 +00003358AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwisf2e488d2003-05-05 22:00:11 +00003359#include <unistd.h>
Martin v. Löwisd6640d42003-07-06 09:29:52 +00003360#ifdef HAVE_GRP_H
3361#include <grp.h>
3362#endif
Matthias Klosec511b472010-05-08 11:01:39 +00003363]], [[void* p = setgroups]])],
3364 [AC_DEFINE(HAVE_SETGROUPS, 1, Define if you have the 'setgroups' function.)
3365 AC_MSG_RESULT(yes)],
3366 [AC_MSG_RESULT(no)
3367])
Martin v. Löwisd5843682002-11-21 20:41:28 +00003368
Fred Drake8cef4cf2000-06-28 16:40:38 +00003369# check for openpty and forkpty
3370
Martin v. Löwisfd9a72a2006-01-08 10:07:33 +00003371AC_CHECK_FUNCS(openpty,,
3372 AC_CHECK_LIB(util,openpty,
3373 [AC_DEFINE(HAVE_OPENPTY) LIBS="$LIBS -lutil"],
3374 AC_CHECK_LIB(bsd,openpty, [AC_DEFINE(HAVE_OPENPTY) LIBS="$LIBS -lbsd"])
3375 )
3376)
3377AC_CHECK_FUNCS(forkpty,,
3378 AC_CHECK_LIB(util,forkpty,
3379 [AC_DEFINE(HAVE_FORKPTY) LIBS="$LIBS -lutil"],
3380 AC_CHECK_LIB(bsd,forkpty, [AC_DEFINE(HAVE_FORKPTY) LIBS="$LIBS -lbsd"])
3381 )
3382)
Fred Drake8cef4cf2000-06-28 16:40:38 +00003383
Brett Cannonaa5778d2008-03-18 04:09:00 +00003384# Stuff for expat.
3385AC_CHECK_FUNCS(memmove)
3386
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00003387# check for long file support functions
3388AC_CHECK_FUNCS(fseek64 fseeko fstatvfs ftell64 ftello statvfs)
3389
Brett Cannonaa5778d2008-03-18 04:09:00 +00003390AC_REPLACE_FUNCS(dup2 getcwd strdup)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003391AC_CHECK_FUNCS(getpgrp,
Matthias Klosec511b472010-05-08 11:01:39 +00003392 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[getpgrp(0);]])],
3393 [AC_DEFINE(GETPGRP_HAVE_ARG, 1, [Define if getpgrp() must be called as getpgrp(0).])],
3394 [])
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003395)
Jack Jansen150753c2003-03-29 22:07:47 +00003396AC_CHECK_FUNCS(setpgrp,
Matthias Klosec511b472010-05-08 11:01:39 +00003397 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[setpgrp(0,0);]])],
3398 [AC_DEFINE(SETPGRP_HAVE_ARG, 1, [Define if setpgrp() must be called as setpgrp(0, 0).])],
3399 [])
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003400)
3401AC_CHECK_FUNCS(gettimeofday,
Matthias Klosec511b472010-05-08 11:01:39 +00003402 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/time.h>]],
3403 [[gettimeofday((struct timeval*)0,(struct timezone*)0);]])],
3404 [],
3405 [AC_DEFINE(GETTIMEOFDAY_NO_TZ, 1,
3406 [Define if gettimeofday() does not have second (timezone) argument
3407 This is the case on Motorola V4 (R40V4.2)])
3408 ])
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003409)
Guido van Rossum627b2d71993-12-24 10:39:16 +00003410
Martin v. Löwisdbe3f762002-10-10 14:27:30 +00003411AC_MSG_CHECKING(for major, minor, and makedev)
Matthias Klosec511b472010-05-08 11:01:39 +00003412AC_LINK_IFELSE([AC_LANG_PROGRAM([[
Neal Norwitz6eb37f02003-02-23 23:28:15 +00003413#if defined(MAJOR_IN_MKDEV)
3414#include <sys/mkdev.h>
3415#elif defined(MAJOR_IN_SYSMACROS)
3416#include <sys/sysmacros.h>
3417#else
3418#include <sys/types.h>
3419#endif
Matthias Klosec511b472010-05-08 11:01:39 +00003420]], [[
Martin v. Löwisdbe3f762002-10-10 14:27:30 +00003421 makedev(major(0),minor(0));
Matthias Klosec511b472010-05-08 11:01:39 +00003422]])],[
Martin v. Löwisdbe3f762002-10-10 14:27:30 +00003423 AC_DEFINE(HAVE_DEVICE_MACROS, 1,
3424 [Define to 1 if you have the device macros.])
3425 AC_MSG_RESULT(yes)
3426],[
3427 AC_MSG_RESULT(no)
3428])
Martin v. Löwis861a65b2001-10-24 14:36:00 +00003429
3430# On OSF/1 V5.1, getaddrinfo is available, but a define
3431# for [no]getaddrinfo in netdb.h.
3432AC_MSG_CHECKING(for getaddrinfo)
Matthias Klosec511b472010-05-08 11:01:39 +00003433AC_LINK_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwisc010b6d2001-11-09 17:50:52 +00003434#include <sys/types.h>
Martin v. Löwis861a65b2001-10-24 14:36:00 +00003435#include <sys/socket.h>
3436#include <netdb.h>
Martin v. Löwisc010b6d2001-11-09 17:50:52 +00003437#include <stdio.h>
Matthias Klosec511b472010-05-08 11:01:39 +00003438]], [[getaddrinfo(NULL, NULL, NULL, NULL);]])],
3439[have_getaddrinfo=yes],
3440[have_getaddrinfo=no])
Alexandre Vassalotti00900892009-07-17 05:26:39 +00003441AC_MSG_RESULT($have_getaddrinfo)
3442if test $have_getaddrinfo = yes
3443then
3444 AC_MSG_CHECKING(getaddrinfo bug)
3445 AC_CACHE_VAL(ac_cv_buggy_getaddrinfo,
Matthias Klosec511b472010-05-08 11:01:39 +00003446 AC_RUN_IFELSE([AC_LANG_SOURCE([[[
Stefan Krah0afe4e42012-11-22 23:56:51 +01003447#include <stdio.h>
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003448#include <sys/types.h>
3449#include <netdb.h>
3450#include <string.h>
3451#include <sys/socket.h>
3452#include <netinet/in.h>
3453
Alexandre Vassalotti00900892009-07-17 05:26:39 +00003454int main()
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003455{
3456 int passive, gaierr, inet4 = 0, inet6 = 0;
3457 struct addrinfo hints, *ai, *aitop;
3458 char straddr[INET6_ADDRSTRLEN], strport[16];
3459
3460 for (passive = 0; passive <= 1; passive++) {
3461 memset(&hints, 0, sizeof(hints));
3462 hints.ai_family = AF_UNSPEC;
3463 hints.ai_flags = passive ? AI_PASSIVE : 0;
3464 hints.ai_socktype = SOCK_STREAM;
Hye-Shik Chang54f94392004-04-14 07:55:31 +00003465 hints.ai_protocol = IPPROTO_TCP;
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003466 if ((gaierr = getaddrinfo(NULL, "54321", &hints, &aitop)) != 0) {
3467 (void)gai_strerror(gaierr);
3468 goto bad;
3469 }
3470 for (ai = aitop; ai; ai = ai->ai_next) {
3471 if (ai->ai_addr == NULL ||
3472 ai->ai_addrlen == 0 ||
3473 getnameinfo(ai->ai_addr, ai->ai_addrlen,
3474 straddr, sizeof(straddr), strport, sizeof(strport),
3475 NI_NUMERICHOST|NI_NUMERICSERV) != 0) {
3476 goto bad;
3477 }
3478 switch (ai->ai_family) {
3479 case AF_INET:
3480 if (strcmp(strport, "54321") != 0) {
3481 goto bad;
3482 }
3483 if (passive) {
3484 if (strcmp(straddr, "0.0.0.0") != 0) {
3485 goto bad;
3486 }
3487 } else {
3488 if (strcmp(straddr, "127.0.0.1") != 0) {
3489 goto bad;
3490 }
3491 }
3492 inet4++;
3493 break;
3494 case AF_INET6:
3495 if (strcmp(strport, "54321") != 0) {
3496 goto bad;
3497 }
3498 if (passive) {
3499 if (strcmp(straddr, "::") != 0) {
3500 goto bad;
3501 }
3502 } else {
3503 if (strcmp(straddr, "::1") != 0) {
3504 goto bad;
3505 }
3506 }
3507 inet6++;
3508 break;
3509 case AF_UNSPEC:
3510 goto bad;
3511 break;
3512 default:
3513 /* another family support? */
3514 break;
3515 }
3516 }
Benjamin Petersond34677c2016-09-06 15:54:24 -07003517 freeaddrinfo(aitop);
3518 aitop = NULL;
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003519 }
3520
3521 if (!(inet4 == 0 || inet4 == 2))
3522 goto bad;
3523 if (!(inet6 == 0 || inet6 == 2))
3524 goto bad;
3525
3526 if (aitop)
3527 freeaddrinfo(aitop);
Alexandre Vassalotti00900892009-07-17 05:26:39 +00003528 return 0;
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003529
3530 bad:
3531 if (aitop)
3532 freeaddrinfo(aitop);
Alexandre Vassalotti00900892009-07-17 05:26:39 +00003533 return 1;
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003534}
Matthias Klosec511b472010-05-08 11:01:39 +00003535]]])],
3536[ac_cv_buggy_getaddrinfo=no],
3537[ac_cv_buggy_getaddrinfo=yes],
doko@python.orgd65e2ba2013-01-31 23:52:03 +01003538[
3539if test "${enable_ipv6+set}" = set; then
3540 ac_cv_buggy_getaddrinfo="no -- configured with --(en|dis)able-ipv6"
3541else
3542 ac_cv_buggy_getaddrinfo=yes
3543fi]))
Alexandre Vassalotti00900892009-07-17 05:26:39 +00003544fi
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003545
Benjamin Peterson75fed812010-11-01 01:47:19 +00003546AC_MSG_RESULT($ac_cv_buggy_getaddrinfo)
3547
Mark Dickinson0ef0b912009-12-31 21:11:48 +00003548if test $have_getaddrinfo = no -o "$ac_cv_buggy_getaddrinfo" = yes
Alexandre Vassalotti00900892009-07-17 05:26:39 +00003549then
3550 if test $ipv6 = yes
3551 then
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003552 echo 'Fatal: You must get working getaddrinfo() function.'
3553 echo ' or you can specify "--disable-ipv6"'.
3554 exit 1
3555 fi
Martin v. Löwis861a65b2001-10-24 14:36:00 +00003556else
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003557 AC_DEFINE(HAVE_GETADDRINFO, 1, [Define if you have the getaddrinfo function.])
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003558fi
Benjamin Peterson75fed812010-11-01 01:47:19 +00003559
Thomas Woutersb0db85a2001-08-08 10:39:03 +00003560AC_CHECK_FUNCS(getnameinfo)
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003561
Guido van Rossum627b2d71993-12-24 10:39:16 +00003562# checks for structures
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003563AC_HEADER_TIME
Guido van Rossum627b2d71993-12-24 10:39:16 +00003564AC_STRUCT_TM
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003565AC_STRUCT_TIMEZONE
Martin v. Löwis60a5d722002-10-16 20:28:25 +00003566AC_CHECK_MEMBERS([struct stat.st_rdev])
3567AC_CHECK_MEMBERS([struct stat.st_blksize])
Hye-Shik Chang5f937a72005-06-02 13:09:30 +00003568AC_CHECK_MEMBERS([struct stat.st_flags])
Martin v. Löwisebd9d5b2005-08-09 15:00:59 +00003569AC_CHECK_MEMBERS([struct stat.st_gen])
3570AC_CHECK_MEMBERS([struct stat.st_birthtime])
Martin Pantera45120d2016-03-18 02:36:41 +00003571AC_CHECK_MEMBERS([struct stat.st_blocks])
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003572
3573AC_MSG_CHECKING(for time.h that defines altzone)
Matthias Klosec511b472010-05-08 11:01:39 +00003574AC_CACHE_VAL(ac_cv_header_time_altzone,[
3575 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <time.h>]], [[return altzone;]])],
3576 [ac_cv_header_time_altzone=yes],
3577 [ac_cv_header_time_altzone=no])
3578 ])
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003579AC_MSG_RESULT($ac_cv_header_time_altzone)
3580if test $ac_cv_header_time_altzone = yes; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003581 AC_DEFINE(HAVE_ALTZONE, 1, [Define this if your time.h defines altzone.])
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003582fi
3583
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003584was_it_defined=no
3585AC_MSG_CHECKING(whether sys/select.h and sys/time.h may both be included)
Matthias Klosec511b472010-05-08 11:01:39 +00003586AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003587#include <sys/types.h>
3588#include <sys/select.h>
3589#include <sys/time.h>
Matthias Klosec511b472010-05-08 11:01:39 +00003590]], [[;]])],[
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003591 AC_DEFINE(SYS_SELECT_WITH_SYS_TIME, 1,
3592 [Define if you can safely include both <sys/select.h> and <sys/time.h>
3593 (which you can't on SCO ODT 3.0).])
3594 was_it_defined=yes
Matthias Klosec511b472010-05-08 11:01:39 +00003595],[])
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003596AC_MSG_RESULT($was_it_defined)
Guido van Rossum627b2d71993-12-24 10:39:16 +00003597
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003598AC_MSG_CHECKING(for addrinfo)
3599AC_CACHE_VAL(ac_cv_struct_addrinfo,
Matthias Klosec511b472010-05-08 11:01:39 +00003600AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <netdb.h>]], [[struct addrinfo a]])],
3601 [ac_cv_struct_addrinfo=yes],
3602 [ac_cv_struct_addrinfo=no]))
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003603AC_MSG_RESULT($ac_cv_struct_addrinfo)
3604if test $ac_cv_struct_addrinfo = yes; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003605 AC_DEFINE(HAVE_ADDRINFO, 1, [struct addrinfo (netdb.h)])
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003606fi
3607
3608AC_MSG_CHECKING(for sockaddr_storage)
3609AC_CACHE_VAL(ac_cv_struct_sockaddr_storage,
Matthias Klosec511b472010-05-08 11:01:39 +00003610AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003611# include <sys/types.h>
Matthias Klosec511b472010-05-08 11:01:39 +00003612# include <sys/socket.h>]], [[struct sockaddr_storage s]])],
3613 [ac_cv_struct_sockaddr_storage=yes],
3614 [ac_cv_struct_sockaddr_storage=no]))
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003615AC_MSG_RESULT($ac_cv_struct_sockaddr_storage)
3616if test $ac_cv_struct_sockaddr_storage = yes; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003617 AC_DEFINE(HAVE_SOCKADDR_STORAGE, 1, [struct sockaddr_storage (sys/socket.h)])
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003618fi
3619
Guido van Rossum627b2d71993-12-24 10:39:16 +00003620# checks for compiler characteristics
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003621
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003622AC_C_CHAR_UNSIGNED
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003623AC_C_CONST
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003624
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003625works=no
3626AC_MSG_CHECKING(for working volatile)
Matthias Klosec511b472010-05-08 11:01:39 +00003627AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[volatile int x; x = 0;]])],
3628 [works=yes],
3629 [AC_DEFINE(volatile, , [Define to empty if the keyword does not work.])]
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003630)
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003631AC_MSG_RESULT($works)
Guido van Rossumdabb11b1994-10-11 15:04:27 +00003632
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003633works=no
3634AC_MSG_CHECKING(for working signed char)
Matthias Klosec511b472010-05-08 11:01:39 +00003635AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[signed char c;]])],
3636 [works=yes],
3637 [AC_DEFINE(signed, , [Define to empty if the keyword does not work.])]
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003638)
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003639AC_MSG_RESULT($works)
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003640
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003641have_prototypes=no
3642AC_MSG_CHECKING(for prototypes)
Matthias Klosec511b472010-05-08 11:01:39 +00003643AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[int foo(int x) { return 0; }]], [[return foo(10);]])],
3644 [AC_DEFINE(HAVE_PROTOTYPES, 1,
3645 [Define if your compiler supports function prototype])
3646 have_prototypes=yes],
3647 []
3648)
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003649AC_MSG_RESULT($have_prototypes)
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003650
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003651works=no
3652AC_MSG_CHECKING(for variable length prototypes and stdarg.h)
Matthias Klosec511b472010-05-08 11:01:39 +00003653AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003654#include <stdarg.h>
Guido van Rossum3f13e481996-08-30 20:58:11 +00003655int foo(int x, ...) {
3656 va_list va;
3657 va_start(va, x);
3658 va_arg(va, int);
3659 va_arg(va, char *);
3660 va_arg(va, double);
3661 return 0;
3662}
Matthias Klosec511b472010-05-08 11:01:39 +00003663]], [[return foo(10, "", 3.14);]])],[
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003664 AC_DEFINE(HAVE_STDARG_PROTOTYPES, 1,
3665 [Define if your compiler supports variable length function prototypes
3666 (e.g. void fprintf(FILE *, char *, ...);) *and* <stdarg.h>])
3667 works=yes
Matthias Klosec511b472010-05-08 11:01:39 +00003668],[])
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003669AC_MSG_RESULT($works)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003670
Dave Cole331708b2004-08-09 04:51:41 +00003671# check for socketpair
3672AC_MSG_CHECKING(for socketpair)
Matthias Klosec511b472010-05-08 11:01:39 +00003673AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Dave Cole331708b2004-08-09 04:51:41 +00003674#include <sys/types.h>
3675#include <sys/socket.h>
Matthias Klosec511b472010-05-08 11:01:39 +00003676]], [[void *x=socketpair]])],
3677 [AC_DEFINE(HAVE_SOCKETPAIR, 1, [Define if you have the 'socketpair' function.])
3678 AC_MSG_RESULT(yes)],
3679 [AC_MSG_RESULT(no)]
Dave Cole331708b2004-08-09 04:51:41 +00003680)
3681
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003682# check if sockaddr has sa_len member
3683AC_MSG_CHECKING(if sockaddr has sa_len member)
Matthias Klosec511b472010-05-08 11:01:39 +00003684AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
3685#include <sys/socket.h>]], [[struct sockaddr x;
3686x.sa_len = 0;]])],
3687 [AC_MSG_RESULT(yes)
3688 AC_DEFINE(HAVE_SOCKADDR_SA_LEN, 1, [Define if sockaddr has sa_len member])],
3689 [AC_MSG_RESULT(no)]
3690)
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003691
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003692va_list_is_array=no
3693AC_MSG_CHECKING(whether va_list is an array)
Matthias Klosec511b472010-05-08 11:01:39 +00003694AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003695#ifdef HAVE_STDARG_PROTOTYPES
3696#include <stdarg.h>
3697#else
3698#include <varargs.h>
3699#endif
Matthias Klosec511b472010-05-08 11:01:39 +00003700]], [[va_list list1, list2; list1 = list2;]])],[],[
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003701 AC_DEFINE(VA_LIST_IS_ARRAY, 1, [Define if a va_list is an array of some kind])
3702 va_list_is_array=yes
3703])
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003704AC_MSG_RESULT($va_list_is_array)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003705
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003706# sigh -- gethostbyname_r is a mess; it can have 3, 5 or 6 arguments :-(
Martin v. Löwis11437992002-04-12 09:54:03 +00003707AH_TEMPLATE(HAVE_GETHOSTBYNAME_R,
3708 [Define this if you have some version of gethostbyname_r()])
3709
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003710AC_CHECK_FUNC(gethostbyname_r, [
3711 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
3712 AC_MSG_CHECKING([gethostbyname_r with 6 args])
3713 OLD_CFLAGS=$CFLAGS
3714 CFLAGS="$CFLAGS $MY_CPPFLAGS $MY_THREAD_CPPFLAGS $MY_CFLAGS"
Matthias Klosec511b472010-05-08 11:01:39 +00003715 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003716# include <netdb.h>
Matthias Klosec511b472010-05-08 11:01:39 +00003717 ]], [[
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003718 char *name;
3719 struct hostent *he, *res;
3720 char buffer[2048];
3721 int buflen = 2048;
3722 int h_errnop;
3723
3724 (void) gethostbyname_r(name, he, buffer, buflen, &res, &h_errnop)
Matthias Klosec511b472010-05-08 11:01:39 +00003725 ]])],[
Guido van Rossum8db7d8b1999-03-23 16:40:33 +00003726 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003727 AC_DEFINE(HAVE_GETHOSTBYNAME_R_6_ARG, 1,
3728 [Define this if you have the 6-arg version of gethostbyname_r().])
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003729 AC_MSG_RESULT(yes)
Matthias Klosec511b472010-05-08 11:01:39 +00003730 ],[
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003731 AC_MSG_RESULT(no)
3732 AC_MSG_CHECKING([gethostbyname_r with 5 args])
Matthias Klosec511b472010-05-08 11:01:39 +00003733 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003734# include <netdb.h>
Matthias Klosec511b472010-05-08 11:01:39 +00003735 ]], [[
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003736 char *name;
3737 struct hostent *he;
Matthias Klosec511b472010-05-08 11:01:39 +00003738 char buffer[2048];
3739 int buflen = 2048;
3740 int h_errnop;
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003741
Matthias Klosec511b472010-05-08 11:01:39 +00003742 (void) gethostbyname_r(name, he, buffer, buflen, &h_errnop)
3743 ]])],
3744 [
Guido van Rossum8db7d8b1999-03-23 16:40:33 +00003745 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
Matthias Klosec511b472010-05-08 11:01:39 +00003746 AC_DEFINE(HAVE_GETHOSTBYNAME_R_5_ARG, 1,
3747 [Define this if you have the 5-arg version of gethostbyname_r().])
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003748 AC_MSG_RESULT(yes)
3749 ], [
3750 AC_MSG_RESULT(no)
Matthias Klosec511b472010-05-08 11:01:39 +00003751 AC_MSG_CHECKING([gethostbyname_r with 3 args])
3752 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3753# include <netdb.h>
3754 ]], [[
3755 char *name;
3756 struct hostent *he;
3757 struct hostent_data data;
3758
3759 (void) gethostbyname_r(name, he, &data);
3760 ]])],
3761 [
3762 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
3763 AC_DEFINE(HAVE_GETHOSTBYNAME_R_3_ARG, 1,
3764 [Define this if you have the 3-arg version of gethostbyname_r().])
3765 AC_MSG_RESULT(yes)
3766 ], [
3767 AC_MSG_RESULT(no)
3768 ])
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003769 ])
3770 ])
3771 CFLAGS=$OLD_CFLAGS
3772], [
Thomas Wouters3a584202000-08-05 23:28:51 +00003773 AC_CHECK_FUNCS(gethostbyname)
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003774])
3775AC_SUBST(HAVE_GETHOSTBYNAME_R_6_ARG)
3776AC_SUBST(HAVE_GETHOSTBYNAME_R_5_ARG)
3777AC_SUBST(HAVE_GETHOSTBYNAME_R_3_ARG)
Guido van Rossum8db7d8b1999-03-23 16:40:33 +00003778AC_SUBST(HAVE_GETHOSTBYNAME_R)
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003779AC_SUBST(HAVE_GETHOSTBYNAME)
3780
Guido van Rossum627b2d71993-12-24 10:39:16 +00003781# checks for system services
3782# (none yet)
3783
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003784# Linux requires this for correct f.p. operations
Jeremy Hyltonbe28f5b2000-07-27 21:03:04 +00003785AC_CHECK_FUNC(__fpu_control,
3786 [],
3787 [AC_CHECK_LIB(ieee, __fpu_control)
3788])
Guido van Rossum627b2d71993-12-24 10:39:16 +00003789
Guido van Rossum93274221997-05-09 02:42:00 +00003790# Check for --with-fpectl
Guido van Rossum93274221997-05-09 02:42:00 +00003791AC_MSG_CHECKING(for --with-fpectl)
Barry Warsawc0d24d82000-06-29 16:12:00 +00003792AC_ARG_WITH(fpectl,
Matthias Klose22520ea2010-05-08 10:14:46 +00003793 AS_HELP_STRING([--with-fpectl], [enable SIGFPE catching]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003794[
Guido van Rossum93274221997-05-09 02:42:00 +00003795if test "$withval" != no
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003796then
3797 AC_DEFINE(WANT_SIGFPE_HANDLER, 1,
3798 [Define if you want SIGFPE handled (see Include/pyfpe.h).])
3799 AC_MSG_RESULT(yes)
Guido van Rossum93274221997-05-09 02:42:00 +00003800else AC_MSG_RESULT(no)
Guido van Rossumef2255b2000-03-10 22:30:29 +00003801fi],
3802[AC_MSG_RESULT(no)])
Guido van Rossum93274221997-05-09 02:42:00 +00003803
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003804# check for --with-libm=...
3805AC_SUBST(LIBM)
Guido van Rossum4b6b5791996-09-09 20:09:34 +00003806case $ac_sys_system in
Guido van Rossum3dc0a512000-10-05 18:00:06 +00003807Darwin) ;;
Guido van Rossumec95c7b1998-08-04 17:59:56 +00003808BeOS) ;;
Guido van Rossum4b6b5791996-09-09 20:09:34 +00003809*) LIBM=-lm
3810esac
Guido van Rossum93274221997-05-09 02:42:00 +00003811AC_MSG_CHECKING(for --with-libm=STRING)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003812AC_ARG_WITH(libm,
Matthias Klose22520ea2010-05-08 10:14:46 +00003813 AS_HELP_STRING([--with-libm=STRING], [math library]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003814[
Guido van Rossum93274221997-05-09 02:42:00 +00003815if test "$withval" = no
3816then LIBM=
3817 AC_MSG_RESULT(force LIBM empty)
3818elif test "$withval" != yes
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003819then LIBM=$withval
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003820 AC_MSG_RESULT(set LIBM="$withval")
3821else AC_MSG_ERROR([proper usage is --with-libm=STRING])
Guido van Rossum93274221997-05-09 02:42:00 +00003822fi],
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003823[AC_MSG_RESULT(default LIBM="$LIBM")])
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003824
3825# check for --with-libc=...
3826AC_SUBST(LIBC)
Guido van Rossum93274221997-05-09 02:42:00 +00003827AC_MSG_CHECKING(for --with-libc=STRING)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003828AC_ARG_WITH(libc,
Matthias Klose22520ea2010-05-08 10:14:46 +00003829 AS_HELP_STRING([--with-libc=STRING], [C library]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003830[
Guido van Rossum93274221997-05-09 02:42:00 +00003831if test "$withval" = no
3832then LIBC=
3833 AC_MSG_RESULT(force LIBC empty)
3834elif test "$withval" != yes
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003835then LIBC=$withval
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003836 AC_MSG_RESULT(set LIBC="$withval")
3837else AC_MSG_ERROR([proper usage is --with-libc=STRING])
Guido van Rossum93274221997-05-09 02:42:00 +00003838fi],
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003839[AC_MSG_RESULT(default LIBC="$LIBC")])
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003840
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003841# **************************************************
3842# * Check for various properties of floating point *
3843# **************************************************
Mark Dickinson265d7382008-04-21 22:32:24 +00003844
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003845AC_MSG_CHECKING(whether C doubles are little-endian IEEE 754 binary64)
3846AC_CACHE_VAL(ac_cv_little_endian_double, [
Matthias Klosec511b472010-05-08 11:01:39 +00003847AC_RUN_IFELSE([AC_LANG_SOURCE([[
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003848#include <string.h>
3849int main() {
3850 double x = 9006104071832581.0;
3851 if (memcmp(&x, "\x05\x04\x03\x02\x01\xff\x3f\x43", 8) == 0)
3852 return 0;
3853 else
3854 return 1;
3855}
Matthias Klosec511b472010-05-08 11:01:39 +00003856]])],
3857[ac_cv_little_endian_double=yes],
3858[ac_cv_little_endian_double=no],
3859[ac_cv_little_endian_double=no])])
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003860AC_MSG_RESULT($ac_cv_little_endian_double)
3861if test "$ac_cv_little_endian_double" = yes
3862then
3863 AC_DEFINE(DOUBLE_IS_LITTLE_ENDIAN_IEEE754, 1,
3864 [Define if C doubles are 64-bit IEEE 754 binary format, stored
3865 with the least significant byte first])
3866fi
3867
3868AC_MSG_CHECKING(whether C doubles are big-endian IEEE 754 binary64)
3869AC_CACHE_VAL(ac_cv_big_endian_double, [
Matthias Klosec511b472010-05-08 11:01:39 +00003870AC_RUN_IFELSE([AC_LANG_SOURCE([[
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003871#include <string.h>
3872int main() {
3873 double x = 9006104071832581.0;
3874 if (memcmp(&x, "\x43\x3f\xff\x01\x02\x03\x04\x05", 8) == 0)
3875 return 0;
3876 else
3877 return 1;
3878}
Matthias Klosec511b472010-05-08 11:01:39 +00003879]])],
3880[ac_cv_big_endian_double=yes],
3881[ac_cv_big_endian_double=no],
3882[ac_cv_big_endian_double=no])])
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003883AC_MSG_RESULT($ac_cv_big_endian_double)
3884if test "$ac_cv_big_endian_double" = yes
3885then
3886 AC_DEFINE(DOUBLE_IS_BIG_ENDIAN_IEEE754, 1,
3887 [Define if C doubles are 64-bit IEEE 754 binary format, stored
3888 with the most significant byte first])
3889fi
3890
3891# Some ARM platforms use a mixed-endian representation for doubles.
3892# While Python doesn't currently have full support for these platforms
3893# (see e.g., issue 1762561), we can at least make sure that float <-> string
3894# conversions work.
3895AC_MSG_CHECKING(whether C doubles are ARM mixed-endian IEEE 754 binary64)
3896AC_CACHE_VAL(ac_cv_mixed_endian_double, [
Matthias Klosec511b472010-05-08 11:01:39 +00003897AC_RUN_IFELSE([AC_LANG_SOURCE([[
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003898#include <string.h>
3899int main() {
3900 double x = 9006104071832581.0;
3901 if (memcmp(&x, "\x01\xff\x3f\x43\x05\x04\x03\x02", 8) == 0)
3902 return 0;
3903 else
3904 return 1;
3905}
Matthias Klosec511b472010-05-08 11:01:39 +00003906]])],
3907[ac_cv_mixed_endian_double=yes],
3908[ac_cv_mixed_endian_double=no],
3909[ac_cv_mixed_endian_double=no])])
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003910AC_MSG_RESULT($ac_cv_mixed_endian_double)
3911if test "$ac_cv_mixed_endian_double" = yes
3912then
3913 AC_DEFINE(DOUBLE_IS_ARM_MIXED_ENDIAN_IEEE754, 1,
3914 [Define if C doubles are 64-bit IEEE 754 binary format, stored
3915 in ARM mixed-endian order (byte order 45670123)])
3916fi
3917
3918# The short float repr introduced in Python 3.1 requires the
3919# correctly-rounded string <-> double conversion functions from
3920# Python/dtoa.c, which in turn require that the FPU uses 53-bit
3921# rounding; this is a problem on x86, where the x87 FPU has a default
Mark Dickinsona548dee2009-11-15 13:12:43 +00003922# rounding precision of 64 bits. For gcc/x86, we can fix this by
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003923# using inline assembler to get and set the x87 FPU control word.
Mark Dickinsona548dee2009-11-15 13:12:43 +00003924
3925# This inline assembler syntax may also work for suncc and icc,
3926# so we try it on all platforms.
3927
3928AC_MSG_CHECKING(whether we can use gcc inline assembler to get and set x87 control word)
Stefan Krah99e36b92015-07-03 15:30:54 +02003929AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
Mark Dickinsona548dee2009-11-15 13:12:43 +00003930 unsigned short cw;
3931 __asm__ __volatile__ ("fnstcw %0" : "=m" (cw));
3932 __asm__ __volatile__ ("fldcw %0" : : "m" (cw));
Matthias Klosec511b472010-05-08 11:01:39 +00003933]])],[have_gcc_asm_for_x87=yes],[have_gcc_asm_for_x87=no])
Mark Dickinsona548dee2009-11-15 13:12:43 +00003934AC_MSG_RESULT($have_gcc_asm_for_x87)
3935if test "$have_gcc_asm_for_x87" = yes
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003936then
Mark Dickinsona548dee2009-11-15 13:12:43 +00003937 AC_DEFINE(HAVE_GCC_ASM_FOR_X87, 1,
3938 [Define if we can use gcc inline assembler to get and set x87 control word])
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003939fi
Mark Dickinson7a3d8642008-04-22 00:54:27 +00003940
Mark Dickinson04b27232009-01-04 12:29:36 +00003941# Detect whether system arithmetic is subject to x87-style double
3942# rounding issues. The result of this test has little meaning on non
3943# IEEE 754 platforms. On IEEE 754, test should return 1 if rounding
3944# mode is round-to-nearest and double rounding issues are present, and
3945# 0 otherwise. See http://bugs.python.org/issue2937 for more info.
3946AC_MSG_CHECKING(for x87-style double rounding)
Mark Dickinson99abd142009-10-24 13:44:16 +00003947# $BASECFLAGS may affect the result
3948ac_save_cc="$CC"
3949CC="$CC $BASECFLAGS"
Matthias Klosec511b472010-05-08 11:01:39 +00003950AC_RUN_IFELSE([AC_LANG_SOURCE([[
Mark Dickinson04b27232009-01-04 12:29:36 +00003951#include <stdlib.h>
3952#include <math.h>
3953int main() {
3954 volatile double x, y, z;
3955 /* 1./(1-2**-53) -> 1+2**-52 (correct), 1.0 (double rounding) */
3956 x = 0.99999999999999989; /* 1-2**-53 */
3957 y = 1./x;
3958 if (y != 1.)
3959 exit(0);
3960 /* 1e16+2.99999 -> 1e16+2. (correct), 1e16+4. (double rounding) */
3961 x = 1e16;
3962 y = 2.99999;
3963 z = x + y;
3964 if (z != 1e16+4.)
3965 exit(0);
3966 /* both tests show evidence of double rounding */
3967 exit(1);
3968}
Matthias Klosec511b472010-05-08 11:01:39 +00003969]])],
3970[ac_cv_x87_double_rounding=no],
3971[ac_cv_x87_double_rounding=yes],
3972[ac_cv_x87_double_rounding=no])
Mark Dickinson99abd142009-10-24 13:44:16 +00003973CC="$ac_save_cc"
Mark Dickinson04b27232009-01-04 12:29:36 +00003974AC_MSG_RESULT($ac_cv_x87_double_rounding)
3975if test "$ac_cv_x87_double_rounding" = yes
3976then
3977 AC_DEFINE(X87_DOUBLE_ROUNDING, 1,
3978 [Define if arithmetic is subject to x87-style double rounding issue])
3979fi
3980
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003981# ************************************
3982# * Check for mathematical functions *
3983# ************************************
3984
3985LIBS_SAVE=$LIBS
3986LIBS="$LIBS $LIBM"
3987
Mark Dickinsonc63392c2009-11-28 13:13:13 +00003988# On FreeBSD 6.2, it appears that tanh(-0.) returns 0. instead of
3989# -0. on some architectures.
3990AC_MSG_CHECKING(whether tanh preserves the sign of zero)
3991AC_CACHE_VAL(ac_cv_tanh_preserves_zero_sign, [
Matthias Klosec511b472010-05-08 11:01:39 +00003992AC_RUN_IFELSE([AC_LANG_SOURCE([[
Mark Dickinsonc63392c2009-11-28 13:13:13 +00003993#include <math.h>
3994#include <stdlib.h>
3995int main() {
3996 /* return 0 if either negative zeros don't exist
3997 on this platform or if negative zeros exist
3998 and tanh(-0.) == -0. */
3999 if (atan2(0., -1.) == atan2(-0., -1.) ||
4000 atan2(tanh(-0.), -1.) == atan2(-0., -1.)) exit(0);
4001 else exit(1);
4002}
Matthias Klosec511b472010-05-08 11:01:39 +00004003]])],
4004[ac_cv_tanh_preserves_zero_sign=yes],
4005[ac_cv_tanh_preserves_zero_sign=no],
4006[ac_cv_tanh_preserves_zero_sign=no])])
Mark Dickinsonc63392c2009-11-28 13:13:13 +00004007AC_MSG_RESULT($ac_cv_tanh_preserves_zero_sign)
4008if test "$ac_cv_tanh_preserves_zero_sign" = yes
4009then
4010 AC_DEFINE(TANH_PRESERVES_ZERO_SIGN, 1,
4011 [Define if tanh(-0.) is -0., or if platform doesn't have signed zeros])
4012fi
4013
4014AC_CHECK_FUNCS([acosh asinh atanh copysign erf erfc expm1 finite gamma])
4015AC_CHECK_FUNCS([hypot lgamma log1p round tgamma])
4016AC_CHECK_DECLS([isinf, isnan, isfinite], [], [], [[#include <math.h>]])
4017
4018LIBS=$LIBS_SAVE
4019
Mark Dickinsonc4920e82009-11-20 19:30:22 +00004020# For multiprocessing module, check that sem_open
4021# actually works. For FreeBSD versions <= 7.2,
4022# the kernel module that provides POSIX semaphores
4023# isn't loaded by default, so an attempt to call
4024# sem_open results in a 'Signal 12' error.
4025AC_MSG_CHECKING(whether POSIX semaphores are enabled)
4026AC_CACHE_VAL(ac_cv_posix_semaphores_enabled,
Matthias Klosec511b472010-05-08 11:01:39 +00004027AC_RUN_IFELSE([AC_LANG_SOURCE([[
Mark Dickinsonc4920e82009-11-20 19:30:22 +00004028#include <unistd.h>
4029#include <fcntl.h>
4030#include <stdio.h>
4031#include <semaphore.h>
4032#include <sys/stat.h>
4033
4034int main(void) {
4035 sem_t *a = sem_open("/autoconf", O_CREAT, S_IRUSR|S_IWUSR, 0);
4036 if (a == SEM_FAILED) {
4037 perror("sem_open");
4038 return 1;
4039 }
4040 sem_close(a);
Mark Dickinson59dc89e2009-12-13 21:06:06 +00004041 sem_unlink("/autoconf");
Mark Dickinsonc4920e82009-11-20 19:30:22 +00004042 return 0;
4043}
Matthias Klosec511b472010-05-08 11:01:39 +00004044]])],
4045[ac_cv_posix_semaphores_enabled=yes],
4046[ac_cv_posix_semaphores_enabled=no],
4047[ac_cv_posix_semaphores_enabled=yes])
Mark Dickinsonc4920e82009-11-20 19:30:22 +00004048)
4049AC_MSG_RESULT($ac_cv_posix_semaphores_enabled)
4050if test $ac_cv_posix_semaphores_enabled = no
4051then
Mark Dickinson5afa6d42009-11-28 10:44:20 +00004052 AC_DEFINE(POSIX_SEMAPHORES_NOT_ENABLED, 1,
4053 [Define if POSIX semaphores aren't enabled on your system])
Mark Dickinsonc4920e82009-11-20 19:30:22 +00004054fi
4055
Jesse Noller355b1262009-04-02 00:03:28 +00004056# Multiprocessing check for broken sem_getvalue
4057AC_MSG_CHECKING(for broken sem_getvalue)
Alexandre Vassalotti00900892009-07-17 05:26:39 +00004058AC_CACHE_VAL(ac_cv_broken_sem_getvalue,
Matthias Klosec511b472010-05-08 11:01:39 +00004059AC_RUN_IFELSE([AC_LANG_SOURCE([[
Jesse Noller355b1262009-04-02 00:03:28 +00004060#include <unistd.h>
4061#include <fcntl.h>
4062#include <stdio.h>
4063#include <semaphore.h>
4064#include <sys/stat.h>
4065
4066int main(void){
Mark Dickinson59dc89e2009-12-13 21:06:06 +00004067 sem_t *a = sem_open("/autocftw", O_CREAT, S_IRUSR|S_IWUSR, 0);
Jesse Noller355b1262009-04-02 00:03:28 +00004068 int count;
4069 int res;
4070 if(a==SEM_FAILED){
4071 perror("sem_open");
4072 return 1;
4073
4074 }
4075 res = sem_getvalue(a, &count);
4076 sem_close(a);
Mark Dickinson59dc89e2009-12-13 21:06:06 +00004077 sem_unlink("/autocftw");
Jesse Noller355b1262009-04-02 00:03:28 +00004078 return res==-1 ? 1 : 0;
4079}
Matthias Klosec511b472010-05-08 11:01:39 +00004080]])],
4081[ac_cv_broken_sem_getvalue=no],
4082[ac_cv_broken_sem_getvalue=yes],
4083[ac_cv_broken_sem_getvalue=yes])
Jesse Noller355b1262009-04-02 00:03:28 +00004084)
Alexandre Vassalotti00900892009-07-17 05:26:39 +00004085AC_MSG_RESULT($ac_cv_broken_sem_getvalue)
4086if test $ac_cv_broken_sem_getvalue = yes
4087then
4088 AC_DEFINE(HAVE_BROKEN_SEM_GETVALUE, 1,
4089 [define to 1 if your sem_getvalue is broken.])
4090fi
Mark Dickinson04b27232009-01-04 12:29:36 +00004091
Mark Dickinsonefc82f72009-03-20 15:51:55 +00004092# determine what size digit to use for Python's longs
4093AC_MSG_CHECKING([digit size for Python's longs])
4094AC_ARG_ENABLE(big-digits,
Matthias Klose22520ea2010-05-08 10:14:46 +00004095AS_HELP_STRING([--enable-big-digits@<:@=BITS@:>@],[use big digits for Python longs [[BITS=30]]]),
Mark Dickinsonefc82f72009-03-20 15:51:55 +00004096[case $enable_big_digits in
4097yes)
4098 enable_big_digits=30 ;;
4099no)
4100 enable_big_digits=15 ;;
4101[15|30])
4102 ;;
4103*)
4104 AC_MSG_ERROR([bad value $enable_big_digits for --enable-big-digits; value should be 15 or 30]) ;;
4105esac
4106AC_MSG_RESULT($enable_big_digits)
4107AC_DEFINE_UNQUOTED(PYLONG_BITS_IN_DIGIT, $enable_big_digits, [Define as the preferred size in bits of long digits])
4108],
4109[AC_MSG_RESULT(no value specified)])
4110
Guido van Rossumef2255b2000-03-10 22:30:29 +00004111# check for wchar.h
Martin v. Löwisc45929e2002-04-06 10:10:49 +00004112AC_CHECK_HEADER(wchar.h, [
4113 AC_DEFINE(HAVE_WCHAR_H, 1,
4114 [Define if the compiler provides a wchar.h header file.])
4115 wchar_h="yes"
4116],
Guido van Rossumef2255b2000-03-10 22:30:29 +00004117wchar_h="no"
4118)
4119
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00004120# determine wchar_t size
4121if test "$wchar_h" = yes
4122then
Guido van Rossum67b26592001-10-20 14:21:45 +00004123 AC_CHECK_SIZEOF(wchar_t, 4, [#include <wchar.h>])
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00004124fi
4125
Martin v. Löwisfa3bdea2003-09-04 18:50:54 +00004126AC_MSG_CHECKING(for UCS-4 tcl)
4127have_ucs4_tcl=no
Matthias Klosec511b472010-05-08 11:01:39 +00004128AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwisfa3bdea2003-09-04 18:50:54 +00004129#include <tcl.h>
4130#if TCL_UTF_MAX != 6
4131# error "NOT UCS4_TCL"
Matthias Klosec511b472010-05-08 11:01:39 +00004132#endif]], [[]])],[
Martin v. Löwisfa3bdea2003-09-04 18:50:54 +00004133 AC_DEFINE(HAVE_UCS4_TCL, 1, [Define this if you have tcl and TCL_UTF_MAX==6])
4134 have_ucs4_tcl=yes
Matthias Klosec511b472010-05-08 11:01:39 +00004135],[])
Martin v. Löwisfa3bdea2003-09-04 18:50:54 +00004136AC_MSG_RESULT($have_ucs4_tcl)
4137
Marc-André Lemburgd7160f82003-09-22 11:14:40 +00004138# check whether wchar_t is signed or not
4139if test "$wchar_h" = yes
4140then
4141 # check whether wchar_t is signed or not
4142 AC_MSG_CHECKING(whether wchar_t is signed)
4143 AC_CACHE_VAL(ac_cv_wchar_t_signed, [
Matthias Klosec511b472010-05-08 11:01:39 +00004144 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Marc-André Lemburgd7160f82003-09-22 11:14:40 +00004145 #include <wchar.h>
4146 int main()
4147 {
Martin v. Löwis44fe0e42006-04-11 07:15:30 +00004148 /* Success: exit code 0 */
4149 exit((((wchar_t) -1) < ((wchar_t) 0)) ? 0 : 1);
Marc-André Lemburgd7160f82003-09-22 11:14:40 +00004150 }
Matthias Klosec511b472010-05-08 11:01:39 +00004151 ]])],
4152 [ac_cv_wchar_t_signed=yes],
4153 [ac_cv_wchar_t_signed=no],
4154 [ac_cv_wchar_t_signed=yes])])
Marc-André Lemburgd7160f82003-09-22 11:14:40 +00004155 AC_MSG_RESULT($ac_cv_wchar_t_signed)
4156fi
4157
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00004158AC_MSG_CHECKING(what type to use for unicode)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00004159dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00004160AC_ARG_ENABLE(unicode,
Benjamin Peterson66556b02010-05-25 02:23:32 +00004161 AS_HELP_STRING([--enable-unicode@<:@=ucs@<:@24@:>@@:>@], [Enable Unicode strings (default is ucs2)]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00004162 [],
4163 [enable_unicode=yes])
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00004164
4165if test $enable_unicode = yes
4166then
Martin v. Löwisfd917792001-06-27 20:22:04 +00004167 # Without any arguments, Py_UNICODE defaults to two-byte mode
Martin v. Löwisfa3bdea2003-09-04 18:50:54 +00004168 case "$have_ucs4_tcl" in
4169 yes) enable_unicode="ucs4"
4170 ;;
4171 *) enable_unicode="ucs2"
4172 ;;
4173 esac
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00004174fi
4175
Martin v. Löwis0036cba2002-04-12 09:58:45 +00004176AH_TEMPLATE(Py_UNICODE_SIZE,
4177 [Define as the size of the unicode type.])
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00004178case "$enable_unicode" in
4179ucs2) unicode_size="2"
4180 AC_DEFINE(Py_UNICODE_SIZE,2)
4181 ;;
4182ucs4) unicode_size="4"
4183 AC_DEFINE(Py_UNICODE_SIZE,4)
4184 ;;
Martin v. Löwised11a5d2012-05-20 10:42:17 +02004185no) ;; # To allow --disable-unicode
Ezio Melotti5820efb2010-02-27 00:05:42 +00004186*) AC_MSG_ERROR([invalid value for --enable-unicode. Use either ucs2 or ucs4 (lowercase).]) ;;
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00004187esac
4188
Martin v. Löwis11437992002-04-12 09:54:03 +00004189AH_TEMPLATE(PY_UNICODE_TYPE,
4190 [Define as the integral type used for Unicode representation.])
Martin v. Löwis0036cba2002-04-12 09:58:45 +00004191
Martin v. Löwis339d0f72001-08-17 18:39:25 +00004192AC_SUBST(UNICODE_OBJS)
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00004193if test "$enable_unicode" = "no"
4194then
Martin v. Löwis339d0f72001-08-17 18:39:25 +00004195 UNICODE_OBJS=""
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00004196 AC_MSG_RESULT(not used)
4197else
Martin v. Löwis339d0f72001-08-17 18:39:25 +00004198 UNICODE_OBJS="Objects/unicodeobject.o Objects/unicodectype.o"
Martin v. Löwisc45929e2002-04-06 10:10:49 +00004199 AC_DEFINE(Py_USING_UNICODE, 1,
4200 [Define if you want to have a Unicode type.])
Marc-André Lemburgd7160f82003-09-22 11:14:40 +00004201
4202 # wchar_t is only usable if it maps to an unsigned type
4203 if test "$unicode_size" = "$ac_cv_sizeof_wchar_t" \
Matthias Klose7dbeed72004-12-24 08:22:17 +00004204 -a "$ac_cv_wchar_t_signed" = "no"
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00004205 then
4206 PY_UNICODE_TYPE="wchar_t"
Martin v. Löwisc45929e2002-04-06 10:10:49 +00004207 AC_DEFINE(HAVE_USABLE_WCHAR_T, 1,
4208 [Define if you have a useable wchar_t type defined in wchar.h; useable
Marc-André Lemburgd7160f82003-09-22 11:14:40 +00004209 means wchar_t must be an unsigned type with at least 16 bits. (see
Martin v. Löwisc45929e2002-04-06 10:10:49 +00004210 Include/unicodeobject.h).])
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00004211 AC_DEFINE(PY_UNICODE_TYPE,wchar_t)
4212 elif test "$ac_cv_sizeof_short" = "$unicode_size"
4213 then
4214 PY_UNICODE_TYPE="unsigned short"
4215 AC_DEFINE(PY_UNICODE_TYPE,unsigned short)
4216 elif test "$ac_cv_sizeof_long" = "$unicode_size"
4217 then
4218 PY_UNICODE_TYPE="unsigned long"
4219 AC_DEFINE(PY_UNICODE_TYPE,unsigned long)
4220 else
4221 PY_UNICODE_TYPE="no type found"
4222 fi
4223 AC_MSG_RESULT($PY_UNICODE_TYPE)
4224fi
Guido van Rossumef2255b2000-03-10 22:30:29 +00004225
4226# check for endianness
4227AC_C_BIGENDIAN
4228
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00004229# Check whether right shifting a negative integer extends the sign bit
4230# or fills with zeros (like the Cray J90, according to Tim Peters).
4231AC_MSG_CHECKING(whether right shift extends the sign bit)
Vladimir Marangozova6180282000-07-12 05:05:06 +00004232AC_CACHE_VAL(ac_cv_rshift_extends_sign, [
Matthias Klosec511b472010-05-08 11:01:39 +00004233AC_RUN_IFELSE([AC_LANG_SOURCE([[
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00004234int main()
4235{
Vladimir Marangozova6180282000-07-12 05:05:06 +00004236 exit(((-1)>>3 == -1) ? 0 : 1);
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00004237}
Matthias Klosec511b472010-05-08 11:01:39 +00004238]])],
4239[ac_cv_rshift_extends_sign=yes],
4240[ac_cv_rshift_extends_sign=no],
4241[ac_cv_rshift_extends_sign=yes])])
Vladimir Marangozova6180282000-07-12 05:05:06 +00004242AC_MSG_RESULT($ac_cv_rshift_extends_sign)
4243if test "$ac_cv_rshift_extends_sign" = no
4244then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00004245 AC_DEFINE(SIGNED_RIGHT_SHIFT_ZERO_FILLS, 1,
4246 [Define if i>>j for signed int i does not extend the sign bit
4247 when i < 0])
Vladimir Marangozova6180282000-07-12 05:05:06 +00004248fi
4249
Guido van Rossumcadfaec2001-01-05 14:45:49 +00004250# check for getc_unlocked and related locking functions
4251AC_MSG_CHECKING(for getc_unlocked() and friends)
4252AC_CACHE_VAL(ac_cv_have_getc_unlocked, [
Matthias Klosec511b472010-05-08 11:01:39 +00004253AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <stdio.h>]], [[
Guido van Rossumcadfaec2001-01-05 14:45:49 +00004254 FILE *f = fopen("/dev/null", "r");
4255 flockfile(f);
4256 getc_unlocked(f);
4257 funlockfile(f);
Matthias Klosec511b472010-05-08 11:01:39 +00004258]])],[ac_cv_have_getc_unlocked=yes],[ac_cv_have_getc_unlocked=no])])
Guido van Rossumcadfaec2001-01-05 14:45:49 +00004259AC_MSG_RESULT($ac_cv_have_getc_unlocked)
4260if test "$ac_cv_have_getc_unlocked" = yes
4261then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00004262 AC_DEFINE(HAVE_GETC_UNLOCKED, 1,
4263 [Define this if you have flockfile(), getc_unlocked(), and funlockfile()])
Guido van Rossumcadfaec2001-01-05 14:45:49 +00004264fi
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00004265
Neal Norwitzfe8e3d92006-01-07 21:07:20 +00004266# check where readline lives
Martin v. Löwis82bca632006-02-10 20:49:30 +00004267# save the value of LIBS so we don't actually link Python with readline
4268LIBS_no_readline=$LIBS
Gregory P. Smith980b99b2008-09-07 05:15:18 +00004269
4270# On some systems we need to link readline to a termcap compatible
4271# library. NOTE: Keep the precedence of listed libraries synchronised
4272# with setup.py.
4273py_cv_lib_readline=no
4274AC_MSG_CHECKING([how to link readline libs])
4275for py_libtermcap in "" ncursesw ncurses curses termcap; do
4276 if test -z "$py_libtermcap"; then
4277 READLINE_LIBS="-lreadline"
4278 else
4279 READLINE_LIBS="-lreadline -l$py_libtermcap"
4280 fi
4281 LIBS="$READLINE_LIBS $LIBS_no_readline"
4282 AC_LINK_IFELSE(
4283 [AC_LANG_CALL([],[readline])],
4284 [py_cv_lib_readline=yes])
4285 if test $py_cv_lib_readline = yes; then
4286 break
4287 fi
4288done
4289# Uncomment this line if you want to use READINE_LIBS in Makefile or scripts
4290#AC_SUBST([READLINE_LIBS])
Gregory P. Smith29ec7502008-09-07 19:18:16 +00004291if test $py_cv_lib_readline = no; then
Gregory P. Smith980b99b2008-09-07 05:15:18 +00004292 AC_MSG_RESULT([none])
4293else
4294 AC_MSG_RESULT([$READLINE_LIBS])
4295 AC_DEFINE(HAVE_LIBREADLINE, 1,
4296 [Define if you have the readline library (-lreadline).])
Neal Norwitzfe8e3d92006-01-07 21:07:20 +00004297fi
4298
Michael W. Hudson30ea2f22004-07-07 17:44:12 +00004299# check for readline 2.1
4300AC_CHECK_LIB(readline, rl_callback_handler_install,
4301 AC_DEFINE(HAVE_RL_CALLBACK, 1,
Gregory P. Smithff7b2d52008-09-03 05:57:48 +00004302 [Define if you have readline 2.1]), ,$READLINE_LIBS)
Michael W. Hudson30ea2f22004-07-07 17:44:12 +00004303
Guido van Rossumfaf5e4d2002-12-30 16:25:41 +00004304# check for readline 2.2
Matthias Klosec511b472010-05-08 11:01:39 +00004305AC_PREPROC_IFELSE([AC_LANG_SOURCE([[#include <readline/readline.h>]])],
4306 [have_readline=yes],
4307 [have_readline=no]
4308)
Guido van Rossumfaf5e4d2002-12-30 16:25:41 +00004309if test $have_readline = yes
4310then
4311 AC_EGREP_HEADER([extern int rl_completion_append_character;],
4312 [readline/readline.h],
4313 AC_DEFINE(HAVE_RL_COMPLETION_APPEND_CHARACTER, 1,
4314 [Define if you have readline 2.2]), )
Antoine Pitroud9ff74e2009-10-26 19:16:46 +00004315 AC_EGREP_HEADER([extern int rl_completion_suppress_append;],
4316 [readline/readline.h],
4317 AC_DEFINE(HAVE_RL_COMPLETION_SUPPRESS_APPEND, 1,
4318 [Define if you have rl_completion_suppress_append]), )
Guido van Rossumfaf5e4d2002-12-30 16:25:41 +00004319fi
4320
Martin v. Löwis0daad592001-09-30 21:09:59 +00004321# check for readline 4.0
4322AC_CHECK_LIB(readline, rl_pre_input_hook,
Martin v. Löwisc45929e2002-04-06 10:10:49 +00004323 AC_DEFINE(HAVE_RL_PRE_INPUT_HOOK, 1,
Gregory P. Smithff7b2d52008-09-03 05:57:48 +00004324 [Define if you have readline 4.0]), ,$READLINE_LIBS)
Martin v. Löwis0daad592001-09-30 21:09:59 +00004325
Martin v. Löwis58bd49f2007-09-04 13:13:14 +00004326# also in 4.0
4327AC_CHECK_LIB(readline, rl_completion_display_matches_hook,
4328 AC_DEFINE(HAVE_RL_COMPLETION_DISPLAY_MATCHES_HOOK, 1,
Gregory P. Smithff7b2d52008-09-03 05:57:48 +00004329 [Define if you have readline 4.0]), ,$READLINE_LIBS)
Martin v. Löwis58bd49f2007-09-04 13:13:14 +00004330
Martin Pantera70c3232016-04-03 02:54:58 +00004331# also in 4.0, but not in editline
4332AC_CHECK_LIB(readline, rl_resize_terminal,
4333 AC_DEFINE(HAVE_RL_RESIZE_TERMINAL, 1,
4334 [Define if you have readline 4.0]), ,$READLINE_LIBS)
4335
Guido van Rossum353ae582001-07-10 16:45:32 +00004336# check for readline 4.2
4337AC_CHECK_LIB(readline, rl_completion_matches,
Martin v. Löwisc45929e2002-04-06 10:10:49 +00004338 AC_DEFINE(HAVE_RL_COMPLETION_MATCHES, 1,
Gregory P. Smithff7b2d52008-09-03 05:57:48 +00004339 [Define if you have readline 4.2]), ,$READLINE_LIBS)
Guido van Rossum353ae582001-07-10 16:45:32 +00004340
Michael W. Hudson30ea2f22004-07-07 17:44:12 +00004341# also in readline 4.2
Matthias Klosec511b472010-05-08 11:01:39 +00004342AC_PREPROC_IFELSE([AC_LANG_SOURCE([[#include <readline/readline.h>]])],
4343 [have_readline=yes],
4344 [have_readline=no]
4345)
Michael W. Hudson30ea2f22004-07-07 17:44:12 +00004346if test $have_readline = yes
4347then
4348 AC_EGREP_HEADER([extern int rl_catch_signals;],
4349 [readline/readline.h],
4350 AC_DEFINE(HAVE_RL_CATCH_SIGNAL, 1,
4351 [Define if you can turn off readline's signal handling.]), )
4352fi
4353
Martin v. Löwis82bca632006-02-10 20:49:30 +00004354# End of readline checks: restore LIBS
4355LIBS=$LIBS_no_readline
4356
Thomas Wouterse38b2f12001-07-11 22:35:31 +00004357AC_MSG_CHECKING(for broken nice())
4358AC_CACHE_VAL(ac_cv_broken_nice, [
Matthias Klosec511b472010-05-08 11:01:39 +00004359AC_RUN_IFELSE([AC_LANG_SOURCE([[
Thomas Wouterse38b2f12001-07-11 22:35:31 +00004360int main()
4361{
4362 int val1 = nice(1);
4363 if (val1 != -1 && val1 == nice(2))
4364 exit(0);
4365 exit(1);
4366}
Matthias Klosec511b472010-05-08 11:01:39 +00004367]])],
4368[ac_cv_broken_nice=yes],
4369[ac_cv_broken_nice=no],
4370[ac_cv_broken_nice=no])])
Thomas Wouterse38b2f12001-07-11 22:35:31 +00004371AC_MSG_RESULT($ac_cv_broken_nice)
4372if test "$ac_cv_broken_nice" = yes
4373then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00004374 AC_DEFINE(HAVE_BROKEN_NICE, 1,
4375 [Define if nice() returns success/failure instead of the new priority.])
Thomas Wouterse38b2f12001-07-11 22:35:31 +00004376fi
4377
Nicholas Bastine62c5c82004-03-21 23:45:42 +00004378AC_MSG_CHECKING(for broken poll())
Alexandre Vassalotti00900892009-07-17 05:26:39 +00004379AC_CACHE_VAL(ac_cv_broken_poll,
Matthias Klosec511b472010-05-08 11:01:39 +00004380AC_RUN_IFELSE([AC_LANG_SOURCE([[
Nicholas Bastine62c5c82004-03-21 23:45:42 +00004381#include <poll.h>
4382
Alexandre Vassalotti66da2632009-07-17 06:17:33 +00004383int main()
4384{
Nicholas Bastine62c5c82004-03-21 23:45:42 +00004385 struct pollfd poll_struct = { 42, POLLIN|POLLPRI|POLLOUT, 0 };
Alexandre Vassalotti66da2632009-07-17 06:17:33 +00004386 int poll_test;
4387
Nicholas Bastine62c5c82004-03-21 23:45:42 +00004388 close (42);
4389
Alexandre Vassalotti66da2632009-07-17 06:17:33 +00004390 poll_test = poll(&poll_struct, 1, 0);
Nicholas Bastine62c5c82004-03-21 23:45:42 +00004391 if (poll_test < 0)
Alexandre Vassalotti66da2632009-07-17 06:17:33 +00004392 return 0;
Nicholas Bastine62c5c82004-03-21 23:45:42 +00004393 else if (poll_test == 0 && poll_struct.revents != POLLNVAL)
Alexandre Vassalotti66da2632009-07-17 06:17:33 +00004394 return 0;
Nicholas Bastine62c5c82004-03-21 23:45:42 +00004395 else
Alexandre Vassalotti66da2632009-07-17 06:17:33 +00004396 return 1;
4397}
Matthias Klosec511b472010-05-08 11:01:39 +00004398]])],
4399[ac_cv_broken_poll=yes],
4400[ac_cv_broken_poll=no],
4401[ac_cv_broken_poll=no]))
Nicholas Bastine62c5c82004-03-21 23:45:42 +00004402AC_MSG_RESULT($ac_cv_broken_poll)
4403if test "$ac_cv_broken_poll" = yes
4404then
4405 AC_DEFINE(HAVE_BROKEN_POLL, 1,
4406 [Define if poll() sets errno on invalid file descriptors.])
4407fi
4408
Brett Cannon43802422005-02-10 20:48:03 +00004409# Before we can test tzset, we need to check if struct tm has a tm_zone
4410# (which is not required by ISO C or UNIX spec) and/or if we support
4411# tzname[]
4412AC_STRUCT_TIMEZONE
Nicholas Bastine62c5c82004-03-21 23:45:42 +00004413
Brett Cannon43802422005-02-10 20:48:03 +00004414# check tzset(3) exists and works like we expect it to
Guido van Rossumd11b62e2003-03-14 21:51:36 +00004415AC_MSG_CHECKING(for working tzset())
4416AC_CACHE_VAL(ac_cv_working_tzset, [
Matthias Klosec511b472010-05-08 11:01:39 +00004417AC_RUN_IFELSE([AC_LANG_SOURCE([[
Guido van Rossumd11b62e2003-03-14 21:51:36 +00004418#include <stdlib.h>
4419#include <time.h>
Brett Cannon18367812003-09-19 00:59:16 +00004420#include <string.h>
Brett Cannon43802422005-02-10 20:48:03 +00004421
4422#if HAVE_TZNAME
4423extern char *tzname[];
4424#endif
4425
Guido van Rossumd11b62e2003-03-14 21:51:36 +00004426int main()
4427{
Brett Cannon18367812003-09-19 00:59:16 +00004428 /* Note that we need to ensure that not only does tzset(3)
4429 do 'something' with localtime, but it works as documented
4430 in the library reference and as expected by the test suite.
Brett Cannon43802422005-02-10 20:48:03 +00004431 This includes making sure that tzname is set properly if
4432 tm->tm_zone does not exist since it is the alternative way
4433 of getting timezone info.
Brett Cannon18367812003-09-19 00:59:16 +00004434
4435 Red Hat 6.2 doesn't understand the southern hemisphere
Brett Cannon43802422005-02-10 20:48:03 +00004436 after New Year's Day.
Brett Cannon18367812003-09-19 00:59:16 +00004437 */
4438
Brett Cannon43802422005-02-10 20:48:03 +00004439 time_t groundhogday = 1044144000; /* GMT-based */
Brett Cannon18367812003-09-19 00:59:16 +00004440 time_t midyear = groundhogday + (365 * 24 * 3600 / 2);
4441
Neal Norwitz7f2588c2003-04-11 15:35:53 +00004442 putenv("TZ=UTC+0");
Guido van Rossumd11b62e2003-03-14 21:51:36 +00004443 tzset();
Brett Cannon18367812003-09-19 00:59:16 +00004444 if (localtime(&groundhogday)->tm_hour != 0)
4445 exit(1);
Brett Cannon43802422005-02-10 20:48:03 +00004446#if HAVE_TZNAME
4447 /* For UTC, tzname[1] is sometimes "", sometimes " " */
4448 if (strcmp(tzname[0], "UTC") ||
4449 (tzname[1][0] != 0 && tzname[1][0] != ' '))
4450 exit(1);
4451#endif
Brett Cannon18367812003-09-19 00:59:16 +00004452
Neal Norwitz7f2588c2003-04-11 15:35:53 +00004453 putenv("TZ=EST+5EDT,M4.1.0,M10.5.0");
Guido van Rossumd11b62e2003-03-14 21:51:36 +00004454 tzset();
Brett Cannon18367812003-09-19 00:59:16 +00004455 if (localtime(&groundhogday)->tm_hour != 19)
Guido van Rossumd11b62e2003-03-14 21:51:36 +00004456 exit(1);
Brett Cannon43802422005-02-10 20:48:03 +00004457#if HAVE_TZNAME
4458 if (strcmp(tzname[0], "EST") || strcmp(tzname[1], "EDT"))
4459 exit(1);
4460#endif
Brett Cannon18367812003-09-19 00:59:16 +00004461
4462 putenv("TZ=AEST-10AEDT-11,M10.5.0,M3.5.0");
4463 tzset();
4464 if (localtime(&groundhogday)->tm_hour != 11)
4465 exit(1);
Brett Cannon43802422005-02-10 20:48:03 +00004466#if HAVE_TZNAME
4467 if (strcmp(tzname[0], "AEST") || strcmp(tzname[1], "AEDT"))
4468 exit(1);
4469#endif
4470
4471#if HAVE_STRUCT_TM_TM_ZONE
Brett Cannon18367812003-09-19 00:59:16 +00004472 if (strcmp(localtime(&groundhogday)->tm_zone, "AEDT"))
4473 exit(1);
4474 if (strcmp(localtime(&midyear)->tm_zone, "AEST"))
4475 exit(1);
Brett Cannon43802422005-02-10 20:48:03 +00004476#endif
Brett Cannon18367812003-09-19 00:59:16 +00004477
Guido van Rossumd11b62e2003-03-14 21:51:36 +00004478 exit(0);
4479}
Matthias Klosec511b472010-05-08 11:01:39 +00004480]])],
4481[ac_cv_working_tzset=yes],
4482[ac_cv_working_tzset=no],
4483[ac_cv_working_tzset=no])])
Guido van Rossumd11b62e2003-03-14 21:51:36 +00004484AC_MSG_RESULT($ac_cv_working_tzset)
4485if test "$ac_cv_working_tzset" = yes
4486then
4487 AC_DEFINE(HAVE_WORKING_TZSET, 1,
4488 [Define if tzset() actually switches the local timezone in a meaningful way.])
4489fi
4490
Martin v. Löwis94717ed2002-09-09 14:24:16 +00004491# Look for subsecond timestamps in struct stat
4492AC_MSG_CHECKING(for tv_nsec in struct stat)
4493AC_CACHE_VAL(ac_cv_stat_tv_nsec,
Matthias Klosec511b472010-05-08 11:01:39 +00004494AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/stat.h>]], [[
Martin v. Löwis94717ed2002-09-09 14:24:16 +00004495struct stat st;
4496st.st_mtim.tv_nsec = 1;
Matthias Klosec511b472010-05-08 11:01:39 +00004497]])],
4498[ac_cv_stat_tv_nsec=yes],
4499[ac_cv_stat_tv_nsec=no]))
Martin v. Löwis94717ed2002-09-09 14:24:16 +00004500AC_MSG_RESULT($ac_cv_stat_tv_nsec)
4501if test "$ac_cv_stat_tv_nsec" = yes
4502then
4503 AC_DEFINE(HAVE_STAT_TV_NSEC, 1,
4504 [Define if you have struct stat.st_mtim.tv_nsec])
4505fi
4506
Martin v. Löwisebd9d5b2005-08-09 15:00:59 +00004507# Look for BSD style subsecond timestamps in struct stat
4508AC_MSG_CHECKING(for tv_nsec2 in struct stat)
4509AC_CACHE_VAL(ac_cv_stat_tv_nsec2,
Matthias Klosec511b472010-05-08 11:01:39 +00004510AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/stat.h>]], [[
Martin v. Löwisebd9d5b2005-08-09 15:00:59 +00004511struct stat st;
4512st.st_mtimespec.tv_nsec = 1;
Matthias Klosec511b472010-05-08 11:01:39 +00004513]])],
4514[ac_cv_stat_tv_nsec2=yes],
4515[ac_cv_stat_tv_nsec2=no]))
Martin v. Löwisebd9d5b2005-08-09 15:00:59 +00004516AC_MSG_RESULT($ac_cv_stat_tv_nsec2)
4517if test "$ac_cv_stat_tv_nsec2" = yes
4518then
4519 AC_DEFINE(HAVE_STAT_TV_NSEC2, 1,
4520 [Define if you have struct stat.st_mtimensec])
4521fi
4522
doko@ubuntu.comf27ec3e2014-04-17 20:11:19 +02004523# first curses configure check
4524ac_save_cppflags="$CPPFLAGS"
4525CPPFLAGS="$CPPFLAGS -I/usr/include/ncursesw"
4526
4527AC_CHECK_HEADERS(curses.h ncurses.h)
4528
4529# On Solaris, term.h requires curses.h
4530AC_CHECK_HEADERS(term.h,,,[
4531#ifdef HAVE_CURSES_H
4532#include <curses.h>
4533#endif
4534])
4535
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00004536# On HP/UX 11.0, mvwdelch is a block with a return statement
4537AC_MSG_CHECKING(whether mvwdelch is an expression)
4538AC_CACHE_VAL(ac_cv_mvwdelch_is_expression,
Matthias Klosec511b472010-05-08 11:01:39 +00004539AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <curses.h>]], [[
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00004540 int rtn;
4541 rtn = mvwdelch(0,0,0);
Matthias Klosec511b472010-05-08 11:01:39 +00004542]])],
4543[ac_cv_mvwdelch_is_expression=yes],
4544[ac_cv_mvwdelch_is_expression=no]))
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00004545AC_MSG_RESULT($ac_cv_mvwdelch_is_expression)
4546
4547if test "$ac_cv_mvwdelch_is_expression" = yes
4548then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00004549 AC_DEFINE(MVWDELCH_IS_EXPRESSION, 1,
4550 [Define if mvwdelch in curses.h is an expression.])
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00004551fi
4552
Miss Islington (bot)6ba0b582017-11-01 05:36:48 -07004553# Issue #25720: ncurses has introduced the NCURSES_OPAQUE symbol making opaque
4554# structs since version 5.7. If the macro is defined as zero before including
4555# [n]curses.h, ncurses will expose fields of the structs regardless of the
4556# configuration.
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00004557AC_MSG_CHECKING(whether WINDOW has _flags)
4558AC_CACHE_VAL(ac_cv_window_has_flags,
Miss Islington (bot)6ba0b582017-11-01 05:36:48 -07004559AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4560 #define NCURSES_OPAQUE 0
4561 #include <curses.h>
4562]], [[
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00004563 WINDOW *w;
4564 w->_flags = 0;
Matthias Klosec511b472010-05-08 11:01:39 +00004565]])],
4566[ac_cv_window_has_flags=yes],
4567[ac_cv_window_has_flags=no]))
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00004568AC_MSG_RESULT($ac_cv_window_has_flags)
4569
4570
4571if test "$ac_cv_window_has_flags" = yes
4572then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00004573 AC_DEFINE(WINDOW_HAS_FLAGS, 1,
4574 [Define if WINDOW in curses.h offers a field _flags.])
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00004575fi
4576
Miss Islington (bot)6ba0b582017-11-01 05:36:48 -07004577AC_MSG_CHECKING(for is_pad)
4578AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <curses.h>]], [[
4579#ifndef is_pad
4580void *x=is_pad
4581#endif
4582]])],
4583 [AC_DEFINE(HAVE_CURSES_IS_PAD, 1, Define if you have the 'is_pad' function or macro.)
4584 AC_MSG_RESULT(yes)],
4585 [AC_MSG_RESULT(no)]
4586)
4587
Walter Dörwald4994d952006-06-19 08:07:50 +00004588AC_MSG_CHECKING(for is_term_resized)
Matthias Klosec511b472010-05-08 11:01:39 +00004589AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <curses.h>]], [[void *x=is_term_resized]])],
4590 [AC_DEFINE(HAVE_CURSES_IS_TERM_RESIZED, 1, Define if you have the 'is_term_resized' function.)
4591 AC_MSG_RESULT(yes)],
4592 [AC_MSG_RESULT(no)]
Walter Dörwald4994d952006-06-19 08:07:50 +00004593)
4594
Walter Dörwald05fdbf12006-06-19 08:14:09 +00004595AC_MSG_CHECKING(for resize_term)
Matthias Klosec511b472010-05-08 11:01:39 +00004596AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <curses.h>]], [[void *x=resize_term]])],
4597 [AC_DEFINE(HAVE_CURSES_RESIZE_TERM, 1, Define if you have the 'resize_term' function.)
4598 AC_MSG_RESULT(yes)],
4599 [AC_MSG_RESULT(no)]
Walter Dörwald4994d952006-06-19 08:07:50 +00004600)
4601
Walter Dörwald05fdbf12006-06-19 08:14:09 +00004602AC_MSG_CHECKING(for resizeterm)
Matthias Klosec511b472010-05-08 11:01:39 +00004603AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <curses.h>]], [[void *x=resizeterm]])],
4604 [AC_DEFINE(HAVE_CURSES_RESIZETERM, 1, Define if you have the 'resizeterm' function.)
4605 AC_MSG_RESULT(yes)],
4606 [AC_MSG_RESULT(no)]
Walter Dörwald4994d952006-06-19 08:07:50 +00004607)
Serhiy Storchakae0fc1af2017-10-31 16:12:35 +02004608
4609AC_MSG_CHECKING(for immedok)
4610AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <curses.h>]], [[
4611#ifndef immedok
4612void *x=immedok
4613#endif
4614]])],
4615 [AC_DEFINE(HAVE_CURSES_IMMEDOK, 1, Define if you have the 'immedok' function.)
4616 AC_MSG_RESULT(yes)],
4617 [AC_MSG_RESULT(no)]
4618)
4619
4620AC_MSG_CHECKING(for syncok)
4621AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <curses.h>]], [[
4622#ifndef syncok
4623void *x=syncok
4624#endif
4625]])],
4626 [AC_DEFINE(HAVE_CURSES_SYNCOK, 1, Define if you have the 'syncok' function.)
4627 AC_MSG_RESULT(yes)],
4628 [AC_MSG_RESULT(no)]
4629)
4630
Miss Islington (bot)87c66e42017-11-01 06:11:18 -07004631AC_MSG_CHECKING(for wchgat)
4632AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <curses.h>]], [[
4633#ifndef wchgat
4634void *x=wchgat
4635#endif
4636]])],
4637 [AC_DEFINE(HAVE_CURSES_WCHGAT, 1, Define if you have the 'wchgat' function.)
4638 AC_MSG_RESULT(yes)],
4639 [AC_MSG_RESULT(no)]
4640)
4641
Serhiy Storchakae0fc1af2017-10-31 16:12:35 +02004642AC_MSG_CHECKING(for filter)
4643AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <curses.h>]], [[
4644#ifndef filter
4645void *x=filter
4646#endif
4647]])],
4648 [AC_DEFINE(HAVE_CURSES_FILTER, 1, Define if you have the 'filter' function.)
4649 AC_MSG_RESULT(yes)],
4650 [AC_MSG_RESULT(no)]
4651)
4652
4653AC_MSG_CHECKING(for has_key)
4654AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <curses.h>]], [[
4655#ifndef has_key
4656void *x=has_key
4657#endif
4658]])],
4659 [AC_DEFINE(HAVE_CURSES_HAS_KEY, 1, Define if you have the 'has_key' function.)
4660 AC_MSG_RESULT(yes)],
4661 [AC_MSG_RESULT(no)]
4662)
4663
4664AC_MSG_CHECKING(for typeahead)
4665AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <curses.h>]], [[
4666#ifndef typeahead
4667void *x=typeahead
4668#endif
4669]])],
4670 [AC_DEFINE(HAVE_CURSES_TYPEAHEAD, 1, Define if you have the 'typeahead' function.)
4671 AC_MSG_RESULT(yes)],
4672 [AC_MSG_RESULT(no)]
4673)
4674
4675AC_MSG_CHECKING(for use_env)
4676AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <curses.h>]], [[
4677#ifndef use_env
4678void *x=use_env
4679#endif
4680]])],
4681 [AC_DEFINE(HAVE_CURSES_USE_ENV, 1, Define if you have the 'use_env' function.)
4682 AC_MSG_RESULT(yes)],
4683 [AC_MSG_RESULT(no)]
4684)
doko@ubuntu.comf27ec3e2014-04-17 20:11:19 +02004685# last curses configure check
4686CPPFLAGS=$ac_save_cppflags
Walter Dörwald4994d952006-06-19 08:07:50 +00004687
doko@python.orgd65e2ba2013-01-31 23:52:03 +01004688AC_MSG_NOTICE([checking for device files])
Martin v. Löwisfefbc202006-10-17 18:59:23 +00004689
doko@python.orgd65e2ba2013-01-31 23:52:03 +01004690dnl NOTE: Inform user how to proceed with files when cross compiling.
4691if test "x$cross_compiling" = xyes; then
4692 if test "${ac_cv_file__dev_ptmx+set}" != set; then
4693 AC_MSG_CHECKING([for /dev/ptmx])
4694 AC_MSG_RESULT([not set])
4695 AC_MSG_ERROR([set ac_cv_file__dev_ptmx to yes/no in your CONFIG_SITE file when cross compiling])
4696 fi
4697 if test "${ac_cv_file__dev_ptc+set}" != set; then
4698 AC_MSG_CHECKING([for /dev/ptc])
4699 AC_MSG_RESULT([not set])
4700 AC_MSG_ERROR([set ac_cv_file__dev_ptc to yes/no in your CONFIG_SITE file when cross compiling])
4701 fi
Martin v. Löwisfefbc202006-10-17 18:59:23 +00004702fi
4703
doko@python.orgd65e2ba2013-01-31 23:52:03 +01004704AC_CHECK_FILE(/dev/ptmx, [], [])
4705if test "x$ac_cv_file__dev_ptmx" = xyes; then
4706 AC_DEFINE(HAVE_DEV_PTMX, 1,
4707 [Define to 1 if you have the /dev/ptmx device file.])
4708fi
4709AC_CHECK_FILE(/dev/ptc, [], [])
4710if test "x$ac_cv_file__dev_ptc" = xyes; then
Martin v. Löwisfefbc202006-10-17 18:59:23 +00004711 AC_DEFINE(HAVE_DEV_PTC, 1,
doko@python.orgd65e2ba2013-01-31 23:52:03 +01004712 [Define to 1 if you have the /dev/ptc device file.])
Martin v. Löwisfefbc202006-10-17 18:59:23 +00004713fi
Neal Norwitz865400f2003-03-21 01:42:58 +00004714
Mark Dickinson82864d12009-11-15 16:18:58 +00004715if test "$have_long_long" = yes
4716then
4717 AC_MSG_CHECKING(for %lld and %llu printf() format support)
4718 AC_CACHE_VAL(ac_cv_have_long_long_format,
Matthias Klosec511b472010-05-08 11:01:39 +00004719 AC_RUN_IFELSE([AC_LANG_SOURCE([[[
Mark Dickinson82864d12009-11-15 16:18:58 +00004720 #include <stdio.h>
4721 #include <stddef.h>
4722 #include <string.h>
4723
4724 #ifdef HAVE_SYS_TYPES_H
4725 #include <sys/types.h>
4726 #endif
4727
4728 int main()
4729 {
4730 char buffer[256];
4731
4732 if (sprintf(buffer, "%lld", (long long)123) < 0)
4733 return 1;
4734 if (strcmp(buffer, "123"))
4735 return 1;
4736
4737 if (sprintf(buffer, "%lld", (long long)-123) < 0)
4738 return 1;
4739 if (strcmp(buffer, "-123"))
4740 return 1;
4741
4742 if (sprintf(buffer, "%llu", (unsigned long long)123) < 0)
4743 return 1;
4744 if (strcmp(buffer, "123"))
4745 return 1;
4746
4747 return 0;
4748 }
Matthias Klosec511b472010-05-08 11:01:39 +00004749 ]]])],
4750 [ac_cv_have_long_long_format=yes],
4751 [ac_cv_have_long_long_format=no],
doko@python.orgd65e2ba2013-01-31 23:52:03 +01004752 [ac_cv_have_long_long_format="cross -- assuming no"
4753 if test x$GCC = xyes; then
4754 save_CFLAGS=$CFLAGS
4755 CFLAGS="$CFLAGS -Werror -Wformat"
4756 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4757 #include <stdio.h>
4758 #include <stddef.h>
4759 ]], [[
4760 char *buffer;
4761 sprintf(buffer, "%lld", (long long)123);
4762 sprintf(buffer, "%lld", (long long)-123);
4763 sprintf(buffer, "%llu", (unsigned long long)123);
4764 ]])],
4765 ac_cv_have_long_long_format=yes
4766 )
4767 CFLAGS=$save_CFLAGS
4768 fi])
Mark Dickinson82864d12009-11-15 16:18:58 +00004769 )
4770 AC_MSG_RESULT($ac_cv_have_long_long_format)
4771fi
4772
Mark Dickinson5ce84742009-12-31 20:48:04 +00004773if test "$ac_cv_have_long_long_format" = yes
Mark Dickinson82864d12009-11-15 16:18:58 +00004774then
4775 AC_DEFINE(PY_FORMAT_LONG_LONG, "ll",
4776 [Define to printf format modifier for long long type])
4777fi
4778
Ronald Oussoren315cd0c2009-11-19 16:25:21 +00004779if test $ac_sys_system = Darwin
4780then
4781 LIBS="$LIBS -framework CoreFoundation"
4782fi
4783
Mark Dickinson82864d12009-11-15 16:18:58 +00004784
Gregory P. Smithd8cb2d92009-11-02 02:02:38 +00004785AC_CACHE_CHECK([for %zd printf() format support], ac_cv_have_size_t_format, [dnl
Matthias Klosec511b472010-05-08 11:01:39 +00004786AC_RUN_IFELSE([AC_LANG_SOURCE([[
Alexandre Vassalottie7cf1182009-07-17 06:33:51 +00004787#include <stdio.h>
Brett Cannon09d12362006-05-11 05:11:33 +00004788#include <stddef.h>
4789#include <string.h>
4790
Christian Heimesdb3d6cb2007-12-16 21:39:43 +00004791#ifdef HAVE_SYS_TYPES_H
4792#include <sys/types.h>
4793#endif
Neal Norwitz4a8fbdb2006-09-22 08:16:26 +00004794
4795#ifdef HAVE_SSIZE_T
4796typedef ssize_t Py_ssize_t;
4797#elif SIZEOF_VOID_P == SIZEOF_LONG
4798typedef long Py_ssize_t;
4799#else
4800typedef int Py_ssize_t;
4801#endif
Brett Cannon09d12362006-05-11 05:11:33 +00004802
Christian Heimesdb3d6cb2007-12-16 21:39:43 +00004803int main()
4804{
4805 char buffer[256];
4806
Brett Cannon09d12362006-05-11 05:11:33 +00004807 if(sprintf(buffer, "%zd", (size_t)123) < 0)
4808 return 1;
4809
Neal Norwitz4a8fbdb2006-09-22 08:16:26 +00004810 if (strcmp(buffer, "123"))
Brett Cannon09d12362006-05-11 05:11:33 +00004811 return 1;
Neal Norwitz4a8fbdb2006-09-22 08:16:26 +00004812
4813 if (sprintf(buffer, "%zd", (Py_ssize_t)-123) < 0)
4814 return 1;
4815
4816 if (strcmp(buffer, "-123"))
4817 return 1;
4818
Brett Cannon09d12362006-05-11 05:11:33 +00004819 return 0;
Alexandre Vassalotti00900892009-07-17 05:26:39 +00004820}
Matthias Klosec511b472010-05-08 11:01:39 +00004821]])],
4822[ac_cv_have_size_t_format=yes],
4823[ac_cv_have_size_t_format=no],
4824[ac_cv_have_size_t_format="cross -- assuming yes"
4825])])
Gregory P. Smithd8cb2d92009-11-02 02:02:38 +00004826if test "$ac_cv_have_size_t_format" != no ; then
Alexandre Vassalotti00900892009-07-17 05:26:39 +00004827 AC_DEFINE(PY_FORMAT_SIZE_T, "z",
4828 [Define to printf format modifier for Py_ssize_t])
4829fi
Brett Cannon09d12362006-05-11 05:11:33 +00004830
Martin v. Löwis01c04012002-11-11 14:58:44 +00004831AC_CHECK_TYPE(socklen_t,,
4832 AC_DEFINE(socklen_t,int,
Matthias Klose5183ebd2010-04-24 16:38:36 +00004833 [Define to `int' if <sys/socket.h> does not define.]),[
Martin v. Löwis01c04012002-11-11 14:58:44 +00004834#ifdef HAVE_SYS_TYPES_H
4835#include <sys/types.h>
4836#endif
Guido van Rossum95713eb2000-05-18 20:53:31 +00004837#ifdef HAVE_SYS_SOCKET_H
4838#include <sys/socket.h>
4839#endif
Martin v. Löwis01c04012002-11-11 14:58:44 +00004840])
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00004841
R. David Murray1d9d16e2010-10-16 00:43:13 +00004842case $ac_sys_system in
4843AIX*)
4844 AC_DEFINE(HAVE_BROKEN_PIPE_BUF, 1, [Define if the system reports an invalid PIPE_BUF value.]) ;;
4845esac
4846
4847
Martin v. Löwis06f15bb2001-12-02 13:02:32 +00004848AC_SUBST(THREADHEADERS)
4849
4850for h in `(cd $srcdir;echo Python/thread_*.h)`
4851do
4852 THREADHEADERS="$THREADHEADERS \$(srcdir)/$h"
4853done
4854
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00004855AC_SUBST(SRCDIRS)
Victor Stinner5f4056a2017-04-28 03:41:40 +02004856SRCDIRS="Parser Objects Python Modules"
Andrew M. Kuchling8abedde2001-01-26 22:55:24 +00004857AC_MSG_CHECKING(for build directories)
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00004858for dir in $SRCDIRS; do
4859 if test ! -d $dir; then
4860 mkdir $dir
Fred Drake884d3ba2000-11-02 17:52:56 +00004861 fi
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00004862done
Benjamin Peterson2c992a02015-05-28 12:45:31 -05004863
4864# BEGIN_COMPUTED_GOTO
4865# Check for --with-computed-gotos
4866AC_MSG_CHECKING(for --with-computed-gotos)
4867AC_ARG_WITH(computed-gotos,
4868 AS_HELP_STRING([--with(out)-computed-gotos],
4869 [Use computed gotos in evaluation loop (enabled by default on supported compilers)]),
4870[
4871if test "$withval" = yes
4872then
4873 AC_DEFINE(USE_COMPUTED_GOTOS, 1,
4874 [Define if you want to use computed gotos in ceval.c.])
4875 AC_MSG_RESULT(yes)
4876fi
4877if test "$withval" = no
4878then
4879 AC_DEFINE(USE_COMPUTED_GOTOS, 0,
4880 [Define if you want to use computed gotos in ceval.c.])
4881 AC_MSG_RESULT(no)
4882fi
4883],
4884[AC_MSG_RESULT(no value specified)])
4885
4886AC_MSG_CHECKING(whether $CC supports computed gotos)
4887AC_CACHE_VAL(ac_cv_computed_gotos,
4888AC_RUN_IFELSE([AC_LANG_SOURCE([[[
4889int main(int argc, char **argv)
4890{
4891 static void *targets[1] = { &&LABEL1 };
4892 goto LABEL2;
4893LABEL1:
4894 return 0;
4895LABEL2:
4896 goto *targets[0];
4897 return 1;
4898}
4899]]])],
4900[ac_cv_computed_gotos=yes],
4901[ac_cv_computed_gotos=no],
4902[if test "${with_computed_gotos+set}" = set; then
4903 ac_cv_computed_gotos="$with_computed_gotos -- configured --with(out)-computed-gotos"
4904 else
4905 ac_cv_computed_gotos=no
4906 fi]))
4907AC_MSG_RESULT($ac_cv_computed_gotos)
4908case "$ac_cv_computed_gotos" in yes*)
4909 AC_DEFINE(HAVE_COMPUTED_GOTOS, 1,
4910 [Define if the C compiler supports computed gotos.])
4911esac
4912# END_COMPUTED_GOTO
4913
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00004914AC_MSG_RESULT(done)
Fred Drake036144d2000-10-26 17:09:35 +00004915
Ned Deily3f1d0b32014-11-20 02:11:03 -08004916# ensurepip option
4917AC_MSG_CHECKING(for ensurepip)
4918AC_ARG_WITH(ensurepip,
4919 [AS_HELP_STRING([--with(out)-ensurepip=@<:@=OPTION@:>@],
4920 ["install" or "upgrade" using bundled pip, default is "no"])],
4921 [],
4922 [with_ensurepip=no])
4923AS_CASE($with_ensurepip,
4924 [yes|upgrade],[ENSUREPIP=upgrade],
4925 [install],[ENSUREPIP=install],
4926 [no],[ENSUREPIP=no],
4927 [AC_MSG_ERROR([--with-ensurepip=upgrade|install|no])])
4928AC_MSG_RESULT($ENSUREPIP)
4929AC_SUBST(ENSUREPIP)
4930
Guido van Rossum627b2d71993-12-24 10:39:16 +00004931# generate output files
Antoine Pitrouf2caeed2009-05-24 20:23:57 +00004932AC_CONFIG_FILES(Makefile.pre Modules/Setup.config Misc/python.pc)
Antoine Pitrouaabdceb2010-09-10 20:03:17 +00004933AC_CONFIG_FILES([Modules/ld_so_aix], [chmod +x Modules/ld_so_aix])
Martin v. Löwis88afe662002-10-26 13:47:44 +00004934AC_OUTPUT
Neil Schemenauer61c51152001-01-26 16:18:16 +00004935
Martin v. Löwisf7afe952006-04-14 15:16:15 +00004936echo "creating Modules/Setup"
Neil Schemenauer61c51152001-01-26 16:18:16 +00004937if test ! -f Modules/Setup
4938then
4939 cp $srcdir/Modules/Setup.dist Modules/Setup
4940fi
4941
Martin v. Löwisf7afe952006-04-14 15:16:15 +00004942echo "creating Modules/Setup.local"
Neil Schemenauer61c51152001-01-26 16:18:16 +00004943if test ! -f Modules/Setup.local
4944then
4945 echo "# Edit this file for local setup changes" >Modules/Setup.local
4946fi
4947
4948echo "creating Makefile"
4949$SHELL $srcdir/Modules/makesetup -c $srcdir/Modules/config.c.in \
4950 -s Modules Modules/Setup.config \
Neil Schemenauerf8b71c52001-04-21 17:41:16 +00004951 Modules/Setup.local Modules/Setup
Skip Montanaro7221d932007-08-22 19:02:16 +00004952
4953case $ac_sys_system in
4954BeOS)
4955 AC_MSG_WARN([
4956
4957 Support for BeOS is deprecated as of Python 2.6.
4958 See PEP 11 for the gory details.
4959 ])
4960 ;;
4961*) ;;
4962esac
4963
Neil Schemenauer66252162001-02-19 04:47:42 +00004964mv config.c Modules
Gregory P. Smith6d8fdfc2016-09-07 23:28:23 -07004965
4966if test "$Py_OPT" = 'false' -a "$Py_DEBUG" != 'true'; then
4967 echo "" >&AS_MESSAGE_FD
4968 echo "" >&AS_MESSAGE_FD
4969 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 +00004970 echo "please run ./configure --enable-optimizations" >&AS_MESSAGE_FD
Gregory P. Smith6d8fdfc2016-09-07 23:28:23 -07004971 echo "" >&AS_MESSAGE_FD
4972 echo "" >&AS_MESSAGE_FD
4973fi