blob: 16da9f39996b24d8fba3d7162317fb14a9f98f23 [file] [log] [blame]
Benjamin Petersond7c77842008-05-26 13:01:25 +00001dnl ***********************************************
2dnl * Please run autoreconf to test your changes! *
3dnl ***********************************************
Martin v. Löwis88afe662002-10-26 13:47:44 +00004
5# Set VERSION so we only need to edit in one place (i.e., here)
Martin v. Löwis174440b2008-10-03 08:59:41 +00006m4_define(PYTHON_VERSION, 2.7)
Martin v. Löwis88afe662002-10-26 13:47:44 +00007
Georg Brandl71f4fbb2011-02-25 11:04:50 +00008AC_PREREQ(2.65)
Alexandre Vassalotti130ae152009-07-18 00:31:06 +00009
Guido van Rossum76be6ed1995-01-02 18:33:54 +000010AC_REVISION($Revision$)
Georg Brandl464432d2009-05-20 18:24:08 +000011AC_INIT(python, PYTHON_VERSION, http://bugs.python.org/)
Martin v. Löwis88afe662002-10-26 13:47:44 +000012AC_CONFIG_SRCDIR([Include/object.h])
Martin v. Löwis4f1cd8b2001-07-26 13:41:06 +000013AC_CONFIG_HEADER(pyconfig.h)
Guido van Rossum627b2d71993-12-24 10:39:16 +000014
doko@python.orgd65e2ba2013-01-31 23:52:03 +010015AC_CANONICAL_HOST
16AC_SUBST(build)
17AC_SUBST(host)
18
Ned Deily983df862014-08-22 13:30:59 -070019# pybuilddir.txt will be created by --generate-posix-vars in the Makefile
20rm -f pybuilddir.txt
21
doko@python.orgd65e2ba2013-01-31 23:52:03 +010022if test "$cross_compiling" = yes; then
23 AC_MSG_CHECKING([for python interpreter for cross build])
24 if test -z "$PYTHON_FOR_BUILD"; then
25 for interp in python$PACKAGE_VERSION python2 python; do
26 which $interp >/dev/null 2>&1 || continue
27 if $interp -c 'import sys;sys.exit(not (sys.version_info@<:@:2@:>@ >= (2,7) and sys.version_info@<:@0@:>@ < 3))'; then
28 break
29 fi
30 interp=
31 done
32 if test x$interp = x; then
33 AC_MSG_ERROR([python$PACKAGE_VERSION interpreter not found])
34 fi
35 AC_MSG_RESULT($interp)
36 PYTHON_FOR_BUILD='_PYTHON_PROJECT_BASE=$(abs_builddir) _PYTHON_HOST_PLATFORM=$(_PYTHON_HOST_PLATFORM) PYTHONPATH=$(shell test -f pybuilddir.txt && echo $(abs_builddir)/`cat pybuilddir.txt`:)$(srcdir)/Lib:$(srcdir)/Lib/plat-$(MACHDEP) '$interp
37 fi
38elif test "$cross_compiling" = maybe; then
39 AC_MSG_ERROR([Cross compiling required --host=HOST-TUPLE and --build=ARCH])
40else
41 PYTHON_FOR_BUILD='./$(BUILDPYTHON) -E'
42fi
43AC_SUBST(PYTHON_FOR_BUILD)
44
Georg Brandlbcd64a32009-03-31 21:45:18 +000045dnl Ensure that if prefix is specified, it does not end in a slash. If
46dnl it does, we get path names containing '//' which is both ugly and
47dnl can cause trouble.
48
49dnl Last slash shouldn't be stripped if prefix=/
50if test "$prefix" != "/"; then
51 prefix=`echo "$prefix" | sed -e 's/\/$//g'`
52fi
53
Martin v. Löwis8316feb2003-06-14 07:48:07 +000054dnl This is for stuff that absolutely must end up in pyconfig.h.
55dnl Please use pyport.h instead, if possible.
Martin v. Löwisbddf5a52002-11-11 13:37:28 +000056AH_TOP([
57#ifndef Py_PYCONFIG_H
58#define Py_PYCONFIG_H
59])
Martin v. Löwis11437992002-04-12 09:54:03 +000060AH_BOTTOM([
Martin v. Löwis11437992002-04-12 09:54:03 +000061/* Define the macros needed if on a UnixWare 7.x system. */
62#if defined(__USLC__) && defined(__SCO_VERSION__)
63#define STRICT_SYSV_CURSES /* Don't use ncurses extensions */
64#endif
Martin v. Löwisbddf5a52002-11-11 13:37:28 +000065
66#endif /*Py_PYCONFIG_H*/
Martin v. Löwis11437992002-04-12 09:54:03 +000067])
68
Martin v. Löwis8316feb2003-06-14 07:48:07 +000069# We don't use PACKAGE_ variables, and they cause conflicts
70# with other autoconf-based packages that include Python.h
71grep -v 'define PACKAGE_' <confdefs.h >confdefs.h.new
72rm confdefs.h
73mv confdefs.h.new confdefs.h
74
Guido van Rossum642b6781997-07-19 19:35:41 +000075AC_SUBST(VERSION)
Martin v. Löwis88afe662002-10-26 13:47:44 +000076VERSION=PYTHON_VERSION
Guido van Rossum642b6781997-07-19 19:35:41 +000077
Martin v. Löwis1142de32002-03-29 16:28:31 +000078AC_SUBST(SOVERSION)
79SOVERSION=1.0
80
Martin v. Löwis6f18a3c2002-07-20 08:51:52 +000081# The later defininition of _XOPEN_SOURCE disables certain features
82# on Linux, so we need _GNU_SOURCE to re-enable them (makedev, tm_zone).
83AC_DEFINE(_GNU_SOURCE, 1, [Define on Linux to activate all library features])
84
Martin v. Löwisbcd93962003-05-03 10:32:18 +000085# The later defininition of _XOPEN_SOURCE and _POSIX_C_SOURCE disables
86# certain features on NetBSD, so we need _NETBSD_SOURCE to re-enable
87# them.
88AC_DEFINE(_NETBSD_SOURCE, 1, [Define on NetBSD to activate all library features])
89
Andrew MacIntyreabccf412003-07-02 13:53:25 +000090# The later defininition of _XOPEN_SOURCE and _POSIX_C_SOURCE disables
91# certain features on FreeBSD, so we need __BSD_VISIBLE to re-enable
92# them.
93AC_DEFINE(__BSD_VISIBLE, 1, [Define on FreeBSD to activate all library features])
94
Martin v. Löwisd6320502004-08-12 13:45:08 +000095# The later defininition of _XOPEN_SOURCE and _POSIX_C_SOURCE disables
96# u_int on Irix 5.3. Defining _BSD_TYPES brings it back.
97AC_DEFINE(_BSD_TYPES, 1, [Define on Irix to enable u_int])
98
Ronald Oussoren5640ce22008-06-05 12:58:24 +000099# The later defininition of _XOPEN_SOURCE and _POSIX_C_SOURCE disables
100# certain features on Mac OS X, so we need _DARWIN_C_SOURCE to re-enable
101# them.
102AC_DEFINE(_DARWIN_C_SOURCE, 1, [Define on Darwin to activate all library features])
103
104
Martin v. Löwise981a4e2002-11-11 13:26:51 +0000105define_xopen_source=yes
Martin v. Löwis6f18a3c2002-07-20 08:51:52 +0000106
Neil Schemenauer4edbc2a2001-03-22 00:34:03 +0000107# Arguments passed to configure.
108AC_SUBST(CONFIG_ARGS)
109CONFIG_ARGS="$ac_configure_args"
110
Ronald Oussoren3c0a1262010-01-17 19:27:57 +0000111AC_MSG_CHECKING([for --enable-universalsdk])
Ronald Oussoren988117f2006-04-29 11:31:35 +0000112AC_ARG_ENABLE(universalsdk,
Matthias Klose22520ea2010-05-08 10:14:46 +0000113 AS_HELP_STRING([--enable-universalsdk@<:@=SDKDIR@:>@], [Build against Mac OS X 10.4u SDK (ppc/i386)]),
Ronald Oussoren988117f2006-04-29 11:31:35 +0000114[
115 case $enableval in
116 yes)
117 enableval=/Developer/SDKs/MacOSX10.4u.sdk
Ronald Oussoren3c0a1262010-01-17 19:27:57 +0000118 if test ! -d "${enableval}"
119 then
120 enableval=/
121 fi
Ronald Oussoren988117f2006-04-29 11:31:35 +0000122 ;;
123 esac
124 case $enableval in
125 no)
126 UNIVERSALSDK=
127 enable_universalsdk=
128 ;;
129 *)
130 UNIVERSALSDK=$enableval
Ronald Oussoren3c0a1262010-01-17 19:27:57 +0000131 if test ! -d "${UNIVERSALSDK}"
132 then
133 AC_MSG_ERROR([--enable-universalsdk specifies non-existing SDK: ${UNIVERSALSDK}])
134 fi
Ronald Oussoren988117f2006-04-29 11:31:35 +0000135 ;;
136 esac
Ronald Oussoren3c0a1262010-01-17 19:27:57 +0000137
Ronald Oussoren988117f2006-04-29 11:31:35 +0000138],[
139 UNIVERSALSDK=
140 enable_universalsdk=
141])
Ronald Oussoren3c0a1262010-01-17 19:27:57 +0000142if test -n "${UNIVERSALSDK}"
143then
144 AC_MSG_RESULT(${UNIVERSALSDK})
145else
146 AC_MSG_RESULT(no)
147fi
Ronald Oussoren988117f2006-04-29 11:31:35 +0000148AC_SUBST(UNIVERSALSDK)
149
Benjamin Peterson0e6ea5d2008-07-16 20:17:04 +0000150AC_SUBST(ARCH_RUN_32BIT)
Ned Deily8e60f6e2013-05-30 00:14:29 -0700151ARCH_RUN_32BIT=""
Benjamin Peterson0e6ea5d2008-07-16 20:17:04 +0000152
Ronald Oussoren5640ce22008-06-05 12:58:24 +0000153UNIVERSAL_ARCHS="32-bit"
Ronald Oussoren92919a62009-12-24 13:30:58 +0000154AC_SUBST(LIPO_32BIT_FLAGS)
Ronald Oussoren5640ce22008-06-05 12:58:24 +0000155AC_MSG_CHECKING(for --with-universal-archs)
156AC_ARG_WITH(universal-archs,
Matthias Klose22520ea2010-05-08 10:14:46 +0000157 AS_HELP_STRING([--with-universal-archs=ARCH], [select architectures for universal build ("32-bit", "64-bit", "3-way", "intel" or "all")]),
Ronald Oussoren5640ce22008-06-05 12:58:24 +0000158[
159 AC_MSG_RESULT($withval)
160 UNIVERSAL_ARCHS="$withval"
Ronald Oussoren9ebd2422009-09-29 13:00:44 +0000161 if test "${enable_universalsdk}" ; then
162 :
163 else
164 AC_MSG_ERROR([--with-universal-archs without --enable-universalsdk. See Mac/README])
165 fi
Ronald Oussoren5640ce22008-06-05 12:58:24 +0000166],
167[
168 AC_MSG_RESULT(32-bit)
169])
170
171
172
Ronald Oussoren580c7fe2008-05-02 19:45:11 +0000173AC_ARG_WITH(framework-name,
Matthias Klose22520ea2010-05-08 10:14:46 +0000174 AS_HELP_STRING([--with-framework-name=FRAMEWORK],
Matthias Klose5183ebd2010-04-24 16:38:36 +0000175 [specify an alternate name of the framework built with --enable-framework]),
Ronald Oussoren580c7fe2008-05-02 19:45:11 +0000176[
Ronald Oussoren9ebd2422009-09-29 13:00:44 +0000177 if test "${enable_framework}"; then
178 :
179 else
180 AC_MSG_ERROR([--with-framework-name without --enable-framework. See Mac/README])
181 fi
Ronald Oussoren580c7fe2008-05-02 19:45:11 +0000182 PYTHONFRAMEWORK=${withval}
183 PYTHONFRAMEWORKDIR=${withval}.framework
184 PYTHONFRAMEWORKIDENTIFIER=org.python.`echo $withval | tr '[A-Z]' '[a-z]'`
185 ],[
186 PYTHONFRAMEWORK=Python
187 PYTHONFRAMEWORKDIR=Python.framework
188 PYTHONFRAMEWORKIDENTIFIER=org.python.python
189])
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000190dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000191AC_ARG_ENABLE(framework,
Matthias Klose22520ea2010-05-08 10:14:46 +0000192 AS_HELP_STRING([--enable-framework@<:@=INSTALLDIR@:>@], [Build (MacOSX|Darwin) framework]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000193[
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000194 case $enableval in
195 yes)
196 enableval=/Library/Frameworks
Jack Jansen127e56e2001-09-11 14:41:54 +0000197 esac
198 case $enableval in
199 no)
200 PYTHONFRAMEWORK=
201 PYTHONFRAMEWORKDIR=no-framework
202 PYTHONFRAMEWORKPREFIX=
203 PYTHONFRAMEWORKINSTALLDIR=
Ronald Oussoren567a8ff2006-05-26 11:43:26 +0000204 FRAMEWORKINSTALLFIRST=
205 FRAMEWORKINSTALLLAST=
Ronald Oussoren5b787322006-06-06 19:50:24 +0000206 FRAMEWORKALTINSTALLFIRST=
207 FRAMEWORKALTINSTALLLAST=
Ronald Oussoren2db3a8f2006-06-07 19:06:01 +0000208 if test "x${prefix}" = "xNONE"; then
209 FRAMEWORKUNIXTOOLSPREFIX="${ac_default_prefix}"
210 else
211 FRAMEWORKUNIXTOOLSPREFIX="${prefix}"
212 fi
Jack Jansen127e56e2001-09-11 14:41:54 +0000213 enable_framework=
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000214 ;;
215 *)
Ronald Oussoren01d149f2010-04-30 11:20:14 +0000216 PYTHONFRAMEWORKPREFIX="${enableval}"
Jack Jansen127e56e2001-09-11 14:41:54 +0000217 PYTHONFRAMEWORKINSTALLDIR=$PYTHONFRAMEWORKPREFIX/$PYTHONFRAMEWORKDIR
Ronald Oussoren567a8ff2006-05-26 11:43:26 +0000218 FRAMEWORKINSTALLFIRST="frameworkinstallstructure"
Ronald Oussoren5640ce22008-06-05 12:58:24 +0000219 FRAMEWORKALTINSTALLFIRST="frameworkinstallstructure bininstall maninstall"
Ronald Oussoren92919a62009-12-24 13:30:58 +0000220 FRAMEWORKINSTALLLAST="frameworkinstallmaclib frameworkinstallapps frameworkinstallunixtools"
221 FRAMEWORKALTINSTALLLAST="frameworkinstallmaclib frameworkinstallapps frameworkaltinstallunixtools"
Ronald Oussoren01d149f2010-04-30 11:20:14 +0000222 FRAMEWORKINSTALLAPPSPREFIX="/Applications"
Ronald Oussoren5640ce22008-06-05 12:58:24 +0000223
Ronald Oussoren2db3a8f2006-06-07 19:06:01 +0000224 if test "x${prefix}" = "xNONE" ; then
225 FRAMEWORKUNIXTOOLSPREFIX="${ac_default_prefix}"
Ronald Oussoren01d149f2010-04-30 11:20:14 +0000226
Ronald Oussoren2db3a8f2006-06-07 19:06:01 +0000227 else
228 FRAMEWORKUNIXTOOLSPREFIX="${prefix}"
229 fi
Ronald Oussoren01d149f2010-04-30 11:20:14 +0000230
231 case "${enableval}" in
232 /System*)
233 FRAMEWORKINSTALLAPPSPREFIX="/Applications"
234 if test "${prefix}" = "NONE" ; then
235 # See below
236 FRAMEWORKUNIXTOOLSPREFIX="/usr"
237 fi
238 ;;
239
240 /Library*)
241 FRAMEWORKINSTALLAPPSPREFIX="/Applications"
242 ;;
243
244 */Library/Frameworks)
245 MDIR="`dirname "${enableval}"`"
246 MDIR="`dirname "${MDIR}"`"
247 FRAMEWORKINSTALLAPPSPREFIX="${MDIR}/Applications"
248
249 if test "${prefix}" = "NONE"; then
250 # User hasn't specified the
251 # --prefix option, but wants to install
252 # the framework in a non-default location,
253 # ensure that the compatibility links get
254 # installed relative to that prefix as well
255 # instead of in /usr/local.
256 FRAMEWORKUNIXTOOLSPREFIX="${MDIR}"
257 fi
258 ;;
259
260 *)
261 FRAMEWORKINSTALLAPPSPREFIX="/Applications"
262 ;;
263 esac
264
Jack Jansen127e56e2001-09-11 14:41:54 +0000265 prefix=$PYTHONFRAMEWORKINSTALLDIR/Versions/$VERSION
Ronald Oussoren836b0392006-05-14 19:56:34 +0000266
Ronald Oussoren580c7fe2008-05-02 19:45:11 +0000267 # Add files for Mac specific code to the list of output
Ronald Oussoren836b0392006-05-14 19:56:34 +0000268 # files:
Ronald Oussoren2db3a8f2006-06-07 19:06:01 +0000269 AC_CONFIG_FILES(Mac/Makefile)
270 AC_CONFIG_FILES(Mac/PythonLauncher/Makefile)
271 AC_CONFIG_FILES(Mac/IDLE/Makefile)
Ronald Oussoren580c7fe2008-05-02 19:45:11 +0000272 AC_CONFIG_FILES(Mac/Resources/framework/Info.plist)
273 AC_CONFIG_FILES(Mac/Resources/app/Info.plist)
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000274 esac
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000275 ],[
276 PYTHONFRAMEWORK=
Jack Jansen127e56e2001-09-11 14:41:54 +0000277 PYTHONFRAMEWORKDIR=no-framework
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000278 PYTHONFRAMEWORKPREFIX=
279 PYTHONFRAMEWORKINSTALLDIR=
Ronald Oussoren567a8ff2006-05-26 11:43:26 +0000280 FRAMEWORKINSTALLFIRST=
281 FRAMEWORKINSTALLLAST=
Ronald Oussoren5b787322006-06-06 19:50:24 +0000282 FRAMEWORKALTINSTALLFIRST=
283 FRAMEWORKALTINSTALLLAST=
Ronald Oussoren2db3a8f2006-06-07 19:06:01 +0000284 if test "x${prefix}" = "xNONE" ; then
285 FRAMEWORKUNIXTOOLSPREFIX="${ac_default_prefix}"
286 else
287 FRAMEWORKUNIXTOOLSPREFIX="${prefix}"
288 fi
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000289 enable_framework=
Ronald Oussoren5640ce22008-06-05 12:58:24 +0000290
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000291])
292AC_SUBST(PYTHONFRAMEWORK)
Ronald Oussoren580c7fe2008-05-02 19:45:11 +0000293AC_SUBST(PYTHONFRAMEWORKIDENTIFIER)
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000294AC_SUBST(PYTHONFRAMEWORKDIR)
295AC_SUBST(PYTHONFRAMEWORKPREFIX)
296AC_SUBST(PYTHONFRAMEWORKINSTALLDIR)
Ronald Oussoren567a8ff2006-05-26 11:43:26 +0000297AC_SUBST(FRAMEWORKINSTALLFIRST)
298AC_SUBST(FRAMEWORKINSTALLLAST)
Ronald Oussoren5b787322006-06-06 19:50:24 +0000299AC_SUBST(FRAMEWORKALTINSTALLFIRST)
300AC_SUBST(FRAMEWORKALTINSTALLLAST)
301AC_SUBST(FRAMEWORKUNIXTOOLSPREFIX)
Ronald Oussoren01d149f2010-04-30 11:20:14 +0000302AC_SUBST(FRAMEWORKINSTALLAPPSPREFIX)
Guido van Rossum4b6b5791996-09-09 20:09:34 +0000303
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000304##AC_ARG_WITH(dyld,
Matthias Klose22520ea2010-05-08 10:14:46 +0000305## AS_HELP_STRING([--with-dyld],
306## [Use (OpenStep|Rhapsody) dynamic linker]))
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000307##
Guido van Rossumb418f891996-07-30 18:06:02 +0000308# Set name for machine-dependent library files
309AC_SUBST(MACHDEP)
310AC_MSG_CHECKING(MACHDEP)
311if test -z "$MACHDEP"
312then
doko@python.orgd65e2ba2013-01-31 23:52:03 +0100313 # avoid using uname for cross builds
314 if test "$cross_compiling" = yes; then
315 # ac_sys_system and ac_sys_release are only used for setting
316 # `define_xopen_source' in the case statement below. For the
317 # current supported cross builds, this macro is not adjusted.
318 case "$host" in
319 *-*-linux*)
320 ac_sys_system=Linux
321 ;;
322 *-*-cygwin*)
323 ac_sys_system=Cygwin
324 ;;
325 *)
326 # for now, limit cross builds to known configurations
327 MACHDEP="unknown"
328 AC_MSG_ERROR([cross build not supported for $host])
329 esac
330 ac_sys_release=
331 else
Guido van Rossum4b6b5791996-09-09 20:09:34 +0000332 ac_sys_system=`uname -s`
Georg Brandlfe18a112009-09-04 07:55:14 +0000333 if test "$ac_sys_system" = "AIX" \
Martin v. Löwis21ee4092002-09-30 16:19:48 +0000334 -o "$ac_sys_system" = "UnixWare" -o "$ac_sys_system" = "OpenUNIX"; then
Guido van Rossum4b6b5791996-09-09 20:09:34 +0000335 ac_sys_release=`uname -v`
Guido van Rossumb418f891996-07-30 18:06:02 +0000336 else
Guido van Rossum4b6b5791996-09-09 20:09:34 +0000337 ac_sys_release=`uname -r`
Guido van Rossumb418f891996-07-30 18:06:02 +0000338 fi
doko@python.orgd65e2ba2013-01-31 23:52:03 +0100339 fi
340 ac_md_system=`echo $ac_sys_system |
341 tr -d '[/ ]' | tr '[[A-Z]]' '[[a-z]]'`
342 ac_md_release=`echo $ac_sys_release |
343 tr -d '[/ ]' | sed 's/^[[A-Z]]\.//' | sed 's/\..*//'`
344 MACHDEP="$ac_md_system$ac_md_release"
Guido van Rossum4b6b5791996-09-09 20:09:34 +0000345
doko@python.orgd65e2ba2013-01-31 23:52:03 +0100346 case $MACHDEP in
Victor Stinneracacbaa2011-08-20 14:02:38 +0200347 linux*) MACHDEP="linux2";;
Andrew M. Kuchling5a3e4cb2001-07-20 19:29:04 +0000348 cygwin*) MACHDEP="cygwin";;
Jack Jansen8a97f4a2001-12-05 23:27:32 +0000349 darwin*) MACHDEP="darwin";;
Martin v. Löwisf90ae202002-06-11 06:22:31 +0000350 atheos*) MACHDEP="atheos";;
Martin v. Löwisf3322282003-07-13 09:46:13 +0000351 irix646) MACHDEP="irix6";;
Guido van Rossumb97ef171997-09-28 05:44:03 +0000352 '') MACHDEP="unknown";;
doko@python.orgd65e2ba2013-01-31 23:52:03 +0100353 esac
354fi
355
356AC_SUBST(_PYTHON_HOST_PLATFORM)
357if test "$cross_compiling" = yes; then
358 case "$host" in
359 *-*-linux*)
360 case "$host_cpu" in
361 arm*)
362 _host_cpu=arm
363 ;;
364 *)
365 _host_cpu=$host_cpu
366 esac
367 ;;
368 *-*-cygwin*)
369 _host_cpu=
370 ;;
371 *)
372 # for now, limit cross builds to known configurations
373 MACHDEP="unknown"
374 AC_MSG_ERROR([cross build not supported for $host])
Guido van Rossumb418f891996-07-30 18:06:02 +0000375 esac
doko@python.orgd65e2ba2013-01-31 23:52:03 +0100376 _PYTHON_HOST_PLATFORM="$MACHDEP${_host_cpu:+-$_host_cpu}"
Guido van Rossumb418f891996-07-30 18:06:02 +0000377fi
Jack Jansen83f898c2002-12-30 22:23:40 +0000378
Martin v. Löwise981a4e2002-11-11 13:26:51 +0000379# Some systems cannot stand _XOPEN_SOURCE being defined at all; they
380# disable features if it is defined, without any means to access these
381# features as extensions. For these systems, we skip the definition of
382# _XOPEN_SOURCE. Before adding a system to the list to gain access to
383# some feature, make sure there is no alternative way to access this
384# feature. Also, when using wildcards, make sure you have verified the
385# need for not defining _XOPEN_SOURCE on all systems matching the
386# wildcard, and that the wildcard does not include future systems
387# (which may remove their limitations).
388dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
389case $ac_sys_system/$ac_sys_release in
390 # On OpenBSD, select(2) is not available if _XOPEN_SOURCE is defined,
391 # even though select is a POSIX function. Reported by J. Ribbens.
Martin v. Löwis76bafc62003-10-03 13:47:44 +0000392 # Reconfirmed for OpenBSD 3.3 by Zachary Hamm, for 3.4 by Jason Ish.
Martin v. Löwis7875ef62010-02-15 21:41:12 +0000393 # In addition, Stefan Krah confirms that issue #1244610 exists through
394 # OpenBSD 4.6, but is fixed in 4.7.
Charles-François Natali97781b02011-07-22 23:43:42 +0200395 OpenBSD/2.* | OpenBSD/3.* | OpenBSD/4.@<:@0123456@:>@)
Martin v. Löwiscb78de62007-12-29 18:49:21 +0000396 define_xopen_source=no
397 # OpenBSD undoes our definition of __BSD_VISIBLE if _XOPEN_SOURCE is
398 # also defined. This can be overridden by defining _BSD_SOURCE
399 # As this has a different meaning on Linux, only define it on OpenBSD
400 AC_DEFINE(_BSD_SOURCE, 1, [Define on OpenBSD to activate all library features])
401 ;;
Charles-François Natali97781b02011-07-22 23:43:42 +0200402 OpenBSD/*)
Martin v. Löwis5e2dd862010-02-15 08:32:00 +0000403 # OpenBSD undoes our definition of __BSD_VISIBLE if _XOPEN_SOURCE is
404 # also defined. This can be overridden by defining _BSD_SOURCE
405 # As this has a different meaning on Linux, only define it on OpenBSD
406 AC_DEFINE(_BSD_SOURCE, 1, [Define on OpenBSD to activate all library features])
407 ;;
Martin v. Löwis4d542ec2006-11-25 15:39:19 +0000408 # Defining _XOPEN_SOURCE on NetBSD version prior to the introduction of
409 # _NETBSD_SOURCE disables certain features (eg. setgroups). Reported by
410 # Marc Recht
Georg Brandl4b9bcfc2008-11-16 08:00:17 +0000411 NetBSD/1.5 | NetBSD/1.5.* | NetBSD/1.6 | NetBSD/1.6.* | NetBSD/1.6@<:@A-S@:>@)
Martin v. Löwis4d542ec2006-11-25 15:39:19 +0000412 define_xopen_source=no;;
Martin v. Löwisb41afb52010-05-28 15:28:47 +0000413 # From the perspective of Solaris, _XOPEN_SOURCE is not so much a
414 # request to enable features supported by the standard as a request
415 # to disable features not supported by the standard. The best way
416 # for Python to use Solaris is simply to leave _XOPEN_SOURCE out
417 # entirely and define __EXTENSIONS__ instead.
418 SunOS/*)
Martin v. Löwisa9d71422003-03-28 18:43:31 +0000419 define_xopen_source=no;;
Martin v. Löwisc2409b42003-05-11 05:53:41 +0000420 # On UnixWare 7, u_long is never defined with _XOPEN_SOURCE,
421 # but used in /usr/include/netinet/tcp.h. Reported by Tim Rice.
Martin v. Löwis253d1f42004-05-07 19:14:14 +0000422 # Reconfirmed for 7.1.4 by Martin v. Loewis.
423 OpenUNIX/8.0.0| UnixWare/7.1.@<:@0-4@:>@)
Martin v. Löwisc2409b42003-05-11 05:53:41 +0000424 define_xopen_source=no;;
425 # On OpenServer 5, u_short is never defined with _XOPEN_SOURCE,
Martin v. Löwis53e73c32003-05-05 05:13:18 +0000426 # but used in struct sockaddr.sa_family. Reported by Tim Rice.
Martin v. Löwisc2409b42003-05-11 05:53:41 +0000427 SCO_SV/3.2)
Martin v. Löwis53e73c32003-05-05 05:13:18 +0000428 define_xopen_source=no;;
Martin v. Löwisbb86d832008-11-04 20:40:09 +0000429 # On FreeBSD 4, the math functions C89 does not cover are never defined
430 # with _XOPEN_SOURCE and __BSD_VISIBLE does not re-enable them.
431 FreeBSD/4.*)
432 define_xopen_source=no;;
433 # On MacOS X 10.2, a bug in ncurses.h means that it craps out if
434 # _XOPEN_EXTENDED_SOURCE is defined. Apparently, this is fixed in 10.3, which
435 # identifies itself as Darwin/7.*
436 # On Mac OS X 10.4, defining _POSIX_C_SOURCE or _XOPEN_SOURCE
437 # disables platform specific features beyond repair.
438 # On Mac OS X 10.3, defining _POSIX_C_SOURCE or _XOPEN_SOURCE
439 # has no effect, don't bother defining them
440 Darwin/@<:@6789@:>@.*)
Anthony Baxter6169c6b2003-10-04 07:46:23 +0000441 define_xopen_source=no;;
Ronald Oussorena55af9a2010-01-17 16:25:57 +0000442 Darwin/1@<:@0-9@:>@.*)
443 define_xopen_source=no;;
Trent Mickaf16e8c2004-08-25 23:55:59 +0000444 # On AIX 4 and 5.1, mbstate_t is defined only when _XOPEN_SOURCE == 500 but
445 # used in wcsnrtombs() and mbsnrtowcs() even if _XOPEN_SOURCE is not defined
446 # or has another value. By not (re)defining it, the defaults come in place.
Martin v. Löwisc19c5a62003-11-18 20:00:44 +0000447 AIX/4)
448 define_xopen_source=no;;
Trent Mickaf16e8c2004-08-25 23:55:59 +0000449 AIX/5)
450 if test `uname -r` -eq 1; then
451 define_xopen_source=no
452 fi
453 ;;
Martin v. Löwis8c255e42008-05-23 15:06:50 +0000454 # On QNX 6.3.2, defining _XOPEN_SOURCE prevents netdb.h from
455 # defining NI_NUMERICHOST.
456 QNX/6.3.2)
457 define_xopen_source=no
458 ;;
Martin v. Löwisa0588362006-04-04 06:03:50 +0000459
Martin v. Löwise981a4e2002-11-11 13:26:51 +0000460esac
461
462if test $define_xopen_source = yes
463then
Martin v. Löwisb41afb52010-05-28 15:28:47 +0000464 AC_DEFINE(_XOPEN_SOURCE, 600,
465 Define to the level of X/Open that your system supports)
Martin v. Löwis678fc1e2002-11-12 06:04:39 +0000466
467 # On Tru64 Unix 4.0F, defining _XOPEN_SOURCE also requires
468 # definition of _XOPEN_SOURCE_EXTENDED and _POSIX_C_SOURCE, or else
469 # several APIs are not declared. Since this is also needed in some
470 # cases for HP-UX, we define it globally.
Martin v. Löwisb41afb52010-05-28 15:28:47 +0000471 AC_DEFINE(_XOPEN_SOURCE_EXTENDED, 1,
472 Define to activate Unix95-and-earlier features)
Martin v. Löwis678fc1e2002-11-12 06:04:39 +0000473
Bob Ippolito7026a0a2005-03-28 23:23:47 +0000474 AC_DEFINE(_POSIX_C_SOURCE, 200112L, Define to activate features from IEEE Stds 1003.1-2001)
475
Martin v. Löwise981a4e2002-11-11 13:26:51 +0000476fi
477
Guido van Rossum91922671997-10-09 20:24:13 +0000478#
479# SGI compilers allow the specification of the both the ABI and the
480# ISA on the command line. Depending on the values of these switches,
481# different and often incompatable code will be generated.
482#
483# The SGI_ABI variable can be used to modify the CC and LDFLAGS and
484# thus supply support for various ABI/ISA combinations. The MACHDEP
485# variable is also adjusted.
486#
487AC_SUBST(SGI_ABI)
488if test ! -z "$SGI_ABI"
489then
490 CC="cc $SGI_ABI"
491 LDFLAGS="$SGI_ABI $LDFLAGS"
492 MACHDEP=`echo "${MACHDEP}${SGI_ABI}" | sed 's/ *//g'`
493fi
Guido van Rossumb418f891996-07-30 18:06:02 +0000494AC_MSG_RESULT($MACHDEP)
495
Jack Jansen83f898c2002-12-30 22:23:40 +0000496# And add extra plat-mac for darwin
497AC_SUBST(EXTRAPLATDIR)
Jack Jansen7b59b422003-03-17 15:44:10 +0000498AC_SUBST(EXTRAMACHDEPPATH)
Jack Jansen83f898c2002-12-30 22:23:40 +0000499AC_MSG_CHECKING(EXTRAPLATDIR)
500if test -z "$EXTRAPLATDIR"
501then
502 case $MACHDEP in
Jack Jansen7b59b422003-03-17 15:44:10 +0000503 darwin)
504 EXTRAPLATDIR="\$(PLATMACDIRS)"
505 EXTRAMACHDEPPATH="\$(PLATMACPATH)"
506 ;;
507 *)
508 EXTRAPLATDIR=""
509 EXTRAMACHDEPPATH=""
510 ;;
Jack Jansen83f898c2002-12-30 22:23:40 +0000511 esac
512fi
513AC_MSG_RESULT($EXTRAPLATDIR)
514
Jack Jansen6b08a402004-06-03 12:41:45 +0000515# Record the configure-time value of MACOSX_DEPLOYMENT_TARGET,
516# it may influence the way we can build extensions, so distutils
517# needs to check it
518AC_SUBST(CONFIGURE_MACOSX_DEPLOYMENT_TARGET)
Ronald Oussoren988117f2006-04-29 11:31:35 +0000519AC_SUBST(EXPORT_MACOSX_DEPLOYMENT_TARGET)
Jack Jansen6b08a402004-06-03 12:41:45 +0000520CONFIGURE_MACOSX_DEPLOYMENT_TARGET=
Ronald Oussoren988117f2006-04-29 11:31:35 +0000521EXPORT_MACOSX_DEPLOYMENT_TARGET='#'
Jack Jansen6b08a402004-06-03 12:41:45 +0000522
Guido van Rossum627b2d71993-12-24 10:39:16 +0000523# checks for alternative programs
Skip Montanarodecc6a42003-01-01 20:07:49 +0000524
525# compiler flags are generated in two sets, BASECFLAGS and OPT. OPT is just
526# for debug/optimization stuff. BASECFLAGS is for flags that are required
527# just to get things to compile and link. Users are free to override OPT
528# when running configure or make. The build should not break if they do.
529# BASECFLAGS should generally not be messed with, however.
530
531# XXX shouldn't some/most/all of this code be merged with the stuff later
532# on that fiddles with OPT and BASECFLAGS?
Guido van Rossum5739e7e1995-01-20 16:50:53 +0000533AC_MSG_CHECKING(for --without-gcc)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000534AC_ARG_WITH(gcc,
Matthias Klose22520ea2010-05-08 10:14:46 +0000535 AS_HELP_STRING([--without-gcc], [never use gcc]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000536[
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000537 case $withval in
Skip Montanaro516144f2009-01-04 10:36:58 +0000538 no) CC=${CC:-cc}
Guido van Rossum5739e7e1995-01-20 16:50:53 +0000539 without_gcc=yes;;
540 yes) CC=gcc
541 without_gcc=no;;
542 *) CC=$withval
543 without_gcc=$withval;;
Guido van Rossum55a214e1995-09-13 17:48:09 +0000544 esac], [
Guido van Rossumb418f891996-07-30 18:06:02 +0000545 case $ac_sys_system in
Antoine Pitrou285cd162010-09-21 15:23:17 +0000546 AIX*) CC=${CC:-xlc_r}
Neil Schemenauerb3531b82001-02-16 04:09:05 +0000547 without_gcc=;;
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000548 BeOS*)
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000549 case $BE_HOST_CPU in
550 ppc)
Fred Drake5790be12000-10-09 17:06:13 +0000551 CC=mwcc
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000552 without_gcc=yes
Skip Montanarodecc6a42003-01-01 20:07:49 +0000553 BASECFLAGS="$BASECFLAGS -export pragma"
554 OPT="$OPT -O"
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000555 LDFLAGS="$LDFLAGS -nodup"
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000556 ;;
557 x86)
Fred Drake5790be12000-10-09 17:06:13 +0000558 CC=gcc
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000559 without_gcc=no
Skip Montanarodecc6a42003-01-01 20:07:49 +0000560 OPT="$OPT -O"
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000561 ;;
562 *)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000563 AC_MSG_ERROR([Unknown BeOS platform "$BE_HOST_CPU"])
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000564 ;;
565 esac
Neil Schemenauerb3531b82001-02-16 04:09:05 +0000566 AR="\$(srcdir)/Modules/ar_beos"
567 RANLIB=:
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000568 ;;
Martin v. Löwis130fb172001-07-19 11:00:41 +0000569 *) without_gcc=no;;
Guido van Rossum55a214e1995-09-13 17:48:09 +0000570 esac])
Guido van Rossum5739e7e1995-01-20 16:50:53 +0000571AC_MSG_RESULT($without_gcc)
572
Guido van Rossum03ad99f1995-03-09 14:09:54 +0000573# If the user switches compilers, we can't believe the cache
574if test ! -z "$ac_cv_prog_CC" -a ! -z "$CC" -a "$CC" != "$ac_cv_prog_CC"
575then
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000576 AC_MSG_ERROR([cached CC is different -- throw away $cache_file
577(it is also a good idea to do 'make clean' before compiling)])
Guido van Rossum03ad99f1995-03-09 14:09:54 +0000578fi
579
Trent Nelson15daa352012-12-13 06:46:39 +0000580if test "$MACHDEP" = "irix6" && test "$CC" != "gcc"; then
581 # Normally, MIPSpro CC treats #error directives as warnings, which means
582 # a successful exit code is returned (0). This is a problem because IRIX
583 # has a bunch of system headers with this guard at the top:
584 #
585 # #ifndef __c99
586 # #error This header file is to be used only for c99 mode compilations
587 # #else
588 #
589 # When autoconf tests for such a header, like stdint.h, this happens:
590 #
591 # configure:4619: cc -c conftest.c >&5
592 # cc-1035 cc: WARNING File = /usr/include/stdint.h, Line = 5
593 # #error directive: This header file is to be used only for c99 mode
594 # compilations
595 #
596 # #error This header file is to be used only for c99 mode compilations
597 # ^
598 #
599 # configure:4619: $? = 0
600 # configure:4619: result: yes
601 #
602 # Therefore, we use `-diag_error 1035` to have the compiler treat the
603 # warning as an error, which causes cc to return a non-zero result,
604 # which autoconf can interpret correctly.
605 CFLAGS="$CFLAGS -diag_error 1035"
606 # Whilst we're here, we might as well make sure CXX defaults to something
607 # sensible if we're not using gcc.
608 if test -z "$CXX"; then
609 CXX="CC"
610 fi
611fi
612
Marc-André Lemburg6d5e5792010-04-30 17:20:14 +0000613# If the user set CFLAGS, use this instead of the automatically
614# determined setting
615preset_cflags="$CFLAGS"
Guido van Rossum627b2d71993-12-24 10:39:16 +0000616AC_PROG_CC
Marc-André Lemburg6d5e5792010-04-30 17:20:14 +0000617if test ! -z "$preset_cflags"
618then
619 CFLAGS=$preset_cflags
620fi
Martin v. Löwis1d5ecb72001-08-09 10:29:44 +0000621
Martin v. Löwis0f48d982006-04-14 14:34:26 +0000622AC_SUBST(CXX)
623AC_SUBST(MAINCC)
624AC_MSG_CHECKING(for --with-cxx-main=<compiler>)
625AC_ARG_WITH(cxx_main,
Matthias Klose22520ea2010-05-08 10:14:46 +0000626 AS_HELP_STRING([--with-cxx-main=<compiler>],
Martin v. Löwis0f48d982006-04-14 14:34:26 +0000627 [compile main() and link python executable with C++ compiler]),
628[
629
630 case $withval in
631 no) with_cxx_main=no
632 MAINCC='$(CC)';;
633 yes) with_cxx_main=yes
634 MAINCC='$(CXX)';;
635 *) with_cxx_main=yes
636 MAINCC=$withval
637 if test -z "$CXX"
638 then
639 CXX=$withval
640 fi;;
641 esac], [
642 with_cxx_main=no
643 MAINCC='$(CC)'
644])
645AC_MSG_RESULT($with_cxx_main)
646
647preset_cxx="$CXX"
648if test -z "$CXX"
649then
650 case "$CC" in
doko@python.orgd65e2ba2013-01-31 23:52:03 +0100651 gcc) AC_PATH_TOOL(CXX, [g++], [g++], [notfound]) ;;
652 cc) AC_PATH_TOOL(CXX, [c++], [c++], [notfound]) ;;
Martin v. Löwis0f48d982006-04-14 14:34:26 +0000653 esac
654 if test "$CXX" = "notfound"
655 then
656 CXX=""
657 fi
658fi
659if test -z "$CXX"
660then
doko@python.orgd65e2ba2013-01-31 23:52:03 +0100661 AC_CHECK_TOOLS(CXX, $CCC c++ g++ gcc CC cxx cc++ cl, notfound)
Martin v. Löwis0f48d982006-04-14 14:34:26 +0000662 if test "$CXX" = "notfound"
663 then
664 CXX=""
665 fi
666fi
667if test "$preset_cxx" != "$CXX"
668then
669 AC_MSG_WARN([
670
671 By default, distutils will build C++ extension modules with "$CXX".
672 If this is not intended, then set CXX on the configure command line.
673 ])
674fi
675
doko@python.org4e63fbe2013-01-25 13:08:27 +0100676MULTIARCH=$($CC --print-multiarch 2>/dev/null)
677AC_SUBST(MULTIARCH)
678
Martin v. Löwis0f48d982006-04-14 14:34:26 +0000679
Martin v. Löwis1d5ecb72001-08-09 10:29:44 +0000680# checks for UNIX variants that set C preprocessor variables
Matthias Klose9f8e0c12010-05-08 10:17:27 +0000681AC_USE_SYSTEM_EXTENSIONS
Martin v. Löwis1d5ecb72001-08-09 10:29:44 +0000682
Martin v. Löwis779ffc02002-12-02 22:17:01 +0000683# Check for unsupported systems
684case $ac_sys_system/$ac_sys_release in
Brett Cannon19fab762007-06-02 03:02:29 +0000685atheos*|Linux*/1*)
Martin v. Löwis779ffc02002-12-02 22:17:01 +0000686 echo This system \($ac_sys_system/$ac_sys_release\) is no longer supported.
687 echo See README for details.
688 exit 1;;
689esac
690
Neil Schemenauer55f0cf32001-01-24 17:24:33 +0000691AC_EXEEXT
Neil Schemenauer3ae1d0a2001-01-27 06:54:42 +0000692AC_MSG_CHECKING(for --with-suffix)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000693AC_ARG_WITH(suffix,
Matthias Klose22520ea2010-05-08 10:14:46 +0000694 AS_HELP_STRING([--with-suffix=.exe], [set executable suffix]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000695[
Neil Schemenauer3ae1d0a2001-01-27 06:54:42 +0000696 case $withval in
697 no) EXEEXT=;;
698 yes) EXEEXT=.exe;;
699 *) EXEEXT=$withval;;
700 esac])
701AC_MSG_RESULT($EXEEXT)
Jack Jansen1999ef42001-12-06 21:47:20 +0000702
Jack Jansen9a66b6d2001-08-08 13:56:14 +0000703# Test whether we're running on a non-case-sensitive system, in which
704# case we give a warning if no ext is given
Jack Jansen1999ef42001-12-06 21:47:20 +0000705AC_SUBST(BUILDEXEEXT)
706AC_MSG_CHECKING(for case-insensitive build directory)
Jack Jansen3c2c4332002-11-06 13:33:32 +0000707if test ! -d CaseSensitiveTestDir; then
708mkdir CaseSensitiveTestDir
709fi
710
711if test -d casesensitivetestdir
Jack Jansen9a66b6d2001-08-08 13:56:14 +0000712then
Jack Jansen1999ef42001-12-06 21:47:20 +0000713 AC_MSG_RESULT(yes)
714 BUILDEXEEXT=.exe
715else
716 AC_MSG_RESULT(no)
Jack Jansendd19cf82001-12-06 22:36:17 +0000717 BUILDEXEEXT=$EXEEXT
Jack Jansen9a66b6d2001-08-08 13:56:14 +0000718fi
Jack Jansen3c2c4332002-11-06 13:33:32 +0000719rmdir CaseSensitiveTestDir
Guido van Rossumfb842551997-08-06 23:42:07 +0000720
Guido van Rossumdd997f71998-10-07 19:58:26 +0000721case $MACHDEP in
722bsdos*)
723 case $CC in
724 gcc) CC="$CC -D_HAVE_BSDI";;
725 esac;;
726esac
727
Guido van Rossum84561611997-08-21 00:08:11 +0000728case $ac_sys_system in
729hp*|HP*)
730 case $CC in
Guido van Rossumcd5ff9f2000-09-22 16:15:54 +0000731 cc|*/cc) CC="$CC -Ae";;
Guido van Rossum84561611997-08-21 00:08:11 +0000732 esac;;
Martin v. Löwise8964d42001-03-06 12:09:07 +0000733SunOS*)
734 # Some functions have a prototype only with that define, e.g. confstr
Martin v. Löwisc45929e2002-04-06 10:10:49 +0000735 AC_DEFINE(__EXTENSIONS__, 1, [Defined on Solaris to see additional function prototypes.])
Martin v. Löwise8964d42001-03-06 12:09:07 +0000736 ;;
Guido van Rossum84561611997-08-21 00:08:11 +0000737esac
738
Martin v. Löwise8964d42001-03-06 12:09:07 +0000739
Neil Schemenauer61c51152001-01-26 16:18:16 +0000740AC_SUBST(LIBRARY)
741AC_MSG_CHECKING(LIBRARY)
742if test -z "$LIBRARY"
743then
744 LIBRARY='libpython$(VERSION).a'
745fi
746AC_MSG_RESULT($LIBRARY)
747
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000748# LDLIBRARY is the name of the library to link against (as opposed to the
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000749# name of the library into which to insert object files). BLDLIBRARY is also
750# the library to link against, usually. On Mac OS X frameworks, BLDLIBRARY
751# is blank as the main program is not linked directly against LDLIBRARY.
752# LDLIBRARYDIR is the path to LDLIBRARY, which is made in a subdirectory. On
753# systems without shared libraries, LDLIBRARY is the same as LIBRARY
754# (defined in the Makefiles). On Cygwin LDLIBRARY is the import library,
755# DLLLIBRARY is the shared (i.e., DLL) library.
756#
Martin v. Löwis1142de32002-03-29 16:28:31 +0000757# RUNSHARED is used to run shared python without installed libraries
758#
759# INSTSONAME is the name of the shared library that will be use to install
760# on the system - some systems like version suffix, others don't
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000761AC_SUBST(LDLIBRARY)
Guido van Rossum27552902001-01-23 01:52:26 +0000762AC_SUBST(DLLLIBRARY)
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000763AC_SUBST(BLDLIBRARY)
764AC_SUBST(LDLIBRARYDIR)
Martin v. Löwis1142de32002-03-29 16:28:31 +0000765AC_SUBST(INSTSONAME)
766AC_SUBST(RUNSHARED)
Neil Schemenauer61c51152001-01-26 16:18:16 +0000767LDLIBRARY="$LIBRARY"
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000768BLDLIBRARY='$(LDLIBRARY)'
Martin v. Löwis09bdf722002-05-08 08:51:29 +0000769INSTSONAME='$(LDLIBRARY)'
Guido van Rossum27552902001-01-23 01:52:26 +0000770DLLLIBRARY=''
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000771LDLIBRARYDIR=''
Martin v. Löwis1142de32002-03-29 16:28:31 +0000772RUNSHARED=''
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000773
Guido van Rossumfb842551997-08-06 23:42:07 +0000774# LINKCC is the command that links the python executable -- default is $(CC).
Martin v. Löwisb7da67a2001-10-18 15:35:38 +0000775# If CXX is set, and if it is needed to link a main function that was
776# compiled with CXX, LINKCC is CXX instead. Always using CXX is undesirable:
777# python might then depend on the C++ runtime
Fred Drake5790be12000-10-09 17:06:13 +0000778# This is altered for AIX in order to build the export list before
Guido van Rossumec95c7b1998-08-04 17:59:56 +0000779# linking.
Guido van Rossumfb842551997-08-06 23:42:07 +0000780AC_SUBST(LINKCC)
781AC_MSG_CHECKING(LINKCC)
782if test -z "$LINKCC"
783then
Martin v. Löwis0f48d982006-04-14 14:34:26 +0000784 LINKCC='$(PURIFY) $(MAINCC)'
Guido van Rossumfb842551997-08-06 23:42:07 +0000785 case $ac_sys_system in
786 AIX*)
Neal Norwitz0b27ff92003-03-31 15:53:49 +0000787 exp_extra="\"\""
788 if test $ac_sys_release -ge 5 -o \
789 $ac_sys_release -eq 4 -a `uname -r` -ge 2 ; then
790 exp_extra="."
791 fi
792 LINKCC="\$(srcdir)/Modules/makexp_aix Modules/python.exp $exp_extra \$(LIBRARY); $LINKCC";;
Martin v. Löwis8c255e42008-05-23 15:06:50 +0000793 QNX*)
794 # qcc must be used because the other compilers do not
795 # support -N.
796 LINKCC=qcc;;
Guido van Rossumfb842551997-08-06 23:42:07 +0000797 esac
798fi
799AC_MSG_RESULT($LINKCC)
800
Tarek Ziadée2be83d2009-05-09 08:28:53 +0000801# GNULD is set to "yes" if the GNU linker is used. If this goes wrong
802# make sure we default having it set to "no": this is used by
803# distutils.unixccompiler to know if it should add --enable-new-dtags
804# to linker command lines, and failing to detect GNU ld simply results
805# in the same bahaviour as before.
806AC_SUBST(GNULD)
807AC_MSG_CHECKING(for GNU ld)
808ac_prog=ld
809if test "$GCC" = yes; then
810 ac_prog=`$CC -print-prog-name=ld`
811fi
812case `"$ac_prog" -V 2>&1 < /dev/null` in
813 *GNU*)
814 GNULD=yes;;
815 *)
816 GNULD=no;;
817esac
818AC_MSG_RESULT($GNULD)
819
Martin v. Löwis1142de32002-03-29 16:28:31 +0000820AC_MSG_CHECKING(for --enable-shared)
821AC_ARG_ENABLE(shared,
Matthias Klose22520ea2010-05-08 10:14:46 +0000822 AS_HELP_STRING([--enable-shared], [disable/enable building shared python library]))
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000823
Martin v. Löwis1142de32002-03-29 16:28:31 +0000824if test -z "$enable_shared"
825then
Martin v. Löwisb51033d2002-05-03 05:53:15 +0000826 case $ac_sys_system in
Martin v. Löwisf90ae202002-06-11 06:22:31 +0000827 CYGWIN* | atheos*)
Martin v. Löwisb51033d2002-05-03 05:53:15 +0000828 enable_shared="yes";;
829 *)
830 enable_shared="no";;
831 esac
Martin v. Löwis1142de32002-03-29 16:28:31 +0000832fi
833AC_MSG_RESULT($enable_shared)
834
Skip Montanaro56f6a4f2004-06-18 02:47:22 +0000835AC_MSG_CHECKING(for --enable-profiling)
836AC_ARG_ENABLE(profiling,
doko@python.orgd65e2ba2013-01-31 23:52:03 +0100837 AS_HELP_STRING([--enable-profiling], [enable C-level code profiling]))
838if test "x$enable_profiling" = xyes; then
839 ac_save_cc="$CC"
Benjamin Petersonb9be7bb2013-03-26 08:55:37 -0400840 CC="$CC -pg"
doko@python.orgd65e2ba2013-01-31 23:52:03 +0100841 AC_LINK_IFELSE([AC_LANG_SOURCE([[int main() { return 0; }]])],
842 [],
843 [enable_profiling=no])
844 CC="$ac_save_cc"
845else
846 enable_profiling=no
847fi
848AC_MSG_RESULT($enable_profiling)
Skip Montanaro56f6a4f2004-06-18 02:47:22 +0000849
doko@python.orgd65e2ba2013-01-31 23:52:03 +0100850if test "x$enable_profiling" = xyes; then
851 BASECFLAGS="-pg $BASECFLAGS"
852 LDFLAGS="-pg $LDFLAGS"
853fi
Martin v. Löwis1142de32002-03-29 16:28:31 +0000854
855AC_MSG_CHECKING(LDLIBRARY)
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000856
Guido van Rossumb8552162001-09-05 14:58:11 +0000857# MacOSX framework builds need more magic. LDLIBRARY is the dynamic
858# library that we build, but we do not want to link against it (we
859# will find it with a -framework option). For this reason there is an
860# extra variable BLDLIBRARY against which Python and the extension
861# modules are linked, BLDLIBRARY. This is normally the same as
862# LDLIBRARY, but empty for MacOSX framework builds.
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000863if test "$enable_framework"
864then
865 LDLIBRARY='$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
doko@ubuntu.com9ba90c92014-05-07 04:41:26 +0200866 RUNSHARED=DYLD_FRAMEWORK_PATH=`pwd`${DYLD_FRAMEWORK_PATH:+:${DYLD_FRAMEWORK_PATH}}
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000867 BLDLIBRARY=''
868else
869 BLDLIBRARY='$(LDLIBRARY)'
870fi
871
Martin v. Löwis1142de32002-03-29 16:28:31 +0000872# Other platforms follow
873if test $enable_shared = "yes"; then
Mark Hammond8235ea12002-07-19 06:55:41 +0000874 AC_DEFINE(Py_ENABLE_SHARED, 1, [Defined if Python is built as a shared library.])
Martin v. Löwis1142de32002-03-29 16:28:31 +0000875 case $ac_sys_system in
876 BeOS*)
877 LDLIBRARY='libpython$(VERSION).so'
878 ;;
879 CYGWIN*)
880 LDLIBRARY='libpython$(VERSION).dll.a'
881 DLLLIBRARY='libpython$(VERSION).dll'
882 ;;
883 SunOS*)
884 LDLIBRARY='libpython$(VERSION).so'
Martin v. Löwisd141a8c2003-06-14 15:20:28 +0000885 BLDLIBRARY='-Wl,-R,$(LIBDIR) -L. -lpython$(VERSION)'
doko@ubuntu.com9ba90c92014-05-07 04:41:26 +0200886 RUNSHARED=LD_LIBRARY_PATH=`pwd`${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
Martin v. Löwis2389c412003-10-31 15:42:07 +0000887 INSTSONAME="$LDLIBRARY".$SOVERSION
Martin v. Löwis1142de32002-03-29 16:28:31 +0000888 ;;
Charles-François Natali3de8c732011-07-24 22:33:35 +0200889 Linux*|GNU*|NetBSD*|FreeBSD*|DragonFly*|OpenBSD*)
Martin v. Löwis1142de32002-03-29 16:28:31 +0000890 LDLIBRARY='libpython$(VERSION).so'
891 BLDLIBRARY='-L. -lpython$(VERSION)'
doko@ubuntu.com9ba90c92014-05-07 04:41:26 +0200892 RUNSHARED=LD_LIBRARY_PATH=`pwd`${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
Hye-Shik Chang33761492004-10-26 09:53:46 +0000893 case $ac_sys_system in
894 FreeBSD*)
895 SOVERSION=`echo $SOVERSION|cut -d "." -f 1`
896 ;;
897 esac
Martin v. Löwis1142de32002-03-29 16:28:31 +0000898 INSTSONAME="$LDLIBRARY".$SOVERSION
899 ;;
900 hp*|HP*)
Neal Norwitz58e28882006-05-19 07:00:58 +0000901 case `uname -m` in
902 ia64)
903 LDLIBRARY='libpython$(VERSION).so'
904 ;;
905 *)
906 LDLIBRARY='libpython$(VERSION).sl'
907 ;;
908 esac
Martin v. Löwis1142de32002-03-29 16:28:31 +0000909 BLDLIBRARY='-Wl,+b,$(LIBDIR) -L. -lpython$(VERSION)'
doko@ubuntu.com9ba90c92014-05-07 04:41:26 +0200910 RUNSHARED=SHLIB_PATH=`pwd`${SHLIB_PATH:+:${SHLIB_PATH}}
Martin v. Löwis1142de32002-03-29 16:28:31 +0000911 ;;
912 OSF*)
913 LDLIBRARY='libpython$(VERSION).so'
Neal Norwitz671b9e32006-01-09 07:07:12 +0000914 BLDLIBRARY='-rpath $(LIBDIR) -L. -lpython$(VERSION)'
doko@ubuntu.com9ba90c92014-05-07 04:41:26 +0200915 RUNSHARED=LD_LIBRARY_PATH=`pwd`${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
Martin v. Löwis1142de32002-03-29 16:28:31 +0000916 ;;
Martin v. Löwisf90ae202002-06-11 06:22:31 +0000917 atheos*)
918 LDLIBRARY='libpython$(VERSION).so'
919 BLDLIBRARY='-L. -lpython$(VERSION)'
920 RUNSHARED=DLL_PATH=`pwd`:${DLL_PATH:-/atheos/sys/libs:/atheos/autolnk/lib}
921 ;;
Ronald Oussoren79f90492009-01-02 10:44:46 +0000922 Darwin*)
923 LDLIBRARY='libpython$(VERSION).dylib'
924 BLDLIBRARY='-L. -lpython$(VERSION)'
doko@ubuntu.com9ba90c92014-05-07 04:41:26 +0200925 RUNSHARED=DYLD_LIBRARY_PATH=`pwd`${DYLD_LIBRARY_PATH:+:${DYLD_LIBRARY_PATH}}
Ronald Oussoren79f90492009-01-02 10:44:46 +0000926 ;;
Antoine Pitrouaabdceb2010-09-10 20:03:17 +0000927 AIX*)
928 LDLIBRARY='libpython$(VERSION).so'
doko@ubuntu.com9ba90c92014-05-07 04:41:26 +0200929 RUNSHARED=LIBPATH=`pwd`${LIBPATH:+:${LIBPATH}}
Antoine Pitrouaabdceb2010-09-10 20:03:17 +0000930 ;;
Ronald Oussoren79f90492009-01-02 10:44:46 +0000931
Martin v. Löwis1142de32002-03-29 16:28:31 +0000932 esac
Jason Tishler30765592003-09-04 11:04:06 +0000933else # shared is disabled
934 case $ac_sys_system in
935 CYGWIN*)
936 BLDLIBRARY='$(LIBRARY)'
937 LDLIBRARY='libpython$(VERSION).dll.a'
938 ;;
939 esac
Martin v. Löwis1142de32002-03-29 16:28:31 +0000940fi
941
doko@python.orgd65e2ba2013-01-31 23:52:03 +0100942if test "$cross_compiling" = yes; then
943 RUNSHARED=
944fi
945
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000946AC_MSG_RESULT($LDLIBRARY)
947
Guido van Rossum627b2d71993-12-24 10:39:16 +0000948AC_PROG_RANLIB
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000949AC_SUBST(AR)
doko@python.orgd65e2ba2013-01-31 23:52:03 +0100950AC_CHECK_TOOLS(AR, ar aal, ar)
Neil Schemenauera42c8272001-03-31 00:01:55 +0000951
Tarek Ziadé99f660a2009-05-07 21:20:34 +0000952# tweak ARFLAGS only if the user didn't set it on the command line
953AC_SUBST(ARFLAGS)
954if test -z "$ARFLAGS"
955then
956 ARFLAGS="rc"
957fi
958
Martin v. Löwisdea59e52006-01-05 10:00:36 +0000959AC_SUBST(SVNVERSION)
Martin v. Löwisff600232006-04-03 19:12:32 +0000960AC_CHECK_PROG(SVNVERSION, svnversion, found, not-found)
Martin v. Löwisc5bf5a02006-01-05 10:33:59 +0000961if test $SVNVERSION = found
962then
963 SVNVERSION="svnversion \$(srcdir)"
964else
Benjamin Petersone5afa3b2009-05-23 19:24:37 +0000965 SVNVERSION="echo Unversioned directory"
Martin v. Löwisc5bf5a02006-01-05 10:33:59 +0000966fi
Martin v. Löwisdea59e52006-01-05 10:00:36 +0000967
Trent Nelsond86ceec2012-10-16 09:42:45 -0400968AC_SUBST(BASECPPFLAGS)
Trent Nelsonabf20512012-10-17 04:32:49 -0400969if test "$abs_srcdir" != "$abs_builddir"; then
Trent Nelsond86ceec2012-10-16 09:42:45 -0400970 # If we're building out-of-tree make sure Include (in the current dir)
971 # gets picked up before its $srcdir counterpart in order for Python-ast.h
972 # and graminit.h to get picked up from the correct directory.
973 # (A side effect of this is that these resources will automatically be
974 # regenerated when building out-of-tree, regardless of whether or not
975 # the $srcdir counterpart is up-to-date. This is an acceptable trade
976 # off.)
977 BASECPPFLAGS="-IInclude"
978else
979 BASECPPFLAGS=""
980fi
981
Georg Brandl3a5508e2011-03-06 10:42:21 +0100982AC_SUBST(HGVERSION)
983AC_SUBST(HGTAG)
984AC_SUBST(HGBRANCH)
985AC_CHECK_PROG(HAS_HG, hg, found, not-found)
986if test $HAS_HG = found
987then
988 HGVERSION="hg id -i \$(srcdir)"
989 HGTAG="hg id -t \$(srcdir)"
990 HGBRANCH="hg id -b \$(srcdir)"
991else
992 HGVERSION=""
993 HGTAG=""
994 HGBRANCH=""
995fi
996
Neil Schemenauera42c8272001-03-31 00:01:55 +0000997case $MACHDEP in
Neil Schemenaueraf5567f2001-10-21 22:32:04 +0000998bsdos*|hp*|HP*)
999 # install -d does not work on BSDI or HP-UX
Neil Schemenauera42c8272001-03-31 00:01:55 +00001000 if test -z "$INSTALL"
1001 then
1002 INSTALL="${srcdir}/install-sh -c"
1003 fi
1004esac
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00001005AC_PROG_INSTALL
Trent Nelsonf6407a12012-08-30 14:56:13 +00001006AC_PROG_MKDIR_P
Guido van Rossumb418f891996-07-30 18:06:02 +00001007
Guido van Rossumec95c7b1998-08-04 17:59:56 +00001008# Not every filesystem supports hard links
1009AC_SUBST(LN)
1010if test -z "$LN" ; then
1011 case $ac_sys_system in
1012 BeOS*) LN="ln -s";;
Guido van Rossumaef734b2001-01-10 21:09:12 +00001013 CYGWIN*) LN="ln -s";;
Martin v. Löwisf90ae202002-06-11 06:22:31 +00001014 atheos*) LN="ln -s";;
Guido van Rossumec95c7b1998-08-04 17:59:56 +00001015 *) LN=ln;;
1016 esac
1017fi
1018
Fred Drake9f715822001-07-11 06:27:00 +00001019# Check for --with-pydebug
1020AC_MSG_CHECKING(for --with-pydebug)
1021AC_ARG_WITH(pydebug,
Matthias Klose22520ea2010-05-08 10:14:46 +00001022 AS_HELP_STRING([--with-pydebug], [build with Py_DEBUG defined]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00001023[
Fred Drake9f715822001-07-11 06:27:00 +00001024if test "$withval" != no
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001025then
1026 AC_DEFINE(Py_DEBUG, 1,
1027 [Define if you want to build an interpreter with many run-time checks.])
1028 AC_MSG_RESULT(yes);
1029 Py_DEBUG='true'
Fred Drake9f715822001-07-11 06:27:00 +00001030else AC_MSG_RESULT(no); Py_DEBUG='false'
1031fi],
1032[AC_MSG_RESULT(no)])
1033
Skip Montanarodecc6a42003-01-01 20:07:49 +00001034# XXX Shouldn't the code above that fiddles with BASECFLAGS and OPT be
1035# merged with this chunk of code?
1036
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00001037# Optimizer/debugger flags
Skip Montanarodecc6a42003-01-01 20:07:49 +00001038# ------------------------
1039# (The following bit of code is complicated enough - please keep things
1040# indented properly. Just pretend you're editing Python code. ;-)
1041
1042# There are two parallel sets of case statements below, one that checks to
1043# see if OPT was set and one that does BASECFLAGS setting based upon
1044# compiler and platform. BASECFLAGS tweaks need to be made even if the
1045# user set OPT.
1046
1047# tweak OPT based on compiler and platform, only if the user didn't set
1048# it on the command line
Guido van Rossumb418f891996-07-30 18:06:02 +00001049AC_SUBST(OPT)
Benjamin Petersond4b721b2010-03-23 20:58:37 +00001050if test "${OPT-unset}" = "unset"
Guido van Rossumb418f891996-07-30 18:06:02 +00001051then
Skip Montanarodecc6a42003-01-01 20:07:49 +00001052 case $GCC in
1053 yes)
Skip Montanaro288a5be2006-04-13 02:00:56 +00001054 if test "$CC" != 'g++' ; then
1055 STRICT_PROTO="-Wstrict-prototypes"
1056 fi
Guido van Rossum7c862f82007-12-13 20:50:10 +00001057 # For gcc 4.x we need to use -fwrapv so lets check if its supported
1058 if "$CC" -v --help 2>/dev/null |grep -- -fwrapv > /dev/null; then
1059 WRAP="-fwrapv"
1060 fi
Stefan Krah503e5e12011-09-14 15:19:42 +02001061
1062 # Clang also needs -fwrapv
Stefan Krah2bc1e8f2011-12-08 22:26:06 +01001063 case $CC in
1064 *clang*) WRAP="-fwrapv"
1065 ;;
1066 esac
Stefan Krah503e5e12011-09-14 15:19:42 +02001067
Skip Montanarodecc6a42003-01-01 20:07:49 +00001068 case $ac_cv_prog_cc_g in
Guido van Rossum2242f2f2001-04-11 20:58:20 +00001069 yes)
Fred Drake9f715822001-07-11 06:27:00 +00001070 if test "$Py_DEBUG" = 'true' ; then
1071 # Optimization messes up debuggers, so turn it off for
1072 # debug builds.
Mark Dickinsond2f3e3f2010-05-05 22:23:58 +00001073 OPT="-g -O0 -Wall $STRICT_PROTO"
Fred Drake9f715822001-07-11 06:27:00 +00001074 else
Guido van Rossum7c862f82007-12-13 20:50:10 +00001075 OPT="-g $WRAP -O3 -Wall $STRICT_PROTO"
Skip Montanarodecc6a42003-01-01 20:07:49 +00001076 fi
1077 ;;
Guido van Rossum2242f2f2001-04-11 20:58:20 +00001078 *)
Skip Montanaro288a5be2006-04-13 02:00:56 +00001079 OPT="-O3 -Wall $STRICT_PROTO"
Skip Montanarodecc6a42003-01-01 20:07:49 +00001080 ;;
Fred Drake9f715822001-07-11 06:27:00 +00001081 esac
Martin v. Löwis21ee4092002-09-30 16:19:48 +00001082 case $ac_sys_system in
Skip Montanarodecc6a42003-01-01 20:07:49 +00001083 SCO_SV*) OPT="$OPT -m486 -DSCO5"
1084 ;;
1085 esac
Fred Drake9f715822001-07-11 06:27:00 +00001086 ;;
Skip Montanarodecc6a42003-01-01 20:07:49 +00001087
Guido van Rossum2242f2f2001-04-11 20:58:20 +00001088 *)
Skip Montanarodecc6a42003-01-01 20:07:49 +00001089 OPT="-O"
1090 ;;
Guido van Rossum2242f2f2001-04-11 20:58:20 +00001091 esac
Guido van Rossum4e8af441994-08-19 15:33:54 +00001092fi
Guido van Rossum627b2d71993-12-24 10:39:16 +00001093
Skip Montanarodecc6a42003-01-01 20:07:49 +00001094AC_SUBST(BASECFLAGS)
Ronald Oussoren5640ce22008-06-05 12:58:24 +00001095
1096# The -arch flags for universal builds on OSX
1097UNIVERSAL_ARCH_FLAGS=
1098AC_SUBST(UNIVERSAL_ARCH_FLAGS)
1099
Skip Montanarodecc6a42003-01-01 20:07:49 +00001100# tweak BASECFLAGS based on compiler and platform
1101case $GCC in
1102yes)
Martin v. Löwis70fedcd2003-07-07 21:26:19 +00001103 # Python violates C99 rules, by casting between incompatible
1104 # pointer types. GCC may generate bad code as a result of that,
1105 # so use -fno-strict-aliasing if supported.
1106 AC_MSG_CHECKING(whether $CC accepts -fno-strict-aliasing)
1107 ac_save_cc="$CC"
1108 CC="$CC -fno-strict-aliasing"
Alexandre Vassalotti00900892009-07-17 05:26:39 +00001109 AC_CACHE_VAL(ac_cv_no_strict_aliasing_ok,
Matthias Klosec511b472010-05-08 11:01:39 +00001110 AC_COMPILE_IFELSE(
Mark Dickinson5e13e292010-05-11 08:55:06 +00001111 [AC_LANG_PROGRAM([[]], [[]])],
Matthias Klosec511b472010-05-08 11:01:39 +00001112 [ac_cv_no_strict_aliasing_ok=yes],
1113 [ac_cv_no_strict_aliasing_ok=no]))
Martin v. Löwis70fedcd2003-07-07 21:26:19 +00001114 CC="$ac_save_cc"
1115 AC_MSG_RESULT($ac_cv_no_strict_aliasing_ok)
1116 if test $ac_cv_no_strict_aliasing_ok = yes
1117 then
1118 BASECFLAGS="$BASECFLAGS -fno-strict-aliasing"
1119 fi
Mark Dickinson65134662008-04-25 16:11:04 +00001120
1121 # if using gcc on alpha, use -mieee to get (near) full IEEE 754
1122 # support. Without this, treatment of subnormals doesn't follow
1123 # the standard.
doko@python.orgd65e2ba2013-01-31 23:52:03 +01001124 case $host in
Mark Dickinson65134662008-04-25 16:11:04 +00001125 alpha*)
1126 BASECFLAGS="$BASECFLAGS -mieee"
1127 ;;
1128 esac
1129
Skip Montanarodecc6a42003-01-01 20:07:49 +00001130 case $ac_sys_system in
1131 SCO_SV*)
1132 BASECFLAGS="$BASECFLAGS -m486 -DSCO5"
1133 ;;
1134 # is there any other compiler on Darwin besides gcc?
1135 Darwin*)
Jeffrey Yasskin1b4e45b2008-03-17 14:40:53 +00001136 # -Wno-long-double, -no-cpp-precomp, and -mno-fused-madd
1137 # used to be here, but non-Apple gcc doesn't accept them.
Ronald Oussorena55af9a2010-01-17 16:25:57 +00001138 if test "${CC}" = gcc
1139 then
1140 AC_MSG_CHECKING(which compiler should be used)
1141 case "${UNIVERSALSDK}" in
1142 */MacOSX10.4u.sdk)
1143 # Build using 10.4 SDK, force usage of gcc when the
1144 # compiler is gcc, otherwise the user will get very
1145 # confusing error messages when building on OSX 10.6
1146 CC=gcc-4.0
1147 CPP=cpp-4.0
1148 ;;
1149 esac
1150 AC_MSG_RESULT($CC)
Ronald Oussoren988117f2006-04-29 11:31:35 +00001151 fi
1152
Benjamin Peterson4347c442008-07-17 15:59:24 +00001153 # Calculate the right deployment target for this build.
1154 #
Ned Deilyc40b9032014-06-25 13:48:46 -07001155 cur_target_major=`sw_vers -productVersion | \
1156 sed 's/\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'`
1157 cur_target_minor=`sw_vers -productVersion | \
1158 sed 's/\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'`
1159 cur_target="${cur_target_major}.${cur_target_minor}"
1160 if test ${cur_target_major} -eq 10 && \
1161 test ${cur_target_minor} -ge 3
1162 then
Benjamin Peterson4347c442008-07-17 15:59:24 +00001163 cur_target=10.3
Ronald Oussoren25967582009-09-06 10:00:26 +00001164 if test ${enable_universalsdk}; then
1165 if test "${UNIVERSAL_ARCHS}" = "all"; then
1166 # Ensure that the default platform for a
1167 # 4-way universal build is OSX 10.5,
1168 # that's the first OS release where
1169 # 4-way builds make sense.
1170 cur_target='10.5'
Ronald Oussoren23d92532009-09-07 06:12:00 +00001171
1172 elif test "${UNIVERSAL_ARCHS}" = "3-way"; then
1173 cur_target='10.5'
1174
1175 elif test "${UNIVERSAL_ARCHS}" = "intel"; then
1176 cur_target='10.5'
1177
1178 elif test "${UNIVERSAL_ARCHS}" = "64-bit"; then
1179 cur_target='10.5'
Ronald Oussoren25967582009-09-06 10:00:26 +00001180 fi
1181 else
Ronald Oussorenbc0e83c2010-02-11 13:26:54 +00001182 if test `/usr/bin/arch` = "i386"; then
Ronald Oussoren25967582009-09-06 10:00:26 +00001183 # On Intel macs default to a deployment
1184 # target of 10.4, that's the first OSX
1185 # release with Intel support.
1186 cur_target="10.4"
1187 fi
1188 fi
Benjamin Peterson4347c442008-07-17 15:59:24 +00001189 fi
1190 CONFIGURE_MACOSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET-${cur_target}}
1191
1192 # Make sure that MACOSX_DEPLOYMENT_TARGET is set in the
1193 # environment with a value that is the same as what we'll use
1194 # in the Makefile to ensure that we'll get the same compiler
1195 # environment during configure and build time.
1196 MACOSX_DEPLOYMENT_TARGET="$CONFIGURE_MACOSX_DEPLOYMENT_TARGET"
1197 export MACOSX_DEPLOYMENT_TARGET
1198 EXPORT_MACOSX_DEPLOYMENT_TARGET=''
1199
Ronald Oussorena55af9a2010-01-17 16:25:57 +00001200 if test "${enable_universalsdk}"; then
1201 UNIVERSAL_ARCH_FLAGS=""
1202 if test "$UNIVERSAL_ARCHS" = "32-bit" ; then
1203 UNIVERSAL_ARCH_FLAGS="-arch ppc -arch i386"
1204 ARCH_RUN_32BIT=""
Ronald Oussoren75912852010-04-08 08:13:31 +00001205 LIPO_32BIT_FLAGS=""
Ronald Oussorena55af9a2010-01-17 16:25:57 +00001206
1207 elif test "$UNIVERSAL_ARCHS" = "64-bit" ; then
1208 UNIVERSAL_ARCH_FLAGS="-arch ppc64 -arch x86_64"
1209 LIPO_32BIT_FLAGS=""
1210 ARCH_RUN_32BIT="true"
1211
1212 elif test "$UNIVERSAL_ARCHS" = "all" ; then
1213 UNIVERSAL_ARCH_FLAGS="-arch i386 -arch ppc -arch ppc64 -arch x86_64"
1214 LIPO_32BIT_FLAGS="-extract ppc7400 -extract i386"
Ronald Oussoren92397ce2010-01-17 19:32:00 +00001215 ARCH_RUN_32BIT="/usr/bin/arch -i386 -ppc"
Ronald Oussorena55af9a2010-01-17 16:25:57 +00001216
1217 elif test "$UNIVERSAL_ARCHS" = "intel" ; then
1218 UNIVERSAL_ARCH_FLAGS="-arch i386 -arch x86_64"
1219 LIPO_32BIT_FLAGS="-extract i386"
Ronald Oussoren92397ce2010-01-17 19:32:00 +00001220 ARCH_RUN_32BIT="/usr/bin/arch -i386"
Ronald Oussorena55af9a2010-01-17 16:25:57 +00001221
1222 elif test "$UNIVERSAL_ARCHS" = "3-way" ; then
1223 UNIVERSAL_ARCH_FLAGS="-arch i386 -arch ppc -arch x86_64"
1224 LIPO_32BIT_FLAGS="-extract ppc7400 -extract i386"
Ronald Oussoren9922f172010-02-11 13:19:34 +00001225 ARCH_RUN_32BIT="/usr/bin/arch -i386 -ppc"
Ronald Oussorena55af9a2010-01-17 16:25:57 +00001226
1227 else
1228 AC_MSG_ERROR([proper usage is --with-universal-arch=32-bit|64-bit|all|intel|3-way])
1229
1230 fi
1231
1232
Ronald Oussoren974eb5e2010-04-18 17:59:37 +00001233 CFLAGS="${UNIVERSAL_ARCH_FLAGS} ${CFLAGS}"
1234 if test "${UNIVERSALSDK}" != "/"
1235 then
1236 CPPFLAGS="-isysroot ${UNIVERSALSDK} ${CPPFLAGS}"
1237 LDFLAGS="-isysroot ${UNIVERSALSDK} ${LDFLAGS}"
1238 CFLAGS="-isysroot ${UNIVERSALSDK} ${CFLAGS}"
Ronald Oussorena55af9a2010-01-17 16:25:57 +00001239 fi
1240
1241 fi
1242
1243
Skip Montanarodecc6a42003-01-01 20:07:49 +00001244 ;;
Neal Norwitzdedeeaa2006-03-31 06:54:45 +00001245 OSF*)
1246 BASECFLAGS="$BASECFLAGS -mieee"
1247 ;;
Skip Montanarodecc6a42003-01-01 20:07:49 +00001248 esac
1249 ;;
1250
1251*)
1252 case $ac_sys_system in
1253 OpenUNIX*|UnixWare*)
1254 BASECFLAGS="$BASECFLAGS -K pentium,host,inline,loop_unroll,alloca "
1255 ;;
Neal Norwitzb44f1652003-05-26 14:11:55 +00001256 OSF*)
1257 BASECFLAGS="$BASECFLAGS -ieee -std"
1258 ;;
Skip Montanarodecc6a42003-01-01 20:07:49 +00001259 SCO_SV*)
1260 BASECFLAGS="$BASECFLAGS -belf -Ki486 -DSCO5"
1261 ;;
1262 esac
1263 ;;
1264esac
1265
Fred Drakee1ceaa02001-12-04 20:55:47 +00001266if test "$Py_DEBUG" = 'true'; then
1267 :
1268else
1269 OPT="-DNDEBUG $OPT"
1270fi
1271
Guido van Rossum6f2260e1996-09-09 16:21:03 +00001272if test "$ac_arch_flags"
Guido van Rossumc5a39031996-07-31 17:35:03 +00001273then
Skip Montanarodecc6a42003-01-01 20:07:49 +00001274 BASECFLAGS="$BASECFLAGS $ac_arch_flags"
Guido van Rossumc5a39031996-07-31 17:35:03 +00001275fi
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001276
Neal Norwitz020c46a2006-01-07 21:39:28 +00001277# disable check for icc since it seems to pass, but generates a warning
1278if test "$CC" = icc
1279then
1280 ac_cv_opt_olimit_ok=no
1281fi
1282
Guido van Rossum91922671997-10-09 20:24:13 +00001283AC_MSG_CHECKING(whether $CC accepts -OPT:Olimit=0)
1284AC_CACHE_VAL(ac_cv_opt_olimit_ok,
1285[ac_save_cc="$CC"
1286CC="$CC -OPT:Olimit=0"
Matthias Klosec511b472010-05-08 11:01:39 +00001287AC_COMPILE_IFELSE(
Mark Dickinson5e13e292010-05-11 08:55:06 +00001288 [AC_LANG_PROGRAM([[]], [[]])],
Matthias Klosec511b472010-05-08 11:01:39 +00001289 [ac_cv_opt_olimit_ok=yes],
1290 [ac_cv_opt_olimit_ok=no]
Gregory P. Smithec3b8bd2009-11-01 21:02:52 +00001291 )
Guido van Rossum91922671997-10-09 20:24:13 +00001292CC="$ac_save_cc"])
1293AC_MSG_RESULT($ac_cv_opt_olimit_ok)
Guido van Rossum2efa34b1997-10-23 17:43:11 +00001294if test $ac_cv_opt_olimit_ok = yes; then
Guido van Rossum5839e582000-10-09 19:52:35 +00001295 case $ac_sys_system in
Skip Montanarodecc6a42003-01-01 20:07:49 +00001296 # XXX is this branch needed? On MacOSX 10.2.2 the result of the
1297 # olimit_ok test is "no". Is it "yes" in some other Darwin-esque
1298 # environment?
1299 Darwin*)
1300 ;;
Trent Nelson34562e12012-10-17 18:01:12 -04001301 # XXX thankfully this useless troublemaker of a flag has been
1302 # eradicated in the 3.x line. For now, make sure it isn't picked
1303 # up by any of our other platforms that use CC.
1304 AIX*|SunOS*|HP-UX*|IRIX*)
1305 ;;
Skip Montanarodecc6a42003-01-01 20:07:49 +00001306 *)
1307 BASECFLAGS="$BASECFLAGS -OPT:Olimit=0"
1308 ;;
Guido van Rossum5839e582000-10-09 19:52:35 +00001309 esac
Guido van Rossumf8678121998-07-07 21:05:09 +00001310else
1311 AC_MSG_CHECKING(whether $CC accepts -Olimit 1500)
1312 AC_CACHE_VAL(ac_cv_olimit_ok,
1313 [ac_save_cc="$CC"
1314 CC="$CC -Olimit 1500"
Matthias Klosec511b472010-05-08 11:01:39 +00001315 AC_COMPILE_IFELSE(
Mark Dickinson5e13e292010-05-11 08:55:06 +00001316 [AC_LANG_PROGRAM([[]], [[]])],
Matthias Klosec511b472010-05-08 11:01:39 +00001317 [ac_cv_olimit_ok=yes],
1318 [ac_cv_olimit_ok=no]
Gregory P. Smithec3b8bd2009-11-01 21:02:52 +00001319 )
Guido van Rossumf8678121998-07-07 21:05:09 +00001320 CC="$ac_save_cc"])
1321 AC_MSG_RESULT($ac_cv_olimit_ok)
1322 if test $ac_cv_olimit_ok = yes; then
Stefan Krah67473262012-11-29 00:17:05 +01001323 case $ac_sys_system in
1324 # Issue #16534: On HP-UX ac_cv_olimit_ok=yes is a false positive.
1325 HP-UX*)
1326 ;;
1327 *)
1328 BASECFLAGS="$BASECFLAGS -Olimit 1500"
1329 ;;
1330 esac
Guido van Rossumf8678121998-07-07 21:05:09 +00001331 fi
Guido van Rossum201afe51997-05-14 21:14:44 +00001332fi
Guido van Rossumf8678121998-07-07 21:05:09 +00001333
Martin v. Löwisaac13162006-10-19 10:58:46 +00001334# Check whether GCC supports PyArg_ParseTuple format
1335if test "$GCC" = "yes"
1336then
1337 AC_MSG_CHECKING(whether gcc supports ParseTuple __format__)
1338 save_CFLAGS=$CFLAGS
Benjamin Petersonc8759662013-05-11 13:00:05 -05001339 CFLAGS="$CFLAGS -Werror -Wformat"
Matthias Klosec511b472010-05-08 11:01:39 +00001340 AC_COMPILE_IFELSE([
1341 AC_LANG_PROGRAM([[void f(char*,...)__attribute((format(PyArg_ParseTuple, 1, 2)));]], [[]])
1342 ],[
1343 AC_DEFINE(HAVE_ATTRIBUTE_FORMAT_PARSETUPLE, 1,
1344 [Define if GCC supports __attribute__((format(PyArg_ParseTuple, 2, 3)))])
1345 AC_MSG_RESULT(yes)
1346 ],[
1347 AC_MSG_RESULT(no)
1348 ])
Martin v. Löwisc1d75972006-10-19 16:01:37 +00001349 CFLAGS=$save_CFLAGS
Martin v. Löwisaac13162006-10-19 10:58:46 +00001350fi
1351
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00001352# On some compilers, pthreads are available without further options
1353# (e.g. MacOS X). On some of these systems, the compiler will not
1354# complain if unaccepted options are passed (e.g. gcc on Mac OS X).
1355# So we have to see first whether pthreads are available without
1356# options before we can check whether -Kpthread improves anything.
1357AC_MSG_CHECKING(whether pthreads are available without options)
1358AC_CACHE_VAL(ac_cv_pthread_is_default,
Matthias Klosec511b472010-05-08 11:01:39 +00001359[AC_RUN_IFELSE([AC_LANG_SOURCE([[
Stefan Krahae66ca62012-11-22 22:36:57 +01001360#include <stdio.h>
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00001361#include <pthread.h>
1362
1363void* routine(void* p){return NULL;}
1364
1365int main(){
1366 pthread_t p;
1367 if(pthread_create(&p,NULL,routine,NULL)!=0)
1368 return 1;
Jack Jansen4f8d0542002-03-08 13:43:01 +00001369 (void)pthread_detach(p);
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00001370 return 0;
1371}
Matthias Klosec511b472010-05-08 11:01:39 +00001372]])],[
Skip Montanarod8d39a02003-07-10 20:44:10 +00001373 ac_cv_pthread_is_default=yes
1374 ac_cv_kthread=no
1375 ac_cv_pthread=no
Matthias Klosec511b472010-05-08 11:01:39 +00001376],[ac_cv_pthread_is_default=no],[ac_cv_pthread_is_default=no])
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00001377])
1378AC_MSG_RESULT($ac_cv_pthread_is_default)
1379
1380
1381if test $ac_cv_pthread_is_default = yes
1382then
1383 ac_cv_kpthread=no
1384else
Martin v. Löwis130fb172001-07-19 11:00:41 +00001385# -Kpthread, if available, provides the right #defines
1386# and linker options to make pthread_create available
Martin v. Löwis260aecc2001-10-07 08:14:41 +00001387# Some compilers won't report that they do not support -Kpthread,
1388# so we need to run a program to see whether it really made the
1389# function available.
Martin v. Löwis130fb172001-07-19 11:00:41 +00001390AC_MSG_CHECKING(whether $CC accepts -Kpthread)
1391AC_CACHE_VAL(ac_cv_kpthread,
1392[ac_save_cc="$CC"
1393CC="$CC -Kpthread"
Matthias Klosec511b472010-05-08 11:01:39 +00001394AC_RUN_IFELSE([AC_LANG_SOURCE([[
Stefan Krahae66ca62012-11-22 22:36:57 +01001395#include <stdio.h>
Martin v. Löwis260aecc2001-10-07 08:14:41 +00001396#include <pthread.h>
1397
1398void* routine(void* p){return NULL;}
1399
1400int main(){
1401 pthread_t p;
1402 if(pthread_create(&p,NULL,routine,NULL)!=0)
1403 return 1;
Jack Jansen4f8d0542002-03-08 13:43:01 +00001404 (void)pthread_detach(p);
Martin v. Löwis260aecc2001-10-07 08:14:41 +00001405 return 0;
1406}
Matthias Klosec511b472010-05-08 11:01:39 +00001407]])],[ac_cv_kpthread=yes],[ac_cv_kpthread=no],[ac_cv_kpthread=no])
Martin v. Löwis130fb172001-07-19 11:00:41 +00001408CC="$ac_save_cc"])
Martin v. Löwis130fb172001-07-19 11:00:41 +00001409AC_MSG_RESULT($ac_cv_kpthread)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00001410fi
Martin v. Löwis130fb172001-07-19 11:00:41 +00001411
Skip Montanarod8d39a02003-07-10 20:44:10 +00001412if test $ac_cv_kpthread = no -a $ac_cv_pthread_is_default = no
Martin v. Löwis5f433f02003-05-05 05:05:30 +00001413then
1414# -Kthread, if available, provides the right #defines
1415# and linker options to make pthread_create available
1416# Some compilers won't report that they do not support -Kthread,
1417# so we need to run a program to see whether it really made the
1418# function available.
1419AC_MSG_CHECKING(whether $CC accepts -Kthread)
1420AC_CACHE_VAL(ac_cv_kthread,
1421[ac_save_cc="$CC"
1422CC="$CC -Kthread"
Matthias Klosec511b472010-05-08 11:01:39 +00001423AC_RUN_IFELSE([AC_LANG_SOURCE([[
Stefan Krahae66ca62012-11-22 22:36:57 +01001424#include <stdio.h>
Martin v. Löwis5f433f02003-05-05 05:05:30 +00001425#include <pthread.h>
1426
1427void* routine(void* p){return NULL;}
1428
1429int main(){
1430 pthread_t p;
1431 if(pthread_create(&p,NULL,routine,NULL)!=0)
1432 return 1;
1433 (void)pthread_detach(p);
1434 return 0;
1435}
Matthias Klosec511b472010-05-08 11:01:39 +00001436]])],[ac_cv_kthread=yes],[ac_cv_kthread=no],[ac_cv_kthread=no])
Martin v. Löwis5f433f02003-05-05 05:05:30 +00001437CC="$ac_save_cc"])
1438AC_MSG_RESULT($ac_cv_kthread)
1439fi
1440
Skip Montanarod8d39a02003-07-10 20:44:10 +00001441if test $ac_cv_kthread = no -a $ac_cv_pthread_is_default = no
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00001442then
1443# -pthread, if available, provides the right #defines
1444# and linker options to make pthread_create available
1445# Some compilers won't report that they do not support -pthread,
1446# so we need to run a program to see whether it really made the
1447# function available.
1448AC_MSG_CHECKING(whether $CC accepts -pthread)
doko@python.orgfa3f9a32013-01-25 15:32:31 +01001449AC_CACHE_VAL(ac_cv_pthread,
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00001450[ac_save_cc="$CC"
1451CC="$CC -pthread"
Matthias Klosec511b472010-05-08 11:01:39 +00001452AC_RUN_IFELSE([AC_LANG_SOURCE([[
Stefan Krahae66ca62012-11-22 22:36:57 +01001453#include <stdio.h>
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00001454#include <pthread.h>
1455
1456void* routine(void* p){return NULL;}
1457
1458int main(){
1459 pthread_t p;
1460 if(pthread_create(&p,NULL,routine,NULL)!=0)
1461 return 1;
1462 (void)pthread_detach(p);
1463 return 0;
1464}
Matthias Klosec511b472010-05-08 11:01:39 +00001465]])],[ac_cv_pthread=yes],[ac_cv_pthread=no],[ac_cv_pthread=no])
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00001466CC="$ac_save_cc"])
1467AC_MSG_RESULT($ac_cv_pthread)
1468fi
1469
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001470# If we have set a CC compiler flag for thread support then
1471# check if it works for CXX, too.
1472ac_cv_cxx_thread=no
1473if test ! -z "$CXX"
1474then
1475AC_MSG_CHECKING(whether $CXX also accepts flags for thread support)
1476ac_save_cxx="$CXX"
1477
1478if test "$ac_cv_kpthread" = "yes"
1479then
Martin v. Löwis519adae2003-09-20 10:47:47 +00001480 CXX="$CXX -Kpthread"
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001481 ac_cv_cxx_thread=yes
1482elif test "$ac_cv_kthread" = "yes"
1483then
1484 CXX="$CXX -Kthread"
1485 ac_cv_cxx_thread=yes
1486elif test "$ac_cv_pthread" = "yes"
1487then
1488 CXX="$CXX -pthread"
1489 ac_cv_cxx_thread=yes
1490fi
1491
1492if test $ac_cv_cxx_thread = yes
1493then
1494 echo 'void foo();int main(){foo();}void foo(){}' > conftest.$ac_ext
1495 $CXX -c conftest.$ac_ext 2>&5
1496 if $CXX -o conftest$ac_exeext conftest.$ac_objext 2>&5 \
1497 && test -s conftest$ac_exeext && ./conftest$ac_exeext
1498 then
1499 ac_cv_cxx_thread=yes
1500 else
1501 ac_cv_cxx_thread=no
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001502 fi
1503 rm -fr conftest*
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001504fi
Brett Cannonc601e0f2004-11-07 01:24:12 +00001505AC_MSG_RESULT($ac_cv_cxx_thread)
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001506fi
Martin v. Löwis519adae2003-09-20 10:47:47 +00001507CXX="$ac_save_cxx"
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001508
Fred Drakece81d592000-07-09 14:39:29 +00001509dnl # check for ANSI or K&R ("traditional") preprocessor
1510dnl AC_MSG_CHECKING(for C preprocessor type)
Matthias Klosec511b472010-05-08 11:01:39 +00001511dnl AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Fred Drakece81d592000-07-09 14:39:29 +00001512dnl #define spam(name, doc) {#name, &name, #name "() -- " doc}
1513dnl int foo;
1514dnl struct {char *name; int *addr; char *doc;} desc = spam(foo, "something");
Matthias Klosec511b472010-05-08 11:01:39 +00001515dnl ]], [[;]])],[cpp_type=ansi],[AC_DEFINE(HAVE_OLD_CPP) cpp_type=traditional])
Fred Drakece81d592000-07-09 14:39:29 +00001516dnl AC_MSG_RESULT($cpp_type)
Guido van Rossum300fda71996-08-19 21:58:16 +00001517
Guido van Rossum627b2d71993-12-24 10:39:16 +00001518# checks for header files
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001519AC_HEADER_STDC
doko@ubuntu.comf27ec3e2014-04-17 20:11:19 +02001520AC_CHECK_HEADERS(asm/types.h conio.h direct.h dlfcn.h errno.h \
Martin v. Löwis0e8bd7e2006-06-10 12:23:46 +00001521fcntl.h grp.h \
doko@ubuntu.comf27ec3e2014-04-17 20:11:19 +02001522ieeefp.h io.h langinfo.h libintl.h poll.h process.h pthread.h \
Martin v. Löwis40e9aed2006-10-02 15:20:37 +00001523shadow.h signal.h stdint.h stropts.h termios.h thread.h \
Martin v. Löwis14e73b12003-01-01 09:51:12 +00001524unistd.h utime.h \
Christian Heimes0e9ab5f2008-03-21 23:49:44 +00001525sys/audioio.h sys/bsdtty.h sys/epoll.h sys/event.h sys/file.h sys/loadavg.h \
1526sys/lock.h sys/mkdev.h sys/modem.h \
Martin v. Löwis0e8bd7e2006-06-10 12:23:46 +00001527sys/param.h sys/poll.h sys/select.h sys/socket.h sys/statvfs.h sys/stat.h \
Martin v. Löwis8c255e42008-05-23 15:06:50 +00001528sys/termio.h sys/time.h \
Martin v. Löwis0e8bd7e2006-06-10 12:23:46 +00001529sys/times.h sys/types.h sys/un.h sys/utsname.h sys/wait.h pty.h libutil.h \
Martin v. Löwis0347a9a2006-10-27 07:06:52 +00001530sys/resource.h netpacket/packet.h sysexits.h bluetooth.h \
Christian Heimes3aa138f2013-06-18 13:25:24 +02001531bluetooth/bluetooth.h linux/tipc.h spawn.h util.h alloca.h)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001532AC_HEADER_DIRENT
Martin v. Löwisdbe3f762002-10-10 14:27:30 +00001533AC_HEADER_MAJOR
Guido van Rossum627b2d71993-12-24 10:39:16 +00001534
Martin v. Löwis11017b12006-01-14 18:12:57 +00001535# On Linux, netlink.h requires asm/types.h
1536AC_CHECK_HEADERS(linux/netlink.h,,,[
1537#ifdef HAVE_ASM_TYPES_H
1538#include <asm/types.h>
1539#endif
1540#ifdef HAVE_SYS_SOCKET_H
1541#include <sys/socket.h>
1542#endif
1543])
1544
Guido van Rossum627b2d71993-12-24 10:39:16 +00001545# checks for typedefs
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001546was_it_defined=no
1547AC_MSG_CHECKING(for clock_t in time.h)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001548AC_EGREP_HEADER(clock_t, time.h, was_it_defined=yes, [
1549 AC_DEFINE(clock_t, long, [Define to 'long' if <time.h> doesn't define.])
1550])
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001551AC_MSG_RESULT($was_it_defined)
1552
Neal Norwitz11690112002-07-30 01:08:28 +00001553# Check whether using makedev requires defining _OSF_SOURCE
1554AC_MSG_CHECKING(for makedev)
Matthias Klosec511b472010-05-08 11:01:39 +00001555AC_LINK_IFELSE([AC_LANG_PROGRAM([[
Jesus Cea616de772010-04-28 10:32:30 +00001556#if defined(MAJOR_IN_MKDEV)
1557#include <sys/mkdev.h>
1558#elif defined(MAJOR_IN_SYSMACROS)
1559#include <sys/sysmacros.h>
1560#else
1561#include <sys/types.h>
Matthias Klosec511b472010-05-08 11:01:39 +00001562#endif ]], [[ makedev(0, 0) ]])],
1563[ac_cv_has_makedev=yes],
1564[ac_cv_has_makedev=no])
Neal Norwitz11690112002-07-30 01:08:28 +00001565if test "$ac_cv_has_makedev" = "no"; then
1566 # we didn't link, try if _OSF_SOURCE will allow us to link
Matthias Klosec511b472010-05-08 11:01:39 +00001567 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
Neal Norwitz6eb37f02003-02-23 23:28:15 +00001568#define _OSF_SOURCE 1
1569#include <sys/types.h>
Matthias Klosec511b472010-05-08 11:01:39 +00001570 ]], [[ makedev(0, 0) ]])],
1571[ac_cv_has_makedev=yes],
1572[ac_cv_has_makedev=no])
Neal Norwitz11690112002-07-30 01:08:28 +00001573 if test "$ac_cv_has_makedev" = "yes"; then
1574 AC_DEFINE(_OSF_SOURCE, 1, [Define _OSF_SOURCE to get the makedev macro.])
1575 fi
1576fi
1577AC_MSG_RESULT($ac_cv_has_makedev)
1578if test "$ac_cv_has_makedev" = "yes"; then
1579 AC_DEFINE(HAVE_MAKEDEV, 1, [Define this if you have the makedev macro.])
1580fi
1581
Martin v. Löwis399a6892002-10-04 10:22:02 +00001582# Enabling LFS on Solaris (2.6 to 9) with gcc 2.95 triggers a bug in
1583# the system headers: If _XOPEN_SOURCE and _LARGEFILE_SOURCE are
1584# defined, but the compiler does not support pragma redefine_extname,
1585# and _LARGEFILE64_SOURCE is not defined, the headers refer to 64-bit
1586# structures (such as rlimit64) without declaring them. As a
1587# work-around, disable LFS on such configurations
1588
1589use_lfs=yes
1590AC_MSG_CHECKING(Solaris LFS bug)
Matthias Klosec511b472010-05-08 11:01:39 +00001591AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwis399a6892002-10-04 10:22:02 +00001592#define _LARGEFILE_SOURCE 1
1593#define _FILE_OFFSET_BITS 64
1594#include <sys/resource.h>
Matthias Klosec511b472010-05-08 11:01:39 +00001595]], [[struct rlimit foo;]])],[sol_lfs_bug=no],[sol_lfs_bug=yes])
Martin v. Löwis399a6892002-10-04 10:22:02 +00001596AC_MSG_RESULT($sol_lfs_bug)
1597if test "$sol_lfs_bug" = "yes"; then
1598 use_lfs=no
1599fi
1600
1601if test "$use_lfs" = "yes"; then
Guido van Rossum810cc512001-09-09 23:51:39 +00001602# Two defines needed to enable largefile support on various platforms
1603# These may affect some typedefs
Georg Brandl94800df2011-02-25 11:09:02 +00001604case $ac_sys_system/$ac_sys_release in
1605AIX*)
1606 AC_DEFINE(_LARGE_FILES, 1,
1607 [This must be defined on AIX systems to enable large file support.])
1608 ;;
1609esac
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001610AC_DEFINE(_LARGEFILE_SOURCE, 1,
1611[This must be defined on some systems to enable large file support.])
1612AC_DEFINE(_FILE_OFFSET_BITS, 64,
1613[This must be set to 64 on some systems to enable large file support.])
Martin v. Löwis399a6892002-10-04 10:22:02 +00001614fi
Guido van Rossum810cc512001-09-09 23:51:39 +00001615
Guido van Rossum300fda71996-08-19 21:58:16 +00001616# Add some code to confdefs.h so that the test for off_t works on SCO
1617cat >> confdefs.h <<\EOF
1618#if defined(SCO_DS)
1619#undef _OFF_T
1620#endif
1621EOF
1622
Guido van Rossumef2255b2000-03-10 22:30:29 +00001623# Type availability checks
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001624AC_TYPE_MODE_T
1625AC_TYPE_OFF_T
1626AC_TYPE_PID_T
Matthias Klosecbf54b12010-05-08 11:04:18 +00001627AC_DEFINE_UNQUOTED([RETSIGTYPE],[void],[assume C89 semantics that RETSIGTYPE is always void])
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001628AC_TYPE_SIZE_T
1629AC_TYPE_UID_T
Mark Dickinson17c50cd2012-12-02 13:13:56 +00001630
1631# There are two separate checks for each of the exact-width integer types we
1632# need. First we check whether the type is available using the usual
1633# AC_CHECK_TYPE macro with the default includes (which includes <inttypes.h>
1634# and <stdint.h> where available). We then also use the special type checks of
1635# the form AC_TYPE_UINT32_T, which in the case that uint32_t is not available
1636# directly, #define's uint32_t to be a suitable type.
1637
1638AC_CHECK_TYPE(uint32_t,
1639 AC_DEFINE(HAVE_UINT32_T, 1, [Define if your compiler provides uint32_t.]),,)
Mark Dickinsonefc82f72009-03-20 15:51:55 +00001640AC_TYPE_UINT32_T
Mark Dickinson17c50cd2012-12-02 13:13:56 +00001641
1642AC_CHECK_TYPE(uint64_t,
1643 AC_DEFINE(HAVE_UINT64_T, 1, [Define if your compiler provides uint64_t.]),,)
Mark Dickinsonefc82f72009-03-20 15:51:55 +00001644AC_TYPE_UINT64_T
Mark Dickinson17c50cd2012-12-02 13:13:56 +00001645
1646AC_CHECK_TYPE(int32_t,
1647 AC_DEFINE(HAVE_INT32_T, 1, [Define if your compiler provides int32_t.]),,)
Mark Dickinsonefc82f72009-03-20 15:51:55 +00001648AC_TYPE_INT32_T
Mark Dickinson17c50cd2012-12-02 13:13:56 +00001649
1650AC_CHECK_TYPE(int64_t,
1651 AC_DEFINE(HAVE_INT64_T, 1, [Define if your compiler provides int64_t.]),,)
Mark Dickinsonefc82f72009-03-20 15:51:55 +00001652AC_TYPE_INT64_T
Mark Dickinson17c50cd2012-12-02 13:13:56 +00001653
Christian Heimes951cc0f2008-01-31 23:08:23 +00001654AC_CHECK_TYPE(ssize_t,
Matthias Klose5183ebd2010-04-24 16:38:36 +00001655 AC_DEFINE(HAVE_SSIZE_T, 1, [Define if your compiler provides ssize_t]),,)
Guido van Rossum627b2d71993-12-24 10:39:16 +00001656
Guido van Rossumef2255b2000-03-10 22:30:29 +00001657# Sizes of various common basic types
Skip Montanarob9820a32004-01-17 00:16:12 +00001658# ANSI C requires sizeof(char) == 1, so no need to check it
Guido van Rossum3065c942001-09-17 04:03:14 +00001659AC_CHECK_SIZEOF(int, 4)
1660AC_CHECK_SIZEOF(long, 4)
1661AC_CHECK_SIZEOF(void *, 4)
Guido van Rossum3065c942001-09-17 04:03:14 +00001662AC_CHECK_SIZEOF(short, 2)
1663AC_CHECK_SIZEOF(float, 4)
1664AC_CHECK_SIZEOF(double, 8)
1665AC_CHECK_SIZEOF(fpos_t, 4)
Martin v. Löwis18e16552006-02-15 17:27:45 +00001666AC_CHECK_SIZEOF(size_t, 4)
Christian Heimes951cc0f2008-01-31 23:08:23 +00001667AC_CHECK_SIZEOF(pid_t, 4)
Guido van Rossumac405f61994-09-12 10:56:06 +00001668
Guido van Rossumec95c7b1998-08-04 17:59:56 +00001669AC_MSG_CHECKING(for long long support)
1670have_long_long=no
Matthias Klosec511b472010-05-08 11:01:39 +00001671AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[long long x; x = (long long)0;]])],[
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001672 AC_DEFINE(HAVE_LONG_LONG, 1, [Define this if you have the type long long.])
1673 have_long_long=yes
Matthias Klosec511b472010-05-08 11:01:39 +00001674],[])
Guido van Rossumec95c7b1998-08-04 17:59:56 +00001675AC_MSG_RESULT($have_long_long)
Guido van Rossum8bc1dfd1999-04-10 16:01:48 +00001676if test "$have_long_long" = yes ; then
Guido van Rossum3065c942001-09-17 04:03:14 +00001677AC_CHECK_SIZEOF(long long, 8)
Guido van Rossumec95c7b1998-08-04 17:59:56 +00001678fi
1679
Travis E. Oliphant711c9e92008-06-06 22:33:21 +00001680AC_MSG_CHECKING(for long double support)
1681have_long_double=no
Matthias Klosec511b472010-05-08 11:01:39 +00001682AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[long double x; x = (long double)0;]])],[
Travis E. Oliphant711c9e92008-06-06 22:33:21 +00001683 AC_DEFINE(HAVE_LONG_DOUBLE, 1, [Define this if you have the type long double.])
1684 have_long_double=yes
Matthias Klosec511b472010-05-08 11:01:39 +00001685],[])
Travis E. Oliphant711c9e92008-06-06 22:33:21 +00001686AC_MSG_RESULT($have_long_double)
Mark Dickinsondc1688a2008-06-27 22:20:14 +00001687if test "$have_long_double" = yes ; then
Travis E. Oliphant711c9e92008-06-06 22:33:21 +00001688AC_CHECK_SIZEOF(long double, 12)
1689fi
1690
Martin v. Löwisaef4c6b2007-01-21 09:33:07 +00001691AC_MSG_CHECKING(for _Bool support)
1692have_c99_bool=no
Matthias Klosec511b472010-05-08 11:01:39 +00001693AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[_Bool x; x = (_Bool)0;]])],[
Martin v. Löwisaef4c6b2007-01-21 09:33:07 +00001694 AC_DEFINE(HAVE_C99_BOOL, 1, [Define this if you have the type _Bool.])
1695 have_c99_bool=yes
Matthias Klosec511b472010-05-08 11:01:39 +00001696],[])
Martin v. Löwisaef4c6b2007-01-21 09:33:07 +00001697AC_MSG_RESULT($have_c99_bool)
1698if test "$have_c99_bool" = yes ; then
1699AC_CHECK_SIZEOF(_Bool, 1)
1700fi
1701
Martin v. Löwisebe26702006-10-02 14:55:51 +00001702AC_CHECK_TYPES(uintptr_t,
1703 [AC_CHECK_SIZEOF(uintptr_t, 4)],
Martin v. Löwis40e9aed2006-10-02 15:20:37 +00001704 [], [#ifdef HAVE_STDINT_H
1705 #include <stdint.h>
Antoine Pitrou7be5a652010-10-10 08:14:41 +00001706 #endif
1707 #ifdef HAVE_INTTYPES_H
1708 #include <inttypes.h>
Martin v. Löwis40e9aed2006-10-02 15:20:37 +00001709 #endif])
Martin v. Löwisebe26702006-10-02 14:55:51 +00001710
Alexandre Vassalotti856782e2009-07-17 04:59:05 +00001711AC_CHECK_SIZEOF(off_t, [], [
1712#ifdef HAVE_SYS_TYPES_H
1713#include <sys/types.h>
1714#endif
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001715])
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001716
1717AC_MSG_CHECKING(whether to enable large file support)
Mark Dickinson0ef0b912009-12-31 21:11:48 +00001718if test "$have_long_long" = yes
1719then
1720if test "$ac_cv_sizeof_off_t" -gt "$ac_cv_sizeof_long" -a \
Guido van Rossum8bc1dfd1999-04-10 16:01:48 +00001721 "$ac_cv_sizeof_long_long" -ge "$ac_cv_sizeof_off_t"; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001722 AC_DEFINE(HAVE_LARGEFILE_SUPPORT, 1,
1723 [Defined to enable large file support when an off_t is bigger than a long
1724 and long long is available and at least as big as an off_t. You may need
1725 to add some flags for configuration and compilation to enable this mode.
1726 (For Solaris and Linux, the necessary defines are already defined.)])
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001727 AC_MSG_RESULT(yes)
1728else
1729 AC_MSG_RESULT(no)
1730fi
Mark Dickinson0ef0b912009-12-31 21:11:48 +00001731else
1732 AC_MSG_RESULT(no)
1733fi
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001734
Alexandre Vassalotti856782e2009-07-17 04:59:05 +00001735AC_CHECK_SIZEOF(time_t, [], [
1736#ifdef HAVE_SYS_TYPES_H
1737#include <sys/types.h>
1738#endif
1739#ifdef HAVE_TIME_H
1740#include <time.h>
1741#endif
Fred Drakea3f6e912000-06-29 20:44:47 +00001742])
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001743
Trent Mick635f6fb2000-08-23 21:33:05 +00001744# if have pthread_t then define SIZEOF_PTHREAD_T
Martin v. Löwis123cbd22001-07-19 14:21:10 +00001745ac_save_cc="$CC"
1746if test "$ac_cv_kpthread" = "yes"
1747then CC="$CC -Kpthread"
Martin v. Löwis5f433f02003-05-05 05:05:30 +00001748elif test "$ac_cv_kthread" = "yes"
1749then CC="$CC -Kthread"
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00001750elif test "$ac_cv_pthread" = "yes"
1751then CC="$CC -pthread"
Martin v. Löwis123cbd22001-07-19 14:21:10 +00001752fi
Trent Mick635f6fb2000-08-23 21:33:05 +00001753AC_MSG_CHECKING(for pthread_t)
1754have_pthread_t=no
Matthias Klosec511b472010-05-08 11:01:39 +00001755AC_COMPILE_IFELSE([
1756 AC_LANG_PROGRAM([[#include <pthread.h>]], [[pthread_t x; x = *(pthread_t*)0;]])
1757],[have_pthread_t=yes],[])
Trent Mick635f6fb2000-08-23 21:33:05 +00001758AC_MSG_RESULT($have_pthread_t)
1759if test "$have_pthread_t" = yes ; then
Alexandre Vassalotti856782e2009-07-17 04:59:05 +00001760 AC_CHECK_SIZEOF(pthread_t, [], [
1761#ifdef HAVE_PTHREAD_H
1762#include <pthread.h>
1763#endif
Trent Mick635f6fb2000-08-23 21:33:05 +00001764 ])
Trent Mick635f6fb2000-08-23 21:33:05 +00001765fi
Martin v. Löwis123cbd22001-07-19 14:21:10 +00001766CC="$ac_save_cc"
Trent Mick635f6fb2000-08-23 21:33:05 +00001767
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001768AC_MSG_CHECKING(for --enable-toolbox-glue)
1769AC_ARG_ENABLE(toolbox-glue,
Matthias Klose22520ea2010-05-08 10:14:46 +00001770 AS_HELP_STRING([--enable-toolbox-glue], [disable/enable MacOSX glue code for extensions]))
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001771
1772if test -z "$enable_toolbox_glue"
1773then
1774 case $ac_sys_system/$ac_sys_release in
1775 Darwin/*)
1776 enable_toolbox_glue="yes";;
1777 *)
1778 enable_toolbox_glue="no";;
1779 esac
1780fi
1781case "$enable_toolbox_glue" in
1782yes)
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001783 extra_machdep_objs="Python/mactoolboxglue.o"
Raymond Hettingerec6eb362004-11-05 07:02:59 +00001784 extra_undefs="-u _PyMac_Error"
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001785 AC_DEFINE(USE_TOOLBOX_OBJECT_GLUE, 1,
1786 [Define if you want to use MacPython modules on MacOSX in unix-Python.])
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001787 ;;
1788*)
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001789 extra_machdep_objs=""
Jack Jansen591cbed2001-08-15 13:55:15 +00001790 extra_undefs=""
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001791 ;;
1792esac
1793AC_MSG_RESULT($enable_toolbox_glue)
1794
Ronald Oussoren0d236eb2008-06-06 21:31:33 +00001795
Bob Ippolito7026a0a2005-03-28 23:23:47 +00001796AC_SUBST(OTHER_LIBTOOL_OPT)
1797case $ac_sys_system/$ac_sys_release in
Anthony Baxter82201742006-04-09 15:07:40 +00001798 Darwin/@<:@01567@:>@\..*)
Bob Ippolito7026a0a2005-03-28 23:23:47 +00001799 OTHER_LIBTOOL_OPT="-prebind -seg1addr 0x10000000"
1800 ;;
1801 Darwin/*)
1802 OTHER_LIBTOOL_OPT=""
1803 ;;
1804esac
1805
Ronald Oussoren25967582009-09-06 10:00:26 +00001806
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001807AC_SUBST(LIBTOOL_CRUFT)
1808case $ac_sys_system/$ac_sys_release in
Anthony Baxter82201742006-04-09 15:07:40 +00001809 Darwin/@<:@01567@:>@\..*)
Ronald Oussoren988117f2006-04-29 11:31:35 +00001810 LIBTOOL_CRUFT="-framework System -lcc_dynamic"
1811 if test "${enable_universalsdk}"; then
1812 :
1813 else
Ronald Oussorenbc0e83c2010-02-11 13:26:54 +00001814 LIBTOOL_CRUFT="${LIBTOOL_CRUFT} -arch_only `/usr/bin/arch`"
Ronald Oussoren988117f2006-04-29 11:31:35 +00001815 fi
Jack Jansenb36687a2004-07-16 08:43:47 +00001816 LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -install_name $(PYTHONFRAMEWORKINSTALLDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansena3891ea2001-09-07 14:25:12 +00001817 LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -compatibility_version $(VERSION) -current_version $(VERSION)';;
Guido van Rossum5839e582000-10-09 19:52:35 +00001818 Darwin/*)
Ronald Oussorena55af9a2010-01-17 16:25:57 +00001819 gcc_version=`gcc -dumpversion`
Bob Ippolito7026a0a2005-03-28 23:23:47 +00001820 if test ${gcc_version} '<' 4.0
1821 then
1822 LIBTOOL_CRUFT="-lcc_dynamic"
1823 else
1824 LIBTOOL_CRUFT=""
1825 fi
Matthias Klosec511b472010-05-08 11:01:39 +00001826 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Ronald Oussoren25967582009-09-06 10:00:26 +00001827 #include <unistd.h>
1828 int main(int argc, char*argv[])
1829 {
1830 if (sizeof(long) == 4) {
1831 return 0;
1832 } else {
1833 return 1;
1834 }
Ronald Oussoren84ddd722009-09-08 07:17:10 +00001835 }
Matthias Klosec511b472010-05-08 11:01:39 +00001836 ]])],[ac_osx_32bit=yes],[ac_osx_32bit=no],[ac_osx_32bit=yes])
Ronald Oussoren25967582009-09-06 10:00:26 +00001837
1838 if test "${ac_osx_32bit}" = "yes"; then
Ronald Oussorenbc0e83c2010-02-11 13:26:54 +00001839 case `/usr/bin/arch` in
Ronald Oussoren25967582009-09-06 10:00:26 +00001840 i386)
1841 MACOSX_DEFAULT_ARCH="i386"
1842 ;;
1843 ppc)
1844 MACOSX_DEFAULT_ARCH="ppc"
1845 ;;
1846 *)
1847 AC_MSG_ERROR([Unexpected output of 'arch' on OSX])
1848 ;;
1849 esac
1850 else
Ronald Oussorenbc0e83c2010-02-11 13:26:54 +00001851 case `/usr/bin/arch` in
Ronald Oussoren25967582009-09-06 10:00:26 +00001852 i386)
1853 MACOSX_DEFAULT_ARCH="x86_64"
1854 ;;
1855 ppc)
1856 MACOSX_DEFAULT_ARCH="ppc64"
1857 ;;
1858 *)
1859 AC_MSG_ERROR([Unexpected output of 'arch' on OSX])
1860 ;;
1861 esac
1862
1863 #ARCH_RUN_32BIT="true"
1864 fi
1865
1866 LIBTOOL_CRUFT=$LIBTOOL_CRUFT" -lSystem -lSystemStubs -arch_only ${MACOSX_DEFAULT_ARCH}"
Jack Jansenb36687a2004-07-16 08:43:47 +00001867 LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -install_name $(PYTHONFRAMEWORKINSTALLDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001868 LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -compatibility_version $(VERSION) -current_version $(VERSION)';;
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001869esac
1870
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001871AC_MSG_CHECKING(for --enable-framework)
1872if test "$enable_framework"
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001873then
Skip Montanarodecc6a42003-01-01 20:07:49 +00001874 BASECFLAGS="$BASECFLAGS -fno-common -dynamic"
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001875 # -F. is needed to allow linking to the framework while
1876 # in the build location.
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001877 AC_DEFINE(WITH_NEXT_FRAMEWORK, 1,
1878 [Define if you want to produce an OpenStep/Rhapsody framework
1879 (shared library plus accessory files).])
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001880 AC_MSG_RESULT(yes)
Ronald Oussoren450d5612009-06-08 21:12:41 +00001881 if test $enable_shared = "yes"
1882 then
Ronald Oussoren9ebd2422009-09-29 13:00:44 +00001883 AC_MSG_ERROR([Specifying both --enable-shared and --enable-framework is not supported, use only --enable-framework instead. See Mac/README.])
Ronald Oussoren450d5612009-06-08 21:12:41 +00001884 fi
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001885else
1886 AC_MSG_RESULT(no)
1887fi
1888
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001889AC_MSG_CHECKING(for dyld)
Jack Jansen9a66b6d2001-08-08 13:56:14 +00001890case $ac_sys_system/$ac_sys_release in
1891 Darwin/*)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001892 AC_DEFINE(WITH_DYLD, 1,
1893 [Define if you want to use the new-style (Openstep, Rhapsody, MacOS)
1894 dynamic linker (dyld) instead of the old-style (NextStep) dynamic
1895 linker (rld). Dyld is necessary to support frameworks.])
Jack Jansen9a66b6d2001-08-08 13:56:14 +00001896 AC_MSG_RESULT(always on for Darwin)
1897 ;;
1898 *)
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001899 AC_MSG_RESULT(no)
1900 ;;
Jack Jansen9a66b6d2001-08-08 13:56:14 +00001901esac
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001902
Guido van Rossumac405f61994-09-12 10:56:06 +00001903# Set info about shared libraries.
Guido van Rossumac405f61994-09-12 10:56:06 +00001904AC_SUBST(SO)
1905AC_SUBST(LDSHARED)
Tarek Ziadé00002952010-04-03 08:37:59 +00001906AC_SUBST(LDCXXSHARED)
Neil Schemenauerb3531b82001-02-16 04:09:05 +00001907AC_SUBST(BLDSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00001908AC_SUBST(CCSHARED)
1909AC_SUBST(LINKFORSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00001910# SO is the extension of shared libraries `(including the dot!)
Guido van Rossumaef734b2001-01-10 21:09:12 +00001911# -- usually .so, .sl on HP-UX, .dll on Cygwin
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001912AC_MSG_CHECKING(SO)
Guido van Rossumac405f61994-09-12 10:56:06 +00001913if test -z "$SO"
1914then
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001915 case $ac_sys_system in
Neal Norwitz58e28882006-05-19 07:00:58 +00001916 hp*|HP*)
1917 case `uname -m` in
1918 ia64) SO=.so;;
1919 *) SO=.sl;;
1920 esac
1921 ;;
Guido van Rossumaef734b2001-01-10 21:09:12 +00001922 CYGWIN*) SO=.dll;;
Guido van Rossum4b6b5791996-09-09 20:09:34 +00001923 *) SO=.so;;
Guido van Rossumac405f61994-09-12 10:56:06 +00001924 esac
Martin v. Löwis368de8f2003-06-14 14:46:38 +00001925else
1926 # this might also be a termcap variable, see #610332
1927 echo
1928 echo '====================================================================='
1929 echo '+ +'
1930 echo '+ WARNING: You have set SO in your environment. +'
1931 echo '+ Do you really mean to change the extension for shared libraries? +'
1932 echo '+ Continuing in 10 seconds to let you to ponder. +'
1933 echo '+ +'
1934 echo '====================================================================='
1935 sleep 10
Guido van Rossumac405f61994-09-12 10:56:06 +00001936fi
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001937AC_MSG_RESULT($SO)
Ronald Oussoren79f90492009-01-02 10:44:46 +00001938
Neal Norwitz58e28882006-05-19 07:00:58 +00001939AC_DEFINE_UNQUOTED(SHLIB_EXT, "$SO", [Define this to be extension of shared libraries (including the dot!).])
Guido van Rossumac405f61994-09-12 10:56:06 +00001940# LDSHARED is the ld *command* used to create shared library
Skip Montanaroce59c042004-01-17 14:19:44 +00001941# -- "cc -G" on SunOS 5.x, "ld -shared" on IRIX 5
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001942# (Shared libraries in this instance are shared modules to be loaded into
1943# Python, as opposed to building Python itself as a shared library.)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001944AC_MSG_CHECKING(LDSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00001945if test -z "$LDSHARED"
1946then
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001947 case $ac_sys_system/$ac_sys_release in
Neil Schemenauerb3531b82001-02-16 04:09:05 +00001948 AIX*)
Georg Brandl71f4fbb2011-02-25 11:04:50 +00001949 BLDSHARED="\$(srcdir)/Modules/ld_so_aix \$(CC) -bI:\$(srcdir)/Modules/python.exp"
Guido van Rossumce608b02001-09-28 15:59:38 +00001950 LDSHARED="\$(BINLIBDEST)/config/ld_so_aix \$(CC) -bI:\$(BINLIBDEST)/config/python.exp"
Neil Schemenauerb3531b82001-02-16 04:09:05 +00001951 ;;
1952 BeOS*)
1953 BLDSHARED="\$(srcdir)/Modules/ld_so_beos $LDLIBRARY"
Guido van Rossumce608b02001-09-28 15:59:38 +00001954 LDSHARED="\$(BINLIBDEST)/config/ld_so_beos \$(LIBDIR)/$LDLIBRARY"
Neil Schemenauerb3531b82001-02-16 04:09:05 +00001955 ;;
Guido van Rossum6100aaf1997-04-29 21:48:51 +00001956 IRIX/5*) LDSHARED="ld -shared";;
Guido van Rossum91922671997-10-09 20:24:13 +00001957 IRIX*/6*) LDSHARED="ld ${SGI_ABI} -shared -all";;
Greg Ward57c9a662000-05-26 12:22:54 +00001958 SunOS/5*)
Tarek Ziadé00002952010-04-03 08:37:59 +00001959 if test "$GCC" = "yes" ; then
1960 LDSHARED='$(CC) -shared'
1961 LDCXXSHARED='$(CXX) -shared'
1962 else
1963 LDSHARED='$(CC) -G'
1964 LDCXXSHARED='$(CXX) -G'
Greg Ward57c9a662000-05-26 12:22:54 +00001965 fi ;;
Thomas Hellerdc96a772008-04-04 10:07:55 +00001966 hp*|HP*)
Tarek Ziadé00002952010-04-03 08:37:59 +00001967 if test "$GCC" = "yes" ; then
1968 LDSHARED='$(CC) -shared'
1969 LDCXXSHARED='$(CXX) -shared'
1970 else
1971 LDSHARED='ld -b'
Thomas Hellerdc96a772008-04-04 10:07:55 +00001972 fi ;;
Guido van Rossum71001e41995-01-26 00:44:03 +00001973 OSF*) LDSHARED="ld -shared -expect_unresolved \"*\"";;
Jack Jansen418c3b12001-11-14 10:59:57 +00001974 Darwin/1.3*)
Stefan Krah3a3e2032010-11-28 15:30:05 +00001975 LDSHARED='$(CC) -bundle'
1976 LDCXXSHARED='$(CXX) -bundle'
Jack Jansena3891ea2001-09-07 14:25:12 +00001977 if test "$enable_framework" ; then
1978 # Link against the framework. All externals should be defined.
Jack Jansenda49e192005-01-07 13:08:22 +00001979 BLDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
1980 LDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Tarek Ziadé00002952010-04-03 08:37:59 +00001981 LDCXXSHARED="$LDCXXSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansena3891ea2001-09-07 14:25:12 +00001982 else
1983 # No framework. Ignore undefined symbols, assuming they come from Python
Jack Jansen418c3b12001-11-14 10:59:57 +00001984 LDSHARED="$LDSHARED -undefined suppress"
Tarek Ziadé00002952010-04-03 08:37:59 +00001985 LDCXXSHARED="$LDCXXSHARED -undefined suppress"
Jack Jansena3891ea2001-09-07 14:25:12 +00001986 fi ;;
Jack Jansen6b08a402004-06-03 12:41:45 +00001987 Darwin/1.4*|Darwin/5.*|Darwin/6.*)
Stefan Krah3a3e2032010-11-28 15:30:05 +00001988 LDSHARED='$(CC) -bundle'
1989 LDCXXSHARED='$(CXX) -bundle'
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001990 if test "$enable_framework" ; then
1991 # Link against the framework. All externals should be defined.
Jack Jansenda49e192005-01-07 13:08:22 +00001992 BLDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
1993 LDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Tarek Ziadé00002952010-04-03 08:37:59 +00001994 LDCXXSHARED="$LDCXXSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001995 else
Michael W. Hudson0c46c0c2002-03-07 09:58:56 +00001996 # No framework, use the Python app as bundle-loader
1997 BLDSHARED="$LDSHARED "'-bundle_loader $(BUILDPYTHON)'
Jack Jansenc28fc372003-02-25 13:14:43 +00001998 LDSHARED="$LDSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)'
Tarek Ziadé00002952010-04-03 08:37:59 +00001999 LDCXXSHARED="$LDCXXSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)'
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00002000 fi ;;
Jack Jansen6b08a402004-06-03 12:41:45 +00002001 Darwin/*)
2002 # Use -undefined dynamic_lookup whenever possible (10.3 and later).
2003 # This allows an extension to be used in any Python
Ronald Oussoren38f1b982007-09-02 09:46:07 +00002004
Ned Deilyc40b9032014-06-25 13:48:46 -07002005 dep_target_major=`echo ${MACOSX_DEPLOYMENT_TARGET} | \
2006 sed 's/\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'`
2007 dep_target_minor=`echo ${MACOSX_DEPLOYMENT_TARGET} | \
2008 sed 's/\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'`
2009 if test ${dep_target_major} -eq 10 && \
2010 test ${dep_target_minor} -le 2
Jack Jansen6b08a402004-06-03 12:41:45 +00002011 then
Ned Deilyc40b9032014-06-25 13:48:46 -07002012 # building for OS X 10.0 through 10.2
Stefan Krah3a3e2032010-11-28 15:30:05 +00002013 LDSHARED='$(CC) -bundle'
2014 LDCXXSHARED='$(CXX) -bundle'
Jack Jansen6b08a402004-06-03 12:41:45 +00002015 if test "$enable_framework" ; then
2016 # Link against the framework. All externals should be defined.
Jack Jansenda49e192005-01-07 13:08:22 +00002017 BLDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
2018 LDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Tarek Ziadé00002952010-04-03 08:37:59 +00002019 LDCXXSHARED="$LDCXXSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansen6b08a402004-06-03 12:41:45 +00002020 else
2021 # No framework, use the Python app as bundle-loader
2022 BLDSHARED="$LDSHARED "'-bundle_loader $(BUILDPYTHON)'
2023 LDSHARED="$LDSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)'
Tarek Ziadé00002952010-04-03 08:37:59 +00002024 LDCXXSHARED="$LDCXXSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)'
Jack Jansen6b08a402004-06-03 12:41:45 +00002025 fi
Ned Deilyc40b9032014-06-25 13:48:46 -07002026 else
2027 # building for OS X 10.3 and later
2028 if test "${enable_universalsdk}"; then
2029 LDFLAGS="${UNIVERSAL_ARCH_FLAGS} -isysroot ${UNIVERSALSDK} ${LDFLAGS}"
2030 fi
2031 LDSHARED='$(CC) -bundle -undefined dynamic_lookup'
2032 LDCXXSHARED='$(CXX) -bundle -undefined dynamic_lookup'
2033 BLDSHARED="$LDSHARED"
Jack Jansen6b08a402004-06-03 12:41:45 +00002034 fi
2035 ;;
Tarek Ziadé00002952010-04-03 08:37:59 +00002036 Linux*|GNU*|QNX*)
2037 LDSHARED='$(CC) -shared'
2038 LDCXXSHARED='$(CXX) -shared';;
2039 BSD/OS*/4*)
2040 LDSHARED="gcc -shared"
2041 LDCXXSHARED="g++ -shared";;
Martin v. Löwis222c5152006-06-03 07:37:13 +00002042 FreeBSD*)
Jeremy Hylton4bcc7c52000-08-31 17:45:35 +00002043 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
Guido van Rossum0286ae82000-08-29 15:06:49 +00002044 then
Stefan Krah3a3e2032010-11-28 15:30:05 +00002045 LDSHARED='$(CC) -shared'
2046 LDCXXSHARED='$(CXX) -shared'
Guido van Rossum0286ae82000-08-29 15:06:49 +00002047 else
Stefan Krah3a3e2032010-11-28 15:30:05 +00002048 LDSHARED="ld -Bshareable"
Guido van Rossum0286ae82000-08-29 15:06:49 +00002049 fi;;
Martin v. Löwis222c5152006-06-03 07:37:13 +00002050 OpenBSD*)
2051 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
2052 then
Stefan Krah3a3e2032010-11-28 15:30:05 +00002053 LDSHARED='$(CC) -shared $(CCSHARED)'
2054 LDCXXSHARED='$(CXX) -shared $(CCSHARED)'
Martin v. Löwis222c5152006-06-03 07:37:13 +00002055 else
2056 case `uname -r` in
2057 [[01]].* | 2.[[0-7]] | 2.[[0-7]].*)
2058 LDSHARED="ld -Bshareable ${LDFLAGS}"
2059 ;;
2060 *)
Stefan Krah3a3e2032010-11-28 15:30:05 +00002061 LDSHARED='$(CC) -shared $(CCSHARED)'
2062 LDCXXSHARED='$(CXX) -shared $(CCSHARED)'
Martin v. Löwis222c5152006-06-03 07:37:13 +00002063 ;;
2064 esac
2065 fi;;
Tarek Ziadé00002952010-04-03 08:37:59 +00002066 NetBSD*|DragonFly*)
Antoine Pitroucb402772011-01-02 20:51:34 +00002067 LDSHARED='$(CC) -shared'
2068 LDCXXSHARED='$(CXX) -shared';;
Martin v. Löwis25ae43b2001-10-07 08:39:18 +00002069 OpenUNIX*|UnixWare*)
Tarek Ziadé00002952010-04-03 08:37:59 +00002070 if test "$GCC" = "yes" ; then
2071 LDSHARED='$(CC) -shared'
2072 LDCXXSHARED='$(CXX) -shared'
2073 else
2074 LDSHARED='$(CC) -G'
2075 LDCXXSHARED='$(CXX) -G'
Martin v. Löwisbec19582001-03-21 15:57:54 +00002076 fi;;
Tarek Ziadé00002952010-04-03 08:37:59 +00002077 SCO_SV*)
2078 LDSHARED='$(CC) -Wl,-G,-Bexport'
2079 LDCXXSHARED='$(CXX) -Wl,-G,-Bexport';;
2080 CYGWIN*)
2081 LDSHARED="gcc -shared -Wl,--enable-auto-image-base"
2082 LDCXXSHARED="g++ -shared -Wl,--enable-auto-image-base";;
2083 atheos*)
2084 LDSHARED="gcc -shared"
2085 LDCXXSHARED="g++ -shared";;
Guido van Rossumac405f61994-09-12 10:56:06 +00002086 *) LDSHARED="ld";;
2087 esac
Guido van Rossumac405f61994-09-12 10:56:06 +00002088fi
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002089AC_MSG_RESULT($LDSHARED)
Tarek Ziadé00002952010-04-03 08:37:59 +00002090LDCXXSHARED=${LDCXXSHARED-$LDSHARED}
Neil Schemenauerb3531b82001-02-16 04:09:05 +00002091BLDSHARED=${BLDSHARED-$LDSHARED}
Guido van Rossumac405f61994-09-12 10:56:06 +00002092# CCSHARED are the C *flags* used to create objects to go into a shared
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00002093# library (module) -- this is only needed for a few systems
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002094AC_MSG_CHECKING(CCSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00002095if test -z "$CCSHARED"
2096then
Guido van Rossum6100aaf1997-04-29 21:48:51 +00002097 case $ac_sys_system/$ac_sys_release in
Neil Schemenauer66252162001-02-19 04:47:42 +00002098 SunOS*) if test "$GCC" = yes;
Martin v. Löwiseb623572007-03-12 10:50:39 +00002099 then CCSHARED="-fPIC";
2100 elif test `uname -p` = sparc;
2101 then CCSHARED="-xcode=pic32";
2102 else CCSHARED="-Kpic";
2103 fi;;
Guido van Rossumaf07a441995-02-13 19:45:27 +00002104 hp*|HP*) if test "$GCC" = yes;
Martin v. Löwis703ad702001-09-05 08:36:52 +00002105 then CCSHARED="-fPIC";
Guido van Rossumaf07a441995-02-13 19:45:27 +00002106 else CCSHARED="+z";
2107 fi;;
Martin v. Löwisa6e97582002-01-01 18:41:33 +00002108 Linux*|GNU*) CCSHARED="-fPIC";;
Guido van Rossumf5957ea1999-10-05 21:59:33 +00002109 BSD/OS*/4*) CCSHARED="-fpic";;
Martin v. Löwis86d66262006-02-17 08:40:11 +00002110 FreeBSD*|NetBSD*|OpenBSD*|DragonFly*) CCSHARED="-fPIC";;
Martin v. Löwis25ae43b2001-10-07 08:39:18 +00002111 OpenUNIX*|UnixWare*)
Martin v. Löwisbec19582001-03-21 15:57:54 +00002112 if test "$GCC" = "yes"
2113 then CCSHARED="-fPIC"
Martin v. Löwis130fb172001-07-19 11:00:41 +00002114 else CCSHARED="-KPIC"
Martin v. Löwisbec19582001-03-21 15:57:54 +00002115 fi;;
Martin v. Löwis21ee4092002-09-30 16:19:48 +00002116 SCO_SV*)
2117 if test "$GCC" = "yes"
2118 then CCSHARED="-fPIC"
2119 else CCSHARED="-Kpic -belf"
2120 fi;;
Guido van Rossum2b5ca001998-03-05 15:41:09 +00002121 IRIX*/6*) case $CC in
2122 *gcc*) CCSHARED="-shared";;
Guido van Rossumee21f411998-04-20 18:51:54 +00002123 *) CCSHARED="";;
Guido van Rossum2b5ca001998-03-05 15:41:09 +00002124 esac;;
Martin v. Löwisf90ae202002-06-11 06:22:31 +00002125 atheos*) CCSHARED="-fPIC";;
Guido van Rossumac405f61994-09-12 10:56:06 +00002126 esac
Guido van Rossumac405f61994-09-12 10:56:06 +00002127fi
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002128AC_MSG_RESULT($CCSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00002129# LINKFORSHARED are the flags passed to the $(CC) command that links
Guido van Rossumb65a48e1995-06-14 18:21:23 +00002130# the python executable -- this is only needed for a few systems
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002131AC_MSG_CHECKING(LINKFORSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00002132if test -z "$LINKFORSHARED"
2133then
Guido van Rossum6100aaf1997-04-29 21:48:51 +00002134 case $ac_sys_system/$ac_sys_release in
Neil Schemenauerb3531b82001-02-16 04:09:05 +00002135 AIX*) LINKFORSHARED='-Wl,-bE:Modules/python.exp -lld';;
Guido van Rossum5dab3d81996-12-06 21:18:18 +00002136 hp*|HP*)
Martin v. Löwis1142de32002-03-29 16:28:31 +00002137 LINKFORSHARED="-Wl,-E -Wl,+s";;
2138# LINKFORSHARED="-Wl,-E -Wl,+s -Wl,+b\$(BINLIBDEST)/lib-dynload";;
Guido van Rossumf5957ea1999-10-05 21:59:33 +00002139 BSD/OS/4*) LINKFORSHARED="-Xlinker -export-dynamic";;
Martin v. Löwisa6e97582002-01-01 18:41:33 +00002140 Linux*|GNU*) LINKFORSHARED="-Xlinker -export-dynamic";;
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00002141 # -u libsys_s pulls in all symbols in libsys
Jack Jansenb6e9cad2001-08-15 01:26:28 +00002142 Darwin/*)
Raymond Hettingerec6eb362004-11-05 07:02:59 +00002143 # -u _PyMac_Error is needed to pull in the mac toolbox glue,
2144 # which is
Jack Jansenb6e9cad2001-08-15 01:26:28 +00002145 # not used by the core itself but which needs to be in the core so
2146 # that dynamically loaded extension modules have access to it.
Jack Jansen97e3f002003-02-23 22:59:01 +00002147 # -prebind is no longer used, because it actually seems to give a
2148 # slowdown in stead of a speedup, maybe due to the large number of
2149 # dynamic loads Python does.
Raymond Hettingerec6eb362004-11-05 07:02:59 +00002150
2151 LINKFORSHARED="$extra_undefs"
Jack Jansenb6e9cad2001-08-15 01:26:28 +00002152 if test "$enable_framework"
2153 then
Jack Jansenda49e192005-01-07 13:08:22 +00002154 LINKFORSHARED="$LINKFORSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansenb6e9cad2001-08-15 01:26:28 +00002155 fi
Raymond Hettingerec6eb362004-11-05 07:02:59 +00002156 LINKFORSHARED="$LINKFORSHARED";;
Martin v. Löwis25ae43b2001-10-07 08:39:18 +00002157 OpenUNIX*|UnixWare*) LINKFORSHARED="-Wl,-Bexport";;
Martin v. Löwis21ee4092002-09-30 16:19:48 +00002158 SCO_SV*) LINKFORSHARED="-Wl,-Bexport";;
Fred Drake02706f52000-09-25 15:08:46 +00002159 ReliantUNIX*) LINKFORSHARED="-W1 -Blargedynsym";;
Martin v. Löwis86d66262006-02-17 08:40:11 +00002160 FreeBSD*|NetBSD*|OpenBSD*|DragonFly*)
Guido van Rossumdf693651999-01-07 21:50:41 +00002161 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
2162 then
2163 LINKFORSHARED="-Wl,--export-dynamic"
2164 fi;;
Guido van Rossum2b5ca001998-03-05 15:41:09 +00002165 SunOS/5*) case $CC in
2166 *gcc*)
Martin v. Löwisa4548572002-04-18 14:51:36 +00002167 if $CC -Xlinker --help 2>&1 | grep export-dynamic >/dev/null
Guido van Rossum8f4ceb11997-12-18 23:42:19 +00002168 then
2169 LINKFORSHARED="-Xlinker --export-dynamic"
Guido van Rossum2b5ca001998-03-05 15:41:09 +00002170 fi;;
2171 esac;;
Jason Tishler30765592003-09-04 11:04:06 +00002172 CYGWIN*)
2173 if test $enable_shared = "no"
2174 then
2175 LINKFORSHARED='-Wl,--out-implib=$(LDLIBRARY)'
2176 fi;;
Martin v. Löwis8c255e42008-05-23 15:06:50 +00002177 QNX*)
2178 # -Wl,-E causes the symbols to be added to the dynamic
2179 # symbol table so that they can be found when a module
2180 # is loaded. -N 2048K causes the stack size to be set
2181 # to 2048 kilobytes so that the stack doesn't overflow
2182 # when running test_compile.py.
2183 LINKFORSHARED='-Wl,-E -N 2048K';;
Guido van Rossumac405f61994-09-12 10:56:06 +00002184 esac
Guido van Rossumac405f61994-09-12 10:56:06 +00002185fi
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002186AC_MSG_RESULT($LINKFORSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00002187
Ronald Oussoren0d236eb2008-06-06 21:31:33 +00002188
Neil Schemenauer61c51152001-01-26 16:18:16 +00002189AC_SUBST(CFLAGSFORSHARED)
2190AC_MSG_CHECKING(CFLAGSFORSHARED)
2191if test ! "$LIBRARY" = "$LDLIBRARY"
2192then
Neil Schemenauerd9cf41c2001-01-27 21:39:17 +00002193 case $ac_sys_system in
2194 CYGWIN*)
2195 # Cygwin needs CCSHARED when building extension DLLs
2196 # but not when building the interpreter DLL.
2197 CFLAGSFORSHARED='';;
2198 *)
2199 CFLAGSFORSHARED='$(CCSHARED)'
2200 esac
Neil Schemenauer61c51152001-01-26 16:18:16 +00002201fi
2202AC_MSG_RESULT($CFLAGSFORSHARED)
2203
Martin v. Löwisf90ae202002-06-11 06:22:31 +00002204# SHLIBS are libraries (except -lc and -lm) to link to the python shared
2205# library (with --enable-shared).
2206# For platforms on which shared libraries are not allowed to have unresolved
Martin v. Löwisd6359c52002-08-04 12:38:50 +00002207# symbols, this must be set to $(LIBS) (expanded by make). We do this even
2208# if it is not required, since it creates a dependency of the shared library
2209# to LIBS. This, in turn, means that applications linking the shared libpython
2210# don't need to link LIBS explicitly. The default should be only changed
2211# on systems where this approach causes problems.
Martin v. Löwisf90ae202002-06-11 06:22:31 +00002212AC_SUBST(SHLIBS)
2213AC_MSG_CHECKING(SHLIBS)
2214case "$ac_sys_system" in
Martin v. Löwisf90ae202002-06-11 06:22:31 +00002215 *)
Martin v. Löwisd6359c52002-08-04 12:38:50 +00002216 SHLIBS='$(LIBS)';;
Martin v. Löwisf90ae202002-06-11 06:22:31 +00002217esac
2218AC_MSG_RESULT($SHLIBS)
2219
2220
Guido van Rossum627b2d71993-12-24 10:39:16 +00002221# checks for libraries
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002222AC_CHECK_LIB(dl, dlopen) # Dynamic linking for SunOS/Solaris and SYSV
2223AC_CHECK_LIB(dld, shl_load) # Dynamic linking for HP-UX
Martin v. Löwis519adae2003-09-20 10:47:47 +00002224
Skip Montanaro4d756af2008-12-01 01:55:22 +00002225# only check for sem_init if thread support is requested
Martin v. Löwis519adae2003-09-20 10:47:47 +00002226if test "$with_threads" = "yes" -o -z "$with_threads"; then
2227 AC_SEARCH_LIBS(sem_init, pthread rt posix4) # 'Real Time' functions on Solaris
2228 # posix4 on Solaris 2.6
2229 # pthread (first!) on Linux
2230fi
2231
Martin v. Löwis19d17342003-06-14 21:03:05 +00002232# check if we need libintl for locale functions
2233AC_CHECK_LIB(intl, textdomain,
2234 AC_DEFINE(WITH_LIBINTL, 1,
2235 [Define to 1 if libintl is needed for locale functions.]))
Guido van Rossum0eefa3f1999-11-16 15:57:37 +00002236
2237# checks for system dependent C++ extensions support
2238case "$ac_sys_system" in
2239 AIX*) AC_MSG_CHECKING(for genuine AIX C++ extensions support)
Matthias Klosec511b472010-05-08 11:01:39 +00002240 AC_LINK_IFELSE([
Georg Brandl94800df2011-02-25 11:09:02 +00002241 AC_LANG_PROGRAM([[#include <load.h>]],
Matthias Klosec511b472010-05-08 11:01:39 +00002242 [[loadAndInit("", 0, "")]])
2243 ],[
2244 AC_DEFINE(AIX_GENUINE_CPLUSPLUS, 1,
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002245 [Define for AIX if your compiler is a genuine IBM xlC/xlC_r
2246 and you want support for AIX C++ shared extension modules.])
Matthias Klosec511b472010-05-08 11:01:39 +00002247 AC_MSG_RESULT(yes)
2248 ],[
2249 AC_MSG_RESULT(no)
2250 ]);;
Guido van Rossum0eefa3f1999-11-16 15:57:37 +00002251 *) ;;
2252esac
2253
Guido van Rossum70c7f481998-03-26 18:44:10 +00002254# Most SVR4 platforms (e.g. Solaris) need -lsocket and -lnsl.
Guido van Rossumec95c7b1998-08-04 17:59:56 +00002255# BeOS' sockets are stashed in libnet.
Guido van Rossumf618d2c1995-01-17 16:36:13 +00002256AC_CHECK_LIB(nsl, t_open, [LIBS="-lnsl $LIBS"]) # SVR4
Guido van Rossumf618d2c1995-01-17 16:36:13 +00002257AC_CHECK_LIB(socket, socket, [LIBS="-lsocket $LIBS"], [], $LIBS) # SVR4 sockets
Skip Montanarob9949db2004-01-17 04:04:13 +00002258
Jeremy Hyltoncb25d5e2000-07-27 21:23:28 +00002259case "$ac_sys_system" in
2260BeOS*)
Guido van Rossumec95c7b1998-08-04 17:59:56 +00002261AC_CHECK_LIB(net, socket, [LIBS="-lnet $LIBS"], [], $LIBS) # BeOS
2262;;
2263esac
Guido van Rossum70c7f481998-03-26 18:44:10 +00002264
Guido van Rossumc5a39031996-07-31 17:35:03 +00002265AC_MSG_CHECKING(for --with-libs)
Barry Warsawc0d24d82000-06-29 16:12:00 +00002266AC_ARG_WITH(libs,
Matthias Klose22520ea2010-05-08 10:14:46 +00002267 AS_HELP_STRING([--with-libs='lib1 ...'], [link against additional libs]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002268[
Guido van Rossumc5a39031996-07-31 17:35:03 +00002269AC_MSG_RESULT($withval)
2270LIBS="$withval $LIBS"
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002271],
2272[AC_MSG_RESULT(no)])
Guido van Rossum627b2d71993-12-24 10:39:16 +00002273
Benjamin Petersone9e07bf2010-03-09 21:46:54 +00002274AC_PATH_TOOL([PKG_CONFIG], [pkg-config])
2275
Benjamin Peterson2c196742009-12-31 03:17:18 +00002276# Check for use of the system expat library
2277AC_MSG_CHECKING(for --with-system-expat)
2278AC_ARG_WITH(system_expat,
Benjamin Petersonf2d1b2a2010-10-31 16:53:53 +00002279 AS_HELP_STRING([--with-system-expat], [build pyexpat module using an installed expat library]),
2280 [],
2281 [with_system_expat="no"])
Benjamin Peterson2c196742009-12-31 03:17:18 +00002282
2283AC_MSG_RESULT($with_system_expat)
2284
Martin v. Löwis9176fc12006-04-11 11:12:43 +00002285# Check for use of the system libffi library
2286AC_MSG_CHECKING(for --with-system-ffi)
2287AC_ARG_WITH(system_ffi,
Benjamin Petersonf2d1b2a2010-10-31 16:53:53 +00002288 AS_HELP_STRING([--with-system-ffi], [build _ctypes module using an installed ffi library]),
2289 [],
2290 [with_system_ffi="no"])
Martin v. Löwis9176fc12006-04-11 11:12:43 +00002291
Benjamin Petersone9e07bf2010-03-09 21:46:54 +00002292if test "$with_system_ffi" = "yes" && test -n "$PKG_CONFIG"; then
Benjamin Peterson1c335e62010-01-01 15:16:29 +00002293 LIBFFI_INCLUDEDIR="`"$PKG_CONFIG" libffi --cflags-only-I 2>/dev/null | sed -e 's/^-I//;s/ *$//'`"
2294else
2295 LIBFFI_INCLUDEDIR=""
2296fi
2297AC_SUBST(LIBFFI_INCLUDEDIR)
2298
Martin v. Löwis9176fc12006-04-11 11:12:43 +00002299AC_MSG_RESULT($with_system_ffi)
2300
Ned Deilya2a9f572013-10-25 00:30:10 -07002301# Check for --with-tcltk-includes=path and --with-tcltk-libs=path
2302AC_SUBST(TCLTK_INCLUDES)
2303AC_SUBST(TCLTK_LIBS)
2304AC_MSG_CHECKING(for --with-tcltk-includes)
2305AC_ARG_WITH(tcltk-includes,
2306 AS_HELP_STRING([--with-tcltk-includes='-I...'], [override search for Tcl and Tk include files]),
2307 [],
2308 [with_tcltk_includes="default"])
2309AC_MSG_RESULT($with_tcltk_includes)
2310AC_MSG_CHECKING(for --with-tcltk-libs)
2311AC_ARG_WITH(tcltk-libs,
2312 AS_HELP_STRING([--with-tcltk-libs='-L...'], [override search for Tcl and Tk libs]),
2313 [],
2314 [with_tcltk_libs="default"])
2315AC_MSG_RESULT($with_tcltk_libs)
2316if test "x$with_tcltk_includes" = xdefault || test "x$with_tcltk_libs" = xdefault
2317then
2318 if test "x$with_tcltk_includes" != "x$with_tcltk_libs"
2319 then
2320 AC_MSG_ERROR([use both --with-tcltk-includes='...' and --with-tcltk-libs='...' or neither])
2321 fi
2322 TCLTK_INCLUDES=""
2323 TCLTK_LIBS=""
2324else
2325 TCLTK_INCLUDES="$with_tcltk_includes"
2326 TCLTK_LIBS="$with_tcltk_libs"
2327fi
2328
Matthias Klose10cbe482009-04-29 17:18:19 +00002329# Check for --with-dbmliborder
2330AC_MSG_CHECKING(for --with-dbmliborder)
2331AC_ARG_WITH(dbmliborder,
Matthias Klose22520ea2010-05-08 10:14:46 +00002332 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 +00002333[
2334if test x$with_dbmliborder = xyes
2335then
2336AC_MSG_ERROR([proper usage is --with-dbmliborder=db1:db2:...])
2337else
2338 for db in `echo $with_dbmliborder | sed 's/:/ /g'`; do
2339 if test x$db != xndbm && test x$db != xgdbm && test x$db != xbdb
2340 then
2341 AC_MSG_ERROR([proper usage is --with-dbmliborder=db1:db2:...])
2342 fi
2343 done
Matthias Klose61dbdb92009-04-29 20:09:50 +00002344fi])
2345AC_MSG_RESULT($with_dbmliborder)
Matthias Klose10cbe482009-04-29 17:18:19 +00002346
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00002347# Determine if signalmodule should be used.
2348AC_SUBST(USE_SIGNAL_MODULE)
2349AC_SUBST(SIGNAL_OBJS)
2350AC_MSG_CHECKING(for --with-signal-module)
2351AC_ARG_WITH(signal-module,
Matthias Klose22520ea2010-05-08 10:14:46 +00002352 AS_HELP_STRING([--with-signal-module], [disable/enable signal module]))
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00002353
2354if test -z "$with_signal_module"
2355then with_signal_module="yes"
2356fi
2357AC_MSG_RESULT($with_signal_module)
2358
2359if test "${with_signal_module}" = "yes"; then
2360 USE_SIGNAL_MODULE=""
2361 SIGNAL_OBJS=""
2362else
2363 USE_SIGNAL_MODULE="#"
2364 SIGNAL_OBJS="Parser/intrcheck.o Python/sigcheck.o"
2365fi
2366
Guido van Rossum3d15bd82001-01-10 18:53:48 +00002367# This is used to generate Setup.config
Guido van Rossum009f7871997-12-04 00:51:42 +00002368AC_SUBST(USE_THREAD_MODULE)
Barry Warsawc0d24d82000-06-29 16:12:00 +00002369USE_THREAD_MODULE=""
Guido van Rossum009f7871997-12-04 00:51:42 +00002370
Guido van Rossum54d93d41997-01-22 20:51:58 +00002371AC_MSG_CHECKING(for --with-dec-threads)
2372AC_SUBST(LDLAST)
2373AC_ARG_WITH(dec-threads,
Matthias Klose22520ea2010-05-08 10:14:46 +00002374 AS_HELP_STRING([--with-dec-threads], [use DEC Alpha/OSF1 thread-safe libraries]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002375[
Barry Warsawc0d24d82000-06-29 16:12:00 +00002376AC_MSG_RESULT($withval)
Guido van Rossum54d93d41997-01-22 20:51:58 +00002377LDLAST=-threads
Guido van Rossumf78abae1997-01-21 22:02:36 +00002378if test "${with_thread+set}" != set; then
Guido van Rossum54d93d41997-01-22 20:51:58 +00002379 with_thread="$withval";
2380fi],
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002381[AC_MSG_RESULT(no)])
Guido van Rossum54d93d41997-01-22 20:51:58 +00002382
Martin v. Löwis11437992002-04-12 09:54:03 +00002383# Templates for things AC_DEFINEd more than once.
2384# For a single AC_DEFINE, no template is needed.
2385AH_TEMPLATE(C_THREADS,[Define if you have the Mach cthreads package])
2386AH_TEMPLATE(_REENTRANT,
2387 [Define to force use of thread-safe errno, h_errno, and other functions])
2388AH_TEMPLATE(WITH_THREAD,
2389 [Define if you want to compile in rudimentary thread support])
2390
Guido van Rossum54d93d41997-01-22 20:51:58 +00002391AC_MSG_CHECKING(for --with-threads)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002392dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
Barry Warsawc0d24d82000-06-29 16:12:00 +00002393AC_ARG_WITH(threads,
Matthias Klose22520ea2010-05-08 10:14:46 +00002394 AS_HELP_STRING([--with(out)-threads@<:@=DIRECTORY@:>@], [disable/enable thread support]))
Guido van Rossum54d93d41997-01-22 20:51:58 +00002395
Barry Warsawc0d24d82000-06-29 16:12:00 +00002396# --with-thread is deprecated, but check for it anyway
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002397dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
Barry Warsawa0f3c5c2000-06-30 16:39:35 +00002398AC_ARG_WITH(thread,
Matthias Klose22520ea2010-05-08 10:14:46 +00002399 AS_HELP_STRING([--with(out)-thread@<:@=DIRECTORY@:>@], [deprecated; use --with(out)-threads]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002400 [with_threads=$with_thread])
Barry Warsawc0d24d82000-06-29 16:12:00 +00002401
2402if test -z "$with_threads"
2403then with_threads="yes"
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002404fi
Barry Warsawc0d24d82000-06-29 16:12:00 +00002405AC_MSG_RESULT($with_threads)
Guido van Rossum6400c261997-05-22 20:34:27 +00002406
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002407AC_SUBST(THREADOBJ)
Barry Warsawc0d24d82000-06-29 16:12:00 +00002408if test "$with_threads" = "no"
2409then
2410 USE_THREAD_MODULE="#"
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002411elif test "$ac_cv_pthread_is_default" = yes
2412then
2413 AC_DEFINE(WITH_THREAD)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002414 # Defining _REENTRANT on system with POSIX threads should not hurt.
2415 AC_DEFINE(_REENTRANT)
2416 posix_threads=yes
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002417 THREADOBJ="Python/thread.o"
Martin v. Löwis130fb172001-07-19 11:00:41 +00002418elif test "$ac_cv_kpthread" = "yes"
2419then
2420 CC="$CC -Kpthread"
Martin v. Löwis519adae2003-09-20 10:47:47 +00002421 if test "$ac_cv_cxx_thread" = "yes"; then
2422 CXX="$CXX -Kpthread"
2423 fi
Martin v. Löwis130fb172001-07-19 11:00:41 +00002424 AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002425 posix_threads=yes
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002426 THREADOBJ="Python/thread.o"
Martin v. Löwis5f433f02003-05-05 05:05:30 +00002427elif test "$ac_cv_kthread" = "yes"
2428then
2429 CC="$CC -Kthread"
Martin v. Löwis519adae2003-09-20 10:47:47 +00002430 if test "$ac_cv_cxx_thread" = "yes"; then
2431 CXX="$CXX -Kthread"
2432 fi
Martin v. Löwis5f433f02003-05-05 05:05:30 +00002433 AC_DEFINE(WITH_THREAD)
2434 posix_threads=yes
2435 THREADOBJ="Python/thread.o"
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002436elif test "$ac_cv_pthread" = "yes"
2437then
2438 CC="$CC -pthread"
Martin v. Löwis519adae2003-09-20 10:47:47 +00002439 if test "$ac_cv_cxx_thread" = "yes"; then
2440 CXX="$CXX -pthread"
2441 fi
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002442 AC_DEFINE(WITH_THREAD)
2443 posix_threads=yes
2444 THREADOBJ="Python/thread.o"
Barry Warsawc0d24d82000-06-29 16:12:00 +00002445else
Martin v. Löwis130fb172001-07-19 11:00:41 +00002446 if test ! -z "$with_threads" -a -d "$with_threads"
2447 then LDFLAGS="$LDFLAGS -L$with_threads"
2448 fi
2449 if test ! -z "$withval" -a -d "$withval"
2450 then LDFLAGS="$LDFLAGS -L$withval"
2451 fi
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002452
2453 # According to the POSIX spec, a pthreads implementation must
Matthias Klosea2542be2004-08-16 11:35:51 +00002454 # define _POSIX_THREADS in unistd.h. Some apparently don't
2455 # (e.g. gnu pth with pthread emulation)
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002456 AC_MSG_CHECKING(for _POSIX_THREADS in unistd.h)
2457 AC_EGREP_CPP(yes,
Neal Norwitz6eb37f02003-02-23 23:28:15 +00002458 [
2459#include <unistd.h>
2460#ifdef _POSIX_THREADS
2461yes
2462#endif
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002463 ], unistd_defines_pthreads=yes, unistd_defines_pthreads=no)
2464 AC_MSG_RESULT($unistd_defines_pthreads)
2465
Martin v. Löwis130fb172001-07-19 11:00:41 +00002466 AC_DEFINE(_REENTRANT)
Martin v. Löwisa6e97582002-01-01 18:41:33 +00002467 AC_CHECK_HEADER(cthreads.h, [AC_DEFINE(WITH_THREAD)
2468 AC_DEFINE(C_THREADS)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002469 AC_DEFINE(HURD_C_THREADS, 1,
2470 [Define if you are using Mach cthreads directly under /include])
Martin v. Löwisa6e97582002-01-01 18:41:33 +00002471 LIBS="$LIBS -lthreads"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002472 THREADOBJ="Python/thread.o"],[
Martin v. Löwis130fb172001-07-19 11:00:41 +00002473 AC_CHECK_HEADER(mach/cthreads.h, [AC_DEFINE(WITH_THREAD)
2474 AC_DEFINE(C_THREADS)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002475 AC_DEFINE(MACH_C_THREADS, 1,
2476 [Define if you are using Mach cthreads under mach /])
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002477 THREADOBJ="Python/thread.o"],[
Martin v. Löwis130fb172001-07-19 11:00:41 +00002478 AC_MSG_CHECKING(for --with-pth)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002479 AC_ARG_WITH([pth],
Matthias Klose22520ea2010-05-08 10:14:46 +00002480 AS_HELP_STRING([--with-pth], [use GNU pth threading libraries]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002481 [AC_MSG_RESULT($withval)
2482 AC_DEFINE([WITH_THREAD])
2483 AC_DEFINE([HAVE_PTH], 1,
2484 [Define if you have GNU PTH threads.])
2485 LIBS="-lpth $LIBS"
2486 THREADOBJ="Python/thread.o"],
2487 [AC_MSG_RESULT(no)
Martin v. Löwis8158b5a2001-10-08 13:17:28 +00002488
2489 # Just looking for pthread_create in libpthread is not enough:
2490 # on HP/UX, pthread.h renames pthread_create to a different symbol name.
2491 # So we really have to include pthread.h, and then link.
2492 _libs=$LIBS
2493 LIBS="$LIBS -lpthread"
2494 AC_MSG_CHECKING([for pthread_create in -lpthread])
Stefan Krahae66ca62012-11-22 22:36:57 +01002495 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
2496#include <stdio.h>
2497#include <pthread.h>
Martin v. Löwis8158b5a2001-10-08 13:17:28 +00002498
Matthias Klosec511b472010-05-08 11:01:39 +00002499void * start_routine (void *arg) { exit (0); }]], [[
2500pthread_create (NULL, NULL, start_routine, NULL)]])],[
Martin v. Löwis8158b5a2001-10-08 13:17:28 +00002501 AC_MSG_RESULT(yes)
2502 AC_DEFINE(WITH_THREAD)
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002503 posix_threads=yes
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002504 THREADOBJ="Python/thread.o"],[
Martin v. Löwis8158b5a2001-10-08 13:17:28 +00002505 LIBS=$_libs
Martin v. Löwis130fb172001-07-19 11:00:41 +00002506 AC_CHECK_FUNC(pthread_detach, [AC_DEFINE(WITH_THREAD)
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002507 posix_threads=yes
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002508 THREADOBJ="Python/thread.o"],[
Martin v. Löwisf90ae202002-06-11 06:22:31 +00002509 AC_CHECK_HEADER(atheos/threads.h, [AC_DEFINE(WITH_THREAD)
2510 AC_DEFINE(ATHEOS_THREADS, 1,
2511 [Define this if you have AtheOS threads.])
2512 THREADOBJ="Python/thread.o"],[
Martin v. Löwis130fb172001-07-19 11:00:41 +00002513 AC_CHECK_HEADER(kernel/OS.h, [AC_DEFINE(WITH_THREAD)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002514 AC_DEFINE(BEOS_THREADS, 1,
2515 [Define this if you have BeOS threads.])
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002516 THREADOBJ="Python/thread.o"],[
Martin v. Löwis130fb172001-07-19 11:00:41 +00002517 AC_CHECK_LIB(pthreads, pthread_create, [AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002518 posix_threads=yes
Martin v. Löwis130fb172001-07-19 11:00:41 +00002519 LIBS="$LIBS -lpthreads"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002520 THREADOBJ="Python/thread.o"], [
Martin v. Löwis130fb172001-07-19 11:00:41 +00002521 AC_CHECK_LIB(c_r, pthread_create, [AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002522 posix_threads=yes
Martin v. Löwis130fb172001-07-19 11:00:41 +00002523 LIBS="$LIBS -lc_r"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002524 THREADOBJ="Python/thread.o"], [
Martin v. Löwis130fb172001-07-19 11:00:41 +00002525 AC_CHECK_LIB(pthread, __pthread_create_system, [AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002526 posix_threads=yes
Martin v. Löwis130fb172001-07-19 11:00:41 +00002527 LIBS="$LIBS -lpthread"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002528 THREADOBJ="Python/thread.o"], [
Martin v. Löwis130fb172001-07-19 11:00:41 +00002529 AC_CHECK_LIB(cma, pthread_create, [AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002530 posix_threads=yes
Martin v. Löwis130fb172001-07-19 11:00:41 +00002531 LIBS="$LIBS -lcma"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002532 THREADOBJ="Python/thread.o"],[
Martin v. Löwis130fb172001-07-19 11:00:41 +00002533 USE_THREAD_MODULE="#"])
Skip Montanarof8712e52004-01-17 03:04:46 +00002534 ])])])])])])])])])])
Barry Warsawc0d24d82000-06-29 16:12:00 +00002535
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002536 AC_CHECK_LIB(mpc, usconfig, [AC_DEFINE(WITH_THREAD)
2537 LIBS="$LIBS -lmpc"
2538 THREADOBJ="Python/thread.o"
2539 USE_THREAD_MODULE=""])
2540
2541 if test "$posix_threads" != "yes"; then
2542 AC_CHECK_LIB(thread, thr_create, [AC_DEFINE(WITH_THREAD)
2543 LIBS="$LIBS -lthread"
2544 THREADOBJ="Python/thread.o"
2545 USE_THREAD_MODULE=""])
2546 fi
2547
2548 if test "$USE_THREAD_MODULE" != "#"
2549 then
2550 # If the above checks didn't disable threads, (at least) OSF1
2551 # needs this '-threads' argument during linking.
2552 case $ac_sys_system in
2553 OSF1) LDLAST=-threads;;
2554 esac
2555 fi
2556fi
2557
2558if test "$posix_threads" = "yes"; then
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002559 if test "$unistd_defines_pthreads" = "no"; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002560 AC_DEFINE(_POSIX_THREADS, 1,
2561 [Define if you have POSIX threads,
2562 and your system does not define that.])
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002563 fi
2564
Martin v. Löwisdfc33fd2003-01-21 10:14:41 +00002565 # Bug 662787: Using semaphores causes unexplicable hangs on Solaris 8.
2566 case $ac_sys_system/$ac_sys_release in
Charles-François Natali4929eb92011-07-21 19:41:04 +02002567 SunOS/5.6) AC_DEFINE(HAVE_PTHREAD_DESTRUCTOR, 1,
Matthias Klose5183ebd2010-04-24 16:38:36 +00002568 [Defined for Solaris 2.6 bug in pthread header.])
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002569 ;;
Martin v. Löwisdfc33fd2003-01-21 10:14:41 +00002570 SunOS/5.8) AC_DEFINE(HAVE_BROKEN_POSIX_SEMAPHORES, 1,
Matthias Klose5183ebd2010-04-24 16:38:36 +00002571 [Define if the Posix semaphores do not work on your system])
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002572 ;;
Charles-François Natali4929eb92011-07-21 19:41:04 +02002573 AIX/*) AC_DEFINE(HAVE_BROKEN_POSIX_SEMAPHORES, 1,
Matthias Klose5183ebd2010-04-24 16:38:36 +00002574 [Define if the Posix semaphores do not work on your system])
Christian Heimescba36bb2008-01-30 22:54:18 +00002575 ;;
Martin v. Löwisdfc33fd2003-01-21 10:14:41 +00002576 esac
2577
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002578 AC_MSG_CHECKING(if PTHREAD_SCOPE_SYSTEM is supported)
2579 AC_CACHE_VAL(ac_cv_pthread_system_supported,
Stefan Krahae66ca62012-11-22 22:36:57 +01002580 [AC_RUN_IFELSE([AC_LANG_SOURCE([[
2581 #include <stdio.h>
2582 #include <pthread.h>
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002583 void *foo(void *parm) {
2584 return NULL;
2585 }
2586 main() {
2587 pthread_attr_t attr;
Martin v. Löwisa82d3472002-02-24 16:05:05 +00002588 pthread_t id;
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002589 if (pthread_attr_init(&attr)) exit(-1);
2590 if (pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM)) exit(-1);
Martin v. Löwisa82d3472002-02-24 16:05:05 +00002591 if (pthread_create(&id, &attr, foo, NULL)) exit(-1);
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002592 exit(0);
Matthias Klosec511b472010-05-08 11:01:39 +00002593 }]])],
2594 [ac_cv_pthread_system_supported=yes],
2595 [ac_cv_pthread_system_supported=no],
2596 [ac_cv_pthread_system_supported=no])
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002597 ])
2598 AC_MSG_RESULT($ac_cv_pthread_system_supported)
2599 if test "$ac_cv_pthread_system_supported" = "yes"; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002600 AC_DEFINE(PTHREAD_SYSTEM_SCHED_SUPPORTED, 1, [Defined if PTHREAD_SCOPE_SYSTEM supported.])
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002601 fi
Jason Tishlerfac083d2003-07-22 15:20:49 +00002602 AC_CHECK_FUNCS(pthread_sigmask,
2603 [case $ac_sys_system in
2604 CYGWIN*)
2605 AC_DEFINE(HAVE_BROKEN_PTHREAD_SIGMASK, 1,
2606 [Define if pthread_sigmask() does not work on your system.])
2607 ;;
2608 esac])
Christian Heimes0d604cf2013-08-21 13:26:05 +02002609 AC_CHECK_FUNCS(pthread_atfork)
Barry Warsawc0d24d82000-06-29 16:12:00 +00002610fi
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002611
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002612
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002613# Check for enable-ipv6
Martin v. Löwis11437992002-04-12 09:54:03 +00002614AH_TEMPLATE(ENABLE_IPV6, [Define if --enable-ipv6 is specified])
Martin v. Löwisa5f8bb52001-09-05 08:22:34 +00002615AC_MSG_CHECKING([if --enable-ipv6 is specified])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002616AC_ARG_ENABLE(ipv6,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002617[ --enable-ipv6 Enable ipv6 (with ipv4) support
2618 --disable-ipv6 Disable ipv6 support],
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002619[ case "$enableval" in
2620 no)
2621 AC_MSG_RESULT(no)
2622 ipv6=no
2623 ;;
2624 *) AC_MSG_RESULT(yes)
2625 AC_DEFINE(ENABLE_IPV6)
2626 ipv6=yes
2627 ;;
2628 esac ],
2629
Martin v. Löwisa5f8bb52001-09-05 08:22:34 +00002630[
2631dnl the check does not work on cross compilation case...
Charles-François Natalibe2b9072013-01-08 19:47:00 +01002632 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ /* AF_INET6 available check */
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002633#include <sys/types.h>
Charles-François Natalibe2b9072013-01-08 19:47:00 +01002634#include <sys/socket.h>]],
2635[[int domain = AF_INET6;]])],[
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002636 AC_MSG_RESULT(yes)
Matthias Klosec511b472010-05-08 11:01:39 +00002637 ipv6=yes
2638],[
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002639 AC_MSG_RESULT(no)
2640 ipv6=no
Matthias Klosec511b472010-05-08 11:01:39 +00002641])
Martin v. Löwisa5f8bb52001-09-05 08:22:34 +00002642
2643if test "$ipv6" = "yes"; then
2644 AC_MSG_CHECKING(if RFC2553 API is available)
Matthias Klosec511b472010-05-08 11:01:39 +00002645 AC_COMPILE_IFELSE([
2646 AC_LANG_PROGRAM([[#include <sys/types.h>
2647#include <netinet/in.h>]],
2648 [[struct sockaddr_in6 x;
2649 x.sin6_scope_id;]])
2650 ],[
2651 AC_MSG_RESULT(yes)
2652 ipv6=yes
2653 ],[
2654 AC_MSG_RESULT(no, IPv6 disabled)
2655 ipv6=no
2656 ])
Martin v. Löwisa5f8bb52001-09-05 08:22:34 +00002657fi
2658
2659if test "$ipv6" = "yes"; then
2660 AC_DEFINE(ENABLE_IPV6)
2661fi
2662])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002663
2664ipv6type=unknown
2665ipv6lib=none
2666ipv6trylibc=no
2667
2668if test "$ipv6" = "yes"; then
2669 AC_MSG_CHECKING([ipv6 stack type])
Guido van Rossumb8552162001-09-05 14:58:11 +00002670 for i in inria kame linux-glibc linux-inet6 solaris toshiba v6d zeta;
2671 do
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002672 case $i in
2673 inria)
2674 dnl http://www.kame.net/
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002675 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002676#include <netinet/in.h>
2677#ifdef IPV6_INRIA_VERSION
2678yes
2679#endif],
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002680 [ipv6type=$i])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002681 ;;
2682 kame)
2683 dnl http://www.kame.net/
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 <netinet/in.h>
2686#ifdef __KAME__
2687yes
2688#endif],
2689 [ipv6type=$i;
2690 ipv6lib=inet6
2691 ipv6libdir=/usr/local/v6/lib
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002692 ipv6trylibc=yes])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002693 ;;
2694 linux-glibc)
2695 dnl http://www.v6.linux.or.jp/
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002696 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002697#include <features.h>
2698#if defined(__GLIBC__) && ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1) || (__GLIBC__ > 2))
2699yes
2700#endif],
2701 [ipv6type=$i;
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002702 ipv6trylibc=yes])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002703 ;;
2704 linux-inet6)
2705 dnl http://www.v6.linux.or.jp/
2706 if test -d /usr/inet6; then
2707 ipv6type=$i
2708 ipv6lib=inet6
2709 ipv6libdir=/usr/inet6/lib
Skip Montanarodecc6a42003-01-01 20:07:49 +00002710 BASECFLAGS="-I/usr/inet6/include $BASECFLAGS"
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002711 fi
2712 ;;
2713 solaris)
2714 if test -f /etc/netconfig; then
Antoine Pitrou31e85952011-01-03 18:57:14 +00002715 if $GREP -q tcp6 /etc/netconfig; then
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002716 ipv6type=$i
2717 ipv6trylibc=yes
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002718 fi
2719 fi
2720 ;;
2721 toshiba)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002722 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002723#include <sys/param.h>
2724#ifdef _TOSHIBA_INET6
2725yes
2726#endif],
2727 [ipv6type=$i;
2728 ipv6lib=inet6;
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002729 ipv6libdir=/usr/local/v6/lib])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002730 ;;
2731 v6d)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002732 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002733#include </usr/local/v6/include/sys/v6config.h>
2734#ifdef __V6D__
2735yes
2736#endif],
2737 [ipv6type=$i;
2738 ipv6lib=v6;
2739 ipv6libdir=/usr/local/v6/lib;
Skip Montanarodecc6a42003-01-01 20:07:49 +00002740 BASECFLAGS="-I/usr/local/v6/include $BASECFLAGS"])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002741 ;;
2742 zeta)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002743 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002744#include <sys/param.h>
2745#ifdef _ZETA_MINAMI_INET6
2746yes
2747#endif],
2748 [ipv6type=$i;
2749 ipv6lib=inet6;
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002750 ipv6libdir=/usr/local/v6/lib])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002751 ;;
2752 esac
2753 if test "$ipv6type" != "unknown"; then
2754 break
2755 fi
2756 done
2757 AC_MSG_RESULT($ipv6type)
2758fi
2759
2760if test "$ipv6" = "yes" -a "$ipv6lib" != "none"; then
2761 if test -d $ipv6libdir -a -f $ipv6libdir/lib$ipv6lib.a; then
2762 LIBS="-L$ipv6libdir -l$ipv6lib $LIBS"
2763 echo "using lib$ipv6lib"
2764 else
2765 if test $ipv6trylibc = "yes"; then
2766 echo "using libc"
2767 else
2768 echo 'Fatal: no $ipv6lib library found. cannot continue.'
2769 echo "You need to fetch lib$ipv6lib.a from appropriate"
2770 echo 'ipv6 kit and compile beforehand.'
2771 exit 1
2772 fi
2773 fi
2774fi
2775
Ronald Oussoren0d236eb2008-06-06 21:31:33 +00002776AC_MSG_CHECKING(for OSX 10.5 SDK or later)
Matthias Klosec511b472010-05-08 11:01:39 +00002777AC_COMPILE_IFELSE([
Mark Dickinson0712b562010-05-08 19:13:21 +00002778 AC_LANG_PROGRAM([[#include <Carbon/Carbon.h>]], [[FSIORefNum fRef = 0]])
Matthias Klosec511b472010-05-08 11:01:39 +00002779],[
Matthias Klose5183ebd2010-04-24 16:38:36 +00002780 AC_DEFINE(HAVE_OSX105_SDK, 1, [Define if compiling using MacOS X 10.5 SDK or later.])
Matthias Klosec511b472010-05-08 11:01:39 +00002781 AC_MSG_RESULT(yes)
2782],[
Ronald Oussoren0d236eb2008-06-06 21:31:33 +00002783 AC_MSG_RESULT(no)
Matthias Klosec511b472010-05-08 11:01:39 +00002784])
Ronald Oussoren0d236eb2008-06-06 21:31:33 +00002785
Martin v. Löwisa3fb4f72002-06-09 13:33:54 +00002786# Check for --with-doc-strings
2787AC_MSG_CHECKING(for --with-doc-strings)
2788AC_ARG_WITH(doc-strings,
Matthias Klose22520ea2010-05-08 10:14:46 +00002789 AS_HELP_STRING([--with(out)-doc-strings], [disable/enable documentation strings]))
Martin v. Löwisa3fb4f72002-06-09 13:33:54 +00002790
2791if test -z "$with_doc_strings"
2792then with_doc_strings="yes"
2793fi
2794if test "$with_doc_strings" != "no"
2795then
2796 AC_DEFINE(WITH_DOC_STRINGS, 1,
2797 [Define if you want documentation strings in extension modules])
2798fi
2799AC_MSG_RESULT($with_doc_strings)
2800
Neil Schemenauera35c6882001-02-27 04:45:05 +00002801# Check for Python-specific malloc support
Martin v. Löwisf30d60e2004-06-08 08:17:44 +00002802AC_MSG_CHECKING(for --with-tsc)
2803AC_ARG_WITH(tsc,
Matthias Klose22520ea2010-05-08 10:14:46 +00002804 AS_HELP_STRING([--with(out)-tsc],[enable/disable timestamp counter profile]),[
Martin v. Löwisf30d60e2004-06-08 08:17:44 +00002805if test "$withval" != no
2806then
2807 AC_DEFINE(WITH_TSC, 1,
2808 [Define to profile with the Pentium timestamp counter])
2809 AC_MSG_RESULT(yes)
2810else AC_MSG_RESULT(no)
2811fi],
2812[AC_MSG_RESULT(no)])
2813
2814# Check for Python-specific malloc support
Neil Schemenauera35c6882001-02-27 04:45:05 +00002815AC_MSG_CHECKING(for --with-pymalloc)
2816AC_ARG_WITH(pymalloc,
Matthias Klose22520ea2010-05-08 10:14:46 +00002817 AS_HELP_STRING([--with(out)-pymalloc], [disable/enable specialized mallocs]))
Neil Schemenauer16c22972002-03-22 15:34:49 +00002818
2819if test -z "$with_pymalloc"
2820then with_pymalloc="yes"
2821fi
2822if test "$with_pymalloc" != "no"
2823then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002824 AC_DEFINE(WITH_PYMALLOC, 1,
2825 [Define if you want to compile in Python-specific mallocs])
Neil Schemenauer16c22972002-03-22 15:34:49 +00002826fi
2827AC_MSG_RESULT($with_pymalloc)
Neil Schemenauera35c6882001-02-27 04:45:05 +00002828
Benjamin Peterson91c12eb2009-12-03 02:52:39 +00002829# Check for Valgrind support
2830AC_MSG_CHECKING([for --with-valgrind])
2831AC_ARG_WITH([valgrind],
Matthias Klose22520ea2010-05-08 10:14:46 +00002832 AS_HELP_STRING([--with-valgrind], [Enable Valgrind support]),,
Benjamin Peterson91c12eb2009-12-03 02:52:39 +00002833 with_valgrind=no)
2834AC_MSG_RESULT([$with_valgrind])
2835if test "$with_valgrind" != no; then
2836 AC_CHECK_HEADER([valgrind/valgrind.h],
2837 [AC_DEFINE([WITH_VALGRIND], 1, [Define if you want pymalloc to be disabled when running under valgrind])],
2838 [AC_MSG_ERROR([Valgrind support requested but headers not available])]
2839 )
2840fi
2841
Barry Warsawef82cd72000-06-30 16:21:01 +00002842# Check for --with-wctype-functions
2843AC_MSG_CHECKING(for --with-wctype-functions)
2844AC_ARG_WITH(wctype-functions,
Matthias Klose22520ea2010-05-08 10:14:46 +00002845 AS_HELP_STRING([--with-wctype-functions], [use wctype.h functions]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002846[
Barry Warsawef82cd72000-06-30 16:21:01 +00002847if test "$withval" != no
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002848then
2849 AC_DEFINE(WANT_WCTYPE_FUNCTIONS, 1,
2850 [Define if you want wctype.h functions to be used instead of the
2851 one supplied by Python itself. (see Include/unicodectype.h).])
2852 AC_MSG_RESULT(yes)
Barry Warsawef82cd72000-06-30 16:21:01 +00002853else AC_MSG_RESULT(no)
2854fi],
2855[AC_MSG_RESULT(no)])
2856
Guido van Rossum68242b51996-05-28 22:53:03 +00002857# -I${DLINCLDIR} is added to the compile rule for importdl.o
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002858AC_SUBST(DLINCLDIR)
Guido van Rossum98935bf2001-09-05 19:13:16 +00002859DLINCLDIR=.
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002860
Guido van Rossume97ee181999-12-20 21:27:22 +00002861# the dlopen() function means we might want to use dynload_shlib.o. some
2862# platforms, such as AIX, have dlopen(), but don't want to use it.
Thomas Wouters3a584202000-08-05 23:28:51 +00002863AC_CHECK_FUNCS(dlopen)
Guido van Rossume97ee181999-12-20 21:27:22 +00002864
2865# DYNLOADFILE specifies which dynload_*.o file we will use for dynamic
2866# loading of modules.
2867AC_SUBST(DYNLOADFILE)
2868AC_MSG_CHECKING(DYNLOADFILE)
2869if test -z "$DYNLOADFILE"
2870then
2871 case $ac_sys_system/$ac_sys_release in
Martin v. Löwisc19c5a62003-11-18 20:00:44 +00002872 AIX*) # Use dynload_shlib.c and dlopen() if we have it; otherwise dynload_aix.c
2873 if test "$ac_cv_func_dlopen" = yes
2874 then DYNLOADFILE="dynload_shlib.o"
2875 else DYNLOADFILE="dynload_aix.o"
2876 fi
2877 ;;
Guido van Rossume97ee181999-12-20 21:27:22 +00002878 BeOS*) DYNLOADFILE="dynload_beos.o";;
2879 hp*|HP*) DYNLOADFILE="dynload_hpux.o";;
Anthony Baxter82201742006-04-09 15:07:40 +00002880 # Use dynload_next.c only on 10.2 and below, which don't have native dlopen()
2881 Darwin/@<:@0156@:>@\..*) DYNLOADFILE="dynload_next.o";;
Martin v. Löwisf90ae202002-06-11 06:22:31 +00002882 atheos*) DYNLOADFILE="dynload_atheos.o";;
Guido van Rossume97ee181999-12-20 21:27:22 +00002883 *)
2884 # use dynload_shlib.c and dlopen() if we have it; otherwise stub
2885 # out any dynamic loading
2886 if test "$ac_cv_func_dlopen" = yes
2887 then DYNLOADFILE="dynload_shlib.o"
2888 else DYNLOADFILE="dynload_stub.o"
2889 fi
2890 ;;
2891 esac
2892fi
2893AC_MSG_RESULT($DYNLOADFILE)
2894if test "$DYNLOADFILE" != "dynload_stub.o"
2895then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002896 AC_DEFINE(HAVE_DYNAMIC_LOADING, 1,
2897 [Defined when any dynamic module loading is enabled.])
Guido van Rossume97ee181999-12-20 21:27:22 +00002898fi
2899
Jack Jansenc49e5b72001-06-19 15:00:23 +00002900# MACHDEP_OBJS can be set to platform-specific object files needed by Python
2901
2902AC_SUBST(MACHDEP_OBJS)
2903AC_MSG_CHECKING(MACHDEP_OBJS)
2904if test -z "$MACHDEP_OBJS"
2905then
Jack Jansenb6e9cad2001-08-15 01:26:28 +00002906 MACHDEP_OBJS=$extra_machdep_objs
2907else
2908 MACHDEP_OBJS="$MACHDEP_OBJS $extra_machdep_objs"
Jack Jansenc49e5b72001-06-19 15:00:23 +00002909fi
Jack Jansenb6e9cad2001-08-15 01:26:28 +00002910AC_MSG_RESULT(MACHDEP_OBJS)
Jack Jansenc49e5b72001-06-19 15:00:23 +00002911
Guido van Rossum627b2d71993-12-24 10:39:16 +00002912# checks for library functions
Martin v. Löwisaef18b12008-03-24 13:31:16 +00002913AC_CHECK_FUNCS(alarm setitimer getitimer bind_textdomain_codeset chown \
2914 clock confstr ctermid execv fchmod fchown fork fpathconf ftime ftruncate \
Martin v. Löwis438b5342002-12-27 10:16:42 +00002915 gai_strerror getgroups getlogin getloadavg getpeername getpgid getpid \
Martin v. Löwis50ea4562009-11-27 13:56:01 +00002916 getpriority getresuid getresgid getpwent getspnam getspent getsid getwd \
Benjamin Petersond16e01c2014-02-04 10:20:26 -05002917 initgroups kill killpg lchmod lchown lstat mkfifo mknod mktime mmap \
Martin v. Löwisa5f09072002-10-11 05:37:59 +00002918 mremap nice pathconf pause plock poll pthread_init \
Guido van Rossum162e38c2003-02-19 15:25:10 +00002919 putenv readlink realpath \
Jesse Noller355b1262009-04-02 00:03:28 +00002920 select sem_open sem_timedwait sem_getvalue sem_unlink setegid seteuid \
2921 setgid \
Martin v. Löwis4daacb12003-03-28 18:37:01 +00002922 setlocale setregid setreuid setsid setpgid setpgrp setuid setvbuf snprintf \
Martin v. Löwis50ea4562009-11-27 13:56:01 +00002923 setlocale setregid setreuid setresuid setresgid \
2924 setsid setpgid setpgrp setuid setvbuf snprintf \
Skip Montanaro7e11a012004-02-07 12:55:46 +00002925 sigaction siginterrupt sigrelse strftime \
Michael W. Hudson34f20ea2002-05-27 15:08:24 +00002926 sysconf tcgetpgrp tcsetpgrp tempnam timegm times tmpfile tmpnam tmpnam_r \
Neal Norwitz05a45592006-03-20 06:30:08 +00002927 truncate uname unsetenv utimes waitpid wait3 wait4 wcscoll _getpty)
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00002928
Martin v. Löwisc8ad7cc2002-11-11 13:23:45 +00002929# For some functions, having a definition is not sufficient, since
2930# we want to take their address.
2931AC_MSG_CHECKING(for chroot)
Matthias Klosec511b472010-05-08 11:01:39 +00002932AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[void *x=chroot]])],
2933 [AC_DEFINE(HAVE_CHROOT, 1, Define if you have the 'chroot' function.)
2934 AC_MSG_RESULT(yes)],
2935 [AC_MSG_RESULT(no)
2936])
Martin v. Löwisc8ad7cc2002-11-11 13:23:45 +00002937AC_MSG_CHECKING(for link)
Matthias Klosec511b472010-05-08 11:01:39 +00002938AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[void *x=link]])],
2939 [AC_DEFINE(HAVE_LINK, 1, Define if you have the 'link' function.)
2940 AC_MSG_RESULT(yes)],
2941 [AC_MSG_RESULT(no)
2942])
Martin v. Löwisc8ad7cc2002-11-11 13:23:45 +00002943AC_MSG_CHECKING(for symlink)
Matthias Klosec511b472010-05-08 11:01:39 +00002944AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[void *x=symlink]])],
2945 [AC_DEFINE(HAVE_SYMLINK, 1, Define if you have the 'symlink' function.)
2946 AC_MSG_RESULT(yes)],
2947 [AC_MSG_RESULT(no)
2948])
Martin v. Löwisa64988c2003-09-20 15:30:20 +00002949AC_MSG_CHECKING(for fchdir)
Matthias Klosec511b472010-05-08 11:01:39 +00002950AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[void *x=fchdir]])],
2951 [AC_DEFINE(HAVE_FCHDIR, 1, Define if you have the 'fchdir' function.)
2952 AC_MSG_RESULT(yes)],
2953 [AC_MSG_RESULT(no)
2954])
Martin v. Löwisa64988c2003-09-20 15:30:20 +00002955AC_MSG_CHECKING(for fsync)
Matthias Klosec511b472010-05-08 11:01:39 +00002956AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[void *x=fsync]])],
2957 [AC_DEFINE(HAVE_FSYNC, 1, Define if you have the 'fsync' function.)
2958 AC_MSG_RESULT(yes)],
2959 [AC_MSG_RESULT(no)
2960])
Martin v. Löwisa64988c2003-09-20 15:30:20 +00002961AC_MSG_CHECKING(for fdatasync)
Matthias Klosec511b472010-05-08 11:01:39 +00002962AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[void *x=fdatasync]])],
2963 [AC_DEFINE(HAVE_FDATASYNC, 1, Define if you have the 'fdatasync' function.)
2964 AC_MSG_RESULT(yes)],
2965 [AC_MSG_RESULT(no)
2966])
Christian Heimes0e9ab5f2008-03-21 23:49:44 +00002967AC_MSG_CHECKING(for epoll)
Matthias Klosec511b472010-05-08 11:01:39 +00002968AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/epoll.h>]], [[void *x=epoll_create]])],
2969 [AC_DEFINE(HAVE_EPOLL, 1, Define if you have the 'epoll' functions.)
2970 AC_MSG_RESULT(yes)],
2971 [AC_MSG_RESULT(no)
2972])
Christian Heimes0e9ab5f2008-03-21 23:49:44 +00002973AC_MSG_CHECKING(for kqueue)
Matthias Klosec511b472010-05-08 11:01:39 +00002974AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Christian Heimes0e9ab5f2008-03-21 23:49:44 +00002975#include <sys/types.h>
2976#include <sys/event.h>
Matthias Klosec511b472010-05-08 11:01:39 +00002977 ]], [[int x=kqueue()]])],
2978 [AC_DEFINE(HAVE_KQUEUE, 1, Define if you have the 'kqueue' functions.)
2979 AC_MSG_RESULT(yes)],
2980 [AC_MSG_RESULT(no)
2981])
Martin v. Löwisd5843682002-11-21 20:41:28 +00002982# On some systems (eg. FreeBSD 5), we would find a definition of the
2983# functions ctermid_r, setgroups in the library, but no prototype
2984# (e.g. because we use _XOPEN_SOURCE). See whether we can take their
2985# address to avoid compiler warnings and potential miscompilations
2986# because of the missing prototypes.
2987
2988AC_MSG_CHECKING(for ctermid_r)
Matthias Klosec511b472010-05-08 11:01:39 +00002989AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwisd5843682002-11-21 20:41:28 +00002990#include <stdio.h>
Matthias Klosec511b472010-05-08 11:01:39 +00002991]], [[void* p = ctermid_r]])],
2992 [AC_DEFINE(HAVE_CTERMID_R, 1, Define if you have the 'ctermid_r' function.)
2993 AC_MSG_RESULT(yes)],
2994 [AC_MSG_RESULT(no)
2995])
Martin v. Löwisd5843682002-11-21 20:41:28 +00002996
Antoine Pitroub170f172010-09-10 18:47:36 +00002997AC_CACHE_CHECK([for flock declaration], [ac_cv_flock_decl],
2998 [AC_COMPILE_IFELSE(
2999 [AC_LANG_PROGRAM(
3000 [#include <sys/file.h>],
3001 [void* p = flock]
3002 )],
3003 [ac_cv_flock_decl=yes],
3004 [ac_cv_flock_decl=no]
3005 )
Matthias Klosec511b472010-05-08 11:01:39 +00003006])
Antoine Pitroub170f172010-09-10 18:47:36 +00003007if test "x${ac_cv_flock_decl}" = xyes; then
3008 AC_CHECK_FUNCS(flock,,
3009 AC_CHECK_LIB(bsd,flock,
3010 [AC_DEFINE(HAVE_FLOCK)
3011 AC_DEFINE(FLOCK_NEEDS_LIBBSD, 1, Define if flock needs to be linked with bsd library.)
3012 ])
3013 )
Antoine Pitrou85729812010-09-07 14:55:24 +00003014fi
Martin v. Löwisf26d63b2003-03-30 17:23:49 +00003015
3016AC_MSG_CHECKING(for getpagesize)
Matthias Klosec511b472010-05-08 11:01:39 +00003017AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwisf26d63b2003-03-30 17:23:49 +00003018#include <unistd.h>
Matthias Klosec511b472010-05-08 11:01:39 +00003019]], [[void* p = getpagesize]])],
3020 [AC_DEFINE(HAVE_GETPAGESIZE, 1, Define if you have the 'getpagesize' function.)
3021 AC_MSG_RESULT(yes)],
3022 [AC_MSG_RESULT(no)
3023])
Martin v. Löwisf26d63b2003-03-30 17:23:49 +00003024
Charles-François Natali93a11752011-11-27 13:01:35 +01003025AC_MSG_CHECKING(for broken unsetenv)
3026AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3027#include <stdlib.h>
3028]], [[int res = unsetenv("DUMMY")]])],
3029 [AC_MSG_RESULT(no)],
3030 [AC_DEFINE(HAVE_BROKEN_UNSETENV, 1, Define if `unsetenv` does not return an int.)
3031 AC_MSG_RESULT(yes)
3032])
3033
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00003034dnl check for true
3035AC_CHECK_PROGS(TRUE, true, /bin/true)
3036
Martin v. Löwis95c419b2003-05-03 12:10:48 +00003037dnl On some systems (e.g. Solaris 9), hstrerror and inet_aton are in -lresolv
3038dnl On others, they are in the C library, so we to take no action
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00003039AC_CHECK_LIB(c, inet_aton, [$ac_cv_prog_TRUE],
Martin v. Löwis95c419b2003-05-03 12:10:48 +00003040 AC_CHECK_LIB(resolv, inet_aton)
3041)
3042
Martin v. Löwisa51d5c82007-12-04 08:37:59 +00003043# On Tru64, chflags seems to be present, but calling it will
3044# exit Python
Gregory P. Smithbb213892009-11-02 01:37:37 +00003045AC_CACHE_CHECK([for chflags], [ac_cv_have_chflags], [dnl
Ned Deily43e10542011-06-27 23:41:53 -07003046AC_RUN_IFELSE([AC_LANG_SOURCE([[
Martin v. Löwisa51d5c82007-12-04 08:37:59 +00003047#include <sys/stat.h>
3048#include <unistd.h>
3049int main(int argc, char*argv[])
3050{
3051 if(chflags(argv[0], 0) != 0)
3052 return 1;
3053 return 0;
3054}
Ned Deily43e10542011-06-27 23:41:53 -07003055]])],
Matthias Klosec511b472010-05-08 11:01:39 +00003056[ac_cv_have_chflags=yes],
3057[ac_cv_have_chflags=no],
3058[ac_cv_have_chflags=cross])
Gregory P. Smithbb213892009-11-02 01:37:37 +00003059])
3060if test "$ac_cv_have_chflags" = cross ; then
3061 AC_CHECK_FUNC([chflags], [ac_cv_have_chflags="yes"], [ac_cv_have_chflags="no"])
3062fi
3063if test "$ac_cv_have_chflags" = yes ; then
Ned Deily43e10542011-06-27 23:41:53 -07003064 AC_DEFINE(HAVE_CHFLAGS, 1, [Define to 1 if you have the 'chflags' function.])
Alexandre Vassalotti00900892009-07-17 05:26:39 +00003065fi
Martin v. Löwisa51d5c82007-12-04 08:37:59 +00003066
Gregory P. Smithbb213892009-11-02 01:37:37 +00003067AC_CACHE_CHECK([for lchflags], [ac_cv_have_lchflags], [dnl
Ned Deily43e10542011-06-27 23:41:53 -07003068AC_RUN_IFELSE([AC_LANG_SOURCE([[
Martin v. Löwisa51d5c82007-12-04 08:37:59 +00003069#include <sys/stat.h>
3070#include <unistd.h>
3071int main(int argc, char*argv[])
3072{
3073 if(lchflags(argv[0], 0) != 0)
3074 return 1;
3075 return 0;
3076}
Ned Deily43e10542011-06-27 23:41:53 -07003077]])],[ac_cv_have_lchflags=yes],[ac_cv_have_lchflags=no],[ac_cv_have_lchflags=cross])
Gregory P. Smithbb213892009-11-02 01:37:37 +00003078])
3079if test "$ac_cv_have_lchflags" = cross ; then
3080 AC_CHECK_FUNC([lchflags], [ac_cv_have_lchflags="yes"], [ac_cv_have_lchflags="no"])
3081fi
3082if test "$ac_cv_have_lchflags" = yes ; then
Ned Deily43e10542011-06-27 23:41:53 -07003083 AC_DEFINE(HAVE_LCHFLAGS, 1, [Define to 1 if you have the 'lchflags' function.])
Alexandre Vassalotti00900892009-07-17 05:26:39 +00003084fi
Martin v. Löwisa51d5c82007-12-04 08:37:59 +00003085
Neal Norwitz6e73aaa2006-06-12 03:33:09 +00003086dnl Check if system zlib has *Copy() functions
Ronald Oussorenf8752642006-07-06 10:13:35 +00003087dnl
3088dnl On MacOSX the linker will search for dylibs on the entire linker path
3089dnl before searching for static libraries. setup.py adds -Wl,-search_paths_first
3090dnl to revert to a more traditional unix behaviour and make it possible to
3091dnl override the system libz with a local static library of libz. Temporarily
3092dnl add that flag to our CFLAGS as well to ensure that we check the version
3093dnl of libz that will be used by setup.py.
3094dnl The -L/usr/local/lib is needed as wel to get the same compilation
3095dnl environment as setup.py (and leaving it out can cause configure to use the
3096dnl wrong version of the library)
3097case $ac_sys_system/$ac_sys_release in
3098Darwin/*)
3099 _CUR_CFLAGS="${CFLAGS}"
3100 _CUR_LDFLAGS="${LDFLAGS}"
3101 CFLAGS="${CFLAGS} -Wl,-search_paths_first"
3102 LDFLAGS="${LDFLAGS} -Wl,-search_paths_first -L/usr/local/lib"
3103 ;;
3104esac
3105
Matthias Klose5183ebd2010-04-24 16:38:36 +00003106AC_CHECK_LIB(z, inflateCopy, AC_DEFINE(HAVE_ZLIB_COPY, 1, [Define if the zlib library has inflateCopy]))
Neal Norwitz6e73aaa2006-06-12 03:33:09 +00003107
Ronald Oussorenf8752642006-07-06 10:13:35 +00003108case $ac_sys_system/$ac_sys_release in
3109Darwin/*)
3110 CFLAGS="${_CUR_CFLAGS}"
3111 LDFLAGS="${_CUR_LDFLAGS}"
3112 ;;
3113esac
3114
Martin v. Löwise9416172003-05-03 10:12:45 +00003115AC_MSG_CHECKING(for hstrerror)
Matthias Klosec511b472010-05-08 11:01:39 +00003116AC_LINK_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwise9416172003-05-03 10:12:45 +00003117#include <netdb.h>
Matthias Klosec511b472010-05-08 11:01:39 +00003118]], [[void* p = hstrerror; hstrerror(0)]])],
3119 [AC_DEFINE(HAVE_HSTRERROR, 1, Define if you have the 'hstrerror' function.)
3120 AC_MSG_RESULT(yes)],
3121 [AC_MSG_RESULT(no)
3122])
Martin v. Löwise9416172003-05-03 10:12:45 +00003123
3124AC_MSG_CHECKING(for inet_aton)
Matthias Klosec511b472010-05-08 11:01:39 +00003125AC_LINK_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwis86d66262006-02-17 08:40:11 +00003126#include <sys/types.h>
Martin v. Löwise9416172003-05-03 10:12:45 +00003127#include <sys/socket.h>
3128#include <netinet/in.h>
3129#include <arpa/inet.h>
Matthias Klosec511b472010-05-08 11:01:39 +00003130]], [[void* p = inet_aton;inet_aton(0,0)]])],
3131 [AC_DEFINE(HAVE_INET_ATON, 1, Define if you have the 'inet_aton' function.)
3132 AC_MSG_RESULT(yes)],
3133 [AC_MSG_RESULT(no)
3134])
Martin v. Löwise9416172003-05-03 10:12:45 +00003135
3136AC_MSG_CHECKING(for inet_pton)
Matthias Klosec511b472010-05-08 11:01:39 +00003137AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwisf2e488d2003-05-05 22:00:11 +00003138#include <sys/types.h>
Martin v. Löwise9416172003-05-03 10:12:45 +00003139#include <sys/socket.h>
3140#include <netinet/in.h>
3141#include <arpa/inet.h>
Matthias Klosec511b472010-05-08 11:01:39 +00003142]], [[void* p = inet_pton]])],
3143 [AC_DEFINE(HAVE_INET_PTON, 1, Define if you have the 'inet_pton' function.)
3144 AC_MSG_RESULT(yes)],
3145 [AC_MSG_RESULT(no)
3146])
Martin v. Löwise9416172003-05-03 10:12:45 +00003147
Martin v. Löwisd6640d42003-07-06 09:29:52 +00003148# On some systems, setgroups is in unistd.h, on others, in grp.h
Martin v. Löwisd5843682002-11-21 20:41:28 +00003149AC_MSG_CHECKING(for setgroups)
Matthias Klosec511b472010-05-08 11:01:39 +00003150AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwisf2e488d2003-05-05 22:00:11 +00003151#include <unistd.h>
Martin v. Löwisd6640d42003-07-06 09:29:52 +00003152#ifdef HAVE_GRP_H
3153#include <grp.h>
3154#endif
Matthias Klosec511b472010-05-08 11:01:39 +00003155]], [[void* p = setgroups]])],
3156 [AC_DEFINE(HAVE_SETGROUPS, 1, Define if you have the 'setgroups' function.)
3157 AC_MSG_RESULT(yes)],
3158 [AC_MSG_RESULT(no)
3159])
Martin v. Löwisd5843682002-11-21 20:41:28 +00003160
Fred Drake8cef4cf2000-06-28 16:40:38 +00003161# check for openpty and forkpty
3162
Martin v. Löwisfd9a72a2006-01-08 10:07:33 +00003163AC_CHECK_FUNCS(openpty,,
3164 AC_CHECK_LIB(util,openpty,
3165 [AC_DEFINE(HAVE_OPENPTY) LIBS="$LIBS -lutil"],
3166 AC_CHECK_LIB(bsd,openpty, [AC_DEFINE(HAVE_OPENPTY) LIBS="$LIBS -lbsd"])
3167 )
3168)
3169AC_CHECK_FUNCS(forkpty,,
3170 AC_CHECK_LIB(util,forkpty,
3171 [AC_DEFINE(HAVE_FORKPTY) LIBS="$LIBS -lutil"],
3172 AC_CHECK_LIB(bsd,forkpty, [AC_DEFINE(HAVE_FORKPTY) LIBS="$LIBS -lbsd"])
3173 )
3174)
Fred Drake8cef4cf2000-06-28 16:40:38 +00003175
Brett Cannonaa5778d2008-03-18 04:09:00 +00003176# Stuff for expat.
3177AC_CHECK_FUNCS(memmove)
3178
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00003179# check for long file support functions
3180AC_CHECK_FUNCS(fseek64 fseeko fstatvfs ftell64 ftello statvfs)
3181
Brett Cannonaa5778d2008-03-18 04:09:00 +00003182AC_REPLACE_FUNCS(dup2 getcwd strdup)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003183AC_CHECK_FUNCS(getpgrp,
Matthias Klosec511b472010-05-08 11:01:39 +00003184 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[getpgrp(0);]])],
3185 [AC_DEFINE(GETPGRP_HAVE_ARG, 1, [Define if getpgrp() must be called as getpgrp(0).])],
3186 [])
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003187)
Jack Jansen150753c2003-03-29 22:07:47 +00003188AC_CHECK_FUNCS(setpgrp,
Matthias Klosec511b472010-05-08 11:01:39 +00003189 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[setpgrp(0,0);]])],
3190 [AC_DEFINE(SETPGRP_HAVE_ARG, 1, [Define if setpgrp() must be called as setpgrp(0, 0).])],
3191 [])
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003192)
3193AC_CHECK_FUNCS(gettimeofday,
Matthias Klosec511b472010-05-08 11:01:39 +00003194 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/time.h>]],
3195 [[gettimeofday((struct timeval*)0,(struct timezone*)0);]])],
3196 [],
3197 [AC_DEFINE(GETTIMEOFDAY_NO_TZ, 1,
3198 [Define if gettimeofday() does not have second (timezone) argument
3199 This is the case on Motorola V4 (R40V4.2)])
3200 ])
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003201)
Guido van Rossum627b2d71993-12-24 10:39:16 +00003202
Martin v. Löwisdbe3f762002-10-10 14:27:30 +00003203AC_MSG_CHECKING(for major, minor, and makedev)
Matthias Klosec511b472010-05-08 11:01:39 +00003204AC_LINK_IFELSE([AC_LANG_PROGRAM([[
Neal Norwitz6eb37f02003-02-23 23:28:15 +00003205#if defined(MAJOR_IN_MKDEV)
3206#include <sys/mkdev.h>
3207#elif defined(MAJOR_IN_SYSMACROS)
3208#include <sys/sysmacros.h>
3209#else
3210#include <sys/types.h>
3211#endif
Matthias Klosec511b472010-05-08 11:01:39 +00003212]], [[
Martin v. Löwisdbe3f762002-10-10 14:27:30 +00003213 makedev(major(0),minor(0));
Matthias Klosec511b472010-05-08 11:01:39 +00003214]])],[
Martin v. Löwisdbe3f762002-10-10 14:27:30 +00003215 AC_DEFINE(HAVE_DEVICE_MACROS, 1,
3216 [Define to 1 if you have the device macros.])
3217 AC_MSG_RESULT(yes)
3218],[
3219 AC_MSG_RESULT(no)
3220])
Martin v. Löwis861a65b2001-10-24 14:36:00 +00003221
3222# On OSF/1 V5.1, getaddrinfo is available, but a define
3223# for [no]getaddrinfo in netdb.h.
3224AC_MSG_CHECKING(for getaddrinfo)
Matthias Klosec511b472010-05-08 11:01:39 +00003225AC_LINK_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwisc010b6d2001-11-09 17:50:52 +00003226#include <sys/types.h>
Martin v. Löwis861a65b2001-10-24 14:36:00 +00003227#include <sys/socket.h>
3228#include <netdb.h>
Martin v. Löwisc010b6d2001-11-09 17:50:52 +00003229#include <stdio.h>
Matthias Klosec511b472010-05-08 11:01:39 +00003230]], [[getaddrinfo(NULL, NULL, NULL, NULL);]])],
3231[have_getaddrinfo=yes],
3232[have_getaddrinfo=no])
Alexandre Vassalotti00900892009-07-17 05:26:39 +00003233AC_MSG_RESULT($have_getaddrinfo)
3234if test $have_getaddrinfo = yes
3235then
3236 AC_MSG_CHECKING(getaddrinfo bug)
3237 AC_CACHE_VAL(ac_cv_buggy_getaddrinfo,
Matthias Klosec511b472010-05-08 11:01:39 +00003238 AC_RUN_IFELSE([AC_LANG_SOURCE([[[
Stefan Krah0afe4e42012-11-22 23:56:51 +01003239#include <stdio.h>
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003240#include <sys/types.h>
3241#include <netdb.h>
3242#include <string.h>
3243#include <sys/socket.h>
3244#include <netinet/in.h>
3245
Alexandre Vassalotti00900892009-07-17 05:26:39 +00003246int main()
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003247{
3248 int passive, gaierr, inet4 = 0, inet6 = 0;
3249 struct addrinfo hints, *ai, *aitop;
3250 char straddr[INET6_ADDRSTRLEN], strport[16];
3251
3252 for (passive = 0; passive <= 1; passive++) {
3253 memset(&hints, 0, sizeof(hints));
3254 hints.ai_family = AF_UNSPEC;
3255 hints.ai_flags = passive ? AI_PASSIVE : 0;
3256 hints.ai_socktype = SOCK_STREAM;
Hye-Shik Chang54f94392004-04-14 07:55:31 +00003257 hints.ai_protocol = IPPROTO_TCP;
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003258 if ((gaierr = getaddrinfo(NULL, "54321", &hints, &aitop)) != 0) {
3259 (void)gai_strerror(gaierr);
3260 goto bad;
3261 }
3262 for (ai = aitop; ai; ai = ai->ai_next) {
3263 if (ai->ai_addr == NULL ||
3264 ai->ai_addrlen == 0 ||
3265 getnameinfo(ai->ai_addr, ai->ai_addrlen,
3266 straddr, sizeof(straddr), strport, sizeof(strport),
3267 NI_NUMERICHOST|NI_NUMERICSERV) != 0) {
3268 goto bad;
3269 }
3270 switch (ai->ai_family) {
3271 case AF_INET:
3272 if (strcmp(strport, "54321") != 0) {
3273 goto bad;
3274 }
3275 if (passive) {
3276 if (strcmp(straddr, "0.0.0.0") != 0) {
3277 goto bad;
3278 }
3279 } else {
3280 if (strcmp(straddr, "127.0.0.1") != 0) {
3281 goto bad;
3282 }
3283 }
3284 inet4++;
3285 break;
3286 case AF_INET6:
3287 if (strcmp(strport, "54321") != 0) {
3288 goto bad;
3289 }
3290 if (passive) {
3291 if (strcmp(straddr, "::") != 0) {
3292 goto bad;
3293 }
3294 } else {
3295 if (strcmp(straddr, "::1") != 0) {
3296 goto bad;
3297 }
3298 }
3299 inet6++;
3300 break;
3301 case AF_UNSPEC:
3302 goto bad;
3303 break;
3304 default:
3305 /* another family support? */
3306 break;
3307 }
3308 }
3309 }
3310
3311 if (!(inet4 == 0 || inet4 == 2))
3312 goto bad;
3313 if (!(inet6 == 0 || inet6 == 2))
3314 goto bad;
3315
3316 if (aitop)
3317 freeaddrinfo(aitop);
Alexandre Vassalotti00900892009-07-17 05:26:39 +00003318 return 0;
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003319
3320 bad:
3321 if (aitop)
3322 freeaddrinfo(aitop);
Alexandre Vassalotti00900892009-07-17 05:26:39 +00003323 return 1;
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003324}
Matthias Klosec511b472010-05-08 11:01:39 +00003325]]])],
3326[ac_cv_buggy_getaddrinfo=no],
3327[ac_cv_buggy_getaddrinfo=yes],
doko@python.orgd65e2ba2013-01-31 23:52:03 +01003328[
3329if test "${enable_ipv6+set}" = set; then
3330 ac_cv_buggy_getaddrinfo="no -- configured with --(en|dis)able-ipv6"
3331else
3332 ac_cv_buggy_getaddrinfo=yes
3333fi]))
Alexandre Vassalotti00900892009-07-17 05:26:39 +00003334fi
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003335
Benjamin Peterson75fed812010-11-01 01:47:19 +00003336AC_MSG_RESULT($ac_cv_buggy_getaddrinfo)
3337
Mark Dickinson0ef0b912009-12-31 21:11:48 +00003338if test $have_getaddrinfo = no -o "$ac_cv_buggy_getaddrinfo" = yes
Alexandre Vassalotti00900892009-07-17 05:26:39 +00003339then
3340 if test $ipv6 = yes
3341 then
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003342 echo 'Fatal: You must get working getaddrinfo() function.'
3343 echo ' or you can specify "--disable-ipv6"'.
3344 exit 1
3345 fi
Martin v. Löwis861a65b2001-10-24 14:36:00 +00003346else
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003347 AC_DEFINE(HAVE_GETADDRINFO, 1, [Define if you have the getaddrinfo function.])
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003348fi
Benjamin Peterson75fed812010-11-01 01:47:19 +00003349
Thomas Woutersb0db85a2001-08-08 10:39:03 +00003350AC_CHECK_FUNCS(getnameinfo)
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003351
Guido van Rossum627b2d71993-12-24 10:39:16 +00003352# checks for structures
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003353AC_HEADER_TIME
Guido van Rossum627b2d71993-12-24 10:39:16 +00003354AC_STRUCT_TM
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003355AC_STRUCT_TIMEZONE
Martin v. Löwis60a5d722002-10-16 20:28:25 +00003356AC_CHECK_MEMBERS([struct stat.st_rdev])
3357AC_CHECK_MEMBERS([struct stat.st_blksize])
Hye-Shik Chang5f937a72005-06-02 13:09:30 +00003358AC_CHECK_MEMBERS([struct stat.st_flags])
Martin v. Löwisebd9d5b2005-08-09 15:00:59 +00003359AC_CHECK_MEMBERS([struct stat.st_gen])
3360AC_CHECK_MEMBERS([struct stat.st_birthtime])
Guido van Rossum98bf58f2001-10-18 20:34:25 +00003361AC_STRUCT_ST_BLOCKS
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003362
3363AC_MSG_CHECKING(for time.h that defines altzone)
Matthias Klosec511b472010-05-08 11:01:39 +00003364AC_CACHE_VAL(ac_cv_header_time_altzone,[
3365 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <time.h>]], [[return altzone;]])],
3366 [ac_cv_header_time_altzone=yes],
3367 [ac_cv_header_time_altzone=no])
3368 ])
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003369AC_MSG_RESULT($ac_cv_header_time_altzone)
3370if test $ac_cv_header_time_altzone = yes; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003371 AC_DEFINE(HAVE_ALTZONE, 1, [Define this if your time.h defines altzone.])
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003372fi
3373
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003374was_it_defined=no
3375AC_MSG_CHECKING(whether sys/select.h and sys/time.h may both be included)
Matthias Klosec511b472010-05-08 11:01:39 +00003376AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003377#include <sys/types.h>
3378#include <sys/select.h>
3379#include <sys/time.h>
Matthias Klosec511b472010-05-08 11:01:39 +00003380]], [[;]])],[
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003381 AC_DEFINE(SYS_SELECT_WITH_SYS_TIME, 1,
3382 [Define if you can safely include both <sys/select.h> and <sys/time.h>
3383 (which you can't on SCO ODT 3.0).])
3384 was_it_defined=yes
Matthias Klosec511b472010-05-08 11:01:39 +00003385],[])
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003386AC_MSG_RESULT($was_it_defined)
Guido van Rossum627b2d71993-12-24 10:39:16 +00003387
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003388AC_MSG_CHECKING(for addrinfo)
3389AC_CACHE_VAL(ac_cv_struct_addrinfo,
Matthias Klosec511b472010-05-08 11:01:39 +00003390AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <netdb.h>]], [[struct addrinfo a]])],
3391 [ac_cv_struct_addrinfo=yes],
3392 [ac_cv_struct_addrinfo=no]))
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003393AC_MSG_RESULT($ac_cv_struct_addrinfo)
3394if test $ac_cv_struct_addrinfo = yes; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003395 AC_DEFINE(HAVE_ADDRINFO, 1, [struct addrinfo (netdb.h)])
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003396fi
3397
3398AC_MSG_CHECKING(for sockaddr_storage)
3399AC_CACHE_VAL(ac_cv_struct_sockaddr_storage,
Matthias Klosec511b472010-05-08 11:01:39 +00003400AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003401# include <sys/types.h>
Matthias Klosec511b472010-05-08 11:01:39 +00003402# include <sys/socket.h>]], [[struct sockaddr_storage s]])],
3403 [ac_cv_struct_sockaddr_storage=yes],
3404 [ac_cv_struct_sockaddr_storage=no]))
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003405AC_MSG_RESULT($ac_cv_struct_sockaddr_storage)
3406if test $ac_cv_struct_sockaddr_storage = yes; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003407 AC_DEFINE(HAVE_SOCKADDR_STORAGE, 1, [struct sockaddr_storage (sys/socket.h)])
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003408fi
3409
Guido van Rossum627b2d71993-12-24 10:39:16 +00003410# checks for compiler characteristics
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003411
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003412AC_C_CHAR_UNSIGNED
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003413AC_C_CONST
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003414
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003415works=no
3416AC_MSG_CHECKING(for working volatile)
Matthias Klosec511b472010-05-08 11:01:39 +00003417AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[volatile int x; x = 0;]])],
3418 [works=yes],
3419 [AC_DEFINE(volatile, , [Define to empty if the keyword does not work.])]
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003420)
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003421AC_MSG_RESULT($works)
Guido van Rossumdabb11b1994-10-11 15:04:27 +00003422
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003423works=no
3424AC_MSG_CHECKING(for working signed char)
Matthias Klosec511b472010-05-08 11:01:39 +00003425AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[signed char c;]])],
3426 [works=yes],
3427 [AC_DEFINE(signed, , [Define to empty if the keyword does not work.])]
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003428)
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003429AC_MSG_RESULT($works)
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003430
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003431have_prototypes=no
3432AC_MSG_CHECKING(for prototypes)
Matthias Klosec511b472010-05-08 11:01:39 +00003433AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[int foo(int x) { return 0; }]], [[return foo(10);]])],
3434 [AC_DEFINE(HAVE_PROTOTYPES, 1,
3435 [Define if your compiler supports function prototype])
3436 have_prototypes=yes],
3437 []
3438)
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003439AC_MSG_RESULT($have_prototypes)
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003440
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003441works=no
3442AC_MSG_CHECKING(for variable length prototypes and stdarg.h)
Matthias Klosec511b472010-05-08 11:01:39 +00003443AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003444#include <stdarg.h>
Guido van Rossum3f13e481996-08-30 20:58:11 +00003445int foo(int x, ...) {
3446 va_list va;
3447 va_start(va, x);
3448 va_arg(va, int);
3449 va_arg(va, char *);
3450 va_arg(va, double);
3451 return 0;
3452}
Matthias Klosec511b472010-05-08 11:01:39 +00003453]], [[return foo(10, "", 3.14);]])],[
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003454 AC_DEFINE(HAVE_STDARG_PROTOTYPES, 1,
3455 [Define if your compiler supports variable length function prototypes
3456 (e.g. void fprintf(FILE *, char *, ...);) *and* <stdarg.h>])
3457 works=yes
Matthias Klosec511b472010-05-08 11:01:39 +00003458],[])
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003459AC_MSG_RESULT($works)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003460
Dave Cole331708b2004-08-09 04:51:41 +00003461# check for socketpair
3462AC_MSG_CHECKING(for socketpair)
Matthias Klosec511b472010-05-08 11:01:39 +00003463AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Dave Cole331708b2004-08-09 04:51:41 +00003464#include <sys/types.h>
3465#include <sys/socket.h>
Matthias Klosec511b472010-05-08 11:01:39 +00003466]], [[void *x=socketpair]])],
3467 [AC_DEFINE(HAVE_SOCKETPAIR, 1, [Define if you have the 'socketpair' function.])
3468 AC_MSG_RESULT(yes)],
3469 [AC_MSG_RESULT(no)]
Dave Cole331708b2004-08-09 04:51:41 +00003470)
3471
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003472# check if sockaddr has sa_len member
3473AC_MSG_CHECKING(if sockaddr has sa_len member)
Matthias Klosec511b472010-05-08 11:01:39 +00003474AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
3475#include <sys/socket.h>]], [[struct sockaddr x;
3476x.sa_len = 0;]])],
3477 [AC_MSG_RESULT(yes)
3478 AC_DEFINE(HAVE_SOCKADDR_SA_LEN, 1, [Define if sockaddr has sa_len member])],
3479 [AC_MSG_RESULT(no)]
3480)
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003481
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003482va_list_is_array=no
3483AC_MSG_CHECKING(whether va_list is an array)
Matthias Klosec511b472010-05-08 11:01:39 +00003484AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003485#ifdef HAVE_STDARG_PROTOTYPES
3486#include <stdarg.h>
3487#else
3488#include <varargs.h>
3489#endif
Matthias Klosec511b472010-05-08 11:01:39 +00003490]], [[va_list list1, list2; list1 = list2;]])],[],[
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003491 AC_DEFINE(VA_LIST_IS_ARRAY, 1, [Define if a va_list is an array of some kind])
3492 va_list_is_array=yes
3493])
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003494AC_MSG_RESULT($va_list_is_array)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003495
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003496# sigh -- gethostbyname_r is a mess; it can have 3, 5 or 6 arguments :-(
Martin v. Löwis11437992002-04-12 09:54:03 +00003497AH_TEMPLATE(HAVE_GETHOSTBYNAME_R,
3498 [Define this if you have some version of gethostbyname_r()])
3499
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003500AC_CHECK_FUNC(gethostbyname_r, [
3501 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
3502 AC_MSG_CHECKING([gethostbyname_r with 6 args])
3503 OLD_CFLAGS=$CFLAGS
3504 CFLAGS="$CFLAGS $MY_CPPFLAGS $MY_THREAD_CPPFLAGS $MY_CFLAGS"
Matthias Klosec511b472010-05-08 11:01:39 +00003505 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003506# include <netdb.h>
Matthias Klosec511b472010-05-08 11:01:39 +00003507 ]], [[
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003508 char *name;
3509 struct hostent *he, *res;
3510 char buffer[2048];
3511 int buflen = 2048;
3512 int h_errnop;
3513
3514 (void) gethostbyname_r(name, he, buffer, buflen, &res, &h_errnop)
Matthias Klosec511b472010-05-08 11:01:39 +00003515 ]])],[
Guido van Rossum8db7d8b1999-03-23 16:40:33 +00003516 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003517 AC_DEFINE(HAVE_GETHOSTBYNAME_R_6_ARG, 1,
3518 [Define this if you have the 6-arg version of gethostbyname_r().])
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003519 AC_MSG_RESULT(yes)
Matthias Klosec511b472010-05-08 11:01:39 +00003520 ],[
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003521 AC_MSG_RESULT(no)
3522 AC_MSG_CHECKING([gethostbyname_r with 5 args])
Matthias Klosec511b472010-05-08 11:01:39 +00003523 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003524# include <netdb.h>
Matthias Klosec511b472010-05-08 11:01:39 +00003525 ]], [[
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003526 char *name;
3527 struct hostent *he;
Matthias Klosec511b472010-05-08 11:01:39 +00003528 char buffer[2048];
3529 int buflen = 2048;
3530 int h_errnop;
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003531
Matthias Klosec511b472010-05-08 11:01:39 +00003532 (void) gethostbyname_r(name, he, buffer, buflen, &h_errnop)
3533 ]])],
3534 [
Guido van Rossum8db7d8b1999-03-23 16:40:33 +00003535 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
Matthias Klosec511b472010-05-08 11:01:39 +00003536 AC_DEFINE(HAVE_GETHOSTBYNAME_R_5_ARG, 1,
3537 [Define this if you have the 5-arg version of gethostbyname_r().])
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003538 AC_MSG_RESULT(yes)
3539 ], [
3540 AC_MSG_RESULT(no)
Matthias Klosec511b472010-05-08 11:01:39 +00003541 AC_MSG_CHECKING([gethostbyname_r with 3 args])
3542 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3543# include <netdb.h>
3544 ]], [[
3545 char *name;
3546 struct hostent *he;
3547 struct hostent_data data;
3548
3549 (void) gethostbyname_r(name, he, &data);
3550 ]])],
3551 [
3552 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
3553 AC_DEFINE(HAVE_GETHOSTBYNAME_R_3_ARG, 1,
3554 [Define this if you have the 3-arg version of gethostbyname_r().])
3555 AC_MSG_RESULT(yes)
3556 ], [
3557 AC_MSG_RESULT(no)
3558 ])
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003559 ])
3560 ])
3561 CFLAGS=$OLD_CFLAGS
3562], [
Thomas Wouters3a584202000-08-05 23:28:51 +00003563 AC_CHECK_FUNCS(gethostbyname)
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003564])
3565AC_SUBST(HAVE_GETHOSTBYNAME_R_6_ARG)
3566AC_SUBST(HAVE_GETHOSTBYNAME_R_5_ARG)
3567AC_SUBST(HAVE_GETHOSTBYNAME_R_3_ARG)
Guido van Rossum8db7d8b1999-03-23 16:40:33 +00003568AC_SUBST(HAVE_GETHOSTBYNAME_R)
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003569AC_SUBST(HAVE_GETHOSTBYNAME)
3570
Guido van Rossum627b2d71993-12-24 10:39:16 +00003571# checks for system services
3572# (none yet)
3573
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003574# Linux requires this for correct f.p. operations
Jeremy Hyltonbe28f5b2000-07-27 21:03:04 +00003575AC_CHECK_FUNC(__fpu_control,
3576 [],
3577 [AC_CHECK_LIB(ieee, __fpu_control)
3578])
Guido van Rossum627b2d71993-12-24 10:39:16 +00003579
Guido van Rossum93274221997-05-09 02:42:00 +00003580# Check for --with-fpectl
Guido van Rossum93274221997-05-09 02:42:00 +00003581AC_MSG_CHECKING(for --with-fpectl)
Barry Warsawc0d24d82000-06-29 16:12:00 +00003582AC_ARG_WITH(fpectl,
Matthias Klose22520ea2010-05-08 10:14:46 +00003583 AS_HELP_STRING([--with-fpectl], [enable SIGFPE catching]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003584[
Guido van Rossum93274221997-05-09 02:42:00 +00003585if test "$withval" != no
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003586then
3587 AC_DEFINE(WANT_SIGFPE_HANDLER, 1,
3588 [Define if you want SIGFPE handled (see Include/pyfpe.h).])
3589 AC_MSG_RESULT(yes)
Guido van Rossum93274221997-05-09 02:42:00 +00003590else AC_MSG_RESULT(no)
Guido van Rossumef2255b2000-03-10 22:30:29 +00003591fi],
3592[AC_MSG_RESULT(no)])
Guido van Rossum93274221997-05-09 02:42:00 +00003593
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003594# check for --with-libm=...
3595AC_SUBST(LIBM)
Guido van Rossum4b6b5791996-09-09 20:09:34 +00003596case $ac_sys_system in
Guido van Rossum3dc0a512000-10-05 18:00:06 +00003597Darwin) ;;
Guido van Rossumec95c7b1998-08-04 17:59:56 +00003598BeOS) ;;
Guido van Rossum4b6b5791996-09-09 20:09:34 +00003599*) LIBM=-lm
3600esac
Guido van Rossum93274221997-05-09 02:42:00 +00003601AC_MSG_CHECKING(for --with-libm=STRING)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003602AC_ARG_WITH(libm,
Matthias Klose22520ea2010-05-08 10:14:46 +00003603 AS_HELP_STRING([--with-libm=STRING], [math library]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003604[
Guido van Rossum93274221997-05-09 02:42:00 +00003605if test "$withval" = no
3606then LIBM=
3607 AC_MSG_RESULT(force LIBM empty)
3608elif test "$withval" != yes
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003609then LIBM=$withval
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003610 AC_MSG_RESULT(set LIBM="$withval")
3611else AC_MSG_ERROR([proper usage is --with-libm=STRING])
Guido van Rossum93274221997-05-09 02:42:00 +00003612fi],
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003613[AC_MSG_RESULT(default LIBM="$LIBM")])
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003614
3615# check for --with-libc=...
3616AC_SUBST(LIBC)
Guido van Rossum93274221997-05-09 02:42:00 +00003617AC_MSG_CHECKING(for --with-libc=STRING)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003618AC_ARG_WITH(libc,
Matthias Klose22520ea2010-05-08 10:14:46 +00003619 AS_HELP_STRING([--with-libc=STRING], [C library]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003620[
Guido van Rossum93274221997-05-09 02:42:00 +00003621if test "$withval" = no
3622then LIBC=
3623 AC_MSG_RESULT(force LIBC empty)
3624elif test "$withval" != yes
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003625then LIBC=$withval
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003626 AC_MSG_RESULT(set LIBC="$withval")
3627else AC_MSG_ERROR([proper usage is --with-libc=STRING])
Guido van Rossum93274221997-05-09 02:42:00 +00003628fi],
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003629[AC_MSG_RESULT(default LIBC="$LIBC")])
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003630
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003631# **************************************************
3632# * Check for various properties of floating point *
3633# **************************************************
Mark Dickinson265d7382008-04-21 22:32:24 +00003634
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003635AC_MSG_CHECKING(whether C doubles are little-endian IEEE 754 binary64)
3636AC_CACHE_VAL(ac_cv_little_endian_double, [
Matthias Klosec511b472010-05-08 11:01:39 +00003637AC_RUN_IFELSE([AC_LANG_SOURCE([[
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003638#include <string.h>
3639int main() {
3640 double x = 9006104071832581.0;
3641 if (memcmp(&x, "\x05\x04\x03\x02\x01\xff\x3f\x43", 8) == 0)
3642 return 0;
3643 else
3644 return 1;
3645}
Matthias Klosec511b472010-05-08 11:01:39 +00003646]])],
3647[ac_cv_little_endian_double=yes],
3648[ac_cv_little_endian_double=no],
3649[ac_cv_little_endian_double=no])])
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003650AC_MSG_RESULT($ac_cv_little_endian_double)
3651if test "$ac_cv_little_endian_double" = yes
3652then
3653 AC_DEFINE(DOUBLE_IS_LITTLE_ENDIAN_IEEE754, 1,
3654 [Define if C doubles are 64-bit IEEE 754 binary format, stored
3655 with the least significant byte first])
3656fi
3657
3658AC_MSG_CHECKING(whether C doubles are big-endian IEEE 754 binary64)
3659AC_CACHE_VAL(ac_cv_big_endian_double, [
Matthias Klosec511b472010-05-08 11:01:39 +00003660AC_RUN_IFELSE([AC_LANG_SOURCE([[
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003661#include <string.h>
3662int main() {
3663 double x = 9006104071832581.0;
3664 if (memcmp(&x, "\x43\x3f\xff\x01\x02\x03\x04\x05", 8) == 0)
3665 return 0;
3666 else
3667 return 1;
3668}
Matthias Klosec511b472010-05-08 11:01:39 +00003669]])],
3670[ac_cv_big_endian_double=yes],
3671[ac_cv_big_endian_double=no],
3672[ac_cv_big_endian_double=no])])
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003673AC_MSG_RESULT($ac_cv_big_endian_double)
3674if test "$ac_cv_big_endian_double" = yes
3675then
3676 AC_DEFINE(DOUBLE_IS_BIG_ENDIAN_IEEE754, 1,
3677 [Define if C doubles are 64-bit IEEE 754 binary format, stored
3678 with the most significant byte first])
3679fi
3680
3681# Some ARM platforms use a mixed-endian representation for doubles.
3682# While Python doesn't currently have full support for these platforms
3683# (see e.g., issue 1762561), we can at least make sure that float <-> string
3684# conversions work.
3685AC_MSG_CHECKING(whether C doubles are ARM mixed-endian IEEE 754 binary64)
3686AC_CACHE_VAL(ac_cv_mixed_endian_double, [
Matthias Klosec511b472010-05-08 11:01:39 +00003687AC_RUN_IFELSE([AC_LANG_SOURCE([[
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003688#include <string.h>
3689int main() {
3690 double x = 9006104071832581.0;
3691 if (memcmp(&x, "\x01\xff\x3f\x43\x05\x04\x03\x02", 8) == 0)
3692 return 0;
3693 else
3694 return 1;
3695}
Matthias Klosec511b472010-05-08 11:01:39 +00003696]])],
3697[ac_cv_mixed_endian_double=yes],
3698[ac_cv_mixed_endian_double=no],
3699[ac_cv_mixed_endian_double=no])])
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003700AC_MSG_RESULT($ac_cv_mixed_endian_double)
3701if test "$ac_cv_mixed_endian_double" = yes
3702then
3703 AC_DEFINE(DOUBLE_IS_ARM_MIXED_ENDIAN_IEEE754, 1,
3704 [Define if C doubles are 64-bit IEEE 754 binary format, stored
3705 in ARM mixed-endian order (byte order 45670123)])
3706fi
3707
3708# The short float repr introduced in Python 3.1 requires the
3709# correctly-rounded string <-> double conversion functions from
3710# Python/dtoa.c, which in turn require that the FPU uses 53-bit
3711# rounding; this is a problem on x86, where the x87 FPU has a default
Mark Dickinsona548dee2009-11-15 13:12:43 +00003712# rounding precision of 64 bits. For gcc/x86, we can fix this by
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003713# using inline assembler to get and set the x87 FPU control word.
Mark Dickinsona548dee2009-11-15 13:12:43 +00003714
3715# This inline assembler syntax may also work for suncc and icc,
3716# so we try it on all platforms.
3717
3718AC_MSG_CHECKING(whether we can use gcc inline assembler to get and set x87 control word)
Matthias Klosec511b472010-05-08 11:01:39 +00003719AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
Mark Dickinsona548dee2009-11-15 13:12:43 +00003720 unsigned short cw;
3721 __asm__ __volatile__ ("fnstcw %0" : "=m" (cw));
3722 __asm__ __volatile__ ("fldcw %0" : : "m" (cw));
Matthias Klosec511b472010-05-08 11:01:39 +00003723]])],[have_gcc_asm_for_x87=yes],[have_gcc_asm_for_x87=no])
Mark Dickinsona548dee2009-11-15 13:12:43 +00003724AC_MSG_RESULT($have_gcc_asm_for_x87)
3725if test "$have_gcc_asm_for_x87" = yes
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003726then
Mark Dickinsona548dee2009-11-15 13:12:43 +00003727 AC_DEFINE(HAVE_GCC_ASM_FOR_X87, 1,
3728 [Define if we can use gcc inline assembler to get and set x87 control word])
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003729fi
Mark Dickinson7a3d8642008-04-22 00:54:27 +00003730
Mark Dickinson04b27232009-01-04 12:29:36 +00003731# Detect whether system arithmetic is subject to x87-style double
3732# rounding issues. The result of this test has little meaning on non
3733# IEEE 754 platforms. On IEEE 754, test should return 1 if rounding
3734# mode is round-to-nearest and double rounding issues are present, and
3735# 0 otherwise. See http://bugs.python.org/issue2937 for more info.
3736AC_MSG_CHECKING(for x87-style double rounding)
Mark Dickinson99abd142009-10-24 13:44:16 +00003737# $BASECFLAGS may affect the result
3738ac_save_cc="$CC"
3739CC="$CC $BASECFLAGS"
Matthias Klosec511b472010-05-08 11:01:39 +00003740AC_RUN_IFELSE([AC_LANG_SOURCE([[
Mark Dickinson04b27232009-01-04 12:29:36 +00003741#include <stdlib.h>
3742#include <math.h>
3743int main() {
3744 volatile double x, y, z;
3745 /* 1./(1-2**-53) -> 1+2**-52 (correct), 1.0 (double rounding) */
3746 x = 0.99999999999999989; /* 1-2**-53 */
3747 y = 1./x;
3748 if (y != 1.)
3749 exit(0);
3750 /* 1e16+2.99999 -> 1e16+2. (correct), 1e16+4. (double rounding) */
3751 x = 1e16;
3752 y = 2.99999;
3753 z = x + y;
3754 if (z != 1e16+4.)
3755 exit(0);
3756 /* both tests show evidence of double rounding */
3757 exit(1);
3758}
Matthias Klosec511b472010-05-08 11:01:39 +00003759]])],
3760[ac_cv_x87_double_rounding=no],
3761[ac_cv_x87_double_rounding=yes],
3762[ac_cv_x87_double_rounding=no])
Mark Dickinson99abd142009-10-24 13:44:16 +00003763CC="$ac_save_cc"
Mark Dickinson04b27232009-01-04 12:29:36 +00003764AC_MSG_RESULT($ac_cv_x87_double_rounding)
3765if test "$ac_cv_x87_double_rounding" = yes
3766then
3767 AC_DEFINE(X87_DOUBLE_ROUNDING, 1,
3768 [Define if arithmetic is subject to x87-style double rounding issue])
3769fi
3770
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003771# ************************************
3772# * Check for mathematical functions *
3773# ************************************
3774
3775LIBS_SAVE=$LIBS
3776LIBS="$LIBS $LIBM"
3777
Mark Dickinsonc63392c2009-11-28 13:13:13 +00003778# On FreeBSD 6.2, it appears that tanh(-0.) returns 0. instead of
3779# -0. on some architectures.
3780AC_MSG_CHECKING(whether tanh preserves the sign of zero)
3781AC_CACHE_VAL(ac_cv_tanh_preserves_zero_sign, [
Matthias Klosec511b472010-05-08 11:01:39 +00003782AC_RUN_IFELSE([AC_LANG_SOURCE([[
Mark Dickinsonc63392c2009-11-28 13:13:13 +00003783#include <math.h>
3784#include <stdlib.h>
3785int main() {
3786 /* return 0 if either negative zeros don't exist
3787 on this platform or if negative zeros exist
3788 and tanh(-0.) == -0. */
3789 if (atan2(0., -1.) == atan2(-0., -1.) ||
3790 atan2(tanh(-0.), -1.) == atan2(-0., -1.)) exit(0);
3791 else exit(1);
3792}
Matthias Klosec511b472010-05-08 11:01:39 +00003793]])],
3794[ac_cv_tanh_preserves_zero_sign=yes],
3795[ac_cv_tanh_preserves_zero_sign=no],
3796[ac_cv_tanh_preserves_zero_sign=no])])
Mark Dickinsonc63392c2009-11-28 13:13:13 +00003797AC_MSG_RESULT($ac_cv_tanh_preserves_zero_sign)
3798if test "$ac_cv_tanh_preserves_zero_sign" = yes
3799then
3800 AC_DEFINE(TANH_PRESERVES_ZERO_SIGN, 1,
3801 [Define if tanh(-0.) is -0., or if platform doesn't have signed zeros])
3802fi
3803
3804AC_CHECK_FUNCS([acosh asinh atanh copysign erf erfc expm1 finite gamma])
3805AC_CHECK_FUNCS([hypot lgamma log1p round tgamma])
3806AC_CHECK_DECLS([isinf, isnan, isfinite], [], [], [[#include <math.h>]])
3807
3808LIBS=$LIBS_SAVE
3809
Mark Dickinsonc4920e82009-11-20 19:30:22 +00003810# For multiprocessing module, check that sem_open
3811# actually works. For FreeBSD versions <= 7.2,
3812# the kernel module that provides POSIX semaphores
3813# isn't loaded by default, so an attempt to call
3814# sem_open results in a 'Signal 12' error.
3815AC_MSG_CHECKING(whether POSIX semaphores are enabled)
3816AC_CACHE_VAL(ac_cv_posix_semaphores_enabled,
Matthias Klosec511b472010-05-08 11:01:39 +00003817AC_RUN_IFELSE([AC_LANG_SOURCE([[
Mark Dickinsonc4920e82009-11-20 19:30:22 +00003818#include <unistd.h>
3819#include <fcntl.h>
3820#include <stdio.h>
3821#include <semaphore.h>
3822#include <sys/stat.h>
3823
3824int main(void) {
3825 sem_t *a = sem_open("/autoconf", O_CREAT, S_IRUSR|S_IWUSR, 0);
3826 if (a == SEM_FAILED) {
3827 perror("sem_open");
3828 return 1;
3829 }
3830 sem_close(a);
Mark Dickinson59dc89e2009-12-13 21:06:06 +00003831 sem_unlink("/autoconf");
Mark Dickinsonc4920e82009-11-20 19:30:22 +00003832 return 0;
3833}
Matthias Klosec511b472010-05-08 11:01:39 +00003834]])],
3835[ac_cv_posix_semaphores_enabled=yes],
3836[ac_cv_posix_semaphores_enabled=no],
3837[ac_cv_posix_semaphores_enabled=yes])
Mark Dickinsonc4920e82009-11-20 19:30:22 +00003838)
3839AC_MSG_RESULT($ac_cv_posix_semaphores_enabled)
3840if test $ac_cv_posix_semaphores_enabled = no
3841then
Mark Dickinson5afa6d42009-11-28 10:44:20 +00003842 AC_DEFINE(POSIX_SEMAPHORES_NOT_ENABLED, 1,
3843 [Define if POSIX semaphores aren't enabled on your system])
Mark Dickinsonc4920e82009-11-20 19:30:22 +00003844fi
3845
Jesse Noller355b1262009-04-02 00:03:28 +00003846# Multiprocessing check for broken sem_getvalue
3847AC_MSG_CHECKING(for broken sem_getvalue)
Alexandre Vassalotti00900892009-07-17 05:26:39 +00003848AC_CACHE_VAL(ac_cv_broken_sem_getvalue,
Matthias Klosec511b472010-05-08 11:01:39 +00003849AC_RUN_IFELSE([AC_LANG_SOURCE([[
Jesse Noller355b1262009-04-02 00:03:28 +00003850#include <unistd.h>
3851#include <fcntl.h>
3852#include <stdio.h>
3853#include <semaphore.h>
3854#include <sys/stat.h>
3855
3856int main(void){
Mark Dickinson59dc89e2009-12-13 21:06:06 +00003857 sem_t *a = sem_open("/autocftw", O_CREAT, S_IRUSR|S_IWUSR, 0);
Jesse Noller355b1262009-04-02 00:03:28 +00003858 int count;
3859 int res;
3860 if(a==SEM_FAILED){
3861 perror("sem_open");
3862 return 1;
3863
3864 }
3865 res = sem_getvalue(a, &count);
3866 sem_close(a);
Mark Dickinson59dc89e2009-12-13 21:06:06 +00003867 sem_unlink("/autocftw");
Jesse Noller355b1262009-04-02 00:03:28 +00003868 return res==-1 ? 1 : 0;
3869}
Matthias Klosec511b472010-05-08 11:01:39 +00003870]])],
3871[ac_cv_broken_sem_getvalue=no],
3872[ac_cv_broken_sem_getvalue=yes],
3873[ac_cv_broken_sem_getvalue=yes])
Jesse Noller355b1262009-04-02 00:03:28 +00003874)
Alexandre Vassalotti00900892009-07-17 05:26:39 +00003875AC_MSG_RESULT($ac_cv_broken_sem_getvalue)
3876if test $ac_cv_broken_sem_getvalue = yes
3877then
3878 AC_DEFINE(HAVE_BROKEN_SEM_GETVALUE, 1,
3879 [define to 1 if your sem_getvalue is broken.])
3880fi
Mark Dickinson04b27232009-01-04 12:29:36 +00003881
Mark Dickinsonefc82f72009-03-20 15:51:55 +00003882# determine what size digit to use for Python's longs
3883AC_MSG_CHECKING([digit size for Python's longs])
3884AC_ARG_ENABLE(big-digits,
Matthias Klose22520ea2010-05-08 10:14:46 +00003885AS_HELP_STRING([--enable-big-digits@<:@=BITS@:>@],[use big digits for Python longs [[BITS=30]]]),
Mark Dickinsonefc82f72009-03-20 15:51:55 +00003886[case $enable_big_digits in
3887yes)
3888 enable_big_digits=30 ;;
3889no)
3890 enable_big_digits=15 ;;
3891[15|30])
3892 ;;
3893*)
3894 AC_MSG_ERROR([bad value $enable_big_digits for --enable-big-digits; value should be 15 or 30]) ;;
3895esac
3896AC_MSG_RESULT($enable_big_digits)
3897AC_DEFINE_UNQUOTED(PYLONG_BITS_IN_DIGIT, $enable_big_digits, [Define as the preferred size in bits of long digits])
3898],
3899[AC_MSG_RESULT(no value specified)])
3900
Guido van Rossumef2255b2000-03-10 22:30:29 +00003901# check for wchar.h
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003902AC_CHECK_HEADER(wchar.h, [
3903 AC_DEFINE(HAVE_WCHAR_H, 1,
3904 [Define if the compiler provides a wchar.h header file.])
3905 wchar_h="yes"
3906],
Guido van Rossumef2255b2000-03-10 22:30:29 +00003907wchar_h="no"
3908)
3909
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003910# determine wchar_t size
3911if test "$wchar_h" = yes
3912then
Guido van Rossum67b26592001-10-20 14:21:45 +00003913 AC_CHECK_SIZEOF(wchar_t, 4, [#include <wchar.h>])
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003914fi
3915
Martin v. Löwisfa3bdea2003-09-04 18:50:54 +00003916AC_MSG_CHECKING(for UCS-4 tcl)
3917have_ucs4_tcl=no
Matthias Klosec511b472010-05-08 11:01:39 +00003918AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwisfa3bdea2003-09-04 18:50:54 +00003919#include <tcl.h>
3920#if TCL_UTF_MAX != 6
3921# error "NOT UCS4_TCL"
Matthias Klosec511b472010-05-08 11:01:39 +00003922#endif]], [[]])],[
Martin v. Löwisfa3bdea2003-09-04 18:50:54 +00003923 AC_DEFINE(HAVE_UCS4_TCL, 1, [Define this if you have tcl and TCL_UTF_MAX==6])
3924 have_ucs4_tcl=yes
Matthias Klosec511b472010-05-08 11:01:39 +00003925],[])
Martin v. Löwisfa3bdea2003-09-04 18:50:54 +00003926AC_MSG_RESULT($have_ucs4_tcl)
3927
Marc-André Lemburgd7160f82003-09-22 11:14:40 +00003928# check whether wchar_t is signed or not
3929if test "$wchar_h" = yes
3930then
3931 # check whether wchar_t is signed or not
3932 AC_MSG_CHECKING(whether wchar_t is signed)
3933 AC_CACHE_VAL(ac_cv_wchar_t_signed, [
Matthias Klosec511b472010-05-08 11:01:39 +00003934 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Marc-André Lemburgd7160f82003-09-22 11:14:40 +00003935 #include <wchar.h>
3936 int main()
3937 {
Martin v. Löwis44fe0e42006-04-11 07:15:30 +00003938 /* Success: exit code 0 */
3939 exit((((wchar_t) -1) < ((wchar_t) 0)) ? 0 : 1);
Marc-André Lemburgd7160f82003-09-22 11:14:40 +00003940 }
Matthias Klosec511b472010-05-08 11:01:39 +00003941 ]])],
3942 [ac_cv_wchar_t_signed=yes],
3943 [ac_cv_wchar_t_signed=no],
3944 [ac_cv_wchar_t_signed=yes])])
Marc-André Lemburgd7160f82003-09-22 11:14:40 +00003945 AC_MSG_RESULT($ac_cv_wchar_t_signed)
3946fi
3947
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003948AC_MSG_CHECKING(what type to use for unicode)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003949dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003950AC_ARG_ENABLE(unicode,
Benjamin Peterson66556b02010-05-25 02:23:32 +00003951 AS_HELP_STRING([--enable-unicode@<:@=ucs@<:@24@:>@@:>@], [Enable Unicode strings (default is ucs2)]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003952 [],
3953 [enable_unicode=yes])
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003954
3955if test $enable_unicode = yes
3956then
Martin v. Löwisfd917792001-06-27 20:22:04 +00003957 # Without any arguments, Py_UNICODE defaults to two-byte mode
Martin v. Löwisfa3bdea2003-09-04 18:50:54 +00003958 case "$have_ucs4_tcl" in
3959 yes) enable_unicode="ucs4"
3960 ;;
3961 *) enable_unicode="ucs2"
3962 ;;
3963 esac
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003964fi
3965
Martin v. Löwis0036cba2002-04-12 09:58:45 +00003966AH_TEMPLATE(Py_UNICODE_SIZE,
3967 [Define as the size of the unicode type.])
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003968case "$enable_unicode" in
3969ucs2) unicode_size="2"
3970 AC_DEFINE(Py_UNICODE_SIZE,2)
3971 ;;
3972ucs4) unicode_size="4"
3973 AC_DEFINE(Py_UNICODE_SIZE,4)
3974 ;;
Martin v. Löwised11a5d2012-05-20 10:42:17 +02003975no) ;; # To allow --disable-unicode
Ezio Melotti5820efb2010-02-27 00:05:42 +00003976*) AC_MSG_ERROR([invalid value for --enable-unicode. Use either ucs2 or ucs4 (lowercase).]) ;;
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003977esac
3978
Martin v. Löwis11437992002-04-12 09:54:03 +00003979AH_TEMPLATE(PY_UNICODE_TYPE,
3980 [Define as the integral type used for Unicode representation.])
Martin v. Löwis0036cba2002-04-12 09:58:45 +00003981
Martin v. Löwis339d0f72001-08-17 18:39:25 +00003982AC_SUBST(UNICODE_OBJS)
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003983if test "$enable_unicode" = "no"
3984then
Martin v. Löwis339d0f72001-08-17 18:39:25 +00003985 UNICODE_OBJS=""
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003986 AC_MSG_RESULT(not used)
3987else
Martin v. Löwis339d0f72001-08-17 18:39:25 +00003988 UNICODE_OBJS="Objects/unicodeobject.o Objects/unicodectype.o"
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003989 AC_DEFINE(Py_USING_UNICODE, 1,
3990 [Define if you want to have a Unicode type.])
Marc-André Lemburgd7160f82003-09-22 11:14:40 +00003991
3992 # wchar_t is only usable if it maps to an unsigned type
3993 if test "$unicode_size" = "$ac_cv_sizeof_wchar_t" \
Matthias Klose7dbeed72004-12-24 08:22:17 +00003994 -a "$ac_cv_wchar_t_signed" = "no"
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003995 then
3996 PY_UNICODE_TYPE="wchar_t"
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003997 AC_DEFINE(HAVE_USABLE_WCHAR_T, 1,
3998 [Define if you have a useable wchar_t type defined in wchar.h; useable
Marc-André Lemburgd7160f82003-09-22 11:14:40 +00003999 means wchar_t must be an unsigned type with at least 16 bits. (see
Martin v. Löwisc45929e2002-04-06 10:10:49 +00004000 Include/unicodeobject.h).])
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00004001 AC_DEFINE(PY_UNICODE_TYPE,wchar_t)
4002 elif test "$ac_cv_sizeof_short" = "$unicode_size"
4003 then
4004 PY_UNICODE_TYPE="unsigned short"
4005 AC_DEFINE(PY_UNICODE_TYPE,unsigned short)
4006 elif test "$ac_cv_sizeof_long" = "$unicode_size"
4007 then
4008 PY_UNICODE_TYPE="unsigned long"
4009 AC_DEFINE(PY_UNICODE_TYPE,unsigned long)
4010 else
4011 PY_UNICODE_TYPE="no type found"
4012 fi
4013 AC_MSG_RESULT($PY_UNICODE_TYPE)
4014fi
Guido van Rossumef2255b2000-03-10 22:30:29 +00004015
4016# check for endianness
4017AC_C_BIGENDIAN
4018
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00004019# Check whether right shifting a negative integer extends the sign bit
4020# or fills with zeros (like the Cray J90, according to Tim Peters).
4021AC_MSG_CHECKING(whether right shift extends the sign bit)
Vladimir Marangozova6180282000-07-12 05:05:06 +00004022AC_CACHE_VAL(ac_cv_rshift_extends_sign, [
Matthias Klosec511b472010-05-08 11:01:39 +00004023AC_RUN_IFELSE([AC_LANG_SOURCE([[
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00004024int main()
4025{
Vladimir Marangozova6180282000-07-12 05:05:06 +00004026 exit(((-1)>>3 == -1) ? 0 : 1);
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00004027}
Matthias Klosec511b472010-05-08 11:01:39 +00004028]])],
4029[ac_cv_rshift_extends_sign=yes],
4030[ac_cv_rshift_extends_sign=no],
4031[ac_cv_rshift_extends_sign=yes])])
Vladimir Marangozova6180282000-07-12 05:05:06 +00004032AC_MSG_RESULT($ac_cv_rshift_extends_sign)
4033if test "$ac_cv_rshift_extends_sign" = no
4034then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00004035 AC_DEFINE(SIGNED_RIGHT_SHIFT_ZERO_FILLS, 1,
4036 [Define if i>>j for signed int i does not extend the sign bit
4037 when i < 0])
Vladimir Marangozova6180282000-07-12 05:05:06 +00004038fi
4039
Guido van Rossumcadfaec2001-01-05 14:45:49 +00004040# check for getc_unlocked and related locking functions
4041AC_MSG_CHECKING(for getc_unlocked() and friends)
4042AC_CACHE_VAL(ac_cv_have_getc_unlocked, [
Matthias Klosec511b472010-05-08 11:01:39 +00004043AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <stdio.h>]], [[
Guido van Rossumcadfaec2001-01-05 14:45:49 +00004044 FILE *f = fopen("/dev/null", "r");
4045 flockfile(f);
4046 getc_unlocked(f);
4047 funlockfile(f);
Matthias Klosec511b472010-05-08 11:01:39 +00004048]])],[ac_cv_have_getc_unlocked=yes],[ac_cv_have_getc_unlocked=no])])
Guido van Rossumcadfaec2001-01-05 14:45:49 +00004049AC_MSG_RESULT($ac_cv_have_getc_unlocked)
4050if test "$ac_cv_have_getc_unlocked" = yes
4051then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00004052 AC_DEFINE(HAVE_GETC_UNLOCKED, 1,
4053 [Define this if you have flockfile(), getc_unlocked(), and funlockfile()])
Guido van Rossumcadfaec2001-01-05 14:45:49 +00004054fi
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00004055
Neal Norwitzfe8e3d92006-01-07 21:07:20 +00004056# check where readline lives
Martin v. Löwis82bca632006-02-10 20:49:30 +00004057# save the value of LIBS so we don't actually link Python with readline
4058LIBS_no_readline=$LIBS
Gregory P. Smith980b99b2008-09-07 05:15:18 +00004059
4060# On some systems we need to link readline to a termcap compatible
4061# library. NOTE: Keep the precedence of listed libraries synchronised
4062# with setup.py.
4063py_cv_lib_readline=no
4064AC_MSG_CHECKING([how to link readline libs])
4065for py_libtermcap in "" ncursesw ncurses curses termcap; do
4066 if test -z "$py_libtermcap"; then
4067 READLINE_LIBS="-lreadline"
4068 else
4069 READLINE_LIBS="-lreadline -l$py_libtermcap"
4070 fi
4071 LIBS="$READLINE_LIBS $LIBS_no_readline"
4072 AC_LINK_IFELSE(
4073 [AC_LANG_CALL([],[readline])],
4074 [py_cv_lib_readline=yes])
4075 if test $py_cv_lib_readline = yes; then
4076 break
4077 fi
4078done
4079# Uncomment this line if you want to use READINE_LIBS in Makefile or scripts
4080#AC_SUBST([READLINE_LIBS])
Gregory P. Smith29ec7502008-09-07 19:18:16 +00004081if test $py_cv_lib_readline = no; then
Gregory P. Smith980b99b2008-09-07 05:15:18 +00004082 AC_MSG_RESULT([none])
4083else
4084 AC_MSG_RESULT([$READLINE_LIBS])
4085 AC_DEFINE(HAVE_LIBREADLINE, 1,
4086 [Define if you have the readline library (-lreadline).])
Neal Norwitzfe8e3d92006-01-07 21:07:20 +00004087fi
4088
Michael W. Hudson30ea2f22004-07-07 17:44:12 +00004089# check for readline 2.1
4090AC_CHECK_LIB(readline, rl_callback_handler_install,
4091 AC_DEFINE(HAVE_RL_CALLBACK, 1,
Gregory P. Smithff7b2d52008-09-03 05:57:48 +00004092 [Define if you have readline 2.1]), ,$READLINE_LIBS)
Michael W. Hudson30ea2f22004-07-07 17:44:12 +00004093
Guido van Rossumfaf5e4d2002-12-30 16:25:41 +00004094# check for readline 2.2
Matthias Klosec511b472010-05-08 11:01:39 +00004095AC_PREPROC_IFELSE([AC_LANG_SOURCE([[#include <readline/readline.h>]])],
4096 [have_readline=yes],
4097 [have_readline=no]
4098)
Guido van Rossumfaf5e4d2002-12-30 16:25:41 +00004099if test $have_readline = yes
4100then
4101 AC_EGREP_HEADER([extern int rl_completion_append_character;],
4102 [readline/readline.h],
4103 AC_DEFINE(HAVE_RL_COMPLETION_APPEND_CHARACTER, 1,
4104 [Define if you have readline 2.2]), )
Antoine Pitroud9ff74e2009-10-26 19:16:46 +00004105 AC_EGREP_HEADER([extern int rl_completion_suppress_append;],
4106 [readline/readline.h],
4107 AC_DEFINE(HAVE_RL_COMPLETION_SUPPRESS_APPEND, 1,
4108 [Define if you have rl_completion_suppress_append]), )
Guido van Rossumfaf5e4d2002-12-30 16:25:41 +00004109fi
4110
Martin v. Löwis0daad592001-09-30 21:09:59 +00004111# check for readline 4.0
4112AC_CHECK_LIB(readline, rl_pre_input_hook,
Martin v. Löwisc45929e2002-04-06 10:10:49 +00004113 AC_DEFINE(HAVE_RL_PRE_INPUT_HOOK, 1,
Gregory P. Smithff7b2d52008-09-03 05:57:48 +00004114 [Define if you have readline 4.0]), ,$READLINE_LIBS)
Martin v. Löwis0daad592001-09-30 21:09:59 +00004115
Martin v. Löwis58bd49f2007-09-04 13:13:14 +00004116# also in 4.0
4117AC_CHECK_LIB(readline, rl_completion_display_matches_hook,
4118 AC_DEFINE(HAVE_RL_COMPLETION_DISPLAY_MATCHES_HOOK, 1,
Gregory P. Smithff7b2d52008-09-03 05:57:48 +00004119 [Define if you have readline 4.0]), ,$READLINE_LIBS)
Martin v. Löwis58bd49f2007-09-04 13:13:14 +00004120
Guido van Rossum353ae582001-07-10 16:45:32 +00004121# check for readline 4.2
4122AC_CHECK_LIB(readline, rl_completion_matches,
Martin v. Löwisc45929e2002-04-06 10:10:49 +00004123 AC_DEFINE(HAVE_RL_COMPLETION_MATCHES, 1,
Gregory P. Smithff7b2d52008-09-03 05:57:48 +00004124 [Define if you have readline 4.2]), ,$READLINE_LIBS)
Guido van Rossum353ae582001-07-10 16:45:32 +00004125
Michael W. Hudson30ea2f22004-07-07 17:44:12 +00004126# also in readline 4.2
Matthias Klosec511b472010-05-08 11:01:39 +00004127AC_PREPROC_IFELSE([AC_LANG_SOURCE([[#include <readline/readline.h>]])],
4128 [have_readline=yes],
4129 [have_readline=no]
4130)
Michael W. Hudson30ea2f22004-07-07 17:44:12 +00004131if test $have_readline = yes
4132then
4133 AC_EGREP_HEADER([extern int rl_catch_signals;],
4134 [readline/readline.h],
4135 AC_DEFINE(HAVE_RL_CATCH_SIGNAL, 1,
4136 [Define if you can turn off readline's signal handling.]), )
4137fi
4138
Martin v. Löwis82bca632006-02-10 20:49:30 +00004139# End of readline checks: restore LIBS
4140LIBS=$LIBS_no_readline
4141
Thomas Wouterse38b2f12001-07-11 22:35:31 +00004142AC_MSG_CHECKING(for broken nice())
4143AC_CACHE_VAL(ac_cv_broken_nice, [
Matthias Klosec511b472010-05-08 11:01:39 +00004144AC_RUN_IFELSE([AC_LANG_SOURCE([[
Thomas Wouterse38b2f12001-07-11 22:35:31 +00004145int main()
4146{
4147 int val1 = nice(1);
4148 if (val1 != -1 && val1 == nice(2))
4149 exit(0);
4150 exit(1);
4151}
Matthias Klosec511b472010-05-08 11:01:39 +00004152]])],
4153[ac_cv_broken_nice=yes],
4154[ac_cv_broken_nice=no],
4155[ac_cv_broken_nice=no])])
Thomas Wouterse38b2f12001-07-11 22:35:31 +00004156AC_MSG_RESULT($ac_cv_broken_nice)
4157if test "$ac_cv_broken_nice" = yes
4158then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00004159 AC_DEFINE(HAVE_BROKEN_NICE, 1,
4160 [Define if nice() returns success/failure instead of the new priority.])
Thomas Wouterse38b2f12001-07-11 22:35:31 +00004161fi
4162
Nicholas Bastine62c5c82004-03-21 23:45:42 +00004163AC_MSG_CHECKING(for broken poll())
Alexandre Vassalotti00900892009-07-17 05:26:39 +00004164AC_CACHE_VAL(ac_cv_broken_poll,
Matthias Klosec511b472010-05-08 11:01:39 +00004165AC_RUN_IFELSE([AC_LANG_SOURCE([[
Nicholas Bastine62c5c82004-03-21 23:45:42 +00004166#include <poll.h>
4167
Alexandre Vassalotti66da2632009-07-17 06:17:33 +00004168int main()
4169{
Nicholas Bastine62c5c82004-03-21 23:45:42 +00004170 struct pollfd poll_struct = { 42, POLLIN|POLLPRI|POLLOUT, 0 };
Alexandre Vassalotti66da2632009-07-17 06:17:33 +00004171 int poll_test;
4172
Nicholas Bastine62c5c82004-03-21 23:45:42 +00004173 close (42);
4174
Alexandre Vassalotti66da2632009-07-17 06:17:33 +00004175 poll_test = poll(&poll_struct, 1, 0);
Nicholas Bastine62c5c82004-03-21 23:45:42 +00004176 if (poll_test < 0)
Alexandre Vassalotti66da2632009-07-17 06:17:33 +00004177 return 0;
Nicholas Bastine62c5c82004-03-21 23:45:42 +00004178 else if (poll_test == 0 && poll_struct.revents != POLLNVAL)
Alexandre Vassalotti66da2632009-07-17 06:17:33 +00004179 return 0;
Nicholas Bastine62c5c82004-03-21 23:45:42 +00004180 else
Alexandre Vassalotti66da2632009-07-17 06:17:33 +00004181 return 1;
4182}
Matthias Klosec511b472010-05-08 11:01:39 +00004183]])],
4184[ac_cv_broken_poll=yes],
4185[ac_cv_broken_poll=no],
4186[ac_cv_broken_poll=no]))
Nicholas Bastine62c5c82004-03-21 23:45:42 +00004187AC_MSG_RESULT($ac_cv_broken_poll)
4188if test "$ac_cv_broken_poll" = yes
4189then
4190 AC_DEFINE(HAVE_BROKEN_POLL, 1,
4191 [Define if poll() sets errno on invalid file descriptors.])
4192fi
4193
Brett Cannon43802422005-02-10 20:48:03 +00004194# Before we can test tzset, we need to check if struct tm has a tm_zone
4195# (which is not required by ISO C or UNIX spec) and/or if we support
4196# tzname[]
4197AC_STRUCT_TIMEZONE
Nicholas Bastine62c5c82004-03-21 23:45:42 +00004198
Brett Cannon43802422005-02-10 20:48:03 +00004199# check tzset(3) exists and works like we expect it to
Guido van Rossumd11b62e2003-03-14 21:51:36 +00004200AC_MSG_CHECKING(for working tzset())
4201AC_CACHE_VAL(ac_cv_working_tzset, [
Matthias Klosec511b472010-05-08 11:01:39 +00004202AC_RUN_IFELSE([AC_LANG_SOURCE([[
Guido van Rossumd11b62e2003-03-14 21:51:36 +00004203#include <stdlib.h>
4204#include <time.h>
Brett Cannon18367812003-09-19 00:59:16 +00004205#include <string.h>
Brett Cannon43802422005-02-10 20:48:03 +00004206
4207#if HAVE_TZNAME
4208extern char *tzname[];
4209#endif
4210
Guido van Rossumd11b62e2003-03-14 21:51:36 +00004211int main()
4212{
Brett Cannon18367812003-09-19 00:59:16 +00004213 /* Note that we need to ensure that not only does tzset(3)
4214 do 'something' with localtime, but it works as documented
4215 in the library reference and as expected by the test suite.
Brett Cannon43802422005-02-10 20:48:03 +00004216 This includes making sure that tzname is set properly if
4217 tm->tm_zone does not exist since it is the alternative way
4218 of getting timezone info.
Brett Cannon18367812003-09-19 00:59:16 +00004219
4220 Red Hat 6.2 doesn't understand the southern hemisphere
Brett Cannon43802422005-02-10 20:48:03 +00004221 after New Year's Day.
Brett Cannon18367812003-09-19 00:59:16 +00004222 */
4223
Brett Cannon43802422005-02-10 20:48:03 +00004224 time_t groundhogday = 1044144000; /* GMT-based */
Brett Cannon18367812003-09-19 00:59:16 +00004225 time_t midyear = groundhogday + (365 * 24 * 3600 / 2);
4226
Neal Norwitz7f2588c2003-04-11 15:35:53 +00004227 putenv("TZ=UTC+0");
Guido van Rossumd11b62e2003-03-14 21:51:36 +00004228 tzset();
Brett Cannon18367812003-09-19 00:59:16 +00004229 if (localtime(&groundhogday)->tm_hour != 0)
4230 exit(1);
Brett Cannon43802422005-02-10 20:48:03 +00004231#if HAVE_TZNAME
4232 /* For UTC, tzname[1] is sometimes "", sometimes " " */
4233 if (strcmp(tzname[0], "UTC") ||
4234 (tzname[1][0] != 0 && tzname[1][0] != ' '))
4235 exit(1);
4236#endif
Brett Cannon18367812003-09-19 00:59:16 +00004237
Neal Norwitz7f2588c2003-04-11 15:35:53 +00004238 putenv("TZ=EST+5EDT,M4.1.0,M10.5.0");
Guido van Rossumd11b62e2003-03-14 21:51:36 +00004239 tzset();
Brett Cannon18367812003-09-19 00:59:16 +00004240 if (localtime(&groundhogday)->tm_hour != 19)
Guido van Rossumd11b62e2003-03-14 21:51:36 +00004241 exit(1);
Brett Cannon43802422005-02-10 20:48:03 +00004242#if HAVE_TZNAME
4243 if (strcmp(tzname[0], "EST") || strcmp(tzname[1], "EDT"))
4244 exit(1);
4245#endif
Brett Cannon18367812003-09-19 00:59:16 +00004246
4247 putenv("TZ=AEST-10AEDT-11,M10.5.0,M3.5.0");
4248 tzset();
4249 if (localtime(&groundhogday)->tm_hour != 11)
4250 exit(1);
Brett Cannon43802422005-02-10 20:48:03 +00004251#if HAVE_TZNAME
4252 if (strcmp(tzname[0], "AEST") || strcmp(tzname[1], "AEDT"))
4253 exit(1);
4254#endif
4255
4256#if HAVE_STRUCT_TM_TM_ZONE
Brett Cannon18367812003-09-19 00:59:16 +00004257 if (strcmp(localtime(&groundhogday)->tm_zone, "AEDT"))
4258 exit(1);
4259 if (strcmp(localtime(&midyear)->tm_zone, "AEST"))
4260 exit(1);
Brett Cannon43802422005-02-10 20:48:03 +00004261#endif
Brett Cannon18367812003-09-19 00:59:16 +00004262
Guido van Rossumd11b62e2003-03-14 21:51:36 +00004263 exit(0);
4264}
Matthias Klosec511b472010-05-08 11:01:39 +00004265]])],
4266[ac_cv_working_tzset=yes],
4267[ac_cv_working_tzset=no],
4268[ac_cv_working_tzset=no])])
Guido van Rossumd11b62e2003-03-14 21:51:36 +00004269AC_MSG_RESULT($ac_cv_working_tzset)
4270if test "$ac_cv_working_tzset" = yes
4271then
4272 AC_DEFINE(HAVE_WORKING_TZSET, 1,
4273 [Define if tzset() actually switches the local timezone in a meaningful way.])
4274fi
4275
Martin v. Löwis94717ed2002-09-09 14:24:16 +00004276# Look for subsecond timestamps in struct stat
4277AC_MSG_CHECKING(for tv_nsec in struct stat)
4278AC_CACHE_VAL(ac_cv_stat_tv_nsec,
Matthias Klosec511b472010-05-08 11:01:39 +00004279AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/stat.h>]], [[
Martin v. Löwis94717ed2002-09-09 14:24:16 +00004280struct stat st;
4281st.st_mtim.tv_nsec = 1;
Matthias Klosec511b472010-05-08 11:01:39 +00004282]])],
4283[ac_cv_stat_tv_nsec=yes],
4284[ac_cv_stat_tv_nsec=no]))
Martin v. Löwis94717ed2002-09-09 14:24:16 +00004285AC_MSG_RESULT($ac_cv_stat_tv_nsec)
4286if test "$ac_cv_stat_tv_nsec" = yes
4287then
4288 AC_DEFINE(HAVE_STAT_TV_NSEC, 1,
4289 [Define if you have struct stat.st_mtim.tv_nsec])
4290fi
4291
Martin v. Löwisebd9d5b2005-08-09 15:00:59 +00004292# Look for BSD style subsecond timestamps in struct stat
4293AC_MSG_CHECKING(for tv_nsec2 in struct stat)
4294AC_CACHE_VAL(ac_cv_stat_tv_nsec2,
Matthias Klosec511b472010-05-08 11:01:39 +00004295AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/stat.h>]], [[
Martin v. Löwisebd9d5b2005-08-09 15:00:59 +00004296struct stat st;
4297st.st_mtimespec.tv_nsec = 1;
Matthias Klosec511b472010-05-08 11:01:39 +00004298]])],
4299[ac_cv_stat_tv_nsec2=yes],
4300[ac_cv_stat_tv_nsec2=no]))
Martin v. Löwisebd9d5b2005-08-09 15:00:59 +00004301AC_MSG_RESULT($ac_cv_stat_tv_nsec2)
4302if test "$ac_cv_stat_tv_nsec2" = yes
4303then
4304 AC_DEFINE(HAVE_STAT_TV_NSEC2, 1,
4305 [Define if you have struct stat.st_mtimensec])
4306fi
4307
doko@ubuntu.comf27ec3e2014-04-17 20:11:19 +02004308# first curses configure check
4309ac_save_cppflags="$CPPFLAGS"
4310CPPFLAGS="$CPPFLAGS -I/usr/include/ncursesw"
4311
4312AC_CHECK_HEADERS(curses.h ncurses.h)
4313
4314# On Solaris, term.h requires curses.h
4315AC_CHECK_HEADERS(term.h,,,[
4316#ifdef HAVE_CURSES_H
4317#include <curses.h>
4318#endif
4319])
4320
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00004321# On HP/UX 11.0, mvwdelch is a block with a return statement
4322AC_MSG_CHECKING(whether mvwdelch is an expression)
4323AC_CACHE_VAL(ac_cv_mvwdelch_is_expression,
Matthias Klosec511b472010-05-08 11:01:39 +00004324AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <curses.h>]], [[
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00004325 int rtn;
4326 rtn = mvwdelch(0,0,0);
Matthias Klosec511b472010-05-08 11:01:39 +00004327]])],
4328[ac_cv_mvwdelch_is_expression=yes],
4329[ac_cv_mvwdelch_is_expression=no]))
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00004330AC_MSG_RESULT($ac_cv_mvwdelch_is_expression)
4331
4332if test "$ac_cv_mvwdelch_is_expression" = yes
4333then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00004334 AC_DEFINE(MVWDELCH_IS_EXPRESSION, 1,
4335 [Define if mvwdelch in curses.h is an expression.])
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00004336fi
4337
4338AC_MSG_CHECKING(whether WINDOW has _flags)
4339AC_CACHE_VAL(ac_cv_window_has_flags,
Matthias Klosec511b472010-05-08 11:01:39 +00004340AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <curses.h>]], [[
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00004341 WINDOW *w;
4342 w->_flags = 0;
Matthias Klosec511b472010-05-08 11:01:39 +00004343]])],
4344[ac_cv_window_has_flags=yes],
4345[ac_cv_window_has_flags=no]))
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00004346AC_MSG_RESULT($ac_cv_window_has_flags)
4347
4348
4349if test "$ac_cv_window_has_flags" = yes
4350then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00004351 AC_DEFINE(WINDOW_HAS_FLAGS, 1,
4352 [Define if WINDOW in curses.h offers a field _flags.])
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00004353fi
4354
Walter Dörwald4994d952006-06-19 08:07:50 +00004355AC_MSG_CHECKING(for is_term_resized)
Matthias Klosec511b472010-05-08 11:01:39 +00004356AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <curses.h>]], [[void *x=is_term_resized]])],
4357 [AC_DEFINE(HAVE_CURSES_IS_TERM_RESIZED, 1, Define if you have the 'is_term_resized' function.)
4358 AC_MSG_RESULT(yes)],
4359 [AC_MSG_RESULT(no)]
Walter Dörwald4994d952006-06-19 08:07:50 +00004360)
4361
Walter Dörwald05fdbf12006-06-19 08:14:09 +00004362AC_MSG_CHECKING(for resize_term)
Matthias Klosec511b472010-05-08 11:01:39 +00004363AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <curses.h>]], [[void *x=resize_term]])],
4364 [AC_DEFINE(HAVE_CURSES_RESIZE_TERM, 1, Define if you have the 'resize_term' function.)
4365 AC_MSG_RESULT(yes)],
4366 [AC_MSG_RESULT(no)]
Walter Dörwald4994d952006-06-19 08:07:50 +00004367)
4368
Walter Dörwald05fdbf12006-06-19 08:14:09 +00004369AC_MSG_CHECKING(for resizeterm)
Matthias Klosec511b472010-05-08 11:01:39 +00004370AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <curses.h>]], [[void *x=resizeterm]])],
4371 [AC_DEFINE(HAVE_CURSES_RESIZETERM, 1, Define if you have the 'resizeterm' function.)
4372 AC_MSG_RESULT(yes)],
4373 [AC_MSG_RESULT(no)]
Walter Dörwald4994d952006-06-19 08:07:50 +00004374)
doko@ubuntu.comf27ec3e2014-04-17 20:11:19 +02004375# last curses configure check
4376CPPFLAGS=$ac_save_cppflags
Walter Dörwald4994d952006-06-19 08:07:50 +00004377
doko@python.orgd65e2ba2013-01-31 23:52:03 +01004378AC_MSG_NOTICE([checking for device files])
Martin v. Löwisfefbc202006-10-17 18:59:23 +00004379
doko@python.orgd65e2ba2013-01-31 23:52:03 +01004380dnl NOTE: Inform user how to proceed with files when cross compiling.
4381if test "x$cross_compiling" = xyes; then
4382 if test "${ac_cv_file__dev_ptmx+set}" != set; then
4383 AC_MSG_CHECKING([for /dev/ptmx])
4384 AC_MSG_RESULT([not set])
4385 AC_MSG_ERROR([set ac_cv_file__dev_ptmx to yes/no in your CONFIG_SITE file when cross compiling])
4386 fi
4387 if test "${ac_cv_file__dev_ptc+set}" != set; then
4388 AC_MSG_CHECKING([for /dev/ptc])
4389 AC_MSG_RESULT([not set])
4390 AC_MSG_ERROR([set ac_cv_file__dev_ptc to yes/no in your CONFIG_SITE file when cross compiling])
4391 fi
Martin v. Löwisfefbc202006-10-17 18:59:23 +00004392fi
4393
doko@python.orgd65e2ba2013-01-31 23:52:03 +01004394AC_CHECK_FILE(/dev/ptmx, [], [])
4395if test "x$ac_cv_file__dev_ptmx" = xyes; then
4396 AC_DEFINE(HAVE_DEV_PTMX, 1,
4397 [Define to 1 if you have the /dev/ptmx device file.])
4398fi
4399AC_CHECK_FILE(/dev/ptc, [], [])
4400if test "x$ac_cv_file__dev_ptc" = xyes; then
Martin v. Löwisfefbc202006-10-17 18:59:23 +00004401 AC_DEFINE(HAVE_DEV_PTC, 1,
doko@python.orgd65e2ba2013-01-31 23:52:03 +01004402 [Define to 1 if you have the /dev/ptc device file.])
Martin v. Löwisfefbc202006-10-17 18:59:23 +00004403fi
Neal Norwitz865400f2003-03-21 01:42:58 +00004404
Mark Dickinson82864d12009-11-15 16:18:58 +00004405if test "$have_long_long" = yes
4406then
4407 AC_MSG_CHECKING(for %lld and %llu printf() format support)
4408 AC_CACHE_VAL(ac_cv_have_long_long_format,
Matthias Klosec511b472010-05-08 11:01:39 +00004409 AC_RUN_IFELSE([AC_LANG_SOURCE([[[
Mark Dickinson82864d12009-11-15 16:18:58 +00004410 #include <stdio.h>
4411 #include <stddef.h>
4412 #include <string.h>
4413
4414 #ifdef HAVE_SYS_TYPES_H
4415 #include <sys/types.h>
4416 #endif
4417
4418 int main()
4419 {
4420 char buffer[256];
4421
4422 if (sprintf(buffer, "%lld", (long long)123) < 0)
4423 return 1;
4424 if (strcmp(buffer, "123"))
4425 return 1;
4426
4427 if (sprintf(buffer, "%lld", (long long)-123) < 0)
4428 return 1;
4429 if (strcmp(buffer, "-123"))
4430 return 1;
4431
4432 if (sprintf(buffer, "%llu", (unsigned long long)123) < 0)
4433 return 1;
4434 if (strcmp(buffer, "123"))
4435 return 1;
4436
4437 return 0;
4438 }
Matthias Klosec511b472010-05-08 11:01:39 +00004439 ]]])],
4440 [ac_cv_have_long_long_format=yes],
4441 [ac_cv_have_long_long_format=no],
doko@python.orgd65e2ba2013-01-31 23:52:03 +01004442 [ac_cv_have_long_long_format="cross -- assuming no"
4443 if test x$GCC = xyes; then
4444 save_CFLAGS=$CFLAGS
4445 CFLAGS="$CFLAGS -Werror -Wformat"
4446 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4447 #include <stdio.h>
4448 #include <stddef.h>
4449 ]], [[
4450 char *buffer;
4451 sprintf(buffer, "%lld", (long long)123);
4452 sprintf(buffer, "%lld", (long long)-123);
4453 sprintf(buffer, "%llu", (unsigned long long)123);
4454 ]])],
4455 ac_cv_have_long_long_format=yes
4456 )
4457 CFLAGS=$save_CFLAGS
4458 fi])
Mark Dickinson82864d12009-11-15 16:18:58 +00004459 )
4460 AC_MSG_RESULT($ac_cv_have_long_long_format)
4461fi
4462
Mark Dickinson5ce84742009-12-31 20:48:04 +00004463if test "$ac_cv_have_long_long_format" = yes
Mark Dickinson82864d12009-11-15 16:18:58 +00004464then
4465 AC_DEFINE(PY_FORMAT_LONG_LONG, "ll",
4466 [Define to printf format modifier for long long type])
4467fi
4468
Ronald Oussoren315cd0c2009-11-19 16:25:21 +00004469if test $ac_sys_system = Darwin
4470then
4471 LIBS="$LIBS -framework CoreFoundation"
4472fi
4473
Mark Dickinson82864d12009-11-15 16:18:58 +00004474
Gregory P. Smithd8cb2d92009-11-02 02:02:38 +00004475AC_CACHE_CHECK([for %zd printf() format support], ac_cv_have_size_t_format, [dnl
Matthias Klosec511b472010-05-08 11:01:39 +00004476AC_RUN_IFELSE([AC_LANG_SOURCE([[
Alexandre Vassalottie7cf1182009-07-17 06:33:51 +00004477#include <stdio.h>
Brett Cannon09d12362006-05-11 05:11:33 +00004478#include <stddef.h>
4479#include <string.h>
4480
Christian Heimesdb3d6cb2007-12-16 21:39:43 +00004481#ifdef HAVE_SYS_TYPES_H
4482#include <sys/types.h>
4483#endif
Neal Norwitz4a8fbdb2006-09-22 08:16:26 +00004484
4485#ifdef HAVE_SSIZE_T
4486typedef ssize_t Py_ssize_t;
4487#elif SIZEOF_VOID_P == SIZEOF_LONG
4488typedef long Py_ssize_t;
4489#else
4490typedef int Py_ssize_t;
4491#endif
Brett Cannon09d12362006-05-11 05:11:33 +00004492
Christian Heimesdb3d6cb2007-12-16 21:39:43 +00004493int main()
4494{
4495 char buffer[256];
4496
Brett Cannon09d12362006-05-11 05:11:33 +00004497 if(sprintf(buffer, "%zd", (size_t)123) < 0)
4498 return 1;
4499
Neal Norwitz4a8fbdb2006-09-22 08:16:26 +00004500 if (strcmp(buffer, "123"))
Brett Cannon09d12362006-05-11 05:11:33 +00004501 return 1;
Neal Norwitz4a8fbdb2006-09-22 08:16:26 +00004502
4503 if (sprintf(buffer, "%zd", (Py_ssize_t)-123) < 0)
4504 return 1;
4505
4506 if (strcmp(buffer, "-123"))
4507 return 1;
4508
Brett Cannon09d12362006-05-11 05:11:33 +00004509 return 0;
Alexandre Vassalotti00900892009-07-17 05:26:39 +00004510}
Matthias Klosec511b472010-05-08 11:01:39 +00004511]])],
4512[ac_cv_have_size_t_format=yes],
4513[ac_cv_have_size_t_format=no],
4514[ac_cv_have_size_t_format="cross -- assuming yes"
4515])])
Gregory P. Smithd8cb2d92009-11-02 02:02:38 +00004516if test "$ac_cv_have_size_t_format" != no ; then
Alexandre Vassalotti00900892009-07-17 05:26:39 +00004517 AC_DEFINE(PY_FORMAT_SIZE_T, "z",
4518 [Define to printf format modifier for Py_ssize_t])
4519fi
Brett Cannon09d12362006-05-11 05:11:33 +00004520
Martin v. Löwis01c04012002-11-11 14:58:44 +00004521AC_CHECK_TYPE(socklen_t,,
4522 AC_DEFINE(socklen_t,int,
Matthias Klose5183ebd2010-04-24 16:38:36 +00004523 [Define to `int' if <sys/socket.h> does not define.]),[
Martin v. Löwis01c04012002-11-11 14:58:44 +00004524#ifdef HAVE_SYS_TYPES_H
4525#include <sys/types.h>
4526#endif
Guido van Rossum95713eb2000-05-18 20:53:31 +00004527#ifdef HAVE_SYS_SOCKET_H
4528#include <sys/socket.h>
4529#endif
Martin v. Löwis01c04012002-11-11 14:58:44 +00004530])
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00004531
R. David Murray1d9d16e2010-10-16 00:43:13 +00004532case $ac_sys_system in
4533AIX*)
4534 AC_DEFINE(HAVE_BROKEN_PIPE_BUF, 1, [Define if the system reports an invalid PIPE_BUF value.]) ;;
4535esac
4536
4537
Martin v. Löwis06f15bb2001-12-02 13:02:32 +00004538AC_SUBST(THREADHEADERS)
4539
4540for h in `(cd $srcdir;echo Python/thread_*.h)`
4541do
4542 THREADHEADERS="$THREADHEADERS \$(srcdir)/$h"
4543done
4544
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00004545AC_SUBST(SRCDIRS)
Neal Norwitzd24499d2005-12-18 21:36:39 +00004546SRCDIRS="Parser Grammar Objects Python Modules Mac"
Andrew M. Kuchling8abedde2001-01-26 22:55:24 +00004547AC_MSG_CHECKING(for build directories)
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00004548for dir in $SRCDIRS; do
4549 if test ! -d $dir; then
4550 mkdir $dir
Fred Drake884d3ba2000-11-02 17:52:56 +00004551 fi
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00004552done
4553AC_MSG_RESULT(done)
Fred Drake036144d2000-10-26 17:09:35 +00004554
Guido van Rossum627b2d71993-12-24 10:39:16 +00004555# generate output files
Antoine Pitrouf2caeed2009-05-24 20:23:57 +00004556AC_CONFIG_FILES(Makefile.pre Modules/Setup.config Misc/python.pc)
Antoine Pitrouaabdceb2010-09-10 20:03:17 +00004557AC_CONFIG_FILES([Modules/ld_so_aix], [chmod +x Modules/ld_so_aix])
Martin v. Löwis88afe662002-10-26 13:47:44 +00004558AC_OUTPUT
Neil Schemenauer61c51152001-01-26 16:18:16 +00004559
Martin v. Löwisf7afe952006-04-14 15:16:15 +00004560echo "creating Modules/Setup"
Neil Schemenauer61c51152001-01-26 16:18:16 +00004561if test ! -f Modules/Setup
4562then
4563 cp $srcdir/Modules/Setup.dist Modules/Setup
4564fi
4565
Martin v. Löwisf7afe952006-04-14 15:16:15 +00004566echo "creating Modules/Setup.local"
Neil Schemenauer61c51152001-01-26 16:18:16 +00004567if test ! -f Modules/Setup.local
4568then
4569 echo "# Edit this file for local setup changes" >Modules/Setup.local
4570fi
4571
4572echo "creating Makefile"
4573$SHELL $srcdir/Modules/makesetup -c $srcdir/Modules/config.c.in \
4574 -s Modules Modules/Setup.config \
Neil Schemenauerf8b71c52001-04-21 17:41:16 +00004575 Modules/Setup.local Modules/Setup
Skip Montanaro7221d932007-08-22 19:02:16 +00004576
4577case $ac_sys_system in
4578BeOS)
4579 AC_MSG_WARN([
4580
4581 Support for BeOS is deprecated as of Python 2.6.
4582 See PEP 11 for the gory details.
4583 ])
4584 ;;
4585*) ;;
4586esac
4587
Neil Schemenauer66252162001-02-19 04:47:42 +00004588mv config.c Modules