blob: 5889d68f495ee404ebc984dd256f9cf7db301a0e [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;;
Ronald Oussoren095d2822010-03-08 07:03:14 +0000325 Darwin/1@<:@6789@:>@.*)
326 define_xopen_source=no;;
Trent Mickaf16e8c2004-08-25 23:55:59 +0000327 # On AIX 4 and 5.1, mbstate_t is defined only when _XOPEN_SOURCE == 500 but
328 # used in wcsnrtombs() and mbsnrtowcs() even if _XOPEN_SOURCE is not defined
329 # or has another value. By not (re)defining it, the defaults come in place.
Martin v. Löwisc19c5a62003-11-18 20:00:44 +0000330 AIX/4)
331 define_xopen_source=no;;
Trent Mickaf16e8c2004-08-25 23:55:59 +0000332 AIX/5)
333 if test `uname -r` -eq 1; then
334 define_xopen_source=no
335 fi
336 ;;
Georg Brandlf78e02b2008-06-10 17:40:04 +0000337 # On QNX 6.3.2, defining _XOPEN_SOURCE prevents netdb.h from
338 # defining NI_NUMERICHOST.
339 QNX/6.3.2)
340 define_xopen_source=no
341 ;;
Bob Ippolito7026a0a2005-03-28 23:23:47 +0000342
Martin v. Löwise981a4e2002-11-11 13:26:51 +0000343esac
344
345if test $define_xopen_source = yes
346then
Skip Montanarof0d5f792004-08-15 14:08:23 +0000347 # On Solaris w/ g++ it appears that _XOPEN_SOURCE has to be
348 # defined precisely as g++ defines it
Martin v. Löwis7dece662005-11-26 11:38:24 +0000349 # Furthermore, on Solaris 10, XPG6 requires the use of a C99
350 # compiler
Skip Montanarof0d5f792004-08-15 14:08:23 +0000351 case $ac_sys_system/$ac_sys_release in
Martin v. Löwis7dece662005-11-26 11:38:24 +0000352 SunOS/5.8|SunOS/5.9|SunOS/5.10)
Skip Montanarof0d5f792004-08-15 14:08:23 +0000353 AC_DEFINE(_XOPEN_SOURCE, 500,
354 Define to the level of X/Open that your system supports)
355 ;;
356 *)
357 AC_DEFINE(_XOPEN_SOURCE, 600,
358 Define to the level of X/Open that your system supports)
359 ;;
360 esac
Martin v. Löwis678fc1e2002-11-12 06:04:39 +0000361
362 # On Tru64 Unix 4.0F, defining _XOPEN_SOURCE also requires
363 # definition of _XOPEN_SOURCE_EXTENDED and _POSIX_C_SOURCE, or else
364 # several APIs are not declared. Since this is also needed in some
365 # cases for HP-UX, we define it globally.
Martin v. Löwis7dece662005-11-26 11:38:24 +0000366 # except for Solaris 10, where it must not be defined,
367 # as it implies XPG4.2
368 case $ac_sys_system/$ac_sys_release in
369 SunOS/5.10)
370 ;;
371 *)
372 AC_DEFINE(_XOPEN_SOURCE_EXTENDED, 1,
373 Define to activate Unix95-and-earlier features)
374 ;;
375 esac
Martin v. Löwis678fc1e2002-11-12 06:04:39 +0000376
Bob Ippolito7026a0a2005-03-28 23:23:47 +0000377 AC_DEFINE(_POSIX_C_SOURCE, 200112L, Define to activate features from IEEE Stds 1003.1-2001)
378
Martin v. Löwise981a4e2002-11-11 13:26:51 +0000379fi
380
Guido van Rossum91922671997-10-09 20:24:13 +0000381#
382# SGI compilers allow the specification of the both the ABI and the
383# ISA on the command line. Depending on the values of these switches,
384# different and often incompatable code will be generated.
385#
386# The SGI_ABI variable can be used to modify the CC and LDFLAGS and
387# thus supply support for various ABI/ISA combinations. The MACHDEP
388# variable is also adjusted.
389#
390AC_SUBST(SGI_ABI)
391if test ! -z "$SGI_ABI"
392then
393 CC="cc $SGI_ABI"
394 LDFLAGS="$SGI_ABI $LDFLAGS"
395 MACHDEP=`echo "${MACHDEP}${SGI_ABI}" | sed 's/ *//g'`
396fi
Guido van Rossumb418f891996-07-30 18:06:02 +0000397AC_MSG_RESULT($MACHDEP)
398
Jack Jansen6b08a402004-06-03 12:41:45 +0000399# Record the configure-time value of MACOSX_DEPLOYMENT_TARGET,
400# it may influence the way we can build extensions, so distutils
401# needs to check it
402AC_SUBST(CONFIGURE_MACOSX_DEPLOYMENT_TARGET)
Thomas Wouters477c8d52006-05-27 19:21:47 +0000403AC_SUBST(EXPORT_MACOSX_DEPLOYMENT_TARGET)
Jack Jansen6b08a402004-06-03 12:41:45 +0000404CONFIGURE_MACOSX_DEPLOYMENT_TARGET=
Thomas Wouters477c8d52006-05-27 19:21:47 +0000405EXPORT_MACOSX_DEPLOYMENT_TARGET='#'
Jack Jansen6b08a402004-06-03 12:41:45 +0000406
Mark Dickinsonb0e2b4c2008-04-26 20:48:56 +0000407AC_MSG_CHECKING(machine type as reported by uname -m)
408ac_sys_machine=`uname -m`
409AC_MSG_RESULT($ac_sys_machine)
410
Guido van Rossum627b2d71993-12-24 10:39:16 +0000411# checks for alternative programs
Skip Montanarodecc6a42003-01-01 20:07:49 +0000412
413# compiler flags are generated in two sets, BASECFLAGS and OPT. OPT is just
414# for debug/optimization stuff. BASECFLAGS is for flags that are required
415# just to get things to compile and link. Users are free to override OPT
416# when running configure or make. The build should not break if they do.
417# BASECFLAGS should generally not be messed with, however.
418
419# XXX shouldn't some/most/all of this code be merged with the stuff later
420# on that fiddles with OPT and BASECFLAGS?
Guido van Rossum5739e7e1995-01-20 16:50:53 +0000421AC_MSG_CHECKING(for --without-gcc)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000422AC_ARG_WITH(gcc,
423 AC_HELP_STRING(--without-gcc,never use gcc),
424[
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000425 case $withval in
Benjamin Peterson960cf0f2009-01-09 04:11:44 +0000426 no) CC=${CC:-cc}
Guido van Rossum5739e7e1995-01-20 16:50:53 +0000427 without_gcc=yes;;
428 yes) CC=gcc
429 without_gcc=no;;
430 *) CC=$withval
431 without_gcc=$withval;;
Guido van Rossum55a214e1995-09-13 17:48:09 +0000432 esac], [
Guido van Rossumb418f891996-07-30 18:06:02 +0000433 case $ac_sys_system in
Neil Schemenauerb3531b82001-02-16 04:09:05 +0000434 AIX*) CC=cc_r
435 without_gcc=;;
Martin v. Löwis130fb172001-07-19 11:00:41 +0000436 *) without_gcc=no;;
Guido van Rossum55a214e1995-09-13 17:48:09 +0000437 esac])
Guido van Rossum5739e7e1995-01-20 16:50:53 +0000438AC_MSG_RESULT($without_gcc)
439
Guido van Rossum03ad99f1995-03-09 14:09:54 +0000440# If the user switches compilers, we can't believe the cache
441if test ! -z "$ac_cv_prog_CC" -a ! -z "$CC" -a "$CC" != "$ac_cv_prog_CC"
442then
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000443 AC_MSG_ERROR([cached CC is different -- throw away $cache_file
444(it is also a good idea to do 'make clean' before compiling)])
Guido van Rossum03ad99f1995-03-09 14:09:54 +0000445fi
446
Guido van Rossum627b2d71993-12-24 10:39:16 +0000447AC_PROG_CC
Martin v. Löwis1d5ecb72001-08-09 10:29:44 +0000448
Thomas Wouters49fd7fa2006-04-21 10:40:58 +0000449AC_SUBST(CXX)
450AC_SUBST(MAINCC)
451AC_MSG_CHECKING(for --with-cxx-main=<compiler>)
452AC_ARG_WITH(cxx_main,
453 AC_HELP_STRING([--with-cxx-main=<compiler>],
454 [compile main() and link python executable with C++ compiler]),
455[
456
457 case $withval in
458 no) with_cxx_main=no
459 MAINCC='$(CC)';;
460 yes) with_cxx_main=yes
461 MAINCC='$(CXX)';;
462 *) with_cxx_main=yes
463 MAINCC=$withval
464 if test -z "$CXX"
465 then
466 CXX=$withval
467 fi;;
468 esac], [
469 with_cxx_main=no
470 MAINCC='$(CC)'
471])
472AC_MSG_RESULT($with_cxx_main)
473
474preset_cxx="$CXX"
475if test -z "$CXX"
476then
477 case "$CC" in
478 gcc) AC_PATH_PROG(CXX, [g++], [g++], [notfound]) ;;
479 cc) AC_PATH_PROG(CXX, [c++], [c++], [notfound]) ;;
480 esac
481 if test "$CXX" = "notfound"
482 then
483 CXX=""
484 fi
485fi
486if test -z "$CXX"
487then
488 AC_CHECK_PROGS(CXX, $CCC c++ g++ gcc CC cxx cc++ cl, notfound)
489 if test "$CXX" = "notfound"
490 then
491 CXX=""
492 fi
493fi
494if test "$preset_cxx" != "$CXX"
495then
496 AC_MSG_WARN([
497
498 By default, distutils will build C++ extension modules with "$CXX".
499 If this is not intended, then set CXX on the configure command line.
500 ])
501fi
502
503
Martin v. Löwis1d5ecb72001-08-09 10:29:44 +0000504# checks for UNIX variants that set C preprocessor variables
505AC_AIX
Martin v. Löwis1d5ecb72001-08-09 10:29:44 +0000506
Martin v. Löwis779ffc02002-12-02 22:17:01 +0000507# Check for unsupported systems
508case $ac_sys_system/$ac_sys_release in
Guido van Rossumcd16bf62007-06-13 18:07:49 +0000509atheos*|Linux*/1*)
Martin v. Löwis779ffc02002-12-02 22:17:01 +0000510 echo This system \($ac_sys_system/$ac_sys_release\) is no longer supported.
511 echo See README for details.
512 exit 1;;
513esac
514
Neil Schemenauer55f0cf32001-01-24 17:24:33 +0000515AC_EXEEXT
Neil Schemenauer3ae1d0a2001-01-27 06:54:42 +0000516AC_MSG_CHECKING(for --with-suffix)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000517AC_ARG_WITH(suffix,
518 AC_HELP_STRING(--with-suffix=.exe, set executable suffix),
519[
Neil Schemenauer3ae1d0a2001-01-27 06:54:42 +0000520 case $withval in
521 no) EXEEXT=;;
522 yes) EXEEXT=.exe;;
523 *) EXEEXT=$withval;;
524 esac])
525AC_MSG_RESULT($EXEEXT)
Jack Jansen1999ef42001-12-06 21:47:20 +0000526
Jack Jansen9a66b6d2001-08-08 13:56:14 +0000527# Test whether we're running on a non-case-sensitive system, in which
528# case we give a warning if no ext is given
Jack Jansen1999ef42001-12-06 21:47:20 +0000529AC_SUBST(BUILDEXEEXT)
530AC_MSG_CHECKING(for case-insensitive build directory)
Jack Jansen3c2c4332002-11-06 13:33:32 +0000531if test ! -d CaseSensitiveTestDir; then
532mkdir CaseSensitiveTestDir
533fi
534
535if test -d casesensitivetestdir
Jack Jansen9a66b6d2001-08-08 13:56:14 +0000536then
Jack Jansen1999ef42001-12-06 21:47:20 +0000537 AC_MSG_RESULT(yes)
538 BUILDEXEEXT=.exe
539else
540 AC_MSG_RESULT(no)
Jack Jansendd19cf82001-12-06 22:36:17 +0000541 BUILDEXEEXT=$EXEEXT
Jack Jansen9a66b6d2001-08-08 13:56:14 +0000542fi
Jack Jansen3c2c4332002-11-06 13:33:32 +0000543rmdir CaseSensitiveTestDir
Guido van Rossumfb842551997-08-06 23:42:07 +0000544
Guido van Rossumdd997f71998-10-07 19:58:26 +0000545case $MACHDEP in
546bsdos*)
547 case $CC in
548 gcc) CC="$CC -D_HAVE_BSDI";;
549 esac;;
550esac
551
Guido van Rossum84561611997-08-21 00:08:11 +0000552case $ac_sys_system in
553hp*|HP*)
554 case $CC in
Guido van Rossumcd5ff9f2000-09-22 16:15:54 +0000555 cc|*/cc) CC="$CC -Ae";;
Guido van Rossum84561611997-08-21 00:08:11 +0000556 esac;;
Martin v. Löwise8964d42001-03-06 12:09:07 +0000557SunOS*)
558 # Some functions have a prototype only with that define, e.g. confstr
Martin v. Löwisc45929e2002-04-06 10:10:49 +0000559 AC_DEFINE(__EXTENSIONS__, 1, [Defined on Solaris to see additional function prototypes.])
Martin v. Löwise8964d42001-03-06 12:09:07 +0000560 ;;
Guido van Rossum84561611997-08-21 00:08:11 +0000561esac
562
Martin v. Löwise8964d42001-03-06 12:09:07 +0000563
Neil Schemenauer61c51152001-01-26 16:18:16 +0000564AC_SUBST(LIBRARY)
565AC_MSG_CHECKING(LIBRARY)
566if test -z "$LIBRARY"
567then
568 LIBRARY='libpython$(VERSION).a'
569fi
570AC_MSG_RESULT($LIBRARY)
571
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000572# LDLIBRARY is the name of the library to link against (as opposed to the
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000573# name of the library into which to insert object files). BLDLIBRARY is also
574# the library to link against, usually. On Mac OS X frameworks, BLDLIBRARY
575# is blank as the main program is not linked directly against LDLIBRARY.
576# LDLIBRARYDIR is the path to LDLIBRARY, which is made in a subdirectory. On
577# systems without shared libraries, LDLIBRARY is the same as LIBRARY
578# (defined in the Makefiles). On Cygwin LDLIBRARY is the import library,
579# DLLLIBRARY is the shared (i.e., DLL) library.
580#
Martin v. Löwis1142de32002-03-29 16:28:31 +0000581# RUNSHARED is used to run shared python without installed libraries
582#
583# INSTSONAME is the name of the shared library that will be use to install
584# on the system - some systems like version suffix, others don't
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000585AC_SUBST(LDLIBRARY)
Guido van Rossum27552902001-01-23 01:52:26 +0000586AC_SUBST(DLLLIBRARY)
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000587AC_SUBST(BLDLIBRARY)
588AC_SUBST(LDLIBRARYDIR)
Martin v. Löwis1142de32002-03-29 16:28:31 +0000589AC_SUBST(INSTSONAME)
590AC_SUBST(RUNSHARED)
Neil Schemenauer61c51152001-01-26 16:18:16 +0000591LDLIBRARY="$LIBRARY"
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000592BLDLIBRARY='$(LDLIBRARY)'
Martin v. Löwis09bdf722002-05-08 08:51:29 +0000593INSTSONAME='$(LDLIBRARY)'
Guido van Rossum27552902001-01-23 01:52:26 +0000594DLLLIBRARY=''
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000595LDLIBRARYDIR=''
Martin v. Löwis1142de32002-03-29 16:28:31 +0000596RUNSHARED=''
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000597
Guido van Rossumfb842551997-08-06 23:42:07 +0000598# LINKCC is the command that links the python executable -- default is $(CC).
Martin v. Löwisb7da67a2001-10-18 15:35:38 +0000599# If CXX is set, and if it is needed to link a main function that was
600# compiled with CXX, LINKCC is CXX instead. Always using CXX is undesirable:
601# python might then depend on the C++ runtime
Fred Drake5790be12000-10-09 17:06:13 +0000602# This is altered for AIX in order to build the export list before
Guido van Rossumec95c7b1998-08-04 17:59:56 +0000603# linking.
Guido van Rossumfb842551997-08-06 23:42:07 +0000604AC_SUBST(LINKCC)
605AC_MSG_CHECKING(LINKCC)
606if test -z "$LINKCC"
607then
Thomas Wouters49fd7fa2006-04-21 10:40:58 +0000608 LINKCC='$(PURIFY) $(MAINCC)'
Guido van Rossumfb842551997-08-06 23:42:07 +0000609 case $ac_sys_system in
610 AIX*)
Neal Norwitz0b27ff92003-03-31 15:53:49 +0000611 exp_extra="\"\""
612 if test $ac_sys_release -ge 5 -o \
613 $ac_sys_release -eq 4 -a `uname -r` -ge 2 ; then
614 exp_extra="."
615 fi
616 LINKCC="\$(srcdir)/Modules/makexp_aix Modules/python.exp $exp_extra \$(LIBRARY); $LINKCC";;
Georg Brandlf78e02b2008-06-10 17:40:04 +0000617 QNX*)
618 # qcc must be used because the other compilers do not
619 # support -N.
620 LINKCC=qcc;;
Guido van Rossumfb842551997-08-06 23:42:07 +0000621 esac
622fi
623AC_MSG_RESULT($LINKCC)
624
Tarek Ziadébe720e02009-05-09 11:55:12 +0000625# GNULD is set to "yes" if the GNU linker is used. If this goes wrong
626# make sure we default having it set to "no": this is used by
627# distutils.unixccompiler to know if it should add --enable-new-dtags
628# to linker command lines, and failing to detect GNU ld simply results
629# in the same bahaviour as before.
630AC_SUBST(GNULD)
631AC_MSG_CHECKING(for GNU ld)
632ac_prog=ld
633if test "$GCC" = yes; then
634 ac_prog=`$CC -print-prog-name=ld`
635fi
636case `"$ac_prog" -V 2>&1 < /dev/null` in
637 *GNU*)
638 GNULD=yes;;
639 *)
640 GNULD=no;;
641esac
642AC_MSG_RESULT($GNULD)
643
Martin v. Löwis1142de32002-03-29 16:28:31 +0000644AC_MSG_CHECKING(for --enable-shared)
645AC_ARG_ENABLE(shared,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000646 AC_HELP_STRING(--enable-shared, disable/enable building shared python library))
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000647
Martin v. Löwis1142de32002-03-29 16:28:31 +0000648if test -z "$enable_shared"
649then
Martin v. Löwisb51033d2002-05-03 05:53:15 +0000650 case $ac_sys_system in
Martin v. Löwisf90ae202002-06-11 06:22:31 +0000651 CYGWIN* | atheos*)
Martin v. Löwisb51033d2002-05-03 05:53:15 +0000652 enable_shared="yes";;
653 *)
654 enable_shared="no";;
655 esac
Martin v. Löwis1142de32002-03-29 16:28:31 +0000656fi
657AC_MSG_RESULT($enable_shared)
658
Skip Montanaro56f6a4f2004-06-18 02:47:22 +0000659AC_MSG_CHECKING(for --enable-profiling)
660AC_ARG_ENABLE(profiling,
661 AC_HELP_STRING(--enable-profiling, enable C-level code profiling),
662[ac_save_cc="$CC"
663 CC="$CC -pg"
664 AC_TRY_RUN([int main() { return 0; }],
665 ac_enable_profiling="yes",
666 ac_enable_profiling="no",
667 ac_enable_profiling="no")
668 CC="$ac_save_cc"])
669AC_MSG_RESULT($ac_enable_profiling)
670
671case "$ac_enable_profiling" in
672 "yes")
673 BASECFLAGS="-pg $BASECFLAGS"
674 LDFLAGS="-pg $LDFLAGS"
675 ;;
676esac
Martin v. Löwis1142de32002-03-29 16:28:31 +0000677
678AC_MSG_CHECKING(LDLIBRARY)
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000679
Guido van Rossumb8552162001-09-05 14:58:11 +0000680# MacOSX framework builds need more magic. LDLIBRARY is the dynamic
681# library that we build, but we do not want to link against it (we
682# will find it with a -framework option). For this reason there is an
683# extra variable BLDLIBRARY against which Python and the extension
684# modules are linked, BLDLIBRARY. This is normally the same as
685# LDLIBRARY, but empty for MacOSX framework builds.
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000686if test "$enable_framework"
687then
688 LDLIBRARY='$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansen66b84832003-07-04 12:14:39 +0000689 RUNSHARED=DYLD_FRAMEWORK_PATH="`pwd`:$DYLD_FRAMEWORK_PATH"
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000690 BLDLIBRARY=''
691else
692 BLDLIBRARY='$(LDLIBRARY)'
693fi
694
Martin v. Löwis1142de32002-03-29 16:28:31 +0000695# Other platforms follow
696if test $enable_shared = "yes"; then
Mark Hammond8235ea12002-07-19 06:55:41 +0000697 AC_DEFINE(Py_ENABLE_SHARED, 1, [Defined if Python is built as a shared library.])
Martin v. Löwis1142de32002-03-29 16:28:31 +0000698 case $ac_sys_system in
Martin v. Löwis1142de32002-03-29 16:28:31 +0000699 CYGWIN*)
700 LDLIBRARY='libpython$(VERSION).dll.a'
701 DLLLIBRARY='libpython$(VERSION).dll'
702 ;;
703 SunOS*)
704 LDLIBRARY='libpython$(VERSION).so'
Martin v. Löwisd141a8c2003-06-14 15:20:28 +0000705 BLDLIBRARY='-Wl,-R,$(LIBDIR) -L. -lpython$(VERSION)'
Martin v. Löwisfc9b75f2003-08-09 09:06:52 +0000706 RUNSHARED=LD_LIBRARY_PATH=`pwd`:${LD_LIBRARY_PATH}
Martin v. Löwis2389c412003-10-31 15:42:07 +0000707 INSTSONAME="$LDLIBRARY".$SOVERSION
Martin v. Löwis1142de32002-03-29 16:28:31 +0000708 ;;
Martin v. Löwis86d66262006-02-17 08:40:11 +0000709 Linux*|GNU*|NetBSD*|FreeBSD*|DragonFly*)
Martin v. Löwis1142de32002-03-29 16:28:31 +0000710 LDLIBRARY='libpython$(VERSION).so'
711 BLDLIBRARY='-L. -lpython$(VERSION)'
Martin v. Löwisfc9b75f2003-08-09 09:06:52 +0000712 RUNSHARED=LD_LIBRARY_PATH=`pwd`:${LD_LIBRARY_PATH}
Hye-Shik Chang33761492004-10-26 09:53:46 +0000713 case $ac_sys_system in
714 FreeBSD*)
715 SOVERSION=`echo $SOVERSION|cut -d "." -f 1`
716 ;;
717 esac
Martin v. Löwis1142de32002-03-29 16:28:31 +0000718 INSTSONAME="$LDLIBRARY".$SOVERSION
719 ;;
720 hp*|HP*)
Thomas Wouters477c8d52006-05-27 19:21:47 +0000721 case `uname -m` in
722 ia64)
723 LDLIBRARY='libpython$(VERSION).so'
724 ;;
725 *)
726 LDLIBRARY='libpython$(VERSION).sl'
727 ;;
728 esac
Martin v. Löwis1142de32002-03-29 16:28:31 +0000729 BLDLIBRARY='-Wl,+b,$(LIBDIR) -L. -lpython$(VERSION)'
Martin v. Löwisfc9b75f2003-08-09 09:06:52 +0000730 RUNSHARED=SHLIB_PATH=`pwd`:${SHLIB_PATH}
Martin v. Löwis1142de32002-03-29 16:28:31 +0000731 ;;
732 OSF*)
733 LDLIBRARY='libpython$(VERSION).so'
Neal Norwitz671b9e32006-01-09 07:07:12 +0000734 BLDLIBRARY='-rpath $(LIBDIR) -L. -lpython$(VERSION)'
Martin v. Löwisfc9b75f2003-08-09 09:06:52 +0000735 RUNSHARED=LD_LIBRARY_PATH=`pwd`:${LD_LIBRARY_PATH}
Martin v. Löwis1142de32002-03-29 16:28:31 +0000736 ;;
Martin v. Löwisf90ae202002-06-11 06:22:31 +0000737 atheos*)
738 LDLIBRARY='libpython$(VERSION).so'
739 BLDLIBRARY='-L. -lpython$(VERSION)'
740 RUNSHARED=DLL_PATH=`pwd`:${DLL_PATH:-/atheos/sys/libs:/atheos/autolnk/lib}
741 ;;
Georg Brandlb1441c72009-01-03 22:33:39 +0000742 Darwin*)
743 LDLIBRARY='libpython$(VERSION).dylib'
744 BLDLIBRARY='-L. -lpython$(VERSION)'
745 RUNSHARED='DYLD_LIBRARY_PATH=`pwd`:${DYLD_LIBRARY_PATH}'
746 ;;
747
Martin v. Löwis1142de32002-03-29 16:28:31 +0000748 esac
Jason Tishler30765592003-09-04 11:04:06 +0000749else # shared is disabled
750 case $ac_sys_system in
751 CYGWIN*)
752 BLDLIBRARY='$(LIBRARY)'
753 LDLIBRARY='libpython$(VERSION).dll.a'
754 ;;
755 esac
Martin v. Löwis1142de32002-03-29 16:28:31 +0000756fi
757
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000758AC_MSG_RESULT($LDLIBRARY)
759
Guido van Rossum627b2d71993-12-24 10:39:16 +0000760AC_PROG_RANLIB
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000761AC_SUBST(AR)
Guido van Rossum76be6ed1995-01-02 18:33:54 +0000762AC_CHECK_PROGS(AR, ar aal, ar)
Neil Schemenauera42c8272001-03-31 00:01:55 +0000763
Tarek Ziadé5662d3e2009-05-07 21:24:43 +0000764# tweak ARFLAGS only if the user didn't set it on the command line
765AC_SUBST(ARFLAGS)
766if test -z "$ARFLAGS"
767then
768 ARFLAGS="rc"
769fi
770
Martin v. Löwisdea59e52006-01-05 10:00:36 +0000771AC_SUBST(SVNVERSION)
Thomas Wouters49fd7fa2006-04-21 10:40:58 +0000772AC_CHECK_PROG(SVNVERSION, svnversion, found, not-found)
Martin v. Löwisc5bf5a02006-01-05 10:33:59 +0000773if test $SVNVERSION = found
774then
775 SVNVERSION="svnversion \$(srcdir)"
776else
Benjamin Petersonf53eec82009-05-23 19:36:27 +0000777 SVNVERSION="echo Unversioned directory"
Martin v. Löwisc5bf5a02006-01-05 10:33:59 +0000778fi
Martin v. Löwisdea59e52006-01-05 10:00:36 +0000779
Neil Schemenauera42c8272001-03-31 00:01:55 +0000780case $MACHDEP in
Neil Schemenaueraf5567f2001-10-21 22:32:04 +0000781bsdos*|hp*|HP*)
782 # install -d does not work on BSDI or HP-UX
Neil Schemenauera42c8272001-03-31 00:01:55 +0000783 if test -z "$INSTALL"
784 then
785 INSTALL="${srcdir}/install-sh -c"
786 fi
787esac
Neil Schemenauer55f0cf32001-01-24 17:24:33 +0000788AC_PROG_INSTALL
Guido van Rossumb418f891996-07-30 18:06:02 +0000789
Guido van Rossumec95c7b1998-08-04 17:59:56 +0000790# Not every filesystem supports hard links
791AC_SUBST(LN)
792if test -z "$LN" ; then
793 case $ac_sys_system in
Guido van Rossumaef734b2001-01-10 21:09:12 +0000794 CYGWIN*) LN="ln -s";;
Martin v. Löwisf90ae202002-06-11 06:22:31 +0000795 atheos*) LN="ln -s";;
Guido van Rossumec95c7b1998-08-04 17:59:56 +0000796 *) LN=ln;;
797 esac
798fi
799
Fred Drake9f715822001-07-11 06:27:00 +0000800# Check for --with-pydebug
801AC_MSG_CHECKING(for --with-pydebug)
802AC_ARG_WITH(pydebug,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000803 AC_HELP_STRING(--with-pydebug, build with Py_DEBUG defined),
804[
Fred Drake9f715822001-07-11 06:27:00 +0000805if test "$withval" != no
Martin v. Löwisc45929e2002-04-06 10:10:49 +0000806then
807 AC_DEFINE(Py_DEBUG, 1,
808 [Define if you want to build an interpreter with many run-time checks.])
809 AC_MSG_RESULT(yes);
810 Py_DEBUG='true'
Fred Drake9f715822001-07-11 06:27:00 +0000811else AC_MSG_RESULT(no); Py_DEBUG='false'
812fi],
813[AC_MSG_RESULT(no)])
814
Skip Montanarodecc6a42003-01-01 20:07:49 +0000815# XXX Shouldn't the code above that fiddles with BASECFLAGS and OPT be
816# merged with this chunk of code?
817
Neil Schemenauer55f0cf32001-01-24 17:24:33 +0000818# Optimizer/debugger flags
Skip Montanarodecc6a42003-01-01 20:07:49 +0000819# ------------------------
820# (The following bit of code is complicated enough - please keep things
821# indented properly. Just pretend you're editing Python code. ;-)
822
823# There are two parallel sets of case statements below, one that checks to
824# see if OPT was set and one that does BASECFLAGS setting based upon
825# compiler and platform. BASECFLAGS tweaks need to be made even if the
826# user set OPT.
827
828# tweak OPT based on compiler and platform, only if the user didn't set
829# it on the command line
Guido van Rossumb418f891996-07-30 18:06:02 +0000830AC_SUBST(OPT)
Guido van Rossum4e8af441994-08-19 15:33:54 +0000831if test -z "$OPT"
Guido van Rossumb418f891996-07-30 18:06:02 +0000832then
Skip Montanarodecc6a42003-01-01 20:07:49 +0000833 case $GCC in
834 yes)
Thomas Wouters49fd7fa2006-04-21 10:40:58 +0000835 if test "$CC" != 'g++' ; then
836 STRICT_PROTO="-Wstrict-prototypes"
837 fi
Christian Heimes38053212007-12-14 01:24:44 +0000838 # For gcc 4.x we need to use -fwrapv so lets check if its supported
839 if "$CC" -v --help 2>/dev/null |grep -- -fwrapv > /dev/null; then
840 WRAP="-fwrapv"
841 fi
Skip Montanarodecc6a42003-01-01 20:07:49 +0000842 case $ac_cv_prog_cc_g in
Guido van Rossum2242f2f2001-04-11 20:58:20 +0000843 yes)
Fred Drake9f715822001-07-11 06:27:00 +0000844 if test "$Py_DEBUG" = 'true' ; then
845 # Optimization messes up debuggers, so turn it off for
846 # debug builds.
Thomas Wouters49fd7fa2006-04-21 10:40:58 +0000847 OPT="-g -Wall $STRICT_PROTO"
Fred Drake9f715822001-07-11 06:27:00 +0000848 else
Christian Heimes38053212007-12-14 01:24:44 +0000849 OPT="-g $WRAP -O3 -Wall $STRICT_PROTO"
Skip Montanarodecc6a42003-01-01 20:07:49 +0000850 fi
851 ;;
Guido van Rossum2242f2f2001-04-11 20:58:20 +0000852 *)
Thomas Wouters49fd7fa2006-04-21 10:40:58 +0000853 OPT="-O3 -Wall $STRICT_PROTO"
Skip Montanarodecc6a42003-01-01 20:07:49 +0000854 ;;
Fred Drake9f715822001-07-11 06:27:00 +0000855 esac
Martin v. Löwis21ee4092002-09-30 16:19:48 +0000856 case $ac_sys_system in
Skip Montanarodecc6a42003-01-01 20:07:49 +0000857 SCO_SV*) OPT="$OPT -m486 -DSCO5"
858 ;;
859 esac
Fred Drake9f715822001-07-11 06:27:00 +0000860 ;;
Skip Montanarodecc6a42003-01-01 20:07:49 +0000861
Guido van Rossum2242f2f2001-04-11 20:58:20 +0000862 *)
Skip Montanarodecc6a42003-01-01 20:07:49 +0000863 OPT="-O"
864 ;;
Guido van Rossum2242f2f2001-04-11 20:58:20 +0000865 esac
Guido van Rossum4e8af441994-08-19 15:33:54 +0000866fi
Guido van Rossum627b2d71993-12-24 10:39:16 +0000867
Skip Montanarodecc6a42003-01-01 20:07:49 +0000868AC_SUBST(BASECFLAGS)
Georg Brandlfcaf9102008-07-16 02:17:56 +0000869
870# The -arch flags for universal builds on OSX
871UNIVERSAL_ARCH_FLAGS=
872AC_SUBST(UNIVERSAL_ARCH_FLAGS)
873
Skip Montanarodecc6a42003-01-01 20:07:49 +0000874# tweak BASECFLAGS based on compiler and platform
875case $GCC in
876yes)
Martin v. Löwis70fedcd2003-07-07 21:26:19 +0000877 # Python violates C99 rules, by casting between incompatible
878 # pointer types. GCC may generate bad code as a result of that,
879 # so use -fno-strict-aliasing if supported.
880 AC_MSG_CHECKING(whether $CC accepts -fno-strict-aliasing)
881 ac_save_cc="$CC"
882 CC="$CC -fno-strict-aliasing"
883 AC_TRY_RUN([int main() { return 0; }],
884 ac_cv_no_strict_aliasing_ok=yes,
885 ac_cv_no_strict_aliasing_ok=no,
886 ac_cv_no_strict_aliasing_ok=no)
887 CC="$ac_save_cc"
888 AC_MSG_RESULT($ac_cv_no_strict_aliasing_ok)
889 if test $ac_cv_no_strict_aliasing_ok = yes
890 then
891 BASECFLAGS="$BASECFLAGS -fno-strict-aliasing"
892 fi
Mark Dickinsonb0e2b4c2008-04-26 20:48:56 +0000893
894 # if using gcc on alpha, use -mieee to get (near) full IEEE 754
895 # support. Without this, treatment of subnormals doesn't follow
896 # the standard.
897 case $ac_sys_machine in
898 alpha*)
899 BASECFLAGS="$BASECFLAGS -mieee"
900 ;;
901 esac
902
Skip Montanarodecc6a42003-01-01 20:07:49 +0000903 case $ac_sys_system in
904 SCO_SV*)
905 BASECFLAGS="$BASECFLAGS -m486 -DSCO5"
906 ;;
907 # is there any other compiler on Darwin besides gcc?
908 Darwin*)
Christian Heimesb186d002008-03-18 15:15:01 +0000909 # -Wno-long-double, -no-cpp-precomp, and -mno-fused-madd
910 # used to be here, but non-Apple gcc doesn't accept them.
Benjamin Peterson67c38e22008-07-17 16:10:34 +0000911
912
Thomas Wouters477c8d52006-05-27 19:21:47 +0000913 if test "${enable_universalsdk}"; then
Georg Brandlfcaf9102008-07-16 02:17:56 +0000914 UNIVERSAL_ARCH_FLAGS=""
915 if test "$UNIVERSAL_ARCHS" = "32-bit" ; then
916 UNIVERSAL_ARCH_FLAGS="-arch ppc -arch i386"
Benjamin Peterson6794aa32008-07-16 20:33:37 +0000917 ARCH_RUN_32BIT=""
Georg Brandlfcaf9102008-07-16 02:17:56 +0000918
919 elif test "$UNIVERSAL_ARCHS" = "64-bit" ; then
920 UNIVERSAL_ARCH_FLAGS="-arch ppc64 -arch x86_64"
Ronald Oussorend45ff2c2009-09-06 11:11:04 +0000921 ARCH_RUN_32BIT="true"
Georg Brandlfcaf9102008-07-16 02:17:56 +0000922
923 elif test "$UNIVERSAL_ARCHS" = "all" ; then
924 UNIVERSAL_ARCH_FLAGS="-arch i386 -arch ppc -arch ppc64 -arch x86_64"
Ronald Oussorenc8c89c42010-02-11 13:24:45 +0000925 ARCH_RUN_32BIT="/usr/bin/arch -i386 -ppc"
Georg Brandlfcaf9102008-07-16 02:17:56 +0000926
Ronald Oussoren856624d2009-09-08 07:13:53 +0000927 elif test "$UNIVERSAL_ARCHS" = "intel" ; then
928 UNIVERSAL_ARCH_FLAGS="-arch i386 -arch x86_64"
Ronald Oussorenc8c89c42010-02-11 13:24:45 +0000929 ARCH_RUN_32BIT="/usr/bin/arch -i386"
Ronald Oussoren856624d2009-09-08 07:13:53 +0000930
931 elif test "$UNIVERSAL_ARCHS" = "3-way" ; then
932 UNIVERSAL_ARCH_FLAGS="-arch i386 -arch ppc -arch x86_64"
Ronald Oussorenc8c89c42010-02-11 13:24:45 +0000933 ARCH_RUN_32BIT="/usr/bin/arch -i386 -ppc"
Ronald Oussoren856624d2009-09-08 07:13:53 +0000934
Georg Brandlfcaf9102008-07-16 02:17:56 +0000935 else
Ronald Oussoren5644eb72009-09-20 20:10:02 +0000936 AC_MSG_ERROR([proper usage is --with-universal-arch=32-bit|64-bit|all|intel|3-way])
Georg Brandlfcaf9102008-07-16 02:17:56 +0000937
938 fi
939
940
941 BASECFLAGS="${UNIVERSAL_ARCH_FLAGS} -isysroot ${UNIVERSALSDK} ${BASECFLAGS}"
Georg Brandl3dbca812008-07-23 16:10:53 +0000942 tgt=`sw_vers -productVersion | sed 's/\(10\.[[0-9]]*\).*/\1/'`
Benjamin Peterson67c38e22008-07-17 16:10:34 +0000943 if test "${UNIVERSALSDK}" != "/" -a "${tgt}" '>' '10.4' ; then
944 CFLAGS="${UNIVERSAL_ARCH_FLAGS} -isysroot ${UNIVERSALSDK} ${CFLAGS}"
945 fi
Thomas Wouters477c8d52006-05-27 19:21:47 +0000946 fi
947
Benjamin Peterson67c38e22008-07-17 16:10:34 +0000948 # Calculate the right deployment target for this build.
949 #
950 cur_target=`sw_vers -productVersion | sed 's/\(10\.[[0-9]]*\).*/\1/'`
951 if test ${cur_target} '>' 10.2; then
952 cur_target=10.3
Ronald Oussorend45ff2c2009-09-06 11:11:04 +0000953 if test ${enable_universalsdk}; then
954 if test "${UNIVERSAL_ARCHS}" = "all"; then
955 # Ensure that the default platform for a
956 # 4-way universal build is OSX 10.5,
957 # that's the first OS release where
958 # 4-way builds make sense.
959 cur_target='10.5'
Ronald Oussoren856624d2009-09-08 07:13:53 +0000960
961 elif test "${UNIVERSAL_ARCHS}" = "3-way"; then
962 cur_target='10.5'
963
964 elif test "${UNIVERSAL_ARCHS}" = "intel"; then
965 cur_target='10.5'
966
967 elif test "${UNIVERSAL_ARCHS}" = "64-bit"; then
968 cur_target='10.5'
Ronald Oussorend45ff2c2009-09-06 11:11:04 +0000969 fi
970 else
Ronald Oussoren175a8842010-02-11 13:40:06 +0000971 if test `/usr/bin/arch` = "i386"; then
Ronald Oussorend45ff2c2009-09-06 11:11:04 +0000972 # On Intel macs default to a deployment
973 # target of 10.4, that's the first OSX
974 # release with Intel support.
975 cur_target="10.4"
976 fi
977 fi
Benjamin Peterson67c38e22008-07-17 16:10:34 +0000978 fi
979 CONFIGURE_MACOSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET-${cur_target}}
980
981 # Make sure that MACOSX_DEPLOYMENT_TARGET is set in the
982 # environment with a value that is the same as what we'll use
983 # in the Makefile to ensure that we'll get the same compiler
984 # environment during configure and build time.
985 MACOSX_DEPLOYMENT_TARGET="$CONFIGURE_MACOSX_DEPLOYMENT_TARGET"
986 export MACOSX_DEPLOYMENT_TARGET
987 EXPORT_MACOSX_DEPLOYMENT_TARGET=''
988
Skip Montanarodecc6a42003-01-01 20:07:49 +0000989 ;;
Thomas Wouters49fd7fa2006-04-21 10:40:58 +0000990 OSF*)
991 BASECFLAGS="$BASECFLAGS -mieee"
992 ;;
Skip Montanarodecc6a42003-01-01 20:07:49 +0000993 esac
994 ;;
995
996*)
997 case $ac_sys_system in
998 OpenUNIX*|UnixWare*)
999 BASECFLAGS="$BASECFLAGS -K pentium,host,inline,loop_unroll,alloca "
1000 ;;
Neal Norwitzb44f1652003-05-26 14:11:55 +00001001 OSF*)
1002 BASECFLAGS="$BASECFLAGS -ieee -std"
1003 ;;
Skip Montanarodecc6a42003-01-01 20:07:49 +00001004 SCO_SV*)
1005 BASECFLAGS="$BASECFLAGS -belf -Ki486 -DSCO5"
1006 ;;
1007 esac
1008 ;;
1009esac
1010
Fred Drakee1ceaa02001-12-04 20:55:47 +00001011if test "$Py_DEBUG" = 'true'; then
1012 :
1013else
1014 OPT="-DNDEBUG $OPT"
1015fi
1016
Guido van Rossum6f2260e1996-09-09 16:21:03 +00001017if test "$ac_arch_flags"
Guido van Rossumc5a39031996-07-31 17:35:03 +00001018then
Skip Montanarodecc6a42003-01-01 20:07:49 +00001019 BASECFLAGS="$BASECFLAGS $ac_arch_flags"
Guido van Rossumc5a39031996-07-31 17:35:03 +00001020fi
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001021
Neal Norwitz020c46a2006-01-07 21:39:28 +00001022# disable check for icc since it seems to pass, but generates a warning
1023if test "$CC" = icc
1024then
1025 ac_cv_opt_olimit_ok=no
1026fi
1027
Guido van Rossum91922671997-10-09 20:24:13 +00001028AC_MSG_CHECKING(whether $CC accepts -OPT:Olimit=0)
1029AC_CACHE_VAL(ac_cv_opt_olimit_ok,
1030[ac_save_cc="$CC"
1031CC="$CC -OPT:Olimit=0"
1032AC_TRY_RUN([int main() { return 0; }],
1033 ac_cv_opt_olimit_ok=yes,
Guido van Rossum3065c942001-09-17 04:03:14 +00001034 ac_cv_opt_olimit_ok=no,
Guido van Rossum91922671997-10-09 20:24:13 +00001035 ac_cv_opt_olimit_ok=no)
1036CC="$ac_save_cc"])
1037AC_MSG_RESULT($ac_cv_opt_olimit_ok)
Guido van Rossum2efa34b1997-10-23 17:43:11 +00001038if test $ac_cv_opt_olimit_ok = yes; then
Guido van Rossum5839e582000-10-09 19:52:35 +00001039 case $ac_sys_system in
Skip Montanarodecc6a42003-01-01 20:07:49 +00001040 # XXX is this branch needed? On MacOSX 10.2.2 the result of the
1041 # olimit_ok test is "no". Is it "yes" in some other Darwin-esque
1042 # environment?
1043 Darwin*)
1044 ;;
1045 *)
1046 BASECFLAGS="$BASECFLAGS -OPT:Olimit=0"
1047 ;;
Guido van Rossum5839e582000-10-09 19:52:35 +00001048 esac
Guido van Rossumf8678121998-07-07 21:05:09 +00001049else
1050 AC_MSG_CHECKING(whether $CC accepts -Olimit 1500)
1051 AC_CACHE_VAL(ac_cv_olimit_ok,
1052 [ac_save_cc="$CC"
1053 CC="$CC -Olimit 1500"
1054 AC_TRY_RUN([int main() { return 0; }],
1055 ac_cv_olimit_ok=yes,
Guido van Rossum3065c942001-09-17 04:03:14 +00001056 ac_cv_olimit_ok=no,
Guido van Rossumf8678121998-07-07 21:05:09 +00001057 ac_cv_olimit_ok=no)
1058 CC="$ac_save_cc"])
1059 AC_MSG_RESULT($ac_cv_olimit_ok)
1060 if test $ac_cv_olimit_ok = yes; then
Skip Montanarodecc6a42003-01-01 20:07:49 +00001061 BASECFLAGS="$BASECFLAGS -Olimit 1500"
Guido van Rossumf8678121998-07-07 21:05:09 +00001062 fi
Guido van Rossum201afe51997-05-14 21:14:44 +00001063fi
Guido van Rossumf8678121998-07-07 21:05:09 +00001064
Thomas Wouters89f507f2006-12-13 04:49:30 +00001065# Check whether GCC supports PyArg_ParseTuple format
1066if test "$GCC" = "yes"
1067then
1068 AC_MSG_CHECKING(whether gcc supports ParseTuple __format__)
1069 save_CFLAGS=$CFLAGS
1070 CFLAGS="$CFLAGS -Werror"
1071 AC_TRY_COMPILE([
1072 void f(char*,...)__attribute((format(PyArg_ParseTuple, 1, 2)));
1073 ],,
1074 AC_DEFINE(HAVE_ATTRIBUTE_FORMAT_PARSETUPLE, 1, [Define if GCC supports __attribute__((format(PyArg_ParseTuple, 2, 3)))])
1075 AC_MSG_RESULT(yes),
1076 AC_MSG_RESULT(no)
1077 )
1078 CFLAGS=$save_CFLAGS
1079fi
1080
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00001081# On some compilers, pthreads are available without further options
1082# (e.g. MacOS X). On some of these systems, the compiler will not
1083# complain if unaccepted options are passed (e.g. gcc on Mac OS X).
1084# So we have to see first whether pthreads are available without
1085# options before we can check whether -Kpthread improves anything.
1086AC_MSG_CHECKING(whether pthreads are available without options)
1087AC_CACHE_VAL(ac_cv_pthread_is_default,
1088[AC_TRY_RUN([
1089#include <pthread.h>
1090
1091void* routine(void* p){return NULL;}
1092
1093int main(){
1094 pthread_t p;
1095 if(pthread_create(&p,NULL,routine,NULL)!=0)
1096 return 1;
Jack Jansen4f8d0542002-03-08 13:43:01 +00001097 (void)pthread_detach(p);
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00001098 return 0;
1099}
1100],
Skip Montanarod8d39a02003-07-10 20:44:10 +00001101[
1102 ac_cv_pthread_is_default=yes
1103 ac_cv_kthread=no
1104 ac_cv_pthread=no
1105],
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00001106 ac_cv_pthread_is_default=no,
1107 ac_cv_pthread_is_default=no)
1108])
1109AC_MSG_RESULT($ac_cv_pthread_is_default)
1110
1111
1112if test $ac_cv_pthread_is_default = yes
1113then
1114 ac_cv_kpthread=no
1115else
Martin v. Löwis130fb172001-07-19 11:00:41 +00001116# -Kpthread, if available, provides the right #defines
1117# and linker options to make pthread_create available
Martin v. Löwis260aecc2001-10-07 08:14:41 +00001118# Some compilers won't report that they do not support -Kpthread,
1119# so we need to run a program to see whether it really made the
1120# function available.
Martin v. Löwis130fb172001-07-19 11:00:41 +00001121AC_MSG_CHECKING(whether $CC accepts -Kpthread)
1122AC_CACHE_VAL(ac_cv_kpthread,
1123[ac_save_cc="$CC"
1124CC="$CC -Kpthread"
Martin v. Löwis260aecc2001-10-07 08:14:41 +00001125AC_TRY_RUN([
1126#include <pthread.h>
1127
1128void* routine(void* p){return NULL;}
1129
1130int main(){
1131 pthread_t p;
1132 if(pthread_create(&p,NULL,routine,NULL)!=0)
1133 return 1;
Jack Jansen4f8d0542002-03-08 13:43:01 +00001134 (void)pthread_detach(p);
Martin v. Löwis260aecc2001-10-07 08:14:41 +00001135 return 0;
1136}
1137],
Martin v. Löwis130fb172001-07-19 11:00:41 +00001138 ac_cv_kpthread=yes,
Martin v. Löwis260aecc2001-10-07 08:14:41 +00001139 ac_cv_kpthread=no,
Martin v. Löwis130fb172001-07-19 11:00:41 +00001140 ac_cv_kpthread=no)
1141CC="$ac_save_cc"])
Martin v. Löwis130fb172001-07-19 11:00:41 +00001142AC_MSG_RESULT($ac_cv_kpthread)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00001143fi
Martin v. Löwis130fb172001-07-19 11:00:41 +00001144
Skip Montanarod8d39a02003-07-10 20:44:10 +00001145if test $ac_cv_kpthread = no -a $ac_cv_pthread_is_default = no
Martin v. Löwis5f433f02003-05-05 05:05:30 +00001146then
1147# -Kthread, if available, provides the right #defines
1148# and linker options to make pthread_create available
1149# Some compilers won't report that they do not support -Kthread,
1150# so we need to run a program to see whether it really made the
1151# function available.
1152AC_MSG_CHECKING(whether $CC accepts -Kthread)
1153AC_CACHE_VAL(ac_cv_kthread,
1154[ac_save_cc="$CC"
1155CC="$CC -Kthread"
1156AC_TRY_RUN([
1157#include <pthread.h>
1158
1159void* routine(void* p){return NULL;}
1160
1161int main(){
1162 pthread_t p;
1163 if(pthread_create(&p,NULL,routine,NULL)!=0)
1164 return 1;
1165 (void)pthread_detach(p);
1166 return 0;
1167}
1168],
1169 ac_cv_kthread=yes,
1170 ac_cv_kthread=no,
1171 ac_cv_kthread=no)
1172CC="$ac_save_cc"])
1173AC_MSG_RESULT($ac_cv_kthread)
1174fi
1175
Skip Montanarod8d39a02003-07-10 20:44:10 +00001176if test $ac_cv_kthread = no -a $ac_cv_pthread_is_default = no
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00001177then
1178# -pthread, if available, provides the right #defines
1179# and linker options to make pthread_create available
1180# Some compilers won't report that they do not support -pthread,
1181# so we need to run a program to see whether it really made the
1182# function available.
1183AC_MSG_CHECKING(whether $CC accepts -pthread)
1184AC_CACHE_VAL(ac_cv_thread,
1185[ac_save_cc="$CC"
1186CC="$CC -pthread"
1187AC_TRY_RUN([
1188#include <pthread.h>
1189
1190void* routine(void* p){return NULL;}
1191
1192int main(){
1193 pthread_t p;
1194 if(pthread_create(&p,NULL,routine,NULL)!=0)
1195 return 1;
1196 (void)pthread_detach(p);
1197 return 0;
1198}
1199],
1200 ac_cv_pthread=yes,
1201 ac_cv_pthread=no,
1202 ac_cv_pthread=no)
1203CC="$ac_save_cc"])
1204AC_MSG_RESULT($ac_cv_pthread)
1205fi
1206
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001207# If we have set a CC compiler flag for thread support then
1208# check if it works for CXX, too.
1209ac_cv_cxx_thread=no
1210if test ! -z "$CXX"
1211then
1212AC_MSG_CHECKING(whether $CXX also accepts flags for thread support)
1213ac_save_cxx="$CXX"
1214
1215if test "$ac_cv_kpthread" = "yes"
1216then
Martin v. Löwis519adae2003-09-20 10:47:47 +00001217 CXX="$CXX -Kpthread"
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001218 ac_cv_cxx_thread=yes
1219elif test "$ac_cv_kthread" = "yes"
1220then
1221 CXX="$CXX -Kthread"
1222 ac_cv_cxx_thread=yes
1223elif test "$ac_cv_pthread" = "yes"
1224then
1225 CXX="$CXX -pthread"
1226 ac_cv_cxx_thread=yes
1227fi
1228
1229if test $ac_cv_cxx_thread = yes
1230then
1231 echo 'void foo();int main(){foo();}void foo(){}' > conftest.$ac_ext
1232 $CXX -c conftest.$ac_ext 2>&5
1233 if $CXX -o conftest$ac_exeext conftest.$ac_objext 2>&5 \
1234 && test -s conftest$ac_exeext && ./conftest$ac_exeext
1235 then
1236 ac_cv_cxx_thread=yes
1237 else
1238 ac_cv_cxx_thread=no
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001239 fi
1240 rm -fr conftest*
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001241fi
Brett Cannonc601e0f2004-11-07 01:24:12 +00001242AC_MSG_RESULT($ac_cv_cxx_thread)
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001243fi
Martin v. Löwis519adae2003-09-20 10:47:47 +00001244CXX="$ac_save_cxx"
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001245
Fred Drakece81d592000-07-09 14:39:29 +00001246dnl # check for ANSI or K&R ("traditional") preprocessor
1247dnl AC_MSG_CHECKING(for C preprocessor type)
1248dnl AC_TRY_COMPILE([
1249dnl #define spam(name, doc) {#name, &name, #name "() -- " doc}
1250dnl int foo;
1251dnl struct {char *name; int *addr; char *doc;} desc = spam(foo, "something");
1252dnl ], [;], cpp_type=ansi, AC_DEFINE(HAVE_OLD_CPP) cpp_type=traditional)
1253dnl AC_MSG_RESULT($cpp_type)
Guido van Rossum300fda71996-08-19 21:58:16 +00001254
Guido van Rossum627b2d71993-12-24 10:39:16 +00001255# checks for header files
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001256AC_HEADER_STDC
Thomas Wouters0e3f5912006-08-11 14:57:12 +00001257AC_CHECK_HEADERS(asm/types.h conio.h curses.h direct.h dlfcn.h errno.h \
1258fcntl.h grp.h \
Christian Heimesbbe741d2008-03-28 10:53:29 +00001259ieeefp.h io.h langinfo.h libintl.h ncurses.h poll.h process.h pthread.h \
Thomas Wouters89f507f2006-12-13 04:49:30 +00001260shadow.h signal.h stdint.h stropts.h termios.h thread.h \
Martin v. Löwis14e73b12003-01-01 09:51:12 +00001261unistd.h utime.h \
Christian Heimes4fbc72b2008-03-22 00:47:35 +00001262sys/audioio.h sys/bsdtty.h sys/epoll.h sys/event.h sys/file.h sys/loadavg.h \
1263sys/lock.h sys/mkdev.h sys/modem.h \
Thomas Wouters0e3f5912006-08-11 14:57:12 +00001264sys/param.h sys/poll.h sys/select.h sys/socket.h sys/statvfs.h sys/stat.h \
Georg Brandlf78e02b2008-06-10 17:40:04 +00001265sys/termio.h sys/time.h \
Thomas Wouters0e3f5912006-08-11 14:57:12 +00001266sys/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 +00001267sys/resource.h netpacket/packet.h sysexits.h bluetooth.h \
Christian Heimes043d6f62008-01-07 17:19:16 +00001268bluetooth/bluetooth.h linux/tipc.h)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001269AC_HEADER_DIRENT
Martin v. Löwisdbe3f762002-10-10 14:27:30 +00001270AC_HEADER_MAJOR
Guido van Rossum627b2d71993-12-24 10:39:16 +00001271
Martin v. Löwisae2830c2004-09-18 09:54:52 +00001272# On Solaris, term.h requires curses.h
Martin v. Löwisfd1c69e72004-11-30 22:09:37 +00001273AC_CHECK_HEADERS(term.h,,,[
Martin v. Löwis5d52e782004-09-18 10:07:03 +00001274#ifdef HAVE_CURSES_H
1275#include <curses.h>
1276#endif
1277])
Martin v. Löwisae2830c2004-09-18 09:54:52 +00001278
Martin v. Löwis11017b12006-01-14 18:12:57 +00001279# On Linux, netlink.h requires asm/types.h
1280AC_CHECK_HEADERS(linux/netlink.h,,,[
1281#ifdef HAVE_ASM_TYPES_H
1282#include <asm/types.h>
1283#endif
1284#ifdef HAVE_SYS_SOCKET_H
1285#include <sys/socket.h>
1286#endif
1287])
1288
Guido van Rossum627b2d71993-12-24 10:39:16 +00001289# checks for typedefs
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001290was_it_defined=no
1291AC_MSG_CHECKING(for clock_t in time.h)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001292AC_EGREP_HEADER(clock_t, time.h, was_it_defined=yes, [
1293 AC_DEFINE(clock_t, long, [Define to 'long' if <time.h> doesn't define.])
1294])
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001295AC_MSG_RESULT($was_it_defined)
1296
Neal Norwitz11690112002-07-30 01:08:28 +00001297# Check whether using makedev requires defining _OSF_SOURCE
1298AC_MSG_CHECKING(for makedev)
Neal Norwitz6eb37f02003-02-23 23:28:15 +00001299AC_TRY_LINK([#include <sys/types.h> ],
Neal Norwitz11690112002-07-30 01:08:28 +00001300 [ makedev(0, 0) ],
1301 ac_cv_has_makedev=yes,
1302 ac_cv_has_makedev=no)
1303if test "$ac_cv_has_makedev" = "no"; then
1304 # we didn't link, try if _OSF_SOURCE will allow us to link
1305 AC_TRY_LINK([
Neal Norwitz6eb37f02003-02-23 23:28:15 +00001306#define _OSF_SOURCE 1
1307#include <sys/types.h>
Neal Norwitz11690112002-07-30 01:08:28 +00001308 ],
1309 [ makedev(0, 0) ],
1310 ac_cv_has_makedev=yes,
1311 ac_cv_has_makedev=no)
1312 if test "$ac_cv_has_makedev" = "yes"; then
1313 AC_DEFINE(_OSF_SOURCE, 1, [Define _OSF_SOURCE to get the makedev macro.])
1314 fi
1315fi
1316AC_MSG_RESULT($ac_cv_has_makedev)
1317if test "$ac_cv_has_makedev" = "yes"; then
1318 AC_DEFINE(HAVE_MAKEDEV, 1, [Define this if you have the makedev macro.])
1319fi
1320
Martin v. Löwis399a6892002-10-04 10:22:02 +00001321# Enabling LFS on Solaris (2.6 to 9) with gcc 2.95 triggers a bug in
1322# the system headers: If _XOPEN_SOURCE and _LARGEFILE_SOURCE are
1323# defined, but the compiler does not support pragma redefine_extname,
1324# and _LARGEFILE64_SOURCE is not defined, the headers refer to 64-bit
1325# structures (such as rlimit64) without declaring them. As a
1326# work-around, disable LFS on such configurations
1327
1328use_lfs=yes
1329AC_MSG_CHECKING(Solaris LFS bug)
1330AC_TRY_COMPILE([
1331#define _LARGEFILE_SOURCE 1
1332#define _FILE_OFFSET_BITS 64
1333#include <sys/resource.h>
1334],struct rlimit foo;,sol_lfs_bug=no,sol_lfs_bug=yes)
1335AC_MSG_RESULT($sol_lfs_bug)
1336if test "$sol_lfs_bug" = "yes"; then
1337 use_lfs=no
1338fi
1339
1340if test "$use_lfs" = "yes"; then
Guido van Rossum810cc512001-09-09 23:51:39 +00001341# Two defines needed to enable largefile support on various platforms
1342# These may affect some typedefs
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001343AC_DEFINE(_LARGEFILE_SOURCE, 1,
1344[This must be defined on some systems to enable large file support.])
1345AC_DEFINE(_FILE_OFFSET_BITS, 64,
1346[This must be set to 64 on some systems to enable large file support.])
Martin v. Löwis399a6892002-10-04 10:22:02 +00001347fi
Guido van Rossum810cc512001-09-09 23:51:39 +00001348
Guido van Rossum300fda71996-08-19 21:58:16 +00001349# Add some code to confdefs.h so that the test for off_t works on SCO
1350cat >> confdefs.h <<\EOF
1351#if defined(SCO_DS)
1352#undef _OFF_T
1353#endif
1354EOF
1355
Guido van Rossumef2255b2000-03-10 22:30:29 +00001356# Type availability checks
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001357AC_TYPE_MODE_T
1358AC_TYPE_OFF_T
1359AC_TYPE_PID_T
1360AC_TYPE_SIGNAL
1361AC_TYPE_SIZE_T
1362AC_TYPE_UID_T
Mark Dickinsonbd792642009-03-18 20:06:12 +00001363AC_TYPE_UINT32_T
1364AC_TYPE_UINT64_T
1365AC_TYPE_INT32_T
1366AC_TYPE_INT64_T
Christian Heimes400adb02008-02-01 08:12:03 +00001367AC_CHECK_TYPE(ssize_t,
Martin v. Löwis18e16552006-02-15 17:27:45 +00001368 AC_DEFINE(HAVE_SSIZE_T, 1, Define if your compiler provides ssize_t),,)
Guido van Rossum627b2d71993-12-24 10:39:16 +00001369
Guido van Rossumef2255b2000-03-10 22:30:29 +00001370# Sizes of various common basic types
Skip Montanarob9820a32004-01-17 00:16:12 +00001371# ANSI C requires sizeof(char) == 1, so no need to check it
Guido van Rossum3065c942001-09-17 04:03:14 +00001372AC_CHECK_SIZEOF(int, 4)
1373AC_CHECK_SIZEOF(long, 4)
1374AC_CHECK_SIZEOF(void *, 4)
Guido van Rossum3065c942001-09-17 04:03:14 +00001375AC_CHECK_SIZEOF(short, 2)
1376AC_CHECK_SIZEOF(float, 4)
1377AC_CHECK_SIZEOF(double, 8)
1378AC_CHECK_SIZEOF(fpos_t, 4)
Martin v. Löwis18e16552006-02-15 17:27:45 +00001379AC_CHECK_SIZEOF(size_t, 4)
Christian Heimes400adb02008-02-01 08:12:03 +00001380AC_CHECK_SIZEOF(pid_t, 4)
Guido van Rossumac405f61994-09-12 10:56:06 +00001381
Guido van Rossumec95c7b1998-08-04 17:59:56 +00001382AC_MSG_CHECKING(for long long support)
1383have_long_long=no
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001384AC_TRY_COMPILE([], [long long x; x = (long long)0;], [
1385 AC_DEFINE(HAVE_LONG_LONG, 1, [Define this if you have the type long long.])
1386 have_long_long=yes
1387])
Guido van Rossumec95c7b1998-08-04 17:59:56 +00001388AC_MSG_RESULT($have_long_long)
Guido van Rossum8bc1dfd1999-04-10 16:01:48 +00001389if test "$have_long_long" = yes ; then
Guido van Rossum3065c942001-09-17 04:03:14 +00001390AC_CHECK_SIZEOF(long long, 8)
Guido van Rossumec95c7b1998-08-04 17:59:56 +00001391fi
1392
Travis E. Oliphant9b307842007-10-12 22:06:37 +00001393AC_MSG_CHECKING(for long double support)
1394have_long_double=no
1395AC_TRY_COMPILE([], [long double x; x = (long double)0;], [
1396 AC_DEFINE(HAVE_LONG_DOUBLE, 1, [Define this if you have the type long double.])
1397 have_long_double=yes
1398])
1399AC_MSG_RESULT($have_long_double)
1400if test "$have_long_double" = yes ; then
1401AC_CHECK_SIZEOF(long double, 16)
1402fi
1403
1404
Thomas Woutersb2137042007-02-01 18:02:27 +00001405AC_MSG_CHECKING(for _Bool support)
1406have_c99_bool=no
1407AC_TRY_COMPILE([], [_Bool x; x = (_Bool)0;], [
1408 AC_DEFINE(HAVE_C99_BOOL, 1, [Define this if you have the type _Bool.])
1409 have_c99_bool=yes
1410])
1411AC_MSG_RESULT($have_c99_bool)
1412if test "$have_c99_bool" = yes ; then
1413AC_CHECK_SIZEOF(_Bool, 1)
1414fi
1415
Thomas Wouters89f507f2006-12-13 04:49:30 +00001416AC_CHECK_TYPES(uintptr_t,
1417 [AC_CHECK_SIZEOF(uintptr_t, 4)],
1418 [], [#ifdef HAVE_STDINT_H
1419 #include <stdint.h>
1420 #endif])
1421
Barry Warsawbc7c7f92000-08-18 04:53:33 +00001422
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001423# Hmph. AC_CHECK_SIZEOF() doesn't include <sys/types.h>.
1424AC_MSG_CHECKING(size of off_t)
1425AC_CACHE_VAL(ac_cv_sizeof_off_t,
1426[AC_TRY_RUN([#include <stdio.h>
1427#include <sys/types.h>
1428main()
1429{
1430 FILE *f=fopen("conftestval", "w");
1431 if (!f) exit(1);
1432 fprintf(f, "%d\n", sizeof(off_t));
1433 exit(0);
Guido van Rossum3065c942001-09-17 04:03:14 +00001434}],
1435ac_cv_sizeof_off_t=`cat conftestval`,
1436ac_cv_sizeof_off_t=0,
1437ac_cv_sizeof_off_t=4)
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001438])
1439AC_MSG_RESULT($ac_cv_sizeof_off_t)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001440AC_DEFINE_UNQUOTED(SIZEOF_OFF_T, $ac_cv_sizeof_off_t,
1441[The number of bytes in an off_t.])
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001442
1443AC_MSG_CHECKING(whether to enable large file support)
Mark Dickinsonb87f0d02009-12-31 21:25:02 +00001444if test "$have_long_long" = yes
1445then
1446if test "$ac_cv_sizeof_off_t" -gt "$ac_cv_sizeof_long" -a \
Guido van Rossum8bc1dfd1999-04-10 16:01:48 +00001447 "$ac_cv_sizeof_long_long" -ge "$ac_cv_sizeof_off_t"; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001448 AC_DEFINE(HAVE_LARGEFILE_SUPPORT, 1,
1449 [Defined to enable large file support when an off_t is bigger than a long
1450 and long long is available and at least as big as an off_t. You may need
1451 to add some flags for configuration and compilation to enable this mode.
1452 (For Solaris and Linux, the necessary defines are already defined.)])
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001453 AC_MSG_RESULT(yes)
1454else
1455 AC_MSG_RESULT(no)
1456fi
Mark Dickinsonb87f0d02009-12-31 21:25:02 +00001457else
1458 AC_MSG_RESULT(no)
1459fi
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001460
Fred Drakea3f6e912000-06-29 20:44:47 +00001461# AC_CHECK_SIZEOF() doesn't include <time.h>.
1462AC_MSG_CHECKING(size of time_t)
1463AC_CACHE_VAL(ac_cv_sizeof_time_t,
1464[AC_TRY_RUN([#include <stdio.h>
1465#include <time.h>
1466main()
1467{
1468 FILE *f=fopen("conftestval", "w");
1469 if (!f) exit(1);
1470 fprintf(f, "%d\n", sizeof(time_t));
1471 exit(0);
Guido van Rossum3065c942001-09-17 04:03:14 +00001472}],
1473ac_cv_sizeof_time_t=`cat conftestval`,
1474ac_cv_sizeof_time_t=0,
1475ac_cv_sizeof_time_t=4)
Fred Drakea3f6e912000-06-29 20:44:47 +00001476])
1477AC_MSG_RESULT($ac_cv_sizeof_time_t)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001478AC_DEFINE_UNQUOTED(SIZEOF_TIME_T, $ac_cv_sizeof_time_t,
1479[The number of bytes in a time_t.])
Fred Drakea3f6e912000-06-29 20:44:47 +00001480
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001481
Trent Mick635f6fb2000-08-23 21:33:05 +00001482# if have pthread_t then define SIZEOF_PTHREAD_T
Martin v. Löwis123cbd22001-07-19 14:21:10 +00001483ac_save_cc="$CC"
1484if test "$ac_cv_kpthread" = "yes"
1485then CC="$CC -Kpthread"
Martin v. Löwis5f433f02003-05-05 05:05:30 +00001486elif test "$ac_cv_kthread" = "yes"
1487then CC="$CC -Kthread"
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00001488elif test "$ac_cv_pthread" = "yes"
1489then CC="$CC -pthread"
Martin v. Löwis123cbd22001-07-19 14:21:10 +00001490fi
Trent Mick635f6fb2000-08-23 21:33:05 +00001491AC_MSG_CHECKING(for pthread_t)
1492have_pthread_t=no
Guido van Rossum12580492000-09-24 16:47:19 +00001493AC_TRY_COMPILE([#include <pthread.h>], [pthread_t x; x = *(pthread_t*)0;], have_pthread_t=yes)
Trent Mick635f6fb2000-08-23 21:33:05 +00001494AC_MSG_RESULT($have_pthread_t)
1495if test "$have_pthread_t" = yes ; then
1496 # AC_CHECK_SIZEOF() doesn't include <pthread.h>.
1497 AC_MSG_CHECKING(size of pthread_t)
1498 AC_CACHE_VAL(ac_cv_sizeof_pthread_t,
1499 [AC_TRY_RUN([#include <stdio.h>
Neal Norwitz6eb37f02003-02-23 23:28:15 +00001500#include <pthread.h>
Trent Mick635f6fb2000-08-23 21:33:05 +00001501 main()
1502 {
1503 FILE *f=fopen("conftestval", "w");
1504 if (!f) exit(1);
1505 fprintf(f, "%d\n", sizeof(pthread_t));
1506 exit(0);
Guido van Rossum3065c942001-09-17 04:03:14 +00001507 }],
1508 ac_cv_sizeof_pthread_t=`cat conftestval`,
1509 ac_cv_sizeof_pthread_t=0,
1510 ac_cv_sizeof_pthread_t=4)
Trent Mick635f6fb2000-08-23 21:33:05 +00001511 ])
1512 AC_MSG_RESULT($ac_cv_sizeof_pthread_t)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001513 AC_DEFINE_UNQUOTED(SIZEOF_PTHREAD_T, $ac_cv_sizeof_pthread_t,
1514 [The number of bytes in a pthread_t.])
Trent Mick635f6fb2000-08-23 21:33:05 +00001515fi
Martin v. Löwis123cbd22001-07-19 14:21:10 +00001516CC="$ac_save_cc"
Trent Mick635f6fb2000-08-23 21:33:05 +00001517
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001518
Georg Brandl93de2162008-07-16 02:21:06 +00001519
Bob Ippolito7026a0a2005-03-28 23:23:47 +00001520AC_SUBST(OTHER_LIBTOOL_OPT)
1521case $ac_sys_system/$ac_sys_release in
Thomas Wouters49fd7fa2006-04-21 10:40:58 +00001522 Darwin/@<:@01567@:>@\..*)
Bob Ippolito7026a0a2005-03-28 23:23:47 +00001523 OTHER_LIBTOOL_OPT="-prebind -seg1addr 0x10000000"
1524 ;;
1525 Darwin/*)
1526 OTHER_LIBTOOL_OPT=""
1527 ;;
1528esac
1529
Ronald Oussorend45ff2c2009-09-06 11:11:04 +00001530
1531ARCH_RUN_32BIT=""
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001532AC_SUBST(LIBTOOL_CRUFT)
1533case $ac_sys_system/$ac_sys_release in
Thomas Wouters49fd7fa2006-04-21 10:40:58 +00001534 Darwin/@<:@01567@:>@\..*)
Thomas Wouters477c8d52006-05-27 19:21:47 +00001535 LIBTOOL_CRUFT="-framework System -lcc_dynamic"
1536 if test "${enable_universalsdk}"; then
1537 :
1538 else
Ronald Oussoren175a8842010-02-11 13:40:06 +00001539 LIBTOOL_CRUFT="${LIBTOOL_CRUFT} -arch_only `/usr/bin/arch`"
Thomas Wouters477c8d52006-05-27 19:21:47 +00001540 fi
Jack Jansenb36687a2004-07-16 08:43:47 +00001541 LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -install_name $(PYTHONFRAMEWORKINSTALLDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansena3891ea2001-09-07 14:25:12 +00001542 LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -compatibility_version $(VERSION) -current_version $(VERSION)';;
Guido van Rossum5839e582000-10-09 19:52:35 +00001543 Darwin/*)
Ronald Oussoren652f4de2010-02-07 11:54:03 +00001544 gcc_version=`gcc -dumpversion`
Bob Ippolito7026a0a2005-03-28 23:23:47 +00001545 if test ${gcc_version} '<' 4.0
1546 then
1547 LIBTOOL_CRUFT="-lcc_dynamic"
1548 else
1549 LIBTOOL_CRUFT=""
1550 fi
Ronald Oussoren856624d2009-09-08 07:13:53 +00001551 AC_TRY_RUN([
Ronald Oussorend45ff2c2009-09-06 11:11:04 +00001552 #include <unistd.h>
1553 int main(int argc, char*argv[])
1554 {
1555 if (sizeof(long) == 4) {
1556 return 0;
1557 } else {
1558 return 1;
1559 }
Ronald Oussoren856624d2009-09-08 07:13:53 +00001560 }
1561 ], ac_osx_32bit=yes,
Ronald Oussorend45ff2c2009-09-06 11:11:04 +00001562 ac_osx_32bit=no,
Ronald Oussoren856624d2009-09-08 07:13:53 +00001563 ac_osx_32bit=yes)
Ronald Oussorend45ff2c2009-09-06 11:11:04 +00001564
1565 if test "${ac_osx_32bit}" = "yes"; then
Ronald Oussoren175a8842010-02-11 13:40:06 +00001566 case `/usr/bin/arch` in
Ronald Oussorend45ff2c2009-09-06 11:11:04 +00001567 i386)
1568 MACOSX_DEFAULT_ARCH="i386"
1569 ;;
1570 ppc)
1571 MACOSX_DEFAULT_ARCH="ppc"
1572 ;;
1573 *)
1574 AC_MSG_ERROR([Unexpected output of 'arch' on OSX])
1575 ;;
1576 esac
1577 else
Ronald Oussoren175a8842010-02-11 13:40:06 +00001578 case `/usr/bin/arch` in
Ronald Oussorend45ff2c2009-09-06 11:11:04 +00001579 i386)
1580 MACOSX_DEFAULT_ARCH="x86_64"
1581 ;;
1582 ppc)
1583 MACOSX_DEFAULT_ARCH="ppc64"
1584 ;;
1585 *)
1586 AC_MSG_ERROR([Unexpected output of 'arch' on OSX])
1587 ;;
1588 esac
1589
1590 #ARCH_RUN_32BIT="true"
1591 fi
1592
1593 LIBTOOL_CRUFT=$LIBTOOL_CRUFT" -lSystem -lSystemStubs -arch_only ${MACOSX_DEFAULT_ARCH}"
Jack Jansenb36687a2004-07-16 08:43:47 +00001594 LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -install_name $(PYTHONFRAMEWORKINSTALLDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001595 LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -compatibility_version $(VERSION) -current_version $(VERSION)';;
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001596esac
1597
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001598AC_MSG_CHECKING(for --enable-framework)
1599if test "$enable_framework"
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001600then
Skip Montanarodecc6a42003-01-01 20:07:49 +00001601 BASECFLAGS="$BASECFLAGS -fno-common -dynamic"
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001602 # -F. is needed to allow linking to the framework while
1603 # in the build location.
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001604 AC_DEFINE(WITH_NEXT_FRAMEWORK, 1,
1605 [Define if you want to produce an OpenStep/Rhapsody framework
1606 (shared library plus accessory files).])
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001607 AC_MSG_RESULT(yes)
Ronald Oussoren99aab652009-06-08 21:22:57 +00001608 if test $enable_shared = "yes"
1609 then
1610 AC_MSG_ERROR([Specifying both --enable-shared and --enable-framework is not supported, use only --enable-framework instead])
1611 fi
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001612else
1613 AC_MSG_RESULT(no)
1614fi
1615
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001616AC_MSG_CHECKING(for dyld)
Jack Jansen9a66b6d2001-08-08 13:56:14 +00001617case $ac_sys_system/$ac_sys_release in
1618 Darwin/*)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001619 AC_DEFINE(WITH_DYLD, 1,
1620 [Define if you want to use the new-style (Openstep, Rhapsody, MacOS)
1621 dynamic linker (dyld) instead of the old-style (NextStep) dynamic
1622 linker (rld). Dyld is necessary to support frameworks.])
Jack Jansen9a66b6d2001-08-08 13:56:14 +00001623 AC_MSG_RESULT(always on for Darwin)
1624 ;;
1625 *)
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001626 AC_MSG_RESULT(no)
1627 ;;
Jack Jansen9a66b6d2001-08-08 13:56:14 +00001628esac
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001629
Guido van Rossumac405f61994-09-12 10:56:06 +00001630# Set info about shared libraries.
Guido van Rossumac405f61994-09-12 10:56:06 +00001631AC_SUBST(SO)
1632AC_SUBST(LDSHARED)
Neil Schemenauerb3531b82001-02-16 04:09:05 +00001633AC_SUBST(BLDSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00001634AC_SUBST(CCSHARED)
1635AC_SUBST(LINKFORSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00001636# SO is the extension of shared libraries `(including the dot!)
Guido van Rossumaef734b2001-01-10 21:09:12 +00001637# -- usually .so, .sl on HP-UX, .dll on Cygwin
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001638AC_MSG_CHECKING(SO)
Guido van Rossumac405f61994-09-12 10:56:06 +00001639if test -z "$SO"
1640then
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001641 case $ac_sys_system in
Thomas Wouters477c8d52006-05-27 19:21:47 +00001642 hp*|HP*)
1643 case `uname -m` in
1644 ia64) SO=.so;;
1645 *) SO=.sl;;
1646 esac
1647 ;;
Guido van Rossumaef734b2001-01-10 21:09:12 +00001648 CYGWIN*) SO=.dll;;
Guido van Rossum4b6b5791996-09-09 20:09:34 +00001649 *) SO=.so;;
Guido van Rossumac405f61994-09-12 10:56:06 +00001650 esac
Martin v. Löwis368de8f2003-06-14 14:46:38 +00001651else
1652 # this might also be a termcap variable, see #610332
1653 echo
1654 echo '====================================================================='
1655 echo '+ +'
1656 echo '+ WARNING: You have set SO in your environment. +'
1657 echo '+ Do you really mean to change the extension for shared libraries? +'
1658 echo '+ Continuing in 10 seconds to let you to ponder. +'
1659 echo '+ +'
1660 echo '====================================================================='
1661 sleep 10
Guido van Rossumac405f61994-09-12 10:56:06 +00001662fi
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001663AC_MSG_RESULT($SO)
Georg Brandlb1441c72009-01-03 22:33:39 +00001664
Thomas Wouters477c8d52006-05-27 19:21:47 +00001665AC_DEFINE_UNQUOTED(SHLIB_EXT, "$SO", [Define this to be extension of shared libraries (including the dot!).])
Guido van Rossumac405f61994-09-12 10:56:06 +00001666# LDSHARED is the ld *command* used to create shared library
Skip Montanaroce59c042004-01-17 14:19:44 +00001667# -- "cc -G" on SunOS 5.x, "ld -shared" on IRIX 5
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001668# (Shared libraries in this instance are shared modules to be loaded into
1669# Python, as opposed to building Python itself as a shared library.)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001670AC_MSG_CHECKING(LDSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00001671if test -z "$LDSHARED"
1672then
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001673 case $ac_sys_system/$ac_sys_release in
Neil Schemenauerb3531b82001-02-16 04:09:05 +00001674 AIX*)
1675 BLDSHARED="\$(srcdir)/Modules/ld_so_aix \$(CC) -bI:Modules/python.exp"
Guido van Rossumce608b02001-09-28 15:59:38 +00001676 LDSHARED="\$(BINLIBDEST)/config/ld_so_aix \$(CC) -bI:\$(BINLIBDEST)/config/python.exp"
Neil Schemenauerb3531b82001-02-16 04:09:05 +00001677 ;;
Guido van Rossum6100aaf1997-04-29 21:48:51 +00001678 IRIX/5*) LDSHARED="ld -shared";;
Guido van Rossum91922671997-10-09 20:24:13 +00001679 IRIX*/6*) LDSHARED="ld ${SGI_ABI} -shared -all";;
Greg Ward57c9a6632000-05-26 12:22:54 +00001680 SunOS/5*)
1681 if test "$GCC" = "yes"
Neil Schemenauer95052722001-02-19 18:17:33 +00001682 then LDSHARED='$(CC) -shared'
Martin v. Löwisaa5afe12002-10-07 06:21:41 +00001683 else LDSHARED='$(CC) -G';
Greg Ward57c9a6632000-05-26 12:22:54 +00001684 fi ;;
Thomas Hellerf44b9a12008-04-04 10:18:23 +00001685 hp*|HP*)
1686 if test "$GCC" = "yes"
1687 then LDSHARED='$(CC) -shared'
1688 else LDSHARED='ld -b';
1689 fi ;;
Guido van Rossum71001e41995-01-26 00:44:03 +00001690 OSF*) LDSHARED="ld -shared -expect_unresolved \"*\"";;
Jack Jansen418c3b12001-11-14 10:59:57 +00001691 Darwin/1.3*)
Jack Jansena3891ea2001-09-07 14:25:12 +00001692 LDSHARED='$(CC) $(LDFLAGS) -bundle'
1693 if test "$enable_framework" ; then
1694 # Link against the framework. All externals should be defined.
Jack Jansenda49e192005-01-07 13:08:22 +00001695 BLDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
1696 LDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansena3891ea2001-09-07 14:25:12 +00001697 else
1698 # No framework. Ignore undefined symbols, assuming they come from Python
Jack Jansen418c3b12001-11-14 10:59:57 +00001699 LDSHARED="$LDSHARED -undefined suppress"
Jack Jansena3891ea2001-09-07 14:25:12 +00001700 fi ;;
Jack Jansen6b08a402004-06-03 12:41:45 +00001701 Darwin/1.4*|Darwin/5.*|Darwin/6.*)
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001702 LDSHARED='$(CC) $(LDFLAGS) -bundle'
1703 if test "$enable_framework" ; then
1704 # Link against the framework. All externals should be defined.
Jack Jansenda49e192005-01-07 13:08:22 +00001705 BLDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
1706 LDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001707 else
Michael W. Hudson0c46c0c2002-03-07 09:58:56 +00001708 # No framework, use the Python app as bundle-loader
1709 BLDSHARED="$LDSHARED "'-bundle_loader $(BUILDPYTHON)'
Jack Jansenc28fc372003-02-25 13:14:43 +00001710 LDSHARED="$LDSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)'
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001711 fi ;;
Jack Jansen6b08a402004-06-03 12:41:45 +00001712 Darwin/*)
1713 # Use -undefined dynamic_lookup whenever possible (10.3 and later).
1714 # This allows an extension to be used in any Python
Thomas Wouters89d996e2007-09-08 17:39:28 +00001715
Georg Brandlfcaf9102008-07-16 02:17:56 +00001716 if test ${MACOSX_DEPLOYMENT_TARGET} '>' 10.2
Jack Jansen6b08a402004-06-03 12:41:45 +00001717 then
Thomas Wouters477c8d52006-05-27 19:21:47 +00001718 if test "${enable_universalsdk}"; then
Georg Brandlfcaf9102008-07-16 02:17:56 +00001719 LDFLAGS="${UNIVERSAL_ARCH_FLAGS} -isysroot ${UNIVERSALSDK} ${LDFLAGS}"
Thomas Wouters477c8d52006-05-27 19:21:47 +00001720 fi
Jack Jansen6b08a402004-06-03 12:41:45 +00001721 LDSHARED='$(CC) $(LDFLAGS) -bundle -undefined dynamic_lookup'
1722 BLDSHARED="$LDSHARED"
Jack Jansen6b08a402004-06-03 12:41:45 +00001723 else
1724 LDSHARED='$(CC) $(LDFLAGS) -bundle'
1725 if test "$enable_framework" ; then
1726 # Link against the framework. All externals should be defined.
Jack Jansenda49e192005-01-07 13:08:22 +00001727 BLDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
1728 LDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansen6b08a402004-06-03 12:41:45 +00001729 else
1730 # No framework, use the Python app as bundle-loader
1731 BLDSHARED="$LDSHARED "'-bundle_loader $(BUILDPYTHON)'
1732 LDSHARED="$LDSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)'
1733 fi
1734 fi
1735 ;;
Georg Brandlf78e02b2008-06-10 17:40:04 +00001736 Linux*|GNU*|QNX*) LDSHARED='$(CC) -shared';;
Guido van Rossum458e7fa1999-09-17 15:40:40 +00001737 BSD/OS*/4*) LDSHARED="gcc -shared";;
Thomas Wouters1ba5b3b2006-06-08 14:52:47 +00001738 FreeBSD*)
Jeremy Hylton4bcc7c52000-08-31 17:45:35 +00001739 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
Guido van Rossum0286ae82000-08-29 15:06:49 +00001740 then
Hye-Shik Chang33761492004-10-26 09:53:46 +00001741 LDSHARED="$CC -shared ${LDFLAGS}"
Guido van Rossum0286ae82000-08-29 15:06:49 +00001742 else
1743 LDSHARED="ld -Bshareable ${LDFLAGS}"
1744 fi;;
Thomas Wouters1ba5b3b2006-06-08 14:52:47 +00001745 OpenBSD*)
1746 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
1747 then
1748 LDSHARED='$(CC) -shared $(CCSHARED) ${LDFLAGS}'
1749 else
1750 case `uname -r` in
1751 [[01]].* | 2.[[0-7]] | 2.[[0-7]].*)
1752 LDSHARED="ld -Bshareable ${LDFLAGS}"
1753 ;;
1754 *)
1755 LDSHARED='$(CC) -shared $(CCSHARED) ${LDFLAGS}'
1756 ;;
1757 esac
1758 fi;;
Martin v. Löwis86d66262006-02-17 08:40:11 +00001759 NetBSD*|DragonFly*) LDSHARED="cc -shared ${LDFLAGS}";;
Martin v. Löwis25ae43b2001-10-07 08:39:18 +00001760 OpenUNIX*|UnixWare*)
Martin v. Löwisbec19582001-03-21 15:57:54 +00001761 if test "$GCC" = "yes"
Martin v. Löwis79f3c532002-12-11 12:51:58 +00001762 then LDSHARED='$(CC) -shared'
1763 else LDSHARED='$(CC) -G'
Martin v. Löwisbec19582001-03-21 15:57:54 +00001764 fi;;
Martin v. Löwis79f3c532002-12-11 12:51:58 +00001765 SCO_SV*) LDSHARED='$(CC) -Wl,-G,-Bexport';;
Guido van Rossumaef734b2001-01-10 21:09:12 +00001766 CYGWIN*) LDSHARED="gcc -shared -Wl,--enable-auto-image-base";;
Martin v. Löwisf90ae202002-06-11 06:22:31 +00001767 atheos*) LDSHARED="gcc -shared";;
Guido van Rossumac405f61994-09-12 10:56:06 +00001768 *) LDSHARED="ld";;
1769 esac
Guido van Rossumac405f61994-09-12 10:56:06 +00001770fi
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001771AC_MSG_RESULT($LDSHARED)
Neil Schemenauerb3531b82001-02-16 04:09:05 +00001772BLDSHARED=${BLDSHARED-$LDSHARED}
Guido van Rossumac405f61994-09-12 10:56:06 +00001773# CCSHARED are the C *flags* used to create objects to go into a shared
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001774# library (module) -- this is only needed for a few systems
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001775AC_MSG_CHECKING(CCSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00001776if test -z "$CCSHARED"
1777then
Guido van Rossum6100aaf1997-04-29 21:48:51 +00001778 case $ac_sys_system/$ac_sys_release in
Neil Schemenauer66252162001-02-19 04:47:42 +00001779 SunOS*) if test "$GCC" = yes;
Guido van Rossumd8faa362007-04-27 19:54:29 +00001780 then CCSHARED="-fPIC";
1781 elif test `uname -p` = sparc;
1782 then CCSHARED="-xcode=pic32";
1783 else CCSHARED="-Kpic";
1784 fi;;
Guido van Rossumaf07a441995-02-13 19:45:27 +00001785 hp*|HP*) if test "$GCC" = yes;
Martin v. Löwis703ad702001-09-05 08:36:52 +00001786 then CCSHARED="-fPIC";
Guido van Rossumaf07a441995-02-13 19:45:27 +00001787 else CCSHARED="+z";
1788 fi;;
Martin v. Löwisa6e97582002-01-01 18:41:33 +00001789 Linux*|GNU*) CCSHARED="-fPIC";;
Guido van Rossumf5957ea1999-10-05 21:59:33 +00001790 BSD/OS*/4*) CCSHARED="-fpic";;
Martin v. Löwis86d66262006-02-17 08:40:11 +00001791 FreeBSD*|NetBSD*|OpenBSD*|DragonFly*) CCSHARED="-fPIC";;
Martin v. Löwis25ae43b2001-10-07 08:39:18 +00001792 OpenUNIX*|UnixWare*)
Martin v. Löwisbec19582001-03-21 15:57:54 +00001793 if test "$GCC" = "yes"
1794 then CCSHARED="-fPIC"
Martin v. Löwis130fb172001-07-19 11:00:41 +00001795 else CCSHARED="-KPIC"
Martin v. Löwisbec19582001-03-21 15:57:54 +00001796 fi;;
Martin v. Löwis21ee4092002-09-30 16:19:48 +00001797 SCO_SV*)
1798 if test "$GCC" = "yes"
1799 then CCSHARED="-fPIC"
1800 else CCSHARED="-Kpic -belf"
1801 fi;;
Guido van Rossum2b5ca001998-03-05 15:41:09 +00001802 IRIX*/6*) case $CC in
1803 *gcc*) CCSHARED="-shared";;
Guido van Rossumee21f411998-04-20 18:51:54 +00001804 *) CCSHARED="";;
Guido van Rossum2b5ca001998-03-05 15:41:09 +00001805 esac;;
Martin v. Löwisf90ae202002-06-11 06:22:31 +00001806 atheos*) CCSHARED="-fPIC";;
Guido van Rossumac405f61994-09-12 10:56:06 +00001807 esac
Guido van Rossumac405f61994-09-12 10:56:06 +00001808fi
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001809AC_MSG_RESULT($CCSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00001810# LINKFORSHARED are the flags passed to the $(CC) command that links
Guido van Rossumb65a48e1995-06-14 18:21:23 +00001811# the python executable -- this is only needed for a few systems
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001812AC_MSG_CHECKING(LINKFORSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00001813if test -z "$LINKFORSHARED"
1814then
Guido van Rossum6100aaf1997-04-29 21:48:51 +00001815 case $ac_sys_system/$ac_sys_release in
Neil Schemenauerb3531b82001-02-16 04:09:05 +00001816 AIX*) LINKFORSHARED='-Wl,-bE:Modules/python.exp -lld';;
Guido van Rossum5dab3d81996-12-06 21:18:18 +00001817 hp*|HP*)
Martin v. Löwis1142de32002-03-29 16:28:31 +00001818 LINKFORSHARED="-Wl,-E -Wl,+s";;
1819# LINKFORSHARED="-Wl,-E -Wl,+s -Wl,+b\$(BINLIBDEST)/lib-dynload";;
Guido van Rossumf5957ea1999-10-05 21:59:33 +00001820 BSD/OS/4*) LINKFORSHARED="-Xlinker -export-dynamic";;
Martin v. Löwisa6e97582002-01-01 18:41:33 +00001821 Linux*|GNU*) LINKFORSHARED="-Xlinker -export-dynamic";;
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001822 # -u libsys_s pulls in all symbols in libsys
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001823 Darwin/*)
Benjamin Peterson9c80cac2009-05-23 16:34:23 +00001824 LINKFORSHARED="$extra_undefs -framework CoreFoundation"
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001825 if test "$enable_framework"
1826 then
Jack Jansenda49e192005-01-07 13:08:22 +00001827 LINKFORSHARED="$LINKFORSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001828 fi
Raymond Hettingerec6eb362004-11-05 07:02:59 +00001829 LINKFORSHARED="$LINKFORSHARED";;
Martin v. Löwis25ae43b2001-10-07 08:39:18 +00001830 OpenUNIX*|UnixWare*) LINKFORSHARED="-Wl,-Bexport";;
Martin v. Löwis21ee4092002-09-30 16:19:48 +00001831 SCO_SV*) LINKFORSHARED="-Wl,-Bexport";;
Fred Drake02706f52000-09-25 15:08:46 +00001832 ReliantUNIX*) LINKFORSHARED="-W1 -Blargedynsym";;
Martin v. Löwis86d66262006-02-17 08:40:11 +00001833 FreeBSD*|NetBSD*|OpenBSD*|DragonFly*)
Guido van Rossumdf693651999-01-07 21:50:41 +00001834 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
1835 then
1836 LINKFORSHARED="-Wl,--export-dynamic"
1837 fi;;
Guido van Rossum2b5ca001998-03-05 15:41:09 +00001838 SunOS/5*) case $CC in
1839 *gcc*)
Martin v. Löwisa4548572002-04-18 14:51:36 +00001840 if $CC -Xlinker --help 2>&1 | grep export-dynamic >/dev/null
Guido van Rossum8f4ceb11997-12-18 23:42:19 +00001841 then
1842 LINKFORSHARED="-Xlinker --export-dynamic"
Guido van Rossum2b5ca001998-03-05 15:41:09 +00001843 fi;;
1844 esac;;
Jason Tishler30765592003-09-04 11:04:06 +00001845 CYGWIN*)
1846 if test $enable_shared = "no"
1847 then
1848 LINKFORSHARED='-Wl,--out-implib=$(LDLIBRARY)'
1849 fi;;
Georg Brandlf78e02b2008-06-10 17:40:04 +00001850 QNX*)
1851 # -Wl,-E causes the symbols to be added to the dynamic
1852 # symbol table so that they can be found when a module
1853 # is loaded. -N 2048K causes the stack size to be set
1854 # to 2048 kilobytes so that the stack doesn't overflow
1855 # when running test_compile.py.
1856 LINKFORSHARED='-Wl,-E -N 2048K';;
Guido van Rossumac405f61994-09-12 10:56:06 +00001857 esac
Guido van Rossumac405f61994-09-12 10:56:06 +00001858fi
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001859AC_MSG_RESULT($LINKFORSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00001860
Georg Brandl93de2162008-07-16 02:21:06 +00001861
Neil Schemenauer61c51152001-01-26 16:18:16 +00001862AC_SUBST(CFLAGSFORSHARED)
1863AC_MSG_CHECKING(CFLAGSFORSHARED)
1864if test ! "$LIBRARY" = "$LDLIBRARY"
1865then
Neil Schemenauerd9cf41c2001-01-27 21:39:17 +00001866 case $ac_sys_system in
1867 CYGWIN*)
1868 # Cygwin needs CCSHARED when building extension DLLs
1869 # but not when building the interpreter DLL.
1870 CFLAGSFORSHARED='';;
1871 *)
1872 CFLAGSFORSHARED='$(CCSHARED)'
1873 esac
Neil Schemenauer61c51152001-01-26 16:18:16 +00001874fi
1875AC_MSG_RESULT($CFLAGSFORSHARED)
1876
Martin v. Löwisf90ae202002-06-11 06:22:31 +00001877# SHLIBS are libraries (except -lc and -lm) to link to the python shared
1878# library (with --enable-shared).
1879# For platforms on which shared libraries are not allowed to have unresolved
Martin v. Löwisd6359c52002-08-04 12:38:50 +00001880# symbols, this must be set to $(LIBS) (expanded by make). We do this even
1881# if it is not required, since it creates a dependency of the shared library
1882# to LIBS. This, in turn, means that applications linking the shared libpython
1883# don't need to link LIBS explicitly. The default should be only changed
1884# on systems where this approach causes problems.
Martin v. Löwisf90ae202002-06-11 06:22:31 +00001885AC_SUBST(SHLIBS)
1886AC_MSG_CHECKING(SHLIBS)
1887case "$ac_sys_system" in
Martin v. Löwisf90ae202002-06-11 06:22:31 +00001888 *)
Martin v. Löwisd6359c52002-08-04 12:38:50 +00001889 SHLIBS='$(LIBS)';;
Martin v. Löwisf90ae202002-06-11 06:22:31 +00001890esac
1891AC_MSG_RESULT($SHLIBS)
1892
1893
Guido van Rossum627b2d71993-12-24 10:39:16 +00001894# checks for libraries
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001895AC_CHECK_LIB(dl, dlopen) # Dynamic linking for SunOS/Solaris and SYSV
1896AC_CHECK_LIB(dld, shl_load) # Dynamic linking for HP-UX
Martin v. Löwis519adae2003-09-20 10:47:47 +00001897
Georg Brandleee31162008-12-07 15:15:22 +00001898# only check for sem_init if thread support is requested
Martin v. Löwis519adae2003-09-20 10:47:47 +00001899if test "$with_threads" = "yes" -o -z "$with_threads"; then
1900 AC_SEARCH_LIBS(sem_init, pthread rt posix4) # 'Real Time' functions on Solaris
1901 # posix4 on Solaris 2.6
1902 # pthread (first!) on Linux
1903fi
1904
Martin v. Löwis19d17342003-06-14 21:03:05 +00001905# check if we need libintl for locale functions
1906AC_CHECK_LIB(intl, textdomain,
Brett Cannonc6d936e2009-06-07 20:09:53 +00001907 [AC_DEFINE(WITH_LIBINTL, 1,
1908 [Define to 1 if libintl is needed for locale functions.])
1909 LIBS="-lintl $LIBS"])
Guido van Rossum0eefa3f1999-11-16 15:57:37 +00001910
1911# checks for system dependent C++ extensions support
1912case "$ac_sys_system" in
1913 AIX*) AC_MSG_CHECKING(for genuine AIX C++ extensions support)
1914 AC_TRY_LINK([#include "/usr/lpp/xlC/include/load.h"],
1915 [loadAndInit("", 0, "")],
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001916 [AC_DEFINE(AIX_GENUINE_CPLUSPLUS, 1,
1917 [Define for AIX if your compiler is a genuine IBM xlC/xlC_r
1918 and you want support for AIX C++ shared extension modules.])
Guido van Rossum0eefa3f1999-11-16 15:57:37 +00001919 AC_MSG_RESULT(yes)],
1920 [AC_MSG_RESULT(no)]);;
1921 *) ;;
1922esac
1923
Guido van Rossum70c7f481998-03-26 18:44:10 +00001924# Most SVR4 platforms (e.g. Solaris) need -lsocket and -lnsl.
Guido van Rossumf618d2c1995-01-17 16:36:13 +00001925AC_CHECK_LIB(nsl, t_open, [LIBS="-lnsl $LIBS"]) # SVR4
Guido van Rossumf618d2c1995-01-17 16:36:13 +00001926AC_CHECK_LIB(socket, socket, [LIBS="-lsocket $LIBS"], [], $LIBS) # SVR4 sockets
Skip Montanarob9949db2004-01-17 04:04:13 +00001927
Guido van Rossumc5a39031996-07-31 17:35:03 +00001928AC_MSG_CHECKING(for --with-libs)
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00001929AC_ARG_WITH(libs,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00001930 AC_HELP_STRING(--with-libs='lib1 ...', link against additional libs),
1931[
Guido van Rossumc5a39031996-07-31 17:35:03 +00001932AC_MSG_RESULT($withval)
1933LIBS="$withval $LIBS"
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00001934],
1935[AC_MSG_RESULT(no)])
Guido van Rossum627b2d71993-12-24 10:39:16 +00001936
Thomas Wouters49fd7fa2006-04-21 10:40:58 +00001937# Check for use of the system libffi library
1938AC_MSG_CHECKING(for --with-system-ffi)
1939AC_ARG_WITH(system_ffi,
1940 AC_HELP_STRING(--with-system-ffi, build _ctypes module using an installed ffi library))
1941
Thomas Wouters49fd7fa2006-04-21 10:40:58 +00001942AC_MSG_RESULT($with_system_ffi)
1943
Matthias Klose55708cc2009-04-30 08:06:49 +00001944# Check for --with-dbmliborder
1945AC_MSG_CHECKING(for --with-dbmliborder)
1946AC_ARG_WITH(dbmliborder,
1947 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'.]),
1948[
1949if test x$with_dbmliborder = xyes
1950then
1951AC_MSG_ERROR([proper usage is --with-dbmliborder=db1:db2:...])
1952else
1953 for db in `echo $with_dbmliborder | sed 's/:/ /g'`; do
1954 if test x$db != xndbm && test x$db != xgdbm && test x$db != xbdb
1955 then
1956 AC_MSG_ERROR([proper usage is --with-dbmliborder=db1:db2:...])
1957 fi
1958 done
1959fi])
1960AC_MSG_RESULT($with_dbmliborder)
1961
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00001962# Determine if signalmodule should be used.
1963AC_SUBST(USE_SIGNAL_MODULE)
1964AC_SUBST(SIGNAL_OBJS)
1965AC_MSG_CHECKING(for --with-signal-module)
1966AC_ARG_WITH(signal-module,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00001967 AC_HELP_STRING(--with-signal-module, disable/enable signal module))
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00001968
1969if test -z "$with_signal_module"
1970then with_signal_module="yes"
1971fi
1972AC_MSG_RESULT($with_signal_module)
1973
1974if test "${with_signal_module}" = "yes"; then
1975 USE_SIGNAL_MODULE=""
1976 SIGNAL_OBJS=""
1977else
1978 USE_SIGNAL_MODULE="#"
1979 SIGNAL_OBJS="Parser/intrcheck.o Python/sigcheck.o"
1980fi
1981
Guido van Rossum3d15bd82001-01-10 18:53:48 +00001982# This is used to generate Setup.config
Guido van Rossum009f7871997-12-04 00:51:42 +00001983AC_SUBST(USE_THREAD_MODULE)
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00001984USE_THREAD_MODULE=""
Guido van Rossum009f7871997-12-04 00:51:42 +00001985
Guido van Rossum54d93d41997-01-22 20:51:58 +00001986AC_MSG_CHECKING(for --with-dec-threads)
1987AC_SUBST(LDLAST)
1988AC_ARG_WITH(dec-threads,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00001989 AC_HELP_STRING(--with-dec-threads, use DEC Alpha/OSF1 thread-safe libraries),
1990[
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00001991AC_MSG_RESULT($withval)
Guido van Rossum54d93d41997-01-22 20:51:58 +00001992LDLAST=-threads
Guido van Rossumf78abae1997-01-21 22:02:36 +00001993if test "${with_thread+set}" != set; then
Guido van Rossum54d93d41997-01-22 20:51:58 +00001994 with_thread="$withval";
1995fi],
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00001996[AC_MSG_RESULT(no)])
Guido van Rossum54d93d41997-01-22 20:51:58 +00001997
Martin v. Löwis11437992002-04-12 09:54:03 +00001998# Templates for things AC_DEFINEd more than once.
1999# For a single AC_DEFINE, no template is needed.
2000AH_TEMPLATE(C_THREADS,[Define if you have the Mach cthreads package])
2001AH_TEMPLATE(_REENTRANT,
2002 [Define to force use of thread-safe errno, h_errno, and other functions])
2003AH_TEMPLATE(WITH_THREAD,
2004 [Define if you want to compile in rudimentary thread support])
2005
Guido van Rossum54d93d41997-01-22 20:51:58 +00002006AC_MSG_CHECKING(for --with-threads)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002007dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00002008AC_ARG_WITH(threads,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002009 AC_HELP_STRING(--with(out)-threads@<:@=DIRECTORY@:>@, disable/enable thread support))
Guido van Rossum54d93d41997-01-22 20:51:58 +00002010
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00002011# --with-thread is deprecated, but check for it anyway
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002012dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
Barry Warsawa0f3c5c2000-06-30 16:39:35 +00002013AC_ARG_WITH(thread,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002014 AC_HELP_STRING(--with(out)-thread@<:@=DIRECTORY@:>@, deprecated; use --with(out)-threads),
2015 [with_threads=$with_thread])
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00002016
2017if test -z "$with_threads"
2018then with_threads="yes"
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002019fi
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00002020AC_MSG_RESULT($with_threads)
Guido van Rossum6400c261997-05-22 20:34:27 +00002021
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002022AC_SUBST(THREADOBJ)
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00002023if test "$with_threads" = "no"
2024then
2025 USE_THREAD_MODULE="#"
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002026elif test "$ac_cv_pthread_is_default" = yes
2027then
2028 AC_DEFINE(WITH_THREAD)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002029 # Defining _REENTRANT on system with POSIX threads should not hurt.
2030 AC_DEFINE(_REENTRANT)
2031 posix_threads=yes
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002032 THREADOBJ="Python/thread.o"
Martin v. Löwis130fb172001-07-19 11:00:41 +00002033elif test "$ac_cv_kpthread" = "yes"
2034then
2035 CC="$CC -Kpthread"
Martin v. Löwis519adae2003-09-20 10:47:47 +00002036 if test "$ac_cv_cxx_thread" = "yes"; then
2037 CXX="$CXX -Kpthread"
2038 fi
Martin v. Löwis130fb172001-07-19 11:00:41 +00002039 AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002040 posix_threads=yes
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002041 THREADOBJ="Python/thread.o"
Martin v. Löwis5f433f02003-05-05 05:05:30 +00002042elif test "$ac_cv_kthread" = "yes"
2043then
2044 CC="$CC -Kthread"
Martin v. Löwis519adae2003-09-20 10:47:47 +00002045 if test "$ac_cv_cxx_thread" = "yes"; then
2046 CXX="$CXX -Kthread"
2047 fi
Martin v. Löwis5f433f02003-05-05 05:05:30 +00002048 AC_DEFINE(WITH_THREAD)
2049 posix_threads=yes
2050 THREADOBJ="Python/thread.o"
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002051elif test "$ac_cv_pthread" = "yes"
2052then
2053 CC="$CC -pthread"
Martin v. Löwis519adae2003-09-20 10:47:47 +00002054 if test "$ac_cv_cxx_thread" = "yes"; then
2055 CXX="$CXX -pthread"
2056 fi
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002057 AC_DEFINE(WITH_THREAD)
2058 posix_threads=yes
2059 THREADOBJ="Python/thread.o"
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00002060else
Martin v. Löwis130fb172001-07-19 11:00:41 +00002061 if test ! -z "$with_threads" -a -d "$with_threads"
2062 then LDFLAGS="$LDFLAGS -L$with_threads"
2063 fi
2064 if test ! -z "$withval" -a -d "$withval"
2065 then LDFLAGS="$LDFLAGS -L$withval"
2066 fi
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002067
2068 # According to the POSIX spec, a pthreads implementation must
Matthias Klosea2542be2004-08-16 11:35:51 +00002069 # define _POSIX_THREADS in unistd.h. Some apparently don't
2070 # (e.g. gnu pth with pthread emulation)
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002071 AC_MSG_CHECKING(for _POSIX_THREADS in unistd.h)
2072 AC_EGREP_CPP(yes,
Neal Norwitz6eb37f02003-02-23 23:28:15 +00002073 [
2074#include <unistd.h>
2075#ifdef _POSIX_THREADS
2076yes
2077#endif
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002078 ], unistd_defines_pthreads=yes, unistd_defines_pthreads=no)
2079 AC_MSG_RESULT($unistd_defines_pthreads)
2080
Martin v. Löwis130fb172001-07-19 11:00:41 +00002081 AC_DEFINE(_REENTRANT)
Martin v. Löwisa6e97582002-01-01 18:41:33 +00002082 AC_CHECK_HEADER(cthreads.h, [AC_DEFINE(WITH_THREAD)
2083 AC_DEFINE(C_THREADS)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002084 AC_DEFINE(HURD_C_THREADS, 1,
2085 [Define if you are using Mach cthreads directly under /include])
Martin v. Löwisa6e97582002-01-01 18:41:33 +00002086 LIBS="$LIBS -lthreads"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002087 THREADOBJ="Python/thread.o"],[
Martin v. Löwis130fb172001-07-19 11:00:41 +00002088 AC_CHECK_HEADER(mach/cthreads.h, [AC_DEFINE(WITH_THREAD)
2089 AC_DEFINE(C_THREADS)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002090 AC_DEFINE(MACH_C_THREADS, 1,
2091 [Define if you are using Mach cthreads under mach /])
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002092 THREADOBJ="Python/thread.o"],[
Martin v. Löwis130fb172001-07-19 11:00:41 +00002093 AC_MSG_CHECKING(for --with-pth)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002094 AC_ARG_WITH([pth],
2095 AC_HELP_STRING(--with-pth, use GNU pth threading libraries),
2096 [AC_MSG_RESULT($withval)
2097 AC_DEFINE([WITH_THREAD])
2098 AC_DEFINE([HAVE_PTH], 1,
2099 [Define if you have GNU PTH threads.])
2100 LIBS="-lpth $LIBS"
2101 THREADOBJ="Python/thread.o"],
2102 [AC_MSG_RESULT(no)
Martin v. Löwis8158b5a2001-10-08 13:17:28 +00002103
2104 # Just looking for pthread_create in libpthread is not enough:
2105 # on HP/UX, pthread.h renames pthread_create to a different symbol name.
2106 # So we really have to include pthread.h, and then link.
2107 _libs=$LIBS
2108 LIBS="$LIBS -lpthread"
2109 AC_MSG_CHECKING([for pthread_create in -lpthread])
2110 AC_TRY_LINK([#include <pthread.h>
2111
2112void * start_routine (void *arg) { exit (0); }], [
2113pthread_create (NULL, NULL, start_routine, NULL)], [
2114 AC_MSG_RESULT(yes)
2115 AC_DEFINE(WITH_THREAD)
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002116 posix_threads=yes
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002117 THREADOBJ="Python/thread.o"],[
Martin v. Löwis8158b5a2001-10-08 13:17:28 +00002118 LIBS=$_libs
Martin v. Löwis130fb172001-07-19 11:00:41 +00002119 AC_CHECK_FUNC(pthread_detach, [AC_DEFINE(WITH_THREAD)
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002120 posix_threads=yes
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002121 THREADOBJ="Python/thread.o"],[
Martin v. Löwisf90ae202002-06-11 06:22:31 +00002122 AC_CHECK_HEADER(atheos/threads.h, [AC_DEFINE(WITH_THREAD)
2123 AC_DEFINE(ATHEOS_THREADS, 1,
2124 [Define this if you have AtheOS threads.])
2125 THREADOBJ="Python/thread.o"],[
Martin v. Löwis130fb172001-07-19 11:00:41 +00002126 AC_CHECK_LIB(pthreads, pthread_create, [AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002127 posix_threads=yes
Martin v. Löwis130fb172001-07-19 11:00:41 +00002128 LIBS="$LIBS -lpthreads"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002129 THREADOBJ="Python/thread.o"], [
Martin v. Löwis130fb172001-07-19 11:00:41 +00002130 AC_CHECK_LIB(c_r, pthread_create, [AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002131 posix_threads=yes
Martin v. Löwis130fb172001-07-19 11:00:41 +00002132 LIBS="$LIBS -lc_r"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002133 THREADOBJ="Python/thread.o"], [
Martin v. Löwis130fb172001-07-19 11:00:41 +00002134 AC_CHECK_LIB(pthread, __pthread_create_system, [AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002135 posix_threads=yes
Martin v. Löwis130fb172001-07-19 11:00:41 +00002136 LIBS="$LIBS -lpthread"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002137 THREADOBJ="Python/thread.o"], [
Martin v. Löwis130fb172001-07-19 11:00:41 +00002138 AC_CHECK_LIB(cma, pthread_create, [AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002139 posix_threads=yes
Martin v. Löwis130fb172001-07-19 11:00:41 +00002140 LIBS="$LIBS -lcma"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002141 THREADOBJ="Python/thread.o"],[
Martin v. Löwis130fb172001-07-19 11:00:41 +00002142 USE_THREAD_MODULE="#"])
Skip Montanaroeb33e5a2007-08-17 12:57:41 +00002143 ])])])])])])])])])
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00002144
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002145 AC_CHECK_LIB(mpc, usconfig, [AC_DEFINE(WITH_THREAD)
2146 LIBS="$LIBS -lmpc"
2147 THREADOBJ="Python/thread.o"
2148 USE_THREAD_MODULE=""])
2149
2150 if test "$posix_threads" != "yes"; then
2151 AC_CHECK_LIB(thread, thr_create, [AC_DEFINE(WITH_THREAD)
2152 LIBS="$LIBS -lthread"
2153 THREADOBJ="Python/thread.o"
2154 USE_THREAD_MODULE=""])
2155 fi
2156
2157 if test "$USE_THREAD_MODULE" != "#"
2158 then
2159 # If the above checks didn't disable threads, (at least) OSF1
2160 # needs this '-threads' argument during linking.
2161 case $ac_sys_system in
2162 OSF1) LDLAST=-threads;;
2163 esac
2164 fi
2165fi
2166
2167if test "$posix_threads" = "yes"; then
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002168 if test "$unistd_defines_pthreads" = "no"; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002169 AC_DEFINE(_POSIX_THREADS, 1,
2170 [Define if you have POSIX threads,
2171 and your system does not define that.])
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002172 fi
2173
Martin v. Löwisdfc33fd2003-01-21 10:14:41 +00002174 # Bug 662787: Using semaphores causes unexplicable hangs on Solaris 8.
2175 case $ac_sys_system/$ac_sys_release in
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002176 SunOS/5.6) AC_DEFINE(HAVE_PTHREAD_DESTRUCTOR, 1,
2177 Defined for Solaris 2.6 bug in pthread header.)
2178 ;;
Martin v. Löwisdfc33fd2003-01-21 10:14:41 +00002179 SunOS/5.8) AC_DEFINE(HAVE_BROKEN_POSIX_SEMAPHORES, 1,
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002180 Define if the Posix semaphores do not work on your system)
2181 ;;
Christian Heimes7b3ce6a2008-01-31 14:31:45 +00002182 AIX/5) AC_DEFINE(HAVE_BROKEN_POSIX_SEMAPHORES, 1,
2183 Define if the Posix semaphores do not work on your system)
2184 ;;
Martin v. Löwisdfc33fd2003-01-21 10:14:41 +00002185 esac
2186
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002187 AC_MSG_CHECKING(if PTHREAD_SCOPE_SYSTEM is supported)
2188 AC_CACHE_VAL(ac_cv_pthread_system_supported,
2189 [AC_TRY_RUN([#include <pthread.h>
2190 void *foo(void *parm) {
2191 return NULL;
2192 }
2193 main() {
2194 pthread_attr_t attr;
Martin v. Löwisa82d3472002-02-24 16:05:05 +00002195 pthread_t id;
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002196 if (pthread_attr_init(&attr)) exit(-1);
2197 if (pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM)) exit(-1);
Martin v. Löwisa82d3472002-02-24 16:05:05 +00002198 if (pthread_create(&id, &attr, foo, NULL)) exit(-1);
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002199 exit(0);
Guido van Rossum3065c942001-09-17 04:03:14 +00002200 }],
2201 ac_cv_pthread_system_supported=yes,
2202 ac_cv_pthread_system_supported=no,
2203 ac_cv_pthread_system_supported=no)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002204 ])
2205 AC_MSG_RESULT($ac_cv_pthread_system_supported)
2206 if test "$ac_cv_pthread_system_supported" = "yes"; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002207 AC_DEFINE(PTHREAD_SYSTEM_SCHED_SUPPORTED, 1, [Defined if PTHREAD_SCOPE_SYSTEM supported.])
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002208 fi
Jason Tishlerfac083d2003-07-22 15:20:49 +00002209 AC_CHECK_FUNCS(pthread_sigmask,
2210 [case $ac_sys_system in
2211 CYGWIN*)
2212 AC_DEFINE(HAVE_BROKEN_PTHREAD_SIGMASK, 1,
2213 [Define if pthread_sigmask() does not work on your system.])
2214 ;;
2215 esac])
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00002216fi
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002217
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002218
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002219# Check for enable-ipv6
Martin v. Löwis11437992002-04-12 09:54:03 +00002220AH_TEMPLATE(ENABLE_IPV6, [Define if --enable-ipv6 is specified])
Martin v. Löwisa5f8bb52001-09-05 08:22:34 +00002221AC_MSG_CHECKING([if --enable-ipv6 is specified])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002222AC_ARG_ENABLE(ipv6,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002223[ --enable-ipv6 Enable ipv6 (with ipv4) support
2224 --disable-ipv6 Disable ipv6 support],
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002225[ case "$enableval" in
2226 no)
2227 AC_MSG_RESULT(no)
2228 ipv6=no
2229 ;;
2230 *) AC_MSG_RESULT(yes)
2231 AC_DEFINE(ENABLE_IPV6)
2232 ipv6=yes
2233 ;;
2234 esac ],
2235
Martin v. Löwisa5f8bb52001-09-05 08:22:34 +00002236[
2237dnl the check does not work on cross compilation case...
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002238 AC_TRY_RUN([ /* AF_INET6 available check */
2239#include <sys/types.h>
2240#include <sys/socket.h>
2241main()
2242{
2243 if (socket(AF_INET6, SOCK_STREAM, 0) < 0)
2244 exit(1);
2245 else
2246 exit(0);
2247}
2248],
2249 AC_MSG_RESULT(yes)
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002250 ipv6=yes,
2251 AC_MSG_RESULT(no)
2252 ipv6=no,
2253 AC_MSG_RESULT(no)
2254 ipv6=no
Martin v. Löwisa5f8bb52001-09-05 08:22:34 +00002255)
2256
2257if test "$ipv6" = "yes"; then
2258 AC_MSG_CHECKING(if RFC2553 API is available)
2259 AC_TRY_COMPILE([#include <sys/types.h>
2260#include <netinet/in.h>],
2261 [struct sockaddr_in6 x;
2262x.sin6_scope_id;],
2263 AC_MSG_RESULT(yes)
2264 ipv6=yes,
2265 AC_MSG_RESULT(no, IPv6 disabled)
2266 ipv6=no)
2267fi
2268
2269if test "$ipv6" = "yes"; then
2270 AC_DEFINE(ENABLE_IPV6)
2271fi
2272])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002273
2274ipv6type=unknown
2275ipv6lib=none
2276ipv6trylibc=no
2277
2278if test "$ipv6" = "yes"; then
2279 AC_MSG_CHECKING([ipv6 stack type])
Guido van Rossumb8552162001-09-05 14:58:11 +00002280 for i in inria kame linux-glibc linux-inet6 solaris toshiba v6d zeta;
2281 do
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002282 case $i in
2283 inria)
2284 dnl http://www.kame.net/
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002285 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002286#include <netinet/in.h>
2287#ifdef IPV6_INRIA_VERSION
2288yes
2289#endif],
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002290 [ipv6type=$i])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002291 ;;
2292 kame)
2293 dnl http://www.kame.net/
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002294 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002295#include <netinet/in.h>
2296#ifdef __KAME__
2297yes
2298#endif],
2299 [ipv6type=$i;
2300 ipv6lib=inet6
2301 ipv6libdir=/usr/local/v6/lib
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002302 ipv6trylibc=yes])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002303 ;;
2304 linux-glibc)
2305 dnl http://www.v6.linux.or.jp/
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002306 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002307#include <features.h>
2308#if defined(__GLIBC__) && ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1) || (__GLIBC__ > 2))
2309yes
2310#endif],
2311 [ipv6type=$i;
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002312 ipv6trylibc=yes])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002313 ;;
2314 linux-inet6)
2315 dnl http://www.v6.linux.or.jp/
2316 if test -d /usr/inet6; then
2317 ipv6type=$i
2318 ipv6lib=inet6
2319 ipv6libdir=/usr/inet6/lib
Skip Montanarodecc6a42003-01-01 20:07:49 +00002320 BASECFLAGS="-I/usr/inet6/include $BASECFLAGS"
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002321 fi
2322 ;;
2323 solaris)
2324 if test -f /etc/netconfig; then
2325 if /usr/xpg4/bin/grep -q tcp6 /etc/netconfig; then
2326 ipv6type=$i
2327 ipv6trylibc=yes
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002328 fi
2329 fi
2330 ;;
2331 toshiba)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002332 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002333#include <sys/param.h>
2334#ifdef _TOSHIBA_INET6
2335yes
2336#endif],
2337 [ipv6type=$i;
2338 ipv6lib=inet6;
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002339 ipv6libdir=/usr/local/v6/lib])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002340 ;;
2341 v6d)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002342 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002343#include </usr/local/v6/include/sys/v6config.h>
2344#ifdef __V6D__
2345yes
2346#endif],
2347 [ipv6type=$i;
2348 ipv6lib=v6;
2349 ipv6libdir=/usr/local/v6/lib;
Skip Montanarodecc6a42003-01-01 20:07:49 +00002350 BASECFLAGS="-I/usr/local/v6/include $BASECFLAGS"])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002351 ;;
2352 zeta)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002353 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002354#include <sys/param.h>
2355#ifdef _ZETA_MINAMI_INET6
2356yes
2357#endif],
2358 [ipv6type=$i;
2359 ipv6lib=inet6;
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002360 ipv6libdir=/usr/local/v6/lib])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002361 ;;
2362 esac
2363 if test "$ipv6type" != "unknown"; then
2364 break
2365 fi
2366 done
2367 AC_MSG_RESULT($ipv6type)
2368fi
2369
2370if test "$ipv6" = "yes" -a "$ipv6lib" != "none"; then
2371 if test -d $ipv6libdir -a -f $ipv6libdir/lib$ipv6lib.a; then
2372 LIBS="-L$ipv6libdir -l$ipv6lib $LIBS"
2373 echo "using lib$ipv6lib"
2374 else
2375 if test $ipv6trylibc = "yes"; then
2376 echo "using libc"
2377 else
2378 echo 'Fatal: no $ipv6lib library found. cannot continue.'
2379 echo "You need to fetch lib$ipv6lib.a from appropriate"
2380 echo 'ipv6 kit and compile beforehand.'
2381 exit 1
2382 fi
2383 fi
2384fi
2385
Georg Brandl93de2162008-07-16 02:21:06 +00002386AC_MSG_CHECKING(for OSX 10.5 SDK or later)
2387AC_TRY_COMPILE([#include <Carbon/Carbon.h>], FSIORefNum fRef = 0,
2388 AC_DEFINE(HAVE_OSX105_SDK, 1, Define if compiling using MacOS X 10.5 SDK or later.)
2389 AC_MSG_RESULT(yes),
2390 AC_MSG_RESULT(no)
2391)
2392
Martin v. Löwisa3fb4f72002-06-09 13:33:54 +00002393# Check for --with-doc-strings
2394AC_MSG_CHECKING(for --with-doc-strings)
2395AC_ARG_WITH(doc-strings,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002396 AC_HELP_STRING(--with(out)-doc-strings, disable/enable documentation strings))
Martin v. Löwisa3fb4f72002-06-09 13:33:54 +00002397
2398if test -z "$with_doc_strings"
2399then with_doc_strings="yes"
2400fi
2401if test "$with_doc_strings" != "no"
2402then
2403 AC_DEFINE(WITH_DOC_STRINGS, 1,
2404 [Define if you want documentation strings in extension modules])
2405fi
2406AC_MSG_RESULT($with_doc_strings)
2407
Neil Schemenauera35c6882001-02-27 04:45:05 +00002408# Check for Python-specific malloc support
Martin v. Löwisf30d60e2004-06-08 08:17:44 +00002409AC_MSG_CHECKING(for --with-tsc)
2410AC_ARG_WITH(tsc,
2411[ --with(out)-tsc enable/disable timestamp counter profile], [
2412if test "$withval" != no
2413then
2414 AC_DEFINE(WITH_TSC, 1,
2415 [Define to profile with the Pentium timestamp counter])
2416 AC_MSG_RESULT(yes)
2417else AC_MSG_RESULT(no)
2418fi],
2419[AC_MSG_RESULT(no)])
2420
2421# Check for Python-specific malloc support
Neil Schemenauera35c6882001-02-27 04:45:05 +00002422AC_MSG_CHECKING(for --with-pymalloc)
2423AC_ARG_WITH(pymalloc,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002424 AC_HELP_STRING(--with(out)-pymalloc, disable/enable specialized mallocs))
Neil Schemenauer16c22972002-03-22 15:34:49 +00002425
2426if test -z "$with_pymalloc"
2427then with_pymalloc="yes"
2428fi
2429if test "$with_pymalloc" != "no"
2430then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002431 AC_DEFINE(WITH_PYMALLOC, 1,
2432 [Define if you want to compile in Python-specific mallocs])
Neil Schemenauer16c22972002-03-22 15:34:49 +00002433fi
2434AC_MSG_RESULT($with_pymalloc)
Neil Schemenauera35c6882001-02-27 04:45:05 +00002435
Barry Warsawef82cd72000-06-30 16:21:01 +00002436# Check for --with-wctype-functions
2437AC_MSG_CHECKING(for --with-wctype-functions)
2438AC_ARG_WITH(wctype-functions,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002439 AC_HELP_STRING(--with-wctype-functions, use wctype.h functions),
2440[
Barry Warsawef82cd72000-06-30 16:21:01 +00002441if test "$withval" != no
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002442then
2443 AC_DEFINE(WANT_WCTYPE_FUNCTIONS, 1,
2444 [Define if you want wctype.h functions to be used instead of the
2445 one supplied by Python itself. (see Include/unicodectype.h).])
2446 AC_MSG_RESULT(yes)
Barry Warsawef82cd72000-06-30 16:21:01 +00002447else AC_MSG_RESULT(no)
2448fi],
2449[AC_MSG_RESULT(no)])
2450
Guido van Rossum68242b51996-05-28 22:53:03 +00002451# -I${DLINCLDIR} is added to the compile rule for importdl.o
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002452AC_SUBST(DLINCLDIR)
Guido van Rossum98935bf2001-09-05 19:13:16 +00002453DLINCLDIR=.
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002454
Guido van Rossume97ee181999-12-20 21:27:22 +00002455# the dlopen() function means we might want to use dynload_shlib.o. some
2456# platforms, such as AIX, have dlopen(), but don't want to use it.
Thomas Wouters3a584202000-08-05 23:28:51 +00002457AC_CHECK_FUNCS(dlopen)
Guido van Rossume97ee181999-12-20 21:27:22 +00002458
2459# DYNLOADFILE specifies which dynload_*.o file we will use for dynamic
2460# loading of modules.
2461AC_SUBST(DYNLOADFILE)
2462AC_MSG_CHECKING(DYNLOADFILE)
2463if test -z "$DYNLOADFILE"
2464then
2465 case $ac_sys_system/$ac_sys_release in
Martin v. Löwisc19c5a62003-11-18 20:00:44 +00002466 AIX*) # Use dynload_shlib.c and dlopen() if we have it; otherwise dynload_aix.c
2467 if test "$ac_cv_func_dlopen" = yes
2468 then DYNLOADFILE="dynload_shlib.o"
2469 else DYNLOADFILE="dynload_aix.o"
2470 fi
2471 ;;
Guido van Rossume97ee181999-12-20 21:27:22 +00002472 hp*|HP*) DYNLOADFILE="dynload_hpux.o";;
Thomas Wouters49fd7fa2006-04-21 10:40:58 +00002473 # Use dynload_next.c only on 10.2 and below, which don't have native dlopen()
2474 Darwin/@<:@0156@:>@\..*) DYNLOADFILE="dynload_next.o";;
Martin v. Löwisf90ae202002-06-11 06:22:31 +00002475 atheos*) DYNLOADFILE="dynload_atheos.o";;
Guido van Rossume97ee181999-12-20 21:27:22 +00002476 *)
2477 # use dynload_shlib.c and dlopen() if we have it; otherwise stub
2478 # out any dynamic loading
2479 if test "$ac_cv_func_dlopen" = yes
2480 then DYNLOADFILE="dynload_shlib.o"
2481 else DYNLOADFILE="dynload_stub.o"
2482 fi
2483 ;;
2484 esac
2485fi
2486AC_MSG_RESULT($DYNLOADFILE)
2487if test "$DYNLOADFILE" != "dynload_stub.o"
2488then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002489 AC_DEFINE(HAVE_DYNAMIC_LOADING, 1,
2490 [Defined when any dynamic module loading is enabled.])
Guido van Rossume97ee181999-12-20 21:27:22 +00002491fi
2492
Jack Jansenc49e5b72001-06-19 15:00:23 +00002493# MACHDEP_OBJS can be set to platform-specific object files needed by Python
2494
2495AC_SUBST(MACHDEP_OBJS)
2496AC_MSG_CHECKING(MACHDEP_OBJS)
2497if test -z "$MACHDEP_OBJS"
2498then
Jack Jansenb6e9cad2001-08-15 01:26:28 +00002499 MACHDEP_OBJS=$extra_machdep_objs
2500else
2501 MACHDEP_OBJS="$MACHDEP_OBJS $extra_machdep_objs"
Jack Jansenc49e5b72001-06-19 15:00:23 +00002502fi
Jack Jansenb6e9cad2001-08-15 01:26:28 +00002503AC_MSG_RESULT(MACHDEP_OBJS)
Jack Jansenc49e5b72001-06-19 15:00:23 +00002504
Guido van Rossum627b2d71993-12-24 10:39:16 +00002505# checks for library functions
Martin v. Löwis823725e2008-03-24 13:39:54 +00002506AC_CHECK_FUNCS(alarm setitimer getitimer bind_textdomain_codeset chown \
2507 clock confstr ctermid execv fchmod fchown fork fpathconf ftime ftruncate \
Martin v. Löwis438b5342002-12-27 10:16:42 +00002508 gai_strerror getgroups getlogin getloadavg getpeername getpgid getpid \
Martin v. Löwisc3001752005-01-23 09:27:24 +00002509 getpriority getpwent getspnam getspent getsid getwd \
Martin v. Löwis011e8422009-05-05 04:43:17 +00002510 kill killpg lchmod lchown lstat mbrtowc mkfifo mknod mktime \
Martin v. Löwisa5f09072002-10-11 05:37:59 +00002511 mremap nice pathconf pause plock poll pthread_init \
Guido van Rossum162e38c2003-02-19 15:25:10 +00002512 putenv readlink realpath \
Benjamin Peterson965ce872009-04-05 21:24:58 +00002513 select sem_open sem_timedwait sem_getvalue sem_unlink setegid seteuid \
2514 setgid \
Martin v. Löwis4daacb12003-03-28 18:37:01 +00002515 setlocale setregid setreuid setsid setpgid setpgrp setuid setvbuf snprintf \
Gregory P. Smith6c357262007-09-03 16:44:06 +00002516 sigaction siginterrupt sigrelse strftime strlcpy \
Michael W. Hudson34f20ea2002-05-27 15:08:24 +00002517 sysconf tcgetpgrp tcsetpgrp tempnam timegm times tmpfile tmpnam tmpnam_r \
Martin v. Löwis113a0852009-05-29 17:25:39 +00002518 truncate uname unsetenv utimes waitpid wait3 wait4 \
2519 wcscoll wcsftime wcsxfrm _getpty)
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00002520
Martin v. Löwisc8ad7cc2002-11-11 13:23:45 +00002521# For some functions, having a definition is not sufficient, since
2522# we want to take their address.
2523AC_MSG_CHECKING(for chroot)
2524AC_TRY_COMPILE([#include <unistd.h>], void *x=chroot,
2525 AC_DEFINE(HAVE_CHROOT, 1, Define if you have the 'chroot' function.)
2526 AC_MSG_RESULT(yes),
2527 AC_MSG_RESULT(no)
2528)
2529AC_MSG_CHECKING(for link)
2530AC_TRY_COMPILE([#include <unistd.h>], void *x=link,
2531 AC_DEFINE(HAVE_LINK, 1, Define if you have the 'link' function.)
2532 AC_MSG_RESULT(yes),
2533 AC_MSG_RESULT(no)
2534)
2535AC_MSG_CHECKING(for symlink)
2536AC_TRY_COMPILE([#include <unistd.h>], void *x=symlink,
2537 AC_DEFINE(HAVE_SYMLINK, 1, Define if you have the 'symlink' function.)
2538 AC_MSG_RESULT(yes),
2539 AC_MSG_RESULT(no)
2540)
Martin v. Löwisa64988c2003-09-20 15:30:20 +00002541AC_MSG_CHECKING(for fchdir)
2542AC_TRY_COMPILE([#include <unistd.h>], void *x=fchdir,
2543 AC_DEFINE(HAVE_FCHDIR, 1, Define if you have the 'fchdir' function.)
2544 AC_MSG_RESULT(yes),
2545 AC_MSG_RESULT(no)
2546)
2547AC_MSG_CHECKING(for fsync)
2548AC_TRY_COMPILE([#include <unistd.h>], void *x=fsync,
Skip Montanarod4fa8072003-09-25 14:49:15 +00002549 AC_DEFINE(HAVE_FSYNC, 1, Define if you have the 'fsync' function.)
Martin v. Löwisa64988c2003-09-20 15:30:20 +00002550 AC_MSG_RESULT(yes),
2551 AC_MSG_RESULT(no)
2552)
2553AC_MSG_CHECKING(for fdatasync)
2554AC_TRY_COMPILE([#include <unistd.h>], void *x=fdatasync,
2555 AC_DEFINE(HAVE_FDATASYNC, 1, Define if you have the 'fdatasync' function.)
2556 AC_MSG_RESULT(yes),
2557 AC_MSG_RESULT(no)
2558)
Christian Heimes4fbc72b2008-03-22 00:47:35 +00002559AC_MSG_CHECKING(for epoll)
2560AC_TRY_COMPILE([#include <sys/epoll.h>], void *x=epoll_create,
2561 AC_DEFINE(HAVE_EPOLL, 1, Define if you have the 'epoll' functions.)
2562 AC_MSG_RESULT(yes),
2563 AC_MSG_RESULT(no)
2564)
2565AC_MSG_CHECKING(for kqueue)
2566AC_TRY_COMPILE([
2567#include <sys/types.h>
2568#include <sys/event.h>
2569 ], int x=kqueue(),
2570 AC_DEFINE(HAVE_KQUEUE, 1, Define if you have the 'kqueue' functions.)
2571 AC_MSG_RESULT(yes),
2572 AC_MSG_RESULT(no)
2573)
Martin v. Löwisd5843682002-11-21 20:41:28 +00002574# On some systems (eg. FreeBSD 5), we would find a definition of the
2575# functions ctermid_r, setgroups in the library, but no prototype
2576# (e.g. because we use _XOPEN_SOURCE). See whether we can take their
2577# address to avoid compiler warnings and potential miscompilations
2578# because of the missing prototypes.
2579
2580AC_MSG_CHECKING(for ctermid_r)
2581AC_TRY_COMPILE([
2582#include "confdefs.h"
2583#include <stdio.h>
2584], void* p = ctermid_r,
2585 AC_DEFINE(HAVE_CTERMID_R, 1, Define if you have the 'ctermid_r' function.)
2586 AC_MSG_RESULT(yes),
2587 AC_MSG_RESULT(no)
2588)
2589
Martin v. Löwisf26d63b2003-03-30 17:23:49 +00002590AC_MSG_CHECKING(for flock)
2591AC_TRY_COMPILE([
2592#include "confdefs.h"
2593#include <sys/file.h>
2594], void* p = flock,
2595 AC_DEFINE(HAVE_FLOCK, 1, Define if you have the 'flock' function.)
2596 AC_MSG_RESULT(yes),
2597 AC_MSG_RESULT(no)
2598)
2599
2600AC_MSG_CHECKING(for getpagesize)
2601AC_TRY_COMPILE([
2602#include "confdefs.h"
2603#include <unistd.h>
2604], void* p = getpagesize,
2605 AC_DEFINE(HAVE_GETPAGESIZE, 1, Define if you have the 'getpagesize' function.)
2606 AC_MSG_RESULT(yes),
2607 AC_MSG_RESULT(no)
2608)
2609
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002610dnl check for true
2611AC_CHECK_PROGS(TRUE, true, /bin/true)
2612
Martin v. Löwis95c419b2003-05-03 12:10:48 +00002613dnl On some systems (e.g. Solaris 9), hstrerror and inet_aton are in -lresolv
2614dnl On others, they are in the C library, so we to take no action
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002615AC_CHECK_LIB(c, inet_aton, [$ac_cv_prog_TRUE],
Martin v. Löwis95c419b2003-05-03 12:10:48 +00002616 AC_CHECK_LIB(resolv, inet_aton)
2617)
2618
Christian Heimesd0764e22007-12-04 15:00:33 +00002619# On Tru64, chflags seems to be present, but calling it will
2620# exit Python
Benjamin Peterson08fd6722010-01-30 19:51:43 +00002621AC_CACHE_CHECK([for chflags], [ac_cv_have_chflags], [dnl
2622AC_TRY_RUN([[
Christian Heimesd0764e22007-12-04 15:00:33 +00002623#include <sys/stat.h>
2624#include <unistd.h>
2625int main(int argc, char*argv[])
2626{
2627 if(chflags(argv[0], 0) != 0)
2628 return 1;
2629 return 0;
2630}
Benjamin Peterson08fd6722010-01-30 19:51:43 +00002631]], ac_cv_have_chflags=yes,
2632 ac_cv_have_chflags=no,
2633 ac_cv_have_chflags=cross)
2634])
2635if test "$ac_cv_have_chflags" = cross ; then
2636 AC_CHECK_FUNC([chflags], [ac_cv_have_chflags="yes"], [ac_cv_have_chflags="no"])
2637fi
2638if test "$ac_cv_have_chflags" = yes ; then
2639 AC_DEFINE(HAVE_CHFLAGS, 1, Define to 1 if you have the `chflags' function.)
2640fi
Christian Heimesd0764e22007-12-04 15:00:33 +00002641
Benjamin Peterson08fd6722010-01-30 19:51:43 +00002642AC_CACHE_CHECK([for lchflags], [ac_cv_have_lchflags], [dnl
2643AC_TRY_RUN([[
Christian Heimesd0764e22007-12-04 15:00:33 +00002644#include <sys/stat.h>
2645#include <unistd.h>
2646int main(int argc, char*argv[])
2647{
2648 if(lchflags(argv[0], 0) != 0)
2649 return 1;
2650 return 0;
2651}
Benjamin Peterson08fd6722010-01-30 19:51:43 +00002652]], ac_cv_have_lchflags=yes,
2653 ac_cv_have_lchflags=no,
2654 ac_cv_have_lchflags=cross)
2655])
2656if test "$ac_cv_have_lchflags" = cross ; then
2657 AC_CHECK_FUNC([lchflags], [ac_cv_have_lchflags="yes"], [ac_cv_have_lchflags="no"])
2658fi
2659if test "$ac_cv_have_lchflags" = yes ; then
2660 AC_DEFINE(HAVE_LCHFLAGS, 1, Define to 1 if you have the `lchflags' function.)
2661fi
Christian Heimesd0764e22007-12-04 15:00:33 +00002662
Thomas Wouters0e3f5912006-08-11 14:57:12 +00002663dnl Check if system zlib has *Copy() functions
2664dnl
2665dnl On MacOSX the linker will search for dylibs on the entire linker path
2666dnl before searching for static libraries. setup.py adds -Wl,-search_paths_first
2667dnl to revert to a more traditional unix behaviour and make it possible to
2668dnl override the system libz with a local static library of libz. Temporarily
2669dnl add that flag to our CFLAGS as well to ensure that we check the version
2670dnl of libz that will be used by setup.py.
2671dnl The -L/usr/local/lib is needed as wel to get the same compilation
2672dnl environment as setup.py (and leaving it out can cause configure to use the
2673dnl wrong version of the library)
2674case $ac_sys_system/$ac_sys_release in
2675Darwin/*)
2676 _CUR_CFLAGS="${CFLAGS}"
2677 _CUR_LDFLAGS="${LDFLAGS}"
2678 CFLAGS="${CFLAGS} -Wl,-search_paths_first"
2679 LDFLAGS="${LDFLAGS} -Wl,-search_paths_first -L/usr/local/lib"
2680 ;;
2681esac
2682
2683AC_CHECK_LIB(z, inflateCopy, AC_DEFINE(HAVE_ZLIB_COPY, 1, Define if the zlib library has inflateCopy))
2684
2685case $ac_sys_system/$ac_sys_release in
2686Darwin/*)
2687 CFLAGS="${_CUR_CFLAGS}"
2688 LDFLAGS="${_CUR_LDFLAGS}"
2689 ;;
2690esac
2691
Martin v. Löwise9416172003-05-03 10:12:45 +00002692AC_MSG_CHECKING(for hstrerror)
Martin v. Löwis95c419b2003-05-03 12:10:48 +00002693AC_TRY_LINK([
Martin v. Löwise9416172003-05-03 10:12:45 +00002694#include "confdefs.h"
2695#include <netdb.h>
Martin v. Löwis95c419b2003-05-03 12:10:48 +00002696], void* p = hstrerror; hstrerror(0),
Martin v. Löwise9416172003-05-03 10:12:45 +00002697 AC_DEFINE(HAVE_HSTRERROR, 1, Define if you have the 'hstrerror' function.)
2698 AC_MSG_RESULT(yes),
2699 AC_MSG_RESULT(no)
2700)
2701
2702AC_MSG_CHECKING(for inet_aton)
Martin v. Löwis95c419b2003-05-03 12:10:48 +00002703AC_TRY_LINK([
Martin v. Löwise9416172003-05-03 10:12:45 +00002704#include "confdefs.h"
Martin v. Löwis86d66262006-02-17 08:40:11 +00002705#include <sys/types.h>
Martin v. Löwise9416172003-05-03 10:12:45 +00002706#include <sys/socket.h>
2707#include <netinet/in.h>
2708#include <arpa/inet.h>
Martin v. Löwis95c419b2003-05-03 12:10:48 +00002709], void* p = inet_aton;inet_aton(0,0),
Martin v. Löwise9416172003-05-03 10:12:45 +00002710 AC_DEFINE(HAVE_INET_ATON, 1, Define if you have the 'inet_aton' function.)
2711 AC_MSG_RESULT(yes),
2712 AC_MSG_RESULT(no)
2713)
2714
2715AC_MSG_CHECKING(for inet_pton)
2716AC_TRY_COMPILE([
2717#include "confdefs.h"
Martin v. Löwisf2e488d2003-05-05 22:00:11 +00002718#include <sys/types.h>
Martin v. Löwise9416172003-05-03 10:12:45 +00002719#include <sys/socket.h>
2720#include <netinet/in.h>
2721#include <arpa/inet.h>
2722], void* p = inet_pton,
2723 AC_DEFINE(HAVE_INET_PTON, 1, Define if you have the 'inet_pton' function.)
2724 AC_MSG_RESULT(yes),
2725 AC_MSG_RESULT(no)
2726)
2727
Martin v. Löwisd6640d42003-07-06 09:29:52 +00002728# On some systems, setgroups is in unistd.h, on others, in grp.h
Martin v. Löwisd5843682002-11-21 20:41:28 +00002729AC_MSG_CHECKING(for setgroups)
2730AC_TRY_COMPILE([
2731#include "confdefs.h"
Martin v. Löwisf2e488d2003-05-05 22:00:11 +00002732#include <unistd.h>
Martin v. Löwisd6640d42003-07-06 09:29:52 +00002733#ifdef HAVE_GRP_H
2734#include <grp.h>
2735#endif
Martin v. Löwisd5843682002-11-21 20:41:28 +00002736],
2737void* p = setgroups,
2738 AC_DEFINE(HAVE_SETGROUPS, 1, Define if you have the 'setgroups' function.)
2739 AC_MSG_RESULT(yes),
2740 AC_MSG_RESULT(no)
2741)
2742
Fred Drake8cef4cf2000-06-28 16:40:38 +00002743# check for openpty and forkpty
2744
Martin v. Löwisfd9a72a2006-01-08 10:07:33 +00002745AC_CHECK_FUNCS(openpty,,
2746 AC_CHECK_LIB(util,openpty,
2747 [AC_DEFINE(HAVE_OPENPTY) LIBS="$LIBS -lutil"],
2748 AC_CHECK_LIB(bsd,openpty, [AC_DEFINE(HAVE_OPENPTY) LIBS="$LIBS -lbsd"])
2749 )
2750)
2751AC_CHECK_FUNCS(forkpty,,
2752 AC_CHECK_LIB(util,forkpty,
2753 [AC_DEFINE(HAVE_FORKPTY) LIBS="$LIBS -lutil"],
2754 AC_CHECK_LIB(bsd,forkpty, [AC_DEFINE(HAVE_FORKPTY) LIBS="$LIBS -lbsd"])
2755 )
2756)
Fred Drake8cef4cf2000-06-28 16:40:38 +00002757
Christian Heimesb186d002008-03-18 15:15:01 +00002758# Stuff for expat.
2759AC_CHECK_FUNCS(memmove)
2760
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00002761# check for long file support functions
2762AC_CHECK_FUNCS(fseek64 fseeko fstatvfs ftell64 ftello statvfs)
2763
Christian Heimesb186d002008-03-18 15:15:01 +00002764AC_REPLACE_FUNCS(dup2 getcwd strdup)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002765AC_CHECK_FUNCS(getpgrp,
2766 AC_TRY_COMPILE([#include <unistd.h>],
2767 [getpgrp(0);],
2768 AC_DEFINE(GETPGRP_HAVE_ARG, 1,
2769 [Define if getpgrp() must be called as getpgrp(0).])
2770 )
2771)
Jack Jansen150753c2003-03-29 22:07:47 +00002772AC_CHECK_FUNCS(setpgrp,
2773 AC_TRY_COMPILE([#include <unistd.h>],
2774 [setpgrp(0,0);],
2775 AC_DEFINE(SETPGRP_HAVE_ARG, 1,
2776 [Define if setpgrp() must be called as setpgrp(0, 0).])
2777 )
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002778)
2779AC_CHECK_FUNCS(gettimeofday,
2780 AC_TRY_COMPILE([#include <sys/time.h>],
2781 [gettimeofday((struct timeval*)0,(struct timezone*)0);], ,
2782 AC_DEFINE(GETTIMEOFDAY_NO_TZ, 1,
2783 [Define if gettimeofday() does not have second (timezone) argument
2784 This is the case on Motorola V4 (R40V4.2)])
2785 )
2786)
Guido van Rossum627b2d71993-12-24 10:39:16 +00002787
Martin v. Löwisdbe3f762002-10-10 14:27:30 +00002788AC_MSG_CHECKING(for major, minor, and makedev)
Martin v. Löwise3271202002-11-07 07:42:30 +00002789AC_TRY_LINK([
Neal Norwitz6eb37f02003-02-23 23:28:15 +00002790#if defined(MAJOR_IN_MKDEV)
2791#include <sys/mkdev.h>
2792#elif defined(MAJOR_IN_SYSMACROS)
2793#include <sys/sysmacros.h>
2794#else
2795#include <sys/types.h>
2796#endif
Martin v. Löwisdbe3f762002-10-10 14:27:30 +00002797],[
2798 makedev(major(0),minor(0));
2799],[
2800 AC_DEFINE(HAVE_DEVICE_MACROS, 1,
2801 [Define to 1 if you have the device macros.])
2802 AC_MSG_RESULT(yes)
2803],[
2804 AC_MSG_RESULT(no)
2805])
Martin v. Löwis861a65b2001-10-24 14:36:00 +00002806
2807# On OSF/1 V5.1, getaddrinfo is available, but a define
2808# for [no]getaddrinfo in netdb.h.
2809AC_MSG_CHECKING(for getaddrinfo)
2810AC_TRY_LINK([
Martin v. Löwisc010b6d2001-11-09 17:50:52 +00002811#include <sys/types.h>
Martin v. Löwis861a65b2001-10-24 14:36:00 +00002812#include <sys/socket.h>
2813#include <netdb.h>
Martin v. Löwisc010b6d2001-11-09 17:50:52 +00002814#include <stdio.h>
Martin v. Löwis861a65b2001-10-24 14:36:00 +00002815],[
2816getaddrinfo(NULL, NULL, NULL, NULL);
2817], [
2818AC_MSG_RESULT(yes)
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00002819AC_MSG_CHECKING(getaddrinfo bug)
2820AC_TRY_RUN([
2821#include <sys/types.h>
2822#include <netdb.h>
2823#include <string.h>
2824#include <sys/socket.h>
2825#include <netinet/in.h>
2826
2827main()
2828{
2829 int passive, gaierr, inet4 = 0, inet6 = 0;
2830 struct addrinfo hints, *ai, *aitop;
2831 char straddr[INET6_ADDRSTRLEN], strport[16];
2832
2833 for (passive = 0; passive <= 1; passive++) {
2834 memset(&hints, 0, sizeof(hints));
2835 hints.ai_family = AF_UNSPEC;
2836 hints.ai_flags = passive ? AI_PASSIVE : 0;
2837 hints.ai_socktype = SOCK_STREAM;
Hye-Shik Chang54f94392004-04-14 07:55:31 +00002838 hints.ai_protocol = IPPROTO_TCP;
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00002839 if ((gaierr = getaddrinfo(NULL, "54321", &hints, &aitop)) != 0) {
2840 (void)gai_strerror(gaierr);
2841 goto bad;
2842 }
2843 for (ai = aitop; ai; ai = ai->ai_next) {
2844 if (ai->ai_addr == NULL ||
2845 ai->ai_addrlen == 0 ||
2846 getnameinfo(ai->ai_addr, ai->ai_addrlen,
2847 straddr, sizeof(straddr), strport, sizeof(strport),
2848 NI_NUMERICHOST|NI_NUMERICSERV) != 0) {
2849 goto bad;
2850 }
2851 switch (ai->ai_family) {
2852 case AF_INET:
2853 if (strcmp(strport, "54321") != 0) {
2854 goto bad;
2855 }
2856 if (passive) {
2857 if (strcmp(straddr, "0.0.0.0") != 0) {
2858 goto bad;
2859 }
2860 } else {
2861 if (strcmp(straddr, "127.0.0.1") != 0) {
2862 goto bad;
2863 }
2864 }
2865 inet4++;
2866 break;
2867 case AF_INET6:
2868 if (strcmp(strport, "54321") != 0) {
2869 goto bad;
2870 }
2871 if (passive) {
2872 if (strcmp(straddr, "::") != 0) {
2873 goto bad;
2874 }
2875 } else {
2876 if (strcmp(straddr, "::1") != 0) {
2877 goto bad;
2878 }
2879 }
2880 inet6++;
2881 break;
2882 case AF_UNSPEC:
2883 goto bad;
2884 break;
2885 default:
2886 /* another family support? */
2887 break;
2888 }
2889 }
2890 }
2891
2892 if (!(inet4 == 0 || inet4 == 2))
2893 goto bad;
2894 if (!(inet6 == 0 || inet6 == 2))
2895 goto bad;
2896
2897 if (aitop)
2898 freeaddrinfo(aitop);
2899 exit(0);
2900
2901 bad:
2902 if (aitop)
2903 freeaddrinfo(aitop);
2904 exit(1);
2905}
2906],
2907AC_MSG_RESULT(good)
2908buggygetaddrinfo=no,
2909AC_MSG_RESULT(buggy)
2910buggygetaddrinfo=yes,
2911AC_MSG_RESULT(buggy)
Martin v. Löwis861a65b2001-10-24 14:36:00 +00002912buggygetaddrinfo=yes)], [
2913AC_MSG_RESULT(no)
2914buggygetaddrinfo=yes
2915])
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00002916
2917if test "$buggygetaddrinfo" = "yes"; then
2918 if test "$ipv6" = "yes"; then
2919 echo 'Fatal: You must get working getaddrinfo() function.'
2920 echo ' or you can specify "--disable-ipv6"'.
2921 exit 1
2922 fi
Martin v. Löwis861a65b2001-10-24 14:36:00 +00002923else
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002924 AC_DEFINE(HAVE_GETADDRINFO, 1, [Define if you have the getaddrinfo function.])
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00002925fi
Thomas Woutersb0db85a2001-08-08 10:39:03 +00002926AC_CHECK_FUNCS(getnameinfo)
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00002927
Guido van Rossum627b2d71993-12-24 10:39:16 +00002928# checks for structures
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002929AC_HEADER_TIME
Guido van Rossum627b2d71993-12-24 10:39:16 +00002930AC_STRUCT_TM
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002931AC_STRUCT_TIMEZONE
Martin v. Löwis60a5d722002-10-16 20:28:25 +00002932AC_CHECK_MEMBERS([struct stat.st_rdev])
2933AC_CHECK_MEMBERS([struct stat.st_blksize])
Hye-Shik Chang5f937a72005-06-02 13:09:30 +00002934AC_CHECK_MEMBERS([struct stat.st_flags])
Martin v. Löwisebd9d5b2005-08-09 15:00:59 +00002935AC_CHECK_MEMBERS([struct stat.st_gen])
2936AC_CHECK_MEMBERS([struct stat.st_birthtime])
Guido van Rossum98bf58f2001-10-18 20:34:25 +00002937AC_STRUCT_ST_BLOCKS
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002938
2939AC_MSG_CHECKING(for time.h that defines altzone)
2940AC_CACHE_VAL(ac_cv_header_time_altzone,
2941[AC_TRY_COMPILE([#include <time.h>], [return altzone;],
2942 ac_cv_header_time_altzone=yes,
2943 ac_cv_header_time_altzone=no)])
2944AC_MSG_RESULT($ac_cv_header_time_altzone)
2945if test $ac_cv_header_time_altzone = yes; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002946 AC_DEFINE(HAVE_ALTZONE, 1, [Define this if your time.h defines altzone.])
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002947fi
2948
Guido van Rossum5739e7e1995-01-20 16:50:53 +00002949was_it_defined=no
2950AC_MSG_CHECKING(whether sys/select.h and sys/time.h may both be included)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002951AC_TRY_COMPILE([
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002952#include <sys/types.h>
2953#include <sys/select.h>
2954#include <sys/time.h>
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002955], [;], [
2956 AC_DEFINE(SYS_SELECT_WITH_SYS_TIME, 1,
2957 [Define if you can safely include both <sys/select.h> and <sys/time.h>
2958 (which you can't on SCO ODT 3.0).])
2959 was_it_defined=yes
2960])
Guido van Rossum5739e7e1995-01-20 16:50:53 +00002961AC_MSG_RESULT($was_it_defined)
Guido van Rossum627b2d71993-12-24 10:39:16 +00002962
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00002963AC_MSG_CHECKING(for addrinfo)
2964AC_CACHE_VAL(ac_cv_struct_addrinfo,
2965AC_TRY_COMPILE([
2966# include <netdb.h>],
2967 [struct addrinfo a],
2968 ac_cv_struct_addrinfo=yes,
2969 ac_cv_struct_addrinfo=no))
2970AC_MSG_RESULT($ac_cv_struct_addrinfo)
2971if test $ac_cv_struct_addrinfo = yes; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002972 AC_DEFINE(HAVE_ADDRINFO, 1, [struct addrinfo (netdb.h)])
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00002973fi
2974
2975AC_MSG_CHECKING(for sockaddr_storage)
2976AC_CACHE_VAL(ac_cv_struct_sockaddr_storage,
2977AC_TRY_COMPILE([
2978# include <sys/types.h>
2979# include <sys/socket.h>],
2980 [struct sockaddr_storage s],
2981 ac_cv_struct_sockaddr_storage=yes,
2982 ac_cv_struct_sockaddr_storage=no))
2983AC_MSG_RESULT($ac_cv_struct_sockaddr_storage)
2984if test $ac_cv_struct_sockaddr_storage = yes; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002985 AC_DEFINE(HAVE_SOCKADDR_STORAGE, 1, [struct sockaddr_storage (sys/socket.h)])
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00002986fi
2987
Guido van Rossum627b2d71993-12-24 10:39:16 +00002988# checks for compiler characteristics
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002989
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002990AC_C_CHAR_UNSIGNED
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002991AC_C_CONST
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002992
Guido van Rossum5739e7e1995-01-20 16:50:53 +00002993works=no
2994AC_MSG_CHECKING(for working volatile)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002995AC_TRY_COMPILE([],[volatile int x; x = 0;], works=yes,
2996 AC_DEFINE(volatile, [], [Define to empty if the keyword does not work.])
2997)
Guido van Rossum5739e7e1995-01-20 16:50:53 +00002998AC_MSG_RESULT($works)
Guido van Rossumdabb11b1994-10-11 15:04:27 +00002999
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003000works=no
3001AC_MSG_CHECKING(for working signed char)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003002AC_TRY_COMPILE([], [signed char c;], works=yes,
3003 AC_DEFINE(signed, [], [Define to empty if the keyword does not work.])
3004)
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003005AC_MSG_RESULT($works)
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003006
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003007have_prototypes=no
3008AC_MSG_CHECKING(for prototypes)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003009AC_TRY_COMPILE([int foo(int x) { return 0; }], [return foo(10);],[
3010 AC_DEFINE(HAVE_PROTOTYPES, 1,
3011 [Define if your compiler supports function prototype])
3012 have_prototypes=yes
3013])
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003014AC_MSG_RESULT($have_prototypes)
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003015
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003016works=no
3017AC_MSG_CHECKING(for variable length prototypes and stdarg.h)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003018AC_TRY_COMPILE([
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003019#include <stdarg.h>
Guido van Rossum3f13e481996-08-30 20:58:11 +00003020int foo(int x, ...) {
3021 va_list va;
3022 va_start(va, x);
3023 va_arg(va, int);
3024 va_arg(va, char *);
3025 va_arg(va, double);
3026 return 0;
3027}
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003028], [return foo(10, "", 3.14);], [
3029 AC_DEFINE(HAVE_STDARG_PROTOTYPES, 1,
3030 [Define if your compiler supports variable length function prototypes
3031 (e.g. void fprintf(FILE *, char *, ...);) *and* <stdarg.h>])
3032 works=yes
3033])
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003034AC_MSG_RESULT($works)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003035
Dave Cole331708b2004-08-09 04:51:41 +00003036# check for socketpair
3037AC_MSG_CHECKING(for socketpair)
3038AC_TRY_COMPILE([
3039#include <sys/types.h>
3040#include <sys/socket.h>
3041], void *x=socketpair,
3042 AC_DEFINE(HAVE_SOCKETPAIR, 1, Define if you have the 'socketpair' function.)
3043 AC_MSG_RESULT(yes),
3044 AC_MSG_RESULT(no)
3045)
3046
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003047# check if sockaddr has sa_len member
3048AC_MSG_CHECKING(if sockaddr has sa_len member)
3049AC_TRY_COMPILE([#include <sys/types.h>
3050#include <sys/socket.h>],
3051[struct sockaddr x;
3052x.sa_len = 0;],
3053 AC_MSG_RESULT(yes)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003054 AC_DEFINE(HAVE_SOCKADDR_SA_LEN, 1, [Define if sockaddr has sa_len member]),
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003055 AC_MSG_RESULT(no))
3056
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003057va_list_is_array=no
3058AC_MSG_CHECKING(whether va_list is an array)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003059AC_TRY_COMPILE([
3060#ifdef HAVE_STDARG_PROTOTYPES
3061#include <stdarg.h>
3062#else
3063#include <varargs.h>
3064#endif
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003065], [va_list list1, list2; list1 = list2;], , [
3066 AC_DEFINE(VA_LIST_IS_ARRAY, 1, [Define if a va_list is an array of some kind])
3067 va_list_is_array=yes
3068])
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003069AC_MSG_RESULT($va_list_is_array)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003070
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003071# sigh -- gethostbyname_r is a mess; it can have 3, 5 or 6 arguments :-(
Martin v. Löwis11437992002-04-12 09:54:03 +00003072AH_TEMPLATE(HAVE_GETHOSTBYNAME_R,
3073 [Define this if you have some version of gethostbyname_r()])
3074
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003075AC_CHECK_FUNC(gethostbyname_r, [
3076 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
3077 AC_MSG_CHECKING([gethostbyname_r with 6 args])
3078 OLD_CFLAGS=$CFLAGS
3079 CFLAGS="$CFLAGS $MY_CPPFLAGS $MY_THREAD_CPPFLAGS $MY_CFLAGS"
3080 AC_TRY_COMPILE([
3081# include <netdb.h>
3082 ], [
3083 char *name;
3084 struct hostent *he, *res;
3085 char buffer[2048];
3086 int buflen = 2048;
3087 int h_errnop;
3088
3089 (void) gethostbyname_r(name, he, buffer, buflen, &res, &h_errnop)
3090 ], [
Guido van Rossum8db7d8b1999-03-23 16:40:33 +00003091 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003092 AC_DEFINE(HAVE_GETHOSTBYNAME_R_6_ARG, 1,
3093 [Define this if you have the 6-arg version of gethostbyname_r().])
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003094 AC_MSG_RESULT(yes)
3095 ], [
3096 AC_MSG_RESULT(no)
3097 AC_MSG_CHECKING([gethostbyname_r with 5 args])
3098 AC_TRY_COMPILE([
3099# include <netdb.h>
3100 ], [
3101 char *name;
3102 struct hostent *he;
3103 char buffer[2048];
3104 int buflen = 2048;
3105 int h_errnop;
3106
3107 (void) gethostbyname_r(name, he, buffer, buflen, &h_errnop)
3108 ], [
Guido van Rossum8db7d8b1999-03-23 16:40:33 +00003109 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003110 AC_DEFINE(HAVE_GETHOSTBYNAME_R_5_ARG, 1,
3111 [Define this if you have the 5-arg version of gethostbyname_r().])
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003112 AC_MSG_RESULT(yes)
3113 ], [
3114 AC_MSG_RESULT(no)
3115 AC_MSG_CHECKING([gethostbyname_r with 3 args])
3116 AC_TRY_COMPILE([
3117# include <netdb.h>
3118 ], [
3119 char *name;
3120 struct hostent *he;
3121 struct hostent_data data;
3122
3123 (void) gethostbyname_r(name, he, &data);
3124 ], [
Guido van Rossum8db7d8b1999-03-23 16:40:33 +00003125 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003126 AC_DEFINE(HAVE_GETHOSTBYNAME_R_3_ARG, 1,
3127 [Define this if you have the 3-arg version of gethostbyname_r().])
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003128 AC_MSG_RESULT(yes)
3129 ], [
3130 AC_MSG_RESULT(no)
3131 ])
3132 ])
3133 ])
3134 CFLAGS=$OLD_CFLAGS
3135], [
Thomas Wouters3a584202000-08-05 23:28:51 +00003136 AC_CHECK_FUNCS(gethostbyname)
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003137])
3138AC_SUBST(HAVE_GETHOSTBYNAME_R_6_ARG)
3139AC_SUBST(HAVE_GETHOSTBYNAME_R_5_ARG)
3140AC_SUBST(HAVE_GETHOSTBYNAME_R_3_ARG)
Guido van Rossum8db7d8b1999-03-23 16:40:33 +00003141AC_SUBST(HAVE_GETHOSTBYNAME_R)
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003142AC_SUBST(HAVE_GETHOSTBYNAME)
3143
Guido van Rossum627b2d71993-12-24 10:39:16 +00003144# checks for system services
3145# (none yet)
3146
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003147# Linux requires this for correct f.p. operations
Jeremy Hyltonbe28f5b2000-07-27 21:03:04 +00003148AC_CHECK_FUNC(__fpu_control,
3149 [],
3150 [AC_CHECK_LIB(ieee, __fpu_control)
3151])
Guido van Rossum627b2d71993-12-24 10:39:16 +00003152
Guido van Rossum93274221997-05-09 02:42:00 +00003153# Check for --with-fpectl
Guido van Rossum93274221997-05-09 02:42:00 +00003154AC_MSG_CHECKING(for --with-fpectl)
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00003155AC_ARG_WITH(fpectl,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003156 AC_HELP_STRING(--with-fpectl, enable SIGFPE catching),
3157[
Guido van Rossum93274221997-05-09 02:42:00 +00003158if test "$withval" != no
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003159then
3160 AC_DEFINE(WANT_SIGFPE_HANDLER, 1,
3161 [Define if you want SIGFPE handled (see Include/pyfpe.h).])
3162 AC_MSG_RESULT(yes)
Guido van Rossum93274221997-05-09 02:42:00 +00003163else AC_MSG_RESULT(no)
Guido van Rossumef2255b2000-03-10 22:30:29 +00003164fi],
3165[AC_MSG_RESULT(no)])
Guido van Rossum93274221997-05-09 02:42:00 +00003166
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003167# check for --with-libm=...
3168AC_SUBST(LIBM)
Guido van Rossum4b6b5791996-09-09 20:09:34 +00003169case $ac_sys_system in
Guido van Rossum3dc0a512000-10-05 18:00:06 +00003170Darwin) ;;
Guido van Rossum4b6b5791996-09-09 20:09:34 +00003171*) LIBM=-lm
3172esac
Guido van Rossum93274221997-05-09 02:42:00 +00003173AC_MSG_CHECKING(for --with-libm=STRING)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003174AC_ARG_WITH(libm,
3175 AC_HELP_STRING(--with-libm=STRING, math library),
3176[
Guido van Rossum93274221997-05-09 02:42:00 +00003177if test "$withval" = no
3178then LIBM=
3179 AC_MSG_RESULT(force LIBM empty)
3180elif test "$withval" != yes
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003181then LIBM=$withval
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003182 AC_MSG_RESULT(set LIBM="$withval")
3183else AC_MSG_ERROR([proper usage is --with-libm=STRING])
Guido van Rossum93274221997-05-09 02:42:00 +00003184fi],
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003185[AC_MSG_RESULT(default LIBM="$LIBM")])
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003186
3187# check for --with-libc=...
3188AC_SUBST(LIBC)
Guido van Rossum93274221997-05-09 02:42:00 +00003189AC_MSG_CHECKING(for --with-libc=STRING)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003190AC_ARG_WITH(libc,
3191 AC_HELP_STRING(--with-libc=STRING, C library),
3192[
Guido van Rossum93274221997-05-09 02:42:00 +00003193if test "$withval" = no
3194then LIBC=
3195 AC_MSG_RESULT(force LIBC empty)
3196elif test "$withval" != yes
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003197then LIBC=$withval
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003198 AC_MSG_RESULT(set LIBC="$withval")
3199else AC_MSG_ERROR([proper usage is --with-libc=STRING])
Guido van Rossum93274221997-05-09 02:42:00 +00003200fi],
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003201[AC_MSG_RESULT(default LIBC="$LIBC")])
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003202
Mark Dickinsonb08a53a2009-04-16 19:52:09 +00003203# **************************************************
3204# * Check for various properties of floating point *
3205# **************************************************
Christian Heimes81ee3ef2008-05-04 22:42:01 +00003206
Mark Dickinsonb08a53a2009-04-16 19:52:09 +00003207AC_MSG_CHECKING(whether C doubles are little-endian IEEE 754 binary64)
3208AC_CACHE_VAL(ac_cv_little_endian_double, [
3209AC_TRY_RUN([
3210#include <string.h>
3211int main() {
3212 double x = 9006104071832581.0;
3213 if (memcmp(&x, "\x05\x04\x03\x02\x01\xff\x3f\x43", 8) == 0)
3214 return 0;
3215 else
3216 return 1;
3217}
3218],
3219ac_cv_little_endian_double=yes,
3220ac_cv_little_endian_double=no,
3221ac_cv_little_endian_double=no)])
3222AC_MSG_RESULT($ac_cv_little_endian_double)
3223if test "$ac_cv_little_endian_double" = yes
3224then
3225 AC_DEFINE(DOUBLE_IS_LITTLE_ENDIAN_IEEE754, 1,
3226 [Define if C doubles are 64-bit IEEE 754 binary format, stored
3227 with the least significant byte first])
3228fi
3229
3230AC_MSG_CHECKING(whether C doubles are big-endian IEEE 754 binary64)
3231AC_CACHE_VAL(ac_cv_big_endian_double, [
3232AC_TRY_RUN([
3233#include <string.h>
3234int main() {
3235 double x = 9006104071832581.0;
3236 if (memcmp(&x, "\x43\x3f\xff\x01\x02\x03\x04\x05", 8) == 0)
3237 return 0;
3238 else
3239 return 1;
3240}
3241],
3242ac_cv_big_endian_double=yes,
3243ac_cv_big_endian_double=no,
3244ac_cv_big_endian_double=no)])
3245AC_MSG_RESULT($ac_cv_big_endian_double)
3246if test "$ac_cv_big_endian_double" = yes
3247then
3248 AC_DEFINE(DOUBLE_IS_BIG_ENDIAN_IEEE754, 1,
3249 [Define if C doubles are 64-bit IEEE 754 binary format, stored
3250 with the most significant byte first])
3251fi
3252
3253# Some ARM platforms use a mixed-endian representation for doubles.
3254# While Python doesn't currently have full support for these platforms
3255# (see e.g., issue 1762561), we can at least make sure that float <-> string
3256# conversions work.
3257AC_MSG_CHECKING(whether C doubles are ARM mixed-endian IEEE 754 binary64)
3258AC_CACHE_VAL(ac_cv_mixed_endian_double, [
3259AC_TRY_RUN([
3260#include <string.h>
3261int main() {
3262 double x = 9006104071832581.0;
3263 if (memcmp(&x, "\x01\xff\x3f\x43\x05\x04\x03\x02", 8) == 0)
3264 return 0;
3265 else
3266 return 1;
3267}
3268],
3269ac_cv_mixed_endian_double=yes,
3270ac_cv_mixed_endian_double=no,
3271ac_cv_mixed_endian_double=no)])
3272AC_MSG_RESULT($ac_cv_mixed_endian_double)
3273if test "$ac_cv_mixed_endian_double" = yes
3274then
3275 AC_DEFINE(DOUBLE_IS_ARM_MIXED_ENDIAN_IEEE754, 1,
3276 [Define if C doubles are 64-bit IEEE 754 binary format, stored
3277 in ARM mixed-endian order (byte order 45670123)])
3278fi
3279
Mark Dickinson7abf8d42009-04-18 20:17:52 +00003280# The short float repr introduced in Python 3.1 requires the
3281# correctly-rounded string <-> double conversion functions from
3282# Python/dtoa.c, which in turn require that the FPU uses 53-bit
3283# rounding; this is a problem on x86, where the x87 FPU has a default
3284# rounding precision of 64 bits. For gcc/x86, we try to fix this by
3285# using inline assembler to get and set the x87 FPU control word.
Mark Dickinsonb08a53a2009-04-16 19:52:09 +00003286if test "$GCC" = yes && test -n "`$CC -dM -E - </dev/null | grep i386`"
3287then
Mark Dickinson7abf8d42009-04-18 20:17:52 +00003288 # Check that it's okay to use gcc inline assembler to get and set
3289 # x87 control word. It should be, but you never know...
3290 AC_MSG_CHECKING(whether we can use gcc inline assembler to get and set x87 control word)
3291 AC_TRY_COMPILE([], [
3292 unsigned short cw;
3293 __asm__ __volatile__ ("fnstcw %0" : "=m" (cw));
3294 __asm__ __volatile__ ("fldcw %0" : : "m" (cw));
3295 ],
3296 [have_gcc_asm_for_x87=yes], [have_gcc_asm_for_x87=no])
3297 AC_MSG_RESULT($have_gcc_asm_for_x87)
3298 if test "$have_gcc_asm_for_x87" = yes
Mark Dickinsonb08a53a2009-04-16 19:52:09 +00003299 then
Mark Dickinson7abf8d42009-04-18 20:17:52 +00003300 AC_DEFINE(HAVE_GCC_ASM_FOR_X87, 1,
3301 [Define if we can use gcc inline assembler to get and set x87 control word])
Mark Dickinsonb08a53a2009-04-16 19:52:09 +00003302 fi
3303fi
Christian Heimes81ee3ef2008-05-04 22:42:01 +00003304
Mark Dickinson3dc7c6a2009-01-04 15:09:02 +00003305# Detect whether system arithmetic is subject to x87-style double
3306# rounding issues. The result of this test has little meaning on non
3307# IEEE 754 platforms. On IEEE 754, test should return 1 if rounding
3308# mode is round-to-nearest and double rounding issues are present, and
3309# 0 otherwise. See http://bugs.python.org/issue2937 for more info.
3310AC_MSG_CHECKING(for x87-style double rounding)
Mark Dickinsonb08a53a2009-04-16 19:52:09 +00003311# $BASECFLAGS may affect the result
3312ac_save_cc="$CC"
3313CC="$CC $BASECFLAGS"
Mark Dickinson3dc7c6a2009-01-04 15:09:02 +00003314AC_TRY_RUN([
3315#include <stdlib.h>
3316#include <math.h>
3317int main() {
3318 volatile double x, y, z;
3319 /* 1./(1-2**-53) -> 1+2**-52 (correct), 1.0 (double rounding) */
3320 x = 0.99999999999999989; /* 1-2**-53 */
3321 y = 1./x;
3322 if (y != 1.)
3323 exit(0);
3324 /* 1e16+2.99999 -> 1e16+2. (correct), 1e16+4. (double rounding) */
3325 x = 1e16;
3326 y = 2.99999;
3327 z = x + y;
3328 if (z != 1e16+4.)
3329 exit(0);
3330 /* both tests show evidence of double rounding */
3331 exit(1);
3332}
3333],
3334ac_cv_x87_double_rounding=no,
3335ac_cv_x87_double_rounding=yes,
Mark Dickinsonb08a53a2009-04-16 19:52:09 +00003336ac_cv_x87_double_rounding=no)
3337CC="$ac_save_cc"
Mark Dickinson3dc7c6a2009-01-04 15:09:02 +00003338AC_MSG_RESULT($ac_cv_x87_double_rounding)
3339if test "$ac_cv_x87_double_rounding" = yes
3340then
3341 AC_DEFINE(X87_DOUBLE_ROUNDING, 1,
3342 [Define if arithmetic is subject to x87-style double rounding issue])
3343fi
3344
Mark Dickinsonb08a53a2009-04-16 19:52:09 +00003345# ************************************
3346# * Check for mathematical functions *
3347# ************************************
3348
3349LIBS_SAVE=$LIBS
3350LIBS="$LIBS $LIBM"
3351
Christian Heimes81ee3ef2008-05-04 22:42:01 +00003352# On FreeBSD 6.2, it appears that tanh(-0.) returns 0. instead of
3353# -0. on some architectures.
3354AC_MSG_CHECKING(whether tanh preserves the sign of zero)
3355AC_CACHE_VAL(ac_cv_tanh_preserves_zero_sign, [
3356AC_TRY_RUN([
3357#include <math.h>
3358#include <stdlib.h>
3359int main() {
3360 /* return 0 if either negative zeros don't exist
3361 on this platform or if negative zeros exist
3362 and tanh(-0.) == -0. */
3363 if (atan2(0., -1.) == atan2(-0., -1.) ||
3364 atan2(tanh(-0.), -1.) == atan2(-0., -1.)) exit(0);
3365 else exit(1);
3366}
3367],
3368ac_cv_tanh_preserves_zero_sign=yes,
3369ac_cv_tanh_preserves_zero_sign=no,
3370ac_cv_tanh_preserves_zero_sign=no)])
3371AC_MSG_RESULT($ac_cv_tanh_preserves_zero_sign)
3372if test "$ac_cv_tanh_preserves_zero_sign" = yes
3373then
3374 AC_DEFINE(TANH_PRESERVES_ZERO_SIGN, 1,
3375 [Define if tanh(-0.) is -0., or if platform doesn't have signed zeros])
3376fi
3377
Mark Dickinsonf2537862009-04-18 13:58:18 +00003378AC_CHECK_FUNCS([acosh asinh atanh copysign expm1 finite hypot log1p round])
Mark Dickinson3dc7c6a2009-01-04 15:09:02 +00003379AC_CHECK_DECLS([isinf, isnan, isfinite], [], [], [[#include <math.h>]])
Christian Heimes99170a52007-12-19 02:07:34 +00003380
Guido van Rossumaf5b83e1995-01-04 19:02:35 +00003381LIBS=$LIBS_SAVE
3382
Mark Dickinson875ada42009-11-28 12:52:39 +00003383# For multiprocessing module, check that sem_open
3384# actually works. For FreeBSD versions <= 7.2,
3385# the kernel module that provides POSIX semaphores
3386# isn't loaded by default, so an attempt to call
3387# sem_open results in a 'Signal 12' error.
3388AC_MSG_CHECKING(whether POSIX semaphores are enabled)
3389AC_CACHE_VAL(ac_cv_posix_semaphores_enabled,
3390AC_TRY_RUN([
3391#include <unistd.h>
3392#include <fcntl.h>
3393#include <stdio.h>
3394#include <semaphore.h>
3395#include <sys/stat.h>
3396
3397int main(void) {
3398 sem_t *a = sem_open("/autoconf", O_CREAT, S_IRUSR|S_IWUSR, 0);
3399 if (a == SEM_FAILED) {
3400 perror("sem_open");
3401 return 1;
3402 }
3403 sem_close(a);
Mark Dickinson62eda4d2009-12-13 21:18:16 +00003404 sem_unlink("/autoconf");
Mark Dickinson875ada42009-11-28 12:52:39 +00003405 return 0;
3406}
3407], ac_cv_posix_semaphores_enabled=yes,
3408 ac_cv_posix_semaphores_enabled=no,
3409 ac_cv_posix_semaphores_enabled=yes)
3410)
3411AC_MSG_RESULT($ac_cv_posix_semaphores_enabled)
3412if test $ac_cv_posix_semaphores_enabled = no
3413then
3414 AC_DEFINE(POSIX_SEMAPHORES_NOT_ENABLED, 1,
3415 [Define if POSIX semaphores aren't enabled on your system])
3416fi
3417
Mark Dickinson10683072009-04-18 21:18:19 +00003418# Multiprocessing check for broken sem_getvalue
3419AC_MSG_CHECKING(for broken sem_getvalue)
3420AC_TRY_RUN([
3421#include <unistd.h>
3422#include <fcntl.h>
3423#include <stdio.h>
3424#include <semaphore.h>
3425#include <sys/stat.h>
3426
3427int main(void){
Mark Dickinson62eda4d2009-12-13 21:18:16 +00003428 sem_t *a = sem_open("/autocftw", O_CREAT, S_IRUSR|S_IWUSR, 0);
Mark Dickinson10683072009-04-18 21:18:19 +00003429 int count;
3430 int res;
3431 if(a==SEM_FAILED){
3432 perror("sem_open");
3433 return 1;
3434
3435 }
3436 res = sem_getvalue(a, &count);
3437 sem_close(a);
Mark Dickinson62eda4d2009-12-13 21:18:16 +00003438 sem_unlink("/autocftw");
Mark Dickinson10683072009-04-18 21:18:19 +00003439 return res==-1 ? 1 : 0;
3440}
3441]
3442,AC_MSG_RESULT(no),
3443 AC_MSG_RESULT(yes)
3444 AC_DEFINE(HAVE_BROKEN_SEM_GETVALUE, 1, define to 1 if your sem_getvalue is broken.)
3445)
3446
Mark Dickinsonbd792642009-03-18 20:06:12 +00003447# determine what size digit to use for Python's longs
3448AC_MSG_CHECKING([digit size for Python's longs])
3449AC_ARG_ENABLE(big-digits,
3450AC_HELP_STRING([--enable-big-digits@<:@=BITS@:>@],[use big digits for Python longs [[BITS=30]]]),
3451[case $enable_big_digits in
3452yes)
3453 enable_big_digits=30 ;;
3454no)
3455 enable_big_digits=15 ;;
3456[15|30])
3457 ;;
3458*)
3459 AC_MSG_ERROR([bad value $enable_big_digits for --enable-big-digits; value should be 15 or 30]) ;;
3460esac
3461AC_MSG_RESULT($enable_big_digits)
3462AC_DEFINE_UNQUOTED(PYLONG_BITS_IN_DIGIT, $enable_big_digits, [Define as the preferred size in bits of long digits])
3463],
3464[AC_MSG_RESULT(no value specified)])
3465
Guido van Rossumef2255b2000-03-10 22:30:29 +00003466# check for wchar.h
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003467AC_CHECK_HEADER(wchar.h, [
3468 AC_DEFINE(HAVE_WCHAR_H, 1,
3469 [Define if the compiler provides a wchar.h header file.])
3470 wchar_h="yes"
3471],
Guido van Rossumef2255b2000-03-10 22:30:29 +00003472wchar_h="no"
3473)
3474
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003475# determine wchar_t size
3476if test "$wchar_h" = yes
3477then
Guido van Rossum67b26592001-10-20 14:21:45 +00003478 AC_CHECK_SIZEOF(wchar_t, 4, [#include <wchar.h>])
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003479fi
3480
Martin v. Löwisfa3bdea2003-09-04 18:50:54 +00003481AC_MSG_CHECKING(for UCS-4 tcl)
3482have_ucs4_tcl=no
3483AC_TRY_COMPILE([
3484#include <tcl.h>
3485#if TCL_UTF_MAX != 6
3486# error "NOT UCS4_TCL"
3487#endif], [], [
3488 AC_DEFINE(HAVE_UCS4_TCL, 1, [Define this if you have tcl and TCL_UTF_MAX==6])
3489 have_ucs4_tcl=yes
3490])
3491AC_MSG_RESULT($have_ucs4_tcl)
3492
Marc-André Lemburgd7160f82003-09-22 11:14:40 +00003493# check whether wchar_t is signed or not
3494if test "$wchar_h" = yes
3495then
3496 # check whether wchar_t is signed or not
3497 AC_MSG_CHECKING(whether wchar_t is signed)
3498 AC_CACHE_VAL(ac_cv_wchar_t_signed, [
3499 AC_TRY_RUN([
3500 #include <wchar.h>
3501 int main()
3502 {
Thomas Wouters49fd7fa2006-04-21 10:40:58 +00003503 /* Success: exit code 0 */
3504 exit((((wchar_t) -1) < ((wchar_t) 0)) ? 0 : 1);
Marc-André Lemburgd7160f82003-09-22 11:14:40 +00003505 }
3506 ],
3507 ac_cv_wchar_t_signed=yes,
3508 ac_cv_wchar_t_signed=no,
3509 ac_cv_wchar_t_signed=yes)])
3510 AC_MSG_RESULT($ac_cv_wchar_t_signed)
3511fi
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003512
Georg Brandl52d168a2008-01-07 18:10:24 +00003513AC_MSG_CHECKING(what type to use for str)
3514AC_ARG_WITH(wide-unicode,
3515 AC_HELP_STRING(--with-wide-unicode, Use 4-byte Unicode characters (default is 2 bytes)),
3516[
3517if test "$withval" != no
3518then unicode_size="4"
3519else unicode_size="2"
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003520fi
Georg Brandl52d168a2008-01-07 18:10:24 +00003521],
3522[
3523case "$have_ucs4_tcl" in
3524 yes) unicode_size="4" ;;
3525 *) unicode_size="2" ;;
3526esac
3527])
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003528
Martin v. Löwis0036cba2002-04-12 09:58:45 +00003529AH_TEMPLATE(Py_UNICODE_SIZE,
3530 [Define as the size of the unicode type.])
Georg Brandl52d168a2008-01-07 18:10:24 +00003531case "$unicode_size" in
3532 4) AC_DEFINE(Py_UNICODE_SIZE, 4) ;;
3533 *) AC_DEFINE(Py_UNICODE_SIZE, 2) ;;
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003534esac
3535
Martin v. Löwis11437992002-04-12 09:54:03 +00003536AH_TEMPLATE(PY_UNICODE_TYPE,
3537 [Define as the integral type used for Unicode representation.])
Martin v. Löwis0036cba2002-04-12 09:58:45 +00003538
Georg Brandl52d168a2008-01-07 18:10:24 +00003539# wchar_t is only usable if it maps to an unsigned type
3540if test "$unicode_size" = "$ac_cv_sizeof_wchar_t" \
Matthias Klose7dbeed72004-12-24 08:22:17 +00003541 -a "$ac_cv_wchar_t_signed" = "no"
Georg Brandl52d168a2008-01-07 18:10:24 +00003542then
3543 PY_UNICODE_TYPE="wchar_t"
3544 AC_DEFINE(HAVE_USABLE_WCHAR_T, 1,
3545 [Define if you have a useable wchar_t type defined in wchar.h; useable
3546 means wchar_t must be an unsigned type with at least 16 bits. (see
3547 Include/unicodeobject.h).])
3548 AC_DEFINE(PY_UNICODE_TYPE,wchar_t)
3549elif test "$ac_cv_sizeof_short" = "$unicode_size"
3550then
3551 PY_UNICODE_TYPE="unsigned short"
3552 AC_DEFINE(PY_UNICODE_TYPE,unsigned short)
3553elif test "$ac_cv_sizeof_long" = "$unicode_size"
3554then
3555 PY_UNICODE_TYPE="unsigned long"
3556 AC_DEFINE(PY_UNICODE_TYPE,unsigned long)
3557else
3558 PY_UNICODE_TYPE="no type found"
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003559fi
Georg Brandl52d168a2008-01-07 18:10:24 +00003560AC_MSG_RESULT($PY_UNICODE_TYPE)
Guido van Rossumef2255b2000-03-10 22:30:29 +00003561
3562# check for endianness
3563AC_C_BIGENDIAN
3564
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00003565# Check whether right shifting a negative integer extends the sign bit
3566# or fills with zeros (like the Cray J90, according to Tim Peters).
3567AC_MSG_CHECKING(whether right shift extends the sign bit)
Vladimir Marangozova6180282000-07-12 05:05:06 +00003568AC_CACHE_VAL(ac_cv_rshift_extends_sign, [
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00003569AC_TRY_RUN([
3570int main()
3571{
Vladimir Marangozova6180282000-07-12 05:05:06 +00003572 exit(((-1)>>3 == -1) ? 0 : 1);
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00003573}
Guido van Rossum3065c942001-09-17 04:03:14 +00003574],
3575ac_cv_rshift_extends_sign=yes,
3576ac_cv_rshift_extends_sign=no,
3577ac_cv_rshift_extends_sign=yes)])
Vladimir Marangozova6180282000-07-12 05:05:06 +00003578AC_MSG_RESULT($ac_cv_rshift_extends_sign)
3579if test "$ac_cv_rshift_extends_sign" = no
3580then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003581 AC_DEFINE(SIGNED_RIGHT_SHIFT_ZERO_FILLS, 1,
3582 [Define if i>>j for signed int i does not extend the sign bit
3583 when i < 0])
Vladimir Marangozova6180282000-07-12 05:05:06 +00003584fi
3585
Guido van Rossumcadfaec2001-01-05 14:45:49 +00003586# check for getc_unlocked and related locking functions
3587AC_MSG_CHECKING(for getc_unlocked() and friends)
3588AC_CACHE_VAL(ac_cv_have_getc_unlocked, [
3589AC_TRY_LINK([#include <stdio.h>],[
3590 FILE *f = fopen("/dev/null", "r");
3591 flockfile(f);
3592 getc_unlocked(f);
3593 funlockfile(f);
3594], ac_cv_have_getc_unlocked=yes, ac_cv_have_getc_unlocked=no)])
3595AC_MSG_RESULT($ac_cv_have_getc_unlocked)
3596if test "$ac_cv_have_getc_unlocked" = yes
3597then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003598 AC_DEFINE(HAVE_GETC_UNLOCKED, 1,
3599 [Define this if you have flockfile(), getc_unlocked(), and funlockfile()])
Guido van Rossumcadfaec2001-01-05 14:45:49 +00003600fi
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00003601
Neal Norwitzfe8e3d92006-01-07 21:07:20 +00003602# check where readline lives
Martin v. Löwis82bca632006-02-10 20:49:30 +00003603# save the value of LIBS so we don't actually link Python with readline
3604LIBS_no_readline=$LIBS
Gregory P. Smith18820942008-09-07 06:24:49 +00003605
3606# On some systems we need to link readline to a termcap compatible
3607# library. NOTE: Keep the precedence of listed libraries synchronised
3608# with setup.py.
3609py_cv_lib_readline=no
3610AC_MSG_CHECKING([how to link readline libs])
3611for py_libtermcap in "" ncursesw ncurses curses termcap; do
3612 if test -z "$py_libtermcap"; then
3613 READLINE_LIBS="-lreadline"
3614 else
3615 READLINE_LIBS="-lreadline -l$py_libtermcap"
3616 fi
3617 LIBS="$READLINE_LIBS $LIBS_no_readline"
3618 AC_LINK_IFELSE(
3619 [AC_LANG_CALL([],[readline])],
3620 [py_cv_lib_readline=yes])
3621 if test $py_cv_lib_readline = yes; then
3622 break
3623 fi
3624done
3625# Uncomment this line if you want to use READINE_LIBS in Makefile or scripts
3626#AC_SUBST([READLINE_LIBS])
Gregory P. Smith97515912008-09-07 19:23:19 +00003627if test $py_cv_lib_readline = no; then
Gregory P. Smith18820942008-09-07 06:24:49 +00003628 AC_MSG_RESULT([none])
3629else
3630 AC_MSG_RESULT([$READLINE_LIBS])
3631 AC_DEFINE(HAVE_LIBREADLINE, 1,
3632 [Define if you have the readline library (-lreadline).])
Neal Norwitzfe8e3d92006-01-07 21:07:20 +00003633fi
3634
Michael W. Hudson30ea2f22004-07-07 17:44:12 +00003635# check for readline 2.1
3636AC_CHECK_LIB(readline, rl_callback_handler_install,
3637 AC_DEFINE(HAVE_RL_CALLBACK, 1,
Gregory P. Smith18820942008-09-07 06:24:49 +00003638 [Define if you have readline 2.1]), ,$READLINE_LIBS)
Michael W. Hudson30ea2f22004-07-07 17:44:12 +00003639
Guido van Rossumfaf5e4d2002-12-30 16:25:41 +00003640# check for readline 2.2
3641AC_TRY_CPP([#include <readline/readline.h>],
3642have_readline=yes, have_readline=no)
3643if test $have_readline = yes
3644then
3645 AC_EGREP_HEADER([extern int rl_completion_append_character;],
3646 [readline/readline.h],
3647 AC_DEFINE(HAVE_RL_COMPLETION_APPEND_CHARACTER, 1,
3648 [Define if you have readline 2.2]), )
Antoine Pitrou37276002009-10-26 19:32:51 +00003649 AC_EGREP_HEADER([extern int rl_completion_suppress_append;],
3650 [readline/readline.h],
3651 AC_DEFINE(HAVE_RL_COMPLETION_SUPPRESS_APPEND, 1,
3652 [Define if you have rl_completion_suppress_append]), )
Guido van Rossumfaf5e4d2002-12-30 16:25:41 +00003653fi
3654
Martin v. Löwis0daad592001-09-30 21:09:59 +00003655# check for readline 4.0
3656AC_CHECK_LIB(readline, rl_pre_input_hook,
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003657 AC_DEFINE(HAVE_RL_PRE_INPUT_HOOK, 1,
Gregory P. Smith18820942008-09-07 06:24:49 +00003658 [Define if you have readline 4.0]), ,$READLINE_LIBS)
Martin v. Löwis0daad592001-09-30 21:09:59 +00003659
Thomas Wouters89d996e2007-09-08 17:39:28 +00003660# also in 4.0
3661AC_CHECK_LIB(readline, rl_completion_display_matches_hook,
3662 AC_DEFINE(HAVE_RL_COMPLETION_DISPLAY_MATCHES_HOOK, 1,
Gregory P. Smith18820942008-09-07 06:24:49 +00003663 [Define if you have readline 4.0]), ,$READLINE_LIBS)
Thomas Wouters89d996e2007-09-08 17:39:28 +00003664
Guido van Rossum353ae582001-07-10 16:45:32 +00003665# check for readline 4.2
3666AC_CHECK_LIB(readline, rl_completion_matches,
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003667 AC_DEFINE(HAVE_RL_COMPLETION_MATCHES, 1,
Gregory P. Smith18820942008-09-07 06:24:49 +00003668 [Define if you have readline 4.2]), ,$READLINE_LIBS)
Guido van Rossum353ae582001-07-10 16:45:32 +00003669
Michael W. Hudson30ea2f22004-07-07 17:44:12 +00003670# also in readline 4.2
3671AC_TRY_CPP([#include <readline/readline.h>],
3672have_readline=yes, have_readline=no)
3673if test $have_readline = yes
3674then
3675 AC_EGREP_HEADER([extern int rl_catch_signals;],
3676 [readline/readline.h],
3677 AC_DEFINE(HAVE_RL_CATCH_SIGNAL, 1,
3678 [Define if you can turn off readline's signal handling.]), )
3679fi
3680
Martin v. Löwis82bca632006-02-10 20:49:30 +00003681# End of readline checks: restore LIBS
3682LIBS=$LIBS_no_readline
3683
Thomas Wouterse38b2f12001-07-11 22:35:31 +00003684AC_MSG_CHECKING(for broken nice())
3685AC_CACHE_VAL(ac_cv_broken_nice, [
3686AC_TRY_RUN([
3687int main()
3688{
3689 int val1 = nice(1);
3690 if (val1 != -1 && val1 == nice(2))
3691 exit(0);
3692 exit(1);
3693}
Guido van Rossum3065c942001-09-17 04:03:14 +00003694],
3695ac_cv_broken_nice=yes,
3696ac_cv_broken_nice=no,
3697ac_cv_broken_nice=no)])
Thomas Wouterse38b2f12001-07-11 22:35:31 +00003698AC_MSG_RESULT($ac_cv_broken_nice)
3699if test "$ac_cv_broken_nice" = yes
3700then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003701 AC_DEFINE(HAVE_BROKEN_NICE, 1,
3702 [Define if nice() returns success/failure instead of the new priority.])
Thomas Wouterse38b2f12001-07-11 22:35:31 +00003703fi
3704
Nicholas Bastine62c5c82004-03-21 23:45:42 +00003705AC_MSG_CHECKING(for broken poll())
3706AC_TRY_RUN([
3707#include <poll.h>
3708
3709int main (void)
3710 {
3711 struct pollfd poll_struct = { 42, POLLIN|POLLPRI|POLLOUT, 0 };
3712
3713 close (42);
3714
3715 int poll_test = poll (&poll_struct, 1, 0);
3716
3717 if (poll_test < 0)
3718 {
3719 exit(0);
3720 }
3721 else if (poll_test == 0 && poll_struct.revents != POLLNVAL)
3722 {
3723 exit(0);
3724 }
3725 else
3726 {
3727 exit(1);
3728 }
3729 }
3730],
3731ac_cv_broken_poll=yes,
3732ac_cv_broken_poll=no,
3733ac_cv_broken_poll=no)
3734AC_MSG_RESULT($ac_cv_broken_poll)
3735if test "$ac_cv_broken_poll" = yes
3736then
3737 AC_DEFINE(HAVE_BROKEN_POLL, 1,
3738 [Define if poll() sets errno on invalid file descriptors.])
3739fi
3740
Brett Cannon43802422005-02-10 20:48:03 +00003741# Before we can test tzset, we need to check if struct tm has a tm_zone
3742# (which is not required by ISO C or UNIX spec) and/or if we support
3743# tzname[]
3744AC_STRUCT_TIMEZONE
Nicholas Bastine62c5c82004-03-21 23:45:42 +00003745
Brett Cannon43802422005-02-10 20:48:03 +00003746# check tzset(3) exists and works like we expect it to
Guido van Rossumd11b62e2003-03-14 21:51:36 +00003747AC_MSG_CHECKING(for working tzset())
3748AC_CACHE_VAL(ac_cv_working_tzset, [
3749AC_TRY_RUN([
3750#include <stdlib.h>
3751#include <time.h>
Brett Cannon18367812003-09-19 00:59:16 +00003752#include <string.h>
Brett Cannon43802422005-02-10 20:48:03 +00003753
3754#if HAVE_TZNAME
3755extern char *tzname[];
3756#endif
3757
Guido van Rossumd11b62e2003-03-14 21:51:36 +00003758int main()
3759{
Brett Cannon18367812003-09-19 00:59:16 +00003760 /* Note that we need to ensure that not only does tzset(3)
3761 do 'something' with localtime, but it works as documented
3762 in the library reference and as expected by the test suite.
Brett Cannon43802422005-02-10 20:48:03 +00003763 This includes making sure that tzname is set properly if
3764 tm->tm_zone does not exist since it is the alternative way
3765 of getting timezone info.
Brett Cannon18367812003-09-19 00:59:16 +00003766
3767 Red Hat 6.2 doesn't understand the southern hemisphere
Brett Cannon43802422005-02-10 20:48:03 +00003768 after New Year's Day.
Brett Cannon18367812003-09-19 00:59:16 +00003769 */
3770
Brett Cannon43802422005-02-10 20:48:03 +00003771 time_t groundhogday = 1044144000; /* GMT-based */
Brett Cannon18367812003-09-19 00:59:16 +00003772 time_t midyear = groundhogday + (365 * 24 * 3600 / 2);
3773
Neal Norwitz7f2588c2003-04-11 15:35:53 +00003774 putenv("TZ=UTC+0");
Guido van Rossumd11b62e2003-03-14 21:51:36 +00003775 tzset();
Brett Cannon18367812003-09-19 00:59:16 +00003776 if (localtime(&groundhogday)->tm_hour != 0)
3777 exit(1);
Brett Cannon43802422005-02-10 20:48:03 +00003778#if HAVE_TZNAME
3779 /* For UTC, tzname[1] is sometimes "", sometimes " " */
3780 if (strcmp(tzname[0], "UTC") ||
3781 (tzname[1][0] != 0 && tzname[1][0] != ' '))
3782 exit(1);
3783#endif
Brett Cannon18367812003-09-19 00:59:16 +00003784
Neal Norwitz7f2588c2003-04-11 15:35:53 +00003785 putenv("TZ=EST+5EDT,M4.1.0,M10.5.0");
Guido van Rossumd11b62e2003-03-14 21:51:36 +00003786 tzset();
Brett Cannon18367812003-09-19 00:59:16 +00003787 if (localtime(&groundhogday)->tm_hour != 19)
Guido van Rossumd11b62e2003-03-14 21:51:36 +00003788 exit(1);
Brett Cannon43802422005-02-10 20:48:03 +00003789#if HAVE_TZNAME
3790 if (strcmp(tzname[0], "EST") || strcmp(tzname[1], "EDT"))
3791 exit(1);
3792#endif
Brett Cannon18367812003-09-19 00:59:16 +00003793
3794 putenv("TZ=AEST-10AEDT-11,M10.5.0,M3.5.0");
3795 tzset();
3796 if (localtime(&groundhogday)->tm_hour != 11)
3797 exit(1);
Brett Cannon43802422005-02-10 20:48:03 +00003798#if HAVE_TZNAME
3799 if (strcmp(tzname[0], "AEST") || strcmp(tzname[1], "AEDT"))
3800 exit(1);
3801#endif
3802
3803#if HAVE_STRUCT_TM_TM_ZONE
Brett Cannon18367812003-09-19 00:59:16 +00003804 if (strcmp(localtime(&groundhogday)->tm_zone, "AEDT"))
3805 exit(1);
3806 if (strcmp(localtime(&midyear)->tm_zone, "AEST"))
3807 exit(1);
Brett Cannon43802422005-02-10 20:48:03 +00003808#endif
Brett Cannon18367812003-09-19 00:59:16 +00003809
Guido van Rossumd11b62e2003-03-14 21:51:36 +00003810 exit(0);
3811}
3812],
3813ac_cv_working_tzset=yes,
3814ac_cv_working_tzset=no,
3815ac_cv_working_tzset=no)])
3816AC_MSG_RESULT($ac_cv_working_tzset)
3817if test "$ac_cv_working_tzset" = yes
3818then
3819 AC_DEFINE(HAVE_WORKING_TZSET, 1,
3820 [Define if tzset() actually switches the local timezone in a meaningful way.])
3821fi
3822
Martin v. Löwis94717ed2002-09-09 14:24:16 +00003823# Look for subsecond timestamps in struct stat
3824AC_MSG_CHECKING(for tv_nsec in struct stat)
3825AC_CACHE_VAL(ac_cv_stat_tv_nsec,
3826AC_TRY_COMPILE([#include <sys/stat.h>], [
3827struct stat st;
3828st.st_mtim.tv_nsec = 1;
3829],
Martin v. Löwisa32c9942002-09-09 16:17:47 +00003830ac_cv_stat_tv_nsec=yes,
Martin v. Löwis94717ed2002-09-09 14:24:16 +00003831ac_cv_stat_tv_nsec=no,
3832ac_cv_stat_tv_nsec=no))
3833AC_MSG_RESULT($ac_cv_stat_tv_nsec)
3834if test "$ac_cv_stat_tv_nsec" = yes
3835then
3836 AC_DEFINE(HAVE_STAT_TV_NSEC, 1,
3837 [Define if you have struct stat.st_mtim.tv_nsec])
3838fi
3839
Martin v. Löwisebd9d5b2005-08-09 15:00:59 +00003840# Look for BSD style subsecond timestamps in struct stat
3841AC_MSG_CHECKING(for tv_nsec2 in struct stat)
3842AC_CACHE_VAL(ac_cv_stat_tv_nsec2,
3843AC_TRY_COMPILE([#include <sys/stat.h>], [
3844struct stat st;
3845st.st_mtimespec.tv_nsec = 1;
3846],
3847ac_cv_stat_tv_nsec2=yes,
3848ac_cv_stat_tv_nsec2=no,
3849ac_cv_stat_tv_nsec2=no))
3850AC_MSG_RESULT($ac_cv_stat_tv_nsec2)
3851if test "$ac_cv_stat_tv_nsec2" = yes
3852then
3853 AC_DEFINE(HAVE_STAT_TV_NSEC2, 1,
3854 [Define if you have struct stat.st_mtimensec])
3855fi
3856
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00003857# On HP/UX 11.0, mvwdelch is a block with a return statement
3858AC_MSG_CHECKING(whether mvwdelch is an expression)
3859AC_CACHE_VAL(ac_cv_mvwdelch_is_expression,
3860AC_TRY_COMPILE([#include <curses.h>], [
3861 int rtn;
3862 rtn = mvwdelch(0,0,0);
3863], ac_cv_mvwdelch_is_expression=yes,
3864 ac_cv_mvwdelch_is_expression=no,
3865 ac_cv_mvwdelch_is_expression=yes))
3866AC_MSG_RESULT($ac_cv_mvwdelch_is_expression)
3867
3868if test "$ac_cv_mvwdelch_is_expression" = yes
3869then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003870 AC_DEFINE(MVWDELCH_IS_EXPRESSION, 1,
3871 [Define if mvwdelch in curses.h is an expression.])
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00003872fi
3873
3874AC_MSG_CHECKING(whether WINDOW has _flags)
3875AC_CACHE_VAL(ac_cv_window_has_flags,
3876AC_TRY_COMPILE([#include <curses.h>], [
3877 WINDOW *w;
3878 w->_flags = 0;
3879], ac_cv_window_has_flags=yes,
3880 ac_cv_window_has_flags=no,
3881 ac_cv_window_has_flags=no))
3882AC_MSG_RESULT($ac_cv_window_has_flags)
3883
3884
3885if test "$ac_cv_window_has_flags" = yes
3886then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003887 AC_DEFINE(WINDOW_HAS_FLAGS, 1,
3888 [Define if WINDOW in curses.h offers a field _flags.])
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00003889fi
3890
Thomas Wouters0e3f5912006-08-11 14:57:12 +00003891AC_MSG_CHECKING(for is_term_resized)
3892AC_TRY_COMPILE([#include <curses.h>], void *x=is_term_resized,
3893 AC_DEFINE(HAVE_CURSES_IS_TERM_RESIZED, 1, Define if you have the 'is_term_resized' function.)
3894 AC_MSG_RESULT(yes),
Martin v. Löwis24a880b2002-12-31 12:55:15 +00003895 AC_MSG_RESULT(no)
Thomas Wouters0e3f5912006-08-11 14:57:12 +00003896)
Martin v. Löwis24a880b2002-12-31 12:55:15 +00003897
Thomas Wouters0e3f5912006-08-11 14:57:12 +00003898AC_MSG_CHECKING(for resize_term)
3899AC_TRY_COMPILE([#include <curses.h>], void *x=resize_term,
3900 AC_DEFINE(HAVE_CURSES_RESIZE_TERM, 1, Define if you have the 'resize_term' function.)
3901 AC_MSG_RESULT(yes),
Neal Norwitz865400f2003-03-21 01:42:58 +00003902 AC_MSG_RESULT(no)
Thomas Wouters0e3f5912006-08-11 14:57:12 +00003903)
3904
3905AC_MSG_CHECKING(for resizeterm)
3906AC_TRY_COMPILE([#include <curses.h>], void *x=resizeterm,
3907 AC_DEFINE(HAVE_CURSES_RESIZETERM, 1, Define if you have the 'resizeterm' function.)
3908 AC_MSG_RESULT(yes),
3909 AC_MSG_RESULT(no)
3910)
3911
Thomas Wouters89f507f2006-12-13 04:49:30 +00003912AC_MSG_CHECKING(for /dev/ptmx)
3913
3914if test -r /dev/ptmx
3915then
3916 AC_MSG_RESULT(yes)
3917 AC_DEFINE(HAVE_DEV_PTMX, 1,
3918 [Define if we have /dev/ptmx.])
3919else
3920 AC_MSG_RESULT(no)
3921fi
3922
3923AC_MSG_CHECKING(for /dev/ptc)
3924
3925if test -r /dev/ptc
3926then
3927 AC_MSG_RESULT(yes)
3928 AC_DEFINE(HAVE_DEV_PTC, 1,
3929 [Define if we have /dev/ptc.])
3930else
3931 AC_MSG_RESULT(no)
3932fi
Neal Norwitz865400f2003-03-21 01:42:58 +00003933
Thomas Wouters477c8d52006-05-27 19:21:47 +00003934AC_MSG_CHECKING(for %zd printf() format support)
3935AC_TRY_RUN([#include <stdio.h>
3936#include <stddef.h>
3937#include <string.h>
3938
Christian Heimes2c181612007-12-17 20:04:13 +00003939#ifdef HAVE_SYS_TYPES_H
3940#include <sys/types.h>
3941#endif
Thomas Wouters89f507f2006-12-13 04:49:30 +00003942
3943#ifdef HAVE_SSIZE_T
3944typedef ssize_t Py_ssize_t;
3945#elif SIZEOF_VOID_P == SIZEOF_LONG
3946typedef long Py_ssize_t;
3947#else
3948typedef int Py_ssize_t;
3949#endif
Thomas Wouters477c8d52006-05-27 19:21:47 +00003950
Christian Heimes2c181612007-12-17 20:04:13 +00003951int main()
3952{
3953 char buffer[256];
3954
Thomas Wouters477c8d52006-05-27 19:21:47 +00003955 if(sprintf(buffer, "%zd", (size_t)123) < 0)
3956 return 1;
3957
Thomas Wouters89f507f2006-12-13 04:49:30 +00003958 if (strcmp(buffer, "123"))
Thomas Wouters477c8d52006-05-27 19:21:47 +00003959 return 1;
Thomas Wouters89f507f2006-12-13 04:49:30 +00003960
3961 if (sprintf(buffer, "%zd", (Py_ssize_t)-123) < 0)
3962 return 1;
3963
3964 if (strcmp(buffer, "-123"))
3965 return 1;
3966
Thomas Wouters477c8d52006-05-27 19:21:47 +00003967 return 0;
3968}],
3969[AC_MSG_RESULT(yes)
3970 AC_DEFINE(PY_FORMAT_SIZE_T, "z", [Define to printf format modifier for Py_ssize_t])],
3971 AC_MSG_RESULT(no))
3972
Martin v. Löwis01c04012002-11-11 14:58:44 +00003973AC_CHECK_TYPE(socklen_t,,
3974 AC_DEFINE(socklen_t,int,
3975 Define to `int' if <sys/socket.h> does not define.),[
3976#ifdef HAVE_SYS_TYPES_H
3977#include <sys/types.h>
3978#endif
Guido van Rossum95713eb2000-05-18 20:53:31 +00003979#ifdef HAVE_SYS_SOCKET_H
3980#include <sys/socket.h>
3981#endif
Martin v. Löwis01c04012002-11-11 14:58:44 +00003982])
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00003983
Antoine Pitroufff95302008-09-03 18:58:51 +00003984AC_MSG_CHECKING(for broken mbstowcs)
3985AC_TRY_RUN([
3986#include<stdlib.h>
3987int main() {
3988 size_t len = -1;
3989 const char *str = "text";
3990 len = mbstowcs(NULL, str, 0);
3991 return (len != 4);
3992}
3993],
3994ac_cv_broken_mbstowcs=no,
3995ac_cv_broken_mbstowcs=yes,
3996ac_cv_broken_mbstowcs=no)
3997AC_MSG_RESULT($ac_cv_broken_mbstowcs)
3998if test "$ac_cv_broken_mbstowcs" = yes
3999then
4000 AC_DEFINE(HAVE_BROKEN_MBSTOWCS, 1,
4001 [Define if mbstowcs(NULL, "text", 0) does not return the number of
4002 wide chars that would be converted.])
4003fi
4004
Antoine Pitroub52ec782009-01-25 16:34:23 +00004005# Check for --with-computed-gotos
4006AC_MSG_CHECKING(for --with-computed-gotos)
4007AC_ARG_WITH(computed-gotos,
4008 AC_HELP_STRING(--with-computed-gotos,
4009 Use computed gotos / threaded dispatch in evaluation loop (not available on all compilers)),
4010[
4011if test "$withval" != no
4012then
4013 AC_DEFINE(USE_COMPUTED_GOTOS, 1,
4014 [Define if you want to use computed gotos in ceval.c.])
4015 AC_MSG_RESULT(yes)
4016else AC_MSG_RESULT(no)
4017fi],
4018[AC_MSG_RESULT(no)])
4019
Ronald Oussoren1b2cad02009-11-19 17:30:05 +00004020if test $ac_sys_system = Darwin
4021then
4022 LIBS="$LIBS -framework CoreFoundation"
4023fi
4024
4025
Antoine Pitroub52ec782009-01-25 16:34:23 +00004026
Martin v. Löwis06f15bb2001-12-02 13:02:32 +00004027AC_SUBST(THREADHEADERS)
4028
4029for h in `(cd $srcdir;echo Python/thread_*.h)`
4030do
4031 THREADHEADERS="$THREADHEADERS \$(srcdir)/$h"
4032done
4033
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00004034AC_SUBST(SRCDIRS)
Neal Norwitzd24499d2005-12-18 21:36:39 +00004035SRCDIRS="Parser Grammar Objects Python Modules Mac"
Andrew M. Kuchling8abedde2001-01-26 22:55:24 +00004036AC_MSG_CHECKING(for build directories)
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00004037for dir in $SRCDIRS; do
4038 if test ! -d $dir; then
4039 mkdir $dir
Fred Drake884d3ba2000-11-02 17:52:56 +00004040 fi
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00004041done
4042AC_MSG_RESULT(done)
Fred Drake036144d2000-10-26 17:09:35 +00004043
Guido van Rossum627b2d71993-12-24 10:39:16 +00004044# generate output files
Antoine Pitrou20327222009-05-24 20:39:11 +00004045AC_CONFIG_FILES(Makefile.pre Modules/Setup.config Misc/python.pc)
Martin v. Löwis88afe662002-10-26 13:47:44 +00004046AC_OUTPUT
Neil Schemenauer61c51152001-01-26 16:18:16 +00004047
Thomas Wouters49fd7fa2006-04-21 10:40:58 +00004048echo "creating Modules/Setup"
Neil Schemenauer61c51152001-01-26 16:18:16 +00004049if test ! -f Modules/Setup
4050then
4051 cp $srcdir/Modules/Setup.dist Modules/Setup
4052fi
4053
Thomas Wouters49fd7fa2006-04-21 10:40:58 +00004054echo "creating Modules/Setup.local"
Neil Schemenauer61c51152001-01-26 16:18:16 +00004055if test ! -f Modules/Setup.local
4056then
4057 echo "# Edit this file for local setup changes" >Modules/Setup.local
4058fi
4059
4060echo "creating Makefile"
4061$SHELL $srcdir/Modules/makesetup -c $srcdir/Modules/config.c.in \
4062 -s Modules Modules/Setup.config \
Neil Schemenauerf8b71c52001-04-21 17:41:16 +00004063 Modules/Setup.local Modules/Setup
Neil Schemenauer66252162001-02-19 04:47:42 +00004064mv config.c Modules