blob: 857fbad52978083e886398f7aa8212317bdc99df [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
Thomas Wouters477c8d52006-05-27 19:21:47 +000089AC_ARG_ENABLE(universalsdk,
Christian Heimes68f5fbe2008-02-14 08:27:37 +000090 AC_HELP_STRING(--enable-universalsdk@<:@=SDKDIR@:>@, Build against Mac OS X 10.4u SDK (ppc/i386)),
Thomas Wouters477c8d52006-05-27 19:21:47 +000091[
92 case $enableval in
93 yes)
94 enableval=/Developer/SDKs/MacOSX10.4u.sdk
95 ;;
96 esac
97 case $enableval in
98 no)
99 UNIVERSALSDK=
100 enable_universalsdk=
101 ;;
102 *)
103 UNIVERSALSDK=$enableval
104 ;;
105 esac
106],[
107 UNIVERSALSDK=
108 enable_universalsdk=
109])
110AC_SUBST(UNIVERSALSDK)
111
Benjamin Peterson6794aa32008-07-16 20:33:37 +0000112AC_SUBST(ARCH_RUN_32BIT)
113
Georg Brandlfcaf9102008-07-16 02:17:56 +0000114UNIVERSAL_ARCHS="32-bit"
115AC_MSG_CHECKING(for --with-universal-archs)
116AC_ARG_WITH(universal-archs,
Ronald Oussoren3c064c12009-09-08 07:12:42 +0000117 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 +0000118[
119 AC_MSG_RESULT($withval)
120 UNIVERSAL_ARCHS="$withval"
121],
122[
123 AC_MSG_RESULT(32-bit)
124])
125
126
127
Christian Heimes81ee3ef2008-05-04 22:42:01 +0000128AC_ARG_WITH(framework-name,
129 AC_HELP_STRING(--with-framework-name=FRAMEWORK,
130 specify an alternate name of the framework built with --enable-framework),
131[
132 PYTHONFRAMEWORK=${withval}
133 PYTHONFRAMEWORKDIR=${withval}.framework
134 PYTHONFRAMEWORKIDENTIFIER=org.python.`echo $withval | tr '[A-Z]' '[a-z]'`
135 ],[
136 PYTHONFRAMEWORK=Python
137 PYTHONFRAMEWORKDIR=Python.framework
138 PYTHONFRAMEWORKIDENTIFIER=org.python.python
139])
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000140dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000141AC_ARG_ENABLE(framework,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000142 AC_HELP_STRING(--enable-framework@<:@=INSTALLDIR@:>@, Build (MacOSX|Darwin) framework),
143[
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000144 case $enableval in
145 yes)
146 enableval=/Library/Frameworks
Jack Jansen127e56e2001-09-11 14:41:54 +0000147 esac
148 case $enableval in
149 no)
150 PYTHONFRAMEWORK=
151 PYTHONFRAMEWORKDIR=no-framework
152 PYTHONFRAMEWORKPREFIX=
153 PYTHONFRAMEWORKINSTALLDIR=
Thomas Wouters477c8d52006-05-27 19:21:47 +0000154 FRAMEWORKINSTALLFIRST=
155 FRAMEWORKINSTALLLAST=
Thomas Wouters73e5a5b2006-06-08 15:35:45 +0000156 FRAMEWORKALTINSTALLFIRST=
157 FRAMEWORKALTINSTALLLAST=
158 if test "x${prefix}" = "xNONE"; then
159 FRAMEWORKUNIXTOOLSPREFIX="${ac_default_prefix}"
160 else
161 FRAMEWORKUNIXTOOLSPREFIX="${prefix}"
162 fi
Jack Jansen127e56e2001-09-11 14:41:54 +0000163 enable_framework=
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000164 ;;
165 *)
166 PYTHONFRAMEWORKPREFIX=$enableval
Jack Jansen127e56e2001-09-11 14:41:54 +0000167 PYTHONFRAMEWORKINSTALLDIR=$PYTHONFRAMEWORKPREFIX/$PYTHONFRAMEWORKDIR
Thomas Wouters477c8d52006-05-27 19:21:47 +0000168 FRAMEWORKINSTALLFIRST="frameworkinstallstructure"
Ronald Oussorenf6ccbf62009-06-02 10:55:56 +0000169 FRAMEWORKALTINSTALLFIRST="frameworkinstallstructure "
Georg Brandlfcaf9102008-07-16 02:17:56 +0000170 if test "$UNIVERSAL_ARCHS" = "all"
171 then
172 FRAMEWORKINSTALLLAST="frameworkinstallmaclib frameworkinstallapps4way frameworkinstallunixtools4way"
Ronald Oussorene3918352009-03-30 18:00:28 +0000173 FRAMEWORKALTINSTALLLAST="frameworkinstallmaclib frameworkinstallapps4way frameworkaltinstallunixtools4way"
Georg Brandlfcaf9102008-07-16 02:17:56 +0000174 else
Ronald Oussorene3918352009-03-30 18:00:28 +0000175 FRAMEWORKINSTALLLAST="frameworkinstallmaclib frameworkinstallapps frameworkinstallunixtools"
Georg Brandlfcaf9102008-07-16 02:17:56 +0000176 FRAMEWORKALTINSTALLLAST="frameworkinstallmaclib frameworkinstallapps frameworkaltinstallunixtools"
177 fi
178
Thomas Wouters73e5a5b2006-06-08 15:35:45 +0000179 if test "x${prefix}" = "xNONE" ; then
180 FRAMEWORKUNIXTOOLSPREFIX="${ac_default_prefix}"
181 else
182 FRAMEWORKUNIXTOOLSPREFIX="${prefix}"
183 fi
Jack Jansen127e56e2001-09-11 14:41:54 +0000184 prefix=$PYTHONFRAMEWORKINSTALLDIR/Versions/$VERSION
Thomas Wouters477c8d52006-05-27 19:21:47 +0000185
Christian Heimes81ee3ef2008-05-04 22:42:01 +0000186 # Add files for Mac specific code to the list of output
Thomas Wouters477c8d52006-05-27 19:21:47 +0000187 # files:
Thomas Wouters73e5a5b2006-06-08 15:35:45 +0000188 AC_CONFIG_FILES(Mac/Makefile)
189 AC_CONFIG_FILES(Mac/PythonLauncher/Makefile)
Christian Heimes81ee3ef2008-05-04 22:42:01 +0000190 AC_CONFIG_FILES(Mac/Resources/framework/Info.plist)
191 AC_CONFIG_FILES(Mac/Resources/app/Info.plist)
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000192 esac
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000193 ],[
194 PYTHONFRAMEWORK=
Jack Jansen127e56e2001-09-11 14:41:54 +0000195 PYTHONFRAMEWORKDIR=no-framework
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000196 PYTHONFRAMEWORKPREFIX=
197 PYTHONFRAMEWORKINSTALLDIR=
Thomas Wouters477c8d52006-05-27 19:21:47 +0000198 FRAMEWORKINSTALLFIRST=
199 FRAMEWORKINSTALLLAST=
Thomas Wouters73e5a5b2006-06-08 15:35:45 +0000200 FRAMEWORKALTINSTALLFIRST=
201 FRAMEWORKALTINSTALLLAST=
202 if test "x${prefix}" = "xNONE" ; then
203 FRAMEWORKUNIXTOOLSPREFIX="${ac_default_prefix}"
204 else
205 FRAMEWORKUNIXTOOLSPREFIX="${prefix}"
206 fi
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000207 enable_framework=
Georg Brandlfcaf9102008-07-16 02:17:56 +0000208
209 if test "$UNIVERSAL_ARCHS" = "all"
210 then
211 FRAMEWORKINSTALLLAST=update4wayuniversal
212 FRAMEWORKALTINSTALLLAST=update4wayuniversal
213 fi
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000214])
215AC_SUBST(PYTHONFRAMEWORK)
Christian Heimes81ee3ef2008-05-04 22:42:01 +0000216AC_SUBST(PYTHONFRAMEWORKIDENTIFIER)
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000217AC_SUBST(PYTHONFRAMEWORKDIR)
218AC_SUBST(PYTHONFRAMEWORKPREFIX)
219AC_SUBST(PYTHONFRAMEWORKINSTALLDIR)
Thomas Wouters477c8d52006-05-27 19:21:47 +0000220AC_SUBST(FRAMEWORKINSTALLFIRST)
221AC_SUBST(FRAMEWORKINSTALLLAST)
Thomas Wouters73e5a5b2006-06-08 15:35:45 +0000222AC_SUBST(FRAMEWORKALTINSTALLFIRST)
223AC_SUBST(FRAMEWORKALTINSTALLLAST)
224AC_SUBST(FRAMEWORKUNIXTOOLSPREFIX)
Guido van Rossum4b6b5791996-09-09 20:09:34 +0000225
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000226##AC_ARG_WITH(dyld,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000227## AC_HELP_STRING(--with-dyld,
228## Use (OpenStep|Rhapsody) dynamic linker))
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000229##
Guido van Rossumb418f891996-07-30 18:06:02 +0000230# Set name for machine-dependent library files
231AC_SUBST(MACHDEP)
232AC_MSG_CHECKING(MACHDEP)
233if test -z "$MACHDEP"
234then
Guido van Rossum4b6b5791996-09-09 20:09:34 +0000235 ac_sys_system=`uname -s`
Benjamin Peterson8719ad52009-09-11 22:24:02 +0000236 if test "$ac_sys_system" = "AIX" \
Martin v. Löwis21ee4092002-09-30 16:19:48 +0000237 -o "$ac_sys_system" = "UnixWare" -o "$ac_sys_system" = "OpenUNIX"; then
Guido van Rossum4b6b5791996-09-09 20:09:34 +0000238 ac_sys_release=`uname -v`
Guido van Rossumb418f891996-07-30 18:06:02 +0000239 else
Guido van Rossum4b6b5791996-09-09 20:09:34 +0000240 ac_sys_release=`uname -r`
Guido van Rossumb418f891996-07-30 18:06:02 +0000241 fi
Guido van Rossum4b6b5791996-09-09 20:09:34 +0000242 ac_md_system=`echo $ac_sys_system |
243 tr -d '[/ ]' | tr '[[A-Z]]' '[[a-z]]'`
244 ac_md_release=`echo $ac_sys_release |
Guido van Rossum67b26592001-10-20 14:21:45 +0000245 tr -d '[/ ]' | sed 's/^[[A-Z]]\.//' | sed 's/\..*//'`
Guido van Rossumb97ef171997-09-28 05:44:03 +0000246 MACHDEP="$ac_md_system$ac_md_release"
Guido van Rossum4b6b5791996-09-09 20:09:34 +0000247
Guido van Rossumbcd91e01997-03-20 20:46:29 +0000248 case $MACHDEP in
Andrew M. Kuchling5a3e4cb2001-07-20 19:29:04 +0000249 cygwin*) MACHDEP="cygwin";;
Jack Jansen8a97f4a2001-12-05 23:27:32 +0000250 darwin*) MACHDEP="darwin";;
Martin v. Löwisf90ae202002-06-11 06:22:31 +0000251 atheos*) MACHDEP="atheos";;
Martin v. Löwisf3322282003-07-13 09:46:13 +0000252 irix646) MACHDEP="irix6";;
Guido van Rossumb97ef171997-09-28 05:44:03 +0000253 '') MACHDEP="unknown";;
Guido van Rossumb418f891996-07-30 18:06:02 +0000254 esac
255fi
Jack Jansen83f898c2002-12-30 22:23:40 +0000256
Martin v. Löwise981a4e2002-11-11 13:26:51 +0000257# Some systems cannot stand _XOPEN_SOURCE being defined at all; they
258# disable features if it is defined, without any means to access these
259# features as extensions. For these systems, we skip the definition of
260# _XOPEN_SOURCE. Before adding a system to the list to gain access to
261# some feature, make sure there is no alternative way to access this
262# feature. Also, when using wildcards, make sure you have verified the
263# need for not defining _XOPEN_SOURCE on all systems matching the
264# wildcard, and that the wildcard does not include future systems
265# (which may remove their limitations).
266dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
267case $ac_sys_system/$ac_sys_release in
268 # On OpenBSD, select(2) is not available if _XOPEN_SOURCE is defined,
269 # even though select is a POSIX function. Reported by J. Ribbens.
Martin v. Löwis76bafc62003-10-03 13:47:44 +0000270 # Reconfirmed for OpenBSD 3.3 by Zachary Hamm, for 3.4 by Jason Ish.
Georg Brandlf78e02b2008-06-10 17:40:04 +0000271 OpenBSD/2.* | OpenBSD/3.@<:@0123456789@:>@ | OpenBSD/4.@<:@0123@:>@)
Christian Heimes5b5e81c2007-12-31 16:14:33 +0000272 define_xopen_source=no
273 # OpenBSD undoes our definition of __BSD_VISIBLE if _XOPEN_SOURCE is
274 # also defined. This can be overridden by defining _BSD_SOURCE
275 # As this has a different meaning on Linux, only define it on OpenBSD
276 AC_DEFINE(_BSD_SOURCE, 1, [Define on OpenBSD to activate all library features])
277 ;;
Thomas Wouters89f507f2006-12-13 04:49:30 +0000278 # Defining _XOPEN_SOURCE on NetBSD version prior to the introduction of
279 # _NETBSD_SOURCE disables certain features (eg. setgroups). Reported by
280 # Marc Recht
Benjamin Petersonf608c612008-11-16 18:33:53 +0000281 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 +0000282 define_xopen_source=no;;
Martin v. Löwisa9d71422003-03-28 18:43:31 +0000283 # On Solaris 2.6, sys/wait.h is inconsistent in the usage
284 # of union __?sigval. Reported by Stuart Bishop.
285 SunOS/5.6)
286 define_xopen_source=no;;
Martin v. Löwisc2409b42003-05-11 05:53:41 +0000287 # On UnixWare 7, u_long is never defined with _XOPEN_SOURCE,
288 # but used in /usr/include/netinet/tcp.h. Reported by Tim Rice.
Martin v. Löwis253d1f42004-05-07 19:14:14 +0000289 # Reconfirmed for 7.1.4 by Martin v. Loewis.
290 OpenUNIX/8.0.0| UnixWare/7.1.@<:@0-4@:>@)
Martin v. Löwisc2409b42003-05-11 05:53:41 +0000291 define_xopen_source=no;;
292 # On OpenServer 5, u_short is never defined with _XOPEN_SOURCE,
Martin v. Löwis53e73c32003-05-05 05:13:18 +0000293 # but used in struct sockaddr.sa_family. Reported by Tim Rice.
Martin v. Löwisc2409b42003-05-11 05:53:41 +0000294 SCO_SV/3.2)
Martin v. Löwis53e73c32003-05-05 05:13:18 +0000295 define_xopen_source=no;;
Martin v. Löwisb37509b2008-11-04 20:45:29 +0000296 # On FreeBSD 4, the math functions C89 does not cover are never defined
297 # with _XOPEN_SOURCE and __BSD_VISIBLE does not re-enable them.
298 FreeBSD/4.*)
299 define_xopen_source=no;;
300 # On MacOS X 10.2, a bug in ncurses.h means that it craps out if
301 # _XOPEN_EXTENDED_SOURCE is defined. Apparently, this is fixed in 10.3, which
302 # identifies itself as Darwin/7.*
303 # On Mac OS X 10.4, defining _POSIX_C_SOURCE or _XOPEN_SOURCE
304 # disables platform specific features beyond repair.
305 # On Mac OS X 10.3, defining _POSIX_C_SOURCE or _XOPEN_SOURCE
306 # has no effect, don't bother defining them
307 Darwin/@<:@6789@:>@.*)
Anthony Baxter6169c6b2003-10-04 07:46:23 +0000308 define_xopen_source=no;;
Trent Mickaf16e8c2004-08-25 23:55:59 +0000309 # On AIX 4 and 5.1, mbstate_t is defined only when _XOPEN_SOURCE == 500 but
310 # used in wcsnrtombs() and mbsnrtowcs() even if _XOPEN_SOURCE is not defined
311 # or has another value. By not (re)defining it, the defaults come in place.
Martin v. Löwisc19c5a62003-11-18 20:00:44 +0000312 AIX/4)
313 define_xopen_source=no;;
Trent Mickaf16e8c2004-08-25 23:55:59 +0000314 AIX/5)
315 if test `uname -r` -eq 1; then
316 define_xopen_source=no
317 fi
318 ;;
Georg Brandlf78e02b2008-06-10 17:40:04 +0000319 # On QNX 6.3.2, defining _XOPEN_SOURCE prevents netdb.h from
320 # defining NI_NUMERICHOST.
321 QNX/6.3.2)
322 define_xopen_source=no
323 ;;
Bob Ippolito7026a0a2005-03-28 23:23:47 +0000324
Martin v. Löwise981a4e2002-11-11 13:26:51 +0000325esac
326
327if test $define_xopen_source = yes
328then
Skip Montanarof0d5f792004-08-15 14:08:23 +0000329 # On Solaris w/ g++ it appears that _XOPEN_SOURCE has to be
330 # defined precisely as g++ defines it
Martin v. Löwis7dece662005-11-26 11:38:24 +0000331 # Furthermore, on Solaris 10, XPG6 requires the use of a C99
332 # compiler
Skip Montanarof0d5f792004-08-15 14:08:23 +0000333 case $ac_sys_system/$ac_sys_release in
Martin v. Löwis7dece662005-11-26 11:38:24 +0000334 SunOS/5.8|SunOS/5.9|SunOS/5.10)
Skip Montanarof0d5f792004-08-15 14:08:23 +0000335 AC_DEFINE(_XOPEN_SOURCE, 500,
336 Define to the level of X/Open that your system supports)
337 ;;
338 *)
339 AC_DEFINE(_XOPEN_SOURCE, 600,
340 Define to the level of X/Open that your system supports)
341 ;;
342 esac
Martin v. Löwis678fc1e2002-11-12 06:04:39 +0000343
344 # On Tru64 Unix 4.0F, defining _XOPEN_SOURCE also requires
345 # definition of _XOPEN_SOURCE_EXTENDED and _POSIX_C_SOURCE, or else
346 # several APIs are not declared. Since this is also needed in some
347 # cases for HP-UX, we define it globally.
Martin v. Löwis7dece662005-11-26 11:38:24 +0000348 # except for Solaris 10, where it must not be defined,
349 # as it implies XPG4.2
350 case $ac_sys_system/$ac_sys_release in
351 SunOS/5.10)
352 ;;
353 *)
354 AC_DEFINE(_XOPEN_SOURCE_EXTENDED, 1,
355 Define to activate Unix95-and-earlier features)
356 ;;
357 esac
Martin v. Löwis678fc1e2002-11-12 06:04:39 +0000358
Bob Ippolito7026a0a2005-03-28 23:23:47 +0000359 AC_DEFINE(_POSIX_C_SOURCE, 200112L, Define to activate features from IEEE Stds 1003.1-2001)
360
Martin v. Löwise981a4e2002-11-11 13:26:51 +0000361fi
362
Guido van Rossum91922671997-10-09 20:24:13 +0000363#
364# SGI compilers allow the specification of the both the ABI and the
365# ISA on the command line. Depending on the values of these switches,
366# different and often incompatable code will be generated.
367#
368# The SGI_ABI variable can be used to modify the CC and LDFLAGS and
369# thus supply support for various ABI/ISA combinations. The MACHDEP
370# variable is also adjusted.
371#
372AC_SUBST(SGI_ABI)
373if test ! -z "$SGI_ABI"
374then
375 CC="cc $SGI_ABI"
376 LDFLAGS="$SGI_ABI $LDFLAGS"
377 MACHDEP=`echo "${MACHDEP}${SGI_ABI}" | sed 's/ *//g'`
378fi
Guido van Rossumb418f891996-07-30 18:06:02 +0000379AC_MSG_RESULT($MACHDEP)
380
Jack Jansen6b08a402004-06-03 12:41:45 +0000381# Record the configure-time value of MACOSX_DEPLOYMENT_TARGET,
382# it may influence the way we can build extensions, so distutils
383# needs to check it
384AC_SUBST(CONFIGURE_MACOSX_DEPLOYMENT_TARGET)
Thomas Wouters477c8d52006-05-27 19:21:47 +0000385AC_SUBST(EXPORT_MACOSX_DEPLOYMENT_TARGET)
Jack Jansen6b08a402004-06-03 12:41:45 +0000386CONFIGURE_MACOSX_DEPLOYMENT_TARGET=
Thomas Wouters477c8d52006-05-27 19:21:47 +0000387EXPORT_MACOSX_DEPLOYMENT_TARGET='#'
Jack Jansen6b08a402004-06-03 12:41:45 +0000388
Mark Dickinsonb0e2b4c2008-04-26 20:48:56 +0000389AC_MSG_CHECKING(machine type as reported by uname -m)
390ac_sys_machine=`uname -m`
391AC_MSG_RESULT($ac_sys_machine)
392
Guido van Rossum627b2d71993-12-24 10:39:16 +0000393# checks for alternative programs
Skip Montanarodecc6a42003-01-01 20:07:49 +0000394
395# compiler flags are generated in two sets, BASECFLAGS and OPT. OPT is just
396# for debug/optimization stuff. BASECFLAGS is for flags that are required
397# just to get things to compile and link. Users are free to override OPT
398# when running configure or make. The build should not break if they do.
399# BASECFLAGS should generally not be messed with, however.
400
401# XXX shouldn't some/most/all of this code be merged with the stuff later
402# on that fiddles with OPT and BASECFLAGS?
Guido van Rossum5739e7e1995-01-20 16:50:53 +0000403AC_MSG_CHECKING(for --without-gcc)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000404AC_ARG_WITH(gcc,
405 AC_HELP_STRING(--without-gcc,never use gcc),
406[
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000407 case $withval in
Benjamin Peterson960cf0f2009-01-09 04:11:44 +0000408 no) CC=${CC:-cc}
Guido van Rossum5739e7e1995-01-20 16:50:53 +0000409 without_gcc=yes;;
410 yes) CC=gcc
411 without_gcc=no;;
412 *) CC=$withval
413 without_gcc=$withval;;
Guido van Rossum55a214e1995-09-13 17:48:09 +0000414 esac], [
Guido van Rossumb418f891996-07-30 18:06:02 +0000415 case $ac_sys_system in
Neil Schemenauerb3531b82001-02-16 04:09:05 +0000416 AIX*) CC=cc_r
417 without_gcc=;;
Martin v. Löwis130fb172001-07-19 11:00:41 +0000418 *) without_gcc=no;;
Guido van Rossum55a214e1995-09-13 17:48:09 +0000419 esac])
Guido van Rossum5739e7e1995-01-20 16:50:53 +0000420AC_MSG_RESULT($without_gcc)
421
Guido van Rossum03ad99f1995-03-09 14:09:54 +0000422# If the user switches compilers, we can't believe the cache
423if test ! -z "$ac_cv_prog_CC" -a ! -z "$CC" -a "$CC" != "$ac_cv_prog_CC"
424then
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000425 AC_MSG_ERROR([cached CC is different -- throw away $cache_file
426(it is also a good idea to do 'make clean' before compiling)])
Guido van Rossum03ad99f1995-03-09 14:09:54 +0000427fi
428
Guido van Rossum627b2d71993-12-24 10:39:16 +0000429AC_PROG_CC
Martin v. Löwis1d5ecb72001-08-09 10:29:44 +0000430
Thomas Wouters49fd7fa2006-04-21 10:40:58 +0000431AC_SUBST(CXX)
432AC_SUBST(MAINCC)
433AC_MSG_CHECKING(for --with-cxx-main=<compiler>)
434AC_ARG_WITH(cxx_main,
435 AC_HELP_STRING([--with-cxx-main=<compiler>],
436 [compile main() and link python executable with C++ compiler]),
437[
438
439 case $withval in
440 no) with_cxx_main=no
441 MAINCC='$(CC)';;
442 yes) with_cxx_main=yes
443 MAINCC='$(CXX)';;
444 *) with_cxx_main=yes
445 MAINCC=$withval
446 if test -z "$CXX"
447 then
448 CXX=$withval
449 fi;;
450 esac], [
451 with_cxx_main=no
452 MAINCC='$(CC)'
453])
454AC_MSG_RESULT($with_cxx_main)
455
456preset_cxx="$CXX"
457if test -z "$CXX"
458then
459 case "$CC" in
460 gcc) AC_PATH_PROG(CXX, [g++], [g++], [notfound]) ;;
461 cc) AC_PATH_PROG(CXX, [c++], [c++], [notfound]) ;;
462 esac
463 if test "$CXX" = "notfound"
464 then
465 CXX=""
466 fi
467fi
468if test -z "$CXX"
469then
470 AC_CHECK_PROGS(CXX, $CCC c++ g++ gcc CC cxx cc++ cl, notfound)
471 if test "$CXX" = "notfound"
472 then
473 CXX=""
474 fi
475fi
476if test "$preset_cxx" != "$CXX"
477then
478 AC_MSG_WARN([
479
480 By default, distutils will build C++ extension modules with "$CXX".
481 If this is not intended, then set CXX on the configure command line.
482 ])
483fi
484
485
Martin v. Löwis1d5ecb72001-08-09 10:29:44 +0000486# checks for UNIX variants that set C preprocessor variables
487AC_AIX
Martin v. Löwis1d5ecb72001-08-09 10:29:44 +0000488
Martin v. Löwis779ffc02002-12-02 22:17:01 +0000489# Check for unsupported systems
490case $ac_sys_system/$ac_sys_release in
Guido van Rossumcd16bf62007-06-13 18:07:49 +0000491atheos*|Linux*/1*)
Martin v. Löwis779ffc02002-12-02 22:17:01 +0000492 echo This system \($ac_sys_system/$ac_sys_release\) is no longer supported.
493 echo See README for details.
494 exit 1;;
495esac
496
Neil Schemenauer55f0cf32001-01-24 17:24:33 +0000497AC_EXEEXT
Neil Schemenauer3ae1d0a2001-01-27 06:54:42 +0000498AC_MSG_CHECKING(for --with-suffix)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000499AC_ARG_WITH(suffix,
500 AC_HELP_STRING(--with-suffix=.exe, set executable suffix),
501[
Neil Schemenauer3ae1d0a2001-01-27 06:54:42 +0000502 case $withval in
503 no) EXEEXT=;;
504 yes) EXEEXT=.exe;;
505 *) EXEEXT=$withval;;
506 esac])
507AC_MSG_RESULT($EXEEXT)
Jack Jansen1999ef42001-12-06 21:47:20 +0000508
Jack Jansen9a66b6d2001-08-08 13:56:14 +0000509# Test whether we're running on a non-case-sensitive system, in which
510# case we give a warning if no ext is given
Jack Jansen1999ef42001-12-06 21:47:20 +0000511AC_SUBST(BUILDEXEEXT)
512AC_MSG_CHECKING(for case-insensitive build directory)
Jack Jansen3c2c4332002-11-06 13:33:32 +0000513if test ! -d CaseSensitiveTestDir; then
514mkdir CaseSensitiveTestDir
515fi
516
517if test -d casesensitivetestdir
Jack Jansen9a66b6d2001-08-08 13:56:14 +0000518then
Jack Jansen1999ef42001-12-06 21:47:20 +0000519 AC_MSG_RESULT(yes)
520 BUILDEXEEXT=.exe
521else
522 AC_MSG_RESULT(no)
Jack Jansendd19cf82001-12-06 22:36:17 +0000523 BUILDEXEEXT=$EXEEXT
Jack Jansen9a66b6d2001-08-08 13:56:14 +0000524fi
Jack Jansen3c2c4332002-11-06 13:33:32 +0000525rmdir CaseSensitiveTestDir
Guido van Rossumfb842551997-08-06 23:42:07 +0000526
Guido van Rossumdd997f71998-10-07 19:58:26 +0000527case $MACHDEP in
528bsdos*)
529 case $CC in
530 gcc) CC="$CC -D_HAVE_BSDI";;
531 esac;;
532esac
533
Guido van Rossum84561611997-08-21 00:08:11 +0000534case $ac_sys_system in
535hp*|HP*)
536 case $CC in
Guido van Rossumcd5ff9f2000-09-22 16:15:54 +0000537 cc|*/cc) CC="$CC -Ae";;
Guido van Rossum84561611997-08-21 00:08:11 +0000538 esac;;
Martin v. Löwise8964d42001-03-06 12:09:07 +0000539SunOS*)
540 # Some functions have a prototype only with that define, e.g. confstr
Martin v. Löwisc45929e2002-04-06 10:10:49 +0000541 AC_DEFINE(__EXTENSIONS__, 1, [Defined on Solaris to see additional function prototypes.])
Martin v. Löwise8964d42001-03-06 12:09:07 +0000542 ;;
Guido van Rossum84561611997-08-21 00:08:11 +0000543esac
544
Martin v. Löwise8964d42001-03-06 12:09:07 +0000545
Neil Schemenauer61c51152001-01-26 16:18:16 +0000546AC_SUBST(LIBRARY)
547AC_MSG_CHECKING(LIBRARY)
548if test -z "$LIBRARY"
549then
550 LIBRARY='libpython$(VERSION).a'
551fi
552AC_MSG_RESULT($LIBRARY)
553
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000554# LDLIBRARY is the name of the library to link against (as opposed to the
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000555# name of the library into which to insert object files). BLDLIBRARY is also
556# the library to link against, usually. On Mac OS X frameworks, BLDLIBRARY
557# is blank as the main program is not linked directly against LDLIBRARY.
558# LDLIBRARYDIR is the path to LDLIBRARY, which is made in a subdirectory. On
559# systems without shared libraries, LDLIBRARY is the same as LIBRARY
560# (defined in the Makefiles). On Cygwin LDLIBRARY is the import library,
561# DLLLIBRARY is the shared (i.e., DLL) library.
562#
Martin v. Löwis1142de32002-03-29 16:28:31 +0000563# RUNSHARED is used to run shared python without installed libraries
564#
565# INSTSONAME is the name of the shared library that will be use to install
566# on the system - some systems like version suffix, others don't
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000567AC_SUBST(LDLIBRARY)
Guido van Rossum27552902001-01-23 01:52:26 +0000568AC_SUBST(DLLLIBRARY)
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000569AC_SUBST(BLDLIBRARY)
570AC_SUBST(LDLIBRARYDIR)
Martin v. Löwis1142de32002-03-29 16:28:31 +0000571AC_SUBST(INSTSONAME)
572AC_SUBST(RUNSHARED)
Neil Schemenauer61c51152001-01-26 16:18:16 +0000573LDLIBRARY="$LIBRARY"
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000574BLDLIBRARY='$(LDLIBRARY)'
Martin v. Löwis09bdf722002-05-08 08:51:29 +0000575INSTSONAME='$(LDLIBRARY)'
Guido van Rossum27552902001-01-23 01:52:26 +0000576DLLLIBRARY=''
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000577LDLIBRARYDIR=''
Martin v. Löwis1142de32002-03-29 16:28:31 +0000578RUNSHARED=''
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000579
Guido van Rossumfb842551997-08-06 23:42:07 +0000580# LINKCC is the command that links the python executable -- default is $(CC).
Martin v. Löwisb7da67a2001-10-18 15:35:38 +0000581# If CXX is set, and if it is needed to link a main function that was
582# compiled with CXX, LINKCC is CXX instead. Always using CXX is undesirable:
583# python might then depend on the C++ runtime
Fred Drake5790be12000-10-09 17:06:13 +0000584# This is altered for AIX in order to build the export list before
Guido van Rossumec95c7b1998-08-04 17:59:56 +0000585# linking.
Guido van Rossumfb842551997-08-06 23:42:07 +0000586AC_SUBST(LINKCC)
587AC_MSG_CHECKING(LINKCC)
588if test -z "$LINKCC"
589then
Thomas Wouters49fd7fa2006-04-21 10:40:58 +0000590 LINKCC='$(PURIFY) $(MAINCC)'
Guido van Rossumfb842551997-08-06 23:42:07 +0000591 case $ac_sys_system in
592 AIX*)
Neal Norwitz0b27ff92003-03-31 15:53:49 +0000593 exp_extra="\"\""
594 if test $ac_sys_release -ge 5 -o \
595 $ac_sys_release -eq 4 -a `uname -r` -ge 2 ; then
596 exp_extra="."
597 fi
598 LINKCC="\$(srcdir)/Modules/makexp_aix Modules/python.exp $exp_extra \$(LIBRARY); $LINKCC";;
Georg Brandlf78e02b2008-06-10 17:40:04 +0000599 QNX*)
600 # qcc must be used because the other compilers do not
601 # support -N.
602 LINKCC=qcc;;
Guido van Rossumfb842551997-08-06 23:42:07 +0000603 esac
604fi
605AC_MSG_RESULT($LINKCC)
606
Tarek Ziadébe720e02009-05-09 11:55:12 +0000607# GNULD is set to "yes" if the GNU linker is used. If this goes wrong
608# make sure we default having it set to "no": this is used by
609# distutils.unixccompiler to know if it should add --enable-new-dtags
610# to linker command lines, and failing to detect GNU ld simply results
611# in the same bahaviour as before.
612AC_SUBST(GNULD)
613AC_MSG_CHECKING(for GNU ld)
614ac_prog=ld
615if test "$GCC" = yes; then
616 ac_prog=`$CC -print-prog-name=ld`
617fi
618case `"$ac_prog" -V 2>&1 < /dev/null` in
619 *GNU*)
620 GNULD=yes;;
621 *)
622 GNULD=no;;
623esac
624AC_MSG_RESULT($GNULD)
625
Martin v. Löwis1142de32002-03-29 16:28:31 +0000626AC_MSG_CHECKING(for --enable-shared)
627AC_ARG_ENABLE(shared,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000628 AC_HELP_STRING(--enable-shared, disable/enable building shared python library))
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000629
Martin v. Löwis1142de32002-03-29 16:28:31 +0000630if test -z "$enable_shared"
631then
Martin v. Löwisb51033d2002-05-03 05:53:15 +0000632 case $ac_sys_system in
Martin v. Löwisf90ae202002-06-11 06:22:31 +0000633 CYGWIN* | atheos*)
Martin v. Löwisb51033d2002-05-03 05:53:15 +0000634 enable_shared="yes";;
635 *)
636 enable_shared="no";;
637 esac
Martin v. Löwis1142de32002-03-29 16:28:31 +0000638fi
639AC_MSG_RESULT($enable_shared)
640
Skip Montanaro56f6a4f2004-06-18 02:47:22 +0000641AC_MSG_CHECKING(for --enable-profiling)
642AC_ARG_ENABLE(profiling,
643 AC_HELP_STRING(--enable-profiling, enable C-level code profiling),
644[ac_save_cc="$CC"
645 CC="$CC -pg"
646 AC_TRY_RUN([int main() { return 0; }],
647 ac_enable_profiling="yes",
648 ac_enable_profiling="no",
649 ac_enable_profiling="no")
650 CC="$ac_save_cc"])
651AC_MSG_RESULT($ac_enable_profiling)
652
653case "$ac_enable_profiling" in
654 "yes")
655 BASECFLAGS="-pg $BASECFLAGS"
656 LDFLAGS="-pg $LDFLAGS"
657 ;;
658esac
Martin v. Löwis1142de32002-03-29 16:28:31 +0000659
660AC_MSG_CHECKING(LDLIBRARY)
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000661
Guido van Rossumb8552162001-09-05 14:58:11 +0000662# MacOSX framework builds need more magic. LDLIBRARY is the dynamic
663# library that we build, but we do not want to link against it (we
664# will find it with a -framework option). For this reason there is an
665# extra variable BLDLIBRARY against which Python and the extension
666# modules are linked, BLDLIBRARY. This is normally the same as
667# LDLIBRARY, but empty for MacOSX framework builds.
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000668if test "$enable_framework"
669then
670 LDLIBRARY='$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansen66b84832003-07-04 12:14:39 +0000671 RUNSHARED=DYLD_FRAMEWORK_PATH="`pwd`:$DYLD_FRAMEWORK_PATH"
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000672 BLDLIBRARY=''
673else
674 BLDLIBRARY='$(LDLIBRARY)'
675fi
676
Martin v. Löwis1142de32002-03-29 16:28:31 +0000677# Other platforms follow
678if test $enable_shared = "yes"; then
Mark Hammond8235ea12002-07-19 06:55:41 +0000679 AC_DEFINE(Py_ENABLE_SHARED, 1, [Defined if Python is built as a shared library.])
Martin v. Löwis1142de32002-03-29 16:28:31 +0000680 case $ac_sys_system in
Martin v. Löwis1142de32002-03-29 16:28:31 +0000681 CYGWIN*)
682 LDLIBRARY='libpython$(VERSION).dll.a'
683 DLLLIBRARY='libpython$(VERSION).dll'
684 ;;
685 SunOS*)
686 LDLIBRARY='libpython$(VERSION).so'
Martin v. Löwisd141a8c2003-06-14 15:20:28 +0000687 BLDLIBRARY='-Wl,-R,$(LIBDIR) -L. -lpython$(VERSION)'
Martin v. Löwisfc9b75f2003-08-09 09:06:52 +0000688 RUNSHARED=LD_LIBRARY_PATH=`pwd`:${LD_LIBRARY_PATH}
Martin v. Löwis2389c412003-10-31 15:42:07 +0000689 INSTSONAME="$LDLIBRARY".$SOVERSION
Martin v. Löwis1142de32002-03-29 16:28:31 +0000690 ;;
Martin v. Löwis86d66262006-02-17 08:40:11 +0000691 Linux*|GNU*|NetBSD*|FreeBSD*|DragonFly*)
Martin v. Löwis1142de32002-03-29 16:28:31 +0000692 LDLIBRARY='libpython$(VERSION).so'
693 BLDLIBRARY='-L. -lpython$(VERSION)'
Martin v. Löwisfc9b75f2003-08-09 09:06:52 +0000694 RUNSHARED=LD_LIBRARY_PATH=`pwd`:${LD_LIBRARY_PATH}
Hye-Shik Chang33761492004-10-26 09:53:46 +0000695 case $ac_sys_system in
696 FreeBSD*)
697 SOVERSION=`echo $SOVERSION|cut -d "." -f 1`
698 ;;
699 esac
Martin v. Löwis1142de32002-03-29 16:28:31 +0000700 INSTSONAME="$LDLIBRARY".$SOVERSION
701 ;;
702 hp*|HP*)
Thomas Wouters477c8d52006-05-27 19:21:47 +0000703 case `uname -m` in
704 ia64)
705 LDLIBRARY='libpython$(VERSION).so'
706 ;;
707 *)
708 LDLIBRARY='libpython$(VERSION).sl'
709 ;;
710 esac
Martin v. Löwis1142de32002-03-29 16:28:31 +0000711 BLDLIBRARY='-Wl,+b,$(LIBDIR) -L. -lpython$(VERSION)'
Martin v. Löwisfc9b75f2003-08-09 09:06:52 +0000712 RUNSHARED=SHLIB_PATH=`pwd`:${SHLIB_PATH}
Martin v. Löwis1142de32002-03-29 16:28:31 +0000713 ;;
714 OSF*)
715 LDLIBRARY='libpython$(VERSION).so'
Neal Norwitz671b9e32006-01-09 07:07:12 +0000716 BLDLIBRARY='-rpath $(LIBDIR) -L. -lpython$(VERSION)'
Martin v. Löwisfc9b75f2003-08-09 09:06:52 +0000717 RUNSHARED=LD_LIBRARY_PATH=`pwd`:${LD_LIBRARY_PATH}
Martin v. Löwis1142de32002-03-29 16:28:31 +0000718 ;;
Martin v. Löwisf90ae202002-06-11 06:22:31 +0000719 atheos*)
720 LDLIBRARY='libpython$(VERSION).so'
721 BLDLIBRARY='-L. -lpython$(VERSION)'
722 RUNSHARED=DLL_PATH=`pwd`:${DLL_PATH:-/atheos/sys/libs:/atheos/autolnk/lib}
723 ;;
Georg Brandlb1441c72009-01-03 22:33:39 +0000724 Darwin*)
725 LDLIBRARY='libpython$(VERSION).dylib'
726 BLDLIBRARY='-L. -lpython$(VERSION)'
727 RUNSHARED='DYLD_LIBRARY_PATH=`pwd`:${DYLD_LIBRARY_PATH}'
728 ;;
729
Martin v. Löwis1142de32002-03-29 16:28:31 +0000730 esac
Jason Tishler30765592003-09-04 11:04:06 +0000731else # shared is disabled
732 case $ac_sys_system in
733 CYGWIN*)
734 BLDLIBRARY='$(LIBRARY)'
735 LDLIBRARY='libpython$(VERSION).dll.a'
736 ;;
737 esac
Martin v. Löwis1142de32002-03-29 16:28:31 +0000738fi
739
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000740AC_MSG_RESULT($LDLIBRARY)
741
Guido van Rossum627b2d71993-12-24 10:39:16 +0000742AC_PROG_RANLIB
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000743AC_SUBST(AR)
Guido van Rossum76be6ed1995-01-02 18:33:54 +0000744AC_CHECK_PROGS(AR, ar aal, ar)
Neil Schemenauera42c8272001-03-31 00:01:55 +0000745
Tarek Ziadé5662d3e2009-05-07 21:24:43 +0000746# tweak ARFLAGS only if the user didn't set it on the command line
747AC_SUBST(ARFLAGS)
748if test -z "$ARFLAGS"
749then
750 ARFLAGS="rc"
751fi
752
Martin v. Löwisdea59e52006-01-05 10:00:36 +0000753AC_SUBST(SVNVERSION)
Thomas Wouters49fd7fa2006-04-21 10:40:58 +0000754AC_CHECK_PROG(SVNVERSION, svnversion, found, not-found)
Martin v. Löwisc5bf5a02006-01-05 10:33:59 +0000755if test $SVNVERSION = found
756then
757 SVNVERSION="svnversion \$(srcdir)"
758else
Benjamin Petersonf53eec82009-05-23 19:36:27 +0000759 SVNVERSION="echo Unversioned directory"
Martin v. Löwisc5bf5a02006-01-05 10:33:59 +0000760fi
Martin v. Löwisdea59e52006-01-05 10:00:36 +0000761
Neil Schemenauera42c8272001-03-31 00:01:55 +0000762case $MACHDEP in
Neil Schemenaueraf5567f2001-10-21 22:32:04 +0000763bsdos*|hp*|HP*)
764 # install -d does not work on BSDI or HP-UX
Neil Schemenauera42c8272001-03-31 00:01:55 +0000765 if test -z "$INSTALL"
766 then
767 INSTALL="${srcdir}/install-sh -c"
768 fi
769esac
Neil Schemenauer55f0cf32001-01-24 17:24:33 +0000770AC_PROG_INSTALL
Guido van Rossumb418f891996-07-30 18:06:02 +0000771
Guido van Rossumec95c7b1998-08-04 17:59:56 +0000772# Not every filesystem supports hard links
773AC_SUBST(LN)
774if test -z "$LN" ; then
775 case $ac_sys_system in
Guido van Rossumaef734b2001-01-10 21:09:12 +0000776 CYGWIN*) LN="ln -s";;
Martin v. Löwisf90ae202002-06-11 06:22:31 +0000777 atheos*) LN="ln -s";;
Guido van Rossumec95c7b1998-08-04 17:59:56 +0000778 *) LN=ln;;
779 esac
780fi
781
Fred Drake9f715822001-07-11 06:27:00 +0000782# Check for --with-pydebug
783AC_MSG_CHECKING(for --with-pydebug)
784AC_ARG_WITH(pydebug,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000785 AC_HELP_STRING(--with-pydebug, build with Py_DEBUG defined),
786[
Fred Drake9f715822001-07-11 06:27:00 +0000787if test "$withval" != no
Martin v. Löwisc45929e2002-04-06 10:10:49 +0000788then
789 AC_DEFINE(Py_DEBUG, 1,
790 [Define if you want to build an interpreter with many run-time checks.])
791 AC_MSG_RESULT(yes);
792 Py_DEBUG='true'
Fred Drake9f715822001-07-11 06:27:00 +0000793else AC_MSG_RESULT(no); Py_DEBUG='false'
794fi],
795[AC_MSG_RESULT(no)])
796
Skip Montanarodecc6a42003-01-01 20:07:49 +0000797# XXX Shouldn't the code above that fiddles with BASECFLAGS and OPT be
798# merged with this chunk of code?
799
Neil Schemenauer55f0cf32001-01-24 17:24:33 +0000800# Optimizer/debugger flags
Skip Montanarodecc6a42003-01-01 20:07:49 +0000801# ------------------------
802# (The following bit of code is complicated enough - please keep things
803# indented properly. Just pretend you're editing Python code. ;-)
804
805# There are two parallel sets of case statements below, one that checks to
806# see if OPT was set and one that does BASECFLAGS setting based upon
807# compiler and platform. BASECFLAGS tweaks need to be made even if the
808# user set OPT.
809
810# tweak OPT based on compiler and platform, only if the user didn't set
811# it on the command line
Guido van Rossumb418f891996-07-30 18:06:02 +0000812AC_SUBST(OPT)
Guido van Rossum4e8af441994-08-19 15:33:54 +0000813if test -z "$OPT"
Guido van Rossumb418f891996-07-30 18:06:02 +0000814then
Skip Montanarodecc6a42003-01-01 20:07:49 +0000815 case $GCC in
816 yes)
Thomas Wouters49fd7fa2006-04-21 10:40:58 +0000817 if test "$CC" != 'g++' ; then
818 STRICT_PROTO="-Wstrict-prototypes"
819 fi
Christian Heimes38053212007-12-14 01:24:44 +0000820 # For gcc 4.x we need to use -fwrapv so lets check if its supported
821 if "$CC" -v --help 2>/dev/null |grep -- -fwrapv > /dev/null; then
822 WRAP="-fwrapv"
823 fi
Skip Montanarodecc6a42003-01-01 20:07:49 +0000824 case $ac_cv_prog_cc_g in
Guido van Rossum2242f2f2001-04-11 20:58:20 +0000825 yes)
Fred Drake9f715822001-07-11 06:27:00 +0000826 if test "$Py_DEBUG" = 'true' ; then
827 # Optimization messes up debuggers, so turn it off for
828 # debug builds.
Thomas Wouters49fd7fa2006-04-21 10:40:58 +0000829 OPT="-g -Wall $STRICT_PROTO"
Fred Drake9f715822001-07-11 06:27:00 +0000830 else
Christian Heimes38053212007-12-14 01:24:44 +0000831 OPT="-g $WRAP -O3 -Wall $STRICT_PROTO"
Skip Montanarodecc6a42003-01-01 20:07:49 +0000832 fi
833 ;;
Guido van Rossum2242f2f2001-04-11 20:58:20 +0000834 *)
Thomas Wouters49fd7fa2006-04-21 10:40:58 +0000835 OPT="-O3 -Wall $STRICT_PROTO"
Skip Montanarodecc6a42003-01-01 20:07:49 +0000836 ;;
Fred Drake9f715822001-07-11 06:27:00 +0000837 esac
Martin v. Löwis21ee4092002-09-30 16:19:48 +0000838 case $ac_sys_system in
Skip Montanarodecc6a42003-01-01 20:07:49 +0000839 SCO_SV*) OPT="$OPT -m486 -DSCO5"
840 ;;
841 esac
Fred Drake9f715822001-07-11 06:27:00 +0000842 ;;
Skip Montanarodecc6a42003-01-01 20:07:49 +0000843
Guido van Rossum2242f2f2001-04-11 20:58:20 +0000844 *)
Skip Montanarodecc6a42003-01-01 20:07:49 +0000845 OPT="-O"
846 ;;
Guido van Rossum2242f2f2001-04-11 20:58:20 +0000847 esac
Guido van Rossum4e8af441994-08-19 15:33:54 +0000848fi
Guido van Rossum627b2d71993-12-24 10:39:16 +0000849
Skip Montanarodecc6a42003-01-01 20:07:49 +0000850AC_SUBST(BASECFLAGS)
Georg Brandlfcaf9102008-07-16 02:17:56 +0000851
852# The -arch flags for universal builds on OSX
853UNIVERSAL_ARCH_FLAGS=
854AC_SUBST(UNIVERSAL_ARCH_FLAGS)
855
Skip Montanarodecc6a42003-01-01 20:07:49 +0000856# tweak BASECFLAGS based on compiler and platform
857case $GCC in
858yes)
Martin v. Löwis70fedcd2003-07-07 21:26:19 +0000859 # Python violates C99 rules, by casting between incompatible
860 # pointer types. GCC may generate bad code as a result of that,
861 # so use -fno-strict-aliasing if supported.
862 AC_MSG_CHECKING(whether $CC accepts -fno-strict-aliasing)
863 ac_save_cc="$CC"
864 CC="$CC -fno-strict-aliasing"
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +0000865 AC_CACHE_VAL(ac_cv_no_strict_aliasing_ok,
Martin v. Löwis70fedcd2003-07-07 21:26:19 +0000866 AC_TRY_RUN([int main() { return 0; }],
867 ac_cv_no_strict_aliasing_ok=yes,
868 ac_cv_no_strict_aliasing_ok=no,
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +0000869 ac_cv_no_strict_aliasing_ok=no))
Martin v. Löwis70fedcd2003-07-07 21:26:19 +0000870 CC="$ac_save_cc"
871 AC_MSG_RESULT($ac_cv_no_strict_aliasing_ok)
872 if test $ac_cv_no_strict_aliasing_ok = yes
873 then
874 BASECFLAGS="$BASECFLAGS -fno-strict-aliasing"
875 fi
Mark Dickinsonb0e2b4c2008-04-26 20:48:56 +0000876
877 # if using gcc on alpha, use -mieee to get (near) full IEEE 754
878 # support. Without this, treatment of subnormals doesn't follow
879 # the standard.
880 case $ac_sys_machine in
881 alpha*)
882 BASECFLAGS="$BASECFLAGS -mieee"
883 ;;
884 esac
885
Skip Montanarodecc6a42003-01-01 20:07:49 +0000886 case $ac_sys_system in
887 SCO_SV*)
888 BASECFLAGS="$BASECFLAGS -m486 -DSCO5"
889 ;;
890 # is there any other compiler on Darwin besides gcc?
891 Darwin*)
Christian Heimesb186d002008-03-18 15:15:01 +0000892 # -Wno-long-double, -no-cpp-precomp, and -mno-fused-madd
893 # used to be here, but non-Apple gcc doesn't accept them.
Benjamin Peterson67c38e22008-07-17 16:10:34 +0000894
895
Thomas Wouters477c8d52006-05-27 19:21:47 +0000896 if test "${enable_universalsdk}"; then
Georg Brandlfcaf9102008-07-16 02:17:56 +0000897 UNIVERSAL_ARCH_FLAGS=""
898 if test "$UNIVERSAL_ARCHS" = "32-bit" ; then
899 UNIVERSAL_ARCH_FLAGS="-arch ppc -arch i386"
Benjamin Peterson6794aa32008-07-16 20:33:37 +0000900 ARCH_RUN_32BIT=""
Georg Brandlfcaf9102008-07-16 02:17:56 +0000901
902 elif test "$UNIVERSAL_ARCHS" = "64-bit" ; then
903 UNIVERSAL_ARCH_FLAGS="-arch ppc64 -arch x86_64"
Ronald Oussoren5bbab3e2009-09-06 11:01:15 +0000904 ARCH_RUN_32BIT="true"
Georg Brandlfcaf9102008-07-16 02:17:56 +0000905
906 elif test "$UNIVERSAL_ARCHS" = "all" ; then
907 UNIVERSAL_ARCH_FLAGS="-arch i386 -arch ppc -arch ppc64 -arch x86_64"
Benjamin Peterson3ad7ba12008-08-19 17:16:56 +0000908 ARCH_RUN_32BIT="arch -i386 -ppc"
Georg Brandlfcaf9102008-07-16 02:17:56 +0000909
Ronald Oussoren3c064c12009-09-08 07:12:42 +0000910 elif test "$UNIVERSAL_ARCHS" = "intel" ; then
911 UNIVERSAL_ARCH_FLAGS="-arch i386 -arch x86_64"
912 ARCH_RUN_32BIT="arch -i386"
913
914 elif test "$UNIVERSAL_ARCHS" = "3-way" ; then
915 UNIVERSAL_ARCH_FLAGS="-arch i386 -arch ppc -arch x86_64"
916 ARCH_RUN_32BIT="arch -i386 -ppc"
917
Georg Brandlfcaf9102008-07-16 02:17:56 +0000918 else
919 AC_MSG_ERROR([proper usage is --with-universalarch=32-bit|64-bit|all])
920
921 fi
922
923
924 BASECFLAGS="${UNIVERSAL_ARCH_FLAGS} -isysroot ${UNIVERSALSDK} ${BASECFLAGS}"
Georg Brandl3dbca812008-07-23 16:10:53 +0000925 tgt=`sw_vers -productVersion | sed 's/\(10\.[[0-9]]*\).*/\1/'`
Benjamin Peterson67c38e22008-07-17 16:10:34 +0000926 if test "${UNIVERSALSDK}" != "/" -a "${tgt}" '>' '10.4' ; then
927 CFLAGS="${UNIVERSAL_ARCH_FLAGS} -isysroot ${UNIVERSALSDK} ${CFLAGS}"
928 fi
Thomas Wouters477c8d52006-05-27 19:21:47 +0000929 fi
930
Benjamin Peterson67c38e22008-07-17 16:10:34 +0000931 # Calculate the right deployment target for this build.
932 #
933 cur_target=`sw_vers -productVersion | sed 's/\(10\.[[0-9]]*\).*/\1/'`
934 if test ${cur_target} '>' 10.2; then
935 cur_target=10.3
Ronald Oussoren5bbab3e2009-09-06 11:01:15 +0000936 if test ${enable_universalsdk}; then
937 if test "${UNIVERSAL_ARCHS}" = "all"; then
938 # Ensure that the default platform for a
939 # 4-way universal build is OSX 10.5,
940 # that's the first OS release where
941 # 4-way builds make sense.
942 cur_target='10.5'
Ronald Oussoren3c064c12009-09-08 07:12:42 +0000943
944 elif test "${UNIVERSAL_ARCHS}" = "3-way"; then
945 cur_target='10.5'
946
947 elif test "${UNIVERSAL_ARCHS}" = "intel"; then
948 cur_target='10.5'
949
950 elif test "${UNIVERSAL_ARCHS}" = "64-bit"; then
951 cur_target='10.5'
Ronald Oussoren5bbab3e2009-09-06 11:01:15 +0000952 fi
953 else
954 if test `arch` = "i386"; then
955 # On Intel macs default to a deployment
956 # target of 10.4, that's the first OSX
957 # release with Intel support.
958 cur_target="10.4"
959 fi
960 fi
Benjamin Peterson67c38e22008-07-17 16:10:34 +0000961 fi
962 CONFIGURE_MACOSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET-${cur_target}}
963
964 # Make sure that MACOSX_DEPLOYMENT_TARGET is set in the
965 # environment with a value that is the same as what we'll use
966 # in the Makefile to ensure that we'll get the same compiler
967 # environment during configure and build time.
968 MACOSX_DEPLOYMENT_TARGET="$CONFIGURE_MACOSX_DEPLOYMENT_TARGET"
969 export MACOSX_DEPLOYMENT_TARGET
970 EXPORT_MACOSX_DEPLOYMENT_TARGET=''
971
Skip Montanarodecc6a42003-01-01 20:07:49 +0000972 ;;
Thomas Wouters49fd7fa2006-04-21 10:40:58 +0000973 OSF*)
974 BASECFLAGS="$BASECFLAGS -mieee"
975 ;;
Skip Montanarodecc6a42003-01-01 20:07:49 +0000976 esac
977 ;;
978
979*)
980 case $ac_sys_system in
981 OpenUNIX*|UnixWare*)
982 BASECFLAGS="$BASECFLAGS -K pentium,host,inline,loop_unroll,alloca "
983 ;;
Neal Norwitzb44f1652003-05-26 14:11:55 +0000984 OSF*)
985 BASECFLAGS="$BASECFLAGS -ieee -std"
986 ;;
Skip Montanarodecc6a42003-01-01 20:07:49 +0000987 SCO_SV*)
988 BASECFLAGS="$BASECFLAGS -belf -Ki486 -DSCO5"
989 ;;
990 esac
991 ;;
992esac
993
Fred Drakee1ceaa02001-12-04 20:55:47 +0000994if test "$Py_DEBUG" = 'true'; then
995 :
996else
997 OPT="-DNDEBUG $OPT"
998fi
999
Guido van Rossum6f2260e1996-09-09 16:21:03 +00001000if test "$ac_arch_flags"
Guido van Rossumc5a39031996-07-31 17:35:03 +00001001then
Skip Montanarodecc6a42003-01-01 20:07:49 +00001002 BASECFLAGS="$BASECFLAGS $ac_arch_flags"
Guido van Rossumc5a39031996-07-31 17:35:03 +00001003fi
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001004
Neal Norwitz020c46a2006-01-07 21:39:28 +00001005# disable check for icc since it seems to pass, but generates a warning
1006if test "$CC" = icc
1007then
1008 ac_cv_opt_olimit_ok=no
1009fi
1010
Guido van Rossum91922671997-10-09 20:24:13 +00001011AC_MSG_CHECKING(whether $CC accepts -OPT:Olimit=0)
1012AC_CACHE_VAL(ac_cv_opt_olimit_ok,
1013[ac_save_cc="$CC"
1014CC="$CC -OPT:Olimit=0"
1015AC_TRY_RUN([int main() { return 0; }],
1016 ac_cv_opt_olimit_ok=yes,
Guido van Rossum3065c942001-09-17 04:03:14 +00001017 ac_cv_opt_olimit_ok=no,
Guido van Rossum91922671997-10-09 20:24:13 +00001018 ac_cv_opt_olimit_ok=no)
1019CC="$ac_save_cc"])
1020AC_MSG_RESULT($ac_cv_opt_olimit_ok)
Guido van Rossum2efa34b1997-10-23 17:43:11 +00001021if test $ac_cv_opt_olimit_ok = yes; then
Guido van Rossum5839e582000-10-09 19:52:35 +00001022 case $ac_sys_system in
Skip Montanarodecc6a42003-01-01 20:07:49 +00001023 # XXX is this branch needed? On MacOSX 10.2.2 the result of the
1024 # olimit_ok test is "no". Is it "yes" in some other Darwin-esque
1025 # environment?
1026 Darwin*)
1027 ;;
1028 *)
1029 BASECFLAGS="$BASECFLAGS -OPT:Olimit=0"
1030 ;;
Guido van Rossum5839e582000-10-09 19:52:35 +00001031 esac
Guido van Rossumf8678121998-07-07 21:05:09 +00001032else
1033 AC_MSG_CHECKING(whether $CC accepts -Olimit 1500)
1034 AC_CACHE_VAL(ac_cv_olimit_ok,
1035 [ac_save_cc="$CC"
1036 CC="$CC -Olimit 1500"
1037 AC_TRY_RUN([int main() { return 0; }],
1038 ac_cv_olimit_ok=yes,
Guido van Rossum3065c942001-09-17 04:03:14 +00001039 ac_cv_olimit_ok=no,
Guido van Rossumf8678121998-07-07 21:05:09 +00001040 ac_cv_olimit_ok=no)
1041 CC="$ac_save_cc"])
1042 AC_MSG_RESULT($ac_cv_olimit_ok)
1043 if test $ac_cv_olimit_ok = yes; then
Skip Montanarodecc6a42003-01-01 20:07:49 +00001044 BASECFLAGS="$BASECFLAGS -Olimit 1500"
Guido van Rossumf8678121998-07-07 21:05:09 +00001045 fi
Guido van Rossum201afe51997-05-14 21:14:44 +00001046fi
Guido van Rossumf8678121998-07-07 21:05:09 +00001047
Thomas Wouters89f507f2006-12-13 04:49:30 +00001048# Check whether GCC supports PyArg_ParseTuple format
1049if test "$GCC" = "yes"
1050then
1051 AC_MSG_CHECKING(whether gcc supports ParseTuple __format__)
1052 save_CFLAGS=$CFLAGS
1053 CFLAGS="$CFLAGS -Werror"
1054 AC_TRY_COMPILE([
1055 void f(char*,...)__attribute((format(PyArg_ParseTuple, 1, 2)));
1056 ],,
1057 AC_DEFINE(HAVE_ATTRIBUTE_FORMAT_PARSETUPLE, 1, [Define if GCC supports __attribute__((format(PyArg_ParseTuple, 2, 3)))])
1058 AC_MSG_RESULT(yes),
1059 AC_MSG_RESULT(no)
1060 )
1061 CFLAGS=$save_CFLAGS
1062fi
1063
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00001064# On some compilers, pthreads are available without further options
1065# (e.g. MacOS X). On some of these systems, the compiler will not
1066# complain if unaccepted options are passed (e.g. gcc on Mac OS X).
1067# So we have to see first whether pthreads are available without
1068# options before we can check whether -Kpthread improves anything.
1069AC_MSG_CHECKING(whether pthreads are available without options)
1070AC_CACHE_VAL(ac_cv_pthread_is_default,
1071[AC_TRY_RUN([
1072#include <pthread.h>
1073
1074void* routine(void* p){return NULL;}
1075
1076int main(){
1077 pthread_t p;
1078 if(pthread_create(&p,NULL,routine,NULL)!=0)
1079 return 1;
Jack Jansen4f8d0542002-03-08 13:43:01 +00001080 (void)pthread_detach(p);
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00001081 return 0;
1082}
1083],
Skip Montanarod8d39a02003-07-10 20:44:10 +00001084[
1085 ac_cv_pthread_is_default=yes
1086 ac_cv_kthread=no
1087 ac_cv_pthread=no
1088],
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00001089 ac_cv_pthread_is_default=no,
1090 ac_cv_pthread_is_default=no)
1091])
1092AC_MSG_RESULT($ac_cv_pthread_is_default)
1093
1094
1095if test $ac_cv_pthread_is_default = yes
1096then
1097 ac_cv_kpthread=no
1098else
Martin v. Löwis130fb172001-07-19 11:00:41 +00001099# -Kpthread, if available, provides the right #defines
1100# and linker options to make pthread_create available
Martin v. Löwis260aecc2001-10-07 08:14:41 +00001101# Some compilers won't report that they do not support -Kpthread,
1102# so we need to run a program to see whether it really made the
1103# function available.
Martin v. Löwis130fb172001-07-19 11:00:41 +00001104AC_MSG_CHECKING(whether $CC accepts -Kpthread)
1105AC_CACHE_VAL(ac_cv_kpthread,
1106[ac_save_cc="$CC"
1107CC="$CC -Kpthread"
Martin v. Löwis260aecc2001-10-07 08:14:41 +00001108AC_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öwis260aecc2001-10-07 08:14:41 +00001118 return 0;
1119}
1120],
Martin v. Löwis130fb172001-07-19 11:00:41 +00001121 ac_cv_kpthread=yes,
Martin v. Löwis260aecc2001-10-07 08:14:41 +00001122 ac_cv_kpthread=no,
Martin v. Löwis130fb172001-07-19 11:00:41 +00001123 ac_cv_kpthread=no)
1124CC="$ac_save_cc"])
Martin v. Löwis130fb172001-07-19 11:00:41 +00001125AC_MSG_RESULT($ac_cv_kpthread)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00001126fi
Martin v. Löwis130fb172001-07-19 11:00:41 +00001127
Skip Montanarod8d39a02003-07-10 20:44:10 +00001128if test $ac_cv_kpthread = no -a $ac_cv_pthread_is_default = no
Martin v. Löwis5f433f02003-05-05 05:05:30 +00001129then
1130# -Kthread, if available, provides the right #defines
1131# and linker options to make pthread_create available
1132# Some compilers won't report that they do not support -Kthread,
1133# so we need to run a program to see whether it really made the
1134# function available.
1135AC_MSG_CHECKING(whether $CC accepts -Kthread)
1136AC_CACHE_VAL(ac_cv_kthread,
1137[ac_save_cc="$CC"
1138CC="$CC -Kthread"
1139AC_TRY_RUN([
1140#include <pthread.h>
1141
1142void* routine(void* p){return NULL;}
1143
1144int main(){
1145 pthread_t p;
1146 if(pthread_create(&p,NULL,routine,NULL)!=0)
1147 return 1;
1148 (void)pthread_detach(p);
1149 return 0;
1150}
1151],
1152 ac_cv_kthread=yes,
1153 ac_cv_kthread=no,
1154 ac_cv_kthread=no)
1155CC="$ac_save_cc"])
1156AC_MSG_RESULT($ac_cv_kthread)
1157fi
1158
Skip Montanarod8d39a02003-07-10 20:44:10 +00001159if test $ac_cv_kthread = no -a $ac_cv_pthread_is_default = no
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00001160then
1161# -pthread, if available, provides the right #defines
1162# and linker options to make pthread_create available
1163# Some compilers won't report that they do not support -pthread,
1164# so we need to run a program to see whether it really made the
1165# function available.
1166AC_MSG_CHECKING(whether $CC accepts -pthread)
1167AC_CACHE_VAL(ac_cv_thread,
1168[ac_save_cc="$CC"
1169CC="$CC -pthread"
1170AC_TRY_RUN([
1171#include <pthread.h>
1172
1173void* routine(void* p){return NULL;}
1174
1175int main(){
1176 pthread_t p;
1177 if(pthread_create(&p,NULL,routine,NULL)!=0)
1178 return 1;
1179 (void)pthread_detach(p);
1180 return 0;
1181}
1182],
1183 ac_cv_pthread=yes,
1184 ac_cv_pthread=no,
1185 ac_cv_pthread=no)
1186CC="$ac_save_cc"])
1187AC_MSG_RESULT($ac_cv_pthread)
1188fi
1189
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001190# If we have set a CC compiler flag for thread support then
1191# check if it works for CXX, too.
1192ac_cv_cxx_thread=no
1193if test ! -z "$CXX"
1194then
1195AC_MSG_CHECKING(whether $CXX also accepts flags for thread support)
1196ac_save_cxx="$CXX"
1197
1198if test "$ac_cv_kpthread" = "yes"
1199then
Martin v. Löwis519adae2003-09-20 10:47:47 +00001200 CXX="$CXX -Kpthread"
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001201 ac_cv_cxx_thread=yes
1202elif test "$ac_cv_kthread" = "yes"
1203then
1204 CXX="$CXX -Kthread"
1205 ac_cv_cxx_thread=yes
1206elif test "$ac_cv_pthread" = "yes"
1207then
1208 CXX="$CXX -pthread"
1209 ac_cv_cxx_thread=yes
1210fi
1211
1212if test $ac_cv_cxx_thread = yes
1213then
1214 echo 'void foo();int main(){foo();}void foo(){}' > conftest.$ac_ext
1215 $CXX -c conftest.$ac_ext 2>&5
1216 if $CXX -o conftest$ac_exeext conftest.$ac_objext 2>&5 \
1217 && test -s conftest$ac_exeext && ./conftest$ac_exeext
1218 then
1219 ac_cv_cxx_thread=yes
1220 else
1221 ac_cv_cxx_thread=no
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001222 fi
1223 rm -fr conftest*
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001224fi
Brett Cannonc601e0f2004-11-07 01:24:12 +00001225AC_MSG_RESULT($ac_cv_cxx_thread)
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001226fi
Martin v. Löwis519adae2003-09-20 10:47:47 +00001227CXX="$ac_save_cxx"
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001228
Fred Drakece81d592000-07-09 14:39:29 +00001229dnl # check for ANSI or K&R ("traditional") preprocessor
1230dnl AC_MSG_CHECKING(for C preprocessor type)
1231dnl AC_TRY_COMPILE([
1232dnl #define spam(name, doc) {#name, &name, #name "() -- " doc}
1233dnl int foo;
1234dnl struct {char *name; int *addr; char *doc;} desc = spam(foo, "something");
1235dnl ], [;], cpp_type=ansi, AC_DEFINE(HAVE_OLD_CPP) cpp_type=traditional)
1236dnl AC_MSG_RESULT($cpp_type)
Guido van Rossum300fda71996-08-19 21:58:16 +00001237
Guido van Rossum627b2d71993-12-24 10:39:16 +00001238# checks for header files
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001239AC_HEADER_STDC
Thomas Wouters0e3f5912006-08-11 14:57:12 +00001240AC_CHECK_HEADERS(asm/types.h conio.h curses.h direct.h dlfcn.h errno.h \
1241fcntl.h grp.h \
Christian Heimesbbe741d2008-03-28 10:53:29 +00001242ieeefp.h io.h langinfo.h libintl.h ncurses.h poll.h process.h pthread.h \
Thomas Wouters89f507f2006-12-13 04:49:30 +00001243shadow.h signal.h stdint.h stropts.h termios.h thread.h \
Martin v. Löwis14e73b12003-01-01 09:51:12 +00001244unistd.h utime.h \
Christian Heimes4fbc72b2008-03-22 00:47:35 +00001245sys/audioio.h sys/bsdtty.h sys/epoll.h sys/event.h sys/file.h sys/loadavg.h \
1246sys/lock.h sys/mkdev.h sys/modem.h \
Thomas Wouters0e3f5912006-08-11 14:57:12 +00001247sys/param.h sys/poll.h sys/select.h sys/socket.h sys/statvfs.h sys/stat.h \
Georg Brandlf78e02b2008-06-10 17:40:04 +00001248sys/termio.h sys/time.h \
Thomas Wouters0e3f5912006-08-11 14:57:12 +00001249sys/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 +00001250sys/resource.h netpacket/packet.h sysexits.h bluetooth.h \
Christian Heimes043d6f62008-01-07 17:19:16 +00001251bluetooth/bluetooth.h linux/tipc.h)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001252AC_HEADER_DIRENT
Martin v. Löwisdbe3f762002-10-10 14:27:30 +00001253AC_HEADER_MAJOR
Guido van Rossum627b2d71993-12-24 10:39:16 +00001254
Martin v. Löwisae2830c2004-09-18 09:54:52 +00001255# On Solaris, term.h requires curses.h
Martin v. Löwisfd1c69e72004-11-30 22:09:37 +00001256AC_CHECK_HEADERS(term.h,,,[
Martin v. Löwis5d52e782004-09-18 10:07:03 +00001257#ifdef HAVE_CURSES_H
1258#include <curses.h>
1259#endif
1260])
Martin v. Löwisae2830c2004-09-18 09:54:52 +00001261
Martin v. Löwis11017b12006-01-14 18:12:57 +00001262# On Linux, netlink.h requires asm/types.h
1263AC_CHECK_HEADERS(linux/netlink.h,,,[
1264#ifdef HAVE_ASM_TYPES_H
1265#include <asm/types.h>
1266#endif
1267#ifdef HAVE_SYS_SOCKET_H
1268#include <sys/socket.h>
1269#endif
1270])
1271
Guido van Rossum627b2d71993-12-24 10:39:16 +00001272# checks for typedefs
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001273was_it_defined=no
1274AC_MSG_CHECKING(for clock_t in time.h)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001275AC_EGREP_HEADER(clock_t, time.h, was_it_defined=yes, [
1276 AC_DEFINE(clock_t, long, [Define to 'long' if <time.h> doesn't define.])
1277])
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001278AC_MSG_RESULT($was_it_defined)
1279
Neal Norwitz11690112002-07-30 01:08:28 +00001280# Check whether using makedev requires defining _OSF_SOURCE
1281AC_MSG_CHECKING(for makedev)
Neal Norwitz6eb37f02003-02-23 23:28:15 +00001282AC_TRY_LINK([#include <sys/types.h> ],
Neal Norwitz11690112002-07-30 01:08:28 +00001283 [ makedev(0, 0) ],
1284 ac_cv_has_makedev=yes,
1285 ac_cv_has_makedev=no)
1286if test "$ac_cv_has_makedev" = "no"; then
1287 # we didn't link, try if _OSF_SOURCE will allow us to link
1288 AC_TRY_LINK([
Neal Norwitz6eb37f02003-02-23 23:28:15 +00001289#define _OSF_SOURCE 1
1290#include <sys/types.h>
Neal Norwitz11690112002-07-30 01:08:28 +00001291 ],
1292 [ makedev(0, 0) ],
1293 ac_cv_has_makedev=yes,
1294 ac_cv_has_makedev=no)
1295 if test "$ac_cv_has_makedev" = "yes"; then
1296 AC_DEFINE(_OSF_SOURCE, 1, [Define _OSF_SOURCE to get the makedev macro.])
1297 fi
1298fi
1299AC_MSG_RESULT($ac_cv_has_makedev)
1300if test "$ac_cv_has_makedev" = "yes"; then
1301 AC_DEFINE(HAVE_MAKEDEV, 1, [Define this if you have the makedev macro.])
1302fi
1303
Martin v. Löwis399a6892002-10-04 10:22:02 +00001304# Enabling LFS on Solaris (2.6 to 9) with gcc 2.95 triggers a bug in
1305# the system headers: If _XOPEN_SOURCE and _LARGEFILE_SOURCE are
1306# defined, but the compiler does not support pragma redefine_extname,
1307# and _LARGEFILE64_SOURCE is not defined, the headers refer to 64-bit
1308# structures (such as rlimit64) without declaring them. As a
1309# work-around, disable LFS on such configurations
1310
1311use_lfs=yes
1312AC_MSG_CHECKING(Solaris LFS bug)
1313AC_TRY_COMPILE([
1314#define _LARGEFILE_SOURCE 1
1315#define _FILE_OFFSET_BITS 64
1316#include <sys/resource.h>
1317],struct rlimit foo;,sol_lfs_bug=no,sol_lfs_bug=yes)
1318AC_MSG_RESULT($sol_lfs_bug)
1319if test "$sol_lfs_bug" = "yes"; then
1320 use_lfs=no
1321fi
1322
1323if test "$use_lfs" = "yes"; then
Guido van Rossum810cc512001-09-09 23:51:39 +00001324# Two defines needed to enable largefile support on various platforms
1325# These may affect some typedefs
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001326AC_DEFINE(_LARGEFILE_SOURCE, 1,
1327[This must be defined on some systems to enable large file support.])
1328AC_DEFINE(_FILE_OFFSET_BITS, 64,
1329[This must be set to 64 on some systems to enable large file support.])
Martin v. Löwis399a6892002-10-04 10:22:02 +00001330fi
Guido van Rossum810cc512001-09-09 23:51:39 +00001331
Guido van Rossum300fda71996-08-19 21:58:16 +00001332# Add some code to confdefs.h so that the test for off_t works on SCO
1333cat >> confdefs.h <<\EOF
1334#if defined(SCO_DS)
1335#undef _OFF_T
1336#endif
1337EOF
1338
Guido van Rossumef2255b2000-03-10 22:30:29 +00001339# Type availability checks
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001340AC_TYPE_MODE_T
1341AC_TYPE_OFF_T
1342AC_TYPE_PID_T
1343AC_TYPE_SIGNAL
1344AC_TYPE_SIZE_T
1345AC_TYPE_UID_T
Mark Dickinsonbd792642009-03-18 20:06:12 +00001346AC_TYPE_UINT32_T
1347AC_TYPE_UINT64_T
1348AC_TYPE_INT32_T
1349AC_TYPE_INT64_T
Christian Heimes400adb02008-02-01 08:12:03 +00001350AC_CHECK_TYPE(ssize_t,
Martin v. Löwis18e16552006-02-15 17:27:45 +00001351 AC_DEFINE(HAVE_SSIZE_T, 1, Define if your compiler provides ssize_t),,)
Guido van Rossum627b2d71993-12-24 10:39:16 +00001352
Guido van Rossumef2255b2000-03-10 22:30:29 +00001353# Sizes of various common basic types
Skip Montanarob9820a32004-01-17 00:16:12 +00001354# ANSI C requires sizeof(char) == 1, so no need to check it
Guido van Rossum3065c942001-09-17 04:03:14 +00001355AC_CHECK_SIZEOF(int, 4)
1356AC_CHECK_SIZEOF(long, 4)
1357AC_CHECK_SIZEOF(void *, 4)
Guido van Rossum3065c942001-09-17 04:03:14 +00001358AC_CHECK_SIZEOF(short, 2)
1359AC_CHECK_SIZEOF(float, 4)
1360AC_CHECK_SIZEOF(double, 8)
1361AC_CHECK_SIZEOF(fpos_t, 4)
Martin v. Löwis18e16552006-02-15 17:27:45 +00001362AC_CHECK_SIZEOF(size_t, 4)
Christian Heimes400adb02008-02-01 08:12:03 +00001363AC_CHECK_SIZEOF(pid_t, 4)
Guido van Rossumac405f61994-09-12 10:56:06 +00001364
Guido van Rossumec95c7b1998-08-04 17:59:56 +00001365AC_MSG_CHECKING(for long long support)
1366have_long_long=no
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001367AC_TRY_COMPILE([], [long long x; x = (long long)0;], [
1368 AC_DEFINE(HAVE_LONG_LONG, 1, [Define this if you have the type long long.])
1369 have_long_long=yes
1370])
Guido van Rossumec95c7b1998-08-04 17:59:56 +00001371AC_MSG_RESULT($have_long_long)
Guido van Rossum8bc1dfd1999-04-10 16:01:48 +00001372if test "$have_long_long" = yes ; then
Guido van Rossum3065c942001-09-17 04:03:14 +00001373AC_CHECK_SIZEOF(long long, 8)
Guido van Rossumec95c7b1998-08-04 17:59:56 +00001374fi
1375
Travis E. Oliphant9b307842007-10-12 22:06:37 +00001376AC_MSG_CHECKING(for long double support)
1377have_long_double=no
1378AC_TRY_COMPILE([], [long double x; x = (long double)0;], [
1379 AC_DEFINE(HAVE_LONG_DOUBLE, 1, [Define this if you have the type long double.])
1380 have_long_double=yes
1381])
1382AC_MSG_RESULT($have_long_double)
1383if test "$have_long_double" = yes ; then
1384AC_CHECK_SIZEOF(long double, 16)
1385fi
1386
1387
Thomas Woutersb2137042007-02-01 18:02:27 +00001388AC_MSG_CHECKING(for _Bool support)
1389have_c99_bool=no
1390AC_TRY_COMPILE([], [_Bool x; x = (_Bool)0;], [
1391 AC_DEFINE(HAVE_C99_BOOL, 1, [Define this if you have the type _Bool.])
1392 have_c99_bool=yes
1393])
1394AC_MSG_RESULT($have_c99_bool)
1395if test "$have_c99_bool" = yes ; then
1396AC_CHECK_SIZEOF(_Bool, 1)
1397fi
1398
Thomas Wouters89f507f2006-12-13 04:49:30 +00001399AC_CHECK_TYPES(uintptr_t,
1400 [AC_CHECK_SIZEOF(uintptr_t, 4)],
1401 [], [#ifdef HAVE_STDINT_H
1402 #include <stdint.h>
1403 #endif])
1404
Alexandre Vassalotti0805b4a2009-07-17 05:47:33 +00001405AC_CHECK_SIZEOF(off_t, [], [
1406#ifdef HAVE_SYS_TYPES_H
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001407#include <sys/types.h>
Alexandre Vassalotti0805b4a2009-07-17 05:47:33 +00001408#endif
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001409])
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001410
1411AC_MSG_CHECKING(whether to enable large file support)
Guido van Rossum8bc1dfd1999-04-10 16:01:48 +00001412if test "$have_long_long" = yes -a \
1413 "$ac_cv_sizeof_off_t" -gt "$ac_cv_sizeof_long" -a \
1414 "$ac_cv_sizeof_long_long" -ge "$ac_cv_sizeof_off_t"; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001415 AC_DEFINE(HAVE_LARGEFILE_SUPPORT, 1,
1416 [Defined to enable large file support when an off_t is bigger than a long
1417 and long long is available and at least as big as an off_t. You may need
1418 to add some flags for configuration and compilation to enable this mode.
1419 (For Solaris and Linux, the necessary defines are already defined.)])
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001420 AC_MSG_RESULT(yes)
1421else
1422 AC_MSG_RESULT(no)
1423fi
1424
Alexandre Vassalotti0805b4a2009-07-17 05:47:33 +00001425AC_CHECK_SIZEOF(time_t, [], [
1426#ifdef HAVE_SYS_TYPES_H
1427#include <sys/types.h>
1428#endif
1429#ifdef HAVE_TIME_H
Fred Drakea3f6e912000-06-29 20:44:47 +00001430#include <time.h>
Alexandre Vassalotti0805b4a2009-07-17 05:47:33 +00001431#endif
Fred Drakea3f6e912000-06-29 20:44:47 +00001432])
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001433
Trent Mick635f6fb2000-08-23 21:33:05 +00001434# if have pthread_t then define SIZEOF_PTHREAD_T
Martin v. Löwis123cbd22001-07-19 14:21:10 +00001435ac_save_cc="$CC"
1436if test "$ac_cv_kpthread" = "yes"
1437then CC="$CC -Kpthread"
Martin v. Löwis5f433f02003-05-05 05:05:30 +00001438elif test "$ac_cv_kthread" = "yes"
1439then CC="$CC -Kthread"
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00001440elif test "$ac_cv_pthread" = "yes"
1441then CC="$CC -pthread"
Martin v. Löwis123cbd22001-07-19 14:21:10 +00001442fi
Alexandre Vassalotti0805b4a2009-07-17 05:47:33 +00001443
Trent Mick635f6fb2000-08-23 21:33:05 +00001444AC_MSG_CHECKING(for pthread_t)
1445have_pthread_t=no
Guido van Rossum12580492000-09-24 16:47:19 +00001446AC_TRY_COMPILE([#include <pthread.h>], [pthread_t x; x = *(pthread_t*)0;], have_pthread_t=yes)
Trent Mick635f6fb2000-08-23 21:33:05 +00001447AC_MSG_RESULT($have_pthread_t)
1448if test "$have_pthread_t" = yes ; then
Alexandre Vassalotti0805b4a2009-07-17 05:47:33 +00001449 AC_CHECK_SIZEOF(pthread_t, [], [
1450#ifdef HAVE_PTHREAD_H
Neal Norwitz6eb37f02003-02-23 23:28:15 +00001451#include <pthread.h>
Alexandre Vassalotti0805b4a2009-07-17 05:47:33 +00001452#endif
Trent Mick635f6fb2000-08-23 21:33:05 +00001453 ])
Trent Mick635f6fb2000-08-23 21:33:05 +00001454fi
Martin v. Löwis123cbd22001-07-19 14:21:10 +00001455CC="$ac_save_cc"
Trent Mick635f6fb2000-08-23 21:33:05 +00001456
Bob Ippolito7026a0a2005-03-28 23:23:47 +00001457AC_SUBST(OTHER_LIBTOOL_OPT)
1458case $ac_sys_system/$ac_sys_release in
Thomas Wouters49fd7fa2006-04-21 10:40:58 +00001459 Darwin/@<:@01567@:>@\..*)
Bob Ippolito7026a0a2005-03-28 23:23:47 +00001460 OTHER_LIBTOOL_OPT="-prebind -seg1addr 0x10000000"
1461 ;;
1462 Darwin/*)
1463 OTHER_LIBTOOL_OPT=""
1464 ;;
1465esac
1466
Ronald Oussoren5bbab3e2009-09-06 11:01:15 +00001467
1468ARCH_RUN_32BIT=""
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001469AC_SUBST(LIBTOOL_CRUFT)
1470case $ac_sys_system/$ac_sys_release in
Thomas Wouters49fd7fa2006-04-21 10:40:58 +00001471 Darwin/@<:@01567@:>@\..*)
Thomas Wouters477c8d52006-05-27 19:21:47 +00001472 LIBTOOL_CRUFT="-framework System -lcc_dynamic"
1473 if test "${enable_universalsdk}"; then
1474 :
1475 else
Ronald Oussoren5bbab3e2009-09-06 11:01:15 +00001476 LIBTOOL_CRUFT="${LIBTOOL_CRUFT} -arch_only `arch`"
Thomas Wouters477c8d52006-05-27 19:21:47 +00001477 fi
Jack Jansenb36687a2004-07-16 08:43:47 +00001478 LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -install_name $(PYTHONFRAMEWORKINSTALLDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansena3891ea2001-09-07 14:25:12 +00001479 LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -compatibility_version $(VERSION) -current_version $(VERSION)';;
Guido van Rossum5839e582000-10-09 19:52:35 +00001480 Darwin/*)
Bob Ippolito7026a0a2005-03-28 23:23:47 +00001481 gcc_version=`gcc -v 2>&1 | grep version | cut -d\ -f3`
1482 if test ${gcc_version} '<' 4.0
1483 then
1484 LIBTOOL_CRUFT="-lcc_dynamic"
1485 else
1486 LIBTOOL_CRUFT=""
1487 fi
Ronald Oussoren3c064c12009-09-08 07:12:42 +00001488 AC_TRY_RUN([
Ronald Oussoren5bbab3e2009-09-06 11:01:15 +00001489 #include <unistd.h>
1490 int main(int argc, char*argv[])
1491 {
1492 if (sizeof(long) == 4) {
1493 return 0;
1494 } else {
1495 return 1;
1496 }
Ronald Oussoren3c064c12009-09-08 07:12:42 +00001497 }
1498 ], ac_osx_32bit=yes,
Ronald Oussoren5bbab3e2009-09-06 11:01:15 +00001499 ac_osx_32bit=no,
Ronald Oussoren3c064c12009-09-08 07:12:42 +00001500 ac_osx_32bit=yes)
Ronald Oussoren5bbab3e2009-09-06 11:01:15 +00001501
1502 if test "${ac_osx_32bit}" = "yes"; then
1503 case `arch` in
1504 i386)
1505 MACOSX_DEFAULT_ARCH="i386"
1506 ;;
1507 ppc)
1508 MACOSX_DEFAULT_ARCH="ppc"
1509 ;;
1510 *)
1511 AC_MSG_ERROR([Unexpected output of 'arch' on OSX])
1512 ;;
1513 esac
1514 else
1515 case `arch` in
1516 i386)
1517 MACOSX_DEFAULT_ARCH="x86_64"
1518 ;;
1519 ppc)
1520 MACOSX_DEFAULT_ARCH="ppc64"
1521 ;;
1522 *)
1523 AC_MSG_ERROR([Unexpected output of 'arch' on OSX])
1524 ;;
1525 esac
1526
1527 #ARCH_RUN_32BIT="true"
1528 fi
1529
1530 LIBTOOL_CRUFT=$LIBTOOL_CRUFT" -lSystem -lSystemStubs -arch_only ${MACOSX_DEFAULT_ARCH}"
Jack Jansenb36687a2004-07-16 08:43:47 +00001531 LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -install_name $(PYTHONFRAMEWORKINSTALLDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001532 LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -compatibility_version $(VERSION) -current_version $(VERSION)';;
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001533esac
1534
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001535AC_MSG_CHECKING(for --enable-framework)
1536if test "$enable_framework"
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001537then
Skip Montanarodecc6a42003-01-01 20:07:49 +00001538 BASECFLAGS="$BASECFLAGS -fno-common -dynamic"
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001539 # -F. is needed to allow linking to the framework while
1540 # in the build location.
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001541 AC_DEFINE(WITH_NEXT_FRAMEWORK, 1,
1542 [Define if you want to produce an OpenStep/Rhapsody framework
1543 (shared library plus accessory files).])
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001544 AC_MSG_RESULT(yes)
Ronald Oussoren99aab652009-06-08 21:22:57 +00001545 if test $enable_shared = "yes"
1546 then
1547 AC_MSG_ERROR([Specifying both --enable-shared and --enable-framework is not supported, use only --enable-framework instead])
1548 fi
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001549else
1550 AC_MSG_RESULT(no)
1551fi
1552
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001553AC_MSG_CHECKING(for dyld)
Jack Jansen9a66b6d2001-08-08 13:56:14 +00001554case $ac_sys_system/$ac_sys_release in
1555 Darwin/*)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001556 AC_DEFINE(WITH_DYLD, 1,
1557 [Define if you want to use the new-style (Openstep, Rhapsody, MacOS)
1558 dynamic linker (dyld) instead of the old-style (NextStep) dynamic
1559 linker (rld). Dyld is necessary to support frameworks.])
Jack Jansen9a66b6d2001-08-08 13:56:14 +00001560 AC_MSG_RESULT(always on for Darwin)
1561 ;;
1562 *)
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001563 AC_MSG_RESULT(no)
1564 ;;
Jack Jansen9a66b6d2001-08-08 13:56:14 +00001565esac
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001566
Guido van Rossumac405f61994-09-12 10:56:06 +00001567# Set info about shared libraries.
Guido van Rossumac405f61994-09-12 10:56:06 +00001568AC_SUBST(SO)
1569AC_SUBST(LDSHARED)
Neil Schemenauerb3531b82001-02-16 04:09:05 +00001570AC_SUBST(BLDSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00001571AC_SUBST(CCSHARED)
1572AC_SUBST(LINKFORSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00001573# SO is the extension of shared libraries `(including the dot!)
Guido van Rossumaef734b2001-01-10 21:09:12 +00001574# -- usually .so, .sl on HP-UX, .dll on Cygwin
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001575AC_MSG_CHECKING(SO)
Guido van Rossumac405f61994-09-12 10:56:06 +00001576if test -z "$SO"
1577then
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001578 case $ac_sys_system in
Thomas Wouters477c8d52006-05-27 19:21:47 +00001579 hp*|HP*)
1580 case `uname -m` in
1581 ia64) SO=.so;;
1582 *) SO=.sl;;
1583 esac
1584 ;;
Guido van Rossumaef734b2001-01-10 21:09:12 +00001585 CYGWIN*) SO=.dll;;
Guido van Rossum4b6b5791996-09-09 20:09:34 +00001586 *) SO=.so;;
Guido van Rossumac405f61994-09-12 10:56:06 +00001587 esac
Martin v. Löwis368de8f2003-06-14 14:46:38 +00001588else
1589 # this might also be a termcap variable, see #610332
1590 echo
1591 echo '====================================================================='
1592 echo '+ +'
1593 echo '+ WARNING: You have set SO in your environment. +'
1594 echo '+ Do you really mean to change the extension for shared libraries? +'
1595 echo '+ Continuing in 10 seconds to let you to ponder. +'
1596 echo '+ +'
1597 echo '====================================================================='
1598 sleep 10
Guido van Rossumac405f61994-09-12 10:56:06 +00001599fi
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001600AC_MSG_RESULT($SO)
Georg Brandlb1441c72009-01-03 22:33:39 +00001601
Thomas Wouters477c8d52006-05-27 19:21:47 +00001602AC_DEFINE_UNQUOTED(SHLIB_EXT, "$SO", [Define this to be extension of shared libraries (including the dot!).])
Guido van Rossumac405f61994-09-12 10:56:06 +00001603# LDSHARED is the ld *command* used to create shared library
Skip Montanaroce59c042004-01-17 14:19:44 +00001604# -- "cc -G" on SunOS 5.x, "ld -shared" on IRIX 5
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001605# (Shared libraries in this instance are shared modules to be loaded into
1606# Python, as opposed to building Python itself as a shared library.)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001607AC_MSG_CHECKING(LDSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00001608if test -z "$LDSHARED"
1609then
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001610 case $ac_sys_system/$ac_sys_release in
Neil Schemenauerb3531b82001-02-16 04:09:05 +00001611 AIX*)
1612 BLDSHARED="\$(srcdir)/Modules/ld_so_aix \$(CC) -bI:Modules/python.exp"
Guido van Rossumce608b02001-09-28 15:59:38 +00001613 LDSHARED="\$(BINLIBDEST)/config/ld_so_aix \$(CC) -bI:\$(BINLIBDEST)/config/python.exp"
Neil Schemenauerb3531b82001-02-16 04:09:05 +00001614 ;;
Guido van Rossum6100aaf1997-04-29 21:48:51 +00001615 IRIX/5*) LDSHARED="ld -shared";;
Guido van Rossum91922671997-10-09 20:24:13 +00001616 IRIX*/6*) LDSHARED="ld ${SGI_ABI} -shared -all";;
Greg Ward57c9a6632000-05-26 12:22:54 +00001617 SunOS/5*)
1618 if test "$GCC" = "yes"
Neil Schemenauer95052722001-02-19 18:17:33 +00001619 then LDSHARED='$(CC) -shared'
Martin v. Löwisaa5afe12002-10-07 06:21:41 +00001620 else LDSHARED='$(CC) -G';
Greg Ward57c9a6632000-05-26 12:22:54 +00001621 fi ;;
Thomas Hellerf44b9a12008-04-04 10:18:23 +00001622 hp*|HP*)
1623 if test "$GCC" = "yes"
1624 then LDSHARED='$(CC) -shared'
1625 else LDSHARED='ld -b';
1626 fi ;;
Guido van Rossum71001e41995-01-26 00:44:03 +00001627 OSF*) LDSHARED="ld -shared -expect_unresolved \"*\"";;
Jack Jansen418c3b12001-11-14 10:59:57 +00001628 Darwin/1.3*)
Jack Jansena3891ea2001-09-07 14:25:12 +00001629 LDSHARED='$(CC) $(LDFLAGS) -bundle'
1630 if test "$enable_framework" ; then
1631 # Link against the framework. All externals should be defined.
Jack Jansenda49e192005-01-07 13:08:22 +00001632 BLDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
1633 LDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansena3891ea2001-09-07 14:25:12 +00001634 else
1635 # No framework. Ignore undefined symbols, assuming they come from Python
Jack Jansen418c3b12001-11-14 10:59:57 +00001636 LDSHARED="$LDSHARED -undefined suppress"
Jack Jansena3891ea2001-09-07 14:25:12 +00001637 fi ;;
Jack Jansen6b08a402004-06-03 12:41:45 +00001638 Darwin/1.4*|Darwin/5.*|Darwin/6.*)
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001639 LDSHARED='$(CC) $(LDFLAGS) -bundle'
1640 if test "$enable_framework" ; then
1641 # Link against the framework. All externals should be defined.
Jack Jansenda49e192005-01-07 13:08:22 +00001642 BLDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
1643 LDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001644 else
Michael W. Hudson0c46c0c2002-03-07 09:58:56 +00001645 # No framework, use the Python app as bundle-loader
1646 BLDSHARED="$LDSHARED "'-bundle_loader $(BUILDPYTHON)'
Jack Jansenc28fc372003-02-25 13:14:43 +00001647 LDSHARED="$LDSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)'
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001648 fi ;;
Jack Jansen6b08a402004-06-03 12:41:45 +00001649 Darwin/*)
1650 # Use -undefined dynamic_lookup whenever possible (10.3 and later).
1651 # This allows an extension to be used in any Python
Thomas Wouters89d996e2007-09-08 17:39:28 +00001652
Georg Brandlfcaf9102008-07-16 02:17:56 +00001653 if test ${MACOSX_DEPLOYMENT_TARGET} '>' 10.2
Jack Jansen6b08a402004-06-03 12:41:45 +00001654 then
Thomas Wouters477c8d52006-05-27 19:21:47 +00001655 if test "${enable_universalsdk}"; then
Georg Brandlfcaf9102008-07-16 02:17:56 +00001656 LDFLAGS="${UNIVERSAL_ARCH_FLAGS} -isysroot ${UNIVERSALSDK} ${LDFLAGS}"
Thomas Wouters477c8d52006-05-27 19:21:47 +00001657 fi
Jack Jansen6b08a402004-06-03 12:41:45 +00001658 LDSHARED='$(CC) $(LDFLAGS) -bundle -undefined dynamic_lookup'
1659 BLDSHARED="$LDSHARED"
Jack Jansen6b08a402004-06-03 12:41:45 +00001660 else
1661 LDSHARED='$(CC) $(LDFLAGS) -bundle'
1662 if test "$enable_framework" ; then
1663 # Link against the framework. All externals should be defined.
Jack Jansenda49e192005-01-07 13:08:22 +00001664 BLDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
1665 LDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansen6b08a402004-06-03 12:41:45 +00001666 else
1667 # No framework, use the Python app as bundle-loader
1668 BLDSHARED="$LDSHARED "'-bundle_loader $(BUILDPYTHON)'
1669 LDSHARED="$LDSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)'
1670 fi
1671 fi
1672 ;;
Georg Brandlf78e02b2008-06-10 17:40:04 +00001673 Linux*|GNU*|QNX*) LDSHARED='$(CC) -shared';;
Guido van Rossum458e7fa1999-09-17 15:40:40 +00001674 BSD/OS*/4*) LDSHARED="gcc -shared";;
Thomas Wouters1ba5b3b2006-06-08 14:52:47 +00001675 FreeBSD*)
Jeremy Hylton4bcc7c52000-08-31 17:45:35 +00001676 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
Guido van Rossum0286ae82000-08-29 15:06:49 +00001677 then
Hye-Shik Chang33761492004-10-26 09:53:46 +00001678 LDSHARED="$CC -shared ${LDFLAGS}"
Guido van Rossum0286ae82000-08-29 15:06:49 +00001679 else
1680 LDSHARED="ld -Bshareable ${LDFLAGS}"
1681 fi;;
Thomas Wouters1ba5b3b2006-06-08 14:52:47 +00001682 OpenBSD*)
1683 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
1684 then
1685 LDSHARED='$(CC) -shared $(CCSHARED) ${LDFLAGS}'
1686 else
1687 case `uname -r` in
1688 [[01]].* | 2.[[0-7]] | 2.[[0-7]].*)
1689 LDSHARED="ld -Bshareable ${LDFLAGS}"
1690 ;;
1691 *)
1692 LDSHARED='$(CC) -shared $(CCSHARED) ${LDFLAGS}'
1693 ;;
1694 esac
1695 fi;;
Martin v. Löwis86d66262006-02-17 08:40:11 +00001696 NetBSD*|DragonFly*) LDSHARED="cc -shared ${LDFLAGS}";;
Martin v. Löwis25ae43b2001-10-07 08:39:18 +00001697 OpenUNIX*|UnixWare*)
Martin v. Löwisbec19582001-03-21 15:57:54 +00001698 if test "$GCC" = "yes"
Martin v. Löwis79f3c532002-12-11 12:51:58 +00001699 then LDSHARED='$(CC) -shared'
1700 else LDSHARED='$(CC) -G'
Martin v. Löwisbec19582001-03-21 15:57:54 +00001701 fi;;
Martin v. Löwis79f3c532002-12-11 12:51:58 +00001702 SCO_SV*) LDSHARED='$(CC) -Wl,-G,-Bexport';;
Guido van Rossumaef734b2001-01-10 21:09:12 +00001703 CYGWIN*) LDSHARED="gcc -shared -Wl,--enable-auto-image-base";;
Martin v. Löwisf90ae202002-06-11 06:22:31 +00001704 atheos*) LDSHARED="gcc -shared";;
Guido van Rossumac405f61994-09-12 10:56:06 +00001705 *) LDSHARED="ld";;
1706 esac
Guido van Rossumac405f61994-09-12 10:56:06 +00001707fi
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001708AC_MSG_RESULT($LDSHARED)
Neil Schemenauerb3531b82001-02-16 04:09:05 +00001709BLDSHARED=${BLDSHARED-$LDSHARED}
Guido van Rossumac405f61994-09-12 10:56:06 +00001710# CCSHARED are the C *flags* used to create objects to go into a shared
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001711# library (module) -- this is only needed for a few systems
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001712AC_MSG_CHECKING(CCSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00001713if test -z "$CCSHARED"
1714then
Guido van Rossum6100aaf1997-04-29 21:48:51 +00001715 case $ac_sys_system/$ac_sys_release in
Neil Schemenauer66252162001-02-19 04:47:42 +00001716 SunOS*) if test "$GCC" = yes;
Guido van Rossumd8faa362007-04-27 19:54:29 +00001717 then CCSHARED="-fPIC";
1718 elif test `uname -p` = sparc;
1719 then CCSHARED="-xcode=pic32";
1720 else CCSHARED="-Kpic";
1721 fi;;
Guido van Rossumaf07a441995-02-13 19:45:27 +00001722 hp*|HP*) if test "$GCC" = yes;
Martin v. Löwis703ad702001-09-05 08:36:52 +00001723 then CCSHARED="-fPIC";
Guido van Rossumaf07a441995-02-13 19:45:27 +00001724 else CCSHARED="+z";
1725 fi;;
Martin v. Löwisa6e97582002-01-01 18:41:33 +00001726 Linux*|GNU*) CCSHARED="-fPIC";;
Guido van Rossumf5957ea1999-10-05 21:59:33 +00001727 BSD/OS*/4*) CCSHARED="-fpic";;
Martin v. Löwis86d66262006-02-17 08:40:11 +00001728 FreeBSD*|NetBSD*|OpenBSD*|DragonFly*) CCSHARED="-fPIC";;
Martin v. Löwis25ae43b2001-10-07 08:39:18 +00001729 OpenUNIX*|UnixWare*)
Martin v. Löwisbec19582001-03-21 15:57:54 +00001730 if test "$GCC" = "yes"
1731 then CCSHARED="-fPIC"
Martin v. Löwis130fb172001-07-19 11:00:41 +00001732 else CCSHARED="-KPIC"
Martin v. Löwisbec19582001-03-21 15:57:54 +00001733 fi;;
Martin v. Löwis21ee4092002-09-30 16:19:48 +00001734 SCO_SV*)
1735 if test "$GCC" = "yes"
1736 then CCSHARED="-fPIC"
1737 else CCSHARED="-Kpic -belf"
1738 fi;;
Guido van Rossum2b5ca001998-03-05 15:41:09 +00001739 IRIX*/6*) case $CC in
1740 *gcc*) CCSHARED="-shared";;
Guido van Rossumee21f411998-04-20 18:51:54 +00001741 *) CCSHARED="";;
Guido van Rossum2b5ca001998-03-05 15:41:09 +00001742 esac;;
Martin v. Löwisf90ae202002-06-11 06:22:31 +00001743 atheos*) CCSHARED="-fPIC";;
Guido van Rossumac405f61994-09-12 10:56:06 +00001744 esac
Guido van Rossumac405f61994-09-12 10:56:06 +00001745fi
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001746AC_MSG_RESULT($CCSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00001747# LINKFORSHARED are the flags passed to the $(CC) command that links
Guido van Rossumb65a48e1995-06-14 18:21:23 +00001748# the python executable -- this is only needed for a few systems
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001749AC_MSG_CHECKING(LINKFORSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00001750if test -z "$LINKFORSHARED"
1751then
Guido van Rossum6100aaf1997-04-29 21:48:51 +00001752 case $ac_sys_system/$ac_sys_release in
Neil Schemenauerb3531b82001-02-16 04:09:05 +00001753 AIX*) LINKFORSHARED='-Wl,-bE:Modules/python.exp -lld';;
Guido van Rossum5dab3d81996-12-06 21:18:18 +00001754 hp*|HP*)
Martin v. Löwis1142de32002-03-29 16:28:31 +00001755 LINKFORSHARED="-Wl,-E -Wl,+s";;
1756# LINKFORSHARED="-Wl,-E -Wl,+s -Wl,+b\$(BINLIBDEST)/lib-dynload";;
Guido van Rossumf5957ea1999-10-05 21:59:33 +00001757 BSD/OS/4*) LINKFORSHARED="-Xlinker -export-dynamic";;
Martin v. Löwisa6e97582002-01-01 18:41:33 +00001758 Linux*|GNU*) LINKFORSHARED="-Xlinker -export-dynamic";;
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001759 # -u libsys_s pulls in all symbols in libsys
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001760 Darwin/*)
Benjamin Peterson9c80cac2009-05-23 16:34:23 +00001761 LINKFORSHARED="$extra_undefs -framework CoreFoundation"
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001762 if test "$enable_framework"
1763 then
Jack Jansenda49e192005-01-07 13:08:22 +00001764 LINKFORSHARED="$LINKFORSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001765 fi
Raymond Hettingerec6eb362004-11-05 07:02:59 +00001766 LINKFORSHARED="$LINKFORSHARED";;
Martin v. Löwis25ae43b2001-10-07 08:39:18 +00001767 OpenUNIX*|UnixWare*) LINKFORSHARED="-Wl,-Bexport";;
Martin v. Löwis21ee4092002-09-30 16:19:48 +00001768 SCO_SV*) LINKFORSHARED="-Wl,-Bexport";;
Fred Drake02706f52000-09-25 15:08:46 +00001769 ReliantUNIX*) LINKFORSHARED="-W1 -Blargedynsym";;
Martin v. Löwis86d66262006-02-17 08:40:11 +00001770 FreeBSD*|NetBSD*|OpenBSD*|DragonFly*)
Guido van Rossumdf693651999-01-07 21:50:41 +00001771 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
1772 then
1773 LINKFORSHARED="-Wl,--export-dynamic"
1774 fi;;
Guido van Rossum2b5ca001998-03-05 15:41:09 +00001775 SunOS/5*) case $CC in
1776 *gcc*)
Martin v. Löwisa4548572002-04-18 14:51:36 +00001777 if $CC -Xlinker --help 2>&1 | grep export-dynamic >/dev/null
Guido van Rossum8f4ceb11997-12-18 23:42:19 +00001778 then
1779 LINKFORSHARED="-Xlinker --export-dynamic"
Guido van Rossum2b5ca001998-03-05 15:41:09 +00001780 fi;;
1781 esac;;
Jason Tishler30765592003-09-04 11:04:06 +00001782 CYGWIN*)
1783 if test $enable_shared = "no"
1784 then
1785 LINKFORSHARED='-Wl,--out-implib=$(LDLIBRARY)'
1786 fi;;
Georg Brandlf78e02b2008-06-10 17:40:04 +00001787 QNX*)
1788 # -Wl,-E causes the symbols to be added to the dynamic
1789 # symbol table so that they can be found when a module
1790 # is loaded. -N 2048K causes the stack size to be set
1791 # to 2048 kilobytes so that the stack doesn't overflow
1792 # when running test_compile.py.
1793 LINKFORSHARED='-Wl,-E -N 2048K';;
Guido van Rossumac405f61994-09-12 10:56:06 +00001794 esac
Guido van Rossumac405f61994-09-12 10:56:06 +00001795fi
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001796AC_MSG_RESULT($LINKFORSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00001797
Georg Brandl93de2162008-07-16 02:21:06 +00001798
Neil Schemenauer61c51152001-01-26 16:18:16 +00001799AC_SUBST(CFLAGSFORSHARED)
1800AC_MSG_CHECKING(CFLAGSFORSHARED)
1801if test ! "$LIBRARY" = "$LDLIBRARY"
1802then
Neil Schemenauerd9cf41c2001-01-27 21:39:17 +00001803 case $ac_sys_system in
1804 CYGWIN*)
1805 # Cygwin needs CCSHARED when building extension DLLs
1806 # but not when building the interpreter DLL.
1807 CFLAGSFORSHARED='';;
1808 *)
1809 CFLAGSFORSHARED='$(CCSHARED)'
1810 esac
Neil Schemenauer61c51152001-01-26 16:18:16 +00001811fi
1812AC_MSG_RESULT($CFLAGSFORSHARED)
1813
Martin v. Löwisf90ae202002-06-11 06:22:31 +00001814# SHLIBS are libraries (except -lc and -lm) to link to the python shared
1815# library (with --enable-shared).
1816# For platforms on which shared libraries are not allowed to have unresolved
Martin v. Löwisd6359c52002-08-04 12:38:50 +00001817# symbols, this must be set to $(LIBS) (expanded by make). We do this even
1818# if it is not required, since it creates a dependency of the shared library
1819# to LIBS. This, in turn, means that applications linking the shared libpython
1820# don't need to link LIBS explicitly. The default should be only changed
1821# on systems where this approach causes problems.
Martin v. Löwisf90ae202002-06-11 06:22:31 +00001822AC_SUBST(SHLIBS)
1823AC_MSG_CHECKING(SHLIBS)
1824case "$ac_sys_system" in
Martin v. Löwisf90ae202002-06-11 06:22:31 +00001825 *)
Martin v. Löwisd6359c52002-08-04 12:38:50 +00001826 SHLIBS='$(LIBS)';;
Martin v. Löwisf90ae202002-06-11 06:22:31 +00001827esac
1828AC_MSG_RESULT($SHLIBS)
1829
1830
Guido van Rossum627b2d71993-12-24 10:39:16 +00001831# checks for libraries
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001832AC_CHECK_LIB(dl, dlopen) # Dynamic linking for SunOS/Solaris and SYSV
1833AC_CHECK_LIB(dld, shl_load) # Dynamic linking for HP-UX
Martin v. Löwis519adae2003-09-20 10:47:47 +00001834
Georg Brandleee31162008-12-07 15:15:22 +00001835# only check for sem_init if thread support is requested
Martin v. Löwis519adae2003-09-20 10:47:47 +00001836if test "$with_threads" = "yes" -o -z "$with_threads"; then
1837 AC_SEARCH_LIBS(sem_init, pthread rt posix4) # 'Real Time' functions on Solaris
1838 # posix4 on Solaris 2.6
1839 # pthread (first!) on Linux
1840fi
1841
Martin v. Löwis19d17342003-06-14 21:03:05 +00001842# check if we need libintl for locale functions
1843AC_CHECK_LIB(intl, textdomain,
Brett Cannonc6d936e2009-06-07 20:09:53 +00001844 [AC_DEFINE(WITH_LIBINTL, 1,
1845 [Define to 1 if libintl is needed for locale functions.])
1846 LIBS="-lintl $LIBS"])
Guido van Rossum0eefa3f1999-11-16 15:57:37 +00001847
1848# checks for system dependent C++ extensions support
1849case "$ac_sys_system" in
1850 AIX*) AC_MSG_CHECKING(for genuine AIX C++ extensions support)
1851 AC_TRY_LINK([#include "/usr/lpp/xlC/include/load.h"],
1852 [loadAndInit("", 0, "")],
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001853 [AC_DEFINE(AIX_GENUINE_CPLUSPLUS, 1,
1854 [Define for AIX if your compiler is a genuine IBM xlC/xlC_r
1855 and you want support for AIX C++ shared extension modules.])
Guido van Rossum0eefa3f1999-11-16 15:57:37 +00001856 AC_MSG_RESULT(yes)],
1857 [AC_MSG_RESULT(no)]);;
1858 *) ;;
1859esac
1860
Guido van Rossum70c7f481998-03-26 18:44:10 +00001861# Most SVR4 platforms (e.g. Solaris) need -lsocket and -lnsl.
Guido van Rossumf618d2c1995-01-17 16:36:13 +00001862AC_CHECK_LIB(nsl, t_open, [LIBS="-lnsl $LIBS"]) # SVR4
Guido van Rossumf618d2c1995-01-17 16:36:13 +00001863AC_CHECK_LIB(socket, socket, [LIBS="-lsocket $LIBS"], [], $LIBS) # SVR4 sockets
Skip Montanarob9949db2004-01-17 04:04:13 +00001864
Guido van Rossumc5a39031996-07-31 17:35:03 +00001865AC_MSG_CHECKING(for --with-libs)
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00001866AC_ARG_WITH(libs,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00001867 AC_HELP_STRING(--with-libs='lib1 ...', link against additional libs),
1868[
Guido van Rossumc5a39031996-07-31 17:35:03 +00001869AC_MSG_RESULT($withval)
1870LIBS="$withval $LIBS"
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00001871],
1872[AC_MSG_RESULT(no)])
Guido van Rossum627b2d71993-12-24 10:39:16 +00001873
Thomas Wouters49fd7fa2006-04-21 10:40:58 +00001874# Check for use of the system libffi library
1875AC_MSG_CHECKING(for --with-system-ffi)
1876AC_ARG_WITH(system_ffi,
1877 AC_HELP_STRING(--with-system-ffi, build _ctypes module using an installed ffi library))
1878
Thomas Wouters49fd7fa2006-04-21 10:40:58 +00001879AC_MSG_RESULT($with_system_ffi)
1880
Matthias Klose55708cc2009-04-30 08:06:49 +00001881# Check for --with-dbmliborder
1882AC_MSG_CHECKING(for --with-dbmliborder)
1883AC_ARG_WITH(dbmliborder,
1884 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'.]),
1885[
1886if test x$with_dbmliborder = xyes
1887then
1888AC_MSG_ERROR([proper usage is --with-dbmliborder=db1:db2:...])
1889else
1890 for db in `echo $with_dbmliborder | sed 's/:/ /g'`; do
1891 if test x$db != xndbm && test x$db != xgdbm && test x$db != xbdb
1892 then
1893 AC_MSG_ERROR([proper usage is --with-dbmliborder=db1:db2:...])
1894 fi
1895 done
1896fi])
1897AC_MSG_RESULT($with_dbmliborder)
1898
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00001899# Determine if signalmodule should be used.
1900AC_SUBST(USE_SIGNAL_MODULE)
1901AC_SUBST(SIGNAL_OBJS)
1902AC_MSG_CHECKING(for --with-signal-module)
1903AC_ARG_WITH(signal-module,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00001904 AC_HELP_STRING(--with-signal-module, disable/enable signal module))
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00001905
1906if test -z "$with_signal_module"
1907then with_signal_module="yes"
1908fi
1909AC_MSG_RESULT($with_signal_module)
1910
1911if test "${with_signal_module}" = "yes"; then
1912 USE_SIGNAL_MODULE=""
1913 SIGNAL_OBJS=""
1914else
1915 USE_SIGNAL_MODULE="#"
1916 SIGNAL_OBJS="Parser/intrcheck.o Python/sigcheck.o"
1917fi
1918
Guido van Rossum3d15bd82001-01-10 18:53:48 +00001919# This is used to generate Setup.config
Guido van Rossum009f7871997-12-04 00:51:42 +00001920AC_SUBST(USE_THREAD_MODULE)
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00001921USE_THREAD_MODULE=""
Guido van Rossum009f7871997-12-04 00:51:42 +00001922
Guido van Rossum54d93d41997-01-22 20:51:58 +00001923AC_MSG_CHECKING(for --with-dec-threads)
1924AC_SUBST(LDLAST)
1925AC_ARG_WITH(dec-threads,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00001926 AC_HELP_STRING(--with-dec-threads, use DEC Alpha/OSF1 thread-safe libraries),
1927[
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00001928AC_MSG_RESULT($withval)
Guido van Rossum54d93d41997-01-22 20:51:58 +00001929LDLAST=-threads
Guido van Rossumf78abae1997-01-21 22:02:36 +00001930if test "${with_thread+set}" != set; then
Guido van Rossum54d93d41997-01-22 20:51:58 +00001931 with_thread="$withval";
1932fi],
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00001933[AC_MSG_RESULT(no)])
Guido van Rossum54d93d41997-01-22 20:51:58 +00001934
Martin v. Löwis11437992002-04-12 09:54:03 +00001935# Templates for things AC_DEFINEd more than once.
1936# For a single AC_DEFINE, no template is needed.
1937AH_TEMPLATE(C_THREADS,[Define if you have the Mach cthreads package])
1938AH_TEMPLATE(_REENTRANT,
1939 [Define to force use of thread-safe errno, h_errno, and other functions])
1940AH_TEMPLATE(WITH_THREAD,
1941 [Define if you want to compile in rudimentary thread support])
1942
Guido van Rossum54d93d41997-01-22 20:51:58 +00001943AC_MSG_CHECKING(for --with-threads)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00001944dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00001945AC_ARG_WITH(threads,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00001946 AC_HELP_STRING(--with(out)-threads@<:@=DIRECTORY@:>@, disable/enable thread support))
Guido van Rossum54d93d41997-01-22 20:51:58 +00001947
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00001948# --with-thread is deprecated, but check for it anyway
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00001949dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
Barry Warsawa0f3c5c2000-06-30 16:39:35 +00001950AC_ARG_WITH(thread,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00001951 AC_HELP_STRING(--with(out)-thread@<:@=DIRECTORY@:>@, deprecated; use --with(out)-threads),
1952 [with_threads=$with_thread])
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00001953
1954if test -z "$with_threads"
1955then with_threads="yes"
Guido van Rossum433c8ad1994-08-01 12:07:07 +00001956fi
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00001957AC_MSG_RESULT($with_threads)
Guido van Rossum6400c261997-05-22 20:34:27 +00001958
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00001959AC_SUBST(THREADOBJ)
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00001960if test "$with_threads" = "no"
1961then
1962 USE_THREAD_MODULE="#"
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00001963elif test "$ac_cv_pthread_is_default" = yes
1964then
1965 AC_DEFINE(WITH_THREAD)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00001966 # Defining _REENTRANT on system with POSIX threads should not hurt.
1967 AC_DEFINE(_REENTRANT)
1968 posix_threads=yes
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00001969 THREADOBJ="Python/thread.o"
Martin v. Löwis130fb172001-07-19 11:00:41 +00001970elif test "$ac_cv_kpthread" = "yes"
1971then
1972 CC="$CC -Kpthread"
Martin v. Löwis519adae2003-09-20 10:47:47 +00001973 if test "$ac_cv_cxx_thread" = "yes"; then
1974 CXX="$CXX -Kpthread"
1975 fi
Martin v. Löwis130fb172001-07-19 11:00:41 +00001976 AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00001977 posix_threads=yes
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00001978 THREADOBJ="Python/thread.o"
Martin v. Löwis5f433f02003-05-05 05:05:30 +00001979elif test "$ac_cv_kthread" = "yes"
1980then
1981 CC="$CC -Kthread"
Martin v. Löwis519adae2003-09-20 10:47:47 +00001982 if test "$ac_cv_cxx_thread" = "yes"; then
1983 CXX="$CXX -Kthread"
1984 fi
Martin v. Löwis5f433f02003-05-05 05:05:30 +00001985 AC_DEFINE(WITH_THREAD)
1986 posix_threads=yes
1987 THREADOBJ="Python/thread.o"
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00001988elif test "$ac_cv_pthread" = "yes"
1989then
1990 CC="$CC -pthread"
Martin v. Löwis519adae2003-09-20 10:47:47 +00001991 if test "$ac_cv_cxx_thread" = "yes"; then
1992 CXX="$CXX -pthread"
1993 fi
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00001994 AC_DEFINE(WITH_THREAD)
1995 posix_threads=yes
1996 THREADOBJ="Python/thread.o"
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00001997else
Martin v. Löwis130fb172001-07-19 11:00:41 +00001998 if test ! -z "$with_threads" -a -d "$with_threads"
1999 then LDFLAGS="$LDFLAGS -L$with_threads"
2000 fi
2001 if test ! -z "$withval" -a -d "$withval"
2002 then LDFLAGS="$LDFLAGS -L$withval"
2003 fi
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002004
2005 # According to the POSIX spec, a pthreads implementation must
Matthias Klosea2542be2004-08-16 11:35:51 +00002006 # define _POSIX_THREADS in unistd.h. Some apparently don't
2007 # (e.g. gnu pth with pthread emulation)
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002008 AC_MSG_CHECKING(for _POSIX_THREADS in unistd.h)
2009 AC_EGREP_CPP(yes,
Neal Norwitz6eb37f02003-02-23 23:28:15 +00002010 [
2011#include <unistd.h>
2012#ifdef _POSIX_THREADS
2013yes
2014#endif
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002015 ], unistd_defines_pthreads=yes, unistd_defines_pthreads=no)
2016 AC_MSG_RESULT($unistd_defines_pthreads)
2017
Martin v. Löwis130fb172001-07-19 11:00:41 +00002018 AC_DEFINE(_REENTRANT)
Martin v. Löwisa6e97582002-01-01 18:41:33 +00002019 AC_CHECK_HEADER(cthreads.h, [AC_DEFINE(WITH_THREAD)
2020 AC_DEFINE(C_THREADS)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002021 AC_DEFINE(HURD_C_THREADS, 1,
2022 [Define if you are using Mach cthreads directly under /include])
Martin v. Löwisa6e97582002-01-01 18:41:33 +00002023 LIBS="$LIBS -lthreads"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002024 THREADOBJ="Python/thread.o"],[
Martin v. Löwis130fb172001-07-19 11:00:41 +00002025 AC_CHECK_HEADER(mach/cthreads.h, [AC_DEFINE(WITH_THREAD)
2026 AC_DEFINE(C_THREADS)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002027 AC_DEFINE(MACH_C_THREADS, 1,
2028 [Define if you are using Mach cthreads under mach /])
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002029 THREADOBJ="Python/thread.o"],[
Martin v. Löwis130fb172001-07-19 11:00:41 +00002030 AC_MSG_CHECKING(for --with-pth)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002031 AC_ARG_WITH([pth],
2032 AC_HELP_STRING(--with-pth, use GNU pth threading libraries),
2033 [AC_MSG_RESULT($withval)
2034 AC_DEFINE([WITH_THREAD])
2035 AC_DEFINE([HAVE_PTH], 1,
2036 [Define if you have GNU PTH threads.])
2037 LIBS="-lpth $LIBS"
2038 THREADOBJ="Python/thread.o"],
2039 [AC_MSG_RESULT(no)
Martin v. Löwis8158b5a2001-10-08 13:17:28 +00002040
2041 # Just looking for pthread_create in libpthread is not enough:
2042 # on HP/UX, pthread.h renames pthread_create to a different symbol name.
2043 # So we really have to include pthread.h, and then link.
2044 _libs=$LIBS
2045 LIBS="$LIBS -lpthread"
2046 AC_MSG_CHECKING([for pthread_create in -lpthread])
2047 AC_TRY_LINK([#include <pthread.h>
2048
2049void * start_routine (void *arg) { exit (0); }], [
2050pthread_create (NULL, NULL, start_routine, NULL)], [
2051 AC_MSG_RESULT(yes)
2052 AC_DEFINE(WITH_THREAD)
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002053 posix_threads=yes
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002054 THREADOBJ="Python/thread.o"],[
Martin v. Löwis8158b5a2001-10-08 13:17:28 +00002055 LIBS=$_libs
Martin v. Löwis130fb172001-07-19 11:00:41 +00002056 AC_CHECK_FUNC(pthread_detach, [AC_DEFINE(WITH_THREAD)
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002057 posix_threads=yes
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002058 THREADOBJ="Python/thread.o"],[
Martin v. Löwisf90ae202002-06-11 06:22:31 +00002059 AC_CHECK_HEADER(atheos/threads.h, [AC_DEFINE(WITH_THREAD)
2060 AC_DEFINE(ATHEOS_THREADS, 1,
2061 [Define this if you have AtheOS threads.])
2062 THREADOBJ="Python/thread.o"],[
Martin v. Löwis130fb172001-07-19 11:00:41 +00002063 AC_CHECK_LIB(pthreads, pthread_create, [AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002064 posix_threads=yes
Martin v. Löwis130fb172001-07-19 11:00:41 +00002065 LIBS="$LIBS -lpthreads"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002066 THREADOBJ="Python/thread.o"], [
Martin v. Löwis130fb172001-07-19 11:00:41 +00002067 AC_CHECK_LIB(c_r, pthread_create, [AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002068 posix_threads=yes
Martin v. Löwis130fb172001-07-19 11:00:41 +00002069 LIBS="$LIBS -lc_r"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002070 THREADOBJ="Python/thread.o"], [
Martin v. Löwis130fb172001-07-19 11:00:41 +00002071 AC_CHECK_LIB(pthread, __pthread_create_system, [AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002072 posix_threads=yes
Martin v. Löwis130fb172001-07-19 11:00:41 +00002073 LIBS="$LIBS -lpthread"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002074 THREADOBJ="Python/thread.o"], [
Martin v. Löwis130fb172001-07-19 11:00:41 +00002075 AC_CHECK_LIB(cma, pthread_create, [AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002076 posix_threads=yes
Martin v. Löwis130fb172001-07-19 11:00:41 +00002077 LIBS="$LIBS -lcma"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002078 THREADOBJ="Python/thread.o"],[
Martin v. Löwis130fb172001-07-19 11:00:41 +00002079 USE_THREAD_MODULE="#"])
Skip Montanaroeb33e5a2007-08-17 12:57:41 +00002080 ])])])])])])])])])
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00002081
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002082 AC_CHECK_LIB(mpc, usconfig, [AC_DEFINE(WITH_THREAD)
2083 LIBS="$LIBS -lmpc"
2084 THREADOBJ="Python/thread.o"
2085 USE_THREAD_MODULE=""])
2086
2087 if test "$posix_threads" != "yes"; then
2088 AC_CHECK_LIB(thread, thr_create, [AC_DEFINE(WITH_THREAD)
2089 LIBS="$LIBS -lthread"
2090 THREADOBJ="Python/thread.o"
2091 USE_THREAD_MODULE=""])
2092 fi
2093
2094 if test "$USE_THREAD_MODULE" != "#"
2095 then
2096 # If the above checks didn't disable threads, (at least) OSF1
2097 # needs this '-threads' argument during linking.
2098 case $ac_sys_system in
2099 OSF1) LDLAST=-threads;;
2100 esac
2101 fi
2102fi
2103
2104if test "$posix_threads" = "yes"; then
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002105 if test "$unistd_defines_pthreads" = "no"; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002106 AC_DEFINE(_POSIX_THREADS, 1,
2107 [Define if you have POSIX threads,
2108 and your system does not define that.])
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002109 fi
2110
Martin v. Löwisdfc33fd2003-01-21 10:14:41 +00002111 # Bug 662787: Using semaphores causes unexplicable hangs on Solaris 8.
2112 case $ac_sys_system/$ac_sys_release in
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002113 SunOS/5.6) AC_DEFINE(HAVE_PTHREAD_DESTRUCTOR, 1,
2114 Defined for Solaris 2.6 bug in pthread header.)
2115 ;;
Martin v. Löwisdfc33fd2003-01-21 10:14:41 +00002116 SunOS/5.8) AC_DEFINE(HAVE_BROKEN_POSIX_SEMAPHORES, 1,
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002117 Define if the Posix semaphores do not work on your system)
2118 ;;
Christian Heimes7b3ce6a2008-01-31 14:31:45 +00002119 AIX/5) AC_DEFINE(HAVE_BROKEN_POSIX_SEMAPHORES, 1,
2120 Define if the Posix semaphores do not work on your system)
2121 ;;
Martin v. Löwisdfc33fd2003-01-21 10:14:41 +00002122 esac
2123
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002124 AC_MSG_CHECKING(if PTHREAD_SCOPE_SYSTEM is supported)
2125 AC_CACHE_VAL(ac_cv_pthread_system_supported,
2126 [AC_TRY_RUN([#include <pthread.h>
2127 void *foo(void *parm) {
2128 return NULL;
2129 }
2130 main() {
2131 pthread_attr_t attr;
Martin v. Löwisa82d3472002-02-24 16:05:05 +00002132 pthread_t id;
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002133 if (pthread_attr_init(&attr)) exit(-1);
2134 if (pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM)) exit(-1);
Martin v. Löwisa82d3472002-02-24 16:05:05 +00002135 if (pthread_create(&id, &attr, foo, NULL)) exit(-1);
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002136 exit(0);
Guido van Rossum3065c942001-09-17 04:03:14 +00002137 }],
2138 ac_cv_pthread_system_supported=yes,
2139 ac_cv_pthread_system_supported=no,
2140 ac_cv_pthread_system_supported=no)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002141 ])
2142 AC_MSG_RESULT($ac_cv_pthread_system_supported)
2143 if test "$ac_cv_pthread_system_supported" = "yes"; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002144 AC_DEFINE(PTHREAD_SYSTEM_SCHED_SUPPORTED, 1, [Defined if PTHREAD_SCOPE_SYSTEM supported.])
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002145 fi
Jason Tishlerfac083d2003-07-22 15:20:49 +00002146 AC_CHECK_FUNCS(pthread_sigmask,
2147 [case $ac_sys_system in
2148 CYGWIN*)
2149 AC_DEFINE(HAVE_BROKEN_PTHREAD_SIGMASK, 1,
2150 [Define if pthread_sigmask() does not work on your system.])
2151 ;;
2152 esac])
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00002153fi
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002154
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002155
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002156# Check for enable-ipv6
Martin v. Löwis11437992002-04-12 09:54:03 +00002157AH_TEMPLATE(ENABLE_IPV6, [Define if --enable-ipv6 is specified])
Martin v. Löwisa5f8bb52001-09-05 08:22:34 +00002158AC_MSG_CHECKING([if --enable-ipv6 is specified])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002159AC_ARG_ENABLE(ipv6,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002160[ --enable-ipv6 Enable ipv6 (with ipv4) support
2161 --disable-ipv6 Disable ipv6 support],
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002162[ case "$enableval" in
2163 no)
2164 AC_MSG_RESULT(no)
2165 ipv6=no
2166 ;;
2167 *) AC_MSG_RESULT(yes)
2168 AC_DEFINE(ENABLE_IPV6)
2169 ipv6=yes
2170 ;;
2171 esac ],
2172
Martin v. Löwisa5f8bb52001-09-05 08:22:34 +00002173[
2174dnl the check does not work on cross compilation case...
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002175 AC_TRY_RUN([ /* AF_INET6 available check */
2176#include <sys/types.h>
2177#include <sys/socket.h>
2178main()
2179{
2180 if (socket(AF_INET6, SOCK_STREAM, 0) < 0)
2181 exit(1);
2182 else
2183 exit(0);
2184}
2185],
2186 AC_MSG_RESULT(yes)
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002187 ipv6=yes,
2188 AC_MSG_RESULT(no)
2189 ipv6=no,
2190 AC_MSG_RESULT(no)
2191 ipv6=no
Martin v. Löwisa5f8bb52001-09-05 08:22:34 +00002192)
2193
2194if test "$ipv6" = "yes"; then
2195 AC_MSG_CHECKING(if RFC2553 API is available)
2196 AC_TRY_COMPILE([#include <sys/types.h>
2197#include <netinet/in.h>],
2198 [struct sockaddr_in6 x;
2199x.sin6_scope_id;],
2200 AC_MSG_RESULT(yes)
2201 ipv6=yes,
2202 AC_MSG_RESULT(no, IPv6 disabled)
2203 ipv6=no)
2204fi
2205
2206if test "$ipv6" = "yes"; then
2207 AC_DEFINE(ENABLE_IPV6)
2208fi
2209])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002210
2211ipv6type=unknown
2212ipv6lib=none
2213ipv6trylibc=no
2214
2215if test "$ipv6" = "yes"; then
2216 AC_MSG_CHECKING([ipv6 stack type])
Guido van Rossumb8552162001-09-05 14:58:11 +00002217 for i in inria kame linux-glibc linux-inet6 solaris toshiba v6d zeta;
2218 do
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002219 case $i in
2220 inria)
2221 dnl http://www.kame.net/
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002222 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002223#include <netinet/in.h>
2224#ifdef IPV6_INRIA_VERSION
2225yes
2226#endif],
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002227 [ipv6type=$i])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002228 ;;
2229 kame)
2230 dnl http://www.kame.net/
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002231 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002232#include <netinet/in.h>
2233#ifdef __KAME__
2234yes
2235#endif],
2236 [ipv6type=$i;
2237 ipv6lib=inet6
2238 ipv6libdir=/usr/local/v6/lib
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002239 ipv6trylibc=yes])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002240 ;;
2241 linux-glibc)
2242 dnl http://www.v6.linux.or.jp/
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002243 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002244#include <features.h>
2245#if defined(__GLIBC__) && ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1) || (__GLIBC__ > 2))
2246yes
2247#endif],
2248 [ipv6type=$i;
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002249 ipv6trylibc=yes])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002250 ;;
2251 linux-inet6)
2252 dnl http://www.v6.linux.or.jp/
2253 if test -d /usr/inet6; then
2254 ipv6type=$i
2255 ipv6lib=inet6
2256 ipv6libdir=/usr/inet6/lib
Skip Montanarodecc6a42003-01-01 20:07:49 +00002257 BASECFLAGS="-I/usr/inet6/include $BASECFLAGS"
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002258 fi
2259 ;;
2260 solaris)
2261 if test -f /etc/netconfig; then
2262 if /usr/xpg4/bin/grep -q tcp6 /etc/netconfig; then
2263 ipv6type=$i
2264 ipv6trylibc=yes
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002265 fi
2266 fi
2267 ;;
2268 toshiba)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002269 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002270#include <sys/param.h>
2271#ifdef _TOSHIBA_INET6
2272yes
2273#endif],
2274 [ipv6type=$i;
2275 ipv6lib=inet6;
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002276 ipv6libdir=/usr/local/v6/lib])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002277 ;;
2278 v6d)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002279 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002280#include </usr/local/v6/include/sys/v6config.h>
2281#ifdef __V6D__
2282yes
2283#endif],
2284 [ipv6type=$i;
2285 ipv6lib=v6;
2286 ipv6libdir=/usr/local/v6/lib;
Skip Montanarodecc6a42003-01-01 20:07:49 +00002287 BASECFLAGS="-I/usr/local/v6/include $BASECFLAGS"])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002288 ;;
2289 zeta)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002290 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002291#include <sys/param.h>
2292#ifdef _ZETA_MINAMI_INET6
2293yes
2294#endif],
2295 [ipv6type=$i;
2296 ipv6lib=inet6;
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002297 ipv6libdir=/usr/local/v6/lib])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002298 ;;
2299 esac
2300 if test "$ipv6type" != "unknown"; then
2301 break
2302 fi
2303 done
2304 AC_MSG_RESULT($ipv6type)
2305fi
2306
2307if test "$ipv6" = "yes" -a "$ipv6lib" != "none"; then
2308 if test -d $ipv6libdir -a -f $ipv6libdir/lib$ipv6lib.a; then
2309 LIBS="-L$ipv6libdir -l$ipv6lib $LIBS"
2310 echo "using lib$ipv6lib"
2311 else
2312 if test $ipv6trylibc = "yes"; then
2313 echo "using libc"
2314 else
2315 echo 'Fatal: no $ipv6lib library found. cannot continue.'
2316 echo "You need to fetch lib$ipv6lib.a from appropriate"
2317 echo 'ipv6 kit and compile beforehand.'
2318 exit 1
2319 fi
2320 fi
2321fi
2322
Georg Brandl93de2162008-07-16 02:21:06 +00002323AC_MSG_CHECKING(for OSX 10.5 SDK or later)
2324AC_TRY_COMPILE([#include <Carbon/Carbon.h>], FSIORefNum fRef = 0,
2325 AC_DEFINE(HAVE_OSX105_SDK, 1, Define if compiling using MacOS X 10.5 SDK or later.)
2326 AC_MSG_RESULT(yes),
2327 AC_MSG_RESULT(no)
2328)
2329
Martin v. Löwisa3fb4f72002-06-09 13:33:54 +00002330# Check for --with-doc-strings
2331AC_MSG_CHECKING(for --with-doc-strings)
2332AC_ARG_WITH(doc-strings,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002333 AC_HELP_STRING(--with(out)-doc-strings, disable/enable documentation strings))
Martin v. Löwisa3fb4f72002-06-09 13:33:54 +00002334
2335if test -z "$with_doc_strings"
2336then with_doc_strings="yes"
2337fi
2338if test "$with_doc_strings" != "no"
2339then
2340 AC_DEFINE(WITH_DOC_STRINGS, 1,
2341 [Define if you want documentation strings in extension modules])
2342fi
2343AC_MSG_RESULT($with_doc_strings)
2344
Neil Schemenauera35c6882001-02-27 04:45:05 +00002345# Check for Python-specific malloc support
Martin v. Löwisf30d60e2004-06-08 08:17:44 +00002346AC_MSG_CHECKING(for --with-tsc)
2347AC_ARG_WITH(tsc,
2348[ --with(out)-tsc enable/disable timestamp counter profile], [
2349if test "$withval" != no
2350then
2351 AC_DEFINE(WITH_TSC, 1,
2352 [Define to profile with the Pentium timestamp counter])
2353 AC_MSG_RESULT(yes)
2354else AC_MSG_RESULT(no)
2355fi],
2356[AC_MSG_RESULT(no)])
2357
2358# Check for Python-specific malloc support
Neil Schemenauera35c6882001-02-27 04:45:05 +00002359AC_MSG_CHECKING(for --with-pymalloc)
2360AC_ARG_WITH(pymalloc,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002361 AC_HELP_STRING(--with(out)-pymalloc, disable/enable specialized mallocs))
Neil Schemenauer16c22972002-03-22 15:34:49 +00002362
2363if test -z "$with_pymalloc"
2364then with_pymalloc="yes"
2365fi
2366if test "$with_pymalloc" != "no"
2367then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002368 AC_DEFINE(WITH_PYMALLOC, 1,
2369 [Define if you want to compile in Python-specific mallocs])
Neil Schemenauer16c22972002-03-22 15:34:49 +00002370fi
2371AC_MSG_RESULT($with_pymalloc)
Neil Schemenauera35c6882001-02-27 04:45:05 +00002372
Barry Warsawef82cd72000-06-30 16:21:01 +00002373# Check for --with-wctype-functions
2374AC_MSG_CHECKING(for --with-wctype-functions)
2375AC_ARG_WITH(wctype-functions,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002376 AC_HELP_STRING(--with-wctype-functions, use wctype.h functions),
2377[
Barry Warsawef82cd72000-06-30 16:21:01 +00002378if test "$withval" != no
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002379then
2380 AC_DEFINE(WANT_WCTYPE_FUNCTIONS, 1,
2381 [Define if you want wctype.h functions to be used instead of the
2382 one supplied by Python itself. (see Include/unicodectype.h).])
2383 AC_MSG_RESULT(yes)
Barry Warsawef82cd72000-06-30 16:21:01 +00002384else AC_MSG_RESULT(no)
2385fi],
2386[AC_MSG_RESULT(no)])
2387
Guido van Rossum68242b51996-05-28 22:53:03 +00002388# -I${DLINCLDIR} is added to the compile rule for importdl.o
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002389AC_SUBST(DLINCLDIR)
Guido van Rossum98935bf2001-09-05 19:13:16 +00002390DLINCLDIR=.
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002391
Guido van Rossume97ee181999-12-20 21:27:22 +00002392# the dlopen() function means we might want to use dynload_shlib.o. some
2393# platforms, such as AIX, have dlopen(), but don't want to use it.
Thomas Wouters3a584202000-08-05 23:28:51 +00002394AC_CHECK_FUNCS(dlopen)
Guido van Rossume97ee181999-12-20 21:27:22 +00002395
2396# DYNLOADFILE specifies which dynload_*.o file we will use for dynamic
2397# loading of modules.
2398AC_SUBST(DYNLOADFILE)
2399AC_MSG_CHECKING(DYNLOADFILE)
2400if test -z "$DYNLOADFILE"
2401then
2402 case $ac_sys_system/$ac_sys_release in
Martin v. Löwisc19c5a62003-11-18 20:00:44 +00002403 AIX*) # Use dynload_shlib.c and dlopen() if we have it; otherwise dynload_aix.c
2404 if test "$ac_cv_func_dlopen" = yes
2405 then DYNLOADFILE="dynload_shlib.o"
2406 else DYNLOADFILE="dynload_aix.o"
2407 fi
2408 ;;
Guido van Rossume97ee181999-12-20 21:27:22 +00002409 hp*|HP*) DYNLOADFILE="dynload_hpux.o";;
Thomas Wouters49fd7fa2006-04-21 10:40:58 +00002410 # Use dynload_next.c only on 10.2 and below, which don't have native dlopen()
2411 Darwin/@<:@0156@:>@\..*) DYNLOADFILE="dynload_next.o";;
Martin v. Löwisf90ae202002-06-11 06:22:31 +00002412 atheos*) DYNLOADFILE="dynload_atheos.o";;
Guido van Rossume97ee181999-12-20 21:27:22 +00002413 *)
2414 # use dynload_shlib.c and dlopen() if we have it; otherwise stub
2415 # out any dynamic loading
2416 if test "$ac_cv_func_dlopen" = yes
2417 then DYNLOADFILE="dynload_shlib.o"
2418 else DYNLOADFILE="dynload_stub.o"
2419 fi
2420 ;;
2421 esac
2422fi
2423AC_MSG_RESULT($DYNLOADFILE)
2424if test "$DYNLOADFILE" != "dynload_stub.o"
2425then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002426 AC_DEFINE(HAVE_DYNAMIC_LOADING, 1,
2427 [Defined when any dynamic module loading is enabled.])
Guido van Rossume97ee181999-12-20 21:27:22 +00002428fi
2429
Jack Jansenc49e5b72001-06-19 15:00:23 +00002430# MACHDEP_OBJS can be set to platform-specific object files needed by Python
2431
2432AC_SUBST(MACHDEP_OBJS)
2433AC_MSG_CHECKING(MACHDEP_OBJS)
2434if test -z "$MACHDEP_OBJS"
2435then
Jack Jansenb6e9cad2001-08-15 01:26:28 +00002436 MACHDEP_OBJS=$extra_machdep_objs
2437else
2438 MACHDEP_OBJS="$MACHDEP_OBJS $extra_machdep_objs"
Jack Jansenc49e5b72001-06-19 15:00:23 +00002439fi
Jack Jansenb6e9cad2001-08-15 01:26:28 +00002440AC_MSG_RESULT(MACHDEP_OBJS)
Jack Jansenc49e5b72001-06-19 15:00:23 +00002441
Guido van Rossum627b2d71993-12-24 10:39:16 +00002442# checks for library functions
Martin v. Löwis823725e2008-03-24 13:39:54 +00002443AC_CHECK_FUNCS(alarm setitimer getitimer bind_textdomain_codeset chown \
2444 clock confstr ctermid execv fchmod fchown fork fpathconf ftime ftruncate \
Martin v. Löwis438b5342002-12-27 10:16:42 +00002445 gai_strerror getgroups getlogin getloadavg getpeername getpgid getpid \
Martin v. Löwisc3001752005-01-23 09:27:24 +00002446 getpriority getpwent getspnam getspent getsid getwd \
Martin v. Löwis011e8422009-05-05 04:43:17 +00002447 kill killpg lchmod lchown lstat mbrtowc mkfifo mknod mktime \
Martin v. Löwisa5f09072002-10-11 05:37:59 +00002448 mremap nice pathconf pause plock poll pthread_init \
Guido van Rossum162e38c2003-02-19 15:25:10 +00002449 putenv readlink realpath \
Benjamin Peterson965ce872009-04-05 21:24:58 +00002450 select sem_open sem_timedwait sem_getvalue sem_unlink setegid seteuid \
2451 setgid \
Martin v. Löwis4daacb12003-03-28 18:37:01 +00002452 setlocale setregid setreuid setsid setpgid setpgrp setuid setvbuf snprintf \
Gregory P. Smith6c357262007-09-03 16:44:06 +00002453 sigaction siginterrupt sigrelse strftime strlcpy \
Michael W. Hudson34f20ea2002-05-27 15:08:24 +00002454 sysconf tcgetpgrp tcsetpgrp tempnam timegm times tmpfile tmpnam tmpnam_r \
Martin v. Löwis113a0852009-05-29 17:25:39 +00002455 truncate uname unsetenv utimes waitpid wait3 wait4 \
2456 wcscoll wcsftime wcsxfrm _getpty)
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00002457
Martin v. Löwisc8ad7cc2002-11-11 13:23:45 +00002458# For some functions, having a definition is not sufficient, since
2459# we want to take their address.
2460AC_MSG_CHECKING(for chroot)
2461AC_TRY_COMPILE([#include <unistd.h>], void *x=chroot,
2462 AC_DEFINE(HAVE_CHROOT, 1, Define if you have the 'chroot' function.)
2463 AC_MSG_RESULT(yes),
2464 AC_MSG_RESULT(no)
2465)
2466AC_MSG_CHECKING(for link)
2467AC_TRY_COMPILE([#include <unistd.h>], void *x=link,
2468 AC_DEFINE(HAVE_LINK, 1, Define if you have the 'link' function.)
2469 AC_MSG_RESULT(yes),
2470 AC_MSG_RESULT(no)
2471)
2472AC_MSG_CHECKING(for symlink)
2473AC_TRY_COMPILE([#include <unistd.h>], void *x=symlink,
2474 AC_DEFINE(HAVE_SYMLINK, 1, Define if you have the 'symlink' function.)
2475 AC_MSG_RESULT(yes),
2476 AC_MSG_RESULT(no)
2477)
Martin v. Löwisa64988c2003-09-20 15:30:20 +00002478AC_MSG_CHECKING(for fchdir)
2479AC_TRY_COMPILE([#include <unistd.h>], void *x=fchdir,
2480 AC_DEFINE(HAVE_FCHDIR, 1, Define if you have the 'fchdir' function.)
2481 AC_MSG_RESULT(yes),
2482 AC_MSG_RESULT(no)
2483)
2484AC_MSG_CHECKING(for fsync)
2485AC_TRY_COMPILE([#include <unistd.h>], void *x=fsync,
Skip Montanarod4fa8072003-09-25 14:49:15 +00002486 AC_DEFINE(HAVE_FSYNC, 1, Define if you have the 'fsync' function.)
Martin v. Löwisa64988c2003-09-20 15:30:20 +00002487 AC_MSG_RESULT(yes),
2488 AC_MSG_RESULT(no)
2489)
2490AC_MSG_CHECKING(for fdatasync)
2491AC_TRY_COMPILE([#include <unistd.h>], void *x=fdatasync,
2492 AC_DEFINE(HAVE_FDATASYNC, 1, Define if you have the 'fdatasync' function.)
2493 AC_MSG_RESULT(yes),
2494 AC_MSG_RESULT(no)
2495)
Christian Heimes4fbc72b2008-03-22 00:47:35 +00002496AC_MSG_CHECKING(for epoll)
2497AC_TRY_COMPILE([#include <sys/epoll.h>], void *x=epoll_create,
2498 AC_DEFINE(HAVE_EPOLL, 1, Define if you have the 'epoll' functions.)
2499 AC_MSG_RESULT(yes),
2500 AC_MSG_RESULT(no)
2501)
2502AC_MSG_CHECKING(for kqueue)
2503AC_TRY_COMPILE([
2504#include <sys/types.h>
2505#include <sys/event.h>
2506 ], int x=kqueue(),
2507 AC_DEFINE(HAVE_KQUEUE, 1, Define if you have the 'kqueue' functions.)
2508 AC_MSG_RESULT(yes),
2509 AC_MSG_RESULT(no)
2510)
Martin v. Löwisd5843682002-11-21 20:41:28 +00002511# On some systems (eg. FreeBSD 5), we would find a definition of the
2512# functions ctermid_r, setgroups in the library, but no prototype
2513# (e.g. because we use _XOPEN_SOURCE). See whether we can take their
2514# address to avoid compiler warnings and potential miscompilations
2515# because of the missing prototypes.
2516
2517AC_MSG_CHECKING(for ctermid_r)
2518AC_TRY_COMPILE([
2519#include "confdefs.h"
2520#include <stdio.h>
2521], void* p = ctermid_r,
2522 AC_DEFINE(HAVE_CTERMID_R, 1, Define if you have the 'ctermid_r' function.)
2523 AC_MSG_RESULT(yes),
2524 AC_MSG_RESULT(no)
2525)
2526
Martin v. Löwisf26d63b2003-03-30 17:23:49 +00002527AC_MSG_CHECKING(for flock)
2528AC_TRY_COMPILE([
2529#include "confdefs.h"
2530#include <sys/file.h>
2531], void* p = flock,
2532 AC_DEFINE(HAVE_FLOCK, 1, Define if you have the 'flock' function.)
2533 AC_MSG_RESULT(yes),
2534 AC_MSG_RESULT(no)
2535)
2536
2537AC_MSG_CHECKING(for getpagesize)
2538AC_TRY_COMPILE([
2539#include "confdefs.h"
2540#include <unistd.h>
2541], void* p = getpagesize,
2542 AC_DEFINE(HAVE_GETPAGESIZE, 1, Define if you have the 'getpagesize' function.)
2543 AC_MSG_RESULT(yes),
2544 AC_MSG_RESULT(no)
2545)
2546
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002547dnl check for true
2548AC_CHECK_PROGS(TRUE, true, /bin/true)
2549
Martin v. Löwis95c419b2003-05-03 12:10:48 +00002550dnl On some systems (e.g. Solaris 9), hstrerror and inet_aton are in -lresolv
2551dnl On others, they are in the C library, so we to take no action
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002552AC_CHECK_LIB(c, inet_aton, [$ac_cv_prog_TRUE],
Martin v. Löwis95c419b2003-05-03 12:10:48 +00002553 AC_CHECK_LIB(resolv, inet_aton)
2554)
2555
Christian Heimesd0764e22007-12-04 15:00:33 +00002556# On Tru64, chflags seems to be present, but calling it will
2557# exit Python
2558AC_MSG_CHECKING(for chflags)
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00002559AC_CACHE_VAL(ac_cv_have_chflags,
2560AC_TRY_RUN([[
Christian Heimesd0764e22007-12-04 15:00:33 +00002561#include <sys/stat.h>
2562#include <unistd.h>
2563int main(int argc, char*argv[])
2564{
2565 if(chflags(argv[0], 0) != 0)
2566 return 1;
2567 return 0;
2568}
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00002569]], ac_cv_have_chflags=yes,
2570 ac_cv_have_chflags=no,
2571 ac_cv_have_chflags=no)
Christian Heimesd0764e22007-12-04 15:00:33 +00002572)
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00002573AC_MSG_RESULT($ac_cv_have_chflags)
2574if test $ac_cv_have_chflags = yes
2575then
2576 AC_DEFINE(HAVE_CHFLAGS, 1, Define to 1 if you have the `chflags' function.)
2577fi
Christian Heimesd0764e22007-12-04 15:00:33 +00002578
2579AC_MSG_CHECKING(for lchflags)
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00002580AC_CACHE_VAL(ac_cv_have_lchflags,
2581AC_TRY_RUN([[
Christian Heimesd0764e22007-12-04 15:00:33 +00002582#include <sys/stat.h>
2583#include <unistd.h>
2584int main(int argc, char*argv[])
2585{
2586 if(lchflags(argv[0], 0) != 0)
2587 return 1;
2588 return 0;
2589}
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00002590]], ac_cv_have_lchflags=yes,
2591 ac_cv_have_lchflags=no,
2592 ac_cv_have_lchflags=no)
Christian Heimesd0764e22007-12-04 15:00:33 +00002593)
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00002594AC_MSG_RESULT($ac_cv_have_lchflags)
2595if test $ac_cv_have_lchflags = yes
2596then
2597 AC_DEFINE(HAVE_LCHFLAGS, 1, Define to 1 if you have the `lchflags' function.)
2598fi
Christian Heimesd0764e22007-12-04 15:00:33 +00002599
Thomas Wouters0e3f5912006-08-11 14:57:12 +00002600dnl Check if system zlib has *Copy() functions
2601dnl
2602dnl On MacOSX the linker will search for dylibs on the entire linker path
2603dnl before searching for static libraries. setup.py adds -Wl,-search_paths_first
2604dnl to revert to a more traditional unix behaviour and make it possible to
2605dnl override the system libz with a local static library of libz. Temporarily
2606dnl add that flag to our CFLAGS as well to ensure that we check the version
2607dnl of libz that will be used by setup.py.
2608dnl The -L/usr/local/lib is needed as wel to get the same compilation
2609dnl environment as setup.py (and leaving it out can cause configure to use the
2610dnl wrong version of the library)
2611case $ac_sys_system/$ac_sys_release in
2612Darwin/*)
2613 _CUR_CFLAGS="${CFLAGS}"
2614 _CUR_LDFLAGS="${LDFLAGS}"
2615 CFLAGS="${CFLAGS} -Wl,-search_paths_first"
2616 LDFLAGS="${LDFLAGS} -Wl,-search_paths_first -L/usr/local/lib"
2617 ;;
2618esac
2619
2620AC_CHECK_LIB(z, inflateCopy, AC_DEFINE(HAVE_ZLIB_COPY, 1, Define if the zlib library has inflateCopy))
2621
2622case $ac_sys_system/$ac_sys_release in
2623Darwin/*)
2624 CFLAGS="${_CUR_CFLAGS}"
2625 LDFLAGS="${_CUR_LDFLAGS}"
2626 ;;
2627esac
2628
Martin v. Löwise9416172003-05-03 10:12:45 +00002629AC_MSG_CHECKING(for hstrerror)
Martin v. Löwis95c419b2003-05-03 12:10:48 +00002630AC_TRY_LINK([
Martin v. Löwise9416172003-05-03 10:12:45 +00002631#include "confdefs.h"
2632#include <netdb.h>
Martin v. Löwis95c419b2003-05-03 12:10:48 +00002633], void* p = hstrerror; hstrerror(0),
Martin v. Löwise9416172003-05-03 10:12:45 +00002634 AC_DEFINE(HAVE_HSTRERROR, 1, Define if you have the 'hstrerror' function.)
2635 AC_MSG_RESULT(yes),
2636 AC_MSG_RESULT(no)
2637)
2638
2639AC_MSG_CHECKING(for inet_aton)
Martin v. Löwis95c419b2003-05-03 12:10:48 +00002640AC_TRY_LINK([
Martin v. Löwise9416172003-05-03 10:12:45 +00002641#include "confdefs.h"
Martin v. Löwis86d66262006-02-17 08:40:11 +00002642#include <sys/types.h>
Martin v. Löwise9416172003-05-03 10:12:45 +00002643#include <sys/socket.h>
2644#include <netinet/in.h>
2645#include <arpa/inet.h>
Martin v. Löwis95c419b2003-05-03 12:10:48 +00002646], void* p = inet_aton;inet_aton(0,0),
Martin v. Löwise9416172003-05-03 10:12:45 +00002647 AC_DEFINE(HAVE_INET_ATON, 1, Define if you have the 'inet_aton' function.)
2648 AC_MSG_RESULT(yes),
2649 AC_MSG_RESULT(no)
2650)
2651
2652AC_MSG_CHECKING(for inet_pton)
2653AC_TRY_COMPILE([
2654#include "confdefs.h"
Martin v. Löwisf2e488d2003-05-05 22:00:11 +00002655#include <sys/types.h>
Martin v. Löwise9416172003-05-03 10:12:45 +00002656#include <sys/socket.h>
2657#include <netinet/in.h>
2658#include <arpa/inet.h>
2659], void* p = inet_pton,
2660 AC_DEFINE(HAVE_INET_PTON, 1, Define if you have the 'inet_pton' function.)
2661 AC_MSG_RESULT(yes),
2662 AC_MSG_RESULT(no)
2663)
2664
Martin v. Löwisd6640d42003-07-06 09:29:52 +00002665# On some systems, setgroups is in unistd.h, on others, in grp.h
Martin v. Löwisd5843682002-11-21 20:41:28 +00002666AC_MSG_CHECKING(for setgroups)
2667AC_TRY_COMPILE([
2668#include "confdefs.h"
Martin v. Löwisf2e488d2003-05-05 22:00:11 +00002669#include <unistd.h>
Martin v. Löwisd6640d42003-07-06 09:29:52 +00002670#ifdef HAVE_GRP_H
2671#include <grp.h>
2672#endif
Martin v. Löwisd5843682002-11-21 20:41:28 +00002673],
2674void* p = setgroups,
2675 AC_DEFINE(HAVE_SETGROUPS, 1, Define if you have the 'setgroups' function.)
2676 AC_MSG_RESULT(yes),
2677 AC_MSG_RESULT(no)
2678)
2679
Fred Drake8cef4cf2000-06-28 16:40:38 +00002680# check for openpty and forkpty
2681
Martin v. Löwisfd9a72a2006-01-08 10:07:33 +00002682AC_CHECK_FUNCS(openpty,,
2683 AC_CHECK_LIB(util,openpty,
2684 [AC_DEFINE(HAVE_OPENPTY) LIBS="$LIBS -lutil"],
2685 AC_CHECK_LIB(bsd,openpty, [AC_DEFINE(HAVE_OPENPTY) LIBS="$LIBS -lbsd"])
2686 )
2687)
2688AC_CHECK_FUNCS(forkpty,,
2689 AC_CHECK_LIB(util,forkpty,
2690 [AC_DEFINE(HAVE_FORKPTY) LIBS="$LIBS -lutil"],
2691 AC_CHECK_LIB(bsd,forkpty, [AC_DEFINE(HAVE_FORKPTY) LIBS="$LIBS -lbsd"])
2692 )
2693)
Fred Drake8cef4cf2000-06-28 16:40:38 +00002694
Christian Heimesb186d002008-03-18 15:15:01 +00002695# Stuff for expat.
2696AC_CHECK_FUNCS(memmove)
2697
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00002698# check for long file support functions
2699AC_CHECK_FUNCS(fseek64 fseeko fstatvfs ftell64 ftello statvfs)
2700
Christian Heimesb186d002008-03-18 15:15:01 +00002701AC_REPLACE_FUNCS(dup2 getcwd strdup)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002702AC_CHECK_FUNCS(getpgrp,
2703 AC_TRY_COMPILE([#include <unistd.h>],
2704 [getpgrp(0);],
2705 AC_DEFINE(GETPGRP_HAVE_ARG, 1,
2706 [Define if getpgrp() must be called as getpgrp(0).])
2707 )
2708)
Jack Jansen150753c2003-03-29 22:07:47 +00002709AC_CHECK_FUNCS(setpgrp,
2710 AC_TRY_COMPILE([#include <unistd.h>],
2711 [setpgrp(0,0);],
2712 AC_DEFINE(SETPGRP_HAVE_ARG, 1,
2713 [Define if setpgrp() must be called as setpgrp(0, 0).])
2714 )
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002715)
2716AC_CHECK_FUNCS(gettimeofday,
2717 AC_TRY_COMPILE([#include <sys/time.h>],
2718 [gettimeofday((struct timeval*)0,(struct timezone*)0);], ,
2719 AC_DEFINE(GETTIMEOFDAY_NO_TZ, 1,
2720 [Define if gettimeofday() does not have second (timezone) argument
2721 This is the case on Motorola V4 (R40V4.2)])
2722 )
2723)
Guido van Rossum627b2d71993-12-24 10:39:16 +00002724
Martin v. Löwisdbe3f762002-10-10 14:27:30 +00002725AC_MSG_CHECKING(for major, minor, and makedev)
Martin v. Löwise3271202002-11-07 07:42:30 +00002726AC_TRY_LINK([
Neal Norwitz6eb37f02003-02-23 23:28:15 +00002727#if defined(MAJOR_IN_MKDEV)
2728#include <sys/mkdev.h>
2729#elif defined(MAJOR_IN_SYSMACROS)
2730#include <sys/sysmacros.h>
2731#else
2732#include <sys/types.h>
2733#endif
Martin v. Löwisdbe3f762002-10-10 14:27:30 +00002734],[
2735 makedev(major(0),minor(0));
2736],[
2737 AC_DEFINE(HAVE_DEVICE_MACROS, 1,
2738 [Define to 1 if you have the device macros.])
2739 AC_MSG_RESULT(yes)
2740],[
2741 AC_MSG_RESULT(no)
2742])
Martin v. Löwis861a65b2001-10-24 14:36:00 +00002743
2744# On OSF/1 V5.1, getaddrinfo is available, but a define
2745# for [no]getaddrinfo in netdb.h.
2746AC_MSG_CHECKING(for getaddrinfo)
2747AC_TRY_LINK([
Martin v. Löwisc010b6d2001-11-09 17:50:52 +00002748#include <sys/types.h>
Martin v. Löwis861a65b2001-10-24 14:36:00 +00002749#include <sys/socket.h>
2750#include <netdb.h>
Martin v. Löwisc010b6d2001-11-09 17:50:52 +00002751#include <stdio.h>
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00002752], [getaddrinfo(NULL, NULL, NULL, NULL);],
2753have_getaddrinfo=yes,
2754have_getaddrinfo=no)
2755AC_MSG_RESULT($have_getaddrinfo)
2756if test $have_getaddrinfo = yes
2757then
2758 AC_MSG_CHECKING(getaddrinfo bug)
2759 AC_CACHE_VAL(ac_cv_buggy_getaddrinfo,
2760 AC_TRY_RUN([[
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00002761#include <sys/types.h>
2762#include <netdb.h>
2763#include <string.h>
2764#include <sys/socket.h>
2765#include <netinet/in.h>
2766
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00002767int main()
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00002768{
2769 int passive, gaierr, inet4 = 0, inet6 = 0;
2770 struct addrinfo hints, *ai, *aitop;
2771 char straddr[INET6_ADDRSTRLEN], strport[16];
2772
2773 for (passive = 0; passive <= 1; passive++) {
2774 memset(&hints, 0, sizeof(hints));
2775 hints.ai_family = AF_UNSPEC;
2776 hints.ai_flags = passive ? AI_PASSIVE : 0;
2777 hints.ai_socktype = SOCK_STREAM;
Hye-Shik Chang54f94392004-04-14 07:55:31 +00002778 hints.ai_protocol = IPPROTO_TCP;
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00002779 if ((gaierr = getaddrinfo(NULL, "54321", &hints, &aitop)) != 0) {
2780 (void)gai_strerror(gaierr);
2781 goto bad;
2782 }
2783 for (ai = aitop; ai; ai = ai->ai_next) {
2784 if (ai->ai_addr == NULL ||
2785 ai->ai_addrlen == 0 ||
2786 getnameinfo(ai->ai_addr, ai->ai_addrlen,
2787 straddr, sizeof(straddr), strport, sizeof(strport),
2788 NI_NUMERICHOST|NI_NUMERICSERV) != 0) {
2789 goto bad;
2790 }
2791 switch (ai->ai_family) {
2792 case AF_INET:
2793 if (strcmp(strport, "54321") != 0) {
2794 goto bad;
2795 }
2796 if (passive) {
2797 if (strcmp(straddr, "0.0.0.0") != 0) {
2798 goto bad;
2799 }
2800 } else {
2801 if (strcmp(straddr, "127.0.0.1") != 0) {
2802 goto bad;
2803 }
2804 }
2805 inet4++;
2806 break;
2807 case AF_INET6:
2808 if (strcmp(strport, "54321") != 0) {
2809 goto bad;
2810 }
2811 if (passive) {
2812 if (strcmp(straddr, "::") != 0) {
2813 goto bad;
2814 }
2815 } else {
2816 if (strcmp(straddr, "::1") != 0) {
2817 goto bad;
2818 }
2819 }
2820 inet6++;
2821 break;
2822 case AF_UNSPEC:
2823 goto bad;
2824 break;
2825 default:
2826 /* another family support? */
2827 break;
2828 }
2829 }
2830 }
2831
2832 if (!(inet4 == 0 || inet4 == 2))
2833 goto bad;
2834 if (!(inet6 == 0 || inet6 == 2))
2835 goto bad;
2836
2837 if (aitop)
2838 freeaddrinfo(aitop);
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00002839 return 0;
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00002840
2841 bad:
2842 if (aitop)
2843 freeaddrinfo(aitop);
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00002844 return 1;
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00002845}
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00002846]], ac_cv_buggy_getaddrinfo=no,
2847 ac_cv_buggy_getaddrinfo=yes,
2848 ac_cv_buggy_getaddrinfo=yes))
2849fi
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00002850
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00002851if test $have_getaddrinfo = no -o $ac_cv_buggy_getaddrinfo = yes
2852then
2853 if test $ipv6 = yes
2854 then
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00002855 echo 'Fatal: You must get working getaddrinfo() function.'
2856 echo ' or you can specify "--disable-ipv6"'.
2857 exit 1
2858 fi
Martin v. Löwis861a65b2001-10-24 14:36:00 +00002859else
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002860 AC_DEFINE(HAVE_GETADDRINFO, 1, [Define if you have the getaddrinfo function.])
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00002861fi
Thomas Woutersb0db85a2001-08-08 10:39:03 +00002862AC_CHECK_FUNCS(getnameinfo)
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00002863
Guido van Rossum627b2d71993-12-24 10:39:16 +00002864# checks for structures
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002865AC_HEADER_TIME
Guido van Rossum627b2d71993-12-24 10:39:16 +00002866AC_STRUCT_TM
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002867AC_STRUCT_TIMEZONE
Martin v. Löwis60a5d722002-10-16 20:28:25 +00002868AC_CHECK_MEMBERS([struct stat.st_rdev])
2869AC_CHECK_MEMBERS([struct stat.st_blksize])
Hye-Shik Chang5f937a72005-06-02 13:09:30 +00002870AC_CHECK_MEMBERS([struct stat.st_flags])
Martin v. Löwisebd9d5b2005-08-09 15:00:59 +00002871AC_CHECK_MEMBERS([struct stat.st_gen])
2872AC_CHECK_MEMBERS([struct stat.st_birthtime])
Guido van Rossum98bf58f2001-10-18 20:34:25 +00002873AC_STRUCT_ST_BLOCKS
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002874
2875AC_MSG_CHECKING(for time.h that defines altzone)
2876AC_CACHE_VAL(ac_cv_header_time_altzone,
2877[AC_TRY_COMPILE([#include <time.h>], [return altzone;],
2878 ac_cv_header_time_altzone=yes,
2879 ac_cv_header_time_altzone=no)])
2880AC_MSG_RESULT($ac_cv_header_time_altzone)
2881if test $ac_cv_header_time_altzone = yes; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002882 AC_DEFINE(HAVE_ALTZONE, 1, [Define this if your time.h defines altzone.])
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002883fi
2884
Guido van Rossum5739e7e1995-01-20 16:50:53 +00002885was_it_defined=no
2886AC_MSG_CHECKING(whether sys/select.h and sys/time.h may both be included)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002887AC_TRY_COMPILE([
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002888#include <sys/types.h>
2889#include <sys/select.h>
2890#include <sys/time.h>
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002891], [;], [
2892 AC_DEFINE(SYS_SELECT_WITH_SYS_TIME, 1,
2893 [Define if you can safely include both <sys/select.h> and <sys/time.h>
2894 (which you can't on SCO ODT 3.0).])
2895 was_it_defined=yes
2896])
Guido van Rossum5739e7e1995-01-20 16:50:53 +00002897AC_MSG_RESULT($was_it_defined)
Guido van Rossum627b2d71993-12-24 10:39:16 +00002898
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00002899AC_MSG_CHECKING(for addrinfo)
2900AC_CACHE_VAL(ac_cv_struct_addrinfo,
2901AC_TRY_COMPILE([
2902# include <netdb.h>],
2903 [struct addrinfo a],
2904 ac_cv_struct_addrinfo=yes,
2905 ac_cv_struct_addrinfo=no))
2906AC_MSG_RESULT($ac_cv_struct_addrinfo)
2907if test $ac_cv_struct_addrinfo = yes; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002908 AC_DEFINE(HAVE_ADDRINFO, 1, [struct addrinfo (netdb.h)])
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00002909fi
2910
2911AC_MSG_CHECKING(for sockaddr_storage)
2912AC_CACHE_VAL(ac_cv_struct_sockaddr_storage,
2913AC_TRY_COMPILE([
2914# include <sys/types.h>
2915# include <sys/socket.h>],
2916 [struct sockaddr_storage s],
2917 ac_cv_struct_sockaddr_storage=yes,
2918 ac_cv_struct_sockaddr_storage=no))
2919AC_MSG_RESULT($ac_cv_struct_sockaddr_storage)
2920if test $ac_cv_struct_sockaddr_storage = yes; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002921 AC_DEFINE(HAVE_SOCKADDR_STORAGE, 1, [struct sockaddr_storage (sys/socket.h)])
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00002922fi
2923
Guido van Rossum627b2d71993-12-24 10:39:16 +00002924# checks for compiler characteristics
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002925
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002926AC_C_CHAR_UNSIGNED
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002927AC_C_CONST
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002928
Guido van Rossum5739e7e1995-01-20 16:50:53 +00002929works=no
2930AC_MSG_CHECKING(for working volatile)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002931AC_TRY_COMPILE([],[volatile int x; x = 0;], works=yes,
2932 AC_DEFINE(volatile, [], [Define to empty if the keyword does not work.])
2933)
Guido van Rossum5739e7e1995-01-20 16:50:53 +00002934AC_MSG_RESULT($works)
Guido van Rossumdabb11b1994-10-11 15:04:27 +00002935
Guido van Rossum5739e7e1995-01-20 16:50:53 +00002936works=no
2937AC_MSG_CHECKING(for working signed char)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002938AC_TRY_COMPILE([], [signed char c;], works=yes,
2939 AC_DEFINE(signed, [], [Define to empty if the keyword does not work.])
2940)
Guido van Rossum5739e7e1995-01-20 16:50:53 +00002941AC_MSG_RESULT($works)
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002942
Guido van Rossum5739e7e1995-01-20 16:50:53 +00002943have_prototypes=no
2944AC_MSG_CHECKING(for prototypes)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002945AC_TRY_COMPILE([int foo(int x) { return 0; }], [return foo(10);],[
2946 AC_DEFINE(HAVE_PROTOTYPES, 1,
2947 [Define if your compiler supports function prototype])
2948 have_prototypes=yes
2949])
Guido van Rossum5739e7e1995-01-20 16:50:53 +00002950AC_MSG_RESULT($have_prototypes)
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002951
Guido van Rossum5739e7e1995-01-20 16:50:53 +00002952works=no
2953AC_MSG_CHECKING(for variable length prototypes and stdarg.h)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002954AC_TRY_COMPILE([
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002955#include <stdarg.h>
Guido van Rossum3f13e481996-08-30 20:58:11 +00002956int foo(int x, ...) {
2957 va_list va;
2958 va_start(va, x);
2959 va_arg(va, int);
2960 va_arg(va, char *);
2961 va_arg(va, double);
2962 return 0;
2963}
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002964], [return foo(10, "", 3.14);], [
2965 AC_DEFINE(HAVE_STDARG_PROTOTYPES, 1,
2966 [Define if your compiler supports variable length function prototypes
2967 (e.g. void fprintf(FILE *, char *, ...);) *and* <stdarg.h>])
2968 works=yes
2969])
Guido van Rossum5739e7e1995-01-20 16:50:53 +00002970AC_MSG_RESULT($works)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002971
Dave Cole331708b2004-08-09 04:51:41 +00002972# check for socketpair
2973AC_MSG_CHECKING(for socketpair)
2974AC_TRY_COMPILE([
2975#include <sys/types.h>
2976#include <sys/socket.h>
2977], void *x=socketpair,
2978 AC_DEFINE(HAVE_SOCKETPAIR, 1, Define if you have the 'socketpair' function.)
2979 AC_MSG_RESULT(yes),
2980 AC_MSG_RESULT(no)
2981)
2982
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00002983# check if sockaddr has sa_len member
2984AC_MSG_CHECKING(if sockaddr has sa_len member)
2985AC_TRY_COMPILE([#include <sys/types.h>
2986#include <sys/socket.h>],
2987[struct sockaddr x;
2988x.sa_len = 0;],
2989 AC_MSG_RESULT(yes)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002990 AC_DEFINE(HAVE_SOCKADDR_SA_LEN, 1, [Define if sockaddr has sa_len member]),
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00002991 AC_MSG_RESULT(no))
2992
Guido van Rossum5739e7e1995-01-20 16:50:53 +00002993va_list_is_array=no
2994AC_MSG_CHECKING(whether va_list is an array)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002995AC_TRY_COMPILE([
2996#ifdef HAVE_STDARG_PROTOTYPES
2997#include <stdarg.h>
2998#else
2999#include <varargs.h>
3000#endif
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003001], [va_list list1, list2; list1 = list2;], , [
3002 AC_DEFINE(VA_LIST_IS_ARRAY, 1, [Define if a va_list is an array of some kind])
3003 va_list_is_array=yes
3004])
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003005AC_MSG_RESULT($va_list_is_array)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003006
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003007# sigh -- gethostbyname_r is a mess; it can have 3, 5 or 6 arguments :-(
Martin v. Löwis11437992002-04-12 09:54:03 +00003008AH_TEMPLATE(HAVE_GETHOSTBYNAME_R,
3009 [Define this if you have some version of gethostbyname_r()])
3010
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003011AC_CHECK_FUNC(gethostbyname_r, [
3012 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
3013 AC_MSG_CHECKING([gethostbyname_r with 6 args])
3014 OLD_CFLAGS=$CFLAGS
3015 CFLAGS="$CFLAGS $MY_CPPFLAGS $MY_THREAD_CPPFLAGS $MY_CFLAGS"
3016 AC_TRY_COMPILE([
3017# include <netdb.h>
3018 ], [
3019 char *name;
3020 struct hostent *he, *res;
3021 char buffer[2048];
3022 int buflen = 2048;
3023 int h_errnop;
3024
3025 (void) gethostbyname_r(name, he, buffer, buflen, &res, &h_errnop)
3026 ], [
Guido van Rossum8db7d8b1999-03-23 16:40:33 +00003027 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003028 AC_DEFINE(HAVE_GETHOSTBYNAME_R_6_ARG, 1,
3029 [Define this if you have the 6-arg version of gethostbyname_r().])
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003030 AC_MSG_RESULT(yes)
3031 ], [
3032 AC_MSG_RESULT(no)
3033 AC_MSG_CHECKING([gethostbyname_r with 5 args])
3034 AC_TRY_COMPILE([
3035# include <netdb.h>
3036 ], [
3037 char *name;
3038 struct hostent *he;
3039 char buffer[2048];
3040 int buflen = 2048;
3041 int h_errnop;
3042
3043 (void) gethostbyname_r(name, he, buffer, buflen, &h_errnop)
3044 ], [
Guido van Rossum8db7d8b1999-03-23 16:40:33 +00003045 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003046 AC_DEFINE(HAVE_GETHOSTBYNAME_R_5_ARG, 1,
3047 [Define this if you have the 5-arg version of gethostbyname_r().])
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003048 AC_MSG_RESULT(yes)
3049 ], [
3050 AC_MSG_RESULT(no)
3051 AC_MSG_CHECKING([gethostbyname_r with 3 args])
3052 AC_TRY_COMPILE([
3053# include <netdb.h>
3054 ], [
3055 char *name;
3056 struct hostent *he;
3057 struct hostent_data data;
3058
3059 (void) gethostbyname_r(name, he, &data);
3060 ], [
Guido van Rossum8db7d8b1999-03-23 16:40:33 +00003061 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003062 AC_DEFINE(HAVE_GETHOSTBYNAME_R_3_ARG, 1,
3063 [Define this if you have the 3-arg version of gethostbyname_r().])
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003064 AC_MSG_RESULT(yes)
3065 ], [
3066 AC_MSG_RESULT(no)
3067 ])
3068 ])
3069 ])
3070 CFLAGS=$OLD_CFLAGS
3071], [
Thomas Wouters3a584202000-08-05 23:28:51 +00003072 AC_CHECK_FUNCS(gethostbyname)
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003073])
3074AC_SUBST(HAVE_GETHOSTBYNAME_R_6_ARG)
3075AC_SUBST(HAVE_GETHOSTBYNAME_R_5_ARG)
3076AC_SUBST(HAVE_GETHOSTBYNAME_R_3_ARG)
Guido van Rossum8db7d8b1999-03-23 16:40:33 +00003077AC_SUBST(HAVE_GETHOSTBYNAME_R)
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003078AC_SUBST(HAVE_GETHOSTBYNAME)
3079
Guido van Rossum627b2d71993-12-24 10:39:16 +00003080# checks for system services
3081# (none yet)
3082
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003083# Linux requires this for correct f.p. operations
Jeremy Hyltonbe28f5b2000-07-27 21:03:04 +00003084AC_CHECK_FUNC(__fpu_control,
3085 [],
3086 [AC_CHECK_LIB(ieee, __fpu_control)
3087])
Guido van Rossum627b2d71993-12-24 10:39:16 +00003088
Guido van Rossum93274221997-05-09 02:42:00 +00003089# Check for --with-fpectl
Guido van Rossum93274221997-05-09 02:42:00 +00003090AC_MSG_CHECKING(for --with-fpectl)
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00003091AC_ARG_WITH(fpectl,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003092 AC_HELP_STRING(--with-fpectl, enable SIGFPE catching),
3093[
Guido van Rossum93274221997-05-09 02:42:00 +00003094if test "$withval" != no
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003095then
3096 AC_DEFINE(WANT_SIGFPE_HANDLER, 1,
3097 [Define if you want SIGFPE handled (see Include/pyfpe.h).])
3098 AC_MSG_RESULT(yes)
Guido van Rossum93274221997-05-09 02:42:00 +00003099else AC_MSG_RESULT(no)
Guido van Rossumef2255b2000-03-10 22:30:29 +00003100fi],
3101[AC_MSG_RESULT(no)])
Guido van Rossum93274221997-05-09 02:42:00 +00003102
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003103# check for --with-libm=...
3104AC_SUBST(LIBM)
Guido van Rossum4b6b5791996-09-09 20:09:34 +00003105case $ac_sys_system in
Guido van Rossum3dc0a512000-10-05 18:00:06 +00003106Darwin) ;;
Guido van Rossum4b6b5791996-09-09 20:09:34 +00003107*) LIBM=-lm
3108esac
Guido van Rossum93274221997-05-09 02:42:00 +00003109AC_MSG_CHECKING(for --with-libm=STRING)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003110AC_ARG_WITH(libm,
3111 AC_HELP_STRING(--with-libm=STRING, math library),
3112[
Guido van Rossum93274221997-05-09 02:42:00 +00003113if test "$withval" = no
3114then LIBM=
3115 AC_MSG_RESULT(force LIBM empty)
3116elif test "$withval" != yes
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003117then LIBM=$withval
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003118 AC_MSG_RESULT(set LIBM="$withval")
3119else AC_MSG_ERROR([proper usage is --with-libm=STRING])
Guido van Rossum93274221997-05-09 02:42:00 +00003120fi],
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003121[AC_MSG_RESULT(default LIBM="$LIBM")])
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003122
3123# check for --with-libc=...
3124AC_SUBST(LIBC)
Guido van Rossum93274221997-05-09 02:42:00 +00003125AC_MSG_CHECKING(for --with-libc=STRING)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003126AC_ARG_WITH(libc,
3127 AC_HELP_STRING(--with-libc=STRING, C library),
3128[
Guido van Rossum93274221997-05-09 02:42:00 +00003129if test "$withval" = no
3130then LIBC=
3131 AC_MSG_RESULT(force LIBC empty)
3132elif test "$withval" != yes
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003133then LIBC=$withval
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003134 AC_MSG_RESULT(set LIBC="$withval")
3135else AC_MSG_ERROR([proper usage is --with-libc=STRING])
Guido van Rossum93274221997-05-09 02:42:00 +00003136fi],
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003137[AC_MSG_RESULT(default LIBC="$LIBC")])
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003138
Mark Dickinsonb08a53a2009-04-16 19:52:09 +00003139# **************************************************
3140# * Check for various properties of floating point *
3141# **************************************************
Christian Heimes81ee3ef2008-05-04 22:42:01 +00003142
Mark Dickinsonb08a53a2009-04-16 19:52:09 +00003143AC_MSG_CHECKING(whether C doubles are little-endian IEEE 754 binary64)
3144AC_CACHE_VAL(ac_cv_little_endian_double, [
3145AC_TRY_RUN([
3146#include <string.h>
3147int main() {
3148 double x = 9006104071832581.0;
3149 if (memcmp(&x, "\x05\x04\x03\x02\x01\xff\x3f\x43", 8) == 0)
3150 return 0;
3151 else
3152 return 1;
3153}
3154],
3155ac_cv_little_endian_double=yes,
3156ac_cv_little_endian_double=no,
3157ac_cv_little_endian_double=no)])
3158AC_MSG_RESULT($ac_cv_little_endian_double)
3159if test "$ac_cv_little_endian_double" = yes
3160then
3161 AC_DEFINE(DOUBLE_IS_LITTLE_ENDIAN_IEEE754, 1,
3162 [Define if C doubles are 64-bit IEEE 754 binary format, stored
3163 with the least significant byte first])
3164fi
3165
3166AC_MSG_CHECKING(whether C doubles are big-endian IEEE 754 binary64)
3167AC_CACHE_VAL(ac_cv_big_endian_double, [
3168AC_TRY_RUN([
3169#include <string.h>
3170int main() {
3171 double x = 9006104071832581.0;
3172 if (memcmp(&x, "\x43\x3f\xff\x01\x02\x03\x04\x05", 8) == 0)
3173 return 0;
3174 else
3175 return 1;
3176}
3177],
3178ac_cv_big_endian_double=yes,
3179ac_cv_big_endian_double=no,
3180ac_cv_big_endian_double=no)])
3181AC_MSG_RESULT($ac_cv_big_endian_double)
3182if test "$ac_cv_big_endian_double" = yes
3183then
3184 AC_DEFINE(DOUBLE_IS_BIG_ENDIAN_IEEE754, 1,
3185 [Define if C doubles are 64-bit IEEE 754 binary format, stored
3186 with the most significant byte first])
3187fi
3188
3189# Some ARM platforms use a mixed-endian representation for doubles.
3190# While Python doesn't currently have full support for these platforms
3191# (see e.g., issue 1762561), we can at least make sure that float <-> string
3192# conversions work.
3193AC_MSG_CHECKING(whether C doubles are ARM mixed-endian IEEE 754 binary64)
3194AC_CACHE_VAL(ac_cv_mixed_endian_double, [
3195AC_TRY_RUN([
3196#include <string.h>
3197int main() {
3198 double x = 9006104071832581.0;
3199 if (memcmp(&x, "\x01\xff\x3f\x43\x05\x04\x03\x02", 8) == 0)
3200 return 0;
3201 else
3202 return 1;
3203}
3204],
3205ac_cv_mixed_endian_double=yes,
3206ac_cv_mixed_endian_double=no,
3207ac_cv_mixed_endian_double=no)])
3208AC_MSG_RESULT($ac_cv_mixed_endian_double)
3209if test "$ac_cv_mixed_endian_double" = yes
3210then
3211 AC_DEFINE(DOUBLE_IS_ARM_MIXED_ENDIAN_IEEE754, 1,
3212 [Define if C doubles are 64-bit IEEE 754 binary format, stored
3213 in ARM mixed-endian order (byte order 45670123)])
3214fi
3215
Mark Dickinson7abf8d42009-04-18 20:17:52 +00003216# The short float repr introduced in Python 3.1 requires the
3217# correctly-rounded string <-> double conversion functions from
3218# Python/dtoa.c, which in turn require that the FPU uses 53-bit
3219# rounding; this is a problem on x86, where the x87 FPU has a default
3220# rounding precision of 64 bits. For gcc/x86, we try to fix this by
3221# using inline assembler to get and set the x87 FPU control word.
Mark Dickinsonb08a53a2009-04-16 19:52:09 +00003222if test "$GCC" = yes && test -n "`$CC -dM -E - </dev/null | grep i386`"
3223then
Mark Dickinson7abf8d42009-04-18 20:17:52 +00003224 # Check that it's okay to use gcc inline assembler to get and set
3225 # x87 control word. It should be, but you never know...
3226 AC_MSG_CHECKING(whether we can use gcc inline assembler to get and set x87 control word)
3227 AC_TRY_COMPILE([], [
3228 unsigned short cw;
3229 __asm__ __volatile__ ("fnstcw %0" : "=m" (cw));
3230 __asm__ __volatile__ ("fldcw %0" : : "m" (cw));
3231 ],
3232 [have_gcc_asm_for_x87=yes], [have_gcc_asm_for_x87=no])
3233 AC_MSG_RESULT($have_gcc_asm_for_x87)
3234 if test "$have_gcc_asm_for_x87" = yes
Mark Dickinsonb08a53a2009-04-16 19:52:09 +00003235 then
Mark Dickinson7abf8d42009-04-18 20:17:52 +00003236 AC_DEFINE(HAVE_GCC_ASM_FOR_X87, 1,
3237 [Define if we can use gcc inline assembler to get and set x87 control word])
Mark Dickinsonb08a53a2009-04-16 19:52:09 +00003238 fi
3239fi
Christian Heimes81ee3ef2008-05-04 22:42:01 +00003240
Mark Dickinson3dc7c6a2009-01-04 15:09:02 +00003241# Detect whether system arithmetic is subject to x87-style double
3242# rounding issues. The result of this test has little meaning on non
3243# IEEE 754 platforms. On IEEE 754, test should return 1 if rounding
3244# mode is round-to-nearest and double rounding issues are present, and
3245# 0 otherwise. See http://bugs.python.org/issue2937 for more info.
3246AC_MSG_CHECKING(for x87-style double rounding)
Mark Dickinsonb08a53a2009-04-16 19:52:09 +00003247# $BASECFLAGS may affect the result
3248ac_save_cc="$CC"
3249CC="$CC $BASECFLAGS"
Mark Dickinson3dc7c6a2009-01-04 15:09:02 +00003250AC_TRY_RUN([
3251#include <stdlib.h>
3252#include <math.h>
3253int main() {
3254 volatile double x, y, z;
3255 /* 1./(1-2**-53) -> 1+2**-52 (correct), 1.0 (double rounding) */
3256 x = 0.99999999999999989; /* 1-2**-53 */
3257 y = 1./x;
3258 if (y != 1.)
3259 exit(0);
3260 /* 1e16+2.99999 -> 1e16+2. (correct), 1e16+4. (double rounding) */
3261 x = 1e16;
3262 y = 2.99999;
3263 z = x + y;
3264 if (z != 1e16+4.)
3265 exit(0);
3266 /* both tests show evidence of double rounding */
3267 exit(1);
3268}
3269],
3270ac_cv_x87_double_rounding=no,
3271ac_cv_x87_double_rounding=yes,
Mark Dickinsonb08a53a2009-04-16 19:52:09 +00003272ac_cv_x87_double_rounding=no)
3273CC="$ac_save_cc"
Mark Dickinson3dc7c6a2009-01-04 15:09:02 +00003274AC_MSG_RESULT($ac_cv_x87_double_rounding)
3275if test "$ac_cv_x87_double_rounding" = yes
3276then
3277 AC_DEFINE(X87_DOUBLE_ROUNDING, 1,
3278 [Define if arithmetic is subject to x87-style double rounding issue])
3279fi
3280
Mark Dickinsonb08a53a2009-04-16 19:52:09 +00003281# ************************************
3282# * Check for mathematical functions *
3283# ************************************
3284
3285LIBS_SAVE=$LIBS
3286LIBS="$LIBS $LIBM"
3287
Christian Heimes81ee3ef2008-05-04 22:42:01 +00003288# On FreeBSD 6.2, it appears that tanh(-0.) returns 0. instead of
3289# -0. on some architectures.
3290AC_MSG_CHECKING(whether tanh preserves the sign of zero)
3291AC_CACHE_VAL(ac_cv_tanh_preserves_zero_sign, [
3292AC_TRY_RUN([
3293#include <math.h>
3294#include <stdlib.h>
3295int main() {
3296 /* return 0 if either negative zeros don't exist
3297 on this platform or if negative zeros exist
3298 and tanh(-0.) == -0. */
3299 if (atan2(0., -1.) == atan2(-0., -1.) ||
3300 atan2(tanh(-0.), -1.) == atan2(-0., -1.)) exit(0);
3301 else exit(1);
3302}
3303],
3304ac_cv_tanh_preserves_zero_sign=yes,
3305ac_cv_tanh_preserves_zero_sign=no,
3306ac_cv_tanh_preserves_zero_sign=no)])
3307AC_MSG_RESULT($ac_cv_tanh_preserves_zero_sign)
3308if test "$ac_cv_tanh_preserves_zero_sign" = yes
3309then
3310 AC_DEFINE(TANH_PRESERVES_ZERO_SIGN, 1,
3311 [Define if tanh(-0.) is -0., or if platform doesn't have signed zeros])
3312fi
3313
Mark Dickinson9c113362009-09-05 10:36:23 +00003314AC_CHECK_FUNCS([acosh asinh atanh copysign erf erfc expm1 finite gamma])
3315AC_CHECK_FUNCS([hypot lgamma log1p round tgamma])
Mark Dickinson3dc7c6a2009-01-04 15:09:02 +00003316AC_CHECK_DECLS([isinf, isnan, isfinite], [], [], [[#include <math.h>]])
Christian Heimes99170a52007-12-19 02:07:34 +00003317
Guido van Rossumaf5b83e1995-01-04 19:02:35 +00003318LIBS=$LIBS_SAVE
3319
Mark Dickinson10683072009-04-18 21:18:19 +00003320# Multiprocessing check for broken sem_getvalue
3321AC_MSG_CHECKING(for broken sem_getvalue)
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00003322AC_CACHE_VAL(ac_cv_broken_sem_getvalue,
Mark Dickinson10683072009-04-18 21:18:19 +00003323AC_TRY_RUN([
3324#include <unistd.h>
3325#include <fcntl.h>
3326#include <stdio.h>
3327#include <semaphore.h>
3328#include <sys/stat.h>
3329
3330int main(void){
3331 sem_t *a = sem_open("/autoconf", O_CREAT, S_IRUSR|S_IWUSR, 0);
3332 int count;
3333 int res;
3334 if(a==SEM_FAILED){
3335 perror("sem_open");
3336 return 1;
3337
3338 }
3339 res = sem_getvalue(a, &count);
3340 sem_close(a);
3341 return res==-1 ? 1 : 0;
3342}
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00003343], ac_cv_broken_sem_getvalue=no,
3344 ac_cv_broken_sem_getvalue=yes,
3345 ac_cv_broken_sem_getvalue=yes)
Mark Dickinson10683072009-04-18 21:18:19 +00003346)
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00003347AC_MSG_RESULT($ac_cv_broken_sem_getvalue)
3348if test $ac_cv_broken_sem_getvalue = yes
3349then
3350 AC_DEFINE(HAVE_BROKEN_SEM_GETVALUE, 1,
3351 [define to 1 if your sem_getvalue is broken.])
3352fi
Mark Dickinson10683072009-04-18 21:18:19 +00003353
Mark Dickinsonbd792642009-03-18 20:06:12 +00003354# determine what size digit to use for Python's longs
3355AC_MSG_CHECKING([digit size for Python's longs])
3356AC_ARG_ENABLE(big-digits,
3357AC_HELP_STRING([--enable-big-digits@<:@=BITS@:>@],[use big digits for Python longs [[BITS=30]]]),
3358[case $enable_big_digits in
3359yes)
3360 enable_big_digits=30 ;;
3361no)
3362 enable_big_digits=15 ;;
3363[15|30])
3364 ;;
3365*)
3366 AC_MSG_ERROR([bad value $enable_big_digits for --enable-big-digits; value should be 15 or 30]) ;;
3367esac
3368AC_MSG_RESULT($enable_big_digits)
3369AC_DEFINE_UNQUOTED(PYLONG_BITS_IN_DIGIT, $enable_big_digits, [Define as the preferred size in bits of long digits])
3370],
3371[AC_MSG_RESULT(no value specified)])
3372
Guido van Rossumef2255b2000-03-10 22:30:29 +00003373# check for wchar.h
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003374AC_CHECK_HEADER(wchar.h, [
3375 AC_DEFINE(HAVE_WCHAR_H, 1,
3376 [Define if the compiler provides a wchar.h header file.])
3377 wchar_h="yes"
3378],
Guido van Rossumef2255b2000-03-10 22:30:29 +00003379wchar_h="no"
3380)
3381
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003382# determine wchar_t size
3383if test "$wchar_h" = yes
3384then
Guido van Rossum67b26592001-10-20 14:21:45 +00003385 AC_CHECK_SIZEOF(wchar_t, 4, [#include <wchar.h>])
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003386fi
3387
Martin v. Löwisfa3bdea2003-09-04 18:50:54 +00003388AC_MSG_CHECKING(for UCS-4 tcl)
3389have_ucs4_tcl=no
3390AC_TRY_COMPILE([
3391#include <tcl.h>
3392#if TCL_UTF_MAX != 6
3393# error "NOT UCS4_TCL"
3394#endif], [], [
3395 AC_DEFINE(HAVE_UCS4_TCL, 1, [Define this if you have tcl and TCL_UTF_MAX==6])
3396 have_ucs4_tcl=yes
3397])
3398AC_MSG_RESULT($have_ucs4_tcl)
3399
Marc-André Lemburgd7160f82003-09-22 11:14:40 +00003400# check whether wchar_t is signed or not
3401if test "$wchar_h" = yes
3402then
3403 # check whether wchar_t is signed or not
3404 AC_MSG_CHECKING(whether wchar_t is signed)
3405 AC_CACHE_VAL(ac_cv_wchar_t_signed, [
3406 AC_TRY_RUN([
3407 #include <wchar.h>
3408 int main()
3409 {
Thomas Wouters49fd7fa2006-04-21 10:40:58 +00003410 /* Success: exit code 0 */
3411 exit((((wchar_t) -1) < ((wchar_t) 0)) ? 0 : 1);
Marc-André Lemburgd7160f82003-09-22 11:14:40 +00003412 }
3413 ],
3414 ac_cv_wchar_t_signed=yes,
3415 ac_cv_wchar_t_signed=no,
3416 ac_cv_wchar_t_signed=yes)])
3417 AC_MSG_RESULT($ac_cv_wchar_t_signed)
3418fi
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003419
Georg Brandl52d168a2008-01-07 18:10:24 +00003420AC_MSG_CHECKING(what type to use for str)
3421AC_ARG_WITH(wide-unicode,
3422 AC_HELP_STRING(--with-wide-unicode, Use 4-byte Unicode characters (default is 2 bytes)),
3423[
3424if test "$withval" != no
3425then unicode_size="4"
3426else unicode_size="2"
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003427fi
Georg Brandl52d168a2008-01-07 18:10:24 +00003428],
3429[
3430case "$have_ucs4_tcl" in
3431 yes) unicode_size="4" ;;
3432 *) unicode_size="2" ;;
3433esac
3434])
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003435
Martin v. Löwis0036cba2002-04-12 09:58:45 +00003436AH_TEMPLATE(Py_UNICODE_SIZE,
3437 [Define as the size of the unicode type.])
Georg Brandl52d168a2008-01-07 18:10:24 +00003438case "$unicode_size" in
3439 4) AC_DEFINE(Py_UNICODE_SIZE, 4) ;;
3440 *) AC_DEFINE(Py_UNICODE_SIZE, 2) ;;
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003441esac
3442
Martin v. Löwis11437992002-04-12 09:54:03 +00003443AH_TEMPLATE(PY_UNICODE_TYPE,
3444 [Define as the integral type used for Unicode representation.])
Martin v. Löwis0036cba2002-04-12 09:58:45 +00003445
Georg Brandl52d168a2008-01-07 18:10:24 +00003446# wchar_t is only usable if it maps to an unsigned type
3447if test "$unicode_size" = "$ac_cv_sizeof_wchar_t" \
Matthias Klose7dbeed72004-12-24 08:22:17 +00003448 -a "$ac_cv_wchar_t_signed" = "no"
Georg Brandl52d168a2008-01-07 18:10:24 +00003449then
3450 PY_UNICODE_TYPE="wchar_t"
3451 AC_DEFINE(HAVE_USABLE_WCHAR_T, 1,
3452 [Define if you have a useable wchar_t type defined in wchar.h; useable
3453 means wchar_t must be an unsigned type with at least 16 bits. (see
3454 Include/unicodeobject.h).])
3455 AC_DEFINE(PY_UNICODE_TYPE,wchar_t)
3456elif test "$ac_cv_sizeof_short" = "$unicode_size"
3457then
3458 PY_UNICODE_TYPE="unsigned short"
3459 AC_DEFINE(PY_UNICODE_TYPE,unsigned short)
3460elif test "$ac_cv_sizeof_long" = "$unicode_size"
3461then
3462 PY_UNICODE_TYPE="unsigned long"
3463 AC_DEFINE(PY_UNICODE_TYPE,unsigned long)
3464else
3465 PY_UNICODE_TYPE="no type found"
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003466fi
Georg Brandl52d168a2008-01-07 18:10:24 +00003467AC_MSG_RESULT($PY_UNICODE_TYPE)
Guido van Rossumef2255b2000-03-10 22:30:29 +00003468
3469# check for endianness
3470AC_C_BIGENDIAN
3471
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00003472# Check whether right shifting a negative integer extends the sign bit
3473# or fills with zeros (like the Cray J90, according to Tim Peters).
3474AC_MSG_CHECKING(whether right shift extends the sign bit)
Vladimir Marangozova6180282000-07-12 05:05:06 +00003475AC_CACHE_VAL(ac_cv_rshift_extends_sign, [
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00003476AC_TRY_RUN([
3477int main()
3478{
Vladimir Marangozova6180282000-07-12 05:05:06 +00003479 exit(((-1)>>3 == -1) ? 0 : 1);
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00003480}
Guido van Rossum3065c942001-09-17 04:03:14 +00003481],
3482ac_cv_rshift_extends_sign=yes,
3483ac_cv_rshift_extends_sign=no,
3484ac_cv_rshift_extends_sign=yes)])
Vladimir Marangozova6180282000-07-12 05:05:06 +00003485AC_MSG_RESULT($ac_cv_rshift_extends_sign)
3486if test "$ac_cv_rshift_extends_sign" = no
3487then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003488 AC_DEFINE(SIGNED_RIGHT_SHIFT_ZERO_FILLS, 1,
3489 [Define if i>>j for signed int i does not extend the sign bit
3490 when i < 0])
Vladimir Marangozova6180282000-07-12 05:05:06 +00003491fi
3492
Guido van Rossumcadfaec2001-01-05 14:45:49 +00003493# check for getc_unlocked and related locking functions
3494AC_MSG_CHECKING(for getc_unlocked() and friends)
3495AC_CACHE_VAL(ac_cv_have_getc_unlocked, [
3496AC_TRY_LINK([#include <stdio.h>],[
3497 FILE *f = fopen("/dev/null", "r");
3498 flockfile(f);
3499 getc_unlocked(f);
3500 funlockfile(f);
3501], ac_cv_have_getc_unlocked=yes, ac_cv_have_getc_unlocked=no)])
3502AC_MSG_RESULT($ac_cv_have_getc_unlocked)
3503if test "$ac_cv_have_getc_unlocked" = yes
3504then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003505 AC_DEFINE(HAVE_GETC_UNLOCKED, 1,
3506 [Define this if you have flockfile(), getc_unlocked(), and funlockfile()])
Guido van Rossumcadfaec2001-01-05 14:45:49 +00003507fi
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00003508
Neal Norwitzfe8e3d92006-01-07 21:07:20 +00003509# check where readline lives
Martin v. Löwis82bca632006-02-10 20:49:30 +00003510# save the value of LIBS so we don't actually link Python with readline
3511LIBS_no_readline=$LIBS
Gregory P. Smith18820942008-09-07 06:24:49 +00003512
3513# On some systems we need to link readline to a termcap compatible
3514# library. NOTE: Keep the precedence of listed libraries synchronised
3515# with setup.py.
3516py_cv_lib_readline=no
3517AC_MSG_CHECKING([how to link readline libs])
3518for py_libtermcap in "" ncursesw ncurses curses termcap; do
3519 if test -z "$py_libtermcap"; then
3520 READLINE_LIBS="-lreadline"
3521 else
3522 READLINE_LIBS="-lreadline -l$py_libtermcap"
3523 fi
3524 LIBS="$READLINE_LIBS $LIBS_no_readline"
3525 AC_LINK_IFELSE(
3526 [AC_LANG_CALL([],[readline])],
3527 [py_cv_lib_readline=yes])
3528 if test $py_cv_lib_readline = yes; then
3529 break
3530 fi
3531done
3532# Uncomment this line if you want to use READINE_LIBS in Makefile or scripts
3533#AC_SUBST([READLINE_LIBS])
Gregory P. Smith97515912008-09-07 19:23:19 +00003534if test $py_cv_lib_readline = no; then
Gregory P. Smith18820942008-09-07 06:24:49 +00003535 AC_MSG_RESULT([none])
3536else
3537 AC_MSG_RESULT([$READLINE_LIBS])
3538 AC_DEFINE(HAVE_LIBREADLINE, 1,
3539 [Define if you have the readline library (-lreadline).])
Neal Norwitzfe8e3d92006-01-07 21:07:20 +00003540fi
3541
Michael W. Hudson30ea2f22004-07-07 17:44:12 +00003542# check for readline 2.1
3543AC_CHECK_LIB(readline, rl_callback_handler_install,
3544 AC_DEFINE(HAVE_RL_CALLBACK, 1,
Gregory P. Smith18820942008-09-07 06:24:49 +00003545 [Define if you have readline 2.1]), ,$READLINE_LIBS)
Michael W. Hudson30ea2f22004-07-07 17:44:12 +00003546
Guido van Rossumfaf5e4d2002-12-30 16:25:41 +00003547# check for readline 2.2
3548AC_TRY_CPP([#include <readline/readline.h>],
3549have_readline=yes, have_readline=no)
3550if test $have_readline = yes
3551then
3552 AC_EGREP_HEADER([extern int rl_completion_append_character;],
3553 [readline/readline.h],
3554 AC_DEFINE(HAVE_RL_COMPLETION_APPEND_CHARACTER, 1,
3555 [Define if you have readline 2.2]), )
3556fi
3557
Martin v. Löwis0daad592001-09-30 21:09:59 +00003558# check for readline 4.0
3559AC_CHECK_LIB(readline, rl_pre_input_hook,
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003560 AC_DEFINE(HAVE_RL_PRE_INPUT_HOOK, 1,
Gregory P. Smith18820942008-09-07 06:24:49 +00003561 [Define if you have readline 4.0]), ,$READLINE_LIBS)
Martin v. Löwis0daad592001-09-30 21:09:59 +00003562
Thomas Wouters89d996e2007-09-08 17:39:28 +00003563# also in 4.0
3564AC_CHECK_LIB(readline, rl_completion_display_matches_hook,
3565 AC_DEFINE(HAVE_RL_COMPLETION_DISPLAY_MATCHES_HOOK, 1,
Gregory P. Smith18820942008-09-07 06:24:49 +00003566 [Define if you have readline 4.0]), ,$READLINE_LIBS)
Thomas Wouters89d996e2007-09-08 17:39:28 +00003567
Guido van Rossum353ae582001-07-10 16:45:32 +00003568# check for readline 4.2
3569AC_CHECK_LIB(readline, rl_completion_matches,
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003570 AC_DEFINE(HAVE_RL_COMPLETION_MATCHES, 1,
Gregory P. Smith18820942008-09-07 06:24:49 +00003571 [Define if you have readline 4.2]), ,$READLINE_LIBS)
Guido van Rossum353ae582001-07-10 16:45:32 +00003572
Michael W. Hudson30ea2f22004-07-07 17:44:12 +00003573# also in readline 4.2
3574AC_TRY_CPP([#include <readline/readline.h>],
3575have_readline=yes, have_readline=no)
3576if test $have_readline = yes
3577then
3578 AC_EGREP_HEADER([extern int rl_catch_signals;],
3579 [readline/readline.h],
3580 AC_DEFINE(HAVE_RL_CATCH_SIGNAL, 1,
3581 [Define if you can turn off readline's signal handling.]), )
3582fi
3583
Martin v. Löwis82bca632006-02-10 20:49:30 +00003584# End of readline checks: restore LIBS
3585LIBS=$LIBS_no_readline
3586
Thomas Wouterse38b2f12001-07-11 22:35:31 +00003587AC_MSG_CHECKING(for broken nice())
3588AC_CACHE_VAL(ac_cv_broken_nice, [
3589AC_TRY_RUN([
3590int main()
3591{
3592 int val1 = nice(1);
3593 if (val1 != -1 && val1 == nice(2))
3594 exit(0);
3595 exit(1);
3596}
Guido van Rossum3065c942001-09-17 04:03:14 +00003597],
3598ac_cv_broken_nice=yes,
3599ac_cv_broken_nice=no,
3600ac_cv_broken_nice=no)])
Thomas Wouterse38b2f12001-07-11 22:35:31 +00003601AC_MSG_RESULT($ac_cv_broken_nice)
3602if test "$ac_cv_broken_nice" = yes
3603then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003604 AC_DEFINE(HAVE_BROKEN_NICE, 1,
3605 [Define if nice() returns success/failure instead of the new priority.])
Thomas Wouterse38b2f12001-07-11 22:35:31 +00003606fi
3607
Nicholas Bastine62c5c82004-03-21 23:45:42 +00003608AC_MSG_CHECKING(for broken poll())
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00003609AC_CACHE_VAL(ac_cv_broken_poll,
Nicholas Bastine62c5c82004-03-21 23:45:42 +00003610AC_TRY_RUN([
3611#include <poll.h>
3612
Alexandre Vassalottiaee170a2009-07-17 06:24:33 +00003613int main()
3614{
Nicholas Bastine62c5c82004-03-21 23:45:42 +00003615 struct pollfd poll_struct = { 42, POLLIN|POLLPRI|POLLOUT, 0 };
Alexandre Vassalottiaee170a2009-07-17 06:24:33 +00003616 int poll_test;
3617
Nicholas Bastine62c5c82004-03-21 23:45:42 +00003618 close (42);
3619
Alexandre Vassalottiaee170a2009-07-17 06:24:33 +00003620 poll_test = poll(&poll_struct, 1, 0);
Nicholas Bastine62c5c82004-03-21 23:45:42 +00003621 if (poll_test < 0)
Alexandre Vassalottiaee170a2009-07-17 06:24:33 +00003622 return 0;
Nicholas Bastine62c5c82004-03-21 23:45:42 +00003623 else if (poll_test == 0 && poll_struct.revents != POLLNVAL)
Alexandre Vassalottiaee170a2009-07-17 06:24:33 +00003624 return 0;
Nicholas Bastine62c5c82004-03-21 23:45:42 +00003625 else
Alexandre Vassalottiaee170a2009-07-17 06:24:33 +00003626 return 1;
3627}
Nicholas Bastine62c5c82004-03-21 23:45:42 +00003628],
3629ac_cv_broken_poll=yes,
3630ac_cv_broken_poll=no,
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00003631ac_cv_broken_poll=no))
Nicholas Bastine62c5c82004-03-21 23:45:42 +00003632AC_MSG_RESULT($ac_cv_broken_poll)
3633if test "$ac_cv_broken_poll" = yes
3634then
3635 AC_DEFINE(HAVE_BROKEN_POLL, 1,
3636 [Define if poll() sets errno on invalid file descriptors.])
3637fi
3638
Brett Cannon43802422005-02-10 20:48:03 +00003639# Before we can test tzset, we need to check if struct tm has a tm_zone
3640# (which is not required by ISO C or UNIX spec) and/or if we support
3641# tzname[]
3642AC_STRUCT_TIMEZONE
Nicholas Bastine62c5c82004-03-21 23:45:42 +00003643
Brett Cannon43802422005-02-10 20:48:03 +00003644# check tzset(3) exists and works like we expect it to
Guido van Rossumd11b62e2003-03-14 21:51:36 +00003645AC_MSG_CHECKING(for working tzset())
3646AC_CACHE_VAL(ac_cv_working_tzset, [
3647AC_TRY_RUN([
3648#include <stdlib.h>
3649#include <time.h>
Brett Cannon18367812003-09-19 00:59:16 +00003650#include <string.h>
Brett Cannon43802422005-02-10 20:48:03 +00003651
3652#if HAVE_TZNAME
3653extern char *tzname[];
3654#endif
3655
Guido van Rossumd11b62e2003-03-14 21:51:36 +00003656int main()
3657{
Brett Cannon18367812003-09-19 00:59:16 +00003658 /* Note that we need to ensure that not only does tzset(3)
3659 do 'something' with localtime, but it works as documented
3660 in the library reference and as expected by the test suite.
Brett Cannon43802422005-02-10 20:48:03 +00003661 This includes making sure that tzname is set properly if
3662 tm->tm_zone does not exist since it is the alternative way
3663 of getting timezone info.
Brett Cannon18367812003-09-19 00:59:16 +00003664
3665 Red Hat 6.2 doesn't understand the southern hemisphere
Brett Cannon43802422005-02-10 20:48:03 +00003666 after New Year's Day.
Brett Cannon18367812003-09-19 00:59:16 +00003667 */
3668
Brett Cannon43802422005-02-10 20:48:03 +00003669 time_t groundhogday = 1044144000; /* GMT-based */
Brett Cannon18367812003-09-19 00:59:16 +00003670 time_t midyear = groundhogday + (365 * 24 * 3600 / 2);
3671
Neal Norwitz7f2588c2003-04-11 15:35:53 +00003672 putenv("TZ=UTC+0");
Guido van Rossumd11b62e2003-03-14 21:51:36 +00003673 tzset();
Brett Cannon18367812003-09-19 00:59:16 +00003674 if (localtime(&groundhogday)->tm_hour != 0)
3675 exit(1);
Brett Cannon43802422005-02-10 20:48:03 +00003676#if HAVE_TZNAME
3677 /* For UTC, tzname[1] is sometimes "", sometimes " " */
3678 if (strcmp(tzname[0], "UTC") ||
3679 (tzname[1][0] != 0 && tzname[1][0] != ' '))
3680 exit(1);
3681#endif
Brett Cannon18367812003-09-19 00:59:16 +00003682
Neal Norwitz7f2588c2003-04-11 15:35:53 +00003683 putenv("TZ=EST+5EDT,M4.1.0,M10.5.0");
Guido van Rossumd11b62e2003-03-14 21:51:36 +00003684 tzset();
Brett Cannon18367812003-09-19 00:59:16 +00003685 if (localtime(&groundhogday)->tm_hour != 19)
Guido van Rossumd11b62e2003-03-14 21:51:36 +00003686 exit(1);
Brett Cannon43802422005-02-10 20:48:03 +00003687#if HAVE_TZNAME
3688 if (strcmp(tzname[0], "EST") || strcmp(tzname[1], "EDT"))
3689 exit(1);
3690#endif
Brett Cannon18367812003-09-19 00:59:16 +00003691
3692 putenv("TZ=AEST-10AEDT-11,M10.5.0,M3.5.0");
3693 tzset();
3694 if (localtime(&groundhogday)->tm_hour != 11)
3695 exit(1);
Brett Cannon43802422005-02-10 20:48:03 +00003696#if HAVE_TZNAME
3697 if (strcmp(tzname[0], "AEST") || strcmp(tzname[1], "AEDT"))
3698 exit(1);
3699#endif
3700
3701#if HAVE_STRUCT_TM_TM_ZONE
Brett Cannon18367812003-09-19 00:59:16 +00003702 if (strcmp(localtime(&groundhogday)->tm_zone, "AEDT"))
3703 exit(1);
3704 if (strcmp(localtime(&midyear)->tm_zone, "AEST"))
3705 exit(1);
Brett Cannon43802422005-02-10 20:48:03 +00003706#endif
Brett Cannon18367812003-09-19 00:59:16 +00003707
Guido van Rossumd11b62e2003-03-14 21:51:36 +00003708 exit(0);
3709}
3710],
3711ac_cv_working_tzset=yes,
3712ac_cv_working_tzset=no,
3713ac_cv_working_tzset=no)])
3714AC_MSG_RESULT($ac_cv_working_tzset)
3715if test "$ac_cv_working_tzset" = yes
3716then
3717 AC_DEFINE(HAVE_WORKING_TZSET, 1,
3718 [Define if tzset() actually switches the local timezone in a meaningful way.])
3719fi
3720
Martin v. Löwis94717ed2002-09-09 14:24:16 +00003721# Look for subsecond timestamps in struct stat
3722AC_MSG_CHECKING(for tv_nsec in struct stat)
3723AC_CACHE_VAL(ac_cv_stat_tv_nsec,
3724AC_TRY_COMPILE([#include <sys/stat.h>], [
3725struct stat st;
3726st.st_mtim.tv_nsec = 1;
3727],
Martin v. Löwisa32c9942002-09-09 16:17:47 +00003728ac_cv_stat_tv_nsec=yes,
Martin v. Löwis94717ed2002-09-09 14:24:16 +00003729ac_cv_stat_tv_nsec=no,
3730ac_cv_stat_tv_nsec=no))
3731AC_MSG_RESULT($ac_cv_stat_tv_nsec)
3732if test "$ac_cv_stat_tv_nsec" = yes
3733then
3734 AC_DEFINE(HAVE_STAT_TV_NSEC, 1,
3735 [Define if you have struct stat.st_mtim.tv_nsec])
3736fi
3737
Martin v. Löwisebd9d5b2005-08-09 15:00:59 +00003738# Look for BSD style subsecond timestamps in struct stat
3739AC_MSG_CHECKING(for tv_nsec2 in struct stat)
3740AC_CACHE_VAL(ac_cv_stat_tv_nsec2,
3741AC_TRY_COMPILE([#include <sys/stat.h>], [
3742struct stat st;
3743st.st_mtimespec.tv_nsec = 1;
3744],
3745ac_cv_stat_tv_nsec2=yes,
3746ac_cv_stat_tv_nsec2=no,
3747ac_cv_stat_tv_nsec2=no))
3748AC_MSG_RESULT($ac_cv_stat_tv_nsec2)
3749if test "$ac_cv_stat_tv_nsec2" = yes
3750then
3751 AC_DEFINE(HAVE_STAT_TV_NSEC2, 1,
3752 [Define if you have struct stat.st_mtimensec])
3753fi
3754
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00003755# On HP/UX 11.0, mvwdelch is a block with a return statement
3756AC_MSG_CHECKING(whether mvwdelch is an expression)
3757AC_CACHE_VAL(ac_cv_mvwdelch_is_expression,
3758AC_TRY_COMPILE([#include <curses.h>], [
3759 int rtn;
3760 rtn = mvwdelch(0,0,0);
3761], ac_cv_mvwdelch_is_expression=yes,
3762 ac_cv_mvwdelch_is_expression=no,
3763 ac_cv_mvwdelch_is_expression=yes))
3764AC_MSG_RESULT($ac_cv_mvwdelch_is_expression)
3765
3766if test "$ac_cv_mvwdelch_is_expression" = yes
3767then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003768 AC_DEFINE(MVWDELCH_IS_EXPRESSION, 1,
3769 [Define if mvwdelch in curses.h is an expression.])
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00003770fi
3771
3772AC_MSG_CHECKING(whether WINDOW has _flags)
3773AC_CACHE_VAL(ac_cv_window_has_flags,
3774AC_TRY_COMPILE([#include <curses.h>], [
3775 WINDOW *w;
3776 w->_flags = 0;
3777], ac_cv_window_has_flags=yes,
3778 ac_cv_window_has_flags=no,
3779 ac_cv_window_has_flags=no))
3780AC_MSG_RESULT($ac_cv_window_has_flags)
3781
3782
3783if test "$ac_cv_window_has_flags" = yes
3784then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003785 AC_DEFINE(WINDOW_HAS_FLAGS, 1,
3786 [Define if WINDOW in curses.h offers a field _flags.])
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00003787fi
3788
Thomas Wouters0e3f5912006-08-11 14:57:12 +00003789AC_MSG_CHECKING(for is_term_resized)
3790AC_TRY_COMPILE([#include <curses.h>], void *x=is_term_resized,
3791 AC_DEFINE(HAVE_CURSES_IS_TERM_RESIZED, 1, Define if you have the 'is_term_resized' function.)
3792 AC_MSG_RESULT(yes),
Martin v. Löwis24a880b2002-12-31 12:55:15 +00003793 AC_MSG_RESULT(no)
Thomas Wouters0e3f5912006-08-11 14:57:12 +00003794)
Martin v. Löwis24a880b2002-12-31 12:55:15 +00003795
Thomas Wouters0e3f5912006-08-11 14:57:12 +00003796AC_MSG_CHECKING(for resize_term)
3797AC_TRY_COMPILE([#include <curses.h>], void *x=resize_term,
3798 AC_DEFINE(HAVE_CURSES_RESIZE_TERM, 1, Define if you have the 'resize_term' function.)
3799 AC_MSG_RESULT(yes),
Neal Norwitz865400f2003-03-21 01:42:58 +00003800 AC_MSG_RESULT(no)
Thomas Wouters0e3f5912006-08-11 14:57:12 +00003801)
3802
3803AC_MSG_CHECKING(for resizeterm)
3804AC_TRY_COMPILE([#include <curses.h>], void *x=resizeterm,
3805 AC_DEFINE(HAVE_CURSES_RESIZETERM, 1, Define if you have the 'resizeterm' function.)
3806 AC_MSG_RESULT(yes),
3807 AC_MSG_RESULT(no)
3808)
3809
Thomas Wouters89f507f2006-12-13 04:49:30 +00003810AC_MSG_CHECKING(for /dev/ptmx)
3811
3812if test -r /dev/ptmx
3813then
3814 AC_MSG_RESULT(yes)
3815 AC_DEFINE(HAVE_DEV_PTMX, 1,
3816 [Define if we have /dev/ptmx.])
3817else
3818 AC_MSG_RESULT(no)
3819fi
3820
3821AC_MSG_CHECKING(for /dev/ptc)
3822
3823if test -r /dev/ptc
3824then
3825 AC_MSG_RESULT(yes)
3826 AC_DEFINE(HAVE_DEV_PTC, 1,
3827 [Define if we have /dev/ptc.])
3828else
3829 AC_MSG_RESULT(no)
3830fi
Neal Norwitz865400f2003-03-21 01:42:58 +00003831
Thomas Wouters477c8d52006-05-27 19:21:47 +00003832AC_MSG_CHECKING(for %zd printf() format support)
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00003833AC_CACHE_VAL(ac_cv_have_size_t_format,
Alexandre Vassalottie5091f62009-07-17 06:41:02 +00003834AC_TRY_RUN([[
3835#include <stdio.h>
Thomas Wouters477c8d52006-05-27 19:21:47 +00003836#include <stddef.h>
3837#include <string.h>
3838
Christian Heimes2c181612007-12-17 20:04:13 +00003839#ifdef HAVE_SYS_TYPES_H
3840#include <sys/types.h>
3841#endif
Thomas Wouters89f507f2006-12-13 04:49:30 +00003842
3843#ifdef HAVE_SSIZE_T
3844typedef ssize_t Py_ssize_t;
3845#elif SIZEOF_VOID_P == SIZEOF_LONG
3846typedef long Py_ssize_t;
3847#else
3848typedef int Py_ssize_t;
3849#endif
Thomas Wouters477c8d52006-05-27 19:21:47 +00003850
Christian Heimes2c181612007-12-17 20:04:13 +00003851int main()
3852{
3853 char buffer[256];
3854
Thomas Wouters477c8d52006-05-27 19:21:47 +00003855 if(sprintf(buffer, "%zd", (size_t)123) < 0)
3856 return 1;
3857
Thomas Wouters89f507f2006-12-13 04:49:30 +00003858 if (strcmp(buffer, "123"))
Thomas Wouters477c8d52006-05-27 19:21:47 +00003859 return 1;
Thomas Wouters89f507f2006-12-13 04:49:30 +00003860
3861 if (sprintf(buffer, "%zd", (Py_ssize_t)-123) < 0)
3862 return 1;
3863
3864 if (strcmp(buffer, "-123"))
3865 return 1;
3866
Thomas Wouters477c8d52006-05-27 19:21:47 +00003867 return 0;
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00003868}
Alexandre Vassalottie5091f62009-07-17 06:41:02 +00003869]], ac_cv_have_size_t_format=yes,
3870 ac_cv_have_size_t_format=no,
3871 ac_cv_have_size_t_format=no)
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00003872)
3873AC_MSG_RESULT($ac_cv_have_size_t_format)
3874if test $ac_cv_have_size_t_format = yes
3875then
3876 AC_DEFINE(PY_FORMAT_SIZE_T, "z",
3877 [Define to printf format modifier for Py_ssize_t])
3878fi
Thomas Wouters477c8d52006-05-27 19:21:47 +00003879
Martin v. Löwis01c04012002-11-11 14:58:44 +00003880AC_CHECK_TYPE(socklen_t,,
3881 AC_DEFINE(socklen_t,int,
3882 Define to `int' if <sys/socket.h> does not define.),[
3883#ifdef HAVE_SYS_TYPES_H
3884#include <sys/types.h>
3885#endif
Guido van Rossum95713eb2000-05-18 20:53:31 +00003886#ifdef HAVE_SYS_SOCKET_H
3887#include <sys/socket.h>
3888#endif
Martin v. Löwis01c04012002-11-11 14:58:44 +00003889])
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00003890
Antoine Pitroufff95302008-09-03 18:58:51 +00003891AC_MSG_CHECKING(for broken mbstowcs)
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00003892AC_CACHE_VAL(ac_cv_broken_mbstowcs,
Antoine Pitroufff95302008-09-03 18:58:51 +00003893AC_TRY_RUN([
3894#include<stdlib.h>
3895int main() {
3896 size_t len = -1;
3897 const char *str = "text";
3898 len = mbstowcs(NULL, str, 0);
3899 return (len != 4);
3900}
3901],
3902ac_cv_broken_mbstowcs=no,
3903ac_cv_broken_mbstowcs=yes,
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00003904ac_cv_broken_mbstowcs=no))
Antoine Pitroufff95302008-09-03 18:58:51 +00003905AC_MSG_RESULT($ac_cv_broken_mbstowcs)
3906if test "$ac_cv_broken_mbstowcs" = yes
3907then
3908 AC_DEFINE(HAVE_BROKEN_MBSTOWCS, 1,
3909 [Define if mbstowcs(NULL, "text", 0) does not return the number of
3910 wide chars that would be converted.])
3911fi
3912
Antoine Pitroub52ec782009-01-25 16:34:23 +00003913# Check for --with-computed-gotos
3914AC_MSG_CHECKING(for --with-computed-gotos)
3915AC_ARG_WITH(computed-gotos,
3916 AC_HELP_STRING(--with-computed-gotos,
3917 Use computed gotos / threaded dispatch in evaluation loop (not available on all compilers)),
3918[
3919if test "$withval" != no
3920then
3921 AC_DEFINE(USE_COMPUTED_GOTOS, 1,
3922 [Define if you want to use computed gotos in ceval.c.])
3923 AC_MSG_RESULT(yes)
3924else AC_MSG_RESULT(no)
3925fi],
3926[AC_MSG_RESULT(no)])
3927
3928
Martin v. Löwis06f15bb2001-12-02 13:02:32 +00003929AC_SUBST(THREADHEADERS)
3930
3931for h in `(cd $srcdir;echo Python/thread_*.h)`
3932do
3933 THREADHEADERS="$THREADHEADERS \$(srcdir)/$h"
3934done
3935
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00003936AC_SUBST(SRCDIRS)
Neal Norwitzd24499d2005-12-18 21:36:39 +00003937SRCDIRS="Parser Grammar Objects Python Modules Mac"
Andrew M. Kuchling8abedde2001-01-26 22:55:24 +00003938AC_MSG_CHECKING(for build directories)
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00003939for dir in $SRCDIRS; do
3940 if test ! -d $dir; then
3941 mkdir $dir
Fred Drake884d3ba2000-11-02 17:52:56 +00003942 fi
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00003943done
3944AC_MSG_RESULT(done)
Fred Drake036144d2000-10-26 17:09:35 +00003945
Guido van Rossum627b2d71993-12-24 10:39:16 +00003946# generate output files
Antoine Pitrou20327222009-05-24 20:39:11 +00003947AC_CONFIG_FILES(Makefile.pre Modules/Setup.config Misc/python.pc)
Martin v. Löwis88afe662002-10-26 13:47:44 +00003948AC_OUTPUT
Neil Schemenauer61c51152001-01-26 16:18:16 +00003949
Thomas Wouters49fd7fa2006-04-21 10:40:58 +00003950echo "creating Modules/Setup"
Neil Schemenauer61c51152001-01-26 16:18:16 +00003951if test ! -f Modules/Setup
3952then
3953 cp $srcdir/Modules/Setup.dist Modules/Setup
3954fi
3955
Thomas Wouters49fd7fa2006-04-21 10:40:58 +00003956echo "creating Modules/Setup.local"
Neil Schemenauer61c51152001-01-26 16:18:16 +00003957if test ! -f Modules/Setup.local
3958then
3959 echo "# Edit this file for local setup changes" >Modules/Setup.local
3960fi
3961
3962echo "creating Makefile"
3963$SHELL $srcdir/Modules/makesetup -c $srcdir/Modules/config.c.in \
3964 -s Modules Modules/Setup.config \
Neil Schemenauerf8b71c52001-04-21 17:41:16 +00003965 Modules/Setup.local Modules/Setup
Neil Schemenauer66252162001-02-19 04:47:42 +00003966mv config.c Modules