blob: 78fe3c785fc983010710797c3fddf1e6d3b8857f [file] [log] [blame]
Benjamin Petersond7c77842008-05-26 13:01:25 +00001dnl ***********************************************
2dnl * Please run autoreconf to test your changes! *
3dnl ***********************************************
Martin v. Löwis88afe662002-10-26 13:47:44 +00004
5# Set VERSION so we only need to edit in one place (i.e., here)
Martin v. Löwis174440b2008-10-03 08:59:41 +00006m4_define(PYTHON_VERSION, 2.7)
Martin v. Löwis88afe662002-10-26 13:47:44 +00007
Georg Brandl71f4fbb2011-02-25 11:04:50 +00008AC_PREREQ(2.65)
Alexandre Vassalotti130ae152009-07-18 00:31:06 +00009
Guido van Rossum76be6ed1995-01-02 18:33:54 +000010AC_REVISION($Revision$)
Georg Brandl464432d2009-05-20 18:24:08 +000011AC_INIT(python, PYTHON_VERSION, http://bugs.python.org/)
Martin v. Löwis88afe662002-10-26 13:47:44 +000012AC_CONFIG_SRCDIR([Include/object.h])
Martin v. Löwis4f1cd8b2001-07-26 13:41:06 +000013AC_CONFIG_HEADER(pyconfig.h)
Guido van Rossum627b2d71993-12-24 10:39:16 +000014
doko@python.orgd65e2ba2013-01-31 23:52:03 +010015AC_CANONICAL_HOST
16AC_SUBST(build)
17AC_SUBST(host)
18
Ned Deily983df862014-08-22 13:30:59 -070019# pybuilddir.txt will be created by --generate-posix-vars in the Makefile
20rm -f pybuilddir.txt
21
doko@python.orgd65e2ba2013-01-31 23:52:03 +010022if test "$cross_compiling" = yes; then
23 AC_MSG_CHECKING([for python interpreter for cross build])
24 if test -z "$PYTHON_FOR_BUILD"; then
25 for interp in python$PACKAGE_VERSION python2 python; do
26 which $interp >/dev/null 2>&1 || continue
27 if $interp -c 'import sys;sys.exit(not (sys.version_info@<:@:2@:>@ >= (2,7) and sys.version_info@<:@0@:>@ < 3))'; then
28 break
29 fi
30 interp=
31 done
32 if test x$interp = x; then
33 AC_MSG_ERROR([python$PACKAGE_VERSION interpreter not found])
34 fi
35 AC_MSG_RESULT($interp)
doko@ubuntu.com9e7ece22015-04-13 21:55:08 +020036 PYTHON_FOR_BUILD='_PYTHON_PROJECT_BASE=$(abs_builddir) _PYTHON_HOST_PLATFORM=$(_PYTHON_HOST_PLATFORM) PYTHONPATH=$(shell test -f pybuilddir.txt && echo $(abs_builddir)/`cat pybuilddir.txt`:)$(srcdir)/Lib:$(srcdir)/Lib/$(PLATDIR) '$interp
doko@python.orgd65e2ba2013-01-31 23:52:03 +010037 fi
38elif test "$cross_compiling" = maybe; then
39 AC_MSG_ERROR([Cross compiling required --host=HOST-TUPLE and --build=ARCH])
40else
41 PYTHON_FOR_BUILD='./$(BUILDPYTHON) -E'
42fi
43AC_SUBST(PYTHON_FOR_BUILD)
44
Georg Brandlbcd64a32009-03-31 21:45:18 +000045dnl Ensure that if prefix is specified, it does not end in a slash. If
46dnl it does, we get path names containing '//' which is both ugly and
47dnl can cause trouble.
48
49dnl Last slash shouldn't be stripped if prefix=/
50if test "$prefix" != "/"; then
51 prefix=`echo "$prefix" | sed -e 's/\/$//g'`
52fi
53
Martin v. Löwis8316feb2003-06-14 07:48:07 +000054dnl This is for stuff that absolutely must end up in pyconfig.h.
55dnl Please use pyport.h instead, if possible.
Martin v. Löwisbddf5a52002-11-11 13:37:28 +000056AH_TOP([
57#ifndef Py_PYCONFIG_H
58#define Py_PYCONFIG_H
59])
Martin v. Löwis11437992002-04-12 09:54:03 +000060AH_BOTTOM([
Martin v. Löwis11437992002-04-12 09:54:03 +000061/* Define the macros needed if on a UnixWare 7.x system. */
62#if defined(__USLC__) && defined(__SCO_VERSION__)
63#define STRICT_SYSV_CURSES /* Don't use ncurses extensions */
64#endif
Martin v. Löwisbddf5a52002-11-11 13:37:28 +000065
66#endif /*Py_PYCONFIG_H*/
Martin v. Löwis11437992002-04-12 09:54:03 +000067])
68
Martin v. Löwis8316feb2003-06-14 07:48:07 +000069# We don't use PACKAGE_ variables, and they cause conflicts
70# with other autoconf-based packages that include Python.h
71grep -v 'define PACKAGE_' <confdefs.h >confdefs.h.new
72rm confdefs.h
73mv confdefs.h.new confdefs.h
74
Guido van Rossum642b6781997-07-19 19:35:41 +000075AC_SUBST(VERSION)
Martin v. Löwis88afe662002-10-26 13:47:44 +000076VERSION=PYTHON_VERSION
Guido van Rossum642b6781997-07-19 19:35:41 +000077
Martin v. Löwis1142de32002-03-29 16:28:31 +000078AC_SUBST(SOVERSION)
79SOVERSION=1.0
80
Martin v. Löwis6f18a3c2002-07-20 08:51:52 +000081# The later defininition of _XOPEN_SOURCE disables certain features
82# on Linux, so we need _GNU_SOURCE to re-enable them (makedev, tm_zone).
83AC_DEFINE(_GNU_SOURCE, 1, [Define on Linux to activate all library features])
84
Martin v. Löwisbcd93962003-05-03 10:32:18 +000085# The later defininition of _XOPEN_SOURCE and _POSIX_C_SOURCE disables
86# certain features on NetBSD, so we need _NETBSD_SOURCE to re-enable
87# them.
88AC_DEFINE(_NETBSD_SOURCE, 1, [Define on NetBSD to activate all library features])
89
Andrew MacIntyreabccf412003-07-02 13:53:25 +000090# The later defininition of _XOPEN_SOURCE and _POSIX_C_SOURCE disables
91# certain features on FreeBSD, so we need __BSD_VISIBLE to re-enable
92# them.
93AC_DEFINE(__BSD_VISIBLE, 1, [Define on FreeBSD to activate all library features])
94
Martin v. Löwisd6320502004-08-12 13:45:08 +000095# The later defininition of _XOPEN_SOURCE and _POSIX_C_SOURCE disables
96# u_int on Irix 5.3. Defining _BSD_TYPES brings it back.
97AC_DEFINE(_BSD_TYPES, 1, [Define on Irix to enable u_int])
98
Ronald Oussoren5640ce22008-06-05 12:58:24 +000099# The later defininition of _XOPEN_SOURCE and _POSIX_C_SOURCE disables
100# certain features on Mac OS X, so we need _DARWIN_C_SOURCE to re-enable
101# them.
102AC_DEFINE(_DARWIN_C_SOURCE, 1, [Define on Darwin to activate all library features])
103
104
Martin v. Löwise981a4e2002-11-11 13:26:51 +0000105define_xopen_source=yes
Martin v. Löwis6f18a3c2002-07-20 08:51:52 +0000106
Neil Schemenauer4edbc2a2001-03-22 00:34:03 +0000107# Arguments passed to configure.
108AC_SUBST(CONFIG_ARGS)
109CONFIG_ARGS="$ac_configure_args"
110
Ronald Oussoren3c0a1262010-01-17 19:27:57 +0000111AC_MSG_CHECKING([for --enable-universalsdk])
Ronald Oussoren988117f2006-04-29 11:31:35 +0000112AC_ARG_ENABLE(universalsdk,
Matthias Klose22520ea2010-05-08 10:14:46 +0000113 AS_HELP_STRING([--enable-universalsdk@<:@=SDKDIR@:>@], [Build against Mac OS X 10.4u SDK (ppc/i386)]),
Ronald Oussoren988117f2006-04-29 11:31:35 +0000114[
115 case $enableval in
116 yes)
117 enableval=/Developer/SDKs/MacOSX10.4u.sdk
Ronald Oussoren3c0a1262010-01-17 19:27:57 +0000118 if test ! -d "${enableval}"
119 then
120 enableval=/
121 fi
Ronald Oussoren988117f2006-04-29 11:31:35 +0000122 ;;
123 esac
124 case $enableval in
125 no)
126 UNIVERSALSDK=
127 enable_universalsdk=
128 ;;
129 *)
130 UNIVERSALSDK=$enableval
Ronald Oussoren3c0a1262010-01-17 19:27:57 +0000131 if test ! -d "${UNIVERSALSDK}"
132 then
133 AC_MSG_ERROR([--enable-universalsdk specifies non-existing SDK: ${UNIVERSALSDK}])
134 fi
Ronald Oussoren988117f2006-04-29 11:31:35 +0000135 ;;
136 esac
Ronald Oussoren3c0a1262010-01-17 19:27:57 +0000137
Ronald Oussoren988117f2006-04-29 11:31:35 +0000138],[
139 UNIVERSALSDK=
140 enable_universalsdk=
141])
Ronald Oussoren3c0a1262010-01-17 19:27:57 +0000142if test -n "${UNIVERSALSDK}"
143then
144 AC_MSG_RESULT(${UNIVERSALSDK})
145else
146 AC_MSG_RESULT(no)
147fi
Ronald Oussoren988117f2006-04-29 11:31:35 +0000148AC_SUBST(UNIVERSALSDK)
149
Benjamin Peterson0e6ea5d2008-07-16 20:17:04 +0000150AC_SUBST(ARCH_RUN_32BIT)
Ned Deily8e60f6e2013-05-30 00:14:29 -0700151ARCH_RUN_32BIT=""
Benjamin Peterson0e6ea5d2008-07-16 20:17:04 +0000152
Ronald Oussoren5640ce22008-06-05 12:58:24 +0000153UNIVERSAL_ARCHS="32-bit"
Ronald Oussoren92919a62009-12-24 13:30:58 +0000154AC_SUBST(LIPO_32BIT_FLAGS)
Ronald Oussoren5640ce22008-06-05 12:58:24 +0000155AC_MSG_CHECKING(for --with-universal-archs)
156AC_ARG_WITH(universal-archs,
Matthias Klose22520ea2010-05-08 10:14:46 +0000157 AS_HELP_STRING([--with-universal-archs=ARCH], [select architectures for universal build ("32-bit", "64-bit", "3-way", "intel" or "all")]),
Ronald Oussoren5640ce22008-06-05 12:58:24 +0000158[
159 AC_MSG_RESULT($withval)
160 UNIVERSAL_ARCHS="$withval"
Ronald Oussoren9ebd2422009-09-29 13:00:44 +0000161 if test "${enable_universalsdk}" ; then
162 :
163 else
164 AC_MSG_ERROR([--with-universal-archs without --enable-universalsdk. See Mac/README])
165 fi
Ronald Oussoren5640ce22008-06-05 12:58:24 +0000166],
167[
168 AC_MSG_RESULT(32-bit)
169])
170
171
172
Ronald Oussoren580c7fe2008-05-02 19:45:11 +0000173AC_ARG_WITH(framework-name,
Matthias Klose22520ea2010-05-08 10:14:46 +0000174 AS_HELP_STRING([--with-framework-name=FRAMEWORK],
Matthias Klose5183ebd2010-04-24 16:38:36 +0000175 [specify an alternate name of the framework built with --enable-framework]),
Ronald Oussoren580c7fe2008-05-02 19:45:11 +0000176[
Ronald Oussoren9ebd2422009-09-29 13:00:44 +0000177 if test "${enable_framework}"; then
178 :
179 else
180 AC_MSG_ERROR([--with-framework-name without --enable-framework. See Mac/README])
181 fi
Ronald Oussoren580c7fe2008-05-02 19:45:11 +0000182 PYTHONFRAMEWORK=${withval}
183 PYTHONFRAMEWORKDIR=${withval}.framework
184 PYTHONFRAMEWORKIDENTIFIER=org.python.`echo $withval | tr '[A-Z]' '[a-z]'`
185 ],[
186 PYTHONFRAMEWORK=Python
187 PYTHONFRAMEWORKDIR=Python.framework
188 PYTHONFRAMEWORKIDENTIFIER=org.python.python
189])
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000190dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000191AC_ARG_ENABLE(framework,
Matthias Klose22520ea2010-05-08 10:14:46 +0000192 AS_HELP_STRING([--enable-framework@<:@=INSTALLDIR@:>@], [Build (MacOSX|Darwin) framework]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000193[
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000194 case $enableval in
195 yes)
196 enableval=/Library/Frameworks
Jack Jansen127e56e2001-09-11 14:41:54 +0000197 esac
198 case $enableval in
199 no)
200 PYTHONFRAMEWORK=
201 PYTHONFRAMEWORKDIR=no-framework
202 PYTHONFRAMEWORKPREFIX=
203 PYTHONFRAMEWORKINSTALLDIR=
Ronald Oussoren567a8ff2006-05-26 11:43:26 +0000204 FRAMEWORKINSTALLFIRST=
205 FRAMEWORKINSTALLLAST=
Ronald Oussoren5b787322006-06-06 19:50:24 +0000206 FRAMEWORKALTINSTALLFIRST=
207 FRAMEWORKALTINSTALLLAST=
Ronald Oussoren2db3a8f2006-06-07 19:06:01 +0000208 if test "x${prefix}" = "xNONE"; then
209 FRAMEWORKUNIXTOOLSPREFIX="${ac_default_prefix}"
210 else
211 FRAMEWORKUNIXTOOLSPREFIX="${prefix}"
212 fi
Jack Jansen127e56e2001-09-11 14:41:54 +0000213 enable_framework=
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000214 ;;
215 *)
Ronald Oussoren01d149f2010-04-30 11:20:14 +0000216 PYTHONFRAMEWORKPREFIX="${enableval}"
Jack Jansen127e56e2001-09-11 14:41:54 +0000217 PYTHONFRAMEWORKINSTALLDIR=$PYTHONFRAMEWORKPREFIX/$PYTHONFRAMEWORKDIR
Ronald Oussoren567a8ff2006-05-26 11:43:26 +0000218 FRAMEWORKINSTALLFIRST="frameworkinstallstructure"
Ronald Oussoren5640ce22008-06-05 12:58:24 +0000219 FRAMEWORKALTINSTALLFIRST="frameworkinstallstructure bininstall maninstall"
Ronald Oussoren92919a62009-12-24 13:30:58 +0000220 FRAMEWORKINSTALLLAST="frameworkinstallmaclib frameworkinstallapps frameworkinstallunixtools"
221 FRAMEWORKALTINSTALLLAST="frameworkinstallmaclib frameworkinstallapps frameworkaltinstallunixtools"
Ronald Oussoren01d149f2010-04-30 11:20:14 +0000222 FRAMEWORKINSTALLAPPSPREFIX="/Applications"
Ronald Oussoren5640ce22008-06-05 12:58:24 +0000223
Ronald Oussoren2db3a8f2006-06-07 19:06:01 +0000224 if test "x${prefix}" = "xNONE" ; then
225 FRAMEWORKUNIXTOOLSPREFIX="${ac_default_prefix}"
Ronald Oussoren01d149f2010-04-30 11:20:14 +0000226
Ronald Oussoren2db3a8f2006-06-07 19:06:01 +0000227 else
228 FRAMEWORKUNIXTOOLSPREFIX="${prefix}"
229 fi
Ronald Oussoren01d149f2010-04-30 11:20:14 +0000230
231 case "${enableval}" in
232 /System*)
233 FRAMEWORKINSTALLAPPSPREFIX="/Applications"
234 if test "${prefix}" = "NONE" ; then
235 # See below
236 FRAMEWORKUNIXTOOLSPREFIX="/usr"
237 fi
238 ;;
239
240 /Library*)
241 FRAMEWORKINSTALLAPPSPREFIX="/Applications"
242 ;;
243
244 */Library/Frameworks)
245 MDIR="`dirname "${enableval}"`"
246 MDIR="`dirname "${MDIR}"`"
247 FRAMEWORKINSTALLAPPSPREFIX="${MDIR}/Applications"
248
249 if test "${prefix}" = "NONE"; then
250 # User hasn't specified the
251 # --prefix option, but wants to install
252 # the framework in a non-default location,
253 # ensure that the compatibility links get
254 # installed relative to that prefix as well
255 # instead of in /usr/local.
256 FRAMEWORKUNIXTOOLSPREFIX="${MDIR}"
257 fi
258 ;;
259
260 *)
261 FRAMEWORKINSTALLAPPSPREFIX="/Applications"
262 ;;
263 esac
264
Jack Jansen127e56e2001-09-11 14:41:54 +0000265 prefix=$PYTHONFRAMEWORKINSTALLDIR/Versions/$VERSION
Ronald Oussoren836b0392006-05-14 19:56:34 +0000266
Ronald Oussoren580c7fe2008-05-02 19:45:11 +0000267 # Add files for Mac specific code to the list of output
Ronald Oussoren836b0392006-05-14 19:56:34 +0000268 # files:
Ronald Oussoren2db3a8f2006-06-07 19:06:01 +0000269 AC_CONFIG_FILES(Mac/Makefile)
270 AC_CONFIG_FILES(Mac/PythonLauncher/Makefile)
271 AC_CONFIG_FILES(Mac/IDLE/Makefile)
Ronald Oussoren580c7fe2008-05-02 19:45:11 +0000272 AC_CONFIG_FILES(Mac/Resources/framework/Info.plist)
273 AC_CONFIG_FILES(Mac/Resources/app/Info.plist)
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000274 esac
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000275 ],[
276 PYTHONFRAMEWORK=
Jack Jansen127e56e2001-09-11 14:41:54 +0000277 PYTHONFRAMEWORKDIR=no-framework
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000278 PYTHONFRAMEWORKPREFIX=
279 PYTHONFRAMEWORKINSTALLDIR=
Ronald Oussoren567a8ff2006-05-26 11:43:26 +0000280 FRAMEWORKINSTALLFIRST=
281 FRAMEWORKINSTALLLAST=
Ronald Oussoren5b787322006-06-06 19:50:24 +0000282 FRAMEWORKALTINSTALLFIRST=
283 FRAMEWORKALTINSTALLLAST=
Ronald Oussoren2db3a8f2006-06-07 19:06:01 +0000284 if test "x${prefix}" = "xNONE" ; then
285 FRAMEWORKUNIXTOOLSPREFIX="${ac_default_prefix}"
286 else
287 FRAMEWORKUNIXTOOLSPREFIX="${prefix}"
288 fi
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000289 enable_framework=
Ronald Oussoren5640ce22008-06-05 12:58:24 +0000290
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000291])
292AC_SUBST(PYTHONFRAMEWORK)
Ronald Oussoren580c7fe2008-05-02 19:45:11 +0000293AC_SUBST(PYTHONFRAMEWORKIDENTIFIER)
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000294AC_SUBST(PYTHONFRAMEWORKDIR)
295AC_SUBST(PYTHONFRAMEWORKPREFIX)
296AC_SUBST(PYTHONFRAMEWORKINSTALLDIR)
Ronald Oussoren567a8ff2006-05-26 11:43:26 +0000297AC_SUBST(FRAMEWORKINSTALLFIRST)
298AC_SUBST(FRAMEWORKINSTALLLAST)
Ronald Oussoren5b787322006-06-06 19:50:24 +0000299AC_SUBST(FRAMEWORKALTINSTALLFIRST)
300AC_SUBST(FRAMEWORKALTINSTALLLAST)
301AC_SUBST(FRAMEWORKUNIXTOOLSPREFIX)
Ronald Oussoren01d149f2010-04-30 11:20:14 +0000302AC_SUBST(FRAMEWORKINSTALLAPPSPREFIX)
Guido van Rossum4b6b5791996-09-09 20:09:34 +0000303
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000304##AC_ARG_WITH(dyld,
Matthias Klose22520ea2010-05-08 10:14:46 +0000305## AS_HELP_STRING([--with-dyld],
306## [Use (OpenStep|Rhapsody) dynamic linker]))
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000307##
Guido van Rossumb418f891996-07-30 18:06:02 +0000308# Set name for machine-dependent library files
309AC_SUBST(MACHDEP)
310AC_MSG_CHECKING(MACHDEP)
311if test -z "$MACHDEP"
312then
doko@python.orgd65e2ba2013-01-31 23:52:03 +0100313 # avoid using uname for cross builds
314 if test "$cross_compiling" = yes; then
315 # ac_sys_system and ac_sys_release are only used for setting
316 # `define_xopen_source' in the case statement below. For the
317 # current supported cross builds, this macro is not adjusted.
318 case "$host" in
319 *-*-linux*)
320 ac_sys_system=Linux
321 ;;
322 *-*-cygwin*)
323 ac_sys_system=Cygwin
324 ;;
325 *)
326 # for now, limit cross builds to known configurations
327 MACHDEP="unknown"
328 AC_MSG_ERROR([cross build not supported for $host])
329 esac
330 ac_sys_release=
331 else
Guido van Rossum4b6b5791996-09-09 20:09:34 +0000332 ac_sys_system=`uname -s`
Georg Brandlfe18a112009-09-04 07:55:14 +0000333 if test "$ac_sys_system" = "AIX" \
Martin v. Löwis21ee4092002-09-30 16:19:48 +0000334 -o "$ac_sys_system" = "UnixWare" -o "$ac_sys_system" = "OpenUNIX"; then
Guido van Rossum4b6b5791996-09-09 20:09:34 +0000335 ac_sys_release=`uname -v`
Guido van Rossumb418f891996-07-30 18:06:02 +0000336 else
Guido van Rossum4b6b5791996-09-09 20:09:34 +0000337 ac_sys_release=`uname -r`
Guido van Rossumb418f891996-07-30 18:06:02 +0000338 fi
doko@python.orgd65e2ba2013-01-31 23:52:03 +0100339 fi
340 ac_md_system=`echo $ac_sys_system |
341 tr -d '[/ ]' | tr '[[A-Z]]' '[[a-z]]'`
342 ac_md_release=`echo $ac_sys_release |
343 tr -d '[/ ]' | sed 's/^[[A-Z]]\.//' | sed 's/\..*//'`
344 MACHDEP="$ac_md_system$ac_md_release"
Guido van Rossum4b6b5791996-09-09 20:09:34 +0000345
doko@python.orgd65e2ba2013-01-31 23:52:03 +0100346 case $MACHDEP in
Victor Stinneracacbaa2011-08-20 14:02:38 +0200347 linux*) MACHDEP="linux2";;
Andrew M. Kuchling5a3e4cb2001-07-20 19:29:04 +0000348 cygwin*) MACHDEP="cygwin";;
Jack Jansen8a97f4a2001-12-05 23:27:32 +0000349 darwin*) MACHDEP="darwin";;
Martin v. Löwisf90ae202002-06-11 06:22:31 +0000350 atheos*) MACHDEP="atheos";;
Martin v. Löwisf3322282003-07-13 09:46:13 +0000351 irix646) MACHDEP="irix6";;
Guido van Rossumb97ef171997-09-28 05:44:03 +0000352 '') MACHDEP="unknown";;
doko@python.orgd65e2ba2013-01-31 23:52:03 +0100353 esac
354fi
355
356AC_SUBST(_PYTHON_HOST_PLATFORM)
357if test "$cross_compiling" = yes; then
358 case "$host" in
359 *-*-linux*)
360 case "$host_cpu" in
361 arm*)
362 _host_cpu=arm
363 ;;
364 *)
365 _host_cpu=$host_cpu
366 esac
367 ;;
368 *-*-cygwin*)
369 _host_cpu=
370 ;;
371 *)
372 # for now, limit cross builds to known configurations
373 MACHDEP="unknown"
374 AC_MSG_ERROR([cross build not supported for $host])
Guido van Rossumb418f891996-07-30 18:06:02 +0000375 esac
doko@python.orgd65e2ba2013-01-31 23:52:03 +0100376 _PYTHON_HOST_PLATFORM="$MACHDEP${_host_cpu:+-$_host_cpu}"
Guido van Rossumb418f891996-07-30 18:06:02 +0000377fi
Jack Jansen83f898c2002-12-30 22:23:40 +0000378
Martin v. Löwise981a4e2002-11-11 13:26:51 +0000379# Some systems cannot stand _XOPEN_SOURCE being defined at all; they
380# disable features if it is defined, without any means to access these
381# features as extensions. For these systems, we skip the definition of
382# _XOPEN_SOURCE. Before adding a system to the list to gain access to
383# some feature, make sure there is no alternative way to access this
384# feature. Also, when using wildcards, make sure you have verified the
385# need for not defining _XOPEN_SOURCE on all systems matching the
386# wildcard, and that the wildcard does not include future systems
387# (which may remove their limitations).
388dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
389case $ac_sys_system/$ac_sys_release in
390 # On OpenBSD, select(2) is not available if _XOPEN_SOURCE is defined,
391 # even though select is a POSIX function. Reported by J. Ribbens.
Martin v. Löwis76bafc62003-10-03 13:47:44 +0000392 # Reconfirmed for OpenBSD 3.3 by Zachary Hamm, for 3.4 by Jason Ish.
Martin v. Löwis7875ef62010-02-15 21:41:12 +0000393 # In addition, Stefan Krah confirms that issue #1244610 exists through
394 # OpenBSD 4.6, but is fixed in 4.7.
Charles-François Natali97781b02011-07-22 23:43:42 +0200395 OpenBSD/2.* | OpenBSD/3.* | OpenBSD/4.@<:@0123456@:>@)
Martin v. Löwiscb78de62007-12-29 18:49:21 +0000396 define_xopen_source=no
397 # OpenBSD undoes our definition of __BSD_VISIBLE if _XOPEN_SOURCE is
398 # also defined. This can be overridden by defining _BSD_SOURCE
399 # As this has a different meaning on Linux, only define it on OpenBSD
400 AC_DEFINE(_BSD_SOURCE, 1, [Define on OpenBSD to activate all library features])
401 ;;
Charles-François Natali97781b02011-07-22 23:43:42 +0200402 OpenBSD/*)
Martin v. Löwis5e2dd862010-02-15 08:32:00 +0000403 # OpenBSD undoes our definition of __BSD_VISIBLE if _XOPEN_SOURCE is
404 # also defined. This can be overridden by defining _BSD_SOURCE
405 # As this has a different meaning on Linux, only define it on OpenBSD
406 AC_DEFINE(_BSD_SOURCE, 1, [Define on OpenBSD to activate all library features])
407 ;;
Martin v. Löwis4d542ec2006-11-25 15:39:19 +0000408 # Defining _XOPEN_SOURCE on NetBSD version prior to the introduction of
409 # _NETBSD_SOURCE disables certain features (eg. setgroups). Reported by
410 # Marc Recht
Georg Brandl4b9bcfc2008-11-16 08:00:17 +0000411 NetBSD/1.5 | NetBSD/1.5.* | NetBSD/1.6 | NetBSD/1.6.* | NetBSD/1.6@<:@A-S@:>@)
Martin v. Löwis4d542ec2006-11-25 15:39:19 +0000412 define_xopen_source=no;;
Martin v. Löwisb41afb52010-05-28 15:28:47 +0000413 # From the perspective of Solaris, _XOPEN_SOURCE is not so much a
414 # request to enable features supported by the standard as a request
415 # to disable features not supported by the standard. The best way
416 # for Python to use Solaris is simply to leave _XOPEN_SOURCE out
417 # entirely and define __EXTENSIONS__ instead.
418 SunOS/*)
Martin v. Löwisa9d71422003-03-28 18:43:31 +0000419 define_xopen_source=no;;
Martin v. Löwisc2409b42003-05-11 05:53:41 +0000420 # On UnixWare 7, u_long is never defined with _XOPEN_SOURCE,
421 # but used in /usr/include/netinet/tcp.h. Reported by Tim Rice.
Martin v. Löwis253d1f42004-05-07 19:14:14 +0000422 # Reconfirmed for 7.1.4 by Martin v. Loewis.
423 OpenUNIX/8.0.0| UnixWare/7.1.@<:@0-4@:>@)
Martin v. Löwisc2409b42003-05-11 05:53:41 +0000424 define_xopen_source=no;;
425 # On OpenServer 5, u_short is never defined with _XOPEN_SOURCE,
Martin v. Löwis53e73c32003-05-05 05:13:18 +0000426 # but used in struct sockaddr.sa_family. Reported by Tim Rice.
Martin v. Löwisc2409b42003-05-11 05:53:41 +0000427 SCO_SV/3.2)
Martin v. Löwis53e73c32003-05-05 05:13:18 +0000428 define_xopen_source=no;;
Martin v. Löwisbb86d832008-11-04 20:40:09 +0000429 # On FreeBSD 4, the math functions C89 does not cover are never defined
430 # with _XOPEN_SOURCE and __BSD_VISIBLE does not re-enable them.
431 FreeBSD/4.*)
432 define_xopen_source=no;;
433 # On MacOS X 10.2, a bug in ncurses.h means that it craps out if
434 # _XOPEN_EXTENDED_SOURCE is defined. Apparently, this is fixed in 10.3, which
435 # identifies itself as Darwin/7.*
436 # On Mac OS X 10.4, defining _POSIX_C_SOURCE or _XOPEN_SOURCE
437 # disables platform specific features beyond repair.
438 # On Mac OS X 10.3, defining _POSIX_C_SOURCE or _XOPEN_SOURCE
439 # has no effect, don't bother defining them
440 Darwin/@<:@6789@:>@.*)
Anthony Baxter6169c6b2003-10-04 07:46:23 +0000441 define_xopen_source=no;;
Ronald Oussorena55af9a2010-01-17 16:25:57 +0000442 Darwin/1@<:@0-9@:>@.*)
443 define_xopen_source=no;;
Trent Mickaf16e8c2004-08-25 23:55:59 +0000444 # On AIX 4 and 5.1, mbstate_t is defined only when _XOPEN_SOURCE == 500 but
445 # used in wcsnrtombs() and mbsnrtowcs() even if _XOPEN_SOURCE is not defined
446 # or has another value. By not (re)defining it, the defaults come in place.
Martin v. Löwisc19c5a62003-11-18 20:00:44 +0000447 AIX/4)
448 define_xopen_source=no;;
Trent Mickaf16e8c2004-08-25 23:55:59 +0000449 AIX/5)
450 if test `uname -r` -eq 1; then
451 define_xopen_source=no
452 fi
453 ;;
Martin v. Löwis8c255e42008-05-23 15:06:50 +0000454 # On QNX 6.3.2, defining _XOPEN_SOURCE prevents netdb.h from
455 # defining NI_NUMERICHOST.
456 QNX/6.3.2)
457 define_xopen_source=no
458 ;;
Martin v. Löwisa0588362006-04-04 06:03:50 +0000459
Martin v. Löwise981a4e2002-11-11 13:26:51 +0000460esac
461
462if test $define_xopen_source = yes
463then
Martin v. Löwisb41afb52010-05-28 15:28:47 +0000464 AC_DEFINE(_XOPEN_SOURCE, 600,
465 Define to the level of X/Open that your system supports)
Martin v. Löwis678fc1e2002-11-12 06:04:39 +0000466
467 # On Tru64 Unix 4.0F, defining _XOPEN_SOURCE also requires
468 # definition of _XOPEN_SOURCE_EXTENDED and _POSIX_C_SOURCE, or else
469 # several APIs are not declared. Since this is also needed in some
470 # cases for HP-UX, we define it globally.
Martin v. Löwisb41afb52010-05-28 15:28:47 +0000471 AC_DEFINE(_XOPEN_SOURCE_EXTENDED, 1,
472 Define to activate Unix95-and-earlier features)
Martin v. Löwis678fc1e2002-11-12 06:04:39 +0000473
Bob Ippolito7026a0a2005-03-28 23:23:47 +0000474 AC_DEFINE(_POSIX_C_SOURCE, 200112L, Define to activate features from IEEE Stds 1003.1-2001)
475
Martin v. Löwise981a4e2002-11-11 13:26:51 +0000476fi
477
Guido van Rossum91922671997-10-09 20:24:13 +0000478#
479# SGI compilers allow the specification of the both the ABI and the
480# ISA on the command line. Depending on the values of these switches,
481# different and often incompatable code will be generated.
482#
483# The SGI_ABI variable can be used to modify the CC and LDFLAGS and
484# thus supply support for various ABI/ISA combinations. The MACHDEP
485# variable is also adjusted.
486#
487AC_SUBST(SGI_ABI)
488if test ! -z "$SGI_ABI"
489then
490 CC="cc $SGI_ABI"
491 LDFLAGS="$SGI_ABI $LDFLAGS"
492 MACHDEP=`echo "${MACHDEP}${SGI_ABI}" | sed 's/ *//g'`
493fi
Guido van Rossumb418f891996-07-30 18:06:02 +0000494AC_MSG_RESULT($MACHDEP)
495
doko@ubuntu.com9e7ece22015-04-13 21:55:08 +0200496AC_SUBST(PLATDIR)
497PLATDIR=plat-$MACHDEP
498
Jack Jansen83f898c2002-12-30 22:23:40 +0000499# And add extra plat-mac for darwin
500AC_SUBST(EXTRAPLATDIR)
Jack Jansen7b59b422003-03-17 15:44:10 +0000501AC_SUBST(EXTRAMACHDEPPATH)
Jack Jansen83f898c2002-12-30 22:23:40 +0000502AC_MSG_CHECKING(EXTRAPLATDIR)
503if test -z "$EXTRAPLATDIR"
504then
505 case $MACHDEP in
Jack Jansen7b59b422003-03-17 15:44:10 +0000506 darwin)
507 EXTRAPLATDIR="\$(PLATMACDIRS)"
508 EXTRAMACHDEPPATH="\$(PLATMACPATH)"
509 ;;
510 *)
511 EXTRAPLATDIR=""
512 EXTRAMACHDEPPATH=""
513 ;;
Jack Jansen83f898c2002-12-30 22:23:40 +0000514 esac
515fi
516AC_MSG_RESULT($EXTRAPLATDIR)
517
Jack Jansen6b08a402004-06-03 12:41:45 +0000518# Record the configure-time value of MACOSX_DEPLOYMENT_TARGET,
519# it may influence the way we can build extensions, so distutils
520# needs to check it
521AC_SUBST(CONFIGURE_MACOSX_DEPLOYMENT_TARGET)
Ronald Oussoren988117f2006-04-29 11:31:35 +0000522AC_SUBST(EXPORT_MACOSX_DEPLOYMENT_TARGET)
Jack Jansen6b08a402004-06-03 12:41:45 +0000523CONFIGURE_MACOSX_DEPLOYMENT_TARGET=
Ronald Oussoren988117f2006-04-29 11:31:35 +0000524EXPORT_MACOSX_DEPLOYMENT_TARGET='#'
Jack Jansen6b08a402004-06-03 12:41:45 +0000525
Guido van Rossum627b2d71993-12-24 10:39:16 +0000526# checks for alternative programs
Skip Montanarodecc6a42003-01-01 20:07:49 +0000527
528# compiler flags are generated in two sets, BASECFLAGS and OPT. OPT is just
529# for debug/optimization stuff. BASECFLAGS is for flags that are required
530# just to get things to compile and link. Users are free to override OPT
531# when running configure or make. The build should not break if they do.
532# BASECFLAGS should generally not be messed with, however.
533
534# XXX shouldn't some/most/all of this code be merged with the stuff later
535# on that fiddles with OPT and BASECFLAGS?
Guido van Rossum5739e7e1995-01-20 16:50:53 +0000536AC_MSG_CHECKING(for --without-gcc)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000537AC_ARG_WITH(gcc,
Matthias Klose22520ea2010-05-08 10:14:46 +0000538 AS_HELP_STRING([--without-gcc], [never use gcc]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000539[
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000540 case $withval in
Skip Montanaro516144f2009-01-04 10:36:58 +0000541 no) CC=${CC:-cc}
Guido van Rossum5739e7e1995-01-20 16:50:53 +0000542 without_gcc=yes;;
543 yes) CC=gcc
544 without_gcc=no;;
545 *) CC=$withval
546 without_gcc=$withval;;
Guido van Rossum55a214e1995-09-13 17:48:09 +0000547 esac], [
Guido van Rossumb418f891996-07-30 18:06:02 +0000548 case $ac_sys_system in
Antoine Pitrou285cd162010-09-21 15:23:17 +0000549 AIX*) CC=${CC:-xlc_r}
Neil Schemenauerb3531b82001-02-16 04:09:05 +0000550 without_gcc=;;
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000551 BeOS*)
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000552 case $BE_HOST_CPU in
553 ppc)
Fred Drake5790be12000-10-09 17:06:13 +0000554 CC=mwcc
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000555 without_gcc=yes
Skip Montanarodecc6a42003-01-01 20:07:49 +0000556 BASECFLAGS="$BASECFLAGS -export pragma"
557 OPT="$OPT -O"
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000558 LDFLAGS="$LDFLAGS -nodup"
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000559 ;;
560 x86)
Fred Drake5790be12000-10-09 17:06:13 +0000561 CC=gcc
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000562 without_gcc=no
Skip Montanarodecc6a42003-01-01 20:07:49 +0000563 OPT="$OPT -O"
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000564 ;;
565 *)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000566 AC_MSG_ERROR([Unknown BeOS platform "$BE_HOST_CPU"])
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000567 ;;
568 esac
Neil Schemenauerb3531b82001-02-16 04:09:05 +0000569 AR="\$(srcdir)/Modules/ar_beos"
570 RANLIB=:
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000571 ;;
Martin v. Löwis130fb172001-07-19 11:00:41 +0000572 *) without_gcc=no;;
Guido van Rossum55a214e1995-09-13 17:48:09 +0000573 esac])
Guido van Rossum5739e7e1995-01-20 16:50:53 +0000574AC_MSG_RESULT($without_gcc)
575
Guido van Rossum03ad99f1995-03-09 14:09:54 +0000576# If the user switches compilers, we can't believe the cache
577if test ! -z "$ac_cv_prog_CC" -a ! -z "$CC" -a "$CC" != "$ac_cv_prog_CC"
578then
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000579 AC_MSG_ERROR([cached CC is different -- throw away $cache_file
580(it is also a good idea to do 'make clean' before compiling)])
Guido van Rossum03ad99f1995-03-09 14:09:54 +0000581fi
582
Trent Nelson15daa352012-12-13 06:46:39 +0000583if test "$MACHDEP" = "irix6" && test "$CC" != "gcc"; then
584 # Normally, MIPSpro CC treats #error directives as warnings, which means
585 # a successful exit code is returned (0). This is a problem because IRIX
586 # has a bunch of system headers with this guard at the top:
587 #
588 # #ifndef __c99
589 # #error This header file is to be used only for c99 mode compilations
590 # #else
591 #
592 # When autoconf tests for such a header, like stdint.h, this happens:
593 #
594 # configure:4619: cc -c conftest.c >&5
595 # cc-1035 cc: WARNING File = /usr/include/stdint.h, Line = 5
596 # #error directive: This header file is to be used only for c99 mode
597 # compilations
598 #
599 # #error This header file is to be used only for c99 mode compilations
600 # ^
601 #
602 # configure:4619: $? = 0
603 # configure:4619: result: yes
604 #
605 # Therefore, we use `-diag_error 1035` to have the compiler treat the
606 # warning as an error, which causes cc to return a non-zero result,
607 # which autoconf can interpret correctly.
608 CFLAGS="$CFLAGS -diag_error 1035"
609 # Whilst we're here, we might as well make sure CXX defaults to something
610 # sensible if we're not using gcc.
611 if test -z "$CXX"; then
612 CXX="CC"
613 fi
614fi
615
Marc-André Lemburg6d5e5792010-04-30 17:20:14 +0000616# If the user set CFLAGS, use this instead of the automatically
617# determined setting
618preset_cflags="$CFLAGS"
Guido van Rossum627b2d71993-12-24 10:39:16 +0000619AC_PROG_CC
Marc-André Lemburg6d5e5792010-04-30 17:20:14 +0000620if test ! -z "$preset_cflags"
621then
622 CFLAGS=$preset_cflags
623fi
Martin v. Löwis1d5ecb72001-08-09 10:29:44 +0000624
Martin v. Löwis0f48d982006-04-14 14:34:26 +0000625AC_SUBST(CXX)
626AC_SUBST(MAINCC)
627AC_MSG_CHECKING(for --with-cxx-main=<compiler>)
628AC_ARG_WITH(cxx_main,
Matthias Klose22520ea2010-05-08 10:14:46 +0000629 AS_HELP_STRING([--with-cxx-main=<compiler>],
Martin v. Löwis0f48d982006-04-14 14:34:26 +0000630 [compile main() and link python executable with C++ compiler]),
631[
632
633 case $withval in
634 no) with_cxx_main=no
635 MAINCC='$(CC)';;
636 yes) with_cxx_main=yes
637 MAINCC='$(CXX)';;
638 *) with_cxx_main=yes
639 MAINCC=$withval
640 if test -z "$CXX"
641 then
642 CXX=$withval
643 fi;;
644 esac], [
645 with_cxx_main=no
646 MAINCC='$(CC)'
647])
648AC_MSG_RESULT($with_cxx_main)
649
650preset_cxx="$CXX"
651if test -z "$CXX"
652then
653 case "$CC" in
doko@python.orgd65e2ba2013-01-31 23:52:03 +0100654 gcc) AC_PATH_TOOL(CXX, [g++], [g++], [notfound]) ;;
655 cc) AC_PATH_TOOL(CXX, [c++], [c++], [notfound]) ;;
Martin v. Löwis0f48d982006-04-14 14:34:26 +0000656 esac
657 if test "$CXX" = "notfound"
658 then
659 CXX=""
660 fi
661fi
662if test -z "$CXX"
663then
doko@python.orgd65e2ba2013-01-31 23:52:03 +0100664 AC_CHECK_TOOLS(CXX, $CCC c++ g++ gcc CC cxx cc++ cl, notfound)
Martin v. Löwis0f48d982006-04-14 14:34:26 +0000665 if test "$CXX" = "notfound"
666 then
667 CXX=""
668 fi
669fi
670if test "$preset_cxx" != "$CXX"
671then
672 AC_MSG_WARN([
673
674 By default, distutils will build C++ extension modules with "$CXX".
675 If this is not intended, then set CXX on the configure command line.
676 ])
677fi
678
doko@python.org4e63fbe2013-01-25 13:08:27 +0100679MULTIARCH=$($CC --print-multiarch 2>/dev/null)
680AC_SUBST(MULTIARCH)
681
Martin v. Löwis0f48d982006-04-14 14:34:26 +0000682
Martin v. Löwis1d5ecb72001-08-09 10:29:44 +0000683# checks for UNIX variants that set C preprocessor variables
Matthias Klose9f8e0c12010-05-08 10:17:27 +0000684AC_USE_SYSTEM_EXTENSIONS
Martin v. Löwis1d5ecb72001-08-09 10:29:44 +0000685
Martin v. Löwis779ffc02002-12-02 22:17:01 +0000686# Check for unsupported systems
687case $ac_sys_system/$ac_sys_release in
Brett Cannon19fab762007-06-02 03:02:29 +0000688atheos*|Linux*/1*)
Martin v. Löwis779ffc02002-12-02 22:17:01 +0000689 echo This system \($ac_sys_system/$ac_sys_release\) is no longer supported.
690 echo See README for details.
691 exit 1;;
692esac
693
Neil Schemenauer55f0cf32001-01-24 17:24:33 +0000694AC_EXEEXT
Neil Schemenauer3ae1d0a2001-01-27 06:54:42 +0000695AC_MSG_CHECKING(for --with-suffix)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000696AC_ARG_WITH(suffix,
Matthias Klose22520ea2010-05-08 10:14:46 +0000697 AS_HELP_STRING([--with-suffix=.exe], [set executable suffix]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000698[
Neil Schemenauer3ae1d0a2001-01-27 06:54:42 +0000699 case $withval in
700 no) EXEEXT=;;
701 yes) EXEEXT=.exe;;
702 *) EXEEXT=$withval;;
703 esac])
704AC_MSG_RESULT($EXEEXT)
Jack Jansen1999ef42001-12-06 21:47:20 +0000705
Jack Jansen9a66b6d2001-08-08 13:56:14 +0000706# Test whether we're running on a non-case-sensitive system, in which
707# case we give a warning if no ext is given
Jack Jansen1999ef42001-12-06 21:47:20 +0000708AC_SUBST(BUILDEXEEXT)
709AC_MSG_CHECKING(for case-insensitive build directory)
Jack Jansen3c2c4332002-11-06 13:33:32 +0000710if test ! -d CaseSensitiveTestDir; then
711mkdir CaseSensitiveTestDir
712fi
713
714if test -d casesensitivetestdir
Jack Jansen9a66b6d2001-08-08 13:56:14 +0000715then
Jack Jansen1999ef42001-12-06 21:47:20 +0000716 AC_MSG_RESULT(yes)
717 BUILDEXEEXT=.exe
718else
719 AC_MSG_RESULT(no)
Jack Jansendd19cf82001-12-06 22:36:17 +0000720 BUILDEXEEXT=$EXEEXT
Jack Jansen9a66b6d2001-08-08 13:56:14 +0000721fi
Jack Jansen3c2c4332002-11-06 13:33:32 +0000722rmdir CaseSensitiveTestDir
Guido van Rossumfb842551997-08-06 23:42:07 +0000723
Guido van Rossumdd997f71998-10-07 19:58:26 +0000724case $MACHDEP in
725bsdos*)
726 case $CC in
727 gcc) CC="$CC -D_HAVE_BSDI";;
728 esac;;
729esac
730
Guido van Rossum84561611997-08-21 00:08:11 +0000731case $ac_sys_system in
732hp*|HP*)
733 case $CC in
Guido van Rossumcd5ff9f2000-09-22 16:15:54 +0000734 cc|*/cc) CC="$CC -Ae";;
Guido van Rossum84561611997-08-21 00:08:11 +0000735 esac;;
Martin v. Löwise8964d42001-03-06 12:09:07 +0000736SunOS*)
737 # Some functions have a prototype only with that define, e.g. confstr
Martin v. Löwisc45929e2002-04-06 10:10:49 +0000738 AC_DEFINE(__EXTENSIONS__, 1, [Defined on Solaris to see additional function prototypes.])
Martin v. Löwise8964d42001-03-06 12:09:07 +0000739 ;;
Guido van Rossum84561611997-08-21 00:08:11 +0000740esac
741
Martin v. Löwise8964d42001-03-06 12:09:07 +0000742
Neil Schemenauer61c51152001-01-26 16:18:16 +0000743AC_SUBST(LIBRARY)
744AC_MSG_CHECKING(LIBRARY)
745if test -z "$LIBRARY"
746then
747 LIBRARY='libpython$(VERSION).a'
748fi
749AC_MSG_RESULT($LIBRARY)
750
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000751# LDLIBRARY is the name of the library to link against (as opposed to the
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000752# name of the library into which to insert object files). BLDLIBRARY is also
753# the library to link against, usually. On Mac OS X frameworks, BLDLIBRARY
754# is blank as the main program is not linked directly against LDLIBRARY.
755# LDLIBRARYDIR is the path to LDLIBRARY, which is made in a subdirectory. On
756# systems without shared libraries, LDLIBRARY is the same as LIBRARY
757# (defined in the Makefiles). On Cygwin LDLIBRARY is the import library,
758# DLLLIBRARY is the shared (i.e., DLL) library.
759#
Martin v. Löwis1142de32002-03-29 16:28:31 +0000760# RUNSHARED is used to run shared python without installed libraries
761#
762# INSTSONAME is the name of the shared library that will be use to install
763# on the system - some systems like version suffix, others don't
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000764AC_SUBST(LDLIBRARY)
Guido van Rossum27552902001-01-23 01:52:26 +0000765AC_SUBST(DLLLIBRARY)
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000766AC_SUBST(BLDLIBRARY)
767AC_SUBST(LDLIBRARYDIR)
Martin v. Löwis1142de32002-03-29 16:28:31 +0000768AC_SUBST(INSTSONAME)
769AC_SUBST(RUNSHARED)
Neil Schemenauer61c51152001-01-26 16:18:16 +0000770LDLIBRARY="$LIBRARY"
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000771BLDLIBRARY='$(LDLIBRARY)'
Martin v. Löwis09bdf722002-05-08 08:51:29 +0000772INSTSONAME='$(LDLIBRARY)'
Guido van Rossum27552902001-01-23 01:52:26 +0000773DLLLIBRARY=''
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000774LDLIBRARYDIR=''
Martin v. Löwis1142de32002-03-29 16:28:31 +0000775RUNSHARED=''
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000776
Guido van Rossumfb842551997-08-06 23:42:07 +0000777# LINKCC is the command that links the python executable -- default is $(CC).
Martin v. Löwisb7da67a2001-10-18 15:35:38 +0000778# If CXX is set, and if it is needed to link a main function that was
779# compiled with CXX, LINKCC is CXX instead. Always using CXX is undesirable:
780# python might then depend on the C++ runtime
Fred Drake5790be12000-10-09 17:06:13 +0000781# This is altered for AIX in order to build the export list before
Guido van Rossumec95c7b1998-08-04 17:59:56 +0000782# linking.
Guido van Rossumfb842551997-08-06 23:42:07 +0000783AC_SUBST(LINKCC)
784AC_MSG_CHECKING(LINKCC)
785if test -z "$LINKCC"
786then
Martin v. Löwis0f48d982006-04-14 14:34:26 +0000787 LINKCC='$(PURIFY) $(MAINCC)'
Guido van Rossumfb842551997-08-06 23:42:07 +0000788 case $ac_sys_system in
789 AIX*)
Neal Norwitz0b27ff92003-03-31 15:53:49 +0000790 exp_extra="\"\""
791 if test $ac_sys_release -ge 5 -o \
792 $ac_sys_release -eq 4 -a `uname -r` -ge 2 ; then
793 exp_extra="."
794 fi
795 LINKCC="\$(srcdir)/Modules/makexp_aix Modules/python.exp $exp_extra \$(LIBRARY); $LINKCC";;
Martin v. Löwis8c255e42008-05-23 15:06:50 +0000796 QNX*)
797 # qcc must be used because the other compilers do not
798 # support -N.
799 LINKCC=qcc;;
Guido van Rossumfb842551997-08-06 23:42:07 +0000800 esac
801fi
802AC_MSG_RESULT($LINKCC)
803
Tarek Ziadée2be83d2009-05-09 08:28:53 +0000804# GNULD is set to "yes" if the GNU linker is used. If this goes wrong
805# make sure we default having it set to "no": this is used by
806# distutils.unixccompiler to know if it should add --enable-new-dtags
807# to linker command lines, and failing to detect GNU ld simply results
808# in the same bahaviour as before.
809AC_SUBST(GNULD)
810AC_MSG_CHECKING(for GNU ld)
811ac_prog=ld
812if test "$GCC" = yes; then
813 ac_prog=`$CC -print-prog-name=ld`
814fi
815case `"$ac_prog" -V 2>&1 < /dev/null` in
816 *GNU*)
817 GNULD=yes;;
818 *)
819 GNULD=no;;
820esac
821AC_MSG_RESULT($GNULD)
822
Martin v. Löwis1142de32002-03-29 16:28:31 +0000823AC_MSG_CHECKING(for --enable-shared)
824AC_ARG_ENABLE(shared,
Matthias Klose22520ea2010-05-08 10:14:46 +0000825 AS_HELP_STRING([--enable-shared], [disable/enable building shared python library]))
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000826
Martin v. Löwis1142de32002-03-29 16:28:31 +0000827if test -z "$enable_shared"
828then
Martin v. Löwisb51033d2002-05-03 05:53:15 +0000829 case $ac_sys_system in
Martin v. Löwisf90ae202002-06-11 06:22:31 +0000830 CYGWIN* | atheos*)
Martin v. Löwisb51033d2002-05-03 05:53:15 +0000831 enable_shared="yes";;
832 *)
833 enable_shared="no";;
834 esac
Martin v. Löwis1142de32002-03-29 16:28:31 +0000835fi
836AC_MSG_RESULT($enable_shared)
837
Skip Montanaro56f6a4f2004-06-18 02:47:22 +0000838AC_MSG_CHECKING(for --enable-profiling)
839AC_ARG_ENABLE(profiling,
doko@python.orgd65e2ba2013-01-31 23:52:03 +0100840 AS_HELP_STRING([--enable-profiling], [enable C-level code profiling]))
841if test "x$enable_profiling" = xyes; then
842 ac_save_cc="$CC"
Benjamin Petersonb9be7bb2013-03-26 08:55:37 -0400843 CC="$CC -pg"
doko@python.orgd65e2ba2013-01-31 23:52:03 +0100844 AC_LINK_IFELSE([AC_LANG_SOURCE([[int main() { return 0; }]])],
845 [],
846 [enable_profiling=no])
847 CC="$ac_save_cc"
848else
849 enable_profiling=no
850fi
851AC_MSG_RESULT($enable_profiling)
Skip Montanaro56f6a4f2004-06-18 02:47:22 +0000852
doko@python.orgd65e2ba2013-01-31 23:52:03 +0100853if test "x$enable_profiling" = xyes; then
854 BASECFLAGS="-pg $BASECFLAGS"
855 LDFLAGS="-pg $LDFLAGS"
856fi
Martin v. Löwis1142de32002-03-29 16:28:31 +0000857
858AC_MSG_CHECKING(LDLIBRARY)
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000859
Guido van Rossumb8552162001-09-05 14:58:11 +0000860# MacOSX framework builds need more magic. LDLIBRARY is the dynamic
861# library that we build, but we do not want to link against it (we
862# will find it with a -framework option). For this reason there is an
863# extra variable BLDLIBRARY against which Python and the extension
864# modules are linked, BLDLIBRARY. This is normally the same as
865# LDLIBRARY, but empty for MacOSX framework builds.
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000866if test "$enable_framework"
867then
868 LDLIBRARY='$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
doko@ubuntu.com9ba90c92014-05-07 04:41:26 +0200869 RUNSHARED=DYLD_FRAMEWORK_PATH=`pwd`${DYLD_FRAMEWORK_PATH:+:${DYLD_FRAMEWORK_PATH}}
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000870 BLDLIBRARY=''
871else
872 BLDLIBRARY='$(LDLIBRARY)'
873fi
874
Martin v. Löwis1142de32002-03-29 16:28:31 +0000875# Other platforms follow
876if test $enable_shared = "yes"; then
Mark Hammond8235ea12002-07-19 06:55:41 +0000877 AC_DEFINE(Py_ENABLE_SHARED, 1, [Defined if Python is built as a shared library.])
Martin v. Löwis1142de32002-03-29 16:28:31 +0000878 case $ac_sys_system in
879 BeOS*)
880 LDLIBRARY='libpython$(VERSION).so'
881 ;;
882 CYGWIN*)
883 LDLIBRARY='libpython$(VERSION).dll.a'
884 DLLLIBRARY='libpython$(VERSION).dll'
885 ;;
886 SunOS*)
887 LDLIBRARY='libpython$(VERSION).so'
Martin v. Löwisd141a8c2003-06-14 15:20:28 +0000888 BLDLIBRARY='-Wl,-R,$(LIBDIR) -L. -lpython$(VERSION)'
doko@ubuntu.com9ba90c92014-05-07 04:41:26 +0200889 RUNSHARED=LD_LIBRARY_PATH=`pwd`${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
Martin v. Löwis2389c412003-10-31 15:42:07 +0000890 INSTSONAME="$LDLIBRARY".$SOVERSION
Martin v. Löwis1142de32002-03-29 16:28:31 +0000891 ;;
Charles-François Natali3de8c732011-07-24 22:33:35 +0200892 Linux*|GNU*|NetBSD*|FreeBSD*|DragonFly*|OpenBSD*)
Martin v. Löwis1142de32002-03-29 16:28:31 +0000893 LDLIBRARY='libpython$(VERSION).so'
894 BLDLIBRARY='-L. -lpython$(VERSION)'
doko@ubuntu.com9ba90c92014-05-07 04:41:26 +0200895 RUNSHARED=LD_LIBRARY_PATH=`pwd`${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
Hye-Shik Chang33761492004-10-26 09:53:46 +0000896 case $ac_sys_system in
897 FreeBSD*)
898 SOVERSION=`echo $SOVERSION|cut -d "." -f 1`
899 ;;
900 esac
Martin v. Löwis1142de32002-03-29 16:28:31 +0000901 INSTSONAME="$LDLIBRARY".$SOVERSION
902 ;;
903 hp*|HP*)
Neal Norwitz58e28882006-05-19 07:00:58 +0000904 case `uname -m` in
905 ia64)
906 LDLIBRARY='libpython$(VERSION).so'
907 ;;
908 *)
909 LDLIBRARY='libpython$(VERSION).sl'
910 ;;
911 esac
Martin v. Löwis1142de32002-03-29 16:28:31 +0000912 BLDLIBRARY='-Wl,+b,$(LIBDIR) -L. -lpython$(VERSION)'
doko@ubuntu.com9ba90c92014-05-07 04:41:26 +0200913 RUNSHARED=SHLIB_PATH=`pwd`${SHLIB_PATH:+:${SHLIB_PATH}}
Martin v. Löwis1142de32002-03-29 16:28:31 +0000914 ;;
915 OSF*)
916 LDLIBRARY='libpython$(VERSION).so'
Neal Norwitz671b9e32006-01-09 07:07:12 +0000917 BLDLIBRARY='-rpath $(LIBDIR) -L. -lpython$(VERSION)'
doko@ubuntu.com9ba90c92014-05-07 04:41:26 +0200918 RUNSHARED=LD_LIBRARY_PATH=`pwd`${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
Martin v. Löwis1142de32002-03-29 16:28:31 +0000919 ;;
Martin v. Löwisf90ae202002-06-11 06:22:31 +0000920 atheos*)
921 LDLIBRARY='libpython$(VERSION).so'
922 BLDLIBRARY='-L. -lpython$(VERSION)'
923 RUNSHARED=DLL_PATH=`pwd`:${DLL_PATH:-/atheos/sys/libs:/atheos/autolnk/lib}
924 ;;
Ronald Oussoren79f90492009-01-02 10:44:46 +0000925 Darwin*)
926 LDLIBRARY='libpython$(VERSION).dylib'
927 BLDLIBRARY='-L. -lpython$(VERSION)'
doko@ubuntu.com9ba90c92014-05-07 04:41:26 +0200928 RUNSHARED=DYLD_LIBRARY_PATH=`pwd`${DYLD_LIBRARY_PATH:+:${DYLD_LIBRARY_PATH}}
Ronald Oussoren79f90492009-01-02 10:44:46 +0000929 ;;
Antoine Pitrouaabdceb2010-09-10 20:03:17 +0000930 AIX*)
931 LDLIBRARY='libpython$(VERSION).so'
doko@ubuntu.com9ba90c92014-05-07 04:41:26 +0200932 RUNSHARED=LIBPATH=`pwd`${LIBPATH:+:${LIBPATH}}
Antoine Pitrouaabdceb2010-09-10 20:03:17 +0000933 ;;
Ronald Oussoren79f90492009-01-02 10:44:46 +0000934
Martin v. Löwis1142de32002-03-29 16:28:31 +0000935 esac
Jason Tishler30765592003-09-04 11:04:06 +0000936else # shared is disabled
937 case $ac_sys_system in
938 CYGWIN*)
939 BLDLIBRARY='$(LIBRARY)'
940 LDLIBRARY='libpython$(VERSION).dll.a'
941 ;;
942 esac
Martin v. Löwis1142de32002-03-29 16:28:31 +0000943fi
944
doko@python.orgd65e2ba2013-01-31 23:52:03 +0100945if test "$cross_compiling" = yes; then
946 RUNSHARED=
947fi
948
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000949AC_MSG_RESULT($LDLIBRARY)
950
Guido van Rossum627b2d71993-12-24 10:39:16 +0000951AC_PROG_RANLIB
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000952AC_SUBST(AR)
doko@python.orgd65e2ba2013-01-31 23:52:03 +0100953AC_CHECK_TOOLS(AR, ar aal, ar)
Neil Schemenauera42c8272001-03-31 00:01:55 +0000954
Tarek Ziadé99f660a2009-05-07 21:20:34 +0000955# tweak ARFLAGS only if the user didn't set it on the command line
956AC_SUBST(ARFLAGS)
957if test -z "$ARFLAGS"
958then
959 ARFLAGS="rc"
960fi
961
Martin v. Löwisdea59e52006-01-05 10:00:36 +0000962AC_SUBST(SVNVERSION)
Martin v. Löwisff600232006-04-03 19:12:32 +0000963AC_CHECK_PROG(SVNVERSION, svnversion, found, not-found)
Martin v. Löwisc5bf5a02006-01-05 10:33:59 +0000964if test $SVNVERSION = found
965then
966 SVNVERSION="svnversion \$(srcdir)"
967else
Benjamin Petersone5afa3b2009-05-23 19:24:37 +0000968 SVNVERSION="echo Unversioned directory"
Martin v. Löwisc5bf5a02006-01-05 10:33:59 +0000969fi
Martin v. Löwisdea59e52006-01-05 10:00:36 +0000970
Trent Nelsond86ceec2012-10-16 09:42:45 -0400971AC_SUBST(BASECPPFLAGS)
Trent Nelsonabf20512012-10-17 04:32:49 -0400972if test "$abs_srcdir" != "$abs_builddir"; then
Trent Nelsond86ceec2012-10-16 09:42:45 -0400973 # If we're building out-of-tree make sure Include (in the current dir)
974 # gets picked up before its $srcdir counterpart in order for Python-ast.h
975 # and graminit.h to get picked up from the correct directory.
976 # (A side effect of this is that these resources will automatically be
977 # regenerated when building out-of-tree, regardless of whether or not
978 # the $srcdir counterpart is up-to-date. This is an acceptable trade
979 # off.)
980 BASECPPFLAGS="-IInclude"
981else
982 BASECPPFLAGS=""
983fi
984
Georg Brandl3a5508e2011-03-06 10:42:21 +0100985AC_SUBST(HGVERSION)
986AC_SUBST(HGTAG)
987AC_SUBST(HGBRANCH)
988AC_CHECK_PROG(HAS_HG, hg, found, not-found)
989if test $HAS_HG = found
990then
991 HGVERSION="hg id -i \$(srcdir)"
992 HGTAG="hg id -t \$(srcdir)"
993 HGBRANCH="hg id -b \$(srcdir)"
994else
995 HGVERSION=""
996 HGTAG=""
997 HGBRANCH=""
998fi
999
Neil Schemenauera42c8272001-03-31 00:01:55 +00001000case $MACHDEP in
Neil Schemenaueraf5567f2001-10-21 22:32:04 +00001001bsdos*|hp*|HP*)
1002 # install -d does not work on BSDI or HP-UX
Neil Schemenauera42c8272001-03-31 00:01:55 +00001003 if test -z "$INSTALL"
1004 then
1005 INSTALL="${srcdir}/install-sh -c"
1006 fi
1007esac
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00001008AC_PROG_INSTALL
Trent Nelsonf6407a12012-08-30 14:56:13 +00001009AC_PROG_MKDIR_P
Guido van Rossumb418f891996-07-30 18:06:02 +00001010
Guido van Rossumec95c7b1998-08-04 17:59:56 +00001011# Not every filesystem supports hard links
1012AC_SUBST(LN)
1013if test -z "$LN" ; then
1014 case $ac_sys_system in
1015 BeOS*) LN="ln -s";;
Guido van Rossumaef734b2001-01-10 21:09:12 +00001016 CYGWIN*) LN="ln -s";;
Martin v. Löwisf90ae202002-06-11 06:22:31 +00001017 atheos*) LN="ln -s";;
Guido van Rossumec95c7b1998-08-04 17:59:56 +00001018 *) LN=ln;;
1019 esac
1020fi
1021
Fred Drake9f715822001-07-11 06:27:00 +00001022# Check for --with-pydebug
1023AC_MSG_CHECKING(for --with-pydebug)
1024AC_ARG_WITH(pydebug,
Matthias Klose22520ea2010-05-08 10:14:46 +00001025 AS_HELP_STRING([--with-pydebug], [build with Py_DEBUG defined]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00001026[
Fred Drake9f715822001-07-11 06:27:00 +00001027if test "$withval" != no
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001028then
1029 AC_DEFINE(Py_DEBUG, 1,
1030 [Define if you want to build an interpreter with many run-time checks.])
1031 AC_MSG_RESULT(yes);
1032 Py_DEBUG='true'
Fred Drake9f715822001-07-11 06:27:00 +00001033else AC_MSG_RESULT(no); Py_DEBUG='false'
1034fi],
1035[AC_MSG_RESULT(no)])
1036
Skip Montanarodecc6a42003-01-01 20:07:49 +00001037# XXX Shouldn't the code above that fiddles with BASECFLAGS and OPT be
1038# merged with this chunk of code?
1039
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00001040# Optimizer/debugger flags
Skip Montanarodecc6a42003-01-01 20:07:49 +00001041# ------------------------
1042# (The following bit of code is complicated enough - please keep things
1043# indented properly. Just pretend you're editing Python code. ;-)
1044
1045# There are two parallel sets of case statements below, one that checks to
1046# see if OPT was set and one that does BASECFLAGS setting based upon
1047# compiler and platform. BASECFLAGS tweaks need to be made even if the
1048# user set OPT.
1049
1050# tweak OPT based on compiler and platform, only if the user didn't set
1051# it on the command line
Guido van Rossumb418f891996-07-30 18:06:02 +00001052AC_SUBST(OPT)
Benjamin Petersond4b721b2010-03-23 20:58:37 +00001053if test "${OPT-unset}" = "unset"
Guido van Rossumb418f891996-07-30 18:06:02 +00001054then
Skip Montanarodecc6a42003-01-01 20:07:49 +00001055 case $GCC in
1056 yes)
Skip Montanaro288a5be2006-04-13 02:00:56 +00001057 if test "$CC" != 'g++' ; then
1058 STRICT_PROTO="-Wstrict-prototypes"
1059 fi
Guido van Rossum7c862f82007-12-13 20:50:10 +00001060 # For gcc 4.x we need to use -fwrapv so lets check if its supported
1061 if "$CC" -v --help 2>/dev/null |grep -- -fwrapv > /dev/null; then
1062 WRAP="-fwrapv"
1063 fi
Stefan Krah503e5e12011-09-14 15:19:42 +02001064
1065 # Clang also needs -fwrapv
Stefan Krah2bc1e8f2011-12-08 22:26:06 +01001066 case $CC in
1067 *clang*) WRAP="-fwrapv"
1068 ;;
1069 esac
Stefan Krah503e5e12011-09-14 15:19:42 +02001070
Skip Montanarodecc6a42003-01-01 20:07:49 +00001071 case $ac_cv_prog_cc_g in
Guido van Rossum2242f2f2001-04-11 20:58:20 +00001072 yes)
Fred Drake9f715822001-07-11 06:27:00 +00001073 if test "$Py_DEBUG" = 'true' ; then
1074 # Optimization messes up debuggers, so turn it off for
1075 # debug builds.
Mark Dickinsond2f3e3f2010-05-05 22:23:58 +00001076 OPT="-g -O0 -Wall $STRICT_PROTO"
Fred Drake9f715822001-07-11 06:27:00 +00001077 else
Guido van Rossum7c862f82007-12-13 20:50:10 +00001078 OPT="-g $WRAP -O3 -Wall $STRICT_PROTO"
Skip Montanarodecc6a42003-01-01 20:07:49 +00001079 fi
1080 ;;
Guido van Rossum2242f2f2001-04-11 20:58:20 +00001081 *)
Skip Montanaro288a5be2006-04-13 02:00:56 +00001082 OPT="-O3 -Wall $STRICT_PROTO"
Skip Montanarodecc6a42003-01-01 20:07:49 +00001083 ;;
Fred Drake9f715822001-07-11 06:27:00 +00001084 esac
Martin v. Löwis21ee4092002-09-30 16:19:48 +00001085 case $ac_sys_system in
Skip Montanarodecc6a42003-01-01 20:07:49 +00001086 SCO_SV*) OPT="$OPT -m486 -DSCO5"
1087 ;;
1088 esac
Fred Drake9f715822001-07-11 06:27:00 +00001089 ;;
Skip Montanarodecc6a42003-01-01 20:07:49 +00001090
Guido van Rossum2242f2f2001-04-11 20:58:20 +00001091 *)
Skip Montanarodecc6a42003-01-01 20:07:49 +00001092 OPT="-O"
1093 ;;
Guido van Rossum2242f2f2001-04-11 20:58:20 +00001094 esac
Guido van Rossum4e8af441994-08-19 15:33:54 +00001095fi
Guido van Rossum627b2d71993-12-24 10:39:16 +00001096
Skip Montanarodecc6a42003-01-01 20:07:49 +00001097AC_SUBST(BASECFLAGS)
Ronald Oussoren5640ce22008-06-05 12:58:24 +00001098
1099# The -arch flags for universal builds on OSX
1100UNIVERSAL_ARCH_FLAGS=
1101AC_SUBST(UNIVERSAL_ARCH_FLAGS)
1102
Skip Montanarodecc6a42003-01-01 20:07:49 +00001103# tweak BASECFLAGS based on compiler and platform
1104case $GCC in
1105yes)
Martin v. Löwis70fedcd2003-07-07 21:26:19 +00001106 # Python violates C99 rules, by casting between incompatible
1107 # pointer types. GCC may generate bad code as a result of that,
1108 # so use -fno-strict-aliasing if supported.
1109 AC_MSG_CHECKING(whether $CC accepts -fno-strict-aliasing)
1110 ac_save_cc="$CC"
1111 CC="$CC -fno-strict-aliasing"
Alexandre Vassalotti00900892009-07-17 05:26:39 +00001112 AC_CACHE_VAL(ac_cv_no_strict_aliasing_ok,
Matthias Klosec511b472010-05-08 11:01:39 +00001113 AC_COMPILE_IFELSE(
Mark Dickinson5e13e292010-05-11 08:55:06 +00001114 [AC_LANG_PROGRAM([[]], [[]])],
Matthias Klosec511b472010-05-08 11:01:39 +00001115 [ac_cv_no_strict_aliasing_ok=yes],
1116 [ac_cv_no_strict_aliasing_ok=no]))
Martin v. Löwis70fedcd2003-07-07 21:26:19 +00001117 CC="$ac_save_cc"
1118 AC_MSG_RESULT($ac_cv_no_strict_aliasing_ok)
1119 if test $ac_cv_no_strict_aliasing_ok = yes
1120 then
1121 BASECFLAGS="$BASECFLAGS -fno-strict-aliasing"
1122 fi
Mark Dickinson65134662008-04-25 16:11:04 +00001123
1124 # if using gcc on alpha, use -mieee to get (near) full IEEE 754
1125 # support. Without this, treatment of subnormals doesn't follow
1126 # the standard.
doko@python.orgd65e2ba2013-01-31 23:52:03 +01001127 case $host in
Mark Dickinson65134662008-04-25 16:11:04 +00001128 alpha*)
1129 BASECFLAGS="$BASECFLAGS -mieee"
1130 ;;
1131 esac
1132
Skip Montanarodecc6a42003-01-01 20:07:49 +00001133 case $ac_sys_system in
1134 SCO_SV*)
1135 BASECFLAGS="$BASECFLAGS -m486 -DSCO5"
1136 ;;
1137 # is there any other compiler on Darwin besides gcc?
1138 Darwin*)
Jeffrey Yasskin1b4e45b2008-03-17 14:40:53 +00001139 # -Wno-long-double, -no-cpp-precomp, and -mno-fused-madd
1140 # used to be here, but non-Apple gcc doesn't accept them.
Ronald Oussorena55af9a2010-01-17 16:25:57 +00001141 if test "${CC}" = gcc
1142 then
1143 AC_MSG_CHECKING(which compiler should be used)
1144 case "${UNIVERSALSDK}" in
1145 */MacOSX10.4u.sdk)
1146 # Build using 10.4 SDK, force usage of gcc when the
1147 # compiler is gcc, otherwise the user will get very
1148 # confusing error messages when building on OSX 10.6
1149 CC=gcc-4.0
1150 CPP=cpp-4.0
1151 ;;
1152 esac
1153 AC_MSG_RESULT($CC)
Ronald Oussoren988117f2006-04-29 11:31:35 +00001154 fi
1155
Benjamin Peterson4347c442008-07-17 15:59:24 +00001156 # Calculate the right deployment target for this build.
1157 #
Ned Deilyc40b9032014-06-25 13:48:46 -07001158 cur_target_major=`sw_vers -productVersion | \
1159 sed 's/\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'`
1160 cur_target_minor=`sw_vers -productVersion | \
1161 sed 's/\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'`
1162 cur_target="${cur_target_major}.${cur_target_minor}"
1163 if test ${cur_target_major} -eq 10 && \
1164 test ${cur_target_minor} -ge 3
1165 then
Benjamin Peterson4347c442008-07-17 15:59:24 +00001166 cur_target=10.3
Ronald Oussoren25967582009-09-06 10:00:26 +00001167 if test ${enable_universalsdk}; then
1168 if test "${UNIVERSAL_ARCHS}" = "all"; then
1169 # Ensure that the default platform for a
1170 # 4-way universal build is OSX 10.5,
1171 # that's the first OS release where
1172 # 4-way builds make sense.
1173 cur_target='10.5'
Ronald Oussoren23d92532009-09-07 06:12:00 +00001174
1175 elif test "${UNIVERSAL_ARCHS}" = "3-way"; then
1176 cur_target='10.5'
1177
1178 elif test "${UNIVERSAL_ARCHS}" = "intel"; then
1179 cur_target='10.5'
1180
1181 elif test "${UNIVERSAL_ARCHS}" = "64-bit"; then
1182 cur_target='10.5'
Ronald Oussoren25967582009-09-06 10:00:26 +00001183 fi
1184 else
Ronald Oussorenbc0e83c2010-02-11 13:26:54 +00001185 if test `/usr/bin/arch` = "i386"; then
Ronald Oussoren25967582009-09-06 10:00:26 +00001186 # On Intel macs default to a deployment
1187 # target of 10.4, that's the first OSX
1188 # release with Intel support.
1189 cur_target="10.4"
1190 fi
1191 fi
Benjamin Peterson4347c442008-07-17 15:59:24 +00001192 fi
1193 CONFIGURE_MACOSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET-${cur_target}}
1194
1195 # Make sure that MACOSX_DEPLOYMENT_TARGET is set in the
1196 # environment with a value that is the same as what we'll use
1197 # in the Makefile to ensure that we'll get the same compiler
1198 # environment during configure and build time.
1199 MACOSX_DEPLOYMENT_TARGET="$CONFIGURE_MACOSX_DEPLOYMENT_TARGET"
1200 export MACOSX_DEPLOYMENT_TARGET
1201 EXPORT_MACOSX_DEPLOYMENT_TARGET=''
1202
Ronald Oussorena55af9a2010-01-17 16:25:57 +00001203 if test "${enable_universalsdk}"; then
1204 UNIVERSAL_ARCH_FLAGS=""
1205 if test "$UNIVERSAL_ARCHS" = "32-bit" ; then
1206 UNIVERSAL_ARCH_FLAGS="-arch ppc -arch i386"
1207 ARCH_RUN_32BIT=""
Ronald Oussoren75912852010-04-08 08:13:31 +00001208 LIPO_32BIT_FLAGS=""
Ronald Oussorena55af9a2010-01-17 16:25:57 +00001209
1210 elif test "$UNIVERSAL_ARCHS" = "64-bit" ; then
1211 UNIVERSAL_ARCH_FLAGS="-arch ppc64 -arch x86_64"
1212 LIPO_32BIT_FLAGS=""
1213 ARCH_RUN_32BIT="true"
1214
1215 elif test "$UNIVERSAL_ARCHS" = "all" ; then
1216 UNIVERSAL_ARCH_FLAGS="-arch i386 -arch ppc -arch ppc64 -arch x86_64"
1217 LIPO_32BIT_FLAGS="-extract ppc7400 -extract i386"
Ronald Oussoren92397ce2010-01-17 19:32:00 +00001218 ARCH_RUN_32BIT="/usr/bin/arch -i386 -ppc"
Ronald Oussorena55af9a2010-01-17 16:25:57 +00001219
1220 elif test "$UNIVERSAL_ARCHS" = "intel" ; then
1221 UNIVERSAL_ARCH_FLAGS="-arch i386 -arch x86_64"
1222 LIPO_32BIT_FLAGS="-extract i386"
Ronald Oussoren92397ce2010-01-17 19:32:00 +00001223 ARCH_RUN_32BIT="/usr/bin/arch -i386"
Ronald Oussorena55af9a2010-01-17 16:25:57 +00001224
1225 elif test "$UNIVERSAL_ARCHS" = "3-way" ; then
1226 UNIVERSAL_ARCH_FLAGS="-arch i386 -arch ppc -arch x86_64"
1227 LIPO_32BIT_FLAGS="-extract ppc7400 -extract i386"
Ronald Oussoren9922f172010-02-11 13:19:34 +00001228 ARCH_RUN_32BIT="/usr/bin/arch -i386 -ppc"
Ronald Oussorena55af9a2010-01-17 16:25:57 +00001229
1230 else
1231 AC_MSG_ERROR([proper usage is --with-universal-arch=32-bit|64-bit|all|intel|3-way])
1232
1233 fi
1234
1235
Ronald Oussoren974eb5e2010-04-18 17:59:37 +00001236 CFLAGS="${UNIVERSAL_ARCH_FLAGS} ${CFLAGS}"
1237 if test "${UNIVERSALSDK}" != "/"
1238 then
1239 CPPFLAGS="-isysroot ${UNIVERSALSDK} ${CPPFLAGS}"
1240 LDFLAGS="-isysroot ${UNIVERSALSDK} ${LDFLAGS}"
1241 CFLAGS="-isysroot ${UNIVERSALSDK} ${CFLAGS}"
Ronald Oussorena55af9a2010-01-17 16:25:57 +00001242 fi
1243
1244 fi
1245
1246
Skip Montanarodecc6a42003-01-01 20:07:49 +00001247 ;;
Neal Norwitzdedeeaa2006-03-31 06:54:45 +00001248 OSF*)
1249 BASECFLAGS="$BASECFLAGS -mieee"
1250 ;;
Skip Montanarodecc6a42003-01-01 20:07:49 +00001251 esac
1252 ;;
1253
1254*)
1255 case $ac_sys_system in
1256 OpenUNIX*|UnixWare*)
1257 BASECFLAGS="$BASECFLAGS -K pentium,host,inline,loop_unroll,alloca "
1258 ;;
Neal Norwitzb44f1652003-05-26 14:11:55 +00001259 OSF*)
1260 BASECFLAGS="$BASECFLAGS -ieee -std"
1261 ;;
Skip Montanarodecc6a42003-01-01 20:07:49 +00001262 SCO_SV*)
1263 BASECFLAGS="$BASECFLAGS -belf -Ki486 -DSCO5"
1264 ;;
1265 esac
1266 ;;
1267esac
1268
Fred Drakee1ceaa02001-12-04 20:55:47 +00001269if test "$Py_DEBUG" = 'true'; then
1270 :
1271else
1272 OPT="-DNDEBUG $OPT"
1273fi
1274
Guido van Rossum6f2260e1996-09-09 16:21:03 +00001275if test "$ac_arch_flags"
Guido van Rossumc5a39031996-07-31 17:35:03 +00001276then
Skip Montanarodecc6a42003-01-01 20:07:49 +00001277 BASECFLAGS="$BASECFLAGS $ac_arch_flags"
Guido van Rossumc5a39031996-07-31 17:35:03 +00001278fi
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001279
Neal Norwitz020c46a2006-01-07 21:39:28 +00001280# disable check for icc since it seems to pass, but generates a warning
1281if test "$CC" = icc
1282then
1283 ac_cv_opt_olimit_ok=no
1284fi
1285
Guido van Rossum91922671997-10-09 20:24:13 +00001286AC_MSG_CHECKING(whether $CC accepts -OPT:Olimit=0)
1287AC_CACHE_VAL(ac_cv_opt_olimit_ok,
1288[ac_save_cc="$CC"
1289CC="$CC -OPT:Olimit=0"
Matthias Klosec511b472010-05-08 11:01:39 +00001290AC_COMPILE_IFELSE(
Mark Dickinson5e13e292010-05-11 08:55:06 +00001291 [AC_LANG_PROGRAM([[]], [[]])],
Matthias Klosec511b472010-05-08 11:01:39 +00001292 [ac_cv_opt_olimit_ok=yes],
1293 [ac_cv_opt_olimit_ok=no]
Gregory P. Smithec3b8bd2009-11-01 21:02:52 +00001294 )
Guido van Rossum91922671997-10-09 20:24:13 +00001295CC="$ac_save_cc"])
1296AC_MSG_RESULT($ac_cv_opt_olimit_ok)
Guido van Rossum2efa34b1997-10-23 17:43:11 +00001297if test $ac_cv_opt_olimit_ok = yes; then
Guido van Rossum5839e582000-10-09 19:52:35 +00001298 case $ac_sys_system in
Skip Montanarodecc6a42003-01-01 20:07:49 +00001299 # XXX is this branch needed? On MacOSX 10.2.2 the result of the
1300 # olimit_ok test is "no". Is it "yes" in some other Darwin-esque
1301 # environment?
1302 Darwin*)
1303 ;;
Trent Nelson34562e12012-10-17 18:01:12 -04001304 # XXX thankfully this useless troublemaker of a flag has been
1305 # eradicated in the 3.x line. For now, make sure it isn't picked
1306 # up by any of our other platforms that use CC.
1307 AIX*|SunOS*|HP-UX*|IRIX*)
1308 ;;
Skip Montanarodecc6a42003-01-01 20:07:49 +00001309 *)
1310 BASECFLAGS="$BASECFLAGS -OPT:Olimit=0"
1311 ;;
Guido van Rossum5839e582000-10-09 19:52:35 +00001312 esac
Guido van Rossumf8678121998-07-07 21:05:09 +00001313else
1314 AC_MSG_CHECKING(whether $CC accepts -Olimit 1500)
1315 AC_CACHE_VAL(ac_cv_olimit_ok,
1316 [ac_save_cc="$CC"
1317 CC="$CC -Olimit 1500"
Matthias Klosec511b472010-05-08 11:01:39 +00001318 AC_COMPILE_IFELSE(
Mark Dickinson5e13e292010-05-11 08:55:06 +00001319 [AC_LANG_PROGRAM([[]], [[]])],
Matthias Klosec511b472010-05-08 11:01:39 +00001320 [ac_cv_olimit_ok=yes],
1321 [ac_cv_olimit_ok=no]
Gregory P. Smithec3b8bd2009-11-01 21:02:52 +00001322 )
Guido van Rossumf8678121998-07-07 21:05:09 +00001323 CC="$ac_save_cc"])
1324 AC_MSG_RESULT($ac_cv_olimit_ok)
1325 if test $ac_cv_olimit_ok = yes; then
Stefan Krah67473262012-11-29 00:17:05 +01001326 case $ac_sys_system in
1327 # Issue #16534: On HP-UX ac_cv_olimit_ok=yes is a false positive.
1328 HP-UX*)
1329 ;;
1330 *)
1331 BASECFLAGS="$BASECFLAGS -Olimit 1500"
1332 ;;
1333 esac
Guido van Rossumf8678121998-07-07 21:05:09 +00001334 fi
Guido van Rossum201afe51997-05-14 21:14:44 +00001335fi
Guido van Rossumf8678121998-07-07 21:05:09 +00001336
Martin v. Löwisaac13162006-10-19 10:58:46 +00001337# Check whether GCC supports PyArg_ParseTuple format
1338if test "$GCC" = "yes"
1339then
1340 AC_MSG_CHECKING(whether gcc supports ParseTuple __format__)
1341 save_CFLAGS=$CFLAGS
Benjamin Petersonc8759662013-05-11 13:00:05 -05001342 CFLAGS="$CFLAGS -Werror -Wformat"
Matthias Klosec511b472010-05-08 11:01:39 +00001343 AC_COMPILE_IFELSE([
1344 AC_LANG_PROGRAM([[void f(char*,...)__attribute((format(PyArg_ParseTuple, 1, 2)));]], [[]])
1345 ],[
1346 AC_DEFINE(HAVE_ATTRIBUTE_FORMAT_PARSETUPLE, 1,
1347 [Define if GCC supports __attribute__((format(PyArg_ParseTuple, 2, 3)))])
1348 AC_MSG_RESULT(yes)
1349 ],[
1350 AC_MSG_RESULT(no)
1351 ])
Martin v. Löwisc1d75972006-10-19 16:01:37 +00001352 CFLAGS=$save_CFLAGS
Martin v. Löwisaac13162006-10-19 10:58:46 +00001353fi
1354
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00001355# On some compilers, pthreads are available without further options
1356# (e.g. MacOS X). On some of these systems, the compiler will not
1357# complain if unaccepted options are passed (e.g. gcc on Mac OS X).
1358# So we have to see first whether pthreads are available without
1359# options before we can check whether -Kpthread improves anything.
1360AC_MSG_CHECKING(whether pthreads are available without options)
1361AC_CACHE_VAL(ac_cv_pthread_is_default,
Matthias Klosec511b472010-05-08 11:01:39 +00001362[AC_RUN_IFELSE([AC_LANG_SOURCE([[
Stefan Krahae66ca62012-11-22 22:36:57 +01001363#include <stdio.h>
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00001364#include <pthread.h>
1365
1366void* routine(void* p){return NULL;}
1367
1368int main(){
1369 pthread_t p;
1370 if(pthread_create(&p,NULL,routine,NULL)!=0)
1371 return 1;
Jack Jansen4f8d0542002-03-08 13:43:01 +00001372 (void)pthread_detach(p);
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00001373 return 0;
1374}
Matthias Klosec511b472010-05-08 11:01:39 +00001375]])],[
Skip Montanarod8d39a02003-07-10 20:44:10 +00001376 ac_cv_pthread_is_default=yes
1377 ac_cv_kthread=no
1378 ac_cv_pthread=no
Matthias Klosec511b472010-05-08 11:01:39 +00001379],[ac_cv_pthread_is_default=no],[ac_cv_pthread_is_default=no])
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00001380])
1381AC_MSG_RESULT($ac_cv_pthread_is_default)
1382
1383
1384if test $ac_cv_pthread_is_default = yes
1385then
1386 ac_cv_kpthread=no
1387else
Martin v. Löwis130fb172001-07-19 11:00:41 +00001388# -Kpthread, if available, provides the right #defines
1389# and linker options to make pthread_create available
Martin v. Löwis260aecc2001-10-07 08:14:41 +00001390# Some compilers won't report that they do not support -Kpthread,
1391# so we need to run a program to see whether it really made the
1392# function available.
Martin v. Löwis130fb172001-07-19 11:00:41 +00001393AC_MSG_CHECKING(whether $CC accepts -Kpthread)
1394AC_CACHE_VAL(ac_cv_kpthread,
1395[ac_save_cc="$CC"
1396CC="$CC -Kpthread"
Matthias Klosec511b472010-05-08 11:01:39 +00001397AC_RUN_IFELSE([AC_LANG_SOURCE([[
Stefan Krahae66ca62012-11-22 22:36:57 +01001398#include <stdio.h>
Martin v. Löwis260aecc2001-10-07 08:14:41 +00001399#include <pthread.h>
1400
1401void* routine(void* p){return NULL;}
1402
1403int main(){
1404 pthread_t p;
1405 if(pthread_create(&p,NULL,routine,NULL)!=0)
1406 return 1;
Jack Jansen4f8d0542002-03-08 13:43:01 +00001407 (void)pthread_detach(p);
Martin v. Löwis260aecc2001-10-07 08:14:41 +00001408 return 0;
1409}
Matthias Klosec511b472010-05-08 11:01:39 +00001410]])],[ac_cv_kpthread=yes],[ac_cv_kpthread=no],[ac_cv_kpthread=no])
Martin v. Löwis130fb172001-07-19 11:00:41 +00001411CC="$ac_save_cc"])
Martin v. Löwis130fb172001-07-19 11:00:41 +00001412AC_MSG_RESULT($ac_cv_kpthread)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00001413fi
Martin v. Löwis130fb172001-07-19 11:00:41 +00001414
Skip Montanarod8d39a02003-07-10 20:44:10 +00001415if test $ac_cv_kpthread = no -a $ac_cv_pthread_is_default = no
Martin v. Löwis5f433f02003-05-05 05:05:30 +00001416then
1417# -Kthread, if available, provides the right #defines
1418# and linker options to make pthread_create available
1419# Some compilers won't report that they do not support -Kthread,
1420# so we need to run a program to see whether it really made the
1421# function available.
1422AC_MSG_CHECKING(whether $CC accepts -Kthread)
1423AC_CACHE_VAL(ac_cv_kthread,
1424[ac_save_cc="$CC"
1425CC="$CC -Kthread"
Matthias Klosec511b472010-05-08 11:01:39 +00001426AC_RUN_IFELSE([AC_LANG_SOURCE([[
Stefan Krahae66ca62012-11-22 22:36:57 +01001427#include <stdio.h>
Martin v. Löwis5f433f02003-05-05 05:05:30 +00001428#include <pthread.h>
1429
1430void* routine(void* p){return NULL;}
1431
1432int main(){
1433 pthread_t p;
1434 if(pthread_create(&p,NULL,routine,NULL)!=0)
1435 return 1;
1436 (void)pthread_detach(p);
1437 return 0;
1438}
Matthias Klosec511b472010-05-08 11:01:39 +00001439]])],[ac_cv_kthread=yes],[ac_cv_kthread=no],[ac_cv_kthread=no])
Martin v. Löwis5f433f02003-05-05 05:05:30 +00001440CC="$ac_save_cc"])
1441AC_MSG_RESULT($ac_cv_kthread)
1442fi
1443
Skip Montanarod8d39a02003-07-10 20:44:10 +00001444if test $ac_cv_kthread = no -a $ac_cv_pthread_is_default = no
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00001445then
1446# -pthread, if available, provides the right #defines
1447# and linker options to make pthread_create available
1448# Some compilers won't report that they do not support -pthread,
1449# so we need to run a program to see whether it really made the
1450# function available.
1451AC_MSG_CHECKING(whether $CC accepts -pthread)
doko@python.orgfa3f9a32013-01-25 15:32:31 +01001452AC_CACHE_VAL(ac_cv_pthread,
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00001453[ac_save_cc="$CC"
1454CC="$CC -pthread"
Matthias Klosec511b472010-05-08 11:01:39 +00001455AC_RUN_IFELSE([AC_LANG_SOURCE([[
Stefan Krahae66ca62012-11-22 22:36:57 +01001456#include <stdio.h>
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00001457#include <pthread.h>
1458
1459void* routine(void* p){return NULL;}
1460
1461int main(){
1462 pthread_t p;
1463 if(pthread_create(&p,NULL,routine,NULL)!=0)
1464 return 1;
1465 (void)pthread_detach(p);
1466 return 0;
1467}
Matthias Klosec511b472010-05-08 11:01:39 +00001468]])],[ac_cv_pthread=yes],[ac_cv_pthread=no],[ac_cv_pthread=no])
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00001469CC="$ac_save_cc"])
1470AC_MSG_RESULT($ac_cv_pthread)
1471fi
1472
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001473# If we have set a CC compiler flag for thread support then
1474# check if it works for CXX, too.
1475ac_cv_cxx_thread=no
1476if test ! -z "$CXX"
1477then
1478AC_MSG_CHECKING(whether $CXX also accepts flags for thread support)
1479ac_save_cxx="$CXX"
1480
1481if test "$ac_cv_kpthread" = "yes"
1482then
Martin v. Löwis519adae2003-09-20 10:47:47 +00001483 CXX="$CXX -Kpthread"
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001484 ac_cv_cxx_thread=yes
1485elif test "$ac_cv_kthread" = "yes"
1486then
1487 CXX="$CXX -Kthread"
1488 ac_cv_cxx_thread=yes
1489elif test "$ac_cv_pthread" = "yes"
1490then
1491 CXX="$CXX -pthread"
1492 ac_cv_cxx_thread=yes
1493fi
1494
1495if test $ac_cv_cxx_thread = yes
1496then
1497 echo 'void foo();int main(){foo();}void foo(){}' > conftest.$ac_ext
1498 $CXX -c conftest.$ac_ext 2>&5
1499 if $CXX -o conftest$ac_exeext conftest.$ac_objext 2>&5 \
1500 && test -s conftest$ac_exeext && ./conftest$ac_exeext
1501 then
1502 ac_cv_cxx_thread=yes
1503 else
1504 ac_cv_cxx_thread=no
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001505 fi
1506 rm -fr conftest*
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001507fi
Brett Cannonc601e0f2004-11-07 01:24:12 +00001508AC_MSG_RESULT($ac_cv_cxx_thread)
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001509fi
Martin v. Löwis519adae2003-09-20 10:47:47 +00001510CXX="$ac_save_cxx"
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001511
Fred Drakece81d592000-07-09 14:39:29 +00001512dnl # check for ANSI or K&R ("traditional") preprocessor
1513dnl AC_MSG_CHECKING(for C preprocessor type)
Matthias Klosec511b472010-05-08 11:01:39 +00001514dnl AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Fred Drakece81d592000-07-09 14:39:29 +00001515dnl #define spam(name, doc) {#name, &name, #name "() -- " doc}
1516dnl int foo;
1517dnl struct {char *name; int *addr; char *doc;} desc = spam(foo, "something");
Matthias Klosec511b472010-05-08 11:01:39 +00001518dnl ]], [[;]])],[cpp_type=ansi],[AC_DEFINE(HAVE_OLD_CPP) cpp_type=traditional])
Fred Drakece81d592000-07-09 14:39:29 +00001519dnl AC_MSG_RESULT($cpp_type)
Guido van Rossum300fda71996-08-19 21:58:16 +00001520
Guido van Rossum627b2d71993-12-24 10:39:16 +00001521# checks for header files
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001522AC_HEADER_STDC
doko@ubuntu.comf27ec3e2014-04-17 20:11:19 +02001523AC_CHECK_HEADERS(asm/types.h conio.h direct.h dlfcn.h errno.h \
Martin v. Löwis0e8bd7e2006-06-10 12:23:46 +00001524fcntl.h grp.h \
doko@ubuntu.comf27ec3e2014-04-17 20:11:19 +02001525ieeefp.h io.h langinfo.h libintl.h poll.h process.h pthread.h \
Martin v. Löwis40e9aed2006-10-02 15:20:37 +00001526shadow.h signal.h stdint.h stropts.h termios.h thread.h \
Martin v. Löwis14e73b12003-01-01 09:51:12 +00001527unistd.h utime.h \
Christian Heimes0e9ab5f2008-03-21 23:49:44 +00001528sys/audioio.h sys/bsdtty.h sys/epoll.h sys/event.h sys/file.h sys/loadavg.h \
1529sys/lock.h sys/mkdev.h sys/modem.h \
Martin v. Löwis0e8bd7e2006-06-10 12:23:46 +00001530sys/param.h sys/poll.h sys/select.h sys/socket.h sys/statvfs.h sys/stat.h \
Martin v. Löwis8c255e42008-05-23 15:06:50 +00001531sys/termio.h sys/time.h \
Martin v. Löwis0e8bd7e2006-06-10 12:23:46 +00001532sys/times.h sys/types.h sys/un.h sys/utsname.h sys/wait.h pty.h libutil.h \
Martin v. Löwis0347a9a2006-10-27 07:06:52 +00001533sys/resource.h netpacket/packet.h sysexits.h bluetooth.h \
Christian Heimes3aa138f2013-06-18 13:25:24 +02001534bluetooth/bluetooth.h linux/tipc.h spawn.h util.h alloca.h)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001535AC_HEADER_DIRENT
Martin v. Löwisdbe3f762002-10-10 14:27:30 +00001536AC_HEADER_MAJOR
Guido van Rossum627b2d71993-12-24 10:39:16 +00001537
Martin v. Löwis11017b12006-01-14 18:12:57 +00001538# On Linux, netlink.h requires asm/types.h
1539AC_CHECK_HEADERS(linux/netlink.h,,,[
1540#ifdef HAVE_ASM_TYPES_H
1541#include <asm/types.h>
1542#endif
1543#ifdef HAVE_SYS_SOCKET_H
1544#include <sys/socket.h>
1545#endif
1546])
1547
Guido van Rossum627b2d71993-12-24 10:39:16 +00001548# checks for typedefs
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001549was_it_defined=no
1550AC_MSG_CHECKING(for clock_t in time.h)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001551AC_EGREP_HEADER(clock_t, time.h, was_it_defined=yes, [
1552 AC_DEFINE(clock_t, long, [Define to 'long' if <time.h> doesn't define.])
1553])
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001554AC_MSG_RESULT($was_it_defined)
1555
Neal Norwitz11690112002-07-30 01:08:28 +00001556# Check whether using makedev requires defining _OSF_SOURCE
1557AC_MSG_CHECKING(for makedev)
Matthias Klosec511b472010-05-08 11:01:39 +00001558AC_LINK_IFELSE([AC_LANG_PROGRAM([[
Jesus Cea616de772010-04-28 10:32:30 +00001559#if defined(MAJOR_IN_MKDEV)
1560#include <sys/mkdev.h>
1561#elif defined(MAJOR_IN_SYSMACROS)
1562#include <sys/sysmacros.h>
1563#else
1564#include <sys/types.h>
Matthias Klosec511b472010-05-08 11:01:39 +00001565#endif ]], [[ makedev(0, 0) ]])],
1566[ac_cv_has_makedev=yes],
1567[ac_cv_has_makedev=no])
Neal Norwitz11690112002-07-30 01:08:28 +00001568if test "$ac_cv_has_makedev" = "no"; then
1569 # we didn't link, try if _OSF_SOURCE will allow us to link
Matthias Klosec511b472010-05-08 11:01:39 +00001570 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
Neal Norwitz6eb37f02003-02-23 23:28:15 +00001571#define _OSF_SOURCE 1
1572#include <sys/types.h>
Matthias Klosec511b472010-05-08 11:01:39 +00001573 ]], [[ makedev(0, 0) ]])],
1574[ac_cv_has_makedev=yes],
1575[ac_cv_has_makedev=no])
Neal Norwitz11690112002-07-30 01:08:28 +00001576 if test "$ac_cv_has_makedev" = "yes"; then
1577 AC_DEFINE(_OSF_SOURCE, 1, [Define _OSF_SOURCE to get the makedev macro.])
1578 fi
1579fi
1580AC_MSG_RESULT($ac_cv_has_makedev)
1581if test "$ac_cv_has_makedev" = "yes"; then
1582 AC_DEFINE(HAVE_MAKEDEV, 1, [Define this if you have the makedev macro.])
1583fi
1584
Martin v. Löwis399a6892002-10-04 10:22:02 +00001585# Enabling LFS on Solaris (2.6 to 9) with gcc 2.95 triggers a bug in
1586# the system headers: If _XOPEN_SOURCE and _LARGEFILE_SOURCE are
1587# defined, but the compiler does not support pragma redefine_extname,
1588# and _LARGEFILE64_SOURCE is not defined, the headers refer to 64-bit
1589# structures (such as rlimit64) without declaring them. As a
1590# work-around, disable LFS on such configurations
1591
1592use_lfs=yes
1593AC_MSG_CHECKING(Solaris LFS bug)
Matthias Klosec511b472010-05-08 11:01:39 +00001594AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwis399a6892002-10-04 10:22:02 +00001595#define _LARGEFILE_SOURCE 1
1596#define _FILE_OFFSET_BITS 64
1597#include <sys/resource.h>
Matthias Klosec511b472010-05-08 11:01:39 +00001598]], [[struct rlimit foo;]])],[sol_lfs_bug=no],[sol_lfs_bug=yes])
Martin v. Löwis399a6892002-10-04 10:22:02 +00001599AC_MSG_RESULT($sol_lfs_bug)
1600if test "$sol_lfs_bug" = "yes"; then
1601 use_lfs=no
1602fi
1603
1604if test "$use_lfs" = "yes"; then
Guido van Rossum810cc512001-09-09 23:51:39 +00001605# Two defines needed to enable largefile support on various platforms
1606# These may affect some typedefs
Georg Brandl94800df2011-02-25 11:09:02 +00001607case $ac_sys_system/$ac_sys_release in
1608AIX*)
1609 AC_DEFINE(_LARGE_FILES, 1,
1610 [This must be defined on AIX systems to enable large file support.])
1611 ;;
1612esac
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001613AC_DEFINE(_LARGEFILE_SOURCE, 1,
1614[This must be defined on some systems to enable large file support.])
1615AC_DEFINE(_FILE_OFFSET_BITS, 64,
1616[This must be set to 64 on some systems to enable large file support.])
Martin v. Löwis399a6892002-10-04 10:22:02 +00001617fi
Guido van Rossum810cc512001-09-09 23:51:39 +00001618
Guido van Rossum300fda71996-08-19 21:58:16 +00001619# Add some code to confdefs.h so that the test for off_t works on SCO
1620cat >> confdefs.h <<\EOF
1621#if defined(SCO_DS)
1622#undef _OFF_T
1623#endif
1624EOF
1625
Guido van Rossumef2255b2000-03-10 22:30:29 +00001626# Type availability checks
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001627AC_TYPE_MODE_T
1628AC_TYPE_OFF_T
1629AC_TYPE_PID_T
Matthias Klosecbf54b12010-05-08 11:04:18 +00001630AC_DEFINE_UNQUOTED([RETSIGTYPE],[void],[assume C89 semantics that RETSIGTYPE is always void])
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001631AC_TYPE_SIZE_T
1632AC_TYPE_UID_T
Mark Dickinson17c50cd2012-12-02 13:13:56 +00001633
1634# There are two separate checks for each of the exact-width integer types we
1635# need. First we check whether the type is available using the usual
1636# AC_CHECK_TYPE macro with the default includes (which includes <inttypes.h>
1637# and <stdint.h> where available). We then also use the special type checks of
1638# the form AC_TYPE_UINT32_T, which in the case that uint32_t is not available
1639# directly, #define's uint32_t to be a suitable type.
1640
1641AC_CHECK_TYPE(uint32_t,
1642 AC_DEFINE(HAVE_UINT32_T, 1, [Define if your compiler provides uint32_t.]),,)
Mark Dickinsonefc82f72009-03-20 15:51:55 +00001643AC_TYPE_UINT32_T
Mark Dickinson17c50cd2012-12-02 13:13:56 +00001644
1645AC_CHECK_TYPE(uint64_t,
1646 AC_DEFINE(HAVE_UINT64_T, 1, [Define if your compiler provides uint64_t.]),,)
Mark Dickinsonefc82f72009-03-20 15:51:55 +00001647AC_TYPE_UINT64_T
Mark Dickinson17c50cd2012-12-02 13:13:56 +00001648
1649AC_CHECK_TYPE(int32_t,
1650 AC_DEFINE(HAVE_INT32_T, 1, [Define if your compiler provides int32_t.]),,)
Mark Dickinsonefc82f72009-03-20 15:51:55 +00001651AC_TYPE_INT32_T
Mark Dickinson17c50cd2012-12-02 13:13:56 +00001652
1653AC_CHECK_TYPE(int64_t,
1654 AC_DEFINE(HAVE_INT64_T, 1, [Define if your compiler provides int64_t.]),,)
Mark Dickinsonefc82f72009-03-20 15:51:55 +00001655AC_TYPE_INT64_T
Mark Dickinson17c50cd2012-12-02 13:13:56 +00001656
Christian Heimes951cc0f2008-01-31 23:08:23 +00001657AC_CHECK_TYPE(ssize_t,
Matthias Klose5183ebd2010-04-24 16:38:36 +00001658 AC_DEFINE(HAVE_SSIZE_T, 1, [Define if your compiler provides ssize_t]),,)
Guido van Rossum627b2d71993-12-24 10:39:16 +00001659
Guido van Rossumef2255b2000-03-10 22:30:29 +00001660# Sizes of various common basic types
Skip Montanarob9820a32004-01-17 00:16:12 +00001661# ANSI C requires sizeof(char) == 1, so no need to check it
Guido van Rossum3065c942001-09-17 04:03:14 +00001662AC_CHECK_SIZEOF(int, 4)
1663AC_CHECK_SIZEOF(long, 4)
1664AC_CHECK_SIZEOF(void *, 4)
Guido van Rossum3065c942001-09-17 04:03:14 +00001665AC_CHECK_SIZEOF(short, 2)
1666AC_CHECK_SIZEOF(float, 4)
1667AC_CHECK_SIZEOF(double, 8)
1668AC_CHECK_SIZEOF(fpos_t, 4)
Martin v. Löwis18e16552006-02-15 17:27:45 +00001669AC_CHECK_SIZEOF(size_t, 4)
Christian Heimes951cc0f2008-01-31 23:08:23 +00001670AC_CHECK_SIZEOF(pid_t, 4)
Guido van Rossumac405f61994-09-12 10:56:06 +00001671
Guido van Rossumec95c7b1998-08-04 17:59:56 +00001672AC_MSG_CHECKING(for long long support)
1673have_long_long=no
Matthias Klosec511b472010-05-08 11:01:39 +00001674AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[long long x; x = (long long)0;]])],[
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001675 AC_DEFINE(HAVE_LONG_LONG, 1, [Define this if you have the type long long.])
1676 have_long_long=yes
Matthias Klosec511b472010-05-08 11:01:39 +00001677],[])
Guido van Rossumec95c7b1998-08-04 17:59:56 +00001678AC_MSG_RESULT($have_long_long)
Guido van Rossum8bc1dfd1999-04-10 16:01:48 +00001679if test "$have_long_long" = yes ; then
Guido van Rossum3065c942001-09-17 04:03:14 +00001680AC_CHECK_SIZEOF(long long, 8)
Guido van Rossumec95c7b1998-08-04 17:59:56 +00001681fi
1682
Travis E. Oliphant711c9e92008-06-06 22:33:21 +00001683AC_MSG_CHECKING(for long double support)
1684have_long_double=no
Matthias Klosec511b472010-05-08 11:01:39 +00001685AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[long double x; x = (long double)0;]])],[
Travis E. Oliphant711c9e92008-06-06 22:33:21 +00001686 AC_DEFINE(HAVE_LONG_DOUBLE, 1, [Define this if you have the type long double.])
1687 have_long_double=yes
Matthias Klosec511b472010-05-08 11:01:39 +00001688],[])
Travis E. Oliphant711c9e92008-06-06 22:33:21 +00001689AC_MSG_RESULT($have_long_double)
Mark Dickinsondc1688a2008-06-27 22:20:14 +00001690if test "$have_long_double" = yes ; then
Travis E. Oliphant711c9e92008-06-06 22:33:21 +00001691AC_CHECK_SIZEOF(long double, 12)
1692fi
1693
Martin v. Löwisaef4c6b2007-01-21 09:33:07 +00001694AC_MSG_CHECKING(for _Bool support)
1695have_c99_bool=no
Matthias Klosec511b472010-05-08 11:01:39 +00001696AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[_Bool x; x = (_Bool)0;]])],[
Martin v. Löwisaef4c6b2007-01-21 09:33:07 +00001697 AC_DEFINE(HAVE_C99_BOOL, 1, [Define this if you have the type _Bool.])
1698 have_c99_bool=yes
Matthias Klosec511b472010-05-08 11:01:39 +00001699],[])
Martin v. Löwisaef4c6b2007-01-21 09:33:07 +00001700AC_MSG_RESULT($have_c99_bool)
1701if test "$have_c99_bool" = yes ; then
1702AC_CHECK_SIZEOF(_Bool, 1)
1703fi
1704
Martin v. Löwisebe26702006-10-02 14:55:51 +00001705AC_CHECK_TYPES(uintptr_t,
1706 [AC_CHECK_SIZEOF(uintptr_t, 4)],
Martin v. Löwis40e9aed2006-10-02 15:20:37 +00001707 [], [#ifdef HAVE_STDINT_H
1708 #include <stdint.h>
Antoine Pitrou7be5a652010-10-10 08:14:41 +00001709 #endif
1710 #ifdef HAVE_INTTYPES_H
1711 #include <inttypes.h>
Martin v. Löwis40e9aed2006-10-02 15:20:37 +00001712 #endif])
Martin v. Löwisebe26702006-10-02 14:55:51 +00001713
Alexandre Vassalotti856782e2009-07-17 04:59:05 +00001714AC_CHECK_SIZEOF(off_t, [], [
1715#ifdef HAVE_SYS_TYPES_H
1716#include <sys/types.h>
1717#endif
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001718])
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001719
1720AC_MSG_CHECKING(whether to enable large file support)
Mark Dickinson0ef0b912009-12-31 21:11:48 +00001721if test "$have_long_long" = yes
1722then
1723if test "$ac_cv_sizeof_off_t" -gt "$ac_cv_sizeof_long" -a \
Guido van Rossum8bc1dfd1999-04-10 16:01:48 +00001724 "$ac_cv_sizeof_long_long" -ge "$ac_cv_sizeof_off_t"; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001725 AC_DEFINE(HAVE_LARGEFILE_SUPPORT, 1,
1726 [Defined to enable large file support when an off_t is bigger than a long
1727 and long long is available and at least as big as an off_t. You may need
1728 to add some flags for configuration and compilation to enable this mode.
1729 (For Solaris and Linux, the necessary defines are already defined.)])
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001730 AC_MSG_RESULT(yes)
1731else
1732 AC_MSG_RESULT(no)
1733fi
Mark Dickinson0ef0b912009-12-31 21:11:48 +00001734else
1735 AC_MSG_RESULT(no)
1736fi
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001737
Alexandre Vassalotti856782e2009-07-17 04:59:05 +00001738AC_CHECK_SIZEOF(time_t, [], [
1739#ifdef HAVE_SYS_TYPES_H
1740#include <sys/types.h>
1741#endif
1742#ifdef HAVE_TIME_H
1743#include <time.h>
1744#endif
Fred Drakea3f6e912000-06-29 20:44:47 +00001745])
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001746
Trent Mick635f6fb2000-08-23 21:33:05 +00001747# if have pthread_t then define SIZEOF_PTHREAD_T
Martin v. Löwis123cbd22001-07-19 14:21:10 +00001748ac_save_cc="$CC"
1749if test "$ac_cv_kpthread" = "yes"
1750then CC="$CC -Kpthread"
Martin v. Löwis5f433f02003-05-05 05:05:30 +00001751elif test "$ac_cv_kthread" = "yes"
1752then CC="$CC -Kthread"
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00001753elif test "$ac_cv_pthread" = "yes"
1754then CC="$CC -pthread"
Martin v. Löwis123cbd22001-07-19 14:21:10 +00001755fi
Trent Mick635f6fb2000-08-23 21:33:05 +00001756AC_MSG_CHECKING(for pthread_t)
1757have_pthread_t=no
Matthias Klosec511b472010-05-08 11:01:39 +00001758AC_COMPILE_IFELSE([
1759 AC_LANG_PROGRAM([[#include <pthread.h>]], [[pthread_t x; x = *(pthread_t*)0;]])
1760],[have_pthread_t=yes],[])
Trent Mick635f6fb2000-08-23 21:33:05 +00001761AC_MSG_RESULT($have_pthread_t)
1762if test "$have_pthread_t" = yes ; then
Alexandre Vassalotti856782e2009-07-17 04:59:05 +00001763 AC_CHECK_SIZEOF(pthread_t, [], [
1764#ifdef HAVE_PTHREAD_H
1765#include <pthread.h>
1766#endif
Trent Mick635f6fb2000-08-23 21:33:05 +00001767 ])
Trent Mick635f6fb2000-08-23 21:33:05 +00001768fi
Martin v. Löwis123cbd22001-07-19 14:21:10 +00001769CC="$ac_save_cc"
Trent Mick635f6fb2000-08-23 21:33:05 +00001770
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001771AC_MSG_CHECKING(for --enable-toolbox-glue)
1772AC_ARG_ENABLE(toolbox-glue,
Matthias Klose22520ea2010-05-08 10:14:46 +00001773 AS_HELP_STRING([--enable-toolbox-glue], [disable/enable MacOSX glue code for extensions]))
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001774
1775if test -z "$enable_toolbox_glue"
1776then
1777 case $ac_sys_system/$ac_sys_release in
1778 Darwin/*)
1779 enable_toolbox_glue="yes";;
1780 *)
1781 enable_toolbox_glue="no";;
1782 esac
1783fi
1784case "$enable_toolbox_glue" in
1785yes)
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001786 extra_machdep_objs="Python/mactoolboxglue.o"
Raymond Hettingerec6eb362004-11-05 07:02:59 +00001787 extra_undefs="-u _PyMac_Error"
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001788 AC_DEFINE(USE_TOOLBOX_OBJECT_GLUE, 1,
1789 [Define if you want to use MacPython modules on MacOSX in unix-Python.])
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001790 ;;
1791*)
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001792 extra_machdep_objs=""
Jack Jansen591cbed2001-08-15 13:55:15 +00001793 extra_undefs=""
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001794 ;;
1795esac
1796AC_MSG_RESULT($enable_toolbox_glue)
1797
Ronald Oussoren0d236eb2008-06-06 21:31:33 +00001798
Bob Ippolito7026a0a2005-03-28 23:23:47 +00001799AC_SUBST(OTHER_LIBTOOL_OPT)
1800case $ac_sys_system/$ac_sys_release in
Anthony Baxter82201742006-04-09 15:07:40 +00001801 Darwin/@<:@01567@:>@\..*)
Bob Ippolito7026a0a2005-03-28 23:23:47 +00001802 OTHER_LIBTOOL_OPT="-prebind -seg1addr 0x10000000"
1803 ;;
1804 Darwin/*)
1805 OTHER_LIBTOOL_OPT=""
1806 ;;
1807esac
1808
Ronald Oussoren25967582009-09-06 10:00:26 +00001809
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001810AC_SUBST(LIBTOOL_CRUFT)
1811case $ac_sys_system/$ac_sys_release in
Anthony Baxter82201742006-04-09 15:07:40 +00001812 Darwin/@<:@01567@:>@\..*)
Ronald Oussoren988117f2006-04-29 11:31:35 +00001813 LIBTOOL_CRUFT="-framework System -lcc_dynamic"
1814 if test "${enable_universalsdk}"; then
1815 :
1816 else
Ronald Oussorenbc0e83c2010-02-11 13:26:54 +00001817 LIBTOOL_CRUFT="${LIBTOOL_CRUFT} -arch_only `/usr/bin/arch`"
Ronald Oussoren988117f2006-04-29 11:31:35 +00001818 fi
Jack Jansenb36687a2004-07-16 08:43:47 +00001819 LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -install_name $(PYTHONFRAMEWORKINSTALLDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansena3891ea2001-09-07 14:25:12 +00001820 LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -compatibility_version $(VERSION) -current_version $(VERSION)';;
Guido van Rossum5839e582000-10-09 19:52:35 +00001821 Darwin/*)
Ronald Oussorena55af9a2010-01-17 16:25:57 +00001822 gcc_version=`gcc -dumpversion`
Bob Ippolito7026a0a2005-03-28 23:23:47 +00001823 if test ${gcc_version} '<' 4.0
1824 then
1825 LIBTOOL_CRUFT="-lcc_dynamic"
1826 else
1827 LIBTOOL_CRUFT=""
1828 fi
Matthias Klosec511b472010-05-08 11:01:39 +00001829 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Ronald Oussoren25967582009-09-06 10:00:26 +00001830 #include <unistd.h>
1831 int main(int argc, char*argv[])
1832 {
1833 if (sizeof(long) == 4) {
1834 return 0;
1835 } else {
1836 return 1;
1837 }
Ronald Oussoren84ddd722009-09-08 07:17:10 +00001838 }
Matthias Klosec511b472010-05-08 11:01:39 +00001839 ]])],[ac_osx_32bit=yes],[ac_osx_32bit=no],[ac_osx_32bit=yes])
Ronald Oussoren25967582009-09-06 10:00:26 +00001840
1841 if test "${ac_osx_32bit}" = "yes"; then
Ronald Oussorenbc0e83c2010-02-11 13:26:54 +00001842 case `/usr/bin/arch` in
Ronald Oussoren25967582009-09-06 10:00:26 +00001843 i386)
1844 MACOSX_DEFAULT_ARCH="i386"
1845 ;;
1846 ppc)
1847 MACOSX_DEFAULT_ARCH="ppc"
1848 ;;
1849 *)
1850 AC_MSG_ERROR([Unexpected output of 'arch' on OSX])
1851 ;;
1852 esac
1853 else
Ronald Oussorenbc0e83c2010-02-11 13:26:54 +00001854 case `/usr/bin/arch` in
Ronald Oussoren25967582009-09-06 10:00:26 +00001855 i386)
1856 MACOSX_DEFAULT_ARCH="x86_64"
1857 ;;
1858 ppc)
1859 MACOSX_DEFAULT_ARCH="ppc64"
1860 ;;
1861 *)
1862 AC_MSG_ERROR([Unexpected output of 'arch' on OSX])
1863 ;;
1864 esac
1865
1866 #ARCH_RUN_32BIT="true"
1867 fi
1868
1869 LIBTOOL_CRUFT=$LIBTOOL_CRUFT" -lSystem -lSystemStubs -arch_only ${MACOSX_DEFAULT_ARCH}"
Jack Jansenb36687a2004-07-16 08:43:47 +00001870 LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -install_name $(PYTHONFRAMEWORKINSTALLDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001871 LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -compatibility_version $(VERSION) -current_version $(VERSION)';;
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001872esac
1873
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001874AC_MSG_CHECKING(for --enable-framework)
1875if test "$enable_framework"
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001876then
Skip Montanarodecc6a42003-01-01 20:07:49 +00001877 BASECFLAGS="$BASECFLAGS -fno-common -dynamic"
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001878 # -F. is needed to allow linking to the framework while
1879 # in the build location.
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001880 AC_DEFINE(WITH_NEXT_FRAMEWORK, 1,
1881 [Define if you want to produce an OpenStep/Rhapsody framework
1882 (shared library plus accessory files).])
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001883 AC_MSG_RESULT(yes)
Ronald Oussoren450d5612009-06-08 21:12:41 +00001884 if test $enable_shared = "yes"
1885 then
Ronald Oussoren9ebd2422009-09-29 13:00:44 +00001886 AC_MSG_ERROR([Specifying both --enable-shared and --enable-framework is not supported, use only --enable-framework instead. See Mac/README.])
Ronald Oussoren450d5612009-06-08 21:12:41 +00001887 fi
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001888else
1889 AC_MSG_RESULT(no)
1890fi
1891
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001892AC_MSG_CHECKING(for dyld)
Jack Jansen9a66b6d2001-08-08 13:56:14 +00001893case $ac_sys_system/$ac_sys_release in
1894 Darwin/*)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001895 AC_DEFINE(WITH_DYLD, 1,
1896 [Define if you want to use the new-style (Openstep, Rhapsody, MacOS)
1897 dynamic linker (dyld) instead of the old-style (NextStep) dynamic
1898 linker (rld). Dyld is necessary to support frameworks.])
Jack Jansen9a66b6d2001-08-08 13:56:14 +00001899 AC_MSG_RESULT(always on for Darwin)
1900 ;;
1901 *)
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001902 AC_MSG_RESULT(no)
1903 ;;
Jack Jansen9a66b6d2001-08-08 13:56:14 +00001904esac
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001905
Guido van Rossumac405f61994-09-12 10:56:06 +00001906# Set info about shared libraries.
Guido van Rossumac405f61994-09-12 10:56:06 +00001907AC_SUBST(SO)
1908AC_SUBST(LDSHARED)
Tarek Ziadé00002952010-04-03 08:37:59 +00001909AC_SUBST(LDCXXSHARED)
Neil Schemenauerb3531b82001-02-16 04:09:05 +00001910AC_SUBST(BLDSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00001911AC_SUBST(CCSHARED)
1912AC_SUBST(LINKFORSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00001913# SO is the extension of shared libraries `(including the dot!)
Guido van Rossumaef734b2001-01-10 21:09:12 +00001914# -- usually .so, .sl on HP-UX, .dll on Cygwin
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001915AC_MSG_CHECKING(SO)
Guido van Rossumac405f61994-09-12 10:56:06 +00001916if test -z "$SO"
1917then
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001918 case $ac_sys_system in
Neal Norwitz58e28882006-05-19 07:00:58 +00001919 hp*|HP*)
1920 case `uname -m` in
1921 ia64) SO=.so;;
1922 *) SO=.sl;;
1923 esac
1924 ;;
Guido van Rossumaef734b2001-01-10 21:09:12 +00001925 CYGWIN*) SO=.dll;;
Guido van Rossum4b6b5791996-09-09 20:09:34 +00001926 *) SO=.so;;
Guido van Rossumac405f61994-09-12 10:56:06 +00001927 esac
Martin v. Löwis368de8f2003-06-14 14:46:38 +00001928else
1929 # this might also be a termcap variable, see #610332
1930 echo
1931 echo '====================================================================='
1932 echo '+ +'
1933 echo '+ WARNING: You have set SO in your environment. +'
1934 echo '+ Do you really mean to change the extension for shared libraries? +'
1935 echo '+ Continuing in 10 seconds to let you to ponder. +'
1936 echo '+ +'
1937 echo '====================================================================='
1938 sleep 10
Guido van Rossumac405f61994-09-12 10:56:06 +00001939fi
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001940AC_MSG_RESULT($SO)
Ronald Oussoren79f90492009-01-02 10:44:46 +00001941
Neal Norwitz58e28882006-05-19 07:00:58 +00001942AC_DEFINE_UNQUOTED(SHLIB_EXT, "$SO", [Define this to be extension of shared libraries (including the dot!).])
Guido van Rossumac405f61994-09-12 10:56:06 +00001943# LDSHARED is the ld *command* used to create shared library
Skip Montanaroce59c042004-01-17 14:19:44 +00001944# -- "cc -G" on SunOS 5.x, "ld -shared" on IRIX 5
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001945# (Shared libraries in this instance are shared modules to be loaded into
1946# Python, as opposed to building Python itself as a shared library.)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001947AC_MSG_CHECKING(LDSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00001948if test -z "$LDSHARED"
1949then
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001950 case $ac_sys_system/$ac_sys_release in
Neil Schemenauerb3531b82001-02-16 04:09:05 +00001951 AIX*)
Georg Brandl71f4fbb2011-02-25 11:04:50 +00001952 BLDSHARED="\$(srcdir)/Modules/ld_so_aix \$(CC) -bI:\$(srcdir)/Modules/python.exp"
Guido van Rossumce608b02001-09-28 15:59:38 +00001953 LDSHARED="\$(BINLIBDEST)/config/ld_so_aix \$(CC) -bI:\$(BINLIBDEST)/config/python.exp"
Neil Schemenauerb3531b82001-02-16 04:09:05 +00001954 ;;
1955 BeOS*)
1956 BLDSHARED="\$(srcdir)/Modules/ld_so_beos $LDLIBRARY"
Guido van Rossumce608b02001-09-28 15:59:38 +00001957 LDSHARED="\$(BINLIBDEST)/config/ld_so_beos \$(LIBDIR)/$LDLIBRARY"
Neil Schemenauerb3531b82001-02-16 04:09:05 +00001958 ;;
Guido van Rossum6100aaf1997-04-29 21:48:51 +00001959 IRIX/5*) LDSHARED="ld -shared";;
Guido van Rossum91922671997-10-09 20:24:13 +00001960 IRIX*/6*) LDSHARED="ld ${SGI_ABI} -shared -all";;
Greg Ward57c9a662000-05-26 12:22:54 +00001961 SunOS/5*)
Tarek Ziadé00002952010-04-03 08:37:59 +00001962 if test "$GCC" = "yes" ; then
1963 LDSHARED='$(CC) -shared'
1964 LDCXXSHARED='$(CXX) -shared'
1965 else
1966 LDSHARED='$(CC) -G'
1967 LDCXXSHARED='$(CXX) -G'
Greg Ward57c9a662000-05-26 12:22:54 +00001968 fi ;;
Thomas Hellerdc96a772008-04-04 10:07:55 +00001969 hp*|HP*)
Tarek Ziadé00002952010-04-03 08:37:59 +00001970 if test "$GCC" = "yes" ; then
1971 LDSHARED='$(CC) -shared'
1972 LDCXXSHARED='$(CXX) -shared'
1973 else
1974 LDSHARED='ld -b'
Thomas Hellerdc96a772008-04-04 10:07:55 +00001975 fi ;;
Guido van Rossum71001e41995-01-26 00:44:03 +00001976 OSF*) LDSHARED="ld -shared -expect_unresolved \"*\"";;
Jack Jansen418c3b12001-11-14 10:59:57 +00001977 Darwin/1.3*)
Stefan Krah3a3e2032010-11-28 15:30:05 +00001978 LDSHARED='$(CC) -bundle'
1979 LDCXXSHARED='$(CXX) -bundle'
Jack Jansena3891ea2001-09-07 14:25:12 +00001980 if test "$enable_framework" ; then
1981 # Link against the framework. All externals should be defined.
Jack Jansenda49e192005-01-07 13:08:22 +00001982 BLDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
1983 LDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Tarek Ziadé00002952010-04-03 08:37:59 +00001984 LDCXXSHARED="$LDCXXSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansena3891ea2001-09-07 14:25:12 +00001985 else
1986 # No framework. Ignore undefined symbols, assuming they come from Python
Jack Jansen418c3b12001-11-14 10:59:57 +00001987 LDSHARED="$LDSHARED -undefined suppress"
Tarek Ziadé00002952010-04-03 08:37:59 +00001988 LDCXXSHARED="$LDCXXSHARED -undefined suppress"
Jack Jansena3891ea2001-09-07 14:25:12 +00001989 fi ;;
Jack Jansen6b08a402004-06-03 12:41:45 +00001990 Darwin/1.4*|Darwin/5.*|Darwin/6.*)
Stefan Krah3a3e2032010-11-28 15:30:05 +00001991 LDSHARED='$(CC) -bundle'
1992 LDCXXSHARED='$(CXX) -bundle'
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001993 if test "$enable_framework" ; then
1994 # Link against the framework. All externals should be defined.
Jack Jansenda49e192005-01-07 13:08:22 +00001995 BLDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
1996 LDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Tarek Ziadé00002952010-04-03 08:37:59 +00001997 LDCXXSHARED="$LDCXXSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001998 else
Michael W. Hudson0c46c0c2002-03-07 09:58:56 +00001999 # No framework, use the Python app as bundle-loader
2000 BLDSHARED="$LDSHARED "'-bundle_loader $(BUILDPYTHON)'
Jack Jansenc28fc372003-02-25 13:14:43 +00002001 LDSHARED="$LDSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)'
Tarek Ziadé00002952010-04-03 08:37:59 +00002002 LDCXXSHARED="$LDCXXSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)'
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00002003 fi ;;
Jack Jansen6b08a402004-06-03 12:41:45 +00002004 Darwin/*)
2005 # Use -undefined dynamic_lookup whenever possible (10.3 and later).
2006 # This allows an extension to be used in any Python
Ronald Oussoren38f1b982007-09-02 09:46:07 +00002007
Ned Deilyc40b9032014-06-25 13:48:46 -07002008 dep_target_major=`echo ${MACOSX_DEPLOYMENT_TARGET} | \
2009 sed 's/\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'`
2010 dep_target_minor=`echo ${MACOSX_DEPLOYMENT_TARGET} | \
2011 sed 's/\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'`
2012 if test ${dep_target_major} -eq 10 && \
2013 test ${dep_target_minor} -le 2
Jack Jansen6b08a402004-06-03 12:41:45 +00002014 then
Ned Deilyc40b9032014-06-25 13:48:46 -07002015 # building for OS X 10.0 through 10.2
Stefan Krah3a3e2032010-11-28 15:30:05 +00002016 LDSHARED='$(CC) -bundle'
2017 LDCXXSHARED='$(CXX) -bundle'
Jack Jansen6b08a402004-06-03 12:41:45 +00002018 if test "$enable_framework" ; then
2019 # Link against the framework. All externals should be defined.
Jack Jansenda49e192005-01-07 13:08:22 +00002020 BLDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
2021 LDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Tarek Ziadé00002952010-04-03 08:37:59 +00002022 LDCXXSHARED="$LDCXXSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansen6b08a402004-06-03 12:41:45 +00002023 else
2024 # No framework, use the Python app as bundle-loader
2025 BLDSHARED="$LDSHARED "'-bundle_loader $(BUILDPYTHON)'
2026 LDSHARED="$LDSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)'
Tarek Ziadé00002952010-04-03 08:37:59 +00002027 LDCXXSHARED="$LDCXXSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)'
Jack Jansen6b08a402004-06-03 12:41:45 +00002028 fi
Ned Deilyc40b9032014-06-25 13:48:46 -07002029 else
2030 # building for OS X 10.3 and later
2031 if test "${enable_universalsdk}"; then
2032 LDFLAGS="${UNIVERSAL_ARCH_FLAGS} -isysroot ${UNIVERSALSDK} ${LDFLAGS}"
2033 fi
2034 LDSHARED='$(CC) -bundle -undefined dynamic_lookup'
2035 LDCXXSHARED='$(CXX) -bundle -undefined dynamic_lookup'
2036 BLDSHARED="$LDSHARED"
Jack Jansen6b08a402004-06-03 12:41:45 +00002037 fi
2038 ;;
Tarek Ziadé00002952010-04-03 08:37:59 +00002039 Linux*|GNU*|QNX*)
2040 LDSHARED='$(CC) -shared'
2041 LDCXXSHARED='$(CXX) -shared';;
2042 BSD/OS*/4*)
2043 LDSHARED="gcc -shared"
2044 LDCXXSHARED="g++ -shared";;
Martin v. Löwis222c5152006-06-03 07:37:13 +00002045 FreeBSD*)
Jeremy Hylton4bcc7c52000-08-31 17:45:35 +00002046 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
Guido van Rossum0286ae82000-08-29 15:06:49 +00002047 then
Stefan Krah3a3e2032010-11-28 15:30:05 +00002048 LDSHARED='$(CC) -shared'
2049 LDCXXSHARED='$(CXX) -shared'
Guido van Rossum0286ae82000-08-29 15:06:49 +00002050 else
Stefan Krah3a3e2032010-11-28 15:30:05 +00002051 LDSHARED="ld -Bshareable"
Guido van Rossum0286ae82000-08-29 15:06:49 +00002052 fi;;
Martin v. Löwis222c5152006-06-03 07:37:13 +00002053 OpenBSD*)
2054 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
2055 then
Stefan Krah3a3e2032010-11-28 15:30:05 +00002056 LDSHARED='$(CC) -shared $(CCSHARED)'
2057 LDCXXSHARED='$(CXX) -shared $(CCSHARED)'
Martin v. Löwis222c5152006-06-03 07:37:13 +00002058 else
2059 case `uname -r` in
2060 [[01]].* | 2.[[0-7]] | 2.[[0-7]].*)
2061 LDSHARED="ld -Bshareable ${LDFLAGS}"
2062 ;;
2063 *)
Stefan Krah3a3e2032010-11-28 15:30:05 +00002064 LDSHARED='$(CC) -shared $(CCSHARED)'
2065 LDCXXSHARED='$(CXX) -shared $(CCSHARED)'
Martin v. Löwis222c5152006-06-03 07:37:13 +00002066 ;;
2067 esac
2068 fi;;
Tarek Ziadé00002952010-04-03 08:37:59 +00002069 NetBSD*|DragonFly*)
Antoine Pitroucb402772011-01-02 20:51:34 +00002070 LDSHARED='$(CC) -shared'
2071 LDCXXSHARED='$(CXX) -shared';;
Martin v. Löwis25ae43b2001-10-07 08:39:18 +00002072 OpenUNIX*|UnixWare*)
Tarek Ziadé00002952010-04-03 08:37:59 +00002073 if test "$GCC" = "yes" ; then
2074 LDSHARED='$(CC) -shared'
2075 LDCXXSHARED='$(CXX) -shared'
2076 else
2077 LDSHARED='$(CC) -G'
2078 LDCXXSHARED='$(CXX) -G'
Martin v. Löwisbec19582001-03-21 15:57:54 +00002079 fi;;
Tarek Ziadé00002952010-04-03 08:37:59 +00002080 SCO_SV*)
2081 LDSHARED='$(CC) -Wl,-G,-Bexport'
2082 LDCXXSHARED='$(CXX) -Wl,-G,-Bexport';;
2083 CYGWIN*)
2084 LDSHARED="gcc -shared -Wl,--enable-auto-image-base"
2085 LDCXXSHARED="g++ -shared -Wl,--enable-auto-image-base";;
2086 atheos*)
2087 LDSHARED="gcc -shared"
2088 LDCXXSHARED="g++ -shared";;
Guido van Rossumac405f61994-09-12 10:56:06 +00002089 *) LDSHARED="ld";;
2090 esac
Guido van Rossumac405f61994-09-12 10:56:06 +00002091fi
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002092AC_MSG_RESULT($LDSHARED)
Tarek Ziadé00002952010-04-03 08:37:59 +00002093LDCXXSHARED=${LDCXXSHARED-$LDSHARED}
Neil Schemenauerb3531b82001-02-16 04:09:05 +00002094BLDSHARED=${BLDSHARED-$LDSHARED}
Guido van Rossumac405f61994-09-12 10:56:06 +00002095# CCSHARED are the C *flags* used to create objects to go into a shared
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00002096# library (module) -- this is only needed for a few systems
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002097AC_MSG_CHECKING(CCSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00002098if test -z "$CCSHARED"
2099then
Guido van Rossum6100aaf1997-04-29 21:48:51 +00002100 case $ac_sys_system/$ac_sys_release in
Neil Schemenauer66252162001-02-19 04:47:42 +00002101 SunOS*) if test "$GCC" = yes;
Martin v. Löwiseb623572007-03-12 10:50:39 +00002102 then CCSHARED="-fPIC";
2103 elif test `uname -p` = sparc;
2104 then CCSHARED="-xcode=pic32";
2105 else CCSHARED="-Kpic";
2106 fi;;
Guido van Rossumaf07a441995-02-13 19:45:27 +00002107 hp*|HP*) if test "$GCC" = yes;
Martin v. Löwis703ad702001-09-05 08:36:52 +00002108 then CCSHARED="-fPIC";
Guido van Rossumaf07a441995-02-13 19:45:27 +00002109 else CCSHARED="+z";
2110 fi;;
Martin v. Löwisa6e97582002-01-01 18:41:33 +00002111 Linux*|GNU*) CCSHARED="-fPIC";;
Guido van Rossumf5957ea1999-10-05 21:59:33 +00002112 BSD/OS*/4*) CCSHARED="-fpic";;
Martin v. Löwis86d66262006-02-17 08:40:11 +00002113 FreeBSD*|NetBSD*|OpenBSD*|DragonFly*) CCSHARED="-fPIC";;
Martin v. Löwis25ae43b2001-10-07 08:39:18 +00002114 OpenUNIX*|UnixWare*)
Martin v. Löwisbec19582001-03-21 15:57:54 +00002115 if test "$GCC" = "yes"
2116 then CCSHARED="-fPIC"
Martin v. Löwis130fb172001-07-19 11:00:41 +00002117 else CCSHARED="-KPIC"
Martin v. Löwisbec19582001-03-21 15:57:54 +00002118 fi;;
Martin v. Löwis21ee4092002-09-30 16:19:48 +00002119 SCO_SV*)
2120 if test "$GCC" = "yes"
2121 then CCSHARED="-fPIC"
2122 else CCSHARED="-Kpic -belf"
2123 fi;;
Guido van Rossum2b5ca001998-03-05 15:41:09 +00002124 IRIX*/6*) case $CC in
2125 *gcc*) CCSHARED="-shared";;
Guido van Rossumee21f411998-04-20 18:51:54 +00002126 *) CCSHARED="";;
Guido van Rossum2b5ca001998-03-05 15:41:09 +00002127 esac;;
Martin v. Löwisf90ae202002-06-11 06:22:31 +00002128 atheos*) CCSHARED="-fPIC";;
Guido van Rossumac405f61994-09-12 10:56:06 +00002129 esac
Guido van Rossumac405f61994-09-12 10:56:06 +00002130fi
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002131AC_MSG_RESULT($CCSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00002132# LINKFORSHARED are the flags passed to the $(CC) command that links
Guido van Rossumb65a48e1995-06-14 18:21:23 +00002133# the python executable -- this is only needed for a few systems
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002134AC_MSG_CHECKING(LINKFORSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00002135if test -z "$LINKFORSHARED"
2136then
Guido van Rossum6100aaf1997-04-29 21:48:51 +00002137 case $ac_sys_system/$ac_sys_release in
Neil Schemenauerb3531b82001-02-16 04:09:05 +00002138 AIX*) LINKFORSHARED='-Wl,-bE:Modules/python.exp -lld';;
Guido van Rossum5dab3d81996-12-06 21:18:18 +00002139 hp*|HP*)
Martin v. Löwis1142de32002-03-29 16:28:31 +00002140 LINKFORSHARED="-Wl,-E -Wl,+s";;
2141# LINKFORSHARED="-Wl,-E -Wl,+s -Wl,+b\$(BINLIBDEST)/lib-dynload";;
Guido van Rossumf5957ea1999-10-05 21:59:33 +00002142 BSD/OS/4*) LINKFORSHARED="-Xlinker -export-dynamic";;
Martin v. Löwisa6e97582002-01-01 18:41:33 +00002143 Linux*|GNU*) LINKFORSHARED="-Xlinker -export-dynamic";;
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00002144 # -u libsys_s pulls in all symbols in libsys
Jack Jansenb6e9cad2001-08-15 01:26:28 +00002145 Darwin/*)
Raymond Hettingerec6eb362004-11-05 07:02:59 +00002146 # -u _PyMac_Error is needed to pull in the mac toolbox glue,
2147 # which is
Jack Jansenb6e9cad2001-08-15 01:26:28 +00002148 # not used by the core itself but which needs to be in the core so
2149 # that dynamically loaded extension modules have access to it.
Jack Jansen97e3f002003-02-23 22:59:01 +00002150 # -prebind is no longer used, because it actually seems to give a
2151 # slowdown in stead of a speedup, maybe due to the large number of
2152 # dynamic loads Python does.
Raymond Hettingerec6eb362004-11-05 07:02:59 +00002153
2154 LINKFORSHARED="$extra_undefs"
Jack Jansenb6e9cad2001-08-15 01:26:28 +00002155 if test "$enable_framework"
2156 then
Jack Jansenda49e192005-01-07 13:08:22 +00002157 LINKFORSHARED="$LINKFORSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansenb6e9cad2001-08-15 01:26:28 +00002158 fi
Raymond Hettingerec6eb362004-11-05 07:02:59 +00002159 LINKFORSHARED="$LINKFORSHARED";;
Martin v. Löwis25ae43b2001-10-07 08:39:18 +00002160 OpenUNIX*|UnixWare*) LINKFORSHARED="-Wl,-Bexport";;
Martin v. Löwis21ee4092002-09-30 16:19:48 +00002161 SCO_SV*) LINKFORSHARED="-Wl,-Bexport";;
Fred Drake02706f52000-09-25 15:08:46 +00002162 ReliantUNIX*) LINKFORSHARED="-W1 -Blargedynsym";;
Martin v. Löwis86d66262006-02-17 08:40:11 +00002163 FreeBSD*|NetBSD*|OpenBSD*|DragonFly*)
Guido van Rossumdf693651999-01-07 21:50:41 +00002164 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
2165 then
2166 LINKFORSHARED="-Wl,--export-dynamic"
2167 fi;;
Guido van Rossum2b5ca001998-03-05 15:41:09 +00002168 SunOS/5*) case $CC in
2169 *gcc*)
Martin v. Löwisa4548572002-04-18 14:51:36 +00002170 if $CC -Xlinker --help 2>&1 | grep export-dynamic >/dev/null
Guido van Rossum8f4ceb11997-12-18 23:42:19 +00002171 then
2172 LINKFORSHARED="-Xlinker --export-dynamic"
Guido van Rossum2b5ca001998-03-05 15:41:09 +00002173 fi;;
2174 esac;;
Jason Tishler30765592003-09-04 11:04:06 +00002175 CYGWIN*)
2176 if test $enable_shared = "no"
2177 then
2178 LINKFORSHARED='-Wl,--out-implib=$(LDLIBRARY)'
2179 fi;;
Martin v. Löwis8c255e42008-05-23 15:06:50 +00002180 QNX*)
2181 # -Wl,-E causes the symbols to be added to the dynamic
2182 # symbol table so that they can be found when a module
2183 # is loaded. -N 2048K causes the stack size to be set
2184 # to 2048 kilobytes so that the stack doesn't overflow
2185 # when running test_compile.py.
2186 LINKFORSHARED='-Wl,-E -N 2048K';;
Guido van Rossumac405f61994-09-12 10:56:06 +00002187 esac
Guido van Rossumac405f61994-09-12 10:56:06 +00002188fi
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002189AC_MSG_RESULT($LINKFORSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00002190
Ronald Oussoren0d236eb2008-06-06 21:31:33 +00002191
Neil Schemenauer61c51152001-01-26 16:18:16 +00002192AC_SUBST(CFLAGSFORSHARED)
2193AC_MSG_CHECKING(CFLAGSFORSHARED)
2194if test ! "$LIBRARY" = "$LDLIBRARY"
2195then
Neil Schemenauerd9cf41c2001-01-27 21:39:17 +00002196 case $ac_sys_system in
2197 CYGWIN*)
2198 # Cygwin needs CCSHARED when building extension DLLs
2199 # but not when building the interpreter DLL.
2200 CFLAGSFORSHARED='';;
2201 *)
2202 CFLAGSFORSHARED='$(CCSHARED)'
2203 esac
Neil Schemenauer61c51152001-01-26 16:18:16 +00002204fi
2205AC_MSG_RESULT($CFLAGSFORSHARED)
2206
Martin v. Löwisf90ae202002-06-11 06:22:31 +00002207# SHLIBS are libraries (except -lc and -lm) to link to the python shared
2208# library (with --enable-shared).
2209# For platforms on which shared libraries are not allowed to have unresolved
Martin v. Löwisd6359c52002-08-04 12:38:50 +00002210# symbols, this must be set to $(LIBS) (expanded by make). We do this even
2211# if it is not required, since it creates a dependency of the shared library
2212# to LIBS. This, in turn, means that applications linking the shared libpython
2213# don't need to link LIBS explicitly. The default should be only changed
2214# on systems where this approach causes problems.
Martin v. Löwisf90ae202002-06-11 06:22:31 +00002215AC_SUBST(SHLIBS)
2216AC_MSG_CHECKING(SHLIBS)
2217case "$ac_sys_system" in
Martin v. Löwisf90ae202002-06-11 06:22:31 +00002218 *)
Martin v. Löwisd6359c52002-08-04 12:38:50 +00002219 SHLIBS='$(LIBS)';;
Martin v. Löwisf90ae202002-06-11 06:22:31 +00002220esac
2221AC_MSG_RESULT($SHLIBS)
2222
2223
Guido van Rossum627b2d71993-12-24 10:39:16 +00002224# checks for libraries
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002225AC_CHECK_LIB(dl, dlopen) # Dynamic linking for SunOS/Solaris and SYSV
2226AC_CHECK_LIB(dld, shl_load) # Dynamic linking for HP-UX
Victor Stinner7c906672015-01-06 13:53:37 +01002227AC_CHECK_LIB(crypto, RAND_egd,
2228 AC_DEFINE(HAVE_RAND_EGD, 1,
2229 [Define if the libcrypto has RAND_egd]))
Martin v. Löwis519adae2003-09-20 10:47:47 +00002230
Skip Montanaro4d756af2008-12-01 01:55:22 +00002231# only check for sem_init if thread support is requested
Martin v. Löwis519adae2003-09-20 10:47:47 +00002232if test "$with_threads" = "yes" -o -z "$with_threads"; then
2233 AC_SEARCH_LIBS(sem_init, pthread rt posix4) # 'Real Time' functions on Solaris
2234 # posix4 on Solaris 2.6
2235 # pthread (first!) on Linux
2236fi
2237
Martin v. Löwis19d17342003-06-14 21:03:05 +00002238# check if we need libintl for locale functions
2239AC_CHECK_LIB(intl, textdomain,
2240 AC_DEFINE(WITH_LIBINTL, 1,
2241 [Define to 1 if libintl is needed for locale functions.]))
Guido van Rossum0eefa3f1999-11-16 15:57:37 +00002242
2243# checks for system dependent C++ extensions support
2244case "$ac_sys_system" in
2245 AIX*) AC_MSG_CHECKING(for genuine AIX C++ extensions support)
Matthias Klosec511b472010-05-08 11:01:39 +00002246 AC_LINK_IFELSE([
Georg Brandl94800df2011-02-25 11:09:02 +00002247 AC_LANG_PROGRAM([[#include <load.h>]],
Matthias Klosec511b472010-05-08 11:01:39 +00002248 [[loadAndInit("", 0, "")]])
2249 ],[
2250 AC_DEFINE(AIX_GENUINE_CPLUSPLUS, 1,
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002251 [Define for AIX if your compiler is a genuine IBM xlC/xlC_r
2252 and you want support for AIX C++ shared extension modules.])
Matthias Klosec511b472010-05-08 11:01:39 +00002253 AC_MSG_RESULT(yes)
2254 ],[
2255 AC_MSG_RESULT(no)
2256 ]);;
Guido van Rossum0eefa3f1999-11-16 15:57:37 +00002257 *) ;;
2258esac
2259
Guido van Rossum70c7f481998-03-26 18:44:10 +00002260# Most SVR4 platforms (e.g. Solaris) need -lsocket and -lnsl.
Guido van Rossumec95c7b1998-08-04 17:59:56 +00002261# BeOS' sockets are stashed in libnet.
Guido van Rossumf618d2c1995-01-17 16:36:13 +00002262AC_CHECK_LIB(nsl, t_open, [LIBS="-lnsl $LIBS"]) # SVR4
Guido van Rossumf618d2c1995-01-17 16:36:13 +00002263AC_CHECK_LIB(socket, socket, [LIBS="-lsocket $LIBS"], [], $LIBS) # SVR4 sockets
Skip Montanarob9949db2004-01-17 04:04:13 +00002264
Jeremy Hyltoncb25d5e2000-07-27 21:23:28 +00002265case "$ac_sys_system" in
2266BeOS*)
Guido van Rossumec95c7b1998-08-04 17:59:56 +00002267AC_CHECK_LIB(net, socket, [LIBS="-lnet $LIBS"], [], $LIBS) # BeOS
2268;;
2269esac
Guido van Rossum70c7f481998-03-26 18:44:10 +00002270
Guido van Rossumc5a39031996-07-31 17:35:03 +00002271AC_MSG_CHECKING(for --with-libs)
Barry Warsawc0d24d82000-06-29 16:12:00 +00002272AC_ARG_WITH(libs,
Matthias Klose22520ea2010-05-08 10:14:46 +00002273 AS_HELP_STRING([--with-libs='lib1 ...'], [link against additional libs]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002274[
Guido van Rossumc5a39031996-07-31 17:35:03 +00002275AC_MSG_RESULT($withval)
2276LIBS="$withval $LIBS"
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002277],
2278[AC_MSG_RESULT(no)])
Guido van Rossum627b2d71993-12-24 10:39:16 +00002279
Benjamin Peterson64e8f6e2014-12-15 00:00:23 -05002280PKG_PROG_PKG_CONFIG
Benjamin Petersone9e07bf2010-03-09 21:46:54 +00002281
Benjamin Peterson2c196742009-12-31 03:17:18 +00002282# Check for use of the system expat library
2283AC_MSG_CHECKING(for --with-system-expat)
2284AC_ARG_WITH(system_expat,
Benjamin Petersonf2d1b2a2010-10-31 16:53:53 +00002285 AS_HELP_STRING([--with-system-expat], [build pyexpat module using an installed expat library]),
2286 [],
2287 [with_system_expat="no"])
Benjamin Peterson2c196742009-12-31 03:17:18 +00002288
2289AC_MSG_RESULT($with_system_expat)
2290
Martin v. Löwis9176fc12006-04-11 11:12:43 +00002291# Check for use of the system libffi library
2292AC_MSG_CHECKING(for --with-system-ffi)
2293AC_ARG_WITH(system_ffi,
Benjamin Petersonf2d1b2a2010-10-31 16:53:53 +00002294 AS_HELP_STRING([--with-system-ffi], [build _ctypes module using an installed ffi library]),
2295 [],
2296 [with_system_ffi="no"])
Martin v. Löwis9176fc12006-04-11 11:12:43 +00002297
Benjamin Petersone9e07bf2010-03-09 21:46:54 +00002298if test "$with_system_ffi" = "yes" && test -n "$PKG_CONFIG"; then
Benjamin Peterson1c335e62010-01-01 15:16:29 +00002299 LIBFFI_INCLUDEDIR="`"$PKG_CONFIG" libffi --cflags-only-I 2>/dev/null | sed -e 's/^-I//;s/ *$//'`"
2300else
2301 LIBFFI_INCLUDEDIR=""
2302fi
2303AC_SUBST(LIBFFI_INCLUDEDIR)
2304
Martin v. Löwis9176fc12006-04-11 11:12:43 +00002305AC_MSG_RESULT($with_system_ffi)
2306
Ned Deilya2a9f572013-10-25 00:30:10 -07002307# Check for --with-tcltk-includes=path and --with-tcltk-libs=path
2308AC_SUBST(TCLTK_INCLUDES)
2309AC_SUBST(TCLTK_LIBS)
2310AC_MSG_CHECKING(for --with-tcltk-includes)
2311AC_ARG_WITH(tcltk-includes,
2312 AS_HELP_STRING([--with-tcltk-includes='-I...'], [override search for Tcl and Tk include files]),
2313 [],
2314 [with_tcltk_includes="default"])
2315AC_MSG_RESULT($with_tcltk_includes)
2316AC_MSG_CHECKING(for --with-tcltk-libs)
2317AC_ARG_WITH(tcltk-libs,
2318 AS_HELP_STRING([--with-tcltk-libs='-L...'], [override search for Tcl and Tk libs]),
2319 [],
2320 [with_tcltk_libs="default"])
2321AC_MSG_RESULT($with_tcltk_libs)
2322if test "x$with_tcltk_includes" = xdefault || test "x$with_tcltk_libs" = xdefault
2323then
2324 if test "x$with_tcltk_includes" != "x$with_tcltk_libs"
2325 then
2326 AC_MSG_ERROR([use both --with-tcltk-includes='...' and --with-tcltk-libs='...' or neither])
2327 fi
2328 TCLTK_INCLUDES=""
2329 TCLTK_LIBS=""
2330else
2331 TCLTK_INCLUDES="$with_tcltk_includes"
2332 TCLTK_LIBS="$with_tcltk_libs"
2333fi
2334
Matthias Klose10cbe482009-04-29 17:18:19 +00002335# Check for --with-dbmliborder
2336AC_MSG_CHECKING(for --with-dbmliborder)
2337AC_ARG_WITH(dbmliborder,
Matthias Klose22520ea2010-05-08 10:14:46 +00002338 AS_HELP_STRING([--with-dbmliborder=db1:db2:...], [order to check db backends for dbm. Valid value is a colon separated string with the backend names `ndbm', `gdbm' and `bdb'.]),
Matthias Klose10cbe482009-04-29 17:18:19 +00002339[
2340if test x$with_dbmliborder = xyes
2341then
2342AC_MSG_ERROR([proper usage is --with-dbmliborder=db1:db2:...])
2343else
2344 for db in `echo $with_dbmliborder | sed 's/:/ /g'`; do
2345 if test x$db != xndbm && test x$db != xgdbm && test x$db != xbdb
2346 then
2347 AC_MSG_ERROR([proper usage is --with-dbmliborder=db1:db2:...])
2348 fi
2349 done
Matthias Klose61dbdb92009-04-29 20:09:50 +00002350fi])
2351AC_MSG_RESULT($with_dbmliborder)
Matthias Klose10cbe482009-04-29 17:18:19 +00002352
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00002353# Determine if signalmodule should be used.
2354AC_SUBST(USE_SIGNAL_MODULE)
2355AC_SUBST(SIGNAL_OBJS)
2356AC_MSG_CHECKING(for --with-signal-module)
2357AC_ARG_WITH(signal-module,
Matthias Klose22520ea2010-05-08 10:14:46 +00002358 AS_HELP_STRING([--with-signal-module], [disable/enable signal module]))
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00002359
2360if test -z "$with_signal_module"
2361then with_signal_module="yes"
2362fi
2363AC_MSG_RESULT($with_signal_module)
2364
2365if test "${with_signal_module}" = "yes"; then
2366 USE_SIGNAL_MODULE=""
2367 SIGNAL_OBJS=""
2368else
2369 USE_SIGNAL_MODULE="#"
2370 SIGNAL_OBJS="Parser/intrcheck.o Python/sigcheck.o"
2371fi
2372
Guido van Rossum3d15bd82001-01-10 18:53:48 +00002373# This is used to generate Setup.config
Guido van Rossum009f7871997-12-04 00:51:42 +00002374AC_SUBST(USE_THREAD_MODULE)
Barry Warsawc0d24d82000-06-29 16:12:00 +00002375USE_THREAD_MODULE=""
Guido van Rossum009f7871997-12-04 00:51:42 +00002376
Guido van Rossum54d93d41997-01-22 20:51:58 +00002377AC_MSG_CHECKING(for --with-dec-threads)
2378AC_SUBST(LDLAST)
2379AC_ARG_WITH(dec-threads,
Matthias Klose22520ea2010-05-08 10:14:46 +00002380 AS_HELP_STRING([--with-dec-threads], [use DEC Alpha/OSF1 thread-safe libraries]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002381[
Barry Warsawc0d24d82000-06-29 16:12:00 +00002382AC_MSG_RESULT($withval)
Guido van Rossum54d93d41997-01-22 20:51:58 +00002383LDLAST=-threads
Guido van Rossumf78abae1997-01-21 22:02:36 +00002384if test "${with_thread+set}" != set; then
Guido van Rossum54d93d41997-01-22 20:51:58 +00002385 with_thread="$withval";
2386fi],
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002387[AC_MSG_RESULT(no)])
Guido van Rossum54d93d41997-01-22 20:51:58 +00002388
Martin v. Löwis11437992002-04-12 09:54:03 +00002389# Templates for things AC_DEFINEd more than once.
2390# For a single AC_DEFINE, no template is needed.
2391AH_TEMPLATE(C_THREADS,[Define if you have the Mach cthreads package])
2392AH_TEMPLATE(_REENTRANT,
2393 [Define to force use of thread-safe errno, h_errno, and other functions])
2394AH_TEMPLATE(WITH_THREAD,
2395 [Define if you want to compile in rudimentary thread support])
2396
Guido van Rossum54d93d41997-01-22 20:51:58 +00002397AC_MSG_CHECKING(for --with-threads)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002398dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
Barry Warsawc0d24d82000-06-29 16:12:00 +00002399AC_ARG_WITH(threads,
Matthias Klose22520ea2010-05-08 10:14:46 +00002400 AS_HELP_STRING([--with(out)-threads@<:@=DIRECTORY@:>@], [disable/enable thread support]))
Guido van Rossum54d93d41997-01-22 20:51:58 +00002401
Barry Warsawc0d24d82000-06-29 16:12:00 +00002402# --with-thread is deprecated, but check for it anyway
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002403dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
Barry Warsawa0f3c5c2000-06-30 16:39:35 +00002404AC_ARG_WITH(thread,
Matthias Klose22520ea2010-05-08 10:14:46 +00002405 AS_HELP_STRING([--with(out)-thread@<:@=DIRECTORY@:>@], [deprecated; use --with(out)-threads]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002406 [with_threads=$with_thread])
Barry Warsawc0d24d82000-06-29 16:12:00 +00002407
2408if test -z "$with_threads"
2409then with_threads="yes"
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002410fi
Barry Warsawc0d24d82000-06-29 16:12:00 +00002411AC_MSG_RESULT($with_threads)
Guido van Rossum6400c261997-05-22 20:34:27 +00002412
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002413AC_SUBST(THREADOBJ)
Barry Warsawc0d24d82000-06-29 16:12:00 +00002414if test "$with_threads" = "no"
2415then
2416 USE_THREAD_MODULE="#"
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002417elif test "$ac_cv_pthread_is_default" = yes
2418then
2419 AC_DEFINE(WITH_THREAD)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002420 # Defining _REENTRANT on system with POSIX threads should not hurt.
2421 AC_DEFINE(_REENTRANT)
2422 posix_threads=yes
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002423 THREADOBJ="Python/thread.o"
Martin v. Löwis130fb172001-07-19 11:00:41 +00002424elif test "$ac_cv_kpthread" = "yes"
2425then
2426 CC="$CC -Kpthread"
Martin v. Löwis519adae2003-09-20 10:47:47 +00002427 if test "$ac_cv_cxx_thread" = "yes"; then
2428 CXX="$CXX -Kpthread"
2429 fi
Martin v. Löwis130fb172001-07-19 11:00:41 +00002430 AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002431 posix_threads=yes
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002432 THREADOBJ="Python/thread.o"
Martin v. Löwis5f433f02003-05-05 05:05:30 +00002433elif test "$ac_cv_kthread" = "yes"
2434then
2435 CC="$CC -Kthread"
Martin v. Löwis519adae2003-09-20 10:47:47 +00002436 if test "$ac_cv_cxx_thread" = "yes"; then
2437 CXX="$CXX -Kthread"
2438 fi
Martin v. Löwis5f433f02003-05-05 05:05:30 +00002439 AC_DEFINE(WITH_THREAD)
2440 posix_threads=yes
2441 THREADOBJ="Python/thread.o"
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002442elif test "$ac_cv_pthread" = "yes"
2443then
2444 CC="$CC -pthread"
Martin v. Löwis519adae2003-09-20 10:47:47 +00002445 if test "$ac_cv_cxx_thread" = "yes"; then
2446 CXX="$CXX -pthread"
2447 fi
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002448 AC_DEFINE(WITH_THREAD)
2449 posix_threads=yes
2450 THREADOBJ="Python/thread.o"
Barry Warsawc0d24d82000-06-29 16:12:00 +00002451else
Martin v. Löwis130fb172001-07-19 11:00:41 +00002452 if test ! -z "$with_threads" -a -d "$with_threads"
2453 then LDFLAGS="$LDFLAGS -L$with_threads"
2454 fi
2455 if test ! -z "$withval" -a -d "$withval"
2456 then LDFLAGS="$LDFLAGS -L$withval"
2457 fi
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002458
2459 # According to the POSIX spec, a pthreads implementation must
Matthias Klosea2542be2004-08-16 11:35:51 +00002460 # define _POSIX_THREADS in unistd.h. Some apparently don't
2461 # (e.g. gnu pth with pthread emulation)
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002462 AC_MSG_CHECKING(for _POSIX_THREADS in unistd.h)
2463 AC_EGREP_CPP(yes,
Neal Norwitz6eb37f02003-02-23 23:28:15 +00002464 [
2465#include <unistd.h>
2466#ifdef _POSIX_THREADS
2467yes
2468#endif
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002469 ], unistd_defines_pthreads=yes, unistd_defines_pthreads=no)
2470 AC_MSG_RESULT($unistd_defines_pthreads)
2471
Martin v. Löwis130fb172001-07-19 11:00:41 +00002472 AC_DEFINE(_REENTRANT)
Martin v. Löwisa6e97582002-01-01 18:41:33 +00002473 AC_CHECK_HEADER(cthreads.h, [AC_DEFINE(WITH_THREAD)
2474 AC_DEFINE(C_THREADS)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002475 AC_DEFINE(HURD_C_THREADS, 1,
2476 [Define if you are using Mach cthreads directly under /include])
Martin v. Löwisa6e97582002-01-01 18:41:33 +00002477 LIBS="$LIBS -lthreads"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002478 THREADOBJ="Python/thread.o"],[
Martin v. Löwis130fb172001-07-19 11:00:41 +00002479 AC_CHECK_HEADER(mach/cthreads.h, [AC_DEFINE(WITH_THREAD)
2480 AC_DEFINE(C_THREADS)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002481 AC_DEFINE(MACH_C_THREADS, 1,
2482 [Define if you are using Mach cthreads under mach /])
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002483 THREADOBJ="Python/thread.o"],[
Martin v. Löwis130fb172001-07-19 11:00:41 +00002484 AC_MSG_CHECKING(for --with-pth)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002485 AC_ARG_WITH([pth],
Matthias Klose22520ea2010-05-08 10:14:46 +00002486 AS_HELP_STRING([--with-pth], [use GNU pth threading libraries]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002487 [AC_MSG_RESULT($withval)
2488 AC_DEFINE([WITH_THREAD])
2489 AC_DEFINE([HAVE_PTH], 1,
2490 [Define if you have GNU PTH threads.])
2491 LIBS="-lpth $LIBS"
2492 THREADOBJ="Python/thread.o"],
2493 [AC_MSG_RESULT(no)
Martin v. Löwis8158b5a2001-10-08 13:17:28 +00002494
2495 # Just looking for pthread_create in libpthread is not enough:
2496 # on HP/UX, pthread.h renames pthread_create to a different symbol name.
2497 # So we really have to include pthread.h, and then link.
2498 _libs=$LIBS
2499 LIBS="$LIBS -lpthread"
2500 AC_MSG_CHECKING([for pthread_create in -lpthread])
Stefan Krahae66ca62012-11-22 22:36:57 +01002501 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
2502#include <stdio.h>
2503#include <pthread.h>
Martin v. Löwis8158b5a2001-10-08 13:17:28 +00002504
Matthias Klosec511b472010-05-08 11:01:39 +00002505void * start_routine (void *arg) { exit (0); }]], [[
2506pthread_create (NULL, NULL, start_routine, NULL)]])],[
Martin v. Löwis8158b5a2001-10-08 13:17:28 +00002507 AC_MSG_RESULT(yes)
2508 AC_DEFINE(WITH_THREAD)
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002509 posix_threads=yes
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002510 THREADOBJ="Python/thread.o"],[
Martin v. Löwis8158b5a2001-10-08 13:17:28 +00002511 LIBS=$_libs
Martin v. Löwis130fb172001-07-19 11:00:41 +00002512 AC_CHECK_FUNC(pthread_detach, [AC_DEFINE(WITH_THREAD)
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002513 posix_threads=yes
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002514 THREADOBJ="Python/thread.o"],[
Martin v. Löwisf90ae202002-06-11 06:22:31 +00002515 AC_CHECK_HEADER(atheos/threads.h, [AC_DEFINE(WITH_THREAD)
2516 AC_DEFINE(ATHEOS_THREADS, 1,
2517 [Define this if you have AtheOS threads.])
2518 THREADOBJ="Python/thread.o"],[
Martin v. Löwis130fb172001-07-19 11:00:41 +00002519 AC_CHECK_HEADER(kernel/OS.h, [AC_DEFINE(WITH_THREAD)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002520 AC_DEFINE(BEOS_THREADS, 1,
2521 [Define this if you have BeOS threads.])
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002522 THREADOBJ="Python/thread.o"],[
Martin v. Löwis130fb172001-07-19 11:00:41 +00002523 AC_CHECK_LIB(pthreads, pthread_create, [AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002524 posix_threads=yes
Martin v. Löwis130fb172001-07-19 11:00:41 +00002525 LIBS="$LIBS -lpthreads"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002526 THREADOBJ="Python/thread.o"], [
Martin v. Löwis130fb172001-07-19 11:00:41 +00002527 AC_CHECK_LIB(c_r, pthread_create, [AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002528 posix_threads=yes
Martin v. Löwis130fb172001-07-19 11:00:41 +00002529 LIBS="$LIBS -lc_r"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002530 THREADOBJ="Python/thread.o"], [
Martin v. Löwis130fb172001-07-19 11:00:41 +00002531 AC_CHECK_LIB(pthread, __pthread_create_system, [AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002532 posix_threads=yes
Martin v. Löwis130fb172001-07-19 11:00:41 +00002533 LIBS="$LIBS -lpthread"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002534 THREADOBJ="Python/thread.o"], [
Martin v. Löwis130fb172001-07-19 11:00:41 +00002535 AC_CHECK_LIB(cma, pthread_create, [AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002536 posix_threads=yes
Martin v. Löwis130fb172001-07-19 11:00:41 +00002537 LIBS="$LIBS -lcma"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002538 THREADOBJ="Python/thread.o"],[
Martin v. Löwis130fb172001-07-19 11:00:41 +00002539 USE_THREAD_MODULE="#"])
Skip Montanarof8712e52004-01-17 03:04:46 +00002540 ])])])])])])])])])])
Barry Warsawc0d24d82000-06-29 16:12:00 +00002541
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002542 AC_CHECK_LIB(mpc, usconfig, [AC_DEFINE(WITH_THREAD)
2543 LIBS="$LIBS -lmpc"
2544 THREADOBJ="Python/thread.o"
2545 USE_THREAD_MODULE=""])
2546
2547 if test "$posix_threads" != "yes"; then
2548 AC_CHECK_LIB(thread, thr_create, [AC_DEFINE(WITH_THREAD)
2549 LIBS="$LIBS -lthread"
2550 THREADOBJ="Python/thread.o"
2551 USE_THREAD_MODULE=""])
2552 fi
2553
2554 if test "$USE_THREAD_MODULE" != "#"
2555 then
2556 # If the above checks didn't disable threads, (at least) OSF1
2557 # needs this '-threads' argument during linking.
2558 case $ac_sys_system in
2559 OSF1) LDLAST=-threads;;
2560 esac
2561 fi
2562fi
2563
2564if test "$posix_threads" = "yes"; then
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002565 if test "$unistd_defines_pthreads" = "no"; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002566 AC_DEFINE(_POSIX_THREADS, 1,
2567 [Define if you have POSIX threads,
2568 and your system does not define that.])
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002569 fi
2570
Martin v. Löwisdfc33fd2003-01-21 10:14:41 +00002571 # Bug 662787: Using semaphores causes unexplicable hangs on Solaris 8.
2572 case $ac_sys_system/$ac_sys_release in
Charles-François Natali4929eb92011-07-21 19:41:04 +02002573 SunOS/5.6) AC_DEFINE(HAVE_PTHREAD_DESTRUCTOR, 1,
Matthias Klose5183ebd2010-04-24 16:38:36 +00002574 [Defined for Solaris 2.6 bug in pthread header.])
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002575 ;;
Martin v. Löwisdfc33fd2003-01-21 10:14:41 +00002576 SunOS/5.8) AC_DEFINE(HAVE_BROKEN_POSIX_SEMAPHORES, 1,
Matthias Klose5183ebd2010-04-24 16:38:36 +00002577 [Define if the Posix semaphores do not work on your system])
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002578 ;;
Charles-François Natali4929eb92011-07-21 19:41:04 +02002579 AIX/*) AC_DEFINE(HAVE_BROKEN_POSIX_SEMAPHORES, 1,
Matthias Klose5183ebd2010-04-24 16:38:36 +00002580 [Define if the Posix semaphores do not work on your system])
Christian Heimescba36bb2008-01-30 22:54:18 +00002581 ;;
Martin v. Löwisdfc33fd2003-01-21 10:14:41 +00002582 esac
2583
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002584 AC_MSG_CHECKING(if PTHREAD_SCOPE_SYSTEM is supported)
2585 AC_CACHE_VAL(ac_cv_pthread_system_supported,
Stefan Krahae66ca62012-11-22 22:36:57 +01002586 [AC_RUN_IFELSE([AC_LANG_SOURCE([[
2587 #include <stdio.h>
2588 #include <pthread.h>
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002589 void *foo(void *parm) {
2590 return NULL;
2591 }
2592 main() {
2593 pthread_attr_t attr;
Martin v. Löwisa82d3472002-02-24 16:05:05 +00002594 pthread_t id;
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002595 if (pthread_attr_init(&attr)) exit(-1);
2596 if (pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM)) exit(-1);
Martin v. Löwisa82d3472002-02-24 16:05:05 +00002597 if (pthread_create(&id, &attr, foo, NULL)) exit(-1);
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002598 exit(0);
Matthias Klosec511b472010-05-08 11:01:39 +00002599 }]])],
2600 [ac_cv_pthread_system_supported=yes],
2601 [ac_cv_pthread_system_supported=no],
2602 [ac_cv_pthread_system_supported=no])
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002603 ])
2604 AC_MSG_RESULT($ac_cv_pthread_system_supported)
2605 if test "$ac_cv_pthread_system_supported" = "yes"; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002606 AC_DEFINE(PTHREAD_SYSTEM_SCHED_SUPPORTED, 1, [Defined if PTHREAD_SCOPE_SYSTEM supported.])
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002607 fi
Jason Tishlerfac083d2003-07-22 15:20:49 +00002608 AC_CHECK_FUNCS(pthread_sigmask,
2609 [case $ac_sys_system in
2610 CYGWIN*)
2611 AC_DEFINE(HAVE_BROKEN_PTHREAD_SIGMASK, 1,
2612 [Define if pthread_sigmask() does not work on your system.])
2613 ;;
2614 esac])
Christian Heimes0d604cf2013-08-21 13:26:05 +02002615 AC_CHECK_FUNCS(pthread_atfork)
Barry Warsawc0d24d82000-06-29 16:12:00 +00002616fi
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002617
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002618
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002619# Check for enable-ipv6
Martin v. Löwis11437992002-04-12 09:54:03 +00002620AH_TEMPLATE(ENABLE_IPV6, [Define if --enable-ipv6 is specified])
Martin v. Löwisa5f8bb52001-09-05 08:22:34 +00002621AC_MSG_CHECKING([if --enable-ipv6 is specified])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002622AC_ARG_ENABLE(ipv6,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002623[ --enable-ipv6 Enable ipv6 (with ipv4) support
2624 --disable-ipv6 Disable ipv6 support],
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002625[ case "$enableval" in
2626 no)
2627 AC_MSG_RESULT(no)
2628 ipv6=no
2629 ;;
2630 *) AC_MSG_RESULT(yes)
2631 AC_DEFINE(ENABLE_IPV6)
2632 ipv6=yes
2633 ;;
2634 esac ],
2635
Martin v. Löwisa5f8bb52001-09-05 08:22:34 +00002636[
2637dnl the check does not work on cross compilation case...
Charles-François Natalibe2b9072013-01-08 19:47:00 +01002638 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ /* AF_INET6 available check */
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002639#include <sys/types.h>
Charles-François Natalibe2b9072013-01-08 19:47:00 +01002640#include <sys/socket.h>]],
2641[[int domain = AF_INET6;]])],[
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002642 AC_MSG_RESULT(yes)
Matthias Klosec511b472010-05-08 11:01:39 +00002643 ipv6=yes
2644],[
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002645 AC_MSG_RESULT(no)
2646 ipv6=no
Matthias Klosec511b472010-05-08 11:01:39 +00002647])
Martin v. Löwisa5f8bb52001-09-05 08:22:34 +00002648
2649if test "$ipv6" = "yes"; then
2650 AC_MSG_CHECKING(if RFC2553 API is available)
Matthias Klosec511b472010-05-08 11:01:39 +00002651 AC_COMPILE_IFELSE([
2652 AC_LANG_PROGRAM([[#include <sys/types.h>
2653#include <netinet/in.h>]],
2654 [[struct sockaddr_in6 x;
2655 x.sin6_scope_id;]])
2656 ],[
2657 AC_MSG_RESULT(yes)
2658 ipv6=yes
2659 ],[
2660 AC_MSG_RESULT(no, IPv6 disabled)
2661 ipv6=no
2662 ])
Martin v. Löwisa5f8bb52001-09-05 08:22:34 +00002663fi
2664
2665if test "$ipv6" = "yes"; then
2666 AC_DEFINE(ENABLE_IPV6)
2667fi
2668])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002669
2670ipv6type=unknown
2671ipv6lib=none
2672ipv6trylibc=no
2673
2674if test "$ipv6" = "yes"; then
2675 AC_MSG_CHECKING([ipv6 stack type])
Guido van Rossumb8552162001-09-05 14:58:11 +00002676 for i in inria kame linux-glibc linux-inet6 solaris toshiba v6d zeta;
2677 do
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002678 case $i in
2679 inria)
2680 dnl http://www.kame.net/
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002681 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002682#include <netinet/in.h>
2683#ifdef IPV6_INRIA_VERSION
2684yes
2685#endif],
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002686 [ipv6type=$i])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002687 ;;
2688 kame)
2689 dnl http://www.kame.net/
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002690 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002691#include <netinet/in.h>
2692#ifdef __KAME__
2693yes
2694#endif],
2695 [ipv6type=$i;
2696 ipv6lib=inet6
2697 ipv6libdir=/usr/local/v6/lib
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002698 ipv6trylibc=yes])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002699 ;;
2700 linux-glibc)
2701 dnl http://www.v6.linux.or.jp/
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002702 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002703#include <features.h>
2704#if defined(__GLIBC__) && ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1) || (__GLIBC__ > 2))
2705yes
2706#endif],
2707 [ipv6type=$i;
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002708 ipv6trylibc=yes])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002709 ;;
2710 linux-inet6)
2711 dnl http://www.v6.linux.or.jp/
2712 if test -d /usr/inet6; then
2713 ipv6type=$i
2714 ipv6lib=inet6
2715 ipv6libdir=/usr/inet6/lib
Skip Montanarodecc6a42003-01-01 20:07:49 +00002716 BASECFLAGS="-I/usr/inet6/include $BASECFLAGS"
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002717 fi
2718 ;;
2719 solaris)
2720 if test -f /etc/netconfig; then
Antoine Pitrou31e85952011-01-03 18:57:14 +00002721 if $GREP -q tcp6 /etc/netconfig; then
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002722 ipv6type=$i
2723 ipv6trylibc=yes
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002724 fi
2725 fi
2726 ;;
2727 toshiba)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002728 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002729#include <sys/param.h>
2730#ifdef _TOSHIBA_INET6
2731yes
2732#endif],
2733 [ipv6type=$i;
2734 ipv6lib=inet6;
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002735 ipv6libdir=/usr/local/v6/lib])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002736 ;;
2737 v6d)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002738 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002739#include </usr/local/v6/include/sys/v6config.h>
2740#ifdef __V6D__
2741yes
2742#endif],
2743 [ipv6type=$i;
2744 ipv6lib=v6;
2745 ipv6libdir=/usr/local/v6/lib;
Skip Montanarodecc6a42003-01-01 20:07:49 +00002746 BASECFLAGS="-I/usr/local/v6/include $BASECFLAGS"])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002747 ;;
2748 zeta)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002749 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002750#include <sys/param.h>
2751#ifdef _ZETA_MINAMI_INET6
2752yes
2753#endif],
2754 [ipv6type=$i;
2755 ipv6lib=inet6;
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002756 ipv6libdir=/usr/local/v6/lib])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002757 ;;
2758 esac
2759 if test "$ipv6type" != "unknown"; then
2760 break
2761 fi
2762 done
2763 AC_MSG_RESULT($ipv6type)
2764fi
2765
2766if test "$ipv6" = "yes" -a "$ipv6lib" != "none"; then
2767 if test -d $ipv6libdir -a -f $ipv6libdir/lib$ipv6lib.a; then
2768 LIBS="-L$ipv6libdir -l$ipv6lib $LIBS"
2769 echo "using lib$ipv6lib"
2770 else
2771 if test $ipv6trylibc = "yes"; then
2772 echo "using libc"
2773 else
2774 echo 'Fatal: no $ipv6lib library found. cannot continue.'
2775 echo "You need to fetch lib$ipv6lib.a from appropriate"
2776 echo 'ipv6 kit and compile beforehand.'
2777 exit 1
2778 fi
2779 fi
2780fi
2781
Ronald Oussoren0d236eb2008-06-06 21:31:33 +00002782AC_MSG_CHECKING(for OSX 10.5 SDK or later)
Matthias Klosec511b472010-05-08 11:01:39 +00002783AC_COMPILE_IFELSE([
Mark Dickinson0712b562010-05-08 19:13:21 +00002784 AC_LANG_PROGRAM([[#include <Carbon/Carbon.h>]], [[FSIORefNum fRef = 0]])
Matthias Klosec511b472010-05-08 11:01:39 +00002785],[
Matthias Klose5183ebd2010-04-24 16:38:36 +00002786 AC_DEFINE(HAVE_OSX105_SDK, 1, [Define if compiling using MacOS X 10.5 SDK or later.])
Matthias Klosec511b472010-05-08 11:01:39 +00002787 AC_MSG_RESULT(yes)
2788],[
Ronald Oussoren0d236eb2008-06-06 21:31:33 +00002789 AC_MSG_RESULT(no)
Matthias Klosec511b472010-05-08 11:01:39 +00002790])
Ronald Oussoren0d236eb2008-06-06 21:31:33 +00002791
Martin v. Löwisa3fb4f72002-06-09 13:33:54 +00002792# Check for --with-doc-strings
2793AC_MSG_CHECKING(for --with-doc-strings)
2794AC_ARG_WITH(doc-strings,
Matthias Klose22520ea2010-05-08 10:14:46 +00002795 AS_HELP_STRING([--with(out)-doc-strings], [disable/enable documentation strings]))
Martin v. Löwisa3fb4f72002-06-09 13:33:54 +00002796
2797if test -z "$with_doc_strings"
2798then with_doc_strings="yes"
2799fi
2800if test "$with_doc_strings" != "no"
2801then
2802 AC_DEFINE(WITH_DOC_STRINGS, 1,
2803 [Define if you want documentation strings in extension modules])
2804fi
2805AC_MSG_RESULT($with_doc_strings)
2806
Neil Schemenauera35c6882001-02-27 04:45:05 +00002807# Check for Python-specific malloc support
Martin v. Löwisf30d60e2004-06-08 08:17:44 +00002808AC_MSG_CHECKING(for --with-tsc)
2809AC_ARG_WITH(tsc,
Matthias Klose22520ea2010-05-08 10:14:46 +00002810 AS_HELP_STRING([--with(out)-tsc],[enable/disable timestamp counter profile]),[
Martin v. Löwisf30d60e2004-06-08 08:17:44 +00002811if test "$withval" != no
2812then
2813 AC_DEFINE(WITH_TSC, 1,
2814 [Define to profile with the Pentium timestamp counter])
2815 AC_MSG_RESULT(yes)
2816else AC_MSG_RESULT(no)
2817fi],
2818[AC_MSG_RESULT(no)])
2819
2820# Check for Python-specific malloc support
Neil Schemenauera35c6882001-02-27 04:45:05 +00002821AC_MSG_CHECKING(for --with-pymalloc)
2822AC_ARG_WITH(pymalloc,
Matthias Klose22520ea2010-05-08 10:14:46 +00002823 AS_HELP_STRING([--with(out)-pymalloc], [disable/enable specialized mallocs]))
Neil Schemenauer16c22972002-03-22 15:34:49 +00002824
2825if test -z "$with_pymalloc"
2826then with_pymalloc="yes"
2827fi
2828if test "$with_pymalloc" != "no"
2829then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002830 AC_DEFINE(WITH_PYMALLOC, 1,
2831 [Define if you want to compile in Python-specific mallocs])
Neil Schemenauer16c22972002-03-22 15:34:49 +00002832fi
2833AC_MSG_RESULT($with_pymalloc)
Neil Schemenauera35c6882001-02-27 04:45:05 +00002834
Benjamin Peterson91c12eb2009-12-03 02:52:39 +00002835# Check for Valgrind support
2836AC_MSG_CHECKING([for --with-valgrind])
2837AC_ARG_WITH([valgrind],
Matthias Klose22520ea2010-05-08 10:14:46 +00002838 AS_HELP_STRING([--with-valgrind], [Enable Valgrind support]),,
Benjamin Peterson91c12eb2009-12-03 02:52:39 +00002839 with_valgrind=no)
2840AC_MSG_RESULT([$with_valgrind])
2841if test "$with_valgrind" != no; then
2842 AC_CHECK_HEADER([valgrind/valgrind.h],
2843 [AC_DEFINE([WITH_VALGRIND], 1, [Define if you want pymalloc to be disabled when running under valgrind])],
2844 [AC_MSG_ERROR([Valgrind support requested but headers not available])]
2845 )
2846fi
2847
Barry Warsawef82cd72000-06-30 16:21:01 +00002848# Check for --with-wctype-functions
2849AC_MSG_CHECKING(for --with-wctype-functions)
2850AC_ARG_WITH(wctype-functions,
Matthias Klose22520ea2010-05-08 10:14:46 +00002851 AS_HELP_STRING([--with-wctype-functions], [use wctype.h functions]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002852[
Barry Warsawef82cd72000-06-30 16:21:01 +00002853if test "$withval" != no
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002854then
2855 AC_DEFINE(WANT_WCTYPE_FUNCTIONS, 1,
2856 [Define if you want wctype.h functions to be used instead of the
2857 one supplied by Python itself. (see Include/unicodectype.h).])
2858 AC_MSG_RESULT(yes)
Barry Warsawef82cd72000-06-30 16:21:01 +00002859else AC_MSG_RESULT(no)
2860fi],
2861[AC_MSG_RESULT(no)])
2862
Guido van Rossum68242b51996-05-28 22:53:03 +00002863# -I${DLINCLDIR} is added to the compile rule for importdl.o
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002864AC_SUBST(DLINCLDIR)
Guido van Rossum98935bf2001-09-05 19:13:16 +00002865DLINCLDIR=.
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002866
Guido van Rossume97ee181999-12-20 21:27:22 +00002867# the dlopen() function means we might want to use dynload_shlib.o. some
2868# platforms, such as AIX, have dlopen(), but don't want to use it.
Thomas Wouters3a584202000-08-05 23:28:51 +00002869AC_CHECK_FUNCS(dlopen)
Guido van Rossume97ee181999-12-20 21:27:22 +00002870
2871# DYNLOADFILE specifies which dynload_*.o file we will use for dynamic
2872# loading of modules.
2873AC_SUBST(DYNLOADFILE)
2874AC_MSG_CHECKING(DYNLOADFILE)
2875if test -z "$DYNLOADFILE"
2876then
2877 case $ac_sys_system/$ac_sys_release in
Martin v. Löwisc19c5a62003-11-18 20:00:44 +00002878 AIX*) # Use dynload_shlib.c and dlopen() if we have it; otherwise dynload_aix.c
2879 if test "$ac_cv_func_dlopen" = yes
2880 then DYNLOADFILE="dynload_shlib.o"
2881 else DYNLOADFILE="dynload_aix.o"
2882 fi
2883 ;;
Guido van Rossume97ee181999-12-20 21:27:22 +00002884 BeOS*) DYNLOADFILE="dynload_beos.o";;
2885 hp*|HP*) DYNLOADFILE="dynload_hpux.o";;
Anthony Baxter82201742006-04-09 15:07:40 +00002886 # Use dynload_next.c only on 10.2 and below, which don't have native dlopen()
2887 Darwin/@<:@0156@:>@\..*) DYNLOADFILE="dynload_next.o";;
Martin v. Löwisf90ae202002-06-11 06:22:31 +00002888 atheos*) DYNLOADFILE="dynload_atheos.o";;
Guido van Rossume97ee181999-12-20 21:27:22 +00002889 *)
2890 # use dynload_shlib.c and dlopen() if we have it; otherwise stub
2891 # out any dynamic loading
2892 if test "$ac_cv_func_dlopen" = yes
2893 then DYNLOADFILE="dynload_shlib.o"
2894 else DYNLOADFILE="dynload_stub.o"
2895 fi
2896 ;;
2897 esac
2898fi
2899AC_MSG_RESULT($DYNLOADFILE)
2900if test "$DYNLOADFILE" != "dynload_stub.o"
2901then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002902 AC_DEFINE(HAVE_DYNAMIC_LOADING, 1,
2903 [Defined when any dynamic module loading is enabled.])
Guido van Rossume97ee181999-12-20 21:27:22 +00002904fi
2905
Jack Jansenc49e5b72001-06-19 15:00:23 +00002906# MACHDEP_OBJS can be set to platform-specific object files needed by Python
2907
2908AC_SUBST(MACHDEP_OBJS)
2909AC_MSG_CHECKING(MACHDEP_OBJS)
2910if test -z "$MACHDEP_OBJS"
2911then
Jack Jansenb6e9cad2001-08-15 01:26:28 +00002912 MACHDEP_OBJS=$extra_machdep_objs
2913else
2914 MACHDEP_OBJS="$MACHDEP_OBJS $extra_machdep_objs"
Jack Jansenc49e5b72001-06-19 15:00:23 +00002915fi
Jack Jansenb6e9cad2001-08-15 01:26:28 +00002916AC_MSG_RESULT(MACHDEP_OBJS)
Jack Jansenc49e5b72001-06-19 15:00:23 +00002917
Guido van Rossum627b2d71993-12-24 10:39:16 +00002918# checks for library functions
Martin v. Löwisaef18b12008-03-24 13:31:16 +00002919AC_CHECK_FUNCS(alarm setitimer getitimer bind_textdomain_codeset chown \
2920 clock confstr ctermid execv fchmod fchown fork fpathconf ftime ftruncate \
Martin v. Löwis438b5342002-12-27 10:16:42 +00002921 gai_strerror getgroups getlogin getloadavg getpeername getpgid getpid \
Benjamin Peterson27c269a2014-12-26 11:09:00 -06002922 getentropy \
Martin v. Löwis50ea4562009-11-27 13:56:01 +00002923 getpriority getresuid getresgid getpwent getspnam getspent getsid getwd \
Benjamin Petersond16e01c2014-02-04 10:20:26 -05002924 initgroups kill killpg lchmod lchown lstat mkfifo mknod mktime mmap \
Martin v. Löwisa5f09072002-10-11 05:37:59 +00002925 mremap nice pathconf pause plock poll pthread_init \
Guido van Rossum162e38c2003-02-19 15:25:10 +00002926 putenv readlink realpath \
Jesse Noller355b1262009-04-02 00:03:28 +00002927 select sem_open sem_timedwait sem_getvalue sem_unlink setegid seteuid \
2928 setgid \
Martin v. Löwis4daacb12003-03-28 18:37:01 +00002929 setlocale setregid setreuid setsid setpgid setpgrp setuid setvbuf snprintf \
Martin v. Löwis50ea4562009-11-27 13:56:01 +00002930 setlocale setregid setreuid setresuid setresgid \
2931 setsid setpgid setpgrp setuid setvbuf snprintf \
Skip Montanaro7e11a012004-02-07 12:55:46 +00002932 sigaction siginterrupt sigrelse strftime \
Michael W. Hudson34f20ea2002-05-27 15:08:24 +00002933 sysconf tcgetpgrp tcsetpgrp tempnam timegm times tmpfile tmpnam tmpnam_r \
Neal Norwitz05a45592006-03-20 06:30:08 +00002934 truncate uname unsetenv utimes waitpid wait3 wait4 wcscoll _getpty)
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00002935
Martin v. Löwisc8ad7cc2002-11-11 13:23:45 +00002936# For some functions, having a definition is not sufficient, since
2937# we want to take their address.
2938AC_MSG_CHECKING(for chroot)
Matthias Klosec511b472010-05-08 11:01:39 +00002939AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[void *x=chroot]])],
2940 [AC_DEFINE(HAVE_CHROOT, 1, Define if you have the 'chroot' function.)
2941 AC_MSG_RESULT(yes)],
2942 [AC_MSG_RESULT(no)
2943])
Martin v. Löwisc8ad7cc2002-11-11 13:23:45 +00002944AC_MSG_CHECKING(for link)
Matthias Klosec511b472010-05-08 11:01:39 +00002945AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[void *x=link]])],
2946 [AC_DEFINE(HAVE_LINK, 1, Define if you have the 'link' function.)
2947 AC_MSG_RESULT(yes)],
2948 [AC_MSG_RESULT(no)
2949])
Martin v. Löwisc8ad7cc2002-11-11 13:23:45 +00002950AC_MSG_CHECKING(for symlink)
Matthias Klosec511b472010-05-08 11:01:39 +00002951AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[void *x=symlink]])],
2952 [AC_DEFINE(HAVE_SYMLINK, 1, Define if you have the 'symlink' function.)
2953 AC_MSG_RESULT(yes)],
2954 [AC_MSG_RESULT(no)
2955])
Martin v. Löwisa64988c2003-09-20 15:30:20 +00002956AC_MSG_CHECKING(for fchdir)
Matthias Klosec511b472010-05-08 11:01:39 +00002957AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[void *x=fchdir]])],
2958 [AC_DEFINE(HAVE_FCHDIR, 1, Define if you have the 'fchdir' function.)
2959 AC_MSG_RESULT(yes)],
2960 [AC_MSG_RESULT(no)
2961])
Martin v. Löwisa64988c2003-09-20 15:30:20 +00002962AC_MSG_CHECKING(for fsync)
Matthias Klosec511b472010-05-08 11:01:39 +00002963AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[void *x=fsync]])],
2964 [AC_DEFINE(HAVE_FSYNC, 1, Define if you have the 'fsync' function.)
2965 AC_MSG_RESULT(yes)],
2966 [AC_MSG_RESULT(no)
2967])
Martin v. Löwisa64988c2003-09-20 15:30:20 +00002968AC_MSG_CHECKING(for fdatasync)
Matthias Klosec511b472010-05-08 11:01:39 +00002969AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[void *x=fdatasync]])],
2970 [AC_DEFINE(HAVE_FDATASYNC, 1, Define if you have the 'fdatasync' function.)
2971 AC_MSG_RESULT(yes)],
2972 [AC_MSG_RESULT(no)
2973])
Christian Heimes0e9ab5f2008-03-21 23:49:44 +00002974AC_MSG_CHECKING(for epoll)
Matthias Klosec511b472010-05-08 11:01:39 +00002975AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/epoll.h>]], [[void *x=epoll_create]])],
2976 [AC_DEFINE(HAVE_EPOLL, 1, Define if you have the 'epoll' functions.)
2977 AC_MSG_RESULT(yes)],
2978 [AC_MSG_RESULT(no)
2979])
Christian Heimes0e9ab5f2008-03-21 23:49:44 +00002980AC_MSG_CHECKING(for kqueue)
Matthias Klosec511b472010-05-08 11:01:39 +00002981AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Christian Heimes0e9ab5f2008-03-21 23:49:44 +00002982#include <sys/types.h>
2983#include <sys/event.h>
Matthias Klosec511b472010-05-08 11:01:39 +00002984 ]], [[int x=kqueue()]])],
2985 [AC_DEFINE(HAVE_KQUEUE, 1, Define if you have the 'kqueue' functions.)
2986 AC_MSG_RESULT(yes)],
2987 [AC_MSG_RESULT(no)
2988])
Martin v. Löwisd5843682002-11-21 20:41:28 +00002989# On some systems (eg. FreeBSD 5), we would find a definition of the
2990# functions ctermid_r, setgroups in the library, but no prototype
2991# (e.g. because we use _XOPEN_SOURCE). See whether we can take their
2992# address to avoid compiler warnings and potential miscompilations
2993# because of the missing prototypes.
2994
2995AC_MSG_CHECKING(for ctermid_r)
Matthias Klosec511b472010-05-08 11:01:39 +00002996AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwisd5843682002-11-21 20:41:28 +00002997#include <stdio.h>
Matthias Klosec511b472010-05-08 11:01:39 +00002998]], [[void* p = ctermid_r]])],
2999 [AC_DEFINE(HAVE_CTERMID_R, 1, Define if you have the 'ctermid_r' function.)
3000 AC_MSG_RESULT(yes)],
3001 [AC_MSG_RESULT(no)
3002])
Martin v. Löwisd5843682002-11-21 20:41:28 +00003003
Antoine Pitroub170f172010-09-10 18:47:36 +00003004AC_CACHE_CHECK([for flock declaration], [ac_cv_flock_decl],
3005 [AC_COMPILE_IFELSE(
3006 [AC_LANG_PROGRAM(
3007 [#include <sys/file.h>],
3008 [void* p = flock]
3009 )],
3010 [ac_cv_flock_decl=yes],
3011 [ac_cv_flock_decl=no]
3012 )
Matthias Klosec511b472010-05-08 11:01:39 +00003013])
Antoine Pitroub170f172010-09-10 18:47:36 +00003014if test "x${ac_cv_flock_decl}" = xyes; then
3015 AC_CHECK_FUNCS(flock,,
3016 AC_CHECK_LIB(bsd,flock,
3017 [AC_DEFINE(HAVE_FLOCK)
3018 AC_DEFINE(FLOCK_NEEDS_LIBBSD, 1, Define if flock needs to be linked with bsd library.)
3019 ])
3020 )
Antoine Pitrou85729812010-09-07 14:55:24 +00003021fi
Martin v. Löwisf26d63b2003-03-30 17:23:49 +00003022
3023AC_MSG_CHECKING(for getpagesize)
Matthias Klosec511b472010-05-08 11:01:39 +00003024AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwisf26d63b2003-03-30 17:23:49 +00003025#include <unistd.h>
Matthias Klosec511b472010-05-08 11:01:39 +00003026]], [[void* p = getpagesize]])],
3027 [AC_DEFINE(HAVE_GETPAGESIZE, 1, Define if you have the 'getpagesize' function.)
3028 AC_MSG_RESULT(yes)],
3029 [AC_MSG_RESULT(no)
3030])
Martin v. Löwisf26d63b2003-03-30 17:23:49 +00003031
Charles-François Natali93a11752011-11-27 13:01:35 +01003032AC_MSG_CHECKING(for broken unsetenv)
3033AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3034#include <stdlib.h>
3035]], [[int res = unsetenv("DUMMY")]])],
3036 [AC_MSG_RESULT(no)],
3037 [AC_DEFINE(HAVE_BROKEN_UNSETENV, 1, Define if `unsetenv` does not return an int.)
3038 AC_MSG_RESULT(yes)
3039])
3040
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00003041dnl check for true
3042AC_CHECK_PROGS(TRUE, true, /bin/true)
3043
Martin v. Löwis95c419b2003-05-03 12:10:48 +00003044dnl On some systems (e.g. Solaris 9), hstrerror and inet_aton are in -lresolv
3045dnl On others, they are in the C library, so we to take no action
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00003046AC_CHECK_LIB(c, inet_aton, [$ac_cv_prog_TRUE],
Martin v. Löwis95c419b2003-05-03 12:10:48 +00003047 AC_CHECK_LIB(resolv, inet_aton)
3048)
3049
Martin v. Löwisa51d5c82007-12-04 08:37:59 +00003050# On Tru64, chflags seems to be present, but calling it will
3051# exit Python
Gregory P. Smithbb213892009-11-02 01:37:37 +00003052AC_CACHE_CHECK([for chflags], [ac_cv_have_chflags], [dnl
Ned Deily43e10542011-06-27 23:41:53 -07003053AC_RUN_IFELSE([AC_LANG_SOURCE([[
Martin v. Löwisa51d5c82007-12-04 08:37:59 +00003054#include <sys/stat.h>
3055#include <unistd.h>
3056int main(int argc, char*argv[])
3057{
3058 if(chflags(argv[0], 0) != 0)
3059 return 1;
3060 return 0;
3061}
Ned Deily43e10542011-06-27 23:41:53 -07003062]])],
Matthias Klosec511b472010-05-08 11:01:39 +00003063[ac_cv_have_chflags=yes],
3064[ac_cv_have_chflags=no],
3065[ac_cv_have_chflags=cross])
Gregory P. Smithbb213892009-11-02 01:37:37 +00003066])
3067if test "$ac_cv_have_chflags" = cross ; then
3068 AC_CHECK_FUNC([chflags], [ac_cv_have_chflags="yes"], [ac_cv_have_chflags="no"])
3069fi
3070if test "$ac_cv_have_chflags" = yes ; then
Ned Deily43e10542011-06-27 23:41:53 -07003071 AC_DEFINE(HAVE_CHFLAGS, 1, [Define to 1 if you have the 'chflags' function.])
Alexandre Vassalotti00900892009-07-17 05:26:39 +00003072fi
Martin v. Löwisa51d5c82007-12-04 08:37:59 +00003073
Gregory P. Smithbb213892009-11-02 01:37:37 +00003074AC_CACHE_CHECK([for lchflags], [ac_cv_have_lchflags], [dnl
Ned Deily43e10542011-06-27 23:41:53 -07003075AC_RUN_IFELSE([AC_LANG_SOURCE([[
Martin v. Löwisa51d5c82007-12-04 08:37:59 +00003076#include <sys/stat.h>
3077#include <unistd.h>
3078int main(int argc, char*argv[])
3079{
3080 if(lchflags(argv[0], 0) != 0)
3081 return 1;
3082 return 0;
3083}
Ned Deily43e10542011-06-27 23:41:53 -07003084]])],[ac_cv_have_lchflags=yes],[ac_cv_have_lchflags=no],[ac_cv_have_lchflags=cross])
Gregory P. Smithbb213892009-11-02 01:37:37 +00003085])
3086if test "$ac_cv_have_lchflags" = cross ; then
3087 AC_CHECK_FUNC([lchflags], [ac_cv_have_lchflags="yes"], [ac_cv_have_lchflags="no"])
3088fi
3089if test "$ac_cv_have_lchflags" = yes ; then
Ned Deily43e10542011-06-27 23:41:53 -07003090 AC_DEFINE(HAVE_LCHFLAGS, 1, [Define to 1 if you have the 'lchflags' function.])
Alexandre Vassalotti00900892009-07-17 05:26:39 +00003091fi
Martin v. Löwisa51d5c82007-12-04 08:37:59 +00003092
Neal Norwitz6e73aaa2006-06-12 03:33:09 +00003093dnl Check if system zlib has *Copy() functions
Ronald Oussorenf8752642006-07-06 10:13:35 +00003094dnl
3095dnl On MacOSX the linker will search for dylibs on the entire linker path
3096dnl before searching for static libraries. setup.py adds -Wl,-search_paths_first
3097dnl to revert to a more traditional unix behaviour and make it possible to
3098dnl override the system libz with a local static library of libz. Temporarily
3099dnl add that flag to our CFLAGS as well to ensure that we check the version
3100dnl of libz that will be used by setup.py.
3101dnl The -L/usr/local/lib is needed as wel to get the same compilation
3102dnl environment as setup.py (and leaving it out can cause configure to use the
3103dnl wrong version of the library)
3104case $ac_sys_system/$ac_sys_release in
3105Darwin/*)
3106 _CUR_CFLAGS="${CFLAGS}"
3107 _CUR_LDFLAGS="${LDFLAGS}"
3108 CFLAGS="${CFLAGS} -Wl,-search_paths_first"
3109 LDFLAGS="${LDFLAGS} -Wl,-search_paths_first -L/usr/local/lib"
3110 ;;
3111esac
3112
Matthias Klose5183ebd2010-04-24 16:38:36 +00003113AC_CHECK_LIB(z, inflateCopy, AC_DEFINE(HAVE_ZLIB_COPY, 1, [Define if the zlib library has inflateCopy]))
Neal Norwitz6e73aaa2006-06-12 03:33:09 +00003114
Ronald Oussorenf8752642006-07-06 10:13:35 +00003115case $ac_sys_system/$ac_sys_release in
3116Darwin/*)
3117 CFLAGS="${_CUR_CFLAGS}"
3118 LDFLAGS="${_CUR_LDFLAGS}"
3119 ;;
3120esac
3121
Martin v. Löwise9416172003-05-03 10:12:45 +00003122AC_MSG_CHECKING(for hstrerror)
Matthias Klosec511b472010-05-08 11:01:39 +00003123AC_LINK_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwise9416172003-05-03 10:12:45 +00003124#include <netdb.h>
Matthias Klosec511b472010-05-08 11:01:39 +00003125]], [[void* p = hstrerror; hstrerror(0)]])],
3126 [AC_DEFINE(HAVE_HSTRERROR, 1, Define if you have the 'hstrerror' function.)
3127 AC_MSG_RESULT(yes)],
3128 [AC_MSG_RESULT(no)
3129])
Martin v. Löwise9416172003-05-03 10:12:45 +00003130
3131AC_MSG_CHECKING(for inet_aton)
Matthias Klosec511b472010-05-08 11:01:39 +00003132AC_LINK_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwis86d66262006-02-17 08:40:11 +00003133#include <sys/types.h>
Martin v. Löwise9416172003-05-03 10:12:45 +00003134#include <sys/socket.h>
3135#include <netinet/in.h>
3136#include <arpa/inet.h>
Matthias Klosec511b472010-05-08 11:01:39 +00003137]], [[void* p = inet_aton;inet_aton(0,0)]])],
3138 [AC_DEFINE(HAVE_INET_ATON, 1, Define if you have the 'inet_aton' function.)
3139 AC_MSG_RESULT(yes)],
3140 [AC_MSG_RESULT(no)
3141])
Martin v. Löwise9416172003-05-03 10:12:45 +00003142
3143AC_MSG_CHECKING(for inet_pton)
Matthias Klosec511b472010-05-08 11:01:39 +00003144AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwisf2e488d2003-05-05 22:00:11 +00003145#include <sys/types.h>
Martin v. Löwise9416172003-05-03 10:12:45 +00003146#include <sys/socket.h>
3147#include <netinet/in.h>
3148#include <arpa/inet.h>
Matthias Klosec511b472010-05-08 11:01:39 +00003149]], [[void* p = inet_pton]])],
3150 [AC_DEFINE(HAVE_INET_PTON, 1, Define if you have the 'inet_pton' function.)
3151 AC_MSG_RESULT(yes)],
3152 [AC_MSG_RESULT(no)
3153])
Martin v. Löwise9416172003-05-03 10:12:45 +00003154
Martin v. Löwisd6640d42003-07-06 09:29:52 +00003155# On some systems, setgroups is in unistd.h, on others, in grp.h
Martin v. Löwisd5843682002-11-21 20:41:28 +00003156AC_MSG_CHECKING(for setgroups)
Matthias Klosec511b472010-05-08 11:01:39 +00003157AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwisf2e488d2003-05-05 22:00:11 +00003158#include <unistd.h>
Martin v. Löwisd6640d42003-07-06 09:29:52 +00003159#ifdef HAVE_GRP_H
3160#include <grp.h>
3161#endif
Matthias Klosec511b472010-05-08 11:01:39 +00003162]], [[void* p = setgroups]])],
3163 [AC_DEFINE(HAVE_SETGROUPS, 1, Define if you have the 'setgroups' function.)
3164 AC_MSG_RESULT(yes)],
3165 [AC_MSG_RESULT(no)
3166])
Martin v. Löwisd5843682002-11-21 20:41:28 +00003167
Fred Drake8cef4cf2000-06-28 16:40:38 +00003168# check for openpty and forkpty
3169
Martin v. Löwisfd9a72a2006-01-08 10:07:33 +00003170AC_CHECK_FUNCS(openpty,,
3171 AC_CHECK_LIB(util,openpty,
3172 [AC_DEFINE(HAVE_OPENPTY) LIBS="$LIBS -lutil"],
3173 AC_CHECK_LIB(bsd,openpty, [AC_DEFINE(HAVE_OPENPTY) LIBS="$LIBS -lbsd"])
3174 )
3175)
3176AC_CHECK_FUNCS(forkpty,,
3177 AC_CHECK_LIB(util,forkpty,
3178 [AC_DEFINE(HAVE_FORKPTY) LIBS="$LIBS -lutil"],
3179 AC_CHECK_LIB(bsd,forkpty, [AC_DEFINE(HAVE_FORKPTY) LIBS="$LIBS -lbsd"])
3180 )
3181)
Fred Drake8cef4cf2000-06-28 16:40:38 +00003182
Brett Cannonaa5778d2008-03-18 04:09:00 +00003183# Stuff for expat.
3184AC_CHECK_FUNCS(memmove)
3185
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00003186# check for long file support functions
3187AC_CHECK_FUNCS(fseek64 fseeko fstatvfs ftell64 ftello statvfs)
3188
Brett Cannonaa5778d2008-03-18 04:09:00 +00003189AC_REPLACE_FUNCS(dup2 getcwd strdup)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003190AC_CHECK_FUNCS(getpgrp,
Matthias Klosec511b472010-05-08 11:01:39 +00003191 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[getpgrp(0);]])],
3192 [AC_DEFINE(GETPGRP_HAVE_ARG, 1, [Define if getpgrp() must be called as getpgrp(0).])],
3193 [])
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003194)
Jack Jansen150753c2003-03-29 22:07:47 +00003195AC_CHECK_FUNCS(setpgrp,
Matthias Klosec511b472010-05-08 11:01:39 +00003196 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[setpgrp(0,0);]])],
3197 [AC_DEFINE(SETPGRP_HAVE_ARG, 1, [Define if setpgrp() must be called as setpgrp(0, 0).])],
3198 [])
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003199)
3200AC_CHECK_FUNCS(gettimeofday,
Matthias Klosec511b472010-05-08 11:01:39 +00003201 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/time.h>]],
3202 [[gettimeofday((struct timeval*)0,(struct timezone*)0);]])],
3203 [],
3204 [AC_DEFINE(GETTIMEOFDAY_NO_TZ, 1,
3205 [Define if gettimeofday() does not have second (timezone) argument
3206 This is the case on Motorola V4 (R40V4.2)])
3207 ])
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003208)
Guido van Rossum627b2d71993-12-24 10:39:16 +00003209
Martin v. Löwisdbe3f762002-10-10 14:27:30 +00003210AC_MSG_CHECKING(for major, minor, and makedev)
Matthias Klosec511b472010-05-08 11:01:39 +00003211AC_LINK_IFELSE([AC_LANG_PROGRAM([[
Neal Norwitz6eb37f02003-02-23 23:28:15 +00003212#if defined(MAJOR_IN_MKDEV)
3213#include <sys/mkdev.h>
3214#elif defined(MAJOR_IN_SYSMACROS)
3215#include <sys/sysmacros.h>
3216#else
3217#include <sys/types.h>
3218#endif
Matthias Klosec511b472010-05-08 11:01:39 +00003219]], [[
Martin v. Löwisdbe3f762002-10-10 14:27:30 +00003220 makedev(major(0),minor(0));
Matthias Klosec511b472010-05-08 11:01:39 +00003221]])],[
Martin v. Löwisdbe3f762002-10-10 14:27:30 +00003222 AC_DEFINE(HAVE_DEVICE_MACROS, 1,
3223 [Define to 1 if you have the device macros.])
3224 AC_MSG_RESULT(yes)
3225],[
3226 AC_MSG_RESULT(no)
3227])
Martin v. Löwis861a65b2001-10-24 14:36:00 +00003228
3229# On OSF/1 V5.1, getaddrinfo is available, but a define
3230# for [no]getaddrinfo in netdb.h.
3231AC_MSG_CHECKING(for getaddrinfo)
Matthias Klosec511b472010-05-08 11:01:39 +00003232AC_LINK_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwisc010b6d2001-11-09 17:50:52 +00003233#include <sys/types.h>
Martin v. Löwis861a65b2001-10-24 14:36:00 +00003234#include <sys/socket.h>
3235#include <netdb.h>
Martin v. Löwisc010b6d2001-11-09 17:50:52 +00003236#include <stdio.h>
Matthias Klosec511b472010-05-08 11:01:39 +00003237]], [[getaddrinfo(NULL, NULL, NULL, NULL);]])],
3238[have_getaddrinfo=yes],
3239[have_getaddrinfo=no])
Alexandre Vassalotti00900892009-07-17 05:26:39 +00003240AC_MSG_RESULT($have_getaddrinfo)
3241if test $have_getaddrinfo = yes
3242then
3243 AC_MSG_CHECKING(getaddrinfo bug)
3244 AC_CACHE_VAL(ac_cv_buggy_getaddrinfo,
Matthias Klosec511b472010-05-08 11:01:39 +00003245 AC_RUN_IFELSE([AC_LANG_SOURCE([[[
Stefan Krah0afe4e42012-11-22 23:56:51 +01003246#include <stdio.h>
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003247#include <sys/types.h>
3248#include <netdb.h>
3249#include <string.h>
3250#include <sys/socket.h>
3251#include <netinet/in.h>
3252
Alexandre Vassalotti00900892009-07-17 05:26:39 +00003253int main()
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003254{
3255 int passive, gaierr, inet4 = 0, inet6 = 0;
3256 struct addrinfo hints, *ai, *aitop;
3257 char straddr[INET6_ADDRSTRLEN], strport[16];
3258
3259 for (passive = 0; passive <= 1; passive++) {
3260 memset(&hints, 0, sizeof(hints));
3261 hints.ai_family = AF_UNSPEC;
3262 hints.ai_flags = passive ? AI_PASSIVE : 0;
3263 hints.ai_socktype = SOCK_STREAM;
Hye-Shik Chang54f94392004-04-14 07:55:31 +00003264 hints.ai_protocol = IPPROTO_TCP;
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003265 if ((gaierr = getaddrinfo(NULL, "54321", &hints, &aitop)) != 0) {
3266 (void)gai_strerror(gaierr);
3267 goto bad;
3268 }
3269 for (ai = aitop; ai; ai = ai->ai_next) {
3270 if (ai->ai_addr == NULL ||
3271 ai->ai_addrlen == 0 ||
3272 getnameinfo(ai->ai_addr, ai->ai_addrlen,
3273 straddr, sizeof(straddr), strport, sizeof(strport),
3274 NI_NUMERICHOST|NI_NUMERICSERV) != 0) {
3275 goto bad;
3276 }
3277 switch (ai->ai_family) {
3278 case AF_INET:
3279 if (strcmp(strport, "54321") != 0) {
3280 goto bad;
3281 }
3282 if (passive) {
3283 if (strcmp(straddr, "0.0.0.0") != 0) {
3284 goto bad;
3285 }
3286 } else {
3287 if (strcmp(straddr, "127.0.0.1") != 0) {
3288 goto bad;
3289 }
3290 }
3291 inet4++;
3292 break;
3293 case AF_INET6:
3294 if (strcmp(strport, "54321") != 0) {
3295 goto bad;
3296 }
3297 if (passive) {
3298 if (strcmp(straddr, "::") != 0) {
3299 goto bad;
3300 }
3301 } else {
3302 if (strcmp(straddr, "::1") != 0) {
3303 goto bad;
3304 }
3305 }
3306 inet6++;
3307 break;
3308 case AF_UNSPEC:
3309 goto bad;
3310 break;
3311 default:
3312 /* another family support? */
3313 break;
3314 }
3315 }
3316 }
3317
3318 if (!(inet4 == 0 || inet4 == 2))
3319 goto bad;
3320 if (!(inet6 == 0 || inet6 == 2))
3321 goto bad;
3322
3323 if (aitop)
3324 freeaddrinfo(aitop);
Alexandre Vassalotti00900892009-07-17 05:26:39 +00003325 return 0;
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003326
3327 bad:
3328 if (aitop)
3329 freeaddrinfo(aitop);
Alexandre Vassalotti00900892009-07-17 05:26:39 +00003330 return 1;
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003331}
Matthias Klosec511b472010-05-08 11:01:39 +00003332]]])],
3333[ac_cv_buggy_getaddrinfo=no],
3334[ac_cv_buggy_getaddrinfo=yes],
doko@python.orgd65e2ba2013-01-31 23:52:03 +01003335[
3336if test "${enable_ipv6+set}" = set; then
3337 ac_cv_buggy_getaddrinfo="no -- configured with --(en|dis)able-ipv6"
3338else
3339 ac_cv_buggy_getaddrinfo=yes
3340fi]))
Alexandre Vassalotti00900892009-07-17 05:26:39 +00003341fi
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003342
Benjamin Peterson75fed812010-11-01 01:47:19 +00003343AC_MSG_RESULT($ac_cv_buggy_getaddrinfo)
3344
Mark Dickinson0ef0b912009-12-31 21:11:48 +00003345if test $have_getaddrinfo = no -o "$ac_cv_buggy_getaddrinfo" = yes
Alexandre Vassalotti00900892009-07-17 05:26:39 +00003346then
3347 if test $ipv6 = yes
3348 then
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003349 echo 'Fatal: You must get working getaddrinfo() function.'
3350 echo ' or you can specify "--disable-ipv6"'.
3351 exit 1
3352 fi
Martin v. Löwis861a65b2001-10-24 14:36:00 +00003353else
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003354 AC_DEFINE(HAVE_GETADDRINFO, 1, [Define if you have the getaddrinfo function.])
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003355fi
Benjamin Peterson75fed812010-11-01 01:47:19 +00003356
Thomas Woutersb0db85a2001-08-08 10:39:03 +00003357AC_CHECK_FUNCS(getnameinfo)
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003358
Guido van Rossum627b2d71993-12-24 10:39:16 +00003359# checks for structures
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003360AC_HEADER_TIME
Guido van Rossum627b2d71993-12-24 10:39:16 +00003361AC_STRUCT_TM
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003362AC_STRUCT_TIMEZONE
Martin v. Löwis60a5d722002-10-16 20:28:25 +00003363AC_CHECK_MEMBERS([struct stat.st_rdev])
3364AC_CHECK_MEMBERS([struct stat.st_blksize])
Hye-Shik Chang5f937a72005-06-02 13:09:30 +00003365AC_CHECK_MEMBERS([struct stat.st_flags])
Martin v. Löwisebd9d5b2005-08-09 15:00:59 +00003366AC_CHECK_MEMBERS([struct stat.st_gen])
3367AC_CHECK_MEMBERS([struct stat.st_birthtime])
Guido van Rossum98bf58f2001-10-18 20:34:25 +00003368AC_STRUCT_ST_BLOCKS
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003369
3370AC_MSG_CHECKING(for time.h that defines altzone)
Matthias Klosec511b472010-05-08 11:01:39 +00003371AC_CACHE_VAL(ac_cv_header_time_altzone,[
3372 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <time.h>]], [[return altzone;]])],
3373 [ac_cv_header_time_altzone=yes],
3374 [ac_cv_header_time_altzone=no])
3375 ])
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003376AC_MSG_RESULT($ac_cv_header_time_altzone)
3377if test $ac_cv_header_time_altzone = yes; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003378 AC_DEFINE(HAVE_ALTZONE, 1, [Define this if your time.h defines altzone.])
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003379fi
3380
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003381was_it_defined=no
3382AC_MSG_CHECKING(whether sys/select.h and sys/time.h may both be included)
Matthias Klosec511b472010-05-08 11:01:39 +00003383AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003384#include <sys/types.h>
3385#include <sys/select.h>
3386#include <sys/time.h>
Matthias Klosec511b472010-05-08 11:01:39 +00003387]], [[;]])],[
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003388 AC_DEFINE(SYS_SELECT_WITH_SYS_TIME, 1,
3389 [Define if you can safely include both <sys/select.h> and <sys/time.h>
3390 (which you can't on SCO ODT 3.0).])
3391 was_it_defined=yes
Matthias Klosec511b472010-05-08 11:01:39 +00003392],[])
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003393AC_MSG_RESULT($was_it_defined)
Guido van Rossum627b2d71993-12-24 10:39:16 +00003394
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003395AC_MSG_CHECKING(for addrinfo)
3396AC_CACHE_VAL(ac_cv_struct_addrinfo,
Matthias Klosec511b472010-05-08 11:01:39 +00003397AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <netdb.h>]], [[struct addrinfo a]])],
3398 [ac_cv_struct_addrinfo=yes],
3399 [ac_cv_struct_addrinfo=no]))
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003400AC_MSG_RESULT($ac_cv_struct_addrinfo)
3401if test $ac_cv_struct_addrinfo = yes; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003402 AC_DEFINE(HAVE_ADDRINFO, 1, [struct addrinfo (netdb.h)])
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003403fi
3404
3405AC_MSG_CHECKING(for sockaddr_storage)
3406AC_CACHE_VAL(ac_cv_struct_sockaddr_storage,
Matthias Klosec511b472010-05-08 11:01:39 +00003407AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003408# include <sys/types.h>
Matthias Klosec511b472010-05-08 11:01:39 +00003409# include <sys/socket.h>]], [[struct sockaddr_storage s]])],
3410 [ac_cv_struct_sockaddr_storage=yes],
3411 [ac_cv_struct_sockaddr_storage=no]))
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003412AC_MSG_RESULT($ac_cv_struct_sockaddr_storage)
3413if test $ac_cv_struct_sockaddr_storage = yes; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003414 AC_DEFINE(HAVE_SOCKADDR_STORAGE, 1, [struct sockaddr_storage (sys/socket.h)])
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003415fi
3416
Guido van Rossum627b2d71993-12-24 10:39:16 +00003417# checks for compiler characteristics
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003418
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003419AC_C_CHAR_UNSIGNED
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003420AC_C_CONST
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003421
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003422works=no
3423AC_MSG_CHECKING(for working volatile)
Matthias Klosec511b472010-05-08 11:01:39 +00003424AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[volatile int x; x = 0;]])],
3425 [works=yes],
3426 [AC_DEFINE(volatile, , [Define to empty if the keyword does not work.])]
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003427)
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003428AC_MSG_RESULT($works)
Guido van Rossumdabb11b1994-10-11 15:04:27 +00003429
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003430works=no
3431AC_MSG_CHECKING(for working signed char)
Matthias Klosec511b472010-05-08 11:01:39 +00003432AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[signed char c;]])],
3433 [works=yes],
3434 [AC_DEFINE(signed, , [Define to empty if the keyword does not work.])]
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003435)
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003436AC_MSG_RESULT($works)
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003437
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003438have_prototypes=no
3439AC_MSG_CHECKING(for prototypes)
Matthias Klosec511b472010-05-08 11:01:39 +00003440AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[int foo(int x) { return 0; }]], [[return foo(10);]])],
3441 [AC_DEFINE(HAVE_PROTOTYPES, 1,
3442 [Define if your compiler supports function prototype])
3443 have_prototypes=yes],
3444 []
3445)
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003446AC_MSG_RESULT($have_prototypes)
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003447
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003448works=no
3449AC_MSG_CHECKING(for variable length prototypes and stdarg.h)
Matthias Klosec511b472010-05-08 11:01:39 +00003450AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003451#include <stdarg.h>
Guido van Rossum3f13e481996-08-30 20:58:11 +00003452int foo(int x, ...) {
3453 va_list va;
3454 va_start(va, x);
3455 va_arg(va, int);
3456 va_arg(va, char *);
3457 va_arg(va, double);
3458 return 0;
3459}
Matthias Klosec511b472010-05-08 11:01:39 +00003460]], [[return foo(10, "", 3.14);]])],[
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003461 AC_DEFINE(HAVE_STDARG_PROTOTYPES, 1,
3462 [Define if your compiler supports variable length function prototypes
3463 (e.g. void fprintf(FILE *, char *, ...);) *and* <stdarg.h>])
3464 works=yes
Matthias Klosec511b472010-05-08 11:01:39 +00003465],[])
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003466AC_MSG_RESULT($works)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003467
Dave Cole331708b2004-08-09 04:51:41 +00003468# check for socketpair
3469AC_MSG_CHECKING(for socketpair)
Matthias Klosec511b472010-05-08 11:01:39 +00003470AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Dave Cole331708b2004-08-09 04:51:41 +00003471#include <sys/types.h>
3472#include <sys/socket.h>
Matthias Klosec511b472010-05-08 11:01:39 +00003473]], [[void *x=socketpair]])],
3474 [AC_DEFINE(HAVE_SOCKETPAIR, 1, [Define if you have the 'socketpair' function.])
3475 AC_MSG_RESULT(yes)],
3476 [AC_MSG_RESULT(no)]
Dave Cole331708b2004-08-09 04:51:41 +00003477)
3478
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003479# check if sockaddr has sa_len member
3480AC_MSG_CHECKING(if sockaddr has sa_len member)
Matthias Klosec511b472010-05-08 11:01:39 +00003481AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
3482#include <sys/socket.h>]], [[struct sockaddr x;
3483x.sa_len = 0;]])],
3484 [AC_MSG_RESULT(yes)
3485 AC_DEFINE(HAVE_SOCKADDR_SA_LEN, 1, [Define if sockaddr has sa_len member])],
3486 [AC_MSG_RESULT(no)]
3487)
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003488
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003489va_list_is_array=no
3490AC_MSG_CHECKING(whether va_list is an array)
Matthias Klosec511b472010-05-08 11:01:39 +00003491AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003492#ifdef HAVE_STDARG_PROTOTYPES
3493#include <stdarg.h>
3494#else
3495#include <varargs.h>
3496#endif
Matthias Klosec511b472010-05-08 11:01:39 +00003497]], [[va_list list1, list2; list1 = list2;]])],[],[
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003498 AC_DEFINE(VA_LIST_IS_ARRAY, 1, [Define if a va_list is an array of some kind])
3499 va_list_is_array=yes
3500])
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003501AC_MSG_RESULT($va_list_is_array)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003502
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003503# sigh -- gethostbyname_r is a mess; it can have 3, 5 or 6 arguments :-(
Martin v. Löwis11437992002-04-12 09:54:03 +00003504AH_TEMPLATE(HAVE_GETHOSTBYNAME_R,
3505 [Define this if you have some version of gethostbyname_r()])
3506
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003507AC_CHECK_FUNC(gethostbyname_r, [
3508 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
3509 AC_MSG_CHECKING([gethostbyname_r with 6 args])
3510 OLD_CFLAGS=$CFLAGS
3511 CFLAGS="$CFLAGS $MY_CPPFLAGS $MY_THREAD_CPPFLAGS $MY_CFLAGS"
Matthias Klosec511b472010-05-08 11:01:39 +00003512 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003513# include <netdb.h>
Matthias Klosec511b472010-05-08 11:01:39 +00003514 ]], [[
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003515 char *name;
3516 struct hostent *he, *res;
3517 char buffer[2048];
3518 int buflen = 2048;
3519 int h_errnop;
3520
3521 (void) gethostbyname_r(name, he, buffer, buflen, &res, &h_errnop)
Matthias Klosec511b472010-05-08 11:01:39 +00003522 ]])],[
Guido van Rossum8db7d8b1999-03-23 16:40:33 +00003523 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003524 AC_DEFINE(HAVE_GETHOSTBYNAME_R_6_ARG, 1,
3525 [Define this if you have the 6-arg version of gethostbyname_r().])
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003526 AC_MSG_RESULT(yes)
Matthias Klosec511b472010-05-08 11:01:39 +00003527 ],[
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003528 AC_MSG_RESULT(no)
3529 AC_MSG_CHECKING([gethostbyname_r with 5 args])
Matthias Klosec511b472010-05-08 11:01:39 +00003530 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003531# include <netdb.h>
Matthias Klosec511b472010-05-08 11:01:39 +00003532 ]], [[
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003533 char *name;
3534 struct hostent *he;
Matthias Klosec511b472010-05-08 11:01:39 +00003535 char buffer[2048];
3536 int buflen = 2048;
3537 int h_errnop;
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003538
Matthias Klosec511b472010-05-08 11:01:39 +00003539 (void) gethostbyname_r(name, he, buffer, buflen, &h_errnop)
3540 ]])],
3541 [
Guido van Rossum8db7d8b1999-03-23 16:40:33 +00003542 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
Matthias Klosec511b472010-05-08 11:01:39 +00003543 AC_DEFINE(HAVE_GETHOSTBYNAME_R_5_ARG, 1,
3544 [Define this if you have the 5-arg version of gethostbyname_r().])
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003545 AC_MSG_RESULT(yes)
3546 ], [
3547 AC_MSG_RESULT(no)
Matthias Klosec511b472010-05-08 11:01:39 +00003548 AC_MSG_CHECKING([gethostbyname_r with 3 args])
3549 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3550# include <netdb.h>
3551 ]], [[
3552 char *name;
3553 struct hostent *he;
3554 struct hostent_data data;
3555
3556 (void) gethostbyname_r(name, he, &data);
3557 ]])],
3558 [
3559 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
3560 AC_DEFINE(HAVE_GETHOSTBYNAME_R_3_ARG, 1,
3561 [Define this if you have the 3-arg version of gethostbyname_r().])
3562 AC_MSG_RESULT(yes)
3563 ], [
3564 AC_MSG_RESULT(no)
3565 ])
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003566 ])
3567 ])
3568 CFLAGS=$OLD_CFLAGS
3569], [
Thomas Wouters3a584202000-08-05 23:28:51 +00003570 AC_CHECK_FUNCS(gethostbyname)
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003571])
3572AC_SUBST(HAVE_GETHOSTBYNAME_R_6_ARG)
3573AC_SUBST(HAVE_GETHOSTBYNAME_R_5_ARG)
3574AC_SUBST(HAVE_GETHOSTBYNAME_R_3_ARG)
Guido van Rossum8db7d8b1999-03-23 16:40:33 +00003575AC_SUBST(HAVE_GETHOSTBYNAME_R)
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003576AC_SUBST(HAVE_GETHOSTBYNAME)
3577
Guido van Rossum627b2d71993-12-24 10:39:16 +00003578# checks for system services
3579# (none yet)
3580
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003581# Linux requires this for correct f.p. operations
Jeremy Hyltonbe28f5b2000-07-27 21:03:04 +00003582AC_CHECK_FUNC(__fpu_control,
3583 [],
3584 [AC_CHECK_LIB(ieee, __fpu_control)
3585])
Guido van Rossum627b2d71993-12-24 10:39:16 +00003586
Guido van Rossum93274221997-05-09 02:42:00 +00003587# Check for --with-fpectl
Guido van Rossum93274221997-05-09 02:42:00 +00003588AC_MSG_CHECKING(for --with-fpectl)
Barry Warsawc0d24d82000-06-29 16:12:00 +00003589AC_ARG_WITH(fpectl,
Matthias Klose22520ea2010-05-08 10:14:46 +00003590 AS_HELP_STRING([--with-fpectl], [enable SIGFPE catching]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003591[
Guido van Rossum93274221997-05-09 02:42:00 +00003592if test "$withval" != no
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003593then
3594 AC_DEFINE(WANT_SIGFPE_HANDLER, 1,
3595 [Define if you want SIGFPE handled (see Include/pyfpe.h).])
3596 AC_MSG_RESULT(yes)
Guido van Rossum93274221997-05-09 02:42:00 +00003597else AC_MSG_RESULT(no)
Guido van Rossumef2255b2000-03-10 22:30:29 +00003598fi],
3599[AC_MSG_RESULT(no)])
Guido van Rossum93274221997-05-09 02:42:00 +00003600
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003601# check for --with-libm=...
3602AC_SUBST(LIBM)
Guido van Rossum4b6b5791996-09-09 20:09:34 +00003603case $ac_sys_system in
Guido van Rossum3dc0a512000-10-05 18:00:06 +00003604Darwin) ;;
Guido van Rossumec95c7b1998-08-04 17:59:56 +00003605BeOS) ;;
Guido van Rossum4b6b5791996-09-09 20:09:34 +00003606*) LIBM=-lm
3607esac
Guido van Rossum93274221997-05-09 02:42:00 +00003608AC_MSG_CHECKING(for --with-libm=STRING)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003609AC_ARG_WITH(libm,
Matthias Klose22520ea2010-05-08 10:14:46 +00003610 AS_HELP_STRING([--with-libm=STRING], [math library]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003611[
Guido van Rossum93274221997-05-09 02:42:00 +00003612if test "$withval" = no
3613then LIBM=
3614 AC_MSG_RESULT(force LIBM empty)
3615elif test "$withval" != yes
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003616then LIBM=$withval
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003617 AC_MSG_RESULT(set LIBM="$withval")
3618else AC_MSG_ERROR([proper usage is --with-libm=STRING])
Guido van Rossum93274221997-05-09 02:42:00 +00003619fi],
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003620[AC_MSG_RESULT(default LIBM="$LIBM")])
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003621
3622# check for --with-libc=...
3623AC_SUBST(LIBC)
Guido van Rossum93274221997-05-09 02:42:00 +00003624AC_MSG_CHECKING(for --with-libc=STRING)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003625AC_ARG_WITH(libc,
Matthias Klose22520ea2010-05-08 10:14:46 +00003626 AS_HELP_STRING([--with-libc=STRING], [C library]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003627[
Guido van Rossum93274221997-05-09 02:42:00 +00003628if test "$withval" = no
3629then LIBC=
3630 AC_MSG_RESULT(force LIBC empty)
3631elif test "$withval" != yes
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003632then LIBC=$withval
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003633 AC_MSG_RESULT(set LIBC="$withval")
3634else AC_MSG_ERROR([proper usage is --with-libc=STRING])
Guido van Rossum93274221997-05-09 02:42:00 +00003635fi],
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003636[AC_MSG_RESULT(default LIBC="$LIBC")])
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003637
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003638# **************************************************
3639# * Check for various properties of floating point *
3640# **************************************************
Mark Dickinson265d7382008-04-21 22:32:24 +00003641
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003642AC_MSG_CHECKING(whether C doubles are little-endian IEEE 754 binary64)
3643AC_CACHE_VAL(ac_cv_little_endian_double, [
Matthias Klosec511b472010-05-08 11:01:39 +00003644AC_RUN_IFELSE([AC_LANG_SOURCE([[
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003645#include <string.h>
3646int main() {
3647 double x = 9006104071832581.0;
3648 if (memcmp(&x, "\x05\x04\x03\x02\x01\xff\x3f\x43", 8) == 0)
3649 return 0;
3650 else
3651 return 1;
3652}
Matthias Klosec511b472010-05-08 11:01:39 +00003653]])],
3654[ac_cv_little_endian_double=yes],
3655[ac_cv_little_endian_double=no],
3656[ac_cv_little_endian_double=no])])
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003657AC_MSG_RESULT($ac_cv_little_endian_double)
3658if test "$ac_cv_little_endian_double" = yes
3659then
3660 AC_DEFINE(DOUBLE_IS_LITTLE_ENDIAN_IEEE754, 1,
3661 [Define if C doubles are 64-bit IEEE 754 binary format, stored
3662 with the least significant byte first])
3663fi
3664
3665AC_MSG_CHECKING(whether C doubles are big-endian IEEE 754 binary64)
3666AC_CACHE_VAL(ac_cv_big_endian_double, [
Matthias Klosec511b472010-05-08 11:01:39 +00003667AC_RUN_IFELSE([AC_LANG_SOURCE([[
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003668#include <string.h>
3669int main() {
3670 double x = 9006104071832581.0;
3671 if (memcmp(&x, "\x43\x3f\xff\x01\x02\x03\x04\x05", 8) == 0)
3672 return 0;
3673 else
3674 return 1;
3675}
Matthias Klosec511b472010-05-08 11:01:39 +00003676]])],
3677[ac_cv_big_endian_double=yes],
3678[ac_cv_big_endian_double=no],
3679[ac_cv_big_endian_double=no])])
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003680AC_MSG_RESULT($ac_cv_big_endian_double)
3681if test "$ac_cv_big_endian_double" = yes
3682then
3683 AC_DEFINE(DOUBLE_IS_BIG_ENDIAN_IEEE754, 1,
3684 [Define if C doubles are 64-bit IEEE 754 binary format, stored
3685 with the most significant byte first])
3686fi
3687
3688# Some ARM platforms use a mixed-endian representation for doubles.
3689# While Python doesn't currently have full support for these platforms
3690# (see e.g., issue 1762561), we can at least make sure that float <-> string
3691# conversions work.
3692AC_MSG_CHECKING(whether C doubles are ARM mixed-endian IEEE 754 binary64)
3693AC_CACHE_VAL(ac_cv_mixed_endian_double, [
Matthias Klosec511b472010-05-08 11:01:39 +00003694AC_RUN_IFELSE([AC_LANG_SOURCE([[
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003695#include <string.h>
3696int main() {
3697 double x = 9006104071832581.0;
3698 if (memcmp(&x, "\x01\xff\x3f\x43\x05\x04\x03\x02", 8) == 0)
3699 return 0;
3700 else
3701 return 1;
3702}
Matthias Klosec511b472010-05-08 11:01:39 +00003703]])],
3704[ac_cv_mixed_endian_double=yes],
3705[ac_cv_mixed_endian_double=no],
3706[ac_cv_mixed_endian_double=no])])
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003707AC_MSG_RESULT($ac_cv_mixed_endian_double)
3708if test "$ac_cv_mixed_endian_double" = yes
3709then
3710 AC_DEFINE(DOUBLE_IS_ARM_MIXED_ENDIAN_IEEE754, 1,
3711 [Define if C doubles are 64-bit IEEE 754 binary format, stored
3712 in ARM mixed-endian order (byte order 45670123)])
3713fi
3714
3715# The short float repr introduced in Python 3.1 requires the
3716# correctly-rounded string <-> double conversion functions from
3717# Python/dtoa.c, which in turn require that the FPU uses 53-bit
3718# rounding; this is a problem on x86, where the x87 FPU has a default
Mark Dickinsona548dee2009-11-15 13:12:43 +00003719# rounding precision of 64 bits. For gcc/x86, we can fix this by
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003720# using inline assembler to get and set the x87 FPU control word.
Mark Dickinsona548dee2009-11-15 13:12:43 +00003721
3722# This inline assembler syntax may also work for suncc and icc,
3723# so we try it on all platforms.
3724
3725AC_MSG_CHECKING(whether we can use gcc inline assembler to get and set x87 control word)
Matthias Klosec511b472010-05-08 11:01:39 +00003726AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
Mark Dickinsona548dee2009-11-15 13:12:43 +00003727 unsigned short cw;
3728 __asm__ __volatile__ ("fnstcw %0" : "=m" (cw));
3729 __asm__ __volatile__ ("fldcw %0" : : "m" (cw));
Matthias Klosec511b472010-05-08 11:01:39 +00003730]])],[have_gcc_asm_for_x87=yes],[have_gcc_asm_for_x87=no])
Mark Dickinsona548dee2009-11-15 13:12:43 +00003731AC_MSG_RESULT($have_gcc_asm_for_x87)
3732if test "$have_gcc_asm_for_x87" = yes
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003733then
Mark Dickinsona548dee2009-11-15 13:12:43 +00003734 AC_DEFINE(HAVE_GCC_ASM_FOR_X87, 1,
3735 [Define if we can use gcc inline assembler to get and set x87 control word])
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003736fi
Mark Dickinson7a3d8642008-04-22 00:54:27 +00003737
Mark Dickinson04b27232009-01-04 12:29:36 +00003738# Detect whether system arithmetic is subject to x87-style double
3739# rounding issues. The result of this test has little meaning on non
3740# IEEE 754 platforms. On IEEE 754, test should return 1 if rounding
3741# mode is round-to-nearest and double rounding issues are present, and
3742# 0 otherwise. See http://bugs.python.org/issue2937 for more info.
3743AC_MSG_CHECKING(for x87-style double rounding)
Mark Dickinson99abd142009-10-24 13:44:16 +00003744# $BASECFLAGS may affect the result
3745ac_save_cc="$CC"
3746CC="$CC $BASECFLAGS"
Matthias Klosec511b472010-05-08 11:01:39 +00003747AC_RUN_IFELSE([AC_LANG_SOURCE([[
Mark Dickinson04b27232009-01-04 12:29:36 +00003748#include <stdlib.h>
3749#include <math.h>
3750int main() {
3751 volatile double x, y, z;
3752 /* 1./(1-2**-53) -> 1+2**-52 (correct), 1.0 (double rounding) */
3753 x = 0.99999999999999989; /* 1-2**-53 */
3754 y = 1./x;
3755 if (y != 1.)
3756 exit(0);
3757 /* 1e16+2.99999 -> 1e16+2. (correct), 1e16+4. (double rounding) */
3758 x = 1e16;
3759 y = 2.99999;
3760 z = x + y;
3761 if (z != 1e16+4.)
3762 exit(0);
3763 /* both tests show evidence of double rounding */
3764 exit(1);
3765}
Matthias Klosec511b472010-05-08 11:01:39 +00003766]])],
3767[ac_cv_x87_double_rounding=no],
3768[ac_cv_x87_double_rounding=yes],
3769[ac_cv_x87_double_rounding=no])
Mark Dickinson99abd142009-10-24 13:44:16 +00003770CC="$ac_save_cc"
Mark Dickinson04b27232009-01-04 12:29:36 +00003771AC_MSG_RESULT($ac_cv_x87_double_rounding)
3772if test "$ac_cv_x87_double_rounding" = yes
3773then
3774 AC_DEFINE(X87_DOUBLE_ROUNDING, 1,
3775 [Define if arithmetic is subject to x87-style double rounding issue])
3776fi
3777
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003778# ************************************
3779# * Check for mathematical functions *
3780# ************************************
3781
3782LIBS_SAVE=$LIBS
3783LIBS="$LIBS $LIBM"
3784
Mark Dickinsonc63392c2009-11-28 13:13:13 +00003785# On FreeBSD 6.2, it appears that tanh(-0.) returns 0. instead of
3786# -0. on some architectures.
3787AC_MSG_CHECKING(whether tanh preserves the sign of zero)
3788AC_CACHE_VAL(ac_cv_tanh_preserves_zero_sign, [
Matthias Klosec511b472010-05-08 11:01:39 +00003789AC_RUN_IFELSE([AC_LANG_SOURCE([[
Mark Dickinsonc63392c2009-11-28 13:13:13 +00003790#include <math.h>
3791#include <stdlib.h>
3792int main() {
3793 /* return 0 if either negative zeros don't exist
3794 on this platform or if negative zeros exist
3795 and tanh(-0.) == -0. */
3796 if (atan2(0., -1.) == atan2(-0., -1.) ||
3797 atan2(tanh(-0.), -1.) == atan2(-0., -1.)) exit(0);
3798 else exit(1);
3799}
Matthias Klosec511b472010-05-08 11:01:39 +00003800]])],
3801[ac_cv_tanh_preserves_zero_sign=yes],
3802[ac_cv_tanh_preserves_zero_sign=no],
3803[ac_cv_tanh_preserves_zero_sign=no])])
Mark Dickinsonc63392c2009-11-28 13:13:13 +00003804AC_MSG_RESULT($ac_cv_tanh_preserves_zero_sign)
3805if test "$ac_cv_tanh_preserves_zero_sign" = yes
3806then
3807 AC_DEFINE(TANH_PRESERVES_ZERO_SIGN, 1,
3808 [Define if tanh(-0.) is -0., or if platform doesn't have signed zeros])
3809fi
3810
3811AC_CHECK_FUNCS([acosh asinh atanh copysign erf erfc expm1 finite gamma])
3812AC_CHECK_FUNCS([hypot lgamma log1p round tgamma])
3813AC_CHECK_DECLS([isinf, isnan, isfinite], [], [], [[#include <math.h>]])
3814
3815LIBS=$LIBS_SAVE
3816
Mark Dickinsonc4920e82009-11-20 19:30:22 +00003817# For multiprocessing module, check that sem_open
3818# actually works. For FreeBSD versions <= 7.2,
3819# the kernel module that provides POSIX semaphores
3820# isn't loaded by default, so an attempt to call
3821# sem_open results in a 'Signal 12' error.
3822AC_MSG_CHECKING(whether POSIX semaphores are enabled)
3823AC_CACHE_VAL(ac_cv_posix_semaphores_enabled,
Matthias Klosec511b472010-05-08 11:01:39 +00003824AC_RUN_IFELSE([AC_LANG_SOURCE([[
Mark Dickinsonc4920e82009-11-20 19:30:22 +00003825#include <unistd.h>
3826#include <fcntl.h>
3827#include <stdio.h>
3828#include <semaphore.h>
3829#include <sys/stat.h>
3830
3831int main(void) {
3832 sem_t *a = sem_open("/autoconf", O_CREAT, S_IRUSR|S_IWUSR, 0);
3833 if (a == SEM_FAILED) {
3834 perror("sem_open");
3835 return 1;
3836 }
3837 sem_close(a);
Mark Dickinson59dc89e2009-12-13 21:06:06 +00003838 sem_unlink("/autoconf");
Mark Dickinsonc4920e82009-11-20 19:30:22 +00003839 return 0;
3840}
Matthias Klosec511b472010-05-08 11:01:39 +00003841]])],
3842[ac_cv_posix_semaphores_enabled=yes],
3843[ac_cv_posix_semaphores_enabled=no],
3844[ac_cv_posix_semaphores_enabled=yes])
Mark Dickinsonc4920e82009-11-20 19:30:22 +00003845)
3846AC_MSG_RESULT($ac_cv_posix_semaphores_enabled)
3847if test $ac_cv_posix_semaphores_enabled = no
3848then
Mark Dickinson5afa6d42009-11-28 10:44:20 +00003849 AC_DEFINE(POSIX_SEMAPHORES_NOT_ENABLED, 1,
3850 [Define if POSIX semaphores aren't enabled on your system])
Mark Dickinsonc4920e82009-11-20 19:30:22 +00003851fi
3852
Jesse Noller355b1262009-04-02 00:03:28 +00003853# Multiprocessing check for broken sem_getvalue
3854AC_MSG_CHECKING(for broken sem_getvalue)
Alexandre Vassalotti00900892009-07-17 05:26:39 +00003855AC_CACHE_VAL(ac_cv_broken_sem_getvalue,
Matthias Klosec511b472010-05-08 11:01:39 +00003856AC_RUN_IFELSE([AC_LANG_SOURCE([[
Jesse Noller355b1262009-04-02 00:03:28 +00003857#include <unistd.h>
3858#include <fcntl.h>
3859#include <stdio.h>
3860#include <semaphore.h>
3861#include <sys/stat.h>
3862
3863int main(void){
Mark Dickinson59dc89e2009-12-13 21:06:06 +00003864 sem_t *a = sem_open("/autocftw", O_CREAT, S_IRUSR|S_IWUSR, 0);
Jesse Noller355b1262009-04-02 00:03:28 +00003865 int count;
3866 int res;
3867 if(a==SEM_FAILED){
3868 perror("sem_open");
3869 return 1;
3870
3871 }
3872 res = sem_getvalue(a, &count);
3873 sem_close(a);
Mark Dickinson59dc89e2009-12-13 21:06:06 +00003874 sem_unlink("/autocftw");
Jesse Noller355b1262009-04-02 00:03:28 +00003875 return res==-1 ? 1 : 0;
3876}
Matthias Klosec511b472010-05-08 11:01:39 +00003877]])],
3878[ac_cv_broken_sem_getvalue=no],
3879[ac_cv_broken_sem_getvalue=yes],
3880[ac_cv_broken_sem_getvalue=yes])
Jesse Noller355b1262009-04-02 00:03:28 +00003881)
Alexandre Vassalotti00900892009-07-17 05:26:39 +00003882AC_MSG_RESULT($ac_cv_broken_sem_getvalue)
3883if test $ac_cv_broken_sem_getvalue = yes
3884then
3885 AC_DEFINE(HAVE_BROKEN_SEM_GETVALUE, 1,
3886 [define to 1 if your sem_getvalue is broken.])
3887fi
Mark Dickinson04b27232009-01-04 12:29:36 +00003888
Mark Dickinsonefc82f72009-03-20 15:51:55 +00003889# determine what size digit to use for Python's longs
3890AC_MSG_CHECKING([digit size for Python's longs])
3891AC_ARG_ENABLE(big-digits,
Matthias Klose22520ea2010-05-08 10:14:46 +00003892AS_HELP_STRING([--enable-big-digits@<:@=BITS@:>@],[use big digits for Python longs [[BITS=30]]]),
Mark Dickinsonefc82f72009-03-20 15:51:55 +00003893[case $enable_big_digits in
3894yes)
3895 enable_big_digits=30 ;;
3896no)
3897 enable_big_digits=15 ;;
3898[15|30])
3899 ;;
3900*)
3901 AC_MSG_ERROR([bad value $enable_big_digits for --enable-big-digits; value should be 15 or 30]) ;;
3902esac
3903AC_MSG_RESULT($enable_big_digits)
3904AC_DEFINE_UNQUOTED(PYLONG_BITS_IN_DIGIT, $enable_big_digits, [Define as the preferred size in bits of long digits])
3905],
3906[AC_MSG_RESULT(no value specified)])
3907
Guido van Rossumef2255b2000-03-10 22:30:29 +00003908# check for wchar.h
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003909AC_CHECK_HEADER(wchar.h, [
3910 AC_DEFINE(HAVE_WCHAR_H, 1,
3911 [Define if the compiler provides a wchar.h header file.])
3912 wchar_h="yes"
3913],
Guido van Rossumef2255b2000-03-10 22:30:29 +00003914wchar_h="no"
3915)
3916
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003917# determine wchar_t size
3918if test "$wchar_h" = yes
3919then
Guido van Rossum67b26592001-10-20 14:21:45 +00003920 AC_CHECK_SIZEOF(wchar_t, 4, [#include <wchar.h>])
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003921fi
3922
Martin v. Löwisfa3bdea2003-09-04 18:50:54 +00003923AC_MSG_CHECKING(for UCS-4 tcl)
3924have_ucs4_tcl=no
Matthias Klosec511b472010-05-08 11:01:39 +00003925AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwisfa3bdea2003-09-04 18:50:54 +00003926#include <tcl.h>
3927#if TCL_UTF_MAX != 6
3928# error "NOT UCS4_TCL"
Matthias Klosec511b472010-05-08 11:01:39 +00003929#endif]], [[]])],[
Martin v. Löwisfa3bdea2003-09-04 18:50:54 +00003930 AC_DEFINE(HAVE_UCS4_TCL, 1, [Define this if you have tcl and TCL_UTF_MAX==6])
3931 have_ucs4_tcl=yes
Matthias Klosec511b472010-05-08 11:01:39 +00003932],[])
Martin v. Löwisfa3bdea2003-09-04 18:50:54 +00003933AC_MSG_RESULT($have_ucs4_tcl)
3934
Marc-André Lemburgd7160f82003-09-22 11:14:40 +00003935# check whether wchar_t is signed or not
3936if test "$wchar_h" = yes
3937then
3938 # check whether wchar_t is signed or not
3939 AC_MSG_CHECKING(whether wchar_t is signed)
3940 AC_CACHE_VAL(ac_cv_wchar_t_signed, [
Matthias Klosec511b472010-05-08 11:01:39 +00003941 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Marc-André Lemburgd7160f82003-09-22 11:14:40 +00003942 #include <wchar.h>
3943 int main()
3944 {
Martin v. Löwis44fe0e42006-04-11 07:15:30 +00003945 /* Success: exit code 0 */
3946 exit((((wchar_t) -1) < ((wchar_t) 0)) ? 0 : 1);
Marc-André Lemburgd7160f82003-09-22 11:14:40 +00003947 }
Matthias Klosec511b472010-05-08 11:01:39 +00003948 ]])],
3949 [ac_cv_wchar_t_signed=yes],
3950 [ac_cv_wchar_t_signed=no],
3951 [ac_cv_wchar_t_signed=yes])])
Marc-André Lemburgd7160f82003-09-22 11:14:40 +00003952 AC_MSG_RESULT($ac_cv_wchar_t_signed)
3953fi
3954
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003955AC_MSG_CHECKING(what type to use for unicode)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003956dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003957AC_ARG_ENABLE(unicode,
Benjamin Peterson66556b02010-05-25 02:23:32 +00003958 AS_HELP_STRING([--enable-unicode@<:@=ucs@<:@24@:>@@:>@], [Enable Unicode strings (default is ucs2)]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003959 [],
3960 [enable_unicode=yes])
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003961
3962if test $enable_unicode = yes
3963then
Martin v. Löwisfd917792001-06-27 20:22:04 +00003964 # Without any arguments, Py_UNICODE defaults to two-byte mode
Martin v. Löwisfa3bdea2003-09-04 18:50:54 +00003965 case "$have_ucs4_tcl" in
3966 yes) enable_unicode="ucs4"
3967 ;;
3968 *) enable_unicode="ucs2"
3969 ;;
3970 esac
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003971fi
3972
Martin v. Löwis0036cba2002-04-12 09:58:45 +00003973AH_TEMPLATE(Py_UNICODE_SIZE,
3974 [Define as the size of the unicode type.])
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003975case "$enable_unicode" in
3976ucs2) unicode_size="2"
3977 AC_DEFINE(Py_UNICODE_SIZE,2)
3978 ;;
3979ucs4) unicode_size="4"
3980 AC_DEFINE(Py_UNICODE_SIZE,4)
3981 ;;
Martin v. Löwised11a5d2012-05-20 10:42:17 +02003982no) ;; # To allow --disable-unicode
Ezio Melotti5820efb2010-02-27 00:05:42 +00003983*) AC_MSG_ERROR([invalid value for --enable-unicode. Use either ucs2 or ucs4 (lowercase).]) ;;
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003984esac
3985
Martin v. Löwis11437992002-04-12 09:54:03 +00003986AH_TEMPLATE(PY_UNICODE_TYPE,
3987 [Define as the integral type used for Unicode representation.])
Martin v. Löwis0036cba2002-04-12 09:58:45 +00003988
Martin v. Löwis339d0f72001-08-17 18:39:25 +00003989AC_SUBST(UNICODE_OBJS)
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003990if test "$enable_unicode" = "no"
3991then
Martin v. Löwis339d0f72001-08-17 18:39:25 +00003992 UNICODE_OBJS=""
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003993 AC_MSG_RESULT(not used)
3994else
Martin v. Löwis339d0f72001-08-17 18:39:25 +00003995 UNICODE_OBJS="Objects/unicodeobject.o Objects/unicodectype.o"
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003996 AC_DEFINE(Py_USING_UNICODE, 1,
3997 [Define if you want to have a Unicode type.])
Marc-André Lemburgd7160f82003-09-22 11:14:40 +00003998
3999 # wchar_t is only usable if it maps to an unsigned type
4000 if test "$unicode_size" = "$ac_cv_sizeof_wchar_t" \
Matthias Klose7dbeed72004-12-24 08:22:17 +00004001 -a "$ac_cv_wchar_t_signed" = "no"
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00004002 then
4003 PY_UNICODE_TYPE="wchar_t"
Martin v. Löwisc45929e2002-04-06 10:10:49 +00004004 AC_DEFINE(HAVE_USABLE_WCHAR_T, 1,
4005 [Define if you have a useable wchar_t type defined in wchar.h; useable
Marc-André Lemburgd7160f82003-09-22 11:14:40 +00004006 means wchar_t must be an unsigned type with at least 16 bits. (see
Martin v. Löwisc45929e2002-04-06 10:10:49 +00004007 Include/unicodeobject.h).])
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00004008 AC_DEFINE(PY_UNICODE_TYPE,wchar_t)
4009 elif test "$ac_cv_sizeof_short" = "$unicode_size"
4010 then
4011 PY_UNICODE_TYPE="unsigned short"
4012 AC_DEFINE(PY_UNICODE_TYPE,unsigned short)
4013 elif test "$ac_cv_sizeof_long" = "$unicode_size"
4014 then
4015 PY_UNICODE_TYPE="unsigned long"
4016 AC_DEFINE(PY_UNICODE_TYPE,unsigned long)
4017 else
4018 PY_UNICODE_TYPE="no type found"
4019 fi
4020 AC_MSG_RESULT($PY_UNICODE_TYPE)
4021fi
Guido van Rossumef2255b2000-03-10 22:30:29 +00004022
4023# check for endianness
4024AC_C_BIGENDIAN
4025
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00004026# Check whether right shifting a negative integer extends the sign bit
4027# or fills with zeros (like the Cray J90, according to Tim Peters).
4028AC_MSG_CHECKING(whether right shift extends the sign bit)
Vladimir Marangozova6180282000-07-12 05:05:06 +00004029AC_CACHE_VAL(ac_cv_rshift_extends_sign, [
Matthias Klosec511b472010-05-08 11:01:39 +00004030AC_RUN_IFELSE([AC_LANG_SOURCE([[
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00004031int main()
4032{
Vladimir Marangozova6180282000-07-12 05:05:06 +00004033 exit(((-1)>>3 == -1) ? 0 : 1);
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00004034}
Matthias Klosec511b472010-05-08 11:01:39 +00004035]])],
4036[ac_cv_rshift_extends_sign=yes],
4037[ac_cv_rshift_extends_sign=no],
4038[ac_cv_rshift_extends_sign=yes])])
Vladimir Marangozova6180282000-07-12 05:05:06 +00004039AC_MSG_RESULT($ac_cv_rshift_extends_sign)
4040if test "$ac_cv_rshift_extends_sign" = no
4041then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00004042 AC_DEFINE(SIGNED_RIGHT_SHIFT_ZERO_FILLS, 1,
4043 [Define if i>>j for signed int i does not extend the sign bit
4044 when i < 0])
Vladimir Marangozova6180282000-07-12 05:05:06 +00004045fi
4046
Guido van Rossumcadfaec2001-01-05 14:45:49 +00004047# check for getc_unlocked and related locking functions
4048AC_MSG_CHECKING(for getc_unlocked() and friends)
4049AC_CACHE_VAL(ac_cv_have_getc_unlocked, [
Matthias Klosec511b472010-05-08 11:01:39 +00004050AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <stdio.h>]], [[
Guido van Rossumcadfaec2001-01-05 14:45:49 +00004051 FILE *f = fopen("/dev/null", "r");
4052 flockfile(f);
4053 getc_unlocked(f);
4054 funlockfile(f);
Matthias Klosec511b472010-05-08 11:01:39 +00004055]])],[ac_cv_have_getc_unlocked=yes],[ac_cv_have_getc_unlocked=no])])
Guido van Rossumcadfaec2001-01-05 14:45:49 +00004056AC_MSG_RESULT($ac_cv_have_getc_unlocked)
4057if test "$ac_cv_have_getc_unlocked" = yes
4058then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00004059 AC_DEFINE(HAVE_GETC_UNLOCKED, 1,
4060 [Define this if you have flockfile(), getc_unlocked(), and funlockfile()])
Guido van Rossumcadfaec2001-01-05 14:45:49 +00004061fi
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00004062
Neal Norwitzfe8e3d92006-01-07 21:07:20 +00004063# check where readline lives
Martin v. Löwis82bca632006-02-10 20:49:30 +00004064# save the value of LIBS so we don't actually link Python with readline
4065LIBS_no_readline=$LIBS
Gregory P. Smith980b99b2008-09-07 05:15:18 +00004066
4067# On some systems we need to link readline to a termcap compatible
4068# library. NOTE: Keep the precedence of listed libraries synchronised
4069# with setup.py.
4070py_cv_lib_readline=no
4071AC_MSG_CHECKING([how to link readline libs])
4072for py_libtermcap in "" ncursesw ncurses curses termcap; do
4073 if test -z "$py_libtermcap"; then
4074 READLINE_LIBS="-lreadline"
4075 else
4076 READLINE_LIBS="-lreadline -l$py_libtermcap"
4077 fi
4078 LIBS="$READLINE_LIBS $LIBS_no_readline"
4079 AC_LINK_IFELSE(
4080 [AC_LANG_CALL([],[readline])],
4081 [py_cv_lib_readline=yes])
4082 if test $py_cv_lib_readline = yes; then
4083 break
4084 fi
4085done
4086# Uncomment this line if you want to use READINE_LIBS in Makefile or scripts
4087#AC_SUBST([READLINE_LIBS])
Gregory P. Smith29ec7502008-09-07 19:18:16 +00004088if test $py_cv_lib_readline = no; then
Gregory P. Smith980b99b2008-09-07 05:15:18 +00004089 AC_MSG_RESULT([none])
4090else
4091 AC_MSG_RESULT([$READLINE_LIBS])
4092 AC_DEFINE(HAVE_LIBREADLINE, 1,
4093 [Define if you have the readline library (-lreadline).])
Neal Norwitzfe8e3d92006-01-07 21:07:20 +00004094fi
4095
Michael W. Hudson30ea2f22004-07-07 17:44:12 +00004096# check for readline 2.1
4097AC_CHECK_LIB(readline, rl_callback_handler_install,
4098 AC_DEFINE(HAVE_RL_CALLBACK, 1,
Gregory P. Smithff7b2d52008-09-03 05:57:48 +00004099 [Define if you have readline 2.1]), ,$READLINE_LIBS)
Michael W. Hudson30ea2f22004-07-07 17:44:12 +00004100
Guido van Rossumfaf5e4d2002-12-30 16:25:41 +00004101# check for readline 2.2
Matthias Klosec511b472010-05-08 11:01:39 +00004102AC_PREPROC_IFELSE([AC_LANG_SOURCE([[#include <readline/readline.h>]])],
4103 [have_readline=yes],
4104 [have_readline=no]
4105)
Guido van Rossumfaf5e4d2002-12-30 16:25:41 +00004106if test $have_readline = yes
4107then
4108 AC_EGREP_HEADER([extern int rl_completion_append_character;],
4109 [readline/readline.h],
4110 AC_DEFINE(HAVE_RL_COMPLETION_APPEND_CHARACTER, 1,
4111 [Define if you have readline 2.2]), )
Antoine Pitroud9ff74e2009-10-26 19:16:46 +00004112 AC_EGREP_HEADER([extern int rl_completion_suppress_append;],
4113 [readline/readline.h],
4114 AC_DEFINE(HAVE_RL_COMPLETION_SUPPRESS_APPEND, 1,
4115 [Define if you have rl_completion_suppress_append]), )
Guido van Rossumfaf5e4d2002-12-30 16:25:41 +00004116fi
4117
Martin v. Löwis0daad592001-09-30 21:09:59 +00004118# check for readline 4.0
4119AC_CHECK_LIB(readline, rl_pre_input_hook,
Martin v. Löwisc45929e2002-04-06 10:10:49 +00004120 AC_DEFINE(HAVE_RL_PRE_INPUT_HOOK, 1,
Gregory P. Smithff7b2d52008-09-03 05:57:48 +00004121 [Define if you have readline 4.0]), ,$READLINE_LIBS)
Martin v. Löwis0daad592001-09-30 21:09:59 +00004122
Martin v. Löwis58bd49f2007-09-04 13:13:14 +00004123# also in 4.0
4124AC_CHECK_LIB(readline, rl_completion_display_matches_hook,
4125 AC_DEFINE(HAVE_RL_COMPLETION_DISPLAY_MATCHES_HOOK, 1,
Gregory P. Smithff7b2d52008-09-03 05:57:48 +00004126 [Define if you have readline 4.0]), ,$READLINE_LIBS)
Martin v. Löwis58bd49f2007-09-04 13:13:14 +00004127
Guido van Rossum353ae582001-07-10 16:45:32 +00004128# check for readline 4.2
4129AC_CHECK_LIB(readline, rl_completion_matches,
Martin v. Löwisc45929e2002-04-06 10:10:49 +00004130 AC_DEFINE(HAVE_RL_COMPLETION_MATCHES, 1,
Gregory P. Smithff7b2d52008-09-03 05:57:48 +00004131 [Define if you have readline 4.2]), ,$READLINE_LIBS)
Guido van Rossum353ae582001-07-10 16:45:32 +00004132
Michael W. Hudson30ea2f22004-07-07 17:44:12 +00004133# also in readline 4.2
Matthias Klosec511b472010-05-08 11:01:39 +00004134AC_PREPROC_IFELSE([AC_LANG_SOURCE([[#include <readline/readline.h>]])],
4135 [have_readline=yes],
4136 [have_readline=no]
4137)
Michael W. Hudson30ea2f22004-07-07 17:44:12 +00004138if test $have_readline = yes
4139then
4140 AC_EGREP_HEADER([extern int rl_catch_signals;],
4141 [readline/readline.h],
4142 AC_DEFINE(HAVE_RL_CATCH_SIGNAL, 1,
4143 [Define if you can turn off readline's signal handling.]), )
4144fi
4145
Martin v. Löwis82bca632006-02-10 20:49:30 +00004146# End of readline checks: restore LIBS
4147LIBS=$LIBS_no_readline
4148
Thomas Wouterse38b2f12001-07-11 22:35:31 +00004149AC_MSG_CHECKING(for broken nice())
4150AC_CACHE_VAL(ac_cv_broken_nice, [
Matthias Klosec511b472010-05-08 11:01:39 +00004151AC_RUN_IFELSE([AC_LANG_SOURCE([[
Thomas Wouterse38b2f12001-07-11 22:35:31 +00004152int main()
4153{
4154 int val1 = nice(1);
4155 if (val1 != -1 && val1 == nice(2))
4156 exit(0);
4157 exit(1);
4158}
Matthias Klosec511b472010-05-08 11:01:39 +00004159]])],
4160[ac_cv_broken_nice=yes],
4161[ac_cv_broken_nice=no],
4162[ac_cv_broken_nice=no])])
Thomas Wouterse38b2f12001-07-11 22:35:31 +00004163AC_MSG_RESULT($ac_cv_broken_nice)
4164if test "$ac_cv_broken_nice" = yes
4165then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00004166 AC_DEFINE(HAVE_BROKEN_NICE, 1,
4167 [Define if nice() returns success/failure instead of the new priority.])
Thomas Wouterse38b2f12001-07-11 22:35:31 +00004168fi
4169
Nicholas Bastine62c5c82004-03-21 23:45:42 +00004170AC_MSG_CHECKING(for broken poll())
Alexandre Vassalotti00900892009-07-17 05:26:39 +00004171AC_CACHE_VAL(ac_cv_broken_poll,
Matthias Klosec511b472010-05-08 11:01:39 +00004172AC_RUN_IFELSE([AC_LANG_SOURCE([[
Nicholas Bastine62c5c82004-03-21 23:45:42 +00004173#include <poll.h>
4174
Alexandre Vassalotti66da2632009-07-17 06:17:33 +00004175int main()
4176{
Nicholas Bastine62c5c82004-03-21 23:45:42 +00004177 struct pollfd poll_struct = { 42, POLLIN|POLLPRI|POLLOUT, 0 };
Alexandre Vassalotti66da2632009-07-17 06:17:33 +00004178 int poll_test;
4179
Nicholas Bastine62c5c82004-03-21 23:45:42 +00004180 close (42);
4181
Alexandre Vassalotti66da2632009-07-17 06:17:33 +00004182 poll_test = poll(&poll_struct, 1, 0);
Nicholas Bastine62c5c82004-03-21 23:45:42 +00004183 if (poll_test < 0)
Alexandre Vassalotti66da2632009-07-17 06:17:33 +00004184 return 0;
Nicholas Bastine62c5c82004-03-21 23:45:42 +00004185 else if (poll_test == 0 && poll_struct.revents != POLLNVAL)
Alexandre Vassalotti66da2632009-07-17 06:17:33 +00004186 return 0;
Nicholas Bastine62c5c82004-03-21 23:45:42 +00004187 else
Alexandre Vassalotti66da2632009-07-17 06:17:33 +00004188 return 1;
4189}
Matthias Klosec511b472010-05-08 11:01:39 +00004190]])],
4191[ac_cv_broken_poll=yes],
4192[ac_cv_broken_poll=no],
4193[ac_cv_broken_poll=no]))
Nicholas Bastine62c5c82004-03-21 23:45:42 +00004194AC_MSG_RESULT($ac_cv_broken_poll)
4195if test "$ac_cv_broken_poll" = yes
4196then
4197 AC_DEFINE(HAVE_BROKEN_POLL, 1,
4198 [Define if poll() sets errno on invalid file descriptors.])
4199fi
4200
Brett Cannon43802422005-02-10 20:48:03 +00004201# Before we can test tzset, we need to check if struct tm has a tm_zone
4202# (which is not required by ISO C or UNIX spec) and/or if we support
4203# tzname[]
4204AC_STRUCT_TIMEZONE
Nicholas Bastine62c5c82004-03-21 23:45:42 +00004205
Brett Cannon43802422005-02-10 20:48:03 +00004206# check tzset(3) exists and works like we expect it to
Guido van Rossumd11b62e2003-03-14 21:51:36 +00004207AC_MSG_CHECKING(for working tzset())
4208AC_CACHE_VAL(ac_cv_working_tzset, [
Matthias Klosec511b472010-05-08 11:01:39 +00004209AC_RUN_IFELSE([AC_LANG_SOURCE([[
Guido van Rossumd11b62e2003-03-14 21:51:36 +00004210#include <stdlib.h>
4211#include <time.h>
Brett Cannon18367812003-09-19 00:59:16 +00004212#include <string.h>
Brett Cannon43802422005-02-10 20:48:03 +00004213
4214#if HAVE_TZNAME
4215extern char *tzname[];
4216#endif
4217
Guido van Rossumd11b62e2003-03-14 21:51:36 +00004218int main()
4219{
Brett Cannon18367812003-09-19 00:59:16 +00004220 /* Note that we need to ensure that not only does tzset(3)
4221 do 'something' with localtime, but it works as documented
4222 in the library reference and as expected by the test suite.
Brett Cannon43802422005-02-10 20:48:03 +00004223 This includes making sure that tzname is set properly if
4224 tm->tm_zone does not exist since it is the alternative way
4225 of getting timezone info.
Brett Cannon18367812003-09-19 00:59:16 +00004226
4227 Red Hat 6.2 doesn't understand the southern hemisphere
Brett Cannon43802422005-02-10 20:48:03 +00004228 after New Year's Day.
Brett Cannon18367812003-09-19 00:59:16 +00004229 */
4230
Brett Cannon43802422005-02-10 20:48:03 +00004231 time_t groundhogday = 1044144000; /* GMT-based */
Brett Cannon18367812003-09-19 00:59:16 +00004232 time_t midyear = groundhogday + (365 * 24 * 3600 / 2);
4233
Neal Norwitz7f2588c2003-04-11 15:35:53 +00004234 putenv("TZ=UTC+0");
Guido van Rossumd11b62e2003-03-14 21:51:36 +00004235 tzset();
Brett Cannon18367812003-09-19 00:59:16 +00004236 if (localtime(&groundhogday)->tm_hour != 0)
4237 exit(1);
Brett Cannon43802422005-02-10 20:48:03 +00004238#if HAVE_TZNAME
4239 /* For UTC, tzname[1] is sometimes "", sometimes " " */
4240 if (strcmp(tzname[0], "UTC") ||
4241 (tzname[1][0] != 0 && tzname[1][0] != ' '))
4242 exit(1);
4243#endif
Brett Cannon18367812003-09-19 00:59:16 +00004244
Neal Norwitz7f2588c2003-04-11 15:35:53 +00004245 putenv("TZ=EST+5EDT,M4.1.0,M10.5.0");
Guido van Rossumd11b62e2003-03-14 21:51:36 +00004246 tzset();
Brett Cannon18367812003-09-19 00:59:16 +00004247 if (localtime(&groundhogday)->tm_hour != 19)
Guido van Rossumd11b62e2003-03-14 21:51:36 +00004248 exit(1);
Brett Cannon43802422005-02-10 20:48:03 +00004249#if HAVE_TZNAME
4250 if (strcmp(tzname[0], "EST") || strcmp(tzname[1], "EDT"))
4251 exit(1);
4252#endif
Brett Cannon18367812003-09-19 00:59:16 +00004253
4254 putenv("TZ=AEST-10AEDT-11,M10.5.0,M3.5.0");
4255 tzset();
4256 if (localtime(&groundhogday)->tm_hour != 11)
4257 exit(1);
Brett Cannon43802422005-02-10 20:48:03 +00004258#if HAVE_TZNAME
4259 if (strcmp(tzname[0], "AEST") || strcmp(tzname[1], "AEDT"))
4260 exit(1);
4261#endif
4262
4263#if HAVE_STRUCT_TM_TM_ZONE
Brett Cannon18367812003-09-19 00:59:16 +00004264 if (strcmp(localtime(&groundhogday)->tm_zone, "AEDT"))
4265 exit(1);
4266 if (strcmp(localtime(&midyear)->tm_zone, "AEST"))
4267 exit(1);
Brett Cannon43802422005-02-10 20:48:03 +00004268#endif
Brett Cannon18367812003-09-19 00:59:16 +00004269
Guido van Rossumd11b62e2003-03-14 21:51:36 +00004270 exit(0);
4271}
Matthias Klosec511b472010-05-08 11:01:39 +00004272]])],
4273[ac_cv_working_tzset=yes],
4274[ac_cv_working_tzset=no],
4275[ac_cv_working_tzset=no])])
Guido van Rossumd11b62e2003-03-14 21:51:36 +00004276AC_MSG_RESULT($ac_cv_working_tzset)
4277if test "$ac_cv_working_tzset" = yes
4278then
4279 AC_DEFINE(HAVE_WORKING_TZSET, 1,
4280 [Define if tzset() actually switches the local timezone in a meaningful way.])
4281fi
4282
Martin v. Löwis94717ed2002-09-09 14:24:16 +00004283# Look for subsecond timestamps in struct stat
4284AC_MSG_CHECKING(for tv_nsec in struct stat)
4285AC_CACHE_VAL(ac_cv_stat_tv_nsec,
Matthias Klosec511b472010-05-08 11:01:39 +00004286AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/stat.h>]], [[
Martin v. Löwis94717ed2002-09-09 14:24:16 +00004287struct stat st;
4288st.st_mtim.tv_nsec = 1;
Matthias Klosec511b472010-05-08 11:01:39 +00004289]])],
4290[ac_cv_stat_tv_nsec=yes],
4291[ac_cv_stat_tv_nsec=no]))
Martin v. Löwis94717ed2002-09-09 14:24:16 +00004292AC_MSG_RESULT($ac_cv_stat_tv_nsec)
4293if test "$ac_cv_stat_tv_nsec" = yes
4294then
4295 AC_DEFINE(HAVE_STAT_TV_NSEC, 1,
4296 [Define if you have struct stat.st_mtim.tv_nsec])
4297fi
4298
Martin v. Löwisebd9d5b2005-08-09 15:00:59 +00004299# Look for BSD style subsecond timestamps in struct stat
4300AC_MSG_CHECKING(for tv_nsec2 in struct stat)
4301AC_CACHE_VAL(ac_cv_stat_tv_nsec2,
Matthias Klosec511b472010-05-08 11:01:39 +00004302AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/stat.h>]], [[
Martin v. Löwisebd9d5b2005-08-09 15:00:59 +00004303struct stat st;
4304st.st_mtimespec.tv_nsec = 1;
Matthias Klosec511b472010-05-08 11:01:39 +00004305]])],
4306[ac_cv_stat_tv_nsec2=yes],
4307[ac_cv_stat_tv_nsec2=no]))
Martin v. Löwisebd9d5b2005-08-09 15:00:59 +00004308AC_MSG_RESULT($ac_cv_stat_tv_nsec2)
4309if test "$ac_cv_stat_tv_nsec2" = yes
4310then
4311 AC_DEFINE(HAVE_STAT_TV_NSEC2, 1,
4312 [Define if you have struct stat.st_mtimensec])
4313fi
4314
doko@ubuntu.comf27ec3e2014-04-17 20:11:19 +02004315# first curses configure check
4316ac_save_cppflags="$CPPFLAGS"
4317CPPFLAGS="$CPPFLAGS -I/usr/include/ncursesw"
4318
4319AC_CHECK_HEADERS(curses.h ncurses.h)
4320
4321# On Solaris, term.h requires curses.h
4322AC_CHECK_HEADERS(term.h,,,[
4323#ifdef HAVE_CURSES_H
4324#include <curses.h>
4325#endif
4326])
4327
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00004328# On HP/UX 11.0, mvwdelch is a block with a return statement
4329AC_MSG_CHECKING(whether mvwdelch is an expression)
4330AC_CACHE_VAL(ac_cv_mvwdelch_is_expression,
Matthias Klosec511b472010-05-08 11:01:39 +00004331AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <curses.h>]], [[
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00004332 int rtn;
4333 rtn = mvwdelch(0,0,0);
Matthias Klosec511b472010-05-08 11:01:39 +00004334]])],
4335[ac_cv_mvwdelch_is_expression=yes],
4336[ac_cv_mvwdelch_is_expression=no]))
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00004337AC_MSG_RESULT($ac_cv_mvwdelch_is_expression)
4338
4339if test "$ac_cv_mvwdelch_is_expression" = yes
4340then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00004341 AC_DEFINE(MVWDELCH_IS_EXPRESSION, 1,
4342 [Define if mvwdelch in curses.h is an expression.])
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00004343fi
4344
4345AC_MSG_CHECKING(whether WINDOW has _flags)
4346AC_CACHE_VAL(ac_cv_window_has_flags,
Matthias Klosec511b472010-05-08 11:01:39 +00004347AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <curses.h>]], [[
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00004348 WINDOW *w;
4349 w->_flags = 0;
Matthias Klosec511b472010-05-08 11:01:39 +00004350]])],
4351[ac_cv_window_has_flags=yes],
4352[ac_cv_window_has_flags=no]))
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00004353AC_MSG_RESULT($ac_cv_window_has_flags)
4354
4355
4356if test "$ac_cv_window_has_flags" = yes
4357then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00004358 AC_DEFINE(WINDOW_HAS_FLAGS, 1,
4359 [Define if WINDOW in curses.h offers a field _flags.])
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00004360fi
4361
Walter Dörwald4994d952006-06-19 08:07:50 +00004362AC_MSG_CHECKING(for is_term_resized)
Matthias Klosec511b472010-05-08 11:01:39 +00004363AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <curses.h>]], [[void *x=is_term_resized]])],
4364 [AC_DEFINE(HAVE_CURSES_IS_TERM_RESIZED, 1, Define if you have the 'is_term_resized' function.)
4365 AC_MSG_RESULT(yes)],
4366 [AC_MSG_RESULT(no)]
Walter Dörwald4994d952006-06-19 08:07:50 +00004367)
4368
Walter Dörwald05fdbf12006-06-19 08:14:09 +00004369AC_MSG_CHECKING(for resize_term)
Matthias Klosec511b472010-05-08 11:01:39 +00004370AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <curses.h>]], [[void *x=resize_term]])],
4371 [AC_DEFINE(HAVE_CURSES_RESIZE_TERM, 1, Define if you have the 'resize_term' function.)
4372 AC_MSG_RESULT(yes)],
4373 [AC_MSG_RESULT(no)]
Walter Dörwald4994d952006-06-19 08:07:50 +00004374)
4375
Walter Dörwald05fdbf12006-06-19 08:14:09 +00004376AC_MSG_CHECKING(for resizeterm)
Matthias Klosec511b472010-05-08 11:01:39 +00004377AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <curses.h>]], [[void *x=resizeterm]])],
4378 [AC_DEFINE(HAVE_CURSES_RESIZETERM, 1, Define if you have the 'resizeterm' function.)
4379 AC_MSG_RESULT(yes)],
4380 [AC_MSG_RESULT(no)]
Walter Dörwald4994d952006-06-19 08:07:50 +00004381)
doko@ubuntu.comf27ec3e2014-04-17 20:11:19 +02004382# last curses configure check
4383CPPFLAGS=$ac_save_cppflags
Walter Dörwald4994d952006-06-19 08:07:50 +00004384
doko@python.orgd65e2ba2013-01-31 23:52:03 +01004385AC_MSG_NOTICE([checking for device files])
Martin v. Löwisfefbc202006-10-17 18:59:23 +00004386
doko@python.orgd65e2ba2013-01-31 23:52:03 +01004387dnl NOTE: Inform user how to proceed with files when cross compiling.
4388if test "x$cross_compiling" = xyes; then
4389 if test "${ac_cv_file__dev_ptmx+set}" != set; then
4390 AC_MSG_CHECKING([for /dev/ptmx])
4391 AC_MSG_RESULT([not set])
4392 AC_MSG_ERROR([set ac_cv_file__dev_ptmx to yes/no in your CONFIG_SITE file when cross compiling])
4393 fi
4394 if test "${ac_cv_file__dev_ptc+set}" != set; then
4395 AC_MSG_CHECKING([for /dev/ptc])
4396 AC_MSG_RESULT([not set])
4397 AC_MSG_ERROR([set ac_cv_file__dev_ptc to yes/no in your CONFIG_SITE file when cross compiling])
4398 fi
Martin v. Löwisfefbc202006-10-17 18:59:23 +00004399fi
4400
doko@python.orgd65e2ba2013-01-31 23:52:03 +01004401AC_CHECK_FILE(/dev/ptmx, [], [])
4402if test "x$ac_cv_file__dev_ptmx" = xyes; then
4403 AC_DEFINE(HAVE_DEV_PTMX, 1,
4404 [Define to 1 if you have the /dev/ptmx device file.])
4405fi
4406AC_CHECK_FILE(/dev/ptc, [], [])
4407if test "x$ac_cv_file__dev_ptc" = xyes; then
Martin v. Löwisfefbc202006-10-17 18:59:23 +00004408 AC_DEFINE(HAVE_DEV_PTC, 1,
doko@python.orgd65e2ba2013-01-31 23:52:03 +01004409 [Define to 1 if you have the /dev/ptc device file.])
Martin v. Löwisfefbc202006-10-17 18:59:23 +00004410fi
Neal Norwitz865400f2003-03-21 01:42:58 +00004411
Mark Dickinson82864d12009-11-15 16:18:58 +00004412if test "$have_long_long" = yes
4413then
4414 AC_MSG_CHECKING(for %lld and %llu printf() format support)
4415 AC_CACHE_VAL(ac_cv_have_long_long_format,
Matthias Klosec511b472010-05-08 11:01:39 +00004416 AC_RUN_IFELSE([AC_LANG_SOURCE([[[
Mark Dickinson82864d12009-11-15 16:18:58 +00004417 #include <stdio.h>
4418 #include <stddef.h>
4419 #include <string.h>
4420
4421 #ifdef HAVE_SYS_TYPES_H
4422 #include <sys/types.h>
4423 #endif
4424
4425 int main()
4426 {
4427 char buffer[256];
4428
4429 if (sprintf(buffer, "%lld", (long long)123) < 0)
4430 return 1;
4431 if (strcmp(buffer, "123"))
4432 return 1;
4433
4434 if (sprintf(buffer, "%lld", (long long)-123) < 0)
4435 return 1;
4436 if (strcmp(buffer, "-123"))
4437 return 1;
4438
4439 if (sprintf(buffer, "%llu", (unsigned long long)123) < 0)
4440 return 1;
4441 if (strcmp(buffer, "123"))
4442 return 1;
4443
4444 return 0;
4445 }
Matthias Klosec511b472010-05-08 11:01:39 +00004446 ]]])],
4447 [ac_cv_have_long_long_format=yes],
4448 [ac_cv_have_long_long_format=no],
doko@python.orgd65e2ba2013-01-31 23:52:03 +01004449 [ac_cv_have_long_long_format="cross -- assuming no"
4450 if test x$GCC = xyes; then
4451 save_CFLAGS=$CFLAGS
4452 CFLAGS="$CFLAGS -Werror -Wformat"
4453 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4454 #include <stdio.h>
4455 #include <stddef.h>
4456 ]], [[
4457 char *buffer;
4458 sprintf(buffer, "%lld", (long long)123);
4459 sprintf(buffer, "%lld", (long long)-123);
4460 sprintf(buffer, "%llu", (unsigned long long)123);
4461 ]])],
4462 ac_cv_have_long_long_format=yes
4463 )
4464 CFLAGS=$save_CFLAGS
4465 fi])
Mark Dickinson82864d12009-11-15 16:18:58 +00004466 )
4467 AC_MSG_RESULT($ac_cv_have_long_long_format)
4468fi
4469
Mark Dickinson5ce84742009-12-31 20:48:04 +00004470if test "$ac_cv_have_long_long_format" = yes
Mark Dickinson82864d12009-11-15 16:18:58 +00004471then
4472 AC_DEFINE(PY_FORMAT_LONG_LONG, "ll",
4473 [Define to printf format modifier for long long type])
4474fi
4475
Ronald Oussoren315cd0c2009-11-19 16:25:21 +00004476if test $ac_sys_system = Darwin
4477then
4478 LIBS="$LIBS -framework CoreFoundation"
4479fi
4480
Mark Dickinson82864d12009-11-15 16:18:58 +00004481
Gregory P. Smithd8cb2d92009-11-02 02:02:38 +00004482AC_CACHE_CHECK([for %zd printf() format support], ac_cv_have_size_t_format, [dnl
Matthias Klosec511b472010-05-08 11:01:39 +00004483AC_RUN_IFELSE([AC_LANG_SOURCE([[
Alexandre Vassalottie7cf1182009-07-17 06:33:51 +00004484#include <stdio.h>
Brett Cannon09d12362006-05-11 05:11:33 +00004485#include <stddef.h>
4486#include <string.h>
4487
Christian Heimesdb3d6cb2007-12-16 21:39:43 +00004488#ifdef HAVE_SYS_TYPES_H
4489#include <sys/types.h>
4490#endif
Neal Norwitz4a8fbdb2006-09-22 08:16:26 +00004491
4492#ifdef HAVE_SSIZE_T
4493typedef ssize_t Py_ssize_t;
4494#elif SIZEOF_VOID_P == SIZEOF_LONG
4495typedef long Py_ssize_t;
4496#else
4497typedef int Py_ssize_t;
4498#endif
Brett Cannon09d12362006-05-11 05:11:33 +00004499
Christian Heimesdb3d6cb2007-12-16 21:39:43 +00004500int main()
4501{
4502 char buffer[256];
4503
Brett Cannon09d12362006-05-11 05:11:33 +00004504 if(sprintf(buffer, "%zd", (size_t)123) < 0)
4505 return 1;
4506
Neal Norwitz4a8fbdb2006-09-22 08:16:26 +00004507 if (strcmp(buffer, "123"))
Brett Cannon09d12362006-05-11 05:11:33 +00004508 return 1;
Neal Norwitz4a8fbdb2006-09-22 08:16:26 +00004509
4510 if (sprintf(buffer, "%zd", (Py_ssize_t)-123) < 0)
4511 return 1;
4512
4513 if (strcmp(buffer, "-123"))
4514 return 1;
4515
Brett Cannon09d12362006-05-11 05:11:33 +00004516 return 0;
Alexandre Vassalotti00900892009-07-17 05:26:39 +00004517}
Matthias Klosec511b472010-05-08 11:01:39 +00004518]])],
4519[ac_cv_have_size_t_format=yes],
4520[ac_cv_have_size_t_format=no],
4521[ac_cv_have_size_t_format="cross -- assuming yes"
4522])])
Gregory P. Smithd8cb2d92009-11-02 02:02:38 +00004523if test "$ac_cv_have_size_t_format" != no ; then
Alexandre Vassalotti00900892009-07-17 05:26:39 +00004524 AC_DEFINE(PY_FORMAT_SIZE_T, "z",
4525 [Define to printf format modifier for Py_ssize_t])
4526fi
Brett Cannon09d12362006-05-11 05:11:33 +00004527
Martin v. Löwis01c04012002-11-11 14:58:44 +00004528AC_CHECK_TYPE(socklen_t,,
4529 AC_DEFINE(socklen_t,int,
Matthias Klose5183ebd2010-04-24 16:38:36 +00004530 [Define to `int' if <sys/socket.h> does not define.]),[
Martin v. Löwis01c04012002-11-11 14:58:44 +00004531#ifdef HAVE_SYS_TYPES_H
4532#include <sys/types.h>
4533#endif
Guido van Rossum95713eb2000-05-18 20:53:31 +00004534#ifdef HAVE_SYS_SOCKET_H
4535#include <sys/socket.h>
4536#endif
Martin v. Löwis01c04012002-11-11 14:58:44 +00004537])
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00004538
R. David Murray1d9d16e2010-10-16 00:43:13 +00004539case $ac_sys_system in
4540AIX*)
4541 AC_DEFINE(HAVE_BROKEN_PIPE_BUF, 1, [Define if the system reports an invalid PIPE_BUF value.]) ;;
4542esac
4543
4544
Martin v. Löwis06f15bb2001-12-02 13:02:32 +00004545AC_SUBST(THREADHEADERS)
4546
4547for h in `(cd $srcdir;echo Python/thread_*.h)`
4548do
4549 THREADHEADERS="$THREADHEADERS \$(srcdir)/$h"
4550done
4551
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00004552AC_SUBST(SRCDIRS)
Neal Norwitzd24499d2005-12-18 21:36:39 +00004553SRCDIRS="Parser Grammar Objects Python Modules Mac"
Andrew M. Kuchling8abedde2001-01-26 22:55:24 +00004554AC_MSG_CHECKING(for build directories)
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00004555for dir in $SRCDIRS; do
4556 if test ! -d $dir; then
4557 mkdir $dir
Fred Drake884d3ba2000-11-02 17:52:56 +00004558 fi
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00004559done
4560AC_MSG_RESULT(done)
Fred Drake036144d2000-10-26 17:09:35 +00004561
Ned Deily3f1d0b32014-11-20 02:11:03 -08004562# ensurepip option
4563AC_MSG_CHECKING(for ensurepip)
4564AC_ARG_WITH(ensurepip,
4565 [AS_HELP_STRING([--with(out)-ensurepip=@<:@=OPTION@:>@],
4566 ["install" or "upgrade" using bundled pip, default is "no"])],
4567 [],
4568 [with_ensurepip=no])
4569AS_CASE($with_ensurepip,
4570 [yes|upgrade],[ENSUREPIP=upgrade],
4571 [install],[ENSUREPIP=install],
4572 [no],[ENSUREPIP=no],
4573 [AC_MSG_ERROR([--with-ensurepip=upgrade|install|no])])
4574AC_MSG_RESULT($ENSUREPIP)
4575AC_SUBST(ENSUREPIP)
4576
Guido van Rossum627b2d71993-12-24 10:39:16 +00004577# generate output files
Antoine Pitrouf2caeed2009-05-24 20:23:57 +00004578AC_CONFIG_FILES(Makefile.pre Modules/Setup.config Misc/python.pc)
Antoine Pitrouaabdceb2010-09-10 20:03:17 +00004579AC_CONFIG_FILES([Modules/ld_so_aix], [chmod +x Modules/ld_so_aix])
Martin v. Löwis88afe662002-10-26 13:47:44 +00004580AC_OUTPUT
Neil Schemenauer61c51152001-01-26 16:18:16 +00004581
Martin v. Löwisf7afe952006-04-14 15:16:15 +00004582echo "creating Modules/Setup"
Neil Schemenauer61c51152001-01-26 16:18:16 +00004583if test ! -f Modules/Setup
4584then
4585 cp $srcdir/Modules/Setup.dist Modules/Setup
4586fi
4587
Martin v. Löwisf7afe952006-04-14 15:16:15 +00004588echo "creating Modules/Setup.local"
Neil Schemenauer61c51152001-01-26 16:18:16 +00004589if test ! -f Modules/Setup.local
4590then
4591 echo "# Edit this file for local setup changes" >Modules/Setup.local
4592fi
4593
4594echo "creating Makefile"
4595$SHELL $srcdir/Modules/makesetup -c $srcdir/Modules/config.c.in \
4596 -s Modules Modules/Setup.config \
Neil Schemenauerf8b71c52001-04-21 17:41:16 +00004597 Modules/Setup.local Modules/Setup
Skip Montanaro7221d932007-08-22 19:02:16 +00004598
4599case $ac_sys_system in
4600BeOS)
4601 AC_MSG_WARN([
4602
4603 Support for BeOS is deprecated as of Python 2.6.
4604 See PEP 11 for the gory details.
4605 ])
4606 ;;
4607*) ;;
4608esac
4609
Neil Schemenauer66252162001-02-19 04:47:42 +00004610mv config.c Modules