blob: f5d03427f7d9e4e504c7b3cc3095e42cd90a51d3 [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.
Martin v. Löwis4d0a20a2010-02-15 21:46:27 +0000279 # In addition, Stefan Krah confirms that issue #1244610 exists through
280 # OpenBSD 4.6, but is fixed in 4.7.
281 OpenBSD/2.* | OpenBSD/3.@<:@0123456789@:>@ | OpenBSD/4.@<:@0123456@:>@)
Christian Heimes5b5e81c2007-12-31 16:14:33 +0000282 define_xopen_source=no
283 # OpenBSD undoes our definition of __BSD_VISIBLE if _XOPEN_SOURCE is
284 # also defined. This can be overridden by defining _BSD_SOURCE
285 # As this has a different meaning on Linux, only define it on OpenBSD
286 AC_DEFINE(_BSD_SOURCE, 1, [Define on OpenBSD to activate all library features])
287 ;;
Martin v. Löwis4d0a20a2010-02-15 21:46:27 +0000288 OpenBSD/4.@<:@789@:>@)
Martin v. Löwisf6594222010-02-15 08:37:47 +0000289 # OpenBSD undoes our definition of __BSD_VISIBLE if _XOPEN_SOURCE is
290 # also defined. This can be overridden by defining _BSD_SOURCE
291 # As this has a different meaning on Linux, only define it on OpenBSD
292 AC_DEFINE(_BSD_SOURCE, 1, [Define on OpenBSD to activate all library features])
293 ;;
Thomas Wouters89f507f2006-12-13 04:49:30 +0000294 # Defining _XOPEN_SOURCE on NetBSD version prior to the introduction of
295 # _NETBSD_SOURCE disables certain features (eg. setgroups). Reported by
296 # Marc Recht
Benjamin Petersonf608c612008-11-16 18:33:53 +0000297 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 +0000298 define_xopen_source=no;;
Martin v. Löwisa9d71422003-03-28 18:43:31 +0000299 # On Solaris 2.6, sys/wait.h is inconsistent in the usage
300 # of union __?sigval. Reported by Stuart Bishop.
301 SunOS/5.6)
302 define_xopen_source=no;;
Martin v. Löwisc2409b42003-05-11 05:53:41 +0000303 # On UnixWare 7, u_long is never defined with _XOPEN_SOURCE,
304 # but used in /usr/include/netinet/tcp.h. Reported by Tim Rice.
Martin v. Löwis253d1f42004-05-07 19:14:14 +0000305 # Reconfirmed for 7.1.4 by Martin v. Loewis.
306 OpenUNIX/8.0.0| UnixWare/7.1.@<:@0-4@:>@)
Martin v. Löwisc2409b42003-05-11 05:53:41 +0000307 define_xopen_source=no;;
308 # On OpenServer 5, u_short is never defined with _XOPEN_SOURCE,
Martin v. Löwis53e73c32003-05-05 05:13:18 +0000309 # but used in struct sockaddr.sa_family. Reported by Tim Rice.
Martin v. Löwisc2409b42003-05-11 05:53:41 +0000310 SCO_SV/3.2)
Martin v. Löwis53e73c32003-05-05 05:13:18 +0000311 define_xopen_source=no;;
Martin v. Löwisb37509b2008-11-04 20:45:29 +0000312 # On FreeBSD 4, the math functions C89 does not cover are never defined
313 # with _XOPEN_SOURCE and __BSD_VISIBLE does not re-enable them.
314 FreeBSD/4.*)
315 define_xopen_source=no;;
316 # On MacOS X 10.2, a bug in ncurses.h means that it craps out if
317 # _XOPEN_EXTENDED_SOURCE is defined. Apparently, this is fixed in 10.3, which
318 # identifies itself as Darwin/7.*
319 # On Mac OS X 10.4, defining _POSIX_C_SOURCE or _XOPEN_SOURCE
320 # disables platform specific features beyond repair.
321 # On Mac OS X 10.3, defining _POSIX_C_SOURCE or _XOPEN_SOURCE
322 # has no effect, don't bother defining them
323 Darwin/@<:@6789@:>@.*)
Anthony Baxter6169c6b2003-10-04 07:46:23 +0000324 define_xopen_source=no;;
Trent Mickaf16e8c2004-08-25 23:55:59 +0000325 # On AIX 4 and 5.1, mbstate_t is defined only when _XOPEN_SOURCE == 500 but
326 # used in wcsnrtombs() and mbsnrtowcs() even if _XOPEN_SOURCE is not defined
327 # or has another value. By not (re)defining it, the defaults come in place.
Martin v. Löwisc19c5a62003-11-18 20:00:44 +0000328 AIX/4)
329 define_xopen_source=no;;
Trent Mickaf16e8c2004-08-25 23:55:59 +0000330 AIX/5)
331 if test `uname -r` -eq 1; then
332 define_xopen_source=no
333 fi
334 ;;
Georg Brandlf78e02b2008-06-10 17:40:04 +0000335 # On QNX 6.3.2, defining _XOPEN_SOURCE prevents netdb.h from
336 # defining NI_NUMERICHOST.
337 QNX/6.3.2)
338 define_xopen_source=no
339 ;;
Bob Ippolito7026a0a2005-03-28 23:23:47 +0000340
Martin v. Löwise981a4e2002-11-11 13:26:51 +0000341esac
342
343if test $define_xopen_source = yes
344then
Skip Montanarof0d5f792004-08-15 14:08:23 +0000345 # On Solaris w/ g++ it appears that _XOPEN_SOURCE has to be
346 # defined precisely as g++ defines it
Martin v. Löwis7dece662005-11-26 11:38:24 +0000347 # Furthermore, on Solaris 10, XPG6 requires the use of a C99
348 # compiler
Skip Montanarof0d5f792004-08-15 14:08:23 +0000349 case $ac_sys_system/$ac_sys_release in
Martin v. Löwis7dece662005-11-26 11:38:24 +0000350 SunOS/5.8|SunOS/5.9|SunOS/5.10)
Skip Montanarof0d5f792004-08-15 14:08:23 +0000351 AC_DEFINE(_XOPEN_SOURCE, 500,
352 Define to the level of X/Open that your system supports)
353 ;;
354 *)
355 AC_DEFINE(_XOPEN_SOURCE, 600,
356 Define to the level of X/Open that your system supports)
357 ;;
358 esac
Martin v. Löwis678fc1e2002-11-12 06:04:39 +0000359
360 # On Tru64 Unix 4.0F, defining _XOPEN_SOURCE also requires
361 # definition of _XOPEN_SOURCE_EXTENDED and _POSIX_C_SOURCE, or else
362 # several APIs are not declared. Since this is also needed in some
363 # cases for HP-UX, we define it globally.
Martin v. Löwis7dece662005-11-26 11:38:24 +0000364 # except for Solaris 10, where it must not be defined,
365 # as it implies XPG4.2
366 case $ac_sys_system/$ac_sys_release in
367 SunOS/5.10)
368 ;;
369 *)
370 AC_DEFINE(_XOPEN_SOURCE_EXTENDED, 1,
371 Define to activate Unix95-and-earlier features)
372 ;;
373 esac
Martin v. Löwis678fc1e2002-11-12 06:04:39 +0000374
Bob Ippolito7026a0a2005-03-28 23:23:47 +0000375 AC_DEFINE(_POSIX_C_SOURCE, 200112L, Define to activate features from IEEE Stds 1003.1-2001)
376
Martin v. Löwise981a4e2002-11-11 13:26:51 +0000377fi
378
Guido van Rossum91922671997-10-09 20:24:13 +0000379#
380# SGI compilers allow the specification of the both the ABI and the
381# ISA on the command line. Depending on the values of these switches,
382# different and often incompatable code will be generated.
383#
384# The SGI_ABI variable can be used to modify the CC and LDFLAGS and
385# thus supply support for various ABI/ISA combinations. The MACHDEP
386# variable is also adjusted.
387#
388AC_SUBST(SGI_ABI)
389if test ! -z "$SGI_ABI"
390then
391 CC="cc $SGI_ABI"
392 LDFLAGS="$SGI_ABI $LDFLAGS"
393 MACHDEP=`echo "${MACHDEP}${SGI_ABI}" | sed 's/ *//g'`
394fi
Guido van Rossumb418f891996-07-30 18:06:02 +0000395AC_MSG_RESULT($MACHDEP)
396
Jack Jansen6b08a402004-06-03 12:41:45 +0000397# Record the configure-time value of MACOSX_DEPLOYMENT_TARGET,
398# it may influence the way we can build extensions, so distutils
399# needs to check it
400AC_SUBST(CONFIGURE_MACOSX_DEPLOYMENT_TARGET)
Thomas Wouters477c8d52006-05-27 19:21:47 +0000401AC_SUBST(EXPORT_MACOSX_DEPLOYMENT_TARGET)
Jack Jansen6b08a402004-06-03 12:41:45 +0000402CONFIGURE_MACOSX_DEPLOYMENT_TARGET=
Thomas Wouters477c8d52006-05-27 19:21:47 +0000403EXPORT_MACOSX_DEPLOYMENT_TARGET='#'
Jack Jansen6b08a402004-06-03 12:41:45 +0000404
Mark Dickinsonb0e2b4c2008-04-26 20:48:56 +0000405AC_MSG_CHECKING(machine type as reported by uname -m)
406ac_sys_machine=`uname -m`
407AC_MSG_RESULT($ac_sys_machine)
408
Guido van Rossum627b2d71993-12-24 10:39:16 +0000409# checks for alternative programs
Skip Montanarodecc6a42003-01-01 20:07:49 +0000410
411# compiler flags are generated in two sets, BASECFLAGS and OPT. OPT is just
412# for debug/optimization stuff. BASECFLAGS is for flags that are required
413# just to get things to compile and link. Users are free to override OPT
414# when running configure or make. The build should not break if they do.
415# BASECFLAGS should generally not be messed with, however.
416
417# XXX shouldn't some/most/all of this code be merged with the stuff later
418# on that fiddles with OPT and BASECFLAGS?
Guido van Rossum5739e7e1995-01-20 16:50:53 +0000419AC_MSG_CHECKING(for --without-gcc)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000420AC_ARG_WITH(gcc,
421 AC_HELP_STRING(--without-gcc,never use gcc),
422[
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000423 case $withval in
Benjamin Peterson960cf0f2009-01-09 04:11:44 +0000424 no) CC=${CC:-cc}
Guido van Rossum5739e7e1995-01-20 16:50:53 +0000425 without_gcc=yes;;
426 yes) CC=gcc
427 without_gcc=no;;
428 *) CC=$withval
429 without_gcc=$withval;;
Guido van Rossum55a214e1995-09-13 17:48:09 +0000430 esac], [
Guido van Rossumb418f891996-07-30 18:06:02 +0000431 case $ac_sys_system in
Neil Schemenauerb3531b82001-02-16 04:09:05 +0000432 AIX*) CC=cc_r
433 without_gcc=;;
Martin v. Löwis130fb172001-07-19 11:00:41 +0000434 *) without_gcc=no;;
Guido van Rossum55a214e1995-09-13 17:48:09 +0000435 esac])
Guido van Rossum5739e7e1995-01-20 16:50:53 +0000436AC_MSG_RESULT($without_gcc)
437
Guido van Rossum03ad99f1995-03-09 14:09:54 +0000438# If the user switches compilers, we can't believe the cache
439if test ! -z "$ac_cv_prog_CC" -a ! -z "$CC" -a "$CC" != "$ac_cv_prog_CC"
440then
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000441 AC_MSG_ERROR([cached CC is different -- throw away $cache_file
442(it is also a good idea to do 'make clean' before compiling)])
Guido van Rossum03ad99f1995-03-09 14:09:54 +0000443fi
444
Guido van Rossum627b2d71993-12-24 10:39:16 +0000445AC_PROG_CC
Martin v. Löwis1d5ecb72001-08-09 10:29:44 +0000446
Thomas Wouters49fd7fa2006-04-21 10:40:58 +0000447AC_SUBST(CXX)
448AC_SUBST(MAINCC)
449AC_MSG_CHECKING(for --with-cxx-main=<compiler>)
450AC_ARG_WITH(cxx_main,
451 AC_HELP_STRING([--with-cxx-main=<compiler>],
452 [compile main() and link python executable with C++ compiler]),
453[
454
455 case $withval in
456 no) with_cxx_main=no
457 MAINCC='$(CC)';;
458 yes) with_cxx_main=yes
459 MAINCC='$(CXX)';;
460 *) with_cxx_main=yes
461 MAINCC=$withval
462 if test -z "$CXX"
463 then
464 CXX=$withval
465 fi;;
466 esac], [
467 with_cxx_main=no
468 MAINCC='$(CC)'
469])
470AC_MSG_RESULT($with_cxx_main)
471
472preset_cxx="$CXX"
473if test -z "$CXX"
474then
475 case "$CC" in
476 gcc) AC_PATH_PROG(CXX, [g++], [g++], [notfound]) ;;
477 cc) AC_PATH_PROG(CXX, [c++], [c++], [notfound]) ;;
478 esac
479 if test "$CXX" = "notfound"
480 then
481 CXX=""
482 fi
483fi
484if test -z "$CXX"
485then
486 AC_CHECK_PROGS(CXX, $CCC c++ g++ gcc CC cxx cc++ cl, notfound)
487 if test "$CXX" = "notfound"
488 then
489 CXX=""
490 fi
491fi
492if test "$preset_cxx" != "$CXX"
493then
494 AC_MSG_WARN([
495
496 By default, distutils will build C++ extension modules with "$CXX".
497 If this is not intended, then set CXX on the configure command line.
498 ])
499fi
500
501
Martin v. Löwis1d5ecb72001-08-09 10:29:44 +0000502# checks for UNIX variants that set C preprocessor variables
503AC_AIX
Martin v. Löwis1d5ecb72001-08-09 10:29:44 +0000504
Martin v. Löwis779ffc02002-12-02 22:17:01 +0000505# Check for unsupported systems
506case $ac_sys_system/$ac_sys_release in
Guido van Rossumcd16bf62007-06-13 18:07:49 +0000507atheos*|Linux*/1*)
Martin v. Löwis779ffc02002-12-02 22:17:01 +0000508 echo This system \($ac_sys_system/$ac_sys_release\) is no longer supported.
509 echo See README for details.
510 exit 1;;
511esac
512
Neil Schemenauer55f0cf32001-01-24 17:24:33 +0000513AC_EXEEXT
Neil Schemenauer3ae1d0a2001-01-27 06:54:42 +0000514AC_MSG_CHECKING(for --with-suffix)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000515AC_ARG_WITH(suffix,
516 AC_HELP_STRING(--with-suffix=.exe, set executable suffix),
517[
Neil Schemenauer3ae1d0a2001-01-27 06:54:42 +0000518 case $withval in
519 no) EXEEXT=;;
520 yes) EXEEXT=.exe;;
521 *) EXEEXT=$withval;;
522 esac])
523AC_MSG_RESULT($EXEEXT)
Jack Jansen1999ef42001-12-06 21:47:20 +0000524
Jack Jansen9a66b6d2001-08-08 13:56:14 +0000525# Test whether we're running on a non-case-sensitive system, in which
526# case we give a warning if no ext is given
Jack Jansen1999ef42001-12-06 21:47:20 +0000527AC_SUBST(BUILDEXEEXT)
528AC_MSG_CHECKING(for case-insensitive build directory)
Jack Jansen3c2c4332002-11-06 13:33:32 +0000529if test ! -d CaseSensitiveTestDir; then
530mkdir CaseSensitiveTestDir
531fi
532
533if test -d casesensitivetestdir
Jack Jansen9a66b6d2001-08-08 13:56:14 +0000534then
Jack Jansen1999ef42001-12-06 21:47:20 +0000535 AC_MSG_RESULT(yes)
536 BUILDEXEEXT=.exe
537else
538 AC_MSG_RESULT(no)
Jack Jansendd19cf82001-12-06 22:36:17 +0000539 BUILDEXEEXT=$EXEEXT
Jack Jansen9a66b6d2001-08-08 13:56:14 +0000540fi
Jack Jansen3c2c4332002-11-06 13:33:32 +0000541rmdir CaseSensitiveTestDir
Guido van Rossumfb842551997-08-06 23:42:07 +0000542
Guido van Rossumdd997f71998-10-07 19:58:26 +0000543case $MACHDEP in
544bsdos*)
545 case $CC in
546 gcc) CC="$CC -D_HAVE_BSDI";;
547 esac;;
548esac
549
Guido van Rossum84561611997-08-21 00:08:11 +0000550case $ac_sys_system in
551hp*|HP*)
552 case $CC in
Guido van Rossumcd5ff9f2000-09-22 16:15:54 +0000553 cc|*/cc) CC="$CC -Ae";;
Guido van Rossum84561611997-08-21 00:08:11 +0000554 esac;;
Martin v. Löwise8964d42001-03-06 12:09:07 +0000555SunOS*)
556 # Some functions have a prototype only with that define, e.g. confstr
Martin v. Löwisc45929e2002-04-06 10:10:49 +0000557 AC_DEFINE(__EXTENSIONS__, 1, [Defined on Solaris to see additional function prototypes.])
Martin v. Löwise8964d42001-03-06 12:09:07 +0000558 ;;
Guido van Rossum84561611997-08-21 00:08:11 +0000559esac
560
Martin v. Löwise8964d42001-03-06 12:09:07 +0000561
Neil Schemenauer61c51152001-01-26 16:18:16 +0000562AC_SUBST(LIBRARY)
563AC_MSG_CHECKING(LIBRARY)
564if test -z "$LIBRARY"
565then
566 LIBRARY='libpython$(VERSION).a'
567fi
568AC_MSG_RESULT($LIBRARY)
569
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000570# LDLIBRARY is the name of the library to link against (as opposed to the
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000571# name of the library into which to insert object files). BLDLIBRARY is also
572# the library to link against, usually. On Mac OS X frameworks, BLDLIBRARY
573# is blank as the main program is not linked directly against LDLIBRARY.
574# LDLIBRARYDIR is the path to LDLIBRARY, which is made in a subdirectory. On
575# systems without shared libraries, LDLIBRARY is the same as LIBRARY
576# (defined in the Makefiles). On Cygwin LDLIBRARY is the import library,
577# DLLLIBRARY is the shared (i.e., DLL) library.
578#
Martin v. Löwis1142de32002-03-29 16:28:31 +0000579# RUNSHARED is used to run shared python without installed libraries
580#
581# INSTSONAME is the name of the shared library that will be use to install
582# on the system - some systems like version suffix, others don't
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000583AC_SUBST(LDLIBRARY)
Guido van Rossum27552902001-01-23 01:52:26 +0000584AC_SUBST(DLLLIBRARY)
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000585AC_SUBST(BLDLIBRARY)
586AC_SUBST(LDLIBRARYDIR)
Martin v. Löwis1142de32002-03-29 16:28:31 +0000587AC_SUBST(INSTSONAME)
588AC_SUBST(RUNSHARED)
Neil Schemenauer61c51152001-01-26 16:18:16 +0000589LDLIBRARY="$LIBRARY"
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000590BLDLIBRARY='$(LDLIBRARY)'
Martin v. Löwis09bdf722002-05-08 08:51:29 +0000591INSTSONAME='$(LDLIBRARY)'
Guido van Rossum27552902001-01-23 01:52:26 +0000592DLLLIBRARY=''
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000593LDLIBRARYDIR=''
Martin v. Löwis1142de32002-03-29 16:28:31 +0000594RUNSHARED=''
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000595
Guido van Rossumfb842551997-08-06 23:42:07 +0000596# LINKCC is the command that links the python executable -- default is $(CC).
Martin v. Löwisb7da67a2001-10-18 15:35:38 +0000597# If CXX is set, and if it is needed to link a main function that was
598# compiled with CXX, LINKCC is CXX instead. Always using CXX is undesirable:
599# python might then depend on the C++ runtime
Fred Drake5790be12000-10-09 17:06:13 +0000600# This is altered for AIX in order to build the export list before
Guido van Rossumec95c7b1998-08-04 17:59:56 +0000601# linking.
Guido van Rossumfb842551997-08-06 23:42:07 +0000602AC_SUBST(LINKCC)
603AC_MSG_CHECKING(LINKCC)
604if test -z "$LINKCC"
605then
Thomas Wouters49fd7fa2006-04-21 10:40:58 +0000606 LINKCC='$(PURIFY) $(MAINCC)'
Guido van Rossumfb842551997-08-06 23:42:07 +0000607 case $ac_sys_system in
608 AIX*)
Neal Norwitz0b27ff92003-03-31 15:53:49 +0000609 exp_extra="\"\""
610 if test $ac_sys_release -ge 5 -o \
611 $ac_sys_release -eq 4 -a `uname -r` -ge 2 ; then
612 exp_extra="."
613 fi
614 LINKCC="\$(srcdir)/Modules/makexp_aix Modules/python.exp $exp_extra \$(LIBRARY); $LINKCC";;
Georg Brandlf78e02b2008-06-10 17:40:04 +0000615 QNX*)
616 # qcc must be used because the other compilers do not
617 # support -N.
618 LINKCC=qcc;;
Guido van Rossumfb842551997-08-06 23:42:07 +0000619 esac
620fi
621AC_MSG_RESULT($LINKCC)
622
Tarek Ziadébe720e02009-05-09 11:55:12 +0000623# GNULD is set to "yes" if the GNU linker is used. If this goes wrong
624# make sure we default having it set to "no": this is used by
625# distutils.unixccompiler to know if it should add --enable-new-dtags
626# to linker command lines, and failing to detect GNU ld simply results
627# in the same bahaviour as before.
628AC_SUBST(GNULD)
629AC_MSG_CHECKING(for GNU ld)
630ac_prog=ld
631if test "$GCC" = yes; then
632 ac_prog=`$CC -print-prog-name=ld`
633fi
634case `"$ac_prog" -V 2>&1 < /dev/null` in
635 *GNU*)
636 GNULD=yes;;
637 *)
638 GNULD=no;;
639esac
640AC_MSG_RESULT($GNULD)
641
Martin v. Löwis1142de32002-03-29 16:28:31 +0000642AC_MSG_CHECKING(for --enable-shared)
643AC_ARG_ENABLE(shared,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000644 AC_HELP_STRING(--enable-shared, disable/enable building shared python library))
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000645
Martin v. Löwis1142de32002-03-29 16:28:31 +0000646if test -z "$enable_shared"
647then
Martin v. Löwisb51033d2002-05-03 05:53:15 +0000648 case $ac_sys_system in
Martin v. Löwisf90ae202002-06-11 06:22:31 +0000649 CYGWIN* | atheos*)
Martin v. Löwisb51033d2002-05-03 05:53:15 +0000650 enable_shared="yes";;
651 *)
652 enable_shared="no";;
653 esac
Martin v. Löwis1142de32002-03-29 16:28:31 +0000654fi
655AC_MSG_RESULT($enable_shared)
656
Skip Montanaro56f6a4f2004-06-18 02:47:22 +0000657AC_MSG_CHECKING(for --enable-profiling)
658AC_ARG_ENABLE(profiling,
659 AC_HELP_STRING(--enable-profiling, enable C-level code profiling),
660[ac_save_cc="$CC"
661 CC="$CC -pg"
662 AC_TRY_RUN([int main() { return 0; }],
663 ac_enable_profiling="yes",
664 ac_enable_profiling="no",
665 ac_enable_profiling="no")
666 CC="$ac_save_cc"])
667AC_MSG_RESULT($ac_enable_profiling)
668
669case "$ac_enable_profiling" in
670 "yes")
671 BASECFLAGS="-pg $BASECFLAGS"
672 LDFLAGS="-pg $LDFLAGS"
673 ;;
674esac
Martin v. Löwis1142de32002-03-29 16:28:31 +0000675
676AC_MSG_CHECKING(LDLIBRARY)
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000677
Guido van Rossumb8552162001-09-05 14:58:11 +0000678# MacOSX framework builds need more magic. LDLIBRARY is the dynamic
679# library that we build, but we do not want to link against it (we
680# will find it with a -framework option). For this reason there is an
681# extra variable BLDLIBRARY against which Python and the extension
682# modules are linked, BLDLIBRARY. This is normally the same as
683# LDLIBRARY, but empty for MacOSX framework builds.
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000684if test "$enable_framework"
685then
686 LDLIBRARY='$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansen66b84832003-07-04 12:14:39 +0000687 RUNSHARED=DYLD_FRAMEWORK_PATH="`pwd`:$DYLD_FRAMEWORK_PATH"
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000688 BLDLIBRARY=''
689else
690 BLDLIBRARY='$(LDLIBRARY)'
691fi
692
Martin v. Löwis1142de32002-03-29 16:28:31 +0000693# Other platforms follow
694if test $enable_shared = "yes"; then
Mark Hammond8235ea12002-07-19 06:55:41 +0000695 AC_DEFINE(Py_ENABLE_SHARED, 1, [Defined if Python is built as a shared library.])
Martin v. Löwis1142de32002-03-29 16:28:31 +0000696 case $ac_sys_system in
Martin v. Löwis1142de32002-03-29 16:28:31 +0000697 CYGWIN*)
698 LDLIBRARY='libpython$(VERSION).dll.a'
699 DLLLIBRARY='libpython$(VERSION).dll'
700 ;;
701 SunOS*)
702 LDLIBRARY='libpython$(VERSION).so'
Martin v. Löwisd141a8c2003-06-14 15:20:28 +0000703 BLDLIBRARY='-Wl,-R,$(LIBDIR) -L. -lpython$(VERSION)'
Martin v. Löwisfc9b75f2003-08-09 09:06:52 +0000704 RUNSHARED=LD_LIBRARY_PATH=`pwd`:${LD_LIBRARY_PATH}
Martin v. Löwis2389c412003-10-31 15:42:07 +0000705 INSTSONAME="$LDLIBRARY".$SOVERSION
Martin v. Löwis1142de32002-03-29 16:28:31 +0000706 ;;
Martin v. Löwis86d66262006-02-17 08:40:11 +0000707 Linux*|GNU*|NetBSD*|FreeBSD*|DragonFly*)
Martin v. Löwis1142de32002-03-29 16:28:31 +0000708 LDLIBRARY='libpython$(VERSION).so'
709 BLDLIBRARY='-L. -lpython$(VERSION)'
Martin v. Löwisfc9b75f2003-08-09 09:06:52 +0000710 RUNSHARED=LD_LIBRARY_PATH=`pwd`:${LD_LIBRARY_PATH}
Hye-Shik Chang33761492004-10-26 09:53:46 +0000711 case $ac_sys_system in
712 FreeBSD*)
713 SOVERSION=`echo $SOVERSION|cut -d "." -f 1`
714 ;;
715 esac
Martin v. Löwis1142de32002-03-29 16:28:31 +0000716 INSTSONAME="$LDLIBRARY".$SOVERSION
717 ;;
718 hp*|HP*)
Thomas Wouters477c8d52006-05-27 19:21:47 +0000719 case `uname -m` in
720 ia64)
721 LDLIBRARY='libpython$(VERSION).so'
722 ;;
723 *)
724 LDLIBRARY='libpython$(VERSION).sl'
725 ;;
726 esac
Martin v. Löwis1142de32002-03-29 16:28:31 +0000727 BLDLIBRARY='-Wl,+b,$(LIBDIR) -L. -lpython$(VERSION)'
Martin v. Löwisfc9b75f2003-08-09 09:06:52 +0000728 RUNSHARED=SHLIB_PATH=`pwd`:${SHLIB_PATH}
Martin v. Löwis1142de32002-03-29 16:28:31 +0000729 ;;
730 OSF*)
731 LDLIBRARY='libpython$(VERSION).so'
Neal Norwitz671b9e32006-01-09 07:07:12 +0000732 BLDLIBRARY='-rpath $(LIBDIR) -L. -lpython$(VERSION)'
Martin v. Löwisfc9b75f2003-08-09 09:06:52 +0000733 RUNSHARED=LD_LIBRARY_PATH=`pwd`:${LD_LIBRARY_PATH}
Martin v. Löwis1142de32002-03-29 16:28:31 +0000734 ;;
Martin v. Löwisf90ae202002-06-11 06:22:31 +0000735 atheos*)
736 LDLIBRARY='libpython$(VERSION).so'
737 BLDLIBRARY='-L. -lpython$(VERSION)'
738 RUNSHARED=DLL_PATH=`pwd`:${DLL_PATH:-/atheos/sys/libs:/atheos/autolnk/lib}
739 ;;
Georg Brandlb1441c72009-01-03 22:33:39 +0000740 Darwin*)
741 LDLIBRARY='libpython$(VERSION).dylib'
742 BLDLIBRARY='-L. -lpython$(VERSION)'
743 RUNSHARED='DYLD_LIBRARY_PATH=`pwd`:${DYLD_LIBRARY_PATH}'
744 ;;
745
Martin v. Löwis1142de32002-03-29 16:28:31 +0000746 esac
Jason Tishler30765592003-09-04 11:04:06 +0000747else # shared is disabled
748 case $ac_sys_system in
749 CYGWIN*)
750 BLDLIBRARY='$(LIBRARY)'
751 LDLIBRARY='libpython$(VERSION).dll.a'
752 ;;
753 esac
Martin v. Löwis1142de32002-03-29 16:28:31 +0000754fi
755
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000756AC_MSG_RESULT($LDLIBRARY)
757
Guido van Rossum627b2d71993-12-24 10:39:16 +0000758AC_PROG_RANLIB
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000759AC_SUBST(AR)
Guido van Rossum76be6ed1995-01-02 18:33:54 +0000760AC_CHECK_PROGS(AR, ar aal, ar)
Neil Schemenauera42c8272001-03-31 00:01:55 +0000761
Tarek Ziadé5662d3e2009-05-07 21:24:43 +0000762# tweak ARFLAGS only if the user didn't set it on the command line
763AC_SUBST(ARFLAGS)
764if test -z "$ARFLAGS"
765then
766 ARFLAGS="rc"
767fi
768
Martin v. Löwisdea59e52006-01-05 10:00:36 +0000769AC_SUBST(SVNVERSION)
Thomas Wouters49fd7fa2006-04-21 10:40:58 +0000770AC_CHECK_PROG(SVNVERSION, svnversion, found, not-found)
Martin v. Löwisc5bf5a02006-01-05 10:33:59 +0000771if test $SVNVERSION = found
772then
773 SVNVERSION="svnversion \$(srcdir)"
774else
Benjamin Petersonf53eec82009-05-23 19:36:27 +0000775 SVNVERSION="echo Unversioned directory"
Martin v. Löwisc5bf5a02006-01-05 10:33:59 +0000776fi
Martin v. Löwisdea59e52006-01-05 10:00:36 +0000777
Neil Schemenauera42c8272001-03-31 00:01:55 +0000778case $MACHDEP in
Neil Schemenaueraf5567f2001-10-21 22:32:04 +0000779bsdos*|hp*|HP*)
780 # install -d does not work on BSDI or HP-UX
Neil Schemenauera42c8272001-03-31 00:01:55 +0000781 if test -z "$INSTALL"
782 then
783 INSTALL="${srcdir}/install-sh -c"
784 fi
785esac
Neil Schemenauer55f0cf32001-01-24 17:24:33 +0000786AC_PROG_INSTALL
Guido van Rossumb418f891996-07-30 18:06:02 +0000787
Guido van Rossumec95c7b1998-08-04 17:59:56 +0000788# Not every filesystem supports hard links
789AC_SUBST(LN)
790if test -z "$LN" ; then
791 case $ac_sys_system in
Guido van Rossumaef734b2001-01-10 21:09:12 +0000792 CYGWIN*) LN="ln -s";;
Martin v. Löwisf90ae202002-06-11 06:22:31 +0000793 atheos*) LN="ln -s";;
Guido van Rossumec95c7b1998-08-04 17:59:56 +0000794 *) LN=ln;;
795 esac
796fi
797
Fred Drake9f715822001-07-11 06:27:00 +0000798# Check for --with-pydebug
799AC_MSG_CHECKING(for --with-pydebug)
800AC_ARG_WITH(pydebug,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000801 AC_HELP_STRING(--with-pydebug, build with Py_DEBUG defined),
802[
Fred Drake9f715822001-07-11 06:27:00 +0000803if test "$withval" != no
Martin v. Löwisc45929e2002-04-06 10:10:49 +0000804then
805 AC_DEFINE(Py_DEBUG, 1,
806 [Define if you want to build an interpreter with many run-time checks.])
807 AC_MSG_RESULT(yes);
808 Py_DEBUG='true'
Fred Drake9f715822001-07-11 06:27:00 +0000809else AC_MSG_RESULT(no); Py_DEBUG='false'
810fi],
811[AC_MSG_RESULT(no)])
812
Skip Montanarodecc6a42003-01-01 20:07:49 +0000813# XXX Shouldn't the code above that fiddles with BASECFLAGS and OPT be
814# merged with this chunk of code?
815
Neil Schemenauer55f0cf32001-01-24 17:24:33 +0000816# Optimizer/debugger flags
Skip Montanarodecc6a42003-01-01 20:07:49 +0000817# ------------------------
818# (The following bit of code is complicated enough - please keep things
819# indented properly. Just pretend you're editing Python code. ;-)
820
821# There are two parallel sets of case statements below, one that checks to
822# see if OPT was set and one that does BASECFLAGS setting based upon
823# compiler and platform. BASECFLAGS tweaks need to be made even if the
824# user set OPT.
825
826# tweak OPT based on compiler and platform, only if the user didn't set
827# it on the command line
Guido van Rossumb418f891996-07-30 18:06:02 +0000828AC_SUBST(OPT)
Guido van Rossum4e8af441994-08-19 15:33:54 +0000829if test -z "$OPT"
Guido van Rossumb418f891996-07-30 18:06:02 +0000830then
Skip Montanarodecc6a42003-01-01 20:07:49 +0000831 case $GCC in
832 yes)
Thomas Wouters49fd7fa2006-04-21 10:40:58 +0000833 if test "$CC" != 'g++' ; then
834 STRICT_PROTO="-Wstrict-prototypes"
835 fi
Christian Heimes38053212007-12-14 01:24:44 +0000836 # For gcc 4.x we need to use -fwrapv so lets check if its supported
837 if "$CC" -v --help 2>/dev/null |grep -- -fwrapv > /dev/null; then
838 WRAP="-fwrapv"
839 fi
Skip Montanarodecc6a42003-01-01 20:07:49 +0000840 case $ac_cv_prog_cc_g in
Guido van Rossum2242f2f2001-04-11 20:58:20 +0000841 yes)
Fred Drake9f715822001-07-11 06:27:00 +0000842 if test "$Py_DEBUG" = 'true' ; then
843 # Optimization messes up debuggers, so turn it off for
844 # debug builds.
Thomas Wouters49fd7fa2006-04-21 10:40:58 +0000845 OPT="-g -Wall $STRICT_PROTO"
Fred Drake9f715822001-07-11 06:27:00 +0000846 else
Christian Heimes38053212007-12-14 01:24:44 +0000847 OPT="-g $WRAP -O3 -Wall $STRICT_PROTO"
Skip Montanarodecc6a42003-01-01 20:07:49 +0000848 fi
849 ;;
Guido van Rossum2242f2f2001-04-11 20:58:20 +0000850 *)
Thomas Wouters49fd7fa2006-04-21 10:40:58 +0000851 OPT="-O3 -Wall $STRICT_PROTO"
Skip Montanarodecc6a42003-01-01 20:07:49 +0000852 ;;
Fred Drake9f715822001-07-11 06:27:00 +0000853 esac
Martin v. Löwis21ee4092002-09-30 16:19:48 +0000854 case $ac_sys_system in
Skip Montanarodecc6a42003-01-01 20:07:49 +0000855 SCO_SV*) OPT="$OPT -m486 -DSCO5"
856 ;;
857 esac
Fred Drake9f715822001-07-11 06:27:00 +0000858 ;;
Skip Montanarodecc6a42003-01-01 20:07:49 +0000859
Guido van Rossum2242f2f2001-04-11 20:58:20 +0000860 *)
Skip Montanarodecc6a42003-01-01 20:07:49 +0000861 OPT="-O"
862 ;;
Guido van Rossum2242f2f2001-04-11 20:58:20 +0000863 esac
Guido van Rossum4e8af441994-08-19 15:33:54 +0000864fi
Guido van Rossum627b2d71993-12-24 10:39:16 +0000865
Skip Montanarodecc6a42003-01-01 20:07:49 +0000866AC_SUBST(BASECFLAGS)
Georg Brandlfcaf9102008-07-16 02:17:56 +0000867
868# The -arch flags for universal builds on OSX
869UNIVERSAL_ARCH_FLAGS=
870AC_SUBST(UNIVERSAL_ARCH_FLAGS)
871
Skip Montanarodecc6a42003-01-01 20:07:49 +0000872# tweak BASECFLAGS based on compiler and platform
873case $GCC in
874yes)
Martin v. Löwis70fedcd2003-07-07 21:26:19 +0000875 # Python violates C99 rules, by casting between incompatible
876 # pointer types. GCC may generate bad code as a result of that,
877 # so use -fno-strict-aliasing if supported.
878 AC_MSG_CHECKING(whether $CC accepts -fno-strict-aliasing)
879 ac_save_cc="$CC"
880 CC="$CC -fno-strict-aliasing"
881 AC_TRY_RUN([int main() { return 0; }],
882 ac_cv_no_strict_aliasing_ok=yes,
883 ac_cv_no_strict_aliasing_ok=no,
884 ac_cv_no_strict_aliasing_ok=no)
885 CC="$ac_save_cc"
886 AC_MSG_RESULT($ac_cv_no_strict_aliasing_ok)
887 if test $ac_cv_no_strict_aliasing_ok = yes
888 then
889 BASECFLAGS="$BASECFLAGS -fno-strict-aliasing"
890 fi
Mark Dickinsonb0e2b4c2008-04-26 20:48:56 +0000891
892 # if using gcc on alpha, use -mieee to get (near) full IEEE 754
893 # support. Without this, treatment of subnormals doesn't follow
894 # the standard.
895 case $ac_sys_machine in
896 alpha*)
897 BASECFLAGS="$BASECFLAGS -mieee"
898 ;;
899 esac
900
Skip Montanarodecc6a42003-01-01 20:07:49 +0000901 case $ac_sys_system in
902 SCO_SV*)
903 BASECFLAGS="$BASECFLAGS -m486 -DSCO5"
904 ;;
905 # is there any other compiler on Darwin besides gcc?
906 Darwin*)
Christian Heimesb186d002008-03-18 15:15:01 +0000907 # -Wno-long-double, -no-cpp-precomp, and -mno-fused-madd
908 # used to be here, but non-Apple gcc doesn't accept them.
Benjamin Peterson67c38e22008-07-17 16:10:34 +0000909
910
Thomas Wouters477c8d52006-05-27 19:21:47 +0000911 if test "${enable_universalsdk}"; then
Georg Brandlfcaf9102008-07-16 02:17:56 +0000912 UNIVERSAL_ARCH_FLAGS=""
913 if test "$UNIVERSAL_ARCHS" = "32-bit" ; then
914 UNIVERSAL_ARCH_FLAGS="-arch ppc -arch i386"
Benjamin Peterson6794aa32008-07-16 20:33:37 +0000915 ARCH_RUN_32BIT=""
Georg Brandlfcaf9102008-07-16 02:17:56 +0000916
917 elif test "$UNIVERSAL_ARCHS" = "64-bit" ; then
918 UNIVERSAL_ARCH_FLAGS="-arch ppc64 -arch x86_64"
Ronald Oussorend45ff2c2009-09-06 11:11:04 +0000919 ARCH_RUN_32BIT="true"
Georg Brandlfcaf9102008-07-16 02:17:56 +0000920
921 elif test "$UNIVERSAL_ARCHS" = "all" ; then
922 UNIVERSAL_ARCH_FLAGS="-arch i386 -arch ppc -arch ppc64 -arch x86_64"
Ronald Oussorenc8c89c42010-02-11 13:24:45 +0000923 ARCH_RUN_32BIT="/usr/bin/arch -i386 -ppc"
Georg Brandlfcaf9102008-07-16 02:17:56 +0000924
Ronald Oussoren856624d2009-09-08 07:13:53 +0000925 elif test "$UNIVERSAL_ARCHS" = "intel" ; then
926 UNIVERSAL_ARCH_FLAGS="-arch i386 -arch x86_64"
Ronald Oussorenc8c89c42010-02-11 13:24:45 +0000927 ARCH_RUN_32BIT="/usr/bin/arch -i386"
Ronald Oussoren856624d2009-09-08 07:13:53 +0000928
929 elif test "$UNIVERSAL_ARCHS" = "3-way" ; then
930 UNIVERSAL_ARCH_FLAGS="-arch i386 -arch ppc -arch x86_64"
Ronald Oussorenc8c89c42010-02-11 13:24:45 +0000931 ARCH_RUN_32BIT="/usr/bin/arch -i386 -ppc"
Ronald Oussoren856624d2009-09-08 07:13:53 +0000932
Georg Brandlfcaf9102008-07-16 02:17:56 +0000933 else
Ronald Oussoren5644eb72009-09-20 20:10:02 +0000934 AC_MSG_ERROR([proper usage is --with-universal-arch=32-bit|64-bit|all|intel|3-way])
Georg Brandlfcaf9102008-07-16 02:17:56 +0000935
936 fi
937
938
939 BASECFLAGS="${UNIVERSAL_ARCH_FLAGS} -isysroot ${UNIVERSALSDK} ${BASECFLAGS}"
Georg Brandl3dbca812008-07-23 16:10:53 +0000940 tgt=`sw_vers -productVersion | sed 's/\(10\.[[0-9]]*\).*/\1/'`
Benjamin Peterson67c38e22008-07-17 16:10:34 +0000941 if test "${UNIVERSALSDK}" != "/" -a "${tgt}" '>' '10.4' ; then
942 CFLAGS="${UNIVERSAL_ARCH_FLAGS} -isysroot ${UNIVERSALSDK} ${CFLAGS}"
943 fi
Thomas Wouters477c8d52006-05-27 19:21:47 +0000944 fi
945
Benjamin Peterson67c38e22008-07-17 16:10:34 +0000946 # Calculate the right deployment target for this build.
947 #
948 cur_target=`sw_vers -productVersion | sed 's/\(10\.[[0-9]]*\).*/\1/'`
949 if test ${cur_target} '>' 10.2; then
950 cur_target=10.3
Ronald Oussorend45ff2c2009-09-06 11:11:04 +0000951 if test ${enable_universalsdk}; then
952 if test "${UNIVERSAL_ARCHS}" = "all"; then
953 # Ensure that the default platform for a
954 # 4-way universal build is OSX 10.5,
955 # that's the first OS release where
956 # 4-way builds make sense.
957 cur_target='10.5'
Ronald Oussoren856624d2009-09-08 07:13:53 +0000958
959 elif test "${UNIVERSAL_ARCHS}" = "3-way"; then
960 cur_target='10.5'
961
962 elif test "${UNIVERSAL_ARCHS}" = "intel"; then
963 cur_target='10.5'
964
965 elif test "${UNIVERSAL_ARCHS}" = "64-bit"; then
966 cur_target='10.5'
Ronald Oussorend45ff2c2009-09-06 11:11:04 +0000967 fi
968 else
Ronald Oussoren175a8842010-02-11 13:40:06 +0000969 if test `/usr/bin/arch` = "i386"; then
Ronald Oussorend45ff2c2009-09-06 11:11:04 +0000970 # On Intel macs default to a deployment
971 # target of 10.4, that's the first OSX
972 # release with Intel support.
973 cur_target="10.4"
974 fi
975 fi
Benjamin Peterson67c38e22008-07-17 16:10:34 +0000976 fi
977 CONFIGURE_MACOSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET-${cur_target}}
978
979 # Make sure that MACOSX_DEPLOYMENT_TARGET is set in the
980 # environment with a value that is the same as what we'll use
981 # in the Makefile to ensure that we'll get the same compiler
982 # environment during configure and build time.
983 MACOSX_DEPLOYMENT_TARGET="$CONFIGURE_MACOSX_DEPLOYMENT_TARGET"
984 export MACOSX_DEPLOYMENT_TARGET
985 EXPORT_MACOSX_DEPLOYMENT_TARGET=''
986
Skip Montanarodecc6a42003-01-01 20:07:49 +0000987 ;;
Thomas Wouters49fd7fa2006-04-21 10:40:58 +0000988 OSF*)
989 BASECFLAGS="$BASECFLAGS -mieee"
990 ;;
Skip Montanarodecc6a42003-01-01 20:07:49 +0000991 esac
992 ;;
993
994*)
995 case $ac_sys_system in
996 OpenUNIX*|UnixWare*)
997 BASECFLAGS="$BASECFLAGS -K pentium,host,inline,loop_unroll,alloca "
998 ;;
Neal Norwitzb44f1652003-05-26 14:11:55 +0000999 OSF*)
1000 BASECFLAGS="$BASECFLAGS -ieee -std"
1001 ;;
Skip Montanarodecc6a42003-01-01 20:07:49 +00001002 SCO_SV*)
1003 BASECFLAGS="$BASECFLAGS -belf -Ki486 -DSCO5"
1004 ;;
1005 esac
1006 ;;
1007esac
1008
Fred Drakee1ceaa02001-12-04 20:55:47 +00001009if test "$Py_DEBUG" = 'true'; then
1010 :
1011else
1012 OPT="-DNDEBUG $OPT"
1013fi
1014
Guido van Rossum6f2260e1996-09-09 16:21:03 +00001015if test "$ac_arch_flags"
Guido van Rossumc5a39031996-07-31 17:35:03 +00001016then
Skip Montanarodecc6a42003-01-01 20:07:49 +00001017 BASECFLAGS="$BASECFLAGS $ac_arch_flags"
Guido van Rossumc5a39031996-07-31 17:35:03 +00001018fi
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001019
Neal Norwitz020c46a2006-01-07 21:39:28 +00001020# disable check for icc since it seems to pass, but generates a warning
1021if test "$CC" = icc
1022then
1023 ac_cv_opt_olimit_ok=no
1024fi
1025
Guido van Rossum91922671997-10-09 20:24:13 +00001026AC_MSG_CHECKING(whether $CC accepts -OPT:Olimit=0)
1027AC_CACHE_VAL(ac_cv_opt_olimit_ok,
1028[ac_save_cc="$CC"
1029CC="$CC -OPT:Olimit=0"
1030AC_TRY_RUN([int main() { return 0; }],
1031 ac_cv_opt_olimit_ok=yes,
Guido van Rossum3065c942001-09-17 04:03:14 +00001032 ac_cv_opt_olimit_ok=no,
Guido van Rossum91922671997-10-09 20:24:13 +00001033 ac_cv_opt_olimit_ok=no)
1034CC="$ac_save_cc"])
1035AC_MSG_RESULT($ac_cv_opt_olimit_ok)
Guido van Rossum2efa34b1997-10-23 17:43:11 +00001036if test $ac_cv_opt_olimit_ok = yes; then
Guido van Rossum5839e582000-10-09 19:52:35 +00001037 case $ac_sys_system in
Skip Montanarodecc6a42003-01-01 20:07:49 +00001038 # XXX is this branch needed? On MacOSX 10.2.2 the result of the
1039 # olimit_ok test is "no". Is it "yes" in some other Darwin-esque
1040 # environment?
1041 Darwin*)
1042 ;;
1043 *)
1044 BASECFLAGS="$BASECFLAGS -OPT:Olimit=0"
1045 ;;
Guido van Rossum5839e582000-10-09 19:52:35 +00001046 esac
Guido van Rossumf8678121998-07-07 21:05:09 +00001047else
1048 AC_MSG_CHECKING(whether $CC accepts -Olimit 1500)
1049 AC_CACHE_VAL(ac_cv_olimit_ok,
1050 [ac_save_cc="$CC"
1051 CC="$CC -Olimit 1500"
1052 AC_TRY_RUN([int main() { return 0; }],
1053 ac_cv_olimit_ok=yes,
Guido van Rossum3065c942001-09-17 04:03:14 +00001054 ac_cv_olimit_ok=no,
Guido van Rossumf8678121998-07-07 21:05:09 +00001055 ac_cv_olimit_ok=no)
1056 CC="$ac_save_cc"])
1057 AC_MSG_RESULT($ac_cv_olimit_ok)
1058 if test $ac_cv_olimit_ok = yes; then
Skip Montanarodecc6a42003-01-01 20:07:49 +00001059 BASECFLAGS="$BASECFLAGS -Olimit 1500"
Guido van Rossumf8678121998-07-07 21:05:09 +00001060 fi
Guido van Rossum201afe51997-05-14 21:14:44 +00001061fi
Guido van Rossumf8678121998-07-07 21:05:09 +00001062
Thomas Wouters89f507f2006-12-13 04:49:30 +00001063# Check whether GCC supports PyArg_ParseTuple format
1064if test "$GCC" = "yes"
1065then
1066 AC_MSG_CHECKING(whether gcc supports ParseTuple __format__)
1067 save_CFLAGS=$CFLAGS
1068 CFLAGS="$CFLAGS -Werror"
1069 AC_TRY_COMPILE([
1070 void f(char*,...)__attribute((format(PyArg_ParseTuple, 1, 2)));
1071 ],,
1072 AC_DEFINE(HAVE_ATTRIBUTE_FORMAT_PARSETUPLE, 1, [Define if GCC supports __attribute__((format(PyArg_ParseTuple, 2, 3)))])
1073 AC_MSG_RESULT(yes),
1074 AC_MSG_RESULT(no)
1075 )
1076 CFLAGS=$save_CFLAGS
1077fi
1078
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00001079# On some compilers, pthreads are available without further options
1080# (e.g. MacOS X). On some of these systems, the compiler will not
1081# complain if unaccepted options are passed (e.g. gcc on Mac OS X).
1082# So we have to see first whether pthreads are available without
1083# options before we can check whether -Kpthread improves anything.
1084AC_MSG_CHECKING(whether pthreads are available without options)
1085AC_CACHE_VAL(ac_cv_pthread_is_default,
1086[AC_TRY_RUN([
1087#include <pthread.h>
1088
1089void* routine(void* p){return NULL;}
1090
1091int main(){
1092 pthread_t p;
1093 if(pthread_create(&p,NULL,routine,NULL)!=0)
1094 return 1;
Jack Jansen4f8d0542002-03-08 13:43:01 +00001095 (void)pthread_detach(p);
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00001096 return 0;
1097}
1098],
Skip Montanarod8d39a02003-07-10 20:44:10 +00001099[
1100 ac_cv_pthread_is_default=yes
1101 ac_cv_kthread=no
1102 ac_cv_pthread=no
1103],
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00001104 ac_cv_pthread_is_default=no,
1105 ac_cv_pthread_is_default=no)
1106])
1107AC_MSG_RESULT($ac_cv_pthread_is_default)
1108
1109
1110if test $ac_cv_pthread_is_default = yes
1111then
1112 ac_cv_kpthread=no
1113else
Martin v. Löwis130fb172001-07-19 11:00:41 +00001114# -Kpthread, if available, provides the right #defines
1115# and linker options to make pthread_create available
Martin v. Löwis260aecc2001-10-07 08:14:41 +00001116# Some compilers won't report that they do not support -Kpthread,
1117# so we need to run a program to see whether it really made the
1118# function available.
Martin v. Löwis130fb172001-07-19 11:00:41 +00001119AC_MSG_CHECKING(whether $CC accepts -Kpthread)
1120AC_CACHE_VAL(ac_cv_kpthread,
1121[ac_save_cc="$CC"
1122CC="$CC -Kpthread"
Martin v. Löwis260aecc2001-10-07 08:14:41 +00001123AC_TRY_RUN([
1124#include <pthread.h>
1125
1126void* routine(void* p){return NULL;}
1127
1128int main(){
1129 pthread_t p;
1130 if(pthread_create(&p,NULL,routine,NULL)!=0)
1131 return 1;
Jack Jansen4f8d0542002-03-08 13:43:01 +00001132 (void)pthread_detach(p);
Martin v. Löwis260aecc2001-10-07 08:14:41 +00001133 return 0;
1134}
1135],
Martin v. Löwis130fb172001-07-19 11:00:41 +00001136 ac_cv_kpthread=yes,
Martin v. Löwis260aecc2001-10-07 08:14:41 +00001137 ac_cv_kpthread=no,
Martin v. Löwis130fb172001-07-19 11:00:41 +00001138 ac_cv_kpthread=no)
1139CC="$ac_save_cc"])
Martin v. Löwis130fb172001-07-19 11:00:41 +00001140AC_MSG_RESULT($ac_cv_kpthread)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00001141fi
Martin v. Löwis130fb172001-07-19 11:00:41 +00001142
Skip Montanarod8d39a02003-07-10 20:44:10 +00001143if test $ac_cv_kpthread = no -a $ac_cv_pthread_is_default = no
Martin v. Löwis5f433f02003-05-05 05:05:30 +00001144then
1145# -Kthread, if available, provides the right #defines
1146# and linker options to make pthread_create available
1147# Some compilers won't report that they do not support -Kthread,
1148# so we need to run a program to see whether it really made the
1149# function available.
1150AC_MSG_CHECKING(whether $CC accepts -Kthread)
1151AC_CACHE_VAL(ac_cv_kthread,
1152[ac_save_cc="$CC"
1153CC="$CC -Kthread"
1154AC_TRY_RUN([
1155#include <pthread.h>
1156
1157void* routine(void* p){return NULL;}
1158
1159int main(){
1160 pthread_t p;
1161 if(pthread_create(&p,NULL,routine,NULL)!=0)
1162 return 1;
1163 (void)pthread_detach(p);
1164 return 0;
1165}
1166],
1167 ac_cv_kthread=yes,
1168 ac_cv_kthread=no,
1169 ac_cv_kthread=no)
1170CC="$ac_save_cc"])
1171AC_MSG_RESULT($ac_cv_kthread)
1172fi
1173
Skip Montanarod8d39a02003-07-10 20:44:10 +00001174if test $ac_cv_kthread = no -a $ac_cv_pthread_is_default = no
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00001175then
1176# -pthread, if available, provides the right #defines
1177# and linker options to make pthread_create available
1178# Some compilers won't report that they do not support -pthread,
1179# so we need to run a program to see whether it really made the
1180# function available.
1181AC_MSG_CHECKING(whether $CC accepts -pthread)
1182AC_CACHE_VAL(ac_cv_thread,
1183[ac_save_cc="$CC"
1184CC="$CC -pthread"
1185AC_TRY_RUN([
1186#include <pthread.h>
1187
1188void* routine(void* p){return NULL;}
1189
1190int main(){
1191 pthread_t p;
1192 if(pthread_create(&p,NULL,routine,NULL)!=0)
1193 return 1;
1194 (void)pthread_detach(p);
1195 return 0;
1196}
1197],
1198 ac_cv_pthread=yes,
1199 ac_cv_pthread=no,
1200 ac_cv_pthread=no)
1201CC="$ac_save_cc"])
1202AC_MSG_RESULT($ac_cv_pthread)
1203fi
1204
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001205# If we have set a CC compiler flag for thread support then
1206# check if it works for CXX, too.
1207ac_cv_cxx_thread=no
1208if test ! -z "$CXX"
1209then
1210AC_MSG_CHECKING(whether $CXX also accepts flags for thread support)
1211ac_save_cxx="$CXX"
1212
1213if test "$ac_cv_kpthread" = "yes"
1214then
Martin v. Löwis519adae2003-09-20 10:47:47 +00001215 CXX="$CXX -Kpthread"
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001216 ac_cv_cxx_thread=yes
1217elif test "$ac_cv_kthread" = "yes"
1218then
1219 CXX="$CXX -Kthread"
1220 ac_cv_cxx_thread=yes
1221elif test "$ac_cv_pthread" = "yes"
1222then
1223 CXX="$CXX -pthread"
1224 ac_cv_cxx_thread=yes
1225fi
1226
1227if test $ac_cv_cxx_thread = yes
1228then
1229 echo 'void foo();int main(){foo();}void foo(){}' > conftest.$ac_ext
1230 $CXX -c conftest.$ac_ext 2>&5
1231 if $CXX -o conftest$ac_exeext conftest.$ac_objext 2>&5 \
1232 && test -s conftest$ac_exeext && ./conftest$ac_exeext
1233 then
1234 ac_cv_cxx_thread=yes
1235 else
1236 ac_cv_cxx_thread=no
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001237 fi
1238 rm -fr conftest*
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001239fi
Brett Cannonc601e0f2004-11-07 01:24:12 +00001240AC_MSG_RESULT($ac_cv_cxx_thread)
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001241fi
Martin v. Löwis519adae2003-09-20 10:47:47 +00001242CXX="$ac_save_cxx"
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001243
Fred Drakece81d592000-07-09 14:39:29 +00001244dnl # check for ANSI or K&R ("traditional") preprocessor
1245dnl AC_MSG_CHECKING(for C preprocessor type)
1246dnl AC_TRY_COMPILE([
1247dnl #define spam(name, doc) {#name, &name, #name "() -- " doc}
1248dnl int foo;
1249dnl struct {char *name; int *addr; char *doc;} desc = spam(foo, "something");
1250dnl ], [;], cpp_type=ansi, AC_DEFINE(HAVE_OLD_CPP) cpp_type=traditional)
1251dnl AC_MSG_RESULT($cpp_type)
Guido van Rossum300fda71996-08-19 21:58:16 +00001252
Guido van Rossum627b2d71993-12-24 10:39:16 +00001253# checks for header files
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001254AC_HEADER_STDC
Thomas Wouters0e3f5912006-08-11 14:57:12 +00001255AC_CHECK_HEADERS(asm/types.h conio.h curses.h direct.h dlfcn.h errno.h \
1256fcntl.h grp.h \
Christian Heimesbbe741d2008-03-28 10:53:29 +00001257ieeefp.h io.h langinfo.h libintl.h ncurses.h poll.h process.h pthread.h \
Thomas Wouters89f507f2006-12-13 04:49:30 +00001258shadow.h signal.h stdint.h stropts.h termios.h thread.h \
Martin v. Löwis14e73b12003-01-01 09:51:12 +00001259unistd.h utime.h \
Christian Heimes4fbc72b2008-03-22 00:47:35 +00001260sys/audioio.h sys/bsdtty.h sys/epoll.h sys/event.h sys/file.h sys/loadavg.h \
1261sys/lock.h sys/mkdev.h sys/modem.h \
Thomas Wouters0e3f5912006-08-11 14:57:12 +00001262sys/param.h sys/poll.h sys/select.h sys/socket.h sys/statvfs.h sys/stat.h \
Georg Brandlf78e02b2008-06-10 17:40:04 +00001263sys/termio.h sys/time.h \
Thomas Wouters0e3f5912006-08-11 14:57:12 +00001264sys/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 +00001265sys/resource.h netpacket/packet.h sysexits.h bluetooth.h \
Christian Heimes043d6f62008-01-07 17:19:16 +00001266bluetooth/bluetooth.h linux/tipc.h)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001267AC_HEADER_DIRENT
Martin v. Löwisdbe3f762002-10-10 14:27:30 +00001268AC_HEADER_MAJOR
Guido van Rossum627b2d71993-12-24 10:39:16 +00001269
Martin v. Löwisae2830c2004-09-18 09:54:52 +00001270# On Solaris, term.h requires curses.h
Martin v. Löwisfd1c69e72004-11-30 22:09:37 +00001271AC_CHECK_HEADERS(term.h,,,[
Martin v. Löwis5d52e782004-09-18 10:07:03 +00001272#ifdef HAVE_CURSES_H
1273#include <curses.h>
1274#endif
1275])
Martin v. Löwisae2830c2004-09-18 09:54:52 +00001276
Martin v. Löwis11017b12006-01-14 18:12:57 +00001277# On Linux, netlink.h requires asm/types.h
1278AC_CHECK_HEADERS(linux/netlink.h,,,[
1279#ifdef HAVE_ASM_TYPES_H
1280#include <asm/types.h>
1281#endif
1282#ifdef HAVE_SYS_SOCKET_H
1283#include <sys/socket.h>
1284#endif
1285])
1286
Guido van Rossum627b2d71993-12-24 10:39:16 +00001287# checks for typedefs
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001288was_it_defined=no
1289AC_MSG_CHECKING(for clock_t in time.h)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001290AC_EGREP_HEADER(clock_t, time.h, was_it_defined=yes, [
1291 AC_DEFINE(clock_t, long, [Define to 'long' if <time.h> doesn't define.])
1292])
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001293AC_MSG_RESULT($was_it_defined)
1294
Neal Norwitz11690112002-07-30 01:08:28 +00001295# Check whether using makedev requires defining _OSF_SOURCE
1296AC_MSG_CHECKING(for makedev)
Neal Norwitz6eb37f02003-02-23 23:28:15 +00001297AC_TRY_LINK([#include <sys/types.h> ],
Neal Norwitz11690112002-07-30 01:08:28 +00001298 [ makedev(0, 0) ],
1299 ac_cv_has_makedev=yes,
1300 ac_cv_has_makedev=no)
1301if test "$ac_cv_has_makedev" = "no"; then
1302 # we didn't link, try if _OSF_SOURCE will allow us to link
1303 AC_TRY_LINK([
Neal Norwitz6eb37f02003-02-23 23:28:15 +00001304#define _OSF_SOURCE 1
1305#include <sys/types.h>
Neal Norwitz11690112002-07-30 01:08:28 +00001306 ],
1307 [ makedev(0, 0) ],
1308 ac_cv_has_makedev=yes,
1309 ac_cv_has_makedev=no)
1310 if test "$ac_cv_has_makedev" = "yes"; then
1311 AC_DEFINE(_OSF_SOURCE, 1, [Define _OSF_SOURCE to get the makedev macro.])
1312 fi
1313fi
1314AC_MSG_RESULT($ac_cv_has_makedev)
1315if test "$ac_cv_has_makedev" = "yes"; then
1316 AC_DEFINE(HAVE_MAKEDEV, 1, [Define this if you have the makedev macro.])
1317fi
1318
Martin v. Löwis399a6892002-10-04 10:22:02 +00001319# Enabling LFS on Solaris (2.6 to 9) with gcc 2.95 triggers a bug in
1320# the system headers: If _XOPEN_SOURCE and _LARGEFILE_SOURCE are
1321# defined, but the compiler does not support pragma redefine_extname,
1322# and _LARGEFILE64_SOURCE is not defined, the headers refer to 64-bit
1323# structures (such as rlimit64) without declaring them. As a
1324# work-around, disable LFS on such configurations
1325
1326use_lfs=yes
1327AC_MSG_CHECKING(Solaris LFS bug)
1328AC_TRY_COMPILE([
1329#define _LARGEFILE_SOURCE 1
1330#define _FILE_OFFSET_BITS 64
1331#include <sys/resource.h>
1332],struct rlimit foo;,sol_lfs_bug=no,sol_lfs_bug=yes)
1333AC_MSG_RESULT($sol_lfs_bug)
1334if test "$sol_lfs_bug" = "yes"; then
1335 use_lfs=no
1336fi
1337
1338if test "$use_lfs" = "yes"; then
Guido van Rossum810cc512001-09-09 23:51:39 +00001339# Two defines needed to enable largefile support on various platforms
1340# These may affect some typedefs
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001341AC_DEFINE(_LARGEFILE_SOURCE, 1,
1342[This must be defined on some systems to enable large file support.])
1343AC_DEFINE(_FILE_OFFSET_BITS, 64,
1344[This must be set to 64 on some systems to enable large file support.])
Martin v. Löwis399a6892002-10-04 10:22:02 +00001345fi
Guido van Rossum810cc512001-09-09 23:51:39 +00001346
Guido van Rossum300fda71996-08-19 21:58:16 +00001347# Add some code to confdefs.h so that the test for off_t works on SCO
1348cat >> confdefs.h <<\EOF
1349#if defined(SCO_DS)
1350#undef _OFF_T
1351#endif
1352EOF
1353
Guido van Rossumef2255b2000-03-10 22:30:29 +00001354# Type availability checks
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001355AC_TYPE_MODE_T
1356AC_TYPE_OFF_T
1357AC_TYPE_PID_T
1358AC_TYPE_SIGNAL
1359AC_TYPE_SIZE_T
1360AC_TYPE_UID_T
Mark Dickinsonbd792642009-03-18 20:06:12 +00001361AC_TYPE_UINT32_T
1362AC_TYPE_UINT64_T
1363AC_TYPE_INT32_T
1364AC_TYPE_INT64_T
Christian Heimes400adb02008-02-01 08:12:03 +00001365AC_CHECK_TYPE(ssize_t,
Martin v. Löwis18e16552006-02-15 17:27:45 +00001366 AC_DEFINE(HAVE_SSIZE_T, 1, Define if your compiler provides ssize_t),,)
Guido van Rossum627b2d71993-12-24 10:39:16 +00001367
Guido van Rossumef2255b2000-03-10 22:30:29 +00001368# Sizes of various common basic types
Skip Montanarob9820a32004-01-17 00:16:12 +00001369# ANSI C requires sizeof(char) == 1, so no need to check it
Guido van Rossum3065c942001-09-17 04:03:14 +00001370AC_CHECK_SIZEOF(int, 4)
1371AC_CHECK_SIZEOF(long, 4)
1372AC_CHECK_SIZEOF(void *, 4)
Guido van Rossum3065c942001-09-17 04:03:14 +00001373AC_CHECK_SIZEOF(short, 2)
1374AC_CHECK_SIZEOF(float, 4)
1375AC_CHECK_SIZEOF(double, 8)
1376AC_CHECK_SIZEOF(fpos_t, 4)
Martin v. Löwis18e16552006-02-15 17:27:45 +00001377AC_CHECK_SIZEOF(size_t, 4)
Christian Heimes400adb02008-02-01 08:12:03 +00001378AC_CHECK_SIZEOF(pid_t, 4)
Guido van Rossumac405f61994-09-12 10:56:06 +00001379
Guido van Rossumec95c7b1998-08-04 17:59:56 +00001380AC_MSG_CHECKING(for long long support)
1381have_long_long=no
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001382AC_TRY_COMPILE([], [long long x; x = (long long)0;], [
1383 AC_DEFINE(HAVE_LONG_LONG, 1, [Define this if you have the type long long.])
1384 have_long_long=yes
1385])
Guido van Rossumec95c7b1998-08-04 17:59:56 +00001386AC_MSG_RESULT($have_long_long)
Guido van Rossum8bc1dfd1999-04-10 16:01:48 +00001387if test "$have_long_long" = yes ; then
Guido van Rossum3065c942001-09-17 04:03:14 +00001388AC_CHECK_SIZEOF(long long, 8)
Guido van Rossumec95c7b1998-08-04 17:59:56 +00001389fi
1390
Travis E. Oliphant9b307842007-10-12 22:06:37 +00001391AC_MSG_CHECKING(for long double support)
1392have_long_double=no
1393AC_TRY_COMPILE([], [long double x; x = (long double)0;], [
1394 AC_DEFINE(HAVE_LONG_DOUBLE, 1, [Define this if you have the type long double.])
1395 have_long_double=yes
1396])
1397AC_MSG_RESULT($have_long_double)
1398if test "$have_long_double" = yes ; then
1399AC_CHECK_SIZEOF(long double, 16)
1400fi
1401
1402
Thomas Woutersb2137042007-02-01 18:02:27 +00001403AC_MSG_CHECKING(for _Bool support)
1404have_c99_bool=no
1405AC_TRY_COMPILE([], [_Bool x; x = (_Bool)0;], [
1406 AC_DEFINE(HAVE_C99_BOOL, 1, [Define this if you have the type _Bool.])
1407 have_c99_bool=yes
1408])
1409AC_MSG_RESULT($have_c99_bool)
1410if test "$have_c99_bool" = yes ; then
1411AC_CHECK_SIZEOF(_Bool, 1)
1412fi
1413
Thomas Wouters89f507f2006-12-13 04:49:30 +00001414AC_CHECK_TYPES(uintptr_t,
1415 [AC_CHECK_SIZEOF(uintptr_t, 4)],
1416 [], [#ifdef HAVE_STDINT_H
1417 #include <stdint.h>
1418 #endif])
1419
Barry Warsawbc7c7f92000-08-18 04:53:33 +00001420
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001421# Hmph. AC_CHECK_SIZEOF() doesn't include <sys/types.h>.
1422AC_MSG_CHECKING(size of off_t)
1423AC_CACHE_VAL(ac_cv_sizeof_off_t,
1424[AC_TRY_RUN([#include <stdio.h>
1425#include <sys/types.h>
1426main()
1427{
1428 FILE *f=fopen("conftestval", "w");
1429 if (!f) exit(1);
1430 fprintf(f, "%d\n", sizeof(off_t));
1431 exit(0);
Guido van Rossum3065c942001-09-17 04:03:14 +00001432}],
1433ac_cv_sizeof_off_t=`cat conftestval`,
1434ac_cv_sizeof_off_t=0,
1435ac_cv_sizeof_off_t=4)
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001436])
1437AC_MSG_RESULT($ac_cv_sizeof_off_t)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001438AC_DEFINE_UNQUOTED(SIZEOF_OFF_T, $ac_cv_sizeof_off_t,
1439[The number of bytes in an off_t.])
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001440
1441AC_MSG_CHECKING(whether to enable large file support)
Mark Dickinsonb87f0d02009-12-31 21:25:02 +00001442if test "$have_long_long" = yes
1443then
1444if test "$ac_cv_sizeof_off_t" -gt "$ac_cv_sizeof_long" -a \
Guido van Rossum8bc1dfd1999-04-10 16:01:48 +00001445 "$ac_cv_sizeof_long_long" -ge "$ac_cv_sizeof_off_t"; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001446 AC_DEFINE(HAVE_LARGEFILE_SUPPORT, 1,
1447 [Defined to enable large file support when an off_t is bigger than a long
1448 and long long is available and at least as big as an off_t. You may need
1449 to add some flags for configuration and compilation to enable this mode.
1450 (For Solaris and Linux, the necessary defines are already defined.)])
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001451 AC_MSG_RESULT(yes)
1452else
1453 AC_MSG_RESULT(no)
1454fi
Mark Dickinsonb87f0d02009-12-31 21:25:02 +00001455else
1456 AC_MSG_RESULT(no)
1457fi
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001458
Fred Drakea3f6e912000-06-29 20:44:47 +00001459# AC_CHECK_SIZEOF() doesn't include <time.h>.
1460AC_MSG_CHECKING(size of time_t)
1461AC_CACHE_VAL(ac_cv_sizeof_time_t,
1462[AC_TRY_RUN([#include <stdio.h>
1463#include <time.h>
1464main()
1465{
1466 FILE *f=fopen("conftestval", "w");
1467 if (!f) exit(1);
1468 fprintf(f, "%d\n", sizeof(time_t));
1469 exit(0);
Guido van Rossum3065c942001-09-17 04:03:14 +00001470}],
1471ac_cv_sizeof_time_t=`cat conftestval`,
1472ac_cv_sizeof_time_t=0,
1473ac_cv_sizeof_time_t=4)
Fred Drakea3f6e912000-06-29 20:44:47 +00001474])
1475AC_MSG_RESULT($ac_cv_sizeof_time_t)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001476AC_DEFINE_UNQUOTED(SIZEOF_TIME_T, $ac_cv_sizeof_time_t,
1477[The number of bytes in a time_t.])
Fred Drakea3f6e912000-06-29 20:44:47 +00001478
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001479
Trent Mick635f6fb2000-08-23 21:33:05 +00001480# if have pthread_t then define SIZEOF_PTHREAD_T
Martin v. Löwis123cbd22001-07-19 14:21:10 +00001481ac_save_cc="$CC"
1482if test "$ac_cv_kpthread" = "yes"
1483then CC="$CC -Kpthread"
Martin v. Löwis5f433f02003-05-05 05:05:30 +00001484elif test "$ac_cv_kthread" = "yes"
1485then CC="$CC -Kthread"
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00001486elif test "$ac_cv_pthread" = "yes"
1487then CC="$CC -pthread"
Martin v. Löwis123cbd22001-07-19 14:21:10 +00001488fi
Trent Mick635f6fb2000-08-23 21:33:05 +00001489AC_MSG_CHECKING(for pthread_t)
1490have_pthread_t=no
Guido van Rossum12580492000-09-24 16:47:19 +00001491AC_TRY_COMPILE([#include <pthread.h>], [pthread_t x; x = *(pthread_t*)0;], have_pthread_t=yes)
Trent Mick635f6fb2000-08-23 21:33:05 +00001492AC_MSG_RESULT($have_pthread_t)
1493if test "$have_pthread_t" = yes ; then
1494 # AC_CHECK_SIZEOF() doesn't include <pthread.h>.
1495 AC_MSG_CHECKING(size of pthread_t)
1496 AC_CACHE_VAL(ac_cv_sizeof_pthread_t,
1497 [AC_TRY_RUN([#include <stdio.h>
Neal Norwitz6eb37f02003-02-23 23:28:15 +00001498#include <pthread.h>
Trent Mick635f6fb2000-08-23 21:33:05 +00001499 main()
1500 {
1501 FILE *f=fopen("conftestval", "w");
1502 if (!f) exit(1);
1503 fprintf(f, "%d\n", sizeof(pthread_t));
1504 exit(0);
Guido van Rossum3065c942001-09-17 04:03:14 +00001505 }],
1506 ac_cv_sizeof_pthread_t=`cat conftestval`,
1507 ac_cv_sizeof_pthread_t=0,
1508 ac_cv_sizeof_pthread_t=4)
Trent Mick635f6fb2000-08-23 21:33:05 +00001509 ])
1510 AC_MSG_RESULT($ac_cv_sizeof_pthread_t)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001511 AC_DEFINE_UNQUOTED(SIZEOF_PTHREAD_T, $ac_cv_sizeof_pthread_t,
1512 [The number of bytes in a pthread_t.])
Trent Mick635f6fb2000-08-23 21:33:05 +00001513fi
Martin v. Löwis123cbd22001-07-19 14:21:10 +00001514CC="$ac_save_cc"
Trent Mick635f6fb2000-08-23 21:33:05 +00001515
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001516
Georg Brandl93de2162008-07-16 02:21:06 +00001517
Bob Ippolito7026a0a2005-03-28 23:23:47 +00001518AC_SUBST(OTHER_LIBTOOL_OPT)
1519case $ac_sys_system/$ac_sys_release in
Thomas Wouters49fd7fa2006-04-21 10:40:58 +00001520 Darwin/@<:@01567@:>@\..*)
Bob Ippolito7026a0a2005-03-28 23:23:47 +00001521 OTHER_LIBTOOL_OPT="-prebind -seg1addr 0x10000000"
1522 ;;
1523 Darwin/*)
1524 OTHER_LIBTOOL_OPT=""
1525 ;;
1526esac
1527
Ronald Oussorend45ff2c2009-09-06 11:11:04 +00001528
1529ARCH_RUN_32BIT=""
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001530AC_SUBST(LIBTOOL_CRUFT)
1531case $ac_sys_system/$ac_sys_release in
Thomas Wouters49fd7fa2006-04-21 10:40:58 +00001532 Darwin/@<:@01567@:>@\..*)
Thomas Wouters477c8d52006-05-27 19:21:47 +00001533 LIBTOOL_CRUFT="-framework System -lcc_dynamic"
1534 if test "${enable_universalsdk}"; then
1535 :
1536 else
Ronald Oussoren175a8842010-02-11 13:40:06 +00001537 LIBTOOL_CRUFT="${LIBTOOL_CRUFT} -arch_only `/usr/bin/arch`"
Thomas Wouters477c8d52006-05-27 19:21:47 +00001538 fi
Jack Jansenb36687a2004-07-16 08:43:47 +00001539 LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -install_name $(PYTHONFRAMEWORKINSTALLDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansena3891ea2001-09-07 14:25:12 +00001540 LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -compatibility_version $(VERSION) -current_version $(VERSION)';;
Guido van Rossum5839e582000-10-09 19:52:35 +00001541 Darwin/*)
Ronald Oussoren652f4de2010-02-07 11:54:03 +00001542 gcc_version=`gcc -dumpversion`
Bob Ippolito7026a0a2005-03-28 23:23:47 +00001543 if test ${gcc_version} '<' 4.0
1544 then
1545 LIBTOOL_CRUFT="-lcc_dynamic"
1546 else
1547 LIBTOOL_CRUFT=""
1548 fi
Ronald Oussoren856624d2009-09-08 07:13:53 +00001549 AC_TRY_RUN([
Ronald Oussorend45ff2c2009-09-06 11:11:04 +00001550 #include <unistd.h>
1551 int main(int argc, char*argv[])
1552 {
1553 if (sizeof(long) == 4) {
1554 return 0;
1555 } else {
1556 return 1;
1557 }
Ronald Oussoren856624d2009-09-08 07:13:53 +00001558 }
1559 ], ac_osx_32bit=yes,
Ronald Oussorend45ff2c2009-09-06 11:11:04 +00001560 ac_osx_32bit=no,
Ronald Oussoren856624d2009-09-08 07:13:53 +00001561 ac_osx_32bit=yes)
Ronald Oussorend45ff2c2009-09-06 11:11:04 +00001562
1563 if test "${ac_osx_32bit}" = "yes"; then
Ronald Oussoren175a8842010-02-11 13:40:06 +00001564 case `/usr/bin/arch` in
Ronald Oussorend45ff2c2009-09-06 11:11:04 +00001565 i386)
1566 MACOSX_DEFAULT_ARCH="i386"
1567 ;;
1568 ppc)
1569 MACOSX_DEFAULT_ARCH="ppc"
1570 ;;
1571 *)
1572 AC_MSG_ERROR([Unexpected output of 'arch' on OSX])
1573 ;;
1574 esac
1575 else
Ronald Oussoren175a8842010-02-11 13:40:06 +00001576 case `/usr/bin/arch` in
Ronald Oussorend45ff2c2009-09-06 11:11:04 +00001577 i386)
1578 MACOSX_DEFAULT_ARCH="x86_64"
1579 ;;
1580 ppc)
1581 MACOSX_DEFAULT_ARCH="ppc64"
1582 ;;
1583 *)
1584 AC_MSG_ERROR([Unexpected output of 'arch' on OSX])
1585 ;;
1586 esac
1587
1588 #ARCH_RUN_32BIT="true"
1589 fi
1590
1591 LIBTOOL_CRUFT=$LIBTOOL_CRUFT" -lSystem -lSystemStubs -arch_only ${MACOSX_DEFAULT_ARCH}"
Jack Jansenb36687a2004-07-16 08:43:47 +00001592 LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -install_name $(PYTHONFRAMEWORKINSTALLDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001593 LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -compatibility_version $(VERSION) -current_version $(VERSION)';;
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001594esac
1595
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001596AC_MSG_CHECKING(for --enable-framework)
1597if test "$enable_framework"
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001598then
Skip Montanarodecc6a42003-01-01 20:07:49 +00001599 BASECFLAGS="$BASECFLAGS -fno-common -dynamic"
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001600 # -F. is needed to allow linking to the framework while
1601 # in the build location.
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001602 AC_DEFINE(WITH_NEXT_FRAMEWORK, 1,
1603 [Define if you want to produce an OpenStep/Rhapsody framework
1604 (shared library plus accessory files).])
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001605 AC_MSG_RESULT(yes)
Ronald Oussoren99aab652009-06-08 21:22:57 +00001606 if test $enable_shared = "yes"
1607 then
1608 AC_MSG_ERROR([Specifying both --enable-shared and --enable-framework is not supported, use only --enable-framework instead])
1609 fi
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001610else
1611 AC_MSG_RESULT(no)
1612fi
1613
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001614AC_MSG_CHECKING(for dyld)
Jack Jansen9a66b6d2001-08-08 13:56:14 +00001615case $ac_sys_system/$ac_sys_release in
1616 Darwin/*)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001617 AC_DEFINE(WITH_DYLD, 1,
1618 [Define if you want to use the new-style (Openstep, Rhapsody, MacOS)
1619 dynamic linker (dyld) instead of the old-style (NextStep) dynamic
1620 linker (rld). Dyld is necessary to support frameworks.])
Jack Jansen9a66b6d2001-08-08 13:56:14 +00001621 AC_MSG_RESULT(always on for Darwin)
1622 ;;
1623 *)
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001624 AC_MSG_RESULT(no)
1625 ;;
Jack Jansen9a66b6d2001-08-08 13:56:14 +00001626esac
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001627
Guido van Rossumac405f61994-09-12 10:56:06 +00001628# Set info about shared libraries.
Guido van Rossumac405f61994-09-12 10:56:06 +00001629AC_SUBST(SO)
1630AC_SUBST(LDSHARED)
Neil Schemenauerb3531b82001-02-16 04:09:05 +00001631AC_SUBST(BLDSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00001632AC_SUBST(CCSHARED)
1633AC_SUBST(LINKFORSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00001634# SO is the extension of shared libraries `(including the dot!)
Guido van Rossumaef734b2001-01-10 21:09:12 +00001635# -- usually .so, .sl on HP-UX, .dll on Cygwin
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001636AC_MSG_CHECKING(SO)
Guido van Rossumac405f61994-09-12 10:56:06 +00001637if test -z "$SO"
1638then
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001639 case $ac_sys_system in
Thomas Wouters477c8d52006-05-27 19:21:47 +00001640 hp*|HP*)
1641 case `uname -m` in
1642 ia64) SO=.so;;
1643 *) SO=.sl;;
1644 esac
1645 ;;
Guido van Rossumaef734b2001-01-10 21:09:12 +00001646 CYGWIN*) SO=.dll;;
Guido van Rossum4b6b5791996-09-09 20:09:34 +00001647 *) SO=.so;;
Guido van Rossumac405f61994-09-12 10:56:06 +00001648 esac
Martin v. Löwis368de8f2003-06-14 14:46:38 +00001649else
1650 # this might also be a termcap variable, see #610332
1651 echo
1652 echo '====================================================================='
1653 echo '+ +'
1654 echo '+ WARNING: You have set SO in your environment. +'
1655 echo '+ Do you really mean to change the extension for shared libraries? +'
1656 echo '+ Continuing in 10 seconds to let you to ponder. +'
1657 echo '+ +'
1658 echo '====================================================================='
1659 sleep 10
Guido van Rossumac405f61994-09-12 10:56:06 +00001660fi
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001661AC_MSG_RESULT($SO)
Georg Brandlb1441c72009-01-03 22:33:39 +00001662
Thomas Wouters477c8d52006-05-27 19:21:47 +00001663AC_DEFINE_UNQUOTED(SHLIB_EXT, "$SO", [Define this to be extension of shared libraries (including the dot!).])
Guido van Rossumac405f61994-09-12 10:56:06 +00001664# LDSHARED is the ld *command* used to create shared library
Skip Montanaroce59c042004-01-17 14:19:44 +00001665# -- "cc -G" on SunOS 5.x, "ld -shared" on IRIX 5
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001666# (Shared libraries in this instance are shared modules to be loaded into
1667# Python, as opposed to building Python itself as a shared library.)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001668AC_MSG_CHECKING(LDSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00001669if test -z "$LDSHARED"
1670then
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001671 case $ac_sys_system/$ac_sys_release in
Neil Schemenauerb3531b82001-02-16 04:09:05 +00001672 AIX*)
1673 BLDSHARED="\$(srcdir)/Modules/ld_so_aix \$(CC) -bI:Modules/python.exp"
Guido van Rossumce608b02001-09-28 15:59:38 +00001674 LDSHARED="\$(BINLIBDEST)/config/ld_so_aix \$(CC) -bI:\$(BINLIBDEST)/config/python.exp"
Neil Schemenauerb3531b82001-02-16 04:09:05 +00001675 ;;
Guido van Rossum6100aaf1997-04-29 21:48:51 +00001676 IRIX/5*) LDSHARED="ld -shared";;
Guido van Rossum91922671997-10-09 20:24:13 +00001677 IRIX*/6*) LDSHARED="ld ${SGI_ABI} -shared -all";;
Greg Ward57c9a6632000-05-26 12:22:54 +00001678 SunOS/5*)
1679 if test "$GCC" = "yes"
Neil Schemenauer95052722001-02-19 18:17:33 +00001680 then LDSHARED='$(CC) -shared'
Martin v. Löwisaa5afe12002-10-07 06:21:41 +00001681 else LDSHARED='$(CC) -G';
Greg Ward57c9a6632000-05-26 12:22:54 +00001682 fi ;;
Thomas Hellerf44b9a12008-04-04 10:18:23 +00001683 hp*|HP*)
1684 if test "$GCC" = "yes"
1685 then LDSHARED='$(CC) -shared'
1686 else LDSHARED='ld -b';
1687 fi ;;
Guido van Rossum71001e41995-01-26 00:44:03 +00001688 OSF*) LDSHARED="ld -shared -expect_unresolved \"*\"";;
Jack Jansen418c3b12001-11-14 10:59:57 +00001689 Darwin/1.3*)
Jack Jansena3891ea2001-09-07 14:25:12 +00001690 LDSHARED='$(CC) $(LDFLAGS) -bundle'
1691 if test "$enable_framework" ; then
1692 # Link against the framework. All externals should be defined.
Jack Jansenda49e192005-01-07 13:08:22 +00001693 BLDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
1694 LDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansena3891ea2001-09-07 14:25:12 +00001695 else
1696 # No framework. Ignore undefined symbols, assuming they come from Python
Jack Jansen418c3b12001-11-14 10:59:57 +00001697 LDSHARED="$LDSHARED -undefined suppress"
Jack Jansena3891ea2001-09-07 14:25:12 +00001698 fi ;;
Jack Jansen6b08a402004-06-03 12:41:45 +00001699 Darwin/1.4*|Darwin/5.*|Darwin/6.*)
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001700 LDSHARED='$(CC) $(LDFLAGS) -bundle'
1701 if test "$enable_framework" ; then
1702 # Link against the framework. All externals should be defined.
Jack Jansenda49e192005-01-07 13:08:22 +00001703 BLDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
1704 LDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001705 else
Michael W. Hudson0c46c0c2002-03-07 09:58:56 +00001706 # No framework, use the Python app as bundle-loader
1707 BLDSHARED="$LDSHARED "'-bundle_loader $(BUILDPYTHON)'
Jack Jansenc28fc372003-02-25 13:14:43 +00001708 LDSHARED="$LDSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)'
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001709 fi ;;
Jack Jansen6b08a402004-06-03 12:41:45 +00001710 Darwin/*)
1711 # Use -undefined dynamic_lookup whenever possible (10.3 and later).
1712 # This allows an extension to be used in any Python
Thomas Wouters89d996e2007-09-08 17:39:28 +00001713
Georg Brandlfcaf9102008-07-16 02:17:56 +00001714 if test ${MACOSX_DEPLOYMENT_TARGET} '>' 10.2
Jack Jansen6b08a402004-06-03 12:41:45 +00001715 then
Thomas Wouters477c8d52006-05-27 19:21:47 +00001716 if test "${enable_universalsdk}"; then
Georg Brandlfcaf9102008-07-16 02:17:56 +00001717 LDFLAGS="${UNIVERSAL_ARCH_FLAGS} -isysroot ${UNIVERSALSDK} ${LDFLAGS}"
Thomas Wouters477c8d52006-05-27 19:21:47 +00001718 fi
Jack Jansen6b08a402004-06-03 12:41:45 +00001719 LDSHARED='$(CC) $(LDFLAGS) -bundle -undefined dynamic_lookup'
1720 BLDSHARED="$LDSHARED"
Jack Jansen6b08a402004-06-03 12:41:45 +00001721 else
1722 LDSHARED='$(CC) $(LDFLAGS) -bundle'
1723 if test "$enable_framework" ; then
1724 # Link against the framework. All externals should be defined.
Jack Jansenda49e192005-01-07 13:08:22 +00001725 BLDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
1726 LDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansen6b08a402004-06-03 12:41:45 +00001727 else
1728 # No framework, use the Python app as bundle-loader
1729 BLDSHARED="$LDSHARED "'-bundle_loader $(BUILDPYTHON)'
1730 LDSHARED="$LDSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)'
1731 fi
1732 fi
1733 ;;
Georg Brandlf78e02b2008-06-10 17:40:04 +00001734 Linux*|GNU*|QNX*) LDSHARED='$(CC) -shared';;
Guido van Rossum458e7fa1999-09-17 15:40:40 +00001735 BSD/OS*/4*) LDSHARED="gcc -shared";;
Thomas Wouters1ba5b3b2006-06-08 14:52:47 +00001736 FreeBSD*)
Jeremy Hylton4bcc7c52000-08-31 17:45:35 +00001737 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
Guido van Rossum0286ae82000-08-29 15:06:49 +00001738 then
Hye-Shik Chang33761492004-10-26 09:53:46 +00001739 LDSHARED="$CC -shared ${LDFLAGS}"
Guido van Rossum0286ae82000-08-29 15:06:49 +00001740 else
1741 LDSHARED="ld -Bshareable ${LDFLAGS}"
1742 fi;;
Thomas Wouters1ba5b3b2006-06-08 14:52:47 +00001743 OpenBSD*)
1744 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
1745 then
1746 LDSHARED='$(CC) -shared $(CCSHARED) ${LDFLAGS}'
1747 else
1748 case `uname -r` in
1749 [[01]].* | 2.[[0-7]] | 2.[[0-7]].*)
1750 LDSHARED="ld -Bshareable ${LDFLAGS}"
1751 ;;
1752 *)
1753 LDSHARED='$(CC) -shared $(CCSHARED) ${LDFLAGS}'
1754 ;;
1755 esac
1756 fi;;
Martin v. Löwis86d66262006-02-17 08:40:11 +00001757 NetBSD*|DragonFly*) LDSHARED="cc -shared ${LDFLAGS}";;
Martin v. Löwis25ae43b2001-10-07 08:39:18 +00001758 OpenUNIX*|UnixWare*)
Martin v. Löwisbec19582001-03-21 15:57:54 +00001759 if test "$GCC" = "yes"
Martin v. Löwis79f3c532002-12-11 12:51:58 +00001760 then LDSHARED='$(CC) -shared'
1761 else LDSHARED='$(CC) -G'
Martin v. Löwisbec19582001-03-21 15:57:54 +00001762 fi;;
Martin v. Löwis79f3c532002-12-11 12:51:58 +00001763 SCO_SV*) LDSHARED='$(CC) -Wl,-G,-Bexport';;
Guido van Rossumaef734b2001-01-10 21:09:12 +00001764 CYGWIN*) LDSHARED="gcc -shared -Wl,--enable-auto-image-base";;
Martin v. Löwisf90ae202002-06-11 06:22:31 +00001765 atheos*) LDSHARED="gcc -shared";;
Guido van Rossumac405f61994-09-12 10:56:06 +00001766 *) LDSHARED="ld";;
1767 esac
Guido van Rossumac405f61994-09-12 10:56:06 +00001768fi
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001769AC_MSG_RESULT($LDSHARED)
Neil Schemenauerb3531b82001-02-16 04:09:05 +00001770BLDSHARED=${BLDSHARED-$LDSHARED}
Guido van Rossumac405f61994-09-12 10:56:06 +00001771# CCSHARED are the C *flags* used to create objects to go into a shared
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001772# library (module) -- this is only needed for a few systems
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001773AC_MSG_CHECKING(CCSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00001774if test -z "$CCSHARED"
1775then
Guido van Rossum6100aaf1997-04-29 21:48:51 +00001776 case $ac_sys_system/$ac_sys_release in
Neil Schemenauer66252162001-02-19 04:47:42 +00001777 SunOS*) if test "$GCC" = yes;
Guido van Rossumd8faa362007-04-27 19:54:29 +00001778 then CCSHARED="-fPIC";
1779 elif test `uname -p` = sparc;
1780 then CCSHARED="-xcode=pic32";
1781 else CCSHARED="-Kpic";
1782 fi;;
Guido van Rossumaf07a441995-02-13 19:45:27 +00001783 hp*|HP*) if test "$GCC" = yes;
Martin v. Löwis703ad702001-09-05 08:36:52 +00001784 then CCSHARED="-fPIC";
Guido van Rossumaf07a441995-02-13 19:45:27 +00001785 else CCSHARED="+z";
1786 fi;;
Martin v. Löwisa6e97582002-01-01 18:41:33 +00001787 Linux*|GNU*) CCSHARED="-fPIC";;
Guido van Rossumf5957ea1999-10-05 21:59:33 +00001788 BSD/OS*/4*) CCSHARED="-fpic";;
Martin v. Löwis86d66262006-02-17 08:40:11 +00001789 FreeBSD*|NetBSD*|OpenBSD*|DragonFly*) CCSHARED="-fPIC";;
Martin v. Löwis25ae43b2001-10-07 08:39:18 +00001790 OpenUNIX*|UnixWare*)
Martin v. Löwisbec19582001-03-21 15:57:54 +00001791 if test "$GCC" = "yes"
1792 then CCSHARED="-fPIC"
Martin v. Löwis130fb172001-07-19 11:00:41 +00001793 else CCSHARED="-KPIC"
Martin v. Löwisbec19582001-03-21 15:57:54 +00001794 fi;;
Martin v. Löwis21ee4092002-09-30 16:19:48 +00001795 SCO_SV*)
1796 if test "$GCC" = "yes"
1797 then CCSHARED="-fPIC"
1798 else CCSHARED="-Kpic -belf"
1799 fi;;
Guido van Rossum2b5ca001998-03-05 15:41:09 +00001800 IRIX*/6*) case $CC in
1801 *gcc*) CCSHARED="-shared";;
Guido van Rossumee21f411998-04-20 18:51:54 +00001802 *) CCSHARED="";;
Guido van Rossum2b5ca001998-03-05 15:41:09 +00001803 esac;;
Martin v. Löwisf90ae202002-06-11 06:22:31 +00001804 atheos*) CCSHARED="-fPIC";;
Guido van Rossumac405f61994-09-12 10:56:06 +00001805 esac
Guido van Rossumac405f61994-09-12 10:56:06 +00001806fi
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001807AC_MSG_RESULT($CCSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00001808# LINKFORSHARED are the flags passed to the $(CC) command that links
Guido van Rossumb65a48e1995-06-14 18:21:23 +00001809# the python executable -- this is only needed for a few systems
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001810AC_MSG_CHECKING(LINKFORSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00001811if test -z "$LINKFORSHARED"
1812then
Guido van Rossum6100aaf1997-04-29 21:48:51 +00001813 case $ac_sys_system/$ac_sys_release in
Neil Schemenauerb3531b82001-02-16 04:09:05 +00001814 AIX*) LINKFORSHARED='-Wl,-bE:Modules/python.exp -lld';;
Guido van Rossum5dab3d81996-12-06 21:18:18 +00001815 hp*|HP*)
Martin v. Löwis1142de32002-03-29 16:28:31 +00001816 LINKFORSHARED="-Wl,-E -Wl,+s";;
1817# LINKFORSHARED="-Wl,-E -Wl,+s -Wl,+b\$(BINLIBDEST)/lib-dynload";;
Guido van Rossumf5957ea1999-10-05 21:59:33 +00001818 BSD/OS/4*) LINKFORSHARED="-Xlinker -export-dynamic";;
Martin v. Löwisa6e97582002-01-01 18:41:33 +00001819 Linux*|GNU*) LINKFORSHARED="-Xlinker -export-dynamic";;
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001820 # -u libsys_s pulls in all symbols in libsys
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001821 Darwin/*)
Benjamin Peterson9c80cac2009-05-23 16:34:23 +00001822 LINKFORSHARED="$extra_undefs -framework CoreFoundation"
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001823 if test "$enable_framework"
1824 then
Jack Jansenda49e192005-01-07 13:08:22 +00001825 LINKFORSHARED="$LINKFORSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001826 fi
Raymond Hettingerec6eb362004-11-05 07:02:59 +00001827 LINKFORSHARED="$LINKFORSHARED";;
Martin v. Löwis25ae43b2001-10-07 08:39:18 +00001828 OpenUNIX*|UnixWare*) LINKFORSHARED="-Wl,-Bexport";;
Martin v. Löwis21ee4092002-09-30 16:19:48 +00001829 SCO_SV*) LINKFORSHARED="-Wl,-Bexport";;
Fred Drake02706f52000-09-25 15:08:46 +00001830 ReliantUNIX*) LINKFORSHARED="-W1 -Blargedynsym";;
Martin v. Löwis86d66262006-02-17 08:40:11 +00001831 FreeBSD*|NetBSD*|OpenBSD*|DragonFly*)
Guido van Rossumdf693651999-01-07 21:50:41 +00001832 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
1833 then
1834 LINKFORSHARED="-Wl,--export-dynamic"
1835 fi;;
Guido van Rossum2b5ca001998-03-05 15:41:09 +00001836 SunOS/5*) case $CC in
1837 *gcc*)
Martin v. Löwisa4548572002-04-18 14:51:36 +00001838 if $CC -Xlinker --help 2>&1 | grep export-dynamic >/dev/null
Guido van Rossum8f4ceb11997-12-18 23:42:19 +00001839 then
1840 LINKFORSHARED="-Xlinker --export-dynamic"
Guido van Rossum2b5ca001998-03-05 15:41:09 +00001841 fi;;
1842 esac;;
Jason Tishler30765592003-09-04 11:04:06 +00001843 CYGWIN*)
1844 if test $enable_shared = "no"
1845 then
1846 LINKFORSHARED='-Wl,--out-implib=$(LDLIBRARY)'
1847 fi;;
Georg Brandlf78e02b2008-06-10 17:40:04 +00001848 QNX*)
1849 # -Wl,-E causes the symbols to be added to the dynamic
1850 # symbol table so that they can be found when a module
1851 # is loaded. -N 2048K causes the stack size to be set
1852 # to 2048 kilobytes so that the stack doesn't overflow
1853 # when running test_compile.py.
1854 LINKFORSHARED='-Wl,-E -N 2048K';;
Guido van Rossumac405f61994-09-12 10:56:06 +00001855 esac
Guido van Rossumac405f61994-09-12 10:56:06 +00001856fi
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001857AC_MSG_RESULT($LINKFORSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00001858
Georg Brandl93de2162008-07-16 02:21:06 +00001859
Neil Schemenauer61c51152001-01-26 16:18:16 +00001860AC_SUBST(CFLAGSFORSHARED)
1861AC_MSG_CHECKING(CFLAGSFORSHARED)
1862if test ! "$LIBRARY" = "$LDLIBRARY"
1863then
Neil Schemenauerd9cf41c2001-01-27 21:39:17 +00001864 case $ac_sys_system in
1865 CYGWIN*)
1866 # Cygwin needs CCSHARED when building extension DLLs
1867 # but not when building the interpreter DLL.
1868 CFLAGSFORSHARED='';;
1869 *)
1870 CFLAGSFORSHARED='$(CCSHARED)'
1871 esac
Neil Schemenauer61c51152001-01-26 16:18:16 +00001872fi
1873AC_MSG_RESULT($CFLAGSFORSHARED)
1874
Martin v. Löwisf90ae202002-06-11 06:22:31 +00001875# SHLIBS are libraries (except -lc and -lm) to link to the python shared
1876# library (with --enable-shared).
1877# For platforms on which shared libraries are not allowed to have unresolved
Martin v. Löwisd6359c52002-08-04 12:38:50 +00001878# symbols, this must be set to $(LIBS) (expanded by make). We do this even
1879# if it is not required, since it creates a dependency of the shared library
1880# to LIBS. This, in turn, means that applications linking the shared libpython
1881# don't need to link LIBS explicitly. The default should be only changed
1882# on systems where this approach causes problems.
Martin v. Löwisf90ae202002-06-11 06:22:31 +00001883AC_SUBST(SHLIBS)
1884AC_MSG_CHECKING(SHLIBS)
1885case "$ac_sys_system" in
Martin v. Löwisf90ae202002-06-11 06:22:31 +00001886 *)
Martin v. Löwisd6359c52002-08-04 12:38:50 +00001887 SHLIBS='$(LIBS)';;
Martin v. Löwisf90ae202002-06-11 06:22:31 +00001888esac
1889AC_MSG_RESULT($SHLIBS)
1890
1891
Guido van Rossum627b2d71993-12-24 10:39:16 +00001892# checks for libraries
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001893AC_CHECK_LIB(dl, dlopen) # Dynamic linking for SunOS/Solaris and SYSV
1894AC_CHECK_LIB(dld, shl_load) # Dynamic linking for HP-UX
Martin v. Löwis519adae2003-09-20 10:47:47 +00001895
Georg Brandleee31162008-12-07 15:15:22 +00001896# only check for sem_init if thread support is requested
Martin v. Löwis519adae2003-09-20 10:47:47 +00001897if test "$with_threads" = "yes" -o -z "$with_threads"; then
1898 AC_SEARCH_LIBS(sem_init, pthread rt posix4) # 'Real Time' functions on Solaris
1899 # posix4 on Solaris 2.6
1900 # pthread (first!) on Linux
1901fi
1902
Martin v. Löwis19d17342003-06-14 21:03:05 +00001903# check if we need libintl for locale functions
1904AC_CHECK_LIB(intl, textdomain,
Brett Cannonc6d936e2009-06-07 20:09:53 +00001905 [AC_DEFINE(WITH_LIBINTL, 1,
1906 [Define to 1 if libintl is needed for locale functions.])
1907 LIBS="-lintl $LIBS"])
Guido van Rossum0eefa3f1999-11-16 15:57:37 +00001908
1909# checks for system dependent C++ extensions support
1910case "$ac_sys_system" in
1911 AIX*) AC_MSG_CHECKING(for genuine AIX C++ extensions support)
1912 AC_TRY_LINK([#include "/usr/lpp/xlC/include/load.h"],
1913 [loadAndInit("", 0, "")],
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001914 [AC_DEFINE(AIX_GENUINE_CPLUSPLUS, 1,
1915 [Define for AIX if your compiler is a genuine IBM xlC/xlC_r
1916 and you want support for AIX C++ shared extension modules.])
Guido van Rossum0eefa3f1999-11-16 15:57:37 +00001917 AC_MSG_RESULT(yes)],
1918 [AC_MSG_RESULT(no)]);;
1919 *) ;;
1920esac
1921
Guido van Rossum70c7f481998-03-26 18:44:10 +00001922# Most SVR4 platforms (e.g. Solaris) need -lsocket and -lnsl.
Guido van Rossumf618d2c1995-01-17 16:36:13 +00001923AC_CHECK_LIB(nsl, t_open, [LIBS="-lnsl $LIBS"]) # SVR4
Guido van Rossumf618d2c1995-01-17 16:36:13 +00001924AC_CHECK_LIB(socket, socket, [LIBS="-lsocket $LIBS"], [], $LIBS) # SVR4 sockets
Skip Montanarob9949db2004-01-17 04:04:13 +00001925
Guido van Rossumc5a39031996-07-31 17:35:03 +00001926AC_MSG_CHECKING(for --with-libs)
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00001927AC_ARG_WITH(libs,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00001928 AC_HELP_STRING(--with-libs='lib1 ...', link against additional libs),
1929[
Guido van Rossumc5a39031996-07-31 17:35:03 +00001930AC_MSG_RESULT($withval)
1931LIBS="$withval $LIBS"
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00001932],
1933[AC_MSG_RESULT(no)])
Guido van Rossum627b2d71993-12-24 10:39:16 +00001934
Thomas Wouters49fd7fa2006-04-21 10:40:58 +00001935# Check for use of the system libffi library
1936AC_MSG_CHECKING(for --with-system-ffi)
1937AC_ARG_WITH(system_ffi,
1938 AC_HELP_STRING(--with-system-ffi, build _ctypes module using an installed ffi library))
1939
Thomas Wouters49fd7fa2006-04-21 10:40:58 +00001940AC_MSG_RESULT($with_system_ffi)
1941
Matthias Klose55708cc2009-04-30 08:06:49 +00001942# Check for --with-dbmliborder
1943AC_MSG_CHECKING(for --with-dbmliborder)
1944AC_ARG_WITH(dbmliborder,
1945 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'.]),
1946[
1947if test x$with_dbmliborder = xyes
1948then
1949AC_MSG_ERROR([proper usage is --with-dbmliborder=db1:db2:...])
1950else
1951 for db in `echo $with_dbmliborder | sed 's/:/ /g'`; do
1952 if test x$db != xndbm && test x$db != xgdbm && test x$db != xbdb
1953 then
1954 AC_MSG_ERROR([proper usage is --with-dbmliborder=db1:db2:...])
1955 fi
1956 done
1957fi])
1958AC_MSG_RESULT($with_dbmliborder)
1959
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00001960# Determine if signalmodule should be used.
1961AC_SUBST(USE_SIGNAL_MODULE)
1962AC_SUBST(SIGNAL_OBJS)
1963AC_MSG_CHECKING(for --with-signal-module)
1964AC_ARG_WITH(signal-module,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00001965 AC_HELP_STRING(--with-signal-module, disable/enable signal module))
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00001966
1967if test -z "$with_signal_module"
1968then with_signal_module="yes"
1969fi
1970AC_MSG_RESULT($with_signal_module)
1971
1972if test "${with_signal_module}" = "yes"; then
1973 USE_SIGNAL_MODULE=""
1974 SIGNAL_OBJS=""
1975else
1976 USE_SIGNAL_MODULE="#"
1977 SIGNAL_OBJS="Parser/intrcheck.o Python/sigcheck.o"
1978fi
1979
Guido van Rossum3d15bd82001-01-10 18:53:48 +00001980# This is used to generate Setup.config
Guido van Rossum009f7871997-12-04 00:51:42 +00001981AC_SUBST(USE_THREAD_MODULE)
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00001982USE_THREAD_MODULE=""
Guido van Rossum009f7871997-12-04 00:51:42 +00001983
Guido van Rossum54d93d41997-01-22 20:51:58 +00001984AC_MSG_CHECKING(for --with-dec-threads)
1985AC_SUBST(LDLAST)
1986AC_ARG_WITH(dec-threads,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00001987 AC_HELP_STRING(--with-dec-threads, use DEC Alpha/OSF1 thread-safe libraries),
1988[
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00001989AC_MSG_RESULT($withval)
Guido van Rossum54d93d41997-01-22 20:51:58 +00001990LDLAST=-threads
Guido van Rossumf78abae1997-01-21 22:02:36 +00001991if test "${with_thread+set}" != set; then
Guido van Rossum54d93d41997-01-22 20:51:58 +00001992 with_thread="$withval";
1993fi],
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00001994[AC_MSG_RESULT(no)])
Guido van Rossum54d93d41997-01-22 20:51:58 +00001995
Martin v. Löwis11437992002-04-12 09:54:03 +00001996# Templates for things AC_DEFINEd more than once.
1997# For a single AC_DEFINE, no template is needed.
1998AH_TEMPLATE(C_THREADS,[Define if you have the Mach cthreads package])
1999AH_TEMPLATE(_REENTRANT,
2000 [Define to force use of thread-safe errno, h_errno, and other functions])
2001AH_TEMPLATE(WITH_THREAD,
2002 [Define if you want to compile in rudimentary thread support])
2003
Guido van Rossum54d93d41997-01-22 20:51:58 +00002004AC_MSG_CHECKING(for --with-threads)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002005dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00002006AC_ARG_WITH(threads,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002007 AC_HELP_STRING(--with(out)-threads@<:@=DIRECTORY@:>@, disable/enable thread support))
Guido van Rossum54d93d41997-01-22 20:51:58 +00002008
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00002009# --with-thread is deprecated, but check for it anyway
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002010dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
Barry Warsawa0f3c5c2000-06-30 16:39:35 +00002011AC_ARG_WITH(thread,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002012 AC_HELP_STRING(--with(out)-thread@<:@=DIRECTORY@:>@, deprecated; use --with(out)-threads),
2013 [with_threads=$with_thread])
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00002014
2015if test -z "$with_threads"
2016then with_threads="yes"
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002017fi
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00002018AC_MSG_RESULT($with_threads)
Guido van Rossum6400c261997-05-22 20:34:27 +00002019
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002020AC_SUBST(THREADOBJ)
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00002021if test "$with_threads" = "no"
2022then
2023 USE_THREAD_MODULE="#"
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002024elif test "$ac_cv_pthread_is_default" = yes
2025then
2026 AC_DEFINE(WITH_THREAD)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002027 # Defining _REENTRANT on system with POSIX threads should not hurt.
2028 AC_DEFINE(_REENTRANT)
2029 posix_threads=yes
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002030 THREADOBJ="Python/thread.o"
Martin v. Löwis130fb172001-07-19 11:00:41 +00002031elif test "$ac_cv_kpthread" = "yes"
2032then
2033 CC="$CC -Kpthread"
Martin v. Löwis519adae2003-09-20 10:47:47 +00002034 if test "$ac_cv_cxx_thread" = "yes"; then
2035 CXX="$CXX -Kpthread"
2036 fi
Martin v. Löwis130fb172001-07-19 11:00:41 +00002037 AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002038 posix_threads=yes
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002039 THREADOBJ="Python/thread.o"
Martin v. Löwis5f433f02003-05-05 05:05:30 +00002040elif test "$ac_cv_kthread" = "yes"
2041then
2042 CC="$CC -Kthread"
Martin v. Löwis519adae2003-09-20 10:47:47 +00002043 if test "$ac_cv_cxx_thread" = "yes"; then
2044 CXX="$CXX -Kthread"
2045 fi
Martin v. Löwis5f433f02003-05-05 05:05:30 +00002046 AC_DEFINE(WITH_THREAD)
2047 posix_threads=yes
2048 THREADOBJ="Python/thread.o"
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002049elif test "$ac_cv_pthread" = "yes"
2050then
2051 CC="$CC -pthread"
Martin v. Löwis519adae2003-09-20 10:47:47 +00002052 if test "$ac_cv_cxx_thread" = "yes"; then
2053 CXX="$CXX -pthread"
2054 fi
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002055 AC_DEFINE(WITH_THREAD)
2056 posix_threads=yes
2057 THREADOBJ="Python/thread.o"
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00002058else
Martin v. Löwis130fb172001-07-19 11:00:41 +00002059 if test ! -z "$with_threads" -a -d "$with_threads"
2060 then LDFLAGS="$LDFLAGS -L$with_threads"
2061 fi
2062 if test ! -z "$withval" -a -d "$withval"
2063 then LDFLAGS="$LDFLAGS -L$withval"
2064 fi
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002065
2066 # According to the POSIX spec, a pthreads implementation must
Matthias Klosea2542be2004-08-16 11:35:51 +00002067 # define _POSIX_THREADS in unistd.h. Some apparently don't
2068 # (e.g. gnu pth with pthread emulation)
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002069 AC_MSG_CHECKING(for _POSIX_THREADS in unistd.h)
2070 AC_EGREP_CPP(yes,
Neal Norwitz6eb37f02003-02-23 23:28:15 +00002071 [
2072#include <unistd.h>
2073#ifdef _POSIX_THREADS
2074yes
2075#endif
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002076 ], unistd_defines_pthreads=yes, unistd_defines_pthreads=no)
2077 AC_MSG_RESULT($unistd_defines_pthreads)
2078
Martin v. Löwis130fb172001-07-19 11:00:41 +00002079 AC_DEFINE(_REENTRANT)
Martin v. Löwisa6e97582002-01-01 18:41:33 +00002080 AC_CHECK_HEADER(cthreads.h, [AC_DEFINE(WITH_THREAD)
2081 AC_DEFINE(C_THREADS)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002082 AC_DEFINE(HURD_C_THREADS, 1,
2083 [Define if you are using Mach cthreads directly under /include])
Martin v. Löwisa6e97582002-01-01 18:41:33 +00002084 LIBS="$LIBS -lthreads"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002085 THREADOBJ="Python/thread.o"],[
Martin v. Löwis130fb172001-07-19 11:00:41 +00002086 AC_CHECK_HEADER(mach/cthreads.h, [AC_DEFINE(WITH_THREAD)
2087 AC_DEFINE(C_THREADS)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002088 AC_DEFINE(MACH_C_THREADS, 1,
2089 [Define if you are using Mach cthreads under mach /])
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002090 THREADOBJ="Python/thread.o"],[
Martin v. Löwis130fb172001-07-19 11:00:41 +00002091 AC_MSG_CHECKING(for --with-pth)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002092 AC_ARG_WITH([pth],
2093 AC_HELP_STRING(--with-pth, use GNU pth threading libraries),
2094 [AC_MSG_RESULT($withval)
2095 AC_DEFINE([WITH_THREAD])
2096 AC_DEFINE([HAVE_PTH], 1,
2097 [Define if you have GNU PTH threads.])
2098 LIBS="-lpth $LIBS"
2099 THREADOBJ="Python/thread.o"],
2100 [AC_MSG_RESULT(no)
Martin v. Löwis8158b5a2001-10-08 13:17:28 +00002101
2102 # Just looking for pthread_create in libpthread is not enough:
2103 # on HP/UX, pthread.h renames pthread_create to a different symbol name.
2104 # So we really have to include pthread.h, and then link.
2105 _libs=$LIBS
2106 LIBS="$LIBS -lpthread"
2107 AC_MSG_CHECKING([for pthread_create in -lpthread])
2108 AC_TRY_LINK([#include <pthread.h>
2109
2110void * start_routine (void *arg) { exit (0); }], [
2111pthread_create (NULL, NULL, start_routine, NULL)], [
2112 AC_MSG_RESULT(yes)
2113 AC_DEFINE(WITH_THREAD)
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002114 posix_threads=yes
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002115 THREADOBJ="Python/thread.o"],[
Martin v. Löwis8158b5a2001-10-08 13:17:28 +00002116 LIBS=$_libs
Martin v. Löwis130fb172001-07-19 11:00:41 +00002117 AC_CHECK_FUNC(pthread_detach, [AC_DEFINE(WITH_THREAD)
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002118 posix_threads=yes
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002119 THREADOBJ="Python/thread.o"],[
Martin v. Löwisf90ae202002-06-11 06:22:31 +00002120 AC_CHECK_HEADER(atheos/threads.h, [AC_DEFINE(WITH_THREAD)
2121 AC_DEFINE(ATHEOS_THREADS, 1,
2122 [Define this if you have AtheOS threads.])
2123 THREADOBJ="Python/thread.o"],[
Martin v. Löwis130fb172001-07-19 11:00:41 +00002124 AC_CHECK_LIB(pthreads, pthread_create, [AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002125 posix_threads=yes
Martin v. Löwis130fb172001-07-19 11:00:41 +00002126 LIBS="$LIBS -lpthreads"
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(c_r, 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 -lc_r"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002131 THREADOBJ="Python/thread.o"], [
Martin v. Löwis130fb172001-07-19 11:00:41 +00002132 AC_CHECK_LIB(pthread, __pthread_create_system, [AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002133 posix_threads=yes
Martin v. Löwis130fb172001-07-19 11:00:41 +00002134 LIBS="$LIBS -lpthread"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002135 THREADOBJ="Python/thread.o"], [
Martin v. Löwis130fb172001-07-19 11:00:41 +00002136 AC_CHECK_LIB(cma, pthread_create, [AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002137 posix_threads=yes
Martin v. Löwis130fb172001-07-19 11:00:41 +00002138 LIBS="$LIBS -lcma"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002139 THREADOBJ="Python/thread.o"],[
Martin v. Löwis130fb172001-07-19 11:00:41 +00002140 USE_THREAD_MODULE="#"])
Skip Montanaroeb33e5a2007-08-17 12:57:41 +00002141 ])])])])])])])])])
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00002142
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002143 AC_CHECK_LIB(mpc, usconfig, [AC_DEFINE(WITH_THREAD)
2144 LIBS="$LIBS -lmpc"
2145 THREADOBJ="Python/thread.o"
2146 USE_THREAD_MODULE=""])
2147
2148 if test "$posix_threads" != "yes"; then
2149 AC_CHECK_LIB(thread, thr_create, [AC_DEFINE(WITH_THREAD)
2150 LIBS="$LIBS -lthread"
2151 THREADOBJ="Python/thread.o"
2152 USE_THREAD_MODULE=""])
2153 fi
2154
2155 if test "$USE_THREAD_MODULE" != "#"
2156 then
2157 # If the above checks didn't disable threads, (at least) OSF1
2158 # needs this '-threads' argument during linking.
2159 case $ac_sys_system in
2160 OSF1) LDLAST=-threads;;
2161 esac
2162 fi
2163fi
2164
2165if test "$posix_threads" = "yes"; then
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002166 if test "$unistd_defines_pthreads" = "no"; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002167 AC_DEFINE(_POSIX_THREADS, 1,
2168 [Define if you have POSIX threads,
2169 and your system does not define that.])
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002170 fi
2171
Martin v. Löwisdfc33fd2003-01-21 10:14:41 +00002172 # Bug 662787: Using semaphores causes unexplicable hangs on Solaris 8.
2173 case $ac_sys_system/$ac_sys_release in
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002174 SunOS/5.6) AC_DEFINE(HAVE_PTHREAD_DESTRUCTOR, 1,
2175 Defined for Solaris 2.6 bug in pthread header.)
2176 ;;
Martin v. Löwisdfc33fd2003-01-21 10:14:41 +00002177 SunOS/5.8) AC_DEFINE(HAVE_BROKEN_POSIX_SEMAPHORES, 1,
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002178 Define if the Posix semaphores do not work on your system)
2179 ;;
Christian Heimes7b3ce6a2008-01-31 14:31:45 +00002180 AIX/5) AC_DEFINE(HAVE_BROKEN_POSIX_SEMAPHORES, 1,
2181 Define if the Posix semaphores do not work on your system)
2182 ;;
Martin v. Löwisdfc33fd2003-01-21 10:14:41 +00002183 esac
2184
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002185 AC_MSG_CHECKING(if PTHREAD_SCOPE_SYSTEM is supported)
2186 AC_CACHE_VAL(ac_cv_pthread_system_supported,
2187 [AC_TRY_RUN([#include <pthread.h>
2188 void *foo(void *parm) {
2189 return NULL;
2190 }
2191 main() {
2192 pthread_attr_t attr;
Martin v. Löwisa82d3472002-02-24 16:05:05 +00002193 pthread_t id;
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002194 if (pthread_attr_init(&attr)) exit(-1);
2195 if (pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM)) exit(-1);
Martin v. Löwisa82d3472002-02-24 16:05:05 +00002196 if (pthread_create(&id, &attr, foo, NULL)) exit(-1);
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002197 exit(0);
Guido van Rossum3065c942001-09-17 04:03:14 +00002198 }],
2199 ac_cv_pthread_system_supported=yes,
2200 ac_cv_pthread_system_supported=no,
2201 ac_cv_pthread_system_supported=no)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002202 ])
2203 AC_MSG_RESULT($ac_cv_pthread_system_supported)
2204 if test "$ac_cv_pthread_system_supported" = "yes"; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002205 AC_DEFINE(PTHREAD_SYSTEM_SCHED_SUPPORTED, 1, [Defined if PTHREAD_SCOPE_SYSTEM supported.])
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002206 fi
Jason Tishlerfac083d2003-07-22 15:20:49 +00002207 AC_CHECK_FUNCS(pthread_sigmask,
2208 [case $ac_sys_system in
2209 CYGWIN*)
2210 AC_DEFINE(HAVE_BROKEN_PTHREAD_SIGMASK, 1,
2211 [Define if pthread_sigmask() does not work on your system.])
2212 ;;
2213 esac])
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00002214fi
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002215
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002216
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002217# Check for enable-ipv6
Martin v. Löwis11437992002-04-12 09:54:03 +00002218AH_TEMPLATE(ENABLE_IPV6, [Define if --enable-ipv6 is specified])
Martin v. Löwisa5f8bb52001-09-05 08:22:34 +00002219AC_MSG_CHECKING([if --enable-ipv6 is specified])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002220AC_ARG_ENABLE(ipv6,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002221[ --enable-ipv6 Enable ipv6 (with ipv4) support
2222 --disable-ipv6 Disable ipv6 support],
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002223[ case "$enableval" in
2224 no)
2225 AC_MSG_RESULT(no)
2226 ipv6=no
2227 ;;
2228 *) AC_MSG_RESULT(yes)
2229 AC_DEFINE(ENABLE_IPV6)
2230 ipv6=yes
2231 ;;
2232 esac ],
2233
Martin v. Löwisa5f8bb52001-09-05 08:22:34 +00002234[
2235dnl the check does not work on cross compilation case...
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002236 AC_TRY_RUN([ /* AF_INET6 available check */
2237#include <sys/types.h>
2238#include <sys/socket.h>
2239main()
2240{
2241 if (socket(AF_INET6, SOCK_STREAM, 0) < 0)
2242 exit(1);
2243 else
2244 exit(0);
2245}
2246],
2247 AC_MSG_RESULT(yes)
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002248 ipv6=yes,
2249 AC_MSG_RESULT(no)
2250 ipv6=no,
2251 AC_MSG_RESULT(no)
2252 ipv6=no
Martin v. Löwisa5f8bb52001-09-05 08:22:34 +00002253)
2254
2255if test "$ipv6" = "yes"; then
2256 AC_MSG_CHECKING(if RFC2553 API is available)
2257 AC_TRY_COMPILE([#include <sys/types.h>
2258#include <netinet/in.h>],
2259 [struct sockaddr_in6 x;
2260x.sin6_scope_id;],
2261 AC_MSG_RESULT(yes)
2262 ipv6=yes,
2263 AC_MSG_RESULT(no, IPv6 disabled)
2264 ipv6=no)
2265fi
2266
2267if test "$ipv6" = "yes"; then
2268 AC_DEFINE(ENABLE_IPV6)
2269fi
2270])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002271
2272ipv6type=unknown
2273ipv6lib=none
2274ipv6trylibc=no
2275
2276if test "$ipv6" = "yes"; then
2277 AC_MSG_CHECKING([ipv6 stack type])
Guido van Rossumb8552162001-09-05 14:58:11 +00002278 for i in inria kame linux-glibc linux-inet6 solaris toshiba v6d zeta;
2279 do
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002280 case $i in
2281 inria)
2282 dnl http://www.kame.net/
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002283 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002284#include <netinet/in.h>
2285#ifdef IPV6_INRIA_VERSION
2286yes
2287#endif],
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002288 [ipv6type=$i])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002289 ;;
2290 kame)
2291 dnl http://www.kame.net/
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002292 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002293#include <netinet/in.h>
2294#ifdef __KAME__
2295yes
2296#endif],
2297 [ipv6type=$i;
2298 ipv6lib=inet6
2299 ipv6libdir=/usr/local/v6/lib
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002300 ipv6trylibc=yes])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002301 ;;
2302 linux-glibc)
2303 dnl http://www.v6.linux.or.jp/
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002304 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002305#include <features.h>
2306#if defined(__GLIBC__) && ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1) || (__GLIBC__ > 2))
2307yes
2308#endif],
2309 [ipv6type=$i;
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002310 ipv6trylibc=yes])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002311 ;;
2312 linux-inet6)
2313 dnl http://www.v6.linux.or.jp/
2314 if test -d /usr/inet6; then
2315 ipv6type=$i
2316 ipv6lib=inet6
2317 ipv6libdir=/usr/inet6/lib
Skip Montanarodecc6a42003-01-01 20:07:49 +00002318 BASECFLAGS="-I/usr/inet6/include $BASECFLAGS"
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002319 fi
2320 ;;
2321 solaris)
2322 if test -f /etc/netconfig; then
2323 if /usr/xpg4/bin/grep -q tcp6 /etc/netconfig; then
2324 ipv6type=$i
2325 ipv6trylibc=yes
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002326 fi
2327 fi
2328 ;;
2329 toshiba)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002330 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002331#include <sys/param.h>
2332#ifdef _TOSHIBA_INET6
2333yes
2334#endif],
2335 [ipv6type=$i;
2336 ipv6lib=inet6;
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002337 ipv6libdir=/usr/local/v6/lib])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002338 ;;
2339 v6d)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002340 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002341#include </usr/local/v6/include/sys/v6config.h>
2342#ifdef __V6D__
2343yes
2344#endif],
2345 [ipv6type=$i;
2346 ipv6lib=v6;
2347 ipv6libdir=/usr/local/v6/lib;
Skip Montanarodecc6a42003-01-01 20:07:49 +00002348 BASECFLAGS="-I/usr/local/v6/include $BASECFLAGS"])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002349 ;;
2350 zeta)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002351 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002352#include <sys/param.h>
2353#ifdef _ZETA_MINAMI_INET6
2354yes
2355#endif],
2356 [ipv6type=$i;
2357 ipv6lib=inet6;
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002358 ipv6libdir=/usr/local/v6/lib])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002359 ;;
2360 esac
2361 if test "$ipv6type" != "unknown"; then
2362 break
2363 fi
2364 done
2365 AC_MSG_RESULT($ipv6type)
2366fi
2367
2368if test "$ipv6" = "yes" -a "$ipv6lib" != "none"; then
2369 if test -d $ipv6libdir -a -f $ipv6libdir/lib$ipv6lib.a; then
2370 LIBS="-L$ipv6libdir -l$ipv6lib $LIBS"
2371 echo "using lib$ipv6lib"
2372 else
2373 if test $ipv6trylibc = "yes"; then
2374 echo "using libc"
2375 else
2376 echo 'Fatal: no $ipv6lib library found. cannot continue.'
2377 echo "You need to fetch lib$ipv6lib.a from appropriate"
2378 echo 'ipv6 kit and compile beforehand.'
2379 exit 1
2380 fi
2381 fi
2382fi
2383
Georg Brandl93de2162008-07-16 02:21:06 +00002384AC_MSG_CHECKING(for OSX 10.5 SDK or later)
2385AC_TRY_COMPILE([#include <Carbon/Carbon.h>], FSIORefNum fRef = 0,
2386 AC_DEFINE(HAVE_OSX105_SDK, 1, Define if compiling using MacOS X 10.5 SDK or later.)
2387 AC_MSG_RESULT(yes),
2388 AC_MSG_RESULT(no)
2389)
2390
Martin v. Löwisa3fb4f72002-06-09 13:33:54 +00002391# Check for --with-doc-strings
2392AC_MSG_CHECKING(for --with-doc-strings)
2393AC_ARG_WITH(doc-strings,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002394 AC_HELP_STRING(--with(out)-doc-strings, disable/enable documentation strings))
Martin v. Löwisa3fb4f72002-06-09 13:33:54 +00002395
2396if test -z "$with_doc_strings"
2397then with_doc_strings="yes"
2398fi
2399if test "$with_doc_strings" != "no"
2400then
2401 AC_DEFINE(WITH_DOC_STRINGS, 1,
2402 [Define if you want documentation strings in extension modules])
2403fi
2404AC_MSG_RESULT($with_doc_strings)
2405
Neil Schemenauera35c6882001-02-27 04:45:05 +00002406# Check for Python-specific malloc support
Martin v. Löwisf30d60e2004-06-08 08:17:44 +00002407AC_MSG_CHECKING(for --with-tsc)
2408AC_ARG_WITH(tsc,
2409[ --with(out)-tsc enable/disable timestamp counter profile], [
2410if test "$withval" != no
2411then
2412 AC_DEFINE(WITH_TSC, 1,
2413 [Define to profile with the Pentium timestamp counter])
2414 AC_MSG_RESULT(yes)
2415else AC_MSG_RESULT(no)
2416fi],
2417[AC_MSG_RESULT(no)])
2418
2419# Check for Python-specific malloc support
Neil Schemenauera35c6882001-02-27 04:45:05 +00002420AC_MSG_CHECKING(for --with-pymalloc)
2421AC_ARG_WITH(pymalloc,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002422 AC_HELP_STRING(--with(out)-pymalloc, disable/enable specialized mallocs))
Neil Schemenauer16c22972002-03-22 15:34:49 +00002423
2424if test -z "$with_pymalloc"
2425then with_pymalloc="yes"
2426fi
2427if test "$with_pymalloc" != "no"
2428then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002429 AC_DEFINE(WITH_PYMALLOC, 1,
2430 [Define if you want to compile in Python-specific mallocs])
Neil Schemenauer16c22972002-03-22 15:34:49 +00002431fi
2432AC_MSG_RESULT($with_pymalloc)
Neil Schemenauera35c6882001-02-27 04:45:05 +00002433
Barry Warsawef82cd72000-06-30 16:21:01 +00002434# Check for --with-wctype-functions
2435AC_MSG_CHECKING(for --with-wctype-functions)
2436AC_ARG_WITH(wctype-functions,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002437 AC_HELP_STRING(--with-wctype-functions, use wctype.h functions),
2438[
Barry Warsawef82cd72000-06-30 16:21:01 +00002439if test "$withval" != no
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002440then
2441 AC_DEFINE(WANT_WCTYPE_FUNCTIONS, 1,
2442 [Define if you want wctype.h functions to be used instead of the
2443 one supplied by Python itself. (see Include/unicodectype.h).])
2444 AC_MSG_RESULT(yes)
Barry Warsawef82cd72000-06-30 16:21:01 +00002445else AC_MSG_RESULT(no)
2446fi],
2447[AC_MSG_RESULT(no)])
2448
Guido van Rossum68242b51996-05-28 22:53:03 +00002449# -I${DLINCLDIR} is added to the compile rule for importdl.o
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002450AC_SUBST(DLINCLDIR)
Guido van Rossum98935bf2001-09-05 19:13:16 +00002451DLINCLDIR=.
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002452
Guido van Rossume97ee181999-12-20 21:27:22 +00002453# the dlopen() function means we might want to use dynload_shlib.o. some
2454# platforms, such as AIX, have dlopen(), but don't want to use it.
Thomas Wouters3a584202000-08-05 23:28:51 +00002455AC_CHECK_FUNCS(dlopen)
Guido van Rossume97ee181999-12-20 21:27:22 +00002456
2457# DYNLOADFILE specifies which dynload_*.o file we will use for dynamic
2458# loading of modules.
2459AC_SUBST(DYNLOADFILE)
2460AC_MSG_CHECKING(DYNLOADFILE)
2461if test -z "$DYNLOADFILE"
2462then
2463 case $ac_sys_system/$ac_sys_release in
Martin v. Löwisc19c5a62003-11-18 20:00:44 +00002464 AIX*) # Use dynload_shlib.c and dlopen() if we have it; otherwise dynload_aix.c
2465 if test "$ac_cv_func_dlopen" = yes
2466 then DYNLOADFILE="dynload_shlib.o"
2467 else DYNLOADFILE="dynload_aix.o"
2468 fi
2469 ;;
Guido van Rossume97ee181999-12-20 21:27:22 +00002470 hp*|HP*) DYNLOADFILE="dynload_hpux.o";;
Thomas Wouters49fd7fa2006-04-21 10:40:58 +00002471 # Use dynload_next.c only on 10.2 and below, which don't have native dlopen()
2472 Darwin/@<:@0156@:>@\..*) DYNLOADFILE="dynload_next.o";;
Martin v. Löwisf90ae202002-06-11 06:22:31 +00002473 atheos*) DYNLOADFILE="dynload_atheos.o";;
Guido van Rossume97ee181999-12-20 21:27:22 +00002474 *)
2475 # use dynload_shlib.c and dlopen() if we have it; otherwise stub
2476 # out any dynamic loading
2477 if test "$ac_cv_func_dlopen" = yes
2478 then DYNLOADFILE="dynload_shlib.o"
2479 else DYNLOADFILE="dynload_stub.o"
2480 fi
2481 ;;
2482 esac
2483fi
2484AC_MSG_RESULT($DYNLOADFILE)
2485if test "$DYNLOADFILE" != "dynload_stub.o"
2486then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002487 AC_DEFINE(HAVE_DYNAMIC_LOADING, 1,
2488 [Defined when any dynamic module loading is enabled.])
Guido van Rossume97ee181999-12-20 21:27:22 +00002489fi
2490
Jack Jansenc49e5b72001-06-19 15:00:23 +00002491# MACHDEP_OBJS can be set to platform-specific object files needed by Python
2492
2493AC_SUBST(MACHDEP_OBJS)
2494AC_MSG_CHECKING(MACHDEP_OBJS)
2495if test -z "$MACHDEP_OBJS"
2496then
Jack Jansenb6e9cad2001-08-15 01:26:28 +00002497 MACHDEP_OBJS=$extra_machdep_objs
2498else
2499 MACHDEP_OBJS="$MACHDEP_OBJS $extra_machdep_objs"
Jack Jansenc49e5b72001-06-19 15:00:23 +00002500fi
Jack Jansenb6e9cad2001-08-15 01:26:28 +00002501AC_MSG_RESULT(MACHDEP_OBJS)
Jack Jansenc49e5b72001-06-19 15:00:23 +00002502
Guido van Rossum627b2d71993-12-24 10:39:16 +00002503# checks for library functions
Martin v. Löwis823725e2008-03-24 13:39:54 +00002504AC_CHECK_FUNCS(alarm setitimer getitimer bind_textdomain_codeset chown \
2505 clock confstr ctermid execv fchmod fchown fork fpathconf ftime ftruncate \
Martin v. Löwis438b5342002-12-27 10:16:42 +00002506 gai_strerror getgroups getlogin getloadavg getpeername getpgid getpid \
Martin v. Löwisc3001752005-01-23 09:27:24 +00002507 getpriority getpwent getspnam getspent getsid getwd \
Martin v. Löwis011e8422009-05-05 04:43:17 +00002508 kill killpg lchmod lchown lstat mbrtowc mkfifo mknod mktime \
Martin v. Löwisa5f09072002-10-11 05:37:59 +00002509 mremap nice pathconf pause plock poll pthread_init \
Guido van Rossum162e38c2003-02-19 15:25:10 +00002510 putenv readlink realpath \
Benjamin Peterson965ce872009-04-05 21:24:58 +00002511 select sem_open sem_timedwait sem_getvalue sem_unlink setegid seteuid \
2512 setgid \
Martin v. Löwis4daacb12003-03-28 18:37:01 +00002513 setlocale setregid setreuid setsid setpgid setpgrp setuid setvbuf snprintf \
Gregory P. Smith6c357262007-09-03 16:44:06 +00002514 sigaction siginterrupt sigrelse strftime strlcpy \
Michael W. Hudson34f20ea2002-05-27 15:08:24 +00002515 sysconf tcgetpgrp tcsetpgrp tempnam timegm times tmpfile tmpnam tmpnam_r \
Martin v. Löwis113a0852009-05-29 17:25:39 +00002516 truncate uname unsetenv utimes waitpid wait3 wait4 \
2517 wcscoll wcsftime wcsxfrm _getpty)
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00002518
Martin v. Löwisc8ad7cc2002-11-11 13:23:45 +00002519# For some functions, having a definition is not sufficient, since
2520# we want to take their address.
2521AC_MSG_CHECKING(for chroot)
2522AC_TRY_COMPILE([#include <unistd.h>], void *x=chroot,
2523 AC_DEFINE(HAVE_CHROOT, 1, Define if you have the 'chroot' function.)
2524 AC_MSG_RESULT(yes),
2525 AC_MSG_RESULT(no)
2526)
2527AC_MSG_CHECKING(for link)
2528AC_TRY_COMPILE([#include <unistd.h>], void *x=link,
2529 AC_DEFINE(HAVE_LINK, 1, Define if you have the 'link' function.)
2530 AC_MSG_RESULT(yes),
2531 AC_MSG_RESULT(no)
2532)
2533AC_MSG_CHECKING(for symlink)
2534AC_TRY_COMPILE([#include <unistd.h>], void *x=symlink,
2535 AC_DEFINE(HAVE_SYMLINK, 1, Define if you have the 'symlink' function.)
2536 AC_MSG_RESULT(yes),
2537 AC_MSG_RESULT(no)
2538)
Martin v. Löwisa64988c2003-09-20 15:30:20 +00002539AC_MSG_CHECKING(for fchdir)
2540AC_TRY_COMPILE([#include <unistd.h>], void *x=fchdir,
2541 AC_DEFINE(HAVE_FCHDIR, 1, Define if you have the 'fchdir' function.)
2542 AC_MSG_RESULT(yes),
2543 AC_MSG_RESULT(no)
2544)
2545AC_MSG_CHECKING(for fsync)
2546AC_TRY_COMPILE([#include <unistd.h>], void *x=fsync,
Skip Montanarod4fa8072003-09-25 14:49:15 +00002547 AC_DEFINE(HAVE_FSYNC, 1, Define if you have the 'fsync' function.)
Martin v. Löwisa64988c2003-09-20 15:30:20 +00002548 AC_MSG_RESULT(yes),
2549 AC_MSG_RESULT(no)
2550)
2551AC_MSG_CHECKING(for fdatasync)
2552AC_TRY_COMPILE([#include <unistd.h>], void *x=fdatasync,
2553 AC_DEFINE(HAVE_FDATASYNC, 1, Define if you have the 'fdatasync' function.)
2554 AC_MSG_RESULT(yes),
2555 AC_MSG_RESULT(no)
2556)
Christian Heimes4fbc72b2008-03-22 00:47:35 +00002557AC_MSG_CHECKING(for epoll)
2558AC_TRY_COMPILE([#include <sys/epoll.h>], void *x=epoll_create,
2559 AC_DEFINE(HAVE_EPOLL, 1, Define if you have the 'epoll' functions.)
2560 AC_MSG_RESULT(yes),
2561 AC_MSG_RESULT(no)
2562)
2563AC_MSG_CHECKING(for kqueue)
2564AC_TRY_COMPILE([
2565#include <sys/types.h>
2566#include <sys/event.h>
2567 ], int x=kqueue(),
2568 AC_DEFINE(HAVE_KQUEUE, 1, Define if you have the 'kqueue' functions.)
2569 AC_MSG_RESULT(yes),
2570 AC_MSG_RESULT(no)
2571)
Martin v. Löwisd5843682002-11-21 20:41:28 +00002572# On some systems (eg. FreeBSD 5), we would find a definition of the
2573# functions ctermid_r, setgroups in the library, but no prototype
2574# (e.g. because we use _XOPEN_SOURCE). See whether we can take their
2575# address to avoid compiler warnings and potential miscompilations
2576# because of the missing prototypes.
2577
2578AC_MSG_CHECKING(for ctermid_r)
2579AC_TRY_COMPILE([
2580#include "confdefs.h"
2581#include <stdio.h>
2582], void* p = ctermid_r,
2583 AC_DEFINE(HAVE_CTERMID_R, 1, Define if you have the 'ctermid_r' function.)
2584 AC_MSG_RESULT(yes),
2585 AC_MSG_RESULT(no)
2586)
2587
Martin v. Löwisf26d63b2003-03-30 17:23:49 +00002588AC_MSG_CHECKING(for flock)
2589AC_TRY_COMPILE([
2590#include "confdefs.h"
2591#include <sys/file.h>
2592], void* p = flock,
2593 AC_DEFINE(HAVE_FLOCK, 1, Define if you have the 'flock' function.)
2594 AC_MSG_RESULT(yes),
2595 AC_MSG_RESULT(no)
2596)
2597
2598AC_MSG_CHECKING(for getpagesize)
2599AC_TRY_COMPILE([
2600#include "confdefs.h"
2601#include <unistd.h>
2602], void* p = getpagesize,
2603 AC_DEFINE(HAVE_GETPAGESIZE, 1, Define if you have the 'getpagesize' function.)
2604 AC_MSG_RESULT(yes),
2605 AC_MSG_RESULT(no)
2606)
2607
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002608dnl check for true
2609AC_CHECK_PROGS(TRUE, true, /bin/true)
2610
Martin v. Löwis95c419b2003-05-03 12:10:48 +00002611dnl On some systems (e.g. Solaris 9), hstrerror and inet_aton are in -lresolv
2612dnl On others, they are in the C library, so we to take no action
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002613AC_CHECK_LIB(c, inet_aton, [$ac_cv_prog_TRUE],
Martin v. Löwis95c419b2003-05-03 12:10:48 +00002614 AC_CHECK_LIB(resolv, inet_aton)
2615)
2616
Christian Heimesd0764e22007-12-04 15:00:33 +00002617# On Tru64, chflags seems to be present, but calling it will
2618# exit Python
Benjamin Peterson08fd6722010-01-30 19:51:43 +00002619AC_CACHE_CHECK([for chflags], [ac_cv_have_chflags], [dnl
2620AC_TRY_RUN([[
Christian Heimesd0764e22007-12-04 15:00:33 +00002621#include <sys/stat.h>
2622#include <unistd.h>
2623int main(int argc, char*argv[])
2624{
2625 if(chflags(argv[0], 0) != 0)
2626 return 1;
2627 return 0;
2628}
Benjamin Peterson08fd6722010-01-30 19:51:43 +00002629]], ac_cv_have_chflags=yes,
2630 ac_cv_have_chflags=no,
2631 ac_cv_have_chflags=cross)
2632])
2633if test "$ac_cv_have_chflags" = cross ; then
2634 AC_CHECK_FUNC([chflags], [ac_cv_have_chflags="yes"], [ac_cv_have_chflags="no"])
2635fi
2636if test "$ac_cv_have_chflags" = yes ; then
2637 AC_DEFINE(HAVE_CHFLAGS, 1, Define to 1 if you have the `chflags' function.)
2638fi
Christian Heimesd0764e22007-12-04 15:00:33 +00002639
Benjamin Peterson08fd6722010-01-30 19:51:43 +00002640AC_CACHE_CHECK([for lchflags], [ac_cv_have_lchflags], [dnl
2641AC_TRY_RUN([[
Christian Heimesd0764e22007-12-04 15:00:33 +00002642#include <sys/stat.h>
2643#include <unistd.h>
2644int main(int argc, char*argv[])
2645{
2646 if(lchflags(argv[0], 0) != 0)
2647 return 1;
2648 return 0;
2649}
Benjamin Peterson08fd6722010-01-30 19:51:43 +00002650]], ac_cv_have_lchflags=yes,
2651 ac_cv_have_lchflags=no,
2652 ac_cv_have_lchflags=cross)
2653])
2654if test "$ac_cv_have_lchflags" = cross ; then
2655 AC_CHECK_FUNC([lchflags], [ac_cv_have_lchflags="yes"], [ac_cv_have_lchflags="no"])
2656fi
2657if test "$ac_cv_have_lchflags" = yes ; then
2658 AC_DEFINE(HAVE_LCHFLAGS, 1, Define to 1 if you have the `lchflags' function.)
2659fi
Christian Heimesd0764e22007-12-04 15:00:33 +00002660
Thomas Wouters0e3f5912006-08-11 14:57:12 +00002661dnl Check if system zlib has *Copy() functions
2662dnl
2663dnl On MacOSX the linker will search for dylibs on the entire linker path
2664dnl before searching for static libraries. setup.py adds -Wl,-search_paths_first
2665dnl to revert to a more traditional unix behaviour and make it possible to
2666dnl override the system libz with a local static library of libz. Temporarily
2667dnl add that flag to our CFLAGS as well to ensure that we check the version
2668dnl of libz that will be used by setup.py.
2669dnl The -L/usr/local/lib is needed as wel to get the same compilation
2670dnl environment as setup.py (and leaving it out can cause configure to use the
2671dnl wrong version of the library)
2672case $ac_sys_system/$ac_sys_release in
2673Darwin/*)
2674 _CUR_CFLAGS="${CFLAGS}"
2675 _CUR_LDFLAGS="${LDFLAGS}"
2676 CFLAGS="${CFLAGS} -Wl,-search_paths_first"
2677 LDFLAGS="${LDFLAGS} -Wl,-search_paths_first -L/usr/local/lib"
2678 ;;
2679esac
2680
2681AC_CHECK_LIB(z, inflateCopy, AC_DEFINE(HAVE_ZLIB_COPY, 1, Define if the zlib library has inflateCopy))
2682
2683case $ac_sys_system/$ac_sys_release in
2684Darwin/*)
2685 CFLAGS="${_CUR_CFLAGS}"
2686 LDFLAGS="${_CUR_LDFLAGS}"
2687 ;;
2688esac
2689
Martin v. Löwise9416172003-05-03 10:12:45 +00002690AC_MSG_CHECKING(for hstrerror)
Martin v. Löwis95c419b2003-05-03 12:10:48 +00002691AC_TRY_LINK([
Martin v. Löwise9416172003-05-03 10:12:45 +00002692#include "confdefs.h"
2693#include <netdb.h>
Martin v. Löwis95c419b2003-05-03 12:10:48 +00002694], void* p = hstrerror; hstrerror(0),
Martin v. Löwise9416172003-05-03 10:12:45 +00002695 AC_DEFINE(HAVE_HSTRERROR, 1, Define if you have the 'hstrerror' function.)
2696 AC_MSG_RESULT(yes),
2697 AC_MSG_RESULT(no)
2698)
2699
2700AC_MSG_CHECKING(for inet_aton)
Martin v. Löwis95c419b2003-05-03 12:10:48 +00002701AC_TRY_LINK([
Martin v. Löwise9416172003-05-03 10:12:45 +00002702#include "confdefs.h"
Martin v. Löwis86d66262006-02-17 08:40:11 +00002703#include <sys/types.h>
Martin v. Löwise9416172003-05-03 10:12:45 +00002704#include <sys/socket.h>
2705#include <netinet/in.h>
2706#include <arpa/inet.h>
Martin v. Löwis95c419b2003-05-03 12:10:48 +00002707], void* p = inet_aton;inet_aton(0,0),
Martin v. Löwise9416172003-05-03 10:12:45 +00002708 AC_DEFINE(HAVE_INET_ATON, 1, Define if you have the 'inet_aton' function.)
2709 AC_MSG_RESULT(yes),
2710 AC_MSG_RESULT(no)
2711)
2712
2713AC_MSG_CHECKING(for inet_pton)
2714AC_TRY_COMPILE([
2715#include "confdefs.h"
Martin v. Löwisf2e488d2003-05-05 22:00:11 +00002716#include <sys/types.h>
Martin v. Löwise9416172003-05-03 10:12:45 +00002717#include <sys/socket.h>
2718#include <netinet/in.h>
2719#include <arpa/inet.h>
2720], void* p = inet_pton,
2721 AC_DEFINE(HAVE_INET_PTON, 1, Define if you have the 'inet_pton' function.)
2722 AC_MSG_RESULT(yes),
2723 AC_MSG_RESULT(no)
2724)
2725
Martin v. Löwisd6640d42003-07-06 09:29:52 +00002726# On some systems, setgroups is in unistd.h, on others, in grp.h
Martin v. Löwisd5843682002-11-21 20:41:28 +00002727AC_MSG_CHECKING(for setgroups)
2728AC_TRY_COMPILE([
2729#include "confdefs.h"
Martin v. Löwisf2e488d2003-05-05 22:00:11 +00002730#include <unistd.h>
Martin v. Löwisd6640d42003-07-06 09:29:52 +00002731#ifdef HAVE_GRP_H
2732#include <grp.h>
2733#endif
Martin v. Löwisd5843682002-11-21 20:41:28 +00002734],
2735void* p = setgroups,
2736 AC_DEFINE(HAVE_SETGROUPS, 1, Define if you have the 'setgroups' function.)
2737 AC_MSG_RESULT(yes),
2738 AC_MSG_RESULT(no)
2739)
2740
Fred Drake8cef4cf2000-06-28 16:40:38 +00002741# check for openpty and forkpty
2742
Martin v. Löwisfd9a72a2006-01-08 10:07:33 +00002743AC_CHECK_FUNCS(openpty,,
2744 AC_CHECK_LIB(util,openpty,
2745 [AC_DEFINE(HAVE_OPENPTY) LIBS="$LIBS -lutil"],
2746 AC_CHECK_LIB(bsd,openpty, [AC_DEFINE(HAVE_OPENPTY) LIBS="$LIBS -lbsd"])
2747 )
2748)
2749AC_CHECK_FUNCS(forkpty,,
2750 AC_CHECK_LIB(util,forkpty,
2751 [AC_DEFINE(HAVE_FORKPTY) LIBS="$LIBS -lutil"],
2752 AC_CHECK_LIB(bsd,forkpty, [AC_DEFINE(HAVE_FORKPTY) LIBS="$LIBS -lbsd"])
2753 )
2754)
Fred Drake8cef4cf2000-06-28 16:40:38 +00002755
Christian Heimesb186d002008-03-18 15:15:01 +00002756# Stuff for expat.
2757AC_CHECK_FUNCS(memmove)
2758
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00002759# check for long file support functions
2760AC_CHECK_FUNCS(fseek64 fseeko fstatvfs ftell64 ftello statvfs)
2761
Christian Heimesb186d002008-03-18 15:15:01 +00002762AC_REPLACE_FUNCS(dup2 getcwd strdup)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002763AC_CHECK_FUNCS(getpgrp,
2764 AC_TRY_COMPILE([#include <unistd.h>],
2765 [getpgrp(0);],
2766 AC_DEFINE(GETPGRP_HAVE_ARG, 1,
2767 [Define if getpgrp() must be called as getpgrp(0).])
2768 )
2769)
Jack Jansen150753c2003-03-29 22:07:47 +00002770AC_CHECK_FUNCS(setpgrp,
2771 AC_TRY_COMPILE([#include <unistd.h>],
2772 [setpgrp(0,0);],
2773 AC_DEFINE(SETPGRP_HAVE_ARG, 1,
2774 [Define if setpgrp() must be called as setpgrp(0, 0).])
2775 )
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002776)
2777AC_CHECK_FUNCS(gettimeofday,
2778 AC_TRY_COMPILE([#include <sys/time.h>],
2779 [gettimeofday((struct timeval*)0,(struct timezone*)0);], ,
2780 AC_DEFINE(GETTIMEOFDAY_NO_TZ, 1,
2781 [Define if gettimeofday() does not have second (timezone) argument
2782 This is the case on Motorola V4 (R40V4.2)])
2783 )
2784)
Guido van Rossum627b2d71993-12-24 10:39:16 +00002785
Martin v. Löwisdbe3f762002-10-10 14:27:30 +00002786AC_MSG_CHECKING(for major, minor, and makedev)
Martin v. Löwise3271202002-11-07 07:42:30 +00002787AC_TRY_LINK([
Neal Norwitz6eb37f02003-02-23 23:28:15 +00002788#if defined(MAJOR_IN_MKDEV)
2789#include <sys/mkdev.h>
2790#elif defined(MAJOR_IN_SYSMACROS)
2791#include <sys/sysmacros.h>
2792#else
2793#include <sys/types.h>
2794#endif
Martin v. Löwisdbe3f762002-10-10 14:27:30 +00002795],[
2796 makedev(major(0),minor(0));
2797],[
2798 AC_DEFINE(HAVE_DEVICE_MACROS, 1,
2799 [Define to 1 if you have the device macros.])
2800 AC_MSG_RESULT(yes)
2801],[
2802 AC_MSG_RESULT(no)
2803])
Martin v. Löwis861a65b2001-10-24 14:36:00 +00002804
2805# On OSF/1 V5.1, getaddrinfo is available, but a define
2806# for [no]getaddrinfo in netdb.h.
2807AC_MSG_CHECKING(for getaddrinfo)
2808AC_TRY_LINK([
Martin v. Löwisc010b6d2001-11-09 17:50:52 +00002809#include <sys/types.h>
Martin v. Löwis861a65b2001-10-24 14:36:00 +00002810#include <sys/socket.h>
2811#include <netdb.h>
Martin v. Löwisc010b6d2001-11-09 17:50:52 +00002812#include <stdio.h>
Martin v. Löwis861a65b2001-10-24 14:36:00 +00002813],[
2814getaddrinfo(NULL, NULL, NULL, NULL);
2815], [
2816AC_MSG_RESULT(yes)
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00002817AC_MSG_CHECKING(getaddrinfo bug)
2818AC_TRY_RUN([
2819#include <sys/types.h>
2820#include <netdb.h>
2821#include <string.h>
2822#include <sys/socket.h>
2823#include <netinet/in.h>
2824
2825main()
2826{
2827 int passive, gaierr, inet4 = 0, inet6 = 0;
2828 struct addrinfo hints, *ai, *aitop;
2829 char straddr[INET6_ADDRSTRLEN], strport[16];
2830
2831 for (passive = 0; passive <= 1; passive++) {
2832 memset(&hints, 0, sizeof(hints));
2833 hints.ai_family = AF_UNSPEC;
2834 hints.ai_flags = passive ? AI_PASSIVE : 0;
2835 hints.ai_socktype = SOCK_STREAM;
Hye-Shik Chang54f94392004-04-14 07:55:31 +00002836 hints.ai_protocol = IPPROTO_TCP;
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00002837 if ((gaierr = getaddrinfo(NULL, "54321", &hints, &aitop)) != 0) {
2838 (void)gai_strerror(gaierr);
2839 goto bad;
2840 }
2841 for (ai = aitop; ai; ai = ai->ai_next) {
2842 if (ai->ai_addr == NULL ||
2843 ai->ai_addrlen == 0 ||
2844 getnameinfo(ai->ai_addr, ai->ai_addrlen,
2845 straddr, sizeof(straddr), strport, sizeof(strport),
2846 NI_NUMERICHOST|NI_NUMERICSERV) != 0) {
2847 goto bad;
2848 }
2849 switch (ai->ai_family) {
2850 case AF_INET:
2851 if (strcmp(strport, "54321") != 0) {
2852 goto bad;
2853 }
2854 if (passive) {
2855 if (strcmp(straddr, "0.0.0.0") != 0) {
2856 goto bad;
2857 }
2858 } else {
2859 if (strcmp(straddr, "127.0.0.1") != 0) {
2860 goto bad;
2861 }
2862 }
2863 inet4++;
2864 break;
2865 case AF_INET6:
2866 if (strcmp(strport, "54321") != 0) {
2867 goto bad;
2868 }
2869 if (passive) {
2870 if (strcmp(straddr, "::") != 0) {
2871 goto bad;
2872 }
2873 } else {
2874 if (strcmp(straddr, "::1") != 0) {
2875 goto bad;
2876 }
2877 }
2878 inet6++;
2879 break;
2880 case AF_UNSPEC:
2881 goto bad;
2882 break;
2883 default:
2884 /* another family support? */
2885 break;
2886 }
2887 }
2888 }
2889
2890 if (!(inet4 == 0 || inet4 == 2))
2891 goto bad;
2892 if (!(inet6 == 0 || inet6 == 2))
2893 goto bad;
2894
2895 if (aitop)
2896 freeaddrinfo(aitop);
2897 exit(0);
2898
2899 bad:
2900 if (aitop)
2901 freeaddrinfo(aitop);
2902 exit(1);
2903}
2904],
2905AC_MSG_RESULT(good)
2906buggygetaddrinfo=no,
2907AC_MSG_RESULT(buggy)
2908buggygetaddrinfo=yes,
2909AC_MSG_RESULT(buggy)
Martin v. Löwis861a65b2001-10-24 14:36:00 +00002910buggygetaddrinfo=yes)], [
2911AC_MSG_RESULT(no)
2912buggygetaddrinfo=yes
2913])
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00002914
2915if test "$buggygetaddrinfo" = "yes"; then
2916 if test "$ipv6" = "yes"; then
2917 echo 'Fatal: You must get working getaddrinfo() function.'
2918 echo ' or you can specify "--disable-ipv6"'.
2919 exit 1
2920 fi
Martin v. Löwis861a65b2001-10-24 14:36:00 +00002921else
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002922 AC_DEFINE(HAVE_GETADDRINFO, 1, [Define if you have the getaddrinfo function.])
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00002923fi
Thomas Woutersb0db85a2001-08-08 10:39:03 +00002924AC_CHECK_FUNCS(getnameinfo)
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00002925
Guido van Rossum627b2d71993-12-24 10:39:16 +00002926# checks for structures
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002927AC_HEADER_TIME
Guido van Rossum627b2d71993-12-24 10:39:16 +00002928AC_STRUCT_TM
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002929AC_STRUCT_TIMEZONE
Martin v. Löwis60a5d722002-10-16 20:28:25 +00002930AC_CHECK_MEMBERS([struct stat.st_rdev])
2931AC_CHECK_MEMBERS([struct stat.st_blksize])
Hye-Shik Chang5f937a72005-06-02 13:09:30 +00002932AC_CHECK_MEMBERS([struct stat.st_flags])
Martin v. Löwisebd9d5b2005-08-09 15:00:59 +00002933AC_CHECK_MEMBERS([struct stat.st_gen])
2934AC_CHECK_MEMBERS([struct stat.st_birthtime])
Guido van Rossum98bf58f2001-10-18 20:34:25 +00002935AC_STRUCT_ST_BLOCKS
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002936
2937AC_MSG_CHECKING(for time.h that defines altzone)
2938AC_CACHE_VAL(ac_cv_header_time_altzone,
2939[AC_TRY_COMPILE([#include <time.h>], [return altzone;],
2940 ac_cv_header_time_altzone=yes,
2941 ac_cv_header_time_altzone=no)])
2942AC_MSG_RESULT($ac_cv_header_time_altzone)
2943if test $ac_cv_header_time_altzone = yes; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002944 AC_DEFINE(HAVE_ALTZONE, 1, [Define this if your time.h defines altzone.])
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002945fi
2946
Guido van Rossum5739e7e1995-01-20 16:50:53 +00002947was_it_defined=no
2948AC_MSG_CHECKING(whether sys/select.h and sys/time.h may both be included)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002949AC_TRY_COMPILE([
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002950#include <sys/types.h>
2951#include <sys/select.h>
2952#include <sys/time.h>
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002953], [;], [
2954 AC_DEFINE(SYS_SELECT_WITH_SYS_TIME, 1,
2955 [Define if you can safely include both <sys/select.h> and <sys/time.h>
2956 (which you can't on SCO ODT 3.0).])
2957 was_it_defined=yes
2958])
Guido van Rossum5739e7e1995-01-20 16:50:53 +00002959AC_MSG_RESULT($was_it_defined)
Guido van Rossum627b2d71993-12-24 10:39:16 +00002960
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00002961AC_MSG_CHECKING(for addrinfo)
2962AC_CACHE_VAL(ac_cv_struct_addrinfo,
2963AC_TRY_COMPILE([
2964# include <netdb.h>],
2965 [struct addrinfo a],
2966 ac_cv_struct_addrinfo=yes,
2967 ac_cv_struct_addrinfo=no))
2968AC_MSG_RESULT($ac_cv_struct_addrinfo)
2969if test $ac_cv_struct_addrinfo = yes; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002970 AC_DEFINE(HAVE_ADDRINFO, 1, [struct addrinfo (netdb.h)])
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00002971fi
2972
2973AC_MSG_CHECKING(for sockaddr_storage)
2974AC_CACHE_VAL(ac_cv_struct_sockaddr_storage,
2975AC_TRY_COMPILE([
2976# include <sys/types.h>
2977# include <sys/socket.h>],
2978 [struct sockaddr_storage s],
2979 ac_cv_struct_sockaddr_storage=yes,
2980 ac_cv_struct_sockaddr_storage=no))
2981AC_MSG_RESULT($ac_cv_struct_sockaddr_storage)
2982if test $ac_cv_struct_sockaddr_storage = yes; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002983 AC_DEFINE(HAVE_SOCKADDR_STORAGE, 1, [struct sockaddr_storage (sys/socket.h)])
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00002984fi
2985
Guido van Rossum627b2d71993-12-24 10:39:16 +00002986# checks for compiler characteristics
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002987
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002988AC_C_CHAR_UNSIGNED
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002989AC_C_CONST
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002990
Guido van Rossum5739e7e1995-01-20 16:50:53 +00002991works=no
2992AC_MSG_CHECKING(for working volatile)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002993AC_TRY_COMPILE([],[volatile int x; x = 0;], works=yes,
2994 AC_DEFINE(volatile, [], [Define to empty if the keyword does not work.])
2995)
Guido van Rossum5739e7e1995-01-20 16:50:53 +00002996AC_MSG_RESULT($works)
Guido van Rossumdabb11b1994-10-11 15:04:27 +00002997
Guido van Rossum5739e7e1995-01-20 16:50:53 +00002998works=no
2999AC_MSG_CHECKING(for working signed char)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003000AC_TRY_COMPILE([], [signed char c;], works=yes,
3001 AC_DEFINE(signed, [], [Define to empty if the keyword does not work.])
3002)
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003003AC_MSG_RESULT($works)
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003004
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003005have_prototypes=no
3006AC_MSG_CHECKING(for prototypes)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003007AC_TRY_COMPILE([int foo(int x) { return 0; }], [return foo(10);],[
3008 AC_DEFINE(HAVE_PROTOTYPES, 1,
3009 [Define if your compiler supports function prototype])
3010 have_prototypes=yes
3011])
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003012AC_MSG_RESULT($have_prototypes)
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003013
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003014works=no
3015AC_MSG_CHECKING(for variable length prototypes and stdarg.h)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003016AC_TRY_COMPILE([
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003017#include <stdarg.h>
Guido van Rossum3f13e481996-08-30 20:58:11 +00003018int foo(int x, ...) {
3019 va_list va;
3020 va_start(va, x);
3021 va_arg(va, int);
3022 va_arg(va, char *);
3023 va_arg(va, double);
3024 return 0;
3025}
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003026], [return foo(10, "", 3.14);], [
3027 AC_DEFINE(HAVE_STDARG_PROTOTYPES, 1,
3028 [Define if your compiler supports variable length function prototypes
3029 (e.g. void fprintf(FILE *, char *, ...);) *and* <stdarg.h>])
3030 works=yes
3031])
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003032AC_MSG_RESULT($works)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003033
Dave Cole331708b2004-08-09 04:51:41 +00003034# check for socketpair
3035AC_MSG_CHECKING(for socketpair)
3036AC_TRY_COMPILE([
3037#include <sys/types.h>
3038#include <sys/socket.h>
3039], void *x=socketpair,
3040 AC_DEFINE(HAVE_SOCKETPAIR, 1, Define if you have the 'socketpair' function.)
3041 AC_MSG_RESULT(yes),
3042 AC_MSG_RESULT(no)
3043)
3044
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003045# check if sockaddr has sa_len member
3046AC_MSG_CHECKING(if sockaddr has sa_len member)
3047AC_TRY_COMPILE([#include <sys/types.h>
3048#include <sys/socket.h>],
3049[struct sockaddr x;
3050x.sa_len = 0;],
3051 AC_MSG_RESULT(yes)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003052 AC_DEFINE(HAVE_SOCKADDR_SA_LEN, 1, [Define if sockaddr has sa_len member]),
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003053 AC_MSG_RESULT(no))
3054
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003055va_list_is_array=no
3056AC_MSG_CHECKING(whether va_list is an array)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003057AC_TRY_COMPILE([
3058#ifdef HAVE_STDARG_PROTOTYPES
3059#include <stdarg.h>
3060#else
3061#include <varargs.h>
3062#endif
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003063], [va_list list1, list2; list1 = list2;], , [
3064 AC_DEFINE(VA_LIST_IS_ARRAY, 1, [Define if a va_list is an array of some kind])
3065 va_list_is_array=yes
3066])
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003067AC_MSG_RESULT($va_list_is_array)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003068
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003069# sigh -- gethostbyname_r is a mess; it can have 3, 5 or 6 arguments :-(
Martin v. Löwis11437992002-04-12 09:54:03 +00003070AH_TEMPLATE(HAVE_GETHOSTBYNAME_R,
3071 [Define this if you have some version of gethostbyname_r()])
3072
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003073AC_CHECK_FUNC(gethostbyname_r, [
3074 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
3075 AC_MSG_CHECKING([gethostbyname_r with 6 args])
3076 OLD_CFLAGS=$CFLAGS
3077 CFLAGS="$CFLAGS $MY_CPPFLAGS $MY_THREAD_CPPFLAGS $MY_CFLAGS"
3078 AC_TRY_COMPILE([
3079# include <netdb.h>
3080 ], [
3081 char *name;
3082 struct hostent *he, *res;
3083 char buffer[2048];
3084 int buflen = 2048;
3085 int h_errnop;
3086
3087 (void) gethostbyname_r(name, he, buffer, buflen, &res, &h_errnop)
3088 ], [
Guido van Rossum8db7d8b1999-03-23 16:40:33 +00003089 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003090 AC_DEFINE(HAVE_GETHOSTBYNAME_R_6_ARG, 1,
3091 [Define this if you have the 6-arg version of gethostbyname_r().])
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003092 AC_MSG_RESULT(yes)
3093 ], [
3094 AC_MSG_RESULT(no)
3095 AC_MSG_CHECKING([gethostbyname_r with 5 args])
3096 AC_TRY_COMPILE([
3097# include <netdb.h>
3098 ], [
3099 char *name;
3100 struct hostent *he;
3101 char buffer[2048];
3102 int buflen = 2048;
3103 int h_errnop;
3104
3105 (void) gethostbyname_r(name, he, buffer, buflen, &h_errnop)
3106 ], [
Guido van Rossum8db7d8b1999-03-23 16:40:33 +00003107 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003108 AC_DEFINE(HAVE_GETHOSTBYNAME_R_5_ARG, 1,
3109 [Define this if you have the 5-arg version of gethostbyname_r().])
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003110 AC_MSG_RESULT(yes)
3111 ], [
3112 AC_MSG_RESULT(no)
3113 AC_MSG_CHECKING([gethostbyname_r with 3 args])
3114 AC_TRY_COMPILE([
3115# include <netdb.h>
3116 ], [
3117 char *name;
3118 struct hostent *he;
3119 struct hostent_data data;
3120
3121 (void) gethostbyname_r(name, he, &data);
3122 ], [
Guido van Rossum8db7d8b1999-03-23 16:40:33 +00003123 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003124 AC_DEFINE(HAVE_GETHOSTBYNAME_R_3_ARG, 1,
3125 [Define this if you have the 3-arg version of gethostbyname_r().])
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003126 AC_MSG_RESULT(yes)
3127 ], [
3128 AC_MSG_RESULT(no)
3129 ])
3130 ])
3131 ])
3132 CFLAGS=$OLD_CFLAGS
3133], [
Thomas Wouters3a584202000-08-05 23:28:51 +00003134 AC_CHECK_FUNCS(gethostbyname)
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003135])
3136AC_SUBST(HAVE_GETHOSTBYNAME_R_6_ARG)
3137AC_SUBST(HAVE_GETHOSTBYNAME_R_5_ARG)
3138AC_SUBST(HAVE_GETHOSTBYNAME_R_3_ARG)
Guido van Rossum8db7d8b1999-03-23 16:40:33 +00003139AC_SUBST(HAVE_GETHOSTBYNAME_R)
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003140AC_SUBST(HAVE_GETHOSTBYNAME)
3141
Guido van Rossum627b2d71993-12-24 10:39:16 +00003142# checks for system services
3143# (none yet)
3144
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003145# Linux requires this for correct f.p. operations
Jeremy Hyltonbe28f5b2000-07-27 21:03:04 +00003146AC_CHECK_FUNC(__fpu_control,
3147 [],
3148 [AC_CHECK_LIB(ieee, __fpu_control)
3149])
Guido van Rossum627b2d71993-12-24 10:39:16 +00003150
Guido van Rossum93274221997-05-09 02:42:00 +00003151# Check for --with-fpectl
Guido van Rossum93274221997-05-09 02:42:00 +00003152AC_MSG_CHECKING(for --with-fpectl)
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00003153AC_ARG_WITH(fpectl,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003154 AC_HELP_STRING(--with-fpectl, enable SIGFPE catching),
3155[
Guido van Rossum93274221997-05-09 02:42:00 +00003156if test "$withval" != no
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003157then
3158 AC_DEFINE(WANT_SIGFPE_HANDLER, 1,
3159 [Define if you want SIGFPE handled (see Include/pyfpe.h).])
3160 AC_MSG_RESULT(yes)
Guido van Rossum93274221997-05-09 02:42:00 +00003161else AC_MSG_RESULT(no)
Guido van Rossumef2255b2000-03-10 22:30:29 +00003162fi],
3163[AC_MSG_RESULT(no)])
Guido van Rossum93274221997-05-09 02:42:00 +00003164
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003165# check for --with-libm=...
3166AC_SUBST(LIBM)
Guido van Rossum4b6b5791996-09-09 20:09:34 +00003167case $ac_sys_system in
Guido van Rossum3dc0a512000-10-05 18:00:06 +00003168Darwin) ;;
Guido van Rossum4b6b5791996-09-09 20:09:34 +00003169*) LIBM=-lm
3170esac
Guido van Rossum93274221997-05-09 02:42:00 +00003171AC_MSG_CHECKING(for --with-libm=STRING)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003172AC_ARG_WITH(libm,
3173 AC_HELP_STRING(--with-libm=STRING, math library),
3174[
Guido van Rossum93274221997-05-09 02:42:00 +00003175if test "$withval" = no
3176then LIBM=
3177 AC_MSG_RESULT(force LIBM empty)
3178elif test "$withval" != yes
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003179then LIBM=$withval
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003180 AC_MSG_RESULT(set LIBM="$withval")
3181else AC_MSG_ERROR([proper usage is --with-libm=STRING])
Guido van Rossum93274221997-05-09 02:42:00 +00003182fi],
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003183[AC_MSG_RESULT(default LIBM="$LIBM")])
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003184
3185# check for --with-libc=...
3186AC_SUBST(LIBC)
Guido van Rossum93274221997-05-09 02:42:00 +00003187AC_MSG_CHECKING(for --with-libc=STRING)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003188AC_ARG_WITH(libc,
3189 AC_HELP_STRING(--with-libc=STRING, C library),
3190[
Guido van Rossum93274221997-05-09 02:42:00 +00003191if test "$withval" = no
3192then LIBC=
3193 AC_MSG_RESULT(force LIBC empty)
3194elif test "$withval" != yes
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003195then LIBC=$withval
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003196 AC_MSG_RESULT(set LIBC="$withval")
3197else AC_MSG_ERROR([proper usage is --with-libc=STRING])
Guido van Rossum93274221997-05-09 02:42:00 +00003198fi],
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003199[AC_MSG_RESULT(default LIBC="$LIBC")])
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003200
Mark Dickinsonb08a53a2009-04-16 19:52:09 +00003201# **************************************************
3202# * Check for various properties of floating point *
3203# **************************************************
Christian Heimes81ee3ef2008-05-04 22:42:01 +00003204
Mark Dickinsonb08a53a2009-04-16 19:52:09 +00003205AC_MSG_CHECKING(whether C doubles are little-endian IEEE 754 binary64)
3206AC_CACHE_VAL(ac_cv_little_endian_double, [
3207AC_TRY_RUN([
3208#include <string.h>
3209int main() {
3210 double x = 9006104071832581.0;
3211 if (memcmp(&x, "\x05\x04\x03\x02\x01\xff\x3f\x43", 8) == 0)
3212 return 0;
3213 else
3214 return 1;
3215}
3216],
3217ac_cv_little_endian_double=yes,
3218ac_cv_little_endian_double=no,
3219ac_cv_little_endian_double=no)])
3220AC_MSG_RESULT($ac_cv_little_endian_double)
3221if test "$ac_cv_little_endian_double" = yes
3222then
3223 AC_DEFINE(DOUBLE_IS_LITTLE_ENDIAN_IEEE754, 1,
3224 [Define if C doubles are 64-bit IEEE 754 binary format, stored
3225 with the least significant byte first])
3226fi
3227
3228AC_MSG_CHECKING(whether C doubles are big-endian IEEE 754 binary64)
3229AC_CACHE_VAL(ac_cv_big_endian_double, [
3230AC_TRY_RUN([
3231#include <string.h>
3232int main() {
3233 double x = 9006104071832581.0;
3234 if (memcmp(&x, "\x43\x3f\xff\x01\x02\x03\x04\x05", 8) == 0)
3235 return 0;
3236 else
3237 return 1;
3238}
3239],
3240ac_cv_big_endian_double=yes,
3241ac_cv_big_endian_double=no,
3242ac_cv_big_endian_double=no)])
3243AC_MSG_RESULT($ac_cv_big_endian_double)
3244if test "$ac_cv_big_endian_double" = yes
3245then
3246 AC_DEFINE(DOUBLE_IS_BIG_ENDIAN_IEEE754, 1,
3247 [Define if C doubles are 64-bit IEEE 754 binary format, stored
3248 with the most significant byte first])
3249fi
3250
3251# Some ARM platforms use a mixed-endian representation for doubles.
3252# While Python doesn't currently have full support for these platforms
3253# (see e.g., issue 1762561), we can at least make sure that float <-> string
3254# conversions work.
3255AC_MSG_CHECKING(whether C doubles are ARM mixed-endian IEEE 754 binary64)
3256AC_CACHE_VAL(ac_cv_mixed_endian_double, [
3257AC_TRY_RUN([
3258#include <string.h>
3259int main() {
3260 double x = 9006104071832581.0;
3261 if (memcmp(&x, "\x01\xff\x3f\x43\x05\x04\x03\x02", 8) == 0)
3262 return 0;
3263 else
3264 return 1;
3265}
3266],
3267ac_cv_mixed_endian_double=yes,
3268ac_cv_mixed_endian_double=no,
3269ac_cv_mixed_endian_double=no)])
3270AC_MSG_RESULT($ac_cv_mixed_endian_double)
3271if test "$ac_cv_mixed_endian_double" = yes
3272then
3273 AC_DEFINE(DOUBLE_IS_ARM_MIXED_ENDIAN_IEEE754, 1,
3274 [Define if C doubles are 64-bit IEEE 754 binary format, stored
3275 in ARM mixed-endian order (byte order 45670123)])
3276fi
3277
Mark Dickinson7abf8d42009-04-18 20:17:52 +00003278# The short float repr introduced in Python 3.1 requires the
3279# correctly-rounded string <-> double conversion functions from
3280# Python/dtoa.c, which in turn require that the FPU uses 53-bit
3281# rounding; this is a problem on x86, where the x87 FPU has a default
3282# rounding precision of 64 bits. For gcc/x86, we try to fix this by
3283# using inline assembler to get and set the x87 FPU control word.
Mark Dickinsonb08a53a2009-04-16 19:52:09 +00003284if test "$GCC" = yes && test -n "`$CC -dM -E - </dev/null | grep i386`"
3285then
Mark Dickinson7abf8d42009-04-18 20:17:52 +00003286 # Check that it's okay to use gcc inline assembler to get and set
3287 # x87 control word. It should be, but you never know...
3288 AC_MSG_CHECKING(whether we can use gcc inline assembler to get and set x87 control word)
3289 AC_TRY_COMPILE([], [
3290 unsigned short cw;
3291 __asm__ __volatile__ ("fnstcw %0" : "=m" (cw));
3292 __asm__ __volatile__ ("fldcw %0" : : "m" (cw));
3293 ],
3294 [have_gcc_asm_for_x87=yes], [have_gcc_asm_for_x87=no])
3295 AC_MSG_RESULT($have_gcc_asm_for_x87)
3296 if test "$have_gcc_asm_for_x87" = yes
Mark Dickinsonb08a53a2009-04-16 19:52:09 +00003297 then
Mark Dickinson7abf8d42009-04-18 20:17:52 +00003298 AC_DEFINE(HAVE_GCC_ASM_FOR_X87, 1,
3299 [Define if we can use gcc inline assembler to get and set x87 control word])
Mark Dickinsonb08a53a2009-04-16 19:52:09 +00003300 fi
3301fi
Christian Heimes81ee3ef2008-05-04 22:42:01 +00003302
Mark Dickinson3dc7c6a2009-01-04 15:09:02 +00003303# Detect whether system arithmetic is subject to x87-style double
3304# rounding issues. The result of this test has little meaning on non
3305# IEEE 754 platforms. On IEEE 754, test should return 1 if rounding
3306# mode is round-to-nearest and double rounding issues are present, and
3307# 0 otherwise. See http://bugs.python.org/issue2937 for more info.
3308AC_MSG_CHECKING(for x87-style double rounding)
Mark Dickinsonb08a53a2009-04-16 19:52:09 +00003309# $BASECFLAGS may affect the result
3310ac_save_cc="$CC"
3311CC="$CC $BASECFLAGS"
Mark Dickinson3dc7c6a2009-01-04 15:09:02 +00003312AC_TRY_RUN([
3313#include <stdlib.h>
3314#include <math.h>
3315int main() {
3316 volatile double x, y, z;
3317 /* 1./(1-2**-53) -> 1+2**-52 (correct), 1.0 (double rounding) */
3318 x = 0.99999999999999989; /* 1-2**-53 */
3319 y = 1./x;
3320 if (y != 1.)
3321 exit(0);
3322 /* 1e16+2.99999 -> 1e16+2. (correct), 1e16+4. (double rounding) */
3323 x = 1e16;
3324 y = 2.99999;
3325 z = x + y;
3326 if (z != 1e16+4.)
3327 exit(0);
3328 /* both tests show evidence of double rounding */
3329 exit(1);
3330}
3331],
3332ac_cv_x87_double_rounding=no,
3333ac_cv_x87_double_rounding=yes,
Mark Dickinsonb08a53a2009-04-16 19:52:09 +00003334ac_cv_x87_double_rounding=no)
3335CC="$ac_save_cc"
Mark Dickinson3dc7c6a2009-01-04 15:09:02 +00003336AC_MSG_RESULT($ac_cv_x87_double_rounding)
3337if test "$ac_cv_x87_double_rounding" = yes
3338then
3339 AC_DEFINE(X87_DOUBLE_ROUNDING, 1,
3340 [Define if arithmetic is subject to x87-style double rounding issue])
3341fi
3342
Mark Dickinsonb08a53a2009-04-16 19:52:09 +00003343# ************************************
3344# * Check for mathematical functions *
3345# ************************************
3346
3347LIBS_SAVE=$LIBS
3348LIBS="$LIBS $LIBM"
3349
Christian Heimes81ee3ef2008-05-04 22:42:01 +00003350# On FreeBSD 6.2, it appears that tanh(-0.) returns 0. instead of
3351# -0. on some architectures.
3352AC_MSG_CHECKING(whether tanh preserves the sign of zero)
3353AC_CACHE_VAL(ac_cv_tanh_preserves_zero_sign, [
3354AC_TRY_RUN([
3355#include <math.h>
3356#include <stdlib.h>
3357int main() {
3358 /* return 0 if either negative zeros don't exist
3359 on this platform or if negative zeros exist
3360 and tanh(-0.) == -0. */
3361 if (atan2(0., -1.) == atan2(-0., -1.) ||
3362 atan2(tanh(-0.), -1.) == atan2(-0., -1.)) exit(0);
3363 else exit(1);
3364}
3365],
3366ac_cv_tanh_preserves_zero_sign=yes,
3367ac_cv_tanh_preserves_zero_sign=no,
3368ac_cv_tanh_preserves_zero_sign=no)])
3369AC_MSG_RESULT($ac_cv_tanh_preserves_zero_sign)
3370if test "$ac_cv_tanh_preserves_zero_sign" = yes
3371then
3372 AC_DEFINE(TANH_PRESERVES_ZERO_SIGN, 1,
3373 [Define if tanh(-0.) is -0., or if platform doesn't have signed zeros])
3374fi
3375
Mark Dickinsonf2537862009-04-18 13:58:18 +00003376AC_CHECK_FUNCS([acosh asinh atanh copysign expm1 finite hypot log1p round])
Mark Dickinson3dc7c6a2009-01-04 15:09:02 +00003377AC_CHECK_DECLS([isinf, isnan, isfinite], [], [], [[#include <math.h>]])
Christian Heimes99170a52007-12-19 02:07:34 +00003378
Guido van Rossumaf5b83e1995-01-04 19:02:35 +00003379LIBS=$LIBS_SAVE
3380
Mark Dickinson875ada42009-11-28 12:52:39 +00003381# For multiprocessing module, check that sem_open
3382# actually works. For FreeBSD versions <= 7.2,
3383# the kernel module that provides POSIX semaphores
3384# isn't loaded by default, so an attempt to call
3385# sem_open results in a 'Signal 12' error.
3386AC_MSG_CHECKING(whether POSIX semaphores are enabled)
3387AC_CACHE_VAL(ac_cv_posix_semaphores_enabled,
3388AC_TRY_RUN([
3389#include <unistd.h>
3390#include <fcntl.h>
3391#include <stdio.h>
3392#include <semaphore.h>
3393#include <sys/stat.h>
3394
3395int main(void) {
3396 sem_t *a = sem_open("/autoconf", O_CREAT, S_IRUSR|S_IWUSR, 0);
3397 if (a == SEM_FAILED) {
3398 perror("sem_open");
3399 return 1;
3400 }
3401 sem_close(a);
Mark Dickinson62eda4d2009-12-13 21:18:16 +00003402 sem_unlink("/autoconf");
Mark Dickinson875ada42009-11-28 12:52:39 +00003403 return 0;
3404}
3405], ac_cv_posix_semaphores_enabled=yes,
3406 ac_cv_posix_semaphores_enabled=no,
3407 ac_cv_posix_semaphores_enabled=yes)
3408)
3409AC_MSG_RESULT($ac_cv_posix_semaphores_enabled)
3410if test $ac_cv_posix_semaphores_enabled = no
3411then
3412 AC_DEFINE(POSIX_SEMAPHORES_NOT_ENABLED, 1,
3413 [Define if POSIX semaphores aren't enabled on your system])
3414fi
3415
Mark Dickinson10683072009-04-18 21:18:19 +00003416# Multiprocessing check for broken sem_getvalue
3417AC_MSG_CHECKING(for broken sem_getvalue)
3418AC_TRY_RUN([
3419#include <unistd.h>
3420#include <fcntl.h>
3421#include <stdio.h>
3422#include <semaphore.h>
3423#include <sys/stat.h>
3424
3425int main(void){
Mark Dickinson62eda4d2009-12-13 21:18:16 +00003426 sem_t *a = sem_open("/autocftw", O_CREAT, S_IRUSR|S_IWUSR, 0);
Mark Dickinson10683072009-04-18 21:18:19 +00003427 int count;
3428 int res;
3429 if(a==SEM_FAILED){
3430 perror("sem_open");
3431 return 1;
3432
3433 }
3434 res = sem_getvalue(a, &count);
3435 sem_close(a);
Mark Dickinson62eda4d2009-12-13 21:18:16 +00003436 sem_unlink("/autocftw");
Mark Dickinson10683072009-04-18 21:18:19 +00003437 return res==-1 ? 1 : 0;
3438}
3439]
3440,AC_MSG_RESULT(no),
3441 AC_MSG_RESULT(yes)
3442 AC_DEFINE(HAVE_BROKEN_SEM_GETVALUE, 1, define to 1 if your sem_getvalue is broken.)
3443)
3444
Mark Dickinsonbd792642009-03-18 20:06:12 +00003445# determine what size digit to use for Python's longs
3446AC_MSG_CHECKING([digit size for Python's longs])
3447AC_ARG_ENABLE(big-digits,
3448AC_HELP_STRING([--enable-big-digits@<:@=BITS@:>@],[use big digits for Python longs [[BITS=30]]]),
3449[case $enable_big_digits in
3450yes)
3451 enable_big_digits=30 ;;
3452no)
3453 enable_big_digits=15 ;;
3454[15|30])
3455 ;;
3456*)
3457 AC_MSG_ERROR([bad value $enable_big_digits for --enable-big-digits; value should be 15 or 30]) ;;
3458esac
3459AC_MSG_RESULT($enable_big_digits)
3460AC_DEFINE_UNQUOTED(PYLONG_BITS_IN_DIGIT, $enable_big_digits, [Define as the preferred size in bits of long digits])
3461],
3462[AC_MSG_RESULT(no value specified)])
3463
Guido van Rossumef2255b2000-03-10 22:30:29 +00003464# check for wchar.h
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003465AC_CHECK_HEADER(wchar.h, [
3466 AC_DEFINE(HAVE_WCHAR_H, 1,
3467 [Define if the compiler provides a wchar.h header file.])
3468 wchar_h="yes"
3469],
Guido van Rossumef2255b2000-03-10 22:30:29 +00003470wchar_h="no"
3471)
3472
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003473# determine wchar_t size
3474if test "$wchar_h" = yes
3475then
Guido van Rossum67b26592001-10-20 14:21:45 +00003476 AC_CHECK_SIZEOF(wchar_t, 4, [#include <wchar.h>])
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003477fi
3478
Martin v. Löwisfa3bdea2003-09-04 18:50:54 +00003479AC_MSG_CHECKING(for UCS-4 tcl)
3480have_ucs4_tcl=no
3481AC_TRY_COMPILE([
3482#include <tcl.h>
3483#if TCL_UTF_MAX != 6
3484# error "NOT UCS4_TCL"
3485#endif], [], [
3486 AC_DEFINE(HAVE_UCS4_TCL, 1, [Define this if you have tcl and TCL_UTF_MAX==6])
3487 have_ucs4_tcl=yes
3488])
3489AC_MSG_RESULT($have_ucs4_tcl)
3490
Marc-André Lemburgd7160f82003-09-22 11:14:40 +00003491# check whether wchar_t is signed or not
3492if test "$wchar_h" = yes
3493then
3494 # check whether wchar_t is signed or not
3495 AC_MSG_CHECKING(whether wchar_t is signed)
3496 AC_CACHE_VAL(ac_cv_wchar_t_signed, [
3497 AC_TRY_RUN([
3498 #include <wchar.h>
3499 int main()
3500 {
Thomas Wouters49fd7fa2006-04-21 10:40:58 +00003501 /* Success: exit code 0 */
3502 exit((((wchar_t) -1) < ((wchar_t) 0)) ? 0 : 1);
Marc-André Lemburgd7160f82003-09-22 11:14:40 +00003503 }
3504 ],
3505 ac_cv_wchar_t_signed=yes,
3506 ac_cv_wchar_t_signed=no,
3507 ac_cv_wchar_t_signed=yes)])
3508 AC_MSG_RESULT($ac_cv_wchar_t_signed)
3509fi
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003510
Georg Brandl52d168a2008-01-07 18:10:24 +00003511AC_MSG_CHECKING(what type to use for str)
3512AC_ARG_WITH(wide-unicode,
3513 AC_HELP_STRING(--with-wide-unicode, Use 4-byte Unicode characters (default is 2 bytes)),
3514[
3515if test "$withval" != no
3516then unicode_size="4"
3517else unicode_size="2"
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003518fi
Georg Brandl52d168a2008-01-07 18:10:24 +00003519],
3520[
3521case "$have_ucs4_tcl" in
3522 yes) unicode_size="4" ;;
3523 *) unicode_size="2" ;;
3524esac
3525])
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003526
Martin v. Löwis0036cba2002-04-12 09:58:45 +00003527AH_TEMPLATE(Py_UNICODE_SIZE,
3528 [Define as the size of the unicode type.])
Georg Brandl52d168a2008-01-07 18:10:24 +00003529case "$unicode_size" in
3530 4) AC_DEFINE(Py_UNICODE_SIZE, 4) ;;
3531 *) AC_DEFINE(Py_UNICODE_SIZE, 2) ;;
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003532esac
3533
Martin v. Löwis11437992002-04-12 09:54:03 +00003534AH_TEMPLATE(PY_UNICODE_TYPE,
3535 [Define as the integral type used for Unicode representation.])
Martin v. Löwis0036cba2002-04-12 09:58:45 +00003536
Georg Brandl52d168a2008-01-07 18:10:24 +00003537# wchar_t is only usable if it maps to an unsigned type
3538if test "$unicode_size" = "$ac_cv_sizeof_wchar_t" \
Matthias Klose7dbeed72004-12-24 08:22:17 +00003539 -a "$ac_cv_wchar_t_signed" = "no"
Georg Brandl52d168a2008-01-07 18:10:24 +00003540then
3541 PY_UNICODE_TYPE="wchar_t"
3542 AC_DEFINE(HAVE_USABLE_WCHAR_T, 1,
3543 [Define if you have a useable wchar_t type defined in wchar.h; useable
3544 means wchar_t must be an unsigned type with at least 16 bits. (see
3545 Include/unicodeobject.h).])
3546 AC_DEFINE(PY_UNICODE_TYPE,wchar_t)
3547elif test "$ac_cv_sizeof_short" = "$unicode_size"
3548then
3549 PY_UNICODE_TYPE="unsigned short"
3550 AC_DEFINE(PY_UNICODE_TYPE,unsigned short)
3551elif test "$ac_cv_sizeof_long" = "$unicode_size"
3552then
3553 PY_UNICODE_TYPE="unsigned long"
3554 AC_DEFINE(PY_UNICODE_TYPE,unsigned long)
3555else
3556 PY_UNICODE_TYPE="no type found"
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003557fi
Georg Brandl52d168a2008-01-07 18:10:24 +00003558AC_MSG_RESULT($PY_UNICODE_TYPE)
Guido van Rossumef2255b2000-03-10 22:30:29 +00003559
3560# check for endianness
3561AC_C_BIGENDIAN
3562
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00003563# Check whether right shifting a negative integer extends the sign bit
3564# or fills with zeros (like the Cray J90, according to Tim Peters).
3565AC_MSG_CHECKING(whether right shift extends the sign bit)
Vladimir Marangozova6180282000-07-12 05:05:06 +00003566AC_CACHE_VAL(ac_cv_rshift_extends_sign, [
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00003567AC_TRY_RUN([
3568int main()
3569{
Vladimir Marangozova6180282000-07-12 05:05:06 +00003570 exit(((-1)>>3 == -1) ? 0 : 1);
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00003571}
Guido van Rossum3065c942001-09-17 04:03:14 +00003572],
3573ac_cv_rshift_extends_sign=yes,
3574ac_cv_rshift_extends_sign=no,
3575ac_cv_rshift_extends_sign=yes)])
Vladimir Marangozova6180282000-07-12 05:05:06 +00003576AC_MSG_RESULT($ac_cv_rshift_extends_sign)
3577if test "$ac_cv_rshift_extends_sign" = no
3578then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003579 AC_DEFINE(SIGNED_RIGHT_SHIFT_ZERO_FILLS, 1,
3580 [Define if i>>j for signed int i does not extend the sign bit
3581 when i < 0])
Vladimir Marangozova6180282000-07-12 05:05:06 +00003582fi
3583
Guido van Rossumcadfaec2001-01-05 14:45:49 +00003584# check for getc_unlocked and related locking functions
3585AC_MSG_CHECKING(for getc_unlocked() and friends)
3586AC_CACHE_VAL(ac_cv_have_getc_unlocked, [
3587AC_TRY_LINK([#include <stdio.h>],[
3588 FILE *f = fopen("/dev/null", "r");
3589 flockfile(f);
3590 getc_unlocked(f);
3591 funlockfile(f);
3592], ac_cv_have_getc_unlocked=yes, ac_cv_have_getc_unlocked=no)])
3593AC_MSG_RESULT($ac_cv_have_getc_unlocked)
3594if test "$ac_cv_have_getc_unlocked" = yes
3595then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003596 AC_DEFINE(HAVE_GETC_UNLOCKED, 1,
3597 [Define this if you have flockfile(), getc_unlocked(), and funlockfile()])
Guido van Rossumcadfaec2001-01-05 14:45:49 +00003598fi
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00003599
Neal Norwitzfe8e3d92006-01-07 21:07:20 +00003600# check where readline lives
Martin v. Löwis82bca632006-02-10 20:49:30 +00003601# save the value of LIBS so we don't actually link Python with readline
3602LIBS_no_readline=$LIBS
Gregory P. Smith18820942008-09-07 06:24:49 +00003603
3604# On some systems we need to link readline to a termcap compatible
3605# library. NOTE: Keep the precedence of listed libraries synchronised
3606# with setup.py.
3607py_cv_lib_readline=no
3608AC_MSG_CHECKING([how to link readline libs])
3609for py_libtermcap in "" ncursesw ncurses curses termcap; do
3610 if test -z "$py_libtermcap"; then
3611 READLINE_LIBS="-lreadline"
3612 else
3613 READLINE_LIBS="-lreadline -l$py_libtermcap"
3614 fi
3615 LIBS="$READLINE_LIBS $LIBS_no_readline"
3616 AC_LINK_IFELSE(
3617 [AC_LANG_CALL([],[readline])],
3618 [py_cv_lib_readline=yes])
3619 if test $py_cv_lib_readline = yes; then
3620 break
3621 fi
3622done
3623# Uncomment this line if you want to use READINE_LIBS in Makefile or scripts
3624#AC_SUBST([READLINE_LIBS])
Gregory P. Smith97515912008-09-07 19:23:19 +00003625if test $py_cv_lib_readline = no; then
Gregory P. Smith18820942008-09-07 06:24:49 +00003626 AC_MSG_RESULT([none])
3627else
3628 AC_MSG_RESULT([$READLINE_LIBS])
3629 AC_DEFINE(HAVE_LIBREADLINE, 1,
3630 [Define if you have the readline library (-lreadline).])
Neal Norwitzfe8e3d92006-01-07 21:07:20 +00003631fi
3632
Michael W. Hudson30ea2f22004-07-07 17:44:12 +00003633# check for readline 2.1
3634AC_CHECK_LIB(readline, rl_callback_handler_install,
3635 AC_DEFINE(HAVE_RL_CALLBACK, 1,
Gregory P. Smith18820942008-09-07 06:24:49 +00003636 [Define if you have readline 2.1]), ,$READLINE_LIBS)
Michael W. Hudson30ea2f22004-07-07 17:44:12 +00003637
Guido van Rossumfaf5e4d2002-12-30 16:25:41 +00003638# check for readline 2.2
3639AC_TRY_CPP([#include <readline/readline.h>],
3640have_readline=yes, have_readline=no)
3641if test $have_readline = yes
3642then
3643 AC_EGREP_HEADER([extern int rl_completion_append_character;],
3644 [readline/readline.h],
3645 AC_DEFINE(HAVE_RL_COMPLETION_APPEND_CHARACTER, 1,
3646 [Define if you have readline 2.2]), )
Antoine Pitrou37276002009-10-26 19:32:51 +00003647 AC_EGREP_HEADER([extern int rl_completion_suppress_append;],
3648 [readline/readline.h],
3649 AC_DEFINE(HAVE_RL_COMPLETION_SUPPRESS_APPEND, 1,
3650 [Define if you have rl_completion_suppress_append]), )
Guido van Rossumfaf5e4d2002-12-30 16:25:41 +00003651fi
3652
Martin v. Löwis0daad592001-09-30 21:09:59 +00003653# check for readline 4.0
3654AC_CHECK_LIB(readline, rl_pre_input_hook,
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003655 AC_DEFINE(HAVE_RL_PRE_INPUT_HOOK, 1,
Gregory P. Smith18820942008-09-07 06:24:49 +00003656 [Define if you have readline 4.0]), ,$READLINE_LIBS)
Martin v. Löwis0daad592001-09-30 21:09:59 +00003657
Thomas Wouters89d996e2007-09-08 17:39:28 +00003658# also in 4.0
3659AC_CHECK_LIB(readline, rl_completion_display_matches_hook,
3660 AC_DEFINE(HAVE_RL_COMPLETION_DISPLAY_MATCHES_HOOK, 1,
Gregory P. Smith18820942008-09-07 06:24:49 +00003661 [Define if you have readline 4.0]), ,$READLINE_LIBS)
Thomas Wouters89d996e2007-09-08 17:39:28 +00003662
Guido van Rossum353ae582001-07-10 16:45:32 +00003663# check for readline 4.2
3664AC_CHECK_LIB(readline, rl_completion_matches,
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003665 AC_DEFINE(HAVE_RL_COMPLETION_MATCHES, 1,
Gregory P. Smith18820942008-09-07 06:24:49 +00003666 [Define if you have readline 4.2]), ,$READLINE_LIBS)
Guido van Rossum353ae582001-07-10 16:45:32 +00003667
Michael W. Hudson30ea2f22004-07-07 17:44:12 +00003668# also in readline 4.2
3669AC_TRY_CPP([#include <readline/readline.h>],
3670have_readline=yes, have_readline=no)
3671if test $have_readline = yes
3672then
3673 AC_EGREP_HEADER([extern int rl_catch_signals;],
3674 [readline/readline.h],
3675 AC_DEFINE(HAVE_RL_CATCH_SIGNAL, 1,
3676 [Define if you can turn off readline's signal handling.]), )
3677fi
3678
Martin v. Löwis82bca632006-02-10 20:49:30 +00003679# End of readline checks: restore LIBS
3680LIBS=$LIBS_no_readline
3681
Thomas Wouterse38b2f12001-07-11 22:35:31 +00003682AC_MSG_CHECKING(for broken nice())
3683AC_CACHE_VAL(ac_cv_broken_nice, [
3684AC_TRY_RUN([
3685int main()
3686{
3687 int val1 = nice(1);
3688 if (val1 != -1 && val1 == nice(2))
3689 exit(0);
3690 exit(1);
3691}
Guido van Rossum3065c942001-09-17 04:03:14 +00003692],
3693ac_cv_broken_nice=yes,
3694ac_cv_broken_nice=no,
3695ac_cv_broken_nice=no)])
Thomas Wouterse38b2f12001-07-11 22:35:31 +00003696AC_MSG_RESULT($ac_cv_broken_nice)
3697if test "$ac_cv_broken_nice" = yes
3698then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003699 AC_DEFINE(HAVE_BROKEN_NICE, 1,
3700 [Define if nice() returns success/failure instead of the new priority.])
Thomas Wouterse38b2f12001-07-11 22:35:31 +00003701fi
3702
Nicholas Bastine62c5c82004-03-21 23:45:42 +00003703AC_MSG_CHECKING(for broken poll())
3704AC_TRY_RUN([
3705#include <poll.h>
3706
3707int main (void)
3708 {
3709 struct pollfd poll_struct = { 42, POLLIN|POLLPRI|POLLOUT, 0 };
3710
3711 close (42);
3712
3713 int poll_test = poll (&poll_struct, 1, 0);
3714
3715 if (poll_test < 0)
3716 {
3717 exit(0);
3718 }
3719 else if (poll_test == 0 && poll_struct.revents != POLLNVAL)
3720 {
3721 exit(0);
3722 }
3723 else
3724 {
3725 exit(1);
3726 }
3727 }
3728],
3729ac_cv_broken_poll=yes,
3730ac_cv_broken_poll=no,
3731ac_cv_broken_poll=no)
3732AC_MSG_RESULT($ac_cv_broken_poll)
3733if test "$ac_cv_broken_poll" = yes
3734then
3735 AC_DEFINE(HAVE_BROKEN_POLL, 1,
3736 [Define if poll() sets errno on invalid file descriptors.])
3737fi
3738
Brett Cannon43802422005-02-10 20:48:03 +00003739# Before we can test tzset, we need to check if struct tm has a tm_zone
3740# (which is not required by ISO C or UNIX spec) and/or if we support
3741# tzname[]
3742AC_STRUCT_TIMEZONE
Nicholas Bastine62c5c82004-03-21 23:45:42 +00003743
Brett Cannon43802422005-02-10 20:48:03 +00003744# check tzset(3) exists and works like we expect it to
Guido van Rossumd11b62e2003-03-14 21:51:36 +00003745AC_MSG_CHECKING(for working tzset())
3746AC_CACHE_VAL(ac_cv_working_tzset, [
3747AC_TRY_RUN([
3748#include <stdlib.h>
3749#include <time.h>
Brett Cannon18367812003-09-19 00:59:16 +00003750#include <string.h>
Brett Cannon43802422005-02-10 20:48:03 +00003751
3752#if HAVE_TZNAME
3753extern char *tzname[];
3754#endif
3755
Guido van Rossumd11b62e2003-03-14 21:51:36 +00003756int main()
3757{
Brett Cannon18367812003-09-19 00:59:16 +00003758 /* Note that we need to ensure that not only does tzset(3)
3759 do 'something' with localtime, but it works as documented
3760 in the library reference and as expected by the test suite.
Brett Cannon43802422005-02-10 20:48:03 +00003761 This includes making sure that tzname is set properly if
3762 tm->tm_zone does not exist since it is the alternative way
3763 of getting timezone info.
Brett Cannon18367812003-09-19 00:59:16 +00003764
3765 Red Hat 6.2 doesn't understand the southern hemisphere
Brett Cannon43802422005-02-10 20:48:03 +00003766 after New Year's Day.
Brett Cannon18367812003-09-19 00:59:16 +00003767 */
3768
Brett Cannon43802422005-02-10 20:48:03 +00003769 time_t groundhogday = 1044144000; /* GMT-based */
Brett Cannon18367812003-09-19 00:59:16 +00003770 time_t midyear = groundhogday + (365 * 24 * 3600 / 2);
3771
Neal Norwitz7f2588c2003-04-11 15:35:53 +00003772 putenv("TZ=UTC+0");
Guido van Rossumd11b62e2003-03-14 21:51:36 +00003773 tzset();
Brett Cannon18367812003-09-19 00:59:16 +00003774 if (localtime(&groundhogday)->tm_hour != 0)
3775 exit(1);
Brett Cannon43802422005-02-10 20:48:03 +00003776#if HAVE_TZNAME
3777 /* For UTC, tzname[1] is sometimes "", sometimes " " */
3778 if (strcmp(tzname[0], "UTC") ||
3779 (tzname[1][0] != 0 && tzname[1][0] != ' '))
3780 exit(1);
3781#endif
Brett Cannon18367812003-09-19 00:59:16 +00003782
Neal Norwitz7f2588c2003-04-11 15:35:53 +00003783 putenv("TZ=EST+5EDT,M4.1.0,M10.5.0");
Guido van Rossumd11b62e2003-03-14 21:51:36 +00003784 tzset();
Brett Cannon18367812003-09-19 00:59:16 +00003785 if (localtime(&groundhogday)->tm_hour != 19)
Guido van Rossumd11b62e2003-03-14 21:51:36 +00003786 exit(1);
Brett Cannon43802422005-02-10 20:48:03 +00003787#if HAVE_TZNAME
3788 if (strcmp(tzname[0], "EST") || strcmp(tzname[1], "EDT"))
3789 exit(1);
3790#endif
Brett Cannon18367812003-09-19 00:59:16 +00003791
3792 putenv("TZ=AEST-10AEDT-11,M10.5.0,M3.5.0");
3793 tzset();
3794 if (localtime(&groundhogday)->tm_hour != 11)
3795 exit(1);
Brett Cannon43802422005-02-10 20:48:03 +00003796#if HAVE_TZNAME
3797 if (strcmp(tzname[0], "AEST") || strcmp(tzname[1], "AEDT"))
3798 exit(1);
3799#endif
3800
3801#if HAVE_STRUCT_TM_TM_ZONE
Brett Cannon18367812003-09-19 00:59:16 +00003802 if (strcmp(localtime(&groundhogday)->tm_zone, "AEDT"))
3803 exit(1);
3804 if (strcmp(localtime(&midyear)->tm_zone, "AEST"))
3805 exit(1);
Brett Cannon43802422005-02-10 20:48:03 +00003806#endif
Brett Cannon18367812003-09-19 00:59:16 +00003807
Guido van Rossumd11b62e2003-03-14 21:51:36 +00003808 exit(0);
3809}
3810],
3811ac_cv_working_tzset=yes,
3812ac_cv_working_tzset=no,
3813ac_cv_working_tzset=no)])
3814AC_MSG_RESULT($ac_cv_working_tzset)
3815if test "$ac_cv_working_tzset" = yes
3816then
3817 AC_DEFINE(HAVE_WORKING_TZSET, 1,
3818 [Define if tzset() actually switches the local timezone in a meaningful way.])
3819fi
3820
Martin v. Löwis94717ed2002-09-09 14:24:16 +00003821# Look for subsecond timestamps in struct stat
3822AC_MSG_CHECKING(for tv_nsec in struct stat)
3823AC_CACHE_VAL(ac_cv_stat_tv_nsec,
3824AC_TRY_COMPILE([#include <sys/stat.h>], [
3825struct stat st;
3826st.st_mtim.tv_nsec = 1;
3827],
Martin v. Löwisa32c9942002-09-09 16:17:47 +00003828ac_cv_stat_tv_nsec=yes,
Martin v. Löwis94717ed2002-09-09 14:24:16 +00003829ac_cv_stat_tv_nsec=no,
3830ac_cv_stat_tv_nsec=no))
3831AC_MSG_RESULT($ac_cv_stat_tv_nsec)
3832if test "$ac_cv_stat_tv_nsec" = yes
3833then
3834 AC_DEFINE(HAVE_STAT_TV_NSEC, 1,
3835 [Define if you have struct stat.st_mtim.tv_nsec])
3836fi
3837
Martin v. Löwisebd9d5b2005-08-09 15:00:59 +00003838# Look for BSD style subsecond timestamps in struct stat
3839AC_MSG_CHECKING(for tv_nsec2 in struct stat)
3840AC_CACHE_VAL(ac_cv_stat_tv_nsec2,
3841AC_TRY_COMPILE([#include <sys/stat.h>], [
3842struct stat st;
3843st.st_mtimespec.tv_nsec = 1;
3844],
3845ac_cv_stat_tv_nsec2=yes,
3846ac_cv_stat_tv_nsec2=no,
3847ac_cv_stat_tv_nsec2=no))
3848AC_MSG_RESULT($ac_cv_stat_tv_nsec2)
3849if test "$ac_cv_stat_tv_nsec2" = yes
3850then
3851 AC_DEFINE(HAVE_STAT_TV_NSEC2, 1,
3852 [Define if you have struct stat.st_mtimensec])
3853fi
3854
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00003855# On HP/UX 11.0, mvwdelch is a block with a return statement
3856AC_MSG_CHECKING(whether mvwdelch is an expression)
3857AC_CACHE_VAL(ac_cv_mvwdelch_is_expression,
3858AC_TRY_COMPILE([#include <curses.h>], [
3859 int rtn;
3860 rtn = mvwdelch(0,0,0);
3861], ac_cv_mvwdelch_is_expression=yes,
3862 ac_cv_mvwdelch_is_expression=no,
3863 ac_cv_mvwdelch_is_expression=yes))
3864AC_MSG_RESULT($ac_cv_mvwdelch_is_expression)
3865
3866if test "$ac_cv_mvwdelch_is_expression" = yes
3867then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003868 AC_DEFINE(MVWDELCH_IS_EXPRESSION, 1,
3869 [Define if mvwdelch in curses.h is an expression.])
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00003870fi
3871
3872AC_MSG_CHECKING(whether WINDOW has _flags)
3873AC_CACHE_VAL(ac_cv_window_has_flags,
3874AC_TRY_COMPILE([#include <curses.h>], [
3875 WINDOW *w;
3876 w->_flags = 0;
3877], ac_cv_window_has_flags=yes,
3878 ac_cv_window_has_flags=no,
3879 ac_cv_window_has_flags=no))
3880AC_MSG_RESULT($ac_cv_window_has_flags)
3881
3882
3883if test "$ac_cv_window_has_flags" = yes
3884then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003885 AC_DEFINE(WINDOW_HAS_FLAGS, 1,
3886 [Define if WINDOW in curses.h offers a field _flags.])
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00003887fi
3888
Thomas Wouters0e3f5912006-08-11 14:57:12 +00003889AC_MSG_CHECKING(for is_term_resized)
3890AC_TRY_COMPILE([#include <curses.h>], void *x=is_term_resized,
3891 AC_DEFINE(HAVE_CURSES_IS_TERM_RESIZED, 1, Define if you have the 'is_term_resized' function.)
3892 AC_MSG_RESULT(yes),
Martin v. Löwis24a880b2002-12-31 12:55:15 +00003893 AC_MSG_RESULT(no)
Thomas Wouters0e3f5912006-08-11 14:57:12 +00003894)
Martin v. Löwis24a880b2002-12-31 12:55:15 +00003895
Thomas Wouters0e3f5912006-08-11 14:57:12 +00003896AC_MSG_CHECKING(for resize_term)
3897AC_TRY_COMPILE([#include <curses.h>], void *x=resize_term,
3898 AC_DEFINE(HAVE_CURSES_RESIZE_TERM, 1, Define if you have the 'resize_term' function.)
3899 AC_MSG_RESULT(yes),
Neal Norwitz865400f2003-03-21 01:42:58 +00003900 AC_MSG_RESULT(no)
Thomas Wouters0e3f5912006-08-11 14:57:12 +00003901)
3902
3903AC_MSG_CHECKING(for resizeterm)
3904AC_TRY_COMPILE([#include <curses.h>], void *x=resizeterm,
3905 AC_DEFINE(HAVE_CURSES_RESIZETERM, 1, Define if you have the 'resizeterm' function.)
3906 AC_MSG_RESULT(yes),
3907 AC_MSG_RESULT(no)
3908)
3909
Thomas Wouters89f507f2006-12-13 04:49:30 +00003910AC_MSG_CHECKING(for /dev/ptmx)
3911
3912if test -r /dev/ptmx
3913then
3914 AC_MSG_RESULT(yes)
3915 AC_DEFINE(HAVE_DEV_PTMX, 1,
3916 [Define if we have /dev/ptmx.])
3917else
3918 AC_MSG_RESULT(no)
3919fi
3920
3921AC_MSG_CHECKING(for /dev/ptc)
3922
3923if test -r /dev/ptc
3924then
3925 AC_MSG_RESULT(yes)
3926 AC_DEFINE(HAVE_DEV_PTC, 1,
3927 [Define if we have /dev/ptc.])
3928else
3929 AC_MSG_RESULT(no)
3930fi
Neal Norwitz865400f2003-03-21 01:42:58 +00003931
Thomas Wouters477c8d52006-05-27 19:21:47 +00003932AC_MSG_CHECKING(for %zd printf() format support)
3933AC_TRY_RUN([#include <stdio.h>
3934#include <stddef.h>
3935#include <string.h>
3936
Christian Heimes2c181612007-12-17 20:04:13 +00003937#ifdef HAVE_SYS_TYPES_H
3938#include <sys/types.h>
3939#endif
Thomas Wouters89f507f2006-12-13 04:49:30 +00003940
3941#ifdef HAVE_SSIZE_T
3942typedef ssize_t Py_ssize_t;
3943#elif SIZEOF_VOID_P == SIZEOF_LONG
3944typedef long Py_ssize_t;
3945#else
3946typedef int Py_ssize_t;
3947#endif
Thomas Wouters477c8d52006-05-27 19:21:47 +00003948
Christian Heimes2c181612007-12-17 20:04:13 +00003949int main()
3950{
3951 char buffer[256];
3952
Thomas Wouters477c8d52006-05-27 19:21:47 +00003953 if(sprintf(buffer, "%zd", (size_t)123) < 0)
3954 return 1;
3955
Thomas Wouters89f507f2006-12-13 04:49:30 +00003956 if (strcmp(buffer, "123"))
Thomas Wouters477c8d52006-05-27 19:21:47 +00003957 return 1;
Thomas Wouters89f507f2006-12-13 04:49:30 +00003958
3959 if (sprintf(buffer, "%zd", (Py_ssize_t)-123) < 0)
3960 return 1;
3961
3962 if (strcmp(buffer, "-123"))
3963 return 1;
3964
Thomas Wouters477c8d52006-05-27 19:21:47 +00003965 return 0;
3966}],
3967[AC_MSG_RESULT(yes)
3968 AC_DEFINE(PY_FORMAT_SIZE_T, "z", [Define to printf format modifier for Py_ssize_t])],
3969 AC_MSG_RESULT(no))
3970
Martin v. Löwis01c04012002-11-11 14:58:44 +00003971AC_CHECK_TYPE(socklen_t,,
3972 AC_DEFINE(socklen_t,int,
3973 Define to `int' if <sys/socket.h> does not define.),[
3974#ifdef HAVE_SYS_TYPES_H
3975#include <sys/types.h>
3976#endif
Guido van Rossum95713eb2000-05-18 20:53:31 +00003977#ifdef HAVE_SYS_SOCKET_H
3978#include <sys/socket.h>
3979#endif
Martin v. Löwis01c04012002-11-11 14:58:44 +00003980])
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00003981
Antoine Pitroufff95302008-09-03 18:58:51 +00003982AC_MSG_CHECKING(for broken mbstowcs)
3983AC_TRY_RUN([
3984#include<stdlib.h>
3985int main() {
3986 size_t len = -1;
3987 const char *str = "text";
3988 len = mbstowcs(NULL, str, 0);
3989 return (len != 4);
3990}
3991],
3992ac_cv_broken_mbstowcs=no,
3993ac_cv_broken_mbstowcs=yes,
3994ac_cv_broken_mbstowcs=no)
3995AC_MSG_RESULT($ac_cv_broken_mbstowcs)
3996if test "$ac_cv_broken_mbstowcs" = yes
3997then
3998 AC_DEFINE(HAVE_BROKEN_MBSTOWCS, 1,
3999 [Define if mbstowcs(NULL, "text", 0) does not return the number of
4000 wide chars that would be converted.])
4001fi
4002
Antoine Pitroub52ec782009-01-25 16:34:23 +00004003# Check for --with-computed-gotos
4004AC_MSG_CHECKING(for --with-computed-gotos)
4005AC_ARG_WITH(computed-gotos,
4006 AC_HELP_STRING(--with-computed-gotos,
4007 Use computed gotos / threaded dispatch in evaluation loop (not available on all compilers)),
4008[
4009if test "$withval" != no
4010then
4011 AC_DEFINE(USE_COMPUTED_GOTOS, 1,
4012 [Define if you want to use computed gotos in ceval.c.])
4013 AC_MSG_RESULT(yes)
4014else AC_MSG_RESULT(no)
4015fi],
4016[AC_MSG_RESULT(no)])
4017
Ronald Oussoren1b2cad02009-11-19 17:30:05 +00004018if test $ac_sys_system = Darwin
4019then
4020 LIBS="$LIBS -framework CoreFoundation"
4021fi
4022
4023
Antoine Pitroub52ec782009-01-25 16:34:23 +00004024
Martin v. Löwis06f15bb2001-12-02 13:02:32 +00004025AC_SUBST(THREADHEADERS)
4026
4027for h in `(cd $srcdir;echo Python/thread_*.h)`
4028do
4029 THREADHEADERS="$THREADHEADERS \$(srcdir)/$h"
4030done
4031
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00004032AC_SUBST(SRCDIRS)
Neal Norwitzd24499d2005-12-18 21:36:39 +00004033SRCDIRS="Parser Grammar Objects Python Modules Mac"
Andrew M. Kuchling8abedde2001-01-26 22:55:24 +00004034AC_MSG_CHECKING(for build directories)
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00004035for dir in $SRCDIRS; do
4036 if test ! -d $dir; then
4037 mkdir $dir
Fred Drake884d3ba2000-11-02 17:52:56 +00004038 fi
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00004039done
4040AC_MSG_RESULT(done)
Fred Drake036144d2000-10-26 17:09:35 +00004041
Guido van Rossum627b2d71993-12-24 10:39:16 +00004042# generate output files
Antoine Pitrou20327222009-05-24 20:39:11 +00004043AC_CONFIG_FILES(Makefile.pre Modules/Setup.config Misc/python.pc)
Martin v. Löwis88afe662002-10-26 13:47:44 +00004044AC_OUTPUT
Neil Schemenauer61c51152001-01-26 16:18:16 +00004045
Thomas Wouters49fd7fa2006-04-21 10:40:58 +00004046echo "creating Modules/Setup"
Neil Schemenauer61c51152001-01-26 16:18:16 +00004047if test ! -f Modules/Setup
4048then
4049 cp $srcdir/Modules/Setup.dist Modules/Setup
4050fi
4051
Thomas Wouters49fd7fa2006-04-21 10:40:58 +00004052echo "creating Modules/Setup.local"
Neil Schemenauer61c51152001-01-26 16:18:16 +00004053if test ! -f Modules/Setup.local
4054then
4055 echo "# Edit this file for local setup changes" >Modules/Setup.local
4056fi
4057
4058echo "creating Makefile"
4059$SHELL $srcdir/Modules/makesetup -c $srcdir/Modules/config.c.in \
4060 -s Modules Modules/Setup.config \
Neil Schemenauerf8b71c52001-04-21 17:41:16 +00004061 Modules/Setup.local Modules/Setup
Neil Schemenauer66252162001-02-19 04:47:42 +00004062mv config.c Modules