blob: b1450afa63f352aa5f9df057d96ddb0d9a42b813 [file] [log] [blame]
Benjamin Petersonfbeb6b62008-05-26 16:04:49 +00001dnl ***********************************************
2dnl * Please run autoreconf to test your changes! *
3dnl ***********************************************
Benjamin Peterson4469d0c2008-11-30 22:46: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)
Benjamin Peterson46ea4f72009-06-27 21:40:27 +00007m4_define(PYTHON_VERSION, 3.2)
Martin v. Löwis88afe662002-10-26 13:47:44 +00008
Alexandre Vassalottib89910f2009-07-18 00:33:23 +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 Brandle2e15612009-05-20 18:25:10 +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
Benjamin Petersond23f8222009-04-05 19:13:16 +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
Georg Brandlfcaf9102008-07-16 02:17:56 +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 Oussoren8af24c12010-02-07 12:03:42 +000089AC_MSG_CHECKING([for --enable-universalsdk])
Thomas Wouters477c8d52006-05-27 19:21:47 +000090AC_ARG_ENABLE(universalsdk,
Christian Heimes68f5fbe2008-02-14 08:27:37 +000091 AC_HELP_STRING(--enable-universalsdk@<:@=SDKDIR@:>@, Build against Mac OS X 10.4u SDK (ppc/i386)),
Thomas Wouters477c8d52006-05-27 19:21:47 +000092[
93 case $enableval in
94 yes)
95 enableval=/Developer/SDKs/MacOSX10.4u.sdk
Ronald Oussoren8af24c12010-02-07 12:03:42 +000096 if test ! -d "${enableval}"
97 then
98 enableval=/
99 fi
Thomas Wouters477c8d52006-05-27 19:21:47 +0000100 ;;
101 esac
102 case $enableval in
103 no)
104 UNIVERSALSDK=
105 enable_universalsdk=
106 ;;
107 *)
108 UNIVERSALSDK=$enableval
Ronald Oussoren8af24c12010-02-07 12:03:42 +0000109 if test ! -d "${UNIVERSALSDK}"
110 then
111 AC_MSG_ERROR([--enable-universalsdk specifies non-existing SDK: ${UNIVERSALSDK}])
112 fi
Thomas Wouters477c8d52006-05-27 19:21:47 +0000113 ;;
114 esac
Ronald Oussoren8af24c12010-02-07 12:03:42 +0000115
Thomas Wouters477c8d52006-05-27 19:21:47 +0000116],[
117 UNIVERSALSDK=
118 enable_universalsdk=
119])
Ronald Oussoren8af24c12010-02-07 12:03:42 +0000120if test -n "${UNIVERSALSDK}"
121then
122 AC_MSG_RESULT(${UNIVERSALSDK})
123else
124 AC_MSG_RESULT(no)
125fi
Thomas Wouters477c8d52006-05-27 19:21:47 +0000126AC_SUBST(UNIVERSALSDK)
127
Benjamin Peterson6794aa32008-07-16 20:33:37 +0000128AC_SUBST(ARCH_RUN_32BIT)
129
Georg Brandlfcaf9102008-07-16 02:17:56 +0000130UNIVERSAL_ARCHS="32-bit"
Ronald Oussoren6f6c5622009-12-24 14:03:19 +0000131AC_SUBST(LIPO_32BIT_FLAGS)
Georg Brandlfcaf9102008-07-16 02:17:56 +0000132AC_MSG_CHECKING(for --with-universal-archs)
133AC_ARG_WITH(universal-archs,
Ronald Oussoren3c064c12009-09-08 07:12:42 +0000134 AC_HELP_STRING(--with-universal-archs=ARCH, select architectures for universal build ("32-bit", "64-bit", "3-way", "intel" or "all")),
Georg Brandlfcaf9102008-07-16 02:17:56 +0000135[
136 AC_MSG_RESULT($withval)
137 UNIVERSAL_ARCHS="$withval"
138],
139[
140 AC_MSG_RESULT(32-bit)
141])
142
143
144
Christian Heimes81ee3ef2008-05-04 22:42:01 +0000145AC_ARG_WITH(framework-name,
146 AC_HELP_STRING(--with-framework-name=FRAMEWORK,
147 specify an alternate name of the framework built with --enable-framework),
148[
149 PYTHONFRAMEWORK=${withval}
150 PYTHONFRAMEWORKDIR=${withval}.framework
151 PYTHONFRAMEWORKIDENTIFIER=org.python.`echo $withval | tr '[A-Z]' '[a-z]'`
152 ],[
153 PYTHONFRAMEWORK=Python
154 PYTHONFRAMEWORKDIR=Python.framework
155 PYTHONFRAMEWORKIDENTIFIER=org.python.python
156])
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000157dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000158AC_ARG_ENABLE(framework,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000159 AC_HELP_STRING(--enable-framework@<:@=INSTALLDIR@:>@, Build (MacOSX|Darwin) framework),
160[
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000161 case $enableval in
162 yes)
163 enableval=/Library/Frameworks
Jack Jansen127e56e2001-09-11 14:41:54 +0000164 esac
165 case $enableval in
166 no)
167 PYTHONFRAMEWORK=
168 PYTHONFRAMEWORKDIR=no-framework
169 PYTHONFRAMEWORKPREFIX=
170 PYTHONFRAMEWORKINSTALLDIR=
Thomas Wouters477c8d52006-05-27 19:21:47 +0000171 FRAMEWORKINSTALLFIRST=
172 FRAMEWORKINSTALLLAST=
Thomas Wouters73e5a5b2006-06-08 15:35:45 +0000173 FRAMEWORKALTINSTALLFIRST=
174 FRAMEWORKALTINSTALLLAST=
175 if test "x${prefix}" = "xNONE"; then
176 FRAMEWORKUNIXTOOLSPREFIX="${ac_default_prefix}"
177 else
178 FRAMEWORKUNIXTOOLSPREFIX="${prefix}"
179 fi
Jack Jansen127e56e2001-09-11 14:41:54 +0000180 enable_framework=
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000181 ;;
182 *)
183 PYTHONFRAMEWORKPREFIX=$enableval
Jack Jansen127e56e2001-09-11 14:41:54 +0000184 PYTHONFRAMEWORKINSTALLDIR=$PYTHONFRAMEWORKPREFIX/$PYTHONFRAMEWORKDIR
Thomas Wouters477c8d52006-05-27 19:21:47 +0000185 FRAMEWORKINSTALLFIRST="frameworkinstallstructure"
Ronald Oussorenf6ccbf62009-06-02 10:55:56 +0000186 FRAMEWORKALTINSTALLFIRST="frameworkinstallstructure "
Ronald Oussoren6f6c5622009-12-24 14:03:19 +0000187 FRAMEWORKINSTALLLAST="frameworkinstallmaclib frameworkinstallapps frameworkinstallunixtools"
188 FRAMEWORKALTINSTALLLAST="frameworkinstallmaclib frameworkinstallapps frameworkaltinstallunixtools"
Georg Brandlfcaf9102008-07-16 02:17:56 +0000189
Thomas Wouters73e5a5b2006-06-08 15:35:45 +0000190 if test "x${prefix}" = "xNONE" ; then
191 FRAMEWORKUNIXTOOLSPREFIX="${ac_default_prefix}"
192 else
193 FRAMEWORKUNIXTOOLSPREFIX="${prefix}"
194 fi
Jack Jansen127e56e2001-09-11 14:41:54 +0000195 prefix=$PYTHONFRAMEWORKINSTALLDIR/Versions/$VERSION
Thomas Wouters477c8d52006-05-27 19:21:47 +0000196
Christian Heimes81ee3ef2008-05-04 22:42:01 +0000197 # Add files for Mac specific code to the list of output
Thomas Wouters477c8d52006-05-27 19:21:47 +0000198 # files:
Thomas Wouters73e5a5b2006-06-08 15:35:45 +0000199 AC_CONFIG_FILES(Mac/Makefile)
200 AC_CONFIG_FILES(Mac/PythonLauncher/Makefile)
Christian Heimes81ee3ef2008-05-04 22:42:01 +0000201 AC_CONFIG_FILES(Mac/Resources/framework/Info.plist)
202 AC_CONFIG_FILES(Mac/Resources/app/Info.plist)
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000203 esac
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000204 ],[
205 PYTHONFRAMEWORK=
Jack Jansen127e56e2001-09-11 14:41:54 +0000206 PYTHONFRAMEWORKDIR=no-framework
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000207 PYTHONFRAMEWORKPREFIX=
208 PYTHONFRAMEWORKINSTALLDIR=
Thomas Wouters477c8d52006-05-27 19:21:47 +0000209 FRAMEWORKINSTALLFIRST=
210 FRAMEWORKINSTALLLAST=
Thomas Wouters73e5a5b2006-06-08 15:35:45 +0000211 FRAMEWORKALTINSTALLFIRST=
212 FRAMEWORKALTINSTALLLAST=
213 if test "x${prefix}" = "xNONE" ; then
214 FRAMEWORKUNIXTOOLSPREFIX="${ac_default_prefix}"
215 else
216 FRAMEWORKUNIXTOOLSPREFIX="${prefix}"
217 fi
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000218 enable_framework=
Georg Brandlfcaf9102008-07-16 02:17:56 +0000219
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000220])
221AC_SUBST(PYTHONFRAMEWORK)
Christian Heimes81ee3ef2008-05-04 22:42:01 +0000222AC_SUBST(PYTHONFRAMEWORKIDENTIFIER)
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000223AC_SUBST(PYTHONFRAMEWORKDIR)
224AC_SUBST(PYTHONFRAMEWORKPREFIX)
225AC_SUBST(PYTHONFRAMEWORKINSTALLDIR)
Thomas Wouters477c8d52006-05-27 19:21:47 +0000226AC_SUBST(FRAMEWORKINSTALLFIRST)
227AC_SUBST(FRAMEWORKINSTALLLAST)
Thomas Wouters73e5a5b2006-06-08 15:35:45 +0000228AC_SUBST(FRAMEWORKALTINSTALLFIRST)
229AC_SUBST(FRAMEWORKALTINSTALLLAST)
230AC_SUBST(FRAMEWORKUNIXTOOLSPREFIX)
Guido van Rossum4b6b5791996-09-09 20:09:34 +0000231
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000232##AC_ARG_WITH(dyld,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000233## AC_HELP_STRING(--with-dyld,
234## Use (OpenStep|Rhapsody) dynamic linker))
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000235##
Guido van Rossumb418f891996-07-30 18:06:02 +0000236# Set name for machine-dependent library files
237AC_SUBST(MACHDEP)
238AC_MSG_CHECKING(MACHDEP)
239if test -z "$MACHDEP"
240then
Guido van Rossum4b6b5791996-09-09 20:09:34 +0000241 ac_sys_system=`uname -s`
Benjamin Peterson8719ad52009-09-11 22:24:02 +0000242 if test "$ac_sys_system" = "AIX" \
Martin v. Löwis21ee4092002-09-30 16:19:48 +0000243 -o "$ac_sys_system" = "UnixWare" -o "$ac_sys_system" = "OpenUNIX"; then
Guido van Rossum4b6b5791996-09-09 20:09:34 +0000244 ac_sys_release=`uname -v`
Guido van Rossumb418f891996-07-30 18:06:02 +0000245 else
Guido van Rossum4b6b5791996-09-09 20:09:34 +0000246 ac_sys_release=`uname -r`
Guido van Rossumb418f891996-07-30 18:06:02 +0000247 fi
Guido van Rossum4b6b5791996-09-09 20:09:34 +0000248 ac_md_system=`echo $ac_sys_system |
249 tr -d '[/ ]' | tr '[[A-Z]]' '[[a-z]]'`
250 ac_md_release=`echo $ac_sys_release |
Guido van Rossum67b26592001-10-20 14:21:45 +0000251 tr -d '[/ ]' | sed 's/^[[A-Z]]\.//' | sed 's/\..*//'`
Guido van Rossumb97ef171997-09-28 05:44:03 +0000252 MACHDEP="$ac_md_system$ac_md_release"
Guido van Rossum4b6b5791996-09-09 20:09:34 +0000253
Guido van Rossumbcd91e01997-03-20 20:46:29 +0000254 case $MACHDEP in
Andrew M. Kuchling5a3e4cb2001-07-20 19:29:04 +0000255 cygwin*) MACHDEP="cygwin";;
Jack Jansen8a97f4a2001-12-05 23:27:32 +0000256 darwin*) MACHDEP="darwin";;
Martin v. Löwisf3322282003-07-13 09:46:13 +0000257 irix646) MACHDEP="irix6";;
Guido van Rossumb97ef171997-09-28 05:44:03 +0000258 '') MACHDEP="unknown";;
Guido van Rossumb418f891996-07-30 18:06:02 +0000259 esac
260fi
Jack Jansen83f898c2002-12-30 22:23:40 +0000261
Martin v. Löwise981a4e2002-11-11 13:26:51 +0000262# Some systems cannot stand _XOPEN_SOURCE being defined at all; they
263# disable features if it is defined, without any means to access these
264# features as extensions. For these systems, we skip the definition of
265# _XOPEN_SOURCE. Before adding a system to the list to gain access to
266# some feature, make sure there is no alternative way to access this
267# feature. Also, when using wildcards, make sure you have verified the
268# need for not defining _XOPEN_SOURCE on all systems matching the
269# wildcard, and that the wildcard does not include future systems
270# (which may remove their limitations).
271dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
272case $ac_sys_system/$ac_sys_release in
273 # On OpenBSD, select(2) is not available if _XOPEN_SOURCE is defined,
274 # even though select is a POSIX function. Reported by J. Ribbens.
Martin v. Löwis76bafc62003-10-03 13:47:44 +0000275 # Reconfirmed for OpenBSD 3.3 by Zachary Hamm, for 3.4 by Jason Ish.
Martin v. Löwis19ed3c82010-02-15 21:45:06 +0000276 # In addition, Stefan Krah confirms that issue #1244610 exists through
277 # OpenBSD 4.6, but is fixed in 4.7.
278 OpenBSD/2.* | OpenBSD/3.@<:@0123456789@:>@ | OpenBSD/4.@<:@0123456@:>@)
Christian Heimes5b5e81c2007-12-31 16:14:33 +0000279 define_xopen_source=no
280 # OpenBSD undoes our definition of __BSD_VISIBLE if _XOPEN_SOURCE is
281 # also defined. This can be overridden by defining _BSD_SOURCE
282 # As this has a different meaning on Linux, only define it on OpenBSD
283 AC_DEFINE(_BSD_SOURCE, 1, [Define on OpenBSD to activate all library features])
284 ;;
Martin v. Löwis19ed3c82010-02-15 21:45:06 +0000285 OpenBSD/4.@<:@789@:>@)
Martin v. Löwis7671efc2010-02-15 08:35:16 +0000286 # OpenBSD undoes our definition of __BSD_VISIBLE if _XOPEN_SOURCE is
287 # also defined. This can be overridden by defining _BSD_SOURCE
288 # As this has a different meaning on Linux, only define it on OpenBSD
289 AC_DEFINE(_BSD_SOURCE, 1, [Define on OpenBSD to activate all library features])
290 ;;
Thomas Wouters89f507f2006-12-13 04:49:30 +0000291 # Defining _XOPEN_SOURCE on NetBSD version prior to the introduction of
292 # _NETBSD_SOURCE disables certain features (eg. setgroups). Reported by
293 # Marc Recht
Benjamin Petersonf608c612008-11-16 18:33:53 +0000294 NetBSD/1.5 | NetBSD/1.5.* | NetBSD/1.6 | NetBSD/1.6.* | NetBSD/1.6@<:@A-S@:>@)
Martin v. Löwise981a4e2002-11-11 13:26:51 +0000295 define_xopen_source=no;;
Martin v. Löwisa9d71422003-03-28 18:43:31 +0000296 # On Solaris 2.6, sys/wait.h is inconsistent in the usage
297 # of union __?sigval. Reported by Stuart Bishop.
298 SunOS/5.6)
299 define_xopen_source=no;;
Martin v. Löwisc2409b42003-05-11 05:53:41 +0000300 # On UnixWare 7, u_long is never defined with _XOPEN_SOURCE,
301 # but used in /usr/include/netinet/tcp.h. Reported by Tim Rice.
Martin v. Löwis253d1f42004-05-07 19:14:14 +0000302 # Reconfirmed for 7.1.4 by Martin v. Loewis.
303 OpenUNIX/8.0.0| UnixWare/7.1.@<:@0-4@:>@)
Martin v. Löwisc2409b42003-05-11 05:53:41 +0000304 define_xopen_source=no;;
305 # On OpenServer 5, u_short is never defined with _XOPEN_SOURCE,
Martin v. Löwis53e73c32003-05-05 05:13:18 +0000306 # but used in struct sockaddr.sa_family. Reported by Tim Rice.
Martin v. Löwisc2409b42003-05-11 05:53:41 +0000307 SCO_SV/3.2)
Martin v. Löwis53e73c32003-05-05 05:13:18 +0000308 define_xopen_source=no;;
Martin v. Löwisb37509b2008-11-04 20:45:29 +0000309 # On FreeBSD 4, the math functions C89 does not cover are never defined
310 # with _XOPEN_SOURCE and __BSD_VISIBLE does not re-enable them.
311 FreeBSD/4.*)
312 define_xopen_source=no;;
313 # On MacOS X 10.2, a bug in ncurses.h means that it craps out if
314 # _XOPEN_EXTENDED_SOURCE is defined. Apparently, this is fixed in 10.3, which
315 # identifies itself as Darwin/7.*
316 # On Mac OS X 10.4, defining _POSIX_C_SOURCE or _XOPEN_SOURCE
317 # disables platform specific features beyond repair.
318 # On Mac OS X 10.3, defining _POSIX_C_SOURCE or _XOPEN_SOURCE
319 # has no effect, don't bother defining them
320 Darwin/@<:@6789@:>@.*)
Anthony Baxter6169c6b2003-10-04 07:46:23 +0000321 define_xopen_source=no;;
Ronald Oussorenb8f11a62010-03-08 07:02:03 +0000322 Darwin/1@<:@6789@:>@.*)
323 define_xopen_source=no;;
Trent Mickaf16e8c2004-08-25 23:55:59 +0000324 # On AIX 4 and 5.1, mbstate_t is defined only when _XOPEN_SOURCE == 500 but
325 # used in wcsnrtombs() and mbsnrtowcs() even if _XOPEN_SOURCE is not defined
326 # or has another value. By not (re)defining it, the defaults come in place.
Martin v. Löwisc19c5a62003-11-18 20:00:44 +0000327 AIX/4)
328 define_xopen_source=no;;
Trent Mickaf16e8c2004-08-25 23:55:59 +0000329 AIX/5)
330 if test `uname -r` -eq 1; then
331 define_xopen_source=no
332 fi
333 ;;
Georg Brandlf78e02b2008-06-10 17:40:04 +0000334 # On QNX 6.3.2, defining _XOPEN_SOURCE prevents netdb.h from
335 # defining NI_NUMERICHOST.
336 QNX/6.3.2)
337 define_xopen_source=no
338 ;;
Bob Ippolito7026a0a2005-03-28 23:23:47 +0000339
Martin v. Löwise981a4e2002-11-11 13:26:51 +0000340esac
341
342if test $define_xopen_source = yes
343then
Skip Montanarof0d5f792004-08-15 14:08:23 +0000344 # On Solaris w/ g++ it appears that _XOPEN_SOURCE has to be
345 # defined precisely as g++ defines it
Martin v. Löwis7dece662005-11-26 11:38:24 +0000346 # Furthermore, on Solaris 10, XPG6 requires the use of a C99
347 # compiler
Skip Montanarof0d5f792004-08-15 14:08:23 +0000348 case $ac_sys_system/$ac_sys_release in
Martin v. Löwis7dece662005-11-26 11:38:24 +0000349 SunOS/5.8|SunOS/5.9|SunOS/5.10)
Skip Montanarof0d5f792004-08-15 14:08:23 +0000350 AC_DEFINE(_XOPEN_SOURCE, 500,
351 Define to the level of X/Open that your system supports)
352 ;;
353 *)
354 AC_DEFINE(_XOPEN_SOURCE, 600,
355 Define to the level of X/Open that your system supports)
356 ;;
357 esac
Martin v. Löwis678fc1e2002-11-12 06:04:39 +0000358
359 # On Tru64 Unix 4.0F, defining _XOPEN_SOURCE also requires
360 # definition of _XOPEN_SOURCE_EXTENDED and _POSIX_C_SOURCE, or else
361 # several APIs are not declared. Since this is also needed in some
362 # cases for HP-UX, we define it globally.
Martin v. Löwis7dece662005-11-26 11:38:24 +0000363 # except for Solaris 10, where it must not be defined,
364 # as it implies XPG4.2
365 case $ac_sys_system/$ac_sys_release in
366 SunOS/5.10)
367 ;;
368 *)
369 AC_DEFINE(_XOPEN_SOURCE_EXTENDED, 1,
370 Define to activate Unix95-and-earlier features)
371 ;;
372 esac
Martin v. Löwis678fc1e2002-11-12 06:04:39 +0000373
Bob Ippolito7026a0a2005-03-28 23:23:47 +0000374 AC_DEFINE(_POSIX_C_SOURCE, 200112L, Define to activate features from IEEE Stds 1003.1-2001)
375
Martin v. Löwise981a4e2002-11-11 13:26:51 +0000376fi
377
Guido van Rossum91922671997-10-09 20:24:13 +0000378#
379# SGI compilers allow the specification of the both the ABI and the
380# ISA on the command line. Depending on the values of these switches,
381# different and often incompatable code will be generated.
382#
383# The SGI_ABI variable can be used to modify the CC and LDFLAGS and
384# thus supply support for various ABI/ISA combinations. The MACHDEP
385# variable is also adjusted.
386#
387AC_SUBST(SGI_ABI)
388if test ! -z "$SGI_ABI"
389then
390 CC="cc $SGI_ABI"
391 LDFLAGS="$SGI_ABI $LDFLAGS"
392 MACHDEP=`echo "${MACHDEP}${SGI_ABI}" | sed 's/ *//g'`
393fi
Guido van Rossumb418f891996-07-30 18:06:02 +0000394AC_MSG_RESULT($MACHDEP)
395
Jack Jansen6b08a402004-06-03 12:41:45 +0000396# Record the configure-time value of MACOSX_DEPLOYMENT_TARGET,
397# it may influence the way we can build extensions, so distutils
398# needs to check it
399AC_SUBST(CONFIGURE_MACOSX_DEPLOYMENT_TARGET)
Thomas Wouters477c8d52006-05-27 19:21:47 +0000400AC_SUBST(EXPORT_MACOSX_DEPLOYMENT_TARGET)
Jack Jansen6b08a402004-06-03 12:41:45 +0000401CONFIGURE_MACOSX_DEPLOYMENT_TARGET=
Thomas Wouters477c8d52006-05-27 19:21:47 +0000402EXPORT_MACOSX_DEPLOYMENT_TARGET='#'
Jack Jansen6b08a402004-06-03 12:41:45 +0000403
Mark Dickinsonb0e2b4c2008-04-26 20:48:56 +0000404AC_MSG_CHECKING(machine type as reported by uname -m)
405ac_sys_machine=`uname -m`
406AC_MSG_RESULT($ac_sys_machine)
407
Guido van Rossum627b2d71993-12-24 10:39:16 +0000408# checks for alternative programs
Skip Montanarodecc6a42003-01-01 20:07:49 +0000409
410# compiler flags are generated in two sets, BASECFLAGS and OPT. OPT is just
411# for debug/optimization stuff. BASECFLAGS is for flags that are required
412# just to get things to compile and link. Users are free to override OPT
413# when running configure or make. The build should not break if they do.
414# BASECFLAGS should generally not be messed with, however.
415
416# XXX shouldn't some/most/all of this code be merged with the stuff later
417# on that fiddles with OPT and BASECFLAGS?
Guido van Rossum5739e7e1995-01-20 16:50:53 +0000418AC_MSG_CHECKING(for --without-gcc)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000419AC_ARG_WITH(gcc,
420 AC_HELP_STRING(--without-gcc,never use gcc),
421[
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000422 case $withval in
Benjamin Peterson960cf0f2009-01-09 04:11:44 +0000423 no) CC=${CC:-cc}
Guido van Rossum5739e7e1995-01-20 16:50:53 +0000424 without_gcc=yes;;
425 yes) CC=gcc
426 without_gcc=no;;
427 *) CC=$withval
428 without_gcc=$withval;;
Guido van Rossum55a214e1995-09-13 17:48:09 +0000429 esac], [
Guido van Rossumb418f891996-07-30 18:06:02 +0000430 case $ac_sys_system in
Neil Schemenauerb3531b82001-02-16 04:09:05 +0000431 AIX*) CC=cc_r
432 without_gcc=;;
Martin v. Löwis130fb172001-07-19 11:00:41 +0000433 *) without_gcc=no;;
Guido van Rossum55a214e1995-09-13 17:48:09 +0000434 esac])
Guido van Rossum5739e7e1995-01-20 16:50:53 +0000435AC_MSG_RESULT($without_gcc)
436
Guido van Rossum03ad99f1995-03-09 14:09:54 +0000437# If the user switches compilers, we can't believe the cache
438if test ! -z "$ac_cv_prog_CC" -a ! -z "$CC" -a "$CC" != "$ac_cv_prog_CC"
439then
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000440 AC_MSG_ERROR([cached CC is different -- throw away $cache_file
441(it is also a good idea to do 'make clean' before compiling)])
Guido van Rossum03ad99f1995-03-09 14:09:54 +0000442fi
443
Guido van Rossum627b2d71993-12-24 10:39:16 +0000444AC_PROG_CC
Martin v. Löwis1d5ecb72001-08-09 10:29:44 +0000445
Thomas Wouters49fd7fa2006-04-21 10:40:58 +0000446AC_SUBST(CXX)
447AC_SUBST(MAINCC)
448AC_MSG_CHECKING(for --with-cxx-main=<compiler>)
449AC_ARG_WITH(cxx_main,
450 AC_HELP_STRING([--with-cxx-main=<compiler>],
451 [compile main() and link python executable with C++ compiler]),
452[
453
454 case $withval in
455 no) with_cxx_main=no
456 MAINCC='$(CC)';;
457 yes) with_cxx_main=yes
458 MAINCC='$(CXX)';;
459 *) with_cxx_main=yes
460 MAINCC=$withval
461 if test -z "$CXX"
462 then
463 CXX=$withval
464 fi;;
465 esac], [
466 with_cxx_main=no
467 MAINCC='$(CC)'
468])
469AC_MSG_RESULT($with_cxx_main)
470
471preset_cxx="$CXX"
472if test -z "$CXX"
473then
474 case "$CC" in
475 gcc) AC_PATH_PROG(CXX, [g++], [g++], [notfound]) ;;
476 cc) AC_PATH_PROG(CXX, [c++], [c++], [notfound]) ;;
477 esac
478 if test "$CXX" = "notfound"
479 then
480 CXX=""
481 fi
482fi
483if test -z "$CXX"
484then
485 AC_CHECK_PROGS(CXX, $CCC c++ g++ gcc CC cxx cc++ cl, notfound)
486 if test "$CXX" = "notfound"
487 then
488 CXX=""
489 fi
490fi
491if test "$preset_cxx" != "$CXX"
492then
493 AC_MSG_WARN([
494
495 By default, distutils will build C++ extension modules with "$CXX".
496 If this is not intended, then set CXX on the configure command line.
497 ])
498fi
499
500
Martin v. Löwis1d5ecb72001-08-09 10:29:44 +0000501# checks for UNIX variants that set C preprocessor variables
502AC_AIX
Martin v. Löwis1d5ecb72001-08-09 10:29:44 +0000503
Martin v. Löwis779ffc02002-12-02 22:17:01 +0000504# Check for unsupported systems
505case $ac_sys_system/$ac_sys_release in
Guido van Rossumcd16bf62007-06-13 18:07:49 +0000506atheos*|Linux*/1*)
Martin v. Löwis779ffc02002-12-02 22:17:01 +0000507 echo This system \($ac_sys_system/$ac_sys_release\) is no longer supported.
508 echo See README for details.
509 exit 1;;
510esac
511
Neil Schemenauer55f0cf32001-01-24 17:24:33 +0000512AC_EXEEXT
Neil Schemenauer3ae1d0a2001-01-27 06:54:42 +0000513AC_MSG_CHECKING(for --with-suffix)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000514AC_ARG_WITH(suffix,
515 AC_HELP_STRING(--with-suffix=.exe, set executable suffix),
516[
Neil Schemenauer3ae1d0a2001-01-27 06:54:42 +0000517 case $withval in
518 no) EXEEXT=;;
519 yes) EXEEXT=.exe;;
520 *) EXEEXT=$withval;;
521 esac])
522AC_MSG_RESULT($EXEEXT)
Jack Jansen1999ef42001-12-06 21:47:20 +0000523
Jack Jansen9a66b6d2001-08-08 13:56:14 +0000524# Test whether we're running on a non-case-sensitive system, in which
525# case we give a warning if no ext is given
Jack Jansen1999ef42001-12-06 21:47:20 +0000526AC_SUBST(BUILDEXEEXT)
527AC_MSG_CHECKING(for case-insensitive build directory)
Jack Jansen3c2c4332002-11-06 13:33:32 +0000528if test ! -d CaseSensitiveTestDir; then
529mkdir CaseSensitiveTestDir
530fi
531
532if test -d casesensitivetestdir
Jack Jansen9a66b6d2001-08-08 13:56:14 +0000533then
Jack Jansen1999ef42001-12-06 21:47:20 +0000534 AC_MSG_RESULT(yes)
535 BUILDEXEEXT=.exe
536else
537 AC_MSG_RESULT(no)
Jack Jansendd19cf82001-12-06 22:36:17 +0000538 BUILDEXEEXT=$EXEEXT
Jack Jansen9a66b6d2001-08-08 13:56:14 +0000539fi
Jack Jansen3c2c4332002-11-06 13:33:32 +0000540rmdir CaseSensitiveTestDir
Guido van Rossumfb842551997-08-06 23:42:07 +0000541
Guido van Rossumdd997f71998-10-07 19:58:26 +0000542case $MACHDEP in
543bsdos*)
544 case $CC in
545 gcc) CC="$CC -D_HAVE_BSDI";;
546 esac;;
547esac
548
Guido van Rossum84561611997-08-21 00:08:11 +0000549case $ac_sys_system in
550hp*|HP*)
551 case $CC in
Guido van Rossumcd5ff9f2000-09-22 16:15:54 +0000552 cc|*/cc) CC="$CC -Ae";;
Guido van Rossum84561611997-08-21 00:08:11 +0000553 esac;;
Martin v. Löwise8964d42001-03-06 12:09:07 +0000554SunOS*)
555 # Some functions have a prototype only with that define, e.g. confstr
Martin v. Löwisc45929e2002-04-06 10:10:49 +0000556 AC_DEFINE(__EXTENSIONS__, 1, [Defined on Solaris to see additional function prototypes.])
Martin v. Löwise8964d42001-03-06 12:09:07 +0000557 ;;
Guido van Rossum84561611997-08-21 00:08:11 +0000558esac
559
Martin v. Löwise8964d42001-03-06 12:09:07 +0000560
Neil Schemenauer61c51152001-01-26 16:18:16 +0000561AC_SUBST(LIBRARY)
562AC_MSG_CHECKING(LIBRARY)
563if test -z "$LIBRARY"
564then
565 LIBRARY='libpython$(VERSION).a'
566fi
567AC_MSG_RESULT($LIBRARY)
568
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000569# LDLIBRARY is the name of the library to link against (as opposed to the
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000570# name of the library into which to insert object files). BLDLIBRARY is also
571# the library to link against, usually. On Mac OS X frameworks, BLDLIBRARY
572# is blank as the main program is not linked directly against LDLIBRARY.
573# LDLIBRARYDIR is the path to LDLIBRARY, which is made in a subdirectory. On
574# systems without shared libraries, LDLIBRARY is the same as LIBRARY
575# (defined in the Makefiles). On Cygwin LDLIBRARY is the import library,
576# DLLLIBRARY is the shared (i.e., DLL) library.
577#
Martin v. Löwis1142de32002-03-29 16:28:31 +0000578# RUNSHARED is used to run shared python without installed libraries
579#
580# INSTSONAME is the name of the shared library that will be use to install
581# on the system - some systems like version suffix, others don't
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000582AC_SUBST(LDLIBRARY)
Guido van Rossum27552902001-01-23 01:52:26 +0000583AC_SUBST(DLLLIBRARY)
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000584AC_SUBST(BLDLIBRARY)
585AC_SUBST(LDLIBRARYDIR)
Martin v. Löwis1142de32002-03-29 16:28:31 +0000586AC_SUBST(INSTSONAME)
587AC_SUBST(RUNSHARED)
Neil Schemenauer61c51152001-01-26 16:18:16 +0000588LDLIBRARY="$LIBRARY"
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000589BLDLIBRARY='$(LDLIBRARY)'
Martin v. Löwis09bdf722002-05-08 08:51:29 +0000590INSTSONAME='$(LDLIBRARY)'
Guido van Rossum27552902001-01-23 01:52:26 +0000591DLLLIBRARY=''
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000592LDLIBRARYDIR=''
Martin v. Löwis1142de32002-03-29 16:28:31 +0000593RUNSHARED=''
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000594
Guido van Rossumfb842551997-08-06 23:42:07 +0000595# LINKCC is the command that links the python executable -- default is $(CC).
Martin v. Löwisb7da67a2001-10-18 15:35:38 +0000596# If CXX is set, and if it is needed to link a main function that was
597# compiled with CXX, LINKCC is CXX instead. Always using CXX is undesirable:
598# python might then depend on the C++ runtime
Fred Drake5790be12000-10-09 17:06:13 +0000599# This is altered for AIX in order to build the export list before
Guido van Rossumec95c7b1998-08-04 17:59:56 +0000600# linking.
Guido van Rossumfb842551997-08-06 23:42:07 +0000601AC_SUBST(LINKCC)
602AC_MSG_CHECKING(LINKCC)
603if test -z "$LINKCC"
604then
Thomas Wouters49fd7fa2006-04-21 10:40:58 +0000605 LINKCC='$(PURIFY) $(MAINCC)'
Guido van Rossumfb842551997-08-06 23:42:07 +0000606 case $ac_sys_system in
607 AIX*)
Neal Norwitz0b27ff92003-03-31 15:53:49 +0000608 exp_extra="\"\""
609 if test $ac_sys_release -ge 5 -o \
610 $ac_sys_release -eq 4 -a `uname -r` -ge 2 ; then
611 exp_extra="."
612 fi
613 LINKCC="\$(srcdir)/Modules/makexp_aix Modules/python.exp $exp_extra \$(LIBRARY); $LINKCC";;
Georg Brandlf78e02b2008-06-10 17:40:04 +0000614 QNX*)
615 # qcc must be used because the other compilers do not
616 # support -N.
617 LINKCC=qcc;;
Guido van Rossumfb842551997-08-06 23:42:07 +0000618 esac
619fi
620AC_MSG_RESULT($LINKCC)
621
Tarek Ziadébe720e02009-05-09 11:55:12 +0000622# GNULD is set to "yes" if the GNU linker is used. If this goes wrong
623# make sure we default having it set to "no": this is used by
624# distutils.unixccompiler to know if it should add --enable-new-dtags
625# to linker command lines, and failing to detect GNU ld simply results
626# in the same bahaviour as before.
627AC_SUBST(GNULD)
628AC_MSG_CHECKING(for GNU ld)
629ac_prog=ld
630if test "$GCC" = yes; then
631 ac_prog=`$CC -print-prog-name=ld`
632fi
633case `"$ac_prog" -V 2>&1 < /dev/null` in
634 *GNU*)
635 GNULD=yes;;
636 *)
637 GNULD=no;;
638esac
639AC_MSG_RESULT($GNULD)
640
Martin v. Löwis1142de32002-03-29 16:28:31 +0000641AC_MSG_CHECKING(for --enable-shared)
642AC_ARG_ENABLE(shared,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000643 AC_HELP_STRING(--enable-shared, disable/enable building shared python library))
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000644
Martin v. Löwis1142de32002-03-29 16:28:31 +0000645if test -z "$enable_shared"
646then
Martin v. Löwisb51033d2002-05-03 05:53:15 +0000647 case $ac_sys_system in
Antoine Pitrou6103ab12009-10-24 20:11:21 +0000648 CYGWIN*)
Martin v. Löwisb51033d2002-05-03 05:53:15 +0000649 enable_shared="yes";;
650 *)
651 enable_shared="no";;
652 esac
Martin v. Löwis1142de32002-03-29 16:28:31 +0000653fi
654AC_MSG_RESULT($enable_shared)
655
Skip Montanaro56f6a4f2004-06-18 02:47:22 +0000656AC_MSG_CHECKING(for --enable-profiling)
657AC_ARG_ENABLE(profiling,
658 AC_HELP_STRING(--enable-profiling, enable C-level code profiling),
659[ac_save_cc="$CC"
660 CC="$CC -pg"
661 AC_TRY_RUN([int main() { return 0; }],
662 ac_enable_profiling="yes",
663 ac_enable_profiling="no",
664 ac_enable_profiling="no")
665 CC="$ac_save_cc"])
666AC_MSG_RESULT($ac_enable_profiling)
667
668case "$ac_enable_profiling" in
669 "yes")
670 BASECFLAGS="-pg $BASECFLAGS"
671 LDFLAGS="-pg $LDFLAGS"
672 ;;
673esac
Martin v. Löwis1142de32002-03-29 16:28:31 +0000674
675AC_MSG_CHECKING(LDLIBRARY)
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000676
Guido van Rossumb8552162001-09-05 14:58:11 +0000677# MacOSX framework builds need more magic. LDLIBRARY is the dynamic
678# library that we build, but we do not want to link against it (we
679# will find it with a -framework option). For this reason there is an
680# extra variable BLDLIBRARY against which Python and the extension
681# modules are linked, BLDLIBRARY. This is normally the same as
682# LDLIBRARY, but empty for MacOSX framework builds.
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000683if test "$enable_framework"
684then
685 LDLIBRARY='$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansen66b84832003-07-04 12:14:39 +0000686 RUNSHARED=DYLD_FRAMEWORK_PATH="`pwd`:$DYLD_FRAMEWORK_PATH"
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000687 BLDLIBRARY=''
688else
689 BLDLIBRARY='$(LDLIBRARY)'
690fi
691
Martin v. Löwis1142de32002-03-29 16:28:31 +0000692# Other platforms follow
693if test $enable_shared = "yes"; then
Mark Hammond8235ea12002-07-19 06:55:41 +0000694 AC_DEFINE(Py_ENABLE_SHARED, 1, [Defined if Python is built as a shared library.])
Martin v. Löwis1142de32002-03-29 16:28:31 +0000695 case $ac_sys_system in
Martin v. Löwis1142de32002-03-29 16:28:31 +0000696 CYGWIN*)
697 LDLIBRARY='libpython$(VERSION).dll.a'
698 DLLLIBRARY='libpython$(VERSION).dll'
699 ;;
700 SunOS*)
701 LDLIBRARY='libpython$(VERSION).so'
Martin v. Löwisd141a8c2003-06-14 15:20:28 +0000702 BLDLIBRARY='-Wl,-R,$(LIBDIR) -L. -lpython$(VERSION)'
Martin v. Löwisfc9b75f2003-08-09 09:06:52 +0000703 RUNSHARED=LD_LIBRARY_PATH=`pwd`:${LD_LIBRARY_PATH}
Martin v. Löwis2389c412003-10-31 15:42:07 +0000704 INSTSONAME="$LDLIBRARY".$SOVERSION
Martin v. Löwis1142de32002-03-29 16:28:31 +0000705 ;;
Martin v. Löwis86d66262006-02-17 08:40:11 +0000706 Linux*|GNU*|NetBSD*|FreeBSD*|DragonFly*)
Martin v. Löwis1142de32002-03-29 16:28:31 +0000707 LDLIBRARY='libpython$(VERSION).so'
708 BLDLIBRARY='-L. -lpython$(VERSION)'
Martin v. Löwisfc9b75f2003-08-09 09:06:52 +0000709 RUNSHARED=LD_LIBRARY_PATH=`pwd`:${LD_LIBRARY_PATH}
Hye-Shik Chang33761492004-10-26 09:53:46 +0000710 case $ac_sys_system in
711 FreeBSD*)
712 SOVERSION=`echo $SOVERSION|cut -d "." -f 1`
713 ;;
714 esac
Martin v. Löwis1142de32002-03-29 16:28:31 +0000715 INSTSONAME="$LDLIBRARY".$SOVERSION
716 ;;
717 hp*|HP*)
Thomas Wouters477c8d52006-05-27 19:21:47 +0000718 case `uname -m` in
719 ia64)
720 LDLIBRARY='libpython$(VERSION).so'
721 ;;
722 *)
723 LDLIBRARY='libpython$(VERSION).sl'
724 ;;
725 esac
Martin v. Löwis1142de32002-03-29 16:28:31 +0000726 BLDLIBRARY='-Wl,+b,$(LIBDIR) -L. -lpython$(VERSION)'
Martin v. Löwisfc9b75f2003-08-09 09:06:52 +0000727 RUNSHARED=SHLIB_PATH=`pwd`:${SHLIB_PATH}
Martin v. Löwis1142de32002-03-29 16:28:31 +0000728 ;;
729 OSF*)
730 LDLIBRARY='libpython$(VERSION).so'
Neal Norwitz671b9e32006-01-09 07:07:12 +0000731 BLDLIBRARY='-rpath $(LIBDIR) -L. -lpython$(VERSION)'
Martin v. Löwisfc9b75f2003-08-09 09:06:52 +0000732 RUNSHARED=LD_LIBRARY_PATH=`pwd`:${LD_LIBRARY_PATH}
Martin v. Löwis1142de32002-03-29 16:28:31 +0000733 ;;
Georg Brandlb1441c72009-01-03 22:33:39 +0000734 Darwin*)
735 LDLIBRARY='libpython$(VERSION).dylib'
736 BLDLIBRARY='-L. -lpython$(VERSION)'
737 RUNSHARED='DYLD_LIBRARY_PATH=`pwd`:${DYLD_LIBRARY_PATH}'
738 ;;
739
Martin v. Löwis1142de32002-03-29 16:28:31 +0000740 esac
Jason Tishler30765592003-09-04 11:04:06 +0000741else # shared is disabled
742 case $ac_sys_system in
743 CYGWIN*)
744 BLDLIBRARY='$(LIBRARY)'
745 LDLIBRARY='libpython$(VERSION).dll.a'
746 ;;
747 esac
Martin v. Löwis1142de32002-03-29 16:28:31 +0000748fi
749
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000750AC_MSG_RESULT($LDLIBRARY)
751
Guido van Rossum627b2d71993-12-24 10:39:16 +0000752AC_PROG_RANLIB
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000753AC_SUBST(AR)
Guido van Rossum76be6ed1995-01-02 18:33:54 +0000754AC_CHECK_PROGS(AR, ar aal, ar)
Neil Schemenauera42c8272001-03-31 00:01:55 +0000755
Tarek Ziadé5662d3e2009-05-07 21:24:43 +0000756# tweak ARFLAGS only if the user didn't set it on the command line
757AC_SUBST(ARFLAGS)
758if test -z "$ARFLAGS"
759then
760 ARFLAGS="rc"
761fi
762
Martin v. Löwisdea59e52006-01-05 10:00:36 +0000763AC_SUBST(SVNVERSION)
Thomas Wouters49fd7fa2006-04-21 10:40:58 +0000764AC_CHECK_PROG(SVNVERSION, svnversion, found, not-found)
Martin v. Löwisc5bf5a02006-01-05 10:33:59 +0000765if test $SVNVERSION = found
766then
767 SVNVERSION="svnversion \$(srcdir)"
768else
Benjamin Petersonf53eec82009-05-23 19:36:27 +0000769 SVNVERSION="echo Unversioned directory"
Martin v. Löwisc5bf5a02006-01-05 10:33:59 +0000770fi
Martin v. Löwisdea59e52006-01-05 10:00:36 +0000771
Neil Schemenauera42c8272001-03-31 00:01:55 +0000772case $MACHDEP in
Neil Schemenaueraf5567f2001-10-21 22:32:04 +0000773bsdos*|hp*|HP*)
774 # install -d does not work on BSDI or HP-UX
Neil Schemenauera42c8272001-03-31 00:01:55 +0000775 if test -z "$INSTALL"
776 then
777 INSTALL="${srcdir}/install-sh -c"
778 fi
779esac
Neil Schemenauer55f0cf32001-01-24 17:24:33 +0000780AC_PROG_INSTALL
Guido van Rossumb418f891996-07-30 18:06:02 +0000781
Guido van Rossumec95c7b1998-08-04 17:59:56 +0000782# Not every filesystem supports hard links
783AC_SUBST(LN)
784if test -z "$LN" ; then
785 case $ac_sys_system in
Guido van Rossumaef734b2001-01-10 21:09:12 +0000786 CYGWIN*) LN="ln -s";;
Guido van Rossumec95c7b1998-08-04 17:59:56 +0000787 *) LN=ln;;
788 esac
789fi
790
Fred Drake9f715822001-07-11 06:27:00 +0000791# Check for --with-pydebug
792AC_MSG_CHECKING(for --with-pydebug)
793AC_ARG_WITH(pydebug,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000794 AC_HELP_STRING(--with-pydebug, build with Py_DEBUG defined),
795[
Fred Drake9f715822001-07-11 06:27:00 +0000796if test "$withval" != no
Martin v. Löwisc45929e2002-04-06 10:10:49 +0000797then
798 AC_DEFINE(Py_DEBUG, 1,
799 [Define if you want to build an interpreter with many run-time checks.])
800 AC_MSG_RESULT(yes);
801 Py_DEBUG='true'
Fred Drake9f715822001-07-11 06:27:00 +0000802else AC_MSG_RESULT(no); Py_DEBUG='false'
803fi],
804[AC_MSG_RESULT(no)])
805
Skip Montanarodecc6a42003-01-01 20:07:49 +0000806# XXX Shouldn't the code above that fiddles with BASECFLAGS and OPT be
807# merged with this chunk of code?
808
Neil Schemenauer55f0cf32001-01-24 17:24:33 +0000809# Optimizer/debugger flags
Skip Montanarodecc6a42003-01-01 20:07:49 +0000810# ------------------------
811# (The following bit of code is complicated enough - please keep things
812# indented properly. Just pretend you're editing Python code. ;-)
813
814# There are two parallel sets of case statements below, one that checks to
815# see if OPT was set and one that does BASECFLAGS setting based upon
816# compiler and platform. BASECFLAGS tweaks need to be made even if the
817# user set OPT.
818
819# tweak OPT based on compiler and platform, only if the user didn't set
820# it on the command line
Guido van Rossumb418f891996-07-30 18:06:02 +0000821AC_SUBST(OPT)
Guido van Rossum4e8af441994-08-19 15:33:54 +0000822if test -z "$OPT"
Guido van Rossumb418f891996-07-30 18:06:02 +0000823then
Skip Montanarodecc6a42003-01-01 20:07:49 +0000824 case $GCC in
825 yes)
Thomas Wouters49fd7fa2006-04-21 10:40:58 +0000826 if test "$CC" != 'g++' ; then
827 STRICT_PROTO="-Wstrict-prototypes"
828 fi
Christian Heimes38053212007-12-14 01:24:44 +0000829 # For gcc 4.x we need to use -fwrapv so lets check if its supported
830 if "$CC" -v --help 2>/dev/null |grep -- -fwrapv > /dev/null; then
831 WRAP="-fwrapv"
832 fi
Skip Montanarodecc6a42003-01-01 20:07:49 +0000833 case $ac_cv_prog_cc_g in
Guido van Rossum2242f2f2001-04-11 20:58:20 +0000834 yes)
Fred Drake9f715822001-07-11 06:27:00 +0000835 if test "$Py_DEBUG" = 'true' ; then
836 # Optimization messes up debuggers, so turn it off for
837 # debug builds.
Thomas Wouters49fd7fa2006-04-21 10:40:58 +0000838 OPT="-g -Wall $STRICT_PROTO"
Fred Drake9f715822001-07-11 06:27:00 +0000839 else
Christian Heimes38053212007-12-14 01:24:44 +0000840 OPT="-g $WRAP -O3 -Wall $STRICT_PROTO"
Skip Montanarodecc6a42003-01-01 20:07:49 +0000841 fi
842 ;;
Guido van Rossum2242f2f2001-04-11 20:58:20 +0000843 *)
Thomas Wouters49fd7fa2006-04-21 10:40:58 +0000844 OPT="-O3 -Wall $STRICT_PROTO"
Skip Montanarodecc6a42003-01-01 20:07:49 +0000845 ;;
Fred Drake9f715822001-07-11 06:27:00 +0000846 esac
Martin v. Löwis21ee4092002-09-30 16:19:48 +0000847 case $ac_sys_system in
Skip Montanarodecc6a42003-01-01 20:07:49 +0000848 SCO_SV*) OPT="$OPT -m486 -DSCO5"
849 ;;
850 esac
Fred Drake9f715822001-07-11 06:27:00 +0000851 ;;
Skip Montanarodecc6a42003-01-01 20:07:49 +0000852
Guido van Rossum2242f2f2001-04-11 20:58:20 +0000853 *)
Skip Montanarodecc6a42003-01-01 20:07:49 +0000854 OPT="-O"
855 ;;
Guido van Rossum2242f2f2001-04-11 20:58:20 +0000856 esac
Guido van Rossum4e8af441994-08-19 15:33:54 +0000857fi
Guido van Rossum627b2d71993-12-24 10:39:16 +0000858
Skip Montanarodecc6a42003-01-01 20:07:49 +0000859AC_SUBST(BASECFLAGS)
Georg Brandlfcaf9102008-07-16 02:17:56 +0000860
861# The -arch flags for universal builds on OSX
862UNIVERSAL_ARCH_FLAGS=
863AC_SUBST(UNIVERSAL_ARCH_FLAGS)
864
Skip Montanarodecc6a42003-01-01 20:07:49 +0000865# tweak BASECFLAGS based on compiler and platform
866case $GCC in
867yes)
Martin v. Löwis70fedcd2003-07-07 21:26:19 +0000868 # Python violates C99 rules, by casting between incompatible
869 # pointer types. GCC may generate bad code as a result of that,
870 # so use -fno-strict-aliasing if supported.
871 AC_MSG_CHECKING(whether $CC accepts -fno-strict-aliasing)
872 ac_save_cc="$CC"
873 CC="$CC -fno-strict-aliasing"
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +0000874 AC_CACHE_VAL(ac_cv_no_strict_aliasing_ok,
Gregory P. Smith4e3ed012009-11-01 21:09:10 +0000875 AC_TRY_COMPILE([],[int main() { return 0; }],
Martin v. Löwis70fedcd2003-07-07 21:26:19 +0000876 ac_cv_no_strict_aliasing_ok=yes,
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +0000877 ac_cv_no_strict_aliasing_ok=no))
Martin v. Löwis70fedcd2003-07-07 21:26:19 +0000878 CC="$ac_save_cc"
879 AC_MSG_RESULT($ac_cv_no_strict_aliasing_ok)
880 if test $ac_cv_no_strict_aliasing_ok = yes
881 then
882 BASECFLAGS="$BASECFLAGS -fno-strict-aliasing"
883 fi
Mark Dickinsonb0e2b4c2008-04-26 20:48:56 +0000884
885 # if using gcc on alpha, use -mieee to get (near) full IEEE 754
886 # support. Without this, treatment of subnormals doesn't follow
887 # the standard.
888 case $ac_sys_machine in
889 alpha*)
890 BASECFLAGS="$BASECFLAGS -mieee"
891 ;;
892 esac
893
Skip Montanarodecc6a42003-01-01 20:07:49 +0000894 case $ac_sys_system in
895 SCO_SV*)
896 BASECFLAGS="$BASECFLAGS -m486 -DSCO5"
897 ;;
898 # is there any other compiler on Darwin besides gcc?
899 Darwin*)
Christian Heimesb186d002008-03-18 15:15:01 +0000900 # -Wno-long-double, -no-cpp-precomp, and -mno-fused-madd
901 # used to be here, but non-Apple gcc doesn't accept them.
Benjamin Peterson67c38e22008-07-17 16:10:34 +0000902
903
Thomas Wouters477c8d52006-05-27 19:21:47 +0000904 if test "${enable_universalsdk}"; then
Georg Brandlfcaf9102008-07-16 02:17:56 +0000905 UNIVERSAL_ARCH_FLAGS=""
906 if test "$UNIVERSAL_ARCHS" = "32-bit" ; then
907 UNIVERSAL_ARCH_FLAGS="-arch ppc -arch i386"
Benjamin Peterson6794aa32008-07-16 20:33:37 +0000908 ARCH_RUN_32BIT=""
Ronald Oussoren6f6c5622009-12-24 14:03:19 +0000909 LIPO_32BIT_FLAGS="-extract ppc7400 -extract i386"
Georg Brandlfcaf9102008-07-16 02:17:56 +0000910
Ronald Oussoren755740f2010-02-07 19:56:39 +0000911 # You have to use different flags on various versions of
912 # OSX to extract PPC code from an universal binary, basically
913 # '-arch ppc' on OSX 10.4 and '-arch ppc7400' on anything
914 # newer.
915 # Because '-arch pp7400' works on OSX 10.5 or higher this
916 # test is only present in the '32-bit' branch, all other
917 # branches require OSX 10.5 to compile.
918
919 AC_MSG_CHECKING(lipo flag for extracting ppc code)
920 FN="test.$$"
921 cat >${FN}.c <<-EOF
922 int main() { return 0; }
923EOF
924 ${CC} ${CFLAGS} -arch ppc -arch i386 -o ${FN} ${FN}.c -isysroot ${UNIVERSALSDK}
925 if test $? != 0 ; then
926 rm ${FN} ${FN}.c
927 AC_MSG_RESULT([failed, assumee -extract ppc7400])
928 else
929 lipo "${FN}" -extract ppc7400 -output "${FN}.out" 2>/dev/null
930 if test $? != 0 ; then
931 LIPO_32BIT_FLAGS="-extract ppc -extract i386"
932 AC_MSG_RESULT("'-extract ppc'")
933 else
934 AC_MSG_RESULT("'-extract ppc7400'")
935 fi
936 rm -f ${FN} ${FN}.c ${FN}.out
937 fi
938
Georg Brandlfcaf9102008-07-16 02:17:56 +0000939 elif test "$UNIVERSAL_ARCHS" = "64-bit" ; then
940 UNIVERSAL_ARCH_FLAGS="-arch ppc64 -arch x86_64"
Ronald Oussoren6f6c5622009-12-24 14:03:19 +0000941 LIPO_32BIT_FLAGS=""
Ronald Oussoren5bbab3e2009-09-06 11:01:15 +0000942 ARCH_RUN_32BIT="true"
Georg Brandlfcaf9102008-07-16 02:17:56 +0000943
944 elif test "$UNIVERSAL_ARCHS" = "all" ; then
945 UNIVERSAL_ARCH_FLAGS="-arch i386 -arch ppc -arch ppc64 -arch x86_64"
Ronald Oussoren6f6c5622009-12-24 14:03:19 +0000946 LIPO_32BIT_FLAGS="-extract ppc7400 -extract i386"
Ronald Oussoren564f7f22010-02-11 13:23:08 +0000947 ARCH_RUN_32BIT="/usr/bin/arch -i386 -ppc"
Georg Brandlfcaf9102008-07-16 02:17:56 +0000948
Ronald Oussoren3c064c12009-09-08 07:12:42 +0000949 elif test "$UNIVERSAL_ARCHS" = "intel" ; then
950 UNIVERSAL_ARCH_FLAGS="-arch i386 -arch x86_64"
Ronald Oussoren6f6c5622009-12-24 14:03:19 +0000951 LIPO_32BIT_FLAGS="-extract i386"
Ronald Oussoren564f7f22010-02-11 13:23:08 +0000952 ARCH_RUN_32BIT="/usr/bin/arch -i386"
Ronald Oussoren3c064c12009-09-08 07:12:42 +0000953
954 elif test "$UNIVERSAL_ARCHS" = "3-way" ; then
955 UNIVERSAL_ARCH_FLAGS="-arch i386 -arch ppc -arch x86_64"
Ronald Oussoren6f6c5622009-12-24 14:03:19 +0000956 LIPO_32BIT_FLAGS="-extract ppc7400 -extract i386"
Ronald Oussoren564f7f22010-02-11 13:23:08 +0000957 ARCH_RUN_32BIT="/usr/bin/arch -i386 -ppc"
Ronald Oussoren3c064c12009-09-08 07:12:42 +0000958
Georg Brandlfcaf9102008-07-16 02:17:56 +0000959 else
Ronald Oussoren74f29b42009-09-20 20:09:26 +0000960 AC_MSG_ERROR([proper usage is --with-universal-arch=32-bit|64-bit|all|intel|3-way])
Georg Brandlfcaf9102008-07-16 02:17:56 +0000961
962 fi
963
964
965 BASECFLAGS="${UNIVERSAL_ARCH_FLAGS} -isysroot ${UNIVERSALSDK} ${BASECFLAGS}"
Georg Brandl3dbca812008-07-23 16:10:53 +0000966 tgt=`sw_vers -productVersion | sed 's/\(10\.[[0-9]]*\).*/\1/'`
Benjamin Peterson67c38e22008-07-17 16:10:34 +0000967 if test "${UNIVERSALSDK}" != "/" -a "${tgt}" '>' '10.4' ; then
968 CFLAGS="${UNIVERSAL_ARCH_FLAGS} -isysroot ${UNIVERSALSDK} ${CFLAGS}"
969 fi
Thomas Wouters477c8d52006-05-27 19:21:47 +0000970 fi
971
Benjamin Peterson67c38e22008-07-17 16:10:34 +0000972 # Calculate the right deployment target for this build.
973 #
974 cur_target=`sw_vers -productVersion | sed 's/\(10\.[[0-9]]*\).*/\1/'`
975 if test ${cur_target} '>' 10.2; then
976 cur_target=10.3
Ronald Oussoren5bbab3e2009-09-06 11:01:15 +0000977 if test ${enable_universalsdk}; then
978 if test "${UNIVERSAL_ARCHS}" = "all"; then
979 # Ensure that the default platform for a
980 # 4-way universal build is OSX 10.5,
981 # that's the first OS release where
982 # 4-way builds make sense.
983 cur_target='10.5'
Ronald Oussoren3c064c12009-09-08 07:12:42 +0000984
985 elif test "${UNIVERSAL_ARCHS}" = "3-way"; then
986 cur_target='10.5'
987
988 elif test "${UNIVERSAL_ARCHS}" = "intel"; then
989 cur_target='10.5'
990
991 elif test "${UNIVERSAL_ARCHS}" = "64-bit"; then
992 cur_target='10.5'
Ronald Oussoren5bbab3e2009-09-06 11:01:15 +0000993 fi
994 else
Ronald Oussorene3da75a2010-02-11 13:38:58 +0000995 if test `/usr/bin/arch` = "i386"; then
Ronald Oussoren5bbab3e2009-09-06 11:01:15 +0000996 # On Intel macs default to a deployment
997 # target of 10.4, that's the first OSX
998 # release with Intel support.
999 cur_target="10.4"
1000 fi
1001 fi
Benjamin Peterson67c38e22008-07-17 16:10:34 +00001002 fi
1003 CONFIGURE_MACOSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET-${cur_target}}
1004
1005 # Make sure that MACOSX_DEPLOYMENT_TARGET is set in the
1006 # environment with a value that is the same as what we'll use
1007 # in the Makefile to ensure that we'll get the same compiler
1008 # environment during configure and build time.
1009 MACOSX_DEPLOYMENT_TARGET="$CONFIGURE_MACOSX_DEPLOYMENT_TARGET"
1010 export MACOSX_DEPLOYMENT_TARGET
1011 EXPORT_MACOSX_DEPLOYMENT_TARGET=''
1012
Skip Montanarodecc6a42003-01-01 20:07:49 +00001013 ;;
Thomas Wouters49fd7fa2006-04-21 10:40:58 +00001014 OSF*)
1015 BASECFLAGS="$BASECFLAGS -mieee"
1016 ;;
Skip Montanarodecc6a42003-01-01 20:07:49 +00001017 esac
1018 ;;
1019
1020*)
1021 case $ac_sys_system in
1022 OpenUNIX*|UnixWare*)
1023 BASECFLAGS="$BASECFLAGS -K pentium,host,inline,loop_unroll,alloca "
1024 ;;
Neal Norwitzb44f1652003-05-26 14:11:55 +00001025 OSF*)
1026 BASECFLAGS="$BASECFLAGS -ieee -std"
1027 ;;
Skip Montanarodecc6a42003-01-01 20:07:49 +00001028 SCO_SV*)
1029 BASECFLAGS="$BASECFLAGS -belf -Ki486 -DSCO5"
1030 ;;
1031 esac
1032 ;;
1033esac
1034
Fred Drakee1ceaa02001-12-04 20:55:47 +00001035if test "$Py_DEBUG" = 'true'; then
1036 :
1037else
1038 OPT="-DNDEBUG $OPT"
1039fi
1040
Guido van Rossum6f2260e1996-09-09 16:21:03 +00001041if test "$ac_arch_flags"
Guido van Rossumc5a39031996-07-31 17:35:03 +00001042then
Skip Montanarodecc6a42003-01-01 20:07:49 +00001043 BASECFLAGS="$BASECFLAGS $ac_arch_flags"
Guido van Rossumc5a39031996-07-31 17:35:03 +00001044fi
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001045
Neal Norwitz020c46a2006-01-07 21:39:28 +00001046# disable check for icc since it seems to pass, but generates a warning
1047if test "$CC" = icc
1048then
1049 ac_cv_opt_olimit_ok=no
1050fi
1051
Guido van Rossum91922671997-10-09 20:24:13 +00001052AC_MSG_CHECKING(whether $CC accepts -OPT:Olimit=0)
1053AC_CACHE_VAL(ac_cv_opt_olimit_ok,
1054[ac_save_cc="$CC"
1055CC="$CC -OPT:Olimit=0"
Gregory P. Smith4e3ed012009-11-01 21:09:10 +00001056AC_TRY_COMPILE([],[int main() { return 0; }],
Guido van Rossum91922671997-10-09 20:24:13 +00001057 ac_cv_opt_olimit_ok=yes,
Guido van Rossum3065c942001-09-17 04:03:14 +00001058 ac_cv_opt_olimit_ok=no,
Gregory P. Smith4e3ed012009-11-01 21:09:10 +00001059 )
Guido van Rossum91922671997-10-09 20:24:13 +00001060CC="$ac_save_cc"])
1061AC_MSG_RESULT($ac_cv_opt_olimit_ok)
Guido van Rossum2efa34b1997-10-23 17:43:11 +00001062if test $ac_cv_opt_olimit_ok = yes; then
Guido van Rossum5839e582000-10-09 19:52:35 +00001063 case $ac_sys_system in
Skip Montanarodecc6a42003-01-01 20:07:49 +00001064 # XXX is this branch needed? On MacOSX 10.2.2 the result of the
1065 # olimit_ok test is "no". Is it "yes" in some other Darwin-esque
1066 # environment?
1067 Darwin*)
1068 ;;
1069 *)
1070 BASECFLAGS="$BASECFLAGS -OPT:Olimit=0"
1071 ;;
Guido van Rossum5839e582000-10-09 19:52:35 +00001072 esac
Guido van Rossumf8678121998-07-07 21:05:09 +00001073else
1074 AC_MSG_CHECKING(whether $CC accepts -Olimit 1500)
1075 AC_CACHE_VAL(ac_cv_olimit_ok,
1076 [ac_save_cc="$CC"
1077 CC="$CC -Olimit 1500"
Gregory P. Smith4e3ed012009-11-01 21:09:10 +00001078 AC_TRY_COMPILE([],[int main() { return 0; }],
Guido van Rossumf8678121998-07-07 21:05:09 +00001079 ac_cv_olimit_ok=yes,
Guido van Rossum3065c942001-09-17 04:03:14 +00001080 ac_cv_olimit_ok=no,
Gregory P. Smith4e3ed012009-11-01 21:09:10 +00001081 )
Guido van Rossumf8678121998-07-07 21:05:09 +00001082 CC="$ac_save_cc"])
1083 AC_MSG_RESULT($ac_cv_olimit_ok)
1084 if test $ac_cv_olimit_ok = yes; then
Skip Montanarodecc6a42003-01-01 20:07:49 +00001085 BASECFLAGS="$BASECFLAGS -Olimit 1500"
Guido van Rossumf8678121998-07-07 21:05:09 +00001086 fi
Guido van Rossum201afe51997-05-14 21:14:44 +00001087fi
Guido van Rossumf8678121998-07-07 21:05:09 +00001088
Thomas Wouters89f507f2006-12-13 04:49:30 +00001089# Check whether GCC supports PyArg_ParseTuple format
1090if test "$GCC" = "yes"
1091then
1092 AC_MSG_CHECKING(whether gcc supports ParseTuple __format__)
1093 save_CFLAGS=$CFLAGS
1094 CFLAGS="$CFLAGS -Werror"
1095 AC_TRY_COMPILE([
1096 void f(char*,...)__attribute((format(PyArg_ParseTuple, 1, 2)));
1097 ],,
1098 AC_DEFINE(HAVE_ATTRIBUTE_FORMAT_PARSETUPLE, 1, [Define if GCC supports __attribute__((format(PyArg_ParseTuple, 2, 3)))])
1099 AC_MSG_RESULT(yes),
1100 AC_MSG_RESULT(no)
1101 )
1102 CFLAGS=$save_CFLAGS
1103fi
1104
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00001105# On some compilers, pthreads are available without further options
1106# (e.g. MacOS X). On some of these systems, the compiler will not
1107# complain if unaccepted options are passed (e.g. gcc on Mac OS X).
1108# So we have to see first whether pthreads are available without
1109# options before we can check whether -Kpthread improves anything.
1110AC_MSG_CHECKING(whether pthreads are available without options)
1111AC_CACHE_VAL(ac_cv_pthread_is_default,
1112[AC_TRY_RUN([
1113#include <pthread.h>
1114
1115void* routine(void* p){return NULL;}
1116
1117int main(){
1118 pthread_t p;
1119 if(pthread_create(&p,NULL,routine,NULL)!=0)
1120 return 1;
Jack Jansen4f8d0542002-03-08 13:43:01 +00001121 (void)pthread_detach(p);
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00001122 return 0;
1123}
1124],
Skip Montanarod8d39a02003-07-10 20:44:10 +00001125[
1126 ac_cv_pthread_is_default=yes
1127 ac_cv_kthread=no
1128 ac_cv_pthread=no
1129],
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00001130 ac_cv_pthread_is_default=no,
1131 ac_cv_pthread_is_default=no)
1132])
1133AC_MSG_RESULT($ac_cv_pthread_is_default)
1134
1135
1136if test $ac_cv_pthread_is_default = yes
1137then
1138 ac_cv_kpthread=no
1139else
Martin v. Löwis130fb172001-07-19 11:00:41 +00001140# -Kpthread, if available, provides the right #defines
1141# and linker options to make pthread_create available
Martin v. Löwis260aecc2001-10-07 08:14:41 +00001142# Some compilers won't report that they do not support -Kpthread,
1143# so we need to run a program to see whether it really made the
1144# function available.
Martin v. Löwis130fb172001-07-19 11:00:41 +00001145AC_MSG_CHECKING(whether $CC accepts -Kpthread)
1146AC_CACHE_VAL(ac_cv_kpthread,
1147[ac_save_cc="$CC"
1148CC="$CC -Kpthread"
Martin v. Löwis260aecc2001-10-07 08:14:41 +00001149AC_TRY_RUN([
1150#include <pthread.h>
1151
1152void* routine(void* p){return NULL;}
1153
1154int main(){
1155 pthread_t p;
1156 if(pthread_create(&p,NULL,routine,NULL)!=0)
1157 return 1;
Jack Jansen4f8d0542002-03-08 13:43:01 +00001158 (void)pthread_detach(p);
Martin v. Löwis260aecc2001-10-07 08:14:41 +00001159 return 0;
1160}
1161],
Martin v. Löwis130fb172001-07-19 11:00:41 +00001162 ac_cv_kpthread=yes,
Martin v. Löwis260aecc2001-10-07 08:14:41 +00001163 ac_cv_kpthread=no,
Martin v. Löwis130fb172001-07-19 11:00:41 +00001164 ac_cv_kpthread=no)
1165CC="$ac_save_cc"])
Martin v. Löwis130fb172001-07-19 11:00:41 +00001166AC_MSG_RESULT($ac_cv_kpthread)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00001167fi
Martin v. Löwis130fb172001-07-19 11:00:41 +00001168
Skip Montanarod8d39a02003-07-10 20:44:10 +00001169if test $ac_cv_kpthread = no -a $ac_cv_pthread_is_default = no
Martin v. Löwis5f433f02003-05-05 05:05:30 +00001170then
1171# -Kthread, if available, provides the right #defines
1172# and linker options to make pthread_create available
1173# Some compilers won't report that they do not support -Kthread,
1174# so we need to run a program to see whether it really made the
1175# function available.
1176AC_MSG_CHECKING(whether $CC accepts -Kthread)
1177AC_CACHE_VAL(ac_cv_kthread,
1178[ac_save_cc="$CC"
1179CC="$CC -Kthread"
1180AC_TRY_RUN([
1181#include <pthread.h>
1182
1183void* routine(void* p){return NULL;}
1184
1185int main(){
1186 pthread_t p;
1187 if(pthread_create(&p,NULL,routine,NULL)!=0)
1188 return 1;
1189 (void)pthread_detach(p);
1190 return 0;
1191}
1192],
1193 ac_cv_kthread=yes,
1194 ac_cv_kthread=no,
1195 ac_cv_kthread=no)
1196CC="$ac_save_cc"])
1197AC_MSG_RESULT($ac_cv_kthread)
1198fi
1199
Skip Montanarod8d39a02003-07-10 20:44:10 +00001200if test $ac_cv_kthread = no -a $ac_cv_pthread_is_default = no
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00001201then
1202# -pthread, if available, provides the right #defines
1203# and linker options to make pthread_create available
1204# Some compilers won't report that they do not support -pthread,
1205# so we need to run a program to see whether it really made the
1206# function available.
1207AC_MSG_CHECKING(whether $CC accepts -pthread)
1208AC_CACHE_VAL(ac_cv_thread,
1209[ac_save_cc="$CC"
1210CC="$CC -pthread"
1211AC_TRY_RUN([
1212#include <pthread.h>
1213
1214void* routine(void* p){return NULL;}
1215
1216int main(){
1217 pthread_t p;
1218 if(pthread_create(&p,NULL,routine,NULL)!=0)
1219 return 1;
1220 (void)pthread_detach(p);
1221 return 0;
1222}
1223],
1224 ac_cv_pthread=yes,
1225 ac_cv_pthread=no,
1226 ac_cv_pthread=no)
1227CC="$ac_save_cc"])
1228AC_MSG_RESULT($ac_cv_pthread)
1229fi
1230
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001231# If we have set a CC compiler flag for thread support then
1232# check if it works for CXX, too.
1233ac_cv_cxx_thread=no
1234if test ! -z "$CXX"
1235then
1236AC_MSG_CHECKING(whether $CXX also accepts flags for thread support)
1237ac_save_cxx="$CXX"
1238
1239if test "$ac_cv_kpthread" = "yes"
1240then
Martin v. Löwis519adae2003-09-20 10:47:47 +00001241 CXX="$CXX -Kpthread"
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001242 ac_cv_cxx_thread=yes
1243elif test "$ac_cv_kthread" = "yes"
1244then
1245 CXX="$CXX -Kthread"
1246 ac_cv_cxx_thread=yes
1247elif test "$ac_cv_pthread" = "yes"
1248then
1249 CXX="$CXX -pthread"
1250 ac_cv_cxx_thread=yes
1251fi
1252
1253if test $ac_cv_cxx_thread = yes
1254then
1255 echo 'void foo();int main(){foo();}void foo(){}' > conftest.$ac_ext
1256 $CXX -c conftest.$ac_ext 2>&5
1257 if $CXX -o conftest$ac_exeext conftest.$ac_objext 2>&5 \
1258 && test -s conftest$ac_exeext && ./conftest$ac_exeext
1259 then
1260 ac_cv_cxx_thread=yes
1261 else
1262 ac_cv_cxx_thread=no
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001263 fi
1264 rm -fr conftest*
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001265fi
Brett Cannonc601e0f2004-11-07 01:24:12 +00001266AC_MSG_RESULT($ac_cv_cxx_thread)
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001267fi
Martin v. Löwis519adae2003-09-20 10:47:47 +00001268CXX="$ac_save_cxx"
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001269
Fred Drakece81d592000-07-09 14:39:29 +00001270dnl # check for ANSI or K&R ("traditional") preprocessor
1271dnl AC_MSG_CHECKING(for C preprocessor type)
1272dnl AC_TRY_COMPILE([
1273dnl #define spam(name, doc) {#name, &name, #name "() -- " doc}
1274dnl int foo;
1275dnl struct {char *name; int *addr; char *doc;} desc = spam(foo, "something");
1276dnl ], [;], cpp_type=ansi, AC_DEFINE(HAVE_OLD_CPP) cpp_type=traditional)
1277dnl AC_MSG_RESULT($cpp_type)
Guido van Rossum300fda71996-08-19 21:58:16 +00001278
Guido van Rossum627b2d71993-12-24 10:39:16 +00001279# checks for header files
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001280AC_HEADER_STDC
Thomas Wouters0e3f5912006-08-11 14:57:12 +00001281AC_CHECK_HEADERS(asm/types.h conio.h curses.h direct.h dlfcn.h errno.h \
1282fcntl.h grp.h \
Christian Heimesbbe741d2008-03-28 10:53:29 +00001283ieeefp.h io.h langinfo.h libintl.h ncurses.h poll.h process.h pthread.h \
Thomas Wouters89f507f2006-12-13 04:49:30 +00001284shadow.h signal.h stdint.h stropts.h termios.h thread.h \
Martin v. Löwis14e73b12003-01-01 09:51:12 +00001285unistd.h utime.h \
Christian Heimes4fbc72b2008-03-22 00:47:35 +00001286sys/audioio.h sys/bsdtty.h sys/epoll.h sys/event.h sys/file.h sys/loadavg.h \
1287sys/lock.h sys/mkdev.h sys/modem.h \
Thomas Wouters0e3f5912006-08-11 14:57:12 +00001288sys/param.h sys/poll.h sys/select.h sys/socket.h sys/statvfs.h sys/stat.h \
Georg Brandlf78e02b2008-06-10 17:40:04 +00001289sys/termio.h sys/time.h \
Thomas Wouters0e3f5912006-08-11 14:57:12 +00001290sys/times.h sys/types.h sys/un.h sys/utsname.h sys/wait.h pty.h libutil.h \
Hye-Shik Chang81268602004-02-02 06:05:24 +00001291sys/resource.h netpacket/packet.h sysexits.h bluetooth.h \
Ronald Oussoren755740f2010-02-07 19:56:39 +00001292bluetooth/bluetooth.h linux/tipc.h spawn.h util.h)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001293AC_HEADER_DIRENT
Martin v. Löwisdbe3f762002-10-10 14:27:30 +00001294AC_HEADER_MAJOR
Guido van Rossum627b2d71993-12-24 10:39:16 +00001295
Martin v. Löwisae2830c2004-09-18 09:54:52 +00001296# On Solaris, term.h requires curses.h
Martin v. Löwisfd1c69e2004-11-30 22:09:37 +00001297AC_CHECK_HEADERS(term.h,,,[
Martin v. Löwis5d52e782004-09-18 10:07:03 +00001298#ifdef HAVE_CURSES_H
1299#include <curses.h>
1300#endif
1301])
Martin v. Löwisae2830c2004-09-18 09:54:52 +00001302
Martin v. Löwis11017b12006-01-14 18:12:57 +00001303# On Linux, netlink.h requires asm/types.h
1304AC_CHECK_HEADERS(linux/netlink.h,,,[
1305#ifdef HAVE_ASM_TYPES_H
1306#include <asm/types.h>
1307#endif
1308#ifdef HAVE_SYS_SOCKET_H
1309#include <sys/socket.h>
1310#endif
1311])
1312
Guido van Rossum627b2d71993-12-24 10:39:16 +00001313# checks for typedefs
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001314was_it_defined=no
1315AC_MSG_CHECKING(for clock_t in time.h)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001316AC_EGREP_HEADER(clock_t, time.h, was_it_defined=yes, [
1317 AC_DEFINE(clock_t, long, [Define to 'long' if <time.h> doesn't define.])
1318])
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001319AC_MSG_RESULT($was_it_defined)
1320
Neal Norwitz11690112002-07-30 01:08:28 +00001321# Check whether using makedev requires defining _OSF_SOURCE
1322AC_MSG_CHECKING(for makedev)
Neal Norwitz6eb37f02003-02-23 23:28:15 +00001323AC_TRY_LINK([#include <sys/types.h> ],
Neal Norwitz11690112002-07-30 01:08:28 +00001324 [ makedev(0, 0) ],
1325 ac_cv_has_makedev=yes,
1326 ac_cv_has_makedev=no)
1327if test "$ac_cv_has_makedev" = "no"; then
1328 # we didn't link, try if _OSF_SOURCE will allow us to link
1329 AC_TRY_LINK([
Neal Norwitz6eb37f02003-02-23 23:28:15 +00001330#define _OSF_SOURCE 1
1331#include <sys/types.h>
Neal Norwitz11690112002-07-30 01:08:28 +00001332 ],
1333 [ makedev(0, 0) ],
1334 ac_cv_has_makedev=yes,
1335 ac_cv_has_makedev=no)
1336 if test "$ac_cv_has_makedev" = "yes"; then
1337 AC_DEFINE(_OSF_SOURCE, 1, [Define _OSF_SOURCE to get the makedev macro.])
1338 fi
1339fi
1340AC_MSG_RESULT($ac_cv_has_makedev)
1341if test "$ac_cv_has_makedev" = "yes"; then
1342 AC_DEFINE(HAVE_MAKEDEV, 1, [Define this if you have the makedev macro.])
1343fi
1344
Martin v. Löwis399a6892002-10-04 10:22:02 +00001345# Enabling LFS on Solaris (2.6 to 9) with gcc 2.95 triggers a bug in
1346# the system headers: If _XOPEN_SOURCE and _LARGEFILE_SOURCE are
1347# defined, but the compiler does not support pragma redefine_extname,
1348# and _LARGEFILE64_SOURCE is not defined, the headers refer to 64-bit
1349# structures (such as rlimit64) without declaring them. As a
1350# work-around, disable LFS on such configurations
1351
1352use_lfs=yes
1353AC_MSG_CHECKING(Solaris LFS bug)
1354AC_TRY_COMPILE([
1355#define _LARGEFILE_SOURCE 1
1356#define _FILE_OFFSET_BITS 64
1357#include <sys/resource.h>
1358],struct rlimit foo;,sol_lfs_bug=no,sol_lfs_bug=yes)
1359AC_MSG_RESULT($sol_lfs_bug)
1360if test "$sol_lfs_bug" = "yes"; then
1361 use_lfs=no
1362fi
1363
1364if test "$use_lfs" = "yes"; then
Guido van Rossum810cc512001-09-09 23:51:39 +00001365# Two defines needed to enable largefile support on various platforms
1366# These may affect some typedefs
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001367AC_DEFINE(_LARGEFILE_SOURCE, 1,
1368[This must be defined on some systems to enable large file support.])
1369AC_DEFINE(_FILE_OFFSET_BITS, 64,
1370[This must be set to 64 on some systems to enable large file support.])
Martin v. Löwis399a6892002-10-04 10:22:02 +00001371fi
Guido van Rossum810cc512001-09-09 23:51:39 +00001372
Guido van Rossum300fda71996-08-19 21:58:16 +00001373# Add some code to confdefs.h so that the test for off_t works on SCO
1374cat >> confdefs.h <<\EOF
1375#if defined(SCO_DS)
1376#undef _OFF_T
1377#endif
1378EOF
1379
Guido van Rossumef2255b2000-03-10 22:30:29 +00001380# Type availability checks
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001381AC_TYPE_MODE_T
1382AC_TYPE_OFF_T
1383AC_TYPE_PID_T
1384AC_TYPE_SIGNAL
1385AC_TYPE_SIZE_T
1386AC_TYPE_UID_T
Mark Dickinsonbd792642009-03-18 20:06:12 +00001387AC_TYPE_UINT32_T
1388AC_TYPE_UINT64_T
1389AC_TYPE_INT32_T
1390AC_TYPE_INT64_T
Christian Heimes400adb02008-02-01 08:12:03 +00001391AC_CHECK_TYPE(ssize_t,
Martin v. Löwis18e16552006-02-15 17:27:45 +00001392 AC_DEFINE(HAVE_SSIZE_T, 1, Define if your compiler provides ssize_t),,)
Guido van Rossum627b2d71993-12-24 10:39:16 +00001393
Guido van Rossumef2255b2000-03-10 22:30:29 +00001394# Sizes of various common basic types
Skip Montanarob9820a32004-01-17 00:16:12 +00001395# ANSI C requires sizeof(char) == 1, so no need to check it
Guido van Rossum3065c942001-09-17 04:03:14 +00001396AC_CHECK_SIZEOF(int, 4)
1397AC_CHECK_SIZEOF(long, 4)
1398AC_CHECK_SIZEOF(void *, 4)
Guido van Rossum3065c942001-09-17 04:03:14 +00001399AC_CHECK_SIZEOF(short, 2)
1400AC_CHECK_SIZEOF(float, 4)
1401AC_CHECK_SIZEOF(double, 8)
1402AC_CHECK_SIZEOF(fpos_t, 4)
Martin v. Löwis18e16552006-02-15 17:27:45 +00001403AC_CHECK_SIZEOF(size_t, 4)
Christian Heimes400adb02008-02-01 08:12:03 +00001404AC_CHECK_SIZEOF(pid_t, 4)
Guido van Rossumac405f61994-09-12 10:56:06 +00001405
Guido van Rossumec95c7b1998-08-04 17:59:56 +00001406AC_MSG_CHECKING(for long long support)
1407have_long_long=no
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001408AC_TRY_COMPILE([], [long long x; x = (long long)0;], [
1409 AC_DEFINE(HAVE_LONG_LONG, 1, [Define this if you have the type long long.])
1410 have_long_long=yes
1411])
Guido van Rossumec95c7b1998-08-04 17:59:56 +00001412AC_MSG_RESULT($have_long_long)
Guido van Rossum8bc1dfd1999-04-10 16:01:48 +00001413if test "$have_long_long" = yes ; then
Guido van Rossum3065c942001-09-17 04:03:14 +00001414AC_CHECK_SIZEOF(long long, 8)
Guido van Rossumec95c7b1998-08-04 17:59:56 +00001415fi
1416
Travis E. Oliphant9b307842007-10-12 22:06:37 +00001417AC_MSG_CHECKING(for long double support)
1418have_long_double=no
1419AC_TRY_COMPILE([], [long double x; x = (long double)0;], [
1420 AC_DEFINE(HAVE_LONG_DOUBLE, 1, [Define this if you have the type long double.])
1421 have_long_double=yes
1422])
1423AC_MSG_RESULT($have_long_double)
1424if test "$have_long_double" = yes ; then
1425AC_CHECK_SIZEOF(long double, 16)
1426fi
1427
1428
Thomas Woutersb2137042007-02-01 18:02:27 +00001429AC_MSG_CHECKING(for _Bool support)
1430have_c99_bool=no
1431AC_TRY_COMPILE([], [_Bool x; x = (_Bool)0;], [
1432 AC_DEFINE(HAVE_C99_BOOL, 1, [Define this if you have the type _Bool.])
1433 have_c99_bool=yes
1434])
1435AC_MSG_RESULT($have_c99_bool)
1436if test "$have_c99_bool" = yes ; then
1437AC_CHECK_SIZEOF(_Bool, 1)
1438fi
1439
Thomas Wouters89f507f2006-12-13 04:49:30 +00001440AC_CHECK_TYPES(uintptr_t,
1441 [AC_CHECK_SIZEOF(uintptr_t, 4)],
1442 [], [#ifdef HAVE_STDINT_H
1443 #include <stdint.h>
1444 #endif])
1445
Alexandre Vassalotti0805b4a2009-07-17 05:47:33 +00001446AC_CHECK_SIZEOF(off_t, [], [
1447#ifdef HAVE_SYS_TYPES_H
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001448#include <sys/types.h>
Alexandre Vassalotti0805b4a2009-07-17 05:47:33 +00001449#endif
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001450])
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001451
1452AC_MSG_CHECKING(whether to enable large file support)
Mark Dickinson2df5d282009-12-31 21:22:50 +00001453if test "$have_long_long" = yes
1454then
1455if test "$ac_cv_sizeof_off_t" -gt "$ac_cv_sizeof_long" -a \
Guido van Rossum8bc1dfd1999-04-10 16:01:48 +00001456 "$ac_cv_sizeof_long_long" -ge "$ac_cv_sizeof_off_t"; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001457 AC_DEFINE(HAVE_LARGEFILE_SUPPORT, 1,
1458 [Defined to enable large file support when an off_t is bigger than a long
1459 and long long is available and at least as big as an off_t. You may need
1460 to add some flags for configuration and compilation to enable this mode.
1461 (For Solaris and Linux, the necessary defines are already defined.)])
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001462 AC_MSG_RESULT(yes)
1463else
1464 AC_MSG_RESULT(no)
1465fi
Mark Dickinson2df5d282009-12-31 21:22:50 +00001466else
1467 AC_MSG_RESULT(no)
1468fi
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001469
Alexandre Vassalotti0805b4a2009-07-17 05:47:33 +00001470AC_CHECK_SIZEOF(time_t, [], [
1471#ifdef HAVE_SYS_TYPES_H
1472#include <sys/types.h>
1473#endif
1474#ifdef HAVE_TIME_H
Fred Drakea3f6e912000-06-29 20:44:47 +00001475#include <time.h>
Alexandre Vassalotti0805b4a2009-07-17 05:47:33 +00001476#endif
Fred Drakea3f6e912000-06-29 20:44:47 +00001477])
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001478
Trent Mick635f6fb2000-08-23 21:33:05 +00001479# if have pthread_t then define SIZEOF_PTHREAD_T
Martin v. Löwis123cbd22001-07-19 14:21:10 +00001480ac_save_cc="$CC"
1481if test "$ac_cv_kpthread" = "yes"
1482then CC="$CC -Kpthread"
Martin v. Löwis5f433f02003-05-05 05:05:30 +00001483elif test "$ac_cv_kthread" = "yes"
1484then CC="$CC -Kthread"
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00001485elif test "$ac_cv_pthread" = "yes"
1486then CC="$CC -pthread"
Martin v. Löwis123cbd22001-07-19 14:21:10 +00001487fi
Alexandre Vassalotti0805b4a2009-07-17 05:47:33 +00001488
Trent Mick635f6fb2000-08-23 21:33:05 +00001489AC_MSG_CHECKING(for pthread_t)
1490have_pthread_t=no
Guido van Rossum12580492000-09-24 16:47:19 +00001491AC_TRY_COMPILE([#include <pthread.h>], [pthread_t x; x = *(pthread_t*)0;], have_pthread_t=yes)
Trent Mick635f6fb2000-08-23 21:33:05 +00001492AC_MSG_RESULT($have_pthread_t)
1493if test "$have_pthread_t" = yes ; then
Alexandre Vassalotti0805b4a2009-07-17 05:47:33 +00001494 AC_CHECK_SIZEOF(pthread_t, [], [
1495#ifdef HAVE_PTHREAD_H
Neal Norwitz6eb37f02003-02-23 23:28:15 +00001496#include <pthread.h>
Alexandre Vassalotti0805b4a2009-07-17 05:47:33 +00001497#endif
Trent Mick635f6fb2000-08-23 21:33:05 +00001498 ])
Trent Mick635f6fb2000-08-23 21:33:05 +00001499fi
Martin v. Löwis123cbd22001-07-19 14:21:10 +00001500CC="$ac_save_cc"
Trent Mick635f6fb2000-08-23 21:33:05 +00001501
Bob Ippolito7026a0a2005-03-28 23:23:47 +00001502AC_SUBST(OTHER_LIBTOOL_OPT)
1503case $ac_sys_system/$ac_sys_release in
Thomas Wouters49fd7fa2006-04-21 10:40:58 +00001504 Darwin/@<:@01567@:>@\..*)
Bob Ippolito7026a0a2005-03-28 23:23:47 +00001505 OTHER_LIBTOOL_OPT="-prebind -seg1addr 0x10000000"
1506 ;;
1507 Darwin/*)
1508 OTHER_LIBTOOL_OPT=""
1509 ;;
1510esac
1511
Ronald Oussoren5bbab3e2009-09-06 11:01:15 +00001512
1513ARCH_RUN_32BIT=""
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001514AC_SUBST(LIBTOOL_CRUFT)
1515case $ac_sys_system/$ac_sys_release in
Thomas Wouters49fd7fa2006-04-21 10:40:58 +00001516 Darwin/@<:@01567@:>@\..*)
Thomas Wouters477c8d52006-05-27 19:21:47 +00001517 LIBTOOL_CRUFT="-framework System -lcc_dynamic"
1518 if test "${enable_universalsdk}"; then
1519 :
1520 else
Ronald Oussorene3da75a2010-02-11 13:38:58 +00001521 LIBTOOL_CRUFT="${LIBTOOL_CRUFT} -arch_only `/usr/bin/arch`"
Thomas Wouters477c8d52006-05-27 19:21:47 +00001522 fi
Jack Jansenb36687a2004-07-16 08:43:47 +00001523 LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -install_name $(PYTHONFRAMEWORKINSTALLDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansena3891ea2001-09-07 14:25:12 +00001524 LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -compatibility_version $(VERSION) -current_version $(VERSION)';;
Guido van Rossum5839e582000-10-09 19:52:35 +00001525 Darwin/*)
Ronald Oussoren9812a6c2010-02-07 11:53:18 +00001526 gcc_version=`gcc -dumpversion`
Bob Ippolito7026a0a2005-03-28 23:23:47 +00001527 if test ${gcc_version} '<' 4.0
1528 then
1529 LIBTOOL_CRUFT="-lcc_dynamic"
1530 else
1531 LIBTOOL_CRUFT=""
1532 fi
Ronald Oussoren3c064c12009-09-08 07:12:42 +00001533 AC_TRY_RUN([
Ronald Oussoren5bbab3e2009-09-06 11:01:15 +00001534 #include <unistd.h>
1535 int main(int argc, char*argv[])
1536 {
1537 if (sizeof(long) == 4) {
1538 return 0;
1539 } else {
1540 return 1;
1541 }
Ronald Oussoren3c064c12009-09-08 07:12:42 +00001542 }
1543 ], ac_osx_32bit=yes,
Ronald Oussoren5bbab3e2009-09-06 11:01:15 +00001544 ac_osx_32bit=no,
Ronald Oussoren3c064c12009-09-08 07:12:42 +00001545 ac_osx_32bit=yes)
Ronald Oussoren5bbab3e2009-09-06 11:01:15 +00001546
1547 if test "${ac_osx_32bit}" = "yes"; then
Ronald Oussorene3da75a2010-02-11 13:38:58 +00001548 case `/usr/bin/arch` in
Ronald Oussoren5bbab3e2009-09-06 11:01:15 +00001549 i386)
1550 MACOSX_DEFAULT_ARCH="i386"
1551 ;;
1552 ppc)
1553 MACOSX_DEFAULT_ARCH="ppc"
1554 ;;
1555 *)
1556 AC_MSG_ERROR([Unexpected output of 'arch' on OSX])
1557 ;;
1558 esac
1559 else
Ronald Oussorene3da75a2010-02-11 13:38:58 +00001560 case `/usr/bin/arch` in
Ronald Oussoren5bbab3e2009-09-06 11:01:15 +00001561 i386)
1562 MACOSX_DEFAULT_ARCH="x86_64"
1563 ;;
1564 ppc)
1565 MACOSX_DEFAULT_ARCH="ppc64"
1566 ;;
1567 *)
1568 AC_MSG_ERROR([Unexpected output of 'arch' on OSX])
1569 ;;
1570 esac
1571
1572 #ARCH_RUN_32BIT="true"
1573 fi
1574
1575 LIBTOOL_CRUFT=$LIBTOOL_CRUFT" -lSystem -lSystemStubs -arch_only ${MACOSX_DEFAULT_ARCH}"
Jack Jansenb36687a2004-07-16 08:43:47 +00001576 LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -install_name $(PYTHONFRAMEWORKINSTALLDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001577 LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -compatibility_version $(VERSION) -current_version $(VERSION)';;
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001578esac
1579
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001580AC_MSG_CHECKING(for --enable-framework)
1581if test "$enable_framework"
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001582then
Skip Montanarodecc6a42003-01-01 20:07:49 +00001583 BASECFLAGS="$BASECFLAGS -fno-common -dynamic"
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001584 # -F. is needed to allow linking to the framework while
1585 # in the build location.
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001586 AC_DEFINE(WITH_NEXT_FRAMEWORK, 1,
1587 [Define if you want to produce an OpenStep/Rhapsody framework
1588 (shared library plus accessory files).])
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001589 AC_MSG_RESULT(yes)
Ronald Oussoren99aab652009-06-08 21:22:57 +00001590 if test $enable_shared = "yes"
1591 then
1592 AC_MSG_ERROR([Specifying both --enable-shared and --enable-framework is not supported, use only --enable-framework instead])
1593 fi
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001594else
1595 AC_MSG_RESULT(no)
1596fi
1597
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001598AC_MSG_CHECKING(for dyld)
Jack Jansen9a66b6d2001-08-08 13:56:14 +00001599case $ac_sys_system/$ac_sys_release in
1600 Darwin/*)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001601 AC_DEFINE(WITH_DYLD, 1,
1602 [Define if you want to use the new-style (Openstep, Rhapsody, MacOS)
1603 dynamic linker (dyld) instead of the old-style (NextStep) dynamic
1604 linker (rld). Dyld is necessary to support frameworks.])
Jack Jansen9a66b6d2001-08-08 13:56:14 +00001605 AC_MSG_RESULT(always on for Darwin)
1606 ;;
1607 *)
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001608 AC_MSG_RESULT(no)
1609 ;;
Jack Jansen9a66b6d2001-08-08 13:56:14 +00001610esac
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001611
Guido van Rossumac405f61994-09-12 10:56:06 +00001612# Set info about shared libraries.
Guido van Rossumac405f61994-09-12 10:56:06 +00001613AC_SUBST(SO)
1614AC_SUBST(LDSHARED)
Neil Schemenauerb3531b82001-02-16 04:09:05 +00001615AC_SUBST(BLDSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00001616AC_SUBST(CCSHARED)
1617AC_SUBST(LINKFORSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00001618# SO is the extension of shared libraries `(including the dot!)
Guido van Rossumaef734b2001-01-10 21:09:12 +00001619# -- usually .so, .sl on HP-UX, .dll on Cygwin
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001620AC_MSG_CHECKING(SO)
Guido van Rossumac405f61994-09-12 10:56:06 +00001621if test -z "$SO"
1622then
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001623 case $ac_sys_system in
Thomas Wouters477c8d52006-05-27 19:21:47 +00001624 hp*|HP*)
1625 case `uname -m` in
1626 ia64) SO=.so;;
1627 *) SO=.sl;;
1628 esac
1629 ;;
Guido van Rossumaef734b2001-01-10 21:09:12 +00001630 CYGWIN*) SO=.dll;;
Guido van Rossum4b6b5791996-09-09 20:09:34 +00001631 *) SO=.so;;
Guido van Rossumac405f61994-09-12 10:56:06 +00001632 esac
Martin v. Löwis368de8f2003-06-14 14:46:38 +00001633else
1634 # this might also be a termcap variable, see #610332
1635 echo
1636 echo '====================================================================='
1637 echo '+ +'
1638 echo '+ WARNING: You have set SO in your environment. +'
1639 echo '+ Do you really mean to change the extension for shared libraries? +'
1640 echo '+ Continuing in 10 seconds to let you to ponder. +'
1641 echo '+ +'
1642 echo '====================================================================='
1643 sleep 10
Guido van Rossumac405f61994-09-12 10:56:06 +00001644fi
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001645AC_MSG_RESULT($SO)
Georg Brandlb1441c72009-01-03 22:33:39 +00001646
Thomas Wouters477c8d52006-05-27 19:21:47 +00001647AC_DEFINE_UNQUOTED(SHLIB_EXT, "$SO", [Define this to be extension of shared libraries (including the dot!).])
Guido van Rossumac405f61994-09-12 10:56:06 +00001648# LDSHARED is the ld *command* used to create shared library
Skip Montanaroce59c042004-01-17 14:19:44 +00001649# -- "cc -G" on SunOS 5.x, "ld -shared" on IRIX 5
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001650# (Shared libraries in this instance are shared modules to be loaded into
1651# Python, as opposed to building Python itself as a shared library.)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001652AC_MSG_CHECKING(LDSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00001653if test -z "$LDSHARED"
1654then
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001655 case $ac_sys_system/$ac_sys_release in
Neil Schemenauerb3531b82001-02-16 04:09:05 +00001656 AIX*)
1657 BLDSHARED="\$(srcdir)/Modules/ld_so_aix \$(CC) -bI:Modules/python.exp"
Guido van Rossumce608b02001-09-28 15:59:38 +00001658 LDSHARED="\$(BINLIBDEST)/config/ld_so_aix \$(CC) -bI:\$(BINLIBDEST)/config/python.exp"
Neil Schemenauerb3531b82001-02-16 04:09:05 +00001659 ;;
Guido van Rossum6100aaf1997-04-29 21:48:51 +00001660 IRIX/5*) LDSHARED="ld -shared";;
Guido van Rossum91922671997-10-09 20:24:13 +00001661 IRIX*/6*) LDSHARED="ld ${SGI_ABI} -shared -all";;
Greg Ward57c9a662000-05-26 12:22:54 +00001662 SunOS/5*)
1663 if test "$GCC" = "yes"
Neil Schemenauer95052722001-02-19 18:17:33 +00001664 then LDSHARED='$(CC) -shared'
Martin v. Löwisaa5afe12002-10-07 06:21:41 +00001665 else LDSHARED='$(CC) -G';
Greg Ward57c9a662000-05-26 12:22:54 +00001666 fi ;;
Thomas Hellerf44b9a12008-04-04 10:18:23 +00001667 hp*|HP*)
1668 if test "$GCC" = "yes"
1669 then LDSHARED='$(CC) -shared'
1670 else LDSHARED='ld -b';
1671 fi ;;
Guido van Rossum71001e41995-01-26 00:44:03 +00001672 OSF*) LDSHARED="ld -shared -expect_unresolved \"*\"";;
Jack Jansen418c3b12001-11-14 10:59:57 +00001673 Darwin/1.3*)
Jack Jansena3891ea2001-09-07 14:25:12 +00001674 LDSHARED='$(CC) $(LDFLAGS) -bundle'
1675 if test "$enable_framework" ; then
1676 # Link against the framework. All externals should be defined.
Jack Jansenda49e192005-01-07 13:08:22 +00001677 BLDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
1678 LDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansena3891ea2001-09-07 14:25:12 +00001679 else
1680 # No framework. Ignore undefined symbols, assuming they come from Python
Jack Jansen418c3b12001-11-14 10:59:57 +00001681 LDSHARED="$LDSHARED -undefined suppress"
Jack Jansena3891ea2001-09-07 14:25:12 +00001682 fi ;;
Jack Jansen6b08a402004-06-03 12:41:45 +00001683 Darwin/1.4*|Darwin/5.*|Darwin/6.*)
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001684 LDSHARED='$(CC) $(LDFLAGS) -bundle'
1685 if test "$enable_framework" ; then
1686 # Link against the framework. All externals should be defined.
Jack Jansenda49e192005-01-07 13:08:22 +00001687 BLDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
1688 LDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001689 else
Michael W. Hudson0c46c0c2002-03-07 09:58:56 +00001690 # No framework, use the Python app as bundle-loader
1691 BLDSHARED="$LDSHARED "'-bundle_loader $(BUILDPYTHON)'
Jack Jansenc28fc372003-02-25 13:14:43 +00001692 LDSHARED="$LDSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)'
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001693 fi ;;
Jack Jansen6b08a402004-06-03 12:41:45 +00001694 Darwin/*)
1695 # Use -undefined dynamic_lookup whenever possible (10.3 and later).
1696 # This allows an extension to be used in any Python
Thomas Wouters89d996e2007-09-08 17:39:28 +00001697
Georg Brandlfcaf9102008-07-16 02:17:56 +00001698 if test ${MACOSX_DEPLOYMENT_TARGET} '>' 10.2
Jack Jansen6b08a402004-06-03 12:41:45 +00001699 then
Thomas Wouters477c8d52006-05-27 19:21:47 +00001700 if test "${enable_universalsdk}"; then
Georg Brandlfcaf9102008-07-16 02:17:56 +00001701 LDFLAGS="${UNIVERSAL_ARCH_FLAGS} -isysroot ${UNIVERSALSDK} ${LDFLAGS}"
Thomas Wouters477c8d52006-05-27 19:21:47 +00001702 fi
Jack Jansen6b08a402004-06-03 12:41:45 +00001703 LDSHARED='$(CC) $(LDFLAGS) -bundle -undefined dynamic_lookup'
1704 BLDSHARED="$LDSHARED"
Jack Jansen6b08a402004-06-03 12:41:45 +00001705 else
1706 LDSHARED='$(CC) $(LDFLAGS) -bundle'
1707 if test "$enable_framework" ; then
1708 # Link against the framework. All externals should be defined.
Jack Jansenda49e192005-01-07 13:08:22 +00001709 BLDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
1710 LDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansen6b08a402004-06-03 12:41:45 +00001711 else
1712 # No framework, use the Python app as bundle-loader
1713 BLDSHARED="$LDSHARED "'-bundle_loader $(BUILDPYTHON)'
1714 LDSHARED="$LDSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)'
1715 fi
1716 fi
1717 ;;
Georg Brandlf78e02b2008-06-10 17:40:04 +00001718 Linux*|GNU*|QNX*) LDSHARED='$(CC) -shared';;
Guido van Rossum458e7fa1999-09-17 15:40:40 +00001719 BSD/OS*/4*) LDSHARED="gcc -shared";;
Thomas Wouters1ba5b3b2006-06-08 14:52:47 +00001720 FreeBSD*)
Jeremy Hylton4bcc7c52000-08-31 17:45:35 +00001721 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
Guido van Rossum0286ae82000-08-29 15:06:49 +00001722 then
Hye-Shik Chang33761492004-10-26 09:53:46 +00001723 LDSHARED="$CC -shared ${LDFLAGS}"
Guido van Rossum0286ae82000-08-29 15:06:49 +00001724 else
1725 LDSHARED="ld -Bshareable ${LDFLAGS}"
1726 fi;;
Thomas Wouters1ba5b3b2006-06-08 14:52:47 +00001727 OpenBSD*)
1728 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
1729 then
1730 LDSHARED='$(CC) -shared $(CCSHARED) ${LDFLAGS}'
1731 else
1732 case `uname -r` in
1733 [[01]].* | 2.[[0-7]] | 2.[[0-7]].*)
1734 LDSHARED="ld -Bshareable ${LDFLAGS}"
1735 ;;
1736 *)
1737 LDSHARED='$(CC) -shared $(CCSHARED) ${LDFLAGS}'
1738 ;;
1739 esac
1740 fi;;
Martin v. Löwis86d66262006-02-17 08:40:11 +00001741 NetBSD*|DragonFly*) LDSHARED="cc -shared ${LDFLAGS}";;
Martin v. Löwis25ae43b2001-10-07 08:39:18 +00001742 OpenUNIX*|UnixWare*)
Martin v. Löwisbec19582001-03-21 15:57:54 +00001743 if test "$GCC" = "yes"
Martin v. Löwis79f3c532002-12-11 12:51:58 +00001744 then LDSHARED='$(CC) -shared'
1745 else LDSHARED='$(CC) -G'
Martin v. Löwisbec19582001-03-21 15:57:54 +00001746 fi;;
Martin v. Löwis79f3c532002-12-11 12:51:58 +00001747 SCO_SV*) LDSHARED='$(CC) -Wl,-G,-Bexport';;
Guido van Rossumaef734b2001-01-10 21:09:12 +00001748 CYGWIN*) LDSHARED="gcc -shared -Wl,--enable-auto-image-base";;
Guido van Rossumac405f61994-09-12 10:56:06 +00001749 *) LDSHARED="ld";;
1750 esac
Guido van Rossumac405f61994-09-12 10:56:06 +00001751fi
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001752AC_MSG_RESULT($LDSHARED)
Neil Schemenauerb3531b82001-02-16 04:09:05 +00001753BLDSHARED=${BLDSHARED-$LDSHARED}
Guido van Rossumac405f61994-09-12 10:56:06 +00001754# CCSHARED are the C *flags* used to create objects to go into a shared
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001755# library (module) -- this is only needed for a few systems
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001756AC_MSG_CHECKING(CCSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00001757if test -z "$CCSHARED"
1758then
Guido van Rossum6100aaf1997-04-29 21:48:51 +00001759 case $ac_sys_system/$ac_sys_release in
Neil Schemenauer66252162001-02-19 04:47:42 +00001760 SunOS*) if test "$GCC" = yes;
Guido van Rossumd8faa362007-04-27 19:54:29 +00001761 then CCSHARED="-fPIC";
1762 elif test `uname -p` = sparc;
1763 then CCSHARED="-xcode=pic32";
1764 else CCSHARED="-Kpic";
1765 fi;;
Guido van Rossumaf07a441995-02-13 19:45:27 +00001766 hp*|HP*) if test "$GCC" = yes;
Martin v. Löwis703ad702001-09-05 08:36:52 +00001767 then CCSHARED="-fPIC";
Guido van Rossumaf07a441995-02-13 19:45:27 +00001768 else CCSHARED="+z";
1769 fi;;
Martin v. Löwisa6e97582002-01-01 18:41:33 +00001770 Linux*|GNU*) CCSHARED="-fPIC";;
Guido van Rossumf5957ea1999-10-05 21:59:33 +00001771 BSD/OS*/4*) CCSHARED="-fpic";;
Martin v. Löwis86d66262006-02-17 08:40:11 +00001772 FreeBSD*|NetBSD*|OpenBSD*|DragonFly*) CCSHARED="-fPIC";;
Martin v. Löwis25ae43b2001-10-07 08:39:18 +00001773 OpenUNIX*|UnixWare*)
Martin v. Löwisbec19582001-03-21 15:57:54 +00001774 if test "$GCC" = "yes"
1775 then CCSHARED="-fPIC"
Martin v. Löwis130fb172001-07-19 11:00:41 +00001776 else CCSHARED="-KPIC"
Martin v. Löwisbec19582001-03-21 15:57:54 +00001777 fi;;
Martin v. Löwis21ee4092002-09-30 16:19:48 +00001778 SCO_SV*)
1779 if test "$GCC" = "yes"
1780 then CCSHARED="-fPIC"
1781 else CCSHARED="-Kpic -belf"
1782 fi;;
Guido van Rossum2b5ca001998-03-05 15:41:09 +00001783 IRIX*/6*) case $CC in
1784 *gcc*) CCSHARED="-shared";;
Guido van Rossumee21f411998-04-20 18:51:54 +00001785 *) CCSHARED="";;
Guido van Rossum2b5ca001998-03-05 15:41:09 +00001786 esac;;
Guido van Rossumac405f61994-09-12 10:56:06 +00001787 esac
Guido van Rossumac405f61994-09-12 10:56:06 +00001788fi
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001789AC_MSG_RESULT($CCSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00001790# LINKFORSHARED are the flags passed to the $(CC) command that links
Guido van Rossumb65a48e1995-06-14 18:21:23 +00001791# the python executable -- this is only needed for a few systems
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001792AC_MSG_CHECKING(LINKFORSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00001793if test -z "$LINKFORSHARED"
1794then
Guido van Rossum6100aaf1997-04-29 21:48:51 +00001795 case $ac_sys_system/$ac_sys_release in
Neil Schemenauerb3531b82001-02-16 04:09:05 +00001796 AIX*) LINKFORSHARED='-Wl,-bE:Modules/python.exp -lld';;
Guido van Rossum5dab3d81996-12-06 21:18:18 +00001797 hp*|HP*)
Martin v. Löwis1142de32002-03-29 16:28:31 +00001798 LINKFORSHARED="-Wl,-E -Wl,+s";;
1799# LINKFORSHARED="-Wl,-E -Wl,+s -Wl,+b\$(BINLIBDEST)/lib-dynload";;
Guido van Rossumf5957ea1999-10-05 21:59:33 +00001800 BSD/OS/4*) LINKFORSHARED="-Xlinker -export-dynamic";;
Martin v. Löwisa6e97582002-01-01 18:41:33 +00001801 Linux*|GNU*) LINKFORSHARED="-Xlinker -export-dynamic";;
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001802 # -u libsys_s pulls in all symbols in libsys
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001803 Darwin/*)
Benjamin Peterson9c80cac2009-05-23 16:34:23 +00001804 LINKFORSHARED="$extra_undefs -framework CoreFoundation"
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001805 if test "$enable_framework"
1806 then
Jack Jansenda49e192005-01-07 13:08:22 +00001807 LINKFORSHARED="$LINKFORSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001808 fi
Raymond Hettingerec6eb362004-11-05 07:02:59 +00001809 LINKFORSHARED="$LINKFORSHARED";;
Martin v. Löwis25ae43b2001-10-07 08:39:18 +00001810 OpenUNIX*|UnixWare*) LINKFORSHARED="-Wl,-Bexport";;
Martin v. Löwis21ee4092002-09-30 16:19:48 +00001811 SCO_SV*) LINKFORSHARED="-Wl,-Bexport";;
Fred Drake02706f52000-09-25 15:08:46 +00001812 ReliantUNIX*) LINKFORSHARED="-W1 -Blargedynsym";;
Martin v. Löwis86d66262006-02-17 08:40:11 +00001813 FreeBSD*|NetBSD*|OpenBSD*|DragonFly*)
Guido van Rossumdf693651999-01-07 21:50:41 +00001814 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
1815 then
1816 LINKFORSHARED="-Wl,--export-dynamic"
1817 fi;;
Guido van Rossum2b5ca001998-03-05 15:41:09 +00001818 SunOS/5*) case $CC in
1819 *gcc*)
Martin v. Löwisa4548572002-04-18 14:51:36 +00001820 if $CC -Xlinker --help 2>&1 | grep export-dynamic >/dev/null
Guido van Rossum8f4ceb11997-12-18 23:42:19 +00001821 then
1822 LINKFORSHARED="-Xlinker --export-dynamic"
Guido van Rossum2b5ca001998-03-05 15:41:09 +00001823 fi;;
1824 esac;;
Jason Tishler30765592003-09-04 11:04:06 +00001825 CYGWIN*)
1826 if test $enable_shared = "no"
1827 then
1828 LINKFORSHARED='-Wl,--out-implib=$(LDLIBRARY)'
1829 fi;;
Georg Brandlf78e02b2008-06-10 17:40:04 +00001830 QNX*)
1831 # -Wl,-E causes the symbols to be added to the dynamic
1832 # symbol table so that they can be found when a module
1833 # is loaded. -N 2048K causes the stack size to be set
1834 # to 2048 kilobytes so that the stack doesn't overflow
1835 # when running test_compile.py.
1836 LINKFORSHARED='-Wl,-E -N 2048K';;
Guido van Rossumac405f61994-09-12 10:56:06 +00001837 esac
Guido van Rossumac405f61994-09-12 10:56:06 +00001838fi
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001839AC_MSG_RESULT($LINKFORSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00001840
Georg Brandl93de2162008-07-16 02:21:06 +00001841
Neil Schemenauer61c51152001-01-26 16:18:16 +00001842AC_SUBST(CFLAGSFORSHARED)
1843AC_MSG_CHECKING(CFLAGSFORSHARED)
1844if test ! "$LIBRARY" = "$LDLIBRARY"
1845then
Neil Schemenauerd9cf41c2001-01-27 21:39:17 +00001846 case $ac_sys_system in
1847 CYGWIN*)
1848 # Cygwin needs CCSHARED when building extension DLLs
1849 # but not when building the interpreter DLL.
1850 CFLAGSFORSHARED='';;
1851 *)
1852 CFLAGSFORSHARED='$(CCSHARED)'
1853 esac
Neil Schemenauer61c51152001-01-26 16:18:16 +00001854fi
1855AC_MSG_RESULT($CFLAGSFORSHARED)
1856
Martin v. Löwisf90ae202002-06-11 06:22:31 +00001857# SHLIBS are libraries (except -lc and -lm) to link to the python shared
1858# library (with --enable-shared).
1859# For platforms on which shared libraries are not allowed to have unresolved
Martin v. Löwisd6359c52002-08-04 12:38:50 +00001860# symbols, this must be set to $(LIBS) (expanded by make). We do this even
1861# if it is not required, since it creates a dependency of the shared library
1862# to LIBS. This, in turn, means that applications linking the shared libpython
1863# don't need to link LIBS explicitly. The default should be only changed
1864# on systems where this approach causes problems.
Martin v. Löwisf90ae202002-06-11 06:22:31 +00001865AC_SUBST(SHLIBS)
1866AC_MSG_CHECKING(SHLIBS)
1867case "$ac_sys_system" in
Martin v. Löwisf90ae202002-06-11 06:22:31 +00001868 *)
Martin v. Löwisd6359c52002-08-04 12:38:50 +00001869 SHLIBS='$(LIBS)';;
Martin v. Löwisf90ae202002-06-11 06:22:31 +00001870esac
1871AC_MSG_RESULT($SHLIBS)
1872
1873
Guido van Rossum627b2d71993-12-24 10:39:16 +00001874# checks for libraries
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001875AC_CHECK_LIB(dl, dlopen) # Dynamic linking for SunOS/Solaris and SYSV
1876AC_CHECK_LIB(dld, shl_load) # Dynamic linking for HP-UX
Martin v. Löwis519adae2003-09-20 10:47:47 +00001877
Georg Brandleee31162008-12-07 15:15:22 +00001878# only check for sem_init if thread support is requested
Martin v. Löwis519adae2003-09-20 10:47:47 +00001879if test "$with_threads" = "yes" -o -z "$with_threads"; then
1880 AC_SEARCH_LIBS(sem_init, pthread rt posix4) # 'Real Time' functions on Solaris
1881 # posix4 on Solaris 2.6
1882 # pthread (first!) on Linux
1883fi
1884
Martin v. Löwis19d17342003-06-14 21:03:05 +00001885# check if we need libintl for locale functions
1886AC_CHECK_LIB(intl, textdomain,
Brett Cannonc6d936e2009-06-07 20:09:53 +00001887 [AC_DEFINE(WITH_LIBINTL, 1,
1888 [Define to 1 if libintl is needed for locale functions.])
1889 LIBS="-lintl $LIBS"])
Guido van Rossum0eefa3f1999-11-16 15:57:37 +00001890
1891# checks for system dependent C++ extensions support
1892case "$ac_sys_system" in
1893 AIX*) AC_MSG_CHECKING(for genuine AIX C++ extensions support)
1894 AC_TRY_LINK([#include "/usr/lpp/xlC/include/load.h"],
1895 [loadAndInit("", 0, "")],
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001896 [AC_DEFINE(AIX_GENUINE_CPLUSPLUS, 1,
1897 [Define for AIX if your compiler is a genuine IBM xlC/xlC_r
1898 and you want support for AIX C++ shared extension modules.])
Guido van Rossum0eefa3f1999-11-16 15:57:37 +00001899 AC_MSG_RESULT(yes)],
1900 [AC_MSG_RESULT(no)]);;
1901 *) ;;
1902esac
1903
Guido van Rossum70c7f481998-03-26 18:44:10 +00001904# Most SVR4 platforms (e.g. Solaris) need -lsocket and -lnsl.
Guido van Rossumf618d2c1995-01-17 16:36:13 +00001905AC_CHECK_LIB(nsl, t_open, [LIBS="-lnsl $LIBS"]) # SVR4
Guido van Rossumf618d2c1995-01-17 16:36:13 +00001906AC_CHECK_LIB(socket, socket, [LIBS="-lsocket $LIBS"], [], $LIBS) # SVR4 sockets
Skip Montanarob9949db2004-01-17 04:04:13 +00001907
Guido van Rossumc5a39031996-07-31 17:35:03 +00001908AC_MSG_CHECKING(for --with-libs)
Barry Warsawc0d24d82000-06-29 16:12:00 +00001909AC_ARG_WITH(libs,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00001910 AC_HELP_STRING(--with-libs='lib1 ...', link against additional libs),
1911[
Guido van Rossumc5a39031996-07-31 17:35:03 +00001912AC_MSG_RESULT($withval)
1913LIBS="$withval $LIBS"
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00001914],
1915[AC_MSG_RESULT(no)])
Guido van Rossum627b2d71993-12-24 10:39:16 +00001916
Benjamin Petersonb2d90462009-12-31 03:23:10 +00001917# Check for use of the system expat library
1918AC_MSG_CHECKING(for --with-system-expat)
1919AC_ARG_WITH(system_expat,
1920 AC_HELP_STRING(--with-system-expat, build pyexpat module using an installed expat library))
1921
1922AC_MSG_RESULT($with_system_expat)
1923
Thomas Wouters49fd7fa2006-04-21 10:40:58 +00001924# Check for use of the system libffi library
1925AC_MSG_CHECKING(for --with-system-ffi)
1926AC_ARG_WITH(system_ffi,
1927 AC_HELP_STRING(--with-system-ffi, build _ctypes module using an installed ffi library))
1928
Benjamin Petersond78735d2010-01-01 16:04:23 +00001929if test "$with_system_ffi" = "yes"; then
1930 AC_PATH_TOOL([PKG_CONFIG], [pkg-config])
1931 LIBFFI_INCLUDEDIR="`"$PKG_CONFIG" libffi --cflags-only-I 2>/dev/null | sed -e 's/^-I//;s/ *$//'`"
1932else
1933 LIBFFI_INCLUDEDIR=""
1934fi
1935AC_SUBST(LIBFFI_INCLUDEDIR)
1936
Thomas Wouters49fd7fa2006-04-21 10:40:58 +00001937AC_MSG_RESULT($with_system_ffi)
1938
Matthias Klose55708cc2009-04-30 08:06:49 +00001939# Check for --with-dbmliborder
1940AC_MSG_CHECKING(for --with-dbmliborder)
1941AC_ARG_WITH(dbmliborder,
1942 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'.]),
1943[
1944if test x$with_dbmliborder = xyes
1945then
1946AC_MSG_ERROR([proper usage is --with-dbmliborder=db1:db2:...])
1947else
1948 for db in `echo $with_dbmliborder | sed 's/:/ /g'`; do
1949 if test x$db != xndbm && test x$db != xgdbm && test x$db != xbdb
1950 then
1951 AC_MSG_ERROR([proper usage is --with-dbmliborder=db1:db2:...])
1952 fi
1953 done
1954fi])
1955AC_MSG_RESULT($with_dbmliborder)
1956
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00001957# Determine if signalmodule should be used.
1958AC_SUBST(USE_SIGNAL_MODULE)
1959AC_SUBST(SIGNAL_OBJS)
1960AC_MSG_CHECKING(for --with-signal-module)
1961AC_ARG_WITH(signal-module,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00001962 AC_HELP_STRING(--with-signal-module, disable/enable signal module))
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00001963
1964if test -z "$with_signal_module"
1965then with_signal_module="yes"
1966fi
1967AC_MSG_RESULT($with_signal_module)
1968
1969if test "${with_signal_module}" = "yes"; then
1970 USE_SIGNAL_MODULE=""
1971 SIGNAL_OBJS=""
1972else
1973 USE_SIGNAL_MODULE="#"
1974 SIGNAL_OBJS="Parser/intrcheck.o Python/sigcheck.o"
1975fi
1976
Guido van Rossum3d15bd82001-01-10 18:53:48 +00001977# This is used to generate Setup.config
Guido van Rossum009f7871997-12-04 00:51:42 +00001978AC_SUBST(USE_THREAD_MODULE)
Barry Warsawc0d24d82000-06-29 16:12:00 +00001979USE_THREAD_MODULE=""
Guido van Rossum009f7871997-12-04 00:51:42 +00001980
Guido van Rossum54d93d41997-01-22 20:51:58 +00001981AC_MSG_CHECKING(for --with-dec-threads)
1982AC_SUBST(LDLAST)
1983AC_ARG_WITH(dec-threads,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00001984 AC_HELP_STRING(--with-dec-threads, use DEC Alpha/OSF1 thread-safe libraries),
1985[
Barry Warsawc0d24d82000-06-29 16:12:00 +00001986AC_MSG_RESULT($withval)
Guido van Rossum54d93d41997-01-22 20:51:58 +00001987LDLAST=-threads
Guido van Rossumf78abae1997-01-21 22:02:36 +00001988if test "${with_thread+set}" != set; then
Guido van Rossum54d93d41997-01-22 20:51:58 +00001989 with_thread="$withval";
1990fi],
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00001991[AC_MSG_RESULT(no)])
Guido van Rossum54d93d41997-01-22 20:51:58 +00001992
Martin v. Löwis11437992002-04-12 09:54:03 +00001993# Templates for things AC_DEFINEd more than once.
1994# For a single AC_DEFINE, no template is needed.
1995AH_TEMPLATE(C_THREADS,[Define if you have the Mach cthreads package])
1996AH_TEMPLATE(_REENTRANT,
1997 [Define to force use of thread-safe errno, h_errno, and other functions])
1998AH_TEMPLATE(WITH_THREAD,
1999 [Define if you want to compile in rudimentary thread support])
2000
Guido van Rossum54d93d41997-01-22 20:51:58 +00002001AC_MSG_CHECKING(for --with-threads)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002002dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
Barry Warsawc0d24d82000-06-29 16:12:00 +00002003AC_ARG_WITH(threads,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002004 AC_HELP_STRING(--with(out)-threads@<:@=DIRECTORY@:>@, disable/enable thread support))
Guido van Rossum54d93d41997-01-22 20:51:58 +00002005
Barry Warsawc0d24d82000-06-29 16:12:00 +00002006# --with-thread is deprecated, but check for it anyway
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002007dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
Barry Warsawa0f3c5c2000-06-30 16:39:35 +00002008AC_ARG_WITH(thread,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002009 AC_HELP_STRING(--with(out)-thread@<:@=DIRECTORY@:>@, deprecated; use --with(out)-threads),
2010 [with_threads=$with_thread])
Barry Warsawc0d24d82000-06-29 16:12:00 +00002011
2012if test -z "$with_threads"
2013then with_threads="yes"
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002014fi
Barry Warsawc0d24d82000-06-29 16:12:00 +00002015AC_MSG_RESULT($with_threads)
Guido van Rossum6400c261997-05-22 20:34:27 +00002016
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002017AC_SUBST(THREADOBJ)
Barry Warsawc0d24d82000-06-29 16:12:00 +00002018if test "$with_threads" = "no"
2019then
2020 USE_THREAD_MODULE="#"
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002021elif test "$ac_cv_pthread_is_default" = yes
2022then
2023 AC_DEFINE(WITH_THREAD)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002024 # Defining _REENTRANT on system with POSIX threads should not hurt.
2025 AC_DEFINE(_REENTRANT)
2026 posix_threads=yes
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002027 THREADOBJ="Python/thread.o"
Martin v. Löwis130fb172001-07-19 11:00:41 +00002028elif test "$ac_cv_kpthread" = "yes"
2029then
2030 CC="$CC -Kpthread"
Martin v. Löwis519adae2003-09-20 10:47:47 +00002031 if test "$ac_cv_cxx_thread" = "yes"; then
2032 CXX="$CXX -Kpthread"
2033 fi
Martin v. Löwis130fb172001-07-19 11:00:41 +00002034 AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002035 posix_threads=yes
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002036 THREADOBJ="Python/thread.o"
Martin v. Löwis5f433f02003-05-05 05:05:30 +00002037elif test "$ac_cv_kthread" = "yes"
2038then
2039 CC="$CC -Kthread"
Martin v. Löwis519adae2003-09-20 10:47:47 +00002040 if test "$ac_cv_cxx_thread" = "yes"; then
2041 CXX="$CXX -Kthread"
2042 fi
Martin v. Löwis5f433f02003-05-05 05:05:30 +00002043 AC_DEFINE(WITH_THREAD)
2044 posix_threads=yes
2045 THREADOBJ="Python/thread.o"
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002046elif test "$ac_cv_pthread" = "yes"
2047then
2048 CC="$CC -pthread"
Martin v. Löwis519adae2003-09-20 10:47:47 +00002049 if test "$ac_cv_cxx_thread" = "yes"; then
2050 CXX="$CXX -pthread"
2051 fi
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002052 AC_DEFINE(WITH_THREAD)
2053 posix_threads=yes
2054 THREADOBJ="Python/thread.o"
Barry Warsawc0d24d82000-06-29 16:12:00 +00002055else
Martin v. Löwis130fb172001-07-19 11:00:41 +00002056 if test ! -z "$with_threads" -a -d "$with_threads"
2057 then LDFLAGS="$LDFLAGS -L$with_threads"
2058 fi
2059 if test ! -z "$withval" -a -d "$withval"
2060 then LDFLAGS="$LDFLAGS -L$withval"
2061 fi
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002062
2063 # According to the POSIX spec, a pthreads implementation must
Matthias Klosea2542be2004-08-16 11:35:51 +00002064 # define _POSIX_THREADS in unistd.h. Some apparently don't
2065 # (e.g. gnu pth with pthread emulation)
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002066 AC_MSG_CHECKING(for _POSIX_THREADS in unistd.h)
2067 AC_EGREP_CPP(yes,
Neal Norwitz6eb37f02003-02-23 23:28:15 +00002068 [
2069#include <unistd.h>
2070#ifdef _POSIX_THREADS
2071yes
2072#endif
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002073 ], unistd_defines_pthreads=yes, unistd_defines_pthreads=no)
2074 AC_MSG_RESULT($unistd_defines_pthreads)
2075
Martin v. Löwis130fb172001-07-19 11:00:41 +00002076 AC_DEFINE(_REENTRANT)
Martin v. Löwisa6e97582002-01-01 18:41:33 +00002077 AC_CHECK_HEADER(cthreads.h, [AC_DEFINE(WITH_THREAD)
2078 AC_DEFINE(C_THREADS)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002079 AC_DEFINE(HURD_C_THREADS, 1,
2080 [Define if you are using Mach cthreads directly under /include])
Martin v. Löwisa6e97582002-01-01 18:41:33 +00002081 LIBS="$LIBS -lthreads"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002082 THREADOBJ="Python/thread.o"],[
Martin v. Löwis130fb172001-07-19 11:00:41 +00002083 AC_CHECK_HEADER(mach/cthreads.h, [AC_DEFINE(WITH_THREAD)
2084 AC_DEFINE(C_THREADS)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002085 AC_DEFINE(MACH_C_THREADS, 1,
2086 [Define if you are using Mach cthreads under mach /])
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002087 THREADOBJ="Python/thread.o"],[
Martin v. Löwis8158b5a2001-10-08 13:17:28 +00002088 # Just looking for pthread_create in libpthread is not enough:
2089 # on HP/UX, pthread.h renames pthread_create to a different symbol name.
2090 # So we really have to include pthread.h, and then link.
2091 _libs=$LIBS
2092 LIBS="$LIBS -lpthread"
2093 AC_MSG_CHECKING([for pthread_create in -lpthread])
2094 AC_TRY_LINK([#include <pthread.h>
2095
2096void * start_routine (void *arg) { exit (0); }], [
2097pthread_create (NULL, NULL, start_routine, NULL)], [
2098 AC_MSG_RESULT(yes)
2099 AC_DEFINE(WITH_THREAD)
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002100 posix_threads=yes
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002101 THREADOBJ="Python/thread.o"],[
Martin v. Löwis8158b5a2001-10-08 13:17:28 +00002102 LIBS=$_libs
Martin v. Löwis130fb172001-07-19 11:00:41 +00002103 AC_CHECK_FUNC(pthread_detach, [AC_DEFINE(WITH_THREAD)
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002104 posix_threads=yes
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002105 THREADOBJ="Python/thread.o"],[
Martin v. Löwis130fb172001-07-19 11:00:41 +00002106 AC_CHECK_LIB(pthreads, pthread_create, [AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002107 posix_threads=yes
Martin v. Löwis130fb172001-07-19 11:00:41 +00002108 LIBS="$LIBS -lpthreads"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002109 THREADOBJ="Python/thread.o"], [
Martin v. Löwis130fb172001-07-19 11:00:41 +00002110 AC_CHECK_LIB(c_r, pthread_create, [AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002111 posix_threads=yes
Martin v. Löwis130fb172001-07-19 11:00:41 +00002112 LIBS="$LIBS -lc_r"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002113 THREADOBJ="Python/thread.o"], [
Martin v. Löwis130fb172001-07-19 11:00:41 +00002114 AC_CHECK_LIB(pthread, __pthread_create_system, [AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002115 posix_threads=yes
Martin v. Löwis130fb172001-07-19 11:00:41 +00002116 LIBS="$LIBS -lpthread"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002117 THREADOBJ="Python/thread.o"], [
Martin v. Löwis130fb172001-07-19 11:00:41 +00002118 AC_CHECK_LIB(cma, pthread_create, [AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002119 posix_threads=yes
Martin v. Löwis130fb172001-07-19 11:00:41 +00002120 LIBS="$LIBS -lcma"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002121 THREADOBJ="Python/thread.o"],[
Martin v. Löwis130fb172001-07-19 11:00:41 +00002122 USE_THREAD_MODULE="#"])
Antoine Pitroudb6c5672009-10-24 20:35:52 +00002123 ])])])])])])])
Barry Warsawc0d24d82000-06-29 16:12:00 +00002124
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002125 AC_CHECK_LIB(mpc, usconfig, [AC_DEFINE(WITH_THREAD)
2126 LIBS="$LIBS -lmpc"
2127 THREADOBJ="Python/thread.o"
2128 USE_THREAD_MODULE=""])
2129
2130 if test "$posix_threads" != "yes"; then
2131 AC_CHECK_LIB(thread, thr_create, [AC_DEFINE(WITH_THREAD)
2132 LIBS="$LIBS -lthread"
2133 THREADOBJ="Python/thread.o"
2134 USE_THREAD_MODULE=""])
2135 fi
2136
2137 if test "$USE_THREAD_MODULE" != "#"
2138 then
2139 # If the above checks didn't disable threads, (at least) OSF1
2140 # needs this '-threads' argument during linking.
2141 case $ac_sys_system in
2142 OSF1) LDLAST=-threads;;
2143 esac
2144 fi
2145fi
2146
2147if test "$posix_threads" = "yes"; then
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002148 if test "$unistd_defines_pthreads" = "no"; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002149 AC_DEFINE(_POSIX_THREADS, 1,
2150 [Define if you have POSIX threads,
2151 and your system does not define that.])
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002152 fi
2153
Martin v. Löwisdfc33fd2003-01-21 10:14:41 +00002154 # Bug 662787: Using semaphores causes unexplicable hangs on Solaris 8.
2155 case $ac_sys_system/$ac_sys_release in
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002156 SunOS/5.6) AC_DEFINE(HAVE_PTHREAD_DESTRUCTOR, 1,
2157 Defined for Solaris 2.6 bug in pthread header.)
2158 ;;
Martin v. Löwisdfc33fd2003-01-21 10:14:41 +00002159 SunOS/5.8) AC_DEFINE(HAVE_BROKEN_POSIX_SEMAPHORES, 1,
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002160 Define if the Posix semaphores do not work on your system)
2161 ;;
Christian Heimes7b3ce6a2008-01-31 14:31:45 +00002162 AIX/5) AC_DEFINE(HAVE_BROKEN_POSIX_SEMAPHORES, 1,
2163 Define if the Posix semaphores do not work on your system)
2164 ;;
Martin v. Löwisdfc33fd2003-01-21 10:14:41 +00002165 esac
2166
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002167 AC_MSG_CHECKING(if PTHREAD_SCOPE_SYSTEM is supported)
2168 AC_CACHE_VAL(ac_cv_pthread_system_supported,
2169 [AC_TRY_RUN([#include <pthread.h>
2170 void *foo(void *parm) {
2171 return NULL;
2172 }
2173 main() {
2174 pthread_attr_t attr;
Martin v. Löwisa82d3472002-02-24 16:05:05 +00002175 pthread_t id;
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002176 if (pthread_attr_init(&attr)) exit(-1);
2177 if (pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM)) exit(-1);
Martin v. Löwisa82d3472002-02-24 16:05:05 +00002178 if (pthread_create(&id, &attr, foo, NULL)) exit(-1);
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002179 exit(0);
Guido van Rossum3065c942001-09-17 04:03:14 +00002180 }],
2181 ac_cv_pthread_system_supported=yes,
2182 ac_cv_pthread_system_supported=no,
2183 ac_cv_pthread_system_supported=no)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002184 ])
2185 AC_MSG_RESULT($ac_cv_pthread_system_supported)
2186 if test "$ac_cv_pthread_system_supported" = "yes"; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002187 AC_DEFINE(PTHREAD_SYSTEM_SCHED_SUPPORTED, 1, [Defined if PTHREAD_SCOPE_SYSTEM supported.])
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002188 fi
Jason Tishlerfac083d2003-07-22 15:20:49 +00002189 AC_CHECK_FUNCS(pthread_sigmask,
2190 [case $ac_sys_system in
2191 CYGWIN*)
2192 AC_DEFINE(HAVE_BROKEN_PTHREAD_SIGMASK, 1,
2193 [Define if pthread_sigmask() does not work on your system.])
2194 ;;
2195 esac])
Barry Warsawc0d24d82000-06-29 16:12:00 +00002196fi
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002197
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002198
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002199# Check for enable-ipv6
Martin v. Löwis11437992002-04-12 09:54:03 +00002200AH_TEMPLATE(ENABLE_IPV6, [Define if --enable-ipv6 is specified])
Martin v. Löwisa5f8bb52001-09-05 08:22:34 +00002201AC_MSG_CHECKING([if --enable-ipv6 is specified])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002202AC_ARG_ENABLE(ipv6,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002203[ --enable-ipv6 Enable ipv6 (with ipv4) support
2204 --disable-ipv6 Disable ipv6 support],
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002205[ case "$enableval" in
2206 no)
2207 AC_MSG_RESULT(no)
2208 ipv6=no
2209 ;;
2210 *) AC_MSG_RESULT(yes)
2211 AC_DEFINE(ENABLE_IPV6)
2212 ipv6=yes
2213 ;;
2214 esac ],
2215
Martin v. Löwisa5f8bb52001-09-05 08:22:34 +00002216[
2217dnl the check does not work on cross compilation case...
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002218 AC_TRY_RUN([ /* AF_INET6 available check */
2219#include <sys/types.h>
2220#include <sys/socket.h>
2221main()
2222{
2223 if (socket(AF_INET6, SOCK_STREAM, 0) < 0)
2224 exit(1);
2225 else
2226 exit(0);
2227}
2228],
2229 AC_MSG_RESULT(yes)
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002230 ipv6=yes,
2231 AC_MSG_RESULT(no)
2232 ipv6=no,
2233 AC_MSG_RESULT(no)
2234 ipv6=no
Martin v. Löwisa5f8bb52001-09-05 08:22:34 +00002235)
2236
2237if test "$ipv6" = "yes"; then
2238 AC_MSG_CHECKING(if RFC2553 API is available)
2239 AC_TRY_COMPILE([#include <sys/types.h>
2240#include <netinet/in.h>],
2241 [struct sockaddr_in6 x;
2242x.sin6_scope_id;],
2243 AC_MSG_RESULT(yes)
2244 ipv6=yes,
2245 AC_MSG_RESULT(no, IPv6 disabled)
2246 ipv6=no)
2247fi
2248
2249if test "$ipv6" = "yes"; then
2250 AC_DEFINE(ENABLE_IPV6)
2251fi
2252])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002253
2254ipv6type=unknown
2255ipv6lib=none
2256ipv6trylibc=no
2257
2258if test "$ipv6" = "yes"; then
2259 AC_MSG_CHECKING([ipv6 stack type])
Guido van Rossumb8552162001-09-05 14:58:11 +00002260 for i in inria kame linux-glibc linux-inet6 solaris toshiba v6d zeta;
2261 do
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002262 case $i in
2263 inria)
2264 dnl http://www.kame.net/
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002265 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002266#include <netinet/in.h>
2267#ifdef IPV6_INRIA_VERSION
2268yes
2269#endif],
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002270 [ipv6type=$i])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002271 ;;
2272 kame)
2273 dnl http://www.kame.net/
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002274 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002275#include <netinet/in.h>
2276#ifdef __KAME__
2277yes
2278#endif],
2279 [ipv6type=$i;
2280 ipv6lib=inet6
2281 ipv6libdir=/usr/local/v6/lib
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002282 ipv6trylibc=yes])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002283 ;;
2284 linux-glibc)
2285 dnl http://www.v6.linux.or.jp/
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002286 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002287#include <features.h>
2288#if defined(__GLIBC__) && ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1) || (__GLIBC__ > 2))
2289yes
2290#endif],
2291 [ipv6type=$i;
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002292 ipv6trylibc=yes])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002293 ;;
2294 linux-inet6)
2295 dnl http://www.v6.linux.or.jp/
2296 if test -d /usr/inet6; then
2297 ipv6type=$i
2298 ipv6lib=inet6
2299 ipv6libdir=/usr/inet6/lib
Skip Montanarodecc6a42003-01-01 20:07:49 +00002300 BASECFLAGS="-I/usr/inet6/include $BASECFLAGS"
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002301 fi
2302 ;;
2303 solaris)
2304 if test -f /etc/netconfig; then
2305 if /usr/xpg4/bin/grep -q tcp6 /etc/netconfig; then
2306 ipv6type=$i
2307 ipv6trylibc=yes
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002308 fi
2309 fi
2310 ;;
2311 toshiba)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002312 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002313#include <sys/param.h>
2314#ifdef _TOSHIBA_INET6
2315yes
2316#endif],
2317 [ipv6type=$i;
2318 ipv6lib=inet6;
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002319 ipv6libdir=/usr/local/v6/lib])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002320 ;;
2321 v6d)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002322 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002323#include </usr/local/v6/include/sys/v6config.h>
2324#ifdef __V6D__
2325yes
2326#endif],
2327 [ipv6type=$i;
2328 ipv6lib=v6;
2329 ipv6libdir=/usr/local/v6/lib;
Skip Montanarodecc6a42003-01-01 20:07:49 +00002330 BASECFLAGS="-I/usr/local/v6/include $BASECFLAGS"])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002331 ;;
2332 zeta)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002333 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002334#include <sys/param.h>
2335#ifdef _ZETA_MINAMI_INET6
2336yes
2337#endif],
2338 [ipv6type=$i;
2339 ipv6lib=inet6;
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002340 ipv6libdir=/usr/local/v6/lib])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002341 ;;
2342 esac
2343 if test "$ipv6type" != "unknown"; then
2344 break
2345 fi
2346 done
2347 AC_MSG_RESULT($ipv6type)
2348fi
2349
2350if test "$ipv6" = "yes" -a "$ipv6lib" != "none"; then
2351 if test -d $ipv6libdir -a -f $ipv6libdir/lib$ipv6lib.a; then
2352 LIBS="-L$ipv6libdir -l$ipv6lib $LIBS"
2353 echo "using lib$ipv6lib"
2354 else
2355 if test $ipv6trylibc = "yes"; then
2356 echo "using libc"
2357 else
2358 echo 'Fatal: no $ipv6lib library found. cannot continue.'
2359 echo "You need to fetch lib$ipv6lib.a from appropriate"
2360 echo 'ipv6 kit and compile beforehand.'
2361 exit 1
2362 fi
2363 fi
2364fi
2365
Georg Brandl93de2162008-07-16 02:21:06 +00002366AC_MSG_CHECKING(for OSX 10.5 SDK or later)
2367AC_TRY_COMPILE([#include <Carbon/Carbon.h>], FSIORefNum fRef = 0,
2368 AC_DEFINE(HAVE_OSX105_SDK, 1, Define if compiling using MacOS X 10.5 SDK or later.)
2369 AC_MSG_RESULT(yes),
2370 AC_MSG_RESULT(no)
2371)
2372
Martin v. Löwisa3fb4f72002-06-09 13:33:54 +00002373# Check for --with-doc-strings
2374AC_MSG_CHECKING(for --with-doc-strings)
2375AC_ARG_WITH(doc-strings,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002376 AC_HELP_STRING(--with(out)-doc-strings, disable/enable documentation strings))
Martin v. Löwisa3fb4f72002-06-09 13:33:54 +00002377
2378if test -z "$with_doc_strings"
2379then with_doc_strings="yes"
2380fi
2381if test "$with_doc_strings" != "no"
2382then
2383 AC_DEFINE(WITH_DOC_STRINGS, 1,
2384 [Define if you want documentation strings in extension modules])
2385fi
2386AC_MSG_RESULT($with_doc_strings)
2387
Neil Schemenauera35c6882001-02-27 04:45:05 +00002388# Check for Python-specific malloc support
Martin v. Löwisf30d60e2004-06-08 08:17:44 +00002389AC_MSG_CHECKING(for --with-tsc)
2390AC_ARG_WITH(tsc,
2391[ --with(out)-tsc enable/disable timestamp counter profile], [
2392if test "$withval" != no
2393then
2394 AC_DEFINE(WITH_TSC, 1,
2395 [Define to profile with the Pentium timestamp counter])
2396 AC_MSG_RESULT(yes)
2397else AC_MSG_RESULT(no)
2398fi],
2399[AC_MSG_RESULT(no)])
2400
2401# Check for Python-specific malloc support
Neil Schemenauera35c6882001-02-27 04:45:05 +00002402AC_MSG_CHECKING(for --with-pymalloc)
2403AC_ARG_WITH(pymalloc,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002404 AC_HELP_STRING(--with(out)-pymalloc, disable/enable specialized mallocs))
Neil Schemenauer16c22972002-03-22 15:34:49 +00002405
2406if test -z "$with_pymalloc"
2407then with_pymalloc="yes"
2408fi
2409if test "$with_pymalloc" != "no"
2410then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002411 AC_DEFINE(WITH_PYMALLOC, 1,
2412 [Define if you want to compile in Python-specific mallocs])
Neil Schemenauer16c22972002-03-22 15:34:49 +00002413fi
2414AC_MSG_RESULT($with_pymalloc)
Neil Schemenauera35c6882001-02-27 04:45:05 +00002415
Benjamin Peterson05159c42009-12-03 03:01:27 +00002416# Check for Valgrind support
2417AC_MSG_CHECKING([for --with-valgrind])
2418AC_ARG_WITH([valgrind],
2419 AC_HELP_STRING([--with-valgrind], [Enable Valgrind support]),,
2420 with_valgrind=no)
2421AC_MSG_RESULT([$with_valgrind])
2422if test "$with_valgrind" != no; then
2423 AC_CHECK_HEADER([valgrind/valgrind.h],
2424 [AC_DEFINE([WITH_VALGRIND], 1, [Define if you want pymalloc to be disabled when running under valgrind])],
2425 [AC_MSG_ERROR([Valgrind support requested but headers not available])]
2426 )
2427fi
2428
Barry Warsawef82cd72000-06-30 16:21:01 +00002429# Check for --with-wctype-functions
2430AC_MSG_CHECKING(for --with-wctype-functions)
2431AC_ARG_WITH(wctype-functions,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002432 AC_HELP_STRING(--with-wctype-functions, use wctype.h functions),
2433[
Barry Warsawef82cd72000-06-30 16:21:01 +00002434if test "$withval" != no
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002435then
2436 AC_DEFINE(WANT_WCTYPE_FUNCTIONS, 1,
2437 [Define if you want wctype.h functions to be used instead of the
2438 one supplied by Python itself. (see Include/unicodectype.h).])
2439 AC_MSG_RESULT(yes)
Barry Warsawef82cd72000-06-30 16:21:01 +00002440else AC_MSG_RESULT(no)
2441fi],
2442[AC_MSG_RESULT(no)])
2443
Guido van Rossum68242b51996-05-28 22:53:03 +00002444# -I${DLINCLDIR} is added to the compile rule for importdl.o
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002445AC_SUBST(DLINCLDIR)
Guido van Rossum98935bf2001-09-05 19:13:16 +00002446DLINCLDIR=.
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002447
Guido van Rossume97ee181999-12-20 21:27:22 +00002448# the dlopen() function means we might want to use dynload_shlib.o. some
2449# platforms, such as AIX, have dlopen(), but don't want to use it.
Thomas Wouters3a584202000-08-05 23:28:51 +00002450AC_CHECK_FUNCS(dlopen)
Guido van Rossume97ee181999-12-20 21:27:22 +00002451
2452# DYNLOADFILE specifies which dynload_*.o file we will use for dynamic
2453# loading of modules.
2454AC_SUBST(DYNLOADFILE)
2455AC_MSG_CHECKING(DYNLOADFILE)
2456if test -z "$DYNLOADFILE"
2457then
2458 case $ac_sys_system/$ac_sys_release in
Martin v. Löwisc19c5a62003-11-18 20:00:44 +00002459 AIX*) # Use dynload_shlib.c and dlopen() if we have it; otherwise dynload_aix.c
2460 if test "$ac_cv_func_dlopen" = yes
2461 then DYNLOADFILE="dynload_shlib.o"
2462 else DYNLOADFILE="dynload_aix.o"
2463 fi
2464 ;;
Guido van Rossume97ee181999-12-20 21:27:22 +00002465 hp*|HP*) DYNLOADFILE="dynload_hpux.o";;
Thomas Wouters49fd7fa2006-04-21 10:40:58 +00002466 # Use dynload_next.c only on 10.2 and below, which don't have native dlopen()
2467 Darwin/@<:@0156@:>@\..*) DYNLOADFILE="dynload_next.o";;
Guido van Rossume97ee181999-12-20 21:27:22 +00002468 *)
2469 # use dynload_shlib.c and dlopen() if we have it; otherwise stub
2470 # out any dynamic loading
2471 if test "$ac_cv_func_dlopen" = yes
2472 then DYNLOADFILE="dynload_shlib.o"
2473 else DYNLOADFILE="dynload_stub.o"
2474 fi
2475 ;;
2476 esac
2477fi
2478AC_MSG_RESULT($DYNLOADFILE)
2479if test "$DYNLOADFILE" != "dynload_stub.o"
2480then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002481 AC_DEFINE(HAVE_DYNAMIC_LOADING, 1,
2482 [Defined when any dynamic module loading is enabled.])
Guido van Rossume97ee181999-12-20 21:27:22 +00002483fi
2484
Jack Jansenc49e5b72001-06-19 15:00:23 +00002485# MACHDEP_OBJS can be set to platform-specific object files needed by Python
2486
2487AC_SUBST(MACHDEP_OBJS)
2488AC_MSG_CHECKING(MACHDEP_OBJS)
2489if test -z "$MACHDEP_OBJS"
2490then
Jack Jansenb6e9cad2001-08-15 01:26:28 +00002491 MACHDEP_OBJS=$extra_machdep_objs
2492else
2493 MACHDEP_OBJS="$MACHDEP_OBJS $extra_machdep_objs"
Jack Jansenc49e5b72001-06-19 15:00:23 +00002494fi
Jack Jansenb6e9cad2001-08-15 01:26:28 +00002495AC_MSG_RESULT(MACHDEP_OBJS)
Jack Jansenc49e5b72001-06-19 15:00:23 +00002496
Guido van Rossum627b2d71993-12-24 10:39:16 +00002497# checks for library functions
Martin v. Löwis823725e2008-03-24 13:39:54 +00002498AC_CHECK_FUNCS(alarm setitimer getitimer bind_textdomain_codeset chown \
2499 clock confstr ctermid execv fchmod fchown fork fpathconf ftime ftruncate \
Martin v. Löwis438b5342002-12-27 10:16:42 +00002500 gai_strerror getgroups getlogin getloadavg getpeername getpgid getpid \
Martin v. Löwis7aed61a2009-11-27 14:09:49 +00002501 getpriority getresuid getresgid getpwent getspnam getspent getsid getwd \
Antoine Pitroub7572f02009-12-02 20:46:48 +00002502 initgroups kill killpg lchmod lchown lstat mbrtowc mkfifo mknod mktime \
Martin v. Löwisa5f09072002-10-11 05:37:59 +00002503 mremap nice pathconf pause plock poll pthread_init \
Guido van Rossum162e38c2003-02-19 15:25:10 +00002504 putenv readlink realpath \
Benjamin Peterson965ce872009-04-05 21:24:58 +00002505 select sem_open sem_timedwait sem_getvalue sem_unlink setegid seteuid \
2506 setgid \
Martin v. Löwis7aed61a2009-11-27 14:09:49 +00002507 setlocale setregid setreuid setresuid setresgid setsid setpgid setpgrp setuid setvbuf \
2508 sigaction siginterrupt sigrelse snprintf strftime strlcpy \
Michael W. Hudson34f20ea2002-05-27 15:08:24 +00002509 sysconf tcgetpgrp tcsetpgrp tempnam timegm times tmpfile tmpnam tmpnam_r \
Martin v. Löwis113a0852009-05-29 17:25:39 +00002510 truncate uname unsetenv utimes waitpid wait3 wait4 \
2511 wcscoll wcsftime wcsxfrm _getpty)
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00002512
Martin v. Löwisc8ad7cc2002-11-11 13:23:45 +00002513# For some functions, having a definition is not sufficient, since
2514# we want to take their address.
2515AC_MSG_CHECKING(for chroot)
2516AC_TRY_COMPILE([#include <unistd.h>], void *x=chroot,
2517 AC_DEFINE(HAVE_CHROOT, 1, Define if you have the 'chroot' function.)
2518 AC_MSG_RESULT(yes),
2519 AC_MSG_RESULT(no)
2520)
2521AC_MSG_CHECKING(for link)
2522AC_TRY_COMPILE([#include <unistd.h>], void *x=link,
2523 AC_DEFINE(HAVE_LINK, 1, Define if you have the 'link' function.)
2524 AC_MSG_RESULT(yes),
2525 AC_MSG_RESULT(no)
2526)
2527AC_MSG_CHECKING(for symlink)
2528AC_TRY_COMPILE([#include <unistd.h>], void *x=symlink,
2529 AC_DEFINE(HAVE_SYMLINK, 1, Define if you have the 'symlink' function.)
2530 AC_MSG_RESULT(yes),
2531 AC_MSG_RESULT(no)
2532)
Martin v. Löwisa64988c2003-09-20 15:30:20 +00002533AC_MSG_CHECKING(for fchdir)
2534AC_TRY_COMPILE([#include <unistd.h>], void *x=fchdir,
2535 AC_DEFINE(HAVE_FCHDIR, 1, Define if you have the 'fchdir' function.)
2536 AC_MSG_RESULT(yes),
2537 AC_MSG_RESULT(no)
2538)
2539AC_MSG_CHECKING(for fsync)
2540AC_TRY_COMPILE([#include <unistd.h>], void *x=fsync,
Skip Montanarod4fa8072003-09-25 14:49:15 +00002541 AC_DEFINE(HAVE_FSYNC, 1, Define if you have the 'fsync' function.)
Martin v. Löwisa64988c2003-09-20 15:30:20 +00002542 AC_MSG_RESULT(yes),
2543 AC_MSG_RESULT(no)
2544)
2545AC_MSG_CHECKING(for fdatasync)
2546AC_TRY_COMPILE([#include <unistd.h>], void *x=fdatasync,
2547 AC_DEFINE(HAVE_FDATASYNC, 1, Define if you have the 'fdatasync' function.)
2548 AC_MSG_RESULT(yes),
2549 AC_MSG_RESULT(no)
2550)
Christian Heimes4fbc72b2008-03-22 00:47:35 +00002551AC_MSG_CHECKING(for epoll)
2552AC_TRY_COMPILE([#include <sys/epoll.h>], void *x=epoll_create,
2553 AC_DEFINE(HAVE_EPOLL, 1, Define if you have the 'epoll' functions.)
2554 AC_MSG_RESULT(yes),
2555 AC_MSG_RESULT(no)
2556)
2557AC_MSG_CHECKING(for kqueue)
2558AC_TRY_COMPILE([
2559#include <sys/types.h>
2560#include <sys/event.h>
2561 ], int x=kqueue(),
2562 AC_DEFINE(HAVE_KQUEUE, 1, Define if you have the 'kqueue' functions.)
2563 AC_MSG_RESULT(yes),
2564 AC_MSG_RESULT(no)
2565)
Martin v. Löwisd5843682002-11-21 20:41:28 +00002566# On some systems (eg. FreeBSD 5), we would find a definition of the
2567# functions ctermid_r, setgroups in the library, but no prototype
2568# (e.g. because we use _XOPEN_SOURCE). See whether we can take their
2569# address to avoid compiler warnings and potential miscompilations
2570# because of the missing prototypes.
2571
2572AC_MSG_CHECKING(for ctermid_r)
2573AC_TRY_COMPILE([
2574#include "confdefs.h"
2575#include <stdio.h>
2576], void* p = ctermid_r,
2577 AC_DEFINE(HAVE_CTERMID_R, 1, Define if you have the 'ctermid_r' function.)
2578 AC_MSG_RESULT(yes),
2579 AC_MSG_RESULT(no)
2580)
2581
Martin v. Löwisf26d63b2003-03-30 17:23:49 +00002582AC_MSG_CHECKING(for flock)
2583AC_TRY_COMPILE([
2584#include "confdefs.h"
2585#include <sys/file.h>
2586], void* p = flock,
2587 AC_DEFINE(HAVE_FLOCK, 1, Define if you have the 'flock' function.)
2588 AC_MSG_RESULT(yes),
2589 AC_MSG_RESULT(no)
2590)
2591
2592AC_MSG_CHECKING(for getpagesize)
2593AC_TRY_COMPILE([
2594#include "confdefs.h"
2595#include <unistd.h>
2596], void* p = getpagesize,
2597 AC_DEFINE(HAVE_GETPAGESIZE, 1, Define if you have the 'getpagesize' function.)
2598 AC_MSG_RESULT(yes),
2599 AC_MSG_RESULT(no)
2600)
2601
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002602dnl check for true
2603AC_CHECK_PROGS(TRUE, true, /bin/true)
2604
Martin v. Löwis95c419b2003-05-03 12:10:48 +00002605dnl On some systems (e.g. Solaris 9), hstrerror and inet_aton are in -lresolv
2606dnl On others, they are in the C library, so we to take no action
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002607AC_CHECK_LIB(c, inet_aton, [$ac_cv_prog_TRUE],
Martin v. Löwis95c419b2003-05-03 12:10:48 +00002608 AC_CHECK_LIB(resolv, inet_aton)
2609)
2610
Christian Heimesd0764e22007-12-04 15:00:33 +00002611# On Tru64, chflags seems to be present, but calling it will
2612# exit Python
Benjamin Petersoned68afa2010-01-30 19:36:43 +00002613AC_CACHE_CHECK([for chflags], [ac_cv_have_chflags], [dnl
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00002614AC_TRY_RUN([[
Christian Heimesd0764e22007-12-04 15:00:33 +00002615#include <sys/stat.h>
2616#include <unistd.h>
2617int main(int argc, char*argv[])
2618{
2619 if(chflags(argv[0], 0) != 0)
2620 return 1;
2621 return 0;
2622}
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00002623]], ac_cv_have_chflags=yes,
Benjamin Petersoned68afa2010-01-30 19:36:43 +00002624 ac_cv_have_chflags=no,
2625 ac_cv_have_chflags=cross)
2626])
2627if test "$ac_cv_have_chflags" = cross ; then
2628 AC_CHECK_FUNC([chflags], [ac_cv_have_chflags="yes"], [ac_cv_have_chflags="no"])
2629fi
2630if test "$ac_cv_have_chflags" = yes ; then
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00002631 AC_DEFINE(HAVE_CHFLAGS, 1, Define to 1 if you have the `chflags' function.)
2632fi
Christian Heimesd0764e22007-12-04 15:00:33 +00002633
Benjamin Petersoned68afa2010-01-30 19:36:43 +00002634AC_CACHE_CHECK([for lchflags], [ac_cv_have_lchflags], [dnl
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00002635AC_TRY_RUN([[
Christian Heimesd0764e22007-12-04 15:00:33 +00002636#include <sys/stat.h>
2637#include <unistd.h>
2638int main(int argc, char*argv[])
2639{
2640 if(lchflags(argv[0], 0) != 0)
2641 return 1;
2642 return 0;
2643}
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00002644]], ac_cv_have_lchflags=yes,
Benjamin Petersoned68afa2010-01-30 19:36:43 +00002645 ac_cv_have_lchflags=no,
2646 ac_cv_have_lchflags=cross)
2647])
2648if test "$ac_cv_have_lchflags" = cross ; then
2649 AC_CHECK_FUNC([lchflags], [ac_cv_have_lchflags="yes"], [ac_cv_have_lchflags="no"])
2650fi
2651if test "$ac_cv_have_lchflags" = yes ; then
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00002652 AC_DEFINE(HAVE_LCHFLAGS, 1, Define to 1 if you have the `lchflags' function.)
2653fi
Christian Heimesd0764e22007-12-04 15:00:33 +00002654
Thomas Wouters0e3f5912006-08-11 14:57:12 +00002655dnl Check if system zlib has *Copy() functions
2656dnl
2657dnl On MacOSX the linker will search for dylibs on the entire linker path
2658dnl before searching for static libraries. setup.py adds -Wl,-search_paths_first
2659dnl to revert to a more traditional unix behaviour and make it possible to
2660dnl override the system libz with a local static library of libz. Temporarily
2661dnl add that flag to our CFLAGS as well to ensure that we check the version
2662dnl of libz that will be used by setup.py.
2663dnl The -L/usr/local/lib is needed as wel to get the same compilation
2664dnl environment as setup.py (and leaving it out can cause configure to use the
2665dnl wrong version of the library)
2666case $ac_sys_system/$ac_sys_release in
2667Darwin/*)
2668 _CUR_CFLAGS="${CFLAGS}"
2669 _CUR_LDFLAGS="${LDFLAGS}"
2670 CFLAGS="${CFLAGS} -Wl,-search_paths_first"
2671 LDFLAGS="${LDFLAGS} -Wl,-search_paths_first -L/usr/local/lib"
2672 ;;
2673esac
2674
2675AC_CHECK_LIB(z, inflateCopy, AC_DEFINE(HAVE_ZLIB_COPY, 1, Define if the zlib library has inflateCopy))
2676
2677case $ac_sys_system/$ac_sys_release in
2678Darwin/*)
2679 CFLAGS="${_CUR_CFLAGS}"
2680 LDFLAGS="${_CUR_LDFLAGS}"
2681 ;;
2682esac
2683
Martin v. Löwise9416172003-05-03 10:12:45 +00002684AC_MSG_CHECKING(for hstrerror)
Martin v. Löwis95c419b2003-05-03 12:10:48 +00002685AC_TRY_LINK([
Martin v. Löwise9416172003-05-03 10:12:45 +00002686#include "confdefs.h"
2687#include <netdb.h>
Martin v. Löwis95c419b2003-05-03 12:10:48 +00002688], void* p = hstrerror; hstrerror(0),
Martin v. Löwise9416172003-05-03 10:12:45 +00002689 AC_DEFINE(HAVE_HSTRERROR, 1, Define if you have the 'hstrerror' function.)
2690 AC_MSG_RESULT(yes),
2691 AC_MSG_RESULT(no)
2692)
2693
2694AC_MSG_CHECKING(for inet_aton)
Martin v. Löwis95c419b2003-05-03 12:10:48 +00002695AC_TRY_LINK([
Martin v. Löwise9416172003-05-03 10:12:45 +00002696#include "confdefs.h"
Martin v. Löwis86d66262006-02-17 08:40:11 +00002697#include <sys/types.h>
Martin v. Löwise9416172003-05-03 10:12:45 +00002698#include <sys/socket.h>
2699#include <netinet/in.h>
2700#include <arpa/inet.h>
Martin v. Löwis95c419b2003-05-03 12:10:48 +00002701], void* p = inet_aton;inet_aton(0,0),
Martin v. Löwise9416172003-05-03 10:12:45 +00002702 AC_DEFINE(HAVE_INET_ATON, 1, Define if you have the 'inet_aton' function.)
2703 AC_MSG_RESULT(yes),
2704 AC_MSG_RESULT(no)
2705)
2706
2707AC_MSG_CHECKING(for inet_pton)
2708AC_TRY_COMPILE([
2709#include "confdefs.h"
Martin v. Löwisf2e488d2003-05-05 22:00:11 +00002710#include <sys/types.h>
Martin v. Löwise9416172003-05-03 10:12:45 +00002711#include <sys/socket.h>
2712#include <netinet/in.h>
2713#include <arpa/inet.h>
2714], void* p = inet_pton,
2715 AC_DEFINE(HAVE_INET_PTON, 1, Define if you have the 'inet_pton' function.)
2716 AC_MSG_RESULT(yes),
2717 AC_MSG_RESULT(no)
2718)
2719
Martin v. Löwisd6640d42003-07-06 09:29:52 +00002720# On some systems, setgroups is in unistd.h, on others, in grp.h
Martin v. Löwisd5843682002-11-21 20:41:28 +00002721AC_MSG_CHECKING(for setgroups)
2722AC_TRY_COMPILE([
2723#include "confdefs.h"
Martin v. Löwisf2e488d2003-05-05 22:00:11 +00002724#include <unistd.h>
Martin v. Löwisd6640d42003-07-06 09:29:52 +00002725#ifdef HAVE_GRP_H
2726#include <grp.h>
2727#endif
Martin v. Löwisd5843682002-11-21 20:41:28 +00002728],
2729void* p = setgroups,
2730 AC_DEFINE(HAVE_SETGROUPS, 1, Define if you have the 'setgroups' function.)
2731 AC_MSG_RESULT(yes),
2732 AC_MSG_RESULT(no)
2733)
2734
Fred Drake8cef4cf2000-06-28 16:40:38 +00002735# check for openpty and forkpty
2736
Martin v. Löwisfd9a72a2006-01-08 10:07:33 +00002737AC_CHECK_FUNCS(openpty,,
2738 AC_CHECK_LIB(util,openpty,
2739 [AC_DEFINE(HAVE_OPENPTY) LIBS="$LIBS -lutil"],
2740 AC_CHECK_LIB(bsd,openpty, [AC_DEFINE(HAVE_OPENPTY) LIBS="$LIBS -lbsd"])
2741 )
2742)
2743AC_CHECK_FUNCS(forkpty,,
2744 AC_CHECK_LIB(util,forkpty,
2745 [AC_DEFINE(HAVE_FORKPTY) LIBS="$LIBS -lutil"],
2746 AC_CHECK_LIB(bsd,forkpty, [AC_DEFINE(HAVE_FORKPTY) LIBS="$LIBS -lbsd"])
2747 )
2748)
Fred Drake8cef4cf2000-06-28 16:40:38 +00002749
Christian Heimesb186d002008-03-18 15:15:01 +00002750# Stuff for expat.
2751AC_CHECK_FUNCS(memmove)
2752
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00002753# check for long file support functions
2754AC_CHECK_FUNCS(fseek64 fseeko fstatvfs ftell64 ftello statvfs)
2755
Christian Heimesb186d002008-03-18 15:15:01 +00002756AC_REPLACE_FUNCS(dup2 getcwd strdup)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002757AC_CHECK_FUNCS(getpgrp,
2758 AC_TRY_COMPILE([#include <unistd.h>],
2759 [getpgrp(0);],
2760 AC_DEFINE(GETPGRP_HAVE_ARG, 1,
2761 [Define if getpgrp() must be called as getpgrp(0).])
2762 )
2763)
Jack Jansen150753c2003-03-29 22:07:47 +00002764AC_CHECK_FUNCS(setpgrp,
2765 AC_TRY_COMPILE([#include <unistd.h>],
2766 [setpgrp(0,0);],
2767 AC_DEFINE(SETPGRP_HAVE_ARG, 1,
2768 [Define if setpgrp() must be called as setpgrp(0, 0).])
2769 )
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002770)
2771AC_CHECK_FUNCS(gettimeofday,
2772 AC_TRY_COMPILE([#include <sys/time.h>],
2773 [gettimeofday((struct timeval*)0,(struct timezone*)0);], ,
2774 AC_DEFINE(GETTIMEOFDAY_NO_TZ, 1,
2775 [Define if gettimeofday() does not have second (timezone) argument
2776 This is the case on Motorola V4 (R40V4.2)])
2777 )
2778)
Guido van Rossum627b2d71993-12-24 10:39:16 +00002779
Martin v. Löwisdbe3f762002-10-10 14:27:30 +00002780AC_MSG_CHECKING(for major, minor, and makedev)
Martin v. Löwise3271202002-11-07 07:42:30 +00002781AC_TRY_LINK([
Neal Norwitz6eb37f02003-02-23 23:28:15 +00002782#if defined(MAJOR_IN_MKDEV)
2783#include <sys/mkdev.h>
2784#elif defined(MAJOR_IN_SYSMACROS)
2785#include <sys/sysmacros.h>
2786#else
2787#include <sys/types.h>
2788#endif
Martin v. Löwisdbe3f762002-10-10 14:27:30 +00002789],[
2790 makedev(major(0),minor(0));
2791],[
2792 AC_DEFINE(HAVE_DEVICE_MACROS, 1,
2793 [Define to 1 if you have the device macros.])
2794 AC_MSG_RESULT(yes)
2795],[
2796 AC_MSG_RESULT(no)
2797])
Martin v. Löwis861a65b2001-10-24 14:36:00 +00002798
2799# On OSF/1 V5.1, getaddrinfo is available, but a define
2800# for [no]getaddrinfo in netdb.h.
2801AC_MSG_CHECKING(for getaddrinfo)
2802AC_TRY_LINK([
Martin v. Löwisc010b6d2001-11-09 17:50:52 +00002803#include <sys/types.h>
Martin v. Löwis861a65b2001-10-24 14:36:00 +00002804#include <sys/socket.h>
2805#include <netdb.h>
Martin v. Löwisc010b6d2001-11-09 17:50:52 +00002806#include <stdio.h>
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00002807], [getaddrinfo(NULL, NULL, NULL, NULL);],
2808have_getaddrinfo=yes,
2809have_getaddrinfo=no)
2810AC_MSG_RESULT($have_getaddrinfo)
2811if test $have_getaddrinfo = yes
2812then
2813 AC_MSG_CHECKING(getaddrinfo bug)
2814 AC_CACHE_VAL(ac_cv_buggy_getaddrinfo,
2815 AC_TRY_RUN([[
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00002816#include <sys/types.h>
2817#include <netdb.h>
2818#include <string.h>
2819#include <sys/socket.h>
2820#include <netinet/in.h>
2821
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00002822int main()
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00002823{
2824 int passive, gaierr, inet4 = 0, inet6 = 0;
2825 struct addrinfo hints, *ai, *aitop;
2826 char straddr[INET6_ADDRSTRLEN], strport[16];
2827
2828 for (passive = 0; passive <= 1; passive++) {
2829 memset(&hints, 0, sizeof(hints));
2830 hints.ai_family = AF_UNSPEC;
2831 hints.ai_flags = passive ? AI_PASSIVE : 0;
2832 hints.ai_socktype = SOCK_STREAM;
Hye-Shik Chang54f94392004-04-14 07:55:31 +00002833 hints.ai_protocol = IPPROTO_TCP;
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00002834 if ((gaierr = getaddrinfo(NULL, "54321", &hints, &aitop)) != 0) {
2835 (void)gai_strerror(gaierr);
2836 goto bad;
2837 }
2838 for (ai = aitop; ai; ai = ai->ai_next) {
2839 if (ai->ai_addr == NULL ||
2840 ai->ai_addrlen == 0 ||
2841 getnameinfo(ai->ai_addr, ai->ai_addrlen,
2842 straddr, sizeof(straddr), strport, sizeof(strport),
2843 NI_NUMERICHOST|NI_NUMERICSERV) != 0) {
2844 goto bad;
2845 }
2846 switch (ai->ai_family) {
2847 case AF_INET:
2848 if (strcmp(strport, "54321") != 0) {
2849 goto bad;
2850 }
2851 if (passive) {
2852 if (strcmp(straddr, "0.0.0.0") != 0) {
2853 goto bad;
2854 }
2855 } else {
2856 if (strcmp(straddr, "127.0.0.1") != 0) {
2857 goto bad;
2858 }
2859 }
2860 inet4++;
2861 break;
2862 case AF_INET6:
2863 if (strcmp(strport, "54321") != 0) {
2864 goto bad;
2865 }
2866 if (passive) {
2867 if (strcmp(straddr, "::") != 0) {
2868 goto bad;
2869 }
2870 } else {
2871 if (strcmp(straddr, "::1") != 0) {
2872 goto bad;
2873 }
2874 }
2875 inet6++;
2876 break;
2877 case AF_UNSPEC:
2878 goto bad;
2879 break;
2880 default:
2881 /* another family support? */
2882 break;
2883 }
2884 }
2885 }
2886
2887 if (!(inet4 == 0 || inet4 == 2))
2888 goto bad;
2889 if (!(inet6 == 0 || inet6 == 2))
2890 goto bad;
2891
2892 if (aitop)
2893 freeaddrinfo(aitop);
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00002894 return 0;
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00002895
2896 bad:
2897 if (aitop)
2898 freeaddrinfo(aitop);
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00002899 return 1;
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00002900}
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00002901]], ac_cv_buggy_getaddrinfo=no,
2902 ac_cv_buggy_getaddrinfo=yes,
2903 ac_cv_buggy_getaddrinfo=yes))
2904fi
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00002905
Mark Dickinson2df5d282009-12-31 21:22:50 +00002906if test $have_getaddrinfo = no -o "$ac_cv_buggy_getaddrinfo" = yes
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00002907then
2908 if test $ipv6 = yes
2909 then
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00002910 echo 'Fatal: You must get working getaddrinfo() function.'
2911 echo ' or you can specify "--disable-ipv6"'.
2912 exit 1
2913 fi
Martin v. Löwis861a65b2001-10-24 14:36:00 +00002914else
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002915 AC_DEFINE(HAVE_GETADDRINFO, 1, [Define if you have the getaddrinfo function.])
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00002916fi
Thomas Woutersb0db85a2001-08-08 10:39:03 +00002917AC_CHECK_FUNCS(getnameinfo)
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00002918
Guido van Rossum627b2d71993-12-24 10:39:16 +00002919# checks for structures
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002920AC_HEADER_TIME
Guido van Rossum627b2d71993-12-24 10:39:16 +00002921AC_STRUCT_TM
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002922AC_STRUCT_TIMEZONE
Martin v. Löwis60a5d722002-10-16 20:28:25 +00002923AC_CHECK_MEMBERS([struct stat.st_rdev])
2924AC_CHECK_MEMBERS([struct stat.st_blksize])
Hye-Shik Chang5f937a72005-06-02 13:09:30 +00002925AC_CHECK_MEMBERS([struct stat.st_flags])
Martin v. Löwisebd9d5b2005-08-09 15:00:59 +00002926AC_CHECK_MEMBERS([struct stat.st_gen])
2927AC_CHECK_MEMBERS([struct stat.st_birthtime])
Guido van Rossum98bf58f2001-10-18 20:34:25 +00002928AC_STRUCT_ST_BLOCKS
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002929
2930AC_MSG_CHECKING(for time.h that defines altzone)
2931AC_CACHE_VAL(ac_cv_header_time_altzone,
2932[AC_TRY_COMPILE([#include <time.h>], [return altzone;],
2933 ac_cv_header_time_altzone=yes,
2934 ac_cv_header_time_altzone=no)])
2935AC_MSG_RESULT($ac_cv_header_time_altzone)
2936if test $ac_cv_header_time_altzone = yes; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002937 AC_DEFINE(HAVE_ALTZONE, 1, [Define this if your time.h defines altzone.])
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002938fi
2939
Guido van Rossum5739e7e1995-01-20 16:50:53 +00002940was_it_defined=no
2941AC_MSG_CHECKING(whether sys/select.h and sys/time.h may both be included)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002942AC_TRY_COMPILE([
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002943#include <sys/types.h>
2944#include <sys/select.h>
2945#include <sys/time.h>
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002946], [;], [
2947 AC_DEFINE(SYS_SELECT_WITH_SYS_TIME, 1,
2948 [Define if you can safely include both <sys/select.h> and <sys/time.h>
2949 (which you can't on SCO ODT 3.0).])
2950 was_it_defined=yes
2951])
Guido van Rossum5739e7e1995-01-20 16:50:53 +00002952AC_MSG_RESULT($was_it_defined)
Guido van Rossum627b2d71993-12-24 10:39:16 +00002953
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00002954AC_MSG_CHECKING(for addrinfo)
2955AC_CACHE_VAL(ac_cv_struct_addrinfo,
2956AC_TRY_COMPILE([
2957# include <netdb.h>],
2958 [struct addrinfo a],
2959 ac_cv_struct_addrinfo=yes,
2960 ac_cv_struct_addrinfo=no))
2961AC_MSG_RESULT($ac_cv_struct_addrinfo)
2962if test $ac_cv_struct_addrinfo = yes; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002963 AC_DEFINE(HAVE_ADDRINFO, 1, [struct addrinfo (netdb.h)])
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00002964fi
2965
2966AC_MSG_CHECKING(for sockaddr_storage)
2967AC_CACHE_VAL(ac_cv_struct_sockaddr_storage,
2968AC_TRY_COMPILE([
2969# include <sys/types.h>
2970# include <sys/socket.h>],
2971 [struct sockaddr_storage s],
2972 ac_cv_struct_sockaddr_storage=yes,
2973 ac_cv_struct_sockaddr_storage=no))
2974AC_MSG_RESULT($ac_cv_struct_sockaddr_storage)
2975if test $ac_cv_struct_sockaddr_storage = yes; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002976 AC_DEFINE(HAVE_SOCKADDR_STORAGE, 1, [struct sockaddr_storage (sys/socket.h)])
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00002977fi
2978
Guido van Rossum627b2d71993-12-24 10:39:16 +00002979# checks for compiler characteristics
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002980
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002981AC_C_CHAR_UNSIGNED
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002982AC_C_CONST
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002983
Guido van Rossum5739e7e1995-01-20 16:50:53 +00002984works=no
2985AC_MSG_CHECKING(for working volatile)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002986AC_TRY_COMPILE([],[volatile int x; x = 0;], works=yes,
2987 AC_DEFINE(volatile, [], [Define to empty if the keyword does not work.])
2988)
Guido van Rossum5739e7e1995-01-20 16:50:53 +00002989AC_MSG_RESULT($works)
Guido van Rossumdabb11b1994-10-11 15:04:27 +00002990
Guido van Rossum5739e7e1995-01-20 16:50:53 +00002991works=no
2992AC_MSG_CHECKING(for working signed char)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002993AC_TRY_COMPILE([], [signed char c;], works=yes,
2994 AC_DEFINE(signed, [], [Define to empty if the keyword does not work.])
2995)
Guido van Rossum5739e7e1995-01-20 16:50:53 +00002996AC_MSG_RESULT($works)
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002997
Guido van Rossum5739e7e1995-01-20 16:50:53 +00002998have_prototypes=no
2999AC_MSG_CHECKING(for prototypes)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003000AC_TRY_COMPILE([int foo(int x) { return 0; }], [return foo(10);],[
3001 AC_DEFINE(HAVE_PROTOTYPES, 1,
3002 [Define if your compiler supports function prototype])
3003 have_prototypes=yes
3004])
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003005AC_MSG_RESULT($have_prototypes)
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003006
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003007works=no
3008AC_MSG_CHECKING(for variable length prototypes and stdarg.h)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003009AC_TRY_COMPILE([
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003010#include <stdarg.h>
Guido van Rossum3f13e481996-08-30 20:58:11 +00003011int foo(int x, ...) {
3012 va_list va;
3013 va_start(va, x);
3014 va_arg(va, int);
3015 va_arg(va, char *);
3016 va_arg(va, double);
3017 return 0;
3018}
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003019], [return foo(10, "", 3.14);], [
3020 AC_DEFINE(HAVE_STDARG_PROTOTYPES, 1,
3021 [Define if your compiler supports variable length function prototypes
3022 (e.g. void fprintf(FILE *, char *, ...);) *and* <stdarg.h>])
3023 works=yes
3024])
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003025AC_MSG_RESULT($works)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003026
Dave Cole331708b2004-08-09 04:51:41 +00003027# check for socketpair
3028AC_MSG_CHECKING(for socketpair)
3029AC_TRY_COMPILE([
3030#include <sys/types.h>
3031#include <sys/socket.h>
3032], void *x=socketpair,
3033 AC_DEFINE(HAVE_SOCKETPAIR, 1, Define if you have the 'socketpair' function.)
3034 AC_MSG_RESULT(yes),
3035 AC_MSG_RESULT(no)
3036)
3037
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003038# check if sockaddr has sa_len member
3039AC_MSG_CHECKING(if sockaddr has sa_len member)
3040AC_TRY_COMPILE([#include <sys/types.h>
3041#include <sys/socket.h>],
3042[struct sockaddr x;
3043x.sa_len = 0;],
3044 AC_MSG_RESULT(yes)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003045 AC_DEFINE(HAVE_SOCKADDR_SA_LEN, 1, [Define if sockaddr has sa_len member]),
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003046 AC_MSG_RESULT(no))
3047
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003048va_list_is_array=no
3049AC_MSG_CHECKING(whether va_list is an array)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003050AC_TRY_COMPILE([
3051#ifdef HAVE_STDARG_PROTOTYPES
3052#include <stdarg.h>
3053#else
3054#include <varargs.h>
3055#endif
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003056], [va_list list1, list2; list1 = list2;], , [
3057 AC_DEFINE(VA_LIST_IS_ARRAY, 1, [Define if a va_list is an array of some kind])
3058 va_list_is_array=yes
3059])
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003060AC_MSG_RESULT($va_list_is_array)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003061
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003062# sigh -- gethostbyname_r is a mess; it can have 3, 5 or 6 arguments :-(
Martin v. Löwis11437992002-04-12 09:54:03 +00003063AH_TEMPLATE(HAVE_GETHOSTBYNAME_R,
3064 [Define this if you have some version of gethostbyname_r()])
3065
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003066AC_CHECK_FUNC(gethostbyname_r, [
3067 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
3068 AC_MSG_CHECKING([gethostbyname_r with 6 args])
3069 OLD_CFLAGS=$CFLAGS
3070 CFLAGS="$CFLAGS $MY_CPPFLAGS $MY_THREAD_CPPFLAGS $MY_CFLAGS"
3071 AC_TRY_COMPILE([
3072# include <netdb.h>
3073 ], [
3074 char *name;
3075 struct hostent *he, *res;
3076 char buffer[2048];
3077 int buflen = 2048;
3078 int h_errnop;
3079
3080 (void) gethostbyname_r(name, he, buffer, buflen, &res, &h_errnop)
3081 ], [
Guido van Rossum8db7d8b1999-03-23 16:40:33 +00003082 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003083 AC_DEFINE(HAVE_GETHOSTBYNAME_R_6_ARG, 1,
3084 [Define this if you have the 6-arg version of gethostbyname_r().])
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003085 AC_MSG_RESULT(yes)
3086 ], [
3087 AC_MSG_RESULT(no)
3088 AC_MSG_CHECKING([gethostbyname_r with 5 args])
3089 AC_TRY_COMPILE([
3090# include <netdb.h>
3091 ], [
3092 char *name;
3093 struct hostent *he;
3094 char buffer[2048];
3095 int buflen = 2048;
3096 int h_errnop;
3097
3098 (void) gethostbyname_r(name, he, buffer, buflen, &h_errnop)
3099 ], [
Guido van Rossum8db7d8b1999-03-23 16:40:33 +00003100 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003101 AC_DEFINE(HAVE_GETHOSTBYNAME_R_5_ARG, 1,
3102 [Define this if you have the 5-arg version of gethostbyname_r().])
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003103 AC_MSG_RESULT(yes)
3104 ], [
3105 AC_MSG_RESULT(no)
3106 AC_MSG_CHECKING([gethostbyname_r with 3 args])
3107 AC_TRY_COMPILE([
3108# include <netdb.h>
3109 ], [
3110 char *name;
3111 struct hostent *he;
3112 struct hostent_data data;
3113
3114 (void) gethostbyname_r(name, he, &data);
3115 ], [
Guido van Rossum8db7d8b1999-03-23 16:40:33 +00003116 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003117 AC_DEFINE(HAVE_GETHOSTBYNAME_R_3_ARG, 1,
3118 [Define this if you have the 3-arg version of gethostbyname_r().])
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003119 AC_MSG_RESULT(yes)
3120 ], [
3121 AC_MSG_RESULT(no)
3122 ])
3123 ])
3124 ])
3125 CFLAGS=$OLD_CFLAGS
3126], [
Thomas Wouters3a584202000-08-05 23:28:51 +00003127 AC_CHECK_FUNCS(gethostbyname)
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003128])
3129AC_SUBST(HAVE_GETHOSTBYNAME_R_6_ARG)
3130AC_SUBST(HAVE_GETHOSTBYNAME_R_5_ARG)
3131AC_SUBST(HAVE_GETHOSTBYNAME_R_3_ARG)
Guido van Rossum8db7d8b1999-03-23 16:40:33 +00003132AC_SUBST(HAVE_GETHOSTBYNAME_R)
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003133AC_SUBST(HAVE_GETHOSTBYNAME)
3134
Guido van Rossum627b2d71993-12-24 10:39:16 +00003135# checks for system services
3136# (none yet)
3137
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003138# Linux requires this for correct f.p. operations
Jeremy Hyltonbe28f5b2000-07-27 21:03:04 +00003139AC_CHECK_FUNC(__fpu_control,
3140 [],
3141 [AC_CHECK_LIB(ieee, __fpu_control)
3142])
Guido van Rossum627b2d71993-12-24 10:39:16 +00003143
Guido van Rossum93274221997-05-09 02:42:00 +00003144# Check for --with-fpectl
Guido van Rossum93274221997-05-09 02:42:00 +00003145AC_MSG_CHECKING(for --with-fpectl)
Barry Warsawc0d24d82000-06-29 16:12:00 +00003146AC_ARG_WITH(fpectl,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003147 AC_HELP_STRING(--with-fpectl, enable SIGFPE catching),
3148[
Guido van Rossum93274221997-05-09 02:42:00 +00003149if test "$withval" != no
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003150then
3151 AC_DEFINE(WANT_SIGFPE_HANDLER, 1,
3152 [Define if you want SIGFPE handled (see Include/pyfpe.h).])
3153 AC_MSG_RESULT(yes)
Guido van Rossum93274221997-05-09 02:42:00 +00003154else AC_MSG_RESULT(no)
Guido van Rossumef2255b2000-03-10 22:30:29 +00003155fi],
3156[AC_MSG_RESULT(no)])
Guido van Rossum93274221997-05-09 02:42:00 +00003157
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003158# check for --with-libm=...
3159AC_SUBST(LIBM)
Guido van Rossum4b6b5791996-09-09 20:09:34 +00003160case $ac_sys_system in
Guido van Rossum3dc0a512000-10-05 18:00:06 +00003161Darwin) ;;
Guido van Rossum4b6b5791996-09-09 20:09:34 +00003162*) LIBM=-lm
3163esac
Guido van Rossum93274221997-05-09 02:42:00 +00003164AC_MSG_CHECKING(for --with-libm=STRING)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003165AC_ARG_WITH(libm,
3166 AC_HELP_STRING(--with-libm=STRING, math library),
3167[
Guido van Rossum93274221997-05-09 02:42:00 +00003168if test "$withval" = no
3169then LIBM=
3170 AC_MSG_RESULT(force LIBM empty)
3171elif test "$withval" != yes
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003172then LIBM=$withval
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003173 AC_MSG_RESULT(set LIBM="$withval")
3174else AC_MSG_ERROR([proper usage is --with-libm=STRING])
Guido van Rossum93274221997-05-09 02:42:00 +00003175fi],
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003176[AC_MSG_RESULT(default LIBM="$LIBM")])
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003177
3178# check for --with-libc=...
3179AC_SUBST(LIBC)
Guido van Rossum93274221997-05-09 02:42:00 +00003180AC_MSG_CHECKING(for --with-libc=STRING)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003181AC_ARG_WITH(libc,
3182 AC_HELP_STRING(--with-libc=STRING, C library),
3183[
Guido van Rossum93274221997-05-09 02:42:00 +00003184if test "$withval" = no
3185then LIBC=
3186 AC_MSG_RESULT(force LIBC empty)
3187elif test "$withval" != yes
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003188then LIBC=$withval
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003189 AC_MSG_RESULT(set LIBC="$withval")
3190else AC_MSG_ERROR([proper usage is --with-libc=STRING])
Guido van Rossum93274221997-05-09 02:42:00 +00003191fi],
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003192[AC_MSG_RESULT(default LIBC="$LIBC")])
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003193
Mark Dickinsonb08a53a2009-04-16 19:52:09 +00003194# **************************************************
3195# * Check for various properties of floating point *
3196# **************************************************
Christian Heimes81ee3ef2008-05-04 22:42:01 +00003197
Mark Dickinsonb08a53a2009-04-16 19:52:09 +00003198AC_MSG_CHECKING(whether C doubles are little-endian IEEE 754 binary64)
3199AC_CACHE_VAL(ac_cv_little_endian_double, [
3200AC_TRY_RUN([
3201#include <string.h>
3202int main() {
3203 double x = 9006104071832581.0;
3204 if (memcmp(&x, "\x05\x04\x03\x02\x01\xff\x3f\x43", 8) == 0)
3205 return 0;
3206 else
3207 return 1;
3208}
3209],
3210ac_cv_little_endian_double=yes,
3211ac_cv_little_endian_double=no,
3212ac_cv_little_endian_double=no)])
3213AC_MSG_RESULT($ac_cv_little_endian_double)
3214if test "$ac_cv_little_endian_double" = yes
3215then
3216 AC_DEFINE(DOUBLE_IS_LITTLE_ENDIAN_IEEE754, 1,
3217 [Define if C doubles are 64-bit IEEE 754 binary format, stored
3218 with the least significant byte first])
3219fi
3220
3221AC_MSG_CHECKING(whether C doubles are big-endian IEEE 754 binary64)
3222AC_CACHE_VAL(ac_cv_big_endian_double, [
3223AC_TRY_RUN([
3224#include <string.h>
3225int main() {
3226 double x = 9006104071832581.0;
3227 if (memcmp(&x, "\x43\x3f\xff\x01\x02\x03\x04\x05", 8) == 0)
3228 return 0;
3229 else
3230 return 1;
3231}
3232],
3233ac_cv_big_endian_double=yes,
3234ac_cv_big_endian_double=no,
3235ac_cv_big_endian_double=no)])
3236AC_MSG_RESULT($ac_cv_big_endian_double)
3237if test "$ac_cv_big_endian_double" = yes
3238then
3239 AC_DEFINE(DOUBLE_IS_BIG_ENDIAN_IEEE754, 1,
3240 [Define if C doubles are 64-bit IEEE 754 binary format, stored
3241 with the most significant byte first])
3242fi
3243
3244# Some ARM platforms use a mixed-endian representation for doubles.
3245# While Python doesn't currently have full support for these platforms
3246# (see e.g., issue 1762561), we can at least make sure that float <-> string
3247# conversions work.
3248AC_MSG_CHECKING(whether C doubles are ARM mixed-endian IEEE 754 binary64)
3249AC_CACHE_VAL(ac_cv_mixed_endian_double, [
3250AC_TRY_RUN([
3251#include <string.h>
3252int main() {
3253 double x = 9006104071832581.0;
3254 if (memcmp(&x, "\x01\xff\x3f\x43\x05\x04\x03\x02", 8) == 0)
3255 return 0;
3256 else
3257 return 1;
3258}
3259],
3260ac_cv_mixed_endian_double=yes,
3261ac_cv_mixed_endian_double=no,
3262ac_cv_mixed_endian_double=no)])
3263AC_MSG_RESULT($ac_cv_mixed_endian_double)
3264if test "$ac_cv_mixed_endian_double" = yes
3265then
3266 AC_DEFINE(DOUBLE_IS_ARM_MIXED_ENDIAN_IEEE754, 1,
3267 [Define if C doubles are 64-bit IEEE 754 binary format, stored
3268 in ARM mixed-endian order (byte order 45670123)])
3269fi
3270
Mark Dickinson7abf8d42009-04-18 20:17:52 +00003271# The short float repr introduced in Python 3.1 requires the
3272# correctly-rounded string <-> double conversion functions from
3273# Python/dtoa.c, which in turn require that the FPU uses 53-bit
3274# rounding; this is a problem on x86, where the x87 FPU has a default
Mark Dickinsonf4243f62009-11-15 13:47:27 +00003275# rounding precision of 64 bits. For gcc/x86, we can fix this by
Mark Dickinson7abf8d42009-04-18 20:17:52 +00003276# using inline assembler to get and set the x87 FPU control word.
Mark Dickinsonf4243f62009-11-15 13:47:27 +00003277
3278# This inline assembler syntax may also work for suncc and icc,
3279# so we try it on all platforms.
3280
3281AC_MSG_CHECKING(whether we can use gcc inline assembler to get and set x87 control word)
3282AC_TRY_COMPILE([], [
3283 unsigned short cw;
3284 __asm__ __volatile__ ("fnstcw %0" : "=m" (cw));
3285 __asm__ __volatile__ ("fldcw %0" : : "m" (cw));
3286],
3287[have_gcc_asm_for_x87=yes], [have_gcc_asm_for_x87=no])
3288AC_MSG_RESULT($have_gcc_asm_for_x87)
3289if test "$have_gcc_asm_for_x87" = yes
Mark Dickinsonb08a53a2009-04-16 19:52:09 +00003290then
Mark Dickinsonf4243f62009-11-15 13:47:27 +00003291 AC_DEFINE(HAVE_GCC_ASM_FOR_X87, 1,
3292 [Define if we can use gcc inline assembler to get and set x87 control word])
Mark Dickinsonb08a53a2009-04-16 19:52:09 +00003293fi
Christian Heimes81ee3ef2008-05-04 22:42:01 +00003294
Mark Dickinson3dc7c6a2009-01-04 15:09:02 +00003295# Detect whether system arithmetic is subject to x87-style double
3296# rounding issues. The result of this test has little meaning on non
3297# IEEE 754 platforms. On IEEE 754, test should return 1 if rounding
3298# mode is round-to-nearest and double rounding issues are present, and
3299# 0 otherwise. See http://bugs.python.org/issue2937 for more info.
3300AC_MSG_CHECKING(for x87-style double rounding)
Mark Dickinsonb08a53a2009-04-16 19:52:09 +00003301# $BASECFLAGS may affect the result
3302ac_save_cc="$CC"
3303CC="$CC $BASECFLAGS"
Mark Dickinson3dc7c6a2009-01-04 15:09:02 +00003304AC_TRY_RUN([
3305#include <stdlib.h>
3306#include <math.h>
3307int main() {
3308 volatile double x, y, z;
3309 /* 1./(1-2**-53) -> 1+2**-52 (correct), 1.0 (double rounding) */
3310 x = 0.99999999999999989; /* 1-2**-53 */
3311 y = 1./x;
3312 if (y != 1.)
3313 exit(0);
3314 /* 1e16+2.99999 -> 1e16+2. (correct), 1e16+4. (double rounding) */
3315 x = 1e16;
3316 y = 2.99999;
3317 z = x + y;
3318 if (z != 1e16+4.)
3319 exit(0);
3320 /* both tests show evidence of double rounding */
3321 exit(1);
3322}
3323],
3324ac_cv_x87_double_rounding=no,
3325ac_cv_x87_double_rounding=yes,
Mark Dickinsonb08a53a2009-04-16 19:52:09 +00003326ac_cv_x87_double_rounding=no)
3327CC="$ac_save_cc"
Mark Dickinson3dc7c6a2009-01-04 15:09:02 +00003328AC_MSG_RESULT($ac_cv_x87_double_rounding)
3329if test "$ac_cv_x87_double_rounding" = yes
3330then
3331 AC_DEFINE(X87_DOUBLE_ROUNDING, 1,
3332 [Define if arithmetic is subject to x87-style double rounding issue])
3333fi
3334
Mark Dickinsonb08a53a2009-04-16 19:52:09 +00003335# ************************************
3336# * Check for mathematical functions *
3337# ************************************
3338
3339LIBS_SAVE=$LIBS
3340LIBS="$LIBS $LIBM"
3341
Christian Heimes81ee3ef2008-05-04 22:42:01 +00003342# On FreeBSD 6.2, it appears that tanh(-0.) returns 0. instead of
3343# -0. on some architectures.
3344AC_MSG_CHECKING(whether tanh preserves the sign of zero)
3345AC_CACHE_VAL(ac_cv_tanh_preserves_zero_sign, [
3346AC_TRY_RUN([
3347#include <math.h>
3348#include <stdlib.h>
3349int main() {
3350 /* return 0 if either negative zeros don't exist
3351 on this platform or if negative zeros exist
3352 and tanh(-0.) == -0. */
3353 if (atan2(0., -1.) == atan2(-0., -1.) ||
3354 atan2(tanh(-0.), -1.) == atan2(-0., -1.)) exit(0);
3355 else exit(1);
3356}
3357],
3358ac_cv_tanh_preserves_zero_sign=yes,
3359ac_cv_tanh_preserves_zero_sign=no,
3360ac_cv_tanh_preserves_zero_sign=no)])
3361AC_MSG_RESULT($ac_cv_tanh_preserves_zero_sign)
3362if test "$ac_cv_tanh_preserves_zero_sign" = yes
3363then
3364 AC_DEFINE(TANH_PRESERVES_ZERO_SIGN, 1,
3365 [Define if tanh(-0.) is -0., or if platform doesn't have signed zeros])
3366fi
3367
Mark Dickinson9c113362009-09-05 10:36:23 +00003368AC_CHECK_FUNCS([acosh asinh atanh copysign erf erfc expm1 finite gamma])
3369AC_CHECK_FUNCS([hypot lgamma log1p round tgamma])
Mark Dickinson3dc7c6a2009-01-04 15:09:02 +00003370AC_CHECK_DECLS([isinf, isnan, isfinite], [], [], [[#include <math.h>]])
Christian Heimes99170a52007-12-19 02:07:34 +00003371
Guido van Rossumaf5b83e1995-01-04 19:02:35 +00003372LIBS=$LIBS_SAVE
3373
Mark Dickinsona614f042009-11-28 12:48:43 +00003374# For multiprocessing module, check that sem_open
3375# actually works. For FreeBSD versions <= 7.2,
3376# the kernel module that provides POSIX semaphores
3377# isn't loaded by default, so an attempt to call
3378# sem_open results in a 'Signal 12' error.
3379AC_MSG_CHECKING(whether POSIX semaphores are enabled)
3380AC_CACHE_VAL(ac_cv_posix_semaphores_enabled,
3381AC_TRY_RUN([
3382#include <unistd.h>
3383#include <fcntl.h>
3384#include <stdio.h>
3385#include <semaphore.h>
3386#include <sys/stat.h>
3387
3388int main(void) {
3389 sem_t *a = sem_open("/autoconf", O_CREAT, S_IRUSR|S_IWUSR, 0);
3390 if (a == SEM_FAILED) {
3391 perror("sem_open");
3392 return 1;
3393 }
3394 sem_close(a);
Mark Dickinsonba79b352009-12-13 21:10:57 +00003395 sem_unlink("/autoconf");
Mark Dickinsona614f042009-11-28 12:48:43 +00003396 return 0;
3397}
3398], ac_cv_posix_semaphores_enabled=yes,
3399 ac_cv_posix_semaphores_enabled=no,
3400 ac_cv_posix_semaphores_enabled=yes)
3401)
3402AC_MSG_RESULT($ac_cv_posix_semaphores_enabled)
3403if test $ac_cv_posix_semaphores_enabled = no
3404then
3405 AC_DEFINE(POSIX_SEMAPHORES_NOT_ENABLED, 1,
3406 [Define if POSIX semaphores aren't enabled on your system])
3407fi
3408
Mark Dickinson10683072009-04-18 21:18:19 +00003409# Multiprocessing check for broken sem_getvalue
3410AC_MSG_CHECKING(for broken sem_getvalue)
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00003411AC_CACHE_VAL(ac_cv_broken_sem_getvalue,
Mark Dickinson10683072009-04-18 21:18:19 +00003412AC_TRY_RUN([
3413#include <unistd.h>
3414#include <fcntl.h>
3415#include <stdio.h>
3416#include <semaphore.h>
3417#include <sys/stat.h>
3418
3419int main(void){
Mark Dickinsonba79b352009-12-13 21:10:57 +00003420 sem_t *a = sem_open("/autocftw", O_CREAT, S_IRUSR|S_IWUSR, 0);
Mark Dickinson10683072009-04-18 21:18:19 +00003421 int count;
3422 int res;
3423 if(a==SEM_FAILED){
3424 perror("sem_open");
3425 return 1;
3426
3427 }
3428 res = sem_getvalue(a, &count);
3429 sem_close(a);
Mark Dickinsonba79b352009-12-13 21:10:57 +00003430 sem_unlink("/autocftw");
Mark Dickinson10683072009-04-18 21:18:19 +00003431 return res==-1 ? 1 : 0;
3432}
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00003433], ac_cv_broken_sem_getvalue=no,
3434 ac_cv_broken_sem_getvalue=yes,
3435 ac_cv_broken_sem_getvalue=yes)
Mark Dickinson10683072009-04-18 21:18:19 +00003436)
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00003437AC_MSG_RESULT($ac_cv_broken_sem_getvalue)
3438if test $ac_cv_broken_sem_getvalue = yes
3439then
3440 AC_DEFINE(HAVE_BROKEN_SEM_GETVALUE, 1,
3441 [define to 1 if your sem_getvalue is broken.])
3442fi
Mark Dickinson10683072009-04-18 21:18:19 +00003443
Mark Dickinsonbd792642009-03-18 20:06:12 +00003444# determine what size digit to use for Python's longs
3445AC_MSG_CHECKING([digit size for Python's longs])
3446AC_ARG_ENABLE(big-digits,
3447AC_HELP_STRING([--enable-big-digits@<:@=BITS@:>@],[use big digits for Python longs [[BITS=30]]]),
3448[case $enable_big_digits in
3449yes)
3450 enable_big_digits=30 ;;
3451no)
3452 enable_big_digits=15 ;;
3453[15|30])
3454 ;;
3455*)
3456 AC_MSG_ERROR([bad value $enable_big_digits for --enable-big-digits; value should be 15 or 30]) ;;
3457esac
3458AC_MSG_RESULT($enable_big_digits)
3459AC_DEFINE_UNQUOTED(PYLONG_BITS_IN_DIGIT, $enable_big_digits, [Define as the preferred size in bits of long digits])
3460],
3461[AC_MSG_RESULT(no value specified)])
3462
Guido van Rossumef2255b2000-03-10 22:30:29 +00003463# check for wchar.h
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003464AC_CHECK_HEADER(wchar.h, [
3465 AC_DEFINE(HAVE_WCHAR_H, 1,
3466 [Define if the compiler provides a wchar.h header file.])
3467 wchar_h="yes"
3468],
Guido van Rossumef2255b2000-03-10 22:30:29 +00003469wchar_h="no"
3470)
3471
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003472# determine wchar_t size
3473if test "$wchar_h" = yes
3474then
Guido van Rossum67b26592001-10-20 14:21:45 +00003475 AC_CHECK_SIZEOF(wchar_t, 4, [#include <wchar.h>])
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003476fi
3477
Martin v. Löwisfa3bdea2003-09-04 18:50:54 +00003478AC_MSG_CHECKING(for UCS-4 tcl)
3479have_ucs4_tcl=no
3480AC_TRY_COMPILE([
3481#include <tcl.h>
3482#if TCL_UTF_MAX != 6
3483# error "NOT UCS4_TCL"
3484#endif], [], [
3485 AC_DEFINE(HAVE_UCS4_TCL, 1, [Define this if you have tcl and TCL_UTF_MAX==6])
3486 have_ucs4_tcl=yes
3487])
3488AC_MSG_RESULT($have_ucs4_tcl)
3489
Marc-André Lemburgd7160f82003-09-22 11:14:40 +00003490# check whether wchar_t is signed or not
3491if test "$wchar_h" = yes
3492then
3493 # check whether wchar_t is signed or not
3494 AC_MSG_CHECKING(whether wchar_t is signed)
3495 AC_CACHE_VAL(ac_cv_wchar_t_signed, [
3496 AC_TRY_RUN([
3497 #include <wchar.h>
3498 int main()
3499 {
Thomas Wouters49fd7fa2006-04-21 10:40:58 +00003500 /* Success: exit code 0 */
3501 exit((((wchar_t) -1) < ((wchar_t) 0)) ? 0 : 1);
Marc-André Lemburgd7160f82003-09-22 11:14:40 +00003502 }
3503 ],
3504 ac_cv_wchar_t_signed=yes,
3505 ac_cv_wchar_t_signed=no,
3506 ac_cv_wchar_t_signed=yes)])
3507 AC_MSG_RESULT($ac_cv_wchar_t_signed)
3508fi
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003509
Georg Brandl52d168a2008-01-07 18:10:24 +00003510AC_MSG_CHECKING(what type to use for str)
3511AC_ARG_WITH(wide-unicode,
3512 AC_HELP_STRING(--with-wide-unicode, Use 4-byte Unicode characters (default is 2 bytes)),
3513[
3514if test "$withval" != no
3515then unicode_size="4"
3516else unicode_size="2"
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003517fi
Georg Brandl52d168a2008-01-07 18:10:24 +00003518],
3519[
3520case "$have_ucs4_tcl" in
3521 yes) unicode_size="4" ;;
3522 *) unicode_size="2" ;;
3523esac
3524])
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003525
Martin v. Löwis0036cba2002-04-12 09:58:45 +00003526AH_TEMPLATE(Py_UNICODE_SIZE,
3527 [Define as the size of the unicode type.])
Georg Brandl52d168a2008-01-07 18:10:24 +00003528case "$unicode_size" in
3529 4) AC_DEFINE(Py_UNICODE_SIZE, 4) ;;
3530 *) AC_DEFINE(Py_UNICODE_SIZE, 2) ;;
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003531esac
3532
Martin v. Löwis11437992002-04-12 09:54:03 +00003533AH_TEMPLATE(PY_UNICODE_TYPE,
3534 [Define as the integral type used for Unicode representation.])
Martin v. Löwis0036cba2002-04-12 09:58:45 +00003535
Georg Brandl52d168a2008-01-07 18:10:24 +00003536# wchar_t is only usable if it maps to an unsigned type
3537if test "$unicode_size" = "$ac_cv_sizeof_wchar_t" \
Matthias Klose7dbeed72004-12-24 08:22:17 +00003538 -a "$ac_cv_wchar_t_signed" = "no"
Georg Brandl52d168a2008-01-07 18:10:24 +00003539then
3540 PY_UNICODE_TYPE="wchar_t"
3541 AC_DEFINE(HAVE_USABLE_WCHAR_T, 1,
3542 [Define if you have a useable wchar_t type defined in wchar.h; useable
3543 means wchar_t must be an unsigned type with at least 16 bits. (see
3544 Include/unicodeobject.h).])
3545 AC_DEFINE(PY_UNICODE_TYPE,wchar_t)
3546elif test "$ac_cv_sizeof_short" = "$unicode_size"
3547then
3548 PY_UNICODE_TYPE="unsigned short"
3549 AC_DEFINE(PY_UNICODE_TYPE,unsigned short)
3550elif test "$ac_cv_sizeof_long" = "$unicode_size"
3551then
3552 PY_UNICODE_TYPE="unsigned long"
3553 AC_DEFINE(PY_UNICODE_TYPE,unsigned long)
3554else
3555 PY_UNICODE_TYPE="no type found"
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003556fi
Georg Brandl52d168a2008-01-07 18:10:24 +00003557AC_MSG_RESULT($PY_UNICODE_TYPE)
Guido van Rossumef2255b2000-03-10 22:30:29 +00003558
3559# check for endianness
3560AC_C_BIGENDIAN
3561
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00003562# Check whether right shifting a negative integer extends the sign bit
3563# or fills with zeros (like the Cray J90, according to Tim Peters).
3564AC_MSG_CHECKING(whether right shift extends the sign bit)
Vladimir Marangozova6180282000-07-12 05:05:06 +00003565AC_CACHE_VAL(ac_cv_rshift_extends_sign, [
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00003566AC_TRY_RUN([
3567int main()
3568{
Vladimir Marangozova6180282000-07-12 05:05:06 +00003569 exit(((-1)>>3 == -1) ? 0 : 1);
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00003570}
Guido van Rossum3065c942001-09-17 04:03:14 +00003571],
3572ac_cv_rshift_extends_sign=yes,
3573ac_cv_rshift_extends_sign=no,
3574ac_cv_rshift_extends_sign=yes)])
Vladimir Marangozova6180282000-07-12 05:05:06 +00003575AC_MSG_RESULT($ac_cv_rshift_extends_sign)
3576if test "$ac_cv_rshift_extends_sign" = no
3577then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003578 AC_DEFINE(SIGNED_RIGHT_SHIFT_ZERO_FILLS, 1,
3579 [Define if i>>j for signed int i does not extend the sign bit
3580 when i < 0])
Vladimir Marangozova6180282000-07-12 05:05:06 +00003581fi
3582
Guido van Rossumcadfaec2001-01-05 14:45:49 +00003583# check for getc_unlocked and related locking functions
3584AC_MSG_CHECKING(for getc_unlocked() and friends)
3585AC_CACHE_VAL(ac_cv_have_getc_unlocked, [
3586AC_TRY_LINK([#include <stdio.h>],[
3587 FILE *f = fopen("/dev/null", "r");
3588 flockfile(f);
3589 getc_unlocked(f);
3590 funlockfile(f);
3591], ac_cv_have_getc_unlocked=yes, ac_cv_have_getc_unlocked=no)])
3592AC_MSG_RESULT($ac_cv_have_getc_unlocked)
3593if test "$ac_cv_have_getc_unlocked" = yes
3594then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003595 AC_DEFINE(HAVE_GETC_UNLOCKED, 1,
3596 [Define this if you have flockfile(), getc_unlocked(), and funlockfile()])
Guido van Rossumcadfaec2001-01-05 14:45:49 +00003597fi
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00003598
Neal Norwitzfe8e3d92006-01-07 21:07:20 +00003599# check where readline lives
Martin v. Löwis82bca632006-02-10 20:49:30 +00003600# save the value of LIBS so we don't actually link Python with readline
3601LIBS_no_readline=$LIBS
Gregory P. Smith18820942008-09-07 06:24:49 +00003602
3603# On some systems we need to link readline to a termcap compatible
3604# library. NOTE: Keep the precedence of listed libraries synchronised
3605# with setup.py.
3606py_cv_lib_readline=no
3607AC_MSG_CHECKING([how to link readline libs])
3608for py_libtermcap in "" ncursesw ncurses curses termcap; do
3609 if test -z "$py_libtermcap"; then
3610 READLINE_LIBS="-lreadline"
3611 else
3612 READLINE_LIBS="-lreadline -l$py_libtermcap"
3613 fi
3614 LIBS="$READLINE_LIBS $LIBS_no_readline"
3615 AC_LINK_IFELSE(
3616 [AC_LANG_CALL([],[readline])],
3617 [py_cv_lib_readline=yes])
3618 if test $py_cv_lib_readline = yes; then
3619 break
3620 fi
3621done
3622# Uncomment this line if you want to use READINE_LIBS in Makefile or scripts
3623#AC_SUBST([READLINE_LIBS])
Gregory P. Smith97515912008-09-07 19:23:19 +00003624if test $py_cv_lib_readline = no; then
Gregory P. Smith18820942008-09-07 06:24:49 +00003625 AC_MSG_RESULT([none])
3626else
3627 AC_MSG_RESULT([$READLINE_LIBS])
3628 AC_DEFINE(HAVE_LIBREADLINE, 1,
3629 [Define if you have the readline library (-lreadline).])
Neal Norwitzfe8e3d92006-01-07 21:07:20 +00003630fi
3631
Michael W. Hudson30ea2f22004-07-07 17:44:12 +00003632# check for readline 2.1
3633AC_CHECK_LIB(readline, rl_callback_handler_install,
3634 AC_DEFINE(HAVE_RL_CALLBACK, 1,
Gregory P. Smith18820942008-09-07 06:24:49 +00003635 [Define if you have readline 2.1]), ,$READLINE_LIBS)
Michael W. Hudson30ea2f22004-07-07 17:44:12 +00003636
Guido van Rossumfaf5e4d2002-12-30 16:25:41 +00003637# check for readline 2.2
3638AC_TRY_CPP([#include <readline/readline.h>],
3639have_readline=yes, have_readline=no)
3640if test $have_readline = yes
3641then
3642 AC_EGREP_HEADER([extern int rl_completion_append_character;],
3643 [readline/readline.h],
3644 AC_DEFINE(HAVE_RL_COMPLETION_APPEND_CHARACTER, 1,
3645 [Define if you have readline 2.2]), )
Antoine Pitroud5131772009-10-26 19:22:14 +00003646 AC_EGREP_HEADER([extern int rl_completion_suppress_append;],
3647 [readline/readline.h],
3648 AC_DEFINE(HAVE_RL_COMPLETION_SUPPRESS_APPEND, 1,
3649 [Define if you have rl_completion_suppress_append]), )
Guido van Rossumfaf5e4d2002-12-30 16:25:41 +00003650fi
3651
Martin v. Löwis0daad592001-09-30 21:09:59 +00003652# check for readline 4.0
3653AC_CHECK_LIB(readline, rl_pre_input_hook,
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003654 AC_DEFINE(HAVE_RL_PRE_INPUT_HOOK, 1,
Gregory P. Smith18820942008-09-07 06:24:49 +00003655 [Define if you have readline 4.0]), ,$READLINE_LIBS)
Martin v. Löwis0daad592001-09-30 21:09:59 +00003656
Thomas Wouters89d996e2007-09-08 17:39:28 +00003657# also in 4.0
3658AC_CHECK_LIB(readline, rl_completion_display_matches_hook,
3659 AC_DEFINE(HAVE_RL_COMPLETION_DISPLAY_MATCHES_HOOK, 1,
Gregory P. Smith18820942008-09-07 06:24:49 +00003660 [Define if you have readline 4.0]), ,$READLINE_LIBS)
Thomas Wouters89d996e2007-09-08 17:39:28 +00003661
Guido van Rossum353ae582001-07-10 16:45:32 +00003662# check for readline 4.2
3663AC_CHECK_LIB(readline, rl_completion_matches,
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003664 AC_DEFINE(HAVE_RL_COMPLETION_MATCHES, 1,
Gregory P. Smith18820942008-09-07 06:24:49 +00003665 [Define if you have readline 4.2]), ,$READLINE_LIBS)
Guido van Rossum353ae582001-07-10 16:45:32 +00003666
Michael W. Hudson30ea2f22004-07-07 17:44:12 +00003667# also in readline 4.2
3668AC_TRY_CPP([#include <readline/readline.h>],
3669have_readline=yes, have_readline=no)
3670if test $have_readline = yes
3671then
3672 AC_EGREP_HEADER([extern int rl_catch_signals;],
3673 [readline/readline.h],
3674 AC_DEFINE(HAVE_RL_CATCH_SIGNAL, 1,
3675 [Define if you can turn off readline's signal handling.]), )
3676fi
3677
Martin v. Löwis82bca632006-02-10 20:49:30 +00003678# End of readline checks: restore LIBS
3679LIBS=$LIBS_no_readline
3680
Thomas Wouterse38b2f12001-07-11 22:35:31 +00003681AC_MSG_CHECKING(for broken nice())
3682AC_CACHE_VAL(ac_cv_broken_nice, [
3683AC_TRY_RUN([
3684int main()
3685{
3686 int val1 = nice(1);
3687 if (val1 != -1 && val1 == nice(2))
3688 exit(0);
3689 exit(1);
3690}
Guido van Rossum3065c942001-09-17 04:03:14 +00003691],
3692ac_cv_broken_nice=yes,
3693ac_cv_broken_nice=no,
3694ac_cv_broken_nice=no)])
Thomas Wouterse38b2f12001-07-11 22:35:31 +00003695AC_MSG_RESULT($ac_cv_broken_nice)
3696if test "$ac_cv_broken_nice" = yes
3697then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003698 AC_DEFINE(HAVE_BROKEN_NICE, 1,
3699 [Define if nice() returns success/failure instead of the new priority.])
Thomas Wouterse38b2f12001-07-11 22:35:31 +00003700fi
3701
Nicholas Bastine62c5c82004-03-21 23:45:42 +00003702AC_MSG_CHECKING(for broken poll())
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00003703AC_CACHE_VAL(ac_cv_broken_poll,
Nicholas Bastine62c5c82004-03-21 23:45:42 +00003704AC_TRY_RUN([
3705#include <poll.h>
3706
Alexandre Vassalottiaee170a2009-07-17 06:24:33 +00003707int main()
3708{
Nicholas Bastine62c5c82004-03-21 23:45:42 +00003709 struct pollfd poll_struct = { 42, POLLIN|POLLPRI|POLLOUT, 0 };
Alexandre Vassalottiaee170a2009-07-17 06:24:33 +00003710 int poll_test;
3711
Nicholas Bastine62c5c82004-03-21 23:45:42 +00003712 close (42);
3713
Alexandre Vassalottiaee170a2009-07-17 06:24:33 +00003714 poll_test = poll(&poll_struct, 1, 0);
Nicholas Bastine62c5c82004-03-21 23:45:42 +00003715 if (poll_test < 0)
Alexandre Vassalottiaee170a2009-07-17 06:24:33 +00003716 return 0;
Nicholas Bastine62c5c82004-03-21 23:45:42 +00003717 else if (poll_test == 0 && poll_struct.revents != POLLNVAL)
Alexandre Vassalottiaee170a2009-07-17 06:24:33 +00003718 return 0;
Nicholas Bastine62c5c82004-03-21 23:45:42 +00003719 else
Alexandre Vassalottiaee170a2009-07-17 06:24:33 +00003720 return 1;
3721}
Nicholas Bastine62c5c82004-03-21 23:45:42 +00003722],
3723ac_cv_broken_poll=yes,
3724ac_cv_broken_poll=no,
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00003725ac_cv_broken_poll=no))
Nicholas Bastine62c5c82004-03-21 23:45:42 +00003726AC_MSG_RESULT($ac_cv_broken_poll)
3727if test "$ac_cv_broken_poll" = yes
3728then
3729 AC_DEFINE(HAVE_BROKEN_POLL, 1,
3730 [Define if poll() sets errno on invalid file descriptors.])
3731fi
3732
Brett Cannon43802422005-02-10 20:48:03 +00003733# Before we can test tzset, we need to check if struct tm has a tm_zone
3734# (which is not required by ISO C or UNIX spec) and/or if we support
3735# tzname[]
3736AC_STRUCT_TIMEZONE
Nicholas Bastine62c5c82004-03-21 23:45:42 +00003737
Brett Cannon43802422005-02-10 20:48:03 +00003738# check tzset(3) exists and works like we expect it to
Guido van Rossumd11b62e2003-03-14 21:51:36 +00003739AC_MSG_CHECKING(for working tzset())
3740AC_CACHE_VAL(ac_cv_working_tzset, [
3741AC_TRY_RUN([
3742#include <stdlib.h>
3743#include <time.h>
Brett Cannon18367812003-09-19 00:59:16 +00003744#include <string.h>
Brett Cannon43802422005-02-10 20:48:03 +00003745
3746#if HAVE_TZNAME
3747extern char *tzname[];
3748#endif
3749
Guido van Rossumd11b62e2003-03-14 21:51:36 +00003750int main()
3751{
Brett Cannon18367812003-09-19 00:59:16 +00003752 /* Note that we need to ensure that not only does tzset(3)
3753 do 'something' with localtime, but it works as documented
3754 in the library reference and as expected by the test suite.
Brett Cannon43802422005-02-10 20:48:03 +00003755 This includes making sure that tzname is set properly if
3756 tm->tm_zone does not exist since it is the alternative way
3757 of getting timezone info.
Brett Cannon18367812003-09-19 00:59:16 +00003758
3759 Red Hat 6.2 doesn't understand the southern hemisphere
Brett Cannon43802422005-02-10 20:48:03 +00003760 after New Year's Day.
Brett Cannon18367812003-09-19 00:59:16 +00003761 */
3762
Brett Cannon43802422005-02-10 20:48:03 +00003763 time_t groundhogday = 1044144000; /* GMT-based */
Brett Cannon18367812003-09-19 00:59:16 +00003764 time_t midyear = groundhogday + (365 * 24 * 3600 / 2);
3765
Neal Norwitz7f2588c2003-04-11 15:35:53 +00003766 putenv("TZ=UTC+0");
Guido van Rossumd11b62e2003-03-14 21:51:36 +00003767 tzset();
Brett Cannon18367812003-09-19 00:59:16 +00003768 if (localtime(&groundhogday)->tm_hour != 0)
3769 exit(1);
Brett Cannon43802422005-02-10 20:48:03 +00003770#if HAVE_TZNAME
3771 /* For UTC, tzname[1] is sometimes "", sometimes " " */
3772 if (strcmp(tzname[0], "UTC") ||
3773 (tzname[1][0] != 0 && tzname[1][0] != ' '))
3774 exit(1);
3775#endif
Brett Cannon18367812003-09-19 00:59:16 +00003776
Neal Norwitz7f2588c2003-04-11 15:35:53 +00003777 putenv("TZ=EST+5EDT,M4.1.0,M10.5.0");
Guido van Rossumd11b62e2003-03-14 21:51:36 +00003778 tzset();
Brett Cannon18367812003-09-19 00:59:16 +00003779 if (localtime(&groundhogday)->tm_hour != 19)
Guido van Rossumd11b62e2003-03-14 21:51:36 +00003780 exit(1);
Brett Cannon43802422005-02-10 20:48:03 +00003781#if HAVE_TZNAME
3782 if (strcmp(tzname[0], "EST") || strcmp(tzname[1], "EDT"))
3783 exit(1);
3784#endif
Brett Cannon18367812003-09-19 00:59:16 +00003785
3786 putenv("TZ=AEST-10AEDT-11,M10.5.0,M3.5.0");
3787 tzset();
3788 if (localtime(&groundhogday)->tm_hour != 11)
3789 exit(1);
Brett Cannon43802422005-02-10 20:48:03 +00003790#if HAVE_TZNAME
3791 if (strcmp(tzname[0], "AEST") || strcmp(tzname[1], "AEDT"))
3792 exit(1);
3793#endif
3794
3795#if HAVE_STRUCT_TM_TM_ZONE
Brett Cannon18367812003-09-19 00:59:16 +00003796 if (strcmp(localtime(&groundhogday)->tm_zone, "AEDT"))
3797 exit(1);
3798 if (strcmp(localtime(&midyear)->tm_zone, "AEST"))
3799 exit(1);
Brett Cannon43802422005-02-10 20:48:03 +00003800#endif
Brett Cannon18367812003-09-19 00:59:16 +00003801
Guido van Rossumd11b62e2003-03-14 21:51:36 +00003802 exit(0);
3803}
3804],
3805ac_cv_working_tzset=yes,
3806ac_cv_working_tzset=no,
3807ac_cv_working_tzset=no)])
3808AC_MSG_RESULT($ac_cv_working_tzset)
3809if test "$ac_cv_working_tzset" = yes
3810then
3811 AC_DEFINE(HAVE_WORKING_TZSET, 1,
3812 [Define if tzset() actually switches the local timezone in a meaningful way.])
3813fi
3814
Martin v. Löwis94717ed2002-09-09 14:24:16 +00003815# Look for subsecond timestamps in struct stat
3816AC_MSG_CHECKING(for tv_nsec in struct stat)
3817AC_CACHE_VAL(ac_cv_stat_tv_nsec,
3818AC_TRY_COMPILE([#include <sys/stat.h>], [
3819struct stat st;
3820st.st_mtim.tv_nsec = 1;
3821],
Martin v. Löwisa32c9942002-09-09 16:17:47 +00003822ac_cv_stat_tv_nsec=yes,
Martin v. Löwis94717ed2002-09-09 14:24:16 +00003823ac_cv_stat_tv_nsec=no,
3824ac_cv_stat_tv_nsec=no))
3825AC_MSG_RESULT($ac_cv_stat_tv_nsec)
3826if test "$ac_cv_stat_tv_nsec" = yes
3827then
3828 AC_DEFINE(HAVE_STAT_TV_NSEC, 1,
3829 [Define if you have struct stat.st_mtim.tv_nsec])
3830fi
3831
Martin v. Löwisebd9d5b2005-08-09 15:00:59 +00003832# Look for BSD style subsecond timestamps in struct stat
3833AC_MSG_CHECKING(for tv_nsec2 in struct stat)
3834AC_CACHE_VAL(ac_cv_stat_tv_nsec2,
3835AC_TRY_COMPILE([#include <sys/stat.h>], [
3836struct stat st;
3837st.st_mtimespec.tv_nsec = 1;
3838],
3839ac_cv_stat_tv_nsec2=yes,
3840ac_cv_stat_tv_nsec2=no,
3841ac_cv_stat_tv_nsec2=no))
3842AC_MSG_RESULT($ac_cv_stat_tv_nsec2)
3843if test "$ac_cv_stat_tv_nsec2" = yes
3844then
3845 AC_DEFINE(HAVE_STAT_TV_NSEC2, 1,
3846 [Define if you have struct stat.st_mtimensec])
3847fi
3848
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00003849# On HP/UX 11.0, mvwdelch is a block with a return statement
3850AC_MSG_CHECKING(whether mvwdelch is an expression)
3851AC_CACHE_VAL(ac_cv_mvwdelch_is_expression,
3852AC_TRY_COMPILE([#include <curses.h>], [
3853 int rtn;
3854 rtn = mvwdelch(0,0,0);
3855], ac_cv_mvwdelch_is_expression=yes,
3856 ac_cv_mvwdelch_is_expression=no,
3857 ac_cv_mvwdelch_is_expression=yes))
3858AC_MSG_RESULT($ac_cv_mvwdelch_is_expression)
3859
3860if test "$ac_cv_mvwdelch_is_expression" = yes
3861then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003862 AC_DEFINE(MVWDELCH_IS_EXPRESSION, 1,
3863 [Define if mvwdelch in curses.h is an expression.])
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00003864fi
3865
3866AC_MSG_CHECKING(whether WINDOW has _flags)
3867AC_CACHE_VAL(ac_cv_window_has_flags,
3868AC_TRY_COMPILE([#include <curses.h>], [
3869 WINDOW *w;
3870 w->_flags = 0;
3871], ac_cv_window_has_flags=yes,
3872 ac_cv_window_has_flags=no,
3873 ac_cv_window_has_flags=no))
3874AC_MSG_RESULT($ac_cv_window_has_flags)
3875
3876
3877if test "$ac_cv_window_has_flags" = yes
3878then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003879 AC_DEFINE(WINDOW_HAS_FLAGS, 1,
3880 [Define if WINDOW in curses.h offers a field _flags.])
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00003881fi
3882
Thomas Wouters0e3f5912006-08-11 14:57:12 +00003883AC_MSG_CHECKING(for is_term_resized)
3884AC_TRY_COMPILE([#include <curses.h>], void *x=is_term_resized,
3885 AC_DEFINE(HAVE_CURSES_IS_TERM_RESIZED, 1, Define if you have the 'is_term_resized' function.)
3886 AC_MSG_RESULT(yes),
Martin v. Löwis24a880b2002-12-31 12:55:15 +00003887 AC_MSG_RESULT(no)
Thomas Wouters0e3f5912006-08-11 14:57:12 +00003888)
Martin v. Löwis24a880b2002-12-31 12:55:15 +00003889
Thomas Wouters0e3f5912006-08-11 14:57:12 +00003890AC_MSG_CHECKING(for resize_term)
3891AC_TRY_COMPILE([#include <curses.h>], void *x=resize_term,
3892 AC_DEFINE(HAVE_CURSES_RESIZE_TERM, 1, Define if you have the 'resize_term' function.)
3893 AC_MSG_RESULT(yes),
Neal Norwitz865400f2003-03-21 01:42:58 +00003894 AC_MSG_RESULT(no)
Thomas Wouters0e3f5912006-08-11 14:57:12 +00003895)
3896
3897AC_MSG_CHECKING(for resizeterm)
3898AC_TRY_COMPILE([#include <curses.h>], void *x=resizeterm,
3899 AC_DEFINE(HAVE_CURSES_RESIZETERM, 1, Define if you have the 'resizeterm' function.)
3900 AC_MSG_RESULT(yes),
3901 AC_MSG_RESULT(no)
3902)
3903
Thomas Wouters89f507f2006-12-13 04:49:30 +00003904AC_MSG_CHECKING(for /dev/ptmx)
3905
3906if test -r /dev/ptmx
3907then
3908 AC_MSG_RESULT(yes)
3909 AC_DEFINE(HAVE_DEV_PTMX, 1,
3910 [Define if we have /dev/ptmx.])
3911else
3912 AC_MSG_RESULT(no)
3913fi
3914
3915AC_MSG_CHECKING(for /dev/ptc)
3916
3917if test -r /dev/ptc
3918then
3919 AC_MSG_RESULT(yes)
3920 AC_DEFINE(HAVE_DEV_PTC, 1,
3921 [Define if we have /dev/ptc.])
3922else
3923 AC_MSG_RESULT(no)
3924fi
Neal Norwitz865400f2003-03-21 01:42:58 +00003925
Mark Dickinson6ce4a9a2009-11-16 17:00:11 +00003926if test "$have_long_long" = yes
3927then
3928 AC_MSG_CHECKING(for %lld and %llu printf() format support)
3929 AC_CACHE_VAL(ac_cv_have_long_long_format,
3930 AC_TRY_RUN([[
3931 #include <stdio.h>
3932 #include <stddef.h>
3933 #include <string.h>
3934
3935 #ifdef HAVE_SYS_TYPES_H
3936 #include <sys/types.h>
3937 #endif
3938
3939 int main()
3940 {
3941 char buffer[256];
3942
3943 if (sprintf(buffer, "%lld", (long long)123) < 0)
3944 return 1;
3945 if (strcmp(buffer, "123"))
3946 return 1;
3947
3948 if (sprintf(buffer, "%lld", (long long)-123) < 0)
3949 return 1;
3950 if (strcmp(buffer, "-123"))
3951 return 1;
3952
3953 if (sprintf(buffer, "%llu", (unsigned long long)123) < 0)
3954 return 1;
3955 if (strcmp(buffer, "123"))
3956 return 1;
3957
3958 return 0;
3959 }
3960 ]], ac_cv_have_long_long_format=yes,
3961 ac_cv_have_long_long_format=no,
3962 ac_cv_have_long_long_format=no)
3963 )
3964 AC_MSG_RESULT($ac_cv_have_long_long_format)
3965fi
3966
Mark Dickinson89d7d412009-12-31 20:50:59 +00003967if test "$ac_cv_have_long_long_format" = yes
Mark Dickinson6ce4a9a2009-11-16 17:00:11 +00003968then
3969 AC_DEFINE(PY_FORMAT_LONG_LONG, "ll",
3970 [Define to printf format modifier for long long type])
3971fi
3972
Ronald Oussoren3c1928a2009-11-19 17:15:31 +00003973if test $ac_sys_system = Darwin
3974then
3975 LIBS="$LIBS -framework CoreFoundation"
3976fi
Mark Dickinson6ce4a9a2009-11-16 17:00:11 +00003977
Benjamin Peterson8f326b22009-12-13 02:10:36 +00003978AC_CACHE_CHECK([for %zd printf() format support], ac_cv_have_size_t_format, [dnl
3979AC_TRY_RUN([
Alexandre Vassalottie5091f62009-07-17 06:41:02 +00003980#include <stdio.h>
Thomas Wouters477c8d52006-05-27 19:21:47 +00003981#include <stddef.h>
3982#include <string.h>
3983
Christian Heimes2c181612007-12-17 20:04:13 +00003984#ifdef HAVE_SYS_TYPES_H
3985#include <sys/types.h>
3986#endif
Thomas Wouters89f507f2006-12-13 04:49:30 +00003987
3988#ifdef HAVE_SSIZE_T
3989typedef ssize_t Py_ssize_t;
3990#elif SIZEOF_VOID_P == SIZEOF_LONG
3991typedef long Py_ssize_t;
3992#else
3993typedef int Py_ssize_t;
3994#endif
Thomas Wouters477c8d52006-05-27 19:21:47 +00003995
Christian Heimes2c181612007-12-17 20:04:13 +00003996int main()
3997{
3998 char buffer[256];
3999
Thomas Wouters477c8d52006-05-27 19:21:47 +00004000 if(sprintf(buffer, "%zd", (size_t)123) < 0)
4001 return 1;
4002
Thomas Wouters89f507f2006-12-13 04:49:30 +00004003 if (strcmp(buffer, "123"))
Thomas Wouters477c8d52006-05-27 19:21:47 +00004004 return 1;
Thomas Wouters89f507f2006-12-13 04:49:30 +00004005
4006 if (sprintf(buffer, "%zd", (Py_ssize_t)-123) < 0)
4007 return 1;
4008
4009 if (strcmp(buffer, "-123"))
4010 return 1;
4011
Thomas Wouters477c8d52006-05-27 19:21:47 +00004012 return 0;
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00004013}
Benjamin Peterson8f326b22009-12-13 02:10:36 +00004014], ac_cv_have_size_t_format=yes,
Alexandre Vassalottie5091f62009-07-17 06:41:02 +00004015 ac_cv_have_size_t_format=no,
Benjamin Peterson8f326b22009-12-13 02:10:36 +00004016 [ac_cv_have_size_t_format="cross -- assuming yes"]
4017)])
4018if test "$ac_cv_have_size_t_format" != no ; then
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00004019 AC_DEFINE(PY_FORMAT_SIZE_T, "z",
4020 [Define to printf format modifier for Py_ssize_t])
4021fi
Thomas Wouters477c8d52006-05-27 19:21:47 +00004022
Martin v. Löwis01c04012002-11-11 14:58:44 +00004023AC_CHECK_TYPE(socklen_t,,
4024 AC_DEFINE(socklen_t,int,
4025 Define to `int' if <sys/socket.h> does not define.),[
4026#ifdef HAVE_SYS_TYPES_H
4027#include <sys/types.h>
4028#endif
Guido van Rossum95713eb2000-05-18 20:53:31 +00004029#ifdef HAVE_SYS_SOCKET_H
4030#include <sys/socket.h>
4031#endif
Martin v. Löwis01c04012002-11-11 14:58:44 +00004032])
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00004033
Antoine Pitroufff95302008-09-03 18:58:51 +00004034AC_MSG_CHECKING(for broken mbstowcs)
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00004035AC_CACHE_VAL(ac_cv_broken_mbstowcs,
Antoine Pitroufff95302008-09-03 18:58:51 +00004036AC_TRY_RUN([
4037#include<stdlib.h>
4038int main() {
4039 size_t len = -1;
4040 const char *str = "text";
4041 len = mbstowcs(NULL, str, 0);
4042 return (len != 4);
4043}
4044],
4045ac_cv_broken_mbstowcs=no,
4046ac_cv_broken_mbstowcs=yes,
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00004047ac_cv_broken_mbstowcs=no))
Antoine Pitroufff95302008-09-03 18:58:51 +00004048AC_MSG_RESULT($ac_cv_broken_mbstowcs)
4049if test "$ac_cv_broken_mbstowcs" = yes
4050then
4051 AC_DEFINE(HAVE_BROKEN_MBSTOWCS, 1,
4052 [Define if mbstowcs(NULL, "text", 0) does not return the number of
4053 wide chars that would be converted.])
4054fi
4055
Antoine Pitroub52ec782009-01-25 16:34:23 +00004056# Check for --with-computed-gotos
4057AC_MSG_CHECKING(for --with-computed-gotos)
4058AC_ARG_WITH(computed-gotos,
4059 AC_HELP_STRING(--with-computed-gotos,
4060 Use computed gotos / threaded dispatch in evaluation loop (not available on all compilers)),
4061[
4062if test "$withval" != no
4063then
4064 AC_DEFINE(USE_COMPUTED_GOTOS, 1,
4065 [Define if you want to use computed gotos in ceval.c.])
4066 AC_MSG_RESULT(yes)
4067else AC_MSG_RESULT(no)
4068fi],
4069[AC_MSG_RESULT(no)])
4070
4071
Martin v. Löwis06f15bb2001-12-02 13:02:32 +00004072AC_SUBST(THREADHEADERS)
4073
4074for h in `(cd $srcdir;echo Python/thread_*.h)`
4075do
4076 THREADHEADERS="$THREADHEADERS \$(srcdir)/$h"
4077done
4078
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00004079AC_SUBST(SRCDIRS)
Neal Norwitzd24499d2005-12-18 21:36:39 +00004080SRCDIRS="Parser Grammar Objects Python Modules Mac"
Andrew M. Kuchling8abedde2001-01-26 22:55:24 +00004081AC_MSG_CHECKING(for build directories)
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00004082for dir in $SRCDIRS; do
4083 if test ! -d $dir; then
4084 mkdir $dir
Fred Drake884d3ba2000-11-02 17:52:56 +00004085 fi
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00004086done
4087AC_MSG_RESULT(done)
Fred Drake036144d2000-10-26 17:09:35 +00004088
Guido van Rossum627b2d71993-12-24 10:39:16 +00004089# generate output files
Antoine Pitrou20327222009-05-24 20:39:11 +00004090AC_CONFIG_FILES(Makefile.pre Modules/Setup.config Misc/python.pc)
Martin v. Löwis88afe662002-10-26 13:47:44 +00004091AC_OUTPUT
Neil Schemenauer61c51152001-01-26 16:18:16 +00004092
Thomas Wouters49fd7fa2006-04-21 10:40:58 +00004093echo "creating Modules/Setup"
Neil Schemenauer61c51152001-01-26 16:18:16 +00004094if test ! -f Modules/Setup
4095then
4096 cp $srcdir/Modules/Setup.dist Modules/Setup
4097fi
4098
Thomas Wouters49fd7fa2006-04-21 10:40:58 +00004099echo "creating Modules/Setup.local"
Neil Schemenauer61c51152001-01-26 16:18:16 +00004100if test ! -f Modules/Setup.local
4101then
4102 echo "# Edit this file for local setup changes" >Modules/Setup.local
4103fi
4104
4105echo "creating Makefile"
4106$SHELL $srcdir/Modules/makesetup -c $srcdir/Modules/config.c.in \
4107 -s Modules Modules/Setup.config \
Neil Schemenauerf8b71c52001-04-21 17:41:16 +00004108 Modules/Setup.local Modules/Setup
Neil Schemenauer66252162001-02-19 04:47:42 +00004109mv config.c Modules