blob: d33df2a0932b3f5dc5e36a96be68b7a79cc684b0 [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)
36 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/plat-$(MACHDEP) '$interp
37 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
Jack Jansen83f898c2002-12-30 22:23:40 +0000496# And add extra plat-mac for darwin
497AC_SUBST(EXTRAPLATDIR)
Jack Jansen7b59b422003-03-17 15:44:10 +0000498AC_SUBST(EXTRAMACHDEPPATH)
Jack Jansen83f898c2002-12-30 22:23:40 +0000499AC_MSG_CHECKING(EXTRAPLATDIR)
500if test -z "$EXTRAPLATDIR"
501then
502 case $MACHDEP in
Jack Jansen7b59b422003-03-17 15:44:10 +0000503 darwin)
504 EXTRAPLATDIR="\$(PLATMACDIRS)"
505 EXTRAMACHDEPPATH="\$(PLATMACPATH)"
506 ;;
507 *)
508 EXTRAPLATDIR=""
509 EXTRAMACHDEPPATH=""
510 ;;
Jack Jansen83f898c2002-12-30 22:23:40 +0000511 esac
512fi
513AC_MSG_RESULT($EXTRAPLATDIR)
514
Jack Jansen6b08a402004-06-03 12:41:45 +0000515# Record the configure-time value of MACOSX_DEPLOYMENT_TARGET,
516# it may influence the way we can build extensions, so distutils
517# needs to check it
518AC_SUBST(CONFIGURE_MACOSX_DEPLOYMENT_TARGET)
Ronald Oussoren988117f2006-04-29 11:31:35 +0000519AC_SUBST(EXPORT_MACOSX_DEPLOYMENT_TARGET)
Jack Jansen6b08a402004-06-03 12:41:45 +0000520CONFIGURE_MACOSX_DEPLOYMENT_TARGET=
Ronald Oussoren988117f2006-04-29 11:31:35 +0000521EXPORT_MACOSX_DEPLOYMENT_TARGET='#'
Jack Jansen6b08a402004-06-03 12:41:45 +0000522
Guido van Rossum627b2d71993-12-24 10:39:16 +0000523# checks for alternative programs
Skip Montanarodecc6a42003-01-01 20:07:49 +0000524
525# compiler flags are generated in two sets, BASECFLAGS and OPT. OPT is just
526# for debug/optimization stuff. BASECFLAGS is for flags that are required
527# just to get things to compile and link. Users are free to override OPT
528# when running configure or make. The build should not break if they do.
529# BASECFLAGS should generally not be messed with, however.
530
531# XXX shouldn't some/most/all of this code be merged with the stuff later
532# on that fiddles with OPT and BASECFLAGS?
Guido van Rossum5739e7e1995-01-20 16:50:53 +0000533AC_MSG_CHECKING(for --without-gcc)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000534AC_ARG_WITH(gcc,
Matthias Klose22520ea2010-05-08 10:14:46 +0000535 AS_HELP_STRING([--without-gcc], [never use gcc]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000536[
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000537 case $withval in
Skip Montanaro516144f2009-01-04 10:36:58 +0000538 no) CC=${CC:-cc}
Guido van Rossum5739e7e1995-01-20 16:50:53 +0000539 without_gcc=yes;;
540 yes) CC=gcc
541 without_gcc=no;;
542 *) CC=$withval
543 without_gcc=$withval;;
Guido van Rossum55a214e1995-09-13 17:48:09 +0000544 esac], [
Guido van Rossumb418f891996-07-30 18:06:02 +0000545 case $ac_sys_system in
Antoine Pitrou285cd162010-09-21 15:23:17 +0000546 AIX*) CC=${CC:-xlc_r}
Neil Schemenauerb3531b82001-02-16 04:09:05 +0000547 without_gcc=;;
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000548 BeOS*)
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000549 case $BE_HOST_CPU in
550 ppc)
Fred Drake5790be12000-10-09 17:06:13 +0000551 CC=mwcc
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000552 without_gcc=yes
Skip Montanarodecc6a42003-01-01 20:07:49 +0000553 BASECFLAGS="$BASECFLAGS -export pragma"
554 OPT="$OPT -O"
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000555 LDFLAGS="$LDFLAGS -nodup"
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000556 ;;
557 x86)
Fred Drake5790be12000-10-09 17:06:13 +0000558 CC=gcc
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000559 without_gcc=no
Skip Montanarodecc6a42003-01-01 20:07:49 +0000560 OPT="$OPT -O"
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000561 ;;
562 *)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000563 AC_MSG_ERROR([Unknown BeOS platform "$BE_HOST_CPU"])
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000564 ;;
565 esac
Neil Schemenauerb3531b82001-02-16 04:09:05 +0000566 AR="\$(srcdir)/Modules/ar_beos"
567 RANLIB=:
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000568 ;;
Martin v. Löwis130fb172001-07-19 11:00:41 +0000569 *) without_gcc=no;;
Guido van Rossum55a214e1995-09-13 17:48:09 +0000570 esac])
Guido van Rossum5739e7e1995-01-20 16:50:53 +0000571AC_MSG_RESULT($without_gcc)
572
Guido van Rossum03ad99f1995-03-09 14:09:54 +0000573# If the user switches compilers, we can't believe the cache
574if test ! -z "$ac_cv_prog_CC" -a ! -z "$CC" -a "$CC" != "$ac_cv_prog_CC"
575then
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000576 AC_MSG_ERROR([cached CC is different -- throw away $cache_file
577(it is also a good idea to do 'make clean' before compiling)])
Guido van Rossum03ad99f1995-03-09 14:09:54 +0000578fi
579
Trent Nelson15daa352012-12-13 06:46:39 +0000580if test "$MACHDEP" = "irix6" && test "$CC" != "gcc"; then
581 # Normally, MIPSpro CC treats #error directives as warnings, which means
582 # a successful exit code is returned (0). This is a problem because IRIX
583 # has a bunch of system headers with this guard at the top:
584 #
585 # #ifndef __c99
586 # #error This header file is to be used only for c99 mode compilations
587 # #else
588 #
589 # When autoconf tests for such a header, like stdint.h, this happens:
590 #
591 # configure:4619: cc -c conftest.c >&5
592 # cc-1035 cc: WARNING File = /usr/include/stdint.h, Line = 5
593 # #error directive: This header file is to be used only for c99 mode
594 # compilations
595 #
596 # #error This header file is to be used only for c99 mode compilations
597 # ^
598 #
599 # configure:4619: $? = 0
600 # configure:4619: result: yes
601 #
602 # Therefore, we use `-diag_error 1035` to have the compiler treat the
603 # warning as an error, which causes cc to return a non-zero result,
604 # which autoconf can interpret correctly.
605 CFLAGS="$CFLAGS -diag_error 1035"
606 # Whilst we're here, we might as well make sure CXX defaults to something
607 # sensible if we're not using gcc.
608 if test -z "$CXX"; then
609 CXX="CC"
610 fi
611fi
612
Marc-André Lemburg6d5e5792010-04-30 17:20:14 +0000613# If the user set CFLAGS, use this instead of the automatically
614# determined setting
615preset_cflags="$CFLAGS"
Guido van Rossum627b2d71993-12-24 10:39:16 +0000616AC_PROG_CC
Marc-André Lemburg6d5e5792010-04-30 17:20:14 +0000617if test ! -z "$preset_cflags"
618then
619 CFLAGS=$preset_cflags
620fi
Martin v. Löwis1d5ecb72001-08-09 10:29:44 +0000621
Martin v. Löwis0f48d982006-04-14 14:34:26 +0000622AC_SUBST(CXX)
623AC_SUBST(MAINCC)
624AC_MSG_CHECKING(for --with-cxx-main=<compiler>)
625AC_ARG_WITH(cxx_main,
Matthias Klose22520ea2010-05-08 10:14:46 +0000626 AS_HELP_STRING([--with-cxx-main=<compiler>],
Martin v. Löwis0f48d982006-04-14 14:34:26 +0000627 [compile main() and link python executable with C++ compiler]),
628[
629
630 case $withval in
631 no) with_cxx_main=no
632 MAINCC='$(CC)';;
633 yes) with_cxx_main=yes
634 MAINCC='$(CXX)';;
635 *) with_cxx_main=yes
636 MAINCC=$withval
637 if test -z "$CXX"
638 then
639 CXX=$withval
640 fi;;
641 esac], [
642 with_cxx_main=no
643 MAINCC='$(CC)'
644])
645AC_MSG_RESULT($with_cxx_main)
646
647preset_cxx="$CXX"
648if test -z "$CXX"
649then
650 case "$CC" in
doko@python.orgd65e2ba2013-01-31 23:52:03 +0100651 gcc) AC_PATH_TOOL(CXX, [g++], [g++], [notfound]) ;;
652 cc) AC_PATH_TOOL(CXX, [c++], [c++], [notfound]) ;;
Martin v. Löwis0f48d982006-04-14 14:34:26 +0000653 esac
654 if test "$CXX" = "notfound"
655 then
656 CXX=""
657 fi
658fi
659if test -z "$CXX"
660then
doko@python.orgd65e2ba2013-01-31 23:52:03 +0100661 AC_CHECK_TOOLS(CXX, $CCC c++ g++ gcc CC cxx cc++ cl, notfound)
Martin v. Löwis0f48d982006-04-14 14:34:26 +0000662 if test "$CXX" = "notfound"
663 then
664 CXX=""
665 fi
666fi
667if test "$preset_cxx" != "$CXX"
668then
669 AC_MSG_WARN([
670
671 By default, distutils will build C++ extension modules with "$CXX".
672 If this is not intended, then set CXX on the configure command line.
673 ])
674fi
675
doko@python.org4e63fbe2013-01-25 13:08:27 +0100676MULTIARCH=$($CC --print-multiarch 2>/dev/null)
677AC_SUBST(MULTIARCH)
678
Martin v. Löwis0f48d982006-04-14 14:34:26 +0000679
Martin v. Löwis1d5ecb72001-08-09 10:29:44 +0000680# checks for UNIX variants that set C preprocessor variables
Matthias Klose9f8e0c12010-05-08 10:17:27 +0000681AC_USE_SYSTEM_EXTENSIONS
Martin v. Löwis1d5ecb72001-08-09 10:29:44 +0000682
Martin v. Löwis779ffc02002-12-02 22:17:01 +0000683# Check for unsupported systems
684case $ac_sys_system/$ac_sys_release in
Brett Cannon19fab762007-06-02 03:02:29 +0000685atheos*|Linux*/1*)
Martin v. Löwis779ffc02002-12-02 22:17:01 +0000686 echo This system \($ac_sys_system/$ac_sys_release\) is no longer supported.
687 echo See README for details.
688 exit 1;;
689esac
690
Neil Schemenauer55f0cf32001-01-24 17:24:33 +0000691AC_EXEEXT
Neil Schemenauer3ae1d0a2001-01-27 06:54:42 +0000692AC_MSG_CHECKING(for --with-suffix)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000693AC_ARG_WITH(suffix,
Matthias Klose22520ea2010-05-08 10:14:46 +0000694 AS_HELP_STRING([--with-suffix=.exe], [set executable suffix]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000695[
Neil Schemenauer3ae1d0a2001-01-27 06:54:42 +0000696 case $withval in
697 no) EXEEXT=;;
698 yes) EXEEXT=.exe;;
699 *) EXEEXT=$withval;;
700 esac])
701AC_MSG_RESULT($EXEEXT)
Jack Jansen1999ef42001-12-06 21:47:20 +0000702
Jack Jansen9a66b6d2001-08-08 13:56:14 +0000703# Test whether we're running on a non-case-sensitive system, in which
704# case we give a warning if no ext is given
Jack Jansen1999ef42001-12-06 21:47:20 +0000705AC_SUBST(BUILDEXEEXT)
706AC_MSG_CHECKING(for case-insensitive build directory)
Jack Jansen3c2c4332002-11-06 13:33:32 +0000707if test ! -d CaseSensitiveTestDir; then
708mkdir CaseSensitiveTestDir
709fi
710
711if test -d casesensitivetestdir
Jack Jansen9a66b6d2001-08-08 13:56:14 +0000712then
Jack Jansen1999ef42001-12-06 21:47:20 +0000713 AC_MSG_RESULT(yes)
714 BUILDEXEEXT=.exe
715else
716 AC_MSG_RESULT(no)
Jack Jansendd19cf82001-12-06 22:36:17 +0000717 BUILDEXEEXT=$EXEEXT
Jack Jansen9a66b6d2001-08-08 13:56:14 +0000718fi
Jack Jansen3c2c4332002-11-06 13:33:32 +0000719rmdir CaseSensitiveTestDir
Guido van Rossumfb842551997-08-06 23:42:07 +0000720
Guido van Rossumdd997f71998-10-07 19:58:26 +0000721case $MACHDEP in
722bsdos*)
723 case $CC in
724 gcc) CC="$CC -D_HAVE_BSDI";;
725 esac;;
726esac
727
Guido van Rossum84561611997-08-21 00:08:11 +0000728case $ac_sys_system in
729hp*|HP*)
730 case $CC in
Guido van Rossumcd5ff9f2000-09-22 16:15:54 +0000731 cc|*/cc) CC="$CC -Ae";;
Guido van Rossum84561611997-08-21 00:08:11 +0000732 esac;;
Martin v. Löwise8964d42001-03-06 12:09:07 +0000733SunOS*)
734 # Some functions have a prototype only with that define, e.g. confstr
Martin v. Löwisc45929e2002-04-06 10:10:49 +0000735 AC_DEFINE(__EXTENSIONS__, 1, [Defined on Solaris to see additional function prototypes.])
Martin v. Löwise8964d42001-03-06 12:09:07 +0000736 ;;
Guido van Rossum84561611997-08-21 00:08:11 +0000737esac
738
Martin v. Löwise8964d42001-03-06 12:09:07 +0000739
Neil Schemenauer61c51152001-01-26 16:18:16 +0000740AC_SUBST(LIBRARY)
741AC_MSG_CHECKING(LIBRARY)
742if test -z "$LIBRARY"
743then
744 LIBRARY='libpython$(VERSION).a'
745fi
746AC_MSG_RESULT($LIBRARY)
747
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000748# LDLIBRARY is the name of the library to link against (as opposed to the
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000749# name of the library into which to insert object files). BLDLIBRARY is also
750# the library to link against, usually. On Mac OS X frameworks, BLDLIBRARY
751# is blank as the main program is not linked directly against LDLIBRARY.
752# LDLIBRARYDIR is the path to LDLIBRARY, which is made in a subdirectory. On
753# systems without shared libraries, LDLIBRARY is the same as LIBRARY
754# (defined in the Makefiles). On Cygwin LDLIBRARY is the import library,
755# DLLLIBRARY is the shared (i.e., DLL) library.
756#
Martin v. Löwis1142de32002-03-29 16:28:31 +0000757# RUNSHARED is used to run shared python without installed libraries
758#
759# INSTSONAME is the name of the shared library that will be use to install
760# on the system - some systems like version suffix, others don't
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000761AC_SUBST(LDLIBRARY)
Guido van Rossum27552902001-01-23 01:52:26 +0000762AC_SUBST(DLLLIBRARY)
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000763AC_SUBST(BLDLIBRARY)
764AC_SUBST(LDLIBRARYDIR)
Martin v. Löwis1142de32002-03-29 16:28:31 +0000765AC_SUBST(INSTSONAME)
766AC_SUBST(RUNSHARED)
Neil Schemenauer61c51152001-01-26 16:18:16 +0000767LDLIBRARY="$LIBRARY"
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000768BLDLIBRARY='$(LDLIBRARY)'
Martin v. Löwis09bdf722002-05-08 08:51:29 +0000769INSTSONAME='$(LDLIBRARY)'
Guido van Rossum27552902001-01-23 01:52:26 +0000770DLLLIBRARY=''
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000771LDLIBRARYDIR=''
Martin v. Löwis1142de32002-03-29 16:28:31 +0000772RUNSHARED=''
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000773
Guido van Rossumfb842551997-08-06 23:42:07 +0000774# LINKCC is the command that links the python executable -- default is $(CC).
Martin v. Löwisb7da67a2001-10-18 15:35:38 +0000775# If CXX is set, and if it is needed to link a main function that was
776# compiled with CXX, LINKCC is CXX instead. Always using CXX is undesirable:
777# python might then depend on the C++ runtime
Fred Drake5790be12000-10-09 17:06:13 +0000778# This is altered for AIX in order to build the export list before
Guido van Rossumec95c7b1998-08-04 17:59:56 +0000779# linking.
Guido van Rossumfb842551997-08-06 23:42:07 +0000780AC_SUBST(LINKCC)
781AC_MSG_CHECKING(LINKCC)
782if test -z "$LINKCC"
783then
Martin v. Löwis0f48d982006-04-14 14:34:26 +0000784 LINKCC='$(PURIFY) $(MAINCC)'
Guido van Rossumfb842551997-08-06 23:42:07 +0000785 case $ac_sys_system in
786 AIX*)
Neal Norwitz0b27ff92003-03-31 15:53:49 +0000787 exp_extra="\"\""
788 if test $ac_sys_release -ge 5 -o \
789 $ac_sys_release -eq 4 -a `uname -r` -ge 2 ; then
790 exp_extra="."
791 fi
792 LINKCC="\$(srcdir)/Modules/makexp_aix Modules/python.exp $exp_extra \$(LIBRARY); $LINKCC";;
Martin v. Löwis8c255e42008-05-23 15:06:50 +0000793 QNX*)
794 # qcc must be used because the other compilers do not
795 # support -N.
796 LINKCC=qcc;;
Guido van Rossumfb842551997-08-06 23:42:07 +0000797 esac
798fi
799AC_MSG_RESULT($LINKCC)
800
Tarek Ziadée2be83d2009-05-09 08:28:53 +0000801# GNULD is set to "yes" if the GNU linker is used. If this goes wrong
802# make sure we default having it set to "no": this is used by
803# distutils.unixccompiler to know if it should add --enable-new-dtags
804# to linker command lines, and failing to detect GNU ld simply results
805# in the same bahaviour as before.
806AC_SUBST(GNULD)
807AC_MSG_CHECKING(for GNU ld)
808ac_prog=ld
809if test "$GCC" = yes; then
810 ac_prog=`$CC -print-prog-name=ld`
811fi
812case `"$ac_prog" -V 2>&1 < /dev/null` in
813 *GNU*)
814 GNULD=yes;;
815 *)
816 GNULD=no;;
817esac
818AC_MSG_RESULT($GNULD)
819
Martin v. Löwis1142de32002-03-29 16:28:31 +0000820AC_MSG_CHECKING(for --enable-shared)
821AC_ARG_ENABLE(shared,
Matthias Klose22520ea2010-05-08 10:14:46 +0000822 AS_HELP_STRING([--enable-shared], [disable/enable building shared python library]))
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000823
Martin v. Löwis1142de32002-03-29 16:28:31 +0000824if test -z "$enable_shared"
825then
Martin v. Löwisb51033d2002-05-03 05:53:15 +0000826 case $ac_sys_system in
Martin v. Löwisf90ae202002-06-11 06:22:31 +0000827 CYGWIN* | atheos*)
Martin v. Löwisb51033d2002-05-03 05:53:15 +0000828 enable_shared="yes";;
829 *)
830 enable_shared="no";;
831 esac
Martin v. Löwis1142de32002-03-29 16:28:31 +0000832fi
833AC_MSG_RESULT($enable_shared)
834
Skip Montanaro56f6a4f2004-06-18 02:47:22 +0000835AC_MSG_CHECKING(for --enable-profiling)
836AC_ARG_ENABLE(profiling,
doko@python.orgd65e2ba2013-01-31 23:52:03 +0100837 AS_HELP_STRING([--enable-profiling], [enable C-level code profiling]))
838if test "x$enable_profiling" = xyes; then
839 ac_save_cc="$CC"
Benjamin Petersonb9be7bb2013-03-26 08:55:37 -0400840 CC="$CC -pg"
doko@python.orgd65e2ba2013-01-31 23:52:03 +0100841 AC_LINK_IFELSE([AC_LANG_SOURCE([[int main() { return 0; }]])],
842 [],
843 [enable_profiling=no])
844 CC="$ac_save_cc"
845else
846 enable_profiling=no
847fi
848AC_MSG_RESULT($enable_profiling)
Skip Montanaro56f6a4f2004-06-18 02:47:22 +0000849
doko@python.orgd65e2ba2013-01-31 23:52:03 +0100850if test "x$enable_profiling" = xyes; then
851 BASECFLAGS="-pg $BASECFLAGS"
852 LDFLAGS="-pg $LDFLAGS"
853fi
Martin v. Löwis1142de32002-03-29 16:28:31 +0000854
855AC_MSG_CHECKING(LDLIBRARY)
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000856
Guido van Rossumb8552162001-09-05 14:58:11 +0000857# MacOSX framework builds need more magic. LDLIBRARY is the dynamic
858# library that we build, but we do not want to link against it (we
859# will find it with a -framework option). For this reason there is an
860# extra variable BLDLIBRARY against which Python and the extension
861# modules are linked, BLDLIBRARY. This is normally the same as
862# LDLIBRARY, but empty for MacOSX framework builds.
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000863if test "$enable_framework"
864then
865 LDLIBRARY='$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
doko@ubuntu.com9ba90c92014-05-07 04:41:26 +0200866 RUNSHARED=DYLD_FRAMEWORK_PATH=`pwd`${DYLD_FRAMEWORK_PATH:+:${DYLD_FRAMEWORK_PATH}}
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000867 BLDLIBRARY=''
868else
869 BLDLIBRARY='$(LDLIBRARY)'
870fi
871
Martin v. Löwis1142de32002-03-29 16:28:31 +0000872# Other platforms follow
873if test $enable_shared = "yes"; then
Mark Hammond8235ea12002-07-19 06:55:41 +0000874 AC_DEFINE(Py_ENABLE_SHARED, 1, [Defined if Python is built as a shared library.])
Martin v. Löwis1142de32002-03-29 16:28:31 +0000875 case $ac_sys_system in
876 BeOS*)
877 LDLIBRARY='libpython$(VERSION).so'
878 ;;
879 CYGWIN*)
880 LDLIBRARY='libpython$(VERSION).dll.a'
881 DLLLIBRARY='libpython$(VERSION).dll'
882 ;;
883 SunOS*)
884 LDLIBRARY='libpython$(VERSION).so'
Martin v. Löwisd141a8c2003-06-14 15:20:28 +0000885 BLDLIBRARY='-Wl,-R,$(LIBDIR) -L. -lpython$(VERSION)'
doko@ubuntu.com9ba90c92014-05-07 04:41:26 +0200886 RUNSHARED=LD_LIBRARY_PATH=`pwd`${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
Martin v. Löwis2389c412003-10-31 15:42:07 +0000887 INSTSONAME="$LDLIBRARY".$SOVERSION
Martin v. Löwis1142de32002-03-29 16:28:31 +0000888 ;;
Charles-François Natali3de8c732011-07-24 22:33:35 +0200889 Linux*|GNU*|NetBSD*|FreeBSD*|DragonFly*|OpenBSD*)
Martin v. Löwis1142de32002-03-29 16:28:31 +0000890 LDLIBRARY='libpython$(VERSION).so'
891 BLDLIBRARY='-L. -lpython$(VERSION)'
doko@ubuntu.com9ba90c92014-05-07 04:41:26 +0200892 RUNSHARED=LD_LIBRARY_PATH=`pwd`${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
Hye-Shik Chang33761492004-10-26 09:53:46 +0000893 case $ac_sys_system in
894 FreeBSD*)
895 SOVERSION=`echo $SOVERSION|cut -d "." -f 1`
896 ;;
897 esac
Martin v. Löwis1142de32002-03-29 16:28:31 +0000898 INSTSONAME="$LDLIBRARY".$SOVERSION
899 ;;
900 hp*|HP*)
Neal Norwitz58e28882006-05-19 07:00:58 +0000901 case `uname -m` in
902 ia64)
903 LDLIBRARY='libpython$(VERSION).so'
904 ;;
905 *)
906 LDLIBRARY='libpython$(VERSION).sl'
907 ;;
908 esac
Martin v. Löwis1142de32002-03-29 16:28:31 +0000909 BLDLIBRARY='-Wl,+b,$(LIBDIR) -L. -lpython$(VERSION)'
doko@ubuntu.com9ba90c92014-05-07 04:41:26 +0200910 RUNSHARED=SHLIB_PATH=`pwd`${SHLIB_PATH:+:${SHLIB_PATH}}
Martin v. Löwis1142de32002-03-29 16:28:31 +0000911 ;;
912 OSF*)
913 LDLIBRARY='libpython$(VERSION).so'
Neal Norwitz671b9e32006-01-09 07:07:12 +0000914 BLDLIBRARY='-rpath $(LIBDIR) -L. -lpython$(VERSION)'
doko@ubuntu.com9ba90c92014-05-07 04:41:26 +0200915 RUNSHARED=LD_LIBRARY_PATH=`pwd`${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
Martin v. Löwis1142de32002-03-29 16:28:31 +0000916 ;;
Martin v. Löwisf90ae202002-06-11 06:22:31 +0000917 atheos*)
918 LDLIBRARY='libpython$(VERSION).so'
919 BLDLIBRARY='-L. -lpython$(VERSION)'
920 RUNSHARED=DLL_PATH=`pwd`:${DLL_PATH:-/atheos/sys/libs:/atheos/autolnk/lib}
921 ;;
Ronald Oussoren79f90492009-01-02 10:44:46 +0000922 Darwin*)
923 LDLIBRARY='libpython$(VERSION).dylib'
924 BLDLIBRARY='-L. -lpython$(VERSION)'
doko@ubuntu.com9ba90c92014-05-07 04:41:26 +0200925 RUNSHARED=DYLD_LIBRARY_PATH=`pwd`${DYLD_LIBRARY_PATH:+:${DYLD_LIBRARY_PATH}}
Ronald Oussoren79f90492009-01-02 10:44:46 +0000926 ;;
Antoine Pitrouaabdceb2010-09-10 20:03:17 +0000927 AIX*)
928 LDLIBRARY='libpython$(VERSION).so'
doko@ubuntu.com9ba90c92014-05-07 04:41:26 +0200929 RUNSHARED=LIBPATH=`pwd`${LIBPATH:+:${LIBPATH}}
Antoine Pitrouaabdceb2010-09-10 20:03:17 +0000930 ;;
Ronald Oussoren79f90492009-01-02 10:44:46 +0000931
Martin v. Löwis1142de32002-03-29 16:28:31 +0000932 esac
Jason Tishler30765592003-09-04 11:04:06 +0000933else # shared is disabled
934 case $ac_sys_system in
935 CYGWIN*)
936 BLDLIBRARY='$(LIBRARY)'
937 LDLIBRARY='libpython$(VERSION).dll.a'
938 ;;
939 esac
Martin v. Löwis1142de32002-03-29 16:28:31 +0000940fi
941
doko@python.orgd65e2ba2013-01-31 23:52:03 +0100942if test "$cross_compiling" = yes; then
943 RUNSHARED=
944fi
945
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000946AC_MSG_RESULT($LDLIBRARY)
947
Guido van Rossum627b2d71993-12-24 10:39:16 +0000948AC_PROG_RANLIB
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000949AC_SUBST(AR)
doko@python.orgd65e2ba2013-01-31 23:52:03 +0100950AC_CHECK_TOOLS(AR, ar aal, ar)
Neil Schemenauera42c8272001-03-31 00:01:55 +0000951
Tarek Ziadé99f660a2009-05-07 21:20:34 +0000952# tweak ARFLAGS only if the user didn't set it on the command line
953AC_SUBST(ARFLAGS)
954if test -z "$ARFLAGS"
955then
956 ARFLAGS="rc"
957fi
958
Martin v. Löwisdea59e52006-01-05 10:00:36 +0000959AC_SUBST(SVNVERSION)
Martin v. Löwisff600232006-04-03 19:12:32 +0000960AC_CHECK_PROG(SVNVERSION, svnversion, found, not-found)
Martin v. Löwisc5bf5a02006-01-05 10:33:59 +0000961if test $SVNVERSION = found
962then
963 SVNVERSION="svnversion \$(srcdir)"
964else
Benjamin Petersone5afa3b2009-05-23 19:24:37 +0000965 SVNVERSION="echo Unversioned directory"
Martin v. Löwisc5bf5a02006-01-05 10:33:59 +0000966fi
Martin v. Löwisdea59e52006-01-05 10:00:36 +0000967
Trent Nelsond86ceec2012-10-16 09:42:45 -0400968AC_SUBST(BASECPPFLAGS)
Trent Nelsonabf20512012-10-17 04:32:49 -0400969if test "$abs_srcdir" != "$abs_builddir"; then
Trent Nelsond86ceec2012-10-16 09:42:45 -0400970 # If we're building out-of-tree make sure Include (in the current dir)
971 # gets picked up before its $srcdir counterpart in order for Python-ast.h
972 # and graminit.h to get picked up from the correct directory.
973 # (A side effect of this is that these resources will automatically be
974 # regenerated when building out-of-tree, regardless of whether or not
975 # the $srcdir counterpart is up-to-date. This is an acceptable trade
976 # off.)
977 BASECPPFLAGS="-IInclude"
978else
979 BASECPPFLAGS=""
980fi
981
Georg Brandl3a5508e2011-03-06 10:42:21 +0100982AC_SUBST(HGVERSION)
983AC_SUBST(HGTAG)
984AC_SUBST(HGBRANCH)
985AC_CHECK_PROG(HAS_HG, hg, found, not-found)
986if test $HAS_HG = found
987then
988 HGVERSION="hg id -i \$(srcdir)"
989 HGTAG="hg id -t \$(srcdir)"
990 HGBRANCH="hg id -b \$(srcdir)"
991else
992 HGVERSION=""
993 HGTAG=""
994 HGBRANCH=""
995fi
996
Neil Schemenauera42c8272001-03-31 00:01:55 +0000997case $MACHDEP in
Neil Schemenaueraf5567f2001-10-21 22:32:04 +0000998bsdos*|hp*|HP*)
999 # install -d does not work on BSDI or HP-UX
Neil Schemenauera42c8272001-03-31 00:01:55 +00001000 if test -z "$INSTALL"
1001 then
1002 INSTALL="${srcdir}/install-sh -c"
1003 fi
1004esac
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00001005AC_PROG_INSTALL
Trent Nelsonf6407a12012-08-30 14:56:13 +00001006AC_PROG_MKDIR_P
Guido van Rossumb418f891996-07-30 18:06:02 +00001007
Guido van Rossumec95c7b1998-08-04 17:59:56 +00001008# Not every filesystem supports hard links
1009AC_SUBST(LN)
1010if test -z "$LN" ; then
1011 case $ac_sys_system in
1012 BeOS*) LN="ln -s";;
Guido van Rossumaef734b2001-01-10 21:09:12 +00001013 CYGWIN*) LN="ln -s";;
Martin v. Löwisf90ae202002-06-11 06:22:31 +00001014 atheos*) LN="ln -s";;
Guido van Rossumec95c7b1998-08-04 17:59:56 +00001015 *) LN=ln;;
1016 esac
1017fi
1018
Fred Drake9f715822001-07-11 06:27:00 +00001019# Check for --with-pydebug
1020AC_MSG_CHECKING(for --with-pydebug)
1021AC_ARG_WITH(pydebug,
Matthias Klose22520ea2010-05-08 10:14:46 +00001022 AS_HELP_STRING([--with-pydebug], [build with Py_DEBUG defined]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00001023[
Fred Drake9f715822001-07-11 06:27:00 +00001024if test "$withval" != no
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001025then
1026 AC_DEFINE(Py_DEBUG, 1,
1027 [Define if you want to build an interpreter with many run-time checks.])
1028 AC_MSG_RESULT(yes);
1029 Py_DEBUG='true'
Fred Drake9f715822001-07-11 06:27:00 +00001030else AC_MSG_RESULT(no); Py_DEBUG='false'
1031fi],
1032[AC_MSG_RESULT(no)])
1033
Skip Montanarodecc6a42003-01-01 20:07:49 +00001034# XXX Shouldn't the code above that fiddles with BASECFLAGS and OPT be
1035# merged with this chunk of code?
1036
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00001037# Optimizer/debugger flags
Skip Montanarodecc6a42003-01-01 20:07:49 +00001038# ------------------------
1039# (The following bit of code is complicated enough - please keep things
1040# indented properly. Just pretend you're editing Python code. ;-)
1041
1042# There are two parallel sets of case statements below, one that checks to
1043# see if OPT was set and one that does BASECFLAGS setting based upon
1044# compiler and platform. BASECFLAGS tweaks need to be made even if the
1045# user set OPT.
1046
1047# tweak OPT based on compiler and platform, only if the user didn't set
1048# it on the command line
Guido van Rossumb418f891996-07-30 18:06:02 +00001049AC_SUBST(OPT)
Benjamin Petersond4b721b2010-03-23 20:58:37 +00001050if test "${OPT-unset}" = "unset"
Guido van Rossumb418f891996-07-30 18:06:02 +00001051then
Skip Montanarodecc6a42003-01-01 20:07:49 +00001052 case $GCC in
1053 yes)
Skip Montanaro288a5be2006-04-13 02:00:56 +00001054 if test "$CC" != 'g++' ; then
1055 STRICT_PROTO="-Wstrict-prototypes"
1056 fi
Guido van Rossum7c862f82007-12-13 20:50:10 +00001057 # For gcc 4.x we need to use -fwrapv so lets check if its supported
1058 if "$CC" -v --help 2>/dev/null |grep -- -fwrapv > /dev/null; then
1059 WRAP="-fwrapv"
1060 fi
Stefan Krah503e5e12011-09-14 15:19:42 +02001061
1062 # Clang also needs -fwrapv
Stefan Krah2bc1e8f2011-12-08 22:26:06 +01001063 case $CC in
1064 *clang*) WRAP="-fwrapv"
1065 ;;
1066 esac
Stefan Krah503e5e12011-09-14 15:19:42 +02001067
Skip Montanarodecc6a42003-01-01 20:07:49 +00001068 case $ac_cv_prog_cc_g in
Guido van Rossum2242f2f2001-04-11 20:58:20 +00001069 yes)
Fred Drake9f715822001-07-11 06:27:00 +00001070 if test "$Py_DEBUG" = 'true' ; then
1071 # Optimization messes up debuggers, so turn it off for
1072 # debug builds.
Mark Dickinsond2f3e3f2010-05-05 22:23:58 +00001073 OPT="-g -O0 -Wall $STRICT_PROTO"
Fred Drake9f715822001-07-11 06:27:00 +00001074 else
Guido van Rossum7c862f82007-12-13 20:50:10 +00001075 OPT="-g $WRAP -O3 -Wall $STRICT_PROTO"
Skip Montanarodecc6a42003-01-01 20:07:49 +00001076 fi
1077 ;;
Guido van Rossum2242f2f2001-04-11 20:58:20 +00001078 *)
Skip Montanaro288a5be2006-04-13 02:00:56 +00001079 OPT="-O3 -Wall $STRICT_PROTO"
Skip Montanarodecc6a42003-01-01 20:07:49 +00001080 ;;
Fred Drake9f715822001-07-11 06:27:00 +00001081 esac
Martin v. Löwis21ee4092002-09-30 16:19:48 +00001082 case $ac_sys_system in
Skip Montanarodecc6a42003-01-01 20:07:49 +00001083 SCO_SV*) OPT="$OPT -m486 -DSCO5"
1084 ;;
1085 esac
Fred Drake9f715822001-07-11 06:27:00 +00001086 ;;
Skip Montanarodecc6a42003-01-01 20:07:49 +00001087
Guido van Rossum2242f2f2001-04-11 20:58:20 +00001088 *)
Skip Montanarodecc6a42003-01-01 20:07:49 +00001089 OPT="-O"
1090 ;;
Guido van Rossum2242f2f2001-04-11 20:58:20 +00001091 esac
Guido van Rossum4e8af441994-08-19 15:33:54 +00001092fi
Guido van Rossum627b2d71993-12-24 10:39:16 +00001093
Skip Montanarodecc6a42003-01-01 20:07:49 +00001094AC_SUBST(BASECFLAGS)
Ronald Oussoren5640ce22008-06-05 12:58:24 +00001095
1096# The -arch flags for universal builds on OSX
1097UNIVERSAL_ARCH_FLAGS=
1098AC_SUBST(UNIVERSAL_ARCH_FLAGS)
1099
Skip Montanarodecc6a42003-01-01 20:07:49 +00001100# tweak BASECFLAGS based on compiler and platform
1101case $GCC in
1102yes)
Martin v. Löwis70fedcd2003-07-07 21:26:19 +00001103 # Python violates C99 rules, by casting between incompatible
1104 # pointer types. GCC may generate bad code as a result of that,
1105 # so use -fno-strict-aliasing if supported.
1106 AC_MSG_CHECKING(whether $CC accepts -fno-strict-aliasing)
1107 ac_save_cc="$CC"
1108 CC="$CC -fno-strict-aliasing"
Alexandre Vassalotti00900892009-07-17 05:26:39 +00001109 AC_CACHE_VAL(ac_cv_no_strict_aliasing_ok,
Matthias Klosec511b472010-05-08 11:01:39 +00001110 AC_COMPILE_IFELSE(
Mark Dickinson5e13e292010-05-11 08:55:06 +00001111 [AC_LANG_PROGRAM([[]], [[]])],
Matthias Klosec511b472010-05-08 11:01:39 +00001112 [ac_cv_no_strict_aliasing_ok=yes],
1113 [ac_cv_no_strict_aliasing_ok=no]))
Martin v. Löwis70fedcd2003-07-07 21:26:19 +00001114 CC="$ac_save_cc"
1115 AC_MSG_RESULT($ac_cv_no_strict_aliasing_ok)
1116 if test $ac_cv_no_strict_aliasing_ok = yes
1117 then
1118 BASECFLAGS="$BASECFLAGS -fno-strict-aliasing"
1119 fi
Mark Dickinson65134662008-04-25 16:11:04 +00001120
1121 # if using gcc on alpha, use -mieee to get (near) full IEEE 754
1122 # support. Without this, treatment of subnormals doesn't follow
1123 # the standard.
doko@python.orgd65e2ba2013-01-31 23:52:03 +01001124 case $host in
Mark Dickinson65134662008-04-25 16:11:04 +00001125 alpha*)
1126 BASECFLAGS="$BASECFLAGS -mieee"
1127 ;;
1128 esac
1129
Skip Montanarodecc6a42003-01-01 20:07:49 +00001130 case $ac_sys_system in
1131 SCO_SV*)
1132 BASECFLAGS="$BASECFLAGS -m486 -DSCO5"
1133 ;;
1134 # is there any other compiler on Darwin besides gcc?
1135 Darwin*)
Jeffrey Yasskin1b4e45b2008-03-17 14:40:53 +00001136 # -Wno-long-double, -no-cpp-precomp, and -mno-fused-madd
1137 # used to be here, but non-Apple gcc doesn't accept them.
Ronald Oussorena55af9a2010-01-17 16:25:57 +00001138 if test "${CC}" = gcc
1139 then
1140 AC_MSG_CHECKING(which compiler should be used)
1141 case "${UNIVERSALSDK}" in
1142 */MacOSX10.4u.sdk)
1143 # Build using 10.4 SDK, force usage of gcc when the
1144 # compiler is gcc, otherwise the user will get very
1145 # confusing error messages when building on OSX 10.6
1146 CC=gcc-4.0
1147 CPP=cpp-4.0
1148 ;;
1149 esac
1150 AC_MSG_RESULT($CC)
Ronald Oussoren988117f2006-04-29 11:31:35 +00001151 fi
1152
Benjamin Peterson4347c442008-07-17 15:59:24 +00001153 # Calculate the right deployment target for this build.
1154 #
Ned Deilyc40b9032014-06-25 13:48:46 -07001155 cur_target_major=`sw_vers -productVersion | \
1156 sed 's/\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'`
1157 cur_target_minor=`sw_vers -productVersion | \
1158 sed 's/\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'`
1159 cur_target="${cur_target_major}.${cur_target_minor}"
1160 if test ${cur_target_major} -eq 10 && \
1161 test ${cur_target_minor} -ge 3
1162 then
Benjamin Peterson4347c442008-07-17 15:59:24 +00001163 cur_target=10.3
Ronald Oussoren25967582009-09-06 10:00:26 +00001164 if test ${enable_universalsdk}; then
1165 if test "${UNIVERSAL_ARCHS}" = "all"; then
1166 # Ensure that the default platform for a
1167 # 4-way universal build is OSX 10.5,
1168 # that's the first OS release where
1169 # 4-way builds make sense.
1170 cur_target='10.5'
Ronald Oussoren23d92532009-09-07 06:12:00 +00001171
1172 elif test "${UNIVERSAL_ARCHS}" = "3-way"; then
1173 cur_target='10.5'
1174
1175 elif test "${UNIVERSAL_ARCHS}" = "intel"; then
1176 cur_target='10.5'
1177
1178 elif test "${UNIVERSAL_ARCHS}" = "64-bit"; then
1179 cur_target='10.5'
Ronald Oussoren25967582009-09-06 10:00:26 +00001180 fi
1181 else
Ronald Oussorenbc0e83c2010-02-11 13:26:54 +00001182 if test `/usr/bin/arch` = "i386"; then
Ronald Oussoren25967582009-09-06 10:00:26 +00001183 # On Intel macs default to a deployment
1184 # target of 10.4, that's the first OSX
1185 # release with Intel support.
1186 cur_target="10.4"
1187 fi
1188 fi
Benjamin Peterson4347c442008-07-17 15:59:24 +00001189 fi
1190 CONFIGURE_MACOSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET-${cur_target}}
1191
1192 # Make sure that MACOSX_DEPLOYMENT_TARGET is set in the
1193 # environment with a value that is the same as what we'll use
1194 # in the Makefile to ensure that we'll get the same compiler
1195 # environment during configure and build time.
1196 MACOSX_DEPLOYMENT_TARGET="$CONFIGURE_MACOSX_DEPLOYMENT_TARGET"
1197 export MACOSX_DEPLOYMENT_TARGET
1198 EXPORT_MACOSX_DEPLOYMENT_TARGET=''
1199
Ronald Oussorena55af9a2010-01-17 16:25:57 +00001200 if test "${enable_universalsdk}"; then
1201 UNIVERSAL_ARCH_FLAGS=""
1202 if test "$UNIVERSAL_ARCHS" = "32-bit" ; then
1203 UNIVERSAL_ARCH_FLAGS="-arch ppc -arch i386"
1204 ARCH_RUN_32BIT=""
Ronald Oussoren75912852010-04-08 08:13:31 +00001205 LIPO_32BIT_FLAGS=""
Ronald Oussorena55af9a2010-01-17 16:25:57 +00001206
1207 elif test "$UNIVERSAL_ARCHS" = "64-bit" ; then
1208 UNIVERSAL_ARCH_FLAGS="-arch ppc64 -arch x86_64"
1209 LIPO_32BIT_FLAGS=""
1210 ARCH_RUN_32BIT="true"
1211
1212 elif test "$UNIVERSAL_ARCHS" = "all" ; then
1213 UNIVERSAL_ARCH_FLAGS="-arch i386 -arch ppc -arch ppc64 -arch x86_64"
1214 LIPO_32BIT_FLAGS="-extract ppc7400 -extract i386"
Ronald Oussoren92397ce2010-01-17 19:32:00 +00001215 ARCH_RUN_32BIT="/usr/bin/arch -i386 -ppc"
Ronald Oussorena55af9a2010-01-17 16:25:57 +00001216
1217 elif test "$UNIVERSAL_ARCHS" = "intel" ; then
1218 UNIVERSAL_ARCH_FLAGS="-arch i386 -arch x86_64"
1219 LIPO_32BIT_FLAGS="-extract i386"
Ronald Oussoren92397ce2010-01-17 19:32:00 +00001220 ARCH_RUN_32BIT="/usr/bin/arch -i386"
Ronald Oussorena55af9a2010-01-17 16:25:57 +00001221
1222 elif test "$UNIVERSAL_ARCHS" = "3-way" ; then
1223 UNIVERSAL_ARCH_FLAGS="-arch i386 -arch ppc -arch x86_64"
1224 LIPO_32BIT_FLAGS="-extract ppc7400 -extract i386"
Ronald Oussoren9922f172010-02-11 13:19:34 +00001225 ARCH_RUN_32BIT="/usr/bin/arch -i386 -ppc"
Ronald Oussorena55af9a2010-01-17 16:25:57 +00001226
1227 else
1228 AC_MSG_ERROR([proper usage is --with-universal-arch=32-bit|64-bit|all|intel|3-way])
1229
1230 fi
1231
1232
Ronald Oussoren974eb5e2010-04-18 17:59:37 +00001233 CFLAGS="${UNIVERSAL_ARCH_FLAGS} ${CFLAGS}"
1234 if test "${UNIVERSALSDK}" != "/"
1235 then
1236 CPPFLAGS="-isysroot ${UNIVERSALSDK} ${CPPFLAGS}"
1237 LDFLAGS="-isysroot ${UNIVERSALSDK} ${LDFLAGS}"
1238 CFLAGS="-isysroot ${UNIVERSALSDK} ${CFLAGS}"
Ronald Oussorena55af9a2010-01-17 16:25:57 +00001239 fi
1240
1241 fi
1242
1243
Skip Montanarodecc6a42003-01-01 20:07:49 +00001244 ;;
Neal Norwitzdedeeaa2006-03-31 06:54:45 +00001245 OSF*)
1246 BASECFLAGS="$BASECFLAGS -mieee"
1247 ;;
Skip Montanarodecc6a42003-01-01 20:07:49 +00001248 esac
1249 ;;
1250
1251*)
1252 case $ac_sys_system in
1253 OpenUNIX*|UnixWare*)
1254 BASECFLAGS="$BASECFLAGS -K pentium,host,inline,loop_unroll,alloca "
1255 ;;
Neal Norwitzb44f1652003-05-26 14:11:55 +00001256 OSF*)
1257 BASECFLAGS="$BASECFLAGS -ieee -std"
1258 ;;
Skip Montanarodecc6a42003-01-01 20:07:49 +00001259 SCO_SV*)
1260 BASECFLAGS="$BASECFLAGS -belf -Ki486 -DSCO5"
1261 ;;
1262 esac
1263 ;;
1264esac
1265
Fred Drakee1ceaa02001-12-04 20:55:47 +00001266if test "$Py_DEBUG" = 'true'; then
1267 :
1268else
1269 OPT="-DNDEBUG $OPT"
1270fi
1271
Guido van Rossum6f2260e1996-09-09 16:21:03 +00001272if test "$ac_arch_flags"
Guido van Rossumc5a39031996-07-31 17:35:03 +00001273then
Skip Montanarodecc6a42003-01-01 20:07:49 +00001274 BASECFLAGS="$BASECFLAGS $ac_arch_flags"
Guido van Rossumc5a39031996-07-31 17:35:03 +00001275fi
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001276
Neal Norwitz020c46a2006-01-07 21:39:28 +00001277# disable check for icc since it seems to pass, but generates a warning
1278if test "$CC" = icc
1279then
1280 ac_cv_opt_olimit_ok=no
1281fi
1282
Guido van Rossum91922671997-10-09 20:24:13 +00001283AC_MSG_CHECKING(whether $CC accepts -OPT:Olimit=0)
1284AC_CACHE_VAL(ac_cv_opt_olimit_ok,
1285[ac_save_cc="$CC"
1286CC="$CC -OPT:Olimit=0"
Matthias Klosec511b472010-05-08 11:01:39 +00001287AC_COMPILE_IFELSE(
Mark Dickinson5e13e292010-05-11 08:55:06 +00001288 [AC_LANG_PROGRAM([[]], [[]])],
Matthias Klosec511b472010-05-08 11:01:39 +00001289 [ac_cv_opt_olimit_ok=yes],
1290 [ac_cv_opt_olimit_ok=no]
Gregory P. Smithec3b8bd2009-11-01 21:02:52 +00001291 )
Guido van Rossum91922671997-10-09 20:24:13 +00001292CC="$ac_save_cc"])
1293AC_MSG_RESULT($ac_cv_opt_olimit_ok)
Guido van Rossum2efa34b1997-10-23 17:43:11 +00001294if test $ac_cv_opt_olimit_ok = yes; then
Guido van Rossum5839e582000-10-09 19:52:35 +00001295 case $ac_sys_system in
Skip Montanarodecc6a42003-01-01 20:07:49 +00001296 # XXX is this branch needed? On MacOSX 10.2.2 the result of the
1297 # olimit_ok test is "no". Is it "yes" in some other Darwin-esque
1298 # environment?
1299 Darwin*)
1300 ;;
Trent Nelson34562e12012-10-17 18:01:12 -04001301 # XXX thankfully this useless troublemaker of a flag has been
1302 # eradicated in the 3.x line. For now, make sure it isn't picked
1303 # up by any of our other platforms that use CC.
1304 AIX*|SunOS*|HP-UX*|IRIX*)
1305 ;;
Skip Montanarodecc6a42003-01-01 20:07:49 +00001306 *)
1307 BASECFLAGS="$BASECFLAGS -OPT:Olimit=0"
1308 ;;
Guido van Rossum5839e582000-10-09 19:52:35 +00001309 esac
Guido van Rossumf8678121998-07-07 21:05:09 +00001310else
1311 AC_MSG_CHECKING(whether $CC accepts -Olimit 1500)
1312 AC_CACHE_VAL(ac_cv_olimit_ok,
1313 [ac_save_cc="$CC"
1314 CC="$CC -Olimit 1500"
Matthias Klosec511b472010-05-08 11:01:39 +00001315 AC_COMPILE_IFELSE(
Mark Dickinson5e13e292010-05-11 08:55:06 +00001316 [AC_LANG_PROGRAM([[]], [[]])],
Matthias Klosec511b472010-05-08 11:01:39 +00001317 [ac_cv_olimit_ok=yes],
1318 [ac_cv_olimit_ok=no]
Gregory P. Smithec3b8bd2009-11-01 21:02:52 +00001319 )
Guido van Rossumf8678121998-07-07 21:05:09 +00001320 CC="$ac_save_cc"])
1321 AC_MSG_RESULT($ac_cv_olimit_ok)
1322 if test $ac_cv_olimit_ok = yes; then
Stefan Krah67473262012-11-29 00:17:05 +01001323 case $ac_sys_system in
1324 # Issue #16534: On HP-UX ac_cv_olimit_ok=yes is a false positive.
1325 HP-UX*)
1326 ;;
1327 *)
1328 BASECFLAGS="$BASECFLAGS -Olimit 1500"
1329 ;;
1330 esac
Guido van Rossumf8678121998-07-07 21:05:09 +00001331 fi
Guido van Rossum201afe51997-05-14 21:14:44 +00001332fi
Guido van Rossumf8678121998-07-07 21:05:09 +00001333
Martin v. Löwisaac13162006-10-19 10:58:46 +00001334# Check whether GCC supports PyArg_ParseTuple format
1335if test "$GCC" = "yes"
1336then
1337 AC_MSG_CHECKING(whether gcc supports ParseTuple __format__)
1338 save_CFLAGS=$CFLAGS
Benjamin Petersonc8759662013-05-11 13:00:05 -05001339 CFLAGS="$CFLAGS -Werror -Wformat"
Matthias Klosec511b472010-05-08 11:01:39 +00001340 AC_COMPILE_IFELSE([
1341 AC_LANG_PROGRAM([[void f(char*,...)__attribute((format(PyArg_ParseTuple, 1, 2)));]], [[]])
1342 ],[
1343 AC_DEFINE(HAVE_ATTRIBUTE_FORMAT_PARSETUPLE, 1,
1344 [Define if GCC supports __attribute__((format(PyArg_ParseTuple, 2, 3)))])
1345 AC_MSG_RESULT(yes)
1346 ],[
1347 AC_MSG_RESULT(no)
1348 ])
Martin v. Löwisc1d75972006-10-19 16:01:37 +00001349 CFLAGS=$save_CFLAGS
Martin v. Löwisaac13162006-10-19 10:58:46 +00001350fi
1351
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00001352# On some compilers, pthreads are available without further options
1353# (e.g. MacOS X). On some of these systems, the compiler will not
1354# complain if unaccepted options are passed (e.g. gcc on Mac OS X).
1355# So we have to see first whether pthreads are available without
1356# options before we can check whether -Kpthread improves anything.
1357AC_MSG_CHECKING(whether pthreads are available without options)
1358AC_CACHE_VAL(ac_cv_pthread_is_default,
Matthias Klosec511b472010-05-08 11:01:39 +00001359[AC_RUN_IFELSE([AC_LANG_SOURCE([[
Stefan Krahae66ca62012-11-22 22:36:57 +01001360#include <stdio.h>
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00001361#include <pthread.h>
1362
1363void* routine(void* p){return NULL;}
1364
1365int main(){
1366 pthread_t p;
1367 if(pthread_create(&p,NULL,routine,NULL)!=0)
1368 return 1;
Jack Jansen4f8d0542002-03-08 13:43:01 +00001369 (void)pthread_detach(p);
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00001370 return 0;
1371}
Matthias Klosec511b472010-05-08 11:01:39 +00001372]])],[
Skip Montanarod8d39a02003-07-10 20:44:10 +00001373 ac_cv_pthread_is_default=yes
1374 ac_cv_kthread=no
1375 ac_cv_pthread=no
Matthias Klosec511b472010-05-08 11:01:39 +00001376],[ac_cv_pthread_is_default=no],[ac_cv_pthread_is_default=no])
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00001377])
1378AC_MSG_RESULT($ac_cv_pthread_is_default)
1379
1380
1381if test $ac_cv_pthread_is_default = yes
1382then
1383 ac_cv_kpthread=no
1384else
Martin v. Löwis130fb172001-07-19 11:00:41 +00001385# -Kpthread, if available, provides the right #defines
1386# and linker options to make pthread_create available
Martin v. Löwis260aecc2001-10-07 08:14:41 +00001387# Some compilers won't report that they do not support -Kpthread,
1388# so we need to run a program to see whether it really made the
1389# function available.
Martin v. Löwis130fb172001-07-19 11:00:41 +00001390AC_MSG_CHECKING(whether $CC accepts -Kpthread)
1391AC_CACHE_VAL(ac_cv_kpthread,
1392[ac_save_cc="$CC"
1393CC="$CC -Kpthread"
Matthias Klosec511b472010-05-08 11:01:39 +00001394AC_RUN_IFELSE([AC_LANG_SOURCE([[
Stefan Krahae66ca62012-11-22 22:36:57 +01001395#include <stdio.h>
Martin v. Löwis260aecc2001-10-07 08:14:41 +00001396#include <pthread.h>
1397
1398void* routine(void* p){return NULL;}
1399
1400int main(){
1401 pthread_t p;
1402 if(pthread_create(&p,NULL,routine,NULL)!=0)
1403 return 1;
Jack Jansen4f8d0542002-03-08 13:43:01 +00001404 (void)pthread_detach(p);
Martin v. Löwis260aecc2001-10-07 08:14:41 +00001405 return 0;
1406}
Matthias Klosec511b472010-05-08 11:01:39 +00001407]])],[ac_cv_kpthread=yes],[ac_cv_kpthread=no],[ac_cv_kpthread=no])
Martin v. Löwis130fb172001-07-19 11:00:41 +00001408CC="$ac_save_cc"])
Martin v. Löwis130fb172001-07-19 11:00:41 +00001409AC_MSG_RESULT($ac_cv_kpthread)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00001410fi
Martin v. Löwis130fb172001-07-19 11:00:41 +00001411
Skip Montanarod8d39a02003-07-10 20:44:10 +00001412if test $ac_cv_kpthread = no -a $ac_cv_pthread_is_default = no
Martin v. Löwis5f433f02003-05-05 05:05:30 +00001413then
1414# -Kthread, if available, provides the right #defines
1415# and linker options to make pthread_create available
1416# Some compilers won't report that they do not support -Kthread,
1417# so we need to run a program to see whether it really made the
1418# function available.
1419AC_MSG_CHECKING(whether $CC accepts -Kthread)
1420AC_CACHE_VAL(ac_cv_kthread,
1421[ac_save_cc="$CC"
1422CC="$CC -Kthread"
Matthias Klosec511b472010-05-08 11:01:39 +00001423AC_RUN_IFELSE([AC_LANG_SOURCE([[
Stefan Krahae66ca62012-11-22 22:36:57 +01001424#include <stdio.h>
Martin v. Löwis5f433f02003-05-05 05:05:30 +00001425#include <pthread.h>
1426
1427void* routine(void* p){return NULL;}
1428
1429int main(){
1430 pthread_t p;
1431 if(pthread_create(&p,NULL,routine,NULL)!=0)
1432 return 1;
1433 (void)pthread_detach(p);
1434 return 0;
1435}
Matthias Klosec511b472010-05-08 11:01:39 +00001436]])],[ac_cv_kthread=yes],[ac_cv_kthread=no],[ac_cv_kthread=no])
Martin v. Löwis5f433f02003-05-05 05:05:30 +00001437CC="$ac_save_cc"])
1438AC_MSG_RESULT($ac_cv_kthread)
1439fi
1440
Skip Montanarod8d39a02003-07-10 20:44:10 +00001441if test $ac_cv_kthread = no -a $ac_cv_pthread_is_default = no
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00001442then
1443# -pthread, if available, provides the right #defines
1444# and linker options to make pthread_create available
1445# Some compilers won't report that they do not support -pthread,
1446# so we need to run a program to see whether it really made the
1447# function available.
1448AC_MSG_CHECKING(whether $CC accepts -pthread)
doko@python.orgfa3f9a32013-01-25 15:32:31 +01001449AC_CACHE_VAL(ac_cv_pthread,
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00001450[ac_save_cc="$CC"
1451CC="$CC -pthread"
Matthias Klosec511b472010-05-08 11:01:39 +00001452AC_RUN_IFELSE([AC_LANG_SOURCE([[
Stefan Krahae66ca62012-11-22 22:36:57 +01001453#include <stdio.h>
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00001454#include <pthread.h>
1455
1456void* routine(void* p){return NULL;}
1457
1458int main(){
1459 pthread_t p;
1460 if(pthread_create(&p,NULL,routine,NULL)!=0)
1461 return 1;
1462 (void)pthread_detach(p);
1463 return 0;
1464}
Matthias Klosec511b472010-05-08 11:01:39 +00001465]])],[ac_cv_pthread=yes],[ac_cv_pthread=no],[ac_cv_pthread=no])
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00001466CC="$ac_save_cc"])
1467AC_MSG_RESULT($ac_cv_pthread)
1468fi
1469
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001470# If we have set a CC compiler flag for thread support then
1471# check if it works for CXX, too.
1472ac_cv_cxx_thread=no
1473if test ! -z "$CXX"
1474then
1475AC_MSG_CHECKING(whether $CXX also accepts flags for thread support)
1476ac_save_cxx="$CXX"
1477
1478if test "$ac_cv_kpthread" = "yes"
1479then
Martin v. Löwis519adae2003-09-20 10:47:47 +00001480 CXX="$CXX -Kpthread"
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001481 ac_cv_cxx_thread=yes
1482elif test "$ac_cv_kthread" = "yes"
1483then
1484 CXX="$CXX -Kthread"
1485 ac_cv_cxx_thread=yes
1486elif test "$ac_cv_pthread" = "yes"
1487then
1488 CXX="$CXX -pthread"
1489 ac_cv_cxx_thread=yes
1490fi
1491
1492if test $ac_cv_cxx_thread = yes
1493then
1494 echo 'void foo();int main(){foo();}void foo(){}' > conftest.$ac_ext
1495 $CXX -c conftest.$ac_ext 2>&5
1496 if $CXX -o conftest$ac_exeext conftest.$ac_objext 2>&5 \
1497 && test -s conftest$ac_exeext && ./conftest$ac_exeext
1498 then
1499 ac_cv_cxx_thread=yes
1500 else
1501 ac_cv_cxx_thread=no
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001502 fi
1503 rm -fr conftest*
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001504fi
Brett Cannonc601e0f2004-11-07 01:24:12 +00001505AC_MSG_RESULT($ac_cv_cxx_thread)
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001506fi
Martin v. Löwis519adae2003-09-20 10:47:47 +00001507CXX="$ac_save_cxx"
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001508
Fred Drakece81d592000-07-09 14:39:29 +00001509dnl # check for ANSI or K&R ("traditional") preprocessor
1510dnl AC_MSG_CHECKING(for C preprocessor type)
Matthias Klosec511b472010-05-08 11:01:39 +00001511dnl AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Fred Drakece81d592000-07-09 14:39:29 +00001512dnl #define spam(name, doc) {#name, &name, #name "() -- " doc}
1513dnl int foo;
1514dnl struct {char *name; int *addr; char *doc;} desc = spam(foo, "something");
Matthias Klosec511b472010-05-08 11:01:39 +00001515dnl ]], [[;]])],[cpp_type=ansi],[AC_DEFINE(HAVE_OLD_CPP) cpp_type=traditional])
Fred Drakece81d592000-07-09 14:39:29 +00001516dnl AC_MSG_RESULT($cpp_type)
Guido van Rossum300fda71996-08-19 21:58:16 +00001517
Guido van Rossum627b2d71993-12-24 10:39:16 +00001518# checks for header files
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001519AC_HEADER_STDC
doko@ubuntu.comf27ec3e2014-04-17 20:11:19 +02001520AC_CHECK_HEADERS(asm/types.h conio.h direct.h dlfcn.h errno.h \
Martin v. Löwis0e8bd7e2006-06-10 12:23:46 +00001521fcntl.h grp.h \
doko@ubuntu.comf27ec3e2014-04-17 20:11:19 +02001522ieeefp.h io.h langinfo.h libintl.h poll.h process.h pthread.h \
Martin v. Löwis40e9aed2006-10-02 15:20:37 +00001523shadow.h signal.h stdint.h stropts.h termios.h thread.h \
Martin v. Löwis14e73b12003-01-01 09:51:12 +00001524unistd.h utime.h \
Christian Heimes0e9ab5f2008-03-21 23:49:44 +00001525sys/audioio.h sys/bsdtty.h sys/epoll.h sys/event.h sys/file.h sys/loadavg.h \
1526sys/lock.h sys/mkdev.h sys/modem.h \
Martin v. Löwis0e8bd7e2006-06-10 12:23:46 +00001527sys/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 +00001528sys/termio.h sys/time.h \
Martin v. Löwis0e8bd7e2006-06-10 12:23:46 +00001529sys/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 +00001530sys/resource.h netpacket/packet.h sysexits.h bluetooth.h \
Christian Heimes3aa138f2013-06-18 13:25:24 +02001531bluetooth/bluetooth.h linux/tipc.h spawn.h util.h alloca.h)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001532AC_HEADER_DIRENT
Martin v. Löwisdbe3f762002-10-10 14:27:30 +00001533AC_HEADER_MAJOR
Guido van Rossum627b2d71993-12-24 10:39:16 +00001534
Martin v. Löwis11017b12006-01-14 18:12:57 +00001535# On Linux, netlink.h requires asm/types.h
1536AC_CHECK_HEADERS(linux/netlink.h,,,[
1537#ifdef HAVE_ASM_TYPES_H
1538#include <asm/types.h>
1539#endif
1540#ifdef HAVE_SYS_SOCKET_H
1541#include <sys/socket.h>
1542#endif
1543])
1544
Guido van Rossum627b2d71993-12-24 10:39:16 +00001545# checks for typedefs
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001546was_it_defined=no
1547AC_MSG_CHECKING(for clock_t in time.h)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001548AC_EGREP_HEADER(clock_t, time.h, was_it_defined=yes, [
1549 AC_DEFINE(clock_t, long, [Define to 'long' if <time.h> doesn't define.])
1550])
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001551AC_MSG_RESULT($was_it_defined)
1552
Neal Norwitz11690112002-07-30 01:08:28 +00001553# Check whether using makedev requires defining _OSF_SOURCE
1554AC_MSG_CHECKING(for makedev)
Matthias Klosec511b472010-05-08 11:01:39 +00001555AC_LINK_IFELSE([AC_LANG_PROGRAM([[
Jesus Cea616de772010-04-28 10:32:30 +00001556#if defined(MAJOR_IN_MKDEV)
1557#include <sys/mkdev.h>
1558#elif defined(MAJOR_IN_SYSMACROS)
1559#include <sys/sysmacros.h>
1560#else
1561#include <sys/types.h>
Matthias Klosec511b472010-05-08 11:01:39 +00001562#endif ]], [[ makedev(0, 0) ]])],
1563[ac_cv_has_makedev=yes],
1564[ac_cv_has_makedev=no])
Neal Norwitz11690112002-07-30 01:08:28 +00001565if test "$ac_cv_has_makedev" = "no"; then
1566 # we didn't link, try if _OSF_SOURCE will allow us to link
Matthias Klosec511b472010-05-08 11:01:39 +00001567 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
Neal Norwitz6eb37f02003-02-23 23:28:15 +00001568#define _OSF_SOURCE 1
1569#include <sys/types.h>
Matthias Klosec511b472010-05-08 11:01:39 +00001570 ]], [[ makedev(0, 0) ]])],
1571[ac_cv_has_makedev=yes],
1572[ac_cv_has_makedev=no])
Neal Norwitz11690112002-07-30 01:08:28 +00001573 if test "$ac_cv_has_makedev" = "yes"; then
1574 AC_DEFINE(_OSF_SOURCE, 1, [Define _OSF_SOURCE to get the makedev macro.])
1575 fi
1576fi
1577AC_MSG_RESULT($ac_cv_has_makedev)
1578if test "$ac_cv_has_makedev" = "yes"; then
1579 AC_DEFINE(HAVE_MAKEDEV, 1, [Define this if you have the makedev macro.])
1580fi
1581
Martin v. Löwis399a6892002-10-04 10:22:02 +00001582# Enabling LFS on Solaris (2.6 to 9) with gcc 2.95 triggers a bug in
1583# the system headers: If _XOPEN_SOURCE and _LARGEFILE_SOURCE are
1584# defined, but the compiler does not support pragma redefine_extname,
1585# and _LARGEFILE64_SOURCE is not defined, the headers refer to 64-bit
1586# structures (such as rlimit64) without declaring them. As a
1587# work-around, disable LFS on such configurations
1588
1589use_lfs=yes
1590AC_MSG_CHECKING(Solaris LFS bug)
Matthias Klosec511b472010-05-08 11:01:39 +00001591AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwis399a6892002-10-04 10:22:02 +00001592#define _LARGEFILE_SOURCE 1
1593#define _FILE_OFFSET_BITS 64
1594#include <sys/resource.h>
Matthias Klosec511b472010-05-08 11:01:39 +00001595]], [[struct rlimit foo;]])],[sol_lfs_bug=no],[sol_lfs_bug=yes])
Martin v. Löwis399a6892002-10-04 10:22:02 +00001596AC_MSG_RESULT($sol_lfs_bug)
1597if test "$sol_lfs_bug" = "yes"; then
1598 use_lfs=no
1599fi
1600
1601if test "$use_lfs" = "yes"; then
Guido van Rossum810cc512001-09-09 23:51:39 +00001602# Two defines needed to enable largefile support on various platforms
1603# These may affect some typedefs
Georg Brandl94800df2011-02-25 11:09:02 +00001604case $ac_sys_system/$ac_sys_release in
1605AIX*)
1606 AC_DEFINE(_LARGE_FILES, 1,
1607 [This must be defined on AIX systems to enable large file support.])
1608 ;;
1609esac
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001610AC_DEFINE(_LARGEFILE_SOURCE, 1,
1611[This must be defined on some systems to enable large file support.])
1612AC_DEFINE(_FILE_OFFSET_BITS, 64,
1613[This must be set to 64 on some systems to enable large file support.])
Martin v. Löwis399a6892002-10-04 10:22:02 +00001614fi
Guido van Rossum810cc512001-09-09 23:51:39 +00001615
Guido van Rossum300fda71996-08-19 21:58:16 +00001616# Add some code to confdefs.h so that the test for off_t works on SCO
1617cat >> confdefs.h <<\EOF
1618#if defined(SCO_DS)
1619#undef _OFF_T
1620#endif
1621EOF
1622
Guido van Rossumef2255b2000-03-10 22:30:29 +00001623# Type availability checks
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001624AC_TYPE_MODE_T
1625AC_TYPE_OFF_T
1626AC_TYPE_PID_T
Matthias Klosecbf54b12010-05-08 11:04:18 +00001627AC_DEFINE_UNQUOTED([RETSIGTYPE],[void],[assume C89 semantics that RETSIGTYPE is always void])
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001628AC_TYPE_SIZE_T
1629AC_TYPE_UID_T
Mark Dickinson17c50cd2012-12-02 13:13:56 +00001630
1631# There are two separate checks for each of the exact-width integer types we
1632# need. First we check whether the type is available using the usual
1633# AC_CHECK_TYPE macro with the default includes (which includes <inttypes.h>
1634# and <stdint.h> where available). We then also use the special type checks of
1635# the form AC_TYPE_UINT32_T, which in the case that uint32_t is not available
1636# directly, #define's uint32_t to be a suitable type.
1637
1638AC_CHECK_TYPE(uint32_t,
1639 AC_DEFINE(HAVE_UINT32_T, 1, [Define if your compiler provides uint32_t.]),,)
Mark Dickinsonefc82f72009-03-20 15:51:55 +00001640AC_TYPE_UINT32_T
Mark Dickinson17c50cd2012-12-02 13:13:56 +00001641
1642AC_CHECK_TYPE(uint64_t,
1643 AC_DEFINE(HAVE_UINT64_T, 1, [Define if your compiler provides uint64_t.]),,)
Mark Dickinsonefc82f72009-03-20 15:51:55 +00001644AC_TYPE_UINT64_T
Mark Dickinson17c50cd2012-12-02 13:13:56 +00001645
1646AC_CHECK_TYPE(int32_t,
1647 AC_DEFINE(HAVE_INT32_T, 1, [Define if your compiler provides int32_t.]),,)
Mark Dickinsonefc82f72009-03-20 15:51:55 +00001648AC_TYPE_INT32_T
Mark Dickinson17c50cd2012-12-02 13:13:56 +00001649
1650AC_CHECK_TYPE(int64_t,
1651 AC_DEFINE(HAVE_INT64_T, 1, [Define if your compiler provides int64_t.]),,)
Mark Dickinsonefc82f72009-03-20 15:51:55 +00001652AC_TYPE_INT64_T
Mark Dickinson17c50cd2012-12-02 13:13:56 +00001653
Christian Heimes951cc0f2008-01-31 23:08:23 +00001654AC_CHECK_TYPE(ssize_t,
Matthias Klose5183ebd2010-04-24 16:38:36 +00001655 AC_DEFINE(HAVE_SSIZE_T, 1, [Define if your compiler provides ssize_t]),,)
Guido van Rossum627b2d71993-12-24 10:39:16 +00001656
Guido van Rossumef2255b2000-03-10 22:30:29 +00001657# Sizes of various common basic types
Skip Montanarob9820a32004-01-17 00:16:12 +00001658# ANSI C requires sizeof(char) == 1, so no need to check it
Guido van Rossum3065c942001-09-17 04:03:14 +00001659AC_CHECK_SIZEOF(int, 4)
1660AC_CHECK_SIZEOF(long, 4)
1661AC_CHECK_SIZEOF(void *, 4)
Guido van Rossum3065c942001-09-17 04:03:14 +00001662AC_CHECK_SIZEOF(short, 2)
1663AC_CHECK_SIZEOF(float, 4)
1664AC_CHECK_SIZEOF(double, 8)
1665AC_CHECK_SIZEOF(fpos_t, 4)
Martin v. Löwis18e16552006-02-15 17:27:45 +00001666AC_CHECK_SIZEOF(size_t, 4)
Christian Heimes951cc0f2008-01-31 23:08:23 +00001667AC_CHECK_SIZEOF(pid_t, 4)
Guido van Rossumac405f61994-09-12 10:56:06 +00001668
Guido van Rossumec95c7b1998-08-04 17:59:56 +00001669AC_MSG_CHECKING(for long long support)
1670have_long_long=no
Matthias Klosec511b472010-05-08 11:01:39 +00001671AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[long long x; x = (long long)0;]])],[
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001672 AC_DEFINE(HAVE_LONG_LONG, 1, [Define this if you have the type long long.])
1673 have_long_long=yes
Matthias Klosec511b472010-05-08 11:01:39 +00001674],[])
Guido van Rossumec95c7b1998-08-04 17:59:56 +00001675AC_MSG_RESULT($have_long_long)
Guido van Rossum8bc1dfd1999-04-10 16:01:48 +00001676if test "$have_long_long" = yes ; then
Guido van Rossum3065c942001-09-17 04:03:14 +00001677AC_CHECK_SIZEOF(long long, 8)
Guido van Rossumec95c7b1998-08-04 17:59:56 +00001678fi
1679
Travis E. Oliphant711c9e92008-06-06 22:33:21 +00001680AC_MSG_CHECKING(for long double support)
1681have_long_double=no
Matthias Klosec511b472010-05-08 11:01:39 +00001682AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[long double x; x = (long double)0;]])],[
Travis E. Oliphant711c9e92008-06-06 22:33:21 +00001683 AC_DEFINE(HAVE_LONG_DOUBLE, 1, [Define this if you have the type long double.])
1684 have_long_double=yes
Matthias Klosec511b472010-05-08 11:01:39 +00001685],[])
Travis E. Oliphant711c9e92008-06-06 22:33:21 +00001686AC_MSG_RESULT($have_long_double)
Mark Dickinsondc1688a2008-06-27 22:20:14 +00001687if test "$have_long_double" = yes ; then
Travis E. Oliphant711c9e92008-06-06 22:33:21 +00001688AC_CHECK_SIZEOF(long double, 12)
1689fi
1690
Martin v. Löwisaef4c6b2007-01-21 09:33:07 +00001691AC_MSG_CHECKING(for _Bool support)
1692have_c99_bool=no
Matthias Klosec511b472010-05-08 11:01:39 +00001693AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[_Bool x; x = (_Bool)0;]])],[
Martin v. Löwisaef4c6b2007-01-21 09:33:07 +00001694 AC_DEFINE(HAVE_C99_BOOL, 1, [Define this if you have the type _Bool.])
1695 have_c99_bool=yes
Matthias Klosec511b472010-05-08 11:01:39 +00001696],[])
Martin v. Löwisaef4c6b2007-01-21 09:33:07 +00001697AC_MSG_RESULT($have_c99_bool)
1698if test "$have_c99_bool" = yes ; then
1699AC_CHECK_SIZEOF(_Bool, 1)
1700fi
1701
Martin v. Löwisebe26702006-10-02 14:55:51 +00001702AC_CHECK_TYPES(uintptr_t,
1703 [AC_CHECK_SIZEOF(uintptr_t, 4)],
Martin v. Löwis40e9aed2006-10-02 15:20:37 +00001704 [], [#ifdef HAVE_STDINT_H
1705 #include <stdint.h>
Antoine Pitrou7be5a652010-10-10 08:14:41 +00001706 #endif
1707 #ifdef HAVE_INTTYPES_H
1708 #include <inttypes.h>
Martin v. Löwis40e9aed2006-10-02 15:20:37 +00001709 #endif])
Martin v. Löwisebe26702006-10-02 14:55:51 +00001710
Alexandre Vassalotti856782e2009-07-17 04:59:05 +00001711AC_CHECK_SIZEOF(off_t, [], [
1712#ifdef HAVE_SYS_TYPES_H
1713#include <sys/types.h>
1714#endif
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001715])
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001716
1717AC_MSG_CHECKING(whether to enable large file support)
Mark Dickinson0ef0b912009-12-31 21:11:48 +00001718if test "$have_long_long" = yes
1719then
1720if test "$ac_cv_sizeof_off_t" -gt "$ac_cv_sizeof_long" -a \
Guido van Rossum8bc1dfd1999-04-10 16:01:48 +00001721 "$ac_cv_sizeof_long_long" -ge "$ac_cv_sizeof_off_t"; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001722 AC_DEFINE(HAVE_LARGEFILE_SUPPORT, 1,
1723 [Defined to enable large file support when an off_t is bigger than a long
1724 and long long is available and at least as big as an off_t. You may need
1725 to add some flags for configuration and compilation to enable this mode.
1726 (For Solaris and Linux, the necessary defines are already defined.)])
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001727 AC_MSG_RESULT(yes)
1728else
1729 AC_MSG_RESULT(no)
1730fi
Mark Dickinson0ef0b912009-12-31 21:11:48 +00001731else
1732 AC_MSG_RESULT(no)
1733fi
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001734
Alexandre Vassalotti856782e2009-07-17 04:59:05 +00001735AC_CHECK_SIZEOF(time_t, [], [
1736#ifdef HAVE_SYS_TYPES_H
1737#include <sys/types.h>
1738#endif
1739#ifdef HAVE_TIME_H
1740#include <time.h>
1741#endif
Fred Drakea3f6e912000-06-29 20:44:47 +00001742])
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001743
Trent Mick635f6fb2000-08-23 21:33:05 +00001744# if have pthread_t then define SIZEOF_PTHREAD_T
Martin v. Löwis123cbd22001-07-19 14:21:10 +00001745ac_save_cc="$CC"
1746if test "$ac_cv_kpthread" = "yes"
1747then CC="$CC -Kpthread"
Martin v. Löwis5f433f02003-05-05 05:05:30 +00001748elif test "$ac_cv_kthread" = "yes"
1749then CC="$CC -Kthread"
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00001750elif test "$ac_cv_pthread" = "yes"
1751then CC="$CC -pthread"
Martin v. Löwis123cbd22001-07-19 14:21:10 +00001752fi
Trent Mick635f6fb2000-08-23 21:33:05 +00001753AC_MSG_CHECKING(for pthread_t)
1754have_pthread_t=no
Matthias Klosec511b472010-05-08 11:01:39 +00001755AC_COMPILE_IFELSE([
1756 AC_LANG_PROGRAM([[#include <pthread.h>]], [[pthread_t x; x = *(pthread_t*)0;]])
1757],[have_pthread_t=yes],[])
Trent Mick635f6fb2000-08-23 21:33:05 +00001758AC_MSG_RESULT($have_pthread_t)
1759if test "$have_pthread_t" = yes ; then
Alexandre Vassalotti856782e2009-07-17 04:59:05 +00001760 AC_CHECK_SIZEOF(pthread_t, [], [
1761#ifdef HAVE_PTHREAD_H
1762#include <pthread.h>
1763#endif
Trent Mick635f6fb2000-08-23 21:33:05 +00001764 ])
Trent Mick635f6fb2000-08-23 21:33:05 +00001765fi
Martin v. Löwis123cbd22001-07-19 14:21:10 +00001766CC="$ac_save_cc"
Trent Mick635f6fb2000-08-23 21:33:05 +00001767
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001768AC_MSG_CHECKING(for --enable-toolbox-glue)
1769AC_ARG_ENABLE(toolbox-glue,
Matthias Klose22520ea2010-05-08 10:14:46 +00001770 AS_HELP_STRING([--enable-toolbox-glue], [disable/enable MacOSX glue code for extensions]))
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001771
1772if test -z "$enable_toolbox_glue"
1773then
1774 case $ac_sys_system/$ac_sys_release in
1775 Darwin/*)
1776 enable_toolbox_glue="yes";;
1777 *)
1778 enable_toolbox_glue="no";;
1779 esac
1780fi
1781case "$enable_toolbox_glue" in
1782yes)
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001783 extra_machdep_objs="Python/mactoolboxglue.o"
Raymond Hettingerec6eb362004-11-05 07:02:59 +00001784 extra_undefs="-u _PyMac_Error"
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001785 AC_DEFINE(USE_TOOLBOX_OBJECT_GLUE, 1,
1786 [Define if you want to use MacPython modules on MacOSX in unix-Python.])
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001787 ;;
1788*)
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001789 extra_machdep_objs=""
Jack Jansen591cbed2001-08-15 13:55:15 +00001790 extra_undefs=""
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001791 ;;
1792esac
1793AC_MSG_RESULT($enable_toolbox_glue)
1794
Ronald Oussoren0d236eb2008-06-06 21:31:33 +00001795
Bob Ippolito7026a0a2005-03-28 23:23:47 +00001796AC_SUBST(OTHER_LIBTOOL_OPT)
1797case $ac_sys_system/$ac_sys_release in
Anthony Baxter82201742006-04-09 15:07:40 +00001798 Darwin/@<:@01567@:>@\..*)
Bob Ippolito7026a0a2005-03-28 23:23:47 +00001799 OTHER_LIBTOOL_OPT="-prebind -seg1addr 0x10000000"
1800 ;;
1801 Darwin/*)
1802 OTHER_LIBTOOL_OPT=""
1803 ;;
1804esac
1805
Ronald Oussoren25967582009-09-06 10:00:26 +00001806
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001807AC_SUBST(LIBTOOL_CRUFT)
1808case $ac_sys_system/$ac_sys_release in
Anthony Baxter82201742006-04-09 15:07:40 +00001809 Darwin/@<:@01567@:>@\..*)
Ronald Oussoren988117f2006-04-29 11:31:35 +00001810 LIBTOOL_CRUFT="-framework System -lcc_dynamic"
1811 if test "${enable_universalsdk}"; then
1812 :
1813 else
Ronald Oussorenbc0e83c2010-02-11 13:26:54 +00001814 LIBTOOL_CRUFT="${LIBTOOL_CRUFT} -arch_only `/usr/bin/arch`"
Ronald Oussoren988117f2006-04-29 11:31:35 +00001815 fi
Jack Jansenb36687a2004-07-16 08:43:47 +00001816 LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -install_name $(PYTHONFRAMEWORKINSTALLDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansena3891ea2001-09-07 14:25:12 +00001817 LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -compatibility_version $(VERSION) -current_version $(VERSION)';;
Guido van Rossum5839e582000-10-09 19:52:35 +00001818 Darwin/*)
Ronald Oussorena55af9a2010-01-17 16:25:57 +00001819 gcc_version=`gcc -dumpversion`
Bob Ippolito7026a0a2005-03-28 23:23:47 +00001820 if test ${gcc_version} '<' 4.0
1821 then
1822 LIBTOOL_CRUFT="-lcc_dynamic"
1823 else
1824 LIBTOOL_CRUFT=""
1825 fi
Matthias Klosec511b472010-05-08 11:01:39 +00001826 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Ronald Oussoren25967582009-09-06 10:00:26 +00001827 #include <unistd.h>
1828 int main(int argc, char*argv[])
1829 {
1830 if (sizeof(long) == 4) {
1831 return 0;
1832 } else {
1833 return 1;
1834 }
Ronald Oussoren84ddd722009-09-08 07:17:10 +00001835 }
Matthias Klosec511b472010-05-08 11:01:39 +00001836 ]])],[ac_osx_32bit=yes],[ac_osx_32bit=no],[ac_osx_32bit=yes])
Ronald Oussoren25967582009-09-06 10:00:26 +00001837
1838 if test "${ac_osx_32bit}" = "yes"; then
Ronald Oussorenbc0e83c2010-02-11 13:26:54 +00001839 case `/usr/bin/arch` in
Ronald Oussoren25967582009-09-06 10:00:26 +00001840 i386)
1841 MACOSX_DEFAULT_ARCH="i386"
1842 ;;
1843 ppc)
1844 MACOSX_DEFAULT_ARCH="ppc"
1845 ;;
1846 *)
1847 AC_MSG_ERROR([Unexpected output of 'arch' on OSX])
1848 ;;
1849 esac
1850 else
Ronald Oussorenbc0e83c2010-02-11 13:26:54 +00001851 case `/usr/bin/arch` in
Ronald Oussoren25967582009-09-06 10:00:26 +00001852 i386)
1853 MACOSX_DEFAULT_ARCH="x86_64"
1854 ;;
1855 ppc)
1856 MACOSX_DEFAULT_ARCH="ppc64"
1857 ;;
1858 *)
1859 AC_MSG_ERROR([Unexpected output of 'arch' on OSX])
1860 ;;
1861 esac
1862
1863 #ARCH_RUN_32BIT="true"
1864 fi
1865
1866 LIBTOOL_CRUFT=$LIBTOOL_CRUFT" -lSystem -lSystemStubs -arch_only ${MACOSX_DEFAULT_ARCH}"
Jack Jansenb36687a2004-07-16 08:43:47 +00001867 LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -install_name $(PYTHONFRAMEWORKINSTALLDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001868 LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -compatibility_version $(VERSION) -current_version $(VERSION)';;
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001869esac
1870
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001871AC_MSG_CHECKING(for --enable-framework)
1872if test "$enable_framework"
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001873then
Skip Montanarodecc6a42003-01-01 20:07:49 +00001874 BASECFLAGS="$BASECFLAGS -fno-common -dynamic"
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001875 # -F. is needed to allow linking to the framework while
1876 # in the build location.
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001877 AC_DEFINE(WITH_NEXT_FRAMEWORK, 1,
1878 [Define if you want to produce an OpenStep/Rhapsody framework
1879 (shared library plus accessory files).])
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001880 AC_MSG_RESULT(yes)
Ronald Oussoren450d5612009-06-08 21:12:41 +00001881 if test $enable_shared = "yes"
1882 then
Ronald Oussoren9ebd2422009-09-29 13:00:44 +00001883 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 +00001884 fi
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001885else
1886 AC_MSG_RESULT(no)
1887fi
1888
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001889AC_MSG_CHECKING(for dyld)
Jack Jansen9a66b6d2001-08-08 13:56:14 +00001890case $ac_sys_system/$ac_sys_release in
1891 Darwin/*)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001892 AC_DEFINE(WITH_DYLD, 1,
1893 [Define if you want to use the new-style (Openstep, Rhapsody, MacOS)
1894 dynamic linker (dyld) instead of the old-style (NextStep) dynamic
1895 linker (rld). Dyld is necessary to support frameworks.])
Jack Jansen9a66b6d2001-08-08 13:56:14 +00001896 AC_MSG_RESULT(always on for Darwin)
1897 ;;
1898 *)
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001899 AC_MSG_RESULT(no)
1900 ;;
Jack Jansen9a66b6d2001-08-08 13:56:14 +00001901esac
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001902
Guido van Rossumac405f61994-09-12 10:56:06 +00001903# Set info about shared libraries.
Guido van Rossumac405f61994-09-12 10:56:06 +00001904AC_SUBST(SO)
1905AC_SUBST(LDSHARED)
Tarek Ziadé00002952010-04-03 08:37:59 +00001906AC_SUBST(LDCXXSHARED)
Neil Schemenauerb3531b82001-02-16 04:09:05 +00001907AC_SUBST(BLDSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00001908AC_SUBST(CCSHARED)
1909AC_SUBST(LINKFORSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00001910# SO is the extension of shared libraries `(including the dot!)
Guido van Rossumaef734b2001-01-10 21:09:12 +00001911# -- usually .so, .sl on HP-UX, .dll on Cygwin
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001912AC_MSG_CHECKING(SO)
Guido van Rossumac405f61994-09-12 10:56:06 +00001913if test -z "$SO"
1914then
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001915 case $ac_sys_system in
Neal Norwitz58e28882006-05-19 07:00:58 +00001916 hp*|HP*)
1917 case `uname -m` in
1918 ia64) SO=.so;;
1919 *) SO=.sl;;
1920 esac
1921 ;;
Guido van Rossumaef734b2001-01-10 21:09:12 +00001922 CYGWIN*) SO=.dll;;
Guido van Rossum4b6b5791996-09-09 20:09:34 +00001923 *) SO=.so;;
Guido van Rossumac405f61994-09-12 10:56:06 +00001924 esac
Martin v. Löwis368de8f2003-06-14 14:46:38 +00001925else
1926 # this might also be a termcap variable, see #610332
1927 echo
1928 echo '====================================================================='
1929 echo '+ +'
1930 echo '+ WARNING: You have set SO in your environment. +'
1931 echo '+ Do you really mean to change the extension for shared libraries? +'
1932 echo '+ Continuing in 10 seconds to let you to ponder. +'
1933 echo '+ +'
1934 echo '====================================================================='
1935 sleep 10
Guido van Rossumac405f61994-09-12 10:56:06 +00001936fi
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001937AC_MSG_RESULT($SO)
Ronald Oussoren79f90492009-01-02 10:44:46 +00001938
Neal Norwitz58e28882006-05-19 07:00:58 +00001939AC_DEFINE_UNQUOTED(SHLIB_EXT, "$SO", [Define this to be extension of shared libraries (including the dot!).])
Guido van Rossumac405f61994-09-12 10:56:06 +00001940# LDSHARED is the ld *command* used to create shared library
Skip Montanaroce59c042004-01-17 14:19:44 +00001941# -- "cc -G" on SunOS 5.x, "ld -shared" on IRIX 5
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001942# (Shared libraries in this instance are shared modules to be loaded into
1943# Python, as opposed to building Python itself as a shared library.)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001944AC_MSG_CHECKING(LDSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00001945if test -z "$LDSHARED"
1946then
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001947 case $ac_sys_system/$ac_sys_release in
Neil Schemenauerb3531b82001-02-16 04:09:05 +00001948 AIX*)
Georg Brandl71f4fbb2011-02-25 11:04:50 +00001949 BLDSHARED="\$(srcdir)/Modules/ld_so_aix \$(CC) -bI:\$(srcdir)/Modules/python.exp"
Guido van Rossumce608b02001-09-28 15:59:38 +00001950 LDSHARED="\$(BINLIBDEST)/config/ld_so_aix \$(CC) -bI:\$(BINLIBDEST)/config/python.exp"
Neil Schemenauerb3531b82001-02-16 04:09:05 +00001951 ;;
1952 BeOS*)
1953 BLDSHARED="\$(srcdir)/Modules/ld_so_beos $LDLIBRARY"
Guido van Rossumce608b02001-09-28 15:59:38 +00001954 LDSHARED="\$(BINLIBDEST)/config/ld_so_beos \$(LIBDIR)/$LDLIBRARY"
Neil Schemenauerb3531b82001-02-16 04:09:05 +00001955 ;;
Guido van Rossum6100aaf1997-04-29 21:48:51 +00001956 IRIX/5*) LDSHARED="ld -shared";;
Guido van Rossum91922671997-10-09 20:24:13 +00001957 IRIX*/6*) LDSHARED="ld ${SGI_ABI} -shared -all";;
Greg Ward57c9a662000-05-26 12:22:54 +00001958 SunOS/5*)
Tarek Ziadé00002952010-04-03 08:37:59 +00001959 if test "$GCC" = "yes" ; then
1960 LDSHARED='$(CC) -shared'
1961 LDCXXSHARED='$(CXX) -shared'
1962 else
1963 LDSHARED='$(CC) -G'
1964 LDCXXSHARED='$(CXX) -G'
Greg Ward57c9a662000-05-26 12:22:54 +00001965 fi ;;
Thomas Hellerdc96a772008-04-04 10:07:55 +00001966 hp*|HP*)
Tarek Ziadé00002952010-04-03 08:37:59 +00001967 if test "$GCC" = "yes" ; then
1968 LDSHARED='$(CC) -shared'
1969 LDCXXSHARED='$(CXX) -shared'
1970 else
1971 LDSHARED='ld -b'
Thomas Hellerdc96a772008-04-04 10:07:55 +00001972 fi ;;
Guido van Rossum71001e41995-01-26 00:44:03 +00001973 OSF*) LDSHARED="ld -shared -expect_unresolved \"*\"";;
Jack Jansen418c3b12001-11-14 10:59:57 +00001974 Darwin/1.3*)
Stefan Krah3a3e2032010-11-28 15:30:05 +00001975 LDSHARED='$(CC) -bundle'
1976 LDCXXSHARED='$(CXX) -bundle'
Jack Jansena3891ea2001-09-07 14:25:12 +00001977 if test "$enable_framework" ; then
1978 # Link against the framework. All externals should be defined.
Jack Jansenda49e192005-01-07 13:08:22 +00001979 BLDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
1980 LDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Tarek Ziadé00002952010-04-03 08:37:59 +00001981 LDCXXSHARED="$LDCXXSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansena3891ea2001-09-07 14:25:12 +00001982 else
1983 # No framework. Ignore undefined symbols, assuming they come from Python
Jack Jansen418c3b12001-11-14 10:59:57 +00001984 LDSHARED="$LDSHARED -undefined suppress"
Tarek Ziadé00002952010-04-03 08:37:59 +00001985 LDCXXSHARED="$LDCXXSHARED -undefined suppress"
Jack Jansena3891ea2001-09-07 14:25:12 +00001986 fi ;;
Jack Jansen6b08a402004-06-03 12:41:45 +00001987 Darwin/1.4*|Darwin/5.*|Darwin/6.*)
Stefan Krah3a3e2032010-11-28 15:30:05 +00001988 LDSHARED='$(CC) -bundle'
1989 LDCXXSHARED='$(CXX) -bundle'
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001990 if test "$enable_framework" ; then
1991 # Link against the framework. All externals should be defined.
Jack Jansenda49e192005-01-07 13:08:22 +00001992 BLDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
1993 LDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Tarek Ziadé00002952010-04-03 08:37:59 +00001994 LDCXXSHARED="$LDCXXSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001995 else
Michael W. Hudson0c46c0c2002-03-07 09:58:56 +00001996 # No framework, use the Python app as bundle-loader
1997 BLDSHARED="$LDSHARED "'-bundle_loader $(BUILDPYTHON)'
Jack Jansenc28fc372003-02-25 13:14:43 +00001998 LDSHARED="$LDSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)'
Tarek Ziadé00002952010-04-03 08:37:59 +00001999 LDCXXSHARED="$LDCXXSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)'
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00002000 fi ;;
Jack Jansen6b08a402004-06-03 12:41:45 +00002001 Darwin/*)
2002 # Use -undefined dynamic_lookup whenever possible (10.3 and later).
2003 # This allows an extension to be used in any Python
Ronald Oussoren38f1b982007-09-02 09:46:07 +00002004
Ned Deilyc40b9032014-06-25 13:48:46 -07002005 dep_target_major=`echo ${MACOSX_DEPLOYMENT_TARGET} | \
2006 sed 's/\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'`
2007 dep_target_minor=`echo ${MACOSX_DEPLOYMENT_TARGET} | \
2008 sed 's/\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'`
2009 if test ${dep_target_major} -eq 10 && \
2010 test ${dep_target_minor} -le 2
Jack Jansen6b08a402004-06-03 12:41:45 +00002011 then
Ned Deilyc40b9032014-06-25 13:48:46 -07002012 # building for OS X 10.0 through 10.2
Stefan Krah3a3e2032010-11-28 15:30:05 +00002013 LDSHARED='$(CC) -bundle'
2014 LDCXXSHARED='$(CXX) -bundle'
Jack Jansen6b08a402004-06-03 12:41:45 +00002015 if test "$enable_framework" ; then
2016 # Link against the framework. All externals should be defined.
Jack Jansenda49e192005-01-07 13:08:22 +00002017 BLDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
2018 LDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Tarek Ziadé00002952010-04-03 08:37:59 +00002019 LDCXXSHARED="$LDCXXSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansen6b08a402004-06-03 12:41:45 +00002020 else
2021 # No framework, use the Python app as bundle-loader
2022 BLDSHARED="$LDSHARED "'-bundle_loader $(BUILDPYTHON)'
2023 LDSHARED="$LDSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)'
Tarek Ziadé00002952010-04-03 08:37:59 +00002024 LDCXXSHARED="$LDCXXSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)'
Jack Jansen6b08a402004-06-03 12:41:45 +00002025 fi
Ned Deilyc40b9032014-06-25 13:48:46 -07002026 else
2027 # building for OS X 10.3 and later
2028 if test "${enable_universalsdk}"; then
2029 LDFLAGS="${UNIVERSAL_ARCH_FLAGS} -isysroot ${UNIVERSALSDK} ${LDFLAGS}"
2030 fi
2031 LDSHARED='$(CC) -bundle -undefined dynamic_lookup'
2032 LDCXXSHARED='$(CXX) -bundle -undefined dynamic_lookup'
2033 BLDSHARED="$LDSHARED"
Jack Jansen6b08a402004-06-03 12:41:45 +00002034 fi
2035 ;;
Tarek Ziadé00002952010-04-03 08:37:59 +00002036 Linux*|GNU*|QNX*)
2037 LDSHARED='$(CC) -shared'
2038 LDCXXSHARED='$(CXX) -shared';;
2039 BSD/OS*/4*)
2040 LDSHARED="gcc -shared"
2041 LDCXXSHARED="g++ -shared";;
Martin v. Löwis222c5152006-06-03 07:37:13 +00002042 FreeBSD*)
Jeremy Hylton4bcc7c52000-08-31 17:45:35 +00002043 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
Guido van Rossum0286ae82000-08-29 15:06:49 +00002044 then
Stefan Krah3a3e2032010-11-28 15:30:05 +00002045 LDSHARED='$(CC) -shared'
2046 LDCXXSHARED='$(CXX) -shared'
Guido van Rossum0286ae82000-08-29 15:06:49 +00002047 else
Stefan Krah3a3e2032010-11-28 15:30:05 +00002048 LDSHARED="ld -Bshareable"
Guido van Rossum0286ae82000-08-29 15:06:49 +00002049 fi;;
Martin v. Löwis222c5152006-06-03 07:37:13 +00002050 OpenBSD*)
2051 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
2052 then
Stefan Krah3a3e2032010-11-28 15:30:05 +00002053 LDSHARED='$(CC) -shared $(CCSHARED)'
2054 LDCXXSHARED='$(CXX) -shared $(CCSHARED)'
Martin v. Löwis222c5152006-06-03 07:37:13 +00002055 else
2056 case `uname -r` in
2057 [[01]].* | 2.[[0-7]] | 2.[[0-7]].*)
2058 LDSHARED="ld -Bshareable ${LDFLAGS}"
2059 ;;
2060 *)
Stefan Krah3a3e2032010-11-28 15:30:05 +00002061 LDSHARED='$(CC) -shared $(CCSHARED)'
2062 LDCXXSHARED='$(CXX) -shared $(CCSHARED)'
Martin v. Löwis222c5152006-06-03 07:37:13 +00002063 ;;
2064 esac
2065 fi;;
Tarek Ziadé00002952010-04-03 08:37:59 +00002066 NetBSD*|DragonFly*)
Antoine Pitroucb402772011-01-02 20:51:34 +00002067 LDSHARED='$(CC) -shared'
2068 LDCXXSHARED='$(CXX) -shared';;
Martin v. Löwis25ae43b2001-10-07 08:39:18 +00002069 OpenUNIX*|UnixWare*)
Tarek Ziadé00002952010-04-03 08:37:59 +00002070 if test "$GCC" = "yes" ; then
2071 LDSHARED='$(CC) -shared'
2072 LDCXXSHARED='$(CXX) -shared'
2073 else
2074 LDSHARED='$(CC) -G'
2075 LDCXXSHARED='$(CXX) -G'
Martin v. Löwisbec19582001-03-21 15:57:54 +00002076 fi;;
Tarek Ziadé00002952010-04-03 08:37:59 +00002077 SCO_SV*)
2078 LDSHARED='$(CC) -Wl,-G,-Bexport'
2079 LDCXXSHARED='$(CXX) -Wl,-G,-Bexport';;
2080 CYGWIN*)
2081 LDSHARED="gcc -shared -Wl,--enable-auto-image-base"
2082 LDCXXSHARED="g++ -shared -Wl,--enable-auto-image-base";;
2083 atheos*)
2084 LDSHARED="gcc -shared"
2085 LDCXXSHARED="g++ -shared";;
Guido van Rossumac405f61994-09-12 10:56:06 +00002086 *) LDSHARED="ld";;
2087 esac
Guido van Rossumac405f61994-09-12 10:56:06 +00002088fi
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002089AC_MSG_RESULT($LDSHARED)
Tarek Ziadé00002952010-04-03 08:37:59 +00002090LDCXXSHARED=${LDCXXSHARED-$LDSHARED}
Neil Schemenauerb3531b82001-02-16 04:09:05 +00002091BLDSHARED=${BLDSHARED-$LDSHARED}
Guido van Rossumac405f61994-09-12 10:56:06 +00002092# CCSHARED are the C *flags* used to create objects to go into a shared
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00002093# library (module) -- this is only needed for a few systems
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002094AC_MSG_CHECKING(CCSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00002095if test -z "$CCSHARED"
2096then
Guido van Rossum6100aaf1997-04-29 21:48:51 +00002097 case $ac_sys_system/$ac_sys_release in
Neil Schemenauer66252162001-02-19 04:47:42 +00002098 SunOS*) if test "$GCC" = yes;
Martin v. Löwiseb623572007-03-12 10:50:39 +00002099 then CCSHARED="-fPIC";
2100 elif test `uname -p` = sparc;
2101 then CCSHARED="-xcode=pic32";
2102 else CCSHARED="-Kpic";
2103 fi;;
Guido van Rossumaf07a441995-02-13 19:45:27 +00002104 hp*|HP*) if test "$GCC" = yes;
Martin v. Löwis703ad702001-09-05 08:36:52 +00002105 then CCSHARED="-fPIC";
Guido van Rossumaf07a441995-02-13 19:45:27 +00002106 else CCSHARED="+z";
2107 fi;;
Martin v. Löwisa6e97582002-01-01 18:41:33 +00002108 Linux*|GNU*) CCSHARED="-fPIC";;
Guido van Rossumf5957ea1999-10-05 21:59:33 +00002109 BSD/OS*/4*) CCSHARED="-fpic";;
Martin v. Löwis86d66262006-02-17 08:40:11 +00002110 FreeBSD*|NetBSD*|OpenBSD*|DragonFly*) CCSHARED="-fPIC";;
Martin v. Löwis25ae43b2001-10-07 08:39:18 +00002111 OpenUNIX*|UnixWare*)
Martin v. Löwisbec19582001-03-21 15:57:54 +00002112 if test "$GCC" = "yes"
2113 then CCSHARED="-fPIC"
Martin v. Löwis130fb172001-07-19 11:00:41 +00002114 else CCSHARED="-KPIC"
Martin v. Löwisbec19582001-03-21 15:57:54 +00002115 fi;;
Martin v. Löwis21ee4092002-09-30 16:19:48 +00002116 SCO_SV*)
2117 if test "$GCC" = "yes"
2118 then CCSHARED="-fPIC"
2119 else CCSHARED="-Kpic -belf"
2120 fi;;
Guido van Rossum2b5ca001998-03-05 15:41:09 +00002121 IRIX*/6*) case $CC in
2122 *gcc*) CCSHARED="-shared";;
Guido van Rossumee21f411998-04-20 18:51:54 +00002123 *) CCSHARED="";;
Guido van Rossum2b5ca001998-03-05 15:41:09 +00002124 esac;;
Martin v. Löwisf90ae202002-06-11 06:22:31 +00002125 atheos*) CCSHARED="-fPIC";;
Guido van Rossumac405f61994-09-12 10:56:06 +00002126 esac
Guido van Rossumac405f61994-09-12 10:56:06 +00002127fi
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002128AC_MSG_RESULT($CCSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00002129# LINKFORSHARED are the flags passed to the $(CC) command that links
Guido van Rossumb65a48e1995-06-14 18:21:23 +00002130# the python executable -- this is only needed for a few systems
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002131AC_MSG_CHECKING(LINKFORSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00002132if test -z "$LINKFORSHARED"
2133then
Guido van Rossum6100aaf1997-04-29 21:48:51 +00002134 case $ac_sys_system/$ac_sys_release in
Neil Schemenauerb3531b82001-02-16 04:09:05 +00002135 AIX*) LINKFORSHARED='-Wl,-bE:Modules/python.exp -lld';;
Guido van Rossum5dab3d81996-12-06 21:18:18 +00002136 hp*|HP*)
Martin v. Löwis1142de32002-03-29 16:28:31 +00002137 LINKFORSHARED="-Wl,-E -Wl,+s";;
2138# LINKFORSHARED="-Wl,-E -Wl,+s -Wl,+b\$(BINLIBDEST)/lib-dynload";;
Guido van Rossumf5957ea1999-10-05 21:59:33 +00002139 BSD/OS/4*) LINKFORSHARED="-Xlinker -export-dynamic";;
Martin v. Löwisa6e97582002-01-01 18:41:33 +00002140 Linux*|GNU*) LINKFORSHARED="-Xlinker -export-dynamic";;
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00002141 # -u libsys_s pulls in all symbols in libsys
Jack Jansenb6e9cad2001-08-15 01:26:28 +00002142 Darwin/*)
Raymond Hettingerec6eb362004-11-05 07:02:59 +00002143 # -u _PyMac_Error is needed to pull in the mac toolbox glue,
2144 # which is
Jack Jansenb6e9cad2001-08-15 01:26:28 +00002145 # not used by the core itself but which needs to be in the core so
2146 # that dynamically loaded extension modules have access to it.
Jack Jansen97e3f002003-02-23 22:59:01 +00002147 # -prebind is no longer used, because it actually seems to give a
2148 # slowdown in stead of a speedup, maybe due to the large number of
2149 # dynamic loads Python does.
Raymond Hettingerec6eb362004-11-05 07:02:59 +00002150
2151 LINKFORSHARED="$extra_undefs"
Jack Jansenb6e9cad2001-08-15 01:26:28 +00002152 if test "$enable_framework"
2153 then
Jack Jansenda49e192005-01-07 13:08:22 +00002154 LINKFORSHARED="$LINKFORSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansenb6e9cad2001-08-15 01:26:28 +00002155 fi
Raymond Hettingerec6eb362004-11-05 07:02:59 +00002156 LINKFORSHARED="$LINKFORSHARED";;
Martin v. Löwis25ae43b2001-10-07 08:39:18 +00002157 OpenUNIX*|UnixWare*) LINKFORSHARED="-Wl,-Bexport";;
Martin v. Löwis21ee4092002-09-30 16:19:48 +00002158 SCO_SV*) LINKFORSHARED="-Wl,-Bexport";;
Fred Drake02706f52000-09-25 15:08:46 +00002159 ReliantUNIX*) LINKFORSHARED="-W1 -Blargedynsym";;
Martin v. Löwis86d66262006-02-17 08:40:11 +00002160 FreeBSD*|NetBSD*|OpenBSD*|DragonFly*)
Guido van Rossumdf693651999-01-07 21:50:41 +00002161 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
2162 then
2163 LINKFORSHARED="-Wl,--export-dynamic"
2164 fi;;
Guido van Rossum2b5ca001998-03-05 15:41:09 +00002165 SunOS/5*) case $CC in
2166 *gcc*)
Martin v. Löwisa4548572002-04-18 14:51:36 +00002167 if $CC -Xlinker --help 2>&1 | grep export-dynamic >/dev/null
Guido van Rossum8f4ceb11997-12-18 23:42:19 +00002168 then
2169 LINKFORSHARED="-Xlinker --export-dynamic"
Guido van Rossum2b5ca001998-03-05 15:41:09 +00002170 fi;;
2171 esac;;
Jason Tishler30765592003-09-04 11:04:06 +00002172 CYGWIN*)
2173 if test $enable_shared = "no"
2174 then
2175 LINKFORSHARED='-Wl,--out-implib=$(LDLIBRARY)'
2176 fi;;
Martin v. Löwis8c255e42008-05-23 15:06:50 +00002177 QNX*)
2178 # -Wl,-E causes the symbols to be added to the dynamic
2179 # symbol table so that they can be found when a module
2180 # is loaded. -N 2048K causes the stack size to be set
2181 # to 2048 kilobytes so that the stack doesn't overflow
2182 # when running test_compile.py.
2183 LINKFORSHARED='-Wl,-E -N 2048K';;
Guido van Rossumac405f61994-09-12 10:56:06 +00002184 esac
Guido van Rossumac405f61994-09-12 10:56:06 +00002185fi
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002186AC_MSG_RESULT($LINKFORSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00002187
Ronald Oussoren0d236eb2008-06-06 21:31:33 +00002188
Neil Schemenauer61c51152001-01-26 16:18:16 +00002189AC_SUBST(CFLAGSFORSHARED)
2190AC_MSG_CHECKING(CFLAGSFORSHARED)
2191if test ! "$LIBRARY" = "$LDLIBRARY"
2192then
Neil Schemenauerd9cf41c2001-01-27 21:39:17 +00002193 case $ac_sys_system in
2194 CYGWIN*)
2195 # Cygwin needs CCSHARED when building extension DLLs
2196 # but not when building the interpreter DLL.
2197 CFLAGSFORSHARED='';;
2198 *)
2199 CFLAGSFORSHARED='$(CCSHARED)'
2200 esac
Neil Schemenauer61c51152001-01-26 16:18:16 +00002201fi
2202AC_MSG_RESULT($CFLAGSFORSHARED)
2203
Martin v. Löwisf90ae202002-06-11 06:22:31 +00002204# SHLIBS are libraries (except -lc and -lm) to link to the python shared
2205# library (with --enable-shared).
2206# For platforms on which shared libraries are not allowed to have unresolved
Martin v. Löwisd6359c52002-08-04 12:38:50 +00002207# symbols, this must be set to $(LIBS) (expanded by make). We do this even
2208# if it is not required, since it creates a dependency of the shared library
2209# to LIBS. This, in turn, means that applications linking the shared libpython
2210# don't need to link LIBS explicitly. The default should be only changed
2211# on systems where this approach causes problems.
Martin v. Löwisf90ae202002-06-11 06:22:31 +00002212AC_SUBST(SHLIBS)
2213AC_MSG_CHECKING(SHLIBS)
2214case "$ac_sys_system" in
Martin v. Löwisf90ae202002-06-11 06:22:31 +00002215 *)
Martin v. Löwisd6359c52002-08-04 12:38:50 +00002216 SHLIBS='$(LIBS)';;
Martin v. Löwisf90ae202002-06-11 06:22:31 +00002217esac
2218AC_MSG_RESULT($SHLIBS)
2219
2220
Guido van Rossum627b2d71993-12-24 10:39:16 +00002221# checks for libraries
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002222AC_CHECK_LIB(dl, dlopen) # Dynamic linking for SunOS/Solaris and SYSV
2223AC_CHECK_LIB(dld, shl_load) # Dynamic linking for HP-UX
Victor Stinner7c906672015-01-06 13:53:37 +01002224AC_CHECK_LIB(crypto, RAND_egd,
2225 AC_DEFINE(HAVE_RAND_EGD, 1,
2226 [Define if the libcrypto has RAND_egd]))
Martin v. Löwis519adae2003-09-20 10:47:47 +00002227
Skip Montanaro4d756af2008-12-01 01:55:22 +00002228# only check for sem_init if thread support is requested
Martin v. Löwis519adae2003-09-20 10:47:47 +00002229if test "$with_threads" = "yes" -o -z "$with_threads"; then
2230 AC_SEARCH_LIBS(sem_init, pthread rt posix4) # 'Real Time' functions on Solaris
2231 # posix4 on Solaris 2.6
2232 # pthread (first!) on Linux
2233fi
2234
Martin v. Löwis19d17342003-06-14 21:03:05 +00002235# check if we need libintl for locale functions
2236AC_CHECK_LIB(intl, textdomain,
2237 AC_DEFINE(WITH_LIBINTL, 1,
2238 [Define to 1 if libintl is needed for locale functions.]))
Guido van Rossum0eefa3f1999-11-16 15:57:37 +00002239
2240# checks for system dependent C++ extensions support
2241case "$ac_sys_system" in
2242 AIX*) AC_MSG_CHECKING(for genuine AIX C++ extensions support)
Matthias Klosec511b472010-05-08 11:01:39 +00002243 AC_LINK_IFELSE([
Georg Brandl94800df2011-02-25 11:09:02 +00002244 AC_LANG_PROGRAM([[#include <load.h>]],
Matthias Klosec511b472010-05-08 11:01:39 +00002245 [[loadAndInit("", 0, "")]])
2246 ],[
2247 AC_DEFINE(AIX_GENUINE_CPLUSPLUS, 1,
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002248 [Define for AIX if your compiler is a genuine IBM xlC/xlC_r
2249 and you want support for AIX C++ shared extension modules.])
Matthias Klosec511b472010-05-08 11:01:39 +00002250 AC_MSG_RESULT(yes)
2251 ],[
2252 AC_MSG_RESULT(no)
2253 ]);;
Guido van Rossum0eefa3f1999-11-16 15:57:37 +00002254 *) ;;
2255esac
2256
Guido van Rossum70c7f481998-03-26 18:44:10 +00002257# Most SVR4 platforms (e.g. Solaris) need -lsocket and -lnsl.
Guido van Rossumec95c7b1998-08-04 17:59:56 +00002258# BeOS' sockets are stashed in libnet.
Guido van Rossumf618d2c1995-01-17 16:36:13 +00002259AC_CHECK_LIB(nsl, t_open, [LIBS="-lnsl $LIBS"]) # SVR4
Guido van Rossumf618d2c1995-01-17 16:36:13 +00002260AC_CHECK_LIB(socket, socket, [LIBS="-lsocket $LIBS"], [], $LIBS) # SVR4 sockets
Skip Montanarob9949db2004-01-17 04:04:13 +00002261
Jeremy Hyltoncb25d5e2000-07-27 21:23:28 +00002262case "$ac_sys_system" in
2263BeOS*)
Guido van Rossumec95c7b1998-08-04 17:59:56 +00002264AC_CHECK_LIB(net, socket, [LIBS="-lnet $LIBS"], [], $LIBS) # BeOS
2265;;
2266esac
Guido van Rossum70c7f481998-03-26 18:44:10 +00002267
Guido van Rossumc5a39031996-07-31 17:35:03 +00002268AC_MSG_CHECKING(for --with-libs)
Barry Warsawc0d24d82000-06-29 16:12:00 +00002269AC_ARG_WITH(libs,
Matthias Klose22520ea2010-05-08 10:14:46 +00002270 AS_HELP_STRING([--with-libs='lib1 ...'], [link against additional libs]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002271[
Guido van Rossumc5a39031996-07-31 17:35:03 +00002272AC_MSG_RESULT($withval)
2273LIBS="$withval $LIBS"
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002274],
2275[AC_MSG_RESULT(no)])
Guido van Rossum627b2d71993-12-24 10:39:16 +00002276
Benjamin Peterson64e8f6e2014-12-15 00:00:23 -05002277PKG_PROG_PKG_CONFIG
Benjamin Petersone9e07bf2010-03-09 21:46:54 +00002278
Benjamin Peterson2c196742009-12-31 03:17:18 +00002279# Check for use of the system expat library
2280AC_MSG_CHECKING(for --with-system-expat)
2281AC_ARG_WITH(system_expat,
Benjamin Petersonf2d1b2a2010-10-31 16:53:53 +00002282 AS_HELP_STRING([--with-system-expat], [build pyexpat module using an installed expat library]),
2283 [],
2284 [with_system_expat="no"])
Benjamin Peterson2c196742009-12-31 03:17:18 +00002285
2286AC_MSG_RESULT($with_system_expat)
2287
Martin v. Löwis9176fc12006-04-11 11:12:43 +00002288# Check for use of the system libffi library
2289AC_MSG_CHECKING(for --with-system-ffi)
2290AC_ARG_WITH(system_ffi,
Benjamin Petersonf2d1b2a2010-10-31 16:53:53 +00002291 AS_HELP_STRING([--with-system-ffi], [build _ctypes module using an installed ffi library]),
2292 [],
2293 [with_system_ffi="no"])
Martin v. Löwis9176fc12006-04-11 11:12:43 +00002294
Benjamin Petersone9e07bf2010-03-09 21:46:54 +00002295if test "$with_system_ffi" = "yes" && test -n "$PKG_CONFIG"; then
Benjamin Peterson1c335e62010-01-01 15:16:29 +00002296 LIBFFI_INCLUDEDIR="`"$PKG_CONFIG" libffi --cflags-only-I 2>/dev/null | sed -e 's/^-I//;s/ *$//'`"
2297else
2298 LIBFFI_INCLUDEDIR=""
2299fi
2300AC_SUBST(LIBFFI_INCLUDEDIR)
2301
Martin v. Löwis9176fc12006-04-11 11:12:43 +00002302AC_MSG_RESULT($with_system_ffi)
2303
Ned Deilya2a9f572013-10-25 00:30:10 -07002304# Check for --with-tcltk-includes=path and --with-tcltk-libs=path
2305AC_SUBST(TCLTK_INCLUDES)
2306AC_SUBST(TCLTK_LIBS)
2307AC_MSG_CHECKING(for --with-tcltk-includes)
2308AC_ARG_WITH(tcltk-includes,
2309 AS_HELP_STRING([--with-tcltk-includes='-I...'], [override search for Tcl and Tk include files]),
2310 [],
2311 [with_tcltk_includes="default"])
2312AC_MSG_RESULT($with_tcltk_includes)
2313AC_MSG_CHECKING(for --with-tcltk-libs)
2314AC_ARG_WITH(tcltk-libs,
2315 AS_HELP_STRING([--with-tcltk-libs='-L...'], [override search for Tcl and Tk libs]),
2316 [],
2317 [with_tcltk_libs="default"])
2318AC_MSG_RESULT($with_tcltk_libs)
2319if test "x$with_tcltk_includes" = xdefault || test "x$with_tcltk_libs" = xdefault
2320then
2321 if test "x$with_tcltk_includes" != "x$with_tcltk_libs"
2322 then
2323 AC_MSG_ERROR([use both --with-tcltk-includes='...' and --with-tcltk-libs='...' or neither])
2324 fi
2325 TCLTK_INCLUDES=""
2326 TCLTK_LIBS=""
2327else
2328 TCLTK_INCLUDES="$with_tcltk_includes"
2329 TCLTK_LIBS="$with_tcltk_libs"
2330fi
2331
Matthias Klose10cbe482009-04-29 17:18:19 +00002332# Check for --with-dbmliborder
2333AC_MSG_CHECKING(for --with-dbmliborder)
2334AC_ARG_WITH(dbmliborder,
Matthias Klose22520ea2010-05-08 10:14:46 +00002335 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 +00002336[
2337if test x$with_dbmliborder = xyes
2338then
2339AC_MSG_ERROR([proper usage is --with-dbmliborder=db1:db2:...])
2340else
2341 for db in `echo $with_dbmliborder | sed 's/:/ /g'`; do
2342 if test x$db != xndbm && test x$db != xgdbm && test x$db != xbdb
2343 then
2344 AC_MSG_ERROR([proper usage is --with-dbmliborder=db1:db2:...])
2345 fi
2346 done
Matthias Klose61dbdb92009-04-29 20:09:50 +00002347fi])
2348AC_MSG_RESULT($with_dbmliborder)
Matthias Klose10cbe482009-04-29 17:18:19 +00002349
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00002350# Determine if signalmodule should be used.
2351AC_SUBST(USE_SIGNAL_MODULE)
2352AC_SUBST(SIGNAL_OBJS)
2353AC_MSG_CHECKING(for --with-signal-module)
2354AC_ARG_WITH(signal-module,
Matthias Klose22520ea2010-05-08 10:14:46 +00002355 AS_HELP_STRING([--with-signal-module], [disable/enable signal module]))
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00002356
2357if test -z "$with_signal_module"
2358then with_signal_module="yes"
2359fi
2360AC_MSG_RESULT($with_signal_module)
2361
2362if test "${with_signal_module}" = "yes"; then
2363 USE_SIGNAL_MODULE=""
2364 SIGNAL_OBJS=""
2365else
2366 USE_SIGNAL_MODULE="#"
2367 SIGNAL_OBJS="Parser/intrcheck.o Python/sigcheck.o"
2368fi
2369
Guido van Rossum3d15bd82001-01-10 18:53:48 +00002370# This is used to generate Setup.config
Guido van Rossum009f7871997-12-04 00:51:42 +00002371AC_SUBST(USE_THREAD_MODULE)
Barry Warsawc0d24d82000-06-29 16:12:00 +00002372USE_THREAD_MODULE=""
Guido van Rossum009f7871997-12-04 00:51:42 +00002373
Guido van Rossum54d93d41997-01-22 20:51:58 +00002374AC_MSG_CHECKING(for --with-dec-threads)
2375AC_SUBST(LDLAST)
2376AC_ARG_WITH(dec-threads,
Matthias Klose22520ea2010-05-08 10:14:46 +00002377 AS_HELP_STRING([--with-dec-threads], [use DEC Alpha/OSF1 thread-safe libraries]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002378[
Barry Warsawc0d24d82000-06-29 16:12:00 +00002379AC_MSG_RESULT($withval)
Guido van Rossum54d93d41997-01-22 20:51:58 +00002380LDLAST=-threads
Guido van Rossumf78abae1997-01-21 22:02:36 +00002381if test "${with_thread+set}" != set; then
Guido van Rossum54d93d41997-01-22 20:51:58 +00002382 with_thread="$withval";
2383fi],
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002384[AC_MSG_RESULT(no)])
Guido van Rossum54d93d41997-01-22 20:51:58 +00002385
Martin v. Löwis11437992002-04-12 09:54:03 +00002386# Templates for things AC_DEFINEd more than once.
2387# For a single AC_DEFINE, no template is needed.
2388AH_TEMPLATE(C_THREADS,[Define if you have the Mach cthreads package])
2389AH_TEMPLATE(_REENTRANT,
2390 [Define to force use of thread-safe errno, h_errno, and other functions])
2391AH_TEMPLATE(WITH_THREAD,
2392 [Define if you want to compile in rudimentary thread support])
2393
Guido van Rossum54d93d41997-01-22 20:51:58 +00002394AC_MSG_CHECKING(for --with-threads)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002395dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
Barry Warsawc0d24d82000-06-29 16:12:00 +00002396AC_ARG_WITH(threads,
Matthias Klose22520ea2010-05-08 10:14:46 +00002397 AS_HELP_STRING([--with(out)-threads@<:@=DIRECTORY@:>@], [disable/enable thread support]))
Guido van Rossum54d93d41997-01-22 20:51:58 +00002398
Barry Warsawc0d24d82000-06-29 16:12:00 +00002399# --with-thread is deprecated, but check for it anyway
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002400dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
Barry Warsawa0f3c5c2000-06-30 16:39:35 +00002401AC_ARG_WITH(thread,
Matthias Klose22520ea2010-05-08 10:14:46 +00002402 AS_HELP_STRING([--with(out)-thread@<:@=DIRECTORY@:>@], [deprecated; use --with(out)-threads]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002403 [with_threads=$with_thread])
Barry Warsawc0d24d82000-06-29 16:12:00 +00002404
2405if test -z "$with_threads"
2406then with_threads="yes"
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002407fi
Barry Warsawc0d24d82000-06-29 16:12:00 +00002408AC_MSG_RESULT($with_threads)
Guido van Rossum6400c261997-05-22 20:34:27 +00002409
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002410AC_SUBST(THREADOBJ)
Barry Warsawc0d24d82000-06-29 16:12:00 +00002411if test "$with_threads" = "no"
2412then
2413 USE_THREAD_MODULE="#"
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002414elif test "$ac_cv_pthread_is_default" = yes
2415then
2416 AC_DEFINE(WITH_THREAD)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002417 # Defining _REENTRANT on system with POSIX threads should not hurt.
2418 AC_DEFINE(_REENTRANT)
2419 posix_threads=yes
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002420 THREADOBJ="Python/thread.o"
Martin v. Löwis130fb172001-07-19 11:00:41 +00002421elif test "$ac_cv_kpthread" = "yes"
2422then
2423 CC="$CC -Kpthread"
Martin v. Löwis519adae2003-09-20 10:47:47 +00002424 if test "$ac_cv_cxx_thread" = "yes"; then
2425 CXX="$CXX -Kpthread"
2426 fi
Martin v. Löwis130fb172001-07-19 11:00:41 +00002427 AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002428 posix_threads=yes
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002429 THREADOBJ="Python/thread.o"
Martin v. Löwis5f433f02003-05-05 05:05:30 +00002430elif test "$ac_cv_kthread" = "yes"
2431then
2432 CC="$CC -Kthread"
Martin v. Löwis519adae2003-09-20 10:47:47 +00002433 if test "$ac_cv_cxx_thread" = "yes"; then
2434 CXX="$CXX -Kthread"
2435 fi
Martin v. Löwis5f433f02003-05-05 05:05:30 +00002436 AC_DEFINE(WITH_THREAD)
2437 posix_threads=yes
2438 THREADOBJ="Python/thread.o"
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002439elif test "$ac_cv_pthread" = "yes"
2440then
2441 CC="$CC -pthread"
Martin v. Löwis519adae2003-09-20 10:47:47 +00002442 if test "$ac_cv_cxx_thread" = "yes"; then
2443 CXX="$CXX -pthread"
2444 fi
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002445 AC_DEFINE(WITH_THREAD)
2446 posix_threads=yes
2447 THREADOBJ="Python/thread.o"
Barry Warsawc0d24d82000-06-29 16:12:00 +00002448else
Martin v. Löwis130fb172001-07-19 11:00:41 +00002449 if test ! -z "$with_threads" -a -d "$with_threads"
2450 then LDFLAGS="$LDFLAGS -L$with_threads"
2451 fi
2452 if test ! -z "$withval" -a -d "$withval"
2453 then LDFLAGS="$LDFLAGS -L$withval"
2454 fi
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002455
2456 # According to the POSIX spec, a pthreads implementation must
Matthias Klosea2542be2004-08-16 11:35:51 +00002457 # define _POSIX_THREADS in unistd.h. Some apparently don't
2458 # (e.g. gnu pth with pthread emulation)
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002459 AC_MSG_CHECKING(for _POSIX_THREADS in unistd.h)
2460 AC_EGREP_CPP(yes,
Neal Norwitz6eb37f02003-02-23 23:28:15 +00002461 [
2462#include <unistd.h>
2463#ifdef _POSIX_THREADS
2464yes
2465#endif
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002466 ], unistd_defines_pthreads=yes, unistd_defines_pthreads=no)
2467 AC_MSG_RESULT($unistd_defines_pthreads)
2468
Martin v. Löwis130fb172001-07-19 11:00:41 +00002469 AC_DEFINE(_REENTRANT)
Martin v. Löwisa6e97582002-01-01 18:41:33 +00002470 AC_CHECK_HEADER(cthreads.h, [AC_DEFINE(WITH_THREAD)
2471 AC_DEFINE(C_THREADS)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002472 AC_DEFINE(HURD_C_THREADS, 1,
2473 [Define if you are using Mach cthreads directly under /include])
Martin v. Löwisa6e97582002-01-01 18:41:33 +00002474 LIBS="$LIBS -lthreads"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002475 THREADOBJ="Python/thread.o"],[
Martin v. Löwis130fb172001-07-19 11:00:41 +00002476 AC_CHECK_HEADER(mach/cthreads.h, [AC_DEFINE(WITH_THREAD)
2477 AC_DEFINE(C_THREADS)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002478 AC_DEFINE(MACH_C_THREADS, 1,
2479 [Define if you are using Mach cthreads under mach /])
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002480 THREADOBJ="Python/thread.o"],[
Martin v. Löwis130fb172001-07-19 11:00:41 +00002481 AC_MSG_CHECKING(for --with-pth)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002482 AC_ARG_WITH([pth],
Matthias Klose22520ea2010-05-08 10:14:46 +00002483 AS_HELP_STRING([--with-pth], [use GNU pth threading libraries]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002484 [AC_MSG_RESULT($withval)
2485 AC_DEFINE([WITH_THREAD])
2486 AC_DEFINE([HAVE_PTH], 1,
2487 [Define if you have GNU PTH threads.])
2488 LIBS="-lpth $LIBS"
2489 THREADOBJ="Python/thread.o"],
2490 [AC_MSG_RESULT(no)
Martin v. Löwis8158b5a2001-10-08 13:17:28 +00002491
2492 # Just looking for pthread_create in libpthread is not enough:
2493 # on HP/UX, pthread.h renames pthread_create to a different symbol name.
2494 # So we really have to include pthread.h, and then link.
2495 _libs=$LIBS
2496 LIBS="$LIBS -lpthread"
2497 AC_MSG_CHECKING([for pthread_create in -lpthread])
Stefan Krahae66ca62012-11-22 22:36:57 +01002498 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
2499#include <stdio.h>
2500#include <pthread.h>
Martin v. Löwis8158b5a2001-10-08 13:17:28 +00002501
Matthias Klosec511b472010-05-08 11:01:39 +00002502void * start_routine (void *arg) { exit (0); }]], [[
2503pthread_create (NULL, NULL, start_routine, NULL)]])],[
Martin v. Löwis8158b5a2001-10-08 13:17:28 +00002504 AC_MSG_RESULT(yes)
2505 AC_DEFINE(WITH_THREAD)
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002506 posix_threads=yes
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002507 THREADOBJ="Python/thread.o"],[
Martin v. Löwis8158b5a2001-10-08 13:17:28 +00002508 LIBS=$_libs
Martin v. Löwis130fb172001-07-19 11:00:41 +00002509 AC_CHECK_FUNC(pthread_detach, [AC_DEFINE(WITH_THREAD)
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002510 posix_threads=yes
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002511 THREADOBJ="Python/thread.o"],[
Martin v. Löwisf90ae202002-06-11 06:22:31 +00002512 AC_CHECK_HEADER(atheos/threads.h, [AC_DEFINE(WITH_THREAD)
2513 AC_DEFINE(ATHEOS_THREADS, 1,
2514 [Define this if you have AtheOS threads.])
2515 THREADOBJ="Python/thread.o"],[
Martin v. Löwis130fb172001-07-19 11:00:41 +00002516 AC_CHECK_HEADER(kernel/OS.h, [AC_DEFINE(WITH_THREAD)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002517 AC_DEFINE(BEOS_THREADS, 1,
2518 [Define this if you have BeOS threads.])
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002519 THREADOBJ="Python/thread.o"],[
Martin v. Löwis130fb172001-07-19 11:00:41 +00002520 AC_CHECK_LIB(pthreads, pthread_create, [AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002521 posix_threads=yes
Martin v. Löwis130fb172001-07-19 11:00:41 +00002522 LIBS="$LIBS -lpthreads"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002523 THREADOBJ="Python/thread.o"], [
Martin v. Löwis130fb172001-07-19 11:00:41 +00002524 AC_CHECK_LIB(c_r, pthread_create, [AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002525 posix_threads=yes
Martin v. Löwis130fb172001-07-19 11:00:41 +00002526 LIBS="$LIBS -lc_r"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002527 THREADOBJ="Python/thread.o"], [
Martin v. Löwis130fb172001-07-19 11:00:41 +00002528 AC_CHECK_LIB(pthread, __pthread_create_system, [AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002529 posix_threads=yes
Martin v. Löwis130fb172001-07-19 11:00:41 +00002530 LIBS="$LIBS -lpthread"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002531 THREADOBJ="Python/thread.o"], [
Martin v. Löwis130fb172001-07-19 11:00:41 +00002532 AC_CHECK_LIB(cma, pthread_create, [AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002533 posix_threads=yes
Martin v. Löwis130fb172001-07-19 11:00:41 +00002534 LIBS="$LIBS -lcma"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002535 THREADOBJ="Python/thread.o"],[
Martin v. Löwis130fb172001-07-19 11:00:41 +00002536 USE_THREAD_MODULE="#"])
Skip Montanarof8712e52004-01-17 03:04:46 +00002537 ])])])])])])])])])])
Barry Warsawc0d24d82000-06-29 16:12:00 +00002538
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002539 AC_CHECK_LIB(mpc, usconfig, [AC_DEFINE(WITH_THREAD)
2540 LIBS="$LIBS -lmpc"
2541 THREADOBJ="Python/thread.o"
2542 USE_THREAD_MODULE=""])
2543
2544 if test "$posix_threads" != "yes"; then
2545 AC_CHECK_LIB(thread, thr_create, [AC_DEFINE(WITH_THREAD)
2546 LIBS="$LIBS -lthread"
2547 THREADOBJ="Python/thread.o"
2548 USE_THREAD_MODULE=""])
2549 fi
2550
2551 if test "$USE_THREAD_MODULE" != "#"
2552 then
2553 # If the above checks didn't disable threads, (at least) OSF1
2554 # needs this '-threads' argument during linking.
2555 case $ac_sys_system in
2556 OSF1) LDLAST=-threads;;
2557 esac
2558 fi
2559fi
2560
2561if test "$posix_threads" = "yes"; then
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002562 if test "$unistd_defines_pthreads" = "no"; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002563 AC_DEFINE(_POSIX_THREADS, 1,
2564 [Define if you have POSIX threads,
2565 and your system does not define that.])
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002566 fi
2567
Martin v. Löwisdfc33fd2003-01-21 10:14:41 +00002568 # Bug 662787: Using semaphores causes unexplicable hangs on Solaris 8.
2569 case $ac_sys_system/$ac_sys_release in
Charles-François Natali4929eb92011-07-21 19:41:04 +02002570 SunOS/5.6) AC_DEFINE(HAVE_PTHREAD_DESTRUCTOR, 1,
Matthias Klose5183ebd2010-04-24 16:38:36 +00002571 [Defined for Solaris 2.6 bug in pthread header.])
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002572 ;;
Martin v. Löwisdfc33fd2003-01-21 10:14:41 +00002573 SunOS/5.8) AC_DEFINE(HAVE_BROKEN_POSIX_SEMAPHORES, 1,
Matthias Klose5183ebd2010-04-24 16:38:36 +00002574 [Define if the Posix semaphores do not work on your system])
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002575 ;;
Charles-François Natali4929eb92011-07-21 19:41:04 +02002576 AIX/*) 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])
Christian Heimescba36bb2008-01-30 22:54:18 +00002578 ;;
Martin v. Löwisdfc33fd2003-01-21 10:14:41 +00002579 esac
2580
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002581 AC_MSG_CHECKING(if PTHREAD_SCOPE_SYSTEM is supported)
2582 AC_CACHE_VAL(ac_cv_pthread_system_supported,
Stefan Krahae66ca62012-11-22 22:36:57 +01002583 [AC_RUN_IFELSE([AC_LANG_SOURCE([[
2584 #include <stdio.h>
2585 #include <pthread.h>
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002586 void *foo(void *parm) {
2587 return NULL;
2588 }
2589 main() {
2590 pthread_attr_t attr;
Martin v. Löwisa82d3472002-02-24 16:05:05 +00002591 pthread_t id;
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002592 if (pthread_attr_init(&attr)) exit(-1);
2593 if (pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM)) exit(-1);
Martin v. Löwisa82d3472002-02-24 16:05:05 +00002594 if (pthread_create(&id, &attr, foo, NULL)) exit(-1);
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002595 exit(0);
Matthias Klosec511b472010-05-08 11:01:39 +00002596 }]])],
2597 [ac_cv_pthread_system_supported=yes],
2598 [ac_cv_pthread_system_supported=no],
2599 [ac_cv_pthread_system_supported=no])
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002600 ])
2601 AC_MSG_RESULT($ac_cv_pthread_system_supported)
2602 if test "$ac_cv_pthread_system_supported" = "yes"; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002603 AC_DEFINE(PTHREAD_SYSTEM_SCHED_SUPPORTED, 1, [Defined if PTHREAD_SCOPE_SYSTEM supported.])
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002604 fi
Jason Tishlerfac083d2003-07-22 15:20:49 +00002605 AC_CHECK_FUNCS(pthread_sigmask,
2606 [case $ac_sys_system in
2607 CYGWIN*)
2608 AC_DEFINE(HAVE_BROKEN_PTHREAD_SIGMASK, 1,
2609 [Define if pthread_sigmask() does not work on your system.])
2610 ;;
2611 esac])
Christian Heimes0d604cf2013-08-21 13:26:05 +02002612 AC_CHECK_FUNCS(pthread_atfork)
Barry Warsawc0d24d82000-06-29 16:12:00 +00002613fi
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002614
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002615
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002616# Check for enable-ipv6
Martin v. Löwis11437992002-04-12 09:54:03 +00002617AH_TEMPLATE(ENABLE_IPV6, [Define if --enable-ipv6 is specified])
Martin v. Löwisa5f8bb52001-09-05 08:22:34 +00002618AC_MSG_CHECKING([if --enable-ipv6 is specified])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002619AC_ARG_ENABLE(ipv6,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002620[ --enable-ipv6 Enable ipv6 (with ipv4) support
2621 --disable-ipv6 Disable ipv6 support],
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002622[ case "$enableval" in
2623 no)
2624 AC_MSG_RESULT(no)
2625 ipv6=no
2626 ;;
2627 *) AC_MSG_RESULT(yes)
2628 AC_DEFINE(ENABLE_IPV6)
2629 ipv6=yes
2630 ;;
2631 esac ],
2632
Martin v. Löwisa5f8bb52001-09-05 08:22:34 +00002633[
2634dnl the check does not work on cross compilation case...
Charles-François Natalibe2b9072013-01-08 19:47:00 +01002635 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ /* AF_INET6 available check */
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002636#include <sys/types.h>
Charles-François Natalibe2b9072013-01-08 19:47:00 +01002637#include <sys/socket.h>]],
2638[[int domain = AF_INET6;]])],[
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002639 AC_MSG_RESULT(yes)
Matthias Klosec511b472010-05-08 11:01:39 +00002640 ipv6=yes
2641],[
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002642 AC_MSG_RESULT(no)
2643 ipv6=no
Matthias Klosec511b472010-05-08 11:01:39 +00002644])
Martin v. Löwisa5f8bb52001-09-05 08:22:34 +00002645
2646if test "$ipv6" = "yes"; then
2647 AC_MSG_CHECKING(if RFC2553 API is available)
Matthias Klosec511b472010-05-08 11:01:39 +00002648 AC_COMPILE_IFELSE([
2649 AC_LANG_PROGRAM([[#include <sys/types.h>
2650#include <netinet/in.h>]],
2651 [[struct sockaddr_in6 x;
2652 x.sin6_scope_id;]])
2653 ],[
2654 AC_MSG_RESULT(yes)
2655 ipv6=yes
2656 ],[
2657 AC_MSG_RESULT(no, IPv6 disabled)
2658 ipv6=no
2659 ])
Martin v. Löwisa5f8bb52001-09-05 08:22:34 +00002660fi
2661
2662if test "$ipv6" = "yes"; then
2663 AC_DEFINE(ENABLE_IPV6)
2664fi
2665])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002666
2667ipv6type=unknown
2668ipv6lib=none
2669ipv6trylibc=no
2670
2671if test "$ipv6" = "yes"; then
2672 AC_MSG_CHECKING([ipv6 stack type])
Guido van Rossumb8552162001-09-05 14:58:11 +00002673 for i in inria kame linux-glibc linux-inet6 solaris toshiba v6d zeta;
2674 do
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002675 case $i in
2676 inria)
2677 dnl http://www.kame.net/
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002678 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002679#include <netinet/in.h>
2680#ifdef IPV6_INRIA_VERSION
2681yes
2682#endif],
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002683 [ipv6type=$i])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002684 ;;
2685 kame)
2686 dnl http://www.kame.net/
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002687 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002688#include <netinet/in.h>
2689#ifdef __KAME__
2690yes
2691#endif],
2692 [ipv6type=$i;
2693 ipv6lib=inet6
2694 ipv6libdir=/usr/local/v6/lib
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002695 ipv6trylibc=yes])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002696 ;;
2697 linux-glibc)
2698 dnl http://www.v6.linux.or.jp/
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002699 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002700#include <features.h>
2701#if defined(__GLIBC__) && ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1) || (__GLIBC__ > 2))
2702yes
2703#endif],
2704 [ipv6type=$i;
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002705 ipv6trylibc=yes])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002706 ;;
2707 linux-inet6)
2708 dnl http://www.v6.linux.or.jp/
2709 if test -d /usr/inet6; then
2710 ipv6type=$i
2711 ipv6lib=inet6
2712 ipv6libdir=/usr/inet6/lib
Skip Montanarodecc6a42003-01-01 20:07:49 +00002713 BASECFLAGS="-I/usr/inet6/include $BASECFLAGS"
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002714 fi
2715 ;;
2716 solaris)
2717 if test -f /etc/netconfig; then
Antoine Pitrou31e85952011-01-03 18:57:14 +00002718 if $GREP -q tcp6 /etc/netconfig; then
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002719 ipv6type=$i
2720 ipv6trylibc=yes
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002721 fi
2722 fi
2723 ;;
2724 toshiba)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002725 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002726#include <sys/param.h>
2727#ifdef _TOSHIBA_INET6
2728yes
2729#endif],
2730 [ipv6type=$i;
2731 ipv6lib=inet6;
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002732 ipv6libdir=/usr/local/v6/lib])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002733 ;;
2734 v6d)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002735 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002736#include </usr/local/v6/include/sys/v6config.h>
2737#ifdef __V6D__
2738yes
2739#endif],
2740 [ipv6type=$i;
2741 ipv6lib=v6;
2742 ipv6libdir=/usr/local/v6/lib;
Skip Montanarodecc6a42003-01-01 20:07:49 +00002743 BASECFLAGS="-I/usr/local/v6/include $BASECFLAGS"])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002744 ;;
2745 zeta)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002746 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002747#include <sys/param.h>
2748#ifdef _ZETA_MINAMI_INET6
2749yes
2750#endif],
2751 [ipv6type=$i;
2752 ipv6lib=inet6;
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002753 ipv6libdir=/usr/local/v6/lib])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002754 ;;
2755 esac
2756 if test "$ipv6type" != "unknown"; then
2757 break
2758 fi
2759 done
2760 AC_MSG_RESULT($ipv6type)
2761fi
2762
2763if test "$ipv6" = "yes" -a "$ipv6lib" != "none"; then
2764 if test -d $ipv6libdir -a -f $ipv6libdir/lib$ipv6lib.a; then
2765 LIBS="-L$ipv6libdir -l$ipv6lib $LIBS"
2766 echo "using lib$ipv6lib"
2767 else
2768 if test $ipv6trylibc = "yes"; then
2769 echo "using libc"
2770 else
2771 echo 'Fatal: no $ipv6lib library found. cannot continue.'
2772 echo "You need to fetch lib$ipv6lib.a from appropriate"
2773 echo 'ipv6 kit and compile beforehand.'
2774 exit 1
2775 fi
2776 fi
2777fi
2778
Ronald Oussoren0d236eb2008-06-06 21:31:33 +00002779AC_MSG_CHECKING(for OSX 10.5 SDK or later)
Matthias Klosec511b472010-05-08 11:01:39 +00002780AC_COMPILE_IFELSE([
Mark Dickinson0712b562010-05-08 19:13:21 +00002781 AC_LANG_PROGRAM([[#include <Carbon/Carbon.h>]], [[FSIORefNum fRef = 0]])
Matthias Klosec511b472010-05-08 11:01:39 +00002782],[
Matthias Klose5183ebd2010-04-24 16:38:36 +00002783 AC_DEFINE(HAVE_OSX105_SDK, 1, [Define if compiling using MacOS X 10.5 SDK or later.])
Matthias Klosec511b472010-05-08 11:01:39 +00002784 AC_MSG_RESULT(yes)
2785],[
Ronald Oussoren0d236eb2008-06-06 21:31:33 +00002786 AC_MSG_RESULT(no)
Matthias Klosec511b472010-05-08 11:01:39 +00002787])
Ronald Oussoren0d236eb2008-06-06 21:31:33 +00002788
Martin v. Löwisa3fb4f72002-06-09 13:33:54 +00002789# Check for --with-doc-strings
2790AC_MSG_CHECKING(for --with-doc-strings)
2791AC_ARG_WITH(doc-strings,
Matthias Klose22520ea2010-05-08 10:14:46 +00002792 AS_HELP_STRING([--with(out)-doc-strings], [disable/enable documentation strings]))
Martin v. Löwisa3fb4f72002-06-09 13:33:54 +00002793
2794if test -z "$with_doc_strings"
2795then with_doc_strings="yes"
2796fi
2797if test "$with_doc_strings" != "no"
2798then
2799 AC_DEFINE(WITH_DOC_STRINGS, 1,
2800 [Define if you want documentation strings in extension modules])
2801fi
2802AC_MSG_RESULT($with_doc_strings)
2803
Neil Schemenauera35c6882001-02-27 04:45:05 +00002804# Check for Python-specific malloc support
Martin v. Löwisf30d60e2004-06-08 08:17:44 +00002805AC_MSG_CHECKING(for --with-tsc)
2806AC_ARG_WITH(tsc,
Matthias Klose22520ea2010-05-08 10:14:46 +00002807 AS_HELP_STRING([--with(out)-tsc],[enable/disable timestamp counter profile]),[
Martin v. Löwisf30d60e2004-06-08 08:17:44 +00002808if test "$withval" != no
2809then
2810 AC_DEFINE(WITH_TSC, 1,
2811 [Define to profile with the Pentium timestamp counter])
2812 AC_MSG_RESULT(yes)
2813else AC_MSG_RESULT(no)
2814fi],
2815[AC_MSG_RESULT(no)])
2816
2817# Check for Python-specific malloc support
Neil Schemenauera35c6882001-02-27 04:45:05 +00002818AC_MSG_CHECKING(for --with-pymalloc)
2819AC_ARG_WITH(pymalloc,
Matthias Klose22520ea2010-05-08 10:14:46 +00002820 AS_HELP_STRING([--with(out)-pymalloc], [disable/enable specialized mallocs]))
Neil Schemenauer16c22972002-03-22 15:34:49 +00002821
2822if test -z "$with_pymalloc"
2823then with_pymalloc="yes"
2824fi
2825if test "$with_pymalloc" != "no"
2826then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002827 AC_DEFINE(WITH_PYMALLOC, 1,
2828 [Define if you want to compile in Python-specific mallocs])
Neil Schemenauer16c22972002-03-22 15:34:49 +00002829fi
2830AC_MSG_RESULT($with_pymalloc)
Neil Schemenauera35c6882001-02-27 04:45:05 +00002831
Benjamin Peterson91c12eb2009-12-03 02:52:39 +00002832# Check for Valgrind support
2833AC_MSG_CHECKING([for --with-valgrind])
2834AC_ARG_WITH([valgrind],
Matthias Klose22520ea2010-05-08 10:14:46 +00002835 AS_HELP_STRING([--with-valgrind], [Enable Valgrind support]),,
Benjamin Peterson91c12eb2009-12-03 02:52:39 +00002836 with_valgrind=no)
2837AC_MSG_RESULT([$with_valgrind])
2838if test "$with_valgrind" != no; then
2839 AC_CHECK_HEADER([valgrind/valgrind.h],
2840 [AC_DEFINE([WITH_VALGRIND], 1, [Define if you want pymalloc to be disabled when running under valgrind])],
2841 [AC_MSG_ERROR([Valgrind support requested but headers not available])]
2842 )
2843fi
2844
Barry Warsawef82cd72000-06-30 16:21:01 +00002845# Check for --with-wctype-functions
2846AC_MSG_CHECKING(for --with-wctype-functions)
2847AC_ARG_WITH(wctype-functions,
Matthias Klose22520ea2010-05-08 10:14:46 +00002848 AS_HELP_STRING([--with-wctype-functions], [use wctype.h functions]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002849[
Barry Warsawef82cd72000-06-30 16:21:01 +00002850if test "$withval" != no
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002851then
2852 AC_DEFINE(WANT_WCTYPE_FUNCTIONS, 1,
2853 [Define if you want wctype.h functions to be used instead of the
2854 one supplied by Python itself. (see Include/unicodectype.h).])
2855 AC_MSG_RESULT(yes)
Barry Warsawef82cd72000-06-30 16:21:01 +00002856else AC_MSG_RESULT(no)
2857fi],
2858[AC_MSG_RESULT(no)])
2859
Guido van Rossum68242b51996-05-28 22:53:03 +00002860# -I${DLINCLDIR} is added to the compile rule for importdl.o
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002861AC_SUBST(DLINCLDIR)
Guido van Rossum98935bf2001-09-05 19:13:16 +00002862DLINCLDIR=.
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002863
Guido van Rossume97ee181999-12-20 21:27:22 +00002864# the dlopen() function means we might want to use dynload_shlib.o. some
2865# platforms, such as AIX, have dlopen(), but don't want to use it.
Thomas Wouters3a584202000-08-05 23:28:51 +00002866AC_CHECK_FUNCS(dlopen)
Guido van Rossume97ee181999-12-20 21:27:22 +00002867
2868# DYNLOADFILE specifies which dynload_*.o file we will use for dynamic
2869# loading of modules.
2870AC_SUBST(DYNLOADFILE)
2871AC_MSG_CHECKING(DYNLOADFILE)
2872if test -z "$DYNLOADFILE"
2873then
2874 case $ac_sys_system/$ac_sys_release in
Martin v. Löwisc19c5a62003-11-18 20:00:44 +00002875 AIX*) # Use dynload_shlib.c and dlopen() if we have it; otherwise dynload_aix.c
2876 if test "$ac_cv_func_dlopen" = yes
2877 then DYNLOADFILE="dynload_shlib.o"
2878 else DYNLOADFILE="dynload_aix.o"
2879 fi
2880 ;;
Guido van Rossume97ee181999-12-20 21:27:22 +00002881 BeOS*) DYNLOADFILE="dynload_beos.o";;
2882 hp*|HP*) DYNLOADFILE="dynload_hpux.o";;
Anthony Baxter82201742006-04-09 15:07:40 +00002883 # Use dynload_next.c only on 10.2 and below, which don't have native dlopen()
2884 Darwin/@<:@0156@:>@\..*) DYNLOADFILE="dynload_next.o";;
Martin v. Löwisf90ae202002-06-11 06:22:31 +00002885 atheos*) DYNLOADFILE="dynload_atheos.o";;
Guido van Rossume97ee181999-12-20 21:27:22 +00002886 *)
2887 # use dynload_shlib.c and dlopen() if we have it; otherwise stub
2888 # out any dynamic loading
2889 if test "$ac_cv_func_dlopen" = yes
2890 then DYNLOADFILE="dynload_shlib.o"
2891 else DYNLOADFILE="dynload_stub.o"
2892 fi
2893 ;;
2894 esac
2895fi
2896AC_MSG_RESULT($DYNLOADFILE)
2897if test "$DYNLOADFILE" != "dynload_stub.o"
2898then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002899 AC_DEFINE(HAVE_DYNAMIC_LOADING, 1,
2900 [Defined when any dynamic module loading is enabled.])
Guido van Rossume97ee181999-12-20 21:27:22 +00002901fi
2902
Jack Jansenc49e5b72001-06-19 15:00:23 +00002903# MACHDEP_OBJS can be set to platform-specific object files needed by Python
2904
2905AC_SUBST(MACHDEP_OBJS)
2906AC_MSG_CHECKING(MACHDEP_OBJS)
2907if test -z "$MACHDEP_OBJS"
2908then
Jack Jansenb6e9cad2001-08-15 01:26:28 +00002909 MACHDEP_OBJS=$extra_machdep_objs
2910else
2911 MACHDEP_OBJS="$MACHDEP_OBJS $extra_machdep_objs"
Jack Jansenc49e5b72001-06-19 15:00:23 +00002912fi
Jack Jansenb6e9cad2001-08-15 01:26:28 +00002913AC_MSG_RESULT(MACHDEP_OBJS)
Jack Jansenc49e5b72001-06-19 15:00:23 +00002914
Guido van Rossum627b2d71993-12-24 10:39:16 +00002915# checks for library functions
Martin v. Löwisaef18b12008-03-24 13:31:16 +00002916AC_CHECK_FUNCS(alarm setitimer getitimer bind_textdomain_codeset chown \
2917 clock confstr ctermid execv fchmod fchown fork fpathconf ftime ftruncate \
Martin v. Löwis438b5342002-12-27 10:16:42 +00002918 gai_strerror getgroups getlogin getloadavg getpeername getpgid getpid \
Benjamin Peterson27c269a2014-12-26 11:09:00 -06002919 getentropy \
Martin v. Löwis50ea4562009-11-27 13:56:01 +00002920 getpriority getresuid getresgid getpwent getspnam getspent getsid getwd \
Benjamin Petersond16e01c2014-02-04 10:20:26 -05002921 initgroups kill killpg lchmod lchown lstat mkfifo mknod mktime mmap \
Martin v. Löwisa5f09072002-10-11 05:37:59 +00002922 mremap nice pathconf pause plock poll pthread_init \
Guido van Rossum162e38c2003-02-19 15:25:10 +00002923 putenv readlink realpath \
Jesse Noller355b1262009-04-02 00:03:28 +00002924 select sem_open sem_timedwait sem_getvalue sem_unlink setegid seteuid \
2925 setgid \
Martin v. Löwis4daacb12003-03-28 18:37:01 +00002926 setlocale setregid setreuid setsid setpgid setpgrp setuid setvbuf snprintf \
Martin v. Löwis50ea4562009-11-27 13:56:01 +00002927 setlocale setregid setreuid setresuid setresgid \
2928 setsid setpgid setpgrp setuid setvbuf snprintf \
Skip Montanaro7e11a012004-02-07 12:55:46 +00002929 sigaction siginterrupt sigrelse strftime \
Michael W. Hudson34f20ea2002-05-27 15:08:24 +00002930 sysconf tcgetpgrp tcsetpgrp tempnam timegm times tmpfile tmpnam tmpnam_r \
Neal Norwitz05a45592006-03-20 06:30:08 +00002931 truncate uname unsetenv utimes waitpid wait3 wait4 wcscoll _getpty)
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00002932
Martin v. Löwisc8ad7cc2002-11-11 13:23:45 +00002933# For some functions, having a definition is not sufficient, since
2934# we want to take their address.
2935AC_MSG_CHECKING(for chroot)
Matthias Klosec511b472010-05-08 11:01:39 +00002936AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[void *x=chroot]])],
2937 [AC_DEFINE(HAVE_CHROOT, 1, Define if you have the 'chroot' function.)
2938 AC_MSG_RESULT(yes)],
2939 [AC_MSG_RESULT(no)
2940])
Martin v. Löwisc8ad7cc2002-11-11 13:23:45 +00002941AC_MSG_CHECKING(for link)
Matthias Klosec511b472010-05-08 11:01:39 +00002942AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[void *x=link]])],
2943 [AC_DEFINE(HAVE_LINK, 1, Define if you have the 'link' function.)
2944 AC_MSG_RESULT(yes)],
2945 [AC_MSG_RESULT(no)
2946])
Martin v. Löwisc8ad7cc2002-11-11 13:23:45 +00002947AC_MSG_CHECKING(for symlink)
Matthias Klosec511b472010-05-08 11:01:39 +00002948AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[void *x=symlink]])],
2949 [AC_DEFINE(HAVE_SYMLINK, 1, Define if you have the 'symlink' function.)
2950 AC_MSG_RESULT(yes)],
2951 [AC_MSG_RESULT(no)
2952])
Martin v. Löwisa64988c2003-09-20 15:30:20 +00002953AC_MSG_CHECKING(for fchdir)
Matthias Klosec511b472010-05-08 11:01:39 +00002954AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[void *x=fchdir]])],
2955 [AC_DEFINE(HAVE_FCHDIR, 1, Define if you have the 'fchdir' function.)
2956 AC_MSG_RESULT(yes)],
2957 [AC_MSG_RESULT(no)
2958])
Martin v. Löwisa64988c2003-09-20 15:30:20 +00002959AC_MSG_CHECKING(for fsync)
Matthias Klosec511b472010-05-08 11:01:39 +00002960AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[void *x=fsync]])],
2961 [AC_DEFINE(HAVE_FSYNC, 1, Define if you have the 'fsync' function.)
2962 AC_MSG_RESULT(yes)],
2963 [AC_MSG_RESULT(no)
2964])
Martin v. Löwisa64988c2003-09-20 15:30:20 +00002965AC_MSG_CHECKING(for fdatasync)
Matthias Klosec511b472010-05-08 11:01:39 +00002966AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[void *x=fdatasync]])],
2967 [AC_DEFINE(HAVE_FDATASYNC, 1, Define if you have the 'fdatasync' function.)
2968 AC_MSG_RESULT(yes)],
2969 [AC_MSG_RESULT(no)
2970])
Christian Heimes0e9ab5f2008-03-21 23:49:44 +00002971AC_MSG_CHECKING(for epoll)
Matthias Klosec511b472010-05-08 11:01:39 +00002972AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/epoll.h>]], [[void *x=epoll_create]])],
2973 [AC_DEFINE(HAVE_EPOLL, 1, Define if you have the 'epoll' functions.)
2974 AC_MSG_RESULT(yes)],
2975 [AC_MSG_RESULT(no)
2976])
Christian Heimes0e9ab5f2008-03-21 23:49:44 +00002977AC_MSG_CHECKING(for kqueue)
Matthias Klosec511b472010-05-08 11:01:39 +00002978AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Christian Heimes0e9ab5f2008-03-21 23:49:44 +00002979#include <sys/types.h>
2980#include <sys/event.h>
Matthias Klosec511b472010-05-08 11:01:39 +00002981 ]], [[int x=kqueue()]])],
2982 [AC_DEFINE(HAVE_KQUEUE, 1, Define if you have the 'kqueue' functions.)
2983 AC_MSG_RESULT(yes)],
2984 [AC_MSG_RESULT(no)
2985])
Martin v. Löwisd5843682002-11-21 20:41:28 +00002986# On some systems (eg. FreeBSD 5), we would find a definition of the
2987# functions ctermid_r, setgroups in the library, but no prototype
2988# (e.g. because we use _XOPEN_SOURCE). See whether we can take their
2989# address to avoid compiler warnings and potential miscompilations
2990# because of the missing prototypes.
2991
2992AC_MSG_CHECKING(for ctermid_r)
Matthias Klosec511b472010-05-08 11:01:39 +00002993AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwisd5843682002-11-21 20:41:28 +00002994#include <stdio.h>
Matthias Klosec511b472010-05-08 11:01:39 +00002995]], [[void* p = ctermid_r]])],
2996 [AC_DEFINE(HAVE_CTERMID_R, 1, Define if you have the 'ctermid_r' function.)
2997 AC_MSG_RESULT(yes)],
2998 [AC_MSG_RESULT(no)
2999])
Martin v. Löwisd5843682002-11-21 20:41:28 +00003000
Antoine Pitroub170f172010-09-10 18:47:36 +00003001AC_CACHE_CHECK([for flock declaration], [ac_cv_flock_decl],
3002 [AC_COMPILE_IFELSE(
3003 [AC_LANG_PROGRAM(
3004 [#include <sys/file.h>],
3005 [void* p = flock]
3006 )],
3007 [ac_cv_flock_decl=yes],
3008 [ac_cv_flock_decl=no]
3009 )
Matthias Klosec511b472010-05-08 11:01:39 +00003010])
Antoine Pitroub170f172010-09-10 18:47:36 +00003011if test "x${ac_cv_flock_decl}" = xyes; then
3012 AC_CHECK_FUNCS(flock,,
3013 AC_CHECK_LIB(bsd,flock,
3014 [AC_DEFINE(HAVE_FLOCK)
3015 AC_DEFINE(FLOCK_NEEDS_LIBBSD, 1, Define if flock needs to be linked with bsd library.)
3016 ])
3017 )
Antoine Pitrou85729812010-09-07 14:55:24 +00003018fi
Martin v. Löwisf26d63b2003-03-30 17:23:49 +00003019
3020AC_MSG_CHECKING(for getpagesize)
Matthias Klosec511b472010-05-08 11:01:39 +00003021AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwisf26d63b2003-03-30 17:23:49 +00003022#include <unistd.h>
Matthias Klosec511b472010-05-08 11:01:39 +00003023]], [[void* p = getpagesize]])],
3024 [AC_DEFINE(HAVE_GETPAGESIZE, 1, Define if you have the 'getpagesize' function.)
3025 AC_MSG_RESULT(yes)],
3026 [AC_MSG_RESULT(no)
3027])
Martin v. Löwisf26d63b2003-03-30 17:23:49 +00003028
Charles-François Natali93a11752011-11-27 13:01:35 +01003029AC_MSG_CHECKING(for broken unsetenv)
3030AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3031#include <stdlib.h>
3032]], [[int res = unsetenv("DUMMY")]])],
3033 [AC_MSG_RESULT(no)],
3034 [AC_DEFINE(HAVE_BROKEN_UNSETENV, 1, Define if `unsetenv` does not return an int.)
3035 AC_MSG_RESULT(yes)
3036])
3037
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00003038dnl check for true
3039AC_CHECK_PROGS(TRUE, true, /bin/true)
3040
Martin v. Löwis95c419b2003-05-03 12:10:48 +00003041dnl On some systems (e.g. Solaris 9), hstrerror and inet_aton are in -lresolv
3042dnl On others, they are in the C library, so we to take no action
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00003043AC_CHECK_LIB(c, inet_aton, [$ac_cv_prog_TRUE],
Martin v. Löwis95c419b2003-05-03 12:10:48 +00003044 AC_CHECK_LIB(resolv, inet_aton)
3045)
3046
Martin v. Löwisa51d5c82007-12-04 08:37:59 +00003047# On Tru64, chflags seems to be present, but calling it will
3048# exit Python
Gregory P. Smithbb213892009-11-02 01:37:37 +00003049AC_CACHE_CHECK([for chflags], [ac_cv_have_chflags], [dnl
Ned Deily43e10542011-06-27 23:41:53 -07003050AC_RUN_IFELSE([AC_LANG_SOURCE([[
Martin v. Löwisa51d5c82007-12-04 08:37:59 +00003051#include <sys/stat.h>
3052#include <unistd.h>
3053int main(int argc, char*argv[])
3054{
3055 if(chflags(argv[0], 0) != 0)
3056 return 1;
3057 return 0;
3058}
Ned Deily43e10542011-06-27 23:41:53 -07003059]])],
Matthias Klosec511b472010-05-08 11:01:39 +00003060[ac_cv_have_chflags=yes],
3061[ac_cv_have_chflags=no],
3062[ac_cv_have_chflags=cross])
Gregory P. Smithbb213892009-11-02 01:37:37 +00003063])
3064if test "$ac_cv_have_chflags" = cross ; then
3065 AC_CHECK_FUNC([chflags], [ac_cv_have_chflags="yes"], [ac_cv_have_chflags="no"])
3066fi
3067if test "$ac_cv_have_chflags" = yes ; then
Ned Deily43e10542011-06-27 23:41:53 -07003068 AC_DEFINE(HAVE_CHFLAGS, 1, [Define to 1 if you have the 'chflags' function.])
Alexandre Vassalotti00900892009-07-17 05:26:39 +00003069fi
Martin v. Löwisa51d5c82007-12-04 08:37:59 +00003070
Gregory P. Smithbb213892009-11-02 01:37:37 +00003071AC_CACHE_CHECK([for lchflags], [ac_cv_have_lchflags], [dnl
Ned Deily43e10542011-06-27 23:41:53 -07003072AC_RUN_IFELSE([AC_LANG_SOURCE([[
Martin v. Löwisa51d5c82007-12-04 08:37:59 +00003073#include <sys/stat.h>
3074#include <unistd.h>
3075int main(int argc, char*argv[])
3076{
3077 if(lchflags(argv[0], 0) != 0)
3078 return 1;
3079 return 0;
3080}
Ned Deily43e10542011-06-27 23:41:53 -07003081]])],[ac_cv_have_lchflags=yes],[ac_cv_have_lchflags=no],[ac_cv_have_lchflags=cross])
Gregory P. Smithbb213892009-11-02 01:37:37 +00003082])
3083if test "$ac_cv_have_lchflags" = cross ; then
3084 AC_CHECK_FUNC([lchflags], [ac_cv_have_lchflags="yes"], [ac_cv_have_lchflags="no"])
3085fi
3086if test "$ac_cv_have_lchflags" = yes ; then
Ned Deily43e10542011-06-27 23:41:53 -07003087 AC_DEFINE(HAVE_LCHFLAGS, 1, [Define to 1 if you have the 'lchflags' function.])
Alexandre Vassalotti00900892009-07-17 05:26:39 +00003088fi
Martin v. Löwisa51d5c82007-12-04 08:37:59 +00003089
Neal Norwitz6e73aaa2006-06-12 03:33:09 +00003090dnl Check if system zlib has *Copy() functions
Ronald Oussorenf8752642006-07-06 10:13:35 +00003091dnl
3092dnl On MacOSX the linker will search for dylibs on the entire linker path
3093dnl before searching for static libraries. setup.py adds -Wl,-search_paths_first
3094dnl to revert to a more traditional unix behaviour and make it possible to
3095dnl override the system libz with a local static library of libz. Temporarily
3096dnl add that flag to our CFLAGS as well to ensure that we check the version
3097dnl of libz that will be used by setup.py.
3098dnl The -L/usr/local/lib is needed as wel to get the same compilation
3099dnl environment as setup.py (and leaving it out can cause configure to use the
3100dnl wrong version of the library)
3101case $ac_sys_system/$ac_sys_release in
3102Darwin/*)
3103 _CUR_CFLAGS="${CFLAGS}"
3104 _CUR_LDFLAGS="${LDFLAGS}"
3105 CFLAGS="${CFLAGS} -Wl,-search_paths_first"
3106 LDFLAGS="${LDFLAGS} -Wl,-search_paths_first -L/usr/local/lib"
3107 ;;
3108esac
3109
Matthias Klose5183ebd2010-04-24 16:38:36 +00003110AC_CHECK_LIB(z, inflateCopy, AC_DEFINE(HAVE_ZLIB_COPY, 1, [Define if the zlib library has inflateCopy]))
Neal Norwitz6e73aaa2006-06-12 03:33:09 +00003111
Ronald Oussorenf8752642006-07-06 10:13:35 +00003112case $ac_sys_system/$ac_sys_release in
3113Darwin/*)
3114 CFLAGS="${_CUR_CFLAGS}"
3115 LDFLAGS="${_CUR_LDFLAGS}"
3116 ;;
3117esac
3118
Martin v. Löwise9416172003-05-03 10:12:45 +00003119AC_MSG_CHECKING(for hstrerror)
Matthias Klosec511b472010-05-08 11:01:39 +00003120AC_LINK_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwise9416172003-05-03 10:12:45 +00003121#include <netdb.h>
Matthias Klosec511b472010-05-08 11:01:39 +00003122]], [[void* p = hstrerror; hstrerror(0)]])],
3123 [AC_DEFINE(HAVE_HSTRERROR, 1, Define if you have the 'hstrerror' function.)
3124 AC_MSG_RESULT(yes)],
3125 [AC_MSG_RESULT(no)
3126])
Martin v. Löwise9416172003-05-03 10:12:45 +00003127
3128AC_MSG_CHECKING(for inet_aton)
Matthias Klosec511b472010-05-08 11:01:39 +00003129AC_LINK_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwis86d66262006-02-17 08:40:11 +00003130#include <sys/types.h>
Martin v. Löwise9416172003-05-03 10:12:45 +00003131#include <sys/socket.h>
3132#include <netinet/in.h>
3133#include <arpa/inet.h>
Matthias Klosec511b472010-05-08 11:01:39 +00003134]], [[void* p = inet_aton;inet_aton(0,0)]])],
3135 [AC_DEFINE(HAVE_INET_ATON, 1, Define if you have the 'inet_aton' function.)
3136 AC_MSG_RESULT(yes)],
3137 [AC_MSG_RESULT(no)
3138])
Martin v. Löwise9416172003-05-03 10:12:45 +00003139
3140AC_MSG_CHECKING(for inet_pton)
Matthias Klosec511b472010-05-08 11:01:39 +00003141AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwisf2e488d2003-05-05 22:00:11 +00003142#include <sys/types.h>
Martin v. Löwise9416172003-05-03 10:12:45 +00003143#include <sys/socket.h>
3144#include <netinet/in.h>
3145#include <arpa/inet.h>
Matthias Klosec511b472010-05-08 11:01:39 +00003146]], [[void* p = inet_pton]])],
3147 [AC_DEFINE(HAVE_INET_PTON, 1, Define if you have the 'inet_pton' function.)
3148 AC_MSG_RESULT(yes)],
3149 [AC_MSG_RESULT(no)
3150])
Martin v. Löwise9416172003-05-03 10:12:45 +00003151
Martin v. Löwisd6640d42003-07-06 09:29:52 +00003152# On some systems, setgroups is in unistd.h, on others, in grp.h
Martin v. Löwisd5843682002-11-21 20:41:28 +00003153AC_MSG_CHECKING(for setgroups)
Matthias Klosec511b472010-05-08 11:01:39 +00003154AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwisf2e488d2003-05-05 22:00:11 +00003155#include <unistd.h>
Martin v. Löwisd6640d42003-07-06 09:29:52 +00003156#ifdef HAVE_GRP_H
3157#include <grp.h>
3158#endif
Matthias Klosec511b472010-05-08 11:01:39 +00003159]], [[void* p = setgroups]])],
3160 [AC_DEFINE(HAVE_SETGROUPS, 1, Define if you have the 'setgroups' function.)
3161 AC_MSG_RESULT(yes)],
3162 [AC_MSG_RESULT(no)
3163])
Martin v. Löwisd5843682002-11-21 20:41:28 +00003164
Fred Drake8cef4cf2000-06-28 16:40:38 +00003165# check for openpty and forkpty
3166
Martin v. Löwisfd9a72a2006-01-08 10:07:33 +00003167AC_CHECK_FUNCS(openpty,,
3168 AC_CHECK_LIB(util,openpty,
3169 [AC_DEFINE(HAVE_OPENPTY) LIBS="$LIBS -lutil"],
3170 AC_CHECK_LIB(bsd,openpty, [AC_DEFINE(HAVE_OPENPTY) LIBS="$LIBS -lbsd"])
3171 )
3172)
3173AC_CHECK_FUNCS(forkpty,,
3174 AC_CHECK_LIB(util,forkpty,
3175 [AC_DEFINE(HAVE_FORKPTY) LIBS="$LIBS -lutil"],
3176 AC_CHECK_LIB(bsd,forkpty, [AC_DEFINE(HAVE_FORKPTY) LIBS="$LIBS -lbsd"])
3177 )
3178)
Fred Drake8cef4cf2000-06-28 16:40:38 +00003179
Brett Cannonaa5778d2008-03-18 04:09:00 +00003180# Stuff for expat.
3181AC_CHECK_FUNCS(memmove)
3182
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00003183# check for long file support functions
3184AC_CHECK_FUNCS(fseek64 fseeko fstatvfs ftell64 ftello statvfs)
3185
Brett Cannonaa5778d2008-03-18 04:09:00 +00003186AC_REPLACE_FUNCS(dup2 getcwd strdup)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003187AC_CHECK_FUNCS(getpgrp,
Matthias Klosec511b472010-05-08 11:01:39 +00003188 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[getpgrp(0);]])],
3189 [AC_DEFINE(GETPGRP_HAVE_ARG, 1, [Define if getpgrp() must be called as getpgrp(0).])],
3190 [])
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003191)
Jack Jansen150753c2003-03-29 22:07:47 +00003192AC_CHECK_FUNCS(setpgrp,
Matthias Klosec511b472010-05-08 11:01:39 +00003193 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[setpgrp(0,0);]])],
3194 [AC_DEFINE(SETPGRP_HAVE_ARG, 1, [Define if setpgrp() must be called as setpgrp(0, 0).])],
3195 [])
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003196)
3197AC_CHECK_FUNCS(gettimeofday,
Matthias Klosec511b472010-05-08 11:01:39 +00003198 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/time.h>]],
3199 [[gettimeofday((struct timeval*)0,(struct timezone*)0);]])],
3200 [],
3201 [AC_DEFINE(GETTIMEOFDAY_NO_TZ, 1,
3202 [Define if gettimeofday() does not have second (timezone) argument
3203 This is the case on Motorola V4 (R40V4.2)])
3204 ])
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003205)
Guido van Rossum627b2d71993-12-24 10:39:16 +00003206
Martin v. Löwisdbe3f762002-10-10 14:27:30 +00003207AC_MSG_CHECKING(for major, minor, and makedev)
Matthias Klosec511b472010-05-08 11:01:39 +00003208AC_LINK_IFELSE([AC_LANG_PROGRAM([[
Neal Norwitz6eb37f02003-02-23 23:28:15 +00003209#if defined(MAJOR_IN_MKDEV)
3210#include <sys/mkdev.h>
3211#elif defined(MAJOR_IN_SYSMACROS)
3212#include <sys/sysmacros.h>
3213#else
3214#include <sys/types.h>
3215#endif
Matthias Klosec511b472010-05-08 11:01:39 +00003216]], [[
Martin v. Löwisdbe3f762002-10-10 14:27:30 +00003217 makedev(major(0),minor(0));
Matthias Klosec511b472010-05-08 11:01:39 +00003218]])],[
Martin v. Löwisdbe3f762002-10-10 14:27:30 +00003219 AC_DEFINE(HAVE_DEVICE_MACROS, 1,
3220 [Define to 1 if you have the device macros.])
3221 AC_MSG_RESULT(yes)
3222],[
3223 AC_MSG_RESULT(no)
3224])
Martin v. Löwis861a65b2001-10-24 14:36:00 +00003225
3226# On OSF/1 V5.1, getaddrinfo is available, but a define
3227# for [no]getaddrinfo in netdb.h.
3228AC_MSG_CHECKING(for getaddrinfo)
Matthias Klosec511b472010-05-08 11:01:39 +00003229AC_LINK_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwisc010b6d2001-11-09 17:50:52 +00003230#include <sys/types.h>
Martin v. Löwis861a65b2001-10-24 14:36:00 +00003231#include <sys/socket.h>
3232#include <netdb.h>
Martin v. Löwisc010b6d2001-11-09 17:50:52 +00003233#include <stdio.h>
Matthias Klosec511b472010-05-08 11:01:39 +00003234]], [[getaddrinfo(NULL, NULL, NULL, NULL);]])],
3235[have_getaddrinfo=yes],
3236[have_getaddrinfo=no])
Alexandre Vassalotti00900892009-07-17 05:26:39 +00003237AC_MSG_RESULT($have_getaddrinfo)
3238if test $have_getaddrinfo = yes
3239then
3240 AC_MSG_CHECKING(getaddrinfo bug)
3241 AC_CACHE_VAL(ac_cv_buggy_getaddrinfo,
Matthias Klosec511b472010-05-08 11:01:39 +00003242 AC_RUN_IFELSE([AC_LANG_SOURCE([[[
Stefan Krah0afe4e42012-11-22 23:56:51 +01003243#include <stdio.h>
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003244#include <sys/types.h>
3245#include <netdb.h>
3246#include <string.h>
3247#include <sys/socket.h>
3248#include <netinet/in.h>
3249
Alexandre Vassalotti00900892009-07-17 05:26:39 +00003250int main()
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003251{
3252 int passive, gaierr, inet4 = 0, inet6 = 0;
3253 struct addrinfo hints, *ai, *aitop;
3254 char straddr[INET6_ADDRSTRLEN], strport[16];
3255
3256 for (passive = 0; passive <= 1; passive++) {
3257 memset(&hints, 0, sizeof(hints));
3258 hints.ai_family = AF_UNSPEC;
3259 hints.ai_flags = passive ? AI_PASSIVE : 0;
3260 hints.ai_socktype = SOCK_STREAM;
Hye-Shik Chang54f94392004-04-14 07:55:31 +00003261 hints.ai_protocol = IPPROTO_TCP;
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003262 if ((gaierr = getaddrinfo(NULL, "54321", &hints, &aitop)) != 0) {
3263 (void)gai_strerror(gaierr);
3264 goto bad;
3265 }
3266 for (ai = aitop; ai; ai = ai->ai_next) {
3267 if (ai->ai_addr == NULL ||
3268 ai->ai_addrlen == 0 ||
3269 getnameinfo(ai->ai_addr, ai->ai_addrlen,
3270 straddr, sizeof(straddr), strport, sizeof(strport),
3271 NI_NUMERICHOST|NI_NUMERICSERV) != 0) {
3272 goto bad;
3273 }
3274 switch (ai->ai_family) {
3275 case AF_INET:
3276 if (strcmp(strport, "54321") != 0) {
3277 goto bad;
3278 }
3279 if (passive) {
3280 if (strcmp(straddr, "0.0.0.0") != 0) {
3281 goto bad;
3282 }
3283 } else {
3284 if (strcmp(straddr, "127.0.0.1") != 0) {
3285 goto bad;
3286 }
3287 }
3288 inet4++;
3289 break;
3290 case AF_INET6:
3291 if (strcmp(strport, "54321") != 0) {
3292 goto bad;
3293 }
3294 if (passive) {
3295 if (strcmp(straddr, "::") != 0) {
3296 goto bad;
3297 }
3298 } else {
3299 if (strcmp(straddr, "::1") != 0) {
3300 goto bad;
3301 }
3302 }
3303 inet6++;
3304 break;
3305 case AF_UNSPEC:
3306 goto bad;
3307 break;
3308 default:
3309 /* another family support? */
3310 break;
3311 }
3312 }
3313 }
3314
3315 if (!(inet4 == 0 || inet4 == 2))
3316 goto bad;
3317 if (!(inet6 == 0 || inet6 == 2))
3318 goto bad;
3319
3320 if (aitop)
3321 freeaddrinfo(aitop);
Alexandre Vassalotti00900892009-07-17 05:26:39 +00003322 return 0;
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003323
3324 bad:
3325 if (aitop)
3326 freeaddrinfo(aitop);
Alexandre Vassalotti00900892009-07-17 05:26:39 +00003327 return 1;
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003328}
Matthias Klosec511b472010-05-08 11:01:39 +00003329]]])],
3330[ac_cv_buggy_getaddrinfo=no],
3331[ac_cv_buggy_getaddrinfo=yes],
doko@python.orgd65e2ba2013-01-31 23:52:03 +01003332[
3333if test "${enable_ipv6+set}" = set; then
3334 ac_cv_buggy_getaddrinfo="no -- configured with --(en|dis)able-ipv6"
3335else
3336 ac_cv_buggy_getaddrinfo=yes
3337fi]))
Alexandre Vassalotti00900892009-07-17 05:26:39 +00003338fi
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003339
Benjamin Peterson75fed812010-11-01 01:47:19 +00003340AC_MSG_RESULT($ac_cv_buggy_getaddrinfo)
3341
Mark Dickinson0ef0b912009-12-31 21:11:48 +00003342if test $have_getaddrinfo = no -o "$ac_cv_buggy_getaddrinfo" = yes
Alexandre Vassalotti00900892009-07-17 05:26:39 +00003343then
3344 if test $ipv6 = yes
3345 then
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003346 echo 'Fatal: You must get working getaddrinfo() function.'
3347 echo ' or you can specify "--disable-ipv6"'.
3348 exit 1
3349 fi
Martin v. Löwis861a65b2001-10-24 14:36:00 +00003350else
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003351 AC_DEFINE(HAVE_GETADDRINFO, 1, [Define if you have the getaddrinfo function.])
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003352fi
Benjamin Peterson75fed812010-11-01 01:47:19 +00003353
Thomas Woutersb0db85a2001-08-08 10:39:03 +00003354AC_CHECK_FUNCS(getnameinfo)
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003355
Guido van Rossum627b2d71993-12-24 10:39:16 +00003356# checks for structures
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003357AC_HEADER_TIME
Guido van Rossum627b2d71993-12-24 10:39:16 +00003358AC_STRUCT_TM
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003359AC_STRUCT_TIMEZONE
Martin v. Löwis60a5d722002-10-16 20:28:25 +00003360AC_CHECK_MEMBERS([struct stat.st_rdev])
3361AC_CHECK_MEMBERS([struct stat.st_blksize])
Hye-Shik Chang5f937a72005-06-02 13:09:30 +00003362AC_CHECK_MEMBERS([struct stat.st_flags])
Martin v. Löwisebd9d5b2005-08-09 15:00:59 +00003363AC_CHECK_MEMBERS([struct stat.st_gen])
3364AC_CHECK_MEMBERS([struct stat.st_birthtime])
Guido van Rossum98bf58f2001-10-18 20:34:25 +00003365AC_STRUCT_ST_BLOCKS
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003366
3367AC_MSG_CHECKING(for time.h that defines altzone)
Matthias Klosec511b472010-05-08 11:01:39 +00003368AC_CACHE_VAL(ac_cv_header_time_altzone,[
3369 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <time.h>]], [[return altzone;]])],
3370 [ac_cv_header_time_altzone=yes],
3371 [ac_cv_header_time_altzone=no])
3372 ])
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003373AC_MSG_RESULT($ac_cv_header_time_altzone)
3374if test $ac_cv_header_time_altzone = yes; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003375 AC_DEFINE(HAVE_ALTZONE, 1, [Define this if your time.h defines altzone.])
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003376fi
3377
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003378was_it_defined=no
3379AC_MSG_CHECKING(whether sys/select.h and sys/time.h may both be included)
Matthias Klosec511b472010-05-08 11:01:39 +00003380AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003381#include <sys/types.h>
3382#include <sys/select.h>
3383#include <sys/time.h>
Matthias Klosec511b472010-05-08 11:01:39 +00003384]], [[;]])],[
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003385 AC_DEFINE(SYS_SELECT_WITH_SYS_TIME, 1,
3386 [Define if you can safely include both <sys/select.h> and <sys/time.h>
3387 (which you can't on SCO ODT 3.0).])
3388 was_it_defined=yes
Matthias Klosec511b472010-05-08 11:01:39 +00003389],[])
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003390AC_MSG_RESULT($was_it_defined)
Guido van Rossum627b2d71993-12-24 10:39:16 +00003391
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003392AC_MSG_CHECKING(for addrinfo)
3393AC_CACHE_VAL(ac_cv_struct_addrinfo,
Matthias Klosec511b472010-05-08 11:01:39 +00003394AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <netdb.h>]], [[struct addrinfo a]])],
3395 [ac_cv_struct_addrinfo=yes],
3396 [ac_cv_struct_addrinfo=no]))
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003397AC_MSG_RESULT($ac_cv_struct_addrinfo)
3398if test $ac_cv_struct_addrinfo = yes; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003399 AC_DEFINE(HAVE_ADDRINFO, 1, [struct addrinfo (netdb.h)])
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003400fi
3401
3402AC_MSG_CHECKING(for sockaddr_storage)
3403AC_CACHE_VAL(ac_cv_struct_sockaddr_storage,
Matthias Klosec511b472010-05-08 11:01:39 +00003404AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003405# include <sys/types.h>
Matthias Klosec511b472010-05-08 11:01:39 +00003406# include <sys/socket.h>]], [[struct sockaddr_storage s]])],
3407 [ac_cv_struct_sockaddr_storage=yes],
3408 [ac_cv_struct_sockaddr_storage=no]))
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003409AC_MSG_RESULT($ac_cv_struct_sockaddr_storage)
3410if test $ac_cv_struct_sockaddr_storage = yes; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003411 AC_DEFINE(HAVE_SOCKADDR_STORAGE, 1, [struct sockaddr_storage (sys/socket.h)])
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003412fi
3413
Guido van Rossum627b2d71993-12-24 10:39:16 +00003414# checks for compiler characteristics
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003415
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003416AC_C_CHAR_UNSIGNED
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003417AC_C_CONST
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003418
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003419works=no
3420AC_MSG_CHECKING(for working volatile)
Matthias Klosec511b472010-05-08 11:01:39 +00003421AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[volatile int x; x = 0;]])],
3422 [works=yes],
3423 [AC_DEFINE(volatile, , [Define to empty if the keyword does not work.])]
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003424)
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003425AC_MSG_RESULT($works)
Guido van Rossumdabb11b1994-10-11 15:04:27 +00003426
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003427works=no
3428AC_MSG_CHECKING(for working signed char)
Matthias Klosec511b472010-05-08 11:01:39 +00003429AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[signed char c;]])],
3430 [works=yes],
3431 [AC_DEFINE(signed, , [Define to empty if the keyword does not work.])]
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003432)
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003433AC_MSG_RESULT($works)
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003434
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003435have_prototypes=no
3436AC_MSG_CHECKING(for prototypes)
Matthias Klosec511b472010-05-08 11:01:39 +00003437AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[int foo(int x) { return 0; }]], [[return foo(10);]])],
3438 [AC_DEFINE(HAVE_PROTOTYPES, 1,
3439 [Define if your compiler supports function prototype])
3440 have_prototypes=yes],
3441 []
3442)
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003443AC_MSG_RESULT($have_prototypes)
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003444
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003445works=no
3446AC_MSG_CHECKING(for variable length prototypes and stdarg.h)
Matthias Klosec511b472010-05-08 11:01:39 +00003447AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003448#include <stdarg.h>
Guido van Rossum3f13e481996-08-30 20:58:11 +00003449int foo(int x, ...) {
3450 va_list va;
3451 va_start(va, x);
3452 va_arg(va, int);
3453 va_arg(va, char *);
3454 va_arg(va, double);
3455 return 0;
3456}
Matthias Klosec511b472010-05-08 11:01:39 +00003457]], [[return foo(10, "", 3.14);]])],[
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003458 AC_DEFINE(HAVE_STDARG_PROTOTYPES, 1,
3459 [Define if your compiler supports variable length function prototypes
3460 (e.g. void fprintf(FILE *, char *, ...);) *and* <stdarg.h>])
3461 works=yes
Matthias Klosec511b472010-05-08 11:01:39 +00003462],[])
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003463AC_MSG_RESULT($works)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003464
Dave Cole331708b2004-08-09 04:51:41 +00003465# check for socketpair
3466AC_MSG_CHECKING(for socketpair)
Matthias Klosec511b472010-05-08 11:01:39 +00003467AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Dave Cole331708b2004-08-09 04:51:41 +00003468#include <sys/types.h>
3469#include <sys/socket.h>
Matthias Klosec511b472010-05-08 11:01:39 +00003470]], [[void *x=socketpair]])],
3471 [AC_DEFINE(HAVE_SOCKETPAIR, 1, [Define if you have the 'socketpair' function.])
3472 AC_MSG_RESULT(yes)],
3473 [AC_MSG_RESULT(no)]
Dave Cole331708b2004-08-09 04:51:41 +00003474)
3475
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003476# check if sockaddr has sa_len member
3477AC_MSG_CHECKING(if sockaddr has sa_len member)
Matthias Klosec511b472010-05-08 11:01:39 +00003478AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
3479#include <sys/socket.h>]], [[struct sockaddr x;
3480x.sa_len = 0;]])],
3481 [AC_MSG_RESULT(yes)
3482 AC_DEFINE(HAVE_SOCKADDR_SA_LEN, 1, [Define if sockaddr has sa_len member])],
3483 [AC_MSG_RESULT(no)]
3484)
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003485
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003486va_list_is_array=no
3487AC_MSG_CHECKING(whether va_list is an array)
Matthias Klosec511b472010-05-08 11:01:39 +00003488AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003489#ifdef HAVE_STDARG_PROTOTYPES
3490#include <stdarg.h>
3491#else
3492#include <varargs.h>
3493#endif
Matthias Klosec511b472010-05-08 11:01:39 +00003494]], [[va_list list1, list2; list1 = list2;]])],[],[
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003495 AC_DEFINE(VA_LIST_IS_ARRAY, 1, [Define if a va_list is an array of some kind])
3496 va_list_is_array=yes
3497])
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003498AC_MSG_RESULT($va_list_is_array)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003499
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003500# sigh -- gethostbyname_r is a mess; it can have 3, 5 or 6 arguments :-(
Martin v. Löwis11437992002-04-12 09:54:03 +00003501AH_TEMPLATE(HAVE_GETHOSTBYNAME_R,
3502 [Define this if you have some version of gethostbyname_r()])
3503
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003504AC_CHECK_FUNC(gethostbyname_r, [
3505 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
3506 AC_MSG_CHECKING([gethostbyname_r with 6 args])
3507 OLD_CFLAGS=$CFLAGS
3508 CFLAGS="$CFLAGS $MY_CPPFLAGS $MY_THREAD_CPPFLAGS $MY_CFLAGS"
Matthias Klosec511b472010-05-08 11:01:39 +00003509 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003510# include <netdb.h>
Matthias Klosec511b472010-05-08 11:01:39 +00003511 ]], [[
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003512 char *name;
3513 struct hostent *he, *res;
3514 char buffer[2048];
3515 int buflen = 2048;
3516 int h_errnop;
3517
3518 (void) gethostbyname_r(name, he, buffer, buflen, &res, &h_errnop)
Matthias Klosec511b472010-05-08 11:01:39 +00003519 ]])],[
Guido van Rossum8db7d8b1999-03-23 16:40:33 +00003520 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003521 AC_DEFINE(HAVE_GETHOSTBYNAME_R_6_ARG, 1,
3522 [Define this if you have the 6-arg version of gethostbyname_r().])
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003523 AC_MSG_RESULT(yes)
Matthias Klosec511b472010-05-08 11:01:39 +00003524 ],[
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003525 AC_MSG_RESULT(no)
3526 AC_MSG_CHECKING([gethostbyname_r with 5 args])
Matthias Klosec511b472010-05-08 11:01:39 +00003527 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003528# include <netdb.h>
Matthias Klosec511b472010-05-08 11:01:39 +00003529 ]], [[
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003530 char *name;
3531 struct hostent *he;
Matthias Klosec511b472010-05-08 11:01:39 +00003532 char buffer[2048];
3533 int buflen = 2048;
3534 int h_errnop;
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003535
Matthias Klosec511b472010-05-08 11:01:39 +00003536 (void) gethostbyname_r(name, he, buffer, buflen, &h_errnop)
3537 ]])],
3538 [
Guido van Rossum8db7d8b1999-03-23 16:40:33 +00003539 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
Matthias Klosec511b472010-05-08 11:01:39 +00003540 AC_DEFINE(HAVE_GETHOSTBYNAME_R_5_ARG, 1,
3541 [Define this if you have the 5-arg version of gethostbyname_r().])
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003542 AC_MSG_RESULT(yes)
3543 ], [
3544 AC_MSG_RESULT(no)
Matthias Klosec511b472010-05-08 11:01:39 +00003545 AC_MSG_CHECKING([gethostbyname_r with 3 args])
3546 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3547# include <netdb.h>
3548 ]], [[
3549 char *name;
3550 struct hostent *he;
3551 struct hostent_data data;
3552
3553 (void) gethostbyname_r(name, he, &data);
3554 ]])],
3555 [
3556 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
3557 AC_DEFINE(HAVE_GETHOSTBYNAME_R_3_ARG, 1,
3558 [Define this if you have the 3-arg version of gethostbyname_r().])
3559 AC_MSG_RESULT(yes)
3560 ], [
3561 AC_MSG_RESULT(no)
3562 ])
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003563 ])
3564 ])
3565 CFLAGS=$OLD_CFLAGS
3566], [
Thomas Wouters3a584202000-08-05 23:28:51 +00003567 AC_CHECK_FUNCS(gethostbyname)
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003568])
3569AC_SUBST(HAVE_GETHOSTBYNAME_R_6_ARG)
3570AC_SUBST(HAVE_GETHOSTBYNAME_R_5_ARG)
3571AC_SUBST(HAVE_GETHOSTBYNAME_R_3_ARG)
Guido van Rossum8db7d8b1999-03-23 16:40:33 +00003572AC_SUBST(HAVE_GETHOSTBYNAME_R)
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003573AC_SUBST(HAVE_GETHOSTBYNAME)
3574
Guido van Rossum627b2d71993-12-24 10:39:16 +00003575# checks for system services
3576# (none yet)
3577
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003578# Linux requires this for correct f.p. operations
Jeremy Hyltonbe28f5b2000-07-27 21:03:04 +00003579AC_CHECK_FUNC(__fpu_control,
3580 [],
3581 [AC_CHECK_LIB(ieee, __fpu_control)
3582])
Guido van Rossum627b2d71993-12-24 10:39:16 +00003583
Guido van Rossum93274221997-05-09 02:42:00 +00003584# Check for --with-fpectl
Guido van Rossum93274221997-05-09 02:42:00 +00003585AC_MSG_CHECKING(for --with-fpectl)
Barry Warsawc0d24d82000-06-29 16:12:00 +00003586AC_ARG_WITH(fpectl,
Matthias Klose22520ea2010-05-08 10:14:46 +00003587 AS_HELP_STRING([--with-fpectl], [enable SIGFPE catching]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003588[
Guido van Rossum93274221997-05-09 02:42:00 +00003589if test "$withval" != no
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003590then
3591 AC_DEFINE(WANT_SIGFPE_HANDLER, 1,
3592 [Define if you want SIGFPE handled (see Include/pyfpe.h).])
3593 AC_MSG_RESULT(yes)
Guido van Rossum93274221997-05-09 02:42:00 +00003594else AC_MSG_RESULT(no)
Guido van Rossumef2255b2000-03-10 22:30:29 +00003595fi],
3596[AC_MSG_RESULT(no)])
Guido van Rossum93274221997-05-09 02:42:00 +00003597
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003598# check for --with-libm=...
3599AC_SUBST(LIBM)
Guido van Rossum4b6b5791996-09-09 20:09:34 +00003600case $ac_sys_system in
Guido van Rossum3dc0a512000-10-05 18:00:06 +00003601Darwin) ;;
Guido van Rossumec95c7b1998-08-04 17:59:56 +00003602BeOS) ;;
Guido van Rossum4b6b5791996-09-09 20:09:34 +00003603*) LIBM=-lm
3604esac
Guido van Rossum93274221997-05-09 02:42:00 +00003605AC_MSG_CHECKING(for --with-libm=STRING)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003606AC_ARG_WITH(libm,
Matthias Klose22520ea2010-05-08 10:14:46 +00003607 AS_HELP_STRING([--with-libm=STRING], [math library]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003608[
Guido van Rossum93274221997-05-09 02:42:00 +00003609if test "$withval" = no
3610then LIBM=
3611 AC_MSG_RESULT(force LIBM empty)
3612elif test "$withval" != yes
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003613then LIBM=$withval
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003614 AC_MSG_RESULT(set LIBM="$withval")
3615else AC_MSG_ERROR([proper usage is --with-libm=STRING])
Guido van Rossum93274221997-05-09 02:42:00 +00003616fi],
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003617[AC_MSG_RESULT(default LIBM="$LIBM")])
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003618
3619# check for --with-libc=...
3620AC_SUBST(LIBC)
Guido van Rossum93274221997-05-09 02:42:00 +00003621AC_MSG_CHECKING(for --with-libc=STRING)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003622AC_ARG_WITH(libc,
Matthias Klose22520ea2010-05-08 10:14:46 +00003623 AS_HELP_STRING([--with-libc=STRING], [C library]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003624[
Guido van Rossum93274221997-05-09 02:42:00 +00003625if test "$withval" = no
3626then LIBC=
3627 AC_MSG_RESULT(force LIBC empty)
3628elif test "$withval" != yes
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003629then LIBC=$withval
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003630 AC_MSG_RESULT(set LIBC="$withval")
3631else AC_MSG_ERROR([proper usage is --with-libc=STRING])
Guido van Rossum93274221997-05-09 02:42:00 +00003632fi],
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003633[AC_MSG_RESULT(default LIBC="$LIBC")])
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003634
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003635# **************************************************
3636# * Check for various properties of floating point *
3637# **************************************************
Mark Dickinson265d7382008-04-21 22:32:24 +00003638
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003639AC_MSG_CHECKING(whether C doubles are little-endian IEEE 754 binary64)
3640AC_CACHE_VAL(ac_cv_little_endian_double, [
Matthias Klosec511b472010-05-08 11:01:39 +00003641AC_RUN_IFELSE([AC_LANG_SOURCE([[
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003642#include <string.h>
3643int main() {
3644 double x = 9006104071832581.0;
3645 if (memcmp(&x, "\x05\x04\x03\x02\x01\xff\x3f\x43", 8) == 0)
3646 return 0;
3647 else
3648 return 1;
3649}
Matthias Klosec511b472010-05-08 11:01:39 +00003650]])],
3651[ac_cv_little_endian_double=yes],
3652[ac_cv_little_endian_double=no],
3653[ac_cv_little_endian_double=no])])
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003654AC_MSG_RESULT($ac_cv_little_endian_double)
3655if test "$ac_cv_little_endian_double" = yes
3656then
3657 AC_DEFINE(DOUBLE_IS_LITTLE_ENDIAN_IEEE754, 1,
3658 [Define if C doubles are 64-bit IEEE 754 binary format, stored
3659 with the least significant byte first])
3660fi
3661
3662AC_MSG_CHECKING(whether C doubles are big-endian IEEE 754 binary64)
3663AC_CACHE_VAL(ac_cv_big_endian_double, [
Matthias Klosec511b472010-05-08 11:01:39 +00003664AC_RUN_IFELSE([AC_LANG_SOURCE([[
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003665#include <string.h>
3666int main() {
3667 double x = 9006104071832581.0;
3668 if (memcmp(&x, "\x43\x3f\xff\x01\x02\x03\x04\x05", 8) == 0)
3669 return 0;
3670 else
3671 return 1;
3672}
Matthias Klosec511b472010-05-08 11:01:39 +00003673]])],
3674[ac_cv_big_endian_double=yes],
3675[ac_cv_big_endian_double=no],
3676[ac_cv_big_endian_double=no])])
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003677AC_MSG_RESULT($ac_cv_big_endian_double)
3678if test "$ac_cv_big_endian_double" = yes
3679then
3680 AC_DEFINE(DOUBLE_IS_BIG_ENDIAN_IEEE754, 1,
3681 [Define if C doubles are 64-bit IEEE 754 binary format, stored
3682 with the most significant byte first])
3683fi
3684
3685# Some ARM platforms use a mixed-endian representation for doubles.
3686# While Python doesn't currently have full support for these platforms
3687# (see e.g., issue 1762561), we can at least make sure that float <-> string
3688# conversions work.
3689AC_MSG_CHECKING(whether C doubles are ARM mixed-endian IEEE 754 binary64)
3690AC_CACHE_VAL(ac_cv_mixed_endian_double, [
Matthias Klosec511b472010-05-08 11:01:39 +00003691AC_RUN_IFELSE([AC_LANG_SOURCE([[
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003692#include <string.h>
3693int main() {
3694 double x = 9006104071832581.0;
3695 if (memcmp(&x, "\x01\xff\x3f\x43\x05\x04\x03\x02", 8) == 0)
3696 return 0;
3697 else
3698 return 1;
3699}
Matthias Klosec511b472010-05-08 11:01:39 +00003700]])],
3701[ac_cv_mixed_endian_double=yes],
3702[ac_cv_mixed_endian_double=no],
3703[ac_cv_mixed_endian_double=no])])
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003704AC_MSG_RESULT($ac_cv_mixed_endian_double)
3705if test "$ac_cv_mixed_endian_double" = yes
3706then
3707 AC_DEFINE(DOUBLE_IS_ARM_MIXED_ENDIAN_IEEE754, 1,
3708 [Define if C doubles are 64-bit IEEE 754 binary format, stored
3709 in ARM mixed-endian order (byte order 45670123)])
3710fi
3711
3712# The short float repr introduced in Python 3.1 requires the
3713# correctly-rounded string <-> double conversion functions from
3714# Python/dtoa.c, which in turn require that the FPU uses 53-bit
3715# rounding; this is a problem on x86, where the x87 FPU has a default
Mark Dickinsona548dee2009-11-15 13:12:43 +00003716# rounding precision of 64 bits. For gcc/x86, we can fix this by
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003717# using inline assembler to get and set the x87 FPU control word.
Mark Dickinsona548dee2009-11-15 13:12:43 +00003718
3719# This inline assembler syntax may also work for suncc and icc,
3720# so we try it on all platforms.
3721
3722AC_MSG_CHECKING(whether we can use gcc inline assembler to get and set x87 control word)
Matthias Klosec511b472010-05-08 11:01:39 +00003723AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
Mark Dickinsona548dee2009-11-15 13:12:43 +00003724 unsigned short cw;
3725 __asm__ __volatile__ ("fnstcw %0" : "=m" (cw));
3726 __asm__ __volatile__ ("fldcw %0" : : "m" (cw));
Matthias Klosec511b472010-05-08 11:01:39 +00003727]])],[have_gcc_asm_for_x87=yes],[have_gcc_asm_for_x87=no])
Mark Dickinsona548dee2009-11-15 13:12:43 +00003728AC_MSG_RESULT($have_gcc_asm_for_x87)
3729if test "$have_gcc_asm_for_x87" = yes
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003730then
Mark Dickinsona548dee2009-11-15 13:12:43 +00003731 AC_DEFINE(HAVE_GCC_ASM_FOR_X87, 1,
3732 [Define if we can use gcc inline assembler to get and set x87 control word])
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003733fi
Mark Dickinson7a3d8642008-04-22 00:54:27 +00003734
Mark Dickinson04b27232009-01-04 12:29:36 +00003735# Detect whether system arithmetic is subject to x87-style double
3736# rounding issues. The result of this test has little meaning on non
3737# IEEE 754 platforms. On IEEE 754, test should return 1 if rounding
3738# mode is round-to-nearest and double rounding issues are present, and
3739# 0 otherwise. See http://bugs.python.org/issue2937 for more info.
3740AC_MSG_CHECKING(for x87-style double rounding)
Mark Dickinson99abd142009-10-24 13:44:16 +00003741# $BASECFLAGS may affect the result
3742ac_save_cc="$CC"
3743CC="$CC $BASECFLAGS"
Matthias Klosec511b472010-05-08 11:01:39 +00003744AC_RUN_IFELSE([AC_LANG_SOURCE([[
Mark Dickinson04b27232009-01-04 12:29:36 +00003745#include <stdlib.h>
3746#include <math.h>
3747int main() {
3748 volatile double x, y, z;
3749 /* 1./(1-2**-53) -> 1+2**-52 (correct), 1.0 (double rounding) */
3750 x = 0.99999999999999989; /* 1-2**-53 */
3751 y = 1./x;
3752 if (y != 1.)
3753 exit(0);
3754 /* 1e16+2.99999 -> 1e16+2. (correct), 1e16+4. (double rounding) */
3755 x = 1e16;
3756 y = 2.99999;
3757 z = x + y;
3758 if (z != 1e16+4.)
3759 exit(0);
3760 /* both tests show evidence of double rounding */
3761 exit(1);
3762}
Matthias Klosec511b472010-05-08 11:01:39 +00003763]])],
3764[ac_cv_x87_double_rounding=no],
3765[ac_cv_x87_double_rounding=yes],
3766[ac_cv_x87_double_rounding=no])
Mark Dickinson99abd142009-10-24 13:44:16 +00003767CC="$ac_save_cc"
Mark Dickinson04b27232009-01-04 12:29:36 +00003768AC_MSG_RESULT($ac_cv_x87_double_rounding)
3769if test "$ac_cv_x87_double_rounding" = yes
3770then
3771 AC_DEFINE(X87_DOUBLE_ROUNDING, 1,
3772 [Define if arithmetic is subject to x87-style double rounding issue])
3773fi
3774
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003775# ************************************
3776# * Check for mathematical functions *
3777# ************************************
3778
3779LIBS_SAVE=$LIBS
3780LIBS="$LIBS $LIBM"
3781
Mark Dickinsonc63392c2009-11-28 13:13:13 +00003782# On FreeBSD 6.2, it appears that tanh(-0.) returns 0. instead of
3783# -0. on some architectures.
3784AC_MSG_CHECKING(whether tanh preserves the sign of zero)
3785AC_CACHE_VAL(ac_cv_tanh_preserves_zero_sign, [
Matthias Klosec511b472010-05-08 11:01:39 +00003786AC_RUN_IFELSE([AC_LANG_SOURCE([[
Mark Dickinsonc63392c2009-11-28 13:13:13 +00003787#include <math.h>
3788#include <stdlib.h>
3789int main() {
3790 /* return 0 if either negative zeros don't exist
3791 on this platform or if negative zeros exist
3792 and tanh(-0.) == -0. */
3793 if (atan2(0., -1.) == atan2(-0., -1.) ||
3794 atan2(tanh(-0.), -1.) == atan2(-0., -1.)) exit(0);
3795 else exit(1);
3796}
Matthias Klosec511b472010-05-08 11:01:39 +00003797]])],
3798[ac_cv_tanh_preserves_zero_sign=yes],
3799[ac_cv_tanh_preserves_zero_sign=no],
3800[ac_cv_tanh_preserves_zero_sign=no])])
Mark Dickinsonc63392c2009-11-28 13:13:13 +00003801AC_MSG_RESULT($ac_cv_tanh_preserves_zero_sign)
3802if test "$ac_cv_tanh_preserves_zero_sign" = yes
3803then
3804 AC_DEFINE(TANH_PRESERVES_ZERO_SIGN, 1,
3805 [Define if tanh(-0.) is -0., or if platform doesn't have signed zeros])
3806fi
3807
3808AC_CHECK_FUNCS([acosh asinh atanh copysign erf erfc expm1 finite gamma])
3809AC_CHECK_FUNCS([hypot lgamma log1p round tgamma])
3810AC_CHECK_DECLS([isinf, isnan, isfinite], [], [], [[#include <math.h>]])
3811
3812LIBS=$LIBS_SAVE
3813
Mark Dickinsonc4920e82009-11-20 19:30:22 +00003814# For multiprocessing module, check that sem_open
3815# actually works. For FreeBSD versions <= 7.2,
3816# the kernel module that provides POSIX semaphores
3817# isn't loaded by default, so an attempt to call
3818# sem_open results in a 'Signal 12' error.
3819AC_MSG_CHECKING(whether POSIX semaphores are enabled)
3820AC_CACHE_VAL(ac_cv_posix_semaphores_enabled,
Matthias Klosec511b472010-05-08 11:01:39 +00003821AC_RUN_IFELSE([AC_LANG_SOURCE([[
Mark Dickinsonc4920e82009-11-20 19:30:22 +00003822#include <unistd.h>
3823#include <fcntl.h>
3824#include <stdio.h>
3825#include <semaphore.h>
3826#include <sys/stat.h>
3827
3828int main(void) {
3829 sem_t *a = sem_open("/autoconf", O_CREAT, S_IRUSR|S_IWUSR, 0);
3830 if (a == SEM_FAILED) {
3831 perror("sem_open");
3832 return 1;
3833 }
3834 sem_close(a);
Mark Dickinson59dc89e2009-12-13 21:06:06 +00003835 sem_unlink("/autoconf");
Mark Dickinsonc4920e82009-11-20 19:30:22 +00003836 return 0;
3837}
Matthias Klosec511b472010-05-08 11:01:39 +00003838]])],
3839[ac_cv_posix_semaphores_enabled=yes],
3840[ac_cv_posix_semaphores_enabled=no],
3841[ac_cv_posix_semaphores_enabled=yes])
Mark Dickinsonc4920e82009-11-20 19:30:22 +00003842)
3843AC_MSG_RESULT($ac_cv_posix_semaphores_enabled)
3844if test $ac_cv_posix_semaphores_enabled = no
3845then
Mark Dickinson5afa6d42009-11-28 10:44:20 +00003846 AC_DEFINE(POSIX_SEMAPHORES_NOT_ENABLED, 1,
3847 [Define if POSIX semaphores aren't enabled on your system])
Mark Dickinsonc4920e82009-11-20 19:30:22 +00003848fi
3849
Jesse Noller355b1262009-04-02 00:03:28 +00003850# Multiprocessing check for broken sem_getvalue
3851AC_MSG_CHECKING(for broken sem_getvalue)
Alexandre Vassalotti00900892009-07-17 05:26:39 +00003852AC_CACHE_VAL(ac_cv_broken_sem_getvalue,
Matthias Klosec511b472010-05-08 11:01:39 +00003853AC_RUN_IFELSE([AC_LANG_SOURCE([[
Jesse Noller355b1262009-04-02 00:03:28 +00003854#include <unistd.h>
3855#include <fcntl.h>
3856#include <stdio.h>
3857#include <semaphore.h>
3858#include <sys/stat.h>
3859
3860int main(void){
Mark Dickinson59dc89e2009-12-13 21:06:06 +00003861 sem_t *a = sem_open("/autocftw", O_CREAT, S_IRUSR|S_IWUSR, 0);
Jesse Noller355b1262009-04-02 00:03:28 +00003862 int count;
3863 int res;
3864 if(a==SEM_FAILED){
3865 perror("sem_open");
3866 return 1;
3867
3868 }
3869 res = sem_getvalue(a, &count);
3870 sem_close(a);
Mark Dickinson59dc89e2009-12-13 21:06:06 +00003871 sem_unlink("/autocftw");
Jesse Noller355b1262009-04-02 00:03:28 +00003872 return res==-1 ? 1 : 0;
3873}
Matthias Klosec511b472010-05-08 11:01:39 +00003874]])],
3875[ac_cv_broken_sem_getvalue=no],
3876[ac_cv_broken_sem_getvalue=yes],
3877[ac_cv_broken_sem_getvalue=yes])
Jesse Noller355b1262009-04-02 00:03:28 +00003878)
Alexandre Vassalotti00900892009-07-17 05:26:39 +00003879AC_MSG_RESULT($ac_cv_broken_sem_getvalue)
3880if test $ac_cv_broken_sem_getvalue = yes
3881then
3882 AC_DEFINE(HAVE_BROKEN_SEM_GETVALUE, 1,
3883 [define to 1 if your sem_getvalue is broken.])
3884fi
Mark Dickinson04b27232009-01-04 12:29:36 +00003885
Mark Dickinsonefc82f72009-03-20 15:51:55 +00003886# determine what size digit to use for Python's longs
3887AC_MSG_CHECKING([digit size for Python's longs])
3888AC_ARG_ENABLE(big-digits,
Matthias Klose22520ea2010-05-08 10:14:46 +00003889AS_HELP_STRING([--enable-big-digits@<:@=BITS@:>@],[use big digits for Python longs [[BITS=30]]]),
Mark Dickinsonefc82f72009-03-20 15:51:55 +00003890[case $enable_big_digits in
3891yes)
3892 enable_big_digits=30 ;;
3893no)
3894 enable_big_digits=15 ;;
3895[15|30])
3896 ;;
3897*)
3898 AC_MSG_ERROR([bad value $enable_big_digits for --enable-big-digits; value should be 15 or 30]) ;;
3899esac
3900AC_MSG_RESULT($enable_big_digits)
3901AC_DEFINE_UNQUOTED(PYLONG_BITS_IN_DIGIT, $enable_big_digits, [Define as the preferred size in bits of long digits])
3902],
3903[AC_MSG_RESULT(no value specified)])
3904
Guido van Rossumef2255b2000-03-10 22:30:29 +00003905# check for wchar.h
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003906AC_CHECK_HEADER(wchar.h, [
3907 AC_DEFINE(HAVE_WCHAR_H, 1,
3908 [Define if the compiler provides a wchar.h header file.])
3909 wchar_h="yes"
3910],
Guido van Rossumef2255b2000-03-10 22:30:29 +00003911wchar_h="no"
3912)
3913
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003914# determine wchar_t size
3915if test "$wchar_h" = yes
3916then
Guido van Rossum67b26592001-10-20 14:21:45 +00003917 AC_CHECK_SIZEOF(wchar_t, 4, [#include <wchar.h>])
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003918fi
3919
Martin v. Löwisfa3bdea2003-09-04 18:50:54 +00003920AC_MSG_CHECKING(for UCS-4 tcl)
3921have_ucs4_tcl=no
Matthias Klosec511b472010-05-08 11:01:39 +00003922AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwisfa3bdea2003-09-04 18:50:54 +00003923#include <tcl.h>
3924#if TCL_UTF_MAX != 6
3925# error "NOT UCS4_TCL"
Matthias Klosec511b472010-05-08 11:01:39 +00003926#endif]], [[]])],[
Martin v. Löwisfa3bdea2003-09-04 18:50:54 +00003927 AC_DEFINE(HAVE_UCS4_TCL, 1, [Define this if you have tcl and TCL_UTF_MAX==6])
3928 have_ucs4_tcl=yes
Matthias Klosec511b472010-05-08 11:01:39 +00003929],[])
Martin v. Löwisfa3bdea2003-09-04 18:50:54 +00003930AC_MSG_RESULT($have_ucs4_tcl)
3931
Marc-André Lemburgd7160f82003-09-22 11:14:40 +00003932# check whether wchar_t is signed or not
3933if test "$wchar_h" = yes
3934then
3935 # check whether wchar_t is signed or not
3936 AC_MSG_CHECKING(whether wchar_t is signed)
3937 AC_CACHE_VAL(ac_cv_wchar_t_signed, [
Matthias Klosec511b472010-05-08 11:01:39 +00003938 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Marc-André Lemburgd7160f82003-09-22 11:14:40 +00003939 #include <wchar.h>
3940 int main()
3941 {
Martin v. Löwis44fe0e42006-04-11 07:15:30 +00003942 /* Success: exit code 0 */
3943 exit((((wchar_t) -1) < ((wchar_t) 0)) ? 0 : 1);
Marc-André Lemburgd7160f82003-09-22 11:14:40 +00003944 }
Matthias Klosec511b472010-05-08 11:01:39 +00003945 ]])],
3946 [ac_cv_wchar_t_signed=yes],
3947 [ac_cv_wchar_t_signed=no],
3948 [ac_cv_wchar_t_signed=yes])])
Marc-André Lemburgd7160f82003-09-22 11:14:40 +00003949 AC_MSG_RESULT($ac_cv_wchar_t_signed)
3950fi
3951
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003952AC_MSG_CHECKING(what type to use for unicode)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003953dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003954AC_ARG_ENABLE(unicode,
Benjamin Peterson66556b02010-05-25 02:23:32 +00003955 AS_HELP_STRING([--enable-unicode@<:@=ucs@<:@24@:>@@:>@], [Enable Unicode strings (default is ucs2)]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003956 [],
3957 [enable_unicode=yes])
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003958
3959if test $enable_unicode = yes
3960then
Martin v. Löwisfd917792001-06-27 20:22:04 +00003961 # Without any arguments, Py_UNICODE defaults to two-byte mode
Martin v. Löwisfa3bdea2003-09-04 18:50:54 +00003962 case "$have_ucs4_tcl" in
3963 yes) enable_unicode="ucs4"
3964 ;;
3965 *) enable_unicode="ucs2"
3966 ;;
3967 esac
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003968fi
3969
Martin v. Löwis0036cba2002-04-12 09:58:45 +00003970AH_TEMPLATE(Py_UNICODE_SIZE,
3971 [Define as the size of the unicode type.])
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003972case "$enable_unicode" in
3973ucs2) unicode_size="2"
3974 AC_DEFINE(Py_UNICODE_SIZE,2)
3975 ;;
3976ucs4) unicode_size="4"
3977 AC_DEFINE(Py_UNICODE_SIZE,4)
3978 ;;
Martin v. Löwised11a5d2012-05-20 10:42:17 +02003979no) ;; # To allow --disable-unicode
Ezio Melotti5820efb2010-02-27 00:05:42 +00003980*) AC_MSG_ERROR([invalid value for --enable-unicode. Use either ucs2 or ucs4 (lowercase).]) ;;
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003981esac
3982
Martin v. Löwis11437992002-04-12 09:54:03 +00003983AH_TEMPLATE(PY_UNICODE_TYPE,
3984 [Define as the integral type used for Unicode representation.])
Martin v. Löwis0036cba2002-04-12 09:58:45 +00003985
Martin v. Löwis339d0f72001-08-17 18:39:25 +00003986AC_SUBST(UNICODE_OBJS)
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003987if test "$enable_unicode" = "no"
3988then
Martin v. Löwis339d0f72001-08-17 18:39:25 +00003989 UNICODE_OBJS=""
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003990 AC_MSG_RESULT(not used)
3991else
Martin v. Löwis339d0f72001-08-17 18:39:25 +00003992 UNICODE_OBJS="Objects/unicodeobject.o Objects/unicodectype.o"
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003993 AC_DEFINE(Py_USING_UNICODE, 1,
3994 [Define if you want to have a Unicode type.])
Marc-André Lemburgd7160f82003-09-22 11:14:40 +00003995
3996 # wchar_t is only usable if it maps to an unsigned type
3997 if test "$unicode_size" = "$ac_cv_sizeof_wchar_t" \
Matthias Klose7dbeed72004-12-24 08:22:17 +00003998 -a "$ac_cv_wchar_t_signed" = "no"
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003999 then
4000 PY_UNICODE_TYPE="wchar_t"
Martin v. Löwisc45929e2002-04-06 10:10:49 +00004001 AC_DEFINE(HAVE_USABLE_WCHAR_T, 1,
4002 [Define if you have a useable wchar_t type defined in wchar.h; useable
Marc-André Lemburgd7160f82003-09-22 11:14:40 +00004003 means wchar_t must be an unsigned type with at least 16 bits. (see
Martin v. Löwisc45929e2002-04-06 10:10:49 +00004004 Include/unicodeobject.h).])
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00004005 AC_DEFINE(PY_UNICODE_TYPE,wchar_t)
4006 elif test "$ac_cv_sizeof_short" = "$unicode_size"
4007 then
4008 PY_UNICODE_TYPE="unsigned short"
4009 AC_DEFINE(PY_UNICODE_TYPE,unsigned short)
4010 elif test "$ac_cv_sizeof_long" = "$unicode_size"
4011 then
4012 PY_UNICODE_TYPE="unsigned long"
4013 AC_DEFINE(PY_UNICODE_TYPE,unsigned long)
4014 else
4015 PY_UNICODE_TYPE="no type found"
4016 fi
4017 AC_MSG_RESULT($PY_UNICODE_TYPE)
4018fi
Guido van Rossumef2255b2000-03-10 22:30:29 +00004019
4020# check for endianness
4021AC_C_BIGENDIAN
4022
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00004023# Check whether right shifting a negative integer extends the sign bit
4024# or fills with zeros (like the Cray J90, according to Tim Peters).
4025AC_MSG_CHECKING(whether right shift extends the sign bit)
Vladimir Marangozova6180282000-07-12 05:05:06 +00004026AC_CACHE_VAL(ac_cv_rshift_extends_sign, [
Matthias Klosec511b472010-05-08 11:01:39 +00004027AC_RUN_IFELSE([AC_LANG_SOURCE([[
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00004028int main()
4029{
Vladimir Marangozova6180282000-07-12 05:05:06 +00004030 exit(((-1)>>3 == -1) ? 0 : 1);
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00004031}
Matthias Klosec511b472010-05-08 11:01:39 +00004032]])],
4033[ac_cv_rshift_extends_sign=yes],
4034[ac_cv_rshift_extends_sign=no],
4035[ac_cv_rshift_extends_sign=yes])])
Vladimir Marangozova6180282000-07-12 05:05:06 +00004036AC_MSG_RESULT($ac_cv_rshift_extends_sign)
4037if test "$ac_cv_rshift_extends_sign" = no
4038then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00004039 AC_DEFINE(SIGNED_RIGHT_SHIFT_ZERO_FILLS, 1,
4040 [Define if i>>j for signed int i does not extend the sign bit
4041 when i < 0])
Vladimir Marangozova6180282000-07-12 05:05:06 +00004042fi
4043
Guido van Rossumcadfaec2001-01-05 14:45:49 +00004044# check for getc_unlocked and related locking functions
4045AC_MSG_CHECKING(for getc_unlocked() and friends)
4046AC_CACHE_VAL(ac_cv_have_getc_unlocked, [
Matthias Klosec511b472010-05-08 11:01:39 +00004047AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <stdio.h>]], [[
Guido van Rossumcadfaec2001-01-05 14:45:49 +00004048 FILE *f = fopen("/dev/null", "r");
4049 flockfile(f);
4050 getc_unlocked(f);
4051 funlockfile(f);
Matthias Klosec511b472010-05-08 11:01:39 +00004052]])],[ac_cv_have_getc_unlocked=yes],[ac_cv_have_getc_unlocked=no])])
Guido van Rossumcadfaec2001-01-05 14:45:49 +00004053AC_MSG_RESULT($ac_cv_have_getc_unlocked)
4054if test "$ac_cv_have_getc_unlocked" = yes
4055then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00004056 AC_DEFINE(HAVE_GETC_UNLOCKED, 1,
4057 [Define this if you have flockfile(), getc_unlocked(), and funlockfile()])
Guido van Rossumcadfaec2001-01-05 14:45:49 +00004058fi
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00004059
Neal Norwitzfe8e3d92006-01-07 21:07:20 +00004060# check where readline lives
Martin v. Löwis82bca632006-02-10 20:49:30 +00004061# save the value of LIBS so we don't actually link Python with readline
4062LIBS_no_readline=$LIBS
Gregory P. Smith980b99b2008-09-07 05:15:18 +00004063
4064# On some systems we need to link readline to a termcap compatible
4065# library. NOTE: Keep the precedence of listed libraries synchronised
4066# with setup.py.
4067py_cv_lib_readline=no
4068AC_MSG_CHECKING([how to link readline libs])
4069for py_libtermcap in "" ncursesw ncurses curses termcap; do
4070 if test -z "$py_libtermcap"; then
4071 READLINE_LIBS="-lreadline"
4072 else
4073 READLINE_LIBS="-lreadline -l$py_libtermcap"
4074 fi
4075 LIBS="$READLINE_LIBS $LIBS_no_readline"
4076 AC_LINK_IFELSE(
4077 [AC_LANG_CALL([],[readline])],
4078 [py_cv_lib_readline=yes])
4079 if test $py_cv_lib_readline = yes; then
4080 break
4081 fi
4082done
4083# Uncomment this line if you want to use READINE_LIBS in Makefile or scripts
4084#AC_SUBST([READLINE_LIBS])
Gregory P. Smith29ec7502008-09-07 19:18:16 +00004085if test $py_cv_lib_readline = no; then
Gregory P. Smith980b99b2008-09-07 05:15:18 +00004086 AC_MSG_RESULT([none])
4087else
4088 AC_MSG_RESULT([$READLINE_LIBS])
4089 AC_DEFINE(HAVE_LIBREADLINE, 1,
4090 [Define if you have the readline library (-lreadline).])
Neal Norwitzfe8e3d92006-01-07 21:07:20 +00004091fi
4092
Michael W. Hudson30ea2f22004-07-07 17:44:12 +00004093# check for readline 2.1
4094AC_CHECK_LIB(readline, rl_callback_handler_install,
4095 AC_DEFINE(HAVE_RL_CALLBACK, 1,
Gregory P. Smithff7b2d52008-09-03 05:57:48 +00004096 [Define if you have readline 2.1]), ,$READLINE_LIBS)
Michael W. Hudson30ea2f22004-07-07 17:44:12 +00004097
Guido van Rossumfaf5e4d2002-12-30 16:25:41 +00004098# check for readline 2.2
Matthias Klosec511b472010-05-08 11:01:39 +00004099AC_PREPROC_IFELSE([AC_LANG_SOURCE([[#include <readline/readline.h>]])],
4100 [have_readline=yes],
4101 [have_readline=no]
4102)
Guido van Rossumfaf5e4d2002-12-30 16:25:41 +00004103if test $have_readline = yes
4104then
4105 AC_EGREP_HEADER([extern int rl_completion_append_character;],
4106 [readline/readline.h],
4107 AC_DEFINE(HAVE_RL_COMPLETION_APPEND_CHARACTER, 1,
4108 [Define if you have readline 2.2]), )
Antoine Pitroud9ff74e2009-10-26 19:16:46 +00004109 AC_EGREP_HEADER([extern int rl_completion_suppress_append;],
4110 [readline/readline.h],
4111 AC_DEFINE(HAVE_RL_COMPLETION_SUPPRESS_APPEND, 1,
4112 [Define if you have rl_completion_suppress_append]), )
Guido van Rossumfaf5e4d2002-12-30 16:25:41 +00004113fi
4114
Martin v. Löwis0daad592001-09-30 21:09:59 +00004115# check for readline 4.0
4116AC_CHECK_LIB(readline, rl_pre_input_hook,
Martin v. Löwisc45929e2002-04-06 10:10:49 +00004117 AC_DEFINE(HAVE_RL_PRE_INPUT_HOOK, 1,
Gregory P. Smithff7b2d52008-09-03 05:57:48 +00004118 [Define if you have readline 4.0]), ,$READLINE_LIBS)
Martin v. Löwis0daad592001-09-30 21:09:59 +00004119
Martin v. Löwis58bd49f2007-09-04 13:13:14 +00004120# also in 4.0
4121AC_CHECK_LIB(readline, rl_completion_display_matches_hook,
4122 AC_DEFINE(HAVE_RL_COMPLETION_DISPLAY_MATCHES_HOOK, 1,
Gregory P. Smithff7b2d52008-09-03 05:57:48 +00004123 [Define if you have readline 4.0]), ,$READLINE_LIBS)
Martin v. Löwis58bd49f2007-09-04 13:13:14 +00004124
Guido van Rossum353ae582001-07-10 16:45:32 +00004125# check for readline 4.2
4126AC_CHECK_LIB(readline, rl_completion_matches,
Martin v. Löwisc45929e2002-04-06 10:10:49 +00004127 AC_DEFINE(HAVE_RL_COMPLETION_MATCHES, 1,
Gregory P. Smithff7b2d52008-09-03 05:57:48 +00004128 [Define if you have readline 4.2]), ,$READLINE_LIBS)
Guido van Rossum353ae582001-07-10 16:45:32 +00004129
Michael W. Hudson30ea2f22004-07-07 17:44:12 +00004130# also in readline 4.2
Matthias Klosec511b472010-05-08 11:01:39 +00004131AC_PREPROC_IFELSE([AC_LANG_SOURCE([[#include <readline/readline.h>]])],
4132 [have_readline=yes],
4133 [have_readline=no]
4134)
Michael W. Hudson30ea2f22004-07-07 17:44:12 +00004135if test $have_readline = yes
4136then
4137 AC_EGREP_HEADER([extern int rl_catch_signals;],
4138 [readline/readline.h],
4139 AC_DEFINE(HAVE_RL_CATCH_SIGNAL, 1,
4140 [Define if you can turn off readline's signal handling.]), )
4141fi
4142
Martin v. Löwis82bca632006-02-10 20:49:30 +00004143# End of readline checks: restore LIBS
4144LIBS=$LIBS_no_readline
4145
Thomas Wouterse38b2f12001-07-11 22:35:31 +00004146AC_MSG_CHECKING(for broken nice())
4147AC_CACHE_VAL(ac_cv_broken_nice, [
Matthias Klosec511b472010-05-08 11:01:39 +00004148AC_RUN_IFELSE([AC_LANG_SOURCE([[
Thomas Wouterse38b2f12001-07-11 22:35:31 +00004149int main()
4150{
4151 int val1 = nice(1);
4152 if (val1 != -1 && val1 == nice(2))
4153 exit(0);
4154 exit(1);
4155}
Matthias Klosec511b472010-05-08 11:01:39 +00004156]])],
4157[ac_cv_broken_nice=yes],
4158[ac_cv_broken_nice=no],
4159[ac_cv_broken_nice=no])])
Thomas Wouterse38b2f12001-07-11 22:35:31 +00004160AC_MSG_RESULT($ac_cv_broken_nice)
4161if test "$ac_cv_broken_nice" = yes
4162then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00004163 AC_DEFINE(HAVE_BROKEN_NICE, 1,
4164 [Define if nice() returns success/failure instead of the new priority.])
Thomas Wouterse38b2f12001-07-11 22:35:31 +00004165fi
4166
Nicholas Bastine62c5c82004-03-21 23:45:42 +00004167AC_MSG_CHECKING(for broken poll())
Alexandre Vassalotti00900892009-07-17 05:26:39 +00004168AC_CACHE_VAL(ac_cv_broken_poll,
Matthias Klosec511b472010-05-08 11:01:39 +00004169AC_RUN_IFELSE([AC_LANG_SOURCE([[
Nicholas Bastine62c5c82004-03-21 23:45:42 +00004170#include <poll.h>
4171
Alexandre Vassalotti66da2632009-07-17 06:17:33 +00004172int main()
4173{
Nicholas Bastine62c5c82004-03-21 23:45:42 +00004174 struct pollfd poll_struct = { 42, POLLIN|POLLPRI|POLLOUT, 0 };
Alexandre Vassalotti66da2632009-07-17 06:17:33 +00004175 int poll_test;
4176
Nicholas Bastine62c5c82004-03-21 23:45:42 +00004177 close (42);
4178
Alexandre Vassalotti66da2632009-07-17 06:17:33 +00004179 poll_test = poll(&poll_struct, 1, 0);
Nicholas Bastine62c5c82004-03-21 23:45:42 +00004180 if (poll_test < 0)
Alexandre Vassalotti66da2632009-07-17 06:17:33 +00004181 return 0;
Nicholas Bastine62c5c82004-03-21 23:45:42 +00004182 else if (poll_test == 0 && poll_struct.revents != POLLNVAL)
Alexandre Vassalotti66da2632009-07-17 06:17:33 +00004183 return 0;
Nicholas Bastine62c5c82004-03-21 23:45:42 +00004184 else
Alexandre Vassalotti66da2632009-07-17 06:17:33 +00004185 return 1;
4186}
Matthias Klosec511b472010-05-08 11:01:39 +00004187]])],
4188[ac_cv_broken_poll=yes],
4189[ac_cv_broken_poll=no],
4190[ac_cv_broken_poll=no]))
Nicholas Bastine62c5c82004-03-21 23:45:42 +00004191AC_MSG_RESULT($ac_cv_broken_poll)
4192if test "$ac_cv_broken_poll" = yes
4193then
4194 AC_DEFINE(HAVE_BROKEN_POLL, 1,
4195 [Define if poll() sets errno on invalid file descriptors.])
4196fi
4197
Brett Cannon43802422005-02-10 20:48:03 +00004198# Before we can test tzset, we need to check if struct tm has a tm_zone
4199# (which is not required by ISO C or UNIX spec) and/or if we support
4200# tzname[]
4201AC_STRUCT_TIMEZONE
Nicholas Bastine62c5c82004-03-21 23:45:42 +00004202
Brett Cannon43802422005-02-10 20:48:03 +00004203# check tzset(3) exists and works like we expect it to
Guido van Rossumd11b62e2003-03-14 21:51:36 +00004204AC_MSG_CHECKING(for working tzset())
4205AC_CACHE_VAL(ac_cv_working_tzset, [
Matthias Klosec511b472010-05-08 11:01:39 +00004206AC_RUN_IFELSE([AC_LANG_SOURCE([[
Guido van Rossumd11b62e2003-03-14 21:51:36 +00004207#include <stdlib.h>
4208#include <time.h>
Brett Cannon18367812003-09-19 00:59:16 +00004209#include <string.h>
Brett Cannon43802422005-02-10 20:48:03 +00004210
4211#if HAVE_TZNAME
4212extern char *tzname[];
4213#endif
4214
Guido van Rossumd11b62e2003-03-14 21:51:36 +00004215int main()
4216{
Brett Cannon18367812003-09-19 00:59:16 +00004217 /* Note that we need to ensure that not only does tzset(3)
4218 do 'something' with localtime, but it works as documented
4219 in the library reference and as expected by the test suite.
Brett Cannon43802422005-02-10 20:48:03 +00004220 This includes making sure that tzname is set properly if
4221 tm->tm_zone does not exist since it is the alternative way
4222 of getting timezone info.
Brett Cannon18367812003-09-19 00:59:16 +00004223
4224 Red Hat 6.2 doesn't understand the southern hemisphere
Brett Cannon43802422005-02-10 20:48:03 +00004225 after New Year's Day.
Brett Cannon18367812003-09-19 00:59:16 +00004226 */
4227
Brett Cannon43802422005-02-10 20:48:03 +00004228 time_t groundhogday = 1044144000; /* GMT-based */
Brett Cannon18367812003-09-19 00:59:16 +00004229 time_t midyear = groundhogday + (365 * 24 * 3600 / 2);
4230
Neal Norwitz7f2588c2003-04-11 15:35:53 +00004231 putenv("TZ=UTC+0");
Guido van Rossumd11b62e2003-03-14 21:51:36 +00004232 tzset();
Brett Cannon18367812003-09-19 00:59:16 +00004233 if (localtime(&groundhogday)->tm_hour != 0)
4234 exit(1);
Brett Cannon43802422005-02-10 20:48:03 +00004235#if HAVE_TZNAME
4236 /* For UTC, tzname[1] is sometimes "", sometimes " " */
4237 if (strcmp(tzname[0], "UTC") ||
4238 (tzname[1][0] != 0 && tzname[1][0] != ' '))
4239 exit(1);
4240#endif
Brett Cannon18367812003-09-19 00:59:16 +00004241
Neal Norwitz7f2588c2003-04-11 15:35:53 +00004242 putenv("TZ=EST+5EDT,M4.1.0,M10.5.0");
Guido van Rossumd11b62e2003-03-14 21:51:36 +00004243 tzset();
Brett Cannon18367812003-09-19 00:59:16 +00004244 if (localtime(&groundhogday)->tm_hour != 19)
Guido van Rossumd11b62e2003-03-14 21:51:36 +00004245 exit(1);
Brett Cannon43802422005-02-10 20:48:03 +00004246#if HAVE_TZNAME
4247 if (strcmp(tzname[0], "EST") || strcmp(tzname[1], "EDT"))
4248 exit(1);
4249#endif
Brett Cannon18367812003-09-19 00:59:16 +00004250
4251 putenv("TZ=AEST-10AEDT-11,M10.5.0,M3.5.0");
4252 tzset();
4253 if (localtime(&groundhogday)->tm_hour != 11)
4254 exit(1);
Brett Cannon43802422005-02-10 20:48:03 +00004255#if HAVE_TZNAME
4256 if (strcmp(tzname[0], "AEST") || strcmp(tzname[1], "AEDT"))
4257 exit(1);
4258#endif
4259
4260#if HAVE_STRUCT_TM_TM_ZONE
Brett Cannon18367812003-09-19 00:59:16 +00004261 if (strcmp(localtime(&groundhogday)->tm_zone, "AEDT"))
4262 exit(1);
4263 if (strcmp(localtime(&midyear)->tm_zone, "AEST"))
4264 exit(1);
Brett Cannon43802422005-02-10 20:48:03 +00004265#endif
Brett Cannon18367812003-09-19 00:59:16 +00004266
Guido van Rossumd11b62e2003-03-14 21:51:36 +00004267 exit(0);
4268}
Matthias Klosec511b472010-05-08 11:01:39 +00004269]])],
4270[ac_cv_working_tzset=yes],
4271[ac_cv_working_tzset=no],
4272[ac_cv_working_tzset=no])])
Guido van Rossumd11b62e2003-03-14 21:51:36 +00004273AC_MSG_RESULT($ac_cv_working_tzset)
4274if test "$ac_cv_working_tzset" = yes
4275then
4276 AC_DEFINE(HAVE_WORKING_TZSET, 1,
4277 [Define if tzset() actually switches the local timezone in a meaningful way.])
4278fi
4279
Martin v. Löwis94717ed2002-09-09 14:24:16 +00004280# Look for subsecond timestamps in struct stat
4281AC_MSG_CHECKING(for tv_nsec in struct stat)
4282AC_CACHE_VAL(ac_cv_stat_tv_nsec,
Matthias Klosec511b472010-05-08 11:01:39 +00004283AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/stat.h>]], [[
Martin v. Löwis94717ed2002-09-09 14:24:16 +00004284struct stat st;
4285st.st_mtim.tv_nsec = 1;
Matthias Klosec511b472010-05-08 11:01:39 +00004286]])],
4287[ac_cv_stat_tv_nsec=yes],
4288[ac_cv_stat_tv_nsec=no]))
Martin v. Löwis94717ed2002-09-09 14:24:16 +00004289AC_MSG_RESULT($ac_cv_stat_tv_nsec)
4290if test "$ac_cv_stat_tv_nsec" = yes
4291then
4292 AC_DEFINE(HAVE_STAT_TV_NSEC, 1,
4293 [Define if you have struct stat.st_mtim.tv_nsec])
4294fi
4295
Martin v. Löwisebd9d5b2005-08-09 15:00:59 +00004296# Look for BSD style subsecond timestamps in struct stat
4297AC_MSG_CHECKING(for tv_nsec2 in struct stat)
4298AC_CACHE_VAL(ac_cv_stat_tv_nsec2,
Matthias Klosec511b472010-05-08 11:01:39 +00004299AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/stat.h>]], [[
Martin v. Löwisebd9d5b2005-08-09 15:00:59 +00004300struct stat st;
4301st.st_mtimespec.tv_nsec = 1;
Matthias Klosec511b472010-05-08 11:01:39 +00004302]])],
4303[ac_cv_stat_tv_nsec2=yes],
4304[ac_cv_stat_tv_nsec2=no]))
Martin v. Löwisebd9d5b2005-08-09 15:00:59 +00004305AC_MSG_RESULT($ac_cv_stat_tv_nsec2)
4306if test "$ac_cv_stat_tv_nsec2" = yes
4307then
4308 AC_DEFINE(HAVE_STAT_TV_NSEC2, 1,
4309 [Define if you have struct stat.st_mtimensec])
4310fi
4311
doko@ubuntu.comf27ec3e2014-04-17 20:11:19 +02004312# first curses configure check
4313ac_save_cppflags="$CPPFLAGS"
4314CPPFLAGS="$CPPFLAGS -I/usr/include/ncursesw"
4315
4316AC_CHECK_HEADERS(curses.h ncurses.h)
4317
4318# On Solaris, term.h requires curses.h
4319AC_CHECK_HEADERS(term.h,,,[
4320#ifdef HAVE_CURSES_H
4321#include <curses.h>
4322#endif
4323])
4324
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00004325# On HP/UX 11.0, mvwdelch is a block with a return statement
4326AC_MSG_CHECKING(whether mvwdelch is an expression)
4327AC_CACHE_VAL(ac_cv_mvwdelch_is_expression,
Matthias Klosec511b472010-05-08 11:01:39 +00004328AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <curses.h>]], [[
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00004329 int rtn;
4330 rtn = mvwdelch(0,0,0);
Matthias Klosec511b472010-05-08 11:01:39 +00004331]])],
4332[ac_cv_mvwdelch_is_expression=yes],
4333[ac_cv_mvwdelch_is_expression=no]))
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00004334AC_MSG_RESULT($ac_cv_mvwdelch_is_expression)
4335
4336if test "$ac_cv_mvwdelch_is_expression" = yes
4337then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00004338 AC_DEFINE(MVWDELCH_IS_EXPRESSION, 1,
4339 [Define if mvwdelch in curses.h is an expression.])
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00004340fi
4341
4342AC_MSG_CHECKING(whether WINDOW has _flags)
4343AC_CACHE_VAL(ac_cv_window_has_flags,
Matthias Klosec511b472010-05-08 11:01:39 +00004344AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <curses.h>]], [[
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00004345 WINDOW *w;
4346 w->_flags = 0;
Matthias Klosec511b472010-05-08 11:01:39 +00004347]])],
4348[ac_cv_window_has_flags=yes],
4349[ac_cv_window_has_flags=no]))
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00004350AC_MSG_RESULT($ac_cv_window_has_flags)
4351
4352
4353if test "$ac_cv_window_has_flags" = yes
4354then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00004355 AC_DEFINE(WINDOW_HAS_FLAGS, 1,
4356 [Define if WINDOW in curses.h offers a field _flags.])
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00004357fi
4358
Walter Dörwald4994d952006-06-19 08:07:50 +00004359AC_MSG_CHECKING(for is_term_resized)
Matthias Klosec511b472010-05-08 11:01:39 +00004360AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <curses.h>]], [[void *x=is_term_resized]])],
4361 [AC_DEFINE(HAVE_CURSES_IS_TERM_RESIZED, 1, Define if you have the 'is_term_resized' function.)
4362 AC_MSG_RESULT(yes)],
4363 [AC_MSG_RESULT(no)]
Walter Dörwald4994d952006-06-19 08:07:50 +00004364)
4365
Walter Dörwald05fdbf12006-06-19 08:14:09 +00004366AC_MSG_CHECKING(for resize_term)
Matthias Klosec511b472010-05-08 11:01:39 +00004367AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <curses.h>]], [[void *x=resize_term]])],
4368 [AC_DEFINE(HAVE_CURSES_RESIZE_TERM, 1, Define if you have the 'resize_term' function.)
4369 AC_MSG_RESULT(yes)],
4370 [AC_MSG_RESULT(no)]
Walter Dörwald4994d952006-06-19 08:07:50 +00004371)
4372
Walter Dörwald05fdbf12006-06-19 08:14:09 +00004373AC_MSG_CHECKING(for resizeterm)
Matthias Klosec511b472010-05-08 11:01:39 +00004374AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <curses.h>]], [[void *x=resizeterm]])],
4375 [AC_DEFINE(HAVE_CURSES_RESIZETERM, 1, Define if you have the 'resizeterm' function.)
4376 AC_MSG_RESULT(yes)],
4377 [AC_MSG_RESULT(no)]
Walter Dörwald4994d952006-06-19 08:07:50 +00004378)
doko@ubuntu.comf27ec3e2014-04-17 20:11:19 +02004379# last curses configure check
4380CPPFLAGS=$ac_save_cppflags
Walter Dörwald4994d952006-06-19 08:07:50 +00004381
doko@python.orgd65e2ba2013-01-31 23:52:03 +01004382AC_MSG_NOTICE([checking for device files])
Martin v. Löwisfefbc202006-10-17 18:59:23 +00004383
doko@python.orgd65e2ba2013-01-31 23:52:03 +01004384dnl NOTE: Inform user how to proceed with files when cross compiling.
4385if test "x$cross_compiling" = xyes; then
4386 if test "${ac_cv_file__dev_ptmx+set}" != set; then
4387 AC_MSG_CHECKING([for /dev/ptmx])
4388 AC_MSG_RESULT([not set])
4389 AC_MSG_ERROR([set ac_cv_file__dev_ptmx to yes/no in your CONFIG_SITE file when cross compiling])
4390 fi
4391 if test "${ac_cv_file__dev_ptc+set}" != set; then
4392 AC_MSG_CHECKING([for /dev/ptc])
4393 AC_MSG_RESULT([not set])
4394 AC_MSG_ERROR([set ac_cv_file__dev_ptc to yes/no in your CONFIG_SITE file when cross compiling])
4395 fi
Martin v. Löwisfefbc202006-10-17 18:59:23 +00004396fi
4397
doko@python.orgd65e2ba2013-01-31 23:52:03 +01004398AC_CHECK_FILE(/dev/ptmx, [], [])
4399if test "x$ac_cv_file__dev_ptmx" = xyes; then
4400 AC_DEFINE(HAVE_DEV_PTMX, 1,
4401 [Define to 1 if you have the /dev/ptmx device file.])
4402fi
4403AC_CHECK_FILE(/dev/ptc, [], [])
4404if test "x$ac_cv_file__dev_ptc" = xyes; then
Martin v. Löwisfefbc202006-10-17 18:59:23 +00004405 AC_DEFINE(HAVE_DEV_PTC, 1,
doko@python.orgd65e2ba2013-01-31 23:52:03 +01004406 [Define to 1 if you have the /dev/ptc device file.])
Martin v. Löwisfefbc202006-10-17 18:59:23 +00004407fi
Neal Norwitz865400f2003-03-21 01:42:58 +00004408
Mark Dickinson82864d12009-11-15 16:18:58 +00004409if test "$have_long_long" = yes
4410then
4411 AC_MSG_CHECKING(for %lld and %llu printf() format support)
4412 AC_CACHE_VAL(ac_cv_have_long_long_format,
Matthias Klosec511b472010-05-08 11:01:39 +00004413 AC_RUN_IFELSE([AC_LANG_SOURCE([[[
Mark Dickinson82864d12009-11-15 16:18:58 +00004414 #include <stdio.h>
4415 #include <stddef.h>
4416 #include <string.h>
4417
4418 #ifdef HAVE_SYS_TYPES_H
4419 #include <sys/types.h>
4420 #endif
4421
4422 int main()
4423 {
4424 char buffer[256];
4425
4426 if (sprintf(buffer, "%lld", (long long)123) < 0)
4427 return 1;
4428 if (strcmp(buffer, "123"))
4429 return 1;
4430
4431 if (sprintf(buffer, "%lld", (long long)-123) < 0)
4432 return 1;
4433 if (strcmp(buffer, "-123"))
4434 return 1;
4435
4436 if (sprintf(buffer, "%llu", (unsigned long long)123) < 0)
4437 return 1;
4438 if (strcmp(buffer, "123"))
4439 return 1;
4440
4441 return 0;
4442 }
Matthias Klosec511b472010-05-08 11:01:39 +00004443 ]]])],
4444 [ac_cv_have_long_long_format=yes],
4445 [ac_cv_have_long_long_format=no],
doko@python.orgd65e2ba2013-01-31 23:52:03 +01004446 [ac_cv_have_long_long_format="cross -- assuming no"
4447 if test x$GCC = xyes; then
4448 save_CFLAGS=$CFLAGS
4449 CFLAGS="$CFLAGS -Werror -Wformat"
4450 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4451 #include <stdio.h>
4452 #include <stddef.h>
4453 ]], [[
4454 char *buffer;
4455 sprintf(buffer, "%lld", (long long)123);
4456 sprintf(buffer, "%lld", (long long)-123);
4457 sprintf(buffer, "%llu", (unsigned long long)123);
4458 ]])],
4459 ac_cv_have_long_long_format=yes
4460 )
4461 CFLAGS=$save_CFLAGS
4462 fi])
Mark Dickinson82864d12009-11-15 16:18:58 +00004463 )
4464 AC_MSG_RESULT($ac_cv_have_long_long_format)
4465fi
4466
Mark Dickinson5ce84742009-12-31 20:48:04 +00004467if test "$ac_cv_have_long_long_format" = yes
Mark Dickinson82864d12009-11-15 16:18:58 +00004468then
4469 AC_DEFINE(PY_FORMAT_LONG_LONG, "ll",
4470 [Define to printf format modifier for long long type])
4471fi
4472
Ronald Oussoren315cd0c2009-11-19 16:25:21 +00004473if test $ac_sys_system = Darwin
4474then
4475 LIBS="$LIBS -framework CoreFoundation"
4476fi
4477
Mark Dickinson82864d12009-11-15 16:18:58 +00004478
Gregory P. Smithd8cb2d92009-11-02 02:02:38 +00004479AC_CACHE_CHECK([for %zd printf() format support], ac_cv_have_size_t_format, [dnl
Matthias Klosec511b472010-05-08 11:01:39 +00004480AC_RUN_IFELSE([AC_LANG_SOURCE([[
Alexandre Vassalottie7cf1182009-07-17 06:33:51 +00004481#include <stdio.h>
Brett Cannon09d12362006-05-11 05:11:33 +00004482#include <stddef.h>
4483#include <string.h>
4484
Christian Heimesdb3d6cb2007-12-16 21:39:43 +00004485#ifdef HAVE_SYS_TYPES_H
4486#include <sys/types.h>
4487#endif
Neal Norwitz4a8fbdb2006-09-22 08:16:26 +00004488
4489#ifdef HAVE_SSIZE_T
4490typedef ssize_t Py_ssize_t;
4491#elif SIZEOF_VOID_P == SIZEOF_LONG
4492typedef long Py_ssize_t;
4493#else
4494typedef int Py_ssize_t;
4495#endif
Brett Cannon09d12362006-05-11 05:11:33 +00004496
Christian Heimesdb3d6cb2007-12-16 21:39:43 +00004497int main()
4498{
4499 char buffer[256];
4500
Brett Cannon09d12362006-05-11 05:11:33 +00004501 if(sprintf(buffer, "%zd", (size_t)123) < 0)
4502 return 1;
4503
Neal Norwitz4a8fbdb2006-09-22 08:16:26 +00004504 if (strcmp(buffer, "123"))
Brett Cannon09d12362006-05-11 05:11:33 +00004505 return 1;
Neal Norwitz4a8fbdb2006-09-22 08:16:26 +00004506
4507 if (sprintf(buffer, "%zd", (Py_ssize_t)-123) < 0)
4508 return 1;
4509
4510 if (strcmp(buffer, "-123"))
4511 return 1;
4512
Brett Cannon09d12362006-05-11 05:11:33 +00004513 return 0;
Alexandre Vassalotti00900892009-07-17 05:26:39 +00004514}
Matthias Klosec511b472010-05-08 11:01:39 +00004515]])],
4516[ac_cv_have_size_t_format=yes],
4517[ac_cv_have_size_t_format=no],
4518[ac_cv_have_size_t_format="cross -- assuming yes"
4519])])
Gregory P. Smithd8cb2d92009-11-02 02:02:38 +00004520if test "$ac_cv_have_size_t_format" != no ; then
Alexandre Vassalotti00900892009-07-17 05:26:39 +00004521 AC_DEFINE(PY_FORMAT_SIZE_T, "z",
4522 [Define to printf format modifier for Py_ssize_t])
4523fi
Brett Cannon09d12362006-05-11 05:11:33 +00004524
Martin v. Löwis01c04012002-11-11 14:58:44 +00004525AC_CHECK_TYPE(socklen_t,,
4526 AC_DEFINE(socklen_t,int,
Matthias Klose5183ebd2010-04-24 16:38:36 +00004527 [Define to `int' if <sys/socket.h> does not define.]),[
Martin v. Löwis01c04012002-11-11 14:58:44 +00004528#ifdef HAVE_SYS_TYPES_H
4529#include <sys/types.h>
4530#endif
Guido van Rossum95713eb2000-05-18 20:53:31 +00004531#ifdef HAVE_SYS_SOCKET_H
4532#include <sys/socket.h>
4533#endif
Martin v. Löwis01c04012002-11-11 14:58:44 +00004534])
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00004535
R. David Murray1d9d16e2010-10-16 00:43:13 +00004536case $ac_sys_system in
4537AIX*)
4538 AC_DEFINE(HAVE_BROKEN_PIPE_BUF, 1, [Define if the system reports an invalid PIPE_BUF value.]) ;;
4539esac
4540
4541
Martin v. Löwis06f15bb2001-12-02 13:02:32 +00004542AC_SUBST(THREADHEADERS)
4543
4544for h in `(cd $srcdir;echo Python/thread_*.h)`
4545do
4546 THREADHEADERS="$THREADHEADERS \$(srcdir)/$h"
4547done
4548
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00004549AC_SUBST(SRCDIRS)
Neal Norwitzd24499d2005-12-18 21:36:39 +00004550SRCDIRS="Parser Grammar Objects Python Modules Mac"
Andrew M. Kuchling8abedde2001-01-26 22:55:24 +00004551AC_MSG_CHECKING(for build directories)
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00004552for dir in $SRCDIRS; do
4553 if test ! -d $dir; then
4554 mkdir $dir
Fred Drake884d3ba2000-11-02 17:52:56 +00004555 fi
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00004556done
4557AC_MSG_RESULT(done)
Fred Drake036144d2000-10-26 17:09:35 +00004558
Ned Deily3f1d0b32014-11-20 02:11:03 -08004559# ensurepip option
4560AC_MSG_CHECKING(for ensurepip)
4561AC_ARG_WITH(ensurepip,
4562 [AS_HELP_STRING([--with(out)-ensurepip=@<:@=OPTION@:>@],
4563 ["install" or "upgrade" using bundled pip, default is "no"])],
4564 [],
4565 [with_ensurepip=no])
4566AS_CASE($with_ensurepip,
4567 [yes|upgrade],[ENSUREPIP=upgrade],
4568 [install],[ENSUREPIP=install],
4569 [no],[ENSUREPIP=no],
4570 [AC_MSG_ERROR([--with-ensurepip=upgrade|install|no])])
4571AC_MSG_RESULT($ENSUREPIP)
4572AC_SUBST(ENSUREPIP)
4573
Guido van Rossum627b2d71993-12-24 10:39:16 +00004574# generate output files
Antoine Pitrouf2caeed2009-05-24 20:23:57 +00004575AC_CONFIG_FILES(Makefile.pre Modules/Setup.config Misc/python.pc)
Antoine Pitrouaabdceb2010-09-10 20:03:17 +00004576AC_CONFIG_FILES([Modules/ld_so_aix], [chmod +x Modules/ld_so_aix])
Martin v. Löwis88afe662002-10-26 13:47:44 +00004577AC_OUTPUT
Neil Schemenauer61c51152001-01-26 16:18:16 +00004578
Martin v. Löwisf7afe952006-04-14 15:16:15 +00004579echo "creating Modules/Setup"
Neil Schemenauer61c51152001-01-26 16:18:16 +00004580if test ! -f Modules/Setup
4581then
4582 cp $srcdir/Modules/Setup.dist Modules/Setup
4583fi
4584
Martin v. Löwisf7afe952006-04-14 15:16:15 +00004585echo "creating Modules/Setup.local"
Neil Schemenauer61c51152001-01-26 16:18:16 +00004586if test ! -f Modules/Setup.local
4587then
4588 echo "# Edit this file for local setup changes" >Modules/Setup.local
4589fi
4590
4591echo "creating Makefile"
4592$SHELL $srcdir/Modules/makesetup -c $srcdir/Modules/config.c.in \
4593 -s Modules Modules/Setup.config \
Neil Schemenauerf8b71c52001-04-21 17:41:16 +00004594 Modules/Setup.local Modules/Setup
Skip Montanaro7221d932007-08-22 19:02:16 +00004595
4596case $ac_sys_system in
4597BeOS)
4598 AC_MSG_WARN([
4599
4600 Support for BeOS is deprecated as of Python 2.6.
4601 See PEP 11 for the gory details.
4602 ])
4603 ;;
4604*) ;;
4605esac
4606
Neil Schemenauer66252162001-02-19 04:47:42 +00004607mv config.c Modules