blob: 0ec9dcff0e689fc3ef295e1c9908c50e90f5f9af [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
Victor Stinner00d6a1d2010-03-25 01:02:29 +0000444save_CFLAGS=$CFLAGS
Guido van Rossum627b2d71993-12-24 10:39:16 +0000445AC_PROG_CC
Victor Stinner00d6a1d2010-03-25 01:02:29 +0000446CFLAGS=$save_CFLAGS
Martin v. Löwis1d5ecb72001-08-09 10:29:44 +0000447
Thomas Wouters49fd7fa2006-04-21 10:40:58 +0000448AC_SUBST(CXX)
449AC_SUBST(MAINCC)
450AC_MSG_CHECKING(for --with-cxx-main=<compiler>)
451AC_ARG_WITH(cxx_main,
452 AC_HELP_STRING([--with-cxx-main=<compiler>],
453 [compile main() and link python executable with C++ compiler]),
454[
455
456 case $withval in
457 no) with_cxx_main=no
458 MAINCC='$(CC)';;
459 yes) with_cxx_main=yes
460 MAINCC='$(CXX)';;
461 *) with_cxx_main=yes
462 MAINCC=$withval
463 if test -z "$CXX"
464 then
465 CXX=$withval
466 fi;;
467 esac], [
468 with_cxx_main=no
469 MAINCC='$(CC)'
470])
471AC_MSG_RESULT($with_cxx_main)
472
473preset_cxx="$CXX"
474if test -z "$CXX"
475then
476 case "$CC" in
477 gcc) AC_PATH_PROG(CXX, [g++], [g++], [notfound]) ;;
478 cc) AC_PATH_PROG(CXX, [c++], [c++], [notfound]) ;;
479 esac
480 if test "$CXX" = "notfound"
481 then
482 CXX=""
483 fi
484fi
485if test -z "$CXX"
486then
487 AC_CHECK_PROGS(CXX, $CCC c++ g++ gcc CC cxx cc++ cl, notfound)
488 if test "$CXX" = "notfound"
489 then
490 CXX=""
491 fi
492fi
493if test "$preset_cxx" != "$CXX"
494then
495 AC_MSG_WARN([
496
497 By default, distutils will build C++ extension modules with "$CXX".
498 If this is not intended, then set CXX on the configure command line.
499 ])
500fi
501
502
Martin v. Löwis1d5ecb72001-08-09 10:29:44 +0000503# checks for UNIX variants that set C preprocessor variables
504AC_AIX
Martin v. Löwis1d5ecb72001-08-09 10:29:44 +0000505
Martin v. Löwis779ffc02002-12-02 22:17:01 +0000506# Check for unsupported systems
507case $ac_sys_system/$ac_sys_release in
Guido van Rossumcd16bf62007-06-13 18:07:49 +0000508atheos*|Linux*/1*)
Martin v. Löwis779ffc02002-12-02 22:17:01 +0000509 echo This system \($ac_sys_system/$ac_sys_release\) is no longer supported.
510 echo See README for details.
511 exit 1;;
512esac
513
Neil Schemenauer55f0cf32001-01-24 17:24:33 +0000514AC_EXEEXT
Neil Schemenauer3ae1d0a2001-01-27 06:54:42 +0000515AC_MSG_CHECKING(for --with-suffix)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000516AC_ARG_WITH(suffix,
517 AC_HELP_STRING(--with-suffix=.exe, set executable suffix),
518[
Neil Schemenauer3ae1d0a2001-01-27 06:54:42 +0000519 case $withval in
520 no) EXEEXT=;;
521 yes) EXEEXT=.exe;;
522 *) EXEEXT=$withval;;
523 esac])
524AC_MSG_RESULT($EXEEXT)
Jack Jansen1999ef42001-12-06 21:47:20 +0000525
Jack Jansen9a66b6d2001-08-08 13:56:14 +0000526# Test whether we're running on a non-case-sensitive system, in which
527# case we give a warning if no ext is given
Jack Jansen1999ef42001-12-06 21:47:20 +0000528AC_SUBST(BUILDEXEEXT)
529AC_MSG_CHECKING(for case-insensitive build directory)
Jack Jansen3c2c4332002-11-06 13:33:32 +0000530if test ! -d CaseSensitiveTestDir; then
531mkdir CaseSensitiveTestDir
532fi
533
534if test -d casesensitivetestdir
Jack Jansen9a66b6d2001-08-08 13:56:14 +0000535then
Jack Jansen1999ef42001-12-06 21:47:20 +0000536 AC_MSG_RESULT(yes)
537 BUILDEXEEXT=.exe
538else
539 AC_MSG_RESULT(no)
Jack Jansendd19cf82001-12-06 22:36:17 +0000540 BUILDEXEEXT=$EXEEXT
Jack Jansen9a66b6d2001-08-08 13:56:14 +0000541fi
Jack Jansen3c2c4332002-11-06 13:33:32 +0000542rmdir CaseSensitiveTestDir
Guido van Rossumfb842551997-08-06 23:42:07 +0000543
Guido van Rossumdd997f71998-10-07 19:58:26 +0000544case $MACHDEP in
545bsdos*)
546 case $CC in
547 gcc) CC="$CC -D_HAVE_BSDI";;
548 esac;;
549esac
550
Guido van Rossum84561611997-08-21 00:08:11 +0000551case $ac_sys_system in
552hp*|HP*)
553 case $CC in
Guido van Rossumcd5ff9f2000-09-22 16:15:54 +0000554 cc|*/cc) CC="$CC -Ae";;
Guido van Rossum84561611997-08-21 00:08:11 +0000555 esac;;
Martin v. Löwise8964d42001-03-06 12:09:07 +0000556SunOS*)
557 # Some functions have a prototype only with that define, e.g. confstr
Martin v. Löwisc45929e2002-04-06 10:10:49 +0000558 AC_DEFINE(__EXTENSIONS__, 1, [Defined on Solaris to see additional function prototypes.])
Martin v. Löwise8964d42001-03-06 12:09:07 +0000559 ;;
Guido van Rossum84561611997-08-21 00:08:11 +0000560esac
561
Martin v. Löwise8964d42001-03-06 12:09:07 +0000562
Neil Schemenauer61c51152001-01-26 16:18:16 +0000563AC_SUBST(LIBRARY)
564AC_MSG_CHECKING(LIBRARY)
565if test -z "$LIBRARY"
566then
567 LIBRARY='libpython$(VERSION).a'
568fi
569AC_MSG_RESULT($LIBRARY)
570
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000571# LDLIBRARY is the name of the library to link against (as opposed to the
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000572# name of the library into which to insert object files). BLDLIBRARY is also
573# the library to link against, usually. On Mac OS X frameworks, BLDLIBRARY
574# is blank as the main program is not linked directly against LDLIBRARY.
575# LDLIBRARYDIR is the path to LDLIBRARY, which is made in a subdirectory. On
576# systems without shared libraries, LDLIBRARY is the same as LIBRARY
577# (defined in the Makefiles). On Cygwin LDLIBRARY is the import library,
578# DLLLIBRARY is the shared (i.e., DLL) library.
579#
Martin v. Löwis1142de32002-03-29 16:28:31 +0000580# RUNSHARED is used to run shared python without installed libraries
581#
582# INSTSONAME is the name of the shared library that will be use to install
583# on the system - some systems like version suffix, others don't
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000584AC_SUBST(LDLIBRARY)
Guido van Rossum27552902001-01-23 01:52:26 +0000585AC_SUBST(DLLLIBRARY)
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000586AC_SUBST(BLDLIBRARY)
587AC_SUBST(LDLIBRARYDIR)
Martin v. Löwis1142de32002-03-29 16:28:31 +0000588AC_SUBST(INSTSONAME)
589AC_SUBST(RUNSHARED)
Neil Schemenauer61c51152001-01-26 16:18:16 +0000590LDLIBRARY="$LIBRARY"
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000591BLDLIBRARY='$(LDLIBRARY)'
Martin v. Löwis09bdf722002-05-08 08:51:29 +0000592INSTSONAME='$(LDLIBRARY)'
Guido van Rossum27552902001-01-23 01:52:26 +0000593DLLLIBRARY=''
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000594LDLIBRARYDIR=''
Martin v. Löwis1142de32002-03-29 16:28:31 +0000595RUNSHARED=''
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000596
Guido van Rossumfb842551997-08-06 23:42:07 +0000597# LINKCC is the command that links the python executable -- default is $(CC).
Martin v. Löwisb7da67a2001-10-18 15:35:38 +0000598# If CXX is set, and if it is needed to link a main function that was
599# compiled with CXX, LINKCC is CXX instead. Always using CXX is undesirable:
600# python might then depend on the C++ runtime
Fred Drake5790be12000-10-09 17:06:13 +0000601# This is altered for AIX in order to build the export list before
Guido van Rossumec95c7b1998-08-04 17:59:56 +0000602# linking.
Guido van Rossumfb842551997-08-06 23:42:07 +0000603AC_SUBST(LINKCC)
604AC_MSG_CHECKING(LINKCC)
605if test -z "$LINKCC"
606then
Thomas Wouters49fd7fa2006-04-21 10:40:58 +0000607 LINKCC='$(PURIFY) $(MAINCC)'
Guido van Rossumfb842551997-08-06 23:42:07 +0000608 case $ac_sys_system in
609 AIX*)
Neal Norwitz0b27ff92003-03-31 15:53:49 +0000610 exp_extra="\"\""
611 if test $ac_sys_release -ge 5 -o \
612 $ac_sys_release -eq 4 -a `uname -r` -ge 2 ; then
613 exp_extra="."
614 fi
615 LINKCC="\$(srcdir)/Modules/makexp_aix Modules/python.exp $exp_extra \$(LIBRARY); $LINKCC";;
Georg Brandlf78e02b2008-06-10 17:40:04 +0000616 QNX*)
617 # qcc must be used because the other compilers do not
618 # support -N.
619 LINKCC=qcc;;
Guido van Rossumfb842551997-08-06 23:42:07 +0000620 esac
621fi
622AC_MSG_RESULT($LINKCC)
623
Tarek Ziadébe720e02009-05-09 11:55:12 +0000624# GNULD is set to "yes" if the GNU linker is used. If this goes wrong
625# make sure we default having it set to "no": this is used by
626# distutils.unixccompiler to know if it should add --enable-new-dtags
627# to linker command lines, and failing to detect GNU ld simply results
628# in the same bahaviour as before.
629AC_SUBST(GNULD)
630AC_MSG_CHECKING(for GNU ld)
631ac_prog=ld
632if test "$GCC" = yes; then
633 ac_prog=`$CC -print-prog-name=ld`
634fi
635case `"$ac_prog" -V 2>&1 < /dev/null` in
636 *GNU*)
637 GNULD=yes;;
638 *)
639 GNULD=no;;
640esac
641AC_MSG_RESULT($GNULD)
642
Martin v. Löwis1142de32002-03-29 16:28:31 +0000643AC_MSG_CHECKING(for --enable-shared)
644AC_ARG_ENABLE(shared,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000645 AC_HELP_STRING(--enable-shared, disable/enable building shared python library))
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000646
Martin v. Löwis1142de32002-03-29 16:28:31 +0000647if test -z "$enable_shared"
648then
Martin v. Löwisb51033d2002-05-03 05:53:15 +0000649 case $ac_sys_system in
Antoine Pitrou6103ab12009-10-24 20:11:21 +0000650 CYGWIN*)
Martin v. Löwisb51033d2002-05-03 05:53:15 +0000651 enable_shared="yes";;
652 *)
653 enable_shared="no";;
654 esac
Martin v. Löwis1142de32002-03-29 16:28:31 +0000655fi
656AC_MSG_RESULT($enable_shared)
657
Skip Montanaro56f6a4f2004-06-18 02:47:22 +0000658AC_MSG_CHECKING(for --enable-profiling)
659AC_ARG_ENABLE(profiling,
660 AC_HELP_STRING(--enable-profiling, enable C-level code profiling),
661[ac_save_cc="$CC"
662 CC="$CC -pg"
663 AC_TRY_RUN([int main() { return 0; }],
664 ac_enable_profiling="yes",
665 ac_enable_profiling="no",
666 ac_enable_profiling="no")
667 CC="$ac_save_cc"])
668AC_MSG_RESULT($ac_enable_profiling)
669
670case "$ac_enable_profiling" in
671 "yes")
672 BASECFLAGS="-pg $BASECFLAGS"
673 LDFLAGS="-pg $LDFLAGS"
674 ;;
675esac
Martin v. Löwis1142de32002-03-29 16:28:31 +0000676
677AC_MSG_CHECKING(LDLIBRARY)
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000678
Guido van Rossumb8552162001-09-05 14:58:11 +0000679# MacOSX framework builds need more magic. LDLIBRARY is the dynamic
680# library that we build, but we do not want to link against it (we
681# will find it with a -framework option). For this reason there is an
682# extra variable BLDLIBRARY against which Python and the extension
683# modules are linked, BLDLIBRARY. This is normally the same as
684# LDLIBRARY, but empty for MacOSX framework builds.
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000685if test "$enable_framework"
686then
687 LDLIBRARY='$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansen66b84832003-07-04 12:14:39 +0000688 RUNSHARED=DYLD_FRAMEWORK_PATH="`pwd`:$DYLD_FRAMEWORK_PATH"
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000689 BLDLIBRARY=''
690else
691 BLDLIBRARY='$(LDLIBRARY)'
692fi
693
Martin v. Löwis1142de32002-03-29 16:28:31 +0000694# Other platforms follow
695if test $enable_shared = "yes"; then
Mark Hammond8235ea12002-07-19 06:55:41 +0000696 AC_DEFINE(Py_ENABLE_SHARED, 1, [Defined if Python is built as a shared library.])
Martin v. Löwis1142de32002-03-29 16:28:31 +0000697 case $ac_sys_system in
Martin v. Löwis1142de32002-03-29 16:28:31 +0000698 CYGWIN*)
699 LDLIBRARY='libpython$(VERSION).dll.a'
700 DLLLIBRARY='libpython$(VERSION).dll'
701 ;;
702 SunOS*)
703 LDLIBRARY='libpython$(VERSION).so'
Martin v. Löwisd141a8c2003-06-14 15:20:28 +0000704 BLDLIBRARY='-Wl,-R,$(LIBDIR) -L. -lpython$(VERSION)'
Martin v. Löwisfc9b75f2003-08-09 09:06:52 +0000705 RUNSHARED=LD_LIBRARY_PATH=`pwd`:${LD_LIBRARY_PATH}
Martin v. Löwis2389c412003-10-31 15:42:07 +0000706 INSTSONAME="$LDLIBRARY".$SOVERSION
Martin v. Löwis1142de32002-03-29 16:28:31 +0000707 ;;
Martin v. Löwis86d66262006-02-17 08:40:11 +0000708 Linux*|GNU*|NetBSD*|FreeBSD*|DragonFly*)
Martin v. Löwis1142de32002-03-29 16:28:31 +0000709 LDLIBRARY='libpython$(VERSION).so'
710 BLDLIBRARY='-L. -lpython$(VERSION)'
Martin v. Löwisfc9b75f2003-08-09 09:06:52 +0000711 RUNSHARED=LD_LIBRARY_PATH=`pwd`:${LD_LIBRARY_PATH}
Hye-Shik Chang33761492004-10-26 09:53:46 +0000712 case $ac_sys_system in
713 FreeBSD*)
714 SOVERSION=`echo $SOVERSION|cut -d "." -f 1`
715 ;;
716 esac
Martin v. Löwis1142de32002-03-29 16:28:31 +0000717 INSTSONAME="$LDLIBRARY".$SOVERSION
718 ;;
719 hp*|HP*)
Thomas Wouters477c8d52006-05-27 19:21:47 +0000720 case `uname -m` in
721 ia64)
722 LDLIBRARY='libpython$(VERSION).so'
723 ;;
724 *)
725 LDLIBRARY='libpython$(VERSION).sl'
726 ;;
727 esac
Martin v. Löwis1142de32002-03-29 16:28:31 +0000728 BLDLIBRARY='-Wl,+b,$(LIBDIR) -L. -lpython$(VERSION)'
Martin v. Löwisfc9b75f2003-08-09 09:06:52 +0000729 RUNSHARED=SHLIB_PATH=`pwd`:${SHLIB_PATH}
Martin v. Löwis1142de32002-03-29 16:28:31 +0000730 ;;
731 OSF*)
732 LDLIBRARY='libpython$(VERSION).so'
Neal Norwitz671b9e32006-01-09 07:07:12 +0000733 BLDLIBRARY='-rpath $(LIBDIR) -L. -lpython$(VERSION)'
Martin v. Löwisfc9b75f2003-08-09 09:06:52 +0000734 RUNSHARED=LD_LIBRARY_PATH=`pwd`:${LD_LIBRARY_PATH}
Martin v. Löwis1142de32002-03-29 16:28:31 +0000735 ;;
Georg Brandlb1441c72009-01-03 22:33:39 +0000736 Darwin*)
737 LDLIBRARY='libpython$(VERSION).dylib'
738 BLDLIBRARY='-L. -lpython$(VERSION)'
739 RUNSHARED='DYLD_LIBRARY_PATH=`pwd`:${DYLD_LIBRARY_PATH}'
740 ;;
741
Martin v. Löwis1142de32002-03-29 16:28:31 +0000742 esac
Jason Tishler30765592003-09-04 11:04:06 +0000743else # shared is disabled
744 case $ac_sys_system in
745 CYGWIN*)
746 BLDLIBRARY='$(LIBRARY)'
747 LDLIBRARY='libpython$(VERSION).dll.a'
748 ;;
749 esac
Martin v. Löwis1142de32002-03-29 16:28:31 +0000750fi
751
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000752AC_MSG_RESULT($LDLIBRARY)
753
Guido van Rossum627b2d71993-12-24 10:39:16 +0000754AC_PROG_RANLIB
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000755AC_SUBST(AR)
Guido van Rossum76be6ed1995-01-02 18:33:54 +0000756AC_CHECK_PROGS(AR, ar aal, ar)
Neil Schemenauera42c8272001-03-31 00:01:55 +0000757
Tarek Ziadé5662d3e2009-05-07 21:24:43 +0000758# tweak ARFLAGS only if the user didn't set it on the command line
759AC_SUBST(ARFLAGS)
760if test -z "$ARFLAGS"
761then
762 ARFLAGS="rc"
763fi
764
Martin v. Löwisdea59e52006-01-05 10:00:36 +0000765AC_SUBST(SVNVERSION)
Thomas Wouters49fd7fa2006-04-21 10:40:58 +0000766AC_CHECK_PROG(SVNVERSION, svnversion, found, not-found)
Martin v. Löwisc5bf5a02006-01-05 10:33:59 +0000767if test $SVNVERSION = found
768then
769 SVNVERSION="svnversion \$(srcdir)"
770else
Benjamin Petersonf53eec82009-05-23 19:36:27 +0000771 SVNVERSION="echo Unversioned directory"
Martin v. Löwisc5bf5a02006-01-05 10:33:59 +0000772fi
Martin v. Löwisdea59e52006-01-05 10:00:36 +0000773
Neil Schemenauera42c8272001-03-31 00:01:55 +0000774case $MACHDEP in
Neil Schemenaueraf5567f2001-10-21 22:32:04 +0000775bsdos*|hp*|HP*)
776 # install -d does not work on BSDI or HP-UX
Neil Schemenauera42c8272001-03-31 00:01:55 +0000777 if test -z "$INSTALL"
778 then
779 INSTALL="${srcdir}/install-sh -c"
780 fi
781esac
Neil Schemenauer55f0cf32001-01-24 17:24:33 +0000782AC_PROG_INSTALL
Guido van Rossumb418f891996-07-30 18:06:02 +0000783
Guido van Rossumec95c7b1998-08-04 17:59:56 +0000784# Not every filesystem supports hard links
785AC_SUBST(LN)
786if test -z "$LN" ; then
787 case $ac_sys_system in
Guido van Rossumaef734b2001-01-10 21:09:12 +0000788 CYGWIN*) LN="ln -s";;
Guido van Rossumec95c7b1998-08-04 17:59:56 +0000789 *) LN=ln;;
790 esac
791fi
792
Fred Drake9f715822001-07-11 06:27:00 +0000793# Check for --with-pydebug
794AC_MSG_CHECKING(for --with-pydebug)
795AC_ARG_WITH(pydebug,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000796 AC_HELP_STRING(--with-pydebug, build with Py_DEBUG defined),
797[
Fred Drake9f715822001-07-11 06:27:00 +0000798if test "$withval" != no
Martin v. Löwisc45929e2002-04-06 10:10:49 +0000799then
800 AC_DEFINE(Py_DEBUG, 1,
801 [Define if you want to build an interpreter with many run-time checks.])
802 AC_MSG_RESULT(yes);
803 Py_DEBUG='true'
Fred Drake9f715822001-07-11 06:27:00 +0000804else AC_MSG_RESULT(no); Py_DEBUG='false'
805fi],
806[AC_MSG_RESULT(no)])
807
Skip Montanarodecc6a42003-01-01 20:07:49 +0000808# XXX Shouldn't the code above that fiddles with BASECFLAGS and OPT be
809# merged with this chunk of code?
810
Neil Schemenauer55f0cf32001-01-24 17:24:33 +0000811# Optimizer/debugger flags
Skip Montanarodecc6a42003-01-01 20:07:49 +0000812# ------------------------
813# (The following bit of code is complicated enough - please keep things
814# indented properly. Just pretend you're editing Python code. ;-)
815
816# There are two parallel sets of case statements below, one that checks to
817# see if OPT was set and one that does BASECFLAGS setting based upon
818# compiler and platform. BASECFLAGS tweaks need to be made even if the
819# user set OPT.
820
821# tweak OPT based on compiler and platform, only if the user didn't set
822# it on the command line
Guido van Rossumb418f891996-07-30 18:06:02 +0000823AC_SUBST(OPT)
Benjamin Peterson65b4ec52010-03-23 21:02:34 +0000824if test "${OPT-unset}" = "unset"
Guido van Rossumb418f891996-07-30 18:06:02 +0000825then
Skip Montanarodecc6a42003-01-01 20:07:49 +0000826 case $GCC in
827 yes)
Thomas Wouters49fd7fa2006-04-21 10:40:58 +0000828 if test "$CC" != 'g++' ; then
829 STRICT_PROTO="-Wstrict-prototypes"
830 fi
Christian Heimes38053212007-12-14 01:24:44 +0000831 # For gcc 4.x we need to use -fwrapv so lets check if its supported
832 if "$CC" -v --help 2>/dev/null |grep -- -fwrapv > /dev/null; then
833 WRAP="-fwrapv"
834 fi
Skip Montanarodecc6a42003-01-01 20:07:49 +0000835 case $ac_cv_prog_cc_g in
Guido van Rossum2242f2f2001-04-11 20:58:20 +0000836 yes)
Fred Drake9f715822001-07-11 06:27:00 +0000837 if test "$Py_DEBUG" = 'true' ; then
838 # Optimization messes up debuggers, so turn it off for
839 # debug builds.
Thomas Wouters49fd7fa2006-04-21 10:40:58 +0000840 OPT="-g -Wall $STRICT_PROTO"
Fred Drake9f715822001-07-11 06:27:00 +0000841 else
Christian Heimes38053212007-12-14 01:24:44 +0000842 OPT="-g $WRAP -O3 -Wall $STRICT_PROTO"
Skip Montanarodecc6a42003-01-01 20:07:49 +0000843 fi
844 ;;
Guido van Rossum2242f2f2001-04-11 20:58:20 +0000845 *)
Thomas Wouters49fd7fa2006-04-21 10:40:58 +0000846 OPT="-O3 -Wall $STRICT_PROTO"
Skip Montanarodecc6a42003-01-01 20:07:49 +0000847 ;;
Fred Drake9f715822001-07-11 06:27:00 +0000848 esac
Martin v. Löwis21ee4092002-09-30 16:19:48 +0000849 case $ac_sys_system in
Skip Montanarodecc6a42003-01-01 20:07:49 +0000850 SCO_SV*) OPT="$OPT -m486 -DSCO5"
851 ;;
852 esac
Fred Drake9f715822001-07-11 06:27:00 +0000853 ;;
Skip Montanarodecc6a42003-01-01 20:07:49 +0000854
Guido van Rossum2242f2f2001-04-11 20:58:20 +0000855 *)
Skip Montanarodecc6a42003-01-01 20:07:49 +0000856 OPT="-O"
857 ;;
Guido van Rossum2242f2f2001-04-11 20:58:20 +0000858 esac
Guido van Rossum4e8af441994-08-19 15:33:54 +0000859fi
Guido van Rossum627b2d71993-12-24 10:39:16 +0000860
Skip Montanarodecc6a42003-01-01 20:07:49 +0000861AC_SUBST(BASECFLAGS)
Georg Brandlfcaf9102008-07-16 02:17:56 +0000862
863# The -arch flags for universal builds on OSX
864UNIVERSAL_ARCH_FLAGS=
865AC_SUBST(UNIVERSAL_ARCH_FLAGS)
866
Skip Montanarodecc6a42003-01-01 20:07:49 +0000867# tweak BASECFLAGS based on compiler and platform
868case $GCC in
869yes)
Benjamin Petersone6c9d242010-03-30 17:34:47 +0000870 # Python doesn't violate C99 aliasing rules, but older versions of
871 # GCC produce warnings for legal Python code. Enable
872 # -fno-strict-aliasing on versions of GCC that support but produce
873 # warnings. See Issue3326
874 AC_MSG_CHECKING(whether $CC accepts and needs -fno-strict-aliasing)
Martin v. Löwis70fedcd2003-07-07 21:26:19 +0000875 ac_save_cc="$CC"
876 CC="$CC -fno-strict-aliasing"
Benjamin Petersone6c9d242010-03-30 17:34:47 +0000877 save_CFLAGS="$CFLAGS"
878 AC_CACHE_VAL(ac_cv_no_strict_aliasing,
879 AC_TRY_COMPILE([],[int main() { return 0; }],
880 CC="$ac_save_cc -fstrict-aliasing"
881 CFLAGS="$CFLAGS -Werror -Wstrict-aliasing"
882 AC_TRY_COMPILE([],[void f(int **x) {} int main() { double *x; f((int **) &x); return 0; }],
883 ac_cv_no_strict_aliasing=no,
884 ac_cv_no_strict_aliasing=yes),
885 ac_cv_no_strict_aliasing=no))
886 CFLAGS="$save_CFLAGS"
Martin v. Löwis70fedcd2003-07-07 21:26:19 +0000887 CC="$ac_save_cc"
Benjamin Petersone6c9d242010-03-30 17:34:47 +0000888 AC_MSG_RESULT($ac_cv_no_strict_aliasing)
889 if test $ac_cv_no_strict_aliasing = yes
Martin v. Löwis70fedcd2003-07-07 21:26:19 +0000890 then
891 BASECFLAGS="$BASECFLAGS -fno-strict-aliasing"
892 fi
Mark Dickinsonb0e2b4c2008-04-26 20:48:56 +0000893
894 # if using gcc on alpha, use -mieee to get (near) full IEEE 754
895 # support. Without this, treatment of subnormals doesn't follow
896 # the standard.
897 case $ac_sys_machine in
898 alpha*)
899 BASECFLAGS="$BASECFLAGS -mieee"
900 ;;
901 esac
902
Skip Montanarodecc6a42003-01-01 20:07:49 +0000903 case $ac_sys_system in
904 SCO_SV*)
905 BASECFLAGS="$BASECFLAGS -m486 -DSCO5"
906 ;;
907 # is there any other compiler on Darwin besides gcc?
908 Darwin*)
Christian Heimesb186d002008-03-18 15:15:01 +0000909 # -Wno-long-double, -no-cpp-precomp, and -mno-fused-madd
910 # used to be here, but non-Apple gcc doesn't accept them.
Benjamin Peterson67c38e22008-07-17 16:10:34 +0000911
912
Thomas Wouters477c8d52006-05-27 19:21:47 +0000913 if test "${enable_universalsdk}"; then
Georg Brandlfcaf9102008-07-16 02:17:56 +0000914 UNIVERSAL_ARCH_FLAGS=""
915 if test "$UNIVERSAL_ARCHS" = "32-bit" ; then
916 UNIVERSAL_ARCH_FLAGS="-arch ppc -arch i386"
Benjamin Peterson6794aa32008-07-16 20:33:37 +0000917 ARCH_RUN_32BIT=""
Benjamin Peterson051858e2010-04-11 22:14:02 +0000918 LIPO_32BIT_FLAGS=""
Georg Brandlfcaf9102008-07-16 02:17:56 +0000919 elif test "$UNIVERSAL_ARCHS" = "64-bit" ; then
920 UNIVERSAL_ARCH_FLAGS="-arch ppc64 -arch x86_64"
Ronald Oussoren6f6c5622009-12-24 14:03:19 +0000921 LIPO_32BIT_FLAGS=""
Ronald Oussoren5bbab3e2009-09-06 11:01:15 +0000922 ARCH_RUN_32BIT="true"
Georg Brandlfcaf9102008-07-16 02:17:56 +0000923
924 elif test "$UNIVERSAL_ARCHS" = "all" ; then
925 UNIVERSAL_ARCH_FLAGS="-arch i386 -arch ppc -arch ppc64 -arch x86_64"
Ronald Oussoren6f6c5622009-12-24 14:03:19 +0000926 LIPO_32BIT_FLAGS="-extract ppc7400 -extract i386"
Ronald Oussoren564f7f22010-02-11 13:23:08 +0000927 ARCH_RUN_32BIT="/usr/bin/arch -i386 -ppc"
Georg Brandlfcaf9102008-07-16 02:17:56 +0000928
Ronald Oussoren3c064c12009-09-08 07:12:42 +0000929 elif test "$UNIVERSAL_ARCHS" = "intel" ; then
930 UNIVERSAL_ARCH_FLAGS="-arch i386 -arch x86_64"
Ronald Oussoren6f6c5622009-12-24 14:03:19 +0000931 LIPO_32BIT_FLAGS="-extract i386"
Ronald Oussoren564f7f22010-02-11 13:23:08 +0000932 ARCH_RUN_32BIT="/usr/bin/arch -i386"
Ronald Oussoren3c064c12009-09-08 07:12:42 +0000933
934 elif test "$UNIVERSAL_ARCHS" = "3-way" ; then
935 UNIVERSAL_ARCH_FLAGS="-arch i386 -arch ppc -arch x86_64"
Ronald Oussoren6f6c5622009-12-24 14:03:19 +0000936 LIPO_32BIT_FLAGS="-extract ppc7400 -extract i386"
Ronald Oussoren564f7f22010-02-11 13:23:08 +0000937 ARCH_RUN_32BIT="/usr/bin/arch -i386 -ppc"
Ronald Oussoren3c064c12009-09-08 07:12:42 +0000938
Georg Brandlfcaf9102008-07-16 02:17:56 +0000939 else
Ronald Oussoren74f29b42009-09-20 20:09:26 +0000940 AC_MSG_ERROR([proper usage is --with-universal-arch=32-bit|64-bit|all|intel|3-way])
Georg Brandlfcaf9102008-07-16 02:17:56 +0000941
942 fi
943
944
945 BASECFLAGS="${UNIVERSAL_ARCH_FLAGS} -isysroot ${UNIVERSALSDK} ${BASECFLAGS}"
Georg Brandl3dbca812008-07-23 16:10:53 +0000946 tgt=`sw_vers -productVersion | sed 's/\(10\.[[0-9]]*\).*/\1/'`
Benjamin Peterson67c38e22008-07-17 16:10:34 +0000947 if test "${UNIVERSALSDK}" != "/" -a "${tgt}" '>' '10.4' ; then
948 CFLAGS="${UNIVERSAL_ARCH_FLAGS} -isysroot ${UNIVERSALSDK} ${CFLAGS}"
949 fi
Thomas Wouters477c8d52006-05-27 19:21:47 +0000950 fi
951
Benjamin Peterson67c38e22008-07-17 16:10:34 +0000952 # Calculate the right deployment target for this build.
953 #
954 cur_target=`sw_vers -productVersion | sed 's/\(10\.[[0-9]]*\).*/\1/'`
955 if test ${cur_target} '>' 10.2; then
956 cur_target=10.3
Ronald Oussoren5bbab3e2009-09-06 11:01:15 +0000957 if test ${enable_universalsdk}; then
958 if test "${UNIVERSAL_ARCHS}" = "all"; then
959 # Ensure that the default platform for a
960 # 4-way universal build is OSX 10.5,
961 # that's the first OS release where
962 # 4-way builds make sense.
963 cur_target='10.5'
Ronald Oussoren3c064c12009-09-08 07:12:42 +0000964
965 elif test "${UNIVERSAL_ARCHS}" = "3-way"; then
966 cur_target='10.5'
967
968 elif test "${UNIVERSAL_ARCHS}" = "intel"; then
969 cur_target='10.5'
970
971 elif test "${UNIVERSAL_ARCHS}" = "64-bit"; then
972 cur_target='10.5'
Ronald Oussoren5bbab3e2009-09-06 11:01:15 +0000973 fi
974 else
Ronald Oussorene3da75a2010-02-11 13:38:58 +0000975 if test `/usr/bin/arch` = "i386"; then
Ronald Oussoren5bbab3e2009-09-06 11:01:15 +0000976 # On Intel macs default to a deployment
977 # target of 10.4, that's the first OSX
978 # release with Intel support.
979 cur_target="10.4"
980 fi
981 fi
Benjamin Peterson67c38e22008-07-17 16:10:34 +0000982 fi
983 CONFIGURE_MACOSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET-${cur_target}}
984
985 # Make sure that MACOSX_DEPLOYMENT_TARGET is set in the
986 # environment with a value that is the same as what we'll use
987 # in the Makefile to ensure that we'll get the same compiler
988 # environment during configure and build time.
989 MACOSX_DEPLOYMENT_TARGET="$CONFIGURE_MACOSX_DEPLOYMENT_TARGET"
990 export MACOSX_DEPLOYMENT_TARGET
991 EXPORT_MACOSX_DEPLOYMENT_TARGET=''
992
Skip Montanarodecc6a42003-01-01 20:07:49 +0000993 ;;
Thomas Wouters49fd7fa2006-04-21 10:40:58 +0000994 OSF*)
995 BASECFLAGS="$BASECFLAGS -mieee"
996 ;;
Skip Montanarodecc6a42003-01-01 20:07:49 +0000997 esac
998 ;;
999
1000*)
1001 case $ac_sys_system in
1002 OpenUNIX*|UnixWare*)
1003 BASECFLAGS="$BASECFLAGS -K pentium,host,inline,loop_unroll,alloca "
1004 ;;
Neal Norwitzb44f1652003-05-26 14:11:55 +00001005 OSF*)
1006 BASECFLAGS="$BASECFLAGS -ieee -std"
1007 ;;
Skip Montanarodecc6a42003-01-01 20:07:49 +00001008 SCO_SV*)
1009 BASECFLAGS="$BASECFLAGS -belf -Ki486 -DSCO5"
1010 ;;
1011 esac
1012 ;;
1013esac
1014
Fred Drakee1ceaa02001-12-04 20:55:47 +00001015if test "$Py_DEBUG" = 'true'; then
1016 :
1017else
1018 OPT="-DNDEBUG $OPT"
1019fi
1020
Guido van Rossum6f2260e1996-09-09 16:21:03 +00001021if test "$ac_arch_flags"
Guido van Rossumc5a39031996-07-31 17:35:03 +00001022then
Skip Montanarodecc6a42003-01-01 20:07:49 +00001023 BASECFLAGS="$BASECFLAGS $ac_arch_flags"
Guido van Rossumc5a39031996-07-31 17:35:03 +00001024fi
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001025
Neal Norwitz020c46a2006-01-07 21:39:28 +00001026# disable check for icc since it seems to pass, but generates a warning
1027if test "$CC" = icc
1028then
1029 ac_cv_opt_olimit_ok=no
1030fi
1031
Guido van Rossum91922671997-10-09 20:24:13 +00001032AC_MSG_CHECKING(whether $CC accepts -OPT:Olimit=0)
1033AC_CACHE_VAL(ac_cv_opt_olimit_ok,
1034[ac_save_cc="$CC"
1035CC="$CC -OPT:Olimit=0"
Gregory P. Smith4e3ed012009-11-01 21:09:10 +00001036AC_TRY_COMPILE([],[int main() { return 0; }],
Guido van Rossum91922671997-10-09 20:24:13 +00001037 ac_cv_opt_olimit_ok=yes,
Guido van Rossum3065c942001-09-17 04:03:14 +00001038 ac_cv_opt_olimit_ok=no,
Gregory P. Smith4e3ed012009-11-01 21:09:10 +00001039 )
Guido van Rossum91922671997-10-09 20:24:13 +00001040CC="$ac_save_cc"])
1041AC_MSG_RESULT($ac_cv_opt_olimit_ok)
Guido van Rossum2efa34b1997-10-23 17:43:11 +00001042if test $ac_cv_opt_olimit_ok = yes; then
Guido van Rossum5839e582000-10-09 19:52:35 +00001043 case $ac_sys_system in
Skip Montanarodecc6a42003-01-01 20:07:49 +00001044 # XXX is this branch needed? On MacOSX 10.2.2 the result of the
1045 # olimit_ok test is "no". Is it "yes" in some other Darwin-esque
1046 # environment?
1047 Darwin*)
1048 ;;
1049 *)
1050 BASECFLAGS="$BASECFLAGS -OPT:Olimit=0"
1051 ;;
Guido van Rossum5839e582000-10-09 19:52:35 +00001052 esac
Guido van Rossumf8678121998-07-07 21:05:09 +00001053else
1054 AC_MSG_CHECKING(whether $CC accepts -Olimit 1500)
1055 AC_CACHE_VAL(ac_cv_olimit_ok,
1056 [ac_save_cc="$CC"
1057 CC="$CC -Olimit 1500"
Gregory P. Smith4e3ed012009-11-01 21:09:10 +00001058 AC_TRY_COMPILE([],[int main() { return 0; }],
Guido van Rossumf8678121998-07-07 21:05:09 +00001059 ac_cv_olimit_ok=yes,
Guido van Rossum3065c942001-09-17 04:03:14 +00001060 ac_cv_olimit_ok=no,
Gregory P. Smith4e3ed012009-11-01 21:09:10 +00001061 )
Guido van Rossumf8678121998-07-07 21:05:09 +00001062 CC="$ac_save_cc"])
1063 AC_MSG_RESULT($ac_cv_olimit_ok)
1064 if test $ac_cv_olimit_ok = yes; then
Skip Montanarodecc6a42003-01-01 20:07:49 +00001065 BASECFLAGS="$BASECFLAGS -Olimit 1500"
Guido van Rossumf8678121998-07-07 21:05:09 +00001066 fi
Guido van Rossum201afe51997-05-14 21:14:44 +00001067fi
Guido van Rossumf8678121998-07-07 21:05:09 +00001068
Thomas Wouters89f507f2006-12-13 04:49:30 +00001069# Check whether GCC supports PyArg_ParseTuple format
1070if test "$GCC" = "yes"
1071then
1072 AC_MSG_CHECKING(whether gcc supports ParseTuple __format__)
1073 save_CFLAGS=$CFLAGS
1074 CFLAGS="$CFLAGS -Werror"
1075 AC_TRY_COMPILE([
1076 void f(char*,...)__attribute((format(PyArg_ParseTuple, 1, 2)));
1077 ],,
1078 AC_DEFINE(HAVE_ATTRIBUTE_FORMAT_PARSETUPLE, 1, [Define if GCC supports __attribute__((format(PyArg_ParseTuple, 2, 3)))])
1079 AC_MSG_RESULT(yes),
1080 AC_MSG_RESULT(no)
1081 )
1082 CFLAGS=$save_CFLAGS
1083fi
1084
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00001085# On some compilers, pthreads are available without further options
1086# (e.g. MacOS X). On some of these systems, the compiler will not
1087# complain if unaccepted options are passed (e.g. gcc on Mac OS X).
1088# So we have to see first whether pthreads are available without
1089# options before we can check whether -Kpthread improves anything.
1090AC_MSG_CHECKING(whether pthreads are available without options)
1091AC_CACHE_VAL(ac_cv_pthread_is_default,
1092[AC_TRY_RUN([
1093#include <pthread.h>
1094
1095void* routine(void* p){return NULL;}
1096
1097int main(){
1098 pthread_t p;
1099 if(pthread_create(&p,NULL,routine,NULL)!=0)
1100 return 1;
Jack Jansen4f8d0542002-03-08 13:43:01 +00001101 (void)pthread_detach(p);
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00001102 return 0;
1103}
1104],
Skip Montanarod8d39a02003-07-10 20:44:10 +00001105[
1106 ac_cv_pthread_is_default=yes
1107 ac_cv_kthread=no
1108 ac_cv_pthread=no
1109],
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00001110 ac_cv_pthread_is_default=no,
1111 ac_cv_pthread_is_default=no)
1112])
1113AC_MSG_RESULT($ac_cv_pthread_is_default)
1114
1115
1116if test $ac_cv_pthread_is_default = yes
1117then
1118 ac_cv_kpthread=no
1119else
Martin v. Löwis130fb172001-07-19 11:00:41 +00001120# -Kpthread, if available, provides the right #defines
1121# and linker options to make pthread_create available
Martin v. Löwis260aecc2001-10-07 08:14:41 +00001122# Some compilers won't report that they do not support -Kpthread,
1123# so we need to run a program to see whether it really made the
1124# function available.
Martin v. Löwis130fb172001-07-19 11:00:41 +00001125AC_MSG_CHECKING(whether $CC accepts -Kpthread)
1126AC_CACHE_VAL(ac_cv_kpthread,
1127[ac_save_cc="$CC"
1128CC="$CC -Kpthread"
Martin v. Löwis260aecc2001-10-07 08:14:41 +00001129AC_TRY_RUN([
1130#include <pthread.h>
1131
1132void* routine(void* p){return NULL;}
1133
1134int main(){
1135 pthread_t p;
1136 if(pthread_create(&p,NULL,routine,NULL)!=0)
1137 return 1;
Jack Jansen4f8d0542002-03-08 13:43:01 +00001138 (void)pthread_detach(p);
Martin v. Löwis260aecc2001-10-07 08:14:41 +00001139 return 0;
1140}
1141],
Martin v. Löwis130fb172001-07-19 11:00:41 +00001142 ac_cv_kpthread=yes,
Martin v. Löwis260aecc2001-10-07 08:14:41 +00001143 ac_cv_kpthread=no,
Martin v. Löwis130fb172001-07-19 11:00:41 +00001144 ac_cv_kpthread=no)
1145CC="$ac_save_cc"])
Martin v. Löwis130fb172001-07-19 11:00:41 +00001146AC_MSG_RESULT($ac_cv_kpthread)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00001147fi
Martin v. Löwis130fb172001-07-19 11:00:41 +00001148
Skip Montanarod8d39a02003-07-10 20:44:10 +00001149if test $ac_cv_kpthread = no -a $ac_cv_pthread_is_default = no
Martin v. Löwis5f433f02003-05-05 05:05:30 +00001150then
1151# -Kthread, if available, provides the right #defines
1152# and linker options to make pthread_create available
1153# Some compilers won't report that they do not support -Kthread,
1154# so we need to run a program to see whether it really made the
1155# function available.
1156AC_MSG_CHECKING(whether $CC accepts -Kthread)
1157AC_CACHE_VAL(ac_cv_kthread,
1158[ac_save_cc="$CC"
1159CC="$CC -Kthread"
1160AC_TRY_RUN([
1161#include <pthread.h>
1162
1163void* routine(void* p){return NULL;}
1164
1165int main(){
1166 pthread_t p;
1167 if(pthread_create(&p,NULL,routine,NULL)!=0)
1168 return 1;
1169 (void)pthread_detach(p);
1170 return 0;
1171}
1172],
1173 ac_cv_kthread=yes,
1174 ac_cv_kthread=no,
1175 ac_cv_kthread=no)
1176CC="$ac_save_cc"])
1177AC_MSG_RESULT($ac_cv_kthread)
1178fi
1179
Skip Montanarod8d39a02003-07-10 20:44:10 +00001180if test $ac_cv_kthread = no -a $ac_cv_pthread_is_default = no
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00001181then
1182# -pthread, if available, provides the right #defines
1183# and linker options to make pthread_create available
1184# Some compilers won't report that they do not support -pthread,
1185# so we need to run a program to see whether it really made the
1186# function available.
1187AC_MSG_CHECKING(whether $CC accepts -pthread)
1188AC_CACHE_VAL(ac_cv_thread,
1189[ac_save_cc="$CC"
1190CC="$CC -pthread"
1191AC_TRY_RUN([
1192#include <pthread.h>
1193
1194void* routine(void* p){return NULL;}
1195
1196int main(){
1197 pthread_t p;
1198 if(pthread_create(&p,NULL,routine,NULL)!=0)
1199 return 1;
1200 (void)pthread_detach(p);
1201 return 0;
1202}
1203],
1204 ac_cv_pthread=yes,
1205 ac_cv_pthread=no,
1206 ac_cv_pthread=no)
1207CC="$ac_save_cc"])
1208AC_MSG_RESULT($ac_cv_pthread)
1209fi
1210
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001211# If we have set a CC compiler flag for thread support then
1212# check if it works for CXX, too.
1213ac_cv_cxx_thread=no
1214if test ! -z "$CXX"
1215then
1216AC_MSG_CHECKING(whether $CXX also accepts flags for thread support)
1217ac_save_cxx="$CXX"
1218
1219if test "$ac_cv_kpthread" = "yes"
1220then
Martin v. Löwis519adae2003-09-20 10:47:47 +00001221 CXX="$CXX -Kpthread"
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001222 ac_cv_cxx_thread=yes
1223elif test "$ac_cv_kthread" = "yes"
1224then
1225 CXX="$CXX -Kthread"
1226 ac_cv_cxx_thread=yes
1227elif test "$ac_cv_pthread" = "yes"
1228then
1229 CXX="$CXX -pthread"
1230 ac_cv_cxx_thread=yes
1231fi
1232
1233if test $ac_cv_cxx_thread = yes
1234then
1235 echo 'void foo();int main(){foo();}void foo(){}' > conftest.$ac_ext
1236 $CXX -c conftest.$ac_ext 2>&5
1237 if $CXX -o conftest$ac_exeext conftest.$ac_objext 2>&5 \
1238 && test -s conftest$ac_exeext && ./conftest$ac_exeext
1239 then
1240 ac_cv_cxx_thread=yes
1241 else
1242 ac_cv_cxx_thread=no
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001243 fi
1244 rm -fr conftest*
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001245fi
Brett Cannonc601e0f2004-11-07 01:24:12 +00001246AC_MSG_RESULT($ac_cv_cxx_thread)
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001247fi
Martin v. Löwis519adae2003-09-20 10:47:47 +00001248CXX="$ac_save_cxx"
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001249
Fred Drakece81d592000-07-09 14:39:29 +00001250dnl # check for ANSI or K&R ("traditional") preprocessor
1251dnl AC_MSG_CHECKING(for C preprocessor type)
1252dnl AC_TRY_COMPILE([
1253dnl #define spam(name, doc) {#name, &name, #name "() -- " doc}
1254dnl int foo;
1255dnl struct {char *name; int *addr; char *doc;} desc = spam(foo, "something");
1256dnl ], [;], cpp_type=ansi, AC_DEFINE(HAVE_OLD_CPP) cpp_type=traditional)
1257dnl AC_MSG_RESULT($cpp_type)
Guido van Rossum300fda71996-08-19 21:58:16 +00001258
Guido van Rossum627b2d71993-12-24 10:39:16 +00001259# checks for header files
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001260AC_HEADER_STDC
Thomas Wouters0e3f5912006-08-11 14:57:12 +00001261AC_CHECK_HEADERS(asm/types.h conio.h curses.h direct.h dlfcn.h errno.h \
1262fcntl.h grp.h \
Christian Heimesbbe741d2008-03-28 10:53:29 +00001263ieeefp.h io.h langinfo.h libintl.h ncurses.h poll.h process.h pthread.h \
Thomas Wouters89f507f2006-12-13 04:49:30 +00001264shadow.h signal.h stdint.h stropts.h termios.h thread.h \
Martin v. Löwis14e73b12003-01-01 09:51:12 +00001265unistd.h utime.h \
Christian Heimes4fbc72b2008-03-22 00:47:35 +00001266sys/audioio.h sys/bsdtty.h sys/epoll.h sys/event.h sys/file.h sys/loadavg.h \
1267sys/lock.h sys/mkdev.h sys/modem.h \
Thomas Wouters0e3f5912006-08-11 14:57:12 +00001268sys/param.h sys/poll.h sys/select.h sys/socket.h sys/statvfs.h sys/stat.h \
Georg Brandlf78e02b2008-06-10 17:40:04 +00001269sys/termio.h sys/time.h \
Thomas Wouters0e3f5912006-08-11 14:57:12 +00001270sys/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 +00001271sys/resource.h netpacket/packet.h sysexits.h bluetooth.h \
Ronald Oussoren755740f2010-02-07 19:56:39 +00001272bluetooth/bluetooth.h linux/tipc.h spawn.h util.h)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001273AC_HEADER_DIRENT
Martin v. Löwisdbe3f762002-10-10 14:27:30 +00001274AC_HEADER_MAJOR
Guido van Rossum627b2d71993-12-24 10:39:16 +00001275
Martin v. Löwisae2830c2004-09-18 09:54:52 +00001276# On Solaris, term.h requires curses.h
Martin v. Löwisfd1c69e72004-11-30 22:09:37 +00001277AC_CHECK_HEADERS(term.h,,,[
Martin v. Löwis5d52e782004-09-18 10:07:03 +00001278#ifdef HAVE_CURSES_H
1279#include <curses.h>
1280#endif
1281])
Martin v. Löwisae2830c2004-09-18 09:54:52 +00001282
Martin v. Löwis11017b12006-01-14 18:12:57 +00001283# On Linux, netlink.h requires asm/types.h
1284AC_CHECK_HEADERS(linux/netlink.h,,,[
1285#ifdef HAVE_ASM_TYPES_H
1286#include <asm/types.h>
1287#endif
1288#ifdef HAVE_SYS_SOCKET_H
1289#include <sys/socket.h>
1290#endif
1291])
1292
Guido van Rossum627b2d71993-12-24 10:39:16 +00001293# checks for typedefs
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001294was_it_defined=no
1295AC_MSG_CHECKING(for clock_t in time.h)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001296AC_EGREP_HEADER(clock_t, time.h, was_it_defined=yes, [
1297 AC_DEFINE(clock_t, long, [Define to 'long' if <time.h> doesn't define.])
1298])
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001299AC_MSG_RESULT($was_it_defined)
1300
Neal Norwitz11690112002-07-30 01:08:28 +00001301# Check whether using makedev requires defining _OSF_SOURCE
1302AC_MSG_CHECKING(for makedev)
Neal Norwitz6eb37f02003-02-23 23:28:15 +00001303AC_TRY_LINK([#include <sys/types.h> ],
Neal Norwitz11690112002-07-30 01:08:28 +00001304 [ makedev(0, 0) ],
1305 ac_cv_has_makedev=yes,
1306 ac_cv_has_makedev=no)
1307if test "$ac_cv_has_makedev" = "no"; then
1308 # we didn't link, try if _OSF_SOURCE will allow us to link
1309 AC_TRY_LINK([
Neal Norwitz6eb37f02003-02-23 23:28:15 +00001310#define _OSF_SOURCE 1
1311#include <sys/types.h>
Neal Norwitz11690112002-07-30 01:08:28 +00001312 ],
1313 [ makedev(0, 0) ],
1314 ac_cv_has_makedev=yes,
1315 ac_cv_has_makedev=no)
1316 if test "$ac_cv_has_makedev" = "yes"; then
1317 AC_DEFINE(_OSF_SOURCE, 1, [Define _OSF_SOURCE to get the makedev macro.])
1318 fi
1319fi
1320AC_MSG_RESULT($ac_cv_has_makedev)
1321if test "$ac_cv_has_makedev" = "yes"; then
1322 AC_DEFINE(HAVE_MAKEDEV, 1, [Define this if you have the makedev macro.])
1323fi
1324
Martin v. Löwis399a6892002-10-04 10:22:02 +00001325# Enabling LFS on Solaris (2.6 to 9) with gcc 2.95 triggers a bug in
1326# the system headers: If _XOPEN_SOURCE and _LARGEFILE_SOURCE are
1327# defined, but the compiler does not support pragma redefine_extname,
1328# and _LARGEFILE64_SOURCE is not defined, the headers refer to 64-bit
1329# structures (such as rlimit64) without declaring them. As a
1330# work-around, disable LFS on such configurations
1331
1332use_lfs=yes
1333AC_MSG_CHECKING(Solaris LFS bug)
1334AC_TRY_COMPILE([
1335#define _LARGEFILE_SOURCE 1
1336#define _FILE_OFFSET_BITS 64
1337#include <sys/resource.h>
1338],struct rlimit foo;,sol_lfs_bug=no,sol_lfs_bug=yes)
1339AC_MSG_RESULT($sol_lfs_bug)
1340if test "$sol_lfs_bug" = "yes"; then
1341 use_lfs=no
1342fi
1343
1344if test "$use_lfs" = "yes"; then
Guido van Rossum810cc512001-09-09 23:51:39 +00001345# Two defines needed to enable largefile support on various platforms
1346# These may affect some typedefs
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001347AC_DEFINE(_LARGEFILE_SOURCE, 1,
1348[This must be defined on some systems to enable large file support.])
1349AC_DEFINE(_FILE_OFFSET_BITS, 64,
1350[This must be set to 64 on some systems to enable large file support.])
Martin v. Löwis399a6892002-10-04 10:22:02 +00001351fi
Guido van Rossum810cc512001-09-09 23:51:39 +00001352
Guido van Rossum300fda71996-08-19 21:58:16 +00001353# Add some code to confdefs.h so that the test for off_t works on SCO
1354cat >> confdefs.h <<\EOF
1355#if defined(SCO_DS)
1356#undef _OFF_T
1357#endif
1358EOF
1359
Guido van Rossumef2255b2000-03-10 22:30:29 +00001360# Type availability checks
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001361AC_TYPE_MODE_T
1362AC_TYPE_OFF_T
1363AC_TYPE_PID_T
1364AC_TYPE_SIGNAL
1365AC_TYPE_SIZE_T
1366AC_TYPE_UID_T
Mark Dickinsonbd792642009-03-18 20:06:12 +00001367AC_TYPE_UINT32_T
1368AC_TYPE_UINT64_T
1369AC_TYPE_INT32_T
1370AC_TYPE_INT64_T
Christian Heimes400adb02008-02-01 08:12:03 +00001371AC_CHECK_TYPE(ssize_t,
Martin v. Löwis18e16552006-02-15 17:27:45 +00001372 AC_DEFINE(HAVE_SSIZE_T, 1, Define if your compiler provides ssize_t),,)
Guido van Rossum627b2d71993-12-24 10:39:16 +00001373
Guido van Rossumef2255b2000-03-10 22:30:29 +00001374# Sizes of various common basic types
Skip Montanarob9820a32004-01-17 00:16:12 +00001375# ANSI C requires sizeof(char) == 1, so no need to check it
Guido van Rossum3065c942001-09-17 04:03:14 +00001376AC_CHECK_SIZEOF(int, 4)
1377AC_CHECK_SIZEOF(long, 4)
1378AC_CHECK_SIZEOF(void *, 4)
Guido van Rossum3065c942001-09-17 04:03:14 +00001379AC_CHECK_SIZEOF(short, 2)
1380AC_CHECK_SIZEOF(float, 4)
1381AC_CHECK_SIZEOF(double, 8)
1382AC_CHECK_SIZEOF(fpos_t, 4)
Martin v. Löwis18e16552006-02-15 17:27:45 +00001383AC_CHECK_SIZEOF(size_t, 4)
Christian Heimes400adb02008-02-01 08:12:03 +00001384AC_CHECK_SIZEOF(pid_t, 4)
Guido van Rossumac405f61994-09-12 10:56:06 +00001385
Guido van Rossumec95c7b1998-08-04 17:59:56 +00001386AC_MSG_CHECKING(for long long support)
1387have_long_long=no
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001388AC_TRY_COMPILE([], [long long x; x = (long long)0;], [
1389 AC_DEFINE(HAVE_LONG_LONG, 1, [Define this if you have the type long long.])
1390 have_long_long=yes
1391])
Guido van Rossumec95c7b1998-08-04 17:59:56 +00001392AC_MSG_RESULT($have_long_long)
Guido van Rossum8bc1dfd1999-04-10 16:01:48 +00001393if test "$have_long_long" = yes ; then
Guido van Rossum3065c942001-09-17 04:03:14 +00001394AC_CHECK_SIZEOF(long long, 8)
Guido van Rossumec95c7b1998-08-04 17:59:56 +00001395fi
1396
Travis E. Oliphant9b307842007-10-12 22:06:37 +00001397AC_MSG_CHECKING(for long double support)
1398have_long_double=no
1399AC_TRY_COMPILE([], [long double x; x = (long double)0;], [
1400 AC_DEFINE(HAVE_LONG_DOUBLE, 1, [Define this if you have the type long double.])
1401 have_long_double=yes
1402])
1403AC_MSG_RESULT($have_long_double)
1404if test "$have_long_double" = yes ; then
1405AC_CHECK_SIZEOF(long double, 16)
1406fi
1407
1408
Thomas Woutersb2137042007-02-01 18:02:27 +00001409AC_MSG_CHECKING(for _Bool support)
1410have_c99_bool=no
1411AC_TRY_COMPILE([], [_Bool x; x = (_Bool)0;], [
1412 AC_DEFINE(HAVE_C99_BOOL, 1, [Define this if you have the type _Bool.])
1413 have_c99_bool=yes
1414])
1415AC_MSG_RESULT($have_c99_bool)
1416if test "$have_c99_bool" = yes ; then
1417AC_CHECK_SIZEOF(_Bool, 1)
1418fi
1419
Thomas Wouters89f507f2006-12-13 04:49:30 +00001420AC_CHECK_TYPES(uintptr_t,
1421 [AC_CHECK_SIZEOF(uintptr_t, 4)],
1422 [], [#ifdef HAVE_STDINT_H
1423 #include <stdint.h>
1424 #endif])
1425
Alexandre Vassalotti0805b4a2009-07-17 05:47:33 +00001426AC_CHECK_SIZEOF(off_t, [], [
1427#ifdef HAVE_SYS_TYPES_H
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001428#include <sys/types.h>
Alexandre Vassalotti0805b4a2009-07-17 05:47:33 +00001429#endif
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001430])
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001431
1432AC_MSG_CHECKING(whether to enable large file support)
Mark Dickinson2df5d282009-12-31 21:22:50 +00001433if test "$have_long_long" = yes
1434then
1435if test "$ac_cv_sizeof_off_t" -gt "$ac_cv_sizeof_long" -a \
Guido van Rossum8bc1dfd1999-04-10 16:01:48 +00001436 "$ac_cv_sizeof_long_long" -ge "$ac_cv_sizeof_off_t"; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001437 AC_DEFINE(HAVE_LARGEFILE_SUPPORT, 1,
1438 [Defined to enable large file support when an off_t is bigger than a long
1439 and long long is available and at least as big as an off_t. You may need
1440 to add some flags for configuration and compilation to enable this mode.
1441 (For Solaris and Linux, the necessary defines are already defined.)])
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001442 AC_MSG_RESULT(yes)
1443else
1444 AC_MSG_RESULT(no)
1445fi
Mark Dickinson2df5d282009-12-31 21:22:50 +00001446else
1447 AC_MSG_RESULT(no)
1448fi
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001449
Alexandre Vassalotti0805b4a2009-07-17 05:47:33 +00001450AC_CHECK_SIZEOF(time_t, [], [
1451#ifdef HAVE_SYS_TYPES_H
1452#include <sys/types.h>
1453#endif
1454#ifdef HAVE_TIME_H
Fred Drakea3f6e912000-06-29 20:44:47 +00001455#include <time.h>
Alexandre Vassalotti0805b4a2009-07-17 05:47:33 +00001456#endif
Fred Drakea3f6e912000-06-29 20:44:47 +00001457])
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001458
Trent Mick635f6fb2000-08-23 21:33:05 +00001459# if have pthread_t then define SIZEOF_PTHREAD_T
Martin v. Löwis123cbd22001-07-19 14:21:10 +00001460ac_save_cc="$CC"
1461if test "$ac_cv_kpthread" = "yes"
1462then CC="$CC -Kpthread"
Martin v. Löwis5f433f02003-05-05 05:05:30 +00001463elif test "$ac_cv_kthread" = "yes"
1464then CC="$CC -Kthread"
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00001465elif test "$ac_cv_pthread" = "yes"
1466then CC="$CC -pthread"
Martin v. Löwis123cbd22001-07-19 14:21:10 +00001467fi
Alexandre Vassalotti0805b4a2009-07-17 05:47:33 +00001468
Trent Mick635f6fb2000-08-23 21:33:05 +00001469AC_MSG_CHECKING(for pthread_t)
1470have_pthread_t=no
Guido van Rossum12580492000-09-24 16:47:19 +00001471AC_TRY_COMPILE([#include <pthread.h>], [pthread_t x; x = *(pthread_t*)0;], have_pthread_t=yes)
Trent Mick635f6fb2000-08-23 21:33:05 +00001472AC_MSG_RESULT($have_pthread_t)
1473if test "$have_pthread_t" = yes ; then
Alexandre Vassalotti0805b4a2009-07-17 05:47:33 +00001474 AC_CHECK_SIZEOF(pthread_t, [], [
1475#ifdef HAVE_PTHREAD_H
Neal Norwitz6eb37f02003-02-23 23:28:15 +00001476#include <pthread.h>
Alexandre Vassalotti0805b4a2009-07-17 05:47:33 +00001477#endif
Trent Mick635f6fb2000-08-23 21:33:05 +00001478 ])
Trent Mick635f6fb2000-08-23 21:33:05 +00001479fi
Martin v. Löwis123cbd22001-07-19 14:21:10 +00001480CC="$ac_save_cc"
Trent Mick635f6fb2000-08-23 21:33:05 +00001481
Bob Ippolito7026a0a2005-03-28 23:23:47 +00001482AC_SUBST(OTHER_LIBTOOL_OPT)
1483case $ac_sys_system/$ac_sys_release in
Thomas Wouters49fd7fa2006-04-21 10:40:58 +00001484 Darwin/@<:@01567@:>@\..*)
Bob Ippolito7026a0a2005-03-28 23:23:47 +00001485 OTHER_LIBTOOL_OPT="-prebind -seg1addr 0x10000000"
1486 ;;
1487 Darwin/*)
1488 OTHER_LIBTOOL_OPT=""
1489 ;;
1490esac
1491
Ronald Oussoren5bbab3e2009-09-06 11:01:15 +00001492
1493ARCH_RUN_32BIT=""
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001494AC_SUBST(LIBTOOL_CRUFT)
1495case $ac_sys_system/$ac_sys_release in
Thomas Wouters49fd7fa2006-04-21 10:40:58 +00001496 Darwin/@<:@01567@:>@\..*)
Thomas Wouters477c8d52006-05-27 19:21:47 +00001497 LIBTOOL_CRUFT="-framework System -lcc_dynamic"
1498 if test "${enable_universalsdk}"; then
1499 :
1500 else
Ronald Oussorene3da75a2010-02-11 13:38:58 +00001501 LIBTOOL_CRUFT="${LIBTOOL_CRUFT} -arch_only `/usr/bin/arch`"
Thomas Wouters477c8d52006-05-27 19:21:47 +00001502 fi
Jack Jansenb36687a2004-07-16 08:43:47 +00001503 LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -install_name $(PYTHONFRAMEWORKINSTALLDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansena3891ea2001-09-07 14:25:12 +00001504 LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -compatibility_version $(VERSION) -current_version $(VERSION)';;
Guido van Rossum5839e582000-10-09 19:52:35 +00001505 Darwin/*)
Ronald Oussoren9812a6c2010-02-07 11:53:18 +00001506 gcc_version=`gcc -dumpversion`
Bob Ippolito7026a0a2005-03-28 23:23:47 +00001507 if test ${gcc_version} '<' 4.0
1508 then
1509 LIBTOOL_CRUFT="-lcc_dynamic"
1510 else
1511 LIBTOOL_CRUFT=""
1512 fi
Ronald Oussoren3c064c12009-09-08 07:12:42 +00001513 AC_TRY_RUN([
Ronald Oussoren5bbab3e2009-09-06 11:01:15 +00001514 #include <unistd.h>
1515 int main(int argc, char*argv[])
1516 {
1517 if (sizeof(long) == 4) {
1518 return 0;
1519 } else {
1520 return 1;
1521 }
Ronald Oussoren3c064c12009-09-08 07:12:42 +00001522 }
1523 ], ac_osx_32bit=yes,
Ronald Oussoren5bbab3e2009-09-06 11:01:15 +00001524 ac_osx_32bit=no,
Ronald Oussoren3c064c12009-09-08 07:12:42 +00001525 ac_osx_32bit=yes)
Ronald Oussoren5bbab3e2009-09-06 11:01:15 +00001526
1527 if test "${ac_osx_32bit}" = "yes"; then
Ronald Oussorene3da75a2010-02-11 13:38:58 +00001528 case `/usr/bin/arch` in
Ronald Oussoren5bbab3e2009-09-06 11:01:15 +00001529 i386)
1530 MACOSX_DEFAULT_ARCH="i386"
1531 ;;
1532 ppc)
1533 MACOSX_DEFAULT_ARCH="ppc"
1534 ;;
1535 *)
1536 AC_MSG_ERROR([Unexpected output of 'arch' on OSX])
1537 ;;
1538 esac
1539 else
Ronald Oussorene3da75a2010-02-11 13:38:58 +00001540 case `/usr/bin/arch` in
Ronald Oussoren5bbab3e2009-09-06 11:01:15 +00001541 i386)
1542 MACOSX_DEFAULT_ARCH="x86_64"
1543 ;;
1544 ppc)
1545 MACOSX_DEFAULT_ARCH="ppc64"
1546 ;;
1547 *)
1548 AC_MSG_ERROR([Unexpected output of 'arch' on OSX])
1549 ;;
1550 esac
1551
1552 #ARCH_RUN_32BIT="true"
1553 fi
1554
1555 LIBTOOL_CRUFT=$LIBTOOL_CRUFT" -lSystem -lSystemStubs -arch_only ${MACOSX_DEFAULT_ARCH}"
Jack Jansenb36687a2004-07-16 08:43:47 +00001556 LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -install_name $(PYTHONFRAMEWORKINSTALLDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001557 LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -compatibility_version $(VERSION) -current_version $(VERSION)';;
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001558esac
1559
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001560AC_MSG_CHECKING(for --enable-framework)
1561if test "$enable_framework"
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001562then
Skip Montanarodecc6a42003-01-01 20:07:49 +00001563 BASECFLAGS="$BASECFLAGS -fno-common -dynamic"
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001564 # -F. is needed to allow linking to the framework while
1565 # in the build location.
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001566 AC_DEFINE(WITH_NEXT_FRAMEWORK, 1,
1567 [Define if you want to produce an OpenStep/Rhapsody framework
1568 (shared library plus accessory files).])
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001569 AC_MSG_RESULT(yes)
Ronald Oussoren99aab652009-06-08 21:22:57 +00001570 if test $enable_shared = "yes"
1571 then
1572 AC_MSG_ERROR([Specifying both --enable-shared and --enable-framework is not supported, use only --enable-framework instead])
1573 fi
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001574else
1575 AC_MSG_RESULT(no)
1576fi
1577
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001578AC_MSG_CHECKING(for dyld)
Jack Jansen9a66b6d2001-08-08 13:56:14 +00001579case $ac_sys_system/$ac_sys_release in
1580 Darwin/*)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001581 AC_DEFINE(WITH_DYLD, 1,
1582 [Define if you want to use the new-style (Openstep, Rhapsody, MacOS)
1583 dynamic linker (dyld) instead of the old-style (NextStep) dynamic
1584 linker (rld). Dyld is necessary to support frameworks.])
Jack Jansen9a66b6d2001-08-08 13:56:14 +00001585 AC_MSG_RESULT(always on for Darwin)
1586 ;;
1587 *)
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001588 AC_MSG_RESULT(no)
1589 ;;
Jack Jansen9a66b6d2001-08-08 13:56:14 +00001590esac
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001591
Guido van Rossumac405f61994-09-12 10:56:06 +00001592# Set info about shared libraries.
Guido van Rossumac405f61994-09-12 10:56:06 +00001593AC_SUBST(SO)
1594AC_SUBST(LDSHARED)
Tarek Ziadé03d788d2010-04-03 08:46:49 +00001595AC_SUBST(LDCXXSHARED)
Neil Schemenauerb3531b82001-02-16 04:09:05 +00001596AC_SUBST(BLDSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00001597AC_SUBST(CCSHARED)
1598AC_SUBST(LINKFORSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00001599# SO is the extension of shared libraries `(including the dot!)
Guido van Rossumaef734b2001-01-10 21:09:12 +00001600# -- usually .so, .sl on HP-UX, .dll on Cygwin
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001601AC_MSG_CHECKING(SO)
Guido van Rossumac405f61994-09-12 10:56:06 +00001602if test -z "$SO"
1603then
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001604 case $ac_sys_system in
Thomas Wouters477c8d52006-05-27 19:21:47 +00001605 hp*|HP*)
1606 case `uname -m` in
1607 ia64) SO=.so;;
1608 *) SO=.sl;;
1609 esac
1610 ;;
Guido van Rossumaef734b2001-01-10 21:09:12 +00001611 CYGWIN*) SO=.dll;;
Guido van Rossum4b6b5791996-09-09 20:09:34 +00001612 *) SO=.so;;
Guido van Rossumac405f61994-09-12 10:56:06 +00001613 esac
Martin v. Löwis368de8f2003-06-14 14:46:38 +00001614else
1615 # this might also be a termcap variable, see #610332
1616 echo
1617 echo '====================================================================='
1618 echo '+ +'
1619 echo '+ WARNING: You have set SO in your environment. +'
1620 echo '+ Do you really mean to change the extension for shared libraries? +'
1621 echo '+ Continuing in 10 seconds to let you to ponder. +'
1622 echo '+ +'
1623 echo '====================================================================='
1624 sleep 10
Guido van Rossumac405f61994-09-12 10:56:06 +00001625fi
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001626AC_MSG_RESULT($SO)
Georg Brandlb1441c72009-01-03 22:33:39 +00001627
Thomas Wouters477c8d52006-05-27 19:21:47 +00001628AC_DEFINE_UNQUOTED(SHLIB_EXT, "$SO", [Define this to be extension of shared libraries (including the dot!).])
Guido van Rossumac405f61994-09-12 10:56:06 +00001629# LDSHARED is the ld *command* used to create shared library
Skip Montanaroce59c042004-01-17 14:19:44 +00001630# -- "cc -G" on SunOS 5.x, "ld -shared" on IRIX 5
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001631# (Shared libraries in this instance are shared modules to be loaded into
1632# Python, as opposed to building Python itself as a shared library.)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001633AC_MSG_CHECKING(LDSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00001634if test -z "$LDSHARED"
1635then
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001636 case $ac_sys_system/$ac_sys_release in
Neil Schemenauerb3531b82001-02-16 04:09:05 +00001637 AIX*)
1638 BLDSHARED="\$(srcdir)/Modules/ld_so_aix \$(CC) -bI:Modules/python.exp"
Guido van Rossumce608b02001-09-28 15:59:38 +00001639 LDSHARED="\$(BINLIBDEST)/config/ld_so_aix \$(CC) -bI:\$(BINLIBDEST)/config/python.exp"
Neil Schemenauerb3531b82001-02-16 04:09:05 +00001640 ;;
Guido van Rossum6100aaf1997-04-29 21:48:51 +00001641 IRIX/5*) LDSHARED="ld -shared";;
Guido van Rossum91922671997-10-09 20:24:13 +00001642 IRIX*/6*) LDSHARED="ld ${SGI_ABI} -shared -all";;
Greg Ward57c9a6632000-05-26 12:22:54 +00001643 SunOS/5*)
Tarek Ziadé03d788d2010-04-03 08:46:49 +00001644 if test "$GCC" = "yes" ; then
1645 LDSHARED='$(CC) -shared'
1646 LDCXXSHARED='$(CXX) -shared'
1647 else
1648 LDSHARED='$(CC) -G'
1649 LDCXXSHARED='$(CXX) -G'
Greg Ward57c9a6632000-05-26 12:22:54 +00001650 fi ;;
Thomas Hellerf44b9a12008-04-04 10:18:23 +00001651 hp*|HP*)
Tarek Ziadé03d788d2010-04-03 08:46:49 +00001652 if test "$GCC" = "yes" ; then
1653 LDSHARED='$(CC) -shared'
1654 LDCXXSHARED='$(CXX) -shared'
1655 else
1656 LDSHARED='ld -b'
Thomas Hellerf44b9a12008-04-04 10:18:23 +00001657 fi ;;
Guido van Rossum71001e41995-01-26 00:44:03 +00001658 OSF*) LDSHARED="ld -shared -expect_unresolved \"*\"";;
Jack Jansen418c3b12001-11-14 10:59:57 +00001659 Darwin/1.3*)
Jack Jansena3891ea2001-09-07 14:25:12 +00001660 LDSHARED='$(CC) $(LDFLAGS) -bundle'
Tarek Ziadé03d788d2010-04-03 08:46:49 +00001661 LDCXXSHARED='$(CXX) $(LDFLAGS) -bundle'
Jack Jansena3891ea2001-09-07 14:25:12 +00001662 if test "$enable_framework" ; then
1663 # Link against the framework. All externals should be defined.
Jack Jansenda49e192005-01-07 13:08:22 +00001664 BLDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
1665 LDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Tarek Ziadé03d788d2010-04-03 08:46:49 +00001666 LDCXXSHARED="$LDCXXSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansena3891ea2001-09-07 14:25:12 +00001667 else
1668 # No framework. Ignore undefined symbols, assuming they come from Python
Jack Jansen418c3b12001-11-14 10:59:57 +00001669 LDSHARED="$LDSHARED -undefined suppress"
Tarek Ziadé03d788d2010-04-03 08:46:49 +00001670 LDCXXSHARED="$LDCXXSHARED -undefined suppress"
Jack Jansena3891ea2001-09-07 14:25:12 +00001671 fi ;;
Jack Jansen6b08a402004-06-03 12:41:45 +00001672 Darwin/1.4*|Darwin/5.*|Darwin/6.*)
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001673 LDSHARED='$(CC) $(LDFLAGS) -bundle'
Tarek Ziadé03d788d2010-04-03 08:46:49 +00001674 LDCXXSHARED='$(CXX) $(LDFLAGS) -bundle'
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001675 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)'
Tarek Ziadé03d788d2010-04-03 08:46:49 +00001679 LDCXXSHARED="$LDCXXSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001680 else
Michael W. Hudson0c46c0c2002-03-07 09:58:56 +00001681 # No framework, use the Python app as bundle-loader
1682 BLDSHARED="$LDSHARED "'-bundle_loader $(BUILDPYTHON)'
Jack Jansenc28fc372003-02-25 13:14:43 +00001683 LDSHARED="$LDSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)'
Tarek Ziadé03d788d2010-04-03 08:46:49 +00001684 LDCXXSHARED="$LDCXXSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)'
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001685 fi ;;
Jack Jansen6b08a402004-06-03 12:41:45 +00001686 Darwin/*)
1687 # Use -undefined dynamic_lookup whenever possible (10.3 and later).
1688 # This allows an extension to be used in any Python
Thomas Wouters89d996e2007-09-08 17:39:28 +00001689
Georg Brandlfcaf9102008-07-16 02:17:56 +00001690 if test ${MACOSX_DEPLOYMENT_TARGET} '>' 10.2
Jack Jansen6b08a402004-06-03 12:41:45 +00001691 then
Thomas Wouters477c8d52006-05-27 19:21:47 +00001692 if test "${enable_universalsdk}"; then
Georg Brandlfcaf9102008-07-16 02:17:56 +00001693 LDFLAGS="${UNIVERSAL_ARCH_FLAGS} -isysroot ${UNIVERSALSDK} ${LDFLAGS}"
Thomas Wouters477c8d52006-05-27 19:21:47 +00001694 fi
Jack Jansen6b08a402004-06-03 12:41:45 +00001695 LDSHARED='$(CC) $(LDFLAGS) -bundle -undefined dynamic_lookup'
Tarek Ziadé03d788d2010-04-03 08:46:49 +00001696 LDCXXSHARED='$(CXX) $(LDFLAGS) -bundle -undefined dynamic_lookup'
Jack Jansen6b08a402004-06-03 12:41:45 +00001697 BLDSHARED="$LDSHARED"
Jack Jansen6b08a402004-06-03 12:41:45 +00001698 else
1699 LDSHARED='$(CC) $(LDFLAGS) -bundle'
Tarek Ziadé03d788d2010-04-03 08:46:49 +00001700 LDCXXSHARED='$(CXX) $(LDFLAGS) -bundle'
Jack Jansen6b08a402004-06-03 12:41:45 +00001701 if test "$enable_framework" ; then
1702 # Link against the framework. All externals should be defined.
Jack Jansenda49e192005-01-07 13:08:22 +00001703 BLDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
1704 LDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Tarek Ziadé03d788d2010-04-03 08:46:49 +00001705 LDCXXSHARED="$LDCXXSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansen6b08a402004-06-03 12:41:45 +00001706 else
1707 # No framework, use the Python app as bundle-loader
1708 BLDSHARED="$LDSHARED "'-bundle_loader $(BUILDPYTHON)'
1709 LDSHARED="$LDSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)'
Tarek Ziadé03d788d2010-04-03 08:46:49 +00001710 LDCXXSHARED="$LDCXXSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)'
Jack Jansen6b08a402004-06-03 12:41:45 +00001711 fi
1712 fi
1713 ;;
Tarek Ziadé03d788d2010-04-03 08:46:49 +00001714 Linux*|GNU*|QNX*)
1715 LDSHARED='$(CC) -shared'
1716 LDCXXSHARED='$(CXX) -shared';;
1717 BSD/OS*/4*)
1718 LDSHARED="gcc -shared"
1719 LDCXXSHARED="g++ -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
Benjamin Petersonab0a7522010-03-14 15:18:25 +00001723 LDSHARED='$(CC) -shared ${LDFLAGS}'
Tarek Ziadé03d788d2010-04-03 08:46:49 +00001724 LDCXXSHARED='$(CXX) -shared ${LDFLAGS}'
Guido van Rossum0286ae82000-08-29 15:06:49 +00001725 else
1726 LDSHARED="ld -Bshareable ${LDFLAGS}"
1727 fi;;
Thomas Wouters1ba5b3b2006-06-08 14:52:47 +00001728 OpenBSD*)
1729 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
1730 then
1731 LDSHARED='$(CC) -shared $(CCSHARED) ${LDFLAGS}'
Tarek Ziadé03d788d2010-04-03 08:46:49 +00001732 LDCXXSHARED='$(CXX) -shared $(CCSHARED) ${LDFLAGS}'
Thomas Wouters1ba5b3b2006-06-08 14:52:47 +00001733 else
1734 case `uname -r` in
1735 [[01]].* | 2.[[0-7]] | 2.[[0-7]].*)
1736 LDSHARED="ld -Bshareable ${LDFLAGS}"
1737 ;;
1738 *)
1739 LDSHARED='$(CC) -shared $(CCSHARED) ${LDFLAGS}'
Tarek Ziadé03d788d2010-04-03 08:46:49 +00001740 LDCXXSHARED='$(CXX) -shared $(CCSHARED) ${LDFLAGS}'
Thomas Wouters1ba5b3b2006-06-08 14:52:47 +00001741 ;;
1742 esac
1743 fi;;
Tarek Ziadé03d788d2010-04-03 08:46:49 +00001744 NetBSD*|DragonFly*)
1745 LDSHARED="cc -shared ${LDFLAGS}"
1746 LDCXXSHARED="c++ -shared ${LDFLAGS}";;
Martin v. Löwis25ae43b2001-10-07 08:39:18 +00001747 OpenUNIX*|UnixWare*)
Tarek Ziadé03d788d2010-04-03 08:46:49 +00001748 if test "$GCC" = "yes" ; then
1749 LDSHARED='$(CC) -shared'
1750 LDCXXSHARED='$(CXX) -shared'
1751 else
1752 LDSHARED='$(CC) -G'
1753 LDCXXSHARED='$(CXX) -G'
Martin v. Löwisbec19582001-03-21 15:57:54 +00001754 fi;;
Tarek Ziadé03d788d2010-04-03 08:46:49 +00001755 SCO_SV*)
1756 LDSHARED='$(CC) -Wl,-G,-Bexport'
1757 LDCXXSHARED='$(CXX) -Wl,-G,-Bexport';;
1758 CYGWIN*)
1759 LDSHARED="gcc -shared -Wl,--enable-auto-image-base"
1760 LDCXXSHARED="g++ -shared -Wl,--enable-auto-image-base";;
Guido van Rossumac405f61994-09-12 10:56:06 +00001761 *) LDSHARED="ld";;
1762 esac
Guido van Rossumac405f61994-09-12 10:56:06 +00001763fi
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001764AC_MSG_RESULT($LDSHARED)
Tarek Ziadé03d788d2010-04-03 08:46:49 +00001765LDCXXSHARED=${LDCXXSHARED-$LDSHARED}
Neil Schemenauerb3531b82001-02-16 04:09:05 +00001766BLDSHARED=${BLDSHARED-$LDSHARED}
Guido van Rossumac405f61994-09-12 10:56:06 +00001767# CCSHARED are the C *flags* used to create objects to go into a shared
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001768# library (module) -- this is only needed for a few systems
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001769AC_MSG_CHECKING(CCSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00001770if test -z "$CCSHARED"
1771then
Guido van Rossum6100aaf1997-04-29 21:48:51 +00001772 case $ac_sys_system/$ac_sys_release in
Neil Schemenauer66252162001-02-19 04:47:42 +00001773 SunOS*) if test "$GCC" = yes;
Guido van Rossumd8faa362007-04-27 19:54:29 +00001774 then CCSHARED="-fPIC";
1775 elif test `uname -p` = sparc;
1776 then CCSHARED="-xcode=pic32";
1777 else CCSHARED="-Kpic";
1778 fi;;
Guido van Rossumaf07a441995-02-13 19:45:27 +00001779 hp*|HP*) if test "$GCC" = yes;
Martin v. Löwis703ad702001-09-05 08:36:52 +00001780 then CCSHARED="-fPIC";
Guido van Rossumaf07a441995-02-13 19:45:27 +00001781 else CCSHARED="+z";
1782 fi;;
Martin v. Löwisa6e97582002-01-01 18:41:33 +00001783 Linux*|GNU*) CCSHARED="-fPIC";;
Guido van Rossumf5957ea1999-10-05 21:59:33 +00001784 BSD/OS*/4*) CCSHARED="-fpic";;
Martin v. Löwis86d66262006-02-17 08:40:11 +00001785 FreeBSD*|NetBSD*|OpenBSD*|DragonFly*) CCSHARED="-fPIC";;
Martin v. Löwis25ae43b2001-10-07 08:39:18 +00001786 OpenUNIX*|UnixWare*)
Martin v. Löwisbec19582001-03-21 15:57:54 +00001787 if test "$GCC" = "yes"
1788 then CCSHARED="-fPIC"
Martin v. Löwis130fb172001-07-19 11:00:41 +00001789 else CCSHARED="-KPIC"
Martin v. Löwisbec19582001-03-21 15:57:54 +00001790 fi;;
Martin v. Löwis21ee4092002-09-30 16:19:48 +00001791 SCO_SV*)
1792 if test "$GCC" = "yes"
1793 then CCSHARED="-fPIC"
1794 else CCSHARED="-Kpic -belf"
1795 fi;;
Guido van Rossum2b5ca001998-03-05 15:41:09 +00001796 IRIX*/6*) case $CC in
1797 *gcc*) CCSHARED="-shared";;
Guido van Rossumee21f411998-04-20 18:51:54 +00001798 *) CCSHARED="";;
Guido van Rossum2b5ca001998-03-05 15:41:09 +00001799 esac;;
Guido van Rossumac405f61994-09-12 10:56:06 +00001800 esac
Guido van Rossumac405f61994-09-12 10:56:06 +00001801fi
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001802AC_MSG_RESULT($CCSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00001803# LINKFORSHARED are the flags passed to the $(CC) command that links
Guido van Rossumb65a48e1995-06-14 18:21:23 +00001804# the python executable -- this is only needed for a few systems
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001805AC_MSG_CHECKING(LINKFORSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00001806if test -z "$LINKFORSHARED"
1807then
Guido van Rossum6100aaf1997-04-29 21:48:51 +00001808 case $ac_sys_system/$ac_sys_release in
Neil Schemenauerb3531b82001-02-16 04:09:05 +00001809 AIX*) LINKFORSHARED='-Wl,-bE:Modules/python.exp -lld';;
Guido van Rossum5dab3d81996-12-06 21:18:18 +00001810 hp*|HP*)
Martin v. Löwis1142de32002-03-29 16:28:31 +00001811 LINKFORSHARED="-Wl,-E -Wl,+s";;
1812# LINKFORSHARED="-Wl,-E -Wl,+s -Wl,+b\$(BINLIBDEST)/lib-dynload";;
Guido van Rossumf5957ea1999-10-05 21:59:33 +00001813 BSD/OS/4*) LINKFORSHARED="-Xlinker -export-dynamic";;
Martin v. Löwisa6e97582002-01-01 18:41:33 +00001814 Linux*|GNU*) LINKFORSHARED="-Xlinker -export-dynamic";;
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001815 # -u libsys_s pulls in all symbols in libsys
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001816 Darwin/*)
Benjamin Peterson9c80cac2009-05-23 16:34:23 +00001817 LINKFORSHARED="$extra_undefs -framework CoreFoundation"
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001818 if test "$enable_framework"
1819 then
Jack Jansenda49e192005-01-07 13:08:22 +00001820 LINKFORSHARED="$LINKFORSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001821 fi
Raymond Hettingerec6eb362004-11-05 07:02:59 +00001822 LINKFORSHARED="$LINKFORSHARED";;
Martin v. Löwis25ae43b2001-10-07 08:39:18 +00001823 OpenUNIX*|UnixWare*) LINKFORSHARED="-Wl,-Bexport";;
Martin v. Löwis21ee4092002-09-30 16:19:48 +00001824 SCO_SV*) LINKFORSHARED="-Wl,-Bexport";;
Fred Drake02706f52000-09-25 15:08:46 +00001825 ReliantUNIX*) LINKFORSHARED="-W1 -Blargedynsym";;
Martin v. Löwis86d66262006-02-17 08:40:11 +00001826 FreeBSD*|NetBSD*|OpenBSD*|DragonFly*)
Guido van Rossumdf693651999-01-07 21:50:41 +00001827 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
1828 then
1829 LINKFORSHARED="-Wl,--export-dynamic"
1830 fi;;
Guido van Rossum2b5ca001998-03-05 15:41:09 +00001831 SunOS/5*) case $CC in
1832 *gcc*)
Martin v. Löwisa4548572002-04-18 14:51:36 +00001833 if $CC -Xlinker --help 2>&1 | grep export-dynamic >/dev/null
Guido van Rossum8f4ceb11997-12-18 23:42:19 +00001834 then
1835 LINKFORSHARED="-Xlinker --export-dynamic"
Guido van Rossum2b5ca001998-03-05 15:41:09 +00001836 fi;;
1837 esac;;
Jason Tishler30765592003-09-04 11:04:06 +00001838 CYGWIN*)
1839 if test $enable_shared = "no"
1840 then
1841 LINKFORSHARED='-Wl,--out-implib=$(LDLIBRARY)'
1842 fi;;
Georg Brandlf78e02b2008-06-10 17:40:04 +00001843 QNX*)
1844 # -Wl,-E causes the symbols to be added to the dynamic
1845 # symbol table so that they can be found when a module
1846 # is loaded. -N 2048K causes the stack size to be set
1847 # to 2048 kilobytes so that the stack doesn't overflow
1848 # when running test_compile.py.
1849 LINKFORSHARED='-Wl,-E -N 2048K';;
Guido van Rossumac405f61994-09-12 10:56:06 +00001850 esac
Guido van Rossumac405f61994-09-12 10:56:06 +00001851fi
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001852AC_MSG_RESULT($LINKFORSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00001853
Georg Brandl93de2162008-07-16 02:21:06 +00001854
Neil Schemenauer61c51152001-01-26 16:18:16 +00001855AC_SUBST(CFLAGSFORSHARED)
1856AC_MSG_CHECKING(CFLAGSFORSHARED)
1857if test ! "$LIBRARY" = "$LDLIBRARY"
1858then
Neil Schemenauerd9cf41c2001-01-27 21:39:17 +00001859 case $ac_sys_system in
1860 CYGWIN*)
1861 # Cygwin needs CCSHARED when building extension DLLs
1862 # but not when building the interpreter DLL.
1863 CFLAGSFORSHARED='';;
1864 *)
1865 CFLAGSFORSHARED='$(CCSHARED)'
1866 esac
Neil Schemenauer61c51152001-01-26 16:18:16 +00001867fi
1868AC_MSG_RESULT($CFLAGSFORSHARED)
1869
Martin v. Löwisf90ae202002-06-11 06:22:31 +00001870# SHLIBS are libraries (except -lc and -lm) to link to the python shared
1871# library (with --enable-shared).
1872# For platforms on which shared libraries are not allowed to have unresolved
Martin v. Löwisd6359c52002-08-04 12:38:50 +00001873# symbols, this must be set to $(LIBS) (expanded by make). We do this even
1874# if it is not required, since it creates a dependency of the shared library
1875# to LIBS. This, in turn, means that applications linking the shared libpython
1876# don't need to link LIBS explicitly. The default should be only changed
1877# on systems where this approach causes problems.
Martin v. Löwisf90ae202002-06-11 06:22:31 +00001878AC_SUBST(SHLIBS)
1879AC_MSG_CHECKING(SHLIBS)
1880case "$ac_sys_system" in
Martin v. Löwisf90ae202002-06-11 06:22:31 +00001881 *)
Martin v. Löwisd6359c52002-08-04 12:38:50 +00001882 SHLIBS='$(LIBS)';;
Martin v. Löwisf90ae202002-06-11 06:22:31 +00001883esac
1884AC_MSG_RESULT($SHLIBS)
1885
1886
Guido van Rossum627b2d71993-12-24 10:39:16 +00001887# checks for libraries
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001888AC_CHECK_LIB(dl, dlopen) # Dynamic linking for SunOS/Solaris and SYSV
1889AC_CHECK_LIB(dld, shl_load) # Dynamic linking for HP-UX
Martin v. Löwis519adae2003-09-20 10:47:47 +00001890
Georg Brandleee31162008-12-07 15:15:22 +00001891# only check for sem_init if thread support is requested
Martin v. Löwis519adae2003-09-20 10:47:47 +00001892if test "$with_threads" = "yes" -o -z "$with_threads"; then
1893 AC_SEARCH_LIBS(sem_init, pthread rt posix4) # 'Real Time' functions on Solaris
1894 # posix4 on Solaris 2.6
1895 # pthread (first!) on Linux
1896fi
1897
Martin v. Löwis19d17342003-06-14 21:03:05 +00001898# check if we need libintl for locale functions
1899AC_CHECK_LIB(intl, textdomain,
Brett Cannonc6d936e2009-06-07 20:09:53 +00001900 [AC_DEFINE(WITH_LIBINTL, 1,
1901 [Define to 1 if libintl is needed for locale functions.])
1902 LIBS="-lintl $LIBS"])
Guido van Rossum0eefa3f1999-11-16 15:57:37 +00001903
1904# checks for system dependent C++ extensions support
1905case "$ac_sys_system" in
1906 AIX*) AC_MSG_CHECKING(for genuine AIX C++ extensions support)
1907 AC_TRY_LINK([#include "/usr/lpp/xlC/include/load.h"],
1908 [loadAndInit("", 0, "")],
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001909 [AC_DEFINE(AIX_GENUINE_CPLUSPLUS, 1,
1910 [Define for AIX if your compiler is a genuine IBM xlC/xlC_r
1911 and you want support for AIX C++ shared extension modules.])
Guido van Rossum0eefa3f1999-11-16 15:57:37 +00001912 AC_MSG_RESULT(yes)],
1913 [AC_MSG_RESULT(no)]);;
1914 *) ;;
1915esac
1916
Guido van Rossum70c7f481998-03-26 18:44:10 +00001917# Most SVR4 platforms (e.g. Solaris) need -lsocket and -lnsl.
Guido van Rossumf618d2c1995-01-17 16:36:13 +00001918AC_CHECK_LIB(nsl, t_open, [LIBS="-lnsl $LIBS"]) # SVR4
Guido van Rossumf618d2c1995-01-17 16:36:13 +00001919AC_CHECK_LIB(socket, socket, [LIBS="-lsocket $LIBS"], [], $LIBS) # SVR4 sockets
Skip Montanarob9949db2004-01-17 04:04:13 +00001920
Guido van Rossumc5a39031996-07-31 17:35:03 +00001921AC_MSG_CHECKING(for --with-libs)
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00001922AC_ARG_WITH(libs,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00001923 AC_HELP_STRING(--with-libs='lib1 ...', link against additional libs),
1924[
Guido van Rossumc5a39031996-07-31 17:35:03 +00001925AC_MSG_RESULT($withval)
1926LIBS="$withval $LIBS"
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00001927],
1928[AC_MSG_RESULT(no)])
Guido van Rossum627b2d71993-12-24 10:39:16 +00001929
Benjamin Peterson0f64b0b2010-03-09 21:49:52 +00001930AC_PATH_TOOL([PKG_CONFIG], [pkg-config])
1931
Benjamin Petersonb2d90462009-12-31 03:23:10 +00001932# Check for use of the system expat library
1933AC_MSG_CHECKING(for --with-system-expat)
1934AC_ARG_WITH(system_expat,
1935 AC_HELP_STRING(--with-system-expat, build pyexpat module using an installed expat library))
1936
1937AC_MSG_RESULT($with_system_expat)
1938
Thomas Wouters49fd7fa2006-04-21 10:40:58 +00001939# Check for use of the system libffi library
1940AC_MSG_CHECKING(for --with-system-ffi)
1941AC_ARG_WITH(system_ffi,
1942 AC_HELP_STRING(--with-system-ffi, build _ctypes module using an installed ffi library))
1943
Benjamin Peterson0f64b0b2010-03-09 21:49:52 +00001944if test "$with_system_ffi" = "yes" && test -n "$PKG_CONFIG"; then
Benjamin Petersond78735d2010-01-01 16:04:23 +00001945 LIBFFI_INCLUDEDIR="`"$PKG_CONFIG" libffi --cflags-only-I 2>/dev/null | sed -e 's/^-I//;s/ *$//'`"
1946else
1947 LIBFFI_INCLUDEDIR=""
1948fi
1949AC_SUBST(LIBFFI_INCLUDEDIR)
1950
Thomas Wouters49fd7fa2006-04-21 10:40:58 +00001951AC_MSG_RESULT($with_system_ffi)
1952
Matthias Klose55708cc2009-04-30 08:06:49 +00001953# Check for --with-dbmliborder
1954AC_MSG_CHECKING(for --with-dbmliborder)
1955AC_ARG_WITH(dbmliborder,
1956 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'.]),
1957[
1958if test x$with_dbmliborder = xyes
1959then
1960AC_MSG_ERROR([proper usage is --with-dbmliborder=db1:db2:...])
1961else
1962 for db in `echo $with_dbmliborder | sed 's/:/ /g'`; do
1963 if test x$db != xndbm && test x$db != xgdbm && test x$db != xbdb
1964 then
1965 AC_MSG_ERROR([proper usage is --with-dbmliborder=db1:db2:...])
1966 fi
1967 done
1968fi])
1969AC_MSG_RESULT($with_dbmliborder)
1970
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00001971# Determine if signalmodule should be used.
1972AC_SUBST(USE_SIGNAL_MODULE)
1973AC_SUBST(SIGNAL_OBJS)
1974AC_MSG_CHECKING(for --with-signal-module)
1975AC_ARG_WITH(signal-module,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00001976 AC_HELP_STRING(--with-signal-module, disable/enable signal module))
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00001977
1978if test -z "$with_signal_module"
1979then with_signal_module="yes"
1980fi
1981AC_MSG_RESULT($with_signal_module)
1982
1983if test "${with_signal_module}" = "yes"; then
1984 USE_SIGNAL_MODULE=""
1985 SIGNAL_OBJS=""
1986else
1987 USE_SIGNAL_MODULE="#"
1988 SIGNAL_OBJS="Parser/intrcheck.o Python/sigcheck.o"
1989fi
1990
Guido van Rossum3d15bd82001-01-10 18:53:48 +00001991# This is used to generate Setup.config
Guido van Rossum009f7871997-12-04 00:51:42 +00001992AC_SUBST(USE_THREAD_MODULE)
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00001993USE_THREAD_MODULE=""
Guido van Rossum009f7871997-12-04 00:51:42 +00001994
Guido van Rossum54d93d41997-01-22 20:51:58 +00001995AC_MSG_CHECKING(for --with-dec-threads)
1996AC_SUBST(LDLAST)
1997AC_ARG_WITH(dec-threads,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00001998 AC_HELP_STRING(--with-dec-threads, use DEC Alpha/OSF1 thread-safe libraries),
1999[
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00002000AC_MSG_RESULT($withval)
Guido van Rossum54d93d41997-01-22 20:51:58 +00002001LDLAST=-threads
Guido van Rossumf78abae1997-01-21 22:02:36 +00002002if test "${with_thread+set}" != set; then
Guido van Rossum54d93d41997-01-22 20:51:58 +00002003 with_thread="$withval";
2004fi],
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002005[AC_MSG_RESULT(no)])
Guido van Rossum54d93d41997-01-22 20:51:58 +00002006
Martin v. Löwis11437992002-04-12 09:54:03 +00002007# Templates for things AC_DEFINEd more than once.
2008# For a single AC_DEFINE, no template is needed.
2009AH_TEMPLATE(C_THREADS,[Define if you have the Mach cthreads package])
2010AH_TEMPLATE(_REENTRANT,
2011 [Define to force use of thread-safe errno, h_errno, and other functions])
2012AH_TEMPLATE(WITH_THREAD,
2013 [Define if you want to compile in rudimentary thread support])
2014
Guido van Rossum54d93d41997-01-22 20:51:58 +00002015AC_MSG_CHECKING(for --with-threads)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002016dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00002017AC_ARG_WITH(threads,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002018 AC_HELP_STRING(--with(out)-threads@<:@=DIRECTORY@:>@, disable/enable thread support))
Guido van Rossum54d93d41997-01-22 20:51:58 +00002019
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00002020# --with-thread is deprecated, but check for it anyway
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002021dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
Barry Warsawa0f3c5c2000-06-30 16:39:35 +00002022AC_ARG_WITH(thread,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002023 AC_HELP_STRING(--with(out)-thread@<:@=DIRECTORY@:>@, deprecated; use --with(out)-threads),
2024 [with_threads=$with_thread])
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00002025
2026if test -z "$with_threads"
2027then with_threads="yes"
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002028fi
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00002029AC_MSG_RESULT($with_threads)
Guido van Rossum6400c261997-05-22 20:34:27 +00002030
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002031AC_SUBST(THREADOBJ)
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00002032if test "$with_threads" = "no"
2033then
2034 USE_THREAD_MODULE="#"
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002035elif test "$ac_cv_pthread_is_default" = yes
2036then
2037 AC_DEFINE(WITH_THREAD)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002038 # Defining _REENTRANT on system with POSIX threads should not hurt.
2039 AC_DEFINE(_REENTRANT)
2040 posix_threads=yes
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002041 THREADOBJ="Python/thread.o"
Martin v. Löwis130fb172001-07-19 11:00:41 +00002042elif test "$ac_cv_kpthread" = "yes"
2043then
2044 CC="$CC -Kpthread"
Martin v. Löwis519adae2003-09-20 10:47:47 +00002045 if test "$ac_cv_cxx_thread" = "yes"; then
2046 CXX="$CXX -Kpthread"
2047 fi
Martin v. Löwis130fb172001-07-19 11:00:41 +00002048 AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002049 posix_threads=yes
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002050 THREADOBJ="Python/thread.o"
Martin v. Löwis5f433f02003-05-05 05:05:30 +00002051elif test "$ac_cv_kthread" = "yes"
2052then
2053 CC="$CC -Kthread"
Martin v. Löwis519adae2003-09-20 10:47:47 +00002054 if test "$ac_cv_cxx_thread" = "yes"; then
2055 CXX="$CXX -Kthread"
2056 fi
Martin v. Löwis5f433f02003-05-05 05:05:30 +00002057 AC_DEFINE(WITH_THREAD)
2058 posix_threads=yes
2059 THREADOBJ="Python/thread.o"
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002060elif test "$ac_cv_pthread" = "yes"
2061then
2062 CC="$CC -pthread"
Martin v. Löwis519adae2003-09-20 10:47:47 +00002063 if test "$ac_cv_cxx_thread" = "yes"; then
2064 CXX="$CXX -pthread"
2065 fi
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002066 AC_DEFINE(WITH_THREAD)
2067 posix_threads=yes
2068 THREADOBJ="Python/thread.o"
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00002069else
Martin v. Löwis130fb172001-07-19 11:00:41 +00002070 if test ! -z "$with_threads" -a -d "$with_threads"
2071 then LDFLAGS="$LDFLAGS -L$with_threads"
2072 fi
2073 if test ! -z "$withval" -a -d "$withval"
2074 then LDFLAGS="$LDFLAGS -L$withval"
2075 fi
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002076
2077 # According to the POSIX spec, a pthreads implementation must
Matthias Klosea2542be2004-08-16 11:35:51 +00002078 # define _POSIX_THREADS in unistd.h. Some apparently don't
2079 # (e.g. gnu pth with pthread emulation)
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002080 AC_MSG_CHECKING(for _POSIX_THREADS in unistd.h)
2081 AC_EGREP_CPP(yes,
Neal Norwitz6eb37f02003-02-23 23:28:15 +00002082 [
2083#include <unistd.h>
2084#ifdef _POSIX_THREADS
2085yes
2086#endif
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002087 ], unistd_defines_pthreads=yes, unistd_defines_pthreads=no)
2088 AC_MSG_RESULT($unistd_defines_pthreads)
2089
Martin v. Löwis130fb172001-07-19 11:00:41 +00002090 AC_DEFINE(_REENTRANT)
Martin v. Löwisa6e97582002-01-01 18:41:33 +00002091 AC_CHECK_HEADER(cthreads.h, [AC_DEFINE(WITH_THREAD)
2092 AC_DEFINE(C_THREADS)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002093 AC_DEFINE(HURD_C_THREADS, 1,
2094 [Define if you are using Mach cthreads directly under /include])
Martin v. Löwisa6e97582002-01-01 18:41:33 +00002095 LIBS="$LIBS -lthreads"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002096 THREADOBJ="Python/thread.o"],[
Martin v. Löwis130fb172001-07-19 11:00:41 +00002097 AC_CHECK_HEADER(mach/cthreads.h, [AC_DEFINE(WITH_THREAD)
2098 AC_DEFINE(C_THREADS)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002099 AC_DEFINE(MACH_C_THREADS, 1,
2100 [Define if you are using Mach cthreads under mach /])
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002101 THREADOBJ="Python/thread.o"],[
Martin v. Löwis8158b5a2001-10-08 13:17:28 +00002102 # Just looking for pthread_create in libpthread is not enough:
2103 # on HP/UX, pthread.h renames pthread_create to a different symbol name.
2104 # So we really have to include pthread.h, and then link.
2105 _libs=$LIBS
2106 LIBS="$LIBS -lpthread"
2107 AC_MSG_CHECKING([for pthread_create in -lpthread])
2108 AC_TRY_LINK([#include <pthread.h>
2109
2110void * start_routine (void *arg) { exit (0); }], [
2111pthread_create (NULL, NULL, start_routine, NULL)], [
2112 AC_MSG_RESULT(yes)
2113 AC_DEFINE(WITH_THREAD)
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002114 posix_threads=yes
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002115 THREADOBJ="Python/thread.o"],[
Martin v. Löwis8158b5a2001-10-08 13:17:28 +00002116 LIBS=$_libs
Martin v. Löwis130fb172001-07-19 11:00:41 +00002117 AC_CHECK_FUNC(pthread_detach, [AC_DEFINE(WITH_THREAD)
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002118 posix_threads=yes
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002119 THREADOBJ="Python/thread.o"],[
Martin v. Löwis130fb172001-07-19 11:00:41 +00002120 AC_CHECK_LIB(pthreads, pthread_create, [AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002121 posix_threads=yes
Martin v. Löwis130fb172001-07-19 11:00:41 +00002122 LIBS="$LIBS -lpthreads"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002123 THREADOBJ="Python/thread.o"], [
Martin v. Löwis130fb172001-07-19 11:00:41 +00002124 AC_CHECK_LIB(c_r, pthread_create, [AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002125 posix_threads=yes
Martin v. Löwis130fb172001-07-19 11:00:41 +00002126 LIBS="$LIBS -lc_r"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002127 THREADOBJ="Python/thread.o"], [
Martin v. Löwis130fb172001-07-19 11:00:41 +00002128 AC_CHECK_LIB(pthread, __pthread_create_system, [AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002129 posix_threads=yes
Martin v. Löwis130fb172001-07-19 11:00:41 +00002130 LIBS="$LIBS -lpthread"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002131 THREADOBJ="Python/thread.o"], [
Martin v. Löwis130fb172001-07-19 11:00:41 +00002132 AC_CHECK_LIB(cma, pthread_create, [AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002133 posix_threads=yes
Martin v. Löwis130fb172001-07-19 11:00:41 +00002134 LIBS="$LIBS -lcma"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002135 THREADOBJ="Python/thread.o"],[
Martin v. Löwis130fb172001-07-19 11:00:41 +00002136 USE_THREAD_MODULE="#"])
Antoine Pitroudb6c5672009-10-24 20:35:52 +00002137 ])])])])])])])
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00002138
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002139 AC_CHECK_LIB(mpc, usconfig, [AC_DEFINE(WITH_THREAD)
2140 LIBS="$LIBS -lmpc"
2141 THREADOBJ="Python/thread.o"
2142 USE_THREAD_MODULE=""])
2143
2144 if test "$posix_threads" != "yes"; then
2145 AC_CHECK_LIB(thread, thr_create, [AC_DEFINE(WITH_THREAD)
2146 LIBS="$LIBS -lthread"
2147 THREADOBJ="Python/thread.o"
2148 USE_THREAD_MODULE=""])
2149 fi
2150
2151 if test "$USE_THREAD_MODULE" != "#"
2152 then
2153 # If the above checks didn't disable threads, (at least) OSF1
2154 # needs this '-threads' argument during linking.
2155 case $ac_sys_system in
2156 OSF1) LDLAST=-threads;;
2157 esac
2158 fi
2159fi
2160
2161if test "$posix_threads" = "yes"; then
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002162 if test "$unistd_defines_pthreads" = "no"; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002163 AC_DEFINE(_POSIX_THREADS, 1,
2164 [Define if you have POSIX threads,
2165 and your system does not define that.])
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002166 fi
2167
Martin v. Löwisdfc33fd2003-01-21 10:14:41 +00002168 # Bug 662787: Using semaphores causes unexplicable hangs on Solaris 8.
2169 case $ac_sys_system/$ac_sys_release in
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002170 SunOS/5.6) AC_DEFINE(HAVE_PTHREAD_DESTRUCTOR, 1,
2171 Defined for Solaris 2.6 bug in pthread header.)
2172 ;;
Martin v. Löwisdfc33fd2003-01-21 10:14:41 +00002173 SunOS/5.8) AC_DEFINE(HAVE_BROKEN_POSIX_SEMAPHORES, 1,
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002174 Define if the Posix semaphores do not work on your system)
2175 ;;
Christian Heimes7b3ce6a2008-01-31 14:31:45 +00002176 AIX/5) AC_DEFINE(HAVE_BROKEN_POSIX_SEMAPHORES, 1,
2177 Define if the Posix semaphores do not work on your system)
2178 ;;
Martin v. Löwisdfc33fd2003-01-21 10:14:41 +00002179 esac
2180
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002181 AC_MSG_CHECKING(if PTHREAD_SCOPE_SYSTEM is supported)
2182 AC_CACHE_VAL(ac_cv_pthread_system_supported,
2183 [AC_TRY_RUN([#include <pthread.h>
2184 void *foo(void *parm) {
2185 return NULL;
2186 }
2187 main() {
2188 pthread_attr_t attr;
Martin v. Löwisa82d3472002-02-24 16:05:05 +00002189 pthread_t id;
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002190 if (pthread_attr_init(&attr)) exit(-1);
2191 if (pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM)) exit(-1);
Martin v. Löwisa82d3472002-02-24 16:05:05 +00002192 if (pthread_create(&id, &attr, foo, NULL)) exit(-1);
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002193 exit(0);
Guido van Rossum3065c942001-09-17 04:03:14 +00002194 }],
2195 ac_cv_pthread_system_supported=yes,
2196 ac_cv_pthread_system_supported=no,
2197 ac_cv_pthread_system_supported=no)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002198 ])
2199 AC_MSG_RESULT($ac_cv_pthread_system_supported)
2200 if test "$ac_cv_pthread_system_supported" = "yes"; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002201 AC_DEFINE(PTHREAD_SYSTEM_SCHED_SUPPORTED, 1, [Defined if PTHREAD_SCOPE_SYSTEM supported.])
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002202 fi
Jason Tishlerfac083d2003-07-22 15:20:49 +00002203 AC_CHECK_FUNCS(pthread_sigmask,
2204 [case $ac_sys_system in
2205 CYGWIN*)
2206 AC_DEFINE(HAVE_BROKEN_PTHREAD_SIGMASK, 1,
2207 [Define if pthread_sigmask() does not work on your system.])
2208 ;;
2209 esac])
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00002210fi
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002211
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002212
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002213# Check for enable-ipv6
Martin v. Löwis11437992002-04-12 09:54:03 +00002214AH_TEMPLATE(ENABLE_IPV6, [Define if --enable-ipv6 is specified])
Martin v. Löwisa5f8bb52001-09-05 08:22:34 +00002215AC_MSG_CHECKING([if --enable-ipv6 is specified])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002216AC_ARG_ENABLE(ipv6,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002217[ --enable-ipv6 Enable ipv6 (with ipv4) support
2218 --disable-ipv6 Disable ipv6 support],
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002219[ case "$enableval" in
2220 no)
2221 AC_MSG_RESULT(no)
2222 ipv6=no
2223 ;;
2224 *) AC_MSG_RESULT(yes)
2225 AC_DEFINE(ENABLE_IPV6)
2226 ipv6=yes
2227 ;;
2228 esac ],
2229
Martin v. Löwisa5f8bb52001-09-05 08:22:34 +00002230[
2231dnl the check does not work on cross compilation case...
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002232 AC_TRY_RUN([ /* AF_INET6 available check */
2233#include <sys/types.h>
2234#include <sys/socket.h>
2235main()
2236{
2237 if (socket(AF_INET6, SOCK_STREAM, 0) < 0)
2238 exit(1);
2239 else
2240 exit(0);
2241}
2242],
2243 AC_MSG_RESULT(yes)
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002244 ipv6=yes,
2245 AC_MSG_RESULT(no)
2246 ipv6=no,
2247 AC_MSG_RESULT(no)
2248 ipv6=no
Martin v. Löwisa5f8bb52001-09-05 08:22:34 +00002249)
2250
2251if test "$ipv6" = "yes"; then
2252 AC_MSG_CHECKING(if RFC2553 API is available)
2253 AC_TRY_COMPILE([#include <sys/types.h>
2254#include <netinet/in.h>],
2255 [struct sockaddr_in6 x;
2256x.sin6_scope_id;],
2257 AC_MSG_RESULT(yes)
2258 ipv6=yes,
2259 AC_MSG_RESULT(no, IPv6 disabled)
2260 ipv6=no)
2261fi
2262
2263if test "$ipv6" = "yes"; then
2264 AC_DEFINE(ENABLE_IPV6)
2265fi
2266])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002267
2268ipv6type=unknown
2269ipv6lib=none
2270ipv6trylibc=no
2271
2272if test "$ipv6" = "yes"; then
2273 AC_MSG_CHECKING([ipv6 stack type])
Guido van Rossumb8552162001-09-05 14:58:11 +00002274 for i in inria kame linux-glibc linux-inet6 solaris toshiba v6d zeta;
2275 do
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002276 case $i in
2277 inria)
2278 dnl http://www.kame.net/
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002279 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002280#include <netinet/in.h>
2281#ifdef IPV6_INRIA_VERSION
2282yes
2283#endif],
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002284 [ipv6type=$i])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002285 ;;
2286 kame)
2287 dnl http://www.kame.net/
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002288 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002289#include <netinet/in.h>
2290#ifdef __KAME__
2291yes
2292#endif],
2293 [ipv6type=$i;
2294 ipv6lib=inet6
2295 ipv6libdir=/usr/local/v6/lib
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002296 ipv6trylibc=yes])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002297 ;;
2298 linux-glibc)
2299 dnl http://www.v6.linux.or.jp/
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002300 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002301#include <features.h>
2302#if defined(__GLIBC__) && ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1) || (__GLIBC__ > 2))
2303yes
2304#endif],
2305 [ipv6type=$i;
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002306 ipv6trylibc=yes])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002307 ;;
2308 linux-inet6)
2309 dnl http://www.v6.linux.or.jp/
2310 if test -d /usr/inet6; then
2311 ipv6type=$i
2312 ipv6lib=inet6
2313 ipv6libdir=/usr/inet6/lib
Skip Montanarodecc6a42003-01-01 20:07:49 +00002314 BASECFLAGS="-I/usr/inet6/include $BASECFLAGS"
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002315 fi
2316 ;;
2317 solaris)
2318 if test -f /etc/netconfig; then
2319 if /usr/xpg4/bin/grep -q tcp6 /etc/netconfig; then
2320 ipv6type=$i
2321 ipv6trylibc=yes
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002322 fi
2323 fi
2324 ;;
2325 toshiba)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002326 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002327#include <sys/param.h>
2328#ifdef _TOSHIBA_INET6
2329yes
2330#endif],
2331 [ipv6type=$i;
2332 ipv6lib=inet6;
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002333 ipv6libdir=/usr/local/v6/lib])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002334 ;;
2335 v6d)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002336 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002337#include </usr/local/v6/include/sys/v6config.h>
2338#ifdef __V6D__
2339yes
2340#endif],
2341 [ipv6type=$i;
2342 ipv6lib=v6;
2343 ipv6libdir=/usr/local/v6/lib;
Skip Montanarodecc6a42003-01-01 20:07:49 +00002344 BASECFLAGS="-I/usr/local/v6/include $BASECFLAGS"])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002345 ;;
2346 zeta)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002347 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002348#include <sys/param.h>
2349#ifdef _ZETA_MINAMI_INET6
2350yes
2351#endif],
2352 [ipv6type=$i;
2353 ipv6lib=inet6;
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002354 ipv6libdir=/usr/local/v6/lib])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002355 ;;
2356 esac
2357 if test "$ipv6type" != "unknown"; then
2358 break
2359 fi
2360 done
2361 AC_MSG_RESULT($ipv6type)
2362fi
2363
2364if test "$ipv6" = "yes" -a "$ipv6lib" != "none"; then
2365 if test -d $ipv6libdir -a -f $ipv6libdir/lib$ipv6lib.a; then
2366 LIBS="-L$ipv6libdir -l$ipv6lib $LIBS"
2367 echo "using lib$ipv6lib"
2368 else
2369 if test $ipv6trylibc = "yes"; then
2370 echo "using libc"
2371 else
2372 echo 'Fatal: no $ipv6lib library found. cannot continue.'
2373 echo "You need to fetch lib$ipv6lib.a from appropriate"
2374 echo 'ipv6 kit and compile beforehand.'
2375 exit 1
2376 fi
2377 fi
2378fi
2379
Georg Brandl93de2162008-07-16 02:21:06 +00002380AC_MSG_CHECKING(for OSX 10.5 SDK or later)
2381AC_TRY_COMPILE([#include <Carbon/Carbon.h>], FSIORefNum fRef = 0,
2382 AC_DEFINE(HAVE_OSX105_SDK, 1, Define if compiling using MacOS X 10.5 SDK or later.)
2383 AC_MSG_RESULT(yes),
2384 AC_MSG_RESULT(no)
2385)
2386
Martin v. Löwisa3fb4f72002-06-09 13:33:54 +00002387# Check for --with-doc-strings
2388AC_MSG_CHECKING(for --with-doc-strings)
2389AC_ARG_WITH(doc-strings,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002390 AC_HELP_STRING(--with(out)-doc-strings, disable/enable documentation strings))
Martin v. Löwisa3fb4f72002-06-09 13:33:54 +00002391
2392if test -z "$with_doc_strings"
2393then with_doc_strings="yes"
2394fi
2395if test "$with_doc_strings" != "no"
2396then
2397 AC_DEFINE(WITH_DOC_STRINGS, 1,
2398 [Define if you want documentation strings in extension modules])
2399fi
2400AC_MSG_RESULT($with_doc_strings)
2401
Neil Schemenauera35c6882001-02-27 04:45:05 +00002402# Check for Python-specific malloc support
Martin v. Löwisf30d60e2004-06-08 08:17:44 +00002403AC_MSG_CHECKING(for --with-tsc)
2404AC_ARG_WITH(tsc,
2405[ --with(out)-tsc enable/disable timestamp counter profile], [
2406if test "$withval" != no
2407then
2408 AC_DEFINE(WITH_TSC, 1,
2409 [Define to profile with the Pentium timestamp counter])
2410 AC_MSG_RESULT(yes)
2411else AC_MSG_RESULT(no)
2412fi],
2413[AC_MSG_RESULT(no)])
2414
2415# Check for Python-specific malloc support
Neil Schemenauera35c6882001-02-27 04:45:05 +00002416AC_MSG_CHECKING(for --with-pymalloc)
2417AC_ARG_WITH(pymalloc,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002418 AC_HELP_STRING(--with(out)-pymalloc, disable/enable specialized mallocs))
Neil Schemenauer16c22972002-03-22 15:34:49 +00002419
2420if test -z "$with_pymalloc"
2421then with_pymalloc="yes"
2422fi
2423if test "$with_pymalloc" != "no"
2424then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002425 AC_DEFINE(WITH_PYMALLOC, 1,
2426 [Define if you want to compile in Python-specific mallocs])
Neil Schemenauer16c22972002-03-22 15:34:49 +00002427fi
2428AC_MSG_RESULT($with_pymalloc)
Neil Schemenauera35c6882001-02-27 04:45:05 +00002429
Benjamin Peterson05159c42009-12-03 03:01:27 +00002430# Check for Valgrind support
2431AC_MSG_CHECKING([for --with-valgrind])
2432AC_ARG_WITH([valgrind],
2433 AC_HELP_STRING([--with-valgrind], [Enable Valgrind support]),,
2434 with_valgrind=no)
2435AC_MSG_RESULT([$with_valgrind])
2436if test "$with_valgrind" != no; then
2437 AC_CHECK_HEADER([valgrind/valgrind.h],
2438 [AC_DEFINE([WITH_VALGRIND], 1, [Define if you want pymalloc to be disabled when running under valgrind])],
2439 [AC_MSG_ERROR([Valgrind support requested but headers not available])]
2440 )
2441fi
2442
Barry Warsawef82cd72000-06-30 16:21:01 +00002443# Check for --with-wctype-functions
2444AC_MSG_CHECKING(for --with-wctype-functions)
2445AC_ARG_WITH(wctype-functions,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002446 AC_HELP_STRING(--with-wctype-functions, use wctype.h functions),
2447[
Barry Warsawef82cd72000-06-30 16:21:01 +00002448if test "$withval" != no
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002449then
2450 AC_DEFINE(WANT_WCTYPE_FUNCTIONS, 1,
2451 [Define if you want wctype.h functions to be used instead of the
2452 one supplied by Python itself. (see Include/unicodectype.h).])
2453 AC_MSG_RESULT(yes)
Barry Warsawef82cd72000-06-30 16:21:01 +00002454else AC_MSG_RESULT(no)
2455fi],
2456[AC_MSG_RESULT(no)])
2457
Guido van Rossum68242b51996-05-28 22:53:03 +00002458# -I${DLINCLDIR} is added to the compile rule for importdl.o
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002459AC_SUBST(DLINCLDIR)
Guido van Rossum98935bf2001-09-05 19:13:16 +00002460DLINCLDIR=.
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002461
Guido van Rossume97ee181999-12-20 21:27:22 +00002462# the dlopen() function means we might want to use dynload_shlib.o. some
2463# platforms, such as AIX, have dlopen(), but don't want to use it.
Thomas Wouters3a584202000-08-05 23:28:51 +00002464AC_CHECK_FUNCS(dlopen)
Guido van Rossume97ee181999-12-20 21:27:22 +00002465
2466# DYNLOADFILE specifies which dynload_*.o file we will use for dynamic
2467# loading of modules.
2468AC_SUBST(DYNLOADFILE)
2469AC_MSG_CHECKING(DYNLOADFILE)
2470if test -z "$DYNLOADFILE"
2471then
2472 case $ac_sys_system/$ac_sys_release in
Martin v. Löwisc19c5a62003-11-18 20:00:44 +00002473 AIX*) # Use dynload_shlib.c and dlopen() if we have it; otherwise dynload_aix.c
2474 if test "$ac_cv_func_dlopen" = yes
2475 then DYNLOADFILE="dynload_shlib.o"
2476 else DYNLOADFILE="dynload_aix.o"
2477 fi
2478 ;;
Guido van Rossume97ee181999-12-20 21:27:22 +00002479 hp*|HP*) DYNLOADFILE="dynload_hpux.o";;
Thomas Wouters49fd7fa2006-04-21 10:40:58 +00002480 # Use dynload_next.c only on 10.2 and below, which don't have native dlopen()
2481 Darwin/@<:@0156@:>@\..*) DYNLOADFILE="dynload_next.o";;
Guido van Rossume97ee181999-12-20 21:27:22 +00002482 *)
2483 # use dynload_shlib.c and dlopen() if we have it; otherwise stub
2484 # out any dynamic loading
2485 if test "$ac_cv_func_dlopen" = yes
2486 then DYNLOADFILE="dynload_shlib.o"
2487 else DYNLOADFILE="dynload_stub.o"
2488 fi
2489 ;;
2490 esac
2491fi
2492AC_MSG_RESULT($DYNLOADFILE)
2493if test "$DYNLOADFILE" != "dynload_stub.o"
2494then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002495 AC_DEFINE(HAVE_DYNAMIC_LOADING, 1,
2496 [Defined when any dynamic module loading is enabled.])
Guido van Rossume97ee181999-12-20 21:27:22 +00002497fi
2498
Jack Jansenc49e5b72001-06-19 15:00:23 +00002499# MACHDEP_OBJS can be set to platform-specific object files needed by Python
2500
2501AC_SUBST(MACHDEP_OBJS)
2502AC_MSG_CHECKING(MACHDEP_OBJS)
2503if test -z "$MACHDEP_OBJS"
2504then
Jack Jansenb6e9cad2001-08-15 01:26:28 +00002505 MACHDEP_OBJS=$extra_machdep_objs
2506else
2507 MACHDEP_OBJS="$MACHDEP_OBJS $extra_machdep_objs"
Jack Jansenc49e5b72001-06-19 15:00:23 +00002508fi
Jack Jansenb6e9cad2001-08-15 01:26:28 +00002509AC_MSG_RESULT(MACHDEP_OBJS)
Jack Jansenc49e5b72001-06-19 15:00:23 +00002510
Guido van Rossum627b2d71993-12-24 10:39:16 +00002511# checks for library functions
Martin v. Löwis823725e2008-03-24 13:39:54 +00002512AC_CHECK_FUNCS(alarm setitimer getitimer bind_textdomain_codeset chown \
2513 clock confstr ctermid execv fchmod fchown fork fpathconf ftime ftruncate \
Martin v. Löwis438b5342002-12-27 10:16:42 +00002514 gai_strerror getgroups getlogin getloadavg getpeername getpgid getpid \
Martin v. Löwis7aed61a2009-11-27 14:09:49 +00002515 getpriority getresuid getresgid getpwent getspnam getspent getsid getwd \
Antoine Pitroub7572f02009-12-02 20:46:48 +00002516 initgroups kill killpg lchmod lchown lstat mbrtowc mkfifo mknod mktime \
Martin v. Löwisa5f09072002-10-11 05:37:59 +00002517 mremap nice pathconf pause plock poll pthread_init \
Guido van Rossum162e38c2003-02-19 15:25:10 +00002518 putenv readlink realpath \
Benjamin Peterson965ce872009-04-05 21:24:58 +00002519 select sem_open sem_timedwait sem_getvalue sem_unlink setegid seteuid \
2520 setgid \
Martin v. Löwis7aed61a2009-11-27 14:09:49 +00002521 setlocale setregid setreuid setresuid setresgid setsid setpgid setpgrp setuid setvbuf \
2522 sigaction siginterrupt sigrelse snprintf strftime strlcpy \
Michael W. Hudson34f20ea2002-05-27 15:08:24 +00002523 sysconf tcgetpgrp tcsetpgrp tempnam timegm times tmpfile tmpnam tmpnam_r \
Martin v. Löwis113a0852009-05-29 17:25:39 +00002524 truncate uname unsetenv utimes waitpid wait3 wait4 \
2525 wcscoll wcsftime wcsxfrm _getpty)
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00002526
Martin v. Löwisc8ad7cc2002-11-11 13:23:45 +00002527# For some functions, having a definition is not sufficient, since
2528# we want to take their address.
2529AC_MSG_CHECKING(for chroot)
2530AC_TRY_COMPILE([#include <unistd.h>], void *x=chroot,
2531 AC_DEFINE(HAVE_CHROOT, 1, Define if you have the 'chroot' function.)
2532 AC_MSG_RESULT(yes),
2533 AC_MSG_RESULT(no)
2534)
2535AC_MSG_CHECKING(for link)
2536AC_TRY_COMPILE([#include <unistd.h>], void *x=link,
2537 AC_DEFINE(HAVE_LINK, 1, Define if you have the 'link' function.)
2538 AC_MSG_RESULT(yes),
2539 AC_MSG_RESULT(no)
2540)
2541AC_MSG_CHECKING(for symlink)
2542AC_TRY_COMPILE([#include <unistd.h>], void *x=symlink,
2543 AC_DEFINE(HAVE_SYMLINK, 1, Define if you have the 'symlink' function.)
2544 AC_MSG_RESULT(yes),
2545 AC_MSG_RESULT(no)
2546)
Martin v. Löwisa64988c2003-09-20 15:30:20 +00002547AC_MSG_CHECKING(for fchdir)
2548AC_TRY_COMPILE([#include <unistd.h>], void *x=fchdir,
2549 AC_DEFINE(HAVE_FCHDIR, 1, Define if you have the 'fchdir' function.)
2550 AC_MSG_RESULT(yes),
2551 AC_MSG_RESULT(no)
2552)
2553AC_MSG_CHECKING(for fsync)
2554AC_TRY_COMPILE([#include <unistd.h>], void *x=fsync,
Skip Montanarod4fa8072003-09-25 14:49:15 +00002555 AC_DEFINE(HAVE_FSYNC, 1, Define if you have the 'fsync' function.)
Martin v. Löwisa64988c2003-09-20 15:30:20 +00002556 AC_MSG_RESULT(yes),
2557 AC_MSG_RESULT(no)
2558)
2559AC_MSG_CHECKING(for fdatasync)
2560AC_TRY_COMPILE([#include <unistd.h>], void *x=fdatasync,
2561 AC_DEFINE(HAVE_FDATASYNC, 1, Define if you have the 'fdatasync' function.)
2562 AC_MSG_RESULT(yes),
2563 AC_MSG_RESULT(no)
2564)
Christian Heimes4fbc72b2008-03-22 00:47:35 +00002565AC_MSG_CHECKING(for epoll)
2566AC_TRY_COMPILE([#include <sys/epoll.h>], void *x=epoll_create,
2567 AC_DEFINE(HAVE_EPOLL, 1, Define if you have the 'epoll' functions.)
2568 AC_MSG_RESULT(yes),
2569 AC_MSG_RESULT(no)
2570)
2571AC_MSG_CHECKING(for kqueue)
2572AC_TRY_COMPILE([
2573#include <sys/types.h>
2574#include <sys/event.h>
2575 ], int x=kqueue(),
2576 AC_DEFINE(HAVE_KQUEUE, 1, Define if you have the 'kqueue' functions.)
2577 AC_MSG_RESULT(yes),
2578 AC_MSG_RESULT(no)
2579)
Martin v. Löwisd5843682002-11-21 20:41:28 +00002580# On some systems (eg. FreeBSD 5), we would find a definition of the
2581# functions ctermid_r, setgroups in the library, but no prototype
2582# (e.g. because we use _XOPEN_SOURCE). See whether we can take their
2583# address to avoid compiler warnings and potential miscompilations
2584# because of the missing prototypes.
2585
2586AC_MSG_CHECKING(for ctermid_r)
2587AC_TRY_COMPILE([
2588#include "confdefs.h"
2589#include <stdio.h>
2590], void* p = ctermid_r,
2591 AC_DEFINE(HAVE_CTERMID_R, 1, Define if you have the 'ctermid_r' function.)
2592 AC_MSG_RESULT(yes),
2593 AC_MSG_RESULT(no)
2594)
2595
Martin v. Löwisf26d63b2003-03-30 17:23:49 +00002596AC_MSG_CHECKING(for flock)
2597AC_TRY_COMPILE([
2598#include "confdefs.h"
2599#include <sys/file.h>
2600], void* p = flock,
2601 AC_DEFINE(HAVE_FLOCK, 1, Define if you have the 'flock' function.)
2602 AC_MSG_RESULT(yes),
2603 AC_MSG_RESULT(no)
2604)
2605
2606AC_MSG_CHECKING(for getpagesize)
2607AC_TRY_COMPILE([
2608#include "confdefs.h"
2609#include <unistd.h>
2610], void* p = getpagesize,
2611 AC_DEFINE(HAVE_GETPAGESIZE, 1, Define if you have the 'getpagesize' function.)
2612 AC_MSG_RESULT(yes),
2613 AC_MSG_RESULT(no)
2614)
2615
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002616dnl check for true
2617AC_CHECK_PROGS(TRUE, true, /bin/true)
2618
Martin v. Löwis95c419b2003-05-03 12:10:48 +00002619dnl On some systems (e.g. Solaris 9), hstrerror and inet_aton are in -lresolv
2620dnl On others, they are in the C library, so we to take no action
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002621AC_CHECK_LIB(c, inet_aton, [$ac_cv_prog_TRUE],
Martin v. Löwis95c419b2003-05-03 12:10:48 +00002622 AC_CHECK_LIB(resolv, inet_aton)
2623)
2624
Christian Heimesd0764e22007-12-04 15:00:33 +00002625# On Tru64, chflags seems to be present, but calling it will
2626# exit Python
Benjamin Petersoned68afa2010-01-30 19:36:43 +00002627AC_CACHE_CHECK([for chflags], [ac_cv_have_chflags], [dnl
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00002628AC_TRY_RUN([[
Christian Heimesd0764e22007-12-04 15:00:33 +00002629#include <sys/stat.h>
2630#include <unistd.h>
2631int main(int argc, char*argv[])
2632{
2633 if(chflags(argv[0], 0) != 0)
2634 return 1;
2635 return 0;
2636}
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00002637]], ac_cv_have_chflags=yes,
Benjamin Petersoned68afa2010-01-30 19:36:43 +00002638 ac_cv_have_chflags=no,
2639 ac_cv_have_chflags=cross)
2640])
2641if test "$ac_cv_have_chflags" = cross ; then
2642 AC_CHECK_FUNC([chflags], [ac_cv_have_chflags="yes"], [ac_cv_have_chflags="no"])
2643fi
2644if test "$ac_cv_have_chflags" = yes ; then
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00002645 AC_DEFINE(HAVE_CHFLAGS, 1, Define to 1 if you have the `chflags' function.)
2646fi
Christian Heimesd0764e22007-12-04 15:00:33 +00002647
Benjamin Petersoned68afa2010-01-30 19:36:43 +00002648AC_CACHE_CHECK([for lchflags], [ac_cv_have_lchflags], [dnl
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00002649AC_TRY_RUN([[
Christian Heimesd0764e22007-12-04 15:00:33 +00002650#include <sys/stat.h>
2651#include <unistd.h>
2652int main(int argc, char*argv[])
2653{
2654 if(lchflags(argv[0], 0) != 0)
2655 return 1;
2656 return 0;
2657}
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00002658]], ac_cv_have_lchflags=yes,
Benjamin Petersoned68afa2010-01-30 19:36:43 +00002659 ac_cv_have_lchflags=no,
2660 ac_cv_have_lchflags=cross)
2661])
2662if test "$ac_cv_have_lchflags" = cross ; then
2663 AC_CHECK_FUNC([lchflags], [ac_cv_have_lchflags="yes"], [ac_cv_have_lchflags="no"])
2664fi
2665if test "$ac_cv_have_lchflags" = yes ; then
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00002666 AC_DEFINE(HAVE_LCHFLAGS, 1, Define to 1 if you have the `lchflags' function.)
2667fi
Christian Heimesd0764e22007-12-04 15:00:33 +00002668
Thomas Wouters0e3f5912006-08-11 14:57:12 +00002669dnl Check if system zlib has *Copy() functions
2670dnl
2671dnl On MacOSX the linker will search for dylibs on the entire linker path
2672dnl before searching for static libraries. setup.py adds -Wl,-search_paths_first
2673dnl to revert to a more traditional unix behaviour and make it possible to
2674dnl override the system libz with a local static library of libz. Temporarily
2675dnl add that flag to our CFLAGS as well to ensure that we check the version
2676dnl of libz that will be used by setup.py.
2677dnl The -L/usr/local/lib is needed as wel to get the same compilation
2678dnl environment as setup.py (and leaving it out can cause configure to use the
2679dnl wrong version of the library)
2680case $ac_sys_system/$ac_sys_release in
2681Darwin/*)
2682 _CUR_CFLAGS="${CFLAGS}"
2683 _CUR_LDFLAGS="${LDFLAGS}"
2684 CFLAGS="${CFLAGS} -Wl,-search_paths_first"
2685 LDFLAGS="${LDFLAGS} -Wl,-search_paths_first -L/usr/local/lib"
2686 ;;
2687esac
2688
2689AC_CHECK_LIB(z, inflateCopy, AC_DEFINE(HAVE_ZLIB_COPY, 1, Define if the zlib library has inflateCopy))
2690
2691case $ac_sys_system/$ac_sys_release in
2692Darwin/*)
2693 CFLAGS="${_CUR_CFLAGS}"
2694 LDFLAGS="${_CUR_LDFLAGS}"
2695 ;;
2696esac
2697
Martin v. Löwise9416172003-05-03 10:12:45 +00002698AC_MSG_CHECKING(for hstrerror)
Martin v. Löwis95c419b2003-05-03 12:10:48 +00002699AC_TRY_LINK([
Martin v. Löwise9416172003-05-03 10:12:45 +00002700#include "confdefs.h"
2701#include <netdb.h>
Martin v. Löwis95c419b2003-05-03 12:10:48 +00002702], void* p = hstrerror; hstrerror(0),
Martin v. Löwise9416172003-05-03 10:12:45 +00002703 AC_DEFINE(HAVE_HSTRERROR, 1, Define if you have the 'hstrerror' function.)
2704 AC_MSG_RESULT(yes),
2705 AC_MSG_RESULT(no)
2706)
2707
2708AC_MSG_CHECKING(for inet_aton)
Martin v. Löwis95c419b2003-05-03 12:10:48 +00002709AC_TRY_LINK([
Martin v. Löwise9416172003-05-03 10:12:45 +00002710#include "confdefs.h"
Martin v. Löwis86d66262006-02-17 08:40: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>
Martin v. Löwis95c419b2003-05-03 12:10:48 +00002715], void* p = inet_aton;inet_aton(0,0),
Martin v. Löwise9416172003-05-03 10:12:45 +00002716 AC_DEFINE(HAVE_INET_ATON, 1, Define if you have the 'inet_aton' function.)
2717 AC_MSG_RESULT(yes),
2718 AC_MSG_RESULT(no)
2719)
2720
2721AC_MSG_CHECKING(for inet_pton)
2722AC_TRY_COMPILE([
2723#include "confdefs.h"
Martin v. Löwisf2e488d2003-05-05 22:00:11 +00002724#include <sys/types.h>
Martin v. Löwise9416172003-05-03 10:12:45 +00002725#include <sys/socket.h>
2726#include <netinet/in.h>
2727#include <arpa/inet.h>
2728], void* p = inet_pton,
2729 AC_DEFINE(HAVE_INET_PTON, 1, Define if you have the 'inet_pton' function.)
2730 AC_MSG_RESULT(yes),
2731 AC_MSG_RESULT(no)
2732)
2733
Martin v. Löwisd6640d42003-07-06 09:29:52 +00002734# On some systems, setgroups is in unistd.h, on others, in grp.h
Martin v. Löwisd5843682002-11-21 20:41:28 +00002735AC_MSG_CHECKING(for setgroups)
2736AC_TRY_COMPILE([
2737#include "confdefs.h"
Martin v. Löwisf2e488d2003-05-05 22:00:11 +00002738#include <unistd.h>
Martin v. Löwisd6640d42003-07-06 09:29:52 +00002739#ifdef HAVE_GRP_H
2740#include <grp.h>
2741#endif
Martin v. Löwisd5843682002-11-21 20:41:28 +00002742],
2743void* p = setgroups,
2744 AC_DEFINE(HAVE_SETGROUPS, 1, Define if you have the 'setgroups' function.)
2745 AC_MSG_RESULT(yes),
2746 AC_MSG_RESULT(no)
2747)
2748
Fred Drake8cef4cf2000-06-28 16:40:38 +00002749# check for openpty and forkpty
2750
Martin v. Löwisfd9a72a2006-01-08 10:07:33 +00002751AC_CHECK_FUNCS(openpty,,
2752 AC_CHECK_LIB(util,openpty,
2753 [AC_DEFINE(HAVE_OPENPTY) LIBS="$LIBS -lutil"],
2754 AC_CHECK_LIB(bsd,openpty, [AC_DEFINE(HAVE_OPENPTY) LIBS="$LIBS -lbsd"])
2755 )
2756)
2757AC_CHECK_FUNCS(forkpty,,
2758 AC_CHECK_LIB(util,forkpty,
2759 [AC_DEFINE(HAVE_FORKPTY) LIBS="$LIBS -lutil"],
2760 AC_CHECK_LIB(bsd,forkpty, [AC_DEFINE(HAVE_FORKPTY) LIBS="$LIBS -lbsd"])
2761 )
2762)
Fred Drake8cef4cf2000-06-28 16:40:38 +00002763
Christian Heimesb186d002008-03-18 15:15:01 +00002764# Stuff for expat.
2765AC_CHECK_FUNCS(memmove)
2766
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00002767# check for long file support functions
2768AC_CHECK_FUNCS(fseek64 fseeko fstatvfs ftell64 ftello statvfs)
2769
Christian Heimesb186d002008-03-18 15:15:01 +00002770AC_REPLACE_FUNCS(dup2 getcwd strdup)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002771AC_CHECK_FUNCS(getpgrp,
2772 AC_TRY_COMPILE([#include <unistd.h>],
2773 [getpgrp(0);],
2774 AC_DEFINE(GETPGRP_HAVE_ARG, 1,
2775 [Define if getpgrp() must be called as getpgrp(0).])
2776 )
2777)
Jack Jansen150753c2003-03-29 22:07:47 +00002778AC_CHECK_FUNCS(setpgrp,
2779 AC_TRY_COMPILE([#include <unistd.h>],
2780 [setpgrp(0,0);],
2781 AC_DEFINE(SETPGRP_HAVE_ARG, 1,
2782 [Define if setpgrp() must be called as setpgrp(0, 0).])
2783 )
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002784)
2785AC_CHECK_FUNCS(gettimeofday,
2786 AC_TRY_COMPILE([#include <sys/time.h>],
2787 [gettimeofday((struct timeval*)0,(struct timezone*)0);], ,
2788 AC_DEFINE(GETTIMEOFDAY_NO_TZ, 1,
2789 [Define if gettimeofday() does not have second (timezone) argument
2790 This is the case on Motorola V4 (R40V4.2)])
2791 )
2792)
Guido van Rossum627b2d71993-12-24 10:39:16 +00002793
Martin v. Löwisdbe3f762002-10-10 14:27:30 +00002794AC_MSG_CHECKING(for major, minor, and makedev)
Martin v. Löwise3271202002-11-07 07:42:30 +00002795AC_TRY_LINK([
Neal Norwitz6eb37f02003-02-23 23:28:15 +00002796#if defined(MAJOR_IN_MKDEV)
2797#include <sys/mkdev.h>
2798#elif defined(MAJOR_IN_SYSMACROS)
2799#include <sys/sysmacros.h>
2800#else
2801#include <sys/types.h>
2802#endif
Martin v. Löwisdbe3f762002-10-10 14:27:30 +00002803],[
2804 makedev(major(0),minor(0));
2805],[
2806 AC_DEFINE(HAVE_DEVICE_MACROS, 1,
2807 [Define to 1 if you have the device macros.])
2808 AC_MSG_RESULT(yes)
2809],[
2810 AC_MSG_RESULT(no)
2811])
Martin v. Löwis861a65b2001-10-24 14:36:00 +00002812
2813# On OSF/1 V5.1, getaddrinfo is available, but a define
2814# for [no]getaddrinfo in netdb.h.
2815AC_MSG_CHECKING(for getaddrinfo)
2816AC_TRY_LINK([
Martin v. Löwisc010b6d2001-11-09 17:50:52 +00002817#include <sys/types.h>
Martin v. Löwis861a65b2001-10-24 14:36:00 +00002818#include <sys/socket.h>
2819#include <netdb.h>
Martin v. Löwisc010b6d2001-11-09 17:50:52 +00002820#include <stdio.h>
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00002821], [getaddrinfo(NULL, NULL, NULL, NULL);],
2822have_getaddrinfo=yes,
2823have_getaddrinfo=no)
2824AC_MSG_RESULT($have_getaddrinfo)
2825if test $have_getaddrinfo = yes
2826then
2827 AC_MSG_CHECKING(getaddrinfo bug)
2828 AC_CACHE_VAL(ac_cv_buggy_getaddrinfo,
2829 AC_TRY_RUN([[
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00002830#include <sys/types.h>
2831#include <netdb.h>
2832#include <string.h>
2833#include <sys/socket.h>
2834#include <netinet/in.h>
2835
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00002836int main()
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00002837{
2838 int passive, gaierr, inet4 = 0, inet6 = 0;
2839 struct addrinfo hints, *ai, *aitop;
2840 char straddr[INET6_ADDRSTRLEN], strport[16];
2841
2842 for (passive = 0; passive <= 1; passive++) {
2843 memset(&hints, 0, sizeof(hints));
2844 hints.ai_family = AF_UNSPEC;
2845 hints.ai_flags = passive ? AI_PASSIVE : 0;
2846 hints.ai_socktype = SOCK_STREAM;
Hye-Shik Chang54f94392004-04-14 07:55:31 +00002847 hints.ai_protocol = IPPROTO_TCP;
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00002848 if ((gaierr = getaddrinfo(NULL, "54321", &hints, &aitop)) != 0) {
2849 (void)gai_strerror(gaierr);
2850 goto bad;
2851 }
2852 for (ai = aitop; ai; ai = ai->ai_next) {
2853 if (ai->ai_addr == NULL ||
2854 ai->ai_addrlen == 0 ||
2855 getnameinfo(ai->ai_addr, ai->ai_addrlen,
2856 straddr, sizeof(straddr), strport, sizeof(strport),
2857 NI_NUMERICHOST|NI_NUMERICSERV) != 0) {
2858 goto bad;
2859 }
2860 switch (ai->ai_family) {
2861 case AF_INET:
2862 if (strcmp(strport, "54321") != 0) {
2863 goto bad;
2864 }
2865 if (passive) {
2866 if (strcmp(straddr, "0.0.0.0") != 0) {
2867 goto bad;
2868 }
2869 } else {
2870 if (strcmp(straddr, "127.0.0.1") != 0) {
2871 goto bad;
2872 }
2873 }
2874 inet4++;
2875 break;
2876 case AF_INET6:
2877 if (strcmp(strport, "54321") != 0) {
2878 goto bad;
2879 }
2880 if (passive) {
2881 if (strcmp(straddr, "::") != 0) {
2882 goto bad;
2883 }
2884 } else {
2885 if (strcmp(straddr, "::1") != 0) {
2886 goto bad;
2887 }
2888 }
2889 inet6++;
2890 break;
2891 case AF_UNSPEC:
2892 goto bad;
2893 break;
2894 default:
2895 /* another family support? */
2896 break;
2897 }
2898 }
2899 }
2900
2901 if (!(inet4 == 0 || inet4 == 2))
2902 goto bad;
2903 if (!(inet6 == 0 || inet6 == 2))
2904 goto bad;
2905
2906 if (aitop)
2907 freeaddrinfo(aitop);
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00002908 return 0;
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00002909
2910 bad:
2911 if (aitop)
2912 freeaddrinfo(aitop);
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00002913 return 1;
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00002914}
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00002915]], ac_cv_buggy_getaddrinfo=no,
2916 ac_cv_buggy_getaddrinfo=yes,
2917 ac_cv_buggy_getaddrinfo=yes))
2918fi
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00002919
Mark Dickinson2df5d282009-12-31 21:22:50 +00002920if test $have_getaddrinfo = no -o "$ac_cv_buggy_getaddrinfo" = yes
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00002921then
2922 if test $ipv6 = yes
2923 then
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00002924 echo 'Fatal: You must get working getaddrinfo() function.'
2925 echo ' or you can specify "--disable-ipv6"'.
2926 exit 1
2927 fi
Martin v. Löwis861a65b2001-10-24 14:36:00 +00002928else
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002929 AC_DEFINE(HAVE_GETADDRINFO, 1, [Define if you have the getaddrinfo function.])
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00002930fi
Thomas Woutersb0db85a2001-08-08 10:39:03 +00002931AC_CHECK_FUNCS(getnameinfo)
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00002932
Guido van Rossum627b2d71993-12-24 10:39:16 +00002933# checks for structures
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002934AC_HEADER_TIME
Guido van Rossum627b2d71993-12-24 10:39:16 +00002935AC_STRUCT_TM
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002936AC_STRUCT_TIMEZONE
Martin v. Löwis60a5d722002-10-16 20:28:25 +00002937AC_CHECK_MEMBERS([struct stat.st_rdev])
2938AC_CHECK_MEMBERS([struct stat.st_blksize])
Hye-Shik Chang5f937a72005-06-02 13:09:30 +00002939AC_CHECK_MEMBERS([struct stat.st_flags])
Martin v. Löwisebd9d5b2005-08-09 15:00:59 +00002940AC_CHECK_MEMBERS([struct stat.st_gen])
2941AC_CHECK_MEMBERS([struct stat.st_birthtime])
Guido van Rossum98bf58f2001-10-18 20:34:25 +00002942AC_STRUCT_ST_BLOCKS
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002943
2944AC_MSG_CHECKING(for time.h that defines altzone)
2945AC_CACHE_VAL(ac_cv_header_time_altzone,
2946[AC_TRY_COMPILE([#include <time.h>], [return altzone;],
2947 ac_cv_header_time_altzone=yes,
2948 ac_cv_header_time_altzone=no)])
2949AC_MSG_RESULT($ac_cv_header_time_altzone)
2950if test $ac_cv_header_time_altzone = yes; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002951 AC_DEFINE(HAVE_ALTZONE, 1, [Define this if your time.h defines altzone.])
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002952fi
2953
Guido van Rossum5739e7e1995-01-20 16:50:53 +00002954was_it_defined=no
2955AC_MSG_CHECKING(whether sys/select.h and sys/time.h may both be included)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002956AC_TRY_COMPILE([
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002957#include <sys/types.h>
2958#include <sys/select.h>
2959#include <sys/time.h>
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002960], [;], [
2961 AC_DEFINE(SYS_SELECT_WITH_SYS_TIME, 1,
2962 [Define if you can safely include both <sys/select.h> and <sys/time.h>
2963 (which you can't on SCO ODT 3.0).])
2964 was_it_defined=yes
2965])
Guido van Rossum5739e7e1995-01-20 16:50:53 +00002966AC_MSG_RESULT($was_it_defined)
Guido van Rossum627b2d71993-12-24 10:39:16 +00002967
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00002968AC_MSG_CHECKING(for addrinfo)
2969AC_CACHE_VAL(ac_cv_struct_addrinfo,
2970AC_TRY_COMPILE([
2971# include <netdb.h>],
2972 [struct addrinfo a],
2973 ac_cv_struct_addrinfo=yes,
2974 ac_cv_struct_addrinfo=no))
2975AC_MSG_RESULT($ac_cv_struct_addrinfo)
2976if test $ac_cv_struct_addrinfo = yes; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002977 AC_DEFINE(HAVE_ADDRINFO, 1, [struct addrinfo (netdb.h)])
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00002978fi
2979
2980AC_MSG_CHECKING(for sockaddr_storage)
2981AC_CACHE_VAL(ac_cv_struct_sockaddr_storage,
2982AC_TRY_COMPILE([
2983# include <sys/types.h>
2984# include <sys/socket.h>],
2985 [struct sockaddr_storage s],
2986 ac_cv_struct_sockaddr_storage=yes,
2987 ac_cv_struct_sockaddr_storage=no))
2988AC_MSG_RESULT($ac_cv_struct_sockaddr_storage)
2989if test $ac_cv_struct_sockaddr_storage = yes; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002990 AC_DEFINE(HAVE_SOCKADDR_STORAGE, 1, [struct sockaddr_storage (sys/socket.h)])
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00002991fi
2992
Guido van Rossum627b2d71993-12-24 10:39:16 +00002993# checks for compiler characteristics
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002994
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002995AC_C_CHAR_UNSIGNED
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002996AC_C_CONST
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002997
Guido van Rossum5739e7e1995-01-20 16:50:53 +00002998works=no
2999AC_MSG_CHECKING(for working volatile)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003000AC_TRY_COMPILE([],[volatile int x; x = 0;], works=yes,
3001 AC_DEFINE(volatile, [], [Define to empty if the keyword does not work.])
3002)
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003003AC_MSG_RESULT($works)
Guido van Rossumdabb11b1994-10-11 15:04:27 +00003004
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003005works=no
3006AC_MSG_CHECKING(for working signed char)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003007AC_TRY_COMPILE([], [signed char c;], works=yes,
3008 AC_DEFINE(signed, [], [Define to empty if the keyword does not work.])
3009)
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003010AC_MSG_RESULT($works)
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003011
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003012have_prototypes=no
3013AC_MSG_CHECKING(for prototypes)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003014AC_TRY_COMPILE([int foo(int x) { return 0; }], [return foo(10);],[
3015 AC_DEFINE(HAVE_PROTOTYPES, 1,
3016 [Define if your compiler supports function prototype])
3017 have_prototypes=yes
3018])
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003019AC_MSG_RESULT($have_prototypes)
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003020
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003021works=no
3022AC_MSG_CHECKING(for variable length prototypes and stdarg.h)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003023AC_TRY_COMPILE([
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003024#include <stdarg.h>
Guido van Rossum3f13e481996-08-30 20:58:11 +00003025int foo(int x, ...) {
3026 va_list va;
3027 va_start(va, x);
3028 va_arg(va, int);
3029 va_arg(va, char *);
3030 va_arg(va, double);
3031 return 0;
3032}
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003033], [return foo(10, "", 3.14);], [
3034 AC_DEFINE(HAVE_STDARG_PROTOTYPES, 1,
3035 [Define if your compiler supports variable length function prototypes
3036 (e.g. void fprintf(FILE *, char *, ...);) *and* <stdarg.h>])
3037 works=yes
3038])
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003039AC_MSG_RESULT($works)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003040
Dave Cole331708b2004-08-09 04:51:41 +00003041# check for socketpair
3042AC_MSG_CHECKING(for socketpair)
3043AC_TRY_COMPILE([
3044#include <sys/types.h>
3045#include <sys/socket.h>
3046], void *x=socketpair,
3047 AC_DEFINE(HAVE_SOCKETPAIR, 1, Define if you have the 'socketpair' function.)
3048 AC_MSG_RESULT(yes),
3049 AC_MSG_RESULT(no)
3050)
3051
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003052# check if sockaddr has sa_len member
3053AC_MSG_CHECKING(if sockaddr has sa_len member)
3054AC_TRY_COMPILE([#include <sys/types.h>
3055#include <sys/socket.h>],
3056[struct sockaddr x;
3057x.sa_len = 0;],
3058 AC_MSG_RESULT(yes)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003059 AC_DEFINE(HAVE_SOCKADDR_SA_LEN, 1, [Define if sockaddr has sa_len member]),
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003060 AC_MSG_RESULT(no))
3061
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003062va_list_is_array=no
3063AC_MSG_CHECKING(whether va_list is an array)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003064AC_TRY_COMPILE([
3065#ifdef HAVE_STDARG_PROTOTYPES
3066#include <stdarg.h>
3067#else
3068#include <varargs.h>
3069#endif
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003070], [va_list list1, list2; list1 = list2;], , [
3071 AC_DEFINE(VA_LIST_IS_ARRAY, 1, [Define if a va_list is an array of some kind])
3072 va_list_is_array=yes
3073])
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003074AC_MSG_RESULT($va_list_is_array)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003075
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003076# sigh -- gethostbyname_r is a mess; it can have 3, 5 or 6 arguments :-(
Martin v. Löwis11437992002-04-12 09:54:03 +00003077AH_TEMPLATE(HAVE_GETHOSTBYNAME_R,
3078 [Define this if you have some version of gethostbyname_r()])
3079
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003080AC_CHECK_FUNC(gethostbyname_r, [
3081 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
3082 AC_MSG_CHECKING([gethostbyname_r with 6 args])
3083 OLD_CFLAGS=$CFLAGS
3084 CFLAGS="$CFLAGS $MY_CPPFLAGS $MY_THREAD_CPPFLAGS $MY_CFLAGS"
3085 AC_TRY_COMPILE([
3086# include <netdb.h>
3087 ], [
3088 char *name;
3089 struct hostent *he, *res;
3090 char buffer[2048];
3091 int buflen = 2048;
3092 int h_errnop;
3093
3094 (void) gethostbyname_r(name, he, buffer, buflen, &res, &h_errnop)
3095 ], [
Guido van Rossum8db7d8b1999-03-23 16:40:33 +00003096 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003097 AC_DEFINE(HAVE_GETHOSTBYNAME_R_6_ARG, 1,
3098 [Define this if you have the 6-arg version of gethostbyname_r().])
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003099 AC_MSG_RESULT(yes)
3100 ], [
3101 AC_MSG_RESULT(no)
3102 AC_MSG_CHECKING([gethostbyname_r with 5 args])
3103 AC_TRY_COMPILE([
3104# include <netdb.h>
3105 ], [
3106 char *name;
3107 struct hostent *he;
3108 char buffer[2048];
3109 int buflen = 2048;
3110 int h_errnop;
3111
3112 (void) gethostbyname_r(name, he, buffer, buflen, &h_errnop)
3113 ], [
Guido van Rossum8db7d8b1999-03-23 16:40:33 +00003114 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003115 AC_DEFINE(HAVE_GETHOSTBYNAME_R_5_ARG, 1,
3116 [Define this if you have the 5-arg version of gethostbyname_r().])
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003117 AC_MSG_RESULT(yes)
3118 ], [
3119 AC_MSG_RESULT(no)
3120 AC_MSG_CHECKING([gethostbyname_r with 3 args])
3121 AC_TRY_COMPILE([
3122# include <netdb.h>
3123 ], [
3124 char *name;
3125 struct hostent *he;
3126 struct hostent_data data;
3127
3128 (void) gethostbyname_r(name, he, &data);
3129 ], [
Guido van Rossum8db7d8b1999-03-23 16:40:33 +00003130 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003131 AC_DEFINE(HAVE_GETHOSTBYNAME_R_3_ARG, 1,
3132 [Define this if you have the 3-arg version of gethostbyname_r().])
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003133 AC_MSG_RESULT(yes)
3134 ], [
3135 AC_MSG_RESULT(no)
3136 ])
3137 ])
3138 ])
3139 CFLAGS=$OLD_CFLAGS
3140], [
Thomas Wouters3a584202000-08-05 23:28:51 +00003141 AC_CHECK_FUNCS(gethostbyname)
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003142])
3143AC_SUBST(HAVE_GETHOSTBYNAME_R_6_ARG)
3144AC_SUBST(HAVE_GETHOSTBYNAME_R_5_ARG)
3145AC_SUBST(HAVE_GETHOSTBYNAME_R_3_ARG)
Guido van Rossum8db7d8b1999-03-23 16:40:33 +00003146AC_SUBST(HAVE_GETHOSTBYNAME_R)
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003147AC_SUBST(HAVE_GETHOSTBYNAME)
3148
Guido van Rossum627b2d71993-12-24 10:39:16 +00003149# checks for system services
3150# (none yet)
3151
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003152# Linux requires this for correct f.p. operations
Jeremy Hyltonbe28f5b2000-07-27 21:03:04 +00003153AC_CHECK_FUNC(__fpu_control,
3154 [],
3155 [AC_CHECK_LIB(ieee, __fpu_control)
3156])
Guido van Rossum627b2d71993-12-24 10:39:16 +00003157
Guido van Rossum93274221997-05-09 02:42:00 +00003158# Check for --with-fpectl
Guido van Rossum93274221997-05-09 02:42:00 +00003159AC_MSG_CHECKING(for --with-fpectl)
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00003160AC_ARG_WITH(fpectl,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003161 AC_HELP_STRING(--with-fpectl, enable SIGFPE catching),
3162[
Guido van Rossum93274221997-05-09 02:42:00 +00003163if test "$withval" != no
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003164then
3165 AC_DEFINE(WANT_SIGFPE_HANDLER, 1,
3166 [Define if you want SIGFPE handled (see Include/pyfpe.h).])
3167 AC_MSG_RESULT(yes)
Guido van Rossum93274221997-05-09 02:42:00 +00003168else AC_MSG_RESULT(no)
Guido van Rossumef2255b2000-03-10 22:30:29 +00003169fi],
3170[AC_MSG_RESULT(no)])
Guido van Rossum93274221997-05-09 02:42:00 +00003171
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003172# check for --with-libm=...
3173AC_SUBST(LIBM)
Guido van Rossum4b6b5791996-09-09 20:09:34 +00003174case $ac_sys_system in
Guido van Rossum3dc0a512000-10-05 18:00:06 +00003175Darwin) ;;
Guido van Rossum4b6b5791996-09-09 20:09:34 +00003176*) LIBM=-lm
3177esac
Guido van Rossum93274221997-05-09 02:42:00 +00003178AC_MSG_CHECKING(for --with-libm=STRING)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003179AC_ARG_WITH(libm,
3180 AC_HELP_STRING(--with-libm=STRING, math library),
3181[
Guido van Rossum93274221997-05-09 02:42:00 +00003182if test "$withval" = no
3183then LIBM=
3184 AC_MSG_RESULT(force LIBM empty)
3185elif test "$withval" != yes
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003186then LIBM=$withval
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003187 AC_MSG_RESULT(set LIBM="$withval")
3188else AC_MSG_ERROR([proper usage is --with-libm=STRING])
Guido van Rossum93274221997-05-09 02:42:00 +00003189fi],
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003190[AC_MSG_RESULT(default LIBM="$LIBM")])
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003191
3192# check for --with-libc=...
3193AC_SUBST(LIBC)
Guido van Rossum93274221997-05-09 02:42:00 +00003194AC_MSG_CHECKING(for --with-libc=STRING)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003195AC_ARG_WITH(libc,
3196 AC_HELP_STRING(--with-libc=STRING, C library),
3197[
Guido van Rossum93274221997-05-09 02:42:00 +00003198if test "$withval" = no
3199then LIBC=
3200 AC_MSG_RESULT(force LIBC empty)
3201elif test "$withval" != yes
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003202then LIBC=$withval
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003203 AC_MSG_RESULT(set LIBC="$withval")
3204else AC_MSG_ERROR([proper usage is --with-libc=STRING])
Guido van Rossum93274221997-05-09 02:42:00 +00003205fi],
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003206[AC_MSG_RESULT(default LIBC="$LIBC")])
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003207
Mark Dickinsonb08a53a2009-04-16 19:52:09 +00003208# **************************************************
3209# * Check for various properties of floating point *
3210# **************************************************
Christian Heimes81ee3ef2008-05-04 22:42:01 +00003211
Mark Dickinsonb08a53a2009-04-16 19:52:09 +00003212AC_MSG_CHECKING(whether C doubles are little-endian IEEE 754 binary64)
3213AC_CACHE_VAL(ac_cv_little_endian_double, [
3214AC_TRY_RUN([
3215#include <string.h>
3216int main() {
3217 double x = 9006104071832581.0;
3218 if (memcmp(&x, "\x05\x04\x03\x02\x01\xff\x3f\x43", 8) == 0)
3219 return 0;
3220 else
3221 return 1;
3222}
3223],
3224ac_cv_little_endian_double=yes,
3225ac_cv_little_endian_double=no,
3226ac_cv_little_endian_double=no)])
3227AC_MSG_RESULT($ac_cv_little_endian_double)
3228if test "$ac_cv_little_endian_double" = yes
3229then
3230 AC_DEFINE(DOUBLE_IS_LITTLE_ENDIAN_IEEE754, 1,
3231 [Define if C doubles are 64-bit IEEE 754 binary format, stored
3232 with the least significant byte first])
3233fi
3234
3235AC_MSG_CHECKING(whether C doubles are big-endian IEEE 754 binary64)
3236AC_CACHE_VAL(ac_cv_big_endian_double, [
3237AC_TRY_RUN([
3238#include <string.h>
3239int main() {
3240 double x = 9006104071832581.0;
3241 if (memcmp(&x, "\x43\x3f\xff\x01\x02\x03\x04\x05", 8) == 0)
3242 return 0;
3243 else
3244 return 1;
3245}
3246],
3247ac_cv_big_endian_double=yes,
3248ac_cv_big_endian_double=no,
3249ac_cv_big_endian_double=no)])
3250AC_MSG_RESULT($ac_cv_big_endian_double)
3251if test "$ac_cv_big_endian_double" = yes
3252then
3253 AC_DEFINE(DOUBLE_IS_BIG_ENDIAN_IEEE754, 1,
3254 [Define if C doubles are 64-bit IEEE 754 binary format, stored
3255 with the most significant byte first])
3256fi
3257
3258# Some ARM platforms use a mixed-endian representation for doubles.
3259# While Python doesn't currently have full support for these platforms
3260# (see e.g., issue 1762561), we can at least make sure that float <-> string
3261# conversions work.
3262AC_MSG_CHECKING(whether C doubles are ARM mixed-endian IEEE 754 binary64)
3263AC_CACHE_VAL(ac_cv_mixed_endian_double, [
3264AC_TRY_RUN([
3265#include <string.h>
3266int main() {
3267 double x = 9006104071832581.0;
3268 if (memcmp(&x, "\x01\xff\x3f\x43\x05\x04\x03\x02", 8) == 0)
3269 return 0;
3270 else
3271 return 1;
3272}
3273],
3274ac_cv_mixed_endian_double=yes,
3275ac_cv_mixed_endian_double=no,
3276ac_cv_mixed_endian_double=no)])
3277AC_MSG_RESULT($ac_cv_mixed_endian_double)
3278if test "$ac_cv_mixed_endian_double" = yes
3279then
3280 AC_DEFINE(DOUBLE_IS_ARM_MIXED_ENDIAN_IEEE754, 1,
3281 [Define if C doubles are 64-bit IEEE 754 binary format, stored
3282 in ARM mixed-endian order (byte order 45670123)])
3283fi
3284
Mark Dickinson7abf8d42009-04-18 20:17:52 +00003285# The short float repr introduced in Python 3.1 requires the
3286# correctly-rounded string <-> double conversion functions from
3287# Python/dtoa.c, which in turn require that the FPU uses 53-bit
3288# rounding; this is a problem on x86, where the x87 FPU has a default
Mark Dickinsonf4243f62009-11-15 13:47:27 +00003289# rounding precision of 64 bits. For gcc/x86, we can fix this by
Mark Dickinson7abf8d42009-04-18 20:17:52 +00003290# using inline assembler to get and set the x87 FPU control word.
Mark Dickinsonf4243f62009-11-15 13:47:27 +00003291
3292# This inline assembler syntax may also work for suncc and icc,
3293# so we try it on all platforms.
3294
3295AC_MSG_CHECKING(whether we can use gcc inline assembler to get and set x87 control word)
3296AC_TRY_COMPILE([], [
3297 unsigned short cw;
3298 __asm__ __volatile__ ("fnstcw %0" : "=m" (cw));
3299 __asm__ __volatile__ ("fldcw %0" : : "m" (cw));
3300],
3301[have_gcc_asm_for_x87=yes], [have_gcc_asm_for_x87=no])
3302AC_MSG_RESULT($have_gcc_asm_for_x87)
3303if test "$have_gcc_asm_for_x87" = yes
Mark Dickinsonb08a53a2009-04-16 19:52:09 +00003304then
Mark Dickinsonf4243f62009-11-15 13:47:27 +00003305 AC_DEFINE(HAVE_GCC_ASM_FOR_X87, 1,
3306 [Define if we can use gcc inline assembler to get and set x87 control word])
Mark Dickinsonb08a53a2009-04-16 19:52:09 +00003307fi
Christian Heimes81ee3ef2008-05-04 22:42:01 +00003308
Mark Dickinson3dc7c6a2009-01-04 15:09:02 +00003309# Detect whether system arithmetic is subject to x87-style double
3310# rounding issues. The result of this test has little meaning on non
3311# IEEE 754 platforms. On IEEE 754, test should return 1 if rounding
3312# mode is round-to-nearest and double rounding issues are present, and
3313# 0 otherwise. See http://bugs.python.org/issue2937 for more info.
3314AC_MSG_CHECKING(for x87-style double rounding)
Mark Dickinsonb08a53a2009-04-16 19:52:09 +00003315# $BASECFLAGS may affect the result
3316ac_save_cc="$CC"
3317CC="$CC $BASECFLAGS"
Mark Dickinson3dc7c6a2009-01-04 15:09:02 +00003318AC_TRY_RUN([
3319#include <stdlib.h>
3320#include <math.h>
3321int main() {
3322 volatile double x, y, z;
3323 /* 1./(1-2**-53) -> 1+2**-52 (correct), 1.0 (double rounding) */
3324 x = 0.99999999999999989; /* 1-2**-53 */
3325 y = 1./x;
3326 if (y != 1.)
3327 exit(0);
3328 /* 1e16+2.99999 -> 1e16+2. (correct), 1e16+4. (double rounding) */
3329 x = 1e16;
3330 y = 2.99999;
3331 z = x + y;
3332 if (z != 1e16+4.)
3333 exit(0);
3334 /* both tests show evidence of double rounding */
3335 exit(1);
3336}
3337],
3338ac_cv_x87_double_rounding=no,
3339ac_cv_x87_double_rounding=yes,
Mark Dickinsonb08a53a2009-04-16 19:52:09 +00003340ac_cv_x87_double_rounding=no)
3341CC="$ac_save_cc"
Mark Dickinson3dc7c6a2009-01-04 15:09:02 +00003342AC_MSG_RESULT($ac_cv_x87_double_rounding)
3343if test "$ac_cv_x87_double_rounding" = yes
3344then
3345 AC_DEFINE(X87_DOUBLE_ROUNDING, 1,
3346 [Define if arithmetic is subject to x87-style double rounding issue])
3347fi
3348
Mark Dickinsonb08a53a2009-04-16 19:52:09 +00003349# ************************************
3350# * Check for mathematical functions *
3351# ************************************
3352
3353LIBS_SAVE=$LIBS
3354LIBS="$LIBS $LIBM"
3355
Christian Heimes81ee3ef2008-05-04 22:42:01 +00003356# On FreeBSD 6.2, it appears that tanh(-0.) returns 0. instead of
3357# -0. on some architectures.
3358AC_MSG_CHECKING(whether tanh preserves the sign of zero)
3359AC_CACHE_VAL(ac_cv_tanh_preserves_zero_sign, [
3360AC_TRY_RUN([
3361#include <math.h>
3362#include <stdlib.h>
3363int main() {
3364 /* return 0 if either negative zeros don't exist
3365 on this platform or if negative zeros exist
3366 and tanh(-0.) == -0. */
3367 if (atan2(0., -1.) == atan2(-0., -1.) ||
3368 atan2(tanh(-0.), -1.) == atan2(-0., -1.)) exit(0);
3369 else exit(1);
3370}
3371],
3372ac_cv_tanh_preserves_zero_sign=yes,
3373ac_cv_tanh_preserves_zero_sign=no,
3374ac_cv_tanh_preserves_zero_sign=no)])
3375AC_MSG_RESULT($ac_cv_tanh_preserves_zero_sign)
3376if test "$ac_cv_tanh_preserves_zero_sign" = yes
3377then
3378 AC_DEFINE(TANH_PRESERVES_ZERO_SIGN, 1,
3379 [Define if tanh(-0.) is -0., or if platform doesn't have signed zeros])
3380fi
3381
Mark Dickinson9c113362009-09-05 10:36:23 +00003382AC_CHECK_FUNCS([acosh asinh atanh copysign erf erfc expm1 finite gamma])
3383AC_CHECK_FUNCS([hypot lgamma log1p round tgamma])
Mark Dickinson3dc7c6a2009-01-04 15:09:02 +00003384AC_CHECK_DECLS([isinf, isnan, isfinite], [], [], [[#include <math.h>]])
Christian Heimes99170a52007-12-19 02:07:34 +00003385
Guido van Rossumaf5b83e1995-01-04 19:02:35 +00003386LIBS=$LIBS_SAVE
3387
Mark Dickinsona614f042009-11-28 12:48:43 +00003388# For multiprocessing module, check that sem_open
3389# actually works. For FreeBSD versions <= 7.2,
3390# the kernel module that provides POSIX semaphores
3391# isn't loaded by default, so an attempt to call
3392# sem_open results in a 'Signal 12' error.
3393AC_MSG_CHECKING(whether POSIX semaphores are enabled)
3394AC_CACHE_VAL(ac_cv_posix_semaphores_enabled,
3395AC_TRY_RUN([
3396#include <unistd.h>
3397#include <fcntl.h>
3398#include <stdio.h>
3399#include <semaphore.h>
3400#include <sys/stat.h>
3401
3402int main(void) {
3403 sem_t *a = sem_open("/autoconf", O_CREAT, S_IRUSR|S_IWUSR, 0);
3404 if (a == SEM_FAILED) {
3405 perror("sem_open");
3406 return 1;
3407 }
3408 sem_close(a);
Mark Dickinsonba79b352009-12-13 21:10:57 +00003409 sem_unlink("/autoconf");
Mark Dickinsona614f042009-11-28 12:48:43 +00003410 return 0;
3411}
3412], ac_cv_posix_semaphores_enabled=yes,
3413 ac_cv_posix_semaphores_enabled=no,
3414 ac_cv_posix_semaphores_enabled=yes)
3415)
3416AC_MSG_RESULT($ac_cv_posix_semaphores_enabled)
3417if test $ac_cv_posix_semaphores_enabled = no
3418then
3419 AC_DEFINE(POSIX_SEMAPHORES_NOT_ENABLED, 1,
3420 [Define if POSIX semaphores aren't enabled on your system])
3421fi
3422
Mark Dickinson10683072009-04-18 21:18:19 +00003423# Multiprocessing check for broken sem_getvalue
3424AC_MSG_CHECKING(for broken sem_getvalue)
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00003425AC_CACHE_VAL(ac_cv_broken_sem_getvalue,
Mark Dickinson10683072009-04-18 21:18:19 +00003426AC_TRY_RUN([
3427#include <unistd.h>
3428#include <fcntl.h>
3429#include <stdio.h>
3430#include <semaphore.h>
3431#include <sys/stat.h>
3432
3433int main(void){
Mark Dickinsonba79b352009-12-13 21:10:57 +00003434 sem_t *a = sem_open("/autocftw", O_CREAT, S_IRUSR|S_IWUSR, 0);
Mark Dickinson10683072009-04-18 21:18:19 +00003435 int count;
3436 int res;
3437 if(a==SEM_FAILED){
3438 perror("sem_open");
3439 return 1;
3440
3441 }
3442 res = sem_getvalue(a, &count);
3443 sem_close(a);
Mark Dickinsonba79b352009-12-13 21:10:57 +00003444 sem_unlink("/autocftw");
Mark Dickinson10683072009-04-18 21:18:19 +00003445 return res==-1 ? 1 : 0;
3446}
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00003447], ac_cv_broken_sem_getvalue=no,
3448 ac_cv_broken_sem_getvalue=yes,
3449 ac_cv_broken_sem_getvalue=yes)
Mark Dickinson10683072009-04-18 21:18:19 +00003450)
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00003451AC_MSG_RESULT($ac_cv_broken_sem_getvalue)
3452if test $ac_cv_broken_sem_getvalue = yes
3453then
3454 AC_DEFINE(HAVE_BROKEN_SEM_GETVALUE, 1,
3455 [define to 1 if your sem_getvalue is broken.])
3456fi
Mark Dickinson10683072009-04-18 21:18:19 +00003457
Mark Dickinsonbd792642009-03-18 20:06:12 +00003458# determine what size digit to use for Python's longs
3459AC_MSG_CHECKING([digit size for Python's longs])
3460AC_ARG_ENABLE(big-digits,
3461AC_HELP_STRING([--enable-big-digits@<:@=BITS@:>@],[use big digits for Python longs [[BITS=30]]]),
3462[case $enable_big_digits in
3463yes)
3464 enable_big_digits=30 ;;
3465no)
3466 enable_big_digits=15 ;;
3467[15|30])
3468 ;;
3469*)
3470 AC_MSG_ERROR([bad value $enable_big_digits for --enable-big-digits; value should be 15 or 30]) ;;
3471esac
3472AC_MSG_RESULT($enable_big_digits)
3473AC_DEFINE_UNQUOTED(PYLONG_BITS_IN_DIGIT, $enable_big_digits, [Define as the preferred size in bits of long digits])
3474],
3475[AC_MSG_RESULT(no value specified)])
3476
Guido van Rossumef2255b2000-03-10 22:30:29 +00003477# check for wchar.h
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003478AC_CHECK_HEADER(wchar.h, [
3479 AC_DEFINE(HAVE_WCHAR_H, 1,
3480 [Define if the compiler provides a wchar.h header file.])
3481 wchar_h="yes"
3482],
Guido van Rossumef2255b2000-03-10 22:30:29 +00003483wchar_h="no"
3484)
3485
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003486# determine wchar_t size
3487if test "$wchar_h" = yes
3488then
Guido van Rossum67b26592001-10-20 14:21:45 +00003489 AC_CHECK_SIZEOF(wchar_t, 4, [#include <wchar.h>])
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003490fi
3491
Martin v. Löwisfa3bdea2003-09-04 18:50:54 +00003492AC_MSG_CHECKING(for UCS-4 tcl)
3493have_ucs4_tcl=no
3494AC_TRY_COMPILE([
3495#include <tcl.h>
3496#if TCL_UTF_MAX != 6
3497# error "NOT UCS4_TCL"
3498#endif], [], [
3499 AC_DEFINE(HAVE_UCS4_TCL, 1, [Define this if you have tcl and TCL_UTF_MAX==6])
3500 have_ucs4_tcl=yes
3501])
3502AC_MSG_RESULT($have_ucs4_tcl)
3503
Marc-André Lemburgd7160f82003-09-22 11:14:40 +00003504# check whether wchar_t is signed or not
3505if test "$wchar_h" = yes
3506then
3507 # check whether wchar_t is signed or not
3508 AC_MSG_CHECKING(whether wchar_t is signed)
3509 AC_CACHE_VAL(ac_cv_wchar_t_signed, [
3510 AC_TRY_RUN([
3511 #include <wchar.h>
3512 int main()
3513 {
Thomas Wouters49fd7fa2006-04-21 10:40:58 +00003514 /* Success: exit code 0 */
3515 exit((((wchar_t) -1) < ((wchar_t) 0)) ? 0 : 1);
Marc-André Lemburgd7160f82003-09-22 11:14:40 +00003516 }
3517 ],
3518 ac_cv_wchar_t_signed=yes,
3519 ac_cv_wchar_t_signed=no,
3520 ac_cv_wchar_t_signed=yes)])
3521 AC_MSG_RESULT($ac_cv_wchar_t_signed)
3522fi
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003523
Georg Brandl52d168a2008-01-07 18:10:24 +00003524AC_MSG_CHECKING(what type to use for str)
3525AC_ARG_WITH(wide-unicode,
3526 AC_HELP_STRING(--with-wide-unicode, Use 4-byte Unicode characters (default is 2 bytes)),
3527[
3528if test "$withval" != no
3529then unicode_size="4"
3530else unicode_size="2"
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003531fi
Georg Brandl52d168a2008-01-07 18:10:24 +00003532],
3533[
3534case "$have_ucs4_tcl" in
3535 yes) unicode_size="4" ;;
3536 *) unicode_size="2" ;;
3537esac
3538])
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003539
Martin v. Löwis0036cba2002-04-12 09:58:45 +00003540AH_TEMPLATE(Py_UNICODE_SIZE,
3541 [Define as the size of the unicode type.])
Georg Brandl52d168a2008-01-07 18:10:24 +00003542case "$unicode_size" in
3543 4) AC_DEFINE(Py_UNICODE_SIZE, 4) ;;
3544 *) AC_DEFINE(Py_UNICODE_SIZE, 2) ;;
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003545esac
3546
Martin v. Löwis11437992002-04-12 09:54:03 +00003547AH_TEMPLATE(PY_UNICODE_TYPE,
3548 [Define as the integral type used for Unicode representation.])
Martin v. Löwis0036cba2002-04-12 09:58:45 +00003549
Georg Brandl52d168a2008-01-07 18:10:24 +00003550# wchar_t is only usable if it maps to an unsigned type
3551if test "$unicode_size" = "$ac_cv_sizeof_wchar_t" \
Matthias Klose7dbeed72004-12-24 08:22:17 +00003552 -a "$ac_cv_wchar_t_signed" = "no"
Georg Brandl52d168a2008-01-07 18:10:24 +00003553then
3554 PY_UNICODE_TYPE="wchar_t"
3555 AC_DEFINE(HAVE_USABLE_WCHAR_T, 1,
3556 [Define if you have a useable wchar_t type defined in wchar.h; useable
3557 means wchar_t must be an unsigned type with at least 16 bits. (see
3558 Include/unicodeobject.h).])
3559 AC_DEFINE(PY_UNICODE_TYPE,wchar_t)
3560elif test "$ac_cv_sizeof_short" = "$unicode_size"
3561then
3562 PY_UNICODE_TYPE="unsigned short"
3563 AC_DEFINE(PY_UNICODE_TYPE,unsigned short)
3564elif test "$ac_cv_sizeof_long" = "$unicode_size"
3565then
3566 PY_UNICODE_TYPE="unsigned long"
3567 AC_DEFINE(PY_UNICODE_TYPE,unsigned long)
3568else
3569 PY_UNICODE_TYPE="no type found"
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003570fi
Georg Brandl52d168a2008-01-07 18:10:24 +00003571AC_MSG_RESULT($PY_UNICODE_TYPE)
Guido van Rossumef2255b2000-03-10 22:30:29 +00003572
3573# check for endianness
3574AC_C_BIGENDIAN
3575
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00003576# Check whether right shifting a negative integer extends the sign bit
3577# or fills with zeros (like the Cray J90, according to Tim Peters).
3578AC_MSG_CHECKING(whether right shift extends the sign bit)
Vladimir Marangozova6180282000-07-12 05:05:06 +00003579AC_CACHE_VAL(ac_cv_rshift_extends_sign, [
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00003580AC_TRY_RUN([
3581int main()
3582{
Vladimir Marangozova6180282000-07-12 05:05:06 +00003583 exit(((-1)>>3 == -1) ? 0 : 1);
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00003584}
Guido van Rossum3065c942001-09-17 04:03:14 +00003585],
3586ac_cv_rshift_extends_sign=yes,
3587ac_cv_rshift_extends_sign=no,
3588ac_cv_rshift_extends_sign=yes)])
Vladimir Marangozova6180282000-07-12 05:05:06 +00003589AC_MSG_RESULT($ac_cv_rshift_extends_sign)
3590if test "$ac_cv_rshift_extends_sign" = no
3591then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003592 AC_DEFINE(SIGNED_RIGHT_SHIFT_ZERO_FILLS, 1,
3593 [Define if i>>j for signed int i does not extend the sign bit
3594 when i < 0])
Vladimir Marangozova6180282000-07-12 05:05:06 +00003595fi
3596
Guido van Rossumcadfaec2001-01-05 14:45:49 +00003597# check for getc_unlocked and related locking functions
3598AC_MSG_CHECKING(for getc_unlocked() and friends)
3599AC_CACHE_VAL(ac_cv_have_getc_unlocked, [
3600AC_TRY_LINK([#include <stdio.h>],[
3601 FILE *f = fopen("/dev/null", "r");
3602 flockfile(f);
3603 getc_unlocked(f);
3604 funlockfile(f);
3605], ac_cv_have_getc_unlocked=yes, ac_cv_have_getc_unlocked=no)])
3606AC_MSG_RESULT($ac_cv_have_getc_unlocked)
3607if test "$ac_cv_have_getc_unlocked" = yes
3608then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003609 AC_DEFINE(HAVE_GETC_UNLOCKED, 1,
3610 [Define this if you have flockfile(), getc_unlocked(), and funlockfile()])
Guido van Rossumcadfaec2001-01-05 14:45:49 +00003611fi
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00003612
Neal Norwitzfe8e3d92006-01-07 21:07:20 +00003613# check where readline lives
Martin v. Löwis82bca632006-02-10 20:49:30 +00003614# save the value of LIBS so we don't actually link Python with readline
3615LIBS_no_readline=$LIBS
Gregory P. Smith18820942008-09-07 06:24:49 +00003616
3617# On some systems we need to link readline to a termcap compatible
3618# library. NOTE: Keep the precedence of listed libraries synchronised
3619# with setup.py.
3620py_cv_lib_readline=no
3621AC_MSG_CHECKING([how to link readline libs])
3622for py_libtermcap in "" ncursesw ncurses curses termcap; do
3623 if test -z "$py_libtermcap"; then
3624 READLINE_LIBS="-lreadline"
3625 else
3626 READLINE_LIBS="-lreadline -l$py_libtermcap"
3627 fi
3628 LIBS="$READLINE_LIBS $LIBS_no_readline"
3629 AC_LINK_IFELSE(
3630 [AC_LANG_CALL([],[readline])],
3631 [py_cv_lib_readline=yes])
3632 if test $py_cv_lib_readline = yes; then
3633 break
3634 fi
3635done
3636# Uncomment this line if you want to use READINE_LIBS in Makefile or scripts
3637#AC_SUBST([READLINE_LIBS])
Gregory P. Smith97515912008-09-07 19:23:19 +00003638if test $py_cv_lib_readline = no; then
Gregory P. Smith18820942008-09-07 06:24:49 +00003639 AC_MSG_RESULT([none])
3640else
3641 AC_MSG_RESULT([$READLINE_LIBS])
3642 AC_DEFINE(HAVE_LIBREADLINE, 1,
3643 [Define if you have the readline library (-lreadline).])
Neal Norwitzfe8e3d92006-01-07 21:07:20 +00003644fi
3645
Michael W. Hudson30ea2f22004-07-07 17:44:12 +00003646# check for readline 2.1
3647AC_CHECK_LIB(readline, rl_callback_handler_install,
3648 AC_DEFINE(HAVE_RL_CALLBACK, 1,
Gregory P. Smith18820942008-09-07 06:24:49 +00003649 [Define if you have readline 2.1]), ,$READLINE_LIBS)
Michael W. Hudson30ea2f22004-07-07 17:44:12 +00003650
Guido van Rossumfaf5e4d2002-12-30 16:25:41 +00003651# check for readline 2.2
3652AC_TRY_CPP([#include <readline/readline.h>],
3653have_readline=yes, have_readline=no)
3654if test $have_readline = yes
3655then
3656 AC_EGREP_HEADER([extern int rl_completion_append_character;],
3657 [readline/readline.h],
3658 AC_DEFINE(HAVE_RL_COMPLETION_APPEND_CHARACTER, 1,
3659 [Define if you have readline 2.2]), )
Antoine Pitroud5131772009-10-26 19:22:14 +00003660 AC_EGREP_HEADER([extern int rl_completion_suppress_append;],
3661 [readline/readline.h],
3662 AC_DEFINE(HAVE_RL_COMPLETION_SUPPRESS_APPEND, 1,
3663 [Define if you have rl_completion_suppress_append]), )
Guido van Rossumfaf5e4d2002-12-30 16:25:41 +00003664fi
3665
Martin v. Löwis0daad592001-09-30 21:09:59 +00003666# check for readline 4.0
3667AC_CHECK_LIB(readline, rl_pre_input_hook,
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003668 AC_DEFINE(HAVE_RL_PRE_INPUT_HOOK, 1,
Gregory P. Smith18820942008-09-07 06:24:49 +00003669 [Define if you have readline 4.0]), ,$READLINE_LIBS)
Martin v. Löwis0daad592001-09-30 21:09:59 +00003670
Thomas Wouters89d996e2007-09-08 17:39:28 +00003671# also in 4.0
3672AC_CHECK_LIB(readline, rl_completion_display_matches_hook,
3673 AC_DEFINE(HAVE_RL_COMPLETION_DISPLAY_MATCHES_HOOK, 1,
Gregory P. Smith18820942008-09-07 06:24:49 +00003674 [Define if you have readline 4.0]), ,$READLINE_LIBS)
Thomas Wouters89d996e2007-09-08 17:39:28 +00003675
Guido van Rossum353ae582001-07-10 16:45:32 +00003676# check for readline 4.2
3677AC_CHECK_LIB(readline, rl_completion_matches,
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003678 AC_DEFINE(HAVE_RL_COMPLETION_MATCHES, 1,
Gregory P. Smith18820942008-09-07 06:24:49 +00003679 [Define if you have readline 4.2]), ,$READLINE_LIBS)
Guido van Rossum353ae582001-07-10 16:45:32 +00003680
Michael W. Hudson30ea2f22004-07-07 17:44:12 +00003681# also in readline 4.2
3682AC_TRY_CPP([#include <readline/readline.h>],
3683have_readline=yes, have_readline=no)
3684if test $have_readline = yes
3685then
3686 AC_EGREP_HEADER([extern int rl_catch_signals;],
3687 [readline/readline.h],
3688 AC_DEFINE(HAVE_RL_CATCH_SIGNAL, 1,
3689 [Define if you can turn off readline's signal handling.]), )
3690fi
3691
Martin v. Löwis82bca632006-02-10 20:49:30 +00003692# End of readline checks: restore LIBS
3693LIBS=$LIBS_no_readline
3694
Thomas Wouterse38b2f12001-07-11 22:35:31 +00003695AC_MSG_CHECKING(for broken nice())
3696AC_CACHE_VAL(ac_cv_broken_nice, [
3697AC_TRY_RUN([
3698int main()
3699{
3700 int val1 = nice(1);
3701 if (val1 != -1 && val1 == nice(2))
3702 exit(0);
3703 exit(1);
3704}
Guido van Rossum3065c942001-09-17 04:03:14 +00003705],
3706ac_cv_broken_nice=yes,
3707ac_cv_broken_nice=no,
3708ac_cv_broken_nice=no)])
Thomas Wouterse38b2f12001-07-11 22:35:31 +00003709AC_MSG_RESULT($ac_cv_broken_nice)
3710if test "$ac_cv_broken_nice" = yes
3711then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003712 AC_DEFINE(HAVE_BROKEN_NICE, 1,
3713 [Define if nice() returns success/failure instead of the new priority.])
Thomas Wouterse38b2f12001-07-11 22:35:31 +00003714fi
3715
Nicholas Bastine62c5c82004-03-21 23:45:42 +00003716AC_MSG_CHECKING(for broken poll())
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00003717AC_CACHE_VAL(ac_cv_broken_poll,
Nicholas Bastine62c5c82004-03-21 23:45:42 +00003718AC_TRY_RUN([
3719#include <poll.h>
3720
Alexandre Vassalottiaee170a2009-07-17 06:24:33 +00003721int main()
3722{
Nicholas Bastine62c5c82004-03-21 23:45:42 +00003723 struct pollfd poll_struct = { 42, POLLIN|POLLPRI|POLLOUT, 0 };
Alexandre Vassalottiaee170a2009-07-17 06:24:33 +00003724 int poll_test;
3725
Nicholas Bastine62c5c82004-03-21 23:45:42 +00003726 close (42);
3727
Alexandre Vassalottiaee170a2009-07-17 06:24:33 +00003728 poll_test = poll(&poll_struct, 1, 0);
Nicholas Bastine62c5c82004-03-21 23:45:42 +00003729 if (poll_test < 0)
Alexandre Vassalottiaee170a2009-07-17 06:24:33 +00003730 return 0;
Nicholas Bastine62c5c82004-03-21 23:45:42 +00003731 else if (poll_test == 0 && poll_struct.revents != POLLNVAL)
Alexandre Vassalottiaee170a2009-07-17 06:24:33 +00003732 return 0;
Nicholas Bastine62c5c82004-03-21 23:45:42 +00003733 else
Alexandre Vassalottiaee170a2009-07-17 06:24:33 +00003734 return 1;
3735}
Nicholas Bastine62c5c82004-03-21 23:45:42 +00003736],
3737ac_cv_broken_poll=yes,
3738ac_cv_broken_poll=no,
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00003739ac_cv_broken_poll=no))
Nicholas Bastine62c5c82004-03-21 23:45:42 +00003740AC_MSG_RESULT($ac_cv_broken_poll)
3741if test "$ac_cv_broken_poll" = yes
3742then
3743 AC_DEFINE(HAVE_BROKEN_POLL, 1,
3744 [Define if poll() sets errno on invalid file descriptors.])
3745fi
3746
Brett Cannon43802422005-02-10 20:48:03 +00003747# Before we can test tzset, we need to check if struct tm has a tm_zone
3748# (which is not required by ISO C or UNIX spec) and/or if we support
3749# tzname[]
3750AC_STRUCT_TIMEZONE
Nicholas Bastine62c5c82004-03-21 23:45:42 +00003751
Brett Cannon43802422005-02-10 20:48:03 +00003752# check tzset(3) exists and works like we expect it to
Guido van Rossumd11b62e2003-03-14 21:51:36 +00003753AC_MSG_CHECKING(for working tzset())
3754AC_CACHE_VAL(ac_cv_working_tzset, [
3755AC_TRY_RUN([
3756#include <stdlib.h>
3757#include <time.h>
Brett Cannon18367812003-09-19 00:59:16 +00003758#include <string.h>
Brett Cannon43802422005-02-10 20:48:03 +00003759
3760#if HAVE_TZNAME
3761extern char *tzname[];
3762#endif
3763
Guido van Rossumd11b62e2003-03-14 21:51:36 +00003764int main()
3765{
Brett Cannon18367812003-09-19 00:59:16 +00003766 /* Note that we need to ensure that not only does tzset(3)
3767 do 'something' with localtime, but it works as documented
3768 in the library reference and as expected by the test suite.
Brett Cannon43802422005-02-10 20:48:03 +00003769 This includes making sure that tzname is set properly if
3770 tm->tm_zone does not exist since it is the alternative way
3771 of getting timezone info.
Brett Cannon18367812003-09-19 00:59:16 +00003772
3773 Red Hat 6.2 doesn't understand the southern hemisphere
Brett Cannon43802422005-02-10 20:48:03 +00003774 after New Year's Day.
Brett Cannon18367812003-09-19 00:59:16 +00003775 */
3776
Brett Cannon43802422005-02-10 20:48:03 +00003777 time_t groundhogday = 1044144000; /* GMT-based */
Brett Cannon18367812003-09-19 00:59:16 +00003778 time_t midyear = groundhogday + (365 * 24 * 3600 / 2);
3779
Neal Norwitz7f2588c2003-04-11 15:35:53 +00003780 putenv("TZ=UTC+0");
Guido van Rossumd11b62e2003-03-14 21:51:36 +00003781 tzset();
Brett Cannon18367812003-09-19 00:59:16 +00003782 if (localtime(&groundhogday)->tm_hour != 0)
3783 exit(1);
Brett Cannon43802422005-02-10 20:48:03 +00003784#if HAVE_TZNAME
3785 /* For UTC, tzname[1] is sometimes "", sometimes " " */
3786 if (strcmp(tzname[0], "UTC") ||
3787 (tzname[1][0] != 0 && tzname[1][0] != ' '))
3788 exit(1);
3789#endif
Brett Cannon18367812003-09-19 00:59:16 +00003790
Neal Norwitz7f2588c2003-04-11 15:35:53 +00003791 putenv("TZ=EST+5EDT,M4.1.0,M10.5.0");
Guido van Rossumd11b62e2003-03-14 21:51:36 +00003792 tzset();
Brett Cannon18367812003-09-19 00:59:16 +00003793 if (localtime(&groundhogday)->tm_hour != 19)
Guido van Rossumd11b62e2003-03-14 21:51:36 +00003794 exit(1);
Brett Cannon43802422005-02-10 20:48:03 +00003795#if HAVE_TZNAME
3796 if (strcmp(tzname[0], "EST") || strcmp(tzname[1], "EDT"))
3797 exit(1);
3798#endif
Brett Cannon18367812003-09-19 00:59:16 +00003799
3800 putenv("TZ=AEST-10AEDT-11,M10.5.0,M3.5.0");
3801 tzset();
3802 if (localtime(&groundhogday)->tm_hour != 11)
3803 exit(1);
Brett Cannon43802422005-02-10 20:48:03 +00003804#if HAVE_TZNAME
3805 if (strcmp(tzname[0], "AEST") || strcmp(tzname[1], "AEDT"))
3806 exit(1);
3807#endif
3808
3809#if HAVE_STRUCT_TM_TM_ZONE
Brett Cannon18367812003-09-19 00:59:16 +00003810 if (strcmp(localtime(&groundhogday)->tm_zone, "AEDT"))
3811 exit(1);
3812 if (strcmp(localtime(&midyear)->tm_zone, "AEST"))
3813 exit(1);
Brett Cannon43802422005-02-10 20:48:03 +00003814#endif
Brett Cannon18367812003-09-19 00:59:16 +00003815
Guido van Rossumd11b62e2003-03-14 21:51:36 +00003816 exit(0);
3817}
3818],
3819ac_cv_working_tzset=yes,
3820ac_cv_working_tzset=no,
3821ac_cv_working_tzset=no)])
3822AC_MSG_RESULT($ac_cv_working_tzset)
3823if test "$ac_cv_working_tzset" = yes
3824then
3825 AC_DEFINE(HAVE_WORKING_TZSET, 1,
3826 [Define if tzset() actually switches the local timezone in a meaningful way.])
3827fi
3828
Martin v. Löwis94717ed2002-09-09 14:24:16 +00003829# Look for subsecond timestamps in struct stat
3830AC_MSG_CHECKING(for tv_nsec in struct stat)
3831AC_CACHE_VAL(ac_cv_stat_tv_nsec,
3832AC_TRY_COMPILE([#include <sys/stat.h>], [
3833struct stat st;
3834st.st_mtim.tv_nsec = 1;
3835],
Martin v. Löwisa32c9942002-09-09 16:17:47 +00003836ac_cv_stat_tv_nsec=yes,
Martin v. Löwis94717ed2002-09-09 14:24:16 +00003837ac_cv_stat_tv_nsec=no,
3838ac_cv_stat_tv_nsec=no))
3839AC_MSG_RESULT($ac_cv_stat_tv_nsec)
3840if test "$ac_cv_stat_tv_nsec" = yes
3841then
3842 AC_DEFINE(HAVE_STAT_TV_NSEC, 1,
3843 [Define if you have struct stat.st_mtim.tv_nsec])
3844fi
3845
Martin v. Löwisebd9d5b2005-08-09 15:00:59 +00003846# Look for BSD style subsecond timestamps in struct stat
3847AC_MSG_CHECKING(for tv_nsec2 in struct stat)
3848AC_CACHE_VAL(ac_cv_stat_tv_nsec2,
3849AC_TRY_COMPILE([#include <sys/stat.h>], [
3850struct stat st;
3851st.st_mtimespec.tv_nsec = 1;
3852],
3853ac_cv_stat_tv_nsec2=yes,
3854ac_cv_stat_tv_nsec2=no,
3855ac_cv_stat_tv_nsec2=no))
3856AC_MSG_RESULT($ac_cv_stat_tv_nsec2)
3857if test "$ac_cv_stat_tv_nsec2" = yes
3858then
3859 AC_DEFINE(HAVE_STAT_TV_NSEC2, 1,
3860 [Define if you have struct stat.st_mtimensec])
3861fi
3862
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00003863# On HP/UX 11.0, mvwdelch is a block with a return statement
3864AC_MSG_CHECKING(whether mvwdelch is an expression)
3865AC_CACHE_VAL(ac_cv_mvwdelch_is_expression,
3866AC_TRY_COMPILE([#include <curses.h>], [
3867 int rtn;
3868 rtn = mvwdelch(0,0,0);
3869], ac_cv_mvwdelch_is_expression=yes,
3870 ac_cv_mvwdelch_is_expression=no,
3871 ac_cv_mvwdelch_is_expression=yes))
3872AC_MSG_RESULT($ac_cv_mvwdelch_is_expression)
3873
3874if test "$ac_cv_mvwdelch_is_expression" = yes
3875then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003876 AC_DEFINE(MVWDELCH_IS_EXPRESSION, 1,
3877 [Define if mvwdelch in curses.h is an expression.])
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00003878fi
3879
3880AC_MSG_CHECKING(whether WINDOW has _flags)
3881AC_CACHE_VAL(ac_cv_window_has_flags,
3882AC_TRY_COMPILE([#include <curses.h>], [
3883 WINDOW *w;
3884 w->_flags = 0;
3885], ac_cv_window_has_flags=yes,
3886 ac_cv_window_has_flags=no,
3887 ac_cv_window_has_flags=no))
3888AC_MSG_RESULT($ac_cv_window_has_flags)
3889
3890
3891if test "$ac_cv_window_has_flags" = yes
3892then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003893 AC_DEFINE(WINDOW_HAS_FLAGS, 1,
3894 [Define if WINDOW in curses.h offers a field _flags.])
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00003895fi
3896
Thomas Wouters0e3f5912006-08-11 14:57:12 +00003897AC_MSG_CHECKING(for is_term_resized)
3898AC_TRY_COMPILE([#include <curses.h>], void *x=is_term_resized,
3899 AC_DEFINE(HAVE_CURSES_IS_TERM_RESIZED, 1, Define if you have the 'is_term_resized' function.)
3900 AC_MSG_RESULT(yes),
Martin v. Löwis24a880b2002-12-31 12:55:15 +00003901 AC_MSG_RESULT(no)
Thomas Wouters0e3f5912006-08-11 14:57:12 +00003902)
Martin v. Löwis24a880b2002-12-31 12:55:15 +00003903
Thomas Wouters0e3f5912006-08-11 14:57:12 +00003904AC_MSG_CHECKING(for resize_term)
3905AC_TRY_COMPILE([#include <curses.h>], void *x=resize_term,
3906 AC_DEFINE(HAVE_CURSES_RESIZE_TERM, 1, Define if you have the 'resize_term' function.)
3907 AC_MSG_RESULT(yes),
Neal Norwitz865400f2003-03-21 01:42:58 +00003908 AC_MSG_RESULT(no)
Thomas Wouters0e3f5912006-08-11 14:57:12 +00003909)
3910
3911AC_MSG_CHECKING(for resizeterm)
3912AC_TRY_COMPILE([#include <curses.h>], void *x=resizeterm,
3913 AC_DEFINE(HAVE_CURSES_RESIZETERM, 1, Define if you have the 'resizeterm' function.)
3914 AC_MSG_RESULT(yes),
3915 AC_MSG_RESULT(no)
3916)
3917
Thomas Wouters89f507f2006-12-13 04:49:30 +00003918AC_MSG_CHECKING(for /dev/ptmx)
3919
3920if test -r /dev/ptmx
3921then
3922 AC_MSG_RESULT(yes)
3923 AC_DEFINE(HAVE_DEV_PTMX, 1,
3924 [Define if we have /dev/ptmx.])
3925else
3926 AC_MSG_RESULT(no)
3927fi
3928
3929AC_MSG_CHECKING(for /dev/ptc)
3930
3931if test -r /dev/ptc
3932then
3933 AC_MSG_RESULT(yes)
3934 AC_DEFINE(HAVE_DEV_PTC, 1,
3935 [Define if we have /dev/ptc.])
3936else
3937 AC_MSG_RESULT(no)
3938fi
Neal Norwitz865400f2003-03-21 01:42:58 +00003939
Mark Dickinson6ce4a9a2009-11-16 17:00:11 +00003940if test "$have_long_long" = yes
3941then
3942 AC_MSG_CHECKING(for %lld and %llu printf() format support)
3943 AC_CACHE_VAL(ac_cv_have_long_long_format,
3944 AC_TRY_RUN([[
3945 #include <stdio.h>
3946 #include <stddef.h>
3947 #include <string.h>
3948
3949 #ifdef HAVE_SYS_TYPES_H
3950 #include <sys/types.h>
3951 #endif
3952
3953 int main()
3954 {
3955 char buffer[256];
3956
3957 if (sprintf(buffer, "%lld", (long long)123) < 0)
3958 return 1;
3959 if (strcmp(buffer, "123"))
3960 return 1;
3961
3962 if (sprintf(buffer, "%lld", (long long)-123) < 0)
3963 return 1;
3964 if (strcmp(buffer, "-123"))
3965 return 1;
3966
3967 if (sprintf(buffer, "%llu", (unsigned long long)123) < 0)
3968 return 1;
3969 if (strcmp(buffer, "123"))
3970 return 1;
3971
3972 return 0;
3973 }
3974 ]], ac_cv_have_long_long_format=yes,
3975 ac_cv_have_long_long_format=no,
3976 ac_cv_have_long_long_format=no)
3977 )
3978 AC_MSG_RESULT($ac_cv_have_long_long_format)
3979fi
3980
Mark Dickinson89d7d412009-12-31 20:50:59 +00003981if test "$ac_cv_have_long_long_format" = yes
Mark Dickinson6ce4a9a2009-11-16 17:00:11 +00003982then
3983 AC_DEFINE(PY_FORMAT_LONG_LONG, "ll",
3984 [Define to printf format modifier for long long type])
3985fi
3986
Ronald Oussoren3c1928a2009-11-19 17:15:31 +00003987if test $ac_sys_system = Darwin
3988then
3989 LIBS="$LIBS -framework CoreFoundation"
3990fi
Mark Dickinson6ce4a9a2009-11-16 17:00:11 +00003991
Benjamin Peterson8f326b22009-12-13 02:10:36 +00003992AC_CACHE_CHECK([for %zd printf() format support], ac_cv_have_size_t_format, [dnl
3993AC_TRY_RUN([
Alexandre Vassalottie5091f62009-07-17 06:41:02 +00003994#include <stdio.h>
Thomas Wouters477c8d52006-05-27 19:21:47 +00003995#include <stddef.h>
3996#include <string.h>
3997
Christian Heimes2c181612007-12-17 20:04:13 +00003998#ifdef HAVE_SYS_TYPES_H
3999#include <sys/types.h>
4000#endif
Thomas Wouters89f507f2006-12-13 04:49:30 +00004001
4002#ifdef HAVE_SSIZE_T
4003typedef ssize_t Py_ssize_t;
4004#elif SIZEOF_VOID_P == SIZEOF_LONG
4005typedef long Py_ssize_t;
4006#else
4007typedef int Py_ssize_t;
4008#endif
Thomas Wouters477c8d52006-05-27 19:21:47 +00004009
Christian Heimes2c181612007-12-17 20:04:13 +00004010int main()
4011{
4012 char buffer[256];
4013
Thomas Wouters477c8d52006-05-27 19:21:47 +00004014 if(sprintf(buffer, "%zd", (size_t)123) < 0)
4015 return 1;
4016
Thomas Wouters89f507f2006-12-13 04:49:30 +00004017 if (strcmp(buffer, "123"))
Thomas Wouters477c8d52006-05-27 19:21:47 +00004018 return 1;
Thomas Wouters89f507f2006-12-13 04:49:30 +00004019
4020 if (sprintf(buffer, "%zd", (Py_ssize_t)-123) < 0)
4021 return 1;
4022
4023 if (strcmp(buffer, "-123"))
4024 return 1;
4025
Thomas Wouters477c8d52006-05-27 19:21:47 +00004026 return 0;
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00004027}
Benjamin Peterson8f326b22009-12-13 02:10:36 +00004028], ac_cv_have_size_t_format=yes,
Alexandre Vassalottie5091f62009-07-17 06:41:02 +00004029 ac_cv_have_size_t_format=no,
Benjamin Peterson8f326b22009-12-13 02:10:36 +00004030 [ac_cv_have_size_t_format="cross -- assuming yes"]
4031)])
4032if test "$ac_cv_have_size_t_format" != no ; then
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00004033 AC_DEFINE(PY_FORMAT_SIZE_T, "z",
4034 [Define to printf format modifier for Py_ssize_t])
4035fi
Thomas Wouters477c8d52006-05-27 19:21:47 +00004036
Martin v. Löwis01c04012002-11-11 14:58:44 +00004037AC_CHECK_TYPE(socklen_t,,
4038 AC_DEFINE(socklen_t,int,
4039 Define to `int' if <sys/socket.h> does not define.),[
4040#ifdef HAVE_SYS_TYPES_H
4041#include <sys/types.h>
4042#endif
Guido van Rossum95713eb2000-05-18 20:53:31 +00004043#ifdef HAVE_SYS_SOCKET_H
4044#include <sys/socket.h>
4045#endif
Martin v. Löwis01c04012002-11-11 14:58:44 +00004046])
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00004047
Antoine Pitroufff95302008-09-03 18:58:51 +00004048AC_MSG_CHECKING(for broken mbstowcs)
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00004049AC_CACHE_VAL(ac_cv_broken_mbstowcs,
Antoine Pitroufff95302008-09-03 18:58:51 +00004050AC_TRY_RUN([
4051#include<stdlib.h>
4052int main() {
4053 size_t len = -1;
4054 const char *str = "text";
4055 len = mbstowcs(NULL, str, 0);
4056 return (len != 4);
4057}
4058],
4059ac_cv_broken_mbstowcs=no,
4060ac_cv_broken_mbstowcs=yes,
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00004061ac_cv_broken_mbstowcs=no))
Antoine Pitroufff95302008-09-03 18:58:51 +00004062AC_MSG_RESULT($ac_cv_broken_mbstowcs)
4063if test "$ac_cv_broken_mbstowcs" = yes
4064then
4065 AC_DEFINE(HAVE_BROKEN_MBSTOWCS, 1,
4066 [Define if mbstowcs(NULL, "text", 0) does not return the number of
4067 wide chars that would be converted.])
4068fi
4069
Antoine Pitroub52ec782009-01-25 16:34:23 +00004070# Check for --with-computed-gotos
4071AC_MSG_CHECKING(for --with-computed-gotos)
4072AC_ARG_WITH(computed-gotos,
4073 AC_HELP_STRING(--with-computed-gotos,
4074 Use computed gotos / threaded dispatch in evaluation loop (not available on all compilers)),
4075[
4076if test "$withval" != no
4077then
4078 AC_DEFINE(USE_COMPUTED_GOTOS, 1,
4079 [Define if you want to use computed gotos in ceval.c.])
4080 AC_MSG_RESULT(yes)
4081else AC_MSG_RESULT(no)
4082fi],
4083[AC_MSG_RESULT(no)])
4084
4085
Martin v. Löwis06f15bb2001-12-02 13:02:32 +00004086AC_SUBST(THREADHEADERS)
4087
4088for h in `(cd $srcdir;echo Python/thread_*.h)`
4089do
4090 THREADHEADERS="$THREADHEADERS \$(srcdir)/$h"
4091done
4092
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00004093AC_SUBST(SRCDIRS)
Neal Norwitzd24499d2005-12-18 21:36:39 +00004094SRCDIRS="Parser Grammar Objects Python Modules Mac"
Andrew M. Kuchling8abedde2001-01-26 22:55:24 +00004095AC_MSG_CHECKING(for build directories)
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00004096for dir in $SRCDIRS; do
4097 if test ! -d $dir; then
4098 mkdir $dir
Fred Drake884d3ba2000-11-02 17:52:56 +00004099 fi
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00004100done
4101AC_MSG_RESULT(done)
Fred Drake036144d2000-10-26 17:09:35 +00004102
Guido van Rossum627b2d71993-12-24 10:39:16 +00004103# generate output files
Antoine Pitrou20327222009-05-24 20:39:11 +00004104AC_CONFIG_FILES(Makefile.pre Modules/Setup.config Misc/python.pc)
Martin v. Löwis88afe662002-10-26 13:47:44 +00004105AC_OUTPUT
Neil Schemenauer61c51152001-01-26 16:18:16 +00004106
Thomas Wouters49fd7fa2006-04-21 10:40:58 +00004107echo "creating Modules/Setup"
Neil Schemenauer61c51152001-01-26 16:18:16 +00004108if test ! -f Modules/Setup
4109then
4110 cp $srcdir/Modules/Setup.dist Modules/Setup
4111fi
4112
Thomas Wouters49fd7fa2006-04-21 10:40:58 +00004113echo "creating Modules/Setup.local"
Neil Schemenauer61c51152001-01-26 16:18:16 +00004114if test ! -f Modules/Setup.local
4115then
4116 echo "# Edit this file for local setup changes" >Modules/Setup.local
4117fi
4118
4119echo "creating Makefile"
4120$SHELL $srcdir/Modules/makesetup -c $srcdir/Modules/config.c.in \
4121 -s Modules Modules/Setup.config \
Neil Schemenauerf8b71c52001-04-21 17:41:16 +00004122 Modules/Setup.local Modules/Setup
Neil Schemenauer66252162001-02-19 04:47:42 +00004123mv config.c Modules