blob: d907d4f4522201a8a35cf1012189f7f9e2556cf9 [file] [log] [blame]
Benjamin Petersond7c77842008-05-26 13:01:25 +00001dnl ***********************************************
2dnl * Please run autoreconf to test your changes! *
3dnl ***********************************************
Benjamin Peterson98b1b022008-11-30 14:43:23 +00004dnl NOTE: autoconf 2.64 doesn't seem to work (use 2.61).
Martin v. Löwis88afe662002-10-26 13:47:44 +00005
6# Set VERSION so we only need to edit in one place (i.e., here)
Martin v. Löwis174440b2008-10-03 08:59:41 +00007m4_define(PYTHON_VERSION, 2.7)
Martin v. Löwis88afe662002-10-26 13:47:44 +00008
Alexandre Vassalotti130ae152009-07-18 00:31:06 +00009dnl Some m4 magic to ensure that the configure script is generated
10dnl by the correct autoconf version.
11m4_define([version_required],
12[m4_if(m4_version_compare(m4_defn([m4_PACKAGE_VERSION]), [$1]), 0,
13 [],
14 [m4_fatal([Autoconf version $1 is required for Python], 63)])
15])
16version_required(2.61)
17
Guido van Rossum76be6ed1995-01-02 18:33:54 +000018AC_REVISION($Revision$)
Georg Brandl464432d2009-05-20 18:24:08 +000019AC_INIT(python, PYTHON_VERSION, http://bugs.python.org/)
Martin v. Löwis88afe662002-10-26 13:47:44 +000020AC_CONFIG_SRCDIR([Include/object.h])
Martin v. Löwis4f1cd8b2001-07-26 13:41:06 +000021AC_CONFIG_HEADER(pyconfig.h)
Guido van Rossum627b2d71993-12-24 10:39:16 +000022
Georg Brandlbcd64a32009-03-31 21:45:18 +000023dnl Ensure that if prefix is specified, it does not end in a slash. If
24dnl it does, we get path names containing '//' which is both ugly and
25dnl can cause trouble.
26
27dnl Last slash shouldn't be stripped if prefix=/
28if test "$prefix" != "/"; then
29 prefix=`echo "$prefix" | sed -e 's/\/$//g'`
30fi
31
Martin v. Löwis8316feb2003-06-14 07:48:07 +000032dnl This is for stuff that absolutely must end up in pyconfig.h.
33dnl Please use pyport.h instead, if possible.
Martin v. Löwisbddf5a52002-11-11 13:37:28 +000034AH_TOP([
35#ifndef Py_PYCONFIG_H
36#define Py_PYCONFIG_H
37])
Martin v. Löwis11437992002-04-12 09:54:03 +000038AH_BOTTOM([
Martin v. Löwis11437992002-04-12 09:54:03 +000039/* Define the macros needed if on a UnixWare 7.x system. */
40#if defined(__USLC__) && defined(__SCO_VERSION__)
41#define STRICT_SYSV_CURSES /* Don't use ncurses extensions */
42#endif
Martin v. Löwisbddf5a52002-11-11 13:37:28 +000043
44#endif /*Py_PYCONFIG_H*/
Martin v. Löwis11437992002-04-12 09:54:03 +000045])
46
Martin v. Löwis8316feb2003-06-14 07:48:07 +000047# We don't use PACKAGE_ variables, and they cause conflicts
48# with other autoconf-based packages that include Python.h
49grep -v 'define PACKAGE_' <confdefs.h >confdefs.h.new
50rm confdefs.h
51mv confdefs.h.new confdefs.h
52
Guido van Rossum642b6781997-07-19 19:35:41 +000053AC_SUBST(VERSION)
Martin v. Löwis88afe662002-10-26 13:47:44 +000054VERSION=PYTHON_VERSION
Guido van Rossum642b6781997-07-19 19:35:41 +000055
Martin v. Löwis1142de32002-03-29 16:28:31 +000056AC_SUBST(SOVERSION)
57SOVERSION=1.0
58
Martin v. Löwis6f18a3c2002-07-20 08:51:52 +000059# The later defininition of _XOPEN_SOURCE disables certain features
60# on Linux, so we need _GNU_SOURCE to re-enable them (makedev, tm_zone).
61AC_DEFINE(_GNU_SOURCE, 1, [Define on Linux to activate all library features])
62
Martin v. Löwisbcd93962003-05-03 10:32:18 +000063# The later defininition of _XOPEN_SOURCE and _POSIX_C_SOURCE disables
64# certain features on NetBSD, so we need _NETBSD_SOURCE to re-enable
65# them.
66AC_DEFINE(_NETBSD_SOURCE, 1, [Define on NetBSD to activate all library features])
67
Andrew MacIntyreabccf412003-07-02 13:53:25 +000068# The later defininition of _XOPEN_SOURCE and _POSIX_C_SOURCE disables
69# certain features on FreeBSD, so we need __BSD_VISIBLE to re-enable
70# them.
71AC_DEFINE(__BSD_VISIBLE, 1, [Define on FreeBSD to activate all library features])
72
Martin v. Löwisd6320502004-08-12 13:45:08 +000073# The later defininition of _XOPEN_SOURCE and _POSIX_C_SOURCE disables
74# u_int on Irix 5.3. Defining _BSD_TYPES brings it back.
75AC_DEFINE(_BSD_TYPES, 1, [Define on Irix to enable u_int])
76
Ronald Oussoren5640ce22008-06-05 12:58:24 +000077# The later defininition of _XOPEN_SOURCE and _POSIX_C_SOURCE disables
78# certain features on Mac OS X, so we need _DARWIN_C_SOURCE to re-enable
79# them.
80AC_DEFINE(_DARWIN_C_SOURCE, 1, [Define on Darwin to activate all library features])
81
82
Martin v. Löwise981a4e2002-11-11 13:26:51 +000083define_xopen_source=yes
Martin v. Löwis6f18a3c2002-07-20 08:51:52 +000084
Neil Schemenauer4edbc2a2001-03-22 00:34:03 +000085# Arguments passed to configure.
86AC_SUBST(CONFIG_ARGS)
87CONFIG_ARGS="$ac_configure_args"
88
Ronald Oussoren3c0a1262010-01-17 19:27:57 +000089AC_MSG_CHECKING([for --enable-universalsdk])
Ronald Oussoren988117f2006-04-29 11:31:35 +000090AC_ARG_ENABLE(universalsdk,
Matthias Klose5183ebd2010-04-24 16:38:36 +000091 AC_HELP_STRING([--enable-universalsdk@<:@=SDKDIR@:>@], [Build against Mac OS X 10.4u SDK (ppc/i386)]),
Ronald Oussoren988117f2006-04-29 11:31:35 +000092[
93 case $enableval in
94 yes)
95 enableval=/Developer/SDKs/MacOSX10.4u.sdk
Ronald Oussoren3c0a1262010-01-17 19:27:57 +000096 if test ! -d "${enableval}"
97 then
98 enableval=/
99 fi
Ronald Oussoren988117f2006-04-29 11:31:35 +0000100 ;;
101 esac
102 case $enableval in
103 no)
104 UNIVERSALSDK=
105 enable_universalsdk=
106 ;;
107 *)
108 UNIVERSALSDK=$enableval
Ronald Oussoren3c0a1262010-01-17 19:27:57 +0000109 if test ! -d "${UNIVERSALSDK}"
110 then
111 AC_MSG_ERROR([--enable-universalsdk specifies non-existing SDK: ${UNIVERSALSDK}])
112 fi
Ronald Oussoren988117f2006-04-29 11:31:35 +0000113 ;;
114 esac
Ronald Oussoren3c0a1262010-01-17 19:27:57 +0000115
Ronald Oussoren988117f2006-04-29 11:31:35 +0000116],[
117 UNIVERSALSDK=
118 enable_universalsdk=
119])
Ronald Oussoren3c0a1262010-01-17 19:27:57 +0000120if test -n "${UNIVERSALSDK}"
121then
122 AC_MSG_RESULT(${UNIVERSALSDK})
123else
124 AC_MSG_RESULT(no)
125fi
Ronald Oussoren988117f2006-04-29 11:31:35 +0000126AC_SUBST(UNIVERSALSDK)
127
Benjamin Peterson0e6ea5d2008-07-16 20:17:04 +0000128AC_SUBST(ARCH_RUN_32BIT)
129
Ronald Oussoren5640ce22008-06-05 12:58:24 +0000130UNIVERSAL_ARCHS="32-bit"
Ronald Oussoren92919a62009-12-24 13:30:58 +0000131AC_SUBST(LIPO_32BIT_FLAGS)
Ronald Oussoren5640ce22008-06-05 12:58:24 +0000132AC_MSG_CHECKING(for --with-universal-archs)
133AC_ARG_WITH(universal-archs,
Matthias Klose5183ebd2010-04-24 16:38:36 +0000134 AC_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 +0000135[
136 AC_MSG_RESULT($withval)
137 UNIVERSAL_ARCHS="$withval"
Ronald Oussoren9ebd2422009-09-29 13:00:44 +0000138 if test "${enable_universalsdk}" ; then
139 :
140 else
141 AC_MSG_ERROR([--with-universal-archs without --enable-universalsdk. See Mac/README])
142 fi
Ronald Oussoren5640ce22008-06-05 12:58:24 +0000143],
144[
145 AC_MSG_RESULT(32-bit)
146])
147
148
149
Ronald Oussoren580c7fe2008-05-02 19:45:11 +0000150AC_ARG_WITH(framework-name,
Matthias Klose5183ebd2010-04-24 16:38:36 +0000151 AC_HELP_STRING([--with-framework-name=FRAMEWORK],
152 [specify an alternate name of the framework built with --enable-framework]),
Ronald Oussoren580c7fe2008-05-02 19:45:11 +0000153[
Ronald Oussoren9ebd2422009-09-29 13:00:44 +0000154 if test "${enable_framework}"; then
155 :
156 else
157 AC_MSG_ERROR([--with-framework-name without --enable-framework. See Mac/README])
158 fi
Ronald Oussoren580c7fe2008-05-02 19:45:11 +0000159 PYTHONFRAMEWORK=${withval}
160 PYTHONFRAMEWORKDIR=${withval}.framework
161 PYTHONFRAMEWORKIDENTIFIER=org.python.`echo $withval | tr '[A-Z]' '[a-z]'`
162 ],[
163 PYTHONFRAMEWORK=Python
164 PYTHONFRAMEWORKDIR=Python.framework
165 PYTHONFRAMEWORKIDENTIFIER=org.python.python
166])
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000167dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000168AC_ARG_ENABLE(framework,
Matthias Klose5183ebd2010-04-24 16:38:36 +0000169 AC_HELP_STRING([--enable-framework@<:@=INSTALLDIR@:>@], [Build (MacOSX|Darwin) framework]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000170[
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000171 case $enableval in
172 yes)
173 enableval=/Library/Frameworks
Jack Jansen127e56e2001-09-11 14:41:54 +0000174 esac
175 case $enableval in
176 no)
177 PYTHONFRAMEWORK=
178 PYTHONFRAMEWORKDIR=no-framework
179 PYTHONFRAMEWORKPREFIX=
180 PYTHONFRAMEWORKINSTALLDIR=
Ronald Oussoren567a8ff2006-05-26 11:43:26 +0000181 FRAMEWORKINSTALLFIRST=
182 FRAMEWORKINSTALLLAST=
Ronald Oussoren5b787322006-06-06 19:50:24 +0000183 FRAMEWORKALTINSTALLFIRST=
184 FRAMEWORKALTINSTALLLAST=
Ronald Oussoren2db3a8f2006-06-07 19:06:01 +0000185 if test "x${prefix}" = "xNONE"; then
186 FRAMEWORKUNIXTOOLSPREFIX="${ac_default_prefix}"
187 else
188 FRAMEWORKUNIXTOOLSPREFIX="${prefix}"
189 fi
Jack Jansen127e56e2001-09-11 14:41:54 +0000190 enable_framework=
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000191 ;;
192 *)
193 PYTHONFRAMEWORKPREFIX=$enableval
Jack Jansen127e56e2001-09-11 14:41:54 +0000194 PYTHONFRAMEWORKINSTALLDIR=$PYTHONFRAMEWORKPREFIX/$PYTHONFRAMEWORKDIR
Ronald Oussoren567a8ff2006-05-26 11:43:26 +0000195 FRAMEWORKINSTALLFIRST="frameworkinstallstructure"
Ronald Oussoren5640ce22008-06-05 12:58:24 +0000196 FRAMEWORKALTINSTALLFIRST="frameworkinstallstructure bininstall maninstall"
Ronald Oussoren92919a62009-12-24 13:30:58 +0000197 FRAMEWORKINSTALLLAST="frameworkinstallmaclib frameworkinstallapps frameworkinstallunixtools"
198 FRAMEWORKALTINSTALLLAST="frameworkinstallmaclib frameworkinstallapps frameworkaltinstallunixtools"
Ronald Oussoren5640ce22008-06-05 12:58:24 +0000199
Ronald Oussoren2db3a8f2006-06-07 19:06:01 +0000200 if test "x${prefix}" = "xNONE" ; then
201 FRAMEWORKUNIXTOOLSPREFIX="${ac_default_prefix}"
202 else
203 FRAMEWORKUNIXTOOLSPREFIX="${prefix}"
204 fi
Jack Jansen127e56e2001-09-11 14:41:54 +0000205 prefix=$PYTHONFRAMEWORKINSTALLDIR/Versions/$VERSION
Ronald Oussoren836b0392006-05-14 19:56:34 +0000206
Ronald Oussoren580c7fe2008-05-02 19:45:11 +0000207 # Add files for Mac specific code to the list of output
Ronald Oussoren836b0392006-05-14 19:56:34 +0000208 # files:
Ronald Oussoren2db3a8f2006-06-07 19:06:01 +0000209 AC_CONFIG_FILES(Mac/Makefile)
210 AC_CONFIG_FILES(Mac/PythonLauncher/Makefile)
211 AC_CONFIG_FILES(Mac/IDLE/Makefile)
Ronald Oussoren580c7fe2008-05-02 19:45:11 +0000212 AC_CONFIG_FILES(Mac/Resources/framework/Info.plist)
213 AC_CONFIG_FILES(Mac/Resources/app/Info.plist)
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000214 esac
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000215 ],[
216 PYTHONFRAMEWORK=
Jack Jansen127e56e2001-09-11 14:41:54 +0000217 PYTHONFRAMEWORKDIR=no-framework
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000218 PYTHONFRAMEWORKPREFIX=
219 PYTHONFRAMEWORKINSTALLDIR=
Ronald Oussoren567a8ff2006-05-26 11:43:26 +0000220 FRAMEWORKINSTALLFIRST=
221 FRAMEWORKINSTALLLAST=
Ronald Oussoren5b787322006-06-06 19:50:24 +0000222 FRAMEWORKALTINSTALLFIRST=
223 FRAMEWORKALTINSTALLLAST=
Ronald Oussoren2db3a8f2006-06-07 19:06:01 +0000224 if test "x${prefix}" = "xNONE" ; then
225 FRAMEWORKUNIXTOOLSPREFIX="${ac_default_prefix}"
226 else
227 FRAMEWORKUNIXTOOLSPREFIX="${prefix}"
228 fi
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000229 enable_framework=
Ronald Oussoren5640ce22008-06-05 12:58:24 +0000230
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000231])
232AC_SUBST(PYTHONFRAMEWORK)
Ronald Oussoren580c7fe2008-05-02 19:45:11 +0000233AC_SUBST(PYTHONFRAMEWORKIDENTIFIER)
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000234AC_SUBST(PYTHONFRAMEWORKDIR)
235AC_SUBST(PYTHONFRAMEWORKPREFIX)
236AC_SUBST(PYTHONFRAMEWORKINSTALLDIR)
Ronald Oussoren567a8ff2006-05-26 11:43:26 +0000237AC_SUBST(FRAMEWORKINSTALLFIRST)
238AC_SUBST(FRAMEWORKINSTALLLAST)
Ronald Oussoren5b787322006-06-06 19:50:24 +0000239AC_SUBST(FRAMEWORKALTINSTALLFIRST)
240AC_SUBST(FRAMEWORKALTINSTALLLAST)
241AC_SUBST(FRAMEWORKUNIXTOOLSPREFIX)
Guido van Rossum4b6b5791996-09-09 20:09:34 +0000242
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000243##AC_ARG_WITH(dyld,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000244## AC_HELP_STRING(--with-dyld,
245## Use (OpenStep|Rhapsody) dynamic linker))
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000246##
Guido van Rossumb418f891996-07-30 18:06:02 +0000247# Set name for machine-dependent library files
248AC_SUBST(MACHDEP)
249AC_MSG_CHECKING(MACHDEP)
250if test -z "$MACHDEP"
251then
Guido van Rossum4b6b5791996-09-09 20:09:34 +0000252 ac_sys_system=`uname -s`
Georg Brandlfe18a112009-09-04 07:55:14 +0000253 if test "$ac_sys_system" = "AIX" \
Martin v. Löwis21ee4092002-09-30 16:19:48 +0000254 -o "$ac_sys_system" = "UnixWare" -o "$ac_sys_system" = "OpenUNIX"; then
Guido van Rossum4b6b5791996-09-09 20:09:34 +0000255 ac_sys_release=`uname -v`
Guido van Rossumb418f891996-07-30 18:06:02 +0000256 else
Guido van Rossum4b6b5791996-09-09 20:09:34 +0000257 ac_sys_release=`uname -r`
Guido van Rossumb418f891996-07-30 18:06:02 +0000258 fi
Guido van Rossum4b6b5791996-09-09 20:09:34 +0000259 ac_md_system=`echo $ac_sys_system |
260 tr -d '[/ ]' | tr '[[A-Z]]' '[[a-z]]'`
261 ac_md_release=`echo $ac_sys_release |
Guido van Rossum67b26592001-10-20 14:21:45 +0000262 tr -d '[/ ]' | sed 's/^[[A-Z]]\.//' | sed 's/\..*//'`
Guido van Rossumb97ef171997-09-28 05:44:03 +0000263 MACHDEP="$ac_md_system$ac_md_release"
Guido van Rossum4b6b5791996-09-09 20:09:34 +0000264
Guido van Rossumbcd91e01997-03-20 20:46:29 +0000265 case $MACHDEP in
Andrew M. Kuchling5a3e4cb2001-07-20 19:29:04 +0000266 cygwin*) MACHDEP="cygwin";;
Jack Jansen8a97f4a2001-12-05 23:27:32 +0000267 darwin*) MACHDEP="darwin";;
Martin v. Löwisf90ae202002-06-11 06:22:31 +0000268 atheos*) MACHDEP="atheos";;
Martin v. Löwisf3322282003-07-13 09:46:13 +0000269 irix646) MACHDEP="irix6";;
Guido van Rossumb97ef171997-09-28 05:44:03 +0000270 '') MACHDEP="unknown";;
Guido van Rossumb418f891996-07-30 18:06:02 +0000271 esac
272fi
Jack Jansen83f898c2002-12-30 22:23:40 +0000273
Martin v. Löwise981a4e2002-11-11 13:26:51 +0000274# Some systems cannot stand _XOPEN_SOURCE being defined at all; they
275# disable features if it is defined, without any means to access these
276# features as extensions. For these systems, we skip the definition of
277# _XOPEN_SOURCE. Before adding a system to the list to gain access to
278# some feature, make sure there is no alternative way to access this
279# feature. Also, when using wildcards, make sure you have verified the
280# need for not defining _XOPEN_SOURCE on all systems matching the
281# wildcard, and that the wildcard does not include future systems
282# (which may remove their limitations).
283dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
284case $ac_sys_system/$ac_sys_release in
285 # On OpenBSD, select(2) is not available if _XOPEN_SOURCE is defined,
286 # even though select is a POSIX function. Reported by J. Ribbens.
Martin v. Löwis76bafc62003-10-03 13:47:44 +0000287 # Reconfirmed for OpenBSD 3.3 by Zachary Hamm, for 3.4 by Jason Ish.
Martin v. Löwis7875ef62010-02-15 21:41:12 +0000288 # In addition, Stefan Krah confirms that issue #1244610 exists through
289 # OpenBSD 4.6, but is fixed in 4.7.
290 OpenBSD/2.* | OpenBSD/3.@<:@0123456789@:>@ | OpenBSD/4.@<:@0123456@:>@)
Martin v. Löwiscb78de62007-12-29 18:49:21 +0000291 define_xopen_source=no
292 # OpenBSD undoes our definition of __BSD_VISIBLE if _XOPEN_SOURCE is
293 # also defined. This can be overridden by defining _BSD_SOURCE
294 # As this has a different meaning on Linux, only define it on OpenBSD
295 AC_DEFINE(_BSD_SOURCE, 1, [Define on OpenBSD to activate all library features])
296 ;;
Martin v. Löwis7875ef62010-02-15 21:41:12 +0000297 OpenBSD/4.@<:@789@:>@)
Martin v. Löwis5e2dd862010-02-15 08:32:00 +0000298 # OpenBSD undoes our definition of __BSD_VISIBLE if _XOPEN_SOURCE is
299 # also defined. This can be overridden by defining _BSD_SOURCE
300 # As this has a different meaning on Linux, only define it on OpenBSD
301 AC_DEFINE(_BSD_SOURCE, 1, [Define on OpenBSD to activate all library features])
302 ;;
Martin v. Löwis4d542ec2006-11-25 15:39:19 +0000303 # Defining _XOPEN_SOURCE on NetBSD version prior to the introduction of
304 # _NETBSD_SOURCE disables certain features (eg. setgroups). Reported by
305 # Marc Recht
Georg Brandl4b9bcfc2008-11-16 08:00:17 +0000306 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 +0000307 define_xopen_source=no;;
Martin v. Löwisa9d71422003-03-28 18:43:31 +0000308 # On Solaris 2.6, sys/wait.h is inconsistent in the usage
309 # of union __?sigval. Reported by Stuart Bishop.
310 SunOS/5.6)
311 define_xopen_source=no;;
Martin v. Löwisc2409b42003-05-11 05:53:41 +0000312 # On UnixWare 7, u_long is never defined with _XOPEN_SOURCE,
313 # but used in /usr/include/netinet/tcp.h. Reported by Tim Rice.
Martin v. Löwis253d1f42004-05-07 19:14:14 +0000314 # Reconfirmed for 7.1.4 by Martin v. Loewis.
315 OpenUNIX/8.0.0| UnixWare/7.1.@<:@0-4@:>@)
Martin v. Löwisc2409b42003-05-11 05:53:41 +0000316 define_xopen_source=no;;
317 # On OpenServer 5, u_short is never defined with _XOPEN_SOURCE,
Martin v. Löwis53e73c32003-05-05 05:13:18 +0000318 # but used in struct sockaddr.sa_family. Reported by Tim Rice.
Martin v. Löwisc2409b42003-05-11 05:53:41 +0000319 SCO_SV/3.2)
Martin v. Löwis53e73c32003-05-05 05:13:18 +0000320 define_xopen_source=no;;
Martin v. Löwisbb86d832008-11-04 20:40:09 +0000321 # On FreeBSD 4, the math functions C89 does not cover are never defined
322 # with _XOPEN_SOURCE and __BSD_VISIBLE does not re-enable them.
323 FreeBSD/4.*)
324 define_xopen_source=no;;
325 # On MacOS X 10.2, a bug in ncurses.h means that it craps out if
326 # _XOPEN_EXTENDED_SOURCE is defined. Apparently, this is fixed in 10.3, which
327 # identifies itself as Darwin/7.*
328 # On Mac OS X 10.4, defining _POSIX_C_SOURCE or _XOPEN_SOURCE
329 # disables platform specific features beyond repair.
330 # On Mac OS X 10.3, defining _POSIX_C_SOURCE or _XOPEN_SOURCE
331 # has no effect, don't bother defining them
332 Darwin/@<:@6789@:>@.*)
Anthony Baxter6169c6b2003-10-04 07:46:23 +0000333 define_xopen_source=no;;
Ronald Oussorena55af9a2010-01-17 16:25:57 +0000334 Darwin/1@<:@0-9@:>@.*)
335 define_xopen_source=no;;
Trent Mickaf16e8c2004-08-25 23:55:59 +0000336 # On AIX 4 and 5.1, mbstate_t is defined only when _XOPEN_SOURCE == 500 but
337 # used in wcsnrtombs() and mbsnrtowcs() even if _XOPEN_SOURCE is not defined
338 # or has another value. By not (re)defining it, the defaults come in place.
Martin v. Löwisc19c5a62003-11-18 20:00:44 +0000339 AIX/4)
340 define_xopen_source=no;;
Trent Mickaf16e8c2004-08-25 23:55:59 +0000341 AIX/5)
342 if test `uname -r` -eq 1; then
343 define_xopen_source=no
344 fi
345 ;;
Martin v. Löwis8c255e42008-05-23 15:06:50 +0000346 # On QNX 6.3.2, defining _XOPEN_SOURCE prevents netdb.h from
347 # defining NI_NUMERICHOST.
348 QNX/6.3.2)
349 define_xopen_source=no
350 ;;
Martin v. Löwisa0588362006-04-04 06:03:50 +0000351
Martin v. Löwise981a4e2002-11-11 13:26:51 +0000352esac
353
354if test $define_xopen_source = yes
355then
Skip Montanarof0d5f792004-08-15 14:08:23 +0000356 # On Solaris w/ g++ it appears that _XOPEN_SOURCE has to be
357 # defined precisely as g++ defines it
Martin v. Löwis7dece662005-11-26 11:38:24 +0000358 # Furthermore, on Solaris 10, XPG6 requires the use of a C99
359 # compiler
Skip Montanarof0d5f792004-08-15 14:08:23 +0000360 case $ac_sys_system/$ac_sys_release in
Martin v. Löwis7dece662005-11-26 11:38:24 +0000361 SunOS/5.8|SunOS/5.9|SunOS/5.10)
Skip Montanarof0d5f792004-08-15 14:08:23 +0000362 AC_DEFINE(_XOPEN_SOURCE, 500,
363 Define to the level of X/Open that your system supports)
364 ;;
365 *)
366 AC_DEFINE(_XOPEN_SOURCE, 600,
367 Define to the level of X/Open that your system supports)
368 ;;
369 esac
Martin v. Löwis678fc1e2002-11-12 06:04:39 +0000370
371 # On Tru64 Unix 4.0F, defining _XOPEN_SOURCE also requires
372 # definition of _XOPEN_SOURCE_EXTENDED and _POSIX_C_SOURCE, or else
373 # several APIs are not declared. Since this is also needed in some
374 # cases for HP-UX, we define it globally.
Martin v. Löwis7dece662005-11-26 11:38:24 +0000375 # except for Solaris 10, where it must not be defined,
376 # as it implies XPG4.2
377 case $ac_sys_system/$ac_sys_release in
378 SunOS/5.10)
379 ;;
380 *)
381 AC_DEFINE(_XOPEN_SOURCE_EXTENDED, 1,
382 Define to activate Unix95-and-earlier features)
383 ;;
384 esac
Martin v. Löwis678fc1e2002-11-12 06:04:39 +0000385
Bob Ippolito7026a0a2005-03-28 23:23:47 +0000386 AC_DEFINE(_POSIX_C_SOURCE, 200112L, Define to activate features from IEEE Stds 1003.1-2001)
387
Martin v. Löwise981a4e2002-11-11 13:26:51 +0000388fi
389
Guido van Rossum91922671997-10-09 20:24:13 +0000390#
391# SGI compilers allow the specification of the both the ABI and the
392# ISA on the command line. Depending on the values of these switches,
393# different and often incompatable code will be generated.
394#
395# The SGI_ABI variable can be used to modify the CC and LDFLAGS and
396# thus supply support for various ABI/ISA combinations. The MACHDEP
397# variable is also adjusted.
398#
399AC_SUBST(SGI_ABI)
400if test ! -z "$SGI_ABI"
401then
402 CC="cc $SGI_ABI"
403 LDFLAGS="$SGI_ABI $LDFLAGS"
404 MACHDEP=`echo "${MACHDEP}${SGI_ABI}" | sed 's/ *//g'`
405fi
Guido van Rossumb418f891996-07-30 18:06:02 +0000406AC_MSG_RESULT($MACHDEP)
407
Jack Jansen83f898c2002-12-30 22:23:40 +0000408# And add extra plat-mac for darwin
409AC_SUBST(EXTRAPLATDIR)
Jack Jansen7b59b422003-03-17 15:44:10 +0000410AC_SUBST(EXTRAMACHDEPPATH)
Jack Jansen83f898c2002-12-30 22:23:40 +0000411AC_MSG_CHECKING(EXTRAPLATDIR)
412if test -z "$EXTRAPLATDIR"
413then
414 case $MACHDEP in
Jack Jansen7b59b422003-03-17 15:44:10 +0000415 darwin)
416 EXTRAPLATDIR="\$(PLATMACDIRS)"
417 EXTRAMACHDEPPATH="\$(PLATMACPATH)"
418 ;;
419 *)
420 EXTRAPLATDIR=""
421 EXTRAMACHDEPPATH=""
422 ;;
Jack Jansen83f898c2002-12-30 22:23:40 +0000423 esac
424fi
425AC_MSG_RESULT($EXTRAPLATDIR)
426
Jack Jansen6b08a402004-06-03 12:41:45 +0000427# Record the configure-time value of MACOSX_DEPLOYMENT_TARGET,
428# it may influence the way we can build extensions, so distutils
429# needs to check it
430AC_SUBST(CONFIGURE_MACOSX_DEPLOYMENT_TARGET)
Ronald Oussoren988117f2006-04-29 11:31:35 +0000431AC_SUBST(EXPORT_MACOSX_DEPLOYMENT_TARGET)
Jack Jansen6b08a402004-06-03 12:41:45 +0000432CONFIGURE_MACOSX_DEPLOYMENT_TARGET=
Ronald Oussoren988117f2006-04-29 11:31:35 +0000433EXPORT_MACOSX_DEPLOYMENT_TARGET='#'
Jack Jansen6b08a402004-06-03 12:41:45 +0000434
Mark Dickinson65134662008-04-25 16:11:04 +0000435AC_MSG_CHECKING(machine type as reported by uname -m)
436ac_sys_machine=`uname -m`
437AC_MSG_RESULT($ac_sys_machine)
438
Guido van Rossum627b2d71993-12-24 10:39:16 +0000439# checks for alternative programs
Skip Montanarodecc6a42003-01-01 20:07:49 +0000440
441# compiler flags are generated in two sets, BASECFLAGS and OPT. OPT is just
442# for debug/optimization stuff. BASECFLAGS is for flags that are required
443# just to get things to compile and link. Users are free to override OPT
444# when running configure or make. The build should not break if they do.
445# BASECFLAGS should generally not be messed with, however.
446
447# XXX shouldn't some/most/all of this code be merged with the stuff later
448# on that fiddles with OPT and BASECFLAGS?
Guido van Rossum5739e7e1995-01-20 16:50:53 +0000449AC_MSG_CHECKING(for --without-gcc)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000450AC_ARG_WITH(gcc,
451 AC_HELP_STRING(--without-gcc,never use gcc),
452[
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000453 case $withval in
Skip Montanaro516144f2009-01-04 10:36:58 +0000454 no) CC=${CC:-cc}
Guido van Rossum5739e7e1995-01-20 16:50:53 +0000455 without_gcc=yes;;
456 yes) CC=gcc
457 without_gcc=no;;
458 *) CC=$withval
459 without_gcc=$withval;;
Guido van Rossum55a214e1995-09-13 17:48:09 +0000460 esac], [
Guido van Rossumb418f891996-07-30 18:06:02 +0000461 case $ac_sys_system in
Neil Schemenauerb3531b82001-02-16 04:09:05 +0000462 AIX*) CC=cc_r
463 without_gcc=;;
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000464 BeOS*)
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000465 case $BE_HOST_CPU in
466 ppc)
Fred Drake5790be12000-10-09 17:06:13 +0000467 CC=mwcc
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000468 without_gcc=yes
Skip Montanarodecc6a42003-01-01 20:07:49 +0000469 BASECFLAGS="$BASECFLAGS -export pragma"
470 OPT="$OPT -O"
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000471 LDFLAGS="$LDFLAGS -nodup"
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000472 ;;
473 x86)
Fred Drake5790be12000-10-09 17:06:13 +0000474 CC=gcc
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000475 without_gcc=no
Skip Montanarodecc6a42003-01-01 20:07:49 +0000476 OPT="$OPT -O"
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000477 ;;
478 *)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000479 AC_MSG_ERROR([Unknown BeOS platform "$BE_HOST_CPU"])
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000480 ;;
481 esac
Neil Schemenauerb3531b82001-02-16 04:09:05 +0000482 AR="\$(srcdir)/Modules/ar_beos"
483 RANLIB=:
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000484 ;;
Martin v. Löwis130fb172001-07-19 11:00:41 +0000485 *) without_gcc=no;;
Guido van Rossum55a214e1995-09-13 17:48:09 +0000486 esac])
Guido van Rossum5739e7e1995-01-20 16:50:53 +0000487AC_MSG_RESULT($without_gcc)
488
Guido van Rossum03ad99f1995-03-09 14:09:54 +0000489# If the user switches compilers, we can't believe the cache
490if test ! -z "$ac_cv_prog_CC" -a ! -z "$CC" -a "$CC" != "$ac_cv_prog_CC"
491then
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000492 AC_MSG_ERROR([cached CC is different -- throw away $cache_file
493(it is also a good idea to do 'make clean' before compiling)])
Guido van Rossum03ad99f1995-03-09 14:09:54 +0000494fi
495
Victor Stinner6cbf90f2010-03-25 00:21:53 +0000496save_CFLAGS=$CFLAGS
Guido van Rossum627b2d71993-12-24 10:39:16 +0000497AC_PROG_CC
Victor Stinner6cbf90f2010-03-25 00:21:53 +0000498CFLAGS=$save_CFLAGS
Martin v. Löwis1d5ecb72001-08-09 10:29:44 +0000499
Martin v. Löwis0f48d982006-04-14 14:34:26 +0000500AC_SUBST(CXX)
501AC_SUBST(MAINCC)
502AC_MSG_CHECKING(for --with-cxx-main=<compiler>)
503AC_ARG_WITH(cxx_main,
504 AC_HELP_STRING([--with-cxx-main=<compiler>],
505 [compile main() and link python executable with C++ compiler]),
506[
507
508 case $withval in
509 no) with_cxx_main=no
510 MAINCC='$(CC)';;
511 yes) with_cxx_main=yes
512 MAINCC='$(CXX)';;
513 *) with_cxx_main=yes
514 MAINCC=$withval
515 if test -z "$CXX"
516 then
517 CXX=$withval
518 fi;;
519 esac], [
520 with_cxx_main=no
521 MAINCC='$(CC)'
522])
523AC_MSG_RESULT($with_cxx_main)
524
525preset_cxx="$CXX"
526if test -z "$CXX"
527then
528 case "$CC" in
529 gcc) AC_PATH_PROG(CXX, [g++], [g++], [notfound]) ;;
530 cc) AC_PATH_PROG(CXX, [c++], [c++], [notfound]) ;;
531 esac
532 if test "$CXX" = "notfound"
533 then
534 CXX=""
535 fi
536fi
537if test -z "$CXX"
538then
539 AC_CHECK_PROGS(CXX, $CCC c++ g++ gcc CC cxx cc++ cl, notfound)
540 if test "$CXX" = "notfound"
541 then
542 CXX=""
543 fi
544fi
545if test "$preset_cxx" != "$CXX"
546then
547 AC_MSG_WARN([
548
549 By default, distutils will build C++ extension modules with "$CXX".
550 If this is not intended, then set CXX on the configure command line.
551 ])
552fi
553
554
Martin v. Löwis1d5ecb72001-08-09 10:29:44 +0000555# checks for UNIX variants that set C preprocessor variables
556AC_AIX
Martin v. Löwis1d5ecb72001-08-09 10:29:44 +0000557
Martin v. Löwis779ffc02002-12-02 22:17:01 +0000558# Check for unsupported systems
559case $ac_sys_system/$ac_sys_release in
Brett Cannon19fab762007-06-02 03:02:29 +0000560atheos*|Linux*/1*)
Martin v. Löwis779ffc02002-12-02 22:17:01 +0000561 echo This system \($ac_sys_system/$ac_sys_release\) is no longer supported.
562 echo See README for details.
563 exit 1;;
564esac
565
Neil Schemenauer55f0cf32001-01-24 17:24:33 +0000566AC_EXEEXT
Neil Schemenauer3ae1d0a2001-01-27 06:54:42 +0000567AC_MSG_CHECKING(for --with-suffix)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000568AC_ARG_WITH(suffix,
569 AC_HELP_STRING(--with-suffix=.exe, set executable suffix),
570[
Neil Schemenauer3ae1d0a2001-01-27 06:54:42 +0000571 case $withval in
572 no) EXEEXT=;;
573 yes) EXEEXT=.exe;;
574 *) EXEEXT=$withval;;
575 esac])
576AC_MSG_RESULT($EXEEXT)
Jack Jansen1999ef42001-12-06 21:47:20 +0000577
Jack Jansen9a66b6d2001-08-08 13:56:14 +0000578# Test whether we're running on a non-case-sensitive system, in which
579# case we give a warning if no ext is given
Jack Jansen1999ef42001-12-06 21:47:20 +0000580AC_SUBST(BUILDEXEEXT)
581AC_MSG_CHECKING(for case-insensitive build directory)
Jack Jansen3c2c4332002-11-06 13:33:32 +0000582if test ! -d CaseSensitiveTestDir; then
583mkdir CaseSensitiveTestDir
584fi
585
586if test -d casesensitivetestdir
Jack Jansen9a66b6d2001-08-08 13:56:14 +0000587then
Jack Jansen1999ef42001-12-06 21:47:20 +0000588 AC_MSG_RESULT(yes)
589 BUILDEXEEXT=.exe
590else
591 AC_MSG_RESULT(no)
Jack Jansendd19cf82001-12-06 22:36:17 +0000592 BUILDEXEEXT=$EXEEXT
Jack Jansen9a66b6d2001-08-08 13:56:14 +0000593fi
Jack Jansen3c2c4332002-11-06 13:33:32 +0000594rmdir CaseSensitiveTestDir
Guido van Rossumfb842551997-08-06 23:42:07 +0000595
Guido van Rossumdd997f71998-10-07 19:58:26 +0000596case $MACHDEP in
597bsdos*)
598 case $CC in
599 gcc) CC="$CC -D_HAVE_BSDI";;
600 esac;;
601esac
602
Guido van Rossum84561611997-08-21 00:08:11 +0000603case $ac_sys_system in
604hp*|HP*)
605 case $CC in
Guido van Rossumcd5ff9f2000-09-22 16:15:54 +0000606 cc|*/cc) CC="$CC -Ae";;
Guido van Rossum84561611997-08-21 00:08:11 +0000607 esac;;
Martin v. Löwise8964d42001-03-06 12:09:07 +0000608SunOS*)
609 # Some functions have a prototype only with that define, e.g. confstr
Martin v. Löwisc45929e2002-04-06 10:10:49 +0000610 AC_DEFINE(__EXTENSIONS__, 1, [Defined on Solaris to see additional function prototypes.])
Martin v. Löwise8964d42001-03-06 12:09:07 +0000611 ;;
Guido van Rossum84561611997-08-21 00:08:11 +0000612esac
613
Martin v. Löwise8964d42001-03-06 12:09:07 +0000614
Neil Schemenauer61c51152001-01-26 16:18:16 +0000615AC_SUBST(LIBRARY)
616AC_MSG_CHECKING(LIBRARY)
617if test -z "$LIBRARY"
618then
619 LIBRARY='libpython$(VERSION).a'
620fi
621AC_MSG_RESULT($LIBRARY)
622
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000623# LDLIBRARY is the name of the library to link against (as opposed to the
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000624# name of the library into which to insert object files). BLDLIBRARY is also
625# the library to link against, usually. On Mac OS X frameworks, BLDLIBRARY
626# is blank as the main program is not linked directly against LDLIBRARY.
627# LDLIBRARYDIR is the path to LDLIBRARY, which is made in a subdirectory. On
628# systems without shared libraries, LDLIBRARY is the same as LIBRARY
629# (defined in the Makefiles). On Cygwin LDLIBRARY is the import library,
630# DLLLIBRARY is the shared (i.e., DLL) library.
631#
Martin v. Löwis1142de32002-03-29 16:28:31 +0000632# RUNSHARED is used to run shared python without installed libraries
633#
634# INSTSONAME is the name of the shared library that will be use to install
635# on the system - some systems like version suffix, others don't
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000636AC_SUBST(LDLIBRARY)
Guido van Rossum27552902001-01-23 01:52:26 +0000637AC_SUBST(DLLLIBRARY)
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000638AC_SUBST(BLDLIBRARY)
639AC_SUBST(LDLIBRARYDIR)
Martin v. Löwis1142de32002-03-29 16:28:31 +0000640AC_SUBST(INSTSONAME)
641AC_SUBST(RUNSHARED)
Neil Schemenauer61c51152001-01-26 16:18:16 +0000642LDLIBRARY="$LIBRARY"
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000643BLDLIBRARY='$(LDLIBRARY)'
Martin v. Löwis09bdf722002-05-08 08:51:29 +0000644INSTSONAME='$(LDLIBRARY)'
Guido van Rossum27552902001-01-23 01:52:26 +0000645DLLLIBRARY=''
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000646LDLIBRARYDIR=''
Martin v. Löwis1142de32002-03-29 16:28:31 +0000647RUNSHARED=''
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000648
Guido van Rossumfb842551997-08-06 23:42:07 +0000649# LINKCC is the command that links the python executable -- default is $(CC).
Martin v. Löwisb7da67a2001-10-18 15:35:38 +0000650# If CXX is set, and if it is needed to link a main function that was
651# compiled with CXX, LINKCC is CXX instead. Always using CXX is undesirable:
652# python might then depend on the C++ runtime
Fred Drake5790be12000-10-09 17:06:13 +0000653# This is altered for AIX in order to build the export list before
Guido van Rossumec95c7b1998-08-04 17:59:56 +0000654# linking.
Guido van Rossumfb842551997-08-06 23:42:07 +0000655AC_SUBST(LINKCC)
656AC_MSG_CHECKING(LINKCC)
657if test -z "$LINKCC"
658then
Martin v. Löwis0f48d982006-04-14 14:34:26 +0000659 LINKCC='$(PURIFY) $(MAINCC)'
Guido van Rossumfb842551997-08-06 23:42:07 +0000660 case $ac_sys_system in
661 AIX*)
Neal Norwitz0b27ff92003-03-31 15:53:49 +0000662 exp_extra="\"\""
663 if test $ac_sys_release -ge 5 -o \
664 $ac_sys_release -eq 4 -a `uname -r` -ge 2 ; then
665 exp_extra="."
666 fi
667 LINKCC="\$(srcdir)/Modules/makexp_aix Modules/python.exp $exp_extra \$(LIBRARY); $LINKCC";;
Martin v. Löwis8c255e42008-05-23 15:06:50 +0000668 QNX*)
669 # qcc must be used because the other compilers do not
670 # support -N.
671 LINKCC=qcc;;
Guido van Rossumfb842551997-08-06 23:42:07 +0000672 esac
673fi
674AC_MSG_RESULT($LINKCC)
675
Tarek Ziadée2be83d2009-05-09 08:28:53 +0000676# GNULD is set to "yes" if the GNU linker is used. If this goes wrong
677# make sure we default having it set to "no": this is used by
678# distutils.unixccompiler to know if it should add --enable-new-dtags
679# to linker command lines, and failing to detect GNU ld simply results
680# in the same bahaviour as before.
681AC_SUBST(GNULD)
682AC_MSG_CHECKING(for GNU ld)
683ac_prog=ld
684if test "$GCC" = yes; then
685 ac_prog=`$CC -print-prog-name=ld`
686fi
687case `"$ac_prog" -V 2>&1 < /dev/null` in
688 *GNU*)
689 GNULD=yes;;
690 *)
691 GNULD=no;;
692esac
693AC_MSG_RESULT($GNULD)
694
Martin v. Löwis1142de32002-03-29 16:28:31 +0000695AC_MSG_CHECKING(for --enable-shared)
696AC_ARG_ENABLE(shared,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000697 AC_HELP_STRING(--enable-shared, disable/enable building shared python library))
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000698
Martin v. Löwis1142de32002-03-29 16:28:31 +0000699if test -z "$enable_shared"
700then
Martin v. Löwisb51033d2002-05-03 05:53:15 +0000701 case $ac_sys_system in
Martin v. Löwisf90ae202002-06-11 06:22:31 +0000702 CYGWIN* | atheos*)
Martin v. Löwisb51033d2002-05-03 05:53:15 +0000703 enable_shared="yes";;
704 *)
705 enable_shared="no";;
706 esac
Martin v. Löwis1142de32002-03-29 16:28:31 +0000707fi
708AC_MSG_RESULT($enable_shared)
709
Skip Montanaro56f6a4f2004-06-18 02:47:22 +0000710AC_MSG_CHECKING(for --enable-profiling)
711AC_ARG_ENABLE(profiling,
712 AC_HELP_STRING(--enable-profiling, enable C-level code profiling),
713[ac_save_cc="$CC"
714 CC="$CC -pg"
715 AC_TRY_RUN([int main() { return 0; }],
716 ac_enable_profiling="yes",
717 ac_enable_profiling="no",
718 ac_enable_profiling="no")
719 CC="$ac_save_cc"])
720AC_MSG_RESULT($ac_enable_profiling)
721
722case "$ac_enable_profiling" in
723 "yes")
724 BASECFLAGS="-pg $BASECFLAGS"
725 LDFLAGS="-pg $LDFLAGS"
726 ;;
727esac
Martin v. Löwis1142de32002-03-29 16:28:31 +0000728
729AC_MSG_CHECKING(LDLIBRARY)
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000730
Guido van Rossumb8552162001-09-05 14:58:11 +0000731# MacOSX framework builds need more magic. LDLIBRARY is the dynamic
732# library that we build, but we do not want to link against it (we
733# will find it with a -framework option). For this reason there is an
734# extra variable BLDLIBRARY against which Python and the extension
735# modules are linked, BLDLIBRARY. This is normally the same as
736# LDLIBRARY, but empty for MacOSX framework builds.
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000737if test "$enable_framework"
738then
739 LDLIBRARY='$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansen66b84832003-07-04 12:14:39 +0000740 RUNSHARED=DYLD_FRAMEWORK_PATH="`pwd`:$DYLD_FRAMEWORK_PATH"
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000741 BLDLIBRARY=''
742else
743 BLDLIBRARY='$(LDLIBRARY)'
744fi
745
Martin v. Löwis1142de32002-03-29 16:28:31 +0000746# Other platforms follow
747if test $enable_shared = "yes"; then
Mark Hammond8235ea12002-07-19 06:55:41 +0000748 AC_DEFINE(Py_ENABLE_SHARED, 1, [Defined if Python is built as a shared library.])
Martin v. Löwis1142de32002-03-29 16:28:31 +0000749 case $ac_sys_system in
750 BeOS*)
751 LDLIBRARY='libpython$(VERSION).so'
752 ;;
753 CYGWIN*)
754 LDLIBRARY='libpython$(VERSION).dll.a'
755 DLLLIBRARY='libpython$(VERSION).dll'
756 ;;
757 SunOS*)
758 LDLIBRARY='libpython$(VERSION).so'
Martin v. Löwisd141a8c2003-06-14 15:20:28 +0000759 BLDLIBRARY='-Wl,-R,$(LIBDIR) -L. -lpython$(VERSION)'
Martin v. Löwisfc9b75f2003-08-09 09:06:52 +0000760 RUNSHARED=LD_LIBRARY_PATH=`pwd`:${LD_LIBRARY_PATH}
Martin v. Löwis2389c412003-10-31 15:42:07 +0000761 INSTSONAME="$LDLIBRARY".$SOVERSION
Martin v. Löwis1142de32002-03-29 16:28:31 +0000762 ;;
Martin v. Löwis86d66262006-02-17 08:40:11 +0000763 Linux*|GNU*|NetBSD*|FreeBSD*|DragonFly*)
Martin v. Löwis1142de32002-03-29 16:28:31 +0000764 LDLIBRARY='libpython$(VERSION).so'
765 BLDLIBRARY='-L. -lpython$(VERSION)'
Martin v. Löwisfc9b75f2003-08-09 09:06:52 +0000766 RUNSHARED=LD_LIBRARY_PATH=`pwd`:${LD_LIBRARY_PATH}
Hye-Shik Chang33761492004-10-26 09:53:46 +0000767 case $ac_sys_system in
768 FreeBSD*)
769 SOVERSION=`echo $SOVERSION|cut -d "." -f 1`
770 ;;
771 esac
Martin v. Löwis1142de32002-03-29 16:28:31 +0000772 INSTSONAME="$LDLIBRARY".$SOVERSION
773 ;;
774 hp*|HP*)
Neal Norwitz58e28882006-05-19 07:00:58 +0000775 case `uname -m` in
776 ia64)
777 LDLIBRARY='libpython$(VERSION).so'
778 ;;
779 *)
780 LDLIBRARY='libpython$(VERSION).sl'
781 ;;
782 esac
Martin v. Löwis1142de32002-03-29 16:28:31 +0000783 BLDLIBRARY='-Wl,+b,$(LIBDIR) -L. -lpython$(VERSION)'
Martin v. Löwisfc9b75f2003-08-09 09:06:52 +0000784 RUNSHARED=SHLIB_PATH=`pwd`:${SHLIB_PATH}
Martin v. Löwis1142de32002-03-29 16:28:31 +0000785 ;;
786 OSF*)
787 LDLIBRARY='libpython$(VERSION).so'
Neal Norwitz671b9e32006-01-09 07:07:12 +0000788 BLDLIBRARY='-rpath $(LIBDIR) -L. -lpython$(VERSION)'
Martin v. Löwisfc9b75f2003-08-09 09:06:52 +0000789 RUNSHARED=LD_LIBRARY_PATH=`pwd`:${LD_LIBRARY_PATH}
Martin v. Löwis1142de32002-03-29 16:28:31 +0000790 ;;
Martin v. Löwisf90ae202002-06-11 06:22:31 +0000791 atheos*)
792 LDLIBRARY='libpython$(VERSION).so'
793 BLDLIBRARY='-L. -lpython$(VERSION)'
794 RUNSHARED=DLL_PATH=`pwd`:${DLL_PATH:-/atheos/sys/libs:/atheos/autolnk/lib}
795 ;;
Ronald Oussoren79f90492009-01-02 10:44:46 +0000796 Darwin*)
797 LDLIBRARY='libpython$(VERSION).dylib'
798 BLDLIBRARY='-L. -lpython$(VERSION)'
799 RUNSHARED='DYLD_LIBRARY_PATH=`pwd`:${DYLD_LIBRARY_PATH}'
800 ;;
801
Martin v. Löwis1142de32002-03-29 16:28:31 +0000802 esac
Jason Tishler30765592003-09-04 11:04:06 +0000803else # shared is disabled
804 case $ac_sys_system in
805 CYGWIN*)
806 BLDLIBRARY='$(LIBRARY)'
807 LDLIBRARY='libpython$(VERSION).dll.a'
808 ;;
809 esac
Martin v. Löwis1142de32002-03-29 16:28:31 +0000810fi
811
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000812AC_MSG_RESULT($LDLIBRARY)
813
Guido van Rossum627b2d71993-12-24 10:39:16 +0000814AC_PROG_RANLIB
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000815AC_SUBST(AR)
Guido van Rossum76be6ed1995-01-02 18:33:54 +0000816AC_CHECK_PROGS(AR, ar aal, ar)
Neil Schemenauera42c8272001-03-31 00:01:55 +0000817
Tarek Ziadé99f660a2009-05-07 21:20:34 +0000818# tweak ARFLAGS only if the user didn't set it on the command line
819AC_SUBST(ARFLAGS)
820if test -z "$ARFLAGS"
821then
822 ARFLAGS="rc"
823fi
824
Martin v. Löwisdea59e52006-01-05 10:00:36 +0000825AC_SUBST(SVNVERSION)
Martin v. Löwisff600232006-04-03 19:12:32 +0000826AC_CHECK_PROG(SVNVERSION, svnversion, found, not-found)
Martin v. Löwisc5bf5a02006-01-05 10:33:59 +0000827if test $SVNVERSION = found
828then
829 SVNVERSION="svnversion \$(srcdir)"
830else
Benjamin Petersone5afa3b2009-05-23 19:24:37 +0000831 SVNVERSION="echo Unversioned directory"
Martin v. Löwisc5bf5a02006-01-05 10:33:59 +0000832fi
Martin v. Löwisdea59e52006-01-05 10:00:36 +0000833
Neil Schemenauera42c8272001-03-31 00:01:55 +0000834case $MACHDEP in
Neil Schemenaueraf5567f2001-10-21 22:32:04 +0000835bsdos*|hp*|HP*)
836 # install -d does not work on BSDI or HP-UX
Neil Schemenauera42c8272001-03-31 00:01:55 +0000837 if test -z "$INSTALL"
838 then
839 INSTALL="${srcdir}/install-sh -c"
840 fi
841esac
Neil Schemenauer55f0cf32001-01-24 17:24:33 +0000842AC_PROG_INSTALL
Guido van Rossumb418f891996-07-30 18:06:02 +0000843
Guido van Rossumec95c7b1998-08-04 17:59:56 +0000844# Not every filesystem supports hard links
845AC_SUBST(LN)
846if test -z "$LN" ; then
847 case $ac_sys_system in
848 BeOS*) LN="ln -s";;
Guido van Rossumaef734b2001-01-10 21:09:12 +0000849 CYGWIN*) LN="ln -s";;
Martin v. Löwisf90ae202002-06-11 06:22:31 +0000850 atheos*) LN="ln -s";;
Guido van Rossumec95c7b1998-08-04 17:59:56 +0000851 *) LN=ln;;
852 esac
853fi
854
Fred Drake9f715822001-07-11 06:27:00 +0000855# Check for --with-pydebug
856AC_MSG_CHECKING(for --with-pydebug)
857AC_ARG_WITH(pydebug,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000858 AC_HELP_STRING(--with-pydebug, build with Py_DEBUG defined),
859[
Fred Drake9f715822001-07-11 06:27:00 +0000860if test "$withval" != no
Martin v. Löwisc45929e2002-04-06 10:10:49 +0000861then
862 AC_DEFINE(Py_DEBUG, 1,
863 [Define if you want to build an interpreter with many run-time checks.])
864 AC_MSG_RESULT(yes);
865 Py_DEBUG='true'
Fred Drake9f715822001-07-11 06:27:00 +0000866else AC_MSG_RESULT(no); Py_DEBUG='false'
867fi],
868[AC_MSG_RESULT(no)])
869
Skip Montanarodecc6a42003-01-01 20:07:49 +0000870# XXX Shouldn't the code above that fiddles with BASECFLAGS and OPT be
871# merged with this chunk of code?
872
Neil Schemenauer55f0cf32001-01-24 17:24:33 +0000873# Optimizer/debugger flags
Skip Montanarodecc6a42003-01-01 20:07:49 +0000874# ------------------------
875# (The following bit of code is complicated enough - please keep things
876# indented properly. Just pretend you're editing Python code. ;-)
877
878# There are two parallel sets of case statements below, one that checks to
879# see if OPT was set and one that does BASECFLAGS setting based upon
880# compiler and platform. BASECFLAGS tweaks need to be made even if the
881# user set OPT.
882
883# tweak OPT based on compiler and platform, only if the user didn't set
884# it on the command line
Guido van Rossumb418f891996-07-30 18:06:02 +0000885AC_SUBST(OPT)
Benjamin Petersond4b721b2010-03-23 20:58:37 +0000886if test "${OPT-unset}" = "unset"
Guido van Rossumb418f891996-07-30 18:06:02 +0000887then
Skip Montanarodecc6a42003-01-01 20:07:49 +0000888 case $GCC in
889 yes)
Skip Montanaro288a5be2006-04-13 02:00:56 +0000890 if test "$CC" != 'g++' ; then
891 STRICT_PROTO="-Wstrict-prototypes"
892 fi
Guido van Rossum7c862f82007-12-13 20:50:10 +0000893 # For gcc 4.x we need to use -fwrapv so lets check if its supported
894 if "$CC" -v --help 2>/dev/null |grep -- -fwrapv > /dev/null; then
895 WRAP="-fwrapv"
896 fi
Skip Montanarodecc6a42003-01-01 20:07:49 +0000897 case $ac_cv_prog_cc_g in
Guido van Rossum2242f2f2001-04-11 20:58:20 +0000898 yes)
Fred Drake9f715822001-07-11 06:27:00 +0000899 if test "$Py_DEBUG" = 'true' ; then
900 # Optimization messes up debuggers, so turn it off for
901 # debug builds.
Skip Montanaro288a5be2006-04-13 02:00:56 +0000902 OPT="-g -Wall $STRICT_PROTO"
Fred Drake9f715822001-07-11 06:27:00 +0000903 else
Guido van Rossum7c862f82007-12-13 20:50:10 +0000904 OPT="-g $WRAP -O3 -Wall $STRICT_PROTO"
Skip Montanarodecc6a42003-01-01 20:07:49 +0000905 fi
906 ;;
Guido van Rossum2242f2f2001-04-11 20:58:20 +0000907 *)
Skip Montanaro288a5be2006-04-13 02:00:56 +0000908 OPT="-O3 -Wall $STRICT_PROTO"
Skip Montanarodecc6a42003-01-01 20:07:49 +0000909 ;;
Fred Drake9f715822001-07-11 06:27:00 +0000910 esac
Martin v. Löwis21ee4092002-09-30 16:19:48 +0000911 case $ac_sys_system in
Skip Montanarodecc6a42003-01-01 20:07:49 +0000912 SCO_SV*) OPT="$OPT -m486 -DSCO5"
913 ;;
914 esac
Fred Drake9f715822001-07-11 06:27:00 +0000915 ;;
Skip Montanarodecc6a42003-01-01 20:07:49 +0000916
Guido van Rossum2242f2f2001-04-11 20:58:20 +0000917 *)
Skip Montanarodecc6a42003-01-01 20:07:49 +0000918 OPT="-O"
919 ;;
Guido van Rossum2242f2f2001-04-11 20:58:20 +0000920 esac
Guido van Rossum4e8af441994-08-19 15:33:54 +0000921fi
Guido van Rossum627b2d71993-12-24 10:39:16 +0000922
Skip Montanarodecc6a42003-01-01 20:07:49 +0000923AC_SUBST(BASECFLAGS)
Ronald Oussoren5640ce22008-06-05 12:58:24 +0000924
925# The -arch flags for universal builds on OSX
926UNIVERSAL_ARCH_FLAGS=
927AC_SUBST(UNIVERSAL_ARCH_FLAGS)
928
Skip Montanarodecc6a42003-01-01 20:07:49 +0000929# tweak BASECFLAGS based on compiler and platform
930case $GCC in
931yes)
Martin v. Löwis70fedcd2003-07-07 21:26:19 +0000932 # Python violates C99 rules, by casting between incompatible
933 # pointer types. GCC may generate bad code as a result of that,
934 # so use -fno-strict-aliasing if supported.
935 AC_MSG_CHECKING(whether $CC accepts -fno-strict-aliasing)
936 ac_save_cc="$CC"
937 CC="$CC -fno-strict-aliasing"
Alexandre Vassalotti00900892009-07-17 05:26:39 +0000938 AC_CACHE_VAL(ac_cv_no_strict_aliasing_ok,
Gregory P. Smithec3b8bd2009-11-01 21:02:52 +0000939 AC_TRY_COMPILE([],[int main() { return 0; }],
Martin v. Löwis70fedcd2003-07-07 21:26:19 +0000940 ac_cv_no_strict_aliasing_ok=yes,
Alexandre Vassalotti00900892009-07-17 05:26:39 +0000941 ac_cv_no_strict_aliasing_ok=no))
Martin v. Löwis70fedcd2003-07-07 21:26:19 +0000942 CC="$ac_save_cc"
943 AC_MSG_RESULT($ac_cv_no_strict_aliasing_ok)
944 if test $ac_cv_no_strict_aliasing_ok = yes
945 then
946 BASECFLAGS="$BASECFLAGS -fno-strict-aliasing"
947 fi
Mark Dickinson65134662008-04-25 16:11:04 +0000948
949 # if using gcc on alpha, use -mieee to get (near) full IEEE 754
950 # support. Without this, treatment of subnormals doesn't follow
951 # the standard.
952 case $ac_sys_machine in
953 alpha*)
954 BASECFLAGS="$BASECFLAGS -mieee"
955 ;;
956 esac
957
Skip Montanarodecc6a42003-01-01 20:07:49 +0000958 case $ac_sys_system in
959 SCO_SV*)
960 BASECFLAGS="$BASECFLAGS -m486 -DSCO5"
961 ;;
962 # is there any other compiler on Darwin besides gcc?
963 Darwin*)
Jeffrey Yasskin1b4e45b2008-03-17 14:40:53 +0000964 # -Wno-long-double, -no-cpp-precomp, and -mno-fused-madd
965 # used to be here, but non-Apple gcc doesn't accept them.
Ronald Oussorena55af9a2010-01-17 16:25:57 +0000966 if test "${CC}" = gcc
967 then
968 AC_MSG_CHECKING(which compiler should be used)
969 case "${UNIVERSALSDK}" in
970 */MacOSX10.4u.sdk)
971 # Build using 10.4 SDK, force usage of gcc when the
972 # compiler is gcc, otherwise the user will get very
973 # confusing error messages when building on OSX 10.6
974 CC=gcc-4.0
975 CPP=cpp-4.0
976 ;;
977 esac
978 AC_MSG_RESULT($CC)
Ronald Oussoren988117f2006-04-29 11:31:35 +0000979 fi
980
Benjamin Peterson4347c442008-07-17 15:59:24 +0000981 # Calculate the right deployment target for this build.
982 #
983 cur_target=`sw_vers -productVersion | sed 's/\(10\.[[0-9]]*\).*/\1/'`
984 if test ${cur_target} '>' 10.2; then
985 cur_target=10.3
Ronald Oussoren25967582009-09-06 10:00:26 +0000986 if test ${enable_universalsdk}; then
987 if test "${UNIVERSAL_ARCHS}" = "all"; then
988 # Ensure that the default platform for a
989 # 4-way universal build is OSX 10.5,
990 # that's the first OS release where
991 # 4-way builds make sense.
992 cur_target='10.5'
Ronald Oussoren23d92532009-09-07 06:12:00 +0000993
994 elif test "${UNIVERSAL_ARCHS}" = "3-way"; then
995 cur_target='10.5'
996
997 elif test "${UNIVERSAL_ARCHS}" = "intel"; then
998 cur_target='10.5'
999
1000 elif test "${UNIVERSAL_ARCHS}" = "64-bit"; then
1001 cur_target='10.5'
Ronald Oussoren25967582009-09-06 10:00:26 +00001002 fi
1003 else
Ronald Oussorenbc0e83c2010-02-11 13:26:54 +00001004 if test `/usr/bin/arch` = "i386"; then
Ronald Oussoren25967582009-09-06 10:00:26 +00001005 # On Intel macs default to a deployment
1006 # target of 10.4, that's the first OSX
1007 # release with Intel support.
1008 cur_target="10.4"
1009 fi
1010 fi
Benjamin Peterson4347c442008-07-17 15:59:24 +00001011 fi
1012 CONFIGURE_MACOSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET-${cur_target}}
1013
1014 # Make sure that MACOSX_DEPLOYMENT_TARGET is set in the
1015 # environment with a value that is the same as what we'll use
1016 # in the Makefile to ensure that we'll get the same compiler
1017 # environment during configure and build time.
1018 MACOSX_DEPLOYMENT_TARGET="$CONFIGURE_MACOSX_DEPLOYMENT_TARGET"
1019 export MACOSX_DEPLOYMENT_TARGET
1020 EXPORT_MACOSX_DEPLOYMENT_TARGET=''
1021
Ronald Oussorena55af9a2010-01-17 16:25:57 +00001022 if test "${enable_universalsdk}"; then
1023 UNIVERSAL_ARCH_FLAGS=""
1024 if test "$UNIVERSAL_ARCHS" = "32-bit" ; then
1025 UNIVERSAL_ARCH_FLAGS="-arch ppc -arch i386"
1026 ARCH_RUN_32BIT=""
Ronald Oussoren75912852010-04-08 08:13:31 +00001027 LIPO_32BIT_FLAGS=""
Ronald Oussorena55af9a2010-01-17 16:25:57 +00001028
1029 elif test "$UNIVERSAL_ARCHS" = "64-bit" ; then
1030 UNIVERSAL_ARCH_FLAGS="-arch ppc64 -arch x86_64"
1031 LIPO_32BIT_FLAGS=""
1032 ARCH_RUN_32BIT="true"
1033
1034 elif test "$UNIVERSAL_ARCHS" = "all" ; then
1035 UNIVERSAL_ARCH_FLAGS="-arch i386 -arch ppc -arch ppc64 -arch x86_64"
1036 LIPO_32BIT_FLAGS="-extract ppc7400 -extract i386"
Ronald Oussoren92397ce2010-01-17 19:32:00 +00001037 ARCH_RUN_32BIT="/usr/bin/arch -i386 -ppc"
Ronald Oussorena55af9a2010-01-17 16:25:57 +00001038
1039 elif test "$UNIVERSAL_ARCHS" = "intel" ; then
1040 UNIVERSAL_ARCH_FLAGS="-arch i386 -arch x86_64"
1041 LIPO_32BIT_FLAGS="-extract i386"
Ronald Oussoren92397ce2010-01-17 19:32:00 +00001042 ARCH_RUN_32BIT="/usr/bin/arch -i386"
Ronald Oussorena55af9a2010-01-17 16:25:57 +00001043
1044 elif test "$UNIVERSAL_ARCHS" = "3-way" ; then
1045 UNIVERSAL_ARCH_FLAGS="-arch i386 -arch ppc -arch x86_64"
1046 LIPO_32BIT_FLAGS="-extract ppc7400 -extract i386"
Ronald Oussoren9922f172010-02-11 13:19:34 +00001047 ARCH_RUN_32BIT="/usr/bin/arch -i386 -ppc"
Ronald Oussorena55af9a2010-01-17 16:25:57 +00001048
1049 else
1050 AC_MSG_ERROR([proper usage is --with-universal-arch=32-bit|64-bit|all|intel|3-way])
1051
1052 fi
1053
1054
Ronald Oussoren974eb5e2010-04-18 17:59:37 +00001055 CFLAGS="${UNIVERSAL_ARCH_FLAGS} ${CFLAGS}"
1056 if test "${UNIVERSALSDK}" != "/"
1057 then
1058 CPPFLAGS="-isysroot ${UNIVERSALSDK} ${CPPFLAGS}"
1059 LDFLAGS="-isysroot ${UNIVERSALSDK} ${LDFLAGS}"
1060 CFLAGS="-isysroot ${UNIVERSALSDK} ${CFLAGS}"
Ronald Oussorena55af9a2010-01-17 16:25:57 +00001061 fi
1062
1063 fi
1064
1065
Skip Montanarodecc6a42003-01-01 20:07:49 +00001066 ;;
Neal Norwitzdedeeaa2006-03-31 06:54:45 +00001067 OSF*)
1068 BASECFLAGS="$BASECFLAGS -mieee"
1069 ;;
Skip Montanarodecc6a42003-01-01 20:07:49 +00001070 esac
1071 ;;
1072
1073*)
1074 case $ac_sys_system in
1075 OpenUNIX*|UnixWare*)
1076 BASECFLAGS="$BASECFLAGS -K pentium,host,inline,loop_unroll,alloca "
1077 ;;
Neal Norwitzb44f1652003-05-26 14:11:55 +00001078 OSF*)
1079 BASECFLAGS="$BASECFLAGS -ieee -std"
1080 ;;
Skip Montanarodecc6a42003-01-01 20:07:49 +00001081 SCO_SV*)
1082 BASECFLAGS="$BASECFLAGS -belf -Ki486 -DSCO5"
1083 ;;
1084 esac
1085 ;;
1086esac
1087
Fred Drakee1ceaa02001-12-04 20:55:47 +00001088if test "$Py_DEBUG" = 'true'; then
1089 :
1090else
1091 OPT="-DNDEBUG $OPT"
1092fi
1093
Guido van Rossum6f2260e1996-09-09 16:21:03 +00001094if test "$ac_arch_flags"
Guido van Rossumc5a39031996-07-31 17:35:03 +00001095then
Skip Montanarodecc6a42003-01-01 20:07:49 +00001096 BASECFLAGS="$BASECFLAGS $ac_arch_flags"
Guido van Rossumc5a39031996-07-31 17:35:03 +00001097fi
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001098
Neal Norwitz020c46a2006-01-07 21:39:28 +00001099# disable check for icc since it seems to pass, but generates a warning
1100if test "$CC" = icc
1101then
1102 ac_cv_opt_olimit_ok=no
1103fi
1104
Guido van Rossum91922671997-10-09 20:24:13 +00001105AC_MSG_CHECKING(whether $CC accepts -OPT:Olimit=0)
1106AC_CACHE_VAL(ac_cv_opt_olimit_ok,
1107[ac_save_cc="$CC"
1108CC="$CC -OPT:Olimit=0"
Gregory P. Smithec3b8bd2009-11-01 21:02:52 +00001109AC_TRY_COMPILE([],[int main() { return 0; }],
Guido van Rossum91922671997-10-09 20:24:13 +00001110 ac_cv_opt_olimit_ok=yes,
Guido van Rossum3065c942001-09-17 04:03:14 +00001111 ac_cv_opt_olimit_ok=no,
Gregory P. Smithec3b8bd2009-11-01 21:02:52 +00001112 )
Guido van Rossum91922671997-10-09 20:24:13 +00001113CC="$ac_save_cc"])
1114AC_MSG_RESULT($ac_cv_opt_olimit_ok)
Guido van Rossum2efa34b1997-10-23 17:43:11 +00001115if test $ac_cv_opt_olimit_ok = yes; then
Guido van Rossum5839e582000-10-09 19:52:35 +00001116 case $ac_sys_system in
Skip Montanarodecc6a42003-01-01 20:07:49 +00001117 # XXX is this branch needed? On MacOSX 10.2.2 the result of the
1118 # olimit_ok test is "no". Is it "yes" in some other Darwin-esque
1119 # environment?
1120 Darwin*)
1121 ;;
1122 *)
1123 BASECFLAGS="$BASECFLAGS -OPT:Olimit=0"
1124 ;;
Guido van Rossum5839e582000-10-09 19:52:35 +00001125 esac
Guido van Rossumf8678121998-07-07 21:05:09 +00001126else
1127 AC_MSG_CHECKING(whether $CC accepts -Olimit 1500)
1128 AC_CACHE_VAL(ac_cv_olimit_ok,
1129 [ac_save_cc="$CC"
1130 CC="$CC -Olimit 1500"
Gregory P. Smithec3b8bd2009-11-01 21:02:52 +00001131 AC_TRY_COMPILE([],[int main() { return 0; }],
Guido van Rossumf8678121998-07-07 21:05:09 +00001132 ac_cv_olimit_ok=yes,
Guido van Rossum3065c942001-09-17 04:03:14 +00001133 ac_cv_olimit_ok=no,
Gregory P. Smithec3b8bd2009-11-01 21:02:52 +00001134 )
Guido van Rossumf8678121998-07-07 21:05:09 +00001135 CC="$ac_save_cc"])
1136 AC_MSG_RESULT($ac_cv_olimit_ok)
1137 if test $ac_cv_olimit_ok = yes; then
Skip Montanarodecc6a42003-01-01 20:07:49 +00001138 BASECFLAGS="$BASECFLAGS -Olimit 1500"
Guido van Rossumf8678121998-07-07 21:05:09 +00001139 fi
Guido van Rossum201afe51997-05-14 21:14:44 +00001140fi
Guido van Rossumf8678121998-07-07 21:05:09 +00001141
Martin v. Löwisaac13162006-10-19 10:58:46 +00001142# Check whether GCC supports PyArg_ParseTuple format
1143if test "$GCC" = "yes"
1144then
1145 AC_MSG_CHECKING(whether gcc supports ParseTuple __format__)
1146 save_CFLAGS=$CFLAGS
1147 CFLAGS="$CFLAGS -Werror"
1148 AC_TRY_COMPILE([
1149 void f(char*,...)__attribute((format(PyArg_ParseTuple, 1, 2)));
1150 ],,
1151 AC_DEFINE(HAVE_ATTRIBUTE_FORMAT_PARSETUPLE, 1, [Define if GCC supports __attribute__((format(PyArg_ParseTuple, 2, 3)))])
1152 AC_MSG_RESULT(yes),
1153 AC_MSG_RESULT(no)
1154 )
Martin v. Löwisc1d75972006-10-19 16:01:37 +00001155 CFLAGS=$save_CFLAGS
Martin v. Löwisaac13162006-10-19 10:58:46 +00001156fi
1157
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00001158# On some compilers, pthreads are available without further options
1159# (e.g. MacOS X). On some of these systems, the compiler will not
1160# complain if unaccepted options are passed (e.g. gcc on Mac OS X).
1161# So we have to see first whether pthreads are available without
1162# options before we can check whether -Kpthread improves anything.
1163AC_MSG_CHECKING(whether pthreads are available without options)
1164AC_CACHE_VAL(ac_cv_pthread_is_default,
1165[AC_TRY_RUN([
1166#include <pthread.h>
1167
1168void* routine(void* p){return NULL;}
1169
1170int main(){
1171 pthread_t p;
1172 if(pthread_create(&p,NULL,routine,NULL)!=0)
1173 return 1;
Jack Jansen4f8d0542002-03-08 13:43:01 +00001174 (void)pthread_detach(p);
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00001175 return 0;
1176}
1177],
Skip Montanarod8d39a02003-07-10 20:44:10 +00001178[
1179 ac_cv_pthread_is_default=yes
1180 ac_cv_kthread=no
1181 ac_cv_pthread=no
1182],
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00001183 ac_cv_pthread_is_default=no,
1184 ac_cv_pthread_is_default=no)
1185])
1186AC_MSG_RESULT($ac_cv_pthread_is_default)
1187
1188
1189if test $ac_cv_pthread_is_default = yes
1190then
1191 ac_cv_kpthread=no
1192else
Martin v. Löwis130fb172001-07-19 11:00:41 +00001193# -Kpthread, if available, provides the right #defines
1194# and linker options to make pthread_create available
Martin v. Löwis260aecc2001-10-07 08:14:41 +00001195# Some compilers won't report that they do not support -Kpthread,
1196# so we need to run a program to see whether it really made the
1197# function available.
Martin v. Löwis130fb172001-07-19 11:00:41 +00001198AC_MSG_CHECKING(whether $CC accepts -Kpthread)
1199AC_CACHE_VAL(ac_cv_kpthread,
1200[ac_save_cc="$CC"
1201CC="$CC -Kpthread"
Martin v. Löwis260aecc2001-10-07 08:14:41 +00001202AC_TRY_RUN([
1203#include <pthread.h>
1204
1205void* routine(void* p){return NULL;}
1206
1207int main(){
1208 pthread_t p;
1209 if(pthread_create(&p,NULL,routine,NULL)!=0)
1210 return 1;
Jack Jansen4f8d0542002-03-08 13:43:01 +00001211 (void)pthread_detach(p);
Martin v. Löwis260aecc2001-10-07 08:14:41 +00001212 return 0;
1213}
1214],
Martin v. Löwis130fb172001-07-19 11:00:41 +00001215 ac_cv_kpthread=yes,
Martin v. Löwis260aecc2001-10-07 08:14:41 +00001216 ac_cv_kpthread=no,
Martin v. Löwis130fb172001-07-19 11:00:41 +00001217 ac_cv_kpthread=no)
1218CC="$ac_save_cc"])
Martin v. Löwis130fb172001-07-19 11:00:41 +00001219AC_MSG_RESULT($ac_cv_kpthread)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00001220fi
Martin v. Löwis130fb172001-07-19 11:00:41 +00001221
Skip Montanarod8d39a02003-07-10 20:44:10 +00001222if test $ac_cv_kpthread = no -a $ac_cv_pthread_is_default = no
Martin v. Löwis5f433f02003-05-05 05:05:30 +00001223then
1224# -Kthread, if available, provides the right #defines
1225# and linker options to make pthread_create available
1226# Some compilers won't report that they do not support -Kthread,
1227# so we need to run a program to see whether it really made the
1228# function available.
1229AC_MSG_CHECKING(whether $CC accepts -Kthread)
1230AC_CACHE_VAL(ac_cv_kthread,
1231[ac_save_cc="$CC"
1232CC="$CC -Kthread"
1233AC_TRY_RUN([
1234#include <pthread.h>
1235
1236void* routine(void* p){return NULL;}
1237
1238int main(){
1239 pthread_t p;
1240 if(pthread_create(&p,NULL,routine,NULL)!=0)
1241 return 1;
1242 (void)pthread_detach(p);
1243 return 0;
1244}
1245],
1246 ac_cv_kthread=yes,
1247 ac_cv_kthread=no,
1248 ac_cv_kthread=no)
1249CC="$ac_save_cc"])
1250AC_MSG_RESULT($ac_cv_kthread)
1251fi
1252
Skip Montanarod8d39a02003-07-10 20:44:10 +00001253if test $ac_cv_kthread = no -a $ac_cv_pthread_is_default = no
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00001254then
1255# -pthread, if available, provides the right #defines
1256# and linker options to make pthread_create available
1257# Some compilers won't report that they do not support -pthread,
1258# so we need to run a program to see whether it really made the
1259# function available.
1260AC_MSG_CHECKING(whether $CC accepts -pthread)
1261AC_CACHE_VAL(ac_cv_thread,
1262[ac_save_cc="$CC"
1263CC="$CC -pthread"
1264AC_TRY_RUN([
1265#include <pthread.h>
1266
1267void* routine(void* p){return NULL;}
1268
1269int main(){
1270 pthread_t p;
1271 if(pthread_create(&p,NULL,routine,NULL)!=0)
1272 return 1;
1273 (void)pthread_detach(p);
1274 return 0;
1275}
1276],
1277 ac_cv_pthread=yes,
1278 ac_cv_pthread=no,
1279 ac_cv_pthread=no)
1280CC="$ac_save_cc"])
1281AC_MSG_RESULT($ac_cv_pthread)
1282fi
1283
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001284# If we have set a CC compiler flag for thread support then
1285# check if it works for CXX, too.
1286ac_cv_cxx_thread=no
1287if test ! -z "$CXX"
1288then
1289AC_MSG_CHECKING(whether $CXX also accepts flags for thread support)
1290ac_save_cxx="$CXX"
1291
1292if test "$ac_cv_kpthread" = "yes"
1293then
Martin v. Löwis519adae2003-09-20 10:47:47 +00001294 CXX="$CXX -Kpthread"
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001295 ac_cv_cxx_thread=yes
1296elif test "$ac_cv_kthread" = "yes"
1297then
1298 CXX="$CXX -Kthread"
1299 ac_cv_cxx_thread=yes
1300elif test "$ac_cv_pthread" = "yes"
1301then
1302 CXX="$CXX -pthread"
1303 ac_cv_cxx_thread=yes
1304fi
1305
1306if test $ac_cv_cxx_thread = yes
1307then
1308 echo 'void foo();int main(){foo();}void foo(){}' > conftest.$ac_ext
1309 $CXX -c conftest.$ac_ext 2>&5
1310 if $CXX -o conftest$ac_exeext conftest.$ac_objext 2>&5 \
1311 && test -s conftest$ac_exeext && ./conftest$ac_exeext
1312 then
1313 ac_cv_cxx_thread=yes
1314 else
1315 ac_cv_cxx_thread=no
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001316 fi
1317 rm -fr conftest*
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001318fi
Brett Cannonc601e0f2004-11-07 01:24:12 +00001319AC_MSG_RESULT($ac_cv_cxx_thread)
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001320fi
Martin v. Löwis519adae2003-09-20 10:47:47 +00001321CXX="$ac_save_cxx"
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001322
Fred Drakece81d592000-07-09 14:39:29 +00001323dnl # check for ANSI or K&R ("traditional") preprocessor
1324dnl AC_MSG_CHECKING(for C preprocessor type)
1325dnl AC_TRY_COMPILE([
1326dnl #define spam(name, doc) {#name, &name, #name "() -- " doc}
1327dnl int foo;
1328dnl struct {char *name; int *addr; char *doc;} desc = spam(foo, "something");
1329dnl ], [;], cpp_type=ansi, AC_DEFINE(HAVE_OLD_CPP) cpp_type=traditional)
1330dnl AC_MSG_RESULT($cpp_type)
Guido van Rossum300fda71996-08-19 21:58:16 +00001331
Guido van Rossum627b2d71993-12-24 10:39:16 +00001332# checks for header files
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001333AC_HEADER_STDC
Martin v. Löwis0e8bd7e2006-06-10 12:23:46 +00001334AC_CHECK_HEADERS(asm/types.h conio.h curses.h direct.h dlfcn.h errno.h \
1335fcntl.h grp.h \
Neal Norwitz9fdfaaf2008-03-28 05:34:59 +00001336ieeefp.h io.h langinfo.h libintl.h ncurses.h poll.h process.h pthread.h \
Martin v. Löwis40e9aed2006-10-02 15:20:37 +00001337shadow.h signal.h stdint.h stropts.h termios.h thread.h \
Martin v. Löwis14e73b12003-01-01 09:51:12 +00001338unistd.h utime.h \
Christian Heimes0e9ab5f2008-03-21 23:49:44 +00001339sys/audioio.h sys/bsdtty.h sys/epoll.h sys/event.h sys/file.h sys/loadavg.h \
1340sys/lock.h sys/mkdev.h sys/modem.h \
Martin v. Löwis0e8bd7e2006-06-10 12:23:46 +00001341sys/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 +00001342sys/termio.h sys/time.h \
Martin v. Löwis0e8bd7e2006-06-10 12:23:46 +00001343sys/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 +00001344sys/resource.h netpacket/packet.h sysexits.h bluetooth.h \
Ronald Oussorena55af9a2010-01-17 16:25:57 +00001345bluetooth/bluetooth.h linux/tipc.h spawn.h util.h)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001346AC_HEADER_DIRENT
Martin v. Löwisdbe3f762002-10-10 14:27:30 +00001347AC_HEADER_MAJOR
Guido van Rossum627b2d71993-12-24 10:39:16 +00001348
Martin v. Löwisae2830c2004-09-18 09:54:52 +00001349# On Solaris, term.h requires curses.h
Martin v. Löwisfd1c69e2004-11-30 22:09:37 +00001350AC_CHECK_HEADERS(term.h,,,[
Martin v. Löwis5d52e782004-09-18 10:07:03 +00001351#ifdef HAVE_CURSES_H
1352#include <curses.h>
1353#endif
1354])
Martin v. Löwisae2830c2004-09-18 09:54:52 +00001355
Martin v. Löwis11017b12006-01-14 18:12:57 +00001356# On Linux, netlink.h requires asm/types.h
1357AC_CHECK_HEADERS(linux/netlink.h,,,[
1358#ifdef HAVE_ASM_TYPES_H
1359#include <asm/types.h>
1360#endif
1361#ifdef HAVE_SYS_SOCKET_H
1362#include <sys/socket.h>
1363#endif
1364])
1365
Guido van Rossum627b2d71993-12-24 10:39:16 +00001366# checks for typedefs
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001367was_it_defined=no
1368AC_MSG_CHECKING(for clock_t in time.h)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001369AC_EGREP_HEADER(clock_t, time.h, was_it_defined=yes, [
1370 AC_DEFINE(clock_t, long, [Define to 'long' if <time.h> doesn't define.])
1371])
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001372AC_MSG_RESULT($was_it_defined)
1373
Neal Norwitz11690112002-07-30 01:08:28 +00001374# Check whether using makedev requires defining _OSF_SOURCE
1375AC_MSG_CHECKING(for makedev)
Jesus Cea616de772010-04-28 10:32:30 +00001376AC_TRY_LINK([
1377#if defined(MAJOR_IN_MKDEV)
1378#include <sys/mkdev.h>
1379#elif defined(MAJOR_IN_SYSMACROS)
1380#include <sys/sysmacros.h>
1381#else
1382#include <sys/types.h>
1383#endif ],
Neal Norwitz11690112002-07-30 01:08:28 +00001384 [ makedev(0, 0) ],
1385 ac_cv_has_makedev=yes,
1386 ac_cv_has_makedev=no)
1387if test "$ac_cv_has_makedev" = "no"; then
1388 # we didn't link, try if _OSF_SOURCE will allow us to link
1389 AC_TRY_LINK([
Neal Norwitz6eb37f02003-02-23 23:28:15 +00001390#define _OSF_SOURCE 1
1391#include <sys/types.h>
Neal Norwitz11690112002-07-30 01:08:28 +00001392 ],
1393 [ makedev(0, 0) ],
1394 ac_cv_has_makedev=yes,
1395 ac_cv_has_makedev=no)
1396 if test "$ac_cv_has_makedev" = "yes"; then
1397 AC_DEFINE(_OSF_SOURCE, 1, [Define _OSF_SOURCE to get the makedev macro.])
1398 fi
1399fi
1400AC_MSG_RESULT($ac_cv_has_makedev)
1401if test "$ac_cv_has_makedev" = "yes"; then
1402 AC_DEFINE(HAVE_MAKEDEV, 1, [Define this if you have the makedev macro.])
1403fi
1404
Martin v. Löwis399a6892002-10-04 10:22:02 +00001405# Enabling LFS on Solaris (2.6 to 9) with gcc 2.95 triggers a bug in
1406# the system headers: If _XOPEN_SOURCE and _LARGEFILE_SOURCE are
1407# defined, but the compiler does not support pragma redefine_extname,
1408# and _LARGEFILE64_SOURCE is not defined, the headers refer to 64-bit
1409# structures (such as rlimit64) without declaring them. As a
1410# work-around, disable LFS on such configurations
1411
1412use_lfs=yes
1413AC_MSG_CHECKING(Solaris LFS bug)
1414AC_TRY_COMPILE([
1415#define _LARGEFILE_SOURCE 1
1416#define _FILE_OFFSET_BITS 64
1417#include <sys/resource.h>
Matthias Klose5183ebd2010-04-24 16:38:36 +00001418],[struct rlimit foo;],sol_lfs_bug=no,sol_lfs_bug=yes)
Martin v. Löwis399a6892002-10-04 10:22:02 +00001419AC_MSG_RESULT($sol_lfs_bug)
1420if test "$sol_lfs_bug" = "yes"; then
1421 use_lfs=no
1422fi
1423
1424if test "$use_lfs" = "yes"; then
Guido van Rossum810cc512001-09-09 23:51:39 +00001425# Two defines needed to enable largefile support on various platforms
1426# These may affect some typedefs
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001427AC_DEFINE(_LARGEFILE_SOURCE, 1,
1428[This must be defined on some systems to enable large file support.])
1429AC_DEFINE(_FILE_OFFSET_BITS, 64,
1430[This must be set to 64 on some systems to enable large file support.])
Martin v. Löwis399a6892002-10-04 10:22:02 +00001431fi
Guido van Rossum810cc512001-09-09 23:51:39 +00001432
Guido van Rossum300fda71996-08-19 21:58:16 +00001433# Add some code to confdefs.h so that the test for off_t works on SCO
1434cat >> confdefs.h <<\EOF
1435#if defined(SCO_DS)
1436#undef _OFF_T
1437#endif
1438EOF
1439
Guido van Rossumef2255b2000-03-10 22:30:29 +00001440# Type availability checks
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001441AC_TYPE_MODE_T
1442AC_TYPE_OFF_T
1443AC_TYPE_PID_T
1444AC_TYPE_SIGNAL
1445AC_TYPE_SIZE_T
1446AC_TYPE_UID_T
Mark Dickinsonefc82f72009-03-20 15:51:55 +00001447AC_TYPE_UINT32_T
1448AC_TYPE_UINT64_T
1449AC_TYPE_INT32_T
1450AC_TYPE_INT64_T
Christian Heimes951cc0f2008-01-31 23:08:23 +00001451AC_CHECK_TYPE(ssize_t,
Matthias Klose5183ebd2010-04-24 16:38:36 +00001452 AC_DEFINE(HAVE_SSIZE_T, 1, [Define if your compiler provides ssize_t]),,)
Guido van Rossum627b2d71993-12-24 10:39:16 +00001453
Guido van Rossumef2255b2000-03-10 22:30:29 +00001454# Sizes of various common basic types
Skip Montanarob9820a32004-01-17 00:16:12 +00001455# ANSI C requires sizeof(char) == 1, so no need to check it
Guido van Rossum3065c942001-09-17 04:03:14 +00001456AC_CHECK_SIZEOF(int, 4)
1457AC_CHECK_SIZEOF(long, 4)
1458AC_CHECK_SIZEOF(void *, 4)
Guido van Rossum3065c942001-09-17 04:03:14 +00001459AC_CHECK_SIZEOF(short, 2)
1460AC_CHECK_SIZEOF(float, 4)
1461AC_CHECK_SIZEOF(double, 8)
1462AC_CHECK_SIZEOF(fpos_t, 4)
Martin v. Löwis18e16552006-02-15 17:27:45 +00001463AC_CHECK_SIZEOF(size_t, 4)
Christian Heimes951cc0f2008-01-31 23:08:23 +00001464AC_CHECK_SIZEOF(pid_t, 4)
Guido van Rossumac405f61994-09-12 10:56:06 +00001465
Guido van Rossumec95c7b1998-08-04 17:59:56 +00001466AC_MSG_CHECKING(for long long support)
1467have_long_long=no
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001468AC_TRY_COMPILE([], [long long x; x = (long long)0;], [
1469 AC_DEFINE(HAVE_LONG_LONG, 1, [Define this if you have the type long long.])
1470 have_long_long=yes
1471])
Guido van Rossumec95c7b1998-08-04 17:59:56 +00001472AC_MSG_RESULT($have_long_long)
Guido van Rossum8bc1dfd1999-04-10 16:01:48 +00001473if test "$have_long_long" = yes ; then
Guido van Rossum3065c942001-09-17 04:03:14 +00001474AC_CHECK_SIZEOF(long long, 8)
Guido van Rossumec95c7b1998-08-04 17:59:56 +00001475fi
1476
Travis E. Oliphant711c9e92008-06-06 22:33:21 +00001477AC_MSG_CHECKING(for long double support)
1478have_long_double=no
1479AC_TRY_COMPILE([], [long double x; x = (long double)0.;], [
1480 AC_DEFINE(HAVE_LONG_DOUBLE, 1, [Define this if you have the type long double.])
1481 have_long_double=yes
1482])
1483AC_MSG_RESULT($have_long_double)
Mark Dickinsondc1688a2008-06-27 22:20:14 +00001484if test "$have_long_double" = yes ; then
Travis E. Oliphant711c9e92008-06-06 22:33:21 +00001485AC_CHECK_SIZEOF(long double, 12)
1486fi
1487
Martin v. Löwisaef4c6b2007-01-21 09:33:07 +00001488AC_MSG_CHECKING(for _Bool support)
1489have_c99_bool=no
1490AC_TRY_COMPILE([], [_Bool x; x = (_Bool)0;], [
1491 AC_DEFINE(HAVE_C99_BOOL, 1, [Define this if you have the type _Bool.])
1492 have_c99_bool=yes
1493])
1494AC_MSG_RESULT($have_c99_bool)
1495if test "$have_c99_bool" = yes ; then
1496AC_CHECK_SIZEOF(_Bool, 1)
1497fi
1498
Martin v. Löwisebe26702006-10-02 14:55:51 +00001499AC_CHECK_TYPES(uintptr_t,
1500 [AC_CHECK_SIZEOF(uintptr_t, 4)],
Martin v. Löwis40e9aed2006-10-02 15:20:37 +00001501 [], [#ifdef HAVE_STDINT_H
1502 #include <stdint.h>
1503 #endif])
Martin v. Löwisebe26702006-10-02 14:55:51 +00001504
Alexandre Vassalotti856782e2009-07-17 04:59:05 +00001505AC_CHECK_SIZEOF(off_t, [], [
1506#ifdef HAVE_SYS_TYPES_H
1507#include <sys/types.h>
1508#endif
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001509])
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001510
1511AC_MSG_CHECKING(whether to enable large file support)
Mark Dickinson0ef0b912009-12-31 21:11:48 +00001512if test "$have_long_long" = yes
1513then
1514if test "$ac_cv_sizeof_off_t" -gt "$ac_cv_sizeof_long" -a \
Guido van Rossum8bc1dfd1999-04-10 16:01:48 +00001515 "$ac_cv_sizeof_long_long" -ge "$ac_cv_sizeof_off_t"; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001516 AC_DEFINE(HAVE_LARGEFILE_SUPPORT, 1,
1517 [Defined to enable large file support when an off_t is bigger than a long
1518 and long long is available and at least as big as an off_t. You may need
1519 to add some flags for configuration and compilation to enable this mode.
1520 (For Solaris and Linux, the necessary defines are already defined.)])
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001521 AC_MSG_RESULT(yes)
1522else
1523 AC_MSG_RESULT(no)
1524fi
Mark Dickinson0ef0b912009-12-31 21:11:48 +00001525else
1526 AC_MSG_RESULT(no)
1527fi
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001528
Alexandre Vassalotti856782e2009-07-17 04:59:05 +00001529AC_CHECK_SIZEOF(time_t, [], [
1530#ifdef HAVE_SYS_TYPES_H
1531#include <sys/types.h>
1532#endif
1533#ifdef HAVE_TIME_H
1534#include <time.h>
1535#endif
Fred Drakea3f6e912000-06-29 20:44:47 +00001536])
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001537
Trent Mick635f6fb2000-08-23 21:33:05 +00001538# if have pthread_t then define SIZEOF_PTHREAD_T
Martin v. Löwis123cbd22001-07-19 14:21:10 +00001539ac_save_cc="$CC"
1540if test "$ac_cv_kpthread" = "yes"
1541then CC="$CC -Kpthread"
Martin v. Löwis5f433f02003-05-05 05:05:30 +00001542elif test "$ac_cv_kthread" = "yes"
1543then CC="$CC -Kthread"
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00001544elif test "$ac_cv_pthread" = "yes"
1545then CC="$CC -pthread"
Martin v. Löwis123cbd22001-07-19 14:21:10 +00001546fi
Trent Mick635f6fb2000-08-23 21:33:05 +00001547AC_MSG_CHECKING(for pthread_t)
1548have_pthread_t=no
Guido van Rossum12580492000-09-24 16:47:19 +00001549AC_TRY_COMPILE([#include <pthread.h>], [pthread_t x; x = *(pthread_t*)0;], have_pthread_t=yes)
Trent Mick635f6fb2000-08-23 21:33:05 +00001550AC_MSG_RESULT($have_pthread_t)
1551if test "$have_pthread_t" = yes ; then
Alexandre Vassalotti856782e2009-07-17 04:59:05 +00001552 AC_CHECK_SIZEOF(pthread_t, [], [
1553#ifdef HAVE_PTHREAD_H
1554#include <pthread.h>
1555#endif
Trent Mick635f6fb2000-08-23 21:33:05 +00001556 ])
Trent Mick635f6fb2000-08-23 21:33:05 +00001557fi
Martin v. Löwis123cbd22001-07-19 14:21:10 +00001558CC="$ac_save_cc"
Trent Mick635f6fb2000-08-23 21:33:05 +00001559
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001560AC_MSG_CHECKING(for --enable-toolbox-glue)
1561AC_ARG_ENABLE(toolbox-glue,
Matthias Klose5183ebd2010-04-24 16:38:36 +00001562 AC_HELP_STRING([--enable-toolbox-glue], [disable/enable MacOSX glue code for extensions]))
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001563
1564if test -z "$enable_toolbox_glue"
1565then
1566 case $ac_sys_system/$ac_sys_release in
1567 Darwin/*)
1568 enable_toolbox_glue="yes";;
1569 *)
1570 enable_toolbox_glue="no";;
1571 esac
1572fi
1573case "$enable_toolbox_glue" in
1574yes)
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001575 extra_machdep_objs="Python/mactoolboxglue.o"
Raymond Hettingerec6eb362004-11-05 07:02:59 +00001576 extra_undefs="-u _PyMac_Error"
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001577 AC_DEFINE(USE_TOOLBOX_OBJECT_GLUE, 1,
1578 [Define if you want to use MacPython modules on MacOSX in unix-Python.])
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001579 ;;
1580*)
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001581 extra_machdep_objs=""
Jack Jansen591cbed2001-08-15 13:55:15 +00001582 extra_undefs=""
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001583 ;;
1584esac
1585AC_MSG_RESULT($enable_toolbox_glue)
1586
Ronald Oussoren0d236eb2008-06-06 21:31:33 +00001587
Bob Ippolito7026a0a2005-03-28 23:23:47 +00001588AC_SUBST(OTHER_LIBTOOL_OPT)
1589case $ac_sys_system/$ac_sys_release in
Anthony Baxter82201742006-04-09 15:07:40 +00001590 Darwin/@<:@01567@:>@\..*)
Bob Ippolito7026a0a2005-03-28 23:23:47 +00001591 OTHER_LIBTOOL_OPT="-prebind -seg1addr 0x10000000"
1592 ;;
1593 Darwin/*)
1594 OTHER_LIBTOOL_OPT=""
1595 ;;
1596esac
1597
Ronald Oussoren25967582009-09-06 10:00:26 +00001598
1599ARCH_RUN_32BIT=""
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001600AC_SUBST(LIBTOOL_CRUFT)
1601case $ac_sys_system/$ac_sys_release in
Anthony Baxter82201742006-04-09 15:07:40 +00001602 Darwin/@<:@01567@:>@\..*)
Ronald Oussoren988117f2006-04-29 11:31:35 +00001603 LIBTOOL_CRUFT="-framework System -lcc_dynamic"
1604 if test "${enable_universalsdk}"; then
1605 :
1606 else
Ronald Oussorenbc0e83c2010-02-11 13:26:54 +00001607 LIBTOOL_CRUFT="${LIBTOOL_CRUFT} -arch_only `/usr/bin/arch`"
Ronald Oussoren988117f2006-04-29 11:31:35 +00001608 fi
Jack Jansenb36687a2004-07-16 08:43:47 +00001609 LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -install_name $(PYTHONFRAMEWORKINSTALLDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansena3891ea2001-09-07 14:25:12 +00001610 LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -compatibility_version $(VERSION) -current_version $(VERSION)';;
Guido van Rossum5839e582000-10-09 19:52:35 +00001611 Darwin/*)
Ronald Oussorena55af9a2010-01-17 16:25:57 +00001612 gcc_version=`gcc -dumpversion`
Bob Ippolito7026a0a2005-03-28 23:23:47 +00001613 if test ${gcc_version} '<' 4.0
1614 then
1615 LIBTOOL_CRUFT="-lcc_dynamic"
1616 else
1617 LIBTOOL_CRUFT=""
1618 fi
Ronald Oussoren23d92532009-09-07 06:12:00 +00001619 AC_TRY_RUN([
Ronald Oussoren25967582009-09-06 10:00:26 +00001620 #include <unistd.h>
1621 int main(int argc, char*argv[])
1622 {
1623 if (sizeof(long) == 4) {
1624 return 0;
1625 } else {
1626 return 1;
1627 }
Ronald Oussoren84ddd722009-09-08 07:17:10 +00001628 }
Ronald Oussoren23d92532009-09-07 06:12:00 +00001629 ], ac_osx_32bit=yes,
Ronald Oussoren25967582009-09-06 10:00:26 +00001630 ac_osx_32bit=no,
Ronald Oussoren23d92532009-09-07 06:12:00 +00001631 ac_osx_32bit=yes)
Ronald Oussoren25967582009-09-06 10:00:26 +00001632
1633 if test "${ac_osx_32bit}" = "yes"; then
Ronald Oussorenbc0e83c2010-02-11 13:26:54 +00001634 case `/usr/bin/arch` in
Ronald Oussoren25967582009-09-06 10:00:26 +00001635 i386)
1636 MACOSX_DEFAULT_ARCH="i386"
1637 ;;
1638 ppc)
1639 MACOSX_DEFAULT_ARCH="ppc"
1640 ;;
1641 *)
1642 AC_MSG_ERROR([Unexpected output of 'arch' on OSX])
1643 ;;
1644 esac
1645 else
Ronald Oussorenbc0e83c2010-02-11 13:26:54 +00001646 case `/usr/bin/arch` in
Ronald Oussoren25967582009-09-06 10:00:26 +00001647 i386)
1648 MACOSX_DEFAULT_ARCH="x86_64"
1649 ;;
1650 ppc)
1651 MACOSX_DEFAULT_ARCH="ppc64"
1652 ;;
1653 *)
1654 AC_MSG_ERROR([Unexpected output of 'arch' on OSX])
1655 ;;
1656 esac
1657
1658 #ARCH_RUN_32BIT="true"
1659 fi
1660
1661 LIBTOOL_CRUFT=$LIBTOOL_CRUFT" -lSystem -lSystemStubs -arch_only ${MACOSX_DEFAULT_ARCH}"
Jack Jansenb36687a2004-07-16 08:43:47 +00001662 LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -install_name $(PYTHONFRAMEWORKINSTALLDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001663 LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -compatibility_version $(VERSION) -current_version $(VERSION)';;
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001664esac
1665
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001666AC_MSG_CHECKING(for --enable-framework)
1667if test "$enable_framework"
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001668then
Skip Montanarodecc6a42003-01-01 20:07:49 +00001669 BASECFLAGS="$BASECFLAGS -fno-common -dynamic"
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001670 # -F. is needed to allow linking to the framework while
1671 # in the build location.
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001672 AC_DEFINE(WITH_NEXT_FRAMEWORK, 1,
1673 [Define if you want to produce an OpenStep/Rhapsody framework
1674 (shared library plus accessory files).])
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001675 AC_MSG_RESULT(yes)
Ronald Oussoren450d5612009-06-08 21:12:41 +00001676 if test $enable_shared = "yes"
1677 then
Ronald Oussoren9ebd2422009-09-29 13:00:44 +00001678 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 +00001679 fi
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001680else
1681 AC_MSG_RESULT(no)
1682fi
1683
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001684AC_MSG_CHECKING(for dyld)
Jack Jansen9a66b6d2001-08-08 13:56:14 +00001685case $ac_sys_system/$ac_sys_release in
1686 Darwin/*)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001687 AC_DEFINE(WITH_DYLD, 1,
1688 [Define if you want to use the new-style (Openstep, Rhapsody, MacOS)
1689 dynamic linker (dyld) instead of the old-style (NextStep) dynamic
1690 linker (rld). Dyld is necessary to support frameworks.])
Jack Jansen9a66b6d2001-08-08 13:56:14 +00001691 AC_MSG_RESULT(always on for Darwin)
1692 ;;
1693 *)
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001694 AC_MSG_RESULT(no)
1695 ;;
Jack Jansen9a66b6d2001-08-08 13:56:14 +00001696esac
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001697
Guido van Rossumac405f61994-09-12 10:56:06 +00001698# Set info about shared libraries.
Guido van Rossumac405f61994-09-12 10:56:06 +00001699AC_SUBST(SO)
1700AC_SUBST(LDSHARED)
Tarek Ziadé00002952010-04-03 08:37:59 +00001701AC_SUBST(LDCXXSHARED)
Neil Schemenauerb3531b82001-02-16 04:09:05 +00001702AC_SUBST(BLDSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00001703AC_SUBST(CCSHARED)
1704AC_SUBST(LINKFORSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00001705# SO is the extension of shared libraries `(including the dot!)
Guido van Rossumaef734b2001-01-10 21:09:12 +00001706# -- usually .so, .sl on HP-UX, .dll on Cygwin
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001707AC_MSG_CHECKING(SO)
Guido van Rossumac405f61994-09-12 10:56:06 +00001708if test -z "$SO"
1709then
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001710 case $ac_sys_system in
Neal Norwitz58e28882006-05-19 07:00:58 +00001711 hp*|HP*)
1712 case `uname -m` in
1713 ia64) SO=.so;;
1714 *) SO=.sl;;
1715 esac
1716 ;;
Guido van Rossumaef734b2001-01-10 21:09:12 +00001717 CYGWIN*) SO=.dll;;
Guido van Rossum4b6b5791996-09-09 20:09:34 +00001718 *) SO=.so;;
Guido van Rossumac405f61994-09-12 10:56:06 +00001719 esac
Martin v. Löwis368de8f2003-06-14 14:46:38 +00001720else
1721 # this might also be a termcap variable, see #610332
1722 echo
1723 echo '====================================================================='
1724 echo '+ +'
1725 echo '+ WARNING: You have set SO in your environment. +'
1726 echo '+ Do you really mean to change the extension for shared libraries? +'
1727 echo '+ Continuing in 10 seconds to let you to ponder. +'
1728 echo '+ +'
1729 echo '====================================================================='
1730 sleep 10
Guido van Rossumac405f61994-09-12 10:56:06 +00001731fi
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001732AC_MSG_RESULT($SO)
Ronald Oussoren79f90492009-01-02 10:44:46 +00001733
Neal Norwitz58e28882006-05-19 07:00:58 +00001734AC_DEFINE_UNQUOTED(SHLIB_EXT, "$SO", [Define this to be extension of shared libraries (including the dot!).])
Guido van Rossumac405f61994-09-12 10:56:06 +00001735# LDSHARED is the ld *command* used to create shared library
Skip Montanaroce59c042004-01-17 14:19:44 +00001736# -- "cc -G" on SunOS 5.x, "ld -shared" on IRIX 5
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001737# (Shared libraries in this instance are shared modules to be loaded into
1738# Python, as opposed to building Python itself as a shared library.)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001739AC_MSG_CHECKING(LDSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00001740if test -z "$LDSHARED"
1741then
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001742 case $ac_sys_system/$ac_sys_release in
Neil Schemenauerb3531b82001-02-16 04:09:05 +00001743 AIX*)
1744 BLDSHARED="\$(srcdir)/Modules/ld_so_aix \$(CC) -bI:Modules/python.exp"
Guido van Rossumce608b02001-09-28 15:59:38 +00001745 LDSHARED="\$(BINLIBDEST)/config/ld_so_aix \$(CC) -bI:\$(BINLIBDEST)/config/python.exp"
Neil Schemenauerb3531b82001-02-16 04:09:05 +00001746 ;;
1747 BeOS*)
1748 BLDSHARED="\$(srcdir)/Modules/ld_so_beos $LDLIBRARY"
Guido van Rossumce608b02001-09-28 15:59:38 +00001749 LDSHARED="\$(BINLIBDEST)/config/ld_so_beos \$(LIBDIR)/$LDLIBRARY"
Neil Schemenauerb3531b82001-02-16 04:09:05 +00001750 ;;
Guido van Rossum6100aaf1997-04-29 21:48:51 +00001751 IRIX/5*) LDSHARED="ld -shared";;
Guido van Rossum91922671997-10-09 20:24:13 +00001752 IRIX*/6*) LDSHARED="ld ${SGI_ABI} -shared -all";;
Greg Ward57c9a662000-05-26 12:22:54 +00001753 SunOS/5*)
Tarek Ziadé00002952010-04-03 08:37:59 +00001754 if test "$GCC" = "yes" ; then
1755 LDSHARED='$(CC) -shared'
1756 LDCXXSHARED='$(CXX) -shared'
1757 else
1758 LDSHARED='$(CC) -G'
1759 LDCXXSHARED='$(CXX) -G'
Greg Ward57c9a662000-05-26 12:22:54 +00001760 fi ;;
Thomas Hellerdc96a772008-04-04 10:07:55 +00001761 hp*|HP*)
Tarek Ziadé00002952010-04-03 08:37:59 +00001762 if test "$GCC" = "yes" ; then
1763 LDSHARED='$(CC) -shared'
1764 LDCXXSHARED='$(CXX) -shared'
1765 else
1766 LDSHARED='ld -b'
Thomas Hellerdc96a772008-04-04 10:07:55 +00001767 fi ;;
Guido van Rossum71001e41995-01-26 00:44:03 +00001768 OSF*) LDSHARED="ld -shared -expect_unresolved \"*\"";;
Jack Jansen418c3b12001-11-14 10:59:57 +00001769 Darwin/1.3*)
Jack Jansena3891ea2001-09-07 14:25:12 +00001770 LDSHARED='$(CC) $(LDFLAGS) -bundle'
Tarek Ziadé00002952010-04-03 08:37:59 +00001771 LDCXXSHARED='$(CXX) $(LDFLAGS) -bundle'
Jack Jansena3891ea2001-09-07 14:25:12 +00001772 if test "$enable_framework" ; then
1773 # Link against the framework. All externals should be defined.
Jack Jansenda49e192005-01-07 13:08:22 +00001774 BLDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
1775 LDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Tarek Ziadé00002952010-04-03 08:37:59 +00001776 LDCXXSHARED="$LDCXXSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansena3891ea2001-09-07 14:25:12 +00001777 else
1778 # No framework. Ignore undefined symbols, assuming they come from Python
Jack Jansen418c3b12001-11-14 10:59:57 +00001779 LDSHARED="$LDSHARED -undefined suppress"
Tarek Ziadé00002952010-04-03 08:37:59 +00001780 LDCXXSHARED="$LDCXXSHARED -undefined suppress"
Jack Jansena3891ea2001-09-07 14:25:12 +00001781 fi ;;
Jack Jansen6b08a402004-06-03 12:41:45 +00001782 Darwin/1.4*|Darwin/5.*|Darwin/6.*)
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001783 LDSHARED='$(CC) $(LDFLAGS) -bundle'
Tarek Ziadé00002952010-04-03 08:37:59 +00001784 LDCXXSHARED='$(CXX) $(LDFLAGS) -bundle'
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001785 if test "$enable_framework" ; then
1786 # Link against the framework. All externals should be defined.
Jack Jansenda49e192005-01-07 13:08:22 +00001787 BLDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
1788 LDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Tarek Ziadé00002952010-04-03 08:37:59 +00001789 LDCXXSHARED="$LDCXXSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001790 else
Michael W. Hudson0c46c0c2002-03-07 09:58:56 +00001791 # No framework, use the Python app as bundle-loader
1792 BLDSHARED="$LDSHARED "'-bundle_loader $(BUILDPYTHON)'
Jack Jansenc28fc372003-02-25 13:14:43 +00001793 LDSHARED="$LDSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)'
Tarek Ziadé00002952010-04-03 08:37:59 +00001794 LDCXXSHARED="$LDCXXSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)'
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001795 fi ;;
Jack Jansen6b08a402004-06-03 12:41:45 +00001796 Darwin/*)
1797 # Use -undefined dynamic_lookup whenever possible (10.3 and later).
1798 # This allows an extension to be used in any Python
Ronald Oussoren38f1b982007-09-02 09:46:07 +00001799
Ronald Oussoren5640ce22008-06-05 12:58:24 +00001800 if test ${MACOSX_DEPLOYMENT_TARGET} '>' 10.2
Jack Jansen6b08a402004-06-03 12:41:45 +00001801 then
Ronald Oussoren988117f2006-04-29 11:31:35 +00001802 if test "${enable_universalsdk}"; then
Ronald Oussoren5640ce22008-06-05 12:58:24 +00001803 LDFLAGS="${UNIVERSAL_ARCH_FLAGS} -isysroot ${UNIVERSALSDK} ${LDFLAGS}"
Ronald Oussoren988117f2006-04-29 11:31:35 +00001804 fi
Jack Jansen6b08a402004-06-03 12:41:45 +00001805 LDSHARED='$(CC) $(LDFLAGS) -bundle -undefined dynamic_lookup'
Tarek Ziadé00002952010-04-03 08:37:59 +00001806 LDCXXSHARED='$(CXX) $(LDFLAGS) -bundle -undefined dynamic_lookup'
Jack Jansen6b08a402004-06-03 12:41:45 +00001807 BLDSHARED="$LDSHARED"
Jack Jansen6b08a402004-06-03 12:41:45 +00001808 else
1809 LDSHARED='$(CC) $(LDFLAGS) -bundle'
Tarek Ziadé00002952010-04-03 08:37:59 +00001810 LDCXXSHARED='$(CXX) $(LDFLAGS) -bundle'
Jack Jansen6b08a402004-06-03 12:41:45 +00001811 if test "$enable_framework" ; then
1812 # Link against the framework. All externals should be defined.
Jack Jansenda49e192005-01-07 13:08:22 +00001813 BLDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
1814 LDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Tarek Ziadé00002952010-04-03 08:37:59 +00001815 LDCXXSHARED="$LDCXXSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansen6b08a402004-06-03 12:41:45 +00001816 else
1817 # No framework, use the Python app as bundle-loader
1818 BLDSHARED="$LDSHARED "'-bundle_loader $(BUILDPYTHON)'
1819 LDSHARED="$LDSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)'
Tarek Ziadé00002952010-04-03 08:37:59 +00001820 LDCXXSHARED="$LDCXXSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)'
Jack Jansen6b08a402004-06-03 12:41:45 +00001821 fi
1822 fi
1823 ;;
Tarek Ziadé00002952010-04-03 08:37:59 +00001824 Linux*|GNU*|QNX*)
1825 LDSHARED='$(CC) -shared'
1826 LDCXXSHARED='$(CXX) -shared';;
1827 BSD/OS*/4*)
1828 LDSHARED="gcc -shared"
1829 LDCXXSHARED="g++ -shared";;
Martin v. Löwis222c5152006-06-03 07:37:13 +00001830 FreeBSD*)
Jeremy Hylton4bcc7c52000-08-31 17:45:35 +00001831 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
Guido van Rossum0286ae82000-08-29 15:06:49 +00001832 then
Benjamin Peterson3b2abe92010-03-14 15:06:14 +00001833 LDSHARED='$(CC) -shared ${LDFLAGS}'
Tarek Ziadé00002952010-04-03 08:37:59 +00001834 LDCXXSHARED='$(CXX) -shared ${LDFLAGS}'
Guido van Rossum0286ae82000-08-29 15:06:49 +00001835 else
1836 LDSHARED="ld -Bshareable ${LDFLAGS}"
1837 fi;;
Martin v. Löwis222c5152006-06-03 07:37:13 +00001838 OpenBSD*)
1839 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
1840 then
1841 LDSHARED='$(CC) -shared $(CCSHARED) ${LDFLAGS}'
Tarek Ziadé00002952010-04-03 08:37:59 +00001842 LDCXXSHARED='$(CXX) -shared $(CCSHARED) ${LDFLAGS}'
Martin v. Löwis222c5152006-06-03 07:37:13 +00001843 else
1844 case `uname -r` in
1845 [[01]].* | 2.[[0-7]] | 2.[[0-7]].*)
1846 LDSHARED="ld -Bshareable ${LDFLAGS}"
1847 ;;
1848 *)
1849 LDSHARED='$(CC) -shared $(CCSHARED) ${LDFLAGS}'
Tarek Ziadé00002952010-04-03 08:37:59 +00001850 LDCXXSHARED='$(CXX) -shared $(CCSHARED) ${LDFLAGS}'
Martin v. Löwis222c5152006-06-03 07:37:13 +00001851 ;;
1852 esac
1853 fi;;
Tarek Ziadé00002952010-04-03 08:37:59 +00001854 NetBSD*|DragonFly*)
1855 LDSHARED="cc -shared ${LDFLAGS}"
1856 LDCXXSHARED="c++ -shared ${LDFLAGS}";;
Martin v. Löwis25ae43b2001-10-07 08:39:18 +00001857 OpenUNIX*|UnixWare*)
Tarek Ziadé00002952010-04-03 08:37:59 +00001858 if test "$GCC" = "yes" ; then
1859 LDSHARED='$(CC) -shared'
1860 LDCXXSHARED='$(CXX) -shared'
1861 else
1862 LDSHARED='$(CC) -G'
1863 LDCXXSHARED='$(CXX) -G'
Martin v. Löwisbec19582001-03-21 15:57:54 +00001864 fi;;
Tarek Ziadé00002952010-04-03 08:37:59 +00001865 SCO_SV*)
1866 LDSHARED='$(CC) -Wl,-G,-Bexport'
1867 LDCXXSHARED='$(CXX) -Wl,-G,-Bexport';;
1868 CYGWIN*)
1869 LDSHARED="gcc -shared -Wl,--enable-auto-image-base"
1870 LDCXXSHARED="g++ -shared -Wl,--enable-auto-image-base";;
1871 atheos*)
1872 LDSHARED="gcc -shared"
1873 LDCXXSHARED="g++ -shared";;
Guido van Rossumac405f61994-09-12 10:56:06 +00001874 *) LDSHARED="ld";;
1875 esac
Guido van Rossumac405f61994-09-12 10:56:06 +00001876fi
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001877AC_MSG_RESULT($LDSHARED)
Tarek Ziadé00002952010-04-03 08:37:59 +00001878LDCXXSHARED=${LDCXXSHARED-$LDSHARED}
Neil Schemenauerb3531b82001-02-16 04:09:05 +00001879BLDSHARED=${BLDSHARED-$LDSHARED}
Guido van Rossumac405f61994-09-12 10:56:06 +00001880# CCSHARED are the C *flags* used to create objects to go into a shared
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001881# library (module) -- this is only needed for a few systems
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001882AC_MSG_CHECKING(CCSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00001883if test -z "$CCSHARED"
1884then
Guido van Rossum6100aaf1997-04-29 21:48:51 +00001885 case $ac_sys_system/$ac_sys_release in
Neil Schemenauer66252162001-02-19 04:47:42 +00001886 SunOS*) if test "$GCC" = yes;
Martin v. Löwiseb623572007-03-12 10:50:39 +00001887 then CCSHARED="-fPIC";
1888 elif test `uname -p` = sparc;
1889 then CCSHARED="-xcode=pic32";
1890 else CCSHARED="-Kpic";
1891 fi;;
Guido van Rossumaf07a441995-02-13 19:45:27 +00001892 hp*|HP*) if test "$GCC" = yes;
Martin v. Löwis703ad702001-09-05 08:36:52 +00001893 then CCSHARED="-fPIC";
Guido van Rossumaf07a441995-02-13 19:45:27 +00001894 else CCSHARED="+z";
1895 fi;;
Martin v. Löwisa6e97582002-01-01 18:41:33 +00001896 Linux*|GNU*) CCSHARED="-fPIC";;
Guido van Rossumf5957ea1999-10-05 21:59:33 +00001897 BSD/OS*/4*) CCSHARED="-fpic";;
Martin v. Löwis86d66262006-02-17 08:40:11 +00001898 FreeBSD*|NetBSD*|OpenBSD*|DragonFly*) CCSHARED="-fPIC";;
Martin v. Löwis25ae43b2001-10-07 08:39:18 +00001899 OpenUNIX*|UnixWare*)
Martin v. Löwisbec19582001-03-21 15:57:54 +00001900 if test "$GCC" = "yes"
1901 then CCSHARED="-fPIC"
Martin v. Löwis130fb172001-07-19 11:00:41 +00001902 else CCSHARED="-KPIC"
Martin v. Löwisbec19582001-03-21 15:57:54 +00001903 fi;;
Martin v. Löwis21ee4092002-09-30 16:19:48 +00001904 SCO_SV*)
1905 if test "$GCC" = "yes"
1906 then CCSHARED="-fPIC"
1907 else CCSHARED="-Kpic -belf"
1908 fi;;
Guido van Rossum2b5ca001998-03-05 15:41:09 +00001909 IRIX*/6*) case $CC in
1910 *gcc*) CCSHARED="-shared";;
Guido van Rossumee21f411998-04-20 18:51:54 +00001911 *) CCSHARED="";;
Guido van Rossum2b5ca001998-03-05 15:41:09 +00001912 esac;;
Martin v. Löwisf90ae202002-06-11 06:22:31 +00001913 atheos*) CCSHARED="-fPIC";;
Guido van Rossumac405f61994-09-12 10:56:06 +00001914 esac
Guido van Rossumac405f61994-09-12 10:56:06 +00001915fi
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001916AC_MSG_RESULT($CCSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00001917# LINKFORSHARED are the flags passed to the $(CC) command that links
Guido van Rossumb65a48e1995-06-14 18:21:23 +00001918# the python executable -- this is only needed for a few systems
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001919AC_MSG_CHECKING(LINKFORSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00001920if test -z "$LINKFORSHARED"
1921then
Guido van Rossum6100aaf1997-04-29 21:48:51 +00001922 case $ac_sys_system/$ac_sys_release in
Neil Schemenauerb3531b82001-02-16 04:09:05 +00001923 AIX*) LINKFORSHARED='-Wl,-bE:Modules/python.exp -lld';;
Guido van Rossum5dab3d81996-12-06 21:18:18 +00001924 hp*|HP*)
Martin v. Löwis1142de32002-03-29 16:28:31 +00001925 LINKFORSHARED="-Wl,-E -Wl,+s";;
1926# LINKFORSHARED="-Wl,-E -Wl,+s -Wl,+b\$(BINLIBDEST)/lib-dynload";;
Guido van Rossumf5957ea1999-10-05 21:59:33 +00001927 BSD/OS/4*) LINKFORSHARED="-Xlinker -export-dynamic";;
Martin v. Löwisa6e97582002-01-01 18:41:33 +00001928 Linux*|GNU*) LINKFORSHARED="-Xlinker -export-dynamic";;
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001929 # -u libsys_s pulls in all symbols in libsys
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001930 Darwin/*)
Raymond Hettingerec6eb362004-11-05 07:02:59 +00001931 # -u _PyMac_Error is needed to pull in the mac toolbox glue,
1932 # which is
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001933 # not used by the core itself but which needs to be in the core so
1934 # that dynamically loaded extension modules have access to it.
Jack Jansen97e3f002003-02-23 22:59:01 +00001935 # -prebind is no longer used, because it actually seems to give a
1936 # slowdown in stead of a speedup, maybe due to the large number of
1937 # dynamic loads Python does.
Raymond Hettingerec6eb362004-11-05 07:02:59 +00001938
1939 LINKFORSHARED="$extra_undefs"
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001940 if test "$enable_framework"
1941 then
Jack Jansenda49e192005-01-07 13:08:22 +00001942 LINKFORSHARED="$LINKFORSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001943 fi
Raymond Hettingerec6eb362004-11-05 07:02:59 +00001944 LINKFORSHARED="$LINKFORSHARED";;
Martin v. Löwis25ae43b2001-10-07 08:39:18 +00001945 OpenUNIX*|UnixWare*) LINKFORSHARED="-Wl,-Bexport";;
Martin v. Löwis21ee4092002-09-30 16:19:48 +00001946 SCO_SV*) LINKFORSHARED="-Wl,-Bexport";;
Fred Drake02706f52000-09-25 15:08:46 +00001947 ReliantUNIX*) LINKFORSHARED="-W1 -Blargedynsym";;
Martin v. Löwis86d66262006-02-17 08:40:11 +00001948 FreeBSD*|NetBSD*|OpenBSD*|DragonFly*)
Guido van Rossumdf693651999-01-07 21:50:41 +00001949 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
1950 then
1951 LINKFORSHARED="-Wl,--export-dynamic"
1952 fi;;
Guido van Rossum2b5ca001998-03-05 15:41:09 +00001953 SunOS/5*) case $CC in
1954 *gcc*)
Martin v. Löwisa4548572002-04-18 14:51:36 +00001955 if $CC -Xlinker --help 2>&1 | grep export-dynamic >/dev/null
Guido van Rossum8f4ceb11997-12-18 23:42:19 +00001956 then
1957 LINKFORSHARED="-Xlinker --export-dynamic"
Guido van Rossum2b5ca001998-03-05 15:41:09 +00001958 fi;;
1959 esac;;
Jason Tishler30765592003-09-04 11:04:06 +00001960 CYGWIN*)
1961 if test $enable_shared = "no"
1962 then
1963 LINKFORSHARED='-Wl,--out-implib=$(LDLIBRARY)'
1964 fi;;
Martin v. Löwis8c255e42008-05-23 15:06:50 +00001965 QNX*)
1966 # -Wl,-E causes the symbols to be added to the dynamic
1967 # symbol table so that they can be found when a module
1968 # is loaded. -N 2048K causes the stack size to be set
1969 # to 2048 kilobytes so that the stack doesn't overflow
1970 # when running test_compile.py.
1971 LINKFORSHARED='-Wl,-E -N 2048K';;
Guido van Rossumac405f61994-09-12 10:56:06 +00001972 esac
Guido van Rossumac405f61994-09-12 10:56:06 +00001973fi
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001974AC_MSG_RESULT($LINKFORSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00001975
Ronald Oussoren0d236eb2008-06-06 21:31:33 +00001976
Neil Schemenauer61c51152001-01-26 16:18:16 +00001977AC_SUBST(CFLAGSFORSHARED)
1978AC_MSG_CHECKING(CFLAGSFORSHARED)
1979if test ! "$LIBRARY" = "$LDLIBRARY"
1980then
Neil Schemenauerd9cf41c2001-01-27 21:39:17 +00001981 case $ac_sys_system in
1982 CYGWIN*)
1983 # Cygwin needs CCSHARED when building extension DLLs
1984 # but not when building the interpreter DLL.
1985 CFLAGSFORSHARED='';;
1986 *)
1987 CFLAGSFORSHARED='$(CCSHARED)'
1988 esac
Neil Schemenauer61c51152001-01-26 16:18:16 +00001989fi
1990AC_MSG_RESULT($CFLAGSFORSHARED)
1991
Martin v. Löwisf90ae202002-06-11 06:22:31 +00001992# SHLIBS are libraries (except -lc and -lm) to link to the python shared
1993# library (with --enable-shared).
1994# For platforms on which shared libraries are not allowed to have unresolved
Martin v. Löwisd6359c52002-08-04 12:38:50 +00001995# symbols, this must be set to $(LIBS) (expanded by make). We do this even
1996# if it is not required, since it creates a dependency of the shared library
1997# to LIBS. This, in turn, means that applications linking the shared libpython
1998# don't need to link LIBS explicitly. The default should be only changed
1999# on systems where this approach causes problems.
Martin v. Löwisf90ae202002-06-11 06:22:31 +00002000AC_SUBST(SHLIBS)
2001AC_MSG_CHECKING(SHLIBS)
2002case "$ac_sys_system" in
Martin v. Löwisf90ae202002-06-11 06:22:31 +00002003 *)
Martin v. Löwisd6359c52002-08-04 12:38:50 +00002004 SHLIBS='$(LIBS)';;
Martin v. Löwisf90ae202002-06-11 06:22:31 +00002005esac
2006AC_MSG_RESULT($SHLIBS)
2007
2008
Guido van Rossum627b2d71993-12-24 10:39:16 +00002009# checks for libraries
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002010AC_CHECK_LIB(dl, dlopen) # Dynamic linking for SunOS/Solaris and SYSV
2011AC_CHECK_LIB(dld, shl_load) # Dynamic linking for HP-UX
Martin v. Löwis519adae2003-09-20 10:47:47 +00002012
Skip Montanaro4d756af2008-12-01 01:55:22 +00002013# only check for sem_init if thread support is requested
Martin v. Löwis519adae2003-09-20 10:47:47 +00002014if test "$with_threads" = "yes" -o -z "$with_threads"; then
2015 AC_SEARCH_LIBS(sem_init, pthread rt posix4) # 'Real Time' functions on Solaris
2016 # posix4 on Solaris 2.6
2017 # pthread (first!) on Linux
2018fi
2019
Martin v. Löwis19d17342003-06-14 21:03:05 +00002020# check if we need libintl for locale functions
2021AC_CHECK_LIB(intl, textdomain,
2022 AC_DEFINE(WITH_LIBINTL, 1,
2023 [Define to 1 if libintl is needed for locale functions.]))
Guido van Rossum0eefa3f1999-11-16 15:57:37 +00002024
2025# checks for system dependent C++ extensions support
2026case "$ac_sys_system" in
2027 AIX*) AC_MSG_CHECKING(for genuine AIX C++ extensions support)
2028 AC_TRY_LINK([#include "/usr/lpp/xlC/include/load.h"],
2029 [loadAndInit("", 0, "")],
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002030 [AC_DEFINE(AIX_GENUINE_CPLUSPLUS, 1,
2031 [Define for AIX if your compiler is a genuine IBM xlC/xlC_r
2032 and you want support for AIX C++ shared extension modules.])
Guido van Rossum0eefa3f1999-11-16 15:57:37 +00002033 AC_MSG_RESULT(yes)],
2034 [AC_MSG_RESULT(no)]);;
2035 *) ;;
2036esac
2037
Guido van Rossum70c7f481998-03-26 18:44:10 +00002038# Most SVR4 platforms (e.g. Solaris) need -lsocket and -lnsl.
Guido van Rossumec95c7b1998-08-04 17:59:56 +00002039# BeOS' sockets are stashed in libnet.
Guido van Rossumf618d2c1995-01-17 16:36:13 +00002040AC_CHECK_LIB(nsl, t_open, [LIBS="-lnsl $LIBS"]) # SVR4
Guido van Rossumf618d2c1995-01-17 16:36:13 +00002041AC_CHECK_LIB(socket, socket, [LIBS="-lsocket $LIBS"], [], $LIBS) # SVR4 sockets
Skip Montanarob9949db2004-01-17 04:04:13 +00002042
Jeremy Hyltoncb25d5e2000-07-27 21:23:28 +00002043case "$ac_sys_system" in
2044BeOS*)
Guido van Rossumec95c7b1998-08-04 17:59:56 +00002045AC_CHECK_LIB(net, socket, [LIBS="-lnet $LIBS"], [], $LIBS) # BeOS
2046;;
2047esac
Guido van Rossum70c7f481998-03-26 18:44:10 +00002048
Guido van Rossumc5a39031996-07-31 17:35:03 +00002049AC_MSG_CHECKING(for --with-libs)
Barry Warsawc0d24d82000-06-29 16:12:00 +00002050AC_ARG_WITH(libs,
Matthias Klose5183ebd2010-04-24 16:38:36 +00002051 AC_HELP_STRING([--with-libs='lib1 ...'], [link against additional libs]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002052[
Guido van Rossumc5a39031996-07-31 17:35:03 +00002053AC_MSG_RESULT($withval)
2054LIBS="$withval $LIBS"
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002055],
2056[AC_MSG_RESULT(no)])
Guido van Rossum627b2d71993-12-24 10:39:16 +00002057
Benjamin Petersone9e07bf2010-03-09 21:46:54 +00002058AC_PATH_TOOL([PKG_CONFIG], [pkg-config])
2059
Benjamin Peterson2c196742009-12-31 03:17:18 +00002060# Check for use of the system expat library
2061AC_MSG_CHECKING(for --with-system-expat)
2062AC_ARG_WITH(system_expat,
Matthias Klose5183ebd2010-04-24 16:38:36 +00002063 AC_HELP_STRING([--with-system-expat], [build pyexpat module using an installed expat library]))
Benjamin Peterson2c196742009-12-31 03:17:18 +00002064
2065AC_MSG_RESULT($with_system_expat)
2066
Martin v. Löwis9176fc12006-04-11 11:12:43 +00002067# Check for use of the system libffi library
2068AC_MSG_CHECKING(for --with-system-ffi)
2069AC_ARG_WITH(system_ffi,
Matthias Klose5183ebd2010-04-24 16:38:36 +00002070 AC_HELP_STRING([--with-system-ffi], [build _ctypes module using an installed ffi library]))
Martin v. Löwis9176fc12006-04-11 11:12:43 +00002071
Benjamin Petersone9e07bf2010-03-09 21:46:54 +00002072if test "$with_system_ffi" = "yes" && test -n "$PKG_CONFIG"; then
Benjamin Peterson1c335e62010-01-01 15:16:29 +00002073 LIBFFI_INCLUDEDIR="`"$PKG_CONFIG" libffi --cflags-only-I 2>/dev/null | sed -e 's/^-I//;s/ *$//'`"
2074else
2075 LIBFFI_INCLUDEDIR=""
2076fi
2077AC_SUBST(LIBFFI_INCLUDEDIR)
2078
Martin v. Löwis9176fc12006-04-11 11:12:43 +00002079AC_MSG_RESULT($with_system_ffi)
2080
Matthias Klose10cbe482009-04-29 17:18:19 +00002081# Check for --with-dbmliborder
2082AC_MSG_CHECKING(for --with-dbmliborder)
2083AC_ARG_WITH(dbmliborder,
Matthias Klose51c614e2009-04-29 19:52:49 +00002084 AC_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 +00002085[
2086if test x$with_dbmliborder = xyes
2087then
2088AC_MSG_ERROR([proper usage is --with-dbmliborder=db1:db2:...])
2089else
2090 for db in `echo $with_dbmliborder | sed 's/:/ /g'`; do
2091 if test x$db != xndbm && test x$db != xgdbm && test x$db != xbdb
2092 then
2093 AC_MSG_ERROR([proper usage is --with-dbmliborder=db1:db2:...])
2094 fi
2095 done
Matthias Klose61dbdb92009-04-29 20:09:50 +00002096fi])
2097AC_MSG_RESULT($with_dbmliborder)
Matthias Klose10cbe482009-04-29 17:18:19 +00002098
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00002099# Determine if signalmodule should be used.
2100AC_SUBST(USE_SIGNAL_MODULE)
2101AC_SUBST(SIGNAL_OBJS)
2102AC_MSG_CHECKING(for --with-signal-module)
2103AC_ARG_WITH(signal-module,
Matthias Klose5183ebd2010-04-24 16:38:36 +00002104 AC_HELP_STRING([--with-signal-module], [disable/enable signal module]))
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00002105
2106if test -z "$with_signal_module"
2107then with_signal_module="yes"
2108fi
2109AC_MSG_RESULT($with_signal_module)
2110
2111if test "${with_signal_module}" = "yes"; then
2112 USE_SIGNAL_MODULE=""
2113 SIGNAL_OBJS=""
2114else
2115 USE_SIGNAL_MODULE="#"
2116 SIGNAL_OBJS="Parser/intrcheck.o Python/sigcheck.o"
2117fi
2118
Guido van Rossum3d15bd82001-01-10 18:53:48 +00002119# This is used to generate Setup.config
Guido van Rossum009f7871997-12-04 00:51:42 +00002120AC_SUBST(USE_THREAD_MODULE)
Barry Warsawc0d24d82000-06-29 16:12:00 +00002121USE_THREAD_MODULE=""
Guido van Rossum009f7871997-12-04 00:51:42 +00002122
Guido van Rossum54d93d41997-01-22 20:51:58 +00002123AC_MSG_CHECKING(for --with-dec-threads)
2124AC_SUBST(LDLAST)
2125AC_ARG_WITH(dec-threads,
Matthias Klose5183ebd2010-04-24 16:38:36 +00002126 AC_HELP_STRING([--with-dec-threads], [use DEC Alpha/OSF1 thread-safe libraries]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002127[
Barry Warsawc0d24d82000-06-29 16:12:00 +00002128AC_MSG_RESULT($withval)
Guido van Rossum54d93d41997-01-22 20:51:58 +00002129LDLAST=-threads
Guido van Rossumf78abae1997-01-21 22:02:36 +00002130if test "${with_thread+set}" != set; then
Guido van Rossum54d93d41997-01-22 20:51:58 +00002131 with_thread="$withval";
2132fi],
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002133[AC_MSG_RESULT(no)])
Guido van Rossum54d93d41997-01-22 20:51:58 +00002134
Martin v. Löwis11437992002-04-12 09:54:03 +00002135# Templates for things AC_DEFINEd more than once.
2136# For a single AC_DEFINE, no template is needed.
2137AH_TEMPLATE(C_THREADS,[Define if you have the Mach cthreads package])
2138AH_TEMPLATE(_REENTRANT,
2139 [Define to force use of thread-safe errno, h_errno, and other functions])
2140AH_TEMPLATE(WITH_THREAD,
2141 [Define if you want to compile in rudimentary thread support])
2142
Guido van Rossum54d93d41997-01-22 20:51:58 +00002143AC_MSG_CHECKING(for --with-threads)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002144dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
Barry Warsawc0d24d82000-06-29 16:12:00 +00002145AC_ARG_WITH(threads,
Matthias Klose5183ebd2010-04-24 16:38:36 +00002146 AC_HELP_STRING([--with(out)-threads@<:@=DIRECTORY@:>@], [disable/enable thread support]))
Guido van Rossum54d93d41997-01-22 20:51:58 +00002147
Barry Warsawc0d24d82000-06-29 16:12:00 +00002148# --with-thread is deprecated, but check for it anyway
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002149dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
Barry Warsawa0f3c5c2000-06-30 16:39:35 +00002150AC_ARG_WITH(thread,
Matthias Klose5183ebd2010-04-24 16:38:36 +00002151 AC_HELP_STRING([--with(out)-thread@<:@=DIRECTORY@:>@], [deprecated; use --with(out)-threads]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002152 [with_threads=$with_thread])
Barry Warsawc0d24d82000-06-29 16:12:00 +00002153
2154if test -z "$with_threads"
2155then with_threads="yes"
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002156fi
Barry Warsawc0d24d82000-06-29 16:12:00 +00002157AC_MSG_RESULT($with_threads)
Guido van Rossum6400c261997-05-22 20:34:27 +00002158
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002159AC_SUBST(THREADOBJ)
Barry Warsawc0d24d82000-06-29 16:12:00 +00002160if test "$with_threads" = "no"
2161then
2162 USE_THREAD_MODULE="#"
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002163elif test "$ac_cv_pthread_is_default" = yes
2164then
2165 AC_DEFINE(WITH_THREAD)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002166 # Defining _REENTRANT on system with POSIX threads should not hurt.
2167 AC_DEFINE(_REENTRANT)
2168 posix_threads=yes
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002169 THREADOBJ="Python/thread.o"
Martin v. Löwis130fb172001-07-19 11:00:41 +00002170elif test "$ac_cv_kpthread" = "yes"
2171then
2172 CC="$CC -Kpthread"
Martin v. Löwis519adae2003-09-20 10:47:47 +00002173 if test "$ac_cv_cxx_thread" = "yes"; then
2174 CXX="$CXX -Kpthread"
2175 fi
Martin v. Löwis130fb172001-07-19 11:00:41 +00002176 AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002177 posix_threads=yes
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002178 THREADOBJ="Python/thread.o"
Martin v. Löwis5f433f02003-05-05 05:05:30 +00002179elif test "$ac_cv_kthread" = "yes"
2180then
2181 CC="$CC -Kthread"
Martin v. Löwis519adae2003-09-20 10:47:47 +00002182 if test "$ac_cv_cxx_thread" = "yes"; then
2183 CXX="$CXX -Kthread"
2184 fi
Martin v. Löwis5f433f02003-05-05 05:05:30 +00002185 AC_DEFINE(WITH_THREAD)
2186 posix_threads=yes
2187 THREADOBJ="Python/thread.o"
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002188elif test "$ac_cv_pthread" = "yes"
2189then
2190 CC="$CC -pthread"
Martin v. Löwis519adae2003-09-20 10:47:47 +00002191 if test "$ac_cv_cxx_thread" = "yes"; then
2192 CXX="$CXX -pthread"
2193 fi
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002194 AC_DEFINE(WITH_THREAD)
2195 posix_threads=yes
2196 THREADOBJ="Python/thread.o"
Barry Warsawc0d24d82000-06-29 16:12:00 +00002197else
Martin v. Löwis130fb172001-07-19 11:00:41 +00002198 if test ! -z "$with_threads" -a -d "$with_threads"
2199 then LDFLAGS="$LDFLAGS -L$with_threads"
2200 fi
2201 if test ! -z "$withval" -a -d "$withval"
2202 then LDFLAGS="$LDFLAGS -L$withval"
2203 fi
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002204
2205 # According to the POSIX spec, a pthreads implementation must
Matthias Klosea2542be2004-08-16 11:35:51 +00002206 # define _POSIX_THREADS in unistd.h. Some apparently don't
2207 # (e.g. gnu pth with pthread emulation)
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002208 AC_MSG_CHECKING(for _POSIX_THREADS in unistd.h)
2209 AC_EGREP_CPP(yes,
Neal Norwitz6eb37f02003-02-23 23:28:15 +00002210 [
2211#include <unistd.h>
2212#ifdef _POSIX_THREADS
2213yes
2214#endif
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002215 ], unistd_defines_pthreads=yes, unistd_defines_pthreads=no)
2216 AC_MSG_RESULT($unistd_defines_pthreads)
2217
Martin v. Löwis130fb172001-07-19 11:00:41 +00002218 AC_DEFINE(_REENTRANT)
Martin v. Löwisa6e97582002-01-01 18:41:33 +00002219 AC_CHECK_HEADER(cthreads.h, [AC_DEFINE(WITH_THREAD)
2220 AC_DEFINE(C_THREADS)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002221 AC_DEFINE(HURD_C_THREADS, 1,
2222 [Define if you are using Mach cthreads directly under /include])
Martin v. Löwisa6e97582002-01-01 18:41:33 +00002223 LIBS="$LIBS -lthreads"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002224 THREADOBJ="Python/thread.o"],[
Martin v. Löwis130fb172001-07-19 11:00:41 +00002225 AC_CHECK_HEADER(mach/cthreads.h, [AC_DEFINE(WITH_THREAD)
2226 AC_DEFINE(C_THREADS)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002227 AC_DEFINE(MACH_C_THREADS, 1,
2228 [Define if you are using Mach cthreads under mach /])
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002229 THREADOBJ="Python/thread.o"],[
Martin v. Löwis130fb172001-07-19 11:00:41 +00002230 AC_MSG_CHECKING(for --with-pth)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002231 AC_ARG_WITH([pth],
Matthias Klose5183ebd2010-04-24 16:38:36 +00002232 AC_HELP_STRING([--with-pth], [use GNU pth threading libraries]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002233 [AC_MSG_RESULT($withval)
2234 AC_DEFINE([WITH_THREAD])
2235 AC_DEFINE([HAVE_PTH], 1,
2236 [Define if you have GNU PTH threads.])
2237 LIBS="-lpth $LIBS"
2238 THREADOBJ="Python/thread.o"],
2239 [AC_MSG_RESULT(no)
Martin v. Löwis8158b5a2001-10-08 13:17:28 +00002240
2241 # Just looking for pthread_create in libpthread is not enough:
2242 # on HP/UX, pthread.h renames pthread_create to a different symbol name.
2243 # So we really have to include pthread.h, and then link.
2244 _libs=$LIBS
2245 LIBS="$LIBS -lpthread"
2246 AC_MSG_CHECKING([for pthread_create in -lpthread])
2247 AC_TRY_LINK([#include <pthread.h>
2248
2249void * start_routine (void *arg) { exit (0); }], [
2250pthread_create (NULL, NULL, start_routine, NULL)], [
2251 AC_MSG_RESULT(yes)
2252 AC_DEFINE(WITH_THREAD)
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002253 posix_threads=yes
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002254 THREADOBJ="Python/thread.o"],[
Martin v. Löwis8158b5a2001-10-08 13:17:28 +00002255 LIBS=$_libs
Martin v. Löwis130fb172001-07-19 11:00:41 +00002256 AC_CHECK_FUNC(pthread_detach, [AC_DEFINE(WITH_THREAD)
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002257 posix_threads=yes
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002258 THREADOBJ="Python/thread.o"],[
Martin v. Löwisf90ae202002-06-11 06:22:31 +00002259 AC_CHECK_HEADER(atheos/threads.h, [AC_DEFINE(WITH_THREAD)
2260 AC_DEFINE(ATHEOS_THREADS, 1,
2261 [Define this if you have AtheOS threads.])
2262 THREADOBJ="Python/thread.o"],[
Martin v. Löwis130fb172001-07-19 11:00:41 +00002263 AC_CHECK_HEADER(kernel/OS.h, [AC_DEFINE(WITH_THREAD)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002264 AC_DEFINE(BEOS_THREADS, 1,
2265 [Define this if you have BeOS threads.])
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002266 THREADOBJ="Python/thread.o"],[
Martin v. Löwis130fb172001-07-19 11:00:41 +00002267 AC_CHECK_LIB(pthreads, pthread_create, [AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002268 posix_threads=yes
Martin v. Löwis130fb172001-07-19 11:00:41 +00002269 LIBS="$LIBS -lpthreads"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002270 THREADOBJ="Python/thread.o"], [
Martin v. Löwis130fb172001-07-19 11:00:41 +00002271 AC_CHECK_LIB(c_r, pthread_create, [AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002272 posix_threads=yes
Martin v. Löwis130fb172001-07-19 11:00:41 +00002273 LIBS="$LIBS -lc_r"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002274 THREADOBJ="Python/thread.o"], [
Martin v. Löwis130fb172001-07-19 11:00:41 +00002275 AC_CHECK_LIB(pthread, __pthread_create_system, [AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002276 posix_threads=yes
Martin v. Löwis130fb172001-07-19 11:00:41 +00002277 LIBS="$LIBS -lpthread"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002278 THREADOBJ="Python/thread.o"], [
Martin v. Löwis130fb172001-07-19 11:00:41 +00002279 AC_CHECK_LIB(cma, pthread_create, [AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002280 posix_threads=yes
Martin v. Löwis130fb172001-07-19 11:00:41 +00002281 LIBS="$LIBS -lcma"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002282 THREADOBJ="Python/thread.o"],[
Martin v. Löwis130fb172001-07-19 11:00:41 +00002283 USE_THREAD_MODULE="#"])
Skip Montanarof8712e52004-01-17 03:04:46 +00002284 ])])])])])])])])])])
Barry Warsawc0d24d82000-06-29 16:12:00 +00002285
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002286 AC_CHECK_LIB(mpc, usconfig, [AC_DEFINE(WITH_THREAD)
2287 LIBS="$LIBS -lmpc"
2288 THREADOBJ="Python/thread.o"
2289 USE_THREAD_MODULE=""])
2290
2291 if test "$posix_threads" != "yes"; then
2292 AC_CHECK_LIB(thread, thr_create, [AC_DEFINE(WITH_THREAD)
2293 LIBS="$LIBS -lthread"
2294 THREADOBJ="Python/thread.o"
2295 USE_THREAD_MODULE=""])
2296 fi
2297
2298 if test "$USE_THREAD_MODULE" != "#"
2299 then
2300 # If the above checks didn't disable threads, (at least) OSF1
2301 # needs this '-threads' argument during linking.
2302 case $ac_sys_system in
2303 OSF1) LDLAST=-threads;;
2304 esac
2305 fi
2306fi
2307
2308if test "$posix_threads" = "yes"; then
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002309 if test "$unistd_defines_pthreads" = "no"; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002310 AC_DEFINE(_POSIX_THREADS, 1,
2311 [Define if you have POSIX threads,
2312 and your system does not define that.])
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002313 fi
2314
Martin v. Löwisdfc33fd2003-01-21 10:14:41 +00002315 # Bug 662787: Using semaphores causes unexplicable hangs on Solaris 8.
2316 case $ac_sys_system/$ac_sys_release in
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002317 SunOS/5.6) AC_DEFINE(HAVE_PTHREAD_DESTRUCTOR, 1,
Matthias Klose5183ebd2010-04-24 16:38:36 +00002318 [Defined for Solaris 2.6 bug in pthread header.])
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002319 ;;
Martin v. Löwisdfc33fd2003-01-21 10:14:41 +00002320 SunOS/5.8) AC_DEFINE(HAVE_BROKEN_POSIX_SEMAPHORES, 1,
Matthias Klose5183ebd2010-04-24 16:38:36 +00002321 [Define if the Posix semaphores do not work on your system])
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002322 ;;
Christian Heimescba36bb2008-01-30 22:54:18 +00002323 AIX/5) AC_DEFINE(HAVE_BROKEN_POSIX_SEMAPHORES, 1,
Matthias Klose5183ebd2010-04-24 16:38:36 +00002324 [Define if the Posix semaphores do not work on your system])
Christian Heimescba36bb2008-01-30 22:54:18 +00002325 ;;
Martin v. Löwisdfc33fd2003-01-21 10:14:41 +00002326 esac
2327
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002328 AC_MSG_CHECKING(if PTHREAD_SCOPE_SYSTEM is supported)
2329 AC_CACHE_VAL(ac_cv_pthread_system_supported,
2330 [AC_TRY_RUN([#include <pthread.h>
2331 void *foo(void *parm) {
2332 return NULL;
2333 }
2334 main() {
2335 pthread_attr_t attr;
Martin v. Löwisa82d3472002-02-24 16:05:05 +00002336 pthread_t id;
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002337 if (pthread_attr_init(&attr)) exit(-1);
2338 if (pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM)) exit(-1);
Martin v. Löwisa82d3472002-02-24 16:05:05 +00002339 if (pthread_create(&id, &attr, foo, NULL)) exit(-1);
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002340 exit(0);
Guido van Rossum3065c942001-09-17 04:03:14 +00002341 }],
2342 ac_cv_pthread_system_supported=yes,
2343 ac_cv_pthread_system_supported=no,
2344 ac_cv_pthread_system_supported=no)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002345 ])
2346 AC_MSG_RESULT($ac_cv_pthread_system_supported)
2347 if test "$ac_cv_pthread_system_supported" = "yes"; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002348 AC_DEFINE(PTHREAD_SYSTEM_SCHED_SUPPORTED, 1, [Defined if PTHREAD_SCOPE_SYSTEM supported.])
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002349 fi
Jason Tishlerfac083d2003-07-22 15:20:49 +00002350 AC_CHECK_FUNCS(pthread_sigmask,
2351 [case $ac_sys_system in
2352 CYGWIN*)
2353 AC_DEFINE(HAVE_BROKEN_PTHREAD_SIGMASK, 1,
2354 [Define if pthread_sigmask() does not work on your system.])
2355 ;;
2356 esac])
Barry Warsawc0d24d82000-06-29 16:12:00 +00002357fi
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002358
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002359
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002360# Check for enable-ipv6
Martin v. Löwis11437992002-04-12 09:54:03 +00002361AH_TEMPLATE(ENABLE_IPV6, [Define if --enable-ipv6 is specified])
Martin v. Löwisa5f8bb52001-09-05 08:22:34 +00002362AC_MSG_CHECKING([if --enable-ipv6 is specified])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002363AC_ARG_ENABLE(ipv6,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002364[ --enable-ipv6 Enable ipv6 (with ipv4) support
2365 --disable-ipv6 Disable ipv6 support],
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002366[ case "$enableval" in
2367 no)
2368 AC_MSG_RESULT(no)
2369 ipv6=no
2370 ;;
2371 *) AC_MSG_RESULT(yes)
2372 AC_DEFINE(ENABLE_IPV6)
2373 ipv6=yes
2374 ;;
2375 esac ],
2376
Martin v. Löwisa5f8bb52001-09-05 08:22:34 +00002377[
2378dnl the check does not work on cross compilation case...
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002379 AC_TRY_RUN([ /* AF_INET6 available check */
2380#include <sys/types.h>
2381#include <sys/socket.h>
2382main()
2383{
2384 if (socket(AF_INET6, SOCK_STREAM, 0) < 0)
2385 exit(1);
2386 else
2387 exit(0);
2388}
2389],
2390 AC_MSG_RESULT(yes)
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002391 ipv6=yes,
2392 AC_MSG_RESULT(no)
2393 ipv6=no,
2394 AC_MSG_RESULT(no)
2395 ipv6=no
Martin v. Löwisa5f8bb52001-09-05 08:22:34 +00002396)
2397
2398if test "$ipv6" = "yes"; then
2399 AC_MSG_CHECKING(if RFC2553 API is available)
2400 AC_TRY_COMPILE([#include <sys/types.h>
2401#include <netinet/in.h>],
2402 [struct sockaddr_in6 x;
2403x.sin6_scope_id;],
2404 AC_MSG_RESULT(yes)
2405 ipv6=yes,
2406 AC_MSG_RESULT(no, IPv6 disabled)
2407 ipv6=no)
2408fi
2409
2410if test "$ipv6" = "yes"; then
2411 AC_DEFINE(ENABLE_IPV6)
2412fi
2413])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002414
2415ipv6type=unknown
2416ipv6lib=none
2417ipv6trylibc=no
2418
2419if test "$ipv6" = "yes"; then
2420 AC_MSG_CHECKING([ipv6 stack type])
Guido van Rossumb8552162001-09-05 14:58:11 +00002421 for i in inria kame linux-glibc linux-inet6 solaris toshiba v6d zeta;
2422 do
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002423 case $i in
2424 inria)
2425 dnl http://www.kame.net/
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002426 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002427#include <netinet/in.h>
2428#ifdef IPV6_INRIA_VERSION
2429yes
2430#endif],
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002431 [ipv6type=$i])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002432 ;;
2433 kame)
2434 dnl http://www.kame.net/
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002435 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002436#include <netinet/in.h>
2437#ifdef __KAME__
2438yes
2439#endif],
2440 [ipv6type=$i;
2441 ipv6lib=inet6
2442 ipv6libdir=/usr/local/v6/lib
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002443 ipv6trylibc=yes])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002444 ;;
2445 linux-glibc)
2446 dnl http://www.v6.linux.or.jp/
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002447 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002448#include <features.h>
2449#if defined(__GLIBC__) && ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1) || (__GLIBC__ > 2))
2450yes
2451#endif],
2452 [ipv6type=$i;
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002453 ipv6trylibc=yes])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002454 ;;
2455 linux-inet6)
2456 dnl http://www.v6.linux.or.jp/
2457 if test -d /usr/inet6; then
2458 ipv6type=$i
2459 ipv6lib=inet6
2460 ipv6libdir=/usr/inet6/lib
Skip Montanarodecc6a42003-01-01 20:07:49 +00002461 BASECFLAGS="-I/usr/inet6/include $BASECFLAGS"
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002462 fi
2463 ;;
2464 solaris)
2465 if test -f /etc/netconfig; then
2466 if /usr/xpg4/bin/grep -q tcp6 /etc/netconfig; then
2467 ipv6type=$i
2468 ipv6trylibc=yes
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002469 fi
2470 fi
2471 ;;
2472 toshiba)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002473 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002474#include <sys/param.h>
2475#ifdef _TOSHIBA_INET6
2476yes
2477#endif],
2478 [ipv6type=$i;
2479 ipv6lib=inet6;
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002480 ipv6libdir=/usr/local/v6/lib])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002481 ;;
2482 v6d)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002483 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002484#include </usr/local/v6/include/sys/v6config.h>
2485#ifdef __V6D__
2486yes
2487#endif],
2488 [ipv6type=$i;
2489 ipv6lib=v6;
2490 ipv6libdir=/usr/local/v6/lib;
Skip Montanarodecc6a42003-01-01 20:07:49 +00002491 BASECFLAGS="-I/usr/local/v6/include $BASECFLAGS"])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002492 ;;
2493 zeta)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002494 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002495#include <sys/param.h>
2496#ifdef _ZETA_MINAMI_INET6
2497yes
2498#endif],
2499 [ipv6type=$i;
2500 ipv6lib=inet6;
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002501 ipv6libdir=/usr/local/v6/lib])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002502 ;;
2503 esac
2504 if test "$ipv6type" != "unknown"; then
2505 break
2506 fi
2507 done
2508 AC_MSG_RESULT($ipv6type)
2509fi
2510
2511if test "$ipv6" = "yes" -a "$ipv6lib" != "none"; then
2512 if test -d $ipv6libdir -a -f $ipv6libdir/lib$ipv6lib.a; then
2513 LIBS="-L$ipv6libdir -l$ipv6lib $LIBS"
2514 echo "using lib$ipv6lib"
2515 else
2516 if test $ipv6trylibc = "yes"; then
2517 echo "using libc"
2518 else
2519 echo 'Fatal: no $ipv6lib library found. cannot continue.'
2520 echo "You need to fetch lib$ipv6lib.a from appropriate"
2521 echo 'ipv6 kit and compile beforehand.'
2522 exit 1
2523 fi
2524 fi
2525fi
2526
Ronald Oussoren0d236eb2008-06-06 21:31:33 +00002527AC_MSG_CHECKING(for OSX 10.5 SDK or later)
2528AC_TRY_COMPILE([#include <Carbon/Carbon.h>], FSIORefNum fRef = 0,
Matthias Klose5183ebd2010-04-24 16:38:36 +00002529 AC_DEFINE(HAVE_OSX105_SDK, 1, [Define if compiling using MacOS X 10.5 SDK or later.])
Ronald Oussoren0d236eb2008-06-06 21:31:33 +00002530 AC_MSG_RESULT(yes),
2531 AC_MSG_RESULT(no)
2532)
2533
Martin v. Löwisa3fb4f72002-06-09 13:33:54 +00002534# Check for --with-doc-strings
2535AC_MSG_CHECKING(for --with-doc-strings)
2536AC_ARG_WITH(doc-strings,
Matthias Klose5183ebd2010-04-24 16:38:36 +00002537 AC_HELP_STRING([--with(out)-doc-strings], [disable/enable documentation strings]))
Martin v. Löwisa3fb4f72002-06-09 13:33:54 +00002538
2539if test -z "$with_doc_strings"
2540then with_doc_strings="yes"
2541fi
2542if test "$with_doc_strings" != "no"
2543then
2544 AC_DEFINE(WITH_DOC_STRINGS, 1,
2545 [Define if you want documentation strings in extension modules])
2546fi
2547AC_MSG_RESULT($with_doc_strings)
2548
Neil Schemenauera35c6882001-02-27 04:45:05 +00002549# Check for Python-specific malloc support
Martin v. Löwisf30d60e2004-06-08 08:17:44 +00002550AC_MSG_CHECKING(for --with-tsc)
2551AC_ARG_WITH(tsc,
Matthias Klose5183ebd2010-04-24 16:38:36 +00002552 AC_HELP_STRING([--with(out)-tsc],[enable/disable timestamp counter profile]),[
Martin v. Löwisf30d60e2004-06-08 08:17:44 +00002553if test "$withval" != no
2554then
2555 AC_DEFINE(WITH_TSC, 1,
2556 [Define to profile with the Pentium timestamp counter])
2557 AC_MSG_RESULT(yes)
2558else AC_MSG_RESULT(no)
2559fi],
2560[AC_MSG_RESULT(no)])
2561
2562# Check for Python-specific malloc support
Neil Schemenauera35c6882001-02-27 04:45:05 +00002563AC_MSG_CHECKING(for --with-pymalloc)
2564AC_ARG_WITH(pymalloc,
Matthias Klose5183ebd2010-04-24 16:38:36 +00002565 AC_HELP_STRING([--with(out)-pymalloc], [disable/enable specialized mallocs]))
Neil Schemenauer16c22972002-03-22 15:34:49 +00002566
2567if test -z "$with_pymalloc"
2568then with_pymalloc="yes"
2569fi
2570if test "$with_pymalloc" != "no"
2571then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002572 AC_DEFINE(WITH_PYMALLOC, 1,
2573 [Define if you want to compile in Python-specific mallocs])
Neil Schemenauer16c22972002-03-22 15:34:49 +00002574fi
2575AC_MSG_RESULT($with_pymalloc)
Neil Schemenauera35c6882001-02-27 04:45:05 +00002576
Benjamin Peterson91c12eb2009-12-03 02:52:39 +00002577# Check for Valgrind support
2578AC_MSG_CHECKING([for --with-valgrind])
2579AC_ARG_WITH([valgrind],
2580 AC_HELP_STRING([--with-valgrind], [Enable Valgrind support]),,
2581 with_valgrind=no)
2582AC_MSG_RESULT([$with_valgrind])
2583if test "$with_valgrind" != no; then
2584 AC_CHECK_HEADER([valgrind/valgrind.h],
2585 [AC_DEFINE([WITH_VALGRIND], 1, [Define if you want pymalloc to be disabled when running under valgrind])],
2586 [AC_MSG_ERROR([Valgrind support requested but headers not available])]
2587 )
2588fi
2589
Barry Warsawef82cd72000-06-30 16:21:01 +00002590# Check for --with-wctype-functions
2591AC_MSG_CHECKING(for --with-wctype-functions)
2592AC_ARG_WITH(wctype-functions,
Matthias Klose5183ebd2010-04-24 16:38:36 +00002593 AC_HELP_STRING([--with-wctype-functions], [use wctype.h functions]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002594[
Barry Warsawef82cd72000-06-30 16:21:01 +00002595if test "$withval" != no
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002596then
2597 AC_DEFINE(WANT_WCTYPE_FUNCTIONS, 1,
2598 [Define if you want wctype.h functions to be used instead of the
2599 one supplied by Python itself. (see Include/unicodectype.h).])
2600 AC_MSG_RESULT(yes)
Barry Warsawef82cd72000-06-30 16:21:01 +00002601else AC_MSG_RESULT(no)
2602fi],
2603[AC_MSG_RESULT(no)])
2604
Guido van Rossum68242b51996-05-28 22:53:03 +00002605# -I${DLINCLDIR} is added to the compile rule for importdl.o
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002606AC_SUBST(DLINCLDIR)
Guido van Rossum98935bf2001-09-05 19:13:16 +00002607DLINCLDIR=.
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002608
Guido van Rossume97ee181999-12-20 21:27:22 +00002609# the dlopen() function means we might want to use dynload_shlib.o. some
2610# platforms, such as AIX, have dlopen(), but don't want to use it.
Thomas Wouters3a584202000-08-05 23:28:51 +00002611AC_CHECK_FUNCS(dlopen)
Guido van Rossume97ee181999-12-20 21:27:22 +00002612
2613# DYNLOADFILE specifies which dynload_*.o file we will use for dynamic
2614# loading of modules.
2615AC_SUBST(DYNLOADFILE)
2616AC_MSG_CHECKING(DYNLOADFILE)
2617if test -z "$DYNLOADFILE"
2618then
2619 case $ac_sys_system/$ac_sys_release in
Martin v. Löwisc19c5a62003-11-18 20:00:44 +00002620 AIX*) # Use dynload_shlib.c and dlopen() if we have it; otherwise dynload_aix.c
2621 if test "$ac_cv_func_dlopen" = yes
2622 then DYNLOADFILE="dynload_shlib.o"
2623 else DYNLOADFILE="dynload_aix.o"
2624 fi
2625 ;;
Guido van Rossume97ee181999-12-20 21:27:22 +00002626 BeOS*) DYNLOADFILE="dynload_beos.o";;
2627 hp*|HP*) DYNLOADFILE="dynload_hpux.o";;
Anthony Baxter82201742006-04-09 15:07:40 +00002628 # Use dynload_next.c only on 10.2 and below, which don't have native dlopen()
2629 Darwin/@<:@0156@:>@\..*) DYNLOADFILE="dynload_next.o";;
Martin v. Löwisf90ae202002-06-11 06:22:31 +00002630 atheos*) DYNLOADFILE="dynload_atheos.o";;
Guido van Rossume97ee181999-12-20 21:27:22 +00002631 *)
2632 # use dynload_shlib.c and dlopen() if we have it; otherwise stub
2633 # out any dynamic loading
2634 if test "$ac_cv_func_dlopen" = yes
2635 then DYNLOADFILE="dynload_shlib.o"
2636 else DYNLOADFILE="dynload_stub.o"
2637 fi
2638 ;;
2639 esac
2640fi
2641AC_MSG_RESULT($DYNLOADFILE)
2642if test "$DYNLOADFILE" != "dynload_stub.o"
2643then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002644 AC_DEFINE(HAVE_DYNAMIC_LOADING, 1,
2645 [Defined when any dynamic module loading is enabled.])
Guido van Rossume97ee181999-12-20 21:27:22 +00002646fi
2647
Jack Jansenc49e5b72001-06-19 15:00:23 +00002648# MACHDEP_OBJS can be set to platform-specific object files needed by Python
2649
2650AC_SUBST(MACHDEP_OBJS)
2651AC_MSG_CHECKING(MACHDEP_OBJS)
2652if test -z "$MACHDEP_OBJS"
2653then
Jack Jansenb6e9cad2001-08-15 01:26:28 +00002654 MACHDEP_OBJS=$extra_machdep_objs
2655else
2656 MACHDEP_OBJS="$MACHDEP_OBJS $extra_machdep_objs"
Jack Jansenc49e5b72001-06-19 15:00:23 +00002657fi
Jack Jansenb6e9cad2001-08-15 01:26:28 +00002658AC_MSG_RESULT(MACHDEP_OBJS)
Jack Jansenc49e5b72001-06-19 15:00:23 +00002659
Guido van Rossum627b2d71993-12-24 10:39:16 +00002660# checks for library functions
Martin v. Löwisaef18b12008-03-24 13:31:16 +00002661AC_CHECK_FUNCS(alarm setitimer getitimer bind_textdomain_codeset chown \
2662 clock confstr ctermid execv fchmod fchown fork fpathconf ftime ftruncate \
Martin v. Löwis438b5342002-12-27 10:16:42 +00002663 gai_strerror getgroups getlogin getloadavg getpeername getpgid getpid \
Martin v. Löwis50ea4562009-11-27 13:56:01 +00002664 getpriority getresuid getresgid getpwent getspnam getspent getsid getwd \
Antoine Pitrou30b3b352009-12-02 20:37:54 +00002665 initgroups kill killpg lchmod lchown lstat mkfifo mknod mktime \
Martin v. Löwisa5f09072002-10-11 05:37:59 +00002666 mremap nice pathconf pause plock poll pthread_init \
Guido van Rossum162e38c2003-02-19 15:25:10 +00002667 putenv readlink realpath \
Jesse Noller355b1262009-04-02 00:03:28 +00002668 select sem_open sem_timedwait sem_getvalue sem_unlink setegid seteuid \
2669 setgid \
Martin v. Löwis4daacb12003-03-28 18:37:01 +00002670 setlocale setregid setreuid setsid setpgid setpgrp setuid setvbuf snprintf \
Martin v. Löwis50ea4562009-11-27 13:56:01 +00002671 setlocale setregid setreuid setresuid setresgid \
2672 setsid setpgid setpgrp setuid setvbuf snprintf \
Skip Montanaro7e11a012004-02-07 12:55:46 +00002673 sigaction siginterrupt sigrelse strftime \
Michael W. Hudson34f20ea2002-05-27 15:08:24 +00002674 sysconf tcgetpgrp tcsetpgrp tempnam timegm times tmpfile tmpnam tmpnam_r \
Neal Norwitz05a45592006-03-20 06:30:08 +00002675 truncate uname unsetenv utimes waitpid wait3 wait4 wcscoll _getpty)
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00002676
Martin v. Löwisc8ad7cc2002-11-11 13:23:45 +00002677# For some functions, having a definition is not sufficient, since
2678# we want to take their address.
2679AC_MSG_CHECKING(for chroot)
Matthias Klose5183ebd2010-04-24 16:38:36 +00002680AC_TRY_COMPILE([#include <unistd.h>], [void *x=chroot],
2681 AC_DEFINE(HAVE_CHROOT, 1, [Define if you have the 'chroot' function.])
Martin v. Löwisc8ad7cc2002-11-11 13:23:45 +00002682 AC_MSG_RESULT(yes),
2683 AC_MSG_RESULT(no)
2684)
2685AC_MSG_CHECKING(for link)
Matthias Klose5183ebd2010-04-24 16:38:36 +00002686AC_TRY_COMPILE([#include <unistd.h>], [void *x=link],
2687 AC_DEFINE(HAVE_LINK, 1, [Define if you have the 'link' function.])
Martin v. Löwisc8ad7cc2002-11-11 13:23:45 +00002688 AC_MSG_RESULT(yes),
2689 AC_MSG_RESULT(no)
2690)
2691AC_MSG_CHECKING(for symlink)
Matthias Klose5183ebd2010-04-24 16:38:36 +00002692AC_TRY_COMPILE([#include <unistd.h>], [void *x=symlink],
2693 AC_DEFINE(HAVE_SYMLINK, 1, [Define if you have the 'symlink' function.])
Martin v. Löwisc8ad7cc2002-11-11 13:23:45 +00002694 AC_MSG_RESULT(yes),
2695 AC_MSG_RESULT(no)
2696)
Martin v. Löwisa64988c2003-09-20 15:30:20 +00002697AC_MSG_CHECKING(for fchdir)
Matthias Klose5183ebd2010-04-24 16:38:36 +00002698AC_TRY_COMPILE([#include <unistd.h>], [void *x=fchdir],
2699 AC_DEFINE(HAVE_FCHDIR, 1, [Define if you have the 'fchdir' function.])
Martin v. Löwisa64988c2003-09-20 15:30:20 +00002700 AC_MSG_RESULT(yes),
2701 AC_MSG_RESULT(no)
2702)
2703AC_MSG_CHECKING(for fsync)
Matthias Klose5183ebd2010-04-24 16:38:36 +00002704AC_TRY_COMPILE([#include <unistd.h>], [void *x=fsync],
2705 AC_DEFINE(HAVE_FSYNC, 1, [Define if you have the 'fsync' function.])
Martin v. Löwisa64988c2003-09-20 15:30:20 +00002706 AC_MSG_RESULT(yes),
2707 AC_MSG_RESULT(no)
2708)
2709AC_MSG_CHECKING(for fdatasync)
Matthias Klose5183ebd2010-04-24 16:38:36 +00002710AC_TRY_COMPILE([#include <unistd.h>], [void *x=fdatasync],
2711 AC_DEFINE(HAVE_FDATASYNC, 1, [Define if you have the 'fdatasync' function.])
Martin v. Löwisa64988c2003-09-20 15:30:20 +00002712 AC_MSG_RESULT(yes),
2713 AC_MSG_RESULT(no)
2714)
Christian Heimes0e9ab5f2008-03-21 23:49:44 +00002715AC_MSG_CHECKING(for epoll)
Matthias Klose5183ebd2010-04-24 16:38:36 +00002716AC_TRY_COMPILE([#include <sys/epoll.h>], [void *x=epoll_create],
2717 AC_DEFINE(HAVE_EPOLL, 1, [Define if you have the 'epoll' functions.])
Christian Heimes0e9ab5f2008-03-21 23:49:44 +00002718 AC_MSG_RESULT(yes),
2719 AC_MSG_RESULT(no)
2720)
2721AC_MSG_CHECKING(for kqueue)
2722AC_TRY_COMPILE([
2723#include <sys/types.h>
2724#include <sys/event.h>
Matthias Klose5183ebd2010-04-24 16:38:36 +00002725 ], [int x=kqueue()],
2726 AC_DEFINE(HAVE_KQUEUE, 1, [Define if you have the 'kqueue' functions.])
Christian Heimes0e9ab5f2008-03-21 23:49:44 +00002727 AC_MSG_RESULT(yes),
2728 AC_MSG_RESULT(no)
2729)
Martin v. Löwisd5843682002-11-21 20:41:28 +00002730# On some systems (eg. FreeBSD 5), we would find a definition of the
2731# functions ctermid_r, setgroups in the library, but no prototype
2732# (e.g. because we use _XOPEN_SOURCE). See whether we can take their
2733# address to avoid compiler warnings and potential miscompilations
2734# because of the missing prototypes.
2735
2736AC_MSG_CHECKING(for ctermid_r)
2737AC_TRY_COMPILE([
2738#include "confdefs.h"
2739#include <stdio.h>
Matthias Klose5183ebd2010-04-24 16:38:36 +00002740], [void* p = ctermid_r],
2741 AC_DEFINE(HAVE_CTERMID_R, 1, [Define if you have the 'ctermid_r' function.])
Martin v. Löwisd5843682002-11-21 20:41:28 +00002742 AC_MSG_RESULT(yes),
2743 AC_MSG_RESULT(no)
2744)
2745
Martin v. Löwisf26d63b2003-03-30 17:23:49 +00002746AC_MSG_CHECKING(for flock)
2747AC_TRY_COMPILE([
2748#include "confdefs.h"
2749#include <sys/file.h>
Matthias Klose5183ebd2010-04-24 16:38:36 +00002750], [void* p = flock],
2751 AC_DEFINE(HAVE_FLOCK, 1, [Define if you have the 'flock' function.])
Martin v. Löwisf26d63b2003-03-30 17:23:49 +00002752 AC_MSG_RESULT(yes),
2753 AC_MSG_RESULT(no)
2754)
2755
2756AC_MSG_CHECKING(for getpagesize)
2757AC_TRY_COMPILE([
2758#include "confdefs.h"
2759#include <unistd.h>
Matthias Klose5183ebd2010-04-24 16:38:36 +00002760], [void* p = getpagesize],
2761 AC_DEFINE(HAVE_GETPAGESIZE, 1, [Define if you have the 'getpagesize' function.])
Martin v. Löwisf26d63b2003-03-30 17:23:49 +00002762 AC_MSG_RESULT(yes),
2763 AC_MSG_RESULT(no)
2764)
2765
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002766dnl check for true
2767AC_CHECK_PROGS(TRUE, true, /bin/true)
2768
Martin v. Löwis95c419b2003-05-03 12:10:48 +00002769dnl On some systems (e.g. Solaris 9), hstrerror and inet_aton are in -lresolv
2770dnl On others, they are in the C library, so we to take no action
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002771AC_CHECK_LIB(c, inet_aton, [$ac_cv_prog_TRUE],
Martin v. Löwis95c419b2003-05-03 12:10:48 +00002772 AC_CHECK_LIB(resolv, inet_aton)
2773)
2774
Martin v. Löwisa51d5c82007-12-04 08:37:59 +00002775# On Tru64, chflags seems to be present, but calling it will
2776# exit Python
Gregory P. Smithbb213892009-11-02 01:37:37 +00002777AC_CACHE_CHECK([for chflags], [ac_cv_have_chflags], [dnl
Alexandre Vassalotti30267d62009-07-17 06:10:06 +00002778AC_TRY_RUN([[
Martin v. Löwisa51d5c82007-12-04 08:37:59 +00002779#include <sys/stat.h>
2780#include <unistd.h>
2781int main(int argc, char*argv[])
2782{
2783 if(chflags(argv[0], 0) != 0)
2784 return 1;
2785 return 0;
2786}
Alexandre Vassalotti30267d62009-07-17 06:10:06 +00002787]], ac_cv_have_chflags=yes,
Alexandre Vassalotti00900892009-07-17 05:26:39 +00002788 ac_cv_have_chflags=no,
Gregory P. Smithbb213892009-11-02 01:37:37 +00002789 ac_cv_have_chflags=cross)
2790])
2791if test "$ac_cv_have_chflags" = cross ; then
2792 AC_CHECK_FUNC([chflags], [ac_cv_have_chflags="yes"], [ac_cv_have_chflags="no"])
2793fi
2794if test "$ac_cv_have_chflags" = yes ; then
Matthias Klose5183ebd2010-04-24 16:38:36 +00002795 AC_DEFINE(HAVE_CHFLAGS, 1, [Define to 1 if you have the `chflags' function.])
Alexandre Vassalotti00900892009-07-17 05:26:39 +00002796fi
Martin v. Löwisa51d5c82007-12-04 08:37:59 +00002797
Gregory P. Smithbb213892009-11-02 01:37:37 +00002798AC_CACHE_CHECK([for lchflags], [ac_cv_have_lchflags], [dnl
Alexandre Vassalotti30267d62009-07-17 06:10:06 +00002799AC_TRY_RUN([[
Martin v. Löwisa51d5c82007-12-04 08:37:59 +00002800#include <sys/stat.h>
2801#include <unistd.h>
2802int main(int argc, char*argv[])
2803{
2804 if(lchflags(argv[0], 0) != 0)
2805 return 1;
2806 return 0;
2807}
Alexandre Vassalotti30267d62009-07-17 06:10:06 +00002808]], ac_cv_have_lchflags=yes,
Alexandre Vassalotti00900892009-07-17 05:26:39 +00002809 ac_cv_have_lchflags=no,
Gregory P. Smithbb213892009-11-02 01:37:37 +00002810 ac_cv_have_lchflags=cross)
2811])
2812if test "$ac_cv_have_lchflags" = cross ; then
2813 AC_CHECK_FUNC([lchflags], [ac_cv_have_lchflags="yes"], [ac_cv_have_lchflags="no"])
2814fi
2815if test "$ac_cv_have_lchflags" = yes ; then
Matthias Klose5183ebd2010-04-24 16:38:36 +00002816 AC_DEFINE(HAVE_LCHFLAGS, 1, [Define to 1 if you have the `lchflags' function.])
Alexandre Vassalotti00900892009-07-17 05:26:39 +00002817fi
Martin v. Löwisa51d5c82007-12-04 08:37:59 +00002818
Neal Norwitz6e73aaa2006-06-12 03:33:09 +00002819dnl Check if system zlib has *Copy() functions
Ronald Oussorenf8752642006-07-06 10:13:35 +00002820dnl
2821dnl On MacOSX the linker will search for dylibs on the entire linker path
2822dnl before searching for static libraries. setup.py adds -Wl,-search_paths_first
2823dnl to revert to a more traditional unix behaviour and make it possible to
2824dnl override the system libz with a local static library of libz. Temporarily
2825dnl add that flag to our CFLAGS as well to ensure that we check the version
2826dnl of libz that will be used by setup.py.
2827dnl The -L/usr/local/lib is needed as wel to get the same compilation
2828dnl environment as setup.py (and leaving it out can cause configure to use the
2829dnl wrong version of the library)
2830case $ac_sys_system/$ac_sys_release in
2831Darwin/*)
2832 _CUR_CFLAGS="${CFLAGS}"
2833 _CUR_LDFLAGS="${LDFLAGS}"
2834 CFLAGS="${CFLAGS} -Wl,-search_paths_first"
2835 LDFLAGS="${LDFLAGS} -Wl,-search_paths_first -L/usr/local/lib"
2836 ;;
2837esac
2838
Matthias Klose5183ebd2010-04-24 16:38:36 +00002839AC_CHECK_LIB(z, inflateCopy, AC_DEFINE(HAVE_ZLIB_COPY, 1, [Define if the zlib library has inflateCopy]))
Neal Norwitz6e73aaa2006-06-12 03:33:09 +00002840
Ronald Oussorenf8752642006-07-06 10:13:35 +00002841case $ac_sys_system/$ac_sys_release in
2842Darwin/*)
2843 CFLAGS="${_CUR_CFLAGS}"
2844 LDFLAGS="${_CUR_LDFLAGS}"
2845 ;;
2846esac
2847
Martin v. Löwise9416172003-05-03 10:12:45 +00002848AC_MSG_CHECKING(for hstrerror)
Martin v. Löwis95c419b2003-05-03 12:10:48 +00002849AC_TRY_LINK([
Martin v. Löwise9416172003-05-03 10:12:45 +00002850#include "confdefs.h"
2851#include <netdb.h>
Matthias Klose5183ebd2010-04-24 16:38:36 +00002852], [void* p = hstrerror; hstrerror(0)],
2853 AC_DEFINE(HAVE_HSTRERROR, 1, [Define if you have the 'hstrerror' function.])
Martin v. Löwise9416172003-05-03 10:12:45 +00002854 AC_MSG_RESULT(yes),
2855 AC_MSG_RESULT(no)
2856)
2857
2858AC_MSG_CHECKING(for inet_aton)
Martin v. Löwis95c419b2003-05-03 12:10:48 +00002859AC_TRY_LINK([
Martin v. Löwise9416172003-05-03 10:12:45 +00002860#include "confdefs.h"
Martin v. Löwis86d66262006-02-17 08:40:11 +00002861#include <sys/types.h>
Martin v. Löwise9416172003-05-03 10:12:45 +00002862#include <sys/socket.h>
2863#include <netinet/in.h>
2864#include <arpa/inet.h>
Matthias Klose5183ebd2010-04-24 16:38:36 +00002865], [void* p = inet_aton;inet_aton(0,0)],
2866 AC_DEFINE(HAVE_INET_ATON, 1, [Define if you have the 'inet_aton' function.])
Martin v. Löwise9416172003-05-03 10:12:45 +00002867 AC_MSG_RESULT(yes),
2868 AC_MSG_RESULT(no)
2869)
2870
2871AC_MSG_CHECKING(for inet_pton)
2872AC_TRY_COMPILE([
2873#include "confdefs.h"
Martin v. Löwisf2e488d2003-05-05 22:00:11 +00002874#include <sys/types.h>
Martin v. Löwise9416172003-05-03 10:12:45 +00002875#include <sys/socket.h>
2876#include <netinet/in.h>
2877#include <arpa/inet.h>
Matthias Klose5183ebd2010-04-24 16:38:36 +00002878], [void* p = inet_pton],
2879 AC_DEFINE(HAVE_INET_PTON, 1, [Define if you have the 'inet_pton' function.])
Martin v. Löwise9416172003-05-03 10:12:45 +00002880 AC_MSG_RESULT(yes),
2881 AC_MSG_RESULT(no)
2882)
2883
Martin v. Löwisd6640d42003-07-06 09:29:52 +00002884# On some systems, setgroups is in unistd.h, on others, in grp.h
Martin v. Löwisd5843682002-11-21 20:41:28 +00002885AC_MSG_CHECKING(for setgroups)
2886AC_TRY_COMPILE([
2887#include "confdefs.h"
Martin v. Löwisf2e488d2003-05-05 22:00:11 +00002888#include <unistd.h>
Martin v. Löwisd6640d42003-07-06 09:29:52 +00002889#ifdef HAVE_GRP_H
2890#include <grp.h>
2891#endif
Martin v. Löwisd5843682002-11-21 20:41:28 +00002892],
Matthias Klose5183ebd2010-04-24 16:38:36 +00002893[void* p = setgroups],
2894 AC_DEFINE(HAVE_SETGROUPS, 1, [Define if you have the 'setgroups' function.])
Martin v. Löwisd5843682002-11-21 20:41:28 +00002895 AC_MSG_RESULT(yes),
2896 AC_MSG_RESULT(no)
2897)
2898
Fred Drake8cef4cf2000-06-28 16:40:38 +00002899# check for openpty and forkpty
2900
Martin v. Löwisfd9a72a2006-01-08 10:07:33 +00002901AC_CHECK_FUNCS(openpty,,
2902 AC_CHECK_LIB(util,openpty,
2903 [AC_DEFINE(HAVE_OPENPTY) LIBS="$LIBS -lutil"],
2904 AC_CHECK_LIB(bsd,openpty, [AC_DEFINE(HAVE_OPENPTY) LIBS="$LIBS -lbsd"])
2905 )
2906)
2907AC_CHECK_FUNCS(forkpty,,
2908 AC_CHECK_LIB(util,forkpty,
2909 [AC_DEFINE(HAVE_FORKPTY) LIBS="$LIBS -lutil"],
2910 AC_CHECK_LIB(bsd,forkpty, [AC_DEFINE(HAVE_FORKPTY) LIBS="$LIBS -lbsd"])
2911 )
2912)
Fred Drake8cef4cf2000-06-28 16:40:38 +00002913
Brett Cannonaa5778d2008-03-18 04:09:00 +00002914# Stuff for expat.
2915AC_CHECK_FUNCS(memmove)
2916
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00002917# check for long file support functions
2918AC_CHECK_FUNCS(fseek64 fseeko fstatvfs ftell64 ftello statvfs)
2919
Brett Cannonaa5778d2008-03-18 04:09:00 +00002920AC_REPLACE_FUNCS(dup2 getcwd strdup)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002921AC_CHECK_FUNCS(getpgrp,
2922 AC_TRY_COMPILE([#include <unistd.h>],
2923 [getpgrp(0);],
2924 AC_DEFINE(GETPGRP_HAVE_ARG, 1,
2925 [Define if getpgrp() must be called as getpgrp(0).])
2926 )
2927)
Jack Jansen150753c2003-03-29 22:07:47 +00002928AC_CHECK_FUNCS(setpgrp,
2929 AC_TRY_COMPILE([#include <unistd.h>],
2930 [setpgrp(0,0);],
2931 AC_DEFINE(SETPGRP_HAVE_ARG, 1,
2932 [Define if setpgrp() must be called as setpgrp(0, 0).])
2933 )
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002934)
2935AC_CHECK_FUNCS(gettimeofday,
2936 AC_TRY_COMPILE([#include <sys/time.h>],
2937 [gettimeofday((struct timeval*)0,(struct timezone*)0);], ,
2938 AC_DEFINE(GETTIMEOFDAY_NO_TZ, 1,
2939 [Define if gettimeofday() does not have second (timezone) argument
2940 This is the case on Motorola V4 (R40V4.2)])
2941 )
2942)
Guido van Rossum627b2d71993-12-24 10:39:16 +00002943
Martin v. Löwisdbe3f762002-10-10 14:27:30 +00002944AC_MSG_CHECKING(for major, minor, and makedev)
Martin v. Löwise3271202002-11-07 07:42:30 +00002945AC_TRY_LINK([
Neal Norwitz6eb37f02003-02-23 23:28:15 +00002946#if defined(MAJOR_IN_MKDEV)
2947#include <sys/mkdev.h>
2948#elif defined(MAJOR_IN_SYSMACROS)
2949#include <sys/sysmacros.h>
2950#else
2951#include <sys/types.h>
2952#endif
Martin v. Löwisdbe3f762002-10-10 14:27:30 +00002953],[
2954 makedev(major(0),minor(0));
2955],[
2956 AC_DEFINE(HAVE_DEVICE_MACROS, 1,
2957 [Define to 1 if you have the device macros.])
2958 AC_MSG_RESULT(yes)
2959],[
2960 AC_MSG_RESULT(no)
2961])
Martin v. Löwis861a65b2001-10-24 14:36:00 +00002962
2963# On OSF/1 V5.1, getaddrinfo is available, but a define
2964# for [no]getaddrinfo in netdb.h.
2965AC_MSG_CHECKING(for getaddrinfo)
2966AC_TRY_LINK([
Martin v. Löwisc010b6d2001-11-09 17:50:52 +00002967#include <sys/types.h>
Martin v. Löwis861a65b2001-10-24 14:36:00 +00002968#include <sys/socket.h>
2969#include <netdb.h>
Martin v. Löwisc010b6d2001-11-09 17:50:52 +00002970#include <stdio.h>
Alexandre Vassalotti00900892009-07-17 05:26:39 +00002971], [getaddrinfo(NULL, NULL, NULL, NULL);],
2972have_getaddrinfo=yes,
2973have_getaddrinfo=no)
2974AC_MSG_RESULT($have_getaddrinfo)
2975if test $have_getaddrinfo = yes
2976then
2977 AC_MSG_CHECKING(getaddrinfo bug)
2978 AC_CACHE_VAL(ac_cv_buggy_getaddrinfo,
2979 AC_TRY_RUN([[
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00002980#include <sys/types.h>
2981#include <netdb.h>
2982#include <string.h>
2983#include <sys/socket.h>
2984#include <netinet/in.h>
2985
Alexandre Vassalotti00900892009-07-17 05:26:39 +00002986int main()
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00002987{
2988 int passive, gaierr, inet4 = 0, inet6 = 0;
2989 struct addrinfo hints, *ai, *aitop;
2990 char straddr[INET6_ADDRSTRLEN], strport[16];
2991
2992 for (passive = 0; passive <= 1; passive++) {
2993 memset(&hints, 0, sizeof(hints));
2994 hints.ai_family = AF_UNSPEC;
2995 hints.ai_flags = passive ? AI_PASSIVE : 0;
2996 hints.ai_socktype = SOCK_STREAM;
Hye-Shik Chang54f94392004-04-14 07:55:31 +00002997 hints.ai_protocol = IPPROTO_TCP;
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00002998 if ((gaierr = getaddrinfo(NULL, "54321", &hints, &aitop)) != 0) {
2999 (void)gai_strerror(gaierr);
3000 goto bad;
3001 }
3002 for (ai = aitop; ai; ai = ai->ai_next) {
3003 if (ai->ai_addr == NULL ||
3004 ai->ai_addrlen == 0 ||
3005 getnameinfo(ai->ai_addr, ai->ai_addrlen,
3006 straddr, sizeof(straddr), strport, sizeof(strport),
3007 NI_NUMERICHOST|NI_NUMERICSERV) != 0) {
3008 goto bad;
3009 }
3010 switch (ai->ai_family) {
3011 case AF_INET:
3012 if (strcmp(strport, "54321") != 0) {
3013 goto bad;
3014 }
3015 if (passive) {
3016 if (strcmp(straddr, "0.0.0.0") != 0) {
3017 goto bad;
3018 }
3019 } else {
3020 if (strcmp(straddr, "127.0.0.1") != 0) {
3021 goto bad;
3022 }
3023 }
3024 inet4++;
3025 break;
3026 case AF_INET6:
3027 if (strcmp(strport, "54321") != 0) {
3028 goto bad;
3029 }
3030 if (passive) {
3031 if (strcmp(straddr, "::") != 0) {
3032 goto bad;
3033 }
3034 } else {
3035 if (strcmp(straddr, "::1") != 0) {
3036 goto bad;
3037 }
3038 }
3039 inet6++;
3040 break;
3041 case AF_UNSPEC:
3042 goto bad;
3043 break;
3044 default:
3045 /* another family support? */
3046 break;
3047 }
3048 }
3049 }
3050
3051 if (!(inet4 == 0 || inet4 == 2))
3052 goto bad;
3053 if (!(inet6 == 0 || inet6 == 2))
3054 goto bad;
3055
3056 if (aitop)
3057 freeaddrinfo(aitop);
Alexandre Vassalotti00900892009-07-17 05:26:39 +00003058 return 0;
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003059
3060 bad:
3061 if (aitop)
3062 freeaddrinfo(aitop);
Alexandre Vassalotti00900892009-07-17 05:26:39 +00003063 return 1;
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003064}
Alexandre Vassalotti00900892009-07-17 05:26:39 +00003065]], ac_cv_buggy_getaddrinfo=no,
3066 ac_cv_buggy_getaddrinfo=yes,
3067 ac_cv_buggy_getaddrinfo=yes))
3068fi
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003069
Mark Dickinson0ef0b912009-12-31 21:11:48 +00003070if test $have_getaddrinfo = no -o "$ac_cv_buggy_getaddrinfo" = yes
Alexandre Vassalotti00900892009-07-17 05:26:39 +00003071then
3072 if test $ipv6 = yes
3073 then
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003074 echo 'Fatal: You must get working getaddrinfo() function.'
3075 echo ' or you can specify "--disable-ipv6"'.
3076 exit 1
3077 fi
Martin v. Löwis861a65b2001-10-24 14:36:00 +00003078else
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003079 AC_DEFINE(HAVE_GETADDRINFO, 1, [Define if you have the getaddrinfo function.])
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003080fi
Thomas Woutersb0db85a2001-08-08 10:39:03 +00003081AC_CHECK_FUNCS(getnameinfo)
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003082
Guido van Rossum627b2d71993-12-24 10:39:16 +00003083# checks for structures
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003084AC_HEADER_TIME
Guido van Rossum627b2d71993-12-24 10:39:16 +00003085AC_STRUCT_TM
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003086AC_STRUCT_TIMEZONE
Martin v. Löwis60a5d722002-10-16 20:28:25 +00003087AC_CHECK_MEMBERS([struct stat.st_rdev])
3088AC_CHECK_MEMBERS([struct stat.st_blksize])
Hye-Shik Chang5f937a72005-06-02 13:09:30 +00003089AC_CHECK_MEMBERS([struct stat.st_flags])
Martin v. Löwisebd9d5b2005-08-09 15:00:59 +00003090AC_CHECK_MEMBERS([struct stat.st_gen])
3091AC_CHECK_MEMBERS([struct stat.st_birthtime])
Guido van Rossum98bf58f2001-10-18 20:34:25 +00003092AC_STRUCT_ST_BLOCKS
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003093
3094AC_MSG_CHECKING(for time.h that defines altzone)
3095AC_CACHE_VAL(ac_cv_header_time_altzone,
3096[AC_TRY_COMPILE([#include <time.h>], [return altzone;],
3097 ac_cv_header_time_altzone=yes,
3098 ac_cv_header_time_altzone=no)])
3099AC_MSG_RESULT($ac_cv_header_time_altzone)
3100if test $ac_cv_header_time_altzone = yes; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003101 AC_DEFINE(HAVE_ALTZONE, 1, [Define this if your time.h defines altzone.])
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003102fi
3103
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003104was_it_defined=no
3105AC_MSG_CHECKING(whether sys/select.h and sys/time.h may both be included)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003106AC_TRY_COMPILE([
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003107#include <sys/types.h>
3108#include <sys/select.h>
3109#include <sys/time.h>
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003110], [;], [
3111 AC_DEFINE(SYS_SELECT_WITH_SYS_TIME, 1,
3112 [Define if you can safely include both <sys/select.h> and <sys/time.h>
3113 (which you can't on SCO ODT 3.0).])
3114 was_it_defined=yes
3115])
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003116AC_MSG_RESULT($was_it_defined)
Guido van Rossum627b2d71993-12-24 10:39:16 +00003117
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003118AC_MSG_CHECKING(for addrinfo)
3119AC_CACHE_VAL(ac_cv_struct_addrinfo,
3120AC_TRY_COMPILE([
3121# include <netdb.h>],
3122 [struct addrinfo a],
3123 ac_cv_struct_addrinfo=yes,
3124 ac_cv_struct_addrinfo=no))
3125AC_MSG_RESULT($ac_cv_struct_addrinfo)
3126if test $ac_cv_struct_addrinfo = yes; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003127 AC_DEFINE(HAVE_ADDRINFO, 1, [struct addrinfo (netdb.h)])
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003128fi
3129
3130AC_MSG_CHECKING(for sockaddr_storage)
3131AC_CACHE_VAL(ac_cv_struct_sockaddr_storage,
3132AC_TRY_COMPILE([
3133# include <sys/types.h>
3134# include <sys/socket.h>],
3135 [struct sockaddr_storage s],
3136 ac_cv_struct_sockaddr_storage=yes,
3137 ac_cv_struct_sockaddr_storage=no))
3138AC_MSG_RESULT($ac_cv_struct_sockaddr_storage)
3139if test $ac_cv_struct_sockaddr_storage = yes; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003140 AC_DEFINE(HAVE_SOCKADDR_STORAGE, 1, [struct sockaddr_storage (sys/socket.h)])
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003141fi
3142
Guido van Rossum627b2d71993-12-24 10:39:16 +00003143# checks for compiler characteristics
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003144
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003145AC_C_CHAR_UNSIGNED
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003146AC_C_CONST
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003147
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003148works=no
3149AC_MSG_CHECKING(for working volatile)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003150AC_TRY_COMPILE([],[volatile int x; x = 0;], works=yes,
3151 AC_DEFINE(volatile, [], [Define to empty if the keyword does not work.])
3152)
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003153AC_MSG_RESULT($works)
Guido van Rossumdabb11b1994-10-11 15:04:27 +00003154
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003155works=no
3156AC_MSG_CHECKING(for working signed char)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003157AC_TRY_COMPILE([], [signed char c;], works=yes,
3158 AC_DEFINE(signed, [], [Define to empty if the keyword does not work.])
3159)
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003160AC_MSG_RESULT($works)
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003161
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003162have_prototypes=no
3163AC_MSG_CHECKING(for prototypes)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003164AC_TRY_COMPILE([int foo(int x) { return 0; }], [return foo(10);],[
3165 AC_DEFINE(HAVE_PROTOTYPES, 1,
3166 [Define if your compiler supports function prototype])
3167 have_prototypes=yes
3168])
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003169AC_MSG_RESULT($have_prototypes)
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003170
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003171works=no
3172AC_MSG_CHECKING(for variable length prototypes and stdarg.h)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003173AC_TRY_COMPILE([
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003174#include <stdarg.h>
Guido van Rossum3f13e481996-08-30 20:58:11 +00003175int foo(int x, ...) {
3176 va_list va;
3177 va_start(va, x);
3178 va_arg(va, int);
3179 va_arg(va, char *);
3180 va_arg(va, double);
3181 return 0;
3182}
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003183], [return foo(10, "", 3.14);], [
3184 AC_DEFINE(HAVE_STDARG_PROTOTYPES, 1,
3185 [Define if your compiler supports variable length function prototypes
3186 (e.g. void fprintf(FILE *, char *, ...);) *and* <stdarg.h>])
3187 works=yes
3188])
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003189AC_MSG_RESULT($works)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003190
Dave Cole331708b2004-08-09 04:51:41 +00003191# check for socketpair
3192AC_MSG_CHECKING(for socketpair)
3193AC_TRY_COMPILE([
3194#include <sys/types.h>
3195#include <sys/socket.h>
Matthias Klose5183ebd2010-04-24 16:38:36 +00003196], [void *x=socketpair],
3197 AC_DEFINE(HAVE_SOCKETPAIR, 1, [Define if you have the 'socketpair' function.])
Dave Cole331708b2004-08-09 04:51:41 +00003198 AC_MSG_RESULT(yes),
3199 AC_MSG_RESULT(no)
3200)
3201
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003202# check if sockaddr has sa_len member
3203AC_MSG_CHECKING(if sockaddr has sa_len member)
3204AC_TRY_COMPILE([#include <sys/types.h>
3205#include <sys/socket.h>],
3206[struct sockaddr x;
3207x.sa_len = 0;],
3208 AC_MSG_RESULT(yes)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003209 AC_DEFINE(HAVE_SOCKADDR_SA_LEN, 1, [Define if sockaddr has sa_len member]),
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003210 AC_MSG_RESULT(no))
3211
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003212va_list_is_array=no
3213AC_MSG_CHECKING(whether va_list is an array)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003214AC_TRY_COMPILE([
3215#ifdef HAVE_STDARG_PROTOTYPES
3216#include <stdarg.h>
3217#else
3218#include <varargs.h>
3219#endif
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003220], [va_list list1, list2; list1 = list2;], , [
3221 AC_DEFINE(VA_LIST_IS_ARRAY, 1, [Define if a va_list is an array of some kind])
3222 va_list_is_array=yes
3223])
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003224AC_MSG_RESULT($va_list_is_array)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003225
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003226# sigh -- gethostbyname_r is a mess; it can have 3, 5 or 6 arguments :-(
Martin v. Löwis11437992002-04-12 09:54:03 +00003227AH_TEMPLATE(HAVE_GETHOSTBYNAME_R,
3228 [Define this if you have some version of gethostbyname_r()])
3229
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003230AC_CHECK_FUNC(gethostbyname_r, [
3231 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
3232 AC_MSG_CHECKING([gethostbyname_r with 6 args])
3233 OLD_CFLAGS=$CFLAGS
3234 CFLAGS="$CFLAGS $MY_CPPFLAGS $MY_THREAD_CPPFLAGS $MY_CFLAGS"
3235 AC_TRY_COMPILE([
3236# include <netdb.h>
3237 ], [
3238 char *name;
3239 struct hostent *he, *res;
3240 char buffer[2048];
3241 int buflen = 2048;
3242 int h_errnop;
3243
3244 (void) gethostbyname_r(name, he, buffer, buflen, &res, &h_errnop)
3245 ], [
Guido van Rossum8db7d8b1999-03-23 16:40:33 +00003246 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003247 AC_DEFINE(HAVE_GETHOSTBYNAME_R_6_ARG, 1,
3248 [Define this if you have the 6-arg version of gethostbyname_r().])
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003249 AC_MSG_RESULT(yes)
3250 ], [
3251 AC_MSG_RESULT(no)
3252 AC_MSG_CHECKING([gethostbyname_r with 5 args])
3253 AC_TRY_COMPILE([
3254# include <netdb.h>
3255 ], [
3256 char *name;
3257 struct hostent *he;
3258 char buffer[2048];
3259 int buflen = 2048;
3260 int h_errnop;
3261
3262 (void) gethostbyname_r(name, he, buffer, buflen, &h_errnop)
3263 ], [
Guido van Rossum8db7d8b1999-03-23 16:40:33 +00003264 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003265 AC_DEFINE(HAVE_GETHOSTBYNAME_R_5_ARG, 1,
3266 [Define this if you have the 5-arg version of gethostbyname_r().])
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003267 AC_MSG_RESULT(yes)
3268 ], [
3269 AC_MSG_RESULT(no)
3270 AC_MSG_CHECKING([gethostbyname_r with 3 args])
3271 AC_TRY_COMPILE([
3272# include <netdb.h>
3273 ], [
3274 char *name;
3275 struct hostent *he;
3276 struct hostent_data data;
3277
3278 (void) gethostbyname_r(name, he, &data);
3279 ], [
Guido van Rossum8db7d8b1999-03-23 16:40:33 +00003280 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003281 AC_DEFINE(HAVE_GETHOSTBYNAME_R_3_ARG, 1,
3282 [Define this if you have the 3-arg version of gethostbyname_r().])
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003283 AC_MSG_RESULT(yes)
3284 ], [
3285 AC_MSG_RESULT(no)
3286 ])
3287 ])
3288 ])
3289 CFLAGS=$OLD_CFLAGS
3290], [
Thomas Wouters3a584202000-08-05 23:28:51 +00003291 AC_CHECK_FUNCS(gethostbyname)
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003292])
3293AC_SUBST(HAVE_GETHOSTBYNAME_R_6_ARG)
3294AC_SUBST(HAVE_GETHOSTBYNAME_R_5_ARG)
3295AC_SUBST(HAVE_GETHOSTBYNAME_R_3_ARG)
Guido van Rossum8db7d8b1999-03-23 16:40:33 +00003296AC_SUBST(HAVE_GETHOSTBYNAME_R)
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003297AC_SUBST(HAVE_GETHOSTBYNAME)
3298
Guido van Rossum627b2d71993-12-24 10:39:16 +00003299# checks for system services
3300# (none yet)
3301
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003302# Linux requires this for correct f.p. operations
Jeremy Hyltonbe28f5b2000-07-27 21:03:04 +00003303AC_CHECK_FUNC(__fpu_control,
3304 [],
3305 [AC_CHECK_LIB(ieee, __fpu_control)
3306])
Guido van Rossum627b2d71993-12-24 10:39:16 +00003307
Guido van Rossum93274221997-05-09 02:42:00 +00003308# Check for --with-fpectl
Guido van Rossum93274221997-05-09 02:42:00 +00003309AC_MSG_CHECKING(for --with-fpectl)
Barry Warsawc0d24d82000-06-29 16:12:00 +00003310AC_ARG_WITH(fpectl,
Matthias Klose5183ebd2010-04-24 16:38:36 +00003311 AC_HELP_STRING([--with-fpectl], [enable SIGFPE catching]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003312[
Guido van Rossum93274221997-05-09 02:42:00 +00003313if test "$withval" != no
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003314then
3315 AC_DEFINE(WANT_SIGFPE_HANDLER, 1,
3316 [Define if you want SIGFPE handled (see Include/pyfpe.h).])
3317 AC_MSG_RESULT(yes)
Guido van Rossum93274221997-05-09 02:42:00 +00003318else AC_MSG_RESULT(no)
Guido van Rossumef2255b2000-03-10 22:30:29 +00003319fi],
3320[AC_MSG_RESULT(no)])
Guido van Rossum93274221997-05-09 02:42:00 +00003321
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003322# check for --with-libm=...
3323AC_SUBST(LIBM)
Guido van Rossum4b6b5791996-09-09 20:09:34 +00003324case $ac_sys_system in
Guido van Rossum3dc0a512000-10-05 18:00:06 +00003325Darwin) ;;
Guido van Rossumec95c7b1998-08-04 17:59:56 +00003326BeOS) ;;
Guido van Rossum4b6b5791996-09-09 20:09:34 +00003327*) LIBM=-lm
3328esac
Guido van Rossum93274221997-05-09 02:42:00 +00003329AC_MSG_CHECKING(for --with-libm=STRING)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003330AC_ARG_WITH(libm,
Matthias Klose5183ebd2010-04-24 16:38:36 +00003331 AC_HELP_STRING([--with-libm=STRING], [math library]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003332[
Guido van Rossum93274221997-05-09 02:42:00 +00003333if test "$withval" = no
3334then LIBM=
3335 AC_MSG_RESULT(force LIBM empty)
3336elif test "$withval" != yes
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003337then LIBM=$withval
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003338 AC_MSG_RESULT(set LIBM="$withval")
3339else AC_MSG_ERROR([proper usage is --with-libm=STRING])
Guido van Rossum93274221997-05-09 02:42:00 +00003340fi],
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003341[AC_MSG_RESULT(default LIBM="$LIBM")])
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003342
3343# check for --with-libc=...
3344AC_SUBST(LIBC)
Guido van Rossum93274221997-05-09 02:42:00 +00003345AC_MSG_CHECKING(for --with-libc=STRING)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003346AC_ARG_WITH(libc,
Matthias Klose5183ebd2010-04-24 16:38:36 +00003347 AC_HELP_STRING([--with-libc=STRING], [C library]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003348[
Guido van Rossum93274221997-05-09 02:42:00 +00003349if test "$withval" = no
3350then LIBC=
3351 AC_MSG_RESULT(force LIBC empty)
3352elif test "$withval" != yes
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003353then LIBC=$withval
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003354 AC_MSG_RESULT(set LIBC="$withval")
3355else AC_MSG_ERROR([proper usage is --with-libc=STRING])
Guido van Rossum93274221997-05-09 02:42:00 +00003356fi],
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003357[AC_MSG_RESULT(default LIBC="$LIBC")])
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003358
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003359# **************************************************
3360# * Check for various properties of floating point *
3361# **************************************************
Mark Dickinson265d7382008-04-21 22:32:24 +00003362
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003363AC_MSG_CHECKING(whether C doubles are little-endian IEEE 754 binary64)
3364AC_CACHE_VAL(ac_cv_little_endian_double, [
3365AC_TRY_RUN([
3366#include <string.h>
3367int main() {
3368 double x = 9006104071832581.0;
3369 if (memcmp(&x, "\x05\x04\x03\x02\x01\xff\x3f\x43", 8) == 0)
3370 return 0;
3371 else
3372 return 1;
3373}
3374],
3375ac_cv_little_endian_double=yes,
3376ac_cv_little_endian_double=no,
3377ac_cv_little_endian_double=no)])
3378AC_MSG_RESULT($ac_cv_little_endian_double)
3379if test "$ac_cv_little_endian_double" = yes
3380then
3381 AC_DEFINE(DOUBLE_IS_LITTLE_ENDIAN_IEEE754, 1,
3382 [Define if C doubles are 64-bit IEEE 754 binary format, stored
3383 with the least significant byte first])
3384fi
3385
3386AC_MSG_CHECKING(whether C doubles are big-endian IEEE 754 binary64)
3387AC_CACHE_VAL(ac_cv_big_endian_double, [
3388AC_TRY_RUN([
3389#include <string.h>
3390int main() {
3391 double x = 9006104071832581.0;
3392 if (memcmp(&x, "\x43\x3f\xff\x01\x02\x03\x04\x05", 8) == 0)
3393 return 0;
3394 else
3395 return 1;
3396}
3397],
3398ac_cv_big_endian_double=yes,
3399ac_cv_big_endian_double=no,
3400ac_cv_big_endian_double=no)])
3401AC_MSG_RESULT($ac_cv_big_endian_double)
3402if test "$ac_cv_big_endian_double" = yes
3403then
3404 AC_DEFINE(DOUBLE_IS_BIG_ENDIAN_IEEE754, 1,
3405 [Define if C doubles are 64-bit IEEE 754 binary format, stored
3406 with the most significant byte first])
3407fi
3408
3409# Some ARM platforms use a mixed-endian representation for doubles.
3410# While Python doesn't currently have full support for these platforms
3411# (see e.g., issue 1762561), we can at least make sure that float <-> string
3412# conversions work.
3413AC_MSG_CHECKING(whether C doubles are ARM mixed-endian IEEE 754 binary64)
3414AC_CACHE_VAL(ac_cv_mixed_endian_double, [
3415AC_TRY_RUN([
3416#include <string.h>
3417int main() {
3418 double x = 9006104071832581.0;
3419 if (memcmp(&x, "\x01\xff\x3f\x43\x05\x04\x03\x02", 8) == 0)
3420 return 0;
3421 else
3422 return 1;
3423}
3424],
3425ac_cv_mixed_endian_double=yes,
3426ac_cv_mixed_endian_double=no,
3427ac_cv_mixed_endian_double=no)])
3428AC_MSG_RESULT($ac_cv_mixed_endian_double)
3429if test "$ac_cv_mixed_endian_double" = yes
3430then
3431 AC_DEFINE(DOUBLE_IS_ARM_MIXED_ENDIAN_IEEE754, 1,
3432 [Define if C doubles are 64-bit IEEE 754 binary format, stored
3433 in ARM mixed-endian order (byte order 45670123)])
3434fi
3435
3436# The short float repr introduced in Python 3.1 requires the
3437# correctly-rounded string <-> double conversion functions from
3438# Python/dtoa.c, which in turn require that the FPU uses 53-bit
3439# rounding; this is a problem on x86, where the x87 FPU has a default
Mark Dickinsona548dee2009-11-15 13:12:43 +00003440# rounding precision of 64 bits. For gcc/x86, we can fix this by
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003441# using inline assembler to get and set the x87 FPU control word.
Mark Dickinsona548dee2009-11-15 13:12:43 +00003442
3443# This inline assembler syntax may also work for suncc and icc,
3444# so we try it on all platforms.
3445
3446AC_MSG_CHECKING(whether we can use gcc inline assembler to get and set x87 control word)
3447AC_TRY_COMPILE([], [
3448 unsigned short cw;
3449 __asm__ __volatile__ ("fnstcw %0" : "=m" (cw));
3450 __asm__ __volatile__ ("fldcw %0" : : "m" (cw));
3451],
3452[have_gcc_asm_for_x87=yes], [have_gcc_asm_for_x87=no])
3453AC_MSG_RESULT($have_gcc_asm_for_x87)
3454if test "$have_gcc_asm_for_x87" = yes
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003455then
Mark Dickinsona548dee2009-11-15 13:12:43 +00003456 AC_DEFINE(HAVE_GCC_ASM_FOR_X87, 1,
3457 [Define if we can use gcc inline assembler to get and set x87 control word])
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003458fi
Mark Dickinson7a3d8642008-04-22 00:54:27 +00003459
Mark Dickinson04b27232009-01-04 12:29:36 +00003460# Detect whether system arithmetic is subject to x87-style double
3461# rounding issues. The result of this test has little meaning on non
3462# IEEE 754 platforms. On IEEE 754, test should return 1 if rounding
3463# mode is round-to-nearest and double rounding issues are present, and
3464# 0 otherwise. See http://bugs.python.org/issue2937 for more info.
3465AC_MSG_CHECKING(for x87-style double rounding)
Mark Dickinson99abd142009-10-24 13:44:16 +00003466# $BASECFLAGS may affect the result
3467ac_save_cc="$CC"
3468CC="$CC $BASECFLAGS"
Mark Dickinson04b27232009-01-04 12:29:36 +00003469AC_TRY_RUN([
3470#include <stdlib.h>
3471#include <math.h>
3472int main() {
3473 volatile double x, y, z;
3474 /* 1./(1-2**-53) -> 1+2**-52 (correct), 1.0 (double rounding) */
3475 x = 0.99999999999999989; /* 1-2**-53 */
3476 y = 1./x;
3477 if (y != 1.)
3478 exit(0);
3479 /* 1e16+2.99999 -> 1e16+2. (correct), 1e16+4. (double rounding) */
3480 x = 1e16;
3481 y = 2.99999;
3482 z = x + y;
3483 if (z != 1e16+4.)
3484 exit(0);
3485 /* both tests show evidence of double rounding */
3486 exit(1);
3487}
3488],
3489ac_cv_x87_double_rounding=no,
3490ac_cv_x87_double_rounding=yes,
Mark Dickinson99abd142009-10-24 13:44:16 +00003491ac_cv_x87_double_rounding=no)
3492CC="$ac_save_cc"
Mark Dickinson04b27232009-01-04 12:29:36 +00003493AC_MSG_RESULT($ac_cv_x87_double_rounding)
3494if test "$ac_cv_x87_double_rounding" = yes
3495then
3496 AC_DEFINE(X87_DOUBLE_ROUNDING, 1,
3497 [Define if arithmetic is subject to x87-style double rounding issue])
3498fi
3499
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003500# ************************************
3501# * Check for mathematical functions *
3502# ************************************
3503
3504LIBS_SAVE=$LIBS
3505LIBS="$LIBS $LIBM"
3506
Mark Dickinsonc63392c2009-11-28 13:13:13 +00003507# On FreeBSD 6.2, it appears that tanh(-0.) returns 0. instead of
3508# -0. on some architectures.
3509AC_MSG_CHECKING(whether tanh preserves the sign of zero)
3510AC_CACHE_VAL(ac_cv_tanh_preserves_zero_sign, [
3511AC_TRY_RUN([
3512#include <math.h>
3513#include <stdlib.h>
3514int main() {
3515 /* return 0 if either negative zeros don't exist
3516 on this platform or if negative zeros exist
3517 and tanh(-0.) == -0. */
3518 if (atan2(0., -1.) == atan2(-0., -1.) ||
3519 atan2(tanh(-0.), -1.) == atan2(-0., -1.)) exit(0);
3520 else exit(1);
3521}
3522],
3523ac_cv_tanh_preserves_zero_sign=yes,
3524ac_cv_tanh_preserves_zero_sign=no,
3525ac_cv_tanh_preserves_zero_sign=no)])
3526AC_MSG_RESULT($ac_cv_tanh_preserves_zero_sign)
3527if test "$ac_cv_tanh_preserves_zero_sign" = yes
3528then
3529 AC_DEFINE(TANH_PRESERVES_ZERO_SIGN, 1,
3530 [Define if tanh(-0.) is -0., or if platform doesn't have signed zeros])
3531fi
3532
3533AC_CHECK_FUNCS([acosh asinh atanh copysign erf erfc expm1 finite gamma])
3534AC_CHECK_FUNCS([hypot lgamma log1p round tgamma])
3535AC_CHECK_DECLS([isinf, isnan, isfinite], [], [], [[#include <math.h>]])
3536
3537LIBS=$LIBS_SAVE
3538
Mark Dickinsonc4920e82009-11-20 19:30:22 +00003539# For multiprocessing module, check that sem_open
3540# actually works. For FreeBSD versions <= 7.2,
3541# the kernel module that provides POSIX semaphores
3542# isn't loaded by default, so an attempt to call
3543# sem_open results in a 'Signal 12' error.
3544AC_MSG_CHECKING(whether POSIX semaphores are enabled)
3545AC_CACHE_VAL(ac_cv_posix_semaphores_enabled,
3546AC_TRY_RUN([
3547#include <unistd.h>
3548#include <fcntl.h>
3549#include <stdio.h>
3550#include <semaphore.h>
3551#include <sys/stat.h>
3552
3553int main(void) {
3554 sem_t *a = sem_open("/autoconf", O_CREAT, S_IRUSR|S_IWUSR, 0);
3555 if (a == SEM_FAILED) {
3556 perror("sem_open");
3557 return 1;
3558 }
3559 sem_close(a);
Mark Dickinson59dc89e2009-12-13 21:06:06 +00003560 sem_unlink("/autoconf");
Mark Dickinsonc4920e82009-11-20 19:30:22 +00003561 return 0;
3562}
3563], ac_cv_posix_semaphores_enabled=yes,
3564 ac_cv_posix_semaphores_enabled=no,
3565 ac_cv_posix_semaphores_enabled=yes)
3566)
3567AC_MSG_RESULT($ac_cv_posix_semaphores_enabled)
3568if test $ac_cv_posix_semaphores_enabled = no
3569then
Mark Dickinson5afa6d42009-11-28 10:44:20 +00003570 AC_DEFINE(POSIX_SEMAPHORES_NOT_ENABLED, 1,
3571 [Define if POSIX semaphores aren't enabled on your system])
Mark Dickinsonc4920e82009-11-20 19:30:22 +00003572fi
3573
Jesse Noller355b1262009-04-02 00:03:28 +00003574# Multiprocessing check for broken sem_getvalue
3575AC_MSG_CHECKING(for broken sem_getvalue)
Alexandre Vassalotti00900892009-07-17 05:26:39 +00003576AC_CACHE_VAL(ac_cv_broken_sem_getvalue,
Jesse Noller355b1262009-04-02 00:03:28 +00003577AC_TRY_RUN([
3578#include <unistd.h>
3579#include <fcntl.h>
3580#include <stdio.h>
3581#include <semaphore.h>
3582#include <sys/stat.h>
3583
3584int main(void){
Mark Dickinson59dc89e2009-12-13 21:06:06 +00003585 sem_t *a = sem_open("/autocftw", O_CREAT, S_IRUSR|S_IWUSR, 0);
Jesse Noller355b1262009-04-02 00:03:28 +00003586 int count;
3587 int res;
3588 if(a==SEM_FAILED){
3589 perror("sem_open");
3590 return 1;
3591
3592 }
3593 res = sem_getvalue(a, &count);
3594 sem_close(a);
Mark Dickinson59dc89e2009-12-13 21:06:06 +00003595 sem_unlink("/autocftw");
Jesse Noller355b1262009-04-02 00:03:28 +00003596 return res==-1 ? 1 : 0;
3597}
Alexandre Vassalotti00900892009-07-17 05:26:39 +00003598], ac_cv_broken_sem_getvalue=no,
3599 ac_cv_broken_sem_getvalue=yes,
3600 ac_cv_broken_sem_getvalue=yes)
Jesse Noller355b1262009-04-02 00:03:28 +00003601)
Alexandre Vassalotti00900892009-07-17 05:26:39 +00003602AC_MSG_RESULT($ac_cv_broken_sem_getvalue)
3603if test $ac_cv_broken_sem_getvalue = yes
3604then
3605 AC_DEFINE(HAVE_BROKEN_SEM_GETVALUE, 1,
3606 [define to 1 if your sem_getvalue is broken.])
3607fi
Mark Dickinson04b27232009-01-04 12:29:36 +00003608
Mark Dickinsonefc82f72009-03-20 15:51:55 +00003609# determine what size digit to use for Python's longs
3610AC_MSG_CHECKING([digit size for Python's longs])
3611AC_ARG_ENABLE(big-digits,
3612AC_HELP_STRING([--enable-big-digits@<:@=BITS@:>@],[use big digits for Python longs [[BITS=30]]]),
3613[case $enable_big_digits in
3614yes)
3615 enable_big_digits=30 ;;
3616no)
3617 enable_big_digits=15 ;;
3618[15|30])
3619 ;;
3620*)
3621 AC_MSG_ERROR([bad value $enable_big_digits for --enable-big-digits; value should be 15 or 30]) ;;
3622esac
3623AC_MSG_RESULT($enable_big_digits)
3624AC_DEFINE_UNQUOTED(PYLONG_BITS_IN_DIGIT, $enable_big_digits, [Define as the preferred size in bits of long digits])
3625],
3626[AC_MSG_RESULT(no value specified)])
3627
Guido van Rossumef2255b2000-03-10 22:30:29 +00003628# check for wchar.h
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003629AC_CHECK_HEADER(wchar.h, [
3630 AC_DEFINE(HAVE_WCHAR_H, 1,
3631 [Define if the compiler provides a wchar.h header file.])
3632 wchar_h="yes"
3633],
Guido van Rossumef2255b2000-03-10 22:30:29 +00003634wchar_h="no"
3635)
3636
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003637# determine wchar_t size
3638if test "$wchar_h" = yes
3639then
Guido van Rossum67b26592001-10-20 14:21:45 +00003640 AC_CHECK_SIZEOF(wchar_t, 4, [#include <wchar.h>])
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003641fi
3642
Martin v. Löwisfa3bdea2003-09-04 18:50:54 +00003643AC_MSG_CHECKING(for UCS-4 tcl)
3644have_ucs4_tcl=no
3645AC_TRY_COMPILE([
3646#include <tcl.h>
3647#if TCL_UTF_MAX != 6
3648# error "NOT UCS4_TCL"
3649#endif], [], [
3650 AC_DEFINE(HAVE_UCS4_TCL, 1, [Define this if you have tcl and TCL_UTF_MAX==6])
3651 have_ucs4_tcl=yes
3652])
3653AC_MSG_RESULT($have_ucs4_tcl)
3654
Marc-André Lemburgd7160f82003-09-22 11:14:40 +00003655# check whether wchar_t is signed or not
3656if test "$wchar_h" = yes
3657then
3658 # check whether wchar_t is signed or not
3659 AC_MSG_CHECKING(whether wchar_t is signed)
3660 AC_CACHE_VAL(ac_cv_wchar_t_signed, [
3661 AC_TRY_RUN([
3662 #include <wchar.h>
3663 int main()
3664 {
Martin v. Löwis44fe0e42006-04-11 07:15:30 +00003665 /* Success: exit code 0 */
3666 exit((((wchar_t) -1) < ((wchar_t) 0)) ? 0 : 1);
Marc-André Lemburgd7160f82003-09-22 11:14:40 +00003667 }
3668 ],
3669 ac_cv_wchar_t_signed=yes,
3670 ac_cv_wchar_t_signed=no,
3671 ac_cv_wchar_t_signed=yes)])
3672 AC_MSG_RESULT($ac_cv_wchar_t_signed)
3673fi
3674
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003675AC_MSG_CHECKING(what type to use for unicode)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003676dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003677AC_ARG_ENABLE(unicode,
Matthias Klose5183ebd2010-04-24 16:38:36 +00003678 AC_HELP_STRING([--enable-unicode@<:@=ucs@<:@24@:>@@:>@], [Enable Unicode strings (default is yes)]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003679 [],
3680 [enable_unicode=yes])
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003681
3682if test $enable_unicode = yes
3683then
Martin v. Löwisfd917792001-06-27 20:22:04 +00003684 # Without any arguments, Py_UNICODE defaults to two-byte mode
Martin v. Löwisfa3bdea2003-09-04 18:50:54 +00003685 case "$have_ucs4_tcl" in
3686 yes) enable_unicode="ucs4"
3687 ;;
3688 *) enable_unicode="ucs2"
3689 ;;
3690 esac
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003691fi
3692
Martin v. Löwis0036cba2002-04-12 09:58:45 +00003693AH_TEMPLATE(Py_UNICODE_SIZE,
3694 [Define as the size of the unicode type.])
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003695case "$enable_unicode" in
3696ucs2) unicode_size="2"
3697 AC_DEFINE(Py_UNICODE_SIZE,2)
3698 ;;
3699ucs4) unicode_size="4"
3700 AC_DEFINE(Py_UNICODE_SIZE,4)
3701 ;;
Ezio Melotti5820efb2010-02-27 00:05:42 +00003702*) AC_MSG_ERROR([invalid value for --enable-unicode. Use either ucs2 or ucs4 (lowercase).]) ;;
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003703esac
3704
Martin v. Löwis11437992002-04-12 09:54:03 +00003705AH_TEMPLATE(PY_UNICODE_TYPE,
3706 [Define as the integral type used for Unicode representation.])
Martin v. Löwis0036cba2002-04-12 09:58:45 +00003707
Martin v. Löwis339d0f72001-08-17 18:39:25 +00003708AC_SUBST(UNICODE_OBJS)
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003709if test "$enable_unicode" = "no"
3710then
Martin v. Löwis339d0f72001-08-17 18:39:25 +00003711 UNICODE_OBJS=""
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003712 AC_MSG_RESULT(not used)
3713else
Martin v. Löwis339d0f72001-08-17 18:39:25 +00003714 UNICODE_OBJS="Objects/unicodeobject.o Objects/unicodectype.o"
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003715 AC_DEFINE(Py_USING_UNICODE, 1,
3716 [Define if you want to have a Unicode type.])
Marc-André Lemburgd7160f82003-09-22 11:14:40 +00003717
3718 # wchar_t is only usable if it maps to an unsigned type
3719 if test "$unicode_size" = "$ac_cv_sizeof_wchar_t" \
Matthias Klose7dbeed72004-12-24 08:22:17 +00003720 -a "$ac_cv_wchar_t_signed" = "no"
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003721 then
3722 PY_UNICODE_TYPE="wchar_t"
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003723 AC_DEFINE(HAVE_USABLE_WCHAR_T, 1,
3724 [Define if you have a useable wchar_t type defined in wchar.h; useable
Marc-André Lemburgd7160f82003-09-22 11:14:40 +00003725 means wchar_t must be an unsigned type with at least 16 bits. (see
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003726 Include/unicodeobject.h).])
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003727 AC_DEFINE(PY_UNICODE_TYPE,wchar_t)
3728 elif test "$ac_cv_sizeof_short" = "$unicode_size"
3729 then
3730 PY_UNICODE_TYPE="unsigned short"
3731 AC_DEFINE(PY_UNICODE_TYPE,unsigned short)
3732 elif test "$ac_cv_sizeof_long" = "$unicode_size"
3733 then
3734 PY_UNICODE_TYPE="unsigned long"
3735 AC_DEFINE(PY_UNICODE_TYPE,unsigned long)
3736 else
3737 PY_UNICODE_TYPE="no type found"
3738 fi
3739 AC_MSG_RESULT($PY_UNICODE_TYPE)
3740fi
Guido van Rossumef2255b2000-03-10 22:30:29 +00003741
3742# check for endianness
3743AC_C_BIGENDIAN
3744
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00003745# Check whether right shifting a negative integer extends the sign bit
3746# or fills with zeros (like the Cray J90, according to Tim Peters).
3747AC_MSG_CHECKING(whether right shift extends the sign bit)
Vladimir Marangozova6180282000-07-12 05:05:06 +00003748AC_CACHE_VAL(ac_cv_rshift_extends_sign, [
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00003749AC_TRY_RUN([
3750int main()
3751{
Vladimir Marangozova6180282000-07-12 05:05:06 +00003752 exit(((-1)>>3 == -1) ? 0 : 1);
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00003753}
Guido van Rossum3065c942001-09-17 04:03:14 +00003754],
3755ac_cv_rshift_extends_sign=yes,
3756ac_cv_rshift_extends_sign=no,
3757ac_cv_rshift_extends_sign=yes)])
Vladimir Marangozova6180282000-07-12 05:05:06 +00003758AC_MSG_RESULT($ac_cv_rshift_extends_sign)
3759if test "$ac_cv_rshift_extends_sign" = no
3760then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003761 AC_DEFINE(SIGNED_RIGHT_SHIFT_ZERO_FILLS, 1,
3762 [Define if i>>j for signed int i does not extend the sign bit
3763 when i < 0])
Vladimir Marangozova6180282000-07-12 05:05:06 +00003764fi
3765
Guido van Rossumcadfaec2001-01-05 14:45:49 +00003766# check for getc_unlocked and related locking functions
3767AC_MSG_CHECKING(for getc_unlocked() and friends)
3768AC_CACHE_VAL(ac_cv_have_getc_unlocked, [
3769AC_TRY_LINK([#include <stdio.h>],[
3770 FILE *f = fopen("/dev/null", "r");
3771 flockfile(f);
3772 getc_unlocked(f);
3773 funlockfile(f);
3774], ac_cv_have_getc_unlocked=yes, ac_cv_have_getc_unlocked=no)])
3775AC_MSG_RESULT($ac_cv_have_getc_unlocked)
3776if test "$ac_cv_have_getc_unlocked" = yes
3777then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003778 AC_DEFINE(HAVE_GETC_UNLOCKED, 1,
3779 [Define this if you have flockfile(), getc_unlocked(), and funlockfile()])
Guido van Rossumcadfaec2001-01-05 14:45:49 +00003780fi
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00003781
Neal Norwitzfe8e3d92006-01-07 21:07:20 +00003782# check where readline lives
Martin v. Löwis82bca632006-02-10 20:49:30 +00003783# save the value of LIBS so we don't actually link Python with readline
3784LIBS_no_readline=$LIBS
Gregory P. Smith980b99b2008-09-07 05:15:18 +00003785
3786# On some systems we need to link readline to a termcap compatible
3787# library. NOTE: Keep the precedence of listed libraries synchronised
3788# with setup.py.
3789py_cv_lib_readline=no
3790AC_MSG_CHECKING([how to link readline libs])
3791for py_libtermcap in "" ncursesw ncurses curses termcap; do
3792 if test -z "$py_libtermcap"; then
3793 READLINE_LIBS="-lreadline"
3794 else
3795 READLINE_LIBS="-lreadline -l$py_libtermcap"
3796 fi
3797 LIBS="$READLINE_LIBS $LIBS_no_readline"
3798 AC_LINK_IFELSE(
3799 [AC_LANG_CALL([],[readline])],
3800 [py_cv_lib_readline=yes])
3801 if test $py_cv_lib_readline = yes; then
3802 break
3803 fi
3804done
3805# Uncomment this line if you want to use READINE_LIBS in Makefile or scripts
3806#AC_SUBST([READLINE_LIBS])
Gregory P. Smith29ec7502008-09-07 19:18:16 +00003807if test $py_cv_lib_readline = no; then
Gregory P. Smith980b99b2008-09-07 05:15:18 +00003808 AC_MSG_RESULT([none])
3809else
3810 AC_MSG_RESULT([$READLINE_LIBS])
3811 AC_DEFINE(HAVE_LIBREADLINE, 1,
3812 [Define if you have the readline library (-lreadline).])
Neal Norwitzfe8e3d92006-01-07 21:07:20 +00003813fi
3814
Michael W. Hudson30ea2f22004-07-07 17:44:12 +00003815# check for readline 2.1
3816AC_CHECK_LIB(readline, rl_callback_handler_install,
3817 AC_DEFINE(HAVE_RL_CALLBACK, 1,
Gregory P. Smithff7b2d52008-09-03 05:57:48 +00003818 [Define if you have readline 2.1]), ,$READLINE_LIBS)
Michael W. Hudson30ea2f22004-07-07 17:44:12 +00003819
Guido van Rossumfaf5e4d2002-12-30 16:25:41 +00003820# check for readline 2.2
3821AC_TRY_CPP([#include <readline/readline.h>],
3822have_readline=yes, have_readline=no)
3823if test $have_readline = yes
3824then
3825 AC_EGREP_HEADER([extern int rl_completion_append_character;],
3826 [readline/readline.h],
3827 AC_DEFINE(HAVE_RL_COMPLETION_APPEND_CHARACTER, 1,
3828 [Define if you have readline 2.2]), )
Antoine Pitroud9ff74e2009-10-26 19:16:46 +00003829 AC_EGREP_HEADER([extern int rl_completion_suppress_append;],
3830 [readline/readline.h],
3831 AC_DEFINE(HAVE_RL_COMPLETION_SUPPRESS_APPEND, 1,
3832 [Define if you have rl_completion_suppress_append]), )
Guido van Rossumfaf5e4d2002-12-30 16:25:41 +00003833fi
3834
Martin v. Löwis0daad592001-09-30 21:09:59 +00003835# check for readline 4.0
3836AC_CHECK_LIB(readline, rl_pre_input_hook,
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003837 AC_DEFINE(HAVE_RL_PRE_INPUT_HOOK, 1,
Gregory P. Smithff7b2d52008-09-03 05:57:48 +00003838 [Define if you have readline 4.0]), ,$READLINE_LIBS)
Martin v. Löwis0daad592001-09-30 21:09:59 +00003839
Martin v. Löwis58bd49f2007-09-04 13:13:14 +00003840# also in 4.0
3841AC_CHECK_LIB(readline, rl_completion_display_matches_hook,
3842 AC_DEFINE(HAVE_RL_COMPLETION_DISPLAY_MATCHES_HOOK, 1,
Gregory P. Smithff7b2d52008-09-03 05:57:48 +00003843 [Define if you have readline 4.0]), ,$READLINE_LIBS)
Martin v. Löwis58bd49f2007-09-04 13:13:14 +00003844
Guido van Rossum353ae582001-07-10 16:45:32 +00003845# check for readline 4.2
3846AC_CHECK_LIB(readline, rl_completion_matches,
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003847 AC_DEFINE(HAVE_RL_COMPLETION_MATCHES, 1,
Gregory P. Smithff7b2d52008-09-03 05:57:48 +00003848 [Define if you have readline 4.2]), ,$READLINE_LIBS)
Guido van Rossum353ae582001-07-10 16:45:32 +00003849
Michael W. Hudson30ea2f22004-07-07 17:44:12 +00003850# also in readline 4.2
3851AC_TRY_CPP([#include <readline/readline.h>],
3852have_readline=yes, have_readline=no)
3853if test $have_readline = yes
3854then
3855 AC_EGREP_HEADER([extern int rl_catch_signals;],
3856 [readline/readline.h],
3857 AC_DEFINE(HAVE_RL_CATCH_SIGNAL, 1,
3858 [Define if you can turn off readline's signal handling.]), )
3859fi
3860
Martin v. Löwis82bca632006-02-10 20:49:30 +00003861# End of readline checks: restore LIBS
3862LIBS=$LIBS_no_readline
3863
Thomas Wouterse38b2f12001-07-11 22:35:31 +00003864AC_MSG_CHECKING(for broken nice())
3865AC_CACHE_VAL(ac_cv_broken_nice, [
3866AC_TRY_RUN([
3867int main()
3868{
3869 int val1 = nice(1);
3870 if (val1 != -1 && val1 == nice(2))
3871 exit(0);
3872 exit(1);
3873}
Guido van Rossum3065c942001-09-17 04:03:14 +00003874],
3875ac_cv_broken_nice=yes,
3876ac_cv_broken_nice=no,
3877ac_cv_broken_nice=no)])
Thomas Wouterse38b2f12001-07-11 22:35:31 +00003878AC_MSG_RESULT($ac_cv_broken_nice)
3879if test "$ac_cv_broken_nice" = yes
3880then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003881 AC_DEFINE(HAVE_BROKEN_NICE, 1,
3882 [Define if nice() returns success/failure instead of the new priority.])
Thomas Wouterse38b2f12001-07-11 22:35:31 +00003883fi
3884
Nicholas Bastine62c5c82004-03-21 23:45:42 +00003885AC_MSG_CHECKING(for broken poll())
Alexandre Vassalotti00900892009-07-17 05:26:39 +00003886AC_CACHE_VAL(ac_cv_broken_poll,
Nicholas Bastine62c5c82004-03-21 23:45:42 +00003887AC_TRY_RUN([
3888#include <poll.h>
3889
Alexandre Vassalotti66da2632009-07-17 06:17:33 +00003890int main()
3891{
Nicholas Bastine62c5c82004-03-21 23:45:42 +00003892 struct pollfd poll_struct = { 42, POLLIN|POLLPRI|POLLOUT, 0 };
Alexandre Vassalotti66da2632009-07-17 06:17:33 +00003893 int poll_test;
3894
Nicholas Bastine62c5c82004-03-21 23:45:42 +00003895 close (42);
3896
Alexandre Vassalotti66da2632009-07-17 06:17:33 +00003897 poll_test = poll(&poll_struct, 1, 0);
Nicholas Bastine62c5c82004-03-21 23:45:42 +00003898 if (poll_test < 0)
Alexandre Vassalotti66da2632009-07-17 06:17:33 +00003899 return 0;
Nicholas Bastine62c5c82004-03-21 23:45:42 +00003900 else if (poll_test == 0 && poll_struct.revents != POLLNVAL)
Alexandre Vassalotti66da2632009-07-17 06:17:33 +00003901 return 0;
Nicholas Bastine62c5c82004-03-21 23:45:42 +00003902 else
Alexandre Vassalotti66da2632009-07-17 06:17:33 +00003903 return 1;
3904}
Nicholas Bastine62c5c82004-03-21 23:45:42 +00003905],
3906ac_cv_broken_poll=yes,
3907ac_cv_broken_poll=no,
Alexandre Vassalotti00900892009-07-17 05:26:39 +00003908ac_cv_broken_poll=no))
Nicholas Bastine62c5c82004-03-21 23:45:42 +00003909AC_MSG_RESULT($ac_cv_broken_poll)
3910if test "$ac_cv_broken_poll" = yes
3911then
3912 AC_DEFINE(HAVE_BROKEN_POLL, 1,
3913 [Define if poll() sets errno on invalid file descriptors.])
3914fi
3915
Brett Cannon43802422005-02-10 20:48:03 +00003916# Before we can test tzset, we need to check if struct tm has a tm_zone
3917# (which is not required by ISO C or UNIX spec) and/or if we support
3918# tzname[]
3919AC_STRUCT_TIMEZONE
Nicholas Bastine62c5c82004-03-21 23:45:42 +00003920
Brett Cannon43802422005-02-10 20:48:03 +00003921# check tzset(3) exists and works like we expect it to
Guido van Rossumd11b62e2003-03-14 21:51:36 +00003922AC_MSG_CHECKING(for working tzset())
3923AC_CACHE_VAL(ac_cv_working_tzset, [
3924AC_TRY_RUN([
3925#include <stdlib.h>
3926#include <time.h>
Brett Cannon18367812003-09-19 00:59:16 +00003927#include <string.h>
Brett Cannon43802422005-02-10 20:48:03 +00003928
3929#if HAVE_TZNAME
3930extern char *tzname[];
3931#endif
3932
Guido van Rossumd11b62e2003-03-14 21:51:36 +00003933int main()
3934{
Brett Cannon18367812003-09-19 00:59:16 +00003935 /* Note that we need to ensure that not only does tzset(3)
3936 do 'something' with localtime, but it works as documented
3937 in the library reference and as expected by the test suite.
Brett Cannon43802422005-02-10 20:48:03 +00003938 This includes making sure that tzname is set properly if
3939 tm->tm_zone does not exist since it is the alternative way
3940 of getting timezone info.
Brett Cannon18367812003-09-19 00:59:16 +00003941
3942 Red Hat 6.2 doesn't understand the southern hemisphere
Brett Cannon43802422005-02-10 20:48:03 +00003943 after New Year's Day.
Brett Cannon18367812003-09-19 00:59:16 +00003944 */
3945
Brett Cannon43802422005-02-10 20:48:03 +00003946 time_t groundhogday = 1044144000; /* GMT-based */
Brett Cannon18367812003-09-19 00:59:16 +00003947 time_t midyear = groundhogday + (365 * 24 * 3600 / 2);
3948
Neal Norwitz7f2588c2003-04-11 15:35:53 +00003949 putenv("TZ=UTC+0");
Guido van Rossumd11b62e2003-03-14 21:51:36 +00003950 tzset();
Brett Cannon18367812003-09-19 00:59:16 +00003951 if (localtime(&groundhogday)->tm_hour != 0)
3952 exit(1);
Brett Cannon43802422005-02-10 20:48:03 +00003953#if HAVE_TZNAME
3954 /* For UTC, tzname[1] is sometimes "", sometimes " " */
3955 if (strcmp(tzname[0], "UTC") ||
3956 (tzname[1][0] != 0 && tzname[1][0] != ' '))
3957 exit(1);
3958#endif
Brett Cannon18367812003-09-19 00:59:16 +00003959
Neal Norwitz7f2588c2003-04-11 15:35:53 +00003960 putenv("TZ=EST+5EDT,M4.1.0,M10.5.0");
Guido van Rossumd11b62e2003-03-14 21:51:36 +00003961 tzset();
Brett Cannon18367812003-09-19 00:59:16 +00003962 if (localtime(&groundhogday)->tm_hour != 19)
Guido van Rossumd11b62e2003-03-14 21:51:36 +00003963 exit(1);
Brett Cannon43802422005-02-10 20:48:03 +00003964#if HAVE_TZNAME
3965 if (strcmp(tzname[0], "EST") || strcmp(tzname[1], "EDT"))
3966 exit(1);
3967#endif
Brett Cannon18367812003-09-19 00:59:16 +00003968
3969 putenv("TZ=AEST-10AEDT-11,M10.5.0,M3.5.0");
3970 tzset();
3971 if (localtime(&groundhogday)->tm_hour != 11)
3972 exit(1);
Brett Cannon43802422005-02-10 20:48:03 +00003973#if HAVE_TZNAME
3974 if (strcmp(tzname[0], "AEST") || strcmp(tzname[1], "AEDT"))
3975 exit(1);
3976#endif
3977
3978#if HAVE_STRUCT_TM_TM_ZONE
Brett Cannon18367812003-09-19 00:59:16 +00003979 if (strcmp(localtime(&groundhogday)->tm_zone, "AEDT"))
3980 exit(1);
3981 if (strcmp(localtime(&midyear)->tm_zone, "AEST"))
3982 exit(1);
Brett Cannon43802422005-02-10 20:48:03 +00003983#endif
Brett Cannon18367812003-09-19 00:59:16 +00003984
Guido van Rossumd11b62e2003-03-14 21:51:36 +00003985 exit(0);
3986}
3987],
3988ac_cv_working_tzset=yes,
3989ac_cv_working_tzset=no,
3990ac_cv_working_tzset=no)])
3991AC_MSG_RESULT($ac_cv_working_tzset)
3992if test "$ac_cv_working_tzset" = yes
3993then
3994 AC_DEFINE(HAVE_WORKING_TZSET, 1,
3995 [Define if tzset() actually switches the local timezone in a meaningful way.])
3996fi
3997
Martin v. Löwis94717ed2002-09-09 14:24:16 +00003998# Look for subsecond timestamps in struct stat
3999AC_MSG_CHECKING(for tv_nsec in struct stat)
4000AC_CACHE_VAL(ac_cv_stat_tv_nsec,
4001AC_TRY_COMPILE([#include <sys/stat.h>], [
4002struct stat st;
4003st.st_mtim.tv_nsec = 1;
4004],
Martin v. Löwisa32c9942002-09-09 16:17:47 +00004005ac_cv_stat_tv_nsec=yes,
Martin v. Löwis94717ed2002-09-09 14:24:16 +00004006ac_cv_stat_tv_nsec=no,
4007ac_cv_stat_tv_nsec=no))
4008AC_MSG_RESULT($ac_cv_stat_tv_nsec)
4009if test "$ac_cv_stat_tv_nsec" = yes
4010then
4011 AC_DEFINE(HAVE_STAT_TV_NSEC, 1,
4012 [Define if you have struct stat.st_mtim.tv_nsec])
4013fi
4014
Martin v. Löwisebd9d5b2005-08-09 15:00:59 +00004015# Look for BSD style subsecond timestamps in struct stat
4016AC_MSG_CHECKING(for tv_nsec2 in struct stat)
4017AC_CACHE_VAL(ac_cv_stat_tv_nsec2,
4018AC_TRY_COMPILE([#include <sys/stat.h>], [
4019struct stat st;
4020st.st_mtimespec.tv_nsec = 1;
4021],
4022ac_cv_stat_tv_nsec2=yes,
4023ac_cv_stat_tv_nsec2=no,
4024ac_cv_stat_tv_nsec2=no))
4025AC_MSG_RESULT($ac_cv_stat_tv_nsec2)
4026if test "$ac_cv_stat_tv_nsec2" = yes
4027then
4028 AC_DEFINE(HAVE_STAT_TV_NSEC2, 1,
4029 [Define if you have struct stat.st_mtimensec])
4030fi
4031
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00004032# On HP/UX 11.0, mvwdelch is a block with a return statement
4033AC_MSG_CHECKING(whether mvwdelch is an expression)
4034AC_CACHE_VAL(ac_cv_mvwdelch_is_expression,
4035AC_TRY_COMPILE([#include <curses.h>], [
4036 int rtn;
4037 rtn = mvwdelch(0,0,0);
4038], ac_cv_mvwdelch_is_expression=yes,
4039 ac_cv_mvwdelch_is_expression=no,
4040 ac_cv_mvwdelch_is_expression=yes))
4041AC_MSG_RESULT($ac_cv_mvwdelch_is_expression)
4042
4043if test "$ac_cv_mvwdelch_is_expression" = yes
4044then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00004045 AC_DEFINE(MVWDELCH_IS_EXPRESSION, 1,
4046 [Define if mvwdelch in curses.h is an expression.])
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00004047fi
4048
4049AC_MSG_CHECKING(whether WINDOW has _flags)
4050AC_CACHE_VAL(ac_cv_window_has_flags,
4051AC_TRY_COMPILE([#include <curses.h>], [
4052 WINDOW *w;
4053 w->_flags = 0;
4054], ac_cv_window_has_flags=yes,
4055 ac_cv_window_has_flags=no,
4056 ac_cv_window_has_flags=no))
4057AC_MSG_RESULT($ac_cv_window_has_flags)
4058
4059
4060if test "$ac_cv_window_has_flags" = yes
4061then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00004062 AC_DEFINE(WINDOW_HAS_FLAGS, 1,
4063 [Define if WINDOW in curses.h offers a field _flags.])
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00004064fi
4065
Walter Dörwald4994d952006-06-19 08:07:50 +00004066AC_MSG_CHECKING(for is_term_resized)
Matthias Klose5183ebd2010-04-24 16:38:36 +00004067AC_TRY_COMPILE([#include <curses.h>], [void *x=is_term_resized],
4068 AC_DEFINE(HAVE_CURSES_IS_TERM_RESIZED, 1, [Define if you have the 'is_term_resized' function.])
Walter Dörwald4994d952006-06-19 08:07:50 +00004069 AC_MSG_RESULT(yes),
4070 AC_MSG_RESULT(no)
4071)
4072
Walter Dörwald05fdbf12006-06-19 08:14:09 +00004073AC_MSG_CHECKING(for resize_term)
Matthias Klose5183ebd2010-04-24 16:38:36 +00004074AC_TRY_COMPILE([#include <curses.h>], [void *x=resize_term],
4075 AC_DEFINE(HAVE_CURSES_RESIZE_TERM, 1, [Define if you have the 'resize_term' function.])
Walter Dörwald4994d952006-06-19 08:07:50 +00004076 AC_MSG_RESULT(yes),
4077 AC_MSG_RESULT(no)
4078)
4079
Walter Dörwald05fdbf12006-06-19 08:14:09 +00004080AC_MSG_CHECKING(for resizeterm)
Matthias Klose5183ebd2010-04-24 16:38:36 +00004081AC_TRY_COMPILE([#include <curses.h>], [void *x=resizeterm],
4082 AC_DEFINE(HAVE_CURSES_RESIZETERM, 1, [Define if you have the 'resizeterm' function.])
Walter Dörwald4994d952006-06-19 08:07:50 +00004083 AC_MSG_RESULT(yes),
4084 AC_MSG_RESULT(no)
4085)
4086
Martin v. Löwisfefbc202006-10-17 18:59:23 +00004087AC_MSG_CHECKING(for /dev/ptmx)
4088
4089if test -r /dev/ptmx
4090then
4091 AC_MSG_RESULT(yes)
4092 AC_DEFINE(HAVE_DEV_PTMX, 1,
4093 [Define if we have /dev/ptmx.])
4094else
4095 AC_MSG_RESULT(no)
4096fi
4097
4098AC_MSG_CHECKING(for /dev/ptc)
4099
4100if test -r /dev/ptc
4101then
4102 AC_MSG_RESULT(yes)
4103 AC_DEFINE(HAVE_DEV_PTC, 1,
4104 [Define if we have /dev/ptc.])
4105else
4106 AC_MSG_RESULT(no)
4107fi
Neal Norwitz865400f2003-03-21 01:42:58 +00004108
Mark Dickinson82864d12009-11-15 16:18:58 +00004109if test "$have_long_long" = yes
4110then
4111 AC_MSG_CHECKING(for %lld and %llu printf() format support)
4112 AC_CACHE_VAL(ac_cv_have_long_long_format,
4113 AC_TRY_RUN([[
4114 #include <stdio.h>
4115 #include <stddef.h>
4116 #include <string.h>
4117
4118 #ifdef HAVE_SYS_TYPES_H
4119 #include <sys/types.h>
4120 #endif
4121
4122 int main()
4123 {
4124 char buffer[256];
4125
4126 if (sprintf(buffer, "%lld", (long long)123) < 0)
4127 return 1;
4128 if (strcmp(buffer, "123"))
4129 return 1;
4130
4131 if (sprintf(buffer, "%lld", (long long)-123) < 0)
4132 return 1;
4133 if (strcmp(buffer, "-123"))
4134 return 1;
4135
4136 if (sprintf(buffer, "%llu", (unsigned long long)123) < 0)
4137 return 1;
4138 if (strcmp(buffer, "123"))
4139 return 1;
4140
4141 return 0;
4142 }
4143 ]], ac_cv_have_long_long_format=yes,
4144 ac_cv_have_long_long_format=no,
4145 ac_cv_have_long_long_format=no)
4146 )
4147 AC_MSG_RESULT($ac_cv_have_long_long_format)
4148fi
4149
Mark Dickinson5ce84742009-12-31 20:48:04 +00004150if test "$ac_cv_have_long_long_format" = yes
Mark Dickinson82864d12009-11-15 16:18:58 +00004151then
4152 AC_DEFINE(PY_FORMAT_LONG_LONG, "ll",
4153 [Define to printf format modifier for long long type])
4154fi
4155
Ronald Oussoren315cd0c2009-11-19 16:25:21 +00004156if test $ac_sys_system = Darwin
4157then
4158 LIBS="$LIBS -framework CoreFoundation"
4159fi
4160
Mark Dickinson82864d12009-11-15 16:18:58 +00004161
Gregory P. Smithd8cb2d92009-11-02 02:02:38 +00004162AC_CACHE_CHECK([for %zd printf() format support], ac_cv_have_size_t_format, [dnl
4163AC_TRY_RUN([
Alexandre Vassalottie7cf1182009-07-17 06:33:51 +00004164#include <stdio.h>
Brett Cannon09d12362006-05-11 05:11:33 +00004165#include <stddef.h>
4166#include <string.h>
4167
Christian Heimesdb3d6cb2007-12-16 21:39:43 +00004168#ifdef HAVE_SYS_TYPES_H
4169#include <sys/types.h>
4170#endif
Neal Norwitz4a8fbdb2006-09-22 08:16:26 +00004171
4172#ifdef HAVE_SSIZE_T
4173typedef ssize_t Py_ssize_t;
4174#elif SIZEOF_VOID_P == SIZEOF_LONG
4175typedef long Py_ssize_t;
4176#else
4177typedef int Py_ssize_t;
4178#endif
Brett Cannon09d12362006-05-11 05:11:33 +00004179
Christian Heimesdb3d6cb2007-12-16 21:39:43 +00004180int main()
4181{
4182 char buffer[256];
4183
Brett Cannon09d12362006-05-11 05:11:33 +00004184 if(sprintf(buffer, "%zd", (size_t)123) < 0)
4185 return 1;
4186
Neal Norwitz4a8fbdb2006-09-22 08:16:26 +00004187 if (strcmp(buffer, "123"))
Brett Cannon09d12362006-05-11 05:11:33 +00004188 return 1;
Neal Norwitz4a8fbdb2006-09-22 08:16:26 +00004189
4190 if (sprintf(buffer, "%zd", (Py_ssize_t)-123) < 0)
4191 return 1;
4192
4193 if (strcmp(buffer, "-123"))
4194 return 1;
4195
Brett Cannon09d12362006-05-11 05:11:33 +00004196 return 0;
Alexandre Vassalotti00900892009-07-17 05:26:39 +00004197}
Gregory P. Smithd8cb2d92009-11-02 02:02:38 +00004198], ac_cv_have_size_t_format=yes,
Alexandre Vassalottie7cf1182009-07-17 06:33:51 +00004199 ac_cv_have_size_t_format=no,
Gregory P. Smithd8cb2d92009-11-02 02:02:38 +00004200 [ac_cv_have_size_t_format="cross -- assuming yes"]
4201)])
4202if test "$ac_cv_have_size_t_format" != no ; then
Alexandre Vassalotti00900892009-07-17 05:26:39 +00004203 AC_DEFINE(PY_FORMAT_SIZE_T, "z",
4204 [Define to printf format modifier for Py_ssize_t])
4205fi
Brett Cannon09d12362006-05-11 05:11:33 +00004206
Martin v. Löwis01c04012002-11-11 14:58:44 +00004207AC_CHECK_TYPE(socklen_t,,
4208 AC_DEFINE(socklen_t,int,
Matthias Klose5183ebd2010-04-24 16:38:36 +00004209 [Define to `int' if <sys/socket.h> does not define.]),[
Martin v. Löwis01c04012002-11-11 14:58:44 +00004210#ifdef HAVE_SYS_TYPES_H
4211#include <sys/types.h>
4212#endif
Guido van Rossum95713eb2000-05-18 20:53:31 +00004213#ifdef HAVE_SYS_SOCKET_H
4214#include <sys/socket.h>
4215#endif
Martin v. Löwis01c04012002-11-11 14:58:44 +00004216])
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00004217
Martin v. Löwis06f15bb2001-12-02 13:02:32 +00004218AC_SUBST(THREADHEADERS)
4219
4220for h in `(cd $srcdir;echo Python/thread_*.h)`
4221do
4222 THREADHEADERS="$THREADHEADERS \$(srcdir)/$h"
4223done
4224
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00004225AC_SUBST(SRCDIRS)
Neal Norwitzd24499d2005-12-18 21:36:39 +00004226SRCDIRS="Parser Grammar Objects Python Modules Mac"
Andrew M. Kuchling8abedde2001-01-26 22:55:24 +00004227AC_MSG_CHECKING(for build directories)
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00004228for dir in $SRCDIRS; do
4229 if test ! -d $dir; then
4230 mkdir $dir
Fred Drake884d3ba2000-11-02 17:52:56 +00004231 fi
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00004232done
4233AC_MSG_RESULT(done)
Fred Drake036144d2000-10-26 17:09:35 +00004234
Guido van Rossum627b2d71993-12-24 10:39:16 +00004235# generate output files
Antoine Pitrouf2caeed2009-05-24 20:23:57 +00004236AC_CONFIG_FILES(Makefile.pre Modules/Setup.config Misc/python.pc)
Martin v. Löwis88afe662002-10-26 13:47:44 +00004237AC_OUTPUT
Neil Schemenauer61c51152001-01-26 16:18:16 +00004238
Martin v. Löwisf7afe952006-04-14 15:16:15 +00004239echo "creating Modules/Setup"
Neil Schemenauer61c51152001-01-26 16:18:16 +00004240if test ! -f Modules/Setup
4241then
4242 cp $srcdir/Modules/Setup.dist Modules/Setup
4243fi
4244
Martin v. Löwisf7afe952006-04-14 15:16:15 +00004245echo "creating Modules/Setup.local"
Neil Schemenauer61c51152001-01-26 16:18:16 +00004246if test ! -f Modules/Setup.local
4247then
4248 echo "# Edit this file for local setup changes" >Modules/Setup.local
4249fi
4250
4251echo "creating Makefile"
4252$SHELL $srcdir/Modules/makesetup -c $srcdir/Modules/config.c.in \
4253 -s Modules Modules/Setup.config \
Neil Schemenauerf8b71c52001-04-21 17:41:16 +00004254 Modules/Setup.local Modules/Setup
Skip Montanaro7221d932007-08-22 19:02:16 +00004255
4256case $ac_sys_system in
4257BeOS)
4258 AC_MSG_WARN([
4259
4260 Support for BeOS is deprecated as of Python 2.6.
4261 See PEP 11 for the gory details.
4262 ])
4263 ;;
4264*) ;;
4265esac
4266
Neil Schemenauer66252162001-02-19 04:47:42 +00004267mv config.c Modules