blob: 5646e00c8f5382612a9fa47c8609465b1142786f [file] [log] [blame]
Benjamin Petersonfbeb6b62008-05-26 16:04:49 +00001dnl ***********************************************
2dnl * Please run autoreconf to test your changes! *
3dnl ***********************************************
Benjamin Peterson4469d0c2008-11-30 22:46:23 +00004dnl NOTE: autoconf 2.64 doesn't seem to work (use 2.61).
Martin v. Löwis88afe662002-10-26 13:47:44 +00005
6# Set VERSION so we only need to edit in one place (i.e., here)
Benjamin Peterson46ea4f72009-06-27 21:40:27 +00007m4_define(PYTHON_VERSION, 3.2)
Martin v. Löwis88afe662002-10-26 13:47:44 +00008
Alexandre Vassalottib89910f2009-07-18 00:33:23 +00009dnl Some m4 magic to ensure that the configure script is generated
10dnl by the correct autoconf version.
11m4_define([version_required],
12[m4_if(m4_version_compare(m4_defn([m4_PACKAGE_VERSION]), [$1]), 0,
13 [],
14 [m4_fatal([Autoconf version $1 is required for Python], 63)])
15])
16version_required(2.61)
17
Guido van Rossum76be6ed1995-01-02 18:33:54 +000018AC_REVISION($Revision$)
Georg Brandle2e15612009-05-20 18:25:10 +000019AC_INIT(python, PYTHON_VERSION, http://bugs.python.org/)
Martin v. Löwis88afe662002-10-26 13:47:44 +000020AC_CONFIG_SRCDIR([Include/object.h])
Martin v. Löwis4f1cd8b2001-07-26 13:41:06 +000021AC_CONFIG_HEADER(pyconfig.h)
Guido van Rossum627b2d71993-12-24 10:39:16 +000022
Benjamin Petersond23f8222009-04-05 19:13:16 +000023dnl Ensure that if prefix is specified, it does not end in a slash. If
24dnl it does, we get path names containing '//' which is both ugly and
25dnl can cause trouble.
26
27dnl Last slash shouldn't be stripped if prefix=/
28if test "$prefix" != "/"; then
29 prefix=`echo "$prefix" | sed -e 's/\/$//g'`
30fi
31
Martin v. Löwis8316feb2003-06-14 07:48:07 +000032dnl This is for stuff that absolutely must end up in pyconfig.h.
33dnl Please use pyport.h instead, if possible.
Martin v. Löwisbddf5a52002-11-11 13:37:28 +000034AH_TOP([
35#ifndef Py_PYCONFIG_H
36#define Py_PYCONFIG_H
37])
Martin v. Löwis11437992002-04-12 09:54:03 +000038AH_BOTTOM([
Martin v. Löwis11437992002-04-12 09:54:03 +000039/* Define the macros needed if on a UnixWare 7.x system. */
40#if defined(__USLC__) && defined(__SCO_VERSION__)
41#define STRICT_SYSV_CURSES /* Don't use ncurses extensions */
42#endif
Martin v. Löwisbddf5a52002-11-11 13:37:28 +000043
44#endif /*Py_PYCONFIG_H*/
Martin v. Löwis11437992002-04-12 09:54:03 +000045])
46
Martin v. Löwis8316feb2003-06-14 07:48:07 +000047# We don't use PACKAGE_ variables, and they cause conflicts
48# with other autoconf-based packages that include Python.h
49grep -v 'define PACKAGE_' <confdefs.h >confdefs.h.new
50rm confdefs.h
51mv confdefs.h.new confdefs.h
52
Guido van Rossum642b6781997-07-19 19:35:41 +000053AC_SUBST(VERSION)
Martin v. Löwis88afe662002-10-26 13:47:44 +000054VERSION=PYTHON_VERSION
Guido van Rossum642b6781997-07-19 19:35:41 +000055
Martin v. Löwis1142de32002-03-29 16:28:31 +000056AC_SUBST(SOVERSION)
57SOVERSION=1.0
58
Martin v. Löwis6f18a3c2002-07-20 08:51:52 +000059# The later defininition of _XOPEN_SOURCE disables certain features
60# on Linux, so we need _GNU_SOURCE to re-enable them (makedev, tm_zone).
61AC_DEFINE(_GNU_SOURCE, 1, [Define on Linux to activate all library features])
62
Martin v. Löwisbcd93962003-05-03 10:32:18 +000063# The later defininition of _XOPEN_SOURCE and _POSIX_C_SOURCE disables
64# certain features on NetBSD, so we need _NETBSD_SOURCE to re-enable
65# them.
66AC_DEFINE(_NETBSD_SOURCE, 1, [Define on NetBSD to activate all library features])
67
Andrew MacIntyreabccf412003-07-02 13:53:25 +000068# The later defininition of _XOPEN_SOURCE and _POSIX_C_SOURCE disables
69# certain features on FreeBSD, so we need __BSD_VISIBLE to re-enable
70# them.
71AC_DEFINE(__BSD_VISIBLE, 1, [Define on FreeBSD to activate all library features])
72
Martin v. Löwisd6320502004-08-12 13:45:08 +000073# The later defininition of _XOPEN_SOURCE and _POSIX_C_SOURCE disables
74# u_int on Irix 5.3. Defining _BSD_TYPES brings it back.
75AC_DEFINE(_BSD_TYPES, 1, [Define on Irix to enable u_int])
76
Georg Brandlfcaf9102008-07-16 02:17:56 +000077# The later defininition of _XOPEN_SOURCE and _POSIX_C_SOURCE disables
78# certain features on Mac OS X, so we need _DARWIN_C_SOURCE to re-enable
79# them.
80AC_DEFINE(_DARWIN_C_SOURCE, 1, [Define on Darwin to activate all library features])
81
82
Martin v. Löwise981a4e2002-11-11 13:26:51 +000083define_xopen_source=yes
Martin v. Löwis6f18a3c2002-07-20 08:51:52 +000084
Neil Schemenauer4edbc2a2001-03-22 00:34:03 +000085# Arguments passed to configure.
86AC_SUBST(CONFIG_ARGS)
87CONFIG_ARGS="$ac_configure_args"
88
Ronald Oussoren8af24c12010-02-07 12:03:42 +000089AC_MSG_CHECKING([for --enable-universalsdk])
Thomas Wouters477c8d52006-05-27 19:21:47 +000090AC_ARG_ENABLE(universalsdk,
Christian Heimes68f5fbe2008-02-14 08:27:37 +000091 AC_HELP_STRING(--enable-universalsdk@<:@=SDKDIR@:>@, Build against Mac OS X 10.4u SDK (ppc/i386)),
Thomas Wouters477c8d52006-05-27 19:21:47 +000092[
93 case $enableval in
94 yes)
95 enableval=/Developer/SDKs/MacOSX10.4u.sdk
Ronald Oussoren8af24c12010-02-07 12:03:42 +000096 if test ! -d "${enableval}"
97 then
98 enableval=/
99 fi
Thomas Wouters477c8d52006-05-27 19:21:47 +0000100 ;;
101 esac
102 case $enableval in
103 no)
104 UNIVERSALSDK=
105 enable_universalsdk=
106 ;;
107 *)
108 UNIVERSALSDK=$enableval
Ronald Oussoren8af24c12010-02-07 12:03:42 +0000109 if test ! -d "${UNIVERSALSDK}"
110 then
111 AC_MSG_ERROR([--enable-universalsdk specifies non-existing SDK: ${UNIVERSALSDK}])
112 fi
Thomas Wouters477c8d52006-05-27 19:21:47 +0000113 ;;
114 esac
Ronald Oussoren8af24c12010-02-07 12:03:42 +0000115
Thomas Wouters477c8d52006-05-27 19:21:47 +0000116],[
117 UNIVERSALSDK=
118 enable_universalsdk=
119])
Ronald Oussoren8af24c12010-02-07 12:03:42 +0000120if test -n "${UNIVERSALSDK}"
121then
122 AC_MSG_RESULT(${UNIVERSALSDK})
123else
124 AC_MSG_RESULT(no)
125fi
Thomas Wouters477c8d52006-05-27 19:21:47 +0000126AC_SUBST(UNIVERSALSDK)
127
Benjamin Peterson6794aa32008-07-16 20:33:37 +0000128AC_SUBST(ARCH_RUN_32BIT)
129
Georg Brandlfcaf9102008-07-16 02:17:56 +0000130UNIVERSAL_ARCHS="32-bit"
Ronald Oussoren6f6c5622009-12-24 14:03:19 +0000131AC_SUBST(LIPO_32BIT_FLAGS)
Georg Brandlfcaf9102008-07-16 02:17:56 +0000132AC_MSG_CHECKING(for --with-universal-archs)
133AC_ARG_WITH(universal-archs,
Ronald Oussoren3c064c12009-09-08 07:12:42 +0000134 AC_HELP_STRING(--with-universal-archs=ARCH, select architectures for universal build ("32-bit", "64-bit", "3-way", "intel" or "all")),
Georg Brandlfcaf9102008-07-16 02:17:56 +0000135[
136 AC_MSG_RESULT($withval)
137 UNIVERSAL_ARCHS="$withval"
138],
139[
140 AC_MSG_RESULT(32-bit)
141])
142
143
144
Christian Heimes81ee3ef2008-05-04 22:42:01 +0000145AC_ARG_WITH(framework-name,
146 AC_HELP_STRING(--with-framework-name=FRAMEWORK,
147 specify an alternate name of the framework built with --enable-framework),
148[
149 PYTHONFRAMEWORK=${withval}
150 PYTHONFRAMEWORKDIR=${withval}.framework
151 PYTHONFRAMEWORKIDENTIFIER=org.python.`echo $withval | tr '[A-Z]' '[a-z]'`
152 ],[
153 PYTHONFRAMEWORK=Python
154 PYTHONFRAMEWORKDIR=Python.framework
155 PYTHONFRAMEWORKIDENTIFIER=org.python.python
156])
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000157dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000158AC_ARG_ENABLE(framework,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000159 AC_HELP_STRING(--enable-framework@<:@=INSTALLDIR@:>@, Build (MacOSX|Darwin) framework),
160[
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000161 case $enableval in
162 yes)
163 enableval=/Library/Frameworks
Jack Jansen127e56e2001-09-11 14:41:54 +0000164 esac
165 case $enableval in
166 no)
167 PYTHONFRAMEWORK=
168 PYTHONFRAMEWORKDIR=no-framework
169 PYTHONFRAMEWORKPREFIX=
170 PYTHONFRAMEWORKINSTALLDIR=
Thomas Wouters477c8d52006-05-27 19:21:47 +0000171 FRAMEWORKINSTALLFIRST=
172 FRAMEWORKINSTALLLAST=
Thomas Wouters73e5a5b2006-06-08 15:35:45 +0000173 FRAMEWORKALTINSTALLFIRST=
174 FRAMEWORKALTINSTALLLAST=
175 if test "x${prefix}" = "xNONE"; then
176 FRAMEWORKUNIXTOOLSPREFIX="${ac_default_prefix}"
177 else
178 FRAMEWORKUNIXTOOLSPREFIX="${prefix}"
179 fi
Jack Jansen127e56e2001-09-11 14:41:54 +0000180 enable_framework=
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000181 ;;
182 *)
183 PYTHONFRAMEWORKPREFIX=$enableval
Jack Jansen127e56e2001-09-11 14:41:54 +0000184 PYTHONFRAMEWORKINSTALLDIR=$PYTHONFRAMEWORKPREFIX/$PYTHONFRAMEWORKDIR
Thomas Wouters477c8d52006-05-27 19:21:47 +0000185 FRAMEWORKINSTALLFIRST="frameworkinstallstructure"
Ronald Oussorenf6ccbf62009-06-02 10:55:56 +0000186 FRAMEWORKALTINSTALLFIRST="frameworkinstallstructure "
Ronald Oussoren6f6c5622009-12-24 14:03:19 +0000187 FRAMEWORKINSTALLLAST="frameworkinstallmaclib frameworkinstallapps frameworkinstallunixtools"
188 FRAMEWORKALTINSTALLLAST="frameworkinstallmaclib frameworkinstallapps frameworkaltinstallunixtools"
Georg Brandlfcaf9102008-07-16 02:17:56 +0000189
Thomas Wouters73e5a5b2006-06-08 15:35:45 +0000190 if test "x${prefix}" = "xNONE" ; then
191 FRAMEWORKUNIXTOOLSPREFIX="${ac_default_prefix}"
192 else
193 FRAMEWORKUNIXTOOLSPREFIX="${prefix}"
194 fi
Jack Jansen127e56e2001-09-11 14:41:54 +0000195 prefix=$PYTHONFRAMEWORKINSTALLDIR/Versions/$VERSION
Thomas Wouters477c8d52006-05-27 19:21:47 +0000196
Christian Heimes81ee3ef2008-05-04 22:42:01 +0000197 # Add files for Mac specific code to the list of output
Thomas Wouters477c8d52006-05-27 19:21:47 +0000198 # files:
Thomas Wouters73e5a5b2006-06-08 15:35:45 +0000199 AC_CONFIG_FILES(Mac/Makefile)
200 AC_CONFIG_FILES(Mac/PythonLauncher/Makefile)
Christian Heimes81ee3ef2008-05-04 22:42:01 +0000201 AC_CONFIG_FILES(Mac/Resources/framework/Info.plist)
202 AC_CONFIG_FILES(Mac/Resources/app/Info.plist)
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000203 esac
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000204 ],[
205 PYTHONFRAMEWORK=
Jack Jansen127e56e2001-09-11 14:41:54 +0000206 PYTHONFRAMEWORKDIR=no-framework
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000207 PYTHONFRAMEWORKPREFIX=
208 PYTHONFRAMEWORKINSTALLDIR=
Thomas Wouters477c8d52006-05-27 19:21:47 +0000209 FRAMEWORKINSTALLFIRST=
210 FRAMEWORKINSTALLLAST=
Thomas Wouters73e5a5b2006-06-08 15:35:45 +0000211 FRAMEWORKALTINSTALLFIRST=
212 FRAMEWORKALTINSTALLLAST=
213 if test "x${prefix}" = "xNONE" ; then
214 FRAMEWORKUNIXTOOLSPREFIX="${ac_default_prefix}"
215 else
216 FRAMEWORKUNIXTOOLSPREFIX="${prefix}"
217 fi
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000218 enable_framework=
Georg Brandlfcaf9102008-07-16 02:17:56 +0000219
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000220])
221AC_SUBST(PYTHONFRAMEWORK)
Christian Heimes81ee3ef2008-05-04 22:42:01 +0000222AC_SUBST(PYTHONFRAMEWORKIDENTIFIER)
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000223AC_SUBST(PYTHONFRAMEWORKDIR)
224AC_SUBST(PYTHONFRAMEWORKPREFIX)
225AC_SUBST(PYTHONFRAMEWORKINSTALLDIR)
Thomas Wouters477c8d52006-05-27 19:21:47 +0000226AC_SUBST(FRAMEWORKINSTALLFIRST)
227AC_SUBST(FRAMEWORKINSTALLLAST)
Thomas Wouters73e5a5b2006-06-08 15:35:45 +0000228AC_SUBST(FRAMEWORKALTINSTALLFIRST)
229AC_SUBST(FRAMEWORKALTINSTALLLAST)
230AC_SUBST(FRAMEWORKUNIXTOOLSPREFIX)
Guido van Rossum4b6b5791996-09-09 20:09:34 +0000231
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000232##AC_ARG_WITH(dyld,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000233## AC_HELP_STRING(--with-dyld,
234## Use (OpenStep|Rhapsody) dynamic linker))
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000235##
Guido van Rossumb418f891996-07-30 18:06:02 +0000236# Set name for machine-dependent library files
237AC_SUBST(MACHDEP)
238AC_MSG_CHECKING(MACHDEP)
239if test -z "$MACHDEP"
240then
Guido van Rossum4b6b5791996-09-09 20:09:34 +0000241 ac_sys_system=`uname -s`
Benjamin Peterson8719ad52009-09-11 22:24:02 +0000242 if test "$ac_sys_system" = "AIX" \
Martin v. Löwis21ee4092002-09-30 16:19:48 +0000243 -o "$ac_sys_system" = "UnixWare" -o "$ac_sys_system" = "OpenUNIX"; then
Guido van Rossum4b6b5791996-09-09 20:09:34 +0000244 ac_sys_release=`uname -v`
Guido van Rossumb418f891996-07-30 18:06:02 +0000245 else
Guido van Rossum4b6b5791996-09-09 20:09:34 +0000246 ac_sys_release=`uname -r`
Guido van Rossumb418f891996-07-30 18:06:02 +0000247 fi
Guido van Rossum4b6b5791996-09-09 20:09:34 +0000248 ac_md_system=`echo $ac_sys_system |
249 tr -d '[/ ]' | tr '[[A-Z]]' '[[a-z]]'`
250 ac_md_release=`echo $ac_sys_release |
Guido van Rossum67b26592001-10-20 14:21:45 +0000251 tr -d '[/ ]' | sed 's/^[[A-Z]]\.//' | sed 's/\..*//'`
Guido van Rossumb97ef171997-09-28 05:44:03 +0000252 MACHDEP="$ac_md_system$ac_md_release"
Guido van Rossum4b6b5791996-09-09 20:09:34 +0000253
Guido van Rossumbcd91e01997-03-20 20:46:29 +0000254 case $MACHDEP in
Andrew M. Kuchling5a3e4cb2001-07-20 19:29:04 +0000255 cygwin*) MACHDEP="cygwin";;
Jack Jansen8a97f4a2001-12-05 23:27:32 +0000256 darwin*) MACHDEP="darwin";;
Martin v. Löwisf3322282003-07-13 09:46:13 +0000257 irix646) MACHDEP="irix6";;
Guido van Rossumb97ef171997-09-28 05:44:03 +0000258 '') MACHDEP="unknown";;
Guido van Rossumb418f891996-07-30 18:06:02 +0000259 esac
260fi
Jack Jansen83f898c2002-12-30 22:23:40 +0000261
Martin v. Löwise981a4e2002-11-11 13:26:51 +0000262# Some systems cannot stand _XOPEN_SOURCE being defined at all; they
263# disable features if it is defined, without any means to access these
264# features as extensions. For these systems, we skip the definition of
265# _XOPEN_SOURCE. Before adding a system to the list to gain access to
266# some feature, make sure there is no alternative way to access this
267# feature. Also, when using wildcards, make sure you have verified the
268# need for not defining _XOPEN_SOURCE on all systems matching the
269# wildcard, and that the wildcard does not include future systems
270# (which may remove their limitations).
271dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
272case $ac_sys_system/$ac_sys_release in
273 # On OpenBSD, select(2) is not available if _XOPEN_SOURCE is defined,
274 # even though select is a POSIX function. Reported by J. Ribbens.
Martin v. Löwis76bafc62003-10-03 13:47:44 +0000275 # Reconfirmed for OpenBSD 3.3 by Zachary Hamm, for 3.4 by Jason Ish.
Georg Brandlf78e02b2008-06-10 17:40:04 +0000276 OpenBSD/2.* | OpenBSD/3.@<:@0123456789@:>@ | OpenBSD/4.@<:@0123@:>@)
Christian Heimes5b5e81c2007-12-31 16:14:33 +0000277 define_xopen_source=no
278 # OpenBSD undoes our definition of __BSD_VISIBLE if _XOPEN_SOURCE is
279 # also defined. This can be overridden by defining _BSD_SOURCE
280 # As this has a different meaning on Linux, only define it on OpenBSD
281 AC_DEFINE(_BSD_SOURCE, 1, [Define on OpenBSD to activate all library features])
282 ;;
Martin v. Löwis7671efc2010-02-15 08:35:16 +0000283 OpenBSD/4.@<:@4@:>@)
284 # OpenBSD undoes our definition of __BSD_VISIBLE if _XOPEN_SOURCE is
285 # also defined. This can be overridden by defining _BSD_SOURCE
286 # As this has a different meaning on Linux, only define it on OpenBSD
287 AC_DEFINE(_BSD_SOURCE, 1, [Define on OpenBSD to activate all library features])
288 ;;
Thomas Wouters89f507f2006-12-13 04:49:30 +0000289 # Defining _XOPEN_SOURCE on NetBSD version prior to the introduction of
290 # _NETBSD_SOURCE disables certain features (eg. setgroups). Reported by
291 # Marc Recht
Benjamin Petersonf608c612008-11-16 18:33:53 +0000292 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 +0000293 define_xopen_source=no;;
Martin v. Löwisa9d71422003-03-28 18:43:31 +0000294 # On Solaris 2.6, sys/wait.h is inconsistent in the usage
295 # of union __?sigval. Reported by Stuart Bishop.
296 SunOS/5.6)
297 define_xopen_source=no;;
Martin v. Löwisc2409b42003-05-11 05:53:41 +0000298 # On UnixWare 7, u_long is never defined with _XOPEN_SOURCE,
299 # but used in /usr/include/netinet/tcp.h. Reported by Tim Rice.
Martin v. Löwis253d1f42004-05-07 19:14:14 +0000300 # Reconfirmed for 7.1.4 by Martin v. Loewis.
301 OpenUNIX/8.0.0| UnixWare/7.1.@<:@0-4@:>@)
Martin v. Löwisc2409b42003-05-11 05:53:41 +0000302 define_xopen_source=no;;
303 # On OpenServer 5, u_short is never defined with _XOPEN_SOURCE,
Martin v. Löwis53e73c32003-05-05 05:13:18 +0000304 # but used in struct sockaddr.sa_family. Reported by Tim Rice.
Martin v. Löwisc2409b42003-05-11 05:53:41 +0000305 SCO_SV/3.2)
Martin v. Löwis53e73c32003-05-05 05:13:18 +0000306 define_xopen_source=no;;
Martin v. Löwisb37509b2008-11-04 20:45:29 +0000307 # On FreeBSD 4, the math functions C89 does not cover are never defined
308 # with _XOPEN_SOURCE and __BSD_VISIBLE does not re-enable them.
309 FreeBSD/4.*)
310 define_xopen_source=no;;
311 # On MacOS X 10.2, a bug in ncurses.h means that it craps out if
312 # _XOPEN_EXTENDED_SOURCE is defined. Apparently, this is fixed in 10.3, which
313 # identifies itself as Darwin/7.*
314 # On Mac OS X 10.4, defining _POSIX_C_SOURCE or _XOPEN_SOURCE
315 # disables platform specific features beyond repair.
316 # On Mac OS X 10.3, defining _POSIX_C_SOURCE or _XOPEN_SOURCE
317 # has no effect, don't bother defining them
318 Darwin/@<:@6789@:>@.*)
Anthony Baxter6169c6b2003-10-04 07:46:23 +0000319 define_xopen_source=no;;
Trent Mickaf16e8c2004-08-25 23:55:59 +0000320 # On AIX 4 and 5.1, mbstate_t is defined only when _XOPEN_SOURCE == 500 but
321 # used in wcsnrtombs() and mbsnrtowcs() even if _XOPEN_SOURCE is not defined
322 # or has another value. By not (re)defining it, the defaults come in place.
Martin v. Löwisc19c5a62003-11-18 20:00:44 +0000323 AIX/4)
324 define_xopen_source=no;;
Trent Mickaf16e8c2004-08-25 23:55:59 +0000325 AIX/5)
326 if test `uname -r` -eq 1; then
327 define_xopen_source=no
328 fi
329 ;;
Georg Brandlf78e02b2008-06-10 17:40:04 +0000330 # On QNX 6.3.2, defining _XOPEN_SOURCE prevents netdb.h from
331 # defining NI_NUMERICHOST.
332 QNX/6.3.2)
333 define_xopen_source=no
334 ;;
Bob Ippolito7026a0a2005-03-28 23:23:47 +0000335
Martin v. Löwise981a4e2002-11-11 13:26:51 +0000336esac
337
338if test $define_xopen_source = yes
339then
Skip Montanarof0d5f792004-08-15 14:08:23 +0000340 # On Solaris w/ g++ it appears that _XOPEN_SOURCE has to be
341 # defined precisely as g++ defines it
Martin v. Löwis7dece662005-11-26 11:38:24 +0000342 # Furthermore, on Solaris 10, XPG6 requires the use of a C99
343 # compiler
Skip Montanarof0d5f792004-08-15 14:08:23 +0000344 case $ac_sys_system/$ac_sys_release in
Martin v. Löwis7dece662005-11-26 11:38:24 +0000345 SunOS/5.8|SunOS/5.9|SunOS/5.10)
Skip Montanarof0d5f792004-08-15 14:08:23 +0000346 AC_DEFINE(_XOPEN_SOURCE, 500,
347 Define to the level of X/Open that your system supports)
348 ;;
349 *)
350 AC_DEFINE(_XOPEN_SOURCE, 600,
351 Define to the level of X/Open that your system supports)
352 ;;
353 esac
Martin v. Löwis678fc1e2002-11-12 06:04:39 +0000354
355 # On Tru64 Unix 4.0F, defining _XOPEN_SOURCE also requires
356 # definition of _XOPEN_SOURCE_EXTENDED and _POSIX_C_SOURCE, or else
357 # several APIs are not declared. Since this is also needed in some
358 # cases for HP-UX, we define it globally.
Martin v. Löwis7dece662005-11-26 11:38:24 +0000359 # except for Solaris 10, where it must not be defined,
360 # as it implies XPG4.2
361 case $ac_sys_system/$ac_sys_release in
362 SunOS/5.10)
363 ;;
364 *)
365 AC_DEFINE(_XOPEN_SOURCE_EXTENDED, 1,
366 Define to activate Unix95-and-earlier features)
367 ;;
368 esac
Martin v. Löwis678fc1e2002-11-12 06:04:39 +0000369
Bob Ippolito7026a0a2005-03-28 23:23:47 +0000370 AC_DEFINE(_POSIX_C_SOURCE, 200112L, Define to activate features from IEEE Stds 1003.1-2001)
371
Martin v. Löwise981a4e2002-11-11 13:26:51 +0000372fi
373
Guido van Rossum91922671997-10-09 20:24:13 +0000374#
375# SGI compilers allow the specification of the both the ABI and the
376# ISA on the command line. Depending on the values of these switches,
377# different and often incompatable code will be generated.
378#
379# The SGI_ABI variable can be used to modify the CC and LDFLAGS and
380# thus supply support for various ABI/ISA combinations. The MACHDEP
381# variable is also adjusted.
382#
383AC_SUBST(SGI_ABI)
384if test ! -z "$SGI_ABI"
385then
386 CC="cc $SGI_ABI"
387 LDFLAGS="$SGI_ABI $LDFLAGS"
388 MACHDEP=`echo "${MACHDEP}${SGI_ABI}" | sed 's/ *//g'`
389fi
Guido van Rossumb418f891996-07-30 18:06:02 +0000390AC_MSG_RESULT($MACHDEP)
391
Jack Jansen6b08a402004-06-03 12:41:45 +0000392# Record the configure-time value of MACOSX_DEPLOYMENT_TARGET,
393# it may influence the way we can build extensions, so distutils
394# needs to check it
395AC_SUBST(CONFIGURE_MACOSX_DEPLOYMENT_TARGET)
Thomas Wouters477c8d52006-05-27 19:21:47 +0000396AC_SUBST(EXPORT_MACOSX_DEPLOYMENT_TARGET)
Jack Jansen6b08a402004-06-03 12:41:45 +0000397CONFIGURE_MACOSX_DEPLOYMENT_TARGET=
Thomas Wouters477c8d52006-05-27 19:21:47 +0000398EXPORT_MACOSX_DEPLOYMENT_TARGET='#'
Jack Jansen6b08a402004-06-03 12:41:45 +0000399
Mark Dickinsonb0e2b4c2008-04-26 20:48:56 +0000400AC_MSG_CHECKING(machine type as reported by uname -m)
401ac_sys_machine=`uname -m`
402AC_MSG_RESULT($ac_sys_machine)
403
Guido van Rossum627b2d71993-12-24 10:39:16 +0000404# checks for alternative programs
Skip Montanarodecc6a42003-01-01 20:07:49 +0000405
406# compiler flags are generated in two sets, BASECFLAGS and OPT. OPT is just
407# for debug/optimization stuff. BASECFLAGS is for flags that are required
408# just to get things to compile and link. Users are free to override OPT
409# when running configure or make. The build should not break if they do.
410# BASECFLAGS should generally not be messed with, however.
411
412# XXX shouldn't some/most/all of this code be merged with the stuff later
413# on that fiddles with OPT and BASECFLAGS?
Guido van Rossum5739e7e1995-01-20 16:50:53 +0000414AC_MSG_CHECKING(for --without-gcc)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000415AC_ARG_WITH(gcc,
416 AC_HELP_STRING(--without-gcc,never use gcc),
417[
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000418 case $withval in
Benjamin Peterson960cf0f2009-01-09 04:11:44 +0000419 no) CC=${CC:-cc}
Guido van Rossum5739e7e1995-01-20 16:50:53 +0000420 without_gcc=yes;;
421 yes) CC=gcc
422 without_gcc=no;;
423 *) CC=$withval
424 without_gcc=$withval;;
Guido van Rossum55a214e1995-09-13 17:48:09 +0000425 esac], [
Guido van Rossumb418f891996-07-30 18:06:02 +0000426 case $ac_sys_system in
Neil Schemenauerb3531b82001-02-16 04:09:05 +0000427 AIX*) CC=cc_r
428 without_gcc=;;
Martin v. Löwis130fb172001-07-19 11:00:41 +0000429 *) without_gcc=no;;
Guido van Rossum55a214e1995-09-13 17:48:09 +0000430 esac])
Guido van Rossum5739e7e1995-01-20 16:50:53 +0000431AC_MSG_RESULT($without_gcc)
432
Guido van Rossum03ad99f1995-03-09 14:09:54 +0000433# If the user switches compilers, we can't believe the cache
434if test ! -z "$ac_cv_prog_CC" -a ! -z "$CC" -a "$CC" != "$ac_cv_prog_CC"
435then
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000436 AC_MSG_ERROR([cached CC is different -- throw away $cache_file
437(it is also a good idea to do 'make clean' before compiling)])
Guido van Rossum03ad99f1995-03-09 14:09:54 +0000438fi
439
Guido van Rossum627b2d71993-12-24 10:39:16 +0000440AC_PROG_CC
Martin v. Löwis1d5ecb72001-08-09 10:29:44 +0000441
Thomas Wouters49fd7fa2006-04-21 10:40:58 +0000442AC_SUBST(CXX)
443AC_SUBST(MAINCC)
444AC_MSG_CHECKING(for --with-cxx-main=<compiler>)
445AC_ARG_WITH(cxx_main,
446 AC_HELP_STRING([--with-cxx-main=<compiler>],
447 [compile main() and link python executable with C++ compiler]),
448[
449
450 case $withval in
451 no) with_cxx_main=no
452 MAINCC='$(CC)';;
453 yes) with_cxx_main=yes
454 MAINCC='$(CXX)';;
455 *) with_cxx_main=yes
456 MAINCC=$withval
457 if test -z "$CXX"
458 then
459 CXX=$withval
460 fi;;
461 esac], [
462 with_cxx_main=no
463 MAINCC='$(CC)'
464])
465AC_MSG_RESULT($with_cxx_main)
466
467preset_cxx="$CXX"
468if test -z "$CXX"
469then
470 case "$CC" in
471 gcc) AC_PATH_PROG(CXX, [g++], [g++], [notfound]) ;;
472 cc) AC_PATH_PROG(CXX, [c++], [c++], [notfound]) ;;
473 esac
474 if test "$CXX" = "notfound"
475 then
476 CXX=""
477 fi
478fi
479if test -z "$CXX"
480then
481 AC_CHECK_PROGS(CXX, $CCC c++ g++ gcc CC cxx cc++ cl, notfound)
482 if test "$CXX" = "notfound"
483 then
484 CXX=""
485 fi
486fi
487if test "$preset_cxx" != "$CXX"
488then
489 AC_MSG_WARN([
490
491 By default, distutils will build C++ extension modules with "$CXX".
492 If this is not intended, then set CXX on the configure command line.
493 ])
494fi
495
496
Martin v. Löwis1d5ecb72001-08-09 10:29:44 +0000497# checks for UNIX variants that set C preprocessor variables
498AC_AIX
Martin v. Löwis1d5ecb72001-08-09 10:29:44 +0000499
Martin v. Löwis779ffc02002-12-02 22:17:01 +0000500# Check for unsupported systems
501case $ac_sys_system/$ac_sys_release in
Guido van Rossumcd16bf62007-06-13 18:07:49 +0000502atheos*|Linux*/1*)
Martin v. Löwis779ffc02002-12-02 22:17:01 +0000503 echo This system \($ac_sys_system/$ac_sys_release\) is no longer supported.
504 echo See README for details.
505 exit 1;;
506esac
507
Neil Schemenauer55f0cf32001-01-24 17:24:33 +0000508AC_EXEEXT
Neil Schemenauer3ae1d0a2001-01-27 06:54:42 +0000509AC_MSG_CHECKING(for --with-suffix)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000510AC_ARG_WITH(suffix,
511 AC_HELP_STRING(--with-suffix=.exe, set executable suffix),
512[
Neil Schemenauer3ae1d0a2001-01-27 06:54:42 +0000513 case $withval in
514 no) EXEEXT=;;
515 yes) EXEEXT=.exe;;
516 *) EXEEXT=$withval;;
517 esac])
518AC_MSG_RESULT($EXEEXT)
Jack Jansen1999ef42001-12-06 21:47:20 +0000519
Jack Jansen9a66b6d2001-08-08 13:56:14 +0000520# Test whether we're running on a non-case-sensitive system, in which
521# case we give a warning if no ext is given
Jack Jansen1999ef42001-12-06 21:47:20 +0000522AC_SUBST(BUILDEXEEXT)
523AC_MSG_CHECKING(for case-insensitive build directory)
Jack Jansen3c2c4332002-11-06 13:33:32 +0000524if test ! -d CaseSensitiveTestDir; then
525mkdir CaseSensitiveTestDir
526fi
527
528if test -d casesensitivetestdir
Jack Jansen9a66b6d2001-08-08 13:56:14 +0000529then
Jack Jansen1999ef42001-12-06 21:47:20 +0000530 AC_MSG_RESULT(yes)
531 BUILDEXEEXT=.exe
532else
533 AC_MSG_RESULT(no)
Jack Jansendd19cf82001-12-06 22:36:17 +0000534 BUILDEXEEXT=$EXEEXT
Jack Jansen9a66b6d2001-08-08 13:56:14 +0000535fi
Jack Jansen3c2c4332002-11-06 13:33:32 +0000536rmdir CaseSensitiveTestDir
Guido van Rossumfb842551997-08-06 23:42:07 +0000537
Guido van Rossumdd997f71998-10-07 19:58:26 +0000538case $MACHDEP in
539bsdos*)
540 case $CC in
541 gcc) CC="$CC -D_HAVE_BSDI";;
542 esac;;
543esac
544
Guido van Rossum84561611997-08-21 00:08:11 +0000545case $ac_sys_system in
546hp*|HP*)
547 case $CC in
Guido van Rossumcd5ff9f2000-09-22 16:15:54 +0000548 cc|*/cc) CC="$CC -Ae";;
Guido van Rossum84561611997-08-21 00:08:11 +0000549 esac;;
Martin v. Löwise8964d42001-03-06 12:09:07 +0000550SunOS*)
551 # Some functions have a prototype only with that define, e.g. confstr
Martin v. Löwisc45929e2002-04-06 10:10:49 +0000552 AC_DEFINE(__EXTENSIONS__, 1, [Defined on Solaris to see additional function prototypes.])
Martin v. Löwise8964d42001-03-06 12:09:07 +0000553 ;;
Guido van Rossum84561611997-08-21 00:08:11 +0000554esac
555
Martin v. Löwise8964d42001-03-06 12:09:07 +0000556
Neil Schemenauer61c51152001-01-26 16:18:16 +0000557AC_SUBST(LIBRARY)
558AC_MSG_CHECKING(LIBRARY)
559if test -z "$LIBRARY"
560then
561 LIBRARY='libpython$(VERSION).a'
562fi
563AC_MSG_RESULT($LIBRARY)
564
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000565# LDLIBRARY is the name of the library to link against (as opposed to the
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000566# name of the library into which to insert object files). BLDLIBRARY is also
567# the library to link against, usually. On Mac OS X frameworks, BLDLIBRARY
568# is blank as the main program is not linked directly against LDLIBRARY.
569# LDLIBRARYDIR is the path to LDLIBRARY, which is made in a subdirectory. On
570# systems without shared libraries, LDLIBRARY is the same as LIBRARY
571# (defined in the Makefiles). On Cygwin LDLIBRARY is the import library,
572# DLLLIBRARY is the shared (i.e., DLL) library.
573#
Martin v. Löwis1142de32002-03-29 16:28:31 +0000574# RUNSHARED is used to run shared python without installed libraries
575#
576# INSTSONAME is the name of the shared library that will be use to install
577# on the system - some systems like version suffix, others don't
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000578AC_SUBST(LDLIBRARY)
Guido van Rossum27552902001-01-23 01:52:26 +0000579AC_SUBST(DLLLIBRARY)
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000580AC_SUBST(BLDLIBRARY)
581AC_SUBST(LDLIBRARYDIR)
Martin v. Löwis1142de32002-03-29 16:28:31 +0000582AC_SUBST(INSTSONAME)
583AC_SUBST(RUNSHARED)
Neil Schemenauer61c51152001-01-26 16:18:16 +0000584LDLIBRARY="$LIBRARY"
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000585BLDLIBRARY='$(LDLIBRARY)'
Martin v. Löwis09bdf722002-05-08 08:51:29 +0000586INSTSONAME='$(LDLIBRARY)'
Guido van Rossum27552902001-01-23 01:52:26 +0000587DLLLIBRARY=''
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000588LDLIBRARYDIR=''
Martin v. Löwis1142de32002-03-29 16:28:31 +0000589RUNSHARED=''
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000590
Guido van Rossumfb842551997-08-06 23:42:07 +0000591# LINKCC is the command that links the python executable -- default is $(CC).
Martin v. Löwisb7da67a2001-10-18 15:35:38 +0000592# If CXX is set, and if it is needed to link a main function that was
593# compiled with CXX, LINKCC is CXX instead. Always using CXX is undesirable:
594# python might then depend on the C++ runtime
Fred Drake5790be12000-10-09 17:06:13 +0000595# This is altered for AIX in order to build the export list before
Guido van Rossumec95c7b1998-08-04 17:59:56 +0000596# linking.
Guido van Rossumfb842551997-08-06 23:42:07 +0000597AC_SUBST(LINKCC)
598AC_MSG_CHECKING(LINKCC)
599if test -z "$LINKCC"
600then
Thomas Wouters49fd7fa2006-04-21 10:40:58 +0000601 LINKCC='$(PURIFY) $(MAINCC)'
Guido van Rossumfb842551997-08-06 23:42:07 +0000602 case $ac_sys_system in
603 AIX*)
Neal Norwitz0b27ff92003-03-31 15:53:49 +0000604 exp_extra="\"\""
605 if test $ac_sys_release -ge 5 -o \
606 $ac_sys_release -eq 4 -a `uname -r` -ge 2 ; then
607 exp_extra="."
608 fi
609 LINKCC="\$(srcdir)/Modules/makexp_aix Modules/python.exp $exp_extra \$(LIBRARY); $LINKCC";;
Georg Brandlf78e02b2008-06-10 17:40:04 +0000610 QNX*)
611 # qcc must be used because the other compilers do not
612 # support -N.
613 LINKCC=qcc;;
Guido van Rossumfb842551997-08-06 23:42:07 +0000614 esac
615fi
616AC_MSG_RESULT($LINKCC)
617
Tarek Ziadébe720e02009-05-09 11:55:12 +0000618# GNULD is set to "yes" if the GNU linker is used. If this goes wrong
619# make sure we default having it set to "no": this is used by
620# distutils.unixccompiler to know if it should add --enable-new-dtags
621# to linker command lines, and failing to detect GNU ld simply results
622# in the same bahaviour as before.
623AC_SUBST(GNULD)
624AC_MSG_CHECKING(for GNU ld)
625ac_prog=ld
626if test "$GCC" = yes; then
627 ac_prog=`$CC -print-prog-name=ld`
628fi
629case `"$ac_prog" -V 2>&1 < /dev/null` in
630 *GNU*)
631 GNULD=yes;;
632 *)
633 GNULD=no;;
634esac
635AC_MSG_RESULT($GNULD)
636
Martin v. Löwis1142de32002-03-29 16:28:31 +0000637AC_MSG_CHECKING(for --enable-shared)
638AC_ARG_ENABLE(shared,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000639 AC_HELP_STRING(--enable-shared, disable/enable building shared python library))
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000640
Martin v. Löwis1142de32002-03-29 16:28:31 +0000641if test -z "$enable_shared"
642then
Martin v. Löwisb51033d2002-05-03 05:53:15 +0000643 case $ac_sys_system in
Antoine Pitrou6103ab12009-10-24 20:11:21 +0000644 CYGWIN*)
Martin v. Löwisb51033d2002-05-03 05:53:15 +0000645 enable_shared="yes";;
646 *)
647 enable_shared="no";;
648 esac
Martin v. Löwis1142de32002-03-29 16:28:31 +0000649fi
650AC_MSG_RESULT($enable_shared)
651
Skip Montanaro56f6a4f2004-06-18 02:47:22 +0000652AC_MSG_CHECKING(for --enable-profiling)
653AC_ARG_ENABLE(profiling,
654 AC_HELP_STRING(--enable-profiling, enable C-level code profiling),
655[ac_save_cc="$CC"
656 CC="$CC -pg"
657 AC_TRY_RUN([int main() { return 0; }],
658 ac_enable_profiling="yes",
659 ac_enable_profiling="no",
660 ac_enable_profiling="no")
661 CC="$ac_save_cc"])
662AC_MSG_RESULT($ac_enable_profiling)
663
664case "$ac_enable_profiling" in
665 "yes")
666 BASECFLAGS="-pg $BASECFLAGS"
667 LDFLAGS="-pg $LDFLAGS"
668 ;;
669esac
Martin v. Löwis1142de32002-03-29 16:28:31 +0000670
671AC_MSG_CHECKING(LDLIBRARY)
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000672
Guido van Rossumb8552162001-09-05 14:58:11 +0000673# MacOSX framework builds need more magic. LDLIBRARY is the dynamic
674# library that we build, but we do not want to link against it (we
675# will find it with a -framework option). For this reason there is an
676# extra variable BLDLIBRARY against which Python and the extension
677# modules are linked, BLDLIBRARY. This is normally the same as
678# LDLIBRARY, but empty for MacOSX framework builds.
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000679if test "$enable_framework"
680then
681 LDLIBRARY='$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansen66b84832003-07-04 12:14:39 +0000682 RUNSHARED=DYLD_FRAMEWORK_PATH="`pwd`:$DYLD_FRAMEWORK_PATH"
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000683 BLDLIBRARY=''
684else
685 BLDLIBRARY='$(LDLIBRARY)'
686fi
687
Martin v. Löwis1142de32002-03-29 16:28:31 +0000688# Other platforms follow
689if test $enable_shared = "yes"; then
Mark Hammond8235ea12002-07-19 06:55:41 +0000690 AC_DEFINE(Py_ENABLE_SHARED, 1, [Defined if Python is built as a shared library.])
Martin v. Löwis1142de32002-03-29 16:28:31 +0000691 case $ac_sys_system in
Martin v. Löwis1142de32002-03-29 16:28:31 +0000692 CYGWIN*)
693 LDLIBRARY='libpython$(VERSION).dll.a'
694 DLLLIBRARY='libpython$(VERSION).dll'
695 ;;
696 SunOS*)
697 LDLIBRARY='libpython$(VERSION).so'
Martin v. Löwisd141a8c2003-06-14 15:20:28 +0000698 BLDLIBRARY='-Wl,-R,$(LIBDIR) -L. -lpython$(VERSION)'
Martin v. Löwisfc9b75f2003-08-09 09:06:52 +0000699 RUNSHARED=LD_LIBRARY_PATH=`pwd`:${LD_LIBRARY_PATH}
Martin v. Löwis2389c412003-10-31 15:42:07 +0000700 INSTSONAME="$LDLIBRARY".$SOVERSION
Martin v. Löwis1142de32002-03-29 16:28:31 +0000701 ;;
Martin v. Löwis86d66262006-02-17 08:40:11 +0000702 Linux*|GNU*|NetBSD*|FreeBSD*|DragonFly*)
Martin v. Löwis1142de32002-03-29 16:28:31 +0000703 LDLIBRARY='libpython$(VERSION).so'
704 BLDLIBRARY='-L. -lpython$(VERSION)'
Martin v. Löwisfc9b75f2003-08-09 09:06:52 +0000705 RUNSHARED=LD_LIBRARY_PATH=`pwd`:${LD_LIBRARY_PATH}
Hye-Shik Chang33761492004-10-26 09:53:46 +0000706 case $ac_sys_system in
707 FreeBSD*)
708 SOVERSION=`echo $SOVERSION|cut -d "." -f 1`
709 ;;
710 esac
Martin v. Löwis1142de32002-03-29 16:28:31 +0000711 INSTSONAME="$LDLIBRARY".$SOVERSION
712 ;;
713 hp*|HP*)
Thomas Wouters477c8d52006-05-27 19:21:47 +0000714 case `uname -m` in
715 ia64)
716 LDLIBRARY='libpython$(VERSION).so'
717 ;;
718 *)
719 LDLIBRARY='libpython$(VERSION).sl'
720 ;;
721 esac
Martin v. Löwis1142de32002-03-29 16:28:31 +0000722 BLDLIBRARY='-Wl,+b,$(LIBDIR) -L. -lpython$(VERSION)'
Martin v. Löwisfc9b75f2003-08-09 09:06:52 +0000723 RUNSHARED=SHLIB_PATH=`pwd`:${SHLIB_PATH}
Martin v. Löwis1142de32002-03-29 16:28:31 +0000724 ;;
725 OSF*)
726 LDLIBRARY='libpython$(VERSION).so'
Neal Norwitz671b9e32006-01-09 07:07:12 +0000727 BLDLIBRARY='-rpath $(LIBDIR) -L. -lpython$(VERSION)'
Martin v. Löwisfc9b75f2003-08-09 09:06:52 +0000728 RUNSHARED=LD_LIBRARY_PATH=`pwd`:${LD_LIBRARY_PATH}
Martin v. Löwis1142de32002-03-29 16:28:31 +0000729 ;;
Georg Brandlb1441c72009-01-03 22:33:39 +0000730 Darwin*)
731 LDLIBRARY='libpython$(VERSION).dylib'
732 BLDLIBRARY='-L. -lpython$(VERSION)'
733 RUNSHARED='DYLD_LIBRARY_PATH=`pwd`:${DYLD_LIBRARY_PATH}'
734 ;;
735
Martin v. Löwis1142de32002-03-29 16:28:31 +0000736 esac
Jason Tishler30765592003-09-04 11:04:06 +0000737else # shared is disabled
738 case $ac_sys_system in
739 CYGWIN*)
740 BLDLIBRARY='$(LIBRARY)'
741 LDLIBRARY='libpython$(VERSION).dll.a'
742 ;;
743 esac
Martin v. Löwis1142de32002-03-29 16:28:31 +0000744fi
745
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000746AC_MSG_RESULT($LDLIBRARY)
747
Guido van Rossum627b2d71993-12-24 10:39:16 +0000748AC_PROG_RANLIB
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000749AC_SUBST(AR)
Guido van Rossum76be6ed1995-01-02 18:33:54 +0000750AC_CHECK_PROGS(AR, ar aal, ar)
Neil Schemenauera42c8272001-03-31 00:01:55 +0000751
Tarek Ziadé5662d3e2009-05-07 21:24:43 +0000752# tweak ARFLAGS only if the user didn't set it on the command line
753AC_SUBST(ARFLAGS)
754if test -z "$ARFLAGS"
755then
756 ARFLAGS="rc"
757fi
758
Martin v. Löwisdea59e52006-01-05 10:00:36 +0000759AC_SUBST(SVNVERSION)
Thomas Wouters49fd7fa2006-04-21 10:40:58 +0000760AC_CHECK_PROG(SVNVERSION, svnversion, found, not-found)
Martin v. Löwisc5bf5a02006-01-05 10:33:59 +0000761if test $SVNVERSION = found
762then
763 SVNVERSION="svnversion \$(srcdir)"
764else
Benjamin Petersonf53eec82009-05-23 19:36:27 +0000765 SVNVERSION="echo Unversioned directory"
Martin v. Löwisc5bf5a02006-01-05 10:33:59 +0000766fi
Martin v. Löwisdea59e52006-01-05 10:00:36 +0000767
Neil Schemenauera42c8272001-03-31 00:01:55 +0000768case $MACHDEP in
Neil Schemenaueraf5567f2001-10-21 22:32:04 +0000769bsdos*|hp*|HP*)
770 # install -d does not work on BSDI or HP-UX
Neil Schemenauera42c8272001-03-31 00:01:55 +0000771 if test -z "$INSTALL"
772 then
773 INSTALL="${srcdir}/install-sh -c"
774 fi
775esac
Neil Schemenauer55f0cf32001-01-24 17:24:33 +0000776AC_PROG_INSTALL
Guido van Rossumb418f891996-07-30 18:06:02 +0000777
Guido van Rossumec95c7b1998-08-04 17:59:56 +0000778# Not every filesystem supports hard links
779AC_SUBST(LN)
780if test -z "$LN" ; then
781 case $ac_sys_system in
Guido van Rossumaef734b2001-01-10 21:09:12 +0000782 CYGWIN*) LN="ln -s";;
Guido van Rossumec95c7b1998-08-04 17:59:56 +0000783 *) LN=ln;;
784 esac
785fi
786
Fred Drake9f715822001-07-11 06:27:00 +0000787# Check for --with-pydebug
788AC_MSG_CHECKING(for --with-pydebug)
789AC_ARG_WITH(pydebug,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000790 AC_HELP_STRING(--with-pydebug, build with Py_DEBUG defined),
791[
Fred Drake9f715822001-07-11 06:27:00 +0000792if test "$withval" != no
Martin v. Löwisc45929e2002-04-06 10:10:49 +0000793then
794 AC_DEFINE(Py_DEBUG, 1,
795 [Define if you want to build an interpreter with many run-time checks.])
796 AC_MSG_RESULT(yes);
797 Py_DEBUG='true'
Fred Drake9f715822001-07-11 06:27:00 +0000798else AC_MSG_RESULT(no); Py_DEBUG='false'
799fi],
800[AC_MSG_RESULT(no)])
801
Skip Montanarodecc6a42003-01-01 20:07:49 +0000802# XXX Shouldn't the code above that fiddles with BASECFLAGS and OPT be
803# merged with this chunk of code?
804
Neil Schemenauer55f0cf32001-01-24 17:24:33 +0000805# Optimizer/debugger flags
Skip Montanarodecc6a42003-01-01 20:07:49 +0000806# ------------------------
807# (The following bit of code is complicated enough - please keep things
808# indented properly. Just pretend you're editing Python code. ;-)
809
810# There are two parallel sets of case statements below, one that checks to
811# see if OPT was set and one that does BASECFLAGS setting based upon
812# compiler and platform. BASECFLAGS tweaks need to be made even if the
813# user set OPT.
814
815# tweak OPT based on compiler and platform, only if the user didn't set
816# it on the command line
Guido van Rossumb418f891996-07-30 18:06:02 +0000817AC_SUBST(OPT)
Guido van Rossum4e8af441994-08-19 15:33:54 +0000818if test -z "$OPT"
Guido van Rossumb418f891996-07-30 18:06:02 +0000819then
Skip Montanarodecc6a42003-01-01 20:07:49 +0000820 case $GCC in
821 yes)
Thomas Wouters49fd7fa2006-04-21 10:40:58 +0000822 if test "$CC" != 'g++' ; then
823 STRICT_PROTO="-Wstrict-prototypes"
824 fi
Christian Heimes38053212007-12-14 01:24:44 +0000825 # For gcc 4.x we need to use -fwrapv so lets check if its supported
826 if "$CC" -v --help 2>/dev/null |grep -- -fwrapv > /dev/null; then
827 WRAP="-fwrapv"
828 fi
Skip Montanarodecc6a42003-01-01 20:07:49 +0000829 case $ac_cv_prog_cc_g in
Guido van Rossum2242f2f2001-04-11 20:58:20 +0000830 yes)
Fred Drake9f715822001-07-11 06:27:00 +0000831 if test "$Py_DEBUG" = 'true' ; then
832 # Optimization messes up debuggers, so turn it off for
833 # debug builds.
Thomas Wouters49fd7fa2006-04-21 10:40:58 +0000834 OPT="-g -Wall $STRICT_PROTO"
Fred Drake9f715822001-07-11 06:27:00 +0000835 else
Christian Heimes38053212007-12-14 01:24:44 +0000836 OPT="-g $WRAP -O3 -Wall $STRICT_PROTO"
Skip Montanarodecc6a42003-01-01 20:07:49 +0000837 fi
838 ;;
Guido van Rossum2242f2f2001-04-11 20:58:20 +0000839 *)
Thomas Wouters49fd7fa2006-04-21 10:40:58 +0000840 OPT="-O3 -Wall $STRICT_PROTO"
Skip Montanarodecc6a42003-01-01 20:07:49 +0000841 ;;
Fred Drake9f715822001-07-11 06:27:00 +0000842 esac
Martin v. Löwis21ee4092002-09-30 16:19:48 +0000843 case $ac_sys_system in
Skip Montanarodecc6a42003-01-01 20:07:49 +0000844 SCO_SV*) OPT="$OPT -m486 -DSCO5"
845 ;;
846 esac
Fred Drake9f715822001-07-11 06:27:00 +0000847 ;;
Skip Montanarodecc6a42003-01-01 20:07:49 +0000848
Guido van Rossum2242f2f2001-04-11 20:58:20 +0000849 *)
Skip Montanarodecc6a42003-01-01 20:07:49 +0000850 OPT="-O"
851 ;;
Guido van Rossum2242f2f2001-04-11 20:58:20 +0000852 esac
Guido van Rossum4e8af441994-08-19 15:33:54 +0000853fi
Guido van Rossum627b2d71993-12-24 10:39:16 +0000854
Skip Montanarodecc6a42003-01-01 20:07:49 +0000855AC_SUBST(BASECFLAGS)
Georg Brandlfcaf9102008-07-16 02:17:56 +0000856
857# The -arch flags for universal builds on OSX
858UNIVERSAL_ARCH_FLAGS=
859AC_SUBST(UNIVERSAL_ARCH_FLAGS)
860
Skip Montanarodecc6a42003-01-01 20:07:49 +0000861# tweak BASECFLAGS based on compiler and platform
862case $GCC in
863yes)
Martin v. Löwis70fedcd2003-07-07 21:26:19 +0000864 # Python violates C99 rules, by casting between incompatible
865 # pointer types. GCC may generate bad code as a result of that,
866 # so use -fno-strict-aliasing if supported.
867 AC_MSG_CHECKING(whether $CC accepts -fno-strict-aliasing)
868 ac_save_cc="$CC"
869 CC="$CC -fno-strict-aliasing"
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +0000870 AC_CACHE_VAL(ac_cv_no_strict_aliasing_ok,
Gregory P. Smith4e3ed012009-11-01 21:09:10 +0000871 AC_TRY_COMPILE([],[int main() { return 0; }],
Martin v. Löwis70fedcd2003-07-07 21:26:19 +0000872 ac_cv_no_strict_aliasing_ok=yes,
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +0000873 ac_cv_no_strict_aliasing_ok=no))
Martin v. Löwis70fedcd2003-07-07 21:26:19 +0000874 CC="$ac_save_cc"
875 AC_MSG_RESULT($ac_cv_no_strict_aliasing_ok)
876 if test $ac_cv_no_strict_aliasing_ok = yes
877 then
878 BASECFLAGS="$BASECFLAGS -fno-strict-aliasing"
879 fi
Mark Dickinsonb0e2b4c2008-04-26 20:48:56 +0000880
881 # if using gcc on alpha, use -mieee to get (near) full IEEE 754
882 # support. Without this, treatment of subnormals doesn't follow
883 # the standard.
884 case $ac_sys_machine in
885 alpha*)
886 BASECFLAGS="$BASECFLAGS -mieee"
887 ;;
888 esac
889
Skip Montanarodecc6a42003-01-01 20:07:49 +0000890 case $ac_sys_system in
891 SCO_SV*)
892 BASECFLAGS="$BASECFLAGS -m486 -DSCO5"
893 ;;
894 # is there any other compiler on Darwin besides gcc?
895 Darwin*)
Christian Heimesb186d002008-03-18 15:15:01 +0000896 # -Wno-long-double, -no-cpp-precomp, and -mno-fused-madd
897 # used to be here, but non-Apple gcc doesn't accept them.
Benjamin Peterson67c38e22008-07-17 16:10:34 +0000898
899
Thomas Wouters477c8d52006-05-27 19:21:47 +0000900 if test "${enable_universalsdk}"; then
Georg Brandlfcaf9102008-07-16 02:17:56 +0000901 UNIVERSAL_ARCH_FLAGS=""
902 if test "$UNIVERSAL_ARCHS" = "32-bit" ; then
903 UNIVERSAL_ARCH_FLAGS="-arch ppc -arch i386"
Benjamin Peterson6794aa32008-07-16 20:33:37 +0000904 ARCH_RUN_32BIT=""
Ronald Oussoren6f6c5622009-12-24 14:03:19 +0000905 LIPO_32BIT_FLAGS="-extract ppc7400 -extract i386"
Georg Brandlfcaf9102008-07-16 02:17:56 +0000906
Ronald Oussoren755740f2010-02-07 19:56:39 +0000907 # You have to use different flags on various versions of
908 # OSX to extract PPC code from an universal binary, basically
909 # '-arch ppc' on OSX 10.4 and '-arch ppc7400' on anything
910 # newer.
911 # Because '-arch pp7400' works on OSX 10.5 or higher this
912 # test is only present in the '32-bit' branch, all other
913 # branches require OSX 10.5 to compile.
914
915 AC_MSG_CHECKING(lipo flag for extracting ppc code)
916 FN="test.$$"
917 cat >${FN}.c <<-EOF
918 int main() { return 0; }
919EOF
920 ${CC} ${CFLAGS} -arch ppc -arch i386 -o ${FN} ${FN}.c -isysroot ${UNIVERSALSDK}
921 if test $? != 0 ; then
922 rm ${FN} ${FN}.c
923 AC_MSG_RESULT([failed, assumee -extract ppc7400])
924 else
925 lipo "${FN}" -extract ppc7400 -output "${FN}.out" 2>/dev/null
926 if test $? != 0 ; then
927 LIPO_32BIT_FLAGS="-extract ppc -extract i386"
928 AC_MSG_RESULT("'-extract ppc'")
929 else
930 AC_MSG_RESULT("'-extract ppc7400'")
931 fi
932 rm -f ${FN} ${FN}.c ${FN}.out
933 fi
934
Georg Brandlfcaf9102008-07-16 02:17:56 +0000935 elif test "$UNIVERSAL_ARCHS" = "64-bit" ; then
936 UNIVERSAL_ARCH_FLAGS="-arch ppc64 -arch x86_64"
Ronald Oussoren6f6c5622009-12-24 14:03:19 +0000937 LIPO_32BIT_FLAGS=""
Ronald Oussoren5bbab3e2009-09-06 11:01:15 +0000938 ARCH_RUN_32BIT="true"
Georg Brandlfcaf9102008-07-16 02:17:56 +0000939
940 elif test "$UNIVERSAL_ARCHS" = "all" ; then
941 UNIVERSAL_ARCH_FLAGS="-arch i386 -arch ppc -arch ppc64 -arch x86_64"
Ronald Oussoren6f6c5622009-12-24 14:03:19 +0000942 LIPO_32BIT_FLAGS="-extract ppc7400 -extract i386"
Ronald Oussoren564f7f22010-02-11 13:23:08 +0000943 ARCH_RUN_32BIT="/usr/bin/arch -i386 -ppc"
Georg Brandlfcaf9102008-07-16 02:17:56 +0000944
Ronald Oussoren3c064c12009-09-08 07:12:42 +0000945 elif test "$UNIVERSAL_ARCHS" = "intel" ; then
946 UNIVERSAL_ARCH_FLAGS="-arch i386 -arch x86_64"
Ronald Oussoren6f6c5622009-12-24 14:03:19 +0000947 LIPO_32BIT_FLAGS="-extract i386"
Ronald Oussoren564f7f22010-02-11 13:23:08 +0000948 ARCH_RUN_32BIT="/usr/bin/arch -i386"
Ronald Oussoren3c064c12009-09-08 07:12:42 +0000949
950 elif test "$UNIVERSAL_ARCHS" = "3-way" ; then
951 UNIVERSAL_ARCH_FLAGS="-arch i386 -arch ppc -arch x86_64"
Ronald Oussoren6f6c5622009-12-24 14:03:19 +0000952 LIPO_32BIT_FLAGS="-extract ppc7400 -extract i386"
Ronald Oussoren564f7f22010-02-11 13:23:08 +0000953 ARCH_RUN_32BIT="/usr/bin/arch -i386 -ppc"
Ronald Oussoren3c064c12009-09-08 07:12:42 +0000954
Georg Brandlfcaf9102008-07-16 02:17:56 +0000955 else
Ronald Oussoren74f29b42009-09-20 20:09:26 +0000956 AC_MSG_ERROR([proper usage is --with-universal-arch=32-bit|64-bit|all|intel|3-way])
Georg Brandlfcaf9102008-07-16 02:17:56 +0000957
958 fi
959
960
961 BASECFLAGS="${UNIVERSAL_ARCH_FLAGS} -isysroot ${UNIVERSALSDK} ${BASECFLAGS}"
Georg Brandl3dbca812008-07-23 16:10:53 +0000962 tgt=`sw_vers -productVersion | sed 's/\(10\.[[0-9]]*\).*/\1/'`
Benjamin Peterson67c38e22008-07-17 16:10:34 +0000963 if test "${UNIVERSALSDK}" != "/" -a "${tgt}" '>' '10.4' ; then
964 CFLAGS="${UNIVERSAL_ARCH_FLAGS} -isysroot ${UNIVERSALSDK} ${CFLAGS}"
965 fi
Thomas Wouters477c8d52006-05-27 19:21:47 +0000966 fi
967
Benjamin Peterson67c38e22008-07-17 16:10:34 +0000968 # Calculate the right deployment target for this build.
969 #
970 cur_target=`sw_vers -productVersion | sed 's/\(10\.[[0-9]]*\).*/\1/'`
971 if test ${cur_target} '>' 10.2; then
972 cur_target=10.3
Ronald Oussoren5bbab3e2009-09-06 11:01:15 +0000973 if test ${enable_universalsdk}; then
974 if test "${UNIVERSAL_ARCHS}" = "all"; then
975 # Ensure that the default platform for a
976 # 4-way universal build is OSX 10.5,
977 # that's the first OS release where
978 # 4-way builds make sense.
979 cur_target='10.5'
Ronald Oussoren3c064c12009-09-08 07:12:42 +0000980
981 elif test "${UNIVERSAL_ARCHS}" = "3-way"; then
982 cur_target='10.5'
983
984 elif test "${UNIVERSAL_ARCHS}" = "intel"; then
985 cur_target='10.5'
986
987 elif test "${UNIVERSAL_ARCHS}" = "64-bit"; then
988 cur_target='10.5'
Ronald Oussoren5bbab3e2009-09-06 11:01:15 +0000989 fi
990 else
Ronald Oussorene3da75a2010-02-11 13:38:58 +0000991 if test `/usr/bin/arch` = "i386"; then
Ronald Oussoren5bbab3e2009-09-06 11:01:15 +0000992 # On Intel macs default to a deployment
993 # target of 10.4, that's the first OSX
994 # release with Intel support.
995 cur_target="10.4"
996 fi
997 fi
Benjamin Peterson67c38e22008-07-17 16:10:34 +0000998 fi
999 CONFIGURE_MACOSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET-${cur_target}}
1000
1001 # Make sure that MACOSX_DEPLOYMENT_TARGET is set in the
1002 # environment with a value that is the same as what we'll use
1003 # in the Makefile to ensure that we'll get the same compiler
1004 # environment during configure and build time.
1005 MACOSX_DEPLOYMENT_TARGET="$CONFIGURE_MACOSX_DEPLOYMENT_TARGET"
1006 export MACOSX_DEPLOYMENT_TARGET
1007 EXPORT_MACOSX_DEPLOYMENT_TARGET=''
1008
Skip Montanarodecc6a42003-01-01 20:07:49 +00001009 ;;
Thomas Wouters49fd7fa2006-04-21 10:40:58 +00001010 OSF*)
1011 BASECFLAGS="$BASECFLAGS -mieee"
1012 ;;
Skip Montanarodecc6a42003-01-01 20:07:49 +00001013 esac
1014 ;;
1015
1016*)
1017 case $ac_sys_system in
1018 OpenUNIX*|UnixWare*)
1019 BASECFLAGS="$BASECFLAGS -K pentium,host,inline,loop_unroll,alloca "
1020 ;;
Neal Norwitzb44f1652003-05-26 14:11:55 +00001021 OSF*)
1022 BASECFLAGS="$BASECFLAGS -ieee -std"
1023 ;;
Skip Montanarodecc6a42003-01-01 20:07:49 +00001024 SCO_SV*)
1025 BASECFLAGS="$BASECFLAGS -belf -Ki486 -DSCO5"
1026 ;;
1027 esac
1028 ;;
1029esac
1030
Fred Drakee1ceaa02001-12-04 20:55:47 +00001031if test "$Py_DEBUG" = 'true'; then
1032 :
1033else
1034 OPT="-DNDEBUG $OPT"
1035fi
1036
Guido van Rossum6f2260e1996-09-09 16:21:03 +00001037if test "$ac_arch_flags"
Guido van Rossumc5a39031996-07-31 17:35:03 +00001038then
Skip Montanarodecc6a42003-01-01 20:07:49 +00001039 BASECFLAGS="$BASECFLAGS $ac_arch_flags"
Guido van Rossumc5a39031996-07-31 17:35:03 +00001040fi
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001041
Neal Norwitz020c46a2006-01-07 21:39:28 +00001042# disable check for icc since it seems to pass, but generates a warning
1043if test "$CC" = icc
1044then
1045 ac_cv_opt_olimit_ok=no
1046fi
1047
Guido van Rossum91922671997-10-09 20:24:13 +00001048AC_MSG_CHECKING(whether $CC accepts -OPT:Olimit=0)
1049AC_CACHE_VAL(ac_cv_opt_olimit_ok,
1050[ac_save_cc="$CC"
1051CC="$CC -OPT:Olimit=0"
Gregory P. Smith4e3ed012009-11-01 21:09:10 +00001052AC_TRY_COMPILE([],[int main() { return 0; }],
Guido van Rossum91922671997-10-09 20:24:13 +00001053 ac_cv_opt_olimit_ok=yes,
Guido van Rossum3065c942001-09-17 04:03:14 +00001054 ac_cv_opt_olimit_ok=no,
Gregory P. Smith4e3ed012009-11-01 21:09:10 +00001055 )
Guido van Rossum91922671997-10-09 20:24:13 +00001056CC="$ac_save_cc"])
1057AC_MSG_RESULT($ac_cv_opt_olimit_ok)
Guido van Rossum2efa34b1997-10-23 17:43:11 +00001058if test $ac_cv_opt_olimit_ok = yes; then
Guido van Rossum5839e582000-10-09 19:52:35 +00001059 case $ac_sys_system in
Skip Montanarodecc6a42003-01-01 20:07:49 +00001060 # XXX is this branch needed? On MacOSX 10.2.2 the result of the
1061 # olimit_ok test is "no". Is it "yes" in some other Darwin-esque
1062 # environment?
1063 Darwin*)
1064 ;;
1065 *)
1066 BASECFLAGS="$BASECFLAGS -OPT:Olimit=0"
1067 ;;
Guido van Rossum5839e582000-10-09 19:52:35 +00001068 esac
Guido van Rossumf8678121998-07-07 21:05:09 +00001069else
1070 AC_MSG_CHECKING(whether $CC accepts -Olimit 1500)
1071 AC_CACHE_VAL(ac_cv_olimit_ok,
1072 [ac_save_cc="$CC"
1073 CC="$CC -Olimit 1500"
Gregory P. Smith4e3ed012009-11-01 21:09:10 +00001074 AC_TRY_COMPILE([],[int main() { return 0; }],
Guido van Rossumf8678121998-07-07 21:05:09 +00001075 ac_cv_olimit_ok=yes,
Guido van Rossum3065c942001-09-17 04:03:14 +00001076 ac_cv_olimit_ok=no,
Gregory P. Smith4e3ed012009-11-01 21:09:10 +00001077 )
Guido van Rossumf8678121998-07-07 21:05:09 +00001078 CC="$ac_save_cc"])
1079 AC_MSG_RESULT($ac_cv_olimit_ok)
1080 if test $ac_cv_olimit_ok = yes; then
Skip Montanarodecc6a42003-01-01 20:07:49 +00001081 BASECFLAGS="$BASECFLAGS -Olimit 1500"
Guido van Rossumf8678121998-07-07 21:05:09 +00001082 fi
Guido van Rossum201afe51997-05-14 21:14:44 +00001083fi
Guido van Rossumf8678121998-07-07 21:05:09 +00001084
Thomas Wouters89f507f2006-12-13 04:49:30 +00001085# Check whether GCC supports PyArg_ParseTuple format
1086if test "$GCC" = "yes"
1087then
1088 AC_MSG_CHECKING(whether gcc supports ParseTuple __format__)
1089 save_CFLAGS=$CFLAGS
1090 CFLAGS="$CFLAGS -Werror"
1091 AC_TRY_COMPILE([
1092 void f(char*,...)__attribute((format(PyArg_ParseTuple, 1, 2)));
1093 ],,
1094 AC_DEFINE(HAVE_ATTRIBUTE_FORMAT_PARSETUPLE, 1, [Define if GCC supports __attribute__((format(PyArg_ParseTuple, 2, 3)))])
1095 AC_MSG_RESULT(yes),
1096 AC_MSG_RESULT(no)
1097 )
1098 CFLAGS=$save_CFLAGS
1099fi
1100
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00001101# On some compilers, pthreads are available without further options
1102# (e.g. MacOS X). On some of these systems, the compiler will not
1103# complain if unaccepted options are passed (e.g. gcc on Mac OS X).
1104# So we have to see first whether pthreads are available without
1105# options before we can check whether -Kpthread improves anything.
1106AC_MSG_CHECKING(whether pthreads are available without options)
1107AC_CACHE_VAL(ac_cv_pthread_is_default,
1108[AC_TRY_RUN([
1109#include <pthread.h>
1110
1111void* routine(void* p){return NULL;}
1112
1113int main(){
1114 pthread_t p;
1115 if(pthread_create(&p,NULL,routine,NULL)!=0)
1116 return 1;
Jack Jansen4f8d0542002-03-08 13:43:01 +00001117 (void)pthread_detach(p);
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00001118 return 0;
1119}
1120],
Skip Montanarod8d39a02003-07-10 20:44:10 +00001121[
1122 ac_cv_pthread_is_default=yes
1123 ac_cv_kthread=no
1124 ac_cv_pthread=no
1125],
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00001126 ac_cv_pthread_is_default=no,
1127 ac_cv_pthread_is_default=no)
1128])
1129AC_MSG_RESULT($ac_cv_pthread_is_default)
1130
1131
1132if test $ac_cv_pthread_is_default = yes
1133then
1134 ac_cv_kpthread=no
1135else
Martin v. Löwis130fb172001-07-19 11:00:41 +00001136# -Kpthread, if available, provides the right #defines
1137# and linker options to make pthread_create available
Martin v. Löwis260aecc2001-10-07 08:14:41 +00001138# Some compilers won't report that they do not support -Kpthread,
1139# so we need to run a program to see whether it really made the
1140# function available.
Martin v. Löwis130fb172001-07-19 11:00:41 +00001141AC_MSG_CHECKING(whether $CC accepts -Kpthread)
1142AC_CACHE_VAL(ac_cv_kpthread,
1143[ac_save_cc="$CC"
1144CC="$CC -Kpthread"
Martin v. Löwis260aecc2001-10-07 08:14:41 +00001145AC_TRY_RUN([
1146#include <pthread.h>
1147
1148void* routine(void* p){return NULL;}
1149
1150int main(){
1151 pthread_t p;
1152 if(pthread_create(&p,NULL,routine,NULL)!=0)
1153 return 1;
Jack Jansen4f8d0542002-03-08 13:43:01 +00001154 (void)pthread_detach(p);
Martin v. Löwis260aecc2001-10-07 08:14:41 +00001155 return 0;
1156}
1157],
Martin v. Löwis130fb172001-07-19 11:00:41 +00001158 ac_cv_kpthread=yes,
Martin v. Löwis260aecc2001-10-07 08:14:41 +00001159 ac_cv_kpthread=no,
Martin v. Löwis130fb172001-07-19 11:00:41 +00001160 ac_cv_kpthread=no)
1161CC="$ac_save_cc"])
Martin v. Löwis130fb172001-07-19 11:00:41 +00001162AC_MSG_RESULT($ac_cv_kpthread)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00001163fi
Martin v. Löwis130fb172001-07-19 11:00:41 +00001164
Skip Montanarod8d39a02003-07-10 20:44:10 +00001165if test $ac_cv_kpthread = no -a $ac_cv_pthread_is_default = no
Martin v. Löwis5f433f02003-05-05 05:05:30 +00001166then
1167# -Kthread, if available, provides the right #defines
1168# and linker options to make pthread_create available
1169# Some compilers won't report that they do not support -Kthread,
1170# so we need to run a program to see whether it really made the
1171# function available.
1172AC_MSG_CHECKING(whether $CC accepts -Kthread)
1173AC_CACHE_VAL(ac_cv_kthread,
1174[ac_save_cc="$CC"
1175CC="$CC -Kthread"
1176AC_TRY_RUN([
1177#include <pthread.h>
1178
1179void* routine(void* p){return NULL;}
1180
1181int main(){
1182 pthread_t p;
1183 if(pthread_create(&p,NULL,routine,NULL)!=0)
1184 return 1;
1185 (void)pthread_detach(p);
1186 return 0;
1187}
1188],
1189 ac_cv_kthread=yes,
1190 ac_cv_kthread=no,
1191 ac_cv_kthread=no)
1192CC="$ac_save_cc"])
1193AC_MSG_RESULT($ac_cv_kthread)
1194fi
1195
Skip Montanarod8d39a02003-07-10 20:44:10 +00001196if test $ac_cv_kthread = no -a $ac_cv_pthread_is_default = no
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00001197then
1198# -pthread, if available, provides the right #defines
1199# and linker options to make pthread_create available
1200# Some compilers won't report that they do not support -pthread,
1201# so we need to run a program to see whether it really made the
1202# function available.
1203AC_MSG_CHECKING(whether $CC accepts -pthread)
1204AC_CACHE_VAL(ac_cv_thread,
1205[ac_save_cc="$CC"
1206CC="$CC -pthread"
1207AC_TRY_RUN([
1208#include <pthread.h>
1209
1210void* routine(void* p){return NULL;}
1211
1212int main(){
1213 pthread_t p;
1214 if(pthread_create(&p,NULL,routine,NULL)!=0)
1215 return 1;
1216 (void)pthread_detach(p);
1217 return 0;
1218}
1219],
1220 ac_cv_pthread=yes,
1221 ac_cv_pthread=no,
1222 ac_cv_pthread=no)
1223CC="$ac_save_cc"])
1224AC_MSG_RESULT($ac_cv_pthread)
1225fi
1226
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001227# If we have set a CC compiler flag for thread support then
1228# check if it works for CXX, too.
1229ac_cv_cxx_thread=no
1230if test ! -z "$CXX"
1231then
1232AC_MSG_CHECKING(whether $CXX also accepts flags for thread support)
1233ac_save_cxx="$CXX"
1234
1235if test "$ac_cv_kpthread" = "yes"
1236then
Martin v. Löwis519adae2003-09-20 10:47:47 +00001237 CXX="$CXX -Kpthread"
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001238 ac_cv_cxx_thread=yes
1239elif test "$ac_cv_kthread" = "yes"
1240then
1241 CXX="$CXX -Kthread"
1242 ac_cv_cxx_thread=yes
1243elif test "$ac_cv_pthread" = "yes"
1244then
1245 CXX="$CXX -pthread"
1246 ac_cv_cxx_thread=yes
1247fi
1248
1249if test $ac_cv_cxx_thread = yes
1250then
1251 echo 'void foo();int main(){foo();}void foo(){}' > conftest.$ac_ext
1252 $CXX -c conftest.$ac_ext 2>&5
1253 if $CXX -o conftest$ac_exeext conftest.$ac_objext 2>&5 \
1254 && test -s conftest$ac_exeext && ./conftest$ac_exeext
1255 then
1256 ac_cv_cxx_thread=yes
1257 else
1258 ac_cv_cxx_thread=no
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001259 fi
1260 rm -fr conftest*
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001261fi
Brett Cannonc601e0f2004-11-07 01:24:12 +00001262AC_MSG_RESULT($ac_cv_cxx_thread)
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001263fi
Martin v. Löwis519adae2003-09-20 10:47:47 +00001264CXX="$ac_save_cxx"
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001265
Fred Drakece81d592000-07-09 14:39:29 +00001266dnl # check for ANSI or K&R ("traditional") preprocessor
1267dnl AC_MSG_CHECKING(for C preprocessor type)
1268dnl AC_TRY_COMPILE([
1269dnl #define spam(name, doc) {#name, &name, #name "() -- " doc}
1270dnl int foo;
1271dnl struct {char *name; int *addr; char *doc;} desc = spam(foo, "something");
1272dnl ], [;], cpp_type=ansi, AC_DEFINE(HAVE_OLD_CPP) cpp_type=traditional)
1273dnl AC_MSG_RESULT($cpp_type)
Guido van Rossum300fda71996-08-19 21:58:16 +00001274
Guido van Rossum627b2d71993-12-24 10:39:16 +00001275# checks for header files
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001276AC_HEADER_STDC
Thomas Wouters0e3f5912006-08-11 14:57:12 +00001277AC_CHECK_HEADERS(asm/types.h conio.h curses.h direct.h dlfcn.h errno.h \
1278fcntl.h grp.h \
Christian Heimesbbe741d2008-03-28 10:53:29 +00001279ieeefp.h io.h langinfo.h libintl.h ncurses.h poll.h process.h pthread.h \
Thomas Wouters89f507f2006-12-13 04:49:30 +00001280shadow.h signal.h stdint.h stropts.h termios.h thread.h \
Martin v. Löwis14e73b12003-01-01 09:51:12 +00001281unistd.h utime.h \
Christian Heimes4fbc72b2008-03-22 00:47:35 +00001282sys/audioio.h sys/bsdtty.h sys/epoll.h sys/event.h sys/file.h sys/loadavg.h \
1283sys/lock.h sys/mkdev.h sys/modem.h \
Thomas Wouters0e3f5912006-08-11 14:57:12 +00001284sys/param.h sys/poll.h sys/select.h sys/socket.h sys/statvfs.h sys/stat.h \
Georg Brandlf78e02b2008-06-10 17:40:04 +00001285sys/termio.h sys/time.h \
Thomas Wouters0e3f5912006-08-11 14:57:12 +00001286sys/times.h sys/types.h sys/un.h sys/utsname.h sys/wait.h pty.h libutil.h \
Hye-Shik Chang81268602004-02-02 06:05:24 +00001287sys/resource.h netpacket/packet.h sysexits.h bluetooth.h \
Ronald Oussoren755740f2010-02-07 19:56:39 +00001288bluetooth/bluetooth.h linux/tipc.h spawn.h util.h)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001289AC_HEADER_DIRENT
Martin v. Löwisdbe3f762002-10-10 14:27:30 +00001290AC_HEADER_MAJOR
Guido van Rossum627b2d71993-12-24 10:39:16 +00001291
Martin v. Löwisae2830c2004-09-18 09:54:52 +00001292# On Solaris, term.h requires curses.h
Martin v. Löwisfd1c69e2004-11-30 22:09:37 +00001293AC_CHECK_HEADERS(term.h,,,[
Martin v. Löwis5d52e782004-09-18 10:07:03 +00001294#ifdef HAVE_CURSES_H
1295#include <curses.h>
1296#endif
1297])
Martin v. Löwisae2830c2004-09-18 09:54:52 +00001298
Martin v. Löwis11017b12006-01-14 18:12:57 +00001299# On Linux, netlink.h requires asm/types.h
1300AC_CHECK_HEADERS(linux/netlink.h,,,[
1301#ifdef HAVE_ASM_TYPES_H
1302#include <asm/types.h>
1303#endif
1304#ifdef HAVE_SYS_SOCKET_H
1305#include <sys/socket.h>
1306#endif
1307])
1308
Guido van Rossum627b2d71993-12-24 10:39:16 +00001309# checks for typedefs
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001310was_it_defined=no
1311AC_MSG_CHECKING(for clock_t in time.h)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001312AC_EGREP_HEADER(clock_t, time.h, was_it_defined=yes, [
1313 AC_DEFINE(clock_t, long, [Define to 'long' if <time.h> doesn't define.])
1314])
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001315AC_MSG_RESULT($was_it_defined)
1316
Neal Norwitz11690112002-07-30 01:08:28 +00001317# Check whether using makedev requires defining _OSF_SOURCE
1318AC_MSG_CHECKING(for makedev)
Neal Norwitz6eb37f02003-02-23 23:28:15 +00001319AC_TRY_LINK([#include <sys/types.h> ],
Neal Norwitz11690112002-07-30 01:08:28 +00001320 [ makedev(0, 0) ],
1321 ac_cv_has_makedev=yes,
1322 ac_cv_has_makedev=no)
1323if test "$ac_cv_has_makedev" = "no"; then
1324 # we didn't link, try if _OSF_SOURCE will allow us to link
1325 AC_TRY_LINK([
Neal Norwitz6eb37f02003-02-23 23:28:15 +00001326#define _OSF_SOURCE 1
1327#include <sys/types.h>
Neal Norwitz11690112002-07-30 01:08:28 +00001328 ],
1329 [ makedev(0, 0) ],
1330 ac_cv_has_makedev=yes,
1331 ac_cv_has_makedev=no)
1332 if test "$ac_cv_has_makedev" = "yes"; then
1333 AC_DEFINE(_OSF_SOURCE, 1, [Define _OSF_SOURCE to get the makedev macro.])
1334 fi
1335fi
1336AC_MSG_RESULT($ac_cv_has_makedev)
1337if test "$ac_cv_has_makedev" = "yes"; then
1338 AC_DEFINE(HAVE_MAKEDEV, 1, [Define this if you have the makedev macro.])
1339fi
1340
Martin v. Löwis399a6892002-10-04 10:22:02 +00001341# Enabling LFS on Solaris (2.6 to 9) with gcc 2.95 triggers a bug in
1342# the system headers: If _XOPEN_SOURCE and _LARGEFILE_SOURCE are
1343# defined, but the compiler does not support pragma redefine_extname,
1344# and _LARGEFILE64_SOURCE is not defined, the headers refer to 64-bit
1345# structures (such as rlimit64) without declaring them. As a
1346# work-around, disable LFS on such configurations
1347
1348use_lfs=yes
1349AC_MSG_CHECKING(Solaris LFS bug)
1350AC_TRY_COMPILE([
1351#define _LARGEFILE_SOURCE 1
1352#define _FILE_OFFSET_BITS 64
1353#include <sys/resource.h>
1354],struct rlimit foo;,sol_lfs_bug=no,sol_lfs_bug=yes)
1355AC_MSG_RESULT($sol_lfs_bug)
1356if test "$sol_lfs_bug" = "yes"; then
1357 use_lfs=no
1358fi
1359
1360if test "$use_lfs" = "yes"; then
Guido van Rossum810cc512001-09-09 23:51:39 +00001361# Two defines needed to enable largefile support on various platforms
1362# These may affect some typedefs
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001363AC_DEFINE(_LARGEFILE_SOURCE, 1,
1364[This must be defined on some systems to enable large file support.])
1365AC_DEFINE(_FILE_OFFSET_BITS, 64,
1366[This must be set to 64 on some systems to enable large file support.])
Martin v. Löwis399a6892002-10-04 10:22:02 +00001367fi
Guido van Rossum810cc512001-09-09 23:51:39 +00001368
Guido van Rossum300fda71996-08-19 21:58:16 +00001369# Add some code to confdefs.h so that the test for off_t works on SCO
1370cat >> confdefs.h <<\EOF
1371#if defined(SCO_DS)
1372#undef _OFF_T
1373#endif
1374EOF
1375
Guido van Rossumef2255b2000-03-10 22:30:29 +00001376# Type availability checks
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001377AC_TYPE_MODE_T
1378AC_TYPE_OFF_T
1379AC_TYPE_PID_T
1380AC_TYPE_SIGNAL
1381AC_TYPE_SIZE_T
1382AC_TYPE_UID_T
Mark Dickinsonbd792642009-03-18 20:06:12 +00001383AC_TYPE_UINT32_T
1384AC_TYPE_UINT64_T
1385AC_TYPE_INT32_T
1386AC_TYPE_INT64_T
Christian Heimes400adb02008-02-01 08:12:03 +00001387AC_CHECK_TYPE(ssize_t,
Martin v. Löwis18e16552006-02-15 17:27:45 +00001388 AC_DEFINE(HAVE_SSIZE_T, 1, Define if your compiler provides ssize_t),,)
Guido van Rossum627b2d71993-12-24 10:39:16 +00001389
Guido van Rossumef2255b2000-03-10 22:30:29 +00001390# Sizes of various common basic types
Skip Montanarob9820a32004-01-17 00:16:12 +00001391# ANSI C requires sizeof(char) == 1, so no need to check it
Guido van Rossum3065c942001-09-17 04:03:14 +00001392AC_CHECK_SIZEOF(int, 4)
1393AC_CHECK_SIZEOF(long, 4)
1394AC_CHECK_SIZEOF(void *, 4)
Guido van Rossum3065c942001-09-17 04:03:14 +00001395AC_CHECK_SIZEOF(short, 2)
1396AC_CHECK_SIZEOF(float, 4)
1397AC_CHECK_SIZEOF(double, 8)
1398AC_CHECK_SIZEOF(fpos_t, 4)
Martin v. Löwis18e16552006-02-15 17:27:45 +00001399AC_CHECK_SIZEOF(size_t, 4)
Christian Heimes400adb02008-02-01 08:12:03 +00001400AC_CHECK_SIZEOF(pid_t, 4)
Guido van Rossumac405f61994-09-12 10:56:06 +00001401
Guido van Rossumec95c7b1998-08-04 17:59:56 +00001402AC_MSG_CHECKING(for long long support)
1403have_long_long=no
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001404AC_TRY_COMPILE([], [long long x; x = (long long)0;], [
1405 AC_DEFINE(HAVE_LONG_LONG, 1, [Define this if you have the type long long.])
1406 have_long_long=yes
1407])
Guido van Rossumec95c7b1998-08-04 17:59:56 +00001408AC_MSG_RESULT($have_long_long)
Guido van Rossum8bc1dfd1999-04-10 16:01:48 +00001409if test "$have_long_long" = yes ; then
Guido van Rossum3065c942001-09-17 04:03:14 +00001410AC_CHECK_SIZEOF(long long, 8)
Guido van Rossumec95c7b1998-08-04 17:59:56 +00001411fi
1412
Travis E. Oliphant9b307842007-10-12 22:06:37 +00001413AC_MSG_CHECKING(for long double support)
1414have_long_double=no
1415AC_TRY_COMPILE([], [long double x; x = (long double)0;], [
1416 AC_DEFINE(HAVE_LONG_DOUBLE, 1, [Define this if you have the type long double.])
1417 have_long_double=yes
1418])
1419AC_MSG_RESULT($have_long_double)
1420if test "$have_long_double" = yes ; then
1421AC_CHECK_SIZEOF(long double, 16)
1422fi
1423
1424
Thomas Woutersb2137042007-02-01 18:02:27 +00001425AC_MSG_CHECKING(for _Bool support)
1426have_c99_bool=no
1427AC_TRY_COMPILE([], [_Bool x; x = (_Bool)0;], [
1428 AC_DEFINE(HAVE_C99_BOOL, 1, [Define this if you have the type _Bool.])
1429 have_c99_bool=yes
1430])
1431AC_MSG_RESULT($have_c99_bool)
1432if test "$have_c99_bool" = yes ; then
1433AC_CHECK_SIZEOF(_Bool, 1)
1434fi
1435
Thomas Wouters89f507f2006-12-13 04:49:30 +00001436AC_CHECK_TYPES(uintptr_t,
1437 [AC_CHECK_SIZEOF(uintptr_t, 4)],
1438 [], [#ifdef HAVE_STDINT_H
1439 #include <stdint.h>
1440 #endif])
1441
Alexandre Vassalotti0805b4a2009-07-17 05:47:33 +00001442AC_CHECK_SIZEOF(off_t, [], [
1443#ifdef HAVE_SYS_TYPES_H
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001444#include <sys/types.h>
Alexandre Vassalotti0805b4a2009-07-17 05:47:33 +00001445#endif
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001446])
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001447
1448AC_MSG_CHECKING(whether to enable large file support)
Mark Dickinson2df5d282009-12-31 21:22:50 +00001449if test "$have_long_long" = yes
1450then
1451if test "$ac_cv_sizeof_off_t" -gt "$ac_cv_sizeof_long" -a \
Guido van Rossum8bc1dfd1999-04-10 16:01:48 +00001452 "$ac_cv_sizeof_long_long" -ge "$ac_cv_sizeof_off_t"; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001453 AC_DEFINE(HAVE_LARGEFILE_SUPPORT, 1,
1454 [Defined to enable large file support when an off_t is bigger than a long
1455 and long long is available and at least as big as an off_t. You may need
1456 to add some flags for configuration and compilation to enable this mode.
1457 (For Solaris and Linux, the necessary defines are already defined.)])
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001458 AC_MSG_RESULT(yes)
1459else
1460 AC_MSG_RESULT(no)
1461fi
Mark Dickinson2df5d282009-12-31 21:22:50 +00001462else
1463 AC_MSG_RESULT(no)
1464fi
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001465
Alexandre Vassalotti0805b4a2009-07-17 05:47:33 +00001466AC_CHECK_SIZEOF(time_t, [], [
1467#ifdef HAVE_SYS_TYPES_H
1468#include <sys/types.h>
1469#endif
1470#ifdef HAVE_TIME_H
Fred Drakea3f6e912000-06-29 20:44:47 +00001471#include <time.h>
Alexandre Vassalotti0805b4a2009-07-17 05:47:33 +00001472#endif
Fred Drakea3f6e912000-06-29 20:44:47 +00001473])
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001474
Trent Mick635f6fb2000-08-23 21:33:05 +00001475# if have pthread_t then define SIZEOF_PTHREAD_T
Martin v. Löwis123cbd22001-07-19 14:21:10 +00001476ac_save_cc="$CC"
1477if test "$ac_cv_kpthread" = "yes"
1478then CC="$CC -Kpthread"
Martin v. Löwis5f433f02003-05-05 05:05:30 +00001479elif test "$ac_cv_kthread" = "yes"
1480then CC="$CC -Kthread"
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00001481elif test "$ac_cv_pthread" = "yes"
1482then CC="$CC -pthread"
Martin v. Löwis123cbd22001-07-19 14:21:10 +00001483fi
Alexandre Vassalotti0805b4a2009-07-17 05:47:33 +00001484
Trent Mick635f6fb2000-08-23 21:33:05 +00001485AC_MSG_CHECKING(for pthread_t)
1486have_pthread_t=no
Guido van Rossum12580492000-09-24 16:47:19 +00001487AC_TRY_COMPILE([#include <pthread.h>], [pthread_t x; x = *(pthread_t*)0;], have_pthread_t=yes)
Trent Mick635f6fb2000-08-23 21:33:05 +00001488AC_MSG_RESULT($have_pthread_t)
1489if test "$have_pthread_t" = yes ; then
Alexandre Vassalotti0805b4a2009-07-17 05:47:33 +00001490 AC_CHECK_SIZEOF(pthread_t, [], [
1491#ifdef HAVE_PTHREAD_H
Neal Norwitz6eb37f02003-02-23 23:28:15 +00001492#include <pthread.h>
Alexandre Vassalotti0805b4a2009-07-17 05:47:33 +00001493#endif
Trent Mick635f6fb2000-08-23 21:33:05 +00001494 ])
Trent Mick635f6fb2000-08-23 21:33:05 +00001495fi
Martin v. Löwis123cbd22001-07-19 14:21:10 +00001496CC="$ac_save_cc"
Trent Mick635f6fb2000-08-23 21:33:05 +00001497
Bob Ippolito7026a0a2005-03-28 23:23:47 +00001498AC_SUBST(OTHER_LIBTOOL_OPT)
1499case $ac_sys_system/$ac_sys_release in
Thomas Wouters49fd7fa2006-04-21 10:40:58 +00001500 Darwin/@<:@01567@:>@\..*)
Bob Ippolito7026a0a2005-03-28 23:23:47 +00001501 OTHER_LIBTOOL_OPT="-prebind -seg1addr 0x10000000"
1502 ;;
1503 Darwin/*)
1504 OTHER_LIBTOOL_OPT=""
1505 ;;
1506esac
1507
Ronald Oussoren5bbab3e2009-09-06 11:01:15 +00001508
1509ARCH_RUN_32BIT=""
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001510AC_SUBST(LIBTOOL_CRUFT)
1511case $ac_sys_system/$ac_sys_release in
Thomas Wouters49fd7fa2006-04-21 10:40:58 +00001512 Darwin/@<:@01567@:>@\..*)
Thomas Wouters477c8d52006-05-27 19:21:47 +00001513 LIBTOOL_CRUFT="-framework System -lcc_dynamic"
1514 if test "${enable_universalsdk}"; then
1515 :
1516 else
Ronald Oussorene3da75a2010-02-11 13:38:58 +00001517 LIBTOOL_CRUFT="${LIBTOOL_CRUFT} -arch_only `/usr/bin/arch`"
Thomas Wouters477c8d52006-05-27 19:21:47 +00001518 fi
Jack Jansenb36687a2004-07-16 08:43:47 +00001519 LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -install_name $(PYTHONFRAMEWORKINSTALLDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansena3891ea2001-09-07 14:25:12 +00001520 LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -compatibility_version $(VERSION) -current_version $(VERSION)';;
Guido van Rossum5839e582000-10-09 19:52:35 +00001521 Darwin/*)
Ronald Oussoren9812a6c2010-02-07 11:53:18 +00001522 gcc_version=`gcc -dumpversion`
Bob Ippolito7026a0a2005-03-28 23:23:47 +00001523 if test ${gcc_version} '<' 4.0
1524 then
1525 LIBTOOL_CRUFT="-lcc_dynamic"
1526 else
1527 LIBTOOL_CRUFT=""
1528 fi
Ronald Oussoren3c064c12009-09-08 07:12:42 +00001529 AC_TRY_RUN([
Ronald Oussoren5bbab3e2009-09-06 11:01:15 +00001530 #include <unistd.h>
1531 int main(int argc, char*argv[])
1532 {
1533 if (sizeof(long) == 4) {
1534 return 0;
1535 } else {
1536 return 1;
1537 }
Ronald Oussoren3c064c12009-09-08 07:12:42 +00001538 }
1539 ], ac_osx_32bit=yes,
Ronald Oussoren5bbab3e2009-09-06 11:01:15 +00001540 ac_osx_32bit=no,
Ronald Oussoren3c064c12009-09-08 07:12:42 +00001541 ac_osx_32bit=yes)
Ronald Oussoren5bbab3e2009-09-06 11:01:15 +00001542
1543 if test "${ac_osx_32bit}" = "yes"; then
Ronald Oussorene3da75a2010-02-11 13:38:58 +00001544 case `/usr/bin/arch` in
Ronald Oussoren5bbab3e2009-09-06 11:01:15 +00001545 i386)
1546 MACOSX_DEFAULT_ARCH="i386"
1547 ;;
1548 ppc)
1549 MACOSX_DEFAULT_ARCH="ppc"
1550 ;;
1551 *)
1552 AC_MSG_ERROR([Unexpected output of 'arch' on OSX])
1553 ;;
1554 esac
1555 else
Ronald Oussorene3da75a2010-02-11 13:38:58 +00001556 case `/usr/bin/arch` in
Ronald Oussoren5bbab3e2009-09-06 11:01:15 +00001557 i386)
1558 MACOSX_DEFAULT_ARCH="x86_64"
1559 ;;
1560 ppc)
1561 MACOSX_DEFAULT_ARCH="ppc64"
1562 ;;
1563 *)
1564 AC_MSG_ERROR([Unexpected output of 'arch' on OSX])
1565 ;;
1566 esac
1567
1568 #ARCH_RUN_32BIT="true"
1569 fi
1570
1571 LIBTOOL_CRUFT=$LIBTOOL_CRUFT" -lSystem -lSystemStubs -arch_only ${MACOSX_DEFAULT_ARCH}"
Jack Jansenb36687a2004-07-16 08:43:47 +00001572 LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -install_name $(PYTHONFRAMEWORKINSTALLDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001573 LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -compatibility_version $(VERSION) -current_version $(VERSION)';;
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001574esac
1575
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001576AC_MSG_CHECKING(for --enable-framework)
1577if test "$enable_framework"
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001578then
Skip Montanarodecc6a42003-01-01 20:07:49 +00001579 BASECFLAGS="$BASECFLAGS -fno-common -dynamic"
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001580 # -F. is needed to allow linking to the framework while
1581 # in the build location.
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001582 AC_DEFINE(WITH_NEXT_FRAMEWORK, 1,
1583 [Define if you want to produce an OpenStep/Rhapsody framework
1584 (shared library plus accessory files).])
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001585 AC_MSG_RESULT(yes)
Ronald Oussoren99aab652009-06-08 21:22:57 +00001586 if test $enable_shared = "yes"
1587 then
1588 AC_MSG_ERROR([Specifying both --enable-shared and --enable-framework is not supported, use only --enable-framework instead])
1589 fi
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001590else
1591 AC_MSG_RESULT(no)
1592fi
1593
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001594AC_MSG_CHECKING(for dyld)
Jack Jansen9a66b6d2001-08-08 13:56:14 +00001595case $ac_sys_system/$ac_sys_release in
1596 Darwin/*)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001597 AC_DEFINE(WITH_DYLD, 1,
1598 [Define if you want to use the new-style (Openstep, Rhapsody, MacOS)
1599 dynamic linker (dyld) instead of the old-style (NextStep) dynamic
1600 linker (rld). Dyld is necessary to support frameworks.])
Jack Jansen9a66b6d2001-08-08 13:56:14 +00001601 AC_MSG_RESULT(always on for Darwin)
1602 ;;
1603 *)
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001604 AC_MSG_RESULT(no)
1605 ;;
Jack Jansen9a66b6d2001-08-08 13:56:14 +00001606esac
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001607
Guido van Rossumac405f61994-09-12 10:56:06 +00001608# Set info about shared libraries.
Guido van Rossumac405f61994-09-12 10:56:06 +00001609AC_SUBST(SO)
1610AC_SUBST(LDSHARED)
Neil Schemenauerb3531b82001-02-16 04:09:05 +00001611AC_SUBST(BLDSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00001612AC_SUBST(CCSHARED)
1613AC_SUBST(LINKFORSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00001614# SO is the extension of shared libraries `(including the dot!)
Guido van Rossumaef734b2001-01-10 21:09:12 +00001615# -- usually .so, .sl on HP-UX, .dll on Cygwin
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001616AC_MSG_CHECKING(SO)
Guido van Rossumac405f61994-09-12 10:56:06 +00001617if test -z "$SO"
1618then
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001619 case $ac_sys_system in
Thomas Wouters477c8d52006-05-27 19:21:47 +00001620 hp*|HP*)
1621 case `uname -m` in
1622 ia64) SO=.so;;
1623 *) SO=.sl;;
1624 esac
1625 ;;
Guido van Rossumaef734b2001-01-10 21:09:12 +00001626 CYGWIN*) SO=.dll;;
Guido van Rossum4b6b5791996-09-09 20:09:34 +00001627 *) SO=.so;;
Guido van Rossumac405f61994-09-12 10:56:06 +00001628 esac
Martin v. Löwis368de8f2003-06-14 14:46:38 +00001629else
1630 # this might also be a termcap variable, see #610332
1631 echo
1632 echo '====================================================================='
1633 echo '+ +'
1634 echo '+ WARNING: You have set SO in your environment. +'
1635 echo '+ Do you really mean to change the extension for shared libraries? +'
1636 echo '+ Continuing in 10 seconds to let you to ponder. +'
1637 echo '+ +'
1638 echo '====================================================================='
1639 sleep 10
Guido van Rossumac405f61994-09-12 10:56:06 +00001640fi
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001641AC_MSG_RESULT($SO)
Georg Brandlb1441c72009-01-03 22:33:39 +00001642
Thomas Wouters477c8d52006-05-27 19:21:47 +00001643AC_DEFINE_UNQUOTED(SHLIB_EXT, "$SO", [Define this to be extension of shared libraries (including the dot!).])
Guido van Rossumac405f61994-09-12 10:56:06 +00001644# LDSHARED is the ld *command* used to create shared library
Skip Montanaroce59c042004-01-17 14:19:44 +00001645# -- "cc -G" on SunOS 5.x, "ld -shared" on IRIX 5
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001646# (Shared libraries in this instance are shared modules to be loaded into
1647# Python, as opposed to building Python itself as a shared library.)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001648AC_MSG_CHECKING(LDSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00001649if test -z "$LDSHARED"
1650then
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001651 case $ac_sys_system/$ac_sys_release in
Neil Schemenauerb3531b82001-02-16 04:09:05 +00001652 AIX*)
1653 BLDSHARED="\$(srcdir)/Modules/ld_so_aix \$(CC) -bI:Modules/python.exp"
Guido van Rossumce608b02001-09-28 15:59:38 +00001654 LDSHARED="\$(BINLIBDEST)/config/ld_so_aix \$(CC) -bI:\$(BINLIBDEST)/config/python.exp"
Neil Schemenauerb3531b82001-02-16 04:09:05 +00001655 ;;
Guido van Rossum6100aaf1997-04-29 21:48:51 +00001656 IRIX/5*) LDSHARED="ld -shared";;
Guido van Rossum91922671997-10-09 20:24:13 +00001657 IRIX*/6*) LDSHARED="ld ${SGI_ABI} -shared -all";;
Greg Ward57c9a662000-05-26 12:22:54 +00001658 SunOS/5*)
1659 if test "$GCC" = "yes"
Neil Schemenauer95052722001-02-19 18:17:33 +00001660 then LDSHARED='$(CC) -shared'
Martin v. Löwisaa5afe12002-10-07 06:21:41 +00001661 else LDSHARED='$(CC) -G';
Greg Ward57c9a662000-05-26 12:22:54 +00001662 fi ;;
Thomas Hellerf44b9a12008-04-04 10:18:23 +00001663 hp*|HP*)
1664 if test "$GCC" = "yes"
1665 then LDSHARED='$(CC) -shared'
1666 else LDSHARED='ld -b';
1667 fi ;;
Guido van Rossum71001e41995-01-26 00:44:03 +00001668 OSF*) LDSHARED="ld -shared -expect_unresolved \"*\"";;
Jack Jansen418c3b12001-11-14 10:59:57 +00001669 Darwin/1.3*)
Jack Jansena3891ea2001-09-07 14:25:12 +00001670 LDSHARED='$(CC) $(LDFLAGS) -bundle'
1671 if test "$enable_framework" ; then
1672 # Link against the framework. All externals should be defined.
Jack Jansenda49e192005-01-07 13:08:22 +00001673 BLDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
1674 LDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansena3891ea2001-09-07 14:25:12 +00001675 else
1676 # No framework. Ignore undefined symbols, assuming they come from Python
Jack Jansen418c3b12001-11-14 10:59:57 +00001677 LDSHARED="$LDSHARED -undefined suppress"
Jack Jansena3891ea2001-09-07 14:25:12 +00001678 fi ;;
Jack Jansen6b08a402004-06-03 12:41:45 +00001679 Darwin/1.4*|Darwin/5.*|Darwin/6.*)
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001680 LDSHARED='$(CC) $(LDFLAGS) -bundle'
1681 if test "$enable_framework" ; then
1682 # Link against the framework. All externals should be defined.
Jack Jansenda49e192005-01-07 13:08:22 +00001683 BLDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
1684 LDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001685 else
Michael W. Hudson0c46c0c2002-03-07 09:58:56 +00001686 # No framework, use the Python app as bundle-loader
1687 BLDSHARED="$LDSHARED "'-bundle_loader $(BUILDPYTHON)'
Jack Jansenc28fc372003-02-25 13:14:43 +00001688 LDSHARED="$LDSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)'
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001689 fi ;;
Jack Jansen6b08a402004-06-03 12:41:45 +00001690 Darwin/*)
1691 # Use -undefined dynamic_lookup whenever possible (10.3 and later).
1692 # This allows an extension to be used in any Python
Thomas Wouters89d996e2007-09-08 17:39:28 +00001693
Georg Brandlfcaf9102008-07-16 02:17:56 +00001694 if test ${MACOSX_DEPLOYMENT_TARGET} '>' 10.2
Jack Jansen6b08a402004-06-03 12:41:45 +00001695 then
Thomas Wouters477c8d52006-05-27 19:21:47 +00001696 if test "${enable_universalsdk}"; then
Georg Brandlfcaf9102008-07-16 02:17:56 +00001697 LDFLAGS="${UNIVERSAL_ARCH_FLAGS} -isysroot ${UNIVERSALSDK} ${LDFLAGS}"
Thomas Wouters477c8d52006-05-27 19:21:47 +00001698 fi
Jack Jansen6b08a402004-06-03 12:41:45 +00001699 LDSHARED='$(CC) $(LDFLAGS) -bundle -undefined dynamic_lookup'
1700 BLDSHARED="$LDSHARED"
Jack Jansen6b08a402004-06-03 12:41:45 +00001701 else
1702 LDSHARED='$(CC) $(LDFLAGS) -bundle'
1703 if test "$enable_framework" ; then
1704 # Link against the framework. All externals should be defined.
Jack Jansenda49e192005-01-07 13:08:22 +00001705 BLDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
1706 LDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansen6b08a402004-06-03 12:41:45 +00001707 else
1708 # No framework, use the Python app as bundle-loader
1709 BLDSHARED="$LDSHARED "'-bundle_loader $(BUILDPYTHON)'
1710 LDSHARED="$LDSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)'
1711 fi
1712 fi
1713 ;;
Georg Brandlf78e02b2008-06-10 17:40:04 +00001714 Linux*|GNU*|QNX*) LDSHARED='$(CC) -shared';;
Guido van Rossum458e7fa1999-09-17 15:40:40 +00001715 BSD/OS*/4*) LDSHARED="gcc -shared";;
Thomas Wouters1ba5b3b2006-06-08 14:52:47 +00001716 FreeBSD*)
Jeremy Hylton4bcc7c52000-08-31 17:45:35 +00001717 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
Guido van Rossum0286ae82000-08-29 15:06:49 +00001718 then
Hye-Shik Chang33761492004-10-26 09:53:46 +00001719 LDSHARED="$CC -shared ${LDFLAGS}"
Guido van Rossum0286ae82000-08-29 15:06:49 +00001720 else
1721 LDSHARED="ld -Bshareable ${LDFLAGS}"
1722 fi;;
Thomas Wouters1ba5b3b2006-06-08 14:52:47 +00001723 OpenBSD*)
1724 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
1725 then
1726 LDSHARED='$(CC) -shared $(CCSHARED) ${LDFLAGS}'
1727 else
1728 case `uname -r` in
1729 [[01]].* | 2.[[0-7]] | 2.[[0-7]].*)
1730 LDSHARED="ld -Bshareable ${LDFLAGS}"
1731 ;;
1732 *)
1733 LDSHARED='$(CC) -shared $(CCSHARED) ${LDFLAGS}'
1734 ;;
1735 esac
1736 fi;;
Martin v. Löwis86d66262006-02-17 08:40:11 +00001737 NetBSD*|DragonFly*) LDSHARED="cc -shared ${LDFLAGS}";;
Martin v. Löwis25ae43b2001-10-07 08:39:18 +00001738 OpenUNIX*|UnixWare*)
Martin v. Löwisbec19582001-03-21 15:57:54 +00001739 if test "$GCC" = "yes"
Martin v. Löwis79f3c532002-12-11 12:51:58 +00001740 then LDSHARED='$(CC) -shared'
1741 else LDSHARED='$(CC) -G'
Martin v. Löwisbec19582001-03-21 15:57:54 +00001742 fi;;
Martin v. Löwis79f3c532002-12-11 12:51:58 +00001743 SCO_SV*) LDSHARED='$(CC) -Wl,-G,-Bexport';;
Guido van Rossumaef734b2001-01-10 21:09:12 +00001744 CYGWIN*) LDSHARED="gcc -shared -Wl,--enable-auto-image-base";;
Guido van Rossumac405f61994-09-12 10:56:06 +00001745 *) LDSHARED="ld";;
1746 esac
Guido van Rossumac405f61994-09-12 10:56:06 +00001747fi
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001748AC_MSG_RESULT($LDSHARED)
Neil Schemenauerb3531b82001-02-16 04:09:05 +00001749BLDSHARED=${BLDSHARED-$LDSHARED}
Guido van Rossumac405f61994-09-12 10:56:06 +00001750# CCSHARED are the C *flags* used to create objects to go into a shared
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001751# library (module) -- this is only needed for a few systems
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001752AC_MSG_CHECKING(CCSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00001753if test -z "$CCSHARED"
1754then
Guido van Rossum6100aaf1997-04-29 21:48:51 +00001755 case $ac_sys_system/$ac_sys_release in
Neil Schemenauer66252162001-02-19 04:47:42 +00001756 SunOS*) if test "$GCC" = yes;
Guido van Rossumd8faa362007-04-27 19:54:29 +00001757 then CCSHARED="-fPIC";
1758 elif test `uname -p` = sparc;
1759 then CCSHARED="-xcode=pic32";
1760 else CCSHARED="-Kpic";
1761 fi;;
Guido van Rossumaf07a441995-02-13 19:45:27 +00001762 hp*|HP*) if test "$GCC" = yes;
Martin v. Löwis703ad702001-09-05 08:36:52 +00001763 then CCSHARED="-fPIC";
Guido van Rossumaf07a441995-02-13 19:45:27 +00001764 else CCSHARED="+z";
1765 fi;;
Martin v. Löwisa6e97582002-01-01 18:41:33 +00001766 Linux*|GNU*) CCSHARED="-fPIC";;
Guido van Rossumf5957ea1999-10-05 21:59:33 +00001767 BSD/OS*/4*) CCSHARED="-fpic";;
Martin v. Löwis86d66262006-02-17 08:40:11 +00001768 FreeBSD*|NetBSD*|OpenBSD*|DragonFly*) CCSHARED="-fPIC";;
Martin v. Löwis25ae43b2001-10-07 08:39:18 +00001769 OpenUNIX*|UnixWare*)
Martin v. Löwisbec19582001-03-21 15:57:54 +00001770 if test "$GCC" = "yes"
1771 then CCSHARED="-fPIC"
Martin v. Löwis130fb172001-07-19 11:00:41 +00001772 else CCSHARED="-KPIC"
Martin v. Löwisbec19582001-03-21 15:57:54 +00001773 fi;;
Martin v. Löwis21ee4092002-09-30 16:19:48 +00001774 SCO_SV*)
1775 if test "$GCC" = "yes"
1776 then CCSHARED="-fPIC"
1777 else CCSHARED="-Kpic -belf"
1778 fi;;
Guido van Rossum2b5ca001998-03-05 15:41:09 +00001779 IRIX*/6*) case $CC in
1780 *gcc*) CCSHARED="-shared";;
Guido van Rossumee21f411998-04-20 18:51:54 +00001781 *) CCSHARED="";;
Guido van Rossum2b5ca001998-03-05 15:41:09 +00001782 esac;;
Guido van Rossumac405f61994-09-12 10:56:06 +00001783 esac
Guido van Rossumac405f61994-09-12 10:56:06 +00001784fi
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001785AC_MSG_RESULT($CCSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00001786# LINKFORSHARED are the flags passed to the $(CC) command that links
Guido van Rossumb65a48e1995-06-14 18:21:23 +00001787# the python executable -- this is only needed for a few systems
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001788AC_MSG_CHECKING(LINKFORSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00001789if test -z "$LINKFORSHARED"
1790then
Guido van Rossum6100aaf1997-04-29 21:48:51 +00001791 case $ac_sys_system/$ac_sys_release in
Neil Schemenauerb3531b82001-02-16 04:09:05 +00001792 AIX*) LINKFORSHARED='-Wl,-bE:Modules/python.exp -lld';;
Guido van Rossum5dab3d81996-12-06 21:18:18 +00001793 hp*|HP*)
Martin v. Löwis1142de32002-03-29 16:28:31 +00001794 LINKFORSHARED="-Wl,-E -Wl,+s";;
1795# LINKFORSHARED="-Wl,-E -Wl,+s -Wl,+b\$(BINLIBDEST)/lib-dynload";;
Guido van Rossumf5957ea1999-10-05 21:59:33 +00001796 BSD/OS/4*) LINKFORSHARED="-Xlinker -export-dynamic";;
Martin v. Löwisa6e97582002-01-01 18:41:33 +00001797 Linux*|GNU*) LINKFORSHARED="-Xlinker -export-dynamic";;
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001798 # -u libsys_s pulls in all symbols in libsys
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001799 Darwin/*)
Benjamin Peterson9c80cac2009-05-23 16:34:23 +00001800 LINKFORSHARED="$extra_undefs -framework CoreFoundation"
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001801 if test "$enable_framework"
1802 then
Jack Jansenda49e192005-01-07 13:08:22 +00001803 LINKFORSHARED="$LINKFORSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001804 fi
Raymond Hettingerec6eb362004-11-05 07:02:59 +00001805 LINKFORSHARED="$LINKFORSHARED";;
Martin v. Löwis25ae43b2001-10-07 08:39:18 +00001806 OpenUNIX*|UnixWare*) LINKFORSHARED="-Wl,-Bexport";;
Martin v. Löwis21ee4092002-09-30 16:19:48 +00001807 SCO_SV*) LINKFORSHARED="-Wl,-Bexport";;
Fred Drake02706f52000-09-25 15:08:46 +00001808 ReliantUNIX*) LINKFORSHARED="-W1 -Blargedynsym";;
Martin v. Löwis86d66262006-02-17 08:40:11 +00001809 FreeBSD*|NetBSD*|OpenBSD*|DragonFly*)
Guido van Rossumdf693651999-01-07 21:50:41 +00001810 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
1811 then
1812 LINKFORSHARED="-Wl,--export-dynamic"
1813 fi;;
Guido van Rossum2b5ca001998-03-05 15:41:09 +00001814 SunOS/5*) case $CC in
1815 *gcc*)
Martin v. Löwisa4548572002-04-18 14:51:36 +00001816 if $CC -Xlinker --help 2>&1 | grep export-dynamic >/dev/null
Guido van Rossum8f4ceb11997-12-18 23:42:19 +00001817 then
1818 LINKFORSHARED="-Xlinker --export-dynamic"
Guido van Rossum2b5ca001998-03-05 15:41:09 +00001819 fi;;
1820 esac;;
Jason Tishler30765592003-09-04 11:04:06 +00001821 CYGWIN*)
1822 if test $enable_shared = "no"
1823 then
1824 LINKFORSHARED='-Wl,--out-implib=$(LDLIBRARY)'
1825 fi;;
Georg Brandlf78e02b2008-06-10 17:40:04 +00001826 QNX*)
1827 # -Wl,-E causes the symbols to be added to the dynamic
1828 # symbol table so that they can be found when a module
1829 # is loaded. -N 2048K causes the stack size to be set
1830 # to 2048 kilobytes so that the stack doesn't overflow
1831 # when running test_compile.py.
1832 LINKFORSHARED='-Wl,-E -N 2048K';;
Guido van Rossumac405f61994-09-12 10:56:06 +00001833 esac
Guido van Rossumac405f61994-09-12 10:56:06 +00001834fi
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001835AC_MSG_RESULT($LINKFORSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00001836
Georg Brandl93de2162008-07-16 02:21:06 +00001837
Neil Schemenauer61c51152001-01-26 16:18:16 +00001838AC_SUBST(CFLAGSFORSHARED)
1839AC_MSG_CHECKING(CFLAGSFORSHARED)
1840if test ! "$LIBRARY" = "$LDLIBRARY"
1841then
Neil Schemenauerd9cf41c2001-01-27 21:39:17 +00001842 case $ac_sys_system in
1843 CYGWIN*)
1844 # Cygwin needs CCSHARED when building extension DLLs
1845 # but not when building the interpreter DLL.
1846 CFLAGSFORSHARED='';;
1847 *)
1848 CFLAGSFORSHARED='$(CCSHARED)'
1849 esac
Neil Schemenauer61c51152001-01-26 16:18:16 +00001850fi
1851AC_MSG_RESULT($CFLAGSFORSHARED)
1852
Martin v. Löwisf90ae202002-06-11 06:22:31 +00001853# SHLIBS are libraries (except -lc and -lm) to link to the python shared
1854# library (with --enable-shared).
1855# For platforms on which shared libraries are not allowed to have unresolved
Martin v. Löwisd6359c52002-08-04 12:38:50 +00001856# symbols, this must be set to $(LIBS) (expanded by make). We do this even
1857# if it is not required, since it creates a dependency of the shared library
1858# to LIBS. This, in turn, means that applications linking the shared libpython
1859# don't need to link LIBS explicitly. The default should be only changed
1860# on systems where this approach causes problems.
Martin v. Löwisf90ae202002-06-11 06:22:31 +00001861AC_SUBST(SHLIBS)
1862AC_MSG_CHECKING(SHLIBS)
1863case "$ac_sys_system" in
Martin v. Löwisf90ae202002-06-11 06:22:31 +00001864 *)
Martin v. Löwisd6359c52002-08-04 12:38:50 +00001865 SHLIBS='$(LIBS)';;
Martin v. Löwisf90ae202002-06-11 06:22:31 +00001866esac
1867AC_MSG_RESULT($SHLIBS)
1868
1869
Guido van Rossum627b2d71993-12-24 10:39:16 +00001870# checks for libraries
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001871AC_CHECK_LIB(dl, dlopen) # Dynamic linking for SunOS/Solaris and SYSV
1872AC_CHECK_LIB(dld, shl_load) # Dynamic linking for HP-UX
Martin v. Löwis519adae2003-09-20 10:47:47 +00001873
Georg Brandleee31162008-12-07 15:15:22 +00001874# only check for sem_init if thread support is requested
Martin v. Löwis519adae2003-09-20 10:47:47 +00001875if test "$with_threads" = "yes" -o -z "$with_threads"; then
1876 AC_SEARCH_LIBS(sem_init, pthread rt posix4) # 'Real Time' functions on Solaris
1877 # posix4 on Solaris 2.6
1878 # pthread (first!) on Linux
1879fi
1880
Martin v. Löwis19d17342003-06-14 21:03:05 +00001881# check if we need libintl for locale functions
1882AC_CHECK_LIB(intl, textdomain,
Brett Cannonc6d936e2009-06-07 20:09:53 +00001883 [AC_DEFINE(WITH_LIBINTL, 1,
1884 [Define to 1 if libintl is needed for locale functions.])
1885 LIBS="-lintl $LIBS"])
Guido van Rossum0eefa3f1999-11-16 15:57:37 +00001886
1887# checks for system dependent C++ extensions support
1888case "$ac_sys_system" in
1889 AIX*) AC_MSG_CHECKING(for genuine AIX C++ extensions support)
1890 AC_TRY_LINK([#include "/usr/lpp/xlC/include/load.h"],
1891 [loadAndInit("", 0, "")],
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001892 [AC_DEFINE(AIX_GENUINE_CPLUSPLUS, 1,
1893 [Define for AIX if your compiler is a genuine IBM xlC/xlC_r
1894 and you want support for AIX C++ shared extension modules.])
Guido van Rossum0eefa3f1999-11-16 15:57:37 +00001895 AC_MSG_RESULT(yes)],
1896 [AC_MSG_RESULT(no)]);;
1897 *) ;;
1898esac
1899
Guido van Rossum70c7f481998-03-26 18:44:10 +00001900# Most SVR4 platforms (e.g. Solaris) need -lsocket and -lnsl.
Guido van Rossumf618d2c1995-01-17 16:36:13 +00001901AC_CHECK_LIB(nsl, t_open, [LIBS="-lnsl $LIBS"]) # SVR4
Guido van Rossumf618d2c1995-01-17 16:36:13 +00001902AC_CHECK_LIB(socket, socket, [LIBS="-lsocket $LIBS"], [], $LIBS) # SVR4 sockets
Skip Montanarob9949db2004-01-17 04:04:13 +00001903
Guido van Rossumc5a39031996-07-31 17:35:03 +00001904AC_MSG_CHECKING(for --with-libs)
Barry Warsawc0d24d82000-06-29 16:12:00 +00001905AC_ARG_WITH(libs,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00001906 AC_HELP_STRING(--with-libs='lib1 ...', link against additional libs),
1907[
Guido van Rossumc5a39031996-07-31 17:35:03 +00001908AC_MSG_RESULT($withval)
1909LIBS="$withval $LIBS"
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00001910],
1911[AC_MSG_RESULT(no)])
Guido van Rossum627b2d71993-12-24 10:39:16 +00001912
Benjamin Petersonb2d90462009-12-31 03:23:10 +00001913# Check for use of the system expat library
1914AC_MSG_CHECKING(for --with-system-expat)
1915AC_ARG_WITH(system_expat,
1916 AC_HELP_STRING(--with-system-expat, build pyexpat module using an installed expat library))
1917
1918AC_MSG_RESULT($with_system_expat)
1919
Thomas Wouters49fd7fa2006-04-21 10:40:58 +00001920# Check for use of the system libffi library
1921AC_MSG_CHECKING(for --with-system-ffi)
1922AC_ARG_WITH(system_ffi,
1923 AC_HELP_STRING(--with-system-ffi, build _ctypes module using an installed ffi library))
1924
Benjamin Petersond78735d2010-01-01 16:04:23 +00001925if test "$with_system_ffi" = "yes"; then
1926 AC_PATH_TOOL([PKG_CONFIG], [pkg-config])
1927 LIBFFI_INCLUDEDIR="`"$PKG_CONFIG" libffi --cflags-only-I 2>/dev/null | sed -e 's/^-I//;s/ *$//'`"
1928else
1929 LIBFFI_INCLUDEDIR=""
1930fi
1931AC_SUBST(LIBFFI_INCLUDEDIR)
1932
Thomas Wouters49fd7fa2006-04-21 10:40:58 +00001933AC_MSG_RESULT($with_system_ffi)
1934
Matthias Klose55708cc2009-04-30 08:06:49 +00001935# Check for --with-dbmliborder
1936AC_MSG_CHECKING(for --with-dbmliborder)
1937AC_ARG_WITH(dbmliborder,
1938 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'.]),
1939[
1940if test x$with_dbmliborder = xyes
1941then
1942AC_MSG_ERROR([proper usage is --with-dbmliborder=db1:db2:...])
1943else
1944 for db in `echo $with_dbmliborder | sed 's/:/ /g'`; do
1945 if test x$db != xndbm && test x$db != xgdbm && test x$db != xbdb
1946 then
1947 AC_MSG_ERROR([proper usage is --with-dbmliborder=db1:db2:...])
1948 fi
1949 done
1950fi])
1951AC_MSG_RESULT($with_dbmliborder)
1952
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00001953# Determine if signalmodule should be used.
1954AC_SUBST(USE_SIGNAL_MODULE)
1955AC_SUBST(SIGNAL_OBJS)
1956AC_MSG_CHECKING(for --with-signal-module)
1957AC_ARG_WITH(signal-module,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00001958 AC_HELP_STRING(--with-signal-module, disable/enable signal module))
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00001959
1960if test -z "$with_signal_module"
1961then with_signal_module="yes"
1962fi
1963AC_MSG_RESULT($with_signal_module)
1964
1965if test "${with_signal_module}" = "yes"; then
1966 USE_SIGNAL_MODULE=""
1967 SIGNAL_OBJS=""
1968else
1969 USE_SIGNAL_MODULE="#"
1970 SIGNAL_OBJS="Parser/intrcheck.o Python/sigcheck.o"
1971fi
1972
Guido van Rossum3d15bd82001-01-10 18:53:48 +00001973# This is used to generate Setup.config
Guido van Rossum009f7871997-12-04 00:51:42 +00001974AC_SUBST(USE_THREAD_MODULE)
Barry Warsawc0d24d82000-06-29 16:12:00 +00001975USE_THREAD_MODULE=""
Guido van Rossum009f7871997-12-04 00:51:42 +00001976
Guido van Rossum54d93d41997-01-22 20:51:58 +00001977AC_MSG_CHECKING(for --with-dec-threads)
1978AC_SUBST(LDLAST)
1979AC_ARG_WITH(dec-threads,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00001980 AC_HELP_STRING(--with-dec-threads, use DEC Alpha/OSF1 thread-safe libraries),
1981[
Barry Warsawc0d24d82000-06-29 16:12:00 +00001982AC_MSG_RESULT($withval)
Guido van Rossum54d93d41997-01-22 20:51:58 +00001983LDLAST=-threads
Guido van Rossumf78abae1997-01-21 22:02:36 +00001984if test "${with_thread+set}" != set; then
Guido van Rossum54d93d41997-01-22 20:51:58 +00001985 with_thread="$withval";
1986fi],
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00001987[AC_MSG_RESULT(no)])
Guido van Rossum54d93d41997-01-22 20:51:58 +00001988
Martin v. Löwis11437992002-04-12 09:54:03 +00001989# Templates for things AC_DEFINEd more than once.
1990# For a single AC_DEFINE, no template is needed.
1991AH_TEMPLATE(C_THREADS,[Define if you have the Mach cthreads package])
1992AH_TEMPLATE(_REENTRANT,
1993 [Define to force use of thread-safe errno, h_errno, and other functions])
1994AH_TEMPLATE(WITH_THREAD,
1995 [Define if you want to compile in rudimentary thread support])
1996
Guido van Rossum54d93d41997-01-22 20:51:58 +00001997AC_MSG_CHECKING(for --with-threads)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00001998dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
Barry Warsawc0d24d82000-06-29 16:12:00 +00001999AC_ARG_WITH(threads,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002000 AC_HELP_STRING(--with(out)-threads@<:@=DIRECTORY@:>@, disable/enable thread support))
Guido van Rossum54d93d41997-01-22 20:51:58 +00002001
Barry Warsawc0d24d82000-06-29 16:12:00 +00002002# --with-thread is deprecated, but check for it anyway
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002003dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
Barry Warsawa0f3c5c2000-06-30 16:39:35 +00002004AC_ARG_WITH(thread,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002005 AC_HELP_STRING(--with(out)-thread@<:@=DIRECTORY@:>@, deprecated; use --with(out)-threads),
2006 [with_threads=$with_thread])
Barry Warsawc0d24d82000-06-29 16:12:00 +00002007
2008if test -z "$with_threads"
2009then with_threads="yes"
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002010fi
Barry Warsawc0d24d82000-06-29 16:12:00 +00002011AC_MSG_RESULT($with_threads)
Guido van Rossum6400c261997-05-22 20:34:27 +00002012
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002013AC_SUBST(THREADOBJ)
Barry Warsawc0d24d82000-06-29 16:12:00 +00002014if test "$with_threads" = "no"
2015then
2016 USE_THREAD_MODULE="#"
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002017elif test "$ac_cv_pthread_is_default" = yes
2018then
2019 AC_DEFINE(WITH_THREAD)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002020 # Defining _REENTRANT on system with POSIX threads should not hurt.
2021 AC_DEFINE(_REENTRANT)
2022 posix_threads=yes
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002023 THREADOBJ="Python/thread.o"
Martin v. Löwis130fb172001-07-19 11:00:41 +00002024elif test "$ac_cv_kpthread" = "yes"
2025then
2026 CC="$CC -Kpthread"
Martin v. Löwis519adae2003-09-20 10:47:47 +00002027 if test "$ac_cv_cxx_thread" = "yes"; then
2028 CXX="$CXX -Kpthread"
2029 fi
Martin v. Löwis130fb172001-07-19 11:00:41 +00002030 AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002031 posix_threads=yes
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002032 THREADOBJ="Python/thread.o"
Martin v. Löwis5f433f02003-05-05 05:05:30 +00002033elif test "$ac_cv_kthread" = "yes"
2034then
2035 CC="$CC -Kthread"
Martin v. Löwis519adae2003-09-20 10:47:47 +00002036 if test "$ac_cv_cxx_thread" = "yes"; then
2037 CXX="$CXX -Kthread"
2038 fi
Martin v. Löwis5f433f02003-05-05 05:05:30 +00002039 AC_DEFINE(WITH_THREAD)
2040 posix_threads=yes
2041 THREADOBJ="Python/thread.o"
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002042elif test "$ac_cv_pthread" = "yes"
2043then
2044 CC="$CC -pthread"
Martin v. Löwis519adae2003-09-20 10:47:47 +00002045 if test "$ac_cv_cxx_thread" = "yes"; then
2046 CXX="$CXX -pthread"
2047 fi
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002048 AC_DEFINE(WITH_THREAD)
2049 posix_threads=yes
2050 THREADOBJ="Python/thread.o"
Barry Warsawc0d24d82000-06-29 16:12:00 +00002051else
Martin v. Löwis130fb172001-07-19 11:00:41 +00002052 if test ! -z "$with_threads" -a -d "$with_threads"
2053 then LDFLAGS="$LDFLAGS -L$with_threads"
2054 fi
2055 if test ! -z "$withval" -a -d "$withval"
2056 then LDFLAGS="$LDFLAGS -L$withval"
2057 fi
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002058
2059 # According to the POSIX spec, a pthreads implementation must
Matthias Klosea2542be2004-08-16 11:35:51 +00002060 # define _POSIX_THREADS in unistd.h. Some apparently don't
2061 # (e.g. gnu pth with pthread emulation)
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002062 AC_MSG_CHECKING(for _POSIX_THREADS in unistd.h)
2063 AC_EGREP_CPP(yes,
Neal Norwitz6eb37f02003-02-23 23:28:15 +00002064 [
2065#include <unistd.h>
2066#ifdef _POSIX_THREADS
2067yes
2068#endif
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002069 ], unistd_defines_pthreads=yes, unistd_defines_pthreads=no)
2070 AC_MSG_RESULT($unistd_defines_pthreads)
2071
Martin v. Löwis130fb172001-07-19 11:00:41 +00002072 AC_DEFINE(_REENTRANT)
Martin v. Löwisa6e97582002-01-01 18:41:33 +00002073 AC_CHECK_HEADER(cthreads.h, [AC_DEFINE(WITH_THREAD)
2074 AC_DEFINE(C_THREADS)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002075 AC_DEFINE(HURD_C_THREADS, 1,
2076 [Define if you are using Mach cthreads directly under /include])
Martin v. Löwisa6e97582002-01-01 18:41:33 +00002077 LIBS="$LIBS -lthreads"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002078 THREADOBJ="Python/thread.o"],[
Martin v. Löwis130fb172001-07-19 11:00:41 +00002079 AC_CHECK_HEADER(mach/cthreads.h, [AC_DEFINE(WITH_THREAD)
2080 AC_DEFINE(C_THREADS)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002081 AC_DEFINE(MACH_C_THREADS, 1,
2082 [Define if you are using Mach cthreads under mach /])
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002083 THREADOBJ="Python/thread.o"],[
Martin v. Löwis8158b5a2001-10-08 13:17:28 +00002084 # Just looking for pthread_create in libpthread is not enough:
2085 # on HP/UX, pthread.h renames pthread_create to a different symbol name.
2086 # So we really have to include pthread.h, and then link.
2087 _libs=$LIBS
2088 LIBS="$LIBS -lpthread"
2089 AC_MSG_CHECKING([for pthread_create in -lpthread])
2090 AC_TRY_LINK([#include <pthread.h>
2091
2092void * start_routine (void *arg) { exit (0); }], [
2093pthread_create (NULL, NULL, start_routine, NULL)], [
2094 AC_MSG_RESULT(yes)
2095 AC_DEFINE(WITH_THREAD)
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002096 posix_threads=yes
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002097 THREADOBJ="Python/thread.o"],[
Martin v. Löwis8158b5a2001-10-08 13:17:28 +00002098 LIBS=$_libs
Martin v. Löwis130fb172001-07-19 11:00:41 +00002099 AC_CHECK_FUNC(pthread_detach, [AC_DEFINE(WITH_THREAD)
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002100 posix_threads=yes
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002101 THREADOBJ="Python/thread.o"],[
Martin v. Löwis130fb172001-07-19 11:00:41 +00002102 AC_CHECK_LIB(pthreads, pthread_create, [AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002103 posix_threads=yes
Martin v. Löwis130fb172001-07-19 11:00:41 +00002104 LIBS="$LIBS -lpthreads"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002105 THREADOBJ="Python/thread.o"], [
Martin v. Löwis130fb172001-07-19 11:00:41 +00002106 AC_CHECK_LIB(c_r, pthread_create, [AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002107 posix_threads=yes
Martin v. Löwis130fb172001-07-19 11:00:41 +00002108 LIBS="$LIBS -lc_r"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002109 THREADOBJ="Python/thread.o"], [
Martin v. Löwis130fb172001-07-19 11:00:41 +00002110 AC_CHECK_LIB(pthread, __pthread_create_system, [AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002111 posix_threads=yes
Martin v. Löwis130fb172001-07-19 11:00:41 +00002112 LIBS="$LIBS -lpthread"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002113 THREADOBJ="Python/thread.o"], [
Martin v. Löwis130fb172001-07-19 11:00:41 +00002114 AC_CHECK_LIB(cma, pthread_create, [AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002115 posix_threads=yes
Martin v. Löwis130fb172001-07-19 11:00:41 +00002116 LIBS="$LIBS -lcma"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002117 THREADOBJ="Python/thread.o"],[
Martin v. Löwis130fb172001-07-19 11:00:41 +00002118 USE_THREAD_MODULE="#"])
Antoine Pitroudb6c5672009-10-24 20:35:52 +00002119 ])])])])])])])
Barry Warsawc0d24d82000-06-29 16:12:00 +00002120
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002121 AC_CHECK_LIB(mpc, usconfig, [AC_DEFINE(WITH_THREAD)
2122 LIBS="$LIBS -lmpc"
2123 THREADOBJ="Python/thread.o"
2124 USE_THREAD_MODULE=""])
2125
2126 if test "$posix_threads" != "yes"; then
2127 AC_CHECK_LIB(thread, thr_create, [AC_DEFINE(WITH_THREAD)
2128 LIBS="$LIBS -lthread"
2129 THREADOBJ="Python/thread.o"
2130 USE_THREAD_MODULE=""])
2131 fi
2132
2133 if test "$USE_THREAD_MODULE" != "#"
2134 then
2135 # If the above checks didn't disable threads, (at least) OSF1
2136 # needs this '-threads' argument during linking.
2137 case $ac_sys_system in
2138 OSF1) LDLAST=-threads;;
2139 esac
2140 fi
2141fi
2142
2143if test "$posix_threads" = "yes"; then
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002144 if test "$unistd_defines_pthreads" = "no"; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002145 AC_DEFINE(_POSIX_THREADS, 1,
2146 [Define if you have POSIX threads,
2147 and your system does not define that.])
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002148 fi
2149
Martin v. Löwisdfc33fd2003-01-21 10:14:41 +00002150 # Bug 662787: Using semaphores causes unexplicable hangs on Solaris 8.
2151 case $ac_sys_system/$ac_sys_release in
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002152 SunOS/5.6) AC_DEFINE(HAVE_PTHREAD_DESTRUCTOR, 1,
2153 Defined for Solaris 2.6 bug in pthread header.)
2154 ;;
Martin v. Löwisdfc33fd2003-01-21 10:14:41 +00002155 SunOS/5.8) AC_DEFINE(HAVE_BROKEN_POSIX_SEMAPHORES, 1,
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002156 Define if the Posix semaphores do not work on your system)
2157 ;;
Christian Heimes7b3ce6a2008-01-31 14:31:45 +00002158 AIX/5) AC_DEFINE(HAVE_BROKEN_POSIX_SEMAPHORES, 1,
2159 Define if the Posix semaphores do not work on your system)
2160 ;;
Martin v. Löwisdfc33fd2003-01-21 10:14:41 +00002161 esac
2162
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002163 AC_MSG_CHECKING(if PTHREAD_SCOPE_SYSTEM is supported)
2164 AC_CACHE_VAL(ac_cv_pthread_system_supported,
2165 [AC_TRY_RUN([#include <pthread.h>
2166 void *foo(void *parm) {
2167 return NULL;
2168 }
2169 main() {
2170 pthread_attr_t attr;
Martin v. Löwisa82d3472002-02-24 16:05:05 +00002171 pthread_t id;
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002172 if (pthread_attr_init(&attr)) exit(-1);
2173 if (pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM)) exit(-1);
Martin v. Löwisa82d3472002-02-24 16:05:05 +00002174 if (pthread_create(&id, &attr, foo, NULL)) exit(-1);
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002175 exit(0);
Guido van Rossum3065c942001-09-17 04:03:14 +00002176 }],
2177 ac_cv_pthread_system_supported=yes,
2178 ac_cv_pthread_system_supported=no,
2179 ac_cv_pthread_system_supported=no)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002180 ])
2181 AC_MSG_RESULT($ac_cv_pthread_system_supported)
2182 if test "$ac_cv_pthread_system_supported" = "yes"; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002183 AC_DEFINE(PTHREAD_SYSTEM_SCHED_SUPPORTED, 1, [Defined if PTHREAD_SCOPE_SYSTEM supported.])
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002184 fi
Jason Tishlerfac083d2003-07-22 15:20:49 +00002185 AC_CHECK_FUNCS(pthread_sigmask,
2186 [case $ac_sys_system in
2187 CYGWIN*)
2188 AC_DEFINE(HAVE_BROKEN_PTHREAD_SIGMASK, 1,
2189 [Define if pthread_sigmask() does not work on your system.])
2190 ;;
2191 esac])
Barry Warsawc0d24d82000-06-29 16:12:00 +00002192fi
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002193
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002194
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002195# Check for enable-ipv6
Martin v. Löwis11437992002-04-12 09:54:03 +00002196AH_TEMPLATE(ENABLE_IPV6, [Define if --enable-ipv6 is specified])
Martin v. Löwisa5f8bb52001-09-05 08:22:34 +00002197AC_MSG_CHECKING([if --enable-ipv6 is specified])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002198AC_ARG_ENABLE(ipv6,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002199[ --enable-ipv6 Enable ipv6 (with ipv4) support
2200 --disable-ipv6 Disable ipv6 support],
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002201[ case "$enableval" in
2202 no)
2203 AC_MSG_RESULT(no)
2204 ipv6=no
2205 ;;
2206 *) AC_MSG_RESULT(yes)
2207 AC_DEFINE(ENABLE_IPV6)
2208 ipv6=yes
2209 ;;
2210 esac ],
2211
Martin v. Löwisa5f8bb52001-09-05 08:22:34 +00002212[
2213dnl the check does not work on cross compilation case...
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002214 AC_TRY_RUN([ /* AF_INET6 available check */
2215#include <sys/types.h>
2216#include <sys/socket.h>
2217main()
2218{
2219 if (socket(AF_INET6, SOCK_STREAM, 0) < 0)
2220 exit(1);
2221 else
2222 exit(0);
2223}
2224],
2225 AC_MSG_RESULT(yes)
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002226 ipv6=yes,
2227 AC_MSG_RESULT(no)
2228 ipv6=no,
2229 AC_MSG_RESULT(no)
2230 ipv6=no
Martin v. Löwisa5f8bb52001-09-05 08:22:34 +00002231)
2232
2233if test "$ipv6" = "yes"; then
2234 AC_MSG_CHECKING(if RFC2553 API is available)
2235 AC_TRY_COMPILE([#include <sys/types.h>
2236#include <netinet/in.h>],
2237 [struct sockaddr_in6 x;
2238x.sin6_scope_id;],
2239 AC_MSG_RESULT(yes)
2240 ipv6=yes,
2241 AC_MSG_RESULT(no, IPv6 disabled)
2242 ipv6=no)
2243fi
2244
2245if test "$ipv6" = "yes"; then
2246 AC_DEFINE(ENABLE_IPV6)
2247fi
2248])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002249
2250ipv6type=unknown
2251ipv6lib=none
2252ipv6trylibc=no
2253
2254if test "$ipv6" = "yes"; then
2255 AC_MSG_CHECKING([ipv6 stack type])
Guido van Rossumb8552162001-09-05 14:58:11 +00002256 for i in inria kame linux-glibc linux-inet6 solaris toshiba v6d zeta;
2257 do
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002258 case $i in
2259 inria)
2260 dnl http://www.kame.net/
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002261 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002262#include <netinet/in.h>
2263#ifdef IPV6_INRIA_VERSION
2264yes
2265#endif],
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002266 [ipv6type=$i])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002267 ;;
2268 kame)
2269 dnl http://www.kame.net/
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002270 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002271#include <netinet/in.h>
2272#ifdef __KAME__
2273yes
2274#endif],
2275 [ipv6type=$i;
2276 ipv6lib=inet6
2277 ipv6libdir=/usr/local/v6/lib
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002278 ipv6trylibc=yes])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002279 ;;
2280 linux-glibc)
2281 dnl http://www.v6.linux.or.jp/
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002282 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002283#include <features.h>
2284#if defined(__GLIBC__) && ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1) || (__GLIBC__ > 2))
2285yes
2286#endif],
2287 [ipv6type=$i;
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002288 ipv6trylibc=yes])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002289 ;;
2290 linux-inet6)
2291 dnl http://www.v6.linux.or.jp/
2292 if test -d /usr/inet6; then
2293 ipv6type=$i
2294 ipv6lib=inet6
2295 ipv6libdir=/usr/inet6/lib
Skip Montanarodecc6a42003-01-01 20:07:49 +00002296 BASECFLAGS="-I/usr/inet6/include $BASECFLAGS"
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002297 fi
2298 ;;
2299 solaris)
2300 if test -f /etc/netconfig; then
2301 if /usr/xpg4/bin/grep -q tcp6 /etc/netconfig; then
2302 ipv6type=$i
2303 ipv6trylibc=yes
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002304 fi
2305 fi
2306 ;;
2307 toshiba)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002308 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002309#include <sys/param.h>
2310#ifdef _TOSHIBA_INET6
2311yes
2312#endif],
2313 [ipv6type=$i;
2314 ipv6lib=inet6;
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002315 ipv6libdir=/usr/local/v6/lib])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002316 ;;
2317 v6d)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002318 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002319#include </usr/local/v6/include/sys/v6config.h>
2320#ifdef __V6D__
2321yes
2322#endif],
2323 [ipv6type=$i;
2324 ipv6lib=v6;
2325 ipv6libdir=/usr/local/v6/lib;
Skip Montanarodecc6a42003-01-01 20:07:49 +00002326 BASECFLAGS="-I/usr/local/v6/include $BASECFLAGS"])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002327 ;;
2328 zeta)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002329 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002330#include <sys/param.h>
2331#ifdef _ZETA_MINAMI_INET6
2332yes
2333#endif],
2334 [ipv6type=$i;
2335 ipv6lib=inet6;
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002336 ipv6libdir=/usr/local/v6/lib])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002337 ;;
2338 esac
2339 if test "$ipv6type" != "unknown"; then
2340 break
2341 fi
2342 done
2343 AC_MSG_RESULT($ipv6type)
2344fi
2345
2346if test "$ipv6" = "yes" -a "$ipv6lib" != "none"; then
2347 if test -d $ipv6libdir -a -f $ipv6libdir/lib$ipv6lib.a; then
2348 LIBS="-L$ipv6libdir -l$ipv6lib $LIBS"
2349 echo "using lib$ipv6lib"
2350 else
2351 if test $ipv6trylibc = "yes"; then
2352 echo "using libc"
2353 else
2354 echo 'Fatal: no $ipv6lib library found. cannot continue.'
2355 echo "You need to fetch lib$ipv6lib.a from appropriate"
2356 echo 'ipv6 kit and compile beforehand.'
2357 exit 1
2358 fi
2359 fi
2360fi
2361
Georg Brandl93de2162008-07-16 02:21:06 +00002362AC_MSG_CHECKING(for OSX 10.5 SDK or later)
2363AC_TRY_COMPILE([#include <Carbon/Carbon.h>], FSIORefNum fRef = 0,
2364 AC_DEFINE(HAVE_OSX105_SDK, 1, Define if compiling using MacOS X 10.5 SDK or later.)
2365 AC_MSG_RESULT(yes),
2366 AC_MSG_RESULT(no)
2367)
2368
Martin v. Löwisa3fb4f72002-06-09 13:33:54 +00002369# Check for --with-doc-strings
2370AC_MSG_CHECKING(for --with-doc-strings)
2371AC_ARG_WITH(doc-strings,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002372 AC_HELP_STRING(--with(out)-doc-strings, disable/enable documentation strings))
Martin v. Löwisa3fb4f72002-06-09 13:33:54 +00002373
2374if test -z "$with_doc_strings"
2375then with_doc_strings="yes"
2376fi
2377if test "$with_doc_strings" != "no"
2378then
2379 AC_DEFINE(WITH_DOC_STRINGS, 1,
2380 [Define if you want documentation strings in extension modules])
2381fi
2382AC_MSG_RESULT($with_doc_strings)
2383
Neil Schemenauera35c6882001-02-27 04:45:05 +00002384# Check for Python-specific malloc support
Martin v. Löwisf30d60e2004-06-08 08:17:44 +00002385AC_MSG_CHECKING(for --with-tsc)
2386AC_ARG_WITH(tsc,
2387[ --with(out)-tsc enable/disable timestamp counter profile], [
2388if test "$withval" != no
2389then
2390 AC_DEFINE(WITH_TSC, 1,
2391 [Define to profile with the Pentium timestamp counter])
2392 AC_MSG_RESULT(yes)
2393else AC_MSG_RESULT(no)
2394fi],
2395[AC_MSG_RESULT(no)])
2396
2397# Check for Python-specific malloc support
Neil Schemenauera35c6882001-02-27 04:45:05 +00002398AC_MSG_CHECKING(for --with-pymalloc)
2399AC_ARG_WITH(pymalloc,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002400 AC_HELP_STRING(--with(out)-pymalloc, disable/enable specialized mallocs))
Neil Schemenauer16c22972002-03-22 15:34:49 +00002401
2402if test -z "$with_pymalloc"
2403then with_pymalloc="yes"
2404fi
2405if test "$with_pymalloc" != "no"
2406then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002407 AC_DEFINE(WITH_PYMALLOC, 1,
2408 [Define if you want to compile in Python-specific mallocs])
Neil Schemenauer16c22972002-03-22 15:34:49 +00002409fi
2410AC_MSG_RESULT($with_pymalloc)
Neil Schemenauera35c6882001-02-27 04:45:05 +00002411
Benjamin Peterson05159c42009-12-03 03:01:27 +00002412# Check for Valgrind support
2413AC_MSG_CHECKING([for --with-valgrind])
2414AC_ARG_WITH([valgrind],
2415 AC_HELP_STRING([--with-valgrind], [Enable Valgrind support]),,
2416 with_valgrind=no)
2417AC_MSG_RESULT([$with_valgrind])
2418if test "$with_valgrind" != no; then
2419 AC_CHECK_HEADER([valgrind/valgrind.h],
2420 [AC_DEFINE([WITH_VALGRIND], 1, [Define if you want pymalloc to be disabled when running under valgrind])],
2421 [AC_MSG_ERROR([Valgrind support requested but headers not available])]
2422 )
2423fi
2424
Barry Warsawef82cd72000-06-30 16:21:01 +00002425# Check for --with-wctype-functions
2426AC_MSG_CHECKING(for --with-wctype-functions)
2427AC_ARG_WITH(wctype-functions,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002428 AC_HELP_STRING(--with-wctype-functions, use wctype.h functions),
2429[
Barry Warsawef82cd72000-06-30 16:21:01 +00002430if test "$withval" != no
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002431then
2432 AC_DEFINE(WANT_WCTYPE_FUNCTIONS, 1,
2433 [Define if you want wctype.h functions to be used instead of the
2434 one supplied by Python itself. (see Include/unicodectype.h).])
2435 AC_MSG_RESULT(yes)
Barry Warsawef82cd72000-06-30 16:21:01 +00002436else AC_MSG_RESULT(no)
2437fi],
2438[AC_MSG_RESULT(no)])
2439
Guido van Rossum68242b51996-05-28 22:53:03 +00002440# -I${DLINCLDIR} is added to the compile rule for importdl.o
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002441AC_SUBST(DLINCLDIR)
Guido van Rossum98935bf2001-09-05 19:13:16 +00002442DLINCLDIR=.
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002443
Guido van Rossume97ee181999-12-20 21:27:22 +00002444# the dlopen() function means we might want to use dynload_shlib.o. some
2445# platforms, such as AIX, have dlopen(), but don't want to use it.
Thomas Wouters3a584202000-08-05 23:28:51 +00002446AC_CHECK_FUNCS(dlopen)
Guido van Rossume97ee181999-12-20 21:27:22 +00002447
2448# DYNLOADFILE specifies which dynload_*.o file we will use for dynamic
2449# loading of modules.
2450AC_SUBST(DYNLOADFILE)
2451AC_MSG_CHECKING(DYNLOADFILE)
2452if test -z "$DYNLOADFILE"
2453then
2454 case $ac_sys_system/$ac_sys_release in
Martin v. Löwisc19c5a62003-11-18 20:00:44 +00002455 AIX*) # Use dynload_shlib.c and dlopen() if we have it; otherwise dynload_aix.c
2456 if test "$ac_cv_func_dlopen" = yes
2457 then DYNLOADFILE="dynload_shlib.o"
2458 else DYNLOADFILE="dynload_aix.o"
2459 fi
2460 ;;
Guido van Rossume97ee181999-12-20 21:27:22 +00002461 hp*|HP*) DYNLOADFILE="dynload_hpux.o";;
Thomas Wouters49fd7fa2006-04-21 10:40:58 +00002462 # Use dynload_next.c only on 10.2 and below, which don't have native dlopen()
2463 Darwin/@<:@0156@:>@\..*) DYNLOADFILE="dynload_next.o";;
Guido van Rossume97ee181999-12-20 21:27:22 +00002464 *)
2465 # use dynload_shlib.c and dlopen() if we have it; otherwise stub
2466 # out any dynamic loading
2467 if test "$ac_cv_func_dlopen" = yes
2468 then DYNLOADFILE="dynload_shlib.o"
2469 else DYNLOADFILE="dynload_stub.o"
2470 fi
2471 ;;
2472 esac
2473fi
2474AC_MSG_RESULT($DYNLOADFILE)
2475if test "$DYNLOADFILE" != "dynload_stub.o"
2476then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002477 AC_DEFINE(HAVE_DYNAMIC_LOADING, 1,
2478 [Defined when any dynamic module loading is enabled.])
Guido van Rossume97ee181999-12-20 21:27:22 +00002479fi
2480
Jack Jansenc49e5b72001-06-19 15:00:23 +00002481# MACHDEP_OBJS can be set to platform-specific object files needed by Python
2482
2483AC_SUBST(MACHDEP_OBJS)
2484AC_MSG_CHECKING(MACHDEP_OBJS)
2485if test -z "$MACHDEP_OBJS"
2486then
Jack Jansenb6e9cad2001-08-15 01:26:28 +00002487 MACHDEP_OBJS=$extra_machdep_objs
2488else
2489 MACHDEP_OBJS="$MACHDEP_OBJS $extra_machdep_objs"
Jack Jansenc49e5b72001-06-19 15:00:23 +00002490fi
Jack Jansenb6e9cad2001-08-15 01:26:28 +00002491AC_MSG_RESULT(MACHDEP_OBJS)
Jack Jansenc49e5b72001-06-19 15:00:23 +00002492
Guido van Rossum627b2d71993-12-24 10:39:16 +00002493# checks for library functions
Martin v. Löwis823725e2008-03-24 13:39:54 +00002494AC_CHECK_FUNCS(alarm setitimer getitimer bind_textdomain_codeset chown \
2495 clock confstr ctermid execv fchmod fchown fork fpathconf ftime ftruncate \
Martin v. Löwis438b5342002-12-27 10:16:42 +00002496 gai_strerror getgroups getlogin getloadavg getpeername getpgid getpid \
Martin v. Löwis7aed61a2009-11-27 14:09:49 +00002497 getpriority getresuid getresgid getpwent getspnam getspent getsid getwd \
Antoine Pitroub7572f02009-12-02 20:46:48 +00002498 initgroups kill killpg lchmod lchown lstat mbrtowc mkfifo mknod mktime \
Martin v. Löwisa5f09072002-10-11 05:37:59 +00002499 mremap nice pathconf pause plock poll pthread_init \
Guido van Rossum162e38c2003-02-19 15:25:10 +00002500 putenv readlink realpath \
Benjamin Peterson965ce872009-04-05 21:24:58 +00002501 select sem_open sem_timedwait sem_getvalue sem_unlink setegid seteuid \
2502 setgid \
Martin v. Löwis7aed61a2009-11-27 14:09:49 +00002503 setlocale setregid setreuid setresuid setresgid setsid setpgid setpgrp setuid setvbuf \
2504 sigaction siginterrupt sigrelse snprintf strftime strlcpy \
Michael W. Hudson34f20ea2002-05-27 15:08:24 +00002505 sysconf tcgetpgrp tcsetpgrp tempnam timegm times tmpfile tmpnam tmpnam_r \
Martin v. Löwis113a0852009-05-29 17:25:39 +00002506 truncate uname unsetenv utimes waitpid wait3 wait4 \
2507 wcscoll wcsftime wcsxfrm _getpty)
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00002508
Martin v. Löwisc8ad7cc2002-11-11 13:23:45 +00002509# For some functions, having a definition is not sufficient, since
2510# we want to take their address.
2511AC_MSG_CHECKING(for chroot)
2512AC_TRY_COMPILE([#include <unistd.h>], void *x=chroot,
2513 AC_DEFINE(HAVE_CHROOT, 1, Define if you have the 'chroot' function.)
2514 AC_MSG_RESULT(yes),
2515 AC_MSG_RESULT(no)
2516)
2517AC_MSG_CHECKING(for link)
2518AC_TRY_COMPILE([#include <unistd.h>], void *x=link,
2519 AC_DEFINE(HAVE_LINK, 1, Define if you have the 'link' function.)
2520 AC_MSG_RESULT(yes),
2521 AC_MSG_RESULT(no)
2522)
2523AC_MSG_CHECKING(for symlink)
2524AC_TRY_COMPILE([#include <unistd.h>], void *x=symlink,
2525 AC_DEFINE(HAVE_SYMLINK, 1, Define if you have the 'symlink' function.)
2526 AC_MSG_RESULT(yes),
2527 AC_MSG_RESULT(no)
2528)
Martin v. Löwisa64988c2003-09-20 15:30:20 +00002529AC_MSG_CHECKING(for fchdir)
2530AC_TRY_COMPILE([#include <unistd.h>], void *x=fchdir,
2531 AC_DEFINE(HAVE_FCHDIR, 1, Define if you have the 'fchdir' function.)
2532 AC_MSG_RESULT(yes),
2533 AC_MSG_RESULT(no)
2534)
2535AC_MSG_CHECKING(for fsync)
2536AC_TRY_COMPILE([#include <unistd.h>], void *x=fsync,
Skip Montanarod4fa8072003-09-25 14:49:15 +00002537 AC_DEFINE(HAVE_FSYNC, 1, Define if you have the 'fsync' function.)
Martin v. Löwisa64988c2003-09-20 15:30:20 +00002538 AC_MSG_RESULT(yes),
2539 AC_MSG_RESULT(no)
2540)
2541AC_MSG_CHECKING(for fdatasync)
2542AC_TRY_COMPILE([#include <unistd.h>], void *x=fdatasync,
2543 AC_DEFINE(HAVE_FDATASYNC, 1, Define if you have the 'fdatasync' function.)
2544 AC_MSG_RESULT(yes),
2545 AC_MSG_RESULT(no)
2546)
Christian Heimes4fbc72b2008-03-22 00:47:35 +00002547AC_MSG_CHECKING(for epoll)
2548AC_TRY_COMPILE([#include <sys/epoll.h>], void *x=epoll_create,
2549 AC_DEFINE(HAVE_EPOLL, 1, Define if you have the 'epoll' functions.)
2550 AC_MSG_RESULT(yes),
2551 AC_MSG_RESULT(no)
2552)
2553AC_MSG_CHECKING(for kqueue)
2554AC_TRY_COMPILE([
2555#include <sys/types.h>
2556#include <sys/event.h>
2557 ], int x=kqueue(),
2558 AC_DEFINE(HAVE_KQUEUE, 1, Define if you have the 'kqueue' functions.)
2559 AC_MSG_RESULT(yes),
2560 AC_MSG_RESULT(no)
2561)
Martin v. Löwisd5843682002-11-21 20:41:28 +00002562# On some systems (eg. FreeBSD 5), we would find a definition of the
2563# functions ctermid_r, setgroups in the library, but no prototype
2564# (e.g. because we use _XOPEN_SOURCE). See whether we can take their
2565# address to avoid compiler warnings and potential miscompilations
2566# because of the missing prototypes.
2567
2568AC_MSG_CHECKING(for ctermid_r)
2569AC_TRY_COMPILE([
2570#include "confdefs.h"
2571#include <stdio.h>
2572], void* p = ctermid_r,
2573 AC_DEFINE(HAVE_CTERMID_R, 1, Define if you have the 'ctermid_r' function.)
2574 AC_MSG_RESULT(yes),
2575 AC_MSG_RESULT(no)
2576)
2577
Martin v. Löwisf26d63b2003-03-30 17:23:49 +00002578AC_MSG_CHECKING(for flock)
2579AC_TRY_COMPILE([
2580#include "confdefs.h"
2581#include <sys/file.h>
2582], void* p = flock,
2583 AC_DEFINE(HAVE_FLOCK, 1, Define if you have the 'flock' function.)
2584 AC_MSG_RESULT(yes),
2585 AC_MSG_RESULT(no)
2586)
2587
2588AC_MSG_CHECKING(for getpagesize)
2589AC_TRY_COMPILE([
2590#include "confdefs.h"
2591#include <unistd.h>
2592], void* p = getpagesize,
2593 AC_DEFINE(HAVE_GETPAGESIZE, 1, Define if you have the 'getpagesize' function.)
2594 AC_MSG_RESULT(yes),
2595 AC_MSG_RESULT(no)
2596)
2597
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002598dnl check for true
2599AC_CHECK_PROGS(TRUE, true, /bin/true)
2600
Martin v. Löwis95c419b2003-05-03 12:10:48 +00002601dnl On some systems (e.g. Solaris 9), hstrerror and inet_aton are in -lresolv
2602dnl On others, they are in the C library, so we to take no action
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002603AC_CHECK_LIB(c, inet_aton, [$ac_cv_prog_TRUE],
Martin v. Löwis95c419b2003-05-03 12:10:48 +00002604 AC_CHECK_LIB(resolv, inet_aton)
2605)
2606
Christian Heimesd0764e22007-12-04 15:00:33 +00002607# On Tru64, chflags seems to be present, but calling it will
2608# exit Python
Benjamin Petersoned68afa2010-01-30 19:36:43 +00002609AC_CACHE_CHECK([for chflags], [ac_cv_have_chflags], [dnl
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00002610AC_TRY_RUN([[
Christian Heimesd0764e22007-12-04 15:00:33 +00002611#include <sys/stat.h>
2612#include <unistd.h>
2613int main(int argc, char*argv[])
2614{
2615 if(chflags(argv[0], 0) != 0)
2616 return 1;
2617 return 0;
2618}
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00002619]], ac_cv_have_chflags=yes,
Benjamin Petersoned68afa2010-01-30 19:36:43 +00002620 ac_cv_have_chflags=no,
2621 ac_cv_have_chflags=cross)
2622])
2623if test "$ac_cv_have_chflags" = cross ; then
2624 AC_CHECK_FUNC([chflags], [ac_cv_have_chflags="yes"], [ac_cv_have_chflags="no"])
2625fi
2626if test "$ac_cv_have_chflags" = yes ; then
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00002627 AC_DEFINE(HAVE_CHFLAGS, 1, Define to 1 if you have the `chflags' function.)
2628fi
Christian Heimesd0764e22007-12-04 15:00:33 +00002629
Benjamin Petersoned68afa2010-01-30 19:36:43 +00002630AC_CACHE_CHECK([for lchflags], [ac_cv_have_lchflags], [dnl
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00002631AC_TRY_RUN([[
Christian Heimesd0764e22007-12-04 15:00:33 +00002632#include <sys/stat.h>
2633#include <unistd.h>
2634int main(int argc, char*argv[])
2635{
2636 if(lchflags(argv[0], 0) != 0)
2637 return 1;
2638 return 0;
2639}
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00002640]], ac_cv_have_lchflags=yes,
Benjamin Petersoned68afa2010-01-30 19:36:43 +00002641 ac_cv_have_lchflags=no,
2642 ac_cv_have_lchflags=cross)
2643])
2644if test "$ac_cv_have_lchflags" = cross ; then
2645 AC_CHECK_FUNC([lchflags], [ac_cv_have_lchflags="yes"], [ac_cv_have_lchflags="no"])
2646fi
2647if test "$ac_cv_have_lchflags" = yes ; then
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00002648 AC_DEFINE(HAVE_LCHFLAGS, 1, Define to 1 if you have the `lchflags' function.)
2649fi
Christian Heimesd0764e22007-12-04 15:00:33 +00002650
Thomas Wouters0e3f5912006-08-11 14:57:12 +00002651dnl Check if system zlib has *Copy() functions
2652dnl
2653dnl On MacOSX the linker will search for dylibs on the entire linker path
2654dnl before searching for static libraries. setup.py adds -Wl,-search_paths_first
2655dnl to revert to a more traditional unix behaviour and make it possible to
2656dnl override the system libz with a local static library of libz. Temporarily
2657dnl add that flag to our CFLAGS as well to ensure that we check the version
2658dnl of libz that will be used by setup.py.
2659dnl The -L/usr/local/lib is needed as wel to get the same compilation
2660dnl environment as setup.py (and leaving it out can cause configure to use the
2661dnl wrong version of the library)
2662case $ac_sys_system/$ac_sys_release in
2663Darwin/*)
2664 _CUR_CFLAGS="${CFLAGS}"
2665 _CUR_LDFLAGS="${LDFLAGS}"
2666 CFLAGS="${CFLAGS} -Wl,-search_paths_first"
2667 LDFLAGS="${LDFLAGS} -Wl,-search_paths_first -L/usr/local/lib"
2668 ;;
2669esac
2670
2671AC_CHECK_LIB(z, inflateCopy, AC_DEFINE(HAVE_ZLIB_COPY, 1, Define if the zlib library has inflateCopy))
2672
2673case $ac_sys_system/$ac_sys_release in
2674Darwin/*)
2675 CFLAGS="${_CUR_CFLAGS}"
2676 LDFLAGS="${_CUR_LDFLAGS}"
2677 ;;
2678esac
2679
Martin v. Löwise9416172003-05-03 10:12:45 +00002680AC_MSG_CHECKING(for hstrerror)
Martin v. Löwis95c419b2003-05-03 12:10:48 +00002681AC_TRY_LINK([
Martin v. Löwise9416172003-05-03 10:12:45 +00002682#include "confdefs.h"
2683#include <netdb.h>
Martin v. Löwis95c419b2003-05-03 12:10:48 +00002684], void* p = hstrerror; hstrerror(0),
Martin v. Löwise9416172003-05-03 10:12:45 +00002685 AC_DEFINE(HAVE_HSTRERROR, 1, Define if you have the 'hstrerror' function.)
2686 AC_MSG_RESULT(yes),
2687 AC_MSG_RESULT(no)
2688)
2689
2690AC_MSG_CHECKING(for inet_aton)
Martin v. Löwis95c419b2003-05-03 12:10:48 +00002691AC_TRY_LINK([
Martin v. Löwise9416172003-05-03 10:12:45 +00002692#include "confdefs.h"
Martin v. Löwis86d66262006-02-17 08:40:11 +00002693#include <sys/types.h>
Martin v. Löwise9416172003-05-03 10:12:45 +00002694#include <sys/socket.h>
2695#include <netinet/in.h>
2696#include <arpa/inet.h>
Martin v. Löwis95c419b2003-05-03 12:10:48 +00002697], void* p = inet_aton;inet_aton(0,0),
Martin v. Löwise9416172003-05-03 10:12:45 +00002698 AC_DEFINE(HAVE_INET_ATON, 1, Define if you have the 'inet_aton' function.)
2699 AC_MSG_RESULT(yes),
2700 AC_MSG_RESULT(no)
2701)
2702
2703AC_MSG_CHECKING(for inet_pton)
2704AC_TRY_COMPILE([
2705#include "confdefs.h"
Martin v. Löwisf2e488d2003-05-05 22:00:11 +00002706#include <sys/types.h>
Martin v. Löwise9416172003-05-03 10:12:45 +00002707#include <sys/socket.h>
2708#include <netinet/in.h>
2709#include <arpa/inet.h>
2710], void* p = inet_pton,
2711 AC_DEFINE(HAVE_INET_PTON, 1, Define if you have the 'inet_pton' function.)
2712 AC_MSG_RESULT(yes),
2713 AC_MSG_RESULT(no)
2714)
2715
Martin v. Löwisd6640d42003-07-06 09:29:52 +00002716# On some systems, setgroups is in unistd.h, on others, in grp.h
Martin v. Löwisd5843682002-11-21 20:41:28 +00002717AC_MSG_CHECKING(for setgroups)
2718AC_TRY_COMPILE([
2719#include "confdefs.h"
Martin v. Löwisf2e488d2003-05-05 22:00:11 +00002720#include <unistd.h>
Martin v. Löwisd6640d42003-07-06 09:29:52 +00002721#ifdef HAVE_GRP_H
2722#include <grp.h>
2723#endif
Martin v. Löwisd5843682002-11-21 20:41:28 +00002724],
2725void* p = setgroups,
2726 AC_DEFINE(HAVE_SETGROUPS, 1, Define if you have the 'setgroups' function.)
2727 AC_MSG_RESULT(yes),
2728 AC_MSG_RESULT(no)
2729)
2730
Fred Drake8cef4cf2000-06-28 16:40:38 +00002731# check for openpty and forkpty
2732
Martin v. Löwisfd9a72a2006-01-08 10:07:33 +00002733AC_CHECK_FUNCS(openpty,,
2734 AC_CHECK_LIB(util,openpty,
2735 [AC_DEFINE(HAVE_OPENPTY) LIBS="$LIBS -lutil"],
2736 AC_CHECK_LIB(bsd,openpty, [AC_DEFINE(HAVE_OPENPTY) LIBS="$LIBS -lbsd"])
2737 )
2738)
2739AC_CHECK_FUNCS(forkpty,,
2740 AC_CHECK_LIB(util,forkpty,
2741 [AC_DEFINE(HAVE_FORKPTY) LIBS="$LIBS -lutil"],
2742 AC_CHECK_LIB(bsd,forkpty, [AC_DEFINE(HAVE_FORKPTY) LIBS="$LIBS -lbsd"])
2743 )
2744)
Fred Drake8cef4cf2000-06-28 16:40:38 +00002745
Christian Heimesb186d002008-03-18 15:15:01 +00002746# Stuff for expat.
2747AC_CHECK_FUNCS(memmove)
2748
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00002749# check for long file support functions
2750AC_CHECK_FUNCS(fseek64 fseeko fstatvfs ftell64 ftello statvfs)
2751
Christian Heimesb186d002008-03-18 15:15:01 +00002752AC_REPLACE_FUNCS(dup2 getcwd strdup)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002753AC_CHECK_FUNCS(getpgrp,
2754 AC_TRY_COMPILE([#include <unistd.h>],
2755 [getpgrp(0);],
2756 AC_DEFINE(GETPGRP_HAVE_ARG, 1,
2757 [Define if getpgrp() must be called as getpgrp(0).])
2758 )
2759)
Jack Jansen150753c2003-03-29 22:07:47 +00002760AC_CHECK_FUNCS(setpgrp,
2761 AC_TRY_COMPILE([#include <unistd.h>],
2762 [setpgrp(0,0);],
2763 AC_DEFINE(SETPGRP_HAVE_ARG, 1,
2764 [Define if setpgrp() must be called as setpgrp(0, 0).])
2765 )
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002766)
2767AC_CHECK_FUNCS(gettimeofday,
2768 AC_TRY_COMPILE([#include <sys/time.h>],
2769 [gettimeofday((struct timeval*)0,(struct timezone*)0);], ,
2770 AC_DEFINE(GETTIMEOFDAY_NO_TZ, 1,
2771 [Define if gettimeofday() does not have second (timezone) argument
2772 This is the case on Motorola V4 (R40V4.2)])
2773 )
2774)
Guido van Rossum627b2d71993-12-24 10:39:16 +00002775
Martin v. Löwisdbe3f762002-10-10 14:27:30 +00002776AC_MSG_CHECKING(for major, minor, and makedev)
Martin v. Löwise3271202002-11-07 07:42:30 +00002777AC_TRY_LINK([
Neal Norwitz6eb37f02003-02-23 23:28:15 +00002778#if defined(MAJOR_IN_MKDEV)
2779#include <sys/mkdev.h>
2780#elif defined(MAJOR_IN_SYSMACROS)
2781#include <sys/sysmacros.h>
2782#else
2783#include <sys/types.h>
2784#endif
Martin v. Löwisdbe3f762002-10-10 14:27:30 +00002785],[
2786 makedev(major(0),minor(0));
2787],[
2788 AC_DEFINE(HAVE_DEVICE_MACROS, 1,
2789 [Define to 1 if you have the device macros.])
2790 AC_MSG_RESULT(yes)
2791],[
2792 AC_MSG_RESULT(no)
2793])
Martin v. Löwis861a65b2001-10-24 14:36:00 +00002794
2795# On OSF/1 V5.1, getaddrinfo is available, but a define
2796# for [no]getaddrinfo in netdb.h.
2797AC_MSG_CHECKING(for getaddrinfo)
2798AC_TRY_LINK([
Martin v. Löwisc010b6d2001-11-09 17:50:52 +00002799#include <sys/types.h>
Martin v. Löwis861a65b2001-10-24 14:36:00 +00002800#include <sys/socket.h>
2801#include <netdb.h>
Martin v. Löwisc010b6d2001-11-09 17:50:52 +00002802#include <stdio.h>
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00002803], [getaddrinfo(NULL, NULL, NULL, NULL);],
2804have_getaddrinfo=yes,
2805have_getaddrinfo=no)
2806AC_MSG_RESULT($have_getaddrinfo)
2807if test $have_getaddrinfo = yes
2808then
2809 AC_MSG_CHECKING(getaddrinfo bug)
2810 AC_CACHE_VAL(ac_cv_buggy_getaddrinfo,
2811 AC_TRY_RUN([[
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00002812#include <sys/types.h>
2813#include <netdb.h>
2814#include <string.h>
2815#include <sys/socket.h>
2816#include <netinet/in.h>
2817
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00002818int main()
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00002819{
2820 int passive, gaierr, inet4 = 0, inet6 = 0;
2821 struct addrinfo hints, *ai, *aitop;
2822 char straddr[INET6_ADDRSTRLEN], strport[16];
2823
2824 for (passive = 0; passive <= 1; passive++) {
2825 memset(&hints, 0, sizeof(hints));
2826 hints.ai_family = AF_UNSPEC;
2827 hints.ai_flags = passive ? AI_PASSIVE : 0;
2828 hints.ai_socktype = SOCK_STREAM;
Hye-Shik Chang54f94392004-04-14 07:55:31 +00002829 hints.ai_protocol = IPPROTO_TCP;
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00002830 if ((gaierr = getaddrinfo(NULL, "54321", &hints, &aitop)) != 0) {
2831 (void)gai_strerror(gaierr);
2832 goto bad;
2833 }
2834 for (ai = aitop; ai; ai = ai->ai_next) {
2835 if (ai->ai_addr == NULL ||
2836 ai->ai_addrlen == 0 ||
2837 getnameinfo(ai->ai_addr, ai->ai_addrlen,
2838 straddr, sizeof(straddr), strport, sizeof(strport),
2839 NI_NUMERICHOST|NI_NUMERICSERV) != 0) {
2840 goto bad;
2841 }
2842 switch (ai->ai_family) {
2843 case AF_INET:
2844 if (strcmp(strport, "54321") != 0) {
2845 goto bad;
2846 }
2847 if (passive) {
2848 if (strcmp(straddr, "0.0.0.0") != 0) {
2849 goto bad;
2850 }
2851 } else {
2852 if (strcmp(straddr, "127.0.0.1") != 0) {
2853 goto bad;
2854 }
2855 }
2856 inet4++;
2857 break;
2858 case AF_INET6:
2859 if (strcmp(strport, "54321") != 0) {
2860 goto bad;
2861 }
2862 if (passive) {
2863 if (strcmp(straddr, "::") != 0) {
2864 goto bad;
2865 }
2866 } else {
2867 if (strcmp(straddr, "::1") != 0) {
2868 goto bad;
2869 }
2870 }
2871 inet6++;
2872 break;
2873 case AF_UNSPEC:
2874 goto bad;
2875 break;
2876 default:
2877 /* another family support? */
2878 break;
2879 }
2880 }
2881 }
2882
2883 if (!(inet4 == 0 || inet4 == 2))
2884 goto bad;
2885 if (!(inet6 == 0 || inet6 == 2))
2886 goto bad;
2887
2888 if (aitop)
2889 freeaddrinfo(aitop);
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00002890 return 0;
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00002891
2892 bad:
2893 if (aitop)
2894 freeaddrinfo(aitop);
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00002895 return 1;
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00002896}
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00002897]], ac_cv_buggy_getaddrinfo=no,
2898 ac_cv_buggy_getaddrinfo=yes,
2899 ac_cv_buggy_getaddrinfo=yes))
2900fi
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00002901
Mark Dickinson2df5d282009-12-31 21:22:50 +00002902if test $have_getaddrinfo = no -o "$ac_cv_buggy_getaddrinfo" = yes
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00002903then
2904 if test $ipv6 = yes
2905 then
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00002906 echo 'Fatal: You must get working getaddrinfo() function.'
2907 echo ' or you can specify "--disable-ipv6"'.
2908 exit 1
2909 fi
Martin v. Löwis861a65b2001-10-24 14:36:00 +00002910else
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002911 AC_DEFINE(HAVE_GETADDRINFO, 1, [Define if you have the getaddrinfo function.])
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00002912fi
Thomas Woutersb0db85a2001-08-08 10:39:03 +00002913AC_CHECK_FUNCS(getnameinfo)
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00002914
Guido van Rossum627b2d71993-12-24 10:39:16 +00002915# checks for structures
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002916AC_HEADER_TIME
Guido van Rossum627b2d71993-12-24 10:39:16 +00002917AC_STRUCT_TM
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002918AC_STRUCT_TIMEZONE
Martin v. Löwis60a5d722002-10-16 20:28:25 +00002919AC_CHECK_MEMBERS([struct stat.st_rdev])
2920AC_CHECK_MEMBERS([struct stat.st_blksize])
Hye-Shik Chang5f937a72005-06-02 13:09:30 +00002921AC_CHECK_MEMBERS([struct stat.st_flags])
Martin v. Löwisebd9d5b2005-08-09 15:00:59 +00002922AC_CHECK_MEMBERS([struct stat.st_gen])
2923AC_CHECK_MEMBERS([struct stat.st_birthtime])
Guido van Rossum98bf58f2001-10-18 20:34:25 +00002924AC_STRUCT_ST_BLOCKS
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002925
2926AC_MSG_CHECKING(for time.h that defines altzone)
2927AC_CACHE_VAL(ac_cv_header_time_altzone,
2928[AC_TRY_COMPILE([#include <time.h>], [return altzone;],
2929 ac_cv_header_time_altzone=yes,
2930 ac_cv_header_time_altzone=no)])
2931AC_MSG_RESULT($ac_cv_header_time_altzone)
2932if test $ac_cv_header_time_altzone = yes; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002933 AC_DEFINE(HAVE_ALTZONE, 1, [Define this if your time.h defines altzone.])
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002934fi
2935
Guido van Rossum5739e7e1995-01-20 16:50:53 +00002936was_it_defined=no
2937AC_MSG_CHECKING(whether sys/select.h and sys/time.h may both be included)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002938AC_TRY_COMPILE([
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002939#include <sys/types.h>
2940#include <sys/select.h>
2941#include <sys/time.h>
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002942], [;], [
2943 AC_DEFINE(SYS_SELECT_WITH_SYS_TIME, 1,
2944 [Define if you can safely include both <sys/select.h> and <sys/time.h>
2945 (which you can't on SCO ODT 3.0).])
2946 was_it_defined=yes
2947])
Guido van Rossum5739e7e1995-01-20 16:50:53 +00002948AC_MSG_RESULT($was_it_defined)
Guido van Rossum627b2d71993-12-24 10:39:16 +00002949
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00002950AC_MSG_CHECKING(for addrinfo)
2951AC_CACHE_VAL(ac_cv_struct_addrinfo,
2952AC_TRY_COMPILE([
2953# include <netdb.h>],
2954 [struct addrinfo a],
2955 ac_cv_struct_addrinfo=yes,
2956 ac_cv_struct_addrinfo=no))
2957AC_MSG_RESULT($ac_cv_struct_addrinfo)
2958if test $ac_cv_struct_addrinfo = yes; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002959 AC_DEFINE(HAVE_ADDRINFO, 1, [struct addrinfo (netdb.h)])
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00002960fi
2961
2962AC_MSG_CHECKING(for sockaddr_storage)
2963AC_CACHE_VAL(ac_cv_struct_sockaddr_storage,
2964AC_TRY_COMPILE([
2965# include <sys/types.h>
2966# include <sys/socket.h>],
2967 [struct sockaddr_storage s],
2968 ac_cv_struct_sockaddr_storage=yes,
2969 ac_cv_struct_sockaddr_storage=no))
2970AC_MSG_RESULT($ac_cv_struct_sockaddr_storage)
2971if test $ac_cv_struct_sockaddr_storage = yes; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002972 AC_DEFINE(HAVE_SOCKADDR_STORAGE, 1, [struct sockaddr_storage (sys/socket.h)])
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00002973fi
2974
Guido van Rossum627b2d71993-12-24 10:39:16 +00002975# checks for compiler characteristics
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002976
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002977AC_C_CHAR_UNSIGNED
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002978AC_C_CONST
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002979
Guido van Rossum5739e7e1995-01-20 16:50:53 +00002980works=no
2981AC_MSG_CHECKING(for working volatile)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002982AC_TRY_COMPILE([],[volatile int x; x = 0;], works=yes,
2983 AC_DEFINE(volatile, [], [Define to empty if the keyword does not work.])
2984)
Guido van Rossum5739e7e1995-01-20 16:50:53 +00002985AC_MSG_RESULT($works)
Guido van Rossumdabb11b1994-10-11 15:04:27 +00002986
Guido van Rossum5739e7e1995-01-20 16:50:53 +00002987works=no
2988AC_MSG_CHECKING(for working signed char)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002989AC_TRY_COMPILE([], [signed char c;], works=yes,
2990 AC_DEFINE(signed, [], [Define to empty if the keyword does not work.])
2991)
Guido van Rossum5739e7e1995-01-20 16:50:53 +00002992AC_MSG_RESULT($works)
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002993
Guido van Rossum5739e7e1995-01-20 16:50:53 +00002994have_prototypes=no
2995AC_MSG_CHECKING(for prototypes)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002996AC_TRY_COMPILE([int foo(int x) { return 0; }], [return foo(10);],[
2997 AC_DEFINE(HAVE_PROTOTYPES, 1,
2998 [Define if your compiler supports function prototype])
2999 have_prototypes=yes
3000])
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003001AC_MSG_RESULT($have_prototypes)
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003002
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003003works=no
3004AC_MSG_CHECKING(for variable length prototypes and stdarg.h)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003005AC_TRY_COMPILE([
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003006#include <stdarg.h>
Guido van Rossum3f13e481996-08-30 20:58:11 +00003007int foo(int x, ...) {
3008 va_list va;
3009 va_start(va, x);
3010 va_arg(va, int);
3011 va_arg(va, char *);
3012 va_arg(va, double);
3013 return 0;
3014}
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003015], [return foo(10, "", 3.14);], [
3016 AC_DEFINE(HAVE_STDARG_PROTOTYPES, 1,
3017 [Define if your compiler supports variable length function prototypes
3018 (e.g. void fprintf(FILE *, char *, ...);) *and* <stdarg.h>])
3019 works=yes
3020])
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003021AC_MSG_RESULT($works)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003022
Dave Cole331708b2004-08-09 04:51:41 +00003023# check for socketpair
3024AC_MSG_CHECKING(for socketpair)
3025AC_TRY_COMPILE([
3026#include <sys/types.h>
3027#include <sys/socket.h>
3028], void *x=socketpair,
3029 AC_DEFINE(HAVE_SOCKETPAIR, 1, Define if you have the 'socketpair' function.)
3030 AC_MSG_RESULT(yes),
3031 AC_MSG_RESULT(no)
3032)
3033
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003034# check if sockaddr has sa_len member
3035AC_MSG_CHECKING(if sockaddr has sa_len member)
3036AC_TRY_COMPILE([#include <sys/types.h>
3037#include <sys/socket.h>],
3038[struct sockaddr x;
3039x.sa_len = 0;],
3040 AC_MSG_RESULT(yes)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003041 AC_DEFINE(HAVE_SOCKADDR_SA_LEN, 1, [Define if sockaddr has sa_len member]),
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003042 AC_MSG_RESULT(no))
3043
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003044va_list_is_array=no
3045AC_MSG_CHECKING(whether va_list is an array)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003046AC_TRY_COMPILE([
3047#ifdef HAVE_STDARG_PROTOTYPES
3048#include <stdarg.h>
3049#else
3050#include <varargs.h>
3051#endif
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003052], [va_list list1, list2; list1 = list2;], , [
3053 AC_DEFINE(VA_LIST_IS_ARRAY, 1, [Define if a va_list is an array of some kind])
3054 va_list_is_array=yes
3055])
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003056AC_MSG_RESULT($va_list_is_array)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003057
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003058# sigh -- gethostbyname_r is a mess; it can have 3, 5 or 6 arguments :-(
Martin v. Löwis11437992002-04-12 09:54:03 +00003059AH_TEMPLATE(HAVE_GETHOSTBYNAME_R,
3060 [Define this if you have some version of gethostbyname_r()])
3061
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003062AC_CHECK_FUNC(gethostbyname_r, [
3063 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
3064 AC_MSG_CHECKING([gethostbyname_r with 6 args])
3065 OLD_CFLAGS=$CFLAGS
3066 CFLAGS="$CFLAGS $MY_CPPFLAGS $MY_THREAD_CPPFLAGS $MY_CFLAGS"
3067 AC_TRY_COMPILE([
3068# include <netdb.h>
3069 ], [
3070 char *name;
3071 struct hostent *he, *res;
3072 char buffer[2048];
3073 int buflen = 2048;
3074 int h_errnop;
3075
3076 (void) gethostbyname_r(name, he, buffer, buflen, &res, &h_errnop)
3077 ], [
Guido van Rossum8db7d8b1999-03-23 16:40:33 +00003078 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003079 AC_DEFINE(HAVE_GETHOSTBYNAME_R_6_ARG, 1,
3080 [Define this if you have the 6-arg version of gethostbyname_r().])
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003081 AC_MSG_RESULT(yes)
3082 ], [
3083 AC_MSG_RESULT(no)
3084 AC_MSG_CHECKING([gethostbyname_r with 5 args])
3085 AC_TRY_COMPILE([
3086# include <netdb.h>
3087 ], [
3088 char *name;
3089 struct hostent *he;
3090 char buffer[2048];
3091 int buflen = 2048;
3092 int h_errnop;
3093
3094 (void) gethostbyname_r(name, he, buffer, buflen, &h_errnop)
3095 ], [
Guido van Rossum8db7d8b1999-03-23 16:40:33 +00003096 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003097 AC_DEFINE(HAVE_GETHOSTBYNAME_R_5_ARG, 1,
3098 [Define this if you have the 5-arg version of gethostbyname_r().])
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003099 AC_MSG_RESULT(yes)
3100 ], [
3101 AC_MSG_RESULT(no)
3102 AC_MSG_CHECKING([gethostbyname_r with 3 args])
3103 AC_TRY_COMPILE([
3104# include <netdb.h>
3105 ], [
3106 char *name;
3107 struct hostent *he;
3108 struct hostent_data data;
3109
3110 (void) gethostbyname_r(name, he, &data);
3111 ], [
Guido van Rossum8db7d8b1999-03-23 16:40:33 +00003112 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003113 AC_DEFINE(HAVE_GETHOSTBYNAME_R_3_ARG, 1,
3114 [Define this if you have the 3-arg version of gethostbyname_r().])
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003115 AC_MSG_RESULT(yes)
3116 ], [
3117 AC_MSG_RESULT(no)
3118 ])
3119 ])
3120 ])
3121 CFLAGS=$OLD_CFLAGS
3122], [
Thomas Wouters3a584202000-08-05 23:28:51 +00003123 AC_CHECK_FUNCS(gethostbyname)
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003124])
3125AC_SUBST(HAVE_GETHOSTBYNAME_R_6_ARG)
3126AC_SUBST(HAVE_GETHOSTBYNAME_R_5_ARG)
3127AC_SUBST(HAVE_GETHOSTBYNAME_R_3_ARG)
Guido van Rossum8db7d8b1999-03-23 16:40:33 +00003128AC_SUBST(HAVE_GETHOSTBYNAME_R)
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003129AC_SUBST(HAVE_GETHOSTBYNAME)
3130
Guido van Rossum627b2d71993-12-24 10:39:16 +00003131# checks for system services
3132# (none yet)
3133
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003134# Linux requires this for correct f.p. operations
Jeremy Hyltonbe28f5b2000-07-27 21:03:04 +00003135AC_CHECK_FUNC(__fpu_control,
3136 [],
3137 [AC_CHECK_LIB(ieee, __fpu_control)
3138])
Guido van Rossum627b2d71993-12-24 10:39:16 +00003139
Guido van Rossum93274221997-05-09 02:42:00 +00003140# Check for --with-fpectl
Guido van Rossum93274221997-05-09 02:42:00 +00003141AC_MSG_CHECKING(for --with-fpectl)
Barry Warsawc0d24d82000-06-29 16:12:00 +00003142AC_ARG_WITH(fpectl,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003143 AC_HELP_STRING(--with-fpectl, enable SIGFPE catching),
3144[
Guido van Rossum93274221997-05-09 02:42:00 +00003145if test "$withval" != no
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003146then
3147 AC_DEFINE(WANT_SIGFPE_HANDLER, 1,
3148 [Define if you want SIGFPE handled (see Include/pyfpe.h).])
3149 AC_MSG_RESULT(yes)
Guido van Rossum93274221997-05-09 02:42:00 +00003150else AC_MSG_RESULT(no)
Guido van Rossumef2255b2000-03-10 22:30:29 +00003151fi],
3152[AC_MSG_RESULT(no)])
Guido van Rossum93274221997-05-09 02:42:00 +00003153
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003154# check for --with-libm=...
3155AC_SUBST(LIBM)
Guido van Rossum4b6b5791996-09-09 20:09:34 +00003156case $ac_sys_system in
Guido van Rossum3dc0a512000-10-05 18:00:06 +00003157Darwin) ;;
Guido van Rossum4b6b5791996-09-09 20:09:34 +00003158*) LIBM=-lm
3159esac
Guido van Rossum93274221997-05-09 02:42:00 +00003160AC_MSG_CHECKING(for --with-libm=STRING)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003161AC_ARG_WITH(libm,
3162 AC_HELP_STRING(--with-libm=STRING, math library),
3163[
Guido van Rossum93274221997-05-09 02:42:00 +00003164if test "$withval" = no
3165then LIBM=
3166 AC_MSG_RESULT(force LIBM empty)
3167elif test "$withval" != yes
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003168then LIBM=$withval
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003169 AC_MSG_RESULT(set LIBM="$withval")
3170else AC_MSG_ERROR([proper usage is --with-libm=STRING])
Guido van Rossum93274221997-05-09 02:42:00 +00003171fi],
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003172[AC_MSG_RESULT(default LIBM="$LIBM")])
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003173
3174# check for --with-libc=...
3175AC_SUBST(LIBC)
Guido van Rossum93274221997-05-09 02:42:00 +00003176AC_MSG_CHECKING(for --with-libc=STRING)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003177AC_ARG_WITH(libc,
3178 AC_HELP_STRING(--with-libc=STRING, C library),
3179[
Guido van Rossum93274221997-05-09 02:42:00 +00003180if test "$withval" = no
3181then LIBC=
3182 AC_MSG_RESULT(force LIBC empty)
3183elif test "$withval" != yes
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003184then LIBC=$withval
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003185 AC_MSG_RESULT(set LIBC="$withval")
3186else AC_MSG_ERROR([proper usage is --with-libc=STRING])
Guido van Rossum93274221997-05-09 02:42:00 +00003187fi],
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003188[AC_MSG_RESULT(default LIBC="$LIBC")])
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003189
Mark Dickinsonb08a53a2009-04-16 19:52:09 +00003190# **************************************************
3191# * Check for various properties of floating point *
3192# **************************************************
Christian Heimes81ee3ef2008-05-04 22:42:01 +00003193
Mark Dickinsonb08a53a2009-04-16 19:52:09 +00003194AC_MSG_CHECKING(whether C doubles are little-endian IEEE 754 binary64)
3195AC_CACHE_VAL(ac_cv_little_endian_double, [
3196AC_TRY_RUN([
3197#include <string.h>
3198int main() {
3199 double x = 9006104071832581.0;
3200 if (memcmp(&x, "\x05\x04\x03\x02\x01\xff\x3f\x43", 8) == 0)
3201 return 0;
3202 else
3203 return 1;
3204}
3205],
3206ac_cv_little_endian_double=yes,
3207ac_cv_little_endian_double=no,
3208ac_cv_little_endian_double=no)])
3209AC_MSG_RESULT($ac_cv_little_endian_double)
3210if test "$ac_cv_little_endian_double" = yes
3211then
3212 AC_DEFINE(DOUBLE_IS_LITTLE_ENDIAN_IEEE754, 1,
3213 [Define if C doubles are 64-bit IEEE 754 binary format, stored
3214 with the least significant byte first])
3215fi
3216
3217AC_MSG_CHECKING(whether C doubles are big-endian IEEE 754 binary64)
3218AC_CACHE_VAL(ac_cv_big_endian_double, [
3219AC_TRY_RUN([
3220#include <string.h>
3221int main() {
3222 double x = 9006104071832581.0;
3223 if (memcmp(&x, "\x43\x3f\xff\x01\x02\x03\x04\x05", 8) == 0)
3224 return 0;
3225 else
3226 return 1;
3227}
3228],
3229ac_cv_big_endian_double=yes,
3230ac_cv_big_endian_double=no,
3231ac_cv_big_endian_double=no)])
3232AC_MSG_RESULT($ac_cv_big_endian_double)
3233if test "$ac_cv_big_endian_double" = yes
3234then
3235 AC_DEFINE(DOUBLE_IS_BIG_ENDIAN_IEEE754, 1,
3236 [Define if C doubles are 64-bit IEEE 754 binary format, stored
3237 with the most significant byte first])
3238fi
3239
3240# Some ARM platforms use a mixed-endian representation for doubles.
3241# While Python doesn't currently have full support for these platforms
3242# (see e.g., issue 1762561), we can at least make sure that float <-> string
3243# conversions work.
3244AC_MSG_CHECKING(whether C doubles are ARM mixed-endian IEEE 754 binary64)
3245AC_CACHE_VAL(ac_cv_mixed_endian_double, [
3246AC_TRY_RUN([
3247#include <string.h>
3248int main() {
3249 double x = 9006104071832581.0;
3250 if (memcmp(&x, "\x01\xff\x3f\x43\x05\x04\x03\x02", 8) == 0)
3251 return 0;
3252 else
3253 return 1;
3254}
3255],
3256ac_cv_mixed_endian_double=yes,
3257ac_cv_mixed_endian_double=no,
3258ac_cv_mixed_endian_double=no)])
3259AC_MSG_RESULT($ac_cv_mixed_endian_double)
3260if test "$ac_cv_mixed_endian_double" = yes
3261then
3262 AC_DEFINE(DOUBLE_IS_ARM_MIXED_ENDIAN_IEEE754, 1,
3263 [Define if C doubles are 64-bit IEEE 754 binary format, stored
3264 in ARM mixed-endian order (byte order 45670123)])
3265fi
3266
Mark Dickinson7abf8d42009-04-18 20:17:52 +00003267# The short float repr introduced in Python 3.1 requires the
3268# correctly-rounded string <-> double conversion functions from
3269# Python/dtoa.c, which in turn require that the FPU uses 53-bit
3270# rounding; this is a problem on x86, where the x87 FPU has a default
Mark Dickinsonf4243f62009-11-15 13:47:27 +00003271# rounding precision of 64 bits. For gcc/x86, we can fix this by
Mark Dickinson7abf8d42009-04-18 20:17:52 +00003272# using inline assembler to get and set the x87 FPU control word.
Mark Dickinsonf4243f62009-11-15 13:47:27 +00003273
3274# This inline assembler syntax may also work for suncc and icc,
3275# so we try it on all platforms.
3276
3277AC_MSG_CHECKING(whether we can use gcc inline assembler to get and set x87 control word)
3278AC_TRY_COMPILE([], [
3279 unsigned short cw;
3280 __asm__ __volatile__ ("fnstcw %0" : "=m" (cw));
3281 __asm__ __volatile__ ("fldcw %0" : : "m" (cw));
3282],
3283[have_gcc_asm_for_x87=yes], [have_gcc_asm_for_x87=no])
3284AC_MSG_RESULT($have_gcc_asm_for_x87)
3285if test "$have_gcc_asm_for_x87" = yes
Mark Dickinsonb08a53a2009-04-16 19:52:09 +00003286then
Mark Dickinsonf4243f62009-11-15 13:47:27 +00003287 AC_DEFINE(HAVE_GCC_ASM_FOR_X87, 1,
3288 [Define if we can use gcc inline assembler to get and set x87 control word])
Mark Dickinsonb08a53a2009-04-16 19:52:09 +00003289fi
Christian Heimes81ee3ef2008-05-04 22:42:01 +00003290
Mark Dickinson3dc7c6a2009-01-04 15:09:02 +00003291# Detect whether system arithmetic is subject to x87-style double
3292# rounding issues. The result of this test has little meaning on non
3293# IEEE 754 platforms. On IEEE 754, test should return 1 if rounding
3294# mode is round-to-nearest and double rounding issues are present, and
3295# 0 otherwise. See http://bugs.python.org/issue2937 for more info.
3296AC_MSG_CHECKING(for x87-style double rounding)
Mark Dickinsonb08a53a2009-04-16 19:52:09 +00003297# $BASECFLAGS may affect the result
3298ac_save_cc="$CC"
3299CC="$CC $BASECFLAGS"
Mark Dickinson3dc7c6a2009-01-04 15:09:02 +00003300AC_TRY_RUN([
3301#include <stdlib.h>
3302#include <math.h>
3303int main() {
3304 volatile double x, y, z;
3305 /* 1./(1-2**-53) -> 1+2**-52 (correct), 1.0 (double rounding) */
3306 x = 0.99999999999999989; /* 1-2**-53 */
3307 y = 1./x;
3308 if (y != 1.)
3309 exit(0);
3310 /* 1e16+2.99999 -> 1e16+2. (correct), 1e16+4. (double rounding) */
3311 x = 1e16;
3312 y = 2.99999;
3313 z = x + y;
3314 if (z != 1e16+4.)
3315 exit(0);
3316 /* both tests show evidence of double rounding */
3317 exit(1);
3318}
3319],
3320ac_cv_x87_double_rounding=no,
3321ac_cv_x87_double_rounding=yes,
Mark Dickinsonb08a53a2009-04-16 19:52:09 +00003322ac_cv_x87_double_rounding=no)
3323CC="$ac_save_cc"
Mark Dickinson3dc7c6a2009-01-04 15:09:02 +00003324AC_MSG_RESULT($ac_cv_x87_double_rounding)
3325if test "$ac_cv_x87_double_rounding" = yes
3326then
3327 AC_DEFINE(X87_DOUBLE_ROUNDING, 1,
3328 [Define if arithmetic is subject to x87-style double rounding issue])
3329fi
3330
Mark Dickinsonb08a53a2009-04-16 19:52:09 +00003331# ************************************
3332# * Check for mathematical functions *
3333# ************************************
3334
3335LIBS_SAVE=$LIBS
3336LIBS="$LIBS $LIBM"
3337
Christian Heimes81ee3ef2008-05-04 22:42:01 +00003338# On FreeBSD 6.2, it appears that tanh(-0.) returns 0. instead of
3339# -0. on some architectures.
3340AC_MSG_CHECKING(whether tanh preserves the sign of zero)
3341AC_CACHE_VAL(ac_cv_tanh_preserves_zero_sign, [
3342AC_TRY_RUN([
3343#include <math.h>
3344#include <stdlib.h>
3345int main() {
3346 /* return 0 if either negative zeros don't exist
3347 on this platform or if negative zeros exist
3348 and tanh(-0.) == -0. */
3349 if (atan2(0., -1.) == atan2(-0., -1.) ||
3350 atan2(tanh(-0.), -1.) == atan2(-0., -1.)) exit(0);
3351 else exit(1);
3352}
3353],
3354ac_cv_tanh_preserves_zero_sign=yes,
3355ac_cv_tanh_preserves_zero_sign=no,
3356ac_cv_tanh_preserves_zero_sign=no)])
3357AC_MSG_RESULT($ac_cv_tanh_preserves_zero_sign)
3358if test "$ac_cv_tanh_preserves_zero_sign" = yes
3359then
3360 AC_DEFINE(TANH_PRESERVES_ZERO_SIGN, 1,
3361 [Define if tanh(-0.) is -0., or if platform doesn't have signed zeros])
3362fi
3363
Mark Dickinson9c113362009-09-05 10:36:23 +00003364AC_CHECK_FUNCS([acosh asinh atanh copysign erf erfc expm1 finite gamma])
3365AC_CHECK_FUNCS([hypot lgamma log1p round tgamma])
Mark Dickinson3dc7c6a2009-01-04 15:09:02 +00003366AC_CHECK_DECLS([isinf, isnan, isfinite], [], [], [[#include <math.h>]])
Christian Heimes99170a52007-12-19 02:07:34 +00003367
Guido van Rossumaf5b83e1995-01-04 19:02:35 +00003368LIBS=$LIBS_SAVE
3369
Mark Dickinsona614f042009-11-28 12:48:43 +00003370# For multiprocessing module, check that sem_open
3371# actually works. For FreeBSD versions <= 7.2,
3372# the kernel module that provides POSIX semaphores
3373# isn't loaded by default, so an attempt to call
3374# sem_open results in a 'Signal 12' error.
3375AC_MSG_CHECKING(whether POSIX semaphores are enabled)
3376AC_CACHE_VAL(ac_cv_posix_semaphores_enabled,
3377AC_TRY_RUN([
3378#include <unistd.h>
3379#include <fcntl.h>
3380#include <stdio.h>
3381#include <semaphore.h>
3382#include <sys/stat.h>
3383
3384int main(void) {
3385 sem_t *a = sem_open("/autoconf", O_CREAT, S_IRUSR|S_IWUSR, 0);
3386 if (a == SEM_FAILED) {
3387 perror("sem_open");
3388 return 1;
3389 }
3390 sem_close(a);
Mark Dickinsonba79b352009-12-13 21:10:57 +00003391 sem_unlink("/autoconf");
Mark Dickinsona614f042009-11-28 12:48:43 +00003392 return 0;
3393}
3394], ac_cv_posix_semaphores_enabled=yes,
3395 ac_cv_posix_semaphores_enabled=no,
3396 ac_cv_posix_semaphores_enabled=yes)
3397)
3398AC_MSG_RESULT($ac_cv_posix_semaphores_enabled)
3399if test $ac_cv_posix_semaphores_enabled = no
3400then
3401 AC_DEFINE(POSIX_SEMAPHORES_NOT_ENABLED, 1,
3402 [Define if POSIX semaphores aren't enabled on your system])
3403fi
3404
Mark Dickinson10683072009-04-18 21:18:19 +00003405# Multiprocessing check for broken sem_getvalue
3406AC_MSG_CHECKING(for broken sem_getvalue)
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00003407AC_CACHE_VAL(ac_cv_broken_sem_getvalue,
Mark Dickinson10683072009-04-18 21:18:19 +00003408AC_TRY_RUN([
3409#include <unistd.h>
3410#include <fcntl.h>
3411#include <stdio.h>
3412#include <semaphore.h>
3413#include <sys/stat.h>
3414
3415int main(void){
Mark Dickinsonba79b352009-12-13 21:10:57 +00003416 sem_t *a = sem_open("/autocftw", O_CREAT, S_IRUSR|S_IWUSR, 0);
Mark Dickinson10683072009-04-18 21:18:19 +00003417 int count;
3418 int res;
3419 if(a==SEM_FAILED){
3420 perror("sem_open");
3421 return 1;
3422
3423 }
3424 res = sem_getvalue(a, &count);
3425 sem_close(a);
Mark Dickinsonba79b352009-12-13 21:10:57 +00003426 sem_unlink("/autocftw");
Mark Dickinson10683072009-04-18 21:18:19 +00003427 return res==-1 ? 1 : 0;
3428}
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00003429], ac_cv_broken_sem_getvalue=no,
3430 ac_cv_broken_sem_getvalue=yes,
3431 ac_cv_broken_sem_getvalue=yes)
Mark Dickinson10683072009-04-18 21:18:19 +00003432)
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00003433AC_MSG_RESULT($ac_cv_broken_sem_getvalue)
3434if test $ac_cv_broken_sem_getvalue = yes
3435then
3436 AC_DEFINE(HAVE_BROKEN_SEM_GETVALUE, 1,
3437 [define to 1 if your sem_getvalue is broken.])
3438fi
Mark Dickinson10683072009-04-18 21:18:19 +00003439
Mark Dickinsonbd792642009-03-18 20:06:12 +00003440# determine what size digit to use for Python's longs
3441AC_MSG_CHECKING([digit size for Python's longs])
3442AC_ARG_ENABLE(big-digits,
3443AC_HELP_STRING([--enable-big-digits@<:@=BITS@:>@],[use big digits for Python longs [[BITS=30]]]),
3444[case $enable_big_digits in
3445yes)
3446 enable_big_digits=30 ;;
3447no)
3448 enable_big_digits=15 ;;
3449[15|30])
3450 ;;
3451*)
3452 AC_MSG_ERROR([bad value $enable_big_digits for --enable-big-digits; value should be 15 or 30]) ;;
3453esac
3454AC_MSG_RESULT($enable_big_digits)
3455AC_DEFINE_UNQUOTED(PYLONG_BITS_IN_DIGIT, $enable_big_digits, [Define as the preferred size in bits of long digits])
3456],
3457[AC_MSG_RESULT(no value specified)])
3458
Guido van Rossumef2255b2000-03-10 22:30:29 +00003459# check for wchar.h
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003460AC_CHECK_HEADER(wchar.h, [
3461 AC_DEFINE(HAVE_WCHAR_H, 1,
3462 [Define if the compiler provides a wchar.h header file.])
3463 wchar_h="yes"
3464],
Guido van Rossumef2255b2000-03-10 22:30:29 +00003465wchar_h="no"
3466)
3467
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003468# determine wchar_t size
3469if test "$wchar_h" = yes
3470then
Guido van Rossum67b26592001-10-20 14:21:45 +00003471 AC_CHECK_SIZEOF(wchar_t, 4, [#include <wchar.h>])
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003472fi
3473
Martin v. Löwisfa3bdea2003-09-04 18:50:54 +00003474AC_MSG_CHECKING(for UCS-4 tcl)
3475have_ucs4_tcl=no
3476AC_TRY_COMPILE([
3477#include <tcl.h>
3478#if TCL_UTF_MAX != 6
3479# error "NOT UCS4_TCL"
3480#endif], [], [
3481 AC_DEFINE(HAVE_UCS4_TCL, 1, [Define this if you have tcl and TCL_UTF_MAX==6])
3482 have_ucs4_tcl=yes
3483])
3484AC_MSG_RESULT($have_ucs4_tcl)
3485
Marc-André Lemburgd7160f82003-09-22 11:14:40 +00003486# check whether wchar_t is signed or not
3487if test "$wchar_h" = yes
3488then
3489 # check whether wchar_t is signed or not
3490 AC_MSG_CHECKING(whether wchar_t is signed)
3491 AC_CACHE_VAL(ac_cv_wchar_t_signed, [
3492 AC_TRY_RUN([
3493 #include <wchar.h>
3494 int main()
3495 {
Thomas Wouters49fd7fa2006-04-21 10:40:58 +00003496 /* Success: exit code 0 */
3497 exit((((wchar_t) -1) < ((wchar_t) 0)) ? 0 : 1);
Marc-André Lemburgd7160f82003-09-22 11:14:40 +00003498 }
3499 ],
3500 ac_cv_wchar_t_signed=yes,
3501 ac_cv_wchar_t_signed=no,
3502 ac_cv_wchar_t_signed=yes)])
3503 AC_MSG_RESULT($ac_cv_wchar_t_signed)
3504fi
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003505
Georg Brandl52d168a2008-01-07 18:10:24 +00003506AC_MSG_CHECKING(what type to use for str)
3507AC_ARG_WITH(wide-unicode,
3508 AC_HELP_STRING(--with-wide-unicode, Use 4-byte Unicode characters (default is 2 bytes)),
3509[
3510if test "$withval" != no
3511then unicode_size="4"
3512else unicode_size="2"
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003513fi
Georg Brandl52d168a2008-01-07 18:10:24 +00003514],
3515[
3516case "$have_ucs4_tcl" in
3517 yes) unicode_size="4" ;;
3518 *) unicode_size="2" ;;
3519esac
3520])
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003521
Martin v. Löwis0036cba2002-04-12 09:58:45 +00003522AH_TEMPLATE(Py_UNICODE_SIZE,
3523 [Define as the size of the unicode type.])
Georg Brandl52d168a2008-01-07 18:10:24 +00003524case "$unicode_size" in
3525 4) AC_DEFINE(Py_UNICODE_SIZE, 4) ;;
3526 *) AC_DEFINE(Py_UNICODE_SIZE, 2) ;;
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003527esac
3528
Martin v. Löwis11437992002-04-12 09:54:03 +00003529AH_TEMPLATE(PY_UNICODE_TYPE,
3530 [Define as the integral type used for Unicode representation.])
Martin v. Löwis0036cba2002-04-12 09:58:45 +00003531
Georg Brandl52d168a2008-01-07 18:10:24 +00003532# wchar_t is only usable if it maps to an unsigned type
3533if test "$unicode_size" = "$ac_cv_sizeof_wchar_t" \
Matthias Klose7dbeed72004-12-24 08:22:17 +00003534 -a "$ac_cv_wchar_t_signed" = "no"
Georg Brandl52d168a2008-01-07 18:10:24 +00003535then
3536 PY_UNICODE_TYPE="wchar_t"
3537 AC_DEFINE(HAVE_USABLE_WCHAR_T, 1,
3538 [Define if you have a useable wchar_t type defined in wchar.h; useable
3539 means wchar_t must be an unsigned type with at least 16 bits. (see
3540 Include/unicodeobject.h).])
3541 AC_DEFINE(PY_UNICODE_TYPE,wchar_t)
3542elif test "$ac_cv_sizeof_short" = "$unicode_size"
3543then
3544 PY_UNICODE_TYPE="unsigned short"
3545 AC_DEFINE(PY_UNICODE_TYPE,unsigned short)
3546elif test "$ac_cv_sizeof_long" = "$unicode_size"
3547then
3548 PY_UNICODE_TYPE="unsigned long"
3549 AC_DEFINE(PY_UNICODE_TYPE,unsigned long)
3550else
3551 PY_UNICODE_TYPE="no type found"
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003552fi
Georg Brandl52d168a2008-01-07 18:10:24 +00003553AC_MSG_RESULT($PY_UNICODE_TYPE)
Guido van Rossumef2255b2000-03-10 22:30:29 +00003554
3555# check for endianness
3556AC_C_BIGENDIAN
3557
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00003558# Check whether right shifting a negative integer extends the sign bit
3559# or fills with zeros (like the Cray J90, according to Tim Peters).
3560AC_MSG_CHECKING(whether right shift extends the sign bit)
Vladimir Marangozova6180282000-07-12 05:05:06 +00003561AC_CACHE_VAL(ac_cv_rshift_extends_sign, [
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00003562AC_TRY_RUN([
3563int main()
3564{
Vladimir Marangozova6180282000-07-12 05:05:06 +00003565 exit(((-1)>>3 == -1) ? 0 : 1);
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00003566}
Guido van Rossum3065c942001-09-17 04:03:14 +00003567],
3568ac_cv_rshift_extends_sign=yes,
3569ac_cv_rshift_extends_sign=no,
3570ac_cv_rshift_extends_sign=yes)])
Vladimir Marangozova6180282000-07-12 05:05:06 +00003571AC_MSG_RESULT($ac_cv_rshift_extends_sign)
3572if test "$ac_cv_rshift_extends_sign" = no
3573then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003574 AC_DEFINE(SIGNED_RIGHT_SHIFT_ZERO_FILLS, 1,
3575 [Define if i>>j for signed int i does not extend the sign bit
3576 when i < 0])
Vladimir Marangozova6180282000-07-12 05:05:06 +00003577fi
3578
Guido van Rossumcadfaec2001-01-05 14:45:49 +00003579# check for getc_unlocked and related locking functions
3580AC_MSG_CHECKING(for getc_unlocked() and friends)
3581AC_CACHE_VAL(ac_cv_have_getc_unlocked, [
3582AC_TRY_LINK([#include <stdio.h>],[
3583 FILE *f = fopen("/dev/null", "r");
3584 flockfile(f);
3585 getc_unlocked(f);
3586 funlockfile(f);
3587], ac_cv_have_getc_unlocked=yes, ac_cv_have_getc_unlocked=no)])
3588AC_MSG_RESULT($ac_cv_have_getc_unlocked)
3589if test "$ac_cv_have_getc_unlocked" = yes
3590then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003591 AC_DEFINE(HAVE_GETC_UNLOCKED, 1,
3592 [Define this if you have flockfile(), getc_unlocked(), and funlockfile()])
Guido van Rossumcadfaec2001-01-05 14:45:49 +00003593fi
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00003594
Neal Norwitzfe8e3d92006-01-07 21:07:20 +00003595# check where readline lives
Martin v. Löwis82bca632006-02-10 20:49:30 +00003596# save the value of LIBS so we don't actually link Python with readline
3597LIBS_no_readline=$LIBS
Gregory P. Smith18820942008-09-07 06:24:49 +00003598
3599# On some systems we need to link readline to a termcap compatible
3600# library. NOTE: Keep the precedence of listed libraries synchronised
3601# with setup.py.
3602py_cv_lib_readline=no
3603AC_MSG_CHECKING([how to link readline libs])
3604for py_libtermcap in "" ncursesw ncurses curses termcap; do
3605 if test -z "$py_libtermcap"; then
3606 READLINE_LIBS="-lreadline"
3607 else
3608 READLINE_LIBS="-lreadline -l$py_libtermcap"
3609 fi
3610 LIBS="$READLINE_LIBS $LIBS_no_readline"
3611 AC_LINK_IFELSE(
3612 [AC_LANG_CALL([],[readline])],
3613 [py_cv_lib_readline=yes])
3614 if test $py_cv_lib_readline = yes; then
3615 break
3616 fi
3617done
3618# Uncomment this line if you want to use READINE_LIBS in Makefile or scripts
3619#AC_SUBST([READLINE_LIBS])
Gregory P. Smith97515912008-09-07 19:23:19 +00003620if test $py_cv_lib_readline = no; then
Gregory P. Smith18820942008-09-07 06:24:49 +00003621 AC_MSG_RESULT([none])
3622else
3623 AC_MSG_RESULT([$READLINE_LIBS])
3624 AC_DEFINE(HAVE_LIBREADLINE, 1,
3625 [Define if you have the readline library (-lreadline).])
Neal Norwitzfe8e3d92006-01-07 21:07:20 +00003626fi
3627
Michael W. Hudson30ea2f22004-07-07 17:44:12 +00003628# check for readline 2.1
3629AC_CHECK_LIB(readline, rl_callback_handler_install,
3630 AC_DEFINE(HAVE_RL_CALLBACK, 1,
Gregory P. Smith18820942008-09-07 06:24:49 +00003631 [Define if you have readline 2.1]), ,$READLINE_LIBS)
Michael W. Hudson30ea2f22004-07-07 17:44:12 +00003632
Guido van Rossumfaf5e4d2002-12-30 16:25:41 +00003633# check for readline 2.2
3634AC_TRY_CPP([#include <readline/readline.h>],
3635have_readline=yes, have_readline=no)
3636if test $have_readline = yes
3637then
3638 AC_EGREP_HEADER([extern int rl_completion_append_character;],
3639 [readline/readline.h],
3640 AC_DEFINE(HAVE_RL_COMPLETION_APPEND_CHARACTER, 1,
3641 [Define if you have readline 2.2]), )
Antoine Pitroud5131772009-10-26 19:22:14 +00003642 AC_EGREP_HEADER([extern int rl_completion_suppress_append;],
3643 [readline/readline.h],
3644 AC_DEFINE(HAVE_RL_COMPLETION_SUPPRESS_APPEND, 1,
3645 [Define if you have rl_completion_suppress_append]), )
Guido van Rossumfaf5e4d2002-12-30 16:25:41 +00003646fi
3647
Martin v. Löwis0daad592001-09-30 21:09:59 +00003648# check for readline 4.0
3649AC_CHECK_LIB(readline, rl_pre_input_hook,
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003650 AC_DEFINE(HAVE_RL_PRE_INPUT_HOOK, 1,
Gregory P. Smith18820942008-09-07 06:24:49 +00003651 [Define if you have readline 4.0]), ,$READLINE_LIBS)
Martin v. Löwis0daad592001-09-30 21:09:59 +00003652
Thomas Wouters89d996e2007-09-08 17:39:28 +00003653# also in 4.0
3654AC_CHECK_LIB(readline, rl_completion_display_matches_hook,
3655 AC_DEFINE(HAVE_RL_COMPLETION_DISPLAY_MATCHES_HOOK, 1,
Gregory P. Smith18820942008-09-07 06:24:49 +00003656 [Define if you have readline 4.0]), ,$READLINE_LIBS)
Thomas Wouters89d996e2007-09-08 17:39:28 +00003657
Guido van Rossum353ae582001-07-10 16:45:32 +00003658# check for readline 4.2
3659AC_CHECK_LIB(readline, rl_completion_matches,
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003660 AC_DEFINE(HAVE_RL_COMPLETION_MATCHES, 1,
Gregory P. Smith18820942008-09-07 06:24:49 +00003661 [Define if you have readline 4.2]), ,$READLINE_LIBS)
Guido van Rossum353ae582001-07-10 16:45:32 +00003662
Michael W. Hudson30ea2f22004-07-07 17:44:12 +00003663# also in readline 4.2
3664AC_TRY_CPP([#include <readline/readline.h>],
3665have_readline=yes, have_readline=no)
3666if test $have_readline = yes
3667then
3668 AC_EGREP_HEADER([extern int rl_catch_signals;],
3669 [readline/readline.h],
3670 AC_DEFINE(HAVE_RL_CATCH_SIGNAL, 1,
3671 [Define if you can turn off readline's signal handling.]), )
3672fi
3673
Martin v. Löwis82bca632006-02-10 20:49:30 +00003674# End of readline checks: restore LIBS
3675LIBS=$LIBS_no_readline
3676
Thomas Wouterse38b2f12001-07-11 22:35:31 +00003677AC_MSG_CHECKING(for broken nice())
3678AC_CACHE_VAL(ac_cv_broken_nice, [
3679AC_TRY_RUN([
3680int main()
3681{
3682 int val1 = nice(1);
3683 if (val1 != -1 && val1 == nice(2))
3684 exit(0);
3685 exit(1);
3686}
Guido van Rossum3065c942001-09-17 04:03:14 +00003687],
3688ac_cv_broken_nice=yes,
3689ac_cv_broken_nice=no,
3690ac_cv_broken_nice=no)])
Thomas Wouterse38b2f12001-07-11 22:35:31 +00003691AC_MSG_RESULT($ac_cv_broken_nice)
3692if test "$ac_cv_broken_nice" = yes
3693then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003694 AC_DEFINE(HAVE_BROKEN_NICE, 1,
3695 [Define if nice() returns success/failure instead of the new priority.])
Thomas Wouterse38b2f12001-07-11 22:35:31 +00003696fi
3697
Nicholas Bastine62c5c82004-03-21 23:45:42 +00003698AC_MSG_CHECKING(for broken poll())
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00003699AC_CACHE_VAL(ac_cv_broken_poll,
Nicholas Bastine62c5c82004-03-21 23:45:42 +00003700AC_TRY_RUN([
3701#include <poll.h>
3702
Alexandre Vassalottiaee170a2009-07-17 06:24:33 +00003703int main()
3704{
Nicholas Bastine62c5c82004-03-21 23:45:42 +00003705 struct pollfd poll_struct = { 42, POLLIN|POLLPRI|POLLOUT, 0 };
Alexandre Vassalottiaee170a2009-07-17 06:24:33 +00003706 int poll_test;
3707
Nicholas Bastine62c5c82004-03-21 23:45:42 +00003708 close (42);
3709
Alexandre Vassalottiaee170a2009-07-17 06:24:33 +00003710 poll_test = poll(&poll_struct, 1, 0);
Nicholas Bastine62c5c82004-03-21 23:45:42 +00003711 if (poll_test < 0)
Alexandre Vassalottiaee170a2009-07-17 06:24:33 +00003712 return 0;
Nicholas Bastine62c5c82004-03-21 23:45:42 +00003713 else if (poll_test == 0 && poll_struct.revents != POLLNVAL)
Alexandre Vassalottiaee170a2009-07-17 06:24:33 +00003714 return 0;
Nicholas Bastine62c5c82004-03-21 23:45:42 +00003715 else
Alexandre Vassalottiaee170a2009-07-17 06:24:33 +00003716 return 1;
3717}
Nicholas Bastine62c5c82004-03-21 23:45:42 +00003718],
3719ac_cv_broken_poll=yes,
3720ac_cv_broken_poll=no,
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00003721ac_cv_broken_poll=no))
Nicholas Bastine62c5c82004-03-21 23:45:42 +00003722AC_MSG_RESULT($ac_cv_broken_poll)
3723if test "$ac_cv_broken_poll" = yes
3724then
3725 AC_DEFINE(HAVE_BROKEN_POLL, 1,
3726 [Define if poll() sets errno on invalid file descriptors.])
3727fi
3728
Brett Cannon43802422005-02-10 20:48:03 +00003729# Before we can test tzset, we need to check if struct tm has a tm_zone
3730# (which is not required by ISO C or UNIX spec) and/or if we support
3731# tzname[]
3732AC_STRUCT_TIMEZONE
Nicholas Bastine62c5c82004-03-21 23:45:42 +00003733
Brett Cannon43802422005-02-10 20:48:03 +00003734# check tzset(3) exists and works like we expect it to
Guido van Rossumd11b62e2003-03-14 21:51:36 +00003735AC_MSG_CHECKING(for working tzset())
3736AC_CACHE_VAL(ac_cv_working_tzset, [
3737AC_TRY_RUN([
3738#include <stdlib.h>
3739#include <time.h>
Brett Cannon18367812003-09-19 00:59:16 +00003740#include <string.h>
Brett Cannon43802422005-02-10 20:48:03 +00003741
3742#if HAVE_TZNAME
3743extern char *tzname[];
3744#endif
3745
Guido van Rossumd11b62e2003-03-14 21:51:36 +00003746int main()
3747{
Brett Cannon18367812003-09-19 00:59:16 +00003748 /* Note that we need to ensure that not only does tzset(3)
3749 do 'something' with localtime, but it works as documented
3750 in the library reference and as expected by the test suite.
Brett Cannon43802422005-02-10 20:48:03 +00003751 This includes making sure that tzname is set properly if
3752 tm->tm_zone does not exist since it is the alternative way
3753 of getting timezone info.
Brett Cannon18367812003-09-19 00:59:16 +00003754
3755 Red Hat 6.2 doesn't understand the southern hemisphere
Brett Cannon43802422005-02-10 20:48:03 +00003756 after New Year's Day.
Brett Cannon18367812003-09-19 00:59:16 +00003757 */
3758
Brett Cannon43802422005-02-10 20:48:03 +00003759 time_t groundhogday = 1044144000; /* GMT-based */
Brett Cannon18367812003-09-19 00:59:16 +00003760 time_t midyear = groundhogday + (365 * 24 * 3600 / 2);
3761
Neal Norwitz7f2588c2003-04-11 15:35:53 +00003762 putenv("TZ=UTC+0");
Guido van Rossumd11b62e2003-03-14 21:51:36 +00003763 tzset();
Brett Cannon18367812003-09-19 00:59:16 +00003764 if (localtime(&groundhogday)->tm_hour != 0)
3765 exit(1);
Brett Cannon43802422005-02-10 20:48:03 +00003766#if HAVE_TZNAME
3767 /* For UTC, tzname[1] is sometimes "", sometimes " " */
3768 if (strcmp(tzname[0], "UTC") ||
3769 (tzname[1][0] != 0 && tzname[1][0] != ' '))
3770 exit(1);
3771#endif
Brett Cannon18367812003-09-19 00:59:16 +00003772
Neal Norwitz7f2588c2003-04-11 15:35:53 +00003773 putenv("TZ=EST+5EDT,M4.1.0,M10.5.0");
Guido van Rossumd11b62e2003-03-14 21:51:36 +00003774 tzset();
Brett Cannon18367812003-09-19 00:59:16 +00003775 if (localtime(&groundhogday)->tm_hour != 19)
Guido van Rossumd11b62e2003-03-14 21:51:36 +00003776 exit(1);
Brett Cannon43802422005-02-10 20:48:03 +00003777#if HAVE_TZNAME
3778 if (strcmp(tzname[0], "EST") || strcmp(tzname[1], "EDT"))
3779 exit(1);
3780#endif
Brett Cannon18367812003-09-19 00:59:16 +00003781
3782 putenv("TZ=AEST-10AEDT-11,M10.5.0,M3.5.0");
3783 tzset();
3784 if (localtime(&groundhogday)->tm_hour != 11)
3785 exit(1);
Brett Cannon43802422005-02-10 20:48:03 +00003786#if HAVE_TZNAME
3787 if (strcmp(tzname[0], "AEST") || strcmp(tzname[1], "AEDT"))
3788 exit(1);
3789#endif
3790
3791#if HAVE_STRUCT_TM_TM_ZONE
Brett Cannon18367812003-09-19 00:59:16 +00003792 if (strcmp(localtime(&groundhogday)->tm_zone, "AEDT"))
3793 exit(1);
3794 if (strcmp(localtime(&midyear)->tm_zone, "AEST"))
3795 exit(1);
Brett Cannon43802422005-02-10 20:48:03 +00003796#endif
Brett Cannon18367812003-09-19 00:59:16 +00003797
Guido van Rossumd11b62e2003-03-14 21:51:36 +00003798 exit(0);
3799}
3800],
3801ac_cv_working_tzset=yes,
3802ac_cv_working_tzset=no,
3803ac_cv_working_tzset=no)])
3804AC_MSG_RESULT($ac_cv_working_tzset)
3805if test "$ac_cv_working_tzset" = yes
3806then
3807 AC_DEFINE(HAVE_WORKING_TZSET, 1,
3808 [Define if tzset() actually switches the local timezone in a meaningful way.])
3809fi
3810
Martin v. Löwis94717ed2002-09-09 14:24:16 +00003811# Look for subsecond timestamps in struct stat
3812AC_MSG_CHECKING(for tv_nsec in struct stat)
3813AC_CACHE_VAL(ac_cv_stat_tv_nsec,
3814AC_TRY_COMPILE([#include <sys/stat.h>], [
3815struct stat st;
3816st.st_mtim.tv_nsec = 1;
3817],
Martin v. Löwisa32c9942002-09-09 16:17:47 +00003818ac_cv_stat_tv_nsec=yes,
Martin v. Löwis94717ed2002-09-09 14:24:16 +00003819ac_cv_stat_tv_nsec=no,
3820ac_cv_stat_tv_nsec=no))
3821AC_MSG_RESULT($ac_cv_stat_tv_nsec)
3822if test "$ac_cv_stat_tv_nsec" = yes
3823then
3824 AC_DEFINE(HAVE_STAT_TV_NSEC, 1,
3825 [Define if you have struct stat.st_mtim.tv_nsec])
3826fi
3827
Martin v. Löwisebd9d5b2005-08-09 15:00:59 +00003828# Look for BSD style subsecond timestamps in struct stat
3829AC_MSG_CHECKING(for tv_nsec2 in struct stat)
3830AC_CACHE_VAL(ac_cv_stat_tv_nsec2,
3831AC_TRY_COMPILE([#include <sys/stat.h>], [
3832struct stat st;
3833st.st_mtimespec.tv_nsec = 1;
3834],
3835ac_cv_stat_tv_nsec2=yes,
3836ac_cv_stat_tv_nsec2=no,
3837ac_cv_stat_tv_nsec2=no))
3838AC_MSG_RESULT($ac_cv_stat_tv_nsec2)
3839if test "$ac_cv_stat_tv_nsec2" = yes
3840then
3841 AC_DEFINE(HAVE_STAT_TV_NSEC2, 1,
3842 [Define if you have struct stat.st_mtimensec])
3843fi
3844
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00003845# On HP/UX 11.0, mvwdelch is a block with a return statement
3846AC_MSG_CHECKING(whether mvwdelch is an expression)
3847AC_CACHE_VAL(ac_cv_mvwdelch_is_expression,
3848AC_TRY_COMPILE([#include <curses.h>], [
3849 int rtn;
3850 rtn = mvwdelch(0,0,0);
3851], ac_cv_mvwdelch_is_expression=yes,
3852 ac_cv_mvwdelch_is_expression=no,
3853 ac_cv_mvwdelch_is_expression=yes))
3854AC_MSG_RESULT($ac_cv_mvwdelch_is_expression)
3855
3856if test "$ac_cv_mvwdelch_is_expression" = yes
3857then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003858 AC_DEFINE(MVWDELCH_IS_EXPRESSION, 1,
3859 [Define if mvwdelch in curses.h is an expression.])
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00003860fi
3861
3862AC_MSG_CHECKING(whether WINDOW has _flags)
3863AC_CACHE_VAL(ac_cv_window_has_flags,
3864AC_TRY_COMPILE([#include <curses.h>], [
3865 WINDOW *w;
3866 w->_flags = 0;
3867], ac_cv_window_has_flags=yes,
3868 ac_cv_window_has_flags=no,
3869 ac_cv_window_has_flags=no))
3870AC_MSG_RESULT($ac_cv_window_has_flags)
3871
3872
3873if test "$ac_cv_window_has_flags" = yes
3874then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003875 AC_DEFINE(WINDOW_HAS_FLAGS, 1,
3876 [Define if WINDOW in curses.h offers a field _flags.])
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00003877fi
3878
Thomas Wouters0e3f5912006-08-11 14:57:12 +00003879AC_MSG_CHECKING(for is_term_resized)
3880AC_TRY_COMPILE([#include <curses.h>], void *x=is_term_resized,
3881 AC_DEFINE(HAVE_CURSES_IS_TERM_RESIZED, 1, Define if you have the 'is_term_resized' function.)
3882 AC_MSG_RESULT(yes),
Martin v. Löwis24a880b2002-12-31 12:55:15 +00003883 AC_MSG_RESULT(no)
Thomas Wouters0e3f5912006-08-11 14:57:12 +00003884)
Martin v. Löwis24a880b2002-12-31 12:55:15 +00003885
Thomas Wouters0e3f5912006-08-11 14:57:12 +00003886AC_MSG_CHECKING(for resize_term)
3887AC_TRY_COMPILE([#include <curses.h>], void *x=resize_term,
3888 AC_DEFINE(HAVE_CURSES_RESIZE_TERM, 1, Define if you have the 'resize_term' function.)
3889 AC_MSG_RESULT(yes),
Neal Norwitz865400f2003-03-21 01:42:58 +00003890 AC_MSG_RESULT(no)
Thomas Wouters0e3f5912006-08-11 14:57:12 +00003891)
3892
3893AC_MSG_CHECKING(for resizeterm)
3894AC_TRY_COMPILE([#include <curses.h>], void *x=resizeterm,
3895 AC_DEFINE(HAVE_CURSES_RESIZETERM, 1, Define if you have the 'resizeterm' function.)
3896 AC_MSG_RESULT(yes),
3897 AC_MSG_RESULT(no)
3898)
3899
Thomas Wouters89f507f2006-12-13 04:49:30 +00003900AC_MSG_CHECKING(for /dev/ptmx)
3901
3902if test -r /dev/ptmx
3903then
3904 AC_MSG_RESULT(yes)
3905 AC_DEFINE(HAVE_DEV_PTMX, 1,
3906 [Define if we have /dev/ptmx.])
3907else
3908 AC_MSG_RESULT(no)
3909fi
3910
3911AC_MSG_CHECKING(for /dev/ptc)
3912
3913if test -r /dev/ptc
3914then
3915 AC_MSG_RESULT(yes)
3916 AC_DEFINE(HAVE_DEV_PTC, 1,
3917 [Define if we have /dev/ptc.])
3918else
3919 AC_MSG_RESULT(no)
3920fi
Neal Norwitz865400f2003-03-21 01:42:58 +00003921
Mark Dickinson6ce4a9a2009-11-16 17:00:11 +00003922if test "$have_long_long" = yes
3923then
3924 AC_MSG_CHECKING(for %lld and %llu printf() format support)
3925 AC_CACHE_VAL(ac_cv_have_long_long_format,
3926 AC_TRY_RUN([[
3927 #include <stdio.h>
3928 #include <stddef.h>
3929 #include <string.h>
3930
3931 #ifdef HAVE_SYS_TYPES_H
3932 #include <sys/types.h>
3933 #endif
3934
3935 int main()
3936 {
3937 char buffer[256];
3938
3939 if (sprintf(buffer, "%lld", (long long)123) < 0)
3940 return 1;
3941 if (strcmp(buffer, "123"))
3942 return 1;
3943
3944 if (sprintf(buffer, "%lld", (long long)-123) < 0)
3945 return 1;
3946 if (strcmp(buffer, "-123"))
3947 return 1;
3948
3949 if (sprintf(buffer, "%llu", (unsigned long long)123) < 0)
3950 return 1;
3951 if (strcmp(buffer, "123"))
3952 return 1;
3953
3954 return 0;
3955 }
3956 ]], ac_cv_have_long_long_format=yes,
3957 ac_cv_have_long_long_format=no,
3958 ac_cv_have_long_long_format=no)
3959 )
3960 AC_MSG_RESULT($ac_cv_have_long_long_format)
3961fi
3962
Mark Dickinson89d7d412009-12-31 20:50:59 +00003963if test "$ac_cv_have_long_long_format" = yes
Mark Dickinson6ce4a9a2009-11-16 17:00:11 +00003964then
3965 AC_DEFINE(PY_FORMAT_LONG_LONG, "ll",
3966 [Define to printf format modifier for long long type])
3967fi
3968
Ronald Oussoren3c1928a2009-11-19 17:15:31 +00003969if test $ac_sys_system = Darwin
3970then
3971 LIBS="$LIBS -framework CoreFoundation"
3972fi
Mark Dickinson6ce4a9a2009-11-16 17:00:11 +00003973
Benjamin Peterson8f326b22009-12-13 02:10:36 +00003974AC_CACHE_CHECK([for %zd printf() format support], ac_cv_have_size_t_format, [dnl
3975AC_TRY_RUN([
Alexandre Vassalottie5091f62009-07-17 06:41:02 +00003976#include <stdio.h>
Thomas Wouters477c8d52006-05-27 19:21:47 +00003977#include <stddef.h>
3978#include <string.h>
3979
Christian Heimes2c181612007-12-17 20:04:13 +00003980#ifdef HAVE_SYS_TYPES_H
3981#include <sys/types.h>
3982#endif
Thomas Wouters89f507f2006-12-13 04:49:30 +00003983
3984#ifdef HAVE_SSIZE_T
3985typedef ssize_t Py_ssize_t;
3986#elif SIZEOF_VOID_P == SIZEOF_LONG
3987typedef long Py_ssize_t;
3988#else
3989typedef int Py_ssize_t;
3990#endif
Thomas Wouters477c8d52006-05-27 19:21:47 +00003991
Christian Heimes2c181612007-12-17 20:04:13 +00003992int main()
3993{
3994 char buffer[256];
3995
Thomas Wouters477c8d52006-05-27 19:21:47 +00003996 if(sprintf(buffer, "%zd", (size_t)123) < 0)
3997 return 1;
3998
Thomas Wouters89f507f2006-12-13 04:49:30 +00003999 if (strcmp(buffer, "123"))
Thomas Wouters477c8d52006-05-27 19:21:47 +00004000 return 1;
Thomas Wouters89f507f2006-12-13 04:49:30 +00004001
4002 if (sprintf(buffer, "%zd", (Py_ssize_t)-123) < 0)
4003 return 1;
4004
4005 if (strcmp(buffer, "-123"))
4006 return 1;
4007
Thomas Wouters477c8d52006-05-27 19:21:47 +00004008 return 0;
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00004009}
Benjamin Peterson8f326b22009-12-13 02:10:36 +00004010], ac_cv_have_size_t_format=yes,
Alexandre Vassalottie5091f62009-07-17 06:41:02 +00004011 ac_cv_have_size_t_format=no,
Benjamin Peterson8f326b22009-12-13 02:10:36 +00004012 [ac_cv_have_size_t_format="cross -- assuming yes"]
4013)])
4014if test "$ac_cv_have_size_t_format" != no ; then
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00004015 AC_DEFINE(PY_FORMAT_SIZE_T, "z",
4016 [Define to printf format modifier for Py_ssize_t])
4017fi
Thomas Wouters477c8d52006-05-27 19:21:47 +00004018
Martin v. Löwis01c04012002-11-11 14:58:44 +00004019AC_CHECK_TYPE(socklen_t,,
4020 AC_DEFINE(socklen_t,int,
4021 Define to `int' if <sys/socket.h> does not define.),[
4022#ifdef HAVE_SYS_TYPES_H
4023#include <sys/types.h>
4024#endif
Guido van Rossum95713eb2000-05-18 20:53:31 +00004025#ifdef HAVE_SYS_SOCKET_H
4026#include <sys/socket.h>
4027#endif
Martin v. Löwis01c04012002-11-11 14:58:44 +00004028])
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00004029
Antoine Pitroufff95302008-09-03 18:58:51 +00004030AC_MSG_CHECKING(for broken mbstowcs)
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00004031AC_CACHE_VAL(ac_cv_broken_mbstowcs,
Antoine Pitroufff95302008-09-03 18:58:51 +00004032AC_TRY_RUN([
4033#include<stdlib.h>
4034int main() {
4035 size_t len = -1;
4036 const char *str = "text";
4037 len = mbstowcs(NULL, str, 0);
4038 return (len != 4);
4039}
4040],
4041ac_cv_broken_mbstowcs=no,
4042ac_cv_broken_mbstowcs=yes,
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00004043ac_cv_broken_mbstowcs=no))
Antoine Pitroufff95302008-09-03 18:58:51 +00004044AC_MSG_RESULT($ac_cv_broken_mbstowcs)
4045if test "$ac_cv_broken_mbstowcs" = yes
4046then
4047 AC_DEFINE(HAVE_BROKEN_MBSTOWCS, 1,
4048 [Define if mbstowcs(NULL, "text", 0) does not return the number of
4049 wide chars that would be converted.])
4050fi
4051
Antoine Pitroub52ec782009-01-25 16:34:23 +00004052# Check for --with-computed-gotos
4053AC_MSG_CHECKING(for --with-computed-gotos)
4054AC_ARG_WITH(computed-gotos,
4055 AC_HELP_STRING(--with-computed-gotos,
4056 Use computed gotos / threaded dispatch in evaluation loop (not available on all compilers)),
4057[
4058if test "$withval" != no
4059then
4060 AC_DEFINE(USE_COMPUTED_GOTOS, 1,
4061 [Define if you want to use computed gotos in ceval.c.])
4062 AC_MSG_RESULT(yes)
4063else AC_MSG_RESULT(no)
4064fi],
4065[AC_MSG_RESULT(no)])
4066
4067
Martin v. Löwis06f15bb2001-12-02 13:02:32 +00004068AC_SUBST(THREADHEADERS)
4069
4070for h in `(cd $srcdir;echo Python/thread_*.h)`
4071do
4072 THREADHEADERS="$THREADHEADERS \$(srcdir)/$h"
4073done
4074
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00004075AC_SUBST(SRCDIRS)
Neal Norwitzd24499d2005-12-18 21:36:39 +00004076SRCDIRS="Parser Grammar Objects Python Modules Mac"
Andrew M. Kuchling8abedde2001-01-26 22:55:24 +00004077AC_MSG_CHECKING(for build directories)
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00004078for dir in $SRCDIRS; do
4079 if test ! -d $dir; then
4080 mkdir $dir
Fred Drake884d3ba2000-11-02 17:52:56 +00004081 fi
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00004082done
4083AC_MSG_RESULT(done)
Fred Drake036144d2000-10-26 17:09:35 +00004084
Guido van Rossum627b2d71993-12-24 10:39:16 +00004085# generate output files
Antoine Pitrou20327222009-05-24 20:39:11 +00004086AC_CONFIG_FILES(Makefile.pre Modules/Setup.config Misc/python.pc)
Martin v. Löwis88afe662002-10-26 13:47:44 +00004087AC_OUTPUT
Neil Schemenauer61c51152001-01-26 16:18:16 +00004088
Thomas Wouters49fd7fa2006-04-21 10:40:58 +00004089echo "creating Modules/Setup"
Neil Schemenauer61c51152001-01-26 16:18:16 +00004090if test ! -f Modules/Setup
4091then
4092 cp $srcdir/Modules/Setup.dist Modules/Setup
4093fi
4094
Thomas Wouters49fd7fa2006-04-21 10:40:58 +00004095echo "creating Modules/Setup.local"
Neil Schemenauer61c51152001-01-26 16:18:16 +00004096if test ! -f Modules/Setup.local
4097then
4098 echo "# Edit this file for local setup changes" >Modules/Setup.local
4099fi
4100
4101echo "creating Makefile"
4102$SHELL $srcdir/Modules/makesetup -c $srcdir/Modules/config.c.in \
4103 -s Modules Modules/Setup.config \
Neil Schemenauerf8b71c52001-04-21 17:41:16 +00004104 Modules/Setup.local Modules/Setup
Neil Schemenauer66252162001-02-19 04:47:42 +00004105mv config.c Modules