blob: 4feb4a336aa63f0cfcac281c82e7fa4530ba5111 [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,
Matthias Klosec80c93f2010-04-24 17:04:35 +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,
Matthias Klosec80c93f2010-04-24 17:04:35 +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,
Matthias Klosec80c93f2010-04-24 17:04:35 +0000146 AC_HELP_STRING([--with-framework-name=FRAMEWORK],
147 [specify an alternate name of the framework built with --enable-framework]),
Christian Heimes81ee3ef2008-05-04 22:42:01 +0000148[
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,
Matthias Klosec80c93f2010-04-24 17:04:35 +0000159 AC_HELP_STRING([--enable-framework@<:@=INSTALLDIR@:>@], [Build (MacOSX|Darwin) framework]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000160[
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,
Matthias Klosec80c93f2010-04-24 17:04:35 +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,
Matthias Klosec80c93f2010-04-24 17:04:35 +0000420 AC_HELP_STRING([--without-gcc], [never use gcc]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000421[
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,
Matthias Klosec80c93f2010-04-24 17:04:35 +0000517 AC_HELP_STRING([--with-suffix=.exe], [set executable suffix]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000518[
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,
Matthias Klosec80c93f2010-04-24 17:04:35 +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,
Matthias Klosec80c93f2010-04-24 17:04:35 +0000660 AC_HELP_STRING([--enable-profiling], [enable C-level code profiling]),
Skip Montanaro56f6a4f2004-06-18 02:47:22 +0000661[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,
Matthias Klosec80c93f2010-04-24 17:04:35 +0000796 AC_HELP_STRING([--with-pydebug], [build with Py_DEBUG defined]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000797[
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.
Ronald Oussoren666028b2010-04-18 19:07:43 +0000911 if test "${CC}" = gcc
912 then
913 AC_MSG_CHECKING(which compiler should be used)
914 case "${UNIVERSALSDK}" in
915 */MacOSX10.4u.sdk)
916 # Build using 10.4 SDK, force usage of gcc when the
917 # compiler is gcc, otherwise the user will get very
918 # confusing error messages when building on OSX 10.6
919 CC=gcc-4.0
920 CPP=cpp-4.0
921 ;;
922 esac
923 AC_MSG_RESULT($CC)
924 fi
Benjamin Peterson67c38e22008-07-17 16:10:34 +0000925
926
Thomas Wouters477c8d52006-05-27 19:21:47 +0000927 if test "${enable_universalsdk}"; then
Georg Brandlfcaf9102008-07-16 02:17:56 +0000928 UNIVERSAL_ARCH_FLAGS=""
929 if test "$UNIVERSAL_ARCHS" = "32-bit" ; then
930 UNIVERSAL_ARCH_FLAGS="-arch ppc -arch i386"
Benjamin Peterson6794aa32008-07-16 20:33:37 +0000931 ARCH_RUN_32BIT=""
Benjamin Peterson051858e2010-04-11 22:14:02 +0000932 LIPO_32BIT_FLAGS=""
Georg Brandlfcaf9102008-07-16 02:17:56 +0000933 elif test "$UNIVERSAL_ARCHS" = "64-bit" ; then
934 UNIVERSAL_ARCH_FLAGS="-arch ppc64 -arch x86_64"
Ronald Oussoren6f6c5622009-12-24 14:03:19 +0000935 LIPO_32BIT_FLAGS=""
Ronald Oussoren5bbab3e2009-09-06 11:01:15 +0000936 ARCH_RUN_32BIT="true"
Georg Brandlfcaf9102008-07-16 02:17:56 +0000937
938 elif test "$UNIVERSAL_ARCHS" = "all" ; then
939 UNIVERSAL_ARCH_FLAGS="-arch i386 -arch ppc -arch ppc64 -arch x86_64"
Ronald Oussoren6f6c5622009-12-24 14:03:19 +0000940 LIPO_32BIT_FLAGS="-extract ppc7400 -extract i386"
Ronald Oussoren564f7f22010-02-11 13:23:08 +0000941 ARCH_RUN_32BIT="/usr/bin/arch -i386 -ppc"
Georg Brandlfcaf9102008-07-16 02:17:56 +0000942
Ronald Oussoren3c064c12009-09-08 07:12:42 +0000943 elif test "$UNIVERSAL_ARCHS" = "intel" ; then
944 UNIVERSAL_ARCH_FLAGS="-arch i386 -arch x86_64"
Ronald Oussoren6f6c5622009-12-24 14:03:19 +0000945 LIPO_32BIT_FLAGS="-extract i386"
Ronald Oussoren564f7f22010-02-11 13:23:08 +0000946 ARCH_RUN_32BIT="/usr/bin/arch -i386"
Ronald Oussoren3c064c12009-09-08 07:12:42 +0000947
948 elif test "$UNIVERSAL_ARCHS" = "3-way" ; then
949 UNIVERSAL_ARCH_FLAGS="-arch i386 -arch ppc -arch x86_64"
Ronald Oussoren6f6c5622009-12-24 14:03:19 +0000950 LIPO_32BIT_FLAGS="-extract ppc7400 -extract i386"
Ronald Oussoren564f7f22010-02-11 13:23:08 +0000951 ARCH_RUN_32BIT="/usr/bin/arch -i386 -ppc"
Ronald Oussoren3c064c12009-09-08 07:12:42 +0000952
Georg Brandlfcaf9102008-07-16 02:17:56 +0000953 else
Ronald Oussoren74f29b42009-09-20 20:09:26 +0000954 AC_MSG_ERROR([proper usage is --with-universal-arch=32-bit|64-bit|all|intel|3-way])
Georg Brandlfcaf9102008-07-16 02:17:56 +0000955
956 fi
957
958
Ronald Oussoren666028b2010-04-18 19:07:43 +0000959 CFLAGS="${UNIVERSAL_ARCH_FLAGS} -isysroot ${UNIVERSALSDK} ${CFLAGS}"
960 if test "${UNIVERSALSDK}" != "/"
961 then
962 CFLAGS="-isysroot ${UNIVERSALSDK} ${CFLAGS}"
963 LDFLAGS="-isysroot ${UNIVERSALSDK} ${LDFLAGS}"
Ronald Oussoren712979d2010-04-20 19:51:33 +0000964 CPPFLAGS="-isysroot ${UNIVERSALSDK} ${CPPFLAGS}"
Benjamin Peterson67c38e22008-07-17 16:10:34 +0000965 fi
Thomas Wouters477c8d52006-05-27 19:21:47 +0000966 fi
967
Benjamin Peterson67c38e22008-07-17 16:10:34 +0000968 # Calculate the right deployment target for this build.
969 #
970 cur_target=`sw_vers -productVersion | sed 's/\(10\.[[0-9]]*\).*/\1/'`
971 if test ${cur_target} '>' 10.2; then
972 cur_target=10.3
Ronald Oussoren5bbab3e2009-09-06 11:01:15 +0000973 if test ${enable_universalsdk}; then
974 if test "${UNIVERSAL_ARCHS}" = "all"; then
975 # Ensure that the default platform for a
976 # 4-way universal build is OSX 10.5,
977 # that's the first OS release where
978 # 4-way builds make sense.
979 cur_target='10.5'
Ronald Oussoren3c064c12009-09-08 07:12:42 +0000980
981 elif test "${UNIVERSAL_ARCHS}" = "3-way"; then
982 cur_target='10.5'
983
984 elif test "${UNIVERSAL_ARCHS}" = "intel"; then
985 cur_target='10.5'
986
987 elif test "${UNIVERSAL_ARCHS}" = "64-bit"; then
988 cur_target='10.5'
Ronald Oussoren5bbab3e2009-09-06 11:01:15 +0000989 fi
990 else
Ronald Oussorene3da75a2010-02-11 13:38:58 +0000991 if test `/usr/bin/arch` = "i386"; then
Ronald Oussoren5bbab3e2009-09-06 11:01:15 +0000992 # On Intel macs default to a deployment
993 # target of 10.4, that's the first OSX
994 # release with Intel support.
995 cur_target="10.4"
996 fi
997 fi
Benjamin Peterson67c38e22008-07-17 16:10:34 +0000998 fi
999 CONFIGURE_MACOSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET-${cur_target}}
1000
1001 # Make sure that MACOSX_DEPLOYMENT_TARGET is set in the
1002 # environment with a value that is the same as what we'll use
1003 # in the Makefile to ensure that we'll get the same compiler
1004 # environment during configure and build time.
1005 MACOSX_DEPLOYMENT_TARGET="$CONFIGURE_MACOSX_DEPLOYMENT_TARGET"
1006 export MACOSX_DEPLOYMENT_TARGET
1007 EXPORT_MACOSX_DEPLOYMENT_TARGET=''
1008
Skip Montanarodecc6a42003-01-01 20:07:49 +00001009 ;;
Thomas Wouters49fd7fa2006-04-21 10:40:58 +00001010 OSF*)
1011 BASECFLAGS="$BASECFLAGS -mieee"
1012 ;;
Skip Montanarodecc6a42003-01-01 20:07:49 +00001013 esac
1014 ;;
1015
1016*)
1017 case $ac_sys_system in
1018 OpenUNIX*|UnixWare*)
1019 BASECFLAGS="$BASECFLAGS -K pentium,host,inline,loop_unroll,alloca "
1020 ;;
Neal Norwitzb44f1652003-05-26 14:11:55 +00001021 OSF*)
1022 BASECFLAGS="$BASECFLAGS -ieee -std"
1023 ;;
Skip Montanarodecc6a42003-01-01 20:07:49 +00001024 SCO_SV*)
1025 BASECFLAGS="$BASECFLAGS -belf -Ki486 -DSCO5"
1026 ;;
1027 esac
1028 ;;
1029esac
1030
Fred Drakee1ceaa02001-12-04 20:55:47 +00001031if test "$Py_DEBUG" = 'true'; then
1032 :
1033else
1034 OPT="-DNDEBUG $OPT"
1035fi
1036
Guido van Rossum6f2260e1996-09-09 16:21:03 +00001037if test "$ac_arch_flags"
Guido van Rossumc5a39031996-07-31 17:35:03 +00001038then
Skip Montanarodecc6a42003-01-01 20:07:49 +00001039 BASECFLAGS="$BASECFLAGS $ac_arch_flags"
Guido van Rossumc5a39031996-07-31 17:35:03 +00001040fi
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001041
Neal Norwitz020c46a2006-01-07 21:39:28 +00001042# disable check for icc since it seems to pass, but generates a warning
1043if test "$CC" = icc
1044then
1045 ac_cv_opt_olimit_ok=no
1046fi
1047
Guido van Rossum91922671997-10-09 20:24:13 +00001048AC_MSG_CHECKING(whether $CC accepts -OPT:Olimit=0)
1049AC_CACHE_VAL(ac_cv_opt_olimit_ok,
1050[ac_save_cc="$CC"
1051CC="$CC -OPT:Olimit=0"
Gregory P. Smith4e3ed012009-11-01 21:09:10 +00001052AC_TRY_COMPILE([],[int main() { return 0; }],
Guido van Rossum91922671997-10-09 20:24:13 +00001053 ac_cv_opt_olimit_ok=yes,
Guido van Rossum3065c942001-09-17 04:03:14 +00001054 ac_cv_opt_olimit_ok=no,
Gregory P. Smith4e3ed012009-11-01 21:09:10 +00001055 )
Guido van Rossum91922671997-10-09 20:24:13 +00001056CC="$ac_save_cc"])
1057AC_MSG_RESULT($ac_cv_opt_olimit_ok)
Guido van Rossum2efa34b1997-10-23 17:43:11 +00001058if test $ac_cv_opt_olimit_ok = yes; then
Guido van Rossum5839e582000-10-09 19:52:35 +00001059 case $ac_sys_system in
Skip Montanarodecc6a42003-01-01 20:07:49 +00001060 # XXX is this branch needed? On MacOSX 10.2.2 the result of the
1061 # olimit_ok test is "no". Is it "yes" in some other Darwin-esque
1062 # environment?
1063 Darwin*)
1064 ;;
1065 *)
1066 BASECFLAGS="$BASECFLAGS -OPT:Olimit=0"
1067 ;;
Guido van Rossum5839e582000-10-09 19:52:35 +00001068 esac
Guido van Rossumf8678121998-07-07 21:05:09 +00001069else
1070 AC_MSG_CHECKING(whether $CC accepts -Olimit 1500)
1071 AC_CACHE_VAL(ac_cv_olimit_ok,
1072 [ac_save_cc="$CC"
1073 CC="$CC -Olimit 1500"
Gregory P. Smith4e3ed012009-11-01 21:09:10 +00001074 AC_TRY_COMPILE([],[int main() { return 0; }],
Guido van Rossumf8678121998-07-07 21:05:09 +00001075 ac_cv_olimit_ok=yes,
Guido van Rossum3065c942001-09-17 04:03:14 +00001076 ac_cv_olimit_ok=no,
Gregory P. Smith4e3ed012009-11-01 21:09:10 +00001077 )
Guido van Rossumf8678121998-07-07 21:05:09 +00001078 CC="$ac_save_cc"])
1079 AC_MSG_RESULT($ac_cv_olimit_ok)
1080 if test $ac_cv_olimit_ok = yes; then
Skip Montanarodecc6a42003-01-01 20:07:49 +00001081 BASECFLAGS="$BASECFLAGS -Olimit 1500"
Guido van Rossumf8678121998-07-07 21:05:09 +00001082 fi
Guido van Rossum201afe51997-05-14 21:14:44 +00001083fi
Guido van Rossumf8678121998-07-07 21:05:09 +00001084
Thomas Wouters89f507f2006-12-13 04:49:30 +00001085# Check whether GCC supports PyArg_ParseTuple format
1086if test "$GCC" = "yes"
1087then
1088 AC_MSG_CHECKING(whether gcc supports ParseTuple __format__)
1089 save_CFLAGS=$CFLAGS
1090 CFLAGS="$CFLAGS -Werror"
1091 AC_TRY_COMPILE([
1092 void f(char*,...)__attribute((format(PyArg_ParseTuple, 1, 2)));
1093 ],,
1094 AC_DEFINE(HAVE_ATTRIBUTE_FORMAT_PARSETUPLE, 1, [Define if GCC supports __attribute__((format(PyArg_ParseTuple, 2, 3)))])
1095 AC_MSG_RESULT(yes),
1096 AC_MSG_RESULT(no)
1097 )
1098 CFLAGS=$save_CFLAGS
1099fi
1100
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00001101# On some compilers, pthreads are available without further options
1102# (e.g. MacOS X). On some of these systems, the compiler will not
1103# complain if unaccepted options are passed (e.g. gcc on Mac OS X).
1104# So we have to see first whether pthreads are available without
1105# options before we can check whether -Kpthread improves anything.
1106AC_MSG_CHECKING(whether pthreads are available without options)
1107AC_CACHE_VAL(ac_cv_pthread_is_default,
1108[AC_TRY_RUN([
1109#include <pthread.h>
1110
1111void* routine(void* p){return NULL;}
1112
1113int main(){
1114 pthread_t p;
1115 if(pthread_create(&p,NULL,routine,NULL)!=0)
1116 return 1;
Jack Jansen4f8d0542002-03-08 13:43:01 +00001117 (void)pthread_detach(p);
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00001118 return 0;
1119}
1120],
Skip Montanarod8d39a02003-07-10 20:44:10 +00001121[
1122 ac_cv_pthread_is_default=yes
1123 ac_cv_kthread=no
1124 ac_cv_pthread=no
1125],
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00001126 ac_cv_pthread_is_default=no,
1127 ac_cv_pthread_is_default=no)
1128])
1129AC_MSG_RESULT($ac_cv_pthread_is_default)
1130
1131
1132if test $ac_cv_pthread_is_default = yes
1133then
1134 ac_cv_kpthread=no
1135else
Martin v. Löwis130fb172001-07-19 11:00:41 +00001136# -Kpthread, if available, provides the right #defines
1137# and linker options to make pthread_create available
Martin v. Löwis260aecc2001-10-07 08:14:41 +00001138# Some compilers won't report that they do not support -Kpthread,
1139# so we need to run a program to see whether it really made the
1140# function available.
Martin v. Löwis130fb172001-07-19 11:00:41 +00001141AC_MSG_CHECKING(whether $CC accepts -Kpthread)
1142AC_CACHE_VAL(ac_cv_kpthread,
1143[ac_save_cc="$CC"
1144CC="$CC -Kpthread"
Martin v. Löwis260aecc2001-10-07 08:14:41 +00001145AC_TRY_RUN([
1146#include <pthread.h>
1147
1148void* routine(void* p){return NULL;}
1149
1150int main(){
1151 pthread_t p;
1152 if(pthread_create(&p,NULL,routine,NULL)!=0)
1153 return 1;
Jack Jansen4f8d0542002-03-08 13:43:01 +00001154 (void)pthread_detach(p);
Martin v. Löwis260aecc2001-10-07 08:14:41 +00001155 return 0;
1156}
1157],
Martin v. Löwis130fb172001-07-19 11:00:41 +00001158 ac_cv_kpthread=yes,
Martin v. Löwis260aecc2001-10-07 08:14:41 +00001159 ac_cv_kpthread=no,
Martin v. Löwis130fb172001-07-19 11:00:41 +00001160 ac_cv_kpthread=no)
1161CC="$ac_save_cc"])
Martin v. Löwis130fb172001-07-19 11:00:41 +00001162AC_MSG_RESULT($ac_cv_kpthread)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00001163fi
Martin v. Löwis130fb172001-07-19 11:00:41 +00001164
Skip Montanarod8d39a02003-07-10 20:44:10 +00001165if test $ac_cv_kpthread = no -a $ac_cv_pthread_is_default = no
Martin v. Löwis5f433f02003-05-05 05:05:30 +00001166then
1167# -Kthread, if available, provides the right #defines
1168# and linker options to make pthread_create available
1169# Some compilers won't report that they do not support -Kthread,
1170# so we need to run a program to see whether it really made the
1171# function available.
1172AC_MSG_CHECKING(whether $CC accepts -Kthread)
1173AC_CACHE_VAL(ac_cv_kthread,
1174[ac_save_cc="$CC"
1175CC="$CC -Kthread"
1176AC_TRY_RUN([
1177#include <pthread.h>
1178
1179void* routine(void* p){return NULL;}
1180
1181int main(){
1182 pthread_t p;
1183 if(pthread_create(&p,NULL,routine,NULL)!=0)
1184 return 1;
1185 (void)pthread_detach(p);
1186 return 0;
1187}
1188],
1189 ac_cv_kthread=yes,
1190 ac_cv_kthread=no,
1191 ac_cv_kthread=no)
1192CC="$ac_save_cc"])
1193AC_MSG_RESULT($ac_cv_kthread)
1194fi
1195
Skip Montanarod8d39a02003-07-10 20:44:10 +00001196if test $ac_cv_kthread = no -a $ac_cv_pthread_is_default = no
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00001197then
1198# -pthread, if available, provides the right #defines
1199# and linker options to make pthread_create available
1200# Some compilers won't report that they do not support -pthread,
1201# so we need to run a program to see whether it really made the
1202# function available.
1203AC_MSG_CHECKING(whether $CC accepts -pthread)
1204AC_CACHE_VAL(ac_cv_thread,
1205[ac_save_cc="$CC"
1206CC="$CC -pthread"
1207AC_TRY_RUN([
1208#include <pthread.h>
1209
1210void* routine(void* p){return NULL;}
1211
1212int main(){
1213 pthread_t p;
1214 if(pthread_create(&p,NULL,routine,NULL)!=0)
1215 return 1;
1216 (void)pthread_detach(p);
1217 return 0;
1218}
1219],
1220 ac_cv_pthread=yes,
1221 ac_cv_pthread=no,
1222 ac_cv_pthread=no)
1223CC="$ac_save_cc"])
1224AC_MSG_RESULT($ac_cv_pthread)
1225fi
1226
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001227# If we have set a CC compiler flag for thread support then
1228# check if it works for CXX, too.
1229ac_cv_cxx_thread=no
1230if test ! -z "$CXX"
1231then
1232AC_MSG_CHECKING(whether $CXX also accepts flags for thread support)
1233ac_save_cxx="$CXX"
1234
1235if test "$ac_cv_kpthread" = "yes"
1236then
Martin v. Löwis519adae2003-09-20 10:47:47 +00001237 CXX="$CXX -Kpthread"
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001238 ac_cv_cxx_thread=yes
1239elif test "$ac_cv_kthread" = "yes"
1240then
1241 CXX="$CXX -Kthread"
1242 ac_cv_cxx_thread=yes
1243elif test "$ac_cv_pthread" = "yes"
1244then
1245 CXX="$CXX -pthread"
1246 ac_cv_cxx_thread=yes
1247fi
1248
1249if test $ac_cv_cxx_thread = yes
1250then
1251 echo 'void foo();int main(){foo();}void foo(){}' > conftest.$ac_ext
1252 $CXX -c conftest.$ac_ext 2>&5
1253 if $CXX -o conftest$ac_exeext conftest.$ac_objext 2>&5 \
1254 && test -s conftest$ac_exeext && ./conftest$ac_exeext
1255 then
1256 ac_cv_cxx_thread=yes
1257 else
1258 ac_cv_cxx_thread=no
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001259 fi
1260 rm -fr conftest*
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001261fi
Brett Cannonc601e0f2004-11-07 01:24:12 +00001262AC_MSG_RESULT($ac_cv_cxx_thread)
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001263fi
Martin v. Löwis519adae2003-09-20 10:47:47 +00001264CXX="$ac_save_cxx"
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001265
Fred Drakece81d592000-07-09 14:39:29 +00001266dnl # check for ANSI or K&R ("traditional") preprocessor
1267dnl AC_MSG_CHECKING(for C preprocessor type)
1268dnl AC_TRY_COMPILE([
1269dnl #define spam(name, doc) {#name, &name, #name "() -- " doc}
1270dnl int foo;
1271dnl struct {char *name; int *addr; char *doc;} desc = spam(foo, "something");
1272dnl ], [;], cpp_type=ansi, AC_DEFINE(HAVE_OLD_CPP) cpp_type=traditional)
1273dnl AC_MSG_RESULT($cpp_type)
Guido van Rossum300fda71996-08-19 21:58:16 +00001274
Guido van Rossum627b2d71993-12-24 10:39:16 +00001275# checks for header files
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001276AC_HEADER_STDC
Thomas Wouters0e3f5912006-08-11 14:57:12 +00001277AC_CHECK_HEADERS(asm/types.h conio.h curses.h direct.h dlfcn.h errno.h \
1278fcntl.h grp.h \
Christian Heimesbbe741d2008-03-28 10:53:29 +00001279ieeefp.h io.h langinfo.h libintl.h ncurses.h poll.h process.h pthread.h \
Thomas Wouters89f507f2006-12-13 04:49:30 +00001280shadow.h signal.h stdint.h stropts.h termios.h thread.h \
Martin v. Löwis14e73b12003-01-01 09:51:12 +00001281unistd.h utime.h \
Christian Heimes4fbc72b2008-03-22 00:47:35 +00001282sys/audioio.h sys/bsdtty.h sys/epoll.h sys/event.h sys/file.h sys/loadavg.h \
1283sys/lock.h sys/mkdev.h sys/modem.h \
Thomas Wouters0e3f5912006-08-11 14:57:12 +00001284sys/param.h sys/poll.h sys/select.h sys/socket.h sys/statvfs.h sys/stat.h \
Georg Brandlf78e02b2008-06-10 17:40:04 +00001285sys/termio.h sys/time.h \
Thomas Wouters0e3f5912006-08-11 14:57:12 +00001286sys/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 +00001287sys/resource.h netpacket/packet.h sysexits.h bluetooth.h \
Ronald Oussoren755740f2010-02-07 19:56:39 +00001288bluetooth/bluetooth.h linux/tipc.h spawn.h util.h)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001289AC_HEADER_DIRENT
Martin v. Löwisdbe3f762002-10-10 14:27:30 +00001290AC_HEADER_MAJOR
Guido van Rossum627b2d71993-12-24 10:39:16 +00001291
Martin v. Löwisae2830c2004-09-18 09:54:52 +00001292# On Solaris, term.h requires curses.h
Martin v. Löwisfd1c69e72004-11-30 22:09:37 +00001293AC_CHECK_HEADERS(term.h,,,[
Martin v. Löwis5d52e782004-09-18 10:07:03 +00001294#ifdef HAVE_CURSES_H
1295#include <curses.h>
1296#endif
1297])
Martin v. Löwisae2830c2004-09-18 09:54:52 +00001298
Martin v. Löwis11017b12006-01-14 18:12:57 +00001299# On Linux, netlink.h requires asm/types.h
1300AC_CHECK_HEADERS(linux/netlink.h,,,[
1301#ifdef HAVE_ASM_TYPES_H
1302#include <asm/types.h>
1303#endif
1304#ifdef HAVE_SYS_SOCKET_H
1305#include <sys/socket.h>
1306#endif
1307])
1308
Guido van Rossum627b2d71993-12-24 10:39:16 +00001309# checks for typedefs
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001310was_it_defined=no
1311AC_MSG_CHECKING(for clock_t in time.h)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001312AC_EGREP_HEADER(clock_t, time.h, was_it_defined=yes, [
1313 AC_DEFINE(clock_t, long, [Define to 'long' if <time.h> doesn't define.])
1314])
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001315AC_MSG_RESULT($was_it_defined)
1316
Neal Norwitz11690112002-07-30 01:08:28 +00001317# Check whether using makedev requires defining _OSF_SOURCE
1318AC_MSG_CHECKING(for makedev)
Neal Norwitz6eb37f02003-02-23 23:28:15 +00001319AC_TRY_LINK([#include <sys/types.h> ],
Neal Norwitz11690112002-07-30 01:08:28 +00001320 [ makedev(0, 0) ],
1321 ac_cv_has_makedev=yes,
1322 ac_cv_has_makedev=no)
1323if test "$ac_cv_has_makedev" = "no"; then
1324 # we didn't link, try if _OSF_SOURCE will allow us to link
1325 AC_TRY_LINK([
Neal Norwitz6eb37f02003-02-23 23:28:15 +00001326#define _OSF_SOURCE 1
1327#include <sys/types.h>
Neal Norwitz11690112002-07-30 01:08:28 +00001328 ],
1329 [ makedev(0, 0) ],
1330 ac_cv_has_makedev=yes,
1331 ac_cv_has_makedev=no)
1332 if test "$ac_cv_has_makedev" = "yes"; then
1333 AC_DEFINE(_OSF_SOURCE, 1, [Define _OSF_SOURCE to get the makedev macro.])
1334 fi
1335fi
1336AC_MSG_RESULT($ac_cv_has_makedev)
1337if test "$ac_cv_has_makedev" = "yes"; then
1338 AC_DEFINE(HAVE_MAKEDEV, 1, [Define this if you have the makedev macro.])
1339fi
1340
Martin v. Löwis399a6892002-10-04 10:22:02 +00001341# Enabling LFS on Solaris (2.6 to 9) with gcc 2.95 triggers a bug in
1342# the system headers: If _XOPEN_SOURCE and _LARGEFILE_SOURCE are
1343# defined, but the compiler does not support pragma redefine_extname,
1344# and _LARGEFILE64_SOURCE is not defined, the headers refer to 64-bit
1345# structures (such as rlimit64) without declaring them. As a
1346# work-around, disable LFS on such configurations
1347
1348use_lfs=yes
1349AC_MSG_CHECKING(Solaris LFS bug)
1350AC_TRY_COMPILE([
1351#define _LARGEFILE_SOURCE 1
1352#define _FILE_OFFSET_BITS 64
1353#include <sys/resource.h>
Matthias Klosec80c93f2010-04-24 17:04:35 +00001354],[struct rlimit foo;],sol_lfs_bug=no,sol_lfs_bug=yes)
Martin v. Löwis399a6892002-10-04 10:22:02 +00001355AC_MSG_RESULT($sol_lfs_bug)
1356if test "$sol_lfs_bug" = "yes"; then
1357 use_lfs=no
1358fi
1359
1360if test "$use_lfs" = "yes"; then
Guido van Rossum810cc512001-09-09 23:51:39 +00001361# Two defines needed to enable largefile support on various platforms
1362# These may affect some typedefs
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001363AC_DEFINE(_LARGEFILE_SOURCE, 1,
1364[This must be defined on some systems to enable large file support.])
1365AC_DEFINE(_FILE_OFFSET_BITS, 64,
1366[This must be set to 64 on some systems to enable large file support.])
Martin v. Löwis399a6892002-10-04 10:22:02 +00001367fi
Guido van Rossum810cc512001-09-09 23:51:39 +00001368
Guido van Rossum300fda71996-08-19 21:58:16 +00001369# Add some code to confdefs.h so that the test for off_t works on SCO
1370cat >> confdefs.h <<\EOF
1371#if defined(SCO_DS)
1372#undef _OFF_T
1373#endif
1374EOF
1375
Guido van Rossumef2255b2000-03-10 22:30:29 +00001376# Type availability checks
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001377AC_TYPE_MODE_T
1378AC_TYPE_OFF_T
1379AC_TYPE_PID_T
1380AC_TYPE_SIGNAL
1381AC_TYPE_SIZE_T
1382AC_TYPE_UID_T
Mark Dickinsonbd792642009-03-18 20:06:12 +00001383AC_TYPE_UINT32_T
1384AC_TYPE_UINT64_T
1385AC_TYPE_INT32_T
1386AC_TYPE_INT64_T
Christian Heimes400adb02008-02-01 08:12:03 +00001387AC_CHECK_TYPE(ssize_t,
Matthias Klosec80c93f2010-04-24 17:04:35 +00001388 AC_DEFINE(HAVE_SSIZE_T, 1, [Define if your compiler provides ssize_t]),,)
Guido van Rossum627b2d71993-12-24 10:39:16 +00001389
Guido van Rossumef2255b2000-03-10 22:30:29 +00001390# Sizes of various common basic types
Skip Montanarob9820a32004-01-17 00:16:12 +00001391# ANSI C requires sizeof(char) == 1, so no need to check it
Guido van Rossum3065c942001-09-17 04:03:14 +00001392AC_CHECK_SIZEOF(int, 4)
1393AC_CHECK_SIZEOF(long, 4)
1394AC_CHECK_SIZEOF(void *, 4)
Guido van Rossum3065c942001-09-17 04:03:14 +00001395AC_CHECK_SIZEOF(short, 2)
1396AC_CHECK_SIZEOF(float, 4)
1397AC_CHECK_SIZEOF(double, 8)
1398AC_CHECK_SIZEOF(fpos_t, 4)
Martin v. Löwis18e16552006-02-15 17:27:45 +00001399AC_CHECK_SIZEOF(size_t, 4)
Christian Heimes400adb02008-02-01 08:12:03 +00001400AC_CHECK_SIZEOF(pid_t, 4)
Guido van Rossumac405f61994-09-12 10:56:06 +00001401
Guido van Rossumec95c7b1998-08-04 17:59:56 +00001402AC_MSG_CHECKING(for long long support)
1403have_long_long=no
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001404AC_TRY_COMPILE([], [long long x; x = (long long)0;], [
1405 AC_DEFINE(HAVE_LONG_LONG, 1, [Define this if you have the type long long.])
1406 have_long_long=yes
1407])
Guido van Rossumec95c7b1998-08-04 17:59:56 +00001408AC_MSG_RESULT($have_long_long)
Guido van Rossum8bc1dfd1999-04-10 16:01:48 +00001409if test "$have_long_long" = yes ; then
Guido van Rossum3065c942001-09-17 04:03:14 +00001410AC_CHECK_SIZEOF(long long, 8)
Guido van Rossumec95c7b1998-08-04 17:59:56 +00001411fi
1412
Travis E. Oliphant9b307842007-10-12 22:06:37 +00001413AC_MSG_CHECKING(for long double support)
1414have_long_double=no
1415AC_TRY_COMPILE([], [long double x; x = (long double)0;], [
1416 AC_DEFINE(HAVE_LONG_DOUBLE, 1, [Define this if you have the type long double.])
1417 have_long_double=yes
1418])
1419AC_MSG_RESULT($have_long_double)
1420if test "$have_long_double" = yes ; then
1421AC_CHECK_SIZEOF(long double, 16)
1422fi
1423
1424
Thomas Woutersb2137042007-02-01 18:02:27 +00001425AC_MSG_CHECKING(for _Bool support)
1426have_c99_bool=no
1427AC_TRY_COMPILE([], [_Bool x; x = (_Bool)0;], [
1428 AC_DEFINE(HAVE_C99_BOOL, 1, [Define this if you have the type _Bool.])
1429 have_c99_bool=yes
1430])
1431AC_MSG_RESULT($have_c99_bool)
1432if test "$have_c99_bool" = yes ; then
1433AC_CHECK_SIZEOF(_Bool, 1)
1434fi
1435
Thomas Wouters89f507f2006-12-13 04:49:30 +00001436AC_CHECK_TYPES(uintptr_t,
1437 [AC_CHECK_SIZEOF(uintptr_t, 4)],
1438 [], [#ifdef HAVE_STDINT_H
1439 #include <stdint.h>
1440 #endif])
1441
Alexandre Vassalotti0805b4a2009-07-17 05:47:33 +00001442AC_CHECK_SIZEOF(off_t, [], [
1443#ifdef HAVE_SYS_TYPES_H
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001444#include <sys/types.h>
Alexandre Vassalotti0805b4a2009-07-17 05:47:33 +00001445#endif
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001446])
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001447
1448AC_MSG_CHECKING(whether to enable large file support)
Mark Dickinson2df5d282009-12-31 21:22:50 +00001449if test "$have_long_long" = yes
1450then
1451if test "$ac_cv_sizeof_off_t" -gt "$ac_cv_sizeof_long" -a \
Guido van Rossum8bc1dfd1999-04-10 16:01:48 +00001452 "$ac_cv_sizeof_long_long" -ge "$ac_cv_sizeof_off_t"; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001453 AC_DEFINE(HAVE_LARGEFILE_SUPPORT, 1,
1454 [Defined to enable large file support when an off_t is bigger than a long
1455 and long long is available and at least as big as an off_t. You may need
1456 to add some flags for configuration and compilation to enable this mode.
1457 (For Solaris and Linux, the necessary defines are already defined.)])
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001458 AC_MSG_RESULT(yes)
1459else
1460 AC_MSG_RESULT(no)
1461fi
Mark Dickinson2df5d282009-12-31 21:22:50 +00001462else
1463 AC_MSG_RESULT(no)
1464fi
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001465
Alexandre Vassalotti0805b4a2009-07-17 05:47:33 +00001466AC_CHECK_SIZEOF(time_t, [], [
1467#ifdef HAVE_SYS_TYPES_H
1468#include <sys/types.h>
1469#endif
1470#ifdef HAVE_TIME_H
Fred Drakea3f6e912000-06-29 20:44:47 +00001471#include <time.h>
Alexandre Vassalotti0805b4a2009-07-17 05:47:33 +00001472#endif
Fred Drakea3f6e912000-06-29 20:44:47 +00001473])
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001474
Trent Mick635f6fb2000-08-23 21:33:05 +00001475# if have pthread_t then define SIZEOF_PTHREAD_T
Martin v. Löwis123cbd22001-07-19 14:21:10 +00001476ac_save_cc="$CC"
1477if test "$ac_cv_kpthread" = "yes"
1478then CC="$CC -Kpthread"
Martin v. Löwis5f433f02003-05-05 05:05:30 +00001479elif test "$ac_cv_kthread" = "yes"
1480then CC="$CC -Kthread"
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00001481elif test "$ac_cv_pthread" = "yes"
1482then CC="$CC -pthread"
Martin v. Löwis123cbd22001-07-19 14:21:10 +00001483fi
Alexandre Vassalotti0805b4a2009-07-17 05:47:33 +00001484
Trent Mick635f6fb2000-08-23 21:33:05 +00001485AC_MSG_CHECKING(for pthread_t)
1486have_pthread_t=no
Guido van Rossum12580492000-09-24 16:47:19 +00001487AC_TRY_COMPILE([#include <pthread.h>], [pthread_t x; x = *(pthread_t*)0;], have_pthread_t=yes)
Trent Mick635f6fb2000-08-23 21:33:05 +00001488AC_MSG_RESULT($have_pthread_t)
1489if test "$have_pthread_t" = yes ; then
Alexandre Vassalotti0805b4a2009-07-17 05:47:33 +00001490 AC_CHECK_SIZEOF(pthread_t, [], [
1491#ifdef HAVE_PTHREAD_H
Neal Norwitz6eb37f02003-02-23 23:28:15 +00001492#include <pthread.h>
Alexandre Vassalotti0805b4a2009-07-17 05:47:33 +00001493#endif
Trent Mick635f6fb2000-08-23 21:33:05 +00001494 ])
Trent Mick635f6fb2000-08-23 21:33:05 +00001495fi
Martin v. Löwis123cbd22001-07-19 14:21:10 +00001496CC="$ac_save_cc"
Trent Mick635f6fb2000-08-23 21:33:05 +00001497
Bob Ippolito7026a0a2005-03-28 23:23:47 +00001498AC_SUBST(OTHER_LIBTOOL_OPT)
1499case $ac_sys_system/$ac_sys_release in
Thomas Wouters49fd7fa2006-04-21 10:40:58 +00001500 Darwin/@<:@01567@:>@\..*)
Bob Ippolito7026a0a2005-03-28 23:23:47 +00001501 OTHER_LIBTOOL_OPT="-prebind -seg1addr 0x10000000"
1502 ;;
1503 Darwin/*)
1504 OTHER_LIBTOOL_OPT=""
1505 ;;
1506esac
1507
Ronald Oussoren5bbab3e2009-09-06 11:01:15 +00001508
1509ARCH_RUN_32BIT=""
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001510AC_SUBST(LIBTOOL_CRUFT)
1511case $ac_sys_system/$ac_sys_release in
Thomas Wouters49fd7fa2006-04-21 10:40:58 +00001512 Darwin/@<:@01567@:>@\..*)
Thomas Wouters477c8d52006-05-27 19:21:47 +00001513 LIBTOOL_CRUFT="-framework System -lcc_dynamic"
1514 if test "${enable_universalsdk}"; then
1515 :
1516 else
Ronald Oussorene3da75a2010-02-11 13:38:58 +00001517 LIBTOOL_CRUFT="${LIBTOOL_CRUFT} -arch_only `/usr/bin/arch`"
Thomas Wouters477c8d52006-05-27 19:21:47 +00001518 fi
Jack Jansenb36687a2004-07-16 08:43:47 +00001519 LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -install_name $(PYTHONFRAMEWORKINSTALLDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansena3891ea2001-09-07 14:25:12 +00001520 LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -compatibility_version $(VERSION) -current_version $(VERSION)';;
Guido van Rossum5839e582000-10-09 19:52:35 +00001521 Darwin/*)
Ronald Oussoren9812a6c2010-02-07 11:53:18 +00001522 gcc_version=`gcc -dumpversion`
Bob Ippolito7026a0a2005-03-28 23:23:47 +00001523 if test ${gcc_version} '<' 4.0
1524 then
1525 LIBTOOL_CRUFT="-lcc_dynamic"
1526 else
1527 LIBTOOL_CRUFT=""
1528 fi
Ronald Oussoren3c064c12009-09-08 07:12:42 +00001529 AC_TRY_RUN([
Ronald Oussoren5bbab3e2009-09-06 11:01:15 +00001530 #include <unistd.h>
1531 int main(int argc, char*argv[])
1532 {
1533 if (sizeof(long) == 4) {
1534 return 0;
1535 } else {
1536 return 1;
1537 }
Ronald Oussoren3c064c12009-09-08 07:12:42 +00001538 }
1539 ], ac_osx_32bit=yes,
Ronald Oussoren5bbab3e2009-09-06 11:01:15 +00001540 ac_osx_32bit=no,
Ronald Oussoren3c064c12009-09-08 07:12:42 +00001541 ac_osx_32bit=yes)
Ronald Oussoren5bbab3e2009-09-06 11:01:15 +00001542
1543 if test "${ac_osx_32bit}" = "yes"; then
Ronald Oussorene3da75a2010-02-11 13:38:58 +00001544 case `/usr/bin/arch` in
Ronald Oussoren5bbab3e2009-09-06 11:01:15 +00001545 i386)
1546 MACOSX_DEFAULT_ARCH="i386"
1547 ;;
1548 ppc)
1549 MACOSX_DEFAULT_ARCH="ppc"
1550 ;;
1551 *)
1552 AC_MSG_ERROR([Unexpected output of 'arch' on OSX])
1553 ;;
1554 esac
1555 else
Ronald Oussorene3da75a2010-02-11 13:38:58 +00001556 case `/usr/bin/arch` in
Ronald Oussoren5bbab3e2009-09-06 11:01:15 +00001557 i386)
1558 MACOSX_DEFAULT_ARCH="x86_64"
1559 ;;
1560 ppc)
1561 MACOSX_DEFAULT_ARCH="ppc64"
1562 ;;
1563 *)
1564 AC_MSG_ERROR([Unexpected output of 'arch' on OSX])
1565 ;;
1566 esac
1567
1568 #ARCH_RUN_32BIT="true"
1569 fi
1570
1571 LIBTOOL_CRUFT=$LIBTOOL_CRUFT" -lSystem -lSystemStubs -arch_only ${MACOSX_DEFAULT_ARCH}"
Jack Jansenb36687a2004-07-16 08:43:47 +00001572 LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -install_name $(PYTHONFRAMEWORKINSTALLDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001573 LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -compatibility_version $(VERSION) -current_version $(VERSION)';;
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001574esac
1575
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001576AC_MSG_CHECKING(for --enable-framework)
1577if test "$enable_framework"
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001578then
Skip Montanarodecc6a42003-01-01 20:07:49 +00001579 BASECFLAGS="$BASECFLAGS -fno-common -dynamic"
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001580 # -F. is needed to allow linking to the framework while
1581 # in the build location.
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001582 AC_DEFINE(WITH_NEXT_FRAMEWORK, 1,
1583 [Define if you want to produce an OpenStep/Rhapsody framework
1584 (shared library plus accessory files).])
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001585 AC_MSG_RESULT(yes)
Ronald Oussoren99aab652009-06-08 21:22:57 +00001586 if test $enable_shared = "yes"
1587 then
1588 AC_MSG_ERROR([Specifying both --enable-shared and --enable-framework is not supported, use only --enable-framework instead])
1589 fi
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001590else
1591 AC_MSG_RESULT(no)
1592fi
1593
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001594AC_MSG_CHECKING(for dyld)
Jack Jansen9a66b6d2001-08-08 13:56:14 +00001595case $ac_sys_system/$ac_sys_release in
1596 Darwin/*)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001597 AC_DEFINE(WITH_DYLD, 1,
1598 [Define if you want to use the new-style (Openstep, Rhapsody, MacOS)
1599 dynamic linker (dyld) instead of the old-style (NextStep) dynamic
1600 linker (rld). Dyld is necessary to support frameworks.])
Jack Jansen9a66b6d2001-08-08 13:56:14 +00001601 AC_MSG_RESULT(always on for Darwin)
1602 ;;
1603 *)
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001604 AC_MSG_RESULT(no)
1605 ;;
Jack Jansen9a66b6d2001-08-08 13:56:14 +00001606esac
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001607
Guido van Rossumac405f61994-09-12 10:56:06 +00001608# Set info about shared libraries.
Guido van Rossumac405f61994-09-12 10:56:06 +00001609AC_SUBST(SO)
1610AC_SUBST(LDSHARED)
Tarek Ziadé03d788d2010-04-03 08:46:49 +00001611AC_SUBST(LDCXXSHARED)
Neil Schemenauerb3531b82001-02-16 04:09:05 +00001612AC_SUBST(BLDSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00001613AC_SUBST(CCSHARED)
1614AC_SUBST(LINKFORSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00001615# SO is the extension of shared libraries `(including the dot!)
Guido van Rossumaef734b2001-01-10 21:09:12 +00001616# -- usually .so, .sl on HP-UX, .dll on Cygwin
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001617AC_MSG_CHECKING(SO)
Guido van Rossumac405f61994-09-12 10:56:06 +00001618if test -z "$SO"
1619then
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001620 case $ac_sys_system in
Thomas Wouters477c8d52006-05-27 19:21:47 +00001621 hp*|HP*)
1622 case `uname -m` in
1623 ia64) SO=.so;;
1624 *) SO=.sl;;
1625 esac
1626 ;;
Guido van Rossumaef734b2001-01-10 21:09:12 +00001627 CYGWIN*) SO=.dll;;
Guido van Rossum4b6b5791996-09-09 20:09:34 +00001628 *) SO=.so;;
Guido van Rossumac405f61994-09-12 10:56:06 +00001629 esac
Martin v. Löwis368de8f2003-06-14 14:46:38 +00001630else
1631 # this might also be a termcap variable, see #610332
1632 echo
1633 echo '====================================================================='
1634 echo '+ +'
1635 echo '+ WARNING: You have set SO in your environment. +'
1636 echo '+ Do you really mean to change the extension for shared libraries? +'
1637 echo '+ Continuing in 10 seconds to let you to ponder. +'
1638 echo '+ +'
1639 echo '====================================================================='
1640 sleep 10
Guido van Rossumac405f61994-09-12 10:56:06 +00001641fi
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001642AC_MSG_RESULT($SO)
Georg Brandlb1441c72009-01-03 22:33:39 +00001643
Thomas Wouters477c8d52006-05-27 19:21:47 +00001644AC_DEFINE_UNQUOTED(SHLIB_EXT, "$SO", [Define this to be extension of shared libraries (including the dot!).])
Guido van Rossumac405f61994-09-12 10:56:06 +00001645# LDSHARED is the ld *command* used to create shared library
Skip Montanaroce59c042004-01-17 14:19:44 +00001646# -- "cc -G" on SunOS 5.x, "ld -shared" on IRIX 5
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001647# (Shared libraries in this instance are shared modules to be loaded into
1648# Python, as opposed to building Python itself as a shared library.)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001649AC_MSG_CHECKING(LDSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00001650if test -z "$LDSHARED"
1651then
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001652 case $ac_sys_system/$ac_sys_release in
Neil Schemenauerb3531b82001-02-16 04:09:05 +00001653 AIX*)
1654 BLDSHARED="\$(srcdir)/Modules/ld_so_aix \$(CC) -bI:Modules/python.exp"
Guido van Rossumce608b02001-09-28 15:59:38 +00001655 LDSHARED="\$(BINLIBDEST)/config/ld_so_aix \$(CC) -bI:\$(BINLIBDEST)/config/python.exp"
Neil Schemenauerb3531b82001-02-16 04:09:05 +00001656 ;;
Guido van Rossum6100aaf1997-04-29 21:48:51 +00001657 IRIX/5*) LDSHARED="ld -shared";;
Guido van Rossum91922671997-10-09 20:24:13 +00001658 IRIX*/6*) LDSHARED="ld ${SGI_ABI} -shared -all";;
Greg Ward57c9a6632000-05-26 12:22:54 +00001659 SunOS/5*)
Tarek Ziadé03d788d2010-04-03 08:46:49 +00001660 if test "$GCC" = "yes" ; then
1661 LDSHARED='$(CC) -shared'
1662 LDCXXSHARED='$(CXX) -shared'
1663 else
1664 LDSHARED='$(CC) -G'
1665 LDCXXSHARED='$(CXX) -G'
Greg Ward57c9a6632000-05-26 12:22:54 +00001666 fi ;;
Thomas Hellerf44b9a12008-04-04 10:18:23 +00001667 hp*|HP*)
Tarek Ziadé03d788d2010-04-03 08:46:49 +00001668 if test "$GCC" = "yes" ; then
1669 LDSHARED='$(CC) -shared'
1670 LDCXXSHARED='$(CXX) -shared'
1671 else
1672 LDSHARED='ld -b'
Thomas Hellerf44b9a12008-04-04 10:18:23 +00001673 fi ;;
Guido van Rossum71001e41995-01-26 00:44:03 +00001674 OSF*) LDSHARED="ld -shared -expect_unresolved \"*\"";;
Jack Jansen418c3b12001-11-14 10:59:57 +00001675 Darwin/1.3*)
Jack Jansena3891ea2001-09-07 14:25:12 +00001676 LDSHARED='$(CC) $(LDFLAGS) -bundle'
Tarek Ziadé03d788d2010-04-03 08:46:49 +00001677 LDCXXSHARED='$(CXX) $(LDFLAGS) -bundle'
Jack Jansena3891ea2001-09-07 14:25:12 +00001678 if test "$enable_framework" ; then
1679 # Link against the framework. All externals should be defined.
Jack Jansenda49e192005-01-07 13:08:22 +00001680 BLDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
1681 LDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Tarek Ziadé03d788d2010-04-03 08:46:49 +00001682 LDCXXSHARED="$LDCXXSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansena3891ea2001-09-07 14:25:12 +00001683 else
1684 # No framework. Ignore undefined symbols, assuming they come from Python
Jack Jansen418c3b12001-11-14 10:59:57 +00001685 LDSHARED="$LDSHARED -undefined suppress"
Tarek Ziadé03d788d2010-04-03 08:46:49 +00001686 LDCXXSHARED="$LDCXXSHARED -undefined suppress"
Jack Jansena3891ea2001-09-07 14:25:12 +00001687 fi ;;
Jack Jansen6b08a402004-06-03 12:41:45 +00001688 Darwin/1.4*|Darwin/5.*|Darwin/6.*)
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001689 LDSHARED='$(CC) $(LDFLAGS) -bundle'
Tarek Ziadé03d788d2010-04-03 08:46:49 +00001690 LDCXXSHARED='$(CXX) $(LDFLAGS) -bundle'
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001691 if test "$enable_framework" ; then
1692 # Link against the framework. All externals should be defined.
Jack Jansenda49e192005-01-07 13:08:22 +00001693 BLDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
1694 LDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Tarek Ziadé03d788d2010-04-03 08:46:49 +00001695 LDCXXSHARED="$LDCXXSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001696 else
Michael W. Hudson0c46c0c2002-03-07 09:58:56 +00001697 # No framework, use the Python app as bundle-loader
1698 BLDSHARED="$LDSHARED "'-bundle_loader $(BUILDPYTHON)'
Jack Jansenc28fc372003-02-25 13:14:43 +00001699 LDSHARED="$LDSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)'
Tarek Ziadé03d788d2010-04-03 08:46:49 +00001700 LDCXXSHARED="$LDCXXSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)'
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001701 fi ;;
Jack Jansen6b08a402004-06-03 12:41:45 +00001702 Darwin/*)
1703 # Use -undefined dynamic_lookup whenever possible (10.3 and later).
1704 # This allows an extension to be used in any Python
Thomas Wouters89d996e2007-09-08 17:39:28 +00001705
Georg Brandlfcaf9102008-07-16 02:17:56 +00001706 if test ${MACOSX_DEPLOYMENT_TARGET} '>' 10.2
Jack Jansen6b08a402004-06-03 12:41:45 +00001707 then
Thomas Wouters477c8d52006-05-27 19:21:47 +00001708 if test "${enable_universalsdk}"; then
Georg Brandlfcaf9102008-07-16 02:17:56 +00001709 LDFLAGS="${UNIVERSAL_ARCH_FLAGS} -isysroot ${UNIVERSALSDK} ${LDFLAGS}"
Thomas Wouters477c8d52006-05-27 19:21:47 +00001710 fi
Jack Jansen6b08a402004-06-03 12:41:45 +00001711 LDSHARED='$(CC) $(LDFLAGS) -bundle -undefined dynamic_lookup'
Tarek Ziadé03d788d2010-04-03 08:46:49 +00001712 LDCXXSHARED='$(CXX) $(LDFLAGS) -bundle -undefined dynamic_lookup'
Jack Jansen6b08a402004-06-03 12:41:45 +00001713 BLDSHARED="$LDSHARED"
Jack Jansen6b08a402004-06-03 12:41:45 +00001714 else
1715 LDSHARED='$(CC) $(LDFLAGS) -bundle'
Tarek Ziadé03d788d2010-04-03 08:46:49 +00001716 LDCXXSHARED='$(CXX) $(LDFLAGS) -bundle'
Jack Jansen6b08a402004-06-03 12:41:45 +00001717 if test "$enable_framework" ; then
1718 # Link against the framework. All externals should be defined.
Jack Jansenda49e192005-01-07 13:08:22 +00001719 BLDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
1720 LDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Tarek Ziadé03d788d2010-04-03 08:46:49 +00001721 LDCXXSHARED="$LDCXXSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansen6b08a402004-06-03 12:41:45 +00001722 else
1723 # No framework, use the Python app as bundle-loader
1724 BLDSHARED="$LDSHARED "'-bundle_loader $(BUILDPYTHON)'
1725 LDSHARED="$LDSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)'
Tarek Ziadé03d788d2010-04-03 08:46:49 +00001726 LDCXXSHARED="$LDCXXSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)'
Jack Jansen6b08a402004-06-03 12:41:45 +00001727 fi
1728 fi
1729 ;;
Tarek Ziadé03d788d2010-04-03 08:46:49 +00001730 Linux*|GNU*|QNX*)
1731 LDSHARED='$(CC) -shared'
1732 LDCXXSHARED='$(CXX) -shared';;
1733 BSD/OS*/4*)
1734 LDSHARED="gcc -shared"
1735 LDCXXSHARED="g++ -shared";;
Thomas Wouters1ba5b3b2006-06-08 14:52:47 +00001736 FreeBSD*)
Jeremy Hylton4bcc7c52000-08-31 17:45:35 +00001737 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
Guido van Rossum0286ae82000-08-29 15:06:49 +00001738 then
Benjamin Petersonab0a7522010-03-14 15:18:25 +00001739 LDSHARED='$(CC) -shared ${LDFLAGS}'
Tarek Ziadé03d788d2010-04-03 08:46:49 +00001740 LDCXXSHARED='$(CXX) -shared ${LDFLAGS}'
Guido van Rossum0286ae82000-08-29 15:06:49 +00001741 else
1742 LDSHARED="ld -Bshareable ${LDFLAGS}"
1743 fi;;
Thomas Wouters1ba5b3b2006-06-08 14:52:47 +00001744 OpenBSD*)
1745 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
1746 then
1747 LDSHARED='$(CC) -shared $(CCSHARED) ${LDFLAGS}'
Tarek Ziadé03d788d2010-04-03 08:46:49 +00001748 LDCXXSHARED='$(CXX) -shared $(CCSHARED) ${LDFLAGS}'
Thomas Wouters1ba5b3b2006-06-08 14:52:47 +00001749 else
1750 case `uname -r` in
1751 [[01]].* | 2.[[0-7]] | 2.[[0-7]].*)
1752 LDSHARED="ld -Bshareable ${LDFLAGS}"
1753 ;;
1754 *)
1755 LDSHARED='$(CC) -shared $(CCSHARED) ${LDFLAGS}'
Tarek Ziadé03d788d2010-04-03 08:46:49 +00001756 LDCXXSHARED='$(CXX) -shared $(CCSHARED) ${LDFLAGS}'
Thomas Wouters1ba5b3b2006-06-08 14:52:47 +00001757 ;;
1758 esac
1759 fi;;
Tarek Ziadé03d788d2010-04-03 08:46:49 +00001760 NetBSD*|DragonFly*)
1761 LDSHARED="cc -shared ${LDFLAGS}"
1762 LDCXXSHARED="c++ -shared ${LDFLAGS}";;
Martin v. Löwis25ae43b2001-10-07 08:39:18 +00001763 OpenUNIX*|UnixWare*)
Tarek Ziadé03d788d2010-04-03 08:46:49 +00001764 if test "$GCC" = "yes" ; then
1765 LDSHARED='$(CC) -shared'
1766 LDCXXSHARED='$(CXX) -shared'
1767 else
1768 LDSHARED='$(CC) -G'
1769 LDCXXSHARED='$(CXX) -G'
Martin v. Löwisbec19582001-03-21 15:57:54 +00001770 fi;;
Tarek Ziadé03d788d2010-04-03 08:46:49 +00001771 SCO_SV*)
1772 LDSHARED='$(CC) -Wl,-G,-Bexport'
1773 LDCXXSHARED='$(CXX) -Wl,-G,-Bexport';;
1774 CYGWIN*)
1775 LDSHARED="gcc -shared -Wl,--enable-auto-image-base"
1776 LDCXXSHARED="g++ -shared -Wl,--enable-auto-image-base";;
Guido van Rossumac405f61994-09-12 10:56:06 +00001777 *) LDSHARED="ld";;
1778 esac
Guido van Rossumac405f61994-09-12 10:56:06 +00001779fi
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001780AC_MSG_RESULT($LDSHARED)
Tarek Ziadé03d788d2010-04-03 08:46:49 +00001781LDCXXSHARED=${LDCXXSHARED-$LDSHARED}
Neil Schemenauerb3531b82001-02-16 04:09:05 +00001782BLDSHARED=${BLDSHARED-$LDSHARED}
Guido van Rossumac405f61994-09-12 10:56:06 +00001783# CCSHARED are the C *flags* used to create objects to go into a shared
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001784# library (module) -- this is only needed for a few systems
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001785AC_MSG_CHECKING(CCSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00001786if test -z "$CCSHARED"
1787then
Guido van Rossum6100aaf1997-04-29 21:48:51 +00001788 case $ac_sys_system/$ac_sys_release in
Neil Schemenauer66252162001-02-19 04:47:42 +00001789 SunOS*) if test "$GCC" = yes;
Guido van Rossumd8faa362007-04-27 19:54:29 +00001790 then CCSHARED="-fPIC";
1791 elif test `uname -p` = sparc;
1792 then CCSHARED="-xcode=pic32";
1793 else CCSHARED="-Kpic";
1794 fi;;
Guido van Rossumaf07a441995-02-13 19:45:27 +00001795 hp*|HP*) if test "$GCC" = yes;
Martin v. Löwis703ad702001-09-05 08:36:52 +00001796 then CCSHARED="-fPIC";
Guido van Rossumaf07a441995-02-13 19:45:27 +00001797 else CCSHARED="+z";
1798 fi;;
Martin v. Löwisa6e97582002-01-01 18:41:33 +00001799 Linux*|GNU*) CCSHARED="-fPIC";;
Guido van Rossumf5957ea1999-10-05 21:59:33 +00001800 BSD/OS*/4*) CCSHARED="-fpic";;
Martin v. Löwis86d66262006-02-17 08:40:11 +00001801 FreeBSD*|NetBSD*|OpenBSD*|DragonFly*) CCSHARED="-fPIC";;
Martin v. Löwis25ae43b2001-10-07 08:39:18 +00001802 OpenUNIX*|UnixWare*)
Martin v. Löwisbec19582001-03-21 15:57:54 +00001803 if test "$GCC" = "yes"
1804 then CCSHARED="-fPIC"
Martin v. Löwis130fb172001-07-19 11:00:41 +00001805 else CCSHARED="-KPIC"
Martin v. Löwisbec19582001-03-21 15:57:54 +00001806 fi;;
Martin v. Löwis21ee4092002-09-30 16:19:48 +00001807 SCO_SV*)
1808 if test "$GCC" = "yes"
1809 then CCSHARED="-fPIC"
1810 else CCSHARED="-Kpic -belf"
1811 fi;;
Guido van Rossum2b5ca001998-03-05 15:41:09 +00001812 IRIX*/6*) case $CC in
1813 *gcc*) CCSHARED="-shared";;
Guido van Rossumee21f411998-04-20 18:51:54 +00001814 *) CCSHARED="";;
Guido van Rossum2b5ca001998-03-05 15:41:09 +00001815 esac;;
Guido van Rossumac405f61994-09-12 10:56:06 +00001816 esac
Guido van Rossumac405f61994-09-12 10:56:06 +00001817fi
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001818AC_MSG_RESULT($CCSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00001819# LINKFORSHARED are the flags passed to the $(CC) command that links
Guido van Rossumb65a48e1995-06-14 18:21:23 +00001820# the python executable -- this is only needed for a few systems
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001821AC_MSG_CHECKING(LINKFORSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00001822if test -z "$LINKFORSHARED"
1823then
Guido van Rossum6100aaf1997-04-29 21:48:51 +00001824 case $ac_sys_system/$ac_sys_release in
Neil Schemenauerb3531b82001-02-16 04:09:05 +00001825 AIX*) LINKFORSHARED='-Wl,-bE:Modules/python.exp -lld';;
Guido van Rossum5dab3d81996-12-06 21:18:18 +00001826 hp*|HP*)
Martin v. Löwis1142de32002-03-29 16:28:31 +00001827 LINKFORSHARED="-Wl,-E -Wl,+s";;
1828# LINKFORSHARED="-Wl,-E -Wl,+s -Wl,+b\$(BINLIBDEST)/lib-dynload";;
Guido van Rossumf5957ea1999-10-05 21:59:33 +00001829 BSD/OS/4*) LINKFORSHARED="-Xlinker -export-dynamic";;
Martin v. Löwisa6e97582002-01-01 18:41:33 +00001830 Linux*|GNU*) LINKFORSHARED="-Xlinker -export-dynamic";;
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001831 # -u libsys_s pulls in all symbols in libsys
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001832 Darwin/*)
Benjamin Peterson9c80cac2009-05-23 16:34:23 +00001833 LINKFORSHARED="$extra_undefs -framework CoreFoundation"
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001834 if test "$enable_framework"
1835 then
Jack Jansenda49e192005-01-07 13:08:22 +00001836 LINKFORSHARED="$LINKFORSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001837 fi
Raymond Hettingerec6eb362004-11-05 07:02:59 +00001838 LINKFORSHARED="$LINKFORSHARED";;
Martin v. Löwis25ae43b2001-10-07 08:39:18 +00001839 OpenUNIX*|UnixWare*) LINKFORSHARED="-Wl,-Bexport";;
Martin v. Löwis21ee4092002-09-30 16:19:48 +00001840 SCO_SV*) LINKFORSHARED="-Wl,-Bexport";;
Fred Drake02706f52000-09-25 15:08:46 +00001841 ReliantUNIX*) LINKFORSHARED="-W1 -Blargedynsym";;
Martin v. Löwis86d66262006-02-17 08:40:11 +00001842 FreeBSD*|NetBSD*|OpenBSD*|DragonFly*)
Guido van Rossumdf693651999-01-07 21:50:41 +00001843 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
1844 then
1845 LINKFORSHARED="-Wl,--export-dynamic"
1846 fi;;
Guido van Rossum2b5ca001998-03-05 15:41:09 +00001847 SunOS/5*) case $CC in
1848 *gcc*)
Martin v. Löwisa4548572002-04-18 14:51:36 +00001849 if $CC -Xlinker --help 2>&1 | grep export-dynamic >/dev/null
Guido van Rossum8f4ceb11997-12-18 23:42:19 +00001850 then
1851 LINKFORSHARED="-Xlinker --export-dynamic"
Guido van Rossum2b5ca001998-03-05 15:41:09 +00001852 fi;;
1853 esac;;
Jason Tishler30765592003-09-04 11:04:06 +00001854 CYGWIN*)
1855 if test $enable_shared = "no"
1856 then
1857 LINKFORSHARED='-Wl,--out-implib=$(LDLIBRARY)'
1858 fi;;
Georg Brandlf78e02b2008-06-10 17:40:04 +00001859 QNX*)
1860 # -Wl,-E causes the symbols to be added to the dynamic
1861 # symbol table so that they can be found when a module
1862 # is loaded. -N 2048K causes the stack size to be set
1863 # to 2048 kilobytes so that the stack doesn't overflow
1864 # when running test_compile.py.
1865 LINKFORSHARED='-Wl,-E -N 2048K';;
Guido van Rossumac405f61994-09-12 10:56:06 +00001866 esac
Guido van Rossumac405f61994-09-12 10:56:06 +00001867fi
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001868AC_MSG_RESULT($LINKFORSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00001869
Georg Brandl93de2162008-07-16 02:21:06 +00001870
Neil Schemenauer61c51152001-01-26 16:18:16 +00001871AC_SUBST(CFLAGSFORSHARED)
1872AC_MSG_CHECKING(CFLAGSFORSHARED)
1873if test ! "$LIBRARY" = "$LDLIBRARY"
1874then
Neil Schemenauerd9cf41c2001-01-27 21:39:17 +00001875 case $ac_sys_system in
1876 CYGWIN*)
1877 # Cygwin needs CCSHARED when building extension DLLs
1878 # but not when building the interpreter DLL.
1879 CFLAGSFORSHARED='';;
1880 *)
1881 CFLAGSFORSHARED='$(CCSHARED)'
1882 esac
Neil Schemenauer61c51152001-01-26 16:18:16 +00001883fi
1884AC_MSG_RESULT($CFLAGSFORSHARED)
1885
Martin v. Löwisf90ae202002-06-11 06:22:31 +00001886# SHLIBS are libraries (except -lc and -lm) to link to the python shared
1887# library (with --enable-shared).
1888# For platforms on which shared libraries are not allowed to have unresolved
Martin v. Löwisd6359c52002-08-04 12:38:50 +00001889# symbols, this must be set to $(LIBS) (expanded by make). We do this even
1890# if it is not required, since it creates a dependency of the shared library
1891# to LIBS. This, in turn, means that applications linking the shared libpython
1892# don't need to link LIBS explicitly. The default should be only changed
1893# on systems where this approach causes problems.
Martin v. Löwisf90ae202002-06-11 06:22:31 +00001894AC_SUBST(SHLIBS)
1895AC_MSG_CHECKING(SHLIBS)
1896case "$ac_sys_system" in
Martin v. Löwisf90ae202002-06-11 06:22:31 +00001897 *)
Martin v. Löwisd6359c52002-08-04 12:38:50 +00001898 SHLIBS='$(LIBS)';;
Martin v. Löwisf90ae202002-06-11 06:22:31 +00001899esac
1900AC_MSG_RESULT($SHLIBS)
1901
1902
Guido van Rossum627b2d71993-12-24 10:39:16 +00001903# checks for libraries
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001904AC_CHECK_LIB(dl, dlopen) # Dynamic linking for SunOS/Solaris and SYSV
1905AC_CHECK_LIB(dld, shl_load) # Dynamic linking for HP-UX
Martin v. Löwis519adae2003-09-20 10:47:47 +00001906
Georg Brandleee31162008-12-07 15:15:22 +00001907# only check for sem_init if thread support is requested
Martin v. Löwis519adae2003-09-20 10:47:47 +00001908if test "$with_threads" = "yes" -o -z "$with_threads"; then
1909 AC_SEARCH_LIBS(sem_init, pthread rt posix4) # 'Real Time' functions on Solaris
1910 # posix4 on Solaris 2.6
1911 # pthread (first!) on Linux
1912fi
1913
Martin v. Löwis19d17342003-06-14 21:03:05 +00001914# check if we need libintl for locale functions
1915AC_CHECK_LIB(intl, textdomain,
Brett Cannonc6d936e2009-06-07 20:09:53 +00001916 [AC_DEFINE(WITH_LIBINTL, 1,
1917 [Define to 1 if libintl is needed for locale functions.])
1918 LIBS="-lintl $LIBS"])
Guido van Rossum0eefa3f1999-11-16 15:57:37 +00001919
1920# checks for system dependent C++ extensions support
1921case "$ac_sys_system" in
1922 AIX*) AC_MSG_CHECKING(for genuine AIX C++ extensions support)
1923 AC_TRY_LINK([#include "/usr/lpp/xlC/include/load.h"],
1924 [loadAndInit("", 0, "")],
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001925 [AC_DEFINE(AIX_GENUINE_CPLUSPLUS, 1,
1926 [Define for AIX if your compiler is a genuine IBM xlC/xlC_r
1927 and you want support for AIX C++ shared extension modules.])
Guido van Rossum0eefa3f1999-11-16 15:57:37 +00001928 AC_MSG_RESULT(yes)],
1929 [AC_MSG_RESULT(no)]);;
1930 *) ;;
1931esac
1932
Guido van Rossum70c7f481998-03-26 18:44:10 +00001933# Most SVR4 platforms (e.g. Solaris) need -lsocket and -lnsl.
Guido van Rossumf618d2c1995-01-17 16:36:13 +00001934AC_CHECK_LIB(nsl, t_open, [LIBS="-lnsl $LIBS"]) # SVR4
Guido van Rossumf618d2c1995-01-17 16:36:13 +00001935AC_CHECK_LIB(socket, socket, [LIBS="-lsocket $LIBS"], [], $LIBS) # SVR4 sockets
Skip Montanarob9949db2004-01-17 04:04:13 +00001936
Guido van Rossumc5a39031996-07-31 17:35:03 +00001937AC_MSG_CHECKING(for --with-libs)
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00001938AC_ARG_WITH(libs,
Matthias Klosec80c93f2010-04-24 17:04:35 +00001939 AC_HELP_STRING([--with-libs='lib1 ...'], [link against additional libs]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00001940[
Guido van Rossumc5a39031996-07-31 17:35:03 +00001941AC_MSG_RESULT($withval)
1942LIBS="$withval $LIBS"
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00001943],
1944[AC_MSG_RESULT(no)])
Guido van Rossum627b2d71993-12-24 10:39:16 +00001945
Benjamin Peterson0f64b0b2010-03-09 21:49:52 +00001946AC_PATH_TOOL([PKG_CONFIG], [pkg-config])
1947
Benjamin Petersonb2d90462009-12-31 03:23:10 +00001948# Check for use of the system expat library
1949AC_MSG_CHECKING(for --with-system-expat)
1950AC_ARG_WITH(system_expat,
Matthias Klosec80c93f2010-04-24 17:04:35 +00001951 AC_HELP_STRING([--with-system-expat], [build pyexpat module using an installed expat library]))
Benjamin Petersonb2d90462009-12-31 03:23:10 +00001952
1953AC_MSG_RESULT($with_system_expat)
1954
Thomas Wouters49fd7fa2006-04-21 10:40:58 +00001955# Check for use of the system libffi library
1956AC_MSG_CHECKING(for --with-system-ffi)
1957AC_ARG_WITH(system_ffi,
Matthias Klosec80c93f2010-04-24 17:04:35 +00001958 AC_HELP_STRING([--with-system-ffi], [build _ctypes module using an installed ffi library]))
Thomas Wouters49fd7fa2006-04-21 10:40:58 +00001959
Benjamin Peterson0f64b0b2010-03-09 21:49:52 +00001960if test "$with_system_ffi" = "yes" && test -n "$PKG_CONFIG"; then
Benjamin Petersond78735d2010-01-01 16:04:23 +00001961 LIBFFI_INCLUDEDIR="`"$PKG_CONFIG" libffi --cflags-only-I 2>/dev/null | sed -e 's/^-I//;s/ *$//'`"
1962else
1963 LIBFFI_INCLUDEDIR=""
1964fi
1965AC_SUBST(LIBFFI_INCLUDEDIR)
1966
Thomas Wouters49fd7fa2006-04-21 10:40:58 +00001967AC_MSG_RESULT($with_system_ffi)
1968
Matthias Klose55708cc2009-04-30 08:06:49 +00001969# Check for --with-dbmliborder
1970AC_MSG_CHECKING(for --with-dbmliborder)
1971AC_ARG_WITH(dbmliborder,
1972 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'.]),
1973[
1974if test x$with_dbmliborder = xyes
1975then
1976AC_MSG_ERROR([proper usage is --with-dbmliborder=db1:db2:...])
1977else
1978 for db in `echo $with_dbmliborder | sed 's/:/ /g'`; do
1979 if test x$db != xndbm && test x$db != xgdbm && test x$db != xbdb
1980 then
1981 AC_MSG_ERROR([proper usage is --with-dbmliborder=db1:db2:...])
1982 fi
1983 done
1984fi])
1985AC_MSG_RESULT($with_dbmliborder)
1986
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00001987# Determine if signalmodule should be used.
1988AC_SUBST(USE_SIGNAL_MODULE)
1989AC_SUBST(SIGNAL_OBJS)
1990AC_MSG_CHECKING(for --with-signal-module)
1991AC_ARG_WITH(signal-module,
Matthias Klosec80c93f2010-04-24 17:04:35 +00001992 AC_HELP_STRING([--with-signal-module], [disable/enable signal module]))
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00001993
1994if test -z "$with_signal_module"
1995then with_signal_module="yes"
1996fi
1997AC_MSG_RESULT($with_signal_module)
1998
1999if test "${with_signal_module}" = "yes"; then
2000 USE_SIGNAL_MODULE=""
2001 SIGNAL_OBJS=""
2002else
2003 USE_SIGNAL_MODULE="#"
2004 SIGNAL_OBJS="Parser/intrcheck.o Python/sigcheck.o"
2005fi
2006
Guido van Rossum3d15bd82001-01-10 18:53:48 +00002007# This is used to generate Setup.config
Guido van Rossum009f7871997-12-04 00:51:42 +00002008AC_SUBST(USE_THREAD_MODULE)
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00002009USE_THREAD_MODULE=""
Guido van Rossum009f7871997-12-04 00:51:42 +00002010
Guido van Rossum54d93d41997-01-22 20:51:58 +00002011AC_MSG_CHECKING(for --with-dec-threads)
2012AC_SUBST(LDLAST)
2013AC_ARG_WITH(dec-threads,
Matthias Klosec80c93f2010-04-24 17:04:35 +00002014 AC_HELP_STRING([--with-dec-threads], [use DEC Alpha/OSF1 thread-safe libraries]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002015[
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00002016AC_MSG_RESULT($withval)
Guido van Rossum54d93d41997-01-22 20:51:58 +00002017LDLAST=-threads
Guido van Rossumf78abae1997-01-21 22:02:36 +00002018if test "${with_thread+set}" != set; then
Guido van Rossum54d93d41997-01-22 20:51:58 +00002019 with_thread="$withval";
2020fi],
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002021[AC_MSG_RESULT(no)])
Guido van Rossum54d93d41997-01-22 20:51:58 +00002022
Martin v. Löwis11437992002-04-12 09:54:03 +00002023# Templates for things AC_DEFINEd more than once.
2024# For a single AC_DEFINE, no template is needed.
2025AH_TEMPLATE(C_THREADS,[Define if you have the Mach cthreads package])
2026AH_TEMPLATE(_REENTRANT,
2027 [Define to force use of thread-safe errno, h_errno, and other functions])
2028AH_TEMPLATE(WITH_THREAD,
2029 [Define if you want to compile in rudimentary thread support])
2030
Guido van Rossum54d93d41997-01-22 20:51:58 +00002031AC_MSG_CHECKING(for --with-threads)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002032dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00002033AC_ARG_WITH(threads,
Matthias Klosec80c93f2010-04-24 17:04:35 +00002034 AC_HELP_STRING([--with(out)-threads@<:@=DIRECTORY@:>@], [disable/enable thread support]))
Guido van Rossum54d93d41997-01-22 20:51:58 +00002035
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00002036# --with-thread is deprecated, but check for it anyway
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002037dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
Barry Warsawa0f3c5c2000-06-30 16:39:35 +00002038AC_ARG_WITH(thread,
Matthias Klosec80c93f2010-04-24 17:04:35 +00002039 AC_HELP_STRING([--with(out)-thread@<:@=DIRECTORY@:>@], [deprecated; use --with(out)-threads]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002040 [with_threads=$with_thread])
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00002041
2042if test -z "$with_threads"
2043then with_threads="yes"
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002044fi
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00002045AC_MSG_RESULT($with_threads)
Guido van Rossum6400c261997-05-22 20:34:27 +00002046
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002047AC_SUBST(THREADOBJ)
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00002048if test "$with_threads" = "no"
2049then
2050 USE_THREAD_MODULE="#"
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002051elif test "$ac_cv_pthread_is_default" = yes
2052then
2053 AC_DEFINE(WITH_THREAD)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002054 # Defining _REENTRANT on system with POSIX threads should not hurt.
2055 AC_DEFINE(_REENTRANT)
2056 posix_threads=yes
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002057 THREADOBJ="Python/thread.o"
Martin v. Löwis130fb172001-07-19 11:00:41 +00002058elif test "$ac_cv_kpthread" = "yes"
2059then
2060 CC="$CC -Kpthread"
Martin v. Löwis519adae2003-09-20 10:47:47 +00002061 if test "$ac_cv_cxx_thread" = "yes"; then
2062 CXX="$CXX -Kpthread"
2063 fi
Martin v. Löwis130fb172001-07-19 11:00:41 +00002064 AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002065 posix_threads=yes
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002066 THREADOBJ="Python/thread.o"
Martin v. Löwis5f433f02003-05-05 05:05:30 +00002067elif test "$ac_cv_kthread" = "yes"
2068then
2069 CC="$CC -Kthread"
Martin v. Löwis519adae2003-09-20 10:47:47 +00002070 if test "$ac_cv_cxx_thread" = "yes"; then
2071 CXX="$CXX -Kthread"
2072 fi
Martin v. Löwis5f433f02003-05-05 05:05:30 +00002073 AC_DEFINE(WITH_THREAD)
2074 posix_threads=yes
2075 THREADOBJ="Python/thread.o"
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002076elif test "$ac_cv_pthread" = "yes"
2077then
2078 CC="$CC -pthread"
Martin v. Löwis519adae2003-09-20 10:47:47 +00002079 if test "$ac_cv_cxx_thread" = "yes"; then
2080 CXX="$CXX -pthread"
2081 fi
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002082 AC_DEFINE(WITH_THREAD)
2083 posix_threads=yes
2084 THREADOBJ="Python/thread.o"
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00002085else
Martin v. Löwis130fb172001-07-19 11:00:41 +00002086 if test ! -z "$with_threads" -a -d "$with_threads"
2087 then LDFLAGS="$LDFLAGS -L$with_threads"
2088 fi
2089 if test ! -z "$withval" -a -d "$withval"
2090 then LDFLAGS="$LDFLAGS -L$withval"
2091 fi
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002092
2093 # According to the POSIX spec, a pthreads implementation must
Matthias Klosea2542be2004-08-16 11:35:51 +00002094 # define _POSIX_THREADS in unistd.h. Some apparently don't
2095 # (e.g. gnu pth with pthread emulation)
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002096 AC_MSG_CHECKING(for _POSIX_THREADS in unistd.h)
2097 AC_EGREP_CPP(yes,
Neal Norwitz6eb37f02003-02-23 23:28:15 +00002098 [
2099#include <unistd.h>
2100#ifdef _POSIX_THREADS
2101yes
2102#endif
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002103 ], unistd_defines_pthreads=yes, unistd_defines_pthreads=no)
2104 AC_MSG_RESULT($unistd_defines_pthreads)
2105
Martin v. Löwis130fb172001-07-19 11:00:41 +00002106 AC_DEFINE(_REENTRANT)
Martin v. Löwisa6e97582002-01-01 18:41:33 +00002107 AC_CHECK_HEADER(cthreads.h, [AC_DEFINE(WITH_THREAD)
2108 AC_DEFINE(C_THREADS)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002109 AC_DEFINE(HURD_C_THREADS, 1,
2110 [Define if you are using Mach cthreads directly under /include])
Martin v. Löwisa6e97582002-01-01 18:41:33 +00002111 LIBS="$LIBS -lthreads"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002112 THREADOBJ="Python/thread.o"],[
Martin v. Löwis130fb172001-07-19 11:00:41 +00002113 AC_CHECK_HEADER(mach/cthreads.h, [AC_DEFINE(WITH_THREAD)
2114 AC_DEFINE(C_THREADS)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002115 AC_DEFINE(MACH_C_THREADS, 1,
2116 [Define if you are using Mach cthreads under mach /])
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002117 THREADOBJ="Python/thread.o"],[
Martin v. Löwis8158b5a2001-10-08 13:17:28 +00002118 # Just looking for pthread_create in libpthread is not enough:
2119 # on HP/UX, pthread.h renames pthread_create to a different symbol name.
2120 # So we really have to include pthread.h, and then link.
2121 _libs=$LIBS
2122 LIBS="$LIBS -lpthread"
2123 AC_MSG_CHECKING([for pthread_create in -lpthread])
2124 AC_TRY_LINK([#include <pthread.h>
2125
2126void * start_routine (void *arg) { exit (0); }], [
2127pthread_create (NULL, NULL, start_routine, NULL)], [
2128 AC_MSG_RESULT(yes)
2129 AC_DEFINE(WITH_THREAD)
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002130 posix_threads=yes
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002131 THREADOBJ="Python/thread.o"],[
Martin v. Löwis8158b5a2001-10-08 13:17:28 +00002132 LIBS=$_libs
Martin v. Löwis130fb172001-07-19 11:00:41 +00002133 AC_CHECK_FUNC(pthread_detach, [AC_DEFINE(WITH_THREAD)
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002134 posix_threads=yes
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002135 THREADOBJ="Python/thread.o"],[
Martin v. Löwis130fb172001-07-19 11:00:41 +00002136 AC_CHECK_LIB(pthreads, pthread_create, [AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002137 posix_threads=yes
Martin v. Löwis130fb172001-07-19 11:00:41 +00002138 LIBS="$LIBS -lpthreads"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002139 THREADOBJ="Python/thread.o"], [
Martin v. Löwis130fb172001-07-19 11:00:41 +00002140 AC_CHECK_LIB(c_r, pthread_create, [AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002141 posix_threads=yes
Martin v. Löwis130fb172001-07-19 11:00:41 +00002142 LIBS="$LIBS -lc_r"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002143 THREADOBJ="Python/thread.o"], [
Martin v. Löwis130fb172001-07-19 11:00:41 +00002144 AC_CHECK_LIB(pthread, __pthread_create_system, [AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002145 posix_threads=yes
Martin v. Löwis130fb172001-07-19 11:00:41 +00002146 LIBS="$LIBS -lpthread"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002147 THREADOBJ="Python/thread.o"], [
Martin v. Löwis130fb172001-07-19 11:00:41 +00002148 AC_CHECK_LIB(cma, pthread_create, [AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002149 posix_threads=yes
Martin v. Löwis130fb172001-07-19 11:00:41 +00002150 LIBS="$LIBS -lcma"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002151 THREADOBJ="Python/thread.o"],[
Martin v. Löwis130fb172001-07-19 11:00:41 +00002152 USE_THREAD_MODULE="#"])
Antoine Pitroudb6c5672009-10-24 20:35:52 +00002153 ])])])])])])])
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00002154
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002155 AC_CHECK_LIB(mpc, usconfig, [AC_DEFINE(WITH_THREAD)
2156 LIBS="$LIBS -lmpc"
2157 THREADOBJ="Python/thread.o"
2158 USE_THREAD_MODULE=""])
2159
2160 if test "$posix_threads" != "yes"; then
2161 AC_CHECK_LIB(thread, thr_create, [AC_DEFINE(WITH_THREAD)
2162 LIBS="$LIBS -lthread"
2163 THREADOBJ="Python/thread.o"
2164 USE_THREAD_MODULE=""])
2165 fi
2166
2167 if test "$USE_THREAD_MODULE" != "#"
2168 then
2169 # If the above checks didn't disable threads, (at least) OSF1
2170 # needs this '-threads' argument during linking.
2171 case $ac_sys_system in
2172 OSF1) LDLAST=-threads;;
2173 esac
2174 fi
2175fi
2176
2177if test "$posix_threads" = "yes"; then
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002178 if test "$unistd_defines_pthreads" = "no"; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002179 AC_DEFINE(_POSIX_THREADS, 1,
2180 [Define if you have POSIX threads,
2181 and your system does not define that.])
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002182 fi
2183
Martin v. Löwisdfc33fd2003-01-21 10:14:41 +00002184 # Bug 662787: Using semaphores causes unexplicable hangs on Solaris 8.
2185 case $ac_sys_system/$ac_sys_release in
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002186 SunOS/5.6) AC_DEFINE(HAVE_PTHREAD_DESTRUCTOR, 1,
Matthias Klosec80c93f2010-04-24 17:04:35 +00002187 [Defined for Solaris 2.6 bug in pthread header.])
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002188 ;;
Martin v. Löwisdfc33fd2003-01-21 10:14:41 +00002189 SunOS/5.8) AC_DEFINE(HAVE_BROKEN_POSIX_SEMAPHORES, 1,
Matthias Klosec80c93f2010-04-24 17:04:35 +00002190 [Define if the Posix semaphores do not work on your system])
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002191 ;;
Christian Heimes7b3ce6a2008-01-31 14:31:45 +00002192 AIX/5) AC_DEFINE(HAVE_BROKEN_POSIX_SEMAPHORES, 1,
Matthias Klosec80c93f2010-04-24 17:04:35 +00002193 [Define if the Posix semaphores do not work on your system])
Christian Heimes7b3ce6a2008-01-31 14:31:45 +00002194 ;;
Martin v. Löwisdfc33fd2003-01-21 10:14:41 +00002195 esac
2196
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002197 AC_MSG_CHECKING(if PTHREAD_SCOPE_SYSTEM is supported)
2198 AC_CACHE_VAL(ac_cv_pthread_system_supported,
2199 [AC_TRY_RUN([#include <pthread.h>
2200 void *foo(void *parm) {
2201 return NULL;
2202 }
2203 main() {
2204 pthread_attr_t attr;
Martin v. Löwisa82d3472002-02-24 16:05:05 +00002205 pthread_t id;
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002206 if (pthread_attr_init(&attr)) exit(-1);
2207 if (pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM)) exit(-1);
Martin v. Löwisa82d3472002-02-24 16:05:05 +00002208 if (pthread_create(&id, &attr, foo, NULL)) exit(-1);
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002209 exit(0);
Guido van Rossum3065c942001-09-17 04:03:14 +00002210 }],
2211 ac_cv_pthread_system_supported=yes,
2212 ac_cv_pthread_system_supported=no,
2213 ac_cv_pthread_system_supported=no)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002214 ])
2215 AC_MSG_RESULT($ac_cv_pthread_system_supported)
2216 if test "$ac_cv_pthread_system_supported" = "yes"; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002217 AC_DEFINE(PTHREAD_SYSTEM_SCHED_SUPPORTED, 1, [Defined if PTHREAD_SCOPE_SYSTEM supported.])
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002218 fi
Jason Tishlerfac083d2003-07-22 15:20:49 +00002219 AC_CHECK_FUNCS(pthread_sigmask,
2220 [case $ac_sys_system in
2221 CYGWIN*)
2222 AC_DEFINE(HAVE_BROKEN_PTHREAD_SIGMASK, 1,
2223 [Define if pthread_sigmask() does not work on your system.])
2224 ;;
2225 esac])
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00002226fi
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002227
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002228
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002229# Check for enable-ipv6
Martin v. Löwis11437992002-04-12 09:54:03 +00002230AH_TEMPLATE(ENABLE_IPV6, [Define if --enable-ipv6 is specified])
Martin v. Löwisa5f8bb52001-09-05 08:22:34 +00002231AC_MSG_CHECKING([if --enable-ipv6 is specified])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002232AC_ARG_ENABLE(ipv6,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002233[ --enable-ipv6 Enable ipv6 (with ipv4) support
2234 --disable-ipv6 Disable ipv6 support],
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002235[ case "$enableval" in
2236 no)
2237 AC_MSG_RESULT(no)
2238 ipv6=no
2239 ;;
2240 *) AC_MSG_RESULT(yes)
2241 AC_DEFINE(ENABLE_IPV6)
2242 ipv6=yes
2243 ;;
2244 esac ],
2245
Martin v. Löwisa5f8bb52001-09-05 08:22:34 +00002246[
2247dnl the check does not work on cross compilation case...
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002248 AC_TRY_RUN([ /* AF_INET6 available check */
2249#include <sys/types.h>
2250#include <sys/socket.h>
2251main()
2252{
2253 if (socket(AF_INET6, SOCK_STREAM, 0) < 0)
2254 exit(1);
2255 else
2256 exit(0);
2257}
2258],
2259 AC_MSG_RESULT(yes)
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002260 ipv6=yes,
2261 AC_MSG_RESULT(no)
2262 ipv6=no,
2263 AC_MSG_RESULT(no)
2264 ipv6=no
Martin v. Löwisa5f8bb52001-09-05 08:22:34 +00002265)
2266
2267if test "$ipv6" = "yes"; then
2268 AC_MSG_CHECKING(if RFC2553 API is available)
2269 AC_TRY_COMPILE([#include <sys/types.h>
2270#include <netinet/in.h>],
2271 [struct sockaddr_in6 x;
2272x.sin6_scope_id;],
2273 AC_MSG_RESULT(yes)
2274 ipv6=yes,
2275 AC_MSG_RESULT(no, IPv6 disabled)
2276 ipv6=no)
2277fi
2278
2279if test "$ipv6" = "yes"; then
2280 AC_DEFINE(ENABLE_IPV6)
2281fi
2282])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002283
2284ipv6type=unknown
2285ipv6lib=none
2286ipv6trylibc=no
2287
2288if test "$ipv6" = "yes"; then
2289 AC_MSG_CHECKING([ipv6 stack type])
Guido van Rossumb8552162001-09-05 14:58:11 +00002290 for i in inria kame linux-glibc linux-inet6 solaris toshiba v6d zeta;
2291 do
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002292 case $i in
2293 inria)
2294 dnl http://www.kame.net/
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002295 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002296#include <netinet/in.h>
2297#ifdef IPV6_INRIA_VERSION
2298yes
2299#endif],
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002300 [ipv6type=$i])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002301 ;;
2302 kame)
2303 dnl http://www.kame.net/
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002304 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002305#include <netinet/in.h>
2306#ifdef __KAME__
2307yes
2308#endif],
2309 [ipv6type=$i;
2310 ipv6lib=inet6
2311 ipv6libdir=/usr/local/v6/lib
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002312 ipv6trylibc=yes])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002313 ;;
2314 linux-glibc)
2315 dnl http://www.v6.linux.or.jp/
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002316 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002317#include <features.h>
2318#if defined(__GLIBC__) && ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1) || (__GLIBC__ > 2))
2319yes
2320#endif],
2321 [ipv6type=$i;
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002322 ipv6trylibc=yes])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002323 ;;
2324 linux-inet6)
2325 dnl http://www.v6.linux.or.jp/
2326 if test -d /usr/inet6; then
2327 ipv6type=$i
2328 ipv6lib=inet6
2329 ipv6libdir=/usr/inet6/lib
Skip Montanarodecc6a42003-01-01 20:07:49 +00002330 BASECFLAGS="-I/usr/inet6/include $BASECFLAGS"
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002331 fi
2332 ;;
2333 solaris)
2334 if test -f /etc/netconfig; then
2335 if /usr/xpg4/bin/grep -q tcp6 /etc/netconfig; then
2336 ipv6type=$i
2337 ipv6trylibc=yes
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002338 fi
2339 fi
2340 ;;
2341 toshiba)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002342 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002343#include <sys/param.h>
2344#ifdef _TOSHIBA_INET6
2345yes
2346#endif],
2347 [ipv6type=$i;
2348 ipv6lib=inet6;
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002349 ipv6libdir=/usr/local/v6/lib])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002350 ;;
2351 v6d)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002352 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002353#include </usr/local/v6/include/sys/v6config.h>
2354#ifdef __V6D__
2355yes
2356#endif],
2357 [ipv6type=$i;
2358 ipv6lib=v6;
2359 ipv6libdir=/usr/local/v6/lib;
Skip Montanarodecc6a42003-01-01 20:07:49 +00002360 BASECFLAGS="-I/usr/local/v6/include $BASECFLAGS"])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002361 ;;
2362 zeta)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002363 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002364#include <sys/param.h>
2365#ifdef _ZETA_MINAMI_INET6
2366yes
2367#endif],
2368 [ipv6type=$i;
2369 ipv6lib=inet6;
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002370 ipv6libdir=/usr/local/v6/lib])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002371 ;;
2372 esac
2373 if test "$ipv6type" != "unknown"; then
2374 break
2375 fi
2376 done
2377 AC_MSG_RESULT($ipv6type)
2378fi
2379
2380if test "$ipv6" = "yes" -a "$ipv6lib" != "none"; then
2381 if test -d $ipv6libdir -a -f $ipv6libdir/lib$ipv6lib.a; then
2382 LIBS="-L$ipv6libdir -l$ipv6lib $LIBS"
2383 echo "using lib$ipv6lib"
2384 else
2385 if test $ipv6trylibc = "yes"; then
2386 echo "using libc"
2387 else
2388 echo 'Fatal: no $ipv6lib library found. cannot continue.'
2389 echo "You need to fetch lib$ipv6lib.a from appropriate"
2390 echo 'ipv6 kit and compile beforehand.'
2391 exit 1
2392 fi
2393 fi
2394fi
2395
Georg Brandl93de2162008-07-16 02:21:06 +00002396AC_MSG_CHECKING(for OSX 10.5 SDK or later)
Matthias Klosec80c93f2010-04-24 17:04:35 +00002397AC_TRY_COMPILE([#include <Carbon/Carbon.h>], [FSIORefNum fRef = 0],
2398 AC_DEFINE(HAVE_OSX105_SDK, 1, [Define if compiling using MacOS X 10.5 SDK or later.])
Georg Brandl93de2162008-07-16 02:21:06 +00002399 AC_MSG_RESULT(yes),
2400 AC_MSG_RESULT(no)
2401)
2402
Martin v. Löwisa3fb4f72002-06-09 13:33:54 +00002403# Check for --with-doc-strings
2404AC_MSG_CHECKING(for --with-doc-strings)
2405AC_ARG_WITH(doc-strings,
Matthias Klosec80c93f2010-04-24 17:04:35 +00002406 AC_HELP_STRING([--with(out)-doc-strings], [disable/enable documentation strings]))
Martin v. Löwisa3fb4f72002-06-09 13:33:54 +00002407
2408if test -z "$with_doc_strings"
2409then with_doc_strings="yes"
2410fi
2411if test "$with_doc_strings" != "no"
2412then
2413 AC_DEFINE(WITH_DOC_STRINGS, 1,
2414 [Define if you want documentation strings in extension modules])
2415fi
2416AC_MSG_RESULT($with_doc_strings)
2417
Neil Schemenauera35c6882001-02-27 04:45:05 +00002418# Check for Python-specific malloc support
Martin v. Löwisf30d60e2004-06-08 08:17:44 +00002419AC_MSG_CHECKING(for --with-tsc)
2420AC_ARG_WITH(tsc,
Matthias Klosec80c93f2010-04-24 17:04:35 +00002421 AC_HELP_STRING([--with(out)-tsc],[enable/disable timestamp counter profile]),[
Martin v. Löwisf30d60e2004-06-08 08:17:44 +00002422if test "$withval" != no
2423then
2424 AC_DEFINE(WITH_TSC, 1,
2425 [Define to profile with the Pentium timestamp counter])
2426 AC_MSG_RESULT(yes)
2427else AC_MSG_RESULT(no)
2428fi],
2429[AC_MSG_RESULT(no)])
2430
2431# Check for Python-specific malloc support
Neil Schemenauera35c6882001-02-27 04:45:05 +00002432AC_MSG_CHECKING(for --with-pymalloc)
2433AC_ARG_WITH(pymalloc,
Matthias Klosec80c93f2010-04-24 17:04:35 +00002434 AC_HELP_STRING([--with(out)-pymalloc], [disable/enable specialized mallocs]))
Neil Schemenauer16c22972002-03-22 15:34:49 +00002435
2436if test -z "$with_pymalloc"
2437then with_pymalloc="yes"
2438fi
2439if test "$with_pymalloc" != "no"
2440then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002441 AC_DEFINE(WITH_PYMALLOC, 1,
2442 [Define if you want to compile in Python-specific mallocs])
Neil Schemenauer16c22972002-03-22 15:34:49 +00002443fi
2444AC_MSG_RESULT($with_pymalloc)
Neil Schemenauera35c6882001-02-27 04:45:05 +00002445
Benjamin Peterson05159c42009-12-03 03:01:27 +00002446# Check for Valgrind support
2447AC_MSG_CHECKING([for --with-valgrind])
2448AC_ARG_WITH([valgrind],
2449 AC_HELP_STRING([--with-valgrind], [Enable Valgrind support]),,
2450 with_valgrind=no)
2451AC_MSG_RESULT([$with_valgrind])
2452if test "$with_valgrind" != no; then
2453 AC_CHECK_HEADER([valgrind/valgrind.h],
2454 [AC_DEFINE([WITH_VALGRIND], 1, [Define if you want pymalloc to be disabled when running under valgrind])],
2455 [AC_MSG_ERROR([Valgrind support requested but headers not available])]
2456 )
2457fi
2458
Barry Warsawef82cd72000-06-30 16:21:01 +00002459# Check for --with-wctype-functions
2460AC_MSG_CHECKING(for --with-wctype-functions)
2461AC_ARG_WITH(wctype-functions,
Matthias Klosec80c93f2010-04-24 17:04:35 +00002462 AC_HELP_STRING([--with-wctype-functions], [use wctype.h functions]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002463[
Barry Warsawef82cd72000-06-30 16:21:01 +00002464if test "$withval" != no
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002465then
2466 AC_DEFINE(WANT_WCTYPE_FUNCTIONS, 1,
2467 [Define if you want wctype.h functions to be used instead of the
2468 one supplied by Python itself. (see Include/unicodectype.h).])
2469 AC_MSG_RESULT(yes)
Barry Warsawef82cd72000-06-30 16:21:01 +00002470else AC_MSG_RESULT(no)
2471fi],
2472[AC_MSG_RESULT(no)])
2473
Guido van Rossum68242b51996-05-28 22:53:03 +00002474# -I${DLINCLDIR} is added to the compile rule for importdl.o
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002475AC_SUBST(DLINCLDIR)
Guido van Rossum98935bf2001-09-05 19:13:16 +00002476DLINCLDIR=.
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002477
Guido van Rossume97ee181999-12-20 21:27:22 +00002478# the dlopen() function means we might want to use dynload_shlib.o. some
2479# platforms, such as AIX, have dlopen(), but don't want to use it.
Thomas Wouters3a584202000-08-05 23:28:51 +00002480AC_CHECK_FUNCS(dlopen)
Guido van Rossume97ee181999-12-20 21:27:22 +00002481
2482# DYNLOADFILE specifies which dynload_*.o file we will use for dynamic
2483# loading of modules.
2484AC_SUBST(DYNLOADFILE)
2485AC_MSG_CHECKING(DYNLOADFILE)
2486if test -z "$DYNLOADFILE"
2487then
2488 case $ac_sys_system/$ac_sys_release in
Martin v. Löwisc19c5a62003-11-18 20:00:44 +00002489 AIX*) # Use dynload_shlib.c and dlopen() if we have it; otherwise dynload_aix.c
2490 if test "$ac_cv_func_dlopen" = yes
2491 then DYNLOADFILE="dynload_shlib.o"
2492 else DYNLOADFILE="dynload_aix.o"
2493 fi
2494 ;;
Guido van Rossume97ee181999-12-20 21:27:22 +00002495 hp*|HP*) DYNLOADFILE="dynload_hpux.o";;
Thomas Wouters49fd7fa2006-04-21 10:40:58 +00002496 # Use dynload_next.c only on 10.2 and below, which don't have native dlopen()
2497 Darwin/@<:@0156@:>@\..*) DYNLOADFILE="dynload_next.o";;
Guido van Rossume97ee181999-12-20 21:27:22 +00002498 *)
2499 # use dynload_shlib.c and dlopen() if we have it; otherwise stub
2500 # out any dynamic loading
2501 if test "$ac_cv_func_dlopen" = yes
2502 then DYNLOADFILE="dynload_shlib.o"
2503 else DYNLOADFILE="dynload_stub.o"
2504 fi
2505 ;;
2506 esac
2507fi
2508AC_MSG_RESULT($DYNLOADFILE)
2509if test "$DYNLOADFILE" != "dynload_stub.o"
2510then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002511 AC_DEFINE(HAVE_DYNAMIC_LOADING, 1,
2512 [Defined when any dynamic module loading is enabled.])
Guido van Rossume97ee181999-12-20 21:27:22 +00002513fi
2514
Jack Jansenc49e5b72001-06-19 15:00:23 +00002515# MACHDEP_OBJS can be set to platform-specific object files needed by Python
2516
2517AC_SUBST(MACHDEP_OBJS)
2518AC_MSG_CHECKING(MACHDEP_OBJS)
2519if test -z "$MACHDEP_OBJS"
2520then
Jack Jansenb6e9cad2001-08-15 01:26:28 +00002521 MACHDEP_OBJS=$extra_machdep_objs
2522else
2523 MACHDEP_OBJS="$MACHDEP_OBJS $extra_machdep_objs"
Jack Jansenc49e5b72001-06-19 15:00:23 +00002524fi
Jack Jansenb6e9cad2001-08-15 01:26:28 +00002525AC_MSG_RESULT(MACHDEP_OBJS)
Jack Jansenc49e5b72001-06-19 15:00:23 +00002526
Guido van Rossum627b2d71993-12-24 10:39:16 +00002527# checks for library functions
Martin v. Löwis823725e2008-03-24 13:39:54 +00002528AC_CHECK_FUNCS(alarm setitimer getitimer bind_textdomain_codeset chown \
2529 clock confstr ctermid execv fchmod fchown fork fpathconf ftime ftruncate \
Martin v. Löwis438b5342002-12-27 10:16:42 +00002530 gai_strerror getgroups getlogin getloadavg getpeername getpgid getpid \
Martin v. Löwis7aed61a2009-11-27 14:09:49 +00002531 getpriority getresuid getresgid getpwent getspnam getspent getsid getwd \
Antoine Pitroub7572f02009-12-02 20:46:48 +00002532 initgroups kill killpg lchmod lchown lstat mbrtowc mkfifo mknod mktime \
Martin v. Löwisa5f09072002-10-11 05:37:59 +00002533 mremap nice pathconf pause plock poll pthread_init \
Guido van Rossum162e38c2003-02-19 15:25:10 +00002534 putenv readlink realpath \
Benjamin Peterson965ce872009-04-05 21:24:58 +00002535 select sem_open sem_timedwait sem_getvalue sem_unlink setegid seteuid \
2536 setgid \
Martin v. Löwis7aed61a2009-11-27 14:09:49 +00002537 setlocale setregid setreuid setresuid setresgid setsid setpgid setpgrp setuid setvbuf \
2538 sigaction siginterrupt sigrelse snprintf strftime strlcpy \
Michael W. Hudson34f20ea2002-05-27 15:08:24 +00002539 sysconf tcgetpgrp tcsetpgrp tempnam timegm times tmpfile tmpnam tmpnam_r \
Martin v. Löwis113a0852009-05-29 17:25:39 +00002540 truncate uname unsetenv utimes waitpid wait3 wait4 \
2541 wcscoll wcsftime wcsxfrm _getpty)
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00002542
Martin v. Löwisc8ad7cc2002-11-11 13:23:45 +00002543# For some functions, having a definition is not sufficient, since
2544# we want to take their address.
2545AC_MSG_CHECKING(for chroot)
Matthias Klosec80c93f2010-04-24 17:04:35 +00002546AC_TRY_COMPILE([#include <unistd.h>], [void *x=chroot],
2547 AC_DEFINE(HAVE_CHROOT, 1, [Define if you have the 'chroot' function.])
Martin v. Löwisc8ad7cc2002-11-11 13:23:45 +00002548 AC_MSG_RESULT(yes),
2549 AC_MSG_RESULT(no)
2550)
2551AC_MSG_CHECKING(for link)
Matthias Klosec80c93f2010-04-24 17:04:35 +00002552AC_TRY_COMPILE([#include <unistd.h>], [void *x=link],
2553 AC_DEFINE(HAVE_LINK, 1, [Define if you have the 'link' function.])
Martin v. Löwisc8ad7cc2002-11-11 13:23:45 +00002554 AC_MSG_RESULT(yes),
2555 AC_MSG_RESULT(no)
2556)
2557AC_MSG_CHECKING(for symlink)
Matthias Klosec80c93f2010-04-24 17:04:35 +00002558AC_TRY_COMPILE([#include <unistd.h>], [void *x=symlink],
2559 AC_DEFINE(HAVE_SYMLINK, 1, [Define if you have the 'symlink' function.])
Martin v. Löwisc8ad7cc2002-11-11 13:23:45 +00002560 AC_MSG_RESULT(yes),
2561 AC_MSG_RESULT(no)
2562)
Martin v. Löwisa64988c2003-09-20 15:30:20 +00002563AC_MSG_CHECKING(for fchdir)
Matthias Klosec80c93f2010-04-24 17:04:35 +00002564AC_TRY_COMPILE([#include <unistd.h>], [void *x=fchdir],
2565 AC_DEFINE(HAVE_FCHDIR, 1, [Define if you have the 'fchdir' function.])
Martin v. Löwisa64988c2003-09-20 15:30:20 +00002566 AC_MSG_RESULT(yes),
2567 AC_MSG_RESULT(no)
2568)
2569AC_MSG_CHECKING(for fsync)
Matthias Klosec80c93f2010-04-24 17:04:35 +00002570AC_TRY_COMPILE([#include <unistd.h>], [void *x=fsync],
2571 AC_DEFINE(HAVE_FSYNC, 1, [Define if you have the 'fsync' function.])
Martin v. Löwisa64988c2003-09-20 15:30:20 +00002572 AC_MSG_RESULT(yes),
2573 AC_MSG_RESULT(no)
2574)
2575AC_MSG_CHECKING(for fdatasync)
Matthias Klosec80c93f2010-04-24 17:04:35 +00002576AC_TRY_COMPILE([#include <unistd.h>], [void *x=fdatasync],
2577 AC_DEFINE(HAVE_FDATASYNC, 1, [Define if you have the 'fdatasync' function.])
Martin v. Löwisa64988c2003-09-20 15:30:20 +00002578 AC_MSG_RESULT(yes),
2579 AC_MSG_RESULT(no)
2580)
Christian Heimes4fbc72b2008-03-22 00:47:35 +00002581AC_MSG_CHECKING(for epoll)
Matthias Klosec80c93f2010-04-24 17:04:35 +00002582AC_TRY_COMPILE([#include <sys/epoll.h>], [void *x=epoll_create],
2583 AC_DEFINE(HAVE_EPOLL, 1, [Define if you have the 'epoll' functions.])
Christian Heimes4fbc72b2008-03-22 00:47:35 +00002584 AC_MSG_RESULT(yes),
2585 AC_MSG_RESULT(no)
2586)
2587AC_MSG_CHECKING(for kqueue)
2588AC_TRY_COMPILE([
2589#include <sys/types.h>
2590#include <sys/event.h>
Matthias Klosec80c93f2010-04-24 17:04:35 +00002591 ], [int x=kqueue()],
2592 AC_DEFINE(HAVE_KQUEUE, 1, [Define if you have the 'kqueue' functions.])
Christian Heimes4fbc72b2008-03-22 00:47:35 +00002593 AC_MSG_RESULT(yes),
2594 AC_MSG_RESULT(no)
2595)
Martin v. Löwisd5843682002-11-21 20:41:28 +00002596# On some systems (eg. FreeBSD 5), we would find a definition of the
2597# functions ctermid_r, setgroups in the library, but no prototype
2598# (e.g. because we use _XOPEN_SOURCE). See whether we can take their
2599# address to avoid compiler warnings and potential miscompilations
2600# because of the missing prototypes.
2601
2602AC_MSG_CHECKING(for ctermid_r)
2603AC_TRY_COMPILE([
2604#include "confdefs.h"
2605#include <stdio.h>
Matthias Klosec80c93f2010-04-24 17:04:35 +00002606], [void* p = ctermid_r],
2607 AC_DEFINE(HAVE_CTERMID_R, 1, [Define if you have the 'ctermid_r' function.])
Martin v. Löwisd5843682002-11-21 20:41:28 +00002608 AC_MSG_RESULT(yes),
2609 AC_MSG_RESULT(no)
2610)
2611
Martin v. Löwisf26d63b2003-03-30 17:23:49 +00002612AC_MSG_CHECKING(for flock)
2613AC_TRY_COMPILE([
2614#include "confdefs.h"
2615#include <sys/file.h>
Matthias Klosec80c93f2010-04-24 17:04:35 +00002616], [void* p = flock],
2617 AC_DEFINE(HAVE_FLOCK, 1, [Define if you have the 'flock' function.])
Martin v. Löwisf26d63b2003-03-30 17:23:49 +00002618 AC_MSG_RESULT(yes),
2619 AC_MSG_RESULT(no)
2620)
2621
2622AC_MSG_CHECKING(for getpagesize)
2623AC_TRY_COMPILE([
2624#include "confdefs.h"
2625#include <unistd.h>
Matthias Klosec80c93f2010-04-24 17:04:35 +00002626], [void* p = getpagesize],
2627 AC_DEFINE(HAVE_GETPAGESIZE, 1, [Define if you have the 'getpagesize' function.])
Martin v. Löwisf26d63b2003-03-30 17:23:49 +00002628 AC_MSG_RESULT(yes),
2629 AC_MSG_RESULT(no)
2630)
2631
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002632dnl check for true
2633AC_CHECK_PROGS(TRUE, true, /bin/true)
2634
Martin v. Löwis95c419b2003-05-03 12:10:48 +00002635dnl On some systems (e.g. Solaris 9), hstrerror and inet_aton are in -lresolv
2636dnl On others, they are in the C library, so we to take no action
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002637AC_CHECK_LIB(c, inet_aton, [$ac_cv_prog_TRUE],
Martin v. Löwis95c419b2003-05-03 12:10:48 +00002638 AC_CHECK_LIB(resolv, inet_aton)
2639)
2640
Christian Heimesd0764e22007-12-04 15:00:33 +00002641# On Tru64, chflags seems to be present, but calling it will
2642# exit Python
Benjamin Petersoned68afa2010-01-30 19:36:43 +00002643AC_CACHE_CHECK([for chflags], [ac_cv_have_chflags], [dnl
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00002644AC_TRY_RUN([[
Christian Heimesd0764e22007-12-04 15:00:33 +00002645#include <sys/stat.h>
2646#include <unistd.h>
2647int main(int argc, char*argv[])
2648{
2649 if(chflags(argv[0], 0) != 0)
2650 return 1;
2651 return 0;
2652}
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00002653]], ac_cv_have_chflags=yes,
Benjamin Petersoned68afa2010-01-30 19:36:43 +00002654 ac_cv_have_chflags=no,
2655 ac_cv_have_chflags=cross)
2656])
2657if test "$ac_cv_have_chflags" = cross ; then
2658 AC_CHECK_FUNC([chflags], [ac_cv_have_chflags="yes"], [ac_cv_have_chflags="no"])
2659fi
2660if test "$ac_cv_have_chflags" = yes ; then
Matthias Klosec80c93f2010-04-24 17:04:35 +00002661 AC_DEFINE(HAVE_CHFLAGS, 1, [Define to 1 if you have the `chflags' function.])
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00002662fi
Christian Heimesd0764e22007-12-04 15:00:33 +00002663
Benjamin Petersoned68afa2010-01-30 19:36:43 +00002664AC_CACHE_CHECK([for lchflags], [ac_cv_have_lchflags], [dnl
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00002665AC_TRY_RUN([[
Christian Heimesd0764e22007-12-04 15:00:33 +00002666#include <sys/stat.h>
2667#include <unistd.h>
2668int main(int argc, char*argv[])
2669{
2670 if(lchflags(argv[0], 0) != 0)
2671 return 1;
2672 return 0;
2673}
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00002674]], ac_cv_have_lchflags=yes,
Benjamin Petersoned68afa2010-01-30 19:36:43 +00002675 ac_cv_have_lchflags=no,
2676 ac_cv_have_lchflags=cross)
2677])
2678if test "$ac_cv_have_lchflags" = cross ; then
2679 AC_CHECK_FUNC([lchflags], [ac_cv_have_lchflags="yes"], [ac_cv_have_lchflags="no"])
2680fi
2681if test "$ac_cv_have_lchflags" = yes ; then
Matthias Klosec80c93f2010-04-24 17:04:35 +00002682 AC_DEFINE(HAVE_LCHFLAGS, 1, [Define to 1 if you have the `lchflags' function.])
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00002683fi
Christian Heimesd0764e22007-12-04 15:00:33 +00002684
Thomas Wouters0e3f5912006-08-11 14:57:12 +00002685dnl Check if system zlib has *Copy() functions
2686dnl
2687dnl On MacOSX the linker will search for dylibs on the entire linker path
2688dnl before searching for static libraries. setup.py adds -Wl,-search_paths_first
2689dnl to revert to a more traditional unix behaviour and make it possible to
2690dnl override the system libz with a local static library of libz. Temporarily
2691dnl add that flag to our CFLAGS as well to ensure that we check the version
2692dnl of libz that will be used by setup.py.
2693dnl The -L/usr/local/lib is needed as wel to get the same compilation
2694dnl environment as setup.py (and leaving it out can cause configure to use the
2695dnl wrong version of the library)
2696case $ac_sys_system/$ac_sys_release in
2697Darwin/*)
2698 _CUR_CFLAGS="${CFLAGS}"
2699 _CUR_LDFLAGS="${LDFLAGS}"
2700 CFLAGS="${CFLAGS} -Wl,-search_paths_first"
2701 LDFLAGS="${LDFLAGS} -Wl,-search_paths_first -L/usr/local/lib"
2702 ;;
2703esac
2704
Matthias Klosec80c93f2010-04-24 17:04:35 +00002705AC_CHECK_LIB(z, inflateCopy, AC_DEFINE(HAVE_ZLIB_COPY, 1, [Define if the zlib library has inflateCopy]))
Thomas Wouters0e3f5912006-08-11 14:57:12 +00002706
2707case $ac_sys_system/$ac_sys_release in
2708Darwin/*)
2709 CFLAGS="${_CUR_CFLAGS}"
2710 LDFLAGS="${_CUR_LDFLAGS}"
2711 ;;
2712esac
2713
Martin v. Löwise9416172003-05-03 10:12:45 +00002714AC_MSG_CHECKING(for hstrerror)
Martin v. Löwis95c419b2003-05-03 12:10:48 +00002715AC_TRY_LINK([
Martin v. Löwise9416172003-05-03 10:12:45 +00002716#include "confdefs.h"
2717#include <netdb.h>
Matthias Klosec80c93f2010-04-24 17:04:35 +00002718], [void* p = hstrerror; hstrerror(0)],
2719 AC_DEFINE(HAVE_HSTRERROR, 1, [Define if you have the 'hstrerror' function.])
Martin v. Löwise9416172003-05-03 10:12:45 +00002720 AC_MSG_RESULT(yes),
2721 AC_MSG_RESULT(no)
2722)
2723
2724AC_MSG_CHECKING(for inet_aton)
Martin v. Löwis95c419b2003-05-03 12:10:48 +00002725AC_TRY_LINK([
Martin v. Löwise9416172003-05-03 10:12:45 +00002726#include "confdefs.h"
Martin v. Löwis86d66262006-02-17 08:40:11 +00002727#include <sys/types.h>
Martin v. Löwise9416172003-05-03 10:12:45 +00002728#include <sys/socket.h>
2729#include <netinet/in.h>
2730#include <arpa/inet.h>
Matthias Klosec80c93f2010-04-24 17:04:35 +00002731], [void* p = inet_aton;inet_aton(0,0)],
2732 AC_DEFINE(HAVE_INET_ATON, 1, [Define if you have the 'inet_aton' function.])
Martin v. Löwise9416172003-05-03 10:12:45 +00002733 AC_MSG_RESULT(yes),
2734 AC_MSG_RESULT(no)
2735)
2736
2737AC_MSG_CHECKING(for inet_pton)
2738AC_TRY_COMPILE([
2739#include "confdefs.h"
Martin v. Löwisf2e488d2003-05-05 22:00:11 +00002740#include <sys/types.h>
Martin v. Löwise9416172003-05-03 10:12:45 +00002741#include <sys/socket.h>
2742#include <netinet/in.h>
2743#include <arpa/inet.h>
Matthias Klosec80c93f2010-04-24 17:04:35 +00002744], [void* p = inet_pton],
2745 AC_DEFINE(HAVE_INET_PTON, 1, [Define if you have the 'inet_pton' function.])
Martin v. Löwise9416172003-05-03 10:12:45 +00002746 AC_MSG_RESULT(yes),
2747 AC_MSG_RESULT(no)
2748)
2749
Martin v. Löwisd6640d42003-07-06 09:29:52 +00002750# On some systems, setgroups is in unistd.h, on others, in grp.h
Martin v. Löwisd5843682002-11-21 20:41:28 +00002751AC_MSG_CHECKING(for setgroups)
2752AC_TRY_COMPILE([
2753#include "confdefs.h"
Martin v. Löwisf2e488d2003-05-05 22:00:11 +00002754#include <unistd.h>
Martin v. Löwisd6640d42003-07-06 09:29:52 +00002755#ifdef HAVE_GRP_H
2756#include <grp.h>
2757#endif
Martin v. Löwisd5843682002-11-21 20:41:28 +00002758],
Matthias Klosec80c93f2010-04-24 17:04:35 +00002759[void* p = setgroups],
2760 AC_DEFINE(HAVE_SETGROUPS, 1, [Define if you have the 'setgroups' function.])
Martin v. Löwisd5843682002-11-21 20:41:28 +00002761 AC_MSG_RESULT(yes),
2762 AC_MSG_RESULT(no)
2763)
2764
Fred Drake8cef4cf2000-06-28 16:40:38 +00002765# check for openpty and forkpty
2766
Martin v. Löwisfd9a72a2006-01-08 10:07:33 +00002767AC_CHECK_FUNCS(openpty,,
2768 AC_CHECK_LIB(util,openpty,
2769 [AC_DEFINE(HAVE_OPENPTY) LIBS="$LIBS -lutil"],
2770 AC_CHECK_LIB(bsd,openpty, [AC_DEFINE(HAVE_OPENPTY) LIBS="$LIBS -lbsd"])
2771 )
2772)
2773AC_CHECK_FUNCS(forkpty,,
2774 AC_CHECK_LIB(util,forkpty,
2775 [AC_DEFINE(HAVE_FORKPTY) LIBS="$LIBS -lutil"],
2776 AC_CHECK_LIB(bsd,forkpty, [AC_DEFINE(HAVE_FORKPTY) LIBS="$LIBS -lbsd"])
2777 )
2778)
Fred Drake8cef4cf2000-06-28 16:40:38 +00002779
Christian Heimesb186d002008-03-18 15:15:01 +00002780# Stuff for expat.
2781AC_CHECK_FUNCS(memmove)
2782
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00002783# check for long file support functions
2784AC_CHECK_FUNCS(fseek64 fseeko fstatvfs ftell64 ftello statvfs)
2785
Christian Heimesb186d002008-03-18 15:15:01 +00002786AC_REPLACE_FUNCS(dup2 getcwd strdup)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002787AC_CHECK_FUNCS(getpgrp,
2788 AC_TRY_COMPILE([#include <unistd.h>],
2789 [getpgrp(0);],
2790 AC_DEFINE(GETPGRP_HAVE_ARG, 1,
2791 [Define if getpgrp() must be called as getpgrp(0).])
2792 )
2793)
Jack Jansen150753c2003-03-29 22:07:47 +00002794AC_CHECK_FUNCS(setpgrp,
2795 AC_TRY_COMPILE([#include <unistd.h>],
2796 [setpgrp(0,0);],
2797 AC_DEFINE(SETPGRP_HAVE_ARG, 1,
2798 [Define if setpgrp() must be called as setpgrp(0, 0).])
2799 )
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002800)
2801AC_CHECK_FUNCS(gettimeofday,
2802 AC_TRY_COMPILE([#include <sys/time.h>],
2803 [gettimeofday((struct timeval*)0,(struct timezone*)0);], ,
2804 AC_DEFINE(GETTIMEOFDAY_NO_TZ, 1,
2805 [Define if gettimeofday() does not have second (timezone) argument
2806 This is the case on Motorola V4 (R40V4.2)])
2807 )
2808)
Guido van Rossum627b2d71993-12-24 10:39:16 +00002809
Martin v. Löwisdbe3f762002-10-10 14:27:30 +00002810AC_MSG_CHECKING(for major, minor, and makedev)
Martin v. Löwise3271202002-11-07 07:42:30 +00002811AC_TRY_LINK([
Neal Norwitz6eb37f02003-02-23 23:28:15 +00002812#if defined(MAJOR_IN_MKDEV)
2813#include <sys/mkdev.h>
2814#elif defined(MAJOR_IN_SYSMACROS)
2815#include <sys/sysmacros.h>
2816#else
2817#include <sys/types.h>
2818#endif
Martin v. Löwisdbe3f762002-10-10 14:27:30 +00002819],[
2820 makedev(major(0),minor(0));
2821],[
2822 AC_DEFINE(HAVE_DEVICE_MACROS, 1,
2823 [Define to 1 if you have the device macros.])
2824 AC_MSG_RESULT(yes)
2825],[
2826 AC_MSG_RESULT(no)
2827])
Martin v. Löwis861a65b2001-10-24 14:36:00 +00002828
2829# On OSF/1 V5.1, getaddrinfo is available, but a define
2830# for [no]getaddrinfo in netdb.h.
2831AC_MSG_CHECKING(for getaddrinfo)
2832AC_TRY_LINK([
Martin v. Löwisc010b6d2001-11-09 17:50:52 +00002833#include <sys/types.h>
Martin v. Löwis861a65b2001-10-24 14:36:00 +00002834#include <sys/socket.h>
2835#include <netdb.h>
Martin v. Löwisc010b6d2001-11-09 17:50:52 +00002836#include <stdio.h>
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00002837], [getaddrinfo(NULL, NULL, NULL, NULL);],
2838have_getaddrinfo=yes,
2839have_getaddrinfo=no)
2840AC_MSG_RESULT($have_getaddrinfo)
2841if test $have_getaddrinfo = yes
2842then
2843 AC_MSG_CHECKING(getaddrinfo bug)
2844 AC_CACHE_VAL(ac_cv_buggy_getaddrinfo,
2845 AC_TRY_RUN([[
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00002846#include <sys/types.h>
2847#include <netdb.h>
2848#include <string.h>
2849#include <sys/socket.h>
2850#include <netinet/in.h>
2851
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00002852int main()
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00002853{
2854 int passive, gaierr, inet4 = 0, inet6 = 0;
2855 struct addrinfo hints, *ai, *aitop;
2856 char straddr[INET6_ADDRSTRLEN], strport[16];
2857
2858 for (passive = 0; passive <= 1; passive++) {
2859 memset(&hints, 0, sizeof(hints));
2860 hints.ai_family = AF_UNSPEC;
2861 hints.ai_flags = passive ? AI_PASSIVE : 0;
2862 hints.ai_socktype = SOCK_STREAM;
Hye-Shik Chang54f94392004-04-14 07:55:31 +00002863 hints.ai_protocol = IPPROTO_TCP;
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00002864 if ((gaierr = getaddrinfo(NULL, "54321", &hints, &aitop)) != 0) {
2865 (void)gai_strerror(gaierr);
2866 goto bad;
2867 }
2868 for (ai = aitop; ai; ai = ai->ai_next) {
2869 if (ai->ai_addr == NULL ||
2870 ai->ai_addrlen == 0 ||
2871 getnameinfo(ai->ai_addr, ai->ai_addrlen,
2872 straddr, sizeof(straddr), strport, sizeof(strport),
2873 NI_NUMERICHOST|NI_NUMERICSERV) != 0) {
2874 goto bad;
2875 }
2876 switch (ai->ai_family) {
2877 case AF_INET:
2878 if (strcmp(strport, "54321") != 0) {
2879 goto bad;
2880 }
2881 if (passive) {
2882 if (strcmp(straddr, "0.0.0.0") != 0) {
2883 goto bad;
2884 }
2885 } else {
2886 if (strcmp(straddr, "127.0.0.1") != 0) {
2887 goto bad;
2888 }
2889 }
2890 inet4++;
2891 break;
2892 case AF_INET6:
2893 if (strcmp(strport, "54321") != 0) {
2894 goto bad;
2895 }
2896 if (passive) {
2897 if (strcmp(straddr, "::") != 0) {
2898 goto bad;
2899 }
2900 } else {
2901 if (strcmp(straddr, "::1") != 0) {
2902 goto bad;
2903 }
2904 }
2905 inet6++;
2906 break;
2907 case AF_UNSPEC:
2908 goto bad;
2909 break;
2910 default:
2911 /* another family support? */
2912 break;
2913 }
2914 }
2915 }
2916
2917 if (!(inet4 == 0 || inet4 == 2))
2918 goto bad;
2919 if (!(inet6 == 0 || inet6 == 2))
2920 goto bad;
2921
2922 if (aitop)
2923 freeaddrinfo(aitop);
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00002924 return 0;
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00002925
2926 bad:
2927 if (aitop)
2928 freeaddrinfo(aitop);
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00002929 return 1;
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00002930}
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00002931]], ac_cv_buggy_getaddrinfo=no,
2932 ac_cv_buggy_getaddrinfo=yes,
2933 ac_cv_buggy_getaddrinfo=yes))
2934fi
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00002935
Mark Dickinson2df5d282009-12-31 21:22:50 +00002936if test $have_getaddrinfo = no -o "$ac_cv_buggy_getaddrinfo" = yes
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00002937then
2938 if test $ipv6 = yes
2939 then
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00002940 echo 'Fatal: You must get working getaddrinfo() function.'
2941 echo ' or you can specify "--disable-ipv6"'.
2942 exit 1
2943 fi
Martin v. Löwis861a65b2001-10-24 14:36:00 +00002944else
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002945 AC_DEFINE(HAVE_GETADDRINFO, 1, [Define if you have the getaddrinfo function.])
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00002946fi
Thomas Woutersb0db85a2001-08-08 10:39:03 +00002947AC_CHECK_FUNCS(getnameinfo)
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00002948
Guido van Rossum627b2d71993-12-24 10:39:16 +00002949# checks for structures
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002950AC_HEADER_TIME
Guido van Rossum627b2d71993-12-24 10:39:16 +00002951AC_STRUCT_TM
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002952AC_STRUCT_TIMEZONE
Martin v. Löwis60a5d722002-10-16 20:28:25 +00002953AC_CHECK_MEMBERS([struct stat.st_rdev])
2954AC_CHECK_MEMBERS([struct stat.st_blksize])
Hye-Shik Chang5f937a72005-06-02 13:09:30 +00002955AC_CHECK_MEMBERS([struct stat.st_flags])
Martin v. Löwisebd9d5b2005-08-09 15:00:59 +00002956AC_CHECK_MEMBERS([struct stat.st_gen])
2957AC_CHECK_MEMBERS([struct stat.st_birthtime])
Guido van Rossum98bf58f2001-10-18 20:34:25 +00002958AC_STRUCT_ST_BLOCKS
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002959
2960AC_MSG_CHECKING(for time.h that defines altzone)
2961AC_CACHE_VAL(ac_cv_header_time_altzone,
2962[AC_TRY_COMPILE([#include <time.h>], [return altzone;],
2963 ac_cv_header_time_altzone=yes,
2964 ac_cv_header_time_altzone=no)])
2965AC_MSG_RESULT($ac_cv_header_time_altzone)
2966if test $ac_cv_header_time_altzone = yes; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002967 AC_DEFINE(HAVE_ALTZONE, 1, [Define this if your time.h defines altzone.])
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002968fi
2969
Guido van Rossum5739e7e1995-01-20 16:50:53 +00002970was_it_defined=no
2971AC_MSG_CHECKING(whether sys/select.h and sys/time.h may both be included)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002972AC_TRY_COMPILE([
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002973#include <sys/types.h>
2974#include <sys/select.h>
2975#include <sys/time.h>
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002976], [;], [
2977 AC_DEFINE(SYS_SELECT_WITH_SYS_TIME, 1,
2978 [Define if you can safely include both <sys/select.h> and <sys/time.h>
2979 (which you can't on SCO ODT 3.0).])
2980 was_it_defined=yes
2981])
Guido van Rossum5739e7e1995-01-20 16:50:53 +00002982AC_MSG_RESULT($was_it_defined)
Guido van Rossum627b2d71993-12-24 10:39:16 +00002983
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00002984AC_MSG_CHECKING(for addrinfo)
2985AC_CACHE_VAL(ac_cv_struct_addrinfo,
2986AC_TRY_COMPILE([
2987# include <netdb.h>],
2988 [struct addrinfo a],
2989 ac_cv_struct_addrinfo=yes,
2990 ac_cv_struct_addrinfo=no))
2991AC_MSG_RESULT($ac_cv_struct_addrinfo)
2992if test $ac_cv_struct_addrinfo = yes; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002993 AC_DEFINE(HAVE_ADDRINFO, 1, [struct addrinfo (netdb.h)])
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00002994fi
2995
2996AC_MSG_CHECKING(for sockaddr_storage)
2997AC_CACHE_VAL(ac_cv_struct_sockaddr_storage,
2998AC_TRY_COMPILE([
2999# include <sys/types.h>
3000# include <sys/socket.h>],
3001 [struct sockaddr_storage s],
3002 ac_cv_struct_sockaddr_storage=yes,
3003 ac_cv_struct_sockaddr_storage=no))
3004AC_MSG_RESULT($ac_cv_struct_sockaddr_storage)
3005if test $ac_cv_struct_sockaddr_storage = yes; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003006 AC_DEFINE(HAVE_SOCKADDR_STORAGE, 1, [struct sockaddr_storage (sys/socket.h)])
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003007fi
3008
Guido van Rossum627b2d71993-12-24 10:39:16 +00003009# checks for compiler characteristics
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003010
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003011AC_C_CHAR_UNSIGNED
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003012AC_C_CONST
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003013
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003014works=no
3015AC_MSG_CHECKING(for working volatile)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003016AC_TRY_COMPILE([],[volatile int x; x = 0;], works=yes,
3017 AC_DEFINE(volatile, [], [Define to empty if the keyword does not work.])
3018)
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003019AC_MSG_RESULT($works)
Guido van Rossumdabb11b1994-10-11 15:04:27 +00003020
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003021works=no
3022AC_MSG_CHECKING(for working signed char)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003023AC_TRY_COMPILE([], [signed char c;], works=yes,
3024 AC_DEFINE(signed, [], [Define to empty if the keyword does not work.])
3025)
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003026AC_MSG_RESULT($works)
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003027
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003028have_prototypes=no
3029AC_MSG_CHECKING(for prototypes)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003030AC_TRY_COMPILE([int foo(int x) { return 0; }], [return foo(10);],[
3031 AC_DEFINE(HAVE_PROTOTYPES, 1,
3032 [Define if your compiler supports function prototype])
3033 have_prototypes=yes
3034])
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003035AC_MSG_RESULT($have_prototypes)
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003036
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003037works=no
3038AC_MSG_CHECKING(for variable length prototypes and stdarg.h)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003039AC_TRY_COMPILE([
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003040#include <stdarg.h>
Guido van Rossum3f13e481996-08-30 20:58:11 +00003041int foo(int x, ...) {
3042 va_list va;
3043 va_start(va, x);
3044 va_arg(va, int);
3045 va_arg(va, char *);
3046 va_arg(va, double);
3047 return 0;
3048}
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003049], [return foo(10, "", 3.14);], [
3050 AC_DEFINE(HAVE_STDARG_PROTOTYPES, 1,
3051 [Define if your compiler supports variable length function prototypes
3052 (e.g. void fprintf(FILE *, char *, ...);) *and* <stdarg.h>])
3053 works=yes
3054])
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003055AC_MSG_RESULT($works)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003056
Dave Cole331708b2004-08-09 04:51:41 +00003057# check for socketpair
3058AC_MSG_CHECKING(for socketpair)
3059AC_TRY_COMPILE([
3060#include <sys/types.h>
3061#include <sys/socket.h>
Matthias Klosec80c93f2010-04-24 17:04:35 +00003062], [void *x=socketpair],
3063 AC_DEFINE(HAVE_SOCKETPAIR, 1, [Define if you have the 'socketpair' function.])
Dave Cole331708b2004-08-09 04:51:41 +00003064 AC_MSG_RESULT(yes),
3065 AC_MSG_RESULT(no)
3066)
3067
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003068# check if sockaddr has sa_len member
3069AC_MSG_CHECKING(if sockaddr has sa_len member)
3070AC_TRY_COMPILE([#include <sys/types.h>
3071#include <sys/socket.h>],
3072[struct sockaddr x;
3073x.sa_len = 0;],
3074 AC_MSG_RESULT(yes)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003075 AC_DEFINE(HAVE_SOCKADDR_SA_LEN, 1, [Define if sockaddr has sa_len member]),
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003076 AC_MSG_RESULT(no))
3077
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003078va_list_is_array=no
3079AC_MSG_CHECKING(whether va_list is an array)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003080AC_TRY_COMPILE([
3081#ifdef HAVE_STDARG_PROTOTYPES
3082#include <stdarg.h>
3083#else
3084#include <varargs.h>
3085#endif
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003086], [va_list list1, list2; list1 = list2;], , [
3087 AC_DEFINE(VA_LIST_IS_ARRAY, 1, [Define if a va_list is an array of some kind])
3088 va_list_is_array=yes
3089])
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003090AC_MSG_RESULT($va_list_is_array)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003091
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003092# sigh -- gethostbyname_r is a mess; it can have 3, 5 or 6 arguments :-(
Martin v. Löwis11437992002-04-12 09:54:03 +00003093AH_TEMPLATE(HAVE_GETHOSTBYNAME_R,
3094 [Define this if you have some version of gethostbyname_r()])
3095
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003096AC_CHECK_FUNC(gethostbyname_r, [
3097 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
3098 AC_MSG_CHECKING([gethostbyname_r with 6 args])
3099 OLD_CFLAGS=$CFLAGS
3100 CFLAGS="$CFLAGS $MY_CPPFLAGS $MY_THREAD_CPPFLAGS $MY_CFLAGS"
3101 AC_TRY_COMPILE([
3102# include <netdb.h>
3103 ], [
3104 char *name;
3105 struct hostent *he, *res;
3106 char buffer[2048];
3107 int buflen = 2048;
3108 int h_errnop;
3109
3110 (void) gethostbyname_r(name, he, buffer, buflen, &res, &h_errnop)
3111 ], [
Guido van Rossum8db7d8b1999-03-23 16:40:33 +00003112 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003113 AC_DEFINE(HAVE_GETHOSTBYNAME_R_6_ARG, 1,
3114 [Define this if you have the 6-arg version of gethostbyname_r().])
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003115 AC_MSG_RESULT(yes)
3116 ], [
3117 AC_MSG_RESULT(no)
3118 AC_MSG_CHECKING([gethostbyname_r with 5 args])
3119 AC_TRY_COMPILE([
3120# include <netdb.h>
3121 ], [
3122 char *name;
3123 struct hostent *he;
3124 char buffer[2048];
3125 int buflen = 2048;
3126 int h_errnop;
3127
3128 (void) gethostbyname_r(name, he, buffer, buflen, &h_errnop)
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_5_ARG, 1,
3132 [Define this if you have the 5-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 AC_MSG_CHECKING([gethostbyname_r with 3 args])
3137 AC_TRY_COMPILE([
3138# include <netdb.h>
3139 ], [
3140 char *name;
3141 struct hostent *he;
3142 struct hostent_data data;
3143
3144 (void) gethostbyname_r(name, he, &data);
3145 ], [
Guido van Rossum8db7d8b1999-03-23 16:40:33 +00003146 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003147 AC_DEFINE(HAVE_GETHOSTBYNAME_R_3_ARG, 1,
3148 [Define this if you have the 3-arg version of gethostbyname_r().])
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003149 AC_MSG_RESULT(yes)
3150 ], [
3151 AC_MSG_RESULT(no)
3152 ])
3153 ])
3154 ])
3155 CFLAGS=$OLD_CFLAGS
3156], [
Thomas Wouters3a584202000-08-05 23:28:51 +00003157 AC_CHECK_FUNCS(gethostbyname)
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003158])
3159AC_SUBST(HAVE_GETHOSTBYNAME_R_6_ARG)
3160AC_SUBST(HAVE_GETHOSTBYNAME_R_5_ARG)
3161AC_SUBST(HAVE_GETHOSTBYNAME_R_3_ARG)
Guido van Rossum8db7d8b1999-03-23 16:40:33 +00003162AC_SUBST(HAVE_GETHOSTBYNAME_R)
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003163AC_SUBST(HAVE_GETHOSTBYNAME)
3164
Guido van Rossum627b2d71993-12-24 10:39:16 +00003165# checks for system services
3166# (none yet)
3167
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003168# Linux requires this for correct f.p. operations
Jeremy Hyltonbe28f5b2000-07-27 21:03:04 +00003169AC_CHECK_FUNC(__fpu_control,
3170 [],
3171 [AC_CHECK_LIB(ieee, __fpu_control)
3172])
Guido van Rossum627b2d71993-12-24 10:39:16 +00003173
Guido van Rossum93274221997-05-09 02:42:00 +00003174# Check for --with-fpectl
Guido van Rossum93274221997-05-09 02:42:00 +00003175AC_MSG_CHECKING(for --with-fpectl)
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00003176AC_ARG_WITH(fpectl,
Matthias Klosec80c93f2010-04-24 17:04:35 +00003177 AC_HELP_STRING([--with-fpectl], [enable SIGFPE catching]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003178[
Guido van Rossum93274221997-05-09 02:42:00 +00003179if test "$withval" != no
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003180then
3181 AC_DEFINE(WANT_SIGFPE_HANDLER, 1,
3182 [Define if you want SIGFPE handled (see Include/pyfpe.h).])
3183 AC_MSG_RESULT(yes)
Guido van Rossum93274221997-05-09 02:42:00 +00003184else AC_MSG_RESULT(no)
Guido van Rossumef2255b2000-03-10 22:30:29 +00003185fi],
3186[AC_MSG_RESULT(no)])
Guido van Rossum93274221997-05-09 02:42:00 +00003187
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003188# check for --with-libm=...
3189AC_SUBST(LIBM)
Guido van Rossum4b6b5791996-09-09 20:09:34 +00003190case $ac_sys_system in
Guido van Rossum3dc0a512000-10-05 18:00:06 +00003191Darwin) ;;
Guido van Rossum4b6b5791996-09-09 20:09:34 +00003192*) LIBM=-lm
3193esac
Guido van Rossum93274221997-05-09 02:42:00 +00003194AC_MSG_CHECKING(for --with-libm=STRING)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003195AC_ARG_WITH(libm,
Matthias Klosec80c93f2010-04-24 17:04:35 +00003196 AC_HELP_STRING([--with-libm=STRING], [math library]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003197[
Guido van Rossum93274221997-05-09 02:42:00 +00003198if test "$withval" = no
3199then LIBM=
3200 AC_MSG_RESULT(force LIBM empty)
3201elif test "$withval" != yes
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003202then LIBM=$withval
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003203 AC_MSG_RESULT(set LIBM="$withval")
3204else AC_MSG_ERROR([proper usage is --with-libm=STRING])
Guido van Rossum93274221997-05-09 02:42:00 +00003205fi],
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003206[AC_MSG_RESULT(default LIBM="$LIBM")])
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003207
3208# check for --with-libc=...
3209AC_SUBST(LIBC)
Guido van Rossum93274221997-05-09 02:42:00 +00003210AC_MSG_CHECKING(for --with-libc=STRING)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003211AC_ARG_WITH(libc,
Matthias Klosec80c93f2010-04-24 17:04:35 +00003212 AC_HELP_STRING([--with-libc=STRING], [C library]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003213[
Guido van Rossum93274221997-05-09 02:42:00 +00003214if test "$withval" = no
3215then LIBC=
3216 AC_MSG_RESULT(force LIBC empty)
3217elif test "$withval" != yes
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003218then LIBC=$withval
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003219 AC_MSG_RESULT(set LIBC="$withval")
3220else AC_MSG_ERROR([proper usage is --with-libc=STRING])
Guido van Rossum93274221997-05-09 02:42:00 +00003221fi],
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003222[AC_MSG_RESULT(default LIBC="$LIBC")])
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003223
Mark Dickinsonb08a53a2009-04-16 19:52:09 +00003224# **************************************************
3225# * Check for various properties of floating point *
3226# **************************************************
Christian Heimes81ee3ef2008-05-04 22:42:01 +00003227
Mark Dickinsonb08a53a2009-04-16 19:52:09 +00003228AC_MSG_CHECKING(whether C doubles are little-endian IEEE 754 binary64)
3229AC_CACHE_VAL(ac_cv_little_endian_double, [
3230AC_TRY_RUN([
3231#include <string.h>
3232int main() {
3233 double x = 9006104071832581.0;
3234 if (memcmp(&x, "\x05\x04\x03\x02\x01\xff\x3f\x43", 8) == 0)
3235 return 0;
3236 else
3237 return 1;
3238}
3239],
3240ac_cv_little_endian_double=yes,
3241ac_cv_little_endian_double=no,
3242ac_cv_little_endian_double=no)])
3243AC_MSG_RESULT($ac_cv_little_endian_double)
3244if test "$ac_cv_little_endian_double" = yes
3245then
3246 AC_DEFINE(DOUBLE_IS_LITTLE_ENDIAN_IEEE754, 1,
3247 [Define if C doubles are 64-bit IEEE 754 binary format, stored
3248 with the least significant byte first])
3249fi
3250
3251AC_MSG_CHECKING(whether C doubles are big-endian IEEE 754 binary64)
3252AC_CACHE_VAL(ac_cv_big_endian_double, [
3253AC_TRY_RUN([
3254#include <string.h>
3255int main() {
3256 double x = 9006104071832581.0;
3257 if (memcmp(&x, "\x43\x3f\xff\x01\x02\x03\x04\x05", 8) == 0)
3258 return 0;
3259 else
3260 return 1;
3261}
3262],
3263ac_cv_big_endian_double=yes,
3264ac_cv_big_endian_double=no,
3265ac_cv_big_endian_double=no)])
3266AC_MSG_RESULT($ac_cv_big_endian_double)
3267if test "$ac_cv_big_endian_double" = yes
3268then
3269 AC_DEFINE(DOUBLE_IS_BIG_ENDIAN_IEEE754, 1,
3270 [Define if C doubles are 64-bit IEEE 754 binary format, stored
3271 with the most significant byte first])
3272fi
3273
3274# Some ARM platforms use a mixed-endian representation for doubles.
3275# While Python doesn't currently have full support for these platforms
3276# (see e.g., issue 1762561), we can at least make sure that float <-> string
3277# conversions work.
3278AC_MSG_CHECKING(whether C doubles are ARM mixed-endian IEEE 754 binary64)
3279AC_CACHE_VAL(ac_cv_mixed_endian_double, [
3280AC_TRY_RUN([
3281#include <string.h>
3282int main() {
3283 double x = 9006104071832581.0;
3284 if (memcmp(&x, "\x01\xff\x3f\x43\x05\x04\x03\x02", 8) == 0)
3285 return 0;
3286 else
3287 return 1;
3288}
3289],
3290ac_cv_mixed_endian_double=yes,
3291ac_cv_mixed_endian_double=no,
3292ac_cv_mixed_endian_double=no)])
3293AC_MSG_RESULT($ac_cv_mixed_endian_double)
3294if test "$ac_cv_mixed_endian_double" = yes
3295then
3296 AC_DEFINE(DOUBLE_IS_ARM_MIXED_ENDIAN_IEEE754, 1,
3297 [Define if C doubles are 64-bit IEEE 754 binary format, stored
3298 in ARM mixed-endian order (byte order 45670123)])
3299fi
3300
Mark Dickinson7abf8d42009-04-18 20:17:52 +00003301# The short float repr introduced in Python 3.1 requires the
3302# correctly-rounded string <-> double conversion functions from
3303# Python/dtoa.c, which in turn require that the FPU uses 53-bit
3304# rounding; this is a problem on x86, where the x87 FPU has a default
Mark Dickinsonf4243f62009-11-15 13:47:27 +00003305# rounding precision of 64 bits. For gcc/x86, we can fix this by
Mark Dickinson7abf8d42009-04-18 20:17:52 +00003306# using inline assembler to get and set the x87 FPU control word.
Mark Dickinsonf4243f62009-11-15 13:47:27 +00003307
3308# This inline assembler syntax may also work for suncc and icc,
3309# so we try it on all platforms.
3310
3311AC_MSG_CHECKING(whether we can use gcc inline assembler to get and set x87 control word)
3312AC_TRY_COMPILE([], [
3313 unsigned short cw;
3314 __asm__ __volatile__ ("fnstcw %0" : "=m" (cw));
3315 __asm__ __volatile__ ("fldcw %0" : : "m" (cw));
3316],
3317[have_gcc_asm_for_x87=yes], [have_gcc_asm_for_x87=no])
3318AC_MSG_RESULT($have_gcc_asm_for_x87)
3319if test "$have_gcc_asm_for_x87" = yes
Mark Dickinsonb08a53a2009-04-16 19:52:09 +00003320then
Mark Dickinsonf4243f62009-11-15 13:47:27 +00003321 AC_DEFINE(HAVE_GCC_ASM_FOR_X87, 1,
3322 [Define if we can use gcc inline assembler to get and set x87 control word])
Mark Dickinsonb08a53a2009-04-16 19:52:09 +00003323fi
Christian Heimes81ee3ef2008-05-04 22:42:01 +00003324
Mark Dickinson3dc7c6a2009-01-04 15:09:02 +00003325# Detect whether system arithmetic is subject to x87-style double
3326# rounding issues. The result of this test has little meaning on non
3327# IEEE 754 platforms. On IEEE 754, test should return 1 if rounding
3328# mode is round-to-nearest and double rounding issues are present, and
3329# 0 otherwise. See http://bugs.python.org/issue2937 for more info.
3330AC_MSG_CHECKING(for x87-style double rounding)
Mark Dickinsonb08a53a2009-04-16 19:52:09 +00003331# $BASECFLAGS may affect the result
3332ac_save_cc="$CC"
3333CC="$CC $BASECFLAGS"
Mark Dickinson3dc7c6a2009-01-04 15:09:02 +00003334AC_TRY_RUN([
3335#include <stdlib.h>
3336#include <math.h>
3337int main() {
3338 volatile double x, y, z;
3339 /* 1./(1-2**-53) -> 1+2**-52 (correct), 1.0 (double rounding) */
3340 x = 0.99999999999999989; /* 1-2**-53 */
3341 y = 1./x;
3342 if (y != 1.)
3343 exit(0);
3344 /* 1e16+2.99999 -> 1e16+2. (correct), 1e16+4. (double rounding) */
3345 x = 1e16;
3346 y = 2.99999;
3347 z = x + y;
3348 if (z != 1e16+4.)
3349 exit(0);
3350 /* both tests show evidence of double rounding */
3351 exit(1);
3352}
3353],
3354ac_cv_x87_double_rounding=no,
3355ac_cv_x87_double_rounding=yes,
Mark Dickinsonb08a53a2009-04-16 19:52:09 +00003356ac_cv_x87_double_rounding=no)
3357CC="$ac_save_cc"
Mark Dickinson3dc7c6a2009-01-04 15:09:02 +00003358AC_MSG_RESULT($ac_cv_x87_double_rounding)
3359if test "$ac_cv_x87_double_rounding" = yes
3360then
3361 AC_DEFINE(X87_DOUBLE_ROUNDING, 1,
3362 [Define if arithmetic is subject to x87-style double rounding issue])
3363fi
3364
Mark Dickinsonb08a53a2009-04-16 19:52:09 +00003365# ************************************
3366# * Check for mathematical functions *
3367# ************************************
3368
3369LIBS_SAVE=$LIBS
3370LIBS="$LIBS $LIBM"
3371
Christian Heimes81ee3ef2008-05-04 22:42:01 +00003372# On FreeBSD 6.2, it appears that tanh(-0.) returns 0. instead of
3373# -0. on some architectures.
3374AC_MSG_CHECKING(whether tanh preserves the sign of zero)
3375AC_CACHE_VAL(ac_cv_tanh_preserves_zero_sign, [
3376AC_TRY_RUN([
3377#include <math.h>
3378#include <stdlib.h>
3379int main() {
3380 /* return 0 if either negative zeros don't exist
3381 on this platform or if negative zeros exist
3382 and tanh(-0.) == -0. */
3383 if (atan2(0., -1.) == atan2(-0., -1.) ||
3384 atan2(tanh(-0.), -1.) == atan2(-0., -1.)) exit(0);
3385 else exit(1);
3386}
3387],
3388ac_cv_tanh_preserves_zero_sign=yes,
3389ac_cv_tanh_preserves_zero_sign=no,
3390ac_cv_tanh_preserves_zero_sign=no)])
3391AC_MSG_RESULT($ac_cv_tanh_preserves_zero_sign)
3392if test "$ac_cv_tanh_preserves_zero_sign" = yes
3393then
3394 AC_DEFINE(TANH_PRESERVES_ZERO_SIGN, 1,
3395 [Define if tanh(-0.) is -0., or if platform doesn't have signed zeros])
3396fi
3397
Mark Dickinson9c113362009-09-05 10:36:23 +00003398AC_CHECK_FUNCS([acosh asinh atanh copysign erf erfc expm1 finite gamma])
3399AC_CHECK_FUNCS([hypot lgamma log1p round tgamma])
Mark Dickinson3dc7c6a2009-01-04 15:09:02 +00003400AC_CHECK_DECLS([isinf, isnan, isfinite], [], [], [[#include <math.h>]])
Christian Heimes99170a52007-12-19 02:07:34 +00003401
Guido van Rossumaf5b83e1995-01-04 19:02:35 +00003402LIBS=$LIBS_SAVE
3403
Mark Dickinsona614f042009-11-28 12:48:43 +00003404# For multiprocessing module, check that sem_open
3405# actually works. For FreeBSD versions <= 7.2,
3406# the kernel module that provides POSIX semaphores
3407# isn't loaded by default, so an attempt to call
3408# sem_open results in a 'Signal 12' error.
3409AC_MSG_CHECKING(whether POSIX semaphores are enabled)
3410AC_CACHE_VAL(ac_cv_posix_semaphores_enabled,
3411AC_TRY_RUN([
3412#include <unistd.h>
3413#include <fcntl.h>
3414#include <stdio.h>
3415#include <semaphore.h>
3416#include <sys/stat.h>
3417
3418int main(void) {
3419 sem_t *a = sem_open("/autoconf", O_CREAT, S_IRUSR|S_IWUSR, 0);
3420 if (a == SEM_FAILED) {
3421 perror("sem_open");
3422 return 1;
3423 }
3424 sem_close(a);
Mark Dickinsonba79b352009-12-13 21:10:57 +00003425 sem_unlink("/autoconf");
Mark Dickinsona614f042009-11-28 12:48:43 +00003426 return 0;
3427}
3428], ac_cv_posix_semaphores_enabled=yes,
3429 ac_cv_posix_semaphores_enabled=no,
3430 ac_cv_posix_semaphores_enabled=yes)
3431)
3432AC_MSG_RESULT($ac_cv_posix_semaphores_enabled)
3433if test $ac_cv_posix_semaphores_enabled = no
3434then
3435 AC_DEFINE(POSIX_SEMAPHORES_NOT_ENABLED, 1,
3436 [Define if POSIX semaphores aren't enabled on your system])
3437fi
3438
Mark Dickinson10683072009-04-18 21:18:19 +00003439# Multiprocessing check for broken sem_getvalue
3440AC_MSG_CHECKING(for broken sem_getvalue)
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00003441AC_CACHE_VAL(ac_cv_broken_sem_getvalue,
Mark Dickinson10683072009-04-18 21:18:19 +00003442AC_TRY_RUN([
3443#include <unistd.h>
3444#include <fcntl.h>
3445#include <stdio.h>
3446#include <semaphore.h>
3447#include <sys/stat.h>
3448
3449int main(void){
Mark Dickinsonba79b352009-12-13 21:10:57 +00003450 sem_t *a = sem_open("/autocftw", O_CREAT, S_IRUSR|S_IWUSR, 0);
Mark Dickinson10683072009-04-18 21:18:19 +00003451 int count;
3452 int res;
3453 if(a==SEM_FAILED){
3454 perror("sem_open");
3455 return 1;
3456
3457 }
3458 res = sem_getvalue(a, &count);
3459 sem_close(a);
Mark Dickinsonba79b352009-12-13 21:10:57 +00003460 sem_unlink("/autocftw");
Mark Dickinson10683072009-04-18 21:18:19 +00003461 return res==-1 ? 1 : 0;
3462}
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00003463], ac_cv_broken_sem_getvalue=no,
3464 ac_cv_broken_sem_getvalue=yes,
3465 ac_cv_broken_sem_getvalue=yes)
Mark Dickinson10683072009-04-18 21:18:19 +00003466)
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00003467AC_MSG_RESULT($ac_cv_broken_sem_getvalue)
3468if test $ac_cv_broken_sem_getvalue = yes
3469then
3470 AC_DEFINE(HAVE_BROKEN_SEM_GETVALUE, 1,
3471 [define to 1 if your sem_getvalue is broken.])
3472fi
Mark Dickinson10683072009-04-18 21:18:19 +00003473
Mark Dickinsonbd792642009-03-18 20:06:12 +00003474# determine what size digit to use for Python's longs
3475AC_MSG_CHECKING([digit size for Python's longs])
3476AC_ARG_ENABLE(big-digits,
3477AC_HELP_STRING([--enable-big-digits@<:@=BITS@:>@],[use big digits for Python longs [[BITS=30]]]),
3478[case $enable_big_digits in
3479yes)
3480 enable_big_digits=30 ;;
3481no)
3482 enable_big_digits=15 ;;
3483[15|30])
3484 ;;
3485*)
3486 AC_MSG_ERROR([bad value $enable_big_digits for --enable-big-digits; value should be 15 or 30]) ;;
3487esac
3488AC_MSG_RESULT($enable_big_digits)
3489AC_DEFINE_UNQUOTED(PYLONG_BITS_IN_DIGIT, $enable_big_digits, [Define as the preferred size in bits of long digits])
3490],
3491[AC_MSG_RESULT(no value specified)])
3492
Guido van Rossumef2255b2000-03-10 22:30:29 +00003493# check for wchar.h
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003494AC_CHECK_HEADER(wchar.h, [
3495 AC_DEFINE(HAVE_WCHAR_H, 1,
3496 [Define if the compiler provides a wchar.h header file.])
3497 wchar_h="yes"
3498],
Guido van Rossumef2255b2000-03-10 22:30:29 +00003499wchar_h="no"
3500)
3501
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003502# determine wchar_t size
3503if test "$wchar_h" = yes
3504then
Guido van Rossum67b26592001-10-20 14:21:45 +00003505 AC_CHECK_SIZEOF(wchar_t, 4, [#include <wchar.h>])
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003506fi
3507
Martin v. Löwisfa3bdea2003-09-04 18:50:54 +00003508AC_MSG_CHECKING(for UCS-4 tcl)
3509have_ucs4_tcl=no
3510AC_TRY_COMPILE([
3511#include <tcl.h>
3512#if TCL_UTF_MAX != 6
3513# error "NOT UCS4_TCL"
3514#endif], [], [
3515 AC_DEFINE(HAVE_UCS4_TCL, 1, [Define this if you have tcl and TCL_UTF_MAX==6])
3516 have_ucs4_tcl=yes
3517])
3518AC_MSG_RESULT($have_ucs4_tcl)
3519
Marc-André Lemburgd7160f82003-09-22 11:14:40 +00003520# check whether wchar_t is signed or not
3521if test "$wchar_h" = yes
3522then
3523 # check whether wchar_t is signed or not
3524 AC_MSG_CHECKING(whether wchar_t is signed)
3525 AC_CACHE_VAL(ac_cv_wchar_t_signed, [
3526 AC_TRY_RUN([
3527 #include <wchar.h>
3528 int main()
3529 {
Thomas Wouters49fd7fa2006-04-21 10:40:58 +00003530 /* Success: exit code 0 */
3531 exit((((wchar_t) -1) < ((wchar_t) 0)) ? 0 : 1);
Marc-André Lemburgd7160f82003-09-22 11:14:40 +00003532 }
3533 ],
3534 ac_cv_wchar_t_signed=yes,
3535 ac_cv_wchar_t_signed=no,
3536 ac_cv_wchar_t_signed=yes)])
3537 AC_MSG_RESULT($ac_cv_wchar_t_signed)
3538fi
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003539
Georg Brandl52d168a2008-01-07 18:10:24 +00003540AC_MSG_CHECKING(what type to use for str)
3541AC_ARG_WITH(wide-unicode,
Matthias Klosec80c93f2010-04-24 17:04:35 +00003542 AC_HELP_STRING([--with-wide-unicode], [Use 4-byte Unicode characters (default is 2 bytes)]),
Georg Brandl52d168a2008-01-07 18:10:24 +00003543[
3544if test "$withval" != no
3545then unicode_size="4"
3546else unicode_size="2"
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003547fi
Georg Brandl52d168a2008-01-07 18:10:24 +00003548],
3549[
3550case "$have_ucs4_tcl" in
3551 yes) unicode_size="4" ;;
3552 *) unicode_size="2" ;;
3553esac
3554])
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003555
Martin v. Löwis0036cba2002-04-12 09:58:45 +00003556AH_TEMPLATE(Py_UNICODE_SIZE,
3557 [Define as the size of the unicode type.])
Georg Brandl52d168a2008-01-07 18:10:24 +00003558case "$unicode_size" in
3559 4) AC_DEFINE(Py_UNICODE_SIZE, 4) ;;
3560 *) AC_DEFINE(Py_UNICODE_SIZE, 2) ;;
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003561esac
3562
Martin v. Löwis11437992002-04-12 09:54:03 +00003563AH_TEMPLATE(PY_UNICODE_TYPE,
3564 [Define as the integral type used for Unicode representation.])
Martin v. Löwis0036cba2002-04-12 09:58:45 +00003565
Georg Brandl52d168a2008-01-07 18:10:24 +00003566# wchar_t is only usable if it maps to an unsigned type
3567if test "$unicode_size" = "$ac_cv_sizeof_wchar_t" \
Matthias Klose7dbeed72004-12-24 08:22:17 +00003568 -a "$ac_cv_wchar_t_signed" = "no"
Georg Brandl52d168a2008-01-07 18:10:24 +00003569then
3570 PY_UNICODE_TYPE="wchar_t"
3571 AC_DEFINE(HAVE_USABLE_WCHAR_T, 1,
3572 [Define if you have a useable wchar_t type defined in wchar.h; useable
3573 means wchar_t must be an unsigned type with at least 16 bits. (see
3574 Include/unicodeobject.h).])
3575 AC_DEFINE(PY_UNICODE_TYPE,wchar_t)
3576elif test "$ac_cv_sizeof_short" = "$unicode_size"
3577then
3578 PY_UNICODE_TYPE="unsigned short"
3579 AC_DEFINE(PY_UNICODE_TYPE,unsigned short)
3580elif test "$ac_cv_sizeof_long" = "$unicode_size"
3581then
3582 PY_UNICODE_TYPE="unsigned long"
3583 AC_DEFINE(PY_UNICODE_TYPE,unsigned long)
3584else
3585 PY_UNICODE_TYPE="no type found"
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003586fi
Georg Brandl52d168a2008-01-07 18:10:24 +00003587AC_MSG_RESULT($PY_UNICODE_TYPE)
Guido van Rossumef2255b2000-03-10 22:30:29 +00003588
3589# check for endianness
3590AC_C_BIGENDIAN
3591
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00003592# Check whether right shifting a negative integer extends the sign bit
3593# or fills with zeros (like the Cray J90, according to Tim Peters).
3594AC_MSG_CHECKING(whether right shift extends the sign bit)
Vladimir Marangozova6180282000-07-12 05:05:06 +00003595AC_CACHE_VAL(ac_cv_rshift_extends_sign, [
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00003596AC_TRY_RUN([
3597int main()
3598{
Vladimir Marangozova6180282000-07-12 05:05:06 +00003599 exit(((-1)>>3 == -1) ? 0 : 1);
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00003600}
Guido van Rossum3065c942001-09-17 04:03:14 +00003601],
3602ac_cv_rshift_extends_sign=yes,
3603ac_cv_rshift_extends_sign=no,
3604ac_cv_rshift_extends_sign=yes)])
Vladimir Marangozova6180282000-07-12 05:05:06 +00003605AC_MSG_RESULT($ac_cv_rshift_extends_sign)
3606if test "$ac_cv_rshift_extends_sign" = no
3607then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003608 AC_DEFINE(SIGNED_RIGHT_SHIFT_ZERO_FILLS, 1,
3609 [Define if i>>j for signed int i does not extend the sign bit
3610 when i < 0])
Vladimir Marangozova6180282000-07-12 05:05:06 +00003611fi
3612
Guido van Rossumcadfaec2001-01-05 14:45:49 +00003613# check for getc_unlocked and related locking functions
3614AC_MSG_CHECKING(for getc_unlocked() and friends)
3615AC_CACHE_VAL(ac_cv_have_getc_unlocked, [
3616AC_TRY_LINK([#include <stdio.h>],[
3617 FILE *f = fopen("/dev/null", "r");
3618 flockfile(f);
3619 getc_unlocked(f);
3620 funlockfile(f);
3621], ac_cv_have_getc_unlocked=yes, ac_cv_have_getc_unlocked=no)])
3622AC_MSG_RESULT($ac_cv_have_getc_unlocked)
3623if test "$ac_cv_have_getc_unlocked" = yes
3624then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003625 AC_DEFINE(HAVE_GETC_UNLOCKED, 1,
3626 [Define this if you have flockfile(), getc_unlocked(), and funlockfile()])
Guido van Rossumcadfaec2001-01-05 14:45:49 +00003627fi
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00003628
Neal Norwitzfe8e3d92006-01-07 21:07:20 +00003629# check where readline lives
Martin v. Löwis82bca632006-02-10 20:49:30 +00003630# save the value of LIBS so we don't actually link Python with readline
3631LIBS_no_readline=$LIBS
Gregory P. Smith18820942008-09-07 06:24:49 +00003632
3633# On some systems we need to link readline to a termcap compatible
3634# library. NOTE: Keep the precedence of listed libraries synchronised
3635# with setup.py.
3636py_cv_lib_readline=no
3637AC_MSG_CHECKING([how to link readline libs])
3638for py_libtermcap in "" ncursesw ncurses curses termcap; do
3639 if test -z "$py_libtermcap"; then
3640 READLINE_LIBS="-lreadline"
3641 else
3642 READLINE_LIBS="-lreadline -l$py_libtermcap"
3643 fi
3644 LIBS="$READLINE_LIBS $LIBS_no_readline"
3645 AC_LINK_IFELSE(
3646 [AC_LANG_CALL([],[readline])],
3647 [py_cv_lib_readline=yes])
3648 if test $py_cv_lib_readline = yes; then
3649 break
3650 fi
3651done
3652# Uncomment this line if you want to use READINE_LIBS in Makefile or scripts
3653#AC_SUBST([READLINE_LIBS])
Gregory P. Smith97515912008-09-07 19:23:19 +00003654if test $py_cv_lib_readline = no; then
Gregory P. Smith18820942008-09-07 06:24:49 +00003655 AC_MSG_RESULT([none])
3656else
3657 AC_MSG_RESULT([$READLINE_LIBS])
3658 AC_DEFINE(HAVE_LIBREADLINE, 1,
3659 [Define if you have the readline library (-lreadline).])
Neal Norwitzfe8e3d92006-01-07 21:07:20 +00003660fi
3661
Michael W. Hudson30ea2f22004-07-07 17:44:12 +00003662# check for readline 2.1
3663AC_CHECK_LIB(readline, rl_callback_handler_install,
3664 AC_DEFINE(HAVE_RL_CALLBACK, 1,
Gregory P. Smith18820942008-09-07 06:24:49 +00003665 [Define if you have readline 2.1]), ,$READLINE_LIBS)
Michael W. Hudson30ea2f22004-07-07 17:44:12 +00003666
Guido van Rossumfaf5e4d2002-12-30 16:25:41 +00003667# check for readline 2.2
3668AC_TRY_CPP([#include <readline/readline.h>],
3669have_readline=yes, have_readline=no)
3670if test $have_readline = yes
3671then
3672 AC_EGREP_HEADER([extern int rl_completion_append_character;],
3673 [readline/readline.h],
3674 AC_DEFINE(HAVE_RL_COMPLETION_APPEND_CHARACTER, 1,
3675 [Define if you have readline 2.2]), )
Antoine Pitroud5131772009-10-26 19:22:14 +00003676 AC_EGREP_HEADER([extern int rl_completion_suppress_append;],
3677 [readline/readline.h],
3678 AC_DEFINE(HAVE_RL_COMPLETION_SUPPRESS_APPEND, 1,
3679 [Define if you have rl_completion_suppress_append]), )
Guido van Rossumfaf5e4d2002-12-30 16:25:41 +00003680fi
3681
Martin v. Löwis0daad592001-09-30 21:09:59 +00003682# check for readline 4.0
3683AC_CHECK_LIB(readline, rl_pre_input_hook,
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003684 AC_DEFINE(HAVE_RL_PRE_INPUT_HOOK, 1,
Gregory P. Smith18820942008-09-07 06:24:49 +00003685 [Define if you have readline 4.0]), ,$READLINE_LIBS)
Martin v. Löwis0daad592001-09-30 21:09:59 +00003686
Thomas Wouters89d996e2007-09-08 17:39:28 +00003687# also in 4.0
3688AC_CHECK_LIB(readline, rl_completion_display_matches_hook,
3689 AC_DEFINE(HAVE_RL_COMPLETION_DISPLAY_MATCHES_HOOK, 1,
Gregory P. Smith18820942008-09-07 06:24:49 +00003690 [Define if you have readline 4.0]), ,$READLINE_LIBS)
Thomas Wouters89d996e2007-09-08 17:39:28 +00003691
Guido van Rossum353ae582001-07-10 16:45:32 +00003692# check for readline 4.2
3693AC_CHECK_LIB(readline, rl_completion_matches,
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003694 AC_DEFINE(HAVE_RL_COMPLETION_MATCHES, 1,
Gregory P. Smith18820942008-09-07 06:24:49 +00003695 [Define if you have readline 4.2]), ,$READLINE_LIBS)
Guido van Rossum353ae582001-07-10 16:45:32 +00003696
Michael W. Hudson30ea2f22004-07-07 17:44:12 +00003697# also in readline 4.2
3698AC_TRY_CPP([#include <readline/readline.h>],
3699have_readline=yes, have_readline=no)
3700if test $have_readline = yes
3701then
3702 AC_EGREP_HEADER([extern int rl_catch_signals;],
3703 [readline/readline.h],
3704 AC_DEFINE(HAVE_RL_CATCH_SIGNAL, 1,
3705 [Define if you can turn off readline's signal handling.]), )
3706fi
3707
Martin v. Löwis82bca632006-02-10 20:49:30 +00003708# End of readline checks: restore LIBS
3709LIBS=$LIBS_no_readline
3710
Thomas Wouterse38b2f12001-07-11 22:35:31 +00003711AC_MSG_CHECKING(for broken nice())
3712AC_CACHE_VAL(ac_cv_broken_nice, [
3713AC_TRY_RUN([
3714int main()
3715{
3716 int val1 = nice(1);
3717 if (val1 != -1 && val1 == nice(2))
3718 exit(0);
3719 exit(1);
3720}
Guido van Rossum3065c942001-09-17 04:03:14 +00003721],
3722ac_cv_broken_nice=yes,
3723ac_cv_broken_nice=no,
3724ac_cv_broken_nice=no)])
Thomas Wouterse38b2f12001-07-11 22:35:31 +00003725AC_MSG_RESULT($ac_cv_broken_nice)
3726if test "$ac_cv_broken_nice" = yes
3727then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003728 AC_DEFINE(HAVE_BROKEN_NICE, 1,
3729 [Define if nice() returns success/failure instead of the new priority.])
Thomas Wouterse38b2f12001-07-11 22:35:31 +00003730fi
3731
Nicholas Bastine62c5c82004-03-21 23:45:42 +00003732AC_MSG_CHECKING(for broken poll())
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00003733AC_CACHE_VAL(ac_cv_broken_poll,
Nicholas Bastine62c5c82004-03-21 23:45:42 +00003734AC_TRY_RUN([
3735#include <poll.h>
3736
Alexandre Vassalottiaee170a2009-07-17 06:24:33 +00003737int main()
3738{
Nicholas Bastine62c5c82004-03-21 23:45:42 +00003739 struct pollfd poll_struct = { 42, POLLIN|POLLPRI|POLLOUT, 0 };
Alexandre Vassalottiaee170a2009-07-17 06:24:33 +00003740 int poll_test;
3741
Nicholas Bastine62c5c82004-03-21 23:45:42 +00003742 close (42);
3743
Alexandre Vassalottiaee170a2009-07-17 06:24:33 +00003744 poll_test = poll(&poll_struct, 1, 0);
Nicholas Bastine62c5c82004-03-21 23:45:42 +00003745 if (poll_test < 0)
Alexandre Vassalottiaee170a2009-07-17 06:24:33 +00003746 return 0;
Nicholas Bastine62c5c82004-03-21 23:45:42 +00003747 else if (poll_test == 0 && poll_struct.revents != POLLNVAL)
Alexandre Vassalottiaee170a2009-07-17 06:24:33 +00003748 return 0;
Nicholas Bastine62c5c82004-03-21 23:45:42 +00003749 else
Alexandre Vassalottiaee170a2009-07-17 06:24:33 +00003750 return 1;
3751}
Nicholas Bastine62c5c82004-03-21 23:45:42 +00003752],
3753ac_cv_broken_poll=yes,
3754ac_cv_broken_poll=no,
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00003755ac_cv_broken_poll=no))
Nicholas Bastine62c5c82004-03-21 23:45:42 +00003756AC_MSG_RESULT($ac_cv_broken_poll)
3757if test "$ac_cv_broken_poll" = yes
3758then
3759 AC_DEFINE(HAVE_BROKEN_POLL, 1,
3760 [Define if poll() sets errno on invalid file descriptors.])
3761fi
3762
Brett Cannon43802422005-02-10 20:48:03 +00003763# Before we can test tzset, we need to check if struct tm has a tm_zone
3764# (which is not required by ISO C or UNIX spec) and/or if we support
3765# tzname[]
3766AC_STRUCT_TIMEZONE
Nicholas Bastine62c5c82004-03-21 23:45:42 +00003767
Brett Cannon43802422005-02-10 20:48:03 +00003768# check tzset(3) exists and works like we expect it to
Guido van Rossumd11b62e2003-03-14 21:51:36 +00003769AC_MSG_CHECKING(for working tzset())
3770AC_CACHE_VAL(ac_cv_working_tzset, [
3771AC_TRY_RUN([
3772#include <stdlib.h>
3773#include <time.h>
Brett Cannon18367812003-09-19 00:59:16 +00003774#include <string.h>
Brett Cannon43802422005-02-10 20:48:03 +00003775
3776#if HAVE_TZNAME
3777extern char *tzname[];
3778#endif
3779
Guido van Rossumd11b62e2003-03-14 21:51:36 +00003780int main()
3781{
Brett Cannon18367812003-09-19 00:59:16 +00003782 /* Note that we need to ensure that not only does tzset(3)
3783 do 'something' with localtime, but it works as documented
3784 in the library reference and as expected by the test suite.
Brett Cannon43802422005-02-10 20:48:03 +00003785 This includes making sure that tzname is set properly if
3786 tm->tm_zone does not exist since it is the alternative way
3787 of getting timezone info.
Brett Cannon18367812003-09-19 00:59:16 +00003788
3789 Red Hat 6.2 doesn't understand the southern hemisphere
Brett Cannon43802422005-02-10 20:48:03 +00003790 after New Year's Day.
Brett Cannon18367812003-09-19 00:59:16 +00003791 */
3792
Brett Cannon43802422005-02-10 20:48:03 +00003793 time_t groundhogday = 1044144000; /* GMT-based */
Brett Cannon18367812003-09-19 00:59:16 +00003794 time_t midyear = groundhogday + (365 * 24 * 3600 / 2);
3795
Neal Norwitz7f2588c2003-04-11 15:35:53 +00003796 putenv("TZ=UTC+0");
Guido van Rossumd11b62e2003-03-14 21:51:36 +00003797 tzset();
Brett Cannon18367812003-09-19 00:59:16 +00003798 if (localtime(&groundhogday)->tm_hour != 0)
3799 exit(1);
Brett Cannon43802422005-02-10 20:48:03 +00003800#if HAVE_TZNAME
3801 /* For UTC, tzname[1] is sometimes "", sometimes " " */
3802 if (strcmp(tzname[0], "UTC") ||
3803 (tzname[1][0] != 0 && tzname[1][0] != ' '))
3804 exit(1);
3805#endif
Brett Cannon18367812003-09-19 00:59:16 +00003806
Neal Norwitz7f2588c2003-04-11 15:35:53 +00003807 putenv("TZ=EST+5EDT,M4.1.0,M10.5.0");
Guido van Rossumd11b62e2003-03-14 21:51:36 +00003808 tzset();
Brett Cannon18367812003-09-19 00:59:16 +00003809 if (localtime(&groundhogday)->tm_hour != 19)
Guido van Rossumd11b62e2003-03-14 21:51:36 +00003810 exit(1);
Brett Cannon43802422005-02-10 20:48:03 +00003811#if HAVE_TZNAME
3812 if (strcmp(tzname[0], "EST") || strcmp(tzname[1], "EDT"))
3813 exit(1);
3814#endif
Brett Cannon18367812003-09-19 00:59:16 +00003815
3816 putenv("TZ=AEST-10AEDT-11,M10.5.0,M3.5.0");
3817 tzset();
3818 if (localtime(&groundhogday)->tm_hour != 11)
3819 exit(1);
Brett Cannon43802422005-02-10 20:48:03 +00003820#if HAVE_TZNAME
3821 if (strcmp(tzname[0], "AEST") || strcmp(tzname[1], "AEDT"))
3822 exit(1);
3823#endif
3824
3825#if HAVE_STRUCT_TM_TM_ZONE
Brett Cannon18367812003-09-19 00:59:16 +00003826 if (strcmp(localtime(&groundhogday)->tm_zone, "AEDT"))
3827 exit(1);
3828 if (strcmp(localtime(&midyear)->tm_zone, "AEST"))
3829 exit(1);
Brett Cannon43802422005-02-10 20:48:03 +00003830#endif
Brett Cannon18367812003-09-19 00:59:16 +00003831
Guido van Rossumd11b62e2003-03-14 21:51:36 +00003832 exit(0);
3833}
3834],
3835ac_cv_working_tzset=yes,
3836ac_cv_working_tzset=no,
3837ac_cv_working_tzset=no)])
3838AC_MSG_RESULT($ac_cv_working_tzset)
3839if test "$ac_cv_working_tzset" = yes
3840then
3841 AC_DEFINE(HAVE_WORKING_TZSET, 1,
3842 [Define if tzset() actually switches the local timezone in a meaningful way.])
3843fi
3844
Martin v. Löwis94717ed2002-09-09 14:24:16 +00003845# Look for subsecond timestamps in struct stat
3846AC_MSG_CHECKING(for tv_nsec in struct stat)
3847AC_CACHE_VAL(ac_cv_stat_tv_nsec,
3848AC_TRY_COMPILE([#include <sys/stat.h>], [
3849struct stat st;
3850st.st_mtim.tv_nsec = 1;
3851],
Martin v. Löwisa32c9942002-09-09 16:17:47 +00003852ac_cv_stat_tv_nsec=yes,
Martin v. Löwis94717ed2002-09-09 14:24:16 +00003853ac_cv_stat_tv_nsec=no,
3854ac_cv_stat_tv_nsec=no))
3855AC_MSG_RESULT($ac_cv_stat_tv_nsec)
3856if test "$ac_cv_stat_tv_nsec" = yes
3857then
3858 AC_DEFINE(HAVE_STAT_TV_NSEC, 1,
3859 [Define if you have struct stat.st_mtim.tv_nsec])
3860fi
3861
Martin v. Löwisebd9d5b2005-08-09 15:00:59 +00003862# Look for BSD style subsecond timestamps in struct stat
3863AC_MSG_CHECKING(for tv_nsec2 in struct stat)
3864AC_CACHE_VAL(ac_cv_stat_tv_nsec2,
3865AC_TRY_COMPILE([#include <sys/stat.h>], [
3866struct stat st;
3867st.st_mtimespec.tv_nsec = 1;
3868],
3869ac_cv_stat_tv_nsec2=yes,
3870ac_cv_stat_tv_nsec2=no,
3871ac_cv_stat_tv_nsec2=no))
3872AC_MSG_RESULT($ac_cv_stat_tv_nsec2)
3873if test "$ac_cv_stat_tv_nsec2" = yes
3874then
3875 AC_DEFINE(HAVE_STAT_TV_NSEC2, 1,
3876 [Define if you have struct stat.st_mtimensec])
3877fi
3878
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00003879# On HP/UX 11.0, mvwdelch is a block with a return statement
3880AC_MSG_CHECKING(whether mvwdelch is an expression)
3881AC_CACHE_VAL(ac_cv_mvwdelch_is_expression,
3882AC_TRY_COMPILE([#include <curses.h>], [
3883 int rtn;
3884 rtn = mvwdelch(0,0,0);
3885], ac_cv_mvwdelch_is_expression=yes,
3886 ac_cv_mvwdelch_is_expression=no,
3887 ac_cv_mvwdelch_is_expression=yes))
3888AC_MSG_RESULT($ac_cv_mvwdelch_is_expression)
3889
3890if test "$ac_cv_mvwdelch_is_expression" = yes
3891then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003892 AC_DEFINE(MVWDELCH_IS_EXPRESSION, 1,
3893 [Define if mvwdelch in curses.h is an expression.])
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00003894fi
3895
3896AC_MSG_CHECKING(whether WINDOW has _flags)
3897AC_CACHE_VAL(ac_cv_window_has_flags,
3898AC_TRY_COMPILE([#include <curses.h>], [
3899 WINDOW *w;
3900 w->_flags = 0;
3901], ac_cv_window_has_flags=yes,
3902 ac_cv_window_has_flags=no,
3903 ac_cv_window_has_flags=no))
3904AC_MSG_RESULT($ac_cv_window_has_flags)
3905
3906
3907if test "$ac_cv_window_has_flags" = yes
3908then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003909 AC_DEFINE(WINDOW_HAS_FLAGS, 1,
3910 [Define if WINDOW in curses.h offers a field _flags.])
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00003911fi
3912
Thomas Wouters0e3f5912006-08-11 14:57:12 +00003913AC_MSG_CHECKING(for is_term_resized)
Matthias Klosec80c93f2010-04-24 17:04:35 +00003914AC_TRY_COMPILE([#include <curses.h>], [void *x=is_term_resized],
3915 AC_DEFINE(HAVE_CURSES_IS_TERM_RESIZED, 1, [Define if you have the 'is_term_resized' function.])
Thomas Wouters0e3f5912006-08-11 14:57:12 +00003916 AC_MSG_RESULT(yes),
Martin v. Löwis24a880b2002-12-31 12:55:15 +00003917 AC_MSG_RESULT(no)
Thomas Wouters0e3f5912006-08-11 14:57:12 +00003918)
Martin v. Löwis24a880b2002-12-31 12:55:15 +00003919
Thomas Wouters0e3f5912006-08-11 14:57:12 +00003920AC_MSG_CHECKING(for resize_term)
Matthias Klosec80c93f2010-04-24 17:04:35 +00003921AC_TRY_COMPILE([#include <curses.h>], [void *x=resize_term],
3922 AC_DEFINE(HAVE_CURSES_RESIZE_TERM, 1, [Define if you have the 'resize_term' function.])
Thomas Wouters0e3f5912006-08-11 14:57:12 +00003923 AC_MSG_RESULT(yes),
Neal Norwitz865400f2003-03-21 01:42:58 +00003924 AC_MSG_RESULT(no)
Thomas Wouters0e3f5912006-08-11 14:57:12 +00003925)
3926
3927AC_MSG_CHECKING(for resizeterm)
Matthias Klosec80c93f2010-04-24 17:04:35 +00003928AC_TRY_COMPILE([#include <curses.h>], [void *x=resizeterm],
3929 AC_DEFINE(HAVE_CURSES_RESIZETERM, 1, [Define if you have the 'resizeterm' function.])
Thomas Wouters0e3f5912006-08-11 14:57:12 +00003930 AC_MSG_RESULT(yes),
3931 AC_MSG_RESULT(no)
3932)
3933
Thomas Wouters89f507f2006-12-13 04:49:30 +00003934AC_MSG_CHECKING(for /dev/ptmx)
3935
3936if test -r /dev/ptmx
3937then
3938 AC_MSG_RESULT(yes)
3939 AC_DEFINE(HAVE_DEV_PTMX, 1,
3940 [Define if we have /dev/ptmx.])
3941else
3942 AC_MSG_RESULT(no)
3943fi
3944
3945AC_MSG_CHECKING(for /dev/ptc)
3946
3947if test -r /dev/ptc
3948then
3949 AC_MSG_RESULT(yes)
3950 AC_DEFINE(HAVE_DEV_PTC, 1,
3951 [Define if we have /dev/ptc.])
3952else
3953 AC_MSG_RESULT(no)
3954fi
Neal Norwitz865400f2003-03-21 01:42:58 +00003955
Mark Dickinson6ce4a9a2009-11-16 17:00:11 +00003956if test "$have_long_long" = yes
3957then
3958 AC_MSG_CHECKING(for %lld and %llu printf() format support)
3959 AC_CACHE_VAL(ac_cv_have_long_long_format,
3960 AC_TRY_RUN([[
3961 #include <stdio.h>
3962 #include <stddef.h>
3963 #include <string.h>
3964
3965 #ifdef HAVE_SYS_TYPES_H
3966 #include <sys/types.h>
3967 #endif
3968
3969 int main()
3970 {
3971 char buffer[256];
3972
3973 if (sprintf(buffer, "%lld", (long long)123) < 0)
3974 return 1;
3975 if (strcmp(buffer, "123"))
3976 return 1;
3977
3978 if (sprintf(buffer, "%lld", (long long)-123) < 0)
3979 return 1;
3980 if (strcmp(buffer, "-123"))
3981 return 1;
3982
3983 if (sprintf(buffer, "%llu", (unsigned long long)123) < 0)
3984 return 1;
3985 if (strcmp(buffer, "123"))
3986 return 1;
3987
3988 return 0;
3989 }
3990 ]], ac_cv_have_long_long_format=yes,
3991 ac_cv_have_long_long_format=no,
3992 ac_cv_have_long_long_format=no)
3993 )
3994 AC_MSG_RESULT($ac_cv_have_long_long_format)
3995fi
3996
Mark Dickinson89d7d412009-12-31 20:50:59 +00003997if test "$ac_cv_have_long_long_format" = yes
Mark Dickinson6ce4a9a2009-11-16 17:00:11 +00003998then
3999 AC_DEFINE(PY_FORMAT_LONG_LONG, "ll",
4000 [Define to printf format modifier for long long type])
4001fi
4002
Ronald Oussoren3c1928a2009-11-19 17:15:31 +00004003if test $ac_sys_system = Darwin
4004then
4005 LIBS="$LIBS -framework CoreFoundation"
4006fi
Mark Dickinson6ce4a9a2009-11-16 17:00:11 +00004007
Benjamin Peterson8f326b22009-12-13 02:10:36 +00004008AC_CACHE_CHECK([for %zd printf() format support], ac_cv_have_size_t_format, [dnl
4009AC_TRY_RUN([
Alexandre Vassalottie5091f62009-07-17 06:41:02 +00004010#include <stdio.h>
Thomas Wouters477c8d52006-05-27 19:21:47 +00004011#include <stddef.h>
4012#include <string.h>
4013
Christian Heimes2c181612007-12-17 20:04:13 +00004014#ifdef HAVE_SYS_TYPES_H
4015#include <sys/types.h>
4016#endif
Thomas Wouters89f507f2006-12-13 04:49:30 +00004017
4018#ifdef HAVE_SSIZE_T
4019typedef ssize_t Py_ssize_t;
4020#elif SIZEOF_VOID_P == SIZEOF_LONG
4021typedef long Py_ssize_t;
4022#else
4023typedef int Py_ssize_t;
4024#endif
Thomas Wouters477c8d52006-05-27 19:21:47 +00004025
Christian Heimes2c181612007-12-17 20:04:13 +00004026int main()
4027{
4028 char buffer[256];
4029
Thomas Wouters477c8d52006-05-27 19:21:47 +00004030 if(sprintf(buffer, "%zd", (size_t)123) < 0)
4031 return 1;
4032
Thomas Wouters89f507f2006-12-13 04:49:30 +00004033 if (strcmp(buffer, "123"))
Thomas Wouters477c8d52006-05-27 19:21:47 +00004034 return 1;
Thomas Wouters89f507f2006-12-13 04:49:30 +00004035
4036 if (sprintf(buffer, "%zd", (Py_ssize_t)-123) < 0)
4037 return 1;
4038
4039 if (strcmp(buffer, "-123"))
4040 return 1;
4041
Thomas Wouters477c8d52006-05-27 19:21:47 +00004042 return 0;
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00004043}
Benjamin Peterson8f326b22009-12-13 02:10:36 +00004044], ac_cv_have_size_t_format=yes,
Alexandre Vassalottie5091f62009-07-17 06:41:02 +00004045 ac_cv_have_size_t_format=no,
Benjamin Peterson8f326b22009-12-13 02:10:36 +00004046 [ac_cv_have_size_t_format="cross -- assuming yes"]
4047)])
4048if test "$ac_cv_have_size_t_format" != no ; then
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00004049 AC_DEFINE(PY_FORMAT_SIZE_T, "z",
4050 [Define to printf format modifier for Py_ssize_t])
4051fi
Thomas Wouters477c8d52006-05-27 19:21:47 +00004052
Martin v. Löwis01c04012002-11-11 14:58:44 +00004053AC_CHECK_TYPE(socklen_t,,
4054 AC_DEFINE(socklen_t,int,
Matthias Klosec80c93f2010-04-24 17:04:35 +00004055 [Define to `int' if <sys/socket.h> does not define.]),[
Martin v. Löwis01c04012002-11-11 14:58:44 +00004056#ifdef HAVE_SYS_TYPES_H
4057#include <sys/types.h>
4058#endif
Guido van Rossum95713eb2000-05-18 20:53:31 +00004059#ifdef HAVE_SYS_SOCKET_H
4060#include <sys/socket.h>
4061#endif
Martin v. Löwis01c04012002-11-11 14:58:44 +00004062])
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00004063
Antoine Pitroufff95302008-09-03 18:58:51 +00004064AC_MSG_CHECKING(for broken mbstowcs)
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00004065AC_CACHE_VAL(ac_cv_broken_mbstowcs,
Antoine Pitroufff95302008-09-03 18:58:51 +00004066AC_TRY_RUN([
4067#include<stdlib.h>
4068int main() {
4069 size_t len = -1;
4070 const char *str = "text";
4071 len = mbstowcs(NULL, str, 0);
4072 return (len != 4);
4073}
4074],
4075ac_cv_broken_mbstowcs=no,
4076ac_cv_broken_mbstowcs=yes,
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00004077ac_cv_broken_mbstowcs=no))
Antoine Pitroufff95302008-09-03 18:58:51 +00004078AC_MSG_RESULT($ac_cv_broken_mbstowcs)
4079if test "$ac_cv_broken_mbstowcs" = yes
4080then
4081 AC_DEFINE(HAVE_BROKEN_MBSTOWCS, 1,
4082 [Define if mbstowcs(NULL, "text", 0) does not return the number of
4083 wide chars that would be converted.])
4084fi
4085
Antoine Pitroub52ec782009-01-25 16:34:23 +00004086# Check for --with-computed-gotos
4087AC_MSG_CHECKING(for --with-computed-gotos)
4088AC_ARG_WITH(computed-gotos,
Matthias Klosec80c93f2010-04-24 17:04:35 +00004089 AC_HELP_STRING([--with-computed-gotos],
4090 [Use computed gotos / threaded dispatch in evaluation loop (not available on all compilers)]),
Antoine Pitroub52ec782009-01-25 16:34:23 +00004091[
4092if test "$withval" != no
4093then
4094 AC_DEFINE(USE_COMPUTED_GOTOS, 1,
4095 [Define if you want to use computed gotos in ceval.c.])
4096 AC_MSG_RESULT(yes)
4097else AC_MSG_RESULT(no)
4098fi],
4099[AC_MSG_RESULT(no)])
4100
4101
Martin v. Löwis06f15bb2001-12-02 13:02:32 +00004102AC_SUBST(THREADHEADERS)
4103
4104for h in `(cd $srcdir;echo Python/thread_*.h)`
4105do
4106 THREADHEADERS="$THREADHEADERS \$(srcdir)/$h"
4107done
4108
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00004109AC_SUBST(SRCDIRS)
Neal Norwitzd24499d2005-12-18 21:36:39 +00004110SRCDIRS="Parser Grammar Objects Python Modules Mac"
Andrew M. Kuchling8abedde2001-01-26 22:55:24 +00004111AC_MSG_CHECKING(for build directories)
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00004112for dir in $SRCDIRS; do
4113 if test ! -d $dir; then
4114 mkdir $dir
Fred Drake884d3ba2000-11-02 17:52:56 +00004115 fi
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00004116done
4117AC_MSG_RESULT(done)
Fred Drake036144d2000-10-26 17:09:35 +00004118
Guido van Rossum627b2d71993-12-24 10:39:16 +00004119# generate output files
Antoine Pitrou20327222009-05-24 20:39:11 +00004120AC_CONFIG_FILES(Makefile.pre Modules/Setup.config Misc/python.pc)
Martin v. Löwis88afe662002-10-26 13:47:44 +00004121AC_OUTPUT
Neil Schemenauer61c51152001-01-26 16:18:16 +00004122
Thomas Wouters49fd7fa2006-04-21 10:40:58 +00004123echo "creating Modules/Setup"
Neil Schemenauer61c51152001-01-26 16:18:16 +00004124if test ! -f Modules/Setup
4125then
4126 cp $srcdir/Modules/Setup.dist Modules/Setup
4127fi
4128
Thomas Wouters49fd7fa2006-04-21 10:40:58 +00004129echo "creating Modules/Setup.local"
Neil Schemenauer61c51152001-01-26 16:18:16 +00004130if test ! -f Modules/Setup.local
4131then
4132 echo "# Edit this file for local setup changes" >Modules/Setup.local
4133fi
4134
4135echo "creating Makefile"
4136$SHELL $srcdir/Modules/makesetup -c $srcdir/Modules/config.c.in \
4137 -s Modules Modules/Setup.config \
Neil Schemenauerf8b71c52001-04-21 17:41:16 +00004138 Modules/Setup.local Modules/Setup
Neil Schemenauer66252162001-02-19 04:47:42 +00004139mv config.c Modules