blob: 68e6d5af95bee12b556f2727a25c90369badfb14 [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,
Brett Cannon91a1dec2008-02-13 19:15:44 +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,
Ronald Oussoren23d92532009-09-07 06:12:00 +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,
151 AC_HELP_STRING(--with-framework-name=FRAMEWORK,
152 specify an alternate name of the framework built with --enable-framework),
153[
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,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000169 AC_HELP_STRING(--enable-framework@<:@=INSTALLDIR@:>@, Build (MacOSX|Darwin) framework),
170[
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
1055 BASECFLAGS="${UNIVERSAL_ARCH_FLAGS} -isysroot ${UNIVERSALSDK} ${BASECFLAGS}"
1056 tgt=`sw_vers -productVersion | sed 's/\(10\.[[0-9]]*\).*/\1/'`
1057 if test "${UNIVERSALSDK}" != "/" -a "${tgt}" '>' '10.4' ; then
1058 CFLAGS="${UNIVERSAL_ARCH_FLAGS} -isysroot ${UNIVERSALSDK} ${CFLAGS}"
1059 CPPFLAGS="-isysroot ${UNIVERSALSDK}"
1060 fi
1061
1062 fi
1063
1064
Skip Montanarodecc6a42003-01-01 20:07:49 +00001065 ;;
Neal Norwitzdedeeaa2006-03-31 06:54:45 +00001066 OSF*)
1067 BASECFLAGS="$BASECFLAGS -mieee"
1068 ;;
Skip Montanarodecc6a42003-01-01 20:07:49 +00001069 esac
1070 ;;
1071
1072*)
1073 case $ac_sys_system in
1074 OpenUNIX*|UnixWare*)
1075 BASECFLAGS="$BASECFLAGS -K pentium,host,inline,loop_unroll,alloca "
1076 ;;
Neal Norwitzb44f1652003-05-26 14:11:55 +00001077 OSF*)
1078 BASECFLAGS="$BASECFLAGS -ieee -std"
1079 ;;
Skip Montanarodecc6a42003-01-01 20:07:49 +00001080 SCO_SV*)
1081 BASECFLAGS="$BASECFLAGS -belf -Ki486 -DSCO5"
1082 ;;
1083 esac
1084 ;;
1085esac
1086
Fred Drakee1ceaa02001-12-04 20:55:47 +00001087if test "$Py_DEBUG" = 'true'; then
1088 :
1089else
1090 OPT="-DNDEBUG $OPT"
1091fi
1092
Guido van Rossum6f2260e1996-09-09 16:21:03 +00001093if test "$ac_arch_flags"
Guido van Rossumc5a39031996-07-31 17:35:03 +00001094then
Skip Montanarodecc6a42003-01-01 20:07:49 +00001095 BASECFLAGS="$BASECFLAGS $ac_arch_flags"
Guido van Rossumc5a39031996-07-31 17:35:03 +00001096fi
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001097
Neal Norwitz020c46a2006-01-07 21:39:28 +00001098# disable check for icc since it seems to pass, but generates a warning
1099if test "$CC" = icc
1100then
1101 ac_cv_opt_olimit_ok=no
1102fi
1103
Guido van Rossum91922671997-10-09 20:24:13 +00001104AC_MSG_CHECKING(whether $CC accepts -OPT:Olimit=0)
1105AC_CACHE_VAL(ac_cv_opt_olimit_ok,
1106[ac_save_cc="$CC"
1107CC="$CC -OPT:Olimit=0"
Gregory P. Smithec3b8bd2009-11-01 21:02:52 +00001108AC_TRY_COMPILE([],[int main() { return 0; }],
Guido van Rossum91922671997-10-09 20:24:13 +00001109 ac_cv_opt_olimit_ok=yes,
Guido van Rossum3065c942001-09-17 04:03:14 +00001110 ac_cv_opt_olimit_ok=no,
Gregory P. Smithec3b8bd2009-11-01 21:02:52 +00001111 )
Guido van Rossum91922671997-10-09 20:24:13 +00001112CC="$ac_save_cc"])
1113AC_MSG_RESULT($ac_cv_opt_olimit_ok)
Guido van Rossum2efa34b1997-10-23 17:43:11 +00001114if test $ac_cv_opt_olimit_ok = yes; then
Guido van Rossum5839e582000-10-09 19:52:35 +00001115 case $ac_sys_system in
Skip Montanarodecc6a42003-01-01 20:07:49 +00001116 # XXX is this branch needed? On MacOSX 10.2.2 the result of the
1117 # olimit_ok test is "no". Is it "yes" in some other Darwin-esque
1118 # environment?
1119 Darwin*)
1120 ;;
1121 *)
1122 BASECFLAGS="$BASECFLAGS -OPT:Olimit=0"
1123 ;;
Guido van Rossum5839e582000-10-09 19:52:35 +00001124 esac
Guido van Rossumf8678121998-07-07 21:05:09 +00001125else
1126 AC_MSG_CHECKING(whether $CC accepts -Olimit 1500)
1127 AC_CACHE_VAL(ac_cv_olimit_ok,
1128 [ac_save_cc="$CC"
1129 CC="$CC -Olimit 1500"
Gregory P. Smithec3b8bd2009-11-01 21:02:52 +00001130 AC_TRY_COMPILE([],[int main() { return 0; }],
Guido van Rossumf8678121998-07-07 21:05:09 +00001131 ac_cv_olimit_ok=yes,
Guido van Rossum3065c942001-09-17 04:03:14 +00001132 ac_cv_olimit_ok=no,
Gregory P. Smithec3b8bd2009-11-01 21:02:52 +00001133 )
Guido van Rossumf8678121998-07-07 21:05:09 +00001134 CC="$ac_save_cc"])
1135 AC_MSG_RESULT($ac_cv_olimit_ok)
1136 if test $ac_cv_olimit_ok = yes; then
Skip Montanarodecc6a42003-01-01 20:07:49 +00001137 BASECFLAGS="$BASECFLAGS -Olimit 1500"
Guido van Rossumf8678121998-07-07 21:05:09 +00001138 fi
Guido van Rossum201afe51997-05-14 21:14:44 +00001139fi
Guido van Rossumf8678121998-07-07 21:05:09 +00001140
Martin v. Löwisaac13162006-10-19 10:58:46 +00001141# Check whether GCC supports PyArg_ParseTuple format
1142if test "$GCC" = "yes"
1143then
1144 AC_MSG_CHECKING(whether gcc supports ParseTuple __format__)
1145 save_CFLAGS=$CFLAGS
1146 CFLAGS="$CFLAGS -Werror"
1147 AC_TRY_COMPILE([
1148 void f(char*,...)__attribute((format(PyArg_ParseTuple, 1, 2)));
1149 ],,
1150 AC_DEFINE(HAVE_ATTRIBUTE_FORMAT_PARSETUPLE, 1, [Define if GCC supports __attribute__((format(PyArg_ParseTuple, 2, 3)))])
1151 AC_MSG_RESULT(yes),
1152 AC_MSG_RESULT(no)
1153 )
Martin v. Löwisc1d75972006-10-19 16:01:37 +00001154 CFLAGS=$save_CFLAGS
Martin v. Löwisaac13162006-10-19 10:58:46 +00001155fi
1156
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00001157# On some compilers, pthreads are available without further options
1158# (e.g. MacOS X). On some of these systems, the compiler will not
1159# complain if unaccepted options are passed (e.g. gcc on Mac OS X).
1160# So we have to see first whether pthreads are available without
1161# options before we can check whether -Kpthread improves anything.
1162AC_MSG_CHECKING(whether pthreads are available without options)
1163AC_CACHE_VAL(ac_cv_pthread_is_default,
1164[AC_TRY_RUN([
1165#include <pthread.h>
1166
1167void* routine(void* p){return NULL;}
1168
1169int main(){
1170 pthread_t p;
1171 if(pthread_create(&p,NULL,routine,NULL)!=0)
1172 return 1;
Jack Jansen4f8d0542002-03-08 13:43:01 +00001173 (void)pthread_detach(p);
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00001174 return 0;
1175}
1176],
Skip Montanarod8d39a02003-07-10 20:44:10 +00001177[
1178 ac_cv_pthread_is_default=yes
1179 ac_cv_kthread=no
1180 ac_cv_pthread=no
1181],
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00001182 ac_cv_pthread_is_default=no,
1183 ac_cv_pthread_is_default=no)
1184])
1185AC_MSG_RESULT($ac_cv_pthread_is_default)
1186
1187
1188if test $ac_cv_pthread_is_default = yes
1189then
1190 ac_cv_kpthread=no
1191else
Martin v. Löwis130fb172001-07-19 11:00:41 +00001192# -Kpthread, if available, provides the right #defines
1193# and linker options to make pthread_create available
Martin v. Löwis260aecc2001-10-07 08:14:41 +00001194# Some compilers won't report that they do not support -Kpthread,
1195# so we need to run a program to see whether it really made the
1196# function available.
Martin v. Löwis130fb172001-07-19 11:00:41 +00001197AC_MSG_CHECKING(whether $CC accepts -Kpthread)
1198AC_CACHE_VAL(ac_cv_kpthread,
1199[ac_save_cc="$CC"
1200CC="$CC -Kpthread"
Martin v. Löwis260aecc2001-10-07 08:14:41 +00001201AC_TRY_RUN([
1202#include <pthread.h>
1203
1204void* routine(void* p){return NULL;}
1205
1206int main(){
1207 pthread_t p;
1208 if(pthread_create(&p,NULL,routine,NULL)!=0)
1209 return 1;
Jack Jansen4f8d0542002-03-08 13:43:01 +00001210 (void)pthread_detach(p);
Martin v. Löwis260aecc2001-10-07 08:14:41 +00001211 return 0;
1212}
1213],
Martin v. Löwis130fb172001-07-19 11:00:41 +00001214 ac_cv_kpthread=yes,
Martin v. Löwis260aecc2001-10-07 08:14:41 +00001215 ac_cv_kpthread=no,
Martin v. Löwis130fb172001-07-19 11:00:41 +00001216 ac_cv_kpthread=no)
1217CC="$ac_save_cc"])
Martin v. Löwis130fb172001-07-19 11:00:41 +00001218AC_MSG_RESULT($ac_cv_kpthread)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00001219fi
Martin v. Löwis130fb172001-07-19 11:00:41 +00001220
Skip Montanarod8d39a02003-07-10 20:44:10 +00001221if test $ac_cv_kpthread = no -a $ac_cv_pthread_is_default = no
Martin v. Löwis5f433f02003-05-05 05:05:30 +00001222then
1223# -Kthread, if available, provides the right #defines
1224# and linker options to make pthread_create available
1225# Some compilers won't report that they do not support -Kthread,
1226# so we need to run a program to see whether it really made the
1227# function available.
1228AC_MSG_CHECKING(whether $CC accepts -Kthread)
1229AC_CACHE_VAL(ac_cv_kthread,
1230[ac_save_cc="$CC"
1231CC="$CC -Kthread"
1232AC_TRY_RUN([
1233#include <pthread.h>
1234
1235void* routine(void* p){return NULL;}
1236
1237int main(){
1238 pthread_t p;
1239 if(pthread_create(&p,NULL,routine,NULL)!=0)
1240 return 1;
1241 (void)pthread_detach(p);
1242 return 0;
1243}
1244],
1245 ac_cv_kthread=yes,
1246 ac_cv_kthread=no,
1247 ac_cv_kthread=no)
1248CC="$ac_save_cc"])
1249AC_MSG_RESULT($ac_cv_kthread)
1250fi
1251
Skip Montanarod8d39a02003-07-10 20:44:10 +00001252if test $ac_cv_kthread = no -a $ac_cv_pthread_is_default = no
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00001253then
1254# -pthread, if available, provides the right #defines
1255# and linker options to make pthread_create available
1256# Some compilers won't report that they do not support -pthread,
1257# so we need to run a program to see whether it really made the
1258# function available.
1259AC_MSG_CHECKING(whether $CC accepts -pthread)
1260AC_CACHE_VAL(ac_cv_thread,
1261[ac_save_cc="$CC"
1262CC="$CC -pthread"
1263AC_TRY_RUN([
1264#include <pthread.h>
1265
1266void* routine(void* p){return NULL;}
1267
1268int main(){
1269 pthread_t p;
1270 if(pthread_create(&p,NULL,routine,NULL)!=0)
1271 return 1;
1272 (void)pthread_detach(p);
1273 return 0;
1274}
1275],
1276 ac_cv_pthread=yes,
1277 ac_cv_pthread=no,
1278 ac_cv_pthread=no)
1279CC="$ac_save_cc"])
1280AC_MSG_RESULT($ac_cv_pthread)
1281fi
1282
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001283# If we have set a CC compiler flag for thread support then
1284# check if it works for CXX, too.
1285ac_cv_cxx_thread=no
1286if test ! -z "$CXX"
1287then
1288AC_MSG_CHECKING(whether $CXX also accepts flags for thread support)
1289ac_save_cxx="$CXX"
1290
1291if test "$ac_cv_kpthread" = "yes"
1292then
Martin v. Löwis519adae2003-09-20 10:47:47 +00001293 CXX="$CXX -Kpthread"
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001294 ac_cv_cxx_thread=yes
1295elif test "$ac_cv_kthread" = "yes"
1296then
1297 CXX="$CXX -Kthread"
1298 ac_cv_cxx_thread=yes
1299elif test "$ac_cv_pthread" = "yes"
1300then
1301 CXX="$CXX -pthread"
1302 ac_cv_cxx_thread=yes
1303fi
1304
1305if test $ac_cv_cxx_thread = yes
1306then
1307 echo 'void foo();int main(){foo();}void foo(){}' > conftest.$ac_ext
1308 $CXX -c conftest.$ac_ext 2>&5
1309 if $CXX -o conftest$ac_exeext conftest.$ac_objext 2>&5 \
1310 && test -s conftest$ac_exeext && ./conftest$ac_exeext
1311 then
1312 ac_cv_cxx_thread=yes
1313 else
1314 ac_cv_cxx_thread=no
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001315 fi
1316 rm -fr conftest*
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001317fi
Brett Cannonc601e0f2004-11-07 01:24:12 +00001318AC_MSG_RESULT($ac_cv_cxx_thread)
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001319fi
Martin v. Löwis519adae2003-09-20 10:47:47 +00001320CXX="$ac_save_cxx"
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001321
Fred Drakece81d592000-07-09 14:39:29 +00001322dnl # check for ANSI or K&R ("traditional") preprocessor
1323dnl AC_MSG_CHECKING(for C preprocessor type)
1324dnl AC_TRY_COMPILE([
1325dnl #define spam(name, doc) {#name, &name, #name "() -- " doc}
1326dnl int foo;
1327dnl struct {char *name; int *addr; char *doc;} desc = spam(foo, "something");
1328dnl ], [;], cpp_type=ansi, AC_DEFINE(HAVE_OLD_CPP) cpp_type=traditional)
1329dnl AC_MSG_RESULT($cpp_type)
Guido van Rossum300fda71996-08-19 21:58:16 +00001330
Guido van Rossum627b2d71993-12-24 10:39:16 +00001331# checks for header files
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001332AC_HEADER_STDC
Martin v. Löwis0e8bd7e2006-06-10 12:23:46 +00001333AC_CHECK_HEADERS(asm/types.h conio.h curses.h direct.h dlfcn.h errno.h \
1334fcntl.h grp.h \
Neal Norwitz9fdfaaf2008-03-28 05:34:59 +00001335ieeefp.h io.h langinfo.h libintl.h ncurses.h poll.h process.h pthread.h \
Martin v. Löwis40e9aed2006-10-02 15:20:37 +00001336shadow.h signal.h stdint.h stropts.h termios.h thread.h \
Martin v. Löwis14e73b12003-01-01 09:51:12 +00001337unistd.h utime.h \
Christian Heimes0e9ab5f2008-03-21 23:49:44 +00001338sys/audioio.h sys/bsdtty.h sys/epoll.h sys/event.h sys/file.h sys/loadavg.h \
1339sys/lock.h sys/mkdev.h sys/modem.h \
Martin v. Löwis0e8bd7e2006-06-10 12:23:46 +00001340sys/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 +00001341sys/termio.h sys/time.h \
Martin v. Löwis0e8bd7e2006-06-10 12:23:46 +00001342sys/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 +00001343sys/resource.h netpacket/packet.h sysexits.h bluetooth.h \
Ronald Oussorena55af9a2010-01-17 16:25:57 +00001344bluetooth/bluetooth.h linux/tipc.h spawn.h util.h)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001345AC_HEADER_DIRENT
Martin v. Löwisdbe3f762002-10-10 14:27:30 +00001346AC_HEADER_MAJOR
Guido van Rossum627b2d71993-12-24 10:39:16 +00001347
Martin v. Löwisae2830c2004-09-18 09:54:52 +00001348# On Solaris, term.h requires curses.h
Martin v. Löwisfd1c69e2004-11-30 22:09:37 +00001349AC_CHECK_HEADERS(term.h,,,[
Martin v. Löwis5d52e782004-09-18 10:07:03 +00001350#ifdef HAVE_CURSES_H
1351#include <curses.h>
1352#endif
1353])
Martin v. Löwisae2830c2004-09-18 09:54:52 +00001354
Martin v. Löwis11017b12006-01-14 18:12:57 +00001355# On Linux, netlink.h requires asm/types.h
1356AC_CHECK_HEADERS(linux/netlink.h,,,[
1357#ifdef HAVE_ASM_TYPES_H
1358#include <asm/types.h>
1359#endif
1360#ifdef HAVE_SYS_SOCKET_H
1361#include <sys/socket.h>
1362#endif
1363])
1364
Guido van Rossum627b2d71993-12-24 10:39:16 +00001365# checks for typedefs
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001366was_it_defined=no
1367AC_MSG_CHECKING(for clock_t in time.h)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001368AC_EGREP_HEADER(clock_t, time.h, was_it_defined=yes, [
1369 AC_DEFINE(clock_t, long, [Define to 'long' if <time.h> doesn't define.])
1370])
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001371AC_MSG_RESULT($was_it_defined)
1372
Neal Norwitz11690112002-07-30 01:08:28 +00001373# Check whether using makedev requires defining _OSF_SOURCE
1374AC_MSG_CHECKING(for makedev)
Neal Norwitz6eb37f02003-02-23 23:28:15 +00001375AC_TRY_LINK([#include <sys/types.h> ],
Neal Norwitz11690112002-07-30 01:08:28 +00001376 [ makedev(0, 0) ],
1377 ac_cv_has_makedev=yes,
1378 ac_cv_has_makedev=no)
1379if test "$ac_cv_has_makedev" = "no"; then
1380 # we didn't link, try if _OSF_SOURCE will allow us to link
1381 AC_TRY_LINK([
Neal Norwitz6eb37f02003-02-23 23:28:15 +00001382#define _OSF_SOURCE 1
1383#include <sys/types.h>
Neal Norwitz11690112002-07-30 01:08:28 +00001384 ],
1385 [ makedev(0, 0) ],
1386 ac_cv_has_makedev=yes,
1387 ac_cv_has_makedev=no)
1388 if test "$ac_cv_has_makedev" = "yes"; then
1389 AC_DEFINE(_OSF_SOURCE, 1, [Define _OSF_SOURCE to get the makedev macro.])
1390 fi
1391fi
1392AC_MSG_RESULT($ac_cv_has_makedev)
1393if test "$ac_cv_has_makedev" = "yes"; then
1394 AC_DEFINE(HAVE_MAKEDEV, 1, [Define this if you have the makedev macro.])
1395fi
1396
Martin v. Löwis399a6892002-10-04 10:22:02 +00001397# Enabling LFS on Solaris (2.6 to 9) with gcc 2.95 triggers a bug in
1398# the system headers: If _XOPEN_SOURCE and _LARGEFILE_SOURCE are
1399# defined, but the compiler does not support pragma redefine_extname,
1400# and _LARGEFILE64_SOURCE is not defined, the headers refer to 64-bit
1401# structures (such as rlimit64) without declaring them. As a
1402# work-around, disable LFS on such configurations
1403
1404use_lfs=yes
1405AC_MSG_CHECKING(Solaris LFS bug)
1406AC_TRY_COMPILE([
1407#define _LARGEFILE_SOURCE 1
1408#define _FILE_OFFSET_BITS 64
1409#include <sys/resource.h>
1410],struct rlimit foo;,sol_lfs_bug=no,sol_lfs_bug=yes)
1411AC_MSG_RESULT($sol_lfs_bug)
1412if test "$sol_lfs_bug" = "yes"; then
1413 use_lfs=no
1414fi
1415
1416if test "$use_lfs" = "yes"; then
Guido van Rossum810cc512001-09-09 23:51:39 +00001417# Two defines needed to enable largefile support on various platforms
1418# These may affect some typedefs
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001419AC_DEFINE(_LARGEFILE_SOURCE, 1,
1420[This must be defined on some systems to enable large file support.])
1421AC_DEFINE(_FILE_OFFSET_BITS, 64,
1422[This must be set to 64 on some systems to enable large file support.])
Martin v. Löwis399a6892002-10-04 10:22:02 +00001423fi
Guido van Rossum810cc512001-09-09 23:51:39 +00001424
Guido van Rossum300fda71996-08-19 21:58:16 +00001425# Add some code to confdefs.h so that the test for off_t works on SCO
1426cat >> confdefs.h <<\EOF
1427#if defined(SCO_DS)
1428#undef _OFF_T
1429#endif
1430EOF
1431
Guido van Rossumef2255b2000-03-10 22:30:29 +00001432# Type availability checks
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001433AC_TYPE_MODE_T
1434AC_TYPE_OFF_T
1435AC_TYPE_PID_T
1436AC_TYPE_SIGNAL
1437AC_TYPE_SIZE_T
1438AC_TYPE_UID_T
Mark Dickinsonefc82f72009-03-20 15:51:55 +00001439AC_TYPE_UINT32_T
1440AC_TYPE_UINT64_T
1441AC_TYPE_INT32_T
1442AC_TYPE_INT64_T
Christian Heimes951cc0f2008-01-31 23:08:23 +00001443AC_CHECK_TYPE(ssize_t,
Martin v. Löwis18e16552006-02-15 17:27:45 +00001444 AC_DEFINE(HAVE_SSIZE_T, 1, Define if your compiler provides ssize_t),,)
Guido van Rossum627b2d71993-12-24 10:39:16 +00001445
Guido van Rossumef2255b2000-03-10 22:30:29 +00001446# Sizes of various common basic types
Skip Montanarob9820a32004-01-17 00:16:12 +00001447# ANSI C requires sizeof(char) == 1, so no need to check it
Guido van Rossum3065c942001-09-17 04:03:14 +00001448AC_CHECK_SIZEOF(int, 4)
1449AC_CHECK_SIZEOF(long, 4)
1450AC_CHECK_SIZEOF(void *, 4)
Guido van Rossum3065c942001-09-17 04:03:14 +00001451AC_CHECK_SIZEOF(short, 2)
1452AC_CHECK_SIZEOF(float, 4)
1453AC_CHECK_SIZEOF(double, 8)
1454AC_CHECK_SIZEOF(fpos_t, 4)
Martin v. Löwis18e16552006-02-15 17:27:45 +00001455AC_CHECK_SIZEOF(size_t, 4)
Christian Heimes951cc0f2008-01-31 23:08:23 +00001456AC_CHECK_SIZEOF(pid_t, 4)
Guido van Rossumac405f61994-09-12 10:56:06 +00001457
Guido van Rossumec95c7b1998-08-04 17:59:56 +00001458AC_MSG_CHECKING(for long long support)
1459have_long_long=no
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001460AC_TRY_COMPILE([], [long long x; x = (long long)0;], [
1461 AC_DEFINE(HAVE_LONG_LONG, 1, [Define this if you have the type long long.])
1462 have_long_long=yes
1463])
Guido van Rossumec95c7b1998-08-04 17:59:56 +00001464AC_MSG_RESULT($have_long_long)
Guido van Rossum8bc1dfd1999-04-10 16:01:48 +00001465if test "$have_long_long" = yes ; then
Guido van Rossum3065c942001-09-17 04:03:14 +00001466AC_CHECK_SIZEOF(long long, 8)
Guido van Rossumec95c7b1998-08-04 17:59:56 +00001467fi
1468
Travis E. Oliphant711c9e92008-06-06 22:33:21 +00001469AC_MSG_CHECKING(for long double support)
1470have_long_double=no
1471AC_TRY_COMPILE([], [long double x; x = (long double)0.;], [
1472 AC_DEFINE(HAVE_LONG_DOUBLE, 1, [Define this if you have the type long double.])
1473 have_long_double=yes
1474])
1475AC_MSG_RESULT($have_long_double)
Mark Dickinsondc1688a2008-06-27 22:20:14 +00001476if test "$have_long_double" = yes ; then
Travis E. Oliphant711c9e92008-06-06 22:33:21 +00001477AC_CHECK_SIZEOF(long double, 12)
1478fi
1479
Martin v. Löwisaef4c6b2007-01-21 09:33:07 +00001480AC_MSG_CHECKING(for _Bool support)
1481have_c99_bool=no
1482AC_TRY_COMPILE([], [_Bool x; x = (_Bool)0;], [
1483 AC_DEFINE(HAVE_C99_BOOL, 1, [Define this if you have the type _Bool.])
1484 have_c99_bool=yes
1485])
1486AC_MSG_RESULT($have_c99_bool)
1487if test "$have_c99_bool" = yes ; then
1488AC_CHECK_SIZEOF(_Bool, 1)
1489fi
1490
Martin v. Löwisebe26702006-10-02 14:55:51 +00001491AC_CHECK_TYPES(uintptr_t,
1492 [AC_CHECK_SIZEOF(uintptr_t, 4)],
Martin v. Löwis40e9aed2006-10-02 15:20:37 +00001493 [], [#ifdef HAVE_STDINT_H
1494 #include <stdint.h>
1495 #endif])
Martin v. Löwisebe26702006-10-02 14:55:51 +00001496
Alexandre Vassalotti856782e2009-07-17 04:59:05 +00001497AC_CHECK_SIZEOF(off_t, [], [
1498#ifdef HAVE_SYS_TYPES_H
1499#include <sys/types.h>
1500#endif
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001501])
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001502
1503AC_MSG_CHECKING(whether to enable large file support)
Mark Dickinson0ef0b912009-12-31 21:11:48 +00001504if test "$have_long_long" = yes
1505then
1506if test "$ac_cv_sizeof_off_t" -gt "$ac_cv_sizeof_long" -a \
Guido van Rossum8bc1dfd1999-04-10 16:01:48 +00001507 "$ac_cv_sizeof_long_long" -ge "$ac_cv_sizeof_off_t"; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001508 AC_DEFINE(HAVE_LARGEFILE_SUPPORT, 1,
1509 [Defined to enable large file support when an off_t is bigger than a long
1510 and long long is available and at least as big as an off_t. You may need
1511 to add some flags for configuration and compilation to enable this mode.
1512 (For Solaris and Linux, the necessary defines are already defined.)])
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001513 AC_MSG_RESULT(yes)
1514else
1515 AC_MSG_RESULT(no)
1516fi
Mark Dickinson0ef0b912009-12-31 21:11:48 +00001517else
1518 AC_MSG_RESULT(no)
1519fi
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001520
Alexandre Vassalotti856782e2009-07-17 04:59:05 +00001521AC_CHECK_SIZEOF(time_t, [], [
1522#ifdef HAVE_SYS_TYPES_H
1523#include <sys/types.h>
1524#endif
1525#ifdef HAVE_TIME_H
1526#include <time.h>
1527#endif
Fred Drakea3f6e912000-06-29 20:44:47 +00001528])
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001529
Trent Mick635f6fb2000-08-23 21:33:05 +00001530# if have pthread_t then define SIZEOF_PTHREAD_T
Martin v. Löwis123cbd22001-07-19 14:21:10 +00001531ac_save_cc="$CC"
1532if test "$ac_cv_kpthread" = "yes"
1533then CC="$CC -Kpthread"
Martin v. Löwis5f433f02003-05-05 05:05:30 +00001534elif test "$ac_cv_kthread" = "yes"
1535then CC="$CC -Kthread"
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00001536elif test "$ac_cv_pthread" = "yes"
1537then CC="$CC -pthread"
Martin v. Löwis123cbd22001-07-19 14:21:10 +00001538fi
Trent Mick635f6fb2000-08-23 21:33:05 +00001539AC_MSG_CHECKING(for pthread_t)
1540have_pthread_t=no
Guido van Rossum12580492000-09-24 16:47:19 +00001541AC_TRY_COMPILE([#include <pthread.h>], [pthread_t x; x = *(pthread_t*)0;], have_pthread_t=yes)
Trent Mick635f6fb2000-08-23 21:33:05 +00001542AC_MSG_RESULT($have_pthread_t)
1543if test "$have_pthread_t" = yes ; then
Alexandre Vassalotti856782e2009-07-17 04:59:05 +00001544 AC_CHECK_SIZEOF(pthread_t, [], [
1545#ifdef HAVE_PTHREAD_H
1546#include <pthread.h>
1547#endif
Trent Mick635f6fb2000-08-23 21:33:05 +00001548 ])
Trent Mick635f6fb2000-08-23 21:33:05 +00001549fi
Martin v. Löwis123cbd22001-07-19 14:21:10 +00001550CC="$ac_save_cc"
Trent Mick635f6fb2000-08-23 21:33:05 +00001551
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001552AC_MSG_CHECKING(for --enable-toolbox-glue)
1553AC_ARG_ENABLE(toolbox-glue,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00001554 AC_HELP_STRING(--enable-toolbox-glue, disable/enable MacOSX glue code for extensions))
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001555
1556if test -z "$enable_toolbox_glue"
1557then
1558 case $ac_sys_system/$ac_sys_release in
1559 Darwin/*)
1560 enable_toolbox_glue="yes";;
1561 *)
1562 enable_toolbox_glue="no";;
1563 esac
1564fi
1565case "$enable_toolbox_glue" in
1566yes)
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001567 extra_machdep_objs="Python/mactoolboxglue.o"
Raymond Hettingerec6eb362004-11-05 07:02:59 +00001568 extra_undefs="-u _PyMac_Error"
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001569 AC_DEFINE(USE_TOOLBOX_OBJECT_GLUE, 1,
1570 [Define if you want to use MacPython modules on MacOSX in unix-Python.])
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001571 ;;
1572*)
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001573 extra_machdep_objs=""
Jack Jansen591cbed2001-08-15 13:55:15 +00001574 extra_undefs=""
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001575 ;;
1576esac
1577AC_MSG_RESULT($enable_toolbox_glue)
1578
Ronald Oussoren0d236eb2008-06-06 21:31:33 +00001579
Bob Ippolito7026a0a2005-03-28 23:23:47 +00001580AC_SUBST(OTHER_LIBTOOL_OPT)
1581case $ac_sys_system/$ac_sys_release in
Anthony Baxter82201742006-04-09 15:07:40 +00001582 Darwin/@<:@01567@:>@\..*)
Bob Ippolito7026a0a2005-03-28 23:23:47 +00001583 OTHER_LIBTOOL_OPT="-prebind -seg1addr 0x10000000"
1584 ;;
1585 Darwin/*)
1586 OTHER_LIBTOOL_OPT=""
1587 ;;
1588esac
1589
Ronald Oussoren25967582009-09-06 10:00:26 +00001590
1591ARCH_RUN_32BIT=""
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001592AC_SUBST(LIBTOOL_CRUFT)
1593case $ac_sys_system/$ac_sys_release in
Anthony Baxter82201742006-04-09 15:07:40 +00001594 Darwin/@<:@01567@:>@\..*)
Ronald Oussoren988117f2006-04-29 11:31:35 +00001595 LIBTOOL_CRUFT="-framework System -lcc_dynamic"
1596 if test "${enable_universalsdk}"; then
1597 :
1598 else
Ronald Oussorenbc0e83c2010-02-11 13:26:54 +00001599 LIBTOOL_CRUFT="${LIBTOOL_CRUFT} -arch_only `/usr/bin/arch`"
Ronald Oussoren988117f2006-04-29 11:31:35 +00001600 fi
Jack Jansenb36687a2004-07-16 08:43:47 +00001601 LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -install_name $(PYTHONFRAMEWORKINSTALLDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansena3891ea2001-09-07 14:25:12 +00001602 LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -compatibility_version $(VERSION) -current_version $(VERSION)';;
Guido van Rossum5839e582000-10-09 19:52:35 +00001603 Darwin/*)
Ronald Oussorena55af9a2010-01-17 16:25:57 +00001604 gcc_version=`gcc -dumpversion`
Bob Ippolito7026a0a2005-03-28 23:23:47 +00001605 if test ${gcc_version} '<' 4.0
1606 then
1607 LIBTOOL_CRUFT="-lcc_dynamic"
1608 else
1609 LIBTOOL_CRUFT=""
1610 fi
Ronald Oussoren23d92532009-09-07 06:12:00 +00001611 AC_TRY_RUN([
Ronald Oussoren25967582009-09-06 10:00:26 +00001612 #include <unistd.h>
1613 int main(int argc, char*argv[])
1614 {
1615 if (sizeof(long) == 4) {
1616 return 0;
1617 } else {
1618 return 1;
1619 }
Ronald Oussoren84ddd722009-09-08 07:17:10 +00001620 }
Ronald Oussoren23d92532009-09-07 06:12:00 +00001621 ], ac_osx_32bit=yes,
Ronald Oussoren25967582009-09-06 10:00:26 +00001622 ac_osx_32bit=no,
Ronald Oussoren23d92532009-09-07 06:12:00 +00001623 ac_osx_32bit=yes)
Ronald Oussoren25967582009-09-06 10:00:26 +00001624
1625 if test "${ac_osx_32bit}" = "yes"; then
Ronald Oussorenbc0e83c2010-02-11 13:26:54 +00001626 case `/usr/bin/arch` in
Ronald Oussoren25967582009-09-06 10:00:26 +00001627 i386)
1628 MACOSX_DEFAULT_ARCH="i386"
1629 ;;
1630 ppc)
1631 MACOSX_DEFAULT_ARCH="ppc"
1632 ;;
1633 *)
1634 AC_MSG_ERROR([Unexpected output of 'arch' on OSX])
1635 ;;
1636 esac
1637 else
Ronald Oussorenbc0e83c2010-02-11 13:26:54 +00001638 case `/usr/bin/arch` in
Ronald Oussoren25967582009-09-06 10:00:26 +00001639 i386)
1640 MACOSX_DEFAULT_ARCH="x86_64"
1641 ;;
1642 ppc)
1643 MACOSX_DEFAULT_ARCH="ppc64"
1644 ;;
1645 *)
1646 AC_MSG_ERROR([Unexpected output of 'arch' on OSX])
1647 ;;
1648 esac
1649
1650 #ARCH_RUN_32BIT="true"
1651 fi
1652
1653 LIBTOOL_CRUFT=$LIBTOOL_CRUFT" -lSystem -lSystemStubs -arch_only ${MACOSX_DEFAULT_ARCH}"
Jack Jansenb36687a2004-07-16 08:43:47 +00001654 LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -install_name $(PYTHONFRAMEWORKINSTALLDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001655 LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -compatibility_version $(VERSION) -current_version $(VERSION)';;
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001656esac
1657
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001658AC_MSG_CHECKING(for --enable-framework)
1659if test "$enable_framework"
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001660then
Skip Montanarodecc6a42003-01-01 20:07:49 +00001661 BASECFLAGS="$BASECFLAGS -fno-common -dynamic"
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001662 # -F. is needed to allow linking to the framework while
1663 # in the build location.
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001664 AC_DEFINE(WITH_NEXT_FRAMEWORK, 1,
1665 [Define if you want to produce an OpenStep/Rhapsody framework
1666 (shared library plus accessory files).])
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001667 AC_MSG_RESULT(yes)
Ronald Oussoren450d5612009-06-08 21:12:41 +00001668 if test $enable_shared = "yes"
1669 then
Ronald Oussoren9ebd2422009-09-29 13:00:44 +00001670 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 +00001671 fi
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001672else
1673 AC_MSG_RESULT(no)
1674fi
1675
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001676AC_MSG_CHECKING(for dyld)
Jack Jansen9a66b6d2001-08-08 13:56:14 +00001677case $ac_sys_system/$ac_sys_release in
1678 Darwin/*)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001679 AC_DEFINE(WITH_DYLD, 1,
1680 [Define if you want to use the new-style (Openstep, Rhapsody, MacOS)
1681 dynamic linker (dyld) instead of the old-style (NextStep) dynamic
1682 linker (rld). Dyld is necessary to support frameworks.])
Jack Jansen9a66b6d2001-08-08 13:56:14 +00001683 AC_MSG_RESULT(always on for Darwin)
1684 ;;
1685 *)
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001686 AC_MSG_RESULT(no)
1687 ;;
Jack Jansen9a66b6d2001-08-08 13:56:14 +00001688esac
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001689
Guido van Rossumac405f61994-09-12 10:56:06 +00001690# Set info about shared libraries.
Guido van Rossumac405f61994-09-12 10:56:06 +00001691AC_SUBST(SO)
1692AC_SUBST(LDSHARED)
Tarek Ziadé00002952010-04-03 08:37:59 +00001693AC_SUBST(LDCXXSHARED)
Neil Schemenauerb3531b82001-02-16 04:09:05 +00001694AC_SUBST(BLDSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00001695AC_SUBST(CCSHARED)
1696AC_SUBST(LINKFORSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00001697# SO is the extension of shared libraries `(including the dot!)
Guido van Rossumaef734b2001-01-10 21:09:12 +00001698# -- usually .so, .sl on HP-UX, .dll on Cygwin
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001699AC_MSG_CHECKING(SO)
Guido van Rossumac405f61994-09-12 10:56:06 +00001700if test -z "$SO"
1701then
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001702 case $ac_sys_system in
Neal Norwitz58e28882006-05-19 07:00:58 +00001703 hp*|HP*)
1704 case `uname -m` in
1705 ia64) SO=.so;;
1706 *) SO=.sl;;
1707 esac
1708 ;;
Guido van Rossumaef734b2001-01-10 21:09:12 +00001709 CYGWIN*) SO=.dll;;
Guido van Rossum4b6b5791996-09-09 20:09:34 +00001710 *) SO=.so;;
Guido van Rossumac405f61994-09-12 10:56:06 +00001711 esac
Martin v. Löwis368de8f2003-06-14 14:46:38 +00001712else
1713 # this might also be a termcap variable, see #610332
1714 echo
1715 echo '====================================================================='
1716 echo '+ +'
1717 echo '+ WARNING: You have set SO in your environment. +'
1718 echo '+ Do you really mean to change the extension for shared libraries? +'
1719 echo '+ Continuing in 10 seconds to let you to ponder. +'
1720 echo '+ +'
1721 echo '====================================================================='
1722 sleep 10
Guido van Rossumac405f61994-09-12 10:56:06 +00001723fi
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001724AC_MSG_RESULT($SO)
Ronald Oussoren79f90492009-01-02 10:44:46 +00001725
Neal Norwitz58e28882006-05-19 07:00:58 +00001726AC_DEFINE_UNQUOTED(SHLIB_EXT, "$SO", [Define this to be extension of shared libraries (including the dot!).])
Guido van Rossumac405f61994-09-12 10:56:06 +00001727# LDSHARED is the ld *command* used to create shared library
Skip Montanaroce59c042004-01-17 14:19:44 +00001728# -- "cc -G" on SunOS 5.x, "ld -shared" on IRIX 5
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001729# (Shared libraries in this instance are shared modules to be loaded into
1730# Python, as opposed to building Python itself as a shared library.)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001731AC_MSG_CHECKING(LDSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00001732if test -z "$LDSHARED"
1733then
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001734 case $ac_sys_system/$ac_sys_release in
Neil Schemenauerb3531b82001-02-16 04:09:05 +00001735 AIX*)
1736 BLDSHARED="\$(srcdir)/Modules/ld_so_aix \$(CC) -bI:Modules/python.exp"
Guido van Rossumce608b02001-09-28 15:59:38 +00001737 LDSHARED="\$(BINLIBDEST)/config/ld_so_aix \$(CC) -bI:\$(BINLIBDEST)/config/python.exp"
Neil Schemenauerb3531b82001-02-16 04:09:05 +00001738 ;;
1739 BeOS*)
1740 BLDSHARED="\$(srcdir)/Modules/ld_so_beos $LDLIBRARY"
Guido van Rossumce608b02001-09-28 15:59:38 +00001741 LDSHARED="\$(BINLIBDEST)/config/ld_so_beos \$(LIBDIR)/$LDLIBRARY"
Neil Schemenauerb3531b82001-02-16 04:09:05 +00001742 ;;
Guido van Rossum6100aaf1997-04-29 21:48:51 +00001743 IRIX/5*) LDSHARED="ld -shared";;
Guido van Rossum91922671997-10-09 20:24:13 +00001744 IRIX*/6*) LDSHARED="ld ${SGI_ABI} -shared -all";;
Greg Ward57c9a662000-05-26 12:22:54 +00001745 SunOS/5*)
Tarek Ziadé00002952010-04-03 08:37:59 +00001746 if test "$GCC" = "yes" ; then
1747 LDSHARED='$(CC) -shared'
1748 LDCXXSHARED='$(CXX) -shared'
1749 else
1750 LDSHARED='$(CC) -G'
1751 LDCXXSHARED='$(CXX) -G'
Greg Ward57c9a662000-05-26 12:22:54 +00001752 fi ;;
Thomas Hellerdc96a772008-04-04 10:07:55 +00001753 hp*|HP*)
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='ld -b'
Thomas Hellerdc96a772008-04-04 10:07:55 +00001759 fi ;;
Guido van Rossum71001e41995-01-26 00:44:03 +00001760 OSF*) LDSHARED="ld -shared -expect_unresolved \"*\"";;
Jack Jansen418c3b12001-11-14 10:59:57 +00001761 Darwin/1.3*)
Jack Jansena3891ea2001-09-07 14:25:12 +00001762 LDSHARED='$(CC) $(LDFLAGS) -bundle'
Tarek Ziadé00002952010-04-03 08:37:59 +00001763 LDCXXSHARED='$(CXX) $(LDFLAGS) -bundle'
Jack Jansena3891ea2001-09-07 14:25:12 +00001764 if test "$enable_framework" ; then
1765 # Link against the framework. All externals should be defined.
Jack Jansenda49e192005-01-07 13:08:22 +00001766 BLDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
1767 LDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Tarek Ziadé00002952010-04-03 08:37:59 +00001768 LDCXXSHARED="$LDCXXSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansena3891ea2001-09-07 14:25:12 +00001769 else
1770 # No framework. Ignore undefined symbols, assuming they come from Python
Jack Jansen418c3b12001-11-14 10:59:57 +00001771 LDSHARED="$LDSHARED -undefined suppress"
Tarek Ziadé00002952010-04-03 08:37:59 +00001772 LDCXXSHARED="$LDCXXSHARED -undefined suppress"
Jack Jansena3891ea2001-09-07 14:25:12 +00001773 fi ;;
Jack Jansen6b08a402004-06-03 12:41:45 +00001774 Darwin/1.4*|Darwin/5.*|Darwin/6.*)
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001775 LDSHARED='$(CC) $(LDFLAGS) -bundle'
Tarek Ziadé00002952010-04-03 08:37:59 +00001776 LDCXXSHARED='$(CXX) $(LDFLAGS) -bundle'
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001777 if test "$enable_framework" ; then
1778 # Link against the framework. All externals should be defined.
Jack Jansenda49e192005-01-07 13:08:22 +00001779 BLDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
1780 LDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Tarek Ziadé00002952010-04-03 08:37:59 +00001781 LDCXXSHARED="$LDCXXSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001782 else
Michael W. Hudson0c46c0c2002-03-07 09:58:56 +00001783 # No framework, use the Python app as bundle-loader
1784 BLDSHARED="$LDSHARED "'-bundle_loader $(BUILDPYTHON)'
Jack Jansenc28fc372003-02-25 13:14:43 +00001785 LDSHARED="$LDSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)'
Tarek Ziadé00002952010-04-03 08:37:59 +00001786 LDCXXSHARED="$LDCXXSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)'
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001787 fi ;;
Jack Jansen6b08a402004-06-03 12:41:45 +00001788 Darwin/*)
1789 # Use -undefined dynamic_lookup whenever possible (10.3 and later).
1790 # This allows an extension to be used in any Python
Ronald Oussoren38f1b982007-09-02 09:46:07 +00001791
Ronald Oussoren5640ce22008-06-05 12:58:24 +00001792 if test ${MACOSX_DEPLOYMENT_TARGET} '>' 10.2
Jack Jansen6b08a402004-06-03 12:41:45 +00001793 then
Ronald Oussoren988117f2006-04-29 11:31:35 +00001794 if test "${enable_universalsdk}"; then
Ronald Oussoren5640ce22008-06-05 12:58:24 +00001795 LDFLAGS="${UNIVERSAL_ARCH_FLAGS} -isysroot ${UNIVERSALSDK} ${LDFLAGS}"
Ronald Oussoren988117f2006-04-29 11:31:35 +00001796 fi
Jack Jansen6b08a402004-06-03 12:41:45 +00001797 LDSHARED='$(CC) $(LDFLAGS) -bundle -undefined dynamic_lookup'
Tarek Ziadé00002952010-04-03 08:37:59 +00001798 LDCXXSHARED='$(CXX) $(LDFLAGS) -bundle -undefined dynamic_lookup'
Jack Jansen6b08a402004-06-03 12:41:45 +00001799 BLDSHARED="$LDSHARED"
Jack Jansen6b08a402004-06-03 12:41:45 +00001800 else
1801 LDSHARED='$(CC) $(LDFLAGS) -bundle'
Tarek Ziadé00002952010-04-03 08:37:59 +00001802 LDCXXSHARED='$(CXX) $(LDFLAGS) -bundle'
Jack Jansen6b08a402004-06-03 12:41:45 +00001803 if test "$enable_framework" ; then
1804 # Link against the framework. All externals should be defined.
Jack Jansenda49e192005-01-07 13:08:22 +00001805 BLDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
1806 LDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Tarek Ziadé00002952010-04-03 08:37:59 +00001807 LDCXXSHARED="$LDCXXSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansen6b08a402004-06-03 12:41:45 +00001808 else
1809 # No framework, use the Python app as bundle-loader
1810 BLDSHARED="$LDSHARED "'-bundle_loader $(BUILDPYTHON)'
1811 LDSHARED="$LDSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)'
Tarek Ziadé00002952010-04-03 08:37:59 +00001812 LDCXXSHARED="$LDCXXSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)'
Jack Jansen6b08a402004-06-03 12:41:45 +00001813 fi
1814 fi
1815 ;;
Tarek Ziadé00002952010-04-03 08:37:59 +00001816 Linux*|GNU*|QNX*)
1817 LDSHARED='$(CC) -shared'
1818 LDCXXSHARED='$(CXX) -shared';;
1819 BSD/OS*/4*)
1820 LDSHARED="gcc -shared"
1821 LDCXXSHARED="g++ -shared";;
Martin v. Löwis222c5152006-06-03 07:37:13 +00001822 FreeBSD*)
Jeremy Hylton4bcc7c52000-08-31 17:45:35 +00001823 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
Guido van Rossum0286ae82000-08-29 15:06:49 +00001824 then
Benjamin Peterson3b2abe92010-03-14 15:06:14 +00001825 LDSHARED='$(CC) -shared ${LDFLAGS}'
Tarek Ziadé00002952010-04-03 08:37:59 +00001826 LDCXXSHARED='$(CXX) -shared ${LDFLAGS}'
Guido van Rossum0286ae82000-08-29 15:06:49 +00001827 else
1828 LDSHARED="ld -Bshareable ${LDFLAGS}"
1829 fi;;
Martin v. Löwis222c5152006-06-03 07:37:13 +00001830 OpenBSD*)
1831 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
1832 then
1833 LDSHARED='$(CC) -shared $(CCSHARED) ${LDFLAGS}'
Tarek Ziadé00002952010-04-03 08:37:59 +00001834 LDCXXSHARED='$(CXX) -shared $(CCSHARED) ${LDFLAGS}'
Martin v. Löwis222c5152006-06-03 07:37:13 +00001835 else
1836 case `uname -r` in
1837 [[01]].* | 2.[[0-7]] | 2.[[0-7]].*)
1838 LDSHARED="ld -Bshareable ${LDFLAGS}"
1839 ;;
1840 *)
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 ;;
1844 esac
1845 fi;;
Tarek Ziadé00002952010-04-03 08:37:59 +00001846 NetBSD*|DragonFly*)
1847 LDSHARED="cc -shared ${LDFLAGS}"
1848 LDCXXSHARED="c++ -shared ${LDFLAGS}";;
Martin v. Löwis25ae43b2001-10-07 08:39:18 +00001849 OpenUNIX*|UnixWare*)
Tarek Ziadé00002952010-04-03 08:37:59 +00001850 if test "$GCC" = "yes" ; then
1851 LDSHARED='$(CC) -shared'
1852 LDCXXSHARED='$(CXX) -shared'
1853 else
1854 LDSHARED='$(CC) -G'
1855 LDCXXSHARED='$(CXX) -G'
Martin v. Löwisbec19582001-03-21 15:57:54 +00001856 fi;;
Tarek Ziadé00002952010-04-03 08:37:59 +00001857 SCO_SV*)
1858 LDSHARED='$(CC) -Wl,-G,-Bexport'
1859 LDCXXSHARED='$(CXX) -Wl,-G,-Bexport';;
1860 CYGWIN*)
1861 LDSHARED="gcc -shared -Wl,--enable-auto-image-base"
1862 LDCXXSHARED="g++ -shared -Wl,--enable-auto-image-base";;
1863 atheos*)
1864 LDSHARED="gcc -shared"
1865 LDCXXSHARED="g++ -shared";;
Guido van Rossumac405f61994-09-12 10:56:06 +00001866 *) LDSHARED="ld";;
1867 esac
Guido van Rossumac405f61994-09-12 10:56:06 +00001868fi
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001869AC_MSG_RESULT($LDSHARED)
Tarek Ziadé00002952010-04-03 08:37:59 +00001870LDCXXSHARED=${LDCXXSHARED-$LDSHARED}
Neil Schemenauerb3531b82001-02-16 04:09:05 +00001871BLDSHARED=${BLDSHARED-$LDSHARED}
Guido van Rossumac405f61994-09-12 10:56:06 +00001872# CCSHARED are the C *flags* used to create objects to go into a shared
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001873# library (module) -- this is only needed for a few systems
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001874AC_MSG_CHECKING(CCSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00001875if test -z "$CCSHARED"
1876then
Guido van Rossum6100aaf1997-04-29 21:48:51 +00001877 case $ac_sys_system/$ac_sys_release in
Neil Schemenauer66252162001-02-19 04:47:42 +00001878 SunOS*) if test "$GCC" = yes;
Martin v. Löwiseb623572007-03-12 10:50:39 +00001879 then CCSHARED="-fPIC";
1880 elif test `uname -p` = sparc;
1881 then CCSHARED="-xcode=pic32";
1882 else CCSHARED="-Kpic";
1883 fi;;
Guido van Rossumaf07a441995-02-13 19:45:27 +00001884 hp*|HP*) if test "$GCC" = yes;
Martin v. Löwis703ad702001-09-05 08:36:52 +00001885 then CCSHARED="-fPIC";
Guido van Rossumaf07a441995-02-13 19:45:27 +00001886 else CCSHARED="+z";
1887 fi;;
Martin v. Löwisa6e97582002-01-01 18:41:33 +00001888 Linux*|GNU*) CCSHARED="-fPIC";;
Guido van Rossumf5957ea1999-10-05 21:59:33 +00001889 BSD/OS*/4*) CCSHARED="-fpic";;
Martin v. Löwis86d66262006-02-17 08:40:11 +00001890 FreeBSD*|NetBSD*|OpenBSD*|DragonFly*) CCSHARED="-fPIC";;
Martin v. Löwis25ae43b2001-10-07 08:39:18 +00001891 OpenUNIX*|UnixWare*)
Martin v. Löwisbec19582001-03-21 15:57:54 +00001892 if test "$GCC" = "yes"
1893 then CCSHARED="-fPIC"
Martin v. Löwis130fb172001-07-19 11:00:41 +00001894 else CCSHARED="-KPIC"
Martin v. Löwisbec19582001-03-21 15:57:54 +00001895 fi;;
Martin v. Löwis21ee4092002-09-30 16:19:48 +00001896 SCO_SV*)
1897 if test "$GCC" = "yes"
1898 then CCSHARED="-fPIC"
1899 else CCSHARED="-Kpic -belf"
1900 fi;;
Guido van Rossum2b5ca001998-03-05 15:41:09 +00001901 IRIX*/6*) case $CC in
1902 *gcc*) CCSHARED="-shared";;
Guido van Rossumee21f411998-04-20 18:51:54 +00001903 *) CCSHARED="";;
Guido van Rossum2b5ca001998-03-05 15:41:09 +00001904 esac;;
Martin v. Löwisf90ae202002-06-11 06:22:31 +00001905 atheos*) CCSHARED="-fPIC";;
Guido van Rossumac405f61994-09-12 10:56:06 +00001906 esac
Guido van Rossumac405f61994-09-12 10:56:06 +00001907fi
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001908AC_MSG_RESULT($CCSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00001909# LINKFORSHARED are the flags passed to the $(CC) command that links
Guido van Rossumb65a48e1995-06-14 18:21:23 +00001910# the python executable -- this is only needed for a few systems
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001911AC_MSG_CHECKING(LINKFORSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00001912if test -z "$LINKFORSHARED"
1913then
Guido van Rossum6100aaf1997-04-29 21:48:51 +00001914 case $ac_sys_system/$ac_sys_release in
Neil Schemenauerb3531b82001-02-16 04:09:05 +00001915 AIX*) LINKFORSHARED='-Wl,-bE:Modules/python.exp -lld';;
Guido van Rossum5dab3d81996-12-06 21:18:18 +00001916 hp*|HP*)
Martin v. Löwis1142de32002-03-29 16:28:31 +00001917 LINKFORSHARED="-Wl,-E -Wl,+s";;
1918# LINKFORSHARED="-Wl,-E -Wl,+s -Wl,+b\$(BINLIBDEST)/lib-dynload";;
Guido van Rossumf5957ea1999-10-05 21:59:33 +00001919 BSD/OS/4*) LINKFORSHARED="-Xlinker -export-dynamic";;
Martin v. Löwisa6e97582002-01-01 18:41:33 +00001920 Linux*|GNU*) LINKFORSHARED="-Xlinker -export-dynamic";;
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001921 # -u libsys_s pulls in all symbols in libsys
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001922 Darwin/*)
Raymond Hettingerec6eb362004-11-05 07:02:59 +00001923 # -u _PyMac_Error is needed to pull in the mac toolbox glue,
1924 # which is
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001925 # not used by the core itself but which needs to be in the core so
1926 # that dynamically loaded extension modules have access to it.
Jack Jansen97e3f002003-02-23 22:59:01 +00001927 # -prebind is no longer used, because it actually seems to give a
1928 # slowdown in stead of a speedup, maybe due to the large number of
1929 # dynamic loads Python does.
Raymond Hettingerec6eb362004-11-05 07:02:59 +00001930
1931 LINKFORSHARED="$extra_undefs"
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001932 if test "$enable_framework"
1933 then
Jack Jansenda49e192005-01-07 13:08:22 +00001934 LINKFORSHARED="$LINKFORSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001935 fi
Raymond Hettingerec6eb362004-11-05 07:02:59 +00001936 LINKFORSHARED="$LINKFORSHARED";;
Martin v. Löwis25ae43b2001-10-07 08:39:18 +00001937 OpenUNIX*|UnixWare*) LINKFORSHARED="-Wl,-Bexport";;
Martin v. Löwis21ee4092002-09-30 16:19:48 +00001938 SCO_SV*) LINKFORSHARED="-Wl,-Bexport";;
Fred Drake02706f52000-09-25 15:08:46 +00001939 ReliantUNIX*) LINKFORSHARED="-W1 -Blargedynsym";;
Martin v. Löwis86d66262006-02-17 08:40:11 +00001940 FreeBSD*|NetBSD*|OpenBSD*|DragonFly*)
Guido van Rossumdf693651999-01-07 21:50:41 +00001941 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
1942 then
1943 LINKFORSHARED="-Wl,--export-dynamic"
1944 fi;;
Guido van Rossum2b5ca001998-03-05 15:41:09 +00001945 SunOS/5*) case $CC in
1946 *gcc*)
Martin v. Löwisa4548572002-04-18 14:51:36 +00001947 if $CC -Xlinker --help 2>&1 | grep export-dynamic >/dev/null
Guido van Rossum8f4ceb11997-12-18 23:42:19 +00001948 then
1949 LINKFORSHARED="-Xlinker --export-dynamic"
Guido van Rossum2b5ca001998-03-05 15:41:09 +00001950 fi;;
1951 esac;;
Jason Tishler30765592003-09-04 11:04:06 +00001952 CYGWIN*)
1953 if test $enable_shared = "no"
1954 then
1955 LINKFORSHARED='-Wl,--out-implib=$(LDLIBRARY)'
1956 fi;;
Martin v. Löwis8c255e42008-05-23 15:06:50 +00001957 QNX*)
1958 # -Wl,-E causes the symbols to be added to the dynamic
1959 # symbol table so that they can be found when a module
1960 # is loaded. -N 2048K causes the stack size to be set
1961 # to 2048 kilobytes so that the stack doesn't overflow
1962 # when running test_compile.py.
1963 LINKFORSHARED='-Wl,-E -N 2048K';;
Guido van Rossumac405f61994-09-12 10:56:06 +00001964 esac
Guido van Rossumac405f61994-09-12 10:56:06 +00001965fi
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001966AC_MSG_RESULT($LINKFORSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00001967
Ronald Oussoren0d236eb2008-06-06 21:31:33 +00001968
Neil Schemenauer61c51152001-01-26 16:18:16 +00001969AC_SUBST(CFLAGSFORSHARED)
1970AC_MSG_CHECKING(CFLAGSFORSHARED)
1971if test ! "$LIBRARY" = "$LDLIBRARY"
1972then
Neil Schemenauerd9cf41c2001-01-27 21:39:17 +00001973 case $ac_sys_system in
1974 CYGWIN*)
1975 # Cygwin needs CCSHARED when building extension DLLs
1976 # but not when building the interpreter DLL.
1977 CFLAGSFORSHARED='';;
1978 *)
1979 CFLAGSFORSHARED='$(CCSHARED)'
1980 esac
Neil Schemenauer61c51152001-01-26 16:18:16 +00001981fi
1982AC_MSG_RESULT($CFLAGSFORSHARED)
1983
Martin v. Löwisf90ae202002-06-11 06:22:31 +00001984# SHLIBS are libraries (except -lc and -lm) to link to the python shared
1985# library (with --enable-shared).
1986# For platforms on which shared libraries are not allowed to have unresolved
Martin v. Löwisd6359c52002-08-04 12:38:50 +00001987# symbols, this must be set to $(LIBS) (expanded by make). We do this even
1988# if it is not required, since it creates a dependency of the shared library
1989# to LIBS. This, in turn, means that applications linking the shared libpython
1990# don't need to link LIBS explicitly. The default should be only changed
1991# on systems where this approach causes problems.
Martin v. Löwisf90ae202002-06-11 06:22:31 +00001992AC_SUBST(SHLIBS)
1993AC_MSG_CHECKING(SHLIBS)
1994case "$ac_sys_system" in
Martin v. Löwisf90ae202002-06-11 06:22:31 +00001995 *)
Martin v. Löwisd6359c52002-08-04 12:38:50 +00001996 SHLIBS='$(LIBS)';;
Martin v. Löwisf90ae202002-06-11 06:22:31 +00001997esac
1998AC_MSG_RESULT($SHLIBS)
1999
2000
Guido van Rossum627b2d71993-12-24 10:39:16 +00002001# checks for libraries
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002002AC_CHECK_LIB(dl, dlopen) # Dynamic linking for SunOS/Solaris and SYSV
2003AC_CHECK_LIB(dld, shl_load) # Dynamic linking for HP-UX
Martin v. Löwis519adae2003-09-20 10:47:47 +00002004
Skip Montanaro4d756af2008-12-01 01:55:22 +00002005# only check for sem_init if thread support is requested
Martin v. Löwis519adae2003-09-20 10:47:47 +00002006if test "$with_threads" = "yes" -o -z "$with_threads"; then
2007 AC_SEARCH_LIBS(sem_init, pthread rt posix4) # 'Real Time' functions on Solaris
2008 # posix4 on Solaris 2.6
2009 # pthread (first!) on Linux
2010fi
2011
Martin v. Löwis19d17342003-06-14 21:03:05 +00002012# check if we need libintl for locale functions
2013AC_CHECK_LIB(intl, textdomain,
2014 AC_DEFINE(WITH_LIBINTL, 1,
2015 [Define to 1 if libintl is needed for locale functions.]))
Guido van Rossum0eefa3f1999-11-16 15:57:37 +00002016
2017# checks for system dependent C++ extensions support
2018case "$ac_sys_system" in
2019 AIX*) AC_MSG_CHECKING(for genuine AIX C++ extensions support)
2020 AC_TRY_LINK([#include "/usr/lpp/xlC/include/load.h"],
2021 [loadAndInit("", 0, "")],
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002022 [AC_DEFINE(AIX_GENUINE_CPLUSPLUS, 1,
2023 [Define for AIX if your compiler is a genuine IBM xlC/xlC_r
2024 and you want support for AIX C++ shared extension modules.])
Guido van Rossum0eefa3f1999-11-16 15:57:37 +00002025 AC_MSG_RESULT(yes)],
2026 [AC_MSG_RESULT(no)]);;
2027 *) ;;
2028esac
2029
Guido van Rossum70c7f481998-03-26 18:44:10 +00002030# Most SVR4 platforms (e.g. Solaris) need -lsocket and -lnsl.
Guido van Rossumec95c7b1998-08-04 17:59:56 +00002031# BeOS' sockets are stashed in libnet.
Guido van Rossumf618d2c1995-01-17 16:36:13 +00002032AC_CHECK_LIB(nsl, t_open, [LIBS="-lnsl $LIBS"]) # SVR4
Guido van Rossumf618d2c1995-01-17 16:36:13 +00002033AC_CHECK_LIB(socket, socket, [LIBS="-lsocket $LIBS"], [], $LIBS) # SVR4 sockets
Skip Montanarob9949db2004-01-17 04:04:13 +00002034
Jeremy Hyltoncb25d5e2000-07-27 21:23:28 +00002035case "$ac_sys_system" in
2036BeOS*)
Guido van Rossumec95c7b1998-08-04 17:59:56 +00002037AC_CHECK_LIB(net, socket, [LIBS="-lnet $LIBS"], [], $LIBS) # BeOS
2038;;
2039esac
Guido van Rossum70c7f481998-03-26 18:44:10 +00002040
Guido van Rossumc5a39031996-07-31 17:35:03 +00002041AC_MSG_CHECKING(for --with-libs)
Barry Warsawc0d24d82000-06-29 16:12:00 +00002042AC_ARG_WITH(libs,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002043 AC_HELP_STRING(--with-libs='lib1 ...', link against additional libs),
2044[
Guido van Rossumc5a39031996-07-31 17:35:03 +00002045AC_MSG_RESULT($withval)
2046LIBS="$withval $LIBS"
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002047],
2048[AC_MSG_RESULT(no)])
Guido van Rossum627b2d71993-12-24 10:39:16 +00002049
Benjamin Petersone9e07bf2010-03-09 21:46:54 +00002050AC_PATH_TOOL([PKG_CONFIG], [pkg-config])
2051
Benjamin Peterson2c196742009-12-31 03:17:18 +00002052# Check for use of the system expat library
2053AC_MSG_CHECKING(for --with-system-expat)
2054AC_ARG_WITH(system_expat,
2055 AC_HELP_STRING(--with-system-expat, build pyexpat module using an installed expat library))
2056
2057AC_MSG_RESULT($with_system_expat)
2058
Martin v. Löwis9176fc12006-04-11 11:12:43 +00002059# Check for use of the system libffi library
2060AC_MSG_CHECKING(for --with-system-ffi)
2061AC_ARG_WITH(system_ffi,
2062 AC_HELP_STRING(--with-system-ffi, build _ctypes module using an installed ffi library))
2063
Benjamin Petersone9e07bf2010-03-09 21:46:54 +00002064if test "$with_system_ffi" = "yes" && test -n "$PKG_CONFIG"; then
Benjamin Peterson1c335e62010-01-01 15:16:29 +00002065 LIBFFI_INCLUDEDIR="`"$PKG_CONFIG" libffi --cflags-only-I 2>/dev/null | sed -e 's/^-I//;s/ *$//'`"
2066else
2067 LIBFFI_INCLUDEDIR=""
2068fi
2069AC_SUBST(LIBFFI_INCLUDEDIR)
2070
Martin v. Löwis9176fc12006-04-11 11:12:43 +00002071AC_MSG_RESULT($with_system_ffi)
2072
Matthias Klose10cbe482009-04-29 17:18:19 +00002073# Check for --with-dbmliborder
2074AC_MSG_CHECKING(for --with-dbmliborder)
2075AC_ARG_WITH(dbmliborder,
Matthias Klose51c614e2009-04-29 19:52:49 +00002076 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 +00002077[
2078if test x$with_dbmliborder = xyes
2079then
2080AC_MSG_ERROR([proper usage is --with-dbmliborder=db1:db2:...])
2081else
2082 for db in `echo $with_dbmliborder | sed 's/:/ /g'`; do
2083 if test x$db != xndbm && test x$db != xgdbm && test x$db != xbdb
2084 then
2085 AC_MSG_ERROR([proper usage is --with-dbmliborder=db1:db2:...])
2086 fi
2087 done
Matthias Klose61dbdb92009-04-29 20:09:50 +00002088fi])
2089AC_MSG_RESULT($with_dbmliborder)
Matthias Klose10cbe482009-04-29 17:18:19 +00002090
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00002091# Determine if signalmodule should be used.
2092AC_SUBST(USE_SIGNAL_MODULE)
2093AC_SUBST(SIGNAL_OBJS)
2094AC_MSG_CHECKING(for --with-signal-module)
2095AC_ARG_WITH(signal-module,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002096 AC_HELP_STRING(--with-signal-module, disable/enable signal module))
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00002097
2098if test -z "$with_signal_module"
2099then with_signal_module="yes"
2100fi
2101AC_MSG_RESULT($with_signal_module)
2102
2103if test "${with_signal_module}" = "yes"; then
2104 USE_SIGNAL_MODULE=""
2105 SIGNAL_OBJS=""
2106else
2107 USE_SIGNAL_MODULE="#"
2108 SIGNAL_OBJS="Parser/intrcheck.o Python/sigcheck.o"
2109fi
2110
Guido van Rossum3d15bd82001-01-10 18:53:48 +00002111# This is used to generate Setup.config
Guido van Rossum009f7871997-12-04 00:51:42 +00002112AC_SUBST(USE_THREAD_MODULE)
Barry Warsawc0d24d82000-06-29 16:12:00 +00002113USE_THREAD_MODULE=""
Guido van Rossum009f7871997-12-04 00:51:42 +00002114
Guido van Rossum54d93d41997-01-22 20:51:58 +00002115AC_MSG_CHECKING(for --with-dec-threads)
2116AC_SUBST(LDLAST)
2117AC_ARG_WITH(dec-threads,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002118 AC_HELP_STRING(--with-dec-threads, use DEC Alpha/OSF1 thread-safe libraries),
2119[
Barry Warsawc0d24d82000-06-29 16:12:00 +00002120AC_MSG_RESULT($withval)
Guido van Rossum54d93d41997-01-22 20:51:58 +00002121LDLAST=-threads
Guido van Rossumf78abae1997-01-21 22:02:36 +00002122if test "${with_thread+set}" != set; then
Guido van Rossum54d93d41997-01-22 20:51:58 +00002123 with_thread="$withval";
2124fi],
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002125[AC_MSG_RESULT(no)])
Guido van Rossum54d93d41997-01-22 20:51:58 +00002126
Martin v. Löwis11437992002-04-12 09:54:03 +00002127# Templates for things AC_DEFINEd more than once.
2128# For a single AC_DEFINE, no template is needed.
2129AH_TEMPLATE(C_THREADS,[Define if you have the Mach cthreads package])
2130AH_TEMPLATE(_REENTRANT,
2131 [Define to force use of thread-safe errno, h_errno, and other functions])
2132AH_TEMPLATE(WITH_THREAD,
2133 [Define if you want to compile in rudimentary thread support])
2134
Guido van Rossum54d93d41997-01-22 20:51:58 +00002135AC_MSG_CHECKING(for --with-threads)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002136dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
Barry Warsawc0d24d82000-06-29 16:12:00 +00002137AC_ARG_WITH(threads,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002138 AC_HELP_STRING(--with(out)-threads@<:@=DIRECTORY@:>@, disable/enable thread support))
Guido van Rossum54d93d41997-01-22 20:51:58 +00002139
Barry Warsawc0d24d82000-06-29 16:12:00 +00002140# --with-thread is deprecated, but check for it anyway
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002141dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
Barry Warsawa0f3c5c2000-06-30 16:39:35 +00002142AC_ARG_WITH(thread,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002143 AC_HELP_STRING(--with(out)-thread@<:@=DIRECTORY@:>@, deprecated; use --with(out)-threads),
2144 [with_threads=$with_thread])
Barry Warsawc0d24d82000-06-29 16:12:00 +00002145
2146if test -z "$with_threads"
2147then with_threads="yes"
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002148fi
Barry Warsawc0d24d82000-06-29 16:12:00 +00002149AC_MSG_RESULT($with_threads)
Guido van Rossum6400c261997-05-22 20:34:27 +00002150
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002151AC_SUBST(THREADOBJ)
Barry Warsawc0d24d82000-06-29 16:12:00 +00002152if test "$with_threads" = "no"
2153then
2154 USE_THREAD_MODULE="#"
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002155elif test "$ac_cv_pthread_is_default" = yes
2156then
2157 AC_DEFINE(WITH_THREAD)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002158 # Defining _REENTRANT on system with POSIX threads should not hurt.
2159 AC_DEFINE(_REENTRANT)
2160 posix_threads=yes
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002161 THREADOBJ="Python/thread.o"
Martin v. Löwis130fb172001-07-19 11:00:41 +00002162elif test "$ac_cv_kpthread" = "yes"
2163then
2164 CC="$CC -Kpthread"
Martin v. Löwis519adae2003-09-20 10:47:47 +00002165 if test "$ac_cv_cxx_thread" = "yes"; then
2166 CXX="$CXX -Kpthread"
2167 fi
Martin v. Löwis130fb172001-07-19 11:00:41 +00002168 AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002169 posix_threads=yes
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002170 THREADOBJ="Python/thread.o"
Martin v. Löwis5f433f02003-05-05 05:05:30 +00002171elif test "$ac_cv_kthread" = "yes"
2172then
2173 CC="$CC -Kthread"
Martin v. Löwis519adae2003-09-20 10:47:47 +00002174 if test "$ac_cv_cxx_thread" = "yes"; then
2175 CXX="$CXX -Kthread"
2176 fi
Martin v. Löwis5f433f02003-05-05 05:05:30 +00002177 AC_DEFINE(WITH_THREAD)
2178 posix_threads=yes
2179 THREADOBJ="Python/thread.o"
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002180elif test "$ac_cv_pthread" = "yes"
2181then
2182 CC="$CC -pthread"
Martin v. Löwis519adae2003-09-20 10:47:47 +00002183 if test "$ac_cv_cxx_thread" = "yes"; then
2184 CXX="$CXX -pthread"
2185 fi
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002186 AC_DEFINE(WITH_THREAD)
2187 posix_threads=yes
2188 THREADOBJ="Python/thread.o"
Barry Warsawc0d24d82000-06-29 16:12:00 +00002189else
Martin v. Löwis130fb172001-07-19 11:00:41 +00002190 if test ! -z "$with_threads" -a -d "$with_threads"
2191 then LDFLAGS="$LDFLAGS -L$with_threads"
2192 fi
2193 if test ! -z "$withval" -a -d "$withval"
2194 then LDFLAGS="$LDFLAGS -L$withval"
2195 fi
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002196
2197 # According to the POSIX spec, a pthreads implementation must
Matthias Klosea2542be2004-08-16 11:35:51 +00002198 # define _POSIX_THREADS in unistd.h. Some apparently don't
2199 # (e.g. gnu pth with pthread emulation)
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002200 AC_MSG_CHECKING(for _POSIX_THREADS in unistd.h)
2201 AC_EGREP_CPP(yes,
Neal Norwitz6eb37f02003-02-23 23:28:15 +00002202 [
2203#include <unistd.h>
2204#ifdef _POSIX_THREADS
2205yes
2206#endif
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002207 ], unistd_defines_pthreads=yes, unistd_defines_pthreads=no)
2208 AC_MSG_RESULT($unistd_defines_pthreads)
2209
Martin v. Löwis130fb172001-07-19 11:00:41 +00002210 AC_DEFINE(_REENTRANT)
Martin v. Löwisa6e97582002-01-01 18:41:33 +00002211 AC_CHECK_HEADER(cthreads.h, [AC_DEFINE(WITH_THREAD)
2212 AC_DEFINE(C_THREADS)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002213 AC_DEFINE(HURD_C_THREADS, 1,
2214 [Define if you are using Mach cthreads directly under /include])
Martin v. Löwisa6e97582002-01-01 18:41:33 +00002215 LIBS="$LIBS -lthreads"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002216 THREADOBJ="Python/thread.o"],[
Martin v. Löwis130fb172001-07-19 11:00:41 +00002217 AC_CHECK_HEADER(mach/cthreads.h, [AC_DEFINE(WITH_THREAD)
2218 AC_DEFINE(C_THREADS)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002219 AC_DEFINE(MACH_C_THREADS, 1,
2220 [Define if you are using Mach cthreads under mach /])
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002221 THREADOBJ="Python/thread.o"],[
Martin v. Löwis130fb172001-07-19 11:00:41 +00002222 AC_MSG_CHECKING(for --with-pth)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002223 AC_ARG_WITH([pth],
2224 AC_HELP_STRING(--with-pth, use GNU pth threading libraries),
2225 [AC_MSG_RESULT($withval)
2226 AC_DEFINE([WITH_THREAD])
2227 AC_DEFINE([HAVE_PTH], 1,
2228 [Define if you have GNU PTH threads.])
2229 LIBS="-lpth $LIBS"
2230 THREADOBJ="Python/thread.o"],
2231 [AC_MSG_RESULT(no)
Martin v. Löwis8158b5a2001-10-08 13:17:28 +00002232
2233 # Just looking for pthread_create in libpthread is not enough:
2234 # on HP/UX, pthread.h renames pthread_create to a different symbol name.
2235 # So we really have to include pthread.h, and then link.
2236 _libs=$LIBS
2237 LIBS="$LIBS -lpthread"
2238 AC_MSG_CHECKING([for pthread_create in -lpthread])
2239 AC_TRY_LINK([#include <pthread.h>
2240
2241void * start_routine (void *arg) { exit (0); }], [
2242pthread_create (NULL, NULL, start_routine, NULL)], [
2243 AC_MSG_RESULT(yes)
2244 AC_DEFINE(WITH_THREAD)
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002245 posix_threads=yes
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002246 THREADOBJ="Python/thread.o"],[
Martin v. Löwis8158b5a2001-10-08 13:17:28 +00002247 LIBS=$_libs
Martin v. Löwis130fb172001-07-19 11:00:41 +00002248 AC_CHECK_FUNC(pthread_detach, [AC_DEFINE(WITH_THREAD)
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002249 posix_threads=yes
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002250 THREADOBJ="Python/thread.o"],[
Martin v. Löwisf90ae202002-06-11 06:22:31 +00002251 AC_CHECK_HEADER(atheos/threads.h, [AC_DEFINE(WITH_THREAD)
2252 AC_DEFINE(ATHEOS_THREADS, 1,
2253 [Define this if you have AtheOS threads.])
2254 THREADOBJ="Python/thread.o"],[
Martin v. Löwis130fb172001-07-19 11:00:41 +00002255 AC_CHECK_HEADER(kernel/OS.h, [AC_DEFINE(WITH_THREAD)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002256 AC_DEFINE(BEOS_THREADS, 1,
2257 [Define this if you have BeOS threads.])
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002258 THREADOBJ="Python/thread.o"],[
Martin v. Löwis130fb172001-07-19 11:00:41 +00002259 AC_CHECK_LIB(pthreads, pthread_create, [AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002260 posix_threads=yes
Martin v. Löwis130fb172001-07-19 11:00:41 +00002261 LIBS="$LIBS -lpthreads"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002262 THREADOBJ="Python/thread.o"], [
Martin v. Löwis130fb172001-07-19 11:00:41 +00002263 AC_CHECK_LIB(c_r, pthread_create, [AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002264 posix_threads=yes
Martin v. Löwis130fb172001-07-19 11:00:41 +00002265 LIBS="$LIBS -lc_r"
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(pthread, __pthread_create_system, [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 -lpthread"
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(cma, 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 -lcma"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002274 THREADOBJ="Python/thread.o"],[
Martin v. Löwis130fb172001-07-19 11:00:41 +00002275 USE_THREAD_MODULE="#"])
Skip Montanarof8712e52004-01-17 03:04:46 +00002276 ])])])])])])])])])])
Barry Warsawc0d24d82000-06-29 16:12:00 +00002277
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002278 AC_CHECK_LIB(mpc, usconfig, [AC_DEFINE(WITH_THREAD)
2279 LIBS="$LIBS -lmpc"
2280 THREADOBJ="Python/thread.o"
2281 USE_THREAD_MODULE=""])
2282
2283 if test "$posix_threads" != "yes"; then
2284 AC_CHECK_LIB(thread, thr_create, [AC_DEFINE(WITH_THREAD)
2285 LIBS="$LIBS -lthread"
2286 THREADOBJ="Python/thread.o"
2287 USE_THREAD_MODULE=""])
2288 fi
2289
2290 if test "$USE_THREAD_MODULE" != "#"
2291 then
2292 # If the above checks didn't disable threads, (at least) OSF1
2293 # needs this '-threads' argument during linking.
2294 case $ac_sys_system in
2295 OSF1) LDLAST=-threads;;
2296 esac
2297 fi
2298fi
2299
2300if test "$posix_threads" = "yes"; then
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002301 if test "$unistd_defines_pthreads" = "no"; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002302 AC_DEFINE(_POSIX_THREADS, 1,
2303 [Define if you have POSIX threads,
2304 and your system does not define that.])
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002305 fi
2306
Martin v. Löwisdfc33fd2003-01-21 10:14:41 +00002307 # Bug 662787: Using semaphores causes unexplicable hangs on Solaris 8.
2308 case $ac_sys_system/$ac_sys_release in
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002309 SunOS/5.6) AC_DEFINE(HAVE_PTHREAD_DESTRUCTOR, 1,
2310 Defined for Solaris 2.6 bug in pthread header.)
2311 ;;
Martin v. Löwisdfc33fd2003-01-21 10:14:41 +00002312 SunOS/5.8) AC_DEFINE(HAVE_BROKEN_POSIX_SEMAPHORES, 1,
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002313 Define if the Posix semaphores do not work on your system)
2314 ;;
Christian Heimescba36bb2008-01-30 22:54:18 +00002315 AIX/5) AC_DEFINE(HAVE_BROKEN_POSIX_SEMAPHORES, 1,
2316 Define if the Posix semaphores do not work on your system)
2317 ;;
Martin v. Löwisdfc33fd2003-01-21 10:14:41 +00002318 esac
2319
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002320 AC_MSG_CHECKING(if PTHREAD_SCOPE_SYSTEM is supported)
2321 AC_CACHE_VAL(ac_cv_pthread_system_supported,
2322 [AC_TRY_RUN([#include <pthread.h>
2323 void *foo(void *parm) {
2324 return NULL;
2325 }
2326 main() {
2327 pthread_attr_t attr;
Martin v. Löwisa82d3472002-02-24 16:05:05 +00002328 pthread_t id;
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002329 if (pthread_attr_init(&attr)) exit(-1);
2330 if (pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM)) exit(-1);
Martin v. Löwisa82d3472002-02-24 16:05:05 +00002331 if (pthread_create(&id, &attr, foo, NULL)) exit(-1);
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002332 exit(0);
Guido van Rossum3065c942001-09-17 04:03:14 +00002333 }],
2334 ac_cv_pthread_system_supported=yes,
2335 ac_cv_pthread_system_supported=no,
2336 ac_cv_pthread_system_supported=no)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002337 ])
2338 AC_MSG_RESULT($ac_cv_pthread_system_supported)
2339 if test "$ac_cv_pthread_system_supported" = "yes"; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002340 AC_DEFINE(PTHREAD_SYSTEM_SCHED_SUPPORTED, 1, [Defined if PTHREAD_SCOPE_SYSTEM supported.])
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002341 fi
Jason Tishlerfac083d2003-07-22 15:20:49 +00002342 AC_CHECK_FUNCS(pthread_sigmask,
2343 [case $ac_sys_system in
2344 CYGWIN*)
2345 AC_DEFINE(HAVE_BROKEN_PTHREAD_SIGMASK, 1,
2346 [Define if pthread_sigmask() does not work on your system.])
2347 ;;
2348 esac])
Barry Warsawc0d24d82000-06-29 16:12:00 +00002349fi
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002350
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002351
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002352# Check for enable-ipv6
Martin v. Löwis11437992002-04-12 09:54:03 +00002353AH_TEMPLATE(ENABLE_IPV6, [Define if --enable-ipv6 is specified])
Martin v. Löwisa5f8bb52001-09-05 08:22:34 +00002354AC_MSG_CHECKING([if --enable-ipv6 is specified])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002355AC_ARG_ENABLE(ipv6,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002356[ --enable-ipv6 Enable ipv6 (with ipv4) support
2357 --disable-ipv6 Disable ipv6 support],
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002358[ case "$enableval" in
2359 no)
2360 AC_MSG_RESULT(no)
2361 ipv6=no
2362 ;;
2363 *) AC_MSG_RESULT(yes)
2364 AC_DEFINE(ENABLE_IPV6)
2365 ipv6=yes
2366 ;;
2367 esac ],
2368
Martin v. Löwisa5f8bb52001-09-05 08:22:34 +00002369[
2370dnl the check does not work on cross compilation case...
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002371 AC_TRY_RUN([ /* AF_INET6 available check */
2372#include <sys/types.h>
2373#include <sys/socket.h>
2374main()
2375{
2376 if (socket(AF_INET6, SOCK_STREAM, 0) < 0)
2377 exit(1);
2378 else
2379 exit(0);
2380}
2381],
2382 AC_MSG_RESULT(yes)
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002383 ipv6=yes,
2384 AC_MSG_RESULT(no)
2385 ipv6=no,
2386 AC_MSG_RESULT(no)
2387 ipv6=no
Martin v. Löwisa5f8bb52001-09-05 08:22:34 +00002388)
2389
2390if test "$ipv6" = "yes"; then
2391 AC_MSG_CHECKING(if RFC2553 API is available)
2392 AC_TRY_COMPILE([#include <sys/types.h>
2393#include <netinet/in.h>],
2394 [struct sockaddr_in6 x;
2395x.sin6_scope_id;],
2396 AC_MSG_RESULT(yes)
2397 ipv6=yes,
2398 AC_MSG_RESULT(no, IPv6 disabled)
2399 ipv6=no)
2400fi
2401
2402if test "$ipv6" = "yes"; then
2403 AC_DEFINE(ENABLE_IPV6)
2404fi
2405])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002406
2407ipv6type=unknown
2408ipv6lib=none
2409ipv6trylibc=no
2410
2411if test "$ipv6" = "yes"; then
2412 AC_MSG_CHECKING([ipv6 stack type])
Guido van Rossumb8552162001-09-05 14:58:11 +00002413 for i in inria kame linux-glibc linux-inet6 solaris toshiba v6d zeta;
2414 do
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002415 case $i in
2416 inria)
2417 dnl http://www.kame.net/
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002418 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002419#include <netinet/in.h>
2420#ifdef IPV6_INRIA_VERSION
2421yes
2422#endif],
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002423 [ipv6type=$i])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002424 ;;
2425 kame)
2426 dnl http://www.kame.net/
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002427 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002428#include <netinet/in.h>
2429#ifdef __KAME__
2430yes
2431#endif],
2432 [ipv6type=$i;
2433 ipv6lib=inet6
2434 ipv6libdir=/usr/local/v6/lib
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002435 ipv6trylibc=yes])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002436 ;;
2437 linux-glibc)
2438 dnl http://www.v6.linux.or.jp/
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002439 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002440#include <features.h>
2441#if defined(__GLIBC__) && ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1) || (__GLIBC__ > 2))
2442yes
2443#endif],
2444 [ipv6type=$i;
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002445 ipv6trylibc=yes])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002446 ;;
2447 linux-inet6)
2448 dnl http://www.v6.linux.or.jp/
2449 if test -d /usr/inet6; then
2450 ipv6type=$i
2451 ipv6lib=inet6
2452 ipv6libdir=/usr/inet6/lib
Skip Montanarodecc6a42003-01-01 20:07:49 +00002453 BASECFLAGS="-I/usr/inet6/include $BASECFLAGS"
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002454 fi
2455 ;;
2456 solaris)
2457 if test -f /etc/netconfig; then
2458 if /usr/xpg4/bin/grep -q tcp6 /etc/netconfig; then
2459 ipv6type=$i
2460 ipv6trylibc=yes
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002461 fi
2462 fi
2463 ;;
2464 toshiba)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002465 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002466#include <sys/param.h>
2467#ifdef _TOSHIBA_INET6
2468yes
2469#endif],
2470 [ipv6type=$i;
2471 ipv6lib=inet6;
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002472 ipv6libdir=/usr/local/v6/lib])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002473 ;;
2474 v6d)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002475 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002476#include </usr/local/v6/include/sys/v6config.h>
2477#ifdef __V6D__
2478yes
2479#endif],
2480 [ipv6type=$i;
2481 ipv6lib=v6;
2482 ipv6libdir=/usr/local/v6/lib;
Skip Montanarodecc6a42003-01-01 20:07:49 +00002483 BASECFLAGS="-I/usr/local/v6/include $BASECFLAGS"])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002484 ;;
2485 zeta)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002486 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002487#include <sys/param.h>
2488#ifdef _ZETA_MINAMI_INET6
2489yes
2490#endif],
2491 [ipv6type=$i;
2492 ipv6lib=inet6;
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002493 ipv6libdir=/usr/local/v6/lib])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002494 ;;
2495 esac
2496 if test "$ipv6type" != "unknown"; then
2497 break
2498 fi
2499 done
2500 AC_MSG_RESULT($ipv6type)
2501fi
2502
2503if test "$ipv6" = "yes" -a "$ipv6lib" != "none"; then
2504 if test -d $ipv6libdir -a -f $ipv6libdir/lib$ipv6lib.a; then
2505 LIBS="-L$ipv6libdir -l$ipv6lib $LIBS"
2506 echo "using lib$ipv6lib"
2507 else
2508 if test $ipv6trylibc = "yes"; then
2509 echo "using libc"
2510 else
2511 echo 'Fatal: no $ipv6lib library found. cannot continue.'
2512 echo "You need to fetch lib$ipv6lib.a from appropriate"
2513 echo 'ipv6 kit and compile beforehand.'
2514 exit 1
2515 fi
2516 fi
2517fi
2518
Ronald Oussoren0d236eb2008-06-06 21:31:33 +00002519AC_MSG_CHECKING(for OSX 10.5 SDK or later)
2520AC_TRY_COMPILE([#include <Carbon/Carbon.h>], FSIORefNum fRef = 0,
2521 AC_DEFINE(HAVE_OSX105_SDK, 1, Define if compiling using MacOS X 10.5 SDK or later.)
2522 AC_MSG_RESULT(yes),
2523 AC_MSG_RESULT(no)
2524)
2525
Martin v. Löwisa3fb4f72002-06-09 13:33:54 +00002526# Check for --with-doc-strings
2527AC_MSG_CHECKING(for --with-doc-strings)
2528AC_ARG_WITH(doc-strings,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002529 AC_HELP_STRING(--with(out)-doc-strings, disable/enable documentation strings))
Martin v. Löwisa3fb4f72002-06-09 13:33:54 +00002530
2531if test -z "$with_doc_strings"
2532then with_doc_strings="yes"
2533fi
2534if test "$with_doc_strings" != "no"
2535then
2536 AC_DEFINE(WITH_DOC_STRINGS, 1,
2537 [Define if you want documentation strings in extension modules])
2538fi
2539AC_MSG_RESULT($with_doc_strings)
2540
Neil Schemenauera35c6882001-02-27 04:45:05 +00002541# Check for Python-specific malloc support
Martin v. Löwisf30d60e2004-06-08 08:17:44 +00002542AC_MSG_CHECKING(for --with-tsc)
2543AC_ARG_WITH(tsc,
2544[ --with(out)-tsc enable/disable timestamp counter profile], [
2545if test "$withval" != no
2546then
2547 AC_DEFINE(WITH_TSC, 1,
2548 [Define to profile with the Pentium timestamp counter])
2549 AC_MSG_RESULT(yes)
2550else AC_MSG_RESULT(no)
2551fi],
2552[AC_MSG_RESULT(no)])
2553
2554# Check for Python-specific malloc support
Neil Schemenauera35c6882001-02-27 04:45:05 +00002555AC_MSG_CHECKING(for --with-pymalloc)
2556AC_ARG_WITH(pymalloc,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002557 AC_HELP_STRING(--with(out)-pymalloc, disable/enable specialized mallocs))
Neil Schemenauer16c22972002-03-22 15:34:49 +00002558
2559if test -z "$with_pymalloc"
2560then with_pymalloc="yes"
2561fi
2562if test "$with_pymalloc" != "no"
2563then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002564 AC_DEFINE(WITH_PYMALLOC, 1,
2565 [Define if you want to compile in Python-specific mallocs])
Neil Schemenauer16c22972002-03-22 15:34:49 +00002566fi
2567AC_MSG_RESULT($with_pymalloc)
Neil Schemenauera35c6882001-02-27 04:45:05 +00002568
Benjamin Peterson91c12eb2009-12-03 02:52:39 +00002569# Check for Valgrind support
2570AC_MSG_CHECKING([for --with-valgrind])
2571AC_ARG_WITH([valgrind],
2572 AC_HELP_STRING([--with-valgrind], [Enable Valgrind support]),,
2573 with_valgrind=no)
2574AC_MSG_RESULT([$with_valgrind])
2575if test "$with_valgrind" != no; then
2576 AC_CHECK_HEADER([valgrind/valgrind.h],
2577 [AC_DEFINE([WITH_VALGRIND], 1, [Define if you want pymalloc to be disabled when running under valgrind])],
2578 [AC_MSG_ERROR([Valgrind support requested but headers not available])]
2579 )
2580fi
2581
Barry Warsawef82cd72000-06-30 16:21:01 +00002582# Check for --with-wctype-functions
2583AC_MSG_CHECKING(for --with-wctype-functions)
2584AC_ARG_WITH(wctype-functions,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002585 AC_HELP_STRING(--with-wctype-functions, use wctype.h functions),
2586[
Barry Warsawef82cd72000-06-30 16:21:01 +00002587if test "$withval" != no
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002588then
2589 AC_DEFINE(WANT_WCTYPE_FUNCTIONS, 1,
2590 [Define if you want wctype.h functions to be used instead of the
2591 one supplied by Python itself. (see Include/unicodectype.h).])
2592 AC_MSG_RESULT(yes)
Barry Warsawef82cd72000-06-30 16:21:01 +00002593else AC_MSG_RESULT(no)
2594fi],
2595[AC_MSG_RESULT(no)])
2596
Guido van Rossum68242b51996-05-28 22:53:03 +00002597# -I${DLINCLDIR} is added to the compile rule for importdl.o
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002598AC_SUBST(DLINCLDIR)
Guido van Rossum98935bf2001-09-05 19:13:16 +00002599DLINCLDIR=.
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002600
Guido van Rossume97ee181999-12-20 21:27:22 +00002601# the dlopen() function means we might want to use dynload_shlib.o. some
2602# platforms, such as AIX, have dlopen(), but don't want to use it.
Thomas Wouters3a584202000-08-05 23:28:51 +00002603AC_CHECK_FUNCS(dlopen)
Guido van Rossume97ee181999-12-20 21:27:22 +00002604
2605# DYNLOADFILE specifies which dynload_*.o file we will use for dynamic
2606# loading of modules.
2607AC_SUBST(DYNLOADFILE)
2608AC_MSG_CHECKING(DYNLOADFILE)
2609if test -z "$DYNLOADFILE"
2610then
2611 case $ac_sys_system/$ac_sys_release in
Martin v. Löwisc19c5a62003-11-18 20:00:44 +00002612 AIX*) # Use dynload_shlib.c and dlopen() if we have it; otherwise dynload_aix.c
2613 if test "$ac_cv_func_dlopen" = yes
2614 then DYNLOADFILE="dynload_shlib.o"
2615 else DYNLOADFILE="dynload_aix.o"
2616 fi
2617 ;;
Guido van Rossume97ee181999-12-20 21:27:22 +00002618 BeOS*) DYNLOADFILE="dynload_beos.o";;
2619 hp*|HP*) DYNLOADFILE="dynload_hpux.o";;
Anthony Baxter82201742006-04-09 15:07:40 +00002620 # Use dynload_next.c only on 10.2 and below, which don't have native dlopen()
2621 Darwin/@<:@0156@:>@\..*) DYNLOADFILE="dynload_next.o";;
Martin v. Löwisf90ae202002-06-11 06:22:31 +00002622 atheos*) DYNLOADFILE="dynload_atheos.o";;
Guido van Rossume97ee181999-12-20 21:27:22 +00002623 *)
2624 # use dynload_shlib.c and dlopen() if we have it; otherwise stub
2625 # out any dynamic loading
2626 if test "$ac_cv_func_dlopen" = yes
2627 then DYNLOADFILE="dynload_shlib.o"
2628 else DYNLOADFILE="dynload_stub.o"
2629 fi
2630 ;;
2631 esac
2632fi
2633AC_MSG_RESULT($DYNLOADFILE)
2634if test "$DYNLOADFILE" != "dynload_stub.o"
2635then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002636 AC_DEFINE(HAVE_DYNAMIC_LOADING, 1,
2637 [Defined when any dynamic module loading is enabled.])
Guido van Rossume97ee181999-12-20 21:27:22 +00002638fi
2639
Jack Jansenc49e5b72001-06-19 15:00:23 +00002640# MACHDEP_OBJS can be set to platform-specific object files needed by Python
2641
2642AC_SUBST(MACHDEP_OBJS)
2643AC_MSG_CHECKING(MACHDEP_OBJS)
2644if test -z "$MACHDEP_OBJS"
2645then
Jack Jansenb6e9cad2001-08-15 01:26:28 +00002646 MACHDEP_OBJS=$extra_machdep_objs
2647else
2648 MACHDEP_OBJS="$MACHDEP_OBJS $extra_machdep_objs"
Jack Jansenc49e5b72001-06-19 15:00:23 +00002649fi
Jack Jansenb6e9cad2001-08-15 01:26:28 +00002650AC_MSG_RESULT(MACHDEP_OBJS)
Jack Jansenc49e5b72001-06-19 15:00:23 +00002651
Guido van Rossum627b2d71993-12-24 10:39:16 +00002652# checks for library functions
Martin v. Löwisaef18b12008-03-24 13:31:16 +00002653AC_CHECK_FUNCS(alarm setitimer getitimer bind_textdomain_codeset chown \
2654 clock confstr ctermid execv fchmod fchown fork fpathconf ftime ftruncate \
Martin v. Löwis438b5342002-12-27 10:16:42 +00002655 gai_strerror getgroups getlogin getloadavg getpeername getpgid getpid \
Martin v. Löwis50ea4562009-11-27 13:56:01 +00002656 getpriority getresuid getresgid getpwent getspnam getspent getsid getwd \
Antoine Pitrou30b3b352009-12-02 20:37:54 +00002657 initgroups kill killpg lchmod lchown lstat mkfifo mknod mktime \
Martin v. Löwisa5f09072002-10-11 05:37:59 +00002658 mremap nice pathconf pause plock poll pthread_init \
Guido van Rossum162e38c2003-02-19 15:25:10 +00002659 putenv readlink realpath \
Jesse Noller355b1262009-04-02 00:03:28 +00002660 select sem_open sem_timedwait sem_getvalue sem_unlink setegid seteuid \
2661 setgid \
Martin v. Löwis4daacb12003-03-28 18:37:01 +00002662 setlocale setregid setreuid setsid setpgid setpgrp setuid setvbuf snprintf \
Martin v. Löwis50ea4562009-11-27 13:56:01 +00002663 setlocale setregid setreuid setresuid setresgid \
2664 setsid setpgid setpgrp setuid setvbuf snprintf \
Skip Montanaro7e11a012004-02-07 12:55:46 +00002665 sigaction siginterrupt sigrelse strftime \
Michael W. Hudson34f20ea2002-05-27 15:08:24 +00002666 sysconf tcgetpgrp tcsetpgrp tempnam timegm times tmpfile tmpnam tmpnam_r \
Neal Norwitz05a45592006-03-20 06:30:08 +00002667 truncate uname unsetenv utimes waitpid wait3 wait4 wcscoll _getpty)
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00002668
Martin v. Löwisc8ad7cc2002-11-11 13:23:45 +00002669# For some functions, having a definition is not sufficient, since
2670# we want to take their address.
2671AC_MSG_CHECKING(for chroot)
2672AC_TRY_COMPILE([#include <unistd.h>], void *x=chroot,
2673 AC_DEFINE(HAVE_CHROOT, 1, Define if you have the 'chroot' function.)
2674 AC_MSG_RESULT(yes),
2675 AC_MSG_RESULT(no)
2676)
2677AC_MSG_CHECKING(for link)
2678AC_TRY_COMPILE([#include <unistd.h>], void *x=link,
2679 AC_DEFINE(HAVE_LINK, 1, Define if you have the 'link' function.)
2680 AC_MSG_RESULT(yes),
2681 AC_MSG_RESULT(no)
2682)
2683AC_MSG_CHECKING(for symlink)
2684AC_TRY_COMPILE([#include <unistd.h>], void *x=symlink,
2685 AC_DEFINE(HAVE_SYMLINK, 1, Define if you have the 'symlink' function.)
2686 AC_MSG_RESULT(yes),
2687 AC_MSG_RESULT(no)
2688)
Martin v. Löwisa64988c2003-09-20 15:30:20 +00002689AC_MSG_CHECKING(for fchdir)
2690AC_TRY_COMPILE([#include <unistd.h>], void *x=fchdir,
2691 AC_DEFINE(HAVE_FCHDIR, 1, Define if you have the 'fchdir' function.)
2692 AC_MSG_RESULT(yes),
2693 AC_MSG_RESULT(no)
2694)
2695AC_MSG_CHECKING(for fsync)
2696AC_TRY_COMPILE([#include <unistd.h>], void *x=fsync,
Skip Montanarod4fa8072003-09-25 14:49:15 +00002697 AC_DEFINE(HAVE_FSYNC, 1, Define if you have the 'fsync' function.)
Martin v. Löwisa64988c2003-09-20 15:30:20 +00002698 AC_MSG_RESULT(yes),
2699 AC_MSG_RESULT(no)
2700)
2701AC_MSG_CHECKING(for fdatasync)
2702AC_TRY_COMPILE([#include <unistd.h>], void *x=fdatasync,
2703 AC_DEFINE(HAVE_FDATASYNC, 1, Define if you have the 'fdatasync' function.)
2704 AC_MSG_RESULT(yes),
2705 AC_MSG_RESULT(no)
2706)
Christian Heimes0e9ab5f2008-03-21 23:49:44 +00002707AC_MSG_CHECKING(for epoll)
2708AC_TRY_COMPILE([#include <sys/epoll.h>], void *x=epoll_create,
2709 AC_DEFINE(HAVE_EPOLL, 1, Define if you have the 'epoll' functions.)
2710 AC_MSG_RESULT(yes),
2711 AC_MSG_RESULT(no)
2712)
2713AC_MSG_CHECKING(for kqueue)
2714AC_TRY_COMPILE([
2715#include <sys/types.h>
2716#include <sys/event.h>
2717 ], int x=kqueue(),
2718 AC_DEFINE(HAVE_KQUEUE, 1, Define if you have the 'kqueue' functions.)
2719 AC_MSG_RESULT(yes),
2720 AC_MSG_RESULT(no)
2721)
Martin v. Löwisd5843682002-11-21 20:41:28 +00002722# On some systems (eg. FreeBSD 5), we would find a definition of the
2723# functions ctermid_r, setgroups in the library, but no prototype
2724# (e.g. because we use _XOPEN_SOURCE). See whether we can take their
2725# address to avoid compiler warnings and potential miscompilations
2726# because of the missing prototypes.
2727
2728AC_MSG_CHECKING(for ctermid_r)
2729AC_TRY_COMPILE([
2730#include "confdefs.h"
2731#include <stdio.h>
2732], void* p = ctermid_r,
2733 AC_DEFINE(HAVE_CTERMID_R, 1, Define if you have the 'ctermid_r' function.)
2734 AC_MSG_RESULT(yes),
2735 AC_MSG_RESULT(no)
2736)
2737
Martin v. Löwisf26d63b2003-03-30 17:23:49 +00002738AC_MSG_CHECKING(for flock)
2739AC_TRY_COMPILE([
2740#include "confdefs.h"
2741#include <sys/file.h>
2742], void* p = flock,
2743 AC_DEFINE(HAVE_FLOCK, 1, Define if you have the 'flock' function.)
2744 AC_MSG_RESULT(yes),
2745 AC_MSG_RESULT(no)
2746)
2747
2748AC_MSG_CHECKING(for getpagesize)
2749AC_TRY_COMPILE([
2750#include "confdefs.h"
2751#include <unistd.h>
2752], void* p = getpagesize,
2753 AC_DEFINE(HAVE_GETPAGESIZE, 1, Define if you have the 'getpagesize' function.)
2754 AC_MSG_RESULT(yes),
2755 AC_MSG_RESULT(no)
2756)
2757
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002758dnl check for true
2759AC_CHECK_PROGS(TRUE, true, /bin/true)
2760
Martin v. Löwis95c419b2003-05-03 12:10:48 +00002761dnl On some systems (e.g. Solaris 9), hstrerror and inet_aton are in -lresolv
2762dnl On others, they are in the C library, so we to take no action
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002763AC_CHECK_LIB(c, inet_aton, [$ac_cv_prog_TRUE],
Martin v. Löwis95c419b2003-05-03 12:10:48 +00002764 AC_CHECK_LIB(resolv, inet_aton)
2765)
2766
Martin v. Löwisa51d5c82007-12-04 08:37:59 +00002767# On Tru64, chflags seems to be present, but calling it will
2768# exit Python
Gregory P. Smithbb213892009-11-02 01:37:37 +00002769AC_CACHE_CHECK([for chflags], [ac_cv_have_chflags], [dnl
Alexandre Vassalotti30267d62009-07-17 06:10:06 +00002770AC_TRY_RUN([[
Martin v. Löwisa51d5c82007-12-04 08:37:59 +00002771#include <sys/stat.h>
2772#include <unistd.h>
2773int main(int argc, char*argv[])
2774{
2775 if(chflags(argv[0], 0) != 0)
2776 return 1;
2777 return 0;
2778}
Alexandre Vassalotti30267d62009-07-17 06:10:06 +00002779]], ac_cv_have_chflags=yes,
Alexandre Vassalotti00900892009-07-17 05:26:39 +00002780 ac_cv_have_chflags=no,
Gregory P. Smithbb213892009-11-02 01:37:37 +00002781 ac_cv_have_chflags=cross)
2782])
2783if test "$ac_cv_have_chflags" = cross ; then
2784 AC_CHECK_FUNC([chflags], [ac_cv_have_chflags="yes"], [ac_cv_have_chflags="no"])
2785fi
2786if test "$ac_cv_have_chflags" = yes ; then
Alexandre Vassalotti00900892009-07-17 05:26:39 +00002787 AC_DEFINE(HAVE_CHFLAGS, 1, Define to 1 if you have the `chflags' function.)
2788fi
Martin v. Löwisa51d5c82007-12-04 08:37:59 +00002789
Gregory P. Smithbb213892009-11-02 01:37:37 +00002790AC_CACHE_CHECK([for lchflags], [ac_cv_have_lchflags], [dnl
Alexandre Vassalotti30267d62009-07-17 06:10:06 +00002791AC_TRY_RUN([[
Martin v. Löwisa51d5c82007-12-04 08:37:59 +00002792#include <sys/stat.h>
2793#include <unistd.h>
2794int main(int argc, char*argv[])
2795{
2796 if(lchflags(argv[0], 0) != 0)
2797 return 1;
2798 return 0;
2799}
Alexandre Vassalotti30267d62009-07-17 06:10:06 +00002800]], ac_cv_have_lchflags=yes,
Alexandre Vassalotti00900892009-07-17 05:26:39 +00002801 ac_cv_have_lchflags=no,
Gregory P. Smithbb213892009-11-02 01:37:37 +00002802 ac_cv_have_lchflags=cross)
2803])
2804if test "$ac_cv_have_lchflags" = cross ; then
2805 AC_CHECK_FUNC([lchflags], [ac_cv_have_lchflags="yes"], [ac_cv_have_lchflags="no"])
2806fi
2807if test "$ac_cv_have_lchflags" = yes ; then
Alexandre Vassalotti00900892009-07-17 05:26:39 +00002808 AC_DEFINE(HAVE_LCHFLAGS, 1, Define to 1 if you have the `lchflags' function.)
2809fi
Martin v. Löwisa51d5c82007-12-04 08:37:59 +00002810
Neal Norwitz6e73aaa2006-06-12 03:33:09 +00002811dnl Check if system zlib has *Copy() functions
Ronald Oussorenf8752642006-07-06 10:13:35 +00002812dnl
2813dnl On MacOSX the linker will search for dylibs on the entire linker path
2814dnl before searching for static libraries. setup.py adds -Wl,-search_paths_first
2815dnl to revert to a more traditional unix behaviour and make it possible to
2816dnl override the system libz with a local static library of libz. Temporarily
2817dnl add that flag to our CFLAGS as well to ensure that we check the version
2818dnl of libz that will be used by setup.py.
2819dnl The -L/usr/local/lib is needed as wel to get the same compilation
2820dnl environment as setup.py (and leaving it out can cause configure to use the
2821dnl wrong version of the library)
2822case $ac_sys_system/$ac_sys_release in
2823Darwin/*)
2824 _CUR_CFLAGS="${CFLAGS}"
2825 _CUR_LDFLAGS="${LDFLAGS}"
2826 CFLAGS="${CFLAGS} -Wl,-search_paths_first"
2827 LDFLAGS="${LDFLAGS} -Wl,-search_paths_first -L/usr/local/lib"
2828 ;;
2829esac
2830
Neal Norwitz6e73aaa2006-06-12 03:33:09 +00002831AC_CHECK_LIB(z, inflateCopy, AC_DEFINE(HAVE_ZLIB_COPY, 1, Define if the zlib library has inflateCopy))
2832
Ronald Oussorenf8752642006-07-06 10:13:35 +00002833case $ac_sys_system/$ac_sys_release in
2834Darwin/*)
2835 CFLAGS="${_CUR_CFLAGS}"
2836 LDFLAGS="${_CUR_LDFLAGS}"
2837 ;;
2838esac
2839
Martin v. Löwise9416172003-05-03 10:12:45 +00002840AC_MSG_CHECKING(for hstrerror)
Martin v. Löwis95c419b2003-05-03 12:10:48 +00002841AC_TRY_LINK([
Martin v. Löwise9416172003-05-03 10:12:45 +00002842#include "confdefs.h"
2843#include <netdb.h>
Martin v. Löwis95c419b2003-05-03 12:10:48 +00002844], void* p = hstrerror; hstrerror(0),
Martin v. Löwise9416172003-05-03 10:12:45 +00002845 AC_DEFINE(HAVE_HSTRERROR, 1, Define if you have the 'hstrerror' function.)
2846 AC_MSG_RESULT(yes),
2847 AC_MSG_RESULT(no)
2848)
2849
2850AC_MSG_CHECKING(for inet_aton)
Martin v. Löwis95c419b2003-05-03 12:10:48 +00002851AC_TRY_LINK([
Martin v. Löwise9416172003-05-03 10:12:45 +00002852#include "confdefs.h"
Martin v. Löwis86d66262006-02-17 08:40:11 +00002853#include <sys/types.h>
Martin v. Löwise9416172003-05-03 10:12:45 +00002854#include <sys/socket.h>
2855#include <netinet/in.h>
2856#include <arpa/inet.h>
Martin v. Löwis95c419b2003-05-03 12:10:48 +00002857], void* p = inet_aton;inet_aton(0,0),
Martin v. Löwise9416172003-05-03 10:12:45 +00002858 AC_DEFINE(HAVE_INET_ATON, 1, Define if you have the 'inet_aton' function.)
2859 AC_MSG_RESULT(yes),
2860 AC_MSG_RESULT(no)
2861)
2862
2863AC_MSG_CHECKING(for inet_pton)
2864AC_TRY_COMPILE([
2865#include "confdefs.h"
Martin v. Löwisf2e488d2003-05-05 22:00:11 +00002866#include <sys/types.h>
Martin v. Löwise9416172003-05-03 10:12:45 +00002867#include <sys/socket.h>
2868#include <netinet/in.h>
2869#include <arpa/inet.h>
2870], void* p = inet_pton,
2871 AC_DEFINE(HAVE_INET_PTON, 1, Define if you have the 'inet_pton' function.)
2872 AC_MSG_RESULT(yes),
2873 AC_MSG_RESULT(no)
2874)
2875
Martin v. Löwisd6640d42003-07-06 09:29:52 +00002876# On some systems, setgroups is in unistd.h, on others, in grp.h
Martin v. Löwisd5843682002-11-21 20:41:28 +00002877AC_MSG_CHECKING(for setgroups)
2878AC_TRY_COMPILE([
2879#include "confdefs.h"
Martin v. Löwisf2e488d2003-05-05 22:00:11 +00002880#include <unistd.h>
Martin v. Löwisd6640d42003-07-06 09:29:52 +00002881#ifdef HAVE_GRP_H
2882#include <grp.h>
2883#endif
Martin v. Löwisd5843682002-11-21 20:41:28 +00002884],
2885void* p = setgroups,
2886 AC_DEFINE(HAVE_SETGROUPS, 1, Define if you have the 'setgroups' function.)
2887 AC_MSG_RESULT(yes),
2888 AC_MSG_RESULT(no)
2889)
2890
Fred Drake8cef4cf2000-06-28 16:40:38 +00002891# check for openpty and forkpty
2892
Martin v. Löwisfd9a72a2006-01-08 10:07:33 +00002893AC_CHECK_FUNCS(openpty,,
2894 AC_CHECK_LIB(util,openpty,
2895 [AC_DEFINE(HAVE_OPENPTY) LIBS="$LIBS -lutil"],
2896 AC_CHECK_LIB(bsd,openpty, [AC_DEFINE(HAVE_OPENPTY) LIBS="$LIBS -lbsd"])
2897 )
2898)
2899AC_CHECK_FUNCS(forkpty,,
2900 AC_CHECK_LIB(util,forkpty,
2901 [AC_DEFINE(HAVE_FORKPTY) LIBS="$LIBS -lutil"],
2902 AC_CHECK_LIB(bsd,forkpty, [AC_DEFINE(HAVE_FORKPTY) LIBS="$LIBS -lbsd"])
2903 )
2904)
Fred Drake8cef4cf2000-06-28 16:40:38 +00002905
Brett Cannonaa5778d2008-03-18 04:09:00 +00002906# Stuff for expat.
2907AC_CHECK_FUNCS(memmove)
2908
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00002909# check for long file support functions
2910AC_CHECK_FUNCS(fseek64 fseeko fstatvfs ftell64 ftello statvfs)
2911
Brett Cannonaa5778d2008-03-18 04:09:00 +00002912AC_REPLACE_FUNCS(dup2 getcwd strdup)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002913AC_CHECK_FUNCS(getpgrp,
2914 AC_TRY_COMPILE([#include <unistd.h>],
2915 [getpgrp(0);],
2916 AC_DEFINE(GETPGRP_HAVE_ARG, 1,
2917 [Define if getpgrp() must be called as getpgrp(0).])
2918 )
2919)
Jack Jansen150753c2003-03-29 22:07:47 +00002920AC_CHECK_FUNCS(setpgrp,
2921 AC_TRY_COMPILE([#include <unistd.h>],
2922 [setpgrp(0,0);],
2923 AC_DEFINE(SETPGRP_HAVE_ARG, 1,
2924 [Define if setpgrp() must be called as setpgrp(0, 0).])
2925 )
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002926)
2927AC_CHECK_FUNCS(gettimeofday,
2928 AC_TRY_COMPILE([#include <sys/time.h>],
2929 [gettimeofday((struct timeval*)0,(struct timezone*)0);], ,
2930 AC_DEFINE(GETTIMEOFDAY_NO_TZ, 1,
2931 [Define if gettimeofday() does not have second (timezone) argument
2932 This is the case on Motorola V4 (R40V4.2)])
2933 )
2934)
Guido van Rossum627b2d71993-12-24 10:39:16 +00002935
Martin v. Löwisdbe3f762002-10-10 14:27:30 +00002936AC_MSG_CHECKING(for major, minor, and makedev)
Martin v. Löwise3271202002-11-07 07:42:30 +00002937AC_TRY_LINK([
Neal Norwitz6eb37f02003-02-23 23:28:15 +00002938#if defined(MAJOR_IN_MKDEV)
2939#include <sys/mkdev.h>
2940#elif defined(MAJOR_IN_SYSMACROS)
2941#include <sys/sysmacros.h>
2942#else
2943#include <sys/types.h>
2944#endif
Martin v. Löwisdbe3f762002-10-10 14:27:30 +00002945],[
2946 makedev(major(0),minor(0));
2947],[
2948 AC_DEFINE(HAVE_DEVICE_MACROS, 1,
2949 [Define to 1 if you have the device macros.])
2950 AC_MSG_RESULT(yes)
2951],[
2952 AC_MSG_RESULT(no)
2953])
Martin v. Löwis861a65b2001-10-24 14:36:00 +00002954
2955# On OSF/1 V5.1, getaddrinfo is available, but a define
2956# for [no]getaddrinfo in netdb.h.
2957AC_MSG_CHECKING(for getaddrinfo)
2958AC_TRY_LINK([
Martin v. Löwisc010b6d2001-11-09 17:50:52 +00002959#include <sys/types.h>
Martin v. Löwis861a65b2001-10-24 14:36:00 +00002960#include <sys/socket.h>
2961#include <netdb.h>
Martin v. Löwisc010b6d2001-11-09 17:50:52 +00002962#include <stdio.h>
Alexandre Vassalotti00900892009-07-17 05:26:39 +00002963], [getaddrinfo(NULL, NULL, NULL, NULL);],
2964have_getaddrinfo=yes,
2965have_getaddrinfo=no)
2966AC_MSG_RESULT($have_getaddrinfo)
2967if test $have_getaddrinfo = yes
2968then
2969 AC_MSG_CHECKING(getaddrinfo bug)
2970 AC_CACHE_VAL(ac_cv_buggy_getaddrinfo,
2971 AC_TRY_RUN([[
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00002972#include <sys/types.h>
2973#include <netdb.h>
2974#include <string.h>
2975#include <sys/socket.h>
2976#include <netinet/in.h>
2977
Alexandre Vassalotti00900892009-07-17 05:26:39 +00002978int main()
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00002979{
2980 int passive, gaierr, inet4 = 0, inet6 = 0;
2981 struct addrinfo hints, *ai, *aitop;
2982 char straddr[INET6_ADDRSTRLEN], strport[16];
2983
2984 for (passive = 0; passive <= 1; passive++) {
2985 memset(&hints, 0, sizeof(hints));
2986 hints.ai_family = AF_UNSPEC;
2987 hints.ai_flags = passive ? AI_PASSIVE : 0;
2988 hints.ai_socktype = SOCK_STREAM;
Hye-Shik Chang54f94392004-04-14 07:55:31 +00002989 hints.ai_protocol = IPPROTO_TCP;
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00002990 if ((gaierr = getaddrinfo(NULL, "54321", &hints, &aitop)) != 0) {
2991 (void)gai_strerror(gaierr);
2992 goto bad;
2993 }
2994 for (ai = aitop; ai; ai = ai->ai_next) {
2995 if (ai->ai_addr == NULL ||
2996 ai->ai_addrlen == 0 ||
2997 getnameinfo(ai->ai_addr, ai->ai_addrlen,
2998 straddr, sizeof(straddr), strport, sizeof(strport),
2999 NI_NUMERICHOST|NI_NUMERICSERV) != 0) {
3000 goto bad;
3001 }
3002 switch (ai->ai_family) {
3003 case AF_INET:
3004 if (strcmp(strport, "54321") != 0) {
3005 goto bad;
3006 }
3007 if (passive) {
3008 if (strcmp(straddr, "0.0.0.0") != 0) {
3009 goto bad;
3010 }
3011 } else {
3012 if (strcmp(straddr, "127.0.0.1") != 0) {
3013 goto bad;
3014 }
3015 }
3016 inet4++;
3017 break;
3018 case AF_INET6:
3019 if (strcmp(strport, "54321") != 0) {
3020 goto bad;
3021 }
3022 if (passive) {
3023 if (strcmp(straddr, "::") != 0) {
3024 goto bad;
3025 }
3026 } else {
3027 if (strcmp(straddr, "::1") != 0) {
3028 goto bad;
3029 }
3030 }
3031 inet6++;
3032 break;
3033 case AF_UNSPEC:
3034 goto bad;
3035 break;
3036 default:
3037 /* another family support? */
3038 break;
3039 }
3040 }
3041 }
3042
3043 if (!(inet4 == 0 || inet4 == 2))
3044 goto bad;
3045 if (!(inet6 == 0 || inet6 == 2))
3046 goto bad;
3047
3048 if (aitop)
3049 freeaddrinfo(aitop);
Alexandre Vassalotti00900892009-07-17 05:26:39 +00003050 return 0;
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003051
3052 bad:
3053 if (aitop)
3054 freeaddrinfo(aitop);
Alexandre Vassalotti00900892009-07-17 05:26:39 +00003055 return 1;
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003056}
Alexandre Vassalotti00900892009-07-17 05:26:39 +00003057]], ac_cv_buggy_getaddrinfo=no,
3058 ac_cv_buggy_getaddrinfo=yes,
3059 ac_cv_buggy_getaddrinfo=yes))
3060fi
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003061
Mark Dickinson0ef0b912009-12-31 21:11:48 +00003062if test $have_getaddrinfo = no -o "$ac_cv_buggy_getaddrinfo" = yes
Alexandre Vassalotti00900892009-07-17 05:26:39 +00003063then
3064 if test $ipv6 = yes
3065 then
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003066 echo 'Fatal: You must get working getaddrinfo() function.'
3067 echo ' or you can specify "--disable-ipv6"'.
3068 exit 1
3069 fi
Martin v. Löwis861a65b2001-10-24 14:36:00 +00003070else
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003071 AC_DEFINE(HAVE_GETADDRINFO, 1, [Define if you have the getaddrinfo function.])
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003072fi
Thomas Woutersb0db85a2001-08-08 10:39:03 +00003073AC_CHECK_FUNCS(getnameinfo)
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003074
Guido van Rossum627b2d71993-12-24 10:39:16 +00003075# checks for structures
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003076AC_HEADER_TIME
Guido van Rossum627b2d71993-12-24 10:39:16 +00003077AC_STRUCT_TM
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003078AC_STRUCT_TIMEZONE
Martin v. Löwis60a5d722002-10-16 20:28:25 +00003079AC_CHECK_MEMBERS([struct stat.st_rdev])
3080AC_CHECK_MEMBERS([struct stat.st_blksize])
Hye-Shik Chang5f937a72005-06-02 13:09:30 +00003081AC_CHECK_MEMBERS([struct stat.st_flags])
Martin v. Löwisebd9d5b2005-08-09 15:00:59 +00003082AC_CHECK_MEMBERS([struct stat.st_gen])
3083AC_CHECK_MEMBERS([struct stat.st_birthtime])
Guido van Rossum98bf58f2001-10-18 20:34:25 +00003084AC_STRUCT_ST_BLOCKS
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003085
3086AC_MSG_CHECKING(for time.h that defines altzone)
3087AC_CACHE_VAL(ac_cv_header_time_altzone,
3088[AC_TRY_COMPILE([#include <time.h>], [return altzone;],
3089 ac_cv_header_time_altzone=yes,
3090 ac_cv_header_time_altzone=no)])
3091AC_MSG_RESULT($ac_cv_header_time_altzone)
3092if test $ac_cv_header_time_altzone = yes; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003093 AC_DEFINE(HAVE_ALTZONE, 1, [Define this if your time.h defines altzone.])
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003094fi
3095
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003096was_it_defined=no
3097AC_MSG_CHECKING(whether sys/select.h and sys/time.h may both be included)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003098AC_TRY_COMPILE([
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003099#include <sys/types.h>
3100#include <sys/select.h>
3101#include <sys/time.h>
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003102], [;], [
3103 AC_DEFINE(SYS_SELECT_WITH_SYS_TIME, 1,
3104 [Define if you can safely include both <sys/select.h> and <sys/time.h>
3105 (which you can't on SCO ODT 3.0).])
3106 was_it_defined=yes
3107])
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003108AC_MSG_RESULT($was_it_defined)
Guido van Rossum627b2d71993-12-24 10:39:16 +00003109
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003110AC_MSG_CHECKING(for addrinfo)
3111AC_CACHE_VAL(ac_cv_struct_addrinfo,
3112AC_TRY_COMPILE([
3113# include <netdb.h>],
3114 [struct addrinfo a],
3115 ac_cv_struct_addrinfo=yes,
3116 ac_cv_struct_addrinfo=no))
3117AC_MSG_RESULT($ac_cv_struct_addrinfo)
3118if test $ac_cv_struct_addrinfo = yes; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003119 AC_DEFINE(HAVE_ADDRINFO, 1, [struct addrinfo (netdb.h)])
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003120fi
3121
3122AC_MSG_CHECKING(for sockaddr_storage)
3123AC_CACHE_VAL(ac_cv_struct_sockaddr_storage,
3124AC_TRY_COMPILE([
3125# include <sys/types.h>
3126# include <sys/socket.h>],
3127 [struct sockaddr_storage s],
3128 ac_cv_struct_sockaddr_storage=yes,
3129 ac_cv_struct_sockaddr_storage=no))
3130AC_MSG_RESULT($ac_cv_struct_sockaddr_storage)
3131if test $ac_cv_struct_sockaddr_storage = yes; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003132 AC_DEFINE(HAVE_SOCKADDR_STORAGE, 1, [struct sockaddr_storage (sys/socket.h)])
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003133fi
3134
Guido van Rossum627b2d71993-12-24 10:39:16 +00003135# checks for compiler characteristics
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003136
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003137AC_C_CHAR_UNSIGNED
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003138AC_C_CONST
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003139
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003140works=no
3141AC_MSG_CHECKING(for working volatile)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003142AC_TRY_COMPILE([],[volatile int x; x = 0;], works=yes,
3143 AC_DEFINE(volatile, [], [Define to empty if the keyword does not work.])
3144)
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003145AC_MSG_RESULT($works)
Guido van Rossumdabb11b1994-10-11 15:04:27 +00003146
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003147works=no
3148AC_MSG_CHECKING(for working signed char)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003149AC_TRY_COMPILE([], [signed char c;], works=yes,
3150 AC_DEFINE(signed, [], [Define to empty if the keyword does not work.])
3151)
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003152AC_MSG_RESULT($works)
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003153
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003154have_prototypes=no
3155AC_MSG_CHECKING(for prototypes)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003156AC_TRY_COMPILE([int foo(int x) { return 0; }], [return foo(10);],[
3157 AC_DEFINE(HAVE_PROTOTYPES, 1,
3158 [Define if your compiler supports function prototype])
3159 have_prototypes=yes
3160])
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003161AC_MSG_RESULT($have_prototypes)
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003162
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003163works=no
3164AC_MSG_CHECKING(for variable length prototypes and stdarg.h)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003165AC_TRY_COMPILE([
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003166#include <stdarg.h>
Guido van Rossum3f13e481996-08-30 20:58:11 +00003167int foo(int x, ...) {
3168 va_list va;
3169 va_start(va, x);
3170 va_arg(va, int);
3171 va_arg(va, char *);
3172 va_arg(va, double);
3173 return 0;
3174}
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003175], [return foo(10, "", 3.14);], [
3176 AC_DEFINE(HAVE_STDARG_PROTOTYPES, 1,
3177 [Define if your compiler supports variable length function prototypes
3178 (e.g. void fprintf(FILE *, char *, ...);) *and* <stdarg.h>])
3179 works=yes
3180])
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003181AC_MSG_RESULT($works)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003182
Dave Cole331708b2004-08-09 04:51:41 +00003183# check for socketpair
3184AC_MSG_CHECKING(for socketpair)
3185AC_TRY_COMPILE([
3186#include <sys/types.h>
3187#include <sys/socket.h>
3188], void *x=socketpair,
3189 AC_DEFINE(HAVE_SOCKETPAIR, 1, Define if you have the 'socketpair' function.)
3190 AC_MSG_RESULT(yes),
3191 AC_MSG_RESULT(no)
3192)
3193
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003194# check if sockaddr has sa_len member
3195AC_MSG_CHECKING(if sockaddr has sa_len member)
3196AC_TRY_COMPILE([#include <sys/types.h>
3197#include <sys/socket.h>],
3198[struct sockaddr x;
3199x.sa_len = 0;],
3200 AC_MSG_RESULT(yes)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003201 AC_DEFINE(HAVE_SOCKADDR_SA_LEN, 1, [Define if sockaddr has sa_len member]),
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003202 AC_MSG_RESULT(no))
3203
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003204va_list_is_array=no
3205AC_MSG_CHECKING(whether va_list is an array)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003206AC_TRY_COMPILE([
3207#ifdef HAVE_STDARG_PROTOTYPES
3208#include <stdarg.h>
3209#else
3210#include <varargs.h>
3211#endif
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003212], [va_list list1, list2; list1 = list2;], , [
3213 AC_DEFINE(VA_LIST_IS_ARRAY, 1, [Define if a va_list is an array of some kind])
3214 va_list_is_array=yes
3215])
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003216AC_MSG_RESULT($va_list_is_array)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003217
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003218# sigh -- gethostbyname_r is a mess; it can have 3, 5 or 6 arguments :-(
Martin v. Löwis11437992002-04-12 09:54:03 +00003219AH_TEMPLATE(HAVE_GETHOSTBYNAME_R,
3220 [Define this if you have some version of gethostbyname_r()])
3221
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003222AC_CHECK_FUNC(gethostbyname_r, [
3223 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
3224 AC_MSG_CHECKING([gethostbyname_r with 6 args])
3225 OLD_CFLAGS=$CFLAGS
3226 CFLAGS="$CFLAGS $MY_CPPFLAGS $MY_THREAD_CPPFLAGS $MY_CFLAGS"
3227 AC_TRY_COMPILE([
3228# include <netdb.h>
3229 ], [
3230 char *name;
3231 struct hostent *he, *res;
3232 char buffer[2048];
3233 int buflen = 2048;
3234 int h_errnop;
3235
3236 (void) gethostbyname_r(name, he, buffer, buflen, &res, &h_errnop)
3237 ], [
Guido van Rossum8db7d8b1999-03-23 16:40:33 +00003238 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003239 AC_DEFINE(HAVE_GETHOSTBYNAME_R_6_ARG, 1,
3240 [Define this if you have the 6-arg version of gethostbyname_r().])
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003241 AC_MSG_RESULT(yes)
3242 ], [
3243 AC_MSG_RESULT(no)
3244 AC_MSG_CHECKING([gethostbyname_r with 5 args])
3245 AC_TRY_COMPILE([
3246# include <netdb.h>
3247 ], [
3248 char *name;
3249 struct hostent *he;
3250 char buffer[2048];
3251 int buflen = 2048;
3252 int h_errnop;
3253
3254 (void) gethostbyname_r(name, he, buffer, buflen, &h_errnop)
3255 ], [
Guido van Rossum8db7d8b1999-03-23 16:40:33 +00003256 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003257 AC_DEFINE(HAVE_GETHOSTBYNAME_R_5_ARG, 1,
3258 [Define this if you have the 5-arg version of gethostbyname_r().])
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003259 AC_MSG_RESULT(yes)
3260 ], [
3261 AC_MSG_RESULT(no)
3262 AC_MSG_CHECKING([gethostbyname_r with 3 args])
3263 AC_TRY_COMPILE([
3264# include <netdb.h>
3265 ], [
3266 char *name;
3267 struct hostent *he;
3268 struct hostent_data data;
3269
3270 (void) gethostbyname_r(name, he, &data);
3271 ], [
Guido van Rossum8db7d8b1999-03-23 16:40:33 +00003272 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003273 AC_DEFINE(HAVE_GETHOSTBYNAME_R_3_ARG, 1,
3274 [Define this if you have the 3-arg version of gethostbyname_r().])
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003275 AC_MSG_RESULT(yes)
3276 ], [
3277 AC_MSG_RESULT(no)
3278 ])
3279 ])
3280 ])
3281 CFLAGS=$OLD_CFLAGS
3282], [
Thomas Wouters3a584202000-08-05 23:28:51 +00003283 AC_CHECK_FUNCS(gethostbyname)
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003284])
3285AC_SUBST(HAVE_GETHOSTBYNAME_R_6_ARG)
3286AC_SUBST(HAVE_GETHOSTBYNAME_R_5_ARG)
3287AC_SUBST(HAVE_GETHOSTBYNAME_R_3_ARG)
Guido van Rossum8db7d8b1999-03-23 16:40:33 +00003288AC_SUBST(HAVE_GETHOSTBYNAME_R)
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003289AC_SUBST(HAVE_GETHOSTBYNAME)
3290
Guido van Rossum627b2d71993-12-24 10:39:16 +00003291# checks for system services
3292# (none yet)
3293
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003294# Linux requires this for correct f.p. operations
Jeremy Hyltonbe28f5b2000-07-27 21:03:04 +00003295AC_CHECK_FUNC(__fpu_control,
3296 [],
3297 [AC_CHECK_LIB(ieee, __fpu_control)
3298])
Guido van Rossum627b2d71993-12-24 10:39:16 +00003299
Guido van Rossum93274221997-05-09 02:42:00 +00003300# Check for --with-fpectl
Guido van Rossum93274221997-05-09 02:42:00 +00003301AC_MSG_CHECKING(for --with-fpectl)
Barry Warsawc0d24d82000-06-29 16:12:00 +00003302AC_ARG_WITH(fpectl,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003303 AC_HELP_STRING(--with-fpectl, enable SIGFPE catching),
3304[
Guido van Rossum93274221997-05-09 02:42:00 +00003305if test "$withval" != no
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003306then
3307 AC_DEFINE(WANT_SIGFPE_HANDLER, 1,
3308 [Define if you want SIGFPE handled (see Include/pyfpe.h).])
3309 AC_MSG_RESULT(yes)
Guido van Rossum93274221997-05-09 02:42:00 +00003310else AC_MSG_RESULT(no)
Guido van Rossumef2255b2000-03-10 22:30:29 +00003311fi],
3312[AC_MSG_RESULT(no)])
Guido van Rossum93274221997-05-09 02:42:00 +00003313
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003314# check for --with-libm=...
3315AC_SUBST(LIBM)
Guido van Rossum4b6b5791996-09-09 20:09:34 +00003316case $ac_sys_system in
Guido van Rossum3dc0a512000-10-05 18:00:06 +00003317Darwin) ;;
Guido van Rossumec95c7b1998-08-04 17:59:56 +00003318BeOS) ;;
Guido van Rossum4b6b5791996-09-09 20:09:34 +00003319*) LIBM=-lm
3320esac
Guido van Rossum93274221997-05-09 02:42:00 +00003321AC_MSG_CHECKING(for --with-libm=STRING)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003322AC_ARG_WITH(libm,
3323 AC_HELP_STRING(--with-libm=STRING, math library),
3324[
Guido van Rossum93274221997-05-09 02:42:00 +00003325if test "$withval" = no
3326then LIBM=
3327 AC_MSG_RESULT(force LIBM empty)
3328elif test "$withval" != yes
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003329then LIBM=$withval
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003330 AC_MSG_RESULT(set LIBM="$withval")
3331else AC_MSG_ERROR([proper usage is --with-libm=STRING])
Guido van Rossum93274221997-05-09 02:42:00 +00003332fi],
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003333[AC_MSG_RESULT(default LIBM="$LIBM")])
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003334
3335# check for --with-libc=...
3336AC_SUBST(LIBC)
Guido van Rossum93274221997-05-09 02:42:00 +00003337AC_MSG_CHECKING(for --with-libc=STRING)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003338AC_ARG_WITH(libc,
3339 AC_HELP_STRING(--with-libc=STRING, C library),
3340[
Guido van Rossum93274221997-05-09 02:42:00 +00003341if test "$withval" = no
3342then LIBC=
3343 AC_MSG_RESULT(force LIBC empty)
3344elif test "$withval" != yes
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003345then LIBC=$withval
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003346 AC_MSG_RESULT(set LIBC="$withval")
3347else AC_MSG_ERROR([proper usage is --with-libc=STRING])
Guido van Rossum93274221997-05-09 02:42:00 +00003348fi],
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003349[AC_MSG_RESULT(default LIBC="$LIBC")])
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003350
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003351# **************************************************
3352# * Check for various properties of floating point *
3353# **************************************************
Mark Dickinson265d7382008-04-21 22:32:24 +00003354
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003355AC_MSG_CHECKING(whether C doubles are little-endian IEEE 754 binary64)
3356AC_CACHE_VAL(ac_cv_little_endian_double, [
3357AC_TRY_RUN([
3358#include <string.h>
3359int main() {
3360 double x = 9006104071832581.0;
3361 if (memcmp(&x, "\x05\x04\x03\x02\x01\xff\x3f\x43", 8) == 0)
3362 return 0;
3363 else
3364 return 1;
3365}
3366],
3367ac_cv_little_endian_double=yes,
3368ac_cv_little_endian_double=no,
3369ac_cv_little_endian_double=no)])
3370AC_MSG_RESULT($ac_cv_little_endian_double)
3371if test "$ac_cv_little_endian_double" = yes
3372then
3373 AC_DEFINE(DOUBLE_IS_LITTLE_ENDIAN_IEEE754, 1,
3374 [Define if C doubles are 64-bit IEEE 754 binary format, stored
3375 with the least significant byte first])
3376fi
3377
3378AC_MSG_CHECKING(whether C doubles are big-endian IEEE 754 binary64)
3379AC_CACHE_VAL(ac_cv_big_endian_double, [
3380AC_TRY_RUN([
3381#include <string.h>
3382int main() {
3383 double x = 9006104071832581.0;
3384 if (memcmp(&x, "\x43\x3f\xff\x01\x02\x03\x04\x05", 8) == 0)
3385 return 0;
3386 else
3387 return 1;
3388}
3389],
3390ac_cv_big_endian_double=yes,
3391ac_cv_big_endian_double=no,
3392ac_cv_big_endian_double=no)])
3393AC_MSG_RESULT($ac_cv_big_endian_double)
3394if test "$ac_cv_big_endian_double" = yes
3395then
3396 AC_DEFINE(DOUBLE_IS_BIG_ENDIAN_IEEE754, 1,
3397 [Define if C doubles are 64-bit IEEE 754 binary format, stored
3398 with the most significant byte first])
3399fi
3400
3401# Some ARM platforms use a mixed-endian representation for doubles.
3402# While Python doesn't currently have full support for these platforms
3403# (see e.g., issue 1762561), we can at least make sure that float <-> string
3404# conversions work.
3405AC_MSG_CHECKING(whether C doubles are ARM mixed-endian IEEE 754 binary64)
3406AC_CACHE_VAL(ac_cv_mixed_endian_double, [
3407AC_TRY_RUN([
3408#include <string.h>
3409int main() {
3410 double x = 9006104071832581.0;
3411 if (memcmp(&x, "\x01\xff\x3f\x43\x05\x04\x03\x02", 8) == 0)
3412 return 0;
3413 else
3414 return 1;
3415}
3416],
3417ac_cv_mixed_endian_double=yes,
3418ac_cv_mixed_endian_double=no,
3419ac_cv_mixed_endian_double=no)])
3420AC_MSG_RESULT($ac_cv_mixed_endian_double)
3421if test "$ac_cv_mixed_endian_double" = yes
3422then
3423 AC_DEFINE(DOUBLE_IS_ARM_MIXED_ENDIAN_IEEE754, 1,
3424 [Define if C doubles are 64-bit IEEE 754 binary format, stored
3425 in ARM mixed-endian order (byte order 45670123)])
3426fi
3427
3428# The short float repr introduced in Python 3.1 requires the
3429# correctly-rounded string <-> double conversion functions from
3430# Python/dtoa.c, which in turn require that the FPU uses 53-bit
3431# rounding; this is a problem on x86, where the x87 FPU has a default
Mark Dickinsona548dee2009-11-15 13:12:43 +00003432# rounding precision of 64 bits. For gcc/x86, we can fix this by
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003433# using inline assembler to get and set the x87 FPU control word.
Mark Dickinsona548dee2009-11-15 13:12:43 +00003434
3435# This inline assembler syntax may also work for suncc and icc,
3436# so we try it on all platforms.
3437
3438AC_MSG_CHECKING(whether we can use gcc inline assembler to get and set x87 control word)
3439AC_TRY_COMPILE([], [
3440 unsigned short cw;
3441 __asm__ __volatile__ ("fnstcw %0" : "=m" (cw));
3442 __asm__ __volatile__ ("fldcw %0" : : "m" (cw));
3443],
3444[have_gcc_asm_for_x87=yes], [have_gcc_asm_for_x87=no])
3445AC_MSG_RESULT($have_gcc_asm_for_x87)
3446if test "$have_gcc_asm_for_x87" = yes
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003447then
Mark Dickinsona548dee2009-11-15 13:12:43 +00003448 AC_DEFINE(HAVE_GCC_ASM_FOR_X87, 1,
3449 [Define if we can use gcc inline assembler to get and set x87 control word])
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003450fi
Mark Dickinson7a3d8642008-04-22 00:54:27 +00003451
Mark Dickinson04b27232009-01-04 12:29:36 +00003452# Detect whether system arithmetic is subject to x87-style double
3453# rounding issues. The result of this test has little meaning on non
3454# IEEE 754 platforms. On IEEE 754, test should return 1 if rounding
3455# mode is round-to-nearest and double rounding issues are present, and
3456# 0 otherwise. See http://bugs.python.org/issue2937 for more info.
3457AC_MSG_CHECKING(for x87-style double rounding)
Mark Dickinson99abd142009-10-24 13:44:16 +00003458# $BASECFLAGS may affect the result
3459ac_save_cc="$CC"
3460CC="$CC $BASECFLAGS"
Mark Dickinson04b27232009-01-04 12:29:36 +00003461AC_TRY_RUN([
3462#include <stdlib.h>
3463#include <math.h>
3464int main() {
3465 volatile double x, y, z;
3466 /* 1./(1-2**-53) -> 1+2**-52 (correct), 1.0 (double rounding) */
3467 x = 0.99999999999999989; /* 1-2**-53 */
3468 y = 1./x;
3469 if (y != 1.)
3470 exit(0);
3471 /* 1e16+2.99999 -> 1e16+2. (correct), 1e16+4. (double rounding) */
3472 x = 1e16;
3473 y = 2.99999;
3474 z = x + y;
3475 if (z != 1e16+4.)
3476 exit(0);
3477 /* both tests show evidence of double rounding */
3478 exit(1);
3479}
3480],
3481ac_cv_x87_double_rounding=no,
3482ac_cv_x87_double_rounding=yes,
Mark Dickinson99abd142009-10-24 13:44:16 +00003483ac_cv_x87_double_rounding=no)
3484CC="$ac_save_cc"
Mark Dickinson04b27232009-01-04 12:29:36 +00003485AC_MSG_RESULT($ac_cv_x87_double_rounding)
3486if test "$ac_cv_x87_double_rounding" = yes
3487then
3488 AC_DEFINE(X87_DOUBLE_ROUNDING, 1,
3489 [Define if arithmetic is subject to x87-style double rounding issue])
3490fi
3491
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003492# ************************************
3493# * Check for mathematical functions *
3494# ************************************
3495
3496LIBS_SAVE=$LIBS
3497LIBS="$LIBS $LIBM"
3498
Mark Dickinsonc63392c2009-11-28 13:13:13 +00003499# On FreeBSD 6.2, it appears that tanh(-0.) returns 0. instead of
3500# -0. on some architectures.
3501AC_MSG_CHECKING(whether tanh preserves the sign of zero)
3502AC_CACHE_VAL(ac_cv_tanh_preserves_zero_sign, [
3503AC_TRY_RUN([
3504#include <math.h>
3505#include <stdlib.h>
3506int main() {
3507 /* return 0 if either negative zeros don't exist
3508 on this platform or if negative zeros exist
3509 and tanh(-0.) == -0. */
3510 if (atan2(0., -1.) == atan2(-0., -1.) ||
3511 atan2(tanh(-0.), -1.) == atan2(-0., -1.)) exit(0);
3512 else exit(1);
3513}
3514],
3515ac_cv_tanh_preserves_zero_sign=yes,
3516ac_cv_tanh_preserves_zero_sign=no,
3517ac_cv_tanh_preserves_zero_sign=no)])
3518AC_MSG_RESULT($ac_cv_tanh_preserves_zero_sign)
3519if test "$ac_cv_tanh_preserves_zero_sign" = yes
3520then
3521 AC_DEFINE(TANH_PRESERVES_ZERO_SIGN, 1,
3522 [Define if tanh(-0.) is -0., or if platform doesn't have signed zeros])
3523fi
3524
3525AC_CHECK_FUNCS([acosh asinh atanh copysign erf erfc expm1 finite gamma])
3526AC_CHECK_FUNCS([hypot lgamma log1p round tgamma])
3527AC_CHECK_DECLS([isinf, isnan, isfinite], [], [], [[#include <math.h>]])
3528
3529LIBS=$LIBS_SAVE
3530
Mark Dickinsonc4920e82009-11-20 19:30:22 +00003531# For multiprocessing module, check that sem_open
3532# actually works. For FreeBSD versions <= 7.2,
3533# the kernel module that provides POSIX semaphores
3534# isn't loaded by default, so an attempt to call
3535# sem_open results in a 'Signal 12' error.
3536AC_MSG_CHECKING(whether POSIX semaphores are enabled)
3537AC_CACHE_VAL(ac_cv_posix_semaphores_enabled,
3538AC_TRY_RUN([
3539#include <unistd.h>
3540#include <fcntl.h>
3541#include <stdio.h>
3542#include <semaphore.h>
3543#include <sys/stat.h>
3544
3545int main(void) {
3546 sem_t *a = sem_open("/autoconf", O_CREAT, S_IRUSR|S_IWUSR, 0);
3547 if (a == SEM_FAILED) {
3548 perror("sem_open");
3549 return 1;
3550 }
3551 sem_close(a);
Mark Dickinson59dc89e2009-12-13 21:06:06 +00003552 sem_unlink("/autoconf");
Mark Dickinsonc4920e82009-11-20 19:30:22 +00003553 return 0;
3554}
3555], ac_cv_posix_semaphores_enabled=yes,
3556 ac_cv_posix_semaphores_enabled=no,
3557 ac_cv_posix_semaphores_enabled=yes)
3558)
3559AC_MSG_RESULT($ac_cv_posix_semaphores_enabled)
3560if test $ac_cv_posix_semaphores_enabled = no
3561then
Mark Dickinson5afa6d42009-11-28 10:44:20 +00003562 AC_DEFINE(POSIX_SEMAPHORES_NOT_ENABLED, 1,
3563 [Define if POSIX semaphores aren't enabled on your system])
Mark Dickinsonc4920e82009-11-20 19:30:22 +00003564fi
3565
Jesse Noller355b1262009-04-02 00:03:28 +00003566# Multiprocessing check for broken sem_getvalue
3567AC_MSG_CHECKING(for broken sem_getvalue)
Alexandre Vassalotti00900892009-07-17 05:26:39 +00003568AC_CACHE_VAL(ac_cv_broken_sem_getvalue,
Jesse Noller355b1262009-04-02 00:03:28 +00003569AC_TRY_RUN([
3570#include <unistd.h>
3571#include <fcntl.h>
3572#include <stdio.h>
3573#include <semaphore.h>
3574#include <sys/stat.h>
3575
3576int main(void){
Mark Dickinson59dc89e2009-12-13 21:06:06 +00003577 sem_t *a = sem_open("/autocftw", O_CREAT, S_IRUSR|S_IWUSR, 0);
Jesse Noller355b1262009-04-02 00:03:28 +00003578 int count;
3579 int res;
3580 if(a==SEM_FAILED){
3581 perror("sem_open");
3582 return 1;
3583
3584 }
3585 res = sem_getvalue(a, &count);
3586 sem_close(a);
Mark Dickinson59dc89e2009-12-13 21:06:06 +00003587 sem_unlink("/autocftw");
Jesse Noller355b1262009-04-02 00:03:28 +00003588 return res==-1 ? 1 : 0;
3589}
Alexandre Vassalotti00900892009-07-17 05:26:39 +00003590], ac_cv_broken_sem_getvalue=no,
3591 ac_cv_broken_sem_getvalue=yes,
3592 ac_cv_broken_sem_getvalue=yes)
Jesse Noller355b1262009-04-02 00:03:28 +00003593)
Alexandre Vassalotti00900892009-07-17 05:26:39 +00003594AC_MSG_RESULT($ac_cv_broken_sem_getvalue)
3595if test $ac_cv_broken_sem_getvalue = yes
3596then
3597 AC_DEFINE(HAVE_BROKEN_SEM_GETVALUE, 1,
3598 [define to 1 if your sem_getvalue is broken.])
3599fi
Mark Dickinson04b27232009-01-04 12:29:36 +00003600
Mark Dickinsonefc82f72009-03-20 15:51:55 +00003601# determine what size digit to use for Python's longs
3602AC_MSG_CHECKING([digit size for Python's longs])
3603AC_ARG_ENABLE(big-digits,
3604AC_HELP_STRING([--enable-big-digits@<:@=BITS@:>@],[use big digits for Python longs [[BITS=30]]]),
3605[case $enable_big_digits in
3606yes)
3607 enable_big_digits=30 ;;
3608no)
3609 enable_big_digits=15 ;;
3610[15|30])
3611 ;;
3612*)
3613 AC_MSG_ERROR([bad value $enable_big_digits for --enable-big-digits; value should be 15 or 30]) ;;
3614esac
3615AC_MSG_RESULT($enable_big_digits)
3616AC_DEFINE_UNQUOTED(PYLONG_BITS_IN_DIGIT, $enable_big_digits, [Define as the preferred size in bits of long digits])
3617],
3618[AC_MSG_RESULT(no value specified)])
3619
Guido van Rossumef2255b2000-03-10 22:30:29 +00003620# check for wchar.h
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003621AC_CHECK_HEADER(wchar.h, [
3622 AC_DEFINE(HAVE_WCHAR_H, 1,
3623 [Define if the compiler provides a wchar.h header file.])
3624 wchar_h="yes"
3625],
Guido van Rossumef2255b2000-03-10 22:30:29 +00003626wchar_h="no"
3627)
3628
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003629# determine wchar_t size
3630if test "$wchar_h" = yes
3631then
Guido van Rossum67b26592001-10-20 14:21:45 +00003632 AC_CHECK_SIZEOF(wchar_t, 4, [#include <wchar.h>])
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003633fi
3634
Martin v. Löwisfa3bdea2003-09-04 18:50:54 +00003635AC_MSG_CHECKING(for UCS-4 tcl)
3636have_ucs4_tcl=no
3637AC_TRY_COMPILE([
3638#include <tcl.h>
3639#if TCL_UTF_MAX != 6
3640# error "NOT UCS4_TCL"
3641#endif], [], [
3642 AC_DEFINE(HAVE_UCS4_TCL, 1, [Define this if you have tcl and TCL_UTF_MAX==6])
3643 have_ucs4_tcl=yes
3644])
3645AC_MSG_RESULT($have_ucs4_tcl)
3646
Marc-André Lemburgd7160f82003-09-22 11:14:40 +00003647# check whether wchar_t is signed or not
3648if test "$wchar_h" = yes
3649then
3650 # check whether wchar_t is signed or not
3651 AC_MSG_CHECKING(whether wchar_t is signed)
3652 AC_CACHE_VAL(ac_cv_wchar_t_signed, [
3653 AC_TRY_RUN([
3654 #include <wchar.h>
3655 int main()
3656 {
Martin v. Löwis44fe0e42006-04-11 07:15:30 +00003657 /* Success: exit code 0 */
3658 exit((((wchar_t) -1) < ((wchar_t) 0)) ? 0 : 1);
Marc-André Lemburgd7160f82003-09-22 11:14:40 +00003659 }
3660 ],
3661 ac_cv_wchar_t_signed=yes,
3662 ac_cv_wchar_t_signed=no,
3663 ac_cv_wchar_t_signed=yes)])
3664 AC_MSG_RESULT($ac_cv_wchar_t_signed)
3665fi
3666
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003667AC_MSG_CHECKING(what type to use for unicode)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003668dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003669AC_ARG_ENABLE(unicode,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003670 AC_HELP_STRING(--enable-unicode@<:@=ucs@<:@24@:>@@:>@, Enable Unicode strings (default is yes)),
3671 [],
3672 [enable_unicode=yes])
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003673
3674if test $enable_unicode = yes
3675then
Martin v. Löwisfd917792001-06-27 20:22:04 +00003676 # Without any arguments, Py_UNICODE defaults to two-byte mode
Martin v. Löwisfa3bdea2003-09-04 18:50:54 +00003677 case "$have_ucs4_tcl" in
3678 yes) enable_unicode="ucs4"
3679 ;;
3680 *) enable_unicode="ucs2"
3681 ;;
3682 esac
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003683fi
3684
Martin v. Löwis0036cba2002-04-12 09:58:45 +00003685AH_TEMPLATE(Py_UNICODE_SIZE,
3686 [Define as the size of the unicode type.])
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003687case "$enable_unicode" in
3688ucs2) unicode_size="2"
3689 AC_DEFINE(Py_UNICODE_SIZE,2)
3690 ;;
3691ucs4) unicode_size="4"
3692 AC_DEFINE(Py_UNICODE_SIZE,4)
3693 ;;
Ezio Melotti5820efb2010-02-27 00:05:42 +00003694*) AC_MSG_ERROR([invalid value for --enable-unicode. Use either ucs2 or ucs4 (lowercase).]) ;;
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003695esac
3696
Martin v. Löwis11437992002-04-12 09:54:03 +00003697AH_TEMPLATE(PY_UNICODE_TYPE,
3698 [Define as the integral type used for Unicode representation.])
Martin v. Löwis0036cba2002-04-12 09:58:45 +00003699
Martin v. Löwis339d0f72001-08-17 18:39:25 +00003700AC_SUBST(UNICODE_OBJS)
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003701if test "$enable_unicode" = "no"
3702then
Martin v. Löwis339d0f72001-08-17 18:39:25 +00003703 UNICODE_OBJS=""
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003704 AC_MSG_RESULT(not used)
3705else
Martin v. Löwis339d0f72001-08-17 18:39:25 +00003706 UNICODE_OBJS="Objects/unicodeobject.o Objects/unicodectype.o"
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003707 AC_DEFINE(Py_USING_UNICODE, 1,
3708 [Define if you want to have a Unicode type.])
Marc-André Lemburgd7160f82003-09-22 11:14:40 +00003709
3710 # wchar_t is only usable if it maps to an unsigned type
3711 if test "$unicode_size" = "$ac_cv_sizeof_wchar_t" \
Matthias Klose7dbeed72004-12-24 08:22:17 +00003712 -a "$ac_cv_wchar_t_signed" = "no"
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003713 then
3714 PY_UNICODE_TYPE="wchar_t"
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003715 AC_DEFINE(HAVE_USABLE_WCHAR_T, 1,
3716 [Define if you have a useable wchar_t type defined in wchar.h; useable
Marc-André Lemburgd7160f82003-09-22 11:14:40 +00003717 means wchar_t must be an unsigned type with at least 16 bits. (see
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003718 Include/unicodeobject.h).])
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003719 AC_DEFINE(PY_UNICODE_TYPE,wchar_t)
3720 elif test "$ac_cv_sizeof_short" = "$unicode_size"
3721 then
3722 PY_UNICODE_TYPE="unsigned short"
3723 AC_DEFINE(PY_UNICODE_TYPE,unsigned short)
3724 elif test "$ac_cv_sizeof_long" = "$unicode_size"
3725 then
3726 PY_UNICODE_TYPE="unsigned long"
3727 AC_DEFINE(PY_UNICODE_TYPE,unsigned long)
3728 else
3729 PY_UNICODE_TYPE="no type found"
3730 fi
3731 AC_MSG_RESULT($PY_UNICODE_TYPE)
3732fi
Guido van Rossumef2255b2000-03-10 22:30:29 +00003733
3734# check for endianness
3735AC_C_BIGENDIAN
3736
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00003737# Check whether right shifting a negative integer extends the sign bit
3738# or fills with zeros (like the Cray J90, according to Tim Peters).
3739AC_MSG_CHECKING(whether right shift extends the sign bit)
Vladimir Marangozova6180282000-07-12 05:05:06 +00003740AC_CACHE_VAL(ac_cv_rshift_extends_sign, [
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00003741AC_TRY_RUN([
3742int main()
3743{
Vladimir Marangozova6180282000-07-12 05:05:06 +00003744 exit(((-1)>>3 == -1) ? 0 : 1);
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00003745}
Guido van Rossum3065c942001-09-17 04:03:14 +00003746],
3747ac_cv_rshift_extends_sign=yes,
3748ac_cv_rshift_extends_sign=no,
3749ac_cv_rshift_extends_sign=yes)])
Vladimir Marangozova6180282000-07-12 05:05:06 +00003750AC_MSG_RESULT($ac_cv_rshift_extends_sign)
3751if test "$ac_cv_rshift_extends_sign" = no
3752then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003753 AC_DEFINE(SIGNED_RIGHT_SHIFT_ZERO_FILLS, 1,
3754 [Define if i>>j for signed int i does not extend the sign bit
3755 when i < 0])
Vladimir Marangozova6180282000-07-12 05:05:06 +00003756fi
3757
Guido van Rossumcadfaec2001-01-05 14:45:49 +00003758# check for getc_unlocked and related locking functions
3759AC_MSG_CHECKING(for getc_unlocked() and friends)
3760AC_CACHE_VAL(ac_cv_have_getc_unlocked, [
3761AC_TRY_LINK([#include <stdio.h>],[
3762 FILE *f = fopen("/dev/null", "r");
3763 flockfile(f);
3764 getc_unlocked(f);
3765 funlockfile(f);
3766], ac_cv_have_getc_unlocked=yes, ac_cv_have_getc_unlocked=no)])
3767AC_MSG_RESULT($ac_cv_have_getc_unlocked)
3768if test "$ac_cv_have_getc_unlocked" = yes
3769then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003770 AC_DEFINE(HAVE_GETC_UNLOCKED, 1,
3771 [Define this if you have flockfile(), getc_unlocked(), and funlockfile()])
Guido van Rossumcadfaec2001-01-05 14:45:49 +00003772fi
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00003773
Neal Norwitzfe8e3d92006-01-07 21:07:20 +00003774# check where readline lives
Martin v. Löwis82bca632006-02-10 20:49:30 +00003775# save the value of LIBS so we don't actually link Python with readline
3776LIBS_no_readline=$LIBS
Gregory P. Smith980b99b2008-09-07 05:15:18 +00003777
3778# On some systems we need to link readline to a termcap compatible
3779# library. NOTE: Keep the precedence of listed libraries synchronised
3780# with setup.py.
3781py_cv_lib_readline=no
3782AC_MSG_CHECKING([how to link readline libs])
3783for py_libtermcap in "" ncursesw ncurses curses termcap; do
3784 if test -z "$py_libtermcap"; then
3785 READLINE_LIBS="-lreadline"
3786 else
3787 READLINE_LIBS="-lreadline -l$py_libtermcap"
3788 fi
3789 LIBS="$READLINE_LIBS $LIBS_no_readline"
3790 AC_LINK_IFELSE(
3791 [AC_LANG_CALL([],[readline])],
3792 [py_cv_lib_readline=yes])
3793 if test $py_cv_lib_readline = yes; then
3794 break
3795 fi
3796done
3797# Uncomment this line if you want to use READINE_LIBS in Makefile or scripts
3798#AC_SUBST([READLINE_LIBS])
Gregory P. Smith29ec7502008-09-07 19:18:16 +00003799if test $py_cv_lib_readline = no; then
Gregory P. Smith980b99b2008-09-07 05:15:18 +00003800 AC_MSG_RESULT([none])
3801else
3802 AC_MSG_RESULT([$READLINE_LIBS])
3803 AC_DEFINE(HAVE_LIBREADLINE, 1,
3804 [Define if you have the readline library (-lreadline).])
Neal Norwitzfe8e3d92006-01-07 21:07:20 +00003805fi
3806
Michael W. Hudson30ea2f22004-07-07 17:44:12 +00003807# check for readline 2.1
3808AC_CHECK_LIB(readline, rl_callback_handler_install,
3809 AC_DEFINE(HAVE_RL_CALLBACK, 1,
Gregory P. Smithff7b2d52008-09-03 05:57:48 +00003810 [Define if you have readline 2.1]), ,$READLINE_LIBS)
Michael W. Hudson30ea2f22004-07-07 17:44:12 +00003811
Guido van Rossumfaf5e4d2002-12-30 16:25:41 +00003812# check for readline 2.2
3813AC_TRY_CPP([#include <readline/readline.h>],
3814have_readline=yes, have_readline=no)
3815if test $have_readline = yes
3816then
3817 AC_EGREP_HEADER([extern int rl_completion_append_character;],
3818 [readline/readline.h],
3819 AC_DEFINE(HAVE_RL_COMPLETION_APPEND_CHARACTER, 1,
3820 [Define if you have readline 2.2]), )
Antoine Pitroud9ff74e2009-10-26 19:16:46 +00003821 AC_EGREP_HEADER([extern int rl_completion_suppress_append;],
3822 [readline/readline.h],
3823 AC_DEFINE(HAVE_RL_COMPLETION_SUPPRESS_APPEND, 1,
3824 [Define if you have rl_completion_suppress_append]), )
Guido van Rossumfaf5e4d2002-12-30 16:25:41 +00003825fi
3826
Martin v. Löwis0daad592001-09-30 21:09:59 +00003827# check for readline 4.0
3828AC_CHECK_LIB(readline, rl_pre_input_hook,
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003829 AC_DEFINE(HAVE_RL_PRE_INPUT_HOOK, 1,
Gregory P. Smithff7b2d52008-09-03 05:57:48 +00003830 [Define if you have readline 4.0]), ,$READLINE_LIBS)
Martin v. Löwis0daad592001-09-30 21:09:59 +00003831
Martin v. Löwis58bd49f2007-09-04 13:13:14 +00003832# also in 4.0
3833AC_CHECK_LIB(readline, rl_completion_display_matches_hook,
3834 AC_DEFINE(HAVE_RL_COMPLETION_DISPLAY_MATCHES_HOOK, 1,
Gregory P. Smithff7b2d52008-09-03 05:57:48 +00003835 [Define if you have readline 4.0]), ,$READLINE_LIBS)
Martin v. Löwis58bd49f2007-09-04 13:13:14 +00003836
Guido van Rossum353ae582001-07-10 16:45:32 +00003837# check for readline 4.2
3838AC_CHECK_LIB(readline, rl_completion_matches,
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003839 AC_DEFINE(HAVE_RL_COMPLETION_MATCHES, 1,
Gregory P. Smithff7b2d52008-09-03 05:57:48 +00003840 [Define if you have readline 4.2]), ,$READLINE_LIBS)
Guido van Rossum353ae582001-07-10 16:45:32 +00003841
Michael W. Hudson30ea2f22004-07-07 17:44:12 +00003842# also in readline 4.2
3843AC_TRY_CPP([#include <readline/readline.h>],
3844have_readline=yes, have_readline=no)
3845if test $have_readline = yes
3846then
3847 AC_EGREP_HEADER([extern int rl_catch_signals;],
3848 [readline/readline.h],
3849 AC_DEFINE(HAVE_RL_CATCH_SIGNAL, 1,
3850 [Define if you can turn off readline's signal handling.]), )
3851fi
3852
Martin v. Löwis82bca632006-02-10 20:49:30 +00003853# End of readline checks: restore LIBS
3854LIBS=$LIBS_no_readline
3855
Thomas Wouterse38b2f12001-07-11 22:35:31 +00003856AC_MSG_CHECKING(for broken nice())
3857AC_CACHE_VAL(ac_cv_broken_nice, [
3858AC_TRY_RUN([
3859int main()
3860{
3861 int val1 = nice(1);
3862 if (val1 != -1 && val1 == nice(2))
3863 exit(0);
3864 exit(1);
3865}
Guido van Rossum3065c942001-09-17 04:03:14 +00003866],
3867ac_cv_broken_nice=yes,
3868ac_cv_broken_nice=no,
3869ac_cv_broken_nice=no)])
Thomas Wouterse38b2f12001-07-11 22:35:31 +00003870AC_MSG_RESULT($ac_cv_broken_nice)
3871if test "$ac_cv_broken_nice" = yes
3872then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003873 AC_DEFINE(HAVE_BROKEN_NICE, 1,
3874 [Define if nice() returns success/failure instead of the new priority.])
Thomas Wouterse38b2f12001-07-11 22:35:31 +00003875fi
3876
Nicholas Bastine62c5c82004-03-21 23:45:42 +00003877AC_MSG_CHECKING(for broken poll())
Alexandre Vassalotti00900892009-07-17 05:26:39 +00003878AC_CACHE_VAL(ac_cv_broken_poll,
Nicholas Bastine62c5c82004-03-21 23:45:42 +00003879AC_TRY_RUN([
3880#include <poll.h>
3881
Alexandre Vassalotti66da2632009-07-17 06:17:33 +00003882int main()
3883{
Nicholas Bastine62c5c82004-03-21 23:45:42 +00003884 struct pollfd poll_struct = { 42, POLLIN|POLLPRI|POLLOUT, 0 };
Alexandre Vassalotti66da2632009-07-17 06:17:33 +00003885 int poll_test;
3886
Nicholas Bastine62c5c82004-03-21 23:45:42 +00003887 close (42);
3888
Alexandre Vassalotti66da2632009-07-17 06:17:33 +00003889 poll_test = poll(&poll_struct, 1, 0);
Nicholas Bastine62c5c82004-03-21 23:45:42 +00003890 if (poll_test < 0)
Alexandre Vassalotti66da2632009-07-17 06:17:33 +00003891 return 0;
Nicholas Bastine62c5c82004-03-21 23:45:42 +00003892 else if (poll_test == 0 && poll_struct.revents != POLLNVAL)
Alexandre Vassalotti66da2632009-07-17 06:17:33 +00003893 return 0;
Nicholas Bastine62c5c82004-03-21 23:45:42 +00003894 else
Alexandre Vassalotti66da2632009-07-17 06:17:33 +00003895 return 1;
3896}
Nicholas Bastine62c5c82004-03-21 23:45:42 +00003897],
3898ac_cv_broken_poll=yes,
3899ac_cv_broken_poll=no,
Alexandre Vassalotti00900892009-07-17 05:26:39 +00003900ac_cv_broken_poll=no))
Nicholas Bastine62c5c82004-03-21 23:45:42 +00003901AC_MSG_RESULT($ac_cv_broken_poll)
3902if test "$ac_cv_broken_poll" = yes
3903then
3904 AC_DEFINE(HAVE_BROKEN_POLL, 1,
3905 [Define if poll() sets errno on invalid file descriptors.])
3906fi
3907
Brett Cannon43802422005-02-10 20:48:03 +00003908# Before we can test tzset, we need to check if struct tm has a tm_zone
3909# (which is not required by ISO C or UNIX spec) and/or if we support
3910# tzname[]
3911AC_STRUCT_TIMEZONE
Nicholas Bastine62c5c82004-03-21 23:45:42 +00003912
Brett Cannon43802422005-02-10 20:48:03 +00003913# check tzset(3) exists and works like we expect it to
Guido van Rossumd11b62e2003-03-14 21:51:36 +00003914AC_MSG_CHECKING(for working tzset())
3915AC_CACHE_VAL(ac_cv_working_tzset, [
3916AC_TRY_RUN([
3917#include <stdlib.h>
3918#include <time.h>
Brett Cannon18367812003-09-19 00:59:16 +00003919#include <string.h>
Brett Cannon43802422005-02-10 20:48:03 +00003920
3921#if HAVE_TZNAME
3922extern char *tzname[];
3923#endif
3924
Guido van Rossumd11b62e2003-03-14 21:51:36 +00003925int main()
3926{
Brett Cannon18367812003-09-19 00:59:16 +00003927 /* Note that we need to ensure that not only does tzset(3)
3928 do 'something' with localtime, but it works as documented
3929 in the library reference and as expected by the test suite.
Brett Cannon43802422005-02-10 20:48:03 +00003930 This includes making sure that tzname is set properly if
3931 tm->tm_zone does not exist since it is the alternative way
3932 of getting timezone info.
Brett Cannon18367812003-09-19 00:59:16 +00003933
3934 Red Hat 6.2 doesn't understand the southern hemisphere
Brett Cannon43802422005-02-10 20:48:03 +00003935 after New Year's Day.
Brett Cannon18367812003-09-19 00:59:16 +00003936 */
3937
Brett Cannon43802422005-02-10 20:48:03 +00003938 time_t groundhogday = 1044144000; /* GMT-based */
Brett Cannon18367812003-09-19 00:59:16 +00003939 time_t midyear = groundhogday + (365 * 24 * 3600 / 2);
3940
Neal Norwitz7f2588c2003-04-11 15:35:53 +00003941 putenv("TZ=UTC+0");
Guido van Rossumd11b62e2003-03-14 21:51:36 +00003942 tzset();
Brett Cannon18367812003-09-19 00:59:16 +00003943 if (localtime(&groundhogday)->tm_hour != 0)
3944 exit(1);
Brett Cannon43802422005-02-10 20:48:03 +00003945#if HAVE_TZNAME
3946 /* For UTC, tzname[1] is sometimes "", sometimes " " */
3947 if (strcmp(tzname[0], "UTC") ||
3948 (tzname[1][0] != 0 && tzname[1][0] != ' '))
3949 exit(1);
3950#endif
Brett Cannon18367812003-09-19 00:59:16 +00003951
Neal Norwitz7f2588c2003-04-11 15:35:53 +00003952 putenv("TZ=EST+5EDT,M4.1.0,M10.5.0");
Guido van Rossumd11b62e2003-03-14 21:51:36 +00003953 tzset();
Brett Cannon18367812003-09-19 00:59:16 +00003954 if (localtime(&groundhogday)->tm_hour != 19)
Guido van Rossumd11b62e2003-03-14 21:51:36 +00003955 exit(1);
Brett Cannon43802422005-02-10 20:48:03 +00003956#if HAVE_TZNAME
3957 if (strcmp(tzname[0], "EST") || strcmp(tzname[1], "EDT"))
3958 exit(1);
3959#endif
Brett Cannon18367812003-09-19 00:59:16 +00003960
3961 putenv("TZ=AEST-10AEDT-11,M10.5.0,M3.5.0");
3962 tzset();
3963 if (localtime(&groundhogday)->tm_hour != 11)
3964 exit(1);
Brett Cannon43802422005-02-10 20:48:03 +00003965#if HAVE_TZNAME
3966 if (strcmp(tzname[0], "AEST") || strcmp(tzname[1], "AEDT"))
3967 exit(1);
3968#endif
3969
3970#if HAVE_STRUCT_TM_TM_ZONE
Brett Cannon18367812003-09-19 00:59:16 +00003971 if (strcmp(localtime(&groundhogday)->tm_zone, "AEDT"))
3972 exit(1);
3973 if (strcmp(localtime(&midyear)->tm_zone, "AEST"))
3974 exit(1);
Brett Cannon43802422005-02-10 20:48:03 +00003975#endif
Brett Cannon18367812003-09-19 00:59:16 +00003976
Guido van Rossumd11b62e2003-03-14 21:51:36 +00003977 exit(0);
3978}
3979],
3980ac_cv_working_tzset=yes,
3981ac_cv_working_tzset=no,
3982ac_cv_working_tzset=no)])
3983AC_MSG_RESULT($ac_cv_working_tzset)
3984if test "$ac_cv_working_tzset" = yes
3985then
3986 AC_DEFINE(HAVE_WORKING_TZSET, 1,
3987 [Define if tzset() actually switches the local timezone in a meaningful way.])
3988fi
3989
Martin v. Löwis94717ed2002-09-09 14:24:16 +00003990# Look for subsecond timestamps in struct stat
3991AC_MSG_CHECKING(for tv_nsec in struct stat)
3992AC_CACHE_VAL(ac_cv_stat_tv_nsec,
3993AC_TRY_COMPILE([#include <sys/stat.h>], [
3994struct stat st;
3995st.st_mtim.tv_nsec = 1;
3996],
Martin v. Löwisa32c9942002-09-09 16:17:47 +00003997ac_cv_stat_tv_nsec=yes,
Martin v. Löwis94717ed2002-09-09 14:24:16 +00003998ac_cv_stat_tv_nsec=no,
3999ac_cv_stat_tv_nsec=no))
4000AC_MSG_RESULT($ac_cv_stat_tv_nsec)
4001if test "$ac_cv_stat_tv_nsec" = yes
4002then
4003 AC_DEFINE(HAVE_STAT_TV_NSEC, 1,
4004 [Define if you have struct stat.st_mtim.tv_nsec])
4005fi
4006
Martin v. Löwisebd9d5b2005-08-09 15:00:59 +00004007# Look for BSD style subsecond timestamps in struct stat
4008AC_MSG_CHECKING(for tv_nsec2 in struct stat)
4009AC_CACHE_VAL(ac_cv_stat_tv_nsec2,
4010AC_TRY_COMPILE([#include <sys/stat.h>], [
4011struct stat st;
4012st.st_mtimespec.tv_nsec = 1;
4013],
4014ac_cv_stat_tv_nsec2=yes,
4015ac_cv_stat_tv_nsec2=no,
4016ac_cv_stat_tv_nsec2=no))
4017AC_MSG_RESULT($ac_cv_stat_tv_nsec2)
4018if test "$ac_cv_stat_tv_nsec2" = yes
4019then
4020 AC_DEFINE(HAVE_STAT_TV_NSEC2, 1,
4021 [Define if you have struct stat.st_mtimensec])
4022fi
4023
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00004024# On HP/UX 11.0, mvwdelch is a block with a return statement
4025AC_MSG_CHECKING(whether mvwdelch is an expression)
4026AC_CACHE_VAL(ac_cv_mvwdelch_is_expression,
4027AC_TRY_COMPILE([#include <curses.h>], [
4028 int rtn;
4029 rtn = mvwdelch(0,0,0);
4030], ac_cv_mvwdelch_is_expression=yes,
4031 ac_cv_mvwdelch_is_expression=no,
4032 ac_cv_mvwdelch_is_expression=yes))
4033AC_MSG_RESULT($ac_cv_mvwdelch_is_expression)
4034
4035if test "$ac_cv_mvwdelch_is_expression" = yes
4036then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00004037 AC_DEFINE(MVWDELCH_IS_EXPRESSION, 1,
4038 [Define if mvwdelch in curses.h is an expression.])
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00004039fi
4040
4041AC_MSG_CHECKING(whether WINDOW has _flags)
4042AC_CACHE_VAL(ac_cv_window_has_flags,
4043AC_TRY_COMPILE([#include <curses.h>], [
4044 WINDOW *w;
4045 w->_flags = 0;
4046], ac_cv_window_has_flags=yes,
4047 ac_cv_window_has_flags=no,
4048 ac_cv_window_has_flags=no))
4049AC_MSG_RESULT($ac_cv_window_has_flags)
4050
4051
4052if test "$ac_cv_window_has_flags" = yes
4053then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00004054 AC_DEFINE(WINDOW_HAS_FLAGS, 1,
4055 [Define if WINDOW in curses.h offers a field _flags.])
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00004056fi
4057
Walter Dörwald4994d952006-06-19 08:07:50 +00004058AC_MSG_CHECKING(for is_term_resized)
4059AC_TRY_COMPILE([#include <curses.h>], void *x=is_term_resized,
4060 AC_DEFINE(HAVE_CURSES_IS_TERM_RESIZED, 1, Define if you have the 'is_term_resized' function.)
4061 AC_MSG_RESULT(yes),
4062 AC_MSG_RESULT(no)
4063)
4064
Walter Dörwald05fdbf12006-06-19 08:14:09 +00004065AC_MSG_CHECKING(for resize_term)
4066AC_TRY_COMPILE([#include <curses.h>], void *x=resize_term,
4067 AC_DEFINE(HAVE_CURSES_RESIZE_TERM, 1, Define if you have the 'resize_term' function.)
Walter Dörwald4994d952006-06-19 08:07:50 +00004068 AC_MSG_RESULT(yes),
4069 AC_MSG_RESULT(no)
4070)
4071
Walter Dörwald05fdbf12006-06-19 08:14:09 +00004072AC_MSG_CHECKING(for resizeterm)
4073AC_TRY_COMPILE([#include <curses.h>], void *x=resizeterm,
4074 AC_DEFINE(HAVE_CURSES_RESIZETERM, 1, Define if you have the 'resizeterm' function.)
Walter Dörwald4994d952006-06-19 08:07:50 +00004075 AC_MSG_RESULT(yes),
4076 AC_MSG_RESULT(no)
4077)
4078
Martin v. Löwisfefbc202006-10-17 18:59:23 +00004079AC_MSG_CHECKING(for /dev/ptmx)
4080
4081if test -r /dev/ptmx
4082then
4083 AC_MSG_RESULT(yes)
4084 AC_DEFINE(HAVE_DEV_PTMX, 1,
4085 [Define if we have /dev/ptmx.])
4086else
4087 AC_MSG_RESULT(no)
4088fi
4089
4090AC_MSG_CHECKING(for /dev/ptc)
4091
4092if test -r /dev/ptc
4093then
4094 AC_MSG_RESULT(yes)
4095 AC_DEFINE(HAVE_DEV_PTC, 1,
4096 [Define if we have /dev/ptc.])
4097else
4098 AC_MSG_RESULT(no)
4099fi
Neal Norwitz865400f2003-03-21 01:42:58 +00004100
Mark Dickinson82864d12009-11-15 16:18:58 +00004101if test "$have_long_long" = yes
4102then
4103 AC_MSG_CHECKING(for %lld and %llu printf() format support)
4104 AC_CACHE_VAL(ac_cv_have_long_long_format,
4105 AC_TRY_RUN([[
4106 #include <stdio.h>
4107 #include <stddef.h>
4108 #include <string.h>
4109
4110 #ifdef HAVE_SYS_TYPES_H
4111 #include <sys/types.h>
4112 #endif
4113
4114 int main()
4115 {
4116 char buffer[256];
4117
4118 if (sprintf(buffer, "%lld", (long long)123) < 0)
4119 return 1;
4120 if (strcmp(buffer, "123"))
4121 return 1;
4122
4123 if (sprintf(buffer, "%lld", (long long)-123) < 0)
4124 return 1;
4125 if (strcmp(buffer, "-123"))
4126 return 1;
4127
4128 if (sprintf(buffer, "%llu", (unsigned long long)123) < 0)
4129 return 1;
4130 if (strcmp(buffer, "123"))
4131 return 1;
4132
4133 return 0;
4134 }
4135 ]], ac_cv_have_long_long_format=yes,
4136 ac_cv_have_long_long_format=no,
4137 ac_cv_have_long_long_format=no)
4138 )
4139 AC_MSG_RESULT($ac_cv_have_long_long_format)
4140fi
4141
Mark Dickinson5ce84742009-12-31 20:48:04 +00004142if test "$ac_cv_have_long_long_format" = yes
Mark Dickinson82864d12009-11-15 16:18:58 +00004143then
4144 AC_DEFINE(PY_FORMAT_LONG_LONG, "ll",
4145 [Define to printf format modifier for long long type])
4146fi
4147
Ronald Oussoren315cd0c2009-11-19 16:25:21 +00004148if test $ac_sys_system = Darwin
4149then
4150 LIBS="$LIBS -framework CoreFoundation"
4151fi
4152
Mark Dickinson82864d12009-11-15 16:18:58 +00004153
Gregory P. Smithd8cb2d92009-11-02 02:02:38 +00004154AC_CACHE_CHECK([for %zd printf() format support], ac_cv_have_size_t_format, [dnl
4155AC_TRY_RUN([
Alexandre Vassalottie7cf1182009-07-17 06:33:51 +00004156#include <stdio.h>
Brett Cannon09d12362006-05-11 05:11:33 +00004157#include <stddef.h>
4158#include <string.h>
4159
Christian Heimesdb3d6cb2007-12-16 21:39:43 +00004160#ifdef HAVE_SYS_TYPES_H
4161#include <sys/types.h>
4162#endif
Neal Norwitz4a8fbdb2006-09-22 08:16:26 +00004163
4164#ifdef HAVE_SSIZE_T
4165typedef ssize_t Py_ssize_t;
4166#elif SIZEOF_VOID_P == SIZEOF_LONG
4167typedef long Py_ssize_t;
4168#else
4169typedef int Py_ssize_t;
4170#endif
Brett Cannon09d12362006-05-11 05:11:33 +00004171
Christian Heimesdb3d6cb2007-12-16 21:39:43 +00004172int main()
4173{
4174 char buffer[256];
4175
Brett Cannon09d12362006-05-11 05:11:33 +00004176 if(sprintf(buffer, "%zd", (size_t)123) < 0)
4177 return 1;
4178
Neal Norwitz4a8fbdb2006-09-22 08:16:26 +00004179 if (strcmp(buffer, "123"))
Brett Cannon09d12362006-05-11 05:11:33 +00004180 return 1;
Neal Norwitz4a8fbdb2006-09-22 08:16:26 +00004181
4182 if (sprintf(buffer, "%zd", (Py_ssize_t)-123) < 0)
4183 return 1;
4184
4185 if (strcmp(buffer, "-123"))
4186 return 1;
4187
Brett Cannon09d12362006-05-11 05:11:33 +00004188 return 0;
Alexandre Vassalotti00900892009-07-17 05:26:39 +00004189}
Gregory P. Smithd8cb2d92009-11-02 02:02:38 +00004190], ac_cv_have_size_t_format=yes,
Alexandre Vassalottie7cf1182009-07-17 06:33:51 +00004191 ac_cv_have_size_t_format=no,
Gregory P. Smithd8cb2d92009-11-02 02:02:38 +00004192 [ac_cv_have_size_t_format="cross -- assuming yes"]
4193)])
4194if test "$ac_cv_have_size_t_format" != no ; then
Alexandre Vassalotti00900892009-07-17 05:26:39 +00004195 AC_DEFINE(PY_FORMAT_SIZE_T, "z",
4196 [Define to printf format modifier for Py_ssize_t])
4197fi
Brett Cannon09d12362006-05-11 05:11:33 +00004198
Martin v. Löwis01c04012002-11-11 14:58:44 +00004199AC_CHECK_TYPE(socklen_t,,
4200 AC_DEFINE(socklen_t,int,
4201 Define to `int' if <sys/socket.h> does not define.),[
4202#ifdef HAVE_SYS_TYPES_H
4203#include <sys/types.h>
4204#endif
Guido van Rossum95713eb2000-05-18 20:53:31 +00004205#ifdef HAVE_SYS_SOCKET_H
4206#include <sys/socket.h>
4207#endif
Martin v. Löwis01c04012002-11-11 14:58:44 +00004208])
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00004209
Martin v. Löwis06f15bb2001-12-02 13:02:32 +00004210AC_SUBST(THREADHEADERS)
4211
4212for h in `(cd $srcdir;echo Python/thread_*.h)`
4213do
4214 THREADHEADERS="$THREADHEADERS \$(srcdir)/$h"
4215done
4216
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00004217AC_SUBST(SRCDIRS)
Neal Norwitzd24499d2005-12-18 21:36:39 +00004218SRCDIRS="Parser Grammar Objects Python Modules Mac"
Andrew M. Kuchling8abedde2001-01-26 22:55:24 +00004219AC_MSG_CHECKING(for build directories)
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00004220for dir in $SRCDIRS; do
4221 if test ! -d $dir; then
4222 mkdir $dir
Fred Drake884d3ba2000-11-02 17:52:56 +00004223 fi
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00004224done
4225AC_MSG_RESULT(done)
Fred Drake036144d2000-10-26 17:09:35 +00004226
Guido van Rossum627b2d71993-12-24 10:39:16 +00004227# generate output files
Antoine Pitrouf2caeed2009-05-24 20:23:57 +00004228AC_CONFIG_FILES(Makefile.pre Modules/Setup.config Misc/python.pc)
Martin v. Löwis88afe662002-10-26 13:47:44 +00004229AC_OUTPUT
Neil Schemenauer61c51152001-01-26 16:18:16 +00004230
Martin v. Löwisf7afe952006-04-14 15:16:15 +00004231echo "creating Modules/Setup"
Neil Schemenauer61c51152001-01-26 16:18:16 +00004232if test ! -f Modules/Setup
4233then
4234 cp $srcdir/Modules/Setup.dist Modules/Setup
4235fi
4236
Martin v. Löwisf7afe952006-04-14 15:16:15 +00004237echo "creating Modules/Setup.local"
Neil Schemenauer61c51152001-01-26 16:18:16 +00004238if test ! -f Modules/Setup.local
4239then
4240 echo "# Edit this file for local setup changes" >Modules/Setup.local
4241fi
4242
4243echo "creating Makefile"
4244$SHELL $srcdir/Modules/makesetup -c $srcdir/Modules/config.c.in \
4245 -s Modules Modules/Setup.config \
Neil Schemenauerf8b71c52001-04-21 17:41:16 +00004246 Modules/Setup.local Modules/Setup
Skip Montanaro7221d932007-08-22 19:02:16 +00004247
4248case $ac_sys_system in
4249BeOS)
4250 AC_MSG_WARN([
4251
4252 Support for BeOS is deprecated as of Python 2.6.
4253 See PEP 11 for the gory details.
4254 ])
4255 ;;
4256*) ;;
4257esac
4258
Neil Schemenauer66252162001-02-19 04:47:42 +00004259mv config.c Modules