blob: 415a35f41c0337c839d56d7d89e135fd0f08f582 [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 Oussoren92fb9412010-03-09 06:40:19 +0000322 Darwin/1@<:@0-9@:>@.*)
Ronald Oussorenb8f11a62010-03-08 07:02:03 +0000323 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)
Benjamin Peterson1718bd12010-03-09 21:46:49 +0000822if test "${OPT-unset}" == "unset"
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öwisfd1c69e72004-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 Ward57c9a6632000-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 Ward57c9a6632000-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 Warsawc0d24d8b2000-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 Peterson0f64b0b2010-03-09 21:49:52 +00001917AC_PATH_TOOL([PKG_CONFIG], [pkg-config])
1918
Benjamin Petersonb2d90462009-12-31 03:23:10 +00001919# Check for use of the system expat library
1920AC_MSG_CHECKING(for --with-system-expat)
1921AC_ARG_WITH(system_expat,
1922 AC_HELP_STRING(--with-system-expat, build pyexpat module using an installed expat library))
1923
1924AC_MSG_RESULT($with_system_expat)
1925
Thomas Wouters49fd7fa2006-04-21 10:40:58 +00001926# Check for use of the system libffi library
1927AC_MSG_CHECKING(for --with-system-ffi)
1928AC_ARG_WITH(system_ffi,
1929 AC_HELP_STRING(--with-system-ffi, build _ctypes module using an installed ffi library))
1930
Benjamin Peterson0f64b0b2010-03-09 21:49:52 +00001931if test "$with_system_ffi" = "yes" && test -n "$PKG_CONFIG"; then
Benjamin Petersond78735d2010-01-01 16:04:23 +00001932 LIBFFI_INCLUDEDIR="`"$PKG_CONFIG" libffi --cflags-only-I 2>/dev/null | sed -e 's/^-I//;s/ *$//'`"
1933else
1934 LIBFFI_INCLUDEDIR=""
1935fi
1936AC_SUBST(LIBFFI_INCLUDEDIR)
1937
Thomas Wouters49fd7fa2006-04-21 10:40:58 +00001938AC_MSG_RESULT($with_system_ffi)
1939
Matthias Klose55708cc2009-04-30 08:06:49 +00001940# Check for --with-dbmliborder
1941AC_MSG_CHECKING(for --with-dbmliborder)
1942AC_ARG_WITH(dbmliborder,
1943 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'.]),
1944[
1945if test x$with_dbmliborder = xyes
1946then
1947AC_MSG_ERROR([proper usage is --with-dbmliborder=db1:db2:...])
1948else
1949 for db in `echo $with_dbmliborder | sed 's/:/ /g'`; do
1950 if test x$db != xndbm && test x$db != xgdbm && test x$db != xbdb
1951 then
1952 AC_MSG_ERROR([proper usage is --with-dbmliborder=db1:db2:...])
1953 fi
1954 done
1955fi])
1956AC_MSG_RESULT($with_dbmliborder)
1957
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00001958# Determine if signalmodule should be used.
1959AC_SUBST(USE_SIGNAL_MODULE)
1960AC_SUBST(SIGNAL_OBJS)
1961AC_MSG_CHECKING(for --with-signal-module)
1962AC_ARG_WITH(signal-module,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00001963 AC_HELP_STRING(--with-signal-module, disable/enable signal module))
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00001964
1965if test -z "$with_signal_module"
1966then with_signal_module="yes"
1967fi
1968AC_MSG_RESULT($with_signal_module)
1969
1970if test "${with_signal_module}" = "yes"; then
1971 USE_SIGNAL_MODULE=""
1972 SIGNAL_OBJS=""
1973else
1974 USE_SIGNAL_MODULE="#"
1975 SIGNAL_OBJS="Parser/intrcheck.o Python/sigcheck.o"
1976fi
1977
Guido van Rossum3d15bd82001-01-10 18:53:48 +00001978# This is used to generate Setup.config
Guido van Rossum009f7871997-12-04 00:51:42 +00001979AC_SUBST(USE_THREAD_MODULE)
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00001980USE_THREAD_MODULE=""
Guido van Rossum009f7871997-12-04 00:51:42 +00001981
Guido van Rossum54d93d41997-01-22 20:51:58 +00001982AC_MSG_CHECKING(for --with-dec-threads)
1983AC_SUBST(LDLAST)
1984AC_ARG_WITH(dec-threads,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00001985 AC_HELP_STRING(--with-dec-threads, use DEC Alpha/OSF1 thread-safe libraries),
1986[
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00001987AC_MSG_RESULT($withval)
Guido van Rossum54d93d41997-01-22 20:51:58 +00001988LDLAST=-threads
Guido van Rossumf78abae1997-01-21 22:02:36 +00001989if test "${with_thread+set}" != set; then
Guido van Rossum54d93d41997-01-22 20:51:58 +00001990 with_thread="$withval";
1991fi],
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00001992[AC_MSG_RESULT(no)])
Guido van Rossum54d93d41997-01-22 20:51:58 +00001993
Martin v. Löwis11437992002-04-12 09:54:03 +00001994# Templates for things AC_DEFINEd more than once.
1995# For a single AC_DEFINE, no template is needed.
1996AH_TEMPLATE(C_THREADS,[Define if you have the Mach cthreads package])
1997AH_TEMPLATE(_REENTRANT,
1998 [Define to force use of thread-safe errno, h_errno, and other functions])
1999AH_TEMPLATE(WITH_THREAD,
2000 [Define if you want to compile in rudimentary thread support])
2001
Guido van Rossum54d93d41997-01-22 20:51:58 +00002002AC_MSG_CHECKING(for --with-threads)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002003dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00002004AC_ARG_WITH(threads,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002005 AC_HELP_STRING(--with(out)-threads@<:@=DIRECTORY@:>@, disable/enable thread support))
Guido van Rossum54d93d41997-01-22 20:51:58 +00002006
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00002007# --with-thread is deprecated, but check for it anyway
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002008dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
Barry Warsawa0f3c5c2000-06-30 16:39:35 +00002009AC_ARG_WITH(thread,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002010 AC_HELP_STRING(--with(out)-thread@<:@=DIRECTORY@:>@, deprecated; use --with(out)-threads),
2011 [with_threads=$with_thread])
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00002012
2013if test -z "$with_threads"
2014then with_threads="yes"
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002015fi
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00002016AC_MSG_RESULT($with_threads)
Guido van Rossum6400c261997-05-22 20:34:27 +00002017
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002018AC_SUBST(THREADOBJ)
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00002019if test "$with_threads" = "no"
2020then
2021 USE_THREAD_MODULE="#"
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002022elif test "$ac_cv_pthread_is_default" = yes
2023then
2024 AC_DEFINE(WITH_THREAD)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002025 # Defining _REENTRANT on system with POSIX threads should not hurt.
2026 AC_DEFINE(_REENTRANT)
2027 posix_threads=yes
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002028 THREADOBJ="Python/thread.o"
Martin v. Löwis130fb172001-07-19 11:00:41 +00002029elif test "$ac_cv_kpthread" = "yes"
2030then
2031 CC="$CC -Kpthread"
Martin v. Löwis519adae2003-09-20 10:47:47 +00002032 if test "$ac_cv_cxx_thread" = "yes"; then
2033 CXX="$CXX -Kpthread"
2034 fi
Martin v. Löwis130fb172001-07-19 11:00:41 +00002035 AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002036 posix_threads=yes
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002037 THREADOBJ="Python/thread.o"
Martin v. Löwis5f433f02003-05-05 05:05:30 +00002038elif test "$ac_cv_kthread" = "yes"
2039then
2040 CC="$CC -Kthread"
Martin v. Löwis519adae2003-09-20 10:47:47 +00002041 if test "$ac_cv_cxx_thread" = "yes"; then
2042 CXX="$CXX -Kthread"
2043 fi
Martin v. Löwis5f433f02003-05-05 05:05:30 +00002044 AC_DEFINE(WITH_THREAD)
2045 posix_threads=yes
2046 THREADOBJ="Python/thread.o"
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002047elif test "$ac_cv_pthread" = "yes"
2048then
2049 CC="$CC -pthread"
Martin v. Löwis519adae2003-09-20 10:47:47 +00002050 if test "$ac_cv_cxx_thread" = "yes"; then
2051 CXX="$CXX -pthread"
2052 fi
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002053 AC_DEFINE(WITH_THREAD)
2054 posix_threads=yes
2055 THREADOBJ="Python/thread.o"
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00002056else
Martin v. Löwis130fb172001-07-19 11:00:41 +00002057 if test ! -z "$with_threads" -a -d "$with_threads"
2058 then LDFLAGS="$LDFLAGS -L$with_threads"
2059 fi
2060 if test ! -z "$withval" -a -d "$withval"
2061 then LDFLAGS="$LDFLAGS -L$withval"
2062 fi
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002063
2064 # According to the POSIX spec, a pthreads implementation must
Matthias Klosea2542be2004-08-16 11:35:51 +00002065 # define _POSIX_THREADS in unistd.h. Some apparently don't
2066 # (e.g. gnu pth with pthread emulation)
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002067 AC_MSG_CHECKING(for _POSIX_THREADS in unistd.h)
2068 AC_EGREP_CPP(yes,
Neal Norwitz6eb37f02003-02-23 23:28:15 +00002069 [
2070#include <unistd.h>
2071#ifdef _POSIX_THREADS
2072yes
2073#endif
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002074 ], unistd_defines_pthreads=yes, unistd_defines_pthreads=no)
2075 AC_MSG_RESULT($unistd_defines_pthreads)
2076
Martin v. Löwis130fb172001-07-19 11:00:41 +00002077 AC_DEFINE(_REENTRANT)
Martin v. Löwisa6e97582002-01-01 18:41:33 +00002078 AC_CHECK_HEADER(cthreads.h, [AC_DEFINE(WITH_THREAD)
2079 AC_DEFINE(C_THREADS)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002080 AC_DEFINE(HURD_C_THREADS, 1,
2081 [Define if you are using Mach cthreads directly under /include])
Martin v. Löwisa6e97582002-01-01 18:41:33 +00002082 LIBS="$LIBS -lthreads"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002083 THREADOBJ="Python/thread.o"],[
Martin v. Löwis130fb172001-07-19 11:00:41 +00002084 AC_CHECK_HEADER(mach/cthreads.h, [AC_DEFINE(WITH_THREAD)
2085 AC_DEFINE(C_THREADS)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002086 AC_DEFINE(MACH_C_THREADS, 1,
2087 [Define if you are using Mach cthreads under mach /])
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002088 THREADOBJ="Python/thread.o"],[
Martin v. Löwis8158b5a2001-10-08 13:17:28 +00002089 # Just looking for pthread_create in libpthread is not enough:
2090 # on HP/UX, pthread.h renames pthread_create to a different symbol name.
2091 # So we really have to include pthread.h, and then link.
2092 _libs=$LIBS
2093 LIBS="$LIBS -lpthread"
2094 AC_MSG_CHECKING([for pthread_create in -lpthread])
2095 AC_TRY_LINK([#include <pthread.h>
2096
2097void * start_routine (void *arg) { exit (0); }], [
2098pthread_create (NULL, NULL, start_routine, NULL)], [
2099 AC_MSG_RESULT(yes)
2100 AC_DEFINE(WITH_THREAD)
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002101 posix_threads=yes
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002102 THREADOBJ="Python/thread.o"],[
Martin v. Löwis8158b5a2001-10-08 13:17:28 +00002103 LIBS=$_libs
Martin v. Löwis130fb172001-07-19 11:00:41 +00002104 AC_CHECK_FUNC(pthread_detach, [AC_DEFINE(WITH_THREAD)
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002105 posix_threads=yes
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002106 THREADOBJ="Python/thread.o"],[
Martin v. Löwis130fb172001-07-19 11:00:41 +00002107 AC_CHECK_LIB(pthreads, pthread_create, [AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002108 posix_threads=yes
Martin v. Löwis130fb172001-07-19 11:00:41 +00002109 LIBS="$LIBS -lpthreads"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002110 THREADOBJ="Python/thread.o"], [
Martin v. Löwis130fb172001-07-19 11:00:41 +00002111 AC_CHECK_LIB(c_r, pthread_create, [AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002112 posix_threads=yes
Martin v. Löwis130fb172001-07-19 11:00:41 +00002113 LIBS="$LIBS -lc_r"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002114 THREADOBJ="Python/thread.o"], [
Martin v. Löwis130fb172001-07-19 11:00:41 +00002115 AC_CHECK_LIB(pthread, __pthread_create_system, [AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002116 posix_threads=yes
Martin v. Löwis130fb172001-07-19 11:00:41 +00002117 LIBS="$LIBS -lpthread"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002118 THREADOBJ="Python/thread.o"], [
Martin v. Löwis130fb172001-07-19 11:00:41 +00002119 AC_CHECK_LIB(cma, pthread_create, [AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002120 posix_threads=yes
Martin v. Löwis130fb172001-07-19 11:00:41 +00002121 LIBS="$LIBS -lcma"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002122 THREADOBJ="Python/thread.o"],[
Martin v. Löwis130fb172001-07-19 11:00:41 +00002123 USE_THREAD_MODULE="#"])
Antoine Pitroudb6c5672009-10-24 20:35:52 +00002124 ])])])])])])])
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00002125
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002126 AC_CHECK_LIB(mpc, usconfig, [AC_DEFINE(WITH_THREAD)
2127 LIBS="$LIBS -lmpc"
2128 THREADOBJ="Python/thread.o"
2129 USE_THREAD_MODULE=""])
2130
2131 if test "$posix_threads" != "yes"; then
2132 AC_CHECK_LIB(thread, thr_create, [AC_DEFINE(WITH_THREAD)
2133 LIBS="$LIBS -lthread"
2134 THREADOBJ="Python/thread.o"
2135 USE_THREAD_MODULE=""])
2136 fi
2137
2138 if test "$USE_THREAD_MODULE" != "#"
2139 then
2140 # If the above checks didn't disable threads, (at least) OSF1
2141 # needs this '-threads' argument during linking.
2142 case $ac_sys_system in
2143 OSF1) LDLAST=-threads;;
2144 esac
2145 fi
2146fi
2147
2148if test "$posix_threads" = "yes"; then
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002149 if test "$unistd_defines_pthreads" = "no"; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002150 AC_DEFINE(_POSIX_THREADS, 1,
2151 [Define if you have POSIX threads,
2152 and your system does not define that.])
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002153 fi
2154
Martin v. Löwisdfc33fd2003-01-21 10:14:41 +00002155 # Bug 662787: Using semaphores causes unexplicable hangs on Solaris 8.
2156 case $ac_sys_system/$ac_sys_release in
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002157 SunOS/5.6) AC_DEFINE(HAVE_PTHREAD_DESTRUCTOR, 1,
2158 Defined for Solaris 2.6 bug in pthread header.)
2159 ;;
Martin v. Löwisdfc33fd2003-01-21 10:14:41 +00002160 SunOS/5.8) AC_DEFINE(HAVE_BROKEN_POSIX_SEMAPHORES, 1,
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002161 Define if the Posix semaphores do not work on your system)
2162 ;;
Christian Heimes7b3ce6a2008-01-31 14:31:45 +00002163 AIX/5) AC_DEFINE(HAVE_BROKEN_POSIX_SEMAPHORES, 1,
2164 Define if the Posix semaphores do not work on your system)
2165 ;;
Martin v. Löwisdfc33fd2003-01-21 10:14:41 +00002166 esac
2167
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002168 AC_MSG_CHECKING(if PTHREAD_SCOPE_SYSTEM is supported)
2169 AC_CACHE_VAL(ac_cv_pthread_system_supported,
2170 [AC_TRY_RUN([#include <pthread.h>
2171 void *foo(void *parm) {
2172 return NULL;
2173 }
2174 main() {
2175 pthread_attr_t attr;
Martin v. Löwisa82d3472002-02-24 16:05:05 +00002176 pthread_t id;
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002177 if (pthread_attr_init(&attr)) exit(-1);
2178 if (pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM)) exit(-1);
Martin v. Löwisa82d3472002-02-24 16:05:05 +00002179 if (pthread_create(&id, &attr, foo, NULL)) exit(-1);
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002180 exit(0);
Guido van Rossum3065c942001-09-17 04:03:14 +00002181 }],
2182 ac_cv_pthread_system_supported=yes,
2183 ac_cv_pthread_system_supported=no,
2184 ac_cv_pthread_system_supported=no)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002185 ])
2186 AC_MSG_RESULT($ac_cv_pthread_system_supported)
2187 if test "$ac_cv_pthread_system_supported" = "yes"; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002188 AC_DEFINE(PTHREAD_SYSTEM_SCHED_SUPPORTED, 1, [Defined if PTHREAD_SCOPE_SYSTEM supported.])
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002189 fi
Jason Tishlerfac083d2003-07-22 15:20:49 +00002190 AC_CHECK_FUNCS(pthread_sigmask,
2191 [case $ac_sys_system in
2192 CYGWIN*)
2193 AC_DEFINE(HAVE_BROKEN_PTHREAD_SIGMASK, 1,
2194 [Define if pthread_sigmask() does not work on your system.])
2195 ;;
2196 esac])
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00002197fi
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002198
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002199
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002200# Check for enable-ipv6
Martin v. Löwis11437992002-04-12 09:54:03 +00002201AH_TEMPLATE(ENABLE_IPV6, [Define if --enable-ipv6 is specified])
Martin v. Löwisa5f8bb52001-09-05 08:22:34 +00002202AC_MSG_CHECKING([if --enable-ipv6 is specified])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002203AC_ARG_ENABLE(ipv6,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002204[ --enable-ipv6 Enable ipv6 (with ipv4) support
2205 --disable-ipv6 Disable ipv6 support],
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002206[ case "$enableval" in
2207 no)
2208 AC_MSG_RESULT(no)
2209 ipv6=no
2210 ;;
2211 *) AC_MSG_RESULT(yes)
2212 AC_DEFINE(ENABLE_IPV6)
2213 ipv6=yes
2214 ;;
2215 esac ],
2216
Martin v. Löwisa5f8bb52001-09-05 08:22:34 +00002217[
2218dnl the check does not work on cross compilation case...
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002219 AC_TRY_RUN([ /* AF_INET6 available check */
2220#include <sys/types.h>
2221#include <sys/socket.h>
2222main()
2223{
2224 if (socket(AF_INET6, SOCK_STREAM, 0) < 0)
2225 exit(1);
2226 else
2227 exit(0);
2228}
2229],
2230 AC_MSG_RESULT(yes)
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002231 ipv6=yes,
2232 AC_MSG_RESULT(no)
2233 ipv6=no,
2234 AC_MSG_RESULT(no)
2235 ipv6=no
Martin v. Löwisa5f8bb52001-09-05 08:22:34 +00002236)
2237
2238if test "$ipv6" = "yes"; then
2239 AC_MSG_CHECKING(if RFC2553 API is available)
2240 AC_TRY_COMPILE([#include <sys/types.h>
2241#include <netinet/in.h>],
2242 [struct sockaddr_in6 x;
2243x.sin6_scope_id;],
2244 AC_MSG_RESULT(yes)
2245 ipv6=yes,
2246 AC_MSG_RESULT(no, IPv6 disabled)
2247 ipv6=no)
2248fi
2249
2250if test "$ipv6" = "yes"; then
2251 AC_DEFINE(ENABLE_IPV6)
2252fi
2253])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002254
2255ipv6type=unknown
2256ipv6lib=none
2257ipv6trylibc=no
2258
2259if test "$ipv6" = "yes"; then
2260 AC_MSG_CHECKING([ipv6 stack type])
Guido van Rossumb8552162001-09-05 14:58:11 +00002261 for i in inria kame linux-glibc linux-inet6 solaris toshiba v6d zeta;
2262 do
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002263 case $i in
2264 inria)
2265 dnl http://www.kame.net/
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002266 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002267#include <netinet/in.h>
2268#ifdef IPV6_INRIA_VERSION
2269yes
2270#endif],
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002271 [ipv6type=$i])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002272 ;;
2273 kame)
2274 dnl http://www.kame.net/
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002275 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002276#include <netinet/in.h>
2277#ifdef __KAME__
2278yes
2279#endif],
2280 [ipv6type=$i;
2281 ipv6lib=inet6
2282 ipv6libdir=/usr/local/v6/lib
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002283 ipv6trylibc=yes])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002284 ;;
2285 linux-glibc)
2286 dnl http://www.v6.linux.or.jp/
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002287 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002288#include <features.h>
2289#if defined(__GLIBC__) && ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1) || (__GLIBC__ > 2))
2290yes
2291#endif],
2292 [ipv6type=$i;
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002293 ipv6trylibc=yes])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002294 ;;
2295 linux-inet6)
2296 dnl http://www.v6.linux.or.jp/
2297 if test -d /usr/inet6; then
2298 ipv6type=$i
2299 ipv6lib=inet6
2300 ipv6libdir=/usr/inet6/lib
Skip Montanarodecc6a42003-01-01 20:07:49 +00002301 BASECFLAGS="-I/usr/inet6/include $BASECFLAGS"
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002302 fi
2303 ;;
2304 solaris)
2305 if test -f /etc/netconfig; then
2306 if /usr/xpg4/bin/grep -q tcp6 /etc/netconfig; then
2307 ipv6type=$i
2308 ipv6trylibc=yes
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002309 fi
2310 fi
2311 ;;
2312 toshiba)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002313 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002314#include <sys/param.h>
2315#ifdef _TOSHIBA_INET6
2316yes
2317#endif],
2318 [ipv6type=$i;
2319 ipv6lib=inet6;
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002320 ipv6libdir=/usr/local/v6/lib])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002321 ;;
2322 v6d)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002323 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002324#include </usr/local/v6/include/sys/v6config.h>
2325#ifdef __V6D__
2326yes
2327#endif],
2328 [ipv6type=$i;
2329 ipv6lib=v6;
2330 ipv6libdir=/usr/local/v6/lib;
Skip Montanarodecc6a42003-01-01 20:07:49 +00002331 BASECFLAGS="-I/usr/local/v6/include $BASECFLAGS"])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002332 ;;
2333 zeta)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002334 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002335#include <sys/param.h>
2336#ifdef _ZETA_MINAMI_INET6
2337yes
2338#endif],
2339 [ipv6type=$i;
2340 ipv6lib=inet6;
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002341 ipv6libdir=/usr/local/v6/lib])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002342 ;;
2343 esac
2344 if test "$ipv6type" != "unknown"; then
2345 break
2346 fi
2347 done
2348 AC_MSG_RESULT($ipv6type)
2349fi
2350
2351if test "$ipv6" = "yes" -a "$ipv6lib" != "none"; then
2352 if test -d $ipv6libdir -a -f $ipv6libdir/lib$ipv6lib.a; then
2353 LIBS="-L$ipv6libdir -l$ipv6lib $LIBS"
2354 echo "using lib$ipv6lib"
2355 else
2356 if test $ipv6trylibc = "yes"; then
2357 echo "using libc"
2358 else
2359 echo 'Fatal: no $ipv6lib library found. cannot continue.'
2360 echo "You need to fetch lib$ipv6lib.a from appropriate"
2361 echo 'ipv6 kit and compile beforehand.'
2362 exit 1
2363 fi
2364 fi
2365fi
2366
Georg Brandl93de2162008-07-16 02:21:06 +00002367AC_MSG_CHECKING(for OSX 10.5 SDK or later)
2368AC_TRY_COMPILE([#include <Carbon/Carbon.h>], FSIORefNum fRef = 0,
2369 AC_DEFINE(HAVE_OSX105_SDK, 1, Define if compiling using MacOS X 10.5 SDK or later.)
2370 AC_MSG_RESULT(yes),
2371 AC_MSG_RESULT(no)
2372)
2373
Martin v. Löwisa3fb4f72002-06-09 13:33:54 +00002374# Check for --with-doc-strings
2375AC_MSG_CHECKING(for --with-doc-strings)
2376AC_ARG_WITH(doc-strings,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002377 AC_HELP_STRING(--with(out)-doc-strings, disable/enable documentation strings))
Martin v. Löwisa3fb4f72002-06-09 13:33:54 +00002378
2379if test -z "$with_doc_strings"
2380then with_doc_strings="yes"
2381fi
2382if test "$with_doc_strings" != "no"
2383then
2384 AC_DEFINE(WITH_DOC_STRINGS, 1,
2385 [Define if you want documentation strings in extension modules])
2386fi
2387AC_MSG_RESULT($with_doc_strings)
2388
Neil Schemenauera35c6882001-02-27 04:45:05 +00002389# Check for Python-specific malloc support
Martin v. Löwisf30d60e2004-06-08 08:17:44 +00002390AC_MSG_CHECKING(for --with-tsc)
2391AC_ARG_WITH(tsc,
2392[ --with(out)-tsc enable/disable timestamp counter profile], [
2393if test "$withval" != no
2394then
2395 AC_DEFINE(WITH_TSC, 1,
2396 [Define to profile with the Pentium timestamp counter])
2397 AC_MSG_RESULT(yes)
2398else AC_MSG_RESULT(no)
2399fi],
2400[AC_MSG_RESULT(no)])
2401
2402# Check for Python-specific malloc support
Neil Schemenauera35c6882001-02-27 04:45:05 +00002403AC_MSG_CHECKING(for --with-pymalloc)
2404AC_ARG_WITH(pymalloc,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002405 AC_HELP_STRING(--with(out)-pymalloc, disable/enable specialized mallocs))
Neil Schemenauer16c22972002-03-22 15:34:49 +00002406
2407if test -z "$with_pymalloc"
2408then with_pymalloc="yes"
2409fi
2410if test "$with_pymalloc" != "no"
2411then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002412 AC_DEFINE(WITH_PYMALLOC, 1,
2413 [Define if you want to compile in Python-specific mallocs])
Neil Schemenauer16c22972002-03-22 15:34:49 +00002414fi
2415AC_MSG_RESULT($with_pymalloc)
Neil Schemenauera35c6882001-02-27 04:45:05 +00002416
Benjamin Peterson05159c42009-12-03 03:01:27 +00002417# Check for Valgrind support
2418AC_MSG_CHECKING([for --with-valgrind])
2419AC_ARG_WITH([valgrind],
2420 AC_HELP_STRING([--with-valgrind], [Enable Valgrind support]),,
2421 with_valgrind=no)
2422AC_MSG_RESULT([$with_valgrind])
2423if test "$with_valgrind" != no; then
2424 AC_CHECK_HEADER([valgrind/valgrind.h],
2425 [AC_DEFINE([WITH_VALGRIND], 1, [Define if you want pymalloc to be disabled when running under valgrind])],
2426 [AC_MSG_ERROR([Valgrind support requested but headers not available])]
2427 )
2428fi
2429
Barry Warsawef82cd72000-06-30 16:21:01 +00002430# Check for --with-wctype-functions
2431AC_MSG_CHECKING(for --with-wctype-functions)
2432AC_ARG_WITH(wctype-functions,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002433 AC_HELP_STRING(--with-wctype-functions, use wctype.h functions),
2434[
Barry Warsawef82cd72000-06-30 16:21:01 +00002435if test "$withval" != no
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002436then
2437 AC_DEFINE(WANT_WCTYPE_FUNCTIONS, 1,
2438 [Define if you want wctype.h functions to be used instead of the
2439 one supplied by Python itself. (see Include/unicodectype.h).])
2440 AC_MSG_RESULT(yes)
Barry Warsawef82cd72000-06-30 16:21:01 +00002441else AC_MSG_RESULT(no)
2442fi],
2443[AC_MSG_RESULT(no)])
2444
Guido van Rossum68242b51996-05-28 22:53:03 +00002445# -I${DLINCLDIR} is added to the compile rule for importdl.o
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002446AC_SUBST(DLINCLDIR)
Guido van Rossum98935bf2001-09-05 19:13:16 +00002447DLINCLDIR=.
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002448
Guido van Rossume97ee181999-12-20 21:27:22 +00002449# the dlopen() function means we might want to use dynload_shlib.o. some
2450# platforms, such as AIX, have dlopen(), but don't want to use it.
Thomas Wouters3a584202000-08-05 23:28:51 +00002451AC_CHECK_FUNCS(dlopen)
Guido van Rossume97ee181999-12-20 21:27:22 +00002452
2453# DYNLOADFILE specifies which dynload_*.o file we will use for dynamic
2454# loading of modules.
2455AC_SUBST(DYNLOADFILE)
2456AC_MSG_CHECKING(DYNLOADFILE)
2457if test -z "$DYNLOADFILE"
2458then
2459 case $ac_sys_system/$ac_sys_release in
Martin v. Löwisc19c5a62003-11-18 20:00:44 +00002460 AIX*) # Use dynload_shlib.c and dlopen() if we have it; otherwise dynload_aix.c
2461 if test "$ac_cv_func_dlopen" = yes
2462 then DYNLOADFILE="dynload_shlib.o"
2463 else DYNLOADFILE="dynload_aix.o"
2464 fi
2465 ;;
Guido van Rossume97ee181999-12-20 21:27:22 +00002466 hp*|HP*) DYNLOADFILE="dynload_hpux.o";;
Thomas Wouters49fd7fa2006-04-21 10:40:58 +00002467 # Use dynload_next.c only on 10.2 and below, which don't have native dlopen()
2468 Darwin/@<:@0156@:>@\..*) DYNLOADFILE="dynload_next.o";;
Guido van Rossume97ee181999-12-20 21:27:22 +00002469 *)
2470 # use dynload_shlib.c and dlopen() if we have it; otherwise stub
2471 # out any dynamic loading
2472 if test "$ac_cv_func_dlopen" = yes
2473 then DYNLOADFILE="dynload_shlib.o"
2474 else DYNLOADFILE="dynload_stub.o"
2475 fi
2476 ;;
2477 esac
2478fi
2479AC_MSG_RESULT($DYNLOADFILE)
2480if test "$DYNLOADFILE" != "dynload_stub.o"
2481then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002482 AC_DEFINE(HAVE_DYNAMIC_LOADING, 1,
2483 [Defined when any dynamic module loading is enabled.])
Guido van Rossume97ee181999-12-20 21:27:22 +00002484fi
2485
Jack Jansenc49e5b72001-06-19 15:00:23 +00002486# MACHDEP_OBJS can be set to platform-specific object files needed by Python
2487
2488AC_SUBST(MACHDEP_OBJS)
2489AC_MSG_CHECKING(MACHDEP_OBJS)
2490if test -z "$MACHDEP_OBJS"
2491then
Jack Jansenb6e9cad2001-08-15 01:26:28 +00002492 MACHDEP_OBJS=$extra_machdep_objs
2493else
2494 MACHDEP_OBJS="$MACHDEP_OBJS $extra_machdep_objs"
Jack Jansenc49e5b72001-06-19 15:00:23 +00002495fi
Jack Jansenb6e9cad2001-08-15 01:26:28 +00002496AC_MSG_RESULT(MACHDEP_OBJS)
Jack Jansenc49e5b72001-06-19 15:00:23 +00002497
Guido van Rossum627b2d71993-12-24 10:39:16 +00002498# checks for library functions
Martin v. Löwis823725e2008-03-24 13:39:54 +00002499AC_CHECK_FUNCS(alarm setitimer getitimer bind_textdomain_codeset chown \
2500 clock confstr ctermid execv fchmod fchown fork fpathconf ftime ftruncate \
Martin v. Löwis438b5342002-12-27 10:16:42 +00002501 gai_strerror getgroups getlogin getloadavg getpeername getpgid getpid \
Martin v. Löwis7aed61a2009-11-27 14:09:49 +00002502 getpriority getresuid getresgid getpwent getspnam getspent getsid getwd \
Antoine Pitroub7572f02009-12-02 20:46:48 +00002503 initgroups kill killpg lchmod lchown lstat mbrtowc mkfifo mknod mktime \
Martin v. Löwisa5f09072002-10-11 05:37:59 +00002504 mremap nice pathconf pause plock poll pthread_init \
Guido van Rossum162e38c2003-02-19 15:25:10 +00002505 putenv readlink realpath \
Benjamin Peterson965ce872009-04-05 21:24:58 +00002506 select sem_open sem_timedwait sem_getvalue sem_unlink setegid seteuid \
2507 setgid \
Martin v. Löwis7aed61a2009-11-27 14:09:49 +00002508 setlocale setregid setreuid setresuid setresgid setsid setpgid setpgrp setuid setvbuf \
2509 sigaction siginterrupt sigrelse snprintf strftime strlcpy \
Michael W. Hudson34f20ea2002-05-27 15:08:24 +00002510 sysconf tcgetpgrp tcsetpgrp tempnam timegm times tmpfile tmpnam tmpnam_r \
Martin v. Löwis113a0852009-05-29 17:25:39 +00002511 truncate uname unsetenv utimes waitpid wait3 wait4 \
2512 wcscoll wcsftime wcsxfrm _getpty)
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00002513
Martin v. Löwisc8ad7cc2002-11-11 13:23:45 +00002514# For some functions, having a definition is not sufficient, since
2515# we want to take their address.
2516AC_MSG_CHECKING(for chroot)
2517AC_TRY_COMPILE([#include <unistd.h>], void *x=chroot,
2518 AC_DEFINE(HAVE_CHROOT, 1, Define if you have the 'chroot' function.)
2519 AC_MSG_RESULT(yes),
2520 AC_MSG_RESULT(no)
2521)
2522AC_MSG_CHECKING(for link)
2523AC_TRY_COMPILE([#include <unistd.h>], void *x=link,
2524 AC_DEFINE(HAVE_LINK, 1, Define if you have the 'link' function.)
2525 AC_MSG_RESULT(yes),
2526 AC_MSG_RESULT(no)
2527)
2528AC_MSG_CHECKING(for symlink)
2529AC_TRY_COMPILE([#include <unistd.h>], void *x=symlink,
2530 AC_DEFINE(HAVE_SYMLINK, 1, Define if you have the 'symlink' function.)
2531 AC_MSG_RESULT(yes),
2532 AC_MSG_RESULT(no)
2533)
Martin v. Löwisa64988c2003-09-20 15:30:20 +00002534AC_MSG_CHECKING(for fchdir)
2535AC_TRY_COMPILE([#include <unistd.h>], void *x=fchdir,
2536 AC_DEFINE(HAVE_FCHDIR, 1, Define if you have the 'fchdir' function.)
2537 AC_MSG_RESULT(yes),
2538 AC_MSG_RESULT(no)
2539)
2540AC_MSG_CHECKING(for fsync)
2541AC_TRY_COMPILE([#include <unistd.h>], void *x=fsync,
Skip Montanarod4fa8072003-09-25 14:49:15 +00002542 AC_DEFINE(HAVE_FSYNC, 1, Define if you have the 'fsync' function.)
Martin v. Löwisa64988c2003-09-20 15:30:20 +00002543 AC_MSG_RESULT(yes),
2544 AC_MSG_RESULT(no)
2545)
2546AC_MSG_CHECKING(for fdatasync)
2547AC_TRY_COMPILE([#include <unistd.h>], void *x=fdatasync,
2548 AC_DEFINE(HAVE_FDATASYNC, 1, Define if you have the 'fdatasync' function.)
2549 AC_MSG_RESULT(yes),
2550 AC_MSG_RESULT(no)
2551)
Christian Heimes4fbc72b2008-03-22 00:47:35 +00002552AC_MSG_CHECKING(for epoll)
2553AC_TRY_COMPILE([#include <sys/epoll.h>], void *x=epoll_create,
2554 AC_DEFINE(HAVE_EPOLL, 1, Define if you have the 'epoll' functions.)
2555 AC_MSG_RESULT(yes),
2556 AC_MSG_RESULT(no)
2557)
2558AC_MSG_CHECKING(for kqueue)
2559AC_TRY_COMPILE([
2560#include <sys/types.h>
2561#include <sys/event.h>
2562 ], int x=kqueue(),
2563 AC_DEFINE(HAVE_KQUEUE, 1, Define if you have the 'kqueue' functions.)
2564 AC_MSG_RESULT(yes),
2565 AC_MSG_RESULT(no)
2566)
Martin v. Löwisd5843682002-11-21 20:41:28 +00002567# On some systems (eg. FreeBSD 5), we would find a definition of the
2568# functions ctermid_r, setgroups in the library, but no prototype
2569# (e.g. because we use _XOPEN_SOURCE). See whether we can take their
2570# address to avoid compiler warnings and potential miscompilations
2571# because of the missing prototypes.
2572
2573AC_MSG_CHECKING(for ctermid_r)
2574AC_TRY_COMPILE([
2575#include "confdefs.h"
2576#include <stdio.h>
2577], void* p = ctermid_r,
2578 AC_DEFINE(HAVE_CTERMID_R, 1, Define if you have the 'ctermid_r' function.)
2579 AC_MSG_RESULT(yes),
2580 AC_MSG_RESULT(no)
2581)
2582
Martin v. Löwisf26d63b2003-03-30 17:23:49 +00002583AC_MSG_CHECKING(for flock)
2584AC_TRY_COMPILE([
2585#include "confdefs.h"
2586#include <sys/file.h>
2587], void* p = flock,
2588 AC_DEFINE(HAVE_FLOCK, 1, Define if you have the 'flock' function.)
2589 AC_MSG_RESULT(yes),
2590 AC_MSG_RESULT(no)
2591)
2592
2593AC_MSG_CHECKING(for getpagesize)
2594AC_TRY_COMPILE([
2595#include "confdefs.h"
2596#include <unistd.h>
2597], void* p = getpagesize,
2598 AC_DEFINE(HAVE_GETPAGESIZE, 1, Define if you have the 'getpagesize' function.)
2599 AC_MSG_RESULT(yes),
2600 AC_MSG_RESULT(no)
2601)
2602
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002603dnl check for true
2604AC_CHECK_PROGS(TRUE, true, /bin/true)
2605
Martin v. Löwis95c419b2003-05-03 12:10:48 +00002606dnl On some systems (e.g. Solaris 9), hstrerror and inet_aton are in -lresolv
2607dnl On others, they are in the C library, so we to take no action
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002608AC_CHECK_LIB(c, inet_aton, [$ac_cv_prog_TRUE],
Martin v. Löwis95c419b2003-05-03 12:10:48 +00002609 AC_CHECK_LIB(resolv, inet_aton)
2610)
2611
Christian Heimesd0764e22007-12-04 15:00:33 +00002612# On Tru64, chflags seems to be present, but calling it will
2613# exit Python
Benjamin Petersoned68afa2010-01-30 19:36:43 +00002614AC_CACHE_CHECK([for chflags], [ac_cv_have_chflags], [dnl
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00002615AC_TRY_RUN([[
Christian Heimesd0764e22007-12-04 15:00:33 +00002616#include <sys/stat.h>
2617#include <unistd.h>
2618int main(int argc, char*argv[])
2619{
2620 if(chflags(argv[0], 0) != 0)
2621 return 1;
2622 return 0;
2623}
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00002624]], ac_cv_have_chflags=yes,
Benjamin Petersoned68afa2010-01-30 19:36:43 +00002625 ac_cv_have_chflags=no,
2626 ac_cv_have_chflags=cross)
2627])
2628if test "$ac_cv_have_chflags" = cross ; then
2629 AC_CHECK_FUNC([chflags], [ac_cv_have_chflags="yes"], [ac_cv_have_chflags="no"])
2630fi
2631if test "$ac_cv_have_chflags" = yes ; then
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00002632 AC_DEFINE(HAVE_CHFLAGS, 1, Define to 1 if you have the `chflags' function.)
2633fi
Christian Heimesd0764e22007-12-04 15:00:33 +00002634
Benjamin Petersoned68afa2010-01-30 19:36:43 +00002635AC_CACHE_CHECK([for lchflags], [ac_cv_have_lchflags], [dnl
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00002636AC_TRY_RUN([[
Christian Heimesd0764e22007-12-04 15:00:33 +00002637#include <sys/stat.h>
2638#include <unistd.h>
2639int main(int argc, char*argv[])
2640{
2641 if(lchflags(argv[0], 0) != 0)
2642 return 1;
2643 return 0;
2644}
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00002645]], ac_cv_have_lchflags=yes,
Benjamin Petersoned68afa2010-01-30 19:36:43 +00002646 ac_cv_have_lchflags=no,
2647 ac_cv_have_lchflags=cross)
2648])
2649if test "$ac_cv_have_lchflags" = cross ; then
2650 AC_CHECK_FUNC([lchflags], [ac_cv_have_lchflags="yes"], [ac_cv_have_lchflags="no"])
2651fi
2652if test "$ac_cv_have_lchflags" = yes ; then
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00002653 AC_DEFINE(HAVE_LCHFLAGS, 1, Define to 1 if you have the `lchflags' function.)
2654fi
Christian Heimesd0764e22007-12-04 15:00:33 +00002655
Thomas Wouters0e3f5912006-08-11 14:57:12 +00002656dnl Check if system zlib has *Copy() functions
2657dnl
2658dnl On MacOSX the linker will search for dylibs on the entire linker path
2659dnl before searching for static libraries. setup.py adds -Wl,-search_paths_first
2660dnl to revert to a more traditional unix behaviour and make it possible to
2661dnl override the system libz with a local static library of libz. Temporarily
2662dnl add that flag to our CFLAGS as well to ensure that we check the version
2663dnl of libz that will be used by setup.py.
2664dnl The -L/usr/local/lib is needed as wel to get the same compilation
2665dnl environment as setup.py (and leaving it out can cause configure to use the
2666dnl wrong version of the library)
2667case $ac_sys_system/$ac_sys_release in
2668Darwin/*)
2669 _CUR_CFLAGS="${CFLAGS}"
2670 _CUR_LDFLAGS="${LDFLAGS}"
2671 CFLAGS="${CFLAGS} -Wl,-search_paths_first"
2672 LDFLAGS="${LDFLAGS} -Wl,-search_paths_first -L/usr/local/lib"
2673 ;;
2674esac
2675
2676AC_CHECK_LIB(z, inflateCopy, AC_DEFINE(HAVE_ZLIB_COPY, 1, Define if the zlib library has inflateCopy))
2677
2678case $ac_sys_system/$ac_sys_release in
2679Darwin/*)
2680 CFLAGS="${_CUR_CFLAGS}"
2681 LDFLAGS="${_CUR_LDFLAGS}"
2682 ;;
2683esac
2684
Martin v. Löwise9416172003-05-03 10:12:45 +00002685AC_MSG_CHECKING(for hstrerror)
Martin v. Löwis95c419b2003-05-03 12:10:48 +00002686AC_TRY_LINK([
Martin v. Löwise9416172003-05-03 10:12:45 +00002687#include "confdefs.h"
2688#include <netdb.h>
Martin v. Löwis95c419b2003-05-03 12:10:48 +00002689], void* p = hstrerror; hstrerror(0),
Martin v. Löwise9416172003-05-03 10:12:45 +00002690 AC_DEFINE(HAVE_HSTRERROR, 1, Define if you have the 'hstrerror' function.)
2691 AC_MSG_RESULT(yes),
2692 AC_MSG_RESULT(no)
2693)
2694
2695AC_MSG_CHECKING(for inet_aton)
Martin v. Löwis95c419b2003-05-03 12:10:48 +00002696AC_TRY_LINK([
Martin v. Löwise9416172003-05-03 10:12:45 +00002697#include "confdefs.h"
Martin v. Löwis86d66262006-02-17 08:40:11 +00002698#include <sys/types.h>
Martin v. Löwise9416172003-05-03 10:12:45 +00002699#include <sys/socket.h>
2700#include <netinet/in.h>
2701#include <arpa/inet.h>
Martin v. Löwis95c419b2003-05-03 12:10:48 +00002702], void* p = inet_aton;inet_aton(0,0),
Martin v. Löwise9416172003-05-03 10:12:45 +00002703 AC_DEFINE(HAVE_INET_ATON, 1, Define if you have the 'inet_aton' function.)
2704 AC_MSG_RESULT(yes),
2705 AC_MSG_RESULT(no)
2706)
2707
2708AC_MSG_CHECKING(for inet_pton)
2709AC_TRY_COMPILE([
2710#include "confdefs.h"
Martin v. Löwisf2e488d2003-05-05 22:00:11 +00002711#include <sys/types.h>
Martin v. Löwise9416172003-05-03 10:12:45 +00002712#include <sys/socket.h>
2713#include <netinet/in.h>
2714#include <arpa/inet.h>
2715], void* p = inet_pton,
2716 AC_DEFINE(HAVE_INET_PTON, 1, Define if you have the 'inet_pton' function.)
2717 AC_MSG_RESULT(yes),
2718 AC_MSG_RESULT(no)
2719)
2720
Martin v. Löwisd6640d42003-07-06 09:29:52 +00002721# On some systems, setgroups is in unistd.h, on others, in grp.h
Martin v. Löwisd5843682002-11-21 20:41:28 +00002722AC_MSG_CHECKING(for setgroups)
2723AC_TRY_COMPILE([
2724#include "confdefs.h"
Martin v. Löwisf2e488d2003-05-05 22:00:11 +00002725#include <unistd.h>
Martin v. Löwisd6640d42003-07-06 09:29:52 +00002726#ifdef HAVE_GRP_H
2727#include <grp.h>
2728#endif
Martin v. Löwisd5843682002-11-21 20:41:28 +00002729],
2730void* p = setgroups,
2731 AC_DEFINE(HAVE_SETGROUPS, 1, Define if you have the 'setgroups' function.)
2732 AC_MSG_RESULT(yes),
2733 AC_MSG_RESULT(no)
2734)
2735
Fred Drake8cef4cf2000-06-28 16:40:38 +00002736# check for openpty and forkpty
2737
Martin v. Löwisfd9a72a2006-01-08 10:07:33 +00002738AC_CHECK_FUNCS(openpty,,
2739 AC_CHECK_LIB(util,openpty,
2740 [AC_DEFINE(HAVE_OPENPTY) LIBS="$LIBS -lutil"],
2741 AC_CHECK_LIB(bsd,openpty, [AC_DEFINE(HAVE_OPENPTY) LIBS="$LIBS -lbsd"])
2742 )
2743)
2744AC_CHECK_FUNCS(forkpty,,
2745 AC_CHECK_LIB(util,forkpty,
2746 [AC_DEFINE(HAVE_FORKPTY) LIBS="$LIBS -lutil"],
2747 AC_CHECK_LIB(bsd,forkpty, [AC_DEFINE(HAVE_FORKPTY) LIBS="$LIBS -lbsd"])
2748 )
2749)
Fred Drake8cef4cf2000-06-28 16:40:38 +00002750
Christian Heimesb186d002008-03-18 15:15:01 +00002751# Stuff for expat.
2752AC_CHECK_FUNCS(memmove)
2753
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00002754# check for long file support functions
2755AC_CHECK_FUNCS(fseek64 fseeko fstatvfs ftell64 ftello statvfs)
2756
Christian Heimesb186d002008-03-18 15:15:01 +00002757AC_REPLACE_FUNCS(dup2 getcwd strdup)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002758AC_CHECK_FUNCS(getpgrp,
2759 AC_TRY_COMPILE([#include <unistd.h>],
2760 [getpgrp(0);],
2761 AC_DEFINE(GETPGRP_HAVE_ARG, 1,
2762 [Define if getpgrp() must be called as getpgrp(0).])
2763 )
2764)
Jack Jansen150753c2003-03-29 22:07:47 +00002765AC_CHECK_FUNCS(setpgrp,
2766 AC_TRY_COMPILE([#include <unistd.h>],
2767 [setpgrp(0,0);],
2768 AC_DEFINE(SETPGRP_HAVE_ARG, 1,
2769 [Define if setpgrp() must be called as setpgrp(0, 0).])
2770 )
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002771)
2772AC_CHECK_FUNCS(gettimeofday,
2773 AC_TRY_COMPILE([#include <sys/time.h>],
2774 [gettimeofday((struct timeval*)0,(struct timezone*)0);], ,
2775 AC_DEFINE(GETTIMEOFDAY_NO_TZ, 1,
2776 [Define if gettimeofday() does not have second (timezone) argument
2777 This is the case on Motorola V4 (R40V4.2)])
2778 )
2779)
Guido van Rossum627b2d71993-12-24 10:39:16 +00002780
Martin v. Löwisdbe3f762002-10-10 14:27:30 +00002781AC_MSG_CHECKING(for major, minor, and makedev)
Martin v. Löwise3271202002-11-07 07:42:30 +00002782AC_TRY_LINK([
Neal Norwitz6eb37f02003-02-23 23:28:15 +00002783#if defined(MAJOR_IN_MKDEV)
2784#include <sys/mkdev.h>
2785#elif defined(MAJOR_IN_SYSMACROS)
2786#include <sys/sysmacros.h>
2787#else
2788#include <sys/types.h>
2789#endif
Martin v. Löwisdbe3f762002-10-10 14:27:30 +00002790],[
2791 makedev(major(0),minor(0));
2792],[
2793 AC_DEFINE(HAVE_DEVICE_MACROS, 1,
2794 [Define to 1 if you have the device macros.])
2795 AC_MSG_RESULT(yes)
2796],[
2797 AC_MSG_RESULT(no)
2798])
Martin v. Löwis861a65b2001-10-24 14:36:00 +00002799
2800# On OSF/1 V5.1, getaddrinfo is available, but a define
2801# for [no]getaddrinfo in netdb.h.
2802AC_MSG_CHECKING(for getaddrinfo)
2803AC_TRY_LINK([
Martin v. Löwisc010b6d2001-11-09 17:50:52 +00002804#include <sys/types.h>
Martin v. Löwis861a65b2001-10-24 14:36:00 +00002805#include <sys/socket.h>
2806#include <netdb.h>
Martin v. Löwisc010b6d2001-11-09 17:50:52 +00002807#include <stdio.h>
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00002808], [getaddrinfo(NULL, NULL, NULL, NULL);],
2809have_getaddrinfo=yes,
2810have_getaddrinfo=no)
2811AC_MSG_RESULT($have_getaddrinfo)
2812if test $have_getaddrinfo = yes
2813then
2814 AC_MSG_CHECKING(getaddrinfo bug)
2815 AC_CACHE_VAL(ac_cv_buggy_getaddrinfo,
2816 AC_TRY_RUN([[
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00002817#include <sys/types.h>
2818#include <netdb.h>
2819#include <string.h>
2820#include <sys/socket.h>
2821#include <netinet/in.h>
2822
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00002823int main()
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00002824{
2825 int passive, gaierr, inet4 = 0, inet6 = 0;
2826 struct addrinfo hints, *ai, *aitop;
2827 char straddr[INET6_ADDRSTRLEN], strport[16];
2828
2829 for (passive = 0; passive <= 1; passive++) {
2830 memset(&hints, 0, sizeof(hints));
2831 hints.ai_family = AF_UNSPEC;
2832 hints.ai_flags = passive ? AI_PASSIVE : 0;
2833 hints.ai_socktype = SOCK_STREAM;
Hye-Shik Chang54f94392004-04-14 07:55:31 +00002834 hints.ai_protocol = IPPROTO_TCP;
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00002835 if ((gaierr = getaddrinfo(NULL, "54321", &hints, &aitop)) != 0) {
2836 (void)gai_strerror(gaierr);
2837 goto bad;
2838 }
2839 for (ai = aitop; ai; ai = ai->ai_next) {
2840 if (ai->ai_addr == NULL ||
2841 ai->ai_addrlen == 0 ||
2842 getnameinfo(ai->ai_addr, ai->ai_addrlen,
2843 straddr, sizeof(straddr), strport, sizeof(strport),
2844 NI_NUMERICHOST|NI_NUMERICSERV) != 0) {
2845 goto bad;
2846 }
2847 switch (ai->ai_family) {
2848 case AF_INET:
2849 if (strcmp(strport, "54321") != 0) {
2850 goto bad;
2851 }
2852 if (passive) {
2853 if (strcmp(straddr, "0.0.0.0") != 0) {
2854 goto bad;
2855 }
2856 } else {
2857 if (strcmp(straddr, "127.0.0.1") != 0) {
2858 goto bad;
2859 }
2860 }
2861 inet4++;
2862 break;
2863 case AF_INET6:
2864 if (strcmp(strport, "54321") != 0) {
2865 goto bad;
2866 }
2867 if (passive) {
2868 if (strcmp(straddr, "::") != 0) {
2869 goto bad;
2870 }
2871 } else {
2872 if (strcmp(straddr, "::1") != 0) {
2873 goto bad;
2874 }
2875 }
2876 inet6++;
2877 break;
2878 case AF_UNSPEC:
2879 goto bad;
2880 break;
2881 default:
2882 /* another family support? */
2883 break;
2884 }
2885 }
2886 }
2887
2888 if (!(inet4 == 0 || inet4 == 2))
2889 goto bad;
2890 if (!(inet6 == 0 || inet6 == 2))
2891 goto bad;
2892
2893 if (aitop)
2894 freeaddrinfo(aitop);
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00002895 return 0;
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00002896
2897 bad:
2898 if (aitop)
2899 freeaddrinfo(aitop);
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00002900 return 1;
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00002901}
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00002902]], ac_cv_buggy_getaddrinfo=no,
2903 ac_cv_buggy_getaddrinfo=yes,
2904 ac_cv_buggy_getaddrinfo=yes))
2905fi
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00002906
Mark Dickinson2df5d282009-12-31 21:22:50 +00002907if test $have_getaddrinfo = no -o "$ac_cv_buggy_getaddrinfo" = yes
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00002908then
2909 if test $ipv6 = yes
2910 then
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00002911 echo 'Fatal: You must get working getaddrinfo() function.'
2912 echo ' or you can specify "--disable-ipv6"'.
2913 exit 1
2914 fi
Martin v. Löwis861a65b2001-10-24 14:36:00 +00002915else
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002916 AC_DEFINE(HAVE_GETADDRINFO, 1, [Define if you have the getaddrinfo function.])
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00002917fi
Thomas Woutersb0db85a2001-08-08 10:39:03 +00002918AC_CHECK_FUNCS(getnameinfo)
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00002919
Guido van Rossum627b2d71993-12-24 10:39:16 +00002920# checks for structures
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002921AC_HEADER_TIME
Guido van Rossum627b2d71993-12-24 10:39:16 +00002922AC_STRUCT_TM
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002923AC_STRUCT_TIMEZONE
Martin v. Löwis60a5d722002-10-16 20:28:25 +00002924AC_CHECK_MEMBERS([struct stat.st_rdev])
2925AC_CHECK_MEMBERS([struct stat.st_blksize])
Hye-Shik Chang5f937a72005-06-02 13:09:30 +00002926AC_CHECK_MEMBERS([struct stat.st_flags])
Martin v. Löwisebd9d5b2005-08-09 15:00:59 +00002927AC_CHECK_MEMBERS([struct stat.st_gen])
2928AC_CHECK_MEMBERS([struct stat.st_birthtime])
Guido van Rossum98bf58f2001-10-18 20:34:25 +00002929AC_STRUCT_ST_BLOCKS
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002930
2931AC_MSG_CHECKING(for time.h that defines altzone)
2932AC_CACHE_VAL(ac_cv_header_time_altzone,
2933[AC_TRY_COMPILE([#include <time.h>], [return altzone;],
2934 ac_cv_header_time_altzone=yes,
2935 ac_cv_header_time_altzone=no)])
2936AC_MSG_RESULT($ac_cv_header_time_altzone)
2937if test $ac_cv_header_time_altzone = yes; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002938 AC_DEFINE(HAVE_ALTZONE, 1, [Define this if your time.h defines altzone.])
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002939fi
2940
Guido van Rossum5739e7e1995-01-20 16:50:53 +00002941was_it_defined=no
2942AC_MSG_CHECKING(whether sys/select.h and sys/time.h may both be included)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002943AC_TRY_COMPILE([
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002944#include <sys/types.h>
2945#include <sys/select.h>
2946#include <sys/time.h>
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002947], [;], [
2948 AC_DEFINE(SYS_SELECT_WITH_SYS_TIME, 1,
2949 [Define if you can safely include both <sys/select.h> and <sys/time.h>
2950 (which you can't on SCO ODT 3.0).])
2951 was_it_defined=yes
2952])
Guido van Rossum5739e7e1995-01-20 16:50:53 +00002953AC_MSG_RESULT($was_it_defined)
Guido van Rossum627b2d71993-12-24 10:39:16 +00002954
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00002955AC_MSG_CHECKING(for addrinfo)
2956AC_CACHE_VAL(ac_cv_struct_addrinfo,
2957AC_TRY_COMPILE([
2958# include <netdb.h>],
2959 [struct addrinfo a],
2960 ac_cv_struct_addrinfo=yes,
2961 ac_cv_struct_addrinfo=no))
2962AC_MSG_RESULT($ac_cv_struct_addrinfo)
2963if test $ac_cv_struct_addrinfo = yes; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002964 AC_DEFINE(HAVE_ADDRINFO, 1, [struct addrinfo (netdb.h)])
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00002965fi
2966
2967AC_MSG_CHECKING(for sockaddr_storage)
2968AC_CACHE_VAL(ac_cv_struct_sockaddr_storage,
2969AC_TRY_COMPILE([
2970# include <sys/types.h>
2971# include <sys/socket.h>],
2972 [struct sockaddr_storage s],
2973 ac_cv_struct_sockaddr_storage=yes,
2974 ac_cv_struct_sockaddr_storage=no))
2975AC_MSG_RESULT($ac_cv_struct_sockaddr_storage)
2976if test $ac_cv_struct_sockaddr_storage = yes; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002977 AC_DEFINE(HAVE_SOCKADDR_STORAGE, 1, [struct sockaddr_storage (sys/socket.h)])
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00002978fi
2979
Guido van Rossum627b2d71993-12-24 10:39:16 +00002980# checks for compiler characteristics
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002981
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002982AC_C_CHAR_UNSIGNED
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002983AC_C_CONST
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002984
Guido van Rossum5739e7e1995-01-20 16:50:53 +00002985works=no
2986AC_MSG_CHECKING(for working volatile)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002987AC_TRY_COMPILE([],[volatile int x; x = 0;], works=yes,
2988 AC_DEFINE(volatile, [], [Define to empty if the keyword does not work.])
2989)
Guido van Rossum5739e7e1995-01-20 16:50:53 +00002990AC_MSG_RESULT($works)
Guido van Rossumdabb11b1994-10-11 15:04:27 +00002991
Guido van Rossum5739e7e1995-01-20 16:50:53 +00002992works=no
2993AC_MSG_CHECKING(for working signed char)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002994AC_TRY_COMPILE([], [signed char c;], works=yes,
2995 AC_DEFINE(signed, [], [Define to empty if the keyword does not work.])
2996)
Guido van Rossum5739e7e1995-01-20 16:50:53 +00002997AC_MSG_RESULT($works)
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002998
Guido van Rossum5739e7e1995-01-20 16:50:53 +00002999have_prototypes=no
3000AC_MSG_CHECKING(for prototypes)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003001AC_TRY_COMPILE([int foo(int x) { return 0; }], [return foo(10);],[
3002 AC_DEFINE(HAVE_PROTOTYPES, 1,
3003 [Define if your compiler supports function prototype])
3004 have_prototypes=yes
3005])
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003006AC_MSG_RESULT($have_prototypes)
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003007
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003008works=no
3009AC_MSG_CHECKING(for variable length prototypes and stdarg.h)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003010AC_TRY_COMPILE([
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003011#include <stdarg.h>
Guido van Rossum3f13e481996-08-30 20:58:11 +00003012int foo(int x, ...) {
3013 va_list va;
3014 va_start(va, x);
3015 va_arg(va, int);
3016 va_arg(va, char *);
3017 va_arg(va, double);
3018 return 0;
3019}
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003020], [return foo(10, "", 3.14);], [
3021 AC_DEFINE(HAVE_STDARG_PROTOTYPES, 1,
3022 [Define if your compiler supports variable length function prototypes
3023 (e.g. void fprintf(FILE *, char *, ...);) *and* <stdarg.h>])
3024 works=yes
3025])
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003026AC_MSG_RESULT($works)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003027
Dave Cole331708b2004-08-09 04:51:41 +00003028# check for socketpair
3029AC_MSG_CHECKING(for socketpair)
3030AC_TRY_COMPILE([
3031#include <sys/types.h>
3032#include <sys/socket.h>
3033], void *x=socketpair,
3034 AC_DEFINE(HAVE_SOCKETPAIR, 1, Define if you have the 'socketpair' function.)
3035 AC_MSG_RESULT(yes),
3036 AC_MSG_RESULT(no)
3037)
3038
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003039# check if sockaddr has sa_len member
3040AC_MSG_CHECKING(if sockaddr has sa_len member)
3041AC_TRY_COMPILE([#include <sys/types.h>
3042#include <sys/socket.h>],
3043[struct sockaddr x;
3044x.sa_len = 0;],
3045 AC_MSG_RESULT(yes)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003046 AC_DEFINE(HAVE_SOCKADDR_SA_LEN, 1, [Define if sockaddr has sa_len member]),
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003047 AC_MSG_RESULT(no))
3048
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003049va_list_is_array=no
3050AC_MSG_CHECKING(whether va_list is an array)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003051AC_TRY_COMPILE([
3052#ifdef HAVE_STDARG_PROTOTYPES
3053#include <stdarg.h>
3054#else
3055#include <varargs.h>
3056#endif
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003057], [va_list list1, list2; list1 = list2;], , [
3058 AC_DEFINE(VA_LIST_IS_ARRAY, 1, [Define if a va_list is an array of some kind])
3059 va_list_is_array=yes
3060])
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003061AC_MSG_RESULT($va_list_is_array)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003062
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003063# sigh -- gethostbyname_r is a mess; it can have 3, 5 or 6 arguments :-(
Martin v. Löwis11437992002-04-12 09:54:03 +00003064AH_TEMPLATE(HAVE_GETHOSTBYNAME_R,
3065 [Define this if you have some version of gethostbyname_r()])
3066
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003067AC_CHECK_FUNC(gethostbyname_r, [
3068 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
3069 AC_MSG_CHECKING([gethostbyname_r with 6 args])
3070 OLD_CFLAGS=$CFLAGS
3071 CFLAGS="$CFLAGS $MY_CPPFLAGS $MY_THREAD_CPPFLAGS $MY_CFLAGS"
3072 AC_TRY_COMPILE([
3073# include <netdb.h>
3074 ], [
3075 char *name;
3076 struct hostent *he, *res;
3077 char buffer[2048];
3078 int buflen = 2048;
3079 int h_errnop;
3080
3081 (void) gethostbyname_r(name, he, buffer, buflen, &res, &h_errnop)
3082 ], [
Guido van Rossum8db7d8b1999-03-23 16:40:33 +00003083 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003084 AC_DEFINE(HAVE_GETHOSTBYNAME_R_6_ARG, 1,
3085 [Define this if you have the 6-arg version of gethostbyname_r().])
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003086 AC_MSG_RESULT(yes)
3087 ], [
3088 AC_MSG_RESULT(no)
3089 AC_MSG_CHECKING([gethostbyname_r with 5 args])
3090 AC_TRY_COMPILE([
3091# include <netdb.h>
3092 ], [
3093 char *name;
3094 struct hostent *he;
3095 char buffer[2048];
3096 int buflen = 2048;
3097 int h_errnop;
3098
3099 (void) gethostbyname_r(name, he, buffer, buflen, &h_errnop)
3100 ], [
Guido van Rossum8db7d8b1999-03-23 16:40:33 +00003101 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003102 AC_DEFINE(HAVE_GETHOSTBYNAME_R_5_ARG, 1,
3103 [Define this if you have the 5-arg version of gethostbyname_r().])
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003104 AC_MSG_RESULT(yes)
3105 ], [
3106 AC_MSG_RESULT(no)
3107 AC_MSG_CHECKING([gethostbyname_r with 3 args])
3108 AC_TRY_COMPILE([
3109# include <netdb.h>
3110 ], [
3111 char *name;
3112 struct hostent *he;
3113 struct hostent_data data;
3114
3115 (void) gethostbyname_r(name, he, &data);
3116 ], [
Guido van Rossum8db7d8b1999-03-23 16:40:33 +00003117 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003118 AC_DEFINE(HAVE_GETHOSTBYNAME_R_3_ARG, 1,
3119 [Define this if you have the 3-arg version of gethostbyname_r().])
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003120 AC_MSG_RESULT(yes)
3121 ], [
3122 AC_MSG_RESULT(no)
3123 ])
3124 ])
3125 ])
3126 CFLAGS=$OLD_CFLAGS
3127], [
Thomas Wouters3a584202000-08-05 23:28:51 +00003128 AC_CHECK_FUNCS(gethostbyname)
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003129])
3130AC_SUBST(HAVE_GETHOSTBYNAME_R_6_ARG)
3131AC_SUBST(HAVE_GETHOSTBYNAME_R_5_ARG)
3132AC_SUBST(HAVE_GETHOSTBYNAME_R_3_ARG)
Guido van Rossum8db7d8b1999-03-23 16:40:33 +00003133AC_SUBST(HAVE_GETHOSTBYNAME_R)
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003134AC_SUBST(HAVE_GETHOSTBYNAME)
3135
Guido van Rossum627b2d71993-12-24 10:39:16 +00003136# checks for system services
3137# (none yet)
3138
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003139# Linux requires this for correct f.p. operations
Jeremy Hyltonbe28f5b2000-07-27 21:03:04 +00003140AC_CHECK_FUNC(__fpu_control,
3141 [],
3142 [AC_CHECK_LIB(ieee, __fpu_control)
3143])
Guido van Rossum627b2d71993-12-24 10:39:16 +00003144
Guido van Rossum93274221997-05-09 02:42:00 +00003145# Check for --with-fpectl
Guido van Rossum93274221997-05-09 02:42:00 +00003146AC_MSG_CHECKING(for --with-fpectl)
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00003147AC_ARG_WITH(fpectl,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003148 AC_HELP_STRING(--with-fpectl, enable SIGFPE catching),
3149[
Guido van Rossum93274221997-05-09 02:42:00 +00003150if test "$withval" != no
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003151then
3152 AC_DEFINE(WANT_SIGFPE_HANDLER, 1,
3153 [Define if you want SIGFPE handled (see Include/pyfpe.h).])
3154 AC_MSG_RESULT(yes)
Guido van Rossum93274221997-05-09 02:42:00 +00003155else AC_MSG_RESULT(no)
Guido van Rossumef2255b2000-03-10 22:30:29 +00003156fi],
3157[AC_MSG_RESULT(no)])
Guido van Rossum93274221997-05-09 02:42:00 +00003158
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003159# check for --with-libm=...
3160AC_SUBST(LIBM)
Guido van Rossum4b6b5791996-09-09 20:09:34 +00003161case $ac_sys_system in
Guido van Rossum3dc0a512000-10-05 18:00:06 +00003162Darwin) ;;
Guido van Rossum4b6b5791996-09-09 20:09:34 +00003163*) LIBM=-lm
3164esac
Guido van Rossum93274221997-05-09 02:42:00 +00003165AC_MSG_CHECKING(for --with-libm=STRING)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003166AC_ARG_WITH(libm,
3167 AC_HELP_STRING(--with-libm=STRING, math library),
3168[
Guido van Rossum93274221997-05-09 02:42:00 +00003169if test "$withval" = no
3170then LIBM=
3171 AC_MSG_RESULT(force LIBM empty)
3172elif test "$withval" != yes
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003173then LIBM=$withval
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003174 AC_MSG_RESULT(set LIBM="$withval")
3175else AC_MSG_ERROR([proper usage is --with-libm=STRING])
Guido van Rossum93274221997-05-09 02:42:00 +00003176fi],
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003177[AC_MSG_RESULT(default LIBM="$LIBM")])
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003178
3179# check for --with-libc=...
3180AC_SUBST(LIBC)
Guido van Rossum93274221997-05-09 02:42:00 +00003181AC_MSG_CHECKING(for --with-libc=STRING)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003182AC_ARG_WITH(libc,
3183 AC_HELP_STRING(--with-libc=STRING, C library),
3184[
Guido van Rossum93274221997-05-09 02:42:00 +00003185if test "$withval" = no
3186then LIBC=
3187 AC_MSG_RESULT(force LIBC empty)
3188elif test "$withval" != yes
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003189then LIBC=$withval
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003190 AC_MSG_RESULT(set LIBC="$withval")
3191else AC_MSG_ERROR([proper usage is --with-libc=STRING])
Guido van Rossum93274221997-05-09 02:42:00 +00003192fi],
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003193[AC_MSG_RESULT(default LIBC="$LIBC")])
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003194
Mark Dickinsonb08a53a2009-04-16 19:52:09 +00003195# **************************************************
3196# * Check for various properties of floating point *
3197# **************************************************
Christian Heimes81ee3ef2008-05-04 22:42:01 +00003198
Mark Dickinsonb08a53a2009-04-16 19:52:09 +00003199AC_MSG_CHECKING(whether C doubles are little-endian IEEE 754 binary64)
3200AC_CACHE_VAL(ac_cv_little_endian_double, [
3201AC_TRY_RUN([
3202#include <string.h>
3203int main() {
3204 double x = 9006104071832581.0;
3205 if (memcmp(&x, "\x05\x04\x03\x02\x01\xff\x3f\x43", 8) == 0)
3206 return 0;
3207 else
3208 return 1;
3209}
3210],
3211ac_cv_little_endian_double=yes,
3212ac_cv_little_endian_double=no,
3213ac_cv_little_endian_double=no)])
3214AC_MSG_RESULT($ac_cv_little_endian_double)
3215if test "$ac_cv_little_endian_double" = yes
3216then
3217 AC_DEFINE(DOUBLE_IS_LITTLE_ENDIAN_IEEE754, 1,
3218 [Define if C doubles are 64-bit IEEE 754 binary format, stored
3219 with the least significant byte first])
3220fi
3221
3222AC_MSG_CHECKING(whether C doubles are big-endian IEEE 754 binary64)
3223AC_CACHE_VAL(ac_cv_big_endian_double, [
3224AC_TRY_RUN([
3225#include <string.h>
3226int main() {
3227 double x = 9006104071832581.0;
3228 if (memcmp(&x, "\x43\x3f\xff\x01\x02\x03\x04\x05", 8) == 0)
3229 return 0;
3230 else
3231 return 1;
3232}
3233],
3234ac_cv_big_endian_double=yes,
3235ac_cv_big_endian_double=no,
3236ac_cv_big_endian_double=no)])
3237AC_MSG_RESULT($ac_cv_big_endian_double)
3238if test "$ac_cv_big_endian_double" = yes
3239then
3240 AC_DEFINE(DOUBLE_IS_BIG_ENDIAN_IEEE754, 1,
3241 [Define if C doubles are 64-bit IEEE 754 binary format, stored
3242 with the most significant byte first])
3243fi
3244
3245# Some ARM platforms use a mixed-endian representation for doubles.
3246# While Python doesn't currently have full support for these platforms
3247# (see e.g., issue 1762561), we can at least make sure that float <-> string
3248# conversions work.
3249AC_MSG_CHECKING(whether C doubles are ARM mixed-endian IEEE 754 binary64)
3250AC_CACHE_VAL(ac_cv_mixed_endian_double, [
3251AC_TRY_RUN([
3252#include <string.h>
3253int main() {
3254 double x = 9006104071832581.0;
3255 if (memcmp(&x, "\x01\xff\x3f\x43\x05\x04\x03\x02", 8) == 0)
3256 return 0;
3257 else
3258 return 1;
3259}
3260],
3261ac_cv_mixed_endian_double=yes,
3262ac_cv_mixed_endian_double=no,
3263ac_cv_mixed_endian_double=no)])
3264AC_MSG_RESULT($ac_cv_mixed_endian_double)
3265if test "$ac_cv_mixed_endian_double" = yes
3266then
3267 AC_DEFINE(DOUBLE_IS_ARM_MIXED_ENDIAN_IEEE754, 1,
3268 [Define if C doubles are 64-bit IEEE 754 binary format, stored
3269 in ARM mixed-endian order (byte order 45670123)])
3270fi
3271
Mark Dickinson7abf8d42009-04-18 20:17:52 +00003272# The short float repr introduced in Python 3.1 requires the
3273# correctly-rounded string <-> double conversion functions from
3274# Python/dtoa.c, which in turn require that the FPU uses 53-bit
3275# rounding; this is a problem on x86, where the x87 FPU has a default
Mark Dickinsonf4243f62009-11-15 13:47:27 +00003276# rounding precision of 64 bits. For gcc/x86, we can fix this by
Mark Dickinson7abf8d42009-04-18 20:17:52 +00003277# using inline assembler to get and set the x87 FPU control word.
Mark Dickinsonf4243f62009-11-15 13:47:27 +00003278
3279# This inline assembler syntax may also work for suncc and icc,
3280# so we try it on all platforms.
3281
3282AC_MSG_CHECKING(whether we can use gcc inline assembler to get and set x87 control word)
3283AC_TRY_COMPILE([], [
3284 unsigned short cw;
3285 __asm__ __volatile__ ("fnstcw %0" : "=m" (cw));
3286 __asm__ __volatile__ ("fldcw %0" : : "m" (cw));
3287],
3288[have_gcc_asm_for_x87=yes], [have_gcc_asm_for_x87=no])
3289AC_MSG_RESULT($have_gcc_asm_for_x87)
3290if test "$have_gcc_asm_for_x87" = yes
Mark Dickinsonb08a53a2009-04-16 19:52:09 +00003291then
Mark Dickinsonf4243f62009-11-15 13:47:27 +00003292 AC_DEFINE(HAVE_GCC_ASM_FOR_X87, 1,
3293 [Define if we can use gcc inline assembler to get and set x87 control word])
Mark Dickinsonb08a53a2009-04-16 19:52:09 +00003294fi
Christian Heimes81ee3ef2008-05-04 22:42:01 +00003295
Mark Dickinson3dc7c6a2009-01-04 15:09:02 +00003296# Detect whether system arithmetic is subject to x87-style double
3297# rounding issues. The result of this test has little meaning on non
3298# IEEE 754 platforms. On IEEE 754, test should return 1 if rounding
3299# mode is round-to-nearest and double rounding issues are present, and
3300# 0 otherwise. See http://bugs.python.org/issue2937 for more info.
3301AC_MSG_CHECKING(for x87-style double rounding)
Mark Dickinsonb08a53a2009-04-16 19:52:09 +00003302# $BASECFLAGS may affect the result
3303ac_save_cc="$CC"
3304CC="$CC $BASECFLAGS"
Mark Dickinson3dc7c6a2009-01-04 15:09:02 +00003305AC_TRY_RUN([
3306#include <stdlib.h>
3307#include <math.h>
3308int main() {
3309 volatile double x, y, z;
3310 /* 1./(1-2**-53) -> 1+2**-52 (correct), 1.0 (double rounding) */
3311 x = 0.99999999999999989; /* 1-2**-53 */
3312 y = 1./x;
3313 if (y != 1.)
3314 exit(0);
3315 /* 1e16+2.99999 -> 1e16+2. (correct), 1e16+4. (double rounding) */
3316 x = 1e16;
3317 y = 2.99999;
3318 z = x + y;
3319 if (z != 1e16+4.)
3320 exit(0);
3321 /* both tests show evidence of double rounding */
3322 exit(1);
3323}
3324],
3325ac_cv_x87_double_rounding=no,
3326ac_cv_x87_double_rounding=yes,
Mark Dickinsonb08a53a2009-04-16 19:52:09 +00003327ac_cv_x87_double_rounding=no)
3328CC="$ac_save_cc"
Mark Dickinson3dc7c6a2009-01-04 15:09:02 +00003329AC_MSG_RESULT($ac_cv_x87_double_rounding)
3330if test "$ac_cv_x87_double_rounding" = yes
3331then
3332 AC_DEFINE(X87_DOUBLE_ROUNDING, 1,
3333 [Define if arithmetic is subject to x87-style double rounding issue])
3334fi
3335
Mark Dickinsonb08a53a2009-04-16 19:52:09 +00003336# ************************************
3337# * Check for mathematical functions *
3338# ************************************
3339
3340LIBS_SAVE=$LIBS
3341LIBS="$LIBS $LIBM"
3342
Christian Heimes81ee3ef2008-05-04 22:42:01 +00003343# On FreeBSD 6.2, it appears that tanh(-0.) returns 0. instead of
3344# -0. on some architectures.
3345AC_MSG_CHECKING(whether tanh preserves the sign of zero)
3346AC_CACHE_VAL(ac_cv_tanh_preserves_zero_sign, [
3347AC_TRY_RUN([
3348#include <math.h>
3349#include <stdlib.h>
3350int main() {
3351 /* return 0 if either negative zeros don't exist
3352 on this platform or if negative zeros exist
3353 and tanh(-0.) == -0. */
3354 if (atan2(0., -1.) == atan2(-0., -1.) ||
3355 atan2(tanh(-0.), -1.) == atan2(-0., -1.)) exit(0);
3356 else exit(1);
3357}
3358],
3359ac_cv_tanh_preserves_zero_sign=yes,
3360ac_cv_tanh_preserves_zero_sign=no,
3361ac_cv_tanh_preserves_zero_sign=no)])
3362AC_MSG_RESULT($ac_cv_tanh_preserves_zero_sign)
3363if test "$ac_cv_tanh_preserves_zero_sign" = yes
3364then
3365 AC_DEFINE(TANH_PRESERVES_ZERO_SIGN, 1,
3366 [Define if tanh(-0.) is -0., or if platform doesn't have signed zeros])
3367fi
3368
Mark Dickinson9c113362009-09-05 10:36:23 +00003369AC_CHECK_FUNCS([acosh asinh atanh copysign erf erfc expm1 finite gamma])
3370AC_CHECK_FUNCS([hypot lgamma log1p round tgamma])
Mark Dickinson3dc7c6a2009-01-04 15:09:02 +00003371AC_CHECK_DECLS([isinf, isnan, isfinite], [], [], [[#include <math.h>]])
Christian Heimes99170a52007-12-19 02:07:34 +00003372
Guido van Rossumaf5b83e1995-01-04 19:02:35 +00003373LIBS=$LIBS_SAVE
3374
Mark Dickinsona614f042009-11-28 12:48:43 +00003375# For multiprocessing module, check that sem_open
3376# actually works. For FreeBSD versions <= 7.2,
3377# the kernel module that provides POSIX semaphores
3378# isn't loaded by default, so an attempt to call
3379# sem_open results in a 'Signal 12' error.
3380AC_MSG_CHECKING(whether POSIX semaphores are enabled)
3381AC_CACHE_VAL(ac_cv_posix_semaphores_enabled,
3382AC_TRY_RUN([
3383#include <unistd.h>
3384#include <fcntl.h>
3385#include <stdio.h>
3386#include <semaphore.h>
3387#include <sys/stat.h>
3388
3389int main(void) {
3390 sem_t *a = sem_open("/autoconf", O_CREAT, S_IRUSR|S_IWUSR, 0);
3391 if (a == SEM_FAILED) {
3392 perror("sem_open");
3393 return 1;
3394 }
3395 sem_close(a);
Mark Dickinsonba79b352009-12-13 21:10:57 +00003396 sem_unlink("/autoconf");
Mark Dickinsona614f042009-11-28 12:48:43 +00003397 return 0;
3398}
3399], ac_cv_posix_semaphores_enabled=yes,
3400 ac_cv_posix_semaphores_enabled=no,
3401 ac_cv_posix_semaphores_enabled=yes)
3402)
3403AC_MSG_RESULT($ac_cv_posix_semaphores_enabled)
3404if test $ac_cv_posix_semaphores_enabled = no
3405then
3406 AC_DEFINE(POSIX_SEMAPHORES_NOT_ENABLED, 1,
3407 [Define if POSIX semaphores aren't enabled on your system])
3408fi
3409
Mark Dickinson10683072009-04-18 21:18:19 +00003410# Multiprocessing check for broken sem_getvalue
3411AC_MSG_CHECKING(for broken sem_getvalue)
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00003412AC_CACHE_VAL(ac_cv_broken_sem_getvalue,
Mark Dickinson10683072009-04-18 21:18:19 +00003413AC_TRY_RUN([
3414#include <unistd.h>
3415#include <fcntl.h>
3416#include <stdio.h>
3417#include <semaphore.h>
3418#include <sys/stat.h>
3419
3420int main(void){
Mark Dickinsonba79b352009-12-13 21:10:57 +00003421 sem_t *a = sem_open("/autocftw", O_CREAT, S_IRUSR|S_IWUSR, 0);
Mark Dickinson10683072009-04-18 21:18:19 +00003422 int count;
3423 int res;
3424 if(a==SEM_FAILED){
3425 perror("sem_open");
3426 return 1;
3427
3428 }
3429 res = sem_getvalue(a, &count);
3430 sem_close(a);
Mark Dickinsonba79b352009-12-13 21:10:57 +00003431 sem_unlink("/autocftw");
Mark Dickinson10683072009-04-18 21:18:19 +00003432 return res==-1 ? 1 : 0;
3433}
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00003434], ac_cv_broken_sem_getvalue=no,
3435 ac_cv_broken_sem_getvalue=yes,
3436 ac_cv_broken_sem_getvalue=yes)
Mark Dickinson10683072009-04-18 21:18:19 +00003437)
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00003438AC_MSG_RESULT($ac_cv_broken_sem_getvalue)
3439if test $ac_cv_broken_sem_getvalue = yes
3440then
3441 AC_DEFINE(HAVE_BROKEN_SEM_GETVALUE, 1,
3442 [define to 1 if your sem_getvalue is broken.])
3443fi
Mark Dickinson10683072009-04-18 21:18:19 +00003444
Mark Dickinsonbd792642009-03-18 20:06:12 +00003445# determine what size digit to use for Python's longs
3446AC_MSG_CHECKING([digit size for Python's longs])
3447AC_ARG_ENABLE(big-digits,
3448AC_HELP_STRING([--enable-big-digits@<:@=BITS@:>@],[use big digits for Python longs [[BITS=30]]]),
3449[case $enable_big_digits in
3450yes)
3451 enable_big_digits=30 ;;
3452no)
3453 enable_big_digits=15 ;;
3454[15|30])
3455 ;;
3456*)
3457 AC_MSG_ERROR([bad value $enable_big_digits for --enable-big-digits; value should be 15 or 30]) ;;
3458esac
3459AC_MSG_RESULT($enable_big_digits)
3460AC_DEFINE_UNQUOTED(PYLONG_BITS_IN_DIGIT, $enable_big_digits, [Define as the preferred size in bits of long digits])
3461],
3462[AC_MSG_RESULT(no value specified)])
3463
Guido van Rossumef2255b2000-03-10 22:30:29 +00003464# check for wchar.h
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003465AC_CHECK_HEADER(wchar.h, [
3466 AC_DEFINE(HAVE_WCHAR_H, 1,
3467 [Define if the compiler provides a wchar.h header file.])
3468 wchar_h="yes"
3469],
Guido van Rossumef2255b2000-03-10 22:30:29 +00003470wchar_h="no"
3471)
3472
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003473# determine wchar_t size
3474if test "$wchar_h" = yes
3475then
Guido van Rossum67b26592001-10-20 14:21:45 +00003476 AC_CHECK_SIZEOF(wchar_t, 4, [#include <wchar.h>])
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003477fi
3478
Martin v. Löwisfa3bdea2003-09-04 18:50:54 +00003479AC_MSG_CHECKING(for UCS-4 tcl)
3480have_ucs4_tcl=no
3481AC_TRY_COMPILE([
3482#include <tcl.h>
3483#if TCL_UTF_MAX != 6
3484# error "NOT UCS4_TCL"
3485#endif], [], [
3486 AC_DEFINE(HAVE_UCS4_TCL, 1, [Define this if you have tcl and TCL_UTF_MAX==6])
3487 have_ucs4_tcl=yes
3488])
3489AC_MSG_RESULT($have_ucs4_tcl)
3490
Marc-André Lemburgd7160f82003-09-22 11:14:40 +00003491# check whether wchar_t is signed or not
3492if test "$wchar_h" = yes
3493then
3494 # check whether wchar_t is signed or not
3495 AC_MSG_CHECKING(whether wchar_t is signed)
3496 AC_CACHE_VAL(ac_cv_wchar_t_signed, [
3497 AC_TRY_RUN([
3498 #include <wchar.h>
3499 int main()
3500 {
Thomas Wouters49fd7fa2006-04-21 10:40:58 +00003501 /* Success: exit code 0 */
3502 exit((((wchar_t) -1) < ((wchar_t) 0)) ? 0 : 1);
Marc-André Lemburgd7160f82003-09-22 11:14:40 +00003503 }
3504 ],
3505 ac_cv_wchar_t_signed=yes,
3506 ac_cv_wchar_t_signed=no,
3507 ac_cv_wchar_t_signed=yes)])
3508 AC_MSG_RESULT($ac_cv_wchar_t_signed)
3509fi
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003510
Georg Brandl52d168a2008-01-07 18:10:24 +00003511AC_MSG_CHECKING(what type to use for str)
3512AC_ARG_WITH(wide-unicode,
3513 AC_HELP_STRING(--with-wide-unicode, Use 4-byte Unicode characters (default is 2 bytes)),
3514[
3515if test "$withval" != no
3516then unicode_size="4"
3517else unicode_size="2"
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003518fi
Georg Brandl52d168a2008-01-07 18:10:24 +00003519],
3520[
3521case "$have_ucs4_tcl" in
3522 yes) unicode_size="4" ;;
3523 *) unicode_size="2" ;;
3524esac
3525])
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003526
Martin v. Löwis0036cba2002-04-12 09:58:45 +00003527AH_TEMPLATE(Py_UNICODE_SIZE,
3528 [Define as the size of the unicode type.])
Georg Brandl52d168a2008-01-07 18:10:24 +00003529case "$unicode_size" in
3530 4) AC_DEFINE(Py_UNICODE_SIZE, 4) ;;
3531 *) AC_DEFINE(Py_UNICODE_SIZE, 2) ;;
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003532esac
3533
Martin v. Löwis11437992002-04-12 09:54:03 +00003534AH_TEMPLATE(PY_UNICODE_TYPE,
3535 [Define as the integral type used for Unicode representation.])
Martin v. Löwis0036cba2002-04-12 09:58:45 +00003536
Georg Brandl52d168a2008-01-07 18:10:24 +00003537# wchar_t is only usable if it maps to an unsigned type
3538if test "$unicode_size" = "$ac_cv_sizeof_wchar_t" \
Matthias Klose7dbeed72004-12-24 08:22:17 +00003539 -a "$ac_cv_wchar_t_signed" = "no"
Georg Brandl52d168a2008-01-07 18:10:24 +00003540then
3541 PY_UNICODE_TYPE="wchar_t"
3542 AC_DEFINE(HAVE_USABLE_WCHAR_T, 1,
3543 [Define if you have a useable wchar_t type defined in wchar.h; useable
3544 means wchar_t must be an unsigned type with at least 16 bits. (see
3545 Include/unicodeobject.h).])
3546 AC_DEFINE(PY_UNICODE_TYPE,wchar_t)
3547elif test "$ac_cv_sizeof_short" = "$unicode_size"
3548then
3549 PY_UNICODE_TYPE="unsigned short"
3550 AC_DEFINE(PY_UNICODE_TYPE,unsigned short)
3551elif test "$ac_cv_sizeof_long" = "$unicode_size"
3552then
3553 PY_UNICODE_TYPE="unsigned long"
3554 AC_DEFINE(PY_UNICODE_TYPE,unsigned long)
3555else
3556 PY_UNICODE_TYPE="no type found"
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003557fi
Georg Brandl52d168a2008-01-07 18:10:24 +00003558AC_MSG_RESULT($PY_UNICODE_TYPE)
Guido van Rossumef2255b2000-03-10 22:30:29 +00003559
3560# check for endianness
3561AC_C_BIGENDIAN
3562
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00003563# Check whether right shifting a negative integer extends the sign bit
3564# or fills with zeros (like the Cray J90, according to Tim Peters).
3565AC_MSG_CHECKING(whether right shift extends the sign bit)
Vladimir Marangozova6180282000-07-12 05:05:06 +00003566AC_CACHE_VAL(ac_cv_rshift_extends_sign, [
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00003567AC_TRY_RUN([
3568int main()
3569{
Vladimir Marangozova6180282000-07-12 05:05:06 +00003570 exit(((-1)>>3 == -1) ? 0 : 1);
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00003571}
Guido van Rossum3065c942001-09-17 04:03:14 +00003572],
3573ac_cv_rshift_extends_sign=yes,
3574ac_cv_rshift_extends_sign=no,
3575ac_cv_rshift_extends_sign=yes)])
Vladimir Marangozova6180282000-07-12 05:05:06 +00003576AC_MSG_RESULT($ac_cv_rshift_extends_sign)
3577if test "$ac_cv_rshift_extends_sign" = no
3578then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003579 AC_DEFINE(SIGNED_RIGHT_SHIFT_ZERO_FILLS, 1,
3580 [Define if i>>j for signed int i does not extend the sign bit
3581 when i < 0])
Vladimir Marangozova6180282000-07-12 05:05:06 +00003582fi
3583
Guido van Rossumcadfaec2001-01-05 14:45:49 +00003584# check for getc_unlocked and related locking functions
3585AC_MSG_CHECKING(for getc_unlocked() and friends)
3586AC_CACHE_VAL(ac_cv_have_getc_unlocked, [
3587AC_TRY_LINK([#include <stdio.h>],[
3588 FILE *f = fopen("/dev/null", "r");
3589 flockfile(f);
3590 getc_unlocked(f);
3591 funlockfile(f);
3592], ac_cv_have_getc_unlocked=yes, ac_cv_have_getc_unlocked=no)])
3593AC_MSG_RESULT($ac_cv_have_getc_unlocked)
3594if test "$ac_cv_have_getc_unlocked" = yes
3595then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003596 AC_DEFINE(HAVE_GETC_UNLOCKED, 1,
3597 [Define this if you have flockfile(), getc_unlocked(), and funlockfile()])
Guido van Rossumcadfaec2001-01-05 14:45:49 +00003598fi
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00003599
Neal Norwitzfe8e3d92006-01-07 21:07:20 +00003600# check where readline lives
Martin v. Löwis82bca632006-02-10 20:49:30 +00003601# save the value of LIBS so we don't actually link Python with readline
3602LIBS_no_readline=$LIBS
Gregory P. Smith18820942008-09-07 06:24:49 +00003603
3604# On some systems we need to link readline to a termcap compatible
3605# library. NOTE: Keep the precedence of listed libraries synchronised
3606# with setup.py.
3607py_cv_lib_readline=no
3608AC_MSG_CHECKING([how to link readline libs])
3609for py_libtermcap in "" ncursesw ncurses curses termcap; do
3610 if test -z "$py_libtermcap"; then
3611 READLINE_LIBS="-lreadline"
3612 else
3613 READLINE_LIBS="-lreadline -l$py_libtermcap"
3614 fi
3615 LIBS="$READLINE_LIBS $LIBS_no_readline"
3616 AC_LINK_IFELSE(
3617 [AC_LANG_CALL([],[readline])],
3618 [py_cv_lib_readline=yes])
3619 if test $py_cv_lib_readline = yes; then
3620 break
3621 fi
3622done
3623# Uncomment this line if you want to use READINE_LIBS in Makefile or scripts
3624#AC_SUBST([READLINE_LIBS])
Gregory P. Smith97515912008-09-07 19:23:19 +00003625if test $py_cv_lib_readline = no; then
Gregory P. Smith18820942008-09-07 06:24:49 +00003626 AC_MSG_RESULT([none])
3627else
3628 AC_MSG_RESULT([$READLINE_LIBS])
3629 AC_DEFINE(HAVE_LIBREADLINE, 1,
3630 [Define if you have the readline library (-lreadline).])
Neal Norwitzfe8e3d92006-01-07 21:07:20 +00003631fi
3632
Michael W. Hudson30ea2f22004-07-07 17:44:12 +00003633# check for readline 2.1
3634AC_CHECK_LIB(readline, rl_callback_handler_install,
3635 AC_DEFINE(HAVE_RL_CALLBACK, 1,
Gregory P. Smith18820942008-09-07 06:24:49 +00003636 [Define if you have readline 2.1]), ,$READLINE_LIBS)
Michael W. Hudson30ea2f22004-07-07 17:44:12 +00003637
Guido van Rossumfaf5e4d2002-12-30 16:25:41 +00003638# check for readline 2.2
3639AC_TRY_CPP([#include <readline/readline.h>],
3640have_readline=yes, have_readline=no)
3641if test $have_readline = yes
3642then
3643 AC_EGREP_HEADER([extern int rl_completion_append_character;],
3644 [readline/readline.h],
3645 AC_DEFINE(HAVE_RL_COMPLETION_APPEND_CHARACTER, 1,
3646 [Define if you have readline 2.2]), )
Antoine Pitroud5131772009-10-26 19:22:14 +00003647 AC_EGREP_HEADER([extern int rl_completion_suppress_append;],
3648 [readline/readline.h],
3649 AC_DEFINE(HAVE_RL_COMPLETION_SUPPRESS_APPEND, 1,
3650 [Define if you have rl_completion_suppress_append]), )
Guido van Rossumfaf5e4d2002-12-30 16:25:41 +00003651fi
3652
Martin v. Löwis0daad592001-09-30 21:09:59 +00003653# check for readline 4.0
3654AC_CHECK_LIB(readline, rl_pre_input_hook,
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003655 AC_DEFINE(HAVE_RL_PRE_INPUT_HOOK, 1,
Gregory P. Smith18820942008-09-07 06:24:49 +00003656 [Define if you have readline 4.0]), ,$READLINE_LIBS)
Martin v. Löwis0daad592001-09-30 21:09:59 +00003657
Thomas Wouters89d996e2007-09-08 17:39:28 +00003658# also in 4.0
3659AC_CHECK_LIB(readline, rl_completion_display_matches_hook,
3660 AC_DEFINE(HAVE_RL_COMPLETION_DISPLAY_MATCHES_HOOK, 1,
Gregory P. Smith18820942008-09-07 06:24:49 +00003661 [Define if you have readline 4.0]), ,$READLINE_LIBS)
Thomas Wouters89d996e2007-09-08 17:39:28 +00003662
Guido van Rossum353ae582001-07-10 16:45:32 +00003663# check for readline 4.2
3664AC_CHECK_LIB(readline, rl_completion_matches,
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003665 AC_DEFINE(HAVE_RL_COMPLETION_MATCHES, 1,
Gregory P. Smith18820942008-09-07 06:24:49 +00003666 [Define if you have readline 4.2]), ,$READLINE_LIBS)
Guido van Rossum353ae582001-07-10 16:45:32 +00003667
Michael W. Hudson30ea2f22004-07-07 17:44:12 +00003668# also in readline 4.2
3669AC_TRY_CPP([#include <readline/readline.h>],
3670have_readline=yes, have_readline=no)
3671if test $have_readline = yes
3672then
3673 AC_EGREP_HEADER([extern int rl_catch_signals;],
3674 [readline/readline.h],
3675 AC_DEFINE(HAVE_RL_CATCH_SIGNAL, 1,
3676 [Define if you can turn off readline's signal handling.]), )
3677fi
3678
Martin v. Löwis82bca632006-02-10 20:49:30 +00003679# End of readline checks: restore LIBS
3680LIBS=$LIBS_no_readline
3681
Thomas Wouterse38b2f12001-07-11 22:35:31 +00003682AC_MSG_CHECKING(for broken nice())
3683AC_CACHE_VAL(ac_cv_broken_nice, [
3684AC_TRY_RUN([
3685int main()
3686{
3687 int val1 = nice(1);
3688 if (val1 != -1 && val1 == nice(2))
3689 exit(0);
3690 exit(1);
3691}
Guido van Rossum3065c942001-09-17 04:03:14 +00003692],
3693ac_cv_broken_nice=yes,
3694ac_cv_broken_nice=no,
3695ac_cv_broken_nice=no)])
Thomas Wouterse38b2f12001-07-11 22:35:31 +00003696AC_MSG_RESULT($ac_cv_broken_nice)
3697if test "$ac_cv_broken_nice" = yes
3698then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003699 AC_DEFINE(HAVE_BROKEN_NICE, 1,
3700 [Define if nice() returns success/failure instead of the new priority.])
Thomas Wouterse38b2f12001-07-11 22:35:31 +00003701fi
3702
Nicholas Bastine62c5c82004-03-21 23:45:42 +00003703AC_MSG_CHECKING(for broken poll())
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00003704AC_CACHE_VAL(ac_cv_broken_poll,
Nicholas Bastine62c5c82004-03-21 23:45:42 +00003705AC_TRY_RUN([
3706#include <poll.h>
3707
Alexandre Vassalottiaee170a2009-07-17 06:24:33 +00003708int main()
3709{
Nicholas Bastine62c5c82004-03-21 23:45:42 +00003710 struct pollfd poll_struct = { 42, POLLIN|POLLPRI|POLLOUT, 0 };
Alexandre Vassalottiaee170a2009-07-17 06:24:33 +00003711 int poll_test;
3712
Nicholas Bastine62c5c82004-03-21 23:45:42 +00003713 close (42);
3714
Alexandre Vassalottiaee170a2009-07-17 06:24:33 +00003715 poll_test = poll(&poll_struct, 1, 0);
Nicholas Bastine62c5c82004-03-21 23:45:42 +00003716 if (poll_test < 0)
Alexandre Vassalottiaee170a2009-07-17 06:24:33 +00003717 return 0;
Nicholas Bastine62c5c82004-03-21 23:45:42 +00003718 else if (poll_test == 0 && poll_struct.revents != POLLNVAL)
Alexandre Vassalottiaee170a2009-07-17 06:24:33 +00003719 return 0;
Nicholas Bastine62c5c82004-03-21 23:45:42 +00003720 else
Alexandre Vassalottiaee170a2009-07-17 06:24:33 +00003721 return 1;
3722}
Nicholas Bastine62c5c82004-03-21 23:45:42 +00003723],
3724ac_cv_broken_poll=yes,
3725ac_cv_broken_poll=no,
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00003726ac_cv_broken_poll=no))
Nicholas Bastine62c5c82004-03-21 23:45:42 +00003727AC_MSG_RESULT($ac_cv_broken_poll)
3728if test "$ac_cv_broken_poll" = yes
3729then
3730 AC_DEFINE(HAVE_BROKEN_POLL, 1,
3731 [Define if poll() sets errno on invalid file descriptors.])
3732fi
3733
Brett Cannon43802422005-02-10 20:48:03 +00003734# Before we can test tzset, we need to check if struct tm has a tm_zone
3735# (which is not required by ISO C or UNIX spec) and/or if we support
3736# tzname[]
3737AC_STRUCT_TIMEZONE
Nicholas Bastine62c5c82004-03-21 23:45:42 +00003738
Brett Cannon43802422005-02-10 20:48:03 +00003739# check tzset(3) exists and works like we expect it to
Guido van Rossumd11b62e2003-03-14 21:51:36 +00003740AC_MSG_CHECKING(for working tzset())
3741AC_CACHE_VAL(ac_cv_working_tzset, [
3742AC_TRY_RUN([
3743#include <stdlib.h>
3744#include <time.h>
Brett Cannon18367812003-09-19 00:59:16 +00003745#include <string.h>
Brett Cannon43802422005-02-10 20:48:03 +00003746
3747#if HAVE_TZNAME
3748extern char *tzname[];
3749#endif
3750
Guido van Rossumd11b62e2003-03-14 21:51:36 +00003751int main()
3752{
Brett Cannon18367812003-09-19 00:59:16 +00003753 /* Note that we need to ensure that not only does tzset(3)
3754 do 'something' with localtime, but it works as documented
3755 in the library reference and as expected by the test suite.
Brett Cannon43802422005-02-10 20:48:03 +00003756 This includes making sure that tzname is set properly if
3757 tm->tm_zone does not exist since it is the alternative way
3758 of getting timezone info.
Brett Cannon18367812003-09-19 00:59:16 +00003759
3760 Red Hat 6.2 doesn't understand the southern hemisphere
Brett Cannon43802422005-02-10 20:48:03 +00003761 after New Year's Day.
Brett Cannon18367812003-09-19 00:59:16 +00003762 */
3763
Brett Cannon43802422005-02-10 20:48:03 +00003764 time_t groundhogday = 1044144000; /* GMT-based */
Brett Cannon18367812003-09-19 00:59:16 +00003765 time_t midyear = groundhogday + (365 * 24 * 3600 / 2);
3766
Neal Norwitz7f2588c2003-04-11 15:35:53 +00003767 putenv("TZ=UTC+0");
Guido van Rossumd11b62e2003-03-14 21:51:36 +00003768 tzset();
Brett Cannon18367812003-09-19 00:59:16 +00003769 if (localtime(&groundhogday)->tm_hour != 0)
3770 exit(1);
Brett Cannon43802422005-02-10 20:48:03 +00003771#if HAVE_TZNAME
3772 /* For UTC, tzname[1] is sometimes "", sometimes " " */
3773 if (strcmp(tzname[0], "UTC") ||
3774 (tzname[1][0] != 0 && tzname[1][0] != ' '))
3775 exit(1);
3776#endif
Brett Cannon18367812003-09-19 00:59:16 +00003777
Neal Norwitz7f2588c2003-04-11 15:35:53 +00003778 putenv("TZ=EST+5EDT,M4.1.0,M10.5.0");
Guido van Rossumd11b62e2003-03-14 21:51:36 +00003779 tzset();
Brett Cannon18367812003-09-19 00:59:16 +00003780 if (localtime(&groundhogday)->tm_hour != 19)
Guido van Rossumd11b62e2003-03-14 21:51:36 +00003781 exit(1);
Brett Cannon43802422005-02-10 20:48:03 +00003782#if HAVE_TZNAME
3783 if (strcmp(tzname[0], "EST") || strcmp(tzname[1], "EDT"))
3784 exit(1);
3785#endif
Brett Cannon18367812003-09-19 00:59:16 +00003786
3787 putenv("TZ=AEST-10AEDT-11,M10.5.0,M3.5.0");
3788 tzset();
3789 if (localtime(&groundhogday)->tm_hour != 11)
3790 exit(1);
Brett Cannon43802422005-02-10 20:48:03 +00003791#if HAVE_TZNAME
3792 if (strcmp(tzname[0], "AEST") || strcmp(tzname[1], "AEDT"))
3793 exit(1);
3794#endif
3795
3796#if HAVE_STRUCT_TM_TM_ZONE
Brett Cannon18367812003-09-19 00:59:16 +00003797 if (strcmp(localtime(&groundhogday)->tm_zone, "AEDT"))
3798 exit(1);
3799 if (strcmp(localtime(&midyear)->tm_zone, "AEST"))
3800 exit(1);
Brett Cannon43802422005-02-10 20:48:03 +00003801#endif
Brett Cannon18367812003-09-19 00:59:16 +00003802
Guido van Rossumd11b62e2003-03-14 21:51:36 +00003803 exit(0);
3804}
3805],
3806ac_cv_working_tzset=yes,
3807ac_cv_working_tzset=no,
3808ac_cv_working_tzset=no)])
3809AC_MSG_RESULT($ac_cv_working_tzset)
3810if test "$ac_cv_working_tzset" = yes
3811then
3812 AC_DEFINE(HAVE_WORKING_TZSET, 1,
3813 [Define if tzset() actually switches the local timezone in a meaningful way.])
3814fi
3815
Martin v. Löwis94717ed2002-09-09 14:24:16 +00003816# Look for subsecond timestamps in struct stat
3817AC_MSG_CHECKING(for tv_nsec in struct stat)
3818AC_CACHE_VAL(ac_cv_stat_tv_nsec,
3819AC_TRY_COMPILE([#include <sys/stat.h>], [
3820struct stat st;
3821st.st_mtim.tv_nsec = 1;
3822],
Martin v. Löwisa32c9942002-09-09 16:17:47 +00003823ac_cv_stat_tv_nsec=yes,
Martin v. Löwis94717ed2002-09-09 14:24:16 +00003824ac_cv_stat_tv_nsec=no,
3825ac_cv_stat_tv_nsec=no))
3826AC_MSG_RESULT($ac_cv_stat_tv_nsec)
3827if test "$ac_cv_stat_tv_nsec" = yes
3828then
3829 AC_DEFINE(HAVE_STAT_TV_NSEC, 1,
3830 [Define if you have struct stat.st_mtim.tv_nsec])
3831fi
3832
Martin v. Löwisebd9d5b2005-08-09 15:00:59 +00003833# Look for BSD style subsecond timestamps in struct stat
3834AC_MSG_CHECKING(for tv_nsec2 in struct stat)
3835AC_CACHE_VAL(ac_cv_stat_tv_nsec2,
3836AC_TRY_COMPILE([#include <sys/stat.h>], [
3837struct stat st;
3838st.st_mtimespec.tv_nsec = 1;
3839],
3840ac_cv_stat_tv_nsec2=yes,
3841ac_cv_stat_tv_nsec2=no,
3842ac_cv_stat_tv_nsec2=no))
3843AC_MSG_RESULT($ac_cv_stat_tv_nsec2)
3844if test "$ac_cv_stat_tv_nsec2" = yes
3845then
3846 AC_DEFINE(HAVE_STAT_TV_NSEC2, 1,
3847 [Define if you have struct stat.st_mtimensec])
3848fi
3849
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00003850# On HP/UX 11.0, mvwdelch is a block with a return statement
3851AC_MSG_CHECKING(whether mvwdelch is an expression)
3852AC_CACHE_VAL(ac_cv_mvwdelch_is_expression,
3853AC_TRY_COMPILE([#include <curses.h>], [
3854 int rtn;
3855 rtn = mvwdelch(0,0,0);
3856], ac_cv_mvwdelch_is_expression=yes,
3857 ac_cv_mvwdelch_is_expression=no,
3858 ac_cv_mvwdelch_is_expression=yes))
3859AC_MSG_RESULT($ac_cv_mvwdelch_is_expression)
3860
3861if test "$ac_cv_mvwdelch_is_expression" = yes
3862then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003863 AC_DEFINE(MVWDELCH_IS_EXPRESSION, 1,
3864 [Define if mvwdelch in curses.h is an expression.])
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00003865fi
3866
3867AC_MSG_CHECKING(whether WINDOW has _flags)
3868AC_CACHE_VAL(ac_cv_window_has_flags,
3869AC_TRY_COMPILE([#include <curses.h>], [
3870 WINDOW *w;
3871 w->_flags = 0;
3872], ac_cv_window_has_flags=yes,
3873 ac_cv_window_has_flags=no,
3874 ac_cv_window_has_flags=no))
3875AC_MSG_RESULT($ac_cv_window_has_flags)
3876
3877
3878if test "$ac_cv_window_has_flags" = yes
3879then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003880 AC_DEFINE(WINDOW_HAS_FLAGS, 1,
3881 [Define if WINDOW in curses.h offers a field _flags.])
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00003882fi
3883
Thomas Wouters0e3f5912006-08-11 14:57:12 +00003884AC_MSG_CHECKING(for is_term_resized)
3885AC_TRY_COMPILE([#include <curses.h>], void *x=is_term_resized,
3886 AC_DEFINE(HAVE_CURSES_IS_TERM_RESIZED, 1, Define if you have the 'is_term_resized' function.)
3887 AC_MSG_RESULT(yes),
Martin v. Löwis24a880b2002-12-31 12:55:15 +00003888 AC_MSG_RESULT(no)
Thomas Wouters0e3f5912006-08-11 14:57:12 +00003889)
Martin v. Löwis24a880b2002-12-31 12:55:15 +00003890
Thomas Wouters0e3f5912006-08-11 14:57:12 +00003891AC_MSG_CHECKING(for resize_term)
3892AC_TRY_COMPILE([#include <curses.h>], void *x=resize_term,
3893 AC_DEFINE(HAVE_CURSES_RESIZE_TERM, 1, Define if you have the 'resize_term' function.)
3894 AC_MSG_RESULT(yes),
Neal Norwitz865400f2003-03-21 01:42:58 +00003895 AC_MSG_RESULT(no)
Thomas Wouters0e3f5912006-08-11 14:57:12 +00003896)
3897
3898AC_MSG_CHECKING(for resizeterm)
3899AC_TRY_COMPILE([#include <curses.h>], void *x=resizeterm,
3900 AC_DEFINE(HAVE_CURSES_RESIZETERM, 1, Define if you have the 'resizeterm' function.)
3901 AC_MSG_RESULT(yes),
3902 AC_MSG_RESULT(no)
3903)
3904
Thomas Wouters89f507f2006-12-13 04:49:30 +00003905AC_MSG_CHECKING(for /dev/ptmx)
3906
3907if test -r /dev/ptmx
3908then
3909 AC_MSG_RESULT(yes)
3910 AC_DEFINE(HAVE_DEV_PTMX, 1,
3911 [Define if we have /dev/ptmx.])
3912else
3913 AC_MSG_RESULT(no)
3914fi
3915
3916AC_MSG_CHECKING(for /dev/ptc)
3917
3918if test -r /dev/ptc
3919then
3920 AC_MSG_RESULT(yes)
3921 AC_DEFINE(HAVE_DEV_PTC, 1,
3922 [Define if we have /dev/ptc.])
3923else
3924 AC_MSG_RESULT(no)
3925fi
Neal Norwitz865400f2003-03-21 01:42:58 +00003926
Mark Dickinson6ce4a9a2009-11-16 17:00:11 +00003927if test "$have_long_long" = yes
3928then
3929 AC_MSG_CHECKING(for %lld and %llu printf() format support)
3930 AC_CACHE_VAL(ac_cv_have_long_long_format,
3931 AC_TRY_RUN([[
3932 #include <stdio.h>
3933 #include <stddef.h>
3934 #include <string.h>
3935
3936 #ifdef HAVE_SYS_TYPES_H
3937 #include <sys/types.h>
3938 #endif
3939
3940 int main()
3941 {
3942 char buffer[256];
3943
3944 if (sprintf(buffer, "%lld", (long long)123) < 0)
3945 return 1;
3946 if (strcmp(buffer, "123"))
3947 return 1;
3948
3949 if (sprintf(buffer, "%lld", (long long)-123) < 0)
3950 return 1;
3951 if (strcmp(buffer, "-123"))
3952 return 1;
3953
3954 if (sprintf(buffer, "%llu", (unsigned long long)123) < 0)
3955 return 1;
3956 if (strcmp(buffer, "123"))
3957 return 1;
3958
3959 return 0;
3960 }
3961 ]], ac_cv_have_long_long_format=yes,
3962 ac_cv_have_long_long_format=no,
3963 ac_cv_have_long_long_format=no)
3964 )
3965 AC_MSG_RESULT($ac_cv_have_long_long_format)
3966fi
3967
Mark Dickinson89d7d412009-12-31 20:50:59 +00003968if test "$ac_cv_have_long_long_format" = yes
Mark Dickinson6ce4a9a2009-11-16 17:00:11 +00003969then
3970 AC_DEFINE(PY_FORMAT_LONG_LONG, "ll",
3971 [Define to printf format modifier for long long type])
3972fi
3973
Ronald Oussoren3c1928a2009-11-19 17:15:31 +00003974if test $ac_sys_system = Darwin
3975then
3976 LIBS="$LIBS -framework CoreFoundation"
3977fi
Mark Dickinson6ce4a9a2009-11-16 17:00:11 +00003978
Benjamin Peterson8f326b22009-12-13 02:10:36 +00003979AC_CACHE_CHECK([for %zd printf() format support], ac_cv_have_size_t_format, [dnl
3980AC_TRY_RUN([
Alexandre Vassalottie5091f62009-07-17 06:41:02 +00003981#include <stdio.h>
Thomas Wouters477c8d52006-05-27 19:21:47 +00003982#include <stddef.h>
3983#include <string.h>
3984
Christian Heimes2c181612007-12-17 20:04:13 +00003985#ifdef HAVE_SYS_TYPES_H
3986#include <sys/types.h>
3987#endif
Thomas Wouters89f507f2006-12-13 04:49:30 +00003988
3989#ifdef HAVE_SSIZE_T
3990typedef ssize_t Py_ssize_t;
3991#elif SIZEOF_VOID_P == SIZEOF_LONG
3992typedef long Py_ssize_t;
3993#else
3994typedef int Py_ssize_t;
3995#endif
Thomas Wouters477c8d52006-05-27 19:21:47 +00003996
Christian Heimes2c181612007-12-17 20:04:13 +00003997int main()
3998{
3999 char buffer[256];
4000
Thomas Wouters477c8d52006-05-27 19:21:47 +00004001 if(sprintf(buffer, "%zd", (size_t)123) < 0)
4002 return 1;
4003
Thomas Wouters89f507f2006-12-13 04:49:30 +00004004 if (strcmp(buffer, "123"))
Thomas Wouters477c8d52006-05-27 19:21:47 +00004005 return 1;
Thomas Wouters89f507f2006-12-13 04:49:30 +00004006
4007 if (sprintf(buffer, "%zd", (Py_ssize_t)-123) < 0)
4008 return 1;
4009
4010 if (strcmp(buffer, "-123"))
4011 return 1;
4012
Thomas Wouters477c8d52006-05-27 19:21:47 +00004013 return 0;
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00004014}
Benjamin Peterson8f326b22009-12-13 02:10:36 +00004015], ac_cv_have_size_t_format=yes,
Alexandre Vassalottie5091f62009-07-17 06:41:02 +00004016 ac_cv_have_size_t_format=no,
Benjamin Peterson8f326b22009-12-13 02:10:36 +00004017 [ac_cv_have_size_t_format="cross -- assuming yes"]
4018)])
4019if test "$ac_cv_have_size_t_format" != no ; then
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00004020 AC_DEFINE(PY_FORMAT_SIZE_T, "z",
4021 [Define to printf format modifier for Py_ssize_t])
4022fi
Thomas Wouters477c8d52006-05-27 19:21:47 +00004023
Martin v. Löwis01c04012002-11-11 14:58:44 +00004024AC_CHECK_TYPE(socklen_t,,
4025 AC_DEFINE(socklen_t,int,
4026 Define to `int' if <sys/socket.h> does not define.),[
4027#ifdef HAVE_SYS_TYPES_H
4028#include <sys/types.h>
4029#endif
Guido van Rossum95713eb2000-05-18 20:53:31 +00004030#ifdef HAVE_SYS_SOCKET_H
4031#include <sys/socket.h>
4032#endif
Martin v. Löwis01c04012002-11-11 14:58:44 +00004033])
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00004034
Antoine Pitroufff95302008-09-03 18:58:51 +00004035AC_MSG_CHECKING(for broken mbstowcs)
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00004036AC_CACHE_VAL(ac_cv_broken_mbstowcs,
Antoine Pitroufff95302008-09-03 18:58:51 +00004037AC_TRY_RUN([
4038#include<stdlib.h>
4039int main() {
4040 size_t len = -1;
4041 const char *str = "text";
4042 len = mbstowcs(NULL, str, 0);
4043 return (len != 4);
4044}
4045],
4046ac_cv_broken_mbstowcs=no,
4047ac_cv_broken_mbstowcs=yes,
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00004048ac_cv_broken_mbstowcs=no))
Antoine Pitroufff95302008-09-03 18:58:51 +00004049AC_MSG_RESULT($ac_cv_broken_mbstowcs)
4050if test "$ac_cv_broken_mbstowcs" = yes
4051then
4052 AC_DEFINE(HAVE_BROKEN_MBSTOWCS, 1,
4053 [Define if mbstowcs(NULL, "text", 0) does not return the number of
4054 wide chars that would be converted.])
4055fi
4056
Antoine Pitroub52ec782009-01-25 16:34:23 +00004057# Check for --with-computed-gotos
4058AC_MSG_CHECKING(for --with-computed-gotos)
4059AC_ARG_WITH(computed-gotos,
4060 AC_HELP_STRING(--with-computed-gotos,
4061 Use computed gotos / threaded dispatch in evaluation loop (not available on all compilers)),
4062[
4063if test "$withval" != no
4064then
4065 AC_DEFINE(USE_COMPUTED_GOTOS, 1,
4066 [Define if you want to use computed gotos in ceval.c.])
4067 AC_MSG_RESULT(yes)
4068else AC_MSG_RESULT(no)
4069fi],
4070[AC_MSG_RESULT(no)])
4071
4072
Martin v. Löwis06f15bb2001-12-02 13:02:32 +00004073AC_SUBST(THREADHEADERS)
4074
4075for h in `(cd $srcdir;echo Python/thread_*.h)`
4076do
4077 THREADHEADERS="$THREADHEADERS \$(srcdir)/$h"
4078done
4079
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00004080AC_SUBST(SRCDIRS)
Neal Norwitzd24499d2005-12-18 21:36:39 +00004081SRCDIRS="Parser Grammar Objects Python Modules Mac"
Andrew M. Kuchling8abedde2001-01-26 22:55:24 +00004082AC_MSG_CHECKING(for build directories)
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00004083for dir in $SRCDIRS; do
4084 if test ! -d $dir; then
4085 mkdir $dir
Fred Drake884d3ba2000-11-02 17:52:56 +00004086 fi
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00004087done
4088AC_MSG_RESULT(done)
Fred Drake036144d2000-10-26 17:09:35 +00004089
Guido van Rossum627b2d71993-12-24 10:39:16 +00004090# generate output files
Antoine Pitrou20327222009-05-24 20:39:11 +00004091AC_CONFIG_FILES(Makefile.pre Modules/Setup.config Misc/python.pc)
Martin v. Löwis88afe662002-10-26 13:47:44 +00004092AC_OUTPUT
Neil Schemenauer61c51152001-01-26 16:18:16 +00004093
Thomas Wouters49fd7fa2006-04-21 10:40:58 +00004094echo "creating Modules/Setup"
Neil Schemenauer61c51152001-01-26 16:18:16 +00004095if test ! -f Modules/Setup
4096then
4097 cp $srcdir/Modules/Setup.dist Modules/Setup
4098fi
4099
Thomas Wouters49fd7fa2006-04-21 10:40:58 +00004100echo "creating Modules/Setup.local"
Neil Schemenauer61c51152001-01-26 16:18:16 +00004101if test ! -f Modules/Setup.local
4102then
4103 echo "# Edit this file for local setup changes" >Modules/Setup.local
4104fi
4105
4106echo "creating Makefile"
4107$SHELL $srcdir/Modules/makesetup -c $srcdir/Modules/config.c.in \
4108 -s Modules Modules/Setup.config \
Neil Schemenauerf8b71c52001-04-21 17:41:16 +00004109 Modules/Setup.local Modules/Setup
Neil Schemenauer66252162001-02-19 04:47:42 +00004110mv config.c Modules