blob: 89692798273da6826d9f57b8071aa570464c8ec1 [file] [log] [blame]
Benjamin Petersonfbeb6b62008-05-26 16:04:49 +00001dnl ***********************************************
2dnl * Please run autoreconf to test your changes! *
3dnl ***********************************************
Martin v. Löwis88afe662002-10-26 13:47:44 +00004
5# Set VERSION so we only need to edit in one place (i.e., here)
Georg Brandl08a90122012-09-29 09:34:13 +02006m4_define(PYTHON_VERSION, 3.4)
Martin v. Löwis88afe662002-10-26 13:47:44 +00007
Barry Warsaw35f3a2c2010-09-03 18:30:30 +00008AC_PREREQ(2.65)
Alexandre Vassalottib89910f2009-07-18 00:33:23 +00009
Georg Brandle2e15612009-05-20 18:25:10 +000010AC_INIT(python, PYTHON_VERSION, http://bugs.python.org/)
Benjamin Peterson8c6f88e2011-05-31 20:52:17 -050011
Trent Nelson4d4ec652012-10-16 08:51:24 -040012AC_SUBST(BASECPPFLAGS)
Trent Nelson5595ab52012-10-17 04:47:31 -040013if test "$abs_srcdir" != "$abs_builddir"; then
Trent Nelson4d4ec652012-10-16 08:51:24 -040014 # If we're building out-of-tree, we need to make sure the following
15 # resources get picked up before their $srcdir counterparts.
16 # Objects/ -> typeslots.inc
17 # Include/ -> Python-ast.h, graminit.h
18 # Python/ -> importlib.h
19 # (A side effect of this is that these resources will automatically be
20 # regenerated when building out-of-tree, regardless of whether or not
21 # the $srcdir counterpart is up-to-date. This is an acceptable trade
22 # off.)
23 BASECPPFLAGS="-IObjects -IInclude -IPython"
24else
25 BASECPPFLAGS=""
26fi
27
Benjamin Peterson8c6f88e2011-05-31 20:52:17 -050028AC_SUBST(HGVERSION)
29AC_SUBST(HGTAG)
30AC_SUBST(HGBRANCH)
31
Antoine Pitroud3b2aef2011-07-27 01:22:41 +020032if test -e $srcdir/.hg/dirstate
Benjamin Peterson8c6f88e2011-05-31 20:52:17 -050033then
34AC_CHECK_PROG(HAS_HG, hg, found, not-found)
35else
36HAS_HG=no-repository
37fi
38if test $HAS_HG = found
39then
40 HGVERSION="hg id -i \$(srcdir)"
41 HGTAG="hg id -t \$(srcdir)"
42 HGBRANCH="hg id -b \$(srcdir)"
43else
44 HGVERSION=""
45 HGTAG=""
46 HGBRANCH=""
47fi
48
Martin v. Löwis88afe662002-10-26 13:47:44 +000049AC_CONFIG_SRCDIR([Include/object.h])
Martin v. Löwis4f1cd8b2001-07-26 13:41:06 +000050AC_CONFIG_HEADER(pyconfig.h)
Guido van Rossum627b2d71993-12-24 10:39:16 +000051
Matthias Kloseca2f6ec2012-03-15 21:30:11 +010052AC_CANONICAL_HOST
doko@python.orga10e4a92013-01-25 18:45:12 +010053AC_SUBST(build)
54AC_SUBST(host)
Matthias Kloseca2f6ec2012-03-15 21:30:11 +010055
Ned Deilyfcbc2462014-08-22 13:32:49 -070056# pybuilddir.txt will be created by --generate-posix-vars in the Makefile
57rm -f pybuilddir.txt
58
doko@ubuntu.com1abe1c52012-06-30 20:42:45 +020059if test "$cross_compiling" = yes; then
60 AC_MSG_CHECKING([for python interpreter for cross build])
61 if test -z "$PYTHON_FOR_BUILD"; then
62 for interp in python$PACKAGE_VERSION python3 python; do
63 which $interp >/dev/null 2>&1 || continue
64 if $interp -c 'import sys;sys.exit(not sys.version_info@<:@:2@:>@ >= (3,3))'; then
65 break
66 fi
67 interp=
68 done
69 if test x$interp = x; then
70 AC_MSG_ERROR([python$PACKAGE_VERSION interpreter not found])
71 fi
72 AC_MSG_RESULT($interp)
doko@python.org244b6872013-01-26 12:08:25 +010073 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@ubuntu.com1abe1c52012-06-30 20:42:45 +020074 fi
Christian Heimes954ac032012-12-12 13:10:21 +010075elif test "$cross_compiling" = maybe; then
76 AC_MSG_ERROR([Cross compiling required --host=HOST-TUPLE and --build=ARCH])
doko@ubuntu.com1abe1c52012-06-30 20:42:45 +020077else
78 PYTHON_FOR_BUILD='./$(BUILDPYTHON) -E'
79fi
80AC_SUBST(PYTHON_FOR_BUILD)
81
Benjamin Petersond23f8222009-04-05 19:13:16 +000082dnl Ensure that if prefix is specified, it does not end in a slash. If
83dnl it does, we get path names containing '//' which is both ugly and
84dnl can cause trouble.
85
86dnl Last slash shouldn't be stripped if prefix=/
87if test "$prefix" != "/"; then
88 prefix=`echo "$prefix" | sed -e 's/\/$//g'`
89fi
90
Martin v. Löwis8316feb2003-06-14 07:48:07 +000091dnl This is for stuff that absolutely must end up in pyconfig.h.
92dnl Please use pyport.h instead, if possible.
Martin v. Löwisbddf5a52002-11-11 13:37:28 +000093AH_TOP([
94#ifndef Py_PYCONFIG_H
95#define Py_PYCONFIG_H
96])
Martin v. Löwis11437992002-04-12 09:54:03 +000097AH_BOTTOM([
Martin v. Löwis11437992002-04-12 09:54:03 +000098/* Define the macros needed if on a UnixWare 7.x system. */
99#if defined(__USLC__) && defined(__SCO_VERSION__)
100#define STRICT_SYSV_CURSES /* Don't use ncurses extensions */
101#endif
Martin v. Löwisbddf5a52002-11-11 13:37:28 +0000102
103#endif /*Py_PYCONFIG_H*/
Martin v. Löwis11437992002-04-12 09:54:03 +0000104])
105
Martin v. Löwis8316feb2003-06-14 07:48:07 +0000106# We don't use PACKAGE_ variables, and they cause conflicts
107# with other autoconf-based packages that include Python.h
108grep -v 'define PACKAGE_' <confdefs.h >confdefs.h.new
109rm confdefs.h
110mv confdefs.h.new confdefs.h
111
Guido van Rossum642b6781997-07-19 19:35:41 +0000112AC_SUBST(VERSION)
Martin v. Löwis88afe662002-10-26 13:47:44 +0000113VERSION=PYTHON_VERSION
Guido van Rossum642b6781997-07-19 19:35:41 +0000114
Georg Brandlde7d8342010-09-03 22:19:07 +0000115# Version number of Python's own shared library file.
Martin v. Löwis1142de32002-03-29 16:28:31 +0000116AC_SUBST(SOVERSION)
117SOVERSION=1.0
118
Martin v. Löwis6f18a3c2002-07-20 08:51:52 +0000119# The later defininition of _XOPEN_SOURCE disables certain features
120# on Linux, so we need _GNU_SOURCE to re-enable them (makedev, tm_zone).
121AC_DEFINE(_GNU_SOURCE, 1, [Define on Linux to activate all library features])
122
Martin v. Löwisbcd93962003-05-03 10:32:18 +0000123# The later defininition of _XOPEN_SOURCE and _POSIX_C_SOURCE disables
124# certain features on NetBSD, so we need _NETBSD_SOURCE to re-enable
125# them.
126AC_DEFINE(_NETBSD_SOURCE, 1, [Define on NetBSD to activate all library features])
127
Andrew MacIntyreabccf412003-07-02 13:53:25 +0000128# The later defininition of _XOPEN_SOURCE and _POSIX_C_SOURCE disables
129# certain features on FreeBSD, so we need __BSD_VISIBLE to re-enable
130# them.
131AC_DEFINE(__BSD_VISIBLE, 1, [Define on FreeBSD to activate all library features])
132
Martin v. Löwisd6320502004-08-12 13:45:08 +0000133# The later defininition of _XOPEN_SOURCE and _POSIX_C_SOURCE disables
134# u_int on Irix 5.3. Defining _BSD_TYPES brings it back.
135AC_DEFINE(_BSD_TYPES, 1, [Define on Irix to enable u_int])
136
Georg Brandlfcaf9102008-07-16 02:17:56 +0000137# The later defininition of _XOPEN_SOURCE and _POSIX_C_SOURCE disables
138# certain features on Mac OS X, so we need _DARWIN_C_SOURCE to re-enable
139# them.
140AC_DEFINE(_DARWIN_C_SOURCE, 1, [Define on Darwin to activate all library features])
141
142
Martin v. Löwise981a4e2002-11-11 13:26:51 +0000143define_xopen_source=yes
Martin v. Löwis6f18a3c2002-07-20 08:51:52 +0000144
Neil Schemenauer4edbc2a2001-03-22 00:34:03 +0000145# Arguments passed to configure.
146AC_SUBST(CONFIG_ARGS)
147CONFIG_ARGS="$ac_configure_args"
148
Ronald Oussoren8af24c12010-02-07 12:03:42 +0000149AC_MSG_CHECKING([for --enable-universalsdk])
Thomas Wouters477c8d52006-05-27 19:21:47 +0000150AC_ARG_ENABLE(universalsdk,
Ned Deilycbfb9a52012-06-23 16:02:19 -0700151 AS_HELP_STRING([--enable-universalsdk@<:@=SDKDIR@:>@], [Build fat binary against Mac OS X SDK]),
Thomas Wouters477c8d52006-05-27 19:21:47 +0000152[
153 case $enableval in
154 yes)
Ned Deilycbfb9a52012-06-23 16:02:19 -0700155 # Locate the best usable SDK, see Mac/README.txt for more
156 # information
157 enableval="`/usr/bin/xcodebuild -version -sdk macosx Path 2>/dev/null`"
Ned Deily87adb6e2013-10-18 21:09:56 -0700158 if ! ( echo $enableval | grep -E '\.sdk' 1>/dev/null )
Ronald Oussoren8af24c12010-02-07 12:03:42 +0000159 then
Ned Deilycbfb9a52012-06-23 16:02:19 -0700160 enableval=/Developer/SDKs/MacOSX10.4u.sdk
161 if test ! -d "${enableval}"
162 then
163 enableval=/
164 fi
Ronald Oussoren8af24c12010-02-07 12:03:42 +0000165 fi
Thomas Wouters477c8d52006-05-27 19:21:47 +0000166 ;;
167 esac
168 case $enableval in
169 no)
170 UNIVERSALSDK=
171 enable_universalsdk=
172 ;;
173 *)
174 UNIVERSALSDK=$enableval
Ronald Oussoren8af24c12010-02-07 12:03:42 +0000175 if test ! -d "${UNIVERSALSDK}"
176 then
177 AC_MSG_ERROR([--enable-universalsdk specifies non-existing SDK: ${UNIVERSALSDK}])
178 fi
Thomas Wouters477c8d52006-05-27 19:21:47 +0000179 ;;
180 esac
Ronald Oussoren8af24c12010-02-07 12:03:42 +0000181
Thomas Wouters477c8d52006-05-27 19:21:47 +0000182],[
183 UNIVERSALSDK=
184 enable_universalsdk=
185])
Ronald Oussoren8af24c12010-02-07 12:03:42 +0000186if test -n "${UNIVERSALSDK}"
187then
188 AC_MSG_RESULT(${UNIVERSALSDK})
189else
190 AC_MSG_RESULT(no)
191fi
Thomas Wouters477c8d52006-05-27 19:21:47 +0000192AC_SUBST(UNIVERSALSDK)
193
Benjamin Peterson6794aa32008-07-16 20:33:37 +0000194AC_SUBST(ARCH_RUN_32BIT)
Ned Deily87adb6e2013-10-18 21:09:56 -0700195ARCH_RUN_32BIT=""
Benjamin Peterson6794aa32008-07-16 20:33:37 +0000196
Ned Deilycbfb9a52012-06-23 16:02:19 -0700197# For backward compatibility reasons we prefer to select '32-bit' if available,
198# otherwise use 'intel'
Georg Brandlfcaf9102008-07-16 02:17:56 +0000199UNIVERSAL_ARCHS="32-bit"
Ned Deilycbfb9a52012-06-23 16:02:19 -0700200if test "`uname -s`" = "Darwin"
201then
202 if test -n "${UNIVERSALSDK}"
203 then
Ned Deily87adb6e2013-10-18 21:09:56 -0700204 if test -z "`/usr/bin/file -L "${UNIVERSALSDK}/usr/lib/libSystem.dylib" | grep ppc`"
Ned Deilycbfb9a52012-06-23 16:02:19 -0700205 then
206 UNIVERSAL_ARCHS="intel"
207 fi
208 fi
209fi
210
Ronald Oussoren6f6c5622009-12-24 14:03:19 +0000211AC_SUBST(LIPO_32BIT_FLAGS)
Georg Brandlfcaf9102008-07-16 02:17:56 +0000212AC_MSG_CHECKING(for --with-universal-archs)
213AC_ARG_WITH(universal-archs,
Ned Deily87adb6e2013-10-18 21:09:56 -0700214 AS_HELP_STRING([--with-universal-archs=ARCH], [select architectures for universal build ("32-bit", "64-bit", "3-way", "intel", "intel-32", or "all")]),
Georg Brandlfcaf9102008-07-16 02:17:56 +0000215[
Georg Brandlfcaf9102008-07-16 02:17:56 +0000216 UNIVERSAL_ARCHS="$withval"
217],
Ned Deily87adb6e2013-10-18 21:09:56 -0700218[])
219if test -n "${UNIVERSALSDK}"
220then
221 AC_MSG_RESULT(${UNIVERSAL_ARCHS})
222else
223 AC_MSG_RESULT(no)
224fi
Georg Brandlfcaf9102008-07-16 02:17:56 +0000225
Christian Heimes81ee3ef2008-05-04 22:42:01 +0000226AC_ARG_WITH(framework-name,
Matthias Klose2b8733f2010-04-25 18:34:36 +0000227 AS_HELP_STRING([--with-framework-name=FRAMEWORK],
Matthias Klosec80c93f2010-04-24 17:04:35 +0000228 [specify an alternate name of the framework built with --enable-framework]),
Christian Heimes81ee3ef2008-05-04 22:42:01 +0000229[
230 PYTHONFRAMEWORK=${withval}
231 PYTHONFRAMEWORKDIR=${withval}.framework
232 PYTHONFRAMEWORKIDENTIFIER=org.python.`echo $withval | tr '[A-Z]' '[a-z]'`
233 ],[
234 PYTHONFRAMEWORK=Python
235 PYTHONFRAMEWORKDIR=Python.framework
236 PYTHONFRAMEWORKIDENTIFIER=org.python.python
237])
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000238dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000239AC_ARG_ENABLE(framework,
Matthias Klose2b8733f2010-04-25 18:34:36 +0000240 AS_HELP_STRING([--enable-framework@<:@=INSTALLDIR@:>@], [Build (MacOSX|Darwin) framework]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000241[
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000242 case $enableval in
243 yes)
244 enableval=/Library/Frameworks
Jack Jansen127e56e2001-09-11 14:41:54 +0000245 esac
246 case $enableval in
247 no)
248 PYTHONFRAMEWORK=
249 PYTHONFRAMEWORKDIR=no-framework
250 PYTHONFRAMEWORKPREFIX=
251 PYTHONFRAMEWORKINSTALLDIR=
Thomas Wouters477c8d52006-05-27 19:21:47 +0000252 FRAMEWORKINSTALLFIRST=
253 FRAMEWORKINSTALLLAST=
Thomas Wouters73e5a5b2006-06-08 15:35:45 +0000254 FRAMEWORKALTINSTALLFIRST=
255 FRAMEWORKALTINSTALLLAST=
Ned Deilyb8f944f2013-11-21 22:42:25 -0800256 FRAMEWORKPYTHONW=
Thomas Wouters73e5a5b2006-06-08 15:35:45 +0000257 if test "x${prefix}" = "xNONE"; then
258 FRAMEWORKUNIXTOOLSPREFIX="${ac_default_prefix}"
259 else
260 FRAMEWORKUNIXTOOLSPREFIX="${prefix}"
261 fi
Jack Jansen127e56e2001-09-11 14:41:54 +0000262 enable_framework=
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000263 ;;
264 *)
Ronald Oussoren86b33c82010-04-30 11:41:56 +0000265 PYTHONFRAMEWORKPREFIX="${enableval}"
Jack Jansen127e56e2001-09-11 14:41:54 +0000266 PYTHONFRAMEWORKINSTALLDIR=$PYTHONFRAMEWORKPREFIX/$PYTHONFRAMEWORKDIR
Thomas Wouters477c8d52006-05-27 19:21:47 +0000267 FRAMEWORKINSTALLFIRST="frameworkinstallstructure"
Ronald Oussorenf6ccbf62009-06-02 10:55:56 +0000268 FRAMEWORKALTINSTALLFIRST="frameworkinstallstructure "
Ronald Oussoren6f6c5622009-12-24 14:03:19 +0000269 FRAMEWORKINSTALLLAST="frameworkinstallmaclib frameworkinstallapps frameworkinstallunixtools"
270 FRAMEWORKALTINSTALLLAST="frameworkinstallmaclib frameworkinstallapps frameworkaltinstallunixtools"
Ned Deilyb8f944f2013-11-21 22:42:25 -0800271 FRAMEWORKPYTHONW="frameworkpythonw"
Ronald Oussoren86b33c82010-04-30 11:41:56 +0000272 FRAMEWORKINSTALLAPPSPREFIX="/Applications"
Georg Brandlfcaf9102008-07-16 02:17:56 +0000273
Thomas Wouters73e5a5b2006-06-08 15:35:45 +0000274 if test "x${prefix}" = "xNONE" ; then
275 FRAMEWORKUNIXTOOLSPREFIX="${ac_default_prefix}"
Ronald Oussoren86b33c82010-04-30 11:41:56 +0000276
Thomas Wouters73e5a5b2006-06-08 15:35:45 +0000277 else
278 FRAMEWORKUNIXTOOLSPREFIX="${prefix}"
279 fi
Ronald Oussoren86b33c82010-04-30 11:41:56 +0000280
281 case "${enableval}" in
282 /System*)
283 FRAMEWORKINSTALLAPPSPREFIX="/Applications"
284 if test "${prefix}" = "NONE" ; then
285 # See below
286 FRAMEWORKUNIXTOOLSPREFIX="/usr"
287 fi
288 ;;
289
290 /Library*)
291 FRAMEWORKINSTALLAPPSPREFIX="/Applications"
292 ;;
293
294 */Library/Frameworks)
295 MDIR="`dirname "${enableval}"`"
296 MDIR="`dirname "${MDIR}"`"
297 FRAMEWORKINSTALLAPPSPREFIX="${MDIR}/Applications"
298
299 if test "${prefix}" = "NONE"; then
300 # User hasn't specified the
301 # --prefix option, but wants to install
302 # the framework in a non-default location,
303 # ensure that the compatibility links get
304 # installed relative to that prefix as well
305 # instead of in /usr/local.
306 FRAMEWORKUNIXTOOLSPREFIX="${MDIR}"
307 fi
308 ;;
309
310 *)
311 FRAMEWORKINSTALLAPPSPREFIX="/Applications"
312 ;;
313 esac
314
Jack Jansen127e56e2001-09-11 14:41:54 +0000315 prefix=$PYTHONFRAMEWORKINSTALLDIR/Versions/$VERSION
Thomas Wouters477c8d52006-05-27 19:21:47 +0000316
Christian Heimes81ee3ef2008-05-04 22:42:01 +0000317 # Add files for Mac specific code to the list of output
Thomas Wouters477c8d52006-05-27 19:21:47 +0000318 # files:
Thomas Wouters73e5a5b2006-06-08 15:35:45 +0000319 AC_CONFIG_FILES(Mac/Makefile)
320 AC_CONFIG_FILES(Mac/PythonLauncher/Makefile)
Christian Heimes81ee3ef2008-05-04 22:42:01 +0000321 AC_CONFIG_FILES(Mac/Resources/framework/Info.plist)
322 AC_CONFIG_FILES(Mac/Resources/app/Info.plist)
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000323 esac
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000324 ],[
325 PYTHONFRAMEWORK=
Jack Jansen127e56e2001-09-11 14:41:54 +0000326 PYTHONFRAMEWORKDIR=no-framework
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000327 PYTHONFRAMEWORKPREFIX=
328 PYTHONFRAMEWORKINSTALLDIR=
Thomas Wouters477c8d52006-05-27 19:21:47 +0000329 FRAMEWORKINSTALLFIRST=
330 FRAMEWORKINSTALLLAST=
Thomas Wouters73e5a5b2006-06-08 15:35:45 +0000331 FRAMEWORKALTINSTALLFIRST=
332 FRAMEWORKALTINSTALLLAST=
Ned Deilyb8f944f2013-11-21 22:42:25 -0800333 FRAMEWORKPYTHONW=
Thomas Wouters73e5a5b2006-06-08 15:35:45 +0000334 if test "x${prefix}" = "xNONE" ; then
335 FRAMEWORKUNIXTOOLSPREFIX="${ac_default_prefix}"
336 else
337 FRAMEWORKUNIXTOOLSPREFIX="${prefix}"
338 fi
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000339 enable_framework=
Georg Brandlfcaf9102008-07-16 02:17:56 +0000340
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000341])
342AC_SUBST(PYTHONFRAMEWORK)
Christian Heimes81ee3ef2008-05-04 22:42:01 +0000343AC_SUBST(PYTHONFRAMEWORKIDENTIFIER)
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000344AC_SUBST(PYTHONFRAMEWORKDIR)
345AC_SUBST(PYTHONFRAMEWORKPREFIX)
346AC_SUBST(PYTHONFRAMEWORKINSTALLDIR)
Thomas Wouters477c8d52006-05-27 19:21:47 +0000347AC_SUBST(FRAMEWORKINSTALLFIRST)
348AC_SUBST(FRAMEWORKINSTALLLAST)
Thomas Wouters73e5a5b2006-06-08 15:35:45 +0000349AC_SUBST(FRAMEWORKALTINSTALLFIRST)
350AC_SUBST(FRAMEWORKALTINSTALLLAST)
Ned Deilyb8f944f2013-11-21 22:42:25 -0800351AC_SUBST(FRAMEWORKPYTHONW)
Thomas Wouters73e5a5b2006-06-08 15:35:45 +0000352AC_SUBST(FRAMEWORKUNIXTOOLSPREFIX)
Ronald Oussoren86b33c82010-04-30 11:41:56 +0000353AC_SUBST(FRAMEWORKINSTALLAPPSPREFIX)
Guido van Rossum4b6b5791996-09-09 20:09:34 +0000354
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000355##AC_ARG_WITH(dyld,
Matthias Klose2b8733f2010-04-25 18:34:36 +0000356## AS_HELP_STRING([--with-dyld],
Matthias Klosec80c93f2010-04-24 17:04:35 +0000357## [Use (OpenStep|Rhapsody) dynamic linker]))
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000358##
Guido van Rossumb418f891996-07-30 18:06:02 +0000359# Set name for machine-dependent library files
doko@python.orgeab42bf2013-01-26 18:57:19 +0100360AC_ARG_VAR([MACHDEP], [name for machine-dependent library files])
Guido van Rossumb418f891996-07-30 18:06:02 +0000361AC_MSG_CHECKING(MACHDEP)
362if test -z "$MACHDEP"
363then
Matthias Klosedf2aecb2012-03-15 22:19:28 +0100364 # avoid using uname for cross builds
365 if test "$cross_compiling" = yes; then
doko@python.org44bbbda2013-01-25 14:44:00 +0100366 # ac_sys_system and ac_sys_release are used for setting
367 # a lot of different things including 'define_xopen_source'
368 # in the case statement below.
Matthias Klosedf2aecb2012-03-15 22:19:28 +0100369 case "$host" in
370 *-*-linux*)
371 ac_sys_system=Linux
372 ;;
373 *-*-cygwin*)
374 ac_sys_system=Cygwin
375 ;;
376 *)
377 # for now, limit cross builds to known configurations
378 MACHDEP="unknown"
379 AC_MSG_ERROR([cross build not supported for $host])
380 esac
381 ac_sys_release=
382 else
Guido van Rossum4b6b5791996-09-09 20:09:34 +0000383 ac_sys_system=`uname -s`
Benjamin Peterson8719ad52009-09-11 22:24:02 +0000384 if test "$ac_sys_system" = "AIX" \
Martin v. Löwis21ee4092002-09-30 16:19:48 +0000385 -o "$ac_sys_system" = "UnixWare" -o "$ac_sys_system" = "OpenUNIX"; then
Guido van Rossum4b6b5791996-09-09 20:09:34 +0000386 ac_sys_release=`uname -v`
Guido van Rossumb418f891996-07-30 18:06:02 +0000387 else
Guido van Rossum4b6b5791996-09-09 20:09:34 +0000388 ac_sys_release=`uname -r`
Guido van Rossumb418f891996-07-30 18:06:02 +0000389 fi
Matthias Klosedf2aecb2012-03-15 22:19:28 +0100390 fi
391 ac_md_system=`echo $ac_sys_system |
392 tr -d '[/ ]' | tr '[[A-Z]]' '[[a-z]]'`
393 ac_md_release=`echo $ac_sys_release |
394 tr -d '[/ ]' | sed 's/^[[A-Z]]\.//' | sed 's/\..*//'`
395 MACHDEP="$ac_md_system$ac_md_release"
Guido van Rossum4b6b5791996-09-09 20:09:34 +0000396
Matthias Klosedf2aecb2012-03-15 22:19:28 +0100397 case $MACHDEP in
Victor Stinner7209ff22011-08-21 00:00:16 +0200398 linux*) MACHDEP="linux";;
Andrew M. Kuchling5a3e4cb2001-07-20 19:29:04 +0000399 cygwin*) MACHDEP="cygwin";;
Jack Jansen8a97f4a2001-12-05 23:27:32 +0000400 darwin*) MACHDEP="darwin";;
doko@ubuntu.comba015832012-06-30 16:52:05 +0200401 irix646) MACHDEP="irix6";;
Guido van Rossumb97ef171997-09-28 05:44:03 +0000402 '') MACHDEP="unknown";;
Matthias Klosedf2aecb2012-03-15 22:19:28 +0100403 esac
Guido van Rossumb418f891996-07-30 18:06:02 +0000404fi
doko@ubuntu.com1abe1c52012-06-30 20:42:45 +0200405
406AC_SUBST(_PYTHON_HOST_PLATFORM)
407if test "$cross_compiling" = yes; then
408 case "$host" in
409 *-*-linux*)
410 case "$host_cpu" in
411 arm*)
412 _host_cpu=arm
413 ;;
414 *)
415 _host_cpu=$host_cpu
416 esac
417 ;;
418 *-*-cygwin*)
419 _host_cpu=
420 ;;
421 *)
422 # for now, limit cross builds to known configurations
423 MACHDEP="unknown"
424 AC_MSG_ERROR([cross build not supported for $host])
425 esac
426 _PYTHON_HOST_PLATFORM="$MACHDEP${_host_cpu:+-$_host_cpu}"
427fi
Jack Jansen83f898c2002-12-30 22:23:40 +0000428
Martin v. Löwise981a4e2002-11-11 13:26:51 +0000429# Some systems cannot stand _XOPEN_SOURCE being defined at all; they
430# disable features if it is defined, without any means to access these
431# features as extensions. For these systems, we skip the definition of
432# _XOPEN_SOURCE. Before adding a system to the list to gain access to
433# some feature, make sure there is no alternative way to access this
434# feature. Also, when using wildcards, make sure you have verified the
435# need for not defining _XOPEN_SOURCE on all systems matching the
436# wildcard, and that the wildcard does not include future systems
437# (which may remove their limitations).
438dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
439case $ac_sys_system/$ac_sys_release in
440 # On OpenBSD, select(2) is not available if _XOPEN_SOURCE is defined,
441 # even though select is a POSIX function. Reported by J. Ribbens.
Martin v. Löwis76bafc62003-10-03 13:47:44 +0000442 # Reconfirmed for OpenBSD 3.3 by Zachary Hamm, for 3.4 by Jason Ish.
Martin v. Löwis19ed3c82010-02-15 21:45:06 +0000443 # In addition, Stefan Krah confirms that issue #1244610 exists through
444 # OpenBSD 4.6, but is fixed in 4.7.
Charles-François Natali54ef40b2011-07-22 23:52:02 +0200445 OpenBSD/2.* | OpenBSD/3.* | OpenBSD/4.@<:@0123456@:>@)
Christian Heimes5b5e81c2007-12-31 16:14:33 +0000446 define_xopen_source=no
447 # OpenBSD undoes our definition of __BSD_VISIBLE if _XOPEN_SOURCE is
448 # also defined. This can be overridden by defining _BSD_SOURCE
449 # As this has a different meaning on Linux, only define it on OpenBSD
450 AC_DEFINE(_BSD_SOURCE, 1, [Define on OpenBSD to activate all library features])
451 ;;
Charles-François Natali54ef40b2011-07-22 23:52:02 +0200452 OpenBSD/*)
Martin v. Löwis7671efc2010-02-15 08:35:16 +0000453 # OpenBSD undoes our definition of __BSD_VISIBLE if _XOPEN_SOURCE is
454 # also defined. This can be overridden by defining _BSD_SOURCE
455 # As this has a different meaning on Linux, only define it on OpenBSD
456 AC_DEFINE(_BSD_SOURCE, 1, [Define on OpenBSD to activate all library features])
457 ;;
Thomas Wouters89f507f2006-12-13 04:49:30 +0000458 # Defining _XOPEN_SOURCE on NetBSD version prior to the introduction of
459 # _NETBSD_SOURCE disables certain features (eg. setgroups). Reported by
460 # Marc Recht
Benjamin Petersonf608c612008-11-16 18:33:53 +0000461 NetBSD/1.5 | NetBSD/1.5.* | NetBSD/1.6 | NetBSD/1.6.* | NetBSD/1.6@<:@A-S@:>@)
Martin v. Löwise981a4e2002-11-11 13:26:51 +0000462 define_xopen_source=no;;
Martin v. Löwis1a415762010-05-28 15:44:20 +0000463 # From the perspective of Solaris, _XOPEN_SOURCE is not so much a
464 # request to enable features supported by the standard as a request
465 # to disable features not supported by the standard. The best way
466 # for Python to use Solaris is simply to leave _XOPEN_SOURCE out
467 # entirely and define __EXTENSIONS__ instead.
468 SunOS/*)
Martin v. Löwisa9d71422003-03-28 18:43:31 +0000469 define_xopen_source=no;;
Martin v. Löwisc2409b42003-05-11 05:53:41 +0000470 # On UnixWare 7, u_long is never defined with _XOPEN_SOURCE,
471 # but used in /usr/include/netinet/tcp.h. Reported by Tim Rice.
Martin v. Löwis253d1f42004-05-07 19:14:14 +0000472 # Reconfirmed for 7.1.4 by Martin v. Loewis.
473 OpenUNIX/8.0.0| UnixWare/7.1.@<:@0-4@:>@)
Martin v. Löwisc2409b42003-05-11 05:53:41 +0000474 define_xopen_source=no;;
475 # On OpenServer 5, u_short is never defined with _XOPEN_SOURCE,
Martin v. Löwis53e73c32003-05-05 05:13:18 +0000476 # but used in struct sockaddr.sa_family. Reported by Tim Rice.
Martin v. Löwisc2409b42003-05-11 05:53:41 +0000477 SCO_SV/3.2)
Martin v. Löwis53e73c32003-05-05 05:13:18 +0000478 define_xopen_source=no;;
Martin v. Löwisb37509b2008-11-04 20:45:29 +0000479 # On FreeBSD 4, the math functions C89 does not cover are never defined
480 # with _XOPEN_SOURCE and __BSD_VISIBLE does not re-enable them.
481 FreeBSD/4.*)
482 define_xopen_source=no;;
483 # On MacOS X 10.2, a bug in ncurses.h means that it craps out if
484 # _XOPEN_EXTENDED_SOURCE is defined. Apparently, this is fixed in 10.3, which
485 # identifies itself as Darwin/7.*
486 # On Mac OS X 10.4, defining _POSIX_C_SOURCE or _XOPEN_SOURCE
487 # disables platform specific features beyond repair.
488 # On Mac OS X 10.3, defining _POSIX_C_SOURCE or _XOPEN_SOURCE
489 # has no effect, don't bother defining them
490 Darwin/@<:@6789@:>@.*)
Anthony Baxter6169c6b2003-10-04 07:46:23 +0000491 define_xopen_source=no;;
Ronald Oussoren92fb9412010-03-09 06:40:19 +0000492 Darwin/1@<:@0-9@:>@.*)
Ronald Oussorenb8f11a62010-03-08 07:02:03 +0000493 define_xopen_source=no;;
Trent Mickaf16e8c2004-08-25 23:55:59 +0000494 # On AIX 4 and 5.1, mbstate_t is defined only when _XOPEN_SOURCE == 500 but
495 # used in wcsnrtombs() and mbsnrtowcs() even if _XOPEN_SOURCE is not defined
496 # or has another value. By not (re)defining it, the defaults come in place.
Martin v. Löwisc19c5a62003-11-18 20:00:44 +0000497 AIX/4)
498 define_xopen_source=no;;
Trent Mickaf16e8c2004-08-25 23:55:59 +0000499 AIX/5)
500 if test `uname -r` -eq 1; then
501 define_xopen_source=no
502 fi
503 ;;
Georg Brandlf78e02b2008-06-10 17:40:04 +0000504 # On QNX 6.3.2, defining _XOPEN_SOURCE prevents netdb.h from
505 # defining NI_NUMERICHOST.
506 QNX/6.3.2)
507 define_xopen_source=no
508 ;;
Bob Ippolito7026a0a2005-03-28 23:23:47 +0000509
Martin v. Löwise981a4e2002-11-11 13:26:51 +0000510esac
511
512if test $define_xopen_source = yes
513then
Victor Stinner14d098d2011-09-07 22:29:43 +0200514 # X/Open 7, incorporating POSIX.1-2008
515 AC_DEFINE(_XOPEN_SOURCE, 700,
Martin v. Löwis1a415762010-05-28 15:44:20 +0000516 Define to the level of X/Open that your system supports)
Martin v. Löwis678fc1e2002-11-12 06:04:39 +0000517
518 # On Tru64 Unix 4.0F, defining _XOPEN_SOURCE also requires
519 # definition of _XOPEN_SOURCE_EXTENDED and _POSIX_C_SOURCE, or else
520 # several APIs are not declared. Since this is also needed in some
521 # cases for HP-UX, we define it globally.
Martin v. Löwis1a415762010-05-28 15:44:20 +0000522 AC_DEFINE(_XOPEN_SOURCE_EXTENDED, 1,
523 Define to activate Unix95-and-earlier features)
Martin v. Löwis678fc1e2002-11-12 06:04:39 +0000524
Victor Stinnerd169fdc2011-09-08 00:56:17 +0200525 AC_DEFINE(_POSIX_C_SOURCE, 200809L, Define to activate features from IEEE Stds 1003.1-2008)
Martin v. Löwise981a4e2002-11-11 13:26:51 +0000526fi
527
Christian Heimes647cd872013-12-07 23:39:33 +0100528# On HP-UX mbstate_t requires _INCLUDE__STDC_A1_SOURCE
529case $ac_sys_system in
Christian Heimesb02bcae2013-12-08 15:21:08 +0100530 hp*|HP*)
531 define_stdc_a1=yes;;
532 *)
533 define_stdc_a1=no;;
Christian Heimes647cd872013-12-07 23:39:33 +0100534esac
535
Christian Heimesb02bcae2013-12-08 15:21:08 +0100536if test $define_stdc_a1 = yes
537then
538 AC_DEFINE(_INCLUDE__STDC_A1_SOURCE, 1, Define to include mbstate_t for mbrtowc)
539fi
540
Guido van Rossum91922671997-10-09 20:24:13 +0000541#
542# SGI compilers allow the specification of the both the ABI and the
543# ISA on the command line. Depending on the values of these switches,
544# different and often incompatable code will be generated.
545#
546# The SGI_ABI variable can be used to modify the CC and LDFLAGS and
547# thus supply support for various ABI/ISA combinations. The MACHDEP
548# variable is also adjusted.
549#
550AC_SUBST(SGI_ABI)
551if test ! -z "$SGI_ABI"
552then
553 CC="cc $SGI_ABI"
554 LDFLAGS="$SGI_ABI $LDFLAGS"
555 MACHDEP=`echo "${MACHDEP}${SGI_ABI}" | sed 's/ *//g'`
556fi
Guido van Rossumb418f891996-07-30 18:06:02 +0000557AC_MSG_RESULT($MACHDEP)
558
Jack Jansen6b08a402004-06-03 12:41:45 +0000559# Record the configure-time value of MACOSX_DEPLOYMENT_TARGET,
560# it may influence the way we can build extensions, so distutils
561# needs to check it
562AC_SUBST(CONFIGURE_MACOSX_DEPLOYMENT_TARGET)
Thomas Wouters477c8d52006-05-27 19:21:47 +0000563AC_SUBST(EXPORT_MACOSX_DEPLOYMENT_TARGET)
Jack Jansen6b08a402004-06-03 12:41:45 +0000564CONFIGURE_MACOSX_DEPLOYMENT_TARGET=
Thomas Wouters477c8d52006-05-27 19:21:47 +0000565EXPORT_MACOSX_DEPLOYMENT_TARGET='#'
Jack Jansen6b08a402004-06-03 12:41:45 +0000566
Guido van Rossum627b2d71993-12-24 10:39:16 +0000567# checks for alternative programs
Skip Montanarodecc6a42003-01-01 20:07:49 +0000568
569# compiler flags are generated in two sets, BASECFLAGS and OPT. OPT is just
570# for debug/optimization stuff. BASECFLAGS is for flags that are required
571# just to get things to compile and link. Users are free to override OPT
572# when running configure or make. The build should not break if they do.
573# BASECFLAGS should generally not be messed with, however.
574
575# XXX shouldn't some/most/all of this code be merged with the stuff later
576# on that fiddles with OPT and BASECFLAGS?
Guido van Rossum5739e7e1995-01-20 16:50:53 +0000577AC_MSG_CHECKING(for --without-gcc)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000578AC_ARG_WITH(gcc,
Matthias Klose2b8733f2010-04-25 18:34:36 +0000579 AS_HELP_STRING([--without-gcc], [never use gcc]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000580[
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000581 case $withval in
Benjamin Peterson960cf0f2009-01-09 04:11:44 +0000582 no) CC=${CC:-cc}
Guido van Rossum5739e7e1995-01-20 16:50:53 +0000583 without_gcc=yes;;
584 yes) CC=gcc
585 without_gcc=no;;
586 *) CC=$withval
587 without_gcc=$withval;;
Guido van Rossum55a214e1995-09-13 17:48:09 +0000588 esac], [
Guido van Rossumb418f891996-07-30 18:06:02 +0000589 case $ac_sys_system in
Antoine Pitrouf6350d22010-09-21 15:19:14 +0000590 AIX*) CC=${CC:-xlc_r}
Neil Schemenauerb3531b82001-02-16 04:09:05 +0000591 without_gcc=;;
Martin v. Löwis130fb172001-07-19 11:00:41 +0000592 *) without_gcc=no;;
Guido van Rossum55a214e1995-09-13 17:48:09 +0000593 esac])
Guido van Rossum5739e7e1995-01-20 16:50:53 +0000594AC_MSG_RESULT($without_gcc)
595
Guido van Rossum03ad99f1995-03-09 14:09:54 +0000596# If the user switches compilers, we can't believe the cache
597if test ! -z "$ac_cv_prog_CC" -a ! -z "$CC" -a "$CC" != "$ac_cv_prog_CC"
598then
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000599 AC_MSG_ERROR([cached CC is different -- throw away $cache_file
600(it is also a good idea to do 'make clean' before compiling)])
Guido van Rossum03ad99f1995-03-09 14:09:54 +0000601fi
602
Jeffrey Yasskind4fcdb12010-07-09 16:30:58 +0000603# Don't let AC_PROG_CC set the default CFLAGS. It normally sets -g -O2
604# when the compiler supports them, but we don't always want -O2, and
605# we set -g later.
606if test -z "$CFLAGS"; then
607 CFLAGS=
Marc-André Lemburgdf700f02010-04-30 17:29:56 +0000608fi
Ned Deilycbfb9a52012-06-23 16:02:19 -0700609
610if test "$ac_sys_system" = "Darwin"
611then
612 # Compiler selection on MacOSX is more complicated than
613 # AC_PROG_CC can handle, see Mac/README.txt for more
614 # information
615 if test -z "${CC}"
616 then
617 found_gcc=
618 found_clang=
619 as_save_IFS=$IFS; IFS=:
620 for as_dir in $PATH
621 do
622 IFS=$as_save_IFS
623 if test -x $as_dir/gcc; then
624 if test -z "${found_gcc}"; then
625 found_gcc=$as_dir/gcc
626 fi
627 fi
628 if test -x $as_dir/clang; then
629 if test -z "${found_clang}"; then
630 found_clang=$as_dir/clang
631 fi
632 fi
633 done
634 IFS=$as_save_IFS
635
636 if test -n "$found_gcc" -a -n "$found_clang"
637 then
638 if test -n "`"$found_gcc" --version | grep llvm-gcc`"
639 then
640 AC_MSG_NOTICE([Detected llvm-gcc, falling back to clang])
641 CC="$found_clang"
642 CXX="$found_clang++"
643 fi
644
645
646 elif test -z "$found_gcc" -a -n "$found_clang"
647 then
648 AC_MSG_NOTICE([No GCC found, use CLANG])
649 CC="$found_clang"
650 CXX="$found_clang++"
651
652 elif test -z "$found_gcc" -a -z "$found_clang"
653 then
654 found_clang=`/usr/bin/xcrun -find clang 2>/dev/null`
655 if test -n "${found_clang}"
656 then
657 AC_MSG_NOTICE([Using clang from Xcode.app])
658 CC="${found_clang}"
659 CXX="`/usr/bin/xcrun -find clang++`"
660
661 # else: use default behaviour
662 fi
663 fi
664 fi
665fi
Jeffrey Yasskind4fcdb12010-07-09 16:30:58 +0000666AC_PROG_CC
Martin v. Löwis1d5ecb72001-08-09 10:29:44 +0000667
Thomas Wouters49fd7fa2006-04-21 10:40:58 +0000668AC_SUBST(CXX)
669AC_SUBST(MAINCC)
670AC_MSG_CHECKING(for --with-cxx-main=<compiler>)
671AC_ARG_WITH(cxx_main,
Matthias Klose2b8733f2010-04-25 18:34:36 +0000672 AS_HELP_STRING([--with-cxx-main=<compiler>],
Thomas Wouters49fd7fa2006-04-21 10:40:58 +0000673 [compile main() and link python executable with C++ compiler]),
674[
675
676 case $withval in
677 no) with_cxx_main=no
678 MAINCC='$(CC)';;
679 yes) with_cxx_main=yes
680 MAINCC='$(CXX)';;
681 *) with_cxx_main=yes
682 MAINCC=$withval
683 if test -z "$CXX"
684 then
685 CXX=$withval
686 fi;;
687 esac], [
688 with_cxx_main=no
689 MAINCC='$(CC)'
690])
691AC_MSG_RESULT($with_cxx_main)
692
693preset_cxx="$CXX"
694if test -z "$CXX"
695then
696 case "$CC" in
doko@ubuntu.com51f65942012-06-30 14:42:46 +0200697 gcc) AC_PATH_TOOL(CXX, [g++], [g++], [notfound]) ;;
698 cc) AC_PATH_TOOL(CXX, [c++], [c++], [notfound]) ;;
699 clang|*/clang) AC_PATH_TOOL(CXX, [clang++], [clang++], [notfound]) ;;
Thomas Wouters49fd7fa2006-04-21 10:40:58 +0000700 esac
701 if test "$CXX" = "notfound"
702 then
703 CXX=""
704 fi
705fi
706if test -z "$CXX"
707then
doko@ubuntu.com51f65942012-06-30 14:42:46 +0200708 AC_CHECK_TOOLS(CXX, $CCC c++ g++ gcc CC cxx cc++ cl, notfound)
Thomas Wouters49fd7fa2006-04-21 10:40:58 +0000709 if test "$CXX" = "notfound"
710 then
711 CXX=""
712 fi
713fi
714if test "$preset_cxx" != "$CXX"
715then
Christian Heimesfe32aec2013-11-20 01:18:26 +0100716 AC_MSG_NOTICE([
Thomas Wouters49fd7fa2006-04-21 10:40:58 +0000717
718 By default, distutils will build C++ extension modules with "$CXX".
719 If this is not intended, then set CXX on the configure command line.
720 ])
721fi
722
723
Martin v. Löwis48e14d32011-05-09 07:37:45 +0200724AC_MSG_CHECKING([for -Wl,--no-as-needed])
725save_LDFLAGS="$LDFLAGS"
726LDFLAGS="$LDFLAGS -Wl,--no-as-needed"
727AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
728 [NO_AS_NEEDED="-Wl,--no-as-needed"
729 AC_MSG_RESULT([yes])],
730 [NO_AS_NEEDED=""
731 AC_MSG_RESULT([no])])
732LDFLAGS="$save_LDFLAGS"
733AC_SUBST(NO_AS_NEEDED)
734
735
Martin v. Löwis1d5ecb72001-08-09 10:29:44 +0000736# checks for UNIX variants that set C preprocessor variables
Matthias Kloseaf30c5d2010-04-25 18:43:42 +0000737AC_USE_SYSTEM_EXTENSIONS
Martin v. Löwis1d5ecb72001-08-09 10:29:44 +0000738
Martin v. Löwis779ffc02002-12-02 22:17:01 +0000739# Check for unsupported systems
740case $ac_sys_system/$ac_sys_release in
Guido van Rossumcd16bf62007-06-13 18:07:49 +0000741atheos*|Linux*/1*)
Martin v. Löwis779ffc02002-12-02 22:17:01 +0000742 echo This system \($ac_sys_system/$ac_sys_release\) is no longer supported.
743 echo See README for details.
744 exit 1;;
745esac
746
Neil Schemenauer55f0cf32001-01-24 17:24:33 +0000747AC_EXEEXT
Neil Schemenauer3ae1d0a2001-01-27 06:54:42 +0000748AC_MSG_CHECKING(for --with-suffix)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000749AC_ARG_WITH(suffix,
Matthias Klose2b8733f2010-04-25 18:34:36 +0000750 AS_HELP_STRING([--with-suffix=.exe], [set executable suffix]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000751[
Neil Schemenauer3ae1d0a2001-01-27 06:54:42 +0000752 case $withval in
753 no) EXEEXT=;;
754 yes) EXEEXT=.exe;;
755 *) EXEEXT=$withval;;
756 esac])
757AC_MSG_RESULT($EXEEXT)
Jack Jansen1999ef42001-12-06 21:47:20 +0000758
Jack Jansen9a66b6d2001-08-08 13:56:14 +0000759# Test whether we're running on a non-case-sensitive system, in which
760# case we give a warning if no ext is given
Jack Jansen1999ef42001-12-06 21:47:20 +0000761AC_SUBST(BUILDEXEEXT)
762AC_MSG_CHECKING(for case-insensitive build directory)
Jack Jansen3c2c4332002-11-06 13:33:32 +0000763if test ! -d CaseSensitiveTestDir; then
764mkdir CaseSensitiveTestDir
765fi
766
767if test -d casesensitivetestdir
Jack Jansen9a66b6d2001-08-08 13:56:14 +0000768then
Jack Jansen1999ef42001-12-06 21:47:20 +0000769 AC_MSG_RESULT(yes)
770 BUILDEXEEXT=.exe
771else
772 AC_MSG_RESULT(no)
Jack Jansendd19cf82001-12-06 22:36:17 +0000773 BUILDEXEEXT=$EXEEXT
Jack Jansen9a66b6d2001-08-08 13:56:14 +0000774fi
Jack Jansen3c2c4332002-11-06 13:33:32 +0000775rmdir CaseSensitiveTestDir
Guido van Rossumfb842551997-08-06 23:42:07 +0000776
Guido van Rossumdd997f71998-10-07 19:58:26 +0000777case $MACHDEP in
778bsdos*)
779 case $CC in
780 gcc) CC="$CC -D_HAVE_BSDI";;
781 esac;;
782esac
783
Guido van Rossum84561611997-08-21 00:08:11 +0000784case $ac_sys_system in
785hp*|HP*)
786 case $CC in
Guido van Rossumcd5ff9f2000-09-22 16:15:54 +0000787 cc|*/cc) CC="$CC -Ae";;
Guido van Rossum84561611997-08-21 00:08:11 +0000788 esac;;
789esac
790
doko@python.org3e6e2ac2013-01-25 13:12:29 +0100791MULTIARCH=$($CC --print-multiarch 2>/dev/null)
792AC_SUBST(MULTIARCH)
793
Martin v. Löwise8964d42001-03-06 12:09:07 +0000794
Neil Schemenauer61c51152001-01-26 16:18:16 +0000795AC_SUBST(LIBRARY)
796AC_MSG_CHECKING(LIBRARY)
797if test -z "$LIBRARY"
798then
Barry Warsawf040d7d2010-10-18 17:09:07 +0000799 LIBRARY='libpython$(VERSION)$(ABIFLAGS).a'
Neil Schemenauer61c51152001-01-26 16:18:16 +0000800fi
801AC_MSG_RESULT($LIBRARY)
802
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000803# LDLIBRARY is the name of the library to link against (as opposed to the
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000804# name of the library into which to insert object files). BLDLIBRARY is also
805# the library to link against, usually. On Mac OS X frameworks, BLDLIBRARY
806# is blank as the main program is not linked directly against LDLIBRARY.
807# LDLIBRARYDIR is the path to LDLIBRARY, which is made in a subdirectory. On
808# systems without shared libraries, LDLIBRARY is the same as LIBRARY
809# (defined in the Makefiles). On Cygwin LDLIBRARY is the import library,
810# DLLLIBRARY is the shared (i.e., DLL) library.
811#
Martin v. Löwis1142de32002-03-29 16:28:31 +0000812# RUNSHARED is used to run shared python without installed libraries
813#
814# INSTSONAME is the name of the shared library that will be use to install
815# on the system - some systems like version suffix, others don't
Barry Warsaw8cf4eae2010-10-16 01:04:07 +0000816#
817# LDVERSION is the shared library version number, normally the Python version
818# with the ABI build flags appended.
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000819AC_SUBST(LDLIBRARY)
Guido van Rossum27552902001-01-23 01:52:26 +0000820AC_SUBST(DLLLIBRARY)
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000821AC_SUBST(BLDLIBRARY)
Martin v. Löwisd1fc34d2010-12-30 14:55:47 +0000822AC_SUBST(PY3LIBRARY)
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000823AC_SUBST(LDLIBRARYDIR)
Martin v. Löwis1142de32002-03-29 16:28:31 +0000824AC_SUBST(INSTSONAME)
825AC_SUBST(RUNSHARED)
Barry Warsaw8cf4eae2010-10-16 01:04:07 +0000826AC_SUBST(LDVERSION)
Neil Schemenauer61c51152001-01-26 16:18:16 +0000827LDLIBRARY="$LIBRARY"
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000828BLDLIBRARY='$(LDLIBRARY)'
Martin v. Löwis09bdf722002-05-08 08:51:29 +0000829INSTSONAME='$(LDLIBRARY)'
Guido van Rossum27552902001-01-23 01:52:26 +0000830DLLLIBRARY=''
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000831LDLIBRARYDIR=''
Martin v. Löwis1142de32002-03-29 16:28:31 +0000832RUNSHARED=''
Barry Warsaw14d98ac2010-11-24 19:43:47 +0000833LDVERSION="$VERSION"
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000834
Guido van Rossumfb842551997-08-06 23:42:07 +0000835# LINKCC is the command that links the python executable -- default is $(CC).
Martin v. Löwisb7da67a2001-10-18 15:35:38 +0000836# If CXX is set, and if it is needed to link a main function that was
837# compiled with CXX, LINKCC is CXX instead. Always using CXX is undesirable:
838# python might then depend on the C++ runtime
Fred Drake5790be12000-10-09 17:06:13 +0000839# This is altered for AIX in order to build the export list before
Guido van Rossumec95c7b1998-08-04 17:59:56 +0000840# linking.
Guido van Rossumfb842551997-08-06 23:42:07 +0000841AC_SUBST(LINKCC)
842AC_MSG_CHECKING(LINKCC)
843if test -z "$LINKCC"
844then
Thomas Wouters49fd7fa2006-04-21 10:40:58 +0000845 LINKCC='$(PURIFY) $(MAINCC)'
Guido van Rossumfb842551997-08-06 23:42:07 +0000846 case $ac_sys_system in
847 AIX*)
Neal Norwitz0b27ff92003-03-31 15:53:49 +0000848 exp_extra="\"\""
849 if test $ac_sys_release -ge 5 -o \
850 $ac_sys_release -eq 4 -a `uname -r` -ge 2 ; then
851 exp_extra="."
852 fi
853 LINKCC="\$(srcdir)/Modules/makexp_aix Modules/python.exp $exp_extra \$(LIBRARY); $LINKCC";;
Georg Brandlf78e02b2008-06-10 17:40:04 +0000854 QNX*)
855 # qcc must be used because the other compilers do not
856 # support -N.
857 LINKCC=qcc;;
Guido van Rossumfb842551997-08-06 23:42:07 +0000858 esac
859fi
860AC_MSG_RESULT($LINKCC)
861
Tarek Ziadébe720e02009-05-09 11:55:12 +0000862# GNULD is set to "yes" if the GNU linker is used. If this goes wrong
863# make sure we default having it set to "no": this is used by
864# distutils.unixccompiler to know if it should add --enable-new-dtags
865# to linker command lines, and failing to detect GNU ld simply results
866# in the same bahaviour as before.
867AC_SUBST(GNULD)
868AC_MSG_CHECKING(for GNU ld)
869ac_prog=ld
870if test "$GCC" = yes; then
871 ac_prog=`$CC -print-prog-name=ld`
872fi
873case `"$ac_prog" -V 2>&1 < /dev/null` in
874 *GNU*)
875 GNULD=yes;;
876 *)
877 GNULD=no;;
878esac
879AC_MSG_RESULT($GNULD)
880
Daniel Stutzbacha606faa2010-08-31 19:51:07 +0000881AC_C_INLINE
882if test "$ac_cv_c_inline" != no ; then
Benjamin Petersond7f73e92010-09-05 00:09:07 +0000883 AC_DEFINE(USE_INLINE, 1, [Define to use the C99 inline keyword.])
Daniel Stutzbacha606faa2010-08-31 19:51:07 +0000884 AC_SUBST(USE_INLINE)
885fi
886
887
Martin v. Löwis1142de32002-03-29 16:28:31 +0000888AC_MSG_CHECKING(for --enable-shared)
889AC_ARG_ENABLE(shared,
Matthias Klose2b8733f2010-04-25 18:34:36 +0000890 AS_HELP_STRING([--enable-shared], [disable/enable building shared python library]))
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000891
Martin v. Löwis1142de32002-03-29 16:28:31 +0000892if test -z "$enable_shared"
893then
Martin v. Löwisb51033d2002-05-03 05:53:15 +0000894 case $ac_sys_system in
Antoine Pitrou6103ab12009-10-24 20:11:21 +0000895 CYGWIN*)
Martin v. Löwisb51033d2002-05-03 05:53:15 +0000896 enable_shared="yes";;
897 *)
898 enable_shared="no";;
899 esac
Martin v. Löwis1142de32002-03-29 16:28:31 +0000900fi
901AC_MSG_RESULT($enable_shared)
902
Skip Montanaro56f6a4f2004-06-18 02:47:22 +0000903AC_MSG_CHECKING(for --enable-profiling)
904AC_ARG_ENABLE(profiling,
doko@ubuntu.comba015832012-06-30 16:52:05 +0200905 AS_HELP_STRING([--enable-profiling], [enable C-level code profiling]))
906if test "x$enable_profiling" = xyes; then
907 ac_save_cc="$CC"
Benjamin Peterson615ea1a2013-03-26 08:55:37 -0400908 CC="$CC -pg"
doko@ubuntu.comba015832012-06-30 16:52:05 +0200909 AC_LINK_IFELSE([AC_LANG_SOURCE([[int main() { return 0; }]])],
910 [],
911 [enable_profiling=no])
912 CC="$ac_save_cc"
913else
914 enable_profiling=no
915fi
916AC_MSG_RESULT($enable_profiling)
Skip Montanaro56f6a4f2004-06-18 02:47:22 +0000917
doko@ubuntu.comba015832012-06-30 16:52:05 +0200918if test "x$enable_profiling" = xyes; then
919 BASECFLAGS="-pg $BASECFLAGS"
920 LDFLAGS="-pg $LDFLAGS"
921fi
Martin v. Löwis1142de32002-03-29 16:28:31 +0000922
923AC_MSG_CHECKING(LDLIBRARY)
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000924
Guido van Rossumb8552162001-09-05 14:58:11 +0000925# MacOSX framework builds need more magic. LDLIBRARY is the dynamic
926# library that we build, but we do not want to link against it (we
927# will find it with a -framework option). For this reason there is an
928# extra variable BLDLIBRARY against which Python and the extension
929# modules are linked, BLDLIBRARY. This is normally the same as
930# LDLIBRARY, but empty for MacOSX framework builds.
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000931if test "$enable_framework"
932then
933 LDLIBRARY='$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
doko@ubuntu.come5de66e2014-05-07 12:57:44 +0200934 RUNSHARED=DYLD_FRAMEWORK_PATH=`pwd`${DYLD_FRAMEWORK_PATH:+:${DYLD_FRAMEWORK_PATH}}
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000935 BLDLIBRARY=''
936else
937 BLDLIBRARY='$(LDLIBRARY)'
938fi
939
Martin v. Löwis1142de32002-03-29 16:28:31 +0000940# Other platforms follow
941if test $enable_shared = "yes"; then
doko@python.org87421192013-01-26 11:39:31 +0100942 PY_ENABLE_SHARED=1
Mark Hammond8235ea12002-07-19 06:55:41 +0000943 AC_DEFINE(Py_ENABLE_SHARED, 1, [Defined if Python is built as a shared library.])
Martin v. Löwis1142de32002-03-29 16:28:31 +0000944 case $ac_sys_system in
Martin v. Löwis1142de32002-03-29 16:28:31 +0000945 CYGWIN*)
Barry Warsaw8cf4eae2010-10-16 01:04:07 +0000946 LDLIBRARY='libpython$(LDVERSION).dll.a'
947 DLLLIBRARY='libpython$(LDVERSION).dll'
Martin v. Löwis1142de32002-03-29 16:28:31 +0000948 ;;
949 SunOS*)
Barry Warsaw8cf4eae2010-10-16 01:04:07 +0000950 LDLIBRARY='libpython$(LDVERSION).so'
951 BLDLIBRARY='-Wl,-R,$(LIBDIR) -L. -lpython$(LDVERSION)'
doko@ubuntu.come5de66e2014-05-07 12:57:44 +0200952 RUNSHARED=LD_LIBRARY_PATH=`pwd`${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
Martin v. Löwis2389c412003-10-31 15:42:07 +0000953 INSTSONAME="$LDLIBRARY".$SOVERSION
Martin v. Löwis9b142aa2011-02-05 20:26:52 +0000954 if test "$with_pydebug" != yes
Martin v. Löwisd1fc34d2010-12-30 14:55:47 +0000955 then
956 PY3LIBRARY=libpython3.so
957 fi
Martin v. Löwis1142de32002-03-29 16:28:31 +0000958 ;;
Charles-François Natali749400a2011-07-24 22:41:18 +0200959 Linux*|GNU*|NetBSD*|FreeBSD*|DragonFly*|OpenBSD*)
Barry Warsaw8cf4eae2010-10-16 01:04:07 +0000960 LDLIBRARY='libpython$(LDVERSION).so'
961 BLDLIBRARY='-L. -lpython$(LDVERSION)'
doko@ubuntu.come5de66e2014-05-07 12:57:44 +0200962 RUNSHARED=LD_LIBRARY_PATH=`pwd`${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
Hye-Shik Chang33761492004-10-26 09:53:46 +0000963 case $ac_sys_system in
964 FreeBSD*)
965 SOVERSION=`echo $SOVERSION|cut -d "." -f 1`
966 ;;
967 esac
Martin v. Löwis1142de32002-03-29 16:28:31 +0000968 INSTSONAME="$LDLIBRARY".$SOVERSION
Martin v. Löwis9b142aa2011-02-05 20:26:52 +0000969 if test "$with_pydebug" != yes
Martin v. Löwisd1fc34d2010-12-30 14:55:47 +0000970 then
971 PY3LIBRARY=libpython3.so
972 fi
Martin v. Löwis1142de32002-03-29 16:28:31 +0000973 ;;
974 hp*|HP*)
Thomas Wouters477c8d52006-05-27 19:21:47 +0000975 case `uname -m` in
976 ia64)
Barry Warsaw8cf4eae2010-10-16 01:04:07 +0000977 LDLIBRARY='libpython$(LDVERSION).so'
Thomas Wouters477c8d52006-05-27 19:21:47 +0000978 ;;
979 *)
Barry Warsaw8cf4eae2010-10-16 01:04:07 +0000980 LDLIBRARY='libpython$(LDVERSION).sl'
Thomas Wouters477c8d52006-05-27 19:21:47 +0000981 ;;
982 esac
Barry Warsaw8cf4eae2010-10-16 01:04:07 +0000983 BLDLIBRARY='-Wl,+b,$(LIBDIR) -L. -lpython$(LDVERSION)'
doko@ubuntu.come5de66e2014-05-07 12:57:44 +0200984 RUNSHARED=SHLIB_PATH=`pwd`${SHLIB_PATH:+:${SHLIB_PATH}}
Martin v. Löwis1142de32002-03-29 16:28:31 +0000985 ;;
Georg Brandlb1441c72009-01-03 22:33:39 +0000986 Darwin*)
Barry Warsaw8cf4eae2010-10-16 01:04:07 +0000987 LDLIBRARY='libpython$(LDVERSION).dylib'
988 BLDLIBRARY='-L. -lpython$(LDVERSION)'
doko@ubuntu.come5de66e2014-05-07 12:57:44 +0200989 RUNSHARED=DYLD_LIBRARY_PATH=`pwd`${DYLD_LIBRARY_PATH:+:${DYLD_LIBRARY_PATH}}
Georg Brandlb1441c72009-01-03 22:33:39 +0000990 ;;
Antoine Pitrou8e6b4072010-09-10 19:44:44 +0000991 AIX*)
Barry Warsaw8cf4eae2010-10-16 01:04:07 +0000992 LDLIBRARY='libpython$(LDVERSION).so'
doko@ubuntu.come5de66e2014-05-07 12:57:44 +0200993 RUNSHARED=LIBPATH=`pwd`${LIBPATH:+:${LIBPATH}}
Antoine Pitrou8e6b4072010-09-10 19:44:44 +0000994 ;;
Georg Brandlb1441c72009-01-03 22:33:39 +0000995
Martin v. Löwis1142de32002-03-29 16:28:31 +0000996 esac
Jason Tishler30765592003-09-04 11:04:06 +0000997else # shared is disabled
doko@python.org87421192013-01-26 11:39:31 +0100998 PY_ENABLE_SHARED=0
Jason Tishler30765592003-09-04 11:04:06 +0000999 case $ac_sys_system in
1000 CYGWIN*)
1001 BLDLIBRARY='$(LIBRARY)'
Barry Warsaw8cf4eae2010-10-16 01:04:07 +00001002 LDLIBRARY='libpython$(LDVERSION).dll.a'
Jason Tishler30765592003-09-04 11:04:06 +00001003 ;;
1004 esac
Martin v. Löwis1142de32002-03-29 16:28:31 +00001005fi
1006
doko@ubuntu.com1abe1c52012-06-30 20:42:45 +02001007if test "$cross_compiling" = yes; then
1008 RUNSHARED=
1009fi
1010
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001011AC_MSG_RESULT($LDLIBRARY)
1012
Guido van Rossum627b2d71993-12-24 10:39:16 +00001013AC_PROG_RANLIB
Guido van Rossum433c8ad1994-08-01 12:07:07 +00001014AC_SUBST(AR)
doko@ubuntu.com51f65942012-06-30 14:42:46 +02001015AC_CHECK_TOOLS(AR, ar aal, ar)
Neil Schemenauera42c8272001-03-31 00:01:55 +00001016
Tarek Ziadé5662d3e2009-05-07 21:24:43 +00001017# tweak ARFLAGS only if the user didn't set it on the command line
1018AC_SUBST(ARFLAGS)
1019if test -z "$ARFLAGS"
1020then
1021 ARFLAGS="rc"
1022fi
1023
doko@ubuntu.com58844492012-06-30 18:25:32 +02001024AC_CHECK_TOOLS([READELF], [readelf], [:])
1025if test "$cross_compiling" = yes; then
1026 case "$READELF" in
1027 readelf|:)
1028 AC_MSG_ERROR([readelf for the host is required for cross builds])
1029 ;;
1030 esac
1031fi
1032AC_SUBST(READELF)
1033
Matthias Klosec4c48422012-10-21 23:05:35 +02001034AC_SUBST(ASDLGEN)
1035AC_CHECK_PROGS(PYTHON, python$PACKAGE_VERSION python3 python, not-found)
Ross Lagerwall1b863eb2012-10-29 17:31:54 +00001036if test "$PYTHON" = not-found; then
Matthias Klosec4c48422012-10-21 23:05:35 +02001037 ASDLGEN="@echo python: $PYTHON! cannot run \$(srcdir)/Parser/asdl_c.py #"
1038else
1039 ASDLGEN="$PYTHON"
Ralf Schmitt023f3a72011-05-31 17:10:03 -05001040fi
1041
1042
Neil Schemenauera42c8272001-03-31 00:01:55 +00001043case $MACHDEP in
Neil Schemenaueraf5567f2001-10-21 22:32:04 +00001044bsdos*|hp*|HP*)
1045 # install -d does not work on BSDI or HP-UX
Neil Schemenauera42c8272001-03-31 00:01:55 +00001046 if test -z "$INSTALL"
1047 then
1048 INSTALL="${srcdir}/install-sh -c"
1049 fi
1050esac
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00001051AC_PROG_INSTALL
Matthias Klose93a0ef12012-03-15 18:08:34 +01001052AC_PROG_MKDIR_P
Guido van Rossumb418f891996-07-30 18:06:02 +00001053
Guido van Rossumec95c7b1998-08-04 17:59:56 +00001054# Not every filesystem supports hard links
1055AC_SUBST(LN)
1056if test -z "$LN" ; then
1057 case $ac_sys_system in
Guido van Rossumaef734b2001-01-10 21:09:12 +00001058 CYGWIN*) LN="ln -s";;
Guido van Rossumec95c7b1998-08-04 17:59:56 +00001059 *) LN=ln;;
1060 esac
1061fi
1062
Barry Warsaw35f3a2c2010-09-03 18:30:30 +00001063# For calculating the .so ABI tag.
Barry Warsaw8cf4eae2010-10-16 01:04:07 +00001064AC_SUBST(ABIFLAGS)
1065ABIFLAGS=""
Barry Warsaw35f3a2c2010-09-03 18:30:30 +00001066
Fred Drake9f715822001-07-11 06:27:00 +00001067# Check for --with-pydebug
1068AC_MSG_CHECKING(for --with-pydebug)
1069AC_ARG_WITH(pydebug,
Matthias Klose2b8733f2010-04-25 18:34:36 +00001070 AS_HELP_STRING([--with-pydebug], [build with Py_DEBUG defined]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00001071[
Fred Drake9f715822001-07-11 06:27:00 +00001072if test "$withval" != no
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001073then
1074 AC_DEFINE(Py_DEBUG, 1,
1075 [Define if you want to build an interpreter with many run-time checks.])
1076 AC_MSG_RESULT(yes);
1077 Py_DEBUG='true'
Barry Warsaw8cf4eae2010-10-16 01:04:07 +00001078 ABIFLAGS="${ABIFLAGS}d"
Fred Drake9f715822001-07-11 06:27:00 +00001079else AC_MSG_RESULT(no); Py_DEBUG='false'
1080fi],
1081[AC_MSG_RESULT(no)])
1082
Skip Montanarodecc6a42003-01-01 20:07:49 +00001083# XXX Shouldn't the code above that fiddles with BASECFLAGS and OPT be
1084# merged with this chunk of code?
1085
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00001086# Optimizer/debugger flags
Skip Montanarodecc6a42003-01-01 20:07:49 +00001087# ------------------------
1088# (The following bit of code is complicated enough - please keep things
1089# indented properly. Just pretend you're editing Python code. ;-)
1090
1091# There are two parallel sets of case statements below, one that checks to
1092# see if OPT was set and one that does BASECFLAGS setting based upon
1093# compiler and platform. BASECFLAGS tweaks need to be made even if the
1094# user set OPT.
1095
1096# tweak OPT based on compiler and platform, only if the user didn't set
1097# it on the command line
Guido van Rossumb418f891996-07-30 18:06:02 +00001098AC_SUBST(OPT)
Benjamin Peterson65b4ec52010-03-23 21:02:34 +00001099if test "${OPT-unset}" = "unset"
Guido van Rossumb418f891996-07-30 18:06:02 +00001100then
Skip Montanarodecc6a42003-01-01 20:07:49 +00001101 case $GCC in
1102 yes)
Thomas Wouters49fd7fa2006-04-21 10:40:58 +00001103 if test "$CC" != 'g++' ; then
1104 STRICT_PROTO="-Wstrict-prototypes"
1105 fi
Christian Heimes38053212007-12-14 01:24:44 +00001106 # For gcc 4.x we need to use -fwrapv so lets check if its supported
1107 if "$CC" -v --help 2>/dev/null |grep -- -fwrapv > /dev/null; then
1108 WRAP="-fwrapv"
1109 fi
Stefan Krah962055d2011-09-14 15:14:08 +02001110
1111 # Clang also needs -fwrapv
Stefan Krahaf04ff22011-12-08 22:20:31 +01001112 case $CC in
1113 *clang*) WRAP="-fwrapv"
1114 ;;
1115 esac
Stefan Krah962055d2011-09-14 15:14:08 +02001116
Skip Montanarodecc6a42003-01-01 20:07:49 +00001117 case $ac_cv_prog_cc_g in
Guido van Rossum2242f2f2001-04-11 20:58:20 +00001118 yes)
Fred Drake9f715822001-07-11 06:27:00 +00001119 if test "$Py_DEBUG" = 'true' ; then
1120 # Optimization messes up debuggers, so turn it off for
1121 # debug builds.
Antoine Pitrou3d6c7842015-02-11 19:39:16 +01001122 if "$CC" -v --help 2>/dev/null |grep -- -Og > /dev/null; then
1123 OPT="-g -Og -Wall $STRICT_PROTO"
1124 else
1125 OPT="-g -O0 -Wall $STRICT_PROTO"
1126 fi
Fred Drake9f715822001-07-11 06:27:00 +00001127 else
Christian Heimes38053212007-12-14 01:24:44 +00001128 OPT="-g $WRAP -O3 -Wall $STRICT_PROTO"
Skip Montanarodecc6a42003-01-01 20:07:49 +00001129 fi
1130 ;;
Guido van Rossum2242f2f2001-04-11 20:58:20 +00001131 *)
Thomas Wouters49fd7fa2006-04-21 10:40:58 +00001132 OPT="-O3 -Wall $STRICT_PROTO"
Skip Montanarodecc6a42003-01-01 20:07:49 +00001133 ;;
Fred Drake9f715822001-07-11 06:27:00 +00001134 esac
Martin v. Löwis21ee4092002-09-30 16:19:48 +00001135 case $ac_sys_system in
Skip Montanarodecc6a42003-01-01 20:07:49 +00001136 SCO_SV*) OPT="$OPT -m486 -DSCO5"
1137 ;;
1138 esac
Fred Drake9f715822001-07-11 06:27:00 +00001139 ;;
Skip Montanarodecc6a42003-01-01 20:07:49 +00001140
Guido van Rossum2242f2f2001-04-11 20:58:20 +00001141 *)
Skip Montanarodecc6a42003-01-01 20:07:49 +00001142 OPT="-O"
1143 ;;
Guido van Rossum2242f2f2001-04-11 20:58:20 +00001144 esac
Guido van Rossum4e8af441994-08-19 15:33:54 +00001145fi
Guido van Rossum627b2d71993-12-24 10:39:16 +00001146
Skip Montanarodecc6a42003-01-01 20:07:49 +00001147AC_SUBST(BASECFLAGS)
Benjamin Petersonacb8c522014-08-09 20:01:49 -07001148AC_SUBST(CFLAGS_NODIST)
Georg Brandlfcaf9102008-07-16 02:17:56 +00001149
1150# The -arch flags for universal builds on OSX
1151UNIVERSAL_ARCH_FLAGS=
1152AC_SUBST(UNIVERSAL_ARCH_FLAGS)
1153
Skip Montanarodecc6a42003-01-01 20:07:49 +00001154# tweak BASECFLAGS based on compiler and platform
1155case $GCC in
1156yes)
Benjamin Petersone6c9d242010-03-30 17:34:47 +00001157 # Python doesn't violate C99 aliasing rules, but older versions of
1158 # GCC produce warnings for legal Python code. Enable
1159 # -fno-strict-aliasing on versions of GCC that support but produce
1160 # warnings. See Issue3326
1161 AC_MSG_CHECKING(whether $CC accepts and needs -fno-strict-aliasing)
Martin v. Löwis70fedcd2003-07-07 21:26:19 +00001162 ac_save_cc="$CC"
1163 CC="$CC -fno-strict-aliasing"
Benjamin Petersone6c9d242010-03-30 17:34:47 +00001164 save_CFLAGS="$CFLAGS"
1165 AC_CACHE_VAL(ac_cv_no_strict_aliasing,
Matthias Kloseb159a552010-04-25 21:00:44 +00001166 AC_COMPILE_IFELSE(
1167 [
Mark Dickinson8c2b6f12010-05-11 09:23:07 +00001168 AC_LANG_PROGRAM([[]], [[]])
Matthias Kloseb159a552010-04-25 21:00:44 +00001169 ],[
1170 CC="$ac_save_cc -fstrict-aliasing"
1171 CFLAGS="$CFLAGS -Werror -Wstrict-aliasing"
1172 AC_COMPILE_IFELSE(
1173 [
Mark Dickinson8c2b6f12010-05-11 09:23:07 +00001174 AC_LANG_PROGRAM([[void f(int **x) {}]],
1175 [[double *x; f((int **) &x);]])
Matthias Kloseb159a552010-04-25 21:00:44 +00001176 ],[
1177 ac_cv_no_strict_aliasing=no
1178 ],[
1179 ac_cv_no_strict_aliasing=yes
1180 ])
1181 ],[
1182 ac_cv_no_strict_aliasing=no
1183 ]))
Benjamin Petersone6c9d242010-03-30 17:34:47 +00001184 CFLAGS="$save_CFLAGS"
Martin v. Löwis70fedcd2003-07-07 21:26:19 +00001185 CC="$ac_save_cc"
Benjamin Petersone6c9d242010-03-30 17:34:47 +00001186 AC_MSG_RESULT($ac_cv_no_strict_aliasing)
1187 if test $ac_cv_no_strict_aliasing = yes
Martin v. Löwis70fedcd2003-07-07 21:26:19 +00001188 then
1189 BASECFLAGS="$BASECFLAGS -fno-strict-aliasing"
1190 fi
Mark Dickinsonb0e2b4c2008-04-26 20:48:56 +00001191
Benjamin Peterson7ddbf102011-09-23 13:23:22 -04001192 AC_MSG_CHECKING(if we can turn off $CC unused result warning)
1193 ac_save_cc="$CC"
1194 CC="$CC -Wunused-result -Werror"
1195 save_CFLAGS="$CFLAGS"
1196 AC_CACHE_VAL(ac_cv_disable_unused_result_warning,
1197 AC_COMPILE_IFELSE(
1198 [
1199 AC_LANG_PROGRAM([[]], [[]])
1200 ],[
1201 ac_cv_disable_unused_result_warning=yes
1202 ],[
1203 ac_cv_disable_unused_result_warning=no
1204 ]))
1205 CFLAGS="$save_CFLAGS"
1206 CC="$ac_save_cc"
1207 AC_MSG_RESULT($ac_cv_disable_unused_result_warning)
1208
1209 if test $ac_cv_disable_unused_result_warning = yes
1210 then
1211 BASECFLAGS="$BASECFLAGS -Wno-unused-result"
1212 fi
1213
Benjamin Petersoncc00e012013-05-20 08:22:04 -07001214 AC_MSG_CHECKING(for -Werror=declaration-after-statement)
1215 ac_save_cc="$CC"
1216 CC="$CC -Werror=declaration-after-statement"
1217 save_CFLAGS="$CFLAGS"
1218 AC_CACHE_VAL(ac_cv_declaration_after_statement_warning,
1219 AC_COMPILE_IFELSE(
1220 [
1221 AC_LANG_PROGRAM([[]], [[]])
1222 ],[
1223 ac_cv_declaration_after_statement_warning=yes
1224 ],[
1225 ac_cv_declaration_after_statement_warning=no
1226 ]))
1227 CFLAGS="$save_CFLAGS"
1228 CC="$ac_save_cc"
1229 AC_MSG_RESULT($ac_cv_declaration_after_statement_warning)
1230
1231 if test $ac_cv_declaration_after_statement_warning = yes
1232 then
Benjamin Petersonacb8c522014-08-09 20:01:49 -07001233 CFLAGS_NODIST="$CFLAGS_NODIST -Werror=declaration-after-statement"
Benjamin Petersoncc00e012013-05-20 08:22:04 -07001234 fi
1235
Mark Dickinsonb0e2b4c2008-04-26 20:48:56 +00001236 # if using gcc on alpha, use -mieee to get (near) full IEEE 754
1237 # support. Without this, treatment of subnormals doesn't follow
1238 # the standard.
Matthias Klosedf2aecb2012-03-15 22:19:28 +01001239 case $host in
Mark Dickinsonb0e2b4c2008-04-26 20:48:56 +00001240 alpha*)
1241 BASECFLAGS="$BASECFLAGS -mieee"
1242 ;;
1243 esac
1244
Skip Montanarodecc6a42003-01-01 20:07:49 +00001245 case $ac_sys_system in
1246 SCO_SV*)
1247 BASECFLAGS="$BASECFLAGS -m486 -DSCO5"
1248 ;;
Benjamin Peterson67c38e22008-07-17 16:10:34 +00001249
Ned Deily87adb6e2013-10-18 21:09:56 -07001250 # is there any other compiler on Darwin besides gcc?
1251 Darwin*)
1252 # -Wno-long-double, -no-cpp-precomp, and -mno-fused-madd
1253 # used to be here, but non-Apple gcc doesn't accept them.
1254 if test "${CC}" = gcc
1255 then
1256 AC_MSG_CHECKING(which compiler should be used)
1257 case "${UNIVERSALSDK}" in
1258 */MacOSX10.4u.sdk)
1259 # Build using 10.4 SDK, force usage of gcc when the
1260 # compiler is gcc, otherwise the user will get very
1261 # confusing error messages when building on OSX 10.6
1262 CC=gcc-4.0
1263 CPP=cpp-4.0
1264 ;;
1265 esac
1266 AC_MSG_RESULT($CC)
1267 fi
Benjamin Peterson67c38e22008-07-17 16:10:34 +00001268
Ned Deily87adb6e2013-10-18 21:09:56 -07001269 if test "${enable_universalsdk}"
1270 then
1271 case "$UNIVERSAL_ARCHS" in
1272 32-bit)
1273 UNIVERSAL_ARCH_FLAGS="-arch ppc -arch i386"
1274 LIPO_32BIT_FLAGS=""
1275 ARCH_RUN_32BIT=""
1276 ;;
1277 64-bit)
1278 UNIVERSAL_ARCH_FLAGS="-arch ppc64 -arch x86_64"
1279 LIPO_32BIT_FLAGS=""
1280 ARCH_RUN_32BIT="true"
1281 ;;
1282 all)
1283 UNIVERSAL_ARCH_FLAGS="-arch i386 -arch ppc -arch ppc64 -arch x86_64"
1284 LIPO_32BIT_FLAGS="-extract ppc7400 -extract i386"
1285 ARCH_RUN_32BIT="/usr/bin/arch -i386 -ppc"
1286 ;;
1287 intel)
1288 UNIVERSAL_ARCH_FLAGS="-arch i386 -arch x86_64"
1289 LIPO_32BIT_FLAGS="-extract i386"
1290 ARCH_RUN_32BIT="/usr/bin/arch -i386"
1291 ;;
1292 intel-32)
1293 UNIVERSAL_ARCH_FLAGS="-arch i386"
1294 LIPO_32BIT_FLAGS=""
1295 ARCH_RUN_32BIT=""
1296 ;;
1297 3-way)
1298 UNIVERSAL_ARCH_FLAGS="-arch i386 -arch ppc -arch x86_64"
1299 LIPO_32BIT_FLAGS="-extract ppc7400 -extract i386"
1300 ARCH_RUN_32BIT="/usr/bin/arch -i386 -ppc"
1301 ;;
1302 *)
1303 AC_MSG_ERROR([proper usage is --with-universal-arch=32-bit|64-bit|all|intel|3-way])
1304 ;;
1305 esac
Georg Brandlfcaf9102008-07-16 02:17:56 +00001306
Ned Deily87adb6e2013-10-18 21:09:56 -07001307 CFLAGS="${UNIVERSAL_ARCH_FLAGS} -isysroot ${UNIVERSALSDK} ${CFLAGS}"
1308 LDFLAGS="${UNIVERSAL_ARCH_FLAGS} -isysroot ${UNIVERSALSDK} ${LDFLAGS}"
1309 if test "${UNIVERSALSDK}" != "/"
1310 then
1311 CPPFLAGS="-isysroot ${UNIVERSALSDK} ${CPPFLAGS}"
1312 fi
1313 fi
Georg Brandlfcaf9102008-07-16 02:17:56 +00001314
Ned Deily87adb6e2013-10-18 21:09:56 -07001315 # Calculate an appropriate deployment target for this build:
1316 # The deployment target value is used explicitly to enable certain
1317 # features are enabled (such as builtin libedit support for readline)
1318 # through the use of Apple's Availabiliy Macros and is used as a
1319 # component of the string returned by distutils.get_platform().
1320 #
1321 # Use the value from:
1322 # 1. the MACOSX_DEPLOYMENT_TARGET environment variable if specified
1323 # 2. the operating system version of the build machine if >= 10.6
1324 # 3. If running on OS X 10.3 through 10.5, use the legacy tests
1325 # below to pick either 10.3, 10.4, or 10.5 as the target.
1326 # 4. If we are running on OS X 10.2 or earlier, good luck!
Ronald Oussoren3c064c12009-09-08 07:12:42 +00001327
Ned Deily87adb6e2013-10-18 21:09:56 -07001328 AC_MSG_CHECKING(which MACOSX_DEPLOYMENT_TARGET to use)
Ned Deily36820b62014-06-25 13:44:22 -07001329 cur_target_major=`sw_vers -productVersion | \
1330 sed 's/\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'`
1331 cur_target_minor=`sw_vers -productVersion | \
1332 sed 's/\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'`
1333 cur_target="${cur_target_major}.${cur_target_minor}"
1334 if test ${cur_target_major} -eq 10 && \
1335 test ${cur_target_minor} -ge 3 && \
1336 test ${cur_target_minor} -le 5
Ned Deily87adb6e2013-10-18 21:09:56 -07001337 then
Ned Deily36820b62014-06-25 13:44:22 -07001338 # OS X 10.3 through 10.5
Ned Deily87adb6e2013-10-18 21:09:56 -07001339 cur_target=10.3
1340 if test ${enable_universalsdk}
1341 then
1342 case "$UNIVERSAL_ARCHS" in
1343 all|3-way|intel|64-bit)
1344 # These configurations were first supported in 10.5
1345 cur_target='10.5'
1346 ;;
1347 esac
1348 else
1349 if test `/usr/bin/arch` = "i386"
1350 then
1351 # 10.4 was the first release to support Intel archs
1352 cur_target="10.4"
1353 fi
1354 fi
1355 fi
1356 CONFIGURE_MACOSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET-${cur_target}}
Ronald Oussoren3c064c12009-09-08 07:12:42 +00001357
Ned Deily87adb6e2013-10-18 21:09:56 -07001358 # Make sure that MACOSX_DEPLOYMENT_TARGET is set in the
1359 # environment with a value that is the same as what we'll use
1360 # in the Makefile to ensure that we'll get the same compiler
1361 # environment during configure and build time.
1362 MACOSX_DEPLOYMENT_TARGET="$CONFIGURE_MACOSX_DEPLOYMENT_TARGET"
1363 export MACOSX_DEPLOYMENT_TARGET
1364 EXPORT_MACOSX_DEPLOYMENT_TARGET=''
1365 AC_MSG_RESULT($MACOSX_DEPLOYMENT_TARGET)
Georg Brandlfcaf9102008-07-16 02:17:56 +00001366
Ned Deily87adb6e2013-10-18 21:09:56 -07001367 # end of Darwin* tests
1368 ;;
Skip Montanarodecc6a42003-01-01 20:07:49 +00001369 esac
1370 ;;
1371
1372*)
1373 case $ac_sys_system in
1374 OpenUNIX*|UnixWare*)
1375 BASECFLAGS="$BASECFLAGS -K pentium,host,inline,loop_unroll,alloca "
1376 ;;
1377 SCO_SV*)
1378 BASECFLAGS="$BASECFLAGS -belf -Ki486 -DSCO5"
1379 ;;
1380 esac
1381 ;;
1382esac
1383
Fred Drakee1ceaa02001-12-04 20:55:47 +00001384if test "$Py_DEBUG" = 'true'; then
1385 :
1386else
1387 OPT="-DNDEBUG $OPT"
1388fi
1389
Guido van Rossum6f2260e1996-09-09 16:21:03 +00001390if test "$ac_arch_flags"
Guido van Rossumc5a39031996-07-31 17:35:03 +00001391then
Skip Montanarodecc6a42003-01-01 20:07:49 +00001392 BASECFLAGS="$BASECFLAGS $ac_arch_flags"
Guido van Rossumc5a39031996-07-31 17:35:03 +00001393fi
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001394
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00001395# On some compilers, pthreads are available without further options
1396# (e.g. MacOS X). On some of these systems, the compiler will not
1397# complain if unaccepted options are passed (e.g. gcc on Mac OS X).
1398# So we have to see first whether pthreads are available without
1399# options before we can check whether -Kpthread improves anything.
1400AC_MSG_CHECKING(whether pthreads are available without options)
1401AC_CACHE_VAL(ac_cv_pthread_is_default,
Matthias Kloseb159a552010-04-25 21:00:44 +00001402[AC_RUN_IFELSE([AC_LANG_SOURCE([[
Stefan Krah7dba5942012-11-22 22:49:11 +01001403#include <stdio.h>
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00001404#include <pthread.h>
1405
1406void* routine(void* p){return NULL;}
1407
1408int main(){
1409 pthread_t p;
1410 if(pthread_create(&p,NULL,routine,NULL)!=0)
1411 return 1;
Jack Jansen4f8d0542002-03-08 13:43:01 +00001412 (void)pthread_detach(p);
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00001413 return 0;
1414}
Matthias Kloseb159a552010-04-25 21:00:44 +00001415]])],[
Skip Montanarod8d39a02003-07-10 20:44:10 +00001416 ac_cv_pthread_is_default=yes
1417 ac_cv_kthread=no
1418 ac_cv_pthread=no
Matthias Kloseb159a552010-04-25 21:00:44 +00001419],[ac_cv_pthread_is_default=no],[ac_cv_pthread_is_default=no])
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00001420])
1421AC_MSG_RESULT($ac_cv_pthread_is_default)
1422
1423
1424if test $ac_cv_pthread_is_default = yes
1425then
1426 ac_cv_kpthread=no
1427else
Martin v. Löwis130fb172001-07-19 11:00:41 +00001428# -Kpthread, if available, provides the right #defines
1429# and linker options to make pthread_create available
Martin v. Löwis260aecc2001-10-07 08:14:41 +00001430# Some compilers won't report that they do not support -Kpthread,
1431# so we need to run a program to see whether it really made the
1432# function available.
Martin v. Löwis130fb172001-07-19 11:00:41 +00001433AC_MSG_CHECKING(whether $CC accepts -Kpthread)
1434AC_CACHE_VAL(ac_cv_kpthread,
1435[ac_save_cc="$CC"
1436CC="$CC -Kpthread"
Matthias Kloseb159a552010-04-25 21:00:44 +00001437AC_RUN_IFELSE([AC_LANG_SOURCE([[
Stefan Krah7dba5942012-11-22 22:49:11 +01001438#include <stdio.h>
Martin v. Löwis260aecc2001-10-07 08:14:41 +00001439#include <pthread.h>
1440
1441void* routine(void* p){return NULL;}
1442
1443int main(){
1444 pthread_t p;
1445 if(pthread_create(&p,NULL,routine,NULL)!=0)
1446 return 1;
Jack Jansen4f8d0542002-03-08 13:43:01 +00001447 (void)pthread_detach(p);
Martin v. Löwis260aecc2001-10-07 08:14:41 +00001448 return 0;
1449}
Matthias Kloseb159a552010-04-25 21:00:44 +00001450]])],[ac_cv_kpthread=yes],[ac_cv_kpthread=no],[ac_cv_kpthread=no])
Martin v. Löwis130fb172001-07-19 11:00:41 +00001451CC="$ac_save_cc"])
Martin v. Löwis130fb172001-07-19 11:00:41 +00001452AC_MSG_RESULT($ac_cv_kpthread)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00001453fi
Martin v. Löwis130fb172001-07-19 11:00:41 +00001454
Skip Montanarod8d39a02003-07-10 20:44:10 +00001455if test $ac_cv_kpthread = no -a $ac_cv_pthread_is_default = no
Martin v. Löwis5f433f02003-05-05 05:05:30 +00001456then
1457# -Kthread, if available, provides the right #defines
1458# and linker options to make pthread_create available
1459# Some compilers won't report that they do not support -Kthread,
1460# so we need to run a program to see whether it really made the
1461# function available.
1462AC_MSG_CHECKING(whether $CC accepts -Kthread)
1463AC_CACHE_VAL(ac_cv_kthread,
1464[ac_save_cc="$CC"
1465CC="$CC -Kthread"
Matthias Kloseb159a552010-04-25 21:00:44 +00001466AC_RUN_IFELSE([AC_LANG_SOURCE([[
Stefan Krah7dba5942012-11-22 22:49:11 +01001467#include <stdio.h>
Martin v. Löwis5f433f02003-05-05 05:05:30 +00001468#include <pthread.h>
1469
1470void* routine(void* p){return NULL;}
1471
1472int main(){
1473 pthread_t p;
1474 if(pthread_create(&p,NULL,routine,NULL)!=0)
1475 return 1;
1476 (void)pthread_detach(p);
1477 return 0;
1478}
Matthias Kloseb159a552010-04-25 21:00:44 +00001479]])],[ac_cv_kthread=yes],[ac_cv_kthread=no],[ac_cv_kthread=no])
Martin v. Löwis5f433f02003-05-05 05:05:30 +00001480CC="$ac_save_cc"])
1481AC_MSG_RESULT($ac_cv_kthread)
1482fi
1483
Skip Montanarod8d39a02003-07-10 20:44:10 +00001484if test $ac_cv_kthread = no -a $ac_cv_pthread_is_default = no
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00001485then
1486# -pthread, if available, provides the right #defines
1487# and linker options to make pthread_create available
1488# Some compilers won't report that they do not support -pthread,
1489# so we need to run a program to see whether it really made the
1490# function available.
1491AC_MSG_CHECKING(whether $CC accepts -pthread)
doko@python.org7981f202013-01-25 15:33:25 +01001492AC_CACHE_VAL(ac_cv_pthread,
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00001493[ac_save_cc="$CC"
1494CC="$CC -pthread"
Matthias Kloseb159a552010-04-25 21:00:44 +00001495AC_RUN_IFELSE([AC_LANG_SOURCE([[
Stefan Krah7dba5942012-11-22 22:49:11 +01001496#include <stdio.h>
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00001497#include <pthread.h>
1498
1499void* routine(void* p){return NULL;}
1500
1501int main(){
1502 pthread_t p;
1503 if(pthread_create(&p,NULL,routine,NULL)!=0)
1504 return 1;
1505 (void)pthread_detach(p);
1506 return 0;
1507}
Matthias Kloseb159a552010-04-25 21:00:44 +00001508]])],[ac_cv_pthread=yes],[ac_cv_pthread=no],[ac_cv_pthread=no])
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00001509CC="$ac_save_cc"])
1510AC_MSG_RESULT($ac_cv_pthread)
1511fi
1512
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001513# If we have set a CC compiler flag for thread support then
1514# check if it works for CXX, too.
1515ac_cv_cxx_thread=no
1516if test ! -z "$CXX"
1517then
1518AC_MSG_CHECKING(whether $CXX also accepts flags for thread support)
1519ac_save_cxx="$CXX"
1520
1521if test "$ac_cv_kpthread" = "yes"
1522then
Martin v. Löwis519adae2003-09-20 10:47:47 +00001523 CXX="$CXX -Kpthread"
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001524 ac_cv_cxx_thread=yes
1525elif test "$ac_cv_kthread" = "yes"
1526then
1527 CXX="$CXX -Kthread"
1528 ac_cv_cxx_thread=yes
1529elif test "$ac_cv_pthread" = "yes"
1530then
1531 CXX="$CXX -pthread"
1532 ac_cv_cxx_thread=yes
1533fi
1534
1535if test $ac_cv_cxx_thread = yes
1536then
1537 echo 'void foo();int main(){foo();}void foo(){}' > conftest.$ac_ext
1538 $CXX -c conftest.$ac_ext 2>&5
1539 if $CXX -o conftest$ac_exeext conftest.$ac_objext 2>&5 \
1540 && test -s conftest$ac_exeext && ./conftest$ac_exeext
1541 then
1542 ac_cv_cxx_thread=yes
1543 else
1544 ac_cv_cxx_thread=no
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001545 fi
1546 rm -fr conftest*
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001547fi
Brett Cannonc601e0f2004-11-07 01:24:12 +00001548AC_MSG_RESULT($ac_cv_cxx_thread)
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001549fi
Martin v. Löwis519adae2003-09-20 10:47:47 +00001550CXX="$ac_save_cxx"
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001551
Fred Drakece81d592000-07-09 14:39:29 +00001552dnl # check for ANSI or K&R ("traditional") preprocessor
1553dnl AC_MSG_CHECKING(for C preprocessor type)
Matthias Kloseb159a552010-04-25 21:00:44 +00001554dnl AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Fred Drakece81d592000-07-09 14:39:29 +00001555dnl #define spam(name, doc) {#name, &name, #name "() -- " doc}
1556dnl int foo;
1557dnl struct {char *name; int *addr; char *doc;} desc = spam(foo, "something");
Matthias Kloseb159a552010-04-25 21:00:44 +00001558dnl ]], [[;]])],[cpp_type=ansi],[AC_DEFINE(HAVE_OLD_CPP) cpp_type=traditional])
Fred Drakece81d592000-07-09 14:39:29 +00001559dnl AC_MSG_RESULT($cpp_type)
Guido van Rossum300fda71996-08-19 21:58:16 +00001560
Guido van Rossum627b2d71993-12-24 10:39:16 +00001561# checks for header files
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001562AC_HEADER_STDC
doko@ubuntu.com1a4f5612014-04-17 20:13:44 +02001563AC_CHECK_HEADERS(asm/types.h conio.h direct.h dlfcn.h errno.h \
Thomas Wouters0e3f5912006-08-11 14:57:12 +00001564fcntl.h grp.h \
doko@ubuntu.com1a4f5612014-04-17 20:13:44 +02001565ieeefp.h io.h langinfo.h libintl.h process.h pthread.h \
Benjamin Peterson94b580d2011-08-02 17:30:04 -05001566sched.h shadow.h signal.h stdint.h stropts.h termios.h \
Martin v. Löwis14e73b12003-01-01 09:51:12 +00001567unistd.h utime.h \
Jesus Cead8b9ae62011-11-14 19:07:41 +01001568poll.h sys/devpoll.h sys/epoll.h sys/poll.h \
Antoine Pitroubcf2b592012-02-08 23:28:36 +01001569sys/audioio.h sys/xattr.h sys/bsdtty.h sys/event.h sys/file.h sys/ioctl.h \
Martin v. Löwis9d6c6692012-02-03 17:44:58 +01001570sys/kern_control.h sys/loadavg.h sys/lock.h sys/mkdev.h sys/modem.h \
Jesus Cead8b9ae62011-11-14 19:07:41 +01001571sys/param.h sys/select.h sys/sendfile.h sys/socket.h sys/statvfs.h \
Martin v. Löwis9d6c6692012-02-03 17:44:58 +01001572sys/stat.h sys/syscall.h sys/sys_domain.h sys/termio.h sys/time.h \
Giampaolo Rodolàc9c2c8b2011-02-25 14:39:16 +00001573sys/times.h sys/types.h sys/uio.h sys/un.h sys/utsname.h sys/wait.h pty.h \
Gregory P. Smith3b1f2c32011-05-15 12:18:23 -07001574libutil.h sys/resource.h netpacket/packet.h sysexits.h bluetooth.h \
Christian Heimes985ecdc2013-11-20 11:46:18 +01001575bluetooth/bluetooth.h linux/tipc.h spawn.h util.h alloca.h endian.h \
1576sys/endian.h)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001577AC_HEADER_DIRENT
Martin v. Löwisdbe3f762002-10-10 14:27:30 +00001578AC_HEADER_MAJOR
Guido van Rossum627b2d71993-12-24 10:39:16 +00001579
Gregory P. Smith3b1f2c32011-05-15 12:18:23 -07001580# On Darwin (OS X) net/if.h requires sys/socket.h to be imported first.
1581AC_CHECK_HEADERS([net/if.h], [], [],
1582[#include <stdio.h>
1583#ifdef STDC_HEADERS
1584# include <stdlib.h>
1585# include <stddef.h>
1586#else
1587# ifdef HAVE_STDLIB_H
1588# include <stdlib.h>
1589# endif
1590#endif
1591#ifdef HAVE_SYS_SOCKET_H
1592# include <sys/socket.h>
1593#endif
1594])
1595
Martin v. Löwis11017b12006-01-14 18:12:57 +00001596# On Linux, netlink.h requires asm/types.h
1597AC_CHECK_HEADERS(linux/netlink.h,,,[
1598#ifdef HAVE_ASM_TYPES_H
1599#include <asm/types.h>
1600#endif
1601#ifdef HAVE_SYS_SOCKET_H
1602#include <sys/socket.h>
1603#endif
1604])
1605
Charles-François Natali47413c12011-10-06 19:47:44 +02001606# On Linux, can.h and can/raw.h require sys/socket.h
Charles-François Natali773e42d2013-02-05 19:42:01 +01001607AC_CHECK_HEADERS(linux/can.h linux/can/raw.h linux/can/bcm.h,,,[
Charles-François Natali47413c12011-10-06 19:47:44 +02001608#ifdef HAVE_SYS_SOCKET_H
1609#include <sys/socket.h>
1610#endif
1611])
1612
Guido van Rossum627b2d71993-12-24 10:39:16 +00001613# checks for typedefs
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001614was_it_defined=no
1615AC_MSG_CHECKING(for clock_t in time.h)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001616AC_EGREP_HEADER(clock_t, time.h, was_it_defined=yes, [
1617 AC_DEFINE(clock_t, long, [Define to 'long' if <time.h> doesn't define.])
1618])
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001619AC_MSG_RESULT($was_it_defined)
1620
Neal Norwitz11690112002-07-30 01:08:28 +00001621AC_MSG_CHECKING(for makedev)
Jesus Cea740f53a2010-04-28 11:35:30 +00001622AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1623#if defined(MAJOR_IN_MKDEV)
1624#include <sys/mkdev.h>
1625#elif defined(MAJOR_IN_SYSMACROS)
1626#include <sys/sysmacros.h>
1627#else
1628#include <sys/types.h>
1629#endif
1630]], [[
1631 makedev(0, 0) ]])
Matthias Kloseb159a552010-04-25 21:00:44 +00001632],[ac_cv_has_makedev=yes],[ac_cv_has_makedev=no])
Neal Norwitz11690112002-07-30 01:08:28 +00001633AC_MSG_RESULT($ac_cv_has_makedev)
1634if test "$ac_cv_has_makedev" = "yes"; then
1635 AC_DEFINE(HAVE_MAKEDEV, 1, [Define this if you have the makedev macro.])
1636fi
1637
Christian Heimes985ecdc2013-11-20 11:46:18 +01001638# byte swapping
1639AC_MSG_CHECKING(for le64toh)
1640AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1641#ifdef HAVE_ENDIAN_H
1642#include <endian.h>
1643#elif defined(HAVE_SYS_ENDIAN_H)
1644#include <sys/endian.h>
1645#endif
1646]], [[
1647 le64toh(1) ]])
1648],[ac_cv_has_le64toh=yes],[ac_cv_has_le64toh=no])
1649AC_MSG_RESULT($ac_cv_has_le64toh)
1650if test "$ac_cv_has_le64toh" = "yes"; then
1651 AC_DEFINE(HAVE_HTOLE64, 1, [Define this if you have le64toh()])
1652fi
1653
Martin v. Löwis399a6892002-10-04 10:22:02 +00001654# Enabling LFS on Solaris (2.6 to 9) with gcc 2.95 triggers a bug in
1655# the system headers: If _XOPEN_SOURCE and _LARGEFILE_SOURCE are
1656# defined, but the compiler does not support pragma redefine_extname,
1657# and _LARGEFILE64_SOURCE is not defined, the headers refer to 64-bit
1658# structures (such as rlimit64) without declaring them. As a
1659# work-around, disable LFS on such configurations
1660
1661use_lfs=yes
1662AC_MSG_CHECKING(Solaris LFS bug)
Matthias Kloseb159a552010-04-25 21:00:44 +00001663AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwis399a6892002-10-04 10:22:02 +00001664#define _LARGEFILE_SOURCE 1
1665#define _FILE_OFFSET_BITS 64
1666#include <sys/resource.h>
Matthias Kloseb159a552010-04-25 21:00:44 +00001667]], [[struct rlimit foo;]])],[sol_lfs_bug=no],[sol_lfs_bug=yes])
Martin v. Löwis399a6892002-10-04 10:22:02 +00001668AC_MSG_RESULT($sol_lfs_bug)
1669if test "$sol_lfs_bug" = "yes"; then
1670 use_lfs=no
1671fi
1672
1673if test "$use_lfs" = "yes"; then
Guido van Rossum810cc512001-09-09 23:51:39 +00001674# Two defines needed to enable largefile support on various platforms
1675# These may affect some typedefs
Georg Brandl216e4042011-02-19 08:58:23 +00001676case $ac_sys_system/$ac_sys_release in
1677AIX*)
1678 AC_DEFINE(_LARGE_FILES, 1,
1679 [This must be defined on AIX systems to enable large file support.])
1680 ;;
1681esac
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001682AC_DEFINE(_LARGEFILE_SOURCE, 1,
1683[This must be defined on some systems to enable large file support.])
1684AC_DEFINE(_FILE_OFFSET_BITS, 64,
1685[This must be set to 64 on some systems to enable large file support.])
Martin v. Löwis399a6892002-10-04 10:22:02 +00001686fi
Guido van Rossum810cc512001-09-09 23:51:39 +00001687
Guido van Rossum300fda71996-08-19 21:58:16 +00001688# Add some code to confdefs.h so that the test for off_t works on SCO
1689cat >> confdefs.h <<\EOF
1690#if defined(SCO_DS)
1691#undef _OFF_T
1692#endif
1693EOF
1694
Guido van Rossumef2255b2000-03-10 22:30:29 +00001695# Type availability checks
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001696AC_TYPE_MODE_T
1697AC_TYPE_OFF_T
1698AC_TYPE_PID_T
Matthias Klosebada4c32010-04-25 21:18:48 +00001699AC_DEFINE_UNQUOTED([RETSIGTYPE],[void],[assume C89 semantics that RETSIGTYPE is always void])
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001700AC_TYPE_SIZE_T
1701AC_TYPE_UID_T
Mark Dickinson983bc162012-12-02 12:11:38 +00001702
1703# There are two separate checks for each of the exact-width integer types we
1704# need. First we check whether the type is available using the usual
1705# AC_CHECK_TYPE macro with the default includes (which includes <inttypes.h>
1706# and <stdint.h> where available). We then also use the special type checks of
1707# the form AC_TYPE_UINT32_T, which in the case that uint32_t is not available
1708# directly, #define's uint32_t to be a suitable type.
1709
1710AC_CHECK_TYPE(uint32_t,
1711 AC_DEFINE(HAVE_UINT32_T, 1, [Define if your compiler provides uint32_t.]),,)
Mark Dickinsonbd792642009-03-18 20:06:12 +00001712AC_TYPE_UINT32_T
Mark Dickinson983bc162012-12-02 12:11:38 +00001713
1714AC_CHECK_TYPE(uint64_t,
1715 AC_DEFINE(HAVE_UINT64_T, 1, [Define if your compiler provides uint64_t.]),,)
Mark Dickinsonbd792642009-03-18 20:06:12 +00001716AC_TYPE_UINT64_T
Mark Dickinson983bc162012-12-02 12:11:38 +00001717
1718AC_CHECK_TYPE(int32_t,
1719 AC_DEFINE(HAVE_INT32_T, 1, [Define if your compiler provides int32_t.]),,)
Mark Dickinsonbd792642009-03-18 20:06:12 +00001720AC_TYPE_INT32_T
Mark Dickinson983bc162012-12-02 12:11:38 +00001721
1722AC_CHECK_TYPE(int64_t,
1723 AC_DEFINE(HAVE_INT64_T, 1, [Define if your compiler provides int64_t.]),,)
Mark Dickinsonbd792642009-03-18 20:06:12 +00001724AC_TYPE_INT64_T
Mark Dickinson983bc162012-12-02 12:11:38 +00001725
Christian Heimes400adb02008-02-01 08:12:03 +00001726AC_CHECK_TYPE(ssize_t,
Matthias Klosec80c93f2010-04-24 17:04:35 +00001727 AC_DEFINE(HAVE_SSIZE_T, 1, [Define if your compiler provides ssize_t]),,)
Stefan Krah1919b7e2012-03-21 18:25:23 +01001728AC_CHECK_TYPE(__uint128_t,
1729 AC_DEFINE(HAVE_GCC_UINT128_T, 1, [Define if your compiler provides __uint128_t]),,)
Guido van Rossum627b2d71993-12-24 10:39:16 +00001730
Guido van Rossumef2255b2000-03-10 22:30:29 +00001731# Sizes of various common basic types
Skip Montanarob9820a32004-01-17 00:16:12 +00001732# ANSI C requires sizeof(char) == 1, so no need to check it
Guido van Rossum3065c942001-09-17 04:03:14 +00001733AC_CHECK_SIZEOF(int, 4)
1734AC_CHECK_SIZEOF(long, 4)
1735AC_CHECK_SIZEOF(void *, 4)
Guido van Rossum3065c942001-09-17 04:03:14 +00001736AC_CHECK_SIZEOF(short, 2)
1737AC_CHECK_SIZEOF(float, 4)
1738AC_CHECK_SIZEOF(double, 8)
1739AC_CHECK_SIZEOF(fpos_t, 4)
Martin v. Löwis18e16552006-02-15 17:27:45 +00001740AC_CHECK_SIZEOF(size_t, 4)
Christian Heimes400adb02008-02-01 08:12:03 +00001741AC_CHECK_SIZEOF(pid_t, 4)
Guido van Rossumac405f61994-09-12 10:56:06 +00001742
Guido van Rossumec95c7b1998-08-04 17:59:56 +00001743AC_MSG_CHECKING(for long long support)
1744have_long_long=no
Matthias Kloseb159a552010-04-25 21:00:44 +00001745AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[long long x; x = (long long)0;]])],[
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001746 AC_DEFINE(HAVE_LONG_LONG, 1, [Define this if you have the type long long.])
1747 have_long_long=yes
Matthias Kloseb159a552010-04-25 21:00:44 +00001748],[])
Guido van Rossumec95c7b1998-08-04 17:59:56 +00001749AC_MSG_RESULT($have_long_long)
Guido van Rossum8bc1dfd1999-04-10 16:01:48 +00001750if test "$have_long_long" = yes ; then
Guido van Rossum3065c942001-09-17 04:03:14 +00001751AC_CHECK_SIZEOF(long long, 8)
Guido van Rossumec95c7b1998-08-04 17:59:56 +00001752fi
1753
Travis E. Oliphant9b307842007-10-12 22:06:37 +00001754AC_MSG_CHECKING(for long double support)
1755have_long_double=no
Matthias Kloseb159a552010-04-25 21:00:44 +00001756AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[long double x; x = (long double)0;]])],[
Travis E. Oliphant9b307842007-10-12 22:06:37 +00001757 AC_DEFINE(HAVE_LONG_DOUBLE, 1, [Define this if you have the type long double.])
1758 have_long_double=yes
Matthias Kloseb159a552010-04-25 21:00:44 +00001759],[])
Travis E. Oliphant9b307842007-10-12 22:06:37 +00001760AC_MSG_RESULT($have_long_double)
1761if test "$have_long_double" = yes ; then
1762AC_CHECK_SIZEOF(long double, 16)
1763fi
1764
1765
Thomas Woutersb2137042007-02-01 18:02:27 +00001766AC_MSG_CHECKING(for _Bool support)
1767have_c99_bool=no
Matthias Kloseb159a552010-04-25 21:00:44 +00001768AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[_Bool x; x = (_Bool)0;]])],[
Thomas Woutersb2137042007-02-01 18:02:27 +00001769 AC_DEFINE(HAVE_C99_BOOL, 1, [Define this if you have the type _Bool.])
1770 have_c99_bool=yes
Matthias Kloseb159a552010-04-25 21:00:44 +00001771],[])
Thomas Woutersb2137042007-02-01 18:02:27 +00001772AC_MSG_RESULT($have_c99_bool)
1773if test "$have_c99_bool" = yes ; then
1774AC_CHECK_SIZEOF(_Bool, 1)
1775fi
1776
Thomas Wouters89f507f2006-12-13 04:49:30 +00001777AC_CHECK_TYPES(uintptr_t,
1778 [AC_CHECK_SIZEOF(uintptr_t, 4)],
1779 [], [#ifdef HAVE_STDINT_H
1780 #include <stdint.h>
Antoine Pitrou1bf29b72010-10-10 08:10:16 +00001781 #endif
1782 #ifdef HAVE_INTTYPES_H
1783 #include <inttypes.h>
Thomas Wouters89f507f2006-12-13 04:49:30 +00001784 #endif])
1785
Alexandre Vassalotti0805b4a2009-07-17 05:47:33 +00001786AC_CHECK_SIZEOF(off_t, [], [
1787#ifdef HAVE_SYS_TYPES_H
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001788#include <sys/types.h>
Alexandre Vassalotti0805b4a2009-07-17 05:47:33 +00001789#endif
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001790])
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001791
1792AC_MSG_CHECKING(whether to enable large file support)
Mark Dickinson2df5d282009-12-31 21:22:50 +00001793if test "$have_long_long" = yes
1794then
1795if test "$ac_cv_sizeof_off_t" -gt "$ac_cv_sizeof_long" -a \
Guido van Rossum8bc1dfd1999-04-10 16:01:48 +00001796 "$ac_cv_sizeof_long_long" -ge "$ac_cv_sizeof_off_t"; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001797 AC_DEFINE(HAVE_LARGEFILE_SUPPORT, 1,
1798 [Defined to enable large file support when an off_t is bigger than a long
1799 and long long is available and at least as big as an off_t. You may need
1800 to add some flags for configuration and compilation to enable this mode.
1801 (For Solaris and Linux, the necessary defines are already defined.)])
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001802 AC_MSG_RESULT(yes)
1803else
1804 AC_MSG_RESULT(no)
1805fi
Mark Dickinson2df5d282009-12-31 21:22:50 +00001806else
1807 AC_MSG_RESULT(no)
1808fi
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001809
Alexandre Vassalotti0805b4a2009-07-17 05:47:33 +00001810AC_CHECK_SIZEOF(time_t, [], [
1811#ifdef HAVE_SYS_TYPES_H
1812#include <sys/types.h>
1813#endif
1814#ifdef HAVE_TIME_H
Fred Drakea3f6e912000-06-29 20:44:47 +00001815#include <time.h>
Alexandre Vassalotti0805b4a2009-07-17 05:47:33 +00001816#endif
Fred Drakea3f6e912000-06-29 20:44:47 +00001817])
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001818
Trent Mick635f6fb2000-08-23 21:33:05 +00001819# if have pthread_t then define SIZEOF_PTHREAD_T
Martin v. Löwis123cbd22001-07-19 14:21:10 +00001820ac_save_cc="$CC"
1821if test "$ac_cv_kpthread" = "yes"
1822then CC="$CC -Kpthread"
Martin v. Löwis5f433f02003-05-05 05:05:30 +00001823elif test "$ac_cv_kthread" = "yes"
1824then CC="$CC -Kthread"
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00001825elif test "$ac_cv_pthread" = "yes"
1826then CC="$CC -pthread"
Martin v. Löwis123cbd22001-07-19 14:21:10 +00001827fi
Alexandre Vassalotti0805b4a2009-07-17 05:47:33 +00001828
Trent Mick635f6fb2000-08-23 21:33:05 +00001829AC_MSG_CHECKING(for pthread_t)
1830have_pthread_t=no
Matthias Kloseb159a552010-04-25 21:00:44 +00001831AC_COMPILE_IFELSE([
1832 AC_LANG_PROGRAM([[#include <pthread.h>]], [[pthread_t x; x = *(pthread_t*)0;]])
1833],[have_pthread_t=yes],[])
Trent Mick635f6fb2000-08-23 21:33:05 +00001834AC_MSG_RESULT($have_pthread_t)
1835if test "$have_pthread_t" = yes ; then
Alexandre Vassalotti0805b4a2009-07-17 05:47:33 +00001836 AC_CHECK_SIZEOF(pthread_t, [], [
1837#ifdef HAVE_PTHREAD_H
Neal Norwitz6eb37f02003-02-23 23:28:15 +00001838#include <pthread.h>
Alexandre Vassalotti0805b4a2009-07-17 05:47:33 +00001839#endif
Trent Mick635f6fb2000-08-23 21:33:05 +00001840 ])
Trent Mick635f6fb2000-08-23 21:33:05 +00001841fi
Martin v. Löwis123cbd22001-07-19 14:21:10 +00001842CC="$ac_save_cc"
Trent Mick635f6fb2000-08-23 21:33:05 +00001843
Bob Ippolito7026a0a2005-03-28 23:23:47 +00001844AC_SUBST(OTHER_LIBTOOL_OPT)
1845case $ac_sys_system/$ac_sys_release in
Thomas Wouters49fd7fa2006-04-21 10:40:58 +00001846 Darwin/@<:@01567@:>@\..*)
Bob Ippolito7026a0a2005-03-28 23:23:47 +00001847 OTHER_LIBTOOL_OPT="-prebind -seg1addr 0x10000000"
1848 ;;
1849 Darwin/*)
1850 OTHER_LIBTOOL_OPT=""
1851 ;;
1852esac
1853
Ronald Oussoren5bbab3e2009-09-06 11:01:15 +00001854
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001855AC_SUBST(LIBTOOL_CRUFT)
1856case $ac_sys_system/$ac_sys_release in
Thomas Wouters49fd7fa2006-04-21 10:40:58 +00001857 Darwin/@<:@01567@:>@\..*)
Thomas Wouters477c8d52006-05-27 19:21:47 +00001858 LIBTOOL_CRUFT="-framework System -lcc_dynamic"
1859 if test "${enable_universalsdk}"; then
1860 :
1861 else
Ronald Oussorene3da75a2010-02-11 13:38:58 +00001862 LIBTOOL_CRUFT="${LIBTOOL_CRUFT} -arch_only `/usr/bin/arch`"
Thomas Wouters477c8d52006-05-27 19:21:47 +00001863 fi
Jack Jansenb36687a2004-07-16 08:43:47 +00001864 LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -install_name $(PYTHONFRAMEWORKINSTALLDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansena3891ea2001-09-07 14:25:12 +00001865 LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -compatibility_version $(VERSION) -current_version $(VERSION)';;
Guido van Rossum5839e582000-10-09 19:52:35 +00001866 Darwin/*)
Ronald Oussoren9812a6c2010-02-07 11:53:18 +00001867 gcc_version=`gcc -dumpversion`
Bob Ippolito7026a0a2005-03-28 23:23:47 +00001868 if test ${gcc_version} '<' 4.0
1869 then
1870 LIBTOOL_CRUFT="-lcc_dynamic"
1871 else
1872 LIBTOOL_CRUFT=""
1873 fi
Matthias Kloseb159a552010-04-25 21:00:44 +00001874 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Ronald Oussoren5bbab3e2009-09-06 11:01:15 +00001875 #include <unistd.h>
1876 int main(int argc, char*argv[])
1877 {
1878 if (sizeof(long) == 4) {
1879 return 0;
1880 } else {
1881 return 1;
1882 }
Ronald Oussoren3c064c12009-09-08 07:12:42 +00001883 }
Matthias Kloseb159a552010-04-25 21:00:44 +00001884 ]])],[ac_osx_32bit=yes],[ac_osx_32bit=no],[ac_osx_32bit=yes])
Ronald Oussoren5bbab3e2009-09-06 11:01:15 +00001885
1886 if test "${ac_osx_32bit}" = "yes"; then
Ronald Oussorene3da75a2010-02-11 13:38:58 +00001887 case `/usr/bin/arch` in
Ronald Oussoren5bbab3e2009-09-06 11:01:15 +00001888 i386)
1889 MACOSX_DEFAULT_ARCH="i386"
1890 ;;
1891 ppc)
1892 MACOSX_DEFAULT_ARCH="ppc"
1893 ;;
1894 *)
1895 AC_MSG_ERROR([Unexpected output of 'arch' on OSX])
1896 ;;
1897 esac
1898 else
Ronald Oussorene3da75a2010-02-11 13:38:58 +00001899 case `/usr/bin/arch` in
Ronald Oussoren5bbab3e2009-09-06 11:01:15 +00001900 i386)
1901 MACOSX_DEFAULT_ARCH="x86_64"
1902 ;;
1903 ppc)
1904 MACOSX_DEFAULT_ARCH="ppc64"
1905 ;;
1906 *)
1907 AC_MSG_ERROR([Unexpected output of 'arch' on OSX])
1908 ;;
1909 esac
1910
Ronald Oussoren5bbab3e2009-09-06 11:01:15 +00001911 fi
1912
1913 LIBTOOL_CRUFT=$LIBTOOL_CRUFT" -lSystem -lSystemStubs -arch_only ${MACOSX_DEFAULT_ARCH}"
Jack Jansenb36687a2004-07-16 08:43:47 +00001914 LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -install_name $(PYTHONFRAMEWORKINSTALLDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001915 LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -compatibility_version $(VERSION) -current_version $(VERSION)';;
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001916esac
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001917AC_MSG_CHECKING(for --enable-framework)
1918if test "$enable_framework"
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001919then
Skip Montanarodecc6a42003-01-01 20:07:49 +00001920 BASECFLAGS="$BASECFLAGS -fno-common -dynamic"
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001921 # -F. is needed to allow linking to the framework while
1922 # in the build location.
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001923 AC_DEFINE(WITH_NEXT_FRAMEWORK, 1,
1924 [Define if you want to produce an OpenStep/Rhapsody framework
1925 (shared library plus accessory files).])
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001926 AC_MSG_RESULT(yes)
Ronald Oussoren99aab652009-06-08 21:22:57 +00001927 if test $enable_shared = "yes"
1928 then
1929 AC_MSG_ERROR([Specifying both --enable-shared and --enable-framework is not supported, use only --enable-framework instead])
1930 fi
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001931else
1932 AC_MSG_RESULT(no)
1933fi
1934
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001935AC_MSG_CHECKING(for dyld)
Jack Jansen9a66b6d2001-08-08 13:56:14 +00001936case $ac_sys_system/$ac_sys_release in
1937 Darwin/*)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001938 AC_DEFINE(WITH_DYLD, 1,
1939 [Define if you want to use the new-style (Openstep, Rhapsody, MacOS)
1940 dynamic linker (dyld) instead of the old-style (NextStep) dynamic
1941 linker (rld). Dyld is necessary to support frameworks.])
Jack Jansen9a66b6d2001-08-08 13:56:14 +00001942 AC_MSG_RESULT(always on for Darwin)
1943 ;;
1944 *)
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001945 AC_MSG_RESULT(no)
1946 ;;
Jack Jansen9a66b6d2001-08-08 13:56:14 +00001947esac
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001948
Guido van Rossumac405f61994-09-12 10:56:06 +00001949# Set info about shared libraries.
doko@ubuntu.comd5537d02013-03-21 13:21:49 -07001950AC_SUBST(SHLIB_SUFFIX)
Guido van Rossumac405f61994-09-12 10:56:06 +00001951AC_SUBST(LDSHARED)
Tarek Ziadé03d788d2010-04-03 08:46:49 +00001952AC_SUBST(LDCXXSHARED)
Neil Schemenauerb3531b82001-02-16 04:09:05 +00001953AC_SUBST(BLDSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00001954AC_SUBST(CCSHARED)
1955AC_SUBST(LINKFORSHARED)
Georg Brandlb1441c72009-01-03 22:33:39 +00001956
doko@ubuntu.comd5537d02013-03-21 13:21:49 -07001957# SHLIB_SUFFIX is the extension of shared libraries `(including the dot!)
1958# -- usually .so, .sl on HP-UX, .dll on Cygwin
1959AC_MSG_CHECKING(the extension of shared libraries)
1960if test -z "$SHLIB_SUFFIX"; then
1961 case $ac_sys_system in
1962 hp*|HP*)
1963 case `uname -m` in
1964 ia64) SHLIB_SUFFIX=.so;;
1965 *) SHLIB_SUFFIX=.sl;;
1966 esac
1967 ;;
1968 CYGWIN*) SHLIB_SUFFIX=.dll;;
1969 *) SHLIB_SUFFIX=.so;;
1970 esac
1971fi
1972AC_MSG_RESULT($SHLIB_SUFFIX)
1973
Guido van Rossumac405f61994-09-12 10:56:06 +00001974# LDSHARED is the ld *command* used to create shared library
Skip Montanaroce59c042004-01-17 14:19:44 +00001975# -- "cc -G" on SunOS 5.x, "ld -shared" on IRIX 5
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001976# (Shared libraries in this instance are shared modules to be loaded into
1977# Python, as opposed to building Python itself as a shared library.)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001978AC_MSG_CHECKING(LDSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00001979if test -z "$LDSHARED"
1980then
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001981 case $ac_sys_system/$ac_sys_release in
Neil Schemenauerb3531b82001-02-16 04:09:05 +00001982 AIX*)
Georg Brandl9a829be2011-02-15 15:44:51 +00001983 BLDSHARED="\$(srcdir)/Modules/ld_so_aix \$(CC) -bI:\$(srcdir)/Modules/python.exp"
Guido van Rossumce608b02001-09-28 15:59:38 +00001984 LDSHARED="\$(BINLIBDEST)/config/ld_so_aix \$(CC) -bI:\$(BINLIBDEST)/config/python.exp"
Neil Schemenauerb3531b82001-02-16 04:09:05 +00001985 ;;
Guido van Rossum6100aaf1997-04-29 21:48:51 +00001986 IRIX/5*) LDSHARED="ld -shared";;
Guido van Rossum91922671997-10-09 20:24:13 +00001987 IRIX*/6*) LDSHARED="ld ${SGI_ABI} -shared -all";;
Greg Ward57c9a6632000-05-26 12:22:54 +00001988 SunOS/5*)
Tarek Ziadé03d788d2010-04-03 08:46:49 +00001989 if test "$GCC" = "yes" ; then
1990 LDSHARED='$(CC) -shared'
1991 LDCXXSHARED='$(CXX) -shared'
1992 else
1993 LDSHARED='$(CC) -G'
1994 LDCXXSHARED='$(CXX) -G'
Greg Ward57c9a6632000-05-26 12:22:54 +00001995 fi ;;
Thomas Hellerf44b9a12008-04-04 10:18:23 +00001996 hp*|HP*)
Tarek Ziadé03d788d2010-04-03 08:46:49 +00001997 if test "$GCC" = "yes" ; then
1998 LDSHARED='$(CC) -shared'
1999 LDCXXSHARED='$(CXX) -shared'
2000 else
2001 LDSHARED='ld -b'
Thomas Hellerf44b9a12008-04-04 10:18:23 +00002002 fi ;;
Jack Jansen418c3b12001-11-14 10:59:57 +00002003 Darwin/1.3*)
Antoine Pitroud4958c22010-10-13 17:01:10 +00002004 LDSHARED='$(CC) -bundle'
2005 LDCXXSHARED='$(CXX) -bundle'
Jack Jansena3891ea2001-09-07 14:25:12 +00002006 if test "$enable_framework" ; then
2007 # Link against the framework. All externals should be defined.
Jack Jansenda49e192005-01-07 13:08:22 +00002008 BLDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
2009 LDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Tarek Ziadé03d788d2010-04-03 08:46:49 +00002010 LDCXXSHARED="$LDCXXSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansena3891ea2001-09-07 14:25:12 +00002011 else
2012 # No framework. Ignore undefined symbols, assuming they come from Python
Jack Jansen418c3b12001-11-14 10:59:57 +00002013 LDSHARED="$LDSHARED -undefined suppress"
Tarek Ziadé03d788d2010-04-03 08:46:49 +00002014 LDCXXSHARED="$LDCXXSHARED -undefined suppress"
Jack Jansena3891ea2001-09-07 14:25:12 +00002015 fi ;;
Jack Jansen6b08a402004-06-03 12:41:45 +00002016 Darwin/1.4*|Darwin/5.*|Darwin/6.*)
Antoine Pitroud4958c22010-10-13 17:01:10 +00002017 LDSHARED='$(CC) -bundle'
2018 LDCXXSHARED='$(CXX) -bundle'
Jack Jansenb6e9cad2001-08-15 01:26:28 +00002019 if test "$enable_framework" ; then
2020 # Link against the framework. All externals should be defined.
Jack Jansenda49e192005-01-07 13:08:22 +00002021 BLDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
2022 LDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Tarek Ziadé03d788d2010-04-03 08:46:49 +00002023 LDCXXSHARED="$LDCXXSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansenb6e9cad2001-08-15 01:26:28 +00002024 else
Michael W. Hudson0c46c0c2002-03-07 09:58:56 +00002025 # No framework, use the Python app as bundle-loader
2026 BLDSHARED="$LDSHARED "'-bundle_loader $(BUILDPYTHON)'
Jack Jansenc28fc372003-02-25 13:14:43 +00002027 LDSHARED="$LDSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)'
Tarek Ziadé03d788d2010-04-03 08:46:49 +00002028 LDCXXSHARED="$LDCXXSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)'
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00002029 fi ;;
Jack Jansen6b08a402004-06-03 12:41:45 +00002030 Darwin/*)
2031 # Use -undefined dynamic_lookup whenever possible (10.3 and later).
2032 # This allows an extension to be used in any Python
Thomas Wouters89d996e2007-09-08 17:39:28 +00002033
Ned Deily36820b62014-06-25 13:44:22 -07002034 dep_target_major=`echo ${MACOSX_DEPLOYMENT_TARGET} | \
2035 sed 's/\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'`
2036 dep_target_minor=`echo ${MACOSX_DEPLOYMENT_TARGET} | \
2037 sed 's/\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'`
2038 if test ${dep_target_major} -eq 10 && \
2039 test ${dep_target_minor} -le 2
Jack Jansen6b08a402004-06-03 12:41:45 +00002040 then
Ned Deily36820b62014-06-25 13:44:22 -07002041 # building for OS X 10.0 through 10.2
Antoine Pitroud4958c22010-10-13 17:01:10 +00002042 LDSHARED='$(CC) -bundle'
2043 LDCXXSHARED='$(CXX) -bundle'
Jack Jansen6b08a402004-06-03 12:41:45 +00002044 if test "$enable_framework" ; then
2045 # Link against the framework. All externals should be defined.
Jack Jansenda49e192005-01-07 13:08:22 +00002046 BLDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
2047 LDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Tarek Ziadé03d788d2010-04-03 08:46:49 +00002048 LDCXXSHARED="$LDCXXSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansen6b08a402004-06-03 12:41:45 +00002049 else
2050 # No framework, use the Python app as bundle-loader
2051 BLDSHARED="$LDSHARED "'-bundle_loader $(BUILDPYTHON)'
2052 LDSHARED="$LDSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)'
Tarek Ziadé03d788d2010-04-03 08:46:49 +00002053 LDCXXSHARED="$LDCXXSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)'
Jack Jansen6b08a402004-06-03 12:41:45 +00002054 fi
Ned Deily36820b62014-06-25 13:44:22 -07002055 else
2056 # building for OS X 10.3 and later
2057 LDSHARED='$(CC) -bundle -undefined dynamic_lookup'
2058 LDCXXSHARED='$(CXX) -bundle -undefined dynamic_lookup'
2059 BLDSHARED="$LDSHARED"
Jack Jansen6b08a402004-06-03 12:41:45 +00002060 fi
2061 ;;
Tarek Ziadé03d788d2010-04-03 08:46:49 +00002062 Linux*|GNU*|QNX*)
2063 LDSHARED='$(CC) -shared'
2064 LDCXXSHARED='$(CXX) -shared';;
2065 BSD/OS*/4*)
2066 LDSHARED="gcc -shared"
2067 LDCXXSHARED="g++ -shared";;
Thomas Wouters1ba5b3b2006-06-08 14:52:47 +00002068 FreeBSD*)
Jeremy Hylton4bcc7c52000-08-31 17:45:35 +00002069 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
Guido van Rossum0286ae82000-08-29 15:06:49 +00002070 then
Antoine Pitroud4958c22010-10-13 17:01:10 +00002071 LDSHARED='$(CC) -shared'
2072 LDCXXSHARED='$(CXX) -shared'
Guido van Rossum0286ae82000-08-29 15:06:49 +00002073 else
Antoine Pitroud4958c22010-10-13 17:01:10 +00002074 LDSHARED="ld -Bshareable"
Guido van Rossum0286ae82000-08-29 15:06:49 +00002075 fi;;
Thomas Wouters1ba5b3b2006-06-08 14:52:47 +00002076 OpenBSD*)
2077 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
2078 then
Antoine Pitroud4958c22010-10-13 17:01:10 +00002079 LDSHARED='$(CC) -shared $(CCSHARED)'
2080 LDCXXSHARED='$(CXX) -shared $(CCSHARED)'
Thomas Wouters1ba5b3b2006-06-08 14:52:47 +00002081 else
2082 case `uname -r` in
2083 [[01]].* | 2.[[0-7]] | 2.[[0-7]].*)
2084 LDSHARED="ld -Bshareable ${LDFLAGS}"
2085 ;;
2086 *)
Antoine Pitroud4958c22010-10-13 17:01:10 +00002087 LDSHARED='$(CC) -shared $(CCSHARED)'
2088 LDCXXSHARED='$(CXX) -shared $(CCSHARED)'
Thomas Wouters1ba5b3b2006-06-08 14:52:47 +00002089 ;;
2090 esac
2091 fi;;
Tarek Ziadé03d788d2010-04-03 08:46:49 +00002092 NetBSD*|DragonFly*)
Antoine Pitrouece919e2011-01-02 20:45:21 +00002093 LDSHARED='$(CC) -shared'
2094 LDCXXSHARED='$(CXX) -shared';;
Martin v. Löwis25ae43b2001-10-07 08:39:18 +00002095 OpenUNIX*|UnixWare*)
Tarek Ziadé03d788d2010-04-03 08:46:49 +00002096 if test "$GCC" = "yes" ; then
2097 LDSHARED='$(CC) -shared'
2098 LDCXXSHARED='$(CXX) -shared'
2099 else
2100 LDSHARED='$(CC) -G'
2101 LDCXXSHARED='$(CXX) -G'
Martin v. Löwisbec19582001-03-21 15:57:54 +00002102 fi;;
Tarek Ziadé03d788d2010-04-03 08:46:49 +00002103 SCO_SV*)
2104 LDSHARED='$(CC) -Wl,-G,-Bexport'
2105 LDCXXSHARED='$(CXX) -Wl,-G,-Bexport';;
2106 CYGWIN*)
2107 LDSHARED="gcc -shared -Wl,--enable-auto-image-base"
2108 LDCXXSHARED="g++ -shared -Wl,--enable-auto-image-base";;
Guido van Rossumac405f61994-09-12 10:56:06 +00002109 *) LDSHARED="ld";;
2110 esac
Guido van Rossumac405f61994-09-12 10:56:06 +00002111fi
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002112AC_MSG_RESULT($LDSHARED)
Tarek Ziadé03d788d2010-04-03 08:46:49 +00002113LDCXXSHARED=${LDCXXSHARED-$LDSHARED}
Neil Schemenauerb3531b82001-02-16 04:09:05 +00002114BLDSHARED=${BLDSHARED-$LDSHARED}
Guido van Rossumac405f61994-09-12 10:56:06 +00002115# CCSHARED are the C *flags* used to create objects to go into a shared
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00002116# library (module) -- this is only needed for a few systems
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002117AC_MSG_CHECKING(CCSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00002118if test -z "$CCSHARED"
2119then
Guido van Rossum6100aaf1997-04-29 21:48:51 +00002120 case $ac_sys_system/$ac_sys_release in
Neil Schemenauer66252162001-02-19 04:47:42 +00002121 SunOS*) if test "$GCC" = yes;
Guido van Rossumd8faa362007-04-27 19:54:29 +00002122 then CCSHARED="-fPIC";
2123 elif test `uname -p` = sparc;
2124 then CCSHARED="-xcode=pic32";
2125 else CCSHARED="-Kpic";
2126 fi;;
Guido van Rossumaf07a441995-02-13 19:45:27 +00002127 hp*|HP*) if test "$GCC" = yes;
Martin v. Löwis703ad702001-09-05 08:36:52 +00002128 then CCSHARED="-fPIC";
Guido van Rossumaf07a441995-02-13 19:45:27 +00002129 else CCSHARED="+z";
2130 fi;;
Martin v. Löwisa6e97582002-01-01 18:41:33 +00002131 Linux*|GNU*) CCSHARED="-fPIC";;
Guido van Rossumf5957ea1999-10-05 21:59:33 +00002132 BSD/OS*/4*) CCSHARED="-fpic";;
Martin v. Löwis86d66262006-02-17 08:40:11 +00002133 FreeBSD*|NetBSD*|OpenBSD*|DragonFly*) CCSHARED="-fPIC";;
Martin v. Löwis25ae43b2001-10-07 08:39:18 +00002134 OpenUNIX*|UnixWare*)
Martin v. Löwisbec19582001-03-21 15:57:54 +00002135 if test "$GCC" = "yes"
2136 then CCSHARED="-fPIC"
Martin v. Löwis130fb172001-07-19 11:00:41 +00002137 else CCSHARED="-KPIC"
Martin v. Löwisbec19582001-03-21 15:57:54 +00002138 fi;;
Martin v. Löwis21ee4092002-09-30 16:19:48 +00002139 SCO_SV*)
2140 if test "$GCC" = "yes"
2141 then CCSHARED="-fPIC"
2142 else CCSHARED="-Kpic -belf"
2143 fi;;
Guido van Rossum2b5ca001998-03-05 15:41:09 +00002144 IRIX*/6*) case $CC in
2145 *gcc*) CCSHARED="-shared";;
Guido van Rossumee21f411998-04-20 18:51:54 +00002146 *) CCSHARED="";;
Guido van Rossum2b5ca001998-03-05 15:41:09 +00002147 esac;;
Guido van Rossumac405f61994-09-12 10:56:06 +00002148 esac
Guido van Rossumac405f61994-09-12 10:56:06 +00002149fi
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002150AC_MSG_RESULT($CCSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00002151# LINKFORSHARED are the flags passed to the $(CC) command that links
Guido van Rossumb65a48e1995-06-14 18:21:23 +00002152# the python executable -- this is only needed for a few systems
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002153AC_MSG_CHECKING(LINKFORSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00002154if test -z "$LINKFORSHARED"
2155then
Guido van Rossum6100aaf1997-04-29 21:48:51 +00002156 case $ac_sys_system/$ac_sys_release in
Neil Schemenauerb3531b82001-02-16 04:09:05 +00002157 AIX*) LINKFORSHARED='-Wl,-bE:Modules/python.exp -lld';;
Guido van Rossum5dab3d81996-12-06 21:18:18 +00002158 hp*|HP*)
Martin v. Löwis1142de32002-03-29 16:28:31 +00002159 LINKFORSHARED="-Wl,-E -Wl,+s";;
2160# LINKFORSHARED="-Wl,-E -Wl,+s -Wl,+b\$(BINLIBDEST)/lib-dynload";;
Guido van Rossumf5957ea1999-10-05 21:59:33 +00002161 BSD/OS/4*) LINKFORSHARED="-Xlinker -export-dynamic";;
Martin v. Löwisa6e97582002-01-01 18:41:33 +00002162 Linux*|GNU*) LINKFORSHARED="-Xlinker -export-dynamic";;
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00002163 # -u libsys_s pulls in all symbols in libsys
Jack Jansenb6e9cad2001-08-15 01:26:28 +00002164 Darwin/*)
Benjamin Peterson9c80cac2009-05-23 16:34:23 +00002165 LINKFORSHARED="$extra_undefs -framework CoreFoundation"
Łukasz Langa335ab5b2013-05-30 20:58:53 +02002166
2167 # Issue #18075: the default maximum stack size (8MBytes) is too
2168 # small for the default recursion limit. Increase the stack size
2169 # to ensure that tests don't crash
2170 LINKFORSHARED="-Wl,-stack_size,1000000 $LINKFORSHARED"
2171
Jack Jansenb6e9cad2001-08-15 01:26:28 +00002172 if test "$enable_framework"
2173 then
Jack Jansenda49e192005-01-07 13:08:22 +00002174 LINKFORSHARED="$LINKFORSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansenb6e9cad2001-08-15 01:26:28 +00002175 fi
Raymond Hettingerec6eb362004-11-05 07:02:59 +00002176 LINKFORSHARED="$LINKFORSHARED";;
Martin v. Löwis25ae43b2001-10-07 08:39:18 +00002177 OpenUNIX*|UnixWare*) LINKFORSHARED="-Wl,-Bexport";;
Martin v. Löwis21ee4092002-09-30 16:19:48 +00002178 SCO_SV*) LINKFORSHARED="-Wl,-Bexport";;
Fred Drake02706f52000-09-25 15:08:46 +00002179 ReliantUNIX*) LINKFORSHARED="-W1 -Blargedynsym";;
Martin v. Löwis86d66262006-02-17 08:40:11 +00002180 FreeBSD*|NetBSD*|OpenBSD*|DragonFly*)
Guido van Rossumdf693651999-01-07 21:50:41 +00002181 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
2182 then
2183 LINKFORSHARED="-Wl,--export-dynamic"
2184 fi;;
Guido van Rossum2b5ca001998-03-05 15:41:09 +00002185 SunOS/5*) case $CC in
2186 *gcc*)
Martin v. Löwisa4548572002-04-18 14:51:36 +00002187 if $CC -Xlinker --help 2>&1 | grep export-dynamic >/dev/null
Guido van Rossum8f4ceb11997-12-18 23:42:19 +00002188 then
2189 LINKFORSHARED="-Xlinker --export-dynamic"
Guido van Rossum2b5ca001998-03-05 15:41:09 +00002190 fi;;
2191 esac;;
Jason Tishler30765592003-09-04 11:04:06 +00002192 CYGWIN*)
2193 if test $enable_shared = "no"
2194 then
2195 LINKFORSHARED='-Wl,--out-implib=$(LDLIBRARY)'
2196 fi;;
Georg Brandlf78e02b2008-06-10 17:40:04 +00002197 QNX*)
2198 # -Wl,-E causes the symbols to be added to the dynamic
2199 # symbol table so that they can be found when a module
2200 # is loaded. -N 2048K causes the stack size to be set
2201 # to 2048 kilobytes so that the stack doesn't overflow
2202 # when running test_compile.py.
2203 LINKFORSHARED='-Wl,-E -N 2048K';;
Guido van Rossumac405f61994-09-12 10:56:06 +00002204 esac
Guido van Rossumac405f61994-09-12 10:56:06 +00002205fi
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002206AC_MSG_RESULT($LINKFORSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00002207
Georg Brandl93de2162008-07-16 02:21:06 +00002208
Neil Schemenauer61c51152001-01-26 16:18:16 +00002209AC_SUBST(CFLAGSFORSHARED)
2210AC_MSG_CHECKING(CFLAGSFORSHARED)
2211if test ! "$LIBRARY" = "$LDLIBRARY"
2212then
Neil Schemenauerd9cf41c2001-01-27 21:39:17 +00002213 case $ac_sys_system in
2214 CYGWIN*)
2215 # Cygwin needs CCSHARED when building extension DLLs
2216 # but not when building the interpreter DLL.
2217 CFLAGSFORSHARED='';;
2218 *)
2219 CFLAGSFORSHARED='$(CCSHARED)'
2220 esac
Neil Schemenauer61c51152001-01-26 16:18:16 +00002221fi
2222AC_MSG_RESULT($CFLAGSFORSHARED)
2223
Martin v. Löwisf90ae202002-06-11 06:22:31 +00002224# SHLIBS are libraries (except -lc and -lm) to link to the python shared
2225# library (with --enable-shared).
2226# For platforms on which shared libraries are not allowed to have unresolved
Martin v. Löwisd6359c52002-08-04 12:38:50 +00002227# symbols, this must be set to $(LIBS) (expanded by make). We do this even
2228# if it is not required, since it creates a dependency of the shared library
2229# to LIBS. This, in turn, means that applications linking the shared libpython
2230# don't need to link LIBS explicitly. The default should be only changed
2231# on systems where this approach causes problems.
Martin v. Löwisf90ae202002-06-11 06:22:31 +00002232AC_SUBST(SHLIBS)
2233AC_MSG_CHECKING(SHLIBS)
2234case "$ac_sys_system" in
Martin v. Löwisf90ae202002-06-11 06:22:31 +00002235 *)
Martin v. Löwisd6359c52002-08-04 12:38:50 +00002236 SHLIBS='$(LIBS)';;
Martin v. Löwisf90ae202002-06-11 06:22:31 +00002237esac
2238AC_MSG_RESULT($SHLIBS)
2239
2240
Guido van Rossum627b2d71993-12-24 10:39:16 +00002241# checks for libraries
Giampaolo Rodolàc9c2c8b2011-02-25 14:39:16 +00002242AC_CHECK_LIB(sendfile, sendfile)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002243AC_CHECK_LIB(dl, dlopen) # Dynamic linking for SunOS/Solaris and SYSV
2244AC_CHECK_LIB(dld, shl_load) # Dynamic linking for HP-UX
Victor Stinnerfcfed192015-01-06 13:54:58 +01002245AC_CHECK_LIB(crypto, RAND_egd,
2246 AC_DEFINE(HAVE_RAND_EGD, 1,
2247 [Define if the libcrypto has RAND_egd]))
Martin v. Löwis519adae2003-09-20 10:47:47 +00002248
Georg Brandleee31162008-12-07 15:15:22 +00002249# only check for sem_init if thread support is requested
Martin v. Löwis519adae2003-09-20 10:47:47 +00002250if test "$with_threads" = "yes" -o -z "$with_threads"; then
2251 AC_SEARCH_LIBS(sem_init, pthread rt posix4) # 'Real Time' functions on Solaris
2252 # posix4 on Solaris 2.6
2253 # pthread (first!) on Linux
2254fi
2255
Martin v. Löwis19d17342003-06-14 21:03:05 +00002256# check if we need libintl for locale functions
2257AC_CHECK_LIB(intl, textdomain,
Brett Cannonc6d936e2009-06-07 20:09:53 +00002258 [AC_DEFINE(WITH_LIBINTL, 1,
2259 [Define to 1 if libintl is needed for locale functions.])
2260 LIBS="-lintl $LIBS"])
Guido van Rossum0eefa3f1999-11-16 15:57:37 +00002261
2262# checks for system dependent C++ extensions support
2263case "$ac_sys_system" in
2264 AIX*) AC_MSG_CHECKING(for genuine AIX C++ extensions support)
Matthias Kloseb159a552010-04-25 21:00:44 +00002265 AC_LINK_IFELSE([
Georg Brandl59e87bd2011-02-15 19:48:59 +00002266 AC_LANG_PROGRAM([[#include <load.h>]],
Matthias Kloseb159a552010-04-25 21:00:44 +00002267 [[loadAndInit("", 0, "")]])
2268 ],[
2269 AC_DEFINE(AIX_GENUINE_CPLUSPLUS, 1,
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002270 [Define for AIX if your compiler is a genuine IBM xlC/xlC_r
2271 and you want support for AIX C++ shared extension modules.])
Matthias Kloseb159a552010-04-25 21:00:44 +00002272 AC_MSG_RESULT(yes)
2273 ],[
2274 AC_MSG_RESULT(no)
2275 ]);;
Guido van Rossum0eefa3f1999-11-16 15:57:37 +00002276 *) ;;
2277esac
2278
Christian Heimes985ecdc2013-11-20 11:46:18 +01002279# check for systems that require aligned memory access
2280AC_MSG_CHECKING(aligned memory access is required)
2281AC_TRY_RUN([
2282int main()
2283{
2284 char s[16];
2285 int i, *p1, *p2;
2286 for (i=0; i < 16; i++)
2287 s[i] = i;
2288 p1 = (int*)(s+1);
2289 p2 = (int*)(s+2);
2290 if (*p1 == *p2)
2291 return 1;
2292 return 0;
2293}
2294 ],
2295 [aligned_required=no],
2296 [aligned_required=yes],
2297 [aligned_required=yes])
2298
2299if test "$aligned_required" = yes ; then
2300 AC_DEFINE([HAVE_ALIGNED_REQUIRED], [1],
2301 [Define if aligned memory access is required])
2302fi
2303AC_MSG_RESULT($aligned_required)
2304
2305
2306# str, bytes and memoryview hash algorithm
2307AH_TEMPLATE(Py_HASH_ALGORITHM,
2308 [Define hash algorithm for str, bytes and memoryview.
2309 SipHash24: 1, FNV: 2, externally defined: 0])
2310
2311AC_MSG_CHECKING(for --with-hash-algorithm)
2312dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
2313AC_ARG_WITH(hash_algorithm,
2314 AS_HELP_STRING([--with-hash-algorithm=@<:@fnv|siphash24@:>@],
2315 [select hash algorithm]),
2316[
2317AC_MSG_RESULT($withval)
2318case "$withval" in
2319 siphash24)
2320 AC_DEFINE(Py_HASH_ALGORITHM, 1)
2321 ;;
2322 fnv)
2323 AC_DEFINE(Py_HASH_ALGORITHM, 2)
2324 ;;
2325 *)
2326 AC_MSG_ERROR([unknown hash algorithm '$withval'])
2327 ;;
2328esac
2329],
2330[AC_MSG_RESULT(default)])
2331
Guido van Rossum70c7f481998-03-26 18:44:10 +00002332# Most SVR4 platforms (e.g. Solaris) need -lsocket and -lnsl.
Guido van Rossumf618d2c1995-01-17 16:36:13 +00002333AC_CHECK_LIB(nsl, t_open, [LIBS="-lnsl $LIBS"]) # SVR4
Guido van Rossumf618d2c1995-01-17 16:36:13 +00002334AC_CHECK_LIB(socket, socket, [LIBS="-lsocket $LIBS"], [], $LIBS) # SVR4 sockets
Skip Montanarob9949db2004-01-17 04:04:13 +00002335
Guido van Rossumc5a39031996-07-31 17:35:03 +00002336AC_MSG_CHECKING(for --with-libs)
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00002337AC_ARG_WITH(libs,
Matthias Klose2b8733f2010-04-25 18:34:36 +00002338 AS_HELP_STRING([--with-libs='lib1 ...'], [link against additional libs]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002339[
Guido van Rossumc5a39031996-07-31 17:35:03 +00002340AC_MSG_RESULT($withval)
2341LIBS="$withval $LIBS"
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002342],
2343[AC_MSG_RESULT(no)])
Guido van Rossum627b2d71993-12-24 10:39:16 +00002344
Benjamin Peterson0f3cde12014-12-15 00:00:23 -05002345PKG_PROG_PKG_CONFIG
Benjamin Peterson0f64b0b2010-03-09 21:49:52 +00002346
Benjamin Petersonb2d90462009-12-31 03:23:10 +00002347# Check for use of the system expat library
2348AC_MSG_CHECKING(for --with-system-expat)
2349AC_ARG_WITH(system_expat,
Benjamin Peterson79263252010-10-31 16:50:44 +00002350 AS_HELP_STRING([--with-system-expat], [build pyexpat module using an installed expat library]),
2351 [],
2352 [with_system_expat="no"])
Benjamin Petersonb2d90462009-12-31 03:23:10 +00002353
2354AC_MSG_RESULT($with_system_expat)
2355
Thomas Wouters49fd7fa2006-04-21 10:40:58 +00002356# Check for use of the system libffi library
2357AC_MSG_CHECKING(for --with-system-ffi)
2358AC_ARG_WITH(system_ffi,
Benjamin Peterson79263252010-10-31 16:50:44 +00002359 AS_HELP_STRING([--with-system-ffi], [build _ctypes module using an installed ffi library]),
2360 [],
2361 [with_system_ffi="no"])
Thomas Wouters49fd7fa2006-04-21 10:40:58 +00002362
Benjamin Peterson0f64b0b2010-03-09 21:49:52 +00002363if test "$with_system_ffi" = "yes" && test -n "$PKG_CONFIG"; then
Benjamin Petersond78735d2010-01-01 16:04:23 +00002364 LIBFFI_INCLUDEDIR="`"$PKG_CONFIG" libffi --cflags-only-I 2>/dev/null | sed -e 's/^-I//;s/ *$//'`"
2365else
2366 LIBFFI_INCLUDEDIR=""
2367fi
2368AC_SUBST(LIBFFI_INCLUDEDIR)
2369
Thomas Wouters49fd7fa2006-04-21 10:40:58 +00002370AC_MSG_RESULT($with_system_ffi)
2371
Stefan Krah60187b52012-03-23 19:06:27 +01002372# Check for use of the system libmpdec library
2373AC_MSG_CHECKING(for --with-system-libmpdec)
2374AC_ARG_WITH(system_libmpdec,
2375 AS_HELP_STRING([--with-system-libmpdec], [build _decimal module using an installed libmpdec library]),
2376 [],
2377 [with_system_libmpdec="no"])
2378
2379AC_MSG_RESULT($with_system_libmpdec)
2380
Benjamin Peterson076ed002010-10-31 17:11:02 +00002381# Check for support for loadable sqlite extensions
2382AC_MSG_CHECKING(for --enable-loadable-sqlite-extensions)
2383AC_ARG_ENABLE(loadable-sqlite-extensions,
2384 AS_HELP_STRING([--enable-loadable-sqlite-extensions], [support loadable extensions in _sqlite module]),
2385 [],
2386 [enable_loadable_sqlite_extensions="no"])
2387
2388AC_MSG_RESULT($enable_loadable_sqlite_extensions)
2389
Ned Deilyd819b932013-09-06 01:07:05 -07002390# Check for --with-tcltk-includes=path and --with-tcltk-libs=path
2391AC_SUBST(TCLTK_INCLUDES)
2392AC_SUBST(TCLTK_LIBS)
2393AC_MSG_CHECKING(for --with-tcltk-includes)
2394AC_ARG_WITH(tcltk-includes,
2395 AS_HELP_STRING([--with-tcltk-includes='-I...'], [override search for Tcl and Tk include files]),
2396 [],
2397 [with_tcltk_includes="default"])
2398AC_MSG_RESULT($with_tcltk_includes)
2399AC_MSG_CHECKING(for --with-tcltk-libs)
2400AC_ARG_WITH(tcltk-libs,
2401 AS_HELP_STRING([--with-tcltk-libs='-L...'], [override search for Tcl and Tk libs]),
2402 [],
2403 [with_tcltk_libs="default"])
2404AC_MSG_RESULT($with_tcltk_libs)
2405if test "x$with_tcltk_includes" = xdefault || test "x$with_tcltk_libs" = xdefault
2406then
2407 if test "x$with_tcltk_includes" != "x$with_tcltk_libs"
2408 then
2409 AC_MSG_ERROR([use both --with-tcltk-includes='...' and --with-tcltk-libs='...' or neither])
2410 fi
2411 TCLTK_INCLUDES=""
2412 TCLTK_LIBS=""
2413else
2414 TCLTK_INCLUDES="$with_tcltk_includes"
2415 TCLTK_LIBS="$with_tcltk_libs"
2416fi
2417
Matthias Klose55708cc2009-04-30 08:06:49 +00002418# Check for --with-dbmliborder
2419AC_MSG_CHECKING(for --with-dbmliborder)
2420AC_ARG_WITH(dbmliborder,
Matthias Klose2b8733f2010-04-25 18:34:36 +00002421 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 Klose55708cc2009-04-30 08:06:49 +00002422[
2423if test x$with_dbmliborder = xyes
2424then
2425AC_MSG_ERROR([proper usage is --with-dbmliborder=db1:db2:...])
2426else
2427 for db in `echo $with_dbmliborder | sed 's/:/ /g'`; do
2428 if test x$db != xndbm && test x$db != xgdbm && test x$db != xbdb
2429 then
2430 AC_MSG_ERROR([proper usage is --with-dbmliborder=db1:db2:...])
2431 fi
2432 done
2433fi])
2434AC_MSG_RESULT($with_dbmliborder)
2435
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00002436# Determine if signalmodule should be used.
2437AC_SUBST(USE_SIGNAL_MODULE)
2438AC_SUBST(SIGNAL_OBJS)
2439AC_MSG_CHECKING(for --with-signal-module)
2440AC_ARG_WITH(signal-module,
Matthias Klose2b8733f2010-04-25 18:34:36 +00002441 AS_HELP_STRING([--with-signal-module], [disable/enable signal module]))
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00002442
2443if test -z "$with_signal_module"
2444then with_signal_module="yes"
2445fi
2446AC_MSG_RESULT($with_signal_module)
2447
2448if test "${with_signal_module}" = "yes"; then
2449 USE_SIGNAL_MODULE=""
2450 SIGNAL_OBJS=""
2451else
2452 USE_SIGNAL_MODULE="#"
2453 SIGNAL_OBJS="Parser/intrcheck.o Python/sigcheck.o"
2454fi
2455
Guido van Rossum3d15bd82001-01-10 18:53:48 +00002456# This is used to generate Setup.config
Guido van Rossum009f7871997-12-04 00:51:42 +00002457AC_SUBST(USE_THREAD_MODULE)
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00002458USE_THREAD_MODULE=""
Guido van Rossum009f7871997-12-04 00:51:42 +00002459
Guido van Rossum54d93d41997-01-22 20:51:58 +00002460AC_SUBST(LDLAST)
Guido van Rossum54d93d41997-01-22 20:51:58 +00002461
Martin v. Löwis11437992002-04-12 09:54:03 +00002462# Templates for things AC_DEFINEd more than once.
2463# For a single AC_DEFINE, no template is needed.
Martin v. Löwis11437992002-04-12 09:54:03 +00002464AH_TEMPLATE(_REENTRANT,
2465 [Define to force use of thread-safe errno, h_errno, and other functions])
2466AH_TEMPLATE(WITH_THREAD,
2467 [Define if you want to compile in rudimentary thread support])
2468
Guido van Rossum54d93d41997-01-22 20:51:58 +00002469AC_MSG_CHECKING(for --with-threads)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002470dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00002471AC_ARG_WITH(threads,
Matthias Klose2b8733f2010-04-25 18:34:36 +00002472 AS_HELP_STRING([--with(out)-threads@<:@=DIRECTORY@:>@], [disable/enable thread support]))
Guido van Rossum54d93d41997-01-22 20:51:58 +00002473
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00002474# --with-thread is deprecated, but check for it anyway
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002475dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
Barry Warsawa0f3c5c2000-06-30 16:39:35 +00002476AC_ARG_WITH(thread,
Matthias Klose2b8733f2010-04-25 18:34:36 +00002477 AS_HELP_STRING([--with(out)-thread@<:@=DIRECTORY@:>@], [deprecated; use --with(out)-threads]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002478 [with_threads=$with_thread])
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00002479
2480if test -z "$with_threads"
2481then with_threads="yes"
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002482fi
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00002483AC_MSG_RESULT($with_threads)
Guido van Rossum6400c261997-05-22 20:34:27 +00002484
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002485AC_SUBST(THREADOBJ)
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00002486if test "$with_threads" = "no"
2487then
2488 USE_THREAD_MODULE="#"
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002489elif test "$ac_cv_pthread_is_default" = yes
2490then
2491 AC_DEFINE(WITH_THREAD)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002492 # Defining _REENTRANT on system with POSIX threads should not hurt.
2493 AC_DEFINE(_REENTRANT)
2494 posix_threads=yes
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002495 THREADOBJ="Python/thread.o"
Martin v. Löwis130fb172001-07-19 11:00:41 +00002496elif test "$ac_cv_kpthread" = "yes"
2497then
2498 CC="$CC -Kpthread"
Martin v. Löwis519adae2003-09-20 10:47:47 +00002499 if test "$ac_cv_cxx_thread" = "yes"; then
2500 CXX="$CXX -Kpthread"
2501 fi
Martin v. Löwis130fb172001-07-19 11:00:41 +00002502 AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002503 posix_threads=yes
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002504 THREADOBJ="Python/thread.o"
Martin v. Löwis5f433f02003-05-05 05:05:30 +00002505elif test "$ac_cv_kthread" = "yes"
2506then
2507 CC="$CC -Kthread"
Martin v. Löwis519adae2003-09-20 10:47:47 +00002508 if test "$ac_cv_cxx_thread" = "yes"; then
2509 CXX="$CXX -Kthread"
2510 fi
Martin v. Löwis5f433f02003-05-05 05:05:30 +00002511 AC_DEFINE(WITH_THREAD)
2512 posix_threads=yes
2513 THREADOBJ="Python/thread.o"
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002514elif test "$ac_cv_pthread" = "yes"
2515then
2516 CC="$CC -pthread"
Martin v. Löwis519adae2003-09-20 10:47:47 +00002517 if test "$ac_cv_cxx_thread" = "yes"; then
2518 CXX="$CXX -pthread"
2519 fi
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002520 AC_DEFINE(WITH_THREAD)
2521 posix_threads=yes
2522 THREADOBJ="Python/thread.o"
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00002523else
Martin v. Löwis130fb172001-07-19 11:00:41 +00002524 if test ! -z "$with_threads" -a -d "$with_threads"
2525 then LDFLAGS="$LDFLAGS -L$with_threads"
2526 fi
2527 if test ! -z "$withval" -a -d "$withval"
2528 then LDFLAGS="$LDFLAGS -L$withval"
2529 fi
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002530
2531 # According to the POSIX spec, a pthreads implementation must
Matthias Klosea2542be2004-08-16 11:35:51 +00002532 # define _POSIX_THREADS in unistd.h. Some apparently don't
2533 # (e.g. gnu pth with pthread emulation)
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002534 AC_MSG_CHECKING(for _POSIX_THREADS in unistd.h)
2535 AC_EGREP_CPP(yes,
Neal Norwitz6eb37f02003-02-23 23:28:15 +00002536 [
2537#include <unistd.h>
2538#ifdef _POSIX_THREADS
2539yes
2540#endif
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002541 ], unistd_defines_pthreads=yes, unistd_defines_pthreads=no)
2542 AC_MSG_RESULT($unistd_defines_pthreads)
2543
Martin v. Löwis130fb172001-07-19 11:00:41 +00002544 AC_DEFINE(_REENTRANT)
Martin v. Löwis8158b5a2001-10-08 13:17:28 +00002545 # Just looking for pthread_create in libpthread is not enough:
2546 # on HP/UX, pthread.h renames pthread_create to a different symbol name.
2547 # So we really have to include pthread.h, and then link.
2548 _libs=$LIBS
2549 LIBS="$LIBS -lpthread"
2550 AC_MSG_CHECKING([for pthread_create in -lpthread])
Stefan Krah7dba5942012-11-22 22:49:11 +01002551 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
2552#include <stdio.h>
2553#include <pthread.h>
Martin v. Löwis8158b5a2001-10-08 13:17:28 +00002554
Matthias Kloseb159a552010-04-25 21:00:44 +00002555void * start_routine (void *arg) { exit (0); }]], [[
2556pthread_create (NULL, NULL, start_routine, NULL)]])],[
Martin v. Löwis8158b5a2001-10-08 13:17:28 +00002557 AC_MSG_RESULT(yes)
2558 AC_DEFINE(WITH_THREAD)
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002559 posix_threads=yes
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002560 THREADOBJ="Python/thread.o"],[
Martin v. Löwis8158b5a2001-10-08 13:17:28 +00002561 LIBS=$_libs
Martin v. Löwis130fb172001-07-19 11:00:41 +00002562 AC_CHECK_FUNC(pthread_detach, [AC_DEFINE(WITH_THREAD)
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002563 posix_threads=yes
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002564 THREADOBJ="Python/thread.o"],[
Martin v. Löwis130fb172001-07-19 11:00:41 +00002565 AC_CHECK_LIB(pthreads, pthread_create, [AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002566 posix_threads=yes
Martin v. Löwis130fb172001-07-19 11:00:41 +00002567 LIBS="$LIBS -lpthreads"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002568 THREADOBJ="Python/thread.o"], [
Martin v. Löwis130fb172001-07-19 11:00:41 +00002569 AC_CHECK_LIB(c_r, pthread_create, [AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002570 posix_threads=yes
Martin v. Löwis130fb172001-07-19 11:00:41 +00002571 LIBS="$LIBS -lc_r"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002572 THREADOBJ="Python/thread.o"], [
Martin v. Löwis130fb172001-07-19 11:00:41 +00002573 AC_CHECK_LIB(pthread, __pthread_create_system, [AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002574 posix_threads=yes
Martin v. Löwis130fb172001-07-19 11:00:41 +00002575 LIBS="$LIBS -lpthread"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002576 THREADOBJ="Python/thread.o"], [
Martin v. Löwis130fb172001-07-19 11:00:41 +00002577 AC_CHECK_LIB(cma, pthread_create, [AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002578 posix_threads=yes
Martin v. Löwis130fb172001-07-19 11:00:41 +00002579 LIBS="$LIBS -lcma"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002580 THREADOBJ="Python/thread.o"],[
Martin v. Löwis130fb172001-07-19 11:00:41 +00002581 USE_THREAD_MODULE="#"])
Antoine Pitrou37009202011-07-08 23:47:50 +02002582 ])])])])])
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00002583
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002584 AC_CHECK_LIB(mpc, usconfig, [AC_DEFINE(WITH_THREAD)
2585 LIBS="$LIBS -lmpc"
2586 THREADOBJ="Python/thread.o"
2587 USE_THREAD_MODULE=""])
2588
2589 if test "$posix_threads" != "yes"; then
2590 AC_CHECK_LIB(thread, thr_create, [AC_DEFINE(WITH_THREAD)
2591 LIBS="$LIBS -lthread"
2592 THREADOBJ="Python/thread.o"
2593 USE_THREAD_MODULE=""])
2594 fi
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002595fi
2596
2597if test "$posix_threads" = "yes"; then
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002598 if test "$unistd_defines_pthreads" = "no"; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002599 AC_DEFINE(_POSIX_THREADS, 1,
2600 [Define if you have POSIX threads,
2601 and your system does not define that.])
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002602 fi
2603
Martin v. Löwisdfc33fd2003-01-21 10:14:41 +00002604 # Bug 662787: Using semaphores causes unexplicable hangs on Solaris 8.
2605 case $ac_sys_system/$ac_sys_release in
Charles-François Natali996f6062011-07-21 19:45:31 +02002606 SunOS/5.6) AC_DEFINE(HAVE_PTHREAD_DESTRUCTOR, 1,
Matthias Klosec80c93f2010-04-24 17:04:35 +00002607 [Defined for Solaris 2.6 bug in pthread header.])
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002608 ;;
Martin v. Löwisdfc33fd2003-01-21 10:14:41 +00002609 SunOS/5.8) AC_DEFINE(HAVE_BROKEN_POSIX_SEMAPHORES, 1,
Matthias Klosec80c93f2010-04-24 17:04:35 +00002610 [Define if the Posix semaphores do not work on your system])
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002611 ;;
Charles-François Natali996f6062011-07-21 19:45:31 +02002612 AIX/*) AC_DEFINE(HAVE_BROKEN_POSIX_SEMAPHORES, 1,
Matthias Klosec80c93f2010-04-24 17:04:35 +00002613 [Define if the Posix semaphores do not work on your system])
Christian Heimes7b3ce6a2008-01-31 14:31:45 +00002614 ;;
Martin v. Löwisdfc33fd2003-01-21 10:14:41 +00002615 esac
2616
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002617 AC_MSG_CHECKING(if PTHREAD_SCOPE_SYSTEM is supported)
2618 AC_CACHE_VAL(ac_cv_pthread_system_supported,
Stefan Krah7dba5942012-11-22 22:49:11 +01002619 [AC_RUN_IFELSE([AC_LANG_SOURCE([[
2620 #include <stdio.h>
2621 #include <pthread.h>
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002622 void *foo(void *parm) {
2623 return NULL;
2624 }
2625 main() {
2626 pthread_attr_t attr;
Martin v. Löwisa82d3472002-02-24 16:05:05 +00002627 pthread_t id;
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002628 if (pthread_attr_init(&attr)) exit(-1);
2629 if (pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM)) exit(-1);
Martin v. Löwisa82d3472002-02-24 16:05:05 +00002630 if (pthread_create(&id, &attr, foo, NULL)) exit(-1);
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002631 exit(0);
Matthias Kloseb159a552010-04-25 21:00:44 +00002632 }]])],
2633 [ac_cv_pthread_system_supported=yes],
2634 [ac_cv_pthread_system_supported=no],
2635 [ac_cv_pthread_system_supported=no])
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002636 ])
2637 AC_MSG_RESULT($ac_cv_pthread_system_supported)
2638 if test "$ac_cv_pthread_system_supported" = "yes"; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002639 AC_DEFINE(PTHREAD_SYSTEM_SCHED_SUPPORTED, 1, [Defined if PTHREAD_SCOPE_SYSTEM supported.])
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002640 fi
Jason Tishlerfac083d2003-07-22 15:20:49 +00002641 AC_CHECK_FUNCS(pthread_sigmask,
2642 [case $ac_sys_system in
2643 CYGWIN*)
2644 AC_DEFINE(HAVE_BROKEN_PTHREAD_SIGMASK, 1,
2645 [Define if pthread_sigmask() does not work on your system.])
2646 ;;
2647 esac])
Christian Heimesf77b4b22013-08-21 13:26:05 +02002648 AC_CHECK_FUNCS(pthread_atfork)
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00002649fi
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002650
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002651
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002652# Check for enable-ipv6
Martin v. Löwis11437992002-04-12 09:54:03 +00002653AH_TEMPLATE(ENABLE_IPV6, [Define if --enable-ipv6 is specified])
Martin v. Löwisa5f8bb52001-09-05 08:22:34 +00002654AC_MSG_CHECKING([if --enable-ipv6 is specified])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002655AC_ARG_ENABLE(ipv6,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002656[ --enable-ipv6 Enable ipv6 (with ipv4) support
2657 --disable-ipv6 Disable ipv6 support],
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002658[ case "$enableval" in
2659 no)
2660 AC_MSG_RESULT(no)
2661 ipv6=no
2662 ;;
2663 *) AC_MSG_RESULT(yes)
2664 AC_DEFINE(ENABLE_IPV6)
2665 ipv6=yes
2666 ;;
2667 esac ],
2668
Martin v. Löwisa5f8bb52001-09-05 08:22:34 +00002669[
2670dnl the check does not work on cross compilation case...
Charles-François Natalif6fd7942013-01-08 19:49:42 +01002671 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ /* AF_INET6 available check */
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002672#include <sys/types.h>
Charles-François Natalif6fd7942013-01-08 19:49:42 +01002673#include <sys/socket.h>]],
2674[[int domain = AF_INET6;]])],[
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002675 AC_MSG_RESULT(yes)
Matthias Kloseb159a552010-04-25 21:00:44 +00002676 ipv6=yes
2677],[
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002678 AC_MSG_RESULT(no)
2679 ipv6=no
Matthias Kloseb159a552010-04-25 21:00:44 +00002680])
Martin v. Löwisa5f8bb52001-09-05 08:22:34 +00002681
2682if test "$ipv6" = "yes"; then
2683 AC_MSG_CHECKING(if RFC2553 API is available)
Matthias Kloseb159a552010-04-25 21:00:44 +00002684 AC_COMPILE_IFELSE([
2685 AC_LANG_PROGRAM([[#include <sys/types.h>
2686#include <netinet/in.h>]],
2687 [[struct sockaddr_in6 x;
2688 x.sin6_scope_id;]])
2689 ],[
2690 AC_MSG_RESULT(yes)
2691 ipv6=yes
2692 ],[
2693 AC_MSG_RESULT(no, IPv6 disabled)
2694 ipv6=no
2695 ])
Martin v. Löwisa5f8bb52001-09-05 08:22:34 +00002696fi
2697
2698if test "$ipv6" = "yes"; then
2699 AC_DEFINE(ENABLE_IPV6)
2700fi
2701])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002702
2703ipv6type=unknown
2704ipv6lib=none
2705ipv6trylibc=no
2706
2707if test "$ipv6" = "yes"; then
2708 AC_MSG_CHECKING([ipv6 stack type])
Guido van Rossumb8552162001-09-05 14:58:11 +00002709 for i in inria kame linux-glibc linux-inet6 solaris toshiba v6d zeta;
2710 do
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002711 case $i in
2712 inria)
2713 dnl http://www.kame.net/
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002714 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002715#include <netinet/in.h>
2716#ifdef IPV6_INRIA_VERSION
2717yes
2718#endif],
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002719 [ipv6type=$i])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002720 ;;
2721 kame)
2722 dnl http://www.kame.net/
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002723 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002724#include <netinet/in.h>
2725#ifdef __KAME__
2726yes
2727#endif],
2728 [ipv6type=$i;
2729 ipv6lib=inet6
2730 ipv6libdir=/usr/local/v6/lib
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002731 ipv6trylibc=yes])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002732 ;;
2733 linux-glibc)
2734 dnl http://www.v6.linux.or.jp/
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002735 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002736#include <features.h>
2737#if defined(__GLIBC__) && ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1) || (__GLIBC__ > 2))
2738yes
2739#endif],
2740 [ipv6type=$i;
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002741 ipv6trylibc=yes])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002742 ;;
2743 linux-inet6)
2744 dnl http://www.v6.linux.or.jp/
2745 if test -d /usr/inet6; then
2746 ipv6type=$i
2747 ipv6lib=inet6
2748 ipv6libdir=/usr/inet6/lib
Skip Montanarodecc6a42003-01-01 20:07:49 +00002749 BASECFLAGS="-I/usr/inet6/include $BASECFLAGS"
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002750 fi
2751 ;;
2752 solaris)
2753 if test -f /etc/netconfig; then
Antoine Pitrouf3fcd9f2011-01-03 18:53:50 +00002754 if $GREP -q tcp6 /etc/netconfig; then
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002755 ipv6type=$i
2756 ipv6trylibc=yes
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002757 fi
2758 fi
2759 ;;
2760 toshiba)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002761 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002762#include <sys/param.h>
2763#ifdef _TOSHIBA_INET6
2764yes
2765#endif],
2766 [ipv6type=$i;
2767 ipv6lib=inet6;
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002768 ipv6libdir=/usr/local/v6/lib])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002769 ;;
2770 v6d)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002771 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002772#include </usr/local/v6/include/sys/v6config.h>
2773#ifdef __V6D__
2774yes
2775#endif],
2776 [ipv6type=$i;
2777 ipv6lib=v6;
2778 ipv6libdir=/usr/local/v6/lib;
Skip Montanarodecc6a42003-01-01 20:07:49 +00002779 BASECFLAGS="-I/usr/local/v6/include $BASECFLAGS"])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002780 ;;
2781 zeta)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002782 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002783#include <sys/param.h>
2784#ifdef _ZETA_MINAMI_INET6
2785yes
2786#endif],
2787 [ipv6type=$i;
2788 ipv6lib=inet6;
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002789 ipv6libdir=/usr/local/v6/lib])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002790 ;;
2791 esac
2792 if test "$ipv6type" != "unknown"; then
2793 break
2794 fi
2795 done
2796 AC_MSG_RESULT($ipv6type)
2797fi
2798
2799if test "$ipv6" = "yes" -a "$ipv6lib" != "none"; then
2800 if test -d $ipv6libdir -a -f $ipv6libdir/lib$ipv6lib.a; then
2801 LIBS="-L$ipv6libdir -l$ipv6lib $LIBS"
2802 echo "using lib$ipv6lib"
2803 else
2804 if test $ipv6trylibc = "yes"; then
2805 echo "using libc"
2806 else
2807 echo 'Fatal: no $ipv6lib library found. cannot continue.'
2808 echo "You need to fetch lib$ipv6lib.a from appropriate"
2809 echo 'ipv6 kit and compile beforehand.'
2810 exit 1
2811 fi
2812 fi
2813fi
2814
Georg Brandl93de2162008-07-16 02:21:06 +00002815AC_MSG_CHECKING(for OSX 10.5 SDK or later)
Matthias Kloseb159a552010-04-25 21:00:44 +00002816AC_COMPILE_IFELSE([
2817 AC_LANG_PROGRAM([[#include <Carbon/Carbon.h>]], [[FSIORefNum fRef = 0]])
2818],[
Matthias Klosec80c93f2010-04-24 17:04:35 +00002819 AC_DEFINE(HAVE_OSX105_SDK, 1, [Define if compiling using MacOS X 10.5 SDK or later.])
Matthias Kloseb159a552010-04-25 21:00:44 +00002820 AC_MSG_RESULT(yes)
2821],[
Georg Brandl93de2162008-07-16 02:21:06 +00002822 AC_MSG_RESULT(no)
Matthias Kloseb159a552010-04-25 21:00:44 +00002823])
Georg Brandl93de2162008-07-16 02:21:06 +00002824
Martin v. Löwisa3fb4f72002-06-09 13:33:54 +00002825# Check for --with-doc-strings
2826AC_MSG_CHECKING(for --with-doc-strings)
2827AC_ARG_WITH(doc-strings,
Matthias Klose2b8733f2010-04-25 18:34:36 +00002828 AS_HELP_STRING([--with(out)-doc-strings], [disable/enable documentation strings]))
Martin v. Löwisa3fb4f72002-06-09 13:33:54 +00002829
2830if test -z "$with_doc_strings"
2831then with_doc_strings="yes"
2832fi
2833if test "$with_doc_strings" != "no"
2834then
2835 AC_DEFINE(WITH_DOC_STRINGS, 1,
2836 [Define if you want documentation strings in extension modules])
2837fi
2838AC_MSG_RESULT($with_doc_strings)
2839
Georg Brandl9976a512010-08-02 21:02:36 +00002840# Check if eval loop should use timestamp counter profiling
Martin v. Löwisf30d60e2004-06-08 08:17:44 +00002841AC_MSG_CHECKING(for --with-tsc)
2842AC_ARG_WITH(tsc,
Matthias Klose2b8733f2010-04-25 18:34:36 +00002843 AS_HELP_STRING([--with(out)-tsc],[enable/disable timestamp counter profile]),[
Martin v. Löwisf30d60e2004-06-08 08:17:44 +00002844if test "$withval" != no
2845then
2846 AC_DEFINE(WITH_TSC, 1,
2847 [Define to profile with the Pentium timestamp counter])
2848 AC_MSG_RESULT(yes)
2849else AC_MSG_RESULT(no)
2850fi],
2851[AC_MSG_RESULT(no)])
2852
2853# Check for Python-specific malloc support
Neil Schemenauera35c6882001-02-27 04:45:05 +00002854AC_MSG_CHECKING(for --with-pymalloc)
2855AC_ARG_WITH(pymalloc,
Matthias Klose2b8733f2010-04-25 18:34:36 +00002856 AS_HELP_STRING([--with(out)-pymalloc], [disable/enable specialized mallocs]))
Neil Schemenauer16c22972002-03-22 15:34:49 +00002857
2858if test -z "$with_pymalloc"
Barry Warsaw35f3a2c2010-09-03 18:30:30 +00002859then
2860 with_pymalloc="yes"
Neil Schemenauer16c22972002-03-22 15:34:49 +00002861fi
2862if test "$with_pymalloc" != "no"
2863then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002864 AC_DEFINE(WITH_PYMALLOC, 1,
2865 [Define if you want to compile in Python-specific mallocs])
doko@ubuntu.com9c7817e2012-06-30 17:05:13 +02002866 ABIFLAGS="${ABIFLAGS}m"
Neil Schemenauer16c22972002-03-22 15:34:49 +00002867fi
2868AC_MSG_RESULT($with_pymalloc)
Neil Schemenauera35c6882001-02-27 04:45:05 +00002869
Benjamin Peterson05159c42009-12-03 03:01:27 +00002870# Check for Valgrind support
2871AC_MSG_CHECKING([for --with-valgrind])
2872AC_ARG_WITH([valgrind],
Matthias Klose2b8733f2010-04-25 18:34:36 +00002873 AS_HELP_STRING([--with-valgrind], [Enable Valgrind support]),,
Benjamin Peterson05159c42009-12-03 03:01:27 +00002874 with_valgrind=no)
2875AC_MSG_RESULT([$with_valgrind])
2876if test "$with_valgrind" != no; then
2877 AC_CHECK_HEADER([valgrind/valgrind.h],
2878 [AC_DEFINE([WITH_VALGRIND], 1, [Define if you want pymalloc to be disabled when running under valgrind])],
2879 [AC_MSG_ERROR([Valgrind support requested but headers not available])]
2880 )
Jeffrey Yasskin39370832010-05-03 19:29:34 +00002881 OPT="-DDYNAMIC_ANNOTATIONS_ENABLED=1 $OPT"
Benjamin Peterson05159c42009-12-03 03:01:27 +00002882fi
2883
Guido van Rossum68242b51996-05-28 22:53:03 +00002884# -I${DLINCLDIR} is added to the compile rule for importdl.o
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002885AC_SUBST(DLINCLDIR)
Guido van Rossum98935bf2001-09-05 19:13:16 +00002886DLINCLDIR=.
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002887
Guido van Rossume97ee181999-12-20 21:27:22 +00002888# the dlopen() function means we might want to use dynload_shlib.o. some
2889# platforms, such as AIX, have dlopen(), but don't want to use it.
Thomas Wouters3a584202000-08-05 23:28:51 +00002890AC_CHECK_FUNCS(dlopen)
Guido van Rossume97ee181999-12-20 21:27:22 +00002891
2892# DYNLOADFILE specifies which dynload_*.o file we will use for dynamic
2893# loading of modules.
2894AC_SUBST(DYNLOADFILE)
2895AC_MSG_CHECKING(DYNLOADFILE)
2896if test -z "$DYNLOADFILE"
2897then
2898 case $ac_sys_system/$ac_sys_release in
Martin v. Löwisc19c5a62003-11-18 20:00:44 +00002899 AIX*) # Use dynload_shlib.c and dlopen() if we have it; otherwise dynload_aix.c
2900 if test "$ac_cv_func_dlopen" = yes
2901 then DYNLOADFILE="dynload_shlib.o"
2902 else DYNLOADFILE="dynload_aix.o"
2903 fi
2904 ;;
Guido van Rossume97ee181999-12-20 21:27:22 +00002905 hp*|HP*) DYNLOADFILE="dynload_hpux.o";;
Thomas Wouters49fd7fa2006-04-21 10:40:58 +00002906 # Use dynload_next.c only on 10.2 and below, which don't have native dlopen()
2907 Darwin/@<:@0156@:>@\..*) DYNLOADFILE="dynload_next.o";;
Guido van Rossume97ee181999-12-20 21:27:22 +00002908 *)
2909 # use dynload_shlib.c and dlopen() if we have it; otherwise stub
2910 # out any dynamic loading
2911 if test "$ac_cv_func_dlopen" = yes
2912 then DYNLOADFILE="dynload_shlib.o"
2913 else DYNLOADFILE="dynload_stub.o"
2914 fi
2915 ;;
2916 esac
2917fi
2918AC_MSG_RESULT($DYNLOADFILE)
2919if test "$DYNLOADFILE" != "dynload_stub.o"
2920then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002921 AC_DEFINE(HAVE_DYNAMIC_LOADING, 1,
2922 [Defined when any dynamic module loading is enabled.])
Guido van Rossume97ee181999-12-20 21:27:22 +00002923fi
2924
Jack Jansenc49e5b72001-06-19 15:00:23 +00002925# MACHDEP_OBJS can be set to platform-specific object files needed by Python
2926
2927AC_SUBST(MACHDEP_OBJS)
2928AC_MSG_CHECKING(MACHDEP_OBJS)
2929if test -z "$MACHDEP_OBJS"
2930then
Jack Jansenb6e9cad2001-08-15 01:26:28 +00002931 MACHDEP_OBJS=$extra_machdep_objs
2932else
2933 MACHDEP_OBJS="$MACHDEP_OBJS $extra_machdep_objs"
Jack Jansenc49e5b72001-06-19 15:00:23 +00002934fi
doko@ubuntu.com9c7817e2012-06-30 17:05:13 +02002935if test -z "$MACHDEP_OBJS"; then
2936 AC_MSG_RESULT([none])
2937else
2938 AC_MSG_RESULT([$MACHDEP_OBJS])
2939fi
Jack Jansenc49e5b72001-06-19 15:00:23 +00002940
Guido van Rossum627b2d71993-12-24 10:39:16 +00002941# checks for library functions
Antoine Pitroub1c54962010-10-14 15:05:38 +00002942AC_CHECK_FUNCS(alarm accept4 setitimer getitimer bind_textdomain_codeset chown \
Victor Stinnerdaf45552013-08-28 00:53:59 +02002943 clock confstr ctermid dup3 execv faccessat fchmod fchmodat fchown fchownat \
Ross Lagerwall7807c352011-03-17 20:20:30 +02002944 fexecve fdopendir fork fpathconf fstatat ftime ftruncate futimesat \
Victor Stinnerfe02e392014-12-21 01:16:38 +01002945 futimens futimes gai_strerror getentropy \
Ross Lagerwallb0ae53d2011-06-10 07:30:30 +02002946 getgrouplist getgroups getlogin getloadavg getpeername getpgid getpid \
Martin v. Löwis7aed61a2009-11-27 14:09:49 +00002947 getpriority getresuid getresgid getpwent getspnam getspent getsid getwd \
Gregory P. Smith5ed2e772011-05-15 00:26:45 -07002948 if_nameindex \
Antoine Pitrouf0effe62011-11-26 01:11:02 +01002949 initgroups kill killpg lchmod lchown lockf linkat lstat lutimes mmap \
2950 memrchr mbrtowc mkdirat mkfifo \
Charles-François Natalidaafdd52011-05-29 20:07:40 +02002951 mkfifoat mknod mknodat mktime mremap nice openat pathconf pause pipe2 plock poll \
Ross Lagerwall7807c352011-03-17 20:20:30 +02002952 posix_fallocate posix_fadvise pread \
Victor Stinnerb3e72192011-05-08 01:46:11 +02002953 pthread_init pthread_kill putenv pwrite readlink readlinkat readv realpath renameat \
Giampaolo Rodolàc9c2c8b2011-02-25 14:39:16 +00002954 select sem_open sem_timedwait sem_getvalue sem_unlink sendfile setegid seteuid \
Antoine Pitrou061cfb52011-02-28 22:25:22 +00002955 setgid sethostname \
Giampaolo Rodolà18e8bcb2011-02-25 20:57:54 +00002956 setlocale setregid setreuid setresuid setresgid setsid setpgid setpgrp setpriority setuid setvbuf \
Charles-François Nataliea0d5fc2011-09-06 19:03:35 +02002957 sched_get_priority_max sched_setaffinity sched_setscheduler sched_setparam \
2958 sched_rr_get_interval \
Ross Lagerwallbc808222011-06-25 12:13:40 +02002959 sigaction sigaltstack siginterrupt sigpending sigrelse \
2960 sigtimedwait sigwait sigwaitinfo snprintf strftime strlcpy symlinkat sync \
Michael W. Hudson34f20ea2002-05-27 15:08:24 +00002961 sysconf tcgetpgrp tcsetpgrp tempnam timegm times tmpfile tmpnam tmpnam_r \
Ross Lagerwall7807c352011-03-17 20:20:30 +02002962 truncate uname unlinkat unsetenv utimensat utimes waitid waitpid wait3 wait4 \
Victor Stinnercd777ea2013-04-08 22:43:44 +02002963 wcscoll wcsftime wcsxfrm wmemcmp writev _getpty)
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00002964
Gregory P. Smithdf300d52012-01-21 18:20:15 -08002965AC_CHECK_DECL(dirfd,
2966 AC_DEFINE(HAVE_DIRFD, 1,
2967 Define if you have the 'dirfd' function or macro.), ,
2968 [#include <sys/types.h>
2969 #include <dirent.h>])
2970
Martin v. Löwisc8ad7cc2002-11-11 13:23:45 +00002971# For some functions, having a definition is not sufficient, since
2972# we want to take their address.
2973AC_MSG_CHECKING(for chroot)
Matthias Kloseb159a552010-04-25 21:00:44 +00002974AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[void *x=chroot]])],
2975 [AC_DEFINE(HAVE_CHROOT, 1, Define if you have the 'chroot' function.)
2976 AC_MSG_RESULT(yes)],
2977 [AC_MSG_RESULT(no)
2978])
Martin v. Löwisc8ad7cc2002-11-11 13:23:45 +00002979AC_MSG_CHECKING(for link)
Matthias Kloseb159a552010-04-25 21:00:44 +00002980AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[void *x=link]])],
2981 [AC_DEFINE(HAVE_LINK, 1, Define if you have the 'link' function.)
2982 AC_MSG_RESULT(yes)],
2983 [AC_MSG_RESULT(no)
2984])
Martin v. Löwisc8ad7cc2002-11-11 13:23:45 +00002985AC_MSG_CHECKING(for symlink)
Matthias Kloseb159a552010-04-25 21:00:44 +00002986AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[void *x=symlink]])],
2987 [AC_DEFINE(HAVE_SYMLINK, 1, Define if you have the 'symlink' function.)
2988 AC_MSG_RESULT(yes)],
2989 [AC_MSG_RESULT(no)
2990])
Martin v. Löwisa64988c2003-09-20 15:30:20 +00002991AC_MSG_CHECKING(for fchdir)
Matthias Kloseb159a552010-04-25 21:00:44 +00002992AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[void *x=fchdir]])],
2993 [AC_DEFINE(HAVE_FCHDIR, 1, Define if you have the 'fchdir' function.)
2994 AC_MSG_RESULT(yes)],
2995 [AC_MSG_RESULT(no)
2996])
Martin v. Löwisa64988c2003-09-20 15:30:20 +00002997AC_MSG_CHECKING(for fsync)
Matthias Kloseb159a552010-04-25 21:00:44 +00002998AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[void *x=fsync]])],
2999 [AC_DEFINE(HAVE_FSYNC, 1, Define if you have the 'fsync' function.)
3000 AC_MSG_RESULT(yes)],
3001 [AC_MSG_RESULT(no)
3002])
Martin v. Löwisa64988c2003-09-20 15:30:20 +00003003AC_MSG_CHECKING(for fdatasync)
Matthias Kloseb159a552010-04-25 21:00:44 +00003004AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[void *x=fdatasync]])],
3005 [AC_DEFINE(HAVE_FDATASYNC, 1, Define if you have the 'fdatasync' function.)
3006 AC_MSG_RESULT(yes)],
3007 [AC_MSG_RESULT(no)
3008])
Christian Heimes4fbc72b2008-03-22 00:47:35 +00003009AC_MSG_CHECKING(for epoll)
Matthias Kloseb159a552010-04-25 21:00:44 +00003010AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/epoll.h>]], [[void *x=epoll_create]])],
3011 [AC_DEFINE(HAVE_EPOLL, 1, Define if you have the 'epoll' functions.)
3012 AC_MSG_RESULT(yes)],
3013 [AC_MSG_RESULT(no)
3014])
Benjamin Peterson95c16622011-12-27 15:36:32 -06003015AC_MSG_CHECKING(for epoll_create1)
3016AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/epoll.h>]], [[void *x=epoll_create1]])],
3017 [AC_DEFINE(HAVE_EPOLL_CREATE1, 1, Define if you have the 'epoll_create1' function.)
3018 AC_MSG_RESULT(yes)],
3019 [AC_MSG_RESULT(no)
3020])
Christian Heimes4fbc72b2008-03-22 00:47:35 +00003021AC_MSG_CHECKING(for kqueue)
Matthias Kloseb159a552010-04-25 21:00:44 +00003022AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Christian Heimes4fbc72b2008-03-22 00:47:35 +00003023#include <sys/types.h>
3024#include <sys/event.h>
Matthias Kloseb159a552010-04-25 21:00:44 +00003025 ]], [[int x=kqueue()]])],
3026 [AC_DEFINE(HAVE_KQUEUE, 1, Define if you have the 'kqueue' functions.)
3027 AC_MSG_RESULT(yes)],
3028 [AC_MSG_RESULT(no)
3029])
Christian Heimesb7bd5df2013-10-22 11:21:54 +02003030AC_MSG_CHECKING(for prlimit)
3031AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3032#include <sys/time.h>
3033#include <sys/resource.h>
3034 ]], [[void *x=prlimit]])],
3035 [AC_DEFINE(HAVE_PRLIMIT, 1, Define if you have the 'prlimit' functions.)
3036 AC_MSG_RESULT(yes)],
3037 [AC_MSG_RESULT(no)
3038])
3039
Martin v. Löwisd5843682002-11-21 20:41:28 +00003040# On some systems (eg. FreeBSD 5), we would find a definition of the
3041# functions ctermid_r, setgroups in the library, but no prototype
3042# (e.g. because we use _XOPEN_SOURCE). See whether we can take their
3043# address to avoid compiler warnings and potential miscompilations
3044# because of the missing prototypes.
3045
3046AC_MSG_CHECKING(for ctermid_r)
Matthias Kloseb159a552010-04-25 21:00:44 +00003047AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwisd5843682002-11-21 20:41:28 +00003048#include <stdio.h>
Matthias Kloseb159a552010-04-25 21:00:44 +00003049]], [[void* p = ctermid_r]])],
3050 [AC_DEFINE(HAVE_CTERMID_R, 1, Define if you have the 'ctermid_r' function.)
3051 AC_MSG_RESULT(yes)],
3052 [AC_MSG_RESULT(no)
3053])
Martin v. Löwisd5843682002-11-21 20:41:28 +00003054
Antoine Pitroua4e4ae22010-09-10 18:39:00 +00003055AC_CACHE_CHECK([for flock declaration], [ac_cv_flock_decl],
3056 [AC_COMPILE_IFELSE(
3057 [AC_LANG_PROGRAM(
3058 [#include <sys/file.h>],
3059 [void* p = flock]
3060 )],
3061 [ac_cv_flock_decl=yes],
3062 [ac_cv_flock_decl=no]
3063 )
Matthias Kloseb159a552010-04-25 21:00:44 +00003064])
Antoine Pitroua4e4ae22010-09-10 18:39:00 +00003065if test "x${ac_cv_flock_decl}" = xyes; then
3066 AC_CHECK_FUNCS(flock,,
3067 AC_CHECK_LIB(bsd,flock,
3068 [AC_DEFINE(HAVE_FLOCK)
3069 AC_DEFINE(FLOCK_NEEDS_LIBBSD, 1, Define if flock needs to be linked with bsd library.)
3070 ])
3071 )
Antoine Pitroua3000072010-09-07 14:52:42 +00003072fi
Martin v. Löwisf26d63b2003-03-30 17:23:49 +00003073
3074AC_MSG_CHECKING(for getpagesize)
Matthias Kloseb159a552010-04-25 21:00:44 +00003075AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwisf26d63b2003-03-30 17:23:49 +00003076#include <unistd.h>
Matthias Kloseb159a552010-04-25 21:00:44 +00003077]], [[void* p = getpagesize]])],
3078 [AC_DEFINE(HAVE_GETPAGESIZE, 1, Define if you have the 'getpagesize' function.)
3079 AC_MSG_RESULT(yes)],
3080 [AC_MSG_RESULT(no)
3081])
Martin v. Löwisf26d63b2003-03-30 17:23:49 +00003082
Victor Stinner984890f2011-11-24 13:53:38 +01003083AC_MSG_CHECKING(for broken unsetenv)
3084AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3085#include <stdlib.h>
3086]], [[int res = unsetenv("DUMMY")]])],
3087 [AC_MSG_RESULT(no)],
3088 [AC_DEFINE(HAVE_BROKEN_UNSETENV, 1, Define if `unsetenv` does not return an int.)
3089 AC_MSG_RESULT(yes)
3090])
3091
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00003092dnl check for true
3093AC_CHECK_PROGS(TRUE, true, /bin/true)
3094
Martin v. Löwis95c419b2003-05-03 12:10:48 +00003095dnl On some systems (e.g. Solaris 9), hstrerror and inet_aton are in -lresolv
3096dnl On others, they are in the C library, so we to take no action
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00003097AC_CHECK_LIB(c, inet_aton, [$ac_cv_prog_TRUE],
Martin v. Löwis95c419b2003-05-03 12:10:48 +00003098 AC_CHECK_LIB(resolv, inet_aton)
3099)
3100
Christian Heimesd0764e22007-12-04 15:00:33 +00003101# On Tru64, chflags seems to be present, but calling it will
3102# exit Python
Benjamin Petersoned68afa2010-01-30 19:36:43 +00003103AC_CACHE_CHECK([for chflags], [ac_cv_have_chflags], [dnl
Ned Deily3eb67d52011-06-28 00:00:28 -07003104AC_RUN_IFELSE([AC_LANG_SOURCE([[
Christian Heimesd0764e22007-12-04 15:00:33 +00003105#include <sys/stat.h>
3106#include <unistd.h>
3107int main(int argc, char*argv[])
3108{
3109 if(chflags(argv[0], 0) != 0)
3110 return 1;
3111 return 0;
3112}
Ned Deily3eb67d52011-06-28 00:00:28 -07003113]])],
Matthias Kloseb159a552010-04-25 21:00:44 +00003114[ac_cv_have_chflags=yes],
3115[ac_cv_have_chflags=no],
3116[ac_cv_have_chflags=cross])
Benjamin Petersoned68afa2010-01-30 19:36:43 +00003117])
3118if test "$ac_cv_have_chflags" = cross ; then
3119 AC_CHECK_FUNC([chflags], [ac_cv_have_chflags="yes"], [ac_cv_have_chflags="no"])
3120fi
3121if test "$ac_cv_have_chflags" = yes ; then
Ned Deily3eb67d52011-06-28 00:00:28 -07003122 AC_DEFINE(HAVE_CHFLAGS, 1, [Define to 1 if you have the 'chflags' function.])
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00003123fi
Christian Heimesd0764e22007-12-04 15:00:33 +00003124
Benjamin Petersoned68afa2010-01-30 19:36:43 +00003125AC_CACHE_CHECK([for lchflags], [ac_cv_have_lchflags], [dnl
Ned Deily3eb67d52011-06-28 00:00:28 -07003126AC_RUN_IFELSE([AC_LANG_SOURCE([[
Christian Heimesd0764e22007-12-04 15:00:33 +00003127#include <sys/stat.h>
3128#include <unistd.h>
3129int main(int argc, char*argv[])
3130{
3131 if(lchflags(argv[0], 0) != 0)
3132 return 1;
3133 return 0;
3134}
Ned Deily3eb67d52011-06-28 00:00:28 -07003135]])],[ac_cv_have_lchflags=yes],[ac_cv_have_lchflags=no],[ac_cv_have_lchflags=cross])
Benjamin Petersoned68afa2010-01-30 19:36:43 +00003136])
3137if test "$ac_cv_have_lchflags" = cross ; then
3138 AC_CHECK_FUNC([lchflags], [ac_cv_have_lchflags="yes"], [ac_cv_have_lchflags="no"])
3139fi
3140if test "$ac_cv_have_lchflags" = yes ; then
Ned Deily3eb67d52011-06-28 00:00:28 -07003141 AC_DEFINE(HAVE_LCHFLAGS, 1, [Define to 1 if you have the 'lchflags' function.])
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00003142fi
Christian Heimesd0764e22007-12-04 15:00:33 +00003143
Thomas Wouters0e3f5912006-08-11 14:57:12 +00003144dnl Check if system zlib has *Copy() functions
3145dnl
3146dnl On MacOSX the linker will search for dylibs on the entire linker path
3147dnl before searching for static libraries. setup.py adds -Wl,-search_paths_first
3148dnl to revert to a more traditional unix behaviour and make it possible to
3149dnl override the system libz with a local static library of libz. Temporarily
3150dnl add that flag to our CFLAGS as well to ensure that we check the version
3151dnl of libz that will be used by setup.py.
3152dnl The -L/usr/local/lib is needed as wel to get the same compilation
3153dnl environment as setup.py (and leaving it out can cause configure to use the
3154dnl wrong version of the library)
3155case $ac_sys_system/$ac_sys_release in
3156Darwin/*)
3157 _CUR_CFLAGS="${CFLAGS}"
3158 _CUR_LDFLAGS="${LDFLAGS}"
3159 CFLAGS="${CFLAGS} -Wl,-search_paths_first"
3160 LDFLAGS="${LDFLAGS} -Wl,-search_paths_first -L/usr/local/lib"
3161 ;;
3162esac
3163
Matthias Klosec80c93f2010-04-24 17:04:35 +00003164AC_CHECK_LIB(z, inflateCopy, AC_DEFINE(HAVE_ZLIB_COPY, 1, [Define if the zlib library has inflateCopy]))
Thomas Wouters0e3f5912006-08-11 14:57:12 +00003165
3166case $ac_sys_system/$ac_sys_release in
3167Darwin/*)
3168 CFLAGS="${_CUR_CFLAGS}"
3169 LDFLAGS="${_CUR_LDFLAGS}"
3170 ;;
3171esac
3172
Martin v. Löwise9416172003-05-03 10:12:45 +00003173AC_MSG_CHECKING(for hstrerror)
Matthias Kloseb159a552010-04-25 21:00:44 +00003174AC_LINK_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwise9416172003-05-03 10:12:45 +00003175#include <netdb.h>
Matthias Kloseb159a552010-04-25 21:00:44 +00003176]], [[void* p = hstrerror; hstrerror(0)]])],
3177 [AC_DEFINE(HAVE_HSTRERROR, 1, Define if you have the 'hstrerror' function.)
3178 AC_MSG_RESULT(yes)],
3179 [AC_MSG_RESULT(no)
3180])
Martin v. Löwise9416172003-05-03 10:12:45 +00003181
3182AC_MSG_CHECKING(for inet_aton)
Matthias Kloseb159a552010-04-25 21:00:44 +00003183AC_LINK_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwis86d66262006-02-17 08:40:11 +00003184#include <sys/types.h>
Martin v. Löwise9416172003-05-03 10:12:45 +00003185#include <sys/socket.h>
3186#include <netinet/in.h>
3187#include <arpa/inet.h>
Matthias Kloseb159a552010-04-25 21:00:44 +00003188]], [[void* p = inet_aton;inet_aton(0,0)]])],
3189 [AC_DEFINE(HAVE_INET_ATON, 1, Define if you have the 'inet_aton' function.)
3190 AC_MSG_RESULT(yes)],
3191 [AC_MSG_RESULT(no)
3192])
Martin v. Löwise9416172003-05-03 10:12:45 +00003193
3194AC_MSG_CHECKING(for inet_pton)
Matthias Kloseb159a552010-04-25 21:00:44 +00003195AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwisf2e488d2003-05-05 22:00:11 +00003196#include <sys/types.h>
Martin v. Löwise9416172003-05-03 10:12:45 +00003197#include <sys/socket.h>
3198#include <netinet/in.h>
3199#include <arpa/inet.h>
Matthias Kloseb159a552010-04-25 21:00:44 +00003200]], [[void* p = inet_pton]])],
3201 [AC_DEFINE(HAVE_INET_PTON, 1, Define if you have the 'inet_pton' function.)
3202 AC_MSG_RESULT(yes)],
3203 [AC_MSG_RESULT(no)
3204])
Martin v. Löwise9416172003-05-03 10:12:45 +00003205
Martin v. Löwisd6640d42003-07-06 09:29:52 +00003206# On some systems, setgroups is in unistd.h, on others, in grp.h
Martin v. Löwisd5843682002-11-21 20:41:28 +00003207AC_MSG_CHECKING(for setgroups)
Matthias Kloseb159a552010-04-25 21:00:44 +00003208AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwisf2e488d2003-05-05 22:00:11 +00003209#include <unistd.h>
Martin v. Löwisd6640d42003-07-06 09:29:52 +00003210#ifdef HAVE_GRP_H
3211#include <grp.h>
3212#endif
Matthias Kloseb159a552010-04-25 21:00:44 +00003213]], [[void* p = setgroups]])],
3214 [AC_DEFINE(HAVE_SETGROUPS, 1, Define if you have the 'setgroups' function.)
3215 AC_MSG_RESULT(yes)],
3216 [AC_MSG_RESULT(no)
3217])
Martin v. Löwisd5843682002-11-21 20:41:28 +00003218
Fred Drake8cef4cf2000-06-28 16:40:38 +00003219# check for openpty and forkpty
3220
Martin v. Löwisfd9a72a2006-01-08 10:07:33 +00003221AC_CHECK_FUNCS(openpty,,
3222 AC_CHECK_LIB(util,openpty,
3223 [AC_DEFINE(HAVE_OPENPTY) LIBS="$LIBS -lutil"],
3224 AC_CHECK_LIB(bsd,openpty, [AC_DEFINE(HAVE_OPENPTY) LIBS="$LIBS -lbsd"])
3225 )
3226)
3227AC_CHECK_FUNCS(forkpty,,
3228 AC_CHECK_LIB(util,forkpty,
3229 [AC_DEFINE(HAVE_FORKPTY) LIBS="$LIBS -lutil"],
3230 AC_CHECK_LIB(bsd,forkpty, [AC_DEFINE(HAVE_FORKPTY) LIBS="$LIBS -lbsd"])
3231 )
3232)
Fred Drake8cef4cf2000-06-28 16:40:38 +00003233
Christian Heimesb186d002008-03-18 15:15:01 +00003234# Stuff for expat.
3235AC_CHECK_FUNCS(memmove)
3236
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00003237# check for long file support functions
3238AC_CHECK_FUNCS(fseek64 fseeko fstatvfs ftell64 ftello statvfs)
3239
Benjamin Peterson3a7dffa2013-08-23 21:01:48 -05003240AC_REPLACE_FUNCS(dup2 strdup)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003241AC_CHECK_FUNCS(getpgrp,
Matthias Kloseb159a552010-04-25 21:00:44 +00003242 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[getpgrp(0);]])],
3243 [AC_DEFINE(GETPGRP_HAVE_ARG, 1, [Define if getpgrp() must be called as getpgrp(0).])],
3244 [])
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003245)
Jack Jansen150753c2003-03-29 22:07:47 +00003246AC_CHECK_FUNCS(setpgrp,
Matthias Kloseb159a552010-04-25 21:00:44 +00003247 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[setpgrp(0,0);]])],
3248 [AC_DEFINE(SETPGRP_HAVE_ARG, 1, [Define if setpgrp() must be called as setpgrp(0, 0).])],
3249 [])
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003250)
3251AC_CHECK_FUNCS(gettimeofday,
Matthias Kloseb159a552010-04-25 21:00:44 +00003252 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/time.h>]],
3253 [[gettimeofday((struct timeval*)0,(struct timezone*)0);]])],
3254 [],
3255 [AC_DEFINE(GETTIMEOFDAY_NO_TZ, 1,
3256 [Define if gettimeofday() does not have second (timezone) argument
3257 This is the case on Motorola V4 (R40V4.2)])
3258 ])
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003259)
Guido van Rossum627b2d71993-12-24 10:39:16 +00003260
Victor Stinnere0be4232011-10-25 13:06:09 +02003261AC_CHECK_FUNCS(clock_gettime, [], [
3262 AC_CHECK_LIB(rt, clock_gettime, [
3263 AC_DEFINE(HAVE_CLOCK_GETTIME, 1)
3264 AC_DEFINE(TIMEMODULE_LIB, [rt],
3265 [Library needed by timemodule.c: librt may be needed for clock_gettime()])
3266 ])
3267])
3268
3269AC_CHECK_FUNCS(clock_getres, [], [
3270 AC_CHECK_LIB(rt, clock_getres, [
3271 AC_DEFINE(HAVE_CLOCK_GETRES, 1)
3272 ])
3273])
3274
Martin v. Löwisdbe3f762002-10-10 14:27:30 +00003275AC_MSG_CHECKING(for major, minor, and makedev)
Matthias Kloseb159a552010-04-25 21:00:44 +00003276AC_LINK_IFELSE([AC_LANG_PROGRAM([[
Neal Norwitz6eb37f02003-02-23 23:28:15 +00003277#if defined(MAJOR_IN_MKDEV)
3278#include <sys/mkdev.h>
3279#elif defined(MAJOR_IN_SYSMACROS)
3280#include <sys/sysmacros.h>
3281#else
3282#include <sys/types.h>
3283#endif
Matthias Kloseb159a552010-04-25 21:00:44 +00003284]], [[
Martin v. Löwisdbe3f762002-10-10 14:27:30 +00003285 makedev(major(0),minor(0));
Matthias Kloseb159a552010-04-25 21:00:44 +00003286]])],[
Martin v. Löwisdbe3f762002-10-10 14:27:30 +00003287 AC_DEFINE(HAVE_DEVICE_MACROS, 1,
3288 [Define to 1 if you have the device macros.])
3289 AC_MSG_RESULT(yes)
3290],[
3291 AC_MSG_RESULT(no)
3292])
Martin v. Löwis861a65b2001-10-24 14:36:00 +00003293
3294# On OSF/1 V5.1, getaddrinfo is available, but a define
3295# for [no]getaddrinfo in netdb.h.
3296AC_MSG_CHECKING(for getaddrinfo)
Matthias Kloseb159a552010-04-25 21:00:44 +00003297AC_LINK_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwisc010b6d2001-11-09 17:50:52 +00003298#include <sys/types.h>
Martin v. Löwis861a65b2001-10-24 14:36:00 +00003299#include <sys/socket.h>
3300#include <netdb.h>
Martin v. Löwisc010b6d2001-11-09 17:50:52 +00003301#include <stdio.h>
Matthias Kloseb159a552010-04-25 21:00:44 +00003302]], [[getaddrinfo(NULL, NULL, NULL, NULL);]])],
3303[have_getaddrinfo=yes],
3304[have_getaddrinfo=no])
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00003305AC_MSG_RESULT($have_getaddrinfo)
3306if test $have_getaddrinfo = yes
3307then
3308 AC_MSG_CHECKING(getaddrinfo bug)
3309 AC_CACHE_VAL(ac_cv_buggy_getaddrinfo,
Matthias Kloseb159a552010-04-25 21:00:44 +00003310 AC_RUN_IFELSE([AC_LANG_SOURCE([[[
Stefan Krah19c21392012-11-22 23:47:32 +01003311#include <stdio.h>
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003312#include <sys/types.h>
3313#include <netdb.h>
3314#include <string.h>
3315#include <sys/socket.h>
3316#include <netinet/in.h>
3317
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00003318int main()
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003319{
3320 int passive, gaierr, inet4 = 0, inet6 = 0;
3321 struct addrinfo hints, *ai, *aitop;
3322 char straddr[INET6_ADDRSTRLEN], strport[16];
3323
3324 for (passive = 0; passive <= 1; passive++) {
3325 memset(&hints, 0, sizeof(hints));
3326 hints.ai_family = AF_UNSPEC;
3327 hints.ai_flags = passive ? AI_PASSIVE : 0;
3328 hints.ai_socktype = SOCK_STREAM;
Hye-Shik Chang54f94392004-04-14 07:55:31 +00003329 hints.ai_protocol = IPPROTO_TCP;
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003330 if ((gaierr = getaddrinfo(NULL, "54321", &hints, &aitop)) != 0) {
3331 (void)gai_strerror(gaierr);
3332 goto bad;
3333 }
3334 for (ai = aitop; ai; ai = ai->ai_next) {
3335 if (ai->ai_addr == NULL ||
3336 ai->ai_addrlen == 0 ||
3337 getnameinfo(ai->ai_addr, ai->ai_addrlen,
3338 straddr, sizeof(straddr), strport, sizeof(strport),
3339 NI_NUMERICHOST|NI_NUMERICSERV) != 0) {
3340 goto bad;
3341 }
3342 switch (ai->ai_family) {
3343 case AF_INET:
3344 if (strcmp(strport, "54321") != 0) {
3345 goto bad;
3346 }
3347 if (passive) {
3348 if (strcmp(straddr, "0.0.0.0") != 0) {
3349 goto bad;
3350 }
3351 } else {
3352 if (strcmp(straddr, "127.0.0.1") != 0) {
3353 goto bad;
3354 }
3355 }
3356 inet4++;
3357 break;
3358 case AF_INET6:
3359 if (strcmp(strport, "54321") != 0) {
3360 goto bad;
3361 }
3362 if (passive) {
3363 if (strcmp(straddr, "::") != 0) {
3364 goto bad;
3365 }
3366 } else {
3367 if (strcmp(straddr, "::1") != 0) {
3368 goto bad;
3369 }
3370 }
3371 inet6++;
3372 break;
3373 case AF_UNSPEC:
3374 goto bad;
3375 break;
3376 default:
3377 /* another family support? */
3378 break;
3379 }
3380 }
3381 }
3382
3383 if (!(inet4 == 0 || inet4 == 2))
3384 goto bad;
3385 if (!(inet6 == 0 || inet6 == 2))
3386 goto bad;
3387
3388 if (aitop)
3389 freeaddrinfo(aitop);
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00003390 return 0;
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003391
3392 bad:
3393 if (aitop)
3394 freeaddrinfo(aitop);
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00003395 return 1;
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003396}
Matthias Kloseb159a552010-04-25 21:00:44 +00003397]]])],
3398[ac_cv_buggy_getaddrinfo=no],
3399[ac_cv_buggy_getaddrinfo=yes],
Matthias Klose96350132012-03-15 20:42:23 +01003400[
3401if test "${enable_ipv6+set}" = set; then
3402 ac_cv_buggy_getaddrinfo="no -- configured with --(en|dis)able-ipv6"
3403else
3404 ac_cv_buggy_getaddrinfo=yes
3405fi]))
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00003406fi
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003407
Benjamin Petersond4694ed2010-11-01 01:44:30 +00003408AC_MSG_RESULT($ac_cv_buggy_getaddrinfo)
3409
doko@ubuntu.com9c7817e2012-06-30 17:05:13 +02003410if test $have_getaddrinfo = no || test "$ac_cv_buggy_getaddrinfo" = yes
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00003411then
3412 if test $ipv6 = yes
3413 then
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003414 echo 'Fatal: You must get working getaddrinfo() function.'
3415 echo ' or you can specify "--disable-ipv6"'.
3416 exit 1
3417 fi
Martin v. Löwis861a65b2001-10-24 14:36:00 +00003418else
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003419 AC_DEFINE(HAVE_GETADDRINFO, 1, [Define if you have the getaddrinfo function.])
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003420fi
Benjamin Petersond4694ed2010-11-01 01:44:30 +00003421
Thomas Woutersb0db85a2001-08-08 10:39:03 +00003422AC_CHECK_FUNCS(getnameinfo)
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003423
Guido van Rossum627b2d71993-12-24 10:39:16 +00003424# checks for structures
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003425AC_HEADER_TIME
Guido van Rossum627b2d71993-12-24 10:39:16 +00003426AC_STRUCT_TM
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003427AC_STRUCT_TIMEZONE
Martin v. Löwis60a5d722002-10-16 20:28:25 +00003428AC_CHECK_MEMBERS([struct stat.st_rdev])
3429AC_CHECK_MEMBERS([struct stat.st_blksize])
Hye-Shik Chang5f937a72005-06-02 13:09:30 +00003430AC_CHECK_MEMBERS([struct stat.st_flags])
Martin v. Löwisebd9d5b2005-08-09 15:00:59 +00003431AC_CHECK_MEMBERS([struct stat.st_gen])
3432AC_CHECK_MEMBERS([struct stat.st_birthtime])
Guido van Rossum98bf58f2001-10-18 20:34:25 +00003433AC_STRUCT_ST_BLOCKS
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003434
3435AC_MSG_CHECKING(for time.h that defines altzone)
Matthias Kloseb159a552010-04-25 21:00:44 +00003436AC_CACHE_VAL(ac_cv_header_time_altzone,[
3437 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <time.h>]], [[return altzone;]])],
3438 [ac_cv_header_time_altzone=yes],
3439 [ac_cv_header_time_altzone=no])
3440 ])
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003441AC_MSG_RESULT($ac_cv_header_time_altzone)
3442if test $ac_cv_header_time_altzone = yes; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003443 AC_DEFINE(HAVE_ALTZONE, 1, [Define this if your time.h defines altzone.])
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003444fi
3445
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003446was_it_defined=no
3447AC_MSG_CHECKING(whether sys/select.h and sys/time.h may both be included)
Matthias Kloseb159a552010-04-25 21:00:44 +00003448AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003449#include <sys/types.h>
3450#include <sys/select.h>
3451#include <sys/time.h>
Matthias Kloseb159a552010-04-25 21:00:44 +00003452]], [[;]])],[
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003453 AC_DEFINE(SYS_SELECT_WITH_SYS_TIME, 1,
3454 [Define if you can safely include both <sys/select.h> and <sys/time.h>
3455 (which you can't on SCO ODT 3.0).])
3456 was_it_defined=yes
Matthias Kloseb159a552010-04-25 21:00:44 +00003457],[])
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003458AC_MSG_RESULT($was_it_defined)
Guido van Rossum627b2d71993-12-24 10:39:16 +00003459
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003460AC_MSG_CHECKING(for addrinfo)
3461AC_CACHE_VAL(ac_cv_struct_addrinfo,
Matthias Kloseb159a552010-04-25 21:00:44 +00003462AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <netdb.h>]], [[struct addrinfo a]])],
3463 [ac_cv_struct_addrinfo=yes],
3464 [ac_cv_struct_addrinfo=no]))
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003465AC_MSG_RESULT($ac_cv_struct_addrinfo)
3466if test $ac_cv_struct_addrinfo = yes; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003467 AC_DEFINE(HAVE_ADDRINFO, 1, [struct addrinfo (netdb.h)])
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003468fi
3469
3470AC_MSG_CHECKING(for sockaddr_storage)
3471AC_CACHE_VAL(ac_cv_struct_sockaddr_storage,
Matthias Kloseb159a552010-04-25 21:00:44 +00003472AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003473# include <sys/types.h>
Matthias Kloseb159a552010-04-25 21:00:44 +00003474# include <sys/socket.h>]], [[struct sockaddr_storage s]])],
3475 [ac_cv_struct_sockaddr_storage=yes],
3476 [ac_cv_struct_sockaddr_storage=no]))
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003477AC_MSG_RESULT($ac_cv_struct_sockaddr_storage)
3478if test $ac_cv_struct_sockaddr_storage = yes; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003479 AC_DEFINE(HAVE_SOCKADDR_STORAGE, 1, [struct sockaddr_storage (sys/socket.h)])
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003480fi
3481
Guido van Rossum627b2d71993-12-24 10:39:16 +00003482# checks for compiler characteristics
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003483
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003484AC_C_CHAR_UNSIGNED
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003485AC_C_CONST
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003486
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003487works=no
3488AC_MSG_CHECKING(for working volatile)
Matthias Kloseb159a552010-04-25 21:00:44 +00003489AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[volatile int x; x = 0;]])],
3490 [works=yes],
3491 [AC_DEFINE(volatile, , [Define to empty if the keyword does not work.])]
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003492)
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003493AC_MSG_RESULT($works)
Guido van Rossumdabb11b1994-10-11 15:04:27 +00003494
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003495works=no
3496AC_MSG_CHECKING(for working signed char)
Matthias Kloseb159a552010-04-25 21:00:44 +00003497AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[signed char c;]])],
3498 [works=yes],
3499 [AC_DEFINE(signed, , [Define to empty if the keyword does not work.])]
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003500)
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003501AC_MSG_RESULT($works)
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003502
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003503have_prototypes=no
3504AC_MSG_CHECKING(for prototypes)
Matthias Kloseb159a552010-04-25 21:00:44 +00003505AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[int foo(int x) { return 0; }]], [[return foo(10);]])],
3506 [AC_DEFINE(HAVE_PROTOTYPES, 1,
3507 [Define if your compiler supports function prototype])
3508 have_prototypes=yes],
3509 []
3510)
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003511AC_MSG_RESULT($have_prototypes)
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003512
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003513works=no
3514AC_MSG_CHECKING(for variable length prototypes and stdarg.h)
Matthias Kloseb159a552010-04-25 21:00:44 +00003515AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003516#include <stdarg.h>
Guido van Rossum3f13e481996-08-30 20:58:11 +00003517int foo(int x, ...) {
3518 va_list va;
3519 va_start(va, x);
3520 va_arg(va, int);
3521 va_arg(va, char *);
3522 va_arg(va, double);
3523 return 0;
3524}
Matthias Kloseb159a552010-04-25 21:00:44 +00003525]], [[return foo(10, "", 3.14);]])],[
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003526 AC_DEFINE(HAVE_STDARG_PROTOTYPES, 1,
3527 [Define if your compiler supports variable length function prototypes
3528 (e.g. void fprintf(FILE *, char *, ...);) *and* <stdarg.h>])
3529 works=yes
Matthias Kloseb159a552010-04-25 21:00:44 +00003530],[])
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003531AC_MSG_RESULT($works)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003532
Dave Cole331708b2004-08-09 04:51:41 +00003533# check for socketpair
3534AC_MSG_CHECKING(for socketpair)
Matthias Kloseb159a552010-04-25 21:00:44 +00003535AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Dave Cole331708b2004-08-09 04:51:41 +00003536#include <sys/types.h>
3537#include <sys/socket.h>
Matthias Kloseb159a552010-04-25 21:00:44 +00003538]], [[void *x=socketpair]])],
3539 [AC_DEFINE(HAVE_SOCKETPAIR, 1, [Define if you have the 'socketpair' function.])
3540 AC_MSG_RESULT(yes)],
3541 [AC_MSG_RESULT(no)]
Dave Cole331708b2004-08-09 04:51:41 +00003542)
3543
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003544# check if sockaddr has sa_len member
3545AC_MSG_CHECKING(if sockaddr has sa_len member)
Matthias Kloseb159a552010-04-25 21:00:44 +00003546AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
3547#include <sys/socket.h>]], [[struct sockaddr x;
3548x.sa_len = 0;]])],
3549 [AC_MSG_RESULT(yes)
3550 AC_DEFINE(HAVE_SOCKADDR_SA_LEN, 1, [Define if sockaddr has sa_len member])],
3551 [AC_MSG_RESULT(no)]
3552)
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003553
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003554va_list_is_array=no
3555AC_MSG_CHECKING(whether va_list is an array)
Matthias Kloseb159a552010-04-25 21:00:44 +00003556AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003557#ifdef HAVE_STDARG_PROTOTYPES
3558#include <stdarg.h>
3559#else
3560#include <varargs.h>
3561#endif
Matthias Kloseb159a552010-04-25 21:00:44 +00003562]], [[va_list list1, list2; list1 = list2;]])],[],[
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003563 AC_DEFINE(VA_LIST_IS_ARRAY, 1, [Define if a va_list is an array of some kind])
3564 va_list_is_array=yes
3565])
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003566AC_MSG_RESULT($va_list_is_array)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003567
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003568# sigh -- gethostbyname_r is a mess; it can have 3, 5 or 6 arguments :-(
Martin v. Löwis11437992002-04-12 09:54:03 +00003569AH_TEMPLATE(HAVE_GETHOSTBYNAME_R,
3570 [Define this if you have some version of gethostbyname_r()])
3571
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003572AC_CHECK_FUNC(gethostbyname_r, [
3573 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
3574 AC_MSG_CHECKING([gethostbyname_r with 6 args])
3575 OLD_CFLAGS=$CFLAGS
3576 CFLAGS="$CFLAGS $MY_CPPFLAGS $MY_THREAD_CPPFLAGS $MY_CFLAGS"
Matthias Kloseb159a552010-04-25 21:00:44 +00003577 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003578# include <netdb.h>
Matthias Kloseb159a552010-04-25 21:00:44 +00003579 ]], [[
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003580 char *name;
3581 struct hostent *he, *res;
3582 char buffer[2048];
3583 int buflen = 2048;
3584 int h_errnop;
3585
3586 (void) gethostbyname_r(name, he, buffer, buflen, &res, &h_errnop)
Matthias Kloseb159a552010-04-25 21:00:44 +00003587 ]])],[
Guido van Rossum8db7d8b1999-03-23 16:40:33 +00003588 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003589 AC_DEFINE(HAVE_GETHOSTBYNAME_R_6_ARG, 1,
3590 [Define this if you have the 6-arg version of gethostbyname_r().])
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003591 AC_MSG_RESULT(yes)
Matthias Kloseb159a552010-04-25 21:00:44 +00003592 ],[
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003593 AC_MSG_RESULT(no)
3594 AC_MSG_CHECKING([gethostbyname_r with 5 args])
Matthias Kloseb159a552010-04-25 21:00:44 +00003595 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003596# include <netdb.h>
Matthias Kloseb159a552010-04-25 21:00:44 +00003597 ]], [[
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003598 char *name;
3599 struct hostent *he;
Matthias Kloseb159a552010-04-25 21:00:44 +00003600 char buffer[2048];
3601 int buflen = 2048;
3602 int h_errnop;
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003603
Matthias Kloseb159a552010-04-25 21:00:44 +00003604 (void) gethostbyname_r(name, he, buffer, buflen, &h_errnop)
3605 ]])],
3606 [
Guido van Rossum8db7d8b1999-03-23 16:40:33 +00003607 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
Matthias Kloseb159a552010-04-25 21:00:44 +00003608 AC_DEFINE(HAVE_GETHOSTBYNAME_R_5_ARG, 1,
3609 [Define this if you have the 5-arg version of gethostbyname_r().])
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003610 AC_MSG_RESULT(yes)
3611 ], [
3612 AC_MSG_RESULT(no)
Matthias Kloseb159a552010-04-25 21:00:44 +00003613 AC_MSG_CHECKING([gethostbyname_r with 3 args])
3614 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3615# include <netdb.h>
3616 ]], [[
3617 char *name;
3618 struct hostent *he;
3619 struct hostent_data data;
3620
3621 (void) gethostbyname_r(name, he, &data);
3622 ]])],
3623 [
3624 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
3625 AC_DEFINE(HAVE_GETHOSTBYNAME_R_3_ARG, 1,
3626 [Define this if you have the 3-arg version of gethostbyname_r().])
3627 AC_MSG_RESULT(yes)
3628 ], [
3629 AC_MSG_RESULT(no)
3630 ])
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003631 ])
3632 ])
3633 CFLAGS=$OLD_CFLAGS
3634], [
Thomas Wouters3a584202000-08-05 23:28:51 +00003635 AC_CHECK_FUNCS(gethostbyname)
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003636])
3637AC_SUBST(HAVE_GETHOSTBYNAME_R_6_ARG)
3638AC_SUBST(HAVE_GETHOSTBYNAME_R_5_ARG)
3639AC_SUBST(HAVE_GETHOSTBYNAME_R_3_ARG)
Guido van Rossum8db7d8b1999-03-23 16:40:33 +00003640AC_SUBST(HAVE_GETHOSTBYNAME_R)
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003641AC_SUBST(HAVE_GETHOSTBYNAME)
3642
Guido van Rossum627b2d71993-12-24 10:39:16 +00003643# checks for system services
3644# (none yet)
3645
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003646# Linux requires this for correct f.p. operations
Jeremy Hyltonbe28f5b2000-07-27 21:03:04 +00003647AC_CHECK_FUNC(__fpu_control,
3648 [],
3649 [AC_CHECK_LIB(ieee, __fpu_control)
3650])
Guido van Rossum627b2d71993-12-24 10:39:16 +00003651
Guido van Rossum93274221997-05-09 02:42:00 +00003652# Check for --with-fpectl
Guido van Rossum93274221997-05-09 02:42:00 +00003653AC_MSG_CHECKING(for --with-fpectl)
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00003654AC_ARG_WITH(fpectl,
Matthias Klose2b8733f2010-04-25 18:34:36 +00003655 AS_HELP_STRING([--with-fpectl], [enable SIGFPE catching]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003656[
Guido van Rossum93274221997-05-09 02:42:00 +00003657if test "$withval" != no
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003658then
3659 AC_DEFINE(WANT_SIGFPE_HANDLER, 1,
3660 [Define if you want SIGFPE handled (see Include/pyfpe.h).])
3661 AC_MSG_RESULT(yes)
Guido van Rossum93274221997-05-09 02:42:00 +00003662else AC_MSG_RESULT(no)
Guido van Rossumef2255b2000-03-10 22:30:29 +00003663fi],
3664[AC_MSG_RESULT(no)])
Guido van Rossum93274221997-05-09 02:42:00 +00003665
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003666# check for --with-libm=...
3667AC_SUBST(LIBM)
Guido van Rossum4b6b5791996-09-09 20:09:34 +00003668case $ac_sys_system in
Guido van Rossum3dc0a512000-10-05 18:00:06 +00003669Darwin) ;;
Guido van Rossum4b6b5791996-09-09 20:09:34 +00003670*) LIBM=-lm
3671esac
Guido van Rossum93274221997-05-09 02:42:00 +00003672AC_MSG_CHECKING(for --with-libm=STRING)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003673AC_ARG_WITH(libm,
Matthias Klose2b8733f2010-04-25 18:34:36 +00003674 AS_HELP_STRING([--with-libm=STRING], [math library]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003675[
Guido van Rossum93274221997-05-09 02:42:00 +00003676if test "$withval" = no
3677then LIBM=
3678 AC_MSG_RESULT(force LIBM empty)
3679elif test "$withval" != yes
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003680then LIBM=$withval
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003681 AC_MSG_RESULT(set LIBM="$withval")
3682else AC_MSG_ERROR([proper usage is --with-libm=STRING])
Guido van Rossum93274221997-05-09 02:42:00 +00003683fi],
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003684[AC_MSG_RESULT(default LIBM="$LIBM")])
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003685
3686# check for --with-libc=...
3687AC_SUBST(LIBC)
Guido van Rossum93274221997-05-09 02:42:00 +00003688AC_MSG_CHECKING(for --with-libc=STRING)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003689AC_ARG_WITH(libc,
Matthias Klose2b8733f2010-04-25 18:34:36 +00003690 AS_HELP_STRING([--with-libc=STRING], [C library]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003691[
Guido van Rossum93274221997-05-09 02:42:00 +00003692if test "$withval" = no
3693then LIBC=
3694 AC_MSG_RESULT(force LIBC empty)
3695elif test "$withval" != yes
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003696then LIBC=$withval
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003697 AC_MSG_RESULT(set LIBC="$withval")
3698else AC_MSG_ERROR([proper usage is --with-libc=STRING])
Guido van Rossum93274221997-05-09 02:42:00 +00003699fi],
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003700[AC_MSG_RESULT(default LIBC="$LIBC")])
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003701
Stefan Krah1919b7e2012-03-21 18:25:23 +01003702# **************************************
3703# * Check for gcc x64 inline assembler *
3704# **************************************
3705
3706AC_MSG_CHECKING(for x64 gcc inline assembler)
3707AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3708 __asm__ __volatile__ ("movq %rcx, %rax");
3709]])],[have_gcc_asm_for_x64=yes],[have_gcc_asm_for_x64=no])
3710AC_MSG_RESULT($have_gcc_asm_for_x64)
3711if test "$have_gcc_asm_for_x64" = yes
3712then
3713 AC_DEFINE(HAVE_GCC_ASM_FOR_X64, 1,
3714 [Define if we can use x64 gcc inline assembler])
3715fi
3716
Mark Dickinsonb08a53a2009-04-16 19:52:09 +00003717# **************************************************
3718# * Check for various properties of floating point *
3719# **************************************************
Christian Heimes81ee3ef2008-05-04 22:42:01 +00003720
Mark Dickinsonb08a53a2009-04-16 19:52:09 +00003721AC_MSG_CHECKING(whether C doubles are little-endian IEEE 754 binary64)
3722AC_CACHE_VAL(ac_cv_little_endian_double, [
Matthias Kloseb159a552010-04-25 21:00:44 +00003723AC_RUN_IFELSE([AC_LANG_SOURCE([[
Mark Dickinsonb08a53a2009-04-16 19:52:09 +00003724#include <string.h>
3725int main() {
3726 double x = 9006104071832581.0;
3727 if (memcmp(&x, "\x05\x04\x03\x02\x01\xff\x3f\x43", 8) == 0)
3728 return 0;
3729 else
3730 return 1;
3731}
Matthias Kloseb159a552010-04-25 21:00:44 +00003732]])],
3733[ac_cv_little_endian_double=yes],
3734[ac_cv_little_endian_double=no],
3735[ac_cv_little_endian_double=no])])
Mark Dickinsonb08a53a2009-04-16 19:52:09 +00003736AC_MSG_RESULT($ac_cv_little_endian_double)
3737if test "$ac_cv_little_endian_double" = yes
3738then
3739 AC_DEFINE(DOUBLE_IS_LITTLE_ENDIAN_IEEE754, 1,
3740 [Define if C doubles are 64-bit IEEE 754 binary format, stored
3741 with the least significant byte first])
3742fi
3743
3744AC_MSG_CHECKING(whether C doubles are big-endian IEEE 754 binary64)
3745AC_CACHE_VAL(ac_cv_big_endian_double, [
Matthias Kloseb159a552010-04-25 21:00:44 +00003746AC_RUN_IFELSE([AC_LANG_SOURCE([[
Mark Dickinsonb08a53a2009-04-16 19:52:09 +00003747#include <string.h>
3748int main() {
3749 double x = 9006104071832581.0;
3750 if (memcmp(&x, "\x43\x3f\xff\x01\x02\x03\x04\x05", 8) == 0)
3751 return 0;
3752 else
3753 return 1;
3754}
Matthias Kloseb159a552010-04-25 21:00:44 +00003755]])],
3756[ac_cv_big_endian_double=yes],
3757[ac_cv_big_endian_double=no],
3758[ac_cv_big_endian_double=no])])
Mark Dickinsonb08a53a2009-04-16 19:52:09 +00003759AC_MSG_RESULT($ac_cv_big_endian_double)
3760if test "$ac_cv_big_endian_double" = yes
3761then
3762 AC_DEFINE(DOUBLE_IS_BIG_ENDIAN_IEEE754, 1,
3763 [Define if C doubles are 64-bit IEEE 754 binary format, stored
3764 with the most significant byte first])
3765fi
3766
3767# Some ARM platforms use a mixed-endian representation for doubles.
3768# While Python doesn't currently have full support for these platforms
3769# (see e.g., issue 1762561), we can at least make sure that float <-> string
3770# conversions work.
3771AC_MSG_CHECKING(whether C doubles are ARM mixed-endian IEEE 754 binary64)
3772AC_CACHE_VAL(ac_cv_mixed_endian_double, [
Matthias Kloseb159a552010-04-25 21:00:44 +00003773AC_RUN_IFELSE([AC_LANG_SOURCE([[
Mark Dickinsonb08a53a2009-04-16 19:52:09 +00003774#include <string.h>
3775int main() {
3776 double x = 9006104071832581.0;
3777 if (memcmp(&x, "\x01\xff\x3f\x43\x05\x04\x03\x02", 8) == 0)
3778 return 0;
3779 else
3780 return 1;
3781}
Matthias Kloseb159a552010-04-25 21:00:44 +00003782]])],
3783[ac_cv_mixed_endian_double=yes],
3784[ac_cv_mixed_endian_double=no],
3785[ac_cv_mixed_endian_double=no])])
Mark Dickinsonb08a53a2009-04-16 19:52:09 +00003786AC_MSG_RESULT($ac_cv_mixed_endian_double)
3787if test "$ac_cv_mixed_endian_double" = yes
3788then
3789 AC_DEFINE(DOUBLE_IS_ARM_MIXED_ENDIAN_IEEE754, 1,
3790 [Define if C doubles are 64-bit IEEE 754 binary format, stored
3791 in ARM mixed-endian order (byte order 45670123)])
3792fi
3793
Mark Dickinson7abf8d42009-04-18 20:17:52 +00003794# The short float repr introduced in Python 3.1 requires the
3795# correctly-rounded string <-> double conversion functions from
3796# Python/dtoa.c, which in turn require that the FPU uses 53-bit
3797# rounding; this is a problem on x86, where the x87 FPU has a default
Mark Dickinsonf4243f62009-11-15 13:47:27 +00003798# rounding precision of 64 bits. For gcc/x86, we can fix this by
Mark Dickinson7abf8d42009-04-18 20:17:52 +00003799# using inline assembler to get and set the x87 FPU control word.
Mark Dickinsonf4243f62009-11-15 13:47:27 +00003800
3801# This inline assembler syntax may also work for suncc and icc,
3802# so we try it on all platforms.
3803
3804AC_MSG_CHECKING(whether we can use gcc inline assembler to get and set x87 control word)
Matthias Kloseb159a552010-04-25 21:00:44 +00003805AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
Mark Dickinsonf4243f62009-11-15 13:47:27 +00003806 unsigned short cw;
3807 __asm__ __volatile__ ("fnstcw %0" : "=m" (cw));
3808 __asm__ __volatile__ ("fldcw %0" : : "m" (cw));
Matthias Kloseb159a552010-04-25 21:00:44 +00003809]])],[have_gcc_asm_for_x87=yes],[have_gcc_asm_for_x87=no])
Mark Dickinsonf4243f62009-11-15 13:47:27 +00003810AC_MSG_RESULT($have_gcc_asm_for_x87)
3811if test "$have_gcc_asm_for_x87" = yes
Mark Dickinsonb08a53a2009-04-16 19:52:09 +00003812then
Mark Dickinsonf4243f62009-11-15 13:47:27 +00003813 AC_DEFINE(HAVE_GCC_ASM_FOR_X87, 1,
3814 [Define if we can use gcc inline assembler to get and set x87 control word])
Mark Dickinsonb08a53a2009-04-16 19:52:09 +00003815fi
Christian Heimes81ee3ef2008-05-04 22:42:01 +00003816
Mark Dickinson3dc7c6a2009-01-04 15:09:02 +00003817# Detect whether system arithmetic is subject to x87-style double
3818# rounding issues. The result of this test has little meaning on non
3819# IEEE 754 platforms. On IEEE 754, test should return 1 if rounding
3820# mode is round-to-nearest and double rounding issues are present, and
3821# 0 otherwise. See http://bugs.python.org/issue2937 for more info.
3822AC_MSG_CHECKING(for x87-style double rounding)
Mark Dickinsonb08a53a2009-04-16 19:52:09 +00003823# $BASECFLAGS may affect the result
3824ac_save_cc="$CC"
3825CC="$CC $BASECFLAGS"
Matthias Kloseb159a552010-04-25 21:00:44 +00003826AC_RUN_IFELSE([AC_LANG_SOURCE([[
Mark Dickinson3dc7c6a2009-01-04 15:09:02 +00003827#include <stdlib.h>
3828#include <math.h>
3829int main() {
3830 volatile double x, y, z;
3831 /* 1./(1-2**-53) -> 1+2**-52 (correct), 1.0 (double rounding) */
3832 x = 0.99999999999999989; /* 1-2**-53 */
3833 y = 1./x;
3834 if (y != 1.)
3835 exit(0);
3836 /* 1e16+2.99999 -> 1e16+2. (correct), 1e16+4. (double rounding) */
3837 x = 1e16;
3838 y = 2.99999;
3839 z = x + y;
3840 if (z != 1e16+4.)
3841 exit(0);
3842 /* both tests show evidence of double rounding */
3843 exit(1);
3844}
Matthias Kloseb159a552010-04-25 21:00:44 +00003845]])],
3846[ac_cv_x87_double_rounding=no],
3847[ac_cv_x87_double_rounding=yes],
3848[ac_cv_x87_double_rounding=no])
Mark Dickinsonb08a53a2009-04-16 19:52:09 +00003849CC="$ac_save_cc"
Mark Dickinson3dc7c6a2009-01-04 15:09:02 +00003850AC_MSG_RESULT($ac_cv_x87_double_rounding)
3851if test "$ac_cv_x87_double_rounding" = yes
3852then
3853 AC_DEFINE(X87_DOUBLE_ROUNDING, 1,
3854 [Define if arithmetic is subject to x87-style double rounding issue])
3855fi
3856
Mark Dickinsonb08a53a2009-04-16 19:52:09 +00003857# ************************************
3858# * Check for mathematical functions *
3859# ************************************
3860
3861LIBS_SAVE=$LIBS
3862LIBS="$LIBS $LIBM"
3863
Mark Dickinson7edecdd2010-11-20 10:09:56 +00003864AC_CHECK_FUNCS([acosh asinh atanh copysign erf erfc expm1 finite gamma])
Victor Stinner8f9f8d62011-05-09 12:45:41 +02003865AC_CHECK_FUNCS([hypot lgamma log1p log2 round tgamma])
Mark Dickinson7edecdd2010-11-20 10:09:56 +00003866AC_CHECK_DECLS([isinf, isnan, isfinite], [], [], [[#include <math.h>]])
3867
Christian Heimes81ee3ef2008-05-04 22:42:01 +00003868# On FreeBSD 6.2, it appears that tanh(-0.) returns 0. instead of
3869# -0. on some architectures.
3870AC_MSG_CHECKING(whether tanh preserves the sign of zero)
3871AC_CACHE_VAL(ac_cv_tanh_preserves_zero_sign, [
Matthias Kloseb159a552010-04-25 21:00:44 +00003872AC_RUN_IFELSE([AC_LANG_SOURCE([[
Christian Heimes81ee3ef2008-05-04 22:42:01 +00003873#include <math.h>
3874#include <stdlib.h>
3875int main() {
3876 /* return 0 if either negative zeros don't exist
3877 on this platform or if negative zeros exist
3878 and tanh(-0.) == -0. */
3879 if (atan2(0., -1.) == atan2(-0., -1.) ||
3880 atan2(tanh(-0.), -1.) == atan2(-0., -1.)) exit(0);
3881 else exit(1);
3882}
Matthias Kloseb159a552010-04-25 21:00:44 +00003883]])],
3884[ac_cv_tanh_preserves_zero_sign=yes],
3885[ac_cv_tanh_preserves_zero_sign=no],
3886[ac_cv_tanh_preserves_zero_sign=no])])
Christian Heimes81ee3ef2008-05-04 22:42:01 +00003887AC_MSG_RESULT($ac_cv_tanh_preserves_zero_sign)
3888if test "$ac_cv_tanh_preserves_zero_sign" = yes
3889then
3890 AC_DEFINE(TANH_PRESERVES_ZERO_SIGN, 1,
3891 [Define if tanh(-0.) is -0., or if platform doesn't have signed zeros])
3892fi
3893
Mark Dickinson7edecdd2010-11-20 10:09:56 +00003894if test "$ac_cv_func_log1p" = yes
3895then
3896 # On some versions of AIX, log1p(-0.) returns 0. instead of
3897 # -0. See issue #9920.
3898 AC_MSG_CHECKING(whether log1p drops the sign of negative zero)
3899 AC_CACHE_VAL(ac_cv_log1p_drops_zero_sign, [
3900 AC_RUN_IFELSE([AC_LANG_SOURCE([[
3901 #include <math.h>
3902 #include <stdlib.h>
3903 int main() {
3904 /* Fail if the signs of log1p(-0.) and -0. can be
3905 distinguished. */
3906 if (atan2(log1p(-0.), -1.) == atan2(-0., -1.))
3907 return 0;
3908 else
3909 return 1;
3910 }
3911 ]])],
3912 [ac_cv_log1p_drops_zero_sign=no],
3913 [ac_cv_log1p_drops_zero_sign=yes],
3914 [ac_cv_log1p_drops_zero_sign=no])])
3915 AC_MSG_RESULT($ac_cv_log1p_drops_zero_sign)
3916fi
3917if test "$ac_cv_log1p_drops_zero_sign" = yes
3918then
3919 AC_DEFINE(LOG1P_DROPS_ZERO_SIGN, 1,
3920 [Define if log1p(-0.) is 0. rather than -0.])
3921fi
Christian Heimes99170a52007-12-19 02:07:34 +00003922
Guido van Rossumaf5b83e1995-01-04 19:02:35 +00003923LIBS=$LIBS_SAVE
3924
Mark Dickinsona614f042009-11-28 12:48:43 +00003925# For multiprocessing module, check that sem_open
3926# actually works. For FreeBSD versions <= 7.2,
3927# the kernel module that provides POSIX semaphores
3928# isn't loaded by default, so an attempt to call
3929# sem_open results in a 'Signal 12' error.
3930AC_MSG_CHECKING(whether POSIX semaphores are enabled)
3931AC_CACHE_VAL(ac_cv_posix_semaphores_enabled,
Matthias Kloseb159a552010-04-25 21:00:44 +00003932AC_RUN_IFELSE([AC_LANG_SOURCE([[
Mark Dickinsona614f042009-11-28 12:48:43 +00003933#include <unistd.h>
3934#include <fcntl.h>
3935#include <stdio.h>
3936#include <semaphore.h>
3937#include <sys/stat.h>
3938
3939int main(void) {
3940 sem_t *a = sem_open("/autoconf", O_CREAT, S_IRUSR|S_IWUSR, 0);
3941 if (a == SEM_FAILED) {
3942 perror("sem_open");
3943 return 1;
3944 }
3945 sem_close(a);
Mark Dickinsonba79b352009-12-13 21:10:57 +00003946 sem_unlink("/autoconf");
Mark Dickinsona614f042009-11-28 12:48:43 +00003947 return 0;
3948}
Matthias Kloseb159a552010-04-25 21:00:44 +00003949]])],
3950[ac_cv_posix_semaphores_enabled=yes],
3951[ac_cv_posix_semaphores_enabled=no],
3952[ac_cv_posix_semaphores_enabled=yes])
Mark Dickinsona614f042009-11-28 12:48:43 +00003953)
3954AC_MSG_RESULT($ac_cv_posix_semaphores_enabled)
3955if test $ac_cv_posix_semaphores_enabled = no
3956then
3957 AC_DEFINE(POSIX_SEMAPHORES_NOT_ENABLED, 1,
3958 [Define if POSIX semaphores aren't enabled on your system])
3959fi
3960
Mark Dickinson10683072009-04-18 21:18:19 +00003961# Multiprocessing check for broken sem_getvalue
3962AC_MSG_CHECKING(for broken sem_getvalue)
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00003963AC_CACHE_VAL(ac_cv_broken_sem_getvalue,
Matthias Kloseb159a552010-04-25 21:00:44 +00003964AC_RUN_IFELSE([AC_LANG_SOURCE([[
Mark Dickinson10683072009-04-18 21:18:19 +00003965#include <unistd.h>
3966#include <fcntl.h>
3967#include <stdio.h>
3968#include <semaphore.h>
3969#include <sys/stat.h>
3970
3971int main(void){
Mark Dickinsonba79b352009-12-13 21:10:57 +00003972 sem_t *a = sem_open("/autocftw", O_CREAT, S_IRUSR|S_IWUSR, 0);
Mark Dickinson10683072009-04-18 21:18:19 +00003973 int count;
3974 int res;
3975 if(a==SEM_FAILED){
3976 perror("sem_open");
3977 return 1;
3978
3979 }
3980 res = sem_getvalue(a, &count);
3981 sem_close(a);
Mark Dickinsonba79b352009-12-13 21:10:57 +00003982 sem_unlink("/autocftw");
Mark Dickinson10683072009-04-18 21:18:19 +00003983 return res==-1 ? 1 : 0;
3984}
Matthias Kloseb159a552010-04-25 21:00:44 +00003985]])],
3986[ac_cv_broken_sem_getvalue=no],
3987[ac_cv_broken_sem_getvalue=yes],
3988[ac_cv_broken_sem_getvalue=yes])
Mark Dickinson10683072009-04-18 21:18:19 +00003989)
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00003990AC_MSG_RESULT($ac_cv_broken_sem_getvalue)
3991if test $ac_cv_broken_sem_getvalue = yes
3992then
3993 AC_DEFINE(HAVE_BROKEN_SEM_GETVALUE, 1,
3994 [define to 1 if your sem_getvalue is broken.])
3995fi
Mark Dickinson10683072009-04-18 21:18:19 +00003996
Mark Dickinsonbd792642009-03-18 20:06:12 +00003997# determine what size digit to use for Python's longs
3998AC_MSG_CHECKING([digit size for Python's longs])
3999AC_ARG_ENABLE(big-digits,
Matthias Klose2b8733f2010-04-25 18:34:36 +00004000AS_HELP_STRING([--enable-big-digits@<:@=BITS@:>@],[use big digits for Python longs [[BITS=30]]]),
Mark Dickinsonbd792642009-03-18 20:06:12 +00004001[case $enable_big_digits in
4002yes)
4003 enable_big_digits=30 ;;
4004no)
4005 enable_big_digits=15 ;;
4006[15|30])
4007 ;;
4008*)
4009 AC_MSG_ERROR([bad value $enable_big_digits for --enable-big-digits; value should be 15 or 30]) ;;
4010esac
4011AC_MSG_RESULT($enable_big_digits)
4012AC_DEFINE_UNQUOTED(PYLONG_BITS_IN_DIGIT, $enable_big_digits, [Define as the preferred size in bits of long digits])
4013],
4014[AC_MSG_RESULT(no value specified)])
4015
Guido van Rossumef2255b2000-03-10 22:30:29 +00004016# check for wchar.h
Martin v. Löwisc45929e2002-04-06 10:10:49 +00004017AC_CHECK_HEADER(wchar.h, [
4018 AC_DEFINE(HAVE_WCHAR_H, 1,
4019 [Define if the compiler provides a wchar.h header file.])
4020 wchar_h="yes"
4021],
Guido van Rossumef2255b2000-03-10 22:30:29 +00004022wchar_h="no"
4023)
4024
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00004025# determine wchar_t size
4026if test "$wchar_h" = yes
4027then
Guido van Rossum67b26592001-10-20 14:21:45 +00004028 AC_CHECK_SIZEOF(wchar_t, 4, [#include <wchar.h>])
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00004029fi
4030
Martin v. Löwisfa3bdea2003-09-04 18:50:54 +00004031AC_MSG_CHECKING(for UCS-4 tcl)
4032have_ucs4_tcl=no
Matthias Kloseb159a552010-04-25 21:00:44 +00004033AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwisfa3bdea2003-09-04 18:50:54 +00004034#include <tcl.h>
4035#if TCL_UTF_MAX != 6
4036# error "NOT UCS4_TCL"
Matthias Kloseb159a552010-04-25 21:00:44 +00004037#endif]], [[]])],[
Martin v. Löwisfa3bdea2003-09-04 18:50:54 +00004038 AC_DEFINE(HAVE_UCS4_TCL, 1, [Define this if you have tcl and TCL_UTF_MAX==6])
4039 have_ucs4_tcl=yes
Matthias Kloseb159a552010-04-25 21:00:44 +00004040],[])
Martin v. Löwisfa3bdea2003-09-04 18:50:54 +00004041AC_MSG_RESULT($have_ucs4_tcl)
4042
Marc-André Lemburgd7160f82003-09-22 11:14:40 +00004043# check whether wchar_t is signed or not
4044if test "$wchar_h" = yes
4045then
4046 # check whether wchar_t is signed or not
4047 AC_MSG_CHECKING(whether wchar_t is signed)
4048 AC_CACHE_VAL(ac_cv_wchar_t_signed, [
Matthias Kloseb159a552010-04-25 21:00:44 +00004049 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Marc-André Lemburgd7160f82003-09-22 11:14:40 +00004050 #include <wchar.h>
4051 int main()
4052 {
Thomas Wouters49fd7fa2006-04-21 10:40:58 +00004053 /* Success: exit code 0 */
4054 exit((((wchar_t) -1) < ((wchar_t) 0)) ? 0 : 1);
Marc-André Lemburgd7160f82003-09-22 11:14:40 +00004055 }
Matthias Kloseb159a552010-04-25 21:00:44 +00004056 ]])],
4057 [ac_cv_wchar_t_signed=yes],
4058 [ac_cv_wchar_t_signed=no],
4059 [ac_cv_wchar_t_signed=yes])])
Marc-André Lemburgd7160f82003-09-22 11:14:40 +00004060 AC_MSG_RESULT($ac_cv_wchar_t_signed)
4061fi
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00004062
Georg Brandl52d168a2008-01-07 18:10:24 +00004063# wchar_t is only usable if it maps to an unsigned type
Martin v. Löwisd63a3b82011-09-28 07:41:54 +02004064if test "$ac_cv_sizeof_wchar_t" -ge 2 \
Matthias Klose7dbeed72004-12-24 08:22:17 +00004065 -a "$ac_cv_wchar_t_signed" = "no"
Georg Brandl52d168a2008-01-07 18:10:24 +00004066then
Martin v. Löwisd63a3b82011-09-28 07:41:54 +02004067 HAVE_USABLE_WCHAR_T="yes"
Georg Brandl52d168a2008-01-07 18:10:24 +00004068 AC_DEFINE(HAVE_USABLE_WCHAR_T, 1,
4069 [Define if you have a useable wchar_t type defined in wchar.h; useable
4070 means wchar_t must be an unsigned type with at least 16 bits. (see
4071 Include/unicodeobject.h).])
Georg Brandl52d168a2008-01-07 18:10:24 +00004072else
Martin v. Löwisd63a3b82011-09-28 07:41:54 +02004073 HAVE_USABLE_WCHAR_T="no usable wchar_t found"
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00004074fi
Martin v. Löwisd63a3b82011-09-28 07:41:54 +02004075AC_MSG_RESULT($HAVE_USABLE_WCHAR_T)
Guido van Rossumef2255b2000-03-10 22:30:29 +00004076
4077# check for endianness
4078AC_C_BIGENDIAN
4079
Barry Warsaw35f3a2c2010-09-03 18:30:30 +00004080# ABI version string for Python extension modules. This appears between the
4081# periods in shared library file names, e.g. foo.<SOABI>.so. It is calculated
4082# from the following attributes which affect the ABI of this Python build (in
4083# this order):
4084#
4085# * The Python implementation (always 'cpython-' for us)
4086# * The major and minor version numbers
4087# * --with-pydebug (adds a 'd')
4088# * --with-pymalloc (adds a 'm')
4089# * --with-wide-unicode (adds a 'u')
4090#
4091# Thus for example, Python 3.2 built with wide unicode, pydebug, and pymalloc,
Georg Brandlde7d8342010-09-03 22:19:07 +00004092# would get a shared library ABI version tag of 'cpython-32dmu' and shared
4093# libraries would be named 'foo.cpython-32dmu.so'.
Barry Warsaw35f3a2c2010-09-03 18:30:30 +00004094AC_SUBST(SOABI)
Barry Warsaw8cf4eae2010-10-16 01:04:07 +00004095AC_MSG_CHECKING(ABIFLAGS)
4096AC_MSG_RESULT($ABIFLAGS)
Barry Warsaw35f3a2c2010-09-03 18:30:30 +00004097AC_MSG_CHECKING(SOABI)
Barry Warsaw8cf4eae2010-10-16 01:04:07 +00004098SOABI='cpython-'`echo $VERSION | tr -d .`${ABIFLAGS}
Barry Warsaw35f3a2c2010-09-03 18:30:30 +00004099AC_MSG_RESULT($SOABI)
4100
doko@ubuntu.comd5537d02013-03-21 13:21:49 -07004101AC_SUBST(EXT_SUFFIX)
4102case $ac_sys_system in
4103 Linux*|GNU*)
4104 EXT_SUFFIX=.${SOABI}${SHLIB_SUFFIX};;
4105 *)
4106 EXT_SUFFIX=${SHLIB_SUFFIX};;
4107esac
4108
Barry Warsaw8cf4eae2010-10-16 01:04:07 +00004109AC_MSG_CHECKING(LDVERSION)
4110LDVERSION='$(VERSION)$(ABIFLAGS)'
4111AC_MSG_RESULT($LDVERSION)
4112
doko@python.org87421192013-01-26 11:39:31 +01004113dnl define LIBPL after ABIFLAGS and LDVERSION is defined.
4114AC_SUBST(PY_ENABLE_SHARED)
4115LIBPL="${prefix}/lib/python${VERSION}/config-${LDVERSION}"
4116AC_SUBST(LIBPL)
4117
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00004118# Check whether right shifting a negative integer extends the sign bit
4119# or fills with zeros (like the Cray J90, according to Tim Peters).
4120AC_MSG_CHECKING(whether right shift extends the sign bit)
Vladimir Marangozova6180282000-07-12 05:05:06 +00004121AC_CACHE_VAL(ac_cv_rshift_extends_sign, [
Matthias Kloseb159a552010-04-25 21:00:44 +00004122AC_RUN_IFELSE([AC_LANG_SOURCE([[
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00004123int main()
4124{
Vladimir Marangozova6180282000-07-12 05:05:06 +00004125 exit(((-1)>>3 == -1) ? 0 : 1);
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00004126}
Matthias Kloseb159a552010-04-25 21:00:44 +00004127]])],
4128[ac_cv_rshift_extends_sign=yes],
4129[ac_cv_rshift_extends_sign=no],
4130[ac_cv_rshift_extends_sign=yes])])
Vladimir Marangozova6180282000-07-12 05:05:06 +00004131AC_MSG_RESULT($ac_cv_rshift_extends_sign)
4132if test "$ac_cv_rshift_extends_sign" = no
4133then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00004134 AC_DEFINE(SIGNED_RIGHT_SHIFT_ZERO_FILLS, 1,
4135 [Define if i>>j for signed int i does not extend the sign bit
4136 when i < 0])
Vladimir Marangozova6180282000-07-12 05:05:06 +00004137fi
4138
Guido van Rossumcadfaec2001-01-05 14:45:49 +00004139# check for getc_unlocked and related locking functions
4140AC_MSG_CHECKING(for getc_unlocked() and friends)
4141AC_CACHE_VAL(ac_cv_have_getc_unlocked, [
Matthias Kloseb159a552010-04-25 21:00:44 +00004142AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <stdio.h>]], [[
Guido van Rossumcadfaec2001-01-05 14:45:49 +00004143 FILE *f = fopen("/dev/null", "r");
4144 flockfile(f);
4145 getc_unlocked(f);
4146 funlockfile(f);
Matthias Kloseb159a552010-04-25 21:00:44 +00004147]])],[ac_cv_have_getc_unlocked=yes],[ac_cv_have_getc_unlocked=no])])
Guido van Rossumcadfaec2001-01-05 14:45:49 +00004148AC_MSG_RESULT($ac_cv_have_getc_unlocked)
4149if test "$ac_cv_have_getc_unlocked" = yes
4150then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00004151 AC_DEFINE(HAVE_GETC_UNLOCKED, 1,
4152 [Define this if you have flockfile(), getc_unlocked(), and funlockfile()])
Guido van Rossumcadfaec2001-01-05 14:45:49 +00004153fi
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00004154
Neal Norwitzfe8e3d92006-01-07 21:07:20 +00004155# check where readline lives
Martin v. Löwis82bca632006-02-10 20:49:30 +00004156# save the value of LIBS so we don't actually link Python with readline
4157LIBS_no_readline=$LIBS
Gregory P. Smith18820942008-09-07 06:24:49 +00004158
4159# On some systems we need to link readline to a termcap compatible
4160# library. NOTE: Keep the precedence of listed libraries synchronised
4161# with setup.py.
4162py_cv_lib_readline=no
4163AC_MSG_CHECKING([how to link readline libs])
doko@ubuntu.comf2967c72012-06-30 17:32:23 +02004164for py_libtermcap in "" tinfo ncursesw ncurses curses termcap; do
Gregory P. Smith18820942008-09-07 06:24:49 +00004165 if test -z "$py_libtermcap"; then
4166 READLINE_LIBS="-lreadline"
4167 else
4168 READLINE_LIBS="-lreadline -l$py_libtermcap"
4169 fi
4170 LIBS="$READLINE_LIBS $LIBS_no_readline"
4171 AC_LINK_IFELSE(
4172 [AC_LANG_CALL([],[readline])],
4173 [py_cv_lib_readline=yes])
4174 if test $py_cv_lib_readline = yes; then
4175 break
4176 fi
4177done
4178# Uncomment this line if you want to use READINE_LIBS in Makefile or scripts
4179#AC_SUBST([READLINE_LIBS])
Gregory P. Smith97515912008-09-07 19:23:19 +00004180if test $py_cv_lib_readline = no; then
Gregory P. Smith18820942008-09-07 06:24:49 +00004181 AC_MSG_RESULT([none])
4182else
4183 AC_MSG_RESULT([$READLINE_LIBS])
4184 AC_DEFINE(HAVE_LIBREADLINE, 1,
4185 [Define if you have the readline library (-lreadline).])
Neal Norwitzfe8e3d92006-01-07 21:07:20 +00004186fi
4187
Michael W. Hudson30ea2f22004-07-07 17:44:12 +00004188# check for readline 2.1
4189AC_CHECK_LIB(readline, rl_callback_handler_install,
4190 AC_DEFINE(HAVE_RL_CALLBACK, 1,
Gregory P. Smith18820942008-09-07 06:24:49 +00004191 [Define if you have readline 2.1]), ,$READLINE_LIBS)
Michael W. Hudson30ea2f22004-07-07 17:44:12 +00004192
Guido van Rossumfaf5e4d2002-12-30 16:25:41 +00004193# check for readline 2.2
Matthias Kloseb159a552010-04-25 21:00:44 +00004194AC_PREPROC_IFELSE([AC_LANG_SOURCE([[#include <readline/readline.h>]])],
4195 [have_readline=yes],
4196 [have_readline=no]
4197)
Guido van Rossumfaf5e4d2002-12-30 16:25:41 +00004198if test $have_readline = yes
4199then
4200 AC_EGREP_HEADER([extern int rl_completion_append_character;],
4201 [readline/readline.h],
4202 AC_DEFINE(HAVE_RL_COMPLETION_APPEND_CHARACTER, 1,
4203 [Define if you have readline 2.2]), )
Antoine Pitroud5131772009-10-26 19:22:14 +00004204 AC_EGREP_HEADER([extern int rl_completion_suppress_append;],
4205 [readline/readline.h],
4206 AC_DEFINE(HAVE_RL_COMPLETION_SUPPRESS_APPEND, 1,
4207 [Define if you have rl_completion_suppress_append]), )
Guido van Rossumfaf5e4d2002-12-30 16:25:41 +00004208fi
4209
Martin v. Löwis0daad592001-09-30 21:09:59 +00004210# check for readline 4.0
4211AC_CHECK_LIB(readline, rl_pre_input_hook,
Martin v. Löwisc45929e2002-04-06 10:10:49 +00004212 AC_DEFINE(HAVE_RL_PRE_INPUT_HOOK, 1,
Gregory P. Smith18820942008-09-07 06:24:49 +00004213 [Define if you have readline 4.0]), ,$READLINE_LIBS)
Martin v. Löwis0daad592001-09-30 21:09:59 +00004214
Thomas Wouters89d996e2007-09-08 17:39:28 +00004215# also in 4.0
4216AC_CHECK_LIB(readline, rl_completion_display_matches_hook,
4217 AC_DEFINE(HAVE_RL_COMPLETION_DISPLAY_MATCHES_HOOK, 1,
Gregory P. Smith18820942008-09-07 06:24:49 +00004218 [Define if you have readline 4.0]), ,$READLINE_LIBS)
Thomas Wouters89d996e2007-09-08 17:39:28 +00004219
Guido van Rossum353ae582001-07-10 16:45:32 +00004220# check for readline 4.2
4221AC_CHECK_LIB(readline, rl_completion_matches,
Martin v. Löwisc45929e2002-04-06 10:10:49 +00004222 AC_DEFINE(HAVE_RL_COMPLETION_MATCHES, 1,
Gregory P. Smith18820942008-09-07 06:24:49 +00004223 [Define if you have readline 4.2]), ,$READLINE_LIBS)
Guido van Rossum353ae582001-07-10 16:45:32 +00004224
Michael W. Hudson30ea2f22004-07-07 17:44:12 +00004225# also in readline 4.2
Matthias Kloseb159a552010-04-25 21:00:44 +00004226AC_PREPROC_IFELSE([AC_LANG_SOURCE([[#include <readline/readline.h>]])],
4227 [have_readline=yes],
4228 [have_readline=no]
4229)
Michael W. Hudson30ea2f22004-07-07 17:44:12 +00004230if test $have_readline = yes
4231then
4232 AC_EGREP_HEADER([extern int rl_catch_signals;],
4233 [readline/readline.h],
4234 AC_DEFINE(HAVE_RL_CATCH_SIGNAL, 1,
4235 [Define if you can turn off readline's signal handling.]), )
4236fi
4237
Martin v. Löwis82bca632006-02-10 20:49:30 +00004238# End of readline checks: restore LIBS
4239LIBS=$LIBS_no_readline
4240
Thomas Wouterse38b2f12001-07-11 22:35:31 +00004241AC_MSG_CHECKING(for broken nice())
4242AC_CACHE_VAL(ac_cv_broken_nice, [
Matthias Kloseb159a552010-04-25 21:00:44 +00004243AC_RUN_IFELSE([AC_LANG_SOURCE([[
Thomas Wouterse38b2f12001-07-11 22:35:31 +00004244int main()
4245{
4246 int val1 = nice(1);
4247 if (val1 != -1 && val1 == nice(2))
4248 exit(0);
4249 exit(1);
4250}
Matthias Kloseb159a552010-04-25 21:00:44 +00004251]])],
4252[ac_cv_broken_nice=yes],
4253[ac_cv_broken_nice=no],
4254[ac_cv_broken_nice=no])])
Thomas Wouterse38b2f12001-07-11 22:35:31 +00004255AC_MSG_RESULT($ac_cv_broken_nice)
4256if test "$ac_cv_broken_nice" = yes
4257then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00004258 AC_DEFINE(HAVE_BROKEN_NICE, 1,
4259 [Define if nice() returns success/failure instead of the new priority.])
Thomas Wouterse38b2f12001-07-11 22:35:31 +00004260fi
4261
Nicholas Bastine62c5c82004-03-21 23:45:42 +00004262AC_MSG_CHECKING(for broken poll())
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00004263AC_CACHE_VAL(ac_cv_broken_poll,
Matthias Kloseb159a552010-04-25 21:00:44 +00004264AC_RUN_IFELSE([AC_LANG_SOURCE([[
Nicholas Bastine62c5c82004-03-21 23:45:42 +00004265#include <poll.h>
4266
Alexandre Vassalottiaee170a2009-07-17 06:24:33 +00004267int main()
4268{
Nicholas Bastine62c5c82004-03-21 23:45:42 +00004269 struct pollfd poll_struct = { 42, POLLIN|POLLPRI|POLLOUT, 0 };
Alexandre Vassalottiaee170a2009-07-17 06:24:33 +00004270 int poll_test;
4271
Nicholas Bastine62c5c82004-03-21 23:45:42 +00004272 close (42);
4273
Alexandre Vassalottiaee170a2009-07-17 06:24:33 +00004274 poll_test = poll(&poll_struct, 1, 0);
Nicholas Bastine62c5c82004-03-21 23:45:42 +00004275 if (poll_test < 0)
Alexandre Vassalottiaee170a2009-07-17 06:24:33 +00004276 return 0;
Nicholas Bastine62c5c82004-03-21 23:45:42 +00004277 else if (poll_test == 0 && poll_struct.revents != POLLNVAL)
Alexandre Vassalottiaee170a2009-07-17 06:24:33 +00004278 return 0;
Nicholas Bastine62c5c82004-03-21 23:45:42 +00004279 else
Alexandre Vassalottiaee170a2009-07-17 06:24:33 +00004280 return 1;
4281}
Matthias Kloseb159a552010-04-25 21:00:44 +00004282]])],
4283[ac_cv_broken_poll=yes],
4284[ac_cv_broken_poll=no],
4285[ac_cv_broken_poll=no]))
Nicholas Bastine62c5c82004-03-21 23:45:42 +00004286AC_MSG_RESULT($ac_cv_broken_poll)
4287if test "$ac_cv_broken_poll" = yes
4288then
4289 AC_DEFINE(HAVE_BROKEN_POLL, 1,
4290 [Define if poll() sets errno on invalid file descriptors.])
4291fi
4292
Brett Cannon43802422005-02-10 20:48:03 +00004293# Before we can test tzset, we need to check if struct tm has a tm_zone
4294# (which is not required by ISO C or UNIX spec) and/or if we support
4295# tzname[]
4296AC_STRUCT_TIMEZONE
Nicholas Bastine62c5c82004-03-21 23:45:42 +00004297
Brett Cannon43802422005-02-10 20:48:03 +00004298# check tzset(3) exists and works like we expect it to
Guido van Rossumd11b62e2003-03-14 21:51:36 +00004299AC_MSG_CHECKING(for working tzset())
4300AC_CACHE_VAL(ac_cv_working_tzset, [
Matthias Kloseb159a552010-04-25 21:00:44 +00004301AC_RUN_IFELSE([AC_LANG_SOURCE([[
Guido van Rossumd11b62e2003-03-14 21:51:36 +00004302#include <stdlib.h>
4303#include <time.h>
Brett Cannon18367812003-09-19 00:59:16 +00004304#include <string.h>
Brett Cannon43802422005-02-10 20:48:03 +00004305
4306#if HAVE_TZNAME
4307extern char *tzname[];
4308#endif
4309
Guido van Rossumd11b62e2003-03-14 21:51:36 +00004310int main()
4311{
Brett Cannon18367812003-09-19 00:59:16 +00004312 /* Note that we need to ensure that not only does tzset(3)
4313 do 'something' with localtime, but it works as documented
4314 in the library reference and as expected by the test suite.
Brett Cannon43802422005-02-10 20:48:03 +00004315 This includes making sure that tzname is set properly if
4316 tm->tm_zone does not exist since it is the alternative way
4317 of getting timezone info.
Brett Cannon18367812003-09-19 00:59:16 +00004318
4319 Red Hat 6.2 doesn't understand the southern hemisphere
Brett Cannon43802422005-02-10 20:48:03 +00004320 after New Year's Day.
Brett Cannon18367812003-09-19 00:59:16 +00004321 */
4322
Brett Cannon43802422005-02-10 20:48:03 +00004323 time_t groundhogday = 1044144000; /* GMT-based */
Brett Cannon18367812003-09-19 00:59:16 +00004324 time_t midyear = groundhogday + (365 * 24 * 3600 / 2);
4325
Neal Norwitz7f2588c2003-04-11 15:35:53 +00004326 putenv("TZ=UTC+0");
Guido van Rossumd11b62e2003-03-14 21:51:36 +00004327 tzset();
Brett Cannon18367812003-09-19 00:59:16 +00004328 if (localtime(&groundhogday)->tm_hour != 0)
4329 exit(1);
Brett Cannon43802422005-02-10 20:48:03 +00004330#if HAVE_TZNAME
4331 /* For UTC, tzname[1] is sometimes "", sometimes " " */
4332 if (strcmp(tzname[0], "UTC") ||
4333 (tzname[1][0] != 0 && tzname[1][0] != ' '))
4334 exit(1);
4335#endif
Brett Cannon18367812003-09-19 00:59:16 +00004336
Neal Norwitz7f2588c2003-04-11 15:35:53 +00004337 putenv("TZ=EST+5EDT,M4.1.0,M10.5.0");
Guido van Rossumd11b62e2003-03-14 21:51:36 +00004338 tzset();
Brett Cannon18367812003-09-19 00:59:16 +00004339 if (localtime(&groundhogday)->tm_hour != 19)
Guido van Rossumd11b62e2003-03-14 21:51:36 +00004340 exit(1);
Brett Cannon43802422005-02-10 20:48:03 +00004341#if HAVE_TZNAME
4342 if (strcmp(tzname[0], "EST") || strcmp(tzname[1], "EDT"))
4343 exit(1);
4344#endif
Brett Cannon18367812003-09-19 00:59:16 +00004345
4346 putenv("TZ=AEST-10AEDT-11,M10.5.0,M3.5.0");
4347 tzset();
4348 if (localtime(&groundhogday)->tm_hour != 11)
4349 exit(1);
Brett Cannon43802422005-02-10 20:48:03 +00004350#if HAVE_TZNAME
4351 if (strcmp(tzname[0], "AEST") || strcmp(tzname[1], "AEDT"))
4352 exit(1);
4353#endif
4354
4355#if HAVE_STRUCT_TM_TM_ZONE
Brett Cannon18367812003-09-19 00:59:16 +00004356 if (strcmp(localtime(&groundhogday)->tm_zone, "AEDT"))
4357 exit(1);
4358 if (strcmp(localtime(&midyear)->tm_zone, "AEST"))
4359 exit(1);
Brett Cannon43802422005-02-10 20:48:03 +00004360#endif
Brett Cannon18367812003-09-19 00:59:16 +00004361
Guido van Rossumd11b62e2003-03-14 21:51:36 +00004362 exit(0);
4363}
Matthias Kloseb159a552010-04-25 21:00:44 +00004364]])],
4365[ac_cv_working_tzset=yes],
4366[ac_cv_working_tzset=no],
4367[ac_cv_working_tzset=no])])
Guido van Rossumd11b62e2003-03-14 21:51:36 +00004368AC_MSG_RESULT($ac_cv_working_tzset)
4369if test "$ac_cv_working_tzset" = yes
4370then
4371 AC_DEFINE(HAVE_WORKING_TZSET, 1,
4372 [Define if tzset() actually switches the local timezone in a meaningful way.])
4373fi
4374
Martin v. Löwis94717ed2002-09-09 14:24:16 +00004375# Look for subsecond timestamps in struct stat
4376AC_MSG_CHECKING(for tv_nsec in struct stat)
4377AC_CACHE_VAL(ac_cv_stat_tv_nsec,
Matthias Kloseb159a552010-04-25 21:00:44 +00004378AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/stat.h>]], [[
Martin v. Löwis94717ed2002-09-09 14:24:16 +00004379struct stat st;
4380st.st_mtim.tv_nsec = 1;
Matthias Kloseb159a552010-04-25 21:00:44 +00004381]])],
4382[ac_cv_stat_tv_nsec=yes],
4383[ac_cv_stat_tv_nsec=no]))
Martin v. Löwis94717ed2002-09-09 14:24:16 +00004384AC_MSG_RESULT($ac_cv_stat_tv_nsec)
4385if test "$ac_cv_stat_tv_nsec" = yes
4386then
4387 AC_DEFINE(HAVE_STAT_TV_NSEC, 1,
4388 [Define if you have struct stat.st_mtim.tv_nsec])
4389fi
4390
Martin v. Löwisebd9d5b2005-08-09 15:00:59 +00004391# Look for BSD style subsecond timestamps in struct stat
4392AC_MSG_CHECKING(for tv_nsec2 in struct stat)
4393AC_CACHE_VAL(ac_cv_stat_tv_nsec2,
Matthias Kloseb159a552010-04-25 21:00:44 +00004394AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/stat.h>]], [[
Martin v. Löwisebd9d5b2005-08-09 15:00:59 +00004395struct stat st;
4396st.st_mtimespec.tv_nsec = 1;
Matthias Kloseb159a552010-04-25 21:00:44 +00004397]])],
4398[ac_cv_stat_tv_nsec2=yes],
4399[ac_cv_stat_tv_nsec2=no]))
Martin v. Löwisebd9d5b2005-08-09 15:00:59 +00004400AC_MSG_RESULT($ac_cv_stat_tv_nsec2)
4401if test "$ac_cv_stat_tv_nsec2" = yes
4402then
4403 AC_DEFINE(HAVE_STAT_TV_NSEC2, 1,
4404 [Define if you have struct stat.st_mtimensec])
4405fi
4406
doko@ubuntu.com1a4f5612014-04-17 20:13:44 +02004407# first curses header check
doko@ubuntu.com9dc823d2012-07-07 03:06:42 +02004408ac_save_cppflags="$CPPFLAGS"
4409CPPFLAGS="$CPPFLAGS -I/usr/include/ncursesw"
doko@ubuntu.com1a4f5612014-04-17 20:13:44 +02004410
4411AC_CHECK_HEADERS(curses.h ncurses.h)
4412
4413# On Solaris, term.h requires curses.h
4414AC_CHECK_HEADERS(term.h,,,[
4415#ifdef HAVE_CURSES_H
4416#include <curses.h>
4417#endif
4418])
4419
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00004420# On HP/UX 11.0, mvwdelch is a block with a return statement
4421AC_MSG_CHECKING(whether mvwdelch is an expression)
4422AC_CACHE_VAL(ac_cv_mvwdelch_is_expression,
Matthias Kloseb159a552010-04-25 21:00:44 +00004423AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <curses.h>]], [[
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00004424 int rtn;
4425 rtn = mvwdelch(0,0,0);
Matthias Kloseb159a552010-04-25 21:00:44 +00004426]])],
4427[ac_cv_mvwdelch_is_expression=yes],
4428[ac_cv_mvwdelch_is_expression=no]))
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00004429AC_MSG_RESULT($ac_cv_mvwdelch_is_expression)
4430
4431if test "$ac_cv_mvwdelch_is_expression" = yes
4432then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00004433 AC_DEFINE(MVWDELCH_IS_EXPRESSION, 1,
4434 [Define if mvwdelch in curses.h is an expression.])
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00004435fi
4436
4437AC_MSG_CHECKING(whether WINDOW has _flags)
4438AC_CACHE_VAL(ac_cv_window_has_flags,
Matthias Kloseb159a552010-04-25 21:00:44 +00004439AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <curses.h>]], [[
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00004440 WINDOW *w;
4441 w->_flags = 0;
Matthias Kloseb159a552010-04-25 21:00:44 +00004442]])],
4443[ac_cv_window_has_flags=yes],
4444[ac_cv_window_has_flags=no]))
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00004445AC_MSG_RESULT($ac_cv_window_has_flags)
4446
4447
4448if test "$ac_cv_window_has_flags" = yes
4449then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00004450 AC_DEFINE(WINDOW_HAS_FLAGS, 1,
4451 [Define if WINDOW in curses.h offers a field _flags.])
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00004452fi
4453
Thomas Wouters0e3f5912006-08-11 14:57:12 +00004454AC_MSG_CHECKING(for is_term_resized)
Matthias Kloseb159a552010-04-25 21:00:44 +00004455AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <curses.h>]], [[void *x=is_term_resized]])],
4456 [AC_DEFINE(HAVE_CURSES_IS_TERM_RESIZED, 1, Define if you have the 'is_term_resized' function.)
4457 AC_MSG_RESULT(yes)],
4458 [AC_MSG_RESULT(no)]
Thomas Wouters0e3f5912006-08-11 14:57:12 +00004459)
Martin v. Löwis24a880b2002-12-31 12:55:15 +00004460
Thomas Wouters0e3f5912006-08-11 14:57:12 +00004461AC_MSG_CHECKING(for resize_term)
Matthias Kloseb159a552010-04-25 21:00:44 +00004462AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <curses.h>]], [[void *x=resize_term]])],
4463 [AC_DEFINE(HAVE_CURSES_RESIZE_TERM, 1, Define if you have the 'resize_term' function.)
4464 AC_MSG_RESULT(yes)],
4465 [AC_MSG_RESULT(no)]
Thomas Wouters0e3f5912006-08-11 14:57:12 +00004466)
4467
4468AC_MSG_CHECKING(for resizeterm)
Matthias Kloseb159a552010-04-25 21:00:44 +00004469AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <curses.h>]], [[void *x=resizeterm]])],
4470 [AC_DEFINE(HAVE_CURSES_RESIZETERM, 1, Define if you have the 'resizeterm' function.)
4471 AC_MSG_RESULT(yes)],
4472 [AC_MSG_RESULT(no)]
Thomas Wouters0e3f5912006-08-11 14:57:12 +00004473)
doko@ubuntu.com9dc823d2012-07-07 03:06:42 +02004474# last curses configure check
4475CPPFLAGS=$ac_save_cppflags
Thomas Wouters0e3f5912006-08-11 14:57:12 +00004476
doko@ubuntu.comb457b9b2012-06-30 19:28:16 +02004477AC_MSG_NOTICE([checking for device files])
Thomas Wouters89f507f2006-12-13 04:49:30 +00004478
doko@ubuntu.comb457b9b2012-06-30 19:28:16 +02004479dnl NOTE: Inform user how to proceed with files when cross compiling.
4480if test "x$cross_compiling" = xyes; then
4481 if test "${ac_cv_file__dev_ptmx+set}" != set; then
4482 AC_MSG_CHECKING([for /dev/ptmx])
4483 AC_MSG_RESULT([not set])
4484 AC_MSG_ERROR([set ac_cv_file__dev_ptmx to yes/no in your CONFIG_SITE file when cross compiling])
4485 fi
4486 if test "${ac_cv_file__dev_ptc+set}" != set; then
4487 AC_MSG_CHECKING([for /dev/ptc])
4488 AC_MSG_RESULT([not set])
4489 AC_MSG_ERROR([set ac_cv_file__dev_ptc to yes/no in your CONFIG_SITE file when cross compiling])
4490 fi
Thomas Wouters89f507f2006-12-13 04:49:30 +00004491fi
4492
doko@ubuntu.comb457b9b2012-06-30 19:28:16 +02004493AC_CHECK_FILE(/dev/ptmx, [], [])
4494if test "x$ac_cv_file__dev_ptmx" = xyes; then
4495 AC_DEFINE(HAVE_DEV_PTMX, 1,
4496 [Define to 1 if you have the /dev/ptmx device file.])
4497fi
4498AC_CHECK_FILE(/dev/ptc, [], [])
4499if test "x$ac_cv_file__dev_ptc" = xyes; then
Thomas Wouters89f507f2006-12-13 04:49:30 +00004500 AC_DEFINE(HAVE_DEV_PTC, 1,
doko@ubuntu.comb457b9b2012-06-30 19:28:16 +02004501 [Define to 1 if you have the /dev/ptc device file.])
Thomas Wouters89f507f2006-12-13 04:49:30 +00004502fi
Neal Norwitz865400f2003-03-21 01:42:58 +00004503
Mark Dickinson6ce4a9a2009-11-16 17:00:11 +00004504if test "$have_long_long" = yes
4505then
4506 AC_MSG_CHECKING(for %lld and %llu printf() format support)
4507 AC_CACHE_VAL(ac_cv_have_long_long_format,
Matthias Kloseb159a552010-04-25 21:00:44 +00004508 AC_RUN_IFELSE([AC_LANG_SOURCE([[[
Mark Dickinson6ce4a9a2009-11-16 17:00:11 +00004509 #include <stdio.h>
4510 #include <stddef.h>
4511 #include <string.h>
4512
4513 #ifdef HAVE_SYS_TYPES_H
4514 #include <sys/types.h>
4515 #endif
4516
4517 int main()
4518 {
4519 char buffer[256];
4520
4521 if (sprintf(buffer, "%lld", (long long)123) < 0)
4522 return 1;
4523 if (strcmp(buffer, "123"))
4524 return 1;
4525
4526 if (sprintf(buffer, "%lld", (long long)-123) < 0)
4527 return 1;
4528 if (strcmp(buffer, "-123"))
4529 return 1;
4530
4531 if (sprintf(buffer, "%llu", (unsigned long long)123) < 0)
4532 return 1;
4533 if (strcmp(buffer, "123"))
4534 return 1;
4535
4536 return 0;
4537 }
Matthias Kloseb159a552010-04-25 21:00:44 +00004538 ]]])],
4539 [ac_cv_have_long_long_format=yes],
4540 [ac_cv_have_long_long_format=no],
Matthias Klose3b739b12012-03-15 19:31:06 +01004541 [ac_cv_have_long_long_format="cross -- assuming no"
4542 if test x$GCC = xyes; then
4543 save_CFLAGS=$CFLAGS
4544 CFLAGS="$CFLAGS -Werror -Wformat"
4545 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4546 #include <stdio.h>
4547 #include <stddef.h>
4548 ]], [[
4549 char *buffer;
4550 sprintf(buffer, "%lld", (long long)123);
4551 sprintf(buffer, "%lld", (long long)-123);
4552 sprintf(buffer, "%llu", (unsigned long long)123);
4553 ]])],
4554 ac_cv_have_long_long_format=yes
4555 )
4556 CFLAGS=$save_CFLAGS
4557 fi])
Mark Dickinson6ce4a9a2009-11-16 17:00:11 +00004558 )
4559 AC_MSG_RESULT($ac_cv_have_long_long_format)
4560fi
4561
Mark Dickinson89d7d412009-12-31 20:50:59 +00004562if test "$ac_cv_have_long_long_format" = yes
Mark Dickinson6ce4a9a2009-11-16 17:00:11 +00004563then
4564 AC_DEFINE(PY_FORMAT_LONG_LONG, "ll",
4565 [Define to printf format modifier for long long type])
4566fi
4567
Ronald Oussoren3c1928a2009-11-19 17:15:31 +00004568if test $ac_sys_system = Darwin
4569then
4570 LIBS="$LIBS -framework CoreFoundation"
4571fi
Mark Dickinson6ce4a9a2009-11-16 17:00:11 +00004572
Benjamin Peterson8f326b22009-12-13 02:10:36 +00004573AC_CACHE_CHECK([for %zd printf() format support], ac_cv_have_size_t_format, [dnl
Matthias Kloseb159a552010-04-25 21:00:44 +00004574AC_RUN_IFELSE([AC_LANG_SOURCE([[
Alexandre Vassalottie5091f62009-07-17 06:41:02 +00004575#include <stdio.h>
Thomas Wouters477c8d52006-05-27 19:21:47 +00004576#include <stddef.h>
4577#include <string.h>
4578
Christian Heimes2c181612007-12-17 20:04:13 +00004579#ifdef HAVE_SYS_TYPES_H
4580#include <sys/types.h>
4581#endif
Thomas Wouters89f507f2006-12-13 04:49:30 +00004582
4583#ifdef HAVE_SSIZE_T
4584typedef ssize_t Py_ssize_t;
4585#elif SIZEOF_VOID_P == SIZEOF_LONG
4586typedef long Py_ssize_t;
4587#else
4588typedef int Py_ssize_t;
4589#endif
Thomas Wouters477c8d52006-05-27 19:21:47 +00004590
Christian Heimes2c181612007-12-17 20:04:13 +00004591int main()
4592{
4593 char buffer[256];
4594
Thomas Wouters477c8d52006-05-27 19:21:47 +00004595 if(sprintf(buffer, "%zd", (size_t)123) < 0)
4596 return 1;
4597
Thomas Wouters89f507f2006-12-13 04:49:30 +00004598 if (strcmp(buffer, "123"))
Thomas Wouters477c8d52006-05-27 19:21:47 +00004599 return 1;
Thomas Wouters89f507f2006-12-13 04:49:30 +00004600
4601 if (sprintf(buffer, "%zd", (Py_ssize_t)-123) < 0)
4602 return 1;
4603
4604 if (strcmp(buffer, "-123"))
4605 return 1;
4606
Thomas Wouters477c8d52006-05-27 19:21:47 +00004607 return 0;
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00004608}
Matthias Kloseb159a552010-04-25 21:00:44 +00004609]])],
4610 [ac_cv_have_size_t_format=yes],
4611 [ac_cv_have_size_t_format=no],
4612 [ac_cv_have_size_t_format="cross -- assuming yes"
4613])])
Benjamin Peterson8f326b22009-12-13 02:10:36 +00004614if test "$ac_cv_have_size_t_format" != no ; then
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00004615 AC_DEFINE(PY_FORMAT_SIZE_T, "z",
4616 [Define to printf format modifier for Py_ssize_t])
4617fi
Thomas Wouters477c8d52006-05-27 19:21:47 +00004618
Martin v. Löwis01c04012002-11-11 14:58:44 +00004619AC_CHECK_TYPE(socklen_t,,
4620 AC_DEFINE(socklen_t,int,
Matthias Klosec80c93f2010-04-24 17:04:35 +00004621 [Define to `int' if <sys/socket.h> does not define.]),[
Martin v. Löwis01c04012002-11-11 14:58:44 +00004622#ifdef HAVE_SYS_TYPES_H
4623#include <sys/types.h>
4624#endif
Guido van Rossum95713eb2000-05-18 20:53:31 +00004625#ifdef HAVE_SYS_SOCKET_H
4626#include <sys/socket.h>
4627#endif
Martin v. Löwis01c04012002-11-11 14:58:44 +00004628])
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00004629
Antoine Pitroufff95302008-09-03 18:58:51 +00004630AC_MSG_CHECKING(for broken mbstowcs)
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00004631AC_CACHE_VAL(ac_cv_broken_mbstowcs,
Matthias Kloseb159a552010-04-25 21:00:44 +00004632AC_RUN_IFELSE([AC_LANG_SOURCE([[
Stefan Krah19c21392012-11-22 23:47:32 +01004633#include <stdio.h>
Antoine Pitroufff95302008-09-03 18:58:51 +00004634#include<stdlib.h>
4635int main() {
4636 size_t len = -1;
4637 const char *str = "text";
4638 len = mbstowcs(NULL, str, 0);
4639 return (len != 4);
4640}
Matthias Kloseb159a552010-04-25 21:00:44 +00004641]])],
4642[ac_cv_broken_mbstowcs=no],
4643[ac_cv_broken_mbstowcs=yes],
4644[ac_cv_broken_mbstowcs=no]))
Antoine Pitroufff95302008-09-03 18:58:51 +00004645AC_MSG_RESULT($ac_cv_broken_mbstowcs)
4646if test "$ac_cv_broken_mbstowcs" = yes
4647then
4648 AC_DEFINE(HAVE_BROKEN_MBSTOWCS, 1,
4649 [Define if mbstowcs(NULL, "text", 0) does not return the number of
4650 wide chars that would be converted.])
4651fi
4652
Antoine Pitroub52ec782009-01-25 16:34:23 +00004653# Check for --with-computed-gotos
4654AC_MSG_CHECKING(for --with-computed-gotos)
4655AC_ARG_WITH(computed-gotos,
Antoine Pitrou042b1282010-08-13 21:15:58 +00004656 AS_HELP_STRING([--with(out)-computed-gotos],
4657 [Use computed gotos in evaluation loop (enabled by default on supported compilers)]),
Antoine Pitroub52ec782009-01-25 16:34:23 +00004658[
Antoine Pitrou042b1282010-08-13 21:15:58 +00004659if test "$withval" = yes
Antoine Pitroub52ec782009-01-25 16:34:23 +00004660then
4661 AC_DEFINE(USE_COMPUTED_GOTOS, 1,
4662 [Define if you want to use computed gotos in ceval.c.])
4663 AC_MSG_RESULT(yes)
Antoine Pitrou042b1282010-08-13 21:15:58 +00004664fi
4665if test "$withval" = no
4666then
4667 AC_DEFINE(USE_COMPUTED_GOTOS, 0,
4668 [Define if you want to use computed gotos in ceval.c.])
4669 AC_MSG_RESULT(no)
4670fi
4671],
4672[AC_MSG_RESULT(no value specified)])
Antoine Pitroub52ec782009-01-25 16:34:23 +00004673
Matthias Kloseb17289e2012-03-15 19:51:34 +01004674AC_MSG_CHECKING(whether $CC supports computed gotos)
4675AC_CACHE_VAL(ac_cv_computed_gotos,
4676AC_RUN_IFELSE([AC_LANG_SOURCE([[[
4677int main(int argc, char **argv)
4678{
4679 static void *targets[1] = { &&LABEL1 };
4680 goto LABEL2;
4681LABEL1:
4682 return 0;
4683LABEL2:
4684 goto *targets[0];
4685 return 1;
4686}
4687]]])],
4688[ac_cv_computed_gotos=yes],
4689[ac_cv_computed_gotos=no],
4690[if test "${with_computed_gotos+set}" = set; then
4691 ac_cv_computed_gotos="$with_computed_gotos -- configured --with(out)-computed-gotos"
4692 else
4693 ac_cv_computed_gotos=no
4694 fi]))
4695AC_MSG_RESULT($ac_cv_computed_gotos)
4696case "$ac_cv_computed_gotos" in yes*)
4697 AC_DEFINE(HAVE_COMPUTED_GOTOS, 1,
4698 [Define if the C compiler supports computed gotos.])
4699esac
4700
R. David Murraye16cda92010-10-15 23:12:57 +00004701case $ac_sys_system in
4702AIX*)
4703 AC_DEFINE(HAVE_BROKEN_PIPE_BUF, 1, [Define if the system reports an invalid PIPE_BUF value.]) ;;
4704esac
Antoine Pitroub52ec782009-01-25 16:34:23 +00004705
Jesus Cea6a792292010-05-03 21:18:48 +00004706
Martin v. Löwis06f15bb2001-12-02 13:02:32 +00004707AC_SUBST(THREADHEADERS)
4708
4709for h in `(cd $srcdir;echo Python/thread_*.h)`
4710do
4711 THREADHEADERS="$THREADHEADERS \$(srcdir)/$h"
4712done
4713
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00004714AC_SUBST(SRCDIRS)
Neal Norwitzd24499d2005-12-18 21:36:39 +00004715SRCDIRS="Parser Grammar Objects Python Modules Mac"
Andrew M. Kuchling8abedde2001-01-26 22:55:24 +00004716AC_MSG_CHECKING(for build directories)
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00004717for dir in $SRCDIRS; do
4718 if test ! -d $dir; then
4719 mkdir $dir
Fred Drake884d3ba2000-11-02 17:52:56 +00004720 fi
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00004721done
4722AC_MSG_RESULT(done)
Fred Drake036144d2000-10-26 17:09:35 +00004723
Stefan Krah1919b7e2012-03-21 18:25:23 +01004724# Availability of -O2:
4725AC_MSG_CHECKING(for -O2)
4726saved_cflags="$CFLAGS"
4727CFLAGS="-O2"
4728AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
4729]])],[have_O2=yes],[have_O2=no])
4730AC_MSG_RESULT($have_O2)
4731CFLAGS="$saved_cflags"
4732
4733# _FORTIFY_SOURCE wrappers for memmove and bcopy are incorrect:
4734# http://sourceware.org/ml/libc-alpha/2010-12/msg00009.html
4735AC_MSG_CHECKING(for glibc _FORTIFY_SOURCE/memmove bug)
4736saved_cflags="$CFLAGS"
4737CFLAGS="-O2 -D_FORTIFY_SOURCE=2"
4738if test "$have_O2" = no; then
4739 CFLAGS=""
4740fi
4741AC_RUN_IFELSE([AC_LANG_SOURCE([[
4742#include <stdio.h>
4743#include <stdlib.h>
4744#include <string.h>
4745void foo(void *p, void *q) { memmove(p, q, 19); }
4746int main() {
4747 char a[32] = "123456789000000000";
4748 foo(&a[9], a);
4749 if (strcmp(a, "123456789123456789000000000") != 0)
4750 return 1;
4751 foo(a, &a[9]);
4752 if (strcmp(a, "123456789000000000") != 0)
4753 return 1;
4754 return 0;
4755}
4756]])],
4757[have_glibc_memmove_bug=no],
4758[have_glibc_memmove_bug=yes],
4759[have_glibc_memmove_bug=undefined])
4760CFLAGS="$saved_cflags"
4761AC_MSG_RESULT($have_glibc_memmove_bug)
4762if test "$have_glibc_memmove_bug" = yes; then
4763 AC_DEFINE(HAVE_GLIBC_MEMMOVE_BUG, 1,
4764 [Define if glibc has incorrect _FORTIFY_SOURCE wrappers
4765 for memmove and bcopy.])
4766fi
4767
4768if test "$have_gcc_asm_for_x87" = yes; then
4769 # Some versions of gcc miscompile inline asm:
4770 # http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46491
4771 # http://gcc.gnu.org/ml/gcc/2010-11/msg00366.html
4772 case $CC in
4773 *gcc*)
4774 AC_MSG_CHECKING(for gcc ipa-pure-const bug)
4775 saved_cflags="$CFLAGS"
4776 CFLAGS="-O2"
4777 AC_RUN_IFELSE([AC_LANG_SOURCE([[
4778 __attribute__((noinline)) int
4779 foo(int *p) {
4780 int r;
4781 asm ( "movl \$6, (%1)\n\t"
4782 "xorl %0, %0\n\t"
4783 : "=r" (r) : "r" (p) : "memory"
4784 );
4785 return r;
4786 }
4787 int main() {
4788 int p = 8;
4789 if ((foo(&p) ? : p) != 6)
4790 return 1;
4791 return 0;
4792 }
4793 ]])],
4794 [have_ipa_pure_const_bug=no],
4795 [have_ipa_pure_const_bug=yes],
4796 [have_ipa_pure_const_bug=undefined])
4797 CFLAGS="$saved_cflags"
4798 AC_MSG_RESULT($have_ipa_pure_const_bug)
4799 if test "$have_ipa_pure_const_bug" = yes; then
4800 AC_DEFINE(HAVE_IPA_PURE_CONST_BUG, 1,
4801 [Define if gcc has the ipa-pure-const bug.])
4802 fi
4803 ;;
4804 esac
4805fi
4806
Ned Deily322f5ba2013-11-21 23:01:59 -08004807# ensurepip option
4808AC_MSG_CHECKING(for ensurepip)
4809AC_ARG_WITH(ensurepip,
4810 [AS_HELP_STRING([--with(out)-ensurepip=@<:@=upgrade@:>@],
4811 ["install" or "upgrade" using bundled pip])],
4812 [],
4813 [with_ensurepip=upgrade])
4814AS_CASE($with_ensurepip,
4815 [yes|upgrade],[ENSUREPIP=upgrade],
4816 [install],[ENSUREPIP=install],
4817 [no],[ENSUREPIP=no],
4818 [AC_MSG_ERROR([--with-ensurepip=upgrade|install|no])])
4819AC_MSG_RESULT($ENSUREPIP)
4820AC_SUBST(ENSUREPIP)
4821
Guido van Rossum627b2d71993-12-24 10:39:16 +00004822# generate output files
doko@python.org87421192013-01-26 11:39:31 +01004823AC_CONFIG_FILES(Makefile.pre Modules/Setup.config Misc/python.pc Misc/python-config.sh)
Antoine Pitrou8e6b4072010-09-10 19:44:44 +00004824AC_CONFIG_FILES([Modules/ld_so_aix], [chmod +x Modules/ld_so_aix])
Martin v. Löwis88afe662002-10-26 13:47:44 +00004825AC_OUTPUT
Neil Schemenauer61c51152001-01-26 16:18:16 +00004826
Christian Heimes75ed8902013-11-20 01:11:18 +01004827echo "creating Modules/Setup" >&AS_MESSAGE_FD
Neil Schemenauer61c51152001-01-26 16:18:16 +00004828if test ! -f Modules/Setup
4829then
4830 cp $srcdir/Modules/Setup.dist Modules/Setup
4831fi
4832
Christian Heimes75ed8902013-11-20 01:11:18 +01004833echo "creating Modules/Setup.local" >&AS_MESSAGE_FD
Neil Schemenauer61c51152001-01-26 16:18:16 +00004834if test ! -f Modules/Setup.local
4835then
4836 echo "# Edit this file for local setup changes" >Modules/Setup.local
4837fi
4838
Christian Heimes75ed8902013-11-20 01:11:18 +01004839echo "creating Makefile" >&AS_MESSAGE_FD
Neil Schemenauer61c51152001-01-26 16:18:16 +00004840$SHELL $srcdir/Modules/makesetup -c $srcdir/Modules/config.c.in \
4841 -s Modules Modules/Setup.config \
Neil Schemenauerf8b71c52001-04-21 17:41:16 +00004842 Modules/Setup.local Modules/Setup
Neil Schemenauer66252162001-02-19 04:47:42 +00004843mv config.c Modules