blob: 85c065f2bd30a0aa5a34fb05045f557dbad58657 [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)
Christian Heimes70e5cab2008-12-03 18:18:23 +00007m4_define(PYTHON_VERSION, 3.1)
Martin v. Löwis88afe662002-10-26 13:47:44 +00008
Guido van Rossum76be6ed1995-01-02 18:33:54 +00009AC_REVISION($Revision$)
Thomas Wouters47b49bf2007-08-30 22:15:33 +000010AC_PREREQ(2.61)
Georg Brandle2e15612009-05-20 18:25:10 +000011AC_INIT(python, PYTHON_VERSION, http://bugs.python.org/)
Martin v. Löwis88afe662002-10-26 13:47:44 +000012AC_CONFIG_SRCDIR([Include/object.h])
Martin v. Löwis4f1cd8b2001-07-26 13:41:06 +000013AC_CONFIG_HEADER(pyconfig.h)
Guido van Rossum627b2d71993-12-24 10:39:16 +000014
Benjamin Petersond23f8222009-04-05 19:13:16 +000015dnl Ensure that if prefix is specified, it does not end in a slash. If
16dnl it does, we get path names containing '//' which is both ugly and
17dnl can cause trouble.
18
19dnl Last slash shouldn't be stripped if prefix=/
20if test "$prefix" != "/"; then
21 prefix=`echo "$prefix" | sed -e 's/\/$//g'`
22fi
23
Martin v. Löwis8316feb2003-06-14 07:48:07 +000024dnl This is for stuff that absolutely must end up in pyconfig.h.
25dnl Please use pyport.h instead, if possible.
Martin v. Löwisbddf5a52002-11-11 13:37:28 +000026AH_TOP([
27#ifndef Py_PYCONFIG_H
28#define Py_PYCONFIG_H
29])
Martin v. Löwis11437992002-04-12 09:54:03 +000030AH_BOTTOM([
Martin v. Löwis11437992002-04-12 09:54:03 +000031/* Define the macros needed if on a UnixWare 7.x system. */
32#if defined(__USLC__) && defined(__SCO_VERSION__)
33#define STRICT_SYSV_CURSES /* Don't use ncurses extensions */
34#endif
Martin v. Löwisbddf5a52002-11-11 13:37:28 +000035
36#endif /*Py_PYCONFIG_H*/
Martin v. Löwis11437992002-04-12 09:54:03 +000037])
38
Martin v. Löwis8316feb2003-06-14 07:48:07 +000039# We don't use PACKAGE_ variables, and they cause conflicts
40# with other autoconf-based packages that include Python.h
41grep -v 'define PACKAGE_' <confdefs.h >confdefs.h.new
42rm confdefs.h
43mv confdefs.h.new confdefs.h
44
Guido van Rossum642b6781997-07-19 19:35:41 +000045AC_SUBST(VERSION)
Martin v. Löwis88afe662002-10-26 13:47:44 +000046VERSION=PYTHON_VERSION
Guido van Rossum642b6781997-07-19 19:35:41 +000047
Martin v. Löwis1142de32002-03-29 16:28:31 +000048AC_SUBST(SOVERSION)
49SOVERSION=1.0
50
Martin v. Löwis6f18a3c2002-07-20 08:51:52 +000051# The later defininition of _XOPEN_SOURCE disables certain features
52# on Linux, so we need _GNU_SOURCE to re-enable them (makedev, tm_zone).
53AC_DEFINE(_GNU_SOURCE, 1, [Define on Linux to activate all library features])
54
Martin v. Löwisbcd93962003-05-03 10:32:18 +000055# The later defininition of _XOPEN_SOURCE and _POSIX_C_SOURCE disables
56# certain features on NetBSD, so we need _NETBSD_SOURCE to re-enable
57# them.
58AC_DEFINE(_NETBSD_SOURCE, 1, [Define on NetBSD to activate all library features])
59
Andrew MacIntyreabccf412003-07-02 13:53:25 +000060# The later defininition of _XOPEN_SOURCE and _POSIX_C_SOURCE disables
61# certain features on FreeBSD, so we need __BSD_VISIBLE to re-enable
62# them.
63AC_DEFINE(__BSD_VISIBLE, 1, [Define on FreeBSD to activate all library features])
64
Martin v. Löwisd6320502004-08-12 13:45:08 +000065# The later defininition of _XOPEN_SOURCE and _POSIX_C_SOURCE disables
66# u_int on Irix 5.3. Defining _BSD_TYPES brings it back.
67AC_DEFINE(_BSD_TYPES, 1, [Define on Irix to enable u_int])
68
Georg Brandlfcaf9102008-07-16 02:17:56 +000069# The later defininition of _XOPEN_SOURCE and _POSIX_C_SOURCE disables
70# certain features on Mac OS X, so we need _DARWIN_C_SOURCE to re-enable
71# them.
72AC_DEFINE(_DARWIN_C_SOURCE, 1, [Define on Darwin to activate all library features])
73
74
Martin v. Löwise981a4e2002-11-11 13:26:51 +000075define_xopen_source=yes
Martin v. Löwis6f18a3c2002-07-20 08:51:52 +000076
Neil Schemenauer4edbc2a2001-03-22 00:34:03 +000077# Arguments passed to configure.
78AC_SUBST(CONFIG_ARGS)
79CONFIG_ARGS="$ac_configure_args"
80
Ronald Oussorend5736812010-02-07 12:04:41 +000081AC_MSG_CHECKING([for --enable-universalsdk])
Thomas Wouters477c8d52006-05-27 19:21:47 +000082AC_ARG_ENABLE(universalsdk,
Christian Heimes68f5fbe2008-02-14 08:27:37 +000083 AC_HELP_STRING(--enable-universalsdk@<:@=SDKDIR@:>@, Build against Mac OS X 10.4u SDK (ppc/i386)),
Thomas Wouters477c8d52006-05-27 19:21:47 +000084[
85 case $enableval in
86 yes)
87 enableval=/Developer/SDKs/MacOSX10.4u.sdk
Ronald Oussorend5736812010-02-07 12:04:41 +000088 if test ! -d "${enableval}"
89 then
90 enableval=/
91 fi
Thomas Wouters477c8d52006-05-27 19:21:47 +000092 ;;
93 esac
94 case $enableval in
95 no)
96 UNIVERSALSDK=
97 enable_universalsdk=
98 ;;
99 *)
100 UNIVERSALSDK=$enableval
Ronald Oussorend5736812010-02-07 12:04:41 +0000101 if test ! -d "${UNIVERSALSDK}"
102 then
103 AC_MSG_ERROR([--enable-universalsdk specifies non-existing SDK: ${UNIVERSALSDK}])
104 fi
Thomas Wouters477c8d52006-05-27 19:21:47 +0000105 ;;
106 esac
Ronald Oussorend5736812010-02-07 12:04:41 +0000107
Thomas Wouters477c8d52006-05-27 19:21:47 +0000108],[
109 UNIVERSALSDK=
110 enable_universalsdk=
111])
Ronald Oussorend5736812010-02-07 12:04:41 +0000112if test -n "${UNIVERSALSDK}"
113then
114 AC_MSG_RESULT(${UNIVERSALSDK})
115else
116 AC_MSG_RESULT(no)
117fi
Thomas Wouters477c8d52006-05-27 19:21:47 +0000118AC_SUBST(UNIVERSALSDK)
119
Benjamin Peterson6794aa32008-07-16 20:33:37 +0000120AC_SUBST(ARCH_RUN_32BIT)
121
Georg Brandlfcaf9102008-07-16 02:17:56 +0000122UNIVERSAL_ARCHS="32-bit"
123AC_MSG_CHECKING(for --with-universal-archs)
124AC_ARG_WITH(universal-archs,
Ronald Oussoren856624d2009-09-08 07:13:53 +0000125 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 +0000126[
127 AC_MSG_RESULT($withval)
128 UNIVERSAL_ARCHS="$withval"
129],
130[
131 AC_MSG_RESULT(32-bit)
132])
133
134
135
Christian Heimes81ee3ef2008-05-04 22:42:01 +0000136AC_ARG_WITH(framework-name,
137 AC_HELP_STRING(--with-framework-name=FRAMEWORK,
138 specify an alternate name of the framework built with --enable-framework),
139[
140 PYTHONFRAMEWORK=${withval}
141 PYTHONFRAMEWORKDIR=${withval}.framework
142 PYTHONFRAMEWORKIDENTIFIER=org.python.`echo $withval | tr '[A-Z]' '[a-z]'`
143 ],[
144 PYTHONFRAMEWORK=Python
145 PYTHONFRAMEWORKDIR=Python.framework
146 PYTHONFRAMEWORKIDENTIFIER=org.python.python
147])
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000148dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000149AC_ARG_ENABLE(framework,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000150 AC_HELP_STRING(--enable-framework@<:@=INSTALLDIR@:>@, Build (MacOSX|Darwin) framework),
151[
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000152 case $enableval in
153 yes)
154 enableval=/Library/Frameworks
Jack Jansen127e56e2001-09-11 14:41:54 +0000155 esac
156 case $enableval in
157 no)
158 PYTHONFRAMEWORK=
159 PYTHONFRAMEWORKDIR=no-framework
160 PYTHONFRAMEWORKPREFIX=
161 PYTHONFRAMEWORKINSTALLDIR=
Thomas Wouters477c8d52006-05-27 19:21:47 +0000162 FRAMEWORKINSTALLFIRST=
163 FRAMEWORKINSTALLLAST=
Thomas Wouters73e5a5b2006-06-08 15:35:45 +0000164 FRAMEWORKALTINSTALLFIRST=
165 FRAMEWORKALTINSTALLLAST=
166 if test "x${prefix}" = "xNONE"; then
167 FRAMEWORKUNIXTOOLSPREFIX="${ac_default_prefix}"
168 else
169 FRAMEWORKUNIXTOOLSPREFIX="${prefix}"
170 fi
Jack Jansen127e56e2001-09-11 14:41:54 +0000171 enable_framework=
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000172 ;;
173 *)
174 PYTHONFRAMEWORKPREFIX=$enableval
Jack Jansen127e56e2001-09-11 14:41:54 +0000175 PYTHONFRAMEWORKINSTALLDIR=$PYTHONFRAMEWORKPREFIX/$PYTHONFRAMEWORKDIR
Thomas Wouters477c8d52006-05-27 19:21:47 +0000176 FRAMEWORKINSTALLFIRST="frameworkinstallstructure"
Ronald Oussorenf6ccbf62009-06-02 10:55:56 +0000177 FRAMEWORKALTINSTALLFIRST="frameworkinstallstructure "
Georg Brandlfcaf9102008-07-16 02:17:56 +0000178 if test "$UNIVERSAL_ARCHS" = "all"
179 then
180 FRAMEWORKINSTALLLAST="frameworkinstallmaclib frameworkinstallapps4way frameworkinstallunixtools4way"
Ronald Oussorene3918352009-03-30 18:00:28 +0000181 FRAMEWORKALTINSTALLLAST="frameworkinstallmaclib frameworkinstallapps4way frameworkaltinstallunixtools4way"
Georg Brandlfcaf9102008-07-16 02:17:56 +0000182 else
Ronald Oussorene3918352009-03-30 18:00:28 +0000183 FRAMEWORKINSTALLLAST="frameworkinstallmaclib frameworkinstallapps frameworkinstallunixtools"
Georg Brandlfcaf9102008-07-16 02:17:56 +0000184 FRAMEWORKALTINSTALLLAST="frameworkinstallmaclib frameworkinstallapps frameworkaltinstallunixtools"
185 fi
186
Thomas Wouters73e5a5b2006-06-08 15:35:45 +0000187 if test "x${prefix}" = "xNONE" ; then
188 FRAMEWORKUNIXTOOLSPREFIX="${ac_default_prefix}"
189 else
190 FRAMEWORKUNIXTOOLSPREFIX="${prefix}"
191 fi
Jack Jansen127e56e2001-09-11 14:41:54 +0000192 prefix=$PYTHONFRAMEWORKINSTALLDIR/Versions/$VERSION
Thomas Wouters477c8d52006-05-27 19:21:47 +0000193
Christian Heimes81ee3ef2008-05-04 22:42:01 +0000194 # Add files for Mac specific code to the list of output
Thomas Wouters477c8d52006-05-27 19:21:47 +0000195 # files:
Thomas Wouters73e5a5b2006-06-08 15:35:45 +0000196 AC_CONFIG_FILES(Mac/Makefile)
197 AC_CONFIG_FILES(Mac/PythonLauncher/Makefile)
Christian Heimes81ee3ef2008-05-04 22:42:01 +0000198 AC_CONFIG_FILES(Mac/Resources/framework/Info.plist)
199 AC_CONFIG_FILES(Mac/Resources/app/Info.plist)
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000200 esac
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000201 ],[
202 PYTHONFRAMEWORK=
Jack Jansen127e56e2001-09-11 14:41:54 +0000203 PYTHONFRAMEWORKDIR=no-framework
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000204 PYTHONFRAMEWORKPREFIX=
205 PYTHONFRAMEWORKINSTALLDIR=
Thomas Wouters477c8d52006-05-27 19:21:47 +0000206 FRAMEWORKINSTALLFIRST=
207 FRAMEWORKINSTALLLAST=
Thomas Wouters73e5a5b2006-06-08 15:35:45 +0000208 FRAMEWORKALTINSTALLFIRST=
209 FRAMEWORKALTINSTALLLAST=
210 if test "x${prefix}" = "xNONE" ; then
211 FRAMEWORKUNIXTOOLSPREFIX="${ac_default_prefix}"
212 else
213 FRAMEWORKUNIXTOOLSPREFIX="${prefix}"
214 fi
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000215 enable_framework=
Georg Brandlfcaf9102008-07-16 02:17:56 +0000216
217 if test "$UNIVERSAL_ARCHS" = "all"
218 then
219 FRAMEWORKINSTALLLAST=update4wayuniversal
220 FRAMEWORKALTINSTALLLAST=update4wayuniversal
221 fi
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000222])
223AC_SUBST(PYTHONFRAMEWORK)
Christian Heimes81ee3ef2008-05-04 22:42:01 +0000224AC_SUBST(PYTHONFRAMEWORKIDENTIFIER)
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000225AC_SUBST(PYTHONFRAMEWORKDIR)
226AC_SUBST(PYTHONFRAMEWORKPREFIX)
227AC_SUBST(PYTHONFRAMEWORKINSTALLDIR)
Thomas Wouters477c8d52006-05-27 19:21:47 +0000228AC_SUBST(FRAMEWORKINSTALLFIRST)
229AC_SUBST(FRAMEWORKINSTALLLAST)
Thomas Wouters73e5a5b2006-06-08 15:35:45 +0000230AC_SUBST(FRAMEWORKALTINSTALLFIRST)
231AC_SUBST(FRAMEWORKALTINSTALLLAST)
232AC_SUBST(FRAMEWORKUNIXTOOLSPREFIX)
Guido van Rossum4b6b5791996-09-09 20:09:34 +0000233
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000234##AC_ARG_WITH(dyld,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000235## AC_HELP_STRING(--with-dyld,
236## Use (OpenStep|Rhapsody) dynamic linker))
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000237##
Guido van Rossumb418f891996-07-30 18:06:02 +0000238# Set name for machine-dependent library files
239AC_SUBST(MACHDEP)
240AC_MSG_CHECKING(MACHDEP)
241if test -z "$MACHDEP"
242then
Guido van Rossum4b6b5791996-09-09 20:09:34 +0000243 ac_sys_system=`uname -s`
Benjamin Petersona8332062009-09-11 22:36:27 +0000244 if test "$ac_sys_system" = "AIX" \
Martin v. Löwis21ee4092002-09-30 16:19:48 +0000245 -o "$ac_sys_system" = "UnixWare" -o "$ac_sys_system" = "OpenUNIX"; then
Guido van Rossum4b6b5791996-09-09 20:09:34 +0000246 ac_sys_release=`uname -v`
Guido van Rossumb418f891996-07-30 18:06:02 +0000247 else
Guido van Rossum4b6b5791996-09-09 20:09:34 +0000248 ac_sys_release=`uname -r`
Guido van Rossumb418f891996-07-30 18:06:02 +0000249 fi
Guido van Rossum4b6b5791996-09-09 20:09:34 +0000250 ac_md_system=`echo $ac_sys_system |
251 tr -d '[/ ]' | tr '[[A-Z]]' '[[a-z]]'`
252 ac_md_release=`echo $ac_sys_release |
Guido van Rossum67b26592001-10-20 14:21:45 +0000253 tr -d '[/ ]' | sed 's/^[[A-Z]]\.//' | sed 's/\..*//'`
Guido van Rossumb97ef171997-09-28 05:44:03 +0000254 MACHDEP="$ac_md_system$ac_md_release"
Guido van Rossum4b6b5791996-09-09 20:09:34 +0000255
Guido van Rossumbcd91e01997-03-20 20:46:29 +0000256 case $MACHDEP in
Andrew M. Kuchling5a3e4cb2001-07-20 19:29:04 +0000257 cygwin*) MACHDEP="cygwin";;
Jack Jansen8a97f4a2001-12-05 23:27:32 +0000258 darwin*) MACHDEP="darwin";;
Martin v. Löwisf90ae202002-06-11 06:22:31 +0000259 atheos*) MACHDEP="atheos";;
Martin v. Löwisf3322282003-07-13 09:46:13 +0000260 irix646) MACHDEP="irix6";;
Guido van Rossumb97ef171997-09-28 05:44:03 +0000261 '') MACHDEP="unknown";;
Guido van Rossumb418f891996-07-30 18:06:02 +0000262 esac
263fi
Jack Jansen83f898c2002-12-30 22:23:40 +0000264
Martin v. Löwise981a4e2002-11-11 13:26:51 +0000265# Some systems cannot stand _XOPEN_SOURCE being defined at all; they
266# disable features if it is defined, without any means to access these
267# features as extensions. For these systems, we skip the definition of
268# _XOPEN_SOURCE. Before adding a system to the list to gain access to
269# some feature, make sure there is no alternative way to access this
270# feature. Also, when using wildcards, make sure you have verified the
271# need for not defining _XOPEN_SOURCE on all systems matching the
272# wildcard, and that the wildcard does not include future systems
273# (which may remove their limitations).
274dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
275case $ac_sys_system/$ac_sys_release in
276 # On OpenBSD, select(2) is not available if _XOPEN_SOURCE is defined,
277 # even though select is a POSIX function. Reported by J. Ribbens.
Martin v. Löwis76bafc62003-10-03 13:47:44 +0000278 # Reconfirmed for OpenBSD 3.3 by Zachary Hamm, for 3.4 by Jason Ish.
Georg Brandlf78e02b2008-06-10 17:40:04 +0000279 OpenBSD/2.* | OpenBSD/3.@<:@0123456789@:>@ | OpenBSD/4.@<:@0123@:>@)
Christian Heimes5b5e81c2007-12-31 16:14:33 +0000280 define_xopen_source=no
281 # OpenBSD undoes our definition of __BSD_VISIBLE if _XOPEN_SOURCE is
282 # also defined. This can be overridden by defining _BSD_SOURCE
283 # As this has a different meaning on Linux, only define it on OpenBSD
284 AC_DEFINE(_BSD_SOURCE, 1, [Define on OpenBSD to activate all library features])
285 ;;
Thomas Wouters89f507f2006-12-13 04:49:30 +0000286 # Defining _XOPEN_SOURCE on NetBSD version prior to the introduction of
287 # _NETBSD_SOURCE disables certain features (eg. setgroups). Reported by
288 # Marc Recht
Benjamin Petersonf608c612008-11-16 18:33:53 +0000289 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 +0000290 define_xopen_source=no;;
Martin v. Löwisa9d71422003-03-28 18:43:31 +0000291 # On Solaris 2.6, sys/wait.h is inconsistent in the usage
292 # of union __?sigval. Reported by Stuart Bishop.
293 SunOS/5.6)
294 define_xopen_source=no;;
Martin v. Löwisc2409b42003-05-11 05:53:41 +0000295 # On UnixWare 7, u_long is never defined with _XOPEN_SOURCE,
296 # but used in /usr/include/netinet/tcp.h. Reported by Tim Rice.
Martin v. Löwis253d1f42004-05-07 19:14:14 +0000297 # Reconfirmed for 7.1.4 by Martin v. Loewis.
298 OpenUNIX/8.0.0| UnixWare/7.1.@<:@0-4@:>@)
Martin v. Löwisc2409b42003-05-11 05:53:41 +0000299 define_xopen_source=no;;
300 # On OpenServer 5, u_short is never defined with _XOPEN_SOURCE,
Martin v. Löwis53e73c32003-05-05 05:13:18 +0000301 # but used in struct sockaddr.sa_family. Reported by Tim Rice.
Martin v. Löwisc2409b42003-05-11 05:53:41 +0000302 SCO_SV/3.2)
Martin v. Löwis53e73c32003-05-05 05:13:18 +0000303 define_xopen_source=no;;
Martin v. Löwisb37509b2008-11-04 20:45:29 +0000304 # On FreeBSD 4, the math functions C89 does not cover are never defined
305 # with _XOPEN_SOURCE and __BSD_VISIBLE does not re-enable them.
306 FreeBSD/4.*)
307 define_xopen_source=no;;
308 # On MacOS X 10.2, a bug in ncurses.h means that it craps out if
309 # _XOPEN_EXTENDED_SOURCE is defined. Apparently, this is fixed in 10.3, which
310 # identifies itself as Darwin/7.*
311 # On Mac OS X 10.4, defining _POSIX_C_SOURCE or _XOPEN_SOURCE
312 # disables platform specific features beyond repair.
313 # On Mac OS X 10.3, defining _POSIX_C_SOURCE or _XOPEN_SOURCE
314 # has no effect, don't bother defining them
315 Darwin/@<:@6789@:>@.*)
Anthony Baxter6169c6b2003-10-04 07:46:23 +0000316 define_xopen_source=no;;
Trent Mickaf16e8c2004-08-25 23:55:59 +0000317 # On AIX 4 and 5.1, mbstate_t is defined only when _XOPEN_SOURCE == 500 but
318 # used in wcsnrtombs() and mbsnrtowcs() even if _XOPEN_SOURCE is not defined
319 # or has another value. By not (re)defining it, the defaults come in place.
Martin v. Löwisc19c5a62003-11-18 20:00:44 +0000320 AIX/4)
321 define_xopen_source=no;;
Trent Mickaf16e8c2004-08-25 23:55:59 +0000322 AIX/5)
323 if test `uname -r` -eq 1; then
324 define_xopen_source=no
325 fi
326 ;;
Georg Brandlf78e02b2008-06-10 17:40:04 +0000327 # On QNX 6.3.2, defining _XOPEN_SOURCE prevents netdb.h from
328 # defining NI_NUMERICHOST.
329 QNX/6.3.2)
330 define_xopen_source=no
331 ;;
Bob Ippolito7026a0a2005-03-28 23:23:47 +0000332
Martin v. Löwise981a4e2002-11-11 13:26:51 +0000333esac
334
335if test $define_xopen_source = yes
336then
Skip Montanarof0d5f792004-08-15 14:08:23 +0000337 # On Solaris w/ g++ it appears that _XOPEN_SOURCE has to be
338 # defined precisely as g++ defines it
Martin v. Löwis7dece662005-11-26 11:38:24 +0000339 # Furthermore, on Solaris 10, XPG6 requires the use of a C99
340 # compiler
Skip Montanarof0d5f792004-08-15 14:08:23 +0000341 case $ac_sys_system/$ac_sys_release in
Martin v. Löwis7dece662005-11-26 11:38:24 +0000342 SunOS/5.8|SunOS/5.9|SunOS/5.10)
Skip Montanarof0d5f792004-08-15 14:08:23 +0000343 AC_DEFINE(_XOPEN_SOURCE, 500,
344 Define to the level of X/Open that your system supports)
345 ;;
346 *)
347 AC_DEFINE(_XOPEN_SOURCE, 600,
348 Define to the level of X/Open that your system supports)
349 ;;
350 esac
Martin v. Löwis678fc1e2002-11-12 06:04:39 +0000351
352 # On Tru64 Unix 4.0F, defining _XOPEN_SOURCE also requires
353 # definition of _XOPEN_SOURCE_EXTENDED and _POSIX_C_SOURCE, or else
354 # several APIs are not declared. Since this is also needed in some
355 # cases for HP-UX, we define it globally.
Martin v. Löwis7dece662005-11-26 11:38:24 +0000356 # except for Solaris 10, where it must not be defined,
357 # as it implies XPG4.2
358 case $ac_sys_system/$ac_sys_release in
359 SunOS/5.10)
360 ;;
361 *)
362 AC_DEFINE(_XOPEN_SOURCE_EXTENDED, 1,
363 Define to activate Unix95-and-earlier features)
364 ;;
365 esac
Martin v. Löwis678fc1e2002-11-12 06:04:39 +0000366
Bob Ippolito7026a0a2005-03-28 23:23:47 +0000367 AC_DEFINE(_POSIX_C_SOURCE, 200112L, Define to activate features from IEEE Stds 1003.1-2001)
368
Martin v. Löwise981a4e2002-11-11 13:26:51 +0000369fi
370
Guido van Rossum91922671997-10-09 20:24:13 +0000371#
372# SGI compilers allow the specification of the both the ABI and the
373# ISA on the command line. Depending on the values of these switches,
374# different and often incompatable code will be generated.
375#
376# The SGI_ABI variable can be used to modify the CC and LDFLAGS and
377# thus supply support for various ABI/ISA combinations. The MACHDEP
378# variable is also adjusted.
379#
380AC_SUBST(SGI_ABI)
381if test ! -z "$SGI_ABI"
382then
383 CC="cc $SGI_ABI"
384 LDFLAGS="$SGI_ABI $LDFLAGS"
385 MACHDEP=`echo "${MACHDEP}${SGI_ABI}" | sed 's/ *//g'`
386fi
Guido van Rossumb418f891996-07-30 18:06:02 +0000387AC_MSG_RESULT($MACHDEP)
388
Jack Jansen6b08a402004-06-03 12:41:45 +0000389# Record the configure-time value of MACOSX_DEPLOYMENT_TARGET,
390# it may influence the way we can build extensions, so distutils
391# needs to check it
392AC_SUBST(CONFIGURE_MACOSX_DEPLOYMENT_TARGET)
Thomas Wouters477c8d52006-05-27 19:21:47 +0000393AC_SUBST(EXPORT_MACOSX_DEPLOYMENT_TARGET)
Jack Jansen6b08a402004-06-03 12:41:45 +0000394CONFIGURE_MACOSX_DEPLOYMENT_TARGET=
Thomas Wouters477c8d52006-05-27 19:21:47 +0000395EXPORT_MACOSX_DEPLOYMENT_TARGET='#'
Jack Jansen6b08a402004-06-03 12:41:45 +0000396
Mark Dickinsonb0e2b4c2008-04-26 20:48:56 +0000397AC_MSG_CHECKING(machine type as reported by uname -m)
398ac_sys_machine=`uname -m`
399AC_MSG_RESULT($ac_sys_machine)
400
Guido van Rossum627b2d71993-12-24 10:39:16 +0000401# checks for alternative programs
Skip Montanarodecc6a42003-01-01 20:07:49 +0000402
403# compiler flags are generated in two sets, BASECFLAGS and OPT. OPT is just
404# for debug/optimization stuff. BASECFLAGS is for flags that are required
405# just to get things to compile and link. Users are free to override OPT
406# when running configure or make. The build should not break if they do.
407# BASECFLAGS should generally not be messed with, however.
408
409# XXX shouldn't some/most/all of this code be merged with the stuff later
410# on that fiddles with OPT and BASECFLAGS?
Guido van Rossum5739e7e1995-01-20 16:50:53 +0000411AC_MSG_CHECKING(for --without-gcc)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000412AC_ARG_WITH(gcc,
413 AC_HELP_STRING(--without-gcc,never use gcc),
414[
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000415 case $withval in
Benjamin Peterson960cf0f2009-01-09 04:11:44 +0000416 no) CC=${CC:-cc}
Guido van Rossum5739e7e1995-01-20 16:50:53 +0000417 without_gcc=yes;;
418 yes) CC=gcc
419 without_gcc=no;;
420 *) CC=$withval
421 without_gcc=$withval;;
Guido van Rossum55a214e1995-09-13 17:48:09 +0000422 esac], [
Guido van Rossumb418f891996-07-30 18:06:02 +0000423 case $ac_sys_system in
Neil Schemenauerb3531b82001-02-16 04:09:05 +0000424 AIX*) CC=cc_r
425 without_gcc=;;
Martin v. Löwis130fb172001-07-19 11:00:41 +0000426 *) without_gcc=no;;
Guido van Rossum55a214e1995-09-13 17:48:09 +0000427 esac])
Guido van Rossum5739e7e1995-01-20 16:50:53 +0000428AC_MSG_RESULT($without_gcc)
429
Guido van Rossum03ad99f1995-03-09 14:09:54 +0000430# If the user switches compilers, we can't believe the cache
431if test ! -z "$ac_cv_prog_CC" -a ! -z "$CC" -a "$CC" != "$ac_cv_prog_CC"
432then
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000433 AC_MSG_ERROR([cached CC is different -- throw away $cache_file
434(it is also a good idea to do 'make clean' before compiling)])
Guido van Rossum03ad99f1995-03-09 14:09:54 +0000435fi
436
Guido van Rossum627b2d71993-12-24 10:39:16 +0000437AC_PROG_CC
Martin v. Löwis1d5ecb72001-08-09 10:29:44 +0000438
Thomas Wouters49fd7fa2006-04-21 10:40:58 +0000439AC_SUBST(CXX)
440AC_SUBST(MAINCC)
441AC_MSG_CHECKING(for --with-cxx-main=<compiler>)
442AC_ARG_WITH(cxx_main,
443 AC_HELP_STRING([--with-cxx-main=<compiler>],
444 [compile main() and link python executable with C++ compiler]),
445[
446
447 case $withval in
448 no) with_cxx_main=no
449 MAINCC='$(CC)';;
450 yes) with_cxx_main=yes
451 MAINCC='$(CXX)';;
452 *) with_cxx_main=yes
453 MAINCC=$withval
454 if test -z "$CXX"
455 then
456 CXX=$withval
457 fi;;
458 esac], [
459 with_cxx_main=no
460 MAINCC='$(CC)'
461])
462AC_MSG_RESULT($with_cxx_main)
463
464preset_cxx="$CXX"
465if test -z "$CXX"
466then
467 case "$CC" in
468 gcc) AC_PATH_PROG(CXX, [g++], [g++], [notfound]) ;;
469 cc) AC_PATH_PROG(CXX, [c++], [c++], [notfound]) ;;
470 esac
471 if test "$CXX" = "notfound"
472 then
473 CXX=""
474 fi
475fi
476if test -z "$CXX"
477then
478 AC_CHECK_PROGS(CXX, $CCC c++ g++ gcc CC cxx cc++ cl, notfound)
479 if test "$CXX" = "notfound"
480 then
481 CXX=""
482 fi
483fi
484if test "$preset_cxx" != "$CXX"
485then
486 AC_MSG_WARN([
487
488 By default, distutils will build C++ extension modules with "$CXX".
489 If this is not intended, then set CXX on the configure command line.
490 ])
491fi
492
493
Martin v. Löwis1d5ecb72001-08-09 10:29:44 +0000494# checks for UNIX variants that set C preprocessor variables
495AC_AIX
Martin v. Löwis1d5ecb72001-08-09 10:29:44 +0000496
Martin v. Löwis779ffc02002-12-02 22:17:01 +0000497# Check for unsupported systems
498case $ac_sys_system/$ac_sys_release in
Guido van Rossumcd16bf62007-06-13 18:07:49 +0000499atheos*|Linux*/1*)
Martin v. Löwis779ffc02002-12-02 22:17:01 +0000500 echo This system \($ac_sys_system/$ac_sys_release\) is no longer supported.
501 echo See README for details.
502 exit 1;;
503esac
504
Neil Schemenauer55f0cf32001-01-24 17:24:33 +0000505AC_EXEEXT
Neil Schemenauer3ae1d0a2001-01-27 06:54:42 +0000506AC_MSG_CHECKING(for --with-suffix)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000507AC_ARG_WITH(suffix,
508 AC_HELP_STRING(--with-suffix=.exe, set executable suffix),
509[
Neil Schemenauer3ae1d0a2001-01-27 06:54:42 +0000510 case $withval in
511 no) EXEEXT=;;
512 yes) EXEEXT=.exe;;
513 *) EXEEXT=$withval;;
514 esac])
515AC_MSG_RESULT($EXEEXT)
Jack Jansen1999ef42001-12-06 21:47:20 +0000516
Jack Jansen9a66b6d2001-08-08 13:56:14 +0000517# Test whether we're running on a non-case-sensitive system, in which
518# case we give a warning if no ext is given
Jack Jansen1999ef42001-12-06 21:47:20 +0000519AC_SUBST(BUILDEXEEXT)
520AC_MSG_CHECKING(for case-insensitive build directory)
Jack Jansen3c2c4332002-11-06 13:33:32 +0000521if test ! -d CaseSensitiveTestDir; then
522mkdir CaseSensitiveTestDir
523fi
524
525if test -d casesensitivetestdir
Jack Jansen9a66b6d2001-08-08 13:56:14 +0000526then
Jack Jansen1999ef42001-12-06 21:47:20 +0000527 AC_MSG_RESULT(yes)
528 BUILDEXEEXT=.exe
529else
530 AC_MSG_RESULT(no)
Jack Jansendd19cf82001-12-06 22:36:17 +0000531 BUILDEXEEXT=$EXEEXT
Jack Jansen9a66b6d2001-08-08 13:56:14 +0000532fi
Jack Jansen3c2c4332002-11-06 13:33:32 +0000533rmdir CaseSensitiveTestDir
Guido van Rossumfb842551997-08-06 23:42:07 +0000534
Guido van Rossumdd997f71998-10-07 19:58:26 +0000535case $MACHDEP in
536bsdos*)
537 case $CC in
538 gcc) CC="$CC -D_HAVE_BSDI";;
539 esac;;
540esac
541
Guido van Rossum84561611997-08-21 00:08:11 +0000542case $ac_sys_system in
543hp*|HP*)
544 case $CC in
Guido van Rossumcd5ff9f2000-09-22 16:15:54 +0000545 cc|*/cc) CC="$CC -Ae";;
Guido van Rossum84561611997-08-21 00:08:11 +0000546 esac;;
Martin v. Löwise8964d42001-03-06 12:09:07 +0000547SunOS*)
548 # Some functions have a prototype only with that define, e.g. confstr
Martin v. Löwisc45929e2002-04-06 10:10:49 +0000549 AC_DEFINE(__EXTENSIONS__, 1, [Defined on Solaris to see additional function prototypes.])
Martin v. Löwise8964d42001-03-06 12:09:07 +0000550 ;;
Guido van Rossum84561611997-08-21 00:08:11 +0000551esac
552
Martin v. Löwise8964d42001-03-06 12:09:07 +0000553
Neil Schemenauer61c51152001-01-26 16:18:16 +0000554AC_SUBST(LIBRARY)
555AC_MSG_CHECKING(LIBRARY)
556if test -z "$LIBRARY"
557then
558 LIBRARY='libpython$(VERSION).a'
559fi
560AC_MSG_RESULT($LIBRARY)
561
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000562# LDLIBRARY is the name of the library to link against (as opposed to the
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000563# name of the library into which to insert object files). BLDLIBRARY is also
564# the library to link against, usually. On Mac OS X frameworks, BLDLIBRARY
565# is blank as the main program is not linked directly against LDLIBRARY.
566# LDLIBRARYDIR is the path to LDLIBRARY, which is made in a subdirectory. On
567# systems without shared libraries, LDLIBRARY is the same as LIBRARY
568# (defined in the Makefiles). On Cygwin LDLIBRARY is the import library,
569# DLLLIBRARY is the shared (i.e., DLL) library.
570#
Martin v. Löwis1142de32002-03-29 16:28:31 +0000571# RUNSHARED is used to run shared python without installed libraries
572#
573# INSTSONAME is the name of the shared library that will be use to install
574# on the system - some systems like version suffix, others don't
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000575AC_SUBST(LDLIBRARY)
Guido van Rossum27552902001-01-23 01:52:26 +0000576AC_SUBST(DLLLIBRARY)
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000577AC_SUBST(BLDLIBRARY)
578AC_SUBST(LDLIBRARYDIR)
Martin v. Löwis1142de32002-03-29 16:28:31 +0000579AC_SUBST(INSTSONAME)
580AC_SUBST(RUNSHARED)
Neil Schemenauer61c51152001-01-26 16:18:16 +0000581LDLIBRARY="$LIBRARY"
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000582BLDLIBRARY='$(LDLIBRARY)'
Martin v. Löwis09bdf722002-05-08 08:51:29 +0000583INSTSONAME='$(LDLIBRARY)'
Guido van Rossum27552902001-01-23 01:52:26 +0000584DLLLIBRARY=''
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000585LDLIBRARYDIR=''
Martin v. Löwis1142de32002-03-29 16:28:31 +0000586RUNSHARED=''
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000587
Guido van Rossumfb842551997-08-06 23:42:07 +0000588# LINKCC is the command that links the python executable -- default is $(CC).
Martin v. Löwisb7da67a2001-10-18 15:35:38 +0000589# If CXX is set, and if it is needed to link a main function that was
590# compiled with CXX, LINKCC is CXX instead. Always using CXX is undesirable:
591# python might then depend on the C++ runtime
Fred Drake5790be12000-10-09 17:06:13 +0000592# This is altered for AIX in order to build the export list before
Guido van Rossumec95c7b1998-08-04 17:59:56 +0000593# linking.
Guido van Rossumfb842551997-08-06 23:42:07 +0000594AC_SUBST(LINKCC)
595AC_MSG_CHECKING(LINKCC)
596if test -z "$LINKCC"
597then
Thomas Wouters49fd7fa2006-04-21 10:40:58 +0000598 LINKCC='$(PURIFY) $(MAINCC)'
Guido van Rossumfb842551997-08-06 23:42:07 +0000599 case $ac_sys_system in
600 AIX*)
Neal Norwitz0b27ff92003-03-31 15:53:49 +0000601 exp_extra="\"\""
602 if test $ac_sys_release -ge 5 -o \
603 $ac_sys_release -eq 4 -a `uname -r` -ge 2 ; then
604 exp_extra="."
605 fi
606 LINKCC="\$(srcdir)/Modules/makexp_aix Modules/python.exp $exp_extra \$(LIBRARY); $LINKCC";;
Georg Brandlf78e02b2008-06-10 17:40:04 +0000607 QNX*)
608 # qcc must be used because the other compilers do not
609 # support -N.
610 LINKCC=qcc;;
Guido van Rossumfb842551997-08-06 23:42:07 +0000611 esac
612fi
613AC_MSG_RESULT($LINKCC)
614
Tarek Ziadébe720e02009-05-09 11:55:12 +0000615# GNULD is set to "yes" if the GNU linker is used. If this goes wrong
616# make sure we default having it set to "no": this is used by
617# distutils.unixccompiler to know if it should add --enable-new-dtags
618# to linker command lines, and failing to detect GNU ld simply results
619# in the same bahaviour as before.
620AC_SUBST(GNULD)
621AC_MSG_CHECKING(for GNU ld)
622ac_prog=ld
623if test "$GCC" = yes; then
624 ac_prog=`$CC -print-prog-name=ld`
625fi
626case `"$ac_prog" -V 2>&1 < /dev/null` in
627 *GNU*)
628 GNULD=yes;;
629 *)
630 GNULD=no;;
631esac
632AC_MSG_RESULT($GNULD)
633
Martin v. Löwis1142de32002-03-29 16:28:31 +0000634AC_MSG_CHECKING(for --enable-shared)
635AC_ARG_ENABLE(shared,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000636 AC_HELP_STRING(--enable-shared, disable/enable building shared python library))
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000637
Martin v. Löwis1142de32002-03-29 16:28:31 +0000638if test -z "$enable_shared"
639then
Martin v. Löwisb51033d2002-05-03 05:53:15 +0000640 case $ac_sys_system in
Martin v. Löwisf90ae202002-06-11 06:22:31 +0000641 CYGWIN* | atheos*)
Martin v. Löwisb51033d2002-05-03 05:53:15 +0000642 enable_shared="yes";;
643 *)
644 enable_shared="no";;
645 esac
Martin v. Löwis1142de32002-03-29 16:28:31 +0000646fi
647AC_MSG_RESULT($enable_shared)
648
Skip Montanaro56f6a4f2004-06-18 02:47:22 +0000649AC_MSG_CHECKING(for --enable-profiling)
650AC_ARG_ENABLE(profiling,
651 AC_HELP_STRING(--enable-profiling, enable C-level code profiling),
652[ac_save_cc="$CC"
653 CC="$CC -pg"
654 AC_TRY_RUN([int main() { return 0; }],
655 ac_enable_profiling="yes",
656 ac_enable_profiling="no",
657 ac_enable_profiling="no")
658 CC="$ac_save_cc"])
659AC_MSG_RESULT($ac_enable_profiling)
660
661case "$ac_enable_profiling" in
662 "yes")
663 BASECFLAGS="-pg $BASECFLAGS"
664 LDFLAGS="-pg $LDFLAGS"
665 ;;
666esac
Martin v. Löwis1142de32002-03-29 16:28:31 +0000667
668AC_MSG_CHECKING(LDLIBRARY)
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000669
Guido van Rossumb8552162001-09-05 14:58:11 +0000670# MacOSX framework builds need more magic. LDLIBRARY is the dynamic
671# library that we build, but we do not want to link against it (we
672# will find it with a -framework option). For this reason there is an
673# extra variable BLDLIBRARY against which Python and the extension
674# modules are linked, BLDLIBRARY. This is normally the same as
675# LDLIBRARY, but empty for MacOSX framework builds.
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000676if test "$enable_framework"
677then
678 LDLIBRARY='$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansen66b84832003-07-04 12:14:39 +0000679 RUNSHARED=DYLD_FRAMEWORK_PATH="`pwd`:$DYLD_FRAMEWORK_PATH"
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000680 BLDLIBRARY=''
681else
682 BLDLIBRARY='$(LDLIBRARY)'
683fi
684
Martin v. Löwis1142de32002-03-29 16:28:31 +0000685# Other platforms follow
686if test $enable_shared = "yes"; then
Mark Hammond8235ea12002-07-19 06:55:41 +0000687 AC_DEFINE(Py_ENABLE_SHARED, 1, [Defined if Python is built as a shared library.])
Martin v. Löwis1142de32002-03-29 16:28:31 +0000688 case $ac_sys_system in
Martin v. Löwis1142de32002-03-29 16:28:31 +0000689 CYGWIN*)
690 LDLIBRARY='libpython$(VERSION).dll.a'
691 DLLLIBRARY='libpython$(VERSION).dll'
692 ;;
693 SunOS*)
694 LDLIBRARY='libpython$(VERSION).so'
Martin v. Löwisd141a8c2003-06-14 15:20:28 +0000695 BLDLIBRARY='-Wl,-R,$(LIBDIR) -L. -lpython$(VERSION)'
Martin v. Löwisfc9b75f2003-08-09 09:06:52 +0000696 RUNSHARED=LD_LIBRARY_PATH=`pwd`:${LD_LIBRARY_PATH}
Martin v. Löwis2389c412003-10-31 15:42:07 +0000697 INSTSONAME="$LDLIBRARY".$SOVERSION
Martin v. Löwis1142de32002-03-29 16:28:31 +0000698 ;;
Martin v. Löwis86d66262006-02-17 08:40:11 +0000699 Linux*|GNU*|NetBSD*|FreeBSD*|DragonFly*)
Martin v. Löwis1142de32002-03-29 16:28:31 +0000700 LDLIBRARY='libpython$(VERSION).so'
701 BLDLIBRARY='-L. -lpython$(VERSION)'
Martin v. Löwisfc9b75f2003-08-09 09:06:52 +0000702 RUNSHARED=LD_LIBRARY_PATH=`pwd`:${LD_LIBRARY_PATH}
Hye-Shik Chang33761492004-10-26 09:53:46 +0000703 case $ac_sys_system in
704 FreeBSD*)
705 SOVERSION=`echo $SOVERSION|cut -d "." -f 1`
706 ;;
707 esac
Martin v. Löwis1142de32002-03-29 16:28:31 +0000708 INSTSONAME="$LDLIBRARY".$SOVERSION
709 ;;
710 hp*|HP*)
Thomas Wouters477c8d52006-05-27 19:21:47 +0000711 case `uname -m` in
712 ia64)
713 LDLIBRARY='libpython$(VERSION).so'
714 ;;
715 *)
716 LDLIBRARY='libpython$(VERSION).sl'
717 ;;
718 esac
Martin v. Löwis1142de32002-03-29 16:28:31 +0000719 BLDLIBRARY='-Wl,+b,$(LIBDIR) -L. -lpython$(VERSION)'
Martin v. Löwisfc9b75f2003-08-09 09:06:52 +0000720 RUNSHARED=SHLIB_PATH=`pwd`:${SHLIB_PATH}
Martin v. Löwis1142de32002-03-29 16:28:31 +0000721 ;;
722 OSF*)
723 LDLIBRARY='libpython$(VERSION).so'
Neal Norwitz671b9e32006-01-09 07:07:12 +0000724 BLDLIBRARY='-rpath $(LIBDIR) -L. -lpython$(VERSION)'
Martin v. Löwisfc9b75f2003-08-09 09:06:52 +0000725 RUNSHARED=LD_LIBRARY_PATH=`pwd`:${LD_LIBRARY_PATH}
Martin v. Löwis1142de32002-03-29 16:28:31 +0000726 ;;
Martin v. Löwisf90ae202002-06-11 06:22:31 +0000727 atheos*)
728 LDLIBRARY='libpython$(VERSION).so'
729 BLDLIBRARY='-L. -lpython$(VERSION)'
730 RUNSHARED=DLL_PATH=`pwd`:${DLL_PATH:-/atheos/sys/libs:/atheos/autolnk/lib}
731 ;;
Georg Brandlb1441c72009-01-03 22:33:39 +0000732 Darwin*)
733 LDLIBRARY='libpython$(VERSION).dylib'
734 BLDLIBRARY='-L. -lpython$(VERSION)'
735 RUNSHARED='DYLD_LIBRARY_PATH=`pwd`:${DYLD_LIBRARY_PATH}'
736 ;;
737
Martin v. Löwis1142de32002-03-29 16:28:31 +0000738 esac
Jason Tishler30765592003-09-04 11:04:06 +0000739else # shared is disabled
740 case $ac_sys_system in
741 CYGWIN*)
742 BLDLIBRARY='$(LIBRARY)'
743 LDLIBRARY='libpython$(VERSION).dll.a'
744 ;;
745 esac
Martin v. Löwis1142de32002-03-29 16:28:31 +0000746fi
747
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000748AC_MSG_RESULT($LDLIBRARY)
749
Guido van Rossum627b2d71993-12-24 10:39:16 +0000750AC_PROG_RANLIB
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000751AC_SUBST(AR)
Guido van Rossum76be6ed1995-01-02 18:33:54 +0000752AC_CHECK_PROGS(AR, ar aal, ar)
Neil Schemenauera42c8272001-03-31 00:01:55 +0000753
Tarek Ziadé5662d3e2009-05-07 21:24:43 +0000754# tweak ARFLAGS only if the user didn't set it on the command line
755AC_SUBST(ARFLAGS)
756if test -z "$ARFLAGS"
757then
758 ARFLAGS="rc"
759fi
760
Martin v. Löwisdea59e52006-01-05 10:00:36 +0000761AC_SUBST(SVNVERSION)
Thomas Wouters49fd7fa2006-04-21 10:40:58 +0000762AC_CHECK_PROG(SVNVERSION, svnversion, found, not-found)
Martin v. Löwisc5bf5a02006-01-05 10:33:59 +0000763if test $SVNVERSION = found
764then
765 SVNVERSION="svnversion \$(srcdir)"
766else
Benjamin Petersonf53eec82009-05-23 19:36:27 +0000767 SVNVERSION="echo Unversioned directory"
Martin v. Löwisc5bf5a02006-01-05 10:33:59 +0000768fi
Martin v. Löwisdea59e52006-01-05 10:00:36 +0000769
Neil Schemenauera42c8272001-03-31 00:01:55 +0000770case $MACHDEP in
Neil Schemenaueraf5567f2001-10-21 22:32:04 +0000771bsdos*|hp*|HP*)
772 # install -d does not work on BSDI or HP-UX
Neil Schemenauera42c8272001-03-31 00:01:55 +0000773 if test -z "$INSTALL"
774 then
775 INSTALL="${srcdir}/install-sh -c"
776 fi
777esac
Neil Schemenauer55f0cf32001-01-24 17:24:33 +0000778AC_PROG_INSTALL
Guido van Rossumb418f891996-07-30 18:06:02 +0000779
Guido van Rossumec95c7b1998-08-04 17:59:56 +0000780# Not every filesystem supports hard links
781AC_SUBST(LN)
782if test -z "$LN" ; then
783 case $ac_sys_system in
Guido van Rossumaef734b2001-01-10 21:09:12 +0000784 CYGWIN*) LN="ln -s";;
Martin v. Löwisf90ae202002-06-11 06:22:31 +0000785 atheos*) LN="ln -s";;
Guido van Rossumec95c7b1998-08-04 17:59:56 +0000786 *) LN=ln;;
787 esac
788fi
789
Fred Drake9f715822001-07-11 06:27:00 +0000790# Check for --with-pydebug
791AC_MSG_CHECKING(for --with-pydebug)
792AC_ARG_WITH(pydebug,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000793 AC_HELP_STRING(--with-pydebug, build with Py_DEBUG defined),
794[
Fred Drake9f715822001-07-11 06:27:00 +0000795if test "$withval" != no
Martin v. Löwisc45929e2002-04-06 10:10:49 +0000796then
797 AC_DEFINE(Py_DEBUG, 1,
798 [Define if you want to build an interpreter with many run-time checks.])
799 AC_MSG_RESULT(yes);
800 Py_DEBUG='true'
Fred Drake9f715822001-07-11 06:27:00 +0000801else AC_MSG_RESULT(no); Py_DEBUG='false'
802fi],
803[AC_MSG_RESULT(no)])
804
Skip Montanarodecc6a42003-01-01 20:07:49 +0000805# XXX Shouldn't the code above that fiddles with BASECFLAGS and OPT be
806# merged with this chunk of code?
807
Neil Schemenauer55f0cf32001-01-24 17:24:33 +0000808# Optimizer/debugger flags
Skip Montanarodecc6a42003-01-01 20:07:49 +0000809# ------------------------
810# (The following bit of code is complicated enough - please keep things
811# indented properly. Just pretend you're editing Python code. ;-)
812
813# There are two parallel sets of case statements below, one that checks to
814# see if OPT was set and one that does BASECFLAGS setting based upon
815# compiler and platform. BASECFLAGS tweaks need to be made even if the
816# user set OPT.
817
818# tweak OPT based on compiler and platform, only if the user didn't set
819# it on the command line
Guido van Rossumb418f891996-07-30 18:06:02 +0000820AC_SUBST(OPT)
Guido van Rossum4e8af441994-08-19 15:33:54 +0000821if test -z "$OPT"
Guido van Rossumb418f891996-07-30 18:06:02 +0000822then
Skip Montanarodecc6a42003-01-01 20:07:49 +0000823 case $GCC in
824 yes)
Thomas Wouters49fd7fa2006-04-21 10:40:58 +0000825 if test "$CC" != 'g++' ; then
826 STRICT_PROTO="-Wstrict-prototypes"
827 fi
Christian Heimes38053212007-12-14 01:24:44 +0000828 # For gcc 4.x we need to use -fwrapv so lets check if its supported
829 if "$CC" -v --help 2>/dev/null |grep -- -fwrapv > /dev/null; then
830 WRAP="-fwrapv"
831 fi
Skip Montanarodecc6a42003-01-01 20:07:49 +0000832 case $ac_cv_prog_cc_g in
Guido van Rossum2242f2f2001-04-11 20:58:20 +0000833 yes)
Fred Drake9f715822001-07-11 06:27:00 +0000834 if test "$Py_DEBUG" = 'true' ; then
835 # Optimization messes up debuggers, so turn it off for
836 # debug builds.
Thomas Wouters49fd7fa2006-04-21 10:40:58 +0000837 OPT="-g -Wall $STRICT_PROTO"
Fred Drake9f715822001-07-11 06:27:00 +0000838 else
Christian Heimes38053212007-12-14 01:24:44 +0000839 OPT="-g $WRAP -O3 -Wall $STRICT_PROTO"
Skip Montanarodecc6a42003-01-01 20:07:49 +0000840 fi
841 ;;
Guido van Rossum2242f2f2001-04-11 20:58:20 +0000842 *)
Thomas Wouters49fd7fa2006-04-21 10:40:58 +0000843 OPT="-O3 -Wall $STRICT_PROTO"
Skip Montanarodecc6a42003-01-01 20:07:49 +0000844 ;;
Fred Drake9f715822001-07-11 06:27:00 +0000845 esac
Martin v. Löwis21ee4092002-09-30 16:19:48 +0000846 case $ac_sys_system in
Skip Montanarodecc6a42003-01-01 20:07:49 +0000847 SCO_SV*) OPT="$OPT -m486 -DSCO5"
848 ;;
849 esac
Fred Drake9f715822001-07-11 06:27:00 +0000850 ;;
Skip Montanarodecc6a42003-01-01 20:07:49 +0000851
Guido van Rossum2242f2f2001-04-11 20:58:20 +0000852 *)
Skip Montanarodecc6a42003-01-01 20:07:49 +0000853 OPT="-O"
854 ;;
Guido van Rossum2242f2f2001-04-11 20:58:20 +0000855 esac
Guido van Rossum4e8af441994-08-19 15:33:54 +0000856fi
Guido van Rossum627b2d71993-12-24 10:39:16 +0000857
Skip Montanarodecc6a42003-01-01 20:07:49 +0000858AC_SUBST(BASECFLAGS)
Georg Brandlfcaf9102008-07-16 02:17:56 +0000859
860# The -arch flags for universal builds on OSX
861UNIVERSAL_ARCH_FLAGS=
862AC_SUBST(UNIVERSAL_ARCH_FLAGS)
863
Skip Montanarodecc6a42003-01-01 20:07:49 +0000864# tweak BASECFLAGS based on compiler and platform
865case $GCC in
866yes)
Martin v. Löwis70fedcd2003-07-07 21:26:19 +0000867 # Python violates C99 rules, by casting between incompatible
868 # pointer types. GCC may generate bad code as a result of that,
869 # so use -fno-strict-aliasing if supported.
870 AC_MSG_CHECKING(whether $CC accepts -fno-strict-aliasing)
871 ac_save_cc="$CC"
872 CC="$CC -fno-strict-aliasing"
873 AC_TRY_RUN([int main() { return 0; }],
874 ac_cv_no_strict_aliasing_ok=yes,
875 ac_cv_no_strict_aliasing_ok=no,
876 ac_cv_no_strict_aliasing_ok=no)
877 CC="$ac_save_cc"
878 AC_MSG_RESULT($ac_cv_no_strict_aliasing_ok)
879 if test $ac_cv_no_strict_aliasing_ok = yes
880 then
881 BASECFLAGS="$BASECFLAGS -fno-strict-aliasing"
882 fi
Mark Dickinsonb0e2b4c2008-04-26 20:48:56 +0000883
884 # if using gcc on alpha, use -mieee to get (near) full IEEE 754
885 # support. Without this, treatment of subnormals doesn't follow
886 # the standard.
887 case $ac_sys_machine in
888 alpha*)
889 BASECFLAGS="$BASECFLAGS -mieee"
890 ;;
891 esac
892
Skip Montanarodecc6a42003-01-01 20:07:49 +0000893 case $ac_sys_system in
894 SCO_SV*)
895 BASECFLAGS="$BASECFLAGS -m486 -DSCO5"
896 ;;
897 # is there any other compiler on Darwin besides gcc?
898 Darwin*)
Christian Heimesb186d002008-03-18 15:15:01 +0000899 # -Wno-long-double, -no-cpp-precomp, and -mno-fused-madd
900 # used to be here, but non-Apple gcc doesn't accept them.
Benjamin Peterson67c38e22008-07-17 16:10:34 +0000901
902
Thomas Wouters477c8d52006-05-27 19:21:47 +0000903 if test "${enable_universalsdk}"; then
Georg Brandlfcaf9102008-07-16 02:17:56 +0000904 UNIVERSAL_ARCH_FLAGS=""
905 if test "$UNIVERSAL_ARCHS" = "32-bit" ; then
906 UNIVERSAL_ARCH_FLAGS="-arch ppc -arch i386"
Benjamin Peterson6794aa32008-07-16 20:33:37 +0000907 ARCH_RUN_32BIT=""
Georg Brandlfcaf9102008-07-16 02:17:56 +0000908
909 elif test "$UNIVERSAL_ARCHS" = "64-bit" ; then
910 UNIVERSAL_ARCH_FLAGS="-arch ppc64 -arch x86_64"
Ronald Oussorend45ff2c2009-09-06 11:11:04 +0000911 ARCH_RUN_32BIT="true"
Georg Brandlfcaf9102008-07-16 02:17:56 +0000912
913 elif test "$UNIVERSAL_ARCHS" = "all" ; then
914 UNIVERSAL_ARCH_FLAGS="-arch i386 -arch ppc -arch ppc64 -arch x86_64"
Ronald Oussorenc8c89c42010-02-11 13:24:45 +0000915 ARCH_RUN_32BIT="/usr/bin/arch -i386 -ppc"
Georg Brandlfcaf9102008-07-16 02:17:56 +0000916
Ronald Oussoren856624d2009-09-08 07:13:53 +0000917 elif test "$UNIVERSAL_ARCHS" = "intel" ; then
918 UNIVERSAL_ARCH_FLAGS="-arch i386 -arch x86_64"
Ronald Oussorenc8c89c42010-02-11 13:24:45 +0000919 ARCH_RUN_32BIT="/usr/bin/arch -i386"
Ronald Oussoren856624d2009-09-08 07:13:53 +0000920
921 elif test "$UNIVERSAL_ARCHS" = "3-way" ; then
922 UNIVERSAL_ARCH_FLAGS="-arch i386 -arch ppc -arch x86_64"
Ronald Oussorenc8c89c42010-02-11 13:24:45 +0000923 ARCH_RUN_32BIT="/usr/bin/arch -i386 -ppc"
Ronald Oussoren856624d2009-09-08 07:13:53 +0000924
Georg Brandlfcaf9102008-07-16 02:17:56 +0000925 else
Ronald Oussoren5644eb72009-09-20 20:10:02 +0000926 AC_MSG_ERROR([proper usage is --with-universal-arch=32-bit|64-bit|all|intel|3-way])
Georg Brandlfcaf9102008-07-16 02:17:56 +0000927
928 fi
929
930
931 BASECFLAGS="${UNIVERSAL_ARCH_FLAGS} -isysroot ${UNIVERSALSDK} ${BASECFLAGS}"
Georg Brandl3dbca812008-07-23 16:10:53 +0000932 tgt=`sw_vers -productVersion | sed 's/\(10\.[[0-9]]*\).*/\1/'`
Benjamin Peterson67c38e22008-07-17 16:10:34 +0000933 if test "${UNIVERSALSDK}" != "/" -a "${tgt}" '>' '10.4' ; then
934 CFLAGS="${UNIVERSAL_ARCH_FLAGS} -isysroot ${UNIVERSALSDK} ${CFLAGS}"
935 fi
Thomas Wouters477c8d52006-05-27 19:21:47 +0000936 fi
937
Benjamin Peterson67c38e22008-07-17 16:10:34 +0000938 # Calculate the right deployment target for this build.
939 #
940 cur_target=`sw_vers -productVersion | sed 's/\(10\.[[0-9]]*\).*/\1/'`
941 if test ${cur_target} '>' 10.2; then
942 cur_target=10.3
Ronald Oussorend45ff2c2009-09-06 11:11:04 +0000943 if test ${enable_universalsdk}; then
944 if test "${UNIVERSAL_ARCHS}" = "all"; then
945 # Ensure that the default platform for a
946 # 4-way universal build is OSX 10.5,
947 # that's the first OS release where
948 # 4-way builds make sense.
949 cur_target='10.5'
Ronald Oussoren856624d2009-09-08 07:13:53 +0000950
951 elif test "${UNIVERSAL_ARCHS}" = "3-way"; then
952 cur_target='10.5'
953
954 elif test "${UNIVERSAL_ARCHS}" = "intel"; then
955 cur_target='10.5'
956
957 elif test "${UNIVERSAL_ARCHS}" = "64-bit"; then
958 cur_target='10.5'
Ronald Oussorend45ff2c2009-09-06 11:11:04 +0000959 fi
960 else
961 if test `arch` = "i386"; then
962 # On Intel macs default to a deployment
963 # target of 10.4, that's the first OSX
964 # release with Intel support.
965 cur_target="10.4"
966 fi
967 fi
Benjamin Peterson67c38e22008-07-17 16:10:34 +0000968 fi
969 CONFIGURE_MACOSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET-${cur_target}}
970
971 # Make sure that MACOSX_DEPLOYMENT_TARGET is set in the
972 # environment with a value that is the same as what we'll use
973 # in the Makefile to ensure that we'll get the same compiler
974 # environment during configure and build time.
975 MACOSX_DEPLOYMENT_TARGET="$CONFIGURE_MACOSX_DEPLOYMENT_TARGET"
976 export MACOSX_DEPLOYMENT_TARGET
977 EXPORT_MACOSX_DEPLOYMENT_TARGET=''
978
Skip Montanarodecc6a42003-01-01 20:07:49 +0000979 ;;
Thomas Wouters49fd7fa2006-04-21 10:40:58 +0000980 OSF*)
981 BASECFLAGS="$BASECFLAGS -mieee"
982 ;;
Skip Montanarodecc6a42003-01-01 20:07:49 +0000983 esac
984 ;;
985
986*)
987 case $ac_sys_system in
988 OpenUNIX*|UnixWare*)
989 BASECFLAGS="$BASECFLAGS -K pentium,host,inline,loop_unroll,alloca "
990 ;;
Neal Norwitzb44f1652003-05-26 14:11:55 +0000991 OSF*)
992 BASECFLAGS="$BASECFLAGS -ieee -std"
993 ;;
Skip Montanarodecc6a42003-01-01 20:07:49 +0000994 SCO_SV*)
995 BASECFLAGS="$BASECFLAGS -belf -Ki486 -DSCO5"
996 ;;
997 esac
998 ;;
999esac
1000
Fred Drakee1ceaa02001-12-04 20:55:47 +00001001if test "$Py_DEBUG" = 'true'; then
1002 :
1003else
1004 OPT="-DNDEBUG $OPT"
1005fi
1006
Guido van Rossum6f2260e1996-09-09 16:21:03 +00001007if test "$ac_arch_flags"
Guido van Rossumc5a39031996-07-31 17:35:03 +00001008then
Skip Montanarodecc6a42003-01-01 20:07:49 +00001009 BASECFLAGS="$BASECFLAGS $ac_arch_flags"
Guido van Rossumc5a39031996-07-31 17:35:03 +00001010fi
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001011
Neal Norwitz020c46a2006-01-07 21:39:28 +00001012# disable check for icc since it seems to pass, but generates a warning
1013if test "$CC" = icc
1014then
1015 ac_cv_opt_olimit_ok=no
1016fi
1017
Guido van Rossum91922671997-10-09 20:24:13 +00001018AC_MSG_CHECKING(whether $CC accepts -OPT:Olimit=0)
1019AC_CACHE_VAL(ac_cv_opt_olimit_ok,
1020[ac_save_cc="$CC"
1021CC="$CC -OPT:Olimit=0"
1022AC_TRY_RUN([int main() { return 0; }],
1023 ac_cv_opt_olimit_ok=yes,
Guido van Rossum3065c942001-09-17 04:03:14 +00001024 ac_cv_opt_olimit_ok=no,
Guido van Rossum91922671997-10-09 20:24:13 +00001025 ac_cv_opt_olimit_ok=no)
1026CC="$ac_save_cc"])
1027AC_MSG_RESULT($ac_cv_opt_olimit_ok)
Guido van Rossum2efa34b1997-10-23 17:43:11 +00001028if test $ac_cv_opt_olimit_ok = yes; then
Guido van Rossum5839e582000-10-09 19:52:35 +00001029 case $ac_sys_system in
Skip Montanarodecc6a42003-01-01 20:07:49 +00001030 # XXX is this branch needed? On MacOSX 10.2.2 the result of the
1031 # olimit_ok test is "no". Is it "yes" in some other Darwin-esque
1032 # environment?
1033 Darwin*)
1034 ;;
1035 *)
1036 BASECFLAGS="$BASECFLAGS -OPT:Olimit=0"
1037 ;;
Guido van Rossum5839e582000-10-09 19:52:35 +00001038 esac
Guido van Rossumf8678121998-07-07 21:05:09 +00001039else
1040 AC_MSG_CHECKING(whether $CC accepts -Olimit 1500)
1041 AC_CACHE_VAL(ac_cv_olimit_ok,
1042 [ac_save_cc="$CC"
1043 CC="$CC -Olimit 1500"
1044 AC_TRY_RUN([int main() { return 0; }],
1045 ac_cv_olimit_ok=yes,
Guido van Rossum3065c942001-09-17 04:03:14 +00001046 ac_cv_olimit_ok=no,
Guido van Rossumf8678121998-07-07 21:05:09 +00001047 ac_cv_olimit_ok=no)
1048 CC="$ac_save_cc"])
1049 AC_MSG_RESULT($ac_cv_olimit_ok)
1050 if test $ac_cv_olimit_ok = yes; then
Skip Montanarodecc6a42003-01-01 20:07:49 +00001051 BASECFLAGS="$BASECFLAGS -Olimit 1500"
Guido van Rossumf8678121998-07-07 21:05:09 +00001052 fi
Guido van Rossum201afe51997-05-14 21:14:44 +00001053fi
Guido van Rossumf8678121998-07-07 21:05:09 +00001054
Thomas Wouters89f507f2006-12-13 04:49:30 +00001055# Check whether GCC supports PyArg_ParseTuple format
1056if test "$GCC" = "yes"
1057then
1058 AC_MSG_CHECKING(whether gcc supports ParseTuple __format__)
1059 save_CFLAGS=$CFLAGS
1060 CFLAGS="$CFLAGS -Werror"
1061 AC_TRY_COMPILE([
1062 void f(char*,...)__attribute((format(PyArg_ParseTuple, 1, 2)));
1063 ],,
1064 AC_DEFINE(HAVE_ATTRIBUTE_FORMAT_PARSETUPLE, 1, [Define if GCC supports __attribute__((format(PyArg_ParseTuple, 2, 3)))])
1065 AC_MSG_RESULT(yes),
1066 AC_MSG_RESULT(no)
1067 )
1068 CFLAGS=$save_CFLAGS
1069fi
1070
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00001071# On some compilers, pthreads are available without further options
1072# (e.g. MacOS X). On some of these systems, the compiler will not
1073# complain if unaccepted options are passed (e.g. gcc on Mac OS X).
1074# So we have to see first whether pthreads are available without
1075# options before we can check whether -Kpthread improves anything.
1076AC_MSG_CHECKING(whether pthreads are available without options)
1077AC_CACHE_VAL(ac_cv_pthread_is_default,
1078[AC_TRY_RUN([
1079#include <pthread.h>
1080
1081void* routine(void* p){return NULL;}
1082
1083int main(){
1084 pthread_t p;
1085 if(pthread_create(&p,NULL,routine,NULL)!=0)
1086 return 1;
Jack Jansen4f8d0542002-03-08 13:43:01 +00001087 (void)pthread_detach(p);
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00001088 return 0;
1089}
1090],
Skip Montanarod8d39a02003-07-10 20:44:10 +00001091[
1092 ac_cv_pthread_is_default=yes
1093 ac_cv_kthread=no
1094 ac_cv_pthread=no
1095],
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00001096 ac_cv_pthread_is_default=no,
1097 ac_cv_pthread_is_default=no)
1098])
1099AC_MSG_RESULT($ac_cv_pthread_is_default)
1100
1101
1102if test $ac_cv_pthread_is_default = yes
1103then
1104 ac_cv_kpthread=no
1105else
Martin v. Löwis130fb172001-07-19 11:00:41 +00001106# -Kpthread, if available, provides the right #defines
1107# and linker options to make pthread_create available
Martin v. Löwis260aecc2001-10-07 08:14:41 +00001108# Some compilers won't report that they do not support -Kpthread,
1109# so we need to run a program to see whether it really made the
1110# function available.
Martin v. Löwis130fb172001-07-19 11:00:41 +00001111AC_MSG_CHECKING(whether $CC accepts -Kpthread)
1112AC_CACHE_VAL(ac_cv_kpthread,
1113[ac_save_cc="$CC"
1114CC="$CC -Kpthread"
Martin v. Löwis260aecc2001-10-07 08:14:41 +00001115AC_TRY_RUN([
1116#include <pthread.h>
1117
1118void* routine(void* p){return NULL;}
1119
1120int main(){
1121 pthread_t p;
1122 if(pthread_create(&p,NULL,routine,NULL)!=0)
1123 return 1;
Jack Jansen4f8d0542002-03-08 13:43:01 +00001124 (void)pthread_detach(p);
Martin v. Löwis260aecc2001-10-07 08:14:41 +00001125 return 0;
1126}
1127],
Martin v. Löwis130fb172001-07-19 11:00:41 +00001128 ac_cv_kpthread=yes,
Martin v. Löwis260aecc2001-10-07 08:14:41 +00001129 ac_cv_kpthread=no,
Martin v. Löwis130fb172001-07-19 11:00:41 +00001130 ac_cv_kpthread=no)
1131CC="$ac_save_cc"])
Martin v. Löwis130fb172001-07-19 11:00:41 +00001132AC_MSG_RESULT($ac_cv_kpthread)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00001133fi
Martin v. Löwis130fb172001-07-19 11:00:41 +00001134
Skip Montanarod8d39a02003-07-10 20:44:10 +00001135if test $ac_cv_kpthread = no -a $ac_cv_pthread_is_default = no
Martin v. Löwis5f433f02003-05-05 05:05:30 +00001136then
1137# -Kthread, if available, provides the right #defines
1138# and linker options to make pthread_create available
1139# Some compilers won't report that they do not support -Kthread,
1140# so we need to run a program to see whether it really made the
1141# function available.
1142AC_MSG_CHECKING(whether $CC accepts -Kthread)
1143AC_CACHE_VAL(ac_cv_kthread,
1144[ac_save_cc="$CC"
1145CC="$CC -Kthread"
1146AC_TRY_RUN([
1147#include <pthread.h>
1148
1149void* routine(void* p){return NULL;}
1150
1151int main(){
1152 pthread_t p;
1153 if(pthread_create(&p,NULL,routine,NULL)!=0)
1154 return 1;
1155 (void)pthread_detach(p);
1156 return 0;
1157}
1158],
1159 ac_cv_kthread=yes,
1160 ac_cv_kthread=no,
1161 ac_cv_kthread=no)
1162CC="$ac_save_cc"])
1163AC_MSG_RESULT($ac_cv_kthread)
1164fi
1165
Skip Montanarod8d39a02003-07-10 20:44:10 +00001166if test $ac_cv_kthread = no -a $ac_cv_pthread_is_default = no
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00001167then
1168# -pthread, if available, provides the right #defines
1169# and linker options to make pthread_create available
1170# Some compilers won't report that they do not support -pthread,
1171# so we need to run a program to see whether it really made the
1172# function available.
1173AC_MSG_CHECKING(whether $CC accepts -pthread)
1174AC_CACHE_VAL(ac_cv_thread,
1175[ac_save_cc="$CC"
1176CC="$CC -pthread"
1177AC_TRY_RUN([
1178#include <pthread.h>
1179
1180void* routine(void* p){return NULL;}
1181
1182int main(){
1183 pthread_t p;
1184 if(pthread_create(&p,NULL,routine,NULL)!=0)
1185 return 1;
1186 (void)pthread_detach(p);
1187 return 0;
1188}
1189],
1190 ac_cv_pthread=yes,
1191 ac_cv_pthread=no,
1192 ac_cv_pthread=no)
1193CC="$ac_save_cc"])
1194AC_MSG_RESULT($ac_cv_pthread)
1195fi
1196
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001197# If we have set a CC compiler flag for thread support then
1198# check if it works for CXX, too.
1199ac_cv_cxx_thread=no
1200if test ! -z "$CXX"
1201then
1202AC_MSG_CHECKING(whether $CXX also accepts flags for thread support)
1203ac_save_cxx="$CXX"
1204
1205if test "$ac_cv_kpthread" = "yes"
1206then
Martin v. Löwis519adae2003-09-20 10:47:47 +00001207 CXX="$CXX -Kpthread"
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001208 ac_cv_cxx_thread=yes
1209elif test "$ac_cv_kthread" = "yes"
1210then
1211 CXX="$CXX -Kthread"
1212 ac_cv_cxx_thread=yes
1213elif test "$ac_cv_pthread" = "yes"
1214then
1215 CXX="$CXX -pthread"
1216 ac_cv_cxx_thread=yes
1217fi
1218
1219if test $ac_cv_cxx_thread = yes
1220then
1221 echo 'void foo();int main(){foo();}void foo(){}' > conftest.$ac_ext
1222 $CXX -c conftest.$ac_ext 2>&5
1223 if $CXX -o conftest$ac_exeext conftest.$ac_objext 2>&5 \
1224 && test -s conftest$ac_exeext && ./conftest$ac_exeext
1225 then
1226 ac_cv_cxx_thread=yes
1227 else
1228 ac_cv_cxx_thread=no
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001229 fi
1230 rm -fr conftest*
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001231fi
Brett Cannonc601e0f2004-11-07 01:24:12 +00001232AC_MSG_RESULT($ac_cv_cxx_thread)
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001233fi
Martin v. Löwis519adae2003-09-20 10:47:47 +00001234CXX="$ac_save_cxx"
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001235
Fred Drakece81d592000-07-09 14:39:29 +00001236dnl # check for ANSI or K&R ("traditional") preprocessor
1237dnl AC_MSG_CHECKING(for C preprocessor type)
1238dnl AC_TRY_COMPILE([
1239dnl #define spam(name, doc) {#name, &name, #name "() -- " doc}
1240dnl int foo;
1241dnl struct {char *name; int *addr; char *doc;} desc = spam(foo, "something");
1242dnl ], [;], cpp_type=ansi, AC_DEFINE(HAVE_OLD_CPP) cpp_type=traditional)
1243dnl AC_MSG_RESULT($cpp_type)
Guido van Rossum300fda71996-08-19 21:58:16 +00001244
Guido van Rossum627b2d71993-12-24 10:39:16 +00001245# checks for header files
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001246AC_HEADER_STDC
Thomas Wouters0e3f5912006-08-11 14:57:12 +00001247AC_CHECK_HEADERS(asm/types.h conio.h curses.h direct.h dlfcn.h errno.h \
1248fcntl.h grp.h \
Christian Heimesbbe741d2008-03-28 10:53:29 +00001249ieeefp.h io.h langinfo.h libintl.h ncurses.h poll.h process.h pthread.h \
Thomas Wouters89f507f2006-12-13 04:49:30 +00001250shadow.h signal.h stdint.h stropts.h termios.h thread.h \
Martin v. Löwis14e73b12003-01-01 09:51:12 +00001251unistd.h utime.h \
Christian Heimes4fbc72b2008-03-22 00:47:35 +00001252sys/audioio.h sys/bsdtty.h sys/epoll.h sys/event.h sys/file.h sys/loadavg.h \
1253sys/lock.h sys/mkdev.h sys/modem.h \
Thomas Wouters0e3f5912006-08-11 14:57:12 +00001254sys/param.h sys/poll.h sys/select.h sys/socket.h sys/statvfs.h sys/stat.h \
Georg Brandlf78e02b2008-06-10 17:40:04 +00001255sys/termio.h sys/time.h \
Thomas Wouters0e3f5912006-08-11 14:57:12 +00001256sys/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 +00001257sys/resource.h netpacket/packet.h sysexits.h bluetooth.h \
Christian Heimes043d6f62008-01-07 17:19:16 +00001258bluetooth/bluetooth.h linux/tipc.h)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001259AC_HEADER_DIRENT
Martin v. Löwisdbe3f762002-10-10 14:27:30 +00001260AC_HEADER_MAJOR
Guido van Rossum627b2d71993-12-24 10:39:16 +00001261
Martin v. Löwisae2830c2004-09-18 09:54:52 +00001262# On Solaris, term.h requires curses.h
Martin v. Löwisfd1c69e72004-11-30 22:09:37 +00001263AC_CHECK_HEADERS(term.h,,,[
Martin v. Löwis5d52e782004-09-18 10:07:03 +00001264#ifdef HAVE_CURSES_H
1265#include <curses.h>
1266#endif
1267])
Martin v. Löwisae2830c2004-09-18 09:54:52 +00001268
Martin v. Löwis11017b12006-01-14 18:12:57 +00001269# On Linux, netlink.h requires asm/types.h
1270AC_CHECK_HEADERS(linux/netlink.h,,,[
1271#ifdef HAVE_ASM_TYPES_H
1272#include <asm/types.h>
1273#endif
1274#ifdef HAVE_SYS_SOCKET_H
1275#include <sys/socket.h>
1276#endif
1277])
1278
Guido van Rossum627b2d71993-12-24 10:39:16 +00001279# checks for typedefs
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001280was_it_defined=no
1281AC_MSG_CHECKING(for clock_t in time.h)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001282AC_EGREP_HEADER(clock_t, time.h, was_it_defined=yes, [
1283 AC_DEFINE(clock_t, long, [Define to 'long' if <time.h> doesn't define.])
1284])
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001285AC_MSG_RESULT($was_it_defined)
1286
Neal Norwitz11690112002-07-30 01:08:28 +00001287# Check whether using makedev requires defining _OSF_SOURCE
1288AC_MSG_CHECKING(for makedev)
Neal Norwitz6eb37f02003-02-23 23:28:15 +00001289AC_TRY_LINK([#include <sys/types.h> ],
Neal Norwitz11690112002-07-30 01:08:28 +00001290 [ makedev(0, 0) ],
1291 ac_cv_has_makedev=yes,
1292 ac_cv_has_makedev=no)
1293if test "$ac_cv_has_makedev" = "no"; then
1294 # we didn't link, try if _OSF_SOURCE will allow us to link
1295 AC_TRY_LINK([
Neal Norwitz6eb37f02003-02-23 23:28:15 +00001296#define _OSF_SOURCE 1
1297#include <sys/types.h>
Neal Norwitz11690112002-07-30 01:08:28 +00001298 ],
1299 [ makedev(0, 0) ],
1300 ac_cv_has_makedev=yes,
1301 ac_cv_has_makedev=no)
1302 if test "$ac_cv_has_makedev" = "yes"; then
1303 AC_DEFINE(_OSF_SOURCE, 1, [Define _OSF_SOURCE to get the makedev macro.])
1304 fi
1305fi
1306AC_MSG_RESULT($ac_cv_has_makedev)
1307if test "$ac_cv_has_makedev" = "yes"; then
1308 AC_DEFINE(HAVE_MAKEDEV, 1, [Define this if you have the makedev macro.])
1309fi
1310
Martin v. Löwis399a6892002-10-04 10:22:02 +00001311# Enabling LFS on Solaris (2.6 to 9) with gcc 2.95 triggers a bug in
1312# the system headers: If _XOPEN_SOURCE and _LARGEFILE_SOURCE are
1313# defined, but the compiler does not support pragma redefine_extname,
1314# and _LARGEFILE64_SOURCE is not defined, the headers refer to 64-bit
1315# structures (such as rlimit64) without declaring them. As a
1316# work-around, disable LFS on such configurations
1317
1318use_lfs=yes
1319AC_MSG_CHECKING(Solaris LFS bug)
1320AC_TRY_COMPILE([
1321#define _LARGEFILE_SOURCE 1
1322#define _FILE_OFFSET_BITS 64
1323#include <sys/resource.h>
1324],struct rlimit foo;,sol_lfs_bug=no,sol_lfs_bug=yes)
1325AC_MSG_RESULT($sol_lfs_bug)
1326if test "$sol_lfs_bug" = "yes"; then
1327 use_lfs=no
1328fi
1329
1330if test "$use_lfs" = "yes"; then
Guido van Rossum810cc512001-09-09 23:51:39 +00001331# Two defines needed to enable largefile support on various platforms
1332# These may affect some typedefs
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001333AC_DEFINE(_LARGEFILE_SOURCE, 1,
1334[This must be defined on some systems to enable large file support.])
1335AC_DEFINE(_FILE_OFFSET_BITS, 64,
1336[This must be set to 64 on some systems to enable large file support.])
Martin v. Löwis399a6892002-10-04 10:22:02 +00001337fi
Guido van Rossum810cc512001-09-09 23:51:39 +00001338
Guido van Rossum300fda71996-08-19 21:58:16 +00001339# Add some code to confdefs.h so that the test for off_t works on SCO
1340cat >> confdefs.h <<\EOF
1341#if defined(SCO_DS)
1342#undef _OFF_T
1343#endif
1344EOF
1345
Guido van Rossumef2255b2000-03-10 22:30:29 +00001346# Type availability checks
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001347AC_TYPE_MODE_T
1348AC_TYPE_OFF_T
1349AC_TYPE_PID_T
1350AC_TYPE_SIGNAL
1351AC_TYPE_SIZE_T
1352AC_TYPE_UID_T
Mark Dickinsonbd792642009-03-18 20:06:12 +00001353AC_TYPE_UINT32_T
1354AC_TYPE_UINT64_T
1355AC_TYPE_INT32_T
1356AC_TYPE_INT64_T
Christian Heimes400adb02008-02-01 08:12:03 +00001357AC_CHECK_TYPE(ssize_t,
Martin v. Löwis18e16552006-02-15 17:27:45 +00001358 AC_DEFINE(HAVE_SSIZE_T, 1, Define if your compiler provides ssize_t),,)
Guido van Rossum627b2d71993-12-24 10:39:16 +00001359
Guido van Rossumef2255b2000-03-10 22:30:29 +00001360# Sizes of various common basic types
Skip Montanarob9820a32004-01-17 00:16:12 +00001361# ANSI C requires sizeof(char) == 1, so no need to check it
Guido van Rossum3065c942001-09-17 04:03:14 +00001362AC_CHECK_SIZEOF(int, 4)
1363AC_CHECK_SIZEOF(long, 4)
1364AC_CHECK_SIZEOF(void *, 4)
Guido van Rossum3065c942001-09-17 04:03:14 +00001365AC_CHECK_SIZEOF(short, 2)
1366AC_CHECK_SIZEOF(float, 4)
1367AC_CHECK_SIZEOF(double, 8)
1368AC_CHECK_SIZEOF(fpos_t, 4)
Martin v. Löwis18e16552006-02-15 17:27:45 +00001369AC_CHECK_SIZEOF(size_t, 4)
Christian Heimes400adb02008-02-01 08:12:03 +00001370AC_CHECK_SIZEOF(pid_t, 4)
Guido van Rossumac405f61994-09-12 10:56:06 +00001371
Guido van Rossumec95c7b1998-08-04 17:59:56 +00001372AC_MSG_CHECKING(for long long support)
1373have_long_long=no
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001374AC_TRY_COMPILE([], [long long x; x = (long long)0;], [
1375 AC_DEFINE(HAVE_LONG_LONG, 1, [Define this if you have the type long long.])
1376 have_long_long=yes
1377])
Guido van Rossumec95c7b1998-08-04 17:59:56 +00001378AC_MSG_RESULT($have_long_long)
Guido van Rossum8bc1dfd1999-04-10 16:01:48 +00001379if test "$have_long_long" = yes ; then
Guido van Rossum3065c942001-09-17 04:03:14 +00001380AC_CHECK_SIZEOF(long long, 8)
Guido van Rossumec95c7b1998-08-04 17:59:56 +00001381fi
1382
Travis E. Oliphant9b307842007-10-12 22:06:37 +00001383AC_MSG_CHECKING(for long double support)
1384have_long_double=no
1385AC_TRY_COMPILE([], [long double x; x = (long double)0;], [
1386 AC_DEFINE(HAVE_LONG_DOUBLE, 1, [Define this if you have the type long double.])
1387 have_long_double=yes
1388])
1389AC_MSG_RESULT($have_long_double)
1390if test "$have_long_double" = yes ; then
1391AC_CHECK_SIZEOF(long double, 16)
1392fi
1393
1394
Thomas Woutersb2137042007-02-01 18:02:27 +00001395AC_MSG_CHECKING(for _Bool support)
1396have_c99_bool=no
1397AC_TRY_COMPILE([], [_Bool x; x = (_Bool)0;], [
1398 AC_DEFINE(HAVE_C99_BOOL, 1, [Define this if you have the type _Bool.])
1399 have_c99_bool=yes
1400])
1401AC_MSG_RESULT($have_c99_bool)
1402if test "$have_c99_bool" = yes ; then
1403AC_CHECK_SIZEOF(_Bool, 1)
1404fi
1405
Thomas Wouters89f507f2006-12-13 04:49:30 +00001406AC_CHECK_TYPES(uintptr_t,
1407 [AC_CHECK_SIZEOF(uintptr_t, 4)],
1408 [], [#ifdef HAVE_STDINT_H
1409 #include <stdint.h>
1410 #endif])
1411
Barry Warsawbc7c7f92000-08-18 04:53:33 +00001412
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001413# Hmph. AC_CHECK_SIZEOF() doesn't include <sys/types.h>.
1414AC_MSG_CHECKING(size of off_t)
1415AC_CACHE_VAL(ac_cv_sizeof_off_t,
1416[AC_TRY_RUN([#include <stdio.h>
1417#include <sys/types.h>
1418main()
1419{
1420 FILE *f=fopen("conftestval", "w");
1421 if (!f) exit(1);
1422 fprintf(f, "%d\n", sizeof(off_t));
1423 exit(0);
Guido van Rossum3065c942001-09-17 04:03:14 +00001424}],
1425ac_cv_sizeof_off_t=`cat conftestval`,
1426ac_cv_sizeof_off_t=0,
1427ac_cv_sizeof_off_t=4)
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001428])
1429AC_MSG_RESULT($ac_cv_sizeof_off_t)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001430AC_DEFINE_UNQUOTED(SIZEOF_OFF_T, $ac_cv_sizeof_off_t,
1431[The number of bytes in an off_t.])
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001432
1433AC_MSG_CHECKING(whether to enable large file support)
Mark Dickinsonb87f0d02009-12-31 21:25:02 +00001434if test "$have_long_long" = yes
1435then
1436if test "$ac_cv_sizeof_off_t" -gt "$ac_cv_sizeof_long" -a \
Guido van Rossum8bc1dfd1999-04-10 16:01:48 +00001437 "$ac_cv_sizeof_long_long" -ge "$ac_cv_sizeof_off_t"; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001438 AC_DEFINE(HAVE_LARGEFILE_SUPPORT, 1,
1439 [Defined to enable large file support when an off_t is bigger than a long
1440 and long long is available and at least as big as an off_t. You may need
1441 to add some flags for configuration and compilation to enable this mode.
1442 (For Solaris and Linux, the necessary defines are already defined.)])
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001443 AC_MSG_RESULT(yes)
1444else
1445 AC_MSG_RESULT(no)
1446fi
Mark Dickinsonb87f0d02009-12-31 21:25:02 +00001447else
1448 AC_MSG_RESULT(no)
1449fi
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001450
Fred Drakea3f6e912000-06-29 20:44:47 +00001451# AC_CHECK_SIZEOF() doesn't include <time.h>.
1452AC_MSG_CHECKING(size of time_t)
1453AC_CACHE_VAL(ac_cv_sizeof_time_t,
1454[AC_TRY_RUN([#include <stdio.h>
1455#include <time.h>
1456main()
1457{
1458 FILE *f=fopen("conftestval", "w");
1459 if (!f) exit(1);
1460 fprintf(f, "%d\n", sizeof(time_t));
1461 exit(0);
Guido van Rossum3065c942001-09-17 04:03:14 +00001462}],
1463ac_cv_sizeof_time_t=`cat conftestval`,
1464ac_cv_sizeof_time_t=0,
1465ac_cv_sizeof_time_t=4)
Fred Drakea3f6e912000-06-29 20:44:47 +00001466])
1467AC_MSG_RESULT($ac_cv_sizeof_time_t)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001468AC_DEFINE_UNQUOTED(SIZEOF_TIME_T, $ac_cv_sizeof_time_t,
1469[The number of bytes in a time_t.])
Fred Drakea3f6e912000-06-29 20:44:47 +00001470
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001471
Trent Mick635f6fb2000-08-23 21:33:05 +00001472# if have pthread_t then define SIZEOF_PTHREAD_T
Martin v. Löwis123cbd22001-07-19 14:21:10 +00001473ac_save_cc="$CC"
1474if test "$ac_cv_kpthread" = "yes"
1475then CC="$CC -Kpthread"
Martin v. Löwis5f433f02003-05-05 05:05:30 +00001476elif test "$ac_cv_kthread" = "yes"
1477then CC="$CC -Kthread"
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00001478elif test "$ac_cv_pthread" = "yes"
1479then CC="$CC -pthread"
Martin v. Löwis123cbd22001-07-19 14:21:10 +00001480fi
Trent Mick635f6fb2000-08-23 21:33:05 +00001481AC_MSG_CHECKING(for pthread_t)
1482have_pthread_t=no
Guido van Rossum12580492000-09-24 16:47:19 +00001483AC_TRY_COMPILE([#include <pthread.h>], [pthread_t x; x = *(pthread_t*)0;], have_pthread_t=yes)
Trent Mick635f6fb2000-08-23 21:33:05 +00001484AC_MSG_RESULT($have_pthread_t)
1485if test "$have_pthread_t" = yes ; then
1486 # AC_CHECK_SIZEOF() doesn't include <pthread.h>.
1487 AC_MSG_CHECKING(size of pthread_t)
1488 AC_CACHE_VAL(ac_cv_sizeof_pthread_t,
1489 [AC_TRY_RUN([#include <stdio.h>
Neal Norwitz6eb37f02003-02-23 23:28:15 +00001490#include <pthread.h>
Trent Mick635f6fb2000-08-23 21:33:05 +00001491 main()
1492 {
1493 FILE *f=fopen("conftestval", "w");
1494 if (!f) exit(1);
1495 fprintf(f, "%d\n", sizeof(pthread_t));
1496 exit(0);
Guido van Rossum3065c942001-09-17 04:03:14 +00001497 }],
1498 ac_cv_sizeof_pthread_t=`cat conftestval`,
1499 ac_cv_sizeof_pthread_t=0,
1500 ac_cv_sizeof_pthread_t=4)
Trent Mick635f6fb2000-08-23 21:33:05 +00001501 ])
1502 AC_MSG_RESULT($ac_cv_sizeof_pthread_t)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001503 AC_DEFINE_UNQUOTED(SIZEOF_PTHREAD_T, $ac_cv_sizeof_pthread_t,
1504 [The number of bytes in a pthread_t.])
Trent Mick635f6fb2000-08-23 21:33:05 +00001505fi
Martin v. Löwis123cbd22001-07-19 14:21:10 +00001506CC="$ac_save_cc"
Trent Mick635f6fb2000-08-23 21:33:05 +00001507
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001508
Georg Brandl93de2162008-07-16 02:21:06 +00001509
Bob Ippolito7026a0a2005-03-28 23:23:47 +00001510AC_SUBST(OTHER_LIBTOOL_OPT)
1511case $ac_sys_system/$ac_sys_release in
Thomas Wouters49fd7fa2006-04-21 10:40:58 +00001512 Darwin/@<:@01567@:>@\..*)
Bob Ippolito7026a0a2005-03-28 23:23:47 +00001513 OTHER_LIBTOOL_OPT="-prebind -seg1addr 0x10000000"
1514 ;;
1515 Darwin/*)
1516 OTHER_LIBTOOL_OPT=""
1517 ;;
1518esac
1519
Ronald Oussorend45ff2c2009-09-06 11:11:04 +00001520
1521ARCH_RUN_32BIT=""
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001522AC_SUBST(LIBTOOL_CRUFT)
1523case $ac_sys_system/$ac_sys_release in
Thomas Wouters49fd7fa2006-04-21 10:40:58 +00001524 Darwin/@<:@01567@:>@\..*)
Thomas Wouters477c8d52006-05-27 19:21:47 +00001525 LIBTOOL_CRUFT="-framework System -lcc_dynamic"
1526 if test "${enable_universalsdk}"; then
1527 :
1528 else
Ronald Oussorend45ff2c2009-09-06 11:11:04 +00001529 LIBTOOL_CRUFT="${LIBTOOL_CRUFT} -arch_only `arch`"
Thomas Wouters477c8d52006-05-27 19:21:47 +00001530 fi
Jack Jansenb36687a2004-07-16 08:43:47 +00001531 LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -install_name $(PYTHONFRAMEWORKINSTALLDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansena3891ea2001-09-07 14:25:12 +00001532 LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -compatibility_version $(VERSION) -current_version $(VERSION)';;
Guido van Rossum5839e582000-10-09 19:52:35 +00001533 Darwin/*)
Ronald Oussoren652f4de2010-02-07 11:54:03 +00001534 gcc_version=`gcc -dumpversion`
Bob Ippolito7026a0a2005-03-28 23:23:47 +00001535 if test ${gcc_version} '<' 4.0
1536 then
1537 LIBTOOL_CRUFT="-lcc_dynamic"
1538 else
1539 LIBTOOL_CRUFT=""
1540 fi
Ronald Oussoren856624d2009-09-08 07:13:53 +00001541 AC_TRY_RUN([
Ronald Oussorend45ff2c2009-09-06 11:11:04 +00001542 #include <unistd.h>
1543 int main(int argc, char*argv[])
1544 {
1545 if (sizeof(long) == 4) {
1546 return 0;
1547 } else {
1548 return 1;
1549 }
Ronald Oussoren856624d2009-09-08 07:13:53 +00001550 }
1551 ], ac_osx_32bit=yes,
Ronald Oussorend45ff2c2009-09-06 11:11:04 +00001552 ac_osx_32bit=no,
Ronald Oussoren856624d2009-09-08 07:13:53 +00001553 ac_osx_32bit=yes)
Ronald Oussorend45ff2c2009-09-06 11:11:04 +00001554
1555 if test "${ac_osx_32bit}" = "yes"; then
1556 case `arch` in
1557 i386)
1558 MACOSX_DEFAULT_ARCH="i386"
1559 ;;
1560 ppc)
1561 MACOSX_DEFAULT_ARCH="ppc"
1562 ;;
1563 *)
1564 AC_MSG_ERROR([Unexpected output of 'arch' on OSX])
1565 ;;
1566 esac
1567 else
1568 case `arch` in
1569 i386)
1570 MACOSX_DEFAULT_ARCH="x86_64"
1571 ;;
1572 ppc)
1573 MACOSX_DEFAULT_ARCH="ppc64"
1574 ;;
1575 *)
1576 AC_MSG_ERROR([Unexpected output of 'arch' on OSX])
1577 ;;
1578 esac
1579
1580 #ARCH_RUN_32BIT="true"
1581 fi
1582
1583 LIBTOOL_CRUFT=$LIBTOOL_CRUFT" -lSystem -lSystemStubs -arch_only ${MACOSX_DEFAULT_ARCH}"
Jack Jansenb36687a2004-07-16 08:43:47 +00001584 LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -install_name $(PYTHONFRAMEWORKINSTALLDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001585 LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -compatibility_version $(VERSION) -current_version $(VERSION)';;
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001586esac
1587
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001588AC_MSG_CHECKING(for --enable-framework)
1589if test "$enable_framework"
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001590then
Skip Montanarodecc6a42003-01-01 20:07:49 +00001591 BASECFLAGS="$BASECFLAGS -fno-common -dynamic"
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001592 # -F. is needed to allow linking to the framework while
1593 # in the build location.
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001594 AC_DEFINE(WITH_NEXT_FRAMEWORK, 1,
1595 [Define if you want to produce an OpenStep/Rhapsody framework
1596 (shared library plus accessory files).])
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001597 AC_MSG_RESULT(yes)
Ronald Oussoren99aab652009-06-08 21:22:57 +00001598 if test $enable_shared = "yes"
1599 then
1600 AC_MSG_ERROR([Specifying both --enable-shared and --enable-framework is not supported, use only --enable-framework instead])
1601 fi
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001602else
1603 AC_MSG_RESULT(no)
1604fi
1605
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001606AC_MSG_CHECKING(for dyld)
Jack Jansen9a66b6d2001-08-08 13:56:14 +00001607case $ac_sys_system/$ac_sys_release in
1608 Darwin/*)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001609 AC_DEFINE(WITH_DYLD, 1,
1610 [Define if you want to use the new-style (Openstep, Rhapsody, MacOS)
1611 dynamic linker (dyld) instead of the old-style (NextStep) dynamic
1612 linker (rld). Dyld is necessary to support frameworks.])
Jack Jansen9a66b6d2001-08-08 13:56:14 +00001613 AC_MSG_RESULT(always on for Darwin)
1614 ;;
1615 *)
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001616 AC_MSG_RESULT(no)
1617 ;;
Jack Jansen9a66b6d2001-08-08 13:56:14 +00001618esac
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001619
Guido van Rossumac405f61994-09-12 10:56:06 +00001620# Set info about shared libraries.
Guido van Rossumac405f61994-09-12 10:56:06 +00001621AC_SUBST(SO)
1622AC_SUBST(LDSHARED)
Neil Schemenauerb3531b82001-02-16 04:09:05 +00001623AC_SUBST(BLDSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00001624AC_SUBST(CCSHARED)
1625AC_SUBST(LINKFORSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00001626# SO is the extension of shared libraries `(including the dot!)
Guido van Rossumaef734b2001-01-10 21:09:12 +00001627# -- usually .so, .sl on HP-UX, .dll on Cygwin
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001628AC_MSG_CHECKING(SO)
Guido van Rossumac405f61994-09-12 10:56:06 +00001629if test -z "$SO"
1630then
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001631 case $ac_sys_system in
Thomas Wouters477c8d52006-05-27 19:21:47 +00001632 hp*|HP*)
1633 case `uname -m` in
1634 ia64) SO=.so;;
1635 *) SO=.sl;;
1636 esac
1637 ;;
Guido van Rossumaef734b2001-01-10 21:09:12 +00001638 CYGWIN*) SO=.dll;;
Guido van Rossum4b6b5791996-09-09 20:09:34 +00001639 *) SO=.so;;
Guido van Rossumac405f61994-09-12 10:56:06 +00001640 esac
Martin v. Löwis368de8f2003-06-14 14:46:38 +00001641else
1642 # this might also be a termcap variable, see #610332
1643 echo
1644 echo '====================================================================='
1645 echo '+ +'
1646 echo '+ WARNING: You have set SO in your environment. +'
1647 echo '+ Do you really mean to change the extension for shared libraries? +'
1648 echo '+ Continuing in 10 seconds to let you to ponder. +'
1649 echo '+ +'
1650 echo '====================================================================='
1651 sleep 10
Guido van Rossumac405f61994-09-12 10:56:06 +00001652fi
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001653AC_MSG_RESULT($SO)
Georg Brandlb1441c72009-01-03 22:33:39 +00001654
Thomas Wouters477c8d52006-05-27 19:21:47 +00001655AC_DEFINE_UNQUOTED(SHLIB_EXT, "$SO", [Define this to be extension of shared libraries (including the dot!).])
Guido van Rossumac405f61994-09-12 10:56:06 +00001656# LDSHARED is the ld *command* used to create shared library
Skip Montanaroce59c042004-01-17 14:19:44 +00001657# -- "cc -G" on SunOS 5.x, "ld -shared" on IRIX 5
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001658# (Shared libraries in this instance are shared modules to be loaded into
1659# Python, as opposed to building Python itself as a shared library.)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001660AC_MSG_CHECKING(LDSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00001661if test -z "$LDSHARED"
1662then
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001663 case $ac_sys_system/$ac_sys_release in
Neil Schemenauerb3531b82001-02-16 04:09:05 +00001664 AIX*)
1665 BLDSHARED="\$(srcdir)/Modules/ld_so_aix \$(CC) -bI:Modules/python.exp"
Guido van Rossumce608b02001-09-28 15:59:38 +00001666 LDSHARED="\$(BINLIBDEST)/config/ld_so_aix \$(CC) -bI:\$(BINLIBDEST)/config/python.exp"
Neil Schemenauerb3531b82001-02-16 04:09:05 +00001667 ;;
Guido van Rossum6100aaf1997-04-29 21:48:51 +00001668 IRIX/5*) LDSHARED="ld -shared";;
Guido van Rossum91922671997-10-09 20:24:13 +00001669 IRIX*/6*) LDSHARED="ld ${SGI_ABI} -shared -all";;
Greg Ward57c9a6632000-05-26 12:22:54 +00001670 SunOS/5*)
1671 if test "$GCC" = "yes"
Neil Schemenauer95052722001-02-19 18:17:33 +00001672 then LDSHARED='$(CC) -shared'
Martin v. Löwisaa5afe12002-10-07 06:21:41 +00001673 else LDSHARED='$(CC) -G';
Greg Ward57c9a6632000-05-26 12:22:54 +00001674 fi ;;
Thomas Hellerf44b9a12008-04-04 10:18:23 +00001675 hp*|HP*)
1676 if test "$GCC" = "yes"
1677 then LDSHARED='$(CC) -shared'
1678 else LDSHARED='ld -b';
1679 fi ;;
Guido van Rossum71001e41995-01-26 00:44:03 +00001680 OSF*) LDSHARED="ld -shared -expect_unresolved \"*\"";;
Jack Jansen418c3b12001-11-14 10:59:57 +00001681 Darwin/1.3*)
Jack Jansena3891ea2001-09-07 14:25:12 +00001682 LDSHARED='$(CC) $(LDFLAGS) -bundle'
1683 if test "$enable_framework" ; then
1684 # Link against the framework. All externals should be defined.
Jack Jansenda49e192005-01-07 13:08:22 +00001685 BLDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
1686 LDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansena3891ea2001-09-07 14:25:12 +00001687 else
1688 # No framework. Ignore undefined symbols, assuming they come from Python
Jack Jansen418c3b12001-11-14 10:59:57 +00001689 LDSHARED="$LDSHARED -undefined suppress"
Jack Jansena3891ea2001-09-07 14:25:12 +00001690 fi ;;
Jack Jansen6b08a402004-06-03 12:41:45 +00001691 Darwin/1.4*|Darwin/5.*|Darwin/6.*)
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001692 LDSHARED='$(CC) $(LDFLAGS) -bundle'
1693 if test "$enable_framework" ; then
1694 # Link against the framework. All externals should be defined.
Jack Jansenda49e192005-01-07 13:08:22 +00001695 BLDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
1696 LDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001697 else
Michael W. Hudson0c46c0c2002-03-07 09:58:56 +00001698 # No framework, use the Python app as bundle-loader
1699 BLDSHARED="$LDSHARED "'-bundle_loader $(BUILDPYTHON)'
Jack Jansenc28fc372003-02-25 13:14:43 +00001700 LDSHARED="$LDSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)'
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001701 fi ;;
Jack Jansen6b08a402004-06-03 12:41:45 +00001702 Darwin/*)
1703 # Use -undefined dynamic_lookup whenever possible (10.3 and later).
1704 # This allows an extension to be used in any Python
Thomas Wouters89d996e2007-09-08 17:39:28 +00001705
Georg Brandlfcaf9102008-07-16 02:17:56 +00001706 if test ${MACOSX_DEPLOYMENT_TARGET} '>' 10.2
Jack Jansen6b08a402004-06-03 12:41:45 +00001707 then
Thomas Wouters477c8d52006-05-27 19:21:47 +00001708 if test "${enable_universalsdk}"; then
Georg Brandlfcaf9102008-07-16 02:17:56 +00001709 LDFLAGS="${UNIVERSAL_ARCH_FLAGS} -isysroot ${UNIVERSALSDK} ${LDFLAGS}"
Thomas Wouters477c8d52006-05-27 19:21:47 +00001710 fi
Jack Jansen6b08a402004-06-03 12:41:45 +00001711 LDSHARED='$(CC) $(LDFLAGS) -bundle -undefined dynamic_lookup'
1712 BLDSHARED="$LDSHARED"
Jack Jansen6b08a402004-06-03 12:41:45 +00001713 else
1714 LDSHARED='$(CC) $(LDFLAGS) -bundle'
1715 if test "$enable_framework" ; then
1716 # Link against the framework. All externals should be defined.
Jack Jansenda49e192005-01-07 13:08:22 +00001717 BLDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
1718 LDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansen6b08a402004-06-03 12:41:45 +00001719 else
1720 # No framework, use the Python app as bundle-loader
1721 BLDSHARED="$LDSHARED "'-bundle_loader $(BUILDPYTHON)'
1722 LDSHARED="$LDSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)'
1723 fi
1724 fi
1725 ;;
Georg Brandlf78e02b2008-06-10 17:40:04 +00001726 Linux*|GNU*|QNX*) LDSHARED='$(CC) -shared';;
Guido van Rossum458e7fa1999-09-17 15:40:40 +00001727 BSD/OS*/4*) LDSHARED="gcc -shared";;
Thomas Wouters1ba5b3b2006-06-08 14:52:47 +00001728 FreeBSD*)
Jeremy Hylton4bcc7c52000-08-31 17:45:35 +00001729 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
Guido van Rossum0286ae82000-08-29 15:06:49 +00001730 then
Hye-Shik Chang33761492004-10-26 09:53:46 +00001731 LDSHARED="$CC -shared ${LDFLAGS}"
Guido van Rossum0286ae82000-08-29 15:06:49 +00001732 else
1733 LDSHARED="ld -Bshareable ${LDFLAGS}"
1734 fi;;
Thomas Wouters1ba5b3b2006-06-08 14:52:47 +00001735 OpenBSD*)
1736 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
1737 then
1738 LDSHARED='$(CC) -shared $(CCSHARED) ${LDFLAGS}'
1739 else
1740 case `uname -r` in
1741 [[01]].* | 2.[[0-7]] | 2.[[0-7]].*)
1742 LDSHARED="ld -Bshareable ${LDFLAGS}"
1743 ;;
1744 *)
1745 LDSHARED='$(CC) -shared $(CCSHARED) ${LDFLAGS}'
1746 ;;
1747 esac
1748 fi;;
Martin v. Löwis86d66262006-02-17 08:40:11 +00001749 NetBSD*|DragonFly*) LDSHARED="cc -shared ${LDFLAGS}";;
Martin v. Löwis25ae43b2001-10-07 08:39:18 +00001750 OpenUNIX*|UnixWare*)
Martin v. Löwisbec19582001-03-21 15:57:54 +00001751 if test "$GCC" = "yes"
Martin v. Löwis79f3c532002-12-11 12:51:58 +00001752 then LDSHARED='$(CC) -shared'
1753 else LDSHARED='$(CC) -G'
Martin v. Löwisbec19582001-03-21 15:57:54 +00001754 fi;;
Martin v. Löwis79f3c532002-12-11 12:51:58 +00001755 SCO_SV*) LDSHARED='$(CC) -Wl,-G,-Bexport';;
Guido van Rossumaef734b2001-01-10 21:09:12 +00001756 CYGWIN*) LDSHARED="gcc -shared -Wl,--enable-auto-image-base";;
Martin v. Löwisf90ae202002-06-11 06:22:31 +00001757 atheos*) LDSHARED="gcc -shared";;
Guido van Rossumac405f61994-09-12 10:56:06 +00001758 *) LDSHARED="ld";;
1759 esac
Guido van Rossumac405f61994-09-12 10:56:06 +00001760fi
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001761AC_MSG_RESULT($LDSHARED)
Neil Schemenauerb3531b82001-02-16 04:09:05 +00001762BLDSHARED=${BLDSHARED-$LDSHARED}
Guido van Rossumac405f61994-09-12 10:56:06 +00001763# CCSHARED are the C *flags* used to create objects to go into a shared
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001764# library (module) -- this is only needed for a few systems
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001765AC_MSG_CHECKING(CCSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00001766if test -z "$CCSHARED"
1767then
Guido van Rossum6100aaf1997-04-29 21:48:51 +00001768 case $ac_sys_system/$ac_sys_release in
Neil Schemenauer66252162001-02-19 04:47:42 +00001769 SunOS*) if test "$GCC" = yes;
Guido van Rossumd8faa362007-04-27 19:54:29 +00001770 then CCSHARED="-fPIC";
1771 elif test `uname -p` = sparc;
1772 then CCSHARED="-xcode=pic32";
1773 else CCSHARED="-Kpic";
1774 fi;;
Guido van Rossumaf07a441995-02-13 19:45:27 +00001775 hp*|HP*) if test "$GCC" = yes;
Martin v. Löwis703ad702001-09-05 08:36:52 +00001776 then CCSHARED="-fPIC";
Guido van Rossumaf07a441995-02-13 19:45:27 +00001777 else CCSHARED="+z";
1778 fi;;
Martin v. Löwisa6e97582002-01-01 18:41:33 +00001779 Linux*|GNU*) CCSHARED="-fPIC";;
Guido van Rossumf5957ea1999-10-05 21:59:33 +00001780 BSD/OS*/4*) CCSHARED="-fpic";;
Martin v. Löwis86d66262006-02-17 08:40:11 +00001781 FreeBSD*|NetBSD*|OpenBSD*|DragonFly*) CCSHARED="-fPIC";;
Martin v. Löwis25ae43b2001-10-07 08:39:18 +00001782 OpenUNIX*|UnixWare*)
Martin v. Löwisbec19582001-03-21 15:57:54 +00001783 if test "$GCC" = "yes"
1784 then CCSHARED="-fPIC"
Martin v. Löwis130fb172001-07-19 11:00:41 +00001785 else CCSHARED="-KPIC"
Martin v. Löwisbec19582001-03-21 15:57:54 +00001786 fi;;
Martin v. Löwis21ee4092002-09-30 16:19:48 +00001787 SCO_SV*)
1788 if test "$GCC" = "yes"
1789 then CCSHARED="-fPIC"
1790 else CCSHARED="-Kpic -belf"
1791 fi;;
Guido van Rossum2b5ca001998-03-05 15:41:09 +00001792 IRIX*/6*) case $CC in
1793 *gcc*) CCSHARED="-shared";;
Guido van Rossumee21f411998-04-20 18:51:54 +00001794 *) CCSHARED="";;
Guido van Rossum2b5ca001998-03-05 15:41:09 +00001795 esac;;
Martin v. Löwisf90ae202002-06-11 06:22:31 +00001796 atheos*) CCSHARED="-fPIC";;
Guido van Rossumac405f61994-09-12 10:56:06 +00001797 esac
Guido van Rossumac405f61994-09-12 10:56:06 +00001798fi
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001799AC_MSG_RESULT($CCSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00001800# LINKFORSHARED are the flags passed to the $(CC) command that links
Guido van Rossumb65a48e1995-06-14 18:21:23 +00001801# the python executable -- this is only needed for a few systems
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001802AC_MSG_CHECKING(LINKFORSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00001803if test -z "$LINKFORSHARED"
1804then
Guido van Rossum6100aaf1997-04-29 21:48:51 +00001805 case $ac_sys_system/$ac_sys_release in
Neil Schemenauerb3531b82001-02-16 04:09:05 +00001806 AIX*) LINKFORSHARED='-Wl,-bE:Modules/python.exp -lld';;
Guido van Rossum5dab3d81996-12-06 21:18:18 +00001807 hp*|HP*)
Martin v. Löwis1142de32002-03-29 16:28:31 +00001808 LINKFORSHARED="-Wl,-E -Wl,+s";;
1809# LINKFORSHARED="-Wl,-E -Wl,+s -Wl,+b\$(BINLIBDEST)/lib-dynload";;
Guido van Rossumf5957ea1999-10-05 21:59:33 +00001810 BSD/OS/4*) LINKFORSHARED="-Xlinker -export-dynamic";;
Martin v. Löwisa6e97582002-01-01 18:41:33 +00001811 Linux*|GNU*) LINKFORSHARED="-Xlinker -export-dynamic";;
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001812 # -u libsys_s pulls in all symbols in libsys
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001813 Darwin/*)
Benjamin Peterson9c80cac2009-05-23 16:34:23 +00001814 LINKFORSHARED="$extra_undefs -framework CoreFoundation"
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001815 if test "$enable_framework"
1816 then
Jack Jansenda49e192005-01-07 13:08:22 +00001817 LINKFORSHARED="$LINKFORSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001818 fi
Raymond Hettingerec6eb362004-11-05 07:02:59 +00001819 LINKFORSHARED="$LINKFORSHARED";;
Martin v. Löwis25ae43b2001-10-07 08:39:18 +00001820 OpenUNIX*|UnixWare*) LINKFORSHARED="-Wl,-Bexport";;
Martin v. Löwis21ee4092002-09-30 16:19:48 +00001821 SCO_SV*) LINKFORSHARED="-Wl,-Bexport";;
Fred Drake02706f52000-09-25 15:08:46 +00001822 ReliantUNIX*) LINKFORSHARED="-W1 -Blargedynsym";;
Martin v. Löwis86d66262006-02-17 08:40:11 +00001823 FreeBSD*|NetBSD*|OpenBSD*|DragonFly*)
Guido van Rossumdf693651999-01-07 21:50:41 +00001824 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
1825 then
1826 LINKFORSHARED="-Wl,--export-dynamic"
1827 fi;;
Guido van Rossum2b5ca001998-03-05 15:41:09 +00001828 SunOS/5*) case $CC in
1829 *gcc*)
Martin v. Löwisa4548572002-04-18 14:51:36 +00001830 if $CC -Xlinker --help 2>&1 | grep export-dynamic >/dev/null
Guido van Rossum8f4ceb11997-12-18 23:42:19 +00001831 then
1832 LINKFORSHARED="-Xlinker --export-dynamic"
Guido van Rossum2b5ca001998-03-05 15:41:09 +00001833 fi;;
1834 esac;;
Jason Tishler30765592003-09-04 11:04:06 +00001835 CYGWIN*)
1836 if test $enable_shared = "no"
1837 then
1838 LINKFORSHARED='-Wl,--out-implib=$(LDLIBRARY)'
1839 fi;;
Georg Brandlf78e02b2008-06-10 17:40:04 +00001840 QNX*)
1841 # -Wl,-E causes the symbols to be added to the dynamic
1842 # symbol table so that they can be found when a module
1843 # is loaded. -N 2048K causes the stack size to be set
1844 # to 2048 kilobytes so that the stack doesn't overflow
1845 # when running test_compile.py.
1846 LINKFORSHARED='-Wl,-E -N 2048K';;
Guido van Rossumac405f61994-09-12 10:56:06 +00001847 esac
Guido van Rossumac405f61994-09-12 10:56:06 +00001848fi
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001849AC_MSG_RESULT($LINKFORSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00001850
Georg Brandl93de2162008-07-16 02:21:06 +00001851
Neil Schemenauer61c51152001-01-26 16:18:16 +00001852AC_SUBST(CFLAGSFORSHARED)
1853AC_MSG_CHECKING(CFLAGSFORSHARED)
1854if test ! "$LIBRARY" = "$LDLIBRARY"
1855then
Neil Schemenauerd9cf41c2001-01-27 21:39:17 +00001856 case $ac_sys_system in
1857 CYGWIN*)
1858 # Cygwin needs CCSHARED when building extension DLLs
1859 # but not when building the interpreter DLL.
1860 CFLAGSFORSHARED='';;
1861 *)
1862 CFLAGSFORSHARED='$(CCSHARED)'
1863 esac
Neil Schemenauer61c51152001-01-26 16:18:16 +00001864fi
1865AC_MSG_RESULT($CFLAGSFORSHARED)
1866
Martin v. Löwisf90ae202002-06-11 06:22:31 +00001867# SHLIBS are libraries (except -lc and -lm) to link to the python shared
1868# library (with --enable-shared).
1869# For platforms on which shared libraries are not allowed to have unresolved
Martin v. Löwisd6359c52002-08-04 12:38:50 +00001870# symbols, this must be set to $(LIBS) (expanded by make). We do this even
1871# if it is not required, since it creates a dependency of the shared library
1872# to LIBS. This, in turn, means that applications linking the shared libpython
1873# don't need to link LIBS explicitly. The default should be only changed
1874# on systems where this approach causes problems.
Martin v. Löwisf90ae202002-06-11 06:22:31 +00001875AC_SUBST(SHLIBS)
1876AC_MSG_CHECKING(SHLIBS)
1877case "$ac_sys_system" in
Martin v. Löwisf90ae202002-06-11 06:22:31 +00001878 *)
Martin v. Löwisd6359c52002-08-04 12:38:50 +00001879 SHLIBS='$(LIBS)';;
Martin v. Löwisf90ae202002-06-11 06:22:31 +00001880esac
1881AC_MSG_RESULT($SHLIBS)
1882
1883
Guido van Rossum627b2d71993-12-24 10:39:16 +00001884# checks for libraries
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001885AC_CHECK_LIB(dl, dlopen) # Dynamic linking for SunOS/Solaris and SYSV
1886AC_CHECK_LIB(dld, shl_load) # Dynamic linking for HP-UX
Martin v. Löwis519adae2003-09-20 10:47:47 +00001887
Georg Brandleee31162008-12-07 15:15:22 +00001888# only check for sem_init if thread support is requested
Martin v. Löwis519adae2003-09-20 10:47:47 +00001889if test "$with_threads" = "yes" -o -z "$with_threads"; then
1890 AC_SEARCH_LIBS(sem_init, pthread rt posix4) # 'Real Time' functions on Solaris
1891 # posix4 on Solaris 2.6
1892 # pthread (first!) on Linux
1893fi
1894
Martin v. Löwis19d17342003-06-14 21:03:05 +00001895# check if we need libintl for locale functions
1896AC_CHECK_LIB(intl, textdomain,
Brett Cannonc6d936e2009-06-07 20:09:53 +00001897 [AC_DEFINE(WITH_LIBINTL, 1,
1898 [Define to 1 if libintl is needed for locale functions.])
1899 LIBS="-lintl $LIBS"])
Guido van Rossum0eefa3f1999-11-16 15:57:37 +00001900
1901# checks for system dependent C++ extensions support
1902case "$ac_sys_system" in
1903 AIX*) AC_MSG_CHECKING(for genuine AIX C++ extensions support)
1904 AC_TRY_LINK([#include "/usr/lpp/xlC/include/load.h"],
1905 [loadAndInit("", 0, "")],
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001906 [AC_DEFINE(AIX_GENUINE_CPLUSPLUS, 1,
1907 [Define for AIX if your compiler is a genuine IBM xlC/xlC_r
1908 and you want support for AIX C++ shared extension modules.])
Guido van Rossum0eefa3f1999-11-16 15:57:37 +00001909 AC_MSG_RESULT(yes)],
1910 [AC_MSG_RESULT(no)]);;
1911 *) ;;
1912esac
1913
Guido van Rossum70c7f481998-03-26 18:44:10 +00001914# Most SVR4 platforms (e.g. Solaris) need -lsocket and -lnsl.
Guido van Rossumf618d2c1995-01-17 16:36:13 +00001915AC_CHECK_LIB(nsl, t_open, [LIBS="-lnsl $LIBS"]) # SVR4
Guido van Rossumf618d2c1995-01-17 16:36:13 +00001916AC_CHECK_LIB(socket, socket, [LIBS="-lsocket $LIBS"], [], $LIBS) # SVR4 sockets
Skip Montanarob9949db2004-01-17 04:04:13 +00001917
Guido van Rossumc5a39031996-07-31 17:35:03 +00001918AC_MSG_CHECKING(for --with-libs)
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00001919AC_ARG_WITH(libs,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00001920 AC_HELP_STRING(--with-libs='lib1 ...', link against additional libs),
1921[
Guido van Rossumc5a39031996-07-31 17:35:03 +00001922AC_MSG_RESULT($withval)
1923LIBS="$withval $LIBS"
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00001924],
1925[AC_MSG_RESULT(no)])
Guido van Rossum627b2d71993-12-24 10:39:16 +00001926
Thomas Wouters49fd7fa2006-04-21 10:40:58 +00001927# Check for use of the system libffi library
1928AC_MSG_CHECKING(for --with-system-ffi)
1929AC_ARG_WITH(system_ffi,
1930 AC_HELP_STRING(--with-system-ffi, build _ctypes module using an installed ffi library))
1931
Thomas Wouters49fd7fa2006-04-21 10:40:58 +00001932AC_MSG_RESULT($with_system_ffi)
1933
Matthias Klose55708cc2009-04-30 08:06:49 +00001934# Check for --with-dbmliborder
1935AC_MSG_CHECKING(for --with-dbmliborder)
1936AC_ARG_WITH(dbmliborder,
1937 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'.]),
1938[
1939if test x$with_dbmliborder = xyes
1940then
1941AC_MSG_ERROR([proper usage is --with-dbmliborder=db1:db2:...])
1942else
1943 for db in `echo $with_dbmliborder | sed 's/:/ /g'`; do
1944 if test x$db != xndbm && test x$db != xgdbm && test x$db != xbdb
1945 then
1946 AC_MSG_ERROR([proper usage is --with-dbmliborder=db1:db2:...])
1947 fi
1948 done
1949fi])
1950AC_MSG_RESULT($with_dbmliborder)
1951
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00001952# Determine if signalmodule should be used.
1953AC_SUBST(USE_SIGNAL_MODULE)
1954AC_SUBST(SIGNAL_OBJS)
1955AC_MSG_CHECKING(for --with-signal-module)
1956AC_ARG_WITH(signal-module,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00001957 AC_HELP_STRING(--with-signal-module, disable/enable signal module))
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00001958
1959if test -z "$with_signal_module"
1960then with_signal_module="yes"
1961fi
1962AC_MSG_RESULT($with_signal_module)
1963
1964if test "${with_signal_module}" = "yes"; then
1965 USE_SIGNAL_MODULE=""
1966 SIGNAL_OBJS=""
1967else
1968 USE_SIGNAL_MODULE="#"
1969 SIGNAL_OBJS="Parser/intrcheck.o Python/sigcheck.o"
1970fi
1971
Guido van Rossum3d15bd82001-01-10 18:53:48 +00001972# This is used to generate Setup.config
Guido van Rossum009f7871997-12-04 00:51:42 +00001973AC_SUBST(USE_THREAD_MODULE)
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00001974USE_THREAD_MODULE=""
Guido van Rossum009f7871997-12-04 00:51:42 +00001975
Guido van Rossum54d93d41997-01-22 20:51:58 +00001976AC_MSG_CHECKING(for --with-dec-threads)
1977AC_SUBST(LDLAST)
1978AC_ARG_WITH(dec-threads,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00001979 AC_HELP_STRING(--with-dec-threads, use DEC Alpha/OSF1 thread-safe libraries),
1980[
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00001981AC_MSG_RESULT($withval)
Guido van Rossum54d93d41997-01-22 20:51:58 +00001982LDLAST=-threads
Guido van Rossumf78abae1997-01-21 22:02:36 +00001983if test "${with_thread+set}" != set; then
Guido van Rossum54d93d41997-01-22 20:51:58 +00001984 with_thread="$withval";
1985fi],
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00001986[AC_MSG_RESULT(no)])
Guido van Rossum54d93d41997-01-22 20:51:58 +00001987
Martin v. Löwis11437992002-04-12 09:54:03 +00001988# Templates for things AC_DEFINEd more than once.
1989# For a single AC_DEFINE, no template is needed.
1990AH_TEMPLATE(C_THREADS,[Define if you have the Mach cthreads package])
1991AH_TEMPLATE(_REENTRANT,
1992 [Define to force use of thread-safe errno, h_errno, and other functions])
1993AH_TEMPLATE(WITH_THREAD,
1994 [Define if you want to compile in rudimentary thread support])
1995
Guido van Rossum54d93d41997-01-22 20:51:58 +00001996AC_MSG_CHECKING(for --with-threads)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00001997dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00001998AC_ARG_WITH(threads,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00001999 AC_HELP_STRING(--with(out)-threads@<:@=DIRECTORY@:>@, disable/enable thread support))
Guido van Rossum54d93d41997-01-22 20:51:58 +00002000
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00002001# --with-thread is deprecated, but check for it anyway
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002002dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
Barry Warsawa0f3c5c2000-06-30 16:39:35 +00002003AC_ARG_WITH(thread,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002004 AC_HELP_STRING(--with(out)-thread@<:@=DIRECTORY@:>@, deprecated; use --with(out)-threads),
2005 [with_threads=$with_thread])
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00002006
2007if test -z "$with_threads"
2008then with_threads="yes"
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002009fi
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00002010AC_MSG_RESULT($with_threads)
Guido van Rossum6400c261997-05-22 20:34:27 +00002011
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002012AC_SUBST(THREADOBJ)
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00002013if test "$with_threads" = "no"
2014then
2015 USE_THREAD_MODULE="#"
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002016elif test "$ac_cv_pthread_is_default" = yes
2017then
2018 AC_DEFINE(WITH_THREAD)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002019 # Defining _REENTRANT on system with POSIX threads should not hurt.
2020 AC_DEFINE(_REENTRANT)
2021 posix_threads=yes
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002022 THREADOBJ="Python/thread.o"
Martin v. Löwis130fb172001-07-19 11:00:41 +00002023elif test "$ac_cv_kpthread" = "yes"
2024then
2025 CC="$CC -Kpthread"
Martin v. Löwis519adae2003-09-20 10:47:47 +00002026 if test "$ac_cv_cxx_thread" = "yes"; then
2027 CXX="$CXX -Kpthread"
2028 fi
Martin v. Löwis130fb172001-07-19 11:00:41 +00002029 AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002030 posix_threads=yes
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002031 THREADOBJ="Python/thread.o"
Martin v. Löwis5f433f02003-05-05 05:05:30 +00002032elif test "$ac_cv_kthread" = "yes"
2033then
2034 CC="$CC -Kthread"
Martin v. Löwis519adae2003-09-20 10:47:47 +00002035 if test "$ac_cv_cxx_thread" = "yes"; then
2036 CXX="$CXX -Kthread"
2037 fi
Martin v. Löwis5f433f02003-05-05 05:05:30 +00002038 AC_DEFINE(WITH_THREAD)
2039 posix_threads=yes
2040 THREADOBJ="Python/thread.o"
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002041elif test "$ac_cv_pthread" = "yes"
2042then
2043 CC="$CC -pthread"
Martin v. Löwis519adae2003-09-20 10:47:47 +00002044 if test "$ac_cv_cxx_thread" = "yes"; then
2045 CXX="$CXX -pthread"
2046 fi
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002047 AC_DEFINE(WITH_THREAD)
2048 posix_threads=yes
2049 THREADOBJ="Python/thread.o"
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00002050else
Martin v. Löwis130fb172001-07-19 11:00:41 +00002051 if test ! -z "$with_threads" -a -d "$with_threads"
2052 then LDFLAGS="$LDFLAGS -L$with_threads"
2053 fi
2054 if test ! -z "$withval" -a -d "$withval"
2055 then LDFLAGS="$LDFLAGS -L$withval"
2056 fi
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002057
2058 # According to the POSIX spec, a pthreads implementation must
Matthias Klosea2542be2004-08-16 11:35:51 +00002059 # define _POSIX_THREADS in unistd.h. Some apparently don't
2060 # (e.g. gnu pth with pthread emulation)
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002061 AC_MSG_CHECKING(for _POSIX_THREADS in unistd.h)
2062 AC_EGREP_CPP(yes,
Neal Norwitz6eb37f02003-02-23 23:28:15 +00002063 [
2064#include <unistd.h>
2065#ifdef _POSIX_THREADS
2066yes
2067#endif
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002068 ], unistd_defines_pthreads=yes, unistd_defines_pthreads=no)
2069 AC_MSG_RESULT($unistd_defines_pthreads)
2070
Martin v. Löwis130fb172001-07-19 11:00:41 +00002071 AC_DEFINE(_REENTRANT)
Martin v. Löwisa6e97582002-01-01 18:41:33 +00002072 AC_CHECK_HEADER(cthreads.h, [AC_DEFINE(WITH_THREAD)
2073 AC_DEFINE(C_THREADS)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002074 AC_DEFINE(HURD_C_THREADS, 1,
2075 [Define if you are using Mach cthreads directly under /include])
Martin v. Löwisa6e97582002-01-01 18:41:33 +00002076 LIBS="$LIBS -lthreads"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002077 THREADOBJ="Python/thread.o"],[
Martin v. Löwis130fb172001-07-19 11:00:41 +00002078 AC_CHECK_HEADER(mach/cthreads.h, [AC_DEFINE(WITH_THREAD)
2079 AC_DEFINE(C_THREADS)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002080 AC_DEFINE(MACH_C_THREADS, 1,
2081 [Define if you are using Mach cthreads under mach /])
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002082 THREADOBJ="Python/thread.o"],[
Martin v. Löwis130fb172001-07-19 11:00:41 +00002083 AC_MSG_CHECKING(for --with-pth)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002084 AC_ARG_WITH([pth],
2085 AC_HELP_STRING(--with-pth, use GNU pth threading libraries),
2086 [AC_MSG_RESULT($withval)
2087 AC_DEFINE([WITH_THREAD])
2088 AC_DEFINE([HAVE_PTH], 1,
2089 [Define if you have GNU PTH threads.])
2090 LIBS="-lpth $LIBS"
2091 THREADOBJ="Python/thread.o"],
2092 [AC_MSG_RESULT(no)
Martin v. Löwis8158b5a2001-10-08 13:17:28 +00002093
2094 # Just looking for pthread_create in libpthread is not enough:
2095 # on HP/UX, pthread.h renames pthread_create to a different symbol name.
2096 # So we really have to include pthread.h, and then link.
2097 _libs=$LIBS
2098 LIBS="$LIBS -lpthread"
2099 AC_MSG_CHECKING([for pthread_create in -lpthread])
2100 AC_TRY_LINK([#include <pthread.h>
2101
2102void * start_routine (void *arg) { exit (0); }], [
2103pthread_create (NULL, NULL, start_routine, NULL)], [
2104 AC_MSG_RESULT(yes)
2105 AC_DEFINE(WITH_THREAD)
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002106 posix_threads=yes
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002107 THREADOBJ="Python/thread.o"],[
Martin v. Löwis8158b5a2001-10-08 13:17:28 +00002108 LIBS=$_libs
Martin v. Löwis130fb172001-07-19 11:00:41 +00002109 AC_CHECK_FUNC(pthread_detach, [AC_DEFINE(WITH_THREAD)
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002110 posix_threads=yes
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002111 THREADOBJ="Python/thread.o"],[
Martin v. Löwisf90ae202002-06-11 06:22:31 +00002112 AC_CHECK_HEADER(atheos/threads.h, [AC_DEFINE(WITH_THREAD)
2113 AC_DEFINE(ATHEOS_THREADS, 1,
2114 [Define this if you have AtheOS threads.])
2115 THREADOBJ="Python/thread.o"],[
Martin v. Löwis130fb172001-07-19 11:00:41 +00002116 AC_CHECK_LIB(pthreads, pthread_create, [AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002117 posix_threads=yes
Martin v. Löwis130fb172001-07-19 11:00:41 +00002118 LIBS="$LIBS -lpthreads"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002119 THREADOBJ="Python/thread.o"], [
Martin v. Löwis130fb172001-07-19 11:00:41 +00002120 AC_CHECK_LIB(c_r, pthread_create, [AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002121 posix_threads=yes
Martin v. Löwis130fb172001-07-19 11:00:41 +00002122 LIBS="$LIBS -lc_r"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002123 THREADOBJ="Python/thread.o"], [
Martin v. Löwis130fb172001-07-19 11:00:41 +00002124 AC_CHECK_LIB(pthread, __pthread_create_system, [AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002125 posix_threads=yes
Martin v. Löwis130fb172001-07-19 11:00:41 +00002126 LIBS="$LIBS -lpthread"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002127 THREADOBJ="Python/thread.o"], [
Martin v. Löwis130fb172001-07-19 11:00:41 +00002128 AC_CHECK_LIB(cma, pthread_create, [AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002129 posix_threads=yes
Martin v. Löwis130fb172001-07-19 11:00:41 +00002130 LIBS="$LIBS -lcma"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002131 THREADOBJ="Python/thread.o"],[
Martin v. Löwis130fb172001-07-19 11:00:41 +00002132 USE_THREAD_MODULE="#"])
Skip Montanaroeb33e5a2007-08-17 12:57:41 +00002133 ])])])])])])])])])
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00002134
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002135 AC_CHECK_LIB(mpc, usconfig, [AC_DEFINE(WITH_THREAD)
2136 LIBS="$LIBS -lmpc"
2137 THREADOBJ="Python/thread.o"
2138 USE_THREAD_MODULE=""])
2139
2140 if test "$posix_threads" != "yes"; then
2141 AC_CHECK_LIB(thread, thr_create, [AC_DEFINE(WITH_THREAD)
2142 LIBS="$LIBS -lthread"
2143 THREADOBJ="Python/thread.o"
2144 USE_THREAD_MODULE=""])
2145 fi
2146
2147 if test "$USE_THREAD_MODULE" != "#"
2148 then
2149 # If the above checks didn't disable threads, (at least) OSF1
2150 # needs this '-threads' argument during linking.
2151 case $ac_sys_system in
2152 OSF1) LDLAST=-threads;;
2153 esac
2154 fi
2155fi
2156
2157if test "$posix_threads" = "yes"; then
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002158 if test "$unistd_defines_pthreads" = "no"; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002159 AC_DEFINE(_POSIX_THREADS, 1,
2160 [Define if you have POSIX threads,
2161 and your system does not define that.])
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002162 fi
2163
Martin v. Löwisdfc33fd2003-01-21 10:14:41 +00002164 # Bug 662787: Using semaphores causes unexplicable hangs on Solaris 8.
2165 case $ac_sys_system/$ac_sys_release in
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002166 SunOS/5.6) AC_DEFINE(HAVE_PTHREAD_DESTRUCTOR, 1,
2167 Defined for Solaris 2.6 bug in pthread header.)
2168 ;;
Martin v. Löwisdfc33fd2003-01-21 10:14:41 +00002169 SunOS/5.8) AC_DEFINE(HAVE_BROKEN_POSIX_SEMAPHORES, 1,
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002170 Define if the Posix semaphores do not work on your system)
2171 ;;
Christian Heimes7b3ce6a2008-01-31 14:31:45 +00002172 AIX/5) AC_DEFINE(HAVE_BROKEN_POSIX_SEMAPHORES, 1,
2173 Define if the Posix semaphores do not work on your system)
2174 ;;
Martin v. Löwisdfc33fd2003-01-21 10:14:41 +00002175 esac
2176
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002177 AC_MSG_CHECKING(if PTHREAD_SCOPE_SYSTEM is supported)
2178 AC_CACHE_VAL(ac_cv_pthread_system_supported,
2179 [AC_TRY_RUN([#include <pthread.h>
2180 void *foo(void *parm) {
2181 return NULL;
2182 }
2183 main() {
2184 pthread_attr_t attr;
Martin v. Löwisa82d3472002-02-24 16:05:05 +00002185 pthread_t id;
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002186 if (pthread_attr_init(&attr)) exit(-1);
2187 if (pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM)) exit(-1);
Martin v. Löwisa82d3472002-02-24 16:05:05 +00002188 if (pthread_create(&id, &attr, foo, NULL)) exit(-1);
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002189 exit(0);
Guido van Rossum3065c942001-09-17 04:03:14 +00002190 }],
2191 ac_cv_pthread_system_supported=yes,
2192 ac_cv_pthread_system_supported=no,
2193 ac_cv_pthread_system_supported=no)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002194 ])
2195 AC_MSG_RESULT($ac_cv_pthread_system_supported)
2196 if test "$ac_cv_pthread_system_supported" = "yes"; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002197 AC_DEFINE(PTHREAD_SYSTEM_SCHED_SUPPORTED, 1, [Defined if PTHREAD_SCOPE_SYSTEM supported.])
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002198 fi
Jason Tishlerfac083d2003-07-22 15:20:49 +00002199 AC_CHECK_FUNCS(pthread_sigmask,
2200 [case $ac_sys_system in
2201 CYGWIN*)
2202 AC_DEFINE(HAVE_BROKEN_PTHREAD_SIGMASK, 1,
2203 [Define if pthread_sigmask() does not work on your system.])
2204 ;;
2205 esac])
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00002206fi
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002207
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002208
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002209# Check for enable-ipv6
Martin v. Löwis11437992002-04-12 09:54:03 +00002210AH_TEMPLATE(ENABLE_IPV6, [Define if --enable-ipv6 is specified])
Martin v. Löwisa5f8bb52001-09-05 08:22:34 +00002211AC_MSG_CHECKING([if --enable-ipv6 is specified])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002212AC_ARG_ENABLE(ipv6,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002213[ --enable-ipv6 Enable ipv6 (with ipv4) support
2214 --disable-ipv6 Disable ipv6 support],
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002215[ case "$enableval" in
2216 no)
2217 AC_MSG_RESULT(no)
2218 ipv6=no
2219 ;;
2220 *) AC_MSG_RESULT(yes)
2221 AC_DEFINE(ENABLE_IPV6)
2222 ipv6=yes
2223 ;;
2224 esac ],
2225
Martin v. Löwisa5f8bb52001-09-05 08:22:34 +00002226[
2227dnl the check does not work on cross compilation case...
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002228 AC_TRY_RUN([ /* AF_INET6 available check */
2229#include <sys/types.h>
2230#include <sys/socket.h>
2231main()
2232{
2233 if (socket(AF_INET6, SOCK_STREAM, 0) < 0)
2234 exit(1);
2235 else
2236 exit(0);
2237}
2238],
2239 AC_MSG_RESULT(yes)
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002240 ipv6=yes,
2241 AC_MSG_RESULT(no)
2242 ipv6=no,
2243 AC_MSG_RESULT(no)
2244 ipv6=no
Martin v. Löwisa5f8bb52001-09-05 08:22:34 +00002245)
2246
2247if test "$ipv6" = "yes"; then
2248 AC_MSG_CHECKING(if RFC2553 API is available)
2249 AC_TRY_COMPILE([#include <sys/types.h>
2250#include <netinet/in.h>],
2251 [struct sockaddr_in6 x;
2252x.sin6_scope_id;],
2253 AC_MSG_RESULT(yes)
2254 ipv6=yes,
2255 AC_MSG_RESULT(no, IPv6 disabled)
2256 ipv6=no)
2257fi
2258
2259if test "$ipv6" = "yes"; then
2260 AC_DEFINE(ENABLE_IPV6)
2261fi
2262])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002263
2264ipv6type=unknown
2265ipv6lib=none
2266ipv6trylibc=no
2267
2268if test "$ipv6" = "yes"; then
2269 AC_MSG_CHECKING([ipv6 stack type])
Guido van Rossumb8552162001-09-05 14:58:11 +00002270 for i in inria kame linux-glibc linux-inet6 solaris toshiba v6d zeta;
2271 do
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002272 case $i in
2273 inria)
2274 dnl http://www.kame.net/
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002275 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002276#include <netinet/in.h>
2277#ifdef IPV6_INRIA_VERSION
2278yes
2279#endif],
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002280 [ipv6type=$i])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002281 ;;
2282 kame)
2283 dnl http://www.kame.net/
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002284 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002285#include <netinet/in.h>
2286#ifdef __KAME__
2287yes
2288#endif],
2289 [ipv6type=$i;
2290 ipv6lib=inet6
2291 ipv6libdir=/usr/local/v6/lib
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002292 ipv6trylibc=yes])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002293 ;;
2294 linux-glibc)
2295 dnl http://www.v6.linux.or.jp/
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002296 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002297#include <features.h>
2298#if defined(__GLIBC__) && ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1) || (__GLIBC__ > 2))
2299yes
2300#endif],
2301 [ipv6type=$i;
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002302 ipv6trylibc=yes])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002303 ;;
2304 linux-inet6)
2305 dnl http://www.v6.linux.or.jp/
2306 if test -d /usr/inet6; then
2307 ipv6type=$i
2308 ipv6lib=inet6
2309 ipv6libdir=/usr/inet6/lib
Skip Montanarodecc6a42003-01-01 20:07:49 +00002310 BASECFLAGS="-I/usr/inet6/include $BASECFLAGS"
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002311 fi
2312 ;;
2313 solaris)
2314 if test -f /etc/netconfig; then
2315 if /usr/xpg4/bin/grep -q tcp6 /etc/netconfig; then
2316 ipv6type=$i
2317 ipv6trylibc=yes
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002318 fi
2319 fi
2320 ;;
2321 toshiba)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002322 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002323#include <sys/param.h>
2324#ifdef _TOSHIBA_INET6
2325yes
2326#endif],
2327 [ipv6type=$i;
2328 ipv6lib=inet6;
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002329 ipv6libdir=/usr/local/v6/lib])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002330 ;;
2331 v6d)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002332 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002333#include </usr/local/v6/include/sys/v6config.h>
2334#ifdef __V6D__
2335yes
2336#endif],
2337 [ipv6type=$i;
2338 ipv6lib=v6;
2339 ipv6libdir=/usr/local/v6/lib;
Skip Montanarodecc6a42003-01-01 20:07:49 +00002340 BASECFLAGS="-I/usr/local/v6/include $BASECFLAGS"])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002341 ;;
2342 zeta)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002343 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002344#include <sys/param.h>
2345#ifdef _ZETA_MINAMI_INET6
2346yes
2347#endif],
2348 [ipv6type=$i;
2349 ipv6lib=inet6;
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002350 ipv6libdir=/usr/local/v6/lib])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002351 ;;
2352 esac
2353 if test "$ipv6type" != "unknown"; then
2354 break
2355 fi
2356 done
2357 AC_MSG_RESULT($ipv6type)
2358fi
2359
2360if test "$ipv6" = "yes" -a "$ipv6lib" != "none"; then
2361 if test -d $ipv6libdir -a -f $ipv6libdir/lib$ipv6lib.a; then
2362 LIBS="-L$ipv6libdir -l$ipv6lib $LIBS"
2363 echo "using lib$ipv6lib"
2364 else
2365 if test $ipv6trylibc = "yes"; then
2366 echo "using libc"
2367 else
2368 echo 'Fatal: no $ipv6lib library found. cannot continue.'
2369 echo "You need to fetch lib$ipv6lib.a from appropriate"
2370 echo 'ipv6 kit and compile beforehand.'
2371 exit 1
2372 fi
2373 fi
2374fi
2375
Georg Brandl93de2162008-07-16 02:21:06 +00002376AC_MSG_CHECKING(for OSX 10.5 SDK or later)
2377AC_TRY_COMPILE([#include <Carbon/Carbon.h>], FSIORefNum fRef = 0,
2378 AC_DEFINE(HAVE_OSX105_SDK, 1, Define if compiling using MacOS X 10.5 SDK or later.)
2379 AC_MSG_RESULT(yes),
2380 AC_MSG_RESULT(no)
2381)
2382
Martin v. Löwisa3fb4f72002-06-09 13:33:54 +00002383# Check for --with-doc-strings
2384AC_MSG_CHECKING(for --with-doc-strings)
2385AC_ARG_WITH(doc-strings,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002386 AC_HELP_STRING(--with(out)-doc-strings, disable/enable documentation strings))
Martin v. Löwisa3fb4f72002-06-09 13:33:54 +00002387
2388if test -z "$with_doc_strings"
2389then with_doc_strings="yes"
2390fi
2391if test "$with_doc_strings" != "no"
2392then
2393 AC_DEFINE(WITH_DOC_STRINGS, 1,
2394 [Define if you want documentation strings in extension modules])
2395fi
2396AC_MSG_RESULT($with_doc_strings)
2397
Neil Schemenauera35c6882001-02-27 04:45:05 +00002398# Check for Python-specific malloc support
Martin v. Löwisf30d60e2004-06-08 08:17:44 +00002399AC_MSG_CHECKING(for --with-tsc)
2400AC_ARG_WITH(tsc,
2401[ --with(out)-tsc enable/disable timestamp counter profile], [
2402if test "$withval" != no
2403then
2404 AC_DEFINE(WITH_TSC, 1,
2405 [Define to profile with the Pentium timestamp counter])
2406 AC_MSG_RESULT(yes)
2407else AC_MSG_RESULT(no)
2408fi],
2409[AC_MSG_RESULT(no)])
2410
2411# Check for Python-specific malloc support
Neil Schemenauera35c6882001-02-27 04:45:05 +00002412AC_MSG_CHECKING(for --with-pymalloc)
2413AC_ARG_WITH(pymalloc,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002414 AC_HELP_STRING(--with(out)-pymalloc, disable/enable specialized mallocs))
Neil Schemenauer16c22972002-03-22 15:34:49 +00002415
2416if test -z "$with_pymalloc"
2417then with_pymalloc="yes"
2418fi
2419if test "$with_pymalloc" != "no"
2420then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002421 AC_DEFINE(WITH_PYMALLOC, 1,
2422 [Define if you want to compile in Python-specific mallocs])
Neil Schemenauer16c22972002-03-22 15:34:49 +00002423fi
2424AC_MSG_RESULT($with_pymalloc)
Neil Schemenauera35c6882001-02-27 04:45:05 +00002425
Barry Warsawef82cd72000-06-30 16:21:01 +00002426# Check for --with-wctype-functions
2427AC_MSG_CHECKING(for --with-wctype-functions)
2428AC_ARG_WITH(wctype-functions,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002429 AC_HELP_STRING(--with-wctype-functions, use wctype.h functions),
2430[
Barry Warsawef82cd72000-06-30 16:21:01 +00002431if test "$withval" != no
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002432then
2433 AC_DEFINE(WANT_WCTYPE_FUNCTIONS, 1,
2434 [Define if you want wctype.h functions to be used instead of the
2435 one supplied by Python itself. (see Include/unicodectype.h).])
2436 AC_MSG_RESULT(yes)
Barry Warsawef82cd72000-06-30 16:21:01 +00002437else AC_MSG_RESULT(no)
2438fi],
2439[AC_MSG_RESULT(no)])
2440
Guido van Rossum68242b51996-05-28 22:53:03 +00002441# -I${DLINCLDIR} is added to the compile rule for importdl.o
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002442AC_SUBST(DLINCLDIR)
Guido van Rossum98935bf2001-09-05 19:13:16 +00002443DLINCLDIR=.
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002444
Guido van Rossume97ee181999-12-20 21:27:22 +00002445# the dlopen() function means we might want to use dynload_shlib.o. some
2446# platforms, such as AIX, have dlopen(), but don't want to use it.
Thomas Wouters3a584202000-08-05 23:28:51 +00002447AC_CHECK_FUNCS(dlopen)
Guido van Rossume97ee181999-12-20 21:27:22 +00002448
2449# DYNLOADFILE specifies which dynload_*.o file we will use for dynamic
2450# loading of modules.
2451AC_SUBST(DYNLOADFILE)
2452AC_MSG_CHECKING(DYNLOADFILE)
2453if test -z "$DYNLOADFILE"
2454then
2455 case $ac_sys_system/$ac_sys_release in
Martin v. Löwisc19c5a62003-11-18 20:00:44 +00002456 AIX*) # Use dynload_shlib.c and dlopen() if we have it; otherwise dynload_aix.c
2457 if test "$ac_cv_func_dlopen" = yes
2458 then DYNLOADFILE="dynload_shlib.o"
2459 else DYNLOADFILE="dynload_aix.o"
2460 fi
2461 ;;
Guido van Rossume97ee181999-12-20 21:27:22 +00002462 hp*|HP*) DYNLOADFILE="dynload_hpux.o";;
Thomas Wouters49fd7fa2006-04-21 10:40:58 +00002463 # Use dynload_next.c only on 10.2 and below, which don't have native dlopen()
2464 Darwin/@<:@0156@:>@\..*) DYNLOADFILE="dynload_next.o";;
Martin v. Löwisf90ae202002-06-11 06:22:31 +00002465 atheos*) DYNLOADFILE="dynload_atheos.o";;
Guido van Rossume97ee181999-12-20 21:27:22 +00002466 *)
2467 # use dynload_shlib.c and dlopen() if we have it; otherwise stub
2468 # out any dynamic loading
2469 if test "$ac_cv_func_dlopen" = yes
2470 then DYNLOADFILE="dynload_shlib.o"
2471 else DYNLOADFILE="dynload_stub.o"
2472 fi
2473 ;;
2474 esac
2475fi
2476AC_MSG_RESULT($DYNLOADFILE)
2477if test "$DYNLOADFILE" != "dynload_stub.o"
2478then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002479 AC_DEFINE(HAVE_DYNAMIC_LOADING, 1,
2480 [Defined when any dynamic module loading is enabled.])
Guido van Rossume97ee181999-12-20 21:27:22 +00002481fi
2482
Jack Jansenc49e5b72001-06-19 15:00:23 +00002483# MACHDEP_OBJS can be set to platform-specific object files needed by Python
2484
2485AC_SUBST(MACHDEP_OBJS)
2486AC_MSG_CHECKING(MACHDEP_OBJS)
2487if test -z "$MACHDEP_OBJS"
2488then
Jack Jansenb6e9cad2001-08-15 01:26:28 +00002489 MACHDEP_OBJS=$extra_machdep_objs
2490else
2491 MACHDEP_OBJS="$MACHDEP_OBJS $extra_machdep_objs"
Jack Jansenc49e5b72001-06-19 15:00:23 +00002492fi
Jack Jansenb6e9cad2001-08-15 01:26:28 +00002493AC_MSG_RESULT(MACHDEP_OBJS)
Jack Jansenc49e5b72001-06-19 15:00:23 +00002494
Guido van Rossum627b2d71993-12-24 10:39:16 +00002495# checks for library functions
Martin v. Löwis823725e2008-03-24 13:39:54 +00002496AC_CHECK_FUNCS(alarm setitimer getitimer bind_textdomain_codeset chown \
2497 clock confstr ctermid execv fchmod fchown fork fpathconf ftime ftruncate \
Martin v. Löwis438b5342002-12-27 10:16:42 +00002498 gai_strerror getgroups getlogin getloadavg getpeername getpgid getpid \
Martin v. Löwisc3001752005-01-23 09:27:24 +00002499 getpriority getpwent getspnam getspent getsid getwd \
Martin v. Löwis011e8422009-05-05 04:43:17 +00002500 kill killpg lchmod lchown lstat mbrtowc mkfifo mknod mktime \
Martin v. Löwisa5f09072002-10-11 05:37:59 +00002501 mremap nice pathconf pause plock poll pthread_init \
Guido van Rossum162e38c2003-02-19 15:25:10 +00002502 putenv readlink realpath \
Benjamin Peterson965ce872009-04-05 21:24:58 +00002503 select sem_open sem_timedwait sem_getvalue sem_unlink setegid seteuid \
2504 setgid \
Martin v. Löwis4daacb12003-03-28 18:37:01 +00002505 setlocale setregid setreuid setsid setpgid setpgrp setuid setvbuf snprintf \
Gregory P. Smith6c357262007-09-03 16:44:06 +00002506 sigaction siginterrupt sigrelse strftime strlcpy \
Michael W. Hudson34f20ea2002-05-27 15:08:24 +00002507 sysconf tcgetpgrp tcsetpgrp tempnam timegm times tmpfile tmpnam tmpnam_r \
Martin v. Löwis113a0852009-05-29 17:25:39 +00002508 truncate uname unsetenv utimes waitpid wait3 wait4 \
2509 wcscoll wcsftime wcsxfrm _getpty)
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00002510
Martin v. Löwisc8ad7cc2002-11-11 13:23:45 +00002511# For some functions, having a definition is not sufficient, since
2512# we want to take their address.
2513AC_MSG_CHECKING(for chroot)
2514AC_TRY_COMPILE([#include <unistd.h>], void *x=chroot,
2515 AC_DEFINE(HAVE_CHROOT, 1, Define if you have the 'chroot' function.)
2516 AC_MSG_RESULT(yes),
2517 AC_MSG_RESULT(no)
2518)
2519AC_MSG_CHECKING(for link)
2520AC_TRY_COMPILE([#include <unistd.h>], void *x=link,
2521 AC_DEFINE(HAVE_LINK, 1, Define if you have the 'link' function.)
2522 AC_MSG_RESULT(yes),
2523 AC_MSG_RESULT(no)
2524)
2525AC_MSG_CHECKING(for symlink)
2526AC_TRY_COMPILE([#include <unistd.h>], void *x=symlink,
2527 AC_DEFINE(HAVE_SYMLINK, 1, Define if you have the 'symlink' function.)
2528 AC_MSG_RESULT(yes),
2529 AC_MSG_RESULT(no)
2530)
Martin v. Löwisa64988c2003-09-20 15:30:20 +00002531AC_MSG_CHECKING(for fchdir)
2532AC_TRY_COMPILE([#include <unistd.h>], void *x=fchdir,
2533 AC_DEFINE(HAVE_FCHDIR, 1, Define if you have the 'fchdir' function.)
2534 AC_MSG_RESULT(yes),
2535 AC_MSG_RESULT(no)
2536)
2537AC_MSG_CHECKING(for fsync)
2538AC_TRY_COMPILE([#include <unistd.h>], void *x=fsync,
Skip Montanarod4fa8072003-09-25 14:49:15 +00002539 AC_DEFINE(HAVE_FSYNC, 1, Define if you have the 'fsync' function.)
Martin v. Löwisa64988c2003-09-20 15:30:20 +00002540 AC_MSG_RESULT(yes),
2541 AC_MSG_RESULT(no)
2542)
2543AC_MSG_CHECKING(for fdatasync)
2544AC_TRY_COMPILE([#include <unistd.h>], void *x=fdatasync,
2545 AC_DEFINE(HAVE_FDATASYNC, 1, Define if you have the 'fdatasync' function.)
2546 AC_MSG_RESULT(yes),
2547 AC_MSG_RESULT(no)
2548)
Christian Heimes4fbc72b2008-03-22 00:47:35 +00002549AC_MSG_CHECKING(for epoll)
2550AC_TRY_COMPILE([#include <sys/epoll.h>], void *x=epoll_create,
2551 AC_DEFINE(HAVE_EPOLL, 1, Define if you have the 'epoll' functions.)
2552 AC_MSG_RESULT(yes),
2553 AC_MSG_RESULT(no)
2554)
2555AC_MSG_CHECKING(for kqueue)
2556AC_TRY_COMPILE([
2557#include <sys/types.h>
2558#include <sys/event.h>
2559 ], int x=kqueue(),
2560 AC_DEFINE(HAVE_KQUEUE, 1, Define if you have the 'kqueue' functions.)
2561 AC_MSG_RESULT(yes),
2562 AC_MSG_RESULT(no)
2563)
Martin v. Löwisd5843682002-11-21 20:41:28 +00002564# On some systems (eg. FreeBSD 5), we would find a definition of the
2565# functions ctermid_r, setgroups in the library, but no prototype
2566# (e.g. because we use _XOPEN_SOURCE). See whether we can take their
2567# address to avoid compiler warnings and potential miscompilations
2568# because of the missing prototypes.
2569
2570AC_MSG_CHECKING(for ctermid_r)
2571AC_TRY_COMPILE([
2572#include "confdefs.h"
2573#include <stdio.h>
2574], void* p = ctermid_r,
2575 AC_DEFINE(HAVE_CTERMID_R, 1, Define if you have the 'ctermid_r' function.)
2576 AC_MSG_RESULT(yes),
2577 AC_MSG_RESULT(no)
2578)
2579
Martin v. Löwisf26d63b2003-03-30 17:23:49 +00002580AC_MSG_CHECKING(for flock)
2581AC_TRY_COMPILE([
2582#include "confdefs.h"
2583#include <sys/file.h>
2584], void* p = flock,
2585 AC_DEFINE(HAVE_FLOCK, 1, Define if you have the 'flock' function.)
2586 AC_MSG_RESULT(yes),
2587 AC_MSG_RESULT(no)
2588)
2589
2590AC_MSG_CHECKING(for getpagesize)
2591AC_TRY_COMPILE([
2592#include "confdefs.h"
2593#include <unistd.h>
2594], void* p = getpagesize,
2595 AC_DEFINE(HAVE_GETPAGESIZE, 1, Define if you have the 'getpagesize' function.)
2596 AC_MSG_RESULT(yes),
2597 AC_MSG_RESULT(no)
2598)
2599
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002600dnl check for true
2601AC_CHECK_PROGS(TRUE, true, /bin/true)
2602
Martin v. Löwis95c419b2003-05-03 12:10:48 +00002603dnl On some systems (e.g. Solaris 9), hstrerror and inet_aton are in -lresolv
2604dnl On others, they are in the C library, so we to take no action
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002605AC_CHECK_LIB(c, inet_aton, [$ac_cv_prog_TRUE],
Martin v. Löwis95c419b2003-05-03 12:10:48 +00002606 AC_CHECK_LIB(resolv, inet_aton)
2607)
2608
Christian Heimesd0764e22007-12-04 15:00:33 +00002609# On Tru64, chflags seems to be present, but calling it will
2610# exit Python
Benjamin Peterson08fd6722010-01-30 19:51:43 +00002611AC_CACHE_CHECK([for chflags], [ac_cv_have_chflags], [dnl
2612AC_TRY_RUN([[
Christian Heimesd0764e22007-12-04 15:00:33 +00002613#include <sys/stat.h>
2614#include <unistd.h>
2615int main(int argc, char*argv[])
2616{
2617 if(chflags(argv[0], 0) != 0)
2618 return 1;
2619 return 0;
2620}
Benjamin Peterson08fd6722010-01-30 19:51:43 +00002621]], ac_cv_have_chflags=yes,
2622 ac_cv_have_chflags=no,
2623 ac_cv_have_chflags=cross)
2624])
2625if test "$ac_cv_have_chflags" = cross ; then
2626 AC_CHECK_FUNC([chflags], [ac_cv_have_chflags="yes"], [ac_cv_have_chflags="no"])
2627fi
2628if test "$ac_cv_have_chflags" = yes ; then
2629 AC_DEFINE(HAVE_CHFLAGS, 1, Define to 1 if you have the `chflags' function.)
2630fi
Christian Heimesd0764e22007-12-04 15:00:33 +00002631
Benjamin Peterson08fd6722010-01-30 19:51:43 +00002632AC_CACHE_CHECK([for lchflags], [ac_cv_have_lchflags], [dnl
2633AC_TRY_RUN([[
Christian Heimesd0764e22007-12-04 15:00:33 +00002634#include <sys/stat.h>
2635#include <unistd.h>
2636int main(int argc, char*argv[])
2637{
2638 if(lchflags(argv[0], 0) != 0)
2639 return 1;
2640 return 0;
2641}
Benjamin Peterson08fd6722010-01-30 19:51:43 +00002642]], ac_cv_have_lchflags=yes,
2643 ac_cv_have_lchflags=no,
2644 ac_cv_have_lchflags=cross)
2645])
2646if test "$ac_cv_have_lchflags" = cross ; then
2647 AC_CHECK_FUNC([lchflags], [ac_cv_have_lchflags="yes"], [ac_cv_have_lchflags="no"])
2648fi
2649if test "$ac_cv_have_lchflags" = yes ; then
2650 AC_DEFINE(HAVE_LCHFLAGS, 1, Define to 1 if you have the `lchflags' function.)
2651fi
Christian Heimesd0764e22007-12-04 15:00:33 +00002652
Thomas Wouters0e3f5912006-08-11 14:57:12 +00002653dnl Check if system zlib has *Copy() functions
2654dnl
2655dnl On MacOSX the linker will search for dylibs on the entire linker path
2656dnl before searching for static libraries. setup.py adds -Wl,-search_paths_first
2657dnl to revert to a more traditional unix behaviour and make it possible to
2658dnl override the system libz with a local static library of libz. Temporarily
2659dnl add that flag to our CFLAGS as well to ensure that we check the version
2660dnl of libz that will be used by setup.py.
2661dnl The -L/usr/local/lib is needed as wel to get the same compilation
2662dnl environment as setup.py (and leaving it out can cause configure to use the
2663dnl wrong version of the library)
2664case $ac_sys_system/$ac_sys_release in
2665Darwin/*)
2666 _CUR_CFLAGS="${CFLAGS}"
2667 _CUR_LDFLAGS="${LDFLAGS}"
2668 CFLAGS="${CFLAGS} -Wl,-search_paths_first"
2669 LDFLAGS="${LDFLAGS} -Wl,-search_paths_first -L/usr/local/lib"
2670 ;;
2671esac
2672
2673AC_CHECK_LIB(z, inflateCopy, AC_DEFINE(HAVE_ZLIB_COPY, 1, Define if the zlib library has inflateCopy))
2674
2675case $ac_sys_system/$ac_sys_release in
2676Darwin/*)
2677 CFLAGS="${_CUR_CFLAGS}"
2678 LDFLAGS="${_CUR_LDFLAGS}"
2679 ;;
2680esac
2681
Martin v. Löwise9416172003-05-03 10:12:45 +00002682AC_MSG_CHECKING(for hstrerror)
Martin v. Löwis95c419b2003-05-03 12:10:48 +00002683AC_TRY_LINK([
Martin v. Löwise9416172003-05-03 10:12:45 +00002684#include "confdefs.h"
2685#include <netdb.h>
Martin v. Löwis95c419b2003-05-03 12:10:48 +00002686], void* p = hstrerror; hstrerror(0),
Martin v. Löwise9416172003-05-03 10:12:45 +00002687 AC_DEFINE(HAVE_HSTRERROR, 1, Define if you have the 'hstrerror' function.)
2688 AC_MSG_RESULT(yes),
2689 AC_MSG_RESULT(no)
2690)
2691
2692AC_MSG_CHECKING(for inet_aton)
Martin v. Löwis95c419b2003-05-03 12:10:48 +00002693AC_TRY_LINK([
Martin v. Löwise9416172003-05-03 10:12:45 +00002694#include "confdefs.h"
Martin v. Löwis86d66262006-02-17 08:40:11 +00002695#include <sys/types.h>
Martin v. Löwise9416172003-05-03 10:12:45 +00002696#include <sys/socket.h>
2697#include <netinet/in.h>
2698#include <arpa/inet.h>
Martin v. Löwis95c419b2003-05-03 12:10:48 +00002699], void* p = inet_aton;inet_aton(0,0),
Martin v. Löwise9416172003-05-03 10:12:45 +00002700 AC_DEFINE(HAVE_INET_ATON, 1, Define if you have the 'inet_aton' function.)
2701 AC_MSG_RESULT(yes),
2702 AC_MSG_RESULT(no)
2703)
2704
2705AC_MSG_CHECKING(for inet_pton)
2706AC_TRY_COMPILE([
2707#include "confdefs.h"
Martin v. Löwisf2e488d2003-05-05 22:00:11 +00002708#include <sys/types.h>
Martin v. Löwise9416172003-05-03 10:12:45 +00002709#include <sys/socket.h>
2710#include <netinet/in.h>
2711#include <arpa/inet.h>
2712], void* p = inet_pton,
2713 AC_DEFINE(HAVE_INET_PTON, 1, Define if you have the 'inet_pton' function.)
2714 AC_MSG_RESULT(yes),
2715 AC_MSG_RESULT(no)
2716)
2717
Martin v. Löwisd6640d42003-07-06 09:29:52 +00002718# On some systems, setgroups is in unistd.h, on others, in grp.h
Martin v. Löwisd5843682002-11-21 20:41:28 +00002719AC_MSG_CHECKING(for setgroups)
2720AC_TRY_COMPILE([
2721#include "confdefs.h"
Martin v. Löwisf2e488d2003-05-05 22:00:11 +00002722#include <unistd.h>
Martin v. Löwisd6640d42003-07-06 09:29:52 +00002723#ifdef HAVE_GRP_H
2724#include <grp.h>
2725#endif
Martin v. Löwisd5843682002-11-21 20:41:28 +00002726],
2727void* p = setgroups,
2728 AC_DEFINE(HAVE_SETGROUPS, 1, Define if you have the 'setgroups' function.)
2729 AC_MSG_RESULT(yes),
2730 AC_MSG_RESULT(no)
2731)
2732
Fred Drake8cef4cf2000-06-28 16:40:38 +00002733# check for openpty and forkpty
2734
Martin v. Löwisfd9a72a2006-01-08 10:07:33 +00002735AC_CHECK_FUNCS(openpty,,
2736 AC_CHECK_LIB(util,openpty,
2737 [AC_DEFINE(HAVE_OPENPTY) LIBS="$LIBS -lutil"],
2738 AC_CHECK_LIB(bsd,openpty, [AC_DEFINE(HAVE_OPENPTY) LIBS="$LIBS -lbsd"])
2739 )
2740)
2741AC_CHECK_FUNCS(forkpty,,
2742 AC_CHECK_LIB(util,forkpty,
2743 [AC_DEFINE(HAVE_FORKPTY) LIBS="$LIBS -lutil"],
2744 AC_CHECK_LIB(bsd,forkpty, [AC_DEFINE(HAVE_FORKPTY) LIBS="$LIBS -lbsd"])
2745 )
2746)
Fred Drake8cef4cf2000-06-28 16:40:38 +00002747
Christian Heimesb186d002008-03-18 15:15:01 +00002748# Stuff for expat.
2749AC_CHECK_FUNCS(memmove)
2750
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00002751# check for long file support functions
2752AC_CHECK_FUNCS(fseek64 fseeko fstatvfs ftell64 ftello statvfs)
2753
Christian Heimesb186d002008-03-18 15:15:01 +00002754AC_REPLACE_FUNCS(dup2 getcwd strdup)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002755AC_CHECK_FUNCS(getpgrp,
2756 AC_TRY_COMPILE([#include <unistd.h>],
2757 [getpgrp(0);],
2758 AC_DEFINE(GETPGRP_HAVE_ARG, 1,
2759 [Define if getpgrp() must be called as getpgrp(0).])
2760 )
2761)
Jack Jansen150753c2003-03-29 22:07:47 +00002762AC_CHECK_FUNCS(setpgrp,
2763 AC_TRY_COMPILE([#include <unistd.h>],
2764 [setpgrp(0,0);],
2765 AC_DEFINE(SETPGRP_HAVE_ARG, 1,
2766 [Define if setpgrp() must be called as setpgrp(0, 0).])
2767 )
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002768)
2769AC_CHECK_FUNCS(gettimeofday,
2770 AC_TRY_COMPILE([#include <sys/time.h>],
2771 [gettimeofday((struct timeval*)0,(struct timezone*)0);], ,
2772 AC_DEFINE(GETTIMEOFDAY_NO_TZ, 1,
2773 [Define if gettimeofday() does not have second (timezone) argument
2774 This is the case on Motorola V4 (R40V4.2)])
2775 )
2776)
Guido van Rossum627b2d71993-12-24 10:39:16 +00002777
Martin v. Löwisdbe3f762002-10-10 14:27:30 +00002778AC_MSG_CHECKING(for major, minor, and makedev)
Martin v. Löwise3271202002-11-07 07:42:30 +00002779AC_TRY_LINK([
Neal Norwitz6eb37f02003-02-23 23:28:15 +00002780#if defined(MAJOR_IN_MKDEV)
2781#include <sys/mkdev.h>
2782#elif defined(MAJOR_IN_SYSMACROS)
2783#include <sys/sysmacros.h>
2784#else
2785#include <sys/types.h>
2786#endif
Martin v. Löwisdbe3f762002-10-10 14:27:30 +00002787],[
2788 makedev(major(0),minor(0));
2789],[
2790 AC_DEFINE(HAVE_DEVICE_MACROS, 1,
2791 [Define to 1 if you have the device macros.])
2792 AC_MSG_RESULT(yes)
2793],[
2794 AC_MSG_RESULT(no)
2795])
Martin v. Löwis861a65b2001-10-24 14:36:00 +00002796
2797# On OSF/1 V5.1, getaddrinfo is available, but a define
2798# for [no]getaddrinfo in netdb.h.
2799AC_MSG_CHECKING(for getaddrinfo)
2800AC_TRY_LINK([
Martin v. Löwisc010b6d2001-11-09 17:50:52 +00002801#include <sys/types.h>
Martin v. Löwis861a65b2001-10-24 14:36:00 +00002802#include <sys/socket.h>
2803#include <netdb.h>
Martin v. Löwisc010b6d2001-11-09 17:50:52 +00002804#include <stdio.h>
Martin v. Löwis861a65b2001-10-24 14:36:00 +00002805],[
2806getaddrinfo(NULL, NULL, NULL, NULL);
2807], [
2808AC_MSG_RESULT(yes)
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00002809AC_MSG_CHECKING(getaddrinfo bug)
2810AC_TRY_RUN([
2811#include <sys/types.h>
2812#include <netdb.h>
2813#include <string.h>
2814#include <sys/socket.h>
2815#include <netinet/in.h>
2816
2817main()
2818{
2819 int passive, gaierr, inet4 = 0, inet6 = 0;
2820 struct addrinfo hints, *ai, *aitop;
2821 char straddr[INET6_ADDRSTRLEN], strport[16];
2822
2823 for (passive = 0; passive <= 1; passive++) {
2824 memset(&hints, 0, sizeof(hints));
2825 hints.ai_family = AF_UNSPEC;
2826 hints.ai_flags = passive ? AI_PASSIVE : 0;
2827 hints.ai_socktype = SOCK_STREAM;
Hye-Shik Chang54f94392004-04-14 07:55:31 +00002828 hints.ai_protocol = IPPROTO_TCP;
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00002829 if ((gaierr = getaddrinfo(NULL, "54321", &hints, &aitop)) != 0) {
2830 (void)gai_strerror(gaierr);
2831 goto bad;
2832 }
2833 for (ai = aitop; ai; ai = ai->ai_next) {
2834 if (ai->ai_addr == NULL ||
2835 ai->ai_addrlen == 0 ||
2836 getnameinfo(ai->ai_addr, ai->ai_addrlen,
2837 straddr, sizeof(straddr), strport, sizeof(strport),
2838 NI_NUMERICHOST|NI_NUMERICSERV) != 0) {
2839 goto bad;
2840 }
2841 switch (ai->ai_family) {
2842 case AF_INET:
2843 if (strcmp(strport, "54321") != 0) {
2844 goto bad;
2845 }
2846 if (passive) {
2847 if (strcmp(straddr, "0.0.0.0") != 0) {
2848 goto bad;
2849 }
2850 } else {
2851 if (strcmp(straddr, "127.0.0.1") != 0) {
2852 goto bad;
2853 }
2854 }
2855 inet4++;
2856 break;
2857 case AF_INET6:
2858 if (strcmp(strport, "54321") != 0) {
2859 goto bad;
2860 }
2861 if (passive) {
2862 if (strcmp(straddr, "::") != 0) {
2863 goto bad;
2864 }
2865 } else {
2866 if (strcmp(straddr, "::1") != 0) {
2867 goto bad;
2868 }
2869 }
2870 inet6++;
2871 break;
2872 case AF_UNSPEC:
2873 goto bad;
2874 break;
2875 default:
2876 /* another family support? */
2877 break;
2878 }
2879 }
2880 }
2881
2882 if (!(inet4 == 0 || inet4 == 2))
2883 goto bad;
2884 if (!(inet6 == 0 || inet6 == 2))
2885 goto bad;
2886
2887 if (aitop)
2888 freeaddrinfo(aitop);
2889 exit(0);
2890
2891 bad:
2892 if (aitop)
2893 freeaddrinfo(aitop);
2894 exit(1);
2895}
2896],
2897AC_MSG_RESULT(good)
2898buggygetaddrinfo=no,
2899AC_MSG_RESULT(buggy)
2900buggygetaddrinfo=yes,
2901AC_MSG_RESULT(buggy)
Martin v. Löwis861a65b2001-10-24 14:36:00 +00002902buggygetaddrinfo=yes)], [
2903AC_MSG_RESULT(no)
2904buggygetaddrinfo=yes
2905])
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00002906
2907if test "$buggygetaddrinfo" = "yes"; then
2908 if test "$ipv6" = "yes"; then
2909 echo 'Fatal: You must get working getaddrinfo() function.'
2910 echo ' or you can specify "--disable-ipv6"'.
2911 exit 1
2912 fi
Martin v. Löwis861a65b2001-10-24 14:36:00 +00002913else
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002914 AC_DEFINE(HAVE_GETADDRINFO, 1, [Define if you have the getaddrinfo function.])
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00002915fi
Thomas Woutersb0db85a2001-08-08 10:39:03 +00002916AC_CHECK_FUNCS(getnameinfo)
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00002917
Guido van Rossum627b2d71993-12-24 10:39:16 +00002918# checks for structures
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002919AC_HEADER_TIME
Guido van Rossum627b2d71993-12-24 10:39:16 +00002920AC_STRUCT_TM
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002921AC_STRUCT_TIMEZONE
Martin v. Löwis60a5d722002-10-16 20:28:25 +00002922AC_CHECK_MEMBERS([struct stat.st_rdev])
2923AC_CHECK_MEMBERS([struct stat.st_blksize])
Hye-Shik Chang5f937a72005-06-02 13:09:30 +00002924AC_CHECK_MEMBERS([struct stat.st_flags])
Martin v. Löwisebd9d5b2005-08-09 15:00:59 +00002925AC_CHECK_MEMBERS([struct stat.st_gen])
2926AC_CHECK_MEMBERS([struct stat.st_birthtime])
Guido van Rossum98bf58f2001-10-18 20:34:25 +00002927AC_STRUCT_ST_BLOCKS
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002928
2929AC_MSG_CHECKING(for time.h that defines altzone)
2930AC_CACHE_VAL(ac_cv_header_time_altzone,
2931[AC_TRY_COMPILE([#include <time.h>], [return altzone;],
2932 ac_cv_header_time_altzone=yes,
2933 ac_cv_header_time_altzone=no)])
2934AC_MSG_RESULT($ac_cv_header_time_altzone)
2935if test $ac_cv_header_time_altzone = yes; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002936 AC_DEFINE(HAVE_ALTZONE, 1, [Define this if your time.h defines altzone.])
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002937fi
2938
Guido van Rossum5739e7e1995-01-20 16:50:53 +00002939was_it_defined=no
2940AC_MSG_CHECKING(whether sys/select.h and sys/time.h may both be included)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002941AC_TRY_COMPILE([
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002942#include <sys/types.h>
2943#include <sys/select.h>
2944#include <sys/time.h>
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002945], [;], [
2946 AC_DEFINE(SYS_SELECT_WITH_SYS_TIME, 1,
2947 [Define if you can safely include both <sys/select.h> and <sys/time.h>
2948 (which you can't on SCO ODT 3.0).])
2949 was_it_defined=yes
2950])
Guido van Rossum5739e7e1995-01-20 16:50:53 +00002951AC_MSG_RESULT($was_it_defined)
Guido van Rossum627b2d71993-12-24 10:39:16 +00002952
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00002953AC_MSG_CHECKING(for addrinfo)
2954AC_CACHE_VAL(ac_cv_struct_addrinfo,
2955AC_TRY_COMPILE([
2956# include <netdb.h>],
2957 [struct addrinfo a],
2958 ac_cv_struct_addrinfo=yes,
2959 ac_cv_struct_addrinfo=no))
2960AC_MSG_RESULT($ac_cv_struct_addrinfo)
2961if test $ac_cv_struct_addrinfo = yes; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002962 AC_DEFINE(HAVE_ADDRINFO, 1, [struct addrinfo (netdb.h)])
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00002963fi
2964
2965AC_MSG_CHECKING(for sockaddr_storage)
2966AC_CACHE_VAL(ac_cv_struct_sockaddr_storage,
2967AC_TRY_COMPILE([
2968# include <sys/types.h>
2969# include <sys/socket.h>],
2970 [struct sockaddr_storage s],
2971 ac_cv_struct_sockaddr_storage=yes,
2972 ac_cv_struct_sockaddr_storage=no))
2973AC_MSG_RESULT($ac_cv_struct_sockaddr_storage)
2974if test $ac_cv_struct_sockaddr_storage = yes; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002975 AC_DEFINE(HAVE_SOCKADDR_STORAGE, 1, [struct sockaddr_storage (sys/socket.h)])
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00002976fi
2977
Guido van Rossum627b2d71993-12-24 10:39:16 +00002978# checks for compiler characteristics
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002979
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002980AC_C_CHAR_UNSIGNED
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002981AC_C_CONST
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002982
Guido van Rossum5739e7e1995-01-20 16:50:53 +00002983works=no
2984AC_MSG_CHECKING(for working volatile)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002985AC_TRY_COMPILE([],[volatile int x; x = 0;], works=yes,
2986 AC_DEFINE(volatile, [], [Define to empty if the keyword does not work.])
2987)
Guido van Rossum5739e7e1995-01-20 16:50:53 +00002988AC_MSG_RESULT($works)
Guido van Rossumdabb11b1994-10-11 15:04:27 +00002989
Guido van Rossum5739e7e1995-01-20 16:50:53 +00002990works=no
2991AC_MSG_CHECKING(for working signed char)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002992AC_TRY_COMPILE([], [signed char c;], works=yes,
2993 AC_DEFINE(signed, [], [Define to empty if the keyword does not work.])
2994)
Guido van Rossum5739e7e1995-01-20 16:50:53 +00002995AC_MSG_RESULT($works)
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002996
Guido van Rossum5739e7e1995-01-20 16:50:53 +00002997have_prototypes=no
2998AC_MSG_CHECKING(for prototypes)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002999AC_TRY_COMPILE([int foo(int x) { return 0; }], [return foo(10);],[
3000 AC_DEFINE(HAVE_PROTOTYPES, 1,
3001 [Define if your compiler supports function prototype])
3002 have_prototypes=yes
3003])
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003004AC_MSG_RESULT($have_prototypes)
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003005
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003006works=no
3007AC_MSG_CHECKING(for variable length prototypes and stdarg.h)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003008AC_TRY_COMPILE([
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003009#include <stdarg.h>
Guido van Rossum3f13e481996-08-30 20:58:11 +00003010int foo(int x, ...) {
3011 va_list va;
3012 va_start(va, x);
3013 va_arg(va, int);
3014 va_arg(va, char *);
3015 va_arg(va, double);
3016 return 0;
3017}
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003018], [return foo(10, "", 3.14);], [
3019 AC_DEFINE(HAVE_STDARG_PROTOTYPES, 1,
3020 [Define if your compiler supports variable length function prototypes
3021 (e.g. void fprintf(FILE *, char *, ...);) *and* <stdarg.h>])
3022 works=yes
3023])
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003024AC_MSG_RESULT($works)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003025
Dave Cole331708b2004-08-09 04:51:41 +00003026# check for socketpair
3027AC_MSG_CHECKING(for socketpair)
3028AC_TRY_COMPILE([
3029#include <sys/types.h>
3030#include <sys/socket.h>
3031], void *x=socketpair,
3032 AC_DEFINE(HAVE_SOCKETPAIR, 1, Define if you have the 'socketpair' function.)
3033 AC_MSG_RESULT(yes),
3034 AC_MSG_RESULT(no)
3035)
3036
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003037# check if sockaddr has sa_len member
3038AC_MSG_CHECKING(if sockaddr has sa_len member)
3039AC_TRY_COMPILE([#include <sys/types.h>
3040#include <sys/socket.h>],
3041[struct sockaddr x;
3042x.sa_len = 0;],
3043 AC_MSG_RESULT(yes)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003044 AC_DEFINE(HAVE_SOCKADDR_SA_LEN, 1, [Define if sockaddr has sa_len member]),
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003045 AC_MSG_RESULT(no))
3046
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003047va_list_is_array=no
3048AC_MSG_CHECKING(whether va_list is an array)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003049AC_TRY_COMPILE([
3050#ifdef HAVE_STDARG_PROTOTYPES
3051#include <stdarg.h>
3052#else
3053#include <varargs.h>
3054#endif
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003055], [va_list list1, list2; list1 = list2;], , [
3056 AC_DEFINE(VA_LIST_IS_ARRAY, 1, [Define if a va_list is an array of some kind])
3057 va_list_is_array=yes
3058])
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003059AC_MSG_RESULT($va_list_is_array)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003060
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003061# sigh -- gethostbyname_r is a mess; it can have 3, 5 or 6 arguments :-(
Martin v. Löwis11437992002-04-12 09:54:03 +00003062AH_TEMPLATE(HAVE_GETHOSTBYNAME_R,
3063 [Define this if you have some version of gethostbyname_r()])
3064
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003065AC_CHECK_FUNC(gethostbyname_r, [
3066 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
3067 AC_MSG_CHECKING([gethostbyname_r with 6 args])
3068 OLD_CFLAGS=$CFLAGS
3069 CFLAGS="$CFLAGS $MY_CPPFLAGS $MY_THREAD_CPPFLAGS $MY_CFLAGS"
3070 AC_TRY_COMPILE([
3071# include <netdb.h>
3072 ], [
3073 char *name;
3074 struct hostent *he, *res;
3075 char buffer[2048];
3076 int buflen = 2048;
3077 int h_errnop;
3078
3079 (void) gethostbyname_r(name, he, buffer, buflen, &res, &h_errnop)
3080 ], [
Guido van Rossum8db7d8b1999-03-23 16:40:33 +00003081 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003082 AC_DEFINE(HAVE_GETHOSTBYNAME_R_6_ARG, 1,
3083 [Define this if you have the 6-arg version of gethostbyname_r().])
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003084 AC_MSG_RESULT(yes)
3085 ], [
3086 AC_MSG_RESULT(no)
3087 AC_MSG_CHECKING([gethostbyname_r with 5 args])
3088 AC_TRY_COMPILE([
3089# include <netdb.h>
3090 ], [
3091 char *name;
3092 struct hostent *he;
3093 char buffer[2048];
3094 int buflen = 2048;
3095 int h_errnop;
3096
3097 (void) gethostbyname_r(name, he, buffer, buflen, &h_errnop)
3098 ], [
Guido van Rossum8db7d8b1999-03-23 16:40:33 +00003099 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003100 AC_DEFINE(HAVE_GETHOSTBYNAME_R_5_ARG, 1,
3101 [Define this if you have the 5-arg version of gethostbyname_r().])
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003102 AC_MSG_RESULT(yes)
3103 ], [
3104 AC_MSG_RESULT(no)
3105 AC_MSG_CHECKING([gethostbyname_r with 3 args])
3106 AC_TRY_COMPILE([
3107# include <netdb.h>
3108 ], [
3109 char *name;
3110 struct hostent *he;
3111 struct hostent_data data;
3112
3113 (void) gethostbyname_r(name, he, &data);
3114 ], [
Guido van Rossum8db7d8b1999-03-23 16:40:33 +00003115 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003116 AC_DEFINE(HAVE_GETHOSTBYNAME_R_3_ARG, 1,
3117 [Define this if you have the 3-arg version of gethostbyname_r().])
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003118 AC_MSG_RESULT(yes)
3119 ], [
3120 AC_MSG_RESULT(no)
3121 ])
3122 ])
3123 ])
3124 CFLAGS=$OLD_CFLAGS
3125], [
Thomas Wouters3a584202000-08-05 23:28:51 +00003126 AC_CHECK_FUNCS(gethostbyname)
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003127])
3128AC_SUBST(HAVE_GETHOSTBYNAME_R_6_ARG)
3129AC_SUBST(HAVE_GETHOSTBYNAME_R_5_ARG)
3130AC_SUBST(HAVE_GETHOSTBYNAME_R_3_ARG)
Guido van Rossum8db7d8b1999-03-23 16:40:33 +00003131AC_SUBST(HAVE_GETHOSTBYNAME_R)
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003132AC_SUBST(HAVE_GETHOSTBYNAME)
3133
Guido van Rossum627b2d71993-12-24 10:39:16 +00003134# checks for system services
3135# (none yet)
3136
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003137# Linux requires this for correct f.p. operations
Jeremy Hyltonbe28f5b2000-07-27 21:03:04 +00003138AC_CHECK_FUNC(__fpu_control,
3139 [],
3140 [AC_CHECK_LIB(ieee, __fpu_control)
3141])
Guido van Rossum627b2d71993-12-24 10:39:16 +00003142
Guido van Rossum93274221997-05-09 02:42:00 +00003143# Check for --with-fpectl
Guido van Rossum93274221997-05-09 02:42:00 +00003144AC_MSG_CHECKING(for --with-fpectl)
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00003145AC_ARG_WITH(fpectl,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003146 AC_HELP_STRING(--with-fpectl, enable SIGFPE catching),
3147[
Guido van Rossum93274221997-05-09 02:42:00 +00003148if test "$withval" != no
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003149then
3150 AC_DEFINE(WANT_SIGFPE_HANDLER, 1,
3151 [Define if you want SIGFPE handled (see Include/pyfpe.h).])
3152 AC_MSG_RESULT(yes)
Guido van Rossum93274221997-05-09 02:42:00 +00003153else AC_MSG_RESULT(no)
Guido van Rossumef2255b2000-03-10 22:30:29 +00003154fi],
3155[AC_MSG_RESULT(no)])
Guido van Rossum93274221997-05-09 02:42:00 +00003156
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003157# check for --with-libm=...
3158AC_SUBST(LIBM)
Guido van Rossum4b6b5791996-09-09 20:09:34 +00003159case $ac_sys_system in
Guido van Rossum3dc0a512000-10-05 18:00:06 +00003160Darwin) ;;
Guido van Rossum4b6b5791996-09-09 20:09:34 +00003161*) LIBM=-lm
3162esac
Guido van Rossum93274221997-05-09 02:42:00 +00003163AC_MSG_CHECKING(for --with-libm=STRING)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003164AC_ARG_WITH(libm,
3165 AC_HELP_STRING(--with-libm=STRING, math library),
3166[
Guido van Rossum93274221997-05-09 02:42:00 +00003167if test "$withval" = no
3168then LIBM=
3169 AC_MSG_RESULT(force LIBM empty)
3170elif test "$withval" != yes
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003171then LIBM=$withval
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003172 AC_MSG_RESULT(set LIBM="$withval")
3173else AC_MSG_ERROR([proper usage is --with-libm=STRING])
Guido van Rossum93274221997-05-09 02:42:00 +00003174fi],
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003175[AC_MSG_RESULT(default LIBM="$LIBM")])
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003176
3177# check for --with-libc=...
3178AC_SUBST(LIBC)
Guido van Rossum93274221997-05-09 02:42:00 +00003179AC_MSG_CHECKING(for --with-libc=STRING)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003180AC_ARG_WITH(libc,
3181 AC_HELP_STRING(--with-libc=STRING, C library),
3182[
Guido van Rossum93274221997-05-09 02:42:00 +00003183if test "$withval" = no
3184then LIBC=
3185 AC_MSG_RESULT(force LIBC empty)
3186elif test "$withval" != yes
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003187then LIBC=$withval
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003188 AC_MSG_RESULT(set LIBC="$withval")
3189else AC_MSG_ERROR([proper usage is --with-libc=STRING])
Guido van Rossum93274221997-05-09 02:42:00 +00003190fi],
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003191[AC_MSG_RESULT(default LIBC="$LIBC")])
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003192
Mark Dickinsonb08a53a2009-04-16 19:52:09 +00003193# **************************************************
3194# * Check for various properties of floating point *
3195# **************************************************
Christian Heimes81ee3ef2008-05-04 22:42:01 +00003196
Mark Dickinsonb08a53a2009-04-16 19:52:09 +00003197AC_MSG_CHECKING(whether C doubles are little-endian IEEE 754 binary64)
3198AC_CACHE_VAL(ac_cv_little_endian_double, [
3199AC_TRY_RUN([
3200#include <string.h>
3201int main() {
3202 double x = 9006104071832581.0;
3203 if (memcmp(&x, "\x05\x04\x03\x02\x01\xff\x3f\x43", 8) == 0)
3204 return 0;
3205 else
3206 return 1;
3207}
3208],
3209ac_cv_little_endian_double=yes,
3210ac_cv_little_endian_double=no,
3211ac_cv_little_endian_double=no)])
3212AC_MSG_RESULT($ac_cv_little_endian_double)
3213if test "$ac_cv_little_endian_double" = yes
3214then
3215 AC_DEFINE(DOUBLE_IS_LITTLE_ENDIAN_IEEE754, 1,
3216 [Define if C doubles are 64-bit IEEE 754 binary format, stored
3217 with the least significant byte first])
3218fi
3219
3220AC_MSG_CHECKING(whether C doubles are big-endian IEEE 754 binary64)
3221AC_CACHE_VAL(ac_cv_big_endian_double, [
3222AC_TRY_RUN([
3223#include <string.h>
3224int main() {
3225 double x = 9006104071832581.0;
3226 if (memcmp(&x, "\x43\x3f\xff\x01\x02\x03\x04\x05", 8) == 0)
3227 return 0;
3228 else
3229 return 1;
3230}
3231],
3232ac_cv_big_endian_double=yes,
3233ac_cv_big_endian_double=no,
3234ac_cv_big_endian_double=no)])
3235AC_MSG_RESULT($ac_cv_big_endian_double)
3236if test "$ac_cv_big_endian_double" = yes
3237then
3238 AC_DEFINE(DOUBLE_IS_BIG_ENDIAN_IEEE754, 1,
3239 [Define if C doubles are 64-bit IEEE 754 binary format, stored
3240 with the most significant byte first])
3241fi
3242
3243# Some ARM platforms use a mixed-endian representation for doubles.
3244# While Python doesn't currently have full support for these platforms
3245# (see e.g., issue 1762561), we can at least make sure that float <-> string
3246# conversions work.
3247AC_MSG_CHECKING(whether C doubles are ARM mixed-endian IEEE 754 binary64)
3248AC_CACHE_VAL(ac_cv_mixed_endian_double, [
3249AC_TRY_RUN([
3250#include <string.h>
3251int main() {
3252 double x = 9006104071832581.0;
3253 if (memcmp(&x, "\x01\xff\x3f\x43\x05\x04\x03\x02", 8) == 0)
3254 return 0;
3255 else
3256 return 1;
3257}
3258],
3259ac_cv_mixed_endian_double=yes,
3260ac_cv_mixed_endian_double=no,
3261ac_cv_mixed_endian_double=no)])
3262AC_MSG_RESULT($ac_cv_mixed_endian_double)
3263if test "$ac_cv_mixed_endian_double" = yes
3264then
3265 AC_DEFINE(DOUBLE_IS_ARM_MIXED_ENDIAN_IEEE754, 1,
3266 [Define if C doubles are 64-bit IEEE 754 binary format, stored
3267 in ARM mixed-endian order (byte order 45670123)])
3268fi
3269
Mark Dickinson7abf8d42009-04-18 20:17:52 +00003270# The short float repr introduced in Python 3.1 requires the
3271# correctly-rounded string <-> double conversion functions from
3272# Python/dtoa.c, which in turn require that the FPU uses 53-bit
3273# rounding; this is a problem on x86, where the x87 FPU has a default
3274# rounding precision of 64 bits. For gcc/x86, we try to fix this by
3275# using inline assembler to get and set the x87 FPU control word.
Mark Dickinsonb08a53a2009-04-16 19:52:09 +00003276if test "$GCC" = yes && test -n "`$CC -dM -E - </dev/null | grep i386`"
3277then
Mark Dickinson7abf8d42009-04-18 20:17:52 +00003278 # Check that it's okay to use gcc inline assembler to get and set
3279 # x87 control word. It should be, but you never know...
3280 AC_MSG_CHECKING(whether we can use gcc inline assembler to get and set x87 control word)
3281 AC_TRY_COMPILE([], [
3282 unsigned short cw;
3283 __asm__ __volatile__ ("fnstcw %0" : "=m" (cw));
3284 __asm__ __volatile__ ("fldcw %0" : : "m" (cw));
3285 ],
3286 [have_gcc_asm_for_x87=yes], [have_gcc_asm_for_x87=no])
3287 AC_MSG_RESULT($have_gcc_asm_for_x87)
3288 if test "$have_gcc_asm_for_x87" = yes
Mark Dickinsonb08a53a2009-04-16 19:52:09 +00003289 then
Mark Dickinson7abf8d42009-04-18 20:17:52 +00003290 AC_DEFINE(HAVE_GCC_ASM_FOR_X87, 1,
3291 [Define if we can use gcc inline assembler to get and set x87 control word])
Mark Dickinsonb08a53a2009-04-16 19:52:09 +00003292 fi
3293fi
Christian Heimes81ee3ef2008-05-04 22:42:01 +00003294
Mark Dickinson3dc7c6a2009-01-04 15:09:02 +00003295# Detect whether system arithmetic is subject to x87-style double
3296# rounding issues. The result of this test has little meaning on non
3297# IEEE 754 platforms. On IEEE 754, test should return 1 if rounding
3298# mode is round-to-nearest and double rounding issues are present, and
3299# 0 otherwise. See http://bugs.python.org/issue2937 for more info.
3300AC_MSG_CHECKING(for x87-style double rounding)
Mark Dickinsonb08a53a2009-04-16 19:52:09 +00003301# $BASECFLAGS may affect the result
3302ac_save_cc="$CC"
3303CC="$CC $BASECFLAGS"
Mark Dickinson3dc7c6a2009-01-04 15:09:02 +00003304AC_TRY_RUN([
3305#include <stdlib.h>
3306#include <math.h>
3307int main() {
3308 volatile double x, y, z;
3309 /* 1./(1-2**-53) -> 1+2**-52 (correct), 1.0 (double rounding) */
3310 x = 0.99999999999999989; /* 1-2**-53 */
3311 y = 1./x;
3312 if (y != 1.)
3313 exit(0);
3314 /* 1e16+2.99999 -> 1e16+2. (correct), 1e16+4. (double rounding) */
3315 x = 1e16;
3316 y = 2.99999;
3317 z = x + y;
3318 if (z != 1e16+4.)
3319 exit(0);
3320 /* both tests show evidence of double rounding */
3321 exit(1);
3322}
3323],
3324ac_cv_x87_double_rounding=no,
3325ac_cv_x87_double_rounding=yes,
Mark Dickinsonb08a53a2009-04-16 19:52:09 +00003326ac_cv_x87_double_rounding=no)
3327CC="$ac_save_cc"
Mark Dickinson3dc7c6a2009-01-04 15:09:02 +00003328AC_MSG_RESULT($ac_cv_x87_double_rounding)
3329if test "$ac_cv_x87_double_rounding" = yes
3330then
3331 AC_DEFINE(X87_DOUBLE_ROUNDING, 1,
3332 [Define if arithmetic is subject to x87-style double rounding issue])
3333fi
3334
Mark Dickinsonb08a53a2009-04-16 19:52:09 +00003335# ************************************
3336# * Check for mathematical functions *
3337# ************************************
3338
3339LIBS_SAVE=$LIBS
3340LIBS="$LIBS $LIBM"
3341
Christian Heimes81ee3ef2008-05-04 22:42:01 +00003342# On FreeBSD 6.2, it appears that tanh(-0.) returns 0. instead of
3343# -0. on some architectures.
3344AC_MSG_CHECKING(whether tanh preserves the sign of zero)
3345AC_CACHE_VAL(ac_cv_tanh_preserves_zero_sign, [
3346AC_TRY_RUN([
3347#include <math.h>
3348#include <stdlib.h>
3349int main() {
3350 /* return 0 if either negative zeros don't exist
3351 on this platform or if negative zeros exist
3352 and tanh(-0.) == -0. */
3353 if (atan2(0., -1.) == atan2(-0., -1.) ||
3354 atan2(tanh(-0.), -1.) == atan2(-0., -1.)) exit(0);
3355 else exit(1);
3356}
3357],
3358ac_cv_tanh_preserves_zero_sign=yes,
3359ac_cv_tanh_preserves_zero_sign=no,
3360ac_cv_tanh_preserves_zero_sign=no)])
3361AC_MSG_RESULT($ac_cv_tanh_preserves_zero_sign)
3362if test "$ac_cv_tanh_preserves_zero_sign" = yes
3363then
3364 AC_DEFINE(TANH_PRESERVES_ZERO_SIGN, 1,
3365 [Define if tanh(-0.) is -0., or if platform doesn't have signed zeros])
3366fi
3367
Mark Dickinsonf2537862009-04-18 13:58:18 +00003368AC_CHECK_FUNCS([acosh asinh atanh copysign expm1 finite hypot log1p round])
Mark Dickinson3dc7c6a2009-01-04 15:09:02 +00003369AC_CHECK_DECLS([isinf, isnan, isfinite], [], [], [[#include <math.h>]])
Christian Heimes99170a52007-12-19 02:07:34 +00003370
Guido van Rossumaf5b83e1995-01-04 19:02:35 +00003371LIBS=$LIBS_SAVE
3372
Mark Dickinson875ada42009-11-28 12:52:39 +00003373# For multiprocessing module, check that sem_open
3374# actually works. For FreeBSD versions <= 7.2,
3375# the kernel module that provides POSIX semaphores
3376# isn't loaded by default, so an attempt to call
3377# sem_open results in a 'Signal 12' error.
3378AC_MSG_CHECKING(whether POSIX semaphores are enabled)
3379AC_CACHE_VAL(ac_cv_posix_semaphores_enabled,
3380AC_TRY_RUN([
3381#include <unistd.h>
3382#include <fcntl.h>
3383#include <stdio.h>
3384#include <semaphore.h>
3385#include <sys/stat.h>
3386
3387int main(void) {
3388 sem_t *a = sem_open("/autoconf", O_CREAT, S_IRUSR|S_IWUSR, 0);
3389 if (a == SEM_FAILED) {
3390 perror("sem_open");
3391 return 1;
3392 }
3393 sem_close(a);
Mark Dickinson62eda4d2009-12-13 21:18:16 +00003394 sem_unlink("/autoconf");
Mark Dickinson875ada42009-11-28 12:52:39 +00003395 return 0;
3396}
3397], ac_cv_posix_semaphores_enabled=yes,
3398 ac_cv_posix_semaphores_enabled=no,
3399 ac_cv_posix_semaphores_enabled=yes)
3400)
3401AC_MSG_RESULT($ac_cv_posix_semaphores_enabled)
3402if test $ac_cv_posix_semaphores_enabled = no
3403then
3404 AC_DEFINE(POSIX_SEMAPHORES_NOT_ENABLED, 1,
3405 [Define if POSIX semaphores aren't enabled on your system])
3406fi
3407
Mark Dickinson10683072009-04-18 21:18:19 +00003408# Multiprocessing check for broken sem_getvalue
3409AC_MSG_CHECKING(for broken sem_getvalue)
3410AC_TRY_RUN([
3411#include <unistd.h>
3412#include <fcntl.h>
3413#include <stdio.h>
3414#include <semaphore.h>
3415#include <sys/stat.h>
3416
3417int main(void){
Mark Dickinson62eda4d2009-12-13 21:18:16 +00003418 sem_t *a = sem_open("/autocftw", O_CREAT, S_IRUSR|S_IWUSR, 0);
Mark Dickinson10683072009-04-18 21:18:19 +00003419 int count;
3420 int res;
3421 if(a==SEM_FAILED){
3422 perror("sem_open");
3423 return 1;
3424
3425 }
3426 res = sem_getvalue(a, &count);
3427 sem_close(a);
Mark Dickinson62eda4d2009-12-13 21:18:16 +00003428 sem_unlink("/autocftw");
Mark Dickinson10683072009-04-18 21:18:19 +00003429 return res==-1 ? 1 : 0;
3430}
3431]
3432,AC_MSG_RESULT(no),
3433 AC_MSG_RESULT(yes)
3434 AC_DEFINE(HAVE_BROKEN_SEM_GETVALUE, 1, define to 1 if your sem_getvalue is broken.)
3435)
3436
Mark Dickinsonbd792642009-03-18 20:06:12 +00003437# determine what size digit to use for Python's longs
3438AC_MSG_CHECKING([digit size for Python's longs])
3439AC_ARG_ENABLE(big-digits,
3440AC_HELP_STRING([--enable-big-digits@<:@=BITS@:>@],[use big digits for Python longs [[BITS=30]]]),
3441[case $enable_big_digits in
3442yes)
3443 enable_big_digits=30 ;;
3444no)
3445 enable_big_digits=15 ;;
3446[15|30])
3447 ;;
3448*)
3449 AC_MSG_ERROR([bad value $enable_big_digits for --enable-big-digits; value should be 15 or 30]) ;;
3450esac
3451AC_MSG_RESULT($enable_big_digits)
3452AC_DEFINE_UNQUOTED(PYLONG_BITS_IN_DIGIT, $enable_big_digits, [Define as the preferred size in bits of long digits])
3453],
3454[AC_MSG_RESULT(no value specified)])
3455
Guido van Rossumef2255b2000-03-10 22:30:29 +00003456# check for wchar.h
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003457AC_CHECK_HEADER(wchar.h, [
3458 AC_DEFINE(HAVE_WCHAR_H, 1,
3459 [Define if the compiler provides a wchar.h header file.])
3460 wchar_h="yes"
3461],
Guido van Rossumef2255b2000-03-10 22:30:29 +00003462wchar_h="no"
3463)
3464
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003465# determine wchar_t size
3466if test "$wchar_h" = yes
3467then
Guido van Rossum67b26592001-10-20 14:21:45 +00003468 AC_CHECK_SIZEOF(wchar_t, 4, [#include <wchar.h>])
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003469fi
3470
Martin v. Löwisfa3bdea2003-09-04 18:50:54 +00003471AC_MSG_CHECKING(for UCS-4 tcl)
3472have_ucs4_tcl=no
3473AC_TRY_COMPILE([
3474#include <tcl.h>
3475#if TCL_UTF_MAX != 6
3476# error "NOT UCS4_TCL"
3477#endif], [], [
3478 AC_DEFINE(HAVE_UCS4_TCL, 1, [Define this if you have tcl and TCL_UTF_MAX==6])
3479 have_ucs4_tcl=yes
3480])
3481AC_MSG_RESULT($have_ucs4_tcl)
3482
Marc-André Lemburgd7160f82003-09-22 11:14:40 +00003483# check whether wchar_t is signed or not
3484if test "$wchar_h" = yes
3485then
3486 # check whether wchar_t is signed or not
3487 AC_MSG_CHECKING(whether wchar_t is signed)
3488 AC_CACHE_VAL(ac_cv_wchar_t_signed, [
3489 AC_TRY_RUN([
3490 #include <wchar.h>
3491 int main()
3492 {
Thomas Wouters49fd7fa2006-04-21 10:40:58 +00003493 /* Success: exit code 0 */
3494 exit((((wchar_t) -1) < ((wchar_t) 0)) ? 0 : 1);
Marc-André Lemburgd7160f82003-09-22 11:14:40 +00003495 }
3496 ],
3497 ac_cv_wchar_t_signed=yes,
3498 ac_cv_wchar_t_signed=no,
3499 ac_cv_wchar_t_signed=yes)])
3500 AC_MSG_RESULT($ac_cv_wchar_t_signed)
3501fi
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003502
Georg Brandl52d168a2008-01-07 18:10:24 +00003503AC_MSG_CHECKING(what type to use for str)
3504AC_ARG_WITH(wide-unicode,
3505 AC_HELP_STRING(--with-wide-unicode, Use 4-byte Unicode characters (default is 2 bytes)),
3506[
3507if test "$withval" != no
3508then unicode_size="4"
3509else unicode_size="2"
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003510fi
Georg Brandl52d168a2008-01-07 18:10:24 +00003511],
3512[
3513case "$have_ucs4_tcl" in
3514 yes) unicode_size="4" ;;
3515 *) unicode_size="2" ;;
3516esac
3517])
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003518
Martin v. Löwis0036cba2002-04-12 09:58:45 +00003519AH_TEMPLATE(Py_UNICODE_SIZE,
3520 [Define as the size of the unicode type.])
Georg Brandl52d168a2008-01-07 18:10:24 +00003521case "$unicode_size" in
3522 4) AC_DEFINE(Py_UNICODE_SIZE, 4) ;;
3523 *) AC_DEFINE(Py_UNICODE_SIZE, 2) ;;
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003524esac
3525
Martin v. Löwis11437992002-04-12 09:54:03 +00003526AH_TEMPLATE(PY_UNICODE_TYPE,
3527 [Define as the integral type used for Unicode representation.])
Martin v. Löwis0036cba2002-04-12 09:58:45 +00003528
Georg Brandl52d168a2008-01-07 18:10:24 +00003529# wchar_t is only usable if it maps to an unsigned type
3530if test "$unicode_size" = "$ac_cv_sizeof_wchar_t" \
Matthias Klose7dbeed72004-12-24 08:22:17 +00003531 -a "$ac_cv_wchar_t_signed" = "no"
Georg Brandl52d168a2008-01-07 18:10:24 +00003532then
3533 PY_UNICODE_TYPE="wchar_t"
3534 AC_DEFINE(HAVE_USABLE_WCHAR_T, 1,
3535 [Define if you have a useable wchar_t type defined in wchar.h; useable
3536 means wchar_t must be an unsigned type with at least 16 bits. (see
3537 Include/unicodeobject.h).])
3538 AC_DEFINE(PY_UNICODE_TYPE,wchar_t)
3539elif test "$ac_cv_sizeof_short" = "$unicode_size"
3540then
3541 PY_UNICODE_TYPE="unsigned short"
3542 AC_DEFINE(PY_UNICODE_TYPE,unsigned short)
3543elif test "$ac_cv_sizeof_long" = "$unicode_size"
3544then
3545 PY_UNICODE_TYPE="unsigned long"
3546 AC_DEFINE(PY_UNICODE_TYPE,unsigned long)
3547else
3548 PY_UNICODE_TYPE="no type found"
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003549fi
Georg Brandl52d168a2008-01-07 18:10:24 +00003550AC_MSG_RESULT($PY_UNICODE_TYPE)
Guido van Rossumef2255b2000-03-10 22:30:29 +00003551
3552# check for endianness
3553AC_C_BIGENDIAN
3554
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00003555# Check whether right shifting a negative integer extends the sign bit
3556# or fills with zeros (like the Cray J90, according to Tim Peters).
3557AC_MSG_CHECKING(whether right shift extends the sign bit)
Vladimir Marangozova6180282000-07-12 05:05:06 +00003558AC_CACHE_VAL(ac_cv_rshift_extends_sign, [
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00003559AC_TRY_RUN([
3560int main()
3561{
Vladimir Marangozova6180282000-07-12 05:05:06 +00003562 exit(((-1)>>3 == -1) ? 0 : 1);
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00003563}
Guido van Rossum3065c942001-09-17 04:03:14 +00003564],
3565ac_cv_rshift_extends_sign=yes,
3566ac_cv_rshift_extends_sign=no,
3567ac_cv_rshift_extends_sign=yes)])
Vladimir Marangozova6180282000-07-12 05:05:06 +00003568AC_MSG_RESULT($ac_cv_rshift_extends_sign)
3569if test "$ac_cv_rshift_extends_sign" = no
3570then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003571 AC_DEFINE(SIGNED_RIGHT_SHIFT_ZERO_FILLS, 1,
3572 [Define if i>>j for signed int i does not extend the sign bit
3573 when i < 0])
Vladimir Marangozova6180282000-07-12 05:05:06 +00003574fi
3575
Guido van Rossumcadfaec2001-01-05 14:45:49 +00003576# check for getc_unlocked and related locking functions
3577AC_MSG_CHECKING(for getc_unlocked() and friends)
3578AC_CACHE_VAL(ac_cv_have_getc_unlocked, [
3579AC_TRY_LINK([#include <stdio.h>],[
3580 FILE *f = fopen("/dev/null", "r");
3581 flockfile(f);
3582 getc_unlocked(f);
3583 funlockfile(f);
3584], ac_cv_have_getc_unlocked=yes, ac_cv_have_getc_unlocked=no)])
3585AC_MSG_RESULT($ac_cv_have_getc_unlocked)
3586if test "$ac_cv_have_getc_unlocked" = yes
3587then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003588 AC_DEFINE(HAVE_GETC_UNLOCKED, 1,
3589 [Define this if you have flockfile(), getc_unlocked(), and funlockfile()])
Guido van Rossumcadfaec2001-01-05 14:45:49 +00003590fi
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00003591
Neal Norwitzfe8e3d92006-01-07 21:07:20 +00003592# check where readline lives
Martin v. Löwis82bca632006-02-10 20:49:30 +00003593# save the value of LIBS so we don't actually link Python with readline
3594LIBS_no_readline=$LIBS
Gregory P. Smith18820942008-09-07 06:24:49 +00003595
3596# On some systems we need to link readline to a termcap compatible
3597# library. NOTE: Keep the precedence of listed libraries synchronised
3598# with setup.py.
3599py_cv_lib_readline=no
3600AC_MSG_CHECKING([how to link readline libs])
3601for py_libtermcap in "" ncursesw ncurses curses termcap; do
3602 if test -z "$py_libtermcap"; then
3603 READLINE_LIBS="-lreadline"
3604 else
3605 READLINE_LIBS="-lreadline -l$py_libtermcap"
3606 fi
3607 LIBS="$READLINE_LIBS $LIBS_no_readline"
3608 AC_LINK_IFELSE(
3609 [AC_LANG_CALL([],[readline])],
3610 [py_cv_lib_readline=yes])
3611 if test $py_cv_lib_readline = yes; then
3612 break
3613 fi
3614done
3615# Uncomment this line if you want to use READINE_LIBS in Makefile or scripts
3616#AC_SUBST([READLINE_LIBS])
Gregory P. Smith97515912008-09-07 19:23:19 +00003617if test $py_cv_lib_readline = no; then
Gregory P. Smith18820942008-09-07 06:24:49 +00003618 AC_MSG_RESULT([none])
3619else
3620 AC_MSG_RESULT([$READLINE_LIBS])
3621 AC_DEFINE(HAVE_LIBREADLINE, 1,
3622 [Define if you have the readline library (-lreadline).])
Neal Norwitzfe8e3d92006-01-07 21:07:20 +00003623fi
3624
Michael W. Hudson30ea2f22004-07-07 17:44:12 +00003625# check for readline 2.1
3626AC_CHECK_LIB(readline, rl_callback_handler_install,
3627 AC_DEFINE(HAVE_RL_CALLBACK, 1,
Gregory P. Smith18820942008-09-07 06:24:49 +00003628 [Define if you have readline 2.1]), ,$READLINE_LIBS)
Michael W. Hudson30ea2f22004-07-07 17:44:12 +00003629
Guido van Rossumfaf5e4d2002-12-30 16:25:41 +00003630# check for readline 2.2
3631AC_TRY_CPP([#include <readline/readline.h>],
3632have_readline=yes, have_readline=no)
3633if test $have_readline = yes
3634then
3635 AC_EGREP_HEADER([extern int rl_completion_append_character;],
3636 [readline/readline.h],
3637 AC_DEFINE(HAVE_RL_COMPLETION_APPEND_CHARACTER, 1,
3638 [Define if you have readline 2.2]), )
Antoine Pitrou37276002009-10-26 19:32:51 +00003639 AC_EGREP_HEADER([extern int rl_completion_suppress_append;],
3640 [readline/readline.h],
3641 AC_DEFINE(HAVE_RL_COMPLETION_SUPPRESS_APPEND, 1,
3642 [Define if you have rl_completion_suppress_append]), )
Guido van Rossumfaf5e4d2002-12-30 16:25:41 +00003643fi
3644
Martin v. Löwis0daad592001-09-30 21:09:59 +00003645# check for readline 4.0
3646AC_CHECK_LIB(readline, rl_pre_input_hook,
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003647 AC_DEFINE(HAVE_RL_PRE_INPUT_HOOK, 1,
Gregory P. Smith18820942008-09-07 06:24:49 +00003648 [Define if you have readline 4.0]), ,$READLINE_LIBS)
Martin v. Löwis0daad592001-09-30 21:09:59 +00003649
Thomas Wouters89d996e2007-09-08 17:39:28 +00003650# also in 4.0
3651AC_CHECK_LIB(readline, rl_completion_display_matches_hook,
3652 AC_DEFINE(HAVE_RL_COMPLETION_DISPLAY_MATCHES_HOOK, 1,
Gregory P. Smith18820942008-09-07 06:24:49 +00003653 [Define if you have readline 4.0]), ,$READLINE_LIBS)
Thomas Wouters89d996e2007-09-08 17:39:28 +00003654
Guido van Rossum353ae582001-07-10 16:45:32 +00003655# check for readline 4.2
3656AC_CHECK_LIB(readline, rl_completion_matches,
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003657 AC_DEFINE(HAVE_RL_COMPLETION_MATCHES, 1,
Gregory P. Smith18820942008-09-07 06:24:49 +00003658 [Define if you have readline 4.2]), ,$READLINE_LIBS)
Guido van Rossum353ae582001-07-10 16:45:32 +00003659
Michael W. Hudson30ea2f22004-07-07 17:44:12 +00003660# also in readline 4.2
3661AC_TRY_CPP([#include <readline/readline.h>],
3662have_readline=yes, have_readline=no)
3663if test $have_readline = yes
3664then
3665 AC_EGREP_HEADER([extern int rl_catch_signals;],
3666 [readline/readline.h],
3667 AC_DEFINE(HAVE_RL_CATCH_SIGNAL, 1,
3668 [Define if you can turn off readline's signal handling.]), )
3669fi
3670
Martin v. Löwis82bca632006-02-10 20:49:30 +00003671# End of readline checks: restore LIBS
3672LIBS=$LIBS_no_readline
3673
Thomas Wouterse38b2f12001-07-11 22:35:31 +00003674AC_MSG_CHECKING(for broken nice())
3675AC_CACHE_VAL(ac_cv_broken_nice, [
3676AC_TRY_RUN([
3677int main()
3678{
3679 int val1 = nice(1);
3680 if (val1 != -1 && val1 == nice(2))
3681 exit(0);
3682 exit(1);
3683}
Guido van Rossum3065c942001-09-17 04:03:14 +00003684],
3685ac_cv_broken_nice=yes,
3686ac_cv_broken_nice=no,
3687ac_cv_broken_nice=no)])
Thomas Wouterse38b2f12001-07-11 22:35:31 +00003688AC_MSG_RESULT($ac_cv_broken_nice)
3689if test "$ac_cv_broken_nice" = yes
3690then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003691 AC_DEFINE(HAVE_BROKEN_NICE, 1,
3692 [Define if nice() returns success/failure instead of the new priority.])
Thomas Wouterse38b2f12001-07-11 22:35:31 +00003693fi
3694
Nicholas Bastine62c5c82004-03-21 23:45:42 +00003695AC_MSG_CHECKING(for broken poll())
3696AC_TRY_RUN([
3697#include <poll.h>
3698
3699int main (void)
3700 {
3701 struct pollfd poll_struct = { 42, POLLIN|POLLPRI|POLLOUT, 0 };
3702
3703 close (42);
3704
3705 int poll_test = poll (&poll_struct, 1, 0);
3706
3707 if (poll_test < 0)
3708 {
3709 exit(0);
3710 }
3711 else if (poll_test == 0 && poll_struct.revents != POLLNVAL)
3712 {
3713 exit(0);
3714 }
3715 else
3716 {
3717 exit(1);
3718 }
3719 }
3720],
3721ac_cv_broken_poll=yes,
3722ac_cv_broken_poll=no,
3723ac_cv_broken_poll=no)
3724AC_MSG_RESULT($ac_cv_broken_poll)
3725if test "$ac_cv_broken_poll" = yes
3726then
3727 AC_DEFINE(HAVE_BROKEN_POLL, 1,
3728 [Define if poll() sets errno on invalid file descriptors.])
3729fi
3730
Brett Cannon43802422005-02-10 20:48:03 +00003731# Before we can test tzset, we need to check if struct tm has a tm_zone
3732# (which is not required by ISO C or UNIX spec) and/or if we support
3733# tzname[]
3734AC_STRUCT_TIMEZONE
Nicholas Bastine62c5c82004-03-21 23:45:42 +00003735
Brett Cannon43802422005-02-10 20:48:03 +00003736# check tzset(3) exists and works like we expect it to
Guido van Rossumd11b62e2003-03-14 21:51:36 +00003737AC_MSG_CHECKING(for working tzset())
3738AC_CACHE_VAL(ac_cv_working_tzset, [
3739AC_TRY_RUN([
3740#include <stdlib.h>
3741#include <time.h>
Brett Cannon18367812003-09-19 00:59:16 +00003742#include <string.h>
Brett Cannon43802422005-02-10 20:48:03 +00003743
3744#if HAVE_TZNAME
3745extern char *tzname[];
3746#endif
3747
Guido van Rossumd11b62e2003-03-14 21:51:36 +00003748int main()
3749{
Brett Cannon18367812003-09-19 00:59:16 +00003750 /* Note that we need to ensure that not only does tzset(3)
3751 do 'something' with localtime, but it works as documented
3752 in the library reference and as expected by the test suite.
Brett Cannon43802422005-02-10 20:48:03 +00003753 This includes making sure that tzname is set properly if
3754 tm->tm_zone does not exist since it is the alternative way
3755 of getting timezone info.
Brett Cannon18367812003-09-19 00:59:16 +00003756
3757 Red Hat 6.2 doesn't understand the southern hemisphere
Brett Cannon43802422005-02-10 20:48:03 +00003758 after New Year's Day.
Brett Cannon18367812003-09-19 00:59:16 +00003759 */
3760
Brett Cannon43802422005-02-10 20:48:03 +00003761 time_t groundhogday = 1044144000; /* GMT-based */
Brett Cannon18367812003-09-19 00:59:16 +00003762 time_t midyear = groundhogday + (365 * 24 * 3600 / 2);
3763
Neal Norwitz7f2588c2003-04-11 15:35:53 +00003764 putenv("TZ=UTC+0");
Guido van Rossumd11b62e2003-03-14 21:51:36 +00003765 tzset();
Brett Cannon18367812003-09-19 00:59:16 +00003766 if (localtime(&groundhogday)->tm_hour != 0)
3767 exit(1);
Brett Cannon43802422005-02-10 20:48:03 +00003768#if HAVE_TZNAME
3769 /* For UTC, tzname[1] is sometimes "", sometimes " " */
3770 if (strcmp(tzname[0], "UTC") ||
3771 (tzname[1][0] != 0 && tzname[1][0] != ' '))
3772 exit(1);
3773#endif
Brett Cannon18367812003-09-19 00:59:16 +00003774
Neal Norwitz7f2588c2003-04-11 15:35:53 +00003775 putenv("TZ=EST+5EDT,M4.1.0,M10.5.0");
Guido van Rossumd11b62e2003-03-14 21:51:36 +00003776 tzset();
Brett Cannon18367812003-09-19 00:59:16 +00003777 if (localtime(&groundhogday)->tm_hour != 19)
Guido van Rossumd11b62e2003-03-14 21:51:36 +00003778 exit(1);
Brett Cannon43802422005-02-10 20:48:03 +00003779#if HAVE_TZNAME
3780 if (strcmp(tzname[0], "EST") || strcmp(tzname[1], "EDT"))
3781 exit(1);
3782#endif
Brett Cannon18367812003-09-19 00:59:16 +00003783
3784 putenv("TZ=AEST-10AEDT-11,M10.5.0,M3.5.0");
3785 tzset();
3786 if (localtime(&groundhogday)->tm_hour != 11)
3787 exit(1);
Brett Cannon43802422005-02-10 20:48:03 +00003788#if HAVE_TZNAME
3789 if (strcmp(tzname[0], "AEST") || strcmp(tzname[1], "AEDT"))
3790 exit(1);
3791#endif
3792
3793#if HAVE_STRUCT_TM_TM_ZONE
Brett Cannon18367812003-09-19 00:59:16 +00003794 if (strcmp(localtime(&groundhogday)->tm_zone, "AEDT"))
3795 exit(1);
3796 if (strcmp(localtime(&midyear)->tm_zone, "AEST"))
3797 exit(1);
Brett Cannon43802422005-02-10 20:48:03 +00003798#endif
Brett Cannon18367812003-09-19 00:59:16 +00003799
Guido van Rossumd11b62e2003-03-14 21:51:36 +00003800 exit(0);
3801}
3802],
3803ac_cv_working_tzset=yes,
3804ac_cv_working_tzset=no,
3805ac_cv_working_tzset=no)])
3806AC_MSG_RESULT($ac_cv_working_tzset)
3807if test "$ac_cv_working_tzset" = yes
3808then
3809 AC_DEFINE(HAVE_WORKING_TZSET, 1,
3810 [Define if tzset() actually switches the local timezone in a meaningful way.])
3811fi
3812
Martin v. Löwis94717ed2002-09-09 14:24:16 +00003813# Look for subsecond timestamps in struct stat
3814AC_MSG_CHECKING(for tv_nsec in struct stat)
3815AC_CACHE_VAL(ac_cv_stat_tv_nsec,
3816AC_TRY_COMPILE([#include <sys/stat.h>], [
3817struct stat st;
3818st.st_mtim.tv_nsec = 1;
3819],
Martin v. Löwisa32c9942002-09-09 16:17:47 +00003820ac_cv_stat_tv_nsec=yes,
Martin v. Löwis94717ed2002-09-09 14:24:16 +00003821ac_cv_stat_tv_nsec=no,
3822ac_cv_stat_tv_nsec=no))
3823AC_MSG_RESULT($ac_cv_stat_tv_nsec)
3824if test "$ac_cv_stat_tv_nsec" = yes
3825then
3826 AC_DEFINE(HAVE_STAT_TV_NSEC, 1,
3827 [Define if you have struct stat.st_mtim.tv_nsec])
3828fi
3829
Martin v. Löwisebd9d5b2005-08-09 15:00:59 +00003830# Look for BSD style subsecond timestamps in struct stat
3831AC_MSG_CHECKING(for tv_nsec2 in struct stat)
3832AC_CACHE_VAL(ac_cv_stat_tv_nsec2,
3833AC_TRY_COMPILE([#include <sys/stat.h>], [
3834struct stat st;
3835st.st_mtimespec.tv_nsec = 1;
3836],
3837ac_cv_stat_tv_nsec2=yes,
3838ac_cv_stat_tv_nsec2=no,
3839ac_cv_stat_tv_nsec2=no))
3840AC_MSG_RESULT($ac_cv_stat_tv_nsec2)
3841if test "$ac_cv_stat_tv_nsec2" = yes
3842then
3843 AC_DEFINE(HAVE_STAT_TV_NSEC2, 1,
3844 [Define if you have struct stat.st_mtimensec])
3845fi
3846
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00003847# On HP/UX 11.0, mvwdelch is a block with a return statement
3848AC_MSG_CHECKING(whether mvwdelch is an expression)
3849AC_CACHE_VAL(ac_cv_mvwdelch_is_expression,
3850AC_TRY_COMPILE([#include <curses.h>], [
3851 int rtn;
3852 rtn = mvwdelch(0,0,0);
3853], ac_cv_mvwdelch_is_expression=yes,
3854 ac_cv_mvwdelch_is_expression=no,
3855 ac_cv_mvwdelch_is_expression=yes))
3856AC_MSG_RESULT($ac_cv_mvwdelch_is_expression)
3857
3858if test "$ac_cv_mvwdelch_is_expression" = yes
3859then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003860 AC_DEFINE(MVWDELCH_IS_EXPRESSION, 1,
3861 [Define if mvwdelch in curses.h is an expression.])
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00003862fi
3863
3864AC_MSG_CHECKING(whether WINDOW has _flags)
3865AC_CACHE_VAL(ac_cv_window_has_flags,
3866AC_TRY_COMPILE([#include <curses.h>], [
3867 WINDOW *w;
3868 w->_flags = 0;
3869], ac_cv_window_has_flags=yes,
3870 ac_cv_window_has_flags=no,
3871 ac_cv_window_has_flags=no))
3872AC_MSG_RESULT($ac_cv_window_has_flags)
3873
3874
3875if test "$ac_cv_window_has_flags" = yes
3876then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003877 AC_DEFINE(WINDOW_HAS_FLAGS, 1,
3878 [Define if WINDOW in curses.h offers a field _flags.])
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00003879fi
3880
Thomas Wouters0e3f5912006-08-11 14:57:12 +00003881AC_MSG_CHECKING(for is_term_resized)
3882AC_TRY_COMPILE([#include <curses.h>], void *x=is_term_resized,
3883 AC_DEFINE(HAVE_CURSES_IS_TERM_RESIZED, 1, Define if you have the 'is_term_resized' function.)
3884 AC_MSG_RESULT(yes),
Martin v. Löwis24a880b2002-12-31 12:55:15 +00003885 AC_MSG_RESULT(no)
Thomas Wouters0e3f5912006-08-11 14:57:12 +00003886)
Martin v. Löwis24a880b2002-12-31 12:55:15 +00003887
Thomas Wouters0e3f5912006-08-11 14:57:12 +00003888AC_MSG_CHECKING(for resize_term)
3889AC_TRY_COMPILE([#include <curses.h>], void *x=resize_term,
3890 AC_DEFINE(HAVE_CURSES_RESIZE_TERM, 1, Define if you have the 'resize_term' function.)
3891 AC_MSG_RESULT(yes),
Neal Norwitz865400f2003-03-21 01:42:58 +00003892 AC_MSG_RESULT(no)
Thomas Wouters0e3f5912006-08-11 14:57:12 +00003893)
3894
3895AC_MSG_CHECKING(for resizeterm)
3896AC_TRY_COMPILE([#include <curses.h>], void *x=resizeterm,
3897 AC_DEFINE(HAVE_CURSES_RESIZETERM, 1, Define if you have the 'resizeterm' function.)
3898 AC_MSG_RESULT(yes),
3899 AC_MSG_RESULT(no)
3900)
3901
Thomas Wouters89f507f2006-12-13 04:49:30 +00003902AC_MSG_CHECKING(for /dev/ptmx)
3903
3904if test -r /dev/ptmx
3905then
3906 AC_MSG_RESULT(yes)
3907 AC_DEFINE(HAVE_DEV_PTMX, 1,
3908 [Define if we have /dev/ptmx.])
3909else
3910 AC_MSG_RESULT(no)
3911fi
3912
3913AC_MSG_CHECKING(for /dev/ptc)
3914
3915if test -r /dev/ptc
3916then
3917 AC_MSG_RESULT(yes)
3918 AC_DEFINE(HAVE_DEV_PTC, 1,
3919 [Define if we have /dev/ptc.])
3920else
3921 AC_MSG_RESULT(no)
3922fi
Neal Norwitz865400f2003-03-21 01:42:58 +00003923
Thomas Wouters477c8d52006-05-27 19:21:47 +00003924AC_MSG_CHECKING(for %zd printf() format support)
3925AC_TRY_RUN([#include <stdio.h>
3926#include <stddef.h>
3927#include <string.h>
3928
Christian Heimes2c181612007-12-17 20:04:13 +00003929#ifdef HAVE_SYS_TYPES_H
3930#include <sys/types.h>
3931#endif
Thomas Wouters89f507f2006-12-13 04:49:30 +00003932
3933#ifdef HAVE_SSIZE_T
3934typedef ssize_t Py_ssize_t;
3935#elif SIZEOF_VOID_P == SIZEOF_LONG
3936typedef long Py_ssize_t;
3937#else
3938typedef int Py_ssize_t;
3939#endif
Thomas Wouters477c8d52006-05-27 19:21:47 +00003940
Christian Heimes2c181612007-12-17 20:04:13 +00003941int main()
3942{
3943 char buffer[256];
3944
Thomas Wouters477c8d52006-05-27 19:21:47 +00003945 if(sprintf(buffer, "%zd", (size_t)123) < 0)
3946 return 1;
3947
Thomas Wouters89f507f2006-12-13 04:49:30 +00003948 if (strcmp(buffer, "123"))
Thomas Wouters477c8d52006-05-27 19:21:47 +00003949 return 1;
Thomas Wouters89f507f2006-12-13 04:49:30 +00003950
3951 if (sprintf(buffer, "%zd", (Py_ssize_t)-123) < 0)
3952 return 1;
3953
3954 if (strcmp(buffer, "-123"))
3955 return 1;
3956
Thomas Wouters477c8d52006-05-27 19:21:47 +00003957 return 0;
3958}],
3959[AC_MSG_RESULT(yes)
3960 AC_DEFINE(PY_FORMAT_SIZE_T, "z", [Define to printf format modifier for Py_ssize_t])],
3961 AC_MSG_RESULT(no))
3962
Martin v. Löwis01c04012002-11-11 14:58:44 +00003963AC_CHECK_TYPE(socklen_t,,
3964 AC_DEFINE(socklen_t,int,
3965 Define to `int' if <sys/socket.h> does not define.),[
3966#ifdef HAVE_SYS_TYPES_H
3967#include <sys/types.h>
3968#endif
Guido van Rossum95713eb2000-05-18 20:53:31 +00003969#ifdef HAVE_SYS_SOCKET_H
3970#include <sys/socket.h>
3971#endif
Martin v. Löwis01c04012002-11-11 14:58:44 +00003972])
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00003973
Antoine Pitroufff95302008-09-03 18:58:51 +00003974AC_MSG_CHECKING(for broken mbstowcs)
3975AC_TRY_RUN([
3976#include<stdlib.h>
3977int main() {
3978 size_t len = -1;
3979 const char *str = "text";
3980 len = mbstowcs(NULL, str, 0);
3981 return (len != 4);
3982}
3983],
3984ac_cv_broken_mbstowcs=no,
3985ac_cv_broken_mbstowcs=yes,
3986ac_cv_broken_mbstowcs=no)
3987AC_MSG_RESULT($ac_cv_broken_mbstowcs)
3988if test "$ac_cv_broken_mbstowcs" = yes
3989then
3990 AC_DEFINE(HAVE_BROKEN_MBSTOWCS, 1,
3991 [Define if mbstowcs(NULL, "text", 0) does not return the number of
3992 wide chars that would be converted.])
3993fi
3994
Antoine Pitroub52ec782009-01-25 16:34:23 +00003995# Check for --with-computed-gotos
3996AC_MSG_CHECKING(for --with-computed-gotos)
3997AC_ARG_WITH(computed-gotos,
3998 AC_HELP_STRING(--with-computed-gotos,
3999 Use computed gotos / threaded dispatch in evaluation loop (not available on all compilers)),
4000[
4001if test "$withval" != no
4002then
4003 AC_DEFINE(USE_COMPUTED_GOTOS, 1,
4004 [Define if you want to use computed gotos in ceval.c.])
4005 AC_MSG_RESULT(yes)
4006else AC_MSG_RESULT(no)
4007fi],
4008[AC_MSG_RESULT(no)])
4009
Ronald Oussoren1b2cad02009-11-19 17:30:05 +00004010if test $ac_sys_system = Darwin
4011then
4012 LIBS="$LIBS -framework CoreFoundation"
4013fi
4014
4015
Antoine Pitroub52ec782009-01-25 16:34:23 +00004016
Martin v. Löwis06f15bb2001-12-02 13:02:32 +00004017AC_SUBST(THREADHEADERS)
4018
4019for h in `(cd $srcdir;echo Python/thread_*.h)`
4020do
4021 THREADHEADERS="$THREADHEADERS \$(srcdir)/$h"
4022done
4023
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00004024AC_SUBST(SRCDIRS)
Neal Norwitzd24499d2005-12-18 21:36:39 +00004025SRCDIRS="Parser Grammar Objects Python Modules Mac"
Andrew M. Kuchling8abedde2001-01-26 22:55:24 +00004026AC_MSG_CHECKING(for build directories)
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00004027for dir in $SRCDIRS; do
4028 if test ! -d $dir; then
4029 mkdir $dir
Fred Drake884d3ba2000-11-02 17:52:56 +00004030 fi
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00004031done
4032AC_MSG_RESULT(done)
Fred Drake036144d2000-10-26 17:09:35 +00004033
Guido van Rossum627b2d71993-12-24 10:39:16 +00004034# generate output files
Antoine Pitrou20327222009-05-24 20:39:11 +00004035AC_CONFIG_FILES(Makefile.pre Modules/Setup.config Misc/python.pc)
Martin v. Löwis88afe662002-10-26 13:47:44 +00004036AC_OUTPUT
Neil Schemenauer61c51152001-01-26 16:18:16 +00004037
Thomas Wouters49fd7fa2006-04-21 10:40:58 +00004038echo "creating Modules/Setup"
Neil Schemenauer61c51152001-01-26 16:18:16 +00004039if test ! -f Modules/Setup
4040then
4041 cp $srcdir/Modules/Setup.dist Modules/Setup
4042fi
4043
Thomas Wouters49fd7fa2006-04-21 10:40:58 +00004044echo "creating Modules/Setup.local"
Neil Schemenauer61c51152001-01-26 16:18:16 +00004045if test ! -f Modules/Setup.local
4046then
4047 echo "# Edit this file for local setup changes" >Modules/Setup.local
4048fi
4049
4050echo "creating Makefile"
4051$SHELL $srcdir/Modules/makesetup -c $srcdir/Modules/config.c.in \
4052 -s Modules Modules/Setup.config \
Neil Schemenauerf8b71c52001-04-21 17:41:16 +00004053 Modules/Setup.local Modules/Setup
Neil Schemenauer66252162001-02-19 04:47:42 +00004054mv config.c Modules