blob: cb2a958fbfe8f2f64bed2116413b36bac73141e1 [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
19if test "$cross_compiling" = yes; then
20 AC_MSG_CHECKING([for python interpreter for cross build])
21 if test -z "$PYTHON_FOR_BUILD"; then
22 for interp in python$PACKAGE_VERSION python2 python; do
23 which $interp >/dev/null 2>&1 || continue
24 if $interp -c 'import sys;sys.exit(not (sys.version_info@<:@:2@:>@ >= (2,7) and sys.version_info@<:@0@:>@ < 3))'; then
25 break
26 fi
27 interp=
28 done
29 if test x$interp = x; then
30 AC_MSG_ERROR([python$PACKAGE_VERSION interpreter not found])
31 fi
32 AC_MSG_RESULT($interp)
33 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
34 fi
35elif test "$cross_compiling" = maybe; then
36 AC_MSG_ERROR([Cross compiling required --host=HOST-TUPLE and --build=ARCH])
37else
38 PYTHON_FOR_BUILD='./$(BUILDPYTHON) -E'
39fi
40AC_SUBST(PYTHON_FOR_BUILD)
41
Georg Brandlbcd64a32009-03-31 21:45:18 +000042dnl Ensure that if prefix is specified, it does not end in a slash. If
43dnl it does, we get path names containing '//' which is both ugly and
44dnl can cause trouble.
45
46dnl Last slash shouldn't be stripped if prefix=/
47if test "$prefix" != "/"; then
48 prefix=`echo "$prefix" | sed -e 's/\/$//g'`
49fi
50
Martin v. Löwis8316feb2003-06-14 07:48:07 +000051dnl This is for stuff that absolutely must end up in pyconfig.h.
52dnl Please use pyport.h instead, if possible.
Martin v. Löwisbddf5a52002-11-11 13:37:28 +000053AH_TOP([
54#ifndef Py_PYCONFIG_H
55#define Py_PYCONFIG_H
56])
Martin v. Löwis11437992002-04-12 09:54:03 +000057AH_BOTTOM([
Martin v. Löwis11437992002-04-12 09:54:03 +000058/* Define the macros needed if on a UnixWare 7.x system. */
59#if defined(__USLC__) && defined(__SCO_VERSION__)
60#define STRICT_SYSV_CURSES /* Don't use ncurses extensions */
61#endif
Martin v. Löwisbddf5a52002-11-11 13:37:28 +000062
63#endif /*Py_PYCONFIG_H*/
Martin v. Löwis11437992002-04-12 09:54:03 +000064])
65
Martin v. Löwis8316feb2003-06-14 07:48:07 +000066# We don't use PACKAGE_ variables, and they cause conflicts
67# with other autoconf-based packages that include Python.h
68grep -v 'define PACKAGE_' <confdefs.h >confdefs.h.new
69rm confdefs.h
70mv confdefs.h.new confdefs.h
71
Guido van Rossum642b6781997-07-19 19:35:41 +000072AC_SUBST(VERSION)
Martin v. Löwis88afe662002-10-26 13:47:44 +000073VERSION=PYTHON_VERSION
Guido van Rossum642b6781997-07-19 19:35:41 +000074
Martin v. Löwis1142de32002-03-29 16:28:31 +000075AC_SUBST(SOVERSION)
76SOVERSION=1.0
77
Martin v. Löwis6f18a3c2002-07-20 08:51:52 +000078# The later defininition of _XOPEN_SOURCE disables certain features
79# on Linux, so we need _GNU_SOURCE to re-enable them (makedev, tm_zone).
80AC_DEFINE(_GNU_SOURCE, 1, [Define on Linux to activate all library features])
81
Martin v. Löwisbcd93962003-05-03 10:32:18 +000082# The later defininition of _XOPEN_SOURCE and _POSIX_C_SOURCE disables
83# certain features on NetBSD, so we need _NETBSD_SOURCE to re-enable
84# them.
85AC_DEFINE(_NETBSD_SOURCE, 1, [Define on NetBSD to activate all library features])
86
Andrew MacIntyreabccf412003-07-02 13:53:25 +000087# The later defininition of _XOPEN_SOURCE and _POSIX_C_SOURCE disables
88# certain features on FreeBSD, so we need __BSD_VISIBLE to re-enable
89# them.
90AC_DEFINE(__BSD_VISIBLE, 1, [Define on FreeBSD to activate all library features])
91
Martin v. Löwisd6320502004-08-12 13:45:08 +000092# The later defininition of _XOPEN_SOURCE and _POSIX_C_SOURCE disables
93# u_int on Irix 5.3. Defining _BSD_TYPES brings it back.
94AC_DEFINE(_BSD_TYPES, 1, [Define on Irix to enable u_int])
95
Ronald Oussoren5640ce22008-06-05 12:58:24 +000096# The later defininition of _XOPEN_SOURCE and _POSIX_C_SOURCE disables
97# certain features on Mac OS X, so we need _DARWIN_C_SOURCE to re-enable
98# them.
99AC_DEFINE(_DARWIN_C_SOURCE, 1, [Define on Darwin to activate all library features])
100
101
Martin v. Löwise981a4e2002-11-11 13:26:51 +0000102define_xopen_source=yes
Martin v. Löwis6f18a3c2002-07-20 08:51:52 +0000103
Neil Schemenauer4edbc2a2001-03-22 00:34:03 +0000104# Arguments passed to configure.
105AC_SUBST(CONFIG_ARGS)
106CONFIG_ARGS="$ac_configure_args"
107
Ronald Oussoren3c0a1262010-01-17 19:27:57 +0000108AC_MSG_CHECKING([for --enable-universalsdk])
Ronald Oussoren988117f2006-04-29 11:31:35 +0000109AC_ARG_ENABLE(universalsdk,
Matthias Klose22520ea2010-05-08 10:14:46 +0000110 AS_HELP_STRING([--enable-universalsdk@<:@=SDKDIR@:>@], [Build against Mac OS X 10.4u SDK (ppc/i386)]),
Ronald Oussoren988117f2006-04-29 11:31:35 +0000111[
112 case $enableval in
113 yes)
114 enableval=/Developer/SDKs/MacOSX10.4u.sdk
Ronald Oussoren3c0a1262010-01-17 19:27:57 +0000115 if test ! -d "${enableval}"
116 then
117 enableval=/
118 fi
Ronald Oussoren988117f2006-04-29 11:31:35 +0000119 ;;
120 esac
121 case $enableval in
122 no)
123 UNIVERSALSDK=
124 enable_universalsdk=
125 ;;
126 *)
127 UNIVERSALSDK=$enableval
Ronald Oussoren3c0a1262010-01-17 19:27:57 +0000128 if test ! -d "${UNIVERSALSDK}"
129 then
130 AC_MSG_ERROR([--enable-universalsdk specifies non-existing SDK: ${UNIVERSALSDK}])
131 fi
Ronald Oussoren988117f2006-04-29 11:31:35 +0000132 ;;
133 esac
Ronald Oussoren3c0a1262010-01-17 19:27:57 +0000134
Ronald Oussoren988117f2006-04-29 11:31:35 +0000135],[
136 UNIVERSALSDK=
137 enable_universalsdk=
138])
Ronald Oussoren3c0a1262010-01-17 19:27:57 +0000139if test -n "${UNIVERSALSDK}"
140then
141 AC_MSG_RESULT(${UNIVERSALSDK})
142else
143 AC_MSG_RESULT(no)
144fi
Ronald Oussoren988117f2006-04-29 11:31:35 +0000145AC_SUBST(UNIVERSALSDK)
146
Benjamin Peterson0e6ea5d2008-07-16 20:17:04 +0000147AC_SUBST(ARCH_RUN_32BIT)
148
Ronald Oussoren5640ce22008-06-05 12:58:24 +0000149UNIVERSAL_ARCHS="32-bit"
Ronald Oussoren92919a62009-12-24 13:30:58 +0000150AC_SUBST(LIPO_32BIT_FLAGS)
Ronald Oussoren5640ce22008-06-05 12:58:24 +0000151AC_MSG_CHECKING(for --with-universal-archs)
152AC_ARG_WITH(universal-archs,
Matthias Klose22520ea2010-05-08 10:14:46 +0000153 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 +0000154[
155 AC_MSG_RESULT($withval)
156 UNIVERSAL_ARCHS="$withval"
Ronald Oussoren9ebd2422009-09-29 13:00:44 +0000157 if test "${enable_universalsdk}" ; then
158 :
159 else
160 AC_MSG_ERROR([--with-universal-archs without --enable-universalsdk. See Mac/README])
161 fi
Ronald Oussoren5640ce22008-06-05 12:58:24 +0000162],
163[
164 AC_MSG_RESULT(32-bit)
165])
166
167
168
Ronald Oussoren580c7fe2008-05-02 19:45:11 +0000169AC_ARG_WITH(framework-name,
Matthias Klose22520ea2010-05-08 10:14:46 +0000170 AS_HELP_STRING([--with-framework-name=FRAMEWORK],
Matthias Klose5183ebd2010-04-24 16:38:36 +0000171 [specify an alternate name of the framework built with --enable-framework]),
Ronald Oussoren580c7fe2008-05-02 19:45:11 +0000172[
Ronald Oussoren9ebd2422009-09-29 13:00:44 +0000173 if test "${enable_framework}"; then
174 :
175 else
176 AC_MSG_ERROR([--with-framework-name without --enable-framework. See Mac/README])
177 fi
Ronald Oussoren580c7fe2008-05-02 19:45:11 +0000178 PYTHONFRAMEWORK=${withval}
179 PYTHONFRAMEWORKDIR=${withval}.framework
180 PYTHONFRAMEWORKIDENTIFIER=org.python.`echo $withval | tr '[A-Z]' '[a-z]'`
181 ],[
182 PYTHONFRAMEWORK=Python
183 PYTHONFRAMEWORKDIR=Python.framework
184 PYTHONFRAMEWORKIDENTIFIER=org.python.python
185])
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000186dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000187AC_ARG_ENABLE(framework,
Matthias Klose22520ea2010-05-08 10:14:46 +0000188 AS_HELP_STRING([--enable-framework@<:@=INSTALLDIR@:>@], [Build (MacOSX|Darwin) framework]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000189[
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000190 case $enableval in
191 yes)
192 enableval=/Library/Frameworks
Jack Jansen127e56e2001-09-11 14:41:54 +0000193 esac
194 case $enableval in
195 no)
196 PYTHONFRAMEWORK=
197 PYTHONFRAMEWORKDIR=no-framework
198 PYTHONFRAMEWORKPREFIX=
199 PYTHONFRAMEWORKINSTALLDIR=
Ronald Oussoren567a8ff2006-05-26 11:43:26 +0000200 FRAMEWORKINSTALLFIRST=
201 FRAMEWORKINSTALLLAST=
Ronald Oussoren5b787322006-06-06 19:50:24 +0000202 FRAMEWORKALTINSTALLFIRST=
203 FRAMEWORKALTINSTALLLAST=
Ronald Oussoren2db3a8f2006-06-07 19:06:01 +0000204 if test "x${prefix}" = "xNONE"; then
205 FRAMEWORKUNIXTOOLSPREFIX="${ac_default_prefix}"
206 else
207 FRAMEWORKUNIXTOOLSPREFIX="${prefix}"
208 fi
Jack Jansen127e56e2001-09-11 14:41:54 +0000209 enable_framework=
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000210 ;;
211 *)
Ronald Oussoren01d149f2010-04-30 11:20:14 +0000212 PYTHONFRAMEWORKPREFIX="${enableval}"
Jack Jansen127e56e2001-09-11 14:41:54 +0000213 PYTHONFRAMEWORKINSTALLDIR=$PYTHONFRAMEWORKPREFIX/$PYTHONFRAMEWORKDIR
Ronald Oussoren567a8ff2006-05-26 11:43:26 +0000214 FRAMEWORKINSTALLFIRST="frameworkinstallstructure"
Ronald Oussoren5640ce22008-06-05 12:58:24 +0000215 FRAMEWORKALTINSTALLFIRST="frameworkinstallstructure bininstall maninstall"
Ronald Oussoren92919a62009-12-24 13:30:58 +0000216 FRAMEWORKINSTALLLAST="frameworkinstallmaclib frameworkinstallapps frameworkinstallunixtools"
217 FRAMEWORKALTINSTALLLAST="frameworkinstallmaclib frameworkinstallapps frameworkaltinstallunixtools"
Ronald Oussoren01d149f2010-04-30 11:20:14 +0000218 FRAMEWORKINSTALLAPPSPREFIX="/Applications"
Ronald Oussoren5640ce22008-06-05 12:58:24 +0000219
Ronald Oussoren2db3a8f2006-06-07 19:06:01 +0000220 if test "x${prefix}" = "xNONE" ; then
221 FRAMEWORKUNIXTOOLSPREFIX="${ac_default_prefix}"
Ronald Oussoren01d149f2010-04-30 11:20:14 +0000222
Ronald Oussoren2db3a8f2006-06-07 19:06:01 +0000223 else
224 FRAMEWORKUNIXTOOLSPREFIX="${prefix}"
225 fi
Ronald Oussoren01d149f2010-04-30 11:20:14 +0000226
227 case "${enableval}" in
228 /System*)
229 FRAMEWORKINSTALLAPPSPREFIX="/Applications"
230 if test "${prefix}" = "NONE" ; then
231 # See below
232 FRAMEWORKUNIXTOOLSPREFIX="/usr"
233 fi
234 ;;
235
236 /Library*)
237 FRAMEWORKINSTALLAPPSPREFIX="/Applications"
238 ;;
239
240 */Library/Frameworks)
241 MDIR="`dirname "${enableval}"`"
242 MDIR="`dirname "${MDIR}"`"
243 FRAMEWORKINSTALLAPPSPREFIX="${MDIR}/Applications"
244
245 if test "${prefix}" = "NONE"; then
246 # User hasn't specified the
247 # --prefix option, but wants to install
248 # the framework in a non-default location,
249 # ensure that the compatibility links get
250 # installed relative to that prefix as well
251 # instead of in /usr/local.
252 FRAMEWORKUNIXTOOLSPREFIX="${MDIR}"
253 fi
254 ;;
255
256 *)
257 FRAMEWORKINSTALLAPPSPREFIX="/Applications"
258 ;;
259 esac
260
Jack Jansen127e56e2001-09-11 14:41:54 +0000261 prefix=$PYTHONFRAMEWORKINSTALLDIR/Versions/$VERSION
Ronald Oussoren836b0392006-05-14 19:56:34 +0000262
Ronald Oussoren580c7fe2008-05-02 19:45:11 +0000263 # Add files for Mac specific code to the list of output
Ronald Oussoren836b0392006-05-14 19:56:34 +0000264 # files:
Ronald Oussoren2db3a8f2006-06-07 19:06:01 +0000265 AC_CONFIG_FILES(Mac/Makefile)
266 AC_CONFIG_FILES(Mac/PythonLauncher/Makefile)
267 AC_CONFIG_FILES(Mac/IDLE/Makefile)
Ronald Oussoren580c7fe2008-05-02 19:45:11 +0000268 AC_CONFIG_FILES(Mac/Resources/framework/Info.plist)
269 AC_CONFIG_FILES(Mac/Resources/app/Info.plist)
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000270 esac
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000271 ],[
272 PYTHONFRAMEWORK=
Jack Jansen127e56e2001-09-11 14:41:54 +0000273 PYTHONFRAMEWORKDIR=no-framework
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000274 PYTHONFRAMEWORKPREFIX=
275 PYTHONFRAMEWORKINSTALLDIR=
Ronald Oussoren567a8ff2006-05-26 11:43:26 +0000276 FRAMEWORKINSTALLFIRST=
277 FRAMEWORKINSTALLLAST=
Ronald Oussoren5b787322006-06-06 19:50:24 +0000278 FRAMEWORKALTINSTALLFIRST=
279 FRAMEWORKALTINSTALLLAST=
Ronald Oussoren2db3a8f2006-06-07 19:06:01 +0000280 if test "x${prefix}" = "xNONE" ; then
281 FRAMEWORKUNIXTOOLSPREFIX="${ac_default_prefix}"
282 else
283 FRAMEWORKUNIXTOOLSPREFIX="${prefix}"
284 fi
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000285 enable_framework=
Ronald Oussoren5640ce22008-06-05 12:58:24 +0000286
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000287])
288AC_SUBST(PYTHONFRAMEWORK)
Ronald Oussoren580c7fe2008-05-02 19:45:11 +0000289AC_SUBST(PYTHONFRAMEWORKIDENTIFIER)
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000290AC_SUBST(PYTHONFRAMEWORKDIR)
291AC_SUBST(PYTHONFRAMEWORKPREFIX)
292AC_SUBST(PYTHONFRAMEWORKINSTALLDIR)
Ronald Oussoren567a8ff2006-05-26 11:43:26 +0000293AC_SUBST(FRAMEWORKINSTALLFIRST)
294AC_SUBST(FRAMEWORKINSTALLLAST)
Ronald Oussoren5b787322006-06-06 19:50:24 +0000295AC_SUBST(FRAMEWORKALTINSTALLFIRST)
296AC_SUBST(FRAMEWORKALTINSTALLLAST)
297AC_SUBST(FRAMEWORKUNIXTOOLSPREFIX)
Ronald Oussoren01d149f2010-04-30 11:20:14 +0000298AC_SUBST(FRAMEWORKINSTALLAPPSPREFIX)
Guido van Rossum4b6b5791996-09-09 20:09:34 +0000299
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000300##AC_ARG_WITH(dyld,
Matthias Klose22520ea2010-05-08 10:14:46 +0000301## AS_HELP_STRING([--with-dyld],
302## [Use (OpenStep|Rhapsody) dynamic linker]))
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000303##
Guido van Rossumb418f891996-07-30 18:06:02 +0000304# Set name for machine-dependent library files
305AC_SUBST(MACHDEP)
306AC_MSG_CHECKING(MACHDEP)
307if test -z "$MACHDEP"
308then
doko@python.orgd65e2ba2013-01-31 23:52:03 +0100309 # avoid using uname for cross builds
310 if test "$cross_compiling" = yes; then
311 # ac_sys_system and ac_sys_release are only used for setting
312 # `define_xopen_source' in the case statement below. For the
313 # current supported cross builds, this macro is not adjusted.
314 case "$host" in
315 *-*-linux*)
316 ac_sys_system=Linux
317 ;;
318 *-*-cygwin*)
319 ac_sys_system=Cygwin
320 ;;
321 *)
322 # for now, limit cross builds to known configurations
323 MACHDEP="unknown"
324 AC_MSG_ERROR([cross build not supported for $host])
325 esac
326 ac_sys_release=
327 else
Guido van Rossum4b6b5791996-09-09 20:09:34 +0000328 ac_sys_system=`uname -s`
Georg Brandlfe18a112009-09-04 07:55:14 +0000329 if test "$ac_sys_system" = "AIX" \
Martin v. Löwis21ee4092002-09-30 16:19:48 +0000330 -o "$ac_sys_system" = "UnixWare" -o "$ac_sys_system" = "OpenUNIX"; then
Guido van Rossum4b6b5791996-09-09 20:09:34 +0000331 ac_sys_release=`uname -v`
Guido van Rossumb418f891996-07-30 18:06:02 +0000332 else
Guido van Rossum4b6b5791996-09-09 20:09:34 +0000333 ac_sys_release=`uname -r`
Guido van Rossumb418f891996-07-30 18:06:02 +0000334 fi
doko@python.orgd65e2ba2013-01-31 23:52:03 +0100335 fi
336 ac_md_system=`echo $ac_sys_system |
337 tr -d '[/ ]' | tr '[[A-Z]]' '[[a-z]]'`
338 ac_md_release=`echo $ac_sys_release |
339 tr -d '[/ ]' | sed 's/^[[A-Z]]\.//' | sed 's/\..*//'`
340 MACHDEP="$ac_md_system$ac_md_release"
Guido van Rossum4b6b5791996-09-09 20:09:34 +0000341
doko@python.orgd65e2ba2013-01-31 23:52:03 +0100342 case $MACHDEP in
Victor Stinneracacbaa2011-08-20 14:02:38 +0200343 linux*) MACHDEP="linux2";;
Andrew M. Kuchling5a3e4cb2001-07-20 19:29:04 +0000344 cygwin*) MACHDEP="cygwin";;
Jack Jansen8a97f4a2001-12-05 23:27:32 +0000345 darwin*) MACHDEP="darwin";;
Martin v. Löwisf90ae202002-06-11 06:22:31 +0000346 atheos*) MACHDEP="atheos";;
Martin v. Löwisf3322282003-07-13 09:46:13 +0000347 irix646) MACHDEP="irix6";;
Guido van Rossumb97ef171997-09-28 05:44:03 +0000348 '') MACHDEP="unknown";;
doko@python.orgd65e2ba2013-01-31 23:52:03 +0100349 esac
350fi
351
352AC_SUBST(_PYTHON_HOST_PLATFORM)
353if test "$cross_compiling" = yes; then
354 case "$host" in
355 *-*-linux*)
356 case "$host_cpu" in
357 arm*)
358 _host_cpu=arm
359 ;;
360 *)
361 _host_cpu=$host_cpu
362 esac
363 ;;
364 *-*-cygwin*)
365 _host_cpu=
366 ;;
367 *)
368 # for now, limit cross builds to known configurations
369 MACHDEP="unknown"
370 AC_MSG_ERROR([cross build not supported for $host])
Guido van Rossumb418f891996-07-30 18:06:02 +0000371 esac
doko@python.orgd65e2ba2013-01-31 23:52:03 +0100372 _PYTHON_HOST_PLATFORM="$MACHDEP${_host_cpu:+-$_host_cpu}"
Guido van Rossumb418f891996-07-30 18:06:02 +0000373fi
Jack Jansen83f898c2002-12-30 22:23:40 +0000374
Martin v. Löwise981a4e2002-11-11 13:26:51 +0000375# Some systems cannot stand _XOPEN_SOURCE being defined at all; they
376# disable features if it is defined, without any means to access these
377# features as extensions. For these systems, we skip the definition of
378# _XOPEN_SOURCE. Before adding a system to the list to gain access to
379# some feature, make sure there is no alternative way to access this
380# feature. Also, when using wildcards, make sure you have verified the
381# need for not defining _XOPEN_SOURCE on all systems matching the
382# wildcard, and that the wildcard does not include future systems
383# (which may remove their limitations).
384dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
385case $ac_sys_system/$ac_sys_release in
386 # On OpenBSD, select(2) is not available if _XOPEN_SOURCE is defined,
387 # even though select is a POSIX function. Reported by J. Ribbens.
Martin v. Löwis76bafc62003-10-03 13:47:44 +0000388 # Reconfirmed for OpenBSD 3.3 by Zachary Hamm, for 3.4 by Jason Ish.
Martin v. Löwis7875ef62010-02-15 21:41:12 +0000389 # In addition, Stefan Krah confirms that issue #1244610 exists through
390 # OpenBSD 4.6, but is fixed in 4.7.
Charles-François Natali97781b02011-07-22 23:43:42 +0200391 OpenBSD/2.* | OpenBSD/3.* | OpenBSD/4.@<:@0123456@:>@)
Martin v. Löwiscb78de62007-12-29 18:49:21 +0000392 define_xopen_source=no
393 # OpenBSD undoes our definition of __BSD_VISIBLE if _XOPEN_SOURCE is
394 # also defined. This can be overridden by defining _BSD_SOURCE
395 # As this has a different meaning on Linux, only define it on OpenBSD
396 AC_DEFINE(_BSD_SOURCE, 1, [Define on OpenBSD to activate all library features])
397 ;;
Charles-François Natali97781b02011-07-22 23:43:42 +0200398 OpenBSD/*)
Martin v. Löwis5e2dd862010-02-15 08:32:00 +0000399 # OpenBSD undoes our definition of __BSD_VISIBLE if _XOPEN_SOURCE is
400 # also defined. This can be overridden by defining _BSD_SOURCE
401 # As this has a different meaning on Linux, only define it on OpenBSD
402 AC_DEFINE(_BSD_SOURCE, 1, [Define on OpenBSD to activate all library features])
403 ;;
Martin v. Löwis4d542ec2006-11-25 15:39:19 +0000404 # Defining _XOPEN_SOURCE on NetBSD version prior to the introduction of
405 # _NETBSD_SOURCE disables certain features (eg. setgroups). Reported by
406 # Marc Recht
Georg Brandl4b9bcfc2008-11-16 08:00:17 +0000407 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 +0000408 define_xopen_source=no;;
Martin v. Löwisb41afb52010-05-28 15:28:47 +0000409 # From the perspective of Solaris, _XOPEN_SOURCE is not so much a
410 # request to enable features supported by the standard as a request
411 # to disable features not supported by the standard. The best way
412 # for Python to use Solaris is simply to leave _XOPEN_SOURCE out
413 # entirely and define __EXTENSIONS__ instead.
414 SunOS/*)
Martin v. Löwisa9d71422003-03-28 18:43:31 +0000415 define_xopen_source=no;;
Martin v. Löwisc2409b42003-05-11 05:53:41 +0000416 # On UnixWare 7, u_long is never defined with _XOPEN_SOURCE,
417 # but used in /usr/include/netinet/tcp.h. Reported by Tim Rice.
Martin v. Löwis253d1f42004-05-07 19:14:14 +0000418 # Reconfirmed for 7.1.4 by Martin v. Loewis.
419 OpenUNIX/8.0.0| UnixWare/7.1.@<:@0-4@:>@)
Martin v. Löwisc2409b42003-05-11 05:53:41 +0000420 define_xopen_source=no;;
421 # On OpenServer 5, u_short is never defined with _XOPEN_SOURCE,
Martin v. Löwis53e73c32003-05-05 05:13:18 +0000422 # but used in struct sockaddr.sa_family. Reported by Tim Rice.
Martin v. Löwisc2409b42003-05-11 05:53:41 +0000423 SCO_SV/3.2)
Martin v. Löwis53e73c32003-05-05 05:13:18 +0000424 define_xopen_source=no;;
Martin v. Löwisbb86d832008-11-04 20:40:09 +0000425 # On FreeBSD 4, the math functions C89 does not cover are never defined
426 # with _XOPEN_SOURCE and __BSD_VISIBLE does not re-enable them.
427 FreeBSD/4.*)
428 define_xopen_source=no;;
429 # On MacOS X 10.2, a bug in ncurses.h means that it craps out if
430 # _XOPEN_EXTENDED_SOURCE is defined. Apparently, this is fixed in 10.3, which
431 # identifies itself as Darwin/7.*
432 # On Mac OS X 10.4, defining _POSIX_C_SOURCE or _XOPEN_SOURCE
433 # disables platform specific features beyond repair.
434 # On Mac OS X 10.3, defining _POSIX_C_SOURCE or _XOPEN_SOURCE
435 # has no effect, don't bother defining them
436 Darwin/@<:@6789@:>@.*)
Anthony Baxter6169c6b2003-10-04 07:46:23 +0000437 define_xopen_source=no;;
Ronald Oussorena55af9a2010-01-17 16:25:57 +0000438 Darwin/1@<:@0-9@:>@.*)
439 define_xopen_source=no;;
Trent Mickaf16e8c2004-08-25 23:55:59 +0000440 # On AIX 4 and 5.1, mbstate_t is defined only when _XOPEN_SOURCE == 500 but
441 # used in wcsnrtombs() and mbsnrtowcs() even if _XOPEN_SOURCE is not defined
442 # or has another value. By not (re)defining it, the defaults come in place.
Martin v. Löwisc19c5a62003-11-18 20:00:44 +0000443 AIX/4)
444 define_xopen_source=no;;
Trent Mickaf16e8c2004-08-25 23:55:59 +0000445 AIX/5)
446 if test `uname -r` -eq 1; then
447 define_xopen_source=no
448 fi
449 ;;
Martin v. Löwis8c255e42008-05-23 15:06:50 +0000450 # On QNX 6.3.2, defining _XOPEN_SOURCE prevents netdb.h from
451 # defining NI_NUMERICHOST.
452 QNX/6.3.2)
453 define_xopen_source=no
454 ;;
Martin v. Löwisa0588362006-04-04 06:03:50 +0000455
Martin v. Löwise981a4e2002-11-11 13:26:51 +0000456esac
457
458if test $define_xopen_source = yes
459then
Martin v. Löwisb41afb52010-05-28 15:28:47 +0000460 AC_DEFINE(_XOPEN_SOURCE, 600,
461 Define to the level of X/Open that your system supports)
Martin v. Löwis678fc1e2002-11-12 06:04:39 +0000462
463 # On Tru64 Unix 4.0F, defining _XOPEN_SOURCE also requires
464 # definition of _XOPEN_SOURCE_EXTENDED and _POSIX_C_SOURCE, or else
465 # several APIs are not declared. Since this is also needed in some
466 # cases for HP-UX, we define it globally.
Martin v. Löwisb41afb52010-05-28 15:28:47 +0000467 AC_DEFINE(_XOPEN_SOURCE_EXTENDED, 1,
468 Define to activate Unix95-and-earlier features)
Martin v. Löwis678fc1e2002-11-12 06:04:39 +0000469
Bob Ippolito7026a0a2005-03-28 23:23:47 +0000470 AC_DEFINE(_POSIX_C_SOURCE, 200112L, Define to activate features from IEEE Stds 1003.1-2001)
471
Martin v. Löwise981a4e2002-11-11 13:26:51 +0000472fi
473
Guido van Rossum91922671997-10-09 20:24:13 +0000474#
475# SGI compilers allow the specification of the both the ABI and the
476# ISA on the command line. Depending on the values of these switches,
477# different and often incompatable code will be generated.
478#
479# The SGI_ABI variable can be used to modify the CC and LDFLAGS and
480# thus supply support for various ABI/ISA combinations. The MACHDEP
481# variable is also adjusted.
482#
483AC_SUBST(SGI_ABI)
484if test ! -z "$SGI_ABI"
485then
486 CC="cc $SGI_ABI"
487 LDFLAGS="$SGI_ABI $LDFLAGS"
488 MACHDEP=`echo "${MACHDEP}${SGI_ABI}" | sed 's/ *//g'`
489fi
Guido van Rossumb418f891996-07-30 18:06:02 +0000490AC_MSG_RESULT($MACHDEP)
491
Jack Jansen83f898c2002-12-30 22:23:40 +0000492# And add extra plat-mac for darwin
493AC_SUBST(EXTRAPLATDIR)
Jack Jansen7b59b422003-03-17 15:44:10 +0000494AC_SUBST(EXTRAMACHDEPPATH)
Jack Jansen83f898c2002-12-30 22:23:40 +0000495AC_MSG_CHECKING(EXTRAPLATDIR)
496if test -z "$EXTRAPLATDIR"
497then
498 case $MACHDEP in
Jack Jansen7b59b422003-03-17 15:44:10 +0000499 darwin)
500 EXTRAPLATDIR="\$(PLATMACDIRS)"
501 EXTRAMACHDEPPATH="\$(PLATMACPATH)"
502 ;;
503 *)
504 EXTRAPLATDIR=""
505 EXTRAMACHDEPPATH=""
506 ;;
Jack Jansen83f898c2002-12-30 22:23:40 +0000507 esac
508fi
509AC_MSG_RESULT($EXTRAPLATDIR)
510
Jack Jansen6b08a402004-06-03 12:41:45 +0000511# Record the configure-time value of MACOSX_DEPLOYMENT_TARGET,
512# it may influence the way we can build extensions, so distutils
513# needs to check it
514AC_SUBST(CONFIGURE_MACOSX_DEPLOYMENT_TARGET)
Ronald Oussoren988117f2006-04-29 11:31:35 +0000515AC_SUBST(EXPORT_MACOSX_DEPLOYMENT_TARGET)
Jack Jansen6b08a402004-06-03 12:41:45 +0000516CONFIGURE_MACOSX_DEPLOYMENT_TARGET=
Ronald Oussoren988117f2006-04-29 11:31:35 +0000517EXPORT_MACOSX_DEPLOYMENT_TARGET='#'
Jack Jansen6b08a402004-06-03 12:41:45 +0000518
Guido van Rossum627b2d71993-12-24 10:39:16 +0000519# checks for alternative programs
Skip Montanarodecc6a42003-01-01 20:07:49 +0000520
521# compiler flags are generated in two sets, BASECFLAGS and OPT. OPT is just
522# for debug/optimization stuff. BASECFLAGS is for flags that are required
523# just to get things to compile and link. Users are free to override OPT
524# when running configure or make. The build should not break if they do.
525# BASECFLAGS should generally not be messed with, however.
526
527# XXX shouldn't some/most/all of this code be merged with the stuff later
528# on that fiddles with OPT and BASECFLAGS?
Guido van Rossum5739e7e1995-01-20 16:50:53 +0000529AC_MSG_CHECKING(for --without-gcc)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000530AC_ARG_WITH(gcc,
Matthias Klose22520ea2010-05-08 10:14:46 +0000531 AS_HELP_STRING([--without-gcc], [never use gcc]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000532[
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000533 case $withval in
Skip Montanaro516144f2009-01-04 10:36:58 +0000534 no) CC=${CC:-cc}
Guido van Rossum5739e7e1995-01-20 16:50:53 +0000535 without_gcc=yes;;
536 yes) CC=gcc
537 without_gcc=no;;
538 *) CC=$withval
539 without_gcc=$withval;;
Guido van Rossum55a214e1995-09-13 17:48:09 +0000540 esac], [
Guido van Rossumb418f891996-07-30 18:06:02 +0000541 case $ac_sys_system in
Antoine Pitrou285cd162010-09-21 15:23:17 +0000542 AIX*) CC=${CC:-xlc_r}
Neil Schemenauerb3531b82001-02-16 04:09:05 +0000543 without_gcc=;;
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000544 BeOS*)
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000545 case $BE_HOST_CPU in
546 ppc)
Fred Drake5790be12000-10-09 17:06:13 +0000547 CC=mwcc
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000548 without_gcc=yes
Skip Montanarodecc6a42003-01-01 20:07:49 +0000549 BASECFLAGS="$BASECFLAGS -export pragma"
550 OPT="$OPT -O"
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000551 LDFLAGS="$LDFLAGS -nodup"
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000552 ;;
553 x86)
Fred Drake5790be12000-10-09 17:06:13 +0000554 CC=gcc
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000555 without_gcc=no
Skip Montanarodecc6a42003-01-01 20:07:49 +0000556 OPT="$OPT -O"
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000557 ;;
558 *)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000559 AC_MSG_ERROR([Unknown BeOS platform "$BE_HOST_CPU"])
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000560 ;;
561 esac
Neil Schemenauerb3531b82001-02-16 04:09:05 +0000562 AR="\$(srcdir)/Modules/ar_beos"
563 RANLIB=:
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000564 ;;
Martin v. Löwis130fb172001-07-19 11:00:41 +0000565 *) without_gcc=no;;
Guido van Rossum55a214e1995-09-13 17:48:09 +0000566 esac])
Guido van Rossum5739e7e1995-01-20 16:50:53 +0000567AC_MSG_RESULT($without_gcc)
568
Guido van Rossum03ad99f1995-03-09 14:09:54 +0000569# If the user switches compilers, we can't believe the cache
570if test ! -z "$ac_cv_prog_CC" -a ! -z "$CC" -a "$CC" != "$ac_cv_prog_CC"
571then
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000572 AC_MSG_ERROR([cached CC is different -- throw away $cache_file
573(it is also a good idea to do 'make clean' before compiling)])
Guido van Rossum03ad99f1995-03-09 14:09:54 +0000574fi
575
Trent Nelson15daa352012-12-13 06:46:39 +0000576if test "$MACHDEP" = "irix6" && test "$CC" != "gcc"; then
577 # Normally, MIPSpro CC treats #error directives as warnings, which means
578 # a successful exit code is returned (0). This is a problem because IRIX
579 # has a bunch of system headers with this guard at the top:
580 #
581 # #ifndef __c99
582 # #error This header file is to be used only for c99 mode compilations
583 # #else
584 #
585 # When autoconf tests for such a header, like stdint.h, this happens:
586 #
587 # configure:4619: cc -c conftest.c >&5
588 # cc-1035 cc: WARNING File = /usr/include/stdint.h, Line = 5
589 # #error directive: This header file is to be used only for c99 mode
590 # compilations
591 #
592 # #error This header file is to be used only for c99 mode compilations
593 # ^
594 #
595 # configure:4619: $? = 0
596 # configure:4619: result: yes
597 #
598 # Therefore, we use `-diag_error 1035` to have the compiler treat the
599 # warning as an error, which causes cc to return a non-zero result,
600 # which autoconf can interpret correctly.
601 CFLAGS="$CFLAGS -diag_error 1035"
602 # Whilst we're here, we might as well make sure CXX defaults to something
603 # sensible if we're not using gcc.
604 if test -z "$CXX"; then
605 CXX="CC"
606 fi
607fi
608
Marc-André Lemburg6d5e5792010-04-30 17:20:14 +0000609# If the user set CFLAGS, use this instead of the automatically
610# determined setting
611preset_cflags="$CFLAGS"
Guido van Rossum627b2d71993-12-24 10:39:16 +0000612AC_PROG_CC
Marc-André Lemburg6d5e5792010-04-30 17:20:14 +0000613if test ! -z "$preset_cflags"
614then
615 CFLAGS=$preset_cflags
616fi
Martin v. Löwis1d5ecb72001-08-09 10:29:44 +0000617
Martin v. Löwis0f48d982006-04-14 14:34:26 +0000618AC_SUBST(CXX)
619AC_SUBST(MAINCC)
620AC_MSG_CHECKING(for --with-cxx-main=<compiler>)
621AC_ARG_WITH(cxx_main,
Matthias Klose22520ea2010-05-08 10:14:46 +0000622 AS_HELP_STRING([--with-cxx-main=<compiler>],
Martin v. Löwis0f48d982006-04-14 14:34:26 +0000623 [compile main() and link python executable with C++ compiler]),
624[
625
626 case $withval in
627 no) with_cxx_main=no
628 MAINCC='$(CC)';;
629 yes) with_cxx_main=yes
630 MAINCC='$(CXX)';;
631 *) with_cxx_main=yes
632 MAINCC=$withval
633 if test -z "$CXX"
634 then
635 CXX=$withval
636 fi;;
637 esac], [
638 with_cxx_main=no
639 MAINCC='$(CC)'
640])
641AC_MSG_RESULT($with_cxx_main)
642
643preset_cxx="$CXX"
644if test -z "$CXX"
645then
646 case "$CC" in
doko@python.orgd65e2ba2013-01-31 23:52:03 +0100647 gcc) AC_PATH_TOOL(CXX, [g++], [g++], [notfound]) ;;
648 cc) AC_PATH_TOOL(CXX, [c++], [c++], [notfound]) ;;
Martin v. Löwis0f48d982006-04-14 14:34:26 +0000649 esac
650 if test "$CXX" = "notfound"
651 then
652 CXX=""
653 fi
654fi
655if test -z "$CXX"
656then
doko@python.orgd65e2ba2013-01-31 23:52:03 +0100657 AC_CHECK_TOOLS(CXX, $CCC c++ g++ gcc CC cxx cc++ cl, notfound)
Martin v. Löwis0f48d982006-04-14 14:34:26 +0000658 if test "$CXX" = "notfound"
659 then
660 CXX=""
661 fi
662fi
663if test "$preset_cxx" != "$CXX"
664then
665 AC_MSG_WARN([
666
667 By default, distutils will build C++ extension modules with "$CXX".
668 If this is not intended, then set CXX on the configure command line.
669 ])
670fi
671
doko@python.org4e63fbe2013-01-25 13:08:27 +0100672MULTIARCH=$($CC --print-multiarch 2>/dev/null)
673AC_SUBST(MULTIARCH)
674
Martin v. Löwis0f48d982006-04-14 14:34:26 +0000675
Martin v. Löwis1d5ecb72001-08-09 10:29:44 +0000676# checks for UNIX variants that set C preprocessor variables
Matthias Klose9f8e0c12010-05-08 10:17:27 +0000677AC_USE_SYSTEM_EXTENSIONS
Martin v. Löwis1d5ecb72001-08-09 10:29:44 +0000678
Martin v. Löwis779ffc02002-12-02 22:17:01 +0000679# Check for unsupported systems
680case $ac_sys_system/$ac_sys_release in
Brett Cannon19fab762007-06-02 03:02:29 +0000681atheos*|Linux*/1*)
Martin v. Löwis779ffc02002-12-02 22:17:01 +0000682 echo This system \($ac_sys_system/$ac_sys_release\) is no longer supported.
683 echo See README for details.
684 exit 1;;
685esac
686
Neil Schemenauer55f0cf32001-01-24 17:24:33 +0000687AC_EXEEXT
Neil Schemenauer3ae1d0a2001-01-27 06:54:42 +0000688AC_MSG_CHECKING(for --with-suffix)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000689AC_ARG_WITH(suffix,
Matthias Klose22520ea2010-05-08 10:14:46 +0000690 AS_HELP_STRING([--with-suffix=.exe], [set executable suffix]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000691[
Neil Schemenauer3ae1d0a2001-01-27 06:54:42 +0000692 case $withval in
693 no) EXEEXT=;;
694 yes) EXEEXT=.exe;;
695 *) EXEEXT=$withval;;
696 esac])
697AC_MSG_RESULT($EXEEXT)
Jack Jansen1999ef42001-12-06 21:47:20 +0000698
Jack Jansen9a66b6d2001-08-08 13:56:14 +0000699# Test whether we're running on a non-case-sensitive system, in which
700# case we give a warning if no ext is given
Jack Jansen1999ef42001-12-06 21:47:20 +0000701AC_SUBST(BUILDEXEEXT)
702AC_MSG_CHECKING(for case-insensitive build directory)
Jack Jansen3c2c4332002-11-06 13:33:32 +0000703if test ! -d CaseSensitiveTestDir; then
704mkdir CaseSensitiveTestDir
705fi
706
707if test -d casesensitivetestdir
Jack Jansen9a66b6d2001-08-08 13:56:14 +0000708then
Jack Jansen1999ef42001-12-06 21:47:20 +0000709 AC_MSG_RESULT(yes)
710 BUILDEXEEXT=.exe
711else
712 AC_MSG_RESULT(no)
Jack Jansendd19cf82001-12-06 22:36:17 +0000713 BUILDEXEEXT=$EXEEXT
Jack Jansen9a66b6d2001-08-08 13:56:14 +0000714fi
Jack Jansen3c2c4332002-11-06 13:33:32 +0000715rmdir CaseSensitiveTestDir
Guido van Rossumfb842551997-08-06 23:42:07 +0000716
Guido van Rossumdd997f71998-10-07 19:58:26 +0000717case $MACHDEP in
718bsdos*)
719 case $CC in
720 gcc) CC="$CC -D_HAVE_BSDI";;
721 esac;;
722esac
723
Guido van Rossum84561611997-08-21 00:08:11 +0000724case $ac_sys_system in
725hp*|HP*)
726 case $CC in
Guido van Rossumcd5ff9f2000-09-22 16:15:54 +0000727 cc|*/cc) CC="$CC -Ae";;
Guido van Rossum84561611997-08-21 00:08:11 +0000728 esac;;
Martin v. Löwise8964d42001-03-06 12:09:07 +0000729SunOS*)
730 # Some functions have a prototype only with that define, e.g. confstr
Martin v. Löwisc45929e2002-04-06 10:10:49 +0000731 AC_DEFINE(__EXTENSIONS__, 1, [Defined on Solaris to see additional function prototypes.])
Martin v. Löwise8964d42001-03-06 12:09:07 +0000732 ;;
Guido van Rossum84561611997-08-21 00:08:11 +0000733esac
734
Martin v. Löwise8964d42001-03-06 12:09:07 +0000735
Neil Schemenauer61c51152001-01-26 16:18:16 +0000736AC_SUBST(LIBRARY)
737AC_MSG_CHECKING(LIBRARY)
738if test -z "$LIBRARY"
739then
740 LIBRARY='libpython$(VERSION).a'
741fi
742AC_MSG_RESULT($LIBRARY)
743
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000744# LDLIBRARY is the name of the library to link against (as opposed to the
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000745# name of the library into which to insert object files). BLDLIBRARY is also
746# the library to link against, usually. On Mac OS X frameworks, BLDLIBRARY
747# is blank as the main program is not linked directly against LDLIBRARY.
748# LDLIBRARYDIR is the path to LDLIBRARY, which is made in a subdirectory. On
749# systems without shared libraries, LDLIBRARY is the same as LIBRARY
750# (defined in the Makefiles). On Cygwin LDLIBRARY is the import library,
751# DLLLIBRARY is the shared (i.e., DLL) library.
752#
Martin v. Löwis1142de32002-03-29 16:28:31 +0000753# RUNSHARED is used to run shared python without installed libraries
754#
755# INSTSONAME is the name of the shared library that will be use to install
756# on the system - some systems like version suffix, others don't
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000757AC_SUBST(LDLIBRARY)
Guido van Rossum27552902001-01-23 01:52:26 +0000758AC_SUBST(DLLLIBRARY)
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000759AC_SUBST(BLDLIBRARY)
760AC_SUBST(LDLIBRARYDIR)
Martin v. Löwis1142de32002-03-29 16:28:31 +0000761AC_SUBST(INSTSONAME)
762AC_SUBST(RUNSHARED)
Neil Schemenauer61c51152001-01-26 16:18:16 +0000763LDLIBRARY="$LIBRARY"
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000764BLDLIBRARY='$(LDLIBRARY)'
Martin v. Löwis09bdf722002-05-08 08:51:29 +0000765INSTSONAME='$(LDLIBRARY)'
Guido van Rossum27552902001-01-23 01:52:26 +0000766DLLLIBRARY=''
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000767LDLIBRARYDIR=''
Martin v. Löwis1142de32002-03-29 16:28:31 +0000768RUNSHARED=''
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000769
Guido van Rossumfb842551997-08-06 23:42:07 +0000770# LINKCC is the command that links the python executable -- default is $(CC).
Martin v. Löwisb7da67a2001-10-18 15:35:38 +0000771# If CXX is set, and if it is needed to link a main function that was
772# compiled with CXX, LINKCC is CXX instead. Always using CXX is undesirable:
773# python might then depend on the C++ runtime
Fred Drake5790be12000-10-09 17:06:13 +0000774# This is altered for AIX in order to build the export list before
Guido van Rossumec95c7b1998-08-04 17:59:56 +0000775# linking.
Guido van Rossumfb842551997-08-06 23:42:07 +0000776AC_SUBST(LINKCC)
777AC_MSG_CHECKING(LINKCC)
778if test -z "$LINKCC"
779then
Martin v. Löwis0f48d982006-04-14 14:34:26 +0000780 LINKCC='$(PURIFY) $(MAINCC)'
Guido van Rossumfb842551997-08-06 23:42:07 +0000781 case $ac_sys_system in
782 AIX*)
Neal Norwitz0b27ff92003-03-31 15:53:49 +0000783 exp_extra="\"\""
784 if test $ac_sys_release -ge 5 -o \
785 $ac_sys_release -eq 4 -a `uname -r` -ge 2 ; then
786 exp_extra="."
787 fi
788 LINKCC="\$(srcdir)/Modules/makexp_aix Modules/python.exp $exp_extra \$(LIBRARY); $LINKCC";;
Martin v. Löwis8c255e42008-05-23 15:06:50 +0000789 QNX*)
790 # qcc must be used because the other compilers do not
791 # support -N.
792 LINKCC=qcc;;
Guido van Rossumfb842551997-08-06 23:42:07 +0000793 esac
794fi
795AC_MSG_RESULT($LINKCC)
796
Tarek Ziadée2be83d2009-05-09 08:28:53 +0000797# GNULD is set to "yes" if the GNU linker is used. If this goes wrong
798# make sure we default having it set to "no": this is used by
799# distutils.unixccompiler to know if it should add --enable-new-dtags
800# to linker command lines, and failing to detect GNU ld simply results
801# in the same bahaviour as before.
802AC_SUBST(GNULD)
803AC_MSG_CHECKING(for GNU ld)
804ac_prog=ld
805if test "$GCC" = yes; then
806 ac_prog=`$CC -print-prog-name=ld`
807fi
808case `"$ac_prog" -V 2>&1 < /dev/null` in
809 *GNU*)
810 GNULD=yes;;
811 *)
812 GNULD=no;;
813esac
814AC_MSG_RESULT($GNULD)
815
Martin v. Löwis1142de32002-03-29 16:28:31 +0000816AC_MSG_CHECKING(for --enable-shared)
817AC_ARG_ENABLE(shared,
Matthias Klose22520ea2010-05-08 10:14:46 +0000818 AS_HELP_STRING([--enable-shared], [disable/enable building shared python library]))
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000819
Martin v. Löwis1142de32002-03-29 16:28:31 +0000820if test -z "$enable_shared"
821then
Martin v. Löwisb51033d2002-05-03 05:53:15 +0000822 case $ac_sys_system in
Martin v. Löwisf90ae202002-06-11 06:22:31 +0000823 CYGWIN* | atheos*)
Martin v. Löwisb51033d2002-05-03 05:53:15 +0000824 enable_shared="yes";;
825 *)
826 enable_shared="no";;
827 esac
Martin v. Löwis1142de32002-03-29 16:28:31 +0000828fi
829AC_MSG_RESULT($enable_shared)
830
Skip Montanaro56f6a4f2004-06-18 02:47:22 +0000831AC_MSG_CHECKING(for --enable-profiling)
832AC_ARG_ENABLE(profiling,
doko@python.orgd65e2ba2013-01-31 23:52:03 +0100833 AS_HELP_STRING([--enable-profiling], [enable C-level code profiling]))
834if test "x$enable_profiling" = xyes; then
835 ac_save_cc="$CC"
Benjamin Petersonb9be7bb2013-03-26 08:55:37 -0400836 CC="$CC -pg"
doko@python.orgd65e2ba2013-01-31 23:52:03 +0100837 AC_LINK_IFELSE([AC_LANG_SOURCE([[int main() { return 0; }]])],
838 [],
839 [enable_profiling=no])
840 CC="$ac_save_cc"
841else
842 enable_profiling=no
843fi
844AC_MSG_RESULT($enable_profiling)
Skip Montanaro56f6a4f2004-06-18 02:47:22 +0000845
doko@python.orgd65e2ba2013-01-31 23:52:03 +0100846if test "x$enable_profiling" = xyes; then
847 BASECFLAGS="-pg $BASECFLAGS"
848 LDFLAGS="-pg $LDFLAGS"
849fi
Martin v. Löwis1142de32002-03-29 16:28:31 +0000850
851AC_MSG_CHECKING(LDLIBRARY)
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000852
Guido van Rossumb8552162001-09-05 14:58:11 +0000853# MacOSX framework builds need more magic. LDLIBRARY is the dynamic
854# library that we build, but we do not want to link against it (we
855# will find it with a -framework option). For this reason there is an
856# extra variable BLDLIBRARY against which Python and the extension
857# modules are linked, BLDLIBRARY. This is normally the same as
858# LDLIBRARY, but empty for MacOSX framework builds.
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000859if test "$enable_framework"
860then
861 LDLIBRARY='$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansen66b84832003-07-04 12:14:39 +0000862 RUNSHARED=DYLD_FRAMEWORK_PATH="`pwd`:$DYLD_FRAMEWORK_PATH"
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000863 BLDLIBRARY=''
864else
865 BLDLIBRARY='$(LDLIBRARY)'
866fi
867
Martin v. Löwis1142de32002-03-29 16:28:31 +0000868# Other platforms follow
869if test $enable_shared = "yes"; then
Mark Hammond8235ea12002-07-19 06:55:41 +0000870 AC_DEFINE(Py_ENABLE_SHARED, 1, [Defined if Python is built as a shared library.])
Martin v. Löwis1142de32002-03-29 16:28:31 +0000871 case $ac_sys_system in
872 BeOS*)
873 LDLIBRARY='libpython$(VERSION).so'
874 ;;
875 CYGWIN*)
876 LDLIBRARY='libpython$(VERSION).dll.a'
877 DLLLIBRARY='libpython$(VERSION).dll'
878 ;;
879 SunOS*)
880 LDLIBRARY='libpython$(VERSION).so'
Martin v. Löwisd141a8c2003-06-14 15:20:28 +0000881 BLDLIBRARY='-Wl,-R,$(LIBDIR) -L. -lpython$(VERSION)'
Martin v. Löwisfc9b75f2003-08-09 09:06:52 +0000882 RUNSHARED=LD_LIBRARY_PATH=`pwd`:${LD_LIBRARY_PATH}
Martin v. Löwis2389c412003-10-31 15:42:07 +0000883 INSTSONAME="$LDLIBRARY".$SOVERSION
Martin v. Löwis1142de32002-03-29 16:28:31 +0000884 ;;
Charles-François Natali3de8c732011-07-24 22:33:35 +0200885 Linux*|GNU*|NetBSD*|FreeBSD*|DragonFly*|OpenBSD*)
Martin v. Löwis1142de32002-03-29 16:28:31 +0000886 LDLIBRARY='libpython$(VERSION).so'
887 BLDLIBRARY='-L. -lpython$(VERSION)'
Martin v. Löwisfc9b75f2003-08-09 09:06:52 +0000888 RUNSHARED=LD_LIBRARY_PATH=`pwd`:${LD_LIBRARY_PATH}
Hye-Shik Chang33761492004-10-26 09:53:46 +0000889 case $ac_sys_system in
890 FreeBSD*)
891 SOVERSION=`echo $SOVERSION|cut -d "." -f 1`
892 ;;
893 esac
Martin v. Löwis1142de32002-03-29 16:28:31 +0000894 INSTSONAME="$LDLIBRARY".$SOVERSION
895 ;;
896 hp*|HP*)
Neal Norwitz58e28882006-05-19 07:00:58 +0000897 case `uname -m` in
898 ia64)
899 LDLIBRARY='libpython$(VERSION).so'
900 ;;
901 *)
902 LDLIBRARY='libpython$(VERSION).sl'
903 ;;
904 esac
Martin v. Löwis1142de32002-03-29 16:28:31 +0000905 BLDLIBRARY='-Wl,+b,$(LIBDIR) -L. -lpython$(VERSION)'
Martin v. Löwisfc9b75f2003-08-09 09:06:52 +0000906 RUNSHARED=SHLIB_PATH=`pwd`:${SHLIB_PATH}
Martin v. Löwis1142de32002-03-29 16:28:31 +0000907 ;;
908 OSF*)
909 LDLIBRARY='libpython$(VERSION).so'
Neal Norwitz671b9e32006-01-09 07:07:12 +0000910 BLDLIBRARY='-rpath $(LIBDIR) -L. -lpython$(VERSION)'
Martin v. Löwisfc9b75f2003-08-09 09:06:52 +0000911 RUNSHARED=LD_LIBRARY_PATH=`pwd`:${LD_LIBRARY_PATH}
Martin v. Löwis1142de32002-03-29 16:28:31 +0000912 ;;
Martin v. Löwisf90ae202002-06-11 06:22:31 +0000913 atheos*)
914 LDLIBRARY='libpython$(VERSION).so'
915 BLDLIBRARY='-L. -lpython$(VERSION)'
916 RUNSHARED=DLL_PATH=`pwd`:${DLL_PATH:-/atheos/sys/libs:/atheos/autolnk/lib}
917 ;;
Ronald Oussoren79f90492009-01-02 10:44:46 +0000918 Darwin*)
919 LDLIBRARY='libpython$(VERSION).dylib'
920 BLDLIBRARY='-L. -lpython$(VERSION)'
921 RUNSHARED='DYLD_LIBRARY_PATH=`pwd`:${DYLD_LIBRARY_PATH}'
922 ;;
Antoine Pitrouaabdceb2010-09-10 20:03:17 +0000923 AIX*)
924 LDLIBRARY='libpython$(VERSION).so'
925 RUNSHARED=LIBPATH=`pwd`:${LIBPATH}
926 ;;
Ronald Oussoren79f90492009-01-02 10:44:46 +0000927
Martin v. Löwis1142de32002-03-29 16:28:31 +0000928 esac
Jason Tishler30765592003-09-04 11:04:06 +0000929else # shared is disabled
930 case $ac_sys_system in
931 CYGWIN*)
932 BLDLIBRARY='$(LIBRARY)'
933 LDLIBRARY='libpython$(VERSION).dll.a'
934 ;;
935 esac
Martin v. Löwis1142de32002-03-29 16:28:31 +0000936fi
937
doko@python.orgd65e2ba2013-01-31 23:52:03 +0100938if test "$cross_compiling" = yes; then
939 RUNSHARED=
940fi
941
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000942AC_MSG_RESULT($LDLIBRARY)
943
Guido van Rossum627b2d71993-12-24 10:39:16 +0000944AC_PROG_RANLIB
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000945AC_SUBST(AR)
doko@python.orgd65e2ba2013-01-31 23:52:03 +0100946AC_CHECK_TOOLS(AR, ar aal, ar)
Neil Schemenauera42c8272001-03-31 00:01:55 +0000947
Tarek Ziadé99f660a2009-05-07 21:20:34 +0000948# tweak ARFLAGS only if the user didn't set it on the command line
949AC_SUBST(ARFLAGS)
950if test -z "$ARFLAGS"
951then
952 ARFLAGS="rc"
953fi
954
Martin v. Löwisdea59e52006-01-05 10:00:36 +0000955AC_SUBST(SVNVERSION)
Martin v. Löwisff600232006-04-03 19:12:32 +0000956AC_CHECK_PROG(SVNVERSION, svnversion, found, not-found)
Martin v. Löwisc5bf5a02006-01-05 10:33:59 +0000957if test $SVNVERSION = found
958then
959 SVNVERSION="svnversion \$(srcdir)"
960else
Benjamin Petersone5afa3b2009-05-23 19:24:37 +0000961 SVNVERSION="echo Unversioned directory"
Martin v. Löwisc5bf5a02006-01-05 10:33:59 +0000962fi
Martin v. Löwisdea59e52006-01-05 10:00:36 +0000963
Trent Nelsond86ceec2012-10-16 09:42:45 -0400964AC_SUBST(BASECPPFLAGS)
Trent Nelsonabf20512012-10-17 04:32:49 -0400965if test "$abs_srcdir" != "$abs_builddir"; then
Trent Nelsond86ceec2012-10-16 09:42:45 -0400966 # If we're building out-of-tree make sure Include (in the current dir)
967 # gets picked up before its $srcdir counterpart in order for Python-ast.h
968 # and graminit.h to get picked up from the correct directory.
969 # (A side effect of this is that these resources will automatically be
970 # regenerated when building out-of-tree, regardless of whether or not
971 # the $srcdir counterpart is up-to-date. This is an acceptable trade
972 # off.)
973 BASECPPFLAGS="-IInclude"
974else
975 BASECPPFLAGS=""
976fi
977
Georg Brandl3a5508e2011-03-06 10:42:21 +0100978AC_SUBST(HGVERSION)
979AC_SUBST(HGTAG)
980AC_SUBST(HGBRANCH)
981AC_CHECK_PROG(HAS_HG, hg, found, not-found)
982if test $HAS_HG = found
983then
984 HGVERSION="hg id -i \$(srcdir)"
985 HGTAG="hg id -t \$(srcdir)"
986 HGBRANCH="hg id -b \$(srcdir)"
987else
988 HGVERSION=""
989 HGTAG=""
990 HGBRANCH=""
991fi
992
Neil Schemenauera42c8272001-03-31 00:01:55 +0000993case $MACHDEP in
Neil Schemenaueraf5567f2001-10-21 22:32:04 +0000994bsdos*|hp*|HP*)
995 # install -d does not work on BSDI or HP-UX
Neil Schemenauera42c8272001-03-31 00:01:55 +0000996 if test -z "$INSTALL"
997 then
998 INSTALL="${srcdir}/install-sh -c"
999 fi
1000esac
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00001001AC_PROG_INSTALL
Trent Nelsonf6407a12012-08-30 14:56:13 +00001002AC_PROG_MKDIR_P
Guido van Rossumb418f891996-07-30 18:06:02 +00001003
Guido van Rossumec95c7b1998-08-04 17:59:56 +00001004# Not every filesystem supports hard links
1005AC_SUBST(LN)
1006if test -z "$LN" ; then
1007 case $ac_sys_system in
1008 BeOS*) LN="ln -s";;
Guido van Rossumaef734b2001-01-10 21:09:12 +00001009 CYGWIN*) LN="ln -s";;
Martin v. Löwisf90ae202002-06-11 06:22:31 +00001010 atheos*) LN="ln -s";;
Guido van Rossumec95c7b1998-08-04 17:59:56 +00001011 *) LN=ln;;
1012 esac
1013fi
1014
Fred Drake9f715822001-07-11 06:27:00 +00001015# Check for --with-pydebug
1016AC_MSG_CHECKING(for --with-pydebug)
1017AC_ARG_WITH(pydebug,
Matthias Klose22520ea2010-05-08 10:14:46 +00001018 AS_HELP_STRING([--with-pydebug], [build with Py_DEBUG defined]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00001019[
Fred Drake9f715822001-07-11 06:27:00 +00001020if test "$withval" != no
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001021then
1022 AC_DEFINE(Py_DEBUG, 1,
1023 [Define if you want to build an interpreter with many run-time checks.])
1024 AC_MSG_RESULT(yes);
1025 Py_DEBUG='true'
Fred Drake9f715822001-07-11 06:27:00 +00001026else AC_MSG_RESULT(no); Py_DEBUG='false'
1027fi],
1028[AC_MSG_RESULT(no)])
1029
Skip Montanarodecc6a42003-01-01 20:07:49 +00001030# XXX Shouldn't the code above that fiddles with BASECFLAGS and OPT be
1031# merged with this chunk of code?
1032
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00001033# Optimizer/debugger flags
Skip Montanarodecc6a42003-01-01 20:07:49 +00001034# ------------------------
1035# (The following bit of code is complicated enough - please keep things
1036# indented properly. Just pretend you're editing Python code. ;-)
1037
1038# There are two parallel sets of case statements below, one that checks to
1039# see if OPT was set and one that does BASECFLAGS setting based upon
1040# compiler and platform. BASECFLAGS tweaks need to be made even if the
1041# user set OPT.
1042
1043# tweak OPT based on compiler and platform, only if the user didn't set
1044# it on the command line
Guido van Rossumb418f891996-07-30 18:06:02 +00001045AC_SUBST(OPT)
Benjamin Petersond4b721b2010-03-23 20:58:37 +00001046if test "${OPT-unset}" = "unset"
Guido van Rossumb418f891996-07-30 18:06:02 +00001047then
Skip Montanarodecc6a42003-01-01 20:07:49 +00001048 case $GCC in
1049 yes)
Skip Montanaro288a5be2006-04-13 02:00:56 +00001050 if test "$CC" != 'g++' ; then
1051 STRICT_PROTO="-Wstrict-prototypes"
1052 fi
Guido van Rossum7c862f82007-12-13 20:50:10 +00001053 # For gcc 4.x we need to use -fwrapv so lets check if its supported
1054 if "$CC" -v --help 2>/dev/null |grep -- -fwrapv > /dev/null; then
1055 WRAP="-fwrapv"
1056 fi
Stefan Krah503e5e12011-09-14 15:19:42 +02001057
1058 # Clang also needs -fwrapv
Stefan Krah2bc1e8f2011-12-08 22:26:06 +01001059 case $CC in
1060 *clang*) WRAP="-fwrapv"
1061 ;;
1062 esac
Stefan Krah503e5e12011-09-14 15:19:42 +02001063
Skip Montanarodecc6a42003-01-01 20:07:49 +00001064 case $ac_cv_prog_cc_g in
Guido van Rossum2242f2f2001-04-11 20:58:20 +00001065 yes)
Fred Drake9f715822001-07-11 06:27:00 +00001066 if test "$Py_DEBUG" = 'true' ; then
1067 # Optimization messes up debuggers, so turn it off for
1068 # debug builds.
Mark Dickinsond2f3e3f2010-05-05 22:23:58 +00001069 OPT="-g -O0 -Wall $STRICT_PROTO"
Fred Drake9f715822001-07-11 06:27:00 +00001070 else
Guido van Rossum7c862f82007-12-13 20:50:10 +00001071 OPT="-g $WRAP -O3 -Wall $STRICT_PROTO"
Skip Montanarodecc6a42003-01-01 20:07:49 +00001072 fi
1073 ;;
Guido van Rossum2242f2f2001-04-11 20:58:20 +00001074 *)
Skip Montanaro288a5be2006-04-13 02:00:56 +00001075 OPT="-O3 -Wall $STRICT_PROTO"
Skip Montanarodecc6a42003-01-01 20:07:49 +00001076 ;;
Fred Drake9f715822001-07-11 06:27:00 +00001077 esac
Martin v. Löwis21ee4092002-09-30 16:19:48 +00001078 case $ac_sys_system in
Skip Montanarodecc6a42003-01-01 20:07:49 +00001079 SCO_SV*) OPT="$OPT -m486 -DSCO5"
1080 ;;
1081 esac
Fred Drake9f715822001-07-11 06:27:00 +00001082 ;;
Skip Montanarodecc6a42003-01-01 20:07:49 +00001083
Guido van Rossum2242f2f2001-04-11 20:58:20 +00001084 *)
Skip Montanarodecc6a42003-01-01 20:07:49 +00001085 OPT="-O"
1086 ;;
Guido van Rossum2242f2f2001-04-11 20:58:20 +00001087 esac
Guido van Rossum4e8af441994-08-19 15:33:54 +00001088fi
Guido van Rossum627b2d71993-12-24 10:39:16 +00001089
Skip Montanarodecc6a42003-01-01 20:07:49 +00001090AC_SUBST(BASECFLAGS)
Ronald Oussoren5640ce22008-06-05 12:58:24 +00001091
1092# The -arch flags for universal builds on OSX
1093UNIVERSAL_ARCH_FLAGS=
1094AC_SUBST(UNIVERSAL_ARCH_FLAGS)
1095
Skip Montanarodecc6a42003-01-01 20:07:49 +00001096# tweak BASECFLAGS based on compiler and platform
1097case $GCC in
1098yes)
Martin v. Löwis70fedcd2003-07-07 21:26:19 +00001099 # Python violates C99 rules, by casting between incompatible
1100 # pointer types. GCC may generate bad code as a result of that,
1101 # so use -fno-strict-aliasing if supported.
1102 AC_MSG_CHECKING(whether $CC accepts -fno-strict-aliasing)
1103 ac_save_cc="$CC"
1104 CC="$CC -fno-strict-aliasing"
Alexandre Vassalotti00900892009-07-17 05:26:39 +00001105 AC_CACHE_VAL(ac_cv_no_strict_aliasing_ok,
Matthias Klosec511b472010-05-08 11:01:39 +00001106 AC_COMPILE_IFELSE(
Mark Dickinson5e13e292010-05-11 08:55:06 +00001107 [AC_LANG_PROGRAM([[]], [[]])],
Matthias Klosec511b472010-05-08 11:01:39 +00001108 [ac_cv_no_strict_aliasing_ok=yes],
1109 [ac_cv_no_strict_aliasing_ok=no]))
Martin v. Löwis70fedcd2003-07-07 21:26:19 +00001110 CC="$ac_save_cc"
1111 AC_MSG_RESULT($ac_cv_no_strict_aliasing_ok)
1112 if test $ac_cv_no_strict_aliasing_ok = yes
1113 then
1114 BASECFLAGS="$BASECFLAGS -fno-strict-aliasing"
1115 fi
Mark Dickinson65134662008-04-25 16:11:04 +00001116
1117 # if using gcc on alpha, use -mieee to get (near) full IEEE 754
1118 # support. Without this, treatment of subnormals doesn't follow
1119 # the standard.
doko@python.orgd65e2ba2013-01-31 23:52:03 +01001120 case $host in
Mark Dickinson65134662008-04-25 16:11:04 +00001121 alpha*)
1122 BASECFLAGS="$BASECFLAGS -mieee"
1123 ;;
1124 esac
1125
Skip Montanarodecc6a42003-01-01 20:07:49 +00001126 case $ac_sys_system in
1127 SCO_SV*)
1128 BASECFLAGS="$BASECFLAGS -m486 -DSCO5"
1129 ;;
1130 # is there any other compiler on Darwin besides gcc?
1131 Darwin*)
Jeffrey Yasskin1b4e45b2008-03-17 14:40:53 +00001132 # -Wno-long-double, -no-cpp-precomp, and -mno-fused-madd
1133 # used to be here, but non-Apple gcc doesn't accept them.
Ronald Oussorena55af9a2010-01-17 16:25:57 +00001134 if test "${CC}" = gcc
1135 then
1136 AC_MSG_CHECKING(which compiler should be used)
1137 case "${UNIVERSALSDK}" in
1138 */MacOSX10.4u.sdk)
1139 # Build using 10.4 SDK, force usage of gcc when the
1140 # compiler is gcc, otherwise the user will get very
1141 # confusing error messages when building on OSX 10.6
1142 CC=gcc-4.0
1143 CPP=cpp-4.0
1144 ;;
1145 esac
1146 AC_MSG_RESULT($CC)
Ronald Oussoren988117f2006-04-29 11:31:35 +00001147 fi
1148
Benjamin Peterson4347c442008-07-17 15:59:24 +00001149 # Calculate the right deployment target for this build.
1150 #
1151 cur_target=`sw_vers -productVersion | sed 's/\(10\.[[0-9]]*\).*/\1/'`
1152 if test ${cur_target} '>' 10.2; then
1153 cur_target=10.3
Ronald Oussoren25967582009-09-06 10:00:26 +00001154 if test ${enable_universalsdk}; then
1155 if test "${UNIVERSAL_ARCHS}" = "all"; then
1156 # Ensure that the default platform for a
1157 # 4-way universal build is OSX 10.5,
1158 # that's the first OS release where
1159 # 4-way builds make sense.
1160 cur_target='10.5'
Ronald Oussoren23d92532009-09-07 06:12:00 +00001161
1162 elif test "${UNIVERSAL_ARCHS}" = "3-way"; then
1163 cur_target='10.5'
1164
1165 elif test "${UNIVERSAL_ARCHS}" = "intel"; then
1166 cur_target='10.5'
1167
1168 elif test "${UNIVERSAL_ARCHS}" = "64-bit"; then
1169 cur_target='10.5'
Ronald Oussoren25967582009-09-06 10:00:26 +00001170 fi
1171 else
Ronald Oussorenbc0e83c2010-02-11 13:26:54 +00001172 if test `/usr/bin/arch` = "i386"; then
Ronald Oussoren25967582009-09-06 10:00:26 +00001173 # On Intel macs default to a deployment
1174 # target of 10.4, that's the first OSX
1175 # release with Intel support.
1176 cur_target="10.4"
1177 fi
1178 fi
Benjamin Peterson4347c442008-07-17 15:59:24 +00001179 fi
1180 CONFIGURE_MACOSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET-${cur_target}}
1181
1182 # Make sure that MACOSX_DEPLOYMENT_TARGET is set in the
1183 # environment with a value that is the same as what we'll use
1184 # in the Makefile to ensure that we'll get the same compiler
1185 # environment during configure and build time.
1186 MACOSX_DEPLOYMENT_TARGET="$CONFIGURE_MACOSX_DEPLOYMENT_TARGET"
1187 export MACOSX_DEPLOYMENT_TARGET
1188 EXPORT_MACOSX_DEPLOYMENT_TARGET=''
1189
Ronald Oussorena55af9a2010-01-17 16:25:57 +00001190 if test "${enable_universalsdk}"; then
1191 UNIVERSAL_ARCH_FLAGS=""
1192 if test "$UNIVERSAL_ARCHS" = "32-bit" ; then
1193 UNIVERSAL_ARCH_FLAGS="-arch ppc -arch i386"
1194 ARCH_RUN_32BIT=""
Ronald Oussoren75912852010-04-08 08:13:31 +00001195 LIPO_32BIT_FLAGS=""
Ronald Oussorena55af9a2010-01-17 16:25:57 +00001196
1197 elif test "$UNIVERSAL_ARCHS" = "64-bit" ; then
1198 UNIVERSAL_ARCH_FLAGS="-arch ppc64 -arch x86_64"
1199 LIPO_32BIT_FLAGS=""
1200 ARCH_RUN_32BIT="true"
1201
1202 elif test "$UNIVERSAL_ARCHS" = "all" ; then
1203 UNIVERSAL_ARCH_FLAGS="-arch i386 -arch ppc -arch ppc64 -arch x86_64"
1204 LIPO_32BIT_FLAGS="-extract ppc7400 -extract i386"
Ronald Oussoren92397ce2010-01-17 19:32:00 +00001205 ARCH_RUN_32BIT="/usr/bin/arch -i386 -ppc"
Ronald Oussorena55af9a2010-01-17 16:25:57 +00001206
1207 elif test "$UNIVERSAL_ARCHS" = "intel" ; then
1208 UNIVERSAL_ARCH_FLAGS="-arch i386 -arch x86_64"
1209 LIPO_32BIT_FLAGS="-extract i386"
Ronald Oussoren92397ce2010-01-17 19:32:00 +00001210 ARCH_RUN_32BIT="/usr/bin/arch -i386"
Ronald Oussorena55af9a2010-01-17 16:25:57 +00001211
1212 elif test "$UNIVERSAL_ARCHS" = "3-way" ; then
1213 UNIVERSAL_ARCH_FLAGS="-arch i386 -arch ppc -arch x86_64"
1214 LIPO_32BIT_FLAGS="-extract ppc7400 -extract i386"
Ronald Oussoren9922f172010-02-11 13:19:34 +00001215 ARCH_RUN_32BIT="/usr/bin/arch -i386 -ppc"
Ronald Oussorena55af9a2010-01-17 16:25:57 +00001216
1217 else
1218 AC_MSG_ERROR([proper usage is --with-universal-arch=32-bit|64-bit|all|intel|3-way])
1219
1220 fi
1221
1222
Ronald Oussoren974eb5e2010-04-18 17:59:37 +00001223 CFLAGS="${UNIVERSAL_ARCH_FLAGS} ${CFLAGS}"
1224 if test "${UNIVERSALSDK}" != "/"
1225 then
1226 CPPFLAGS="-isysroot ${UNIVERSALSDK} ${CPPFLAGS}"
1227 LDFLAGS="-isysroot ${UNIVERSALSDK} ${LDFLAGS}"
1228 CFLAGS="-isysroot ${UNIVERSALSDK} ${CFLAGS}"
Ronald Oussorena55af9a2010-01-17 16:25:57 +00001229 fi
1230
1231 fi
1232
1233
Skip Montanarodecc6a42003-01-01 20:07:49 +00001234 ;;
Neal Norwitzdedeeaa2006-03-31 06:54:45 +00001235 OSF*)
1236 BASECFLAGS="$BASECFLAGS -mieee"
1237 ;;
Skip Montanarodecc6a42003-01-01 20:07:49 +00001238 esac
1239 ;;
1240
1241*)
1242 case $ac_sys_system in
1243 OpenUNIX*|UnixWare*)
1244 BASECFLAGS="$BASECFLAGS -K pentium,host,inline,loop_unroll,alloca "
1245 ;;
Neal Norwitzb44f1652003-05-26 14:11:55 +00001246 OSF*)
1247 BASECFLAGS="$BASECFLAGS -ieee -std"
1248 ;;
Skip Montanarodecc6a42003-01-01 20:07:49 +00001249 SCO_SV*)
1250 BASECFLAGS="$BASECFLAGS -belf -Ki486 -DSCO5"
1251 ;;
1252 esac
1253 ;;
1254esac
1255
Fred Drakee1ceaa02001-12-04 20:55:47 +00001256if test "$Py_DEBUG" = 'true'; then
1257 :
1258else
1259 OPT="-DNDEBUG $OPT"
1260fi
1261
Guido van Rossum6f2260e1996-09-09 16:21:03 +00001262if test "$ac_arch_flags"
Guido van Rossumc5a39031996-07-31 17:35:03 +00001263then
Skip Montanarodecc6a42003-01-01 20:07:49 +00001264 BASECFLAGS="$BASECFLAGS $ac_arch_flags"
Guido van Rossumc5a39031996-07-31 17:35:03 +00001265fi
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001266
Neal Norwitz020c46a2006-01-07 21:39:28 +00001267# disable check for icc since it seems to pass, but generates a warning
1268if test "$CC" = icc
1269then
1270 ac_cv_opt_olimit_ok=no
1271fi
1272
Guido van Rossum91922671997-10-09 20:24:13 +00001273AC_MSG_CHECKING(whether $CC accepts -OPT:Olimit=0)
1274AC_CACHE_VAL(ac_cv_opt_olimit_ok,
1275[ac_save_cc="$CC"
1276CC="$CC -OPT:Olimit=0"
Matthias Klosec511b472010-05-08 11:01:39 +00001277AC_COMPILE_IFELSE(
Mark Dickinson5e13e292010-05-11 08:55:06 +00001278 [AC_LANG_PROGRAM([[]], [[]])],
Matthias Klosec511b472010-05-08 11:01:39 +00001279 [ac_cv_opt_olimit_ok=yes],
1280 [ac_cv_opt_olimit_ok=no]
Gregory P. Smithec3b8bd2009-11-01 21:02:52 +00001281 )
Guido van Rossum91922671997-10-09 20:24:13 +00001282CC="$ac_save_cc"])
1283AC_MSG_RESULT($ac_cv_opt_olimit_ok)
Guido van Rossum2efa34b1997-10-23 17:43:11 +00001284if test $ac_cv_opt_olimit_ok = yes; then
Guido van Rossum5839e582000-10-09 19:52:35 +00001285 case $ac_sys_system in
Skip Montanarodecc6a42003-01-01 20:07:49 +00001286 # XXX is this branch needed? On MacOSX 10.2.2 the result of the
1287 # olimit_ok test is "no". Is it "yes" in some other Darwin-esque
1288 # environment?
1289 Darwin*)
1290 ;;
Trent Nelson34562e12012-10-17 18:01:12 -04001291 # XXX thankfully this useless troublemaker of a flag has been
1292 # eradicated in the 3.x line. For now, make sure it isn't picked
1293 # up by any of our other platforms that use CC.
1294 AIX*|SunOS*|HP-UX*|IRIX*)
1295 ;;
Skip Montanarodecc6a42003-01-01 20:07:49 +00001296 *)
1297 BASECFLAGS="$BASECFLAGS -OPT:Olimit=0"
1298 ;;
Guido van Rossum5839e582000-10-09 19:52:35 +00001299 esac
Guido van Rossumf8678121998-07-07 21:05:09 +00001300else
1301 AC_MSG_CHECKING(whether $CC accepts -Olimit 1500)
1302 AC_CACHE_VAL(ac_cv_olimit_ok,
1303 [ac_save_cc="$CC"
1304 CC="$CC -Olimit 1500"
Matthias Klosec511b472010-05-08 11:01:39 +00001305 AC_COMPILE_IFELSE(
Mark Dickinson5e13e292010-05-11 08:55:06 +00001306 [AC_LANG_PROGRAM([[]], [[]])],
Matthias Klosec511b472010-05-08 11:01:39 +00001307 [ac_cv_olimit_ok=yes],
1308 [ac_cv_olimit_ok=no]
Gregory P. Smithec3b8bd2009-11-01 21:02:52 +00001309 )
Guido van Rossumf8678121998-07-07 21:05:09 +00001310 CC="$ac_save_cc"])
1311 AC_MSG_RESULT($ac_cv_olimit_ok)
1312 if test $ac_cv_olimit_ok = yes; then
Stefan Krah67473262012-11-29 00:17:05 +01001313 case $ac_sys_system in
1314 # Issue #16534: On HP-UX ac_cv_olimit_ok=yes is a false positive.
1315 HP-UX*)
1316 ;;
1317 *)
1318 BASECFLAGS="$BASECFLAGS -Olimit 1500"
1319 ;;
1320 esac
Guido van Rossumf8678121998-07-07 21:05:09 +00001321 fi
Guido van Rossum201afe51997-05-14 21:14:44 +00001322fi
Guido van Rossumf8678121998-07-07 21:05:09 +00001323
Martin v. Löwisaac13162006-10-19 10:58:46 +00001324# Check whether GCC supports PyArg_ParseTuple format
1325if test "$GCC" = "yes"
1326then
1327 AC_MSG_CHECKING(whether gcc supports ParseTuple __format__)
1328 save_CFLAGS=$CFLAGS
1329 CFLAGS="$CFLAGS -Werror"
Matthias Klosec511b472010-05-08 11:01:39 +00001330 AC_COMPILE_IFELSE([
1331 AC_LANG_PROGRAM([[void f(char*,...)__attribute((format(PyArg_ParseTuple, 1, 2)));]], [[]])
1332 ],[
1333 AC_DEFINE(HAVE_ATTRIBUTE_FORMAT_PARSETUPLE, 1,
1334 [Define if GCC supports __attribute__((format(PyArg_ParseTuple, 2, 3)))])
1335 AC_MSG_RESULT(yes)
1336 ],[
1337 AC_MSG_RESULT(no)
1338 ])
Martin v. Löwisc1d75972006-10-19 16:01:37 +00001339 CFLAGS=$save_CFLAGS
Martin v. Löwisaac13162006-10-19 10:58:46 +00001340fi
1341
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00001342# On some compilers, pthreads are available without further options
1343# (e.g. MacOS X). On some of these systems, the compiler will not
1344# complain if unaccepted options are passed (e.g. gcc on Mac OS X).
1345# So we have to see first whether pthreads are available without
1346# options before we can check whether -Kpthread improves anything.
1347AC_MSG_CHECKING(whether pthreads are available without options)
1348AC_CACHE_VAL(ac_cv_pthread_is_default,
Matthias Klosec511b472010-05-08 11:01:39 +00001349[AC_RUN_IFELSE([AC_LANG_SOURCE([[
Stefan Krahae66ca62012-11-22 22:36:57 +01001350#include <stdio.h>
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00001351#include <pthread.h>
1352
1353void* routine(void* p){return NULL;}
1354
1355int main(){
1356 pthread_t p;
1357 if(pthread_create(&p,NULL,routine,NULL)!=0)
1358 return 1;
Jack Jansen4f8d0542002-03-08 13:43:01 +00001359 (void)pthread_detach(p);
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00001360 return 0;
1361}
Matthias Klosec511b472010-05-08 11:01:39 +00001362]])],[
Skip Montanarod8d39a02003-07-10 20:44:10 +00001363 ac_cv_pthread_is_default=yes
1364 ac_cv_kthread=no
1365 ac_cv_pthread=no
Matthias Klosec511b472010-05-08 11:01:39 +00001366],[ac_cv_pthread_is_default=no],[ac_cv_pthread_is_default=no])
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00001367])
1368AC_MSG_RESULT($ac_cv_pthread_is_default)
1369
1370
1371if test $ac_cv_pthread_is_default = yes
1372then
1373 ac_cv_kpthread=no
1374else
Martin v. Löwis130fb172001-07-19 11:00:41 +00001375# -Kpthread, if available, provides the right #defines
1376# and linker options to make pthread_create available
Martin v. Löwis260aecc2001-10-07 08:14:41 +00001377# Some compilers won't report that they do not support -Kpthread,
1378# so we need to run a program to see whether it really made the
1379# function available.
Martin v. Löwis130fb172001-07-19 11:00:41 +00001380AC_MSG_CHECKING(whether $CC accepts -Kpthread)
1381AC_CACHE_VAL(ac_cv_kpthread,
1382[ac_save_cc="$CC"
1383CC="$CC -Kpthread"
Matthias Klosec511b472010-05-08 11:01:39 +00001384AC_RUN_IFELSE([AC_LANG_SOURCE([[
Stefan Krahae66ca62012-11-22 22:36:57 +01001385#include <stdio.h>
Martin v. Löwis260aecc2001-10-07 08:14:41 +00001386#include <pthread.h>
1387
1388void* routine(void* p){return NULL;}
1389
1390int main(){
1391 pthread_t p;
1392 if(pthread_create(&p,NULL,routine,NULL)!=0)
1393 return 1;
Jack Jansen4f8d0542002-03-08 13:43:01 +00001394 (void)pthread_detach(p);
Martin v. Löwis260aecc2001-10-07 08:14:41 +00001395 return 0;
1396}
Matthias Klosec511b472010-05-08 11:01:39 +00001397]])],[ac_cv_kpthread=yes],[ac_cv_kpthread=no],[ac_cv_kpthread=no])
Martin v. Löwis130fb172001-07-19 11:00:41 +00001398CC="$ac_save_cc"])
Martin v. Löwis130fb172001-07-19 11:00:41 +00001399AC_MSG_RESULT($ac_cv_kpthread)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00001400fi
Martin v. Löwis130fb172001-07-19 11:00:41 +00001401
Skip Montanarod8d39a02003-07-10 20:44:10 +00001402if test $ac_cv_kpthread = no -a $ac_cv_pthread_is_default = no
Martin v. Löwis5f433f02003-05-05 05:05:30 +00001403then
1404# -Kthread, if available, provides the right #defines
1405# and linker options to make pthread_create available
1406# Some compilers won't report that they do not support -Kthread,
1407# so we need to run a program to see whether it really made the
1408# function available.
1409AC_MSG_CHECKING(whether $CC accepts -Kthread)
1410AC_CACHE_VAL(ac_cv_kthread,
1411[ac_save_cc="$CC"
1412CC="$CC -Kthread"
Matthias Klosec511b472010-05-08 11:01:39 +00001413AC_RUN_IFELSE([AC_LANG_SOURCE([[
Stefan Krahae66ca62012-11-22 22:36:57 +01001414#include <stdio.h>
Martin v. Löwis5f433f02003-05-05 05:05:30 +00001415#include <pthread.h>
1416
1417void* routine(void* p){return NULL;}
1418
1419int main(){
1420 pthread_t p;
1421 if(pthread_create(&p,NULL,routine,NULL)!=0)
1422 return 1;
1423 (void)pthread_detach(p);
1424 return 0;
1425}
Matthias Klosec511b472010-05-08 11:01:39 +00001426]])],[ac_cv_kthread=yes],[ac_cv_kthread=no],[ac_cv_kthread=no])
Martin v. Löwis5f433f02003-05-05 05:05:30 +00001427CC="$ac_save_cc"])
1428AC_MSG_RESULT($ac_cv_kthread)
1429fi
1430
Skip Montanarod8d39a02003-07-10 20:44:10 +00001431if test $ac_cv_kthread = no -a $ac_cv_pthread_is_default = no
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00001432then
1433# -pthread, if available, provides the right #defines
1434# and linker options to make pthread_create available
1435# Some compilers won't report that they do not support -pthread,
1436# so we need to run a program to see whether it really made the
1437# function available.
1438AC_MSG_CHECKING(whether $CC accepts -pthread)
doko@python.orgfa3f9a32013-01-25 15:32:31 +01001439AC_CACHE_VAL(ac_cv_pthread,
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00001440[ac_save_cc="$CC"
1441CC="$CC -pthread"
Matthias Klosec511b472010-05-08 11:01:39 +00001442AC_RUN_IFELSE([AC_LANG_SOURCE([[
Stefan Krahae66ca62012-11-22 22:36:57 +01001443#include <stdio.h>
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00001444#include <pthread.h>
1445
1446void* routine(void* p){return NULL;}
1447
1448int main(){
1449 pthread_t p;
1450 if(pthread_create(&p,NULL,routine,NULL)!=0)
1451 return 1;
1452 (void)pthread_detach(p);
1453 return 0;
1454}
Matthias Klosec511b472010-05-08 11:01:39 +00001455]])],[ac_cv_pthread=yes],[ac_cv_pthread=no],[ac_cv_pthread=no])
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00001456CC="$ac_save_cc"])
1457AC_MSG_RESULT($ac_cv_pthread)
1458fi
1459
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001460# If we have set a CC compiler flag for thread support then
1461# check if it works for CXX, too.
1462ac_cv_cxx_thread=no
1463if test ! -z "$CXX"
1464then
1465AC_MSG_CHECKING(whether $CXX also accepts flags for thread support)
1466ac_save_cxx="$CXX"
1467
1468if test "$ac_cv_kpthread" = "yes"
1469then
Martin v. Löwis519adae2003-09-20 10:47:47 +00001470 CXX="$CXX -Kpthread"
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001471 ac_cv_cxx_thread=yes
1472elif test "$ac_cv_kthread" = "yes"
1473then
1474 CXX="$CXX -Kthread"
1475 ac_cv_cxx_thread=yes
1476elif test "$ac_cv_pthread" = "yes"
1477then
1478 CXX="$CXX -pthread"
1479 ac_cv_cxx_thread=yes
1480fi
1481
1482if test $ac_cv_cxx_thread = yes
1483then
1484 echo 'void foo();int main(){foo();}void foo(){}' > conftest.$ac_ext
1485 $CXX -c conftest.$ac_ext 2>&5
1486 if $CXX -o conftest$ac_exeext conftest.$ac_objext 2>&5 \
1487 && test -s conftest$ac_exeext && ./conftest$ac_exeext
1488 then
1489 ac_cv_cxx_thread=yes
1490 else
1491 ac_cv_cxx_thread=no
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001492 fi
1493 rm -fr conftest*
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001494fi
Brett Cannonc601e0f2004-11-07 01:24:12 +00001495AC_MSG_RESULT($ac_cv_cxx_thread)
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001496fi
Martin v. Löwis519adae2003-09-20 10:47:47 +00001497CXX="$ac_save_cxx"
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001498
Fred Drakece81d592000-07-09 14:39:29 +00001499dnl # check for ANSI or K&R ("traditional") preprocessor
1500dnl AC_MSG_CHECKING(for C preprocessor type)
Matthias Klosec511b472010-05-08 11:01:39 +00001501dnl AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Fred Drakece81d592000-07-09 14:39:29 +00001502dnl #define spam(name, doc) {#name, &name, #name "() -- " doc}
1503dnl int foo;
1504dnl struct {char *name; int *addr; char *doc;} desc = spam(foo, "something");
Matthias Klosec511b472010-05-08 11:01:39 +00001505dnl ]], [[;]])],[cpp_type=ansi],[AC_DEFINE(HAVE_OLD_CPP) cpp_type=traditional])
Fred Drakece81d592000-07-09 14:39:29 +00001506dnl AC_MSG_RESULT($cpp_type)
Guido van Rossum300fda71996-08-19 21:58:16 +00001507
Guido van Rossum627b2d71993-12-24 10:39:16 +00001508# checks for header files
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001509AC_HEADER_STDC
Martin v. Löwis0e8bd7e2006-06-10 12:23:46 +00001510AC_CHECK_HEADERS(asm/types.h conio.h curses.h direct.h dlfcn.h errno.h \
1511fcntl.h grp.h \
Neal Norwitz9fdfaaf2008-03-28 05:34:59 +00001512ieeefp.h io.h langinfo.h libintl.h ncurses.h poll.h process.h pthread.h \
Martin v. Löwis40e9aed2006-10-02 15:20:37 +00001513shadow.h signal.h stdint.h stropts.h termios.h thread.h \
Martin v. Löwis14e73b12003-01-01 09:51:12 +00001514unistd.h utime.h \
Christian Heimes0e9ab5f2008-03-21 23:49:44 +00001515sys/audioio.h sys/bsdtty.h sys/epoll.h sys/event.h sys/file.h sys/loadavg.h \
1516sys/lock.h sys/mkdev.h sys/modem.h \
Martin v. Löwis0e8bd7e2006-06-10 12:23:46 +00001517sys/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 +00001518sys/termio.h sys/time.h \
Martin v. Löwis0e8bd7e2006-06-10 12:23:46 +00001519sys/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 +00001520sys/resource.h netpacket/packet.h sysexits.h bluetooth.h \
Ronald Oussorena55af9a2010-01-17 16:25:57 +00001521bluetooth/bluetooth.h linux/tipc.h spawn.h util.h)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001522AC_HEADER_DIRENT
Martin v. Löwisdbe3f762002-10-10 14:27:30 +00001523AC_HEADER_MAJOR
Guido van Rossum627b2d71993-12-24 10:39:16 +00001524
Martin v. Löwisae2830c2004-09-18 09:54:52 +00001525# On Solaris, term.h requires curses.h
Martin v. Löwisfd1c69e2004-11-30 22:09:37 +00001526AC_CHECK_HEADERS(term.h,,,[
Martin v. Löwis5d52e782004-09-18 10:07:03 +00001527#ifdef HAVE_CURSES_H
1528#include <curses.h>
1529#endif
1530])
Martin v. Löwisae2830c2004-09-18 09:54:52 +00001531
Martin v. Löwis11017b12006-01-14 18:12:57 +00001532# On Linux, netlink.h requires asm/types.h
1533AC_CHECK_HEADERS(linux/netlink.h,,,[
1534#ifdef HAVE_ASM_TYPES_H
1535#include <asm/types.h>
1536#endif
1537#ifdef HAVE_SYS_SOCKET_H
1538#include <sys/socket.h>
1539#endif
1540])
1541
Guido van Rossum627b2d71993-12-24 10:39:16 +00001542# checks for typedefs
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001543was_it_defined=no
1544AC_MSG_CHECKING(for clock_t in time.h)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001545AC_EGREP_HEADER(clock_t, time.h, was_it_defined=yes, [
1546 AC_DEFINE(clock_t, long, [Define to 'long' if <time.h> doesn't define.])
1547])
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001548AC_MSG_RESULT($was_it_defined)
1549
Neal Norwitz11690112002-07-30 01:08:28 +00001550# Check whether using makedev requires defining _OSF_SOURCE
1551AC_MSG_CHECKING(for makedev)
Matthias Klosec511b472010-05-08 11:01:39 +00001552AC_LINK_IFELSE([AC_LANG_PROGRAM([[
Jesus Cea616de772010-04-28 10:32:30 +00001553#if defined(MAJOR_IN_MKDEV)
1554#include <sys/mkdev.h>
1555#elif defined(MAJOR_IN_SYSMACROS)
1556#include <sys/sysmacros.h>
1557#else
1558#include <sys/types.h>
Matthias Klosec511b472010-05-08 11:01:39 +00001559#endif ]], [[ makedev(0, 0) ]])],
1560[ac_cv_has_makedev=yes],
1561[ac_cv_has_makedev=no])
Neal Norwitz11690112002-07-30 01:08:28 +00001562if test "$ac_cv_has_makedev" = "no"; then
1563 # we didn't link, try if _OSF_SOURCE will allow us to link
Matthias Klosec511b472010-05-08 11:01:39 +00001564 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
Neal Norwitz6eb37f02003-02-23 23:28:15 +00001565#define _OSF_SOURCE 1
1566#include <sys/types.h>
Matthias Klosec511b472010-05-08 11:01:39 +00001567 ]], [[ makedev(0, 0) ]])],
1568[ac_cv_has_makedev=yes],
1569[ac_cv_has_makedev=no])
Neal Norwitz11690112002-07-30 01:08:28 +00001570 if test "$ac_cv_has_makedev" = "yes"; then
1571 AC_DEFINE(_OSF_SOURCE, 1, [Define _OSF_SOURCE to get the makedev macro.])
1572 fi
1573fi
1574AC_MSG_RESULT($ac_cv_has_makedev)
1575if test "$ac_cv_has_makedev" = "yes"; then
1576 AC_DEFINE(HAVE_MAKEDEV, 1, [Define this if you have the makedev macro.])
1577fi
1578
Martin v. Löwis399a6892002-10-04 10:22:02 +00001579# Enabling LFS on Solaris (2.6 to 9) with gcc 2.95 triggers a bug in
1580# the system headers: If _XOPEN_SOURCE and _LARGEFILE_SOURCE are
1581# defined, but the compiler does not support pragma redefine_extname,
1582# and _LARGEFILE64_SOURCE is not defined, the headers refer to 64-bit
1583# structures (such as rlimit64) without declaring them. As a
1584# work-around, disable LFS on such configurations
1585
1586use_lfs=yes
1587AC_MSG_CHECKING(Solaris LFS bug)
Matthias Klosec511b472010-05-08 11:01:39 +00001588AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwis399a6892002-10-04 10:22:02 +00001589#define _LARGEFILE_SOURCE 1
1590#define _FILE_OFFSET_BITS 64
1591#include <sys/resource.h>
Matthias Klosec511b472010-05-08 11:01:39 +00001592]], [[struct rlimit foo;]])],[sol_lfs_bug=no],[sol_lfs_bug=yes])
Martin v. Löwis399a6892002-10-04 10:22:02 +00001593AC_MSG_RESULT($sol_lfs_bug)
1594if test "$sol_lfs_bug" = "yes"; then
1595 use_lfs=no
1596fi
1597
1598if test "$use_lfs" = "yes"; then
Guido van Rossum810cc512001-09-09 23:51:39 +00001599# Two defines needed to enable largefile support on various platforms
1600# These may affect some typedefs
Georg Brandl94800df2011-02-25 11:09:02 +00001601case $ac_sys_system/$ac_sys_release in
1602AIX*)
1603 AC_DEFINE(_LARGE_FILES, 1,
1604 [This must be defined on AIX systems to enable large file support.])
1605 ;;
1606esac
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001607AC_DEFINE(_LARGEFILE_SOURCE, 1,
1608[This must be defined on some systems to enable large file support.])
1609AC_DEFINE(_FILE_OFFSET_BITS, 64,
1610[This must be set to 64 on some systems to enable large file support.])
Martin v. Löwis399a6892002-10-04 10:22:02 +00001611fi
Guido van Rossum810cc512001-09-09 23:51:39 +00001612
Guido van Rossum300fda71996-08-19 21:58:16 +00001613# Add some code to confdefs.h so that the test for off_t works on SCO
1614cat >> confdefs.h <<\EOF
1615#if defined(SCO_DS)
1616#undef _OFF_T
1617#endif
1618EOF
1619
Guido van Rossumef2255b2000-03-10 22:30:29 +00001620# Type availability checks
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001621AC_TYPE_MODE_T
1622AC_TYPE_OFF_T
1623AC_TYPE_PID_T
Matthias Klosecbf54b12010-05-08 11:04:18 +00001624AC_DEFINE_UNQUOTED([RETSIGTYPE],[void],[assume C89 semantics that RETSIGTYPE is always void])
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001625AC_TYPE_SIZE_T
1626AC_TYPE_UID_T
Mark Dickinson17c50cd2012-12-02 13:13:56 +00001627
1628# There are two separate checks for each of the exact-width integer types we
1629# need. First we check whether the type is available using the usual
1630# AC_CHECK_TYPE macro with the default includes (which includes <inttypes.h>
1631# and <stdint.h> where available). We then also use the special type checks of
1632# the form AC_TYPE_UINT32_T, which in the case that uint32_t is not available
1633# directly, #define's uint32_t to be a suitable type.
1634
1635AC_CHECK_TYPE(uint32_t,
1636 AC_DEFINE(HAVE_UINT32_T, 1, [Define if your compiler provides uint32_t.]),,)
Mark Dickinsonefc82f72009-03-20 15:51:55 +00001637AC_TYPE_UINT32_T
Mark Dickinson17c50cd2012-12-02 13:13:56 +00001638
1639AC_CHECK_TYPE(uint64_t,
1640 AC_DEFINE(HAVE_UINT64_T, 1, [Define if your compiler provides uint64_t.]),,)
Mark Dickinsonefc82f72009-03-20 15:51:55 +00001641AC_TYPE_UINT64_T
Mark Dickinson17c50cd2012-12-02 13:13:56 +00001642
1643AC_CHECK_TYPE(int32_t,
1644 AC_DEFINE(HAVE_INT32_T, 1, [Define if your compiler provides int32_t.]),,)
Mark Dickinsonefc82f72009-03-20 15:51:55 +00001645AC_TYPE_INT32_T
Mark Dickinson17c50cd2012-12-02 13:13:56 +00001646
1647AC_CHECK_TYPE(int64_t,
1648 AC_DEFINE(HAVE_INT64_T, 1, [Define if your compiler provides int64_t.]),,)
Mark Dickinsonefc82f72009-03-20 15:51:55 +00001649AC_TYPE_INT64_T
Mark Dickinson17c50cd2012-12-02 13:13:56 +00001650
Christian Heimes951cc0f2008-01-31 23:08:23 +00001651AC_CHECK_TYPE(ssize_t,
Matthias Klose5183ebd2010-04-24 16:38:36 +00001652 AC_DEFINE(HAVE_SSIZE_T, 1, [Define if your compiler provides ssize_t]),,)
Guido van Rossum627b2d71993-12-24 10:39:16 +00001653
Guido van Rossumef2255b2000-03-10 22:30:29 +00001654# Sizes of various common basic types
Skip Montanarob9820a32004-01-17 00:16:12 +00001655# ANSI C requires sizeof(char) == 1, so no need to check it
Guido van Rossum3065c942001-09-17 04:03:14 +00001656AC_CHECK_SIZEOF(int, 4)
1657AC_CHECK_SIZEOF(long, 4)
1658AC_CHECK_SIZEOF(void *, 4)
Guido van Rossum3065c942001-09-17 04:03:14 +00001659AC_CHECK_SIZEOF(short, 2)
1660AC_CHECK_SIZEOF(float, 4)
1661AC_CHECK_SIZEOF(double, 8)
1662AC_CHECK_SIZEOF(fpos_t, 4)
Martin v. Löwis18e16552006-02-15 17:27:45 +00001663AC_CHECK_SIZEOF(size_t, 4)
Christian Heimes951cc0f2008-01-31 23:08:23 +00001664AC_CHECK_SIZEOF(pid_t, 4)
Guido van Rossumac405f61994-09-12 10:56:06 +00001665
Guido van Rossumec95c7b1998-08-04 17:59:56 +00001666AC_MSG_CHECKING(for long long support)
1667have_long_long=no
Matthias Klosec511b472010-05-08 11:01:39 +00001668AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[long long x; x = (long long)0;]])],[
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001669 AC_DEFINE(HAVE_LONG_LONG, 1, [Define this if you have the type long long.])
1670 have_long_long=yes
Matthias Klosec511b472010-05-08 11:01:39 +00001671],[])
Guido van Rossumec95c7b1998-08-04 17:59:56 +00001672AC_MSG_RESULT($have_long_long)
Guido van Rossum8bc1dfd1999-04-10 16:01:48 +00001673if test "$have_long_long" = yes ; then
Guido van Rossum3065c942001-09-17 04:03:14 +00001674AC_CHECK_SIZEOF(long long, 8)
Guido van Rossumec95c7b1998-08-04 17:59:56 +00001675fi
1676
Travis E. Oliphant711c9e92008-06-06 22:33:21 +00001677AC_MSG_CHECKING(for long double support)
1678have_long_double=no
Matthias Klosec511b472010-05-08 11:01:39 +00001679AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[long double x; x = (long double)0;]])],[
Travis E. Oliphant711c9e92008-06-06 22:33:21 +00001680 AC_DEFINE(HAVE_LONG_DOUBLE, 1, [Define this if you have the type long double.])
1681 have_long_double=yes
Matthias Klosec511b472010-05-08 11:01:39 +00001682],[])
Travis E. Oliphant711c9e92008-06-06 22:33:21 +00001683AC_MSG_RESULT($have_long_double)
Mark Dickinsondc1688a2008-06-27 22:20:14 +00001684if test "$have_long_double" = yes ; then
Travis E. Oliphant711c9e92008-06-06 22:33:21 +00001685AC_CHECK_SIZEOF(long double, 12)
1686fi
1687
Martin v. Löwisaef4c6b2007-01-21 09:33:07 +00001688AC_MSG_CHECKING(for _Bool support)
1689have_c99_bool=no
Matthias Klosec511b472010-05-08 11:01:39 +00001690AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[_Bool x; x = (_Bool)0;]])],[
Martin v. Löwisaef4c6b2007-01-21 09:33:07 +00001691 AC_DEFINE(HAVE_C99_BOOL, 1, [Define this if you have the type _Bool.])
1692 have_c99_bool=yes
Matthias Klosec511b472010-05-08 11:01:39 +00001693],[])
Martin v. Löwisaef4c6b2007-01-21 09:33:07 +00001694AC_MSG_RESULT($have_c99_bool)
1695if test "$have_c99_bool" = yes ; then
1696AC_CHECK_SIZEOF(_Bool, 1)
1697fi
1698
Martin v. Löwisebe26702006-10-02 14:55:51 +00001699AC_CHECK_TYPES(uintptr_t,
1700 [AC_CHECK_SIZEOF(uintptr_t, 4)],
Martin v. Löwis40e9aed2006-10-02 15:20:37 +00001701 [], [#ifdef HAVE_STDINT_H
1702 #include <stdint.h>
Antoine Pitrou7be5a652010-10-10 08:14:41 +00001703 #endif
1704 #ifdef HAVE_INTTYPES_H
1705 #include <inttypes.h>
Martin v. Löwis40e9aed2006-10-02 15:20:37 +00001706 #endif])
Martin v. Löwisebe26702006-10-02 14:55:51 +00001707
Alexandre Vassalotti856782e2009-07-17 04:59:05 +00001708AC_CHECK_SIZEOF(off_t, [], [
1709#ifdef HAVE_SYS_TYPES_H
1710#include <sys/types.h>
1711#endif
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001712])
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001713
1714AC_MSG_CHECKING(whether to enable large file support)
Mark Dickinson0ef0b912009-12-31 21:11:48 +00001715if test "$have_long_long" = yes
1716then
1717if test "$ac_cv_sizeof_off_t" -gt "$ac_cv_sizeof_long" -a \
Guido van Rossum8bc1dfd1999-04-10 16:01:48 +00001718 "$ac_cv_sizeof_long_long" -ge "$ac_cv_sizeof_off_t"; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001719 AC_DEFINE(HAVE_LARGEFILE_SUPPORT, 1,
1720 [Defined to enable large file support when an off_t is bigger than a long
1721 and long long is available and at least as big as an off_t. You may need
1722 to add some flags for configuration and compilation to enable this mode.
1723 (For Solaris and Linux, the necessary defines are already defined.)])
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001724 AC_MSG_RESULT(yes)
1725else
1726 AC_MSG_RESULT(no)
1727fi
Mark Dickinson0ef0b912009-12-31 21:11:48 +00001728else
1729 AC_MSG_RESULT(no)
1730fi
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001731
Alexandre Vassalotti856782e2009-07-17 04:59:05 +00001732AC_CHECK_SIZEOF(time_t, [], [
1733#ifdef HAVE_SYS_TYPES_H
1734#include <sys/types.h>
1735#endif
1736#ifdef HAVE_TIME_H
1737#include <time.h>
1738#endif
Fred Drakea3f6e912000-06-29 20:44:47 +00001739])
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001740
Trent Mick635f6fb2000-08-23 21:33:05 +00001741# if have pthread_t then define SIZEOF_PTHREAD_T
Martin v. Löwis123cbd22001-07-19 14:21:10 +00001742ac_save_cc="$CC"
1743if test "$ac_cv_kpthread" = "yes"
1744then CC="$CC -Kpthread"
Martin v. Löwis5f433f02003-05-05 05:05:30 +00001745elif test "$ac_cv_kthread" = "yes"
1746then CC="$CC -Kthread"
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00001747elif test "$ac_cv_pthread" = "yes"
1748then CC="$CC -pthread"
Martin v. Löwis123cbd22001-07-19 14:21:10 +00001749fi
Trent Mick635f6fb2000-08-23 21:33:05 +00001750AC_MSG_CHECKING(for pthread_t)
1751have_pthread_t=no
Matthias Klosec511b472010-05-08 11:01:39 +00001752AC_COMPILE_IFELSE([
1753 AC_LANG_PROGRAM([[#include <pthread.h>]], [[pthread_t x; x = *(pthread_t*)0;]])
1754],[have_pthread_t=yes],[])
Trent Mick635f6fb2000-08-23 21:33:05 +00001755AC_MSG_RESULT($have_pthread_t)
1756if test "$have_pthread_t" = yes ; then
Alexandre Vassalotti856782e2009-07-17 04:59:05 +00001757 AC_CHECK_SIZEOF(pthread_t, [], [
1758#ifdef HAVE_PTHREAD_H
1759#include <pthread.h>
1760#endif
Trent Mick635f6fb2000-08-23 21:33:05 +00001761 ])
Trent Mick635f6fb2000-08-23 21:33:05 +00001762fi
Martin v. Löwis123cbd22001-07-19 14:21:10 +00001763CC="$ac_save_cc"
Trent Mick635f6fb2000-08-23 21:33:05 +00001764
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001765AC_MSG_CHECKING(for --enable-toolbox-glue)
1766AC_ARG_ENABLE(toolbox-glue,
Matthias Klose22520ea2010-05-08 10:14:46 +00001767 AS_HELP_STRING([--enable-toolbox-glue], [disable/enable MacOSX glue code for extensions]))
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001768
1769if test -z "$enable_toolbox_glue"
1770then
1771 case $ac_sys_system/$ac_sys_release in
1772 Darwin/*)
1773 enable_toolbox_glue="yes";;
1774 *)
1775 enable_toolbox_glue="no";;
1776 esac
1777fi
1778case "$enable_toolbox_glue" in
1779yes)
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001780 extra_machdep_objs="Python/mactoolboxglue.o"
Raymond Hettingerec6eb362004-11-05 07:02:59 +00001781 extra_undefs="-u _PyMac_Error"
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001782 AC_DEFINE(USE_TOOLBOX_OBJECT_GLUE, 1,
1783 [Define if you want to use MacPython modules on MacOSX in unix-Python.])
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001784 ;;
1785*)
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001786 extra_machdep_objs=""
Jack Jansen591cbed2001-08-15 13:55:15 +00001787 extra_undefs=""
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001788 ;;
1789esac
1790AC_MSG_RESULT($enable_toolbox_glue)
1791
Ronald Oussoren0d236eb2008-06-06 21:31:33 +00001792
Bob Ippolito7026a0a2005-03-28 23:23:47 +00001793AC_SUBST(OTHER_LIBTOOL_OPT)
1794case $ac_sys_system/$ac_sys_release in
Anthony Baxter82201742006-04-09 15:07:40 +00001795 Darwin/@<:@01567@:>@\..*)
Bob Ippolito7026a0a2005-03-28 23:23:47 +00001796 OTHER_LIBTOOL_OPT="-prebind -seg1addr 0x10000000"
1797 ;;
1798 Darwin/*)
1799 OTHER_LIBTOOL_OPT=""
1800 ;;
1801esac
1802
Ronald Oussoren25967582009-09-06 10:00:26 +00001803
1804ARCH_RUN_32BIT=""
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001805AC_SUBST(LIBTOOL_CRUFT)
1806case $ac_sys_system/$ac_sys_release in
Anthony Baxter82201742006-04-09 15:07:40 +00001807 Darwin/@<:@01567@:>@\..*)
Ronald Oussoren988117f2006-04-29 11:31:35 +00001808 LIBTOOL_CRUFT="-framework System -lcc_dynamic"
1809 if test "${enable_universalsdk}"; then
1810 :
1811 else
Ronald Oussorenbc0e83c2010-02-11 13:26:54 +00001812 LIBTOOL_CRUFT="${LIBTOOL_CRUFT} -arch_only `/usr/bin/arch`"
Ronald Oussoren988117f2006-04-29 11:31:35 +00001813 fi
Jack Jansenb36687a2004-07-16 08:43:47 +00001814 LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -install_name $(PYTHONFRAMEWORKINSTALLDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansena3891ea2001-09-07 14:25:12 +00001815 LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -compatibility_version $(VERSION) -current_version $(VERSION)';;
Guido van Rossum5839e582000-10-09 19:52:35 +00001816 Darwin/*)
Ronald Oussorena55af9a2010-01-17 16:25:57 +00001817 gcc_version=`gcc -dumpversion`
Bob Ippolito7026a0a2005-03-28 23:23:47 +00001818 if test ${gcc_version} '<' 4.0
1819 then
1820 LIBTOOL_CRUFT="-lcc_dynamic"
1821 else
1822 LIBTOOL_CRUFT=""
1823 fi
Matthias Klosec511b472010-05-08 11:01:39 +00001824 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Ronald Oussoren25967582009-09-06 10:00:26 +00001825 #include <unistd.h>
1826 int main(int argc, char*argv[])
1827 {
1828 if (sizeof(long) == 4) {
1829 return 0;
1830 } else {
1831 return 1;
1832 }
Ronald Oussoren84ddd722009-09-08 07:17:10 +00001833 }
Matthias Klosec511b472010-05-08 11:01:39 +00001834 ]])],[ac_osx_32bit=yes],[ac_osx_32bit=no],[ac_osx_32bit=yes])
Ronald Oussoren25967582009-09-06 10:00:26 +00001835
1836 if test "${ac_osx_32bit}" = "yes"; then
Ronald Oussorenbc0e83c2010-02-11 13:26:54 +00001837 case `/usr/bin/arch` in
Ronald Oussoren25967582009-09-06 10:00:26 +00001838 i386)
1839 MACOSX_DEFAULT_ARCH="i386"
1840 ;;
1841 ppc)
1842 MACOSX_DEFAULT_ARCH="ppc"
1843 ;;
1844 *)
1845 AC_MSG_ERROR([Unexpected output of 'arch' on OSX])
1846 ;;
1847 esac
1848 else
Ronald Oussorenbc0e83c2010-02-11 13:26:54 +00001849 case `/usr/bin/arch` in
Ronald Oussoren25967582009-09-06 10:00:26 +00001850 i386)
1851 MACOSX_DEFAULT_ARCH="x86_64"
1852 ;;
1853 ppc)
1854 MACOSX_DEFAULT_ARCH="ppc64"
1855 ;;
1856 *)
1857 AC_MSG_ERROR([Unexpected output of 'arch' on OSX])
1858 ;;
1859 esac
1860
1861 #ARCH_RUN_32BIT="true"
1862 fi
1863
1864 LIBTOOL_CRUFT=$LIBTOOL_CRUFT" -lSystem -lSystemStubs -arch_only ${MACOSX_DEFAULT_ARCH}"
Jack Jansenb36687a2004-07-16 08:43:47 +00001865 LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -install_name $(PYTHONFRAMEWORKINSTALLDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001866 LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -compatibility_version $(VERSION) -current_version $(VERSION)';;
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001867esac
1868
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001869AC_MSG_CHECKING(for --enable-framework)
1870if test "$enable_framework"
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001871then
Skip Montanarodecc6a42003-01-01 20:07:49 +00001872 BASECFLAGS="$BASECFLAGS -fno-common -dynamic"
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001873 # -F. is needed to allow linking to the framework while
1874 # in the build location.
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001875 AC_DEFINE(WITH_NEXT_FRAMEWORK, 1,
1876 [Define if you want to produce an OpenStep/Rhapsody framework
1877 (shared library plus accessory files).])
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001878 AC_MSG_RESULT(yes)
Ronald Oussoren450d5612009-06-08 21:12:41 +00001879 if test $enable_shared = "yes"
1880 then
Ronald Oussoren9ebd2422009-09-29 13:00:44 +00001881 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 +00001882 fi
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001883else
1884 AC_MSG_RESULT(no)
1885fi
1886
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001887AC_MSG_CHECKING(for dyld)
Jack Jansen9a66b6d2001-08-08 13:56:14 +00001888case $ac_sys_system/$ac_sys_release in
1889 Darwin/*)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001890 AC_DEFINE(WITH_DYLD, 1,
1891 [Define if you want to use the new-style (Openstep, Rhapsody, MacOS)
1892 dynamic linker (dyld) instead of the old-style (NextStep) dynamic
1893 linker (rld). Dyld is necessary to support frameworks.])
Jack Jansen9a66b6d2001-08-08 13:56:14 +00001894 AC_MSG_RESULT(always on for Darwin)
1895 ;;
1896 *)
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001897 AC_MSG_RESULT(no)
1898 ;;
Jack Jansen9a66b6d2001-08-08 13:56:14 +00001899esac
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001900
Guido van Rossumac405f61994-09-12 10:56:06 +00001901# Set info about shared libraries.
Guido van Rossumac405f61994-09-12 10:56:06 +00001902AC_SUBST(SO)
1903AC_SUBST(LDSHARED)
Tarek Ziadé00002952010-04-03 08:37:59 +00001904AC_SUBST(LDCXXSHARED)
Neil Schemenauerb3531b82001-02-16 04:09:05 +00001905AC_SUBST(BLDSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00001906AC_SUBST(CCSHARED)
1907AC_SUBST(LINKFORSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00001908# SO is the extension of shared libraries `(including the dot!)
Guido van Rossumaef734b2001-01-10 21:09:12 +00001909# -- usually .so, .sl on HP-UX, .dll on Cygwin
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001910AC_MSG_CHECKING(SO)
Guido van Rossumac405f61994-09-12 10:56:06 +00001911if test -z "$SO"
1912then
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001913 case $ac_sys_system in
Neal Norwitz58e28882006-05-19 07:00:58 +00001914 hp*|HP*)
1915 case `uname -m` in
1916 ia64) SO=.so;;
1917 *) SO=.sl;;
1918 esac
1919 ;;
Guido van Rossumaef734b2001-01-10 21:09:12 +00001920 CYGWIN*) SO=.dll;;
Guido van Rossum4b6b5791996-09-09 20:09:34 +00001921 *) SO=.so;;
Guido van Rossumac405f61994-09-12 10:56:06 +00001922 esac
Martin v. Löwis368de8f2003-06-14 14:46:38 +00001923else
1924 # this might also be a termcap variable, see #610332
1925 echo
1926 echo '====================================================================='
1927 echo '+ +'
1928 echo '+ WARNING: You have set SO in your environment. +'
1929 echo '+ Do you really mean to change the extension for shared libraries? +'
1930 echo '+ Continuing in 10 seconds to let you to ponder. +'
1931 echo '+ +'
1932 echo '====================================================================='
1933 sleep 10
Guido van Rossumac405f61994-09-12 10:56:06 +00001934fi
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001935AC_MSG_RESULT($SO)
Ronald Oussoren79f90492009-01-02 10:44:46 +00001936
Neal Norwitz58e28882006-05-19 07:00:58 +00001937AC_DEFINE_UNQUOTED(SHLIB_EXT, "$SO", [Define this to be extension of shared libraries (including the dot!).])
Guido van Rossumac405f61994-09-12 10:56:06 +00001938# LDSHARED is the ld *command* used to create shared library
Skip Montanaroce59c042004-01-17 14:19:44 +00001939# -- "cc -G" on SunOS 5.x, "ld -shared" on IRIX 5
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001940# (Shared libraries in this instance are shared modules to be loaded into
1941# Python, as opposed to building Python itself as a shared library.)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001942AC_MSG_CHECKING(LDSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00001943if test -z "$LDSHARED"
1944then
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001945 case $ac_sys_system/$ac_sys_release in
Neil Schemenauerb3531b82001-02-16 04:09:05 +00001946 AIX*)
Georg Brandl71f4fbb2011-02-25 11:04:50 +00001947 BLDSHARED="\$(srcdir)/Modules/ld_so_aix \$(CC) -bI:\$(srcdir)/Modules/python.exp"
Guido van Rossumce608b02001-09-28 15:59:38 +00001948 LDSHARED="\$(BINLIBDEST)/config/ld_so_aix \$(CC) -bI:\$(BINLIBDEST)/config/python.exp"
Neil Schemenauerb3531b82001-02-16 04:09:05 +00001949 ;;
1950 BeOS*)
1951 BLDSHARED="\$(srcdir)/Modules/ld_so_beos $LDLIBRARY"
Guido van Rossumce608b02001-09-28 15:59:38 +00001952 LDSHARED="\$(BINLIBDEST)/config/ld_so_beos \$(LIBDIR)/$LDLIBRARY"
Neil Schemenauerb3531b82001-02-16 04:09:05 +00001953 ;;
Guido van Rossum6100aaf1997-04-29 21:48:51 +00001954 IRIX/5*) LDSHARED="ld -shared";;
Guido van Rossum91922671997-10-09 20:24:13 +00001955 IRIX*/6*) LDSHARED="ld ${SGI_ABI} -shared -all";;
Greg Ward57c9a662000-05-26 12:22:54 +00001956 SunOS/5*)
Tarek Ziadé00002952010-04-03 08:37:59 +00001957 if test "$GCC" = "yes" ; then
1958 LDSHARED='$(CC) -shared'
1959 LDCXXSHARED='$(CXX) -shared'
1960 else
1961 LDSHARED='$(CC) -G'
1962 LDCXXSHARED='$(CXX) -G'
Greg Ward57c9a662000-05-26 12:22:54 +00001963 fi ;;
Thomas Hellerdc96a772008-04-04 10:07:55 +00001964 hp*|HP*)
Tarek Ziadé00002952010-04-03 08:37:59 +00001965 if test "$GCC" = "yes" ; then
1966 LDSHARED='$(CC) -shared'
1967 LDCXXSHARED='$(CXX) -shared'
1968 else
1969 LDSHARED='ld -b'
Thomas Hellerdc96a772008-04-04 10:07:55 +00001970 fi ;;
Guido van Rossum71001e41995-01-26 00:44:03 +00001971 OSF*) LDSHARED="ld -shared -expect_unresolved \"*\"";;
Jack Jansen418c3b12001-11-14 10:59:57 +00001972 Darwin/1.3*)
Stefan Krah3a3e2032010-11-28 15:30:05 +00001973 LDSHARED='$(CC) -bundle'
1974 LDCXXSHARED='$(CXX) -bundle'
Jack Jansena3891ea2001-09-07 14:25:12 +00001975 if test "$enable_framework" ; then
1976 # Link against the framework. All externals should be defined.
Jack Jansenda49e192005-01-07 13:08:22 +00001977 BLDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
1978 LDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Tarek Ziadé00002952010-04-03 08:37:59 +00001979 LDCXXSHARED="$LDCXXSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansena3891ea2001-09-07 14:25:12 +00001980 else
1981 # No framework. Ignore undefined symbols, assuming they come from Python
Jack Jansen418c3b12001-11-14 10:59:57 +00001982 LDSHARED="$LDSHARED -undefined suppress"
Tarek Ziadé00002952010-04-03 08:37:59 +00001983 LDCXXSHARED="$LDCXXSHARED -undefined suppress"
Jack Jansena3891ea2001-09-07 14:25:12 +00001984 fi ;;
Jack Jansen6b08a402004-06-03 12:41:45 +00001985 Darwin/1.4*|Darwin/5.*|Darwin/6.*)
Stefan Krah3a3e2032010-11-28 15:30:05 +00001986 LDSHARED='$(CC) -bundle'
1987 LDCXXSHARED='$(CXX) -bundle'
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001988 if test "$enable_framework" ; then
1989 # Link against the framework. All externals should be defined.
Jack Jansenda49e192005-01-07 13:08:22 +00001990 BLDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
1991 LDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Tarek Ziadé00002952010-04-03 08:37:59 +00001992 LDCXXSHARED="$LDCXXSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001993 else
Michael W. Hudson0c46c0c2002-03-07 09:58:56 +00001994 # No framework, use the Python app as bundle-loader
1995 BLDSHARED="$LDSHARED "'-bundle_loader $(BUILDPYTHON)'
Jack Jansenc28fc372003-02-25 13:14:43 +00001996 LDSHARED="$LDSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)'
Tarek Ziadé00002952010-04-03 08:37:59 +00001997 LDCXXSHARED="$LDCXXSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)'
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001998 fi ;;
Jack Jansen6b08a402004-06-03 12:41:45 +00001999 Darwin/*)
2000 # Use -undefined dynamic_lookup whenever possible (10.3 and later).
2001 # This allows an extension to be used in any Python
Ronald Oussoren38f1b982007-09-02 09:46:07 +00002002
Ronald Oussoren5640ce22008-06-05 12:58:24 +00002003 if test ${MACOSX_DEPLOYMENT_TARGET} '>' 10.2
Jack Jansen6b08a402004-06-03 12:41:45 +00002004 then
Ronald Oussoren988117f2006-04-29 11:31:35 +00002005 if test "${enable_universalsdk}"; then
Ronald Oussoren5640ce22008-06-05 12:58:24 +00002006 LDFLAGS="${UNIVERSAL_ARCH_FLAGS} -isysroot ${UNIVERSALSDK} ${LDFLAGS}"
Ronald Oussoren988117f2006-04-29 11:31:35 +00002007 fi
Stefan Krah3a3e2032010-11-28 15:30:05 +00002008 LDSHARED='$(CC) -bundle -undefined dynamic_lookup'
2009 LDCXXSHARED='$(CXX) -bundle -undefined dynamic_lookup'
Jack Jansen6b08a402004-06-03 12:41:45 +00002010 BLDSHARED="$LDSHARED"
Jack Jansen6b08a402004-06-03 12:41:45 +00002011 else
Stefan Krah3a3e2032010-11-28 15:30:05 +00002012 LDSHARED='$(CC) -bundle'
2013 LDCXXSHARED='$(CXX) -bundle'
Jack Jansen6b08a402004-06-03 12:41:45 +00002014 if test "$enable_framework" ; then
2015 # Link against the framework. All externals should be defined.
Jack Jansenda49e192005-01-07 13:08:22 +00002016 BLDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
2017 LDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Tarek Ziadé00002952010-04-03 08:37:59 +00002018 LDCXXSHARED="$LDCXXSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansen6b08a402004-06-03 12:41:45 +00002019 else
2020 # No framework, use the Python app as bundle-loader
2021 BLDSHARED="$LDSHARED "'-bundle_loader $(BUILDPYTHON)'
2022 LDSHARED="$LDSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)'
Tarek Ziadé00002952010-04-03 08:37:59 +00002023 LDCXXSHARED="$LDCXXSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)'
Jack Jansen6b08a402004-06-03 12:41:45 +00002024 fi
2025 fi
2026 ;;
Tarek Ziadé00002952010-04-03 08:37:59 +00002027 Linux*|GNU*|QNX*)
2028 LDSHARED='$(CC) -shared'
2029 LDCXXSHARED='$(CXX) -shared';;
2030 BSD/OS*/4*)
2031 LDSHARED="gcc -shared"
2032 LDCXXSHARED="g++ -shared";;
Martin v. Löwis222c5152006-06-03 07:37:13 +00002033 FreeBSD*)
Jeremy Hylton4bcc7c52000-08-31 17:45:35 +00002034 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
Guido van Rossum0286ae82000-08-29 15:06:49 +00002035 then
Stefan Krah3a3e2032010-11-28 15:30:05 +00002036 LDSHARED='$(CC) -shared'
2037 LDCXXSHARED='$(CXX) -shared'
Guido van Rossum0286ae82000-08-29 15:06:49 +00002038 else
Stefan Krah3a3e2032010-11-28 15:30:05 +00002039 LDSHARED="ld -Bshareable"
Guido van Rossum0286ae82000-08-29 15:06:49 +00002040 fi;;
Martin v. Löwis222c5152006-06-03 07:37:13 +00002041 OpenBSD*)
2042 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
2043 then
Stefan Krah3a3e2032010-11-28 15:30:05 +00002044 LDSHARED='$(CC) -shared $(CCSHARED)'
2045 LDCXXSHARED='$(CXX) -shared $(CCSHARED)'
Martin v. Löwis222c5152006-06-03 07:37:13 +00002046 else
2047 case `uname -r` in
2048 [[01]].* | 2.[[0-7]] | 2.[[0-7]].*)
2049 LDSHARED="ld -Bshareable ${LDFLAGS}"
2050 ;;
2051 *)
Stefan Krah3a3e2032010-11-28 15:30:05 +00002052 LDSHARED='$(CC) -shared $(CCSHARED)'
2053 LDCXXSHARED='$(CXX) -shared $(CCSHARED)'
Martin v. Löwis222c5152006-06-03 07:37:13 +00002054 ;;
2055 esac
2056 fi;;
Tarek Ziadé00002952010-04-03 08:37:59 +00002057 NetBSD*|DragonFly*)
Antoine Pitroucb402772011-01-02 20:51:34 +00002058 LDSHARED='$(CC) -shared'
2059 LDCXXSHARED='$(CXX) -shared';;
Martin v. Löwis25ae43b2001-10-07 08:39:18 +00002060 OpenUNIX*|UnixWare*)
Tarek Ziadé00002952010-04-03 08:37:59 +00002061 if test "$GCC" = "yes" ; then
2062 LDSHARED='$(CC) -shared'
2063 LDCXXSHARED='$(CXX) -shared'
2064 else
2065 LDSHARED='$(CC) -G'
2066 LDCXXSHARED='$(CXX) -G'
Martin v. Löwisbec19582001-03-21 15:57:54 +00002067 fi;;
Tarek Ziadé00002952010-04-03 08:37:59 +00002068 SCO_SV*)
2069 LDSHARED='$(CC) -Wl,-G,-Bexport'
2070 LDCXXSHARED='$(CXX) -Wl,-G,-Bexport';;
2071 CYGWIN*)
2072 LDSHARED="gcc -shared -Wl,--enable-auto-image-base"
2073 LDCXXSHARED="g++ -shared -Wl,--enable-auto-image-base";;
2074 atheos*)
2075 LDSHARED="gcc -shared"
2076 LDCXXSHARED="g++ -shared";;
Guido van Rossumac405f61994-09-12 10:56:06 +00002077 *) LDSHARED="ld";;
2078 esac
Guido van Rossumac405f61994-09-12 10:56:06 +00002079fi
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002080AC_MSG_RESULT($LDSHARED)
Tarek Ziadé00002952010-04-03 08:37:59 +00002081LDCXXSHARED=${LDCXXSHARED-$LDSHARED}
Neil Schemenauerb3531b82001-02-16 04:09:05 +00002082BLDSHARED=${BLDSHARED-$LDSHARED}
Guido van Rossumac405f61994-09-12 10:56:06 +00002083# CCSHARED are the C *flags* used to create objects to go into a shared
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00002084# library (module) -- this is only needed for a few systems
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002085AC_MSG_CHECKING(CCSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00002086if test -z "$CCSHARED"
2087then
Guido van Rossum6100aaf1997-04-29 21:48:51 +00002088 case $ac_sys_system/$ac_sys_release in
Neil Schemenauer66252162001-02-19 04:47:42 +00002089 SunOS*) if test "$GCC" = yes;
Martin v. Löwiseb623572007-03-12 10:50:39 +00002090 then CCSHARED="-fPIC";
2091 elif test `uname -p` = sparc;
2092 then CCSHARED="-xcode=pic32";
2093 else CCSHARED="-Kpic";
2094 fi;;
Guido van Rossumaf07a441995-02-13 19:45:27 +00002095 hp*|HP*) if test "$GCC" = yes;
Martin v. Löwis703ad702001-09-05 08:36:52 +00002096 then CCSHARED="-fPIC";
Guido van Rossumaf07a441995-02-13 19:45:27 +00002097 else CCSHARED="+z";
2098 fi;;
Martin v. Löwisa6e97582002-01-01 18:41:33 +00002099 Linux*|GNU*) CCSHARED="-fPIC";;
Guido van Rossumf5957ea1999-10-05 21:59:33 +00002100 BSD/OS*/4*) CCSHARED="-fpic";;
Martin v. Löwis86d66262006-02-17 08:40:11 +00002101 FreeBSD*|NetBSD*|OpenBSD*|DragonFly*) CCSHARED="-fPIC";;
Martin v. Löwis25ae43b2001-10-07 08:39:18 +00002102 OpenUNIX*|UnixWare*)
Martin v. Löwisbec19582001-03-21 15:57:54 +00002103 if test "$GCC" = "yes"
2104 then CCSHARED="-fPIC"
Martin v. Löwis130fb172001-07-19 11:00:41 +00002105 else CCSHARED="-KPIC"
Martin v. Löwisbec19582001-03-21 15:57:54 +00002106 fi;;
Martin v. Löwis21ee4092002-09-30 16:19:48 +00002107 SCO_SV*)
2108 if test "$GCC" = "yes"
2109 then CCSHARED="-fPIC"
2110 else CCSHARED="-Kpic -belf"
2111 fi;;
Guido van Rossum2b5ca001998-03-05 15:41:09 +00002112 IRIX*/6*) case $CC in
2113 *gcc*) CCSHARED="-shared";;
Guido van Rossumee21f411998-04-20 18:51:54 +00002114 *) CCSHARED="";;
Guido van Rossum2b5ca001998-03-05 15:41:09 +00002115 esac;;
Martin v. Löwisf90ae202002-06-11 06:22:31 +00002116 atheos*) CCSHARED="-fPIC";;
Guido van Rossumac405f61994-09-12 10:56:06 +00002117 esac
Guido van Rossumac405f61994-09-12 10:56:06 +00002118fi
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002119AC_MSG_RESULT($CCSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00002120# LINKFORSHARED are the flags passed to the $(CC) command that links
Guido van Rossumb65a48e1995-06-14 18:21:23 +00002121# the python executable -- this is only needed for a few systems
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002122AC_MSG_CHECKING(LINKFORSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00002123if test -z "$LINKFORSHARED"
2124then
Guido van Rossum6100aaf1997-04-29 21:48:51 +00002125 case $ac_sys_system/$ac_sys_release in
Neil Schemenauerb3531b82001-02-16 04:09:05 +00002126 AIX*) LINKFORSHARED='-Wl,-bE:Modules/python.exp -lld';;
Guido van Rossum5dab3d81996-12-06 21:18:18 +00002127 hp*|HP*)
Martin v. Löwis1142de32002-03-29 16:28:31 +00002128 LINKFORSHARED="-Wl,-E -Wl,+s";;
2129# LINKFORSHARED="-Wl,-E -Wl,+s -Wl,+b\$(BINLIBDEST)/lib-dynload";;
Guido van Rossumf5957ea1999-10-05 21:59:33 +00002130 BSD/OS/4*) LINKFORSHARED="-Xlinker -export-dynamic";;
Martin v. Löwisa6e97582002-01-01 18:41:33 +00002131 Linux*|GNU*) LINKFORSHARED="-Xlinker -export-dynamic";;
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00002132 # -u libsys_s pulls in all symbols in libsys
Jack Jansenb6e9cad2001-08-15 01:26:28 +00002133 Darwin/*)
Raymond Hettingerec6eb362004-11-05 07:02:59 +00002134 # -u _PyMac_Error is needed to pull in the mac toolbox glue,
2135 # which is
Jack Jansenb6e9cad2001-08-15 01:26:28 +00002136 # not used by the core itself but which needs to be in the core so
2137 # that dynamically loaded extension modules have access to it.
Jack Jansen97e3f002003-02-23 22:59:01 +00002138 # -prebind is no longer used, because it actually seems to give a
2139 # slowdown in stead of a speedup, maybe due to the large number of
2140 # dynamic loads Python does.
Raymond Hettingerec6eb362004-11-05 07:02:59 +00002141
2142 LINKFORSHARED="$extra_undefs"
Jack Jansenb6e9cad2001-08-15 01:26:28 +00002143 if test "$enable_framework"
2144 then
Jack Jansenda49e192005-01-07 13:08:22 +00002145 LINKFORSHARED="$LINKFORSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansenb6e9cad2001-08-15 01:26:28 +00002146 fi
Raymond Hettingerec6eb362004-11-05 07:02:59 +00002147 LINKFORSHARED="$LINKFORSHARED";;
Martin v. Löwis25ae43b2001-10-07 08:39:18 +00002148 OpenUNIX*|UnixWare*) LINKFORSHARED="-Wl,-Bexport";;
Martin v. Löwis21ee4092002-09-30 16:19:48 +00002149 SCO_SV*) LINKFORSHARED="-Wl,-Bexport";;
Fred Drake02706f52000-09-25 15:08:46 +00002150 ReliantUNIX*) LINKFORSHARED="-W1 -Blargedynsym";;
Martin v. Löwis86d66262006-02-17 08:40:11 +00002151 FreeBSD*|NetBSD*|OpenBSD*|DragonFly*)
Guido van Rossumdf693651999-01-07 21:50:41 +00002152 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
2153 then
2154 LINKFORSHARED="-Wl,--export-dynamic"
2155 fi;;
Guido van Rossum2b5ca001998-03-05 15:41:09 +00002156 SunOS/5*) case $CC in
2157 *gcc*)
Martin v. Löwisa4548572002-04-18 14:51:36 +00002158 if $CC -Xlinker --help 2>&1 | grep export-dynamic >/dev/null
Guido van Rossum8f4ceb11997-12-18 23:42:19 +00002159 then
2160 LINKFORSHARED="-Xlinker --export-dynamic"
Guido van Rossum2b5ca001998-03-05 15:41:09 +00002161 fi;;
2162 esac;;
Jason Tishler30765592003-09-04 11:04:06 +00002163 CYGWIN*)
2164 if test $enable_shared = "no"
2165 then
2166 LINKFORSHARED='-Wl,--out-implib=$(LDLIBRARY)'
2167 fi;;
Martin v. Löwis8c255e42008-05-23 15:06:50 +00002168 QNX*)
2169 # -Wl,-E causes the symbols to be added to the dynamic
2170 # symbol table so that they can be found when a module
2171 # is loaded. -N 2048K causes the stack size to be set
2172 # to 2048 kilobytes so that the stack doesn't overflow
2173 # when running test_compile.py.
2174 LINKFORSHARED='-Wl,-E -N 2048K';;
Guido van Rossumac405f61994-09-12 10:56:06 +00002175 esac
Guido van Rossumac405f61994-09-12 10:56:06 +00002176fi
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002177AC_MSG_RESULT($LINKFORSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00002178
Ronald Oussoren0d236eb2008-06-06 21:31:33 +00002179
Neil Schemenauer61c51152001-01-26 16:18:16 +00002180AC_SUBST(CFLAGSFORSHARED)
2181AC_MSG_CHECKING(CFLAGSFORSHARED)
2182if test ! "$LIBRARY" = "$LDLIBRARY"
2183then
Neil Schemenauerd9cf41c2001-01-27 21:39:17 +00002184 case $ac_sys_system in
2185 CYGWIN*)
2186 # Cygwin needs CCSHARED when building extension DLLs
2187 # but not when building the interpreter DLL.
2188 CFLAGSFORSHARED='';;
2189 *)
2190 CFLAGSFORSHARED='$(CCSHARED)'
2191 esac
Neil Schemenauer61c51152001-01-26 16:18:16 +00002192fi
2193AC_MSG_RESULT($CFLAGSFORSHARED)
2194
Martin v. Löwisf90ae202002-06-11 06:22:31 +00002195# SHLIBS are libraries (except -lc and -lm) to link to the python shared
2196# library (with --enable-shared).
2197# For platforms on which shared libraries are not allowed to have unresolved
Martin v. Löwisd6359c52002-08-04 12:38:50 +00002198# symbols, this must be set to $(LIBS) (expanded by make). We do this even
2199# if it is not required, since it creates a dependency of the shared library
2200# to LIBS. This, in turn, means that applications linking the shared libpython
2201# don't need to link LIBS explicitly. The default should be only changed
2202# on systems where this approach causes problems.
Martin v. Löwisf90ae202002-06-11 06:22:31 +00002203AC_SUBST(SHLIBS)
2204AC_MSG_CHECKING(SHLIBS)
2205case "$ac_sys_system" in
Martin v. Löwisf90ae202002-06-11 06:22:31 +00002206 *)
Martin v. Löwisd6359c52002-08-04 12:38:50 +00002207 SHLIBS='$(LIBS)';;
Martin v. Löwisf90ae202002-06-11 06:22:31 +00002208esac
2209AC_MSG_RESULT($SHLIBS)
2210
2211
Guido van Rossum627b2d71993-12-24 10:39:16 +00002212# checks for libraries
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002213AC_CHECK_LIB(dl, dlopen) # Dynamic linking for SunOS/Solaris and SYSV
2214AC_CHECK_LIB(dld, shl_load) # Dynamic linking for HP-UX
Martin v. Löwis519adae2003-09-20 10:47:47 +00002215
Skip Montanaro4d756af2008-12-01 01:55:22 +00002216# only check for sem_init if thread support is requested
Martin v. Löwis519adae2003-09-20 10:47:47 +00002217if test "$with_threads" = "yes" -o -z "$with_threads"; then
2218 AC_SEARCH_LIBS(sem_init, pthread rt posix4) # 'Real Time' functions on Solaris
2219 # posix4 on Solaris 2.6
2220 # pthread (first!) on Linux
2221fi
2222
Martin v. Löwis19d17342003-06-14 21:03:05 +00002223# check if we need libintl for locale functions
2224AC_CHECK_LIB(intl, textdomain,
2225 AC_DEFINE(WITH_LIBINTL, 1,
2226 [Define to 1 if libintl is needed for locale functions.]))
Guido van Rossum0eefa3f1999-11-16 15:57:37 +00002227
2228# checks for system dependent C++ extensions support
2229case "$ac_sys_system" in
2230 AIX*) AC_MSG_CHECKING(for genuine AIX C++ extensions support)
Matthias Klosec511b472010-05-08 11:01:39 +00002231 AC_LINK_IFELSE([
Georg Brandl94800df2011-02-25 11:09:02 +00002232 AC_LANG_PROGRAM([[#include <load.h>]],
Matthias Klosec511b472010-05-08 11:01:39 +00002233 [[loadAndInit("", 0, "")]])
2234 ],[
2235 AC_DEFINE(AIX_GENUINE_CPLUSPLUS, 1,
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002236 [Define for AIX if your compiler is a genuine IBM xlC/xlC_r
2237 and you want support for AIX C++ shared extension modules.])
Matthias Klosec511b472010-05-08 11:01:39 +00002238 AC_MSG_RESULT(yes)
2239 ],[
2240 AC_MSG_RESULT(no)
2241 ]);;
Guido van Rossum0eefa3f1999-11-16 15:57:37 +00002242 *) ;;
2243esac
2244
Guido van Rossum70c7f481998-03-26 18:44:10 +00002245# Most SVR4 platforms (e.g. Solaris) need -lsocket and -lnsl.
Guido van Rossumec95c7b1998-08-04 17:59:56 +00002246# BeOS' sockets are stashed in libnet.
Guido van Rossumf618d2c1995-01-17 16:36:13 +00002247AC_CHECK_LIB(nsl, t_open, [LIBS="-lnsl $LIBS"]) # SVR4
Guido van Rossumf618d2c1995-01-17 16:36:13 +00002248AC_CHECK_LIB(socket, socket, [LIBS="-lsocket $LIBS"], [], $LIBS) # SVR4 sockets
Skip Montanarob9949db2004-01-17 04:04:13 +00002249
Jeremy Hyltoncb25d5e2000-07-27 21:23:28 +00002250case "$ac_sys_system" in
2251BeOS*)
Guido van Rossumec95c7b1998-08-04 17:59:56 +00002252AC_CHECK_LIB(net, socket, [LIBS="-lnet $LIBS"], [], $LIBS) # BeOS
2253;;
2254esac
Guido van Rossum70c7f481998-03-26 18:44:10 +00002255
Guido van Rossumc5a39031996-07-31 17:35:03 +00002256AC_MSG_CHECKING(for --with-libs)
Barry Warsawc0d24d82000-06-29 16:12:00 +00002257AC_ARG_WITH(libs,
Matthias Klose22520ea2010-05-08 10:14:46 +00002258 AS_HELP_STRING([--with-libs='lib1 ...'], [link against additional libs]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002259[
Guido van Rossumc5a39031996-07-31 17:35:03 +00002260AC_MSG_RESULT($withval)
2261LIBS="$withval $LIBS"
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002262],
2263[AC_MSG_RESULT(no)])
Guido van Rossum627b2d71993-12-24 10:39:16 +00002264
Benjamin Petersone9e07bf2010-03-09 21:46:54 +00002265AC_PATH_TOOL([PKG_CONFIG], [pkg-config])
2266
Benjamin Peterson2c196742009-12-31 03:17:18 +00002267# Check for use of the system expat library
2268AC_MSG_CHECKING(for --with-system-expat)
2269AC_ARG_WITH(system_expat,
Benjamin Petersonf2d1b2a2010-10-31 16:53:53 +00002270 AS_HELP_STRING([--with-system-expat], [build pyexpat module using an installed expat library]),
2271 [],
2272 [with_system_expat="no"])
Benjamin Peterson2c196742009-12-31 03:17:18 +00002273
2274AC_MSG_RESULT($with_system_expat)
2275
Martin v. Löwis9176fc12006-04-11 11:12:43 +00002276# Check for use of the system libffi library
2277AC_MSG_CHECKING(for --with-system-ffi)
2278AC_ARG_WITH(system_ffi,
Benjamin Petersonf2d1b2a2010-10-31 16:53:53 +00002279 AS_HELP_STRING([--with-system-ffi], [build _ctypes module using an installed ffi library]),
2280 [],
2281 [with_system_ffi="no"])
Martin v. Löwis9176fc12006-04-11 11:12:43 +00002282
Benjamin Petersone9e07bf2010-03-09 21:46:54 +00002283if test "$with_system_ffi" = "yes" && test -n "$PKG_CONFIG"; then
Benjamin Peterson1c335e62010-01-01 15:16:29 +00002284 LIBFFI_INCLUDEDIR="`"$PKG_CONFIG" libffi --cflags-only-I 2>/dev/null | sed -e 's/^-I//;s/ *$//'`"
2285else
2286 LIBFFI_INCLUDEDIR=""
2287fi
2288AC_SUBST(LIBFFI_INCLUDEDIR)
2289
Martin v. Löwis9176fc12006-04-11 11:12:43 +00002290AC_MSG_RESULT($with_system_ffi)
2291
Matthias Klose10cbe482009-04-29 17:18:19 +00002292# Check for --with-dbmliborder
2293AC_MSG_CHECKING(for --with-dbmliborder)
2294AC_ARG_WITH(dbmliborder,
Matthias Klose22520ea2010-05-08 10:14:46 +00002295 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 +00002296[
2297if test x$with_dbmliborder = xyes
2298then
2299AC_MSG_ERROR([proper usage is --with-dbmliborder=db1:db2:...])
2300else
2301 for db in `echo $with_dbmliborder | sed 's/:/ /g'`; do
2302 if test x$db != xndbm && test x$db != xgdbm && test x$db != xbdb
2303 then
2304 AC_MSG_ERROR([proper usage is --with-dbmliborder=db1:db2:...])
2305 fi
2306 done
Matthias Klose61dbdb92009-04-29 20:09:50 +00002307fi])
2308AC_MSG_RESULT($with_dbmliborder)
Matthias Klose10cbe482009-04-29 17:18:19 +00002309
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00002310# Determine if signalmodule should be used.
2311AC_SUBST(USE_SIGNAL_MODULE)
2312AC_SUBST(SIGNAL_OBJS)
2313AC_MSG_CHECKING(for --with-signal-module)
2314AC_ARG_WITH(signal-module,
Matthias Klose22520ea2010-05-08 10:14:46 +00002315 AS_HELP_STRING([--with-signal-module], [disable/enable signal module]))
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00002316
2317if test -z "$with_signal_module"
2318then with_signal_module="yes"
2319fi
2320AC_MSG_RESULT($with_signal_module)
2321
2322if test "${with_signal_module}" = "yes"; then
2323 USE_SIGNAL_MODULE=""
2324 SIGNAL_OBJS=""
2325else
2326 USE_SIGNAL_MODULE="#"
2327 SIGNAL_OBJS="Parser/intrcheck.o Python/sigcheck.o"
2328fi
2329
Guido van Rossum3d15bd82001-01-10 18:53:48 +00002330# This is used to generate Setup.config
Guido van Rossum009f7871997-12-04 00:51:42 +00002331AC_SUBST(USE_THREAD_MODULE)
Barry Warsawc0d24d82000-06-29 16:12:00 +00002332USE_THREAD_MODULE=""
Guido van Rossum009f7871997-12-04 00:51:42 +00002333
Guido van Rossum54d93d41997-01-22 20:51:58 +00002334AC_MSG_CHECKING(for --with-dec-threads)
2335AC_SUBST(LDLAST)
2336AC_ARG_WITH(dec-threads,
Matthias Klose22520ea2010-05-08 10:14:46 +00002337 AS_HELP_STRING([--with-dec-threads], [use DEC Alpha/OSF1 thread-safe libraries]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002338[
Barry Warsawc0d24d82000-06-29 16:12:00 +00002339AC_MSG_RESULT($withval)
Guido van Rossum54d93d41997-01-22 20:51:58 +00002340LDLAST=-threads
Guido van Rossumf78abae1997-01-21 22:02:36 +00002341if test "${with_thread+set}" != set; then
Guido van Rossum54d93d41997-01-22 20:51:58 +00002342 with_thread="$withval";
2343fi],
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002344[AC_MSG_RESULT(no)])
Guido van Rossum54d93d41997-01-22 20:51:58 +00002345
Martin v. Löwis11437992002-04-12 09:54:03 +00002346# Templates for things AC_DEFINEd more than once.
2347# For a single AC_DEFINE, no template is needed.
2348AH_TEMPLATE(C_THREADS,[Define if you have the Mach cthreads package])
2349AH_TEMPLATE(_REENTRANT,
2350 [Define to force use of thread-safe errno, h_errno, and other functions])
2351AH_TEMPLATE(WITH_THREAD,
2352 [Define if you want to compile in rudimentary thread support])
2353
Guido van Rossum54d93d41997-01-22 20:51:58 +00002354AC_MSG_CHECKING(for --with-threads)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002355dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
Barry Warsawc0d24d82000-06-29 16:12:00 +00002356AC_ARG_WITH(threads,
Matthias Klose22520ea2010-05-08 10:14:46 +00002357 AS_HELP_STRING([--with(out)-threads@<:@=DIRECTORY@:>@], [disable/enable thread support]))
Guido van Rossum54d93d41997-01-22 20:51:58 +00002358
Barry Warsawc0d24d82000-06-29 16:12:00 +00002359# --with-thread is deprecated, but check for it anyway
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002360dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
Barry Warsawa0f3c5c2000-06-30 16:39:35 +00002361AC_ARG_WITH(thread,
Matthias Klose22520ea2010-05-08 10:14:46 +00002362 AS_HELP_STRING([--with(out)-thread@<:@=DIRECTORY@:>@], [deprecated; use --with(out)-threads]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002363 [with_threads=$with_thread])
Barry Warsawc0d24d82000-06-29 16:12:00 +00002364
2365if test -z "$with_threads"
2366then with_threads="yes"
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002367fi
Barry Warsawc0d24d82000-06-29 16:12:00 +00002368AC_MSG_RESULT($with_threads)
Guido van Rossum6400c261997-05-22 20:34:27 +00002369
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002370AC_SUBST(THREADOBJ)
Barry Warsawc0d24d82000-06-29 16:12:00 +00002371if test "$with_threads" = "no"
2372then
2373 USE_THREAD_MODULE="#"
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002374elif test "$ac_cv_pthread_is_default" = yes
2375then
2376 AC_DEFINE(WITH_THREAD)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002377 # Defining _REENTRANT on system with POSIX threads should not hurt.
2378 AC_DEFINE(_REENTRANT)
2379 posix_threads=yes
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002380 THREADOBJ="Python/thread.o"
Martin v. Löwis130fb172001-07-19 11:00:41 +00002381elif test "$ac_cv_kpthread" = "yes"
2382then
2383 CC="$CC -Kpthread"
Martin v. Löwis519adae2003-09-20 10:47:47 +00002384 if test "$ac_cv_cxx_thread" = "yes"; then
2385 CXX="$CXX -Kpthread"
2386 fi
Martin v. Löwis130fb172001-07-19 11:00:41 +00002387 AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002388 posix_threads=yes
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002389 THREADOBJ="Python/thread.o"
Martin v. Löwis5f433f02003-05-05 05:05:30 +00002390elif test "$ac_cv_kthread" = "yes"
2391then
2392 CC="$CC -Kthread"
Martin v. Löwis519adae2003-09-20 10:47:47 +00002393 if test "$ac_cv_cxx_thread" = "yes"; then
2394 CXX="$CXX -Kthread"
2395 fi
Martin v. Löwis5f433f02003-05-05 05:05:30 +00002396 AC_DEFINE(WITH_THREAD)
2397 posix_threads=yes
2398 THREADOBJ="Python/thread.o"
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002399elif test "$ac_cv_pthread" = "yes"
2400then
2401 CC="$CC -pthread"
Martin v. Löwis519adae2003-09-20 10:47:47 +00002402 if test "$ac_cv_cxx_thread" = "yes"; then
2403 CXX="$CXX -pthread"
2404 fi
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002405 AC_DEFINE(WITH_THREAD)
2406 posix_threads=yes
2407 THREADOBJ="Python/thread.o"
Barry Warsawc0d24d82000-06-29 16:12:00 +00002408else
Martin v. Löwis130fb172001-07-19 11:00:41 +00002409 if test ! -z "$with_threads" -a -d "$with_threads"
2410 then LDFLAGS="$LDFLAGS -L$with_threads"
2411 fi
2412 if test ! -z "$withval" -a -d "$withval"
2413 then LDFLAGS="$LDFLAGS -L$withval"
2414 fi
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002415
2416 # According to the POSIX spec, a pthreads implementation must
Matthias Klosea2542be2004-08-16 11:35:51 +00002417 # define _POSIX_THREADS in unistd.h. Some apparently don't
2418 # (e.g. gnu pth with pthread emulation)
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002419 AC_MSG_CHECKING(for _POSIX_THREADS in unistd.h)
2420 AC_EGREP_CPP(yes,
Neal Norwitz6eb37f02003-02-23 23:28:15 +00002421 [
2422#include <unistd.h>
2423#ifdef _POSIX_THREADS
2424yes
2425#endif
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002426 ], unistd_defines_pthreads=yes, unistd_defines_pthreads=no)
2427 AC_MSG_RESULT($unistd_defines_pthreads)
2428
Martin v. Löwis130fb172001-07-19 11:00:41 +00002429 AC_DEFINE(_REENTRANT)
Martin v. Löwisa6e97582002-01-01 18:41:33 +00002430 AC_CHECK_HEADER(cthreads.h, [AC_DEFINE(WITH_THREAD)
2431 AC_DEFINE(C_THREADS)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002432 AC_DEFINE(HURD_C_THREADS, 1,
2433 [Define if you are using Mach cthreads directly under /include])
Martin v. Löwisa6e97582002-01-01 18:41:33 +00002434 LIBS="$LIBS -lthreads"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002435 THREADOBJ="Python/thread.o"],[
Martin v. Löwis130fb172001-07-19 11:00:41 +00002436 AC_CHECK_HEADER(mach/cthreads.h, [AC_DEFINE(WITH_THREAD)
2437 AC_DEFINE(C_THREADS)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002438 AC_DEFINE(MACH_C_THREADS, 1,
2439 [Define if you are using Mach cthreads under mach /])
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002440 THREADOBJ="Python/thread.o"],[
Martin v. Löwis130fb172001-07-19 11:00:41 +00002441 AC_MSG_CHECKING(for --with-pth)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002442 AC_ARG_WITH([pth],
Matthias Klose22520ea2010-05-08 10:14:46 +00002443 AS_HELP_STRING([--with-pth], [use GNU pth threading libraries]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002444 [AC_MSG_RESULT($withval)
2445 AC_DEFINE([WITH_THREAD])
2446 AC_DEFINE([HAVE_PTH], 1,
2447 [Define if you have GNU PTH threads.])
2448 LIBS="-lpth $LIBS"
2449 THREADOBJ="Python/thread.o"],
2450 [AC_MSG_RESULT(no)
Martin v. Löwis8158b5a2001-10-08 13:17:28 +00002451
2452 # Just looking for pthread_create in libpthread is not enough:
2453 # on HP/UX, pthread.h renames pthread_create to a different symbol name.
2454 # So we really have to include pthread.h, and then link.
2455 _libs=$LIBS
2456 LIBS="$LIBS -lpthread"
2457 AC_MSG_CHECKING([for pthread_create in -lpthread])
Stefan Krahae66ca62012-11-22 22:36:57 +01002458 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
2459#include <stdio.h>
2460#include <pthread.h>
Martin v. Löwis8158b5a2001-10-08 13:17:28 +00002461
Matthias Klosec511b472010-05-08 11:01:39 +00002462void * start_routine (void *arg) { exit (0); }]], [[
2463pthread_create (NULL, NULL, start_routine, NULL)]])],[
Martin v. Löwis8158b5a2001-10-08 13:17:28 +00002464 AC_MSG_RESULT(yes)
2465 AC_DEFINE(WITH_THREAD)
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002466 posix_threads=yes
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002467 THREADOBJ="Python/thread.o"],[
Martin v. Löwis8158b5a2001-10-08 13:17:28 +00002468 LIBS=$_libs
Martin v. Löwis130fb172001-07-19 11:00:41 +00002469 AC_CHECK_FUNC(pthread_detach, [AC_DEFINE(WITH_THREAD)
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002470 posix_threads=yes
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002471 THREADOBJ="Python/thread.o"],[
Martin v. Löwisf90ae202002-06-11 06:22:31 +00002472 AC_CHECK_HEADER(atheos/threads.h, [AC_DEFINE(WITH_THREAD)
2473 AC_DEFINE(ATHEOS_THREADS, 1,
2474 [Define this if you have AtheOS threads.])
2475 THREADOBJ="Python/thread.o"],[
Martin v. Löwis130fb172001-07-19 11:00:41 +00002476 AC_CHECK_HEADER(kernel/OS.h, [AC_DEFINE(WITH_THREAD)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002477 AC_DEFINE(BEOS_THREADS, 1,
2478 [Define this if you have BeOS threads.])
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002479 THREADOBJ="Python/thread.o"],[
Martin v. Löwis130fb172001-07-19 11:00:41 +00002480 AC_CHECK_LIB(pthreads, pthread_create, [AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002481 posix_threads=yes
Martin v. Löwis130fb172001-07-19 11:00:41 +00002482 LIBS="$LIBS -lpthreads"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002483 THREADOBJ="Python/thread.o"], [
Martin v. Löwis130fb172001-07-19 11:00:41 +00002484 AC_CHECK_LIB(c_r, pthread_create, [AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002485 posix_threads=yes
Martin v. Löwis130fb172001-07-19 11:00:41 +00002486 LIBS="$LIBS -lc_r"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002487 THREADOBJ="Python/thread.o"], [
Martin v. Löwis130fb172001-07-19 11:00:41 +00002488 AC_CHECK_LIB(pthread, __pthread_create_system, [AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002489 posix_threads=yes
Martin v. Löwis130fb172001-07-19 11:00:41 +00002490 LIBS="$LIBS -lpthread"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002491 THREADOBJ="Python/thread.o"], [
Martin v. Löwis130fb172001-07-19 11:00:41 +00002492 AC_CHECK_LIB(cma, pthread_create, [AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002493 posix_threads=yes
Martin v. Löwis130fb172001-07-19 11:00:41 +00002494 LIBS="$LIBS -lcma"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002495 THREADOBJ="Python/thread.o"],[
Martin v. Löwis130fb172001-07-19 11:00:41 +00002496 USE_THREAD_MODULE="#"])
Skip Montanarof8712e52004-01-17 03:04:46 +00002497 ])])])])])])])])])])
Barry Warsawc0d24d82000-06-29 16:12:00 +00002498
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002499 AC_CHECK_LIB(mpc, usconfig, [AC_DEFINE(WITH_THREAD)
2500 LIBS="$LIBS -lmpc"
2501 THREADOBJ="Python/thread.o"
2502 USE_THREAD_MODULE=""])
2503
2504 if test "$posix_threads" != "yes"; then
2505 AC_CHECK_LIB(thread, thr_create, [AC_DEFINE(WITH_THREAD)
2506 LIBS="$LIBS -lthread"
2507 THREADOBJ="Python/thread.o"
2508 USE_THREAD_MODULE=""])
2509 fi
2510
2511 if test "$USE_THREAD_MODULE" != "#"
2512 then
2513 # If the above checks didn't disable threads, (at least) OSF1
2514 # needs this '-threads' argument during linking.
2515 case $ac_sys_system in
2516 OSF1) LDLAST=-threads;;
2517 esac
2518 fi
2519fi
2520
2521if test "$posix_threads" = "yes"; then
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002522 if test "$unistd_defines_pthreads" = "no"; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002523 AC_DEFINE(_POSIX_THREADS, 1,
2524 [Define if you have POSIX threads,
2525 and your system does not define that.])
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002526 fi
2527
Martin v. Löwisdfc33fd2003-01-21 10:14:41 +00002528 # Bug 662787: Using semaphores causes unexplicable hangs on Solaris 8.
2529 case $ac_sys_system/$ac_sys_release in
Charles-François Natali4929eb92011-07-21 19:41:04 +02002530 SunOS/5.6) AC_DEFINE(HAVE_PTHREAD_DESTRUCTOR, 1,
Matthias Klose5183ebd2010-04-24 16:38:36 +00002531 [Defined for Solaris 2.6 bug in pthread header.])
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002532 ;;
Martin v. Löwisdfc33fd2003-01-21 10:14:41 +00002533 SunOS/5.8) AC_DEFINE(HAVE_BROKEN_POSIX_SEMAPHORES, 1,
Matthias Klose5183ebd2010-04-24 16:38:36 +00002534 [Define if the Posix semaphores do not work on your system])
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002535 ;;
Charles-François Natali4929eb92011-07-21 19:41:04 +02002536 AIX/*) AC_DEFINE(HAVE_BROKEN_POSIX_SEMAPHORES, 1,
Matthias Klose5183ebd2010-04-24 16:38:36 +00002537 [Define if the Posix semaphores do not work on your system])
Christian Heimescba36bb2008-01-30 22:54:18 +00002538 ;;
Martin v. Löwisdfc33fd2003-01-21 10:14:41 +00002539 esac
2540
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002541 AC_MSG_CHECKING(if PTHREAD_SCOPE_SYSTEM is supported)
2542 AC_CACHE_VAL(ac_cv_pthread_system_supported,
Stefan Krahae66ca62012-11-22 22:36:57 +01002543 [AC_RUN_IFELSE([AC_LANG_SOURCE([[
2544 #include <stdio.h>
2545 #include <pthread.h>
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002546 void *foo(void *parm) {
2547 return NULL;
2548 }
2549 main() {
2550 pthread_attr_t attr;
Martin v. Löwisa82d3472002-02-24 16:05:05 +00002551 pthread_t id;
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002552 if (pthread_attr_init(&attr)) exit(-1);
2553 if (pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM)) exit(-1);
Martin v. Löwisa82d3472002-02-24 16:05:05 +00002554 if (pthread_create(&id, &attr, foo, NULL)) exit(-1);
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002555 exit(0);
Matthias Klosec511b472010-05-08 11:01:39 +00002556 }]])],
2557 [ac_cv_pthread_system_supported=yes],
2558 [ac_cv_pthread_system_supported=no],
2559 [ac_cv_pthread_system_supported=no])
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002560 ])
2561 AC_MSG_RESULT($ac_cv_pthread_system_supported)
2562 if test "$ac_cv_pthread_system_supported" = "yes"; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002563 AC_DEFINE(PTHREAD_SYSTEM_SCHED_SUPPORTED, 1, [Defined if PTHREAD_SCOPE_SYSTEM supported.])
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002564 fi
Jason Tishlerfac083d2003-07-22 15:20:49 +00002565 AC_CHECK_FUNCS(pthread_sigmask,
2566 [case $ac_sys_system in
2567 CYGWIN*)
2568 AC_DEFINE(HAVE_BROKEN_PTHREAD_SIGMASK, 1,
2569 [Define if pthread_sigmask() does not work on your system.])
2570 ;;
2571 esac])
Barry Warsawc0d24d82000-06-29 16:12:00 +00002572fi
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002573
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002574
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002575# Check for enable-ipv6
Martin v. Löwis11437992002-04-12 09:54:03 +00002576AH_TEMPLATE(ENABLE_IPV6, [Define if --enable-ipv6 is specified])
Martin v. Löwisa5f8bb52001-09-05 08:22:34 +00002577AC_MSG_CHECKING([if --enable-ipv6 is specified])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002578AC_ARG_ENABLE(ipv6,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002579[ --enable-ipv6 Enable ipv6 (with ipv4) support
2580 --disable-ipv6 Disable ipv6 support],
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002581[ case "$enableval" in
2582 no)
2583 AC_MSG_RESULT(no)
2584 ipv6=no
2585 ;;
2586 *) AC_MSG_RESULT(yes)
2587 AC_DEFINE(ENABLE_IPV6)
2588 ipv6=yes
2589 ;;
2590 esac ],
2591
Martin v. Löwisa5f8bb52001-09-05 08:22:34 +00002592[
2593dnl the check does not work on cross compilation case...
Charles-François Natalibe2b9072013-01-08 19:47:00 +01002594 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ /* AF_INET6 available check */
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002595#include <sys/types.h>
Charles-François Natalibe2b9072013-01-08 19:47:00 +01002596#include <sys/socket.h>]],
2597[[int domain = AF_INET6;]])],[
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002598 AC_MSG_RESULT(yes)
Matthias Klosec511b472010-05-08 11:01:39 +00002599 ipv6=yes
2600],[
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002601 AC_MSG_RESULT(no)
2602 ipv6=no
Matthias Klosec511b472010-05-08 11:01:39 +00002603])
Martin v. Löwisa5f8bb52001-09-05 08:22:34 +00002604
2605if test "$ipv6" = "yes"; then
2606 AC_MSG_CHECKING(if RFC2553 API is available)
Matthias Klosec511b472010-05-08 11:01:39 +00002607 AC_COMPILE_IFELSE([
2608 AC_LANG_PROGRAM([[#include <sys/types.h>
2609#include <netinet/in.h>]],
2610 [[struct sockaddr_in6 x;
2611 x.sin6_scope_id;]])
2612 ],[
2613 AC_MSG_RESULT(yes)
2614 ipv6=yes
2615 ],[
2616 AC_MSG_RESULT(no, IPv6 disabled)
2617 ipv6=no
2618 ])
Martin v. Löwisa5f8bb52001-09-05 08:22:34 +00002619fi
2620
2621if test "$ipv6" = "yes"; then
2622 AC_DEFINE(ENABLE_IPV6)
2623fi
2624])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002625
2626ipv6type=unknown
2627ipv6lib=none
2628ipv6trylibc=no
2629
2630if test "$ipv6" = "yes"; then
2631 AC_MSG_CHECKING([ipv6 stack type])
Guido van Rossumb8552162001-09-05 14:58:11 +00002632 for i in inria kame linux-glibc linux-inet6 solaris toshiba v6d zeta;
2633 do
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002634 case $i in
2635 inria)
2636 dnl http://www.kame.net/
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002637 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002638#include <netinet/in.h>
2639#ifdef IPV6_INRIA_VERSION
2640yes
2641#endif],
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002642 [ipv6type=$i])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002643 ;;
2644 kame)
2645 dnl http://www.kame.net/
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002646 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002647#include <netinet/in.h>
2648#ifdef __KAME__
2649yes
2650#endif],
2651 [ipv6type=$i;
2652 ipv6lib=inet6
2653 ipv6libdir=/usr/local/v6/lib
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002654 ipv6trylibc=yes])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002655 ;;
2656 linux-glibc)
2657 dnl http://www.v6.linux.or.jp/
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002658 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002659#include <features.h>
2660#if defined(__GLIBC__) && ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1) || (__GLIBC__ > 2))
2661yes
2662#endif],
2663 [ipv6type=$i;
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002664 ipv6trylibc=yes])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002665 ;;
2666 linux-inet6)
2667 dnl http://www.v6.linux.or.jp/
2668 if test -d /usr/inet6; then
2669 ipv6type=$i
2670 ipv6lib=inet6
2671 ipv6libdir=/usr/inet6/lib
Skip Montanarodecc6a42003-01-01 20:07:49 +00002672 BASECFLAGS="-I/usr/inet6/include $BASECFLAGS"
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002673 fi
2674 ;;
2675 solaris)
2676 if test -f /etc/netconfig; then
Antoine Pitrou31e85952011-01-03 18:57:14 +00002677 if $GREP -q tcp6 /etc/netconfig; then
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002678 ipv6type=$i
2679 ipv6trylibc=yes
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002680 fi
2681 fi
2682 ;;
2683 toshiba)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002684 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002685#include <sys/param.h>
2686#ifdef _TOSHIBA_INET6
2687yes
2688#endif],
2689 [ipv6type=$i;
2690 ipv6lib=inet6;
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002691 ipv6libdir=/usr/local/v6/lib])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002692 ;;
2693 v6d)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002694 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002695#include </usr/local/v6/include/sys/v6config.h>
2696#ifdef __V6D__
2697yes
2698#endif],
2699 [ipv6type=$i;
2700 ipv6lib=v6;
2701 ipv6libdir=/usr/local/v6/lib;
Skip Montanarodecc6a42003-01-01 20:07:49 +00002702 BASECFLAGS="-I/usr/local/v6/include $BASECFLAGS"])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002703 ;;
2704 zeta)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002705 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002706#include <sys/param.h>
2707#ifdef _ZETA_MINAMI_INET6
2708yes
2709#endif],
2710 [ipv6type=$i;
2711 ipv6lib=inet6;
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002712 ipv6libdir=/usr/local/v6/lib])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002713 ;;
2714 esac
2715 if test "$ipv6type" != "unknown"; then
2716 break
2717 fi
2718 done
2719 AC_MSG_RESULT($ipv6type)
2720fi
2721
2722if test "$ipv6" = "yes" -a "$ipv6lib" != "none"; then
2723 if test -d $ipv6libdir -a -f $ipv6libdir/lib$ipv6lib.a; then
2724 LIBS="-L$ipv6libdir -l$ipv6lib $LIBS"
2725 echo "using lib$ipv6lib"
2726 else
2727 if test $ipv6trylibc = "yes"; then
2728 echo "using libc"
2729 else
2730 echo 'Fatal: no $ipv6lib library found. cannot continue.'
2731 echo "You need to fetch lib$ipv6lib.a from appropriate"
2732 echo 'ipv6 kit and compile beforehand.'
2733 exit 1
2734 fi
2735 fi
2736fi
2737
Ronald Oussoren0d236eb2008-06-06 21:31:33 +00002738AC_MSG_CHECKING(for OSX 10.5 SDK or later)
Matthias Klosec511b472010-05-08 11:01:39 +00002739AC_COMPILE_IFELSE([
Mark Dickinson0712b562010-05-08 19:13:21 +00002740 AC_LANG_PROGRAM([[#include <Carbon/Carbon.h>]], [[FSIORefNum fRef = 0]])
Matthias Klosec511b472010-05-08 11:01:39 +00002741],[
Matthias Klose5183ebd2010-04-24 16:38:36 +00002742 AC_DEFINE(HAVE_OSX105_SDK, 1, [Define if compiling using MacOS X 10.5 SDK or later.])
Matthias Klosec511b472010-05-08 11:01:39 +00002743 AC_MSG_RESULT(yes)
2744],[
Ronald Oussoren0d236eb2008-06-06 21:31:33 +00002745 AC_MSG_RESULT(no)
Matthias Klosec511b472010-05-08 11:01:39 +00002746])
Ronald Oussoren0d236eb2008-06-06 21:31:33 +00002747
Martin v. Löwisa3fb4f72002-06-09 13:33:54 +00002748# Check for --with-doc-strings
2749AC_MSG_CHECKING(for --with-doc-strings)
2750AC_ARG_WITH(doc-strings,
Matthias Klose22520ea2010-05-08 10:14:46 +00002751 AS_HELP_STRING([--with(out)-doc-strings], [disable/enable documentation strings]))
Martin v. Löwisa3fb4f72002-06-09 13:33:54 +00002752
2753if test -z "$with_doc_strings"
2754then with_doc_strings="yes"
2755fi
2756if test "$with_doc_strings" != "no"
2757then
2758 AC_DEFINE(WITH_DOC_STRINGS, 1,
2759 [Define if you want documentation strings in extension modules])
2760fi
2761AC_MSG_RESULT($with_doc_strings)
2762
Neil Schemenauera35c6882001-02-27 04:45:05 +00002763# Check for Python-specific malloc support
Martin v. Löwisf30d60e2004-06-08 08:17:44 +00002764AC_MSG_CHECKING(for --with-tsc)
2765AC_ARG_WITH(tsc,
Matthias Klose22520ea2010-05-08 10:14:46 +00002766 AS_HELP_STRING([--with(out)-tsc],[enable/disable timestamp counter profile]),[
Martin v. Löwisf30d60e2004-06-08 08:17:44 +00002767if test "$withval" != no
2768then
2769 AC_DEFINE(WITH_TSC, 1,
2770 [Define to profile with the Pentium timestamp counter])
2771 AC_MSG_RESULT(yes)
2772else AC_MSG_RESULT(no)
2773fi],
2774[AC_MSG_RESULT(no)])
2775
2776# Check for Python-specific malloc support
Neil Schemenauera35c6882001-02-27 04:45:05 +00002777AC_MSG_CHECKING(for --with-pymalloc)
2778AC_ARG_WITH(pymalloc,
Matthias Klose22520ea2010-05-08 10:14:46 +00002779 AS_HELP_STRING([--with(out)-pymalloc], [disable/enable specialized mallocs]))
Neil Schemenauer16c22972002-03-22 15:34:49 +00002780
2781if test -z "$with_pymalloc"
2782then with_pymalloc="yes"
2783fi
2784if test "$with_pymalloc" != "no"
2785then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002786 AC_DEFINE(WITH_PYMALLOC, 1,
2787 [Define if you want to compile in Python-specific mallocs])
Neil Schemenauer16c22972002-03-22 15:34:49 +00002788fi
2789AC_MSG_RESULT($with_pymalloc)
Neil Schemenauera35c6882001-02-27 04:45:05 +00002790
Benjamin Peterson91c12eb2009-12-03 02:52:39 +00002791# Check for Valgrind support
2792AC_MSG_CHECKING([for --with-valgrind])
2793AC_ARG_WITH([valgrind],
Matthias Klose22520ea2010-05-08 10:14:46 +00002794 AS_HELP_STRING([--with-valgrind], [Enable Valgrind support]),,
Benjamin Peterson91c12eb2009-12-03 02:52:39 +00002795 with_valgrind=no)
2796AC_MSG_RESULT([$with_valgrind])
2797if test "$with_valgrind" != no; then
2798 AC_CHECK_HEADER([valgrind/valgrind.h],
2799 [AC_DEFINE([WITH_VALGRIND], 1, [Define if you want pymalloc to be disabled when running under valgrind])],
2800 [AC_MSG_ERROR([Valgrind support requested but headers not available])]
2801 )
2802fi
2803
Barry Warsawef82cd72000-06-30 16:21:01 +00002804# Check for --with-wctype-functions
2805AC_MSG_CHECKING(for --with-wctype-functions)
2806AC_ARG_WITH(wctype-functions,
Matthias Klose22520ea2010-05-08 10:14:46 +00002807 AS_HELP_STRING([--with-wctype-functions], [use wctype.h functions]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002808[
Barry Warsawef82cd72000-06-30 16:21:01 +00002809if test "$withval" != no
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002810then
2811 AC_DEFINE(WANT_WCTYPE_FUNCTIONS, 1,
2812 [Define if you want wctype.h functions to be used instead of the
2813 one supplied by Python itself. (see Include/unicodectype.h).])
2814 AC_MSG_RESULT(yes)
Barry Warsawef82cd72000-06-30 16:21:01 +00002815else AC_MSG_RESULT(no)
2816fi],
2817[AC_MSG_RESULT(no)])
2818
Guido van Rossum68242b51996-05-28 22:53:03 +00002819# -I${DLINCLDIR} is added to the compile rule for importdl.o
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002820AC_SUBST(DLINCLDIR)
Guido van Rossum98935bf2001-09-05 19:13:16 +00002821DLINCLDIR=.
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002822
Guido van Rossume97ee181999-12-20 21:27:22 +00002823# the dlopen() function means we might want to use dynload_shlib.o. some
2824# platforms, such as AIX, have dlopen(), but don't want to use it.
Thomas Wouters3a584202000-08-05 23:28:51 +00002825AC_CHECK_FUNCS(dlopen)
Guido van Rossume97ee181999-12-20 21:27:22 +00002826
2827# DYNLOADFILE specifies which dynload_*.o file we will use for dynamic
2828# loading of modules.
2829AC_SUBST(DYNLOADFILE)
2830AC_MSG_CHECKING(DYNLOADFILE)
2831if test -z "$DYNLOADFILE"
2832then
2833 case $ac_sys_system/$ac_sys_release in
Martin v. Löwisc19c5a62003-11-18 20:00:44 +00002834 AIX*) # Use dynload_shlib.c and dlopen() if we have it; otherwise dynload_aix.c
2835 if test "$ac_cv_func_dlopen" = yes
2836 then DYNLOADFILE="dynload_shlib.o"
2837 else DYNLOADFILE="dynload_aix.o"
2838 fi
2839 ;;
Guido van Rossume97ee181999-12-20 21:27:22 +00002840 BeOS*) DYNLOADFILE="dynload_beos.o";;
2841 hp*|HP*) DYNLOADFILE="dynload_hpux.o";;
Anthony Baxter82201742006-04-09 15:07:40 +00002842 # Use dynload_next.c only on 10.2 and below, which don't have native dlopen()
2843 Darwin/@<:@0156@:>@\..*) DYNLOADFILE="dynload_next.o";;
Martin v. Löwisf90ae202002-06-11 06:22:31 +00002844 atheos*) DYNLOADFILE="dynload_atheos.o";;
Guido van Rossume97ee181999-12-20 21:27:22 +00002845 *)
2846 # use dynload_shlib.c and dlopen() if we have it; otherwise stub
2847 # out any dynamic loading
2848 if test "$ac_cv_func_dlopen" = yes
2849 then DYNLOADFILE="dynload_shlib.o"
2850 else DYNLOADFILE="dynload_stub.o"
2851 fi
2852 ;;
2853 esac
2854fi
2855AC_MSG_RESULT($DYNLOADFILE)
2856if test "$DYNLOADFILE" != "dynload_stub.o"
2857then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002858 AC_DEFINE(HAVE_DYNAMIC_LOADING, 1,
2859 [Defined when any dynamic module loading is enabled.])
Guido van Rossume97ee181999-12-20 21:27:22 +00002860fi
2861
Jack Jansenc49e5b72001-06-19 15:00:23 +00002862# MACHDEP_OBJS can be set to platform-specific object files needed by Python
2863
2864AC_SUBST(MACHDEP_OBJS)
2865AC_MSG_CHECKING(MACHDEP_OBJS)
2866if test -z "$MACHDEP_OBJS"
2867then
Jack Jansenb6e9cad2001-08-15 01:26:28 +00002868 MACHDEP_OBJS=$extra_machdep_objs
2869else
2870 MACHDEP_OBJS="$MACHDEP_OBJS $extra_machdep_objs"
Jack Jansenc49e5b72001-06-19 15:00:23 +00002871fi
Jack Jansenb6e9cad2001-08-15 01:26:28 +00002872AC_MSG_RESULT(MACHDEP_OBJS)
Jack Jansenc49e5b72001-06-19 15:00:23 +00002873
Guido van Rossum627b2d71993-12-24 10:39:16 +00002874# checks for library functions
Martin v. Löwisaef18b12008-03-24 13:31:16 +00002875AC_CHECK_FUNCS(alarm setitimer getitimer bind_textdomain_codeset chown \
2876 clock confstr ctermid execv fchmod fchown fork fpathconf ftime ftruncate \
Martin v. Löwis438b5342002-12-27 10:16:42 +00002877 gai_strerror getgroups getlogin getloadavg getpeername getpgid getpid \
Martin v. Löwis50ea4562009-11-27 13:56:01 +00002878 getpriority getresuid getresgid getpwent getspnam getspent getsid getwd \
Antoine Pitrou30b3b352009-12-02 20:37:54 +00002879 initgroups kill killpg lchmod lchown lstat mkfifo mknod mktime \
Martin v. Löwisa5f09072002-10-11 05:37:59 +00002880 mremap nice pathconf pause plock poll pthread_init \
Guido van Rossum162e38c2003-02-19 15:25:10 +00002881 putenv readlink realpath \
Jesse Noller355b1262009-04-02 00:03:28 +00002882 select sem_open sem_timedwait sem_getvalue sem_unlink setegid seteuid \
2883 setgid \
Martin v. Löwis4daacb12003-03-28 18:37:01 +00002884 setlocale setregid setreuid setsid setpgid setpgrp setuid setvbuf snprintf \
Martin v. Löwis50ea4562009-11-27 13:56:01 +00002885 setlocale setregid setreuid setresuid setresgid \
2886 setsid setpgid setpgrp setuid setvbuf snprintf \
Skip Montanaro7e11a012004-02-07 12:55:46 +00002887 sigaction siginterrupt sigrelse strftime \
Michael W. Hudson34f20ea2002-05-27 15:08:24 +00002888 sysconf tcgetpgrp tcsetpgrp tempnam timegm times tmpfile tmpnam tmpnam_r \
Neal Norwitz05a45592006-03-20 06:30:08 +00002889 truncate uname unsetenv utimes waitpid wait3 wait4 wcscoll _getpty)
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00002890
Martin v. Löwisc8ad7cc2002-11-11 13:23:45 +00002891# For some functions, having a definition is not sufficient, since
2892# we want to take their address.
2893AC_MSG_CHECKING(for chroot)
Matthias Klosec511b472010-05-08 11:01:39 +00002894AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[void *x=chroot]])],
2895 [AC_DEFINE(HAVE_CHROOT, 1, Define if you have the 'chroot' function.)
2896 AC_MSG_RESULT(yes)],
2897 [AC_MSG_RESULT(no)
2898])
Martin v. Löwisc8ad7cc2002-11-11 13:23:45 +00002899AC_MSG_CHECKING(for link)
Matthias Klosec511b472010-05-08 11:01:39 +00002900AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[void *x=link]])],
2901 [AC_DEFINE(HAVE_LINK, 1, Define if you have the 'link' function.)
2902 AC_MSG_RESULT(yes)],
2903 [AC_MSG_RESULT(no)
2904])
Martin v. Löwisc8ad7cc2002-11-11 13:23:45 +00002905AC_MSG_CHECKING(for symlink)
Matthias Klosec511b472010-05-08 11:01:39 +00002906AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[void *x=symlink]])],
2907 [AC_DEFINE(HAVE_SYMLINK, 1, Define if you have the 'symlink' function.)
2908 AC_MSG_RESULT(yes)],
2909 [AC_MSG_RESULT(no)
2910])
Martin v. Löwisa64988c2003-09-20 15:30:20 +00002911AC_MSG_CHECKING(for fchdir)
Matthias Klosec511b472010-05-08 11:01:39 +00002912AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[void *x=fchdir]])],
2913 [AC_DEFINE(HAVE_FCHDIR, 1, Define if you have the 'fchdir' function.)
2914 AC_MSG_RESULT(yes)],
2915 [AC_MSG_RESULT(no)
2916])
Martin v. Löwisa64988c2003-09-20 15:30:20 +00002917AC_MSG_CHECKING(for fsync)
Matthias Klosec511b472010-05-08 11:01:39 +00002918AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[void *x=fsync]])],
2919 [AC_DEFINE(HAVE_FSYNC, 1, Define if you have the 'fsync' function.)
2920 AC_MSG_RESULT(yes)],
2921 [AC_MSG_RESULT(no)
2922])
Martin v. Löwisa64988c2003-09-20 15:30:20 +00002923AC_MSG_CHECKING(for fdatasync)
Matthias Klosec511b472010-05-08 11:01:39 +00002924AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[void *x=fdatasync]])],
2925 [AC_DEFINE(HAVE_FDATASYNC, 1, Define if you have the 'fdatasync' function.)
2926 AC_MSG_RESULT(yes)],
2927 [AC_MSG_RESULT(no)
2928])
Christian Heimes0e9ab5f2008-03-21 23:49:44 +00002929AC_MSG_CHECKING(for epoll)
Matthias Klosec511b472010-05-08 11:01:39 +00002930AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/epoll.h>]], [[void *x=epoll_create]])],
2931 [AC_DEFINE(HAVE_EPOLL, 1, Define if you have the 'epoll' functions.)
2932 AC_MSG_RESULT(yes)],
2933 [AC_MSG_RESULT(no)
2934])
Christian Heimes0e9ab5f2008-03-21 23:49:44 +00002935AC_MSG_CHECKING(for kqueue)
Matthias Klosec511b472010-05-08 11:01:39 +00002936AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Christian Heimes0e9ab5f2008-03-21 23:49:44 +00002937#include <sys/types.h>
2938#include <sys/event.h>
Matthias Klosec511b472010-05-08 11:01:39 +00002939 ]], [[int x=kqueue()]])],
2940 [AC_DEFINE(HAVE_KQUEUE, 1, Define if you have the 'kqueue' functions.)
2941 AC_MSG_RESULT(yes)],
2942 [AC_MSG_RESULT(no)
2943])
Martin v. Löwisd5843682002-11-21 20:41:28 +00002944# On some systems (eg. FreeBSD 5), we would find a definition of the
2945# functions ctermid_r, setgroups in the library, but no prototype
2946# (e.g. because we use _XOPEN_SOURCE). See whether we can take their
2947# address to avoid compiler warnings and potential miscompilations
2948# because of the missing prototypes.
2949
2950AC_MSG_CHECKING(for ctermid_r)
Matthias Klosec511b472010-05-08 11:01:39 +00002951AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwisd5843682002-11-21 20:41:28 +00002952#include <stdio.h>
Matthias Klosec511b472010-05-08 11:01:39 +00002953]], [[void* p = ctermid_r]])],
2954 [AC_DEFINE(HAVE_CTERMID_R, 1, Define if you have the 'ctermid_r' function.)
2955 AC_MSG_RESULT(yes)],
2956 [AC_MSG_RESULT(no)
2957])
Martin v. Löwisd5843682002-11-21 20:41:28 +00002958
Antoine Pitroub170f172010-09-10 18:47:36 +00002959AC_CACHE_CHECK([for flock declaration], [ac_cv_flock_decl],
2960 [AC_COMPILE_IFELSE(
2961 [AC_LANG_PROGRAM(
2962 [#include <sys/file.h>],
2963 [void* p = flock]
2964 )],
2965 [ac_cv_flock_decl=yes],
2966 [ac_cv_flock_decl=no]
2967 )
Matthias Klosec511b472010-05-08 11:01:39 +00002968])
Antoine Pitroub170f172010-09-10 18:47:36 +00002969if test "x${ac_cv_flock_decl}" = xyes; then
2970 AC_CHECK_FUNCS(flock,,
2971 AC_CHECK_LIB(bsd,flock,
2972 [AC_DEFINE(HAVE_FLOCK)
2973 AC_DEFINE(FLOCK_NEEDS_LIBBSD, 1, Define if flock needs to be linked with bsd library.)
2974 ])
2975 )
Antoine Pitrou85729812010-09-07 14:55:24 +00002976fi
Martin v. Löwisf26d63b2003-03-30 17:23:49 +00002977
2978AC_MSG_CHECKING(for getpagesize)
Matthias Klosec511b472010-05-08 11:01:39 +00002979AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwisf26d63b2003-03-30 17:23:49 +00002980#include <unistd.h>
Matthias Klosec511b472010-05-08 11:01:39 +00002981]], [[void* p = getpagesize]])],
2982 [AC_DEFINE(HAVE_GETPAGESIZE, 1, Define if you have the 'getpagesize' function.)
2983 AC_MSG_RESULT(yes)],
2984 [AC_MSG_RESULT(no)
2985])
Martin v. Löwisf26d63b2003-03-30 17:23:49 +00002986
Charles-François Natali93a11752011-11-27 13:01:35 +01002987AC_MSG_CHECKING(for broken unsetenv)
2988AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
2989#include <stdlib.h>
2990]], [[int res = unsetenv("DUMMY")]])],
2991 [AC_MSG_RESULT(no)],
2992 [AC_DEFINE(HAVE_BROKEN_UNSETENV, 1, Define if `unsetenv` does not return an int.)
2993 AC_MSG_RESULT(yes)
2994])
2995
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002996dnl check for true
2997AC_CHECK_PROGS(TRUE, true, /bin/true)
2998
Martin v. Löwis95c419b2003-05-03 12:10:48 +00002999dnl On some systems (e.g. Solaris 9), hstrerror and inet_aton are in -lresolv
3000dnl On others, they are in the C library, so we to take no action
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00003001AC_CHECK_LIB(c, inet_aton, [$ac_cv_prog_TRUE],
Martin v. Löwis95c419b2003-05-03 12:10:48 +00003002 AC_CHECK_LIB(resolv, inet_aton)
3003)
3004
Martin v. Löwisa51d5c82007-12-04 08:37:59 +00003005# On Tru64, chflags seems to be present, but calling it will
3006# exit Python
Gregory P. Smithbb213892009-11-02 01:37:37 +00003007AC_CACHE_CHECK([for chflags], [ac_cv_have_chflags], [dnl
Ned Deily43e10542011-06-27 23:41:53 -07003008AC_RUN_IFELSE([AC_LANG_SOURCE([[
Martin v. Löwisa51d5c82007-12-04 08:37:59 +00003009#include <sys/stat.h>
3010#include <unistd.h>
3011int main(int argc, char*argv[])
3012{
3013 if(chflags(argv[0], 0) != 0)
3014 return 1;
3015 return 0;
3016}
Ned Deily43e10542011-06-27 23:41:53 -07003017]])],
Matthias Klosec511b472010-05-08 11:01:39 +00003018[ac_cv_have_chflags=yes],
3019[ac_cv_have_chflags=no],
3020[ac_cv_have_chflags=cross])
Gregory P. Smithbb213892009-11-02 01:37:37 +00003021])
3022if test "$ac_cv_have_chflags" = cross ; then
3023 AC_CHECK_FUNC([chflags], [ac_cv_have_chflags="yes"], [ac_cv_have_chflags="no"])
3024fi
3025if test "$ac_cv_have_chflags" = yes ; then
Ned Deily43e10542011-06-27 23:41:53 -07003026 AC_DEFINE(HAVE_CHFLAGS, 1, [Define to 1 if you have the 'chflags' function.])
Alexandre Vassalotti00900892009-07-17 05:26:39 +00003027fi
Martin v. Löwisa51d5c82007-12-04 08:37:59 +00003028
Gregory P. Smithbb213892009-11-02 01:37:37 +00003029AC_CACHE_CHECK([for lchflags], [ac_cv_have_lchflags], [dnl
Ned Deily43e10542011-06-27 23:41:53 -07003030AC_RUN_IFELSE([AC_LANG_SOURCE([[
Martin v. Löwisa51d5c82007-12-04 08:37:59 +00003031#include <sys/stat.h>
3032#include <unistd.h>
3033int main(int argc, char*argv[])
3034{
3035 if(lchflags(argv[0], 0) != 0)
3036 return 1;
3037 return 0;
3038}
Ned Deily43e10542011-06-27 23:41:53 -07003039]])],[ac_cv_have_lchflags=yes],[ac_cv_have_lchflags=no],[ac_cv_have_lchflags=cross])
Gregory P. Smithbb213892009-11-02 01:37:37 +00003040])
3041if test "$ac_cv_have_lchflags" = cross ; then
3042 AC_CHECK_FUNC([lchflags], [ac_cv_have_lchflags="yes"], [ac_cv_have_lchflags="no"])
3043fi
3044if test "$ac_cv_have_lchflags" = yes ; then
Ned Deily43e10542011-06-27 23:41:53 -07003045 AC_DEFINE(HAVE_LCHFLAGS, 1, [Define to 1 if you have the 'lchflags' function.])
Alexandre Vassalotti00900892009-07-17 05:26:39 +00003046fi
Martin v. Löwisa51d5c82007-12-04 08:37:59 +00003047
Neal Norwitz6e73aaa2006-06-12 03:33:09 +00003048dnl Check if system zlib has *Copy() functions
Ronald Oussorenf8752642006-07-06 10:13:35 +00003049dnl
3050dnl On MacOSX the linker will search for dylibs on the entire linker path
3051dnl before searching for static libraries. setup.py adds -Wl,-search_paths_first
3052dnl to revert to a more traditional unix behaviour and make it possible to
3053dnl override the system libz with a local static library of libz. Temporarily
3054dnl add that flag to our CFLAGS as well to ensure that we check the version
3055dnl of libz that will be used by setup.py.
3056dnl The -L/usr/local/lib is needed as wel to get the same compilation
3057dnl environment as setup.py (and leaving it out can cause configure to use the
3058dnl wrong version of the library)
3059case $ac_sys_system/$ac_sys_release in
3060Darwin/*)
3061 _CUR_CFLAGS="${CFLAGS}"
3062 _CUR_LDFLAGS="${LDFLAGS}"
3063 CFLAGS="${CFLAGS} -Wl,-search_paths_first"
3064 LDFLAGS="${LDFLAGS} -Wl,-search_paths_first -L/usr/local/lib"
3065 ;;
3066esac
3067
Matthias Klose5183ebd2010-04-24 16:38:36 +00003068AC_CHECK_LIB(z, inflateCopy, AC_DEFINE(HAVE_ZLIB_COPY, 1, [Define if the zlib library has inflateCopy]))
Neal Norwitz6e73aaa2006-06-12 03:33:09 +00003069
Ronald Oussorenf8752642006-07-06 10:13:35 +00003070case $ac_sys_system/$ac_sys_release in
3071Darwin/*)
3072 CFLAGS="${_CUR_CFLAGS}"
3073 LDFLAGS="${_CUR_LDFLAGS}"
3074 ;;
3075esac
3076
Martin v. Löwise9416172003-05-03 10:12:45 +00003077AC_MSG_CHECKING(for hstrerror)
Matthias Klosec511b472010-05-08 11:01:39 +00003078AC_LINK_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwise9416172003-05-03 10:12:45 +00003079#include <netdb.h>
Matthias Klosec511b472010-05-08 11:01:39 +00003080]], [[void* p = hstrerror; hstrerror(0)]])],
3081 [AC_DEFINE(HAVE_HSTRERROR, 1, Define if you have the 'hstrerror' function.)
3082 AC_MSG_RESULT(yes)],
3083 [AC_MSG_RESULT(no)
3084])
Martin v. Löwise9416172003-05-03 10:12:45 +00003085
3086AC_MSG_CHECKING(for inet_aton)
Matthias Klosec511b472010-05-08 11:01:39 +00003087AC_LINK_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwis86d66262006-02-17 08:40:11 +00003088#include <sys/types.h>
Martin v. Löwise9416172003-05-03 10:12:45 +00003089#include <sys/socket.h>
3090#include <netinet/in.h>
3091#include <arpa/inet.h>
Matthias Klosec511b472010-05-08 11:01:39 +00003092]], [[void* p = inet_aton;inet_aton(0,0)]])],
3093 [AC_DEFINE(HAVE_INET_ATON, 1, Define if you have the 'inet_aton' function.)
3094 AC_MSG_RESULT(yes)],
3095 [AC_MSG_RESULT(no)
3096])
Martin v. Löwise9416172003-05-03 10:12:45 +00003097
3098AC_MSG_CHECKING(for inet_pton)
Matthias Klosec511b472010-05-08 11:01:39 +00003099AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwisf2e488d2003-05-05 22:00:11 +00003100#include <sys/types.h>
Martin v. Löwise9416172003-05-03 10:12:45 +00003101#include <sys/socket.h>
3102#include <netinet/in.h>
3103#include <arpa/inet.h>
Matthias Klosec511b472010-05-08 11:01:39 +00003104]], [[void* p = inet_pton]])],
3105 [AC_DEFINE(HAVE_INET_PTON, 1, Define if you have the 'inet_pton' function.)
3106 AC_MSG_RESULT(yes)],
3107 [AC_MSG_RESULT(no)
3108])
Martin v. Löwise9416172003-05-03 10:12:45 +00003109
Martin v. Löwisd6640d42003-07-06 09:29:52 +00003110# On some systems, setgroups is in unistd.h, on others, in grp.h
Martin v. Löwisd5843682002-11-21 20:41:28 +00003111AC_MSG_CHECKING(for setgroups)
Matthias Klosec511b472010-05-08 11:01:39 +00003112AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwisf2e488d2003-05-05 22:00:11 +00003113#include <unistd.h>
Martin v. Löwisd6640d42003-07-06 09:29:52 +00003114#ifdef HAVE_GRP_H
3115#include <grp.h>
3116#endif
Matthias Klosec511b472010-05-08 11:01:39 +00003117]], [[void* p = setgroups]])],
3118 [AC_DEFINE(HAVE_SETGROUPS, 1, Define if you have the 'setgroups' function.)
3119 AC_MSG_RESULT(yes)],
3120 [AC_MSG_RESULT(no)
3121])
Martin v. Löwisd5843682002-11-21 20:41:28 +00003122
Fred Drake8cef4cf2000-06-28 16:40:38 +00003123# check for openpty and forkpty
3124
Martin v. Löwisfd9a72a2006-01-08 10:07:33 +00003125AC_CHECK_FUNCS(openpty,,
3126 AC_CHECK_LIB(util,openpty,
3127 [AC_DEFINE(HAVE_OPENPTY) LIBS="$LIBS -lutil"],
3128 AC_CHECK_LIB(bsd,openpty, [AC_DEFINE(HAVE_OPENPTY) LIBS="$LIBS -lbsd"])
3129 )
3130)
3131AC_CHECK_FUNCS(forkpty,,
3132 AC_CHECK_LIB(util,forkpty,
3133 [AC_DEFINE(HAVE_FORKPTY) LIBS="$LIBS -lutil"],
3134 AC_CHECK_LIB(bsd,forkpty, [AC_DEFINE(HAVE_FORKPTY) LIBS="$LIBS -lbsd"])
3135 )
3136)
Fred Drake8cef4cf2000-06-28 16:40:38 +00003137
Brett Cannonaa5778d2008-03-18 04:09:00 +00003138# Stuff for expat.
3139AC_CHECK_FUNCS(memmove)
3140
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00003141# check for long file support functions
3142AC_CHECK_FUNCS(fseek64 fseeko fstatvfs ftell64 ftello statvfs)
3143
Brett Cannonaa5778d2008-03-18 04:09:00 +00003144AC_REPLACE_FUNCS(dup2 getcwd strdup)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003145AC_CHECK_FUNCS(getpgrp,
Matthias Klosec511b472010-05-08 11:01:39 +00003146 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[getpgrp(0);]])],
3147 [AC_DEFINE(GETPGRP_HAVE_ARG, 1, [Define if getpgrp() must be called as getpgrp(0).])],
3148 [])
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003149)
Jack Jansen150753c2003-03-29 22:07:47 +00003150AC_CHECK_FUNCS(setpgrp,
Matthias Klosec511b472010-05-08 11:01:39 +00003151 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[setpgrp(0,0);]])],
3152 [AC_DEFINE(SETPGRP_HAVE_ARG, 1, [Define if setpgrp() must be called as setpgrp(0, 0).])],
3153 [])
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003154)
3155AC_CHECK_FUNCS(gettimeofday,
Matthias Klosec511b472010-05-08 11:01:39 +00003156 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/time.h>]],
3157 [[gettimeofday((struct timeval*)0,(struct timezone*)0);]])],
3158 [],
3159 [AC_DEFINE(GETTIMEOFDAY_NO_TZ, 1,
3160 [Define if gettimeofday() does not have second (timezone) argument
3161 This is the case on Motorola V4 (R40V4.2)])
3162 ])
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003163)
Guido van Rossum627b2d71993-12-24 10:39:16 +00003164
Martin v. Löwisdbe3f762002-10-10 14:27:30 +00003165AC_MSG_CHECKING(for major, minor, and makedev)
Matthias Klosec511b472010-05-08 11:01:39 +00003166AC_LINK_IFELSE([AC_LANG_PROGRAM([[
Neal Norwitz6eb37f02003-02-23 23:28:15 +00003167#if defined(MAJOR_IN_MKDEV)
3168#include <sys/mkdev.h>
3169#elif defined(MAJOR_IN_SYSMACROS)
3170#include <sys/sysmacros.h>
3171#else
3172#include <sys/types.h>
3173#endif
Matthias Klosec511b472010-05-08 11:01:39 +00003174]], [[
Martin v. Löwisdbe3f762002-10-10 14:27:30 +00003175 makedev(major(0),minor(0));
Matthias Klosec511b472010-05-08 11:01:39 +00003176]])],[
Martin v. Löwisdbe3f762002-10-10 14:27:30 +00003177 AC_DEFINE(HAVE_DEVICE_MACROS, 1,
3178 [Define to 1 if you have the device macros.])
3179 AC_MSG_RESULT(yes)
3180],[
3181 AC_MSG_RESULT(no)
3182])
Martin v. Löwis861a65b2001-10-24 14:36:00 +00003183
3184# On OSF/1 V5.1, getaddrinfo is available, but a define
3185# for [no]getaddrinfo in netdb.h.
3186AC_MSG_CHECKING(for getaddrinfo)
Matthias Klosec511b472010-05-08 11:01:39 +00003187AC_LINK_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwisc010b6d2001-11-09 17:50:52 +00003188#include <sys/types.h>
Martin v. Löwis861a65b2001-10-24 14:36:00 +00003189#include <sys/socket.h>
3190#include <netdb.h>
Martin v. Löwisc010b6d2001-11-09 17:50:52 +00003191#include <stdio.h>
Matthias Klosec511b472010-05-08 11:01:39 +00003192]], [[getaddrinfo(NULL, NULL, NULL, NULL);]])],
3193[have_getaddrinfo=yes],
3194[have_getaddrinfo=no])
Alexandre Vassalotti00900892009-07-17 05:26:39 +00003195AC_MSG_RESULT($have_getaddrinfo)
3196if test $have_getaddrinfo = yes
3197then
3198 AC_MSG_CHECKING(getaddrinfo bug)
3199 AC_CACHE_VAL(ac_cv_buggy_getaddrinfo,
Matthias Klosec511b472010-05-08 11:01:39 +00003200 AC_RUN_IFELSE([AC_LANG_SOURCE([[[
Stefan Krah0afe4e42012-11-22 23:56:51 +01003201#include <stdio.h>
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003202#include <sys/types.h>
3203#include <netdb.h>
3204#include <string.h>
3205#include <sys/socket.h>
3206#include <netinet/in.h>
3207
Alexandre Vassalotti00900892009-07-17 05:26:39 +00003208int main()
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003209{
3210 int passive, gaierr, inet4 = 0, inet6 = 0;
3211 struct addrinfo hints, *ai, *aitop;
3212 char straddr[INET6_ADDRSTRLEN], strport[16];
3213
3214 for (passive = 0; passive <= 1; passive++) {
3215 memset(&hints, 0, sizeof(hints));
3216 hints.ai_family = AF_UNSPEC;
3217 hints.ai_flags = passive ? AI_PASSIVE : 0;
3218 hints.ai_socktype = SOCK_STREAM;
Hye-Shik Chang54f94392004-04-14 07:55:31 +00003219 hints.ai_protocol = IPPROTO_TCP;
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003220 if ((gaierr = getaddrinfo(NULL, "54321", &hints, &aitop)) != 0) {
3221 (void)gai_strerror(gaierr);
3222 goto bad;
3223 }
3224 for (ai = aitop; ai; ai = ai->ai_next) {
3225 if (ai->ai_addr == NULL ||
3226 ai->ai_addrlen == 0 ||
3227 getnameinfo(ai->ai_addr, ai->ai_addrlen,
3228 straddr, sizeof(straddr), strport, sizeof(strport),
3229 NI_NUMERICHOST|NI_NUMERICSERV) != 0) {
3230 goto bad;
3231 }
3232 switch (ai->ai_family) {
3233 case AF_INET:
3234 if (strcmp(strport, "54321") != 0) {
3235 goto bad;
3236 }
3237 if (passive) {
3238 if (strcmp(straddr, "0.0.0.0") != 0) {
3239 goto bad;
3240 }
3241 } else {
3242 if (strcmp(straddr, "127.0.0.1") != 0) {
3243 goto bad;
3244 }
3245 }
3246 inet4++;
3247 break;
3248 case AF_INET6:
3249 if (strcmp(strport, "54321") != 0) {
3250 goto bad;
3251 }
3252 if (passive) {
3253 if (strcmp(straddr, "::") != 0) {
3254 goto bad;
3255 }
3256 } else {
3257 if (strcmp(straddr, "::1") != 0) {
3258 goto bad;
3259 }
3260 }
3261 inet6++;
3262 break;
3263 case AF_UNSPEC:
3264 goto bad;
3265 break;
3266 default:
3267 /* another family support? */
3268 break;
3269 }
3270 }
3271 }
3272
3273 if (!(inet4 == 0 || inet4 == 2))
3274 goto bad;
3275 if (!(inet6 == 0 || inet6 == 2))
3276 goto bad;
3277
3278 if (aitop)
3279 freeaddrinfo(aitop);
Alexandre Vassalotti00900892009-07-17 05:26:39 +00003280 return 0;
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003281
3282 bad:
3283 if (aitop)
3284 freeaddrinfo(aitop);
Alexandre Vassalotti00900892009-07-17 05:26:39 +00003285 return 1;
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003286}
Matthias Klosec511b472010-05-08 11:01:39 +00003287]]])],
3288[ac_cv_buggy_getaddrinfo=no],
3289[ac_cv_buggy_getaddrinfo=yes],
doko@python.orgd65e2ba2013-01-31 23:52:03 +01003290[
3291if test "${enable_ipv6+set}" = set; then
3292 ac_cv_buggy_getaddrinfo="no -- configured with --(en|dis)able-ipv6"
3293else
3294 ac_cv_buggy_getaddrinfo=yes
3295fi]))
Alexandre Vassalotti00900892009-07-17 05:26:39 +00003296fi
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003297
Benjamin Peterson75fed812010-11-01 01:47:19 +00003298AC_MSG_RESULT($ac_cv_buggy_getaddrinfo)
3299
Mark Dickinson0ef0b912009-12-31 21:11:48 +00003300if test $have_getaddrinfo = no -o "$ac_cv_buggy_getaddrinfo" = yes
Alexandre Vassalotti00900892009-07-17 05:26:39 +00003301then
3302 if test $ipv6 = yes
3303 then
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003304 echo 'Fatal: You must get working getaddrinfo() function.'
3305 echo ' or you can specify "--disable-ipv6"'.
3306 exit 1
3307 fi
Martin v. Löwis861a65b2001-10-24 14:36:00 +00003308else
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003309 AC_DEFINE(HAVE_GETADDRINFO, 1, [Define if you have the getaddrinfo function.])
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003310fi
Benjamin Peterson75fed812010-11-01 01:47:19 +00003311
Thomas Woutersb0db85a2001-08-08 10:39:03 +00003312AC_CHECK_FUNCS(getnameinfo)
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003313
Guido van Rossum627b2d71993-12-24 10:39:16 +00003314# checks for structures
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003315AC_HEADER_TIME
Guido van Rossum627b2d71993-12-24 10:39:16 +00003316AC_STRUCT_TM
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003317AC_STRUCT_TIMEZONE
Martin v. Löwis60a5d722002-10-16 20:28:25 +00003318AC_CHECK_MEMBERS([struct stat.st_rdev])
3319AC_CHECK_MEMBERS([struct stat.st_blksize])
Hye-Shik Chang5f937a72005-06-02 13:09:30 +00003320AC_CHECK_MEMBERS([struct stat.st_flags])
Martin v. Löwisebd9d5b2005-08-09 15:00:59 +00003321AC_CHECK_MEMBERS([struct stat.st_gen])
3322AC_CHECK_MEMBERS([struct stat.st_birthtime])
Guido van Rossum98bf58f2001-10-18 20:34:25 +00003323AC_STRUCT_ST_BLOCKS
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003324
3325AC_MSG_CHECKING(for time.h that defines altzone)
Matthias Klosec511b472010-05-08 11:01:39 +00003326AC_CACHE_VAL(ac_cv_header_time_altzone,[
3327 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <time.h>]], [[return altzone;]])],
3328 [ac_cv_header_time_altzone=yes],
3329 [ac_cv_header_time_altzone=no])
3330 ])
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003331AC_MSG_RESULT($ac_cv_header_time_altzone)
3332if test $ac_cv_header_time_altzone = yes; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003333 AC_DEFINE(HAVE_ALTZONE, 1, [Define this if your time.h defines altzone.])
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003334fi
3335
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003336was_it_defined=no
3337AC_MSG_CHECKING(whether sys/select.h and sys/time.h may both be included)
Matthias Klosec511b472010-05-08 11:01:39 +00003338AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003339#include <sys/types.h>
3340#include <sys/select.h>
3341#include <sys/time.h>
Matthias Klosec511b472010-05-08 11:01:39 +00003342]], [[;]])],[
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003343 AC_DEFINE(SYS_SELECT_WITH_SYS_TIME, 1,
3344 [Define if you can safely include both <sys/select.h> and <sys/time.h>
3345 (which you can't on SCO ODT 3.0).])
3346 was_it_defined=yes
Matthias Klosec511b472010-05-08 11:01:39 +00003347],[])
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003348AC_MSG_RESULT($was_it_defined)
Guido van Rossum627b2d71993-12-24 10:39:16 +00003349
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003350AC_MSG_CHECKING(for addrinfo)
3351AC_CACHE_VAL(ac_cv_struct_addrinfo,
Matthias Klosec511b472010-05-08 11:01:39 +00003352AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <netdb.h>]], [[struct addrinfo a]])],
3353 [ac_cv_struct_addrinfo=yes],
3354 [ac_cv_struct_addrinfo=no]))
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003355AC_MSG_RESULT($ac_cv_struct_addrinfo)
3356if test $ac_cv_struct_addrinfo = yes; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003357 AC_DEFINE(HAVE_ADDRINFO, 1, [struct addrinfo (netdb.h)])
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003358fi
3359
3360AC_MSG_CHECKING(for sockaddr_storage)
3361AC_CACHE_VAL(ac_cv_struct_sockaddr_storage,
Matthias Klosec511b472010-05-08 11:01:39 +00003362AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003363# include <sys/types.h>
Matthias Klosec511b472010-05-08 11:01:39 +00003364# include <sys/socket.h>]], [[struct sockaddr_storage s]])],
3365 [ac_cv_struct_sockaddr_storage=yes],
3366 [ac_cv_struct_sockaddr_storage=no]))
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003367AC_MSG_RESULT($ac_cv_struct_sockaddr_storage)
3368if test $ac_cv_struct_sockaddr_storage = yes; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003369 AC_DEFINE(HAVE_SOCKADDR_STORAGE, 1, [struct sockaddr_storage (sys/socket.h)])
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003370fi
3371
Guido van Rossum627b2d71993-12-24 10:39:16 +00003372# checks for compiler characteristics
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003373
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003374AC_C_CHAR_UNSIGNED
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003375AC_C_CONST
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003376
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003377works=no
3378AC_MSG_CHECKING(for working volatile)
Matthias Klosec511b472010-05-08 11:01:39 +00003379AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[volatile int x; x = 0;]])],
3380 [works=yes],
3381 [AC_DEFINE(volatile, , [Define to empty if the keyword does not work.])]
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003382)
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003383AC_MSG_RESULT($works)
Guido van Rossumdabb11b1994-10-11 15:04:27 +00003384
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003385works=no
3386AC_MSG_CHECKING(for working signed char)
Matthias Klosec511b472010-05-08 11:01:39 +00003387AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[signed char c;]])],
3388 [works=yes],
3389 [AC_DEFINE(signed, , [Define to empty if the keyword does not work.])]
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003390)
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003391AC_MSG_RESULT($works)
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003392
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003393have_prototypes=no
3394AC_MSG_CHECKING(for prototypes)
Matthias Klosec511b472010-05-08 11:01:39 +00003395AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[int foo(int x) { return 0; }]], [[return foo(10);]])],
3396 [AC_DEFINE(HAVE_PROTOTYPES, 1,
3397 [Define if your compiler supports function prototype])
3398 have_prototypes=yes],
3399 []
3400)
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003401AC_MSG_RESULT($have_prototypes)
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003402
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003403works=no
3404AC_MSG_CHECKING(for variable length prototypes and stdarg.h)
Matthias Klosec511b472010-05-08 11:01:39 +00003405AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003406#include <stdarg.h>
Guido van Rossum3f13e481996-08-30 20:58:11 +00003407int foo(int x, ...) {
3408 va_list va;
3409 va_start(va, x);
3410 va_arg(va, int);
3411 va_arg(va, char *);
3412 va_arg(va, double);
3413 return 0;
3414}
Matthias Klosec511b472010-05-08 11:01:39 +00003415]], [[return foo(10, "", 3.14);]])],[
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003416 AC_DEFINE(HAVE_STDARG_PROTOTYPES, 1,
3417 [Define if your compiler supports variable length function prototypes
3418 (e.g. void fprintf(FILE *, char *, ...);) *and* <stdarg.h>])
3419 works=yes
Matthias Klosec511b472010-05-08 11:01:39 +00003420],[])
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003421AC_MSG_RESULT($works)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003422
Dave Cole331708b2004-08-09 04:51:41 +00003423# check for socketpair
3424AC_MSG_CHECKING(for socketpair)
Matthias Klosec511b472010-05-08 11:01:39 +00003425AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Dave Cole331708b2004-08-09 04:51:41 +00003426#include <sys/types.h>
3427#include <sys/socket.h>
Matthias Klosec511b472010-05-08 11:01:39 +00003428]], [[void *x=socketpair]])],
3429 [AC_DEFINE(HAVE_SOCKETPAIR, 1, [Define if you have the 'socketpair' function.])
3430 AC_MSG_RESULT(yes)],
3431 [AC_MSG_RESULT(no)]
Dave Cole331708b2004-08-09 04:51:41 +00003432)
3433
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003434# check if sockaddr has sa_len member
3435AC_MSG_CHECKING(if sockaddr has sa_len member)
Matthias Klosec511b472010-05-08 11:01:39 +00003436AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
3437#include <sys/socket.h>]], [[struct sockaddr x;
3438x.sa_len = 0;]])],
3439 [AC_MSG_RESULT(yes)
3440 AC_DEFINE(HAVE_SOCKADDR_SA_LEN, 1, [Define if sockaddr has sa_len member])],
3441 [AC_MSG_RESULT(no)]
3442)
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003443
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003444va_list_is_array=no
3445AC_MSG_CHECKING(whether va_list is an array)
Matthias Klosec511b472010-05-08 11:01:39 +00003446AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003447#ifdef HAVE_STDARG_PROTOTYPES
3448#include <stdarg.h>
3449#else
3450#include <varargs.h>
3451#endif
Matthias Klosec511b472010-05-08 11:01:39 +00003452]], [[va_list list1, list2; list1 = list2;]])],[],[
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003453 AC_DEFINE(VA_LIST_IS_ARRAY, 1, [Define if a va_list is an array of some kind])
3454 va_list_is_array=yes
3455])
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003456AC_MSG_RESULT($va_list_is_array)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003457
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003458# sigh -- gethostbyname_r is a mess; it can have 3, 5 or 6 arguments :-(
Martin v. Löwis11437992002-04-12 09:54:03 +00003459AH_TEMPLATE(HAVE_GETHOSTBYNAME_R,
3460 [Define this if you have some version of gethostbyname_r()])
3461
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003462AC_CHECK_FUNC(gethostbyname_r, [
3463 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
3464 AC_MSG_CHECKING([gethostbyname_r with 6 args])
3465 OLD_CFLAGS=$CFLAGS
3466 CFLAGS="$CFLAGS $MY_CPPFLAGS $MY_THREAD_CPPFLAGS $MY_CFLAGS"
Matthias Klosec511b472010-05-08 11:01:39 +00003467 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003468# include <netdb.h>
Matthias Klosec511b472010-05-08 11:01:39 +00003469 ]], [[
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003470 char *name;
3471 struct hostent *he, *res;
3472 char buffer[2048];
3473 int buflen = 2048;
3474 int h_errnop;
3475
3476 (void) gethostbyname_r(name, he, buffer, buflen, &res, &h_errnop)
Matthias Klosec511b472010-05-08 11:01:39 +00003477 ]])],[
Guido van Rossum8db7d8b1999-03-23 16:40:33 +00003478 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003479 AC_DEFINE(HAVE_GETHOSTBYNAME_R_6_ARG, 1,
3480 [Define this if you have the 6-arg version of gethostbyname_r().])
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003481 AC_MSG_RESULT(yes)
Matthias Klosec511b472010-05-08 11:01:39 +00003482 ],[
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003483 AC_MSG_RESULT(no)
3484 AC_MSG_CHECKING([gethostbyname_r with 5 args])
Matthias Klosec511b472010-05-08 11:01:39 +00003485 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003486# include <netdb.h>
Matthias Klosec511b472010-05-08 11:01:39 +00003487 ]], [[
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003488 char *name;
3489 struct hostent *he;
Matthias Klosec511b472010-05-08 11:01:39 +00003490 char buffer[2048];
3491 int buflen = 2048;
3492 int h_errnop;
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003493
Matthias Klosec511b472010-05-08 11:01:39 +00003494 (void) gethostbyname_r(name, he, buffer, buflen, &h_errnop)
3495 ]])],
3496 [
Guido van Rossum8db7d8b1999-03-23 16:40:33 +00003497 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
Matthias Klosec511b472010-05-08 11:01:39 +00003498 AC_DEFINE(HAVE_GETHOSTBYNAME_R_5_ARG, 1,
3499 [Define this if you have the 5-arg version of gethostbyname_r().])
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003500 AC_MSG_RESULT(yes)
3501 ], [
3502 AC_MSG_RESULT(no)
Matthias Klosec511b472010-05-08 11:01:39 +00003503 AC_MSG_CHECKING([gethostbyname_r with 3 args])
3504 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3505# include <netdb.h>
3506 ]], [[
3507 char *name;
3508 struct hostent *he;
3509 struct hostent_data data;
3510
3511 (void) gethostbyname_r(name, he, &data);
3512 ]])],
3513 [
3514 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
3515 AC_DEFINE(HAVE_GETHOSTBYNAME_R_3_ARG, 1,
3516 [Define this if you have the 3-arg version of gethostbyname_r().])
3517 AC_MSG_RESULT(yes)
3518 ], [
3519 AC_MSG_RESULT(no)
3520 ])
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003521 ])
3522 ])
3523 CFLAGS=$OLD_CFLAGS
3524], [
Thomas Wouters3a584202000-08-05 23:28:51 +00003525 AC_CHECK_FUNCS(gethostbyname)
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003526])
3527AC_SUBST(HAVE_GETHOSTBYNAME_R_6_ARG)
3528AC_SUBST(HAVE_GETHOSTBYNAME_R_5_ARG)
3529AC_SUBST(HAVE_GETHOSTBYNAME_R_3_ARG)
Guido van Rossum8db7d8b1999-03-23 16:40:33 +00003530AC_SUBST(HAVE_GETHOSTBYNAME_R)
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003531AC_SUBST(HAVE_GETHOSTBYNAME)
3532
Guido van Rossum627b2d71993-12-24 10:39:16 +00003533# checks for system services
3534# (none yet)
3535
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003536# Linux requires this for correct f.p. operations
Jeremy Hyltonbe28f5b2000-07-27 21:03:04 +00003537AC_CHECK_FUNC(__fpu_control,
3538 [],
3539 [AC_CHECK_LIB(ieee, __fpu_control)
3540])
Guido van Rossum627b2d71993-12-24 10:39:16 +00003541
Guido van Rossum93274221997-05-09 02:42:00 +00003542# Check for --with-fpectl
Guido van Rossum93274221997-05-09 02:42:00 +00003543AC_MSG_CHECKING(for --with-fpectl)
Barry Warsawc0d24d82000-06-29 16:12:00 +00003544AC_ARG_WITH(fpectl,
Matthias Klose22520ea2010-05-08 10:14:46 +00003545 AS_HELP_STRING([--with-fpectl], [enable SIGFPE catching]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003546[
Guido van Rossum93274221997-05-09 02:42:00 +00003547if test "$withval" != no
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003548then
3549 AC_DEFINE(WANT_SIGFPE_HANDLER, 1,
3550 [Define if you want SIGFPE handled (see Include/pyfpe.h).])
3551 AC_MSG_RESULT(yes)
Guido van Rossum93274221997-05-09 02:42:00 +00003552else AC_MSG_RESULT(no)
Guido van Rossumef2255b2000-03-10 22:30:29 +00003553fi],
3554[AC_MSG_RESULT(no)])
Guido van Rossum93274221997-05-09 02:42:00 +00003555
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003556# check for --with-libm=...
3557AC_SUBST(LIBM)
Guido van Rossum4b6b5791996-09-09 20:09:34 +00003558case $ac_sys_system in
Guido van Rossum3dc0a512000-10-05 18:00:06 +00003559Darwin) ;;
Guido van Rossumec95c7b1998-08-04 17:59:56 +00003560BeOS) ;;
Guido van Rossum4b6b5791996-09-09 20:09:34 +00003561*) LIBM=-lm
3562esac
Guido van Rossum93274221997-05-09 02:42:00 +00003563AC_MSG_CHECKING(for --with-libm=STRING)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003564AC_ARG_WITH(libm,
Matthias Klose22520ea2010-05-08 10:14:46 +00003565 AS_HELP_STRING([--with-libm=STRING], [math library]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003566[
Guido van Rossum93274221997-05-09 02:42:00 +00003567if test "$withval" = no
3568then LIBM=
3569 AC_MSG_RESULT(force LIBM empty)
3570elif test "$withval" != yes
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003571then LIBM=$withval
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003572 AC_MSG_RESULT(set LIBM="$withval")
3573else AC_MSG_ERROR([proper usage is --with-libm=STRING])
Guido van Rossum93274221997-05-09 02:42:00 +00003574fi],
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003575[AC_MSG_RESULT(default LIBM="$LIBM")])
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003576
3577# check for --with-libc=...
3578AC_SUBST(LIBC)
Guido van Rossum93274221997-05-09 02:42:00 +00003579AC_MSG_CHECKING(for --with-libc=STRING)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003580AC_ARG_WITH(libc,
Matthias Klose22520ea2010-05-08 10:14:46 +00003581 AS_HELP_STRING([--with-libc=STRING], [C library]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003582[
Guido van Rossum93274221997-05-09 02:42:00 +00003583if test "$withval" = no
3584then LIBC=
3585 AC_MSG_RESULT(force LIBC empty)
3586elif test "$withval" != yes
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003587then LIBC=$withval
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003588 AC_MSG_RESULT(set LIBC="$withval")
3589else AC_MSG_ERROR([proper usage is --with-libc=STRING])
Guido van Rossum93274221997-05-09 02:42:00 +00003590fi],
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003591[AC_MSG_RESULT(default LIBC="$LIBC")])
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003592
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003593# **************************************************
3594# * Check for various properties of floating point *
3595# **************************************************
Mark Dickinson265d7382008-04-21 22:32:24 +00003596
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003597AC_MSG_CHECKING(whether C doubles are little-endian IEEE 754 binary64)
3598AC_CACHE_VAL(ac_cv_little_endian_double, [
Matthias Klosec511b472010-05-08 11:01:39 +00003599AC_RUN_IFELSE([AC_LANG_SOURCE([[
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003600#include <string.h>
3601int main() {
3602 double x = 9006104071832581.0;
3603 if (memcmp(&x, "\x05\x04\x03\x02\x01\xff\x3f\x43", 8) == 0)
3604 return 0;
3605 else
3606 return 1;
3607}
Matthias Klosec511b472010-05-08 11:01:39 +00003608]])],
3609[ac_cv_little_endian_double=yes],
3610[ac_cv_little_endian_double=no],
3611[ac_cv_little_endian_double=no])])
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003612AC_MSG_RESULT($ac_cv_little_endian_double)
3613if test "$ac_cv_little_endian_double" = yes
3614then
3615 AC_DEFINE(DOUBLE_IS_LITTLE_ENDIAN_IEEE754, 1,
3616 [Define if C doubles are 64-bit IEEE 754 binary format, stored
3617 with the least significant byte first])
3618fi
3619
3620AC_MSG_CHECKING(whether C doubles are big-endian IEEE 754 binary64)
3621AC_CACHE_VAL(ac_cv_big_endian_double, [
Matthias Klosec511b472010-05-08 11:01:39 +00003622AC_RUN_IFELSE([AC_LANG_SOURCE([[
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003623#include <string.h>
3624int main() {
3625 double x = 9006104071832581.0;
3626 if (memcmp(&x, "\x43\x3f\xff\x01\x02\x03\x04\x05", 8) == 0)
3627 return 0;
3628 else
3629 return 1;
3630}
Matthias Klosec511b472010-05-08 11:01:39 +00003631]])],
3632[ac_cv_big_endian_double=yes],
3633[ac_cv_big_endian_double=no],
3634[ac_cv_big_endian_double=no])])
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003635AC_MSG_RESULT($ac_cv_big_endian_double)
3636if test "$ac_cv_big_endian_double" = yes
3637then
3638 AC_DEFINE(DOUBLE_IS_BIG_ENDIAN_IEEE754, 1,
3639 [Define if C doubles are 64-bit IEEE 754 binary format, stored
3640 with the most significant byte first])
3641fi
3642
3643# Some ARM platforms use a mixed-endian representation for doubles.
3644# While Python doesn't currently have full support for these platforms
3645# (see e.g., issue 1762561), we can at least make sure that float <-> string
3646# conversions work.
3647AC_MSG_CHECKING(whether C doubles are ARM mixed-endian IEEE 754 binary64)
3648AC_CACHE_VAL(ac_cv_mixed_endian_double, [
Matthias Klosec511b472010-05-08 11:01:39 +00003649AC_RUN_IFELSE([AC_LANG_SOURCE([[
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003650#include <string.h>
3651int main() {
3652 double x = 9006104071832581.0;
3653 if (memcmp(&x, "\x01\xff\x3f\x43\x05\x04\x03\x02", 8) == 0)
3654 return 0;
3655 else
3656 return 1;
3657}
Matthias Klosec511b472010-05-08 11:01:39 +00003658]])],
3659[ac_cv_mixed_endian_double=yes],
3660[ac_cv_mixed_endian_double=no],
3661[ac_cv_mixed_endian_double=no])])
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003662AC_MSG_RESULT($ac_cv_mixed_endian_double)
3663if test "$ac_cv_mixed_endian_double" = yes
3664then
3665 AC_DEFINE(DOUBLE_IS_ARM_MIXED_ENDIAN_IEEE754, 1,
3666 [Define if C doubles are 64-bit IEEE 754 binary format, stored
3667 in ARM mixed-endian order (byte order 45670123)])
3668fi
3669
3670# The short float repr introduced in Python 3.1 requires the
3671# correctly-rounded string <-> double conversion functions from
3672# Python/dtoa.c, which in turn require that the FPU uses 53-bit
3673# rounding; this is a problem on x86, where the x87 FPU has a default
Mark Dickinsona548dee2009-11-15 13:12:43 +00003674# rounding precision of 64 bits. For gcc/x86, we can fix this by
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003675# using inline assembler to get and set the x87 FPU control word.
Mark Dickinsona548dee2009-11-15 13:12:43 +00003676
3677# This inline assembler syntax may also work for suncc and icc,
3678# so we try it on all platforms.
3679
3680AC_MSG_CHECKING(whether we can use gcc inline assembler to get and set x87 control word)
Matthias Klosec511b472010-05-08 11:01:39 +00003681AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
Mark Dickinsona548dee2009-11-15 13:12:43 +00003682 unsigned short cw;
3683 __asm__ __volatile__ ("fnstcw %0" : "=m" (cw));
3684 __asm__ __volatile__ ("fldcw %0" : : "m" (cw));
Matthias Klosec511b472010-05-08 11:01:39 +00003685]])],[have_gcc_asm_for_x87=yes],[have_gcc_asm_for_x87=no])
Mark Dickinsona548dee2009-11-15 13:12:43 +00003686AC_MSG_RESULT($have_gcc_asm_for_x87)
3687if test "$have_gcc_asm_for_x87" = yes
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003688then
Mark Dickinsona548dee2009-11-15 13:12:43 +00003689 AC_DEFINE(HAVE_GCC_ASM_FOR_X87, 1,
3690 [Define if we can use gcc inline assembler to get and set x87 control word])
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003691fi
Mark Dickinson7a3d8642008-04-22 00:54:27 +00003692
Mark Dickinson04b27232009-01-04 12:29:36 +00003693# Detect whether system arithmetic is subject to x87-style double
3694# rounding issues. The result of this test has little meaning on non
3695# IEEE 754 platforms. On IEEE 754, test should return 1 if rounding
3696# mode is round-to-nearest and double rounding issues are present, and
3697# 0 otherwise. See http://bugs.python.org/issue2937 for more info.
3698AC_MSG_CHECKING(for x87-style double rounding)
Mark Dickinson99abd142009-10-24 13:44:16 +00003699# $BASECFLAGS may affect the result
3700ac_save_cc="$CC"
3701CC="$CC $BASECFLAGS"
Matthias Klosec511b472010-05-08 11:01:39 +00003702AC_RUN_IFELSE([AC_LANG_SOURCE([[
Mark Dickinson04b27232009-01-04 12:29:36 +00003703#include <stdlib.h>
3704#include <math.h>
3705int main() {
3706 volatile double x, y, z;
3707 /* 1./(1-2**-53) -> 1+2**-52 (correct), 1.0 (double rounding) */
3708 x = 0.99999999999999989; /* 1-2**-53 */
3709 y = 1./x;
3710 if (y != 1.)
3711 exit(0);
3712 /* 1e16+2.99999 -> 1e16+2. (correct), 1e16+4. (double rounding) */
3713 x = 1e16;
3714 y = 2.99999;
3715 z = x + y;
3716 if (z != 1e16+4.)
3717 exit(0);
3718 /* both tests show evidence of double rounding */
3719 exit(1);
3720}
Matthias Klosec511b472010-05-08 11:01:39 +00003721]])],
3722[ac_cv_x87_double_rounding=no],
3723[ac_cv_x87_double_rounding=yes],
3724[ac_cv_x87_double_rounding=no])
Mark Dickinson99abd142009-10-24 13:44:16 +00003725CC="$ac_save_cc"
Mark Dickinson04b27232009-01-04 12:29:36 +00003726AC_MSG_RESULT($ac_cv_x87_double_rounding)
3727if test "$ac_cv_x87_double_rounding" = yes
3728then
3729 AC_DEFINE(X87_DOUBLE_ROUNDING, 1,
3730 [Define if arithmetic is subject to x87-style double rounding issue])
3731fi
3732
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003733# ************************************
3734# * Check for mathematical functions *
3735# ************************************
3736
3737LIBS_SAVE=$LIBS
3738LIBS="$LIBS $LIBM"
3739
Mark Dickinsonc63392c2009-11-28 13:13:13 +00003740# On FreeBSD 6.2, it appears that tanh(-0.) returns 0. instead of
3741# -0. on some architectures.
3742AC_MSG_CHECKING(whether tanh preserves the sign of zero)
3743AC_CACHE_VAL(ac_cv_tanh_preserves_zero_sign, [
Matthias Klosec511b472010-05-08 11:01:39 +00003744AC_RUN_IFELSE([AC_LANG_SOURCE([[
Mark Dickinsonc63392c2009-11-28 13:13:13 +00003745#include <math.h>
3746#include <stdlib.h>
3747int main() {
3748 /* return 0 if either negative zeros don't exist
3749 on this platform or if negative zeros exist
3750 and tanh(-0.) == -0. */
3751 if (atan2(0., -1.) == atan2(-0., -1.) ||
3752 atan2(tanh(-0.), -1.) == atan2(-0., -1.)) exit(0);
3753 else exit(1);
3754}
Matthias Klosec511b472010-05-08 11:01:39 +00003755]])],
3756[ac_cv_tanh_preserves_zero_sign=yes],
3757[ac_cv_tanh_preserves_zero_sign=no],
3758[ac_cv_tanh_preserves_zero_sign=no])])
Mark Dickinsonc63392c2009-11-28 13:13:13 +00003759AC_MSG_RESULT($ac_cv_tanh_preserves_zero_sign)
3760if test "$ac_cv_tanh_preserves_zero_sign" = yes
3761then
3762 AC_DEFINE(TANH_PRESERVES_ZERO_SIGN, 1,
3763 [Define if tanh(-0.) is -0., or if platform doesn't have signed zeros])
3764fi
3765
3766AC_CHECK_FUNCS([acosh asinh atanh copysign erf erfc expm1 finite gamma])
3767AC_CHECK_FUNCS([hypot lgamma log1p round tgamma])
3768AC_CHECK_DECLS([isinf, isnan, isfinite], [], [], [[#include <math.h>]])
3769
3770LIBS=$LIBS_SAVE
3771
Mark Dickinsonc4920e82009-11-20 19:30:22 +00003772# For multiprocessing module, check that sem_open
3773# actually works. For FreeBSD versions <= 7.2,
3774# the kernel module that provides POSIX semaphores
3775# isn't loaded by default, so an attempt to call
3776# sem_open results in a 'Signal 12' error.
3777AC_MSG_CHECKING(whether POSIX semaphores are enabled)
3778AC_CACHE_VAL(ac_cv_posix_semaphores_enabled,
Matthias Klosec511b472010-05-08 11:01:39 +00003779AC_RUN_IFELSE([AC_LANG_SOURCE([[
Mark Dickinsonc4920e82009-11-20 19:30:22 +00003780#include <unistd.h>
3781#include <fcntl.h>
3782#include <stdio.h>
3783#include <semaphore.h>
3784#include <sys/stat.h>
3785
3786int main(void) {
3787 sem_t *a = sem_open("/autoconf", O_CREAT, S_IRUSR|S_IWUSR, 0);
3788 if (a == SEM_FAILED) {
3789 perror("sem_open");
3790 return 1;
3791 }
3792 sem_close(a);
Mark Dickinson59dc89e2009-12-13 21:06:06 +00003793 sem_unlink("/autoconf");
Mark Dickinsonc4920e82009-11-20 19:30:22 +00003794 return 0;
3795}
Matthias Klosec511b472010-05-08 11:01:39 +00003796]])],
3797[ac_cv_posix_semaphores_enabled=yes],
3798[ac_cv_posix_semaphores_enabled=no],
3799[ac_cv_posix_semaphores_enabled=yes])
Mark Dickinsonc4920e82009-11-20 19:30:22 +00003800)
3801AC_MSG_RESULT($ac_cv_posix_semaphores_enabled)
3802if test $ac_cv_posix_semaphores_enabled = no
3803then
Mark Dickinson5afa6d42009-11-28 10:44:20 +00003804 AC_DEFINE(POSIX_SEMAPHORES_NOT_ENABLED, 1,
3805 [Define if POSIX semaphores aren't enabled on your system])
Mark Dickinsonc4920e82009-11-20 19:30:22 +00003806fi
3807
Jesse Noller355b1262009-04-02 00:03:28 +00003808# Multiprocessing check for broken sem_getvalue
3809AC_MSG_CHECKING(for broken sem_getvalue)
Alexandre Vassalotti00900892009-07-17 05:26:39 +00003810AC_CACHE_VAL(ac_cv_broken_sem_getvalue,
Matthias Klosec511b472010-05-08 11:01:39 +00003811AC_RUN_IFELSE([AC_LANG_SOURCE([[
Jesse Noller355b1262009-04-02 00:03:28 +00003812#include <unistd.h>
3813#include <fcntl.h>
3814#include <stdio.h>
3815#include <semaphore.h>
3816#include <sys/stat.h>
3817
3818int main(void){
Mark Dickinson59dc89e2009-12-13 21:06:06 +00003819 sem_t *a = sem_open("/autocftw", O_CREAT, S_IRUSR|S_IWUSR, 0);
Jesse Noller355b1262009-04-02 00:03:28 +00003820 int count;
3821 int res;
3822 if(a==SEM_FAILED){
3823 perror("sem_open");
3824 return 1;
3825
3826 }
3827 res = sem_getvalue(a, &count);
3828 sem_close(a);
Mark Dickinson59dc89e2009-12-13 21:06:06 +00003829 sem_unlink("/autocftw");
Jesse Noller355b1262009-04-02 00:03:28 +00003830 return res==-1 ? 1 : 0;
3831}
Matthias Klosec511b472010-05-08 11:01:39 +00003832]])],
3833[ac_cv_broken_sem_getvalue=no],
3834[ac_cv_broken_sem_getvalue=yes],
3835[ac_cv_broken_sem_getvalue=yes])
Jesse Noller355b1262009-04-02 00:03:28 +00003836)
Alexandre Vassalotti00900892009-07-17 05:26:39 +00003837AC_MSG_RESULT($ac_cv_broken_sem_getvalue)
3838if test $ac_cv_broken_sem_getvalue = yes
3839then
3840 AC_DEFINE(HAVE_BROKEN_SEM_GETVALUE, 1,
3841 [define to 1 if your sem_getvalue is broken.])
3842fi
Mark Dickinson04b27232009-01-04 12:29:36 +00003843
Mark Dickinsonefc82f72009-03-20 15:51:55 +00003844# determine what size digit to use for Python's longs
3845AC_MSG_CHECKING([digit size for Python's longs])
3846AC_ARG_ENABLE(big-digits,
Matthias Klose22520ea2010-05-08 10:14:46 +00003847AS_HELP_STRING([--enable-big-digits@<:@=BITS@:>@],[use big digits for Python longs [[BITS=30]]]),
Mark Dickinsonefc82f72009-03-20 15:51:55 +00003848[case $enable_big_digits in
3849yes)
3850 enable_big_digits=30 ;;
3851no)
3852 enable_big_digits=15 ;;
3853[15|30])
3854 ;;
3855*)
3856 AC_MSG_ERROR([bad value $enable_big_digits for --enable-big-digits; value should be 15 or 30]) ;;
3857esac
3858AC_MSG_RESULT($enable_big_digits)
3859AC_DEFINE_UNQUOTED(PYLONG_BITS_IN_DIGIT, $enable_big_digits, [Define as the preferred size in bits of long digits])
3860],
3861[AC_MSG_RESULT(no value specified)])
3862
Guido van Rossumef2255b2000-03-10 22:30:29 +00003863# check for wchar.h
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003864AC_CHECK_HEADER(wchar.h, [
3865 AC_DEFINE(HAVE_WCHAR_H, 1,
3866 [Define if the compiler provides a wchar.h header file.])
3867 wchar_h="yes"
3868],
Guido van Rossumef2255b2000-03-10 22:30:29 +00003869wchar_h="no"
3870)
3871
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003872# determine wchar_t size
3873if test "$wchar_h" = yes
3874then
Guido van Rossum67b26592001-10-20 14:21:45 +00003875 AC_CHECK_SIZEOF(wchar_t, 4, [#include <wchar.h>])
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003876fi
3877
Martin v. Löwisfa3bdea2003-09-04 18:50:54 +00003878AC_MSG_CHECKING(for UCS-4 tcl)
3879have_ucs4_tcl=no
Matthias Klosec511b472010-05-08 11:01:39 +00003880AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwisfa3bdea2003-09-04 18:50:54 +00003881#include <tcl.h>
3882#if TCL_UTF_MAX != 6
3883# error "NOT UCS4_TCL"
Matthias Klosec511b472010-05-08 11:01:39 +00003884#endif]], [[]])],[
Martin v. Löwisfa3bdea2003-09-04 18:50:54 +00003885 AC_DEFINE(HAVE_UCS4_TCL, 1, [Define this if you have tcl and TCL_UTF_MAX==6])
3886 have_ucs4_tcl=yes
Matthias Klosec511b472010-05-08 11:01:39 +00003887],[])
Martin v. Löwisfa3bdea2003-09-04 18:50:54 +00003888AC_MSG_RESULT($have_ucs4_tcl)
3889
Marc-André Lemburgd7160f82003-09-22 11:14:40 +00003890# check whether wchar_t is signed or not
3891if test "$wchar_h" = yes
3892then
3893 # check whether wchar_t is signed or not
3894 AC_MSG_CHECKING(whether wchar_t is signed)
3895 AC_CACHE_VAL(ac_cv_wchar_t_signed, [
Matthias Klosec511b472010-05-08 11:01:39 +00003896 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Marc-André Lemburgd7160f82003-09-22 11:14:40 +00003897 #include <wchar.h>
3898 int main()
3899 {
Martin v. Löwis44fe0e42006-04-11 07:15:30 +00003900 /* Success: exit code 0 */
3901 exit((((wchar_t) -1) < ((wchar_t) 0)) ? 0 : 1);
Marc-André Lemburgd7160f82003-09-22 11:14:40 +00003902 }
Matthias Klosec511b472010-05-08 11:01:39 +00003903 ]])],
3904 [ac_cv_wchar_t_signed=yes],
3905 [ac_cv_wchar_t_signed=no],
3906 [ac_cv_wchar_t_signed=yes])])
Marc-André Lemburgd7160f82003-09-22 11:14:40 +00003907 AC_MSG_RESULT($ac_cv_wchar_t_signed)
3908fi
3909
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003910AC_MSG_CHECKING(what type to use for unicode)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003911dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003912AC_ARG_ENABLE(unicode,
Benjamin Peterson66556b02010-05-25 02:23:32 +00003913 AS_HELP_STRING([--enable-unicode@<:@=ucs@<:@24@:>@@:>@], [Enable Unicode strings (default is ucs2)]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003914 [],
3915 [enable_unicode=yes])
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003916
3917if test $enable_unicode = yes
3918then
Martin v. Löwisfd917792001-06-27 20:22:04 +00003919 # Without any arguments, Py_UNICODE defaults to two-byte mode
Martin v. Löwisfa3bdea2003-09-04 18:50:54 +00003920 case "$have_ucs4_tcl" in
3921 yes) enable_unicode="ucs4"
3922 ;;
3923 *) enable_unicode="ucs2"
3924 ;;
3925 esac
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003926fi
3927
Martin v. Löwis0036cba2002-04-12 09:58:45 +00003928AH_TEMPLATE(Py_UNICODE_SIZE,
3929 [Define as the size of the unicode type.])
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003930case "$enable_unicode" in
3931ucs2) unicode_size="2"
3932 AC_DEFINE(Py_UNICODE_SIZE,2)
3933 ;;
3934ucs4) unicode_size="4"
3935 AC_DEFINE(Py_UNICODE_SIZE,4)
3936 ;;
Martin v. Löwised11a5d2012-05-20 10:42:17 +02003937no) ;; # To allow --disable-unicode
Ezio Melotti5820efb2010-02-27 00:05:42 +00003938*) AC_MSG_ERROR([invalid value for --enable-unicode. Use either ucs2 or ucs4 (lowercase).]) ;;
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003939esac
3940
Martin v. Löwis11437992002-04-12 09:54:03 +00003941AH_TEMPLATE(PY_UNICODE_TYPE,
3942 [Define as the integral type used for Unicode representation.])
Martin v. Löwis0036cba2002-04-12 09:58:45 +00003943
Martin v. Löwis339d0f72001-08-17 18:39:25 +00003944AC_SUBST(UNICODE_OBJS)
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003945if test "$enable_unicode" = "no"
3946then
Martin v. Löwis339d0f72001-08-17 18:39:25 +00003947 UNICODE_OBJS=""
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003948 AC_MSG_RESULT(not used)
3949else
Martin v. Löwis339d0f72001-08-17 18:39:25 +00003950 UNICODE_OBJS="Objects/unicodeobject.o Objects/unicodectype.o"
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003951 AC_DEFINE(Py_USING_UNICODE, 1,
3952 [Define if you want to have a Unicode type.])
Marc-André Lemburgd7160f82003-09-22 11:14:40 +00003953
3954 # wchar_t is only usable if it maps to an unsigned type
3955 if test "$unicode_size" = "$ac_cv_sizeof_wchar_t" \
Matthias Klose7dbeed72004-12-24 08:22:17 +00003956 -a "$ac_cv_wchar_t_signed" = "no"
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003957 then
3958 PY_UNICODE_TYPE="wchar_t"
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003959 AC_DEFINE(HAVE_USABLE_WCHAR_T, 1,
3960 [Define if you have a useable wchar_t type defined in wchar.h; useable
Marc-André Lemburgd7160f82003-09-22 11:14:40 +00003961 means wchar_t must be an unsigned type with at least 16 bits. (see
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003962 Include/unicodeobject.h).])
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003963 AC_DEFINE(PY_UNICODE_TYPE,wchar_t)
3964 elif test "$ac_cv_sizeof_short" = "$unicode_size"
3965 then
3966 PY_UNICODE_TYPE="unsigned short"
3967 AC_DEFINE(PY_UNICODE_TYPE,unsigned short)
3968 elif test "$ac_cv_sizeof_long" = "$unicode_size"
3969 then
3970 PY_UNICODE_TYPE="unsigned long"
3971 AC_DEFINE(PY_UNICODE_TYPE,unsigned long)
3972 else
3973 PY_UNICODE_TYPE="no type found"
3974 fi
3975 AC_MSG_RESULT($PY_UNICODE_TYPE)
3976fi
Guido van Rossumef2255b2000-03-10 22:30:29 +00003977
3978# check for endianness
3979AC_C_BIGENDIAN
3980
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00003981# Check whether right shifting a negative integer extends the sign bit
3982# or fills with zeros (like the Cray J90, according to Tim Peters).
3983AC_MSG_CHECKING(whether right shift extends the sign bit)
Vladimir Marangozova6180282000-07-12 05:05:06 +00003984AC_CACHE_VAL(ac_cv_rshift_extends_sign, [
Matthias Klosec511b472010-05-08 11:01:39 +00003985AC_RUN_IFELSE([AC_LANG_SOURCE([[
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00003986int main()
3987{
Vladimir Marangozova6180282000-07-12 05:05:06 +00003988 exit(((-1)>>3 == -1) ? 0 : 1);
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00003989}
Matthias Klosec511b472010-05-08 11:01:39 +00003990]])],
3991[ac_cv_rshift_extends_sign=yes],
3992[ac_cv_rshift_extends_sign=no],
3993[ac_cv_rshift_extends_sign=yes])])
Vladimir Marangozova6180282000-07-12 05:05:06 +00003994AC_MSG_RESULT($ac_cv_rshift_extends_sign)
3995if test "$ac_cv_rshift_extends_sign" = no
3996then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003997 AC_DEFINE(SIGNED_RIGHT_SHIFT_ZERO_FILLS, 1,
3998 [Define if i>>j for signed int i does not extend the sign bit
3999 when i < 0])
Vladimir Marangozova6180282000-07-12 05:05:06 +00004000fi
4001
Guido van Rossumcadfaec2001-01-05 14:45:49 +00004002# check for getc_unlocked and related locking functions
4003AC_MSG_CHECKING(for getc_unlocked() and friends)
4004AC_CACHE_VAL(ac_cv_have_getc_unlocked, [
Matthias Klosec511b472010-05-08 11:01:39 +00004005AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <stdio.h>]], [[
Guido van Rossumcadfaec2001-01-05 14:45:49 +00004006 FILE *f = fopen("/dev/null", "r");
4007 flockfile(f);
4008 getc_unlocked(f);
4009 funlockfile(f);
Matthias Klosec511b472010-05-08 11:01:39 +00004010]])],[ac_cv_have_getc_unlocked=yes],[ac_cv_have_getc_unlocked=no])])
Guido van Rossumcadfaec2001-01-05 14:45:49 +00004011AC_MSG_RESULT($ac_cv_have_getc_unlocked)
4012if test "$ac_cv_have_getc_unlocked" = yes
4013then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00004014 AC_DEFINE(HAVE_GETC_UNLOCKED, 1,
4015 [Define this if you have flockfile(), getc_unlocked(), and funlockfile()])
Guido van Rossumcadfaec2001-01-05 14:45:49 +00004016fi
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00004017
Neal Norwitzfe8e3d92006-01-07 21:07:20 +00004018# check where readline lives
Martin v. Löwis82bca632006-02-10 20:49:30 +00004019# save the value of LIBS so we don't actually link Python with readline
4020LIBS_no_readline=$LIBS
Gregory P. Smith980b99b2008-09-07 05:15:18 +00004021
4022# On some systems we need to link readline to a termcap compatible
4023# library. NOTE: Keep the precedence of listed libraries synchronised
4024# with setup.py.
4025py_cv_lib_readline=no
4026AC_MSG_CHECKING([how to link readline libs])
4027for py_libtermcap in "" ncursesw ncurses curses termcap; do
4028 if test -z "$py_libtermcap"; then
4029 READLINE_LIBS="-lreadline"
4030 else
4031 READLINE_LIBS="-lreadline -l$py_libtermcap"
4032 fi
4033 LIBS="$READLINE_LIBS $LIBS_no_readline"
4034 AC_LINK_IFELSE(
4035 [AC_LANG_CALL([],[readline])],
4036 [py_cv_lib_readline=yes])
4037 if test $py_cv_lib_readline = yes; then
4038 break
4039 fi
4040done
4041# Uncomment this line if you want to use READINE_LIBS in Makefile or scripts
4042#AC_SUBST([READLINE_LIBS])
Gregory P. Smith29ec7502008-09-07 19:18:16 +00004043if test $py_cv_lib_readline = no; then
Gregory P. Smith980b99b2008-09-07 05:15:18 +00004044 AC_MSG_RESULT([none])
4045else
4046 AC_MSG_RESULT([$READLINE_LIBS])
4047 AC_DEFINE(HAVE_LIBREADLINE, 1,
4048 [Define if you have the readline library (-lreadline).])
Neal Norwitzfe8e3d92006-01-07 21:07:20 +00004049fi
4050
Michael W. Hudson30ea2f22004-07-07 17:44:12 +00004051# check for readline 2.1
4052AC_CHECK_LIB(readline, rl_callback_handler_install,
4053 AC_DEFINE(HAVE_RL_CALLBACK, 1,
Gregory P. Smithff7b2d52008-09-03 05:57:48 +00004054 [Define if you have readline 2.1]), ,$READLINE_LIBS)
Michael W. Hudson30ea2f22004-07-07 17:44:12 +00004055
Guido van Rossumfaf5e4d2002-12-30 16:25:41 +00004056# check for readline 2.2
Matthias Klosec511b472010-05-08 11:01:39 +00004057AC_PREPROC_IFELSE([AC_LANG_SOURCE([[#include <readline/readline.h>]])],
4058 [have_readline=yes],
4059 [have_readline=no]
4060)
Guido van Rossumfaf5e4d2002-12-30 16:25:41 +00004061if test $have_readline = yes
4062then
4063 AC_EGREP_HEADER([extern int rl_completion_append_character;],
4064 [readline/readline.h],
4065 AC_DEFINE(HAVE_RL_COMPLETION_APPEND_CHARACTER, 1,
4066 [Define if you have readline 2.2]), )
Antoine Pitroud9ff74e2009-10-26 19:16:46 +00004067 AC_EGREP_HEADER([extern int rl_completion_suppress_append;],
4068 [readline/readline.h],
4069 AC_DEFINE(HAVE_RL_COMPLETION_SUPPRESS_APPEND, 1,
4070 [Define if you have rl_completion_suppress_append]), )
Guido van Rossumfaf5e4d2002-12-30 16:25:41 +00004071fi
4072
Martin v. Löwis0daad592001-09-30 21:09:59 +00004073# check for readline 4.0
4074AC_CHECK_LIB(readline, rl_pre_input_hook,
Martin v. Löwisc45929e2002-04-06 10:10:49 +00004075 AC_DEFINE(HAVE_RL_PRE_INPUT_HOOK, 1,
Gregory P. Smithff7b2d52008-09-03 05:57:48 +00004076 [Define if you have readline 4.0]), ,$READLINE_LIBS)
Martin v. Löwis0daad592001-09-30 21:09:59 +00004077
Martin v. Löwis58bd49f2007-09-04 13:13:14 +00004078# also in 4.0
4079AC_CHECK_LIB(readline, rl_completion_display_matches_hook,
4080 AC_DEFINE(HAVE_RL_COMPLETION_DISPLAY_MATCHES_HOOK, 1,
Gregory P. Smithff7b2d52008-09-03 05:57:48 +00004081 [Define if you have readline 4.0]), ,$READLINE_LIBS)
Martin v. Löwis58bd49f2007-09-04 13:13:14 +00004082
Guido van Rossum353ae582001-07-10 16:45:32 +00004083# check for readline 4.2
4084AC_CHECK_LIB(readline, rl_completion_matches,
Martin v. Löwisc45929e2002-04-06 10:10:49 +00004085 AC_DEFINE(HAVE_RL_COMPLETION_MATCHES, 1,
Gregory P. Smithff7b2d52008-09-03 05:57:48 +00004086 [Define if you have readline 4.2]), ,$READLINE_LIBS)
Guido van Rossum353ae582001-07-10 16:45:32 +00004087
Michael W. Hudson30ea2f22004-07-07 17:44:12 +00004088# also in readline 4.2
Matthias Klosec511b472010-05-08 11:01:39 +00004089AC_PREPROC_IFELSE([AC_LANG_SOURCE([[#include <readline/readline.h>]])],
4090 [have_readline=yes],
4091 [have_readline=no]
4092)
Michael W. Hudson30ea2f22004-07-07 17:44:12 +00004093if test $have_readline = yes
4094then
4095 AC_EGREP_HEADER([extern int rl_catch_signals;],
4096 [readline/readline.h],
4097 AC_DEFINE(HAVE_RL_CATCH_SIGNAL, 1,
4098 [Define if you can turn off readline's signal handling.]), )
4099fi
4100
Martin v. Löwis82bca632006-02-10 20:49:30 +00004101# End of readline checks: restore LIBS
4102LIBS=$LIBS_no_readline
4103
Thomas Wouterse38b2f12001-07-11 22:35:31 +00004104AC_MSG_CHECKING(for broken nice())
4105AC_CACHE_VAL(ac_cv_broken_nice, [
Matthias Klosec511b472010-05-08 11:01:39 +00004106AC_RUN_IFELSE([AC_LANG_SOURCE([[
Thomas Wouterse38b2f12001-07-11 22:35:31 +00004107int main()
4108{
4109 int val1 = nice(1);
4110 if (val1 != -1 && val1 == nice(2))
4111 exit(0);
4112 exit(1);
4113}
Matthias Klosec511b472010-05-08 11:01:39 +00004114]])],
4115[ac_cv_broken_nice=yes],
4116[ac_cv_broken_nice=no],
4117[ac_cv_broken_nice=no])])
Thomas Wouterse38b2f12001-07-11 22:35:31 +00004118AC_MSG_RESULT($ac_cv_broken_nice)
4119if test "$ac_cv_broken_nice" = yes
4120then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00004121 AC_DEFINE(HAVE_BROKEN_NICE, 1,
4122 [Define if nice() returns success/failure instead of the new priority.])
Thomas Wouterse38b2f12001-07-11 22:35:31 +00004123fi
4124
Nicholas Bastine62c5c82004-03-21 23:45:42 +00004125AC_MSG_CHECKING(for broken poll())
Alexandre Vassalotti00900892009-07-17 05:26:39 +00004126AC_CACHE_VAL(ac_cv_broken_poll,
Matthias Klosec511b472010-05-08 11:01:39 +00004127AC_RUN_IFELSE([AC_LANG_SOURCE([[
Nicholas Bastine62c5c82004-03-21 23:45:42 +00004128#include <poll.h>
4129
Alexandre Vassalotti66da2632009-07-17 06:17:33 +00004130int main()
4131{
Nicholas Bastine62c5c82004-03-21 23:45:42 +00004132 struct pollfd poll_struct = { 42, POLLIN|POLLPRI|POLLOUT, 0 };
Alexandre Vassalotti66da2632009-07-17 06:17:33 +00004133 int poll_test;
4134
Nicholas Bastine62c5c82004-03-21 23:45:42 +00004135 close (42);
4136
Alexandre Vassalotti66da2632009-07-17 06:17:33 +00004137 poll_test = poll(&poll_struct, 1, 0);
Nicholas Bastine62c5c82004-03-21 23:45:42 +00004138 if (poll_test < 0)
Alexandre Vassalotti66da2632009-07-17 06:17:33 +00004139 return 0;
Nicholas Bastine62c5c82004-03-21 23:45:42 +00004140 else if (poll_test == 0 && poll_struct.revents != POLLNVAL)
Alexandre Vassalotti66da2632009-07-17 06:17:33 +00004141 return 0;
Nicholas Bastine62c5c82004-03-21 23:45:42 +00004142 else
Alexandre Vassalotti66da2632009-07-17 06:17:33 +00004143 return 1;
4144}
Matthias Klosec511b472010-05-08 11:01:39 +00004145]])],
4146[ac_cv_broken_poll=yes],
4147[ac_cv_broken_poll=no],
4148[ac_cv_broken_poll=no]))
Nicholas Bastine62c5c82004-03-21 23:45:42 +00004149AC_MSG_RESULT($ac_cv_broken_poll)
4150if test "$ac_cv_broken_poll" = yes
4151then
4152 AC_DEFINE(HAVE_BROKEN_POLL, 1,
4153 [Define if poll() sets errno on invalid file descriptors.])
4154fi
4155
Brett Cannon43802422005-02-10 20:48:03 +00004156# Before we can test tzset, we need to check if struct tm has a tm_zone
4157# (which is not required by ISO C or UNIX spec) and/or if we support
4158# tzname[]
4159AC_STRUCT_TIMEZONE
Nicholas Bastine62c5c82004-03-21 23:45:42 +00004160
Brett Cannon43802422005-02-10 20:48:03 +00004161# check tzset(3) exists and works like we expect it to
Guido van Rossumd11b62e2003-03-14 21:51:36 +00004162AC_MSG_CHECKING(for working tzset())
4163AC_CACHE_VAL(ac_cv_working_tzset, [
Matthias Klosec511b472010-05-08 11:01:39 +00004164AC_RUN_IFELSE([AC_LANG_SOURCE([[
Guido van Rossumd11b62e2003-03-14 21:51:36 +00004165#include <stdlib.h>
4166#include <time.h>
Brett Cannon18367812003-09-19 00:59:16 +00004167#include <string.h>
Brett Cannon43802422005-02-10 20:48:03 +00004168
4169#if HAVE_TZNAME
4170extern char *tzname[];
4171#endif
4172
Guido van Rossumd11b62e2003-03-14 21:51:36 +00004173int main()
4174{
Brett Cannon18367812003-09-19 00:59:16 +00004175 /* Note that we need to ensure that not only does tzset(3)
4176 do 'something' with localtime, but it works as documented
4177 in the library reference and as expected by the test suite.
Brett Cannon43802422005-02-10 20:48:03 +00004178 This includes making sure that tzname is set properly if
4179 tm->tm_zone does not exist since it is the alternative way
4180 of getting timezone info.
Brett Cannon18367812003-09-19 00:59:16 +00004181
4182 Red Hat 6.2 doesn't understand the southern hemisphere
Brett Cannon43802422005-02-10 20:48:03 +00004183 after New Year's Day.
Brett Cannon18367812003-09-19 00:59:16 +00004184 */
4185
Brett Cannon43802422005-02-10 20:48:03 +00004186 time_t groundhogday = 1044144000; /* GMT-based */
Brett Cannon18367812003-09-19 00:59:16 +00004187 time_t midyear = groundhogday + (365 * 24 * 3600 / 2);
4188
Neal Norwitz7f2588c2003-04-11 15:35:53 +00004189 putenv("TZ=UTC+0");
Guido van Rossumd11b62e2003-03-14 21:51:36 +00004190 tzset();
Brett Cannon18367812003-09-19 00:59:16 +00004191 if (localtime(&groundhogday)->tm_hour != 0)
4192 exit(1);
Brett Cannon43802422005-02-10 20:48:03 +00004193#if HAVE_TZNAME
4194 /* For UTC, tzname[1] is sometimes "", sometimes " " */
4195 if (strcmp(tzname[0], "UTC") ||
4196 (tzname[1][0] != 0 && tzname[1][0] != ' '))
4197 exit(1);
4198#endif
Brett Cannon18367812003-09-19 00:59:16 +00004199
Neal Norwitz7f2588c2003-04-11 15:35:53 +00004200 putenv("TZ=EST+5EDT,M4.1.0,M10.5.0");
Guido van Rossumd11b62e2003-03-14 21:51:36 +00004201 tzset();
Brett Cannon18367812003-09-19 00:59:16 +00004202 if (localtime(&groundhogday)->tm_hour != 19)
Guido van Rossumd11b62e2003-03-14 21:51:36 +00004203 exit(1);
Brett Cannon43802422005-02-10 20:48:03 +00004204#if HAVE_TZNAME
4205 if (strcmp(tzname[0], "EST") || strcmp(tzname[1], "EDT"))
4206 exit(1);
4207#endif
Brett Cannon18367812003-09-19 00:59:16 +00004208
4209 putenv("TZ=AEST-10AEDT-11,M10.5.0,M3.5.0");
4210 tzset();
4211 if (localtime(&groundhogday)->tm_hour != 11)
4212 exit(1);
Brett Cannon43802422005-02-10 20:48:03 +00004213#if HAVE_TZNAME
4214 if (strcmp(tzname[0], "AEST") || strcmp(tzname[1], "AEDT"))
4215 exit(1);
4216#endif
4217
4218#if HAVE_STRUCT_TM_TM_ZONE
Brett Cannon18367812003-09-19 00:59:16 +00004219 if (strcmp(localtime(&groundhogday)->tm_zone, "AEDT"))
4220 exit(1);
4221 if (strcmp(localtime(&midyear)->tm_zone, "AEST"))
4222 exit(1);
Brett Cannon43802422005-02-10 20:48:03 +00004223#endif
Brett Cannon18367812003-09-19 00:59:16 +00004224
Guido van Rossumd11b62e2003-03-14 21:51:36 +00004225 exit(0);
4226}
Matthias Klosec511b472010-05-08 11:01:39 +00004227]])],
4228[ac_cv_working_tzset=yes],
4229[ac_cv_working_tzset=no],
4230[ac_cv_working_tzset=no])])
Guido van Rossumd11b62e2003-03-14 21:51:36 +00004231AC_MSG_RESULT($ac_cv_working_tzset)
4232if test "$ac_cv_working_tzset" = yes
4233then
4234 AC_DEFINE(HAVE_WORKING_TZSET, 1,
4235 [Define if tzset() actually switches the local timezone in a meaningful way.])
4236fi
4237
Martin v. Löwis94717ed2002-09-09 14:24:16 +00004238# Look for subsecond timestamps in struct stat
4239AC_MSG_CHECKING(for tv_nsec in struct stat)
4240AC_CACHE_VAL(ac_cv_stat_tv_nsec,
Matthias Klosec511b472010-05-08 11:01:39 +00004241AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/stat.h>]], [[
Martin v. Löwis94717ed2002-09-09 14:24:16 +00004242struct stat st;
4243st.st_mtim.tv_nsec = 1;
Matthias Klosec511b472010-05-08 11:01:39 +00004244]])],
4245[ac_cv_stat_tv_nsec=yes],
4246[ac_cv_stat_tv_nsec=no]))
Martin v. Löwis94717ed2002-09-09 14:24:16 +00004247AC_MSG_RESULT($ac_cv_stat_tv_nsec)
4248if test "$ac_cv_stat_tv_nsec" = yes
4249then
4250 AC_DEFINE(HAVE_STAT_TV_NSEC, 1,
4251 [Define if you have struct stat.st_mtim.tv_nsec])
4252fi
4253
Martin v. Löwisebd9d5b2005-08-09 15:00:59 +00004254# Look for BSD style subsecond timestamps in struct stat
4255AC_MSG_CHECKING(for tv_nsec2 in struct stat)
4256AC_CACHE_VAL(ac_cv_stat_tv_nsec2,
Matthias Klosec511b472010-05-08 11:01:39 +00004257AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/stat.h>]], [[
Martin v. Löwisebd9d5b2005-08-09 15:00:59 +00004258struct stat st;
4259st.st_mtimespec.tv_nsec = 1;
Matthias Klosec511b472010-05-08 11:01:39 +00004260]])],
4261[ac_cv_stat_tv_nsec2=yes],
4262[ac_cv_stat_tv_nsec2=no]))
Martin v. Löwisebd9d5b2005-08-09 15:00:59 +00004263AC_MSG_RESULT($ac_cv_stat_tv_nsec2)
4264if test "$ac_cv_stat_tv_nsec2" = yes
4265then
4266 AC_DEFINE(HAVE_STAT_TV_NSEC2, 1,
4267 [Define if you have struct stat.st_mtimensec])
4268fi
4269
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00004270# On HP/UX 11.0, mvwdelch is a block with a return statement
4271AC_MSG_CHECKING(whether mvwdelch is an expression)
4272AC_CACHE_VAL(ac_cv_mvwdelch_is_expression,
Matthias Klosec511b472010-05-08 11:01:39 +00004273AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <curses.h>]], [[
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00004274 int rtn;
4275 rtn = mvwdelch(0,0,0);
Matthias Klosec511b472010-05-08 11:01:39 +00004276]])],
4277[ac_cv_mvwdelch_is_expression=yes],
4278[ac_cv_mvwdelch_is_expression=no]))
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00004279AC_MSG_RESULT($ac_cv_mvwdelch_is_expression)
4280
4281if test "$ac_cv_mvwdelch_is_expression" = yes
4282then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00004283 AC_DEFINE(MVWDELCH_IS_EXPRESSION, 1,
4284 [Define if mvwdelch in curses.h is an expression.])
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00004285fi
4286
4287AC_MSG_CHECKING(whether WINDOW has _flags)
4288AC_CACHE_VAL(ac_cv_window_has_flags,
Matthias Klosec511b472010-05-08 11:01:39 +00004289AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <curses.h>]], [[
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00004290 WINDOW *w;
4291 w->_flags = 0;
Matthias Klosec511b472010-05-08 11:01:39 +00004292]])],
4293[ac_cv_window_has_flags=yes],
4294[ac_cv_window_has_flags=no]))
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00004295AC_MSG_RESULT($ac_cv_window_has_flags)
4296
4297
4298if test "$ac_cv_window_has_flags" = yes
4299then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00004300 AC_DEFINE(WINDOW_HAS_FLAGS, 1,
4301 [Define if WINDOW in curses.h offers a field _flags.])
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00004302fi
4303
Walter Dörwald4994d952006-06-19 08:07:50 +00004304AC_MSG_CHECKING(for is_term_resized)
Matthias Klosec511b472010-05-08 11:01:39 +00004305AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <curses.h>]], [[void *x=is_term_resized]])],
4306 [AC_DEFINE(HAVE_CURSES_IS_TERM_RESIZED, 1, Define if you have the 'is_term_resized' function.)
4307 AC_MSG_RESULT(yes)],
4308 [AC_MSG_RESULT(no)]
Walter Dörwald4994d952006-06-19 08:07:50 +00004309)
4310
Walter Dörwald05fdbf12006-06-19 08:14:09 +00004311AC_MSG_CHECKING(for resize_term)
Matthias Klosec511b472010-05-08 11:01:39 +00004312AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <curses.h>]], [[void *x=resize_term]])],
4313 [AC_DEFINE(HAVE_CURSES_RESIZE_TERM, 1, Define if you have the 'resize_term' function.)
4314 AC_MSG_RESULT(yes)],
4315 [AC_MSG_RESULT(no)]
Walter Dörwald4994d952006-06-19 08:07:50 +00004316)
4317
Walter Dörwald05fdbf12006-06-19 08:14:09 +00004318AC_MSG_CHECKING(for resizeterm)
Matthias Klosec511b472010-05-08 11:01:39 +00004319AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <curses.h>]], [[void *x=resizeterm]])],
4320 [AC_DEFINE(HAVE_CURSES_RESIZETERM, 1, Define if you have the 'resizeterm' function.)
4321 AC_MSG_RESULT(yes)],
4322 [AC_MSG_RESULT(no)]
Walter Dörwald4994d952006-06-19 08:07:50 +00004323)
4324
doko@python.orgd65e2ba2013-01-31 23:52:03 +01004325AC_MSG_NOTICE([checking for device files])
Martin v. Löwisfefbc202006-10-17 18:59:23 +00004326
doko@python.orgd65e2ba2013-01-31 23:52:03 +01004327dnl NOTE: Inform user how to proceed with files when cross compiling.
4328if test "x$cross_compiling" = xyes; then
4329 if test "${ac_cv_file__dev_ptmx+set}" != set; then
4330 AC_MSG_CHECKING([for /dev/ptmx])
4331 AC_MSG_RESULT([not set])
4332 AC_MSG_ERROR([set ac_cv_file__dev_ptmx to yes/no in your CONFIG_SITE file when cross compiling])
4333 fi
4334 if test "${ac_cv_file__dev_ptc+set}" != set; then
4335 AC_MSG_CHECKING([for /dev/ptc])
4336 AC_MSG_RESULT([not set])
4337 AC_MSG_ERROR([set ac_cv_file__dev_ptc to yes/no in your CONFIG_SITE file when cross compiling])
4338 fi
Martin v. Löwisfefbc202006-10-17 18:59:23 +00004339fi
4340
doko@python.orgd65e2ba2013-01-31 23:52:03 +01004341AC_CHECK_FILE(/dev/ptmx, [], [])
4342if test "x$ac_cv_file__dev_ptmx" = xyes; then
4343 AC_DEFINE(HAVE_DEV_PTMX, 1,
4344 [Define to 1 if you have the /dev/ptmx device file.])
4345fi
4346AC_CHECK_FILE(/dev/ptc, [], [])
4347if test "x$ac_cv_file__dev_ptc" = xyes; then
Martin v. Löwisfefbc202006-10-17 18:59:23 +00004348 AC_DEFINE(HAVE_DEV_PTC, 1,
doko@python.orgd65e2ba2013-01-31 23:52:03 +01004349 [Define to 1 if you have the /dev/ptc device file.])
Martin v. Löwisfefbc202006-10-17 18:59:23 +00004350fi
Neal Norwitz865400f2003-03-21 01:42:58 +00004351
Mark Dickinson82864d12009-11-15 16:18:58 +00004352if test "$have_long_long" = yes
4353then
4354 AC_MSG_CHECKING(for %lld and %llu printf() format support)
4355 AC_CACHE_VAL(ac_cv_have_long_long_format,
Matthias Klosec511b472010-05-08 11:01:39 +00004356 AC_RUN_IFELSE([AC_LANG_SOURCE([[[
Mark Dickinson82864d12009-11-15 16:18:58 +00004357 #include <stdio.h>
4358 #include <stddef.h>
4359 #include <string.h>
4360
4361 #ifdef HAVE_SYS_TYPES_H
4362 #include <sys/types.h>
4363 #endif
4364
4365 int main()
4366 {
4367 char buffer[256];
4368
4369 if (sprintf(buffer, "%lld", (long long)123) < 0)
4370 return 1;
4371 if (strcmp(buffer, "123"))
4372 return 1;
4373
4374 if (sprintf(buffer, "%lld", (long long)-123) < 0)
4375 return 1;
4376 if (strcmp(buffer, "-123"))
4377 return 1;
4378
4379 if (sprintf(buffer, "%llu", (unsigned long long)123) < 0)
4380 return 1;
4381 if (strcmp(buffer, "123"))
4382 return 1;
4383
4384 return 0;
4385 }
Matthias Klosec511b472010-05-08 11:01:39 +00004386 ]]])],
4387 [ac_cv_have_long_long_format=yes],
4388 [ac_cv_have_long_long_format=no],
doko@python.orgd65e2ba2013-01-31 23:52:03 +01004389 [ac_cv_have_long_long_format="cross -- assuming no"
4390 if test x$GCC = xyes; then
4391 save_CFLAGS=$CFLAGS
4392 CFLAGS="$CFLAGS -Werror -Wformat"
4393 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4394 #include <stdio.h>
4395 #include <stddef.h>
4396 ]], [[
4397 char *buffer;
4398 sprintf(buffer, "%lld", (long long)123);
4399 sprintf(buffer, "%lld", (long long)-123);
4400 sprintf(buffer, "%llu", (unsigned long long)123);
4401 ]])],
4402 ac_cv_have_long_long_format=yes
4403 )
4404 CFLAGS=$save_CFLAGS
4405 fi])
Mark Dickinson82864d12009-11-15 16:18:58 +00004406 )
4407 AC_MSG_RESULT($ac_cv_have_long_long_format)
4408fi
4409
Mark Dickinson5ce84742009-12-31 20:48:04 +00004410if test "$ac_cv_have_long_long_format" = yes
Mark Dickinson82864d12009-11-15 16:18:58 +00004411then
4412 AC_DEFINE(PY_FORMAT_LONG_LONG, "ll",
4413 [Define to printf format modifier for long long type])
4414fi
4415
Ronald Oussoren315cd0c2009-11-19 16:25:21 +00004416if test $ac_sys_system = Darwin
4417then
4418 LIBS="$LIBS -framework CoreFoundation"
4419fi
4420
Mark Dickinson82864d12009-11-15 16:18:58 +00004421
Gregory P. Smithd8cb2d92009-11-02 02:02:38 +00004422AC_CACHE_CHECK([for %zd printf() format support], ac_cv_have_size_t_format, [dnl
Matthias Klosec511b472010-05-08 11:01:39 +00004423AC_RUN_IFELSE([AC_LANG_SOURCE([[
Alexandre Vassalottie7cf1182009-07-17 06:33:51 +00004424#include <stdio.h>
Brett Cannon09d12362006-05-11 05:11:33 +00004425#include <stddef.h>
4426#include <string.h>
4427
Christian Heimesdb3d6cb2007-12-16 21:39:43 +00004428#ifdef HAVE_SYS_TYPES_H
4429#include <sys/types.h>
4430#endif
Neal Norwitz4a8fbdb2006-09-22 08:16:26 +00004431
4432#ifdef HAVE_SSIZE_T
4433typedef ssize_t Py_ssize_t;
4434#elif SIZEOF_VOID_P == SIZEOF_LONG
4435typedef long Py_ssize_t;
4436#else
4437typedef int Py_ssize_t;
4438#endif
Brett Cannon09d12362006-05-11 05:11:33 +00004439
Christian Heimesdb3d6cb2007-12-16 21:39:43 +00004440int main()
4441{
4442 char buffer[256];
4443
Brett Cannon09d12362006-05-11 05:11:33 +00004444 if(sprintf(buffer, "%zd", (size_t)123) < 0)
4445 return 1;
4446
Neal Norwitz4a8fbdb2006-09-22 08:16:26 +00004447 if (strcmp(buffer, "123"))
Brett Cannon09d12362006-05-11 05:11:33 +00004448 return 1;
Neal Norwitz4a8fbdb2006-09-22 08:16:26 +00004449
4450 if (sprintf(buffer, "%zd", (Py_ssize_t)-123) < 0)
4451 return 1;
4452
4453 if (strcmp(buffer, "-123"))
4454 return 1;
4455
Brett Cannon09d12362006-05-11 05:11:33 +00004456 return 0;
Alexandre Vassalotti00900892009-07-17 05:26:39 +00004457}
Matthias Klosec511b472010-05-08 11:01:39 +00004458]])],
4459[ac_cv_have_size_t_format=yes],
4460[ac_cv_have_size_t_format=no],
4461[ac_cv_have_size_t_format="cross -- assuming yes"
4462])])
Gregory P. Smithd8cb2d92009-11-02 02:02:38 +00004463if test "$ac_cv_have_size_t_format" != no ; then
Alexandre Vassalotti00900892009-07-17 05:26:39 +00004464 AC_DEFINE(PY_FORMAT_SIZE_T, "z",
4465 [Define to printf format modifier for Py_ssize_t])
4466fi
Brett Cannon09d12362006-05-11 05:11:33 +00004467
Martin v. Löwis01c04012002-11-11 14:58:44 +00004468AC_CHECK_TYPE(socklen_t,,
4469 AC_DEFINE(socklen_t,int,
Matthias Klose5183ebd2010-04-24 16:38:36 +00004470 [Define to `int' if <sys/socket.h> does not define.]),[
Martin v. Löwis01c04012002-11-11 14:58:44 +00004471#ifdef HAVE_SYS_TYPES_H
4472#include <sys/types.h>
4473#endif
Guido van Rossum95713eb2000-05-18 20:53:31 +00004474#ifdef HAVE_SYS_SOCKET_H
4475#include <sys/socket.h>
4476#endif
Martin v. Löwis01c04012002-11-11 14:58:44 +00004477])
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00004478
R. David Murray1d9d16e2010-10-16 00:43:13 +00004479case $ac_sys_system in
4480AIX*)
4481 AC_DEFINE(HAVE_BROKEN_PIPE_BUF, 1, [Define if the system reports an invalid PIPE_BUF value.]) ;;
4482esac
4483
4484
Martin v. Löwis06f15bb2001-12-02 13:02:32 +00004485AC_SUBST(THREADHEADERS)
4486
4487for h in `(cd $srcdir;echo Python/thread_*.h)`
4488do
4489 THREADHEADERS="$THREADHEADERS \$(srcdir)/$h"
4490done
4491
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00004492AC_SUBST(SRCDIRS)
Neal Norwitzd24499d2005-12-18 21:36:39 +00004493SRCDIRS="Parser Grammar Objects Python Modules Mac"
Andrew M. Kuchling8abedde2001-01-26 22:55:24 +00004494AC_MSG_CHECKING(for build directories)
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00004495for dir in $SRCDIRS; do
4496 if test ! -d $dir; then
4497 mkdir $dir
Fred Drake884d3ba2000-11-02 17:52:56 +00004498 fi
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00004499done
4500AC_MSG_RESULT(done)
Fred Drake036144d2000-10-26 17:09:35 +00004501
Guido van Rossum627b2d71993-12-24 10:39:16 +00004502# generate output files
Antoine Pitrouf2caeed2009-05-24 20:23:57 +00004503AC_CONFIG_FILES(Makefile.pre Modules/Setup.config Misc/python.pc)
Antoine Pitrouaabdceb2010-09-10 20:03:17 +00004504AC_CONFIG_FILES([Modules/ld_so_aix], [chmod +x Modules/ld_so_aix])
Martin v. Löwis88afe662002-10-26 13:47:44 +00004505AC_OUTPUT
Neil Schemenauer61c51152001-01-26 16:18:16 +00004506
Martin v. Löwisf7afe952006-04-14 15:16:15 +00004507echo "creating Modules/Setup"
Neil Schemenauer61c51152001-01-26 16:18:16 +00004508if test ! -f Modules/Setup
4509then
4510 cp $srcdir/Modules/Setup.dist Modules/Setup
4511fi
4512
Martin v. Löwisf7afe952006-04-14 15:16:15 +00004513echo "creating Modules/Setup.local"
Neil Schemenauer61c51152001-01-26 16:18:16 +00004514if test ! -f Modules/Setup.local
4515then
4516 echo "# Edit this file for local setup changes" >Modules/Setup.local
4517fi
4518
4519echo "creating Makefile"
4520$SHELL $srcdir/Modules/makesetup -c $srcdir/Modules/config.c.in \
4521 -s Modules Modules/Setup.config \
Neil Schemenauerf8b71c52001-04-21 17:41:16 +00004522 Modules/Setup.local Modules/Setup
Skip Montanaro7221d932007-08-22 19:02:16 +00004523
4524case $ac_sys_system in
4525BeOS)
4526 AC_MSG_WARN([
4527
4528 Support for BeOS is deprecated as of Python 2.6.
4529 See PEP 11 for the gory details.
4530 ])
4531 ;;
4532*) ;;
4533esac
4534
Neil Schemenauer66252162001-02-19 04:47:42 +00004535mv config.c Modules